diff --git a/.azure-pipelines/azure-pipelines-build.yml b/.azure-pipelines/azure-pipelines-build.yml index 835e2fcf652..cd0b12b7968 100644 --- a/.azure-pipelines/azure-pipelines-build.yml +++ b/.azure-pipelines/azure-pipelines-build.yml @@ -103,12 +103,6 @@ jobs: syncd_rpc_image: yes platform_rpc: mlnx - - name: nephos - variables: - dbg_image: yes - docker_syncd_rpc_image: yes - platform_rpc: nephos - - name: pensando pool: sonicso1ES-arm64 variables: @@ -235,4 +229,3 @@ jobs: BuildDropPath: '$(System.DefaultWorkingDirectory)/target/' ManifestDirPath: 'target/' BuildComponentPath: $(System.DefaultWorkingDirectory)/src/ - diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3400e16cf5f..0c5090568b5 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -80,7 +80,6 @@ /platform/mellanox/ @sonic-net/sonic-mellanox-maintainer /device/nvidia-bluefield/ @sonic-net/sonic-mellanox-maintainer /platform/nvidia-bluefield/ @sonic-net/sonic-mellanox-maintainer -/platform/nephos/ @sonic-net/sonic-nephos-maintainer /device/nexthop/ @sonic-net/sonic-nexthop-maintainer /platform/aspeed/sonic-platform-modules-nexthop/ @sonic-net/sonic-nexthop-maintainer /platform/broadcom/sonic-platform-modules/nexthop/ @sonic-net/sonic-nexthop-maintainer diff --git a/.github/ISSUE_TEMPLATE/01-bug.yml b/.github/ISSUE_TEMPLATE/01-bug.yml index ed8ed501d62..951a00b4d5e 100644 --- a/.github/ISSUE_TEMPLATE/01-bug.yml +++ b/.github/ISSUE_TEMPLATE/01-bug.yml @@ -34,7 +34,6 @@ body: - innovium - marvell - mellanox - - nephos default: 0 validations: required: true diff --git a/.github/ISSUE_TEMPLATE/02-enhancement.yml b/.github/ISSUE_TEMPLATE/02-enhancement.yml index 52e116f239e..25a4f9ec911 100644 --- a/.github/ISSUE_TEMPLATE/02-enhancement.yml +++ b/.github/ISSUE_TEMPLATE/02-enhancement.yml @@ -23,7 +23,6 @@ body: - innovium - marvell - mellanox - - nephos default: 0 validations: required: true diff --git a/.github/ISSUE_TEMPLATE/04-regression.yml b/.github/ISSUE_TEMPLATE/04-regression.yml index 787a4bdbd5a..fe4224fcc2f 100644 --- a/.github/ISSUE_TEMPLATE/04-regression.yml +++ b/.github/ISSUE_TEMPLATE/04-regression.yml @@ -28,7 +28,6 @@ body: - innovium - marvell - mellanox - - nephos default: 0 validations: required: true diff --git a/README.md b/README.md index 6440eca0487..82f46a7eb1f 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,6 @@ The supported ASIC vendors are: * PLATFORM=marvell-teralynx * PLATFORM=mellanox * PLATFORM=centec -* PLATFORM=nephos * PLATFORM=nvidia-bluefield * PLATFORM=vs @@ -400,8 +399,6 @@ reproducibility notes, and known limitations. and Cavium switch ASIC (gzip tar archive) * docker-syncd-mlnx.gz: docker image for the daemon to sync database and Mellanox switch ASIC (gzip tar archive) - * docker-syncd-nephos.gz: docker image for the daemon to sync database - and Nephos switch ASIC (gzip tar archive) * docker-syncd-mrvl-teralynx.gz: docker image for the daemon to sync database and Marvell-Teralynx switch ASIC (gzip tar archive) * docker-syncd-mrvl-prestera.gz: docker image for the daemon to sync database diff --git a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/buffers.json.j2 b/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/buffers.json.j2 deleted file mode 100644 index 9354b7ec5b5..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/buffers.json.j2 +++ /dev/null @@ -1,2 +0,0 @@ -{%- set default_topo = 't0' %} -{%- include 'buffers_config.j2' %} \ No newline at end of file diff --git a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/buffers_defaults_t0.j2 b/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/buffers_defaults_t0.j2 deleted file mode 100644 index 6673155a3d6..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/buffers_defaults_t0.j2 +++ /dev/null @@ -1,72 +0,0 @@ -{% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '20971328' %} -{% set ingress_lossy_pool_size = '20971328' %} -{% set egress_lossless_pool_size = '20971328' %} -{% set egress_lossy_pool_size = '20971328' %} - -{%- macro generate_port_lists(PORT_ALL) %} - {# Generate list of ports #} - {%- for port_idx in range(0, 48) %} - {%- if PORT_ALL.append("Ethernet%d" % (port_idx)) %}{%- endif %} - {%- endfor %} - {%- for port_idx in range(48, 54) %} - {%- if PORT_ALL.append("Ethernet%d" % (48 + (port_idx-48) * 4)) %}{%- endif %} - {%- endfor %} -{%- endmacro %} - -{%- macro generate_buffer_pool_and_profiles() %} - "BUFFER_POOL": { - "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", - "type": "ingress", - "mode": "static" - }, - "ingress_lossy_pool": { - "size": "{{ ingress_lossy_pool_size }}", - "type": "ingress", - "mode": "dynamic" - }, - "egress_lossless_pool": { - "size": "{{ egress_lossless_pool_size }}", - "type": "egress", - "mode": "static" - }, - "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", - "type": "egress", - "mode": "dynamic" - } - }, - "BUFFER_PROFILE": { - "ingress_lossless_profile": { - "pool":"ingress_lossless_pool", - "xon":"78400", - "xoff":"132160", - "size":"3584", - "static_th":"82880" - }, - "ingress_lossy_profile": { - "pool":"ingress_lossy_pool", - "size":"3584", - "dynamic_th":"-1" - }, - "egress_lossy_profile": { - "pool":"egress_lossy_pool", - "size":"3584", - "dynamic_th":"-4" - } - }, -{%- endmacro %} - -{# the typo of generate_pg_profils dued to buffers_config.j2 #} -{# Default, we do not bind any buffer profiles. #} -{%- macro generate_pg_profils(port_names) %} - "BUFFER_PG": { - } -{%- endmacro %} - -{# Default, we do not bind any buffer profiles. #} -{%- macro generate_queue_buffers(port_names) %} - "BUFFER_QUEUE": { - } -{%- endmacro %} \ No newline at end of file diff --git a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/buffers_defaults_t1.j2 b/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/buffers_defaults_t1.j2 deleted file mode 100644 index 6673155a3d6..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/buffers_defaults_t1.j2 +++ /dev/null @@ -1,72 +0,0 @@ -{% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '20971328' %} -{% set ingress_lossy_pool_size = '20971328' %} -{% set egress_lossless_pool_size = '20971328' %} -{% set egress_lossy_pool_size = '20971328' %} - -{%- macro generate_port_lists(PORT_ALL) %} - {# Generate list of ports #} - {%- for port_idx in range(0, 48) %} - {%- if PORT_ALL.append("Ethernet%d" % (port_idx)) %}{%- endif %} - {%- endfor %} - {%- for port_idx in range(48, 54) %} - {%- if PORT_ALL.append("Ethernet%d" % (48 + (port_idx-48) * 4)) %}{%- endif %} - {%- endfor %} -{%- endmacro %} - -{%- macro generate_buffer_pool_and_profiles() %} - "BUFFER_POOL": { - "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", - "type": "ingress", - "mode": "static" - }, - "ingress_lossy_pool": { - "size": "{{ ingress_lossy_pool_size }}", - "type": "ingress", - "mode": "dynamic" - }, - "egress_lossless_pool": { - "size": "{{ egress_lossless_pool_size }}", - "type": "egress", - "mode": "static" - }, - "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", - "type": "egress", - "mode": "dynamic" - } - }, - "BUFFER_PROFILE": { - "ingress_lossless_profile": { - "pool":"ingress_lossless_pool", - "xon":"78400", - "xoff":"132160", - "size":"3584", - "static_th":"82880" - }, - "ingress_lossy_profile": { - "pool":"ingress_lossy_pool", - "size":"3584", - "dynamic_th":"-1" - }, - "egress_lossy_profile": { - "pool":"egress_lossy_pool", - "size":"3584", - "dynamic_th":"-4" - } - }, -{%- endmacro %} - -{# the typo of generate_pg_profils dued to buffers_config.j2 #} -{# Default, we do not bind any buffer profiles. #} -{%- macro generate_pg_profils(port_names) %} - "BUFFER_PG": { - } -{%- endmacro %} - -{# Default, we do not bind any buffer profiles. #} -{%- macro generate_queue_buffers(port_names) %} - "BUFFER_QUEUE": { - } -{%- endmacro %} \ No newline at end of file diff --git a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/led.bin b/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/led.bin deleted file mode 100644 index bb4426fb59f..00000000000 Binary files a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/led.bin and /dev/null differ diff --git a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/nephos_dac.dsh b/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/nephos_dac.dsh deleted file mode 100644 index 42102053c3f..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/nephos_dac.dsh +++ /dev/null @@ -1,414 +0,0 @@ -init start stage unit=0 low-level -init set port-map unit=0 port=0 eth-macro=2 lane=0 max-speed=25g active=true -init set port-map unit=0 port=1 eth-macro=2 lane=1 max-speed=25g active=true -init set port-map unit=0 port=2 eth-macro=2 lane=2 max-speed=25g active=true -init set port-map unit=0 port=3 eth-macro=2 lane=3 max-speed=25g active=true -init set port-map unit=0 port=4 eth-macro=3 lane=0 max-speed=25g active=true -init set port-map unit=0 port=5 eth-macro=3 lane=1 max-speed=25g active=true -init set port-map unit=0 port=6 eth-macro=3 lane=2 max-speed=25g active=true -init set port-map unit=0 port=7 eth-macro=3 lane=3 max-speed=25g active=true -init set port-map unit=0 port=8 eth-macro=4 lane=0 max-speed=25g active=true -init set port-map unit=0 port=9 eth-macro=4 lane=1 max-speed=25g active=true -init set port-map unit=0 port=10 eth-macro=4 lane=2 max-speed=25g active=true -init set port-map unit=0 port=11 eth-macro=4 lane=3 max-speed=25g active=true -init set port-map unit=0 port=12 eth-macro=5 lane=0 max-speed=25g active=true -init set port-map unit=0 port=13 eth-macro=5 lane=1 max-speed=25g active=true -init set port-map unit=0 port=14 eth-macro=5 lane=2 max-speed=25g active=true -init set port-map unit=0 port=15 eth-macro=5 lane=3 max-speed=25g active=true -init set port-map unit=0 port=16 eth-macro=8 lane=0 max-speed=25g active=true -init set port-map unit=0 port=17 eth-macro=8 lane=1 max-speed=25g active=true -init set port-map unit=0 port=18 eth-macro=8 lane=2 max-speed=25g active=true -init set port-map unit=0 port=19 eth-macro=8 lane=3 max-speed=25g active=true -init set port-map unit=0 port=20 eth-macro=10 lane=0 max-speed=25g active=true -init set port-map unit=0 port=21 eth-macro=10 lane=1 max-speed=25g active=true -init set port-map unit=0 port=22 eth-macro=10 lane=2 max-speed=25g active=true -init set port-map unit=0 port=23 eth-macro=10 lane=3 max-speed=25g active=true -init set port-map unit=0 port=24 eth-macro=12 lane=0 max-speed=25g active=true -init set port-map unit=0 port=25 eth-macro=12 lane=1 max-speed=25g active=true -init set port-map unit=0 port=26 eth-macro=12 lane=2 max-speed=25g active=true -init set port-map unit=0 port=27 eth-macro=12 lane=3 max-speed=25g active=true -init set port-map unit=0 port=28 eth-macro=14 lane=0 max-speed=25g active=true -init set port-map unit=0 port=29 eth-macro=14 lane=1 max-speed=25g active=true -init set port-map unit=0 port=30 eth-macro=14 lane=2 max-speed=25g active=true -init set port-map unit=0 port=31 eth-macro=14 lane=3 max-speed=25g active=true -init set port-map unit=0 port=32 eth-macro=16 lane=0 max-speed=25g active=true -init set port-map unit=0 port=33 eth-macro=16 lane=1 max-speed=25g active=true -init set port-map unit=0 port=34 eth-macro=16 lane=2 max-speed=25g active=true -init set port-map unit=0 port=35 eth-macro=16 lane=3 max-speed=25g active=true -init set port-map unit=0 port=36 eth-macro=17 lane=0 max-speed=25g active=true -init set port-map unit=0 port=37 eth-macro=17 lane=1 max-speed=25g active=true -init set port-map unit=0 port=38 eth-macro=17 lane=2 max-speed=25g active=true -init set port-map unit=0 port=39 eth-macro=17 lane=3 max-speed=25g active=true -init set port-map unit=0 port=40 eth-macro=18 lane=0 max-speed=25g active=true -init set port-map unit=0 port=41 eth-macro=18 lane=1 max-speed=25g active=true -init set port-map unit=0 port=42 eth-macro=18 lane=2 max-speed=25g active=true -init set port-map unit=0 port=43 eth-macro=18 lane=3 max-speed=25g active=true -init set port-map unit=0 port=44 eth-macro=19 lane=0 max-speed=25g active=true -init set port-map unit=0 port=45 eth-macro=19 lane=1 max-speed=25g active=true -init set port-map unit=0 port=46 eth-macro=19 lane=2 max-speed=25g active=true -init set port-map unit=0 port=47 eth-macro=19 lane=3 max-speed=25g active=true -init set port-map unit=0 port=48 eth-macro=21 lane=0 max-speed=100g active=true -init set port-map unit=0 port=49 eth-macro=20 lane=0 max-speed=100g active=true -init set port-map unit=0 port=50 eth-macro=26 lane=0 max-speed=100g active=true -init set port-map unit=0 port=51 eth-macro=27 lane=0 max-speed=100g active=true -init set port-map unit=0 port=52 eth-macro=28 lane=0 max-speed=100g active=true -init set port-map unit=0 port=53 eth-macro=29 lane=0 max-speed=100g active=true -init set port-map unit=0 port=129 eth-macro=0 lane=1 max-speed=10g active=true guarantee=true cpi=true -init set port-map unit=0 port=130 eth-macro=0 lane=0 max-speed=10g active=true guarantee=true cpi=true init-done=true -init start stage unit=0 task-rsrc -init start stage unit=0 module -init start stage unit=0 task -phy set lane-swap unit=0 portlist=0 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=1 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=2 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=3 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=4 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=5 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=6 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=7 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=8 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=9 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=10 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=11 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=12 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=13 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=14 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=15 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=16 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=17 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=18 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=19 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=20 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=21 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=22 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=23 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=24 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=25 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=26 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=27 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=28 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=29 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=30 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=31 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=32 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=33 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=34 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=35 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=36 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=37 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=38 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=39 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=40 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=41 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=42 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=43 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=44 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=45 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=46 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=47 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=48 lane-cnt=4 property=tx data=0x1.3.0.2 -phy set lane-swap unit=0 portlist=49 lane-cnt=4 property=tx data=0x0.3.1.2 -phy set lane-swap unit=0 portlist=50 lane-cnt=4 property=tx data=0x1.3.0.2 -phy set lane-swap unit=0 portlist=51 lane-cnt=4 property=tx data=0x2.0.3.1 -phy set lane-swap unit=0 portlist=52 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=53 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=0 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=1 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=2 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=3 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=4 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=5 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=6 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=7 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=8 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=9 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=10 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=11 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=12 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=13 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=14 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=15 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=16 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=17 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=18 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=19 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=20 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=21 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=22 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=23 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=24 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=25 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=26 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=27 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=28 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=29 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=30 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=31 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=32 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=33 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=34 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=35 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=36 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=37 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=38 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=39 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=40 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=41 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=42 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=43 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=44 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=45 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=46 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=47 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=48 lane-cnt=4 property=rx data=0x2.1.0.3 -phy set lane-swap unit=0 portlist=49 lane-cnt=4 property=rx data=0x0.1.3.2 -phy set lane-swap unit=0 portlist=50 lane-cnt=4 property=rx data=0x3.1.0.2 -phy set lane-swap unit=0 portlist=51 lane-cnt=4 property=rx data=0x1.3.0.2 -phy set lane-swap unit=0 portlist=52 lane-cnt=4 property=rx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=53 lane-cnt=4 property=rx data=0x3.2.1.0 -phy set polarity-rev unit=0 portlist=0 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=1 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=2 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=3 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=4 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=5 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=6 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=7 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=8 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=9 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=10 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=11 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=12 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=13 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=14 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=15 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=16 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=17 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=18 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=19 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=20 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=21 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=22 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=23 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=24 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=25 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=26 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=27 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=28 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=29 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=30 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=31 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=32 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=33 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=34 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=35 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=36 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=37 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=38 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=39 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=40 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=41 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=42 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=43 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=44 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=45 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=46 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=47 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=48 lane-cnt=4 property=tx data=0x0.0.0.1 -phy set polarity-rev unit=0 portlist=49 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=50 lane-cnt=4 property=tx data=0x1.1.0.0 -phy set polarity-rev unit=0 portlist=51 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=52 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=53 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=0 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=1 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=2 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=3 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=4 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=5 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=6 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=7 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=8 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=9 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=10 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=11 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=12 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=13 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=14 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=15 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=16 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=17 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=18 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=19 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=20 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=21 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=22 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=23 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=24 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=25 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=26 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=27 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=28 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=29 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=30 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=31 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=32 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=33 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=34 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=35 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=36 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=37 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=38 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=39 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=40 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=41 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=42 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=43 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=44 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=45 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=46 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=47 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=48 lane-cnt=4 property=rx data=0x0.1.0.1 -phy set polarity-rev unit=0 portlist=49 lane-cnt=4 property=rx data=0x1.0.1.0 -phy set polarity-rev unit=0 portlist=50 lane-cnt=4 property=rx data=0x0.0.1.0 -phy set polarity-rev unit=0 portlist=51 lane-cnt=4 property=rx data=0x0.0.0.1 -phy set polarity-rev unit=0 portlist=52 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=53 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=0 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=4 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=8 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=12 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=16 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=20 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=24 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=28 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=32 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=36 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=40 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=44 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c2 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=cn1 data=0x4.4.4.4 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c0 data=0x1e.1e.1e.1e -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c1 data=0x2.2.2.2 -phy set mdio portlist=0 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=1 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=2 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=3 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=4 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=5 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=6 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=7 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=8 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=9 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=10 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=11 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=12 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=13 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=14 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=15 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=16 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=17 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=18 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=19 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=20 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=21 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=22 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=23 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=24 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=25 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=26 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=27 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=28 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=29 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=30 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=31 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=32 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=33 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=34 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=35 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=36 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=37 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=38 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=39 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=40 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=41 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=42 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=43 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=44 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=45 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=46 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=47 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=48 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=49 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=50 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=51 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=52 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=53 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=129 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=130 devad=0x1E addr=0x2 data=0x0000 -port set property unit=0 portlist=0-47 speed=25g -port set property unit=0 portlist=48-53 speed=100g -port set property unit=0 portlist=129-130 speed=10g -port set property unit=0 portlist=0-47 medium-type=cr -port set property unit=0 portlist=48-53 medium-type=cr4 -port set property unit=0 portlist=129-130 medium-type=kr -port set adver unit=0 portlist=129-130 speed-10g-kr -port set property unit=0 portlist=129-130 an=enable -port set property unit=0 portlist=129-130 admin=enable -port set property unit=0 portlist=0-53 admin=disable diff --git a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/nephos_opt.dsh b/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/nephos_opt.dsh deleted file mode 100644 index ca2bc649768..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/nephos_opt.dsh +++ /dev/null @@ -1,415 +0,0 @@ -init start stage unit=0 low-level -init set port-map unit=0 port=0 eth-macro=2 lane=0 max-speed=25g active=true -init set port-map unit=0 port=1 eth-macro=2 lane=1 max-speed=25g active=true -init set port-map unit=0 port=2 eth-macro=2 lane=2 max-speed=25g active=true -init set port-map unit=0 port=3 eth-macro=2 lane=3 max-speed=25g active=true -init set port-map unit=0 port=4 eth-macro=3 lane=0 max-speed=25g active=true -init set port-map unit=0 port=5 eth-macro=3 lane=1 max-speed=25g active=true -init set port-map unit=0 port=6 eth-macro=3 lane=2 max-speed=25g active=true -init set port-map unit=0 port=7 eth-macro=3 lane=3 max-speed=25g active=true -init set port-map unit=0 port=8 eth-macro=4 lane=0 max-speed=25g active=true -init set port-map unit=0 port=9 eth-macro=4 lane=1 max-speed=25g active=true -init set port-map unit=0 port=10 eth-macro=4 lane=2 max-speed=25g active=true -init set port-map unit=0 port=11 eth-macro=4 lane=3 max-speed=25g active=true -init set port-map unit=0 port=12 eth-macro=5 lane=0 max-speed=25g active=true -init set port-map unit=0 port=13 eth-macro=5 lane=1 max-speed=25g active=true -init set port-map unit=0 port=14 eth-macro=5 lane=2 max-speed=25g active=true -init set port-map unit=0 port=15 eth-macro=5 lane=3 max-speed=25g active=true -init set port-map unit=0 port=16 eth-macro=8 lane=0 max-speed=25g active=true -init set port-map unit=0 port=17 eth-macro=8 lane=1 max-speed=25g active=true -init set port-map unit=0 port=18 eth-macro=8 lane=2 max-speed=25g active=true -init set port-map unit=0 port=19 eth-macro=8 lane=3 max-speed=25g active=true -init set port-map unit=0 port=20 eth-macro=10 lane=0 max-speed=25g active=true -init set port-map unit=0 port=21 eth-macro=10 lane=1 max-speed=25g active=true -init set port-map unit=0 port=22 eth-macro=10 lane=2 max-speed=25g active=true -init set port-map unit=0 port=23 eth-macro=10 lane=3 max-speed=25g active=true -init set port-map unit=0 port=24 eth-macro=12 lane=0 max-speed=25g active=true -init set port-map unit=0 port=25 eth-macro=12 lane=1 max-speed=25g active=true -init set port-map unit=0 port=26 eth-macro=12 lane=2 max-speed=25g active=true -init set port-map unit=0 port=27 eth-macro=12 lane=3 max-speed=25g active=true -init set port-map unit=0 port=28 eth-macro=14 lane=0 max-speed=25g active=true -init set port-map unit=0 port=29 eth-macro=14 lane=1 max-speed=25g active=true -init set port-map unit=0 port=30 eth-macro=14 lane=2 max-speed=25g active=true -init set port-map unit=0 port=31 eth-macro=14 lane=3 max-speed=25g active=true -init set port-map unit=0 port=32 eth-macro=16 lane=0 max-speed=25g active=true -init set port-map unit=0 port=33 eth-macro=16 lane=1 max-speed=25g active=true -init set port-map unit=0 port=34 eth-macro=16 lane=2 max-speed=25g active=true -init set port-map unit=0 port=35 eth-macro=16 lane=3 max-speed=25g active=true -init set port-map unit=0 port=36 eth-macro=17 lane=0 max-speed=25g active=true -init set port-map unit=0 port=37 eth-macro=17 lane=1 max-speed=25g active=true -init set port-map unit=0 port=38 eth-macro=17 lane=2 max-speed=25g active=true -init set port-map unit=0 port=39 eth-macro=17 lane=3 max-speed=25g active=true -init set port-map unit=0 port=40 eth-macro=18 lane=0 max-speed=25g active=true -init set port-map unit=0 port=41 eth-macro=18 lane=1 max-speed=25g active=true -init set port-map unit=0 port=42 eth-macro=18 lane=2 max-speed=25g active=true -init set port-map unit=0 port=43 eth-macro=18 lane=3 max-speed=25g active=true -init set port-map unit=0 port=44 eth-macro=19 lane=0 max-speed=25g active=true -init set port-map unit=0 port=45 eth-macro=19 lane=1 max-speed=25g active=true -init set port-map unit=0 port=46 eth-macro=19 lane=2 max-speed=25g active=true -init set port-map unit=0 port=47 eth-macro=19 lane=3 max-speed=25g active=true -init set port-map unit=0 port=48 eth-macro=21 lane=0 max-speed=100g active=true -init set port-map unit=0 port=49 eth-macro=20 lane=0 max-speed=100g active=true -init set port-map unit=0 port=50 eth-macro=26 lane=0 max-speed=100g active=true -init set port-map unit=0 port=51 eth-macro=27 lane=0 max-speed=100g active=true -init set port-map unit=0 port=52 eth-macro=28 lane=0 max-speed=100g active=true -init set port-map unit=0 port=53 eth-macro=29 lane=0 max-speed=100g active=true -init set port-map unit=0 port=129 eth-macro=0 lane=1 max-speed=10g active=true guarantee=true cpi=true -init set port-map unit=0 port=130 eth-macro=0 lane=0 max-speed=10g active=true guarantee=true cpi=true init-done=true -init start stage unit=0 task-rsrc -init start stage unit=0 module -init start stage unit=0 task -phy set lane-swap portlist=0 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=1 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=2 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=3 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=4 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=5 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=6 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=7 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=8 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=9 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=10 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=11 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=12 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=13 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=14 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=15 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=16 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=17 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=18 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=19 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=20 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=21 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=22 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=23 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=24 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=25 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=26 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=27 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=28 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=29 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=30 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=31 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=32 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=33 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=34 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=35 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=36 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=37 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=38 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=39 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=40 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=41 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=42 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=43 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=44 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=45 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=46 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=47 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=48 lane-cnt=4 property=tx data=0x1.3.0.2 -phy set lane-swap portlist=49 lane-cnt=4 property=tx data=0x0.3.1.2 -phy set lane-swap portlist=50 lane-cnt=4 property=tx data=0x1.3.0.2 -phy set lane-swap portlist=51 lane-cnt=4 property=tx data=0x2.0.3.1 -phy set lane-swap portlist=52 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap portlist=53 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap portlist=0 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=1 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=2 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=3 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=4 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=5 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=6 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=7 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=8 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=9 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=10 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=11 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=12 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=13 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=14 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=15 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=16 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=17 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=18 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=19 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=20 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=21 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=22 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=23 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=24 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=25 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=26 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=27 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=28 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=29 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=30 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=31 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=32 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=33 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=34 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=35 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=36 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=37 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=38 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=39 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=40 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=41 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=42 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=43 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=44 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=45 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=46 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=47 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=48 lane-cnt=4 property=rx data=0x2.1.0.3 -phy set lane-swap portlist=49 lane-cnt=4 property=rx data=0x0.1.3.2 -phy set lane-swap portlist=50 lane-cnt=4 property=rx data=0x3.1.0.2 -phy set lane-swap portlist=51 lane-cnt=4 property=rx data=0x1.3.0.2 -phy set lane-swap portlist=52 lane-cnt=4 property=rx data=0x3.2.1.0 -phy set lane-swap portlist=53 lane-cnt=4 property=rx data=0x3.2.1.0 -phy set polarity-rev portlist=0 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=1 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=2 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=3 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=4 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=5 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=6 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=7 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=8 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=9 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=10 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=11 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=12 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=13 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=14 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=15 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=16 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=17 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=18 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=19 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=20 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=21 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=22 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=23 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=24 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=25 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=26 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=27 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=28 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=29 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=30 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=31 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=32 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=33 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=34 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=35 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=36 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=37 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=38 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=39 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=40 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=41 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=42 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=43 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=44 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=45 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=46 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=47 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=48 lane-cnt=4 property=tx data=0x0.0.0.1 -phy set polarity-rev portlist=49 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=50 lane-cnt=4 property=tx data=0x1.1.0.0 -phy set polarity-rev portlist=51 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=52 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=53 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=0 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=1 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=2 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=3 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=4 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=5 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=6 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=7 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=8 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=9 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=10 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=11 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=12 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=13 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=14 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=15 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=16 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=17 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=18 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=19 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=20 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=21 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=22 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=23 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=24 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=25 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=26 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=27 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=28 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=29 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=30 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=31 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=32 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=33 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=34 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=35 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=36 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=37 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=38 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=39 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=40 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=41 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=42 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=43 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=44 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=45 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=46 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=47 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=48 lane-cnt=4 property=rx data=0x0.1.0.1 -phy set polarity-rev portlist=49 lane-cnt=4 property=rx data=0x1.0.1.0 -phy set polarity-rev portlist=50 lane-cnt=4 property=rx data=0x0.0.1.0 -phy set polarity-rev portlist=51 lane-cnt=4 property=rx data=0x0.0.0.1 -phy set polarity-rev portlist=52 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=53 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set pre-emphasis portlist=0 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=0 lane-cnt=4 property=cn1 data=0x1.1.1.1 -phy set pre-emphasis portlist=0 lane-cnt=4 property=c0 data=0x1a.1a.1a.1a -phy set pre-emphasis portlist=0 lane-cnt=4 property=c1 data=0x7.7.7.7 -phy set pre-emphasis portlist=4 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=4 lane-cnt=4 property=cn1 data=0x1.1.1.1 -phy set pre-emphasis portlist=4 lane-cnt=4 property=c0 data=0x1a.1a.1a.1a -phy set pre-emphasis portlist=4 lane-cnt=4 property=c1 data=0x7.7.7.7 -phy set pre-emphasis portlist=8 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=8 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=8 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=8 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=12 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=12 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=12 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis portlist=12 lane-cnt=4 property=c1 data=0x7.7.7.7 -phy set pre-emphasis portlist=16 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=16 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=16 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=16 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=20 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=20 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=20 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=20 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=24 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=24 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=24 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=24 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=28 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=28 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=28 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=28 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=32 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=32 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=32 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=32 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=36 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=36 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=36 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=36 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=40 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=40 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=40 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=40 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=44 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=44 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=44 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=44 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=48 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=48 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=48 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis portlist=48 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=49 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=49 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=49 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis portlist=49 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=50 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=50 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=50 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis portlist=50 lane-cnt=4 property=c1 data=0x7.7.7.7 -phy set pre-emphasis portlist=51 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=51 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=51 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis portlist=51 lane-cnt=4 property=c1 data=0x7.7.7.7 -phy set pre-emphasis portlist=52 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=52 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=52 lane-cnt=4 property=c0 data=0x1a.1a.1a.1a -phy set pre-emphasis portlist=52 lane-cnt=4 property=c1 data=0x8.8.8.8 -phy set pre-emphasis portlist=53 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=53 lane-cnt=4 property=cn1 data=0x1.1.1.1 -phy set pre-emphasis portlist=53 lane-cnt=4 property=c0 data=0x1a.1a.1a.1a -phy set pre-emphasis portlist=53 lane-cnt=4 property=c1 data=0x7.7.7.7 -phy set mdio portlist=0 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=1 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=2 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=3 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=4 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=5 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=6 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=7 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=8 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=9 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=10 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=11 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=12 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=13 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=14 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=15 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=16 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=17 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=18 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=19 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=20 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=21 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=22 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=23 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=24 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=25 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=26 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=27 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=28 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=29 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=30 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=31 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=32 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=33 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=34 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=35 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=36 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=37 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=38 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=39 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=40 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=41 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=42 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=43 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=44 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=45 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=46 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=47 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=48 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=49 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=50 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=51 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=52 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=53 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=129 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=130 devad=0x1E addr=0x2 data=0x0000 -port set property portlist=0-47 speed=25g -port set property portlist=48-53 speed=100g -port set property portlist=129-130 speed=10g -port set property portlist=0-47 medium-type=sr -port set property portlist=48-53 medium-type=sr4 -port set property portlist=129-130 medium-type=kr -port set adver portlist=129-130 speed-10g-kr -port set property portlist=129-130 an=enable -port set property unit=0 portlist=129-130 admin=enable -port set property unit=0 portlist=0-53 admin=disable - diff --git a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/pg_profile_lookup.ini b/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/pg_profile_lookup.ini deleted file mode 100644 index d98b0eca6d1..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/pg_profile_lookup.ini +++ /dev/null @@ -1,17 +0,0 @@ -# PG lossless profiles. -# speed cable size xon xoff threshold - 10000 5m 3584 32256 59136 36736 - 25000 5m 3584 41216 68096 45696 - 40000 5m 3584 47488 74368 51968 - 50000 5m 3584 52864 79744 57344 - 100000 5m 3584 78400 132160 82880 - 10000 40m 3584 32256 59136 36736 - 25000 40m 3584 41216 68096 45696 - 40000 40m 3584 47488 74368 51968 - 50000 40m 3584 52864 79744 57344 - 100000 40m 3584 78400 132160 82880 - 10000 300m 3584 32256 65856 36736 - 25000 300m 3584 41216 84672 45696 - 40000 300m 3584 47488 101024 51968 - 50000 300m 3584 52864 113120 57344 - 100000 300m 3584 78400 198688 82880 \ No newline at end of file diff --git a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/port_config.ini b/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/port_config.ini deleted file mode 100644 index 9b05ff8e63f..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/port_config.ini +++ /dev/null @@ -1,55 +0,0 @@ -# name lanes alias index speed -Ethernet0 8 Ethernet1/1 0 25000 -Ethernet1 9 Ethernet2/1 1 25000 -Ethernet2 10 Ethernet3/1 2 25000 -Ethernet3 11 Ethernet4/1 3 25000 -Ethernet4 12 Ethernet5/1 4 25000 -Ethernet5 13 Ethernet6/1 5 25000 -Ethernet6 14 Ethernet7/1 6 25000 -Ethernet7 15 Ethernet8/1 7 25000 -Ethernet8 16 Ethernet9/1 8 25000 -Ethernet9 17 Ethernet10/1 9 25000 -Ethernet10 18 Ethernet11/1 10 25000 -Ethernet11 19 Ethernet12/1 11 25000 -Ethernet12 20 Ethernet13/1 12 25000 -Ethernet13 21 Ethernet14/1 13 25000 -Ethernet14 22 Ethernet15/1 14 25000 -Ethernet15 23 Ethernet16/1 15 25000 -Ethernet16 32 Ethernet17/1 16 25000 -Ethernet17 33 Ethernet18/1 17 25000 -Ethernet18 34 Ethernet19/1 18 25000 -Ethernet19 35 Ethernet20/1 19 25000 -Ethernet20 40 Ethernet21/1 20 25000 -Ethernet21 41 Ethernet22/1 21 25000 -Ethernet22 42 Ethernet23/1 22 25000 -Ethernet23 43 Ethernet24/1 23 25000 -Ethernet24 48 Ethernet25/1 24 25000 -Ethernet25 49 Ethernet26/1 25 25000 -Ethernet26 50 Ethernet27/1 26 25000 -Ethernet27 51 Ethernet28/1 27 25000 -Ethernet28 56 Ethernet29/1 28 25000 -Ethernet29 57 Ethernet30/1 29 25000 -Ethernet30 58 Ethernet31/1 30 25000 -Ethernet31 59 Ethernet32/1 31 25000 -Ethernet32 64 Ethernet33/1 32 25000 -Ethernet33 65 Ethernet34/1 33 25000 -Ethernet34 66 Ethernet35/1 34 25000 -Ethernet35 67 Ethernet36/1 35 25000 -Ethernet36 68 Ethernet37/1 36 25000 -Ethernet37 69 Ethernet38/1 37 25000 -Ethernet38 70 Ethernet39/1 38 25000 -Ethernet39 71 Ethernet40/1 39 25000 -Ethernet40 72 Ethernet41/1 40 25000 -Ethernet41 73 Ethernet42/1 41 25000 -Ethernet42 74 Ethernet43/1 42 25000 -Ethernet43 75 Ethernet44/1 43 25000 -Ethernet44 76 Ethernet45/1 44 25000 -Ethernet45 77 Ethernet46/1 45 25000 -Ethernet46 78 Ethernet47/1 46 25000 -Ethernet47 79 Ethernet48/1 47 25000 -Ethernet48 84,85,86,87 Ethernet49/1 48 100000 -Ethernet49 80,81,82,83 Ethernet50/1 49 100000 -Ethernet50 104,105,106,107 Ethernet51/1 50 100000 -Ethernet51 108,109,110,111 Ethernet52/1 51 100000 -Ethernet52 112,113,114,115 Ethernet53/1 52 100000 -Ethernet53 116,117,118,119 Ethernet54/1 53 100000 diff --git a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/port_config.nps b/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/port_config.nps deleted file mode 100644 index ca2bc649768..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/port_config.nps +++ /dev/null @@ -1,415 +0,0 @@ -init start stage unit=0 low-level -init set port-map unit=0 port=0 eth-macro=2 lane=0 max-speed=25g active=true -init set port-map unit=0 port=1 eth-macro=2 lane=1 max-speed=25g active=true -init set port-map unit=0 port=2 eth-macro=2 lane=2 max-speed=25g active=true -init set port-map unit=0 port=3 eth-macro=2 lane=3 max-speed=25g active=true -init set port-map unit=0 port=4 eth-macro=3 lane=0 max-speed=25g active=true -init set port-map unit=0 port=5 eth-macro=3 lane=1 max-speed=25g active=true -init set port-map unit=0 port=6 eth-macro=3 lane=2 max-speed=25g active=true -init set port-map unit=0 port=7 eth-macro=3 lane=3 max-speed=25g active=true -init set port-map unit=0 port=8 eth-macro=4 lane=0 max-speed=25g active=true -init set port-map unit=0 port=9 eth-macro=4 lane=1 max-speed=25g active=true -init set port-map unit=0 port=10 eth-macro=4 lane=2 max-speed=25g active=true -init set port-map unit=0 port=11 eth-macro=4 lane=3 max-speed=25g active=true -init set port-map unit=0 port=12 eth-macro=5 lane=0 max-speed=25g active=true -init set port-map unit=0 port=13 eth-macro=5 lane=1 max-speed=25g active=true -init set port-map unit=0 port=14 eth-macro=5 lane=2 max-speed=25g active=true -init set port-map unit=0 port=15 eth-macro=5 lane=3 max-speed=25g active=true -init set port-map unit=0 port=16 eth-macro=8 lane=0 max-speed=25g active=true -init set port-map unit=0 port=17 eth-macro=8 lane=1 max-speed=25g active=true -init set port-map unit=0 port=18 eth-macro=8 lane=2 max-speed=25g active=true -init set port-map unit=0 port=19 eth-macro=8 lane=3 max-speed=25g active=true -init set port-map unit=0 port=20 eth-macro=10 lane=0 max-speed=25g active=true -init set port-map unit=0 port=21 eth-macro=10 lane=1 max-speed=25g active=true -init set port-map unit=0 port=22 eth-macro=10 lane=2 max-speed=25g active=true -init set port-map unit=0 port=23 eth-macro=10 lane=3 max-speed=25g active=true -init set port-map unit=0 port=24 eth-macro=12 lane=0 max-speed=25g active=true -init set port-map unit=0 port=25 eth-macro=12 lane=1 max-speed=25g active=true -init set port-map unit=0 port=26 eth-macro=12 lane=2 max-speed=25g active=true -init set port-map unit=0 port=27 eth-macro=12 lane=3 max-speed=25g active=true -init set port-map unit=0 port=28 eth-macro=14 lane=0 max-speed=25g active=true -init set port-map unit=0 port=29 eth-macro=14 lane=1 max-speed=25g active=true -init set port-map unit=0 port=30 eth-macro=14 lane=2 max-speed=25g active=true -init set port-map unit=0 port=31 eth-macro=14 lane=3 max-speed=25g active=true -init set port-map unit=0 port=32 eth-macro=16 lane=0 max-speed=25g active=true -init set port-map unit=0 port=33 eth-macro=16 lane=1 max-speed=25g active=true -init set port-map unit=0 port=34 eth-macro=16 lane=2 max-speed=25g active=true -init set port-map unit=0 port=35 eth-macro=16 lane=3 max-speed=25g active=true -init set port-map unit=0 port=36 eth-macro=17 lane=0 max-speed=25g active=true -init set port-map unit=0 port=37 eth-macro=17 lane=1 max-speed=25g active=true -init set port-map unit=0 port=38 eth-macro=17 lane=2 max-speed=25g active=true -init set port-map unit=0 port=39 eth-macro=17 lane=3 max-speed=25g active=true -init set port-map unit=0 port=40 eth-macro=18 lane=0 max-speed=25g active=true -init set port-map unit=0 port=41 eth-macro=18 lane=1 max-speed=25g active=true -init set port-map unit=0 port=42 eth-macro=18 lane=2 max-speed=25g active=true -init set port-map unit=0 port=43 eth-macro=18 lane=3 max-speed=25g active=true -init set port-map unit=0 port=44 eth-macro=19 lane=0 max-speed=25g active=true -init set port-map unit=0 port=45 eth-macro=19 lane=1 max-speed=25g active=true -init set port-map unit=0 port=46 eth-macro=19 lane=2 max-speed=25g active=true -init set port-map unit=0 port=47 eth-macro=19 lane=3 max-speed=25g active=true -init set port-map unit=0 port=48 eth-macro=21 lane=0 max-speed=100g active=true -init set port-map unit=0 port=49 eth-macro=20 lane=0 max-speed=100g active=true -init set port-map unit=0 port=50 eth-macro=26 lane=0 max-speed=100g active=true -init set port-map unit=0 port=51 eth-macro=27 lane=0 max-speed=100g active=true -init set port-map unit=0 port=52 eth-macro=28 lane=0 max-speed=100g active=true -init set port-map unit=0 port=53 eth-macro=29 lane=0 max-speed=100g active=true -init set port-map unit=0 port=129 eth-macro=0 lane=1 max-speed=10g active=true guarantee=true cpi=true -init set port-map unit=0 port=130 eth-macro=0 lane=0 max-speed=10g active=true guarantee=true cpi=true init-done=true -init start stage unit=0 task-rsrc -init start stage unit=0 module -init start stage unit=0 task -phy set lane-swap portlist=0 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=1 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=2 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=3 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=4 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=5 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=6 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=7 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=8 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=9 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=10 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=11 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=12 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=13 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=14 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=15 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=16 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=17 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=18 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=19 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=20 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=21 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=22 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=23 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=24 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=25 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=26 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=27 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=28 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=29 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=30 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=31 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=32 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=33 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=34 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=35 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=36 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=37 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=38 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=39 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=40 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=41 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=42 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=43 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=44 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=45 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=46 lane-cnt=1 property=tx data=0x2 -phy set lane-swap portlist=47 lane-cnt=1 property=tx data=0x3 -phy set lane-swap portlist=48 lane-cnt=4 property=tx data=0x1.3.0.2 -phy set lane-swap portlist=49 lane-cnt=4 property=tx data=0x0.3.1.2 -phy set lane-swap portlist=50 lane-cnt=4 property=tx data=0x1.3.0.2 -phy set lane-swap portlist=51 lane-cnt=4 property=tx data=0x2.0.3.1 -phy set lane-swap portlist=52 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap portlist=53 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap portlist=0 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=1 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=2 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=3 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=4 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=5 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=6 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=7 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=8 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=9 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=10 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=11 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=12 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=13 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=14 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=15 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=16 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=17 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=18 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=19 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=20 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=21 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=22 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=23 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=24 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=25 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=26 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=27 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=28 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=29 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=30 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=31 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=32 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=33 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=34 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=35 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=36 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=37 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=38 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=39 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=40 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=41 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=42 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=43 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=44 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=45 lane-cnt=1 property=rx data=0x2 -phy set lane-swap portlist=46 lane-cnt=1 property=rx data=0x3 -phy set lane-swap portlist=47 lane-cnt=1 property=rx data=0x0 -phy set lane-swap portlist=48 lane-cnt=4 property=rx data=0x2.1.0.3 -phy set lane-swap portlist=49 lane-cnt=4 property=rx data=0x0.1.3.2 -phy set lane-swap portlist=50 lane-cnt=4 property=rx data=0x3.1.0.2 -phy set lane-swap portlist=51 lane-cnt=4 property=rx data=0x1.3.0.2 -phy set lane-swap portlist=52 lane-cnt=4 property=rx data=0x3.2.1.0 -phy set lane-swap portlist=53 lane-cnt=4 property=rx data=0x3.2.1.0 -phy set polarity-rev portlist=0 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=1 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=2 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=3 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=4 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=5 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=6 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=7 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=8 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=9 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=10 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=11 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=12 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=13 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=14 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=15 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=16 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=17 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=18 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=19 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=20 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=21 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=22 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=23 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=24 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=25 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=26 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=27 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=28 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=29 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=30 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=31 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=32 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=33 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=34 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=35 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=36 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=37 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=38 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=39 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=40 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=41 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=42 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=43 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=44 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=45 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=46 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=47 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=48 lane-cnt=4 property=tx data=0x0.0.0.1 -phy set polarity-rev portlist=49 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=50 lane-cnt=4 property=tx data=0x1.1.0.0 -phy set polarity-rev portlist=51 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=52 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=53 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=0 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=1 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=2 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=3 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=4 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=5 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=6 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=7 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=8 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=9 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=10 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=11 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=12 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=13 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=14 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=15 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=16 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=17 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=18 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=19 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=20 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=21 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=22 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=23 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=24 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=25 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=26 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=27 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=28 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=29 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=30 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=31 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=32 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=33 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=34 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=35 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=36 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=37 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=38 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=39 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=40 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=41 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=42 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=43 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=44 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=45 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=46 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=47 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=48 lane-cnt=4 property=rx data=0x0.1.0.1 -phy set polarity-rev portlist=49 lane-cnt=4 property=rx data=0x1.0.1.0 -phy set polarity-rev portlist=50 lane-cnt=4 property=rx data=0x0.0.1.0 -phy set polarity-rev portlist=51 lane-cnt=4 property=rx data=0x0.0.0.1 -phy set polarity-rev portlist=52 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=53 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set pre-emphasis portlist=0 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=0 lane-cnt=4 property=cn1 data=0x1.1.1.1 -phy set pre-emphasis portlist=0 lane-cnt=4 property=c0 data=0x1a.1a.1a.1a -phy set pre-emphasis portlist=0 lane-cnt=4 property=c1 data=0x7.7.7.7 -phy set pre-emphasis portlist=4 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=4 lane-cnt=4 property=cn1 data=0x1.1.1.1 -phy set pre-emphasis portlist=4 lane-cnt=4 property=c0 data=0x1a.1a.1a.1a -phy set pre-emphasis portlist=4 lane-cnt=4 property=c1 data=0x7.7.7.7 -phy set pre-emphasis portlist=8 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=8 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=8 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=8 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=12 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=12 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=12 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis portlist=12 lane-cnt=4 property=c1 data=0x7.7.7.7 -phy set pre-emphasis portlist=16 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=16 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=16 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=16 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=20 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=20 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=20 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=20 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=24 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=24 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=24 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=24 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=28 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=28 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=28 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=28 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=32 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=32 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=32 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=32 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=36 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=36 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=36 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=36 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=40 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=40 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=40 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=40 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=44 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=44 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=44 lane-cnt=4 property=c0 data=0x1c.1c.1c.1c -phy set pre-emphasis portlist=44 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=48 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=48 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=48 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis portlist=48 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=49 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=49 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=49 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis portlist=49 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis portlist=50 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=50 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=50 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis portlist=50 lane-cnt=4 property=c1 data=0x7.7.7.7 -phy set pre-emphasis portlist=51 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=51 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=51 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis portlist=51 lane-cnt=4 property=c1 data=0x7.7.7.7 -phy set pre-emphasis portlist=52 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=52 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis portlist=52 lane-cnt=4 property=c0 data=0x1a.1a.1a.1a -phy set pre-emphasis portlist=52 lane-cnt=4 property=c1 data=0x8.8.8.8 -phy set pre-emphasis portlist=53 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis portlist=53 lane-cnt=4 property=cn1 data=0x1.1.1.1 -phy set pre-emphasis portlist=53 lane-cnt=4 property=c0 data=0x1a.1a.1a.1a -phy set pre-emphasis portlist=53 lane-cnt=4 property=c1 data=0x7.7.7.7 -phy set mdio portlist=0 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=1 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=2 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=3 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=4 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=5 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=6 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=7 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=8 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=9 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=10 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=11 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=12 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=13 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=14 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=15 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=16 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=17 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=18 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=19 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=20 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=21 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=22 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=23 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=24 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=25 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=26 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=27 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=28 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=29 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=30 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=31 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=32 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=33 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=34 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=35 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=36 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=37 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=38 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=39 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=40 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=41 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=42 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=43 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=44 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=45 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=46 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=47 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=48 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=49 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=50 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=51 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=52 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=53 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=129 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=130 devad=0x1E addr=0x2 data=0x0000 -port set property portlist=0-47 speed=25g -port set property portlist=48-53 speed=100g -port set property portlist=129-130 speed=10g -port set property portlist=0-47 medium-type=sr -port set property portlist=48-53 medium-type=sr4 -port set property portlist=129-130 medium-type=kr -port set adver portlist=129-130 speed-10g-kr -port set property portlist=129-130 an=enable -port set property unit=0 portlist=129-130 admin=enable -port set property unit=0 portlist=0-53 admin=disable - diff --git a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/proc_init.nps b/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/proc_init.nps deleted file mode 100644 index e25c78018ad..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/proc_init.nps +++ /dev/null @@ -1,10 +0,0 @@ -#unit NPS_CFG_TYPE_XXX param0 param1 value -#---- ---------------- ------ ------ ----- -0 NPS_CFG_TYPE_USE_UNIT_PORT 0 0 1 -0 NPS_CFG_TYPE_LED_CFG 0 0 5 -0 NPS_CFG_TYPE_CPI_PORT_MODE 129 0 1 -0 NPS_CFG_TYPE_CPI_PORT_MODE 130 0 1 -0 NPS_CFG_TYPE_USER_BUF_CTRL 0 0 1 -0 NPS_CFG_TYPE_HASH_L2_FDB_REGION_ENTRY_NUM 0 0 49152 -0 NPS_CFG_TYPE_HASH_L3_WITH_IPV6_PREFIX_64_REGION_ENTRY_NUM 0 0 32768 - diff --git a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/qos.json.j2 b/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/qos.json.j2 deleted file mode 100644 index 5c5fc6e4969..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/qos.json.j2 +++ /dev/null @@ -1,136 +0,0 @@ -{ - "TC_TO_PRIORITY_GROUP_MAP": { - "AZURE": { - "0": "1", - "1": "0", - "3": "3", - "4": "4" - } - }, - "MAP_PFC_PRIORITY_TO_QUEUE": { - "AZURE": { - "3": "3", - "4": "4" - } - }, - "TC_TO_QUEUE_MAP": { - "AZURE": { - "0": "1", - "1": "0", - "3": "3", - "4": "4" - } - }, - "DSCP_TO_TC_MAP": { - "AZURE": { - "0":"1", - "1":"0", - "2":"0", - "3":"3", - "4":"4", - "5":"0", - "6":"0", - "7":"0", - "8":"1", - "9":"0", - "10":"0", - "11":"0", - "12":"0", - "13":"0", - "14":"0", - "15":"0", - "16":"0", - "17":"0", - "18":"0", - "19":"0", - "20":"0", - "21":"0", - "22":"0", - "23":"0", - "24":"0", - "25":"0", - "26":"0", - "27":"0", - "28":"0", - "29":"0", - "30":"0", - "31":"0", - "32":"0", - "33":"0", - "34":"0", - "35":"0", - "36":"0", - "37":"0", - "38":"0", - "39":"0", - "40":"0", - "41":"0", - "42":"0", - "43":"0", - "44":"0", - "45":"0", - "46":"0", - "47":"0", - "48":"0", - "49":"0", - "50":"0", - "51":"0", - "52":"0", - "53":"0", - "54":"0", - "55":"0", - "56":"0", - "57":"0", - "58":"0", - "59":"0", - "60":"0", - "61":"0", - "62":"0", - "63":"0" - } - }, - "SCHEDULER": { - "scheduler.0" : { - "type":"DWRR", - "weight": "25" - }, - "scheduler.1" : { - "type":"DWRR", - "weight": "30" - }, - "scheduler.2" : { - "type":"DWRR", - "weight": "20" - } - }, - "PORT_QOS_MAP": { - }, - "WRED_PROFILE": { - "AZURE_LOSSY" : { - "wred_green_enable":"true", - "wred_yellow_enable":"true", - "wred_red_enable":"true", - "ecn":"ecn_all", - "red_max_threshold":"613984", - "red_min_threshold":"76608", - "yellow_max_threshold":"628320", - "yellow_min_threshold":"78400", - "green_max_threshold": "642656", - "green_min_threshold": "80192" - }, - "AZURE_LOSSLESS" : { - "wred_green_enable":"true", - "wred_yellow_enable":"true", - "wred_red_enable":"true", - "ecn":"ecn_all", - "red_max_threshold":"613984", - "red_min_threshold":"76608", - "yellow_max_threshold":"628320", - "yellow_min_threshold":"78400", - "green_max_threshold": "642656", - "green_min_threshold": "80192" - } - }, - "QUEUE": { - } -} diff --git a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/sai.profile b/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/sai.profile deleted file mode 100644 index 5e4ff9064d5..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/Accton-AS7116-54X-R0/sai.profile +++ /dev/null @@ -1,2 +0,0 @@ -SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/proc_init.nps -SAI_DSH_CONFIG_FILE=/usr/share/sonic/hwsku/port_config.nps diff --git a/device/accton/x86_64-accton_as7116_54x-r0/default_sku b/device/accton/x86_64-accton_as7116_54x-r0/default_sku deleted file mode 100644 index 146edca5263..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/default_sku +++ /dev/null @@ -1 +0,0 @@ -Accton-AS7116-54X-R0 t1 diff --git a/device/accton/x86_64-accton_as7116_54x-r0/fancontrol b/device/accton/x86_64-accton_as7116_54x-r0/fancontrol deleted file mode 100644 index e16d8f936f8..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/fancontrol +++ /dev/null @@ -1,10 +0,0 @@ -INTERVAL=10 -FCTEMPS=/sys/bus/i2c/devices/1-0063/fan_duty_cycle_percentage=/sys/bus/i2c/devices/20-004a/hwmon/hwmon*/temp1_input /sys/bus/i2c/devices/1-0063/fan_duty_cycle_percentage=/sys/bus/i2c/devices/19-0049/hwmon/hwmon*/temp1_input /sys/bus/i2c/devices/1-0063/fan_duty_cycle_percentage=/sys/bus/i2c/devices/17-004b/hwmon/hwmon*/temp1_input -FCFANS=/sys/bus/i2c/devices/1-0063/fan_duty_cycle_percentage=/sys/bus/i2c/devices/1-0063/fan1_input /sys/bus/i2c/devices/1-0063/fan_duty_cycle_percentage=/sys/bus/i2c/devices/1-0063/fan2_input -/sys/bus/i2c/devices/1-0063/fan_duty_cycle_percentage=/sys/bus/i2c/devices/1-0063/fan3_input /sys/bus/i2c/devices/1-0063/fan_duty_cycle_percentage=/sys/bus/i2c/devices/1-0063/fan4_input /sys/bus/i2c/devices/1-0063/fan_duty_cycle_percentage=/sys/bus/i2c/devices/1-0063/fan5_input -MINTEMP=/sys/bus/i2c/devices/1-0063/fan_duty_cycle_percentage=49 -MAXTEMP=/sys/bus/i2c/devices/1-0063/fan_duty_cycle_percentage=58 -MINSTART=/sys/bus/i2c/devices/1-0063/fan_duty_cycle_percentage=100 -MINSTOP=/sys/bus/i2c/devices/1-0063/fan_duty_cycle_percentage=40 -MINPWM=/sys/bus/i2c/devices/1-0063/fan_duty_cycle_percentage=40 -MAXPWM=/sys/bus/i2c/devices/1-0063/fan_duty_cycle_percentage=100 diff --git a/device/accton/x86_64-accton_as7116_54x-r0/installer.conf b/device/accton/x86_64-accton_as7116_54x-r0/installer.conf deleted file mode 100644 index 4eeedca86a4..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/installer.conf +++ /dev/null @@ -1,4 +0,0 @@ -CONSOLE_PORT=0x3f8 -CONSOLE_DEV=0 -CONSOLE_SPEED=115200 -ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="pci=noaer" \ No newline at end of file diff --git a/device/accton/x86_64-accton_as7116_54x-r0/platform_asic b/device/accton/x86_64-accton_as7116_54x-r0/platform_asic deleted file mode 100644 index 4211b60b9ce..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/platform_asic +++ /dev/null @@ -1 +0,0 @@ -nephos diff --git a/device/accton/x86_64-accton_as7116_54x-r0/plugins/eeprom.py b/device/accton/x86_64-accton_as7116_54x-r0/plugins/eeprom.py deleted file mode 100644 index 4241483d68e..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/plugins/eeprom.py +++ /dev/null @@ -1,20 +0,0 @@ -try: - import binascii - import time - import optparse - import warnings - import os - import sys - from sonic_eeprom import eeprom_base - from sonic_eeprom import eeprom_tlvinfo - import subprocess -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class board(eeprom_tlvinfo.TlvInfoDecoder): - _TLV_INFO_MAX_LEN = 256 - - def __init__(self, name, path, cpld_root, ro): - self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom" - super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/accton/x86_64-accton_as7116_54x-r0/plugins/psuutil.py b/device/accton/x86_64-accton_as7116_54x-r0/plugins/psuutil.py deleted file mode 100644 index 40e7257a6f0..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/plugins/psuutil.py +++ /dev/null @@ -1,91 +0,0 @@ -# -# psuutil.py -# Platform-specific PSU status interface for SONiC -# - - -import os.path - -try: - from sonic_psu.psu_base import PsuBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class PsuUtil(PsuBase): - """Platform-specific PSUutil class""" - - SYSFS_PSU_DIR = ["/sys/bus/i2c/devices/10-0050", - "/sys/bus/i2c/devices/11-0053"] - - def __init__(self): - PsuBase.__init__(self) - - # Get sysfs attribute - - def get_attr_value(self, attr_path): - - retval = 'ERR' - if (not os.path.isfile(attr_path)): - return retval - - try: - with open(attr_path, 'r') as fd: - retval = fd.read() - except Exception as error: - logging.error("Unable to open ", attr_path, " file !") - - retval = retval.rstrip('\r\n') - return retval - - def get_num_psus(self): - """ - Retrieves the number of PSUs available on the device - :return: An integer, the number of PSUs available on the device - """ - MAX_PSUS = 2 - return MAX_PSUS - - def get_psu_status(self, index): - """ - Retrieves the oprational status of power supply unit (PSU) defined - by index - :param index: An integer, index of the PSU of which to query status - :return: Boolean, True if PSU is operating properly, False if PSU is\ - faulty - """ - status = 0 - attr_file = 'psu_power_good' - attr_path = self.SYSFS_PSU_DIR[index-1] + '/' + attr_file - - attr_value = self.get_attr_value(attr_path) - - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - # Check for PSU status - if (attr_value == 1): - status = 1 - - return status - - def get_psu_presence(self, index): - """ - Retrieves the presence status of power supply unit (PSU) defined - by index - :param index: An integer, index of the PSU of which to query status - :return: Boolean, True if PSU is plugged, False if not - """ - status = 0 - psu_absent = 0 - attr_file = 'psu_present' - attr_path = self.SYSFS_PSU_DIR[index-1] + '/' + attr_file - - attr_value = self.get_attr_value(attr_path) - - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - # Check for PSU presence - if (attr_value == 1): - status = 1 - - return status diff --git a/device/accton/x86_64-accton_as7116_54x-r0/plugins/sfputil.py b/device/accton/x86_64-accton_as7116_54x-r0/plugins/sfputil.py deleted file mode 100644 index 9f678757f2a..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/plugins/sfputil.py +++ /dev/null @@ -1,171 +0,0 @@ -try: - import time - from sonic_sfp.sfputilbase import SfpUtilBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -SFP_STATUS_INSERTED = '1' -SFP_STATUS_REMOVED = '0' - - -class SfpUtil(SfpUtilBase): - """Platform specific SfpUtill class""" - - _port_start = 0 - _port_end = 53 - _qsfp_port_start = 48 - _ports_in_block = 54 - - _port_to_eeprom_mapping = {} - _port_to_i2c_mapping = { - 0: 37, - 1: 38, - 2: 39, - 3: 40, - 4: 41, - 5: 42, - 6: 43, - 7: 44, - 8: 45, - 9: 46, - 10: 47, - 11: 48, - 12: 49, - 13: 50, - 14: 51, - 15: 52, - 16: 53, - 17: 54, - 18: 55, - 19: 56, - 20: 57, - 21: 58, - 22: 59, - 23: 60, - 24: 61, - 25: 62, - 26: 63, - 27: 64, - 28: 65, - 29: 66, - 30: 67, - 31: 68, - 32: 69, - 33: 70, - 34: 71, - 35: 72, - 36: 73, - 37: 74, - 38: 75, - 39: 76, - 40: 77, - 41: 78, - 42: 79, - 43: 80, - 44: 81, - 45: 82, - 46: 83, - 47: 84, - 48: 21, - 49: 22, - 50: 23, - 51: 24, - 52: 25, - 53: 26, - } - - _qsfp_ports = list(range(_qsfp_port_start, _ports_in_block + 1)) - - _present_status = dict() - - def __init__(self): - eeprom_path = '/sys/bus/i2c/devices/{0}-0050/sfp_eeprom' - for x in range(self._port_start, self._port_end + 1): - port_eeprom_path = eeprom_path.format(self._port_to_i2c_mapping[x]) - self._port_to_eeprom_mapping[x] = port_eeprom_path - self._present_status[x] = SFP_STATUS_REMOVED - - SfpUtilBase.__init__(self) - - def reset(self, port_num): - # Check for invalid port_num - if port_num < self._qsfp_port_start or port_num > self._port_end: - print("Error: port %d is not qsfp port" % port_num) - return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_port_reset" - port_ps = path.format(self._port_to_i2c_mapping[port_num]) - - try: - reg_file = open(port_ps, 'w') - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - # toggle reset - reg_file.seek(0) - reg_file.write('1') - time.sleep(1) - reg_file.seek(0) - reg_file.write('0') - reg_file.close() - return True - - def set_low_power_mode(self, port_nuM, lpmode): - raise NotImplementedError - - def get_low_power_mode(self, port_num): - raise NotImplementedError - - def get_presence(self, port_num): - # Check for invalid port_num - if port_num < self._port_start or port_num > self._port_end: - return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_is_present" - port_ps = path.format(self._port_to_i2c_mapping[port_num]) - - reg_value = '0' - try: - reg_file = open(port_ps) - reg_value = reg_file.readline().rstrip() - reg_file.close() - except IOError as e: - print("Error: unable to access file: %s" % str(e)) - return False - - if reg_value == '1': - return True - - return False - - def get_transceiver_change_event(self, timeout=0): - raise NotImplementedError - - @property - def port_start(self): - return self._port_start - - @property - def port_end(self): - return self._port_end - - @property - def qsfp_ports(self): - return self._qsfp_ports - - @property - def port_to_eeprom_mapping(self): - return self._port_to_eeprom_mapping - - def get_transceiver_change_event(self, timeout=0): - ret_present = dict() - for phy_port in range(self._port_start, self._port_end + 1): - last_present_status = SFP_STATUS_INSERTED if self.get_presence(phy_port) else SFP_STATUS_REMOVED - if self._present_status[phy_port] != last_present_status: - ret_present[phy_port] = last_present_status - self._present_status[phy_port] = last_present_status - - time.sleep(2) - - return True, ret_present diff --git a/device/accton/x86_64-accton_as7116_54x-r0/pmon_daemon_control.json b/device/accton/x86_64-accton_as7116_54x-r0/pmon_daemon_control.json deleted file mode 100644 index 584a14b9d94..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/pmon_daemon_control.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "skip_ledd": true, - "skip_thermalctld": true -} - diff --git a/device/accton/x86_64-accton_as7116_54x-r0/sensors.conf b/device/accton/x86_64-accton_as7116_54x-r0/sensors.conf deleted file mode 100644 index 9edb51a9e72..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/sensors.conf +++ /dev/null @@ -1,13 +0,0 @@ -# libsensors configuration file - -chip "as7116_54x_fan-*" - label fan1 "front fan 1" - label fan2 "front fan 2" - label fan3 "front fan 3" - label fan4 "front fan 4" - label fan5 "front fan 5" - label fan6 "rear fan 1" - label fan7 "rear fan 2" - label fan8 "rear fan 3" - label fan9 "rear fan 4" - label fan10 "rear fan 5" diff --git a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/__init__.py b/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/__init__.py deleted file mode 100644 index d82f3749319..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -__all__ = ["platform", "chassis"] -from sonic_platform import * diff --git a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/chassis.py b/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/chassis.py deleted file mode 100644 index 178f3c56265..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/chassis.py +++ /dev/null @@ -1,167 +0,0 @@ -############################################################################# -# -# Module contains an implementation of SONiC Platform Base API and -# provides the Chassis information which are available in the platform -# -############################################################################# -try: - import subprocess - from sonic_platform_base.chassis_base import ChassisBase - from sonic_py_common.logger import Logger - from sonic_platform.fan import Fan - from sonic_platform.psu import Psu - from sonic_platform.component import Component - from sonic_platform.thermal import Thermal - from sonic_platform.sfp import Sfp - from sonic_platform.eeprom import Tlv -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -NUM_FAN_TRAY = 5 -NUM_FAN = 2 -NUM_PSU = 2 -NUM_THERMAL = 4 -NUM_SFP = 54 -SFP_PORT_START = 0 -QSFP_PORT_START = 48 -SFP_PORT_END = 47 -QSFP_PORT_END = 53 -HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/" -PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/" -REBOOT_CAUSE_FILE = "reboot-cause.txt" -PREV_REBOOT_CAUSE_FILE = "previous-reboot-cause.txt" -COMPONENT_NAME_LIST = ["BIOS"] -HOST_CHK_CMD = ["docker"] - - -class Chassis(ChassisBase): - """Platform-specific Chassis class""" - - def __init__(self): - super(Chassis, self).__init__() - - for fantray_index in range(0, NUM_FAN_TRAY): - for fan_index in range(0, NUM_FAN): - fan = Fan(fantray_index, fan_index) - self._fan_list.append(fan) - for index in range(0, NUM_PSU): - psu = Psu(index) - self._psu_list.append(psu) - for index in range(0, NUM_THERMAL): - thermal = Thermal(index) - self._thermal_list.append(thermal) - - self.PORT_START = SFP_PORT_START - self.QSFP_PORT_START = QSFP_PORT_START - self.PORT_END = QSFP_PORT_END - for index in range(0, NUM_SFP): - if index in range(self.QSFP_PORT_START, self.QSPORT_END + 1): - sfp_module = Sfp(index, 'QSFP') - else: - sfp_module = Sfp(index, 'SFP') - self._sfp_list.append(sfp_module) - self._component_name_list = COMPONENT_NAME_LIST - self._watchdog = Watchdog() - self._eeprom = Tlv() - logger.log_info("Chassis loaded successfully") - - def __is_host(self): - return subprocess.call(HOST_CHK_CMD) == 0 - - def __read_txt_file(self, file_path): - try: - with open(file_path, 'r') as fd: - data = fd.read() - return data.strip() - except IOError: - pass - return None - - def get_base_mac(self): - """ - Retrieves the base MAC address for the chassis - Returns: - A string containing the MAC address in the format - 'XX:XX:XX:XX:XX:XX' - """ - return self._eeprom.get_mac() - - def get_serial(self): - """ - Retrieves the hardware serial number for the chassis - Returns: - A string containing the hardware serial number for this chassis. - """ - return self._eeprom.get_serial() - - def get_system_eeprom_info(self): - """ - Retrieves the full content of system EEPROM information for the chassis - Returns: - A dictionary where keys are the type code defined in - OCP ONIE TlvInfo EEPROM format and values are their corresponding - values. - """ - return self._eeprom.get_eeprom() - - def get_firmware_version(self, component_name): - """ - Retrieves platform-specific hardware/firmware versions for chassis - componenets such as BIOS, CPLD, FPGA, etc. - Args: - type: A string, component name - - Returns: - A string containing platform-specific component versions - """ - self.component = Component(component_name) - if component_name not in self._component_name_list: - return None - return self.component.get_firmware_version() - - def install_component_firmware(self, component_name, image_path): - """ - Install firmware to module - Args: - type: A string, component name. - image_path: A string, path to firmware image. - - Returns: - A boolean, True if install successfully, False if not - """ - self.component = Component(component_name) - if component_name not in self._component_name_list: - return False - return self.component.upgrade_firmware(image_path) - - def get_reboot_cause(self): - """ - Retrieves the cause of the previous reboot - - Returns: - A tuple (string, string) where the first element is a string - containing the cause of the previous reboot. This string must be - one of the predefined strings in this class. If the first string - is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used - to pass a description of the reboot cause. - """ - description = 'None' - reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER - - reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE) if self.__is_host( - ) else PMON_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE - prev_reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + PREV_REBOOT_CAUSE_FILE) if self.__is_host( - ) else PMON_REBOOT_CAUSE_PATH + PREV_REBOOT_CAUSE_FILE - sw_reboot_cause = self.__read_txt_file( - reboot_cause_path) or "Unknown" - prev_sw_reboot_cause = self.__read_txt_file( - prev_reboot_cause_path) or "Unknown" - - if sw_reboot_cause != "Unknown": - reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE - description = sw_reboot_cause - else: - reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER - description = 'Unknown reason' - - return (reboot_cause, description) diff --git a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/component.py b/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/component.py deleted file mode 100644 index 5e1e800d52f..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/component.py +++ /dev/null @@ -1,78 +0,0 @@ -############################################################################# -# Component contains an implementation of SONiC Platform Base API and -# provides the components firmware management function -############################################################################# - -import os.path -import subprocess - -try: - from sonic_platform_base.device_base import DeviceBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version" - - -class Component(DeviceBase): - """Platform-specific Component class""" - - DEVICE_TYPE = "component" - - def __init__(self, component_name): - DeviceBase.__init__(self) - self.name = component_name.upper() - - def __run_command(self, command): - # Run bash command and print output to stdout - try: - process = subprocess.Popen(command, universal_newlines=True, stdout=subprocess.PIPE) - while True: - output = process.stdout.readline() - if output == '' and process.poll() is not None: - break - rc = process.poll() - if rc != 0: - return False - except: - return False - return True - - def __get_bios_version(self): - # Retrieves the BIOS firmware version - try: - with open(BIOS_VERSION_PATH, 'r') as fd: - bios_version = fd.read() - return bios_version.strip() - except Exception as e: - return None - - def get_firmware_version(self): - """ - Retrieves the firmware version of module - Returns: - string: The firmware versions of the module - """ - fw_version = None - - if self.name == "BIOS": - fw_version = self.__get_bios_version() - - return fw_version - - def upgrade_firmware(self, image_path): - """ - Install firmware to module - Args: - image_path: A string, path to firmware image - Returns: - A boolean, True if install successfully, False if not - """ - if not os.path.isfile(image_path): - return False - - if self.name == "BIOS": - print("Not supported") - return False - - return self.__run_command(install_command) diff --git a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/eeprom.py b/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/eeprom.py deleted file mode 100644 index 9cdd0910633..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/eeprom.py +++ /dev/null @@ -1,114 +0,0 @@ -############################################################################# -# Platform and model specific eeprom subclass, inherits from the base class, -# and provides the followings: -# - the eeprom format definition -# - specific encoder/decoder if there is special need -############################################################################# - -try: - import glob - import os - import sys - import re - from array import array - - if sys.version_info.major == 3: - from io import StringIO - else: - from cStringIO import StringIO - - from sonic_platform_base.sonic_eeprom import eeprom_dts - from sonic_platform_base.sonic_eeprom import eeprom_tlvinfo -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -CACHE_ROOT = '/var/cache/sonic/decode-syseeprom' -CACHE_FILE = 'syseeprom_cache' - - -class Tlv(eeprom_tlvinfo.TlvInfoDecoder): - - EEPROM_DECODE_HEADLINES = 6 - - def __init__(self): - self._eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom" - super(Tlv, self).__init__(self._eeprom_path, 0, '', True) - self._eeprom = self._load_eeprom() - - def __parse_output(self, decode_output): - decode_output.replace('\0', '') - lines = decode_output.split('\n') - lines = lines[self.EEPROM_DECODE_HEADLINES:] - _eeprom_info_dict = dict() - - for line in lines: - try: - match = re.search( - '(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)([\S]+)', line) - if match is not None: - idx = match.group(1) - value = match.group(3).rstrip('\0') - - _eeprom_info_dict[idx] = value - except: - pass - return _eeprom_info_dict - - def _load_eeprom(self): - original_stdout = sys.stdout - sys.stdout = StringIO() - err = self.read_eeprom_db() - if err: - # Failed to read EEPROM information from database. Read from cache file - pass - else: - decode_output = sys.stdout.getvalue() - sys.stdout = original_stdout - return self.__parse_output(decode_output) - - status = self.check_status() - if status < 'ok': - return False - - if not os.path.exists(CACHE_ROOT): - try: - os.makedirs(CACHE_ROOT) - except: - pass - - # - # only the eeprom classes that inherit from eeprom_base - # support caching. Others will work normally - # - try: - self.set_cache_name(os.path.join(CACHE_ROOT, CACHE_FILE)) - except: - pass - - e = self.read_eeprom() - if e is None: - return 0 - - try: - self.update_cache(e) - except: - pass - - self.decode_eeprom(e) - decode_output = sys.stdout.getvalue() - sys.stdout = original_stdout - - (is_valid, valid_crc) = self.is_checksum_valid(e) - if not is_valid: - return False - - return self.__parse_output(decode_output) - - def get_eeprom(self): - return self._eeprom - - def get_serial(self): - return self._eeprom.get('0x23', "Undefined.") - - def get_mac(self): - return self._eeprom.get('0x24', "Undefined.") diff --git a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/fan.py b/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/fan.py deleted file mode 100644 index 421e7727cee..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/fan.py +++ /dev/null @@ -1,164 +0,0 @@ -############################################################################# -# -# Module contains an implementation of SONiC Platform Base API and -# provides the fan status which are available in the platform -# -############################################################################# - -import json -import math -import os.path - -try: - from sonic_platform_base.fan_base import FanBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -FAN_PATH = "/sys/bus/i2c/devices/1-0063/" -FANTRAY_NAME_LIST = ["FANTRAY-1", "FANTRAY-2", - "FANTRAY-3", "FANTRAY-4", "FANTRAY-5"] -FAN_NAME_LIST = ["front", "rear"] - - -class Fan(FanBase): - """Platform-specific Fan class""" - - def __init__(self, fan_tray_index, fan_index=0): - self.fan_index = fan_index - self.fan_tray_index = fan_tray_index - self.fan_presence = "fan{}_present" - self.fan_direction = "fan{}_direction" - self.fan_fault = "fan{}_{}_fault" - self.fan_speed_rpm = "fan{}_{}_speed_rpm" - FanBase.__init__(self) - - def __read_txt_file(self, file_path): - try: - with open(file_path, 'r') as fd: - data = fd.read() - return data.strip() - except IOError: - pass - return "" - - def __write_txt_file(self, file_path, value): - try: - with open(file_path, 'w') as fd: - fd.write(str(value)) - except: - return False - return True - - def __search_file_by_name(self, directory, file_name): - for dirpath, dirnames, files in os.walk(directory): - for name in files: - file_path = os.path.join(dirpath, name) - if name in file_name: - return file_path - return None - - def get_direction(self): - """ - Retrieves the direction of fan - Returns: - A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST - depending on fan direction - """ - direction = self.FAN_DIRECTION_EXHAUST - fan_direction_file = (FAN_PATH + - self.fan_direction.format(self.fan_tray_index+1)) - raw = self.__read_txt_file(fan_direction_file).strip('\r\n') - direction = self.FAN_DIRECTION_INTAKE if str( - raw).upper() == "1" else self.FAN_DIRECTION_EXHAUST - - return direction - - def get_speed(self): - """ - Retrieves the speed of fan as a percentage of full speed - Returns: - An integer, the percentage of full fan speed, in the range 0 (off) - to 12000 (full speed) - """ - speed = 0 - if self.get_presence(): - fan_speed_file = (FAN_PATH + - self.fan_speed_rpm.format(self.fan_tray_index+1, FAN_NAME_LIST[self.fan_index])) - speed = self.__read_txt_file(fan_speed_file).strip('\r\n') - - return int(speed) - - def get_target_speed(self): - """ - Retrieves the target (expected) speed of the fan - Returns: - An integer, the percentage of full fan speed, in the range 0 (off) - to 100 (full speed) - """ - target = 0 - if self.get_presence(): - fan_speed_file = (FAN_PATH + - self.fan_speed_rpm.format(self.fan_tray_index+1, FAN_NAME_LIST[self.fan_index])) - target = self.__read_txt_file(fan_speed_file).strip('\r\n') - - return target - - def get_speed_tolerance(self): - """ - Retrieves the speed tolerance of the fan - Returns: - An integer, the percentage of variance from target speed which is - considered tolerable - """ - return 10 - - def set_speed(self, speed): - """ - Sets the fan speed - Args: - speed: An integer, the percentage of full fan speed to set fan to, - in the range 0 (off) to 100 (full speed) - Returns: - A boolean, True if speed is set successfully, False if not - - Note: - Depends on pwm or target mode is selected: - 1) pwm = speed_pc * 255 <-- Currently use this mode. - 2) target_pwm = speed_pc * 100 / 255 - 2.1) set pwm{}_enable to 3 - - """ - return False - - def set_status_led(self, color): - """ - Sets the state of the fan module status LED - Args: - color: A string representing the color with which to set the - fan module status LED - Returns: - bool: True if status LED state is set successfully, False if not - """ - return False - - def get_name(self): - """ - Retrieves the name of the device - Returns: - string: The name of the device - """ - fan_name = FAN_NAME_LIST[self.fan_tray_index] - - return fan_name - - def get_presence(self): - """ - Retrieves the presence of the PSU - Returns: - bool: True if PSU is present, False if not - """ - fan_direction_file = (FAN_PATH + - self.fan_presence.format(self.fan_tray_index+1)) - present_str = self.__read_txt_file(fan_direction_file) or '1' - - return int(present_str) == 0 diff --git a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/platform.py b/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/platform.py deleted file mode 100644 index 6e1a90132ac..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/platform.py +++ /dev/null @@ -1,19 +0,0 @@ -############################################################################# -# Module contains an implementation of SONiC Platform Base API and -# provides the platform information -# -############################################################################# - -try: - from sonic_platform_base.platform_base import PlatformBase - from sonic_platform.chassis import Chassis -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class Platform(PlatformBase): - """Platform-specific Platform class""" - - def __init__(self): - PlatformBase.__init__(self) - self._chassis = Chassis() diff --git a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/psu.py b/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/psu.py deleted file mode 100644 index f53b7506bb3..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/psu.py +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################# -# psuutil.py -# Platform-specific PSU status interface for SONiC -############################################################################# - -import os.path -import sonic_platform - -try: - from sonic_platform_base.psu_base import PsuBase - from sonic_platform.fan import Fan -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -FAN_MAX_RPM = 9600 -PSU_NAME_LIST = ["PSU-0", "PSU-1"] - - -class Psu(PsuBase): - """Platform-specific Psu class""" - - SYSFS_PSU_DIR = ["/sys/bus/i2c/devices/10-0050", - "/sys/bus/i2c/devices/11-0053"] - - def __init__(self): - self.index = psu_index - PsuBase.__init__(self) - - def get_fan(self): - """ - Retrieves object representing the fan module contained in this PSU - Returns: - An object dervied from FanBase representing the fan module - contained in this PSU - """ - # Hardware not supported - return False - - def get_powergood_status(self): - """ - Retrieves the powergood status of PSU - Returns: - A boolean, True if PSU has stablized its output voltages and passed all - its internal self-tests, False if not. - """ - return self.get_status() - - def set_status_led(self, color): - """ - Sets the state of the PSU status LED - Args: - color: A string representing the color with which to set the PSU status LED - Note: Only support green and off - Returns: - bool: True if status LED state is set successfully, False if not - """ - # Hardware not supported - return False - - def get_name(self): - """ - Retrieves the name of the device - Returns: - string: The name of the device - """ - return PSU_NAME_LIST[self.index] - - def get_presence(self): - """ - Retrieves the presence of the PSU - Returns: - bool: True if PSU is present, False if not - """ - attr_file = 'psu_present' - attr_path = self.SYSFS_PSU_DIR[self.index-1] + '/' + attr_file - status = 0 - try: - with open(attr_path, 'r') as psu_prs: - status = int(psu_prs.read()) - except IOError: - return False - - return status == 1 - - def get_status(self): - """ - Retrieves the operational status of the device - Returns: - A boolean value, True if device is operating properly, False if not - """ - attr_file = 'psu_power_good' - attr_path = self.SYSFS_PSU_DIR[self.index-1] + '/' + attr_file - status = 0 - try: - with open(attr_path, 'r') as power_status: - status = int(power_status.read()) - except IOError: - return False - - return status == 1 diff --git a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/sfp.py b/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/sfp.py deleted file mode 100644 index 39c21c0d11c..00000000000 --- a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/sfp.py +++ /dev/null @@ -1,1128 +0,0 @@ -############################################################################# -# Sfp contains an implementation of SONiC Platform Base API and -# provides the sfp device status which are available in the platform -############################################################################# -try: - import time - import subprocess - from ctypes import create_string_buffer - from sonic_platform_base.sfp_base import SfpBase - from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom - from sonic_platform_base.sonic_sfp.sff8472 import sff8472InterfaceId - from sonic_platform_base.sonic_sfp.sff8472 import sffbase - from sonic_platform_base.sonic_sfp.sff8436 import sff8436Dom - from sonic_platform_base.sonic_sfp.sff8436 import sff8436InterfaceId - from sonic_platform_base.sonic_sfp.sfputilhelper import SfpUtilHelper -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -INFO_OFFSET = 0 -DOM_OFFSET = 256 - -QSFP_INFO_OFFSET = 128 -QSFP_DOM_OFFSET = 0 - -XCVR_INTFACE_BULK_OFFSET = 0 -XCVR_INTFACE_BULK_WIDTH_QSFP = 20 -XCVR_HW_REV_WIDTH_QSFP = 2 -XCVR_CABLE_LENGTH_WIDTH_QSFP = 5 -XCVR_VENDOR_NAME_OFFSET = 20 -XCVR_VENDOR_NAME_WIDTH = 16 -XCVR_VENDOR_OUI_OFFSET = 37 -XCVR_VENDOR_OUI_WIDTH = 3 -XCVR_VENDOR_PN_OFFSET = 40 -XCVR_VENDOR_PN_WIDTH = 16 -XCVR_HW_REV_OFFSET = 56 -XCVR_HW_REV_WIDTH_OSFP = 2 -XCVR_HW_REV_WIDTH_SFP = 4 -XCVR_VENDOR_SN_OFFSET = 68 -XCVR_VENDOR_SN_WIDTH = 16 -XCVR_VENDOR_DATE_OFFSET = 84 -XCVR_VENDOR_DATE_WIDTH = 8 -XCVR_DOM_CAPABILITY_OFFSET = 92 -XCVR_DOM_CAPABILITY_WIDTH = 1 - -# Offset for values in SFP eeprom -SFP_TEMPE_OFFSET = 96 -SFP_TEMPE_WIDTH = 2 -SFP_VOLT_OFFSET = 98 -SFP_VOLT_WIDTH = 2 -SFP_CHANNL_MON_OFFSET = 100 -SFP_CHANNL_MON_WIDTH = 6 -SFP_MODULE_THRESHOLD_OFFSET = 0 -SFP_MODULE_THRESHOLD_WIDTH = 40 -SFP_CHANNL_THRESHOLD_OFFSET = 112 -SFP_CHANNL_THRESHOLD_WIDTH = 2 -SFP_STATUS_CONTROL_OFFSET = 110 -SFP_STATUS_CONTROL_WIDTH = 1 -SFP_TX_DISABLE_HARD_BIT = 7 -SFP_TX_DISABLE_SOFT_BIT = 6 - - -sfp_cable_length_tup = ('LengthSMFkm-UnitsOfKm', 'LengthSMF(UnitsOf100m)', - 'Length50um(UnitsOf10m)', 'Length62.5um(UnitsOfm)', - 'LengthCable(UnitsOfm)', 'LengthOM3(UnitsOf10m)') - -sfp_compliance_code_tup = ('10GEthernetComplianceCode', 'InfinibandComplianceCode', - 'ESCONComplianceCodes', 'SONETComplianceCodes', - 'EthernetComplianceCodes', 'FibreChannelLinkLength', - 'FibreChannelTechnology', 'SFP+CableTechnology', - 'FibreChannelTransmissionMedia', 'FibreChannelSpeed') - -# Offset for values in QSFP eeprom -QSFP_DOM_REV_OFFSET = 1 -QSFP_DOM_REV_WIDTH = 1 -QSFP_TEMPE_OFFSET = 22 -QSFP_TEMPE_WIDTH = 2 -QSFP_VOLT_OFFSET = 26 -QSFP_VOLT_WIDTH = 2 -QSFP_CHANNL_MON_OFFSET = 34 -QSFP_CHANNL_MON_WIDTH = 16 -QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH = 24 -QSFP_CONTROL_OFFSET = 86 -QSFP_CONTROL_WIDTH = 8 -QSFP_CHANNL_RX_LOS_STATUS_OFFSET = 3 -QSFP_CHANNL_RX_LOS_STATUS_WIDTH = 1 -QSFP_CHANNL_TX_FAULT_STATUS_OFFSET = 4 -QSFP_CHANNL_TX_FAULT_STATUS_WIDTH = 1 -QSFP_POWEROVERRIDE_OFFSET = 93 -QSFP_POWEROVERRIDE_WIDTH = 1 -QSFP_MODULE_THRESHOLD_OFFSET = 128 -QSFP_MODULE_THRESHOLD_WIDTH = 24 -QSFP_CHANNEL_THRESHOLD_OFFSET = 176 -QSFP_CHANNEL_THRESHOLD_WIDTH = 16 - -qsfp_cable_length_tup = ('Length(km)', 'Length OM3(2m)', - 'Length OM2(m)', 'Length OM1(m)', - 'Length Cable Assembly(m)') - -qsfp_compliance_code_tup = ('10/40G Ethernet Compliance Code', 'SONET Compliance codes', - 'SAS/SATA compliance codes', 'Gigabit Ethernet Compliant codes', - 'Fibre Channel link length/Transmitter Technology', - 'Fibre Channel transmission media', 'Fibre Channel Speed') - - -class Sfp(SfpBase): - """Platform-specific Sfp class""" - - # Port number - PORT_START = 0 - PORT_END = 53 - - port_to_i2c_mapping = { - 0: 37, - 1: 38, - 2: 39, - 3: 40, - 4: 41, - 5: 42, - 6: 43, - 7: 44, - 8: 45, - 9: 46, - 10: 47, - 11: 48, - 12: 49, - 13: 50, - 14: 51, - 15: 52, - 16: 53, - 17: 54, - 18: 55, - 19: 56, - 20: 57, - 21: 58, - 22: 59, - 23: 60, - 24: 61, - 25: 62, - 26: 63, - 27: 64, - 28: 65, - 29: 66, - 30: 67, - 31: 68, - 32: 69, - 33: 70, - 34: 71, - 35: 72, - 36: 73, - 37: 74, - 38: 75, - 39: 76, - 40: 77, - 41: 78, - 42: 79, - 43: 80, - 44: 81, - 45: 82, - 46: 83, - 47: 84, - 48: 21, - 49: 22, - 50: 23, - 51: 24, - 52: 25, - 53: 26, - } - _sfp_port = list(range(48, PORT_END + 1)) - RESET_PATH = "/sys/bus/i2c/devices/{}-0050/sfp_port_reset" - PRS_PATH = "/sys/bus/i2c/devices/{}-0050/sfp_is_present" - - PLATFORM_ROOT_PATH = '/usr/share/sonic/device' - PMON_HWSKU_PATH = '/usr/share/sonic/hwsku' - HOST_CHK_CMD = ["docker"] - - PLATFORM = "x86_64-accton_as7116_54x-r0" - HWSKU = "Accton-AS7116-54X-R0" - - def __init__(self, sfp_index, sfp_type): - # Init index - self.index = sfp_index - self.port_num = self.index + 1 - self.sfp_type = sfp_type - - # Init eeprom path - eeprom_path = '/sys/bus/i2c/devices/{0}-0050/sfp_eeprom' - self.port_to_eeprom_mapping = {} - for x in range(self.PORT_START, self.PORT_END + 1): - p_num = x - 1 if self.PORT_START == 1 else x - self.port_to_eeprom_mapping[p_num] = eeprom_path.format( - self.port_to_i2c_mapping[p_num]) - - self.info_dict_keys = ['type', 'vendor_rev', 'serial', 'manufacturer', 'model', 'connector', 'encoding', 'ext_identifier', - 'ext_rateselect_compliance', 'cable_type', 'cable_length', 'nominal_bit_rate', 'specification_compliance', 'vendor_date', 'vendor_oui'] - - self.dom_dict_keys = ['rx_los', 'tx_fault', 'reset_status', 'power_lpmode', 'tx_disable', 'tx_disable_channel', 'temperature', 'voltage', - 'rx1power', 'rx2power', 'rx3power', 'rx4power', 'tx1bias', 'tx2bias', 'tx3bias', 'tx4bias', 'tx1power', 'tx2power', 'tx3power', 'tx4power'] - - self.threshold_dict_keys = ['temphighalarm', 'temphighwarning', 'templowalarm', 'templowwarning', 'vcchighalarm', 'vcchighwarning', 'vcclowalarm', 'vcclowwarning', 'rxpowerhighalarm', 'rxpowerhighwarning', - 'rxpowerlowalarm', 'rxpowerlowwarning', 'txpowerhighalarm', 'txpowerhighwarning', 'txpowerlowalarm', 'txpowerlowwarning', 'txbiashighalarm', 'txbiashighwarning', 'txbiaslowalarm', 'txbiaslowwarning'] - - SfpBase.__init__(self) - - def _convert_string_to_num(self, value_str): - if "-inf" in value_str: - return 'N/A' - elif "Unknown" in value_str: - return 'N/A' - elif 'dBm' in value_str: - t_str = value_str.rstrip('dBm') - return float(t_str) - elif 'mA' in value_str: - t_str = value_str.rstrip('mA') - return float(t_str) - elif 'C' in value_str: - t_str = value_str.rstrip('C') - return float(t_str) - elif 'Volts' in value_str: - t_str = value_str.rstrip('Volts') - return float(t_str) - else: - return 'N/A' - - def __read_txt_file(self, file_path): - try: - with open(file_path, 'r') as fd: - data = fd.read() - return data.strip() - except IOError: - pass - return "" - - def __is_host(self): - return subprocess.call(self.HOST_CHK_CMD) == 0 - - def __get_path_to_port_config_file(self): - platform_path = "/".join([self.PLATFORM_ROOT_PATH, self.PLATFORM]) - hwsku_path = "/".join([platform_path, self.HWSKU] - ) if self.__is_host() else self.PMON_HWSKU_PATH - return "/".join([hwsku_path, "port_config.ini"]) - - def __read_eeprom_specific_bytes(self, offset, num_bytes): - sysfsfile_eeprom = None - eeprom_raw = [] - for i in range(0, num_bytes): - eeprom_raw.append("0x00") - - sysfs_sfp_i2c_client_eeprom_path = self.port_to_eeprom_mapping[self.sfp_index] - try: - sysfsfile_eeprom = open( - sysfs_sfp_i2c_client_eeprom_path, mode="rb", buffering=0) - sysfsfile_eeprom.seek(offset) - raw = sysfsfile_eeprom.read(num_bytes) - for n in range(0, num_bytes): - eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) - except: - pass - finally: - if sysfsfile_eeprom: - sysfsfile_eeprom.close() - - return eeprom_raw - - def get_transceiver_info(self): - """ - Retrieves transceiver info of this SFP - Returns: - A dict which contains following keys/values : - """ - if self.sfp_type == "SFP": - get_sfp_transceiver_info - else: - get_qsfp_transceiver_info - - def get_transceiver_bulk_status(self): - """ - Retrieves transceiver bulk status of this SFP - Returns: - A dict which contains following keys/values : - """ - if self.sfp_type == "SFP": - get_sfp_transceiver_bulk_status - else: - get_qsfp_transceiver_bulk_status - - def get_transceiver_threshold_info(self): - """ - Retrieves transceiver threshold info of this SFP - Returns: - A dict which contains following keys/values : - """ - if self.sfp_type == "SFP": - get_sfp_transceiver_threshold_info - else: - get_qsfp_transceiver_threshold_info - - def get_sfp_transceiver_info(self): - """ - Retrieves transceiver info of this SFP - Returns: - A dict which contains following keys/values : - ======================================================================== - keys |Value Format |Information - ---------------------------|---------------|---------------------------- - type |1*255VCHAR |type of SFP - vendor_rev |1*255VCHAR |vendor revision of SFP - serial |1*255VCHAR |serial number of the SFP - manufacturer |1*255VCHAR |SFP vendor name - model |1*255VCHAR |SFP model name - connector |1*255VCHAR |connector information - encoding |1*255VCHAR |encoding information - ext_identifier |1*255VCHAR |extend identifier - ext_rateselect_compliance |1*255VCHAR |extended rateSelect compliance - cable_length |INT |cable length in m - nominal_bit_rate |INT |nominal bit rate by 100Mbs - specification_compliance |1*255VCHAR |specification compliance - vendor_date |1*255VCHAR |vendor date - vendor_oui |1*255VCHAR |vendor OUI - ======================================================================== - """ - # check present status - sfpi_obj = sff8472InterfaceId() - if not self.get_presence() or not sfpi_obj: - return {} - - offset = INFO_OFFSET - - sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_INTFACE_BULK_OFFSET), XCVR_INTFACE_BULK_WIDTH_SFP) - sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk( - sfp_interface_bulk_raw, 0) - - sfp_vendor_name_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_VENDOR_NAME_OFFSET), XCVR_VENDOR_NAME_WIDTH) - sfp_vendor_name_data = sfpi_obj.parse_vendor_name( - sfp_vendor_name_raw, 0) - - sfp_vendor_pn_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_VENDOR_PN_OFFSET), XCVR_VENDOR_PN_WIDTH) - sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn( - sfp_vendor_pn_raw, 0) - - sfp_vendor_rev_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_HW_REV_OFFSET), XCVR_HW_REV_WIDTH_SFP) - sfp_vendor_rev_data = sfpi_obj.parse_vendor_rev( - sfp_vendor_rev_raw, 0) - - sfp_vendor_sn_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_VENDOR_SN_OFFSET), XCVR_VENDOR_SN_WIDTH) - sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn( - sfp_vendor_sn_raw, 0) - - sfp_vendor_oui_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_VENDOR_OUI_OFFSET), XCVR_VENDOR_OUI_WIDTH) - if sfp_vendor_oui_raw is not None: - sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui( - sfp_vendor_oui_raw, 0) - - sfp_vendor_date_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_VENDOR_DATE_OFFSET), XCVR_VENDOR_DATE_WIDTH) - sfp_vendor_date_data = sfpi_obj.parse_vendor_date( - sfp_vendor_date_raw, 0) - - transceiver_info_dict = dict.fromkeys(self.info_dict_keys, 'N/A') - compliance_code_dict = dict() - - if sfp_interface_bulk_data: - transceiver_info_dict['type'] = sfp_interface_bulk_data['data']['type']['value'] - transceiver_info_dict['connector'] = sfp_interface_bulk_data['data']['Connector']['value'] - transceiver_info_dict['encoding'] = sfp_interface_bulk_data['data']['EncodingCodes']['value'] - transceiver_info_dict['ext_identifier'] = sfp_interface_bulk_data['data']['Extended Identifier']['value'] - transceiver_info_dict['ext_rateselect_compliance'] = sfp_interface_bulk_data['data']['RateIdentifier']['value'] - transceiver_info_dict['type_abbrv_name'] = sfp_interface_bulk_data['data']['type_abbrv_name']['value'] - - transceiver_info_dict['manufacturer'] = sfp_vendor_name_data[ - 'data']['Vendor Name']['value'] if sfp_vendor_name_data else 'N/A' - transceiver_info_dict['model'] = sfp_vendor_pn_data['data']['Vendor PN']['value'] if sfp_vendor_pn_data else 'N/A' - transceiver_info_dict['vendor_rev'] = sfp_vendor_rev_data['data']['Vendor Rev']['value'] if sfp_vendor_rev_data else 'N/A' - transceiver_info_dict['serial'] = sfp_vendor_sn_data['data']['Vendor SN']['value'] if sfp_vendor_sn_data else 'N/A' - transceiver_info_dict['vendor_oui'] = sfp_vendor_oui_data['data']['Vendor OUI']['value'] if sfp_vendor_oui_data else 'N/A' - transceiver_info_dict['vendor_date'] = sfp_vendor_date_data[ - 'data']['VendorDataCode(YYYY-MM-DD Lot)']['value'] if sfp_vendor_date_data else 'N/A' - transceiver_info_dict['cable_type'] = "Unknown" - transceiver_info_dict['cable_length'] = "Unknown" - - for key in sfp_cable_length_tup: - if key in sfp_interface_bulk_data['data']: - transceiver_info_dict['cable_type'] = key - transceiver_info_dict['cable_length'] = str( - sfp_interface_bulk_data['data'][key]['value']) - - for key in sfp_compliance_code_tup: - if key in sfp_interface_bulk_data['data']['Specification compliance']['value']: - compliance_code_dict[key] = sfp_interface_bulk_data['data']['Specification compliance']['value'][key]['value'] - transceiver_info_dict['specification_compliance'] = str( - compliance_code_dict) - transceiver_info_dict['nominal_bit_rate'] = str( - sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value']) - - return transceiver_info_dict - - def get_sfp_transceiver_bulk_status(self): - """ - Retrieves transceiver bulk status of this SFP - Returns: - A dict which contains following keys/values : - ======================================================================== - keys |Value Format |Information - ---------------------------|---------------|---------------------------- - rx_los |BOOLEAN |RX loss-of-signal status, True if has RX los, False if not. - tx_fault |BOOLEAN |TX fault status, True if has TX fault, False if not. - reset_status |BOOLEAN |reset status, True if SFP in reset, False if not. - lp_mode |BOOLEAN |low power mode status, True in lp mode, False if not. - tx_disable |BOOLEAN |TX disable status, True TX disabled, False if not. - tx_disabled_channel |HEX |disabled TX channels in hex, bits 0 to 3 represent channel 0 - | |to channel 3. - temperature |INT |module temperature in Celsius - voltage |INT |supply voltage in mV - txbias |INT |TX Bias Current in mA, n is the channel number, - | |for example, tx2bias stands for tx bias of channel 2. - rxpower |INT |received optical power in mW, n is the channel number, - | |for example, rx2power stands for rx power of channel 2. - txpower |INT |TX output power in mW, n is the channel number, - | |for example, tx2power stands for tx power of channel 2. - ======================================================================== - """ - # check present status - sfpd_obj = sff8472Dom() - if not self.get_presence() or not sfpd_obj: - return {} - - eeprom_ifraw = self.__read_eeprom_specific_bytes(0, DOM_OFFSET) - sfpi_obj = sff8472InterfaceId(eeprom_ifraw) - cal_type = sfpi_obj.get_calibration_type() - sfpd_obj._calibration_type = cal_type - - offset = DOM_OFFSET - transceiver_dom_info_dict = dict.fromkeys(self.dom_dict_keys, 'N/A') - dom_temperature_raw = self.__read_eeprom_specific_bytes( - (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH) - - if dom_temperature_raw is not None: - dom_temperature_data = sfpd_obj.parse_temperature( - dom_temperature_raw, 0) - transceiver_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value'] - - dom_voltage_raw = self.__read_eeprom_specific_bytes( - (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH) - if dom_voltage_raw is not None: - dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) - transceiver_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value'] - - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( - (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) - if dom_channel_monitor_raw is not None: - dom_voltage_data = sfpd_obj.parse_channel_monitor_params( - dom_channel_monitor_raw, 0) - transceiver_dom_info_dict['tx1power'] = dom_voltage_data['data']['TXPower']['value'] - transceiver_dom_info_dict['rx1power'] = dom_voltage_data['data']['RXPower']['value'] - transceiver_dom_info_dict['tx1bias'] = dom_voltage_data['data']['TXBias']['value'] - - for key in transceiver_dom_info_dict: - transceiver_dom_info_dict[key] = self._convert_string_to_num( - transceiver_dom_info_dict[key]) - - transceiver_dom_info_dict['rx_los'] = self.get_rx_los() - transceiver_dom_info_dict['tx_fault'] = self.get_tx_fault() - transceiver_dom_info_dict['reset_status'] = self.get_reset_status() - transceiver_dom_info_dict['lp_mode'] = self.get_lpmode() - - return transceiver_dom_info_dict - - def get_sfp_transceiver_threshold_info(self): - """ - Retrieves transceiver threshold info of this SFP - Returns: - A dict which contains following keys/values : - ======================================================================== - keys |Value Format |Information - ---------------------------|---------------|---------------------------- - temphighalarm |FLOAT |High Alarm Threshold value of temperature in Celsius. - templowalarm |FLOAT |Low Alarm Threshold value of temperature in Celsius. - temphighwarning |FLOAT |High Warning Threshold value of temperature in Celsius. - templowwarning |FLOAT |Low Warning Threshold value of temperature in Celsius. - vcchighalarm |FLOAT |High Alarm Threshold value of supply voltage in mV. - vcclowalarm |FLOAT |Low Alarm Threshold value of supply voltage in mV. - vcchighwarning |FLOAT |High Warning Threshold value of supply voltage in mV. - vcclowwarning |FLOAT |Low Warning Threshold value of supply voltage in mV. - rxpowerhighalarm |FLOAT |High Alarm Threshold value of received power in dBm. - rxpowerlowalarm |FLOAT |Low Alarm Threshold value of received power in dBm. - rxpowerhighwarning |FLOAT |High Warning Threshold value of received power in dBm. - rxpowerlowwarning |FLOAT |Low Warning Threshold value of received power in dBm. - txpowerhighalarm |FLOAT |High Alarm Threshold value of transmit power in dBm. - txpowerlowalarm |FLOAT |Low Alarm Threshold value of transmit power in dBm. - txpowerhighwarning |FLOAT |High Warning Threshold value of transmit power in dBm. - txpowerlowwarning |FLOAT |Low Warning Threshold value of transmit power in dBm. - txbiashighalarm |FLOAT |High Alarm Threshold value of tx Bias Current in mA. - txbiaslowalarm |FLOAT |Low Alarm Threshold value of tx Bias Current in mA. - txbiashighwarning |FLOAT |High Warning Threshold value of tx Bias Current in mA. - txbiaslowwarning |FLOAT |Low Warning Threshold value of tx Bias Current in mA. - ======================================================================== - """ - # check present status - sfpd_obj = sff8472Dom() - - if not self.get_presence() and not sfpd_obj: - return {} - - eeprom_ifraw = self.__read_eeprom_specific_bytes(0, DOM_OFFSET) - sfpi_obj = sff8472InterfaceId(eeprom_ifraw) - cal_type = sfpi_obj.get_calibration_type() - sfpd_obj._calibration_type = cal_type - - offset = DOM_OFFSET - transceiver_dom_threshold_info_dict = dict.fromkeys( - self.threshold_dict_keys, 'N/A') - dom_module_threshold_raw = self.__read_eeprom_specific_bytes( - (offset + SFP_MODULE_THRESHOLD_OFFSET), SFP_MODULE_THRESHOLD_WIDTH) - if dom_module_threshold_raw is not None: - dom_module_threshold_data = sfpd_obj.parse_alarm_warning_threshold( - dom_module_threshold_raw, 0) - - transceiver_dom_threshold_info_dict['temphighalarm'] = dom_module_threshold_data['data']['TempHighAlarm']['value'] - transceiver_dom_threshold_info_dict['templowalarm'] = dom_module_threshold_data['data']['TempLowAlarm']['value'] - transceiver_dom_threshold_info_dict['temphighwarning'] = dom_module_threshold_data['data']['TempHighWarning']['value'] - transceiver_dom_threshold_info_dict['templowwarning'] = dom_module_threshold_data['data']['TempLowWarning']['value'] - transceiver_dom_threshold_info_dict['vcchighalarm'] = dom_module_threshold_data['data']['VoltageHighAlarm']['value'] - transceiver_dom_threshold_info_dict['vcclowalarm'] = dom_module_threshold_data['data']['VoltageLowAlarm']['value'] - transceiver_dom_threshold_info_dict['vcchighwarning'] = dom_module_threshold_data[ - 'data']['VoltageHighWarning']['value'] - transceiver_dom_threshold_info_dict['vcclowwarning'] = dom_module_threshold_data['data']['VoltageLowWarning']['value'] - transceiver_dom_threshold_info_dict['txbiashighalarm'] = dom_module_threshold_data['data']['BiasHighAlarm']['value'] - transceiver_dom_threshold_info_dict['txbiaslowalarm'] = dom_module_threshold_data['data']['BiasLowAlarm']['value'] - transceiver_dom_threshold_info_dict['txbiashighwarning'] = dom_module_threshold_data['data']['BiasHighWarning']['value'] - transceiver_dom_threshold_info_dict['txbiaslowwarning'] = dom_module_threshold_data['data']['BiasLowWarning']['value'] - transceiver_dom_threshold_info_dict['txpowerhighalarm'] = dom_module_threshold_data['data']['TXPowerHighAlarm']['value'] - transceiver_dom_threshold_info_dict['txpowerlowalarm'] = dom_module_threshold_data['data']['TXPowerLowAlarm']['value'] - transceiver_dom_threshold_info_dict['txpowerhighwarning'] = dom_module_threshold_data['data']['TXPowerHighWarning']['value'] - transceiver_dom_threshold_info_dict['txpowerlowwarning'] = dom_module_threshold_data['data']['TXPowerLowWarning']['value'] - transceiver_dom_threshold_info_dict['rxpowerhighalarm'] = dom_module_threshold_data['data']['RXPowerHighAlarm']['value'] - transceiver_dom_threshold_info_dict['rxpowerlowalarm'] = dom_module_threshold_data['data']['RXPowerLowAlarm']['value'] - transceiver_dom_threshold_info_dict['rxpowerhighwarning'] = dom_module_threshold_data['data']['RXPowerHighWarning']['value'] - transceiver_dom_threshold_info_dict['rxpowerlowwarning'] = dom_module_threshold_data['data']['RXPowerLowWarning']['value'] - - for key in transceiver_dom_threshold_info_dict: - transceiver_dom_threshold_info_dict[key] = self._convert_string_to_num( - transceiver_dom_threshold_info_dict[key]) - - return transceiver_dom_threshold_info_dict - - def get_qsfp_transceiver_info(self): - """ - Retrieves transceiver info of this SFP - Returns: - A dict which contains following keys/values : - ======================================================================== - keys |Value Format |Information - ---------------------------|---------------|---------------------------- - type |1*255VCHAR |type of SFP - vendor_rev |1*255VCHAR |hardware version of SFP - serial |1*255VCHAR |serial number of the SFP - manufacturer |1*255VCHAR |SFP vendor name - model |1*255VCHAR |SFP model name - connector |1*255VCHAR |connector information - encoding |1*255VCHAR |encoding information - ext_identifier |1*255VCHAR |extend identifier - ext_rateselect_compliance |1*255VCHAR |extended rateSelect compliance - cable_length |INT |cable length in m - nominal_bit_rate |INT |nominal bit rate by 100Mbs - specification_compliance |1*255VCHAR |specification compliance - vendor_date |1*255VCHAR |vendor date - vendor_oui |1*255VCHAR |vendor OUI - ======================================================================== - """ - # check present status - sfpi_obj = sff8436InterfaceId() - if not self.get_presence() or not sfpi_obj: - return {} - - offset = INFO_OFFSET - - sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_INTFACE_BULK_OFFSET), XCVR_INTFACE_BULK_WIDTH_QSFP) - sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk( - sfp_interface_bulk_raw, 0) - - sfp_vendor_name_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_VENDOR_NAME_OFFSET), XCVR_VENDOR_NAME_WIDTH) - sfp_vendor_name_data = sfpi_obj.parse_vendor_name( - sfp_vendor_name_raw, 0) - - sfp_vendor_pn_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_VENDOR_PN_OFFSET), XCVR_VENDOR_PN_WIDTH) - sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn( - sfp_vendor_pn_raw, 0) - - sfp_vendor_rev_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_HW_REV_OFFSET), XCVR_HW_REV_WIDTH_QSFP) - sfp_vendor_rev_data = sfpi_obj.parse_vendor_rev( - sfp_vendor_rev_raw, 0) - - sfp_vendor_sn_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_VENDOR_SN_OFFSET), XCVR_VENDOR_SN_WIDTH) - sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn( - sfp_vendor_sn_raw, 0) - - sfp_vendor_oui_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_VENDOR_OUI_OFFSET), XCVR_VENDOR_OUI_WIDTH) - if sfp_vendor_oui_raw is not None: - sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui( - sfp_vendor_oui_raw, 0) - - sfp_vendor_date_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_VENDOR_DATE_OFFSET), XCVR_VENDOR_DATE_WIDTH) - sfp_vendor_date_data = sfpi_obj.parse_vendor_date( - sfp_vendor_date_raw, 0) - - transceiver_info_dict = dict.fromkeys(self.info_dict_keys, 'N/A') - compliance_code_dict = dict() - - if sfp_interface_bulk_data: - transceiver_info_dict['type'] = sfp_interface_bulk_data['data']['type']['value'] - transceiver_info_dict['connector'] = sfp_interface_bulk_data['data']['Connector']['value'] - transceiver_info_dict['encoding'] = sfp_interface_bulk_data['data']['EncodingCodes']['value'] - transceiver_info_dict['ext_identifier'] = sfp_interface_bulk_data['data']['Extended Identifier']['value'] - transceiver_info_dict['ext_rateselect_compliance'] = sfp_interface_bulk_data['data']['RateIdentifier']['value'] - transceiver_info_dict['type_abbrv_name'] = sfp_interface_bulk_data['data']['type_abbrv_name']['value'] - - transceiver_info_dict['manufacturer'] = sfp_vendor_name_data[ - 'data']['Vendor Name']['value'] if sfp_vendor_name_data else 'N/A' - transceiver_info_dict['model'] = sfp_vendor_pn_data['data']['Vendor PN']['value'] if sfp_vendor_pn_data else 'N/A' - transceiver_info_dict['vendor_rev'] = sfp_vendor_rev_data['data']['Vendor Rev']['value'] if sfp_vendor_rev_data else 'N/A' - transceiver_info_dict['serial'] = sfp_vendor_sn_data['data']['Vendor SN']['value'] if sfp_vendor_sn_data else 'N/A' - transceiver_info_dict['vendor_oui'] = sfp_vendor_oui_data['data']['Vendor OUI']['value'] if sfp_vendor_oui_data else 'N/A' - transceiver_info_dict['vendor_date'] = sfp_vendor_date_data[ - 'data']['VendorDataCode(YYYY-MM-DD Lot)']['value'] if sfp_vendor_date_data else 'N/A' - transceiver_info_dict['cable_type'] = "Unknown" - transceiver_info_dict['cable_length'] = "Unknown" - - for key in qsfp_cable_length_tup: - if key in sfp_interface_bulk_data['data']: - transceiver_info_dict['cable_type'] = key - transceiver_info_dict['cable_length'] = str( - sfp_interface_bulk_data['data'][key]['value']) - - for key in qsfp_compliance_code_tup: - if key in sfp_interface_bulk_data['data']['Specification compliance']['value']: - compliance_code_dict[key] = sfp_interface_bulk_data['data']['Specification compliance']['value'][key]['value'] - transceiver_info_dict['specification_compliance'] = str( - compliance_code_dict) - transceiver_info_dict['nominal_bit_rate'] = str( - sfp_interface_bulk_data['data']['Nominal Bit Rate(100Mbs)']['value']) - - return transceiver_info_dict - - def get_qsfp_transceiver_bulk_status(self): - """ - Retrieves transceiver bulk status of this SFP - Returns: - A dict which contains following keys/values : - ======================================================================== - keys |Value Format |Information - ---------------------------|---------------|---------------------------- - rx_los |BOOLEAN |RX loss-of-signal status, True if has RX los, False if not. - tx_fault |BOOLEAN |TX fault status, True if has TX fault, False if not. - reset_status |BOOLEAN |reset status, True if SFP in reset, False if not. - lp_mode |BOOLEAN |low power mode status, True in lp mode, False if not. - tx_disable |BOOLEAN |TX disable status, True TX disabled, False if not. - tx_disabled_channel |HEX |disabled TX channels in hex, bits 0 to 3 represent channel 0 - | |to channel 3. - temperature |INT |module temperature in Celsius - voltage |INT |supply voltage in mV - txbias |INT |TX Bias Current in mA, n is the channel number, - | |for example, tx2bias stands for tx bias of channel 2. - rxpower |INT |received optical power in mW, n is the channel number, - | |for example, rx2power stands for rx power of channel 2. - txpower |INT |TX output power in mW, n is the channel number, - | |for example, tx2power stands for tx power of channel 2. - ======================================================================== - """ - # check present status - sfpd_obj = sff8436Dom() - sfpi_obj = sff8436InterfaceId() - - if not self.get_presence() or not sfpi_obj or not sfpd_obj: - return {} - - transceiver_dom_info_dict = dict.fromkeys(self.dom_dict_keys, 'N/A') - offset = DOM_OFFSET - offset_xcvr = INFO_OFFSET - - # QSFP capability byte parse, through this byte can know whether it support tx_power or not. - # TODO: in the future when decided to migrate to support SFF-8636 instead of SFF-8436, - # need to add more code for determining the capability and version compliance - # in SFF-8636 dom capability definitions evolving with the versions. - qsfp_dom_capability_raw = self.__read_eeprom_specific_bytes( - (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) - if qsfp_dom_capability_raw is not None: - qspf_dom_capability_data = sfpi_obj.parse_dom_capability( - qsfp_dom_capability_raw, 0) - else: - return None - - dom_temperature_raw = self.__read_eeprom_specific_bytes( - (offset + QSFP_TEMPE_OFFSET), QSFP_TEMPE_WIDTH) - if dom_temperature_raw is not None: - dom_temperature_data = sfpd_obj.parse_temperature( - dom_temperature_raw, 0) - transceiver_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value'] - - dom_voltage_raw = self.__read_eeprom_specific_bytes( - (offset + QSFP_VOLT_OFFSET), QSFP_VOLT_WIDTH) - if dom_voltage_raw is not None: - dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) - transceiver_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value'] - - qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes( - (offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH) - if qsfp_dom_rev_raw is not None: - qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev(qsfp_dom_rev_raw, 0) - qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value'] - - # The tx_power monitoring is only available on QSFP which compliant with SFF-8636 - # and claimed that it support tx_power with one indicator bit. - dom_channel_monitor_data = {} - dom_channel_monitor_raw = None - qsfp_tx_power_support = qspf_dom_capability_data['data']['Tx_power_support']['value'] - if (qsfp_dom_rev[0:8] != 'SFF-8636' or (qsfp_dom_rev[0:8] == 'SFF-8636' and qsfp_tx_power_support != 'on')): - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( - (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WIDTH) - if dom_channel_monitor_raw is not None: - dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params( - dom_channel_monitor_raw, 0) - - else: - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( - (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) - if dom_channel_monitor_raw is not None: - dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power( - dom_channel_monitor_raw, 0) - transceiver_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TX1Power']['value'] - transceiver_dom_info_dict['tx2power'] = dom_channel_monitor_data['data']['TX2Power']['value'] - transceiver_dom_info_dict['tx3power'] = dom_channel_monitor_data['data']['TX3Power']['value'] - transceiver_dom_info_dict['tx4power'] = dom_channel_monitor_data['data']['TX4Power']['value'] - - if dom_channel_monitor_raw: - transceiver_dom_info_dict['rx1power'] = dom_channel_monitor_data['data']['RX1Power']['value'] - transceiver_dom_info_dict['rx2power'] = dom_channel_monitor_data['data']['RX2Power']['value'] - transceiver_dom_info_dict['rx3power'] = dom_channel_monitor_data['data']['RX3Power']['value'] - transceiver_dom_info_dict['rx4power'] = dom_channel_monitor_data['data']['RX4Power']['value'] - transceiver_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data']['TX1Bias']['value'] - transceiver_dom_info_dict['tx2bias'] = dom_channel_monitor_data['data']['TX2Bias']['value'] - transceiver_dom_info_dict['tx3bias'] = dom_channel_monitor_data['data']['TX3Bias']['value'] - transceiver_dom_info_dict['tx4bias'] = dom_channel_monitor_data['data']['TX4Bias']['value'] - - for key in transceiver_dom_info_dict: - transceiver_dom_info_dict[key] = self._convert_string_to_num( - transceiver_dom_info_dict[key]) - - transceiver_dom_info_dict['rx_los'] = self.get_rx_los() - transceiver_dom_info_dict['tx_fault'] = self.get_tx_fault() - transceiver_dom_info_dict['reset_status'] = self.get_reset_status() - transceiver_dom_info_dict['lp_mode'] = self.get_lpmode() - - return transceiver_dom_info_dict - - def get_qsfp_transceiver_threshold_info(self): - """ - Retrieves transceiver threshold info of this SFP - Returns: - A dict which contains following keys/values : - ======================================================================== - keys |Value Format |Information - ---------------------------|---------------|---------------------------- - temphighalarm |FLOAT |High Alarm Threshold value of temperature in Celsius. - templowalarm |FLOAT |Low Alarm Threshold value of temperature in Celsius. - temphighwarning |FLOAT |High Warning Threshold value of temperature in Celsius. - templowwarning |FLOAT |Low Warning Threshold value of temperature in Celsius. - vcchighalarm |FLOAT |High Alarm Threshold value of supply voltage in mV. - vcclowalarm |FLOAT |Low Alarm Threshold value of supply voltage in mV. - vcchighwarning |FLOAT |High Warning Threshold value of supply voltage in mV. - vcclowwarning |FLOAT |Low Warning Threshold value of supply voltage in mV. - rxpowerhighalarm |FLOAT |High Alarm Threshold value of received power in dBm. - rxpowerlowalarm |FLOAT |Low Alarm Threshold value of received power in dBm. - rxpowerhighwarning |FLOAT |High Warning Threshold value of received power in dBm. - rxpowerlowwarning |FLOAT |Low Warning Threshold value of received power in dBm. - txpowerhighalarm |FLOAT |High Alarm Threshold value of transmit power in dBm. - txpowerlowalarm |FLOAT |Low Alarm Threshold value of transmit power in dBm. - txpowerhighwarning |FLOAT |High Warning Threshold value of transmit power in dBm. - txpowerlowwarning |FLOAT |Low Warning Threshold value of transmit power in dBm. - txbiashighalarm |FLOAT |High Alarm Threshold value of tx Bias Current in mA. - txbiaslowalarm |FLOAT |Low Alarm Threshold value of tx Bias Current in mA. - txbiashighwarning |FLOAT |High Warning Threshold value of tx Bias Current in mA. - txbiaslowwarning |FLOAT |Low Warning Threshold value of tx Bias Current in mA. - ======================================================================== - """ - # check present status - sfpd_obj = sff8436Dom() - - if not self.get_presence() or not sfpd_obj: - return {} - - transceiver_dom_threshold_dict = dict.fromkeys( - self.threshold_dict_keys, 'N/A') - dom_thres_raw = self.__read_eeprom_specific_bytes( - QSFP_MODULE_THRESHOLD_OFFSET, QSFP_MODULE_THRESHOLD_WIDTH) if self.get_presence() and sfpd_obj else None - - if dom_thres_raw: - module_threshold_values = sfpd_obj.parse_module_threshold_values( - dom_thres_raw, 0) - module_threshold_data = module_threshold_values.get('data') - if module_threshold_data: - transceiver_dom_threshold_dict['temphighalarm'] = module_threshold_data['TempHighAlarm']['value'] - transceiver_dom_threshold_dict['templowalarm'] = module_threshold_data['TempLowAlarm']['value'] - transceiver_dom_threshold_dict['temphighwarning'] = module_threshold_data['TempHighWarning']['value'] - transceiver_dom_threshold_dict['templowwarning'] = module_threshold_data['TempLowWarning']['value'] - transceiver_dom_threshold_dict['vcchighalarm'] = module_threshold_data['VccHighAlarm']['value'] - transceiver_dom_threshold_dict['vcclowalarm'] = module_threshold_data['VccLowAlarm']['value'] - transceiver_dom_threshold_dict['vcchighwarning'] = module_threshold_data['VccHighWarning']['value'] - transceiver_dom_threshold_dict['vcclowwarning'] = module_threshold_data['VccLowWarning']['value'] - - dom_thres_raw = self.__read_eeprom_specific_bytes( - QSFP_CHANNEL_THRESHOLD_OFFSET, QSFP_CHANNEL_THRESHOLD_WIDTH) if self.get_presence() and sfpd_obj else None - channel_threshold_values = sfpd_obj.parse_channel_threshold_values( - dom_thres_raw, 0) - channel_threshold_data = channel_threshold_values.get('data') - if channel_threshold_data: - transceiver_dom_threshold_dict['rxpowerhighalarm'] = channel_threshold_data['RxPowerHighAlarm']['value'] - transceiver_dom_threshold_dict['rxpowerlowalarm'] = channel_threshold_data['RxPowerLowAlarm']['value'] - transceiver_dom_threshold_dict['rxpowerhighwarning'] = channel_threshold_data['RxPowerHighWarning']['value'] - transceiver_dom_threshold_dict['rxpowerlowwarning'] = channel_threshold_data['RxPowerLowWarning']['value'] - transceiver_dom_threshold_dict['txpowerhighalarm'] = "0.0dBm" - transceiver_dom_threshold_dict['txpowerlowalarm'] = "0.0dBm" - transceiver_dom_threshold_dict['txpowerhighwarning'] = "0.0dBm" - transceiver_dom_threshold_dict['txpowerlowwarning'] = "0.0dBm" - transceiver_dom_threshold_dict['txbiashighalarm'] = channel_threshold_data['TxBiasHighAlarm']['value'] - transceiver_dom_threshold_dict['txbiaslowalarm'] = channel_threshold_data['TxBiasLowAlarm']['value'] - transceiver_dom_threshold_dict['txbiashighwarning'] = channel_threshold_data['TxBiasHighWarning']['value'] - transceiver_dom_threshold_dict['txbiaslowwarning'] = channel_threshold_data['TxBiasLowWarning']['value'] - - for key in transceiver_dom_threshold_dict: - transceiver_dom_threshold_dict[key] = self._convert_string_to_num( - transceiver_dom_threshold_dict[key]) - - return transceiver_dom_threshold_dict - - def get_reset_status(self): - """ - Retrieves the reset status of SFP - Returns: - A Boolean, True if reset enabled, False if disabled - """ - # SFP doesn't support this feature - return False - - def get_rx_los(self): - """ - Retrieves the RX LOS (lost-of-signal) status of SFP - Returns: - A Boolean, True if SFP has RX LOS, False if not. - Note : RX LOS status is latched until a call to get_rx_los or a reset. - """ - rx_los = False - status_control_raw = self.__read_eeprom_specific_bytes( - SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) - if status_control_raw: - data = int(status_control_raw[0], 16) - rx_los = (sffbase().test_bit(data, 1) != 0) - - return rx_los - - def get_tx_fault(self): - """ - Retrieves the TX fault status of SFP - Returns: - A Boolean, True if SFP has TX fault, False if not - Note : TX fault status is lached until a call to get_tx_fault or a reset. - """ - tx_fault = False - status_control_raw = self.__read_eeprom_specific_bytes( - SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) - if status_control_raw: - data = int(status_control_raw[0], 16) - tx_fault = (sffbase().test_bit(data, 2) != 0) - - return tx_fault - - def get_tx_disable(self): - """ - Retrieves the tx_disable status of this SFP - Returns: - A Boolean, True if tx_disable is enabled, False if disabled - """ - tx_disable = False - tx_fault = False - status_control_raw = self.__read_eeprom_specific_bytes( - SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) - if status_control_raw: - data = int(status_control_raw[0], 16) - tx_disable_hard = (sffbase().test_bit( - data, SFP_TX_DISABLE_HARD_BIT) != 0) - tx_disable_soft = (sffbase().test_bit( - data, SFP_TX_DISABLE_SOFT_BIT) != 0) - tx_disable = tx_disable_hard | tx_disable_soft - - return tx_disable - - def get_tx_disable_channel(self): - """ - Retrieves the TX disabled channels in this SFP - Returns: - A hex of 4 bits (bit 0 to bit 3 as channel 0 to channel 3) to represent - TX channels which have been disabled in this SFP. - As an example, a returned value of 0x5 indicates that channel 0 - and channel 2 have been disabled. - """ - # SFP doesn't support this feature - return 0 - - def get_lpmode(self): - """ - Retrieves the lpmode (low power mode) status of this SFP - Returns: - A Boolean, True if lpmode is enabled, False if disabled - """ - # SFP doesn't support this feature - return False - - def get_power_override(self): - """ - Retrieves the power-override status of this SFP - Returns: - A Boolean, True if power-override is enabled, False if disabled - """ - # SFP doesn't support this feature - return False - - def get_temperature(self): - """ - Retrieves the temperature of this SFP - Returns: - An integer number of current temperature in Celsius - """ - transceiver_dom_info_dict = self.get_transceiver_bulk_status() - return transceiver_dom_info_dict.get("temperature", "N/A") - - def get_voltage(self): - """ - Retrieves the supply voltage of this SFP - Returns: - An integer number of supply voltage in mV - """ - transceiver_dom_info_dict = self.get_transceiver_bulk_status() - return transceiver_dom_info_dict.get("voltage", "N/A") - - def get_tx_bias(self): - """ - Retrieves the TX bias current of this SFP - Returns: - A list of four integer numbers, representing TX bias in mA - for channel 0 to channel 4. - Ex. ['110.09', '111.12', '108.21', '112.09'] - """ - transceiver_dom_info_dict = self.get_transceiver_bulk_status() - tx1_bs = transceiver_dom_info_dict.get("tx1bias", "N/A") - return [tx1_bs, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] - - def get_rx_power(self): - """ - Retrieves the received optical power for this SFP - Returns: - A list of four integer numbers, representing received optical - power in mW for channel 0 to channel 4. - Ex. ['1.77', '1.71', '1.68', '1.70'] - """ - transceiver_dom_info_dict = self.get_transceiver_bulk_status() - rx1_pw = transceiver_dom_info_dict.get("rx1power", "N/A") - return [rx1_pw, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] - - def get_tx_power(self): - """ - Retrieves the TX power of this SFP - Returns: - A list of four integer numbers, representing TX power in mW - for channel 0 to channel 4. - Ex. ['1.86', '1.86', '1.86', '1.86'] - """ - transceiver_dom_info_dict = self.get_transceiver_bulk_status() - tx1_pw = transceiver_dom_info_dict.get("tx1power", "N/A") - return [tx1_pw, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] - - def reset(self): - """ - Reset SFP and return all user module settings to their default srate. - Returns: - A boolean, True if successful, False if not - """ - # SFP doesn't support this feature - return False - - def tx_disable(self, tx_disable): - """ - Disable SFP TX for all channels - Args: - tx_disable : A Boolean, True to enable tx_disable mode, False to disable - tx_disable mode. - Returns: - A boolean, True if tx_disable is set successfully, False if not - """ - sysfs_sfp_i2c_client_eeprom_path = self.port_to_eeprom_mapping[self.index] - status_control_raw = self.__read_eeprom_specific_bytes( - SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) - if status_control_raw is not None: - # Set bit 6 for Soft TX Disable Select - # 01000000 = 64 and 10111111 = 191 - tx_disable_bit = 64 if tx_disable else 191 - status_control = int(status_control_raw[0], 16) - tx_disable_ctl = (status_control | tx_disable_bit) if tx_disable else ( - status_control & tx_disable_bit) - try: - sysfsfile_eeprom = open( - sysfs_sfp_i2c_client_eeprom_path, mode="r+b", buffering=0) - buffer = create_string_buffer(1) - buffer[0] = chr(tx_disable_ctl) - # Write to eeprom - sysfsfile_eeprom.seek(SFP_STATUS_CONTROL_OFFSET) - sysfsfile_eeprom.write(buffer[0]) - except: - #print("Error: unable to open file: %s" % str(e)) - return False - finally: - if sysfsfile_eeprom: - sysfsfile_eeprom.close() - time.sleep(0.01) - return True - return False - - def tx_disable_channel(self, channel, disable): - """ - Sets the tx_disable for specified SFP channels - Args: - channel : A hex of 4 bits (bit 0 to bit 3) which represent channel 0 to 3, - e.g. 0x5 for channel 0 and channel 2. - disable : A boolean, True to disable TX channels specified in channel, - False to enable - Returns: - A boolean, True if successful, False if not - """ - # SFP doesn't support this feature - return False - - def set_lpmode(self, lpmode): - """ - Sets the lpmode (low power mode) of SFP - Args: - lpmode: A Boolean, True to enable lpmode, False to disable it - Note : lpmode can be overridden by set_power_override - Returns: - A boolean, True if lpmode is set successfully, False if not - """ - # SFP doesn't support this feature - return False - - def set_power_override(self, power_override, power_set): - """ - Sets SFP power level using power_override and power_set - Args: - power_override : - A Boolean, True to override set_lpmode and use power_set - to control SFP power, False to disable SFP power control - through power_override/power_set and use set_lpmode - to control SFP power. - power_set : - Only valid when power_override is True. - A Boolean, True to set SFP to low power mode, False to set - SFP to high power mode. - Returns: - A boolean, True if power-override and power_set are set successfully, - False if not - """ - # SFP doesn't support this feature - return False - - def get_name(self): - """ - Retrieves the name of the device - Returns: - string: The name of the device - """ - sfputil_helper = SfpUtilHelper() - sfputil_helper.read_porttab_mappings( - self.__get_path_to_port_config_file()) - name = sfputil_helper.logical[self.index] or "Unknown" - return name - - def get_presence(self): - """ - Retrieves the presence of the SFP - Returns: - bool: True if SFP is present, False if not - """ - presence = False - - try: - with open(self.PRS_PATH.format(self.index), 'r') as sfp_presence: - presence = int(sfp_presence.read(), 16) - except IOError: - return False - logger.log_info("debug:port_ %s sfp presence is %s" % (str(self.index), str(presence))) - return presence - - def get_model(self): - """ - Retrieves the model number (or part number) of the device - Returns: - string: Model/part number of device - """ - transceiver_dom_info_dict = self.get_transceiver_info() - return transceiver_dom_info_dict.get("model", "N/A") - - def get_serial(self): - """ - Retrieves the serial number of the device - Returns: - string: Serial number of device - """ - transceiver_dom_info_dict = self.get_transceiver_info() - return transceiver_dom_info_dict.get("serial", "N/A") diff --git a/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/buffers.json.j2 b/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/buffers.json.j2 deleted file mode 100644 index 818e8e1f1e6..00000000000 --- a/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/buffers.json.j2 +++ /dev/null @@ -1,111 +0,0 @@ -{# Default values which will be used if no actual configura available #} -{% set default_cable = '40m' %} -{% set default_speed = '10G' %} -{% set default_ports_num = 54 -%} - -{# Port configuration to cable length look-up table #} -{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #} -{# Roles described in the minigraph #} -{% set ports2cable = { - 'torrouter_server' : '5m', - 'leafrouter_torrouter' : '40m', - 'spinerouter_leafrouter' : '300m' - } -%} - -{%- macro cable_length(port_name) -%} - {%- set cable_len = [] -%} - {%- for local_port in DEVICE_NEIGHBOR -%} - {%- if local_port == port_name -%} - {%- if DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} - {%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} - {%- set neighbor_role = neighbor.type -%} - {%- set roles1 = switch_role + '_' + neighbor_role %} - {%- set roles2 = neighbor_role + '_' + switch_role -%} - {%- set roles1 = roles1 | lower -%} - {%- set roles2 = roles2 | lower -%} - {%- if roles1 in ports2cable -%} - {%- if cable_len.append(ports2cable[roles1]) -%}{%- endif -%} - {%- elif roles2 in ports2cable -%} - {%- if cable_len.append(ports2cable[roles2]) -%}{%- endif -%} - {%- endif -%} - {%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- if cable_len -%} - {{ cable_len.0 }} - {%- else -%} - {{ default_cable }} - {%- endif -%} -{% endmacro %} - -{%- if DEVICE_METADATA is defined %} -{%- set switch_role = DEVICE_METADATA['localhost']['type'] %} -{%- endif -%} - -{# Generate list of ports if not defined #} -{% if PORT is not defined %} - {% set PORT = [] %} - {% for port_idx in range(0,default_ports_num) %} - {% if PORT.append("Ethernet%d" % (port_idx)) %}{% endif %} - {% endfor %} -{% endif -%} - -{% set port_names_list = [] %} -{% for port in PORT %} - {%- if port_names_list.append(port) %}{% endif %} -{% endfor %} -{% set port_names = port_names_list | join(',') -%} - -{ - "CABLE_LENGTH": { - "AZURE": { - {% for port in PORT %} - {% set cable = cable_length(port) -%} - "{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %} - - {% endfor %} - } - }, - "BUFFER_POOL": { - "ingress_lossless_pool": { - "size": "20971328", - "type": "ingress", - "mode": "static" - }, - "ingress_lossy_pool": { - "size": "20971328", - "type": "ingress", - "mode": "static" - }, - "egress_lossy_pool": { - "size": "20971328", - "type": "egress", - "mode": "static" - } - }, - "BUFFER_PROFILE": { - "ingress_lossless_profile": { - "pool":"ingress_lossless_pool", - "xon":"78400", - "xoff":"132160", - "size":"3584", - "static_th":"82880" - }, - "ingress_lossy_profile": { - "pool":"ingress_lossy_pool", - "size":"3584", - "dynamic_th":"-1" - }, - "egress_lossy_profile": { - "pool":"egress_lossy_pool", - "size":"3584", - "dynamic_th":"-4" - } - }, - "BUFFER_PG": { - }, - "BUFFER_QUEUE": { - } -} - \ No newline at end of file diff --git a/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/led.bin b/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/led.bin deleted file mode 100644 index 201662a1c60..00000000000 Binary files a/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/led.bin and /dev/null differ diff --git a/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/pg_profile_lookup.ini b/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/pg_profile_lookup.ini deleted file mode 100644 index d98b0eca6d1..00000000000 --- a/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/pg_profile_lookup.ini +++ /dev/null @@ -1,17 +0,0 @@ -# PG lossless profiles. -# speed cable size xon xoff threshold - 10000 5m 3584 32256 59136 36736 - 25000 5m 3584 41216 68096 45696 - 40000 5m 3584 47488 74368 51968 - 50000 5m 3584 52864 79744 57344 - 100000 5m 3584 78400 132160 82880 - 10000 40m 3584 32256 59136 36736 - 25000 40m 3584 41216 68096 45696 - 40000 40m 3584 47488 74368 51968 - 50000 40m 3584 52864 79744 57344 - 100000 40m 3584 78400 132160 82880 - 10000 300m 3584 32256 65856 36736 - 25000 300m 3584 41216 84672 45696 - 40000 300m 3584 47488 101024 51968 - 50000 300m 3584 52864 113120 57344 - 100000 300m 3584 78400 198688 82880 \ No newline at end of file diff --git a/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/port_config.ini b/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/port_config.ini deleted file mode 100644 index ab29b7bed9f..00000000000 --- a/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/port_config.ini +++ /dev/null @@ -1,55 +0,0 @@ -# name lanes alias index speed -Ethernet0 8 Ethernet1/1 1 10000 -Ethernet1 9 Ethernet2/1 2 10000 -Ethernet2 10 Ethernet3/1 3 10000 -Ethernet3 11 Ethernet4/1 4 10000 -Ethernet4 12 Ethernet5/1 5 10000 -Ethernet5 13 Ethernet6/1 6 10000 -Ethernet6 14 Ethernet7/1 7 10000 -Ethernet7 15 Ethernet8/1 8 10000 -Ethernet8 16 Ethernet9/1 9 10000 -Ethernet9 17 Ethernet10/1 10 10000 -Ethernet10 18 Ethernet11/1 11 10000 -Ethernet11 19 Ethernet12/1 12 10000 -Ethernet12 20 Ethernet13/1 13 10000 -Ethernet13 21 Ethernet14/1 14 10000 -Ethernet14 22 Ethernet15/1 15 10000 -Ethernet15 23 Ethernet16/1 16 10000 -Ethernet16 32 Ethernet17/1 17 10000 -Ethernet17 33 Ethernet18/1 18 10000 -Ethernet18 34 Ethernet19/1 19 10000 -Ethernet19 35 Ethernet20/1 20 10000 -Ethernet20 40 Ethernet21/1 21 10000 -Ethernet21 41 Ethernet22/1 22 10000 -Ethernet22 42 Ethernet23/1 23 10000 -Ethernet23 43 Ethernet24/1 24 10000 -Ethernet24 48 Ethernet25/1 25 10000 -Ethernet25 49 Ethernet26/1 26 10000 -Ethernet26 50 Ethernet27/1 27 10000 -Ethernet27 51 Ethernet28/1 28 10000 -Ethernet28 56 Ethernet29/1 29 10000 -Ethernet29 57 Ethernet30/1 30 10000 -Ethernet30 58 Ethernet31/1 31 10000 -Ethernet31 59 Ethernet32/1 32 10000 -Ethernet32 64 Ethernet33/1 33 10000 -Ethernet33 65 Ethernet34/1 34 10000 -Ethernet34 66 Ethernet35/1 35 10000 -Ethernet35 67 Ethernet36/1 36 10000 -Ethernet36 68 Ethernet37/1 37 10000 -Ethernet37 69 Ethernet38/1 38 10000 -Ethernet38 70 Ethernet39/1 39 10000 -Ethernet39 71 Ethernet40/1 40 10000 -Ethernet40 72 Ethernet41/1 41 10000 -Ethernet41 73 Ethernet42/1 42 10000 -Ethernet42 74 Ethernet43/1 43 10000 -Ethernet43 75 Ethernet44/1 44 10000 -Ethernet44 76 Ethernet45/1 45 10000 -Ethernet45 77 Ethernet46/1 46 10000 -Ethernet46 78 Ethernet47/1 47 10000 -Ethernet47 79 Ethernet48/1 48 10000 -Ethernet48 84,85,86,87 Ethernet49/1 49 100000 -Ethernet49 80,81,82,83 Ethernet50/1 50 100000 -Ethernet50 108,109,110,111 Ethernet51/1 51 100000 -Ethernet51 104,105,106,107 Ethernet52/1 52 100000 -Ethernet52 116,117,118,119 Ethernet53/1 53 100000 -Ethernet53 112,113,114,115 Ethernet54/1 54 100000 diff --git a/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/port_config.nps b/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/port_config.nps deleted file mode 100644 index e7f4fc78221..00000000000 --- a/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/port_config.nps +++ /dev/null @@ -1,624 +0,0 @@ -init start stage unit=0 low-level -init set port-map unit=0 port=0 eth-macro=2 lane=0 max-speed=10g active=true -init set port-map unit=0 port=1 eth-macro=2 lane=1 max-speed=10g active=true -init set port-map unit=0 port=2 eth-macro=2 lane=2 max-speed=10g active=true -init set port-map unit=0 port=3 eth-macro=2 lane=3 max-speed=10g active=true -init set port-map unit=0 port=4 eth-macro=3 lane=0 max-speed=10g active=true -init set port-map unit=0 port=5 eth-macro=3 lane=1 max-speed=10g active=true -init set port-map unit=0 port=6 eth-macro=3 lane=2 max-speed=10g active=true -init set port-map unit=0 port=7 eth-macro=3 lane=3 max-speed=10g active=true -init set port-map unit=0 port=8 eth-macro=4 lane=0 max-speed=10g active=true -init set port-map unit=0 port=9 eth-macro=4 lane=1 max-speed=10g active=true -init set port-map unit=0 port=10 eth-macro=4 lane=2 max-speed=10g active=true -init set port-map unit=0 port=11 eth-macro=4 lane=3 max-speed=10g active=true -init set port-map unit=0 port=12 eth-macro=5 lane=0 max-speed=10g active=true -init set port-map unit=0 port=13 eth-macro=5 lane=1 max-speed=10g active=true -init set port-map unit=0 port=14 eth-macro=5 lane=2 max-speed=10g active=true -init set port-map unit=0 port=15 eth-macro=5 lane=3 max-speed=10g active=true -init set port-map unit=0 port=16 eth-macro=8 lane=0 max-speed=10g active=true -init set port-map unit=0 port=17 eth-macro=8 lane=1 max-speed=10g active=true -init set port-map unit=0 port=18 eth-macro=8 lane=2 max-speed=10g active=true -init set port-map unit=0 port=19 eth-macro=8 lane=3 max-speed=10g active=true -init set port-map unit=0 port=20 eth-macro=10 lane=0 max-speed=10g active=true -init set port-map unit=0 port=21 eth-macro=10 lane=1 max-speed=10g active=true -init set port-map unit=0 port=22 eth-macro=10 lane=2 max-speed=10g active=true -init set port-map unit=0 port=23 eth-macro=10 lane=3 max-speed=10g active=true -init set port-map unit=0 port=24 eth-macro=12 lane=0 max-speed=10g active=true -init set port-map unit=0 port=25 eth-macro=12 lane=1 max-speed=10g active=true -init set port-map unit=0 port=26 eth-macro=12 lane=2 max-speed=10g active=true -init set port-map unit=0 port=27 eth-macro=12 lane=3 max-speed=10g active=true -init set port-map unit=0 port=28 eth-macro=14 lane=0 max-speed=10g active=true -init set port-map unit=0 port=29 eth-macro=14 lane=1 max-speed=10g active=true -init set port-map unit=0 port=30 eth-macro=14 lane=2 max-speed=10g active=true -init set port-map unit=0 port=31 eth-macro=14 lane=3 max-speed=10g active=true -init set port-map unit=0 port=32 eth-macro=16 lane=0 max-speed=10g active=true -init set port-map unit=0 port=33 eth-macro=16 lane=1 max-speed=10g active=true -init set port-map unit=0 port=34 eth-macro=16 lane=2 max-speed=10g active=true -init set port-map unit=0 port=35 eth-macro=16 lane=3 max-speed=10g active=true -init set port-map unit=0 port=36 eth-macro=17 lane=0 max-speed=10g active=true -init set port-map unit=0 port=37 eth-macro=17 lane=1 max-speed=10g active=true -init set port-map unit=0 port=38 eth-macro=17 lane=2 max-speed=10g active=true -init set port-map unit=0 port=39 eth-macro=17 lane=3 max-speed=10g active=true -init set port-map unit=0 port=40 eth-macro=18 lane=0 max-speed=10g active=true -init set port-map unit=0 port=41 eth-macro=18 lane=1 max-speed=10g active=true -init set port-map unit=0 port=42 eth-macro=18 lane=2 max-speed=10g active=true -init set port-map unit=0 port=43 eth-macro=18 lane=3 max-speed=10g active=true -init set port-map unit=0 port=44 eth-macro=19 lane=0 max-speed=10g active=true -init set port-map unit=0 port=45 eth-macro=19 lane=1 max-speed=10g active=true -init set port-map unit=0 port=46 eth-macro=19 lane=2 max-speed=10g active=true -init set port-map unit=0 port=47 eth-macro=19 lane=3 max-speed=10g active=true -init set port-map unit=0 port=48 eth-macro=21 lane=0 max-speed=100g active=true -init set port-map unit=0 port=49 eth-macro=20 lane=0 max-speed=100g active=true -init set port-map unit=0 port=50 eth-macro=27 lane=0 max-speed=100g active=true -init set port-map unit=0 port=51 eth-macro=26 lane=0 max-speed=100g active=true -init set port-map unit=0 port=52 eth-macro=29 lane=0 max-speed=100g active=true -init set port-map unit=0 port=53 eth-macro=28 lane=0 max-speed=100g active=true -init set port-map unit=0 port=129 eth-macro=0 lane=1 max-speed=10g active=true guarantee=true cpi=true -init set port-map unit=0 port=130 eth-macro=0 lane=0 max-speed=10g active=true guarantee=true cpi=true init-done=true -init start stage unit=0 task-rsrc -init start stage unit=0 module -init start stage unit=0 task -phy set lane-swap unit=0 portlist=0 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=1 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=2 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=3 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=4 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=5 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=6 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=7 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=8 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=9 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=10 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=11 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=12 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=13 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=14 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=15 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=16 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=17 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=18 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=19 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=20 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=21 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=22 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=23 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=24 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=25 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=26 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=27 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=28 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=29 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=30 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=31 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=32 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=33 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=34 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=35 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=36 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=37 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=38 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=39 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=40 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=41 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=42 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=43 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=44 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=45 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=46 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=47 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=48 lane-cnt=4 property=tx data=0x3.0.1.2 -phy set lane-swap unit=0 portlist=49 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=50 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=51 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=52 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=53 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=129 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=130 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=0 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=1 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=2 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=3 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=4 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=5 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=6 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=7 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=8 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=9 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=10 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=11 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=12 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=13 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=14 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=15 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=16 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=17 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=18 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=19 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=20 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=21 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=22 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=23 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=24 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=25 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=26 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=27 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=28 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=29 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=30 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=31 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=32 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=33 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=34 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=35 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=36 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=37 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=38 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=39 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=40 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=41 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=42 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=43 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=44 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=45 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=46 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=47 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=48 lane-cnt=4 property=rx data=0x3.1.0.2 -phy set lane-swap unit=0 portlist=49 lane-cnt=4 property=rx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=50 lane-cnt=4 property=rx data=0x1.0.3.2 -phy set lane-swap unit=0 portlist=51 lane-cnt=4 property=rx data=0x2.0.1.3 -phy set lane-swap unit=0 portlist=52 lane-cnt=4 property=rx data=0x1.0.3.2 -phy set lane-swap unit=0 portlist=53 lane-cnt=4 property=rx data=0x1.0.3.2 -phy set lane-swap unit=0 portlist=129 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=130 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=0 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=1 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=2 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=3 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=4 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=5 lane-cnt=1 property=tx data=0x1 -phy set polarity-rev unit=0 portlist=6 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=7 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=8 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=9 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=10 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=11 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=12 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=13 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=14 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=15 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=16 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=17 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=18 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=19 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=20 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=21 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=22 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=23 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=24 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=25 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=26 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=27 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=28 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=29 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=30 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=31 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=32 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=33 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=34 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=35 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=36 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=37 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=38 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=39 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=40 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=41 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=42 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=43 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=44 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=45 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=46 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=47 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=48 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=49 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=50 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=51 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=52 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=53 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=129 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=130 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=0 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=1 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=2 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=3 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=4 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=5 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=6 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=7 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=8 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=9 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=10 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=11 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=12 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=13 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=14 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=15 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=16 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=17 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=18 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=19 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=20 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=21 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=22 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=23 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=24 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=25 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=26 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=27 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=28 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=29 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=30 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=31 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=32 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=33 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=34 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=35 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=36 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=37 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=38 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=39 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=40 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=41 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=42 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=43 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=44 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=45 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=46 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=47 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=48 lane-cnt=4 property=rx data=0x0.1.1.0 -phy set polarity-rev unit=0 portlist=49 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=50 lane-cnt=4 property=rx data=0x1.1.1.0 -phy set polarity-rev unit=0 portlist=51 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=52 lane-cnt=4 property=rx data=0x1.1.1.0 -phy set polarity-rev unit=0 portlist=53 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=129 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=130 lane-cnt=1 property=rx data=0x0 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=c0 data=0x1b -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=c0 data=0x1b -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=c0 data=0x1b -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=c0 data=0x1b -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=c2 data=0x1 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=c0 data=0x2 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=c1 data=0x3 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=c2 data=0x1 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=c0 data=0x2 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=c1 data=0x3 -port set property unit=0 portlist=0 speed=10g -port set property unit=0 portlist=1 speed=10g -port set property unit=0 portlist=2 speed=10g -port set property unit=0 portlist=3 speed=10g -port set property unit=0 portlist=4 speed=10g -port set property unit=0 portlist=5 speed=10g -port set property unit=0 portlist=6 speed=10g -port set property unit=0 portlist=7 speed=10g -port set property unit=0 portlist=8 speed=10g -port set property unit=0 portlist=9 speed=10g -port set property unit=0 portlist=10 speed=10g -port set property unit=0 portlist=11 speed=10g -port set property unit=0 portlist=12 speed=10g -port set property unit=0 portlist=13 speed=10g -port set property unit=0 portlist=14 speed=10g -port set property unit=0 portlist=15 speed=10g -port set property unit=0 portlist=16 speed=10g -port set property unit=0 portlist=17 speed=10g -port set property unit=0 portlist=18 speed=10g -port set property unit=0 portlist=19 speed=10g -port set property unit=0 portlist=20 speed=10g -port set property unit=0 portlist=21 speed=10g -port set property unit=0 portlist=22 speed=10g -port set property unit=0 portlist=23 speed=10g -port set property unit=0 portlist=24 speed=10g -port set property unit=0 portlist=25 speed=10g -port set property unit=0 portlist=26 speed=10g -port set property unit=0 portlist=27 speed=10g -port set property unit=0 portlist=28 speed=10g -port set property unit=0 portlist=29 speed=10g -port set property unit=0 portlist=30 speed=10g -port set property unit=0 portlist=31 speed=10g -port set property unit=0 portlist=32 speed=10g -port set property unit=0 portlist=33 speed=10g -port set property unit=0 portlist=34 speed=10g -port set property unit=0 portlist=35 speed=10g -port set property unit=0 portlist=36 speed=10g -port set property unit=0 portlist=37 speed=10g -port set property unit=0 portlist=38 speed=10g -port set property unit=0 portlist=39 speed=10g -port set property unit=0 portlist=40 speed=10g -port set property unit=0 portlist=41 speed=10g -port set property unit=0 portlist=42 speed=10g -port set property unit=0 portlist=43 speed=10g -port set property unit=0 portlist=44 speed=10g -port set property unit=0 portlist=45 speed=10g -port set property unit=0 portlist=46 speed=10g -port set property unit=0 portlist=47 speed=10g -port set property unit=0 portlist=48 speed=100g -port set property unit=0 portlist=49 speed=100g -port set property unit=0 portlist=50 speed=100g -port set property unit=0 portlist=51 speed=100g -port set property unit=0 portlist=52 speed=100g -port set property unit=0 portlist=53 speed=100g -port set property unit=0 portlist=129 speed=10g -port set property unit=0 portlist=130 speed=1g -port set property unit=0 portlist=0 medium-type=sr -port set property unit=0 portlist=1 medium-type=sr -port set property unit=0 portlist=2 medium-type=sr -port set property unit=0 portlist=3 medium-type=sr -port set property unit=0 portlist=4 medium-type=sr -port set property unit=0 portlist=5 medium-type=sr -port set property unit=0 portlist=6 medium-type=sr -port set property unit=0 portlist=7 medium-type=sr -port set property unit=0 portlist=8 medium-type=sr -port set property unit=0 portlist=9 medium-type=sr -port set property unit=0 portlist=10 medium-type=sr -port set property unit=0 portlist=11 medium-type=sr -port set property unit=0 portlist=12 medium-type=sr -port set property unit=0 portlist=13 medium-type=sr -port set property unit=0 portlist=14 medium-type=sr -port set property unit=0 portlist=15 medium-type=sr -port set property unit=0 portlist=16 medium-type=sr -port set property unit=0 portlist=17 medium-type=sr -port set property unit=0 portlist=18 medium-type=sr -port set property unit=0 portlist=19 medium-type=sr -port set property unit=0 portlist=20 medium-type=sr -port set property unit=0 portlist=21 medium-type=sr -port set property unit=0 portlist=22 medium-type=sr -port set property unit=0 portlist=23 medium-type=sr -port set property unit=0 portlist=24 medium-type=sr -port set property unit=0 portlist=25 medium-type=sr -port set property unit=0 portlist=26 medium-type=sr -port set property unit=0 portlist=27 medium-type=sr -port set property unit=0 portlist=28 medium-type=sr -port set property unit=0 portlist=29 medium-type=sr -port set property unit=0 portlist=30 medium-type=sr -port set property unit=0 portlist=31 medium-type=sr -port set property unit=0 portlist=32 medium-type=sr -port set property unit=0 portlist=33 medium-type=sr -port set property unit=0 portlist=34 medium-type=sr -port set property unit=0 portlist=35 medium-type=sr -port set property unit=0 portlist=36 medium-type=sr -port set property unit=0 portlist=37 medium-type=sr -port set property unit=0 portlist=38 medium-type=sr -port set property unit=0 portlist=39 medium-type=sr -port set property unit=0 portlist=40 medium-type=sr -port set property unit=0 portlist=41 medium-type=sr -port set property unit=0 portlist=42 medium-type=sr -port set property unit=0 portlist=43 medium-type=sr -port set property unit=0 portlist=44 medium-type=sr -port set property unit=0 portlist=45 medium-type=sr -port set property unit=0 portlist=46 medium-type=sr -port set property unit=0 portlist=47 medium-type=sr -port set property unit=0 portlist=48 medium-type=sr4 -port set property unit=0 portlist=49 medium-type=sr4 -port set property unit=0 portlist=50 medium-type=sr4 -port set property unit=0 portlist=51 medium-type=sr4 -port set property unit=0 portlist=52 medium-type=sr4 -port set property unit=0 portlist=53 medium-type=sr4 -port set property unit=0 portlist=129 medium-type=kr -port set property unit=0 portlist=130 medium-type=x -port advertise unit=0 portlist=129 speed-10g-kr -port set property unit=0 portlist=129 an=enable -port set property unit=0 portlist=0-53 admin=disable -port set property unit=0 portlist=129-130 admin=disable diff --git a/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/qos.json.j2 b/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/qos.json.j2 deleted file mode 100644 index 3e548325ea3..00000000000 --- a/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/qos.json.j2 +++ /dev/null @@ -1 +0,0 @@ -{%- include 'qos_config.j2' %} diff --git a/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/sai.profile b/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/sai.profile deleted file mode 100644 index e7b5f90ac88..00000000000 --- a/device/cig/x86_64-cig_cs5435_54p-r0/Cig-CS5435-54P/sai.profile +++ /dev/null @@ -1,3 +0,0 @@ -SAI_INIT_LED_CONFIG_FILE=/usr/share/sonic/hwsku/led.bin -SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/proc_init.nps -SAI_DSH_CONFIG_FILE=/usr/share/sonic/hwsku/port_config.nps diff --git a/device/cig/x86_64-cig_cs5435_54p-r0/default_sku b/device/cig/x86_64-cig_cs5435_54p-r0/default_sku deleted file mode 100644 index 66b35b61e09..00000000000 --- a/device/cig/x86_64-cig_cs5435_54p-r0/default_sku +++ /dev/null @@ -1 +0,0 @@ -Cig-CS5435-54P t1 diff --git a/device/cig/x86_64-cig_cs5435_54p-r0/installer.conf b/device/cig/x86_64-cig_cs5435_54p-r0/installer.conf deleted file mode 100644 index ea6b4f6ebe3..00000000000 --- a/device/cig/x86_64-cig_cs5435_54p-r0/installer.conf +++ /dev/null @@ -1,4 +0,0 @@ -CONSOLE_PORT=0x3f8 -CONSOLE_DEV=0 -CONSOLE_SPEED=115200 -ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="pci=noaer" diff --git a/device/cig/x86_64-cig_cs5435_54p-r0/platform_asic b/device/cig/x86_64-cig_cs5435_54p-r0/platform_asic deleted file mode 100644 index 4211b60b9ce..00000000000 --- a/device/cig/x86_64-cig_cs5435_54p-r0/platform_asic +++ /dev/null @@ -1 +0,0 @@ -nephos diff --git a/device/cig/x86_64-cig_cs5435_54p-r0/plugins/eeprom.py b/device/cig/x86_64-cig_cs5435_54p-r0/plugins/eeprom.py deleted file mode 100755 index ae5a8385d96..00000000000 --- a/device/cig/x86_64-cig_cs5435_54p-r0/plugins/eeprom.py +++ /dev/null @@ -1,20 +0,0 @@ -try: - import binascii - import time - import optparse - import warnings - import os - import sys - from sonic_eeprom import eeprom_base - from sonic_eeprom import eeprom_tlvinfo - import subprocess -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class board(eeprom_tlvinfo.TlvInfoDecoder): - _TLV_INFO_MAX_LEN = 256 - - def __init__(self, name, path, cpld_root, ro): - self.eeprom_path = "/sys/bus/i2c/devices/7-0057/eeprom" - super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/cig/x86_64-cig_cs5435_54p-r0/plugins/psuutil.py b/device/cig/x86_64-cig_cs5435_54p-r0/plugins/psuutil.py deleted file mode 100755 index 442026775a5..00000000000 --- a/device/cig/x86_64-cig_cs5435_54p-r0/plugins/psuutil.py +++ /dev/null @@ -1,92 +0,0 @@ -# -# psuutil.py -# Platform-specific PSU status interface for SONiC -# - - -import os.path -import logging - -try: - from sonic_psu.psu_base import PsuBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class PsuUtil(PsuBase): - """Platform-specific PSUutil class""" - - SYSFS_PSU_DIR = ["/sys/bus/i2c/devices/5-005a", - "/sys/bus/i2c/devices/5-005b"] - - def __init__(self): - PsuBase.__init__(self) - - # Get sysfs attribute - - def get_attr_value(self, attr_path): - - retval = 'ERR' - if (not os.path.isfile(attr_path)): - return retval - - try: - with open(attr_path, 'r') as fd: - retval = fd.read() - except Exception as error: - logging.error("Unable to open %s file !", attr_path) - - retval = retval.rstrip('\r\n') - return retval - - def get_num_psus(self): - """ - Retrieves the number of PSUs available on the device - :return: An integer, the number of PSUs available on the device - """ - MAX_PSUS = 2 - return MAX_PSUS - - def get_psu_status(self, index): - """ - Retrieves the oprational status of power supply unit (PSU) defined - by index - :param index: An integer, index of the PSU of which to query status - :return: Boolean, True if PSU is operating properly, False if PSU is\ - faulty - """ - status = 0 - attr_file = 'psu_power_good' - attr_path = self.SYSFS_PSU_DIR[index-1] + '/' + attr_file - - attr_value = self.get_attr_value(attr_path) - - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - # Check for PSU status - if (attr_value == 1): - status = 1 - - return status - - def get_psu_presence(self, index): - """ - Retrieves the presence status of power supply unit (PSU) defined - by index - :param index: An integer, index of the PSU of which to query status - :return: Boolean, True if PSU is plugged, False if not - """ - status = 0 - psu_absent = 0 - attr_file = 'psu_present' - attr_path = self.SYSFS_PSU_DIR[index-1] + '/' + attr_file - - attr_value = self.get_attr_value(attr_path) - - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - # Check for PSU presence - if (attr_value == 1): - status = 1 - - return status diff --git a/device/cig/x86_64-cig_cs5435_54p-r0/plugins/sfputil.py b/device/cig/x86_64-cig_cs5435_54p-r0/plugins/sfputil.py deleted file mode 100755 index 2d682730045..00000000000 --- a/device/cig/x86_64-cig_cs5435_54p-r0/plugins/sfputil.py +++ /dev/null @@ -1,244 +0,0 @@ -try: - import time - from sonic_sfp.sfputilbase import SfpUtilBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class SfpUtil(SfpUtilBase): - """Platform specific SfpUtill class""" - - _port_start = 1 - _port_end = 54 - _qsfp_port_start = 49 - _ports_in_block = 54 - - _port_to_eeprom_mapping = {} - _global_port_pres_dict = {} - - _port_to_i2c_mapping = { - 1: 8, - 2: 9, - 3: 10, - 4: 11, - 5: 12, - 6: 13, - 7: 14, - 8: 15, - 9: 16, - 10: 17, - 11: 18, - 12: 19, - 13: 20, - 14: 21, - 15: 22, - 16: 23, - 17: 24, - 18: 25, - 19: 26, - 20: 27, - 21: 28, - 22: 29, - 23: 30, - 24: 31, - 25: 32, - 26: 33, - 27: 34, - 28: 35, - 29: 36, - 30: 37, - 31: 38, - 32: 39, - 33: 40, - 34: 41, - 35: 42, - 36: 43, - 37: 44, - 38: 45, - 39: 46, - 40: 47, - 41: 48, - 42: 49, - 43: 50, - 44: 51, - 45: 52, - 46: 53, - 47: 54, - 48: 55, - 49: 56, - 50: 57, - 51: 60, - 52: 61, - 53: 62, - 54: 63, - } - - _qsfp_ports = list(range(_qsfp_port_start, _ports_in_block + 1)) - - def get_presence(self, port_num): - # Check for invalid port_num - if port_num < self._port_start or port_num > self._port_end: - return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_is_present" - port_ps = path.format(self._port_to_i2c_mapping[port_num]) - - try: - reg_file = open(port_ps) - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - try: - reg_value = reg_file.readline().rstrip() - except IOError as e: - time.sleep(1) - - try: - reg_value = reg_file.readline().rstrip() - except IOError as e: - print("Error:try again to read file failed: %s %s" % (str(e), port_ps)) - reg_file.close() - return False - - reg_file.close() - if reg_value == '1': - return True - - reg_file.close() - if reg_value == '1': - return True - - return False - - def init_global_port_presence(self): - for port_num in range(self.port_start, (self.port_end + 1)): - self._global_port_pres_dict[port_num] = '0' - - def __init__(self): - eeprom_path = '/sys/bus/i2c/devices/{0}-0050/sfp_eeprom' - for x in range(self._port_start, self._port_end + 1): - port_eeprom_path = eeprom_path.format(self._port_to_i2c_mapping[x]) - self._port_to_eeprom_mapping[x] = port_eeprom_path - - self.init_global_port_presence() - SfpUtilBase.__init__(self) - - def reset(self, port_num): - # Check for invalid port_num - if port_num < self._port_start or port_num > self._port_end: - return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_port_reset" - port_ps = path.format(self._port_to_i2c_mapping[port_num]) - - try: - reg_file = open(port_ps, 'w') - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - # toggle reset - reg_file.seek(0) - reg_file.write('1') - time.sleep(1) - reg_file.seek(0) - reg_file.write('0') - reg_file.close() - return True - - def set_low_power_mode(self, port_num, lpmode): - # Check for invalid port_num - if port_num < self._qsfp_port_start or port_num > self._port_end: - return False - - pre_value = self.get_presence(port_num) - if pre_value == False: - return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_lpmode" - port_ps = path.format(self._port_to_i2c_mapping[port_num]) - - try: - reg_file = open(port_ps, 'w') - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - reg_file.seek(0) - - if lpmode == 1: - reg_file.write('1') - elif lpmode == 0: - reg_file.write('0') - reg_file.close() - - return True - - def get_low_power_mode(self, port_num): - # Check for invalid port_num - - if port_num < self._qsfp_port_start or port_num > self._port_end: - return False - - pre_value = self.get_presence(port_num) - if pre_value == False: - return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_lpmode" - port_ps = path.format(self._port_to_i2c_mapping[port_num]) - - try: - reg_file = open(port_ps) - except IOError as e: - print("Error: unable to open file:%s %s" % (str(e), port_ps)) - return False - - try: - reg_value = reg_file.readline().rstrip() - except IOError as e: - print("Error: unable to open file:%s %s" % (str(e), port_ps)) - reg_file.close() - return False - - reg_file.close() - - if reg_value == '1': - return True - - return False - - def get_transceiver_change_event(self): - port_dict = {} - while True: - for port_num in range(self.port_start, (self.port_end + 1)): - presence = self.get_presence(port_num) - - if(presence and self._global_port_pres_dict[port_num] == '0'): - self._global_port_pres_dict[port_num] = '1' - port_dict[port_num] = '1' - elif(not presence and - self._global_port_pres_dict[port_num] == '1'): - self._global_port_pres_dict[port_num] = '0' - port_dict[port_num] = '0' - - if(len(port_dict) > 0): - return True, port_dict - - time.sleep(0.5) - - @property - def port_start(self): - return self._port_start - - @property - def port_end(self): - return self._port_end - - @property - def qsfp_ports(self): - return self._qsfp_ports - - @property - def port_to_eeprom_mapping(self): - return self._port_to_eeprom_mapping diff --git a/device/cig/x86_64-cig_cs5435_54p-r0/sensors.conf b/device/cig/x86_64-cig_cs5435_54p-r0/sensors.conf deleted file mode 100644 index f0964c87dae..00000000000 --- a/device/cig/x86_64-cig_cs5435_54p-r0/sensors.conf +++ /dev/null @@ -1,13 +0,0 @@ -# libsensors configuration file - -chip "cs5435_54p_fan-*" - label fan1 "front fan 1" - label fan2 "front fan 2" - label fan3 "front fan 3" - label fan4 "front fan 4" - label fan5 "front fan 5" - label fan6 "rear fan 1" - label fan7 "rear fan 2" - label fan8 "rear fan 3" - label fan9 "rear fan 4" - label fan10 "rear fan 5" diff --git a/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/buffers.json.j2 b/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/buffers.json.j2 deleted file mode 100644 index 818e8e1f1e6..00000000000 --- a/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/buffers.json.j2 +++ /dev/null @@ -1,111 +0,0 @@ -{# Default values which will be used if no actual configura available #} -{% set default_cable = '40m' %} -{% set default_speed = '10G' %} -{% set default_ports_num = 54 -%} - -{# Port configuration to cable length look-up table #} -{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #} -{# Roles described in the minigraph #} -{% set ports2cable = { - 'torrouter_server' : '5m', - 'leafrouter_torrouter' : '40m', - 'spinerouter_leafrouter' : '300m' - } -%} - -{%- macro cable_length(port_name) -%} - {%- set cable_len = [] -%} - {%- for local_port in DEVICE_NEIGHBOR -%} - {%- if local_port == port_name -%} - {%- if DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} - {%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} - {%- set neighbor_role = neighbor.type -%} - {%- set roles1 = switch_role + '_' + neighbor_role %} - {%- set roles2 = neighbor_role + '_' + switch_role -%} - {%- set roles1 = roles1 | lower -%} - {%- set roles2 = roles2 | lower -%} - {%- if roles1 in ports2cable -%} - {%- if cable_len.append(ports2cable[roles1]) -%}{%- endif -%} - {%- elif roles2 in ports2cable -%} - {%- if cable_len.append(ports2cable[roles2]) -%}{%- endif -%} - {%- endif -%} - {%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- if cable_len -%} - {{ cable_len.0 }} - {%- else -%} - {{ default_cable }} - {%- endif -%} -{% endmacro %} - -{%- if DEVICE_METADATA is defined %} -{%- set switch_role = DEVICE_METADATA['localhost']['type'] %} -{%- endif -%} - -{# Generate list of ports if not defined #} -{% if PORT is not defined %} - {% set PORT = [] %} - {% for port_idx in range(0,default_ports_num) %} - {% if PORT.append("Ethernet%d" % (port_idx)) %}{% endif %} - {% endfor %} -{% endif -%} - -{% set port_names_list = [] %} -{% for port in PORT %} - {%- if port_names_list.append(port) %}{% endif %} -{% endfor %} -{% set port_names = port_names_list | join(',') -%} - -{ - "CABLE_LENGTH": { - "AZURE": { - {% for port in PORT %} - {% set cable = cable_length(port) -%} - "{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %} - - {% endfor %} - } - }, - "BUFFER_POOL": { - "ingress_lossless_pool": { - "size": "20971328", - "type": "ingress", - "mode": "static" - }, - "ingress_lossy_pool": { - "size": "20971328", - "type": "ingress", - "mode": "static" - }, - "egress_lossy_pool": { - "size": "20971328", - "type": "egress", - "mode": "static" - } - }, - "BUFFER_PROFILE": { - "ingress_lossless_profile": { - "pool":"ingress_lossless_pool", - "xon":"78400", - "xoff":"132160", - "size":"3584", - "static_th":"82880" - }, - "ingress_lossy_profile": { - "pool":"ingress_lossy_pool", - "size":"3584", - "dynamic_th":"-1" - }, - "egress_lossy_profile": { - "pool":"egress_lossy_pool", - "size":"3584", - "dynamic_th":"-4" - } - }, - "BUFFER_PG": { - }, - "BUFFER_QUEUE": { - } -} - \ No newline at end of file diff --git a/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/led.bin b/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/led.bin deleted file mode 100644 index 201662a1c60..00000000000 Binary files a/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/led.bin and /dev/null differ diff --git a/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/pg_profile_lookup.ini b/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/pg_profile_lookup.ini deleted file mode 100644 index d98b0eca6d1..00000000000 --- a/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/pg_profile_lookup.ini +++ /dev/null @@ -1,17 +0,0 @@ -# PG lossless profiles. -# speed cable size xon xoff threshold - 10000 5m 3584 32256 59136 36736 - 25000 5m 3584 41216 68096 45696 - 40000 5m 3584 47488 74368 51968 - 50000 5m 3584 52864 79744 57344 - 100000 5m 3584 78400 132160 82880 - 10000 40m 3584 32256 59136 36736 - 25000 40m 3584 41216 68096 45696 - 40000 40m 3584 47488 74368 51968 - 50000 40m 3584 52864 79744 57344 - 100000 40m 3584 78400 132160 82880 - 10000 300m 3584 32256 65856 36736 - 25000 300m 3584 41216 84672 45696 - 40000 300m 3584 47488 101024 51968 - 50000 300m 3584 52864 113120 57344 - 100000 300m 3584 78400 198688 82880 \ No newline at end of file diff --git a/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/port_config.ini b/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/port_config.ini deleted file mode 100644 index 165b5204c2f..00000000000 --- a/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/port_config.ini +++ /dev/null @@ -1,55 +0,0 @@ -# name lanes alias index speed -Ethernet0 8 Ethernet1/1 1 25000 -Ethernet1 9 Ethernet2/1 2 25000 -Ethernet2 10 Ethernet3/1 3 25000 -Ethernet3 11 Ethernet4/1 4 25000 -Ethernet4 12 Ethernet5/1 5 25000 -Ethernet5 13 Ethernet6/1 6 25000 -Ethernet6 14 Ethernet7/1 7 25000 -Ethernet7 15 Ethernet8/1 8 25000 -Ethernet8 16 Ethernet9/1 9 25000 -Ethernet9 17 Ethernet10/1 10 25000 -Ethernet10 18 Ethernet11/1 11 25000 -Ethernet11 19 Ethernet12/1 12 25000 -Ethernet12 20 Ethernet13/1 13 25000 -Ethernet13 21 Ethernet14/1 14 25000 -Ethernet14 22 Ethernet15/1 15 25000 -Ethernet15 23 Ethernet16/1 16 25000 -Ethernet16 32 Ethernet17/1 17 25000 -Ethernet17 33 Ethernet18/1 18 25000 -Ethernet18 34 Ethernet19/1 19 25000 -Ethernet19 35 Ethernet20/1 20 25000 -Ethernet20 40 Ethernet21/1 21 25000 -Ethernet21 41 Ethernet22/1 22 25000 -Ethernet22 42 Ethernet23/1 23 25000 -Ethernet23 43 Ethernet24/1 24 25000 -Ethernet24 48 Ethernet25/1 25 25000 -Ethernet25 49 Ethernet26/1 26 25000 -Ethernet26 50 Ethernet27/1 27 25000 -Ethernet27 51 Ethernet28/1 28 25000 -Ethernet28 56 Ethernet29/1 29 25000 -Ethernet29 57 Ethernet30/1 30 25000 -Ethernet30 58 Ethernet31/1 31 25000 -Ethernet31 59 Ethernet32/1 32 25000 -Ethernet32 64 Ethernet33/1 33 25000 -Ethernet33 65 Ethernet34/1 34 25000 -Ethernet34 66 Ethernet35/1 35 25000 -Ethernet35 67 Ethernet36/1 36 25000 -Ethernet36 68 Ethernet37/1 37 25000 -Ethernet37 69 Ethernet38/1 38 25000 -Ethernet38 70 Ethernet39/1 39 25000 -Ethernet39 71 Ethernet40/1 40 25000 -Ethernet40 72 Ethernet41/1 41 25000 -Ethernet41 73 Ethernet42/1 42 25000 -Ethernet42 74 Ethernet43/1 43 25000 -Ethernet43 75 Ethernet44/1 44 25000 -Ethernet44 76 Ethernet45/1 45 25000 -Ethernet45 77 Ethernet46/1 46 25000 -Ethernet46 78 Ethernet47/1 47 25000 -Ethernet47 79 Ethernet48/1 48 25000 -Ethernet48 84,85,86,87 Ethernet49/1 49 100000 -Ethernet49 80,81,82,83 Ethernet50/1 50 100000 -Ethernet50 108,109,110,111 Ethernet51/1 51 100000 -Ethernet51 104,105,106,107 Ethernet52/1 52 100000 -Ethernet52 116,117,118,119 Ethernet53/1 53 100000 -Ethernet53 112,113,114,115 Ethernet54/1 54 100000 diff --git a/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/port_config.nps b/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/port_config.nps deleted file mode 100644 index 120b7f39887..00000000000 --- a/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/port_config.nps +++ /dev/null @@ -1,624 +0,0 @@ -init start stage unit=0 low-level -init set port-map unit=0 port=0 eth-macro=2 lane=0 max-speed=25g active=true -init set port-map unit=0 port=1 eth-macro=2 lane=1 max-speed=25g active=true -init set port-map unit=0 port=2 eth-macro=2 lane=2 max-speed=25g active=true -init set port-map unit=0 port=3 eth-macro=2 lane=3 max-speed=25g active=true -init set port-map unit=0 port=4 eth-macro=3 lane=0 max-speed=25g active=true -init set port-map unit=0 port=5 eth-macro=3 lane=1 max-speed=25g active=true -init set port-map unit=0 port=6 eth-macro=3 lane=2 max-speed=25g active=true -init set port-map unit=0 port=7 eth-macro=3 lane=3 max-speed=25g active=true -init set port-map unit=0 port=8 eth-macro=4 lane=0 max-speed=25g active=true -init set port-map unit=0 port=9 eth-macro=4 lane=1 max-speed=25g active=true -init set port-map unit=0 port=10 eth-macro=4 lane=2 max-speed=25g active=true -init set port-map unit=0 port=11 eth-macro=4 lane=3 max-speed=25g active=true -init set port-map unit=0 port=12 eth-macro=5 lane=0 max-speed=25g active=true -init set port-map unit=0 port=13 eth-macro=5 lane=1 max-speed=25g active=true -init set port-map unit=0 port=14 eth-macro=5 lane=2 max-speed=25g active=true -init set port-map unit=0 port=15 eth-macro=5 lane=3 max-speed=25g active=true -init set port-map unit=0 port=16 eth-macro=8 lane=0 max-speed=25g active=true -init set port-map unit=0 port=17 eth-macro=8 lane=1 max-speed=25g active=true -init set port-map unit=0 port=18 eth-macro=8 lane=2 max-speed=25g active=true -init set port-map unit=0 port=19 eth-macro=8 lane=3 max-speed=25g active=true -init set port-map unit=0 port=20 eth-macro=10 lane=0 max-speed=25g active=true -init set port-map unit=0 port=21 eth-macro=10 lane=1 max-speed=25g active=true -init set port-map unit=0 port=22 eth-macro=10 lane=2 max-speed=25g active=true -init set port-map unit=0 port=23 eth-macro=10 lane=3 max-speed=25g active=true -init set port-map unit=0 port=24 eth-macro=12 lane=0 max-speed=25g active=true -init set port-map unit=0 port=25 eth-macro=12 lane=1 max-speed=25g active=true -init set port-map unit=0 port=26 eth-macro=12 lane=2 max-speed=25g active=true -init set port-map unit=0 port=27 eth-macro=12 lane=3 max-speed=25g active=true -init set port-map unit=0 port=28 eth-macro=14 lane=0 max-speed=25g active=true -init set port-map unit=0 port=29 eth-macro=14 lane=1 max-speed=25g active=true -init set port-map unit=0 port=30 eth-macro=14 lane=2 max-speed=25g active=true -init set port-map unit=0 port=31 eth-macro=14 lane=3 max-speed=25g active=true -init set port-map unit=0 port=32 eth-macro=16 lane=0 max-speed=25g active=true -init set port-map unit=0 port=33 eth-macro=16 lane=1 max-speed=25g active=true -init set port-map unit=0 port=34 eth-macro=16 lane=2 max-speed=25g active=true -init set port-map unit=0 port=35 eth-macro=16 lane=3 max-speed=25g active=true -init set port-map unit=0 port=36 eth-macro=17 lane=0 max-speed=25g active=true -init set port-map unit=0 port=37 eth-macro=17 lane=1 max-speed=25g active=true -init set port-map unit=0 port=38 eth-macro=17 lane=2 max-speed=25g active=true -init set port-map unit=0 port=39 eth-macro=17 lane=3 max-speed=25g active=true -init set port-map unit=0 port=40 eth-macro=18 lane=0 max-speed=25g active=true -init set port-map unit=0 port=41 eth-macro=18 lane=1 max-speed=25g active=true -init set port-map unit=0 port=42 eth-macro=18 lane=2 max-speed=25g active=true -init set port-map unit=0 port=43 eth-macro=18 lane=3 max-speed=25g active=true -init set port-map unit=0 port=44 eth-macro=19 lane=0 max-speed=25g active=true -init set port-map unit=0 port=45 eth-macro=19 lane=1 max-speed=25g active=true -init set port-map unit=0 port=46 eth-macro=19 lane=2 max-speed=25g active=true -init set port-map unit=0 port=47 eth-macro=19 lane=3 max-speed=25g active=true -init set port-map unit=0 port=48 eth-macro=21 lane=0 max-speed=100g active=true -init set port-map unit=0 port=49 eth-macro=20 lane=0 max-speed=100g active=true -init set port-map unit=0 port=50 eth-macro=27 lane=0 max-speed=100g active=true -init set port-map unit=0 port=51 eth-macro=26 lane=0 max-speed=100g active=true -init set port-map unit=0 port=52 eth-macro=29 lane=0 max-speed=100g active=true -init set port-map unit=0 port=53 eth-macro=28 lane=0 max-speed=100g active=true -init set port-map unit=0 port=129 eth-macro=0 lane=1 max-speed=10g active=true guarantee=true cpi=true -init set port-map unit=0 port=130 eth-macro=0 lane=0 max-speed=10g active=true guarantee=true cpi=true init-done=true -init start stage unit=0 task-rsrc -init start stage unit=0 module -init start stage unit=0 task -phy set lane-swap unit=0 portlist=0 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=1 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=2 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=3 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=4 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=5 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=6 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=7 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=8 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=9 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=10 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=11 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=12 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=13 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=14 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=15 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=16 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=17 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=18 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=19 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=20 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=21 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=22 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=23 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=24 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=25 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=26 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=27 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=28 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=29 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=30 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=31 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=32 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=33 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=34 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=35 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=36 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=37 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=38 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=39 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=40 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=41 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=42 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=43 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=44 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=45 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=46 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=47 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=48 lane-cnt=4 property=tx data=0x3.0.1.2 -phy set lane-swap unit=0 portlist=49 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=50 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=51 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=52 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=53 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=129 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=130 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=0 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=1 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=2 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=3 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=4 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=5 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=6 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=7 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=8 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=9 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=10 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=11 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=12 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=13 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=14 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=15 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=16 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=17 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=18 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=19 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=20 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=21 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=22 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=23 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=24 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=25 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=26 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=27 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=28 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=29 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=30 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=31 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=32 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=33 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=34 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=35 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=36 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=37 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=38 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=39 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=40 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=41 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=42 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=43 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=44 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=45 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=46 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=47 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=48 lane-cnt=4 property=rx data=0x3.1.0.2 -phy set lane-swap unit=0 portlist=49 lane-cnt=4 property=rx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=50 lane-cnt=4 property=rx data=0x1.0.3.2 -phy set lane-swap unit=0 portlist=51 lane-cnt=4 property=rx data=0x2.0.1.3 -phy set lane-swap unit=0 portlist=52 lane-cnt=4 property=rx data=0x1.0.3.2 -phy set lane-swap unit=0 portlist=53 lane-cnt=4 property=rx data=0x1.0.3.2 -phy set lane-swap unit=0 portlist=129 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=130 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=0 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=1 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=2 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=3 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=4 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=5 lane-cnt=1 property=tx data=0x1 -phy set polarity-rev unit=0 portlist=6 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=7 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=8 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=9 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=10 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=11 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=12 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=13 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=14 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=15 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=16 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=17 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=18 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=19 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=20 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=21 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=22 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=23 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=24 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=25 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=26 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=27 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=28 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=29 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=30 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=31 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=32 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=33 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=34 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=35 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=36 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=37 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=38 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=39 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=40 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=41 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=42 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=43 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=44 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=45 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=46 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=47 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=48 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=49 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=50 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=51 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=52 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=53 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=129 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=130 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=0 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=1 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=2 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=3 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=4 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=5 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=6 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=7 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=8 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=9 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=10 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=11 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=12 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=13 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=14 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=15 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=16 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=17 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=18 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=19 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=20 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=21 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=22 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=23 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=24 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=25 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=26 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=27 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=28 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=29 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=30 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=31 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=32 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=33 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=34 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=35 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=36 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=37 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=38 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=39 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=40 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=41 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=42 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=43 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=44 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=45 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=46 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=47 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=48 lane-cnt=4 property=rx data=0x0.1.1.0 -phy set polarity-rev unit=0 portlist=49 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=50 lane-cnt=4 property=rx data=0x1.1.1.0 -phy set polarity-rev unit=0 portlist=51 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=52 lane-cnt=4 property=rx data=0x1.1.1.0 -phy set polarity-rev unit=0 portlist=53 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=129 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=130 lane-cnt=1 property=rx data=0x0 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=c0 data=0x1b -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=c0 data=0x1b -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=c0 data=0x1b -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=c0 data=0x1b -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=c2 data=0x1 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=c0 data=0x2 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=c1 data=0x3 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=c2 data=0x1 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=c0 data=0x2 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=c1 data=0x3 -port set property unit=0 portlist=0 speed=25g -port set property unit=0 portlist=1 speed=25g -port set property unit=0 portlist=2 speed=25g -port set property unit=0 portlist=3 speed=25g -port set property unit=0 portlist=4 speed=25g -port set property unit=0 portlist=5 speed=25g -port set property unit=0 portlist=6 speed=25g -port set property unit=0 portlist=7 speed=25g -port set property unit=0 portlist=8 speed=25g -port set property unit=0 portlist=9 speed=25g -port set property unit=0 portlist=10 speed=25g -port set property unit=0 portlist=11 speed=25g -port set property unit=0 portlist=12 speed=25g -port set property unit=0 portlist=13 speed=25g -port set property unit=0 portlist=14 speed=25g -port set property unit=0 portlist=15 speed=25g -port set property unit=0 portlist=16 speed=25g -port set property unit=0 portlist=17 speed=25g -port set property unit=0 portlist=18 speed=25g -port set property unit=0 portlist=19 speed=25g -port set property unit=0 portlist=20 speed=25g -port set property unit=0 portlist=21 speed=25g -port set property unit=0 portlist=22 speed=25g -port set property unit=0 portlist=23 speed=25g -port set property unit=0 portlist=24 speed=25g -port set property unit=0 portlist=25 speed=25g -port set property unit=0 portlist=26 speed=25g -port set property unit=0 portlist=27 speed=25g -port set property unit=0 portlist=28 speed=25g -port set property unit=0 portlist=29 speed=25g -port set property unit=0 portlist=30 speed=25g -port set property unit=0 portlist=31 speed=25g -port set property unit=0 portlist=32 speed=25g -port set property unit=0 portlist=33 speed=25g -port set property unit=0 portlist=34 speed=25g -port set property unit=0 portlist=35 speed=25g -port set property unit=0 portlist=36 speed=25g -port set property unit=0 portlist=37 speed=25g -port set property unit=0 portlist=38 speed=25g -port set property unit=0 portlist=39 speed=25g -port set property unit=0 portlist=40 speed=25g -port set property unit=0 portlist=41 speed=25g -port set property unit=0 portlist=42 speed=25g -port set property unit=0 portlist=43 speed=25g -port set property unit=0 portlist=44 speed=25g -port set property unit=0 portlist=45 speed=25g -port set property unit=0 portlist=46 speed=25g -port set property unit=0 portlist=47 speed=25g -port set property unit=0 portlist=48 speed=100g -port set property unit=0 portlist=49 speed=100g -port set property unit=0 portlist=50 speed=100g -port set property unit=0 portlist=51 speed=100g -port set property unit=0 portlist=52 speed=100g -port set property unit=0 portlist=53 speed=100g -port set property unit=0 portlist=129 speed=10g -port set property unit=0 portlist=130 speed=1g -port set property unit=0 portlist=0 medium-type=sr -port set property unit=0 portlist=1 medium-type=sr -port set property unit=0 portlist=2 medium-type=sr -port set property unit=0 portlist=3 medium-type=sr -port set property unit=0 portlist=4 medium-type=sr -port set property unit=0 portlist=5 medium-type=sr -port set property unit=0 portlist=6 medium-type=sr -port set property unit=0 portlist=7 medium-type=sr -port set property unit=0 portlist=8 medium-type=sr -port set property unit=0 portlist=9 medium-type=sr -port set property unit=0 portlist=10 medium-type=sr -port set property unit=0 portlist=11 medium-type=sr -port set property unit=0 portlist=12 medium-type=sr -port set property unit=0 portlist=13 medium-type=sr -port set property unit=0 portlist=14 medium-type=sr -port set property unit=0 portlist=15 medium-type=sr -port set property unit=0 portlist=16 medium-type=sr -port set property unit=0 portlist=17 medium-type=sr -port set property unit=0 portlist=18 medium-type=sr -port set property unit=0 portlist=19 medium-type=sr -port set property unit=0 portlist=20 medium-type=sr -port set property unit=0 portlist=21 medium-type=sr -port set property unit=0 portlist=22 medium-type=sr -port set property unit=0 portlist=23 medium-type=sr -port set property unit=0 portlist=24 medium-type=sr -port set property unit=0 portlist=25 medium-type=sr -port set property unit=0 portlist=26 medium-type=sr -port set property unit=0 portlist=27 medium-type=sr -port set property unit=0 portlist=28 medium-type=sr -port set property unit=0 portlist=29 medium-type=sr -port set property unit=0 portlist=30 medium-type=sr -port set property unit=0 portlist=31 medium-type=sr -port set property unit=0 portlist=32 medium-type=sr -port set property unit=0 portlist=33 medium-type=sr -port set property unit=0 portlist=34 medium-type=sr -port set property unit=0 portlist=35 medium-type=sr -port set property unit=0 portlist=36 medium-type=sr -port set property unit=0 portlist=37 medium-type=sr -port set property unit=0 portlist=38 medium-type=sr -port set property unit=0 portlist=39 medium-type=sr -port set property unit=0 portlist=40 medium-type=sr -port set property unit=0 portlist=41 medium-type=sr -port set property unit=0 portlist=42 medium-type=sr -port set property unit=0 portlist=43 medium-type=sr -port set property unit=0 portlist=44 medium-type=sr -port set property unit=0 portlist=45 medium-type=sr -port set property unit=0 portlist=46 medium-type=sr -port set property unit=0 portlist=47 medium-type=sr -port set property unit=0 portlist=48 medium-type=sr4 -port set property unit=0 portlist=49 medium-type=sr4 -port set property unit=0 portlist=50 medium-type=sr4 -port set property unit=0 portlist=51 medium-type=sr4 -port set property unit=0 portlist=52 medium-type=sr4 -port set property unit=0 portlist=53 medium-type=sr4 -port set property unit=0 portlist=129 medium-type=kr -port set property unit=0 portlist=130 medium-type=x -port advertise unit=0 portlist=129 speed-10g-kr -port set property unit=0 portlist=129 an=enable -port set property unit=0 portlist=0-53 admin=disable -port set property unit=0 portlist=129-130 admin=disable diff --git a/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/qos.json.j2 b/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/qos.json.j2 deleted file mode 100644 index 3e548325ea3..00000000000 --- a/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/qos.json.j2 +++ /dev/null @@ -1 +0,0 @@ -{%- include 'qos_config.j2' %} diff --git a/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/sai.profile b/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/sai.profile deleted file mode 100644 index e7b5f90ac88..00000000000 --- a/device/cig/x86_64-cig_cs6436_54p-r0/Cig-CS6436-54P/sai.profile +++ /dev/null @@ -1,3 +0,0 @@ -SAI_INIT_LED_CONFIG_FILE=/usr/share/sonic/hwsku/led.bin -SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/proc_init.nps -SAI_DSH_CONFIG_FILE=/usr/share/sonic/hwsku/port_config.nps diff --git a/device/cig/x86_64-cig_cs6436_54p-r0/default_sku b/device/cig/x86_64-cig_cs6436_54p-r0/default_sku deleted file mode 100644 index 24afbb73b77..00000000000 --- a/device/cig/x86_64-cig_cs6436_54p-r0/default_sku +++ /dev/null @@ -1 +0,0 @@ -Cig-CS6436-54P t1 diff --git a/device/cig/x86_64-cig_cs6436_54p-r0/installer.conf b/device/cig/x86_64-cig_cs6436_54p-r0/installer.conf deleted file mode 100644 index ea6b4f6ebe3..00000000000 --- a/device/cig/x86_64-cig_cs6436_54p-r0/installer.conf +++ /dev/null @@ -1,4 +0,0 @@ -CONSOLE_PORT=0x3f8 -CONSOLE_DEV=0 -CONSOLE_SPEED=115200 -ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="pci=noaer" diff --git a/device/cig/x86_64-cig_cs6436_54p-r0/platform_asic b/device/cig/x86_64-cig_cs6436_54p-r0/platform_asic deleted file mode 100644 index 4211b60b9ce..00000000000 --- a/device/cig/x86_64-cig_cs6436_54p-r0/platform_asic +++ /dev/null @@ -1 +0,0 @@ -nephos diff --git a/device/cig/x86_64-cig_cs6436_54p-r0/plugins/eeprom.py b/device/cig/x86_64-cig_cs6436_54p-r0/plugins/eeprom.py deleted file mode 100755 index c068c04dac6..00000000000 --- a/device/cig/x86_64-cig_cs6436_54p-r0/plugins/eeprom.py +++ /dev/null @@ -1,19 +0,0 @@ -try: - import binascii - import time - import optparse - import warnings - import os - import sys - from sonic_eeprom import eeprom_base - from sonic_eeprom import eeprom_tlvinfo -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class board(eeprom_tlvinfo.TlvInfoDecoder): - _TLV_INFO_MAX_LEN = 256 - - def __init__(self, name, path, cpld_root, ro): - self.eeprom_path = "/sys/bus/i2c/devices/7-0057/eeprom" - super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/cig/x86_64-cig_cs6436_54p-r0/plugins/psuutil.py b/device/cig/x86_64-cig_cs6436_54p-r0/plugins/psuutil.py deleted file mode 100755 index 442026775a5..00000000000 --- a/device/cig/x86_64-cig_cs6436_54p-r0/plugins/psuutil.py +++ /dev/null @@ -1,92 +0,0 @@ -# -# psuutil.py -# Platform-specific PSU status interface for SONiC -# - - -import os.path -import logging - -try: - from sonic_psu.psu_base import PsuBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class PsuUtil(PsuBase): - """Platform-specific PSUutil class""" - - SYSFS_PSU_DIR = ["/sys/bus/i2c/devices/5-005a", - "/sys/bus/i2c/devices/5-005b"] - - def __init__(self): - PsuBase.__init__(self) - - # Get sysfs attribute - - def get_attr_value(self, attr_path): - - retval = 'ERR' - if (not os.path.isfile(attr_path)): - return retval - - try: - with open(attr_path, 'r') as fd: - retval = fd.read() - except Exception as error: - logging.error("Unable to open %s file !", attr_path) - - retval = retval.rstrip('\r\n') - return retval - - def get_num_psus(self): - """ - Retrieves the number of PSUs available on the device - :return: An integer, the number of PSUs available on the device - """ - MAX_PSUS = 2 - return MAX_PSUS - - def get_psu_status(self, index): - """ - Retrieves the oprational status of power supply unit (PSU) defined - by index - :param index: An integer, index of the PSU of which to query status - :return: Boolean, True if PSU is operating properly, False if PSU is\ - faulty - """ - status = 0 - attr_file = 'psu_power_good' - attr_path = self.SYSFS_PSU_DIR[index-1] + '/' + attr_file - - attr_value = self.get_attr_value(attr_path) - - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - # Check for PSU status - if (attr_value == 1): - status = 1 - - return status - - def get_psu_presence(self, index): - """ - Retrieves the presence status of power supply unit (PSU) defined - by index - :param index: An integer, index of the PSU of which to query status - :return: Boolean, True if PSU is plugged, False if not - """ - status = 0 - psu_absent = 0 - attr_file = 'psu_present' - attr_path = self.SYSFS_PSU_DIR[index-1] + '/' + attr_file - - attr_value = self.get_attr_value(attr_path) - - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - # Check for PSU presence - if (attr_value == 1): - status = 1 - - return status diff --git a/device/cig/x86_64-cig_cs6436_54p-r0/plugins/sfputil.py b/device/cig/x86_64-cig_cs6436_54p-r0/plugins/sfputil.py deleted file mode 100755 index 2d682730045..00000000000 --- a/device/cig/x86_64-cig_cs6436_54p-r0/plugins/sfputil.py +++ /dev/null @@ -1,244 +0,0 @@ -try: - import time - from sonic_sfp.sfputilbase import SfpUtilBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class SfpUtil(SfpUtilBase): - """Platform specific SfpUtill class""" - - _port_start = 1 - _port_end = 54 - _qsfp_port_start = 49 - _ports_in_block = 54 - - _port_to_eeprom_mapping = {} - _global_port_pres_dict = {} - - _port_to_i2c_mapping = { - 1: 8, - 2: 9, - 3: 10, - 4: 11, - 5: 12, - 6: 13, - 7: 14, - 8: 15, - 9: 16, - 10: 17, - 11: 18, - 12: 19, - 13: 20, - 14: 21, - 15: 22, - 16: 23, - 17: 24, - 18: 25, - 19: 26, - 20: 27, - 21: 28, - 22: 29, - 23: 30, - 24: 31, - 25: 32, - 26: 33, - 27: 34, - 28: 35, - 29: 36, - 30: 37, - 31: 38, - 32: 39, - 33: 40, - 34: 41, - 35: 42, - 36: 43, - 37: 44, - 38: 45, - 39: 46, - 40: 47, - 41: 48, - 42: 49, - 43: 50, - 44: 51, - 45: 52, - 46: 53, - 47: 54, - 48: 55, - 49: 56, - 50: 57, - 51: 60, - 52: 61, - 53: 62, - 54: 63, - } - - _qsfp_ports = list(range(_qsfp_port_start, _ports_in_block + 1)) - - def get_presence(self, port_num): - # Check for invalid port_num - if port_num < self._port_start or port_num > self._port_end: - return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_is_present" - port_ps = path.format(self._port_to_i2c_mapping[port_num]) - - try: - reg_file = open(port_ps) - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - try: - reg_value = reg_file.readline().rstrip() - except IOError as e: - time.sleep(1) - - try: - reg_value = reg_file.readline().rstrip() - except IOError as e: - print("Error:try again to read file failed: %s %s" % (str(e), port_ps)) - reg_file.close() - return False - - reg_file.close() - if reg_value == '1': - return True - - reg_file.close() - if reg_value == '1': - return True - - return False - - def init_global_port_presence(self): - for port_num in range(self.port_start, (self.port_end + 1)): - self._global_port_pres_dict[port_num] = '0' - - def __init__(self): - eeprom_path = '/sys/bus/i2c/devices/{0}-0050/sfp_eeprom' - for x in range(self._port_start, self._port_end + 1): - port_eeprom_path = eeprom_path.format(self._port_to_i2c_mapping[x]) - self._port_to_eeprom_mapping[x] = port_eeprom_path - - self.init_global_port_presence() - SfpUtilBase.__init__(self) - - def reset(self, port_num): - # Check for invalid port_num - if port_num < self._port_start or port_num > self._port_end: - return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_port_reset" - port_ps = path.format(self._port_to_i2c_mapping[port_num]) - - try: - reg_file = open(port_ps, 'w') - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - # toggle reset - reg_file.seek(0) - reg_file.write('1') - time.sleep(1) - reg_file.seek(0) - reg_file.write('0') - reg_file.close() - return True - - def set_low_power_mode(self, port_num, lpmode): - # Check for invalid port_num - if port_num < self._qsfp_port_start or port_num > self._port_end: - return False - - pre_value = self.get_presence(port_num) - if pre_value == False: - return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_lpmode" - port_ps = path.format(self._port_to_i2c_mapping[port_num]) - - try: - reg_file = open(port_ps, 'w') - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - reg_file.seek(0) - - if lpmode == 1: - reg_file.write('1') - elif lpmode == 0: - reg_file.write('0') - reg_file.close() - - return True - - def get_low_power_mode(self, port_num): - # Check for invalid port_num - - if port_num < self._qsfp_port_start or port_num > self._port_end: - return False - - pre_value = self.get_presence(port_num) - if pre_value == False: - return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_lpmode" - port_ps = path.format(self._port_to_i2c_mapping[port_num]) - - try: - reg_file = open(port_ps) - except IOError as e: - print("Error: unable to open file:%s %s" % (str(e), port_ps)) - return False - - try: - reg_value = reg_file.readline().rstrip() - except IOError as e: - print("Error: unable to open file:%s %s" % (str(e), port_ps)) - reg_file.close() - return False - - reg_file.close() - - if reg_value == '1': - return True - - return False - - def get_transceiver_change_event(self): - port_dict = {} - while True: - for port_num in range(self.port_start, (self.port_end + 1)): - presence = self.get_presence(port_num) - - if(presence and self._global_port_pres_dict[port_num] == '0'): - self._global_port_pres_dict[port_num] = '1' - port_dict[port_num] = '1' - elif(not presence and - self._global_port_pres_dict[port_num] == '1'): - self._global_port_pres_dict[port_num] = '0' - port_dict[port_num] = '0' - - if(len(port_dict) > 0): - return True, port_dict - - time.sleep(0.5) - - @property - def port_start(self): - return self._port_start - - @property - def port_end(self): - return self._port_end - - @property - def qsfp_ports(self): - return self._qsfp_ports - - @property - def port_to_eeprom_mapping(self): - return self._port_to_eeprom_mapping diff --git a/device/cig/x86_64-cig_cs6436_54p-r0/sensors.conf b/device/cig/x86_64-cig_cs6436_54p-r0/sensors.conf deleted file mode 100644 index 22cd3ccda95..00000000000 --- a/device/cig/x86_64-cig_cs6436_54p-r0/sensors.conf +++ /dev/null @@ -1,13 +0,0 @@ -# libsensors configuration file - -chip "cs6436_54p_fan-*" - label fan1 "front fan 1" - label fan2 "front fan 2" - label fan3 "front fan 3" - label fan4 "front fan 4" - label fan5 "front fan 5" - label fan6 "rear fan 1" - label fan7 "rear fan 2" - label fan8 "rear fan 3" - label fan9 "rear fan 4" - label fan10 "rear fan 5" diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/buffers.json.j2 b/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/buffers.json.j2 deleted file mode 100644 index 818e8e1f1e6..00000000000 --- a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/buffers.json.j2 +++ /dev/null @@ -1,111 +0,0 @@ -{# Default values which will be used if no actual configura available #} -{% set default_cable = '40m' %} -{% set default_speed = '10G' %} -{% set default_ports_num = 54 -%} - -{# Port configuration to cable length look-up table #} -{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #} -{# Roles described in the minigraph #} -{% set ports2cable = { - 'torrouter_server' : '5m', - 'leafrouter_torrouter' : '40m', - 'spinerouter_leafrouter' : '300m' - } -%} - -{%- macro cable_length(port_name) -%} - {%- set cable_len = [] -%} - {%- for local_port in DEVICE_NEIGHBOR -%} - {%- if local_port == port_name -%} - {%- if DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} - {%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} - {%- set neighbor_role = neighbor.type -%} - {%- set roles1 = switch_role + '_' + neighbor_role %} - {%- set roles2 = neighbor_role + '_' + switch_role -%} - {%- set roles1 = roles1 | lower -%} - {%- set roles2 = roles2 | lower -%} - {%- if roles1 in ports2cable -%} - {%- if cable_len.append(ports2cable[roles1]) -%}{%- endif -%} - {%- elif roles2 in ports2cable -%} - {%- if cable_len.append(ports2cable[roles2]) -%}{%- endif -%} - {%- endif -%} - {%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- if cable_len -%} - {{ cable_len.0 }} - {%- else -%} - {{ default_cable }} - {%- endif -%} -{% endmacro %} - -{%- if DEVICE_METADATA is defined %} -{%- set switch_role = DEVICE_METADATA['localhost']['type'] %} -{%- endif -%} - -{# Generate list of ports if not defined #} -{% if PORT is not defined %} - {% set PORT = [] %} - {% for port_idx in range(0,default_ports_num) %} - {% if PORT.append("Ethernet%d" % (port_idx)) %}{% endif %} - {% endfor %} -{% endif -%} - -{% set port_names_list = [] %} -{% for port in PORT %} - {%- if port_names_list.append(port) %}{% endif %} -{% endfor %} -{% set port_names = port_names_list | join(',') -%} - -{ - "CABLE_LENGTH": { - "AZURE": { - {% for port in PORT %} - {% set cable = cable_length(port) -%} - "{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %} - - {% endfor %} - } - }, - "BUFFER_POOL": { - "ingress_lossless_pool": { - "size": "20971328", - "type": "ingress", - "mode": "static" - }, - "ingress_lossy_pool": { - "size": "20971328", - "type": "ingress", - "mode": "static" - }, - "egress_lossy_pool": { - "size": "20971328", - "type": "egress", - "mode": "static" - } - }, - "BUFFER_PROFILE": { - "ingress_lossless_profile": { - "pool":"ingress_lossless_pool", - "xon":"78400", - "xoff":"132160", - "size":"3584", - "static_th":"82880" - }, - "ingress_lossy_profile": { - "pool":"ingress_lossy_pool", - "size":"3584", - "dynamic_th":"-1" - }, - "egress_lossy_profile": { - "pool":"egress_lossy_pool", - "size":"3584", - "dynamic_th":"-4" - } - }, - "BUFFER_PG": { - }, - "BUFFER_QUEUE": { - } -} - \ No newline at end of file diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/led.bin b/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/led.bin deleted file mode 100644 index 8b3490ca3b7..00000000000 Binary files a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/led.bin and /dev/null differ diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/pg_profile_lookup.ini b/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/pg_profile_lookup.ini deleted file mode 100644 index d98b0eca6d1..00000000000 --- a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/pg_profile_lookup.ini +++ /dev/null @@ -1,17 +0,0 @@ -# PG lossless profiles. -# speed cable size xon xoff threshold - 10000 5m 3584 32256 59136 36736 - 25000 5m 3584 41216 68096 45696 - 40000 5m 3584 47488 74368 51968 - 50000 5m 3584 52864 79744 57344 - 100000 5m 3584 78400 132160 82880 - 10000 40m 3584 32256 59136 36736 - 25000 40m 3584 41216 68096 45696 - 40000 40m 3584 47488 74368 51968 - 50000 40m 3584 52864 79744 57344 - 100000 40m 3584 78400 132160 82880 - 10000 300m 3584 32256 65856 36736 - 25000 300m 3584 41216 84672 45696 - 40000 300m 3584 47488 101024 51968 - 50000 300m 3584 52864 113120 57344 - 100000 300m 3584 78400 198688 82880 \ No newline at end of file diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/port_config.ini b/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/port_config.ini deleted file mode 100644 index f7914a5c4ab..00000000000 --- a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/port_config.ini +++ /dev/null @@ -1,57 +0,0 @@ -# name lanes alias index speed -Ethernet0 8 Ethernet1/1 1 25000 -Ethernet1 9 Ethernet2/1 2 25000 -Ethernet2 10 Ethernet3/1 3 25000 -Ethernet3 11 Ethernet4/1 4 25000 -Ethernet4 12 Ethernet5/1 5 25000 -Ethernet5 13 Ethernet6/1 6 25000 -Ethernet6 14 Ethernet7/1 7 25000 -Ethernet7 15 Ethernet8/1 8 25000 -Ethernet8 16 Ethernet9/1 9 25000 -Ethernet9 17 Ethernet10/1 10 25000 -Ethernet10 18 Ethernet11/1 11 25000 -Ethernet11 19 Ethernet12/1 12 25000 -Ethernet12 20 Ethernet13/1 13 25000 -Ethernet13 21 Ethernet14/1 14 25000 -Ethernet14 22 Ethernet15/1 15 25000 -Ethernet15 23 Ethernet16/1 16 25000 -Ethernet16 32 Ethernet17/1 17 25000 -Ethernet17 33 Ethernet18/1 18 25000 -Ethernet18 34 Ethernet19/1 19 25000 -Ethernet19 35 Ethernet20/1 20 25000 -Ethernet20 40 Ethernet21/1 21 25000 -Ethernet21 41 Ethernet22/1 22 25000 -Ethernet22 42 Ethernet23/1 23 25000 -Ethernet23 43 Ethernet24/1 24 25000 -Ethernet24 48 Ethernet25/1 25 25000 -Ethernet25 49 Ethernet26/1 26 25000 -Ethernet26 50 Ethernet27/1 27 25000 -Ethernet27 51 Ethernet28/1 28 25000 -Ethernet28 56 Ethernet29/1 29 25000 -Ethernet29 57 Ethernet30/1 30 25000 -Ethernet30 58 Ethernet31/1 31 25000 -Ethernet31 59 Ethernet32/1 32 25000 -Ethernet32 64 Ethernet33/1 33 25000 -Ethernet33 65 Ethernet34/1 34 25000 -Ethernet34 66 Ethernet35/1 35 25000 -Ethernet35 67 Ethernet36/1 36 25000 -Ethernet36 68 Ethernet37/1 37 25000 -Ethernet37 69 Ethernet38/1 38 25000 -Ethernet38 70 Ethernet39/1 39 25000 -Ethernet39 71 Ethernet40/1 40 25000 -Ethernet40 72 Ethernet41/1 41 25000 -Ethernet41 73 Ethernet42/1 42 25000 -Ethernet42 74 Ethernet43/1 43 25000 -Ethernet43 75 Ethernet44/1 44 25000 -Ethernet44 76 Ethernet45/1 45 25000 -Ethernet45 77 Ethernet46/1 46 25000 -Ethernet46 78 Ethernet47/1 47 25000 -Ethernet47 79 Ethernet48/1 48 25000 -Ethernet48 84,85,86,87 Ethernet49/1 49 100000 -Ethernet49 80,81,82,83 Ethernet50/1 50 100000 -Ethernet50 92,93,94,95 Ethernet51/1 51 100000 -Ethernet51 88,89,90,91 Ethernet52/1 52 100000 -Ethernet52 108,109,110,111 Ethernet53/1 53 100000 -Ethernet53 104,105,106,107 Ethernet54/1 54 100000 -Ethernet54 116,117,118,119 Ethernet55/1 55 100000 -Ethernet55 112,113,114,115 Ethernet56/1 56 100000 \ No newline at end of file diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/port_config.nps b/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/port_config.nps deleted file mode 100644 index c0067a3b56a..00000000000 --- a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/port_config.nps +++ /dev/null @@ -1,646 +0,0 @@ -init start stage unit=0 low-level -init set port-map unit=0 port=0 eth-macro=2 lane=0 max-speed=25g active=true -init set port-map unit=0 port=1 eth-macro=2 lane=1 max-speed=25g active=true -init set port-map unit=0 port=2 eth-macro=2 lane=2 max-speed=25g active=true -init set port-map unit=0 port=3 eth-macro=2 lane=3 max-speed=25g active=true -init set port-map unit=0 port=4 eth-macro=3 lane=0 max-speed=25g active=true -init set port-map unit=0 port=5 eth-macro=3 lane=1 max-speed=25g active=true -init set port-map unit=0 port=6 eth-macro=3 lane=2 max-speed=25g active=true -init set port-map unit=0 port=7 eth-macro=3 lane=3 max-speed=25g active=true -init set port-map unit=0 port=8 eth-macro=4 lane=0 max-speed=25g active=true -init set port-map unit=0 port=9 eth-macro=4 lane=1 max-speed=25g active=true -init set port-map unit=0 port=10 eth-macro=4 lane=2 max-speed=25g active=true -init set port-map unit=0 port=11 eth-macro=4 lane=3 max-speed=25g active=true -init set port-map unit=0 port=12 eth-macro=5 lane=0 max-speed=25g active=true -init set port-map unit=0 port=13 eth-macro=5 lane=1 max-speed=25g active=true -init set port-map unit=0 port=14 eth-macro=5 lane=2 max-speed=25g active=true -init set port-map unit=0 port=15 eth-macro=5 lane=3 max-speed=25g active=true -init set port-map unit=0 port=16 eth-macro=8 lane=0 max-speed=25g active=true -init set port-map unit=0 port=17 eth-macro=8 lane=1 max-speed=25g active=true -init set port-map unit=0 port=18 eth-macro=8 lane=2 max-speed=25g active=true -init set port-map unit=0 port=19 eth-macro=8 lane=3 max-speed=25g active=true -init set port-map unit=0 port=20 eth-macro=10 lane=0 max-speed=25g active=true -init set port-map unit=0 port=21 eth-macro=10 lane=1 max-speed=25g active=true -init set port-map unit=0 port=22 eth-macro=10 lane=2 max-speed=25g active=true -init set port-map unit=0 port=23 eth-macro=10 lane=3 max-speed=25g active=true -init set port-map unit=0 port=24 eth-macro=12 lane=0 max-speed=25g active=true -init set port-map unit=0 port=25 eth-macro=12 lane=1 max-speed=25g active=true -init set port-map unit=0 port=26 eth-macro=12 lane=2 max-speed=25g active=true -init set port-map unit=0 port=27 eth-macro=12 lane=3 max-speed=25g active=true -init set port-map unit=0 port=28 eth-macro=14 lane=0 max-speed=25g active=true -init set port-map unit=0 port=29 eth-macro=14 lane=1 max-speed=25g active=true -init set port-map unit=0 port=30 eth-macro=14 lane=2 max-speed=25g active=true -init set port-map unit=0 port=31 eth-macro=14 lane=3 max-speed=25g active=true -init set port-map unit=0 port=32 eth-macro=16 lane=0 max-speed=25g active=true -init set port-map unit=0 port=33 eth-macro=16 lane=1 max-speed=25g active=true -init set port-map unit=0 port=34 eth-macro=16 lane=2 max-speed=25g active=true -init set port-map unit=0 port=35 eth-macro=16 lane=3 max-speed=25g active=true -init set port-map unit=0 port=36 eth-macro=17 lane=0 max-speed=25g active=true -init set port-map unit=0 port=37 eth-macro=17 lane=1 max-speed=25g active=true -init set port-map unit=0 port=38 eth-macro=17 lane=2 max-speed=25g active=true -init set port-map unit=0 port=39 eth-macro=17 lane=3 max-speed=25g active=true -init set port-map unit=0 port=40 eth-macro=18 lane=0 max-speed=25g active=true -init set port-map unit=0 port=41 eth-macro=18 lane=1 max-speed=25g active=true -init set port-map unit=0 port=42 eth-macro=18 lane=2 max-speed=25g active=true -init set port-map unit=0 port=43 eth-macro=18 lane=3 max-speed=25g active=true -init set port-map unit=0 port=44 eth-macro=19 lane=0 max-speed=25g active=true -init set port-map unit=0 port=45 eth-macro=19 lane=1 max-speed=25g active=true -init set port-map unit=0 port=46 eth-macro=19 lane=2 max-speed=25g active=true -init set port-map unit=0 port=47 eth-macro=19 lane=3 max-speed=25g active=true -init set port-map unit=0 port=48 eth-macro=21 lane=0 max-speed=100g active=true -init set port-map unit=0 port=49 eth-macro=20 lane=0 max-speed=100g active=true -init set port-map unit=0 port=50 eth-macro=23 lane=0 max-speed=100g active=true -init set port-map unit=0 port=51 eth-macro=22 lane=0 max-speed=100g active=true -init set port-map unit=0 port=52 eth-macro=27 lane=0 max-speed=100g active=true -init set port-map unit=0 port=53 eth-macro=26 lane=0 max-speed=100g active=true -init set port-map unit=0 port=54 eth-macro=29 lane=0 max-speed=100g active=true -init set port-map unit=0 port=55 eth-macro=28 lane=0 max-speed=100g active=true -init set port-map unit=0 port=129 eth-macro=0 lane=1 max-speed=10g active=true guarantee=true cpi=true -init set port-map unit=0 port=130 eth-macro=0 lane=0 max-speed=10g active=true guarantee=true cpi=true init-done=true -init start stage unit=0 task-rsrc -init start stage unit=0 module -init start stage unit=0 task -phy set lane-swap unit=0 portlist=0 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=1 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=2 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=3 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=4 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=5 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=6 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=7 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=8 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=9 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=10 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=11 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=12 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=13 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=14 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=15 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=16 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=17 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=18 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=19 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=20 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=21 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=22 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=23 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=24 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=25 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=26 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=27 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=28 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=29 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=30 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=31 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=32 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=33 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=34 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=35 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=36 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=37 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=38 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=39 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=40 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=41 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=42 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=43 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=44 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=45 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=46 lane-cnt=1 property=tx data=0x2 -phy set lane-swap unit=0 portlist=47 lane-cnt=1 property=tx data=0x3 -phy set lane-swap unit=0 portlist=48 lane-cnt=4 property=tx data=0x3.0.1.2 -phy set lane-swap unit=0 portlist=49 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=50 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap unit=0 portlist=51 lane-cnt=4 property=tx data=0x3.2.0.1 -phy set lane-swap unit=0 portlist=52 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=53 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=54 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=55 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=129 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=130 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=0 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=1 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=2 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=3 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=4 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=5 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=6 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=7 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=8 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=9 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=10 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=11 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=12 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=13 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=14 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=15 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=16 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=17 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=18 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=19 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=20 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=21 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=22 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=23 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=24 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=25 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=26 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=27 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=28 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=29 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=30 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=31 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=32 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=33 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=34 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=35 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=36 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=37 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=38 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=39 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=40 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=41 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=42 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=43 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=44 lane-cnt=1 property=rx data=0x2 -phy set lane-swap unit=0 portlist=45 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=46 lane-cnt=1 property=rx data=0x0 -phy set lane-swap unit=0 portlist=47 lane-cnt=1 property=rx data=0x3 -phy set lane-swap unit=0 portlist=48 lane-cnt=4 property=rx data=0x3.1.0.2 -phy set lane-swap unit=0 portlist=49 lane-cnt=4 property=rx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=50 lane-cnt=4 property=rx data=0x3.0.1.2 -phy set lane-swap unit=0 portlist=51 lane-cnt=4 property=rx data=0x3.2.1.0 -phy set lane-swap unit=0 portlist=52 lane-cnt=4 property=rx data=0x1.0.3.2 -phy set lane-swap unit=0 portlist=53 lane-cnt=4 property=rx data=0x2.0.1.3 -phy set lane-swap unit=0 portlist=54 lane-cnt=4 property=rx data=0x1.0.3.2 -phy set lane-swap unit=0 portlist=55 lane-cnt=4 property=rx data=0x1.0.3.2 -phy set lane-swap unit=0 portlist=129 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=130 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=0 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=1 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=2 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=3 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=4 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=5 lane-cnt=1 property=tx data=0x1 -phy set polarity-rev unit=0 portlist=6 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=7 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=8 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=9 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=10 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=11 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=12 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=13 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=14 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=15 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=16 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=17 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=18 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=19 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=20 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=21 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=22 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=23 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=24 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=25 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=26 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=27 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=28 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=29 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=30 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=31 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=32 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=33 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=34 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=35 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=36 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=37 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=38 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=39 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=40 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=41 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=42 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=43 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=44 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=45 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=46 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=47 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=48 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=49 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=50 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=51 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=52 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=53 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=54 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=55 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=129 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=130 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=0 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=1 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=2 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=3 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=4 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=5 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=6 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=7 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=8 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=9 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=10 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=11 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=12 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=13 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=14 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=15 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=16 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=17 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=18 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=19 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=20 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=21 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=22 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=23 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=24 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=25 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=26 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=27 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=28 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=29 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=30 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=31 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=32 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=33 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=34 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=35 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=36 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=37 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=38 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=39 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=40 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=41 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=42 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=43 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=44 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=45 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=46 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=47 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=48 lane-cnt=4 property=rx data=0x0.1.1.0 -phy set polarity-rev unit=0 portlist=49 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=50 lane-cnt=4 property=rx data=0x1.1.1.1 -phy set polarity-rev unit=0 portlist=51 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=52 lane-cnt=4 property=rx data=0x1.1.1.0 -phy set polarity-rev unit=0 portlist=53 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=54 lane-cnt=4 property=rx data=0x1.1.1.0 -phy set polarity-rev unit=0 portlist=55 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=129 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=130 lane-cnt=1 property=rx data=0x0 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=c0 data=0x1a -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=c0 data=0x1b -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=c0 data=0x1b -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=c0 data=0x1b -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=c0 data=0x1b -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=c1 data=0x7 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=c2 data=0x2 -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=c0 data=0x1c -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=c1 data=0x6 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=54 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=54 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=54 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=54 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=55 lane-cnt=4 property=c2 data=0x2.2.2.2 -phy set pre-emphasis unit=0 portlist=55 lane-cnt=4 property=cn1 data=0x0.0.0.0 -phy set pre-emphasis unit=0 portlist=55 lane-cnt=4 property=c0 data=0x1b.1b.1b.1b -phy set pre-emphasis unit=0 portlist=55 lane-cnt=4 property=c1 data=0x6.6.6.6 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=c2 data=0x1 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=cn1 data=0x1 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=c0 data=0x2 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=c1 data=0x3 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=c2 data=0x1 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=cn1 data=0x0 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=c0 data=0x2 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=c1 data=0x3 -port set property unit=0 portlist=0 speed=25g -port set property unit=0 portlist=1 speed=25g -port set property unit=0 portlist=2 speed=25g -port set property unit=0 portlist=3 speed=25g -port set property unit=0 portlist=4 speed=25g -port set property unit=0 portlist=5 speed=25g -port set property unit=0 portlist=6 speed=25g -port set property unit=0 portlist=7 speed=25g -port set property unit=0 portlist=8 speed=25g -port set property unit=0 portlist=9 speed=25g -port set property unit=0 portlist=10 speed=25g -port set property unit=0 portlist=11 speed=25g -port set property unit=0 portlist=12 speed=25g -port set property unit=0 portlist=13 speed=25g -port set property unit=0 portlist=14 speed=25g -port set property unit=0 portlist=15 speed=25g -port set property unit=0 portlist=16 speed=25g -port set property unit=0 portlist=17 speed=25g -port set property unit=0 portlist=18 speed=25g -port set property unit=0 portlist=19 speed=25g -port set property unit=0 portlist=20 speed=25g -port set property unit=0 portlist=21 speed=25g -port set property unit=0 portlist=22 speed=25g -port set property unit=0 portlist=23 speed=25g -port set property unit=0 portlist=24 speed=25g -port set property unit=0 portlist=25 speed=25g -port set property unit=0 portlist=26 speed=25g -port set property unit=0 portlist=27 speed=25g -port set property unit=0 portlist=28 speed=25g -port set property unit=0 portlist=29 speed=25g -port set property unit=0 portlist=30 speed=25g -port set property unit=0 portlist=31 speed=25g -port set property unit=0 portlist=32 speed=25g -port set property unit=0 portlist=33 speed=25g -port set property unit=0 portlist=34 speed=25g -port set property unit=0 portlist=35 speed=25g -port set property unit=0 portlist=36 speed=25g -port set property unit=0 portlist=37 speed=25g -port set property unit=0 portlist=38 speed=25g -port set property unit=0 portlist=39 speed=25g -port set property unit=0 portlist=40 speed=25g -port set property unit=0 portlist=41 speed=25g -port set property unit=0 portlist=42 speed=25g -port set property unit=0 portlist=43 speed=25g -port set property unit=0 portlist=44 speed=25g -port set property unit=0 portlist=45 speed=25g -port set property unit=0 portlist=46 speed=25g -port set property unit=0 portlist=47 speed=25g -port set property unit=0 portlist=48 speed=100g -port set property unit=0 portlist=49 speed=100g -port set property unit=0 portlist=50 speed=100g -port set property unit=0 portlist=51 speed=100g -port set property unit=0 portlist=52 speed=100g -port set property unit=0 portlist=53 speed=100g -port set property unit=0 portlist=54 speed=100g -port set property unit=0 portlist=55 speed=100g -port set property unit=0 portlist=129 speed=10g -port set property unit=0 portlist=130 speed=1g -port set property unit=0 portlist=0 medium-type=sr -port set property unit=0 portlist=1 medium-type=sr -port set property unit=0 portlist=2 medium-type=sr -port set property unit=0 portlist=3 medium-type=sr -port set property unit=0 portlist=4 medium-type=sr -port set property unit=0 portlist=5 medium-type=sr -port set property unit=0 portlist=6 medium-type=sr -port set property unit=0 portlist=7 medium-type=sr -port set property unit=0 portlist=8 medium-type=sr -port set property unit=0 portlist=9 medium-type=sr -port set property unit=0 portlist=10 medium-type=sr -port set property unit=0 portlist=11 medium-type=sr -port set property unit=0 portlist=12 medium-type=sr -port set property unit=0 portlist=13 medium-type=sr -port set property unit=0 portlist=14 medium-type=sr -port set property unit=0 portlist=15 medium-type=sr -port set property unit=0 portlist=16 medium-type=sr -port set property unit=0 portlist=17 medium-type=sr -port set property unit=0 portlist=18 medium-type=sr -port set property unit=0 portlist=19 medium-type=sr -port set property unit=0 portlist=20 medium-type=sr -port set property unit=0 portlist=21 medium-type=sr -port set property unit=0 portlist=22 medium-type=sr -port set property unit=0 portlist=23 medium-type=sr -port set property unit=0 portlist=24 medium-type=sr -port set property unit=0 portlist=25 medium-type=sr -port set property unit=0 portlist=26 medium-type=sr -port set property unit=0 portlist=27 medium-type=sr -port set property unit=0 portlist=28 medium-type=sr -port set property unit=0 portlist=29 medium-type=sr -port set property unit=0 portlist=30 medium-type=sr -port set property unit=0 portlist=31 medium-type=sr -port set property unit=0 portlist=32 medium-type=sr -port set property unit=0 portlist=33 medium-type=sr -port set property unit=0 portlist=34 medium-type=sr -port set property unit=0 portlist=35 medium-type=sr -port set property unit=0 portlist=36 medium-type=sr -port set property unit=0 portlist=37 medium-type=sr -port set property unit=0 portlist=38 medium-type=sr -port set property unit=0 portlist=39 medium-type=sr -port set property unit=0 portlist=40 medium-type=sr -port set property unit=0 portlist=41 medium-type=sr -port set property unit=0 portlist=42 medium-type=sr -port set property unit=0 portlist=43 medium-type=sr -port set property unit=0 portlist=44 medium-type=sr -port set property unit=0 portlist=45 medium-type=sr -port set property unit=0 portlist=46 medium-type=sr -port set property unit=0 portlist=47 medium-type=sr -port set property unit=0 portlist=48 medium-type=sr4 -port set property unit=0 portlist=49 medium-type=sr4 -port set property unit=0 portlist=50 medium-type=sr4 -port set property unit=0 portlist=51 medium-type=sr4 -port set property unit=0 portlist=52 medium-type=sr4 -port set property unit=0 portlist=53 medium-type=sr4 -port set property unit=0 portlist=54 medium-type=sr4 -port set property unit=0 portlist=55 medium-type=sr4 -port set property unit=0 portlist=129 medium-type=kr -port set property unit=0 portlist=130 medium-type=x -port advertise unit=0 portlist=129 speed-10g-kr -port set property unit=0 portlist=129 an=enable -port set property unit=0 portlist=0-55 admin=disable -port set property unit=0 portlist=129-130 admin=disable diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/proc_init.nps b/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/proc_init.nps deleted file mode 100644 index e55ceb0fda3..00000000000 --- a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/proc_init.nps +++ /dev/null @@ -1,10 +0,0 @@ -#unit NPS_CFG_TYPE_XXX param0 param1 value -#---- ---------------- ------ ------ ----- -0 NPS_CFG_TYPE_USE_UNIT_PORT 0 0 1 -0 NPS_CFG_TYPE_LED_CFG 0 0 9 -0 NPS_CFG_TYPE_CPI_PORT_MODE 129 0 1 -0 NPS_CFG_TYPE_CPI_PORT_MODE 130 0 1 -0 NPS_CFG_TYPE_USER_BUF_CTRL 0 0 1 -0 NPS_CFG_TYPE_HASH_L2_FDB_REGION_ENTRY_NUM 0 0 49152 -0 NPS_CFG_TYPE_HASH_L3_WITH_IPV6_PREFIX_64_REGION_ENTRY_NUM 0 0 32768 - diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/qos.json.j2 b/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/qos.json.j2 deleted file mode 100644 index 3e548325ea3..00000000000 --- a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/qos.json.j2 +++ /dev/null @@ -1 +0,0 @@ -{%- include 'qos_config.j2' %} diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/sai.profile b/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/sai.profile deleted file mode 100644 index e7b5f90ac88..00000000000 --- a/device/cig/x86_64-cig_cs6436_56p-r0/Cig-CS6436-56P/sai.profile +++ /dev/null @@ -1,3 +0,0 @@ -SAI_INIT_LED_CONFIG_FILE=/usr/share/sonic/hwsku/led.bin -SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/proc_init.nps -SAI_DSH_CONFIG_FILE=/usr/share/sonic/hwsku/port_config.nps diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/default_sku b/device/cig/x86_64-cig_cs6436_56p-r0/default_sku deleted file mode 100644 index 77eed778107..00000000000 --- a/device/cig/x86_64-cig_cs6436_56p-r0/default_sku +++ /dev/null @@ -1 +0,0 @@ -Cig-CS6436-56P t1 diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/installer.conf b/device/cig/x86_64-cig_cs6436_56p-r0/installer.conf deleted file mode 100644 index ea6b4f6ebe3..00000000000 --- a/device/cig/x86_64-cig_cs6436_56p-r0/installer.conf +++ /dev/null @@ -1,4 +0,0 @@ -CONSOLE_PORT=0x3f8 -CONSOLE_DEV=0 -CONSOLE_SPEED=115200 -ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="pci=noaer" diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/platform_asic b/device/cig/x86_64-cig_cs6436_56p-r0/platform_asic deleted file mode 100644 index 4211b60b9ce..00000000000 --- a/device/cig/x86_64-cig_cs6436_56p-r0/platform_asic +++ /dev/null @@ -1 +0,0 @@ -nephos diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/plugins/eeprom.py b/device/cig/x86_64-cig_cs6436_56p-r0/plugins/eeprom.py deleted file mode 100755 index ae5a8385d96..00000000000 --- a/device/cig/x86_64-cig_cs6436_56p-r0/plugins/eeprom.py +++ /dev/null @@ -1,20 +0,0 @@ -try: - import binascii - import time - import optparse - import warnings - import os - import sys - from sonic_eeprom import eeprom_base - from sonic_eeprom import eeprom_tlvinfo - import subprocess -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class board(eeprom_tlvinfo.TlvInfoDecoder): - _TLV_INFO_MAX_LEN = 256 - - def __init__(self, name, path, cpld_root, ro): - self.eeprom_path = "/sys/bus/i2c/devices/7-0057/eeprom" - super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/plugins/psuutil.py b/device/cig/x86_64-cig_cs6436_56p-r0/plugins/psuutil.py deleted file mode 100755 index 442026775a5..00000000000 --- a/device/cig/x86_64-cig_cs6436_56p-r0/plugins/psuutil.py +++ /dev/null @@ -1,92 +0,0 @@ -# -# psuutil.py -# Platform-specific PSU status interface for SONiC -# - - -import os.path -import logging - -try: - from sonic_psu.psu_base import PsuBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class PsuUtil(PsuBase): - """Platform-specific PSUutil class""" - - SYSFS_PSU_DIR = ["/sys/bus/i2c/devices/5-005a", - "/sys/bus/i2c/devices/5-005b"] - - def __init__(self): - PsuBase.__init__(self) - - # Get sysfs attribute - - def get_attr_value(self, attr_path): - - retval = 'ERR' - if (not os.path.isfile(attr_path)): - return retval - - try: - with open(attr_path, 'r') as fd: - retval = fd.read() - except Exception as error: - logging.error("Unable to open %s file !", attr_path) - - retval = retval.rstrip('\r\n') - return retval - - def get_num_psus(self): - """ - Retrieves the number of PSUs available on the device - :return: An integer, the number of PSUs available on the device - """ - MAX_PSUS = 2 - return MAX_PSUS - - def get_psu_status(self, index): - """ - Retrieves the oprational status of power supply unit (PSU) defined - by index - :param index: An integer, index of the PSU of which to query status - :return: Boolean, True if PSU is operating properly, False if PSU is\ - faulty - """ - status = 0 - attr_file = 'psu_power_good' - attr_path = self.SYSFS_PSU_DIR[index-1] + '/' + attr_file - - attr_value = self.get_attr_value(attr_path) - - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - # Check for PSU status - if (attr_value == 1): - status = 1 - - return status - - def get_psu_presence(self, index): - """ - Retrieves the presence status of power supply unit (PSU) defined - by index - :param index: An integer, index of the PSU of which to query status - :return: Boolean, True if PSU is plugged, False if not - """ - status = 0 - psu_absent = 0 - attr_file = 'psu_present' - attr_path = self.SYSFS_PSU_DIR[index-1] + '/' + attr_file - - attr_value = self.get_attr_value(attr_path) - - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - # Check for PSU presence - if (attr_value == 1): - status = 1 - - return status diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/plugins/sfputil.py b/device/cig/x86_64-cig_cs6436_56p-r0/plugins/sfputil.py deleted file mode 100755 index 9c31083f5c2..00000000000 --- a/device/cig/x86_64-cig_cs6436_56p-r0/plugins/sfputil.py +++ /dev/null @@ -1,246 +0,0 @@ -try: - import time - from sonic_sfp.sfputilbase import SfpUtilBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class SfpUtil(SfpUtilBase): - """Platform specific SfpUtill class""" - - _port_start = 1 - _port_end = 56 - _qsfp_port_start = 49 - _ports_in_block = 56 - - _port_to_eeprom_mapping = {} - _global_port_pres_dict = {} - - _port_to_i2c_mapping = { - 1: 8, - 2: 9, - 3: 10, - 4: 11, - 5: 12, - 6: 13, - 7: 14, - 8: 15, - 9: 16, - 10: 17, - 11: 18, - 12: 19, - 13: 20, - 14: 21, - 15: 22, - 16: 23, - 17: 24, - 18: 25, - 19: 26, - 20: 27, - 21: 28, - 22: 29, - 23: 30, - 24: 31, - 25: 32, - 26: 33, - 27: 34, - 28: 35, - 29: 36, - 30: 37, - 31: 38, - 32: 39, - 33: 40, - 34: 41, - 35: 42, - 36: 43, - 37: 44, - 38: 45, - 39: 46, - 40: 47, - 41: 48, - 42: 49, - 43: 50, - 44: 51, - 45: 52, - 46: 53, - 47: 54, - 48: 55, - 49: 56, - 50: 57, - 51: 58, - 52: 59, - 53: 60, - 54: 61, - 55: 62, - 56: 63, - } - - _qsfp_ports = list(range(_qsfp_port_start, _ports_in_block + 1)) - - def get_presence(self, port_num): - # Check for invalid port_num - if port_num < self._port_start or port_num > self._port_end: - return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_is_present" - port_ps = path.format(self._port_to_i2c_mapping[port_num]) - - try: - reg_file = open(port_ps) - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - try: - reg_value = reg_file.readline().rstrip() - except IOError as e: - time.sleep(1) - - try: - reg_value = reg_file.readline().rstrip() - except IOError as e: - print("Error:try again to read file failed: %s %s" % (str(e), port_ps)) - reg_file.close() - return False - - reg_file.close() - if reg_value == '1': - return True - - reg_file.close() - if reg_value == '1': - return True - - return False - - def init_global_port_presence(self): - for port_num in range(self.port_start, (self.port_end + 1)): - self._global_port_pres_dict[port_num] = '0' - - def __init__(self): - eeprom_path = '/sys/bus/i2c/devices/{0}-0050/sfp_eeprom' - for x in range(self._port_start, self._port_end + 1): - port_eeprom_path = eeprom_path.format(self._port_to_i2c_mapping[x]) - self._port_to_eeprom_mapping[x] = port_eeprom_path - - self.init_global_port_presence() - SfpUtilBase.__init__(self) - - def reset(self, port_num): - # Check for invalid port_num - if port_num < self._port_start or port_num > self._port_end: - return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_port_reset" - port_ps = path.format(self._port_to_i2c_mapping[port_num]) - - try: - reg_file = open(port_ps, 'w') - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - # toggle reset - reg_file.seek(0) - reg_file.write('1') - time.sleep(1) - reg_file.seek(0) - reg_file.write('0') - reg_file.close() - return True - - def set_low_power_mode(self, port_num, lpmode): - # Check for invalid port_num - if port_num < self._qsfp_port_start or port_num > self._port_end: - return False - - pre_value = self.get_presence(port_num) - if pre_value == False: - return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_lpmode" - port_ps = path.format(self._port_to_i2c_mapping[port_num]) - - try: - reg_file = open(port_ps, 'w') - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - reg_file.seek(0) - - if lpmode == 1: - reg_file.write('1') - elif lpmode == 0: - reg_file.write('0') - reg_file.close() - - return True - - def get_low_power_mode(self, port_num): - # Check for invalid port_num - - if port_num < self._qsfp_port_start or port_num > self._port_end: - return False - - pre_value = self.get_presence(port_num) - if pre_value == False: - return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_lpmode" - port_ps = path.format(self._port_to_i2c_mapping[port_num]) - - try: - reg_file = open(port_ps) - except IOError as e: - print("Error: unable to open file:%s %s" % (str(e), port_ps)) - return False - - try: - reg_value = reg_file.readline().rstrip() - except IOError as e: - print("Error: unable to open file:%s %s" % (str(e), port_ps)) - reg_file.close() - return False - - reg_file.close() - - if reg_value == '1': - return True - - return False - - def get_transceiver_change_event(self): - port_dict = {} - while True: - for port_num in range(self.port_start, (self.port_end + 1)): - presence = self.get_presence(port_num) - - if(presence and self._global_port_pres_dict[port_num] == '0'): - self._global_port_pres_dict[port_num] = '1' - port_dict[port_num] = '1' - elif(not presence and - self._global_port_pres_dict[port_num] == '1'): - self._global_port_pres_dict[port_num] = '0' - port_dict[port_num] = '0' - - if(len(port_dict) > 0): - return True, port_dict - - time.sleep(0.5) - - @property - def port_start(self): - return self._port_start - - @property - def port_end(self): - return self._port_end - - @property - def qsfp_ports(self): - return self._qsfp_ports - - @property - def port_to_eeprom_mapping(self): - return self._port_to_eeprom_mapping diff --git a/device/cig/x86_64-cig_cs6436_56p-r0/sensors.conf b/device/cig/x86_64-cig_cs6436_56p-r0/sensors.conf deleted file mode 100644 index 565186de280..00000000000 --- a/device/cig/x86_64-cig_cs6436_56p-r0/sensors.conf +++ /dev/null @@ -1,13 +0,0 @@ -# libsensors configuration file - -chip "cs6436_56p_fan-*" - label fan1 "front fan 1" - label fan2 "front fan 2" - label fan3 "front fan 3" - label fan4 "front fan 4" - label fan5 "front fan 5" - label fan6 "rear fan 1" - label fan7 "rear fan 2" - label fan8 "rear fan 3" - label fan9 "rear fan 4" - label fan10 "rear fan 5" diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/buffers.json.j2 b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/buffers.json.j2 deleted file mode 100644 index 9354b7ec5b5..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/buffers.json.j2 +++ /dev/null @@ -1,2 +0,0 @@ -{%- set default_topo = 't0' %} -{%- include 'buffers_config.j2' %} \ No newline at end of file diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/buffers_defaults_t0.j2 b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/buffers_defaults_t0.j2 deleted file mode 100644 index af6460de039..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/buffers_defaults_t0.j2 +++ /dev/null @@ -1,69 +0,0 @@ -{% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '20971328' %} -{% set ingress_lossy_pool_size = '20971328' %} -{% set egress_lossless_pool_size = '20971328' %} -{% set egress_lossy_pool_size = '20971328' %} - -{%- macro generate_port_lists(PORT_ALL) %} - {# Generate list of ports #} - {%- for port_idx in range(0, 32) %} - {%- if PORT_ALL.append("Ethernet%d" % (port_idx*4)) %}{%- endif %} - {%- endfor %} -{%- endmacro %} - -{%- macro generate_buffer_pool_and_profiles() %} - "BUFFER_POOL": { - "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", - "type": "ingress", - "mode": "dynamic" - }, - "ingress_lossy_pool": { - "size": "{{ ingress_lossy_pool_size }}", - "type": "ingress", - "mode": "dynamic" - }, - "egress_lossless_pool": { - "size": "{{ egress_lossless_pool_size }}", - "type": "egress", - "mode": "dynamic" - }, - "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", - "type": "egress", - "mode": "dynamic" - } - }, - "BUFFER_PROFILE": { - "ingress_lossless_profile": { - "pool":"ingress_lossless_pool", - "xon":"78400", - "xoff":"132160", - "size":"3584", - "static_th":"82880" - }, - "ingress_lossy_profile": { - "pool":"ingress_lossy_pool", - "size":"3584", - "dynamic_th":"-1" - }, - "egress_lossy_profile": { - "pool":"egress_lossy_pool", - "size":"3584", - "dynamic_th":"-4" - } - }, -{%- endmacro %} - -{# the typo of generate_pg_profils dued to buffers_config.j2 #} -{# Default, we do not bind any buffer profiles. #} -{%- macro generate_pg_profils(port_names) %} - "BUFFER_PG": { - } -{%- endmacro %} - -{# Default, we do not bind any buffer profiles. #} -{%- macro generate_queue_buffers(port_names) %} - "BUFFER_QUEUE": { - } -{%- endmacro %} \ No newline at end of file diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/buffers_defaults_t1.j2 b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/buffers_defaults_t1.j2 deleted file mode 100644 index af6460de039..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/buffers_defaults_t1.j2 +++ /dev/null @@ -1,69 +0,0 @@ -{% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '20971328' %} -{% set ingress_lossy_pool_size = '20971328' %} -{% set egress_lossless_pool_size = '20971328' %} -{% set egress_lossy_pool_size = '20971328' %} - -{%- macro generate_port_lists(PORT_ALL) %} - {# Generate list of ports #} - {%- for port_idx in range(0, 32) %} - {%- if PORT_ALL.append("Ethernet%d" % (port_idx*4)) %}{%- endif %} - {%- endfor %} -{%- endmacro %} - -{%- macro generate_buffer_pool_and_profiles() %} - "BUFFER_POOL": { - "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", - "type": "ingress", - "mode": "dynamic" - }, - "ingress_lossy_pool": { - "size": "{{ ingress_lossy_pool_size }}", - "type": "ingress", - "mode": "dynamic" - }, - "egress_lossless_pool": { - "size": "{{ egress_lossless_pool_size }}", - "type": "egress", - "mode": "dynamic" - }, - "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", - "type": "egress", - "mode": "dynamic" - } - }, - "BUFFER_PROFILE": { - "ingress_lossless_profile": { - "pool":"ingress_lossless_pool", - "xon":"78400", - "xoff":"132160", - "size":"3584", - "static_th":"82880" - }, - "ingress_lossy_profile": { - "pool":"ingress_lossy_pool", - "size":"3584", - "dynamic_th":"-1" - }, - "egress_lossy_profile": { - "pool":"egress_lossy_pool", - "size":"3584", - "dynamic_th":"-4" - } - }, -{%- endmacro %} - -{# the typo of generate_pg_profils dued to buffers_config.j2 #} -{# Default, we do not bind any buffer profiles. #} -{%- macro generate_pg_profils(port_names) %} - "BUFFER_PG": { - } -{%- endmacro %} - -{# Default, we do not bind any buffer profiles. #} -{%- macro generate_queue_buffers(port_names) %} - "BUFFER_QUEUE": { - } -{%- endmacro %} \ No newline at end of file diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/pg_profile_lookup.ini b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/pg_profile_lookup.ini deleted file mode 100644 index d98b0eca6d1..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/pg_profile_lookup.ini +++ /dev/null @@ -1,17 +0,0 @@ -# PG lossless profiles. -# speed cable size xon xoff threshold - 10000 5m 3584 32256 59136 36736 - 25000 5m 3584 41216 68096 45696 - 40000 5m 3584 47488 74368 51968 - 50000 5m 3584 52864 79744 57344 - 100000 5m 3584 78400 132160 82880 - 10000 40m 3584 32256 59136 36736 - 25000 40m 3584 41216 68096 45696 - 40000 40m 3584 47488 74368 51968 - 50000 40m 3584 52864 79744 57344 - 100000 40m 3584 78400 132160 82880 - 10000 300m 3584 32256 65856 36736 - 25000 300m 3584 41216 84672 45696 - 40000 300m 3584 47488 101024 51968 - 50000 300m 3584 52864 113120 57344 - 100000 300m 3584 78400 198688 82880 \ No newline at end of file diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/port_config.ini b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/port_config.ini deleted file mode 100644 index bb26684cb7d..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/port_config.ini +++ /dev/null @@ -1,33 +0,0 @@ -# name lanes alias index -Ethernet0 0,1,2,3 Ethernet1/1 0 -Ethernet4 4,5,6,7 Ethernet2/1 1 -Ethernet8 8,9,10,11 Ethernet3/1 2 -Ethernet12 12,13,14,15 Ethernet4/1 3 -Ethernet16 16,17,18,19 Ethernet5/1 4 -Ethernet20 20,21,22,23 Ethernet6/1 5 -Ethernet24 24,25,26,27 Ethernet7/1 6 -Ethernet28 28,29,30,31 Ethernet8/1 7 -Ethernet32 32,33,34,35 Ethernet9/1 8 -Ethernet36 36,37,38,39 Ethernet10/1 9 -Ethernet40 40,41,42,43 Ethernet11/1 10 -Ethernet44 44,45,46,47 Ethernet12/1 11 -Ethernet48 48,49,50,51 Ethernet13/1 12 -Ethernet52 52,53,54,55 Ethernet14/1 13 -Ethernet56 56,57,58,59 Ethernet15/1 14 -Ethernet60 60,61,62,63 Ethernet16/1 15 -Ethernet64 64,65,66,67 Ethernet17/1 16 -Ethernet68 68,69,70,71 Ethernet18/1 17 -Ethernet72 72,73,74,75 Ethernet19/1 18 -Ethernet76 76,77,78,79 Ethernet20/1 19 -Ethernet80 80,81,82,83 Ethernet21/1 20 -Ethernet84 84,85,86,87 Ethernet22/1 21 -Ethernet88 88,89,90,91 Ethernet23/1 22 -Ethernet92 92,93,94,95 Ethernet24/1 23 -Ethernet96 96,97,98,99 Ethernet25/1 24 -Ethernet100 100,101,102,103 Ethernet26/1 25 -Ethernet104 104,105,106,107 Ethernet27/1 26 -Ethernet108 108,109,110,111 Ethernet28/1 27 -Ethernet112 112,113,114,115 Ethernet29/1 28 -Ethernet116 116,117,118,119 Ethernet30/1 29 -Ethernet120 120,121,122,123 Ethernet31/1 30 -Ethernet124 124,125,126,127 Ethernet32/1 31 diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/port_config.nps b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/port_config.nps deleted file mode 100644 index 6d49c672088..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/port_config.nps +++ /dev/null @@ -1,353 +0,0 @@ -init start stage unit=0 low-level -init set port-map unit=0 port=0 eth-macro=0 lane=0 max-speed=100g active=true -init set port-map unit=0 port=1 eth-macro=1 lane=0 max-speed=100g active=true -init set port-map unit=0 port=2 eth-macro=2 lane=0 max-speed=100g active=true -init set port-map unit=0 port=3 eth-macro=3 lane=0 max-speed=100g active=true -init set port-map unit=0 port=4 eth-macro=4 lane=0 max-speed=100g active=true -init set port-map unit=0 port=5 eth-macro=5 lane=0 max-speed=100g active=true -init set port-map unit=0 port=6 eth-macro=6 lane=0 max-speed=100g active=true -init set port-map unit=0 port=7 eth-macro=7 lane=0 max-speed=100g active=true -init set port-map unit=0 port=8 eth-macro=8 lane=0 max-speed=100g active=true -init set port-map unit=0 port=9 eth-macro=9 lane=0 max-speed=100g active=true -init set port-map unit=0 port=10 eth-macro=10 lane=0 max-speed=100g active=true -init set port-map unit=0 port=11 eth-macro=11 lane=0 max-speed=100g active=true -init set port-map unit=0 port=12 eth-macro=12 lane=0 max-speed=100g active=true -init set port-map unit=0 port=13 eth-macro=13 lane=0 max-speed=100g active=true -init set port-map unit=0 port=14 eth-macro=14 lane=0 max-speed=100g active=true -init set port-map unit=0 port=15 eth-macro=15 lane=0 max-speed=100g active=true -init set port-map unit=0 port=16 eth-macro=16 lane=0 max-speed=100g active=true -init set port-map unit=0 port=17 eth-macro=17 lane=0 max-speed=100g active=true -init set port-map unit=0 port=18 eth-macro=18 lane=0 max-speed=100g active=true -init set port-map unit=0 port=19 eth-macro=19 lane=0 max-speed=100g active=true -init set port-map unit=0 port=20 eth-macro=20 lane=0 max-speed=100g active=true -init set port-map unit=0 port=21 eth-macro=21 lane=0 max-speed=100g active=true -init set port-map unit=0 port=22 eth-macro=22 lane=0 max-speed=100g active=true -init set port-map unit=0 port=23 eth-macro=23 lane=0 max-speed=100g active=true -init set port-map unit=0 port=24 eth-macro=24 lane=0 max-speed=100g active=true -init set port-map unit=0 port=25 eth-macro=25 lane=0 max-speed=100g active=true -init set port-map unit=0 port=26 eth-macro=26 lane=0 max-speed=100g active=true -init set port-map unit=0 port=27 eth-macro=27 lane=0 max-speed=100g active=true -init set port-map unit=0 port=28 eth-macro=28 lane=0 max-speed=100g active=true -init set port-map unit=0 port=29 eth-macro=29 lane=0 max-speed=100g active=true -init set port-map unit=0 port=30 eth-macro=30 lane=0 max-speed=100g active=true -init set port-map unit=0 port=31 eth-macro=31 lane=0 max-speed=100g active=true -init set port-map unit=0 port=129 eth-macro=0 lane=1 max-speed=10g active=true guarantee=true cpi=true -init set port-map unit=0 port=130 eth-macro=0 lane=0 max-speed=10g active=true guarantee=true cpi=true init-done=true -init start stage unit=0 task-rsrc -init start stage unit=0 module -init start stage unit=0 task -phy set lane-swap unit=0 portlist=0 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=1 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=2 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=3 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=4 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=5 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=6 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=7 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=8 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=9 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=10 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=11 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=12 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=13 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=14 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=15 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=16 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=17 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=18 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=19 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=20 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=21 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=22 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=23 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=24 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=25 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=26 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=27 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=28 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=29 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=30 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=31 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=129 lane-cnt=1 property=tx data=0x1 -phy set lane-swap unit=0 portlist=130 lane-cnt=1 property=tx data=0x0 -phy set lane-swap unit=0 portlist=0 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=1 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=2 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=3 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=4 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=5 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=6 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=7 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=8 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=9 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=10 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=11 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=12 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=13 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=14 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=15 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=16 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=17 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=18 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=19 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=20 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=21 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=22 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=23 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=24 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=25 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=26 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=27 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=28 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=29 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=30 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=31 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=129 lane-cnt=1 property=rx data=0x1 -phy set lane-swap unit=0 portlist=130 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=0 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=1 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=2 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=3 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=4 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=5 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=6 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=7 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=8 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=9 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=10 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=11 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=12 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=13 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=14 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=15 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=16 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=17 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=18 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=19 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=20 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=21 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=22 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=23 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=24 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=25 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=26 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=27 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=28 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=29 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=30 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=31 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=129 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=130 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev unit=0 portlist=0 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=1 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=2 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=3 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=4 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=5 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=6 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=7 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=8 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=9 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=10 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=11 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=12 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=13 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=14 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=15 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=16 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=17 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=18 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=19 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=20 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=21 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=22 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=23 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=24 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=25 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=26 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=27 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=28 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=29 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=30 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=31 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev unit=0 portlist=129 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev unit=0 portlist=130 lane-cnt=1 property=rx data=0x0 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=4 property=cn1 data=0x01.01.01.01 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=4 property=c0 data=0x1A.1A.1A.1A -phy set pre-emphasis unit=0 portlist=0 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=4 property=c0 data=0x1A.1A.1A.1A -phy set pre-emphasis unit=0 portlist=1 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=4 property=cn1 data=0x01.01.01.01 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=4 property=c0 data=0x1B.1B.1B.1B -phy set pre-emphasis unit=0 portlist=2 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=4 property=c0 data=0x1B.1B.1B.1B -phy set pre-emphasis unit=0 portlist=3 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=4 property=c0 data=0x1B.1B.1B.1B -phy set pre-emphasis unit=0 portlist=4 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=4 property=c0 data=0x1B.1B.1B.1B -phy set pre-emphasis unit=0 portlist=5 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=4 property=c2 data=0x03.03.03.03 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=6 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=7 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=8 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=9 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=10 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=4 property=cn1 data=0x01.01.01.01 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=11 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=12 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=13 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=4 property=c0 data=0x1D.1D.1D.1D -phy set pre-emphasis unit=0 portlist=14 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=15 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=16 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=17 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=18 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=19 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=20 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=4 property=c0 data=0x1B.1B.1B.1B -phy set pre-emphasis unit=0 portlist=21 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=22 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=23 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=24 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=25 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=4 property=c0 data=0x1B.1B.1B.1B -phy set pre-emphasis unit=0 portlist=26 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=4 property=c0 data=0x1B.1B.1B.1B -phy set pre-emphasis unit=0 portlist=27 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=4 property=c0 data=0x1B.1B.1B.1B -phy set pre-emphasis unit=0 portlist=28 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=4 property=c0 data=0x1A.1A.1A.1A -phy set pre-emphasis unit=0 portlist=29 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=4 property=cn1 data=0x01.01.01.01 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=4 property=c0 data=0x1A.1A.1A.1A -phy set pre-emphasis unit=0 portlist=30 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=4 property=c2 data=0x01.01.01.01 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=4 property=cn1 data=0x03.03.03.03 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=4 property=c0 data=0x17.17.17.17 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=4 property=c1 data=0x09.09.09.09 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=c2 data=0x01 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=cn1 data=0x01 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=c0 data=0x02 -phy set pre-emphasis unit=0 portlist=129 lane-cnt=1 property=c1 data=0x03 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=c2 data=0x01 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=cn1 data=0x01 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=c0 data=0x02 -phy set pre-emphasis unit=0 portlist=130 lane-cnt=1 property=c1 data=0x03 -phy set mdio portlist=0 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=1 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=2 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=3 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=4 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=5 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=6 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=7 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=8 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=9 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=10 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=11 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=12 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=13 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=14 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=15 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=16 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=17 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=18 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=19 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=20 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=21 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=22 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=23 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=24 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=25 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=26 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=27 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=28 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=29 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=30 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=31 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=129 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=130 devad=0x1E addr=0x2 data=0x0000 -port set property unit=0 portlist=0-31 speed=100g -port set property unit=0 portlist=129-130 speed=10g -port set property unit=0 portlist=0-31 medium-type=sr4 -port set property unit=0 portlist=129-130 medium-type=kr -port set property unit=0 portlist=0-31 fec=disable -port set adver unit=0 portlist=129-130 speed-10g-kr -port set property unit=0 portlist=129-130 an=enable -port set property unit=0 portlist=129-130 admin=enable -port set property unit=0 portlist=0-31 admin=disable diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/qos.json.j2 b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/qos.json.j2 deleted file mode 100644 index 42eef17c362..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/qos.json.j2 +++ /dev/null @@ -1,136 +0,0 @@ -{ - "TC_TO_PRIORITY_GROUP_MAP": { - "AZURE": { - "0": "1", - "1": "0", - "3": "3", - "4": "4" - } - }, - "MAP_PFC_PRIORITY_TO_QUEUE": { - "AZURE": { - "3": "3", - "4": "4" - } - }, - "TC_TO_QUEUE_MAP": { - "AZURE": { - "0": "1", - "1": "0", - "3": "3", - "4": "4" - } - }, - "DSCP_TO_TC_MAP": { - "AZURE": { - "0":"1", - "1":"0", - "2":"0", - "3":"3", - "4":"4", - "5":"0", - "6":"0", - "7":"0", - "8":"1", - "9":"0", - "10":"0", - "11":"0", - "12":"0", - "13":"0", - "14":"0", - "15":"0", - "16":"0", - "17":"0", - "18":"0", - "19":"0", - "20":"0", - "21":"0", - "22":"0", - "23":"0", - "24":"0", - "25":"0", - "26":"0", - "27":"0", - "28":"0", - "29":"0", - "30":"0", - "31":"0", - "32":"0", - "33":"0", - "34":"0", - "35":"0", - "36":"0", - "37":"0", - "38":"0", - "39":"0", - "40":"0", - "41":"0", - "42":"0", - "43":"0", - "44":"0", - "45":"0", - "46":"0", - "47":"0", - "48":"0", - "49":"0", - "50":"0", - "51":"0", - "52":"0", - "53":"0", - "54":"0", - "55":"0", - "56":"0", - "57":"0", - "58":"0", - "59":"0", - "60":"0", - "61":"0", - "62":"0", - "63":"0" - } - }, - "SCHEDULER": { - "scheduler.0" : { - "type":"DWRR", - "weight": "25" - }, - "scheduler.1" : { - "type":"DWRR", - "weight": "30" - }, - "scheduler.2" : { - "type":"DWRR", - "weight": "20" - } - }, - "PORT_QOS_MAP": { - }, - "WRED_PROFILE": { - "AZURE_LOSSY" : { - "wred_green_enable":"true", - "wred_yellow_enable":"true", - "wred_red_enable":"true", - "ecn":"ecn_all", - "red_max_threshold":"516096", - "red_min_threshold":"516096", - "yellow_max_threshold":"516096", - "yellow_min_threshold":"516096", - "green_max_threshold": "184128", - "green_min_threshold": "184128" - }, - "AZURE_LOSSLESS" : { - "wred_green_enable":"true", - "wred_yellow_enable":"true", - "wred_red_enable":"true", - "ecn":"ecn_all", - "red_max_threshold":"516096", - "red_min_threshold":"516096", - "yellow_max_threshold":"516096", - "yellow_min_threshold":"516096", - "green_max_threshold": "184128", - "green_min_threshold": "184128" - } - }, - "QUEUE": { - } -} diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/sai.profile b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/sai.profile deleted file mode 100644 index 880f47910ac..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/INGRASYS-S9130-32X/sai.profile +++ /dev/null @@ -1,2 +0,0 @@ -SAI_INIT_CONFIG_FILE=/usr/share/sonic/platform/led_proc_init.nps -SAI_DSH_CONFIG_FILE=/usr/share/sonic/hwsku/port_config.nps diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/default_sku b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/default_sku deleted file mode 100644 index 2464f73308e..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/default_sku +++ /dev/null @@ -1 +0,0 @@ -INGRASYS-S9130-32X t1 diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/fancontrol b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/fancontrol deleted file mode 100644 index 5ed165966b9..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/fancontrol +++ /dev/null @@ -1,12 +0,0 @@ -# Configuration file generated by pwmconfig, changes will be lost -INTERVAL=10 -DEVPATH=hwmon5=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-8/8-002f -DEVNAME=hwmon5=w83795adg -FCTEMPS=hwmon5/device/pwm2=hwmon1/temp1_input hwmon5/device/pwm1=hwmon1/temp1_input -FCFANS=hwmon5/device/pwm2=hwmon5/device/fan8_input hwmon5/device/pwm2=hwmon5/device/fan7_input hwmon5/device/pwm2=hwmon5/device/fan6_input hwmon5/device/pwm2=hwmon5/device/fan5_input hwmon5/device/pwm1=hwmon5/device/fan4_input hwmon5/device/pwm1=hwmon5/device/fan3_input hwmon5/device/pwm1=hwmon5/device/fan2_input hwmon5/device/pwm1=hwmon5/device/fan1_input -# TODO: check the temp value with HW after board ready -MINTEMP=hwmon5/device/pwm2=20 hwmon5/device/pwm1=20 -MAXTEMP=hwmon5/device/pwm2=60 hwmon5/device/pwm1=60 -MINSTART=hwmon5/device/pwm2=75 hwmon5/device/pwm1=75 -MINSTOP=hwmon5/device/pwm2=22 hwmon5/device/pwm1=22 - diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/installer.conf b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/installer.conf deleted file mode 100644 index 925a32fc0c3..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/installer.conf +++ /dev/null @@ -1,3 +0,0 @@ -CONSOLE_PORT=0x3f8 -CONSOLE_DEV=0 -CONSOLE_SPEED=115200 diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/led_proc_init.nps b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/led_proc_init.nps deleted file mode 100644 index d1695e36b59..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/led_proc_init.nps +++ /dev/null @@ -1,9 +0,0 @@ -#unit NPS_CFG_TYPE_XXX param0 param1 value -#---- ---------------- ------ ------ ----- -0 NPS_CFG_TYPE_USE_UNIT_PORT 0 0 1 -0 NPS_CFG_TYPE_LED_CFG 0 0 1 -0 NPS_CFG_TYPE_CPI_PORT_MODE 129 0 1 -0 NPS_CFG_TYPE_CPI_PORT_MODE 130 0 1 -0 NPS_CFG_TYPE_USER_BUF_CTRL 0 0 1 -0 NPS_CFG_TYPE_HASH_L2_FDB_REGION_ENTRY_NUM 0 0 49152 -0 NPS_CFG_TYPE_HASH_L3_WITH_IPV6_PREFIX_64_REGION_ENTRY_NUM 0 0 32768 diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/platform_asic b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/platform_asic deleted file mode 100644 index 4211b60b9ce..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/platform_asic +++ /dev/null @@ -1 +0,0 @@ -nephos diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/plugins/eeprom.py b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/plugins/eeprom.py deleted file mode 100644 index 7496ebe21ad..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/plugins/eeprom.py +++ /dev/null @@ -1,20 +0,0 @@ -############################################################################# -# Ingrasys S9130-32X -# -# Platform and model specific eeprom subclass, inherits from the base class, -# and provides the followings: -# - the eeprom format definition -# - specific encoder/decoder if there is special need -############################################################################# - -try: - from sonic_eeprom import eeprom_tlvinfo -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class board(eeprom_tlvinfo.TlvInfoDecoder): - - def __init__(self, name, path, cpld_root, ro): - self.eeprom_path = "/sys/class/i2c-adapter/i2c-0/0-0051/eeprom" - super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/plugins/psuutil.py b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/plugins/psuutil.py deleted file mode 100644 index 37e2173aa9d..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/plugins/psuutil.py +++ /dev/null @@ -1,91 +0,0 @@ -# -# psuutil.py -# Platform-specific PSU status interface for SONiC -# - - -import os.path - -try: - from sonic_psu.psu_base import PsuBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class PsuUtil(PsuBase): - """Platform-specific PSUutil class""" - - SYSFS_PSU_DIR = ["/sys/bus/i2c/devices/i2c-10/10-0050", - "/sys/bus/i2c/devices/i2c-9/9-0050"] - - def __init__(self): - PsuBase.__init__(self) - - # Get sysfs attribute - - def get_attr_value(self, attr_path): - - retval = 'ERR' - if (not os.path.isfile(attr_path)): - return retval - - try: - with open(attr_path, 'r') as fd: - retval = fd.read() - except Exception as error: - logging.error("Unable to open ", attr_path, " file !") - - retval = retval.rstrip('\r\n') - return retval - - def get_num_psus(self): - """ - Retrieves the number of PSUs available on the device - :return: An integer, the number of PSUs available on the device - """ - MAX_PSUS = 2 - return MAX_PSUS - - def get_psu_status(self, index): - """ - Retrieves the oprational status of power supply unit (PSU) defined - by index - :param index: An integer, index of the PSU of which to query status - :return: Boolean, True if PSU is operating properly, False if PSU is\ - faulty - """ - status = 0 - attr_file = 'psu_pg' - attr_path = self.SYSFS_PSU_DIR[index-1] + '/' + attr_file - - attr_value = self.get_attr_value(attr_path) - - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - # Check for PSU status - if (attr_value == 1): - status = 1 - - return status - - def get_psu_presence(self, index): - """ - Retrieves the presence status of power supply unit (PSU) defined - by index - :param index: An integer, index of the PSU of which to query status - :return: Boolean, True if PSU is plugged, False if not - """ - status = 0 - psu_absent = 0 - attr_file = 'psu_abs' - attr_path = self.SYSFS_PSU_DIR[index-1] + '/' + attr_file - - attr_value = self.get_attr_value(attr_path) - - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - # Check for PSU presence - if (attr_value == 0): - status = 1 - - return status diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/plugins/sfputil.py b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/plugins/sfputil.py deleted file mode 100644 index 260c759c799..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/plugins/sfputil.py +++ /dev/null @@ -1,220 +0,0 @@ -# sfputil.py -# -# Platform-specific SFP transceiver interface for SONiC -# - -import os - -try: - import time - from sonic_sfp.sfputilbase import SfpUtilBase -except ImportError as e: - raise ImportError("%s - required module not found" % str(e)) - - -class SfpUtil(SfpUtilBase): - """Platform-specific SfpUtil class""" - - PORT_START = 0 - PORT_END = 31 - PORTS_IN_BLOCK = 32 - EEPROM_OFFSET = 21 - ABS_GPIO_BASE_0_15 = 240 - ABS_GPIO_BASE_16_31 = 224 - LP_MODE_GPIO_BASE_0_15 = 176 - LP_MODE_GPIO_BASE_16_31 = 160 - RST_GPIO_BASE_0_15 = 144 - RST_GPIO_BASE_16_31 = 128 - GPIO_OFFSET = 0 - - GPIO_VAL_PATH = "/sys/class/gpio/gpio{0}/value" - - _port_to_eeprom_mapping = {} - - @property - def port_start(self): - return self.PORT_START - - @property - def port_end(self): - return self.PORT_END - - @property - def qsfp_ports(self): - return list(range(0, self.PORTS_IN_BLOCK + 1)) - - @property - def port_to_eeprom_mapping(self): - return self._port_to_eeprom_mapping - - def set_gpio_offset(self): - sys_gpio_dir = "/sys/class/gpio" - self.GPIO_OFFSET = 0 - gpiochip_no = 0 - for d in os.listdir(sys_gpio_dir): - if "gpiochip" in d: - try: - gpiochip_no = int(d[8:], 10) - except ValueError as e: - print("Error: %s" % str(e)) - if gpiochip_no > 255: - self.GPIO_OFFSET = 256 - return True - return True - - def update_gpio_base(self): - self.ABS_GPIO_BASE_0_15 = 240 + self.GPIO_OFFSET - self.ABS_GPIO_BASE_16_31 = 224 + self.GPIO_OFFSET - self.LP_MODE_GPIO_BASE_0_15 = 176 + self.GPIO_OFFSET - self.LP_MODE_GPIO_BASE_16_31 = 160 + self.GPIO_OFFSET - self.RST_GPIO_BASE_0_15 = 144 + self.GPIO_OFFSET - self.RST_GPIO_BASE_16_31 = 128 + self.GPIO_OFFSET - return True - - def __init__(self): - # Update abs, lpmode, and reset gpio base - self.set_gpio_offset() - self.update_gpio_base() - - # Override port_to_eeprom_mapping for class initialization - eeprom_path = '/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom' - for x in range(self.port_start, self.port_end + 1): - port_eeprom_path = eeprom_path.format(x + self.EEPROM_OFFSET) - self.port_to_eeprom_mapping[x] = port_eeprom_path - - SfpUtilBase.__init__(self) - - def get_presence(self, port_num): - # Check for invalid port_num - if port_num < self.port_start or port_num > self.port_end: - return False - - # open corrsponding gpio file - try: - if port_num <= 15: - gpio_base = self.ABS_GPIO_BASE_0_15 - else: - gpio_base = self.ABS_GPIO_BASE_16_31 - gpio_index = gpio_base + (port_num % 16) - gpio_file_path = self.GPIO_VAL_PATH.format(gpio_index) - gpio_file = open(gpio_file_path) - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - # content is a string containing the gpio value - gpio_val = int(gpio_file.readline().rstrip()) - gpio_file.close() - - # the gpio pin is ACTIVE_LOW but reversed - if gpio_val == 0: - return False - - return True - - 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 - - # open corrsponding gpio file - try: - if port_num <= 15: - gpio_base = self.LP_MODE_GPIO_BASE_0_15 - else: - gpio_base = self.LP_MODE_GPIO_BASE_16_31 - gpio_index = gpio_base + (port_num % 16) - gpio_file_path = self.GPIO_VAL_PATH.format(gpio_index) - gpio_file = open(gpio_file_path) - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - # content is a string containing the gpio value - gpio_val = int(gpio_file.readline().rstrip()) - gpio_file.close() - - if gpio_val == 0: - return False - - return True - - 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 - - # open corrsponding gpio file - try: - if port_num <= 15: - gpio_base = self.LP_MODE_GPIO_BASE_0_15 - else: - gpio_base = self.LP_MODE_GPIO_BASE_16_31 - gpio_index = gpio_base + (port_num % 16) - gpio_file_path = self.GPIO_VAL_PATH.format(gpio_index) - gpio_file = open(gpio_file_path, "r+") - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - # the gpio pin is ACTIVE_HIGH - if lpmode is True: - gpio_val = "1" - else: - gpio_val = "0" - - # write value to gpio - gpio_file.seek(0) - gpio_file.write(gpio_val) - gpio_file.close() - - return True - - def reset(self, port_num): - # Check for invalid port_num - if port_num < self.port_start or port_num > self.port_end: - return False - - # open corrsponding gpio file - try: - if port_num <= 15: - gpio_base = self.RST_GPIO_BASE_0_15 - else: - gpio_base = self.RST_GPIO_BASE_16_31 - gpio_index = gpio_base + (port_num % 16) - gpio_file_path = self.GPIO_VAL_PATH.format(gpio_index) - gpio_file = open(gpio_file_path, "w") - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - # set the gpio to take port into reset - # the gpio pin is ACTIVE_LOW but reversed - gpio_val = "1" - # write value to gpio - gpio_file.seek(0) - gpio_file.write(gpio_val) - gpio_file.close() - - # Sleep 1 second to let it settle - time.sleep(1) - - # open corrsponding gpio file - try: - gpio_file = open(gpio_file_path, "w") - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - # set gpio back low to take port out of reset - # the gpio pin is ACTIVE_LOW but reversed - gpio_val = "0" - # write value to gpio - gpio_file.seek(0) - gpio_file.write(gpio_val) - gpio_file.close() - - return True - - def get_transceiver_change_event(self, timeout=0): - raise NotImplementedError diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/sensors.conf b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/sensors.conf deleted file mode 100644 index 9b55f73af2a..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/sensors.conf +++ /dev/null @@ -1,69 +0,0 @@ -# libsensors configuration file -chip "i350bb-*" - ignore loc1 - -chip "jc42-*" - -bus "i2c-8" "i2c-mux-0 (chan_id 7)" -chip "w83795adg-*" - label in0 "0.9V" - set in0_max 0.945 - set in0_min 0.855 - label in1 "VDD_CORE" - set in1_max 0.945 - set in1_min 0.855 - label in2 "1.2V" - set in2_max 1.26 - set in2_min 1.14 - label in3 "1.8V" - set in3_max 1.89 - set in3_min 1.71 - label in4 "1.01V" - set in4_max 1.0605 - set in4_min 0.9595 - ignore in5 - ignore in6 - ignore in7 - ignore in11 - label in12 "3.3VDD" - set in12_max 3.465 - set in12_min 3.135 - # in12 and in13 are the same source - ignore in13 - label fan1 "FANTRAY 1-A" - label fan2 "FANTRAY 1-B" - label fan3 "FANTRAY 2-A" - label fan4 "FANTRAY 2-B" - label fan5 "FANTRAY 3-A" - label fan6 "FANTRAY 3-B" - label fan7 "FANTRAY 4-A" - label fan8 "FANTRAY 4-B" - ignore temp1 - ignore temp2 - ignore temp3 - ignore temp4 - ignore temp5 - ignore temp6 - ignore intrusion0 - -chip "tmp75-i2c-*-4A" - label temp1 "BMC board Temp" - set temp1_max 50 - set temp1_max_hyst 45 - -bus "i2c-0" "i2c-main" -chip "tmp75-i2c-*-4F" - label temp1 "x86 CPU board Temp" - set temp1_max 50 - set temp1_max_hyst 45 - -bus "i2c-12" "i2c-mux-1 (chan_id 3)" -chip "tmp75-i2c-*-4C" - label temp1 "rear MAC Temp" - set temp1_max 50 - set temp1_max_hyst 45 - -chip "tmp75-i2c-*-49" - label temp1 "front MAC Temp" - set temp1_max 50 - set temp1_max_hyst 45 diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/buffers.json.j2 b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/buffers.json.j2 deleted file mode 100644 index 9354b7ec5b5..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/buffers.json.j2 +++ /dev/null @@ -1,2 +0,0 @@ -{%- set default_topo = 't0' %} -{%- include 'buffers_config.j2' %} \ No newline at end of file diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/buffers_defaults_t0.j2 b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/buffers_defaults_t0.j2 deleted file mode 100644 index c7f65ffd2a1..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/buffers_defaults_t0.j2 +++ /dev/null @@ -1,69 +0,0 @@ -{% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '20971328' %} -{% set ingress_lossy_pool_size = '20971328' %} -{% set egress_lossless_pool_size = '20971328' %} -{% set egress_lossy_pool_size = '20971328' %} - -{%- macro generate_port_lists(PORT_ALL) %} - {# Generate list of ports #} - {%- for port_idx in range(0, 64) %} - {%- if PORT_ALL.append("Ethernet%d" % (port_idx*4)) %}{%- endif %} - {%- endfor %} -{%- endmacro %} - -{%- macro generate_buffer_pool_and_profiles() %} - "BUFFER_POOL": { - "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", - "type": "ingress", - "mode": "dynamic" - }, - "ingress_lossy_pool": { - "size": "{{ ingress_lossy_pool_size }}", - "type": "ingress", - "mode": "dynamic" - }, - "egress_lossless_pool": { - "size": "{{ egress_lossless_pool_size }}", - "type": "egress", - "mode": "dynamic" - }, - "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", - "type": "egress", - "mode": "dynamic" - } - }, - "BUFFER_PROFILE": { - "ingress_lossless_profile": { - "pool":"ingress_lossless_pool", - "xon":"78400", - "xoff":"132160", - "size":"3584", - "static_th":"82880" - }, - "ingress_lossy_profile": { - "pool":"ingress_lossy_pool", - "size":"3584", - "dynamic_th":"-1" - }, - "egress_lossy_profile": { - "pool":"egress_lossy_pool", - "size":"3584", - "dynamic_th":"-4" - } - }, -{%- endmacro %} - -{# the typo of generate_pg_profils dued to buffers_config.j2 #} -{# Default, we do not bind any buffer profiles. #} -{%- macro generate_pg_profils(port_names) %} - "BUFFER_PG": { - } -{%- endmacro %} - -{# Default, we do not bind any buffer profiles. #} -{%- macro generate_queue_buffers(port_names) %} - "BUFFER_QUEUE": { - } -{%- endmacro %} \ No newline at end of file diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/buffers_defaults_t1.j2 b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/buffers_defaults_t1.j2 deleted file mode 100644 index c7f65ffd2a1..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/buffers_defaults_t1.j2 +++ /dev/null @@ -1,69 +0,0 @@ -{% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '20971328' %} -{% set ingress_lossy_pool_size = '20971328' %} -{% set egress_lossless_pool_size = '20971328' %} -{% set egress_lossy_pool_size = '20971328' %} - -{%- macro generate_port_lists(PORT_ALL) %} - {# Generate list of ports #} - {%- for port_idx in range(0, 64) %} - {%- if PORT_ALL.append("Ethernet%d" % (port_idx*4)) %}{%- endif %} - {%- endfor %} -{%- endmacro %} - -{%- macro generate_buffer_pool_and_profiles() %} - "BUFFER_POOL": { - "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", - "type": "ingress", - "mode": "dynamic" - }, - "ingress_lossy_pool": { - "size": "{{ ingress_lossy_pool_size }}", - "type": "ingress", - "mode": "dynamic" - }, - "egress_lossless_pool": { - "size": "{{ egress_lossless_pool_size }}", - "type": "egress", - "mode": "dynamic" - }, - "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", - "type": "egress", - "mode": "dynamic" - } - }, - "BUFFER_PROFILE": { - "ingress_lossless_profile": { - "pool":"ingress_lossless_pool", - "xon":"78400", - "xoff":"132160", - "size":"3584", - "static_th":"82880" - }, - "ingress_lossy_profile": { - "pool":"ingress_lossy_pool", - "size":"3584", - "dynamic_th":"-1" - }, - "egress_lossy_profile": { - "pool":"egress_lossy_pool", - "size":"3584", - "dynamic_th":"-4" - } - }, -{%- endmacro %} - -{# the typo of generate_pg_profils dued to buffers_config.j2 #} -{# Default, we do not bind any buffer profiles. #} -{%- macro generate_pg_profils(port_names) %} - "BUFFER_PG": { - } -{%- endmacro %} - -{# Default, we do not bind any buffer profiles. #} -{%- macro generate_queue_buffers(port_names) %} - "BUFFER_QUEUE": { - } -{%- endmacro %} \ No newline at end of file diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/pg_profile_lookup.ini b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/pg_profile_lookup.ini deleted file mode 100644 index d98b0eca6d1..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/pg_profile_lookup.ini +++ /dev/null @@ -1,17 +0,0 @@ -# PG lossless profiles. -# speed cable size xon xoff threshold - 10000 5m 3584 32256 59136 36736 - 25000 5m 3584 41216 68096 45696 - 40000 5m 3584 47488 74368 51968 - 50000 5m 3584 52864 79744 57344 - 100000 5m 3584 78400 132160 82880 - 10000 40m 3584 32256 59136 36736 - 25000 40m 3584 41216 68096 45696 - 40000 40m 3584 47488 74368 51968 - 50000 40m 3584 52864 79744 57344 - 100000 40m 3584 78400 132160 82880 - 10000 300m 3584 32256 65856 36736 - 25000 300m 3584 41216 84672 45696 - 40000 300m 3584 47488 101024 51968 - 50000 300m 3584 52864 113120 57344 - 100000 300m 3584 78400 198688 82880 \ No newline at end of file diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/port_config.ini b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/port_config.ini deleted file mode 100644 index d57c1f35018..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/port_config.ini +++ /dev/null @@ -1,65 +0,0 @@ -# name lanes alias index -Ethernet0 0,1,2,3 Ethernet1/1 0 -Ethernet4 4,5,6,7 Ethernet2/1 1 -Ethernet8 20,21,22,23 Ethernet3/1 2 -Ethernet12 16,17,18,19 Ethernet4/1 3 -Ethernet16 36,37,38,39 Ethernet5/1 4 -Ethernet20 32,33,34,35 Ethernet6/1 5 -Ethernet24 52,53,54,55 Ethernet7/1 6 -Ethernet28 48,49,50,51 Ethernet8/1 7 -Ethernet32 68,69,70,71 Ethernet9/1 8 -Ethernet36 64,65,66,67 Ethernet10/1 9 -Ethernet40 84,85,86,87 Ethernet11/1 10 -Ethernet44 80,81,82,83 Ethernet12/1 11 -Ethernet48 100,101,102,103 Ethernet13/1 12 -Ethernet52 96,97,98,99 Ethernet14/1 13 -Ethernet56 116,117,118,119 Ethernet15/1 14 -Ethernet60 112,113,114,115 Ethernet16/1 15 -Ethernet64 132,133,134,135 Ethernet17/1 16 -Ethernet68 128,129,130,131 Ethernet18/1 17 -Ethernet72 148,149,150,151 Ethernet19/1 18 -Ethernet76 144,145,146,147 Ethernet20/1 19 -Ethernet80 164,165,166,167 Ethernet21/1 20 -Ethernet84 160,161,162,163 Ethernet22/1 21 -Ethernet88 180,181,182,183 Ethernet23/1 22 -Ethernet92 176,177,178,179 Ethernet24/1 23 -Ethernet96 196,197,198,199 Ethernet25/1 24 -Ethernet100 192,193,194,195 Ethernet26/1 25 -Ethernet104 212,213,214,215 Ethernet27/1 26 -Ethernet108 208,209,210,211 Ethernet28/1 27 -Ethernet112 228,229,230,231 Ethernet29/1 28 -Ethernet116 224,225,226,227 Ethernet30/1 29 -Ethernet120 244,245,246,247 Ethernet31/1 30 -Ethernet124 240,241,242,243 Ethernet32/1 31 -Ethernet128 12,13,14,15 Ethernet33/1 32 -Ethernet132 8,9,10,11 Ethernet34/1 33 -Ethernet136 28,29,30,31 Ethernet35/1 34 -Ethernet140 24,25,26,27 Ethernet36/1 35 -Ethernet144 44,45,46,47 Ethernet37/1 36 -Ethernet148 40,41,42,43 Ethernet38/1 37 -Ethernet152 60,61,62,63 Ethernet39/1 38 -Ethernet156 56,57,58,59 Ethernet40/1 39 -Ethernet160 76,77,78,79 Ethernet41/1 40 -Ethernet164 72,73,74,75 Ethernet42/1 41 -Ethernet168 92,93,94,95 Ethernet43/1 42 -Ethernet172 88,89,90,91 Ethernet44/1 43 -Ethernet176 108,109,110,111 Ethernet45/1 44 -Ethernet180 104,105,106,107 Ethernet46/1 45 -Ethernet184 124,125,126,127 Ethernet47/1 46 -Ethernet188 120,121,122,123 Ethernet48/1 47 -Ethernet192 140,141,142,143 Ethernet49/1 48 -Ethernet196 136,137,138,139 Ethernet50/1 49 -Ethernet200 156,157,158,159 Ethernet51/1 50 -Ethernet204 152,153,154,155 Ethernet52/1 51 -Ethernet208 172,173,174,175 Ethernet53/1 52 -Ethernet212 168,169,170,171 Ethernet54/1 53 -Ethernet216 188,189,190,191 Ethernet55/1 54 -Ethernet220 184,185,186,187 Ethernet56/1 55 -Ethernet224 204,205,206,207 Ethernet57/1 56 -Ethernet228 200,201,202,203 Ethernet58/1 57 -Ethernet232 220,221,222,223 Ethernet59/1 58 -Ethernet236 216,217,218,219 Ethernet60/1 59 -Ethernet240 236,237,238,239 Ethernet61/1 60 -Ethernet244 232,233,234,235 Ethernet62/1 61 -Ethernet248 248,249,250,251 Ethernet63/1 62 -Ethernet252 252,253,254,255 Ethernet64/1 63 \ No newline at end of file diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/port_config.nps b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/port_config.nps deleted file mode 100644 index 4f89209537f..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/port_config.nps +++ /dev/null @@ -1,682 +0,0 @@ -init start stage low-level -init set port-map port=0 eth-macro=0 lane=0 max-speed=100g active=true -init set port-map port=1 eth-macro=1 lane=0 max-speed=100g active=true -init set port-map port=2 eth-macro=5 lane=0 max-speed=100g active=true -init set port-map port=3 eth-macro=4 lane=0 max-speed=100g active=true -init set port-map port=4 eth-macro=9 lane=0 max-speed=100g active=true -init set port-map port=5 eth-macro=8 lane=0 max-speed=100g active=true -init set port-map port=6 eth-macro=13 lane=0 max-speed=100g active=true -init set port-map port=7 eth-macro=12 lane=0 max-speed=100g active=true -init set port-map port=8 eth-macro=17 lane=0 max-speed=100g active=true -init set port-map port=9 eth-macro=16 lane=0 max-speed=100g active=true -init set port-map port=10 eth-macro=21 lane=0 max-speed=100g active=true -init set port-map port=11 eth-macro=20 lane=0 max-speed=100g active=true -init set port-map port=12 eth-macro=25 lane=0 max-speed=100g active=true -init set port-map port=13 eth-macro=24 lane=0 max-speed=100g active=true -init set port-map port=14 eth-macro=29 lane=0 max-speed=100g active=true -init set port-map port=15 eth-macro=28 lane=0 max-speed=100g active=true -init set port-map port=16 eth-macro=33 lane=0 max-speed=100g active=true -init set port-map port=17 eth-macro=32 lane=0 max-speed=100g active=true -init set port-map port=18 eth-macro=37 lane=0 max-speed=100g active=true -init set port-map port=19 eth-macro=36 lane=0 max-speed=100g active=true -init set port-map port=20 eth-macro=41 lane=0 max-speed=100g active=true -init set port-map port=21 eth-macro=40 lane=0 max-speed=100g active=true -init set port-map port=22 eth-macro=45 lane=0 max-speed=100g active=true -init set port-map port=23 eth-macro=44 lane=0 max-speed=100g active=true -init set port-map port=24 eth-macro=49 lane=0 max-speed=100g active=true -init set port-map port=25 eth-macro=48 lane=0 max-speed=100g active=true -init set port-map port=26 eth-macro=53 lane=0 max-speed=100g active=true -init set port-map port=27 eth-macro=52 lane=0 max-speed=100g active=true -init set port-map port=28 eth-macro=57 lane=0 max-speed=100g active=true -init set port-map port=29 eth-macro=56 lane=0 max-speed=100g active=true -init set port-map port=30 eth-macro=61 lane=0 max-speed=100g active=true -init set port-map port=31 eth-macro=60 lane=0 max-speed=100g active=true -init set port-map port=32 eth-macro=3 lane=0 max-speed=100g active=true -init set port-map port=33 eth-macro=2 lane=0 max-speed=100g active=true -init set port-map port=34 eth-macro=7 lane=0 max-speed=100g active=true -init set port-map port=35 eth-macro=6 lane=0 max-speed=100g active=true -init set port-map port=36 eth-macro=11 lane=0 max-speed=100g active=true -init set port-map port=37 eth-macro=10 lane=0 max-speed=100g active=true -init set port-map port=38 eth-macro=15 lane=0 max-speed=100g active=true -init set port-map port=39 eth-macro=14 lane=0 max-speed=100g active=true -init set port-map port=40 eth-macro=19 lane=0 max-speed=100g active=true -init set port-map port=41 eth-macro=18 lane=0 max-speed=100g active=true -init set port-map port=42 eth-macro=23 lane=0 max-speed=100g active=true -init set port-map port=43 eth-macro=22 lane=0 max-speed=100g active=true -init set port-map port=44 eth-macro=27 lane=0 max-speed=100g active=true -init set port-map port=45 eth-macro=26 lane=0 max-speed=100g active=true -init set port-map port=46 eth-macro=31 lane=0 max-speed=100g active=true -init set port-map port=47 eth-macro=30 lane=0 max-speed=100g active=true -init set port-map port=48 eth-macro=35 lane=0 max-speed=100g active=true -init set port-map port=49 eth-macro=34 lane=0 max-speed=100g active=true -init set port-map port=50 eth-macro=39 lane=0 max-speed=100g active=true -init set port-map port=51 eth-macro=38 lane=0 max-speed=100g active=true -init set port-map port=52 eth-macro=43 lane=0 max-speed=100g active=true -init set port-map port=53 eth-macro=42 lane=0 max-speed=100g active=true -init set port-map port=54 eth-macro=47 lane=0 max-speed=100g active=true -init set port-map port=55 eth-macro=46 lane=0 max-speed=100g active=true -init set port-map port=56 eth-macro=51 lane=0 max-speed=100g active=true -init set port-map port=57 eth-macro=50 lane=0 max-speed=100g active=true -init set port-map port=58 eth-macro=55 lane=0 max-speed=100g active=true -init set port-map port=59 eth-macro=54 lane=0 max-speed=100g active=true -init set port-map port=60 eth-macro=59 lane=0 max-speed=100g active=true -init set port-map port=61 eth-macro=58 lane=0 max-speed=100g active=true -init set port-map port=62 eth-macro=62 lane=0 max-speed=100g active=true -init set port-map port=63 eth-macro=63 lane=0 max-speed=100g active=true -init set port-map port=129 eth-macro=0 lane=1 max-speed=10g active=true guarantee=true cpi=true -init set port-map port=130 eth-macro=0 lane=0 max-speed=10g active=true guarantee=true cpi=true init-done=true - -init start stage task-rsrc -init start stage module -init start stage task - -phy set lane-swap portlist=0 lane-cnt=4 property=tx data=0x3.2.0.1 -phy set lane-swap portlist=1 lane-cnt=4 property=tx data=0x2.1.3.0 -phy set lane-swap portlist=2 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=3 lane-cnt=4 property=tx data=0x2.3.0.1 -phy set lane-swap portlist=4 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=5 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=6 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=7 lane-cnt=4 property=tx data=0x1.0.2.3 -phy set lane-swap portlist=8 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=9 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=10 lane-cnt=4 property=tx data=0x0.3.2.1 -phy set lane-swap portlist=11 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=12 lane-cnt=4 property=tx data=0x3.2.0.1 -phy set lane-swap portlist=13 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap portlist=14 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=15 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=16 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=17 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=18 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=19 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=20 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=21 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=22 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=23 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=24 lane-cnt=4 property=tx data=0x0.3.2.1 -phy set lane-swap portlist=25 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=26 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=27 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=28 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=29 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=30 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=31 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=32 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=33 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=34 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=35 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=36 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=37 lane-cnt=4 property=tx data=0x3.1.0.2 -phy set lane-swap portlist=38 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=39 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=40 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=41 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=42 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=43 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=44 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap portlist=45 lane-cnt=4 property=tx data=0x3.2.1.0 -phy set lane-swap portlist=46 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=47 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=48 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=49 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=50 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=51 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=52 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=53 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=54 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=55 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=56 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=57 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=58 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=59 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=60 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=61 lane-cnt=4 property=tx data=0x0.1.2.3 -phy set lane-swap portlist=62 lane-cnt=4 property=tx data=0x1.0.2.3 -phy set lane-swap portlist=63 lane-cnt=4 property=tx data=0x3.1.0.2 -phy set lane-swap portlist=129 lane-cnt=1 property=tx data=0x1 -phy set lane-swap portlist=130 lane-cnt=1 property=tx data=0x0 -phy set lane-swap portlist=0 lane-cnt=4 property=rx data=0x2.0.3.1 -phy set lane-swap portlist=1 lane-cnt=4 property=rx data=0x1.3.0.2 -phy set lane-swap portlist=2 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=3 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=4 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=5 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=6 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=7 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=8 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=9 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=10 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=11 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=12 lane-cnt=4 property=rx data=0x3.2.1.0 -phy set lane-swap portlist=13 lane-cnt=4 property=rx data=0x3.2.1.0 -phy set lane-swap portlist=14 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=15 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=16 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=17 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=18 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=19 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=20 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=21 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=22 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=23 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=24 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=25 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=26 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=27 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=28 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=29 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=30 lane-cnt=4 property=rx data=0x0.2.1.3 -phy set lane-swap portlist=31 lane-cnt=4 property=rx data=0x0.2.1.3 -phy set lane-swap portlist=32 lane-cnt=4 property=rx data=0x0.2.1.3 -phy set lane-swap portlist=33 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=34 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=35 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=36 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=37 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=38 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=39 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=40 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=41 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=42 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=43 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=44 lane-cnt=4 property=rx data=0x3.2.1.0 -phy set lane-swap portlist=45 lane-cnt=4 property=rx data=0x3.2.1.0 -phy set lane-swap portlist=46 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=47 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=48 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=49 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=50 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=51 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=52 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=53 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=54 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=55 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=56 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=57 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=58 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=59 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=60 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=61 lane-cnt=4 property=rx data=0x0.1.2.3 -phy set lane-swap portlist=62 lane-cnt=4 property=rx data=0x1.3.0.2 -phy set lane-swap portlist=63 lane-cnt=4 property=rx data=0x3.1.2.0 -phy set lane-swap portlist=129 lane-cnt=1 property=rx data=0x1 -phy set lane-swap portlist=130 lane-cnt=1 property=rx data=0x0 - -phy set polarity-rev portlist=0 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=1 lane-cnt=4 property=tx data=0x0.1.0.0 -phy set polarity-rev portlist=2 lane-cnt=4 property=tx data=0x1.0.0.1 -phy set polarity-rev portlist=3 lane-cnt=4 property=tx data=0x1.1.1.1 -phy set polarity-rev portlist=4 lane-cnt=4 property=tx data=0x0.1.0.1 -phy set polarity-rev portlist=5 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=6 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=7 lane-cnt=4 property=tx data=0x1.0.0.0 -phy set polarity-rev portlist=8 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=9 lane-cnt=4 property=tx data=0x0.1.0.0 -phy set polarity-rev portlist=10 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=11 lane-cnt=4 property=tx data=0x0.1.0.0 -phy set polarity-rev portlist=12 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=13 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=14 lane-cnt=4 property=tx data=0x1.0.0.0 -phy set polarity-rev portlist=15 lane-cnt=4 property=tx data=0x0.1.0.0 -phy set polarity-rev portlist=16 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=17 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=18 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=19 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=20 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=21 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=22 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=23 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=24 lane-cnt=4 property=tx data=0x0.0.1.0 -phy set polarity-rev portlist=25 lane-cnt=4 property=tx data=0x1.0.0.1 -phy set polarity-rev portlist=26 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=27 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=28 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=29 lane-cnt=4 property=tx data=0x0.1.0.0 -phy set polarity-rev portlist=30 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=31 lane-cnt=4 property=tx data=0x0.0.1.0 -phy set polarity-rev portlist=32 lane-cnt=4 property=tx data=0x0.1.1.1 -phy set polarity-rev portlist=33 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=34 lane-cnt=4 property=tx data=0x0.1.1.1 -phy set polarity-rev portlist=35 lane-cnt=4 property=tx data=0x1.0.0.0 -phy set polarity-rev portlist=36 lane-cnt=4 property=tx data=0x0.0.1.1 -phy set polarity-rev portlist=37 lane-cnt=4 property=tx data=0x0.0.0.1 -phy set polarity-rev portlist=38 lane-cnt=4 property=tx data=0x0.1.1.0 -phy set polarity-rev portlist=39 lane-cnt=4 property=tx data=0x1.0.1.0 -phy set polarity-rev portlist=40 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=41 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=42 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=43 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=44 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=45 lane-cnt=4 property=tx data=0x0.0.1.0 -phy set polarity-rev portlist=46 lane-cnt=4 property=tx data=0x0.0.0.1 -phy set polarity-rev portlist=47 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=48 lane-cnt=4 property=tx data=0x0.0.1.1 -phy set polarity-rev portlist=49 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=50 lane-cnt=4 property=tx data=0x0.0.1.1 -phy set polarity-rev portlist=51 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=52 lane-cnt=4 property=tx data=0x0.0.1.1 -phy set polarity-rev portlist=53 lane-cnt=4 property=tx data=0x0.0.1.0 -phy set polarity-rev portlist=54 lane-cnt=4 property=tx data=0x0.0.1.1 -phy set polarity-rev portlist=55 lane-cnt=4 property=tx data=0x0.0.1.1 -phy set polarity-rev portlist=56 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=57 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=58 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=59 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=60 lane-cnt=4 property=tx data=0x0.1.0.1 -phy set polarity-rev portlist=61 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=62 lane-cnt=4 property=tx data=0x0.0.0.0 -phy set polarity-rev portlist=63 lane-cnt=4 property=tx data=0x0.0.1.0 -phy set polarity-rev portlist=129 lane-cnt=1 property=tx data=0x0 -phy set polarity-rev portlist=130 lane-cnt=1 property=tx data=0x0 - -phy set polarity-rev portlist=0 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=1 lane-cnt=4 property=rx data=0x1.0.0.0 -phy set polarity-rev portlist=2 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=3 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=4 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=5 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=6 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=7 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=8 lane-cnt=4 property=rx data=0x0.0.0.1 -phy set polarity-rev portlist=9 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=10 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=11 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=12 lane-cnt=4 property=rx data=0x1.0.0.0 -phy set polarity-rev portlist=13 lane-cnt=4 property=rx data=0x0.0.1.0 -phy set polarity-rev portlist=14 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=15 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=16 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=17 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=18 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=19 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=20 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=21 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=22 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=23 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=24 lane-cnt=4 property=rx data=0x0.0.0.1 -phy set polarity-rev portlist=25 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=26 lane-cnt=4 property=rx data=0x0.0.0.1 -phy set polarity-rev portlist=27 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=28 lane-cnt=4 property=rx data=0x0.0.0.1 -phy set polarity-rev portlist=29 lane-cnt=4 property=rx data=0x1.0.1.0 -phy set polarity-rev portlist=30 lane-cnt=4 property=rx data=0x0.0.1.0 -phy set polarity-rev portlist=31 lane-cnt=4 property=rx data=0x1.1.0.0 -phy set polarity-rev portlist=32 lane-cnt=4 property=rx data=0x0.1.1.1 -phy set polarity-rev portlist=33 lane-cnt=4 property=rx data=0x1.1.1.0 -phy set polarity-rev portlist=34 lane-cnt=4 property=rx data=0x0.0.1.1 -phy set polarity-rev portlist=35 lane-cnt=4 property=rx data=0x0.0.1.0 -phy set polarity-rev portlist=36 lane-cnt=4 property=rx data=0x0.0.0.1 -phy set polarity-rev portlist=37 lane-cnt=4 property=rx data=0x0.0.0.1 -phy set polarity-rev portlist=38 lane-cnt=4 property=rx data=0x0.0.0.1 -phy set polarity-rev portlist=39 lane-cnt=4 property=rx data=0x0.0.0.1 -phy set polarity-rev portlist=40 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=41 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=42 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=43 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=44 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=45 lane-cnt=4 property=rx data=0x0.1.0.1 -phy set polarity-rev portlist=46 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=47 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=48 lane-cnt=4 property=rx data=0x0.0.0.1 -phy set polarity-rev portlist=49 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=50 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=51 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=52 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=53 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=54 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=55 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=56 lane-cnt=4 property=rx data=0x0.1.0.0 -phy set polarity-rev portlist=57 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=58 lane-cnt=4 property=rx data=0x0.1.0.0 -phy set polarity-rev portlist=59 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=60 lane-cnt=4 property=rx data=0x0.0.0.1 -phy set polarity-rev portlist=61 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=62 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=63 lane-cnt=4 property=rx data=0x0.0.0.0 -phy set polarity-rev portlist=129 lane-cnt=1 property=rx data=0x0 -phy set polarity-rev portlist=130 lane-cnt=1 property=rx data=0x0 - -phy set pre-emphasis portlist=0 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=0 lane-cnt=4 property=c1 data=0x09.09.09.09 -phy set pre-emphasis portlist=0 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=0 lane-cnt=4 property=c0 data=0x19.19.18.19 -phy set pre-emphasis portlist=1 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=1 lane-cnt=4 property=c1 data=0x09.09.09.09 -phy set pre-emphasis portlist=1 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=1 lane-cnt=4 property=c0 data=0x19.18.19.19 -phy set pre-emphasis portlist=2 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=2 lane-cnt=4 property=c1 data=0x08.08.09.09 -phy set pre-emphasis portlist=2 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=2 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=3 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=3 lane-cnt=4 property=c1 data=0x08.08.09.08 -phy set pre-emphasis portlist=3 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=3 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=4 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=4 lane-cnt=4 property=c1 data=0x06.07.07.08 -phy set pre-emphasis portlist=4 lane-cnt=4 property=cn1 data=0x03.02.02.02 -phy set pre-emphasis portlist=4 lane-cnt=4 property=c0 data=0x19.19.18.19 -phy set pre-emphasis portlist=5 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=5 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis portlist=5 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=5 lane-cnt=4 property=c0 data=0x19.19.18.18 -phy set pre-emphasis portlist=6 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=6 lane-cnt=4 property=c1 data=0x06.06.06.07 -phy set pre-emphasis portlist=6 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=6 lane-cnt=4 property=c0 data=0x18.18.18.18 -phy set pre-emphasis portlist=7 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=7 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis portlist=7 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=7 lane-cnt=4 property=c0 data=0x18.18.18.18 -phy set pre-emphasis portlist=8 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=8 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis portlist=8 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=8 lane-cnt=4 property=c0 data=0x18.18.18.18 -phy set pre-emphasis portlist=9 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=9 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis portlist=9 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=9 lane-cnt=4 property=c0 data=0x17.17.17.17 -phy set pre-emphasis portlist=10 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=10 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=10 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=10 lane-cnt=4 property=c0 data=0x16.17.17.17 -phy set pre-emphasis portlist=11 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=11 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=11 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=11 lane-cnt=4 property=c0 data=0x17.17.17.17 -phy set pre-emphasis portlist=12 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=12 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=12 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=12 lane-cnt=4 property=c0 data=0x17.17.17.17 -phy set pre-emphasis portlist=13 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=13 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=13 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=13 lane-cnt=4 property=c0 data=0x17.17.17.17 -phy set pre-emphasis portlist=14 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=14 lane-cnt=4 property=c1 data=0x04.05.04.05 -phy set pre-emphasis portlist=14 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=14 lane-cnt=4 property=c0 data=0x18.17.18.17 -phy set pre-emphasis portlist=15 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=15 lane-cnt=4 property=c1 data=0x06.05.06.06 -phy set pre-emphasis portlist=15 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=15 lane-cnt=4 property=c0 data=0x16.17.16.16 -phy set pre-emphasis portlist=16 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=16 lane-cnt=4 property=c1 data=0x05.06.06.06 -phy set pre-emphasis portlist=16 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=16 lane-cnt=4 property=c0 data=0x17.18.18.16 -phy set pre-emphasis portlist=17 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=17 lane-cnt=4 property=c1 data=0x04.04.04.04 -phy set pre-emphasis portlist=17 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=17 lane-cnt=4 property=c0 data=0x16.16.16.16 -phy set pre-emphasis portlist=18 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=18 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=18 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=18 lane-cnt=4 property=c0 data=0x16.16.16.16 -phy set pre-emphasis portlist=19 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=19 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=19 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=19 lane-cnt=4 property=c0 data=0x16.16.16.16 -phy set pre-emphasis portlist=20 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=20 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=20 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=20 lane-cnt=4 property=c0 data=0x16.16.16.16 -phy set pre-emphasis portlist=21 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=21 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=21 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=21 lane-cnt=4 property=c0 data=0x16.16.16.16 -phy set pre-emphasis portlist=22 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=22 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis portlist=22 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=22 lane-cnt=4 property=c0 data=0x17.17.18.17 -phy set pre-emphasis portlist=23 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=23 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis portlist=23 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=23 lane-cnt=4 property=c0 data=0x17.17.17.17 -phy set pre-emphasis portlist=24 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=24 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis portlist=24 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=24 lane-cnt=4 property=c0 data=0x18.18.18.18 -phy set pre-emphasis portlist=25 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=25 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis portlist=25 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=25 lane-cnt=4 property=c0 data=0x18.18.18.18 -phy set pre-emphasis portlist=26 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=26 lane-cnt=4 property=c1 data=0x08.08.07.07 -phy set pre-emphasis portlist=26 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=26 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=27 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=27 lane-cnt=4 property=c1 data=0x08.08.08.08 -phy set pre-emphasis portlist=27 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=27 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=28 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=28 lane-cnt=4 property=c1 data=0x09.09.09.09 -phy set pre-emphasis portlist=28 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=28 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=29 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=29 lane-cnt=4 property=c1 data=0x09.09.09.09 -phy set pre-emphasis portlist=29 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=29 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=30 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=30 lane-cnt=4 property=c1 data=0x08.09.09.09 -phy set pre-emphasis portlist=30 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=30 lane-cnt=4 property=c0 data=0x18.19.19.19 -phy set pre-emphasis portlist=31 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=31 lane-cnt=4 property=c1 data=0x09.09.09.09 -phy set pre-emphasis portlist=31 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=31 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=32 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=32 lane-cnt=4 property=c1 data=0x09.09.09.09 -phy set pre-emphasis portlist=32 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=32 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=33 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=33 lane-cnt=4 property=c1 data=0x08.09.09.09 -phy set pre-emphasis portlist=33 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=33 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=34 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=34 lane-cnt=4 property=c1 data=0x08.07.08.08 -phy set pre-emphasis portlist=34 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=34 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=35 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=35 lane-cnt=4 property=c1 data=0x08.08.07.08 -phy set pre-emphasis portlist=35 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=35 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=36 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=36 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis portlist=36 lane-cnt=4 property=cn1 data=0x01.02.02.02 -phy set pre-emphasis portlist=36 lane-cnt=4 property=c0 data=0x19.18.18.18 -phy set pre-emphasis portlist=37 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=37 lane-cnt=4 property=c1 data=0x06.06.06.07 -phy set pre-emphasis portlist=37 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=37 lane-cnt=4 property=c0 data=0x18.18.18.18 -phy set pre-emphasis portlist=38 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=38 lane-cnt=4 property=c1 data=0x06.06.05.06 -phy set pre-emphasis portlist=38 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=38 lane-cnt=4 property=c0 data=0x18.18.18.18 -phy set pre-emphasis portlist=39 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=39 lane-cnt=4 property=c1 data=0x06.07.06.06 -phy set pre-emphasis portlist=39 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=39 lane-cnt=4 property=c0 data=0x18.18.18.18 -phy set pre-emphasis portlist=40 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=40 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=40 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=40 lane-cnt=4 property=c0 data=0x18.18.18.18 -phy set pre-emphasis portlist=41 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=41 lane-cnt=4 property=c1 data=0x05.06.05.05 -phy set pre-emphasis portlist=41 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=41 lane-cnt=4 property=c0 data=0x16.17.18.18 -phy set pre-emphasis portlist=42 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=42 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=42 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=42 lane-cnt=4 property=c0 data=0x17.17.17.17 -phy set pre-emphasis portlist=43 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=43 lane-cnt=4 property=c1 data=0x06.05.05.05 -phy set pre-emphasis portlist=43 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=43 lane-cnt=4 property=c0 data=0x17.17.17.17 -phy set pre-emphasis portlist=44 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=44 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=44 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=44 lane-cnt=4 property=c0 data=0x17.17.17.17 -phy set pre-emphasis portlist=45 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=45 lane-cnt=4 property=c1 data=0x05.05.04.05 -phy set pre-emphasis portlist=45 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=45 lane-cnt=4 property=c0 data=0x17.17.18.17 -phy set pre-emphasis portlist=46 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=46 lane-cnt=4 property=c1 data=0x05.05.06.06 -phy set pre-emphasis portlist=46 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=46 lane-cnt=4 property=c0 data=0x17.17.16.16 -phy set pre-emphasis portlist=47 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=47 lane-cnt=4 property=c1 data=0x05.05.06.06 -phy set pre-emphasis portlist=47 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=47 lane-cnt=4 property=c0 data=0x17.17.16.16 -phy set pre-emphasis portlist=48 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=48 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=48 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=48 lane-cnt=4 property=c0 data=0x16.16.16.16 -phy set pre-emphasis portlist=49 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=49 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=49 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=49 lane-cnt=4 property=c0 data=0x16.16.16.16 -phy set pre-emphasis portlist=50 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=50 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=50 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=50 lane-cnt=4 property=c0 data=0x16.16.16.16 -phy set pre-emphasis portlist=51 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=51 lane-cnt=4 property=c1 data=0x05.05.05.05 -phy set pre-emphasis portlist=51 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=51 lane-cnt=4 property=c0 data=0x16.16.16.16 -phy set pre-emphasis portlist=52 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=52 lane-cnt=4 property=c1 data=0x06.06.05.05 -phy set pre-emphasis portlist=52 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=52 lane-cnt=4 property=c0 data=0x16.17.17.17 -phy set pre-emphasis portlist=53 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=53 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis portlist=53 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=53 lane-cnt=4 property=c0 data=0x16.17.17.17 -phy set pre-emphasis portlist=54 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=54 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis portlist=54 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=54 lane-cnt=4 property=c0 data=0x18.18.18.18 -phy set pre-emphasis portlist=55 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=55 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis portlist=55 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=55 lane-cnt=4 property=c0 data=0x18.18.18.18 -phy set pre-emphasis portlist=56 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=56 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis portlist=56 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=56 lane-cnt=4 property=c0 data=0x18.18.18.18 -phy set pre-emphasis portlist=57 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=57 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis portlist=57 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=57 lane-cnt=4 property=c0 data=0x18.18.18.18 -phy set pre-emphasis portlist=58 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=58 lane-cnt=4 property=c1 data=0x08.08.08.08 -phy set pre-emphasis portlist=58 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=58 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=59 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=59 lane-cnt=4 property=c1 data=0x08.08.08.08 -phy set pre-emphasis portlist=59 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=59 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=60 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=60 lane-cnt=4 property=c1 data=0x09.09.09.09 -phy set pre-emphasis portlist=60 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=60 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=61 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=61 lane-cnt=4 property=c1 data=0x09.09.09.09 -phy set pre-emphasis portlist=61 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=61 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=62 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=62 lane-cnt=4 property=c1 data=0x09.09.09.09 -phy set pre-emphasis portlist=62 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=62 lane-cnt=4 property=c0 data=0x19.19.19.19 -phy set pre-emphasis portlist=63 lane-cnt=4 property=c2 data=0x00.00.00.00 -phy set pre-emphasis portlist=63 lane-cnt=4 property=c1 data=0x09.09.09.09 -phy set pre-emphasis portlist=63 lane-cnt=4 property=cn1 data=0x02.02.02.02 -phy set pre-emphasis portlist=63 lane-cnt=4 property=c0 data=0x19.19.19.19 - -phy set pre-emphasis portlist=129 lane-cnt=1 property=c2 data=0x01 -phy set pre-emphasis portlist=129 lane-cnt=1 property=cn1 data=0x01 -phy set pre-emphasis portlist=129 lane-cnt=1 property=c0 data=0x02 -phy set pre-emphasis portlist=129 lane-cnt=1 property=c1 data=0x03 -phy set pre-emphasis portlist=130 lane-cnt=1 property=c2 data=0x01 -phy set pre-emphasis portlist=130 lane-cnt=1 property=cn1 data=0x01 -phy set pre-emphasis portlist=130 lane-cnt=1 property=c0 data=0x02 -phy set pre-emphasis portlist=130 lane-cnt=1 property=c1 data=0x03 - -phy set mdio portlist=0 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=1 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=2 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=3 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=4 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=5 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=6 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=7 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=8 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=9 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=10 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=11 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=12 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=13 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=14 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=15 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=16 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=17 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=18 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=19 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=20 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=21 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=22 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=23 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=24 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=25 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=26 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=27 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=28 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=29 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=30 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=31 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=32 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=33 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=34 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=35 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=36 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=37 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=38 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=39 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=40 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=41 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=42 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=43 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=44 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=45 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=46 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=47 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=48 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=49 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=50 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=51 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=52 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=53 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=54 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=55 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=56 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=57 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=58 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=59 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=60 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=61 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=62 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=63 devad=0x1E addr=0x2 data=0x8000 -phy set mdio portlist=129 devad=0x1E addr=0x2 data=0x0000 -phy set mdio portlist=130 devad=0x1E addr=0x2 data=0x0000 - -port set property portlist=0-63 speed=100g -port set property portlist=129-130 speed=10g -port set property portlist=0-63 medium-type=sr4 -port set property portlist=129-130 medium-type=kr -port set property portlist=0-63 fec=disable -port set adver portlist=129-130 speed-10g-kr -port set property portlist=129-130 an=enable - -port set property portlist=129-130 admin=enable -port set property portlist=0-63 admin=disable diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/qos.json.j2 b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/qos.json.j2 deleted file mode 100644 index 42eef17c362..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/qos.json.j2 +++ /dev/null @@ -1,136 +0,0 @@ -{ - "TC_TO_PRIORITY_GROUP_MAP": { - "AZURE": { - "0": "1", - "1": "0", - "3": "3", - "4": "4" - } - }, - "MAP_PFC_PRIORITY_TO_QUEUE": { - "AZURE": { - "3": "3", - "4": "4" - } - }, - "TC_TO_QUEUE_MAP": { - "AZURE": { - "0": "1", - "1": "0", - "3": "3", - "4": "4" - } - }, - "DSCP_TO_TC_MAP": { - "AZURE": { - "0":"1", - "1":"0", - "2":"0", - "3":"3", - "4":"4", - "5":"0", - "6":"0", - "7":"0", - "8":"1", - "9":"0", - "10":"0", - "11":"0", - "12":"0", - "13":"0", - "14":"0", - "15":"0", - "16":"0", - "17":"0", - "18":"0", - "19":"0", - "20":"0", - "21":"0", - "22":"0", - "23":"0", - "24":"0", - "25":"0", - "26":"0", - "27":"0", - "28":"0", - "29":"0", - "30":"0", - "31":"0", - "32":"0", - "33":"0", - "34":"0", - "35":"0", - "36":"0", - "37":"0", - "38":"0", - "39":"0", - "40":"0", - "41":"0", - "42":"0", - "43":"0", - "44":"0", - "45":"0", - "46":"0", - "47":"0", - "48":"0", - "49":"0", - "50":"0", - "51":"0", - "52":"0", - "53":"0", - "54":"0", - "55":"0", - "56":"0", - "57":"0", - "58":"0", - "59":"0", - "60":"0", - "61":"0", - "62":"0", - "63":"0" - } - }, - "SCHEDULER": { - "scheduler.0" : { - "type":"DWRR", - "weight": "25" - }, - "scheduler.1" : { - "type":"DWRR", - "weight": "30" - }, - "scheduler.2" : { - "type":"DWRR", - "weight": "20" - } - }, - "PORT_QOS_MAP": { - }, - "WRED_PROFILE": { - "AZURE_LOSSY" : { - "wred_green_enable":"true", - "wred_yellow_enable":"true", - "wred_red_enable":"true", - "ecn":"ecn_all", - "red_max_threshold":"516096", - "red_min_threshold":"516096", - "yellow_max_threshold":"516096", - "yellow_min_threshold":"516096", - "green_max_threshold": "184128", - "green_min_threshold": "184128" - }, - "AZURE_LOSSLESS" : { - "wred_green_enable":"true", - "wred_yellow_enable":"true", - "wred_red_enable":"true", - "ecn":"ecn_all", - "red_max_threshold":"516096", - "red_min_threshold":"516096", - "yellow_max_threshold":"516096", - "yellow_min_threshold":"516096", - "green_max_threshold": "184128", - "green_min_threshold": "184128" - } - }, - "QUEUE": { - } -} diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/sai.profile b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/sai.profile deleted file mode 100644 index 880f47910ac..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/INGRASYS-S9230-64X/sai.profile +++ /dev/null @@ -1,2 +0,0 @@ -SAI_INIT_CONFIG_FILE=/usr/share/sonic/platform/led_proc_init.nps -SAI_DSH_CONFIG_FILE=/usr/share/sonic/hwsku/port_config.nps diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/default_sku b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/default_sku deleted file mode 100644 index 46ddac21550..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/default_sku +++ /dev/null @@ -1 +0,0 @@ -INGRASYS-S9230-64X t1 diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/fancontrol b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/fancontrol deleted file mode 100644 index 86b4e636375..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/fancontrol +++ /dev/null @@ -1,9 +0,0 @@ -INTERVAL=10 -DEVPATH=hwmon7=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-002f hwmon4=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-7/7-004e -DEVNAME=hwmon7=w83795adg -FCTEMPS=hwmon7/device/pwm2=hwmon4/temp1_input -FCFANS=hwmon7/device/pwm2=hwmon7/device/fan7_input hwmon7/device/pwm2=hwmon7/device/fan5_input hwmon7/device/pwm2=hwmon7/device/fan3_input hwmon7/device/pwm2=hwmon7/device/fan1_input -MINTEMP=hwmon7/device/pwm2=20 -MAXTEMP=hwmon7/device/pwm2=60 -MINSTART=hwmon7/device/pwm2=75 -MINSTOP=hwmon7/device/pwm2=22 diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/installer.conf b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/installer.conf deleted file mode 100644 index 925a32fc0c3..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/installer.conf +++ /dev/null @@ -1,3 +0,0 @@ -CONSOLE_PORT=0x3f8 -CONSOLE_DEV=0 -CONSOLE_SPEED=115200 diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/led_proc_init.nps b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/led_proc_init.nps deleted file mode 100644 index 717d3303f17..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/led_proc_init.nps +++ /dev/null @@ -1,9 +0,0 @@ -#unit NPS_CFG_TYPE_XXX param0 param1 value -#---- ---------------- ------ ------ ----- -0 NPS_CFG_TYPE_USE_UNIT_PORT 0 0 1 -0 NPS_CFG_TYPE_LED_CFG 0 0 6 -0 NPS_CFG_TYPE_CPI_PORT_MODE 129 0 1 -0 NPS_CFG_TYPE_CPI_PORT_MODE 130 0 1 -0 NPS_CFG_TYPE_USER_BUF_CTRL 0 0 1 -0 NPS_CFG_TYPE_HASH_L2_FDB_REGION_ENTRY_NUM 0 0 49152 -0 NPS_CFG_TYPE_HASH_L3_WITH_IPV6_PREFIX_64_REGION_ENTRY_NUM 0 0 32768 diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/platform_asic b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/platform_asic deleted file mode 100644 index 4211b60b9ce..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/platform_asic +++ /dev/null @@ -1 +0,0 @@ -nephos diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/plugins/eeprom.py b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/plugins/eeprom.py deleted file mode 100644 index 159e12d98f6..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/plugins/eeprom.py +++ /dev/null @@ -1,20 +0,0 @@ -############################################################################# -# Ingrasys S9230-64X -# -# Platform and model specific eeprom subclass, inherits from the base class, -# and provides the followings: -# - the eeprom format definition -# - specific encoder/decoder if there is special need -############################################################################# - -try: - from sonic_eeprom import eeprom_tlvinfo -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class board(eeprom_tlvinfo.TlvInfoDecoder): - - def __init__(self, name, path, cpld_root, ro): - self.eeprom_path = "/sys/class/i2c-adapter/i2c-0/0-0051/eeprom" - super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/plugins/psuutil.py b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/plugins/psuutil.py deleted file mode 100644 index b2cdb9dca02..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/plugins/psuutil.py +++ /dev/null @@ -1,91 +0,0 @@ -# -# psuutil.py -# Platform-specific PSU status interface for SONiC -# - - -import os.path - -try: - from sonic_psu.psu_base import PsuBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class PsuUtil(PsuBase): - """Platform-specific PSUutil class""" - - SYSFS_PSU_DIR = ["/sys/bus/i2c/devices/i2c-18/18-0050", - "/sys/bus/i2c/devices/i2c-17/17-0050"] - - def __init__(self): - PsuBase.__init__(self) - - # Get sysfs attribute - - def get_attr_value(self, attr_path): - - retval = 'ERR' - if (not os.path.isfile(attr_path)): - return retval - - try: - with open(attr_path, 'r') as fd: - retval = fd.read() - except Exception as error: - logging.error("Unable to open ", attr_path, " file !") - - retval = retval.rstrip('\r\n') - return retval - - def get_num_psus(self): - """ - Retrieves the number of PSUs available on the device - :return: An integer, the number of PSUs available on the device - """ - MAX_PSUS = 2 - return MAX_PSUS - - def get_psu_status(self, index): - """ - Retrieves the oprational status of power supply unit (PSU) defined - by index - :param index: An integer, index of the PSU of which to query status - :return: Boolean, True if PSU is operating properly, False if PSU is\ - faulty - """ - status = 0 - attr_file = 'psu_pg' - attr_path = self.SYSFS_PSU_DIR[index-1] + '/' + attr_file - - attr_value = self.get_attr_value(attr_path) - - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - # Check for PSU status - if (attr_value == 1): - status = 1 - - return status - - def get_psu_presence(self, index): - """ - Retrieves the presence status of power supply unit (PSU) defined - by index - :param index: An integer, index of the PSU of which to query status - :return: Boolean, True if PSU is plugged, False if not - """ - status = 0 - psu_absent = 0 - attr_file = 'psu_abs' - attr_path = self.SYSFS_PSU_DIR[index-1] + '/' + attr_file - - attr_value = self.get_attr_value(attr_path) - - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - # Check for PSU presence - if (attr_value == 0): - status = 1 - - return status diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/plugins/sfputil.py b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/plugins/sfputil.py deleted file mode 100644 index f3e1d49cd86..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/plugins/sfputil.py +++ /dev/null @@ -1,294 +0,0 @@ -# sfputil.py -# -# Platform-specific SFP transceiver interface for SONiC -# - -try: - import time - from sonic_sfp.sfputilbase import SfpUtilBase -except ImportError as e: - raise ImportError("%s - required module not found" % str(e)) - - -class SfpUtil(SfpUtilBase): - """Platform-specific SfpUtil class""" - - PORT_START = 0 - PORT_END = 63 - PORTS_IN_BLOCK = 64 - # TODO: modify according to port map - EEPROM_OFFSET = 33 - CPLD1_PORTS = 12 - CPLDx_PORTS = 13 - CPLD_OFFSET = 1 - CPLD_PRES_BIT = 1 - CPLD_RESET_BIT = 0 - CPLD_LPMOD_BIT = 2 - CPLDx_I2C_ADDR = "33" - CPLD_PORT_STATUS_KEY = "cpld_qsfp_port_status" - CPLD_PORT_CONFIG_KEY = "cpld_qsfp_port_config" - CPLD_REG_PATH = "/sys/bus/i2c/devices/{0}-00{1}/{2}_{3}" - - _port_to_eeprom_mapping = {} - - _logic_to_phy_port_mapping = { - 0: 0, - 1: 1, - 2: 4, - 3: 5, - 4: 8, - 5: 9, - 6: 12, - 7: 13, - 8: 16, - 9: 17, - 10: 20, - 11: 21, - 12: 24, - 13: 25, - 14: 28, - 15: 29, - 16: 32, - 17: 33, - 18: 36, - 19: 37, - 20: 40, - 21: 41, - 22: 44, - 23: 45, - 24: 48, - 25: 49, - 26: 52, - 27: 53, - 28: 56, - 29: 57, - 30: 60, - 31: 61, - 32: 2, - 33: 3, - 34: 6, - 35: 7, - 36: 10, - 37: 11, - 38: 14, - 39: 15, - 40: 18, - 41: 19, - 42: 22, - 43: 23, - 44: 26, - 45: 27, - 46: 30, - 47: 31, - 48: 34, - 49: 35, - 50: 38, - 51: 39, - 52: 42, - 53: 43, - 54: 46, - 55: 47, - 56: 50, - 57: 51, - 58: 54, - 59: 55, - 60: 58, - 61: 59, - 62: 62, - 63: 63 - } - - @property - def port_start(self): - return self.PORT_START - - @property - def port_end(self): - return self.PORT_END - - @property - def qsfp_ports(self): - return list(range(0, self.PORTS_IN_BLOCK + 1)) - - @property - def port_to_eeprom_mapping(self): - return self._port_to_eeprom_mapping - - def __init__(self): - # Override port_to_eeprom_mapping for class initialization - eeprom_path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom" - for x in range(self.port_start, self.port_end + 1): - phy_port = self._logic_to_phy_port_mapping[x] - port_eeprom_path = eeprom_path.format(phy_port + self.EEPROM_OFFSET) - self.port_to_eeprom_mapping[x] = port_eeprom_path - - SfpUtilBase.__init__(self) - - def qsfp_to_cpld_index(self, port_num): - if port_num < self.CPLD1_PORTS: - cpld_id = 0 - cpld_port_index = port_num + 1 - else: - cpld_id = 1 + (port_num - self.CPLD1_PORTS) / self.CPLDx_PORTS - cpld_port_index = ((port_num - self.CPLD1_PORTS) % self.CPLDx_PORTS) + 1 - return cpld_id, cpld_port_index - - def get_presence(self, port_num): - # Check for invalid port_num - if port_num < self.port_start or port_num > self.port_end: - return False - - # logic port to physical port mapping - port_num = self._logic_to_phy_port_mapping[port_num] - - cpld_id, cpld_port_index = self.qsfp_to_cpld_index(port_num) - i2c_id = self.CPLD_OFFSET + cpld_id - reg_path = self.CPLD_REG_PATH.format(i2c_id, self.CPLDx_I2C_ADDR, - self.CPLD_PORT_STATUS_KEY, cpld_port_index) - - try: - reg_file = open(reg_path) - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - # content is a string containing the status register value - content = reg_file.readline().rstrip() - reg_file.close() - - reg_value = int(content, 16) - # mask for presence bit (bit 1) - mask = (1 << self.CPLD_PRES_BIT) - - # 0 - presence, 1 - absence - if reg_value & mask == 0: - return True - - 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 - - # logic port to physical port mapping - port_num = self._logic_to_phy_port_mapping[port_num] - - cpld_id, cpld_port_index = self.qsfp_to_cpld_index(port_num) - i2c_id = self.CPLD_OFFSET + cpld_id - reg_path = self.CPLD_REG_PATH.format(i2c_id, self.CPLDx_I2C_ADDR, - self.CPLD_PORT_CONFIG_KEY, cpld_port_index) - - try: - reg_file = open(reg_path) - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - # content is a string containing the status register value - content = reg_file.readline().rstrip() - reg_file.close() - - reg_value = int(content, 16) - # mask for lp_mod bit (bit 2) - mask = (1 << self.CPLD_LPMOD_BIT) - - # 0 - disable, 1 - low power mode - if reg_value & mask == 0: - return False - - return True - - 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 - - # logic port to physical port mapping - port_num = self._logic_to_phy_port_mapping[port_num] - - cpld_id, cpld_port_index = self.qsfp_to_cpld_index(port_num) - i2c_id = self.CPLD_OFFSET + cpld_id - reg_path = self.CPLD_REG_PATH.format(i2c_id, self.CPLDx_I2C_ADDR, - self.CPLD_PORT_CONFIG_KEY, cpld_port_index) - - try: - reg_file = open(reg_path, "r+") - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - # content is a string containing the status register value - content = reg_file.readline().rstrip() - reg_value = int(content, 16) - # mask for lp_mod bit (bit 2) - mask = (1 << self.CPLD_LPMOD_BIT) - - # 1 - low power mode, 0 - high power mode - if lpmode is True: - reg_value = reg_value | mask - else: - reg_value = reg_value & ~mask - - # convert value to hex string - content = hex(reg_value) - - reg_file.seek(0) - reg_file.write(content) - reg_file.close() - - return True - - def reset(self, port_num): - # Check for invalid port_num - if port_num < self.port_start or port_num > self.port_end: - return False - - # logic port to physical port mapping - port_num = self._logic_to_phy_port_mapping[port_num] - - cpld_id, cpld_port_index = self.qsfp_to_cpld_index(port_num) - i2c_id = self.CPLD_OFFSET + cpld_id - reg_path = self.CPLD_REG_PATH.format(i2c_id, self.CPLDx_I2C_ADDR, - self.CPLD_PORT_CONFIG_KEY, cpld_port_index) - - # reset the port - try: - reg_file = open(reg_path, "r+") - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - # content is a string containing the status register value - content = reg_file.readline().rstrip() - reg_value = int(content, 16) - # mask for reset bit (bit 0) - mask = (1 << self.CPLD_RESET_BIT) - - # 1 - out of reset, 0 - reset - reg_value = reg_value & ~mask - - reg_file.seek(0) - reg_file.write(hex(reg_value)) - reg_file.close() - - # Sleep 1 second to reset done - time.sleep(1) - - # take the port out of reset - try: - reg_file = open(reg_path, "w") - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - reg_value = reg_value | mask - - reg_file.seek(0) - reg_file.write(hex(reg_value)) - reg_file.close() - - return True - - def get_transceiver_change_event(self, timeout=0): - raise NotImplementedError diff --git a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/sensors.conf b/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/sensors.conf deleted file mode 100644 index 84abfe88062..00000000000 --- a/device/ingrasys/x86_64-ingrasys_s9230_64x-r0/sensors.conf +++ /dev/null @@ -1,83 +0,0 @@ -# libsensors configuration file -chip "i350bb-*" - ignore loc1 - -chip "jc42-*" - -bus "i2c-16" "i2c-mux-1 (chan_id 7)" -chip "w83795adg-*" - ignore in0 - label in1 "VDD_CORE" - set in1_min 0.90 * 0.98 - set in1_max 0.90 * 1.02 - ignore in2 - label in3 "1.8V" - set in3_min 1.8 * 0.97 - set in3_max 1.8 * 1.03 - label in4 "3.3V" - compute in4 @/(0.3052), (0.3052)*@ - set in4_min 3.3 * 0.95 - set in4_max 3.3 * 1.05 - label in5 "0.9V" - set in5_min 0.90 * 0.98 - set in5_max 0.90 * 1.02 - ignore in6 - ignore in7 - ignore in8 - ignore in9 - ignore in10 - ignore in11 - ignore in12 - ignore in13 - ignore in14 - ignore in15 - ignore in16 - ignore in17 - ignore in18 - ignore in19 - label fan1 "FANTRAY 1" - ignore fan2 - label fan3 "FANTRAY 2" - ignore fan4 - label fan5 "FANTRAY 3" - ignore fan6 - label fan7 "FANTRAY 4" - ignore fan8 - ignore temp1 - ignore temp2 - ignore temp3 - ignore temp4 - ignore temp5 - ignore temp6 - ignore intrusion0 - -chip "tmp75-i2c-*-4A" - label temp1 "BMC Board Temp" - set temp1_max 50 - set temp1_max_hyst 45 - -bus "i2c-0" "SMBus I801 adapter at f000" -chip "tmp75-i2c-*-4F" - label temp1 "x86 CPU Board Temp" - set temp1_max 50 - set temp1_max_hyst 45 - -bus "i2c-6" "i2c-0-mux (chan_id 5)" -chip "lm75-i2c-6-4D" - label temp1 "Rear Panel Temp" - set temp1_max 50 - set temp1_max_hyst 45 -chip "lm75-i2c-6-4E" - label temp1 "Rear MAC Temp" - set temp1_max 50 - set temp1_max_hyst 45 - -bus "i2c-7" "i2c-0-mux (chan_id 6)" -chip "lm75-i2c-7-4D" - label temp1 "Front Panel Temp" - set temp1_max 50 - set temp1_max_hyst 45 -chip "lm75-i2c-7-4E" - label temp1 "Front MAC Temp" - set temp1_max 50 - set temp1_max_hyst 45 diff --git a/device/pegatron/x86_64-pegatron_porsche-r0/default_sku b/device/pegatron/x86_64-pegatron_porsche-r0/default_sku deleted file mode 100644 index 6b47d90d1cf..00000000000 --- a/device/pegatron/x86_64-pegatron_porsche-r0/default_sku +++ /dev/null @@ -1 +0,0 @@ -porsche t1 diff --git a/device/pegatron/x86_64-pegatron_porsche-r0/installer.conf b/device/pegatron/x86_64-pegatron_porsche-r0/installer.conf deleted file mode 100755 index 14404194ef5..00000000000 --- a/device/pegatron/x86_64-pegatron_porsche-r0/installer.conf +++ /dev/null @@ -1,3 +0,0 @@ -CONSOLE_PORT=0x2f8 -CONSOLE_DEV=1 -CONSOLE_SPEED=115200 diff --git a/device/pegatron/x86_64-pegatron_porsche-r0/platform_asic b/device/pegatron/x86_64-pegatron_porsche-r0/platform_asic deleted file mode 100644 index 4211b60b9ce..00000000000 --- a/device/pegatron/x86_64-pegatron_porsche-r0/platform_asic +++ /dev/null @@ -1 +0,0 @@ -nephos diff --git a/device/pegatron/x86_64-pegatron_porsche-r0/plugins/eeprom.py b/device/pegatron/x86_64-pegatron_porsche-r0/plugins/eeprom.py deleted file mode 100755 index 5c2a90e81c2..00000000000 --- a/device/pegatron/x86_64-pegatron_porsche-r0/plugins/eeprom.py +++ /dev/null @@ -1,20 +0,0 @@ -try: - import binascii - import time - import optparse - import warnings - import os - import sys - from sonic_eeprom import eeprom_base - from sonic_eeprom import eeprom_tlvinfo - import subprocess -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class board(eeprom_tlvinfo.TlvInfoDecoder): - _TLV_INFO_MAX_LEN = 256 - - def __init__(self, name, path, cpld_root, ro): - self.eeprom_path = "/sys/bus/i2c/devices/4-0054/eeprom" - super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/pegatron/x86_64-pegatron_porsche-r0/plugins/psuutil.py b/device/pegatron/x86_64-pegatron_porsche-r0/plugins/psuutil.py deleted file mode 100755 index ce859cb70c7..00000000000 --- a/device/pegatron/x86_64-pegatron_porsche-r0/plugins/psuutil.py +++ /dev/null @@ -1,91 +0,0 @@ -# -# psuutil.py -# Platform-specific PSU status interface for SONiC -# - - -import os.path - -try: - from sonic_psu.psu_base import PsuBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class PsuUtil(PsuBase): - """Platform-specific PSUutil class""" - - SYSFS_PSU_DIR = "/sys/bus/i2c/devices/7-0075" - - def __init__(self): - PsuBase.__init__(self) - - # Get sysfs attribute - - def get_attr_value(self, attr_path): - - retval = 'ERR' - if (not os.path.isfile(attr_path)): - return retval - - try: - with open(attr_path, 'r') as fd: - retval = fd.read() - except Exception as error: - logging.error("Unable to open ", attr_path, " file !") - - retval = retval.rstrip('\r\n') - - fd.close() - return retval - - def get_num_psus(self): - """ - Retrieves the number of PSUs available on the device - :return: An integer, the number of PSUs available on the device - """ - MAX_PSUS = 2 - return MAX_PSUS - - def get_psu_status(self, index): - """ - Retrieves the oprational status of power supply unit (PSU) defined - by index - :param index: An integer, index of the PSU of which to query status - :return: Boolean, True if PSU is operating properly, False if PSU is\ - faulty - """ - status = 0 - attr_file = 'psu_'+str(index)+'_status' - attr_path = self.SYSFS_PSU_DIR + '/' + attr_file - - attr_value = self.get_attr_value(attr_path) - - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - # Check for PSU status - if (attr_value == 1): - status = 1 - - return status - - def get_psu_presence(self, index): - """ - Retrieves the presence status of power supply unit (PSU) defined - by index - :param index: An integer, index of the PSU of which to query status - :return: Boolean, True if PSU is plugged, False if not - """ - status = 0 - attr_file = 'psu_'+str(index)+'_present' - attr_path = self.SYSFS_PSU_DIR + '/' + attr_file - - attr_value = self.get_attr_value(attr_path) - - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - # Check for PSU presence - if (attr_value == 0): - status = 1 - - return status diff --git a/device/pegatron/x86_64-pegatron_porsche-r0/plugins/sfputil.py b/device/pegatron/x86_64-pegatron_porsche-r0/plugins/sfputil.py deleted file mode 100755 index 3a757333cd2..00000000000 --- a/device/pegatron/x86_64-pegatron_porsche-r0/plugins/sfputil.py +++ /dev/null @@ -1,231 +0,0 @@ -try: - import os - import re - import time - from sonic_sfp.sfputilbase import SfpUtilBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - - -class SfpUtil(SfpUtilBase): - """Platform specific sfputil class""" - - port_start = 0 - port_end = 53 - ports_in_block = 54 - cplda_sfp_num = 24 - cpldb_sfp_num = 12 - cpldc_sfp_num = 18 - - port_to_eeprom_mapping = {} - port_to_i2c_mapping = {} - sfp_ports = list(range(0, ports_in_block)) - qsfp_ports = list(range(ports_in_block - 6, ports_in_block)) - - def __init__(self): - for x in range(self.port_start, self.port_end + 1): - if x < self.cpldb_sfp_num: - self.port_to_i2c_mapping.update({x: 7}) - elif x < self.cplda_sfp_num + self.cpldb_sfp_num: - self.port_to_i2c_mapping.update({x: 6}) - else: - self.port_to_i2c_mapping.update({x: 8}) - - for x in range(self.port_start, self.port_end+1): - eeprom_path = '/sys/bus/i2c/devices/{0}-0050/sfp'+str(x+1)+'_eeprom' - port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x]) - self.port_to_eeprom_mapping[x] = port_eeprom_path - SfpUtilBase.__init__(self) - - def get_presence(self, port_num): - if port_num < self.port_start or port_num > self.port_end: - return False - - if port_num < self.cpldb_sfp_num: - presence_path = '/sys/bus/i2c/devices/7-0075/sfp'+str(port_num+1)+'_present' - elif port_num < self.cpldb_sfp_num + self.cplda_sfp_num: - presence_path = '/sys/bus/i2c/devices/6-0074/sfp'+str(port_num+1)+'_present' - else: - presence_path = '/sys/bus/i2c/devices/8-0076/sfp'+str(port_num+1)+'_present' - - try: - file = open(presence_path) - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - value = int(file.readline().rstrip()) - - file.close() - if value == 0: - return True - - return False - - def get_low_power_mode(self, port_num): - if port_num not in self.qsfp_ports: - return False - - lowpower_path = '/sys/bus/i2c/devices/8-0076/sfp'+str(port_num+1)+'_lowpower' - - try: - file = open(lowpower_path) - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - value = int(file.readline().rstrip()) - - file.close() - if value == 1: - return True - - return False - - def set_low_power_mode(self, port_num, lpmode): - if port_num not in self.qsfp_ports: - return False - - lowpower_path = '/sys/bus/i2c/devices/8-0076/sfp'+str(port_num+1)+'_lowpower' - - # LPMode is active high; set or clear the bit accordingly - if lpmode is True: - value = 1 - else: - value = 0 - - try: - file = open(lowpower_path, "r+") - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - file.seek(0) - file.write(str(value)) - file.close() - - return True - - def reset(self, port_num): - if port_num not in self.qsfp_ports: - return False - reset_path = '/sys/bus/i2c/devices/8-0076/sfp'+str(port_num+1)+'_reset' - - try: - file = open(reset_path, "r+") - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - file.seek(0) - file.write(str(2)) - file.close() - - # Sleep 1 second to allow it to settle - time.sleep(1) - - try: - file = open(reset_path, "r+") - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - - file.seek(0) - file.write(str(1)) - file.close() - - return True - - def read_porttab_mappings(self, porttabfile): - logical = [] - logical_to_bcm = {} - logical_to_physical = {} - physical_to_logical = {} - last_fp_port_index = 0 - last_portname = "" - first = 1 - port_pos_in_file = 0 - parse_fmt_port_config_ini = False - - try: - f = open(porttabfile) - except: - raise - - parse_fmt_port_config_ini = (os.path.basename(porttabfile) == "port_config.ini") - - # Read the porttab file and generate dicts - # with mapping for future reference. - # XXX: move the porttab - # parsing stuff to a separate module, or reuse - # if something already exists - for line in f: - line.strip() - if re.search("^#", line) is not None: - continue - - # Parsing logic for 'port_config.ini' file - if (parse_fmt_port_config_ini): - # bcm_port is not explicitly listed in port_config.ini format - # Currently we assume ports are listed in numerical order according to bcm_port - # so we use the port's position in the file (zero-based) as bcm_port - portname = line.split()[0] - - bcm_port = str(port_pos_in_file) - - if len(line.split()) >= 4: - fp_port_index = int(line.split()[3]) - else: - fp_port_index = portname.split("Ethernet").pop() - fp_port_index = int(fp_port_index.split("s").pop(0))/4 - else: # Parsing logic for older 'portmap.ini' file - (portname, bcm_port) = line.split("=")[1].split(",")[:2] - - fp_port_index = portname.split("Ethernet").pop() - fp_port_index = int(fp_port_index.split("s").pop(0))/4 - - if ((len(self.sfp_ports) > 0) and (fp_port_index not in self.sfp_ports)): - continue - - if first == 1: - # Initialize last_[physical|logical]_port - # to the first valid port - last_fp_port_index = fp_port_index - last_portname = portname - first = 0 - - logical.append(portname) - - logical_to_bcm[portname] = "xe" + bcm_port - logical_to_physical[portname] = [fp_port_index] - if physical_to_logical.get(fp_port_index) is None: - physical_to_logical[fp_port_index] = [portname] - else: - physical_to_logical[fp_port_index].append( - portname) - - if (fp_port_index - last_fp_port_index) > 1: - # last port was a gang port - for p in range(last_fp_port_index+1, fp_port_index): - logical_to_physical[last_portname].append(p) - if physical_to_logical.get(p) is None: - physical_to_logical[p] = [last_portname] - else: - physical_to_logical[p].append(last_portname) - - last_fp_port_index = fp_port_index - last_portname = portname - - port_pos_in_file += 1 - - self.logical = logical - self.logical_to_bcm = logical_to_bcm - self.logical_to_physical = logical_to_physical - self.physical_to_logical = physical_to_logical - - """ - print "logical: " + self.logical - print "logical to bcm: " + self.logical_to_bcm - print "logical to physical: " + self.logical_to_physical - print "physical to logical: " + self.physical_to_logical - """ diff --git a/device/pegatron/x86_64-pegatron_porsche-r0/porsche/port_config.ini b/device/pegatron/x86_64-pegatron_porsche-r0/porsche/port_config.ini deleted file mode 100755 index 15fc6037594..00000000000 --- a/device/pegatron/x86_64-pegatron_porsche-r0/porsche/port_config.ini +++ /dev/null @@ -1,55 +0,0 @@ -#name lanes alias index speed -Ethernet0 8 Ethernet1/1 0 10000 -Ethernet1 9 Ethernet2/1 1 10000 -Ethernet2 10 Ethernet3/1 2 10000 -Ethernet3 11 Ethernet4/1 3 10000 -Ethernet4 12 Ethernet5/1 4 10000 -Ethernet5 13 Ethernet6/1 5 10000 -Ethernet6 14 Ethernet7/1 6 10000 -Ethernet7 15 Ethernet8/1 7 10000 -Ethernet8 16 Ethernet9/1 8 10000 -Ethernet9 17 Ethernet10/1 9 10000 -Ethernet10 18 Ethernet11/1 10 10000 -Ethernet11 19 Ethernet12/1 11 10000 -Ethernet12 20 Ethernet13/1 12 10000 -Ethernet13 21 Ethernet14/1 13 10000 -Ethernet14 22 Ethernet15/1 14 10000 -Ethernet15 23 Ethernet16/1 15 10000 -Ethernet16 32 Ethernet17/1 16 10000 -Ethernet17 33 Ethernet18/1 17 10000 -Ethernet18 34 Ethernet19/1 18 10000 -Ethernet19 35 Ethernet20/1 19 10000 -Ethernet20 40 Ethernet21/1 20 10000 -Ethernet21 41 Ethernet22/1 21 10000 -Ethernet22 42 Ethernet23/1 22 10000 -Ethernet23 43 Ethernet24/1 23 10000 -Ethernet24 48 Ethernet25/1 24 10000 -Ethernet25 49 Ethernet26/1 25 10000 -Ethernet26 50 Ethernet27/1 26 10000 -Ethernet27 51 Ethernet28/1 27 10000 -Ethernet28 56 Ethernet29/1 28 10000 -Ethernet29 57 Ethernet30/1 29 10000 -Ethernet30 58 Ethernet31/1 30 10000 -Ethernet31 59 Ethernet32/1 31 10000 -Ethernet32 64 Ethernet33/1 32 10000 -Ethernet33 65 Ethernet34/1 33 10000 -Ethernet34 66 Ethernet35/1 34 10000 -Ethernet35 67 Ethernet36/1 35 10000 -Ethernet36 68 Ethernet37/1 36 10000 -Ethernet37 69 Ethernet38/1 37 10000 -Ethernet38 70 Ethernet39/1 38 10000 -Ethernet39 71 Ethernet40/1 39 10000 -Ethernet40 72 Ethernet41/1 40 10000 -Ethernet41 73 Ethernet42/1 41 10000 -Ethernet42 74 Ethernet43/1 42 10000 -Ethernet43 75 Ethernet44/1 43 10000 -Ethernet44 76 Ethernet45/1 44 10000 -Ethernet45 77 Ethernet46/1 45 10000 -Ethernet46 78 Ethernet47/1 46 10000 -Ethernet47 79 Ethernet48/1 47 10000 -Ethernet48 80,81,82,83 Ethernet49/1 48 100000 -Ethernet49 84,85,86,87 Ethernet50/1 49 100000 -Ethernet50 104,105,106,107 Ethernet51/1 50 100000 -Ethernet51 108,109,110,111 Ethernet52/1 51 100000 -Ethernet52 112,113,114,115 Ethernet53/1 52 100000 -Ethernet53 116,117,118,119 Ethernet54/1 53 100000 diff --git a/device/pegatron/x86_64-pegatron_porsche-r0/porsche/sai.profile b/device/pegatron/x86_64-pegatron_porsche-r0/porsche/sai.profile deleted file mode 100755 index f19a366b1ca..00000000000 --- a/device/pegatron/x86_64-pegatron_porsche-r0/porsche/sai.profile +++ /dev/null @@ -1,2 +0,0 @@ -SAI_INIT_CONFIG_FILE=/usr/share/sonic/platform/tau-porsche.cfg -SAI_DSH_CONFIG_FILE=/usr/share/sonic/hwsku/tau-porsche.dsh diff --git a/device/pegatron/x86_64-pegatron_porsche-r0/porsche/tau-porsche.dsh b/device/pegatron/x86_64-pegatron_porsche-r0/porsche/tau-porsche.dsh deleted file mode 100755 index b370fe83b83..00000000000 --- a/device/pegatron/x86_64-pegatron_porsche-r0/porsche/tau-porsche.dsh +++ /dev/null @@ -1,497 +0,0 @@ -init start stage unit=0 low-level -init set port-map unit=0 port=0 eth-macro=2 lane=0 max-speed=10g active=true -init set port-map unit=0 port=1 eth-macro=2 lane=1 max-speed=10g active=true -init set port-map unit=0 port=2 eth-macro=2 lane=2 max-speed=10g active=true -init set port-map unit=0 port=3 eth-macro=2 lane=3 max-speed=10g active=true -init set port-map unit=0 port=4 eth-macro=3 lane=0 max-speed=10g active=true -init set port-map unit=0 port=5 eth-macro=3 lane=1 max-speed=10g active=true -init set port-map unit=0 port=6 eth-macro=3 lane=2 max-speed=10g active=true -init set port-map unit=0 port=7 eth-macro=3 lane=3 max-speed=10g active=true -init set port-map unit=0 port=8 eth-macro=4 lane=0 max-speed=10g active=true -init set port-map unit=0 port=9 eth-macro=4 lane=1 max-speed=10g active=true -init set port-map unit=0 port=10 eth-macro=4 lane=2 max-speed=10g active=true -init set port-map unit=0 port=11 eth-macro=4 lane=3 max-speed=10g active=true -init set port-map unit=0 port=12 eth-macro=5 lane=0 max-speed=10g active=true -init set port-map unit=0 port=13 eth-macro=5 lane=1 max-speed=10g active=true -init set port-map unit=0 port=14 eth-macro=5 lane=2 max-speed=10g active=true -init set port-map unit=0 port=15 eth-macro=5 lane=3 max-speed=10g active=true -init set port-map unit=0 port=16 eth-macro=8 lane=0 max-speed=10g active=true -init set port-map unit=0 port=17 eth-macro=8 lane=1 max-speed=10g active=true -init set port-map unit=0 port=18 eth-macro=8 lane=2 max-speed=10g active=true -init set port-map unit=0 port=19 eth-macro=8 lane=3 max-speed=10g active=true -init set port-map unit=0 port=20 eth-macro=10 lane=0 max-speed=10g active=true -init set port-map unit=0 port=21 eth-macro=10 lane=1 max-speed=10g active=true -init set port-map unit=0 port=22 eth-macro=10 lane=2 max-speed=10g active=true -init set port-map unit=0 port=23 eth-macro=10 lane=3 max-speed=10g active=true -init set port-map unit=0 port=24 eth-macro=12 lane=0 max-speed=10g active=true -init set port-map unit=0 port=25 eth-macro=12 lane=1 max-speed=10g active=true -init set port-map unit=0 port=26 eth-macro=12 lane=2 max-speed=10g active=true -init set port-map unit=0 port=27 eth-macro=12 lane=3 max-speed=10g active=true -init set port-map unit=0 port=28 eth-macro=14 lane=0 max-speed=10g active=true -init set port-map unit=0 port=29 eth-macro=14 lane=1 max-speed=10g active=true -init set port-map unit=0 port=30 eth-macro=14 lane=2 max-speed=10g active=true -init set port-map unit=0 port=31 eth-macro=14 lane=3 max-speed=10g active=true -init set port-map unit=0 port=32 eth-macro=16 lane=0 max-speed=10g active=true -init set port-map unit=0 port=33 eth-macro=16 lane=1 max-speed=10g active=true -init set port-map unit=0 port=34 eth-macro=16 lane=2 max-speed=10g active=true -init set port-map unit=0 port=35 eth-macro=16 lane=3 max-speed=10g active=true -init set port-map unit=0 port=36 eth-macro=17 lane=0 max-speed=10g active=true -init set port-map unit=0 port=37 eth-macro=17 lane=1 max-speed=10g active=true -init set port-map unit=0 port=38 eth-macro=17 lane=2 max-speed=10g active=true -init set port-map unit=0 port=39 eth-macro=17 lane=3 max-speed=10g active=true -init set port-map unit=0 port=40 eth-macro=18 lane=0 max-speed=10g active=true -init set port-map unit=0 port=41 eth-macro=18 lane=1 max-speed=10g active=true -init set port-map unit=0 port=42 eth-macro=18 lane=2 max-speed=10g active=true -init set port-map unit=0 port=43 eth-macro=18 lane=3 max-speed=10g active=true -init set port-map unit=0 port=44 eth-macro=19 lane=0 max-speed=10g active=true -init set port-map unit=0 port=45 eth-macro=19 lane=1 max-speed=10g active=true -init set port-map unit=0 port=46 eth-macro=19 lane=2 max-speed=10g active=true -init set port-map unit=0 port=47 eth-macro=19 lane=3 max-speed=10g active=true -init set port-map unit=0 port=48 eth-macro=20 lane=0 max-speed=100g active=true -init set port-map unit=0 port=49 eth-macro=21 lane=0 max-speed=100g active=true -init set port-map unit=0 port=50 eth-macro=26 lane=0 max-speed=100g active=true -init set port-map unit=0 port=51 eth-macro=27 lane=0 max-speed=100g active=true -init set port-map unit=0 port=52 eth-macro=28 lane=0 max-speed=100g active=true -init set port-map unit=0 port=53 eth-macro=29 lane=0 max-speed=100g active=true init-done=true -init start stage unit=0 task-rsrc -init start stage unit=0 module -init start stage unit=0 task -phy set lane-swap unit=0 portlist=0 lane-cnt=1 property=tx data=0x00 -phy set lane-swap unit=0 portlist=1 lane-cnt=1 property=tx data=0x01 -phy set lane-swap unit=0 portlist=2 lane-cnt=1 property=tx data=0x02 -phy set lane-swap unit=0 portlist=3 lane-cnt=1 property=tx data=0x03 -phy set lane-swap unit=0 portlist=4 lane-cnt=1 property=tx data=0x02 -phy set lane-swap unit=0 portlist=5 lane-cnt=1 property=tx data=0x03 -phy set lane-swap unit=0 portlist=6 lane-cnt=1 property=tx data=0x00 -phy set lane-swap unit=0 portlist=7 lane-cnt=1 property=tx data=0x01 -phy set lane-swap unit=0 portlist=8 lane-cnt=1 property=tx data=0x00 -phy set lane-swap unit=0 portlist=9 lane-cnt=1 property=tx data=0x01 -phy set lane-swap unit=0 portlist=10 lane-cnt=1 property=tx data=0x02 -phy set lane-swap unit=0 portlist=11 lane-cnt=1 property=tx data=0x03 -phy set lane-swap unit=0 portlist=12 lane-cnt=1 property=tx data=0x00 -phy set lane-swap unit=0 portlist=13 lane-cnt=1 property=tx data=0x03 -phy set lane-swap unit=0 portlist=14 lane-cnt=1 property=tx data=0x02 -phy set lane-swap unit=0 portlist=15 lane-cnt=1 property=tx data=0x01 -phy set lane-swap unit=0 portlist=16 lane-cnt=1 property=tx data=0x03 -phy set lane-swap unit=0 portlist=17 lane-cnt=1 property=tx data=0x02 -phy set lane-swap unit=0 portlist=18 lane-cnt=1 property=tx data=0x01 -phy set lane-swap unit=0 portlist=19 lane-cnt=1 property=tx data=0x00 -phy set lane-swap unit=0 portlist=20 lane-cnt=1 property=tx data=0x02 -phy set lane-swap unit=0 portlist=21 lane-cnt=1 property=tx data=0x03 -phy set lane-swap unit=0 portlist=22 lane-cnt=1 property=tx data=0x00 -phy set lane-swap unit=0 portlist=23 lane-cnt=1 property=tx data=0x01 -phy set lane-swap unit=0 portlist=24 lane-cnt=1 property=tx data=0x02 -phy set lane-swap unit=0 portlist=25 lane-cnt=1 property=tx data=0x03 -phy set lane-swap unit=0 portlist=26 lane-cnt=1 property=tx data=0x00 -phy set lane-swap unit=0 portlist=27 lane-cnt=1 property=tx data=0x01 -phy set lane-swap unit=0 portlist=28 lane-cnt=1 property=tx data=0x02 -phy set lane-swap unit=0 portlist=29 lane-cnt=1 property=tx data=0x03 -phy set lane-swap unit=0 portlist=30 lane-cnt=1 property=tx data=0x00 -phy set lane-swap unit=0 portlist=31 lane-cnt=1 property=tx data=0x01 -phy set lane-swap unit=0 portlist=32 lane-cnt=1 property=tx data=0x00 -phy set lane-swap unit=0 portlist=33 lane-cnt=1 property=tx data=0x01 -phy set lane-swap unit=0 portlist=34 lane-cnt=1 property=tx data=0x02 -phy set lane-swap unit=0 portlist=35 lane-cnt=1 property=tx data=0x03 -phy set lane-swap unit=0 portlist=36 lane-cnt=1 property=tx data=0x00 -phy set lane-swap unit=0 portlist=37 lane-cnt=1 property=tx data=0x01 -phy set lane-swap unit=0 portlist=38 lane-cnt=1 property=tx data=0x02 -phy set lane-swap unit=0 portlist=39 lane-cnt=1 property=tx data=0x03 -phy set lane-swap unit=0 portlist=40 lane-cnt=1 property=tx data=0x00 -phy set lane-swap unit=0 portlist=41 lane-cnt=1 property=tx data=0x01 -phy set lane-swap unit=0 portlist=42 lane-cnt=1 property=tx data=0x02 -phy set lane-swap unit=0 portlist=43 lane-cnt=1 property=tx data=0x03 -phy set lane-swap unit=0 portlist=44 lane-cnt=1 property=tx data=0x00 -phy set lane-swap unit=0 portlist=45 lane-cnt=1 property=tx data=0x01 -phy set lane-swap unit=0 portlist=46 lane-cnt=1 property=tx data=0x02 -phy set lane-swap unit=0 portlist=47 lane-cnt=1 property=tx data=0x03 -phy set lane-swap unit=0 portlist=48 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=49 lane-cnt=4 property=tx data=0x01.02.03.00 -phy set lane-swap unit=0 portlist=50 lane-cnt=4 property=tx data=0x01.02.03.00 -phy set lane-swap unit=0 portlist=51 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=52 lane-cnt=4 property=tx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=53 lane-cnt=4 property=tx data=0x01.02.03.00 -phy set lane-swap unit=0 portlist=0 lane-cnt=1 property=rx data=0x00 -phy set lane-swap unit=0 portlist=1 lane-cnt=1 property=rx data=0x01 -phy set lane-swap unit=0 portlist=2 lane-cnt=1 property=rx data=0x02 -phy set lane-swap unit=0 portlist=3 lane-cnt=1 property=rx data=0x03 -phy set lane-swap unit=0 portlist=4 lane-cnt=1 property=rx data=0x02 -phy set lane-swap unit=0 portlist=5 lane-cnt=1 property=rx data=0x03 -phy set lane-swap unit=0 portlist=6 lane-cnt=1 property=rx data=0x00 -phy set lane-swap unit=0 portlist=7 lane-cnt=1 property=rx data=0x01 -phy set lane-swap unit=0 portlist=8 lane-cnt=1 property=rx data=0x00 -phy set lane-swap unit=0 portlist=9 lane-cnt=1 property=rx data=0x01 -phy set lane-swap unit=0 portlist=10 lane-cnt=1 property=rx data=0x02 -phy set lane-swap unit=0 portlist=11 lane-cnt=1 property=rx data=0x03 -phy set lane-swap unit=0 portlist=12 lane-cnt=1 property=rx data=0x03 -phy set lane-swap unit=0 portlist=13 lane-cnt=1 property=rx data=0x02 -phy set lane-swap unit=0 portlist=14 lane-cnt=1 property=rx data=0x01 -phy set lane-swap unit=0 portlist=15 lane-cnt=1 property=rx data=0x00 -phy set lane-swap unit=0 portlist=16 lane-cnt=1 property=rx data=0x00 -phy set lane-swap unit=0 portlist=17 lane-cnt=1 property=rx data=0x03 -phy set lane-swap unit=0 portlist=18 lane-cnt=1 property=rx data=0x02 -phy set lane-swap unit=0 portlist=19 lane-cnt=1 property=rx data=0x01 -phy set lane-swap unit=0 portlist=20 lane-cnt=1 property=rx data=0x00 -phy set lane-swap unit=0 portlist=21 lane-cnt=1 property=rx data=0x03 -phy set lane-swap unit=0 portlist=22 lane-cnt=1 property=rx data=0x02 -phy set lane-swap unit=0 portlist=23 lane-cnt=1 property=rx data=0x01 -phy set lane-swap unit=0 portlist=24 lane-cnt=1 property=rx data=0x00 -phy set lane-swap unit=0 portlist=25 lane-cnt=1 property=rx data=0x03 -phy set lane-swap unit=0 portlist=26 lane-cnt=1 property=rx data=0x02 -phy set lane-swap unit=0 portlist=27 lane-cnt=1 property=rx data=0x01 -phy set lane-swap unit=0 portlist=28 lane-cnt=1 property=rx data=0x00 -phy set lane-swap unit=0 portlist=29 lane-cnt=1 property=rx data=0x03 -phy set lane-swap unit=0 portlist=30 lane-cnt=1 property=rx data=0x02 -phy set lane-swap unit=0 portlist=31 lane-cnt=1 property=rx data=0x01 -phy set lane-swap unit=0 portlist=32 lane-cnt=1 property=rx data=0x02 -phy set lane-swap unit=0 portlist=33 lane-cnt=1 property=rx data=0x01 -phy set lane-swap unit=0 portlist=34 lane-cnt=1 property=rx data=0x00 -phy set lane-swap unit=0 portlist=35 lane-cnt=1 property=rx data=0x03 -phy set lane-swap unit=0 portlist=36 lane-cnt=1 property=rx data=0x02 -phy set lane-swap unit=0 portlist=37 lane-cnt=1 property=rx data=0x01 -phy set lane-swap unit=0 portlist=38 lane-cnt=1 property=rx data=0x00 -phy set lane-swap unit=0 portlist=39 lane-cnt=1 property=rx data=0x03 -phy set lane-swap unit=0 portlist=40 lane-cnt=1 property=rx data=0x02 -phy set lane-swap unit=0 portlist=41 lane-cnt=1 property=rx data=0x01 -phy set lane-swap unit=0 portlist=42 lane-cnt=1 property=rx data=0x00 -phy set lane-swap unit=0 portlist=43 lane-cnt=1 property=rx data=0x03 -phy set lane-swap unit=0 portlist=44 lane-cnt=1 property=rx data=0x02 -phy set lane-swap unit=0 portlist=45 lane-cnt=1 property=rx data=0x01 -phy set lane-swap unit=0 portlist=46 lane-cnt=1 property=rx data=0x00 -phy set lane-swap unit=0 portlist=47 lane-cnt=1 property=rx data=0x03 -phy set lane-swap unit=0 portlist=48 lane-cnt=4 property=rx data=0x03.00.01.02 -phy set lane-swap unit=0 portlist=49 lane-cnt=4 property=rx data=0x03.00.01.02 -phy set lane-swap unit=0 portlist=50 lane-cnt=4 property=rx data=0x03.01.02.00 -phy set lane-swap unit=0 portlist=51 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=52 lane-cnt=4 property=rx data=0x03.02.01.00 -phy set lane-swap unit=0 portlist=53 lane-cnt=4 property=rx data=0x00.01.02.03 -phy set polarity-rev unit=0 portlist=0 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=1 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=2 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=3 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=4 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=5 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=6 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=7 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=8 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=9 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=10 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=11 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=12 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=13 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=14 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=15 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=16 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=17 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=18 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=19 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=20 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=21 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=22 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=23 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=24 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=25 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=26 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=27 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=28 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=29 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=30 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=31 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=32 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=33 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=34 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=35 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=36 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=37 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=38 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=39 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=40 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=41 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=42 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=43 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=44 lane-cnt=1 property=tx data=0x00 -phy set polarity-rev unit=0 portlist=45 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=46 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=47 lane-cnt=1 property=tx data=0x01 -phy set polarity-rev unit=0 portlist=48 lane-cnt=4 property=tx data=0x00.01.00.00 -phy set polarity-rev unit=0 portlist=49 lane-cnt=4 property=tx data=0x00.00.01.00 -phy set polarity-rev unit=0 portlist=50 lane-cnt=4 property=tx data=0x01.00.01.01 -phy set polarity-rev unit=0 portlist=51 lane-cnt=4 property=tx data=0x01.01.01.01 -phy set polarity-rev unit=0 portlist=52 lane-cnt=4 property=tx data=0x01.00.00.00 -phy set polarity-rev unit=0 portlist=53 lane-cnt=4 property=tx data=0x00.00.01.00 -phy set polarity-rev unit=0 portlist=0 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=1 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=2 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=3 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=4 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=5 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=6 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=7 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=8 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=9 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=10 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=11 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=12 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=13 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=14 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=15 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=16 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=17 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=18 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=19 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=20 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=21 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=22 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=23 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=24 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=25 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=26 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=27 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=28 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=29 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=30 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=31 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=32 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=33 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=34 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=35 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=36 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=37 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=38 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=39 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=40 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=41 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=42 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=43 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=44 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=45 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=46 lane-cnt=1 property=rx data=0x01 -phy set polarity-rev unit=0 portlist=47 lane-cnt=1 property=rx data=0x00 -phy set polarity-rev unit=0 portlist=48 lane-cnt=4 property=rx data=0x00.01.00.00 -phy set polarity-rev unit=0 portlist=49 lane-cnt=4 property=rx data=0x00.00.01.00 -phy set polarity-rev unit=0 portlist=50 lane-cnt=4 property=rx data=0x00.00.01.01 -phy set polarity-rev unit=0 portlist=51 lane-cnt=4 property=rx data=0x00.01.00.01 -phy set polarity-rev unit=0 portlist=52 lane-cnt=4 property=rx data=0x00.01.00.01 -phy set polarity-rev unit=0 portlist=53 lane-cnt=4 property=rx data=0x01.01.01.01 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=c2 data=0x00 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=cn1 data=0x04 -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=c0 data=0x1E -phy set pre-emphasis unit=0 portlist=0 lane-cnt=1 property=c1 data=0x02 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=c2 data=0x00 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=cn1 data=0x04 -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=c0 data=0x1E -phy set pre-emphasis unit=0 portlist=1 lane-cnt=1 property=c1 data=0x02 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=c2 data=0x00 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=cn1 data=0x04 -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=c0 data=0x1E -phy set pre-emphasis unit=0 portlist=2 lane-cnt=1 property=c1 data=0x02 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=c2 data=0x00 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=cn1 data=0x04 -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=c0 data=0x1E -phy set pre-emphasis unit=0 portlist=3 lane-cnt=1 property=c1 data=0x02 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=c0 data=0x1B -phy set pre-emphasis unit=0 portlist=4 lane-cnt=1 property=c1 data=0x07 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=c0 data=0x1B -phy set pre-emphasis unit=0 portlist=5 lane-cnt=1 property=c1 data=0x07 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=c0 data=0x1B -phy set pre-emphasis unit=0 portlist=6 lane-cnt=1 property=c1 data=0x07 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=c0 data=0x1B -phy set pre-emphasis unit=0 portlist=7 lane-cnt=1 property=c1 data=0x07 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=c0 data=0x1B -phy set pre-emphasis unit=0 portlist=8 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=c0 data=0x1B -phy set pre-emphasis unit=0 portlist=9 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=c0 data=0x1B -phy set pre-emphasis unit=0 portlist=10 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=c0 data=0x1B -phy set pre-emphasis unit=0 portlist=11 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=c0 data=0x1B -phy set pre-emphasis unit=0 portlist=12 lane-cnt=1 property=c1 data=0x07 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=c0 data=0x1B -phy set pre-emphasis unit=0 portlist=13 lane-cnt=1 property=c1 data=0x07 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=c0 data=0x1B -phy set pre-emphasis unit=0 portlist=14 lane-cnt=1 property=c1 data=0x07 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=c0 data=0x1B -phy set pre-emphasis unit=0 portlist=15 lane-cnt=1 property=c1 data=0x07 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=16 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=17 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=18 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=19 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=20 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=21 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=22 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=23 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=24 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=25 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=26 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=27 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=c0 data=0x1D -phy set pre-emphasis unit=0 portlist=28 lane-cnt=1 property=c1 data=0x05 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=c0 data=0x1D -phy set pre-emphasis unit=0 portlist=29 lane-cnt=1 property=c1 data=0x05 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=c0 data=0x1D -phy set pre-emphasis unit=0 portlist=30 lane-cnt=1 property=c1 data=0x05 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=c0 data=0x1D -phy set pre-emphasis unit=0 portlist=31 lane-cnt=1 property=c1 data=0x05 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=32 lane-cnt=1 property=c1 data=0x05 -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=33 lane-cnt=1 property=c1 data=0x05 -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=34 lane-cnt=1 property=c1 data=0x05 -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=35 lane-cnt=1 property=c1 data=0x05 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=36 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=37 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=38 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=39 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=40 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=41 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=42 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=43 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=44 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=45 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=46 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=c2 data=0x02 -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=cn1 data=0x00 -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=c0 data=0x1C -phy set pre-emphasis unit=0 portlist=47 lane-cnt=1 property=c1 data=0x06 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c0 data=0x1C.1C.1C.1C -phy set pre-emphasis unit=0 portlist=48 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c0 data=0x1B.1B.1B.1B -phy set pre-emphasis unit=0 portlist=49 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c0 data=0x1B.1B.1B.1B -phy set pre-emphasis unit=0 portlist=50 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c0 data=0x1B.1B.1B.1B -phy set pre-emphasis unit=0 portlist=51 lane-cnt=4 property=c1 data=0x06.06.06.06 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c0 data=0x1B.1B.1B.1B -phy set pre-emphasis unit=0 portlist=52 lane-cnt=4 property=c1 data=0x07.07.07.07 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c2 data=0x02.02.02.02 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=cn1 data=0x00.00.00.00 -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c0 data=0x1A.1A.1A.1A -phy set pre-emphasis unit=0 portlist=53 lane-cnt=4 property=c1 data=0x07.07.07.07 -port set property unit=0 portlist=0-47 speed=10g -port set property unit=0 portlist=0-47 medium-type=sr -port set property unit=0 portlist=48-53 speed=100g -port set property unit=0 portlist=48-53 medium-type=sr4 -port set property unit=0 portlist=0-53 fec=disable -port set property unit=0 portlist=0-53 an=disable -port set property unit=0 portlist=0-53 admin=enable \ No newline at end of file diff --git a/device/pegatron/x86_64-pegatron_porsche-r0/tau-porsche.cfg b/device/pegatron/x86_64-pegatron_porsche-r0/tau-porsche.cfg deleted file mode 100755 index bbd7c8f80ff..00000000000 --- a/device/pegatron/x86_64-pegatron_porsche-r0/tau-porsche.cfg +++ /dev/null @@ -1,23 +0,0 @@ -#This configuration file is for customer init value feature. Please refer to mtk_cfg.h/mtk_cfg.c for detail. -#1. The lines beginning with # are comment lines. The lines beginning with number are the setting lines. -#2. There are five parameters which can be set. -# 1) the first is unit. -# 2) the second is NPS_CFG_TYPE_XXX. Refer to NPS_CFG_TYPE_T. -# 3) the 3-5 are {param0, param1, value} pairs. Refer to NPS_CFG_VALUE_T. Support HEX format. -# 4) the (unit, NPS_CFG_TYPE_XXX, param0, param1) group is the key to get the correspingding value. -# There should be no same (unit, NPS_CFG_TYPE_XXX, param0, param1) group. -#3. User must follow correct format to apply the setting. Please refer to below commentted example(#0 NPS_CFG_TYPE_L2_ADDR_MODE 0 0 1); -#4. Usage under the linux shell: -# 1) ./image-path/image-name -c cfg-path/NPS_Ari_EVB_24.cfg : mamually specify directory path if they are not in current work dirctory. -# 2) ./image-name -c NPS_Ari_EVB_24.cfg : the image and the NPS_Ari_EVB_24.cfg are in the current work directory. - -#unit NPS_CFG_TYPE_XXX param0 param1 value -#---- ---------------- ------ ------ ----- -0 NPS_CFG_TYPE_USE_UNIT_PORT 0 0 1 -0 NPS_CFG_TYPE_LED_CFG 0 0 3 -0 NPS_CFG_TYPE_CPI_PORT_MODE 129 0 1 -0 NPS_CFG_TYPE_CPI_PORT_MODE 130 0 1 -0 NPS_CFG_TYPE_USER_BUF_CTRL 0 0 1 -0 NPS_CFG_TYPE_HASH_L2_FDB_REGION_ENTRY_NUM 0 0 49152 -0 NPS_CFG_TYPE_HASH_L3_WITH_IPV6_PREFIX_64_REGION_ENTRY_NUM 0 0 32768 - diff --git a/dockers/docker-orchagent/orchagent.sh b/dockers/docker-orchagent/orchagent.sh index 6c0334bfb38..b66df4d10ca 100755 --- a/dockers/docker-orchagent/orchagent.sh +++ b/dockers/docker-orchagent/orchagent.sh @@ -116,8 +116,6 @@ fi # Add platform specific arguments if necessary if [ "$platform" == "broadcom" ]; then ORCHAGENT_ARGS+="-m $MAC_ADDRESS" -elif [ "$platform" == "nephos" ]; then - ORCHAGENT_ARGS+="-m $MAC_ADDRESS" elif [ "$platform" == "centec" ]; then ORCHAGENT_ARGS+="-m $MAC_ADDRESS" elif [ "$platform" == "barefoot" ]; then diff --git a/dockers/docker-pde/syncd_init_common.sh b/dockers/docker-pde/syncd_init_common.sh index f3a1b2985c4..17ad1310e6e 100755 --- a/dockers/docker-pde/syncd_init_common.sh +++ b/dockers/docker-pde/syncd_init_common.sh @@ -185,11 +185,6 @@ config_syncd_barefoot() ./opt/bfn/install/bin/dma_setup.sh } -config_syncd_nephos() -{ - CMD_ARGS+=" -p $HWSKU_DIR/sai.profile" -} - config_syncd_vs() { CMD_ARGS+=" -p $HWSKU_DIR/sai.profile" @@ -218,8 +213,6 @@ config_syncd() config_syncd_marvell_prestera elif [ "$SONIC_ASIC_TYPE" == "barefoot" ]; then config_syncd_barefoot - elif [ "$SONIC_ASIC_TYPE" == "nephos" ]; then - config_syncd_nephos elif [ "$SONIC_ASIC_TYPE" == "vs" ]; then config_syncd_vs elif [ "$SONIC_ASIC_TYPE" == "marvell-teralynx" ]; then @@ -237,4 +230,3 @@ config_syncd() [ -r $PLATFORM_DIR/syncd.conf ] && . $PLATFORM_DIR/syncd.conf } - diff --git a/files/build_templates/per_namespace/syncd.service.j2 b/files/build_templates/per_namespace/syncd.service.j2 index 16cfc4b2510..eed7bdfb63d 100644 --- a/files/build_templates/per_namespace/syncd.service.j2 +++ b/files/build_templates/per_namespace/syncd.service.j2 @@ -11,9 +11,6 @@ After=topology.service {% if sonic_asic_platform == 'broadcom' %} Requires=opennsl-modules.service After=opennsl-modules.service -{% elif sonic_asic_platform == 'nephos' %} -Requires=nps-modules.service -After=nps-modules.service {% elif sonic_asic_platform == 'clounix' %} Requires=clx-modules.service After=clx-modules.service diff --git a/platform/clounix/clounix-modules/modules/init.d/clx-modules b/platform/clounix/clounix-modules/modules/init.d/clx-modules index d78678b7b46..a965c0801d0 100755 --- a/platform/clounix/clounix-modules/modules/init.d/clx-modules +++ b/platform/clounix/clounix-modules/modules/init.d/clx-modules @@ -25,12 +25,8 @@ start) echo "25165824" > /proc/sys/net/core/wmem_max fi - if ! modprobe clx_dev ; then - modprobe nps_dev - fi - if ! modprobe clx_netif ; then - modprobe nps_netif - fi + modprobe clx_dev + modprobe clx_netif echo "done." ;; @@ -38,12 +34,8 @@ start) stop) echo -n "Unload clx kernel modules... " - if ! rmmod clx_netif ; then - rmmod nps_netif - fi - if ! rmmod clx_dev ; then - rmmod nps_dev - fi + rmmod clx_netif + rmmod clx_dev echo "done." ;; @@ -59,4 +51,3 @@ force-reload|restart) esac exit 0 - diff --git a/platform/nephos/docker-syncd-nephos-rpc.mk b/platform/nephos/docker-syncd-nephos-rpc.mk deleted file mode 100644 index 340c2bdc8dd..00000000000 --- a/platform/nephos/docker-syncd-nephos-rpc.mk +++ /dev/null @@ -1,26 +0,0 @@ -# docker image for nephos syncd with rpc - -DOCKER_SYNCD_NEPHOS_RPC = docker-syncd-nephos-rpc.gz -$(DOCKER_SYNCD_NEPHOS_RPC)_PATH = $(PLATFORM_PATH)/docker-syncd-nephos-rpc -$(DOCKER_SYNCD_NEPHOS_RPC)_DEPENDS += $(SYNCD_RPC) $(LIBTHRIFT) $(PTF) -ifeq ($(INSTALL_DEBUG_TOOLS), y) -$(DOCKER_SYNCD_NEPHOS_RPC)_DEPENDS += $(SYNCD_RPC_DBG) \ - $(LIBSWSSCOMMON_DBG) \ - $(LIBSAIMETADATA_DBG) \ - $(LIBSAIREDIS_DBG) -endif -$(DOCKER_SYNCD_NEPHOS_RPC)_FILES += $(DSSERVE) $(NPX_DIAG) -$(DOCKER_SYNCD_NEPHOS_RPC)_LOAD_DOCKERS += $(DOCKER_SYNCD_BASE) -SONIC_DOCKER_IMAGES += $(DOCKER_SYNCD_NEPHOS_RPC) -SONIC_STRETCH_DOCKERS += $(DOCKER_SYNCD_NEPHOS_RPC) -ifeq ($(ENABLE_SYNCD_RPC),y) -SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_SYNCD_NEPHOS_RPC) -endif - -$(DOCKER_SYNCD_NEPHOS_RPC)_CONTAINER_NAME = syncd -$(DOCKER_SYNCD_NEPHOS_RPC)_VERSION = 1.0.0+rpc -$(DOCKER_SYNCD_NEPHOS_RPC)_PACKAGE_NAME = syncd -$(DOCKER_SYNCD_NEPHOS_RPC)_RUN_OPT += --privileged -t -$(DOCKER_SYNCD_NEPHOS_RPC)_RUN_OPT += -v /host/machine.conf:/etc/machine.conf -$(DOCKER_SYNCD_NEPHOS_RPC)_RUN_OPT += -v /var/run/docker-syncd:/var/run/sswsyncd -$(DOCKER_SYNCD_NEPHOS_RPC)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro diff --git a/platform/nephos/docker-syncd-nephos-rpc/Dockerfile.j2 b/platform/nephos/docker-syncd-nephos-rpc/Dockerfile.j2 deleted file mode 100644 index 3f09bd7524f..00000000000 --- a/platform/nephos/docker-syncd-nephos-rpc/Dockerfile.j2 +++ /dev/null @@ -1,55 +0,0 @@ -FROM docker-syncd-nephos-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} - -## Make apt-get non-interactive -ENV DEBIAN_FRONTEND=noninteractive - -COPY \ -{% for deb in docker_syncd_nephos_rpc_debs.split(' ') -%} -debs/{{ deb }}{{' '}} -{%- endfor -%} -debs/ - -RUN apt-get purge -y syncd - -## Pre-install the fundamental packages -RUN apt-get update \ - && apt-get -y install \ - net-tools \ - python-pip \ - build-essential \ - libssl-dev \ - libffi-dev \ - python-dev \ - wget \ - cmake \ - libqt5core5a \ - libqt5network5 \ - libboost-atomic1.71.0 - -RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ -{% for deb in docker_syncd_nephos_rpc_debs.split(' ') -%} -dpkg_apt debs/{{ deb }}{{'; '}} -{%- endfor %} - -RUN wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ - && tar xvfz 1.0.0.tar.gz \ - && cd nanomsg-1.0.0 \ - && mkdir -p build \ - && cmake . \ - && make install \ - && ldconfig \ - && cd .. \ - && rm -fr nanomsg-1.0.0 \ - && rm -f 1.0.0.tar.gz \ - && pip install cffi==1.7.0 \ - && pip install --upgrade cffi==1.7.0 \ - && pip install nnpy \ - && mkdir -p /opt \ - && cd /opt \ - && wget https://raw.githubusercontent.com/p4lang/ptf/master/ptf_nn/ptf_nn_agent.py \ - && apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y \ - && rm -rf /root/deps - -COPY ["ptf_nn_agent.conf", "/etc/supervisor/conf.d/"] - -ENTRYPOINT ["/usr/local/bin/supervisord"] diff --git a/platform/nephos/docker-syncd-nephos-rpc/ptf_nn_agent.conf b/platform/nephos/docker-syncd-nephos-rpc/ptf_nn_agent.conf deleted file mode 100644 index fa1ed0eb162..00000000000 --- a/platform/nephos/docker-syncd-nephos-rpc/ptf_nn_agent.conf +++ /dev/null @@ -1,10 +0,0 @@ -[program:ptf_nn_agent] -command=/usr/bin/python /opt/ptf_nn_agent.py --device-socket 1@tcp://0.0.0.0:10900 -i 1-3@Ethernet12 --set-iface-rcv-buffer=109430400 -process_name=ptf_nn_agent -stdout_logfile=/tmp/ptf_nn_agent.out.log -stderr_logfile=/tmp/ptf_nn_agent.err.log -redirect_stderr=false -autostart=true -autorestart=true -startsecs=1 -numprocs=1 diff --git a/platform/nephos/docker-syncd-nephos.mk b/platform/nephos/docker-syncd-nephos.mk deleted file mode 100644 index 25befe90c17..00000000000 --- a/platform/nephos/docker-syncd-nephos.mk +++ /dev/null @@ -1,22 +0,0 @@ -# docker image for nephos syncd - -DOCKER_SYNCD_PLATFORM_CODE = nephos -include $(PLATFORM_PATH)/../template/docker-syncd-base.mk - -$(DOCKER_SYNCD_BASE)_DEPENDS += $(SYNCD) -$(DOCKER_SYNCD_BASE)_FILES += $(DSSERVE) $(NPX_DIAG) - -$(DOCKER_SYNCD_BASE)_DBG_DEPENDS += $(SYNCD_DBG) \ - $(LIBSWSSCOMMON_DBG) \ - $(LIBSAIMETADATA_DBG) \ - $(LIBSAIREDIS_DBG) - -SONIC_STRETCH_DOCKERS += $(DOCKER_SYNCD_BASE) -SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_SYNCD_BASE_DBG) - -$(DOCKER_SYNCD_BASE)_VERSION = 1.0.0 -$(DOCKER_SYNCD_BASE)_PACKAGE_NAME = syncd - -$(DOCKER_SYNCD_BASE)_RUN_OPT += -v /var/run/docker-syncd:/var/run/sswsyncd - -$(DOCKER_SYNCD_BASE)_BASE_IMAGE_FILES += npx_diag:/usr/bin/npx_diag diff --git a/platform/nephos/docker-syncd-nephos/Dockerfile.j2 b/platform/nephos/docker-syncd-nephos/Dockerfile.j2 deleted file mode 100755 index f7117b33667..00000000000 --- a/platform/nephos/docker-syncd-nephos/Dockerfile.j2 +++ /dev/null @@ -1,44 +0,0 @@ -FROM docker-config-engine-stretch-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} - -ARG docker_container_name - -## Make apt-get non-interactive -ENV DEBIAN_FRONTEND=noninteractive - -RUN apt-get update - -COPY \ -{% for deb in docker_syncd_nephos_debs.split(' ') -%} -debs/{{ deb }}{{' '}} -{%- endfor -%} -debs/ - -COPY \ -{% for deb in docker_syncd_nephos_pydebs.split(' ') -%} -python-debs/{{ deb }}{{' '}} -{%- endfor -%} -debs/ - -RUN apt-get install -y libxml2 - -RUN dpkg -i \ -{% for deb in docker_syncd_nephos_debs.split(' ') -%} -debs/{{ deb }}{{' '}} -{%- endfor %} - -##RUN dpkg -i \ -##{% for deb in docker_syncd_nephos_pydebs.split(' ') -%} -##debs/{{ deb }}{{' '}} -##{%- endfor %} - -COPY ["files/dsserve", "files/npx_diag", "/usr/bin/"] -RUN chmod +x /usr/bin/npx_diag /usr/bin/dsserve - -COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] -COPY ["critical_processes", "/etc/supervisor/"] - -## Clean up -RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y -RUN rm -rf /debs - -ENTRYPOINT ["/usr/local/bin/supervisord"] diff --git a/platform/nephos/docker-syncd-nephos/base_image_files/npx_diag b/platform/nephos/docker-syncd-nephos/base_image_files/npx_diag deleted file mode 100755 index 876bc1816ec..00000000000 --- a/platform/nephos/docker-syncd-nephos/base_image_files/npx_diag +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -docker exec -i syncd npx_diag "$@" diff --git a/platform/nephos/docker-syncd-nephos/critical_processes b/platform/nephos/docker-syncd-nephos/critical_processes deleted file mode 100644 index d1163a9c304..00000000000 --- a/platform/nephos/docker-syncd-nephos/critical_processes +++ /dev/null @@ -1,2 +0,0 @@ -program:dsserve -program:syncd diff --git a/platform/nephos/docker-syncd-nephos/supervisord.conf b/platform/nephos/docker-syncd-nephos/supervisord.conf deleted file mode 100644 index 286600e33a2..00000000000 --- a/platform/nephos/docker-syncd-nephos/supervisord.conf +++ /dev/null @@ -1,43 +0,0 @@ -[supervisord] -logfile_maxbytes=1MB -logfile_backups=2 -nodaemon=true - -[eventlistener:dependent-startup] -command=python2 -m supervisord_dependent_startup -autostart=true -autorestart=unexpected -startretries=0 -exitcodes=0,3 -events=PROCESS_STATE -buffer_size=1024 - -[eventlistener:supervisor-proc-exit-listener] -command=/usr/bin/supervisor-proc-exit-listener-rs --container-name syncd -events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING,PROCESS_STATE_FATAL -autostart=true -autorestart=unexpected -buffer_size=1024 - -[program:rsyslogd] -command=/usr/sbin/rsyslogd -n -iNONE -priority=1 -autostart=false -autorestart=unexpected -stdout_logfile=NONE -stdout_syslog=true -stderr_logfile=NONE -stderr_syslog=true -dependent_startup=true - -[program:syncd] -command=/usr/bin/syncd_start.sh -priority=2 -autostart=false -autorestart=false -stdout_logfile=NONE -stdout_syslog=true -stderr_logfile=NONE -stderr_syslog=true -dependent_startup=true -dependent_startup_wait_for=rsyslogd:running diff --git a/platform/nephos/libsaithrift-dev.mk b/platform/nephos/libsaithrift-dev.mk deleted file mode 100644 index e21ebc5c682..00000000000 --- a/platform/nephos/libsaithrift-dev.mk +++ /dev/null @@ -1,20 +0,0 @@ -# libsaithrift-dev package - -SAI_VER = 0.9.4 - -LIBSAITHRIFT_DEV = libsaithrift-dev_$(SAI_VER)_amd64.deb -$(LIBSAITHRIFT_DEV)_SRC_PATH = $(SRC_PATH)/sonic-sairedis/SAI -$(LIBSAITHRIFT_DEV)_DEPENDS += $(LIBTHRIFT) $(LIBTHRIFT_DEV) $(PYTHON_THRIFT) $(THRIFT_COMPILER) $(NEPHOS_SAI) $(NEPHOS_SAI_DEV) -$(LIBSAITHRIFT_DEV)_RDEPENDS += $(LIBTHRIFT) $(NEPHOS_SAI) -SONIC_DPKG_DEBS += $(LIBSAITHRIFT_DEV) - -PYTHON_SAITHRIFT = python-saithrift_$(SAI_VER)_amd64.deb -$(eval $(call add_extra_package,$(LIBSAITHRIFT_DEV),$(PYTHON_SAITHRIFT))) - -SAISERVER = saiserver_$(SAI_VER)_amd64.deb -$(SAISERVER)_RDEPENDS += $(LIBTHRIFT) $(NEPHOS_SAI) -$(eval $(call add_extra_package,$(LIBSAITHRIFT_DEV),$(SAISERVER))) - -SAISERVER_DBG = saiserver-dbg_$(SAI_VER)_amd64.deb -$(SAISERVER_DBG)_RDEPENDS += $(SAISERVER) -$(eval $(call add_extra_package,$(LIBSAITHRIFT_DEV),$(SAISERVER_DBG))) diff --git a/platform/nephos/nephos-modules.mk b/platform/nephos/nephos-modules.mk deleted file mode 100644 index 5e055537a42..00000000000 --- a/platform/nephos/nephos-modules.mk +++ /dev/null @@ -1,9 +0,0 @@ -# Nephos Platform modules - -NPS_PLATFORM_MODULE_VERSION = 1.0.1 - -NEPHOS_MODULE = nephos-modules_$(NPS_PLATFORM_MODULE_VERSION)_amd64.deb -$(NEPHOS_MODULE)_SRC_PATH = $(PLATFORM_PATH)/nephos-modules -$(NEPHOS_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) -SONIC_DPKG_DEBS += $(NEPHOS_MODULE) - diff --git a/platform/nephos/nephos-modules/README.md b/platform/nephos/nephos-modules/README.md deleted file mode 100644 index 6bb4cf6bf65..00000000000 --- a/platform/nephos/nephos-modules/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# Nephos-modules -Device drivers for support of Nephos platform for the SONiC project diff --git a/platform/nephos/nephos-modules/debian/changelog b/platform/nephos/nephos-modules/debian/changelog deleted file mode 100644 index 94c7aa7d391..00000000000 --- a/platform/nephos/nephos-modules/debian/changelog +++ /dev/null @@ -1,11 +0,0 @@ -nephos-modules (1.0.1) unstable; urgency=low - - * Upgrade ko version to 3.0.0 - --- Support Tue, 17 Mar 2020 15:54:00 +0800 - -nephos-modules (1.0.0) unstable; urgency=low - - * Initial release - --- Support Fri, 15 Mar 2019 15:54:00 +0800 diff --git a/platform/nephos/nephos-modules/debian/compat b/platform/nephos/nephos-modules/debian/compat deleted file mode 100644 index ec635144f60..00000000000 --- a/platform/nephos/nephos-modules/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/platform/nephos/nephos-modules/debian/control b/platform/nephos/nephos-modules/debian/control deleted file mode 100644 index 1b485d808f3..00000000000 --- a/platform/nephos/nephos-modules/debian/control +++ /dev/null @@ -1,12 +0,0 @@ -Source: nephos-modules -Section: main -Priority: extra -Maintainer: support -Build-Depends: debhelper (>= 8.0.0), bzip2 -Standards-Version: 3.9.3 - -Package: nephos-modules -Architecture: amd64 -Depends: linux-image-4.19.0-12-2-amd64-unsigned -Description: kernel modules for nephos asic - diff --git a/platform/nephos/nephos-modules/debian/rules b/platform/nephos/nephos-modules/debian/rules deleted file mode 100755 index acf96c80e10..00000000000 --- a/platform/nephos/nephos-modules/debian/rules +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/make -f - -export INSTALL_MOD_DIR:=extra - -PACKAGE_NAME := nephos-modules -KVERSION ?= $(shell uname -r) -KERNEL_SRC := /lib/modules/$(KVERSION) -SERVICE_DIR := service -INITD_DIR := init.d -MODULE_SRC := $(shell pwd)/modules -CURRENT_DIR := $(cd "$(dirname "$0")"; pwd) - -%: - dh $@ - -override_dh_auto_build: - make -C $(MODULE_SRC) - -override_dh_auto_install: - dh_installdirs -p$(PACKAGE_NAME) $(KERNEL_SRC)/extra - cp $(MODULE_SRC)/build/module/*.ko debian/$(PACKAGE_NAME)/$(KERNEL_SRC)/extra - dh_installdirs -p$(PACKAGE_NAME) /lib/systemd/system - cp $(MODULE_SRC)/service/*.service debian/$(PACKAGE_NAME)/lib/systemd/system/ - dh_installdirs -p$(PACKAGE_NAME) /etc/init.d - cp $(MODULE_SRC)/init.d/* debian/$(PACKAGE_NAME)/etc/init.d/ - -override_dh_usrlocal: - -override_dh_pysupport: - -override_dh_clean: - dh_clean - test -d $(MODULE_SRC)/build || rm -rf $(MODULE_SRC)/build - diff --git a/platform/nephos/nephos-modules/modules/Makefile b/platform/nephos/nephos-modules/modules/Makefile deleted file mode 100755 index 8351996b04e..00000000000 --- a/platform/nephos/nephos-modules/modules/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -################################################################################ -# Copyright (C) 2019 Nephos, Inc. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of version 2 of the GNU General Public -# License as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# version 2 along with this program. -################################################################################ -NPS_MODULES_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) -SRC_PATH := $(NPS_MODULES_DIR)/src -INC_PATH := $(SRC_PATH)/inc -################################################################################ -include $(NPS_MODULES_DIR)/config.mk -################################################################################ -MODULE_OUTPUT_DIR := $(BUILD_OUTPUT_DIR)/module -################################################################################ -all: compile install -################################################################################ -EXTRA_CFLAGS += -I$(INC_PATH) -EXTRA_CFLAGS += -DNPS_EN_NETIF -EXTRA_CFLAGS += -DNPS_EN_TAURUS -EXTRA_CFLAGS += -DNPS_LINUX_USER_MODE -EXTRA_CFLAGS += -DNPS_EN_LITTLE_ENDIAN -ifeq ($(shell uname -m),x86_64) -EXTRA_CFLAGS += -DNPS_EN_HOST_64_BIT_LITTLE_ENDIAN -else -EXTRA_CFLAGS += -DNPS_EN_HOST_32_BIT_LITTLE_ENDIAN -endif -################################################################################ -include $(SRC_PATH)/make.mk -################################################################################ -compile:: - -install:: - $(TEST_PATH) $(MODULE_OUTPUT_DIR) || $(MKDIR) $(MODULE_OUTPUT_DIR) - $(MV) $(BUILD_OUTPUT_DIR)/$(DEV_MODULE_NAME).ko $(MODULE_OUTPUT_DIR)/$(DEV_MODULE_NAME).ko - $(MV) $(BUILD_OUTPUT_DIR)/$(NETIF_MODULE_NAME).ko $(MODULE_OUTPUT_DIR)/$(NETIF_MODULE_NAME).ko - -clean:: - $(RM) $(BUILD_OUTPUT_DIR) - -.PHONY: all compile install clean -.NOTPARALLEL: all compile install clean diff --git a/platform/nephos/nephos-modules/modules/README b/platform/nephos/nephos-modules/modules/README deleted file mode 100644 index b2e6fb14793..00000000000 --- a/platform/nephos/nephos-modules/modules/README +++ /dev/null @@ -1,32 +0,0 @@ -################################################################################ -# Copyright (C) 2019 Nephos, Inc. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of version 2 of the GNU General Public -# License as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# version 2 along with this program. -################################################################################ -Step 1~4 show how to build and execute NPS kernel modules. - -1. Modify nps-modules/config.mk to specify the output directory to BUILD_OUTPUT_DIR. - The default output path is nps-modules/build. - -2. Compile: - cd nps-modules/ && make - -3. The output kernel modules will be found in $(BUILD_OUTPUT_DIR)/modules/ - - nps_dev.ko - - nps_netif.ko - -4. Load modules: - (1) insmod nps_dev.ko - (2) insmod nps_netif.ko - - Note that the module inserting sequence cannot be changed. diff --git a/platform/nephos/nephos-modules/modules/config.mk b/platform/nephos/nephos-modules/modules/config.mk deleted file mode 100755 index b7a106ea0a4..00000000000 --- a/platform/nephos/nephos-modules/modules/config.mk +++ /dev/null @@ -1,30 +0,0 @@ -################################################################################ -# Copyright (C) 2019 Nephos, Inc. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of version 2 of the GNU General Public -# License as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# version 2 along with this program. -################################################################################ -BUILD_OUTPUT_DIR := $(NPS_MODULES_DIR)/build -################################################################################ -#OS_PATH := /lib/modules/$(shell uname -r)/build -OS_PATH := /lib/modules/$(KVERSION)/build - -################################################################################ -MAKE := make -RM := rm -rf -MKDIR := mkdir -p -CP := cp -MV := mv -TEST_PATH := test -d -################################################################################ -export BUILD_OUTPUT_DIR -export OS_PATH diff --git a/platform/nephos/nephos-modules/modules/init.d/nps-modules b/platform/nephos/nephos-modules/modules/init.d/nps-modules deleted file mode 100755 index d6f841ee02e..00000000000 --- a/platform/nephos/nephos-modules/modules/init.d/nps-modules +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# This script load/unload nps kernel modules - -### BEGIN INIT INFO -# Provides: load-nps-modules -# Required-Start: -# Required-Stop: -# Should-Start: -# Should-Stop: -# Default-Start: S -# Default-Stop: 0 6 -# Short-Description: Load nps kernel modules -### END INIT INFO - -case "$1" in -start) - echo -n "Load nps kernel modules... " - - RMEM_SIZE=`cat /proc/sys/net/core/rmem_max` - if [ $RMEM_SIZE -lt 8388608 ]; then - echo "8388608" > /proc/sys/net/core/rmem_max - fi - WMEM_SIZE=`cat /proc/sys/net/core/wmem_max` - if [ $WMEM_SIZE -lt 25165824 ]; then - echo "25165824" > /proc/sys/net/core/wmem_max - fi - - modprobe nps_dev - modprobe nps_netif - - echo "done." - ;; - -stop) - echo -n "Unload nps kernel modules... " - - rmmod nps_netif - rmmod nps_dev - - echo "done." - ;; - -force-reload|restart) - echo "Not supported" - ;; - -*) - echo "Usage: /etc/init.d/nps-modules {start|stop}" - exit 1 - ;; -esac - -exit 0 - diff --git a/platform/nephos/nephos-modules/modules/service/nps-modules.service b/platform/nephos/nephos-modules/modules/service/nps-modules.service deleted file mode 100644 index 22aa9a7510c..00000000000 --- a/platform/nephos/nephos-modules/modules/service/nps-modules.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Nephos kernel modules init -After=local-fs.target -Before=syncd.service - -[Service] -Type=oneshot -ExecStart=-/etc/init.d/nps-modules start -ExecStop=-/etc/init.d/nps-modules stop -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target diff --git a/platform/nephos/nephos-modules/modules/src/hal_tau_pkt_knl.c b/platform/nephos/nephos-modules/modules/src/hal_tau_pkt_knl.c deleted file mode 100755 index a67b1d5f886..00000000000 --- a/platform/nephos/nephos-modules/modules/src/hal_tau_pkt_knl.c +++ /dev/null @@ -1,6409 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: hal_tau_pkt_knl.c - * PURPOSE: - * To provide Linux kernel for PDMA TX/RX control. - * - * NOTES: - * - */ - -/***************************************************************************** - * INCLUDE FILE DECLARATIONS - ***************************************************************************** - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* netif */ -#include -#include -#if defined(NETIF_EN_NETLINK) -#include -#endif -#include - -/* nps_sdk */ -#include - -/***************************************************************************** - * CHIP DEPENDENT VARIABLES - ***************************************************************************** - */ -/* Interrupt */ -#define HAL_TAU_PKT_ERR_REG(__unit__) (_hal_tau_pkt_intr_vec[0].intr_reg) -#define HAL_TAU_PKT_TCH_REG(__unit__, __channel__) (_hal_tau_pkt_intr_vec[1 + (__channel__)].intr_reg) -#define HAL_TAU_PKT_RCH_REG(__unit__, __channel__) (_hal_tau_pkt_intr_vec[5 + (__channel__)].intr_reg) - -#define HAL_TAU_PKT_ERR_EVENT(__unit__) (&_hal_tau_pkt_intr_vec[0].intr_event) -#define HAL_TAU_PKT_TCH_EVENT(__unit__, __channel__) (&_hal_tau_pkt_intr_vec[1 + (__channel__)].intr_event) -#define HAL_TAU_PKT_RCH_EVENT(__unit__, __channel__) (&_hal_tau_pkt_intr_vec[5 + (__channel__)].intr_event) - -#define HAL_TAU_PKT_ERR_CNT(__unit__) (_hal_tau_pkt_intr_vec[0].intr_cnt) -#define HAL_TAU_PKT_TCH_CNT(__unit__, __channel__) (_hal_tau_pkt_intr_vec[1 + (__channel__)].intr_cnt) -#define HAL_TAU_PKT_RCH_CNT(__unit__, __channel__) (_hal_tau_pkt_intr_vec[5 + (__channel__)].intr_cnt) - - -/* This flag value will be specified when user inserts kernel module. */ -#define HAL_TAU_PKT_DBG_ERR (0x1UL << 0) -#define HAL_TAU_PKT_DBG_TX (0x1UL << 1) -#define HAL_TAU_PKT_DBG_RX (0x1UL << 2) -#define HAL_TAU_PKT_DBG_INTF (0x1UL << 3) -#define HAL_TAU_PKT_DBG_PROFILE (0x1UL << 4) -#define HAL_TAU_PKT_DBG_COMMON (0x1UL << 5) -#define HAL_TAU_PKT_DBG_NETLINK (0x1UL << 6) - -/* Will be set when inserting kernel module */ -UI32_T ext_dbg_flag = 0; - -#define HAL_TAU_PKT_DBG(__flag__, ...) do \ -{ \ - if (0 != ((__flag__) & (ext_dbg_flag))) \ - { \ - osal_printf(__VA_ARGS__); \ - } \ -}while (0) - -typedef struct -{ - UI32_T intr_reg; - NPS_SEMAPHORE_ID_T intr_event; - UI32_T intr_cnt; - -} HAL_TAU_PKT_INTR_VEC_T; - -typedef struct HAL_TAU_PKT_PROFILE_NODE_S -{ - HAL_TAU_PKT_NETIF_PROFILE_T *ptr_profile; - struct HAL_TAU_PKT_PROFILE_NODE_S *ptr_next_node; - -} HAL_TAU_PKT_PROFILE_NODE_T; - -typedef struct -{ - HAL_TAU_PKT_NETIF_INTF_T meta; - struct net_device *ptr_net_dev; - HAL_TAU_PKT_PROFILE_NODE_T *ptr_profile_list; /* the profiles binding to this interface */ - -} HAL_TAU_PKT_NETIF_PORT_DB_T; - - -static HAL_TAU_PKT_INTR_VEC_T _hal_tau_pkt_intr_vec[] = -{ - { /* 0: PDMA_ERR */ 1UL << 0, 0x0, 0 }, - { /* 1: TX_CH0 */ 1UL << 28, 0x0, 0 }, - { /* 2: TX_CH1 */ 1UL << 29, 0x0, 0 }, - { /* 3: TX_CH2 */ 1UL << 30, 0x0, 0 }, - { /* 4: TX_CH3 */ 1UL << 31, 0x0, 0 }, - { /* 5: RX_CH0 */ 1UL << 12, 0x0, 0 }, - { /* 6: RX_CH1 */ 1UL << 13, 0x0, 0 }, - { /* 7: RX_CH2 */ 1UL << 14, 0x0, 0 }, - { /* 8: RX_CH3 */ 1UL << 15, 0x0, 0 }, -}; - -/***************************************************************************** - * NAMING CONSTANT DECLARATIONS - ***************************************************************************** - */ -/* Sleep Time Definitions */ -#define HAL_TAU_PKT_TX_DEQUE_SLEEP() osal_sleepThread(1000) /* us */ -#define HAL_TAU_PKT_RX_DEQUE_SLEEP() osal_sleepThread(1000) /* us */ -#define HAL_TAU_PKT_TX_ENQUE_RETRY_SLEEP() osal_sleepThread(1000) /* us */ -#define HAL_TAU_PKT_RX_ENQUE_RETRY_SLEEP() osal_sleepThread(1000) /* us */ -#define HAL_TAU_PKT_ALLOC_MEM_RETRY_SLEEP() osal_sleepThread(1000) /* us */ - -/* Network Device Definitions */ -/* In case that the watchdog alarm during warm-boot if intf isn't killed */ -#define HAL_TAU_PKT_TX_TIMEOUT (30*HZ) -#define HAL_TAU_PKT_MAX_ETH_FRAME_SIZE (HAL_TAU_PKT_RX_MAX_LEN) -#define HAL_TAU_PKT_MAX_PORT_NUM (HAL_PORT_NUM + 1) /* CPU port */ - -#define HAL_TAU_PKT_NET_PROFILE_NUM_MAX (256) - -static HAL_TAU_PKT_NETIF_PROFILE_T *_ptr_hal_tau_pkt_profile_entry[HAL_TAU_PKT_NET_PROFILE_NUM_MAX] = {0}; -static HAL_TAU_PKT_NETIF_PORT_DB_T _hal_tau_pkt_port_db[HAL_TAU_PKT_MAX_PORT_NUM]; - -/***************************************************************************** - * MACRO VLAUE DECLARATIONS - ***************************************************************************** - */ - -/***************************************************************************** - * MACRO FUNCTION DECLARATIONS - ***************************************************************************** - */ -/*---------------------------------------------------------------------------*/ -#define HAL_TAU_PKT_GET_DRV_CB_PTR(unit) (&_hal_tau_pkt_drv_cb[unit]) -/*---------------------------------------------------------------------------*/ -#define HAL_TAU_PKT_GET_TX_CB_PTR(unit) (&_hal_tau_pkt_tx_cb[unit]) -#define HAL_TAU_PKT_GET_TX_PDMA_PTR(unit, channel) (&_hal_tau_pkt_tx_cb[unit].pdma[channel]) -#define HAL_TAU_PKT_GET_TX_GPD_PTR(unit, channel, gpd) (&_hal_tau_pkt_tx_cb[unit].pdma[channel].ptr_gpd_align_start_addr[gpd]) -/*---------------------------------------------------------------------------*/ -#define HAL_TAU_PKT_GET_RX_CB_PTR(unit) (&_hal_tau_pkt_rx_cb[unit]) -#define HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, channel) (&_hal_tau_pkt_rx_cb[unit].pdma[channel]) -#define HAL_TAU_PKT_GET_RX_GPD_PTR(unit, channel, gpd) (&_hal_tau_pkt_rx_cb[unit].pdma[channel].ptr_gpd_align_start_addr[gpd]) -/*---------------------------------------------------------------------------*/ -#define HAL_TAU_PKT_GET_PORT_DB(port) (&_hal_tau_pkt_port_db[port]) -#define HAL_TAU_PKT_GET_PORT_PROFILE_LIST(port) (_hal_tau_pkt_port_db[port].ptr_profile_list) -#define HAL_TAU_PKT_GET_PORT_NETDEV(port) _hal_tau_pkt_port_db[port].ptr_net_dev - -/***************************************************************************** - * DATA TYPE DECLARATIONS - ***************************************************************************** - */ -/* ----------------------------------------------------------------------------------- General structure */ -typedef struct -{ - UI32_T unit; - UI32_T channel; - -} HAL_TAU_PKT_ISR_COOKIE_T; - -typedef struct -{ - NPS_HUGE_T que_id; - NPS_SEMAPHORE_ID_T sema; - UI32_T len; /* Software CPU queue maximum length. */ - UI32_T weight; /* The weight for thread de-queue algorithm. */ - -} HAL_TAU_PKT_SW_QUEUE_T; - -typedef struct -{ - /* handleErrorTask */ - NPS_THREAD_ID_T err_task_id; - - /* INTR dispatcher */ - NPS_ISRLOCK_ID_T intr_lock; - UI32_T intr_bitmap; - -#define HAL_TAU_PKT_INIT_DRV (1UL << 0) -#define HAL_TAU_PKT_INIT_TASK (1UL << 1) -#define HAL_TAU_PKT_INIT_INTR (1UL << 2) -#define HAL_TAU_PKT_INIT_RX_START (1UL << 3) - /* a bitmap to record the init status */ - UI32_T init_flag; - -} HAL_TAU_PKT_DRV_CB_T; - -/* ----------------------------------------------------------------------------------- TX structure */ -typedef struct -{ - /* NPS_SEMAPHORE_ID_T sema; */ - - /* since the Tx GPD ring may be accessed by multiple process including - * ndo_start_xmit (SW IRQ), it must be protected with an ISRLOCK - * instead of the original semaphore - */ - NPS_ISRLOCK_ID_T ring_lock; - - UI32_T used_idx; /* SW send index = LAMP simulate the Tx HW index */ - UI32_T free_idx; /* SW free index */ - UI32_T used_gpd_num; - UI32_T free_gpd_num; - UI32_T gpd_num; - - HAL_TAU_PKT_TX_GPD_T *ptr_gpd_start_addr; - HAL_TAU_PKT_TX_GPD_T *ptr_gpd_align_start_addr; - BOOL_T err_flag; - - /* ASYNC */ - HAL_TAU_PKT_TX_SW_GPD_T **pptr_sw_gpd_ring; - HAL_TAU_PKT_TX_SW_GPD_T **pptr_sw_gpd_bulk; /* temporary store packets to be enque */ - - /* SYNC_INTR */ - NPS_SEMAPHORE_ID_T sync_intr_sema; - -} HAL_TAU_PKT_TX_PDMA_T; - -typedef struct -{ - HAL_TAU_PKT_TX_WAIT_T wait_mode; - HAL_TAU_PKT_TX_PDMA_T pdma[HAL_TAU_PKT_TX_CHANNEL_LAST]; - HAL_TAU_PKT_TX_CNT_T cnt; - - /* handleTxDoneTask */ - NPS_THREAD_ID_T isr_task_id[HAL_TAU_PKT_TX_CHANNEL_LAST]; - HAL_TAU_PKT_ISR_COOKIE_T isr_task_cookie[HAL_TAU_PKT_TX_CHANNEL_LAST]; - - /* txTask */ - HAL_TAU_PKT_SW_QUEUE_T sw_queue; - NPS_SEMAPHORE_ID_T sync_sema; - NPS_THREAD_ID_T task_id; - BOOL_T running; /* TRUE when Init txTask - * FALSE when Destroy txTask - */ - /* to block net intf Tx in driver level since netif_tx_disable() - * cannot always prevent intf from Tx in time - */ - BOOL_T net_tx_allowed; - -} HAL_TAU_PKT_TX_CB_T; - -/* ----------------------------------------------------------------------------------- RX structure */ -typedef struct -{ - NPS_SEMAPHORE_ID_T sema; - UI32_T cur_idx; /* SW free index */ - UI32_T gpd_num; - - HAL_TAU_PKT_RX_GPD_T *ptr_gpd_start_addr; - HAL_TAU_PKT_RX_GPD_T *ptr_gpd_align_start_addr; - BOOL_T err_flag; - struct sk_buff **pptr_skb_ring; -} HAL_TAU_PKT_RX_PDMA_T; - -typedef struct -{ - /* Rx system configuration */ - UI32_T buf_len; - - HAL_TAU_PKT_RX_SCHED_T sched_mode; - HAL_TAU_PKT_RX_PDMA_T pdma[HAL_TAU_PKT_RX_CHANNEL_LAST]; - HAL_TAU_PKT_RX_CNT_T cnt; - - /* handleRxDoneTask */ - NPS_THREAD_ID_T isr_task_id[HAL_TAU_PKT_RX_CHANNEL_LAST]; - HAL_TAU_PKT_ISR_COOKIE_T isr_task_cookie[HAL_TAU_PKT_RX_CHANNEL_LAST]; - - /* rxTask */ - HAL_TAU_PKT_SW_QUEUE_T sw_queue[HAL_TAU_PKT_RX_QUEUE_NUM]; - UI32_T deque_idx; - NPS_SEMAPHORE_ID_T sync_sema; - NPS_THREAD_ID_T task_id; - NPS_SEMAPHORE_ID_T deinit_sema; /* To sync-up the Rx-stop and thread flush queues */ - BOOL_T running; /* TRUE when rxStart - * FALSE when rxStop - */ - -} HAL_TAU_PKT_RX_CB_T; - -/* ----------------------------------------------------------------------------------- Network Device */ -struct net_device_priv -{ - struct net_device *ptr_net_dev; - struct net_device_stats stats; - UI32_T unit; - UI32_T id; - UI32_T port; - UI16_T vlan; - UI32_T speed; -}; - -typedef enum -{ - HAL_TAU_PKT_DEST_NETDEV = 0, - HAL_TAU_PKT_DEST_SDK, -#if defined(NETIF_EN_NETLINK) - HAL_TAU_PKT_DEST_NETLINK, -#endif - HAL_TAU_PKT_DEST_DROP, - HAL_TAU_PKT_DEST_LAST -} HAL_TAU_PKT_DEST_T; - -/***************************************************************************** - * GLOBAL VARIABLE DECLARATIONS - ***************************************************************************** - */ - -/***************************************************************************** - * STATIC VARIABLE DECLARATIONS - ***************************************************************************** - */ -/*---------------------------------------------------------------------------*/ -static HAL_TAU_PKT_DRV_CB_T _hal_tau_pkt_drv_cb[NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM]; -static HAL_TAU_PKT_TX_CB_T _hal_tau_pkt_tx_cb[NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM]; -static HAL_TAU_PKT_RX_CB_T _hal_tau_pkt_rx_cb[NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM]; -/*---------------------------------------------------------------------------*/ - -/***************************************************************************** - * LOCAL SUBPROGRAM DECLARATIONS - ***************************************************************************** - */ -/* ----------------------------------------------------------------------------------- Interrupt */ -static NPS_ERROR_NO_T -_hal_tau_pkt_enableIntr( - const UI32_T unit, - const UI32_T intr_bitmap) -{ - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - NPS_IRQ_FLAGS_T irq_flag = 0; - UI32_T intr_en = 0; - - osal_takeIsrLock(&ptr_cb->intr_lock, &irq_flag); - osal_mdc_readPciReg(unit, HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_CP_COMMON_INT_EN_HI), &intr_en, sizeof(intr_en)); - intr_en |= intr_bitmap; - osal_mdc_writePciReg(unit, HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_CP_COMMON_INT_EN_HI), &intr_en, sizeof(intr_en)); - osal_giveIsrLock(&ptr_cb->intr_lock, &irq_flag); - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_disableIntr( - const UI32_T unit, - const UI32_T intr_bitmap) -{ - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - NPS_IRQ_FLAGS_T irq_flag = 0; - UI32_T intr_en = 0; - - osal_takeIsrLock(&ptr_cb->intr_lock, &irq_flag); - osal_mdc_readPciReg(unit, HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_CP_COMMON_INT_EN_HI), &intr_en, sizeof(intr_en)); - intr_en &= ~intr_bitmap; - osal_mdc_writePciReg(unit, HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_CP_COMMON_INT_EN_HI), &intr_en, sizeof(intr_en)); - osal_giveIsrLock(&ptr_cb->intr_lock, &irq_flag); - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_maskIntr( - const UI32_T unit, - const UI32_T intr_bitmap) -{ - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - NPS_IRQ_FLAGS_T irq_flag = 0; - - osal_takeIsrLock(&ptr_cb->intr_lock, &irq_flag); - osal_mdc_writePciReg(unit, HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_CP_COMMON_INT_MASK_CLR_HI), &intr_bitmap, sizeof(intr_bitmap)); - osal_giveIsrLock(&ptr_cb->intr_lock, &irq_flag); - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_unmaskIntr( - const UI32_T unit, - const UI32_T intr_bitmap) -{ - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - NPS_IRQ_FLAGS_T irq_flag = 0; - - osal_takeIsrLock(&ptr_cb->intr_lock, &irq_flag); - osal_mdc_writePciReg(unit, HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_CP_COMMON_INT_MASK_SET_HI), &intr_bitmap, sizeof(intr_bitmap)); - osal_giveIsrLock(&ptr_cb->intr_lock, &irq_flag); - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_dispatcher( - void *ptr_cookie) -{ - UI32_T unit = (UI32_T)((NPS_HUGE_T)ptr_cookie); - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - NPS_IRQ_FLAGS_T irq_flag = 0; - - UI32_T idx = 0, vec = sizeof(_hal_tau_pkt_intr_vec) / sizeof(HAL_TAU_PKT_INTR_VEC_T); - UI32_T intr_mask = ptr_cb->intr_bitmap; - UI32_T intr_unmask = 0; - UI32_T intr_status = 0; - - /* MASK, READ and CLEAR PKT IRQs */ - osal_takeIsrLock(&ptr_cb->intr_lock, &irq_flag); - osal_mdc_writePciReg(unit, HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_CP_COMMON_INT_MASK_CLR_HI), &intr_mask, sizeof(UI32_T)); - osal_mdc_readPciReg (unit, HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_CP_COMMON_INT_STAT_HI), &intr_status, sizeof(UI32_T)); - intr_status = intr_status & intr_mask; - osal_mdc_writePciReg(unit, HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_CP_COMMON_INT_CLR_HI), &intr_status, sizeof(UI32_T)); - osal_giveIsrLock(&ptr_cb->intr_lock, &irq_flag); - - /* Module thread handle and unmask the interrupt */ - intr_unmask = intr_status ^ intr_mask; - if (0x0 != intr_status) - { - for (idx = 0; idx < vec; idx++) - { - if (_hal_tau_pkt_intr_vec[idx].intr_reg & intr_status) - { - osal_triggerEvent(&_hal_tau_pkt_intr_vec[idx].intr_event); - _hal_tau_pkt_intr_vec[idx].intr_cnt++; - } - } - } - - /* UNMASK other PKT IRQs */ - osal_takeIsrLock(&ptr_cb->intr_lock, &irq_flag); - osal_mdc_writePciReg(unit, HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_CP_COMMON_INT_MASK_SET_HI), &intr_unmask, sizeof(UI32_T)); - osal_giveIsrLock(&ptr_cb->intr_lock, &irq_flag); - - return (NPS_E_OK); -} - -/* ----------------------------------------------------------------------------------- RW HW Regs */ -/* FUNCTION NAME: _hal_tau_pkt_startTxChannelReg - * PURPOSE: - * To issue "START" command to the target TX channel. - * INPUT: - * unit -- The unit ID - * channel -- The target TX channel - * gpd_num -- The GPD ring length of the channel - * OUTPUT: - * None. - * RETURN: - * NPS_E_OK -- Successfully configure the register. - * NPS_E_OTHERS -- Configure the register failed. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_startTxChannelReg( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel, - const UI32_T gpd_num) -{ - HAL_TAU_PKT_TCH_CMD_REG_T tch_cmd; - - tch_cmd.reg = 0x0; - tch_cmd.field.tch_start = 0x1; - tch_cmd.field.tch_gpd_add_no_lo = gpd_num & 0xff; - tch_cmd.field.tch_gpd_add_no_hi = (gpd_num & 0xff00) >> 8; - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_TCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_TCH_CMD), channel), - &tch_cmd.reg, sizeof(HAL_TAU_PKT_TCH_CMD_REG_T)); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_startRxChannelReg - * PURPOSE: - * To issue "START" command to the target RX channel. - * INPUT: - * unit -- The unit ID - * channel -- The target RX channel - * gpd_num -- The GPD ring length of the channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully configure the register. - * NPS_E_OTHERS -- Configure the register failed. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_startRxChannelReg( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel, - const UI32_T gpd_num) -{ - HAL_TAU_PKT_RCH_CMD_REG_T rch_cmd; - - rch_cmd.reg = 0x0; - rch_cmd.field.rch_start = 0x1; - rch_cmd.field.rch_gpd_add_no_lo = gpd_num & 0xff; - rch_cmd.field.rch_gpd_add_no_hi = (gpd_num & 0xff00) >> 8; - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_RCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_RCH_CMD), channel), - &rch_cmd.reg, sizeof(HAL_TAU_PKT_RCH_CMD_REG_T)); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_resumeTxChannelReg - * PURPOSE: - * To issue "RESUME" command to the target TX channel. - * INPUT: - * unit -- The unit ID - * channel -- The target TX channel - * gpd_num -- The GPD ring length of the channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully configure the register. - * NPS_E_OTHERS -- Configure the register failed. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_resumeTxChannelReg( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel, - const UI32_T gpd_num) -{ - HAL_TAU_PKT_TCH_CMD_REG_T tch_cmd; - - tch_cmd.reg = 0x0; - tch_cmd.field.tch_resume = 0x1; - tch_cmd.field.tch_gpd_add_no_lo = gpd_num & 0xff; - tch_cmd.field.tch_gpd_add_no_hi = (gpd_num & 0xff00) >> 8; - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_TCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_TCH_CMD), channel), - &tch_cmd.reg, sizeof(HAL_TAU_PKT_TCH_CMD_REG_T)); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_resumeRxChannelReg - * PURPOSE: - * To issue "RESUME" command to the target RX channel. - * INPUT: - * unit -- The unit ID - * channel -- The target RX channel - * gpd_num -- The GPD ring length of the channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully configure the register. - * NPS_E_OTHERS -- Configure the register failed. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_resumeRxChannelReg( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel, - const UI32_T gpd_num) -{ - HAL_TAU_PKT_RCH_CMD_REG_T rch_cmd; - - rch_cmd.reg = 0x0; - rch_cmd.field.rch_resume = 0x1; - rch_cmd.field.rch_gpd_add_no_lo = gpd_num & 0xff; - rch_cmd.field.rch_gpd_add_no_hi = (gpd_num & 0xff00) >> 8; - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_RCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_RCH_CMD), channel), - &rch_cmd.reg, sizeof(HAL_TAU_PKT_RCH_CMD_REG_T)); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_stopTxChannelReg - * PURPOSE: - * To issue "STOP" command to the target TX channel. - * INPUT: - * unit -- The unit ID - * channel -- The target TX channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully configure the register. - * NPS_E_OTHERS -- Configure the register failed. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_stopTxChannelReg( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel) -{ - HAL_TAU_PKT_TCH_CMD_REG_T tch_cmd; - - tch_cmd.reg = 0x0; - tch_cmd.field.tch_stop = 0x1; - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_TCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_TCH_CMD), channel), - &tch_cmd.reg, sizeof(HAL_TAU_PKT_TCH_CMD_REG_T)); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_stopRxChannelReg - * PURPOSE: - * To issue "STOP" command to the target RX channel. - * INPUT: - * unit -- The unit ID - * channel -- The target RX channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully configure the register. - * NPS_E_OTHERS -- Configure the register failed. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_stopRxChannelReg( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel) -{ - HAL_TAU_PKT_RCH_CMD_REG_T rch_cmd; - - rch_cmd.reg = 0x0; - rch_cmd.field.rch_stop = 0x1; - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_RCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_RCH_CMD), channel), - &rch_cmd.reg, sizeof(HAL_TAU_PKT_RCH_CMD_REG_T)); - - return (NPS_E_OK); -} - -/* ----------------------------------------------------------------------------------- Init HW Regs */ -/* FUNCTION NAME: _hal_tau_pkt_setTxGpdStartAddrReg - * PURPOSE: - * To configure the start address and the length of target GPD ring of TX channel. - * INPUT: - * unit -- The unit ID - * channel -- The target TX channel - * gpd_start_addr -- The start address of the GPD ring - * gpd_ring_sz -- The size of the GPD ring - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully configure the register. - * NPS_E_OTHERS -- Configure the register failed. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_setTxGpdStartAddrReg( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel, - const NPS_ADDR_T gpd_start_addr, - const UI32_T gpd_ring_sz) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - UI32_T tch_gpd_ring_start_addr_lo = 0; - UI32_T tch_gpd_ring_start_addr_hi = 0; - UI32_T tch_gpd_ring_size = 0; - - /* Configure the low 32-bit address. */ - tch_gpd_ring_start_addr_lo = (UI32_T)NPS_ADDR_64_LOW(gpd_start_addr); - - rc = osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_TCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_TCH_GPD_RING_START_ADDR_LO), channel), - &tch_gpd_ring_start_addr_lo, sizeof(UI32_T)); - - /* Configure the high 32-bit address. */ - if (NPS_E_OK == rc) - { - tch_gpd_ring_start_addr_hi = (UI32_T)NPS_ADDR_64_HI(gpd_start_addr); - - rc = osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_TCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_TCH_GPD_RING_START_ADDR_HI), channel), - &tch_gpd_ring_start_addr_hi, sizeof(UI32_T)); - } - - /* Configure the GPD ring size. */ - if (NPS_E_OK == rc) - { - tch_gpd_ring_size = gpd_ring_sz; - - rc = osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_TCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_TCH_GPD_RING_SIZE), channel), - &tch_gpd_ring_size, sizeof(UI32_T)); - } - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_setRxGpdStartAddrReg - * PURPOSE: - * To configure the start address and the length of target GPD ring of RX channel. - * INPUT: - * unit -- The unit ID - * channel -- The target RX channel - * gpd_start_addr -- The start address of the GPD ring - * gpd_ring_sz -- The size of the GPD ring - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully configure the register. - * NPS_E_OTHERS -- Configure the register failed. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_setRxGpdStartAddrReg( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel, - const NPS_ADDR_T gpd_start_addr, - const UI32_T gpd_ring_sz) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - UI32_T rch_gpd_ring_start_addr_lo = 0; - UI32_T rch_gpd_ring_start_addr_hi = 0; - UI32_T rch_gpd_ring_size = 0; - - /* Configure the low 32-bit address. */ - rch_gpd_ring_start_addr_lo = (UI32_T)NPS_ADDR_64_LOW(gpd_start_addr); - - rc = osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_RCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_RCH_GPD_RING_START_ADDR_LO), channel), - &rch_gpd_ring_start_addr_lo, sizeof(UI32_T)); - - /* Configure the high 32-bit address. */ - if (NPS_E_OK == rc) - { - rch_gpd_ring_start_addr_hi = (UI32_T)NPS_ADDR_64_HI(gpd_start_addr); - - rc = osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_RCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_RCH_GPD_RING_START_ADDR_HI), channel), - &rch_gpd_ring_start_addr_hi, sizeof(UI32_T)); - } - - /* Configure the GPD ring size. */ - if (NPS_E_OK == rc) - { - rch_gpd_ring_size = gpd_ring_sz; - - rc = osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_RCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_RCH_GPD_RING_SIZE), channel), - &rch_gpd_ring_size, sizeof(UI32_T)); - } - - return (rc); -} - -/* ----------------------------------------------------------------------------------- ISR HW Regs */ -/* FUNCTION NAME: _hal_tau_pkt_maskAllTxL2IsrReg - * PURPOSE: - * To mask all the TX L2 interrupts for the specified channel. - * INPUT: - * unit -- The unit ID - * channel -- The target TX channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully mask all the TX L2 interrupts. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_maskAllTxL2IsrReg( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel) -{ - UI32_T reg = 0; - - HAL_TAU_PKT_CLR_BITMAP(reg, - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_HWO_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_CHKSM_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_NO_OVFL_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_DMA_READ_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_BUF_SIZE_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_RUNT_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_OVSZ_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_LEN_MISMATCH_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_PKTPL_DMA_READ_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_COS_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_GT255_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_PFC | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_CREDIT_UDFL_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_DMA_WRITE_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_STOP_CMD_CPLT); - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_TCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_TCH_INT_MASK), channel), - ®, sizeof(UI32_T)); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_maskAllRxL2IsrReg - * PURPOSE: - * To mask all the L2 interrupts for the specified channel. - * INPUT: - * unit -- The unit ID - * channel -- The target RX channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully mask all the L2 interrupts. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_maskAllRxL2IsrReg( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel) -{ - UI32_T reg = 0; - - HAL_TAU_PKT_CLR_BITMAP(reg, - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_LOW | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_EMPTY | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_ERROR | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_GPD_CHKSM_ERROR | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_DMA_READ_ERROR | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_DMA_WRITE_ERROR | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_STOP_CMD_CPLT | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_GPD_GT255_ERROR | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_TOD_UNINIT | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_PKT_ERROR_DROP | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_UDSZ_DROP | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_OVSZ_DROP | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_CMDQ_OVF_DROP | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_FIFO_OVF_DROP); - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_RCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_RCH_INT_MASK), channel), - ®, sizeof(UI32_T)); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_unmaskAllTxL2IsrReg - * PURPOSE: - * To unmask all the TX L2 interrupts for the specified channel. - * INPUT: - * unit -- The unit ID - * channel -- The target TX channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully unmask all the TX L2 interrupts. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_unmaskAllTxL2IsrReg( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel) -{ - UI32_T reg = 0; - - HAL_TAU_PKT_SET_BITMAP(reg, - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_HWO_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_CHKSM_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_NO_OVFL_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_DMA_READ_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_BUF_SIZE_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_RUNT_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_OVSZ_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_LEN_MISMATCH_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_PKTPL_DMA_READ_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_COS_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_GT255_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_PFC | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_CREDIT_UDFL_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_DMA_WRITE_ERROR | - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_STOP_CMD_CPLT); - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_TCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_TCH_INT_MASK), channel), - ®, sizeof(UI32_T)); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_unmaskAllRxL2IsrReg - * PURPOSE: - * To unmask all the L2 interrupts for the specified channel. - * INPUT: - * unit -- The unit ID - * channel -- The target RX channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully unmask all the L2 interrupts. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_unmaskAllRxL2IsrReg( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel) -{ - UI32_T reg = 0; - - HAL_TAU_PKT_SET_BITMAP(reg, - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_LOW | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_EMPTY | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_ERROR | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_GPD_CHKSM_ERROR | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_DMA_READ_ERROR | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_DMA_WRITE_ERROR | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_STOP_CMD_CPLT | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_GPD_GT255_ERROR | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_TOD_UNINIT | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_PKT_ERROR_DROP | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_UDSZ_DROP | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_OVSZ_DROP | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_CMDQ_OVF_DROP | - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_FIFO_OVF_DROP); - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_RCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_RCH_INT_MASK), channel), - ®, sizeof(UI32_T)); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_clearTxL2IsrStatusReg - * PURPOSE: - * To clear the status of TX L2 interrupts for the specified channel. - * INPUT: - * unit -- The unit ID - * channel -- The target TX channel - * isr_bitmap -- The bitmap used to specify the target ISRs - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully clear L1 ISR status. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_clearTxL2IsrStatusReg( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel, - const HAL_TAU_PKT_TX_CHANNEL_L2_ISR_T isr_bitmap) -{ - UI32_T reg = 0; - - HAL_TAU_PKT_SET_BITMAP(reg, isr_bitmap); - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_TCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_TCH_INT_CLR), channel), - ®, sizeof(UI32_T)); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_clearRxL2IsrStatusReg - * PURPOSE: - * To clear the status of RX L2 interrupts for the specified channel. - * INPUT: - * unit -- The unit ID - * channel -- The target RX channel - * isr_bitmap -- The bitmap used to specify the target ISRs - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully clear RX L2 ISR status. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_clearRxL2IsrStatusReg( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel, - const HAL_TAU_PKT_RX_CHANNEL_L2_ISR_T isr_bitmap) -{ - UI32_T reg = 0; - - HAL_TAU_PKT_SET_BITMAP(reg, isr_bitmap); - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_PDMA_RCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_RCH_INT_CLR), channel), - ®, sizeof(UI32_T)); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: hal_tau_pkt_getTxIntrCnt - * PURPOSE: - * To get the PDMA TX interrupt counters of the target channel. - * INPUT: - * unit -- The unit ID - * channel -- The target channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully get the counters. - * NOTES: - * None - */ -NPS_ERROR_NO_T -hal_tau_pkt_getTxIntrCnt( - const UI32_T unit, - const UI32_T channel, - UI32_T *ptr_intr_cnt) -{ - *ptr_intr_cnt = HAL_TAU_PKT_TCH_CNT(unit, channel); - return (NPS_E_OK); -} - -/* FUNCTION NAME: hal_tau_pkt_getRxIntrCnt - * PURPOSE: - * To get the PDMA RX interrupt counters of the target channel. - * INPUT: - * unit -- The unit ID - * channel -- The target channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully get the counters. - * NOTES: - * None - */ -NPS_ERROR_NO_T -hal_tau_pkt_getRxIntrCnt( - const UI32_T unit, - const UI32_T channel, - UI32_T *ptr_intr_cnt) -{ - *ptr_intr_cnt = HAL_TAU_PKT_RCH_CNT(unit, channel); - return (NPS_E_OK); -} - -/* FUNCTION NAME: hal_tau_pkt_getTxKnlCnt - * PURPOSE: - * To get the PDMA TX counters of the target channel. - * INPUT: - * unit -- The unit ID - * ptr_cookie -- Pointer of the TX cookie - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully get the counters. - * NOTES: - * None - */ -NPS_ERROR_NO_T -hal_tau_pkt_getTxKnlCnt( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_CH_CNT_COOKIE_T *ptr_cookie) -{ - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - - osal_io_copyToUser(&ptr_cookie->tx_cnt, &ptr_tx_cb->cnt, sizeof(HAL_TAU_PKT_TX_CNT_T)); - return (NPS_E_OK); -} - -/* FUNCTION NAME: hal_tau_pkt_getRxKnlCnt - * PURPOSE: - * To get the PDMA RX counters of the target channel. - * INPUT: - * unit -- The unit ID - * ptr_cookie -- Pointer of the RX cookie - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully get the counters. - * NOTES: - * None - */ -NPS_ERROR_NO_T -hal_tau_pkt_getRxKnlCnt( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_CH_CNT_COOKIE_T *ptr_cookie) -{ - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - - osal_io_copyToUser(&ptr_cookie->rx_cnt, &ptr_rx_cb->cnt, sizeof(HAL_TAU_PKT_RX_CNT_T)); - return (NPS_E_OK); -} - -/* FUNCTION NAME: hal_tau_pkt_clearTxKnlCnt - * PURPOSE: - * To clear the PDMA TX counters of the target channel. - * INPUT: - * unit -- The unit ID - * ptr_cookie -- Pointer of the TX cookie - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully clear the counters. - * NOTES: - * None - */ -NPS_ERROR_NO_T -hal_tau_pkt_clearTxKnlCnt( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_TX_COOKIE_T *ptr_cookie) -{ - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - - osal_memset(&ptr_tx_cb->cnt, 0, sizeof(HAL_TAU_PKT_TX_CNT_T)); - return (NPS_E_OK); -} - -/* FUNCTION NAME: hal_tau_pkt_clearRxKnlCnt - * PURPOSE: - * To clear the PDMA RX counters of the target channel. - * INPUT: - * unit -- The unit ID - * ptr_cookie -- Pointer of the RX cookie - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully clear the counters. - * NOTES: - * None - */ -NPS_ERROR_NO_T -hal_tau_pkt_clearRxKnlCnt( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_RX_COOKIE_T *ptr_cookie) -{ - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - - osal_memset(&ptr_rx_cb->cnt, 0, sizeof(HAL_TAU_PKT_RX_CNT_T)); - return (NPS_E_OK); -} - -/* FUNCTION NAME: hal_tau_pkt_setPortAttr - * PURPOSE: - * To set the port attributes such as status or speeds. - * INPUT: - * unit -- The unit ID - * ptr_cookie -- Pointer of the Port cookie - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully set the attributes. - * NOTES: - * None - */ -NPS_ERROR_NO_T -hal_tau_pkt_setPortAttr( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_PORT_COOKIE_T *ptr_cookie) -{ -#define HAL_TAU_PKT_PORT_STATUS_UP (1) -#define HAL_TAU_PKT_PORT_STATUS_DOWN (0) - struct net_device *ptr_net_dev; - struct net_device_priv *ptr_priv; - UI32_T port; - UI32_T status; - NPS_PORT_SPEED_T speed; - - osal_io_copyFromUser(&port, &ptr_cookie->port, sizeof(UI32_T)); - osal_io_copyFromUser(&status, &ptr_cookie->status, sizeof(UI32_T)); - osal_io_copyFromUser(&speed, &ptr_cookie->speed, sizeof(NPS_PORT_SPEED_T)); - - ptr_net_dev = HAL_TAU_PKT_GET_PORT_NETDEV(port); - if ((NULL != ptr_net_dev) && (portspeed = SPEED_1000; - break; - case NPS_PORT_SPEED_10G: - ptr_priv->speed = SPEED_10000; - break; - case NPS_PORT_SPEED_25G: - ptr_priv->speed = 25000; - break; - case NPS_PORT_SPEED_40G: - ptr_priv->speed = 40000; - break; - case NPS_PORT_SPEED_50G: - ptr_priv->speed = 50000; - break; - case NPS_PORT_SPEED_100G: - ptr_priv->speed = 100000; - break; - default: - break; - } - } - return (NPS_E_OK); -} - -static void -_hal_tau_pkt_lockRxChannelAll( - const UI32_T unit) -{ - UI32_T rch; - HAL_TAU_PKT_RX_PDMA_T *ptr_rx_pdma; - - for (rch = 0; rch < HAL_TAU_PKT_RX_CHANNEL_LAST; rch++) - { - ptr_rx_pdma = HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, rch); - osal_takeSemaphore(&ptr_rx_pdma->sema, NPS_SEMAPHORE_WAIT_FOREVER); - } -} - -static void -_hal_tau_pkt_unlockRxChannelAll( - const UI32_T unit) -{ - UI32_T rch; - HAL_TAU_PKT_RX_PDMA_T *ptr_rx_pdma; - - for (rch = 0; rch < HAL_TAU_PKT_RX_CHANNEL_LAST; rch++) - { - ptr_rx_pdma = HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, rch); - osal_giveSemaphore(&ptr_rx_pdma->sema); - } -} - -#if defined(NETIF_EN_NETLINK) - -static NPS_ERROR_NO_T -_hal_tau_pkt_setIntfProperty( - const UI32_T unit, - HAL_TAU_PKT_NL_IOCTL_COOKIE_T *ptr_cookie) -{ - UI32_T intf_id; - NETIF_NL_INTF_PROPERTY_T property; - UI32_T param0; - UI32_T param1; - NPS_ERROR_NO_T rc; - - osal_io_copyFromUser(&intf_id, &ptr_cookie->intf_id, sizeof(UI32_T)); - osal_io_copyFromUser(&property, &ptr_cookie->property, sizeof(NETIF_NL_INTF_PROPERTY_T)); - osal_io_copyFromUser(¶m0, &ptr_cookie->param0, sizeof(UI32_T)); - osal_io_copyFromUser(¶m1, &ptr_cookie->param1, sizeof(UI32_T)); - - _hal_tau_pkt_lockRxChannelAll(unit); - - rc = netif_nl_setIntfProperty(unit, intf_id, property, param0, param1); - - _hal_tau_pkt_unlockRxChannelAll(unit); - - osal_io_copyToUser(&ptr_cookie->rc, &rc, sizeof(NPS_ERROR_NO_T)); - - return (rc); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_getIntfProperty( - const UI32_T unit, - HAL_TAU_PKT_NL_IOCTL_COOKIE_T *ptr_cookie) -{ - UI32_T intf_id; - NETIF_NL_INTF_PROPERTY_T property; - UI32_T param0; - UI32_T param1; - NPS_ERROR_NO_T rc; - - osal_io_copyFromUser(&intf_id, &ptr_cookie->intf_id, sizeof(UI32_T)); - osal_io_copyFromUser(&property, &ptr_cookie->property, sizeof(NETIF_NL_INTF_PROPERTY_T)); - osal_io_copyFromUser(¶m0, &ptr_cookie->param0, sizeof(UI32_T)); - - rc = netif_nl_getIntfProperty(unit, intf_id, property, ¶m0, ¶m1); - - osal_io_copyToUser(&ptr_cookie->param0, ¶m0, sizeof(UI32_T)); - osal_io_copyToUser(&ptr_cookie->param1, ¶m1, sizeof(UI32_T)); - osal_io_copyToUser(&ptr_cookie->rc, &rc, sizeof(NPS_ERROR_NO_T)); - - return (rc); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_createNetlink( - const UI32_T unit, - HAL_TAU_PKT_NL_IOCTL_COOKIE_T *ptr_cookie) -{ - NETIF_NL_NETLINK_T netlink; - UI32_T netlink_id; - NPS_ERROR_NO_T rc; - - osal_io_copyFromUser(&netlink, &ptr_cookie->netlink, sizeof(NETIF_NL_NETLINK_T)); - - _hal_tau_pkt_lockRxChannelAll(unit); - - rc = netif_nl_createNetlink(unit, &netlink, &netlink_id); - - _hal_tau_pkt_unlockRxChannelAll(unit); - - osal_io_copyToUser(&ptr_cookie->netlink.id, &netlink_id, sizeof(UI32_T)); - osal_io_copyToUser(&ptr_cookie->rc, &rc, sizeof(NPS_ERROR_NO_T)); - - return (rc); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_destroyNetlink( - const UI32_T unit, - HAL_TAU_PKT_NL_IOCTL_COOKIE_T *ptr_cookie) -{ - UI32_T netlink_id; - NPS_ERROR_NO_T rc; - - osal_io_copyFromUser(&netlink_id, &ptr_cookie->netlink.id, sizeof(UI32_T)); - - _hal_tau_pkt_lockRxChannelAll(unit); - - rc = netif_nl_destroyNetlink(unit, netlink_id); - - _hal_tau_pkt_unlockRxChannelAll(unit); - - osal_io_copyToUser(&ptr_cookie->rc, &rc, sizeof(NPS_ERROR_NO_T)); - - return (rc); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_getNetlink( - const UI32_T unit, - HAL_TAU_PKT_NL_IOCTL_COOKIE_T *ptr_cookie) -{ - UI32_T id; - NETIF_NL_NETLINK_T netlink; - NPS_ERROR_NO_T rc; - - osal_io_copyFromUser(&id, &ptr_cookie->netlink.id, sizeof(UI32_T)); - - rc = netif_nl_getNetlink(unit, id, &netlink); - if (NPS_E_OK == rc) - { - osal_io_copyToUser(&ptr_cookie->netlink, &netlink, sizeof(NETIF_NL_NETLINK_T)); - } - else - { - rc = NPS_E_ENTRY_NOT_FOUND; - } - - osal_io_copyToUser(&ptr_cookie->rc, &rc, sizeof(NPS_ERROR_NO_T)); - - return (NPS_E_OK); -} - -#endif -/* ----------------------------------------------------------------------------------- independent func */ -/* FUNCTION NAME: _hal_tau_pkt_enQueue - * PURPOSE: - * To enqueue the target data. - * INPUT: - * ptr_que -- Pointer for the target queue - * ptr_data -- Pointer for the data to be enqueued - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully enqueue the data. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_enQueue( - HAL_TAU_PKT_SW_QUEUE_T *ptr_que, - void *ptr_data) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - - osal_takeSemaphore(&ptr_que->sema, NPS_SEMAPHORE_WAIT_FOREVER); - rc = osal_que_enque(&ptr_que->que_id, ptr_data); - osal_giveSemaphore(&ptr_que->sema); - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_deQueue - * PURPOSE: - * To dequeue the target data. - * INPUT: - * ptr_que -- Pointer for the target queue - * pptr_data -- Pointer for the data pointer to be dequeued - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully dequeue the data. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_deQueue( - HAL_TAU_PKT_SW_QUEUE_T *ptr_que, - void **pptr_data) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - - osal_takeSemaphore(&ptr_que->sema, NPS_SEMAPHORE_WAIT_FOREVER); - rc = osal_que_deque(&ptr_que->que_id, pptr_data); - osal_giveSemaphore(&ptr_que->sema); - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_getQueueCount - * PURPOSE: - * To obtain the current GPD number in the target RX queue. - * INPUT: - * ptr_que -- Pointer for the target queue - * ptr_count -- Pointer for the data count - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully obtain the GPD count. - * NPS_E_BAD_PARAMETER -- Parameter pointer is null. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_getQueueCount( - HAL_TAU_PKT_SW_QUEUE_T *ptr_que, - UI32_T *ptr_count) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - - osal_takeSemaphore(&ptr_que->sema, NPS_SEMAPHORE_WAIT_FOREVER); - osal_que_getCount(&ptr_que->que_id, ptr_count); - osal_giveSemaphore(&ptr_que->sema); - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_allocRxPayloadBuf - * PURPOSE: - * To allocate the RX packet payload buffer for the GPD. - * INPUT: - * unit -- The unit ID - * channel -- The target RX channel - * gpd_idx -- The current GPD index - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully allocate the buffer. - * NPS_E_NO_MEMORY -- Allocate the buffer failed. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_allocRxPayloadBuf( - const UI32_T unit, - const UI32_T channel, - const UI32_T gpd_idx) -{ - NPS_ERROR_NO_T rc = NPS_E_NO_MEMORY; - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - volatile HAL_TAU_PKT_RX_GPD_T *ptr_rx_gpd = HAL_TAU_PKT_GET_RX_GPD_PTR(unit, channel, gpd_idx); - NPS_ADDR_T phy_addr = 0; - - HAL_TAU_PKT_RX_PDMA_T *ptr_rx_pdma = HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, channel); - struct sk_buff *ptr_skb = NULL; - - ptr_skb = osal_skb_alloc(ptr_rx_cb->buf_len); - if (NULL != ptr_skb) - { - /* map skb to dma */ - phy_addr = osal_skb_mapDma(ptr_skb, DMA_FROM_DEVICE); - if (0x0 == phy_addr) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_ERR, - "u=%u, rxch=%u, skb dma map err, size=%u\n", - unit, channel, ptr_skb->len); - osal_skb_free(ptr_skb); - rc = NPS_E_NO_MEMORY; - } - else - { - ptr_rx_pdma->pptr_skb_ring[gpd_idx] = ptr_skb; - rc = NPS_E_OK; - } - } - - if (NPS_E_OK == rc) - { - ptr_rx_gpd->data_buf_addr_hi = NPS_ADDR_64_HI(phy_addr); - ptr_rx_gpd->data_buf_addr_lo = NPS_ADDR_64_LOW(phy_addr); - ptr_rx_gpd->avbl_buf_len = ptr_rx_cb->buf_len; - } - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_freeRxPayloadBuf - * PURPOSE: - * To free the RX packet payload buffer for the GPD. - * INPUT: - * unit -- The unit ID - * channel -- The target RX channel - * gpd_idx -- The current GPD index - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully free the buffer. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_freeRxPayloadBuf( - const UI32_T unit, - const UI32_T channel, - const UI32_T gpd_idx) -{ - NPS_ERROR_NO_T rc = NPS_E_OTHERS; - volatile HAL_TAU_PKT_RX_GPD_T *ptr_rx_gpd = HAL_TAU_PKT_GET_RX_GPD_PTR(unit, channel, gpd_idx); - NPS_ADDR_T phy_addr = 0; - - HAL_TAU_PKT_RX_PDMA_T *ptr_rx_pdma = HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, channel); - struct sk_buff *ptr_skb = NULL; - - phy_addr = NPS_ADDR_32_TO_64(ptr_rx_gpd->data_buf_addr_hi, ptr_rx_gpd->data_buf_addr_lo); - if (0x0 != phy_addr) - { - /* unmap dma */ - ptr_skb = ptr_rx_pdma->pptr_skb_ring[gpd_idx]; - osal_skb_unmapDma(phy_addr, ptr_skb->len, DMA_FROM_DEVICE); - osal_skb_free(ptr_skb); - rc = NPS_E_OK; - } - - if (NPS_E_OK == rc) - { - ptr_rx_gpd->data_buf_addr_hi = 0x0; - ptr_rx_gpd->data_buf_addr_lo = 0x0; - } - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_freeRxPayloadBufGpd - * PURPOSE: - * To free the RX packet payload buffer for the GPD. - * INPUT: - * unit -- The unit ID - * ptr_sw_gpd -- The pointer of RX SW GPD - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully free the buffer. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_freeRxPayloadBufGpd( - const UI32_T unit, - HAL_TAU_PKT_RX_SW_GPD_T *ptr_sw_gpd) -{ - NPS_ERROR_NO_T rc = NPS_E_OTHERS; - NPS_ADDR_T phy_addr = 0; - - struct sk_buff *ptr_skb = NULL; - - phy_addr = NPS_ADDR_32_TO_64(ptr_sw_gpd->rx_gpd.data_buf_addr_hi, ptr_sw_gpd->rx_gpd.data_buf_addr_lo); - if (0x0 != phy_addr) - { - ptr_skb = ptr_sw_gpd->ptr_cookie; - osal_skb_free(ptr_skb); - rc = NPS_E_OK; - } - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_initTxPdmaRing - * PURPOSE: - * To initialize the GPD ring of target TX channel. - * - * INPUT: - * unit -- The unit ID - * channel -- The target TX channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully initialize the GPD ring. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_initTxPdmaRing( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_TX_PDMA_T *ptr_tx_pdma = HAL_TAU_PKT_GET_TX_PDMA_PTR(unit, channel); - volatile HAL_TAU_PKT_TX_GPD_T *ptr_tx_gpd = NULL; - NPS_ADDR_T phy_addr = 0; - UI32_T gpd_idx = 0; - - for (gpd_idx = 0; gpd_idx < ptr_tx_pdma->gpd_num; gpd_idx++) - { - ptr_tx_gpd = HAL_TAU_PKT_GET_TX_GPD_PTR(unit, channel, gpd_idx); - osal_memset((void *)ptr_tx_gpd, 0x0, sizeof(HAL_TAU_PKT_TX_GPD_T)); - ptr_tx_gpd->ioc = HAL_TAU_PKT_IOC_HAS_INTR; - ptr_tx_gpd->ch = HAL_TAU_PKT_CH_LAST_GPD; - ptr_tx_gpd->hwo = HAL_TAU_PKT_HWO_SW_OWN; - osal_dma_flushCache((void *)ptr_tx_gpd, sizeof(HAL_TAU_PKT_TX_GPD_T)); - } - - phy_addr = osal_dma_convertVirtToPhy(ptr_tx_pdma->ptr_gpd_align_start_addr); - rc = _hal_tau_pkt_setTxGpdStartAddrReg(unit, channel, phy_addr, ptr_tx_pdma->gpd_num); - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_initRxPdmaRing - * PURPOSE: - * To initialize the RX GPD ring. - * INPUT: - * unit -- The target unit - * channel -- The target RX channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully initialize the RX GPD ring. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_initRxPdmaRing( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_RX_PDMA_T *ptr_rx_pdma = HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, channel); - volatile HAL_TAU_PKT_RX_GPD_T *ptr_rx_gpd = NULL; - NPS_ADDR_T phy_addr = 0; - UI32_T gpd_idx = 0; - - for (gpd_idx = 0; gpd_idx < ptr_rx_pdma->gpd_num; gpd_idx++) - { - ptr_rx_gpd = HAL_TAU_PKT_GET_RX_GPD_PTR(unit, channel, gpd_idx); - osal_memset((void *)ptr_rx_gpd, 0x0, sizeof(HAL_TAU_PKT_RX_GPD_T)); - ptr_rx_gpd->ioc = HAL_TAU_PKT_IOC_NO_INTR; - ptr_rx_gpd->hwo = HAL_TAU_PKT_HWO_SW_OWN; - osal_dma_flushCache((void *)ptr_rx_gpd, sizeof(HAL_TAU_PKT_RX_GPD_T)); - } - - phy_addr = osal_dma_convertVirtToPhy(ptr_rx_pdma->ptr_gpd_align_start_addr); - rc = _hal_tau_pkt_setRxGpdStartAddrReg(unit, channel, phy_addr, ptr_rx_pdma->gpd_num); - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_initRxPdmaRingBuf - * PURPOSE: - * To de-init the Rx PDMA ring configuration. - * INPUT: - * unit -- The unit ID - * channel -- The target RX channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully de-init the Rx PDMA ring. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_initRxPdmaRingBuf( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - HAL_TAU_PKT_RX_PDMA_T *ptr_rx_pdma = HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, channel); - volatile HAL_TAU_PKT_RX_GPD_T *ptr_rx_gpd = NULL; - UI32_T gpd_idx = 0; - - if (0 == ptr_rx_cb->buf_len) - { - return (NPS_E_BAD_PARAMETER); - } - - for (gpd_idx = 0; gpd_idx < ptr_rx_pdma->gpd_num; gpd_idx++) - { - ptr_rx_gpd = HAL_TAU_PKT_GET_RX_GPD_PTR(unit, channel, gpd_idx); - osal_dma_invalidateCache((void *)ptr_rx_gpd, sizeof(HAL_TAU_PKT_RX_GPD_T)); - - rc = _hal_tau_pkt_allocRxPayloadBuf(unit, channel, gpd_idx); - if (NPS_E_OK == rc) - { - ptr_rx_gpd->ioc = HAL_TAU_PKT_IOC_HAS_INTR; - ptr_rx_gpd->hwo = HAL_TAU_PKT_HWO_HW_OWN; - osal_dma_flushCache((void *)ptr_rx_gpd, sizeof(HAL_TAU_PKT_RX_GPD_T)); - } - else - { - ptr_rx_cb->cnt.no_memory++; - break; - } - } - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_deinitRxPdmaRingBuf - * PURPOSE: - * To de-init the Rx PDMA ring configuration. - * INPUT: - * unit -- The unit ID - * channel -- The target RX channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully de-init the Rx PDMA ring. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_deinitRxPdmaRingBuf( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_RX_PDMA_T *ptr_rx_pdma = HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, channel); - volatile HAL_TAU_PKT_RX_GPD_T *ptr_rx_gpd = NULL; - UI32_T gpd_idx = 0; - - for (gpd_idx = 0; ((gpd_idx < ptr_rx_pdma->gpd_num) && (NPS_E_OK == rc)); gpd_idx++) - { - /* mark the GPD as invalid to prevent Rx-done task to process it */ - ptr_rx_gpd = HAL_TAU_PKT_GET_RX_GPD_PTR(unit, channel, gpd_idx); - ptr_rx_gpd->hwo = HAL_TAU_PKT_HWO_HW_OWN; - osal_dma_flushCache((void *)ptr_rx_gpd, sizeof(HAL_TAU_PKT_RX_GPD_T)); - - rc = _hal_tau_pkt_freeRxPayloadBuf(unit, channel, gpd_idx); - } - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_recoverTxPdma - * PURPOSE: - * To recover the PDMA status to the initial state. - * INPUT: - * unit -- The unit ID - * channel -- The target TX channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully recover PDMA. - * NOTES: - * - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_recoverTxPdma( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_TX_PDMA_T *ptr_tx_pdma = HAL_TAU_PKT_GET_TX_PDMA_PTR(unit, channel); - - /* Release the software GPD ring and configure it again. */ - ptr_tx_pdma->used_idx = 0; - ptr_tx_pdma->free_idx = 0; - ptr_tx_pdma->used_gpd_num = 0; - ptr_tx_pdma->free_gpd_num = ptr_tx_pdma->gpd_num; - - _hal_tau_pkt_stopTxChannelReg(unit, channel); - rc = _hal_tau_pkt_initTxPdmaRing(unit, channel); - _hal_tau_pkt_startTxChannelReg(unit, channel, 0); - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_recoverRxPdma - * PURPOSE: - * To recover the RX PDMA from the error state. - * INPUT: - * unit -- The unit ID - * channel -- The target RX channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully recovery the PDMA. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_recoverRxPdma( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_RX_PDMA_T *ptr_rx_pdma = HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, channel); - - /* Release the software GPD ring and configure it again. */ - ptr_rx_pdma->cur_idx = 0; - - _hal_tau_pkt_stopRxChannelReg(unit, channel); - rc = _hal_tau_pkt_deinitRxPdmaRingBuf(unit, channel); - if (NPS_E_OK != rc) - { - return (rc); - } - rc = _hal_tau_pkt_initRxPdmaRing(unit, channel); - if (NPS_E_OK != rc) - { - return (rc); - } - rc = _hal_tau_pkt_initRxPdmaRingBuf(unit, channel); - if (NPS_E_OK != rc) - { - return (rc); - } - _hal_tau_pkt_startRxChannelReg(unit, channel, ptr_rx_pdma->gpd_num); - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_freeTxGpdList - * PURPOSE: - * To free the TX SW GPD link list. - * INPUT: - * unit -- The unit ID - * ptr_sw_gpd -- The pointer of TX SW GPD - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully free the GPD list. - * NOTES: - * None - */ -static void -_hal_tau_pkt_freeTxGpdList( - UI32_T unit, - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_gpd) -{ - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_gpd_cur = NULL; - - while (NULL != ptr_sw_gpd) - { - ptr_sw_gpd_cur = ptr_sw_gpd; - ptr_sw_gpd = ptr_sw_gpd->ptr_next; - osal_free(ptr_sw_gpd_cur); - } -} - -/* FUNCTION NAME: _hal_tau_pkt_freeRxGpdList - * PURPOSE: - * To free the RX SW GPD link list. - * INPUT: - * unit -- The unit ID - * ptr_sw_gpd -- The pointer of RX SW GPD - * free_payload -- TRUE: To free the buf in SDK, FALSE: in user process. - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully recovery the PDMA. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_freeRxGpdList( - UI32_T unit, - HAL_TAU_PKT_RX_SW_GPD_T *ptr_sw_gpd, - BOOL_T free_payload) -{ - HAL_TAU_PKT_RX_SW_GPD_T *ptr_sw_gpd_cur = NULL; - - while (NULL != ptr_sw_gpd) - { - ptr_sw_gpd_cur = ptr_sw_gpd; - ptr_sw_gpd = ptr_sw_gpd->ptr_next; - if (TRUE == free_payload) - { - _hal_tau_pkt_freeRxPayloadBufGpd(unit, ptr_sw_gpd_cur); - } - osal_free(ptr_sw_gpd_cur); - } - - return (NPS_E_OK); -} - -/* ----------------------------------------------------------------------------------- pkt_drv */ -/* FUNCTION NAME: _hal_tau_pkt_txEnQueueBulk - * PURPOSE: - * To enqueue numbers of packet in the bulk buffer - * INPUT: - * unit -- The unit ID - * channel -- The target channel - * number -- The number of packet to be enqueue - * OUTPUT: - * None - * RETURN: - * None - * NOTES: - * None - */ -static void -_hal_tau_pkt_txEnQueueBulk( - const UI32_T unit, - const UI32_T channel, - const UI32_T number) -{ - HAL_TAU_PKT_TX_PDMA_T *ptr_tx_pdma = HAL_TAU_PKT_GET_TX_PDMA_PTR(unit, channel); - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_gpd = NULL; - UI32_T idx; - - for (idx = 0; idx < number; idx++) - { - ptr_sw_gpd = ptr_tx_pdma->pptr_sw_gpd_bulk[idx]; - ptr_tx_pdma->pptr_sw_gpd_bulk[idx] = NULL; - if (NULL != ptr_sw_gpd->callback) - { - ptr_sw_gpd->callback(unit, ptr_sw_gpd, ptr_sw_gpd->ptr_cookie); - } - } -} - - -/* FUNCTION NAME: _hal_tau_pkt_strictTxDeQueue - * PURPOSE: - * To dequeue the packets based on the strict algorithm. - * INPUT: - * unit -- The unit ID - * ptr_cookie -- Pointer of the TX cookie - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully dequeue the packets. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_strictTxDeQueue( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_TX_COOKIE_T *ptr_cookie) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_gpd = NULL; - NPS_ADDR_T sw_gpd_addr; - UI32_T que_cnt = 0; - - /* get queue count */ - _hal_tau_pkt_getQueueCount(&ptr_tx_cb->sw_queue, &que_cnt); - - /* wait txTask event */ - if (0 == que_cnt) - { - osal_waitEvent(&ptr_tx_cb->sync_sema); - if (FALSE == ptr_tx_cb->running) - { - return (NPS_E_OTHERS); /* deinit */ - } - - ptr_tx_cb->cnt.wait_event++; - - /* re-get queue count */ - _hal_tau_pkt_getQueueCount(&ptr_tx_cb->sw_queue, &que_cnt); - } - - /* deque */ - if (que_cnt > 0) - { - rc = _hal_tau_pkt_deQueue(&ptr_tx_cb->sw_queue, (void **)&ptr_sw_gpd); - if (NPS_E_OK == rc) - { - ptr_tx_cb->cnt.deque_ok++; - - sw_gpd_addr = (NPS_ADDR_T)ptr_sw_gpd->ptr_cookie; - - /* Give the address of pre-saved SW GPD back to userspace */ - osal_io_copyToUser(&ptr_cookie->done_sw_gpd_addr, - &sw_gpd_addr, - sizeof(NPS_ADDR_T)); - - /* free kernel sw_gpd */ - _hal_tau_pkt_freeTxGpdList(unit, ptr_sw_gpd); - } - else - { - ptr_tx_cb->cnt.deque_fail++; - } - } - else - { - /* It may happen at last gpd, return error and do not invoke callback. */ - rc = NPS_E_OTHERS; - } - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_rxCheckReason - * PURPOSE: - * To check the packets to linux kernel/user. - * INPUT: - * ptr_rx_gpd -- Pointer of the RX GPD - * ptr_hit_prof -- Pointer of the hit flag - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully dispatch the packets. - * NOTES: - * Reference to pkt_srv. - */ -static void -_hal_tau_pkt_rxCheckReason( - volatile HAL_TAU_PKT_RX_GPD_T *ptr_rx_gpd, - HAL_TAU_PKT_NETIF_PROFILE_T *ptr_profile, - BOOL_T *ptr_hit_prof) -{ - HAL_PKT_RX_REASON_BITMAP_T *ptr_reason_bitmap = &ptr_profile->reason_bitmap; - UI32_T bitval = 0; - UI32_T bitmap = 0x0; - - if (0 == (ptr_profile->flags & HAL_TAU_PKT_NETIF_PROFILE_FLAGS_REASON)) - { - /* It means that reason doesn't metters */ - *ptr_hit_prof = TRUE; - return; - } - -#define HAL_TAU_PKT_DI_NON_L3_CPU_MIN (HAL_EXCPT_CPU_BASE_ID + HAL_EXCPT_CPU_NON_L3_MIN) -#define HAL_TAU_PKT_DI_NON_L3_CPU_MAX (HAL_EXCPT_CPU_BASE_ID + HAL_EXCPT_CPU_NON_L3_MAX) -#define HAL_TAU_PKT_DI_L3_CPU_MIN (HAL_EXCPT_CPU_BASE_ID + HAL_EXCPT_CPU_L3_MIN) -#define HAL_TAU_PKT_DI_L3_CPU_MAX (HAL_EXCPT_CPU_BASE_ID + HAL_EXCPT_CPU_L3_MAX) - - switch (ptr_rx_gpd->itmh_eth.typ) - { - case HAL_TAU_PKT_TMH_TYPE_ITMH_ETH: - - /* IPP non-L3 exception */ - if (ptr_rx_gpd->itmh_eth.dst_idx >= HAL_TAU_PKT_DI_NON_L3_CPU_MIN && - ptr_rx_gpd->itmh_eth.dst_idx <= HAL_TAU_PKT_DI_NON_L3_CPU_MAX) - { - bitval = ptr_rx_gpd->itmh_eth.dst_idx - HAL_TAU_PKT_DI_NON_L3_CPU_MIN; - bitmap = 1UL << (bitval % 32); - if (0 != (ptr_reason_bitmap->ipp_excpt_bitmap[bitval / 32] & bitmap)) - { - *ptr_hit_prof = TRUE; - break; - } - } - - /* IPP L3 exception */ - if (ptr_rx_gpd->itmh_eth.dst_idx >= HAL_TAU_PKT_DI_L3_CPU_MIN && - ptr_rx_gpd->itmh_eth.dst_idx <= HAL_TAU_PKT_DI_L3_CPU_MAX) - { - bitmap = ptr_rx_gpd->itmh_eth.dst_idx - HAL_TAU_PKT_DI_L3_CPU_MIN; - if (0 != (ptr_reason_bitmap->ipp_l3_excpt_bitmap[0] & bitmap)) - { - *ptr_hit_prof = TRUE; - break; - } - } - - /* IPP cp_to_cpu_bmap */ - bitmap = ptr_rx_gpd->itmh_eth.cp_to_cpu_bmap; - if (0 != (ptr_reason_bitmap->ipp_copy2cpu_bitmap[0] & bitmap)) - { - *ptr_hit_prof = TRUE; - break; - } - - /* IPP cp_to_cpu_rsn */ - bitval = ptr_rx_gpd->itmh_eth.cp_to_cpu_code; - bitmap = 1UL << (bitval % 32); - if (0 != (ptr_reason_bitmap->ipp_rsn_bitmap[bitval / 32] & bitmap)) - { - *ptr_hit_prof = TRUE; - break; - } - break; - - case HAL_TAU_PKT_TMH_TYPE_ITMH_FAB: - case HAL_TAU_PKT_TMH_TYPE_ETMH_FAB: - break; - - case HAL_TAU_PKT_TMH_TYPE_ETMH_ETH: - - /* EPP exception */ - if (1 == ptr_rx_gpd->etmh_eth.redir) - { - bitval = ptr_rx_gpd->etmh_eth.excpt_code_mir_bmap; - bitmap = 1UL << (bitval % 32); - if (0 != (ptr_reason_bitmap->epp_excpt_bitmap[bitval / 32] & bitmap)) - { - *ptr_hit_prof = TRUE; - break; - } - } - - /* EPP cp_to_cpu_bmap */ - bitmap = ((ptr_rx_gpd->etmh_eth.cp_to_cpu_bmap_w0 << 7) | - (ptr_rx_gpd->etmh_eth.cp_to_cpu_bmap_w1)); - if (0 != (ptr_reason_bitmap->epp_copy2cpu_bitmap[0] & bitmap)) - { - *ptr_hit_prof = TRUE; - break; - } - break; - - default: - *ptr_hit_prof = FALSE; - break; - } -} - -static BOOL_T -_hal_tau_pkt_comparePatternWithPayload( - volatile HAL_TAU_PKT_RX_GPD_T *ptr_rx_gpd, - const UI8_T *ptr_pattern, - const UI8_T *ptr_mask, - const UI32_T offset) -{ - NPS_ADDR_T phy_addr = 0; - UI8_T *ptr_virt_addr = NULL; - UI32_T idx; - - /* Get the packet payload */ - phy_addr = NPS_ADDR_32_TO_64(ptr_rx_gpd->data_buf_addr_hi, ptr_rx_gpd->data_buf_addr_lo); - ptr_virt_addr = (C8_T *) osal_dma_convertPhyToVirt(phy_addr); - - for (idx=0; idxflags & (HAL_TAU_PKT_NETIF_PROFILE_FLAGS_PATTERN_0 | - HAL_TAU_PKT_NETIF_PROFILE_FLAGS_PATTERN_1 | - HAL_TAU_PKT_NETIF_PROFILE_FLAGS_PATTERN_2 | - HAL_TAU_PKT_NETIF_PROFILE_FLAGS_PATTERN_3)) != 0) - { - /* Need to compare the payload with at least one of the four patterns */ - /* Pre-assume that the result is positive */ - *ptr_hit_prof = TRUE; - - /* If any of the following comparison fails, the result will be changed to negtive */ - } - else - { - return; - } - - for (idx=0; idxflags & (HAL_TAU_PKT_NETIF_PROFILE_FLAGS_PATTERN_0 << idx))) - { - match = _hal_tau_pkt_comparePatternWithPayload(ptr_rx_gpd, - ptr_profile->pattern[idx], - ptr_profile->mask[idx], - ptr_profile->offset[idx]); - if (TRUE == match) - { - /* Do nothing */ - } - else - { - /* Change the result to negtive */ - *ptr_hit_prof = FALSE; - break; - } - } - } -} - -static void -_hal_tau_pkt_matchUserProfile( - volatile HAL_TAU_PKT_RX_GPD_T *ptr_rx_gpd, - HAL_TAU_PKT_PROFILE_NODE_T *ptr_profile_list, - HAL_TAU_PKT_NETIF_PROFILE_T **pptr_profile_hit) -{ - HAL_TAU_PKT_PROFILE_NODE_T *ptr_curr_node = ptr_profile_list; - BOOL_T hit; - - *pptr_profile_hit = NULL; - - while (NULL != ptr_curr_node) - { - /* 1st match reason */ - _hal_tau_pkt_rxCheckReason(ptr_rx_gpd, ptr_curr_node->ptr_profile, &hit); - if (TRUE == hit) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "rx prof matched by reason\n"); - - /* Then, check pattern */ - _hal_tau_pkt_rxCheckPattern(ptr_rx_gpd, ptr_curr_node->ptr_profile, &hit); - if (TRUE == hit) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "rx prof matched by pattern\n"); - - *pptr_profile_hit = ptr_curr_node->ptr_profile; - break; - } - } - - /* Seach the next profile (priority lower) */ - ptr_curr_node = ptr_curr_node->ptr_next_node; - } -} - -static void -_hal_tau_pkt_getPacketDest( - volatile HAL_TAU_PKT_RX_GPD_T *ptr_rx_gpd, - HAL_TAU_PKT_DEST_T *ptr_dest, - void **pptr_cookie) -{ - UI32_T port; - HAL_TAU_PKT_PROFILE_NODE_T *ptr_profile_list; - HAL_TAU_PKT_NETIF_PROFILE_T *ptr_profile_hit; - - port = ptr_rx_gpd->itmh_eth.igr_phy_port; - ptr_profile_list = HAL_TAU_PKT_GET_PORT_PROFILE_LIST(port); - - _hal_tau_pkt_matchUserProfile(ptr_rx_gpd, - ptr_profile_list, - &ptr_profile_hit); - if (NULL != ptr_profile_hit) - { -#if defined(NETIF_EN_NETLINK) - if (HAL_TAU_PKT_NETIF_RX_DST_NETLINK == ptr_profile_hit->dst_type) - { - *ptr_dest = HAL_TAU_PKT_DEST_NETLINK; - *pptr_cookie = (void *)&ptr_profile_hit->netlink; - } - else - { - *ptr_dest = HAL_TAU_PKT_DEST_SDK; - } -#else - *ptr_dest = HAL_TAU_PKT_DEST_SDK; -#endif - } - else - { - *ptr_dest = HAL_TAU_PKT_DEST_NETDEV; - } -} - -/* FUNCTION NAME: _hal_tau_pkt_rxEnQueue - * PURPOSE: - * To enqueue the packets to multiple queues. - * INPUT: - * unit -- The unit ID - * channel -- The target channel - * ptr_sw_gpd -- Pointer for the SW Rx GPD link list - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully enqueue the packets. - * NOTES: - * None - */ -static void -_hal_tau_pkt_rxEnQueue( - const UI32_T unit, - const UI32_T channel, - HAL_TAU_PKT_RX_SW_GPD_T *ptr_sw_gpd) -{ - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - HAL_TAU_PKT_RX_SW_GPD_T *ptr_sw_first_gpd = ptr_sw_gpd; - void *ptr_virt_addr = NULL; - NPS_ADDR_T phy_addr = 0; - HAL_TAU_PKT_DEST_T dest_type; - - /* skb meta */ - UI32_T port = 0, len = 0, total_len = 0; - struct net_device *ptr_net_dev = NULL; - struct net_device_priv *ptr_priv = NULL; - struct sk_buff *ptr_skb = NULL, *ptr_merge_skb = NULL; - UI32_T copy_offset; - void *ptr_dest; - -#if defined(PERF_EN_TEST) - /* To verify kernel Rx performance */ - if (NPS_E_OK == perf_rxTest()) - { - while (NULL != ptr_sw_gpd) - { - len += (HAL_TAU_PKT_CH_LAST_GPD == ptr_sw_gpd->rx_gpd.ch)? - ptr_sw_gpd->rx_gpd.cnsm_buf_len : ptr_sw_gpd->rx_gpd.avbl_buf_len; - - total_len += len; - - /* unmap dma */ - phy_addr = NPS_ADDR_32_TO_64(ptr_sw_gpd->rx_gpd.data_buf_addr_hi, ptr_sw_gpd->rx_gpd.data_buf_addr_lo); - osal_skb_unmapDma(phy_addr, len, DMA_FROM_DEVICE); - /* next */ - ptr_sw_gpd = ptr_sw_gpd->ptr_next; - } - perf_rxCallback(total_len); - _hal_tau_pkt_freeRxGpdList(unit, ptr_sw_first_gpd, TRUE); - return ; - } -#endif - - _hal_tau_pkt_getPacketDest(&ptr_sw_gpd->rx_gpd, &dest_type, &ptr_dest); - -#if defined(NETIF_EN_NETLINK) - if ((HAL_TAU_PKT_DEST_NETDEV == dest_type) || - (HAL_TAU_PKT_DEST_NETLINK == dest_type)) -#else - if (HAL_TAU_PKT_DEST_NETDEV == dest_type) -#endif - { - /* need to encap the packet as skb */ - ptr_sw_gpd = ptr_sw_first_gpd; - while (NULL != ptr_sw_gpd) - { - len = (HAL_TAU_PKT_CH_LAST_GPD == ptr_sw_gpd->rx_gpd.ch)? - ptr_sw_gpd->rx_gpd.cnsm_buf_len : ptr_sw_gpd->rx_gpd.avbl_buf_len; - - total_len += len; - - /* unmap dma */ - phy_addr = NPS_ADDR_32_TO_64(ptr_sw_gpd->rx_gpd.data_buf_addr_hi, ptr_sw_gpd->rx_gpd.data_buf_addr_lo); - ptr_virt_addr = ptr_sw_gpd->ptr_cookie; - - ptr_skb = (struct sk_buff *)ptr_virt_addr; - - /* note here ptr_skb->len is the total buffer size not means the actual Rx packet len - * it should be updated later - */ - osal_skb_unmapDma(phy_addr, ptr_skb->len, DMA_FROM_DEVICE); - - /* reset ptr_skb->len with real packet len instead of total buffer size */ - if (NULL == ptr_sw_gpd->ptr_next) - { - /* strip CRC padded by asic for the last gpd segment */ - ptr_skb->len = len - ETH_FCS_LEN; - } - else - { - ptr_skb->len = len; - } - - skb_set_tail_pointer(ptr_skb, ptr_skb->len); - - /* next */ - ptr_sw_gpd = ptr_sw_gpd->ptr_next; - } - - port = ptr_sw_first_gpd->rx_gpd.itmh_eth.igr_phy_port; - ptr_net_dev = HAL_TAU_PKT_GET_PORT_NETDEV(port); - - /* if the packet is composed of multiple gpd (skb), need to merge it into a single skb */ - if (NULL != ptr_sw_first_gpd->ptr_next) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_RX, - "u=%u, rxch=%u, rcv pkt size=%u > gpd buf size=%u\n", - unit, channel, total_len, ptr_rx_cb->buf_len); - ptr_merge_skb = osal_skb_alloc(total_len - ETH_FCS_LEN); - if (NULL != ptr_merge_skb) - { - copy_offset = 0; - ptr_sw_gpd = ptr_sw_first_gpd; - while (NULL != ptr_sw_gpd) - { - ptr_skb = (struct sk_buff *)ptr_sw_gpd->ptr_cookie; - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_RX, - "u=%u, rxch=%u, copy size=%u to buf offset=%u\n", - unit, channel, ptr_skb->len, copy_offset); - - memcpy(&(((UI8_T *)ptr_merge_skb->data)[copy_offset]), - ptr_skb->data, ptr_skb->len); - copy_offset += ptr_skb->len; - ptr_sw_gpd = ptr_sw_gpd->ptr_next; - } - /* put the merged skb to ptr_skb for the following process */ - ptr_skb = ptr_merge_skb; - } - else - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_RX), - "u=%u, rxch=%u, alloc skb failed, size=%u\n", - unit, channel, (total_len - ETH_FCS_LEN)); - } - - /* free both sw_gpd and the skb attached on it */ - _hal_tau_pkt_freeRxGpdList(unit, ptr_sw_first_gpd, TRUE); - } - else - { - /* free only sw_gpd */ - _hal_tau_pkt_freeRxGpdList(unit, ptr_sw_first_gpd, FALSE); - } - - /* if NULL netdev, drop the skb */ - if (NULL == ptr_net_dev) - { - ptr_rx_cb->cnt.channel[channel].netdev_miss++; - osal_skb_free(ptr_skb); - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_RX), - "u=%u, rxch=%u, find netdev failed\n", - unit, channel); - return; - } - - /* skb handling */ - ptr_skb->dev = ptr_net_dev; - ptr_skb->pkt_type = PACKET_HOST; /* this packet is for me */ - ptr_skb->ip_summed = CHECKSUM_UNNECESSARY; /* skip checksum */ - - /* send to linux */ - if (dest_type == HAL_TAU_PKT_DEST_NETDEV) - { - /* skip ethernet header only for Linux net interface*/ - ptr_skb->protocol = eth_type_trans(ptr_skb, ptr_net_dev); - osal_skb_recv(ptr_skb); -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) - ptr_net_dev->last_rx = jiffies; -#endif - ptr_priv = netdev_priv(ptr_net_dev); - ptr_priv->stats.rx_packets++; - ptr_priv->stats.rx_bytes += total_len; - } -#if defined(NETIF_EN_NETLINK) - else - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "hit profile dest=netlink, name=%s, mcgrp=%s\n", - ((NETIF_NL_RX_DST_NETLINK_T *)ptr_dest)->name, - ((NETIF_NL_RX_DST_NETLINK_T *)ptr_dest)->mc_group_name); - netif_nl_rxSkb(unit, ptr_skb, ptr_dest); - } -#endif - } - else if (HAL_TAU_PKT_DEST_SDK == dest_type) - { - while (0 != _hal_tau_pkt_enQueue(&ptr_rx_cb->sw_queue[channel], ptr_sw_gpd)) - { - ptr_rx_cb->cnt.channel[channel].enque_retry++; - HAL_TAU_PKT_RX_ENQUE_RETRY_SLEEP(); - } - ptr_rx_cb->cnt.channel[channel].enque_ok++; - - osal_triggerEvent(&ptr_rx_cb->sync_sema); - ptr_rx_cb->cnt.channel[channel].trig_event++; - } - else if (HAL_TAU_PKT_DEST_DROP == dest_type) - { - _hal_tau_pkt_freeRxGpdList(unit, ptr_sw_first_gpd, TRUE); - } - else - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_RX), - "u=%u, rxch=%u, invalid pkt dest=%d\n", - unit, channel, dest_type); - } -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_flushRxQueue( - const UI32_T unit, - HAL_TAU_PKT_SW_QUEUE_T *ptr_que) -{ - HAL_TAU_PKT_RX_SW_GPD_T *ptr_sw_gpd_knl = NULL; - NPS_ERROR_NO_T rc; - - while (1) - { - rc = _hal_tau_pkt_deQueue(ptr_que, (void **)&ptr_sw_gpd_knl); - if (NPS_E_OK == rc) - { - _hal_tau_pkt_freeRxGpdList(unit, ptr_sw_gpd_knl, TRUE); - } - else - { - break; - } - } - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_schedRxDeQueue - * PURPOSE: - * To dequeue the packets based on the configured algorithm. - * INPUT: - * unit -- The unit ID - * ptr_cookie -- Pointer of the RX cookie - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully dequeue the packets. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_schedRxDeQueue( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_RX_COOKIE_T *ptr_cookie) -{ - HAL_TAU_PKT_IOCTL_RX_COOKIE_T ioctl_data; - HAL_TAU_PKT_IOCTL_RX_GPD_T ioctl_gpd; - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - HAL_TAU_PKT_RX_SW_GPD_T *ptr_sw_gpd_knl = NULL; - HAL_TAU_PKT_RX_SW_GPD_T *ptr_sw_first_gpd_knl = NULL; - UI32_T que_cnt = 0; - UI32_T queue = 0; - UI32_T idx = 0; - UI32_T gpd_idx = 0; - /* copy Rx sw_gpd */ - volatile HAL_TAU_PKT_RX_GPD_T *ptr_rx_gpd = NULL; - void *ptr_virt_addr = NULL; - NPS_ADDR_T phy_addr = 0; - UI32_T buf_len = 0; - NPS_ERROR_NO_T rc = NPS_E_OK; - - /* normal process */ - if (TRUE == ptr_rx_cb->running) - { - /* get queue and count */ - for (idx = 0; idx < HAL_TAU_PKT_RX_QUEUE_NUM; idx++) - { - /* to gurantee the opportunity where each queue can be handler */ - queue = ((ptr_rx_cb->deque_idx + idx) % HAL_TAU_PKT_RX_QUEUE_NUM); - _hal_tau_pkt_getQueueCount(&ptr_rx_cb->sw_queue[queue], &que_cnt); - if (que_cnt > 0) - { - ptr_rx_cb->deque_idx = ((queue + 1) % HAL_TAU_PKT_RX_QUEUE_NUM); - break; - } - } - - /* If all of the queues are empty, wait rxTask event */ - if (0 == que_cnt) - { - osal_waitEvent(&ptr_rx_cb->sync_sema); - - ptr_rx_cb->cnt.wait_event++; - - /* re-get queue and count */ - for (queue = 0; queue < HAL_TAU_PKT_RX_QUEUE_NUM; queue++) - { - _hal_tau_pkt_getQueueCount(&ptr_rx_cb->sw_queue[queue], &que_cnt); - if (que_cnt > 0) - { - ptr_rx_cb->deque_idx = ((queue + 1) % HAL_TAU_PKT_RX_QUEUE_NUM); - break; - } - } - } - - /* deque */ - if ((que_cnt > 0) && (queue < HAL_TAU_PKT_RX_QUEUE_NUM)) - { - rc = _hal_tau_pkt_deQueue(&ptr_rx_cb->sw_queue[queue], (void **)&ptr_sw_gpd_knl); - if (NPS_E_OK == rc) - { - ptr_rx_cb->cnt.channel[queue].deque_ok++; - ptr_sw_first_gpd_knl = ptr_sw_gpd_knl; - - osal_io_copyFromUser(&ioctl_data, ptr_cookie, sizeof(HAL_TAU_PKT_IOCTL_RX_COOKIE_T)); - - while (NULL != ptr_sw_gpd_knl) - { - /* get the IOCTL GPD from user */ - osal_io_copyFromUser(&ioctl_gpd, - ((void *)((NPS_HUGE_T)ioctl_data.ioctl_gpd_addr)) - + gpd_idx*sizeof(HAL_TAU_PKT_IOCTL_RX_GPD_T), - sizeof(HAL_TAU_PKT_IOCTL_RX_GPD_T)); - - /* get knl buf addr */ - ptr_rx_gpd = &ptr_sw_gpd_knl->rx_gpd; - phy_addr = NPS_ADDR_32_TO_64(ptr_rx_gpd->data_buf_addr_hi, ptr_rx_gpd->data_buf_addr_lo); - - ptr_virt_addr = ptr_sw_gpd_knl->ptr_cookie; - osal_skb_unmapDma(phy_addr, ((struct sk_buff *)ptr_virt_addr)->len, DMA_FROM_DEVICE); - - buf_len = (HAL_TAU_PKT_CH_LAST_GPD == ptr_rx_gpd->ch)? - ptr_rx_gpd->cnsm_buf_len : ptr_rx_gpd->avbl_buf_len; - - /* overwrite whole rx_gpd to user - * the user should re-assign the correct value to data_buf_addr_hi, data_buf_addr_low - * after this IOCTL returns - */ - osal_io_copyToUser((void *)((NPS_HUGE_T)ioctl_gpd.hw_gpd_addr), - &ptr_sw_gpd_knl->rx_gpd, - sizeof(HAL_TAU_PKT_RX_GPD_T)); - /* copy buf */ - /* DMA buf address allocated by the user is store in ptr_ioctl_data->gpd[idx].cookie */ - osal_io_copyToUser((void *)((NPS_HUGE_T)ioctl_gpd.dma_buf_addr), - ((struct sk_buff *)ptr_virt_addr)->data, buf_len); - ptr_sw_gpd_knl->ptr_cookie = ptr_virt_addr; - - /* next */ - ptr_sw_gpd_knl = ptr_sw_gpd_knl->ptr_next; - gpd_idx++; - } - - /* Must free kernel sw_gpd */ - _hal_tau_pkt_freeRxGpdList(unit, ptr_sw_first_gpd_knl, TRUE); - } - else - { - ptr_rx_cb->cnt.channel[queue].deque_fail++; - } - } - else - { - /* it means that all queue's are flush -> rx stop flow */ - rc = NPS_E_OTHERS; - } - } - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_waitTxDone - * PURPOSE: - * To determine the next action after transfer the packet to HW. - * INPUT: - * unit -- The unit ID - * channel -- The target TX channel - * ptr_sw_gpd -- Pointer for the SW Tx GPD link list - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully perform the target action. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_waitTxDone( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel, - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_gpd) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - HAL_TAU_PKT_TX_PDMA_T *ptr_tx_pdma = HAL_TAU_PKT_GET_TX_PDMA_PTR(unit, channel); - volatile HAL_TAU_PKT_TX_GPD_T *ptr_tx_gpd = NULL; - UI32_T last_gpd_idx = 0; - UI32_T loop_cnt = 0; - - if (HAL_TAU_PKT_TX_WAIT_ASYNC == ptr_tx_cb->wait_mode) - { - ; - } - else if (HAL_TAU_PKT_TX_WAIT_SYNC_INTR == ptr_tx_cb->wait_mode) - { - osal_takeSemaphore(&ptr_tx_pdma->sync_intr_sema, HAL_TAU_PKT_PDMA_TX_INTR_TIMEOUT); - /* rc = _hal_tau_pkt_invokeTxGpdCallback(unit, ptr_sw_gpd); */ - } - else if (HAL_TAU_PKT_TX_WAIT_SYNC_POLL == ptr_tx_cb->wait_mode) - { - last_gpd_idx = ptr_tx_pdma->free_idx + ptr_tx_pdma->used_gpd_num; - last_gpd_idx %= ptr_tx_pdma->gpd_num; - ptr_tx_gpd = HAL_TAU_PKT_GET_TX_GPD_PTR(unit, channel, last_gpd_idx); - - while (HAL_TAU_PKT_HWO_HW_OWN == ptr_tx_gpd->hwo) - { - osal_dma_invalidateCache((void *)ptr_tx_gpd, sizeof(HAL_TAU_PKT_TX_GPD_T)); - loop_cnt++; - if (0 == loop_cnt % HAL_TAU_PKT_PDMA_TX_POLL_MAX_LOOP) - { - ptr_tx_cb->cnt.channel[channel].poll_timeout++; - rc = NPS_E_OTHERS; - break; - } - } - if (HAL_TAU_PKT_ECC_ERROR_OCCUR == ptr_tx_gpd->ecce) - { - ptr_tx_cb->cnt.channel[channel].ecc_err++; - } - if (NPS_E_OK == rc) - { - ptr_tx_pdma->free_gpd_num += ptr_tx_pdma->used_gpd_num; - ptr_tx_pdma->used_gpd_num = 0; - ptr_tx_pdma->free_idx = ptr_tx_pdma->used_idx; - /* rc = _hal_tau_pkt_invokeTxGpdCallback(unit, ptr_sw_gpd); */ - } - } - - return (rc); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_resumeAllIntf( - const UI32_T unit) -{ - struct net_device *ptr_net_dev = NULL; - UI32_T port; - - /* Unregister net devices by id */ - for (port = 0; port < HAL_TAU_PKT_MAX_PORT_NUM; port++) - { - ptr_net_dev = HAL_TAU_PKT_GET_PORT_NETDEV(port); - if (NULL != ptr_net_dev) - { - if (netif_queue_stopped(ptr_net_dev)) - { - netif_wake_queue(ptr_net_dev); - } - } - } - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_suspendAllIntf( - const UI32_T unit) -{ - struct net_device *ptr_net_dev = NULL; - UI32_T port; - - /* Unregister net devices by id */ - for (port = 0; port < HAL_TAU_PKT_MAX_PORT_NUM; port++) - { - ptr_net_dev = HAL_TAU_PKT_GET_PORT_NETDEV(port); - if (NULL != ptr_net_dev) - { - netif_stop_queue(ptr_net_dev); - } - } - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_stopAllIntf( - const UI32_T unit) -{ - struct net_device *ptr_net_dev = NULL; - UI32_T port; - - /* Unregister net devices by id */ - for (port = 0; port < HAL_TAU_PKT_MAX_PORT_NUM; port++) - { - ptr_net_dev = HAL_TAU_PKT_GET_PORT_NETDEV(port); - if (NULL != ptr_net_dev) - { - netif_tx_disable(ptr_net_dev); - } - } - - return (NPS_E_OK); -} - -/* FUNCTION NAME: hal_tau_pkt_sendGpd - * PURPOSE: - * To perform the packet transmission form CPU to the switch. - * INPUT: - * unit -- The unit ID - * channel -- The target TX channel - * ptr_sw_gpd -- Pointer for the SW Tx GPD link list - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully perform the transferring. - * NOTES: - * None - */ -NPS_ERROR_NO_T -hal_tau_pkt_sendGpd( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel, - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_gpd) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - HAL_TAU_PKT_TX_PDMA_T *ptr_tx_pdma = HAL_TAU_PKT_GET_TX_PDMA_PTR(unit, channel); - volatile HAL_TAU_PKT_TX_GPD_T *ptr_tx_gpd = NULL; - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_first_gpd = ptr_sw_gpd; - UI32_T used_idx = 0; - UI32_T used_gpd_num = ptr_sw_gpd->gpd_num; - NPS_IRQ_FLAGS_T irq_flags; - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - - if (0 != (ptr_cb->init_flag & HAL_TAU_PKT_INIT_TASK)) - { - osal_takeIsrLock(&ptr_tx_pdma->ring_lock, &irq_flags); - - /* If not PDMA error */ - if (FALSE == ptr_tx_pdma->err_flag) - { - /* Make Sure GPD is enough */ - if (ptr_tx_pdma->free_gpd_num >= used_gpd_num) - { - used_idx = ptr_tx_pdma->used_idx; - while (NULL != ptr_sw_gpd) - { - ptr_tx_gpd = HAL_TAU_PKT_GET_TX_GPD_PTR(unit, channel, used_idx); - osal_dma_invalidateCache((void *)ptr_tx_gpd, sizeof(HAL_TAU_PKT_TX_GPD_T)); - - if (HAL_TAU_PKT_HWO_HW_OWN == ptr_tx_gpd->hwo) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_TX), - "u=%u, txch=%u, free gpd idx out-of-sync\n", - unit, channel); - rc = NPS_E_TABLE_FULL; - break; - } - - /* Fill in HW-GPD Ring */ - osal_memcpy((void *)ptr_tx_gpd, &ptr_sw_gpd->tx_gpd, sizeof(HAL_TAU_PKT_TX_GPD_T)); - osal_dma_flushCache((void *)ptr_tx_gpd, sizeof(HAL_TAU_PKT_TX_GPD_T)); - - /* next */ - used_idx++; - used_idx %= ptr_tx_pdma->gpd_num; - ptr_sw_gpd = ptr_sw_gpd->ptr_next; - } - - if (HAL_TAU_PKT_TX_WAIT_ASYNC == ptr_tx_cb->wait_mode) - { - /* Fill 1st GPD in SW-GPD Ring */ - ptr_tx_pdma->pptr_sw_gpd_ring[ptr_tx_pdma->used_idx] = ptr_sw_first_gpd; - } - - /* update Tx PDMA */ - ptr_tx_pdma->used_idx = used_idx; - ptr_tx_pdma->used_gpd_num += used_gpd_num; - ptr_tx_pdma->free_gpd_num -= used_gpd_num; - - _hal_tau_pkt_resumeTxChannelReg(unit, channel, used_gpd_num); - ptr_tx_cb->cnt.channel[channel].send_ok++; - - _hal_tau_pkt_waitTxDone(unit, channel, ptr_sw_first_gpd); - - /* reserve 1 packet buffer for each port in case that the suspension is too late */ -#define HAL_TAU_PKT_KNL_TX_RING_AVBL_GPD_LOW (HAL_PORT_NUM) - if (ptr_tx_pdma->free_gpd_num < HAL_TAU_PKT_KNL_TX_RING_AVBL_GPD_LOW) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_TX, - "u=%u, txch=%u, tx avbl gpd < %d, suspend all netdev\n", - unit, channel, HAL_TAU_PKT_KNL_TX_RING_AVBL_GPD_LOW); - _hal_tau_pkt_suspendAllIntf(unit); - } - } - else - { - rc = NPS_E_TABLE_FULL; - } - } - else - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_TX), - "u=%u, txch=%u, pdma hw err\n", - unit, channel); - rc = NPS_E_OTHERS; - } - - osal_giveIsrLock(&ptr_tx_pdma->ring_lock, &irq_flags); - } - else - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_ERR, - "Tx failed, task already deinit\n"); - rc = NPS_E_OTHERS; - } - - return (rc); -} - -/* ----------------------------------------------------------------------------------- pkt_srv */ -/* ----------------------------------------------------------------------------------- Rx Init */ -static NPS_ERROR_NO_T -_hal_tau_pkt_rxStop( - const UI32_T unit) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_RX_CHANNEL_T channel = 0; - UI32_T idx; - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - HAL_TAU_PKT_RX_PDMA_T *ptr_rx_pdma = NULL; - - /* Check if Rx is already stopped*/ - if (0 == (ptr_cb->init_flag & HAL_TAU_PKT_INIT_RX_START)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_RX | HAL_TAU_PKT_DBG_ERR), - "u=%u, rx stop failed, not started\n", unit); - return (NPS_E_OK); - } - - /* Check if PKT Drv/Task were de-init before stopping Rx */ - /* Currently, we help to stop Rx when deinit Drv/Task, so it shouldn't enter below logic */ - if ((0 == (ptr_cb->init_flag & HAL_TAU_PKT_INIT_TASK)) || - (0 == (ptr_cb->init_flag & HAL_TAU_PKT_INIT_DRV))) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_RX | HAL_TAU_PKT_DBG_ERR), - "u=%u, rx stop failed, pkt task & pkt drv not init\n", unit); - return (NPS_E_OK); - } - - /* Deinit Rx PDMA and free buf for Rx GPD */ - for (channel = 0; channel < HAL_TAU_PKT_RX_CHANNEL_LAST; channel++) - { - ptr_rx_pdma = HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, channel); - - osal_takeSemaphore(&ptr_rx_pdma->sema, NPS_SEMAPHORE_WAIT_FOREVER); - _hal_tau_pkt_stopRxChannelReg(unit, channel); - rc = _hal_tau_pkt_deinitRxPdmaRingBuf(unit, channel); - osal_giveSemaphore(&ptr_rx_pdma->sema); - } - - /* flush packets in all queues since Rx task may be blocked in user space - * in this case it won't do ioctl to kernel to handle remaining packets - */ - for (idx = 0; idx < HAL_TAU_PKT_RX_QUEUE_NUM; idx++) - { - _hal_tau_pkt_flushRxQueue(unit, &ptr_rx_cb->sw_queue[idx]); - } - - /* Return user thread */ - ptr_rx_cb->running = FALSE; - ptr_cb->init_flag &= (~HAL_TAU_PKT_INIT_RX_START); - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_RX, - "u=%u, rx stop done, init flag=0x%x\n", unit, ptr_cb->init_flag); - - osal_triggerEvent(&ptr_rx_cb->sync_sema); - - return (rc); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_rxStart( - const UI32_T unit) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_RX_CHANNEL_T channel = 0; - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - HAL_TAU_PKT_RX_PDMA_T *ptr_rx_pdma = NULL; - - if (0 != (ptr_cb->init_flag & HAL_TAU_PKT_INIT_RX_START)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_RX | HAL_TAU_PKT_DBG_ERR), - "u=%u, rx start failed, already started\n", unit); - return (NPS_E_OK); - } - - /* init Rx PDMA and alloc buf for Rx GPD */ - for (channel = 0; channel < HAL_TAU_PKT_RX_CHANNEL_LAST; channel++) - { - ptr_rx_pdma = HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, channel); - - osal_takeSemaphore(&ptr_rx_pdma->sema, NPS_SEMAPHORE_WAIT_FOREVER); - rc = _hal_tau_pkt_initRxPdmaRingBuf(unit, channel); - if (NPS_E_OK == rc) - { - ptr_rx_pdma->cur_idx = 0; - _hal_tau_pkt_startRxChannelReg(unit, channel, ptr_rx_pdma->gpd_num); - } - osal_giveSemaphore(&ptr_rx_pdma->sema); - } - - /* enable to dequeue rx packets */ - ptr_rx_cb->running = TRUE; - - /* set the flag to record init state */ - ptr_cb->init_flag |= HAL_TAU_PKT_INIT_RX_START; - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_RX, - "u=%u, rx start done, init flag=0x%x\n", unit, ptr_cb->init_flag); - return (rc); -} - -/* FUNCTION NAME: hal_tau_pkt_setRxKnlConfig - * PURPOSE: - * 1. To stop the Rx channel and deinit the Rx subsystem. - * 2. To init the Rx subsystem and start the Rx channel. - * 3. To restart the Rx subsystem - * INPUT: - * unit -- The unit ID - * ptr_cookie -- Pointer of the RX cookie - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully configure the RX parameters. - * NPS_E_OTHERS -- Configure the parameter failed. - * NOTES: - * - */ -NPS_ERROR_NO_T -hal_tau_pkt_setRxKnlConfig( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_RX_COOKIE_T *ptr_cookie) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - HAL_TAU_PKT_IOCTL_RX_TYPE_T rx_type = HAL_TAU_PKT_IOCTL_RX_TYPE_LAST; - - osal_io_copyFromUser(&rx_type, &ptr_cookie->rx_type, sizeof(HAL_TAU_PKT_IOCTL_RX_TYPE_T)); - - if (HAL_TAU_PKT_IOCTL_RX_TYPE_DEINIT == rx_type) - { - _hal_tau_pkt_rxStop(unit); - } - if (HAL_TAU_PKT_IOCTL_RX_TYPE_INIT == rx_type) - { - /* To prevent buffer size from being on-the-fly changed */ - if (0 != (ptr_cb->init_flag & HAL_TAU_PKT_INIT_RX_START)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_RX | HAL_TAU_PKT_DBG_ERR), - "u=%u, rx stop failed, not started\n", unit); - return (NPS_E_OK); - } - - osal_io_copyFromUser(&ptr_rx_cb->buf_len, &ptr_cookie->buf_len, sizeof(UI32_T)); - _hal_tau_pkt_rxStart(unit); - } - - return (rc); -} - -/* FUNCTION NAME: hal_tau_pkt_getRxKnlConfig - * PURPOSE: - * To get the Rx subsystem configuration. - * INPUT: - * unit -- The unit ID - * ptr_cookie -- Pointer of the RX cookie - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully configure the RX parameters. - * NPS_E_OTHERS -- Configure the parameter failed. - * NOTES: - * - */ -NPS_ERROR_NO_T -hal_tau_pkt_getRxKnlConfig( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_RX_COOKIE_T *ptr_cookie) -{ - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - - osal_io_copyToUser(&ptr_cookie->buf_len, &ptr_rx_cb->buf_len, sizeof(UI32_T)); - - return (NPS_E_OK); -} - -/* ----------------------------------------------------------------------------------- Deinit */ -/* FUNCTION NAME: hal_tau_pkt_deinitTask - * PURPOSE: - * To de-initialize the Task for packet module. - * INPUT: - * unit -- The unit ID - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully dinitialize the control block. - * NPS_E_OTHERS -- Initialize the control block failed. - * NOTES: - * None - */ -NPS_ERROR_NO_T -hal_tau_pkt_deinitTask( - const UI32_T unit) -{ - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - UI32_T channel = 0; - - /* to prevent net intf from Tx packet */ - ptr_tx_cb->net_tx_allowed = FALSE; - - /* In case that some undestroyed net intf keep Tx after task deinit */ - _hal_tau_pkt_stopAllIntf(unit); - - if (0 == (ptr_cb->init_flag & HAL_TAU_PKT_INIT_TASK)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_RX | HAL_TAU_PKT_DBG_ERR), - "u=%u, rx stop failed, not started\n", unit); - return (NPS_E_OK); - } - - /* Need to stop Rx before de-init Task */ - if (0 != (ptr_cb->init_flag & HAL_TAU_PKT_INIT_RX_START)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_RX | HAL_TAU_PKT_DBG_ERR), - "u=%u, pkt task deinit failed, rx not stop\n", unit); - - _hal_tau_pkt_rxStop(unit); - } - - /* Make the Rx IOCTL from userspace return back*/ - osal_triggerEvent(&ptr_rx_cb->sync_sema); - - /* Destroy txTask */ - if (HAL_TAU_PKT_TX_WAIT_ASYNC == ptr_tx_cb->wait_mode) - { - ptr_tx_cb->running = FALSE; - osal_triggerEvent(&ptr_tx_cb->sync_sema); - } - - /* Destroy handleRxDoneTask */ - for (channel = 0; channel < HAL_TAU_PKT_RX_CHANNEL_LAST; channel++) - { - osal_stopThread(&ptr_rx_cb->isr_task_id[channel]); - osal_triggerEvent(HAL_TAU_PKT_RCH_EVENT(unit, channel)); - osal_destroyThread(&ptr_rx_cb->isr_task_id[channel]); - } - - /* Destroy handleTxDoneTask */ - for (channel = 0; channel < HAL_TAU_PKT_TX_CHANNEL_LAST; channel++) - { - osal_stopThread(&ptr_tx_cb->isr_task_id[channel]); - osal_triggerEvent(HAL_TAU_PKT_TCH_EVENT(unit, channel)); - osal_destroyThread(&ptr_tx_cb->isr_task_id[channel]); - } - - /* Destroy handleErrorTask */ - osal_stopThread(&ptr_cb->err_task_id); - osal_triggerEvent(HAL_TAU_PKT_ERR_EVENT(unit)); - osal_destroyThread(&ptr_cb->err_task_id); - - /* Set the flag to record init state */ - ptr_cb->init_flag &= (~HAL_TAU_PKT_INIT_TASK); - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_RX, - "u=%u, pkt task deinit done, init flag=0x%x\n", - unit, ptr_cb->init_flag); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_deinitTxPdma - * PURPOSE: - * To de-initialize the Tx PDMA configuration of the specified channel. - * INPUT: - * unit -- The unit ID - * channel -- The target Tx channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully de-init the Tx PDMA. - * NPS_E_OTHERS -- De-init the Tx PDMA failed. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_deinitTxPdma( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel) -{ - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - HAL_TAU_PKT_TX_PDMA_T *ptr_tx_pdma = HAL_TAU_PKT_GET_TX_PDMA_PTR(unit, channel); - - _hal_tau_pkt_stopTxChannelReg(unit, channel); - - /* Free DMA and flush queue */ - osal_dma_free(ptr_tx_pdma->ptr_gpd_start_addr); - - if (HAL_TAU_PKT_TX_WAIT_ASYNC == ptr_tx_cb->wait_mode) - { - osal_free(ptr_tx_pdma->pptr_sw_gpd_ring); - osal_free(ptr_tx_pdma->pptr_sw_gpd_bulk); - } - else if (HAL_TAU_PKT_TX_WAIT_SYNC_INTR == ptr_tx_cb->wait_mode) - { - osal_destroySemaphore(&ptr_tx_pdma->sync_intr_sema); - } - - osal_destroyIsrLock(&ptr_tx_pdma->ring_lock); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_deinitRxPdma - * PURPOSE: - * To de-initialize the Rx PDMA configuration of the specified channel. - * INPUT: - * unit -- The unit ID - * channel -- The target Rx channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully de-init the Rx PDMA. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_deinitRxPdma( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel) -{ - HAL_TAU_PKT_RX_PDMA_T *ptr_rx_pdma = HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, channel); - - /* Free DMA */ - osal_takeSemaphore(&ptr_rx_pdma->sema, NPS_SEMAPHORE_WAIT_FOREVER); - osal_dma_free(ptr_rx_pdma->ptr_gpd_start_addr); - osal_giveSemaphore(&ptr_rx_pdma->sema); - osal_destroySemaphore(&ptr_rx_pdma->sema); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_deinitPktCb - * PURPOSE: - * To de-init the control block of Drv. - * INPUT: - * unit -- The unit ID - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully de-init the control block. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_deinitPktCb( - const UI32_T unit) -{ - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - UI32_T idx = 0, vec = sizeof(_hal_tau_pkt_intr_vec) / sizeof(HAL_TAU_PKT_INTR_VEC_T); - - for (idx = 0; idx < vec; idx++) - { - osal_destroyEvent(&_hal_tau_pkt_intr_vec[idx].intr_event); - ptr_cb->intr_bitmap &= ~(_hal_tau_pkt_intr_vec[idx].intr_reg); - } - - /* Unregister PKT interrupt functions */ - osal_mdc_registerIsr(unit, NULL, NULL); - osal_destroyIsrLock(&ptr_cb->intr_lock); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_deinitPktTxCb - * PURPOSE: - * To de-init the control block of Tx PDMA. - * INPUT: - * unit -- The unit ID - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully de-init the control block. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_deinitPktTxCb( - const UI32_T unit) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - HAL_TAU_PKT_TX_CHANNEL_T channel = 0; - - /* Deinitialize TX PDMA sub-system.*/ - for (channel = 0; channel < HAL_TAU_PKT_TX_CHANNEL_LAST; channel++) - { - _hal_tau_pkt_deinitTxPdma(unit, channel); - } - - if (HAL_TAU_PKT_TX_WAIT_ASYNC == ptr_tx_cb->wait_mode) - { - /* Destroy the sync semaphore of txTask */ - osal_destroyEvent(&ptr_tx_cb->sync_sema); - - /* Deinitialize Tx GPD-queue (of first SW-GPD) from handleTxDoneTask to txTask */ - osal_destroySemaphore(&ptr_tx_cb->sw_queue.sema); - osal_que_destroy(&ptr_tx_cb->sw_queue.que_id); - } - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_deinitPktRxCb - * PURPOSE: - * To de-init the control block of Rx PDMA. - * INPUT: - * unit -- The unit ID - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully de-init the control block. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_deinitPktRxCb( - const UI32_T unit) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - HAL_TAU_PKT_RX_CHANNEL_T channel = 0; - UI32_T queue = 0; - - /* Deinitialize RX PDMA sub-system */ - for (channel = 0; channel < HAL_TAU_PKT_RX_CHANNEL_LAST; channel++) - { - _hal_tau_pkt_deinitRxPdma(unit, channel); - } - - /* Destroy the sync semaphore of rxTask */ - osal_destroyEvent(&ptr_rx_cb->sync_sema); - - /* Deinitialize Rx GPD-queue (of first SW-GPD) from handleRxDoneTask to rxTask */ - for (queue = 0; queue < HAL_TAU_PKT_RX_QUEUE_NUM; queue++) - { - osal_destroySemaphore(&ptr_rx_cb->sw_queue[queue].sema); - osal_que_destroy(&ptr_rx_cb->sw_queue[queue].que_id); - } - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_deinitL1Isr - * PURPOSE: - * To de-initialize the PDMA L1 ISR configuration. - * INPUT: - * unit -- The unit ID - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully de-initialize for the L1 ISR. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_deinitL1Isr( - const UI32_T unit) -{ - UI32_T idx = 0, vec = sizeof(_hal_tau_pkt_intr_vec) / sizeof(HAL_TAU_PKT_INTR_VEC_T); - - for (idx = 0; idx < vec; idx++) - { - _hal_tau_pkt_maskIntr(unit, _hal_tau_pkt_intr_vec[idx].intr_reg); - _hal_tau_pkt_disableIntr(unit, _hal_tau_pkt_intr_vec[idx].intr_reg); - } - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_deinitL2Isr - * PURPOSE: - * To initialize the PDMA L2 ISR configuration. - * INPUT: - * unit -- The unit ID - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully configure for the L2 ISR. - * NPS_E_OTHERS -- Configure failed. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_deinitL2Isr( - const UI32_T unit) -{ - HAL_TAU_PKT_L2_ISR_T isr_status = 0x0; - - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_RCH0); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_RCH1); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_RCH2); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_RCH3); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_TCH0); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_TCH1); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_TCH2); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_TCH3); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_RX_QID_MAP_ERR); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_RX_FRAME_ERR); - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_ERR_INT_MASK_SET), - &isr_status, sizeof(UI32_T)); - - isr_status = 0x0; - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_ERR_INT_EN), - &isr_status, sizeof(UI32_T)); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: hal_tau_pkt_deinitPktDrv - * PURPOSE: - * To invoke the functions to de-initialize the control block for each - * PDMA subsystem. - * INPUT: - * unit -- The unit ID - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully de-initialize the control blocks. - * NPS_E_OTHERS -- De-initialize the control blocks failed. - * NOTES: - * None - */ -NPS_ERROR_NO_T -hal_tau_pkt_deinitPktDrv( - const UI32_T unit) -{ - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - NPS_ERROR_NO_T rc = NPS_E_OK; - - if (0 == (ptr_cb->init_flag & HAL_TAU_PKT_INIT_DRV)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_RX | HAL_TAU_PKT_DBG_ERR), - "u=%u, pkt drv deinit failed, not inited\n", unit); - return (NPS_E_OK); - } - - rc = _hal_tau_pkt_deinitL2Isr(unit); - - if (NPS_E_OK == rc) - { - rc = _hal_tau_pkt_deinitL1Isr(unit); - } - if (NPS_E_OK == rc) - { - rc = _hal_tau_pkt_deinitPktRxCb(unit); - } - if (NPS_E_OK == rc) - { - rc = _hal_tau_pkt_deinitPktTxCb(unit); - } - if (NPS_E_OK == rc) - { - rc = _hal_tau_pkt_deinitPktCb(unit); - } - - ptr_cb->init_flag &= (~HAL_TAU_PKT_INIT_DRV); - - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, - "u=%u, pkt drv deinit done, init flag=0x%x\n", - unit, ptr_cb->init_flag); - return (rc); -} - -/* ----------------------------------------------------------------------------------- Init */ -/* FUNCTION NAME: _hal_tau_pkt_handleTxErrStat - * PURPOSE: - * To handle the TX flow control ISR. - * INPUT: - * unit -- The unit ID - * channel -- The target channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully handle the interrpt. - * NOTES: - * - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_handleTxErrStat( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel) -{ - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - HAL_TAU_PKT_TX_PDMA_T *ptr_tx_pdma = HAL_TAU_PKT_GET_TX_PDMA_PTR(unit, channel); - NPS_IRQ_FLAGS_T irg_flags; - - if (HAL_TAU_PKT_TX_WAIT_SYNC_INTR == ptr_tx_cb->wait_mode) - { - /* Notify the TX process to make it release the channel semaphore. */ - osal_giveSemaphore(&ptr_tx_pdma->sync_intr_sema); - } - - /* Set the error flag. */ - - osal_takeIsrLock(&ptr_tx_pdma->ring_lock, &irg_flags); - ptr_tx_pdma->err_flag = TRUE; - osal_giveIsrLock(&ptr_tx_pdma->ring_lock, &irg_flags); - - osal_triggerEvent(HAL_TAU_PKT_TCH_EVENT(unit, channel)); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_handleRxErrStat - * PURPOSE: - * To handle the error which occurs in RX channels. - * INPUT: - * unit -- The unit ID - * channel -- The channel where the error occurs - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully handle the error situation. - * NOTES: - * - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_handleRxErrStat( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel) -{ - HAL_TAU_PKT_RX_PDMA_T *ptr_rx_pdma = HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, channel); - - /* Set the error flag. */ - osal_takeSemaphore(&ptr_rx_pdma->sema, NPS_SEMAPHORE_WAIT_FOREVER); - ptr_rx_pdma->err_flag = TRUE; - osal_giveSemaphore(&ptr_rx_pdma->sema); - - osal_triggerEvent(HAL_TAU_PKT_RCH_EVENT(unit, channel)); - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_handleTxL2Isr - * PURPOSE: - * To handle the TX L2 interrupt according to the ISR status. - * INPUT: - * unit -- The unit ID - * channel -- The channel where the interrupt occurs - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully handle the L2 interrupt. - * NOTES: - * - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_handleTxL2Isr( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel) -{ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_T isr_status = 0x0; - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - - osal_mdc_readPciReg(unit, - HAL_TAU_PKT_GET_PDMA_TCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_TCH_INT_STAT), channel), - &isr_status, sizeof(isr_status)); - - _hal_tau_pkt_maskAllTxL2IsrReg(unit, channel); - - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_HWO_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_TX), - "u=%u, txch=%u, pdma gpd hwo err\n", unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_HWO_ERROR); - ptr_tx_cb->cnt.channel[channel].gpd_hwo_err++; - _hal_tau_pkt_handleTxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_CHKSM_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_TX), - "u=%u, txch=%u, pdma gpd chksum err\n", unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_CHKSM_ERROR); - ptr_tx_cb->cnt.channel[channel].gpd_chksm_err++; - _hal_tau_pkt_handleTxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_NO_OVFL_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_TX), - "u=%u, txch=%u, pdma gpd num overflow err\n", unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_NO_OVFL_ERROR); - ptr_tx_cb->cnt.channel[channel].gpd_no_ovfl_err++; - _hal_tau_pkt_handleTxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_DMA_READ_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_TX), - "u=%u, txch=%u, pdma gpd dma read err\n", unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_DMA_READ_ERROR); - ptr_tx_cb->cnt.channel[channel].gpd_dma_read_err++; - _hal_tau_pkt_handleTxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_BUF_SIZE_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_TX), - "u=%u, txch=%u, pdma buf size err\n", unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_BUF_SIZE_ERROR); - ptr_tx_cb->cnt.channel[channel].buf_size_err++; - _hal_tau_pkt_handleTxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_RUNT_ERROR)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_TX, - "u=%u, txch=%u, pdma pkt runt\n", unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_RUNT_ERROR); - ptr_tx_cb->cnt.channel[channel].runt_err++; - } - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_OVSZ_ERROR)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_TX, - "u=%u, txch=%u, pdma pkt over size\n", unit, channel);; - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_OVSZ_ERROR); - ptr_tx_cb->cnt.channel[channel].ovsz_err++; - } - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_LEN_MISMATCH_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_TX), - "u=%u, txch=%u, pdma len mismatch err\n", unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_LEN_MISMATCH_ERROR); - ptr_tx_cb->cnt.channel[channel].len_mismatch_err++; - } - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_PKTPL_DMA_READ_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_TX), - "u=%u, txch=%u, pdma pkt buf dma read err\n", unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_PKTPL_DMA_READ_ERROR); - ptr_tx_cb->cnt.channel[channel].pktpl_dma_read_err++; - _hal_tau_pkt_handleTxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_COS_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_TX), - "u=%u, txch=%u, pdma tx cos err\n", unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_COS_ERROR); - ptr_tx_cb->cnt.channel[channel].cos_err++; - } - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_GT255_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_TX), - "u=%u, txch=%u, pdma gpd num > 255 err\n", unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_GT255_ERROR); - ptr_tx_cb->cnt.channel[channel].gpd_gt255_err++; - _hal_tau_pkt_handleTxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_PFC)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_TX, - "u=%u, txch=%u, pdma flow ctrl\n", unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_PFC); - ptr_tx_cb->cnt.channel[channel].pfc++; - } - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_CREDIT_UDFL_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_TX), - "u=%u, txch=%u, pdma credit underflow err\n", unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_CREDIT_UDFL_ERROR); - ptr_tx_cb->cnt.channel[channel].credit_udfl_err++; - _hal_tau_pkt_handleTxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_DMA_WRITE_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_TX), - "u=%u, txch=%u, pdma dma write err\n", unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_DMA_WRITE_ERROR); - ptr_tx_cb->cnt.channel[channel].dma_write_err++; - _hal_tau_pkt_handleTxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_TX_CHANNEL_L2_ISR_STOP_CMD_CPLT)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_TX, - "u=%u, txch=%u, pdma stop done\n", unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_TX_CHANNEL_L2_ISR_STOP_CMD_CPLT); - ptr_tx_cb->cnt.channel[channel].sw_issue_stop++; - } - if (0 != isr_status) - { - _hal_tau_pkt_unmaskAllTxL2IsrReg(unit, channel); - } - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_handleRxL2Isr - * PURPOSE: - * To handle the RX L2 interrupt according to the ISR status. - * INPUT: - * unit -- The unit ID - * channel -- The channel where the interrupt occurs - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully handle the L2 interrupt. - * NOTES: - * - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_handleRxL2Isr( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel) -{ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_T isr_status = 0x0; - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - - osal_mdc_readPciReg(unit, - HAL_TAU_PKT_GET_PDMA_RCH_REG(HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_RCH_INT_STAT), channel), - &isr_status, sizeof(isr_status)); - - _hal_tau_pkt_maskAllRxL2IsrReg(unit, channel); - - if (0 != (isr_status & HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_LOW)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_RX, - "u=%u, rxch=%u, pdma avbl gpd low\n", unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_LOW); - ptr_rx_cb->cnt.channel[channel].avbl_gpd_low++; - } - if (0 != (isr_status & HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_EMPTY)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_RX, - "u=%u, rxch=%u, pdma avbl gpd empty\n", unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_EMPTY); - ptr_rx_cb->cnt.channel[channel].avbl_gpd_empty++; - } - if (0 != (isr_status & HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_RX), - "u=%u, rxch=%u, pdma avbl gpd err\n", unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_ERROR); - ptr_rx_cb->cnt.channel[channel].avbl_gpd_err++; - _hal_tau_pkt_handleRxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_RX_CHANNEL_L2_ISR_GPD_CHKSM_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_RX), - "u=%u, rxch=%u, pdma gpd chksum err\n", unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_RX_CHANNEL_L2_ISR_GPD_CHKSM_ERROR); - ptr_rx_cb->cnt.channel[channel].gpd_chksm_err++; - _hal_tau_pkt_handleRxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_RX_CHANNEL_L2_ISR_DMA_READ_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_RX), - "u=%u, rxch=%u, pdma dma read err\n", unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_RX_CHANNEL_L2_ISR_DMA_READ_ERROR); - ptr_rx_cb->cnt.channel[channel].dma_read_err++; - _hal_tau_pkt_handleRxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_RX_CHANNEL_L2_ISR_DMA_WRITE_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_RX), - "u=%u, rxch=%u, pdma dma write err\n", unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_RX_CHANNEL_L2_ISR_DMA_WRITE_ERROR); - ptr_rx_cb->cnt.channel[channel].dma_write_err++; - _hal_tau_pkt_handleRxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_RX_CHANNEL_L2_ISR_STOP_CMD_CPLT)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_RX, - "u=%u, rxch=%u, pdma stop done\n", unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_RX_CHANNEL_L2_ISR_STOP_CMD_CPLT); - ptr_rx_cb->cnt.channel[channel].sw_issue_stop++; - } - if (0 != (isr_status & HAL_TAU_PKT_RX_CHANNEL_L2_ISR_GPD_GT255_ERROR)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_RX), - "u=%u, rxch=%u, pdma gpd num > 255 err\n", unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_RX_CHANNEL_L2_ISR_GPD_GT255_ERROR); - ptr_rx_cb->cnt.channel[channel].gpd_gt255_err++; - _hal_tau_pkt_handleRxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_RX_CHANNEL_L2_ISR_TOD_UNINIT)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_RX), - "u=%u, rxch=%u, pdma tod ununit err\n", unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_RX_CHANNEL_L2_ISR_TOD_UNINIT); - ptr_rx_cb->cnt.channel[channel].tod_uninit++; - _hal_tau_pkt_handleRxErrStat(unit, channel); - } - if (0 != (isr_status & HAL_TAU_PKT_RX_CHANNEL_L2_ISR_PKT_ERROR_DROP)) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_RX), - "u=%u, rxch=%u, pdma pkt err drop\n", unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_RX_CHANNEL_L2_ISR_PKT_ERROR_DROP); - ptr_rx_cb->cnt.channel[channel].pkt_err_drop++; - } - if (0 != (isr_status & HAL_TAU_PKT_RX_CHANNEL_L2_ISR_UDSZ_DROP)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_RX, - "u=%u, rxch=%u, pdma pkt under size\n", unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_RX_CHANNEL_L2_ISR_UDSZ_DROP); - ptr_rx_cb->cnt.channel[channel].udsz_drop++; - } - if (0 != (isr_status & HAL_TAU_PKT_RX_CHANNEL_L2_ISR_OVSZ_DROP)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_RX, - "u=%u, rxch=%u, pdma pkt over size\n", unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_RX_CHANNEL_L2_ISR_OVSZ_DROP); - ptr_rx_cb->cnt.channel[channel].ovsz_drop++; - } - if (0 != (isr_status & HAL_TAU_PKT_RX_CHANNEL_L2_ISR_CMDQ_OVF_DROP)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_RX, - "u=%u, rxch=%u, pdma cmdq overflow\n", unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_RX_CHANNEL_L2_ISR_CMDQ_OVF_DROP); - ptr_rx_cb->cnt.channel[channel].cmdq_ovf_drop++; - } - if (0 != (isr_status & HAL_TAU_PKT_RX_CHANNEL_L2_ISR_FIFO_OVF_DROP)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_RX, - "u=%u, rxch=%u, pdma fifo overflow\n", unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, HAL_TAU_PKT_RX_CHANNEL_L2_ISR_FIFO_OVF_DROP); - ptr_rx_cb->cnt.channel[channel].fifo_ovf_drop++; - } - if (0 != isr_status) - { - _hal_tau_pkt_unmaskAllRxL2IsrReg(unit, channel); - } - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_handleErrorTask - * PURPOSE: - * To invoke the corresponding handler for the L2 interrupts. - * INPUT: - * ptr_argv -- The unit ID - * OUTPUT: - * None - * RETURN: - * None - * NOTES: - * None - */ -static void -_hal_tau_pkt_handleErrorTask( - void *ptr_argv) -{ - UI32_T unit = (UI32_T)((NPS_HUGE_T)ptr_argv); - HAL_TAU_PKT_L2_ISR_T isr_status = 0x0; - - osal_initRunThread(); - do - { - /* receive Error-ISR */ - osal_waitEvent(HAL_TAU_PKT_ERR_EVENT(unit)); - if (NPS_E_OK != osal_isRunThread()) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, - "u=%u, err task destroyed\n", unit); - break; /* deinit-thread */ - } - - osal_mdc_readPciReg(unit, - HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_ERR_INT_STAT), - &isr_status, sizeof(UI32_T)); - - if (0 != (HAL_TAU_PKT_L2_ISR_RCH0 & isr_status)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, "u=%u, rxch=0, rcv err isr, status=0x%x\n", - unit, isr_status); - _hal_tau_pkt_handleRxL2Isr(unit, HAL_TAU_PKT_RX_CHANNEL_0); - } - if (0 != (HAL_TAU_PKT_L2_ISR_RCH1 & isr_status)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, "u=%u, rxch=1, rcv err isr, status=0x%x\n", - unit, isr_status); - _hal_tau_pkt_handleRxL2Isr(unit, HAL_TAU_PKT_RX_CHANNEL_1); - } - if (0 != (HAL_TAU_PKT_L2_ISR_RCH2 & isr_status)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, "u=%u, rxch=2, rcv err isr, status=0x%x\n", - unit, isr_status); - _hal_tau_pkt_handleRxL2Isr(unit, HAL_TAU_PKT_RX_CHANNEL_2); - } - if (0 != (HAL_TAU_PKT_L2_ISR_RCH3 & isr_status)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, "u=%u, rxch=3, rcv err isr, status=0x%x\n", - unit, isr_status); - _hal_tau_pkt_handleRxL2Isr(unit, HAL_TAU_PKT_RX_CHANNEL_3); - } - if (0 != (HAL_TAU_PKT_L2_ISR_TCH0 & isr_status)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, "u=%u, txch=0, rcv err isr, status=0x%x\n", - unit, isr_status); - _hal_tau_pkt_handleTxL2Isr(unit, HAL_TAU_PKT_TX_CHANNEL_0); - } - if (0 != (HAL_TAU_PKT_L2_ISR_TCH1 & isr_status)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, "u=%u, txch=1, rcv err isr, status=0x%x\n", - unit, isr_status); - _hal_tau_pkt_handleTxL2Isr(unit, HAL_TAU_PKT_TX_CHANNEL_1); - } - if (0 != (HAL_TAU_PKT_L2_ISR_TCH2 & isr_status)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, "u=%u, txch=2, rcv err isr, status=0x%x\n", - unit, isr_status); - _hal_tau_pkt_handleTxL2Isr(unit, HAL_TAU_PKT_TX_CHANNEL_2); - } - if (0 != (HAL_TAU_PKT_L2_ISR_TCH3 & isr_status)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, "u=%u, txch=3, rcv err isr, status=0x%x\n", - unit, isr_status); - _hal_tau_pkt_handleTxL2Isr(unit, HAL_TAU_PKT_TX_CHANNEL_3); - } - if (0 != (HAL_TAU_PKT_L2_ISR_RX_QID_MAP_ERR & isr_status)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, "u=%u, rcv rx qid map err isr, status=0x%x\n", - unit, isr_status); - } - if (0 != (HAL_TAU_PKT_L2_ISR_RX_FRAME_ERR & isr_status)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, "u=%u, rcv rx frame err isr, status=0x%x\n", - unit, isr_status); - } - if (0 != isr_status) - { - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_ERR_INT_CLR), - &isr_status, sizeof(UI32_T)); - - _hal_tau_pkt_unmaskIntr(unit, HAL_TAU_PKT_ERR_REG(unit)); - } - - } while (NPS_E_OK == osal_isRunThread()); - osal_exitRunThread(); -} - -/* FUNCTION NAME: _hal_tau_pkt_handleTxDoneTask - * PURPOSE: - * To handle the TX done interrupt for the specified TX channel. - * INPUT: - * ptr_argv -- The unit ID and channel ID - * OUTPUT: - * None - * RETURN: - * None - * NOTES: - * None - */ -static void -_hal_tau_pkt_handleTxDoneTask( - void *ptr_argv) -{ - /* cookie or index */ - UI32_T unit = ((HAL_TAU_PKT_ISR_COOKIE_T *)ptr_argv)->unit; - HAL_TAU_PKT_TX_CHANNEL_T channel = (HAL_TAU_PKT_TX_CHANNEL_T) - ((HAL_TAU_PKT_ISR_COOKIE_T *)ptr_argv)->channel; - /* control block */ - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - HAL_TAU_PKT_TX_PDMA_T *ptr_tx_pdma = HAL_TAU_PKT_GET_TX_PDMA_PTR(unit, channel); - volatile HAL_TAU_PKT_TX_GPD_T *ptr_tx_gpd = NULL; - UI32_T first_gpd_idx = 0; /* To record the first GPD */ - UI32_T loop_cnt = 0; - NPS_IRQ_FLAGS_T irg_flags; - unsigned long timeout = 0; - UI32_T bulk_pkt_cnt = 0, idx; - - osal_initRunThread(); - do - { - /* receive Tx-Done-ISR */ - osal_waitEvent(HAL_TAU_PKT_TCH_EVENT(unit, channel)); - if (NPS_E_OK != osal_isRunThread()) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_TX, - "u=%u, txch=%u, tx done task destroyed\n", unit, channel); - break; /* deinit-thread */ - } - - /* protect Tx PDMA - * for sync-intr, the sema is locked by sendGpd - */ - if (HAL_TAU_PKT_TX_WAIT_SYNC_INTR != ptr_tx_cb->wait_mode) - { - osal_takeIsrLock(&ptr_tx_pdma->ring_lock, &irg_flags); - } - - loop_cnt = ptr_tx_pdma->used_gpd_num; - while (loop_cnt > 0) - { - ptr_tx_gpd = HAL_TAU_PKT_GET_TX_GPD_PTR(unit, channel, ptr_tx_pdma->free_idx); - osal_dma_invalidateCache((void *)ptr_tx_gpd, sizeof(HAL_TAU_PKT_TX_GPD_T)); - - /* If hwo=HW, it might be: - * 1. err_flag=TRUE -> HW breakdown -> enque and recover -> break - * 2. err_flag=FALSE -> HW busy -> break - */ - if (HAL_TAU_PKT_HWO_HW_OWN == ptr_tx_gpd->hwo) - { - if (TRUE == ptr_tx_pdma->err_flag) - { - /* flush the incomplete Tx packet */ - if (HAL_TAU_PKT_TX_WAIT_ASYNC == ptr_tx_cb->wait_mode) - { - for (idx = 0; idx < ptr_tx_pdma->gpd_num; idx++) - { - if (NULL != ptr_tx_pdma->pptr_sw_gpd_ring[idx]) - { - ptr_tx_pdma->pptr_sw_gpd_bulk[bulk_pkt_cnt] - = ptr_tx_pdma->pptr_sw_gpd_ring[idx]; - ptr_tx_pdma->pptr_sw_gpd_ring[idx] = NULL; - bulk_pkt_cnt++; - } - } - } - - /* do error recover */ - first_gpd_idx = 0; - if (NPS_E_OK == _hal_tau_pkt_recoverTxPdma(unit, channel)) - { - ptr_tx_pdma->err_flag = FALSE; - ptr_tx_cb->cnt.channel[channel].err_recover++; - } - else - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_TX | HAL_TAU_PKT_DBG_ERR), - "u=%u, txch=%u, err recover failed\n", - unit, channel); - } - } - else - { - } - break; - } - - if (HAL_TAU_PKT_TX_WAIT_ASYNC == ptr_tx_cb->wait_mode) - { - /* If hwo=SW and ch=0, record the head of sw gpd in bulk buf */ - if (HAL_TAU_PKT_CH_LAST_GPD == ptr_tx_gpd->ch) - { - ptr_tx_pdma->pptr_sw_gpd_bulk[bulk_pkt_cnt] - = ptr_tx_pdma->pptr_sw_gpd_ring[first_gpd_idx]; - - bulk_pkt_cnt++; - ptr_tx_pdma->pptr_sw_gpd_ring[first_gpd_idx] = NULL; - - /* next SW-GPD must be the head of another PKT->SW-GPD */ - first_gpd_idx = ptr_tx_pdma->free_idx + 1; - first_gpd_idx %= ptr_tx_pdma->gpd_num; - } - } - - if (HAL_TAU_PKT_ECC_ERROR_OCCUR == ptr_tx_gpd->ecce) - { - ptr_tx_cb->cnt.channel[channel].ecc_err++; - } - - /* update Tx PDMA */ - ptr_tx_pdma->free_idx++; - ptr_tx_pdma->free_idx %= ptr_tx_pdma->gpd_num; - ptr_tx_pdma->used_gpd_num--; - ptr_tx_pdma->free_gpd_num++; - loop_cnt--; - } - - /* let the netdev resume Tx */ - _hal_tau_pkt_resumeAllIntf(unit); - - /* update ISR and counter */ - ptr_tx_cb->cnt.channel[channel].tx_done++; - - _hal_tau_pkt_unmaskIntr(unit, HAL_TAU_PKT_TCH_REG(unit, channel)); - - if (HAL_TAU_PKT_TX_WAIT_SYNC_INTR != ptr_tx_cb->wait_mode) - { - osal_giveIsrLock(&ptr_tx_pdma->ring_lock, &irg_flags); - } - else - { - osal_giveSemaphore(&ptr_tx_pdma->sync_intr_sema); - } - - /* enque packet after releasing the spinlock */ - _hal_tau_pkt_txEnQueueBulk(unit, channel, bulk_pkt_cnt); - bulk_pkt_cnt = 0; - - /* prevent this task from executing too long */ - if (!(time_before(jiffies, timeout))) - { - schedule(); - timeout = jiffies + 1; /* continuously free tx descriptor for 1 tick */ - } - - } while (NPS_E_OK == osal_isRunThread()); - osal_exitRunThread(); -} - -/* FUNCTION NAME: _hal_tau_pkt_handleRxDoneTask - * PURPOSE: - * To handle the RX done interrupt for the specified RX channel. - * INPUT: - * ptr_argv -- The unit ID and channel ID - * OUTPUT: - * None - * RETURN: - * None - * NOTES: - * None - */ -static void -_hal_tau_pkt_handleRxDoneTask( - void *ptr_argv) -{ - /* cookie or index */ - UI32_T unit = ((HAL_TAU_PKT_ISR_COOKIE_T *)ptr_argv)->unit; - HAL_TAU_PKT_RX_CHANNEL_T channel = (HAL_TAU_PKT_RX_CHANNEL_T) - ((HAL_TAU_PKT_ISR_COOKIE_T *)ptr_argv)->channel; - - /* control block */ - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - HAL_TAU_PKT_RX_PDMA_T *ptr_rx_pdma = HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, channel); - volatile HAL_TAU_PKT_RX_GPD_T *ptr_rx_gpd = NULL; - - BOOL_T first = TRUE; - BOOL_T last = FALSE; - HAL_TAU_PKT_RX_SW_GPD_T *ptr_sw_gpd = NULL; - HAL_TAU_PKT_RX_SW_GPD_T *ptr_sw_first_gpd = NULL; - UI32_T loop_cnt = 0; - unsigned long timeout = 0; - - osal_initRunThread(); - do - { - /* receive Rx-Done-ISR */ - osal_waitEvent(HAL_TAU_PKT_RCH_EVENT(unit, channel)); - if (NPS_E_OK != osal_isRunThread()) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_RX, - "u=%u, rxch=%u, rx done task destroyed\n", unit, channel); - break; /* deinit-thread */ - } - - /* check if Rx-system is inited */ - if (0 == ptr_rx_cb->buf_len) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_RX | HAL_TAU_PKT_DBG_ERR), - "u=%u, rxch=%u, rx gpd buf len=0\n", - unit, channel); - continue; - } - - /* protect Rx PDMA */ - osal_takeSemaphore(&ptr_rx_pdma->sema, NPS_SEMAPHORE_WAIT_FOREVER); - loop_cnt = ptr_rx_pdma->gpd_num; - while (loop_cnt > 0) - { - ptr_rx_gpd = HAL_TAU_PKT_GET_RX_GPD_PTR(unit, channel, ptr_rx_pdma->cur_idx); - osal_dma_invalidateCache((void *)ptr_rx_gpd, sizeof(HAL_TAU_PKT_RX_GPD_T)); - - /* If hwo=HW, it might be: - * 1. err_flag=TRUE -> HW breakdown -> enque and recover -> break - * 2. err_flag=FALSE -> HW busy -> break - */ - if (HAL_TAU_PKT_HWO_HW_OWN == ptr_rx_gpd->hwo) - { - if (TRUE == ptr_rx_pdma->err_flag) - { - /* free the last incomplete Rx packet */ - if ((NULL != ptr_sw_first_gpd) && - (NULL != ptr_sw_gpd)) - { - ptr_sw_gpd->ptr_next = NULL; - ptr_sw_first_gpd->rx_complete = FALSE; - _hal_tau_pkt_rxEnQueue(unit, channel, ptr_sw_first_gpd); - ptr_sw_first_gpd = NULL; - } - - /* do error recover */ - first = TRUE; - last = FALSE; - if (NPS_E_OK == _hal_tau_pkt_recoverRxPdma(unit, channel)) - { - ptr_rx_pdma->err_flag = FALSE; - ptr_rx_cb->cnt.channel[channel].err_recover++; - } - else - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_RX | HAL_TAU_PKT_DBG_ERR), - "u=%u, rxch=%u, err recover failed\n", - unit, channel); - } - } - else - { - } - break; - } - - /* Move HW-GPD to SW-GPD and append to a link-list */ - if (TRUE == first) - { - ptr_sw_first_gpd = (HAL_TAU_PKT_RX_SW_GPD_T *)osal_alloc(sizeof(HAL_TAU_PKT_RX_SW_GPD_T)); - ptr_sw_gpd = ptr_sw_first_gpd; - if (NULL != ptr_sw_gpd) - { - memcpy(&ptr_sw_gpd->rx_gpd, (void *)ptr_rx_gpd, sizeof(HAL_TAU_PKT_RX_GPD_T)); - first = FALSE; - } - else - { - ptr_rx_cb->cnt.no_memory++; - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_RX | HAL_TAU_PKT_DBG_ERR), - "u=%u, rxch=%u, alloc 1st sw gpd failed, size=%zu\n", - unit, channel, sizeof(HAL_TAU_PKT_RX_SW_GPD_T)); - break; - } - } - else - { - ptr_sw_gpd->ptr_next = (HAL_TAU_PKT_RX_SW_GPD_T *)osal_alloc(sizeof(HAL_TAU_PKT_RX_SW_GPD_T)); - ptr_sw_gpd = ptr_sw_gpd->ptr_next; - if (NULL != ptr_sw_gpd) - { - memcpy(&ptr_sw_gpd->rx_gpd, (void *)ptr_rx_gpd, sizeof(HAL_TAU_PKT_RX_GPD_T)); - } - else - { - ptr_rx_cb->cnt.no_memory++; - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_RX | HAL_TAU_PKT_DBG_ERR), - "u=%u, rxch=%u, alloc mid sw gpd failed, size=%zu\n", - unit, channel, sizeof(HAL_TAU_PKT_RX_SW_GPD_T)); - break; - } - } - - ptr_sw_gpd->ptr_cookie = ptr_rx_pdma->pptr_skb_ring[ptr_rx_pdma->cur_idx]; - - /* If hwo=SW and ch=0, enque SW-GPD and signal rxTask */ - if (HAL_TAU_PKT_CH_LAST_GPD == ptr_rx_gpd->ch) - { - last = TRUE; - } - - /* If hwo=SW and ch=*, re-alloc-buf and resume */ - while (NPS_E_OK != _hal_tau_pkt_allocRxPayloadBuf(unit, channel, ptr_rx_pdma->cur_idx)) - { - ptr_rx_cb->cnt.no_memory++; - HAL_TAU_PKT_ALLOC_MEM_RETRY_SLEEP(); - } - ptr_rx_gpd->ioc = HAL_TAU_PKT_IOC_HAS_INTR; - ptr_rx_gpd->hwo = HAL_TAU_PKT_HWO_HW_OWN; - osal_dma_flushCache((void *)ptr_rx_gpd, sizeof(HAL_TAU_PKT_RX_GPD_T)); - - /* Enque the SW-GPD to rxTask */ - if (TRUE == last) - { - ptr_sw_gpd->ptr_next = NULL; - ptr_sw_first_gpd->rx_complete = TRUE; - _hal_tau_pkt_rxEnQueue(unit, channel, ptr_sw_first_gpd); - ptr_sw_first_gpd = NULL; - - /* To rebuild the SW GPD link list */ - first = TRUE; - last = FALSE; - } - - _hal_tau_pkt_resumeRxChannelReg(unit, channel, 1); - - /* update Rx PDMA */ - ptr_rx_pdma->cur_idx++; - ptr_rx_pdma->cur_idx %= ptr_rx_pdma->gpd_num; - loop_cnt--; - } - - osal_giveSemaphore(&ptr_rx_pdma->sema); - - /* update ISR and counter */ - ptr_rx_cb->cnt.channel[channel].rx_done++; - - _hal_tau_pkt_unmaskIntr(unit, HAL_TAU_PKT_RCH_REG(unit, channel)); - - /* prevent this task from executing too long */ - if (!(time_before(jiffies, timeout))) - { - schedule(); - timeout = jiffies + 1; /* continuously rx for 1 tick */ - } - - } while (NPS_E_OK == osal_isRunThread()); - osal_exitRunThread(); -} - -static void -_hal_tau_pkt_net_dev_tx_callback( - const UI32_T unit, - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_gpd, - struct sk_buff *ptr_skb) -{ - NPS_ADDR_T phy_addr = 0; - - /* unmap dma */ - phy_addr = NPS_ADDR_32_TO_64(ptr_sw_gpd->tx_gpd.data_buf_addr_hi, ptr_sw_gpd->tx_gpd.data_buf_addr_lo); - osal_skb_unmapDma(phy_addr, ptr_skb->len, DMA_TO_DEVICE); - - /* free skb */ - osal_skb_free(ptr_skb); - - /* free gpd */ - osal_free(ptr_sw_gpd); -} - -/* FUNCTION NAME: hal_tau_pkt_initTask - * PURPOSE: - * To initialize the Task for packet module. - * INPUT: - * unit -- The unit ID - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully dinitialize the control block. - * NPS_E_OTHERS -- Initialize the control block failed. - * NOTES: - * None - */ -NPS_ERROR_NO_T -hal_tau_pkt_initTask( - const UI32_T unit) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - UI32_T channel = 0; - - if (0 != (ptr_cb->init_flag & HAL_TAU_PKT_INIT_TASK)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_ERR, - "u=%u, pkt task init failed, not inited\n", unit); - return (rc); - } - - /* Init handleErrorTask */ - rc = osal_createThread("ERROR", HAL_DFLT_CFG_PKT_ERROR_ISR_THREAD_STACK, - HAL_DFLT_CFG_PKT_ERROR_ISR_THREAD_PRI, _hal_tau_pkt_handleErrorTask, - (void *)((NPS_HUGE_T)unit), &ptr_cb->err_task_id); - - /* Init handleTxDoneTask */ - for (channel = 0; ((channel < HAL_TAU_PKT_TX_CHANNEL_LAST) && (NPS_E_OK == rc)); channel++) - { - ptr_tx_cb->isr_task_cookie[channel].unit = unit; - ptr_tx_cb->isr_task_cookie[channel].channel = channel; - - rc = osal_createThread("TX_ISR", HAL_DFLT_CFG_PKT_TX_ISR_THREAD_STACK, - HAL_DFLT_CFG_PKT_TX_ISR_THREAD_PRI, _hal_tau_pkt_handleTxDoneTask, - (void *)&ptr_tx_cb->isr_task_cookie[channel], - &ptr_tx_cb->isr_task_id[channel]); - } - - /* Init handleRxDoneTask */ - for (channel = 0; ((channel < HAL_TAU_PKT_RX_CHANNEL_LAST) && (NPS_E_OK == rc)); channel++) - { - ptr_rx_cb->isr_task_cookie[channel].unit = unit; - ptr_rx_cb->isr_task_cookie[channel].channel = channel; - - rc = osal_createThread("RX_ISR", HAL_DFLT_CFG_PKT_RX_ISR_THREAD_STACK, - HAL_DFLT_CFG_PKT_RX_ISR_THREAD_PRI, _hal_tau_pkt_handleRxDoneTask, - (void *)&ptr_rx_cb->isr_task_cookie[channel], - &ptr_rx_cb->isr_task_id[channel]); - } - - /* Init txTask */ - if (HAL_TAU_PKT_TX_WAIT_ASYNC == ptr_tx_cb->wait_mode) - { - ptr_tx_cb->running = TRUE; - } - - ptr_cb->init_flag |= HAL_TAU_PKT_INIT_TASK; - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, - "u=%u, pkt task init done, init flag=0x%x\n", unit, ptr_cb->init_flag); - - /* For some specail case in warmboot, the netifs are not destroyed during sdk deinit - * but stopped, here we need to resume them with the original carrier status - */ - _hal_tau_pkt_resumeAllIntf(unit); - - ptr_tx_cb->net_tx_allowed = TRUE; - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_initTxPdma - * PURPOSE: - * To initialize the TX PDMA. - * INPUT: - * unit -- The unit ID - * channel -- The target Tx channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully initialize the TX PDMA. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_initTxPdma( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - HAL_TAU_PKT_TX_PDMA_T *ptr_tx_pdma = HAL_TAU_PKT_GET_TX_PDMA_PTR(unit, channel); - NPS_IRQ_FLAGS_T irg_flags; - - /* Isr lock to protect Tx PDMA */ - osal_createIsrLock("TCH_LCK", &ptr_tx_pdma->ring_lock); - - if (HAL_TAU_PKT_TX_WAIT_SYNC_INTR == ptr_tx_cb->wait_mode) - { - /* Sync semaphore to signal sendTxPacket */ - osal_createSemaphore("TCH_SYN", NPS_SEMAPHORE_SYNC, &ptr_tx_pdma->sync_intr_sema); - } - - /* Reset Tx PDMA */ - osal_takeIsrLock(&ptr_tx_pdma->ring_lock, &irg_flags); - - ptr_tx_pdma->used_idx = 0; - ptr_tx_pdma->free_idx = 0; - ptr_tx_pdma->used_gpd_num = 0; - ptr_tx_pdma->free_gpd_num = HAL_DFLT_CFG_PKT_TX_GPD_NUM; - ptr_tx_pdma->gpd_num = HAL_DFLT_CFG_PKT_TX_GPD_NUM; - - /* Prepare the HW-GPD ring */ - ptr_tx_pdma->ptr_gpd_start_addr = (HAL_TAU_PKT_TX_GPD_T *)osal_dma_alloc( - (ptr_tx_pdma->gpd_num + 1) * sizeof(HAL_TAU_PKT_TX_GPD_T)); - - if (NULL != ptr_tx_pdma->ptr_gpd_start_addr) - { - osal_memset(ptr_tx_pdma->ptr_gpd_start_addr, 0x0, - (ptr_tx_pdma->gpd_num + 1) * sizeof(HAL_TAU_PKT_TX_GPD_T)); - - ptr_tx_pdma->ptr_gpd_align_start_addr = (HAL_TAU_PKT_TX_GPD_T *)HAL_TAU_PKT_PDMA_ALIGN_ADDR( - (NPS_HUGE_T)ptr_tx_pdma->ptr_gpd_start_addr, sizeof(HAL_TAU_PKT_TX_GPD_T)); - - rc = _hal_tau_pkt_initTxPdmaRing(unit, channel); - if (NPS_E_OK == rc) - { - _hal_tau_pkt_startTxChannelReg(unit, channel, 0); - } - } - else - { - ptr_tx_cb->cnt.no_memory++; - rc = NPS_E_NO_MEMORY; - } - - if (HAL_TAU_PKT_TX_WAIT_ASYNC == ptr_tx_cb->wait_mode) - { - if (NPS_E_OK == rc) - { - /* Prepare the SW-GPD ring */ - ptr_tx_pdma->pptr_sw_gpd_ring = (HAL_TAU_PKT_TX_SW_GPD_T **)osal_alloc( - ptr_tx_pdma->gpd_num * sizeof(HAL_TAU_PKT_TX_SW_GPD_T *)); - - if (NULL != ptr_tx_pdma->pptr_sw_gpd_ring) - { - osal_memset(ptr_tx_pdma->pptr_sw_gpd_ring, 0x0, - ptr_tx_pdma->gpd_num * sizeof(HAL_TAU_PKT_TX_SW_GPD_T *)); - } - else - { - ptr_tx_cb->cnt.no_memory++; - rc = NPS_E_NO_MEMORY; - } - - /* a temp buffer to store the 1st sw gpd for each packet to be enque - * we cannot enque packet before release a spinlock - */ - ptr_tx_pdma->pptr_sw_gpd_bulk = (HAL_TAU_PKT_TX_SW_GPD_T **)osal_alloc( - ptr_tx_pdma->gpd_num * sizeof(HAL_TAU_PKT_TX_SW_GPD_T *)); - - if (NULL != ptr_tx_pdma->pptr_sw_gpd_bulk) - { - osal_memset(ptr_tx_pdma->pptr_sw_gpd_bulk, 0x0, - ptr_tx_pdma->gpd_num * sizeof(HAL_TAU_PKT_TX_SW_GPD_T *)); - } - else - { - ptr_tx_cb->cnt.no_memory++; - rc = NPS_E_NO_MEMORY; - } - } - } - - osal_giveIsrLock(&ptr_tx_pdma->ring_lock, &irg_flags); - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_initRxPdma - * PURPOSE: - * To initialize the RX PDMA. - * INPUT: - * unit -- The unit ID - * channel -- The target Rx channel - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully initialize the RX PDMA. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_initRxPdma( - const UI32_T unit, - const HAL_TAU_PKT_RX_CHANNEL_T channel) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - HAL_TAU_PKT_RX_PDMA_T *ptr_rx_pdma = HAL_TAU_PKT_GET_RX_PDMA_PTR(unit, channel); - - /* Binary semaphore to protect Rx PDMA */ - osal_createSemaphore("RCH_LCK", NPS_SEMAPHORE_BINARY, &ptr_rx_pdma->sema); - - /* Reset Rx PDMA */ - osal_takeSemaphore(&ptr_rx_pdma->sema, NPS_SEMAPHORE_WAIT_FOREVER); - ptr_rx_pdma->cur_idx = 0; - ptr_rx_pdma->gpd_num = HAL_DFLT_CFG_PKT_RX_GPD_NUM; - - /* Prepare the HW-GPD ring */ - ptr_rx_pdma->ptr_gpd_start_addr = (HAL_TAU_PKT_RX_GPD_T *)osal_dma_alloc( - (ptr_rx_pdma->gpd_num + 1) * sizeof(HAL_TAU_PKT_RX_GPD_T)); - - if (NULL != ptr_rx_pdma->ptr_gpd_start_addr) - { - osal_memset(ptr_rx_pdma->ptr_gpd_start_addr, 0, - (ptr_rx_pdma->gpd_num + 1) * sizeof(HAL_TAU_PKT_RX_GPD_T)); - - ptr_rx_pdma->ptr_gpd_align_start_addr = (HAL_TAU_PKT_RX_GPD_T *)HAL_TAU_PKT_PDMA_ALIGN_ADDR( - (NPS_HUGE_T)ptr_rx_pdma->ptr_gpd_start_addr, sizeof(HAL_TAU_PKT_RX_GPD_T)); - - /* will initRxPdmaRingBuf and start RCH after setRxConfig */ - rc = _hal_tau_pkt_initRxPdmaRing(unit, channel); - } - else - { - ptr_rx_cb->cnt.no_memory++; - rc = NPS_E_NO_MEMORY; - } - - if (NPS_E_OK == rc) - { - /* Prepare the SKB ring */ - ptr_rx_pdma->pptr_skb_ring = (struct sk_buff **)osal_alloc( - ptr_rx_pdma->gpd_num * sizeof(struct sk_buff *)); - - if (NULL != ptr_rx_pdma->pptr_skb_ring) - { - osal_memset(ptr_rx_pdma->pptr_skb_ring, 0x0, - ptr_rx_pdma->gpd_num * sizeof(struct sk_buff *)); - } - else - { - ptr_rx_cb->cnt.no_memory++; - rc = NPS_E_NO_MEMORY; - } - } - - osal_giveSemaphore(&ptr_rx_pdma->sema); - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_initPktCb - * PURPOSE: - * To initialize the control block of Drv. - * INPUT: - * unit -- The unit ID - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully initialize the control block. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_initPktCb( - const UI32_T unit) -{ - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - UI32_T idx = 0, vec = sizeof(_hal_tau_pkt_intr_vec) / sizeof(HAL_TAU_PKT_INTR_VEC_T); - - osal_memset(ptr_cb, 0x0, sizeof(HAL_TAU_PKT_DRV_CB_T)); - - /* Register PKT interrupt functions */ - osal_createIsrLock("ISR_LOCK", &ptr_cb->intr_lock); - osal_mdc_registerIsr(unit, _hal_tau_pkt_dispatcher, (void *)((NPS_HUGE_T)unit)); - - for (idx = 0; idx < vec; idx++) - { - osal_createEvent("ISR_EVENT", &_hal_tau_pkt_intr_vec[idx].intr_event); - ptr_cb->intr_bitmap |= (_hal_tau_pkt_intr_vec[idx].intr_reg); - } - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_initPktTxCb - * PURPOSE: - * To initialize the control block of Rx PDMA. - * INPUT: - * unit -- The unit ID - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully initialize the control block. - * NPS_E_OTHERS -- Configure failed. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_initPktTxCb( - const UI32_T unit) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - HAL_TAU_PKT_TX_CHANNEL_T channel = 0; - - osal_memset(ptr_tx_cb, 0x0, sizeof(HAL_TAU_PKT_TX_CB_T)); - - ptr_tx_cb->wait_mode = HAL_TAU_PKT_TX_WAIT_MODE; - - if (HAL_TAU_PKT_TX_WAIT_ASYNC == ptr_tx_cb->wait_mode) - { - /* Sync semaphore to signal txTask */ - osal_createEvent("TX_SYNC", &ptr_tx_cb->sync_sema); - - /* Initialize Tx GPD-queue (of first SW-GPD) from handleTxDoneTask to txTask */ - ptr_tx_cb->sw_queue.len = HAL_DFLT_CFG_PKT_TX_QUEUE_LEN; - ptr_tx_cb->sw_queue.weight = 0; - - osal_createSemaphore("TX_QUE", NPS_SEMAPHORE_BINARY, &ptr_tx_cb->sw_queue.sema); - osal_que_create(&ptr_tx_cb->sw_queue.que_id, ptr_tx_cb->sw_queue.len); - } - else if (HAL_TAU_PKT_TX_WAIT_SYNC_POLL == ptr_tx_cb->wait_mode) - { - /* Disable TX done ISR. */ - for (channel = 0; channel < HAL_TAU_PKT_TX_CHANNEL_LAST; channel++) - { - _hal_tau_pkt_disableIntr(unit, HAL_TAU_PKT_TCH_REG(unit, channel)); - } - } - - /* Init Tx PDMA */ - for (channel = 0; ((channel < HAL_TAU_PKT_TX_CHANNEL_LAST) && (NPS_E_OK == rc)); channel++) - { - rc = _hal_tau_pkt_initTxPdma(unit, channel); - } - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_initPktRxCb - * PURPOSE: - * To initialize the control block of Rx PDMA. - * INPUT: - * unit -- The unit ID - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully initialize the control block. - * NPS_E_OTHERS -- Configure failed. - * NOTES: - * - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_initPktRxCb( - const UI32_T unit) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - HAL_TAU_PKT_RX_CB_T *ptr_rx_cb = HAL_TAU_PKT_GET_RX_CB_PTR(unit); - HAL_TAU_PKT_RX_CHANNEL_T channel = 0; - UI32_T queue = 0; - - osal_memset(ptr_rx_cb, 0x0, sizeof(HAL_TAU_PKT_RX_CB_T)); - - ptr_rx_cb->sched_mode = HAL_DFLT_CFG_PKT_RX_SCHED_MODE; - - /* Sync semaphore to signal rxTask */ - osal_createEvent("RX_SYNC", &ptr_rx_cb->sync_sema); - - /* Initialize Rx GPD-queue (of first SW-GPD) from handleRxDoneTask to rxTask */ - for (queue = 0; ((queue < HAL_TAU_PKT_RX_QUEUE_NUM) && (NPS_E_OK == rc)); queue++) - { - ptr_rx_cb->sw_queue[queue].len = HAL_DFLT_CFG_PKT_RX_QUEUE_LEN; - ptr_rx_cb->sw_queue[queue].weight = HAL_DFLT_CFG_PKT_RX_QUEUE_WEIGHT; - - osal_createSemaphore("RX_QUE", NPS_SEMAPHORE_BINARY, &ptr_rx_cb->sw_queue[queue].sema); - osal_que_create(&ptr_rx_cb->sw_queue[queue].que_id, ptr_rx_cb->sw_queue[queue].len); - } - - /* Init Rx PDMA */ - for (channel = 0; ((channel < HAL_TAU_PKT_RX_CHANNEL_LAST) && (NPS_E_OK == rc)); channel++) - { - rc = _hal_tau_pkt_initRxPdma(unit, channel); - } - - return (rc); -} - -/* FUNCTION NAME: _hal_tau_pkt_initL1Isr - * PURPOSE: - * To initialize the PDMA L1 ISR configuration. - * INPUT: - * unit -- The unit ID - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully initialize the L1 ISR. - * NPS_E_OTHERS -- Configure failed. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_initL1Isr( - const UI32_T unit) -{ - UI32_T idx = 0, vec = sizeof(_hal_tau_pkt_intr_vec) / sizeof(HAL_TAU_PKT_INTR_VEC_T); - - for (idx = 0; idx < vec; idx++) - { - _hal_tau_pkt_enableIntr(unit, _hal_tau_pkt_intr_vec[idx].intr_reg); - _hal_tau_pkt_unmaskIntr(unit, _hal_tau_pkt_intr_vec[idx].intr_reg); - } - - return (NPS_E_OK); -} - -/* FUNCTION NAME: _hal_tau_pkt_initL2Isr - * PURPOSE: - * To initialize the PDMA L2 ISR configuration. - * INPUT: - * unit -- The unit ID - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully configure for the L2 ISR. - * NPS_E_OTHERS -- Configure failed. - * NOTES: - * None - */ -static NPS_ERROR_NO_T -_hal_tau_pkt_initL2Isr( - const UI32_T unit) -{ - HAL_TAU_PKT_L2_ISR_T isr_status = 0x0; - - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_RCH0); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_RCH1); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_RCH2); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_RCH3); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_TCH0); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_TCH1); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_TCH2); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_TCH3); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_RX_QID_MAP_ERR); - HAL_TAU_PKT_SET_BITMAP(isr_status, HAL_TAU_PKT_L2_ISR_RX_FRAME_ERR); - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_ERR_INT_EN), - &isr_status, sizeof(UI32_T)); - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_ERR_INT_MASK_SET), - &isr_status, sizeof(UI32_T)); - - return (NPS_E_OK); - -} - -NPS_ERROR_NO_T -_hal_tau_pkt_resetIosCreditCfg( - const UI32_T unit) -{ -#define HAL_TAU_PKT_PDMA_CREDIT_CFG_RESET_OFFSET (16) - - UI32_T credit_cfg = 0x0; - UI32_T idx; - - for (idx=0; idxptr_profile = ptr_new_profile; - - /* Create the 1st node in the interface profile list */ - if (NULL == *pptr_profile_list) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "prof list empty\n"); - *pptr_profile_list = ptr_new_prof_node; - ptr_new_prof_node->ptr_next_node = NULL; - } - else - { - ptr_prev_node = *pptr_profile_list; - ptr_curr_node = *pptr_profile_list; - - while (ptr_curr_node != NULL) - { - if (ptr_curr_node->ptr_profile->priority <= ptr_new_profile->priority) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "find prof id=%d (%s) higher priority=%d, search next\n", - ptr_curr_node->ptr_profile->id, - ptr_curr_node->ptr_profile->name, - ptr_curr_node->ptr_profile->priority); - /* Search the next node */ - ptr_prev_node = ptr_curr_node; - ptr_curr_node = ptr_curr_node->ptr_next_node; - } - else - { - /* Insert intermediate node */ - ptr_new_prof_node->ptr_next_node = ptr_curr_node; - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "insert prof id=%d (%s) before prof id=%d (%s) (priority=%d >= %d)\n", - ptr_new_prof_node->ptr_profile->id, - ptr_new_prof_node->ptr_profile->name, - ptr_curr_node->ptr_profile->id, - ptr_curr_node->ptr_profile->name, - ptr_new_prof_node->ptr_profile->priority, - ptr_curr_node->ptr_profile->priority); - - if (ptr_prev_node == ptr_curr_node) - { - /* There is no previous node: change the root */ - *pptr_profile_list = ptr_new_prof_node; - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "insert prof id=%d (%s) to head (priority=%d)\n", - ptr_new_prof_node->ptr_profile->id, - ptr_new_prof_node->ptr_profile->name, - ptr_new_prof_node->ptr_profile->priority); - } - else - { - ptr_prev_node->ptr_next_node = ptr_new_prof_node; - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "insert prof id=%d (%s) after prof id=%d (%s) (priority=%d <= %d)\n", - ptr_new_prof_node->ptr_profile->id, - ptr_new_prof_node->ptr_profile->name, - ptr_prev_node->ptr_profile->id, - ptr_prev_node->ptr_profile->name, - ptr_new_prof_node->ptr_profile->priority, - ptr_prev_node->ptr_profile->priority); - } - - return (NPS_E_OK); - } - } - - /* Insert node to the tail of list */ - ptr_prev_node->ptr_next_node = ptr_new_prof_node; - ptr_new_prof_node->ptr_next_node = NULL; - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "insert prof id=%d (%s) to tail, after prof id=%d (%s) (priority=%d <= %d)\n", - ptr_new_prof_node->ptr_profile->id, - ptr_new_prof_node->ptr_profile->name, - ptr_prev_node->ptr_profile->id, - ptr_prev_node->ptr_profile->name, - ptr_new_prof_node->ptr_profile->priority, - ptr_prev_node->ptr_profile->priority); - } - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_addProfToAllIntf( - HAL_TAU_PKT_NETIF_PROFILE_T *ptr_new_profile) -{ - UI32_T port; - HAL_TAU_PKT_NETIF_PORT_DB_T *ptr_port_db; - - for (port = 0; port < HAL_TAU_PKT_MAX_PORT_NUM; port++) - { - ptr_port_db = HAL_TAU_PKT_GET_PORT_DB(port); - /* Shall we check if the interface is ever created on the port?? */ - /* if (NULL != ptr_port_db->ptr_net_dev) */ - if (1) - { - _hal_tau_pkt_addProfToList(ptr_new_profile, &ptr_port_db->ptr_profile_list); - } - } - - return (NPS_E_OK); -} - -static HAL_TAU_PKT_NETIF_PROFILE_T * -_hal_tau_pkt_delProfFromListById( - const UI32_T id, - HAL_TAU_PKT_PROFILE_NODE_T **pptr_profile_list) -{ - HAL_TAU_PKT_PROFILE_NODE_T *ptr_temp_node; - HAL_TAU_PKT_PROFILE_NODE_T *ptr_curr_node, *ptr_prev_node; - HAL_TAU_PKT_NETIF_PROFILE_T *ptr_profile = NULL;; - - if (NULL != *pptr_profile_list) - { - /* Check the 1st node */ - if (id == (*pptr_profile_list)->ptr_profile->id) - { - ptr_profile = (*pptr_profile_list)->ptr_profile; - ptr_temp_node = (*pptr_profile_list); - (*pptr_profile_list) = ptr_temp_node->ptr_next_node; - - if (NULL != ptr_temp_node->ptr_next_node) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "choose prof id=%d (%s) as new head\n", - ptr_temp_node->ptr_next_node->ptr_profile->id, - ptr_temp_node->ptr_next_node->ptr_profile->name); - } - else - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "prof list is empty\n"); - } - - - osal_free(ptr_temp_node); - } - else - { - ptr_prev_node = *pptr_profile_list; - ptr_curr_node = ptr_prev_node->ptr_next_node; - - while (NULL != ptr_curr_node) - { - if (id != ptr_curr_node->ptr_profile->id) - { - ptr_prev_node = ptr_curr_node; - ptr_curr_node = ptr_curr_node->ptr_next_node; - } - else - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "find prof id=%d, free done\n", id); - - ptr_profile = ptr_curr_node->ptr_profile; - ptr_prev_node->ptr_next_node = ptr_curr_node->ptr_next_node; - osal_free(ptr_curr_node); - break; - } - } - } - } - - if (NULL == ptr_profile) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_PROFILE | HAL_TAU_PKT_DBG_ERR), - "find prof failed, id=%d\n", id); - } - - return (ptr_profile); -} - - -static NPS_ERROR_NO_T -_hal_tau_pkt_delProfFromAllIntfById( - const UI32_T id) -{ - UI32_T port; - HAL_TAU_PKT_NETIF_PORT_DB_T *ptr_port_db; - - for (port = 0; port < HAL_TAU_PKT_MAX_PORT_NUM; port++) - { - ptr_port_db = HAL_TAU_PKT_GET_PORT_DB(port); - /* Shall we check if the interface is ever created on the port?? */ - /* if (NULL != ptr_port_db->ptr_net_dev) */ - if (1) - { - _hal_tau_pkt_delProfFromListById(id, &ptr_port_db->ptr_profile_list); - } - } - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_allocProfEntry( - HAL_TAU_PKT_NETIF_PROFILE_T *ptr_profile) -{ - UI32_T idx; - - for (idx=0; idxid = idx; - return (NPS_E_OK); - } - } - return (NPS_E_TABLE_FULL); -} - -static HAL_TAU_PKT_NETIF_PROFILE_T * -_hal_tau_pkt_freeProfEntry( - const UI32_T id) -{ - HAL_TAU_PKT_NETIF_PROFILE_T *ptr_profile = NULL; - - if (id < HAL_TAU_PKT_NET_PROFILE_NUM_MAX) - { - ptr_profile = _ptr_hal_tau_pkt_profile_entry[id]; - _ptr_hal_tau_pkt_profile_entry[id] = NULL; - } - - return (ptr_profile); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_destroyAllIntf( - const UI32_T unit) -{ - HAL_TAU_PKT_NETIF_PORT_DB_T *ptr_port_db; - UI32_T port = 0; - - /* Unregister net devices by id, although the "id" is now relavent to "port" we still perform a search */ - for (port = 0; port < HAL_TAU_PKT_MAX_PORT_NUM; port++) - { - ptr_port_db = HAL_TAU_PKT_GET_PORT_DB(port); - if (NULL != ptr_port_db->ptr_net_dev) /* valid intf */ - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_INTF, - "u=%u, find intf %s (id=%d) on phy port=%d, destroy done\n", - unit, - ptr_port_db->meta.name, - ptr_port_db->meta.port, - ptr_port_db->meta.port); - - netif_tx_disable(ptr_port_db->ptr_net_dev); - unregister_netdev(ptr_port_db->ptr_net_dev); - free_netdev(ptr_port_db->ptr_net_dev); - - /* Don't need to remove profiles on this port. - * In fact, the profile is binding to "port" not "intf". - */ - /* _hal_tau_pkt_destroyProfList(ptr_port_db->ptr_profile_list); */ - - osal_memset(ptr_port_db, 0x0, sizeof(HAL_TAU_PKT_NETIF_PORT_DB_T)); - } - } - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_delProfListOnAllIntf( - const UI32_T unit) -{ - HAL_TAU_PKT_NETIF_PORT_DB_T *ptr_port_db; - UI32_T port = 0; - HAL_TAU_PKT_PROFILE_NODE_T *ptr_curr_node, *ptr_next_node; - - /* Unregister net devices by id, although the "id" is now relavent to "port" we still perform a search */ - for (port = 0; port < HAL_TAU_PKT_MAX_PORT_NUM; port++) - { - ptr_port_db = HAL_TAU_PKT_GET_PORT_DB(port); - if (NULL != ptr_port_db->ptr_profile_list) /* valid intf */ - { - ptr_curr_node = ptr_port_db->ptr_profile_list; - while (NULL != ptr_curr_node) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "u=%u, del prof id=%d on phy port=%d\n", - unit, ptr_curr_node->ptr_profile->id, port); - - ptr_next_node = ptr_curr_node->ptr_next_node; - osal_free(ptr_curr_node); - ptr_curr_node = ptr_next_node; - } - } - } - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_destroyAllProfile( - const UI32_T unit) -{ - HAL_TAU_PKT_NETIF_PROFILE_T *ptr_profile; - UI32_T prof_id; - - _hal_tau_pkt_delProfListOnAllIntf(unit); - - for (prof_id=0; prof_idid, - ptr_profile->name, - ptr_profile->priority, - ptr_profile->flags); - osal_free(ptr_profile); - } - } - - return (NPS_E_OK); -} - -/* FUNCTION NAME: hal_tau_pkt_initPktDrv - * PURPOSE: - * To invoke the functions to initialize the control block for each - * PDMA subsystem. - * INPUT: - * unit -- The unit ID - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successfully initialize the control blocks. - * NPS_E_OTHERS -- Initialize the control blocks failed. - * NOTES: - * None - */ -NPS_ERROR_NO_T -hal_tau_pkt_initPktDrv( - const UI32_T unit) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - UI32_T channel = 0; - UI32_T flush_intr = 0x0; - UI32_T clear_intr = 0xffffffff; - HAL_TAU_PKT_DRV_CB_T *ptr_cb = HAL_TAU_PKT_GET_DRV_CB_PTR(unit); - - /* There's a case that PDMA Tx is on-going when doing chip reset, - * where PDMA may hang and be not programmable since current Tx packet - * stucks due to IOS credit too low. - * Thus, we always reset IOS credit value before progrmming Tx PDMA. - */ - _hal_tau_pkt_resetIosCreditCfg(unit); - - /* Since the users may kill SDK application without a de-init flow, - * we help to detect if NETIF is ever init before, and perform deinit. - * (Because the users cannot perform Task init bypassing Drv init, this - * check is required only in here) - */ - if (0 != (ptr_cb->init_flag & HAL_TAU_PKT_INIT_DRV)) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_ERR, - "u=%u, init pkt drv failed, inited\n", unit); - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_ERR, - "u=%u, stop rx pkt\n", unit); - _hal_tau_pkt_rxStop(unit); - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_ERR, - "u=%u, stop all intf\n", unit); - _hal_tau_pkt_stopAllIntf(unit); - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_ERR, - "u=%u, deinit pkt task\n", unit); - - hal_tau_pkt_deinitTask(unit); - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_ERR, - "u=%u, deinit pkt drv\n", unit); - hal_tau_pkt_deinitPktDrv(unit); - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_ERR, - "u=%u, destroy all prof\n", unit); - _hal_tau_pkt_destroyAllProfile(unit); - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_ERR, - "u=%u, destroy all intf\n", unit); - _hal_tau_pkt_destroyAllIntf(unit); - } - - /* [cold-boot] 1. stop DMA channel - * 2. disable/mask/clear the interrupt status. - */ - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_ERR_INT_EN), - &flush_intr, sizeof(UI32_T)); - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_ERR_INT_MASK_SET), - &clear_intr, sizeof(UI32_T)); - - osal_mdc_writePciReg(unit, - HAL_TAU_PKT_GET_MMIO(HAL_TAU_PKT_PDMA_ERR_INT_CLR), - &clear_intr, sizeof(UI32_T)); - - for (channel = 0; channel < HAL_TAU_PKT_TX_CHANNEL_LAST; channel++) - { - _hal_tau_pkt_stopTxChannelReg(unit, channel); - _hal_tau_pkt_maskAllTxL2IsrReg(unit, channel); - _hal_tau_pkt_clearTxL2IsrStatusReg(unit, channel, clear_intr); - } - - for (channel = 0; channel < HAL_TAU_PKT_RX_CHANNEL_LAST; channel++) - { - _hal_tau_pkt_stopRxChannelReg(unit, channel); - _hal_tau_pkt_maskAllRxL2IsrReg(unit, channel); - _hal_tau_pkt_clearRxL2IsrStatusReg(unit, channel, clear_intr); - } - - rc = _hal_tau_pkt_initPktCb(unit); - if (NPS_E_OK == rc) - { - rc = _hal_tau_pkt_initPktTxCb(unit); - } - if (NPS_E_OK == rc) - { - rc = _hal_tau_pkt_initPktRxCb(unit); - } - if (NPS_E_OK == rc) - { - rc = _hal_tau_pkt_initL1Isr(unit); - } - if (NPS_E_OK == rc) - { - rc = _hal_tau_pkt_initL2Isr(unit); - } - - /* Set the flag to record init state */ - ptr_cb->init_flag |= HAL_TAU_PKT_INIT_DRV; - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, - "u=%u, pkt drv init done, init flag=0x%x\n", unit, ptr_cb->init_flag); - - return (rc); -} - -/* ----------------------------------------------------------------------------------- Init: I/O */ -NPS_ERROR_NO_T -hal_tau_pkt_getNetDev( - const UI32_T unit, - const UI32_T port, - struct net_device **pptr_net_dev) -{ - *pptr_net_dev = HAL_TAU_PKT_GET_PORT_NETDEV(port); - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -hal_tau_pkt_prepareGpd( - const UI32_T unit, - const NPS_ADDR_T phy_addr, - const UI32_T len, - const UI32_T port, - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_gpd) -{ - /* fill up tx_gpd */ - ptr_sw_gpd->tx_gpd.data_buf_addr_hi = NPS_ADDR_64_HI(phy_addr); - ptr_sw_gpd->tx_gpd.data_buf_addr_lo = NPS_ADDR_64_LOW(phy_addr); - ptr_sw_gpd->tx_gpd.data_buf_size = len; - ptr_sw_gpd->tx_gpd.chksum = 0x0; - ptr_sw_gpd->tx_gpd.ipc = 0; /* Raw mode, sent to plane 0 */ - ptr_sw_gpd->tx_gpd.prg = HAL_TAU_PKT_PRG_PROCESS_GPD; - ptr_sw_gpd->tx_gpd.hwo = HAL_TAU_PKT_HWO_HW_OWN; - ptr_sw_gpd->tx_gpd.ch = HAL_TAU_PKT_CH_LAST_GPD; - ptr_sw_gpd->tx_gpd.ioc = HAL_TAU_PKT_IOC_HAS_INTR; - ptr_sw_gpd->tx_gpd.pkt_len = len; - ptr_sw_gpd->tx_gpd.crcc = HAL_TAU_PKT_CRCC_SUM_BY_HW; - - /* fill up cpu header */ - ptr_sw_gpd->tx_gpd.itmh_eth.skip_ipp = 1; - ptr_sw_gpd->tx_gpd.itmh_eth.skip_epp = 1; - ptr_sw_gpd->tx_gpd.itmh_eth.color = 0; /* Green */ - ptr_sw_gpd->tx_gpd.itmh_eth.tc = 15; /* Max tc */ - ptr_sw_gpd->tx_gpd.itmh_eth.igr_phy_port = 0; - - ptr_sw_gpd->tx_gpd.pph_l2.mrk_pcp_val = 7; /* Max pcp */ - ptr_sw_gpd->tx_gpd.pph_l2.mrk_pcp_dei_en = 1; - - /* destination index - * 1. to local ETH port - * 2. to remote ETH port - * 3. to remote CPU - */ - ptr_sw_gpd->tx_gpd.itmh_eth.dst_idx = port; - - /* [NP8360] we should set all-1 for the following fields to skip some tm-logic */ - - /* TM header */ - ptr_sw_gpd->tx_gpd.itmh_eth.src_idx = 0x7fff; - ptr_sw_gpd->tx_gpd.itmh_eth.intf_fdid = 0x3fff; - ptr_sw_gpd->tx_gpd.itmh_eth.src_supp_tag = 0x1f; - ptr_sw_gpd->tx_gpd.itmh_eth.nvo3_mgid = 0x6fff; - ptr_sw_gpd->tx_gpd.itmh_eth.nvo3_src_supp_tag_w0 = 0x1; - ptr_sw_gpd->tx_gpd.itmh_eth.nvo3_src_supp_tag_w1 = 0xf; - - /* PP header */ - ptr_sw_gpd->tx_gpd.pph_l2.nvo3_encap_idx = HAL_INVALID_NVO3_ENCAP_IDX; - ptr_sw_gpd->tx_gpd.pph_l2.nvo3_adj_idx = HAL_INVALID_NVO3_ADJ_IDX; - - return (NPS_E_OK); -} - -/* ----------------------------------------------------------------------------------- Init: net_dev_ops */ -static int -_hal_tau_pkt_net_dev_init( - struct net_device *ptr_net_dev) -{ - return 0; -} - -static int -_hal_tau_pkt_net_dev_open( - struct net_device *ptr_net_dev) -{ - netif_start_queue(ptr_net_dev); - -#if defined(PERF_EN_TEST) - /* Tx (len, tx_channel, rx_channel, test_skb) */ - perf_test(64, 1, 0, FALSE); - perf_test(64, 2, 0, FALSE); - perf_test(64, 4, 0, FALSE); - - perf_test(1518, 1, 0, FALSE); - perf_test(1518, 2, 0, FALSE); - perf_test(1518, 4, 0, FALSE); - - perf_test(9216, 1, 0, FALSE); - perf_test(9216, 2, 0, FALSE); - perf_test(9216, 4, 0, FALSE); - - /* Rx (len, tx_channel, rx_channel, test_skb) */ - perf_test(64, 0, 1, FALSE); - perf_test(64, 0, 3, FALSE); - perf_test(64, 0, 4, FALSE); - - perf_test(1518, 0, 1, FALSE); - perf_test(1518, 0, 3, FALSE); - perf_test(1518, 0, 4, FALSE); - - perf_test(9216, 0, 1, FALSE); - perf_test(9216, 0, 3, FALSE); - perf_test(9216, 0, 4, FALSE); -#endif - - return 0; -} - -static int -_hal_tau_pkt_net_dev_stop( - struct net_device *ptr_net_dev) -{ - netif_stop_queue(ptr_net_dev); - return 0; -} - -static int -_hal_tau_pkt_net_dev_ioctl( - struct net_device *ptr_net_dev, - struct ifreq *ptr_ifreq, - int cmd) -{ - return 0; -} - -static netdev_tx_t -_hal_tau_pkt_net_dev_tx( - struct sk_buff *ptr_skb, - struct net_device *ptr_net_dev) -{ - struct net_device_priv *ptr_priv = netdev_priv(ptr_net_dev); - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb; - /* chip meta */ - unsigned int unit; - unsigned int channel = 0; - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_gpd = NULL; - void *ptr_virt_addr = NULL; - NPS_ADDR_T phy_addr = 0x0; - - if (NULL == ptr_priv) - { - /* in case that the netdev has been freed/reset somewhere */ - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_ERR, "get netdev_priv failed\n"); - return -EFAULT; - } - - /* check skb */ - if (NULL == ptr_skb) - { - ptr_priv->stats.tx_errors++; - return -EFAULT; - } - - unit = ptr_priv->unit; - - ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - /* for warm de-init procedure, if any net intf not destroyed, it is possible - * that kernel still has packets to send causing segmentation fault - */ - if (FALSE == ptr_tx_cb->net_tx_allowed) { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_ERR, "net tx during sdk de-init\n"); - ptr_priv->stats.tx_dropped++; - osal_skb_free(ptr_skb); - return NETDEV_TX_OK; - } - - /* pad to 60-bytes if skb_len < 60, see: eth_skb_pad(skb) */ - if (ptr_skb->len < ETH_ZLEN) - { - skb_pad(ptr_skb, ETH_ZLEN - ptr_skb->len); - skb_set_tail_pointer(ptr_skb, ETH_ZLEN); - ptr_skb->len = ETH_ZLEN; - } - - /* pad 4-bytes for chip-crc */ - skb_pad(ptr_skb, ETH_FCS_LEN); - skb_set_tail_pointer(ptr_skb, ETH_FCS_LEN); - ptr_skb->len += ETH_FCS_LEN; - - /* alloc gpd */ - ptr_sw_gpd = osal_alloc(sizeof(HAL_TAU_PKT_TX_SW_GPD_T)); - if (NULL == ptr_sw_gpd) - { - ptr_priv->stats.tx_errors++; - osal_skb_free(ptr_skb); - } - else - { - /* map skb to dma */ - ptr_virt_addr = ptr_skb->data; - phy_addr = osal_skb_mapDma(ptr_skb, DMA_TO_DEVICE); - if (0x0 == phy_addr) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_ERR, "u=%u, txch=%u, skb dma map err\n", - unit, channel); - ptr_priv->stats.tx_errors++; - osal_skb_free(ptr_skb); - osal_free(ptr_sw_gpd); - } - else - { - /* trans skb to gpd */ - memset(ptr_sw_gpd, 0x0, sizeof(HAL_TAU_PKT_TX_SW_GPD_T)); - ptr_sw_gpd->callback = (void *)_hal_tau_pkt_net_dev_tx_callback; - ptr_sw_gpd->ptr_cookie = (void *)ptr_skb; - ptr_sw_gpd->gpd_num = 1; - ptr_sw_gpd->ptr_next = NULL; - ptr_sw_gpd->channel = channel; - - /* prepare gpd */ - hal_tau_pkt_prepareGpd(unit, phy_addr, ptr_skb->len, ptr_priv->port, ptr_sw_gpd); - -#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,6,7) - ptr_net_dev->trans_start = jiffies; -#else - netdev_get_tx_queue(ptr_net_dev, 0)->trans_start = jiffies; -#endif - /* send gpd */ - if (NPS_E_OK == hal_tau_pkt_sendGpd(unit, channel, ptr_sw_gpd)) - { - ptr_priv->stats.tx_packets++; - ptr_priv->stats.tx_bytes += ptr_skb->len; - } - else - { - ptr_priv->stats.tx_fifo_errors++; /* to record the extreme cases where packets are dropped */ - ptr_priv->stats.tx_dropped++; - - osal_skb_unmapDma(phy_addr, ptr_skb->len, DMA_TO_DEVICE); - osal_skb_free(ptr_skb); - osal_free(ptr_sw_gpd); - } - } - } - - return NETDEV_TX_OK; -} - -static void -_hal_tau_pkt_net_dev_tx_timeout( - struct net_device *ptr_net_dev) -{ - netif_stop_queue(ptr_net_dev); - osal_sleepThread(1000); - netif_wake_queue(ptr_net_dev); -} - -static struct net_device_stats * -_hal_tau_pkt_net_dev_get_stats( - struct net_device *ptr_net_dev) -{ - struct net_device_priv *ptr_priv = netdev_priv(ptr_net_dev); - - return (&ptr_priv->stats); -} - -static int -_hal_tau_pkt_net_dev_set_mtu( - struct net_device *ptr_net_dev, - int new_mtu) -{ - if (new_mtu < 64 || new_mtu > 9216) - { - return -EINVAL; - } - ptr_net_dev->mtu = new_mtu; /* This mtu need to be synced to chip's */ - return 0; -} - -static int -_hal_tau_pkt_net_dev_set_mac( - struct net_device *ptr_net_dev, - void *ptr_mac_addr) -{ - struct sockaddr *ptr_addr = ptr_mac_addr; - - memcpy(ptr_net_dev->dev_addr, ptr_addr->sa_data, ptr_net_dev->addr_len); - return 0; -} - -static void -_hal_tau_pkt_net_dev_set_rx_mode( - struct net_device *ptr_dev) -{ - if (ptr_dev->flags & IFF_PROMISC) - { - } - else - { - if (ptr_dev->flags & IFF_ALLMULTI) - { - } - else - { - if (netdev_mc_empty(ptr_dev)) - { - return; - } - } - } -} - -static struct net_device_ops _hal_tau_pkt_net_dev_ops = -{ - .ndo_init = _hal_tau_pkt_net_dev_init, - .ndo_open = _hal_tau_pkt_net_dev_open, - .ndo_stop = _hal_tau_pkt_net_dev_stop, - .ndo_do_ioctl = _hal_tau_pkt_net_dev_ioctl, - .ndo_start_xmit = _hal_tau_pkt_net_dev_tx, - .ndo_tx_timeout = _hal_tau_pkt_net_dev_tx_timeout, - .ndo_get_stats = _hal_tau_pkt_net_dev_get_stats, - .ndo_change_mtu = _hal_tau_pkt_net_dev_set_mtu, - .ndo_set_mac_address = _hal_tau_pkt_net_dev_set_mac, - .ndo_set_rx_mode = _hal_tau_pkt_net_dev_set_rx_mode, -}; - -static int -_hal_tau_pkt_net_dev_ethtool_get( - struct net_device *ptr_dev, - struct ethtool_cmd *ptr_cmd) -{ - struct net_device_priv *ptr_priv; - - ptr_cmd->supported = SUPPORTED_1000baseT_Full | SUPPORTED_FIBRE; - ptr_cmd->port = PORT_FIBRE; - ptr_cmd->duplex = DUPLEX_FULL; - - ptr_priv = netdev_priv(ptr_dev); - ethtool_cmd_speed_set(ptr_cmd, ptr_priv->speed); - - return 0; -} - -static struct ethtool_ops _hal_tau_pkt_net_dev_ethtool_ops = -{ - .get_settings = _hal_tau_pkt_net_dev_ethtool_get, - .get_link = ethtool_op_get_link, -}; - -static void -_hal_tau_pkt_setup( - struct net_device *ptr_net_dev) -{ - struct net_device_priv *ptr_priv = netdev_priv(ptr_net_dev); - - /* setup net device */ - ether_setup(ptr_net_dev); - ptr_net_dev->netdev_ops = &_hal_tau_pkt_net_dev_ops; - ptr_net_dev->ethtool_ops = &_hal_tau_pkt_net_dev_ethtool_ops; - ptr_net_dev->watchdog_timeo = HAL_TAU_PKT_TX_TIMEOUT; - ptr_net_dev->mtu = HAL_TAU_PKT_MAX_ETH_FRAME_SIZE; /* This mtu need to be synced to chip's */ - random_ether_addr(ptr_net_dev->dev_addr); /* Please use the mac-addr of interface. */ - - /* setup private data */ - ptr_priv->ptr_net_dev = ptr_net_dev; - memset(&ptr_priv->stats, 0, sizeof(struct net_device_stats)); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_createIntf( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *ptr_cookie) -{ - HAL_TAU_PKT_NETIF_INTF_T net_intf = {0}; - HAL_TAU_PKT_NETIF_PORT_DB_T *ptr_port_db; - struct net_device *ptr_net_dev = NULL; - struct net_device_priv *ptr_priv = NULL; - NPS_ERROR_NO_T rc = NPS_E_OK; - - /* Lock all Rx tasks to avoid any access to the intf during packet processing */ - /* Only Rx tasks are locked since Tx action is performed under a spinlock protection */ - _hal_tau_pkt_lockRxChannelAll(unit); - - osal_io_copyFromUser(&net_intf, &ptr_cookie->net_intf, sizeof(HAL_TAU_PKT_NETIF_INTF_T)); - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_INTF, "u=%u, create intf name=%s, phy port=%d\n", - unit, net_intf.name, net_intf.port); - - /* To check if the interface with the same name exists in kernel */ - ptr_net_dev = dev_get_by_name(&init_net, net_intf.name); - if (NULL != ptr_net_dev) - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_ERR | HAL_TAU_PKT_DBG_INTF), - "u=%u, create intf failed, exist same name=%s\n", - unit, net_intf.name); - - dev_put(ptr_net_dev); - -#if defined(HAL_TAU_PKT_FORCR_REMOVE_DUPLICATE_NETDEV) - ptr_net_dev->operstate = IF_OPER_DOWN; - netif_carrier_off(ptr_net_dev); - netif_tx_disable(ptr_net_dev); - unregister_netdev(ptr_net_dev); - free_netdev(ptr_net_dev); -#endif - _hal_tau_pkt_unlockRxChannelAll(unit); - return (NPS_E_ENTRY_EXISTS); - } - - /* Bind the net dev and intf meta data to internel port-based array */ - ptr_port_db = HAL_TAU_PKT_GET_PORT_DB(net_intf.port); - if (ptr_port_db->ptr_net_dev == NULL) - { - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0) - ptr_net_dev = alloc_netdev(sizeof(struct net_device_priv), - net_intf.name, NET_NAME_UNKNOWN, _hal_tau_pkt_setup); -#else - ptr_net_dev = alloc_netdev(sizeof(struct net_device_priv), - net_intf.name, _hal_tau_pkt_setup); -#endif - memcpy(ptr_net_dev->dev_addr, net_intf.mac, ptr_net_dev->addr_len); - - ptr_priv = netdev_priv(ptr_net_dev); - - /* Port info will be used when packet sent from this netdev */ - ptr_priv->port = net_intf.port; - ptr_priv->id = net_intf.port; - ptr_priv->unit = unit; - - register_netdev(ptr_net_dev); - - netif_carrier_off(ptr_net_dev); - - net_intf.id = net_intf.port; /* Currently, id is 1-to-1 mapped to port */ - osal_memcpy(&ptr_port_db->meta, &net_intf, sizeof(HAL_TAU_PKT_NETIF_INTF_T)); - - ptr_port_db->ptr_net_dev = ptr_net_dev; - - /* Copy the intf-id to user space */ - osal_io_copyToUser(&ptr_cookie->net_intf, &net_intf, sizeof(HAL_TAU_PKT_NETIF_INTF_T)); - } - else - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_INTF | HAL_TAU_PKT_DBG_ERR), - "u=%u, create intf failed, exist on phy port=%d\n", - unit, net_intf.port); - /* The user needs to delete the existing intf binding to the same port */ - rc = NPS_E_ENTRY_EXISTS; - } - - osal_io_copyToUser(&ptr_cookie->rc, &rc, sizeof(NPS_ERROR_NO_T)); - - _hal_tau_pkt_unlockRxChannelAll(unit); - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_destroyIntf( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *ptr_cookie) -{ - HAL_TAU_PKT_NETIF_INTF_T net_intf = {0}; - HAL_TAU_PKT_NETIF_PORT_DB_T *ptr_port_db; - UI32_T port = 0; - NPS_ERROR_NO_T rc = NPS_E_ENTRY_NOT_FOUND; - - /* Lock all Rx tasks to avoid any access to the intf during packet processing */ - /* Only Rx tasks are locked since Tx action is performed under a spinlock protection */ - _hal_tau_pkt_lockRxChannelAll(unit); - - osal_io_copyFromUser(&net_intf, &ptr_cookie->net_intf, sizeof(HAL_TAU_PKT_NETIF_INTF_T)); - - /* Unregister net devices by id, although the "id" is now relavent to "port" we still perform a search */ - for (port = 0; port < HAL_TAU_PKT_MAX_PORT_NUM; port++) - { - ptr_port_db = HAL_TAU_PKT_GET_PORT_DB(port); - if (NULL != ptr_port_db->ptr_net_dev) /* valid intf */ - { - if (ptr_port_db->meta.id == net_intf.id) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_INTF, - "u=%u, find intf %s (id=%d) on phy port=%d, destroy done\n", - unit, - ptr_port_db->meta.name, - ptr_port_db->meta.id, - ptr_port_db->meta.port); - - netif_carrier_off(ptr_port_db->ptr_net_dev); - netif_tx_disable(ptr_port_db->ptr_net_dev); - unregister_netdev(ptr_port_db->ptr_net_dev); - free_netdev(ptr_port_db->ptr_net_dev); - - /* Don't need to remove profiles on this port. - * In fact, the profile is binding to "port" not "intf". - */ - /* _hal_tau_pkt_destroyProfList(ptr_port_db->ptr_profile_list); */ - - osal_memset(ptr_port_db, 0x0, sizeof(HAL_TAU_PKT_NETIF_PORT_DB_T)); - rc = NPS_E_OK; - break; - } - } - } - - osal_io_copyToUser(&ptr_cookie->rc, &rc, sizeof(NPS_ERROR_NO_T)); - - _hal_tau_pkt_unlockRxChannelAll(unit); - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_traverseProfList( - UI32_T intf_id, - HAL_TAU_PKT_PROFILE_NODE_T *ptr_prof_list) -{ - HAL_TAU_PKT_PROFILE_NODE_T *ptr_curr_node; - - ptr_curr_node = ptr_prof_list; - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_INTF, "intf id=%d, prof list=", intf_id); - while(NULL != ptr_curr_node) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_INTF, "%s (%d) => ", - ptr_curr_node->ptr_profile->name, - ptr_curr_node->ptr_profile->priority); - ptr_curr_node = ptr_curr_node->ptr_next_node; - } - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_INTF, "null\n"); - return (NPS_E_OK); -} - - -static NPS_ERROR_NO_T -_hal_tau_pkt_getIntf( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *ptr_cookie) -{ - HAL_TAU_PKT_NETIF_INTF_T net_intf = {0}; - HAL_TAU_PKT_NETIF_PORT_DB_T *ptr_port_db; - UI32_T port = 0; - NPS_ERROR_NO_T rc = NPS_E_ENTRY_NOT_FOUND; - - osal_io_copyFromUser(&net_intf, &ptr_cookie->net_intf, sizeof(HAL_TAU_PKT_NETIF_INTF_T)); - - for (port = 0; port < HAL_TAU_PKT_MAX_PORT_NUM; port++) - { - ptr_port_db = HAL_TAU_PKT_GET_PORT_DB(port); - if (NULL != ptr_port_db->ptr_net_dev) /* valid intf */ - { - if (ptr_port_db->meta.id == net_intf.id) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_INTF, "u=%u, find intf id=%d\n", unit, net_intf.id); - _hal_tau_pkt_traverseProfList(net_intf.id, ptr_port_db->ptr_profile_list); - osal_io_copyToUser(&ptr_cookie->net_intf, &ptr_port_db->meta, sizeof(HAL_TAU_PKT_NETIF_INTF_T)); - rc = NPS_E_OK; - break; - } - } - } - - osal_io_copyToUser(&ptr_cookie->rc, &rc, sizeof(NPS_ERROR_NO_T)); - - return (NPS_E_OK); -} - -static HAL_TAU_PKT_NETIF_PROFILE_T * -_hal_tau_pkt_getProfEntry( - const UI32_T id) -{ - HAL_TAU_PKT_NETIF_PROFILE_T *ptr_profile = NULL; - - if (id < HAL_TAU_PKT_NET_PROFILE_NUM_MAX) - { - if (NULL != _ptr_hal_tau_pkt_profile_entry[id]) - { - ptr_profile = _ptr_hal_tau_pkt_profile_entry[id]; - } - } - - return (ptr_profile); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_createProfile( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *ptr_cookie) -{ - HAL_TAU_PKT_NETIF_PROFILE_T *ptr_profile; - HAL_TAU_PKT_NETIF_PORT_DB_T *ptr_port_db; - NPS_ERROR_NO_T rc; - - /* Lock all Rx tasks to avoid profiles being refered during packet processing */ - /* Need to lock all Rx tasks since packets from all Rx channels do profile lookup */ - _hal_tau_pkt_lockRxChannelAll(unit); - - ptr_profile = osal_alloc(sizeof(HAL_TAU_PKT_NETIF_PROFILE_T)); - osal_io_copyFromUser(ptr_profile, &ptr_cookie->net_profile, - sizeof(HAL_TAU_PKT_NETIF_PROFILE_T)); - - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "u=%u, create prof name=%s, priority=%d, flag=0x%x\n", - unit, - ptr_profile->name, - ptr_profile->priority, - ptr_profile->flags); - - /* Save the profile to the profile array and assign the index to ptr_profile->id */ - rc = _hal_tau_pkt_allocProfEntry(ptr_profile); - if (NPS_E_OK == rc) - { - /* Insert the profile to the corresponding (port) interface */ - if ((ptr_profile->flags & HAL_TAU_PKT_NETIF_PROFILE_FLAGS_PORT) != 0) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "u=%u, bind prof to phy port=%d\n", unit, ptr_profile->port); - ptr_port_db = HAL_TAU_PKT_GET_PORT_DB(ptr_profile->port); - _hal_tau_pkt_addProfToList(ptr_profile, &ptr_port_db->ptr_profile_list); - } - else - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "u=%u, bind prof to all intf\n", unit); - _hal_tau_pkt_addProfToAllIntf(ptr_profile); - } - - /* Copy the ptr_profile->id to user space */ - osal_io_copyToUser(&ptr_cookie->net_profile, ptr_profile, sizeof(HAL_TAU_PKT_NETIF_PROFILE_T)); - } - else - { - HAL_TAU_PKT_DBG((HAL_TAU_PKT_DBG_PROFILE | HAL_TAU_PKT_DBG_ERR), - "u=%u, alloc prof entry failed, tbl full\n", unit); - osal_free(ptr_profile); - } - - osal_io_copyToUser(&ptr_cookie->rc, &rc, sizeof(NPS_ERROR_NO_T)); - - _hal_tau_pkt_unlockRxChannelAll(unit); - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_destroyProfile( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *ptr_cookie) -{ - HAL_TAU_PKT_NETIF_PROFILE_T profile = {0}; - HAL_TAU_PKT_NETIF_PROFILE_T *ptr_profile; - NPS_ERROR_NO_T rc = NPS_E_OK; - - /* Lock all Rx tasks to avoid profiles being refered during packet processing */ - /* Need to lock all Rx tasks since packets from all Rx channels do profile lookup */ - _hal_tau_pkt_lockRxChannelAll(unit); - - osal_io_copyFromUser(&profile, &ptr_cookie->net_profile, - sizeof(HAL_TAU_PKT_NETIF_PROFILE_T)); - - /* Remove the profile from corresponding interface (port) */ - _hal_tau_pkt_delProfFromAllIntfById(profile.id); - - ptr_profile = _hal_tau_pkt_freeProfEntry(profile.id); - if (NULL != ptr_profile) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_PROFILE, - "u=%u, destroy prof id=%d, name=%s, priority=%d, flag=0x%x\n", - unit, - ptr_profile->id, - ptr_profile->name, - ptr_profile->priority, - ptr_profile->flags); - osal_free(ptr_profile); - } - - osal_io_copyToUser(&ptr_cookie->rc, &rc, sizeof(NPS_ERROR_NO_T)); - - _hal_tau_pkt_unlockRxChannelAll(unit); - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_getProfile( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *ptr_cookie) -{ - HAL_TAU_PKT_NETIF_PROFILE_T profile = {0}; - HAL_TAU_PKT_NETIF_PROFILE_T *ptr_profile; - NPS_ERROR_NO_T rc = NPS_E_OK; - - osal_io_copyFromUser(&profile, &ptr_cookie->net_profile, sizeof(HAL_TAU_PKT_NETIF_PROFILE_T)); - - ptr_profile = _hal_tau_pkt_getProfEntry(profile.id); - if (NULL != ptr_profile) - { - osal_io_copyToUser(&ptr_cookie->net_profile, ptr_profile, sizeof(HAL_TAU_PKT_NETIF_PROFILE_T)); - } - else - { - rc = NPS_E_ENTRY_NOT_FOUND; - } - - osal_io_copyToUser(&ptr_cookie->rc, &rc, sizeof(NPS_ERROR_NO_T)); - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_getIntfCnt( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *ptr_cookie) -{ - HAL_TAU_PKT_NETIF_INTF_T net_intf = {0}; - HAL_TAU_PKT_NETIF_INTF_CNT_T intf_cnt = {0}; - HAL_TAU_PKT_NETIF_PORT_DB_T *ptr_port_db; - struct net_device_priv *ptr_priv; - UI32_T port = 0; - NPS_ERROR_NO_T rc = NPS_E_ENTRY_NOT_FOUND; - - osal_io_copyFromUser(&net_intf, &ptr_cookie->net_intf, sizeof(HAL_TAU_PKT_NETIF_INTF_T)); - - for (port = 0; port < HAL_TAU_PKT_MAX_PORT_NUM; port++) - { - ptr_port_db = HAL_TAU_PKT_GET_PORT_DB(port); - if (NULL != ptr_port_db->ptr_net_dev) /* valid intf */ - { - if (ptr_port_db->meta.id == net_intf.id) - { - ptr_priv = netdev_priv(ptr_port_db->ptr_net_dev); - intf_cnt.rx_pkt = ptr_priv->stats.rx_packets; - intf_cnt.tx_pkt = ptr_priv->stats.tx_packets; - intf_cnt.tx_error = ptr_priv->stats.tx_errors; - intf_cnt.tx_queue_full = ptr_priv->stats.tx_fifo_errors; - - rc = NPS_E_OK; - break; - } - } - } - - osal_io_copyToUser(&ptr_cookie->cnt, &intf_cnt, sizeof(HAL_TAU_PKT_NETIF_INTF_CNT_T)); - osal_io_copyToUser(&ptr_cookie->rc, &rc, sizeof(NPS_ERROR_NO_T)); - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_hal_tau_pkt_clearIntfCnt( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *ptr_cookie) -{ - HAL_TAU_PKT_NETIF_INTF_T net_intf = {0}; - HAL_TAU_PKT_NETIF_PORT_DB_T *ptr_port_db; - struct net_device_priv *ptr_priv; - UI32_T port = 0; - NPS_ERROR_NO_T rc = NPS_E_ENTRY_NOT_FOUND; - - osal_io_copyFromUser(&net_intf, &ptr_cookie->net_intf, sizeof(HAL_TAU_PKT_NETIF_INTF_T)); - - for (port = 0; port < HAL_TAU_PKT_MAX_PORT_NUM; port++) - { - ptr_port_db = HAL_TAU_PKT_GET_PORT_DB(port); - if (NULL != ptr_port_db->ptr_net_dev) /* valid intf */ - { - if (ptr_port_db->meta.id == net_intf.id) - { - ptr_priv = netdev_priv(ptr_port_db->ptr_net_dev); - ptr_priv->stats.rx_packets = 0; - ptr_priv->stats.tx_packets = 0; - ptr_priv->stats.tx_errors = 0; - ptr_priv->stats.tx_fifo_errors = 0; - - rc = NPS_E_OK; - break; - } - } - } - - osal_io_copyToUser(&ptr_cookie->rc, &rc, sizeof(NPS_ERROR_NO_T)); - - return (NPS_E_OK); -} - -/* ----------------------------------------------------------------------------------- Init: dev_ops */ -static int -_hal_tau_pkt_dev_open( - struct inode *inode, - struct file *file) -{ - return (0); -} - -static int -_hal_tau_pkt_dev_close( - struct inode *inode, - struct file *file) -{ - return (0); -} - -static void -_hal_tau_pkt_dev_tx_callback( - const UI32_T unit, - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_gpd, - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_gpd_usr) -{ - UI32_T channel = ptr_sw_gpd->channel; - HAL_TAU_PKT_TX_CB_T *ptr_tx_cb = HAL_TAU_PKT_GET_TX_CB_PTR(unit); - - while (0 != _hal_tau_pkt_enQueue(&ptr_tx_cb->sw_queue, ptr_sw_gpd)) - { - ptr_tx_cb->cnt.channel[channel].enque_retry++; - HAL_TAU_PKT_TX_ENQUE_RETRY_SLEEP(); - } - ptr_tx_cb->cnt.channel[channel].enque_ok++; - - osal_triggerEvent(&ptr_tx_cb->sync_sema); - ptr_tx_cb->cnt.channel[channel].trig_event++; -} - -static ssize_t -_hal_tau_pkt_dev_tx( - struct file *file, - const char __user *buf, - size_t count, - loff_t *pos) -{ - int ret = 0; - int idx = 0; - unsigned int unit = 0; - unsigned int channel = 0; - HAL_TAU_PKT_IOCTL_TX_COOKIE_T tx_cookie; - HAL_TAU_PKT_IOCTL_TX_GPD_T ioctl_gpd; - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_gpd_knl = NULL; - HAL_TAU_PKT_TX_SW_GPD_T *ptr_first_sw_gpd_knl = NULL; - - /* copy the tx-cookie */ - osal_io_copyFromUser(&tx_cookie, (void *)buf, sizeof(HAL_TAU_PKT_IOCTL_TX_COOKIE_T)); - - unit = tx_cookie.unit; - channel = tx_cookie.channel; - - ptr_sw_gpd_knl = osal_alloc(sizeof(HAL_TAU_PKT_TX_SW_GPD_T)); - ptr_first_sw_gpd_knl = ptr_sw_gpd_knl; - - /* create SW GPD based on the content of each IOCTL GPD */ - while (1) - { - osal_io_copyFromUser(&ioctl_gpd, - ((void *)((NPS_HUGE_T)tx_cookie.ioctl_gpd_addr)) - +idx*sizeof(HAL_TAU_PKT_IOCTL_TX_GPD_T), - sizeof(HAL_TAU_PKT_IOCTL_TX_GPD_T)); - - ptr_sw_gpd_knl->channel = ioctl_gpd.channel; - ptr_sw_gpd_knl->gpd_num = ioctl_gpd.gpd_num; - ptr_sw_gpd_knl->ptr_cookie = (void *)ioctl_gpd.cookie; - - /* directly copy user's HW GPD */ - osal_io_copyFromUser(&ptr_sw_gpd_knl->tx_gpd, - (void *)((NPS_HUGE_T)ioctl_gpd.hw_gpd_addr), - sizeof(HAL_TAU_PKT_TX_GPD_T)); - - /* replace the callback */ - ptr_sw_gpd_knl->callback = (void *)_hal_tau_pkt_dev_tx_callback; - - /* save the first SW GPD address from userspace since - * we have replaced the original callback - */ - ptr_sw_gpd_knl->ptr_cookie = (void *)ioctl_gpd.sw_gpd_addr; - - if (HAL_TAU_PKT_CH_LAST_GPD == ptr_sw_gpd_knl->tx_gpd.ch) - { - ptr_sw_gpd_knl->ptr_next = NULL; - break; - } - else - { - ptr_sw_gpd_knl->ptr_next = (HAL_TAU_PKT_TX_SW_GPD_T *)osal_alloc( - sizeof(HAL_TAU_PKT_TX_SW_GPD_T)); - ptr_sw_gpd_knl = ptr_sw_gpd_knl->ptr_next; - idx++; - } - } - - ret = hal_tau_pkt_sendGpd(unit, channel, ptr_first_sw_gpd_knl); - if (NPS_E_OK != ret) - { - _hal_tau_pkt_freeTxGpdList(unit, ptr_first_sw_gpd_knl); - } - - /* return 0 if success */ - return (ret); -} - -static ssize_t -_hal_tau_pkt_dev_rx( - struct file *file, - char __user *buf, - size_t count, - loff_t *pos) -{ - return (0); -} - -static long -_hal_tau_pkt_dev_ioctl( - struct file *filp, - unsigned int cmd, - unsigned long arg) -{ - int ret = 0; - - /* cmd */ - HAL_TAU_PKT_IOCTL_CMD_T *ptr_cmd = (HAL_TAU_PKT_IOCTL_CMD_T *)&cmd; - unsigned int unit = ptr_cmd->field.unit; - HAL_TAU_PKT_IOCTL_TYPE_T type = ptr_cmd->field.type; - - switch (type) - { - HAL_TAU_PKT_DBG(HAL_TAU_PKT_DBG_COMMON, "u=%u, ioctl type=%u, cmd=%u\n", - unit, type, cmd); - - /* network interface */ - case HAL_TAU_PKT_IOCTL_TYPE_CREATE_INTF: - ret = _hal_tau_pkt_createIntf(unit, (HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_DESTROY_INTF: - ret = _hal_tau_pkt_destroyIntf(unit, (HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_GET_INTF: - ret = _hal_tau_pkt_getIntf(unit, (HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_CREATE_PROFILE: - ret = _hal_tau_pkt_createProfile(unit, (HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_DESTROY_PROFILE: - ret = _hal_tau_pkt_destroyProfile(unit, (HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_GET_PROFILE: - ret = _hal_tau_pkt_getProfile(unit, (HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_GET_INTF_CNT: - ret = _hal_tau_pkt_getIntfCnt(unit, (HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_CLEAR_INTF_CNT: - ret = _hal_tau_pkt_clearIntfCnt(unit, (HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T *)arg); - break; - - /* driver */ - case HAL_TAU_PKT_IOCTL_TYPE_WAIT_RX_FREE: - ret = _hal_tau_pkt_schedRxDeQueue(unit, (HAL_TAU_PKT_IOCTL_RX_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_WAIT_TX_FREE: - ret = _hal_tau_pkt_strictTxDeQueue(unit, (HAL_TAU_PKT_IOCTL_TX_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_SET_RX_CFG: - ret = hal_tau_pkt_setRxKnlConfig(unit, (HAL_TAU_PKT_IOCTL_RX_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_GET_RX_CFG: - ret = hal_tau_pkt_getRxKnlConfig(unit, (HAL_TAU_PKT_IOCTL_RX_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_DEINIT_TASK: - ret = hal_tau_pkt_deinitTask(unit); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_DEINIT_DRV: - ret = hal_tau_pkt_deinitPktDrv(unit); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_INIT_TASK: - ret = hal_tau_pkt_initTask(unit); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_INIT_DRV: - ret = hal_tau_pkt_initPktDrv(unit); - break; - - /* counter */ - case HAL_TAU_PKT_IOCTL_TYPE_GET_TX_CNT: - ret = hal_tau_pkt_getTxKnlCnt(unit, (HAL_TAU_PKT_IOCTL_CH_CNT_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_GET_RX_CNT: - ret = hal_tau_pkt_getRxKnlCnt(unit, (HAL_TAU_PKT_IOCTL_CH_CNT_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_CLEAR_TX_CNT: - ret = hal_tau_pkt_clearTxKnlCnt(unit, (HAL_TAU_PKT_IOCTL_TX_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_CLEAR_RX_CNT: - ret = hal_tau_pkt_clearRxKnlCnt(unit, (HAL_TAU_PKT_IOCTL_RX_COOKIE_T *)arg); - break; - - case HAL_TAU_PKT_IOCTL_TYPE_SET_PORT_ATTR: - ret = hal_tau_pkt_setPortAttr(unit, (HAL_TAU_PKT_IOCTL_PORT_COOKIE_T *)arg); - break; - -#if defined(NETIF_EN_NETLINK) - case HAL_TAU_PKT_IOCTL_TYPE_NL_SET_INTF_PROPERTY: - ret = _hal_tau_pkt_setIntfProperty(unit, (HAL_TAU_PKT_NL_IOCTL_COOKIE_T *)arg); - break; - case HAL_TAU_PKT_IOCTL_TYPE_NL_GET_INTF_PROPERTY: - ret = _hal_tau_pkt_getIntfProperty(unit, (HAL_TAU_PKT_NL_IOCTL_COOKIE_T *)arg); - break; - case HAL_TAU_PKT_IOCTL_TYPE_NL_CREATE_NETLINK: - ret = _hal_tau_pkt_createNetlink(unit, (HAL_TAU_PKT_NL_IOCTL_COOKIE_T *)arg); - break; - case HAL_TAU_PKT_IOCTL_TYPE_NL_DESTROY_NETLINK: - ret = _hal_tau_pkt_destroyNetlink(unit, (HAL_TAU_PKT_NL_IOCTL_COOKIE_T *)arg); - break; - case HAL_TAU_PKT_IOCTL_TYPE_NL_GET_NETLINK: - ret = _hal_tau_pkt_getNetlink(unit, (HAL_TAU_PKT_NL_IOCTL_COOKIE_T *)arg); - break; -#endif - - default: - ret = -1; - break; - } - - return (ret); -} - -#ifdef CONFIG_COMPAT -static long -_hal_tau_pkt_dev_compat_ioctl( - struct file *filp, - unsigned int cmd, - unsigned long arg) -{ - return _hal_tau_pkt_dev_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); -} -#endif - -static struct file_operations _hal_tau_pkt_dev_ops = -{ - .owner = THIS_MODULE, - .open = _hal_tau_pkt_dev_open, - .release = _hal_tau_pkt_dev_close, - .write = _hal_tau_pkt_dev_tx, - .read = _hal_tau_pkt_dev_rx, - .unlocked_ioctl = _hal_tau_pkt_dev_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = _hal_tau_pkt_dev_compat_ioctl, -#endif -}; - -static struct miscdevice _hal_tau_pkt_dev = -{ - .minor = HAL_TAU_PKT_DRIVER_MINOR_NUM, - .name = HAL_TAU_PKT_DRIVER_NAME, - .fops = &_hal_tau_pkt_dev_ops, -}; - -/* ----------------------------------------------------------------------------------- Init/Deinit */ -static int __init -_hal_tau_pkt_init(void) -{ - /* Register device */ - misc_register(&_hal_tau_pkt_dev); - - /* Init Thread */ - osal_init(); - - /* Reset all database*/ - osal_memset(_hal_tau_pkt_port_db, 0x0, - (HAL_TAU_PKT_MAX_PORT_NUM * sizeof(HAL_TAU_PKT_NETIF_PORT_DB_T))); - osal_memset(_hal_tau_pkt_rx_cb, 0x0, - NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM*sizeof(HAL_TAU_PKT_RX_CB_T)); - osal_memset(_hal_tau_pkt_tx_cb, 0x0, - NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM*sizeof(HAL_TAU_PKT_TX_CB_T)); - osal_memset(_hal_tau_pkt_drv_cb, 0x0, - NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM*sizeof(HAL_TAU_PKT_DRV_CB_T)); - -#if defined(NETIF_EN_NETLINK) - netif_nl_init(); -#endif - - return (0); -} - -static void __exit -_hal_tau_pkt_exit(void) -{ - UI32_T unit = 0; - - /* 1st. Stop all netdev (if any) to prevent kernel from Tx new packets */ - _hal_tau_pkt_stopAllIntf(unit); - - /* 2nd. Stop Rx HW DMA and free all the DMA buffer hooked on the ring */ - _hal_tau_pkt_rxStop(unit); - - /* 3rd. Need to wait Rx done task process all the availavle packets on GPD ring */ -#define HAL_TAU_PKT_MODULE_EXIT_HOLD_TIME_US (1000000) - osal_sleepThread(HAL_TAU_PKT_MODULE_EXIT_HOLD_TIME_US); - - /* 4th. Stop all the internal tasks (if any) */ - hal_tau_pkt_deinitTask(unit); - - /* 5th. Deinit pkt driver for common database/interrupt source (if required) */ - hal_tau_pkt_deinitPktDrv(unit); - - /* 6th. Clean up those intf/profiles not been destroyed */ - _hal_tau_pkt_destroyAllProfile(unit); - _hal_tau_pkt_destroyAllIntf(unit); - - osal_deinit(); - - /* Unregister device */ - misc_deregister(&_hal_tau_pkt_dev); -} - -module_init(_hal_tau_pkt_init); -module_exit(_hal_tau_pkt_exit); - -module_param(ext_dbg_flag, uint, S_IRUGO); -MODULE_PARM_DESC(ext_dbg_flag, "bit0:Error, bit1:Tx, bit2:Rx, bit3:Intf, bit4:Profile"); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("MediaTek"); -MODULE_DESCRIPTION("NETIF Kernel Module"); diff --git a/platform/nephos/nephos-modules/modules/src/inc/aml.h b/platform/nephos/nephos-modules/modules/src/inc/aml.h deleted file mode 100755 index 682eaa5ea31..00000000000 --- a/platform/nephos/nephos-modules/modules/src/inc/aml.h +++ /dev/null @@ -1,366 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: aml.h - * PURPOSE: - * 1. Provide whole AML resource initialization API. - * 2. Provide configuration access APIs. - * 3. Provide ISR registration and deregistration APIs. - * 4. Provide memory access. - * 5. Provide DMA management APIs. - * 6. Provide address translation APIs. - * NOTES: - */ - -#ifndef AML_H -#define AML_H - - -/* INCLUDE FILE DECLARATIONS - */ -#include -#include -#include - - -/* NAMING CONSTANT DECLARATIONS - */ - -/* #define AML_EN_I2C */ -/* #define AML_EN_CUSTOM_DMA_ADDR */ - -/* MACRO FUNCTION DECLARATIONS - */ - -/* DATA TYPE DECLARATIONS - */ -typedef enum -{ - AML_DEV_TYPE_PCI, - AML_DEV_TYPE_I2C, - AML_DEV_TYPE_SPI, - AML_DEV_TYPE_LAST - -} AML_HW_IF_T; - -typedef NPS_ERROR_NO_T -(*AML_DEV_READ_FUNC_T)( - const UI32_T unit, - const UI32_T addr_offset, - UI32_T *ptr_data, - const UI32_T len); - -typedef NPS_ERROR_NO_T -(*AML_DEV_WRITE_FUNC_T)( - const UI32_T unit, - const UI32_T addr_offset, - const UI32_T *ptr_data, - const UI32_T len); - -typedef NPS_ERROR_NO_T -(*AML_DEV_ISR_FUNC_T)( - void *ptr_data); - -/* To mask the chip interrupt in kernel interrupt routine. */ -typedef struct -{ - UI32_T mask_addr; - UI32_T mask_val; - -} AML_DEV_ISR_DATA_T; - -/* To read or write the HW-intf registers. */ -typedef struct -{ - AML_DEV_READ_FUNC_T read_callback; - AML_DEV_WRITE_FUNC_T write_callback; - -} AML_DEV_ACCESS_T; - -typedef struct -{ - UI32_T vendor; - UI32_T device; - UI32_T revision; - -} AML_DEV_ID_T; - - -typedef struct -{ - AML_HW_IF_T if_type; - AML_DEV_ID_T id; - AML_DEV_ACCESS_T access; - -} AML_DEV_T; - -/* EXPORTED SUBPROGRAM SPECIFICATIONS - */ - -/* FUNCTION NAME: aml_getRunMode - * PURPOSE: - * To get current SDK running mode. - * INPUT: - * unit -- the device unit - * OUTPUT: - * ptr_mode -- current running mode - * RETURN: - * NPS_E_OK -- Successfully get the running mode. - * NOTES: - * none - */ -NPS_ERROR_NO_T -aml_getRunMode( - const UI32_T unit, - UI32_T *ptr_mode); - -/* FUNCTION NAME: aml_init - * PURPOSE: - * To initialize the DMA memory and interface-related kernel source - * such as PCIe/I2C/SPI. - * INPUT: - * none - * OUTPUT: - * none - * RETURN: - * NPS_E_OK -- Successfully initialize AML module. - * NPS_E_OTHERS -- Failed to initialize AML module. - * NOTES: - * none - */ -NPS_ERROR_NO_T -aml_deinit(void); - -/* FUNCTION NAME: aml_init - * PURPOSE: - * To initialize the DMA memory and interface-related kernel source - * such as PCIe/I2C/SPI. - * INPUT: - * none - * OUTPUT: - * none - * RETURN: - * NPS_E_OK -- Successfully initialize AML module. - * NPS_E_OTHERS -- Failed to initialize AML module. - * NOTES: - * none - */ -NPS_ERROR_NO_T -aml_init(void); - -/* FUNCTION NAME: aml_getNumberOfChip - * PURPOSE: - * To get the number of chips connected to host CPU. - * INPUT: - * none - * OUTPUT: - * ptr_num -- pointer for the chip number - * RETURN: - * NPS_E_OK -- Successfully get the number of chips. - * NOTES: - * none - */ -NPS_ERROR_NO_T -aml_getNumberOfChip( - UI32_T *ptr_num); - -/* FUNCTION NAME: aml_connectIsr - * PURPOSE: - * To enable the system intterupt and specify the ISR handler. - * INPUT: - * unit -- the device unit - * handler -- the ISR hanlder - * ptr_cookie -- pointer for the data as an argument of the handler - * OUTPUT: - * none - * RETURN: - * NPS_E_OK -- Successfully connect the ISR handler to the system. - * NPS_E_OTHERS -- Failed to connect the ISR handler to the system. - * NOTES: - * none - */ -NPS_ERROR_NO_T -aml_connectIsr( - const UI32_T unit, - AML_DEV_ISR_FUNC_T handler, - AML_DEV_ISR_DATA_T *ptr_cookie); - -/* FUNCTION NAME: aml_disconnectIsr - * PURPOSE: - * To disable the system intterupt notification. - * INPUT: - * unit -- the device unit - * OUTPUT: - * none - * RETURN: - * NPS_E_OK -- Successfully disconnect the ISR handler to the system. - * NPS_E_OTHERS -- Failed to disconnect the ISR handler to the system. - * NOTES: - * none - */ -NPS_ERROR_NO_T -aml_disconnectIsr( - const UI32_T unit); - -/* FUNCTION NAME: aml_getDeviceId - * PURPOSE: - * To get the vendor/device/revision ID of the specified chip unit. - * INPUT: - * unit -- the device unit - * OUTPUT: - * ptr_vendor_id -- pointer for the vendor ID - * ptr_device_id -- pointer for the device ID - * ptr_revision_id -- pointer for the revision ID - * RETURN: - * NPS_E_OK -- Successfully get the IDs. - * NPS_E_OTHERS -- Failed to get the IDs. - * NOTES: - * none - */ -NPS_ERROR_NO_T -aml_getDeviceId( - const UI32_T unit, - UI32_T *ptr_vendor_id, - UI32_T *ptr_device_id, - UI32_T *ptr_revision_id); - -/* FUNCTION NAME: aml_readReg - * PURPOSE: - * To read data from the register of the specified chip unit. - * INPUT: - * unit -- the device unit - * addr_offset -- the address of register - * len -- data size read - * OUTPUT: - * ptr_data -- pointer for the register data - * RETURN: - * NPS_E_OK -- Successfully read the data. - * NPS_E_OTHERS -- Failed to read the data. - * NOTES: - * none - */ -NPS_ERROR_NO_T -aml_readReg( - const UI32_T unit, - const UI32_T addr_offset, - UI32_T *ptr_data, - const UI32_T len); - -/* FUNCTION NAME: aml_writeReg - * PURPOSE: - * To write data to the register of the specified chip unit. - * INPUT: - * unit -- the device unit - * addr_offset -- the address of register - * ptr_data -- pointer for the written data - * len -- data size read - * OUTPUT: - * none - * RETURN: - * NPS_E_OK -- Successfully write the data. - * NPS_E_OTHERS -- Failed to write the data. - * NOTES: - * none - */ -NPS_ERROR_NO_T -aml_writeReg( - const UI32_T unit, - const UI32_T addr_offset, - const UI32_T *ptr_data, - const UI32_T len); - -/* FUNCTION NAME: aml_convertVirtToPhy - * PURPOSE: - * To get the physical address of the corresponding virtual - * address input. - * INPUT: - * ptr_virt_addr -- pointer to the virtual address - * OUTPUT: - * ptr_phy_addr -- pointer to the physical address - * RETURN: - * NPS_E_OK -- Successfully convert the address. - * NPS_E_OTHERS -- Failed to convert the address. - * The memory might be not allocated by AML. - * NOTES: - * none - */ -NPS_ERROR_NO_T -aml_convertVirtToPhy( - void *ptr_virt_addr, - NPS_ADDR_T *ptr_phy_addr); - -/* FUNCTION NAME: aml_convertPhyToVirt - * PURPOSE: - * To get the virtual address of the corresponding physical - * address input. - * INPUT: - * ptr_virt_addr -- pointer for the physical address - * OUTPUT: - * pptr_virt_addr -- pointer for the virtual address pointer - * RETURN: - * NPS_E_OK -- Successfully convert the address. - * NPS_E_OTHERS -- Failed to convert the address. - * The memory might be not allocated by AML. - * NOTES: - * none - */ -NPS_ERROR_NO_T -aml_convertPhyToVirt( - const NPS_ADDR_T phy_addr, - void **pptr_virt_addr); - -/* FUNCTION NAME: aml_flushCache - * PURPOSE: - * To update the data from CPU cache to the physical memory. - * INPUT: - * ptr_virt_addr -- pointer for the data - * size -- target data size to be updated - * OUTPUT: - * none - * RETURN: - * NPS_E_OK -- Successfully update the data from CPU cache - * to the physical memory. - * NPS_E_OTHERS -- Failed to pdate the data from CPU cache - * to the physical memory. - * NOTES: - * none - */ -NPS_ERROR_NO_T -aml_flushCache( - void *ptr_virt_addr, - const UI32_T size); - -/* FUNCTION NAME: aml_invalidateCache - * PURPOSE: - * To update the data from physical memory to the CPU cache. - * INPUT: - * ptr_virt_addr -- pointer for the data - * size -- target data size to be updated - * OUTPUT: - * none - * RETURN: - * NPS_E_OK -- Successfully update the data from physical memory - * to the CPU cache. - * NPS_E_OTHERS -- Failed to pdate the data from physical memory - * to the CPU cache. - * NOTES: - * none - */ -NPS_ERROR_NO_T -aml_invalidateCache( - void *ptr_virt_addr, - const UI32_T size); - -#endif /* #ifndef AML_H */ diff --git a/platform/nephos/nephos-modules/modules/src/inc/hal_dev.h b/platform/nephos/nephos-modules/modules/src/inc/hal_dev.h deleted file mode 100755 index e8d491358c7..00000000000 --- a/platform/nephos/nephos-modules/modules/src/inc/hal_dev.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: hal_dev.h - * PURPOSE: - * Provide a list of device IDs. - * - * NOTES: - */ - -#ifndef HAL_DEV_H -#define HAL_DEV_H - -/* INCLUDE FILE DECLARATIONS - */ -/* NAMING CONSTANT DECLARATIONS - */ -#define HAL_MTK_VENDOR_ID (0x0E8D) -#define HAL_NP_VENDOR_ID (0x1D9F) - -#define HAL_DEVICE_ID_MT3257 (0x3257) -#define HAL_DEVICE_ID_MT3258 (0x3258) - -#define HAL_DEVICE_ID_NP8363 (0x8363) /* 1.08T 1Bin */ -#define HAL_DEVICE_ID_NP8365 (0x8365) /* 1.8T 1Bin */ -#define HAL_DEVICE_ID_NP8366 (0x8366) /* 2.4T 1Bin */ -#define HAL_DEVICE_ID_NP8367 (0x8367) /* 3.2T 1Bin */ -#define HAL_DEVICE_ID_NP8368 (0x8368) /* 3.2T 2Bin */ -#define HAL_DEVICE_ID_NP8369 (0x8369) /* 6.4T 2Bin */ - -#define HAL_REVISION_ID_E1 (0x01) -#define HAL_REVISION_ID_E2 (0x02) - -#define HAL_INVALID_DEVICE_ID (0xFFFFFFFF) - -#endif /* #ifndef HAL_DEV_H */ diff --git a/platform/nephos/nephos-modules/modules/src/inc/hal_tau_pkt_knl.h b/platform/nephos/nephos-modules/modules/src/inc/hal_tau_pkt_knl.h deleted file mode 100755 index 3605323a595..00000000000 --- a/platform/nephos/nephos-modules/modules/src/inc/hal_tau_pkt_knl.h +++ /dev/null @@ -1,2377 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: hal_tau_pkt_knl.h - * PURPOSE: - * To provide Linux kernel for PDMA TX/RX control. - * - * NOTES: - */ - -#ifndef HAL_TAU_PKT_KNL_H -#define HAL_TAU_PKT_KNL_H - - -/* CP_COMMON */ -#define HAL_TAU_PKT_CP_COMMON_INT_EN_HI (0x012C0000) -#define HAL_TAU_PKT_CP_COMMON_INT_LO_HI (0x012C0004) -#define HAL_TAU_PKT_CP_COMMON_INT_LVL_HI (0x012C0008) -#define HAL_TAU_PKT_CP_COMMON_INT_LVL_LO (0x012C000C) -#define HAL_TAU_PKT_CP_COMMON_INT_MASK_SET_HI (0x012C0010) -#define HAL_TAU_PKT_CP_COMMON_INT_MASK_SET_LO (0x012C0014) -#define HAL_TAU_PKT_CP_COMMON_INT_MASK_CLR_HI (0x012C0018) -#define HAL_TAU_PKT_CP_COMMON_INT_MASK_CLR_LO (0x012C001C) -#define HAL_TAU_PKT_CP_COMMON_INT_MASK_VAL_HI (0x012C0020) -#define HAL_TAU_PKT_CP_COMMON_INT_MASK_VAL_LO (0x012C0024) -#define HAL_TAU_PKT_CP_COMMON_INT_STAT_HI (0x012C0028) -#define HAL_TAU_PKT_CP_COMMON_INT_STAT_LO (0x012C002C) -#define HAL_TAU_PKT_CP_COMMON_INT_CLR_HI (0x012C0030) -#define HAL_TAU_PKT_CP_COMMON_INT_CLR_LO (0x012C0034) -#define HAL_TAU_PKT_CP_COMMON_INT_SET_HI (0x012C0038) -#define HAL_TAU_PKT_CP_COMMON_INT_SET_LO (0x012C003C) - -/* PDMA */ -#define HAL_TAU_PKT_PDMA_ERR_INT_STAT (0x013F1000) -#define HAL_TAU_PKT_PDMA_ERR_INT_CLR (0x013F1004) -#define HAL_TAU_PKT_PDMA_ERR_INT_EN (0x013F1010) -#define HAL_TAU_PKT_PDMA_ERR_INT_LVL (0x013F1014) -#define HAL_TAU_PKT_PDMA_ERR_INT_MASK_SET (0x013F1018) -#define HAL_TAU_PKT_PDMA_ERR_INT_MASK_CLR (0x013F101C) -#define HAL_TAU_PKT_PDMA_ERR_INT_MASK_VAL (0x013F1020) -#define HAL_TAU_PKT_PDMA_ERR_INT_SET (0x013F1024) -#define HAL_TAU_PKT_PDMA_CREDIT_CFG (0x013F1100) - -/* Rx */ -#define HAL_TAU_PKT_PDMA_RCH_GPD_RING_START_ADDR_LO (0x013F12E4) -#define HAL_TAU_PKT_PDMA_RCH_GPD_RING_START_ADDR_HI (0x013F12E8) -#define HAL_TAU_PKT_PDMA_RCH_GPD_RING_SIZE (0x013F12EC) -#define HAL_TAU_PKT_PDMA_RCH_CMD (0x013F1300) -#define HAL_TAU_PKT_PDMA_RCH_INT_EN (0x013F1360) -#define HAL_TAU_PKT_PDMA_RCH_INT_LVL (0x013F1364) -#define HAL_TAU_PKT_PDMA_RCH_INT_MASK (0x013F1368) -#define HAL_TAU_PKT_PDMA_RCH_INT_SET (0x013F1370) -#define HAL_TAU_PKT_PDMA_RCH_INT_CLR (0x013F1374) -#define HAL_TAU_PKT_PDMA_RCH_INT_STAT (0x013F1378) - -/* Tx */ -#define HAL_TAU_PKT_PDMA_TCH_GPD_RING_START_ADDR_LO (0x013F1A00) -#define HAL_TAU_PKT_PDMA_TCH_GPD_RING_START_ADDR_HI (0x013F1A04) -#define HAL_TAU_PKT_PDMA_TCH_GPD_RING_SIZE (0x013F1A08) -#define HAL_TAU_PKT_PDMA_TCH_CMD (0x013F1A20) -#define HAL_TAU_PKT_PDMA_TCH_INT_EN (0x013F1A40) -#define HAL_TAU_PKT_PDMA_TCH_INT_LVL (0x013F1A44) -#define HAL_TAU_PKT_PDMA_TCH_INT_MASK (0x013F1A48) -#define HAL_TAU_PKT_PDMA_TCH_INT_SET (0x013F1A50) -#define HAL_TAU_PKT_PDMA_TCH_INT_CLR (0x013F1A54) -#define HAL_TAU_PKT_PDMA_TCH_INT_STAT (0x013F1A58) - -#define HAL_TAU_PKT_GET_MMIO(__tbl__) (0x00FFFFFF & (__tbl__)) -#define HAL_TAU_PKT_GET_PDMA_RCH_REG(__tbl__, __channel__) ((__tbl__) + (0x200 * (__channel__))) -#define HAL_TAU_PKT_GET_PDMA_TCH_REG(__tbl__, __channel__) ((__tbl__) + (0x100 * (__channel__))) - - - -#define NPS_NETIF_NAME_LEN (16) -#define NPS_NETIF_PROFILE_NUM_MAX (256) -#define NPS_NETIF_PROFILE_PATTERN_NUM (4) -#define NPS_NETIF_PROFILE_PATTERN_LEN (8) - -/* nps_port.h */ -typedef enum -{ - NPS_PORT_SPEED_1G = 1000, - NPS_PORT_SPEED_10G = 10000, - NPS_PORT_SPEED_25G = 25000, - NPS_PORT_SPEED_40G = 40000, - NPS_PORT_SPEED_50G = 50000, - NPS_PORT_SPEED_100G = 100000, - NPS_PORT_SPEED_200G = 200000, - NPS_PORT_SPEED_400G = 400000, - NPS_PORT_SPEED_LAST -} NPS_PORT_SPEED_T; - - -/* hal_tau_const.h */ -#define HAL_PORT_NUM (128) -#define HAL_EXCPT_CPU_NUM (256) -#define HAL_INVALID_NVO3_ENCAP_IDX (0x3FFF) -#define HAL_INVALID_NVO3_ADJ_IDX (0xFF) -#define HAL_EXCPT_CPU_BASE_ID (28 * 1024) -#define HAL_EXCPT_CPU_NON_L3_MIN (0) -#define HAL_EXCPT_CPU_NON_L3_MAX (HAL_EXCPT_CPU_NON_L3_MIN + HAL_EXCPT_CPU_NUM - 1) -#define HAL_EXCPT_CPU_L3_MIN (HAL_EXCPT_CPU_NON_L3_MIN + HAL_EXCPT_CPU_NUM) -#define HAL_EXCPT_CPU_L3_MAX (HAL_EXCPT_CPU_L3_MIN + HAL_EXCPT_CPU_NUM - 1) - -/* hal_tau_pkt_rsrc.h */ -#define HAL_TAU_PKT_IPP_EXCPT_LAST (256) -#define HAL_TAU_PKT_EPP_EXCPT_LAST (64) - -#define HAL_TAU_PKT_IPP_EXCPT_IEV_SDK_REDIRECT_TO_CPU_L2UC \ - (192 + IEV_CFG_EXCPT_EN_W1_SDK_REDIRECT_TO_CPU_L2UC_FIELD_ID ) -#define HAL_TAU_PKT_IPP_EXCPT_IEV_SDK_REDIRECT_TO_CPU_L3UC \ - (192 + IEV_CFG_EXCPT_EN_W1_SDK_REDIRECT_TO_CPU_L3UC_FIELD_ID ) -#define HAL_TAU_PKT_IPP_EXCPT_IEV_SDK_L3UC_DA_MISS \ - (192 + IEV_CFG_EXCPT_EN_W1_SDK_L3UC_DA_MISS_FIELD_ID ) -#define HAL_TAU_PKT_IPP_EXCPT_IEV_SDK_L3MC_PIM_REGISTER \ - (192 + IEV_CFG_EXCPT_EN_W1_SDK_L3MC_PIM_REGISTER_FIELD_ID ) -#define HAL_TAU_PKT_IPP_EXCPT_IEV_SDK_FLEX_DECAP_0_REASON_0 \ - (224 + IEV_CFG_EXCPT_EN_W0_SDK_FLEX_DECAP_0_REASON_0_FIELD_ID) - -/* offset of ITM_RSLT_CPU_CP */ -#define HAL_TAU_PKT_IPP_COPY2CPU_OFFSET (16) -#define HAL_TAU_PKT_EPP_COPY2CPU_OFFSET (32) - -typedef UI32_T HAL_TAU_PKT_IPP_EXCPT_T; -typedef UI32_T HAL_TAU_PKT_EPP_EXCPT_T; - -typedef enum -{ - HAL_TAU_PKT_IPP_L3_EXCPT_FCOE_ZONING = 0, - HAL_TAU_PKT_IPP_L3_EXCPT_RPF, - HAL_TAU_PKT_IPP_L3_EXCPT_ICMP_REDIR, - HAL_TAU_PKT_IPP_L3_EXCPT_SW_FWD, - HAL_TAU_PKT_IPP_L3_EXCPT_MTU, - HAL_TAU_PKT_IPP_L3_EXCPT_TTL, - HAL_TAU_PKT_IPP_L3_EXCPT_LAST -} HAL_TAU_PKT_IPP_L3_EXCPT_T; - -typedef enum -{ - HAL_TAU_PKT_IPP_RSN_RSVD_0 = 0, - HAL_TAU_PKT_IPP_RSN_IDS_MPLS_MP_LSP_INNER_IP_LCL, - HAL_TAU_PKT_IPP_RSN_IDS_IP_MC_TNL_LCL_INTF_MISS, - HAL_TAU_PKT_IPP_RSN_IDS_IP_MC_TNL_GRE_ISIS, - HAL_TAU_PKT_IPP_RSN_IDS_IP_MC_TNL_GRE_KA, - HAL_TAU_PKT_IPP_RSN_IDS_IP_MC_TNL_INNER_IP_LCL, - HAL_TAU_PKT_IPP_RSN_IDS_TRILL_MC_LCL_INTF_MISS, - HAL_TAU_PKT_IPP_RSN_IDS_INNER_SRV_1ST_MISS, - HAL_TAU_PKT_IPP_RSN_IDS_INNER_SRV_2ND_MISS, - HAL_TAU_PKT_IPP_RSN_IEV_IP_MC_TTL0, - HAL_TAU_PKT_IPP_RSN_IEV_IP_MC_TTL1, - HAL_TAU_PKT_IPP_RSN_RSVD_1, - HAL_TAU_PKT_IPP_RSN_RSVD_2, - HAL_TAU_PKT_IPP_RSN_IDS_ECN, - HAL_TAU_PKT_IPP_RSN_IEV_ICMP_REDIR, - HAL_TAU_PKT_IPP_RSN_IEV_ICMP_REDIR_WITH_RSN_IDS_ECN, - HAL_TAU_PKT_IPP_RSN_LAST -} HAL_TAU_PKT_IPP_RSN_T; - -typedef enum -{ - /* IEV.cp_to_cpu_bmap |= - * (1 << sw_plane.iev_cp_to_cpu_bit_pos_{i}) | - * (1 << sw_plane.iev_sflw_cp_to_cpu_bidx_{i}) | - * (1 << (IEV_RSLT_CTL2CPU_PROF.code - 1)) | - * (1 << (ICIA_RSLT_TCAM_UCP_POLICY.cp_to_cpu_idx - 1)); - */ - HAL_TAU_PKT_IPP_COPY2CPU_ICIA_0 = 0, - HAL_TAU_PKT_IPP_COPY2CPU_ICIA_1, - HAL_TAU_PKT_IPP_COPY2CPU_ICIA_2, - HAL_TAU_PKT_IPP_COPY2CPU_ICIA_3, - HAL_TAU_PKT_IPP_COPY2CPU_ICIA_4, - HAL_TAU_PKT_IPP_COPY2CPU_ICIA_5, - HAL_TAU_PKT_IPP_COPY2CPU_COPY_TO_CPU_L2UC, - HAL_TAU_PKT_IPP_COPY2CPU_COPY_TO_CPU_L3UC, - HAL_TAU_PKT_IPP_COPY2CPU_PORT_SFLOW, - HAL_TAU_PKT_IPP_COPY2CPU_ICIA_SFLOW, - HAL_TAU_PKT_IPP_COPY2CPU_FLOW_SFLOW, - HAL_TAU_PKT_IPP_COPY2CPU_L3MC_SPT_READY_UNSET, - HAL_TAU_PKT_IPP_COPY2CPU_COPY_TO_CPU_L2MC, - HAL_TAU_PKT_IPP_COPY2CPU_COPY_TO_CPU_L3MC, - HAL_TAU_PKT_IPP_COPY2CPU_USR_DEFINE_0, - HAL_TAU_PKT_IPP_COPY2CPU_USR_DEFINE_1, - HAL_TAU_PKT_IPP_COPY2CPU_LAST -} HAL_TAU_PKT_IPP_COPY2CPU_T; - -typedef enum -{ - /* The value of: - * 1. emi_sflw_cp_to_cpu_idx_bidx_* - * 2. ECIA.cp_to_cpu_idx (last is invalid) - */ - HAL_TAU_PKT_EPP_COPY2CPU_ECIA_0 = 0, - HAL_TAU_PKT_EPP_COPY2CPU_ECIA_1, - HAL_TAU_PKT_EPP_COPY2CPU_ECIA_2, - HAL_TAU_PKT_EPP_COPY2CPU_ECIA_3, - HAL_TAU_PKT_EPP_COPY2CPU_PORT_SFLOW, - HAL_TAU_PKT_EPP_COPY2CPU_ECIA_SFLOW, - HAL_TAU_PKT_EPP_COPY2CPU_RSVD_0, - HAL_TAU_PKT_EPP_COPY2CPU_RSVD_1, - HAL_TAU_PKT_EPP_COPY2CPU_LAST -} HAL_TAU_PKT_EPP_COPY2CPU_T; - -#define HAL_TAU_PKT_IPP_EXCPT_BITMAP_SIZE (NPS_BITMAP_SIZE(HAL_TAU_PKT_IPP_EXCPT_LAST)) -#define HAL_TAU_PKT_IPP_L3_EXCPT_BITMAP_SIZE (NPS_BITMAP_SIZE(HAL_TAU_PKT_IPP_L3_EXCPT_LAST)) -#define HAL_TAU_PKT_EPP_EXCPT_BITMAP_SIZE (NPS_BITMAP_SIZE(HAL_TAU_PKT_EPP_EXCPT_LAST)) -#define HAL_TAU_PKT_IPP_RSN_BITMAP_SIZE (NPS_BITMAP_SIZE(HAL_TAU_PKT_IPP_RSN_LAST)) -#define HAL_TAU_PKT_IPP_COPY2CPU_BITMAP_SIZE (NPS_BITMAP_SIZE(HAL_TAU_PKT_IPP_COPY2CPU_LAST)) -#define HAL_TAU_PKT_EPP_COPY2CPU_BITMAP_SIZE (NPS_BITMAP_SIZE(HAL_TAU_PKT_EPP_COPY2CPU_LAST)) - -typedef UI32_T HAL_TAU_PKT_IPP_EXCPT_BITMAP_T[HAL_TAU_PKT_IPP_EXCPT_BITMAP_SIZE]; -typedef UI32_T HAL_TAU_PKT_IPP_L3_EXCPT_BITMAP_T[HAL_TAU_PKT_IPP_L3_EXCPT_BITMAP_SIZE]; -typedef UI32_T HAL_TAU_PKT_EPP_EXCPT_BITMAP_T[HAL_TAU_PKT_EPP_EXCPT_BITMAP_SIZE]; -typedef UI32_T HAL_TAU_PKT_IPP_RSN_BITMAP_T[HAL_TAU_PKT_IPP_RSN_BITMAP_SIZE]; -typedef UI32_T HAL_TAU_PKT_IPP_COPY2CPU_BITMAP_T[HAL_TAU_PKT_IPP_COPY2CPU_BITMAP_SIZE]; -typedef UI32_T HAL_TAU_PKT_EPP_COPY2CPU_BITMAP_T[HAL_TAU_PKT_EPP_COPY2CPU_BITMAP_SIZE]; - -typedef struct -{ - /* excpt */ - HAL_TAU_PKT_IPP_EXCPT_BITMAP_T ipp_excpt_bitmap; - HAL_TAU_PKT_IPP_L3_EXCPT_BITMAP_T ipp_l3_excpt_bitmap; - HAL_TAU_PKT_EPP_EXCPT_BITMAP_T epp_excpt_bitmap; - - /* cp */ - HAL_TAU_PKT_IPP_RSN_BITMAP_T ipp_rsn_bitmap; - HAL_TAU_PKT_IPP_COPY2CPU_BITMAP_T ipp_copy2cpu_bitmap; - HAL_TAU_PKT_EPP_COPY2CPU_BITMAP_T epp_copy2cpu_bitmap; - -} HAL_PKT_RX_REASON_BITMAP_T; - - -/* hal_tau_pkt.h */ - -/* NAMING DECLARATIONS - */ -/* PKT related configurable parameters */ -#define HAL_DFLT_CFG_PKT_RX_FREE_STACK_SIZE (64 * 1024) -#define HAL_DFLT_CFG_PKT_RX_FREE_THREAD_PRI (80) - -#define HAL_DFLT_CFG_PKT_RX_ISR_THREAD_STACK (64 * 1024) -#define HAL_DFLT_CFG_PKT_RX_ISR_THREAD_PRI (80) - -#define HAL_DFLT_CFG_PKT_TX_FREE_STACK_SIZE (64 * 1024) -#define HAL_DFLT_CFG_PKT_TX_FREE_THREAD_PRI (80) - -#define HAL_DFLT_CFG_PKT_TX_ISR_THREAD_STACK (64 * 1024) -#define HAL_DFLT_CFG_PKT_TX_ISR_THREAD_PRI (80) - -#define HAL_DFLT_CFG_PKT_TX_NET_STACK_SIZE (64 * 1024) -#define HAL_DFLT_CFG_PKT_TX_NET_THREAD_PRI (80) - -#define HAL_DFLT_CFG_PKT_ERROR_ISR_THREAD_STACK (64 * 1024) -#define HAL_DFLT_CFG_PKT_ERROR_ISR_THREAD_PRI (80) - -/* PKT definitions */ -#define HAL_TAU_PKT_TX_MAX_LEN (9216) -#define HAL_TAU_PKT_RX_MAX_LEN (9216 + 86) /* EPP tunnel header */ -#define HAL_TAU_PKT_MIN_LEN (64) /* Ethernet definition */ -#define HAL_TAU_PKT_TMH_HDR_SZ (20) -#define HAL_TAU_PKT_PPH_HDR_SZ (20) -#define HAL_TAU_PKT_CRC_LEN (4) - -/* CH */ -#define HAL_TAU_PKT_CH_LAST_GPD (0) -#define HAL_TAU_PKT_CH_MIDDLE_GPD (1) - -/* PRG */ -#define HAL_TAU_PKT_PRG_PROCESS_GPD (0) /* Normal */ -#define HAL_TAU_PKT_PRG_SKIP_GPD (1) /* Skip */ - -/* CRCC */ -#define HAL_TAU_PKT_CRCC_SUM_BY_HW (0) /* calculated by HW */ -#define HAL_TAU_PKT_CRCC_SUM_BY_SW (1) /* calculated by SW */ - -/* IOC */ -#define HAL_TAU_PKT_IOC_NO_INTR (0) /* trigger interrupt each GPD */ -#define HAL_TAU_PKT_IOC_HAS_INTR (1) /* trigger interrupt when ch=0, default setting */ - -/* HWO */ -#define HAL_TAU_PKT_HWO_SW_OWN (0) -#define HAL_TAU_PKT_HWO_HW_OWN (1) - -/* ECC */ -#define HAL_TAU_PKT_ECC_ERROR_OCCUR (1) - -/* CPU queue number */ -#define HAL_TAU_PKT_CPU_QUE_NUM (48) - -/* PDMA Definitions */ -#define HAL_TAU_PKT_PDMA_MAX_GPD_PER_PKT (10) /* <= 256 */ -#define HAL_DFLT_CFG_PKT_TX_GPD_NUM (1024) /* <= 65535 */ -#define HAL_DFLT_CFG_PKT_RX_GPD_NUM (1024) /* <= 65535 */ -#define HAL_TAU_PKT_PDMA_TX_INTR_TIMEOUT (10 * 1000) /* us */ -#define HAL_TAU_PKT_PDMA_TX_POLL_MAX_LOOP (10 * 1000) /* int */ - -/* Mode */ -#define HAL_TAU_PKT_TX_WAIT_MODE (HAL_TAU_PKT_TX_WAIT_ASYNC) -#define HAL_DFLT_CFG_PKT_RX_SCHED_MODE (HAL_TAU_PKT_RX_SCHED_RR) - -/* TX Queue */ -#define HAL_DFLT_CFG_PKT_TX_QUEUE_LEN (HAL_DFLT_CFG_PKT_TX_GPD_NUM * 10) -#define HAL_TAU_PKT_TX_TASK_MAX_LOOP (HAL_DFLT_CFG_PKT_TX_QUEUE_LEN) - -/* RX Queue */ -#define HAL_TAU_PKT_RX_QUEUE_NUM (HAL_TAU_PKT_RX_CHANNEL_LAST) -#define HAL_DFLT_CFG_PKT_RX_QUEUE_WEIGHT (10) -#define HAL_DFLT_CFG_PKT_RX_QUEUE_LEN (HAL_DFLT_CFG_PKT_RX_GPD_NUM * 10) -#define HAL_TAU_PKT_RX_TASK_MAX_LOOP (HAL_DFLT_CFG_PKT_RX_QUEUE_LEN) - -/* MACRO FUNCTION DECLARATIONS - */ -/*---------------------------------------------------------------------------*/ -/* [NP8360] Alignment to 64-bytes */ -#if defined(NPS_EN_HOST_64_BIT_BIG_ENDIAN) || defined(NPS_EN_HOST_64_BIT_LITTLE_ENDIAN) -#define HAL_TAU_PKT_PDMA_ALIGN_ADDR(pdma_addr, align_sz) (((pdma_addr) + (align_sz)) & 0xFFFFFFFFFFFFFFC0) -#else -#define HAL_TAU_PKT_PDMA_ALIGN_ADDR(pdma_addr, align_sz) (((pdma_addr) + (align_sz)) & 0xFFFFFFC0) -#endif -/*---------------------------------------------------------------------------*/ -#if defined(NPS_EN_BIG_ENDIAN) -#define HAL_TAU_PKT_ENDIAN_SWAP32(val) (val) -#else -#define HAL_TAU_PKT_ENDIAN_SWAP32(val) ((((UI32_T)(val) & 0xFF) << 24) | \ - (((UI32_T)(val) & 0xFF00) << 8) | \ - (((UI32_T)(val) & 0xFF0000) >> 8) | \ - (((UI32_T)(val) & 0xFF000000) >> 24)) -#endif -/*---------------------------------------------------------------------------*/ -#define HAL_TAU_PKT_GET_BIT(flags, bit) ((((flags) & (bit)) > 0)? 1 : 0) -/*---------------------------------------------------------------------------*/ -#define HAL_TAU_PKT_SET_BITMAP(bitmap, mask_bitmap) (bitmap = ((bitmap) | (mask_bitmap))) -#define HAL_TAU_PKT_CLR_BITMAP(bitmap, mask_bitmap) (bitmap = ((bitmap) & (~(mask_bitmap)))) -/*---------------------------------------------------------------------------*/ -#define HAL_TAU_PKT_GET_TX_INTR_TYPE(channel) (HAL_INTR_TX_CH0 + channel) -#define HAL_TAU_PKT_GET_RX_INTR_TYPE(channel) (HAL_INTR_RX_CH0 + channel) - -/* DATA TYPE DECLARATIONS - */ -typedef enum -{ - HAL_TAU_PKT_TX_WAIT_ASYNC = 0, - HAL_TAU_PKT_TX_WAIT_SYNC_INTR = 1, - HAL_TAU_PKT_TX_WAIT_SYNC_POLL = 2 - -} HAL_TAU_PKT_TX_WAIT_T; - -typedef enum -{ - HAL_TAU_PKT_RX_SCHED_RR = 0, - HAL_TAU_PKT_RX_SCHED_WRR = 1 - -} HAL_TAU_PKT_RX_SCHED_T; - -/* GPD and Packet Strucutre Definition */ -#if defined(NPS_EN_BIG_ENDIAN) - -typedef struct -{ - /* NPS DWORD 0 */ - UI32_T typ : 2; - UI32_T tc : 4; - UI32_T color : 2; - UI32_T srv : 3; - UI32_T trig : 1; - UI32_T igr_phy_port :12; - UI32_T hsh_val_w0 : 8; - /* NPS DWORD 1 */ - UI32_T hsh_val_w1 : 2; - UI32_T dst_idx :15; - UI32_T src_idx :15; - /* NPS DWORD 2 */ - UI32_T intf_fdid :14; - UI32_T nvo3_mgid_is_transit : 1; - UI32_T skip_epp : 1; - UI32_T steer_applied : 1; - UI32_T nvo3_ip_tnl_decap_prop_ttl : 1; - UI32_T nvo3_mpls_uhp_prop_ttl : 1; - UI32_T ecn : 2; - UI32_T store_and_forward : 1; - UI32_T lag_epoch : 1; - UI32_T src_supp_tag : 5; - UI32_T one_arm_rte_srv_fdid : 1; - UI32_T fab_one_arm_rte : 1; - UI32_T skip_ipp : 1; - UI32_T igr_fab_port_grp : 1; - /* NPS DWORD 3 */ - UI32_T : 2; - UI32_T nvo3_mgid :15; - UI32_T nvo3_intf :14; - UI32_T nvo3_src_supp_tag_w0 : 1; - /* NPS DWORD 4 */ - UI32_T nvo3_src_supp_tag_w1 : 4; - UI32_T mir_bmap : 8; - UI32_T cp_to_cpu_code : 4; - UI32_T cp_to_cpu_bmap :16; -} HAL_TAU_PKT_ITMH_ETH_T; - -typedef struct -{ - /* NPS DWORD 0 */ - UI32_T typ : 2; - UI32_T tc : 4; - UI32_T color : 2; - UI32_T srv : 3; - UI32_T trig : 1; - UI32_T igr_phy_port :12; - UI32_T hsh_val_w0 : 8; - /* NPS DWORD 1 */ - UI32_T hsh_val_w1 : 2; - UI32_T dst_idx :15; - UI32_T src_idx :15; - /* NPS DWORD 2 */ - UI32_T intf_fdid :14; - UI32_T nvo3_mgid_is_transit : 1; - UI32_T skip_epp : 1; - UI32_T steer_applied : 1; - UI32_T nvo3_ip_tnl_decap_prop_ttl : 1; - UI32_T nvo3_mpls_uhp_prop_ttl : 1; - UI32_T ecn : 2; - UI32_T store_and_forward : 1; - UI32_T lag_epoch : 1; - UI32_T src_supp_tag : 5; - UI32_T one_arm_rte_srv_fdid : 1; - UI32_T fab_one_arm_rte : 1; - UI32_T : 2; - /* NPS DWORD 3 */ - UI32_T :32; - /* NPS DWORD 4 */ - UI32_T :23; - UI32_T excpt_code : 8; - UI32_T exp_dscp_mrkd : 1; -} HAL_TAU_PKT_ETMH_FAB_T; - -typedef struct -{ - /* NPS DWORD 0 */ - UI32_T typ : 2; - UI32_T tc : 4; - UI32_T color : 2; - UI32_T srv : 3; - UI32_T trig : 1; - UI32_T igr_phy_port :12; - UI32_T hsh_val_w0 : 8; - /* NPS DWORD 1 */ - UI32_T hsh_val_w1 : 2; - UI32_T dst_idx :15; - UI32_T src_idx :15; - /* NPS DWORD 2 */ - UI32_T intf_fdid :14; - UI32_T nvo3_mgid_is_transit : 1; - UI32_T skip_epp : 1; - UI32_T steer_applied : 1; - UI32_T nvo3_ip_tnl_decap_prop_ttl : 1; - UI32_T nvo3_mpls_uhp_prop_ttl : 1; - UI32_T ecn : 2; - UI32_T igr_fab_port_grp : 1; - UI32_T redir : 1; - UI32_T excpt_code_mir_bmap : 8; - UI32_T cp_to_cpu_bmap_w0 : 1; - /* NPS DWORD 3 */ - UI32_T cp_to_cpu_bmap_w1 : 7; - UI32_T egr_phy_port :12; - UI32_T src_supp_pnd : 1; - UI32_T mc_vid_ctl : 3; - UI32_T mc_vid_1st_w0 : 9; - /* NPS DWORD 4 */ - UI32_T mc_vid_1st_w1 : 3; - UI32_T mc_vid_2nd :12; - UI32_T mc_decr_ttl : 1; - UI32_T mc_is_routed : 1; - UI32_T mc_mel_vld : 1; - UI32_T mc_cp_idx :13; - UI32_T exp_dscp_mrkd : 1; -} HAL_TAU_PKT_ETMH_ETH_T; - -typedef struct -{ - /* NPS DWORD 0 */ - UI32_T decap_act : 3; - UI32_T igr_l2_vid_num : 2; - UI32_T nvo3_encap_idx :14; - UI32_T mpls_pw_cw_vld : 1; - UI32_T hit_idx_w0 :12; - /* NPS DWORD 1 */ - UI32_T hit_idx_w1 : 7; - UI32_T nvo3_adj_idx : 8; - UI32_T seg_vmid_w0 :17; - /* NPS DWORD 2 */ - UI32_T seg_vmid_w1 : 7; - UI32_T : 1; - UI32_T l2_sa_lrn_en_hw_cvs : 1; - UI32_T l2_sa_lrn_en_hw : 1; - UI32_T vid_ctl : 3; - UI32_T vid_1st :12; - UI32_T vid_2nd_w0 : 7; - /* NPS DWORD 3 */ - UI32_T vid_2nd_w1 : 5; - UI32_T flw_lbl :10; - UI32_T rewr_idx_ctl : 2; - UI32_T rewr_idx_0 :13; - UI32_T rewr_idx_1_w0 : 2; - /* NPS DWORD 4 */ - UI32_T rewr_idx_1_w1 :11; - UI32_T mrk_pcp_dei_en : 1; - UI32_T mrk_pcp_val : 3; - UI32_T mrk_dei_val : 1; - UI32_T ts :16; -} HAL_TAU_PKT_PPH_L2_T; - -typedef struct -{ - /* NPS DWORD 0 */ - UI32_T decap_act : 3; - UI32_T igr_l2_vid_num : 2; - UI32_T nvo3_encap_idx :14; - UI32_T mpls_pw_cw_vld : 1; - UI32_T hit_idx_w0 :12; - /* NPS DWORD 1 */ - UI32_T hit_idx_w1 : 7; - UI32_T nvo3_adj_idx : 8; - UI32_T seg_vmid_w0 :17; - /* NPS DWORD 2 */ - UI32_T seg_vmid_w1 : 7; - UI32_T : 1; - UI32_T rpf_pnd : 1; - UI32_T adj_idx :18; - UI32_T is_mc : 1; - UI32_T decr_ttl : 1; - UI32_T decap_prop_ttl : 1; - UI32_T mrk_dscp_en : 1; - UI32_T mrk_dscp_val_w0 : 1; - /* NPS DWORD 3 */ - UI32_T mrk_dscp_val_w1 : 5; - UI32_T flw_lbl :10; - UI32_T rewr_idx_ctl : 2; - UI32_T rewr_idx_0 :13; - UI32_T rewr_idx_1_w0 : 2; - /* NPS DWORD 4 */ - UI32_T rewr_idx_1_w1 :11; - UI32_T mrk_pcp_dei_en : 1; - UI32_T mrk_pcp_val : 3; - UI32_T mrk_dei_val : 1; - UI32_T ts :16; -} HAL_TAU_PKT_PPH_L3UC_T; - -typedef struct -{ - /* NPS DWORD 0 */ - UI32_T decap_act : 3; - UI32_T igr_l2_vid_num : 2; - UI32_T nvo3_encap_idx :14; - UI32_T mpls_pw_cw_vld : 1; - UI32_T hit_idx_w0 :12; - /* NPS DWORD 1 */ - UI32_T hit_idx_w1 : 7; - UI32_T nvo3_adj_idx : 8; - UI32_T vid_1st :12; - UI32_T vid_2nd_w0 : 5; - /* NPS DWORD 2 */ - UI32_T vid_2nd_w1 : 7; - UI32_T :15; - UI32_T l2_sa_lrn_en_hw_cvs : 1; - UI32_T l2_sa_lrn_en_hw : 1; - UI32_T vid_ctl : 3; - UI32_T is_mc : 1; - UI32_T : 1; - UI32_T decap_prop_ttl : 1; - UI32_T mrk_dscp_en : 1; - UI32_T mrk_dscp_val_w0 : 1; - /* NPS DWORD 3 */ - UI32_T mrk_dscp_val_w1 : 5; - UI32_T flw_lbl :10; - UI32_T rewr_idx_ctl : 2; - UI32_T rewr_idx_0 :13; - UI32_T rewr_idx_1_w0 : 2; - /* NPS DWORD 4 */ - UI32_T rewr_idx_1_w1 :11; - UI32_T mrk_pcp_dei_en : 1; - UI32_T mrk_pcp_val : 3; - UI32_T mrk_dei_val : 1; - UI32_T ts :16; -} HAL_TAU_PKT_PPH_L3MC_T; - -typedef struct -{ - /* NPS DWORD 0 */ - UI32_T decap_act : 3; - UI32_T igr_l2_vid_num : 2; - UI32_T nvo3_encap_idx :14; - UI32_T : 1; - UI32_T hit_idx_w0 :12; - /* NPS DWORD 1 */ - UI32_T hit_idx_w1 : 7; - UI32_T nvo3_adj_idx : 8; - UI32_T seg_vmid_w0 :17; - /* NPS DWORD 2 */ - UI32_T seg_vmid_w1 : 7; - UI32_T : 2; - UI32_T adj_idx :18; - UI32_T : 1; - UI32_T decr_ttl : 1; - UI32_T decap_prop_ttl : 1; - UI32_T mrk_exp_en : 1; - UI32_T : 1; - /* NPS DWORD 3 */ - UI32_T : 2; - UI32_T mrk_exp_val : 3; - UI32_T php_pop_keep_inner_qos : 1; - UI32_T :26; - /* NPS DWORD 4 */ - UI32_T :11; - UI32_T mrk_pcp_dei_en : 1; - UI32_T mrk_pcp_val : 3; - UI32_T mrk_dei_val : 1; - UI32_T ts :16; -} HAL_TAU_PKT_PPH_L25_T; - -#elif defined(NPS_EN_LITTLE_ENDIAN) - -typedef struct -{ - /* NPS DWORD 0 */ - UI32_T hsh_val_w0 : 8; - UI32_T igr_phy_port :12; - UI32_T trig : 1; - UI32_T srv : 3; - UI32_T color : 2; - UI32_T tc : 4; - UI32_T typ : 2; - /* NPS DWORD 1 */ - UI32_T src_idx :15; - UI32_T dst_idx :15; - UI32_T hsh_val_w1 : 2; - /* NPS DWORD 2 */ - UI32_T igr_fab_port_grp : 1; - UI32_T skip_ipp : 1; - UI32_T fab_one_arm_rte : 1; - UI32_T one_arm_rte_srv_fdid : 1; - UI32_T src_supp_tag : 5; - UI32_T lag_epoch : 1; - UI32_T store_and_forward : 1; - UI32_T ecn : 2; - UI32_T nvo3_mpls_uhp_prop_ttl : 1; - UI32_T nvo3_ip_tnl_decap_prop_ttl : 1; - UI32_T steer_applied : 1; - UI32_T skip_epp : 1; - UI32_T nvo3_mgid_is_transit : 1; - UI32_T intf_fdid :14; - /* NPS DWORD 3 */ - UI32_T nvo3_src_supp_tag_w0 : 1; - UI32_T nvo3_intf :14; - UI32_T nvo3_mgid :15; - UI32_T : 2; - /* NPS DWORD 4 */ - UI32_T cp_to_cpu_bmap :16; - UI32_T cp_to_cpu_code : 4; - UI32_T mir_bmap : 8; - UI32_T nvo3_src_supp_tag_w1 : 4; -} HAL_TAU_PKT_ITMH_ETH_T; - -typedef struct -{ - /* NPS DWORD 0 */ - UI32_T hsh_val_w0 : 8; - UI32_T igr_phy_port :12; - UI32_T trig : 1; - UI32_T srv : 3; - UI32_T color : 2; - UI32_T tc : 4; - UI32_T typ : 2; - /* NPS DWORD 1 */ - UI32_T src_idx :15; - UI32_T dst_idx :15; - UI32_T hsh_val_w1 : 2; - /* NPS DWORD 2 */ - UI32_T : 2; - UI32_T fab_one_arm_rte : 1; - UI32_T one_arm_rte_srv_fdid : 1; - UI32_T src_supp_tag : 5; - UI32_T lag_epoch : 1; - UI32_T store_and_forward : 1; - UI32_T ecn : 2; - UI32_T nvo3_mpls_uhp_prop_ttl : 1; - UI32_T nvo3_ip_tnl_decap_prop_ttl : 1; - UI32_T steer_applied : 1; - UI32_T skip_epp : 1; - UI32_T nvo3_mgid_is_transit : 1; - UI32_T intf_fdid :14; - /* NPS DWORD 3 */ - UI32_T :32; - /* NPS DWORD 4 */ - UI32_T exp_dscp_mrkd : 1; - UI32_T excpt_code : 8; - UI32_T :23; -} HAL_TAU_PKT_ETMH_FAB_T; - -typedef struct -{ - /* NPS DWORD 0 */ - UI32_T hsh_val_w0 : 8; - UI32_T igr_phy_port :12; - UI32_T trig : 1; - UI32_T srv : 3; - UI32_T color : 2; - UI32_T tc : 4; - UI32_T typ : 2; - /* NPS DWORD 1 */ - UI32_T src_idx :15; - UI32_T dst_idx :15; - UI32_T hsh_val_w1 : 2; - /* NPS DWORD 2 */ - UI32_T cp_to_cpu_bmap_w0 : 1; - UI32_T excpt_code_mir_bmap : 8; - UI32_T redir : 1; - UI32_T igr_fab_port_grp : 1; - UI32_T ecn : 2; - UI32_T nvo3_mpls_uhp_prop_ttl : 1; - UI32_T nvo3_ip_tnl_decap_prop_ttl : 1; - UI32_T steer_applied : 1; - UI32_T skip_epp : 1; - UI32_T nvo3_mgid_is_transit : 1; - UI32_T intf_fdid :14; - /* NPS DWORD 3 */ - UI32_T mc_vid_1st_w0 : 9; - UI32_T mc_vid_ctl : 3; - UI32_T src_supp_pnd : 1; - UI32_T egr_phy_port :12; - UI32_T cp_to_cpu_bmap_w1 : 7; - /* NPS DWORD 4 */ - UI32_T exp_dscp_mrkd : 1; - UI32_T mc_cp_idx :13; - UI32_T mc_mel_vld : 1; - UI32_T mc_is_routed : 1; - UI32_T mc_decr_ttl : 1; - UI32_T mc_vid_2nd :12; - UI32_T mc_vid_1st_w1 : 3; -} HAL_TAU_PKT_ETMH_ETH_T; - -typedef struct -{ - /* NPS DWORD 0 */ - UI32_T hit_idx_w0 :12; - UI32_T mpls_pw_cw_vld : 1; - UI32_T nvo3_encap_idx :14; - UI32_T igr_l2_vid_num : 2; - UI32_T decap_act : 3; - /* NPS DWORD 1 */ - UI32_T seg_vmid_w0 :17; - UI32_T nvo3_adj_idx : 8; - UI32_T hit_idx_w1 : 7; - /* NPS DWORD 2 */ - UI32_T vid_2nd_w0 : 7; - UI32_T vid_1st :12; - UI32_T vid_ctl : 3; - UI32_T l2_sa_lrn_en_hw : 1; - UI32_T l2_sa_lrn_en_hw_cvs : 1; - UI32_T : 1; - UI32_T seg_vmid_w1 : 7; - /* NPS DWORD 3 */ - UI32_T rewr_idx_1_w0 : 2; - UI32_T rewr_idx_0 :13; - UI32_T rewr_idx_ctl : 2; - UI32_T flw_lbl :10; - UI32_T vid_2nd_w1 : 5; - /* NPS DWORD 4 */ - UI32_T ts :16; - UI32_T mrk_dei_val : 1; - UI32_T mrk_pcp_val : 3; - UI32_T mrk_pcp_dei_en : 1; - UI32_T rewr_idx_1_w1 :11; -} HAL_TAU_PKT_PPH_L2_T; - -typedef struct -{ - /* NPS DWORD 0 */ - UI32_T hit_idx_w0 :12; - UI32_T mpls_pw_cw_vld : 1; - UI32_T nvo3_encap_idx :14; - UI32_T igr_l2_vid_num : 2; - UI32_T decap_act : 3; - /* NPS DWORD 1 */ - UI32_T seg_vmid_w0 :17; - UI32_T nvo3_adj_idx : 8; - UI32_T hit_idx_w1 : 7; - /* NPS DWORD 2 */ - UI32_T mrk_dscp_val_w0 : 1; - UI32_T mrk_dscp_en : 1; - UI32_T decap_prop_ttl : 1; - UI32_T decr_ttl : 1; - UI32_T is_mc : 1; - UI32_T adj_idx :18; - UI32_T rpf_pnd : 1; - UI32_T : 1; - UI32_T seg_vmid_w1 : 7; - /* NPS DWORD 3 */ - UI32_T rewr_idx_1_w0 : 2; - UI32_T rewr_idx_0 :13; - UI32_T rewr_idx_ctl : 2; - UI32_T flw_lbl :10; - UI32_T mrk_dscp_val_w1 : 5; - /* NPS DWORD 4 */ - UI32_T ts :16; - UI32_T mrk_dei_val : 1; - UI32_T mrk_pcp_val : 3; - UI32_T mrk_pcp_dei_en : 1; - UI32_T rewr_idx_1_w1 :11; -} HAL_TAU_PKT_PPH_L3UC_T; - -typedef struct -{ - /* NPS DWORD 0 */ - UI32_T hit_idx_w0 :12; - UI32_T mpls_pw_cw_vld : 1; - UI32_T nvo3_encap_idx :14; - UI32_T igr_l2_vid_num : 2; - UI32_T decap_act : 3; - /* NPS DWORD 1 */ - UI32_T vid_2nd_w0 : 5; - UI32_T vid_1st :12; - UI32_T nvo3_adj_idx : 8; - UI32_T hit_idx_w1 : 7; - /* NPS DWORD 2 */ - UI32_T mrk_dscp_val_w0 : 1; - UI32_T mrk_dscp_en : 1; - UI32_T decap_prop_ttl : 1; - UI32_T : 1; - UI32_T is_mc : 1; - UI32_T vid_ctl : 3; - UI32_T l2_sa_lrn_en_hw : 1; - UI32_T l2_sa_lrn_en_hw_cvs : 1; - UI32_T :15; - UI32_T vid_2nd_w1 : 7; - /* NPS DWORD 3 */ - UI32_T rewr_idx_1_w0 : 2; - UI32_T rewr_idx_0 :13; - UI32_T rewr_idx_ctl : 2; - UI32_T flw_lbl :10; - UI32_T mrk_dscp_val_w1 : 5; - /* NPS DWORD 4 */ - UI32_T ts :16; - UI32_T mrk_dei_val : 1; - UI32_T mrk_pcp_val : 3; - UI32_T mrk_pcp_dei_en : 1; - UI32_T rewr_idx_1_w1 :11; -} HAL_TAU_PKT_PPH_L3MC_T; - -typedef struct -{ - /* NPS DWORD 0 */ - UI32_T hit_idx_w0 :12; - UI32_T : 1; - UI32_T nvo3_encap_idx :14; - UI32_T igr_l2_vid_num : 2; - UI32_T decap_act : 3; - /* NPS DWORD 1 */ - UI32_T seg_vmid_w0 :17; - UI32_T nvo3_adj_idx : 8; - UI32_T hit_idx_w1 : 7; - /* NPS DWORD 2 */ - UI32_T : 1; - UI32_T mrk_exp_en : 1; - UI32_T decap_prop_ttl : 1; - UI32_T decr_ttl : 1; - UI32_T : 1; - UI32_T adj_idx :18; - UI32_T : 2; - UI32_T seg_vmid_w1 : 7; - /* NPS DWORD 3 */ - UI32_T :26; - UI32_T php_pop_keep_inner_qos : 1; - UI32_T mrk_exp_val : 3; - UI32_T : 2; - /* NPS DWORD 4 */ - UI32_T ts :16; - UI32_T mrk_dei_val : 1; - UI32_T mrk_pcp_val : 3; - UI32_T mrk_pcp_dei_en : 1; - UI32_T :11; -} HAL_TAU_PKT_PPH_L25_T; - -#else -#error "Host GPD endian is not defined!!\n" -#endif - -#if defined(NPS_EN_BIG_ENDIAN) - -/* RX GPD STRUCTURE */ -typedef struct -{ - UI32_T data_buf_addr_lo; - UI32_T data_buf_addr_hi; - UI32_T chksum : 16; - UI32_T ioc : 1; - UI32_T : 1; - UI32_T avbl_buf_len : 14; - UI32_T : 32; - - union - { - HAL_TAU_PKT_ITMH_ETH_T itmh_eth; - HAL_TAU_PKT_ETMH_FAB_T etmh_fab; - HAL_TAU_PKT_ETMH_ETH_T etmh_eth; - }; - union - { - HAL_TAU_PKT_PPH_L2_T pph_l2; - HAL_TAU_PKT_PPH_L3UC_T pph_l3uc; - HAL_TAU_PKT_PPH_L3MC_T pph_l3mc; - HAL_TAU_PKT_PPH_L25_T pph_l25; - }; - - UI32_T : 32; - UI32_T hwo : 1; - UI32_T ch : 1; - UI32_T trn : 1; - UI32_T ecce : 1; - UI32_T errf : 1; - UI32_T : 5; - UI32_T queue : 6; - UI32_T : 2; - UI32_T cnsm_buf_len : 14; - -} HAL_TAU_PKT_RX_GPD_T; - -/* TX GPD STRUCTURE */ -typedef struct -{ - UI32_T data_buf_addr_lo; - UI32_T data_buf_addr_hi; - UI32_T chksum : 16; - UI32_T ioc : 1; - UI32_T : 1; - UI32_T data_buf_size : 14; - UI32_T : 32; - - union - { - HAL_TAU_PKT_ITMH_ETH_T itmh_eth; - HAL_TAU_PKT_ETMH_FAB_T etmh_fab; - HAL_TAU_PKT_ETMH_ETH_T etmh_eth; - }; - union - { - HAL_TAU_PKT_PPH_L2_T pph_l2; - HAL_TAU_PKT_PPH_L3UC_T pph_l3uc; - HAL_TAU_PKT_PPH_L3MC_T pph_l3mc; - HAL_TAU_PKT_PPH_L25_T pph_l25; - }; - - UI32_T : 16; - UI32_T ptp_hdr : 16; - UI32_T hwo : 1; - UI32_T ch : 1; - UI32_T : 1; - UI32_T ecce : 1; - UI32_T : 4; - UI32_T cos : 3; - UI32_T phc : 1; /* PTP Header Control */ - UI32_T ipc : 2; /* Ingress Plane Control */ - UI32_T crcc : 1; - UI32_T prg : 1; /* Purge */ - UI32_T : 2; - UI32_T pkt_len : 14; /* Total packet length */ - -} HAL_TAU_PKT_TX_GPD_T; - -#elif defined(NPS_EN_LITTLE_ENDIAN) - -/* RX GPD STRUCTURE */ -typedef struct -{ - UI32_T data_buf_addr_lo; - UI32_T data_buf_addr_hi; - UI32_T avbl_buf_len : 14; - UI32_T : 1; - UI32_T ioc : 1; - UI32_T chksum : 16; - UI32_T : 32; - - union - { - HAL_TAU_PKT_ITMH_ETH_T itmh_eth; - HAL_TAU_PKT_ETMH_FAB_T etmh_fab; - HAL_TAU_PKT_ETMH_ETH_T etmh_eth; - }; - union - { - HAL_TAU_PKT_PPH_L2_T pph_l2; - HAL_TAU_PKT_PPH_L3UC_T pph_l3uc; - HAL_TAU_PKT_PPH_L3MC_T pph_l3mc; - HAL_TAU_PKT_PPH_L25_T pph_l25; - }; - - UI32_T : 32; - UI32_T cnsm_buf_len : 14; - UI32_T : 2; - UI32_T queue : 6; - UI32_T : 5; - UI32_T errf : 1; - UI32_T ecce : 1; - UI32_T trn : 1; - UI32_T ch : 1; - UI32_T hwo : 1; - -} HAL_TAU_PKT_RX_GPD_T; - -/* TX GPD STRUCTURE */ -typedef struct -{ - UI32_T data_buf_addr_lo; - UI32_T data_buf_addr_hi; - UI32_T data_buf_size : 14; - UI32_T : 1; - UI32_T ioc : 1; - UI32_T chksum : 16; - UI32_T : 32; - - union - { - HAL_TAU_PKT_ITMH_ETH_T itmh_eth; - HAL_TAU_PKT_ETMH_FAB_T etmh_fab; - HAL_TAU_PKT_ETMH_ETH_T etmh_eth; - }; - union - { - HAL_TAU_PKT_PPH_L2_T pph_l2; - HAL_TAU_PKT_PPH_L3UC_T pph_l3uc; - HAL_TAU_PKT_PPH_L3MC_T pph_l3mc; - HAL_TAU_PKT_PPH_L25_T pph_l25; - }; - - UI32_T ptp_hdr : 16; - UI32_T : 16; - UI32_T pkt_len : 14; /* Total packet length */ - UI32_T : 2; - UI32_T prg : 1; /* Purge */ - UI32_T crcc : 1; - UI32_T ipc : 2; /* Ingress Plane Control */ - UI32_T phc : 1; /* PTP Header Control */ - UI32_T cos : 3; - UI32_T : 4; - UI32_T ecce : 1; - UI32_T : 1; - UI32_T ch : 1; - UI32_T hwo : 1; -} HAL_TAU_PKT_TX_GPD_T; - -#else -#error "Host GPD endian is not defined\n" -#endif - -/* ----------------------------------------------------------------------------------- PP Type */ -typedef enum -{ - HAL_TAU_PKT_TMH_TYPE_ITMH_ETH = 0, - HAL_TAU_PKT_TMH_TYPE_ITMH_FAB, - HAL_TAU_PKT_TMH_TYPE_ETMH_FAB, - HAL_TAU_PKT_TMH_TYPE_ETMH_ETH, - HAL_TAU_PKT_TMH_TYPE_LAST - -} HAL_TAU_PKT_TMH_TYPE_T; - -typedef enum -{ - HAL_TAU_PKT_TMH_SRV_L2 = 0, - HAL_TAU_PKT_TMH_SRV_L25_MPLS, - HAL_TAU_PKT_TMH_SRV_L3, - HAL_TAU_PKT_TMH_SRV_EGR, /* L3 downgrade L2 */ - HAL_TAU_PKT_TMH_SRV_L25_NSH, - HAL_TAU_PKT_TMH_SRV_L25_TRILL, - HAL_TAU_PKT_TMH_SRV_LAST - -} HAL_TAU_PKT_TMH_SRV_T; - -typedef enum -{ - HAL_TAU_PKT_TMH_DECAP_NONE = 0, - HAL_TAU_PKT_TMH_DECAP_1_MPLS_LABEL, - HAL_TAU_PKT_TMH_DECAP_2_MPLS_LABEL, - HAL_TAU_PKT_TMH_DECAP_3_MPLS_LABEL, - HAL_TAU_PKT_TMH_DECAP_4_MPLS_LABEL, - HAL_TAU_PKT_TMH_DECAP_IP_TRILL_NSH, - HAL_TAU_PKT_TMH_DECAP_LAST - -} HAL_TAU_PKT_TMH_DECAP_T; - -typedef struct -{ - union - { - HAL_TAU_PKT_ITMH_ETH_T itmh_eth; - HAL_TAU_PKT_ETMH_FAB_T etmh_fab; - HAL_TAU_PKT_ETMH_ETH_T etmh_eth; - }; -} HAL_TAU_PKT_TMH_T; - -typedef struct -{ - union - { - HAL_TAU_PKT_PPH_L2_T pph_l2; - HAL_TAU_PKT_PPH_L3UC_T pph_l3uc; - HAL_TAU_PKT_PPH_L3MC_T pph_l3mc; - HAL_TAU_PKT_PPH_L25_T pph_l25; - }; -} HAL_TAU_PKT_PPH_T; - -/* ----------------------------------------------------------------------------------- Reg Type */ -typedef enum -{ - HAL_TAU_PKT_L2_ISR_RCH0 = (0x1UL << 0), - HAL_TAU_PKT_L2_ISR_RCH1 = (0x1UL << 1), - HAL_TAU_PKT_L2_ISR_RCH2 = (0x1UL << 2), - HAL_TAU_PKT_L2_ISR_RCH3 = (0x1UL << 3), - HAL_TAU_PKT_L2_ISR_TCH0 = (0x1UL << 4), - HAL_TAU_PKT_L2_ISR_TCH1 = (0x1UL << 5), - HAL_TAU_PKT_L2_ISR_TCH2 = (0x1UL << 6), - HAL_TAU_PKT_L2_ISR_TCH3 = (0x1UL << 7), - HAL_TAU_PKT_L2_ISR_RX_QID_MAP_ERR = (0x1UL << 8), - HAL_TAU_PKT_L2_ISR_RX_FRAME_ERR = (0x1UL << 9) - -} HAL_TAU_PKT_L2_ISR_T; - -typedef enum -{ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_HWO_ERROR = (0x1UL << 0), /* Tx GPD.hwo = 0 */ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_CHKSM_ERROR = (0x1UL << 1), /* Tx GPD.chksm is error */ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_NO_OVFL_ERROR = (0x1UL << 2), /* S/W push too much GPD */ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_DMA_READ_ERROR = (0x1UL << 3), /* AXI Rd Error when do GPD read */ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_BUF_SIZE_ERROR = (0x1UL << 4), /* Tx GPD.data_buf_size = 0 */ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_RUNT_ERROR = (0x1UL << 5), /* Tx GPD.pkt_len < 64 */ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_OVSZ_ERROR = (0x1UL << 6), /* Tx GPD.pkt_len = 9217 */ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_LEN_MISMATCH_ERROR = (0x1UL << 7), /* Tx GPD.pkt_len != sum of data_buf_size */ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_PKTPL_DMA_READ_ERROR = (0x1UL << 8), /* AXI Rd Error when do Payload read */ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_COS_ERROR = (0x1UL << 9), /* Tx GPD.cos is not match cos_to_tch_map */ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_GPD_GT255_ERROR = (0x1UL << 10), /* Multi-GPD packet's GPD# > 255 */ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_PFC = (0x1UL << 11), /* */ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_CREDIT_UDFL_ERROR = (0x1UL << 12), /* Credit Underflow (count down to 0) */ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_DMA_WRITE_ERROR = (0x1UL << 13), /* AXI Wr Error (GPD Write-Back) */ - HAL_TAU_PKT_TX_CHANNEL_L2_ISR_STOP_CMD_CPLT = (0x1UL << 14) - -} HAL_TAU_PKT_TX_CHANNEL_L2_ISR_T; - -typedef enum -{ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_LOW = (0x1UL << 0), /* Rx GPD.avbl_gpd_num < threshold */ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_EMPTY = (0x1UL << 1), /* Rx GPD.avbl_gpd_num = 0 */ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_AVAIL_GPD_ERROR = (0x1UL << 2), /* Rx GPD.hwo = 0 */ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_GPD_CHKSM_ERROR = (0x1UL << 3), /* Rx GPD.chksm is error */ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_DMA_READ_ERROR = (0x1UL << 4), /* DMAR error occurs in PCIE */ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_DMA_WRITE_ERROR = (0x1UL << 5), /* DMAW error occurs in PCIE */ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_STOP_CMD_CPLT = (0x1UL << 6), /* Stop Completion Acknowledge */ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_GPD_GT255_ERROR = (0x1UL << 7), /* Multi-GPD packet's GPD# > 255 */ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_TOD_UNINIT = (0x1UL << 8), /* */ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_PKT_ERROR_DROP = (0x1UL << 9), /* */ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_UDSZ_DROP = (0x1UL << 10), /* */ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_OVSZ_DROP = (0x1UL << 11), /* */ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_CMDQ_OVF_DROP = (0x1UL << 12), /* */ - HAL_TAU_PKT_RX_CHANNEL_L2_ISR_FIFO_OVF_DROP = (0x1UL << 13) - -} HAL_TAU_PKT_RX_CHANNEL_L2_ISR_T; - -typedef enum -{ - HAL_TAU_PKT_TX_CHANNEL_CFG_IOC = (0x1UL << 0), - HAL_TAU_PKT_TX_CHANNEL_CFG_CHKSUM = (0x1UL << 1), - HAL_TAU_PKT_TX_CHANNEL_CFG_PFC = (0x1UL << 2), - HAL_TAU_PKT_TX_CHANNEL_CFG_PKT_LEN_CHK = (0x1UL << 3), - HAL_TAU_PKT_TX_CHANNEL_CFG_EARLY_DONE_IRQ = (0x1UL << 4), - HAL_TAU_PKT_TX_CHANNEL_CFG_CHK_COS = (0x1UL << 5), - HAL_TAU_PKT_TX_CHANNEL_CFG_ADV_GPD_WRBK = (0x1UL << 6), - HAL_TAU_PKT_TX_CHANNEL_CFG_GPD_WRBK_FULL_PKT_LEN = (0x1UL << 7), - HAL_TAU_PKT_TX_CHANNEL_CFG_LAST = (0x1UL << 8) - -} HAL_TAU_PKT_TX_CHANNEL_CFG_T; - -typedef enum -{ - HAL_TAU_PKT_RX_CHANNEL_CFG_IOC = (0x1UL << 0), - HAL_TAU_PKT_RX_CHANNEL_CFG_CHKSUM = (0x1UL << 1), - HAL_TAU_PKT_RX_CHANNEL_CFG_LAST = (0x1UL << 2) - -} HAL_TAU_PKT_RX_CHANNEL_CFG_T; - -/* ----------------------------------------------------------------------------------- Tx */ -typedef enum -{ - HAL_TAU_PKT_TX_CHANNEL_0 = 0, - HAL_TAU_PKT_TX_CHANNEL_1, - HAL_TAU_PKT_TX_CHANNEL_2, - HAL_TAU_PKT_TX_CHANNEL_3, - HAL_TAU_PKT_TX_CHANNEL_LAST - -} HAL_TAU_PKT_TX_CHANNEL_T; - -typedef void -(*HAL_TAU_PKT_TX_FUNC_T)( - const UI32_T unit, - const void *ptr_sw_gpd, /* SW-GPD to be processed */ - void *ptr_coockie); /* Private data of SDK */ - -typedef struct HAL_TAU_PKT_TX_SW_GPD_S -{ - HAL_TAU_PKT_TX_FUNC_T callback; /* (unit, ptr_sw_gpd, ptr_cookie) */ - void *ptr_cookie; /* Pointer of NPS_PKT_TX_PKT_T */ - HAL_TAU_PKT_TX_GPD_T tx_gpd; - UI32_T gpd_num; - struct HAL_TAU_PKT_TX_SW_GPD_S *ptr_next; - -#if defined (NPS_EN_NETIF) - UI32_T channel; /* For counter */ -#endif - -} HAL_TAU_PKT_TX_SW_GPD_T; - -typedef struct -{ - UI32_T send_ok; - UI32_T gpd_empty; - UI32_T poll_timeout; - - /* queue */ - UI32_T enque_ok; - UI32_T enque_retry; - - /* event */ - UI32_T trig_event; - - /* normal interrupt */ - UI32_T tx_done; - - /* abnormal interrupt */ - UI32_T gpd_hwo_err; /* bit-0 */ - UI32_T gpd_chksm_err; /* bit-1 */ - UI32_T gpd_no_ovfl_err; /* bit-2 */ - UI32_T gpd_dma_read_err; /* bit-3 */ - UI32_T buf_size_err; /* bit-4 */ - UI32_T runt_err; /* bit-5 */ - UI32_T ovsz_err; /* bit-6 */ - UI32_T len_mismatch_err; /* bit-7 */ - UI32_T pktpl_dma_read_err; /* bit-8 */ - UI32_T cos_err; /* bit-9 */ - UI32_T gpd_gt255_err; /* bit-10 */ - UI32_T pfc; /* bit-11 */ - UI32_T credit_udfl_err; /* bit-12 */ - UI32_T dma_write_err; /* bit-13 */ - UI32_T sw_issue_stop; /* bit-14 */ - - /* others */ - UI32_T err_recover; - UI32_T ecc_err; - -} HAL_TAU_PKT_TX_CHANNEL_CNT_T; - -typedef struct -{ - HAL_TAU_PKT_TX_CHANNEL_CNT_T channel[HAL_TAU_PKT_TX_CHANNEL_LAST]; - UI32_T invoke_gpd_callback; - UI32_T no_memory; - - /* queue */ - UI32_T deque_ok; - UI32_T deque_fail; - - /* event */ - UI32_T wait_event; - -} HAL_TAU_PKT_TX_CNT_T; - -/* ----------------------------------------------------------------------------------- Rx */ -typedef enum -{ - HAL_TAU_PKT_RX_CHANNEL_0 = 0, - HAL_TAU_PKT_RX_CHANNEL_1, - HAL_TAU_PKT_RX_CHANNEL_2, - HAL_TAU_PKT_RX_CHANNEL_3, - HAL_TAU_PKT_RX_CHANNEL_LAST -} HAL_TAU_PKT_RX_CHANNEL_T; - -typedef enum -{ - HAL_TAU_PKT_C_NEXT = 0, /* callback continuous */ - HAL_TAU_PKT_C_STOP = 1, - HAL_TAU_PKT_C_OTHERS = 2 -} HAL_TAU_PKT_CALLBACK_NO_T; - -typedef enum -{ - HAL_TAU_PKT_RX_CALLBACK_ACTION_INSERT = 0, - HAL_TAU_PKT_RX_CALLBACK_ACTION_APPEND = 1, - HAL_TAU_PKT_RX_CALLBACK_ACTION_DELETE = 2, - HAL_TAU_PKT_RX_CALLBACK_ACTION_DELETE_ALL = 3 -} HAL_TAU_PKT_RX_CALLBACK_ACTION_T; - -typedef HAL_TAU_PKT_CALLBACK_NO_T -(*HAL_TAU_PKT_RX_FUNC_T)( - const UI32_T unit, - const void *ptr_sw_gpd, /* SW-GPD to be processed */ - void *ptr_cookie); /* Private data of SDK */ - -typedef struct HAL_TAU_PKT_RX_CALLBACK_S -{ - HAL_TAU_PKT_RX_FUNC_T callback; /* (unit, ptr_sw_gpd, ptr_cookie) */ - void *ptr_cookie; - struct HAL_TAU_PKT_RX_CALLBACK_S *ptr_next; -} HAL_TAU_PKT_RX_CALLBACK_T; - -typedef struct HAL_TAU_PKT_RX_SW_GPD_S -{ - BOOL_T rx_complete; /* FALSE when PDMA error occurs */ - HAL_TAU_PKT_RX_GPD_T rx_gpd; - struct HAL_TAU_PKT_RX_SW_GPD_S *ptr_next; - -#if defined (NPS_EN_NETIF) - void *ptr_cookie; /* Pointer of virt-addr */ -#endif - -} HAL_TAU_PKT_RX_SW_GPD_T; - -typedef struct -{ - /* queue */ - UI32_T enque_ok; - UI32_T enque_retry; - UI32_T deque_ok; - UI32_T deque_fail; - - /* event */ - UI32_T trig_event; - - /* normal interrupt */ - UI32_T rx_done; - - /* abnormal interrupt */ - UI32_T avbl_gpd_low; /* bit-0 */ - UI32_T avbl_gpd_empty; /* bit-1 */ - UI32_T avbl_gpd_err; /* bit-2 */ - UI32_T gpd_chksm_err; /* bit-3 */ - UI32_T dma_read_err; /* bit-4 */ - UI32_T dma_write_err; /* bit-5 */ - UI32_T sw_issue_stop; /* bit-6 */ - UI32_T gpd_gt255_err; /* bit-7 */ - UI32_T tod_uninit; /* bit-8 */ - UI32_T pkt_err_drop; /* bit-9 */ - UI32_T udsz_drop; /* bit-10 */ - UI32_T ovsz_drop; /* bit-11 */ - UI32_T cmdq_ovf_drop; /* bit-12 */ - UI32_T fifo_ovf_drop; /* bit-13 */ - - /* others */ - UI32_T err_recover; - UI32_T ecc_err; - -#if defined (NPS_EN_NETIF) - /* it means that user doesn't create intf on that port */ - UI32_T netdev_miss; -#endif - - -} HAL_TAU_PKT_RX_CHANNEL_CNT_T; - -typedef struct -{ - HAL_TAU_PKT_RX_CHANNEL_CNT_T channel[HAL_TAU_PKT_RX_CHANNEL_LAST]; - UI32_T invoke_gpd_callback; - UI32_T no_memory; - - /* event */ - UI32_T wait_event; - -} HAL_TAU_PKT_RX_CNT_T; - -/* ----------------------------------------------------------------------------------- Reg */ -#if defined(NPS_EN_LITTLE_ENDIAN) - -typedef union -{ - UI32_T reg; - struct - { - UI32_T tch_axlen_cfg : 3; - UI32_T : 5; - UI32_T tch_axi_free_arvalid : 1; - UI32_T : 7; - UI32_T tch_arvalid_thrhold_cfg : 2; - UI32_T : 6; - UI32_T tch_rready_low_4_hdr : 1; - UI32_T tch_ios_crdt_add_en : 1; - UI32_T : 6; - } field; -} HAL_TAU_PKT_AXI_LEN_CFG_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T pdma_lbk_en : 1; - UI32_T : 3; - UI32_T pdma_lbk_plane : 2; - UI32_T : 2; - UI32_T pm_lbk_en : 1; - UI32_T : 7; - UI32_T pm_lbk_rqid : 6; - UI32_T : 2; - UI32_T : 8; - } field; -} HAL_TAU_PKT_LBK_CTRL_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T pdma_lbk_rqid0 : 6; - UI32_T : 2; - UI32_T pdma_lbk_rqid1 : 6; - UI32_T : 2; - UI32_T pdma_lbk_rqid2 : 6; - UI32_T : 2; - UI32_T pdma_lbk_rqid3 : 6; - UI32_T : 2; - } field; -} HAL_TAU_PKT_LBK_RQID0_3_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T pdma_lbk_rqid4 : 6; - UI32_T : 2; - UI32_T pdma_lbk_rqid5 : 6; - UI32_T : 2; - UI32_T pdma_lbk_rqid6 : 6; - UI32_T : 2; - UI32_T pdma_lbk_rqid7 : 6; - UI32_T : 2; - } field; -} HAL_TAU_PKT_LBK_RQID4_7_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T cos_pfc_sts0 : 8; - UI32_T cos_pfc_sts1 : 8; - UI32_T cos_pfc_sts2 : 8; - UI32_T cos_pfc_sts3 : 8; - } field; -} HAL_TAU_PKT_COS_PFC_STS_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T pdma_ela_en : 1; - UI32_T : 7; - UI32_T pdma_ela_valid_sel : 8; - UI32_T : 8; - UI32_T : 8; - } field; -} HAL_TAU_PKT_ELA_CTRL_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T pdma_ela_word0_sel : 8; - UI32_T pdma_ela_word1_sel : 8; - UI32_T pdma_ela_word2_sel : 8; - UI32_T pdma_ela_word3_sel : 8; - } field; -} HAL_TAU_PKT_ELA_SEL_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T ingr_pln_ios_credit_base_size_lo : 8; - UI32_T ingr_pln_ios_credit_base_size_hi : 8; - UI32_T ingr_pln_ios_credit_set : 1; - UI32_T : 7; - UI32_T : 1; - UI32_T ingr_pln_full_pkt_mode : 1; - UI32_T : 6; - } field; -} HAL_TAU_PKT_IGR_PLN_CREDIT_CFG_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T ingr_pln_cur_ios_credit_lo : 8; - UI32_T ingr_pln_cur_ios_credit_hi : 8; - UI32_T ingr_pln_ios_credit_ovfl : 1; - UI32_T ingr_pln_ios_credit_udfl : 1; - UI32_T : 6; - UI32_T : 8; - } field; -} HAL_TAU_PKT_IGR_PLN_CREDIT_STS_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T ingr_pln_ios_credit_rdy_lo_bound : 8; - UI32_T ingr_pln_ios_credit_rdy_hi_bound : 8; - UI32_T : 8; - UI32_T : 8; - } field; -} HAL_TAU_PKT_IGR_PLN_CREDIT_THR_REG_T; - - -typedef union -{ - UI32_T reg; - struct - { - UI32_T rch_stomp_crc_en : 1; - UI32_T : 7; - UI32_T rch_crc_regen_en : 1; - UI32_T : 7; - UI32_T rch_pfc_fun_en : 1; - UI32_T : 7; - UI32_T : 8; - } field; -} HAL_TAU_PKT_RCH_STOMP_CRC_CTRL_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T rch_ioc_en : 1; - UI32_T : 7; - UI32_T rch_chksm_en : 1; - UI32_T : 7; - UI32_T : 8; - UI32_T : 8; - } field; -} HAL_TAU_PKT_RCH_MISC_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T rch_gpd_pfc_lo : 8; - UI32_T rch_gpd_pfc_hi : 8; - UI32_T : 8; - UI32_T : 8; - } field; -} HAL_TAU_PKT_RCH_GPD_PFC_CTRL_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T rch_fifo_pfc_lo_lo : 8; - UI32_T rch_fifo_pfc_lo_hi : 3; - UI32_T : 5; - UI32_T rch_fifo_pfc_hi_lo : 8; - UI32_T rch_fifo_pfc_hi_hi : 3; - UI32_T : 5; - } field; -} HAL_TAU_PKT_RCH_FIFO_PFC_CTRL_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T rch_cmdq_pfc_lo : 5; - UI32_T : 3; - UI32_T rch_cmdq_pfc_hi : 5; - UI32_T : 3; - UI32_T : 8; - UI32_T : 8; - } field; -} HAL_TAU_PKT_RCH_CMDQ_PFC_CTRL_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T rch_start : 1; - UI32_T rch_resume : 1; - UI32_T rch_stop : 1; - UI32_T : 5; - UI32_T : 8; - UI32_T rch_gpd_add_no_lo : 8; - UI32_T rch_gpd_add_no_hi : 8; - } field; -} HAL_TAU_PKT_RCH_CMD_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T rch_fifo_ovf_drop_cnt_clr : 1; - UI32_T rch_cmdq_ovf_drop_cnt_clr : 1; - UI32_T rch_ovsz_drop_cnt_clr : 1; - UI32_T rch_udsz_drop_cnt_clr : 1; - UI32_T rch_pkterr_drop_cnt_clr : 1; - UI32_T rch_flush_cnt_clr : 1; - UI32_T : 2; - UI32_T : 8; - UI32_T : 8; - UI32_T : 8; - } field; -} HAL_TAU_PKT_RCH_CNT_CLR_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T rch_active : 1; - UI32_T rch_avbl_gpd_pfc : 1; - UI32_T rch_fifo_pfc : 1; - UI32_T rch_cmdq_pfc : 1; - UI32_T rch_pfc : 1; - UI32_T : 3; - UI32_T : 8; - UI32_T rch_avbl_gpd_no_lo : 8; - UI32_T rch_avbl_gpd_no_hi : 8; - } field; -} HAL_TAU_PKT_RCH_STATUS_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T tch_ioc_en : 1; - UI32_T tch_chksm_en : 1; - UI32_T tch_pfc_en : 1; - UI32_T tch_pktlen_chk_en : 1; - UI32_T tch_early_done_irq : 1; - UI32_T tch_chk_cos_en : 1; - UI32_T tch_adv_gpd_wrbk : 1; - UI32_T tch_gpd_wrbk_full_pkt_len : 1; - UI32_T : 8; - UI32_T : 8; - UI32_T : 8; - } field; -} HAL_TAU_PKT_TCH_CFG_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T tch_start : 1; - UI32_T tch_resume : 1; - UI32_T tch_stop : 1; - UI32_T : 5; - UI32_T : 8; - UI32_T tch_gpd_add_no_lo : 8; - UI32_T tch_gpd_add_no_hi : 8; - } field; -} HAL_TAU_PKT_TCH_CMD_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T tch_active : 1; - UI32_T tch_pfc : 1; - UI32_T tch_gpd_rd_dma_act : 1; - UI32_T : 5; - UI32_T : 8; - UI32_T tch_avbl_gpd_no : 1; - UI32_T : 7; - UI32_T : 8; - } field; -} HAL_TAU_PKT_TCH_STS_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T tch_gpd_dmar_qos : 4; - UI32_T : 4; - UI32_T tch_pkt_dmar_qos : 4; - UI32_T : 4; - UI32_T tch_gpd_dmaw_qos : 4; - UI32_T : 4; - UI32_T : 8; - } field; -} HAL_TAU_PKT_TCH_QOS_CFG_REG_T; - -#elif defined(NPS_EN_BIG_ENDIAN) - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 6; - UI32_T tch_ios_crdt_add_en : 1; - UI32_T tch_rready_low_4_hdr : 1; - UI32_T : 6; - UI32_T tch_arvalid_thrhold_cfg : 2; - UI32_T : 7; - UI32_T tch_axi_free_arvalid : 1; - UI32_T : 5; - UI32_T tch_axlen_cfg : 3; - } field; -} HAL_TAU_PKT_AXI_LEN_CFG_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 8; - UI32_T : 2; - UI32_T pm_lbk_rqid : 6; - UI32_T : 7; - UI32_T pm_lbk_en : 1; - UI32_T : 2; - UI32_T pdma_lbk_plane : 2; - UI32_T : 3; - UI32_T pdma_lbk_en : 1; - } field; -} HAL_TAU_PKT_LBK_CTRL_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 2; - UI32_T pdma_lbk_rqid3 : 6; - UI32_T : 2; - UI32_T pdma_lbk_rqid2 : 6; - UI32_T : 2; - UI32_T pdma_lbk_rqid1 : 6; - UI32_T : 2; - UI32_T pdma_lbk_rqid0 : 6; - } field; -} HAL_TAU_PKT_LBK_RQID0_3_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 2; - UI32_T pdma_lbk_rqid7 : 6; - UI32_T : 2; - UI32_T pdma_lbk_rqid6 : 6; - UI32_T : 2; - UI32_T pdma_lbk_rqid5 : 6; - UI32_T : 2; - UI32_T pdma_lbk_rqid4 : 6; - } field; -} HAL_TAU_PKT_LBK_RQID4_7_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T cos_pfc_sts3 : 8; - UI32_T cos_pfc_sts2 : 8; - UI32_T cos_pfc_sts1 : 8; - UI32_T cos_pfc_sts0 : 8; - } field; -} HAL_TAU_PKT_COS_PFC_STS_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 8; - UI32_T : 8; - UI32_T pdma_ela_valid_sel : 8; - UI32_T : 7; - UI32_T pdma_ela_en : 1; - } field; -} HAL_TAU_PKT_ELA_CTRL_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T pdma_ela_word3_sel : 8; - UI32_T pdma_ela_word2_sel : 8; - UI32_T pdma_ela_word1_sel : 8; - UI32_T pdma_ela_word0_sel : 8; - } field; -} HAL_TAU_PKT_ELA_SEL_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 6; - UI32_T ingr_pln_full_pkt_mode : 1; - UI32_T : 1; - UI32_T : 7; - UI32_T ingr_pln_ios_credit_set : 1; - UI32_T ingr_pln_ios_credit_base_size_hi : 8; - UI32_T ingr_pln_ios_credit_base_size_lo : 8; - } field; -} HAL_TAU_PKT_IGR_PLN_CREDIT_CFG_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 8; - UI32_T : 6; - UI32_T ingr_pln_ios_credit_udfl : 1; - UI32_T ingr_pln_ios_credit_ovfl : 1; - UI32_T ingr_pln_cur_ios_credit_hi : 8; - UI32_T ingr_pln_cur_ios_credit_lo : 8; - } field; -} HAL_TAU_PKT_IGR_PLN_CREDIT_STS_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 8; - UI32_T : 8; - UI32_T ingr_pln_ios_credit_rdy_hi_bound : 8; - UI32_T ingr_pln_ios_credit_rdy_lo_bound : 8; - } field; -} HAL_TAU_PKT_IGR_PLN_CREDIT_THR_REG_T; - - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 8; - UI32_T : 7; - UI32_T rch_pfc_fun_en : 1; - UI32_T : 7; - UI32_T rch_crc_regen_en : 1; - UI32_T : 7; - UI32_T rch_stomp_crc_en : 1; - } field; -} HAL_TAU_PKT_RCH_STOMP_CRC_CTRL_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 8; - UI32_T : 8; - UI32_T : 7; - UI32_T rch_chksm_en : 1; - UI32_T : 7; - UI32_T rch_ioc_en : 1; - } field; -} HAL_TAU_PKT_RCH_MISC_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 8; - UI32_T : 8; - UI32_T rch_gpd_pfc_hi : 8; - UI32_T rch_gpd_pfc_lo : 8; - } field; -} HAL_TAU_PKT_RCH_GPD_PFC_CTRL_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 5; - UI32_T rch_fifo_pfc_hi_hi : 3; - UI32_T rch_fifo_pfc_hi_lo : 8; - UI32_T : 5; - UI32_T rch_fifo_pfc_lo_hi : 3; - UI32_T rch_fifo_pfc_lo_lo : 8; - } field; -} HAL_TAU_PKT_RCH_FIFO_PFC_CTRL_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 8; - UI32_T : 8; - UI32_T : 3; - UI32_T rch_cmdq_pfc_hi : 5; - UI32_T : 3; - UI32_T rch_cmdq_pfc_lo : 5; - } field; -} HAL_TAU_PKT_RCH_CMDQ_PFC_CTRL_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T rch_gpd_add_no_hi : 8; - UI32_T rch_gpd_add_no_lo : 8; - UI32_T : 8; - UI32_T : 5; - UI32_T rch_stop : 1; - UI32_T rch_resume : 1; - UI32_T rch_start : 1; - } field; -} HAL_TAU_PKT_RCH_CMD_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 8; - UI32_T : 8; - UI32_T : 8; - UI32_T : 2; - UI32_T rch_flush_cnt_clr : 1; - UI32_T rch_pkterr_drop_cnt_clr : 1; - UI32_T rch_udsz_drop_cnt_clr : 1; - UI32_T rch_ovsz_drop_cnt_clr : 1; - UI32_T rch_cmdq_ovf_drop_cnt_clr : 1; - UI32_T rch_fifo_ovf_drop_cnt_clr : 1; - } field; -} HAL_TAU_PKT_RCH_CNT_CLR_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T rch_avbl_gpd_no_hi : 8; - UI32_T rch_avbl_gpd_no_lo : 8; - UI32_T : 8; - UI32_T : 3; - UI32_T rch_pfc : 1; - UI32_T rch_cmdq_pfc : 1; - UI32_T rch_fifo_pfc : 1; - UI32_T rch_avbl_gpd_pfc : 1; - UI32_T rch_active : 1; - } field; -} HAL_TAU_PKT_RCH_STATUS_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 8; - UI32_T : 8; - UI32_T : 8; - UI32_T tch_gpd_wrbk_full_pkt_len : 1; - UI32_T tch_adv_gpd_wrbk : 1; - UI32_T tch_chk_cos_en : 1; - UI32_T tch_early_done_irq : 1; - UI32_T tch_pktlen_chk_en : 1; - UI32_T tch_pfc_en : 1; - UI32_T tch_chksm_en : 1; - UI32_T tch_ioc_en : 1; - } field; -} HAL_TAU_PKT_TCH_CFG_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T tch_gpd_add_no_hi : 8; - UI32_T tch_gpd_add_no_lo : 8; - UI32_T : 8; - UI32_T : 5; - UI32_T tch_stop : 1; - UI32_T tch_resume : 1; - UI32_T tch_start : 1; - } field; -} HAL_TAU_PKT_TCH_CMD_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 8; - UI32_T : 7; - UI32_T tch_avbl_gpd_no : 1; - UI32_T : 8; - UI32_T : 5; - UI32_T tch_gpd_rd_dma_act : 1; - UI32_T tch_pfc : 1; - UI32_T tch_active : 1; - } field; -} HAL_TAU_PKT_TCH_STS_REG_T; - -typedef union -{ - UI32_T reg; - struct - { - UI32_T : 8; - UI32_T : 4; - UI32_T tch_gpd_dmaw_qos : 4; - UI32_T : 4; - UI32_T tch_pkt_dmar_qos : 4; - UI32_T : 4; - UI32_T tch_gpd_dmar_qos : 4; - } field; -} HAL_TAU_PKT_TCH_QOS_CFG_REG_T; - -#else -#error "Host GPD endian is not defined\n" -#endif - -/* ----------------------------------------------------------------------------------- NPS_EN_NETIF */ -#if defined (NPS_EN_NETIF) -#define HAL_TAU_PKT_DRIVER_MAJOR_NUM (10) -#define HAL_TAU_PKT_DRIVER_MINOR_NUM (252) /* DO NOT use MISC_DYNAMIC_MINOR */ -#define HAL_TAU_PKT_DRIVER_NAME "nps_netif" -#define HAL_TAU_PKT_DRIVER_PATH "/dev/"HAL_TAU_PKT_DRIVER_NAME - -/* These requirements come from NPS_NETIF APIs. - * nps_netif -> hal_pkt_drv -> hal_pkt_knl - */ - -typedef struct -{ - UI32_T tx_pkt; - UI32_T tx_queue_full; - UI32_T tx_error; - UI32_T rx_pkt; - -} HAL_TAU_PKT_NETIF_INTF_CNT_T; - -typedef struct -{ - /* unique key */ - UI32_T id; - C8_T name[NPS_NETIF_NAME_LEN]; - UI32_T port; /* only support unit port and local port */ - - /* metadata */ - UI8_T mac[6]; - -#define HAL_TAU_PKT_NETIF_INTF_FLAGS_MAC (1UL << 0) - UI32_T flags; - - -} HAL_TAU_PKT_NETIF_INTF_T; - -#if defined(NETIF_EN_NETLINK) -typedef struct -{ - C8_T name[NPS_NETIF_NAME_LEN]; - C8_T mc_group_name[NPS_NETIF_NAME_LEN]; -} HAL_TAU_PKT_NETIF_RX_DST_NETLINK_T; -#endif - -typedef enum -{ - HAL_TAU_PKT_NETIF_RX_DST_SDK = 0, -#if defined(NETIF_EN_NETLINK) - HAL_TAU_PKT_NETIF_RX_DST_NETLINK, -#endif - HAL_TAU_PKT_NETIF_RX_DST_LAST -} HAL_TAU_PKT_NETIF_RX_DST_TYPE_T; - -typedef struct -{ - /* unique key */ - UI32_T id; - C8_T name[NPS_NETIF_NAME_LEN]; - UI32_T priority; - - /* match fields */ - UI32_T port; /* only support unit port and local port */ - HAL_PKT_RX_REASON_BITMAP_T reason_bitmap; - UI8_T pattern[NPS_NETIF_PROFILE_PATTERN_NUM][NPS_NETIF_PROFILE_PATTERN_LEN]; - UI8_T mask[NPS_NETIF_PROFILE_PATTERN_NUM][NPS_NETIF_PROFILE_PATTERN_LEN]; - UI32_T offset[NPS_NETIF_PROFILE_PATTERN_NUM]; - - /* for each flag 1:must hit, 0:don't care */ -#define HAL_TAU_PKT_NETIF_PROFILE_FLAGS_PORT (1UL << 0) -#define HAL_TAU_PKT_NETIF_PROFILE_FLAGS_REASON (1UL << 1) -#define HAL_TAU_PKT_NETIF_PROFILE_FLAGS_PATTERN_0 (1UL << 2) -#define HAL_TAU_PKT_NETIF_PROFILE_FLAGS_PATTERN_1 (1UL << 3) -#define HAL_TAU_PKT_NETIF_PROFILE_FLAGS_PATTERN_2 (1UL << 4) -#define HAL_TAU_PKT_NETIF_PROFILE_FLAGS_PATTERN_3 (1UL << 5) - UI32_T flags; - - HAL_TAU_PKT_NETIF_RX_DST_TYPE_T dst_type; -#if defined(NETIF_EN_NETLINK) - HAL_TAU_PKT_NETIF_RX_DST_NETLINK_T netlink; -#endif - -} HAL_TAU_PKT_NETIF_PROFILE_T; - - -/* These requirements come from NPS_PKT APIs. - * nps_pkt -> hal_pkt_srv -> hal_pkt_drv -> hal_pkt_knl - */ -typedef enum -{ - /* network interface */ - HAL_TAU_PKT_IOCTL_TYPE_CREATE_INTF = 0, - HAL_TAU_PKT_IOCTL_TYPE_DESTROY_INTF, - HAL_TAU_PKT_IOCTL_TYPE_GET_INTF, - HAL_TAU_PKT_IOCTL_TYPE_CREATE_PROFILE, - HAL_TAU_PKT_IOCTL_TYPE_DESTROY_PROFILE, - HAL_TAU_PKT_IOCTL_TYPE_GET_PROFILE, - HAL_TAU_PKT_IOCTL_TYPE_GET_INTF_CNT, - HAL_TAU_PKT_IOCTL_TYPE_CLEAR_INTF_CNT, - /* driver */ - HAL_TAU_PKT_IOCTL_TYPE_WAIT_RX_FREE, - HAL_TAU_PKT_IOCTL_TYPE_WAIT_TX_FREE, /* waitTxFree(ASYNC) */ - HAL_TAU_PKT_IOCTL_TYPE_SET_RX_CFG, /* setRxConfig */ - HAL_TAU_PKT_IOCTL_TYPE_GET_RX_CFG, /* getRxConfig */ - HAL_TAU_PKT_IOCTL_TYPE_DEINIT_TASK, /* deinitTask */ - HAL_TAU_PKT_IOCTL_TYPE_DEINIT_DRV, /* deinitDrv */ - HAL_TAU_PKT_IOCTL_TYPE_INIT_TASK, /* initTask */ - HAL_TAU_PKT_IOCTL_TYPE_INIT_DRV, /* initDrv */ - /* counter */ - HAL_TAU_PKT_IOCTL_TYPE_GET_TX_CNT, - HAL_TAU_PKT_IOCTL_TYPE_GET_RX_CNT, - HAL_TAU_PKT_IOCTL_TYPE_CLEAR_TX_CNT, - HAL_TAU_PKT_IOCTL_TYPE_CLEAR_RX_CNT, - /* port attribute */ - HAL_TAU_PKT_IOCTL_TYPE_SET_PORT_ATTR, -#if defined(NETIF_EN_NETLINK) - HAL_TAU_PKT_IOCTL_TYPE_NL_SET_INTF_PROPERTY, - HAL_TAU_PKT_IOCTL_TYPE_NL_GET_INTF_PROPERTY, - HAL_TAU_PKT_IOCTL_TYPE_NL_CREATE_NETLINK, - HAL_TAU_PKT_IOCTL_TYPE_NL_DESTROY_NETLINK, - HAL_TAU_PKT_IOCTL_TYPE_NL_GET_NETLINK, -#endif - HAL_TAU_PKT_IOCTL_TYPE_LAST - -} HAL_TAU_PKT_IOCTL_TYPE_T; - -typedef enum -{ - HAL_TAU_PKT_IOCTL_RX_TYPE_INIT = 0, - HAL_TAU_PKT_IOCTL_RX_TYPE_DEINIT, - HAL_TAU_PKT_IOCTL_RX_TYPE_LAST, - -} HAL_TAU_PKT_IOCTL_RX_TYPE_T; - -typedef struct -{ - UI32_T unit; - UI32_T channel; - HAL_TAU_PKT_RX_CNT_T rx_cnt; - HAL_TAU_PKT_TX_CNT_T tx_cnt; - NPS_ERROR_NO_T rc; - -} HAL_TAU_PKT_IOCTL_CH_CNT_COOKIE_T; - -typedef struct -{ - UI32_T unit; - HAL_TAU_PKT_NETIF_INTF_T net_intf; /* addIntf[In,Out], delIntf[In] */ - HAL_TAU_PKT_NETIF_PROFILE_T net_profile; /* createProfile[In,Out], destroyProfile[In] */ - HAL_TAU_PKT_NETIF_INTF_CNT_T cnt; - NPS_ERROR_NO_T rc; - -} HAL_TAU_PKT_IOCTL_NETIF_COOKIE_T; - -typedef struct -{ - NPS_ADDR_T callback; /* (unit, ptr_sw_gpd, ptr_cookie) */ - NPS_ADDR_T cookie; /* Pointer of NPS_PKT_TX_PKT_T */ - UI32_T channel; - UI32_T gpd_num; - NPS_ADDR_T hw_gpd_addr; - NPS_ADDR_T sw_gpd_addr; - -} HAL_TAU_PKT_IOCTL_TX_GPD_T; - -typedef struct -{ - UI32_T unit; - UI32_T channel; /* sendGpd[In] */ - NPS_ADDR_T ioctl_gpd_addr; /* sendGpd[In] */ - NPS_ADDR_T done_sw_gpd_addr; /* waitTxFree[Out] */ - -} HAL_TAU_PKT_IOCTL_TX_COOKIE_T; - -typedef struct -{ - BOOL_T rx_complete; /* FALSE when PDMA error occurs */ - NPS_ADDR_T hw_gpd_addr; /* Pointer to HW GPD in user's SW GPD struct */ - NPS_ADDR_T dma_buf_addr; /* Pointer to DMA buffer allocated by the user (virtual) */ - -} HAL_TAU_PKT_IOCTL_RX_GPD_T; - -typedef struct -{ - UI32_T unit; - UI32_T channel; /* getRxCnt[In], clearRxInt[In] */ - NPS_ADDR_T ioctl_gpd_addr; /* waitRxFree[Out] */ - UI32_T buf_len; /* setRxCfg[In] */ - HAL_TAU_PKT_IOCTL_RX_TYPE_T rx_type; /* setRxCfg[In] */ - -} HAL_TAU_PKT_IOCTL_RX_COOKIE_T; - -typedef struct -{ - UI32_T port; - UI32_T status; - UI32_T speed; - -} HAL_TAU_PKT_IOCTL_PORT_COOKIE_T; - -#if defined(NETIF_EN_NETLINK) - -#define NPS_NETIF_NETLINK_NUM_MAX (256) -#define NPS_NETIF_NETLINK_MC_GROUP_NUM_MAX (32) - -typedef enum -{ - NPS_NETIF_INTF_PROPERTY_IGR_SAMPLING_RATE, - NPS_NETIF_INTF_PROPERTY_EGR_SAMPLING_RATE, - NPS_NETIF_INTF_PROPERTY_LAST -} NPS_NETIF_INTF_PROPERTY_T; - -typedef struct -{ - C8_T name[NPS_NETIF_NAME_LEN]; - -} NPS_NETIF_NETLINK_MC_GROUP_T; - -typedef struct -{ - UI32_T id; - C8_T name[NPS_NETIF_NAME_LEN]; - NPS_NETIF_NETLINK_MC_GROUP_T mc_group[NPS_NETIF_NETLINK_MC_GROUP_NUM_MAX]; - UI32_T mc_group_num; - -} NPS_NETIF_NETLINK_T; - -typedef struct -{ - /* intf property */ - UI32_T intf_id; - NPS_NETIF_INTF_PROPERTY_T property; - UI32_T param0; - UI32_T param1; - - /* netlink */ - NPS_NETIF_NETLINK_T netlink; - - NPS_ERROR_NO_T rc; - -} HAL_TAU_PKT_NL_IOCTL_COOKIE_T; - - -#endif /* End of NETIF_EN_NETLINK */ - -typedef union -{ - UI32_T value; - struct - { - UI32_T unit : 6; /* Maximum unit number is 64. */ - HAL_TAU_PKT_IOCTL_TYPE_T type : 10; /* Maximum 1024 IOCTL types */ - UI32_T rsvd : 16; - } field; - -} HAL_TAU_PKT_IOCTL_CMD_T; - - -#endif /* End of NPS_EN_NETIF */ - -NPS_ERROR_NO_T -hal_tau_pkt_sendGpd( - const UI32_T unit, - const HAL_TAU_PKT_TX_CHANNEL_T channel, - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_gpd); - -/*---------------------------------------------------------------------------*/ -/* perf */ -NPS_ERROR_NO_T -hal_tau_pkt_getTxIntrCnt( - const UI32_T unit, - const UI32_T channel, - UI32_T *ptr_intr_cnt); - -NPS_ERROR_NO_T -hal_tau_pkt_getRxIntrCnt( - const UI32_T unit, - const UI32_T channel, - UI32_T *ptr_intr_cnt); - -/* ioctl */ -NPS_ERROR_NO_T -hal_tau_pkt_getTxKnlCnt( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_CH_CNT_COOKIE_T *ptr_cookie); - -NPS_ERROR_NO_T -hal_tau_pkt_getRxKnlCnt( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_CH_CNT_COOKIE_T *ptr_cookie); - -NPS_ERROR_NO_T -hal_tau_pkt_clearTxKnlCnt( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_TX_COOKIE_T *ptr_cookie); - -NPS_ERROR_NO_T -hal_tau_pkt_clearRxKnlCnt( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_RX_COOKIE_T *ptr_cookie); - -NPS_ERROR_NO_T -hal_tau_pkt_setRxKnlConfig( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_RX_COOKIE_T *ptr_cookie); - -NPS_ERROR_NO_T -hal_tau_pkt_getRxKnlConfig( - const UI32_T unit, - HAL_TAU_PKT_IOCTL_RX_COOKIE_T *ptr_cookie); - -/* perf */ -NPS_ERROR_NO_T -hal_tau_pkt_getNetDev( - const UI32_T unit, - const UI32_T port, - struct net_device **pptr_net_dev); - -NPS_ERROR_NO_T -hal_tau_pkt_prepareGpd( - const UI32_T unit, - const NPS_ADDR_T phy_addr, - const UI32_T len, - const UI32_T port, - HAL_TAU_PKT_TX_SW_GPD_T *ptr_sw_gpd); - -#endif /* end of HAL_TAU_PKT_KNL_H */ diff --git a/platform/nephos/nephos-modules/modules/src/inc/netif_nl.h b/platform/nephos/nephos-modules/modules/src/inc/netif_nl.h deleted file mode 100755 index 4b31ceef162..00000000000 --- a/platform/nephos/nephos-modules/modules/src/inc/netif_nl.h +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - - /* FILE NAME: netif_nl.h - * PURPOSE: - * It provide xxx API. - * NOTES: - */ - -#ifndef NETIF_NL_H -#define NETIF_NL_H - -#include - -#define NETIF_NL_NETLINK_MC_GROUP_NUM (32) -#define NETIF_NL_NETLINK_NAME_LEN (16) - -typedef enum -{ - NETIF_NL_INTF_PROPERTY_IGR_SAMPLING_RATE, - NETIF_NL_INTF_PROPERTY_EGR_SAMPLING_RATE, - NETIF_NL_INTF_PROPERTY_LAST -} NETIF_NL_INTF_PROPERTY_T; - -/* must be the same with NPS_NETIF_RX_DST_NETLINK_T */ -typedef struct -{ - C8_T name[NETIF_NL_NETLINK_NAME_LEN]; - C8_T mc_group_name[NETIF_NL_NETLINK_NAME_LEN]; -} NETIF_NL_RX_DST_NETLINK_T; - -/* must be the same with NPS_NETIF_NETLINK_MC_GROUP_T */ -typedef struct -{ - C8_T name[NETIF_NL_NETLINK_NAME_LEN]; - -} NETIF_NL_NETLINK_MC_GROUP_T; - -/* must be the same with NPS_NETIF_NETLINK_T */ -typedef struct -{ - UI32_T id; - C8_T name[NETIF_NL_NETLINK_NAME_LEN]; - NETIF_NL_NETLINK_MC_GROUP_T mc_group[NETIF_NL_NETLINK_MC_GROUP_NUM]; - UI32_T mc_group_num; - -} NETIF_NL_NETLINK_T; - -NPS_ERROR_NO_T -netif_nl_rxSkb( - const UI32_T unit, - struct sk_buff *ptr_skb, - void *ptr_cookie); - -NPS_ERROR_NO_T -netif_nl_setIntfProperty( - const UI32_T unit, - const UI32_T id, - const NETIF_NL_INTF_PROPERTY_T property, - const UI32_T param0, - const UI32_T param1); - -NPS_ERROR_NO_T -netif_nl_getIntfProperty( - const UI32_T unit, - const UI32_T port, - const NETIF_NL_INTF_PROPERTY_T property, - UI32_T *ptr_param0, - UI32_T *ptr_param1); - -NPS_ERROR_NO_T -netif_nl_createNetlink( - const UI32_T unit, - NETIF_NL_NETLINK_T *ptr_netlink, - UI32_T *ptr_netlink_id); - -NPS_ERROR_NO_T -netif_nl_destroyNetlink( - const UI32_T unit, - const UI32_T group_id); - -NPS_ERROR_NO_T -netif_nl_getNetlink( - const UI32_T unit, - const UI32_T netlink_id, - NETIF_NL_NETLINK_T *ptr_netlink); - - -NPS_ERROR_NO_T -netif_nl_init(void); - -#endif /* end of NETIF_NL_H */ diff --git a/platform/nephos/nephos-modules/modules/src/inc/netif_osal.h b/platform/nephos/nephos-modules/modules/src/inc/netif_osal.h deleted file mode 100755 index 93f30fc61ce..00000000000 --- a/platform/nephos/nephos-modules/modules/src/inc/netif_osal.h +++ /dev/null @@ -1,379 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: netif_osal.h - * PURPOSE: - * It provide customer linux API. - * NOTES: - */ - -#ifndef NETIF_OSAL_H -#define NETIF_OSAL_H - -/* - * ENOMEM : 12 - Out of memory - * EFAULT : 14 - Bad address - * EBUSY : 16 - Device or resource busy - * ENODEV : 19 - No such device - * EINVAL : 22 - Invalid argument - - * - * NETDEV_TX_OK : 0x00 - * NETDEV_TX_BUSY : 0x10 - - * - * ETH_HLEN : 14 dmac + smac + etyp - * ETH_ZLEN : 60 minimum ethernet frame size - * ETH_DATA_LEN : 1500 - * ETH_FRAME_LEN : 1514 - * ETH_FCS_LEN : 4 - * - * ETH_P_IP : 0x0800 - * ETH_P_ARP : 0x0806 - * ETH_P_IPV6 : 0x86DD - * ETH_P_SLOW : 0x8809 - * ETH_P_1588 : 0x88F7 - - * - * NET_IP_ALIGN : 2 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* ----------------------------------------------------------------------------------- macro value */ -/* Thread */ -#define OSAL_THREAD_NAME_LEN (16) -#define OSAL_THREAD_DFT_NAME ("Unknown") - -/* Semaphore */ -#define OSAL_SEMA_NAME_LEN (16) -#define OSAL_SEMA_DFT_NAME ("Unknown") - -/* Event */ -#define OSAL_EVENT_NAME_LEN (16) -#define OSAL_EVENT_DFT_NAME ("Unknown") - -/* Spinlock */ -#define OSAL_SPIN_NAME_LEN (16) -#define OSAL_SPIN_DFT_NAME ("Unknown") - -/* Queue */ -#define OSAL_QUEUE_NAME_LEN (16) -#define OSAL_QUEUE_DFT_NAME ("Unknown") - -#define OSAL_PRN_BUF_SZ (256) -#define OSAL_TICKS_PER_SEC (1000000) - -/* ----------------------------------------------------------------------------------- struct */ -typedef struct linux_thread_s -{ - char name[OSAL_THREAD_NAME_LEN + 1]; - struct task_struct *ptr_task; - unsigned int is_stop; - struct linux_thread_s *ptr_prev; - struct linux_thread_s *ptr_next; - -} linux_thread_t; - -typedef struct -{ - char name[OSAL_SEMA_NAME_LEN + 1]; - struct semaphore lock; - -} linux_sema_t; - -typedef struct -{ - char name[OSAL_EVENT_NAME_LEN + 1]; - wait_queue_head_t wait_que; - unsigned int condition; - -} linux_event_t; - -typedef struct -{ - char name[OSAL_SPIN_NAME_LEN + 1]; - spinlock_t spinlock; - -} linux_isrlock_t; - -typedef struct -{ - void *ptr_data; -} linux_queue_entry_t; - -typedef struct -{ - char name[OSAL_QUEUE_NAME_LEN + 1]; - int head; /* index of the queue head entry can be read */ - int tail; /* index of the queue tail entry can be write */ - unsigned int wr_cnt; /* enqueue total count */ - unsigned int rd_cnt; /* dequeue total count */ - unsigned int capacity; /* the queue size */ - linux_queue_entry_t *ptr_entry; /* the queue entry buffer */ - -} linux_queue_t; - -typedef struct -{ - unsigned int size; - dma_addr_t phy_addr; - char data[0]; - -} linux_dma_t; - -/* ----------------------------------------------------------------------------------- function */ -void * -osal_memset( - void *ptr_mem, - const I32_T value, - const UI32_T num); - -void * -osal_memcpy( - void *ptr_dst, - const void *ptr_src, - const UI32_T num); - -UI32_T -osal_strlen( - const C8_T *ptr_str); - -void -osal_printf( - const C8_T *ptr_fmt, - ...); - -void * -osal_alloc( - const UI32_T size); - -void -osal_free( - const void *ptr_mem); - -/* thread */ -NPS_ERROR_NO_T -osal_init(void); - -NPS_ERROR_NO_T -osal_deinit(void); - -NPS_ERROR_NO_T -osal_createThread ( - const C8_T *ptr_thread_name, - const UI32_T stack_size, - const UI32_T priority, - void (function)(void*), - void *ptr_arg, - NPS_THREAD_ID_T *ptr_thread_id); - -NPS_ERROR_NO_T -osal_stopThread( - NPS_THREAD_ID_T *ptr_thread_id); - -NPS_ERROR_NO_T -osal_destroyThread( - NPS_THREAD_ID_T *ptr_thread_id); - -void -osal_initRunThread( - void); - -NPS_ERROR_NO_T -osal_isRunThread( - void); - -void -osal_exitRunThread( - void); - -/* semaphore */ -NPS_ERROR_NO_T -osal_createSemaphore( - const C8_T *ptr_sema_name, - const UI32_T sema_count, - NPS_SEMAPHORE_ID_T *ptr_semaphore_id); - -NPS_ERROR_NO_T -osal_takeSemaphore( - NPS_SEMAPHORE_ID_T *ptr_semaphore_id, - UI32_T time_out); - -NPS_ERROR_NO_T -osal_giveSemaphore( - NPS_SEMAPHORE_ID_T *ptr_semaphore_id); - -NPS_ERROR_NO_T -osal_destroySemaphore( - NPS_SEMAPHORE_ID_T *ptr_semaphore_id); - -/* event */ -NPS_ERROR_NO_T -osal_createEvent( - const C8_T *ptr_event_name, - NPS_SEMAPHORE_ID_T *ptr_event_id); - -NPS_ERROR_NO_T -osal_waitEvent( - NPS_SEMAPHORE_ID_T *ptr_event_id); - -NPS_ERROR_NO_T -osal_triggerEvent( - NPS_SEMAPHORE_ID_T *ptr_event_id); - -NPS_ERROR_NO_T -osal_destroyEvent( - NPS_SEMAPHORE_ID_T *ptr_event_id); - -/* isr_lock */ -NPS_ERROR_NO_T -osal_createIsrLock( - const C8_T *ptr_isrlock_name, - NPS_ISRLOCK_ID_T *ptr_isrlock_id); - -NPS_ERROR_NO_T -osal_takeIsrLock( - NPS_ISRLOCK_ID_T *ptr_isrlock_id, - NPS_IRQ_FLAGS_T *ptr_irq_flags); - -NPS_ERROR_NO_T -osal_giveIsrLock( - NPS_ISRLOCK_ID_T *ptr_isrlock_id, - NPS_IRQ_FLAGS_T *ptr_irq_flags); - -NPS_ERROR_NO_T -osal_destroyIsrLock( - NPS_ISRLOCK_ID_T *ptr_isrlock_id); - -/* timer */ -NPS_ERROR_NO_T -osal_sleepThread( - const UI32_T usecond); - -NPS_ERROR_NO_T -osal_getTime( - NPS_TIME_T *ptr_time); - -/* queue */ -NPS_ERROR_NO_T -osal_que_create( - NPS_HUGE_T *ptr_queue_id, - UI32_T capacity); - -NPS_ERROR_NO_T -osal_que_enque( - NPS_HUGE_T *ptr_queue_id, - void *ptr_data); - -NPS_ERROR_NO_T -osal_que_deque( - NPS_HUGE_T *ptr_queue_id, - void **pptr_data); - -NPS_ERROR_NO_T -osal_que_destroy( - NPS_HUGE_T *ptr_queue_id); - -NPS_ERROR_NO_T -osal_que_getCount( - NPS_HUGE_T *ptr_queue_id, - unsigned int *ptr_count); - -/* IO */ -int -osal_io_copyToUser( - void *ptr_usr_buf, - void *ptr_knl_buf, - unsigned int size); - -int -osal_io_copyFromUser( - void *ptr_knl_buf, - void *ptr_usr_buf, - unsigned int size); - -/* dma */ -void * -osal_dma_alloc( - const UI32_T size); - -NPS_ERROR_NO_T -osal_dma_free( - void *ptr_dma_mem); - -dma_addr_t -osal_dma_convertVirtToPhy( - void *ptr_virt_addr); - -void * -osal_dma_convertPhyToVirt( - const dma_addr_t phy_addr); - -int -osal_dma_flushCache( - void *ptr_virt_addr, - const unsigned int size); - -int -osal_dma_invalidateCache( - void *ptr_virt_addr, - const unsigned int size); - -/* skb */ -struct sk_buff * -osal_skb_alloc( - UI32_T size); - -void -osal_skb_free( - struct sk_buff *ptr_skb); - -dma_addr_t -osal_skb_mapDma( - struct sk_buff *ptr_skb, - enum dma_data_direction dir); - -void -osal_skb_unmapDma( - const dma_addr_t phy_addr, - UI32_T size, - enum dma_data_direction dir); - -void -osal_skb_send( - struct sk_buff *ptr_skb); - -void -osal_skb_recv( - struct sk_buff *ptr_skb); - -#endif /* end of NETIF_OSAL_H */ diff --git a/platform/nephos/nephos-modules/modules/src/inc/netif_perf.h b/platform/nephos/nephos-modules/modules/src/inc/netif_perf.h deleted file mode 100755 index 5309f01b62d..00000000000 --- a/platform/nephos/nephos-modules/modules/src/inc/netif_perf.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: netif_perf.h - * PURPOSE: - * It provide customer performance test API. - * NOTES: - */ - -#ifndef NETIF_PERF_H -#define NETIF_PERF_H - -/* #define PERF_EN_TEST */ - -/* FUNCTION NAME: perf_rxCallback - * PURPOSE: - * To count the Rx-gpd for Rx-test. - * INPUT: - * len -- To check if the Rx-gpd length equals to test length. - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successful operation. - * NOTES: - * None - */ -NPS_ERROR_NO_T -perf_rxCallback( - const UI32_T len); - -/* FUNCTION NAME: perf_rxTest - * PURPOSE: - * To check if Rx-test is going. - * INPUT: - * None - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successful operation. - * NOTES: - * None - */ -NPS_ERROR_NO_T -perf_rxTest( - void); - -/* FUNCTION NAME: perf_test - * PURPOSE: - * To do Tx-test or Rx-test. - * INPUT: - * len -- Test length - * tx_channel -- Test Tx channel numbers - * rx_channel -- Test Rx channel numbers - * test_skb -- Test GPD or SKB - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successful operation. - * NOTES: - * None - */ -NPS_ERROR_NO_T -perf_test( - UI32_T len, - UI32_T tx_channel, - UI32_T rx_channel, - BOOL_T test_skb); - -#endif /* end of NETIF_PERF_H */ diff --git a/platform/nephos/nephos-modules/modules/src/inc/nps_cfg.h b/platform/nephos/nephos-modules/modules/src/inc/nps_cfg.h deleted file mode 100755 index 36de3cc7086..00000000000 --- a/platform/nephos/nephos-modules/modules/src/inc/nps_cfg.h +++ /dev/null @@ -1,317 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: nps_cfg.h - * PURPOSE: - * Customer configuration on NPS SDK. - * NOTES: - */ - -#ifndef NPS_CFG_H -#define NPS_CFG_H - -/* INCLUDE FILE DECLARATIONS - */ - -#include -#include - - -/* NAMING CONSTANT DECLARATIONS - */ - -/* MACRO FUNCTION DECLARATIONS - */ -#define NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM (16) -#define NPS_CFG_USER_PORT_NUM (96) - -/* DATA TYPE DECLARATIONS - */ -typedef enum -{ - NPS_CFG_TYPE_CHIP_MODE, /* chip operating mode. 0: legacy mode, 1:hybrid mode */ - - NPS_CFG_TYPE_PORT_MAX_SPEED, /* Reference to NPS_PORT_SPEED_XXX */ - NPS_CFG_TYPE_PORT_LANE_NUM, - NPS_CFG_TYPE_PORT_TX_LANE, - NPS_CFG_TYPE_PORT_RX_LANE, - NPS_CFG_TYPE_PORT_TX_POLARITY_REV, - NPS_CFG_TYPE_PORT_RX_POLARITY_REV, - NPS_CFG_TYPE_PORT_EXT_LANE, - NPS_CFG_TYPE_PORT_VALID, - - /* l2 module related configuration */ - NPS_CFG_TYPE_L2_THREAD_PRI, - NPS_CFG_TYPE_L2_THREAD_STACK, /* customize L2 thread stack size in bytes */ - NPS_CFG_TYPE_L2_ADDR_MODE, /* L2 address operation mode. 0: Polling mode, 1: FIFO mode */ - - /* PKT module related configuration */ - NPS_CFG_TYPE_PKT_TX_GPD_NUM, - NPS_CFG_TYPE_PKT_RX_GPD_NUM, - NPS_CFG_TYPE_PKT_RX_SCHED_MODE, /* 0: RR mode, 1: WRR mode */ - NPS_CFG_TYPE_PKT_TX_QUEUE_LEN, - NPS_CFG_TYPE_PKT_RX_QUEUE_LEN, - NPS_CFG_TYPE_PKT_RX_QUEUE_WEIGHT, /* valid while NPS_CFG_TYPE_PKT_RX_SCHED_MODE is 1 - * param0: queue - * param1: NA - * value : weight - */ - NPS_CFG_TYPE_PKT_RX_ISR_THREAD_PRI, - NPS_CFG_TYPE_PKT_RX_ISR_THREAD_STACK, /* customize PKT RX ISR thread stack size in bytes */ - NPS_CFG_TYPE_PKT_RX_FREE_THREAD_PRI, - NPS_CFG_TYPE_PKT_RX_FREE_THREAD_STACK, /* customize PKT RX free thread stack size in bytes */ - NPS_CFG_TYPE_PKT_TX_ISR_THREAD_PRI, - NPS_CFG_TYPE_PKT_TX_ISR_THREAD_STACK, /* customize PKT TX ISR thread stack size in bytes */ - NPS_CFG_TYPE_PKT_TX_FREE_THREAD_PRI, - NPS_CFG_TYPE_PKT_TX_FREE_THREAD_STACK, /* customize PKT TX free thread stack size in bytes */ - NPS_CFG_TYPE_PKT_ERROR_ISR_THREAD_PRI, - NPS_CFG_TYPE_PKT_ERROR_ISR_THREAD_STACK, /* customize PKT ERROR ISR thread stack size in bytes */ - - /* STAT module related configuration */ - NPS_CFG_TYPE_CNT_THREAD_PRI, - NPS_CFG_TYPE_CNT_THREAD_STACK, /* customize CNT thread stack size in bytes */ - - /* IFMON module related configuration */ - NPS_CFG_TYPE_IFMON_THREAD_PRI, - NPS_CFG_TYPE_IFMON_THREAD_STACK, /* customize IFMON thread stack size in bytes */ - - /* share memory related configuration */ - NPS_CFG_TYPE_SHARE_MEM_SDN_ENTRY_NUM, /* SDN flow table entry number from share memory */ - NPS_CFG_TYPE_SHARE_MEM_L3_ENTRY_NUM, /* L3 entry number from share memory */ - NPS_CFG_TYPE_SHARE_MEM_L2_ENTRY_NUM, /* L2 entry number from share memory */ - - /* DLB related configuration */ - NPS_CFG_TYPE_DLB_MONITOR_MODE, /* DLB monitor mode. 1: async, 0: sync */ - NPS_CFG_TYPE_DLB_LAG_MONITOR_THREAD_PRI, - NPS_CFG_TYPE_DLB_LAG_MONITOR_THREAD_SLEEP_TIME, - NPS_CFG_TYPE_DLB_L3_MONITOR_THREAD_PRI, - NPS_CFG_TYPE_DLB_L3_MONITOR_THREAD_SLEEP_TIME, - NPS_CFG_TYPE_DLB_L3_INTR_THREAD_PRI, - NPS_CFG_TYPE_DLB_NVO3_MONITOR_THREAD_PRI, - NPS_CFG_TYPE_DLB_NVO3_MONITOR_THREAD_SLEEP_TIME, - NPS_CFG_TYPE_DLB_NVO3_INTR_THREAD_PRI, - - /* l3 related configuration */ - NPS_CFG_TYPE_L3_ECMP_MIN_BLOCK_SIZE, - NPS_CFG_TYPE_L3_ECMP_BLOCK_SIZE, - NPS_CFG_TYPE_TCAM_L3_WITH_IPV6_PREFIX_128_REGION_ENTRY_NUM, - NPS_CFG_TYPE_TCAM_L3_WITH_IPV6_PREFIX_64_REGION_ENTRY_NUM, - - /* share memory related configuration */ - NPS_CFG_TYPE_HASH_L2_FDB_REGION_ENTRY_NUM, - NPS_CFG_TYPE_HASH_L2_GROUP_REGION_ENTRY_NUM, - NPS_CFG_TYPE_HASH_SECURITY_REGION_ENTRY_NUM, - NPS_CFG_TYPE_HASH_L3_WITH_IPV6_PREFIX_128_REGION_ENTRY_NUM, - NPS_CFG_TYPE_HASH_L3_WITH_IPV6_PREFIX_64_REGION_ENTRY_NUM, - NPS_CFG_TYPE_HASH_L3_WITHOUT_PREFIX_REGION_ENTRY_NUM, - NPS_CFG_TYPE_HASH_L3_RPF_REGION_ENTRY_NUM, - NPS_CFG_TYPE_HASH_FLOW_REGION_ENTRY_NUM, - - NPS_CFG_TYPE_PORT_FC_MODE, /* only use to init port TM buffer - * configuration for specific FC mode, - * which not enable/disable FC/PFC - * for the port/pcp. - * param0: port. - * param1: Invalid. - * value : 0, FC disable; - * 1, 802.3x FC; - * 2, PFC. - */ - NPS_CFG_TYPE_PORT_PFC_STATE, /* valid while NPS_CFG_TYPE_PORT_TYPE_FC_MODE - * of the port is PFC. - * param0: port. - * param1: pcp. - * value : 0, PFC disable; - * 1, PFC enable. - */ - NPS_CFG_TYPE_PORT_PFC_QUEUE_STATE, /* valid while NPS_CFG_TYPE_PORT_TYPE_FC_MODE - * of the port is PFC. - * param0: port. - * param1: queue. - * value : 0, PFC disable; - * 1, PFC enable; - */ - NPS_CFG_TYPE_PORT_PFC_MAPPING, /* valid while NPS_CFG_TYPE_PORT_FC_MODE - * of the port is PFC. - * param0: port. - * param1: queue. - * value : PCP bitmap; - * - */ - NPS_CFG_TYPE_TRILL_ENABLE, /* TRILL module related configuration */ - NPS_CFG_TYPE_USE_UNIT_PORT, /* use UNIT_PORT or native port of NPS_PORT_T - * 1 : UNIT_PORT, 0 : native port - */ - NPS_CFG_TYPE_MAC_VLAN_ENABLE, /* use dadicate mac vlan table */ - NPS_CFG_TYPE_CPI_PORT_MODE, /* use to init CPI port working mode. - * param0: CPI port number. - * param1: NA. - * value : 0, CPI mode. - * 1, Ether mode. - */ - NPS_CFG_TYPE_PHY_ADDR, - NPS_CFG_TYPE_LED_CFG, - NPS_CFG_TYPE_USER_BUF_CTRL, - NPS_CFG_TYPE_ARIES_SDP_MODE, /* Select which Aries parser to use - * value: 0, GTP (default) - * 1, PPPOE - * 2, TCP_SPLICING - */ - NPS_CFG_TYPE_FAIR_BUF_CTRL, /* to enable the fairness in flow-control traffic. - * value : 0, disable fairness. - * 1, enable fairness. - */ - NPS_CFG_TYPE_HRM_BUF_SIZE, /* to assign the head room size of port speed. - * param0: Port speed. - * 0, 1G (default) - * 1, 10G - * 2, 25G - * 3, 40G - * 4, 50G - * 5, 100G - * value : cell number. - */ - NPS_CFG_TYPE_STEERING_TRUNCATE_ENABLE, /* set value 0: Do not truncate steering packets. - * set value 1: steering packets will be trucated to 1 cell and - * the cell size is based on chip. - */ - NPS_CFG_TYPE_FABRIC_MODE_ENABLE, /* set value 0: Non-farbic chip mode. (default) - * set value 1: Fabric chip mode. - */ - NPS_CFG_TYPE_ACL_TCP_FLAGS_ENCODE_ENABLE, /* set value 0: Do not encode tcp flags at acl entry. - * (Can only match bit 0-6 of tcp flags.) - * set value 1: Encode tcp flags at acl entry. (default) - */ - NPS_CFG_TYPE_TCAM_ECC_SCAN_ENABLE, /* set value 0: Disable ECC TCAM scanning. (default) - * set value 1: Enable ECC TCAM scanning. - */ - NPS_CFG_TYPE_PORT_BUF_MAX, /* - * Port max buffer threshold and unit is cell count. - * param0: port. - * param1: 0, ingress; - * 1, egress. - * value : 0, disable; - * others, enable max threshold. - */ - NPS_CFG_TYPE_INGRESS_DYNAMIC_BUF, /* - * Queue dynamic alpha setting and value will be - * enlarge to multiple of 256. For example, set value - * as 16 to indicate alpha as 1/16. Set value - * as 256 to indicate alpha as 1. - * param0: port. - * param1: queue (0~7: sc). - * value : alpha * 256. - */ - NPS_CFG_TYPE_EGRESS_DYNAMIC_BUF, /* - * Queue dynamic alpha setting and value will be - * enlarge to multiple of 256. For example, set value - * as 16 to indicate alpha as 1/16. Set value - * as 256 to indicate alpha as 1. - * param0: port. - * param1: queue (0~7: uc, 8~15: mc). - * value : alpha * 256. - */ - - - NPS_CFG_TYPE_DCQCN_ENABLE, /* set value 0: Disable DCQCN. (default) - * set value 1: Enable DCQCN. - */ - - - NPS_CFG_TYPE_LAST - -}NPS_CFG_TYPE_T; - -typedef struct NPS_CFG_VALUE_S -{ - UI32_T param0; /*(Optional) The optional parameter which is available - * when the NPS_CFG_TYPE_T needs the first arguments*/ - UI32_T param1; /*(Optional) The optional parameter which is available - * when the NPS_CFG_TYPE_T needs the second arguments*/ - I32_T value; - -}NPS_CFG_VALUE_T; - -typedef NPS_ERROR_NO_T - (*NPS_CFG_GET_FUNC_T)( - const UI32_T unit, - const NPS_CFG_TYPE_T cfg_type, - NPS_CFG_VALUE_T *ptr_cfg_value); - -typedef NPS_ERROR_NO_T - (*NPS_CFG_GET_LED_FUNC_T) -( - const UI32_T unit, - UI32_T **pptr_led_cfg, - UI32_T *ptr_cfg_size); - -/* EXPORTED SUBPROGRAM SPECIFICATIONS - */ - -/* FUNCTION NAME: nps_cfg_register - * PURPOSE: - * The function is to register NPS_CFG_GET_FUNC to SDK. - * - * INPUT: - * unit -- Device unit number. - * ptr_cfg_callback -- function to get the configuration value. - * - * OUTPUT: - * None - * - * RETURN: - * NPS_E_OK -- Operate success. - * NPS_E_BAD_PARAMETER -- Bad parameter. - * - * NOTES: - * 1. During SDK initializtion, it will call registered NPS_CFG_GET_FUNC to get configuration - * and apply them. - * If No registered NPS_CFG_GET_FUNC or can not get specified NPS_CFG_TYPE_T - * configuration, SDK will apply default setting. - * 2. This function should be called before calling nps_init - */ -NPS_ERROR_NO_T -nps_cfg_register( - const UI32_T unit, - NPS_CFG_GET_FUNC_T ptr_cfg_callback); - -/* FUNCTION NAME: nps_cfg_led_register - * PURPOSE: - * The function is to register NPS_CFG_GET_FUNC to SDK. - * - * INPUT: - * unit -- Device unit number. - * ptr_led_cfg_callback -- function to get LED configuration array. - * - * OUTPUT: - * None - * - * RETURN: - * NPS_E_OK -- Operate success. - * NPS_E_BAD_PARAMETER -- Bad parameter. - * - * NOTES: - * 1. During SDK initializtion, it will call registered NPS_CFG_GET_FUNC to get configuration - * and apply them. - * If No registered NPS_CFG_GET_LED_FUNC or can not get specified external LED cfg - * configuration, SDK will apply default setting. - * 2. This function should be called before calling nps_init - */ -NPS_ERROR_NO_T -nps_cfg_led_register( - const UI32_T unit, - NPS_CFG_GET_LED_FUNC_T ptr_led_cfg_callback); - -#endif /* NPS_CFG_H */ diff --git a/platform/nephos/nephos-modules/modules/src/inc/nps_error.h b/platform/nephos/nephos-modules/modules/src/inc/nps_error.h deleted file mode 100755 index 3cf0a14adc0..00000000000 --- a/platform/nephos/nephos-modules/modules/src/inc/nps_error.h +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: nps_error.h - * PURPOSE: - * Define the generic error code on NPS SDK. - * NOTES: - */ - -#ifndef NPS_ERROR_H -#define NPS_ERROR_H - -/* INCLUDE FILE DECLARATIONS - */ -#include - - -/* NAMING CONSTANT DECLARATIONS - */ - -/* MACRO FUNCTION DECLARATIONS - */ - -/* DATA TYPE DECLARATIONS - */ - -typedef enum -{ - NPS_E_OK = 0, /* Ok and no error */ - NPS_E_BAD_PARAMETER, /* Parameter is wrong */ - NPS_E_NO_MEMORY, /* No memory is available */ - NPS_E_TABLE_FULL, /* Table is full */ - NPS_E_ENTRY_NOT_FOUND, /* Entry is not found */ - NPS_E_ENTRY_EXISTS, /* Entry already exists */ - NPS_E_NOT_SUPPORT, /* Feature is not supported */ - NPS_E_ALREADY_INITED, /* Module is reinitialized */ - NPS_E_NOT_INITED, /* Module is not initialized */ - NPS_E_OTHERS, /* Other errors */ - NPS_E_ENTRY_IN_USE, /* Entry is in use */ - NPS_E_LAST -} NPS_ERROR_NO_T; - -/* EXPORTED SUBPROGRAM SPECIFICATIONS - */ -/* FUNCTION NAME: nps_error_getString - * PURPOSE: - * To obtain the error string of the specified error code - * - * INPUT: - * cause -- The specified error code - * OUTPUT: - * None - * RETURN: - * Pointer to the target error string - * - * NOTES: - * - * - */ -C8_T * -nps_error_getString( - const NPS_ERROR_NO_T cause ); - -#endif /* NPS_ERROR_H */ - diff --git a/platform/nephos/nephos-modules/modules/src/inc/nps_types.h b/platform/nephos/nephos-modules/modules/src/inc/nps_types.h deleted file mode 100755 index 88100f69738..00000000000 --- a/platform/nephos/nephos-modules/modules/src/inc/nps_types.h +++ /dev/null @@ -1,308 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: nps_types.h - * PURPOSE: - * Define the commom data type in NPS SDK. - * NOTES: - */ - -#ifndef NPS_TYPES_H -#define NPS_TYPES_H - -/* INCLUDE FILE DECLARATIONS - */ - -#include - -/* NAMING CONSTANT DECLARATIONS - */ - -#define NPS_BIT_OFF 0 -#define NPS_BIT_ON 1 - -#define NPS_PORT_INVALID (0xFFFFFFFF) -#define NPS_SEG_INVALID (0xFFFFFFFF) - -/* for CPU Rx packet, indicate that the packet - * is not received from remote switch - */ -#define NPS_PATH_INVALID (0xFFFFFFFF) - - -#define NPS_SEMAPHORE_BINARY (1) -#define NPS_SEMAPHORE_SYNC (0) -#define NPS_SEMAPHORE_WAIT_FOREVER (0xFFFFFFFF) - -/* MACRO FUNCTION DECLARATIONS - */ -#if defined(NPS_EN_HOST_32_BIT_BIG_ENDIAN) || defined(NPS_EN_HOST_32_BIT_LITTLE_ENDIAN) -typedef unsigned int NPS_HUGE_T; -#elif defined(NPS_EN_HOST_64_BIT_BIG_ENDIAN) || defined(NPS_EN_HOST_64_BIT_LITTLE_ENDIAN) -typedef unsigned long long int NPS_HUGE_T; -#else -#error "The 32bit and 64bit compatible data type are not defined !!" -#endif - -#if defined(NPS_EN_64BIT_ADDR) -typedef unsigned long long int NPS_ADDR_T; -#else -typedef NPS_HUGE_T NPS_ADDR_T; -#endif - -#if defined(NPS_EN_HOST_64_BIT_BIG_ENDIAN) || defined(NPS_EN_HOST_64_BIT_LITTLE_ENDIAN) || defined(NPS_EN_64BIT_ADDR) -#define NPS_ADDR_64_HI(__addr__) ((__addr__) >> 32) -#define NPS_ADDR_64_LOW(__addr__) ((__addr__) & 0xFFFFFFFF) -#define NPS_ADDR_32_TO_64(__hi32__,__low32__) (((unsigned long long int)(__low32__)) | \ - (((unsigned long long int)(__hi32__)) << 32)) -#else -#define NPS_ADDR_64_HI(__addr__) (0) -#define NPS_ADDR_64_LOW(__addr__) (__addr__) -#define NPS_ADDR_32_TO_64(__hi32__,__low32__) (__low32__) -#endif - -#define NPS_BITMAP_SIZE(bit_num) ((((bit_num) - 1) / 32) + 1) -#define NPS_IPV4_IS_MULTICAST(addr) (0xE0000000 == ((addr) & 0xF0000000)) -#define NPS_IPV6_IS_MULTICAST(addr) (0xFF == (((UI8_T *)(addr))[0])) -#define NPS_MAC_IS_MULTICAST(mac) ((mac[0]) & (0x1)) - -/* DATA TYPE DECLARATIONS - */ -typedef UI8_T NPS_BIT_MASK_8_T; -typedef UI16_T NPS_BIT_MASK_16_T; -typedef UI32_T NPS_BIT_MASK_32_T; -typedef UI64_T NPS_BIT_MASK_64_T; - -typedef UI8_T NPS_MAC_T[6]; -typedef UI32_T NPS_IPV4_T; -typedef UI8_T NPS_IPV6_T[16]; - -typedef UI32_T NPS_TIME_T; - -/* Bridge Domain id data type. */ -typedef UI32_T NPS_BRIDGE_DOMAIN_T; - -/* TRILL nickname type. */ -typedef UI16_T NPS_TRILL_NICKNAME_T; - -typedef union NPS_IP_U -{ - - NPS_IPV4_T ipv4_addr; - NPS_IPV6_T ipv6_addr; - -}NPS_IP_T; - -typedef struct NPS_IP_ADDR_S -{ - NPS_IP_T ip_addr; - BOOL_T ipv4 ; -}NPS_IP_ADDR_T; - -/* Tunnel type*/ -typedef enum -{ - NPS_TUNNEL_TYPE_IPV4INIPV4 = 0, /* RFC2003, IPv4-in-IPv4 tunnel */ - NPS_TUNNEL_TYPE_IPV4INIPV6, /* RFC2003, IPv4-in-IPv6 tunnel */ - NPS_TUNNEL_TYPE_IPV6INIPV4, /* RFC2003, IPv6-in-IPv4 tunnel */ - NPS_TUNNEL_TYPE_IPV6INIPV6, /* RFC2003, IPv6-in-IPv6 tunnel */ - NPS_TUNNEL_TYPE_GREIPV4INIPV4, /* RFC2784/RFC2890,GRE IPv4-in-IPv4 tunnel */ - NPS_TUNNEL_TYPE_GREIPV6INIPV4, /* RFC2784/RFC2890,GRE IPv6-in-IPv4 tunnel */ - NPS_TUNNEL_TYPE_GREIPV4INIPV6, /* RFC2784/RFC2890,GRE IPv4-in-IPv6 tunnel */ - NPS_TUNNEL_TYPE_GREIPV6INIPV6, /* RFC2784/RFC2890,GRE IPv6-in-IPv6 tunnel */ - NPS_TUNNEL_TYPE_GRE_NSH, - NPS_TUNNEL_TYPE_6TO4, /* RFC3056, 6to4 tunnel*/ - NPS_TUNNEL_TYPE_ISATAP, /* RFC5214, ISATAP tunnel */ - NPS_TUNNEL_TYPE_NVGRE_L2, - NPS_TUNNEL_TYPE_NVGRE_V4, - NPS_TUNNEL_TYPE_NVGRE_V6, - NPS_TUNNEL_TYPE_NVGRE_NSH, - NPS_TUNNEL_TYPE_VXLAN, - NPS_TUNNEL_TYPE_GTP_V4, - NPS_TUNNEL_TYPE_GTP_V6, - NPS_TUNNEL_TYPE_MPLSINGRE, - NPS_TUNNEL_TYPE_VXLANGPE_L2, - NPS_TUNNEL_TYPE_VXLANGPE_V4, - NPS_TUNNEL_TYPE_VXLANGPE_V6, - NPS_TUNNEL_TYPE_VXLANGPE_NSH, - NPS_TUNNEL_TYPE_FLEX0_L2, - NPS_TUNNEL_TYPE_FLEX0_V4, - NPS_TUNNEL_TYPE_FLEX0_V6, - NPS_TUNNEL_TYPE_FLEX0_NSH, - NPS_TUNNEL_TYPE_FLEX1_L2, - NPS_TUNNEL_TYPE_FLEX1_V4, - NPS_TUNNEL_TYPE_FLEX1_V6, - NPS_TUNNEL_TYPE_FLEX1_NSH, - NPS_TUNNEL_TYPE_FLEX2_L2, - NPS_TUNNEL_TYPE_FLEX2_V4, - NPS_TUNNEL_TYPE_FLEX2_V6, - NPS_TUNNEL_TYPE_FLEX2_NSH, - NPS_TUNNEL_TYPE_FLEX3_L2, - NPS_TUNNEL_TYPE_FLEX3_V4, - NPS_TUNNEL_TYPE_FLEX3_V6, - NPS_TUNNEL_TYPE_FLEX3_NSH, - NPS_TUNNEL_TYPE_LAST -} NPS_TUNNEL_TYPE_T; - -/* tunnel key */ -typedef struct NPS_TUNNEL_KEY_S -{ - NPS_IP_ADDR_T src_ip; /* key: The outer source IP address used by tunnel encapsulation.*/ - NPS_IP_ADDR_T dst_ip; /* key: The outer destination IP address used by tunnel encapsulation. - * For automatic tunnel, this is not required. If not specified, - * its ip address value must be set to 0, but the IP version - * must be same with src_ip. - */ - NPS_TUNNEL_TYPE_T tunnel_type; /*key: The tunnel type.*/ -}NPS_TUNNEL_KEY_T; - -typedef UI16_T NPS_VLAN_T; -typedef UI32_T NPS_PORT_T; - -typedef enum{ - NPS_PORT_TYPE_NORMAL = 0, - NPS_PORT_TYPE_UNIT_PORT, - NPS_PORT_TYPE_LAG, - NPS_PORT_TYPE_VM_ETAG, - NPS_PORT_TYPE_VM_VNTAG, - NPS_PORT_TYPE_VM_VEPA, - NPS_PORT_TYPE_FCOE, - NPS_PORT_TYPE_IP_TUNNEL, - NPS_PORT_TYPE_TRILL, - NPS_PORT_TYPE_MPLS, - NPS_PORT_TYPE_MPLS_PW, - NPS_PORT_TYPE_CPU_PORT, - NPS_PORT_TYPE_SFC, - NPS_PORT_TYPE_LAST -}NPS_PORT_TYPE_T; - -/*support Green/Yellow/Red color*/ -typedef enum -{ - NPS_COLOR_GREEN = 0, - NPS_COLOR_YELLOW, - NPS_COLOR_RED, - NPS_COLOR_LAST -}NPS_COLOR_T; -typedef enum -{ - NPS_FWD_ACTION_FLOOD = 0, - NPS_FWD_ACTION_NORMAL, - NPS_FWD_ACTION_DROP, - NPS_FWD_ACTION_COPY_TO_CPU, - NPS_FWD_ACTION_REDIRECT_TO_CPU, - NPS_FWD_ACTION_FLOOD_COPY_TO_CPU, - NPS_FWD_ACTION_DROP_COPY_TO_CPU, - NPS_FWD_ACTION_LAST -} NPS_FWD_ACTION_T; - -typedef NPS_HUGE_T NPS_THREAD_ID_T; -typedef NPS_HUGE_T NPS_SEMAPHORE_ID_T; -typedef NPS_HUGE_T NPS_ISRLOCK_ID_T; -typedef NPS_HUGE_T NPS_IRQ_FLAGS_T; - -typedef enum -{ - NPS_DIR_INGRESS = 0, - NPS_DIR_EGRESS, - NPS_DIR_BOTH, - NPS_DIR_LAST -}NPS_DIR_T; - -typedef enum -{ - NPS_VLAN_ACTION_SET, - NPS_VLAN_ACTION_KEEP, - NPS_VLAN_ACTION_REMOVE, - NPS_VLAN_ACTION_LAST -} NPS_VLAN_ACTION_T; - -/* VLAN Precedence */ -/* 000 = SUBNET_PROTOCOL_MAC_PORT - * 001 = SUBNET_MAC_PROTOCOL_PORT - * 010 = PROTOCOL_SUBNET_MAC_PORT - * 011 = PROTOCOL_MAC_SUBNET_PORT - * 100 = MAC_SUBNET_PROTOCOL_PORT - * 101 = MAC_PROTOCOL_SUBNET_PORT - */ -typedef enum -{ - NPS_VLAN_PRECEDENCE_SUBNET_MAC_PROTOCOL_PORT = 1, - NPS_VLAN_PRECEDENCE_MAC_SUBNET_PROTOCOL_PORT = 4, - NPS_VLAN_PRECEDENCE_PORT_ONLY = 7, - NPS_VLAN_PRECEDENCE_FAVOR_TYPE = 8, - NPS_VLAN_PRECEDENCE_FAVOR_ADDR = 9, - NPS_VLAN_PRECEDENCE_LAST -} NPS_VLAN_PRECEDENCE_T; - -/* VLAN Tag Type */ -typedef enum -{ - NPS_VLAN_TAG_NONE = 0, /* UnTag */ - NPS_VLAN_TAG_SINGLE_PRI, /* Single Customer/Service Priority Tag */ - NPS_VLAN_TAG_SINGLE, /* Single Customer/Service Tag */ - NPS_VLAN_TAG_DOUBLE_PRI, /* Double Tag with any VID=0 */ - NPS_VLAN_TAG_DOUBLE, /* Double Tag */ - NPS_VLAN_TAG_LAST -} NPS_VLAN_TAG_T; - -typedef struct NPS_BUM_INFO_S -{ - UI32_T mcast_id; - UI32_T group_label; /* l2 da group label */ - UI32_T vid; /* used when FLAGS_ADD_VID is set */ - -#define NPS_BUM_INFO_FLAGS_MCAST_VALID (1 << 0) -#define NPS_BUM_INFO_FLAGS_TO_CPU (1 << 1) -#define NPS_BUM_INFO_FLAGS_ADD_VID (1 << 2) /* single tag to double tag (i.e) QinQ */ -#define NPS_BUM_INFO_FLAGS_TRILL_ALL_TREE (1 << 3) - UI32_T flags; -} NPS_BUM_INFO_T; - -typedef enum -{ - NPS_PHY_TYPE_INTERNAL = 0x0, - NPS_PHY_TYPE_EXTERNAL, - NPS_PHY_TYPE_LAST -} NPS_PHY_TYPE_T; - -typedef enum -{ - NPS_PHY_DEVICE_ADDR_PMA_PMD = 1, - NPS_PHY_DEVICE_ADDR_WIS = 2, - NPS_PHY_DEVICE_ADDR_PCS = 3, - NPS_PHY_DEVICE_ADDR_PHY_XS = 4, - NPS_PHY_DEVICE_ADDR_DTE_XS = 5, - NPS_PHY_DEVICE_ADDR_TC = 6, - NPS_PHY_DEVICE_ADDR_AN = 7, - NPS_PHY_DEVICE_ADDR_VENDOR_1 = 30, - NPS_PHY_DEVICE_ADDR_VENDOR_2 = 31, - NPS_PHY_DEVICE_ADDR_LAST -} NPS_PHY_DEVICE_ADDR_T; - -typedef struct NPS_RANGE_INFO_S -{ - UI32_T min_id; - UI32_T max_id; - UI32_T max_member_cnt; - -#define NPS_RANGE_INFO_FLAGS_MAX_MEMBER_CNT (1 << 0) - UI32_T flags; -} NPS_RANGE_INFO_T; - -/* EXPORTED SUBPROGRAM SPECIFICATIONS - */ - -#endif /* NPS_TYPES_H */ diff --git a/platform/nephos/nephos-modules/modules/src/inc/osal_mdc.h b/platform/nephos/nephos-modules/modules/src/inc/osal_mdc.h deleted file mode 100755 index 0add2c8216b..00000000000 --- a/platform/nephos/nephos-modules/modules/src/inc/osal_mdc.h +++ /dev/null @@ -1,251 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: osal_mdc.h - * PURPOSE: - * 1. Provide device operate from AML interface - * NOTES: - * - */ - -#ifndef OSAL_MDC_H -#define OSAL_MDC_H - -/* INCLUDE FILE DECLARATIONS */ -#include -#include - -#define OSAL_MDC_DRIVER_NAME "nps_dev" -#define OSAL_MDC_DRIVER_MISC_MAJOR_NUM (10) -#define OSAL_MDC_DRIVER_MISC_MINOR_NUM (250) -#define OSAL_MDC_PCI_BUS_WIDTH (4) - -#define OSAL_MDC_DMA_LIST_SZ_UNLIMITED (0) -#define OSAL_MDC_DMA_LIST_NAME "RSRV_DMA" -#define OSAL_MDC_DMA_SEMAPHORE_NAME "DMALIST" - -/* NAMING CONSTANT DECLARATIONS - */ - -/* linked list node */ -#if defined(NPS_LINUX_KERNEL_MODE) - -typedef struct OSAL_MDC_LIST_NODE_S -{ - void *ptr_data; /* node data */ - struct OSAL_MDC_LIST_NODE_S *ptr_next; /* point to next link node */ - struct OSAL_MDC_LIST_NODE_S *ptr_prev; /* point to previous link node */ -} OSAL_MDC_LIST_NODE_T; - -/* linked list head */ -typedef struct OSAL_MDC_LIST_S -{ - OSAL_MDC_LIST_NODE_T *ptr_head_node; /* linked list head node */ - OSAL_MDC_LIST_NODE_T *ptr_tail_node; /* linked list tail node */ - UI32_T capacity; /* max count of nodes in list - * size=0: the capacity is unlimited. - * size>0: the capacity is limited. - */ - UI32_T node_cnt; /* the count of nodes in the list */ -} OSAL_MDC_LIST_T; - -#endif /* End of defined(NPS_LINUX_KERNEL_MODE) */ - -typedef struct -{ - NPS_ADDR_T phy_addr; - void *ptr_virt_addr; - NPS_ADDR_T size; - -#if defined(NPS_EN_DMA_RESERVED) - BOOL_T available; -#endif - -} OSAL_MDC_DMA_NODE_T; - -typedef struct -{ -#if defined(NPS_EN_DMA_RESERVED) - void *ptr_rsrv_virt_addr; - NPS_ADDR_T rsrv_phy_addr; - NPS_ADDR_T rsrv_size; -#else - struct device *ptr_dma_dev; /* for allocate/free system memory */ -#endif - void *ptr_dma_list; /* the type should be casted again when use */ - NPS_SEMAPHORE_ID_T sema; - -} OSAL_MDC_DMA_INFO_T; - -#if defined(NPS_LINUX_USER_MODE) - -/* Data type of IOCTL argument for DMA management */ -typedef struct -{ -#if defined(NPS_EN_DMA_RESERVED) - NPS_ADDR_T rsrv_dma_phy_addr; /* information of reserved memory */ - NPS_ADDR_T rsrv_dma_size; -#else - NPS_ADDR_T phy_addr; /* information of system memory */ - NPS_ADDR_T size; -#endif -} OSAL_MDC_IOCTL_DMA_DATA_T; - -/* Data type of IOCTL argument for device initialization */ -#pragma pack (push,1) -typedef struct -{ - AML_DEV_ID_T id[NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM]; - NPS_ADDR_T pci_mmio_phy_start[NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM]; - NPS_ADDR_T pci_mmio_size[NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM]; - UI32_T dev_num; -} OSAL_MDC_IOCTL_DEV_DATA_T; -#pragma pack (pop) - -typedef enum -{ - OSAL_MDC_IOCTL_ACCESS_READ = 0, - OSAL_MDC_IOCTL_ACCESS_WRITE, - OSAL_MDC_IOCTL_ACCESS_READ_WRITE, - OSAL_MDC_IOCTL_ACCESS_NONE, - OSAL_MDC_IOCTL_ACCESS_LAST - -} OSAL_MDC_IOCTL_ACCESS_T; - -typedef enum -{ - OSAL_MDC_IOCTL_TYPE_MDC_INIT_DEV = 0, - OSAL_MDC_IOCTL_TYPE_MDC_DEINIT_DEV, - OSAL_MDC_IOCTL_TYPE_MDC_INIT_RSRV_DMA_MEM, - OSAL_MDC_IOCTL_TYPE_MDC_DEINIT_RSRV_DMA_MEM, - OSAL_MDC_IOCTL_TYPE_MDC_ALLOC_SYS_DMA_MEM, - OSAL_MDC_IOCTL_TYPE_MDC_FREE_SYS_DMA_MEM, - OSAL_MDC_IOCTL_TYPE_MDC_CONNECT_ISR, - OSAL_MDC_IOCTL_TYPE_MDC_DISCONNECT_ISR, - OSAL_MDC_IOCTL_TYPE_MDC_SAVE_PCI_CONFIG, - OSAL_MDC_IOCTL_TYPE_MDC_RESTORE_PCI_CONFIG, - OSAL_MDC_IOCTL_TYPE_LAST - -} OSAL_MDC_IOCTL_TYPE_T; - -typedef union -{ - UI32_T value; - struct - { - UI32_T access : 2; /* 0:read, 1:write, 2:read and write, 3:none */ - UI32_T unit : 6; /* Maximum unit number is 64. */ - UI32_T size :14; /* Maximum IOCTL data size is 16KB. */ - UI32_T type :10; /* Maximum 1024 IOCTL types */ - } field; -} OSAL_MDC_IOCTL_CMD_T; - -typedef NPS_ERROR_NO_T -(*OSAL_MDC_IOCTL_CALLBACK_FUNC_T)( - const UI32_T unit, - void *ptr_data); - -#endif /* End of NPS_LINUX_USER_MODE */ - - -/* MACRO FUNCTION DECLARATIONS - */ - -/* DATA TYPE DECLARATIONS - */ - -/* EXPORTED SUBPROGRAM SPECIFICATIONS - */ -NPS_ERROR_NO_T -osal_mdc_readPciReg( - const UI32_T unit, - const UI32_T offset, - UI32_T *ptr_data, - const UI32_T len); - -NPS_ERROR_NO_T -osal_mdc_writePciReg( - const UI32_T unit, - const UI32_T offset, - const UI32_T *ptr_data, - const UI32_T len); - -NPS_ERROR_NO_T -osal_mdc_initDevice( - AML_DEV_T *ptr_dev_list, - UI32_T *ptr_dev_num); - -NPS_ERROR_NO_T -osal_mdc_deinitDevice(void); - -NPS_ERROR_NO_T -osal_mdc_initDmaMem(void); - -NPS_ERROR_NO_T -osal_mdc_deinitDmaMem(void); - -void * -osal_mdc_allocDmaMem( - const UI32_T size); - -NPS_ERROR_NO_T -osal_mdc_freeDmaMem( - void *ptr_virt_addr); - -NPS_ERROR_NO_T -osal_mdc_convertVirtToPhy( - void *ptr_virt_addr, - NPS_ADDR_T *ptr_phy_addr); - -NPS_ERROR_NO_T -osal_mdc_convertPhyToVirt( - const NPS_ADDR_T phy_addr, - void **pptr_virt_addr); - -NPS_ERROR_NO_T -osal_mdc_registerIsr( - const UI32_T unit, - AML_DEV_ISR_FUNC_T handler, - void *ptr_cookie); - -NPS_ERROR_NO_T -osal_mdc_connectIsr( - const UI32_T unit, - AML_DEV_ISR_FUNC_T handler, - AML_DEV_ISR_DATA_T *ptr_cookie); - -NPS_ERROR_NO_T -osal_mdc_disconnectIsr( - const UI32_T unit); - -NPS_ERROR_NO_T -osal_mdc_flushCache( - void *ptr_virt_addr, - const UI32_T size); - -NPS_ERROR_NO_T -osal_mdc_invalidateCache( - void *ptr_virt_addr, - const UI32_T size); - -NPS_ERROR_NO_T -osal_mdc_savePciConfig( - const UI32_T unit); - -NPS_ERROR_NO_T -osal_mdc_restorePciConfig( - const UI32_T unit); - -#endif /* OSAL_MDC_H */ diff --git a/platform/nephos/nephos-modules/modules/src/inc/osal_types.h b/platform/nephos/nephos-modules/modules/src/inc/osal_types.h deleted file mode 100755 index 59fd3df1260..00000000000 --- a/platform/nephos/nephos-modules/modules/src/inc/osal_types.h +++ /dev/null @@ -1,319 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: osal_types.h - * PURPOSE: - * Define the commom data type in NPS SDK. - * NOTES: - */ - -#ifndef OSAL_TYPES_H -#define OSAL_TYPES_H - -/* INCLUDE FILE DECLARATIONS - */ - -/* NAMING CONSTANT DECLARATIONS - */ - - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef NULL -#define NULL (void *)0 -#endif - - -#if defined(NPS_EN_HOST_64_BIT_BIG_ENDIAN) -#define UI64_MSW 0 -#define UI64_LSW 1 -#elif defined(NPS_EN_HOST_64_BIT_LITTLE_ENDIAN) -#define UI64_MSW 1 -#define UI64_LSW 0 -#else -#define UI64_MSW 1 -#define UI64_LSW 0 -#endif - -#if defined(NPS_EN_COMPILER_SUPPORT_LONG_LONG) -#define UI64_HI(dst) ((UI32_T)((dst) >> 32)) -#define UI64_LOW(dst) ((UI32_T)((dst) & 0xffffffff)) -#define UI64_ASSIGN(dst, high, low) ((dst) = ((long long)(high) << 32 | (long long)(low))) -#define UI64_SET(dst, src) ((dst) = (src)) -#define UI64_ADD_UI32(dst, src) ((dst) += ((long long)(src))) -#define UI64_SUB_UI32(dst, src) ((dst) -= ((long long)(src))) -#define UI64_ADD_UI64(dst, src) ((dst) += (src)) -#define UI64_SUB_UI64(dst, src) ((dst) -= (src)) -#define UI64_AND(dst, src) ((dst) &= (src)) -#define UI64_OR(dst, src) ((dst) |= (src)) -#define UI64_XOR(dst, src) ((dst) ^= (src)) -#define UI64_NOT(dst) ((dst) = ~(dst)) -#define UI64_MULT_UI32(dst, src) ((dst) *= (src)) -#define UI64_MULT_UI64(dst, src) ((dst) *= (src)) -/* UI64_T type data comparion: - * if data1 > data2 return 1 - * if data1 < data2 return -1 - * if data1 == data2 return 0 - */ -#define UI64_CMP(data1, data2) (((data1) > (data2)) ? 1 : (((data1) < (data2)) ? -1 : 0)) - -#else -#define UI64_HI(dst) ((dst).ui64[UI64_MSW]) -#define UI64_LOW(dst) ((dst).ui64[UI64_LSW]) -#define UI64_ASSIGN(dst, high, low) \ - do \ - { \ - UI64_HI(dst) = (high); \ - UI64_LOW(dst) = (low); \ - } while(0) - -#define UI64_SET(dst, src) \ - do \ - { \ - UI64_HI(dst) = UI64_HI(src); \ - UI64_LOW(dst) = UI64_LOW(src); \ - } while(0) - - -#define UI64_ADD_UI32(dst, src) \ - do \ - { \ - UI32_T _i_ = UI64_LOW(dst); \ - UI64_LOW(dst) += (src); \ - if (UI64_LOW(dst) < _i_) \ - { \ - UI64_HI(dst)++; \ - } \ - } while(0) - -#define UI64_SUB_UI32(dst, src) \ - do \ - { \ - UI32_T _i_ = UI64_LOW(dst); \ - UI64_LOW(dst) -= src; \ - if (UI64_LOW(dst) > _i_) \ - { \ - UI64_HI(dst)--; \ - } \ - } while(0) - - -#define UI64_ADD_UI64(dst, src) \ - do \ - { \ - UI32_T _i_ = UI64_LOW(dst); \ - UI64_LOW(dst) += UI64_LOW(src); \ - if (UI64_LOW(dst) < _i_) \ - { \ - UI64_HI(dst)++; \ - } \ - UI64_HI(dst) += UI64_HI(src); \ - } while(0) - -#define UI64_SUB_UI64(dst, src) \ - do { \ - UI32_T _i_ = UI64_LOW(dst); \ - UI64_LOW(dst) -= UI64_LOW(src); \ - if (UI64_LOW(dst) > _i_) \ - { \ - UI64_HI(dst)--; \ - } \ - UI64_HI(dst) -= UI64_HI(src); \ - } while(0) - - -#define UI64_AND(dst, src) \ - do { \ - UI64_HI(dst) &= UI64_HI(src); \ - UI64_LOW(dst) &= UI64_LOW(src); \ - } while(0) - -#define UI64_OR(dst, src) \ - do { \ - UI64_HI(dst) |= UI64_HI(src); \ - UI64_LOW(dst) |= UI64_LOW(src); \ - } while(0) - -#define UI64_XOR(dst, src) \ - do { \ - UI64_HI(dst) ^= UI64_HI(src); \ - UI64_LOW(dst) ^= UI64_LOW(src); \ - } while(0) - -#define UI64_NOT(dst) \ - do { \ - UI64_HI(dst) = ~UI64_HI(dst); \ - UI64_LOW(dst) = ~UI64_LOW(dst); \ - } while(0) - -/* UI64_T type data comparion: - * if data1 > data2 return 1 - * if data1 < data2 return -1 - * if data1 == data2 return 0 - */ -#define UI64_CMP(data1, data2) \ - (((data1).ui64[UI64_MSW] > (data2).ui64[UI64_MSW]) \ - ? 1 : (((data1).ui64[UI64_MSW] == (data2).ui64[UI64_MSW]) \ - ? (((data1).ui64[UI64_LSW] == (data2).ui64[UI64_LSW]) \ - ? 0 :(((data1).ui64[UI64_LSW] > (data2).ui64[UI64_LSW]) \ - ? 1 : -1)) : -1)) - -#define UI64_MULT_UI64(dst, src) \ - do \ - { \ - UI32_T _ret_low_ = 0; \ - UI32_T _ret_high_ = 0; \ - UI32_T _i_ = 0; \ - UI32_T _j_ = 0; \ - UI32_T _temp_ = 0; \ - UI32_T dst_t[4] = {0, 0, 0, 0}; \ - UI32_T src_t[4] = {0, 0, 0, 0}; \ - dst_t[0] = UI64_LOW(dst) & 0xFFFF; \ - dst_t[1] = UI64_LOW(dst) >> 16; \ - dst_t[2] = UI64_HI(dst) & 0xFFFF; \ - dst_t[3] = UI64_HI(dst) >> 16; \ - src_t[0] = UI64_LOW(src) & 0xFFFF; \ - src_t[1] = UI64_LOW(src) >> 16; \ - src_t[2] = UI64_HI(src) & 0xFFFF; \ - src_t[3] = UI64_HI(src) >> 16; \ - for(_i_ = 0; _i_ < 4; _i_++) \ - { \ - for(_j_ = 0; _j_ < 4; _j_++) \ - { \ - if((dst_t[_i_] != 0) && (src_t[_j_] != 0)) \ - { \ - _temp_ = dst_t[_i_] * src_t[_j_]; \ - if(0 == (_i_ + _j_)) \ - { \ - _ret_low_ += _temp_; \ - if (_ret_low_ < _temp_) \ - { \ - _ret_high_++; \ - } \ - } \ - if(1 == (_i_ + _j_)) \ - { \ - _ret_low_ += (_temp_ << 16); \ - if (_ret_low_ < (_temp_ << 16)) \ - { \ - _ret_high_++; \ - } \ - _ret_high_ += (_temp_ >> 16); \ - } \ - if(2 == (_i_+_j_)) \ - { \ - _ret_high_ += _temp_; \ - } \ - if(3 == (_i_ + _j_)) \ - { \ - _ret_high_ += (_temp_ << 16); \ - } \ - } \ - } \ - } \ - UI64_HI(dst) = _ret_high_; \ - UI64_LOW(dst) = _ret_low_; \ - } while(0) - -#define UI64_MULT_UI32(dst, src) \ - do \ - { \ - UI32_T _ret_low_ = 0; \ - UI32_T _ret_high_ = 0; \ - UI32_T _i_ = 0; \ - UI32_T _j_ = 0; \ - UI32_T _temp_ = 0; \ - UI32_T dst_t[4] = {0, 0, 0, 0}; \ - UI32_T src_t[2] = {0, 0}; \ - dst_t[0] = UI64_LOW(dst) & 0xFFFF; \ - dst_t[1] = UI64_LOW(dst) >> 16; \ - dst_t[2] = UI64_HI(dst) & 0xFFFF; \ - dst_t[3] = UI64_HI(dst) >> 16; \ - src_t[0] = src & 0xFFFF; \ - src_t[1] = src >> 16; \ - for(_i_ = 0; _i_ < 4; _i_++) \ - { \ - for(_j_ = 0; _j_ < 2; _j_++) \ - { \ - if((dst_t[_i_] != 0) && (src_t[_j_] != 0)) \ - { \ - _temp_ = dst_t[_i_] * src_t[_j_]; \ - if(0 == (_i_ + _j_)) \ - { \ - _ret_low_ += _temp_; \ - if (_ret_low_ < _temp_) \ - { \ - _ret_high_++; \ - } \ - } \ - if(1 == (_i_ + _j_)) \ - { \ - _ret_low_ += (_temp_ << 16); \ - if (_ret_low_ < (_temp_ << 16)) \ - { \ - _ret_high_++; \ - } \ - _ret_high_ += (_temp_ >> 16); \ - } \ - if(2 == (_i_ + _j_)) \ - { \ - _ret_high_ += _temp_; \ - } \ - if(3 == (_i_ + _j_)) \ - { \ - _ret_high_ += (_temp_ << 16); \ - } \ - } \ - } \ - } \ - UI64_HI(dst) = _ret_high_; \ - UI64_LOW(dst) = _ret_low_; \ - } while(0) - -#endif - -/* DATA TYPE DECLARATIONS - */ -typedef int BOOL_T; -typedef signed char I8_T; -typedef unsigned char UI8_T; -typedef signed short I16_T; -typedef unsigned short UI16_T; -typedef signed int I32_T; -typedef unsigned int UI32_T; -typedef char C8_T; - -#if defined(NPS_EN_COMPILER_SUPPORT_LONG_LONG) -typedef signed long long int I64_T; -typedef unsigned long long int UI64_T; -#else -typedef struct -{ - I32_T i64[2]; -} I64_T; - -typedef struct -{ - UI32_T ui64[2]; -} UI64_T; -#endif - -#endif /* OSAL_TYPES_H */ diff --git a/platform/nephos/nephos-modules/modules/src/make.mk b/platform/nephos/nephos-modules/modules/src/make.mk deleted file mode 100755 index b49da8b43cd..00000000000 --- a/platform/nephos/nephos-modules/modules/src/make.mk +++ /dev/null @@ -1,37 +0,0 @@ -################################################################################ -# Copyright (C) 2020 MediaTek, Inc. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of version 2 of the GNU General Public -# License as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# version 2 along with this program. -################################################################################ -DEV_MODULE_NAME := nps_dev -NETIF_MODULE_NAME := nps_netif -################################################################################ -DEV_OBJS_TOTAL := ./src/osal_mdc.o ./src/osal_isymbol.o -NETIF_OBJS_TOTAL := ./src/hal_tau_pkt_knl.o ./src/netif_perf.o ./src/netif_osal.o ./src/netif_nl.o - -obj-m := $(DEV_MODULE_NAME).o $(NETIF_MODULE_NAME).o -$(DEV_MODULE_NAME)-objs := $(DEV_OBJS_TOTAL) -$(NETIF_MODULE_NAME)-objs := $(NETIF_OBJS_TOTAL) - -KBUILD_EXTRA_SYMBOLS := $(BUILD_OUTPUT_DIR)/Module.symvers -################################################################################ -folder: - $(TEST_PATH) $(BUILD_OUTPUT_DIR) || $(MKDIR) $(BUILD_OUTPUT_DIR) - $(TEST_PATH) $(BUILD_OUTPUT_DIR)/src || $(MKDIR) $(BUILD_OUTPUT_DIR)/src - -compile:: folder - touch $(BUILD_OUTPUT_DIR)/Makefile - $(MAKE) -C $(OS_PATH) M=$(BUILD_OUTPUT_DIR) src=$(shell pwd) modules EXTRA_CFLAGS="$(EXTRA_CFLAGS)" KBUILD_EXTRA_SYMBOLS=$(KBUILD_EXTRA_SYMBOLS) -install:: - -clean:: diff --git a/platform/nephos/nephos-modules/modules/src/netif_nl.c b/platform/nephos/nephos-modules/modules/src/netif_nl.c deleted file mode 100755 index c112e4b6dd8..00000000000 --- a/platform/nephos/nephos-modules/modules/src/netif_nl.c +++ /dev/null @@ -1,811 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - - /* FILE NAME: netif_xxx.c - * PURPOSE: - * It provide xxx API. - * NOTES: - */ -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -extern UI32_T ext_dbg_flag; - -#define NETIF_NL_DBG(__flag__, ...) do \ -{ \ - if (0 != ((__flag__) & (ext_dbg_flag))) \ - { \ - osal_printf(__VA_ARGS__); \ - } \ -}while (0) - -#define NETIF_NL_DBG_NETLINK (0x1UL << 6) - -#define NETIF_NL_FAMILY_NUM_MAX (256) -#define NETIF_NL_INTF_NUM_MAX (256) - -#define NETIF_NL_GET_FAMILY_META(__idx__) &(_netif_nl_cb.fam_entry[__idx__].meta) -#define NETIF_NL_GET_INTF_IGR_SAMPLE_RATE(__inft_id__) (_netif_nl_cb.intf_entry[__inft_id__].igr_sample_rate) - -#define NETIF_NL_FAMILY_IS_PSAMPLE(__ptr_family__) (0 == strncmp(__ptr_family__->name, \ - NETIF_NL_PSAMPLE_FAMILY_NAME, \ - NETIF_NL_NETLINK_NAME_LEN)) ? 1 : 0 - -/* porting part */ -#define NETIF_NL_VER_NUM (1) -#define NETIF_NL_PSAMPLE_MAX_ATTR_NUM (NETIF_NL_PSAMPLE_ATTR_LAST) -#define NETIF_NL_REGISTER_FAMILY(__family__) genl_register_family(__family__) - -#define NETIF_NL_UNREGISTER_FAMILY(__family__) genl_unregister_family(__family__) -#define NETIF_NL_ALLOC_SKB(__len__) genlmsg_new(__len__, GFP_ATOMIC) -#define NETIF_NL_FREE_SKB(__ptr_skb__) nlmsg_free(__ptr_skb__) - -#define NETIF_NL_SEND_PKT(__ptr_family__, __mcgrp_id__, __ptr_skb__) \ - genlmsg_multicast_netns(__ptr_family__, \ - &init_net, \ - __ptr_skb__, \ - 0, /* pid, avoid loop */ \ - __mcgrp_id__, \ - GFP_ATOMIC) -#define NETIF_NL_SET_SKB_ATTR_HDR(__skb__, __family__, __hdr_len__, __cmd__) \ - genlmsg_put(__skb__, 0, 0, __family__, \ - __hdr_len__, __cmd__) -#define NETIF_NL_END_SKB_ATTR_HDR(__skb__, __hdr__) genlmsg_end(__skb__, __hdr__) - -#define NETIF_NL_SET_16_BIT_ATTR(__skb__, __attr__, __data__) nla_put_u16(__skb__, __attr__, __data__) -#define NETIF_NL_SET_32_BIT_ATTR(__skb__, __attr__, __data__) nla_put_u32(__skb__, __attr__, __data__) - - -/* - * <----------- nla_total_size(payload) -------------> - * +------------------+- - -+- - - - - - - - - +- - -+ - * | Attribute Header | Pad | Payload | Pad | - * +------------------+- - -+- - - - - - - - - +- - -+ - * - * - * <-------- nla_attr_size(payload) ----------> - * +------------------+- - -+- - - - - - - - - +- - -+ - * | Attribute Header | Pad | Payload | Pad | - * +------------------+- - -+- - - - - - - - - +- - -+ - * - */ -/* total size = attr data size + attr header size */ -#define NETIF_NL_GET_ATTR_TOTAL_SIZE(__data_size__) nla_total_size(__data_size__) -#define NETIF_NL_GET_ATTR_SIZE(__data_size__) nla_attr_size(__data_size__) /* without padding */ - - -/* psample's family and group parameter */ -#define NETIF_NL_PSAMPLE_FAMILY_NAME "psample" -#define NETIF_NL_PSAMPLE_MC_GROUP_NAME_DATA "packets" -#define NETIF_NL_PSAMPLE_MC_GROUP_NAME_CFG "config" -#define NETIF_NL_PSAMPLE_MC_GROUP_NUM (NETIF_NL_PSAMPLE_MC_GROUP_ID_LAST) -#define NETIF_NL_DEFAULT_MC_GROUP_NUM (1) - -#define NETIF_NL_PSAMPLE_PKT_LEN_MAX (9216) -#define NETIF_NL_PSAMPLE_DFLT_USR_GROUP_ID (1) - -typedef enum -{ - NETIF_NL_PSAMPLE_MC_GROUP_ID_CONFIG = 0, - NETIF_NL_PSAMPLE_MC_GROUP_ID_SAMPLE, - NETIF_NL_PSAMPLE_MC_GROUP_ID_LAST, -} NETIF_NL_PSAMPLE_MC_GROUP_ID_T; - -typedef enum -{ - NETIF_NL_PSAMPLE_ATTR_IIFINDEX = 0, - NETIF_NL_PSAMPLE_ATTR_OIFINDEX, - NETIF_NL_PSAMPLE_ATTR_ORIGSIZE, - NETIF_NL_PSAMPLE_ATTR_SAMPLE_GROUP, - NETIF_NL_PSAMPLE_ATTR_GROUP_SEQ, - NETIF_NL_PSAMPLE_ATTR_SAMPLE_RATE, - NETIF_NL_PSAMPLE_ATTR_DATA, - NETIF_NL_PSAMPLE_ATTR_LAST -} NETIF_NL_PSAMPLE_ATTR_ID_T; - - -typedef struct genl_multicast_group NETIF_NL_MC_GROUP_T; -typedef struct genl_family NETIF_NL_FAMILY_T; - -static NETIF_NL_MC_GROUP_T _netif_nl_psample_mc_group[NETIF_NL_PSAMPLE_MC_GROUP_ID_LAST]; -static C8_T *_ptr_netif_nl_psample_mc_group_name[NETIF_NL_PSAMPLE_MC_GROUP_ID_LAST] = - { - NETIF_NL_PSAMPLE_MC_GROUP_NAME_CFG, - NETIF_NL_PSAMPLE_MC_GROUP_NAME_DATA - }; - -static NETIF_NL_MC_GROUP_T _netif_nl_default_mc_group[NETIF_NL_DEFAULT_MC_GROUP_NUM]; -static C8_T *_ptr_netif_nl_default_mc_group_name[NETIF_NL_DEFAULT_MC_GROUP_NUM] = - { - "default", - }; - -typedef struct -{ - NETIF_NL_FAMILY_T meta; - BOOL_T valid; - -} NETIF_NL_FAMILY_ENTRY_T; - -typedef struct -{ - UI32_T igr_sample_rate; - UI32_T egr_sample_rate; - UI32_T trunc_size; -} NETIF_NL_INTF_ENTRY_T; - -typedef struct -{ - NETIF_NL_FAMILY_ENTRY_T fam_entry[NETIF_NL_FAMILY_NUM_MAX]; - NETIF_NL_INTF_ENTRY_T intf_entry[NETIF_NL_INTF_NUM_MAX]; /* sorted in intf_id */ - UI32_T seq_num; -} NETIF_NL_CB_T; - -static NETIF_NL_CB_T _netif_nl_cb; - -/* should extract to common */ -struct net_device_priv -{ - struct net_device *ptr_net_dev; - struct net_device_stats stats; - UI32_T unit; - UI32_T id; - UI32_T port; - UI16_T vlan; - UI32_T speed; -}; - -static NPS_ERROR_NO_T -_netif_nl_setIntfIgrSampleRate( - const UI32_T unit, - const UI32_T id, - const UI32_T rate) -{ - NETIF_NL_CB_T *ptr_cb = &_netif_nl_cb; - - ptr_cb->intf_entry[id].igr_sample_rate = rate; - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_netif_nl_setIntfEgrSampleRate( - const UI32_T unit, - const UI32_T id, - const UI32_T rate) -{ - NETIF_NL_CB_T *ptr_cb = &_netif_nl_cb; - - ptr_cb->intf_entry[id].egr_sample_rate = rate; - - return (NPS_E_OK); -} - - -NPS_ERROR_NO_T -netif_nl_setIntfProperty( - const UI32_T unit, - const UI32_T id, - const NETIF_NL_INTF_PROPERTY_T property, - const UI32_T param0, - const UI32_T param1) -{ - NPS_ERROR_NO_T rc = NPS_E_BAD_PARAMETER; - - if (NETIF_NL_INTF_PROPERTY_IGR_SAMPLING_RATE == property) - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "receive set igr sample rate req, id=%d, property=%d, param0=%d, param=%d\n", - id, property, param0, param1); - rc = _netif_nl_setIntfIgrSampleRate(unit, id, param0); - } - else if (NETIF_NL_INTF_PROPERTY_EGR_SAMPLING_RATE == property) - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "receive set egr sample rate req, id=%d, property=%d, param0=%d, param=%d\n", - id, property, param0, param1); - rc = _netif_nl_setIntfEgrSampleRate(unit, id, param0); - } - else - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "[error] unknown property, property=%d\n", property); - } - - return (rc); -} - -static NPS_ERROR_NO_T -_netif_nl_getIntfIgrSampleRate( - const UI32_T unit, - const UI32_T id, - UI32_T *ptr_rate) -{ - NETIF_NL_CB_T *ptr_cb = &_netif_nl_cb; - - *ptr_rate = ptr_cb->intf_entry[id].igr_sample_rate; - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_netif_nl_getIntfEgrSampleRate( - const UI32_T unit, - const UI32_T id, - UI32_T *ptr_rate) -{ - NETIF_NL_CB_T *ptr_cb = &_netif_nl_cb; - - *ptr_rate = ptr_cb->intf_entry[id].egr_sample_rate; - - return (NPS_E_OK); -} - - -NPS_ERROR_NO_T -netif_nl_getIntfProperty( - const UI32_T unit, - const UI32_T id, - const NETIF_NL_INTF_PROPERTY_T property, - UI32_T *ptr_param0, - UI32_T *ptr_param1) -{ - NPS_ERROR_NO_T rc = NPS_E_BAD_PARAMETER; - - if (NETIF_NL_INTF_PROPERTY_IGR_SAMPLING_RATE == property) - { - rc = _netif_nl_getIntfIgrSampleRate(unit, id, ptr_param0); - } - else if (NETIF_NL_INTF_PROPERTY_EGR_SAMPLING_RATE == property) - { - rc = _netif_nl_getIntfEgrSampleRate(unit, id, ptr_param0); - } - else - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "[error] unknown property, property=%d\n", - property); - } - - return (rc); -} - -NPS_ERROR_NO_T -_netif_nl_allocNlFamilyEntry( - NETIF_NL_CB_T *ptr_cb, - UI32_T *ptr_index) -{ - UI32_T idx; - NPS_ERROR_NO_T rc = NPS_E_TABLE_FULL; - - for (idx = 0; idx < NETIF_NL_FAMILY_NUM_MAX; idx++) - { - if (FALSE == ptr_cb->fam_entry[idx].valid) - { - *ptr_index = idx; - ptr_cb->fam_entry[idx].valid = TRUE; - rc = NPS_E_OK; - break; - } - } - - return (rc); -} - -void -_netif_nl_freeNlFamilyEntry( - NETIF_NL_CB_T *ptr_cb, - const UI32_T index) -{ - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "[DBG] free netlink family entry, idx=%d\n", - index); - ptr_cb->fam_entry[index].valid = FALSE; -} - -NPS_ERROR_NO_T -_netif_nl_setNlMcgroupPsample( - NETIF_NL_FAMILY_T *ptr_nl_family) -{ - NETIF_NL_MC_GROUP_T *ptr_nl_mc_group = _netif_nl_psample_mc_group; - UI32_T idx; - - /* init the mc group and hook the group to family */ - osal_memset(ptr_nl_mc_group, 0x0, - (NETIF_NL_PSAMPLE_MC_GROUP_NUM * sizeof(NETIF_NL_MC_GROUP_T))); - - for (idx = 0; idx < NETIF_NL_PSAMPLE_MC_GROUP_ID_LAST; idx++) - { - osal_memcpy(ptr_nl_mc_group[idx].name, - _ptr_netif_nl_psample_mc_group_name[idx], - osal_strlen(_ptr_netif_nl_psample_mc_group_name[idx])); - } - ptr_nl_family->n_mcgrps = NETIF_NL_PSAMPLE_MC_GROUP_NUM; - ptr_nl_family->mcgrps = ptr_nl_mc_group; - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -_netif_nl_setNlMcgroupDefault( - NETIF_NL_FAMILY_T *ptr_nl_family) -{ - NETIF_NL_MC_GROUP_T *ptr_nl_mc_group = _netif_nl_default_mc_group; - UI32_T idx; - - /* init the mc group and hook the group to family */ - osal_memset(ptr_nl_mc_group, 0x0, - (NETIF_NL_DEFAULT_MC_GROUP_NUM * sizeof(NETIF_NL_MC_GROUP_T))); - - for (idx = 0; idx < NETIF_NL_DEFAULT_MC_GROUP_NUM; idx++) - { - osal_memcpy(ptr_nl_mc_group[idx].name, - _ptr_netif_nl_default_mc_group_name[idx], - osal_strlen(_ptr_netif_nl_default_mc_group_name[idx])); - } - ptr_nl_family->n_mcgrps = NETIF_NL_DEFAULT_MC_GROUP_NUM; - ptr_nl_family->mcgrps = ptr_nl_mc_group; - - return (NPS_E_OK); -} - -#define NETIF_NL_IS_FAMILY_ENTRY_VALID(__idx__) \ - (TRUE == _netif_nl_cb.fam_entry[__idx__].valid) ? (TRUE) : (FALSE) -NPS_ERROR_NO_T -netif_nl_createNetlink( - const UI32_T unit, - NETIF_NL_NETLINK_T *ptr_netlink, - UI32_T *ptr_netlink_id) -{ - NETIF_NL_CB_T *ptr_cb = &_netif_nl_cb; - UI32_T entry_id; - NETIF_NL_FAMILY_T *ptr_nl_family; - NETIF_NL_MC_GROUP_T *ptr_nl_mcgrp; - UI32_T idx; - int ret; - NPS_ERROR_NO_T rc; - - rc = _netif_nl_allocNlFamilyEntry(ptr_cb, &entry_id); - if (NPS_E_OK == rc) - { - ptr_nl_family = NETIF_NL_GET_FAMILY_META(entry_id); - - /* fill in the meta data for that netlink family */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) - ptr_nl_family->id = GENL_ID_GENERATE; /* family id can be ignored since linux 4.10 */ -#endif - ptr_nl_family->version = NETIF_NL_VER_NUM; - ptr_nl_family->maxattr = NETIF_NL_PSAMPLE_MAX_ATTR_NUM; - ptr_nl_family->netnsok = true; - osal_memcpy(ptr_nl_family->name, ptr_netlink->name, NETIF_NL_NETLINK_NAME_LEN); - - /* fill in the mc group info */ - ptr_nl_mcgrp = osal_alloc(sizeof(NETIF_NL_MC_GROUP_T)*ptr_netlink->mc_group_num); - if (NULL != ptr_nl_mcgrp) - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, "[DBG] create mc group:\n"); - for (idx = 0; idx < ptr_netlink->mc_group_num; idx++) - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "[DBG] - mcgrp%d: %s\n", idx, ptr_netlink->mc_group[idx].name); - osal_memcpy(ptr_nl_mcgrp[idx].name, ptr_netlink->mc_group[idx].name, - NETIF_NL_NETLINK_NAME_LEN); - } - ptr_nl_family->n_mcgrps = ptr_netlink->mc_group_num; - ptr_nl_family->mcgrps = ptr_nl_mcgrp; - - /* register the family to kernel */ - ret = NETIF_NL_REGISTER_FAMILY(ptr_nl_family); - if (0 == ret) - { - *ptr_netlink_id = entry_id; - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "[DBG] create netlink family, name=%s, entry_idx=%d, mcgrp_num=%d\n", - ptr_netlink->name, entry_id, ptr_nl_family->n_mcgrps); - rc = NPS_E_OK; - } - else - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "[DBG] register netlink family failed, name=%s, ret=%d\n", - ptr_netlink->name, ret); - osal_free(ptr_nl_mcgrp); - _netif_nl_freeNlFamilyEntry(ptr_cb, entry_id); - rc = NPS_E_OTHERS; - } - } - else - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, "[DBG] alloc mcgrp failed\n"); - rc = NPS_E_NO_MEMORY; - } - } - - return (rc); -} - -NPS_ERROR_NO_T -netif_nl_destroyNetlink( - const UI32_T unit, - const UI32_T netlink_id) -{ - NETIF_NL_CB_T *ptr_cb = &_netif_nl_cb; - UI32_T entry_idx = netlink_id; - NETIF_NL_FAMILY_T *ptr_nl_family; - int ret; - NPS_ERROR_NO_T rc; - - if (TRUE == NETIF_NL_IS_FAMILY_ENTRY_VALID(entry_idx)) - { - ptr_nl_family = NETIF_NL_GET_FAMILY_META(entry_idx); - ret = NETIF_NL_UNREGISTER_FAMILY(ptr_nl_family); - if (0 == ret) - { - osal_free(ptr_nl_family->mcgrps); - _netif_nl_freeNlFamilyEntry(ptr_cb, entry_idx); - rc = NPS_E_OK; - } - else - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "[DBG] unregister netlink family failed, name=%s, ret=%d\n", - ptr_nl_family->name, ret); - rc = NPS_E_OTHERS; - } - } - else - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "[DBG] destroy netlink failed, invalid netlink_id %d\n", - netlink_id); - rc = NPS_E_ENTRY_NOT_FOUND; - } - - return (rc); -} - -NPS_ERROR_NO_T -netif_nl_getNetlink( - const UI32_T unit, - const UI32_T netlink_id, - NETIF_NL_NETLINK_T *ptr_netlink) -{ - UI32_T entry_idx = netlink_id; - NETIF_NL_FAMILY_T *ptr_meta; - UI32_T grp_idx; - NPS_ERROR_NO_T rc = NPS_E_OK; - - if (TRUE == NETIF_NL_IS_FAMILY_ENTRY_VALID(entry_idx)) - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "[DBG] get valid netlink, id=%d\n", netlink_id); - - ptr_netlink->id = netlink_id; - ptr_meta = NETIF_NL_GET_FAMILY_META(entry_idx); - - ptr_netlink->mc_group_num = ptr_meta->n_mcgrps; - osal_memcpy(ptr_netlink->name, ptr_meta->name, NETIF_NL_NETLINK_NAME_LEN); - - for (grp_idx = 0; grp_idx < ptr_meta->n_mcgrps; grp_idx++) - { - osal_memcpy(ptr_netlink->mc_group[grp_idx].name, - ptr_meta->mcgrps[grp_idx].name, - NETIF_NL_NETLINK_NAME_LEN); - } - } - else - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "[DBG] get netlink failed, invalid netlink_id %d\n", - netlink_id); - rc = NPS_E_ENTRY_NOT_FOUND; - } - - return (rc); -} - - -NPS_ERROR_NO_T -_netif_nl_getFamilyByName( - NETIF_NL_CB_T *ptr_cb, - const C8_T *ptr_name, - NETIF_NL_FAMILY_T **pptr_nl_family) -{ - UI32_T idx; - NPS_ERROR_NO_T rc = NPS_E_ENTRY_NOT_FOUND; - - for (idx = 0; idx < NETIF_NL_FAMILY_NUM_MAX; idx++) - { - if ((TRUE == ptr_cb->fam_entry[idx].valid) && - (0 == strncmp(ptr_cb->fam_entry[idx].meta.name, - ptr_name, - NETIF_NL_NETLINK_NAME_LEN))) - { - *pptr_nl_family = &(ptr_cb->fam_entry[idx].meta); - rc = NPS_E_OK; - break; - } - } - - if (NPS_E_ENTRY_NOT_FOUND == rc) - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "[DBG] find family failed, name=%s\n", - ptr_name); - } - - return (rc); -} - -NPS_ERROR_NO_T -_netif_nl_getMcgrpIdByName( - NETIF_NL_FAMILY_T *ptr_nl_family, - const C8_T *ptr_mcgrp_name, - UI32_T *ptr_mcgrp_id) -{ - UI32_T idx; - NPS_ERROR_NO_T rc = NPS_E_ENTRY_NOT_FOUND; - - for (idx = 0; idx < ptr_nl_family->n_mcgrps; idx++) - { - if ((0 == strncmp(ptr_nl_family->mcgrps[idx].name, - ptr_mcgrp_name, - NETIF_NL_NETLINK_NAME_LEN))) - { - *ptr_mcgrp_id = idx; - rc = NPS_E_OK; - break; - } - } - - if (NPS_E_OK != rc) - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "[DBG] find mcgrp %s failed in family %s\n", - ptr_mcgrp_name, ptr_nl_family->name); - } - - return (rc); -} - -NPS_ERROR_NO_T -_netif_nl_allocPsampleSkb( - NETIF_NL_CB_T *ptr_cb, - NETIF_NL_FAMILY_T *ptr_nl_family, - struct sk_buff *ptr_ori_skb, - struct sk_buff **pptr_nl_skb) -{ - UI32_T msg_hdr_len; - UI32_T data_len; - struct sk_buff *ptr_nl_skb; - UI16_T igr_intf_idx; - struct net_device_priv *ptr_priv; - UI32_T rate; - UI32_T intf_id; - void *ptr_nl_hdr = NULL; - struct nlattr *ptr_nl_attr; - NPS_ERROR_NO_T rc = NPS_E_OK; - - /* make sure the total len (original pkt len + hdr msg) < PSAMPLE_MAX_PACKET_SIZE */ - - msg_hdr_len = NETIF_NL_GET_ATTR_TOTAL_SIZE(sizeof(UI16_T)) + /* PSAMPLE_ATTR_IIFINDEX */ - NETIF_NL_GET_ATTR_TOTAL_SIZE(sizeof(UI32_T)) + /* PSAMPLE_ATTR_SAMPLE_RATE */ - NETIF_NL_GET_ATTR_TOTAL_SIZE(sizeof(UI32_T)) + /* PSAMPLE_ATTR_ORIGSIZE */ - NETIF_NL_GET_ATTR_TOTAL_SIZE(sizeof(UI32_T)) + /* PSAMPLE_ATTR_SAMPLE_GROUP */ - NETIF_NL_GET_ATTR_TOTAL_SIZE(sizeof(UI32_T)); /* PSAMPLE_ATTR_GROUP_SEQ */ - - data_len = NETIF_NL_GET_ATTR_TOTAL_SIZE(ptr_ori_skb->len); - - if ((msg_hdr_len + NETIF_NL_GET_ATTR_TOTAL_SIZE(ptr_ori_skb->len)) > NETIF_NL_PSAMPLE_PKT_LEN_MAX) - { - data_len = NETIF_NL_PSAMPLE_PKT_LEN_MAX - msg_hdr_len - NLA_HDRLEN - NLA_ALIGNTO; - } - else - { - data_len = ptr_ori_skb->len; - } - - ptr_nl_skb = NETIF_NL_ALLOC_SKB(NETIF_NL_GET_ATTR_TOTAL_SIZE(data_len) + msg_hdr_len); - if (NULL != ptr_nl_skb) - { - /* to create a netlink msg header (cmd=0) */ - ptr_nl_hdr = NETIF_NL_SET_SKB_ATTR_HDR(ptr_nl_skb, ptr_nl_family, 0, 0); - if (NULL != ptr_nl_hdr) - { - /* obtain the intf index for the igr_port */ - igr_intf_idx = ptr_ori_skb->dev->ifindex; - NETIF_NL_SET_16_BIT_ATTR(ptr_nl_skb, NETIF_NL_PSAMPLE_ATTR_IIFINDEX, - (UI16_T)igr_intf_idx); - - /* meta header */ - /* use the igr port id as the index for the database to get sample rate */ - ptr_priv = netdev_priv(ptr_ori_skb->dev); - intf_id = ptr_priv->port; - rate = NETIF_NL_GET_INTF_IGR_SAMPLE_RATE(intf_id); - NETIF_NL_SET_32_BIT_ATTR(ptr_nl_skb, NETIF_NL_PSAMPLE_ATTR_SAMPLE_RATE, rate); - NETIF_NL_SET_32_BIT_ATTR(ptr_nl_skb, NETIF_NL_PSAMPLE_ATTR_ORIGSIZE, data_len); - NETIF_NL_SET_32_BIT_ATTR(ptr_nl_skb, NETIF_NL_PSAMPLE_ATTR_SAMPLE_GROUP, - NETIF_NL_PSAMPLE_DFLT_USR_GROUP_ID); - NETIF_NL_SET_32_BIT_ATTR(ptr_nl_skb, NETIF_NL_PSAMPLE_ATTR_GROUP_SEQ, ptr_cb->seq_num); - ptr_cb->seq_num++; - - /* data */ - ptr_nl_attr = (struct nlattr *)skb_put(ptr_nl_skb, NETIF_NL_GET_ATTR_TOTAL_SIZE(data_len)); - ptr_nl_attr->nla_type = NETIF_NL_PSAMPLE_ATTR_DATA; - /* get the attr size without padding, since it's the last one */ - ptr_nl_attr->nla_len = NETIF_NL_GET_ATTR_SIZE(data_len); - skb_copy_bits(ptr_ori_skb, 0, nla_data(ptr_nl_attr), data_len); - - NETIF_NL_END_SKB_ATTR_HDR(ptr_nl_skb, ptr_nl_hdr); - } - else - { - rc = NPS_E_OTHERS; - } - } - else - { - rc = NPS_E_OTHERS; - } - - *pptr_nl_skb = ptr_nl_skb; - - return (rc); -} - -NPS_ERROR_NO_T -_netif_nl_allocNetlinkSkb( - NETIF_NL_CB_T *ptr_cb, - NETIF_NL_FAMILY_T *ptr_nl_family, - struct sk_buff *ptr_ori_skb, - struct sk_buff **pptr_nl_skb) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - - /* need to fill specific skb header format */ - if (NETIF_NL_FAMILY_IS_PSAMPLE(ptr_nl_family)) - { - rc = _netif_nl_allocPsampleSkb(ptr_cb, ptr_nl_family, - ptr_ori_skb, pptr_nl_skb); - if (NPS_E_OK != rc) - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "[DBG] alloc netlink skb failed\n"); - } - } - else - { - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "[DBG] unknown netlink family\n"); - rc = NPS_E_OTHERS; - } - - return (rc); -} - -NPS_ERROR_NO_T -_netif_nl_sendNetlinkSkb( - NETIF_NL_FAMILY_T *ptr_nl_family, - UI32_T nl_mcgrp_id, - struct sk_buff *ptr_nl_skb) -{ - int ret; - NPS_ERROR_NO_T rc; - - ret = NETIF_NL_SEND_PKT(ptr_nl_family, nl_mcgrp_id, ptr_nl_skb); - if (0 == ret) - { - rc = NPS_E_OK; - } - else - { - /* in errno_base.h, #define ESRCH 3 : No such process */ - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, - "send skb to mc group failed, ret=%d\n", ret); - rc = NPS_E_OTHERS; - } - - return (rc); -} - -void -_netif_nl_freeNetlinkSkb( - struct sk_buff *ptr_nl_skb) -{ - NETIF_NL_DBG(NETIF_NL_DBG_NETLINK, "[DBG] free nl skb\n"); - NETIF_NL_FREE_SKB(ptr_nl_skb); -} - -NPS_ERROR_NO_T -_netif_nl_forwardPkt( - NETIF_NL_CB_T *ptr_cb, - NETIF_NL_RX_DST_NETLINK_T *ptr_nl_dest, - struct sk_buff *ptr_ori_skb) -{ - struct sk_buff *ptr_nl_skb = NULL; - NETIF_NL_FAMILY_T *ptr_nl_family; - UI32_T nl_mcgrp_id; - NPS_ERROR_NO_T rc; - - rc = _netif_nl_getFamilyByName(ptr_cb, ptr_nl_dest->name, - &ptr_nl_family); - if (NPS_E_OK == rc) - { - rc = _netif_nl_getMcgrpIdByName(ptr_nl_family, ptr_nl_dest->mc_group_name, - &nl_mcgrp_id); - if (NPS_E_OK == rc) - { - rc = _netif_nl_allocNetlinkSkb(ptr_cb, ptr_nl_family, - ptr_ori_skb, &ptr_nl_skb); - if (NPS_E_OK == rc) - { - rc = _netif_nl_sendNetlinkSkb(ptr_nl_family, nl_mcgrp_id, - ptr_nl_skb); - if (NPS_E_OK != rc) - { - /* _netif_nl_freeNetlinkSkb(ptr_nl_skb); */ - } - } - } - } - - return (rc); -} - -NPS_ERROR_NO_T -netif_nl_rxSkb( - const UI32_T unit, - struct sk_buff *ptr_skb, - void *ptr_cookie) -{ - NETIF_NL_CB_T *ptr_cb = &_netif_nl_cb; - - NETIF_NL_RX_DST_NETLINK_T *ptr_nl_dest; - NPS_ERROR_NO_T rc; - - ptr_nl_dest = (NETIF_NL_RX_DST_NETLINK_T *)ptr_cookie; - - /* send the packet to netlink mcgroup */ - rc = _netif_nl_forwardPkt(ptr_cb, ptr_nl_dest, ptr_skb); - - /* need to free the original skb anyway */ - osal_skb_free(ptr_skb); - - return (rc); -} - -NPS_ERROR_NO_T -netif_nl_init(void) -{ - osal_memset(&_netif_nl_cb, 0x0, sizeof(NETIF_NL_CB_T)); - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -netif_nl_deinit(void) -{ - return (NPS_E_OK); -} - diff --git a/platform/nephos/nephos-modules/modules/src/netif_osal.c b/platform/nephos/nephos-modules/modules/src/netif_osal.c deleted file mode 100755 index 51af7fcb3ad..00000000000 --- a/platform/nephos/nephos-modules/modules/src/netif_osal.c +++ /dev/null @@ -1,753 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: netif_osal.c - * PURPOSE: - * It provide customer linux API. - * NOTES: - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) -#include -#endif -#include - -/* ----------------------------------------------------------------------------------- macro value */ -#define OSAL_US_PER_SECOND (1000000) /* macro second per second */ -#define OSAL_NS_PER_USECOND (1000) /* nano second per macro second */ - -/* ----------------------------------------------------------------------------------- macro function */ -#define OSAL_LOG_ERR(msg, ...) \ - osal_printf("\033[31m\033[0m"msg, __LINE__, ##__VA_ARGS__) - -/* ----------------------------------------------------------------------------------- struct */ -extern struct pci_dev *_ptr_ext_pci_dev; - -static linux_thread_t _osal_thread_head = {{0}}; - -/* ----------------------------------------------------------------------------------- function */ -/* general */ -void * -osal_memset( - void *ptr_mem, - const I32_T value, - const UI32_T num) -{ - return memset(ptr_mem, value, num); -} - -void * -osal_memcpy( - void *ptr_dst, - const void *ptr_src, - const UI32_T num) -{ - return memcpy(ptr_dst, ptr_src, num); -} - -UI32_T -osal_strlen( - const C8_T *ptr_str) -{ - return strlen(ptr_str); -} - -void -osal_printf( - const C8_T *ptr_fmt, - ...) -{ - va_list ap; - char buf[OSAL_PRN_BUF_SZ]; - - if (NULL != ptr_fmt) - { - va_start(ap, ptr_fmt); - vsnprintf(buf, OSAL_PRN_BUF_SZ, ptr_fmt, ap); - va_end(ap); - - printk("%s", buf); - } -} - -void * -osal_alloc( - const UI32_T size) -{ - return kmalloc(size, GFP_ATOMIC); -} - -void -osal_free( - const void *ptr_mem) -{ - kfree(ptr_mem); -} - -/* thread */ -NPS_ERROR_NO_T -osal_init(void) -{ - linux_thread_t *ptr_thread_head = &_osal_thread_head; - - memset(ptr_thread_head, 0x0, sizeof(linux_thread_t)); - - /* init */ - ptr_thread_head->ptr_prev = ptr_thread_head; - ptr_thread_head->ptr_next = ptr_thread_head; - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_deinit(void) -{ - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_createThread( - const C8_T *ptr_thread_name, - const UI32_T stack_size, - const UI32_T priority, - void (function)(void*), - void *ptr_arg, - NPS_THREAD_ID_T *ptr_thread_id) -{ - char dft_name[OSAL_THREAD_NAME_LEN + 1] = OSAL_THREAD_DFT_NAME; - linux_thread_t *ptr_thread_head = &_osal_thread_head; - linux_thread_t *ptr_thread_node = osal_alloc(sizeof(linux_thread_t)); - - /* process name */ - osal_memcpy(ptr_thread_node->name, (0 == osal_strlen(ptr_thread_name))? - dft_name : ptr_thread_name, OSAL_THREAD_NAME_LEN); - ptr_thread_node->name[OSAL_THREAD_NAME_LEN] = '\0'; - - /* init */ - ptr_thread_node->ptr_task = kthread_create((int(*)(void *))function, ptr_arg, ptr_thread_name); - ptr_thread_node->ptr_task->policy = SCHED_RR; - ptr_thread_node->ptr_task->rt_priority = priority; - ptr_thread_node->is_stop = FALSE; - - *ptr_thread_id = (NPS_THREAD_ID_T)ptr_thread_node; - - wake_up_process(ptr_thread_node->ptr_task); - - /* append the thread_node */ - ptr_thread_node->ptr_prev = ptr_thread_head->ptr_prev; - ptr_thread_head->ptr_prev->ptr_next = ptr_thread_node; - ptr_thread_node->ptr_next = ptr_thread_head; - ptr_thread_head->ptr_prev = ptr_thread_node; - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_stopThread( - NPS_THREAD_ID_T *ptr_thread_id) -{ - linux_thread_t *ptr_thread_node = (linux_thread_t *)(*ptr_thread_id); - - ptr_thread_node->is_stop = TRUE; - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_destroyThread( - NPS_THREAD_ID_T *ptr_thread_id) -{ - linux_thread_t *ptr_thread_node = (linux_thread_t *)(*ptr_thread_id); - - kthread_stop(ptr_thread_node->ptr_task); - - /* remove the thread_node */ - ptr_thread_node->ptr_next->ptr_prev = ptr_thread_node->ptr_prev; - ptr_thread_node->ptr_prev->ptr_next = ptr_thread_node->ptr_next; - - osal_free(ptr_thread_node); - *ptr_thread_id = 0; - - return (NPS_E_OK); -} - -void -osal_initRunThread(void) -{ - /* for reboot or shutdown without stopping kthread */ - allow_signal(SIGTERM); -} - -NPS_ERROR_NO_T -osal_isRunThread(void) -{ - linux_thread_t *ptr_thread_node = _osal_thread_head.ptr_next; - - while (1) - { - if (ptr_thread_node == &_osal_thread_head) - { - OSAL_LOG_ERR("Cannot find task 0x%x.\n", current); - break; - } - if (ptr_thread_node->ptr_task == current) - { - break; - } - ptr_thread_node = ptr_thread_node->ptr_next; - } - - if ((TRUE == ptr_thread_node->is_stop) || (signal_pending(current))) - { - return (NPS_E_OTHERS); - } - - return (NPS_E_OK); -} - -void -osal_exitRunThread(void) -{ - while (!kthread_should_stop() && !signal_pending(current)) - { - osal_sleepThread(OSAL_NS_PER_USECOND); - } -} - -/* semaphore */ -NPS_ERROR_NO_T -osal_createSemaphore( - const C8_T *ptr_sema_name, - const UI32_T sema_count, - NPS_SEMAPHORE_ID_T *ptr_semaphore_id) -{ - char dft_name[OSAL_SEMA_NAME_LEN + 1] = OSAL_SEMA_DFT_NAME; - linux_sema_t *ptr_sema = osal_alloc(sizeof(linux_sema_t)); - - /* process name */ - osal_memcpy(ptr_sema->name, (0 == osal_strlen(ptr_sema_name))? - dft_name : ptr_sema_name, OSAL_SEMA_NAME_LEN); - ptr_sema->name[OSAL_SEMA_NAME_LEN] = '\0'; - - /* init */ - sema_init(&ptr_sema->lock, NPS_SEMAPHORE_BINARY); - - *ptr_semaphore_id = (NPS_SEMAPHORE_ID_T)ptr_sema; - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_takeSemaphore( - NPS_SEMAPHORE_ID_T *ptr_semaphore_id, - UI32_T time_out) -{ - linux_sema_t *ptr_sema = (linux_sema_t *)(*ptr_semaphore_id); - - if (in_interrupt()) - { - return (NPS_E_OTHERS); - } - - if (!down_interruptible(&ptr_sema->lock)) - { - return (NPS_E_OK); - } - - return (NPS_E_OTHERS); -} - -NPS_ERROR_NO_T -osal_giveSemaphore( - NPS_SEMAPHORE_ID_T *ptr_semaphore_id) -{ - linux_sema_t *ptr_sema = (linux_sema_t *)(*ptr_semaphore_id); - - up(&ptr_sema->lock); - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_destroySemaphore( - NPS_SEMAPHORE_ID_T *ptr_semaphore_id) -{ - linux_sema_t *ptr_sema = (linux_sema_t *)(*ptr_semaphore_id); - - osal_free(ptr_sema); - *ptr_semaphore_id = 0; - - return (NPS_E_OK); -} - -/* event */ -NPS_ERROR_NO_T -osal_createEvent( - const C8_T *ptr_event_name, - NPS_SEMAPHORE_ID_T *ptr_event_id) -{ - char dft_name[OSAL_EVENT_NAME_LEN + 1] = OSAL_EVENT_DFT_NAME; - linux_event_t *ptr_event = osal_alloc(sizeof(linux_event_t)); - - /* process name */ - osal_memcpy(ptr_event->name, (0 == osal_strlen(ptr_event_name))? - dft_name : ptr_event_name, OSAL_EVENT_NAME_LEN); - ptr_event->name[OSAL_EVENT_NAME_LEN] = '\0'; - - /* init */ - ptr_event->condition = FALSE; - init_waitqueue_head(&ptr_event->wait_que); - - *ptr_event_id = (NPS_SEMAPHORE_ID_T)ptr_event; - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_waitEvent( - NPS_SEMAPHORE_ID_T *ptr_event_id) -{ - linux_event_t *ptr_event = (linux_event_t *)(*ptr_event_id); - - if (!wait_event_interruptible(ptr_event->wait_que, ptr_event->condition)) - { - ptr_event->condition = FALSE; - - return (NPS_E_OK); - } - - return (NPS_E_OTHERS); -} - -NPS_ERROR_NO_T -osal_triggerEvent( - NPS_SEMAPHORE_ID_T *ptr_event_id) -{ - linux_event_t *ptr_event = (linux_event_t *)(*ptr_event_id); - - ptr_event->condition = TRUE; - wake_up_interruptible(&ptr_event->wait_que); - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_destroyEvent( - NPS_SEMAPHORE_ID_T *ptr_event_id) -{ - linux_event_t *ptr_event = (linux_event_t *)(*ptr_event_id); - - osal_free(ptr_event); - *ptr_event_id = 0; - - return (NPS_E_OK); -} - -/* isr_lock */ -NPS_ERROR_NO_T -osal_createIsrLock( - const C8_T *ptr_isrlock_name, - NPS_ISRLOCK_ID_T *ptr_isrlock_id) -{ - char dft_name[OSAL_SPIN_NAME_LEN + 1] = OSAL_SPIN_DFT_NAME; - linux_isrlock_t *ptr_isrlock = osal_alloc(sizeof(linux_isrlock_t)); - - /* process name */ - osal_memcpy(ptr_isrlock->name, (0 == osal_strlen(ptr_isrlock_name))? - dft_name : ptr_isrlock_name, OSAL_SPIN_NAME_LEN); - ptr_isrlock->name[OSAL_SPIN_NAME_LEN] = '\0'; - - /* init */ - spin_lock_init(&ptr_isrlock->spinlock); - - *ptr_isrlock_id = (NPS_ISRLOCK_ID_T)ptr_isrlock; - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_takeIsrLock( - NPS_ISRLOCK_ID_T *ptr_isrlock_id, - NPS_IRQ_FLAGS_T *ptr_irq_flags) -{ - linux_isrlock_t *ptr_isrlock = (linux_isrlock_t *)(*ptr_isrlock_id); - unsigned long flags = 0; - - spin_lock_irqsave(&ptr_isrlock->spinlock, flags); - *ptr_irq_flags = (NPS_IRQ_FLAGS_T)flags; - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_giveIsrLock( - NPS_ISRLOCK_ID_T *ptr_isrlock_id, - NPS_IRQ_FLAGS_T *ptr_irq_flags) -{ - linux_isrlock_t *ptr_isrlock = (linux_isrlock_t *)(*ptr_isrlock_id); - unsigned long flags = 0; - - flags = (unsigned long)(*ptr_irq_flags); - spin_unlock_irqrestore(&ptr_isrlock->spinlock, flags); - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_destroyIsrLock( - NPS_ISRLOCK_ID_T *ptr_isrlock_id) -{ - linux_isrlock_t *ptr_isrlock = (linux_isrlock_t *)(*ptr_isrlock_id); - - osal_free(ptr_isrlock); - *ptr_isrlock_id = 0; - - return (NPS_E_OK); -} - -/* time */ -NPS_ERROR_NO_T -osal_sleepThread( - const UI32_T usecond) -{ - UI32_T tick_usec; /* how many usec per second */ - UI32_T jiffies; - - if (0 != usecond) - { - /* HZ : times/sec, tick = 1/HZ */ - tick_usec = OSAL_TICKS_PER_SEC / HZ; - if (in_interrupt() || (usecond < tick_usec)) - { - return (-1); - } - else - { - DECLARE_WAIT_QUEUE_HEAD(suspend_queue); - - if (usecond > 0xFFFFFFFF - (tick_usec - 1)) - { - jiffies = 0xFFFFFFFF / tick_usec; - } - else - { - jiffies = (usecond + (tick_usec - 1)) / tick_usec; - } - - return wait_event_interruptible_timeout(suspend_queue, 0, jiffies); - } - } - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_getTime( - NPS_TIME_T *ptr_time) -{ - struct timeval usec_time; - - do_gettimeofday(&usec_time); - *(NPS_TIME_T *)ptr_time = (usec_time.tv_sec * OSAL_US_PER_SECOND) + usec_time.tv_usec; - - return (NPS_E_OK); -} - -/* queue */ -NPS_ERROR_NO_T -osal_que_create( - NPS_HUGE_T *ptr_queue_id, - UI32_T capacity) -{ - linux_queue_t *ptr_queue = osal_alloc(sizeof(linux_queue_t)); - - ptr_queue->head = 0; - ptr_queue->tail = 0; - ptr_queue->wr_cnt = 0; - ptr_queue->rd_cnt = 0; - ptr_queue->capacity = capacity; - ptr_queue->ptr_entry = osal_alloc(sizeof(linux_queue_entry_t) * capacity); - memset(ptr_queue->ptr_entry, 0x0, sizeof(linux_queue_entry_t) * capacity); - - *ptr_queue_id = (NPS_HUGE_T)ptr_queue; - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_que_enque( - NPS_HUGE_T *ptr_queue_id, - void *ptr_data) -{ - linux_queue_t *ptr_queue = (linux_queue_t *)(*ptr_queue_id); - - if (ptr_queue->wr_cnt - ptr_queue->rd_cnt >= ptr_queue->capacity) - { - return (NPS_E_OTHERS); - } - - /* save data to the tail */ - ptr_queue->ptr_entry[ptr_queue->tail].ptr_data = ptr_data; - - /* calculate tail and wr_cnt */ - ptr_queue->tail++; - if (ptr_queue->tail >= ptr_queue->capacity) - { - ptr_queue->tail = 0; - } - - ptr_queue->wr_cnt++; - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_que_deque( - NPS_HUGE_T *ptr_queue_id, - void **pptr_data) -{ - linux_queue_t *ptr_queue = (linux_queue_t *)(*ptr_queue_id); - - if (ptr_queue->wr_cnt == ptr_queue->rd_cnt) - { - return (NPS_E_OTHERS); - } - - /* get data from head */ - *pptr_data = ptr_queue->ptr_entry[ptr_queue->head].ptr_data; - ptr_queue->ptr_entry[ptr_queue->head].ptr_data = NULL; - - /* calculate head and rd_cnt */ - ptr_queue->head++; - if (ptr_queue->head >= ptr_queue->capacity) - { - ptr_queue->head = 0; - } - - ptr_queue->rd_cnt++; - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_que_destroy( - NPS_HUGE_T *ptr_queue_id) -{ - linux_queue_t *ptr_queue = (linux_queue_t *)(*ptr_queue_id); - - osal_free(ptr_queue->ptr_entry); - osal_free(ptr_queue); - *ptr_queue_id = 0; - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_que_getCount( - NPS_HUGE_T *ptr_queue_id, - unsigned int *ptr_count) -{ - linux_queue_t *ptr_queue = (linux_queue_t *)(*ptr_queue_id); - - *ptr_count = ptr_queue->wr_cnt - ptr_queue->rd_cnt; - - return (NPS_E_OK); -} - -/* IO */ -int -osal_io_copyToUser( - void *ptr_usr_buf, - void *ptr_knl_buf, - unsigned int size) -{ - return copy_to_user(ptr_usr_buf, ptr_knl_buf, size); -} - -int -osal_io_copyFromUser( - void *ptr_knl_buf, - void *ptr_usr_buf, - unsigned int size) -{ - return copy_from_user(ptr_knl_buf, ptr_usr_buf, size); -} - -/* dma */ -void * -osal_dma_alloc( - const UI32_T size) -{ - struct device *ptr_dev = &_ptr_ext_pci_dev->dev; - linux_dma_t *ptr_dma_node = NULL; - dma_addr_t phy_addr = 0x0; - - ptr_dma_node = dma_alloc_coherent(ptr_dev, sizeof(linux_dma_t) + size, &phy_addr, GFP_ATOMIC); - ptr_dma_node->size = sizeof(linux_dma_t) + size; - ptr_dma_node->phy_addr = phy_addr; - - return (void *)ptr_dma_node->data; -} - -NPS_ERROR_NO_T -osal_dma_free( - void *ptr_dma_mem) -{ - struct device *ptr_dev = &_ptr_ext_pci_dev->dev; - linux_dma_t *ptr_dma_node = (linux_dma_t *)(ptr_dma_mem - sizeof(linux_dma_t)); - - dma_free_coherent(ptr_dev, ptr_dma_node->size, ptr_dma_node, ptr_dma_node->phy_addr); - - return (NPS_E_OK); -} - -dma_addr_t -osal_dma_convertVirtToPhy( - void *ptr_virt_addr) -{ - return virt_to_phys(ptr_virt_addr); -} - -void * -osal_dma_convertPhyToVirt( - const dma_addr_t phy_addr) -{ - return phys_to_virt(phy_addr); -} - -int -osal_dma_flushCache( - void *ptr_virt_addr, - const unsigned int size) -{ -#if defined(CONFIG_NOT_COHERENT_CACHE) || defined(CONFIG_DMA_NONCOHERENT) -#if defined(dma_cache_wback_inv) - dma_cache_wback_inv((NPS_HUGE_T)ptr_virt_addr, size); -#else - dma_cache_sync(NULL, ptr_virt_addr, size, DMA_TO_DEVICE); -#endif -#endif - return (0); -} - -int -osal_dma_invalidateCache( - void *ptr_virt_addr, - const unsigned int size) -{ -#if defined(CONFIG_NOT_COHERENT_CACHE) || defined(CONFIG_DMA_NONCOHERENT) -#if defined(dma_cache_wback_inv) - dma_cache_wback_inv((NPS_HUGE_T)ptr_virt_addr, size); -#else - dma_cache_sync(NULL, ptr_virt_addr, size, DMA_FROM_DEVICE); -#endif -#endif - return (0); -} - -/* skb */ -struct sk_buff * -osal_skb_alloc( - UI32_T size) -{ - struct sk_buff *ptr_skb = NULL; - - /* - * 1. alloc_skb (len, flag) : GFP_KERNEL - * 2. netdev_alloc_skb (dev, len) : GFP_ATOMIC - * 3. dev_alloc_skb (len) : GFP_ATOMIC - * 4. netdev_alloc_skb_ip_align (dev, len) : GFP_ATOMIC - * - * note: Eth header is 14-bytes, we reservd 2-bytes to alignment Ip header - */ - ptr_skb = dev_alloc_skb(size + NET_IP_ALIGN); - skb_reserve(ptr_skb, NET_IP_ALIGN); - skb_put(ptr_skb, size); - - return (ptr_skb); -} - -void -osal_skb_free( - struct sk_buff *ptr_skb) -{ - /* - * 1. dev_kfree_skb (*skb) : release in process context - * 2. dev_kfree_skb_irq (*skb) : release in interrupt context - * 3. dev_kfree_skb_any (*skb) : release in any context - */ - dev_kfree_skb_any(ptr_skb); -} - -dma_addr_t -osal_skb_mapDma( - struct sk_buff *ptr_skb, - enum dma_data_direction dir) -{ - struct device *ptr_dev = &_ptr_ext_pci_dev->dev; - dma_addr_t phy_addr = 0x0; - - phy_addr = dma_map_single(ptr_dev, ptr_skb->data, ptr_skb->len, dir); - if (dma_mapping_error(ptr_dev, phy_addr)) - { - phy_addr = 0x0; - } - - return (phy_addr); -} - -void -osal_skb_unmapDma( - const dma_addr_t phy_addr, - UI32_T size, - enum dma_data_direction dir) -{ - struct device *ptr_dev = &_ptr_ext_pci_dev->dev; - - dma_unmap_single(ptr_dev, phy_addr, size, dir); -} - -void -osal_skb_send( - struct sk_buff *ptr_skb) -{ - dev_queue_xmit(ptr_skb); -} - -void -osal_skb_recv( - struct sk_buff *ptr_skb) -{ - /* 1. netif_rx() : handle skb in process context - * 2. netif_rx_ni() : handle skb in interrupt context - * 3. netif_receive_skb() : for NAPI - */ - netif_rx(ptr_skb); -} - diff --git a/platform/nephos/nephos-modules/modules/src/netif_perf.c b/platform/nephos/nephos-modules/modules/src/netif_perf.c deleted file mode 100755 index 11dd03b58eb..00000000000 --- a/platform/nephos/nephos-modules/modules/src/netif_perf.c +++ /dev/null @@ -1,656 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: netif_perf.c - * PURPOSE: - * It provide customer performance test API. - * NOTES: - */ -#include -#include - -#include -#include - -#if defined (NPS_EN_TAURUS) -#include -#endif - -/* -------------------------------------------------------------- switch */ -#if defined (NPS_EN_ARIES) -#define PERF_TX_CHANNEL_NUM_MAX (HAL_ARI_PKT_TX_CHANNEL_LAST) -#define PERF_RX_CHANNEL_NUM_MAX (HAL_ARI_PKT_RX_CHANNEL_LAST) -typedef HAL_ARI_PKT_TX_SW_GPD_T PERF_TX_SW_GPD; -typedef HAL_ARI_PKT_RX_SW_GPD_T PERF_RX_SW_GPD; -#endif - -#if defined (NPS_EN_TAURUS) -#define PERF_TX_CHANNEL_NUM_MAX (HAL_TAU_PKT_TX_CHANNEL_LAST) -#define PERF_RX_CHANNEL_NUM_MAX (HAL_TAU_PKT_RX_CHANNEL_LAST) -typedef HAL_TAU_PKT_TX_SW_GPD_T PERF_TX_SW_GPD; -typedef HAL_TAU_PKT_RX_SW_GPD_T PERF_RX_SW_GPD; -#endif - -/* -------------------------------------------------------------- common */ -#define PERF_TX_PERF_NUM (1000000) /* max: 4294967 */ -#define PERF_TX_PERF_MESG (50000) -#define PERF_TX_PERF_FAIL (10000) -#define PERF_RX_PERF_NUM (1000000) /* max: 4294967 */ -#define PERF_RX_PERF_MESG (50000) -#define PERF_RX_PERF_FAIL (10000) - -/* -------------------------------------------------------------- callbacks for chip dependency */ -/* Tx */ -typedef NPS_ERROR_NO_T -(*PERF_TX_GET_INTR_T)( - const UI32_T unit, - const UI32_T channel, - UI32_T *ptr_intr_cnt); - -typedef NPS_ERROR_NO_T -(*PERF_TX_GET_NETDEV_T)( - const UI32_T unit, - const UI32_T port, - struct net_device **pptr_net_dev); - -typedef NPS_ERROR_NO_T -(*PERF_TX_PREPARE_GPD_T)( - const UI32_T unit, - const NPS_ADDR_T phy_addr, - const UI32_T len, - const UI32_T port, - PERF_TX_SW_GPD *ptr_sw_gpd); - -typedef NPS_ERROR_NO_T -(*PERF_TX_SEND_GPD_T)( - const UI32_T unit, - const UI32_T channel, - PERF_TX_SW_GPD *ptr_sw_gpd); - -/* Rx */ -typedef NPS_ERROR_NO_T -(*PERF_RX_GET_INTR_T)( - const UI32_T unit, - const UI32_T channel, - UI32_T *ptr_intr_cnt); - -/* -------------------------------------------------------------- structs */ -typedef enum -{ - PERF_DIR_TX = 0, - PERF_DIR_RX, - PERF_DIR_LAST, - -} PERF_DIR_T; - -typedef struct -{ - UI32_T unit; - UI32_T channel; - UI32_T len; - UI32_T num; - UI32_T port; - BOOL_T test_skb; - -} PERF_COOKIE_T; - -typedef struct -{ - /* netif-only */ - PERF_COOKIE_T tx_cookie [PERF_TX_CHANNEL_NUM_MAX]; - - NPS_THREAD_ID_T tx_task [PERF_TX_CHANNEL_NUM_MAX]; - NPS_SEMAPHORE_ID_T start_sync [PERF_TX_CHANNEL_NUM_MAX]; - NPS_SEMAPHORE_ID_T end_sync [PERF_TX_CHANNEL_NUM_MAX]; - UI32_T send_ok [PERF_TX_CHANNEL_NUM_MAX]; - UI32_T send_fail [PERF_TX_CHANNEL_NUM_MAX]; - - /* chip dependent callbacks */ - PERF_TX_GET_INTR_T get_intr_cnt; - PERF_TX_GET_NETDEV_T get_netdev; - PERF_TX_PREPARE_GPD_T prepare_gpd; - PERF_TX_SEND_GPD_T send_gpd; - -} PERF_TX_PERF_CB_T; - -typedef struct -{ - /* netif-only */ - BOOL_T rx_test; - - NPS_SEMAPHORE_ID_T start_sync; - NPS_SEMAPHORE_ID_T end_sync; - UI32_T target_num; - UI32_T target_len; - UI32_T recv_pass; - UI32_T recv_fail; - - /* duplicate packets */ - UI32_T rch_qid_map_lo [PERF_RX_CHANNEL_NUM_MAX]; - UI32_T rch_qid_map_hi [PERF_RX_CHANNEL_NUM_MAX]; - - /* chip dependent callbacks */ - PERF_RX_GET_INTR_T get_intr_cnt; - -} PERF_RX_PERF_CB_T; - -/* -------------------------------------------------------------- statics */ -static PERF_TX_PERF_CB_T _perf_tx_perf_cb = -{ -#if defined (NPS_EN_ARIES) - .get_intr_cnt = hal_ari_pkt_getTxIntrCnt, - .get_netdev = hal_ari_pkt_getNetDev, /* test_skb = TRUE */ - .prepare_gpd = hal_ari_pkt_prepareGpd, /* test_skb = FALSE */ - .send_gpd = hal_ari_pkt_sendGpd, /* test_skb = FALSE */ -#endif -#if defined (NPS_EN_TAURUS) - .get_intr_cnt = hal_tau_pkt_getTxIntrCnt, - .get_netdev = hal_tau_pkt_getNetDev, /* test_skb = TRUE */ - .prepare_gpd = hal_tau_pkt_prepareGpd, /* test_skb = FALSE */ - .send_gpd = hal_tau_pkt_sendGpd, /* test_skb = FALSE */ -#endif -}; - -static PERF_RX_PERF_CB_T _perf_rx_perf_cb = -{ -#if defined (NPS_EN_ARIES) - .get_intr_cnt = hal_ari_pkt_getRxIntrCnt, -#endif -#if defined (NPS_EN_TAURUS) - .get_intr_cnt = hal_tau_pkt_getRxIntrCnt, -#endif -}; - -/* -------------------------------------------------------------- functions */ -static void -_perf_duplicateRxPacket( - const UI32_T unit, - const UI32_T rx_channel, - const BOOL_T enable) -{ - ; -} - -static void -_perf_showPerf( - PERF_DIR_T dir, - UI32_T channel, - UI32_T len, - UI32_T num, - UI32_T intr, - UI32_T duration) -{ - UI32_T tx_channel = 0; - UI32_T tx_fail = 0; - - if (duration < 1000) - { - osal_printf("***Error***, %d packets cost < 1000 us.\n", num); - return ; - } - - osal_printf("\n"); - - if (PERF_DIR_TX == dir) - { - osal_printf("Tx-perf\n"); - } - else - { - osal_printf("Rx-perf\n"); - } - - osal_printf("------------------------------------\n"); - osal_printf("channel number : %d\n", channel); - osal_printf("packet length (bytes): %d\n", len); - osal_printf("packet number : %d\n", num); - osal_printf("time duration (us) : %d\n", duration); - osal_printf("------------------------------------\n"); - osal_printf("avg. packet rate (pps) : %d\n", (num * 1000) / (duration / 1000)); - osal_printf("avg. throughput (Mbps) : %d\n", ((num / 1000) * len * 8) / (duration / 1000)); - osal_printf("interrupt number : %d\n", intr); - - if (PERF_DIR_TX == dir) - { - for (tx_channel = 0; tx_channel < channel; tx_channel++) - { - tx_fail += _perf_tx_perf_cb.send_fail[tx_channel]; - } - osal_printf("Tx fail : %d\n", tx_fail); - } - - osal_printf("------------------------------------\n"); -} - -static void -_perf_getIntrCnt( - UI32_T unit, - PERF_DIR_T dir, - UI32_T *ptr_intr_cnt) -{ - UI32_T intr_cnt = 0; - UI32_T channel = 0; - - if (PERF_DIR_TX == dir) - { - for (channel = 0; channel < PERF_TX_CHANNEL_NUM_MAX; channel++) - { - _perf_tx_perf_cb.get_intr_cnt(unit, channel, &intr_cnt); - *ptr_intr_cnt += intr_cnt; - } - } - else - { - for (channel = 0; channel < PERF_RX_CHANNEL_NUM_MAX; channel++) - { - _perf_rx_perf_cb.get_intr_cnt(unit, channel, &intr_cnt); - *ptr_intr_cnt += intr_cnt; - } - } -} - -static void -_perf_txCallback( - const UI32_T unit, - PERF_TX_SW_GPD *ptr_sw_gpd, - void *ptr_virt_addr) -{ - /* free dma */ - osal_dma_free(ptr_virt_addr); - - /* free gpd */ - osal_free(ptr_sw_gpd); -} - -static void -_perf_txTask( - void *ptr_argv) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - UI32_T unit = ((PERF_COOKIE_T *)ptr_argv)->unit; - UI32_T channel = ((PERF_COOKIE_T *)ptr_argv)->channel; - UI32_T len = ((PERF_COOKIE_T *)ptr_argv)->len; - UI32_T num = ((PERF_COOKIE_T *)ptr_argv)->num; - UI32_T port = ((PERF_COOKIE_T *)ptr_argv)->port; - BOOL_T test_skb = ((PERF_COOKIE_T *)ptr_argv)->test_skb; - - /* test targets */ - PERF_TX_SW_GPD *ptr_sw_gpd = NULL; - struct sk_buff *ptr_skb = NULL; - - /* temp variables */ - UI32_T send_fail = 0; - void *ptr_virt_addr = NULL; - NPS_ADDR_T phy_addr = 0x0; - - osal_initRunThread(); - do - { - rc = osal_waitEvent(&_perf_tx_perf_cb.start_sync[channel]); - if (NPS_E_OK != osal_isRunThread()) - { - break; /* deinit-thread */ - } - - while (_perf_tx_perf_cb.send_ok[channel] < num) - { - if (0 == (_perf_tx_perf_cb.send_ok[channel] % PERF_TX_PERF_MESG)) - { - printk("T"); - } - - if (TRUE == test_skb) - { - ptr_skb = osal_skb_alloc(len); - ptr_skb->len = len; - _perf_tx_perf_cb.get_netdev(unit, port, &ptr_skb->dev); - - /* send skb */ - osal_skb_send(ptr_skb); - } - else - { - ptr_sw_gpd = osal_alloc(sizeof(PERF_TX_SW_GPD)); - if (NULL == ptr_sw_gpd) - { - osal_printf("***Error***, alloc sw-gpd fail.\n"); - break; - } - - /* prepare buf */ - ptr_virt_addr = osal_dma_alloc(len); - phy_addr = osal_dma_convertVirtToPhy(ptr_virt_addr); - - /* trans skb to gpd */ - osal_memset(ptr_sw_gpd, 0x0, sizeof(PERF_TX_SW_GPD)); - ptr_sw_gpd->callback = (void *)_perf_txCallback; - ptr_sw_gpd->ptr_cookie = (void *)ptr_virt_addr; - ptr_sw_gpd->gpd_num = 1; - ptr_sw_gpd->ptr_next = NULL; - ptr_sw_gpd->channel = channel; - - /* prepare gpd */ - rc = _perf_tx_perf_cb.prepare_gpd(unit, phy_addr, len, port, ptr_sw_gpd); - - /* send gpd */ - rc = _perf_tx_perf_cb.send_gpd(unit, channel, ptr_sw_gpd); - if (NPS_E_OK == rc) - { - _perf_tx_perf_cb.send_ok[channel]++; - send_fail = 0; - } - else - { - _perf_tx_perf_cb.send_fail[channel]++; - if (send_fail++ >= PERF_TX_PERF_FAIL) - { - osal_printf("***Error***, Tch-%d send fail over %d packet(s). (rc: %d)\n", - channel, PERF_TX_PERF_FAIL, rc); - break; - } - - _perf_txCallback(unit, ptr_sw_gpd, ptr_virt_addr); - osal_sleepThread(1000); - } - } - } - - osal_triggerEvent(&_perf_tx_perf_cb.end_sync[channel]); - } - while (NPS_E_OK == osal_isRunThread()); - osal_exitRunThread(); -} - -static void -_perf_txDeinit( - const UI32_T unit, - const UI32_T tx_channel) -{ - UI32_T channel = 0; - - for (channel = 0; channel < tx_channel; channel++) - { - /* destroy Tx resources */ - osal_stopThread (&_perf_tx_perf_cb.tx_task [channel]); - osal_triggerEvent(&_perf_tx_perf_cb.start_sync [channel]); - osal_destroyThread(&_perf_tx_perf_cb.tx_task [channel]); - osal_destroyEvent(&_perf_tx_perf_cb.end_sync [channel]); - osal_destroyEvent(&_perf_tx_perf_cb.start_sync [channel]); - } -} - -static void -_perf_txInit( - const UI32_T unit, - const UI32_T tx_channel, - const UI32_T len, - BOOL_T test_skb) -{ - UI32_T channel = 0; - - for (channel = 0; channel < tx_channel; channel++) - { - _perf_tx_perf_cb.send_ok [channel] = 0; - _perf_tx_perf_cb.send_fail[channel] = 0; - - /* create Tx resources */ - osal_createEvent("TX_START", &_perf_tx_perf_cb.start_sync [channel]); - osal_createEvent("TX_END", &_perf_tx_perf_cb.end_sync [channel]); - - _perf_tx_perf_cb.tx_cookie[channel].unit = unit; - _perf_tx_perf_cb.tx_cookie[channel].channel = channel; - _perf_tx_perf_cb.tx_cookie[channel].len = len; - _perf_tx_perf_cb.tx_cookie[channel].num = PERF_TX_PERF_NUM / tx_channel; - _perf_tx_perf_cb.tx_cookie[channel].port = 0; - _perf_tx_perf_cb.tx_cookie[channel].test_skb = test_skb; - - osal_createThread( - "TX_PERF", 64 * 1024, 90, - _perf_txTask, - (void *)&_perf_tx_perf_cb.tx_cookie[channel], - &_perf_tx_perf_cb.tx_task[channel]); - } -} - -static void -_perf_rxDeinit( - const UI32_T unit, - const UI32_T rx_channel) -{ - /* turn-off Rx test */ - _perf_rx_perf_cb.rx_test = FALSE; - - /* destroy Rx resources */ - osal_destroyEvent(&_perf_rx_perf_cb.end_sync); - osal_destroyEvent(&_perf_rx_perf_cb.start_sync); - - /* disable duplicate Rx packets to channels */ - _perf_duplicateRxPacket(unit, rx_channel, FALSE); -} - -static void -_perf_rxInit( - const UI32_T unit, - const UI32_T rx_channel, - const UI32_T len) -{ - /* enable duplicate Rx packets to channels */ - _perf_duplicateRxPacket(unit, rx_channel, TRUE); - - /* create Rx callback resources */ - _perf_rx_perf_cb.target_num = PERF_RX_PERF_NUM; - _perf_rx_perf_cb.target_len = len; - _perf_rx_perf_cb.recv_pass = 0; - - osal_createEvent("RX_START", &_perf_rx_perf_cb.start_sync); - osal_createEvent("RX_END", &_perf_rx_perf_cb.end_sync); - - /* turn-on Rx test */ - _perf_rx_perf_cb.rx_test = TRUE; -} - -/* FUNCTION NAME: perf_rxCallback - * PURPOSE: - * To count the Rx-gpd for Rx-test. - * INPUT: - * len -- To check if the Rx-gpd length equals to test length. - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successful operation. - * NOTES: - * None - */ -NPS_ERROR_NO_T -perf_rxCallback( - const UI32_T len) -{ - /* check length */ - if (len == _perf_rx_perf_cb.target_len) - { - _perf_rx_perf_cb.recv_pass++; - } - else - { - if (_perf_rx_perf_cb.recv_fail++ >= PERF_RX_PERF_FAIL) - { - _perf_rx_perf_cb.recv_fail = 0; - } - } - - /* send signals */ - if (0 == _perf_rx_perf_cb.recv_pass) - { - ; /* do nothing */ - } - else if (1 == _perf_rx_perf_cb.recv_pass) - { - osal_triggerEvent(&_perf_rx_perf_cb.start_sync); - } - else if (_perf_rx_perf_cb.recv_pass == _perf_rx_perf_cb.target_num) - { - osal_triggerEvent(&_perf_rx_perf_cb.end_sync); - } - else if (0 == (_perf_rx_perf_cb.recv_pass % PERF_RX_PERF_MESG)) - { - printk("R"); - } - - return (NPS_E_OK); -} - -/* FUNCTION NAME: perf_rxTest - * PURPOSE: - * To check if Rx-test is going. - * INPUT: - * None - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successful operation. - * NOTES: - * None - */ -NPS_ERROR_NO_T -perf_rxTest(void) -{ - if (FALSE == _perf_rx_perf_cb.rx_test) - { - return (NPS_E_OTHERS); - } - - return (NPS_E_OK); -} - -/* FUNCTION NAME: perf_test - * PURPOSE: - * To do Tx-test or Rx-test. - * INPUT: - * len -- Test length - * tx_channel -- Test Tx channel numbers - * rx_channel -- Test Rx channel numbers - * test_skb -- Test GPD or SKB - * OUTPUT: - * None - * RETURN: - * NPS_E_OK -- Successful operation. - * NOTES: - * None - */ -NPS_ERROR_NO_T -perf_test( - UI32_T len, - UI32_T tx_channel, - UI32_T rx_channel, - BOOL_T test_skb) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - NPS_TIME_T start_time; - NPS_TIME_T end_time; - UI32_T unit = 0, channel = 0; - UI32_T tx_pkt_cnt = 0, tx_start_intr = 0, tx_end_intr = 0; - UI32_T rx_pkt_cnt = 0, rx_start_intr = 0, rx_end_intr = 0; - - if ((0 == tx_channel) && (0 == rx_channel)) - { - return (NPS_E_NOT_SUPPORT); - } - - /* start test */ - if ((tx_channel > 0) && (rx_channel > 0)) - { - _perf_getIntrCnt(unit, PERF_DIR_TX, &tx_start_intr); - _perf_getIntrCnt(unit, PERF_DIR_RX, &rx_start_intr); - _perf_txInit(unit, tx_channel, len, test_skb); - _perf_rxInit(unit, rx_channel, len); - - /* wait 1st Rx GPD done */ - osal_waitEvent(&_perf_rx_perf_cb.start_sync); - - /* ------------- in-time ------------- */ - osal_getTime(&start_time); - for (channel = 0; channel < tx_channel; channel++) - { - osal_triggerEvent(&_perf_tx_perf_cb.start_sync[channel]); - } - for (channel = 0; channel < tx_channel; channel++) - { - osal_waitEvent(&_perf_tx_perf_cb.end_sync[channel]); - tx_pkt_cnt += _perf_tx_perf_cb.send_ok[channel]; - } - rx_pkt_cnt = _perf_rx_perf_cb.recv_pass; - osal_getTime(&end_time); - /* ------------- in-time ------------- */ - - _perf_txDeinit(unit, tx_channel); - _perf_rxDeinit(unit, rx_channel); - _perf_getIntrCnt(unit, PERF_DIR_TX, &tx_end_intr); - _perf_getIntrCnt(unit, PERF_DIR_RX, &rx_end_intr); - - _perf_showPerf(PERF_DIR_TX, - tx_channel, len, tx_pkt_cnt, tx_end_intr - tx_start_intr, end_time - start_time); - - _perf_showPerf(PERF_DIR_RX, - rx_channel, len, rx_pkt_cnt, rx_end_intr - rx_start_intr, end_time - start_time); - } - else if (tx_channel > 0) - { - _perf_getIntrCnt(unit, PERF_DIR_TX, &tx_start_intr); - _perf_txInit(unit, tx_channel, len, test_skb); - - /* ------------- in-time ------------- */ - osal_getTime(&start_time); - for (channel = 0; channel < tx_channel; channel++) - { - osal_triggerEvent(&_perf_tx_perf_cb.start_sync[channel]); - } - for (channel = 0; channel < tx_channel; channel++) - { - osal_waitEvent(&_perf_tx_perf_cb.end_sync[channel]); - tx_pkt_cnt += _perf_tx_perf_cb.send_ok[channel]; - } - osal_getTime(&end_time); - /* ------------- in-time ------------- */ - - _perf_txDeinit(unit, tx_channel); - _perf_getIntrCnt(unit, PERF_DIR_TX, &tx_end_intr); - - _perf_showPerf(PERF_DIR_TX, - tx_channel, len, tx_pkt_cnt, tx_end_intr - tx_start_intr, end_time - start_time); - } - else if (rx_channel > 0) - { - _perf_getIntrCnt(unit, PERF_DIR_RX, &rx_start_intr); - _perf_rxInit(unit, rx_channel, len); - - /* wait 1st Rx GPD done */ - osal_waitEvent(&_perf_rx_perf_cb.start_sync); - - /* ------------- in-time ------------- */ - osal_getTime(&start_time); - osal_waitEvent(&_perf_rx_perf_cb.end_sync); - osal_getTime(&end_time); - /* ------------- in-time ------------- */ - - _perf_rxDeinit(unit, rx_channel); - _perf_getIntrCnt(unit, PERF_DIR_RX, &rx_end_intr); - - _perf_showPerf(PERF_DIR_RX, - rx_channel, len, PERF_RX_PERF_NUM, rx_end_intr - rx_start_intr, end_time - start_time); - } - - return (rc); -} - diff --git a/platform/nephos/nephos-modules/modules/src/osal_isymbol.c b/platform/nephos/nephos-modules/modules/src/osal_isymbol.c deleted file mode 100755 index f908c232596..00000000000 --- a/platform/nephos/nephos-modules/modules/src/osal_isymbol.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: osal_isymbol.c -* PURPOSE: -* It provide global OSAL symbol export for linux kernel module -* NOTES: -*/ -#include -#include - -/* ----------------------------------------------------- */ -#include -/* dma */ -extern struct pci_dev *_ptr_ext_pci_dev; -EXPORT_SYMBOL(_ptr_ext_pci_dev); - -#if defined(NPS_LINUX_USER_MODE) -EXPORT_SYMBOL(osal_mdc_readPciReg); -EXPORT_SYMBOL(osal_mdc_writePciReg); -#if defined(NPS_EN_NETIF) -/* intr */ -/* for kernel module, this API will be exported by script with other OSAL functions in osal_symbol.c */ -EXPORT_SYMBOL(osal_mdc_registerIsr); -#endif -#endif diff --git a/platform/nephos/nephos-modules/modules/src/osal_mdc.c b/platform/nephos/nephos-modules/modules/src/osal_mdc.c deleted file mode 100755 index d0a25e48fc3..00000000000 --- a/platform/nephos/nephos-modules/modules/src/osal_mdc.c +++ /dev/null @@ -1,2512 +0,0 @@ -/* Copyright (C) 2020 MediaTek, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program. - */ - -/* FILE NAME: osal_mdc.c - * PURPOSE: - * 1. Provide device operate from AML interface - * NOTES: - * - */ - -/* INCLUDE FILE DECLARATIONS - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#if defined(NPS_LINUX_USER_MODE) -#include - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0) -#include -#else -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -/* #define OSAL_MDC_EN_MSI */ -/* #define OSAL_MDC_DMA_RESERVED_MEM_CACHEABLE */ -/* #define OSAL_MDC_EN_TEST */ - -/* NAMING CONSTANT DECLARATIONS - */ -#define OSAL_MDC_PCI_BAR0_OFFSET (0x0) -#define OSAL_MDC_ERR printk - -/* MACRO FUNCTION DECLARATIONS - */ - -/* DATA TYPE DECLARATIONS - */ -typedef struct -{ - UI32_T unit; - struct pci_dev *ptr_pci_dev; - UI32_T *ptr_mmio_virt_addr; - int irq; - AML_DEV_ISR_FUNC_T isr_callback; - void *ptr_isr_data; - -} OSAL_MDC_DEV_T; - -typedef struct -{ - OSAL_MDC_DEV_T dev[NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM]; - UI32_T dev_num; - OSAL_MDC_DMA_INFO_T dma_info; - -} OSAL_MDC_CB_T; - -#if defined(NPS_LINUX_USER_MODE) - -typedef struct -{ - OSAL_MDC_IOCTL_CALLBACK_FUNC_T callback[OSAL_MDC_IOCTL_TYPE_LAST]; - -} OSAL_MDC_IOCTL_CB_T; - -#if !defined(NPS_EN_DMA_RESERVED) -typedef struct -{ - NPS_ADDR_T phy_addr; - UI32_T size; - struct list_head list; - -} OSAL_MDC_USER_MODE_DMA_NODE_T; -#endif - -#endif - - -#if defined(NPS_LINUX_KERNEL_MODE) - -/* re-define the interface to align OSAL_MDC's implementation with the prototype of CMLIB */ -#define osal_mdc_list_create(__capa__, __type__, __name__, __list__) _osal_mdc_list_create(__capa__, __list__) -#define osal_mdc_list_destroy(__list__, __callback__) _osal_mdc_list_destroy(__list__) -#define osal_mdc_list_getNodeData(__list__, __node__, __data__) _osal_mdc_list_getNodeData(__list__, __node__, __data__) -#define osal_mdc_list_next(__list__, __node__, __next__) _osal_mdc_list_next(__list__, __node__, __next__) -#define osal_mdc_list_locateHead(__list__, __node__) _osal_mdc_list_locateHead(__list__, __node__) -#define osal_mdc_list_insertToHead(__list__, __data__) _osal_mdc_list_insertToHead(__list__, __data__) -#define osal_mdc_list_deleteByData(__list__, __data__) _osal_mdc_list_deleteByData(__list__, __data__) - -#if defined(NPS_EN_DMA_RESERVED) -#define osal_mdc_list_insertBefore(__list__, __node__, __data__) _osal_mdc_list_insertBefore(__list__, __node__, __data__) -#define osal_mdc_list_prev(__list__, __node__, __prev__) _osal_mdc_list_prev(__list__, __node__, __prev__) -#endif - -#define OSAL_MDC_LIST_TYPE_DOUBLE (1) /* don't care the type, always be double */ -#define OSAL_MDC_LIST_TYPE_SINGLE (0) /* don't care the type, always be double */ - -static NPS_ERROR_NO_T -_osal_mdc_list_create( - const UI32_T capacity, - OSAL_MDC_LIST_T **pptr_list ) -{ - NPS_ERROR_NO_T rc = NPS_E_NO_MEMORY; - - *pptr_list = NULL; - - *pptr_list = osal_alloc(sizeof(OSAL_MDC_LIST_T)); - if (NULL != *pptr_list) - { - (*pptr_list)->capacity = capacity; - (*pptr_list)->node_cnt = 0; - (*pptr_list)->ptr_head_node = NULL; - (*pptr_list)->ptr_tail_node = NULL; - rc = NPS_E_OK; - } - - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_list_destroy( - OSAL_MDC_LIST_T *ptr_list ) -{ - OSAL_MDC_LIST_NODE_T *ptr_cur_node, *ptr_next_node; - NPS_ERROR_NO_T rc = NPS_E_OTHERS; - - if (NULL != ptr_list) - { - if (ptr_list->node_cnt != 0) - { - OSAL_MDC_ERR("dma list not empty, node num=%d\n", - ptr_list->node_cnt); - ptr_cur_node = ptr_list->ptr_head_node; - while(NULL != ptr_cur_node) - { - ptr_next_node = ptr_cur_node->ptr_next; - osal_free(ptr_cur_node); - ptr_list->node_cnt--; - ptr_cur_node = ptr_next_node; - } - } - - osal_free(ptr_list); - rc = NPS_E_OK; - } - - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_list_getNodeData( - OSAL_MDC_LIST_T *ptr_list, - OSAL_MDC_LIST_NODE_T *ptr_node, - void **pptr_node_data ) -{ - NPS_ERROR_NO_T rc = NPS_E_OTHERS; - - if (NULL != ptr_list) - { - if (NULL != ptr_node) - { - *pptr_node_data = ptr_node->ptr_data; - rc = NPS_E_OK; - } - } - - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_list_insertToHead( - OSAL_MDC_LIST_T *ptr_list, - void *ptr_data ) -{ - OSAL_MDC_LIST_NODE_T *ptr_new_node = NULL; - NPS_ERROR_NO_T rc = NPS_E_OTHERS; - - if (NULL != ptr_list) - { - ptr_new_node = osal_alloc(sizeof(OSAL_MDC_LIST_NODE_T)); - if (NULL != ptr_new_node) - { - ptr_new_node->ptr_data = ptr_data; - - /* no former node */ - ptr_new_node->ptr_prev = NULL; - - if (NULL != ptr_list->ptr_head_node) - { - ptr_list->ptr_head_node->ptr_prev = ptr_new_node; - ptr_new_node->ptr_next = ptr_list->ptr_head_node; - } - else - { - /* 1st node insertion */ - ptr_list->ptr_tail_node = ptr_new_node; - ptr_new_node->ptr_next = NULL; - } - - ptr_list->ptr_head_node = ptr_new_node; - ptr_list->node_cnt++; - rc = NPS_E_OK; - } - } - - return (rc); -} - -#if defined(NPS_EN_DMA_RESERVED) -static NPS_ERROR_NO_T -_osal_mdc_list_insertBefore( - OSAL_MDC_LIST_T *ptr_list, - OSAL_MDC_LIST_NODE_T *ptr_node, - void *ptr_data ) -{ - OSAL_MDC_LIST_NODE_T *ptr_new_node = NULL; - OSAL_MDC_LIST_NODE_T *ptr_prev_node = ptr_node->ptr_prev; - NPS_ERROR_NO_T rc = NPS_E_OTHERS; - - if (NULL != ptr_list) - { - if (NULL != ptr_node) - { - ptr_new_node = osal_alloc(sizeof(OSAL_MDC_LIST_NODE_T)); - if (NULL != ptr_new_node) - { - ptr_new_node->ptr_data = ptr_data; - - /* location */ - if (NULL != ptr_prev_node) - { - ptr_prev_node->ptr_next = ptr_new_node; - } - ptr_new_node->ptr_prev = ptr_prev_node; - ptr_new_node->ptr_next = ptr_node; - ptr_node->ptr_prev = ptr_new_node; - - /* update head if necessary */ - if (ptr_list->ptr_head_node == ptr_node) - { - ptr_list->ptr_head_node = ptr_new_node; - } - - ptr_list->node_cnt++; - rc = NPS_E_OK; - } - } - } - - return (rc); -} -#endif - -static NPS_ERROR_NO_T -_osal_mdc_list_deleteTargetNode( - OSAL_MDC_LIST_T *ptr_list, - OSAL_MDC_LIST_NODE_T *ptr_target_node) -{ - OSAL_MDC_LIST_NODE_T *ptr_prev_node = ptr_target_node->ptr_prev; - OSAL_MDC_LIST_NODE_T *ptr_next_node = ptr_target_node->ptr_next; - - if (ptr_target_node == ptr_list->ptr_head_node) - { - ptr_list->ptr_head_node = ptr_next_node; - if (NULL != ptr_next_node) - { - ptr_next_node->ptr_prev = NULL; - } - else - { - /* there's only 1 node in the list, and it gets removed */ - ptr_list->ptr_tail_node = NULL; - } - } - else if (ptr_target_node == ptr_list->ptr_tail_node) - { - /* at least 2 nodes in the list, and the target node locates tail */ - ptr_list->ptr_tail_node = ptr_prev_node; - ptr_prev_node->ptr_next = NULL; - } - else - { - /* intermediate node */ - ptr_prev_node->ptr_next = ptr_next_node; - ptr_next_node->ptr_prev = ptr_prev_node; - } - - osal_free(ptr_target_node); - ptr_list->node_cnt--; - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_osal_mdc_list_deleteByData( - OSAL_MDC_LIST_T *ptr_list, - void *ptr_delete_data) -{ - OSAL_MDC_LIST_NODE_T *ptr_tmp_node; - NPS_ERROR_NO_T rc = NPS_E_OTHERS; - - if (NULL != ptr_list) - { - ptr_tmp_node = ptr_list->ptr_head_node; - while (NULL != ptr_tmp_node) - { - if (ptr_tmp_node->ptr_data == ptr_delete_data) - { - rc = _osal_mdc_list_deleteTargetNode(ptr_list, ptr_tmp_node); - break; - } - else - { - ptr_tmp_node = ptr_tmp_node->ptr_next; - } - } - } - - return (rc); -} - - -static NPS_ERROR_NO_T -_osal_mdc_list_locateHead( - OSAL_MDC_LIST_T *ptr_list, - OSAL_MDC_LIST_NODE_T **pptr_node ) -{ - NPS_ERROR_NO_T rc = NPS_E_OTHERS; - - if (NULL != ptr_list) - { - *pptr_node = ptr_list->ptr_head_node; - if (NULL != *pptr_node) - { - rc = NPS_E_OK; - } - } - - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_list_next( - OSAL_MDC_LIST_T *ptr_list, - OSAL_MDC_LIST_NODE_T *ptr_node, - OSAL_MDC_LIST_NODE_T **pptr_next_node ) -{ - NPS_ERROR_NO_T rc = NPS_E_OTHERS; - - if (NULL != ptr_list) - { - if (NULL != ptr_node) - { - *pptr_next_node = ptr_node->ptr_next; - if (NULL != *pptr_next_node) - { - rc = NPS_E_OK; - } - } - } - - return (rc); -} - -#if defined(NPS_EN_DMA_RESERVED) -static NPS_ERROR_NO_T -_osal_mdc_list_prev( - OSAL_MDC_LIST_T *ptr_list, - OSAL_MDC_LIST_NODE_T *ptr_node, - OSAL_MDC_LIST_NODE_T **pptr_prev_node ) -{ - NPS_ERROR_NO_T rc = NPS_E_OTHERS; - - if (NULL != ptr_list) - { - if (NULL != ptr_node) - { - *pptr_prev_node = ptr_node->ptr_prev; - if (NULL != *pptr_prev_node) - { - rc = NPS_E_OK; - } - } - } - - return (rc); -} -#endif /* End of defined(NPS_EN_DMA_RESERVED) */ - -#endif /* End if defined(NPS_LINUX_KERNEL_MODE) */ - -/* GLOBAL VARIABLE DECLARATIONS - */ -static OSAL_MDC_CB_T _osal_mdc_cb; - -/* To let system callback function to access AML database */ -static AML_DEV_T *_ptr_osal_mdc_dev; - -/* Interface */ -struct pci_dev *_ptr_ext_pci_dev; - - -/* STATIC VARIABLE DECLARATIONS - */ -/* --------------------------------------------------------------------------- I2C interface */ -#if defined(AML_EN_I2C) -extern NPS_ERROR_NO_T -dev_switch_readBuffer( - const UI32_T addr, - const UI32_T addr_len, - UI8_T *ptr_buf, - const UI32_T buf_len); - -extern NPS_ERROR_NO_T -dev_switch_writeBuffer( - const UI32_T addr, - const UI32_T addr_len, - const UI8_T *ptr_buf, - const UI32_T buf_len); - -static NPS_ERROR_NO_T -_osal_mdc_readI2cReg( - const UI32_T unit, - const UI32_T offset, - UI32_T *ptr_data, - const UI32_T len) -{ - return dev_switch_readBuffer(offset, sizeof(offset), (UI8_T *)ptr_data, len); -} - -static NPS_ERROR_NO_T -_osal_mdc_writeI2cReg( - const UI32_T unit, - const UI32_T offset, - const UI32_T *ptr_data, - const UI32_T len) -{ - return dev_switch_writeBuffer(offset, sizeof(offset), (UI8_T *)ptr_data, len); -} - -static NPS_ERROR_NO_T -_osal_mdc_probeI2cDevice(void) -{ - /* I2C interface will be probed in BSP. */ - _ptr_osal_mdc_dev->if_type = AML_DEV_TYPE_I2C; - _ptr_osal_mdc_dev->access.read_callback = _osal_mdc_readI2cReg; - _ptr_osal_mdc_dev->access.write_callback = _osal_mdc_writeI2cReg; - - _ptr_osal_mdc_dev->id.device = HAL_DEVICE_ID_MT3258; - _ptr_osal_mdc_dev->id.vendor = HAL_MTK_VENDOR_ID; - _ptr_osal_mdc_dev->id.revision = HAL_REVISION_ID_E2; - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_osal_mdc_removeI2cDevice(void) -{ - /* I2C interface will be removed in BSP. */ - return (NPS_E_OK); -} - -/* --------------------------------------------------------------------------- PCI interface */ -#else - -static NPS_ERROR_NO_T -_osal_mdc_getPciMmioInfo( - struct pci_dev *pdev, - UI32_T **pptr_base_addr) -{ - NPS_ERROR_NO_T rc = NPS_E_OTHERS; - NPS_ADDR_T phy_addr; - UI32_T reg_space_sz; - - phy_addr = pci_resource_start(pdev, OSAL_MDC_PCI_BAR0_OFFSET); - reg_space_sz = pci_resource_len(pdev, OSAL_MDC_PCI_BAR0_OFFSET); - - if (0 == pci_request_region(pdev, OSAL_MDC_PCI_BAR0_OFFSET, OSAL_MDC_DRIVER_NAME)) - { - *pptr_base_addr = ioremap_nocache(phy_addr, reg_space_sz); - if (NULL != *pptr_base_addr) - { - rc = NPS_E_OK; - } - } - return (rc); -} - -NPS_ERROR_NO_T -osal_mdc_readPciReg( - const UI32_T unit, - const UI32_T offset, - UI32_T *ptr_data, - const UI32_T len) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - UI32_T idx; - UI32_T count; - volatile UI32_T *ptr_base_addr = _osal_mdc_cb.dev[unit].ptr_mmio_virt_addr; - - if (NULL != ptr_base_addr) - { - if (OSAL_MDC_PCI_BUS_WIDTH == len) - { - *ptr_data = *((UI32_T *)((NPS_HUGE_T)ptr_base_addr + offset)); - } - else - { - if (0 == (len % OSAL_MDC_PCI_BUS_WIDTH)) - { - count = len / OSAL_MDC_PCI_BUS_WIDTH; - for (idx = 0; idx < count; idx++) - { - *(ptr_data + idx) = *((UI32_T *)((NPS_HUGE_T)ptr_base_addr + offset + idx * 4)); - } - } - else - { - rc = NPS_E_OTHERS; - } - } - } - else - { - rc = NPS_E_NOT_INITED; - } - - return (rc); -} - -NPS_ERROR_NO_T -osal_mdc_writePciReg( - const UI32_T unit, - const UI32_T offset, - const UI32_T *ptr_data, - const UI32_T len) -{ - UI32_T idx; - UI32_T count; - volatile UI32_T *ptr_base_addr = _osal_mdc_cb.dev[unit].ptr_mmio_virt_addr; - NPS_ERROR_NO_T rc = NPS_E_OK; - - if (NULL != ptr_base_addr) - { - if (OSAL_MDC_PCI_BUS_WIDTH == len) - { - *((UI32_T *)((NPS_HUGE_T)ptr_base_addr + offset)) = *ptr_data; - } - else - { - if (0 == (len % OSAL_MDC_PCI_BUS_WIDTH)) - { - count = len / OSAL_MDC_PCI_BUS_WIDTH; - for (idx = 0; idx < count; idx++) - { - *((UI32_T *)((NPS_HUGE_T)ptr_base_addr + offset + idx * 4)) = *(ptr_data + idx); - } - } - else - { - rc = NPS_E_OTHERS; - } - } - } - else - { - rc = NPS_E_NOT_INITED; - } - - return (rc); -} - -static int -_osal_mdc_probePciCallback( - struct pci_dev *pdev, - const struct pci_device_id *id) -{ - int linux_rc; - UI16_T device_id; - UI16_T vendor_id; - UI8_T revision_id; - NPS_ERROR_NO_T rc = NPS_E_OK; - - linux_rc = pci_enable_device(pdev); - if (0 == linux_rc) - { - _ptr_osal_mdc_dev->if_type = AML_DEV_TYPE_PCI; - - pci_read_config_word(pdev, PCI_DEVICE_ID, &device_id); - pci_read_config_word(pdev, PCI_VENDOR_ID, &vendor_id); - pci_read_config_byte(pdev, PCI_REVISION_ID, &revision_id); - - _ptr_osal_mdc_dev->id.device = (UI32_T)device_id; - _ptr_osal_mdc_dev->id.vendor = (UI32_T)vendor_id; - _ptr_osal_mdc_dev->id.revision = (UI32_T)revision_id; - -#if defined(NPS_LINUX_KERNEL_MODE) - _ptr_osal_mdc_dev->access.read_callback = osal_mdc_readPciReg; - _ptr_osal_mdc_dev->access.write_callback = osal_mdc_writePciReg; -#endif - - rc = _osal_mdc_getPciMmioInfo(pdev, &_osal_mdc_cb.dev[_osal_mdc_cb.dev_num].ptr_mmio_virt_addr); - if (NPS_E_OK == rc) - { - /* Save the database to pdev structure for system callback to release recource, - * such like disconnecting ISR etc. - */ - _osal_mdc_cb.dev[_osal_mdc_cb.dev_num].irq = pdev->irq; - _osal_mdc_cb.dev[_osal_mdc_cb.dev_num].ptr_pci_dev = pdev; - _osal_mdc_cb.dev[_osal_mdc_cb.dev_num].unit = _osal_mdc_cb.dev_num; - - pci_set_drvdata(pdev, &_osal_mdc_cb.dev[_osal_mdc_cb.dev_num]); - - /* To set the bus master bit on device to enable the DMA transaction from PCIe EP to RC - * The bus master bit gets cleared when pci_disable_device() is called - */ - pci_set_master(pdev); - -#if !defined(NPS_EN_DMA_RESERVED) - if (NULL == _osal_mdc_cb.dma_info.ptr_dma_dev) - { - /* This variable is for dma_alloc_coherent */ - _osal_mdc_cb.dma_info.ptr_dma_dev = &pdev->dev; - } -#endif - _osal_mdc_cb.dev_num++; - _ptr_osal_mdc_dev++; - } - } - else - { - OSAL_MDC_ERR("enable pci dev failed, linux_rc=%d\n", linux_rc); - } - - return (0); -} - -static void -_osal_mdc_removePciCallback( - struct pci_dev *pdev) -{ - OSAL_MDC_DEV_T *ptr_dev = (OSAL_MDC_DEV_T *)pci_get_drvdata(pdev); - - iounmap(ptr_dev->ptr_mmio_virt_addr); - pci_release_region(pdev, OSAL_MDC_PCI_BAR0_OFFSET); - pci_disable_device(pdev); - _osal_mdc_cb.dev_num--; -} - -static struct pci_device_id _osal_mdc_id_table[] = -{ - {PCI_DEVICE(HAL_MTK_VENDOR_ID, PCI_ANY_ID)}, - {PCI_DEVICE(HAL_NP_VENDOR_ID, PCI_ANY_ID)}, -}; - -static struct pci_driver _osal_mdc_pci_driver = -{ - .name = OSAL_MDC_DRIVER_NAME, - .id_table = _osal_mdc_id_table, - .probe = _osal_mdc_probePciCallback, - .remove = _osal_mdc_removePciCallback, -}; - -static NPS_ERROR_NO_T -_osal_mdc_probePciDevice(void) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - - if (pci_register_driver(&_osal_mdc_pci_driver) < 0) - { - OSAL_MDC_ERR("Cannot find PCI device\n"); - rc = NPS_E_OTHERS; - } - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_removePciDevice(void) -{ - pci_unregister_driver(&_osal_mdc_pci_driver); - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_osal_mdc_maskStatus( - const UI32_T unit) -{ - struct pci_dev *ptr_ep_dev = _osal_mdc_cb.dev[unit].ptr_pci_dev; - struct pci_dev *ptr_rc_dev = ptr_ep_dev->bus->self; - int ext_cap = 0; - UI32_T data_32 = 0; - - ext_cap = pci_find_ext_capability(ptr_rc_dev, 0x1); - if (0 != ext_cap) - { - /* Mask */ - pci_read_config_dword(ptr_rc_dev, ext_cap + 0x8, &data_32); - data_32 |= 0x20; - pci_write_config_dword(ptr_rc_dev, ext_cap + 0x8, data_32); - } - - return NPS_E_OK; -} - -static NPS_ERROR_NO_T -_osal_mdc_clearStatus( - const UI32_T unit) -{ - struct pci_dev *ptr_ep_dev = _osal_mdc_cb.dev[unit].ptr_pci_dev; - struct pci_dev *ptr_rc_dev = ptr_ep_dev->bus->self; - int ext_cap = 0; - UI32_T data_32 = 0; - - ext_cap = pci_find_ext_capability(ptr_rc_dev, 0x1); - if (0 != ext_cap) - { - /* Clear */ - pci_write_config_word(ptr_rc_dev, ptr_rc_dev->pcie_cap + 0xa, 0x04); - pci_write_config_word(ptr_rc_dev, ptr_rc_dev->pcie_cap + 0x12, 0x8000); - pci_write_config_dword(ptr_rc_dev, ext_cap + 0x4, 0x20); - - /* UnMask */ - pci_read_config_dword(ptr_rc_dev, ext_cap + 0x8, &data_32); - data_32 &= ~0x20; - pci_write_config_dword(ptr_rc_dev, ext_cap + 0x8, data_32); - } - - return NPS_E_OK; -} - -static NPS_ERROR_NO_T -_osal_mdc_savePciConfig( - const UI32_T unit) -{ - struct pci_dev *ptr_dev = _osal_mdc_cb.dev[unit].ptr_pci_dev; - NPS_ERROR_NO_T rc = NPS_E_OK; - - rc = _osal_mdc_maskStatus(unit); - - if (NPS_E_OK == rc) - { - pci_save_state(ptr_dev); - } - - return rc; -} - -static NPS_ERROR_NO_T -_osal_mdc_restorePciConfig( - const UI32_T unit) -{ -#define OSAL_MDC_PCI_PRESENT_POLL_CNT (100) -#define OSAL_MDC_PCI_PRESENT_POLL_INTERVAL (10) /* ms */ - - struct pci_dev *ptr_dev = _osal_mdc_cb.dev[unit].ptr_pci_dev; - UI32_T poll_cnt = 0; - NPS_ERROR_NO_T rc = NPS_E_OK; - - /* standard: at least 100ms for link recovery */ - msleep(100); - - /* make sure pci device is there before restoring the config space */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0) - while ((0 == pci_device_is_present(ptr_dev)) && -#else - while ((0 == pci_dev_present(_osal_mdc_id_table)) && -#endif - (poll_cnt < OSAL_MDC_PCI_PRESENT_POLL_CNT)) - { - msleep(OSAL_MDC_PCI_PRESENT_POLL_INTERVAL); - poll_cnt++; - } - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0) - if (1 == pci_device_is_present(ptr_dev)) -#else - if (1 == pci_dev_present(_osal_mdc_id_table)) -#endif - { - pci_restore_state(ptr_dev); - rc = NPS_E_OK; - } - else - { - OSAL_MDC_ERR("detect pci device failed\n"); - rc = NPS_E_OTHERS; - } - - if (NPS_E_OK == rc) - { - rc = _osal_mdc_clearStatus(unit); - } - - return (rc); -} - -#endif /* End of AML_EN_I2C */ - -/* --------------------------------------------------------------------------- DMA */ -#if defined(NPS_LINUX_KERNEL_MODE) - -static NPS_ERROR_NO_T -_osal_mdc_searchDmaVirtAddr( - OSAL_MDC_LIST_T *ptr_dma_list, - const void *ptr_virt_addr, - OSAL_MDC_LIST_NODE_T **pptr_node, - OSAL_MDC_DMA_NODE_T **pptr_node_data) -{ - OSAL_MDC_LIST_NODE_T *ptr_curr_node; - OSAL_MDC_DMA_NODE_T *ptr_curr_node_data; - NPS_ERROR_NO_T rc; - - rc = osal_mdc_list_locateHead(ptr_dma_list, &ptr_curr_node); - while (NPS_E_OK == rc) - { - rc = osal_mdc_list_getNodeData(ptr_dma_list, ptr_curr_node, (void **)&ptr_curr_node_data); - if (NPS_E_OK == rc) - { - if (ptr_curr_node_data->ptr_virt_addr == ptr_virt_addr) - { - *pptr_node = ptr_curr_node; - *pptr_node_data = ptr_curr_node_data; - break; - } - rc = osal_mdc_list_next(ptr_dma_list, ptr_curr_node, &ptr_curr_node); - } - } - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_destroyDmaNodeList( - OSAL_MDC_DMA_INFO_T *ptr_dma_info) -{ - OSAL_MDC_LIST_T *ptr_dma_list = (OSAL_MDC_LIST_T *)ptr_dma_info->ptr_dma_list; - OSAL_MDC_LIST_NODE_T *ptr_curr_node = NULL; - OSAL_MDC_DMA_NODE_T *ptr_curr_node_data = NULL; - NPS_ERROR_NO_T rc = NPS_E_NOT_INITED; - - if (NULL != ptr_dma_list) - { - rc = osal_mdc_list_locateHead(ptr_dma_list, &ptr_curr_node); - while (NPS_E_OK == rc) - { - rc = osal_mdc_list_getNodeData(ptr_dma_list, ptr_curr_node, (void **)&ptr_curr_node_data); - if ((NPS_E_OK == rc) && (NULL != ptr_curr_node_data)) - { - rc = osal_mdc_list_deleteByData(ptr_dma_list, ptr_curr_node_data); - if (NPS_E_OK == rc) - { - kfree(ptr_curr_node_data); - } - } - rc = osal_mdc_list_locateHead(ptr_dma_list, &ptr_curr_node); - } - rc = osal_mdc_list_destroy(ptr_dma_list, NULL); - if (NPS_E_OK == rc) - { - ptr_dma_info->ptr_dma_list = NULL; - } - } - return (rc); -} - -#endif /* End of NPS_LINUX_KERNEL_MODE */ - -#if defined(NPS_EN_DMA_RESERVED) - -#if defined(NPS_LINUX_KERNEL_MODE) - -#if defined(OSAL_MDC_EN_TEST) -static NPS_ERROR_NO_T -_osal_mdc_dumpRsrvDmaList(void) -{ - OSAL_MDC_DMA_INFO_T *ptr_dma_info = &_osal_mdc_cb.dma_info; - OSAL_MDC_LIST_NODE_T *ptr_curr_node; - OSAL_MDC_DMA_NODE_T *ptr_curr_node_data; - UI32_T node = 0; - NPS_ERROR_NO_T rc = NPS_E_OK; - - rc = osal_mdc_list_locateHead((OSAL_MDC_LIST_T *)ptr_dma_info->ptr_dma_list, - &ptr_curr_node); - while (NPS_E_OK == rc) - { - rc = osal_mdc_list_getNodeData((OSAL_MDC_LIST_T *)ptr_dma_info->ptr_dma_list, - ptr_curr_node, (void **)&ptr_curr_node_data); - if (NPS_E_OK == rc) - { - OSAL_MDC_ERR( - "node %d. virt addr=%p, phy addr=%p, size=%d, avbl=%d\n", node, - ptr_curr_node_data->ptr_virt_addr, ptr_curr_node_data->phy_addr, - ptr_curr_node_data->size, ptr_curr_node_data->available); - } - rc = osal_mdc_list_next((OSAL_MDC_LIST_T *)ptr_dma_info->ptr_dma_list, - ptr_curr_node, &ptr_curr_node); - node++; - } - return (rc); -} -#endif - -static NPS_ERROR_NO_T -_osal_mdc_createRsrvDmaNodeList( - OSAL_MDC_DMA_INFO_T *ptr_dma_info) -{ - OSAL_MDC_DMA_NODE_T *ptr_node_data; - NPS_ERROR_NO_T rc; - - rc = osal_mdc_list_create(OSAL_MDC_DMA_LIST_SZ_UNLIMITED, - OSAL_MDC_LIST_TYPE_DOUBLE, - OSAL_MDC_DMA_LIST_NAME, - (OSAL_MDC_LIST_T **)&ptr_dma_info->ptr_dma_list); - if (NPS_E_OK == rc) - { - /* The first node, which contains all of the reserved memory */ - ptr_node_data = kmalloc(sizeof(OSAL_MDC_DMA_NODE_T), GFP_KERNEL); - if (NULL != ptr_node_data) - { - ptr_node_data->ptr_virt_addr = ptr_dma_info->ptr_rsrv_virt_addr; - ptr_node_data->phy_addr = ptr_dma_info->rsrv_phy_addr; - ptr_node_data->size = ptr_dma_info->rsrv_size; - ptr_node_data->available = TRUE; - rc = osal_mdc_list_insertToHead((OSAL_MDC_LIST_T *)ptr_dma_info->ptr_dma_list, - ptr_node_data); - } - else - { - rc = NPS_E_NO_MEMORY; - } - } - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_searchAvblRsrvDmaNode( - OSAL_MDC_LIST_T *ptr_dma_list, - const UI32_T size, - OSAL_MDC_LIST_NODE_T **pptr_avbl_node) -{ - OSAL_MDC_LIST_NODE_T *ptr_curr_node; - OSAL_MDC_DMA_NODE_T *ptr_curr_node_data; - NPS_ERROR_NO_T rc; - - rc = osal_mdc_list_locateHead(ptr_dma_list, &ptr_curr_node); - while (NPS_E_OK == rc) - { - rc = osal_mdc_list_getNodeData(ptr_dma_list, ptr_curr_node, (void **)&ptr_curr_node_data); - if (NPS_E_OK == rc) - { - if ((TRUE == ptr_curr_node_data->available) && (ptr_curr_node_data->size >= size)) - { - *pptr_avbl_node = ptr_curr_node; - break; - } - } - rc = osal_mdc_list_next(ptr_dma_list, ptr_curr_node, &ptr_curr_node); - } - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_splitRsrvDmaNodes( - OSAL_MDC_LIST_T *ptr_dma_list, - OSAL_MDC_LIST_NODE_T *ptr_ori_node, - const UI32_T size, - OSAL_MDC_DMA_NODE_T **pptr_new_node_data) -{ - OSAL_MDC_DMA_NODE_T *ptr_ori_node_data; - NPS_ERROR_NO_T rc; - - rc = osal_mdc_list_getNodeData(ptr_dma_list, ptr_ori_node, (void **)&ptr_ori_node_data); - - if (NPS_E_OK == rc) - { - *pptr_new_node_data = kmalloc(sizeof(OSAL_MDC_DMA_NODE_T), GFP_KERNEL); - - /* Create a new node */ - (*pptr_new_node_data)->size = size; - (*pptr_new_node_data)->phy_addr = ptr_ori_node_data->phy_addr; - (*pptr_new_node_data)->ptr_virt_addr = ptr_ori_node_data->ptr_virt_addr; - (*pptr_new_node_data)->available = TRUE; - - /* Update the original node */ - ptr_ori_node_data->size -= size; - ptr_ori_node_data->phy_addr += size; - ptr_ori_node_data->ptr_virt_addr = - (void *)((NPS_HUGE_T)ptr_ori_node_data->ptr_virt_addr + (NPS_HUGE_T)size); - - rc = osal_mdc_list_insertBefore(ptr_dma_list, ptr_ori_node, (void *)*pptr_new_node_data); - if (NPS_E_OK != rc) - { - OSAL_MDC_ERR("insert rsrv dma node to list failed, size=%d, rc=%d\n", size, rc); - /* Recovery */ - ptr_ori_node_data->size += size; - ptr_ori_node_data->phy_addr -= size; - ptr_ori_node_data->ptr_virt_addr = - (void *)((NPS_HUGE_T)ptr_ori_node_data->ptr_virt_addr - (NPS_HUGE_T)size); - kfree(*pptr_new_node_data); - } - } - return (rc); -} - -static void * -_osal_mdc_allocRsrvDmaMem( - OSAL_MDC_DMA_INFO_T *ptr_dma_info, - const UI32_T size) -{ - OSAL_MDC_LIST_T *ptr_dma_list = (OSAL_MDC_LIST_T *)ptr_dma_info->ptr_dma_list; - OSAL_MDC_LIST_NODE_T *ptr_node = NULL; - OSAL_MDC_DMA_NODE_T *ptr_node_data; - OSAL_MDC_DMA_NODE_T *ptr_new_node_data; - void *ptr_virt_addr = NULL; - NPS_ERROR_NO_T rc; - - rc = _osal_mdc_searchAvblRsrvDmaNode(ptr_dma_list, size, &ptr_node); - if (NPS_E_OK == rc) - { - rc = osal_mdc_list_getNodeData(ptr_dma_list, ptr_node, (void **)&ptr_node_data); - if (NPS_E_OK == rc) - { - /* If the node size just fit the user's requirement, just give it to user */ - if (ptr_node_data->size == size) - { - ptr_node_data->available = FALSE; - ptr_virt_addr = ptr_node_data->ptr_virt_addr; - } - /* or split a new node with user required size. */ - else - { - rc = _osal_mdc_splitRsrvDmaNodes(ptr_dma_list, ptr_node, size, &ptr_new_node_data); - if (NPS_E_OK == rc) - { - ptr_new_node_data->available = FALSE; - ptr_virt_addr = ptr_new_node_data->ptr_virt_addr; - } - } - } - } - return (ptr_virt_addr); -} - -static NPS_ERROR_NO_T -_osal_mdc_mergeTwoRsrvDmaNodes( - OSAL_MDC_LIST_T *ptr_dma_list, - OSAL_MDC_DMA_NODE_T *ptr_first_node_data, - OSAL_MDC_DMA_NODE_T *ptr_second_node_data) -{ - ptr_first_node_data->size += ptr_second_node_data->size; - - osal_mdc_list_deleteByData(ptr_dma_list, ptr_second_node_data); - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_osal_mdc_mergeRsrvDmaNodes( - OSAL_MDC_LIST_T *ptr_dma_list, - OSAL_MDC_LIST_NODE_T *ptr_curr_node) -{ - OSAL_MDC_LIST_NODE_T *ptr_prev_node; - OSAL_MDC_LIST_NODE_T *ptr_next_node; - OSAL_MDC_DMA_NODE_T *ptr_curr_node_data; - OSAL_MDC_DMA_NODE_T *ptr_prev_node_data; - OSAL_MDC_DMA_NODE_T *ptr_next_node_data; - NPS_ERROR_NO_T rc; - - rc = osal_mdc_list_getNodeData(ptr_dma_list, ptr_curr_node, (void **)&ptr_curr_node_data); - if (NPS_E_OK == rc) - { - /* First, check if the previous node is available */ - rc = osal_mdc_list_prev(ptr_dma_list, ptr_curr_node, &ptr_prev_node); - if (NPS_E_OK == rc) - { - osal_mdc_list_getNodeData(ptr_dma_list, ptr_prev_node, (void **)&ptr_prev_node_data); - if (TRUE == ptr_prev_node_data->available) - { - _osal_mdc_mergeTwoRsrvDmaNodes(ptr_dma_list, ptr_prev_node_data, ptr_curr_node_data); - ptr_curr_node = ptr_prev_node; - ptr_curr_node_data = ptr_prev_node_data; - } - } - - /* then, check if the next node is available */ - rc = osal_mdc_list_next(ptr_dma_list, ptr_curr_node, &ptr_next_node); - if (NPS_E_OK == rc) - { - rc = osal_mdc_list_getNodeData(ptr_dma_list, ptr_next_node, (void **)&ptr_next_node_data); - if (NPS_E_OK == rc) - { - if (TRUE == ptr_next_node_data->available) - { - _osal_mdc_mergeTwoRsrvDmaNodes(ptr_dma_list, ptr_curr_node_data, ptr_next_node_data); - } - } - } - } - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_freeRsrvDmaMem( - OSAL_MDC_DMA_INFO_T *ptr_dma_info, - void *ptr_virt_addr) -{ - OSAL_MDC_LIST_T *ptr_dma_list = (OSAL_MDC_LIST_T *)ptr_dma_info->ptr_dma_list; - OSAL_MDC_LIST_NODE_T *ptr_node = NULL; - OSAL_MDC_DMA_NODE_T *ptr_node_data = NULL; - NPS_ERROR_NO_T rc; - - rc = _osal_mdc_searchDmaVirtAddr(ptr_dma_list, ptr_virt_addr, &ptr_node, &ptr_node_data); - if (NPS_E_OK == rc) - { - ptr_node_data->available = TRUE; - _osal_mdc_mergeRsrvDmaNodes(ptr_dma_list, ptr_node); - } - return (rc); -} - -#endif /* End of NPS_LINUX_KERNEL_MODE */ - -static NPS_ERROR_NO_T -_osal_mdc_initRsrvDmaMem( - OSAL_MDC_DMA_INFO_T *ptr_dma_info) -{ - struct resource *ptr_res; - NPS_ERROR_NO_T rc = NPS_E_OK; - - ptr_dma_info->rsrv_size = (NPS_ADDR_T)NPS_DMA_RESERVED_SZ * 1024 * 1024; - ptr_dma_info->rsrv_phy_addr = (NPS_ADDR_T)NPS_OS_MEMORY_SZ * 1024 * 1024; - ptr_res = request_mem_region(ptr_dma_info->rsrv_phy_addr, - ptr_dma_info->rsrv_size, "nps_rsrv_mem"); - if (NULL != ptr_res) - { -#if defined(OSAL_MDC_DMA_RESERVED_MEM_CACHEABLE) - ptr_dma_info->ptr_rsrv_virt_addr = ioremap(ptr_dma_info->rsrv_phy_addr, - ptr_dma_info->rsrv_size); -#else - ptr_dma_info->ptr_rsrv_virt_addr = ioremap_nocache(ptr_dma_info->rsrv_phy_addr, - ptr_dma_info->rsrv_size); -#endif - if (NULL == ptr_dma_info->ptr_rsrv_virt_addr) - { -#if defined(NPS_EN_64BIT_ADDR) || defined(NPS_EN_HOST_64_BIT_BIG_ENDIAN) || defined(NPS_EN_HOST_64_BIT_LITTLE_ENDIAN) - OSAL_MDC_ERR( - "ioremap_nocache() failed, phy addr=0x%llx, size=%llu\n", - ptr_dma_info->rsrv_phy_addr, ptr_dma_info->rsrv_size); -#else - OSAL_MDC_ERR( - "ioremap_nocache() failed, phy addr=0x%x, size=%u\n", - ptr_dma_info->rsrv_phy_addr, ptr_dma_info->rsrv_size); -#endif - rc = NPS_E_OTHERS; - } - } - else - { -#if defined(NPS_EN_64BIT_ADDR) || defined(NPS_EN_HOST_64_BIT_BIG_ENDIAN) || defined(NPS_EN_HOST_64_BIT_LITTLE_ENDIAN) - OSAL_MDC_ERR( - "request_mem_region() failed, phy addr=0x%llx, size=%llu\n", - ptr_dma_info->rsrv_phy_addr, ptr_dma_info->rsrv_size); -#else - OSAL_MDC_ERR( - "request_mem_region() failed, phy addr=0x%x, size=%u\n", - ptr_dma_info->rsrv_phy_addr, ptr_dma_info->rsrv_size); -#endif - rc = NPS_E_OTHERS; - } - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_deinitRsrvDmaMem( - OSAL_MDC_DMA_INFO_T *ptr_dma_info) -{ - if (NULL != ptr_dma_info->ptr_rsrv_virt_addr) - { - iounmap(ptr_dma_info->ptr_rsrv_virt_addr); - } - if (0x0 != ptr_dma_info->rsrv_phy_addr) - { - release_mem_region(ptr_dma_info->rsrv_phy_addr, - ptr_dma_info->rsrv_size); - } - return (NPS_E_OK); -} - - -#else /* Else of NPS_EN_DMA_RESERVED */ - - -#if defined(NPS_LINUX_KERNEL_MODE) - -#if defined(OSAL_MDC_EN_TEST) -static NPS_ERROR_NO_T -_osal_mdc_dumpSysDmaList(void) -{ - OSAL_MDC_DMA_INFO_T *ptr_dma_info = &_osal_mdc_cb.dma_info; - OSAL_MDC_LIST_NODE_T *ptr_curr_node; - OSAL_MDC_DMA_NODE_T *ptr_curr_node_data; - UI32_T node = 0; - NPS_ERROR_NO_T rc = NPS_E_OK; - - rc = osal_mdc_list_locateHead((OSAL_MDC_LIST_T *)ptr_dma_info->ptr_dma_list, - &ptr_curr_node); - while (NPS_E_OK == rc) - { - rc = osal_mdc_list_getNodeData((OSAL_MDC_LIST_T *)ptr_dma_info->ptr_dma_list, - ptr_curr_node, (void **)&ptr_curr_node_data); - if (NPS_E_OK == rc) - { - OSAL_MDC_ERR( - "node %d. virt addr=%p, phy addr=%p, size=%d\n", node, - ptr_curr_node_data->ptr_virt_addr, ptr_curr_node_data->phy_addr, - ptr_curr_node_data->size); - } - - rc = osal_mdc_list_next((OSAL_MDC_LIST_T *)ptr_dma_info->ptr_dma_list, - ptr_curr_node, &ptr_curr_node); - node++; - - } - return (rc); -} -#endif - -static NPS_ERROR_NO_T -_osal_mdc_createSysDmaNodeList( - OSAL_MDC_DMA_INFO_T *ptr_dma_info) -{ - NPS_ERROR_NO_T rc; - - rc = osal_mdc_list_create(OSAL_MDC_DMA_LIST_SZ_UNLIMITED, - OSAL_MDC_LIST_TYPE_SINGLY, - OSAL_MDC_DMA_LIST_NAME, - (OSAL_MDC_LIST_T **)&ptr_dma_info->ptr_dma_list); - return (rc); -} -#if !defined(NPS_LAMP) - -static void * -_osal_mdc_allocSysDmaMem( - OSAL_MDC_DMA_INFO_T *ptr_dma_info, - const UI32_T size) -{ - dma_addr_t phy_addr; - OSAL_MDC_DMA_NODE_T *ptr_node_data; - void *ptr_virt_addr = NULL; - NPS_ERROR_NO_T rc = NPS_E_OK; - - ptr_virt_addr = dma_alloc_coherent(ptr_dma_info->ptr_dma_dev, size, &phy_addr, GFP_ATOMIC); - if (NULL != ptr_virt_addr) - { - ptr_node_data = kmalloc(sizeof(OSAL_MDC_DMA_NODE_T), GFP_KERNEL); - ptr_node_data->phy_addr = (NPS_ADDR_T)phy_addr; - ptr_node_data->ptr_virt_addr = ptr_virt_addr; - ptr_node_data->size = size; - - rc = osal_mdc_list_insertToHead((OSAL_MDC_LIST_T *)ptr_dma_info->ptr_dma_list, ptr_node_data); - if (NPS_E_OK != rc) - { - kfree(ptr_node_data); - dma_free_coherent(ptr_dma_info->ptr_dma_dev, size, - ptr_virt_addr, phy_addr); - ptr_virt_addr = NULL; - } - } - return (ptr_virt_addr); -} - -static NPS_ERROR_NO_T -_osal_mdc_freeSysDmaMem( - OSAL_MDC_DMA_INFO_T *ptr_dma_info, - void *ptr_virt_addr) -{ - OSAL_MDC_LIST_NODE_T *ptr_node = NULL; - OSAL_MDC_DMA_NODE_T *ptr_node_data = NULL; - NPS_ERROR_NO_T rc; - - rc = _osal_mdc_searchDmaVirtAddr((OSAL_MDC_LIST_T *)ptr_dma_info->ptr_dma_list, - ptr_virt_addr, &ptr_node, &ptr_node_data); - if (NPS_E_OK == rc) - { - dma_free_coherent(ptr_dma_info->ptr_dma_dev, ptr_node_data->size, - ptr_virt_addr, ptr_node_data->phy_addr); - - osal_mdc_list_deleteByData((OSAL_MDC_LIST_T *)ptr_dma_info->ptr_dma_list, - ptr_node_data); - kfree(ptr_node_data); - } - return (rc); -} -#endif -#endif /* End of NPS_LINUX_KERNEL_MODE */ - -#endif /* End of NPS_EN_DMA_RESERVED */ - -#if defined(NPS_LINUX_KERNEL_MODE) - -void * -osal_mdc_allocDmaMem( - const UI32_T size) -{ - void *ptr_virt_addr = NULL; - -#if defined(NPS_LAMP) - ptr_virt_addr = osal_alloc(size); -#else - OSAL_MDC_DMA_INFO_T *ptr_dma_info = &_osal_mdc_cb.dma_info; - osal_takeSemaphore(&ptr_dma_info->sema, NPS_SEMAPHORE_WAIT_FOREVER); - -#if defined(NPS_EN_DMA_RESERVED) - ptr_virt_addr = _osal_mdc_allocRsrvDmaMem(ptr_dma_info, size); -#else - ptr_virt_addr = _osal_mdc_allocSysDmaMem(ptr_dma_info, size); -#endif - - osal_giveSemaphore(&ptr_dma_info->sema); -#endif - - return ptr_virt_addr; -} - -NPS_ERROR_NO_T -osal_mdc_freeDmaMem( - void *ptr_virt_addr) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - -#if defined(NPS_LAMP) - osal_free(ptr_virt_addr); -#else - OSAL_MDC_DMA_INFO_T *ptr_dma_info = &_osal_mdc_cb.dma_info; - - osal_takeSemaphore(&ptr_dma_info->sema, NPS_SEMAPHORE_WAIT_FOREVER); - -#if defined(NPS_EN_DMA_RESERVED) - rc = _osal_mdc_freeRsrvDmaMem(ptr_dma_info, ptr_virt_addr); -#else - - rc = _osal_mdc_freeSysDmaMem(ptr_dma_info, ptr_virt_addr); -#endif - osal_giveSemaphore(&ptr_dma_info->sema); - - if (NPS_E_OK != rc) - { - OSAL_MDC_ERR("free dma mem failed, virt addr=%p\n", ptr_virt_addr); - } -#endif - - return (rc); -} - -NPS_ERROR_NO_T -osal_mdc_convertPhyToVirt( - const NPS_ADDR_T phy_addr, - void **pptr_virt_addr) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - -#if defined(NPS_EN_DMA_RESERVED) - OSAL_MDC_DMA_INFO_T *ptr_dma_info = &_osal_mdc_cb.dma_info; - NPS_HUGE_T rsrv_virt_base = (NPS_HUGE_T)ptr_dma_info->ptr_rsrv_virt_addr; - NPS_ADDR_T rsrv_phy_base = ptr_dma_info->rsrv_phy_addr; -#endif - -#if defined(NPS_EN_DMA_RESERVED) - *pptr_virt_addr = (void *)(rsrv_virt_base + (NPS_HUGE_T)(phy_addr - rsrv_phy_base)); -#else - *pptr_virt_addr = NULL; - *pptr_virt_addr = phys_to_virt(phy_addr); - rc = (NULL == *pptr_virt_addr) ? (NPS_E_ENTRY_NOT_FOUND) : (NPS_E_OK); -#endif - -#if defined(AML_EN_CUSTOM_DMA_ADDR) - if (NPS_E_OK != rc) - { - /* Here the user may invoke the API for their private DMA - * address conversion. - */ - } -#endif - return (rc); -} - -NPS_ERROR_NO_T -osal_mdc_convertVirtToPhy( - void *ptr_virt_addr, - NPS_ADDR_T *ptr_phy_addr) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - -#if defined(NPS_EN_DMA_RESERVED) - OSAL_MDC_DMA_INFO_T *ptr_dma_info = &_osal_mdc_cb.dma_info; - NPS_HUGE_T rsrv_virt_base = (NPS_HUGE_T)ptr_dma_info->ptr_rsrv_virt_addr; - NPS_ADDR_T rsrv_phy_base = ptr_dma_info->rsrv_phy_addr; -#endif - -#if defined(NPS_EN_DMA_RESERVED) - *ptr_phy_addr = (NPS_ADDR_T)((NPS_HUGE_T)rsrv_phy_base - + (NPS_HUGE_T)ptr_virt_addr - rsrv_virt_base); -#else - *ptr_phy_addr = 0x0; - *ptr_phy_addr = virt_to_phys(ptr_virt_addr); - rc = (0x0 == *ptr_phy_addr) ? (NPS_E_ENTRY_NOT_FOUND) : (NPS_E_OK); -#endif - -#if defined(AML_EN_CUSTOM_DMA_ADDR) - if (NPS_E_OK != rc) - { - /* Here the user may invoke the API for their private DMA - * address conversion. - */ - } -#endif - return (rc); -} - -NPS_ERROR_NO_T -osal_mdc_initDmaMem(void) -{ - OSAL_MDC_DMA_INFO_T *ptr_dma_info = &_osal_mdc_cb.dma_info; - NPS_ERROR_NO_T rc = NPS_E_OK; - - rc = osal_createSemaphore(OSAL_MDC_DMA_SEMAPHORE_NAME, - NPS_SEMAPHORE_BINARY, &ptr_dma_info->sema); - if (NPS_E_OK == rc) - { -#if defined(NPS_EN_DMA_RESERVED) - rc = _osal_mdc_initRsrvDmaMem(ptr_dma_info); - if (NPS_E_OK == rc) - { - rc = _osal_mdc_createRsrvDmaNodeList(ptr_dma_info); - } -#else - rc = _osal_mdc_createSysDmaNodeList(ptr_dma_info); -#endif - } - return (rc); -} - -NPS_ERROR_NO_T -osal_mdc_deinitDmaMem(void) -{ - OSAL_MDC_DMA_INFO_T *ptr_dma_info = &_osal_mdc_cb.dma_info; - - /* Common function for both reserved/system memory. */ - _osal_mdc_destroyDmaNodeList(ptr_dma_info); - -#if defined(NPS_EN_DMA_RESERVED) - _osal_mdc_deinitRsrvDmaMem(ptr_dma_info); -#endif - - osal_destroySemaphore(&ptr_dma_info->sema); - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_mdc_flushCache( - void *ptr_virt_addr, - const UI32_T size) -{ -#if defined(CONFIG_NOT_COHERENT_CACHE) || defined(CONFIG_DMA_NONCOHERENT) - -#if defined(dma_cache_wback_inv) - dma_cache_wback_inv((NPS_HUGE_T)ptr_virt_addr, size); -#else - dma_cache_sync(NULL, ptr_virt_addr, size, DMA_TO_DEVICE); -#endif - -#endif - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_mdc_invalidateCache( - void *ptr_virt_addr, - const UI32_T size) -{ -#if defined(CONFIG_NOT_COHERENT_CACHE) || defined(CONFIG_DMA_NONCOHERENT) - -#if defined(dma_cache_wback_inv) - dma_cache_wback_inv((NPS_HUGE_T)ptr_virt_addr, size); -#else - dma_cache_sync(NULL, ptr_virt_addr, size, DMA_FROM_DEVICE); -#endif - -#endif - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_mdc_savePciConfig( - const UI32_T unit) -{ - return _osal_mdc_savePciConfig(unit); -} - -NPS_ERROR_NO_T -osal_mdc_restorePciConfig( - const UI32_T unit) -{ - return _osal_mdc_restorePciConfig(unit); -} - -#endif /* End of NPS_LINUX_KERNEL_MODE */ - -/* --------------------------------------------------------------------------- Interrupt */ -#if defined(NPS_LINUX_USER_MODE) -static UI32_T _osal_mdc_isr_init_bitmap = 0; /* To record the dev request_irq */ -static UI32_T _osal_mdc_isr_dev_bitmap; /* To record the dev bitmap */ -static spinlock_t _osal_mdc_isr_dev_bitmap_lock; -static wait_queue_head_t _osal_mdc_isr_wait; -static UI32_T _osal_mdc_isr_mask_addr; -static UI32_T _osal_mdc_isr_mask_val; - - -static inline NPS_ERROR_NO_T -_osal_mdc_initInterrupt(void) -{ - /* init top and bottom halves */ - init_waitqueue_head(&_osal_mdc_isr_wait); - - /* init lock and clear device bitmap */ - spin_lock_init(&_osal_mdc_isr_dev_bitmap_lock); - _osal_mdc_isr_dev_bitmap = 0; - _osal_mdc_isr_init_bitmap = 0; - - /* clear chip interrupt mask address and value */ - _osal_mdc_isr_mask_addr = 0; - _osal_mdc_isr_mask_val = 0; - - return (NPS_E_OK); -} - -/* top half */ -static inline NPS_ERROR_NO_T -_osal_mdc_notifyUserProcess( - const UI32_T unit) -{ - unsigned long flags = 0; - - /* mask chip interrupt */ - osal_mdc_writePciReg(unit, _osal_mdc_isr_mask_addr, - &_osal_mdc_isr_mask_val, sizeof(UI32_T)); - - /* set the device bitmap. */ - spin_lock_irqsave(&_osal_mdc_isr_dev_bitmap_lock, flags); - _osal_mdc_isr_dev_bitmap |= (1U << unit); - spin_unlock_irqrestore(&_osal_mdc_isr_dev_bitmap_lock, flags); - - /* notify user process. */ - wake_up_interruptible(&_osal_mdc_isr_wait); - - return (NPS_E_OK); -} - -static inline NPS_ERROR_NO_T -_osal_mdc_waitEvent( - UI32_T *ptr_dev_bitmap) -{ - unsigned long flags = 0; - - wait_event_interruptible(_osal_mdc_isr_wait, (0 != _osal_mdc_isr_dev_bitmap)); - - /* save and clear the device bitmap. */ - spin_lock_irqsave(&_osal_mdc_isr_dev_bitmap_lock, flags); - *ptr_dev_bitmap = _osal_mdc_isr_dev_bitmap; - _osal_mdc_isr_dev_bitmap = 0; - spin_unlock_irqrestore(&_osal_mdc_isr_dev_bitmap_lock, flags); - - return (NPS_E_OK); -} - -static ssize_t -_osal_mdc_read( - struct file *filep, - char __user *buf, - size_t count, - loff_t *ppos) -{ - ssize_t ret; - UI32_T dev_bitmap = 0; - - if (count != sizeof(UI32_T)) - { - return -EINVAL; - } - - /* check if request_irq is inited. */ - if (0 != _osal_mdc_isr_init_bitmap) - { - _osal_mdc_waitEvent(&dev_bitmap); - } - - /* copy the device bitmap to user process. */ - if (0 != copy_to_user(buf, &dev_bitmap, count)) - { - ret = -EFAULT; - } - else - { - ret = count; - } - - return ret; -} -#endif /* End of NPS_LINUX_USER_MODE */ - -static irqreturn_t -_osal_mdc_systemIntrCallback( - int irq, - void *ptr_cookie) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - int linux_rc = IRQ_HANDLED; - OSAL_MDC_DEV_T *ptr_dev = (OSAL_MDC_DEV_T *)ptr_cookie; - - /* Invoke kernel callback, the callback function exist only in below cases: - * 1. SDK built in kernel mode - * 2. SDK built in user mode, NetIF kernel module is enabled - */ - if (NULL != ptr_dev->isr_callback) - { - rc = ptr_dev->isr_callback(ptr_dev->ptr_isr_data); - if (NPS_E_OK != rc) - { - OSAL_MDC_ERR("handle irq failed, rc=%d\n", rc); - linux_rc = IRQ_NONE; - } - } - -#if defined(NPS_LINUX_USER_MODE) - /* Notify user process */ - rc = _osal_mdc_notifyUserProcess(ptr_dev->unit); - if (NPS_E_OK != rc) - { - OSAL_MDC_ERR("notify intr to usr failed, rc=%d\n", rc); - linux_rc = IRQ_NONE; - } -#endif - - return (linux_rc); -} - -NPS_ERROR_NO_T -osal_mdc_registerIsr( - const UI32_T unit, - AML_DEV_ISR_FUNC_T handler, - void *ptr_cookie) -{ - OSAL_MDC_DEV_T *ptr_dev = &_osal_mdc_cb.dev[unit]; - - ptr_dev->isr_callback = handler; - ptr_dev->ptr_isr_data = (void *)((NPS_HUGE_T)unit); - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_mdc_connectIsr( - const UI32_T unit, - AML_DEV_ISR_FUNC_T handler, - AML_DEV_ISR_DATA_T *ptr_cookie) -{ - OSAL_MDC_DEV_T *ptr_dev = &_osal_mdc_cb.dev[unit]; - int linux_rc = 0; - NPS_ERROR_NO_T rc = NPS_E_OK; - -#if defined(NPS_LINUX_USER_MODE) - if (NULL != ptr_cookie) - { - _osal_mdc_isr_mask_addr = ptr_cookie->mask_addr; - _osal_mdc_isr_mask_val = ptr_cookie->mask_val; - } -#endif - - if (NULL == ptr_dev->isr_callback) - { -#if defined(NPS_LINUX_KERNEL_MODE) - /* In user mode, the following database is created in user space. */ - ptr_dev->isr_callback = handler; - ptr_dev->ptr_isr_data = (void *)((NPS_HUGE_T)unit); -#endif - -#if defined(OSAL_MDC_EN_MSI) - /* If "no_msi" flag is set, it means the device doesn't support MSI. */ - if (1 != ptr_dev->ptr_pci_dev->no_msi) - { - linux_rc = pci_enable_msi(ptr_dev->ptr_pci_dev); - if (0 == linux_rc) - { - /* The system gives a new irq number if MSI is enabled sucessfully. */ - ptr_dev->irq = ptr_dev->ptr_pci_dev->irq; - } - else - { - OSAL_MDC_ERR("pci_enable_msi() failed, rc=%d\n", linux_rc); - rc = NPS_E_OTHERS; - } - } -#endif - - linux_rc = request_irq(ptr_dev->irq, _osal_mdc_systemIntrCallback, - 0, OSAL_MDC_DRIVER_NAME, (void *)ptr_dev); - - if (0 != linux_rc) - { - OSAL_MDC_ERR("request_irq() failed, rc=%d\n", linux_rc); - rc = NPS_E_OTHERS; - } - } - else - { - OSAL_MDC_ERR("double req isr err\n"); - rc = NPS_E_OTHERS; - } - return (rc); -} - -NPS_ERROR_NO_T -osal_mdc_disconnectIsr( - const UI32_T unit) -{ - OSAL_MDC_DEV_T *ptr_dev = &_osal_mdc_cb.dev[unit]; - - free_irq(ptr_dev->irq, (void *)ptr_dev); - -#if defined(OSAL_MDC_EN_MSI) - /* Must free the irq before disabling MSI */ - pci_disable_msi(ptr_dev->ptr_pci_dev); -#endif - -#if defined(NPS_LINUX_KERNEL_MODE) - ptr_dev->isr_callback = NULL; - ptr_dev->ptr_isr_data = NULL; -#endif - -#if defined(NPS_LINUX_USER_MODE) - _osal_mdc_isr_mask_addr = 0x0; - _osal_mdc_isr_mask_val = 0x0; -#endif - - return (NPS_E_OK); -} - -NPS_ERROR_NO_T -osal_mdc_initDevice( - AML_DEV_T *ptr_dev_list, - UI32_T *ptr_dev_num) -{ - OSAL_MDC_CB_T *ptr_cb = &_osal_mdc_cb; - NPS_ERROR_NO_T rc = NPS_E_OK; - - _ptr_osal_mdc_dev = ptr_dev_list; - - memset(ptr_cb, 0x0, sizeof(OSAL_MDC_CB_T)); - -#if defined(AML_EN_I2C) - rc = _osal_mdc_probeI2cDevice(); - *ptr_dev_num = 1; -#else - rc = _osal_mdc_probePciDevice(); - *ptr_dev_num = ptr_cb->dev_num; - - _ptr_ext_pci_dev = _osal_mdc_cb.dev[0].ptr_pci_dev; -#endif /* End of AML_EN_I2C */ - - return (rc); -} - -NPS_ERROR_NO_T -osal_mdc_deinitDevice(void) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - -#if defined(AML_EN_I2C) - rc = _osal_mdc_removeI2cDevice(); -#else - if (NULL != _ptr_ext_pci_dev) - { - rc = _osal_mdc_removePciDevice(); - _ptr_ext_pci_dev = NULL; - } -#endif - - return (rc); -} - -/*****************************************************************************/ -#if defined(NPS_LINUX_USER_MODE) -/* Interface */ -static UI32_T _osal_mdc_devInited = 0; - -/* DMA */ -#if defined(NPS_EN_DMA_RESERVED) -static UI32_T _osal_mdc_rsvDmaInited = 0; -#else -static struct list_head _osal_mdc_sysDmaList[2]; /* To avoid memory corruption when cold-boot */ -static UI32_T _osal_mdc_sysCurDmaListIdx = 0; -#endif - -/* IOCTL */ -static OSAL_MDC_IOCTL_CB_T _osal_mdc_ioctl_cb; -static AML_DEV_T _osal_mdc_ioctl_dev[NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM] = {}; - -static int -_osal_mdc_open( - struct inode *ptr_inode, - struct file *ptr_file) -{ - return (0); -} - -static int -_osal_mdc_release( - struct inode *ptr_inode, - struct file *ptr_file) -{ - return (0); -} - -static struct vm_operations_struct _osal_mdc_remap_vm_ops = -{ - .open = NULL, - .close = NULL, -}; - -static int -_osal_mdc_mmap( - struct file *filp, - struct vm_area_struct *vma) -{ - size_t size = vma->vm_end - vma->vm_start; - int linux_rc = 0; - -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,0,48) - pgprot_val(vma->vm_page_prot) |= (_PAGE_NO_CACHE | _PAGE_GUARDED); -#else - UI32_T dev_idx; - OSAL_MDC_DEV_T *ptr_dev; - NPS_ADDR_T phy_addr = vma->vm_pgoff << PAGE_SHIFT; - - /* check mmio base phy addr */ - for (dev_idx = 0, ptr_dev = &_osal_mdc_cb.dev[0]; - dev_idx < _osal_mdc_cb.dev_num; - dev_idx++, ptr_dev++) - { - if ((NULL != ptr_dev->ptr_pci_dev) && - (phy_addr == pci_resource_start(ptr_dev->ptr_pci_dev, OSAL_MDC_PCI_BAR0_OFFSET))) - { - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - break; - } - } -#endif - - vma->vm_flags |= VM_IO; - if (io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, - size, vma->vm_page_prot)) - { - linux_rc = -EAGAIN; - } - vma->vm_ops = &_osal_mdc_remap_vm_ops; - return (linux_rc); -} - -#if defined(NPS_EN_DMA_RESERVED) - -static NPS_ERROR_NO_T -_osal_mdc_ioctl_initRsrvDmaMemCallback( - const UI32_T unit, - void *ptr_data) -{ - OSAL_MDC_DMA_INFO_T *ptr_dma_info = &_osal_mdc_cb.dma_info; - OSAL_MDC_IOCTL_DMA_DATA_T *ptr_ioctl_data = (OSAL_MDC_IOCTL_DMA_DATA_T *)ptr_data; - NPS_ERROR_NO_T rc = NPS_E_OK; - - if (0 == _osal_mdc_rsvDmaInited) - { - rc = _osal_mdc_initRsrvDmaMem(ptr_dma_info); - _osal_mdc_rsvDmaInited = 1; - } - ptr_ioctl_data->rsrv_dma_phy_addr = ptr_dma_info->rsrv_phy_addr; - ptr_ioctl_data->rsrv_dma_size = ptr_dma_info->rsrv_size; - - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_ioctl_deinitRsrvDmaMemCallback( - const UI32_T unit, - void *ptr_data) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - - rc = _osal_mdc_deinitRsrvDmaMem(&_osal_mdc_cb.dma_info); - _osal_mdc_rsvDmaInited = 0; - - return (rc); -} - -#else - -static NPS_ERROR_NO_T -_osal_mdc_clearSysDmaList( - UI32_T dmaListIdx) -{ - OSAL_MDC_DMA_INFO_T *ptr_dma_info = &_osal_mdc_cb.dma_info; - OSAL_MDC_USER_MODE_DMA_NODE_T *ptr_curr_node_data = NULL; - OSAL_MDC_USER_MODE_DMA_NODE_T *ptr_next_node_data = NULL; - void *ptr_virt_addr; - - list_for_each_entry_safe(ptr_curr_node_data, ptr_next_node_data, - &_osal_mdc_sysDmaList[dmaListIdx], list) - { - list_del(&(ptr_curr_node_data->list)); - ptr_virt_addr = phys_to_virt(ptr_curr_node_data->phy_addr); - dma_free_coherent(ptr_dma_info->ptr_dma_dev, - ptr_curr_node_data->size, ptr_virt_addr, - ptr_curr_node_data->phy_addr); - kfree(ptr_curr_node_data); - } - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_osal_mdc_ioctl_allocSysDmaMemCallback( - const UI32_T unit, - void *ptr_data) -{ - OSAL_MDC_DMA_INFO_T *ptr_dma_info = &_osal_mdc_cb.dma_info; - OSAL_MDC_IOCTL_DMA_DATA_T *ptr_ioctl_data = (OSAL_MDC_IOCTL_DMA_DATA_T *)ptr_data; - OSAL_MDC_USER_MODE_DMA_NODE_T *ptr_node_data = NULL; - -/* To defense the compatible data type of 32bit and 64bit are not synchronized */ -#if defined(CONFIG_ARCH_DMA_ADDR_T_64BIT) /* Bus addressing is 64-bit */\ -&& !defined(NPS_EN_64BIT_ADDR) /* SDK follows HOST with 32-bit addr*/\ -&& (defined(NPS_EN_HOST_32_BIT_LITTLE_ENDIAN) || defined(NPS_EN_HOST_32_BIT_BIG_ENDIAN))/* HOST is 32-bit */ -#error "The DMA address of OS is 64bit. Please enable NPS_EN_64BIT_ADDR in SDK." -#endif - -#if !defined(CONFIG_ARCH_DMA_ADDR_T_64BIT) && defined(NPS_EN_64BIT_ADDR) -#error "The DMA address of OS is not 64bit. Please disable NPS_EN_64BIT_ADDR in SDK." -#endif - - if (NULL == dma_alloc_coherent(ptr_dma_info->ptr_dma_dev, ptr_ioctl_data->size, - (dma_addr_t *)&ptr_ioctl_data->phy_addr, GFP_ATOMIC)) - { - return (NPS_E_NO_MEMORY); - } - - ptr_node_data = kmalloc(sizeof(OSAL_MDC_USER_MODE_DMA_NODE_T), GFP_KERNEL); - if (NULL != ptr_node_data) - { - memset(ptr_node_data, 0, sizeof(OSAL_MDC_USER_MODE_DMA_NODE_T)); - ptr_node_data->phy_addr = ptr_ioctl_data->phy_addr; - ptr_node_data->size = ptr_ioctl_data->size; - list_add(&(ptr_node_data->list), &_osal_mdc_sysDmaList[_osal_mdc_sysCurDmaListIdx]); - } - else - { - dma_free_coherent(ptr_dma_info->ptr_dma_dev, ptr_ioctl_data->size, - phys_to_virt(ptr_ioctl_data->phy_addr), ptr_ioctl_data->phy_addr); - - return (NPS_E_NO_MEMORY); - } - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_osal_mdc_ioctl_freeSysDmaMemCallback( - const UI32_T unit, - void *ptr_data) -{ - OSAL_MDC_DMA_INFO_T *ptr_dma_info = &_osal_mdc_cb.dma_info; - OSAL_MDC_IOCTL_DMA_DATA_T *ptr_ioctl_data = (OSAL_MDC_IOCTL_DMA_DATA_T *)ptr_data; - void *ptr_virt_addr; - - OSAL_MDC_USER_MODE_DMA_NODE_T *ptr_curr_node_data = NULL; - OSAL_MDC_USER_MODE_DMA_NODE_T *ptr_next_node_data = NULL; - - - list_for_each_entry_safe(ptr_curr_node_data, ptr_next_node_data, - &_osal_mdc_sysDmaList[_osal_mdc_sysCurDmaListIdx], list) - { - if (ptr_curr_node_data->phy_addr == ptr_ioctl_data->phy_addr) - { - list_del(&(ptr_curr_node_data->list)); - kfree(ptr_curr_node_data); - break; - } - } - - ptr_virt_addr = phys_to_virt(ptr_ioctl_data->phy_addr); - dma_free_coherent(ptr_dma_info->ptr_dma_dev, ptr_ioctl_data->size, - ptr_virt_addr, ptr_ioctl_data->phy_addr); - - return (NPS_E_OK); -} - -#endif - -static NPS_ERROR_NO_T -_osal_mdc_getPciInfoToIoctlData( - const OSAL_MDC_DEV_T *ptr_dev_list, - OSAL_MDC_IOCTL_DEV_DATA_T *ptr_dev_data) -{ - UI32_T idx; - - /* Search for PCIe device and get the MMIO base address. */ - for (idx = 0; idx < _osal_mdc_cb.dev_num; idx++) - { - if (NULL != ptr_dev_list[idx].ptr_pci_dev) - { - ptr_dev_data->pci_mmio_phy_start[idx] = - pci_resource_start(ptr_dev_list[idx].ptr_pci_dev, OSAL_MDC_PCI_BAR0_OFFSET); - - ptr_dev_data->pci_mmio_size[idx] = - pci_resource_len(ptr_dev_list[idx].ptr_pci_dev, OSAL_MDC_PCI_BAR0_OFFSET); - } - } - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_osal_mdc_getDeviceIdToIoctlData( - AML_DEV_T *ptr_dev, - OSAL_MDC_IOCTL_DEV_DATA_T *ptr_dev_data, - const UI32_T dev_num) -{ - UI32_T idx; - - for (idx = 0; idx < ptr_dev_data->dev_num; idx++) - { - ptr_dev_data->id[idx].device = ptr_dev[idx].id.device; - ptr_dev_data->id[idx].vendor = ptr_dev[idx].id.vendor; - ptr_dev_data->id[idx].revision = ptr_dev[idx].id.revision; - } - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_osal_mdc_ioctl_initDeviceCallback( - const UI32_T unit, - void *ptr_data) -{ - OSAL_MDC_CB_T *ptr_cb = &_osal_mdc_cb; - OSAL_MDC_DEV_T *ptr_dev_list = _osal_mdc_cb.dev; - OSAL_MDC_IOCTL_DEV_DATA_T *ptr_ioctl_data = (OSAL_MDC_IOCTL_DEV_DATA_T *)ptr_data; - - /* "dev" is just created for invoking osal_mdc_initDevice, - * it is no use once the device IDs are copy to ptr_ioctl_data. - */ - - NPS_ERROR_NO_T rc = NPS_E_OK; - - if (0 == _osal_mdc_devInited) - { - rc = osal_mdc_initDevice(_osal_mdc_ioctl_dev, &ptr_ioctl_data->dev_num); - } - else - { - /* ptr_cb->dev_num was initialized in osal_mdc_initDevice(); */ - ptr_ioctl_data->dev_num = ptr_cb->dev_num; - } - - if (ptr_cb->dev_num >= NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM) - { - OSAL_MDC_ERR("dev num=%d > max support num=%d\n", - ptr_ioctl_data->dev_num, NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM); - } - -#if !defined(NPS_EN_DMA_RESERVED) - if (0 == _osal_mdc_devInited) - { - /* Create two DMA memory lists and use 1st. */ - INIT_LIST_HEAD(&_osal_mdc_sysDmaList[0]); - INIT_LIST_HEAD(&_osal_mdc_sysDmaList[1]); - _osal_mdc_sysCurDmaListIdx = 0; - } - else - { - /* Delay free the old list until the chip is reset. - * When we kill the process, the chip continues to write to the DMA memory. - * If we free the old DMA memory before stopping the chip, there could be memory corruption. - */ - _osal_mdc_sysCurDmaListIdx = ((_osal_mdc_sysCurDmaListIdx + 1) & 0x1); - rc = _osal_mdc_clearSysDmaList(_osal_mdc_sysCurDmaListIdx); - } -#endif - - if (NPS_E_OK == rc) - { - rc = _osal_mdc_getDeviceIdToIoctlData(_osal_mdc_ioctl_dev, ptr_ioctl_data, ptr_ioctl_data->dev_num); - } - if (NPS_E_OK == rc) - { - rc = _osal_mdc_getPciInfoToIoctlData(ptr_dev_list, ptr_ioctl_data); - } - - _osal_mdc_devInited = 1; - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_ioctl_deinitDeviceCallback( - const UI32_T unit, - void *ptr_data) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - -#if !defined(NPS_EN_DMA_RESERVED) - _osal_mdc_clearSysDmaList(0); - _osal_mdc_clearSysDmaList(1); -#endif - - if (0 != _osal_mdc_devInited) - { - rc = osal_mdc_deinitDevice(); - _osal_mdc_devInited = 0; - } - - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_ioctl_connectIsrCallback( - const UI32_T unit, - void *ptr_data) -{ - NPS_ERROR_NO_T rc = NPS_E_OK; - - if (0 == (_osal_mdc_isr_init_bitmap & (1U << unit))) - { - rc = osal_mdc_connectIsr(unit, NULL, ptr_data); - if (NPS_E_OK == rc) - { - _osal_mdc_isr_init_bitmap |= (1U << unit); - } - } - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_ioctl_disconnectIsrCallback( - const UI32_T unit, - void *ptr_data) -{ - /* To make the user-space polling task return from read. */ - _osal_mdc_notifyUserProcess(unit); - - osal_mdc_disconnectIsr(unit); - _osal_mdc_isr_init_bitmap &= ~(1U << unit); - - return (NPS_E_OK); -} - -static NPS_ERROR_NO_T -_osal_mdc_ioctl_savePciConfigCallback( - const UI32_T unit, - void *ptr_data) -{ - return _osal_mdc_savePciConfig(unit); -} - -static NPS_ERROR_NO_T -_osal_mdc_ioctl_restorePciConfigCallback( - const UI32_T unit, - void *ptr_data) -{ - return _osal_mdc_restorePciConfig(unit); -} - -static NPS_ERROR_NO_T -_osal_mdc_registerIoctlCallback( - const OSAL_MDC_IOCTL_TYPE_T type, - const OSAL_MDC_IOCTL_CALLBACK_FUNC_T func) -{ - OSAL_MDC_IOCTL_CB_T *ptr_cb = &_osal_mdc_ioctl_cb; - NPS_ERROR_NO_T rc = NPS_E_OTHERS; - - if (type < OSAL_MDC_IOCTL_TYPE_LAST) - { - if (NULL == ptr_cb->callback[type]) - { - ptr_cb->callback[type] = func; - rc = NPS_E_OK; - } - else - { - OSAL_MDC_ERR("register ioctl callback failed, type=%d exist\n", type); - } - } - else - { - OSAL_MDC_ERR("register ioctl callback failed, type=%d >= max=%d\n", - type, OSAL_MDC_IOCTL_TYPE_LAST); - } - return (rc); -} - -static NPS_ERROR_NO_T -_osal_mdc_initIoctl(void) -{ - memset(&_osal_mdc_ioctl_cb, 0x0, sizeof(OSAL_MDC_IOCTL_CB_T)); - - _osal_mdc_registerIoctlCallback(OSAL_MDC_IOCTL_TYPE_MDC_INIT_DEV, - _osal_mdc_ioctl_initDeviceCallback); - - _osal_mdc_registerIoctlCallback(OSAL_MDC_IOCTL_TYPE_MDC_DEINIT_DEV, - _osal_mdc_ioctl_deinitDeviceCallback); -#if defined(NPS_EN_DMA_RESERVED) - _osal_mdc_registerIoctlCallback(OSAL_MDC_IOCTL_TYPE_MDC_INIT_RSRV_DMA_MEM, - _osal_mdc_ioctl_initRsrvDmaMemCallback); - - _osal_mdc_registerIoctlCallback(OSAL_MDC_IOCTL_TYPE_MDC_DEINIT_RSRV_DMA_MEM, - _osal_mdc_ioctl_deinitRsrvDmaMemCallback); -#else - _osal_mdc_registerIoctlCallback(OSAL_MDC_IOCTL_TYPE_MDC_ALLOC_SYS_DMA_MEM, - _osal_mdc_ioctl_allocSysDmaMemCallback); - - _osal_mdc_registerIoctlCallback(OSAL_MDC_IOCTL_TYPE_MDC_FREE_SYS_DMA_MEM, - _osal_mdc_ioctl_freeSysDmaMemCallback); -#endif - _osal_mdc_registerIoctlCallback(OSAL_MDC_IOCTL_TYPE_MDC_CONNECT_ISR, - _osal_mdc_ioctl_connectIsrCallback); - - _osal_mdc_registerIoctlCallback(OSAL_MDC_IOCTL_TYPE_MDC_DISCONNECT_ISR, - _osal_mdc_ioctl_disconnectIsrCallback); - - _osal_mdc_registerIoctlCallback(OSAL_MDC_IOCTL_TYPE_MDC_SAVE_PCI_CONFIG, - _osal_mdc_ioctl_savePciConfigCallback); - - _osal_mdc_registerIoctlCallback(OSAL_MDC_IOCTL_TYPE_MDC_RESTORE_PCI_CONFIG, - _osal_mdc_ioctl_restorePciConfigCallback); - return (NPS_E_OK); -} - -static long -_osal_mdc_ioctl( - struct file *filp, - unsigned int cmd, - unsigned long arg) -{ -#define OSAL_MDC_IOCTL_LOCAL_BUF_SIZE (128) - - OSAL_MDC_IOCTL_CB_T *ptr_cb = &_osal_mdc_ioctl_cb; - OSAL_MDC_IOCTL_CMD_T *ptr_cmd = (OSAL_MDC_IOCTL_CMD_T *)&cmd; - UI32_T unit = ptr_cmd->field.unit; - OSAL_MDC_IOCTL_TYPE_T type = ptr_cmd->field.type; - OSAL_MDC_IOCTL_ACCESS_T access = ptr_cmd->field.access; - UI32_T data_size = ptr_cmd->field.size; - UI8_T temp_buf[OSAL_MDC_IOCTL_LOCAL_BUF_SIZE]; - UI8_T *ptr_temp_buf; - int linux_rc = 0; - - if (NULL != ptr_cb->callback[type]) - { - if (data_size > OSAL_MDC_IOCTL_LOCAL_BUF_SIZE) - { - ptr_temp_buf = kmalloc(data_size, GFP_KERNEL); - } - else - { - ptr_temp_buf = temp_buf; - } - - /*************************************************************/ - if (OSAL_MDC_IOCTL_ACCESS_WRITE == access) - { - /* type: FREE_SYS_DMA_MEM : DMA physical address - * CONNECT_ISR : Chip interrupt mask address and value - */ - if (copy_from_user(ptr_temp_buf, (int __user *)arg, data_size)) - { - linux_rc = -EFAULT; - } - else - { - if (NPS_E_OK != ptr_cb->callback[type](unit, (void *)ptr_temp_buf)) - { - linux_rc = -EFAULT; - } - } - } - else if (OSAL_MDC_IOCTL_ACCESS_READ == access) - { - /* type: INIT_DEV : PCIe device and vendor ID, mmio address and size - * INIT_RSRV_DMA_MEM : Reserved DMA physical address and size - */ - if (NPS_E_OK != ptr_cb->callback[type](unit, (void *)ptr_temp_buf)) - { - linux_rc = -EFAULT; - } - else - { - if (copy_to_user((int __user *)arg, ptr_temp_buf, data_size)) - { - linux_rc = -EFAULT; - } - } - } - else if (OSAL_MDC_IOCTL_ACCESS_READ_WRITE == access) - { - /* type: ALLOC_SYS_DMA_MEM : DMA physical address - */ - if (copy_from_user(ptr_temp_buf, (int __user *)arg, data_size)) - { - linux_rc = -EFAULT; - } - else - { - if (NPS_E_OK != ptr_cb->callback[type](unit, (void *)ptr_temp_buf)) - { - linux_rc = -EFAULT; - } - else - { - if (copy_to_user((int __user *)arg, ptr_temp_buf, data_size)) - { - linux_rc = -EFAULT; - } - } - } - } - else if (OSAL_MDC_IOCTL_ACCESS_NONE == access) - { - /* type: DEINIT_DEV - * DEINIT_RSRV_DMA_MEM - * DISCONNECT_ISR - * SAVE_PCI_CONFIG - * RESTORE_PCI_CONFIG - */ - if (NPS_E_OK != ptr_cb->callback[type](unit, (void *)ptr_temp_buf)) - { - linux_rc = -EFAULT; - } - } - /*************************************************************/ - - if (data_size > OSAL_MDC_IOCTL_LOCAL_BUF_SIZE) - { - kfree(ptr_temp_buf); - } - } - else - { - OSAL_MDC_ERR("invalid ioctl, cmd=%u, arg=%lu, type=%d\n", cmd, arg, type); - } - return (linux_rc); -} - -#ifdef CONFIG_COMPAT -static long -_osal_mdc_compat_ioctl( - struct file *filp, - unsigned int cmd, - unsigned long arg) -{ - return _osal_mdc_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); -} -#endif - -static struct file_operations _osal_mdc_fops = -{ - .owner = THIS_MODULE, - .open = _osal_mdc_open, - .read = _osal_mdc_read, - .release = _osal_mdc_release, - .unlocked_ioctl = _osal_mdc_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = _osal_mdc_compat_ioctl, -#endif - .mmap = _osal_mdc_mmap, -}; - -static struct miscdevice _osal_mdc_misc = -{ - .minor = OSAL_MDC_DRIVER_MISC_MINOR_NUM, - .name = OSAL_MDC_DRIVER_NAME, - .fops = & _osal_mdc_fops, -}; - -static int __init -osal_mdc_module_init(void) -{ - int linux_rc; - - _osal_mdc_initIoctl(); /* To register IOCTL callback functions. */ - _osal_mdc_initInterrupt(); /* To init structs for top and bottom halves */ - - linux_rc = misc_register(&_osal_mdc_misc); - if (0 != linux_rc) - { - OSAL_MDC_ERR("register dev %s failed, linux_rc=%d\n", OSAL_MDC_DRIVER_NAME, linux_rc); - } - return (linux_rc); -} - -static void __exit -osal_mdc_module_exit(void) -{ - int unit = 0; - -#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,2,8) - int linux_rc; - - linux_rc = misc_deregister(&_osal_mdc_misc); - if (0 != linux_rc) - { - OSAL_MDC_ERR("de-register dev %s failed, linux_rc=%d\n", OSAL_MDC_DRIVER_NAME, linux_rc); - } -#else - misc_deregister(&_osal_mdc_misc); -#endif - - /* ref: _osal_mdc_ioctl_disconnectIsrCallback */ - for (unit = 0; unit < NPS_CFG_MAXIMUM_CHIPS_PER_SYSTEM; unit++) - { - if (0 != (_osal_mdc_isr_init_bitmap & (1U << unit))) - { - osal_mdc_disconnectIsr(unit); - _osal_mdc_isr_init_bitmap &= ~(1U << unit); - } - } - - /* ref: _osal_mdc_ioctl_deinitRsrvDmaMemCallback */ -#if defined(NPS_EN_DMA_RESERVED) - if (1 == _osal_mdc_rsvDmaInited) - { - _osal_mdc_deinitRsrvDmaMem(&_osal_mdc_cb.dma_info); - _osal_mdc_rsvDmaInited = 0; - } -#endif - - /* ref: _osal_mdc_ioctl_deinitDeviceCallback */ - if (1 == _osal_mdc_devInited) - { -#if !defined(NPS_EN_DMA_RESERVED) - _osal_mdc_clearSysDmaList(0); - _osal_mdc_clearSysDmaList(1); -#endif - osal_mdc_deinitDevice(); - _osal_mdc_devInited = 0; - } -} - -#else - -static int __init -osal_mdc_module_init(void) -{ - return (0); -} - -static void __exit -osal_mdc_module_exit(void) -{ - -} - -#endif /* End of NPS_LINUX_USER_MODE */ - -module_init(osal_mdc_module_init); -module_exit(osal_mdc_module_exit); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("MediaTek"); -MODULE_DESCRIPTION("SDK Kernel Module"); diff --git a/platform/nephos/one-image.mk b/platform/nephos/one-image.mk deleted file mode 100644 index 60254051c5b..00000000000 --- a/platform/nephos/one-image.mk +++ /dev/null @@ -1,21 +0,0 @@ -# sonic nephos one image installer - -SONIC_ONE_IMAGE = sonic-nephos.bin -$(SONIC_ONE_IMAGE)_MACHINE = nephos -$(SONIC_ONE_IMAGE)_IMAGE_TYPE = onie -$(SONIC_ONE_IMAGE)_INSTALLS += $(NEPHOS_MODULE) -$(SONIC_ONE_IMAGE)_INSTALLS += $(SYSTEMD_SONIC_GENERATOR) -$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(INGRASYS_S9130_32X_PLATFORM_MODULE) \ - $(INGRASYS_S9230_64X_PLATFORM_MODULE) \ - $(ACCTON_AS7116_54X_PLATFORM_MODULE) \ - $(CIG_CS6436_56P_PLATFORM_MODULE) \ - $(CIG_CS6436_54P_PLATFORM_MODULE) \ - $(CIG_CS5435_54P_PLATFORM_MODULE) - -ifeq ($(INSTALL_DEBUG_TOOLS),y) -$(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_DBG_IMAGES) -$(SONIC_ONE_IMAGE)_DOCKERS += $(filter-out $(patsubst %-$(DBG_IMAGE_MARK).gz,%.gz, $(SONIC_INSTALL_DOCKER_DBG_IMAGES)), $(SONIC_INSTALL_DOCKER_IMAGES)) -else -$(SONIC_ONE_IMAGE)_DOCKERS = $(SONIC_INSTALL_DOCKER_IMAGES) -endif -SONIC_INSTALLERS += $(SONIC_ONE_IMAGE) diff --git a/platform/nephos/platform-modules-accton.mk b/platform/nephos/platform-modules-accton.mk deleted file mode 100644 index 1ecb76a2fbb..00000000000 --- a/platform/nephos/platform-modules-accton.mk +++ /dev/null @@ -1,12 +0,0 @@ -# Accton AS7116 54X Platform modules - -ACCTON_AS7116_54X_PLATFORM_MODULE_VERSION = 1.0.1 - -export ACCTON_AS7116_54X_PLATFORM_MODULE_VERSION - -ACCTON_AS7116_54X_PLATFORM_MODULE = sonic-platform-accton-as7116-54x_$(ACCTON_AS7116_54X_PLATFORM_MODULE_VERSION)_amd64.deb -$(ACCTON_AS7116_54X_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-accton -$(ACCTON_AS7116_54X_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) -$(ACCTON_AS7116_54X_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as7116_54x-r0 -SONIC_DPKG_DEBS += $(ACCTON_AS7116_54X_PLATFORM_MODULE) - diff --git a/platform/nephos/platform-modules-cig.mk b/platform/nephos/platform-modules-cig.mk deleted file mode 100644 index 48e7072f6da..00000000000 --- a/platform/nephos/platform-modules-cig.mk +++ /dev/null @@ -1,23 +0,0 @@ -# Cig Nephos Switch Platform modules - -CIG_MTK_PLATFORM_MODULE_VERSION = 1.0.0 - -export CIG_MTK_PLATFORM_MODULE_VERSION - -CIG_CS6436_56P_PLATFORM_MODULE = sonic-platform-cig-cs6436-56p_$(CIG_MTK_PLATFORM_MODULE_VERSION)_amd64.deb -$(CIG_CS6436_56P_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-cig -$(CIG_CS6436_56P_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) -$(CIG_CS6436_56P_PLATFORM_MODULE)_PLATFORM = x86_64-cig_cs6436_56p-r0 -SONIC_DPKG_DEBS += $(CIG_CS6436_56P_PLATFORM_MODULE) - -CIG_CS6436_54P_PLATFORM_MODULE = sonic-platform-cig-cs6436-54p_$(CIG_MTK_PLATFORM_MODULE_VERSION)_amd64.deb -$(CIG_CS6436_54P_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-cig -$(CIG_CS6436_54P_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) -$(CIG_CS6436_54P_PLATFORM_MODULE)_PLATFORM = x86_64-cig_cs6436_54p-r0 -SONIC_DPKG_DEBS += $(CIG_CS6436_54P_PLATFORM_MODULE) - -CIG_CS5435_54P_PLATFORM_MODULE = sonic-platform-cig-cs5435-54p_$(CIG_MTK_PLATFORM_MODULE_VERSION)_amd64.deb -$(CIG_CS5435_54P_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-cig -$(CIG_CS5435_54P_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) -$(CIG_CS5435_54P_PLATFORM_MODULE)_PLATFORM = x86_64-cig_cs5435_54p-r0 -SONIC_DPKG_DEBS += $(CIG_CS5435_54P_PLATFORM_MODULE) diff --git a/platform/nephos/platform-modules-ingrasys.mk b/platform/nephos/platform-modules-ingrasys.mk deleted file mode 100644 index 03818ca8465..00000000000 --- a/platform/nephos/platform-modules-ingrasys.mk +++ /dev/null @@ -1,19 +0,0 @@ -# Ingrasys S9130-32X and S9230-64X Platform modules - -INGRASYS_S9130_32X_PLATFORM_MODULE_VERSION = 1.0.0 -INGRASYS_S9230_64X_PLATFORM_MODULE_VERSION = 1.0.0 - -export INGRASYS_S9130_32X_PLATFORM_MODULE_VERSION -export INGRASYS_S9230_64X_PLATFORM_MODULE_VERSION - -INGRASYS_S9130_32X_PLATFORM_MODULE = sonic-platform-ingrasys-s9130-32x_$(INGRASYS_S9130_32X_PLATFORM_MODULE_VERSION)_amd64.deb -$(INGRASYS_S9130_32X_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-ingrasys -$(INGRASYS_S9130_32X_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) -$(INGRASYS_S9130_32X_PLATFORM_MODULE)_PLATFORM = x86_64-ingrasys_s9130_32x-r0 -SONIC_DPKG_DEBS += $(INGRASYS_S9130_32X_PLATFORM_MODULE) - -INGRASYS_S9230_64X_PLATFORM_MODULE = sonic-platform-ingrasys-s9230-64x_$(INGRASYS_S9230_64X_PLATFORM_MODULE_VERSION)_amd64.deb -$(INGRASYS_S9230_64X_PLATFORM_MODULE)_PLATFORM = x86_64-ingrasys_s9230_64x-r0 - -$(eval $(call add_extra_package,$(INGRASYS_S9130_32X_PLATFORM_MODULE),$(INGRASYS_S9230_64X_PLATFORM_MODULE))) - diff --git a/platform/nephos/platform-modules-pegatron.mk b/platform/nephos/platform-modules-pegatron.mk deleted file mode 100755 index 9a411763cec..00000000000 --- a/platform/nephos/platform-modules-pegatron.mk +++ /dev/null @@ -1,13 +0,0 @@ -# Pegatron Platform modules - -PEGATRON_PORSCHE_PLATFORM_MODULE_VERSION = 0.1 - -export PEGATRON_PORSCHE_PLATFORM_MODULE_VERSION - -PEGATRON_PORSCHE_PLATFORM_MODULE = sonic-platform-pegatron-porsche_$(PEGATRON_PORSCHE_PLATFORM_MODULE_VERSION)_amd64.deb -$(PEGATRON_PORSCHE_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-pegatron -$(PEGATRON_PORSCHE_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) -$(PEGATRON_PORSCHE_PLATFORM_MODULE)_PLATFORM = x86_64-pegatron_porsche-r0 -SONIC_DPKG_DEBS += $(PEGATRON_PORSCHE_PLATFORM_MODULE) - -$(eval $(call add_extra_package,$(PEGATRON_PORSCHE_PLATFORM_MODULE))) diff --git a/platform/nephos/platform.conf b/platform/nephos/platform.conf deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/platform/nephos/rules.dep b/platform/nephos/rules.dep deleted file mode 100644 index 94b8a167a4a..00000000000 --- a/platform/nephos/rules.dep +++ /dev/null @@ -1 +0,0 @@ -include $(PLATFORM_PATH)/sai.dep diff --git a/platform/nephos/rules.mk b/platform/nephos/rules.mk deleted file mode 100644 index d2d1a67075f..00000000000 --- a/platform/nephos/rules.mk +++ /dev/null @@ -1,33 +0,0 @@ -include $(PLATFORM_PATH)/sai.mk -include $(PLATFORM_PATH)/nephos-modules.mk -include $(PLATFORM_PATH)/platform-modules-ingrasys.mk -include $(PLATFORM_PATH)/platform-modules-accton.mk -include $(PLATFORM_PATH)/platform-modules-cig.mk -include $(PLATFORM_PATH)/docker-syncd-nephos.mk -include $(PLATFORM_PATH)/docker-syncd-nephos-rpc.mk -include $(PLATFORM_PATH)/one-image.mk -include $(PLATFORM_PATH)/libsaithrift-dev.mk - -NPX_DIAG = npx_diag -$(NPX_DIAG)_URL = "https://github.com/NephosInc/SONiC/raw/master/sdk/npx_diag" - -WARM_VERIFIER = warm-verifier -$(WARM_VERIFIER)_URL = "https://github.com/NephosInc/SONiC/raw/master/sai/warm-verifier" - -DSSERVE = dsserve -$(DSSERVE)_URL = "$(BUILD_PUBLIC_URL)/20190307/dsserve" - -SONIC_ONLINE_FILES += $(NPX_DIAG) $(WARM_VERIFIER) $(DSSERVE) - -SONIC_ALL += $(SONIC_ONE_IMAGE) $(DOCKER_FPM) - -# Inject nephos sai into syncd -$(SYNCD)_DEPENDS += $(NEPHOS_SAI) $(NEPHOS_SAI_DEV) -$(SYNCD)_UNINSTALLS += $(NEPHOS_SAI_DEV) - -ifeq ($(ENABLE_SYNCD_RPC),y) -$(SYNCD)_DEPENDS += $(LIBSAITHRIFT_DEV) -endif - -# Runtime dependency on nephos sai is set only for syncd -$(SYNCD)_RDEPENDS += $(NEPHOS_SAI) diff --git a/platform/nephos/sai.dep b/platform/nephos/sai.dep deleted file mode 100644 index f4f6fa975e1..00000000000 --- a/platform/nephos/sai.dep +++ /dev/null @@ -1,17 +0,0 @@ -DEP_FILES := $(SONIC_COMMON_FILES_LIST) $(PLATFORM_PATH)/sai.mk $(PLATFORM_PATH)/sai.dep -DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) - -# The Nephos SAI package is a version-pinned online deb: the SDK/SAI version and -# download URL live entirely in sai.mk, so keying the .mk/.dep captures every -# version change. NEPHOS_SAI_DEV is a derived package of NEPHOS_SAI and shares -# its base cache entry, so only NEPHOS_SAI needs a dependency definition here. -# -# Only enable cache keying in the online (SONIC_ONLINE_DEBS) case. When -# NEPHOS_SAI_DEB_LOCAL_URL is set (SAI_FROM_LOCAL=y) the deb is copied from a -# local path outside the repo whose contents are not captured by hashing repo -# files; leave the package uncached in that mode (its pre-existing behavior). -ifneq ($(SAI_FROM_LOCAL),y) -$(NEPHOS_SAI)_CACHE_MODE := GIT_CONTENT_SHA -$(NEPHOS_SAI)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) -$(NEPHOS_SAI)_DEP_FILES := $(DEP_FILES) -endif diff --git a/platform/nephos/sai.mk b/platform/nephos/sai.mk deleted file mode 100644 index 8bbeb9899b5..00000000000 --- a/platform/nephos/sai.mk +++ /dev/null @@ -1,36 +0,0 @@ -SDK_VERSION = 3.0.0 -SAI_VERSION = 1.5.0 -SAI_COMMIT_ID = 06a67d - -# Place here URL where SAI deb exist -NEPHOS_SAI_DEB_LOCAL_URL = -export NEPHOS_SAI_DEB_LOCAL_URL -# -ifneq ($(NEPHOS_SAI_DEB_LOCAL_URL), ) -SAI_FROM_LOCAL = y -else -SAI_FROM_LOCAL = n -endif - -NEPHOS_SAI = libsainps_$(SDK_VERSION)_sai_$(SAI_VERSION)_$(SAI_COMMIT_ID)_amd64.deb -ifeq ($(SAI_FROM_LOCAL), y) -$(NEPHOS_SAI)_PATH = $(NEPHOS_SAI_DEB_LOCAL_URL) -else -$(NEPHOS_SAI)_URL = "https://github.com/NephosInc/SONiC/raw/master/sai/libsainps_$(SDK_VERSION)_sai_$(SAI_VERSION)_$(SAI_COMMIT_ID)_amd64.deb" -endif - -NEPHOS_SAI_DEV = libsainps-dev_$(SDK_VERSION)_sai_$(SAI_VERSION)_$(SAI_COMMIT_ID)_amd64.deb -$(eval $(call add_derived_package,$(NEPHOS_SAI),$(NEPHOS_SAI_DEV))) -ifeq ($(SAI_FROM_LOCAL), y) -$(NEPHOS_SAI_DEV)_PATH = $(NEPHOS_SAI_DEB_LOCAL_URL) -else -$(NEPHOS_SAI_DEV)_URL = "https://github.com/NephosInc/SONiC/raw/master/sai/libsainps-dev_$(SDK_VERSION)_sai_$(SAI_VERSION)_$(SAI_COMMIT_ID)_amd64.deb" -endif - -ifeq ($(SAI_FROM_LOCAL), y) -SONIC_COPY_DEBS += $(NEPHOS_SAI) $(NEPHOS_SAI_DEV) -else -SONIC_ONLINE_DEBS += $(NEPHOS_SAI) $(NEPHOS_SAI_DEV) -endif -$(NEPHOS_SAI_DEV)_DEPENDS += $(NEPHOS_SAI) -$(eval $(call add_conflict_package,$(NEPHOS_SAI_DEV),$(LIBSAIVS_DEV))) diff --git a/platform/nephos/sonic-platform-modules-accton/LICENSE b/platform/nephos/sonic-platform-modules-accton/LICENSE deleted file mode 100644 index bc693f7a4c4..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/LICENSE +++ /dev/null @@ -1,16 +0,0 @@ -Copyright (C) 2016 Microsoft, Inc -Copyright (C) 2017 Accton Technology Corporation - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/platform/nephos/sonic-platform-modules-accton/README.md b/platform/nephos/sonic-platform-modules-accton/README.md deleted file mode 100644 index 0ff20bb2d21..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/README.md +++ /dev/null @@ -1 +0,0 @@ -platform drivers of Accton products for the SONiC project diff --git a/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/Makefile b/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/Makefile deleted file mode 100644 index 2d838864a27..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -obj-m := x86-64-accton-as7116-54x-cpld.o x86-64-accton-as7116-54x-fan.o \ - x86-64-accton-as7116-54x-led.o x86-64-accton-as7116-54x-psu.o x86-64-accton-as7116-54x-sfp.o \ No newline at end of file diff --git a/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-cpld.c b/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-cpld.c deleted file mode 100644 index eb52512343a..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-cpld.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * A hwmon driver for the as7116_54x_cpld - * - * Copyright (C) 2017 Accton Technology Corporation. - * Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include - -static LIST_HEAD(cpld_client_list); -static struct mutex list_lock; - -struct cpld_client_node { - struct i2c_client *client; - struct list_head list; -}; - -/* Addresses scanned for as7116_54x_cpld - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static ssize_t show_cpld_version(struct device *dev, struct device_attribute *attr, char *buf) -{ - int val = 0; - struct i2c_client *client = to_i2c_client(dev); - - val = i2c_smbus_read_byte_data(client, 0x1); - - if (val < 0) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); - } - - return sprintf(buf, "%d\n", val); -} - -static struct device_attribute ver = __ATTR(version, 0600, show_cpld_version, NULL); - -static void as7116_54x_cpld_add_client(struct i2c_client *client) -{ - struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); - - if (!node) { - dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); - return; - } - - node->client = client; - - mutex_lock(&list_lock); - list_add(&node->list, &cpld_client_list); - mutex_unlock(&list_lock); -} - -static void as7116_54x_cpld_remove_client(struct i2c_client *client) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int found = 0; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client == client) { - found = 1; - break; - } - } - - if (found) { - list_del(list_node); - kfree(cpld_node); - } - - mutex_unlock(&list_lock); -} - -static int as7116_54x_cpld_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int status; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_dbg(&client->dev, "i2c_check_functionality failed (0x%x)\n", client->addr); - status = -EIO; - goto exit; - } - - status = sysfs_create_file(&client->dev.kobj, &ver.attr); - if (status) { - goto exit; - } - - dev_info(&client->dev, "chip found\n"); - as7116_54x_cpld_add_client(client); - - return 0; - -exit: - return status; -} - -static int as7116_54x_cpld_remove(struct i2c_client *client) -{ - sysfs_remove_file(&client->dev.kobj, &ver.attr); - as7116_54x_cpld_remove_client(client); - - return 0; -} - -enum cpld_chips -{ - as7116_54x_cpld1, - as7116_54x_cpld2, - as7116_54x_cpld3 -}; - -static const struct i2c_device_id as7116_54x_cpld_id[] = { - { "as7116_54x_cpld1", as7116_54x_cpld1 }, - { "as7116_54x_cpld2", as7116_54x_cpld2 }, - { "as7116_54x_cpld3", as7116_54x_cpld3 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, as7116_54x_cpld_id); - -static struct i2c_driver as7116_54x_cpld_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "as7116_54x_cpld", - }, - .probe = as7116_54x_cpld_probe, - .remove = as7116_54x_cpld_remove, - .id_table = as7116_54x_cpld_id, - .address_list = normal_i2c, -}; - -int as7116_54x_cpld_read(unsigned short cpld_addr, u8 reg) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EPERM; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_read_byte_data(cpld_node->client, reg); - break; - } - } - - mutex_unlock(&list_lock); - - return ret; -} -EXPORT_SYMBOL(as7116_54x_cpld_read); - -int as7116_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EIO; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); - break; - } - } - - mutex_unlock(&list_lock); - - return ret; -} -EXPORT_SYMBOL(as7116_54x_cpld_write); - -static int __init as7116_54x_cpld_init(void) -{ - mutex_init(&list_lock); - return i2c_add_driver(&as7116_54x_cpld_driver); -} - -static void __exit as7116_54x_cpld_exit(void) -{ - i2c_del_driver(&as7116_54x_cpld_driver); -} - -static struct dmi_system_id as7116_54x_dmi_table[] = { - { - .ident = "Accton AS7716", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "Accton"), - DMI_MATCH(DMI_PRODUCT_NAME, "AS7116"), - }, - } -}; - -int platform_accton_as7116_54x(void) -{ - //return dmi_check_system(as7116_54x_dmi_table); - return 1; -} -EXPORT_SYMBOL(platform_accton_as7116_54x); - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton_as7116_54x driver"); -MODULE_LICENSE("GPL"); - -module_init(as7116_54x_cpld_init); -module_exit(as7116_54x_cpld_exit); - diff --git a/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-fan.c b/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-fan.c deleted file mode 100644 index f5159c8f166..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-fan.c +++ /dev/null @@ -1,544 +0,0 @@ -/* - * A hwmon driver for the Accton as7716 32x fan - * - * Copyright (C) 2014 Accton Technology Corporation. - * Brandon Chuang - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRVNAME "as7116_54x_fan" - -static struct as7116_54x_fan_data *as7116_54x_fan_update_device(struct device *dev); -static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); - -/* fan related data, the index should match sysfs_fan_attributes - */ -static const u8 fan_reg[] = { - 0x02, /* fan 1-6 present status */ - 0x03, /* fan 1-6 direction(0:F2B 1:B2F) */ - 0x06, /* fan PWM(for all fan) */ - 0x04, /* front fan fault */ - 0x05, /* rear fan fault */ - 0x07, /* front fan 1 speed(rpm) */ - 0x08, /* front fan 2 speed(rpm) */ - 0x09, /* front fan 3 speed(rpm) */ - 0x0A, /* front fan 4 speed(rpm) */ - 0x0B, /* front fan 5 speed(rpm) */ - 0x0C, /* rear fan 1 speed(rpm) */ - 0x0D, /* rear fan 2 speed(rpm) */ - 0x0E, /* rear fan 3 speed(rpm) */ - 0x0f, /* rear fan 4 speed(rpm) */ - 0x10, /* rear fan 5 speed(rpm) */ -}; - -/* Each client has this additional data */ -struct as7116_54x_fan_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* != 0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */ -}; - -enum fan_id { - FAN1_ID, - FAN2_ID, - FAN3_ID, - FAN4_ID, - FAN5_ID -}; - -enum sysfs_fan_attributes { - FAN_PRESENT_REG, - FAN_DIRECTION_REG, - FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */ - FAN_FRONT_FAULT_REG, - FAN_REAR_FAULT_REG, - FAN1_FRONT_SPEED_RPM, - FAN2_FRONT_SPEED_RPM, - FAN3_FRONT_SPEED_RPM, - FAN4_FRONT_SPEED_RPM, - FAN5_FRONT_SPEED_RPM, - FAN1_REAR_SPEED_RPM, - FAN2_REAR_SPEED_RPM, - FAN3_REAR_SPEED_RPM, - FAN4_REAR_SPEED_RPM, - FAN5_REAR_SPEED_RPM, - FAN1_DIRECTION, - FAN2_DIRECTION, - FAN3_DIRECTION, - FAN4_DIRECTION, - FAN5_DIRECTION, - FAN1_PRESENT, - FAN2_PRESENT, - FAN3_PRESENT, - FAN4_PRESENT, - FAN5_PRESENT, - FAN1_FRONT_FAULT, - FAN2_FRONT_FAULT, - FAN3_FRONT_FAULT, - FAN4_FRONT_FAULT, - FAN5_FRONT_FAULT, - FAN1_REAR_FAULT, - FAN2_REAR_FAULT, - FAN3_REAR_FAULT, - FAN4_REAR_FAULT, - FAN5_REAR_FAULT, - FAN1_INPUT, /* FAN1_FRONT_SPEED_RPM, */ - FAN2_INPUT, /* FAN2_FRONT_SPEED_RPM, */ - FAN3_INPUT, /* FAN3_FRONT_SPEED_RPM, */ - FAN4_INPUT, /* FAN4_FRONT_SPEED_RPM, */ - FAN5_INPUT, /* FAN5_FRONT_SPEED_RPM, */ - FAN6_INPUT, /* FAN1_REAR_SPEED_RPM, */ - FAN7_INPUT, /* FAN2_REAR_SPEED_RPM, */ - FAN8_INPUT, /* FAN3_REAR_SPEED_RPM, */ - FAN9_INPUT, /* FAN4_REAR_SPEED_RPM, */ - FAN10_INPUT, /* FAN5_REAR_SPEED_RPM */ -}; - -/* Define attributes - */ -#define DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_front_fault, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_FAULT);\ - static SENSOR_DEVICE_ATTR(fan##index##_rear_fault, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_FAULT) -#define DECLARE_FAN_FAULT_ATTR(index) &sensor_dev_attr_fan##index##_front_fault.dev_attr.attr,\ - &sensor_dev_attr_fan##index##_rear_fault.dev_attr.attr - -#define DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_direction, S_IRUGO, fan_show_value, NULL, FAN##index##_DIRECTION) -#define DECLARE_FAN_DIRECTION_ATTR(index) &sensor_dev_attr_fan##index##_direction.dev_attr.attr - -#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE) -#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr - -#define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) -#define DECLARE_FAN_PRESENT_ATTR(index) &sensor_dev_attr_fan##index##_present.dev_attr.attr - -#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_front_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\ - static SENSOR_DEVICE_ATTR(fan##index##_rear_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM) -#define DECLARE_FAN_SPEED_RPM_ATTR(index) &sensor_dev_attr_fan##index##_front_speed_rpm.dev_attr.attr, \ - &sensor_dev_attr_fan##index##_rear_speed_rpm.dev_attr.attr - -#define DECLARE_FAN_INPUT_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_input, S_IRUGO, fan_show_value, NULL, FAN##index##_INPUT) -#define DECLARE_FAN_INPUT_ATTR(index) &sensor_dev_attr_fan##index##_input.dev_attr.attr - -/* 6 fan fault attributes in this platform */ -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(4); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(5); -/* 6 fan speed(rpm) attributes in this platform */ -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(4); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(5); -/* 6 fan present attributes in this platform */ -DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(1); -DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(2); -DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(3); -DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(4); -DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(5); -/* 6 fan direction attribute in this platform */ -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(1); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(2); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(3); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(4); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5); -/* 1 fan duty cycle attribute in this platform */ -DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(); - -/* fan input attributes in this platform */ -DECLARE_FAN_INPUT_SENSOR_DEV_ATTR(1); -DECLARE_FAN_INPUT_SENSOR_DEV_ATTR(2); -DECLARE_FAN_INPUT_SENSOR_DEV_ATTR(3); -DECLARE_FAN_INPUT_SENSOR_DEV_ATTR(4); -DECLARE_FAN_INPUT_SENSOR_DEV_ATTR(5); - -DECLARE_FAN_INPUT_SENSOR_DEV_ATTR(6); -DECLARE_FAN_INPUT_SENSOR_DEV_ATTR(7); -DECLARE_FAN_INPUT_SENSOR_DEV_ATTR(8); -DECLARE_FAN_INPUT_SENSOR_DEV_ATTR(9); -DECLARE_FAN_INPUT_SENSOR_DEV_ATTR(10); - -static struct attribute *as7116_54x_fan_attributes[] = { - /* fan related attributes */ - DECLARE_FAN_FAULT_ATTR(1), - DECLARE_FAN_FAULT_ATTR(2), - DECLARE_FAN_FAULT_ATTR(3), - DECLARE_FAN_FAULT_ATTR(4), - DECLARE_FAN_FAULT_ATTR(5), - DECLARE_FAN_SPEED_RPM_ATTR(1), - DECLARE_FAN_SPEED_RPM_ATTR(2), - DECLARE_FAN_SPEED_RPM_ATTR(3), - DECLARE_FAN_SPEED_RPM_ATTR(4), - DECLARE_FAN_SPEED_RPM_ATTR(5), - DECLARE_FAN_PRESENT_ATTR(1), - DECLARE_FAN_PRESENT_ATTR(2), - DECLARE_FAN_PRESENT_ATTR(3), - DECLARE_FAN_PRESENT_ATTR(4), - DECLARE_FAN_PRESENT_ATTR(5), - DECLARE_FAN_DIRECTION_ATTR(1), - DECLARE_FAN_DIRECTION_ATTR(2), - DECLARE_FAN_DIRECTION_ATTR(3), - DECLARE_FAN_DIRECTION_ATTR(4), - DECLARE_FAN_DIRECTION_ATTR(5), - DECLARE_FAN_DUTY_CYCLE_ATTR(), - DECLARE_FAN_INPUT_ATTR(1), - DECLARE_FAN_INPUT_ATTR(2), - DECLARE_FAN_INPUT_ATTR(3), - DECLARE_FAN_INPUT_ATTR(4), - DECLARE_FAN_INPUT_ATTR(5), - DECLARE_FAN_INPUT_ATTR(6), - DECLARE_FAN_INPUT_ATTR(7), - DECLARE_FAN_INPUT_ATTR(8), - DECLARE_FAN_INPUT_ATTR(9), - DECLARE_FAN_INPUT_ATTR(10), - NULL -}; - -#define FAN_DUTY_CYCLE_REG_MASK 0x1F -#define FAN_MIN_DUTY_CYCLE 20 -#define FAN_MAX_DUTY_CYCLE 100 -#define FAN_REG_VAL_TO_SPEED_RPM_STEP 150 - -static int as7116_54x_fan_read_value(struct i2c_client *client, u8 reg) -{ - return i2c_smbus_read_byte_data(client, reg); -} - -static int as7116_54x_fan_write_value(struct i2c_client *client, u8 reg, u8 value) -{ - return i2c_smbus_write_byte_data(client, reg, value); -} - -/* fan utility functions - */ -static u32 reg_val_to_duty_cycle(u8 reg_val) -{ - return (reg_val & FAN_DUTY_CYCLE_REG_MASK) * 5; -} - -static u8 duty_cycle_to_reg_val(u8 duty_cycle) -{ - return (duty_cycle / 5); -} - -static u32 reg_val_to_speed_rpm(u8 reg_val) -{ - return (u32)reg_val * FAN_REG_VAL_TO_SPEED_RPM_STEP; -} - -static u8 reg_val_to_direction(u8 reg_val, enum fan_id id) -{ - return !!(reg_val & (1 << id)); -} - -static u8 reg_val_to_is_present(u8 reg_val, enum fan_id id) -{ - return !(reg_val & (1 << id)); -} - -static u8 is_fan_fault(u8 reg_val, enum fan_id id) -{ - return !!(reg_val & (1 << id)); -} -#if 0 -static u8 is_fan_fault(struct as7116_54x_fan_data *data, enum fan_id id) -{ - u8 ret = 1; - int front_fan_index = FAN1_FRONT_SPEED_RPM + id; - int rear_fan_index = FAN1_REAR_SPEED_RPM + id; - - /* Check if the speed of front or rear fan is ZERO, - */ - if (reg_val_to_speed_rpm(data->reg_val[front_fan_index]) && - reg_val_to_speed_rpm(data->reg_val[rear_fan_index])) { - ret = 0; - } - - return ret; -} -#endif - -static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - int error, value; - struct i2c_client *client = to_i2c_client(dev); - - error = kstrtoint(buf, 10, &value); - if (error) - return error; - - if (value < FAN_MIN_DUTY_CYCLE) { - value = FAN_MIN_DUTY_CYCLE; - } - - if (value > FAN_MAX_DUTY_CYCLE) { - value = FAN_MAX_DUTY_CYCLE; - } - - as7116_54x_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); - return count; -} - -static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct as7116_54x_fan_data *data = as7116_54x_fan_update_device(dev); - ssize_t ret = 0; - - if (data->valid) { - switch (attr->index) { - case FAN_DUTY_CYCLE_PERCENTAGE: - { - u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]); - ret = sprintf(buf, "%u\n", duty_cycle); - break; - } - case FAN1_FRONT_SPEED_RPM: - case FAN2_FRONT_SPEED_RPM: - case FAN3_FRONT_SPEED_RPM: - case FAN4_FRONT_SPEED_RPM: - case FAN5_FRONT_SPEED_RPM: - case FAN1_REAR_SPEED_RPM: - case FAN2_REAR_SPEED_RPM: - case FAN3_REAR_SPEED_RPM: - case FAN4_REAR_SPEED_RPM: - case FAN5_REAR_SPEED_RPM: - ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index])); - break; - case FAN1_PRESENT: - case FAN2_PRESENT: - case FAN3_PRESENT: - case FAN4_PRESENT: - case FAN5_PRESENT: - ret = sprintf(buf, "%d\n", - reg_val_to_is_present(data->reg_val[FAN_PRESENT_REG], - attr->index - FAN1_PRESENT)); - break; - case FAN1_FRONT_FAULT: - case FAN2_FRONT_FAULT: - case FAN3_FRONT_FAULT: - case FAN4_FRONT_FAULT: - case FAN5_FRONT_FAULT: - ret = sprintf(buf, "%d\n", - is_fan_fault(data->reg_val[FAN_FRONT_FAULT_REG], - attr->index - FAN1_FRONT_FAULT)); - break; - case FAN1_REAR_FAULT: - case FAN2_REAR_FAULT: - case FAN3_REAR_FAULT: - case FAN4_REAR_FAULT: - case FAN5_REAR_FAULT: - ret = sprintf(buf, "%d\n", - is_fan_fault(data->reg_val[FAN_REAR_FAULT_REG], - attr->index - FAN1_REAR_FAULT)); - break; - case FAN1_DIRECTION: - case FAN2_DIRECTION: - case FAN3_DIRECTION: - case FAN4_DIRECTION: - case FAN5_DIRECTION: - ret = sprintf(buf, "%d\n", - reg_val_to_direction(data->reg_val[FAN_DIRECTION_REG], - attr->index - FAN1_DIRECTION)); - break; - case FAN1_INPUT: - case FAN2_INPUT: - case FAN3_INPUT: - case FAN4_INPUT: - case FAN5_INPUT: - case FAN6_INPUT: - case FAN7_INPUT: - case FAN8_INPUT: - case FAN9_INPUT: - case FAN10_INPUT: - ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index - - FAN1_INPUT + FAN1_FRONT_SPEED_RPM])); - break; - default: - break; - } - } - - return ret; -} - -static const struct attribute_group as7116_54x_fan_group = { - .attrs = as7116_54x_fan_attributes, -}; - -static struct as7116_54x_fan_data *as7116_54x_fan_update_device(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct as7116_54x_fan_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || - !data->valid) { - int i; - - dev_dbg(&client->dev, "Starting as7116_54x_fan update\n"); - data->valid = 0; - - /* Update fan data - */ - for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) { - int status = as7116_54x_fan_read_value(client, fan_reg[i]); - - if (status < 0) { - data->valid = 0; - mutex_unlock(&data->update_lock); - dev_dbg(&client->dev, "reg %d, err %d\n", fan_reg[i], status); - return data; - } - else { - data->reg_val[i] = status; - } - } - - data->last_updated = jiffies; - data->valid = 1; - } - - mutex_unlock(&data->update_lock); - - return data; -} - -static int as7116_54x_fan_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct as7116_54x_fan_data *data; - int status; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct as7116_54x_fan_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - i2c_set_clientdata(client, data); - data->valid = 0; - mutex_init(&data->update_lock); - - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as7116_54x_fan_group); - if (status) { - goto exit_free; - } - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - dev_info(&client->dev, "%s: fan '%s'\n", - dev_name(data->hwmon_dev), client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &as7116_54x_fan_group); -exit_free: - kfree(data); -exit: - - return status; -} - -static int as7116_54x_fan_remove(struct i2c_client *client) -{ - struct as7116_54x_fan_data *data = i2c_get_clientdata(client); - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as7116_54x_fan_group); - - return 0; -} - -/* Addresses to scan */ -static const unsigned short normal_i2c[] = { 0x66, I2C_CLIENT_END }; - -static const struct i2c_device_id as7116_54x_fan_id[] = { - { "as7116_54x_fan", 0 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, as7116_54x_fan_id); - -static struct i2c_driver as7116_54x_fan_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = DRVNAME, - }, - .probe = as7116_54x_fan_probe, - .remove = as7116_54x_fan_remove, - .id_table = as7116_54x_fan_id, - .address_list = normal_i2c, -}; - -static int __init as7116_54x_fan_init(void) -{ -#if 0 - extern int platform_accton_as7116_54x(void); - if (!platform_accton_as7116_54x()) { - return -ENODEV; - } -#endif - return i2c_add_driver(&as7116_54x_fan_driver); -} - -static void __exit as7116_54x_fan_exit(void) -{ - i2c_del_driver(&as7116_54x_fan_driver); -} - -module_init(as7116_54x_fan_init); -module_exit(as7116_54x_fan_exit); - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("as7116_54x_fan driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-led.c b/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-led.c deleted file mode 100644 index cd69f711c82..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-led.c +++ /dev/null @@ -1,448 +0,0 @@ -/* - * A LED driver for the accton_as7116_54x_led - * - * Copyright (C) 2014 Accton Technology Corporation. - * Brandon Chuang - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define DRVNAME "as7116_54x_fan" - -#define DEBUG_MODE 0 -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -extern int as7116_54x_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as7116_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -struct as7116_54x_led_data { - struct platform_device *pdev; - struct mutex update_lock; - char valid; /* != 0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 reg_val[1]; /* LOC/DIAG LED */ -}; - -static struct as7116_54x_led_data *ledctl = NULL; - -/* LED related data - */ - -#define LED_CNTRLER_I2C_ADDRESS (0x60) - -#define LED_TYPE_DIAG_REG_MASK (0x0C) -#define LED_MODE_DIAG_GREEN_VALUE (0x08) -#define LED_MODE_DIAG_AMBER_VALUE (0x04) -#define LED_MODE_DIAG_YELLOW_VALUE (0x00) -#define LED_MODE_DIAG_OFF_VALUE (0x0C) - -#define LED_TYPE_FAN_REG_MASK (0x03) -#define LED_MODE_FAN_GREEN_VALUE (0x02) -#define LED_MODE_FAN_AMBER_VALUE (0x01) -#define LED_MODE_FAN_OFF_VALUE (0x03) -#define LED_MODE_FAN_AUTO_VALUE (0x00) - -#define LED_TYPE_PSU1_REG_MASK (0x03) -#define LED_MODE_PSU1_GREEN_VALUE (0x02) -#define LED_MODE_PSU1_AMBER_VALUE (0x01) -#define LED_MODE_PSU1_OFF_VALUE (0x03) -#define LED_MODE_PSU1_AUTO_VALUE (0x00) - -#define LED_TYPE_PSU2_REG_MASK (0x0C) -#define LED_MODE_PSU2_GREEN_VALUE (0x08) -#define LED_MODE_PSU2_AMBER_VALUE (0x04) -#define LED_MODE_PSU2_OFF_VALUE (0x0C) -#define LED_MODE_PSU2_AUTO_VALUE (0x00) - -#define LED_TYPE_LOC_REG_MASK (0x30) -#define LED_MODE_LOC_AMBER_VALUE (0x00) -#define LED_MODE_LOC_AMBER_BLINKING_VALUE1 (0x20) -#define LED_MODE_LOC_AMBER_BLINKING_VALUE2 (0x30) -#define LED_MODE_LOC_OFF_VALUE (0x10) - -static const u8 led_reg[] = { - 0x0A, /* LOC/DIAG/FAN LED */ - 0x0B, /* PSU1/PSU2 LED */ -}; - -enum led_type { - LED_TYPE_DIAG, - LED_TYPE_LOC, - LED_TYPE_FAN, - LED_TYPE_PSU1, - LED_TYPE_PSU2 -}; - -enum led_light_mode { - LED_MODE_OFF = 0, - LED_MODE_GREEN, - LED_MODE_GREEN_BLINK, - LED_MODE_AMBER, - LED_MODE_AMBER_BLINK, - LED_MODE_YELLOW, - LED_MODE_YELLOW_BLINK, - LED_MODE_BLUE, - LED_MODE_BLUE_BLINK, - LED_MODE_AUTO, - LED_MODE_UNKNOWN -}; - -struct led_type_mode { - enum led_type type; - enum led_light_mode mode; - int type_mask; - int mode_value; -}; - -static struct led_type_mode led_type_mode_data[] = { -{LED_TYPE_FAN, LED_MODE_OFF, LED_TYPE_FAN_REG_MASK, LED_MODE_FAN_OFF_VALUE}, -{LED_TYPE_FAN, LED_MODE_GREEN, LED_TYPE_FAN_REG_MASK, LED_MODE_FAN_GREEN_VALUE}, -{LED_TYPE_FAN, LED_MODE_AMBER, LED_TYPE_FAN_REG_MASK, LED_MODE_FAN_AMBER_VALUE}, -{LED_TYPE_FAN, LED_MODE_AUTO, LED_TYPE_FAN_REG_MASK, LED_MODE_FAN_AUTO_VALUE}, -{LED_TYPE_PSU1, LED_MODE_OFF, LED_TYPE_PSU1_REG_MASK, LED_MODE_PSU1_OFF_VALUE}, -{LED_TYPE_PSU1, LED_MODE_GREEN, LED_TYPE_PSU1_REG_MASK, LED_MODE_PSU1_GREEN_VALUE}, -{LED_TYPE_PSU1, LED_MODE_AMBER, LED_TYPE_PSU1_REG_MASK, LED_MODE_PSU1_AMBER_VALUE}, -{LED_TYPE_PSU1, LED_MODE_AUTO, LED_TYPE_PSU1_REG_MASK, LED_MODE_PSU1_AUTO_VALUE}, -{LED_TYPE_PSU2, LED_MODE_OFF, LED_TYPE_PSU2_REG_MASK, LED_MODE_PSU2_OFF_VALUE}, -{LED_TYPE_PSU2, LED_MODE_GREEN, LED_TYPE_PSU2_REG_MASK, LED_MODE_PSU2_GREEN_VALUE}, -{LED_TYPE_PSU2, LED_MODE_AMBER, LED_TYPE_PSU2_REG_MASK, LED_MODE_PSU2_AMBER_VALUE}, -{LED_TYPE_PSU2, LED_MODE_AUTO, LED_TYPE_PSU2_REG_MASK, LED_MODE_PSU2_AUTO_VALUE}, -{LED_TYPE_DIAG, LED_MODE_OFF, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_OFF_VALUE}, -{LED_TYPE_DIAG, LED_MODE_GREEN, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_GREEN_VALUE}, -{LED_TYPE_DIAG, LED_MODE_AMBER, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_AMBER_VALUE}, -{LED_TYPE_DIAG, LED_MODE_YELLOW, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_YELLOW_VALUE}, -{LED_TYPE_LOC, LED_MODE_OFF, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_OFF_VALUE}, -{LED_TYPE_LOC, LED_MODE_AMBER, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_AMBER_VALUE}, -{LED_TYPE_LOC, LED_MODE_AMBER_BLINK, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_AMBER_BLINKING_VALUE1}, -{LED_TYPE_LOC, LED_MODE_AMBER_BLINK, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_AMBER_BLINKING_VALUE2} -}; - -static int led_reg_val_to_light_mode(enum led_type type, u8 reg_val) { - int i; - - for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { - if (type != led_type_mode_data[i].type) { - continue; - } - - if ((led_type_mode_data[i].type_mask & reg_val) == - led_type_mode_data[i].mode_value) { - return led_type_mode_data[i].mode; - } - } - - return LED_MODE_UNKNOWN; -} - -static u8 led_light_mode_to_reg_val(enum led_type type, - enum led_light_mode mode, u8 reg_val) { - int i; - - for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { - int type_mask, mode_value; - - if (type != led_type_mode_data[i].type) - continue; - - if (mode != led_type_mode_data[i].mode) - continue; - - type_mask = led_type_mode_data[i].type_mask; - mode_value = led_type_mode_data[i].mode_value; - reg_val = (reg_val & ~type_mask) | mode_value; - } - - return reg_val; -} - -static int as7116_54x_led_read_value(u8 reg) -{ - return as7116_54x_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); -} - -static int as7116_54x_led_write_value(u8 reg, u8 value) -{ - return as7116_54x_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); -} - -static void as7116_54x_led_update(void) -{ - mutex_lock(&ledctl->update_lock); - - if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2) - || !ledctl->valid) { - int i; - - dev_dbg(&ledctl->pdev->dev, "Starting accton_as7116_54x_led update\n"); - ledctl->valid = 0; - - /* Update LED data - */ - for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { - int status = as7116_54x_led_read_value(led_reg[i]); - - if (status < 0) { - dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg[i], status); - goto exit; - } - else { - ledctl->reg_val[i] = status; - } - } - - ledctl->last_updated = jiffies; - ledctl->valid = 1; - } - -exit: - mutex_unlock(&ledctl->update_lock); -} - -static void as7116_54x_led_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode, - u8 reg, enum led_type type) -{ - int reg_val; - - mutex_lock(&ledctl->update_lock); - - reg_val = as7116_54x_led_read_value(reg); - - if (reg_val < 0) { - dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val); - goto exit; - } - reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val); - as7116_54x_led_write_value(reg, reg_val); - - /* to prevent the slow-update issue */ - ledctl->valid = 0; - -exit: - mutex_unlock(&ledctl->update_lock); -} - - -static void as7116_54x_led_diag_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - as7116_54x_led_set(led_cdev, led_light_mode, led_reg[0], LED_TYPE_DIAG); -} - -static enum led_brightness as7116_54x_led_diag_get(struct led_classdev *cdev) -{ - as7116_54x_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_DIAG, ledctl->reg_val[0]); -} - -static void as7116_54x_led_loc_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - as7116_54x_led_set(led_cdev, led_light_mode, led_reg[0], LED_TYPE_LOC); -} - -static enum led_brightness as7116_54x_led_loc_get(struct led_classdev *cdev) -{ - as7116_54x_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[0]); -} - -static void as7116_54x_led_fan_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - as7116_54x_led_set(led_cdev, led_light_mode, led_reg[0], LED_TYPE_FAN); -} - -static enum led_brightness as7116_54x_led_fan_get(struct led_classdev *cdev) -{ - as7116_54x_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_FAN, ledctl->reg_val[0]); -} - -static void as7116_54x_led_psu1_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - as7116_54x_led_set(led_cdev, led_light_mode, led_reg[1], LED_TYPE_PSU1); -} - -static enum led_brightness as7116_54x_led_psu1_get(struct led_classdev *cdev) -{ - as7116_54x_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_PSU1, ledctl->reg_val[1]); -} - -static void as7116_54x_led_psu2_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - as7116_54x_led_set(led_cdev, led_light_mode, led_reg[1], LED_TYPE_PSU2); -} - -static enum led_brightness as7116_54x_led_psu2_get(struct led_classdev *cdev) -{ - as7116_54x_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_PSU2, ledctl->reg_val[1]); -} - -static struct led_classdev as7116_54x_leds[] = { - [LED_TYPE_DIAG] = { - .name = "as7116_54x_led::diag", - .default_trigger = "unused", - .brightness_set = as7116_54x_led_diag_set, - .brightness_get = as7116_54x_led_diag_get, - .max_brightness = LED_MODE_YELLOW, - }, - [LED_TYPE_LOC] = { - .name = "as7116_54x_led::loc", - .default_trigger = "unused", - .brightness_set = as7116_54x_led_loc_set, - .brightness_get = as7116_54x_led_loc_get, - .max_brightness = LED_MODE_AMBER_BLINK, - }, - [LED_TYPE_FAN] = { - .name = "as7116_54x_led::fan", - .default_trigger = "unused", - .brightness_set = as7116_54x_led_fan_set, - .brightness_get = as7116_54x_led_fan_get, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_PSU1] = { - .name = "as7116_54x_led::psu1", - .default_trigger = "unused", - .brightness_set = as7116_54x_led_psu1_set, - .brightness_get = as7116_54x_led_psu1_get, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_PSU2] = { - .name = "as7116_54x_led::psu2", - .default_trigger = "unused", - .brightness_set = as7116_54x_led_psu2_set, - .brightness_get = as7116_54x_led_psu2_get, - .max_brightness = LED_MODE_AUTO, - }, -}; - - -static int as7116_54x_led_probe(struct platform_device *pdev) -{ - int ret, i; - - for (i = 0; i < ARRAY_SIZE(as7116_54x_leds); i++) { - ret = led_classdev_register(&pdev->dev, &as7116_54x_leds[i]); - - if (ret < 0) { - break; - } - } - - /* Check if all LEDs were successfully registered */ - if (i != ARRAY_SIZE(as7116_54x_leds)){ - int j; - - /* only unregister the LEDs that were successfully registered */ - for (j = 0; j < i; j++) { - led_classdev_unregister(&as7116_54x_leds[i]); - } - } - - return ret; -} - -static int as7116_54x_led_remove(struct platform_device *pdev) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(as7116_54x_leds); i++) { - led_classdev_unregister(&as7116_54x_leds[i]); - } - - return 0; -} - -static struct platform_driver as7116_54x_led_driver = { - .probe = as7116_54x_led_probe, - .remove = as7116_54x_led_remove, - .driver = { - .name = DRVNAME, - .owner = THIS_MODULE, - }, -}; - -static int __init as7116_54x_led_init(void) -{ - int ret; - -#if 0 - extern int platform_accton_as7116_54x(void); - if (!platform_accton_as7116_54x()) { - return -ENODEV; - } -#endif - - ret = platform_driver_register(&as7116_54x_led_driver); - if (ret < 0) { - goto exit; - } - - ledctl = kzalloc(sizeof(struct as7116_54x_led_data), GFP_KERNEL); - if (!ledctl) { - ret = -ENOMEM; - goto exit_driver; - } - - mutex_init(&ledctl->update_lock); - - ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); - if (IS_ERR(ledctl->pdev)) { - ret = PTR_ERR(ledctl->pdev); - goto exit_free; - } - - return 0; - -exit_free: - kfree(ledctl); -exit_driver: - platform_driver_unregister(&as7116_54x_led_driver); -exit: - return ret; -} - -static void __exit as7116_54x_led_exit(void) -{ - platform_device_unregister(ledctl->pdev); - platform_driver_unregister(&as7116_54x_led_driver); - kfree(ledctl); -} - -module_init(as7116_54x_led_init); -module_exit(as7116_54x_led_exit); - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton_as7116_54x_led driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-psu.c b/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-psu.c deleted file mode 100644 index b4e14297f41..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-psu.c +++ /dev/null @@ -1,349 +0,0 @@ -/* - * An hwmon driver for accton as7116_54x Power Module - * - * Copyright (C) 2014 Accton Technology Corporation. - * Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PSU_STATUS_I2C_ADDR 0x60 -#define PSU_STATUS_I2C_REG_OFFSET 0x2 - -#define MODEL_NAME_LEN 11 -#define MODEL_NAME_REG_OFFSET 0x20 - -#define SERIAL_NUM_LEN 18 -#define SERIAL_NUM_REG_OFFSET 0x35 - -#define IS_POWER_GOOD(id, value) (!!(value & BIT(id*4 + 1))) -#define IS_PRESENT(id, value) (!(value & BIT(id*4))) - -static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_string(struct device *dev, struct device_attribute *da, char *buf); -static int as7116_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int as7116_54x_cpld_read(unsigned short cpld_addr, u8 reg); -static struct as7116_54x_psu_data *as7116_54x_psu_update_device(struct device *dev, u8 update_eeprom); - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -/* Each client has this additional data - */ -struct as7116_54x_psu_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 index; /* PSU index */ - u8 status; /* Status(present/power_good) register read from CPLD */ - char model_name[MODEL_NAME_LEN+1]; /* Model name, read from eeprom */ - char serial[SERIAL_NUM_LEN+1]; /* Serial number, read from eeprom*/ -}; - -enum as7116_54x_psu_sysfs_attributes { - PSU_PRESENT, - PSU_MODEL_NAME, - PSU_POWER_GOOD, - PSU_SERIAL_NUMBER -}; - -/* sysfs attributes for hwmon - */ -static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); -static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_string, NULL, PSU_MODEL_NAME); -static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); -static SENSOR_DEVICE_ATTR(psu_serial_numer, S_IRUGO, show_string, NULL, PSU_SERIAL_NUMBER); - -static struct attribute *as7116_54x_psu_attributes[] = { - &sensor_dev_attr_psu_present.dev_attr.attr, - &sensor_dev_attr_psu_model_name.dev_attr.attr, - &sensor_dev_attr_psu_power_good.dev_attr.attr, - &sensor_dev_attr_psu_serial_numer.dev_attr.attr, - NULL -}; - -static ssize_t show_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct as7116_54x_psu_data *data = as7116_54x_psu_update_device(dev, 0); - u8 status = 0; - - if (!data->valid) { - return -EIO; - } - - if (attr->index == PSU_PRESENT) { - status = IS_PRESENT(data->index, data->status); - } - else { /* PSU_POWER_GOOD */ - status = IS_POWER_GOOD(data->index, data->status); - } - - return sprintf(buf, "%d\n", status); -} - -static ssize_t show_string(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct as7116_54x_psu_data *data = as7116_54x_psu_update_device(dev, 1); - char *ptr = NULL; - - if (!data->valid) { - return -EIO; - } - - if (!IS_PRESENT(data->index, data->status)) { - return -ENXIO; - } - - if (attr->index == PSU_MODEL_NAME) { - ptr = data->model_name; - } - else { /* PSU_SERIAL_NUBMER */ - ptr = data->serial; - } - - return sprintf(buf, "%s\n", ptr); -} - -static const struct attribute_group as7116_54x_psu_group = { - .attrs = as7116_54x_psu_attributes, -}; - -static int as7116_54x_psu_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct as7116_54x_psu_data *data; - int status; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct as7116_54x_psu_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - i2c_set_clientdata(client, data); - data->valid = 0; - data->index = dev_id->driver_data; - mutex_init(&data->update_lock); - - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as7116_54x_psu_group); - if (status) { - goto exit_free; - } - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - dev_info(&client->dev, "%s: psu '%s'\n", - dev_name(data->hwmon_dev), client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &as7116_54x_psu_group); -exit_free: - kfree(data); -exit: - - return status; -} - -static int as7116_54x_psu_remove(struct i2c_client *client) -{ - struct as7116_54x_psu_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as7116_54x_psu_group); - kfree(data); - - return 0; -} - -enum psu_index -{ - as7116_54x_psu1, - as7116_54x_psu2 -}; - -static const struct i2c_device_id as7116_54x_psu_id[] = { - { "as7116_54x_psu1", as7116_54x_psu1 }, - { "as7116_54x_psu2", as7116_54x_psu2 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, as7116_54x_psu_id); - -static struct i2c_driver as7116_54x_psu_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "as7116_54x_psu", - }, - .probe = as7116_54x_psu_probe, - .remove = as7116_54x_psu_remove, - .id_table = as7116_54x_psu_id, - .address_list = normal_i2c, -}; - -static int as7116_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ - int result = 0; - int retry_count = 5; - - while (retry_count) { - retry_count--; - - result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - - if (unlikely(result < 0)) { - msleep(10); - continue; - } - - if (unlikely(result != data_len)) { - result = -EIO; - msleep(10); - continue; - } - - result = 0; - break; - } - - return result; -} - -static struct as7116_54x_psu_data *as7116_54x_psu_update_device(struct device *dev, u8 update_eeprom) -{ - struct i2c_client *client = to_i2c_client(dev); - struct as7116_54x_psu_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->last_updated + HZ + HZ / 2) - || !data->valid) { - int status; - - data->valid = 0; - dev_dbg(&client->dev, "Starting as7116_54x update\n"); - - /* Read psu status */ - status = as7116_54x_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); - - if (status < 0) { - dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); - goto exit; - } - else { - data->status = status; - } - - - memset(data->model_name, 0, sizeof(data->model_name)); - memset(data->serial, 0, sizeof(data->serial)); - - if (update_eeprom && IS_PRESENT(data->index, data->status)) { - /* Read model name */ - status = as7116_54x_psu_read_block(client, MODEL_NAME_REG_OFFSET, data->model_name, - ARRAY_SIZE(data->model_name)-1); - - if (status < 0) { - data->model_name[0] = '\0'; - dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr); - goto exit; - } - else { - /* Skip the meaningless data byte 8*/ - data->model_name[8] = data->model_name[9]; - data->model_name[9] = data->model_name[10]; - data->model_name[10] = '\0'; - } - - /* Read serial number */ - status = as7116_54x_psu_read_block(client, SERIAL_NUM_REG_OFFSET, data->serial, - ARRAY_SIZE(data->serial)-1); - - if (status < 0) { - data->serial[0] = '\0'; - dev_dbg(&client->dev, "unable to read serial number from (0x%x)\n", client->addr); - goto exit; - } - else { - data->serial[SERIAL_NUM_LEN] = '\0'; - } - } - - data->last_updated = jiffies; - data->valid = 1; - } - -exit: - mutex_unlock(&data->update_lock); - - return data; -} - -static int __init as7116_54x_psu_init(void) -{ - //extern int platform_accton_as7116_54x(void); - //if (!platform_accton_as7116_54x()) { - // return -ENODEV; - //} - - return i2c_add_driver(&as7116_54x_psu_driver); -} - -static void __exit as7116_54x_psu_exit(void) -{ - i2c_del_driver(&as7116_54x_psu_driver); -} - -module_init(as7116_54x_psu_init); -module_exit(as7116_54x_psu_exit); - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("as7116_54x_psu driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-sfp.c b/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-sfp.c deleted file mode 100644 index 540ceb21722..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/as7116-54x/modules/x86-64-accton-as7116-54x-sfp.c +++ /dev/null @@ -1,1384 +0,0 @@ -/* - * SFP driver for accton as7116_54x sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as7116_54x_sfp" /* Platform dependent */ - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 3 -#define I2C_RW_RETRY_INTERVAL 100 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) -#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 -#define SFF8472_10G_BASE_MASK 0xF0 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int as7116_54x_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as7116_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); -static struct attribute *sfp_msa_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - NULL -}; - -/* SFP ddm attributes for sysfs */ -static struct attribute *sfp_ddm_attributes[] = { - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -as7116_54x_sfp1, as7116_54x_sfp2, as7116_54x_sfp3, as7116_54x_sfp4, -as7116_54x_sfp5, as7116_54x_sfp6, as7116_54x_sfp7, as7116_54x_sfp8, -as7116_54x_sfp9, as7116_54x_sfp10, as7116_54x_sfp11, as7116_54x_sfp12, -as7116_54x_sfp13, as7116_54x_sfp14, as7116_54x_sfp15, as7116_54x_sfp16, -as7116_54x_sfp17, as7116_54x_sfp18, as7116_54x_sfp19, as7116_54x_sfp20, -as7116_54x_sfp21, as7116_54x_sfp22, as7116_54x_sfp23, as7116_54x_sfp24, -as7116_54x_sfp25, as7116_54x_sfp26, as7116_54x_sfp27, as7116_54x_sfp28, -as7116_54x_sfp29, as7116_54x_sfp30, as7116_54x_sfp31, as7116_54x_sfp32, -as7116_54x_sfp33, as7116_54x_sfp34, as7116_54x_sfp35, as7116_54x_sfp36, -as7116_54x_sfp37, as7116_54x_sfp38, as7116_54x_sfp39, as7116_54x_sfp40, -as7116_54x_sfp41, as7116_54x_sfp42, as7116_54x_sfp43, as7116_54x_sfp44, -as7116_54x_sfp45, as7116_54x_sfp46, as7116_54x_sfp47, as7116_54x_sfp48, -as7116_54x_sfp49, as7116_54x_sfp50, as7116_54x_sfp51, as7116_54x_sfp52, -as7116_54x_sfp53, as7116_54x_sfp54 -}; - -#define I2C_DEV_ID(x) { #x, x} - -static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(as7116_54x_sfp1), -I2C_DEV_ID(as7116_54x_sfp2), -I2C_DEV_ID(as7116_54x_sfp3), -I2C_DEV_ID(as7116_54x_sfp4), -I2C_DEV_ID(as7116_54x_sfp5), -I2C_DEV_ID(as7116_54x_sfp6), -I2C_DEV_ID(as7116_54x_sfp7), -I2C_DEV_ID(as7116_54x_sfp8), -I2C_DEV_ID(as7116_54x_sfp9), -I2C_DEV_ID(as7116_54x_sfp10), -I2C_DEV_ID(as7116_54x_sfp11), -I2C_DEV_ID(as7116_54x_sfp12), -I2C_DEV_ID(as7116_54x_sfp13), -I2C_DEV_ID(as7116_54x_sfp14), -I2C_DEV_ID(as7116_54x_sfp15), -I2C_DEV_ID(as7116_54x_sfp16), -I2C_DEV_ID(as7116_54x_sfp17), -I2C_DEV_ID(as7116_54x_sfp18), -I2C_DEV_ID(as7116_54x_sfp19), -I2C_DEV_ID(as7116_54x_sfp20), -I2C_DEV_ID(as7116_54x_sfp21), -I2C_DEV_ID(as7116_54x_sfp22), -I2C_DEV_ID(as7116_54x_sfp23), -I2C_DEV_ID(as7116_54x_sfp24), -I2C_DEV_ID(as7116_54x_sfp25), -I2C_DEV_ID(as7116_54x_sfp26), -I2C_DEV_ID(as7116_54x_sfp27), -I2C_DEV_ID(as7116_54x_sfp28), -I2C_DEV_ID(as7116_54x_sfp29), -I2C_DEV_ID(as7116_54x_sfp30), -I2C_DEV_ID(as7116_54x_sfp31), -I2C_DEV_ID(as7116_54x_sfp32), -I2C_DEV_ID(as7116_54x_sfp33), -I2C_DEV_ID(as7116_54x_sfp34), -I2C_DEV_ID(as7116_54x_sfp35), -I2C_DEV_ID(as7116_54x_sfp36), -I2C_DEV_ID(as7116_54x_sfp37), -I2C_DEV_ID(as7116_54x_sfp38), -I2C_DEV_ID(as7116_54x_sfp39), -I2C_DEV_ID(as7116_54x_sfp40), -I2C_DEV_ID(as7116_54x_sfp41), -I2C_DEV_ID(as7116_54x_sfp42), -I2C_DEV_ID(as7116_54x_sfp43), -I2C_DEV_ID(as7116_54x_sfp44), -I2C_DEV_ID(as7116_54x_sfp45), -I2C_DEV_ID(as7116_54x_sfp46), -I2C_DEV_ID(as7116_54x_sfp47), -I2C_DEV_ID(as7116_54x_sfp48), -I2C_DEV_ID(as7116_54x_sfp49), -I2C_DEV_ID(as7116_54x_sfp50), -I2C_DEV_ID(as7116_54x_sfp51), -I2C_DEV_ID(as7116_54x_sfp52), -I2C_DEV_ID(as7116_54x_sfp53), -I2C_DEV_ID(as7116_54x_sfp54), -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); - -/* - * list of valid port types - * note OOM_PORT_TYPE_NOT_PRESENT to indicate no - * module is present in this port - */ -typedef enum oom_driver_port_type_e { - OOM_DRIVER_PORT_TYPE_INVALID, - OOM_DRIVER_PORT_TYPE_NOT_PRESENT, - OOM_DRIVER_PORT_TYPE_SFP, - OOM_DRIVER_PORT_TYPE_SFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP, - OOM_DRIVER_PORT_TYPE_QSFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP28 -} oom_driver_port_type_t; - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct sfp_msa_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[6]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss - 3 => device id - 4 => 10G Ethernet Compliance Codes - to distinguish SFP or SFP+ - 5 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -}; - -struct sfp_ddm_data { - struct eeprom_data eeprom; -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - oom_driver_port_type_t port_type; - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct sfp_msa_data *msa; - struct sfp_ddm_data *ddm; - struct qsfp_data *qsfp; - - struct i2c_client *client; -}; - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - int i = 0, j = 0, status = -1; - u8 reg; - unsigned short cpld_addr; - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - data->present = 0; - - /* Read present status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 3; j++) { - cpld_addr = 0x61+i; - reg = 0x6+j; - status = as7116_54x_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - - DEBUG_PRINT("Present status = 0x%lx\r\n", data->present); - data->present |= (u64)status << ((i*24) + (j%3)*8); - } - } - - /* Read present status of port 49-54(QSFP port) */ - cpld_addr = 0x62; - reg = 0x14; - status = as7116_54x_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - else { - data->present |= (u64)status << 48; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static struct sfp_port_data *sfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0, j = 0; - int status = -1; - - if (time_before(jiffies, data->msa->last_updated + HZ + HZ / 2) && data->msa->valid) { - return data; - } - - DEBUG_PRINT("Starting as7116_54x sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->msa->valid = 0; - memset(data->msa->status, 0, sizeof(data->msa->status)); - - /* Read status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 9; j++) { - u8 reg; - unsigned short cpld_addr; - reg = 0x9+j; - cpld_addr = 0x61+i; - - status = as7116_54x_cpld_read(cpld_addr, reg); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - - data->msa->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); - } - } - - data->msa->valid = 1; - data->msa->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - unsigned short cpld_addr = 0; - u8 cpld_reg = 0, cpld_val = 0, cpld_bit = 0; - long disable; - int error; - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_set_tx_disable(dev, da, buf, count); - } - - error = kstrtol(buf, 10, &disable); - if (error) { - return error; - } - - mutex_lock(&data->update_lock); - - if(data->port < 24) { - cpld_addr = 0x61; - cpld_reg = 0xC + data->port / 8; - cpld_bit = 1 << (data->port % 8); - } - else { /* port 24 ~ 48 */ - cpld_addr = 0x62; - cpld_reg = 0xC + (data->port - 24) / 8; - cpld_bit = 1 << (data->port % 8); - } - - /* Read current status */ - cpld_val = as7116_54x_cpld_read(cpld_addr, cpld_reg); - - /* Update tx_disable status */ - if (disable) { - data->msa->status[1] |= BIT_INDEX(data->port); - cpld_val |= cpld_bit; - } - else { - data->msa->status[1] &= ~BIT_INDEX(data->port); - cpld_val &= ~cpld_bit; - } - - as7116_54x_cpld_write(cpld_addr, cpld_reg, cpld_val); - mutex_unlock(&data->update_lock); - return count; -} -/* Platform dependent --- */ - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return !(data->present & BIT_INDEX(data->port)); /* Platform dependent */ -} - -/* Platform dependent +++ */ -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[7] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 54 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5], - values[6] & 0x3F); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d\n", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *sfp_update_port_type(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - u8 buf = 0; - int status; - - mutex_lock(&data->update_lock); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - if (buf != SFF8024_DEVICE_ID_SFP) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - status = sfp_eeprom_read(client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); - data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; - break; - } - case DRIVER_TYPE_QSFP: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); - switch (buf) { - case SFF8024_DEVICE_ID_QSFP: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; - break; - case SFF8024_DEVICE_ID_QSFP_PLUS: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - case SFF8024_DEVICE_ID_QSFP28: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - default: - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - break; - } - default: - break; - } - - mutex_unlock(&data->update_lock); - return data; -} - -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - if (!present) { - /* port is not present */ - return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); - } - - sfp_update_port_type(dev); - return sprintf(buf, "%d\n", data->port_type); -} - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - DEBUG_PRINT(""); - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - DEBUG_PRINT(""); - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - DEBUG_PRINT(""); - goto exit; - } - } - msleep(200); - DEBUG_PRINT(""); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - DEBUG_PRINT(""); - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - DEBUG_PRINT(""); - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - DEBUG_PRINT(""); - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT(""); - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - DEBUG_PRINT(""); - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - DEBUG_PRINT(""); - data = qsfp_update_tx_rx_status(dev); - DEBUG_PRINT(""); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - DEBUG_PRINT(""); - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - DEBUG_PRINT(""); - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - data->qsfp->status[1] = disable & 0xF; - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status; - char ddm; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (status == 0) { - /* port is not present */ - return -ENODEV; - } - - status = sfp_eeprom_read(client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); - if (unlikely(status < 0)) { - return status; - } - - return sprintf(buf, "%d\n", !!(ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK)); -} - -/* Platform dependent +++ */ -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0, index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("driver type = (%d)", data->driver_type); - if (data->driver_type == DRIVER_TYPE_QSFP) { - DEBUG_PRINT(""); - return qsfp_show_tx_rx_status(dev, da, buf); - } - - DEBUG_PRINT(""); - data = sfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - if(attr->index == RX_LOS_ALL) { - int i = 0; - u8 values[6] = {0}; - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = (u8)(data->msa->status[2] >> (i * 8)); - } - - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } - - switch (attr->index) { - case TX_FAULT: - index = 0; - break; - case TX_DISABLE: - index = 1; - break; - case RX_LOS: - index = 2; - break; - default: - break; - } - - val = !!(data->msa->status[index] & BIT_INDEX(data->port)); - return sprintf(buf, "%d\n", val); -} -/* Platform dependent --- */ -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} - - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_write(data, buf, off, count); -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_read(data, buf, off, count); -} - -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; - eeprom->size = EEPROM_SIZE; - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; - -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} - -static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_msa_data **data) -{ - int status; - struct sfp_msa_data *msa; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); - if (!msa) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = msa; - dev_info(&client->dev, "sfp msa '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); -exit_free: - kfree(msa); -exit: - - return status; -} - -static const struct attribute_group sfp_ddm_group = { - .attrs = sfp_ddm_attributes, -}; - -static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_ddm_data **data) -{ - int status; - struct sfp_ddm_data *ddm; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); - if (!ddm) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = ddm; - dev_info(&client->dev, "sfp ddm '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); -exit_free: - kfree(ddm); -exit: - - return status; -} - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); - if (status) { - goto exit_remove; - } - - /* Bring QSFPs out of reset */ - as7116_54x_cpld_write(0x62, 0x15, 0x3F); - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct sfp_port_data *data = NULL; - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - - if (dev_id->driver_data >= as7116_54x_sfp1 && dev_id->driver_data <= as7116_54x_sfp48) { - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_MSA; - return sfp_msa_probe(client, dev_id, &data->msa); - } - else if (client->addr == SFP_EEPROM_A2_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_DDM; - return sfp_ddm_probe(client, dev_id, &data->ddm); - } - } - else { /* as7116_54x_sfp49 ~ as7116_54x_sfp54 */ - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_QSFP; - return qsfp_probe(client, dev_id, &data->qsfp); - } - } - - return -ENODEV; -} -/* Platform dependent --- */ - -static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); - kfree(data); - return 0; -} - -static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_SFP_DDM: - return sfp_ddm_remove(client, data->ddm); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); - } - - return 0; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - //extern int platform_accton_as7116_54x(void); - //if (!platform_accton_as7116_54x()) { - // return -ENODEV; - //} - - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as7116_54x_sfp driver"); -MODULE_LICENSE("GPL"); - -module_init(sfp_init); -module_exit(sfp_exit); - diff --git a/platform/nephos/sonic-platform-modules-accton/as7116-54x/service/as7116-platform-init.service b/platform/nephos/sonic-platform-modules-accton/as7116-54x/service/as7116-platform-init.service deleted file mode 100755 index 6eaf4745210..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/as7116-54x/service/as7116-platform-init.service +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=Accton AS7116-54X Platform initialization service -Before=pmon.service -After=sysinit.target -DefaultDependencies=no - -[Service] -Type=oneshot -ExecStart=/usr/local/bin/accton_as7116_util.py install -ExecStop=/usr/local/bin/accton_as7116_util.py clean -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target diff --git a/platform/nephos/sonic-platform-modules-accton/as7116-54x/service/platform_api/platform_api_mgnt.sh b/platform/nephos/sonic-platform-modules-accton/as7116-54x/service/platform_api/platform_api_mgnt.sh deleted file mode 100755 index e1d33035789..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/as7116-54x/service/platform_api/platform_api_mgnt.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -PREV_REBOOT_CAUSE="/host/reboot-cause/" -DEVICE="/usr/share/sonic/device" -PLATFORM=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) -FILES=$DEVICE/$PLATFORM/api_files - -install() { - # Install sonic-platform package - if [ -e $DEVICE/$PLATFORM/sonic_platform-1.0-py2-none-any.whl ]; then - pip install $DEVICE/$PLATFORM/sonic_platform-1.0-py2-none-any.whl - fi -} - -init() { - # mount needed files for sonic-platform package - mkdir -p $FILES - - mkdir -p $FILES/reboot-cause - mount -B $PREV_REBOOT_CAUSE $FILES/reboot-cause -} - -deinit() { - # deinit sonic-platform package - umount -f $PREV_REBOOT_CAUSE $FILES/reboot-cause >/dev/null 2>/dev/null -} - -uninstall() { - # Uninstall sonic-platform package - pip uninstall -y sonic-platform >/dev/null 2>/dev/null -} - -case "$1" in -install | uninstall | init | deinit) - $1 - ;; -*) - echo "Usage: $0 {install|uninstall|init|deinit}" - exit 1 - ;; -esac diff --git a/platform/nephos/sonic-platform-modules-accton/as7116-54x/setup.py b/platform/nephos/sonic-platform-modules-accton/as7116-54x/setup.py deleted file mode 100644 index 088e1f30355..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/as7116-54x/setup.py +++ /dev/null @@ -1,34 +0,0 @@ -from setuptools import setup - -DEVICE_NAME = 'accton' -HW_SKU = 'x86_64-accton_as7116_54x-r0' - -setup( - name='sonic-platform', - version='1.0', - description='SONiC platform API implementation on Accton Platforms', - license='Apache 2.0', - author='SONiC Team', - author_email='linuxnetdev@microsoft.com', - url='https://github.com/Azure/sonic-buildimage', - maintainer='Simon Ji', - maintainer_email='Simon.Ji@mediatek.com', - packages=[ - 'sonic_platform', - ], - package_dir={ - 'sonic_platform': '../../../device/{}/{}/sonic_platform'.format(DEVICE_NAME, HW_SKU)}, - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Environment :: Plugins', - 'Intended Audience :: Developers', - 'Intended Audience :: Information Technology', - 'Intended Audience :: System Administrators', - 'License :: OSI Approved :: Apache Software License', - 'Natural Language :: English', - 'Operating System :: POSIX :: Linux', - 'Programming Language :: Python :: 2.7', - 'Topic :: Utilities', - ], - keywords='sonic SONiC platform PLATFORM', -) diff --git a/platform/nephos/sonic-platform-modules-accton/as7116-54x/utils/README b/platform/nephos/sonic-platform-modules-accton/as7116-54x/utils/README deleted file mode 100755 index 0b9fc163399..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/as7116-54x/utils/README +++ /dev/null @@ -1,60 +0,0 @@ -Copyright (C) 2016 Accton Networks, Inc. - -This program is free software: you can redistribute it and/or modify -It under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -To initialize the system, run "accton_as7712_util.py install". -To clean up the drivers & devices, run "accton_as7712_util.py clean". -To dump information of sensors, run "accton_as7712_util.py show". -To dump SFP EEPROM, run "accton_as7712_util.py sff". -To set fan speed, run "accton_as7712_util.py set fan". -To enable/disable SFP emission, run "accton_as7712_util.py set sfp". -To set system LEDs' color, run "accton_as7712_util.py set led" -For more information, run "accton_as7712_util.py --help". - -==================================================================== -Besides applying accton_as7712_util.py to access peripherals, you can -access peripherals by sysfs nodes directly after the installation is run. - -LED controls can be found under /sys/class/leds. The sysfs interface -color mappings are as follows: -Brightness: - 0 => off - 1 => green - 2 => amber - 3 => red - 4 => blue - -There are 5 system LEDs, loc, diag, fan, ps1, and ps2. -They are lit automatically by CPLD, but the loc and diag. -The loc led has only 1 color, blue. -The diag one has 3 colors: red, amber, and green. - -Fan controls can be found in /sys/bus/i2c/devices/2-0066. -There are 12 fans inside 6 fan modules. -All fans share 1 duty setting, ranged from 0~100. - -Three temperature sensors are controlled by the lm75 kernel modules. -They should already be visible under /sys/bus/i2c/drivers/lm75/. - -Two power supplies are controlled by the CPLD. -Here provide their status under -/sys/bus/i2c/devices/10-0050 and /sys/bus/i2c/devices/11-0053. - -There are 32 QSFP+ modules are equipped. -Apply "accton_as7712_util.py show" to get their status. -Apply "accton_as7712_util.py set sfp" to turn on/off light transmission. -Apply "accton_as7712_util.py sff" to dump EEPROM information. -Before operating on that QSFP+, please make sure it is well plugged. -Otherwise, operation is going to fail. - diff --git a/platform/nephos/sonic-platform-modules-accton/as7116-54x/utils/accton_as7116_util.py b/platform/nephos/sonic-platform-modules-accton/as7116-54x/utils/accton_as7116_util.py deleted file mode 100755 index 2d9ea128f97..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/as7116-54x/utils/accton_as7116_util.py +++ /dev/null @@ -1,533 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2016 Accton Networks, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -""" -Usage: %(scriptName)s [options] command object - -options: - -h | --help : this help message - -d | --debug : run with debug mode - -f | --force : ignore error during installation or clean -command: - install : install drivers and generate related sysfs nodes - clean : uninstall drivers and remove related sysfs nodes - show : show all systen status - sff : dump SFP eeprom - set : change board setting with fan|led|sfp -""" - -import os -import commands -import sys, getopt -import logging -import re -import time -from collections import namedtuple - - - - -PROJECT_NAME = 'as7116_54x' -version = '0.1.0' -verbose = False -DEBUG = False -args = [] -ALL_DEVICE = {} -DEVICE_NO = {'led':5, 'fan':1, 'thermal':3, 'psu':2, 'sfp':54} -FORCE = 0 -#logging.basicConfig(filename= PROJECT_NAME+'.log', filemode='w',level=logging.DEBUG) -#logging.basicConfig(level=logging.INFO) - - -if DEBUG == True: - print sys.argv[0] - print 'ARGV :', sys.argv[1:] - - -def main(): - global DEBUG - global args - global FORCE - - if len(sys.argv)<2: - show_help() - - options, args = getopt.getopt(sys.argv[1:], 'hdf', ['help', - 'debug', - 'force', - ]) - if DEBUG == True: - print options - print args - print len(sys.argv) - - for opt, arg in options: - if opt in ('-h', '--help'): - show_help() - elif opt in ('-d', '--debug'): - DEBUG = True - logging.basicConfig(level=logging.INFO) - elif opt in ('-f', '--force'): - FORCE = 1 - else: - logging.info('no option') - for arg in args: - if arg == 'install': - do_install() - elif arg == 'clean': - do_uninstall() - elif arg == 'show': - device_traversal() - elif arg == 'sff': - if len(args)!=2: - show_eeprom_help() - elif int(args[1]) ==0 or int(args[1]) > DEVICE_NO['sfp']: - show_eeprom_help() - else: - show_eeprom(args[1]) - return - elif arg == 'set': - if len(args)<3: - show_set_help() - else: - set_device(args[1:]) - return - else: - show_help() - - - return 0 - -def show_help(): - print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]} - sys.exit(0) - -def show_set_help(): - cmd = sys.argv[0].split("/")[-1]+ " " + args[0] - print cmd +" [led|sfp|fan]" - print " use \""+ cmd + " led 0-4 \" to set led color" - print " use \""+ cmd + " fan 0-100\" to set fan duty percetage" - print " use \""+ cmd + " sfp 1-54 {0|1}\" to set sfp# tx_disable" - sys.exit(0) - -def show_eeprom_help(): - cmd = sys.argv[0].split("/")[-1]+ " " + args[0] - print " use \""+ cmd + " 1-54 \" to dump sfp# eeprom" - sys.exit(0) - -def my_log(txt): - if DEBUG == True: - print "[ROY]"+txt - return - -def log_os_system(cmd, show): - logging.info('Run :'+cmd) - status, output = commands.getstatusoutput(cmd) - my_log (cmd +"with result:" + str(status)) - my_log (" output:"+output) - if status: - logging.info('Failed :'+cmd) - if show: - print('Failed :'+cmd) - return status, output - -def driver_check(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) - logging.info('mods:'+lsmod) - if len(lsmod) ==0: - return False - return True - - - -kos = [ - 'depmod', - 'modprobe i2c_dev', - 'modprobe i2c_mux_pca954x force_deselect_on_exit=1', - 'modprobe x86-64-accton-as7116-54x-cpld' , - 'modprobe x86-64-accton-as7116-54x-fan' , - 'modprobe x86-64-accton-as7116-54x-psu' , - 'modprobe x86-64-accton-as7116-54x-sfp' , - 'modprobe x86-64-accton-as7116-54x-led' ] - -def driver_install(): - global FORCE - for i in range(0,len(kos)): - status, output = log_os_system(kos[i], 1) - if status: - if FORCE == 0: - return status - return 0 - -def driver_uninstall(): - global FORCE - for i in range(0,len(kos)): - rm = kos[-(i+1)].replace("modprobe", "modprobe -rq") - rm = rm.replace("insmod", "rmmod") - status, output = log_os_system(rm, 1) - if status: - if FORCE == 0: - return status - return 0 - -led_prefix ='/sys/class/leds/'+PROJECT_NAME+'_led::' -hwmon_types = {'led': ['diag','fan','loc','psu1','psu2']} -hwmon_nodes = {'led': ['brightness'] } -hwmon_prefix ={'led': led_prefix} - -i2c_prefix = '/sys/bus/i2c/devices/' -i2c_bus = {'fan': ['1-0063'] , - 'thermal': ['17-004b','19-0049', '20-004a'] , - 'psu': ['10-0050','11-0058'], - 'sfp': ['-0050']} -i2c_nodes = {'fan': ['present', 'front_speed_rpm', 'rear_speed_rpm'] , - 'thermal': ['hwmon/hwmon*/temp1_input'] , - 'psu': ['psu_present ', 'psu_power_good'] , - 'sfp': ['sfp_is_present ', 'sfp_tx_disable_all']} - -sfp_map = [37,38,39,40, - 41,42,43,44,45,46,47,48,49,50, - 51,52,53,54,55,56,57,58,59,60, - 61,62,63,64,65,66,67,68,69,70, - 71,72,73,74,75,76,77,78,79,80, - 81,82,83,84, - 21,22,23,24,25,26] - -mknod =[ - 'echo pca9548 0x77 > /sys/bus/i2c/devices/i2c-0/new_device', - 'echo pca9548 0x70 > /sys/bus/i2c/devices/i2c-1/new_device', - 'echo pca9545 0x71 > /sys/bus/i2c/devices/i2c-1/new_device', - 'echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-1/new_device', - 'echo as7116_54x_fan 0x63 > /sys/bus/i2c/devices/i2c-1/new_device', - 'echo lm75 0x4b > /sys/bus/i2c/devices/i2c-17/new_device', - 'echo lm75 0x49 > /sys/bus/i2c/devices/i2c-19/new_device', - 'echo lm75 0x4a > /sys/bus/i2c/devices/i2c-20/new_device', - 'echo as7116_54x_cpld1 0x60 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo as7116_54x_cpld2 0x61 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo as7116_54x_cpld3 0x62 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo as7116_54x_psu1 0x50 > /sys/bus/i2c/devices/i2c-10/new_device', - 'echo ym2401 0x58 > /sys/bus/i2c/devices/i2c-10/new_device', - 'echo as7116_54x_psu2 0x53 > /sys/bus/i2c/devices/i2c-11/new_device', - 'echo ym2401 0x5b > /sys/bus/i2c/devices/i2c-11/new_device', - 'echo pca9548 0x70 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo pca9548 0x71 > /sys/bus/i2c/devices/i2c-29/new_device', - 'echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-30/new_device', - 'echo pca9548 0x73 > /sys/bus/i2c/devices/i2c-31/new_device', - 'echo pca9548 0x74 > /sys/bus/i2c/devices/i2c-32/new_device', - 'echo pca9548 0x75 > /sys/bus/i2c/devices/i2c-33/new_device', - 'echo pca9548 0x76 > /sys/bus/i2c/devices/i2c-34/new_device', - 'echo 24c02 0x56 > /sys/bus/i2c/devices/i2c-0/new_device'] - -def device_install(): - global FORCE - - for i in range(0,len(mknod)): - #for pca954x need times to built new i2c buses - if mknod[i].find('pca954') != -1: - time.sleep(1) - - status, output = log_os_system(mknod[i], 1) - if status: - print output - if FORCE == 0: - return status - - for i in range(0,len(sfp_map)): - status, output =log_os_system("echo as7116_54x_sfp"+str(i+1)+" 0x50 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1) - if status: - print output - if FORCE == 0: - return status - - if i <= 47: - status, output =log_os_system("echo as7116_54x_sfp"+str(i+1)+" 0x51 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1) - if status: - print output - if FORCE == 0: - return status - - return - -def device_uninstall(): - global FORCE - - status, output =log_os_system("ls /sys/bus/i2c/devices/1-0077", 0) - - for i in range(0,len(sfp_map)): - target = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/delete_device" - status, output =log_os_system("echo 0x50 > "+ target, 1) - if status: - print output - if FORCE == 0: - return status - - nodelist = mknod - - for i in range(len(nodelist)): - target = nodelist[-(i+1)] - temp = target.split() - del temp[1] - temp[-1] = temp[-1].replace('new_device', 'delete_device') - status, output = log_os_system(" ".join(temp), 1) - if status: - print output - if FORCE == 0: - return status - - return - -def system_ready(): - if driver_check() == False: - return False - if not device_exist(): - return False - return True - -def do_install(): - print "Checking system...." - if driver_check() == False: - print "No driver, installing...." - status = driver_install() - if status: - if FORCE == 0: - return status - else: - print PROJECT_NAME.upper()+" drivers detected...." - if not device_exist(): - print "No device, installing...." - status = device_install() - if status: - if FORCE == 0: - return status - else: - print PROJECT_NAME.upper()+" devices detected...." - - status, output = log_os_system( - "/bin/sh /usr/local/bin/platform_api_mgnt.sh init", 1) - if status: - print output - if FORCE == 0: - return status - return - -def do_uninstall(): - print "Checking system...." - if not device_exist(): - print PROJECT_NAME.upper() +" has no device installed...." - else: - print "Removing device...." - status = device_uninstall() - if status: - if FORCE == 0: - return status - - if driver_check()== False : - print PROJECT_NAME.upper() +" has no driver installed...." - else: - print "Removing installed driver...." - status = driver_uninstall() - if status: - if FORCE == 0: - return status - - return - -def devices_info(): - global DEVICE_NO - global ALL_DEVICE - global i2c_bus, hwmon_types - for key in DEVICE_NO: - ALL_DEVICE[key]= {} - for i in range(0,DEVICE_NO[key]): - ALL_DEVICE[key][key+str(i+1)] = [] - - for key in i2c_bus: - buses = i2c_bus[key] - nodes = i2c_nodes[key] - for i in range(0,len(buses)): - for j in range(0,len(nodes)): - if 'fan' == key: - for k in range(0,DEVICE_NO[key]): - node = key+str(k+1) - path = i2c_prefix+ buses[i]+"/fan"+str(k+1)+"_"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][node].append(path) - elif 'sfp' == key: - for k in range(0,DEVICE_NO[key]): - node = key+str(k+1) - path = i2c_prefix+ str(sfp_map[k])+ buses[i]+"/"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][node].append(path) - else: - node = key+str(i+1) - path = i2c_prefix+ buses[i]+"/"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][node].append(path) - - for key in hwmon_types: - itypes = hwmon_types[key] - nodes = hwmon_nodes[key] - for i in range(0,len(itypes)): - for j in range(0,len(nodes)): - node = key+"_"+itypes[i] - path = hwmon_prefix[key]+ itypes[i]+"/"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][ key+str(i+1)].append(path) - - #show dict all in the order - if DEBUG == True: - for i in sorted(ALL_DEVICE.keys()): - print(i+": ") - for j in sorted(ALL_DEVICE[i].keys()): - print(" "+j) - for k in (ALL_DEVICE[i][j]): - print(" "+" "+k) - return - -def show_eeprom(index): - if system_ready()==False: - print("System's not ready.") - print("Please install first!") - return - - if len(ALL_DEVICE)==0: - devices_info() - node = ALL_DEVICE['sfp'] ['sfp'+str(index)][0] - node = node.replace(node.split("/")[-1], 'sfp_eeprom') - # check if got hexdump command in current environment - ret, log = log_os_system("which hexdump", 0) - ret, log2 = log_os_system("which busybox hexdump", 0) - if len(log): - hex_cmd = 'hexdump' - elif len(log2): - hex_cmd = ' busybox hexdump' - else: - log = 'Failed : no hexdump cmd!!' - logging.info(log) - print log - return 1 - - print node + ":" - ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1) - if ret==0: - print log - else: - print "**********device no found**********" - return - -def set_device(args): - global DEVICE_NO - global ALL_DEVICE - if system_ready()==False: - print("System's not ready.") - print("Please install first!") - return - - if len(ALL_DEVICE)==0: - devices_info() - - if args[0]=='led': - if int(args[1])>4: - show_set_help() - return - #print ALL_DEVICE['led'] - for i in range(0,len(ALL_DEVICE['led'])): - for k in (ALL_DEVICE['led']['led'+str(i+1)]): - ret, log = log_os_system("echo "+args[1]+" >"+k, 1) - if ret: - return ret - elif args[0]=='fan': - if int(args[1])>100: - show_set_help() - return - #print ALL_DEVICE['fan'] - #fan1~6 is all fine, all fan share same setting - node = ALL_DEVICE['fan'] ['fan1'][0] - node = node.replace(node.split("/")[-1], 'fan_duty_cycle_percentage') - ret, log = log_os_system("cat "+ node, 1) - if ret==0: - print ("Previous fan duty: " + log.strip() +"%") - ret, log = log_os_system("echo "+args[1]+" >"+node, 1) - if ret==0: - print ("Current fan duty: " + args[1] +"%") - return ret - elif args[0]=='sfp': - if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0: - show_set_help() - return - if len(args)<2: - show_set_help() - return - - if int(args[2])>1: - show_set_help() - return - - #print ALL_DEVICE[args[0]] - for i in range(0,len(ALL_DEVICE[args[0]])): - for j in ALL_DEVICE[args[0]][args[0]+str(args[1])]: - if j.find('tx_disable')!= -1: - ret, log = log_os_system("echo "+args[2]+" >"+ j, 1) - if ret: - return ret - - return - -#get digits inside a string. -#Ex: 31 for "sfp31" -def get_value(input): - digit = re.findall('\d+', input) - return int(digit[0]) - -def device_traversal(): - if system_ready()==False: - print("System's not ready.") - print("Please install first!") - return - - if len(ALL_DEVICE)==0: - devices_info() - for i in sorted(ALL_DEVICE.keys()): - print("============================================") - print(i.upper()+": ") - print("============================================") - - for j in sorted(ALL_DEVICE[i].keys(), key=get_value): - print " "+j+":", - for k in (ALL_DEVICE[i][j]): - ret, log = log_os_system("cat "+k, 0) - func = k.split("/")[-1].strip() - func = re.sub(j+'_','',func,1) - func = re.sub(i.lower()+'_','',func,1) - if ret==0: - print func+"="+log+" ", - else: - print func+"="+"X"+" ", - print - print("----------------------------------------------------------------") - - - print - return - -def device_exist(): - ret1, log = log_os_system("ls "+i2c_prefix+"*0077", 0) - ret2, log = log_os_system("ls "+i2c_prefix+"i2c-2", 0) - return not(ret1 or ret2) - -if __name__ == "__main__": - main() diff --git a/platform/nephos/sonic-platform-modules-accton/debian/changelog b/platform/nephos/sonic-platform-modules-accton/debian/changelog deleted file mode 100755 index 595fe0985c0..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -sonic-accton-platform-modules (1.0.1) unstable; urgency=low - - * Add support for AS7116-54X series - - -- developer Wed, 29 Mar 2017 11:00:00 +0800 \ No newline at end of file diff --git a/platform/nephos/sonic-platform-modules-accton/debian/compat b/platform/nephos/sonic-platform-modules-accton/debian/compat deleted file mode 100644 index ec635144f60..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/platform/nephos/sonic-platform-modules-accton/debian/control b/platform/nephos/sonic-platform-modules-accton/debian/control deleted file mode 100755 index 3020b86408d..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/debian/control +++ /dev/null @@ -1,11 +0,0 @@ -Source: sonic-accton-platform-modules -Section: main -Priority: extra -Maintainer: simon.ji@nephosinc.com -Build-Depends: debhelper (>= 8.0.0), bzip2 -Standards-Version: 3.9.3 - -Package: sonic-platform-accton-as7116-54x -Architecture: amd64 -Depends: linux-image-4.19.0-12-2-amd64-unsigned -Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/nephos/sonic-platform-modules-accton/debian/rules b/platform/nephos/sonic-platform-modules-accton/debian/rules deleted file mode 100755 index de84b23d55a..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/debian/rules +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/make -f - -export INSTALL_MOD_DIR:=extra - -PYTHON ?= python2.7 - -PACKAGE_PRE_NAME := sonic-platform-accton -KVERSION ?= $(shell uname -r) -KERNEL_SRC := /lib/modules/$(KVERSION) -MOD_SRC_DIR:= $(shell pwd) -MODULE_DIRS:= as7116-54x -MODULE_DIR := modules -UTILS_DIR := utils -SERVICE_DIR := service -CLASSES_DIR := classes -CONF_DIR := conf - -%: - dh $@ - -override_dh_auto_build: - (for mod in $(MODULE_DIRS); do \ - make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ - $(PYTHON) $${mod}/setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ - done) - -override_dh_auto_install: - (for mod in $(MODULE_DIRS); do \ - dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} /$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ - cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko \ - debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ - done) - -override_dh_usrlocal: - -override_dh_clean: - dh_clean - (for mod in $(MODULE_DIRS); do \ - make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \ - done) diff --git a/platform/nephos/sonic-platform-modules-accton/debian/sonic-platform-accton-as7116-54x.install b/platform/nephos/sonic-platform-modules-accton/debian/sonic-platform-accton-as7116-54x.install deleted file mode 100644 index 61423affe7a..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/debian/sonic-platform-accton-as7116-54x.install +++ /dev/null @@ -1,4 +0,0 @@ -as7116-54x/utils/* usr/local/bin -as7116-54x/service/*.service lib/systemd/system -as7116-54x/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-accton_as7116_54x-r0 -as7116-54x/service/platform_api/platform_api_mgnt.sh usr/local/bin diff --git a/platform/nephos/sonic-platform-modules-accton/debian/sonic-platform-accton-as7116-54x.postinst b/platform/nephos/sonic-platform-modules-accton/debian/sonic-platform-accton-as7116-54x.postinst deleted file mode 100644 index a9947af877b..00000000000 --- a/platform/nephos/sonic-platform-modules-accton/debian/sonic-platform-accton-as7116-54x.postinst +++ /dev/null @@ -1,5 +0,0 @@ -depmod -a -systemctl enable as7116-platform-init.service -systemctl start as7116-platform-init.service - -/usr/local/bin/platform_api_mgnt.sh install diff --git a/platform/nephos/sonic-platform-modules-cig/LICENSE b/platform/nephos/sonic-platform-modules-cig/LICENSE deleted file mode 100755 index baf27e16741..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/LICENSE +++ /dev/null @@ -1,16 +0,0 @@ -Copyright (C) 2016 Microsoft, Inc -Copyright (C) 2017 Cambridgeig Technology Corporation - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/platform/nephos/sonic-platform-modules-cig/README.md b/platform/nephos/sonic-platform-modules-cig/README.md deleted file mode 100755 index 9dc23910b59..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/README.md +++ /dev/null @@ -1 +0,0 @@ -platform drivers of Cambridgeig products for the SONiC project diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/classes/__init__.py b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/classes/__init__.py deleted file mode 100755 index e69de29bb2d..00000000000 diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/classes/fanutil.py b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/classes/fanutil.py deleted file mode 100755 index e69de29bb2d..00000000000 diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/classes/thermalutil.py b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/classes/thermalutil.py deleted file mode 100755 index e69de29bb2d..00000000000 diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/Makefile b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/Makefile deleted file mode 100644 index 446fde4b0a7..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -obj-m :=x86-64-cig-cs5435-54p-sysfs.o \ - x86-64-cig-cs5435-54p-cpld.o \ - x86-64-cig-cs5435-54p-fan.o \ - x86-64-cig-cs5435-54p-led.o \ - x86-64-cig-cs5435-54p-psu.o \ - x86-64-cig-cs5435-54p-sfp.o diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/i2c-algo-lpc.h b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/i2c-algo-lpc.h deleted file mode 100644 index dc9e30d16dd..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/i2c-algo-lpc.h +++ /dev/null @@ -1,222 +0,0 @@ -/* -------------------------------------------------------------------- - - * A hwmon driver for the CIG cs5435-54P - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* -------------------------------------------------------------------- */ - -#ifndef I2C_LPC_H -#define I2C_LPC_H 1 - -/* ----- Control register bits ---------------------------------------- */ -#define I2C_LPC_PIN 0x80 -#define I2C_LPC_ESO 0x40 -#define I2C_LPC_ES1 0x20 -#define I2C_LPC_ES2 0x10 -#define I2C_LPC_ENI 0x08 - -#define I2C_LPC_STO 0x40 -#define I2C_LPC_ACK 0x01 - -/*command register*/ -#define I2C_LPC_STA 0x80 -#define I2C_LPC_ABT 0x40 - -/*status register*/ -#define I2C_LPC_TBE 0x02 -#define I2C_LPC_IBB 0x80 -#define I2C_LPC_RBF 0x01 -#define I2C_LPC_TD 0x08 - -#define I2C_LPC_START I2C_LPC_STA -#define I2C_LPC_STOP I2C_LPC_STO -#define I2C_LPC_REPSTART I2C_LPC_STA -#define I2C_LPC_IDLE - -/* ----- Status register bits ----------------------------------------- */ -/*#define I2C_LPC_PIN 0x80 as above*/ - -#define I2C_LPC_INI 0x40 /* 1 if not initialized */ -#define I2C_LPC_STS 0x20 -#define I2C_LPC_BER 0x10 -#define I2C_LPC_AD0 0x08 -#define I2C_LPC_LRB 0x08 -#define I2C_LPC_AAS 0x04 -#define I2C_LPC_LAB 0x02 -#define I2C_LPC_BB 0x80 - -/* ----- Chip clock frequencies --------------------------------------- */ -#define I2C_LPC_CLK3 0x00 -#define I2C_LPC_CLK443 0x10 -#define I2C_LPC_CLK6 0x14 -#define I2C_LPC_CLK 0x18 -#define I2C_LPC_CLK12 0x1c - -/* ----- transmission frequencies ------------------------------------- */ -#define I2C_LPC_TRNS90 0x00 /* 90 kHz */ -#define I2C_LPC_TRNS45 0x01 /* 45 kHz */ -#define I2C_LPC_TRNS11 0x02 /* 11 kHz */ -#define I2C_LPC_TRNS15 0x03 /* 1.5 kHz */ - - -#define I2C_LPC_OWNADR 0 -#define I2C_LPC_INTREG I2C_LPC_ES2 -#define I2C_LPC_CLKREG I2C_LPC_ES1 - -#define I2C_LPC_REG_TEST 0x01 -#define I2C_LPC_REG_BUS_SEL 0x80 -#define I2C_LPC_REG_DEVICE_ADDR 0x81 -#define I2C_LPC_REG_BYTE_COUNT 0x83 -#define I2C_LPC_REG_COMMAND 0x84 -#define I2C_LPC_REG_STATUS 0x85 -#define I2C_LPC_REG_DATA_RX1 0x86 -#define I2C_LPC_REG_DATA_RX2 0x87 -#define I2C_LPC_REG_DATA_RX3 0x88 -#define I2C_LPC_REG_DATA_RX4 0x89 -#define I2C_LPC_REG_DATA_TX1 0x8a -#define I2C_LPC_REG_DATA_TX2 0x8b -#define I2C_LPC_REG_DATA_TX3 0x8c -#define I2C_LPC_REG_DATA_TX4 0x8d - - -#define ADDR_REG_SFP_STATUS_ADDR 0X62 //reg addr +R/W# //1031 -#define ADDR_REG_SFP_STATUS_TX 0X63 // write data -#define ADDR_REG_SFP_STATUS_RX 0X64 //read data -#define ADDR_REG_SFP_STATUS_COMMAND 0X65 //cmd bit7=1,go -#define ADDR_REG_SFP_STATUS_STATUS 0X66 //status - -#define CPLD_MASTER_INTERRUPT_STATUS_REG 0x20 -#define CPLD_MASTER_INTERRUPT_MASK_REG 0x21 -#define CPLD_MASTER_INTERRUPT_ALL 0x3f -#define CPLD_MASTER_INTERRUPT_CPLD2 0x20 -#define CPLD_MASTER_INTERRUPT_CPLD1 0x10 -#define CPLD_MASTER_INTERRUPT_PSU2 0x08 -#define CPLD_MASTER_INTERRUPT_PSU1 0x04 -#define CPLD_MASTER_INTERRUPT_6320 0x02 -#define CPLD_MASTER_INTERRUPT_LSW 0x01 - - - -#define CPLD_SLAVE1_INTERRUPT_STATUS_L_REG 0x20 -#define CPLD_SLAVE1_INTERRUPT_STATUS_H_REG 0x21 -#define CPLD_SLAVE2_INTERRUPT_STATUS_L_REG 0x22 -#define CPLD_SLAVE2_INTERRUPT_STATUS_H_REG 0x23 -#define CPLD_SLAVE1_INTERRUPT_MASK_REG 0x24 -#define CPLD_SLAVE2_INTERRUPT_MASK_REG 0x25 - - -#define CPLD_SLAVE1_PRESENT08_REG 0x01 -#define CPLD_SLAVE1_PRESENT16_REG 0x02 -#define CPLD_SLAVE1_PRESENT24_REG 0x03 -#define CPLD_SLAVE2_PRESENT32_REG 0x04 -#define CPLD_SLAVE2_PRESENT40_REG 0x05 -#define CPLD_SLAVE2_PRESENT48_REG 0x06 - -#define CPLD_SLAVE1_RX_LOST08_REG 0x07 -#define CPLD_SLAVE1_RX_LOST16_REG 0x08 -#define CPLD_SLAVE1_RX_LOST24_REG 0x09 -#define CPLD_SLAVE2_RX_LOST32_REG 0x0a -#define CPLD_SLAVE2_RX_LOST40_REG 0x0b -#define CPLD_SLAVE2_RX_LOST48_REG 0x0c - -#define CPLD_SLAVE1_TX_FAULT08_REG 0x0d -#define CPLD_SLAVE1_TX_FAULT16_REG 0x0e -#define CPLD_SLAVE1_TX_FAULT24_REG 0x0f -#define CPLD_SLAVE2_TX_FAULT32_REG 0x10 -#define CPLD_SLAVE2_TX_FAULT40_REG 0x11 -#define CPLD_SLAVE2_TX_FAULT48_REG 0x12 - -#define CPLD_SLAVE2_PRESENT56_REG 0x19 -#define CPLD_SLAVE2_QSFP_CR56_REG 0x1a - - -#define CPLD_SLAVE1_INTERRUPT_PRESENT08 0x0001 -#define CPLD_SLAVE1_INTERRUPT_PRESENT16 0x0002 -#define CPLD_SLAVE1_INTERRUPT_PRESENT24 0x0004 -#define CPLD_SLAVE2_INTERRUPT_PRESENT32 0x0001 -#define CPLD_SLAVE2_INTERRUPT_PRESENT40 0x0002 -#define CPLD_SLAVE2_INTERRUPT_PRESENT48 0x0004 - -#define CPLD_SLAVE2_INTERRUPT_QSFP_CR56 0x0200 -#define CPLD_SLAVE2_INTERRUPT_PRESENT56 0x0400 - -#define CPLD_SLAVE1_INTERRUPT_RX_LOST08 0x0008 -#define CPLD_SLAVE1_INTERRUPT_RX_LOST16 0x0010 -#define CPLD_SLAVE1_INTERRUPT_RX_LOST24 0x0020 -#define CPLD_SLAVE2_INTERRUPT_RX_LOST32 0x0008 -#define CPLD_SLAVE2_INTERRUPT_RX_LOST40 0x0010 -#define CPLD_SLAVE2_INTERRUPT_RX_LOST48 0x0020 - -#define CPLD_SLAVE1_INTERRUPT_TX_FAULT08 0x0040 -#define CPLD_SLAVE1_INTERRUPT_TX_FAULT16 0x0080 -#define CPLD_SLAVE1_INTERRUPT_TX_FAULT24 0x0100 -#define CPLD_SLAVE2_INTERRUPT_TX_FAULT32 0x0040 -#define CPLD_SLAVE2_INTERRUPT_TX_FAULT40 0x0080 -#define CPLD_SLAVE2_INTERRUPT_TX_FAULT48 0x0100 - - - - - - - -#define WAIT_TIME_OUT_COUNT 100 - - -struct i2c_algo_lpc_data { - void *data; /* private data for lolevel routines */ - void (*setlpc) (void *data, int ctl, int val); - int (*getlpc) (void *data, int ctl); - int (*getown) (void *data); - int (*getclock) (void *data); - void (*waitforpin) (void *data); - - int (*xfer_begin) (void *data); - int (*xfer_end) (void *data); - - /* Multi-master lost arbitration back-off delay (msecs) - * This should be set by the bus adapter or knowledgable client - * if bus is multi-mastered, else zero - */ - unsigned long lab_mdelay; -}; - - -struct subsys_private { - struct kset subsys; - struct kset *devices_kset; - struct list_head interfaces; - struct mutex mutex; - - struct kset *drivers_kset; - struct klist klist_devices; - struct klist klist_drivers; - struct blocking_notifier_head bus_notifier; - unsigned int drivers_autoprobe:1; - struct bus_type *bus; - - struct kset glue_dirs; - struct class *class; -}; - -void cs5435_54p_sysfs_add_client(struct i2c_client *client); -void cs5435_54p_sysfs_remove_client(struct i2c_client *client); - - -#endif /* I2C_LPC8584_H */ diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-cpld.c b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-cpld.c deleted file mode 100644 index 68f1192e58b..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-cpld.c +++ /dev/null @@ -1,2209 +0,0 @@ -/* - * A hwmon driver for the CIG cs5435-54P CPLD - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "i2c-algo-lpc.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef CPLD_USER -# include -#else -# include -#endif - -#include -#include -#include -#include -#include -#include -#include - - - - - -/********************************************** Start ********************************************************/ - -/* - * ISA bus. - */ - -static void platform_isa_bus_release(struct device * dev) -{ - return ; -} - - -static struct device isa_bus = { - .init_name = "lpc-isa", - .release = platform_isa_bus_release, -}; - -struct isa_dev { - struct device dev; - struct device *next; - unsigned int id; -}; - -#define to_isa_dev(x) container_of((x), struct isa_dev, dev) - -static int isa_bus_match(struct device *dev, struct device_driver *driver) -{ - struct isa_driver *isa_driver = to_isa_driver(driver); - - if (dev->platform_data == isa_driver) { - if (!isa_driver->match || - isa_driver->match(dev, to_isa_dev(dev)->id)) - return 1; - dev->platform_data = NULL; - } - return 0; -} - -static int isa_bus_probe(struct device *dev) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->probe) - return isa_driver->probe(dev, to_isa_dev(dev)->id); - - return 0; -} - -static int isa_bus_remove(struct device *dev) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->remove) - return isa_driver->remove(dev, to_isa_dev(dev)->id); - - return 0; -} - -static void isa_bus_shutdown(struct device *dev) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->shutdown) - isa_driver->shutdown(dev, to_isa_dev(dev)->id); -} - -static int isa_bus_suspend(struct device *dev, pm_message_t state) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->suspend) - return isa_driver->suspend(dev, to_isa_dev(dev)->id, state); - - return 0; -} - -static int isa_bus_resume(struct device *dev) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->resume) - return isa_driver->resume(dev, to_isa_dev(dev)->id); - - return 0; -} - -static struct bus_type isa_bus_type = { - .name = "lpc-isa", - .match = isa_bus_match, - .probe = isa_bus_probe, - .remove = isa_bus_remove, - .shutdown = isa_bus_shutdown, - .suspend = isa_bus_suspend, - .resume = isa_bus_resume -}; - -static void isa_dev_release(struct device *dev) -{ - kfree(to_isa_dev(dev)); -} - -void lpc_unregister_driver(struct isa_driver *isa_driver) -{ - struct device *dev = isa_driver->devices; - - while (dev) { - struct device *tmp = to_isa_dev(dev)->next; - device_unregister(dev); - dev = tmp; - } - driver_unregister(&isa_driver->driver); -} - - -int lpc_register_driver(struct isa_driver *isa_driver, unsigned int ndev) -{ - int error; - unsigned int id; - - isa_driver->driver.bus = &isa_bus_type; - isa_driver->devices = NULL; - - error = driver_register(&isa_driver->driver); - if (error) - return error; - - for (id = 0; id < ndev; id++) { - struct isa_dev *isa_dev; - - isa_dev = kzalloc(sizeof *isa_dev, GFP_KERNEL); - if (!isa_dev) { - error = -ENOMEM; - break; - } - - isa_dev->dev.parent = &isa_bus; - isa_dev->dev.bus = &isa_bus_type; - - dev_set_name(&isa_dev->dev, "%s.%u", - isa_driver->driver.name, id); - isa_dev->dev.platform_data = isa_driver; - isa_dev->dev.release = isa_dev_release; - isa_dev->id = id; - - isa_dev->dev.coherent_dma_mask = DMA_BIT_MASK(24); - isa_dev->dev.dma_mask = &isa_dev->dev.coherent_dma_mask; - - error = device_register(&isa_dev->dev); - if (error) { - put_device(&isa_dev->dev); - break; - } - - if (isa_dev->dev.platform_data) { - isa_dev->next = isa_driver->devices; - isa_driver->devices = &isa_dev->dev; - } else - device_unregister(&isa_dev->dev); - } - - if (!error && !isa_driver->devices) - error = -ENODEV; - - if (error) - isa_unregister_driver(isa_driver); - - return error; -} - - -int lpc_bus_init(void) -{ - int error; - - error = bus_register(&isa_bus_type); - if (!error) { - error = device_register(&isa_bus); - if (error) - bus_unregister(&isa_bus_type); - } - return error; -} - -void lpc_bus_exit(void) -{ - - device_unregister(&isa_bus); - - bus_unregister(&isa_bus_type); -} - - -/********************************************** End ********************************************************/ - - - - - - -/********************************************** Start ********************************************************/ -/* - * module parameters: - */ -static int i2c_debug = 0; -static struct mutex lpc_lock; - - -#define DEB2(x) if (i2c_debug == 2) x -#define DEB3(x) if (i2c_debug == 3) x - /* print several statistical values */ -#define DEBPROTO(x) if (i2c_debug == 9) x; - /* debug the protocol by showing transferred bits */ -#define DEF_TIMEOUT 160 - - - -/* setting states on the bus with the right timing: */ - -#define set_lpc(adap, ctl, val) adap->setlpc(adap->data, ctl, val) -#define get_lpc(adap, ctl) adap->getlpc(adap->data, ctl) -#define get_own(adap) adap->getown(adap->data) -#define get_clock(adap) adap->getclock(adap->data) -#define i2c_outaddr(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DEVICE_ADDR, val) - -#define i2c_outbyte1(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DATA_TX1, val) -#define i2c_outbyte2(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DATA_TX2, val) -#define i2c_outbyte3(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DATA_TX3, val) -#define i2c_outbyte4(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DATA_TX4, val) -#define i2c_inbyte1(adap) adap->getlpc(adap->data, I2C_LPC_REG_DATA_RX1) -#define i2c_inbyte2(adap) adap->getlpc(adap->data, I2C_LPC_REG_DATA_RX2) -#define i2c_inbyte3(adap) adap->getlpc(adap->data, I2C_LPC_REG_DATA_RX3) -#define i2c_inbyte4(adap) adap->getlpc(adap->data, I2C_LPC_REG_DATA_RX4) - - - -#define LPC_FPRINTF_LOG_PATH "/tmp/file.log" -struct file *lpc_fprintf_file = NULL; - -static int lpc_fprintf_debug(const char *fmt, ...) -{ - char lpc_fprintf_buf[256]={0}; - struct va_format vaf; - va_list args; - int r; - mm_segment_t old_fs; - struct timeval tv; - struct rtc_time tm; - - do_gettimeofday(&tv); - - rtc_time_to_tm(tv.tv_sec,&tm); - - va_start(args, fmt); - vaf.fmt = fmt; - vaf.va = &args; - r=snprintf(lpc_fprintf_buf,sizeof(lpc_fprintf_buf),"[%04d.%08d] %pV\n",tm.tm_sec, (int)tv.tv_usec, &vaf); - va_end(args); - old_fs = get_fs(); - set_fs(KERNEL_DS); - vfs_write(lpc_fprintf_file, (char *)&lpc_fprintf_buf, strlen(lpc_fprintf_buf), &lpc_fprintf_file->f_pos); - set_fs(old_fs); - memset(lpc_fprintf_buf,0x0,sizeof(lpc_fprintf_buf)); - return r; - -} - - - -static int lpc_fprintf_init(void) -{ - printk("lpc_fprintf_init.\n"); - - if(lpc_fprintf_file == NULL) - lpc_fprintf_file = filp_open(LPC_FPRINTF_LOG_PATH, O_RDWR | O_APPEND | O_CREAT, 0644); - - if (IS_ERR(lpc_fprintf_file)) { - printk("Error occured while opening file %s, exiting...\n", LPC_FPRINTF_LOG_PATH); - return -1; - } - - return 0; -} - -static int lpc_fprintf_exit(void) -{ - printk("lpc_fprintf_exit.\n"); - - if(lpc_fprintf_file != NULL) - filp_close(lpc_fprintf_file, NULL); - - return 0; -} - - -/* other auxiliary functions */ - - -void print_reg(struct i2c_algo_lpc_data *adap) -{ - unsigned char status; - DEBPROTO(lpc_fprintf_debug("================================================\n");) - status = get_lpc(adap, I2C_LPC_REG_BUS_SEL); - DEBPROTO(lpc_fprintf_debug("%s select reg %x : %x\n",__func__,I2C_LPC_REG_BUS_SEL, status);) - status = get_lpc(adap, I2C_LPC_REG_BYTE_COUNT); - DEBPROTO(lpc_fprintf_debug("%s count reg %x : %x\n",__func__,I2C_LPC_REG_BYTE_COUNT, status);) - - status = get_lpc(adap, I2C_LPC_REG_COMMAND); - DEBPROTO(lpc_fprintf_debug("%s command reg %x : %x\n",__func__,I2C_LPC_REG_COMMAND, status);) - status = get_lpc(adap, I2C_LPC_REG_DEVICE_ADDR); - DEBPROTO(lpc_fprintf_debug("%s address reg %x : %x\n",__func__,I2C_LPC_REG_DEVICE_ADDR, status);) - - status = get_lpc(adap, I2C_LPC_REG_STATUS); - DEBPROTO(lpc_fprintf_debug("%s status reg %x : %x\n",__func__,I2C_LPC_REG_STATUS, status);) -} - - - -static void i2c_repstart(struct i2c_algo_lpc_data *adap) -{ - DEBPROTO(lpc_fprintf_debug("%s :\n",__func__);) - set_lpc(adap, I2C_LPC_REG_COMMAND, I2C_LPC_REPSTART); -} - -static void i2c_stop(struct i2c_algo_lpc_data *adap) -{ - DEBPROTO(lpc_fprintf_debug("%s :\n",__func__);) - set_lpc(adap, I2C_LPC_REG_COMMAND, I2C_LPC_STOP); - udelay(60); - set_lpc(adap, I2C_LPC_REG_COMMAND, 0x00); -} - - - - -static void i2c_start(struct i2c_algo_lpc_data *adap) -{ - print_reg(adap); - - set_lpc(adap, I2C_LPC_REG_COMMAND, I2C_LPC_START); - - print_reg(adap); -} - - - - -static int wait_for_bb(struct i2c_algo_lpc_data *adap) -{ - - int timeout = DEF_TIMEOUT; - int status; - - while (--timeout) { - status = get_lpc(adap, I2C_LPC_REG_STATUS); - - DEBPROTO(lpc_fprintf_debug("%s : Waiting for bus free status : %x\n",__func__,status);) - - if(status == I2C_LPC_TD) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is free status : %x\n",__func__,status);) - break; - } - } - - if (timeout == 0) { - DEBPROTO(lpc_fprintf_debug("%s : Timeout for free busy status : %x\n",__func__,status);) - return -ETIMEDOUT; - } - - - - return 0; -} - - -static int wait_for_be(int mode,struct i2c_algo_lpc_data *adap) -{ - - int timeout = DEF_TIMEOUT; - unsigned char status; - - - while (--timeout) { - - status = get_lpc(adap, I2C_LPC_REG_STATUS); - - DEBPROTO(lpc_fprintf_debug("%s : Waiting for bus empty status : %x\n",__func__,status);) - - if(mode == 1) - { - if((status & I2C_LPC_IBB) && (status & I2C_LPC_TBE)) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is empty status : %x\n",__func__,status);) - break; - } - } - else - { - if(status & I2C_LPC_TD) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is empty status : %x\n",__func__,status);) - break; - } - } - - status = get_lpc(adap, I2C_LPC_REG_TEST); - - DEBPROTO(lpc_fprintf_debug("%s : The test register data : %x\n",__func__,status);) - udelay(1); /* wait for 100 us */ - } - - if (timeout == 0) { - DEBPROTO(lpc_fprintf_debug("%s : Timeout waiting for Bus Empty\n",__func__);) - return -ETIMEDOUT; - } - - return 0; -} - - -static int wait_for_bf(struct i2c_algo_lpc_data *adap) -{ - - int timeout = DEF_TIMEOUT; - int status; - - - while (--timeout) { - status = get_lpc(adap, I2C_LPC_REG_STATUS); - - DEBPROTO(lpc_fprintf_debug("%s : Waiting for bus full status : %x\n",__func__,status);) - - if(status & I2C_LPC_RBF) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is full status : %x\n",__func__,status);) - break; - } - - status = get_lpc(adap, I2C_LPC_REG_TEST); - - DEBPROTO(lpc_fprintf_debug("%s : The test register data : %x\n",__func__,status);) - udelay(1); /* wait for 100 us */ - } - - if (timeout == 0) { - DEBPROTO(lpc_fprintf_debug("%s : Timeout waiting for Bus Full\n",__func__);) - return -ETIMEDOUT; - } - - return 0; -} - -static int wait_for_td(struct i2c_algo_lpc_data *adap) -{ - - int timeout = DEF_TIMEOUT; - int status=0; - - while (--timeout) { - udelay(4); - status = get_lpc(adap, I2C_LPC_REG_STATUS); - - DEBPROTO(lpc_fprintf_debug("%s : Waiting for bus done status : %x\n",__func__,status);) - - if(status == I2C_LPC_TD) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is done status : %x\n",__func__,status);) - break; - } - } - - if (timeout == 0) { - DEBPROTO(lpc_fprintf_debug("%s : Timeout waiting for Bus Done\n",__func__);) - return -ETIMEDOUT; - } - - return 0; -} - - - -static int wait_for_pin(struct i2c_algo_lpc_data *adap, int *status) -{ - int timeout = DEF_TIMEOUT; - *status = get_lpc(adap, I2C_LPC_REG_STATUS); - - while ((*status & I2C_LPC_TBE) && --timeout) { - *status = get_lpc(adap, I2C_LPC_REG_STATUS); - } - - if (timeout == 0) - return -ETIMEDOUT; - - - return 0; -} - - -static int lpc_doAddress(struct i2c_algo_lpc_data *adap,struct i2c_msg *msg) -{ - unsigned short flags = msg->flags; - unsigned char addr; - - addr = msg->addr << 1; - if (flags & I2C_M_RD) - { - addr |= 1; - DEBPROTO(lpc_fprintf_debug("step 7 : read mode then write device address 0x%x\n",addr);) - } - else - { - DEBPROTO(lpc_fprintf_debug("step 2 : write mode then write device address 0x%x\n",addr);) - } - - if (flags & I2C_M_REV_DIR_ADDR) - { - addr ^= 1; - - } - i2c_outaddr(adap, addr); - return 0; - -} - - -static int lpc_sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) -{ - struct i2c_algo_lpc_data *adap = i2c_adap->algo_data; - int i = 0,timeout=0; - - unsigned int count = msg->len; - unsigned char *buf = msg->buf; - - do{ - lpc_doAddress(adap,msg); - set_lpc(adap, I2C_LPC_REG_BYTE_COUNT, (count-i) >= 4 ? 4:(count - i)); - DEBPROTO(lpc_fprintf_debug("step 3 : write register count %x\n",count);) - - if((count -i) >= 4) - { - i2c_outbyte1(adap, buf[i+0] & 0xff); - i2c_outbyte2(adap, buf[i+1] & 0xff); - i2c_outbyte3(adap, buf[i+2] & 0xff); - i2c_outbyte4(adap, buf[i+3] & 0xff); - - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+1,buf[i+1]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+2,buf[i+2]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+3,buf[i+3]);) - i += 4; - } - else if((count -i) == 3) - { - i2c_outbyte1(adap, buf[i+0] & 0xff); - i2c_outbyte2(adap, buf[i+1] & 0xff); - i2c_outbyte3(adap, buf[i+2] & 0xff); - - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+1,buf[i+1]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+2,buf[i+2]);) - - i += 3; - } - else if((count -i) == 2) - { - i2c_outbyte1(adap, buf[i+0] & 0xff); - i2c_outbyte2(adap, buf[i+1] & 0xff); - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+1,buf[i+1]);) - i += 2; - } - else if((count -i) == 1) - { - i2c_outbyte1(adap, buf[i+0] & 0xff); - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+0,buf[i+0]);) - i += 1; - } - - /* Send START */ - DEBPROTO(lpc_fprintf_debug("step 5-1 : Delay 6mS \n");) - udelay(6000); - DEBPROTO(lpc_fprintf_debug("step 5-2 : Start to transfrom \n");) - i2c_stop(adap); - i2c_start(adap); - DEBPROTO(lpc_fprintf_debug("step 5-3 : Start done\n");) - - udelay(400); - DEBPROTO(lpc_fprintf_debug("step 6 : Waiting for BE\n");) - timeout = wait_for_td(adap); - if (timeout) { - DEBPROTO(lpc_fprintf_debug("step 6 : Timeout waiting for BE \n");) - return -EREMOTEIO; - } - }while (i < count); - - if(i == count) - { - DEBPROTO(lpc_fprintf_debug("Writen %d bytes successd !\n",count);) - return i; - } - else - { - DEBPROTO(lpc_fprintf_debug("Writen %d bytes failed \n",count);) - return -EIO; - } -} - -static int lpc_readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) -{ - int i=0,timeout=0; - struct i2c_algo_lpc_data *adap = i2c_adap->algo_data; - - unsigned int count = msg->len; - unsigned char *buf = msg->buf; - - do{ - lpc_doAddress(adap,msg); - set_lpc(adap, I2C_LPC_REG_BYTE_COUNT, (count-i) >= 4 ? 4:(count - i)); - DEBPROTO(lpc_fprintf_debug("step 8 : write register count %d\n",count);) - - /* Send START */ - DEBPROTO(lpc_fprintf_debug("step 9-1 : Delay 6mS\n");) - udelay(6000); - DEBPROTO(lpc_fprintf_debug("step 9-2 : Start to receive data\n");) - i2c_stop(adap); - i2c_start(adap); - DEBPROTO(lpc_fprintf_debug("step 9-3 : Start done\n");) - - udelay(400); - DEBPROTO(lpc_fprintf_debug("step 10 : Waiting for TD\n");) - timeout = wait_for_td(adap); - if (timeout) { - DEBPROTO(lpc_fprintf_debug("step 10 : Timeout waiting for TD \n");) - return -EREMOTEIO; - } - - if((count -i) >= 4) - { - buf[i+0] = 0xff & i2c_inbyte1(adap); - buf[i+1] = 0xff & i2c_inbyte2(adap); - buf[i+2] = 0xff & i2c_inbyte3(adap); - buf[i+3] = 0xff & i2c_inbyte4(adap); - - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+1,buf[i+1]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+2,buf[i+2]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+3,buf[i+3]);) - - i += 4; - } - else if((count -i) == 3) - { - buf[i+0] = 0xff & i2c_inbyte1(adap); - buf[i+1] = 0xff & i2c_inbyte2(adap); - buf[i+2] = 0xff & i2c_inbyte3(adap); - - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+1,buf[i+1]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+2,buf[i+2]);) - - i += 3; - } - else if((count -i) == 2) - { - buf[i+0] = 0xff & i2c_inbyte1(adap); - buf[i+1] = 0xff & i2c_inbyte2(adap); - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+1,buf[i+1]);) - i += 2; - } - else if((count -i) == 1) - { - buf[i+0] = 0xff & i2c_inbyte1(adap); - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+0,buf[i+0]);) - i += 1; - } - - - }while(i < count); - - if(i == count) - { - DEBPROTO(lpc_fprintf_debug("Read %d bytes successd !\n",count);) - return i; - } - else - { - DEBPROTO(lpc_fprintf_debug("Read %d bytes failed \n",count);) - return -EIO; - } -} - - -struct cpld_client_node { - struct i2c_client *client; - struct list_head list; -}; -#define LPC_I2C_MAX_NCHANS 6 - - -struct lpc_iic { - struct i2c_adapter *virt_adaps[LPC_I2C_MAX_NCHANS]; - u8 last_chan; /* last register value */ -}; - - -static int lpc_master_xfer(struct i2c_adapter *i2c_adap, - struct i2c_msg *msgs, - int num) -{ - struct i2c_algo_lpc_data *adap = i2c_adap->algo_data; - struct i2c_msg *pmsg; - int i; - int ret=0; - - mutex_lock(&lpc_lock); - - if (adap->xfer_begin) - adap->xfer_begin(&i2c_adap->nr); - - - for (i = 0;ret >= 0 && i < num; i++) { - pmsg = &msgs[i]; - - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n", - pmsg->flags & I2C_M_RD ? "read" : "write", - pmsg->len, pmsg->addr, i + 1, num);) - - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n", - i, msgs[i].addr, msgs[i].flags, msgs[i].len);) - - if (pmsg->flags & I2C_M_RD) { - ret = lpc_readbytes(i2c_adap, pmsg); - - if (ret != pmsg->len) { - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: fail: " - "only read %d bytes.\n",ret)); - } else { - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: read %d bytes.\n",ret)); - } - } else { - - ret = lpc_sendbytes(i2c_adap, pmsg); - - if (ret != pmsg->len) { - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: fail: " - "only wrote %d bytes.\n",ret)); - } else { - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: wrote %d bytes.\n",ret)); - } - } - } - - if (adap->xfer_end) - adap->xfer_end(&i2c_adap->nr); - - mutex_unlock(&lpc_lock); - - DEBPROTO(lpc_fprintf_debug("ret = 0x%x num = 0x%x i = 0x%x.\n",ret,num,i)); - - return ret = (ret < 0) ? ret : num; -} - - -static u32 lpc_func(struct i2c_adapter *adap) -{ - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_QUICK; -} - -/* exported algorithm data: */ -static const struct i2c_algorithm lpc_algo = { - .master_xfer = lpc_master_xfer, - //.smbus_xfer = lpc_smbus_xfer, - .functionality = lpc_func, -}; - - -/********************************************** End ********************************************************/ - - - - - - -/********************************************** Start ********************************************************/ -#define DEFAULT_BASE 0x0a00 - -static int lpc_base= 0x0a00; -static u8 __iomem *lpc_base_iomem; - -static int lpc_irq; -static int lpc_clock = 0x1c; -static int lpc_own = 0x55; -static int lpc_mmapped; - -static unsigned long lpc_base_addr = 0x0a00; -static unsigned int lpc_io_space_size = 2; - -static unsigned long LPC_INDEX_REG; -static unsigned long LPC_DATA_REG; - - -/* notice : removed static struct i2c_lpc_iic gpi; code - - this module in real supports only one device, due to missing arguments - in some functions, called from the algo-lpc module. Sometimes it's - need to be rewriten - but for now just remove this for simpler reading */ - -static wait_queue_head_t lpc_wait; -static int lpc_pending; -static spinlock_t lock; -static spinlock_t lpc_slock; - -static struct i2c_adapter lpc_iic_ops; - -struct cpld_dev_type { - struct resource *io_resource; - struct semaphore sem; - struct cdev cdev; -}; - -struct cpld_dev_type *cpld_device; - - -/* ----- local functions ---------------------------------------------- */ - -static void lpc_cpld_setbyte(void *data, int ctl, int val) -{ - outb(ctl, LPC_INDEX_REG); - mb(); - - outb(val, LPC_DATA_REG); - mb(); -} - -static int lpc_cpld_getbyte(void *data, int ctl) -{ - u8 val = 0; - - outb(ctl, LPC_INDEX_REG); - mb(); - - val = inb(LPC_DATA_REG); - mb(); - - return val; -} - -static void lpc_iic_setbyte(void *data, int ctl, int val) -{ - if (!cpld_device) - { - return ; - } - - if (down_interruptible(&cpld_device->sem)) - { - return ; - } - - - lpc_cpld_setbyte(data,ctl,val); - - up(&cpld_device->sem); - DEBPROTO(lpc_fprintf_debug("%s REG[%x] = %x\n",__func__,ctl,val);) -} - - -static int lpc_iic_getbyte(void *data, int ctl) -{ - u8 val = 0; - if (!cpld_device) - return -ENOTTY; - - if (down_interruptible(&cpld_device->sem)) - return -ERESTARTSYS; - - val = lpc_cpld_getbyte(data,ctl); - - up(&cpld_device->sem); - DEBPROTO(lpc_fprintf_debug("%s REG[%x] = %x\n",__func__,ctl,val);) - return val; -} - -int cig_cpld_read_register(u8 reg_off, u8 *val) -{ - if (!cpld_device) - return -ENOTTY; - - if (down_interruptible(&cpld_device->sem)) - return -ERESTARTSYS; - - *val = lpc_cpld_getbyte(cpld_device, reg_off); - - up(&cpld_device->sem); - - return 0; -} -EXPORT_SYMBOL(cig_cpld_read_register); - -int cig_cpld_write_register(u8 reg_off, u8 val) -{ - if (!cpld_device) - return -ENOTTY; - - if (down_interruptible(&cpld_device->sem)) - return -ERESTARTSYS; - - lpc_cpld_setbyte(cpld_device, reg_off, val); - up(&cpld_device->sem); - return 0; -} -EXPORT_SYMBOL(cig_cpld_write_register); - - - -static int lpc_iic_getown(void *data) -{ - return (lpc_own); -} - - -static int lpc_iic_getclock(void *data) -{ - return (lpc_clock); -} - -static void lpc_iic_waitforpin(void *data) -{ - DEFINE_WAIT(wait); - int timeout = 2; - unsigned long flags; - - if (lpc_irq > 0) { - spin_lock_irqsave(&lock, flags); - if (lpc_pending == 0) { - spin_unlock_irqrestore(&lock, flags); - prepare_to_wait(&lpc_wait, &wait, TASK_INTERRUPTIBLE); - if (schedule_timeout(timeout*HZ)) { - spin_lock_irqsave(&lock, flags); - if (lpc_pending == 1) { - lpc_pending = 0; - } - spin_unlock_irqrestore(&lock, flags); - } - finish_wait(&lpc_wait, &wait); - } else { - lpc_pending = 0; - spin_unlock_irqrestore(&lock, flags); - } - } else { - udelay(100); - } -} - - -static irqreturn_t lpc_iic_handler(int this_irq, void *dev_id) { - spin_lock(&lock); - lpc_pending = 1; - spin_unlock(&lock); - wake_up_interruptible(&lpc_wait); - return IRQ_HANDLED; -} - -static int board_id = 0; - - -static int lpc_iic_select(void *data) -{ - unsigned int chan_id=0; - chan_id = *(unsigned int *)data; - chan_id -= 2; - DEBPROTO(lpc_fprintf_debug("step 1 : selest channel id = %d\n",chan_id);) - lpc_iic_setbyte(data,I2C_LPC_REG_BUS_SEL,chan_id); - - return 0; -} - -static int lpc_iic_deselect(void *data) -{ - - unsigned int chan_id=0; - chan_id = *(unsigned int *)data; - chan_id -= 2; - DEBPROTO(lpc_fprintf_debug("step last :deselect channel id = %d\n",chan_id);) - - return 0; -} - - -/* ------------------------------------------------------------------------ - * Encapsulate the above functions in the correct operations structure. - * This is only done when more than one hardware adapter is supported. - */ -static struct i2c_algo_lpc_data lpc_iic_data = { - .setlpc = lpc_iic_setbyte, - .getlpc = lpc_iic_getbyte, - .getown = lpc_iic_getown, - .getclock = lpc_iic_getclock, - .waitforpin = lpc_iic_waitforpin, - .xfer_begin = lpc_iic_select, - .xfer_end = lpc_iic_deselect, -}; - -#include - -static struct i2c_adapter lpc_iic_arr_ops[LPC_I2C_MAX_NCHANS] = {0}; - -static void dummy_setscl(void *data, int state) -{ - return; -} - -static void dummy_setsda(void *data, int state) -{ - return; - -} - -static int dummy_getscl(void *data) -{ - return 1; - -} - -static int dummy_getsda(void *data) -{ - return 1; -} - - -static struct i2c_algo_bit_data dummy_algo_data = { - .setsda = dummy_setsda, - .setscl = dummy_setscl, - .getsda = dummy_getsda, - .getscl = dummy_getscl, - .udelay = 50, - .timeout = HZ, -}; - - -static int dummy_xfer(struct i2c_adapter *i2c_adap, - struct i2c_msg *msgs, - int num) -{ - return 1; -} - -static u32 dummy_func(struct i2c_adapter *adap) -{ - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_QUICK; -} - - -static const struct i2c_algorithm dummy_algo = { - .master_xfer = dummy_xfer, - .functionality = dummy_func, -}; - - - -static struct i2c_adapter i2c_dummy = { - .owner = THIS_MODULE, - .class = I2C_CLASS_HWMON, - .algo_data = &dummy_algo_data, - .algo = &dummy_algo, - .name = "i2c_dummy", -}; - - -static int lpc_iic_match(struct device *dev, unsigned int id) -{ - /* sanity checks for lpc_mmapped I/O */ - - DEB2(printk("lpc_iic_match\n");) - - - if (lpc_base < DEFAULT_BASE) { - dev_err(dev, "incorrect lpc_base address (%#x) specified " - "for lpc_mmapped I/O\n", lpc_base); - return 0; - } - - if (lpc_base == 0) { - lpc_base = DEFAULT_BASE; - } - return 1; -} - -static int lpc_iic_probe(struct device *dev, unsigned int id) -{ - int rval,num; - - lpc_fprintf_init(); - - DEB2(printk("lpc_iic_probe\n");) - - mutex_init(&lpc_lock); - - for(num = 0; num < LPC_I2C_MAX_NCHANS;num++) - { - lpc_iic_arr_ops[num].dev.parent = dev; - lpc_iic_arr_ops[num].owner = THIS_MODULE; - lpc_iic_arr_ops[num].class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - lpc_iic_arr_ops[num].algo = &lpc_algo; - lpc_iic_arr_ops[num].algo_data = &lpc_iic_data, - lpc_iic_arr_ops[num].nr=num; - snprintf(lpc_iic_arr_ops[num].name, sizeof(lpc_iic_arr_ops[num].name), "i2c-%d-lpc", i2c_adapter_id(&lpc_iic_arr_ops[num])); - rval |= i2c_add_adapter(&lpc_iic_arr_ops[num]); - DEB2(printk("%s\n",lpc_iic_arr_ops[num].name);) - } - - return 0; -} - -static int lpc_iic_remove(struct device *dev, unsigned int id) -{ - int num; - DEB2(printk("lpc_iic_remove\n")); - - lpc_fprintf_exit(); - for(num = LPC_I2C_MAX_NCHANS - 1; num >= 0 ;num--) - i2c_del_adapter(&lpc_iic_arr_ops[num]); - - - return 0; -} - -static struct isa_driver i2c_lpc_driver = { - .match = lpc_iic_match, - .probe = lpc_iic_probe, - .remove = lpc_iic_remove, - .driver = { - .owner = THIS_MODULE, - .name = "lpc-iic", - }, -}; - -/********************************************** End ********************************************************/ - - - - - - -/********************************************** Start ********************************************************/ - -static int cpld_major = 0; -static int cpld_minor = 0; - -struct cpld_rw_msg { - unsigned char addr; - unsigned char data; -}; - - -static struct cpld_rw_msg param_read = {-1}; -static struct cpld_rw_msg param_write = {-1}; -static struct cpld_rw_msg param_reads = {-1}; -static struct cpld_rw_msg param_writes = {-1}; - -void cpld_sysfs_kobj_release(struct kobject *kobj) -{ - return; -} - -int cpld_sysfs_add_attr(struct kobject* kobj, char* attr_name) -{ - - struct attribute *attr; - - attr = kmalloc(sizeof(struct attribute), GFP_KERNEL); - attr->name = attr_name; - attr->mode = 0644; - - return sysfs_create_file(kobj, attr); -} - -static int cig_cpld_write_slave_cpld_register(u8 reg_addr, u8 reg_data); -static int cig_cpld_read_slave_cpld_register(u8 reg_addr, u8 *reg_data); - - -static ssize_t cpld_sysfs_show(struct kobject *kobj, struct attribute *attr, char *buffer) -{ - u8 val=0,ret=0,year=0,month=0,day=0,cpld_m=0,cpld_1=0,cpld_2=0; - - if (0 == strcmp(attr->name, "read")) - { - val = lpc_iic_getbyte(NULL,param_read.addr); - ret = sprintf(buffer,"read : addr = 0x%x val = 0x%x\n",param_read.addr, val); - - } - else if (0 == strcmp(attr->name, "write")) - { - lpc_iic_setbyte(NULL, param_write.addr,param_write.data); - ret = sprintf(buffer,"write : addr = 0x%x val = 0x%x\n",param_write.addr, param_write.data); - } - else if (0 == strcmp(attr->name, "version")) - { - cpld_m = lpc_iic_getbyte(NULL, 0x02); - year = lpc_iic_getbyte(NULL, 0x03); - month = lpc_iic_getbyte(NULL, 0x04); - day = lpc_iic_getbyte(NULL, 0x05); - - cig_cpld_read_slave_cpld_register(0x1d,&cpld_1); - cig_cpld_read_slave_cpld_register(0x1e,&cpld_2); - - ret = sprintf(buffer,"Main CPLD version : V%02x\n"\ - "Main CPLD date : 20%02x-%02x-%02x\n"\ - "Slave 1 CPLD version : V%02x\n"\ - "Slave 2 CPLD version : V%02x\n",cpld_m,year,month,day,cpld_1,cpld_2); - } - if (0 == strcmp(attr->name, "reads")) - { - ret = cig_cpld_read_slave_cpld_register(param_reads.addr,&val); - if (ret < 0) - printk("ERROR:Failed to read slave cpld.\n"); - ret = sprintf(buffer,"reads : addr = 0x%x val = 0x%x\n",param_reads.addr, val); - - } - else if (0 == strcmp(attr->name, "writes")) - { - ret = cig_cpld_write_slave_cpld_register(param_writes.addr,param_writes.data); - if (ret < 0) - printk("ERROR:Failed to read slave cpld.\n"); - ret = sprintf(buffer,"writes : addr = 0x%x val = 0x%x\n",param_writes.addr, param_writes.data); - } - - - return ret; - -} - -static ssize_t cpld_sysfs_store(struct kobject *kobj, struct attribute *attr, const char *buffer, size_t count) -{ - int param[3]; - - if (0 == strcmp(attr->name, "read")) - { - sscanf(buffer, "0x%02x", ¶m[0]); - param_read.addr = param[0]; - } - else if (0 == strcmp(attr->name, "write")) - { - sscanf(buffer, "0x%2x 0x%02x", ¶m[0], ¶m[1]); - param_write.addr = param[0]; - param_write.data = param[1]; - } - if (0 == strcmp(attr->name, "reads")) - { - sscanf(buffer, "0x%02x", ¶m[0]); - param_reads.addr = param[0]; - } - else if (0 == strcmp(attr->name, "writes")) - { - sscanf(buffer, "0x%2x 0x%02x", ¶m[0], ¶m[1]); - param_writes.addr = param[0]; - param_writes.data = param[1]; - } - return count; -} - - - -static struct sysfs_ops cpld_sysfs_ops = -{ - .show = cpld_sysfs_show, - .store = cpld_sysfs_store, -}; - -static struct kobj_type cpld_kobj_type = -{ - .release = cpld_sysfs_kobj_release, - .sysfs_ops = &cpld_sysfs_ops, - .default_attrs = NULL, -}; - - -static const char driver_name[] = "cpld_drv"; -static atomic_t cpld_available = ATOMIC_INIT(1); -static struct class *cpld_class; -static struct device *cpld_dev; - - - -#define CPLD_IOC_MAGIC '[' - -#define CPLD_IOC_RDREG _IOR(CPLD_IOC_MAGIC, 0, struct cpld_rw_msg) -#define CPLD_IOC_WRREG _IOW(CPLD_IOC_MAGIC, 1, struct cpld_rw_msg) - -#define CPLD_IOC_MAXNR 2 - - -int cpld_open(struct inode *inode, struct file *filp) -{ - struct cpld_dev_type *dev; - - if (! atomic_dec_and_test(&cpld_available)) { - atomic_inc(&cpld_available); - return -EBUSY; - } - - dev = container_of(inode->i_cdev, struct cpld_dev_type, cdev); - filp->private_data = dev; - - return 0; -} - -int cpld_release(struct inode *inode, struct file *flip) -{ - atomic_inc(&cpld_available); - return 0; -} - - -long cpld_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - int rc = 0; - int err = 0; - struct cpld_dev_type *dev = (struct cpld_dev_type *)filp->private_data; - struct cpld_rw_msg msg; - - if (_IOC_TYPE(cmd) != CPLD_IOC_MAGIC) - return -ENOTTY; - if (_IOC_NR(cmd) > CPLD_IOC_MAXNR) - return -ENOTTY; - - if (_IOC_DIR(cmd) & _IOC_READ) - err = !access_ok(VERIFY_WRITE, (void __user *)arg, _IOC_SIZE(cmd)); - if (_IOC_DIR(cmd) & _IOC_WRITE) - err = !access_ok(VERIFY_READ, (void __user *)arg, _IOC_SIZE(cmd)); - if (err) - return -EFAULT; - - if (down_interruptible(&dev->sem)) - return -ERESTARTSYS; - - switch(cmd){ - case CPLD_IOC_RDREG: - rc = copy_from_user(&msg, (void __user *)arg, sizeof(msg)); - if (!rc) { - msg.data = lpc_cpld_getbyte(dev, msg.addr); - rc = copy_to_user((void __user *)arg, &msg, sizeof(msg)); - } - break; - - case CPLD_IOC_WRREG: - rc = copy_from_user(&msg, (void __user *)arg, sizeof(msg)); - if (!rc) { - lpc_cpld_setbyte(dev, msg.addr, msg.data); - } - break; - default: - rc = -ENOTTY; - break; - } - up(&dev->sem); - - return rc; -} - -struct file_operations cpld_fops = { - .owner = THIS_MODULE, - .open = cpld_open, - .unlocked_ioctl = cpld_ioctl, - .release = cpld_release, -}; - - -static void cpld_setup_cdev(struct cpld_dev_type *dev) -{ - int err, devno = MKDEV(cpld_major, cpld_minor); - - cdev_init(&dev->cdev, &cpld_fops); - dev->cdev.owner = THIS_MODULE; - dev->cdev.ops = &cpld_fops; - err = cdev_add(&dev->cdev, devno, 1); - - if (err) - DEB2(printk(KERN_NOTICE "Error %d adding cpld", err);) -} -/********************************************** End ********************************************************/ - - - - -/********************************************** Start ********************************************************/ -#include -#include -#include - -static spinlock_t irq_inter_lock; -static struct delayed_work irq_inter_work; -static unsigned long irq_inter_delay; - - -static int cig_cpld_write_slave_cpld_register(u8 reg_addr, u8 reg_data) -{ - u8 read_status = 0; - u8 wait_time_out = WAIT_TIME_OUT_COUNT; - DEB2(printk("<=======write=========>")); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_ADDR, reg_addr << 1); - DEB2(printk("[62]=%x\n",reg_addr << 1)); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_TX, reg_data); - DEB2(printk("[63]=%x\n",reg_data)); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_COMMAND, 0x80); - DEB2(printk("[65]=%x\n",0x80)); - do{ - cig_cpld_read_register(ADDR_REG_SFP_STATUS_STATUS, &read_status); - DEB2(printk("[66]=%x\n",read_status)); - udelay(60); - wait_time_out--; - if(wait_time_out == 0) - break; - }while(read_status != 0x02); - DEB2(printk("<=======write=========>")); - - - if(wait_time_out == 0) - return -1; - - return 1; -} - - -static int cig_cpld_read_slave_cpld_register(u8 reg_addr, u8 *reg_data) -{ - u8 read_status = 0; - u8 wait_time_out = WAIT_TIME_OUT_COUNT; - DEB2(printk("<========read=========>")); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_ADDR, reg_addr << 1 | 1); - DEB2(printk("[62]=%x\n",reg_addr << 1 | 1)); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_COMMAND, 0x80); - DEB2(printk("[65]=%x\n",0x80)); - do{ - udelay(60); - cig_cpld_read_register(ADDR_REG_SFP_STATUS_STATUS, &read_status); - DEB2(printk("[66]=%x\n",read_status)); - wait_time_out--; - if(wait_time_out == 0) - break; - }while(read_status != 0x01); - - cig_cpld_read_register(ADDR_REG_SFP_STATUS_RX,reg_data); - DEB2(printk("[64]=%x\n",*reg_data)); - DEB2(printk("<========read=========>")); - - if(wait_time_out == 0) - return -1; - - return 1; -} - - - -struct sock *nlsk = NULL; -extern struct net init_net; -#define NETLINK_TEST 26 -#define MSG_LEN 125 -#define USER_PORT 100 -static u32 irq_present_status_low_current,irq_present_status_low_next; -static u32 irq_present_status_high_current,irq_present_status_high_next; -static u32 irq_tx_fault_status_low_current,irq_tx_fault_status_low_next; -static u32 irq_tx_fault_status_high_current,irq_tx_fault_status_high_next; -static u32 irq_rx_lost_status_low_current,irq_rx_lost_status_low_next; -static u32 irq_rx_lost_status_high_current,irq_rx_lost_status_high_next; - -static u8 irq_present_qsfp_current,irq_present_qsfp_next; -static u8 irq_interrupt_qsfp_current,irq_interrupt_qsfp_next; - -struct input_dev *cpld_input_dev; - - - -int send_usrmsg(char *pbuf, uint16_t len) -{ - struct sk_buff *nl_skb; - struct nlmsghdr *nlh; - - int ret; - - - nl_skb = nlmsg_new(len, GFP_ATOMIC); - if(!nl_skb) - { - printk("netlink alloc failure\n"); - return -1; - } - - - nlh = nlmsg_put(nl_skb, 0, 0, NETLINK_TEST, len, 0); - if(nlh == NULL) - { - printk("nlmsg_put failaure \n"); - nlmsg_free(nl_skb); - return -1; - } - - memcpy(nlmsg_data(nlh), pbuf, len); - ret = netlink_unicast(nlsk, nl_skb, USER_PORT, MSG_DONTWAIT); - - return ret; -} - -static void netlink_rcv_msg(struct sk_buff *skb) -{ - - struct nlmsghdr *nlh = NULL; - char *umsg = NULL; - char kmsg[1024] = {0}; - char kmsg_tmp[16] = {0}; - u8 i = 0; - u8 tmp[3]={0}; - - if(skb->len >= nlmsg_total_size(0)) - { - nlh = nlmsg_hdr(skb); - umsg = NLMSG_DATA(nlh); - if(umsg) - { - for(i = 0;i < 24;i++) - { - if(!(irq_present_status_low_current & (0x1 << i))) - { - tmp[0] = 1; - } - else - { - tmp[0] = 0; - } - - if(!(irq_rx_lost_status_low_current & (0x1 << i))) - { - tmp[1] = 1; - } - else - { - tmp[1] = 0; - } - - if(!(irq_tx_fault_status_low_current & (0x1 << i))) - { - tmp[2] = 1; - } - else - { - tmp[2] = 0; - } - memset(kmsg_tmp,0xff,sizeof(kmsg_tmp)); - sprintf(kmsg_tmp,"sfp%02d:%1d:%1d:%1d ",i+1,tmp[0],tmp[1],tmp[2]); - strcat(kmsg,kmsg_tmp); - } - - for(i = 0;i < 24;i++) - { - if(!(irq_present_status_high_current & (0x1 << i))) - { - tmp[0] = 1; - } - else - { - tmp[0] = 0; - } - - if(!(irq_rx_lost_status_high_current & (0x1 << i))) - { - tmp[1] = 1; - } - else - { - tmp[1] = 0; - } - - if(!(irq_tx_fault_status_high_current & (0x1 << i))) - { - tmp[2] = 1; - } - else - { - tmp[2] = 0; - } - memset(kmsg_tmp,0xff,sizeof(kmsg_tmp)); - sprintf(kmsg_tmp,"sfp%02d:%1d:%1d:%1d ",i+25,tmp[0],tmp[1],tmp[2]); - strcat(kmsg,kmsg_tmp); - } - - - for(i = 0;i < 8;i++) - { - if(!(irq_present_qsfp_current & (0x1 << i))) - { - tmp[0] = 1; - } - else - { - tmp[0] = 0; - } - - if(!(irq_interrupt_qsfp_current & (0x1 << i))) - { - tmp[1] = 1; - } - else - { - tmp[1] = 0; - } - - memset(kmsg_tmp,0xff,sizeof(kmsg_tmp)); - sprintf(kmsg_tmp,"qsfp%02d:%1d:%1d:%1d ",i+49,tmp[0],tmp[1],0); - strcat(kmsg,kmsg_tmp); - } - - printk("kernel recv from user: %s\n", umsg); - send_usrmsg(kmsg, strlen(kmsg)); - } - } - - return ; -} - - - -struct netlink_kernel_cfg cfg = { - .input = netlink_rcv_msg, /* set recv callback */ -}; - - - -#define RANGE_OF_BYTE_SHIFT(to_arg,shift,from_arg) {to_arg &= ~(0xff << shift); to_arg |= from_arg << shift;} - - -static void irq_inter_wapper(struct work_struct * work) -{ - - u8 m_data = 0; - u8 data_high8 = 0,data_low8 = 0; - u16 data_16 = 0; - u8 status = 0; - u8 i = 0; - char kmsg[64]={0}; - u8 tmp[3] = {0}; - - DEB2(printk("CPLD_MASTER_INTERRUPT\r\n")); - - m_data = lpc_iic_getbyte(NULL,CPLD_MASTER_INTERRUPT_STATUS_REG); - lpc_iic_setbyte(NULL,CPLD_MASTER_INTERRUPT_STATUS_REG,0xff); - - cig_cpld_write_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_MASK_REG,0xff); - cig_cpld_write_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_MASK_REG,0xff); - if(!(m_data & CPLD_MASTER_INTERRUPT_CPLD1)) - { - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_STATUS_H_REG,&data_high8); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_STATUS_L_REG,&data_low8); - data_16 = data_low8 | data_high8 << 8; - if( - !(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT08) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT16) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT24) - ) - { - if(!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT08)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT08\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_PRESENT08_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_low_current,0,status); - - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT16)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT16\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_PRESENT16_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_low_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT24)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT24\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_PRESENT24_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_low_current,16,status); - } - DEB2(printk("irq_present_status_low_next = %08x irq_present_status_low_current = %08x \n",irq_present_status_low_next,irq_present_status_low_current)); - } - - if( - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST08) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST16) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST24) - ) - { - if(!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST08)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_RX_LOST08\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_RX_LOST08_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_low_current,0,status); - - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST16)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT16\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_RX_LOST16_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_low_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST24)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT24\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_RX_LOST24_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_low_current,16,status); - } - DEB2(printk("irq_rx_lost_status_low_next = %08x irq_rx_lost_status_low_current = %08x \n",irq_rx_lost_status_low_next,irq_rx_lost_status_low_current)); - } - - if( - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST08) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST16) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST24) - ) - { - if(!(data_16 & CPLD_SLAVE1_INTERRUPT_TX_FAULT08)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_TX_FAULT08\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_TX_FAULT08_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_low_current,0,status); - - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_TX_FAULT16)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_TX_FAULT16\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_TX_FAULT16_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_low_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_TX_FAULT24)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_TX_FAULT24\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_TX_FAULT24_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_low_current,16,status); - } - DEB2(printk("irq_tx_fault_status_low_next = %08x irq_tx_fault_status_low_current = %08x \n",irq_tx_fault_status_low_next,irq_tx_fault_status_low_current)); - - } - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_CPLD2)) - { - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_STATUS_H_REG,&data_high8); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_STATUS_L_REG,&data_low8); - data_16 = data_low8 | data_high8 << 8; - if( - !(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT32) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT40) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT48) - ) - { - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT32)) - { - DEB2(printk("CPLD_SLAVE2_PRESENT32_REG\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT32_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_high_current,0,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT40)) - { - DEB2(printk("CPLD_SLAVE2_PRESENT40_REG\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT40_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_high_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT48)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT48\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT48_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_high_current,16,status); - } - } - - if( - !(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST32) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST40) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST48) - ) - { - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST32)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_RX_LOST32\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_RX_LOST32_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_high_current,0,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST40)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT40\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_RX_LOST40_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_high_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST48)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT48\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_RX_LOST48_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_high_current,16,status); - } - - } - - if( - !(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT32) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT40) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT48) - ) - { - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT32)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_RX_LOST32\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_TX_FAULT32_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_high_current,0,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT40)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT40\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_TX_FAULT40_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_high_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT48)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT48\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_TX_FAULT48_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_high_current,16,status); - } - } - - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT56)) - { - DEB2(printk("CPLD_SLAVE2_PRESENT56_REG\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT56_REG,&status); - irq_present_qsfp_current = status; - } - - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_QSFP_CR56)) - { - DEB2(printk("CPLD_SLAVE2_QSFP_CR56_REG\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_QSFP_CR56_REG,&status); - irq_interrupt_qsfp_current = status; - } - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_LSW)) - { - DEB2(printk("CPLD_MASTER_INTERRUPT_LSW\r\n")); - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_PSU1)) - { - DEB2(printk("CPLD_MASTER_INTERRUPT_PSU1\r\n")); - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_PSU2)) - { - DEB2(printk("CPLD_MASTER_INTERRUPT_PSU2\r\n")); - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_6320)) - { - DEB2(printk("CPLD_MASTER_INTERRUPT_6320\r\n")); - } - cig_cpld_write_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_MASK_REG,0x0); - cig_cpld_write_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_MASK_REG,0x0); - - memset(tmp,0xff,sizeof(tmp)); - - for(i = 0;i < 24;i++) - { - if(!(irq_present_status_low_current & (0x1 << i)) && (irq_present_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d is present\r\n",i+1)); - tmp[0] = 1; - } - else if((irq_present_status_low_current & (0x1 << i)) && !(irq_present_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d is absent\r\n",i+1)); - tmp[0] = 0; - } - - if(!(irq_tx_fault_status_low_current & (0x1 << i)) && (irq_tx_fault_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d transmission is right\r\n",i+1)); - tmp[1] = 1; - } - else if((irq_tx_fault_status_low_current & (0x1 << i)) && !(irq_tx_fault_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d transmission is fault\r\n",i+1)); - tmp[1] = 0; - } - - if(!(irq_rx_lost_status_low_current & (0x1 << i)) && (irq_rx_lost_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d optical is meet\r\n",i+1)); - tmp[2] = 1; - } - else if((irq_rx_lost_status_low_current & (0x1 << i)) && !(irq_rx_lost_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d optical is lost\r\n",i+1)); - tmp[2] = 0; - } - - if((tmp[0] != 0xff) || (tmp[1] != 0xff) || (tmp[2] != 0xff)) - { - memset(kmsg,0xff,sizeof(kmsg)); - snprintf(kmsg,sizeof(kmsg),"sfp%02d:%1d:%1d:%1d ",i+1,(tmp[0] == 0xff) ? 0:tmp[0],(tmp[1] == 0xff) ? 0:tmp[1],(tmp[2] == 0xff) ? 0:tmp[2]); - break; - } - } - - memset(tmp,0xff,sizeof(tmp)); - for(i = 0;i < 24;i++) - { - if(!(irq_present_status_high_current & (0x1 << i)) && (irq_present_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d is present\r\n",i+25)); - tmp[0] = 1; - } - else if((irq_present_status_high_current & (0x1 << i)) && !(irq_present_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d is absent\r\n",i+25)); - tmp[0] = 0; - - } - - if(!(irq_rx_lost_status_high_current & (0x1 << i)) && (irq_rx_lost_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d optical is meet\r\n",i+25)); - tmp[1] = 1; - } - else if((irq_rx_lost_status_high_current & (0x1 << i)) && !(irq_rx_lost_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d optical is lost\r\n",i+25)); - tmp[1] = 0; - } - - if(!(irq_tx_fault_status_high_current & (0x1 << i)) && (irq_tx_fault_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d transmission is right\r\n",i+25)); - tmp[2] = 1; - } - else if((irq_tx_fault_status_high_current & (0x1 << i)) && !(irq_tx_fault_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d transmission is fault\r\n",i+25)); - tmp[2] = 0; - } - - if((tmp[0] != 0xff) || (tmp[1] != 0xff) || (tmp[2] != 0xff)) - { - memset(kmsg,0xff,sizeof(kmsg)); - snprintf(kmsg,sizeof(kmsg),"sfp%02d:%1d:%1d:%1d ",i+25,(tmp[0] == 0xff) ? 0:tmp[0],(tmp[1] == 0xff) ? 0:tmp[1],(tmp[2] == 0xff) ? 0:tmp[2]); - break; - } - } - - memset(tmp,0xff,sizeof(tmp)); - for(i = 0 ; i < 8; i++) - { - if(!(irq_present_qsfp_current & (0x1 << i)) && (irq_present_qsfp_next & (0x1 << i))) - { - DEB2(printk("SFP%d is present\r\n",i+49)); - tmp[0] = 1; - } - else if((irq_present_qsfp_current & (0x1 << i)) && !(irq_present_qsfp_next & (0x1 << i))) - { - DEB2(printk("SFP%d is absent\r\n",i+49)); - tmp[0] = 0; - } - - if(!(irq_interrupt_qsfp_current & (0x1 << i)) && (irq_interrupt_qsfp_next & (0x1 << i))) - { - DEB2(printk("SFP%d interrupt is occured \r\n",i+49)); - tmp[1] = 1; - } - else if((irq_interrupt_qsfp_current & (0x1 << i)) && !(irq_interrupt_qsfp_next & (0x1 << i))) - { - DEB2(printk("SFP%d interrupt is cleaned\r\n",i+49)); - tmp[1] = 0; - } - - if((tmp[0] != 0xff) || (tmp[1] != 0xff)) - { - memset(kmsg,0xff,sizeof(kmsg)); - snprintf(kmsg,sizeof(kmsg),"qsfp%02d:%1d:%1d:%1d ",i+49,(tmp[0] == 0xff) ? 0:tmp[0],(tmp[1] == 0xff) ? 0:tmp[1],0); - break; - } - } - - - irq_present_status_low_next = irq_present_status_low_current; - irq_rx_lost_status_low_next = irq_rx_lost_status_low_current; - irq_tx_fault_status_low_next = irq_tx_fault_status_low_current; - irq_present_status_high_next = irq_present_status_high_current; - irq_rx_lost_status_high_next = irq_rx_lost_status_high_current; - irq_tx_fault_status_high_next = irq_tx_fault_status_high_current; - irq_present_qsfp_next = irq_present_qsfp_current; - irq_interrupt_qsfp_next = irq_interrupt_qsfp_current; - - send_usrmsg(kmsg, strlen(kmsg)); -} - -static void disableIrq(unsigned short maskReg, unsigned short mask) -{ - u8 data = 0; - - data = lpc_iic_getbyte(NULL,maskReg); - data |= mask; - lpc_iic_setbyte(NULL,maskReg, data); -} - -static void enableIrq(unsigned short maskReg, unsigned short mask) -{ - unsigned short data; - - data = lpc_iic_getbyte(NULL,maskReg); - data &= ~mask; - lpc_iic_setbyte(NULL,maskReg, data); -} - - -static irqreturn_t irq_inter_isr(int irq, void *handle) -{ - - /* - * use keventd context to read the event fifo registers - * Schedule readout at least 25ms after notification for - * REVID < 4 - */ - - schedule_delayed_work(&irq_inter_work, irq_inter_delay); - - return IRQ_HANDLED; -} - - -#define CIG_CPLD_CHR_NAME "cpld" - - -static int __init cpld_init(void) -{ - int rval,rc=0; - dev_t dev; - u8 s_data; - int isr_GPIO_num = 289; - - DEB2(printk("cpld_init\n");) - -/**************************************************************************************/ - - LPC_INDEX_REG = lpc_base_addr; - LPC_DATA_REG = lpc_base_addr + 1; - - cpld_device = kzalloc(sizeof(struct cpld_dev_type), GFP_KERNEL); - if (!cpld_device) - goto error3; - cpld_device->io_resource = request_region(lpc_base_addr, - lpc_io_space_size, "lpc-i2c"); - if (!cpld_device->io_resource) { - printk("lpc: claim I/O resource fail\n"); - goto error2; - } - sema_init(&cpld_device->sem, 1); - - if (cpld_major) { - dev = MKDEV(cpld_major, cpld_minor); - rc = register_chrdev_region(dev, 1, CIG_CPLD_CHR_NAME); - } else { - rc = alloc_chrdev_region(&dev, cpld_major, 1, CIG_CPLD_CHR_NAME); - cpld_major = MAJOR(dev); - } - - cpld_setup_cdev(cpld_device); - - cpld_class = class_create(THIS_MODULE,CIG_CPLD_CHR_NAME); - if (!cpld_class) { - DEB2(printk("failed to create class\n");) - goto error1; - } - - cpld_class->p->subsys.kobj.ktype= &cpld_kobj_type; - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "read"); - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "write"); - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "reads"); - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "writes"); - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "version"); - - cpld_dev = device_create(cpld_class, NULL, dev, NULL, CIG_CPLD_CHR_NAME); - -/**************************************************************************************/ - - rval = lpc_bus_init(); - rval = lpc_register_driver(&i2c_lpc_driver, 1); - -/**************************************************************************************/ - return 0; -error1: - cdev_del(&cpld_device->cdev); - unregister_chrdev_region(dev, 1); -error2: - release_resource(cpld_device->io_resource); -error3: - kfree(cpld_device); - - return rc; -} - -static void __exit cpld_exit(void) -{ - DEB2(printk("cpld_exit\n")); - - if (nlsk){ - netlink_kernel_release(nlsk); /* release ..*/ - nlsk = NULL; - } - - - lpc_unregister_driver(&i2c_lpc_driver); - lpc_bus_exit(); - dev_t devno = MKDEV(cpld_major, cpld_minor); - - cdev_del(&cpld_device->cdev); - if (cpld_class) { - device_destroy(cpld_class, devno); - class_destroy(cpld_class); - } - - if (cpld_device) { - if (cpld_device->io_resource) - release_resource(cpld_device->io_resource); - - kfree(cpld_device); - } - unregister_chrdev_region(devno, 1); - - -} - -module_param(cpld_major, int, S_IRUGO); -module_param(cpld_minor, int, S_IRUGO); -module_param(i2c_debug, int, S_IRUGO); -module_param(board_id, int, S_IRUGO); - -module_init(cpld_init); -module_exit(cpld_exit); - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs5435-54p-cpld driver"); -MODULE_LICENSE("GPL"); - - -/********************************************** End ********************************************************/ - - - diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-fan.c b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-fan.c deleted file mode 100644 index a254dae33c2..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-fan.c +++ /dev/null @@ -1,521 +0,0 @@ -/* - * A hwmon driver for the CIG cs5435-54p fan - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -#define FAN_SPEED_DUTY_TO_CPLD_STEP 10 - -static struct cs5435_54p_fan_data *cs5435_54p_fan_update_device(struct device *dev); -static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); -static ssize_t set_fan_direction(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); - - -extern int cig_cpld_write_register(u8 reg_off, u8 val); -extern int cig_cpld_read_register(u8 reg_off, u8 *val); - -/* fan related data, the index should match sysfs_fan_attributes - */ -static const u8 fan_reg[] = { - 0x41, /* fan enable/disable */ - 0x40, /* fan PWM(for all fan) */ - 0x42, /* front fan 1 speed(rpm) */ - 0x44, /* front fan 2 speed(rpm) */ - 0x46, /* front fan 3 speed(rpm) */ - 0x48, /* front fan 4 speed(rpm) */ - 0x4a, /* front fan 5 speed(rpm) */ - 0x43, /* rear fan 1 speed(rpm) */ - 0x45, /* rear fan 2 speed(rpm) */ - 0x47, /* rear fan 3 speed(rpm) */ - 0x49, /* rear fan 4 speed(rpm) */ - 0x4b, /* rear fan 5 speed(rpm) */ - 0x4c, /* fan direction rear to front or front to rear */ -}; - - -/* Each client has this additional data */ -struct cs5435_54p_fan_data { - struct platform_device *pdev; - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* != 0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */ -}; - -static struct cs5435_54p_fan_data *fan_data = NULL; - -enum fan_id { - FAN1_ID, - FAN2_ID, - FAN3_ID, - FAN4_ID, - FAN5_ID, -}; - -enum sysfs_fan_attributes { - FAN_STATE_REG, - FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */ - FAN1_FRONT_SPEED_RPM, - FAN2_FRONT_SPEED_RPM, - FAN3_FRONT_SPEED_RPM, - FAN4_FRONT_SPEED_RPM, - FAN5_FRONT_SPEED_RPM, - FAN1_REAR_SPEED_RPM, - FAN2_REAR_SPEED_RPM, - FAN3_REAR_SPEED_RPM, - FAN4_REAR_SPEED_RPM, - FAN5_REAR_SPEED_RPM, - FAN_DIRECTION, - FAN1_STATE, - FAN2_STATE, - FAN3_STATE, - FAN4_STATE, - FAN5_STATE, - FAN1_FAULT, - FAN2_FAULT, - FAN3_FAULT, - FAN4_FAULT, - FAN5_FAULT, - FAN1_DIRECTION, - FAN2_DIRECTION, - FAN3_DIRECTION, - FAN4_DIRECTION, - FAN5_DIRECTION, -}; - -/* Define attributes - */ -#define DECLARE_FAN_STATE_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_state, S_IRUGO, fan_show_value, NULL, FAN##index##_STATE) -#define DECLARE_FAN_STATE_ATTR(index) &sensor_dev_attr_fan##index##_state.dev_attr.attr - -#define DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_fault, S_IRUGO, fan_show_value, NULL, FAN##index##_FAULT) -#define DECLARE_FAN_FAULT_ATTR(index) &sensor_dev_attr_fan##index##_fault.dev_attr.attr - -#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE) -#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr - -#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_front_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\ - static SENSOR_DEVICE_ATTR(fan##index##_rear_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM) -#define DECLARE_FAN_SPEED_RPM_ATTR(index) &sensor_dev_attr_fan##index##_front_speed_rpm.dev_attr.attr, \ - &sensor_dev_attr_fan##index##_rear_speed_rpm.dev_attr.attr - -#define DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_direction, S_IWUSR | S_IRUGO, fan_show_value, set_fan_direction, FAN##index##_DIRECTION) -#define DECLARE_FAN_DIRECTION_ATTR(index) &sensor_dev_attr_fan##index##_direction.dev_attr.attr - - -/* 5 fan state attributes in this platform */ -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(1); -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(2); -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(3); -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(4); -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(5); - - -/* 5 fan fault attributes in this platform */ -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(4); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(5); - -/* 5 fan speed(rpm) attributes in this platform */ -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(4); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(5); - -/* 1 fan duty cycle attribute in this platform */ -DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(); - -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(1); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(2); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(3); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(4); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5); - - -static struct attribute *cs5435_54p_fan_attributes[] = { - /* fan related attributes */ - DECLARE_FAN_STATE_ATTR(1), - DECLARE_FAN_STATE_ATTR(2), - DECLARE_FAN_STATE_ATTR(3), - DECLARE_FAN_STATE_ATTR(4), - DECLARE_FAN_STATE_ATTR(5), - DECLARE_FAN_FAULT_ATTR(1), - DECLARE_FAN_FAULT_ATTR(2), - DECLARE_FAN_FAULT_ATTR(3), - DECLARE_FAN_FAULT_ATTR(4), - DECLARE_FAN_FAULT_ATTR(5), - DECLARE_FAN_SPEED_RPM_ATTR(1), - DECLARE_FAN_SPEED_RPM_ATTR(2), - DECLARE_FAN_SPEED_RPM_ATTR(3), - DECLARE_FAN_SPEED_RPM_ATTR(4), - DECLARE_FAN_SPEED_RPM_ATTR(5), - DECLARE_FAN_DUTY_CYCLE_ATTR(), - DECLARE_FAN_DIRECTION_ATTR(1), - DECLARE_FAN_DIRECTION_ATTR(2), - DECLARE_FAN_DIRECTION_ATTR(3), - DECLARE_FAN_DIRECTION_ATTR(4), - DECLARE_FAN_DIRECTION_ATTR(5), - NULL -}; - -#define FAN_MAX_DUTY_CYCLE 100 -#define FAN_REG_VAL_TO_SPEED_RPM_STEP 100 - -/* fan utility functions - */ -static u32 reg_val_to_duty_cycle(u8 reg_val) -{ - if (reg_val -== 0xFF) { - return 100; - } - return ((u32)(reg_val) * 100)/ 255; -} - -static u8 duty_cycle_to_reg_val(u8 duty_cycle) -{ - if (duty_cycle >= FAN_MAX_DUTY_CYCLE) { - return 0xFF; - } - - return 255 / 10 * (duty_cycle / 10); -} - -static u32 reg_val_to_speed_rpm(u8 reg_val) -{ - return (u32)reg_val * FAN_REG_VAL_TO_SPEED_RPM_STEP; -} - -static u8 reg_val_to_is_state(u8 reg_val, enum fan_id id) -{ - u8 mask = (1 << id); - - reg_val &= mask; - - return reg_val ? 0 : 1; -} - -static u8 is_fan_fault(struct cs5435_54p_fan_data *data, enum fan_id id) -{ - u8 ret = 1; - int front_fan_index = FAN1_FRONT_SPEED_RPM + id; - int rear_fan_index = FAN1_REAR_SPEED_RPM + id; - - /* Check if the speed of front or rear fan is ZERO, - */ - if (reg_val_to_speed_rpm(data->reg_val[front_fan_index]) && - reg_val_to_speed_rpm(data->reg_val[rear_fan_index])) { - ret = 0; - } - - return ret; -} - - -static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - int error, value; - - error = kstrtoint(buf, 10, &value); - if (error) - return error; - - if (value <= 0 || value > FAN_MAX_DUTY_CYCLE) - return -EINVAL; - - cig_cpld_write_register(fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); - - return count; -} - -static ssize_t set_fan_direction(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - int error, value,fan_index; - u8 mask,reg_val; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - fan_index = attr->index - FAN1_DIRECTION; - error = kstrtoint(buf, 10, &value); - if (error) - return error; - - if (!(value == 0 || value == 1)) - return -EINVAL; - - - cig_cpld_read_register(fan_reg[FAN_DIRECTION],®_val); - - if(value == 1) - { - reg_val |= (1 << fan_index); - } - else - { - reg_val &= ~(1 << fan_index); - } - - cig_cpld_write_register(fan_reg[FAN_DIRECTION], reg_val); - - return count; -} - - - - - -static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - - cs5435_54p_fan_update_device(dev); - - struct cs5435_54p_fan_data *data = fan_data; - - ssize_t ret = 0; - - if (data->valid) { - switch (attr->index) { - - case FAN1_STATE: - case FAN2_STATE: - case FAN3_STATE: - case FAN4_STATE: - case FAN5_STATE: - //printk("FAN_STATE_REG: 0x%x\n", data->reg_val[FAN_STATE_REG]); - //printk("index: %d\n", attr->index); - ret = sprintf(buf, "%d\n", - reg_val_to_is_state(data->reg_val[FAN_STATE_REG], - attr->index - FAN1_STATE)); - break; - case FAN_DUTY_CYCLE_PERCENTAGE: - { - u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]); - ret = sprintf(buf, "%u\n", duty_cycle); - break; - } - case FAN1_FRONT_SPEED_RPM: - case FAN2_FRONT_SPEED_RPM: - case FAN3_FRONT_SPEED_RPM: - case FAN4_FRONT_SPEED_RPM: - case FAN5_FRONT_SPEED_RPM: - case FAN1_REAR_SPEED_RPM: - case FAN2_REAR_SPEED_RPM: - case FAN3_REAR_SPEED_RPM: - case FAN4_REAR_SPEED_RPM: - case FAN5_REAR_SPEED_RPM: -// printk("FAN_seed_REG: 0x%x\n", data->reg_val[attr->index]); -// printk("index: %d\n", attr->index); - ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index])); - break; - - case FAN1_FAULT: - case FAN2_FAULT: - case FAN3_FAULT: - case FAN4_FAULT: - case FAN5_FAULT: - ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT)); - break; - case FAN1_DIRECTION: - case FAN2_DIRECTION: - case FAN3_DIRECTION: - case FAN4_DIRECTION: - case FAN5_DIRECTION: - ret = sprintf(buf, "%d\n",reg_val_to_is_state(data->reg_val[FAN_DIRECTION],attr->index - FAN1_DIRECTION)); - break; - default: - break; - } - } - - return ret; -} - -static const struct attribute_group cs5435_54p_fan_group = { - .attrs = cs5435_54p_fan_attributes, -}; - -static struct cs5435_54p_fan_data *cs5435_54p_fan_update_device(struct device *dev) -{ - struct cs5435_54p_fan_data *data = fan_data; - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || - !data->valid) { - int i; - - data->valid = 0; - - /* Update fan data - */ - for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) { - u8 status; - (void)cig_cpld_read_register(fan_reg[i], &status); - - if (status < 0) { - data->valid = 0; - mutex_unlock(&data->update_lock); - return data; - } - else { - data->reg_val[i] = status; - } - } - - data->last_updated = jiffies; - data->valid = 1; - } - - mutex_unlock(&data->update_lock); - - return data; -} - -static int cs5435_54p_fan_probe(struct platform_device *pdev) -{ - int status = -1; - /* Register sysfs hooks */ - status = sysfs_create_group(&pdev->dev.kobj, &cs5435_54p_fan_group); - if (status) { - goto exit; - - } - - fan_data->hwmon_dev = hwmon_device_register(&pdev->dev); - if (IS_ERR(fan_data->hwmon_dev)) { - status = PTR_ERR(fan_data->hwmon_dev); - goto exit_remove; - } - - dev_info(&pdev->dev, "cs5435_54p_fan\n"); - - return 0; - -exit_remove: - sysfs_remove_group(&pdev->dev.kobj, &cs5435_54p_fan_group); -exit: - return status; -} - -static int cs5435_54p_fan_remove(struct platform_device *pdev) -{ - hwmon_device_unregister(fan_data->hwmon_dev); - sysfs_remove_group(&fan_data->pdev->dev.kobj, &cs5435_54p_fan_group); - - return 0; -} - -#define DRVNAME "cs5435_54p_fan" - -static struct platform_driver cs5435_54p_fan_driver = { - .probe = cs5435_54p_fan_probe, - .remove = cs5435_54p_fan_remove, - .driver = { - .name = DRVNAME, - .owner = THIS_MODULE, - }, -}; - - - - - -static int __init cs5435_54p_fan_init(void) -{ - int ret; - - cig_cpld_write_register(0x40, duty_cycle_to_reg_val(50)); - - ret = platform_driver_register(&cs5435_54p_fan_driver); - if (ret < 0) { - goto exit; - } - - fan_data = kzalloc(sizeof(struct cs5435_54p_fan_data), GFP_KERNEL); - if (!fan_data) { - ret = -ENOMEM; - platform_driver_unregister(&cs5435_54p_fan_driver); - goto exit; - } - - mutex_init(&fan_data->update_lock); - fan_data->valid = 0; - - fan_data->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); - if (IS_ERR(fan_data->pdev)) { - ret = PTR_ERR(fan_data->pdev); - platform_driver_unregister(&cs5435_54p_fan_driver); - kfree(fan_data); - goto exit; - } - -exit: - return ret; -} - -static void __exit cs5435_54p_fan_exit(void) -{ - platform_device_unregister(fan_data->pdev); - platform_driver_unregister(&cs5435_54p_fan_driver); - kfree(fan_data); -} - -MODULE_AUTHOR("CIG"); -MODULE_DESCRIPTION("cs5435_54p_fan driver"); -MODULE_LICENSE("GPL"); - -module_init(cs5435_54p_fan_init); -module_exit(cs5435_54p_fan_exit); - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs5435_54p_fan driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-led.c b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-led.c deleted file mode 100644 index dae49967592..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-led.c +++ /dev/null @@ -1,594 +0,0 @@ -/* - * A hwmon driver for the CIG cs5435-54P LED - * - * Copyright (C) 2018 Cambridge, Inc. - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/*#define DEBUG*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -extern int cig_cpld_write_register(u8 reg_off, u8 val); - -extern int cig_cpld_read_register(u8 reg_off, u8 *val); - -extern void led_classdev_unregister(struct led_classdev *led_cdev); -extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); -extern void led_classdev_resume(struct led_classdev *led_cdev); -extern void led_classdev_suspend(struct led_classdev *led_cdev); - -#define DRVNAME "cs5435_54p_led" - -struct cs5435_54p_led_data { - struct platform_device *pdev; - struct mutex update_lock; - char valid; /* != 0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 reg_val[6]; /* 0: system & location - 1: PSU1 &PSU12 - 2: fan & management - 3: console & ToD - 4-5 : fan1-fan5*/ -}; - -static struct cs5435_54p_led_data *ledctl = NULL; - -/* LED related data - */ -#define LED_TYPE_PSU1_REG_MASK 0x0C -#define LED_MODE_PSU1_GREEN_MASK 0x08 -#define LED_MODE_PSU1_RED_MASK 0x04 -#define LED_MODE_PSU1_AMBER_MASK 0x0C -#define LED_MODE_PSU1_OFF_MASK 0x00 - -#define LED_TYPE_PSU2_REG_MASK 0x30 -#define LED_MODE_PSU2_GREEN_MASK 0x20 -#define LED_MODE_PSU2_RED_MASK 0x10 -#define LED_MODE_PSU2_AMBER_MASK 0x30 -#define LED_MODE_PSU2_OFF_MASK 0x00 - -#define LED_TYPE_SYS_REG_MASK 0xF0 -#define LED_MODE_SYS_GREEN_MASK 0x40 -#define LED_MODE_SYS_RED_MASK 0x20 -#define LED_MODE_SYS_AMBER_MASK 0x60 -#define LED_MODE_SYS_AMBER_FLASHING_MASK 0x70 -#define LED_MODE_SYS_OFF_MASK 0x00 - -#define LED_TYPE_RES_REG_MASK 0x0F -#define LED_MODE_RES_GREEN_MASK 0x04 -#define LED_MODE_RES_RED_MASK 0x02 -#define LED_MODE_RES_AMBER_MASK 0x06 -#define LED_MODE_RES_AMBER_FLASHING_MASK 0x07 -#define LED_MODE_RES_OFF_MASK 0x00 - -#define LED_TYPE_FAN_REG_MASK 0x03 -#define LED_MODE_FAN_GREEN_MASK 0x02 -#define LED_MODE_FAN_RED_MASK 0x01 -#define LED_MODE_FAN_AMBER_MASK 0x03 -#define LED_MODE_FAN_OFF_MASK 0x00 - -#define LED_TYPE_FAN1_REG_MASK 0x03 -#define LED_TYPE_FAN2_REG_MASK 0x0C -#define LED_TYPE_FAN3_REG_MASK 0x30 -#define LED_TYPE_FAN4_REG_MASK 0xC0 -#define LED_TYPE_FAN5_REG_MASK 0x03 - -#define LED_MODE_FANX_GREEN_MASK 0x02 -#define LED_MODE_FANX_RED_MASK 0x01 -#define LED_MODE_FANX_AMBER_MASK 0x03 -#define LED_MODE_FANX_OFF_MASK 0x00 - -enum led_type { - LED_TYPE_SYS, - LED_TYPE_PSU2, - LED_TYPE_PSU1, - LED_TYPE_FAN, - LED_TYPE_FAN1, - LED_TYPE_FAN2, - LED_TYPE_FAN3, - LED_TYPE_FAN4, - LED_TYPE_FAN5, -}; - -static const u8 led_reg[] = { - 0x30, /* system & reserved*/ - 0x31, /* fan & PSU1 & PSU2 */ - 0x32, /* FAN5 LED */ - 0x33, /* FAN1-4 LED */ -}; - - -enum led_light_mode { - LED_MODE_OFF = 0, - LED_MODE_GREEN, - LED_MODE_AMBER, - LED_MODE_RED, - LED_MODE_GREEN_BLINK, - LED_MODE_AMBER_BLINK, - LED_MODE_RED_BLINK, - LED_MODE_GREEN_FLASHING, - LED_MODE_AMBER_FLASHING, - LED_MODE_RED_FLASHING, - LED_MODE_AUTO, - LED_MODE_UNKNOWN -}; - -struct led_type_mode { - enum led_type type; - int type_mask; - enum led_light_mode mode; - int mode_mask; -}; - -static struct led_type_mode led_type_mode_data[] = { -{LED_TYPE_PSU1, LED_TYPE_PSU1_REG_MASK, LED_MODE_GREEN, LED_MODE_PSU1_GREEN_MASK}, -{LED_TYPE_PSU1, LED_TYPE_PSU1_REG_MASK, LED_MODE_AMBER, LED_MODE_PSU1_AMBER_MASK}, -{LED_TYPE_PSU1, LED_TYPE_PSU1_REG_MASK, LED_MODE_RED, LED_MODE_PSU1_RED_MASK}, -{LED_TYPE_PSU1, LED_TYPE_PSU1_REG_MASK, LED_MODE_OFF, LED_MODE_PSU1_OFF_MASK}, - -{LED_TYPE_PSU2, LED_TYPE_PSU2_REG_MASK, LED_MODE_GREEN, LED_MODE_PSU2_GREEN_MASK}, -{LED_TYPE_PSU2, LED_TYPE_PSU2_REG_MASK, LED_MODE_AMBER, LED_MODE_PSU2_AMBER_MASK}, -{LED_TYPE_PSU2, LED_TYPE_PSU2_REG_MASK, LED_MODE_RED, LED_MODE_PSU2_RED_MASK}, -{LED_TYPE_PSU2, LED_TYPE_PSU2_REG_MASK, LED_MODE_OFF, LED_MODE_PSU2_OFF_MASK}, - -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_GREEN, LED_MODE_SYS_GREEN_MASK}, -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_AMBER, LED_MODE_SYS_AMBER_MASK}, -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_RED, LED_MODE_SYS_RED_MASK}, -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_AMBER_FLASHING, LED_MODE_SYS_AMBER_FLASHING_MASK}, -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_OFF, LED_MODE_SYS_OFF_MASK}, - -{LED_TYPE_FAN, LED_TYPE_FAN_REG_MASK, LED_MODE_GREEN, LED_MODE_FAN_GREEN_MASK}, -{LED_TYPE_FAN, LED_TYPE_FAN_REG_MASK, LED_MODE_AMBER, LED_MODE_FAN_AMBER_MASK}, -{LED_TYPE_FAN, LED_TYPE_FAN_REG_MASK, LED_MODE_RED, LED_MODE_FAN_RED_MASK}, -{LED_TYPE_FAN, LED_TYPE_FAN_REG_MASK, LED_MODE_OFF, LED_MODE_FAN_OFF_MASK}, - -{LED_TYPE_FAN1, LED_TYPE_FAN1_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 0}, -{LED_TYPE_FAN1, LED_TYPE_FAN1_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 0}, -{LED_TYPE_FAN1, LED_TYPE_FAN1_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 0}, -{LED_TYPE_FAN1, LED_TYPE_FAN1_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 0}, -{LED_TYPE_FAN2, LED_TYPE_FAN2_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 2}, -{LED_TYPE_FAN2, LED_TYPE_FAN2_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 2}, -{LED_TYPE_FAN2, LED_TYPE_FAN2_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 2}, -{LED_TYPE_FAN2, LED_TYPE_FAN2_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 2}, -{LED_TYPE_FAN3, LED_TYPE_FAN3_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 4}, -{LED_TYPE_FAN3, LED_TYPE_FAN3_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 4}, -{LED_TYPE_FAN3, LED_TYPE_FAN3_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 4}, -{LED_TYPE_FAN3, LED_TYPE_FAN3_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 4}, -{LED_TYPE_FAN4, LED_TYPE_FAN4_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 6}, -{LED_TYPE_FAN4, LED_TYPE_FAN4_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 6}, -{LED_TYPE_FAN4, LED_TYPE_FAN4_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 6}, -{LED_TYPE_FAN4, LED_TYPE_FAN4_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 6}, -{LED_TYPE_FAN5, LED_TYPE_FAN5_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 0}, -{LED_TYPE_FAN5, LED_TYPE_FAN5_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 0}, -{LED_TYPE_FAN5, LED_TYPE_FAN5_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 0}, -{LED_TYPE_FAN5, LED_TYPE_FAN5_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 0}, -}; - -struct fanx_info_s { - u8 cname; /* device name */ - enum led_type type; - u8 reg_id; /* map to led_reg & reg_val */ -}; - -static struct fanx_info_s fanx_info[] = { - {'1', LED_TYPE_FAN1, 3}, - {'2', LED_TYPE_FAN2, 3}, - {'3', LED_TYPE_FAN3, 3}, - {'4', LED_TYPE_FAN4, 3}, - {'5', LED_TYPE_FAN5, 2}, -}; - - -static int led_reg_val_to_light_mode(enum led_type type, u8 reg_val) { - int i; - - for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { - - if (type != led_type_mode_data[i].type) - continue; - - if ((led_type_mode_data[i].type_mask & reg_val) == - led_type_mode_data[i].mode_mask) - { - return led_type_mode_data[i].mode; - } - } - - return 0; -} - -static u8 led_light_mode_to_reg_val(enum led_type type, - enum led_light_mode mode, u8 reg_val) { - int i; - - for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { - if (type != led_type_mode_data[i].type) - continue; - - if (mode != led_type_mode_data[i].mode) - continue; - - reg_val = led_type_mode_data[i].mode_mask | - (reg_val & (~led_type_mode_data[i].type_mask)); - break; - } - - return reg_val; -} - -static void cs5435_54p_led_update(void) -{ - mutex_lock(&ledctl->update_lock); - - if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2) - || !ledctl->valid) { - int i; - - dev_dbg(&ledctl->pdev->dev, "Starting cs5435_54p_led update\n"); - - /* Update LED data - */ - for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { - u8 status; - cig_cpld_read_register(led_reg[i], &status); - - if (status < 0) { - ledctl->valid = 0; - dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg[i], status); - goto exit; - } - else - { - ledctl->reg_val[i] = status; - } - } - - ledctl->last_updated = jiffies; - ledctl->valid = 1; - } - -exit: - mutex_unlock(&ledctl->update_lock); -} - -static void cs5435_54p_led_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode, - u8 reg, enum led_type type) -{ - u8 reg_val; - mutex_lock(&ledctl->update_lock); - - cig_cpld_read_register(reg, ®_val); - if (reg_val < 0) { - dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val); - goto exit; - } - - reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val); - - cig_cpld_write_register(reg, reg_val); - - /* to prevent the slow-update issue */ - ledctl->valid = 0; - -exit: - mutex_unlock(&ledctl->update_lock); -} - -static void cs5435_54p_led_fanx_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - enum led_type led_type1; - int reg_id; - int i, nsize; - int ncount = sizeof(fanx_info)/sizeof(struct fanx_info_s); - - for(i=0;iname); - - if (led_cdev->name[nsize-1] == fanx_info[i].cname) - { - led_type1 = fanx_info[i].type; - reg_id = fanx_info[i].reg_id; - - cs5435_54p_led_set(led_cdev, led_light_mode, led_reg[reg_id], led_type1); - return; - } - } -} - - -static enum led_brightness cs5435_54p_led_fanx_get(struct led_classdev *cdev) -{ - enum led_type led_type1; - int reg_id; - int i, nsize; - int ncount = sizeof(fanx_info)/sizeof(struct fanx_info_s); - - for(i=0;iname); - - if (cdev->name[nsize-1] == fanx_info[i].cname) - { - led_type1 = fanx_info[i].type; - reg_id = fanx_info[i].reg_id; - cs5435_54p_led_update(); - return led_reg_val_to_light_mode(led_type1, ledctl->reg_val[reg_id]); - } - } - - return led_reg_val_to_light_mode(LED_TYPE_FAN1, ledctl->reg_val[5]); -} - - -static void cs5435_54p_led_psu1_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - cs5435_54p_led_set(led_cdev, led_light_mode, led_reg[1], LED_TYPE_PSU1); -} - -static enum led_brightness cs5435_54p_led_psu1_get(struct led_classdev *cdev) -{ - cs5435_54p_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_PSU1, ledctl->reg_val[1]); -} - -static void cs5435_54p_led_psu2_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - cs5435_54p_led_set(led_cdev, led_light_mode, led_reg[1], LED_TYPE_PSU2); -} - -static enum led_brightness cs5435_54p_led_psu2_get(struct led_classdev *cdev) -{ - cs5435_54p_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_PSU2, ledctl->reg_val[1]); -} - -static void cs5435_54p_led_sys_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - cs5435_54p_led_set(led_cdev, led_light_mode,led_reg[0], LED_TYPE_SYS); -} - -static enum led_brightness cs5435_54p_led_sys_get(struct led_classdev *cdev) -{ - cs5435_54p_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_SYS, ledctl->reg_val[0]); -} - - -static enum led_brightness cs5435_54p_led_fan_get(struct led_classdev *cdev) -{ - cs5435_54p_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_FAN, ledctl->reg_val[1]); -} - -static void cs5435_54p_led_fan_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - cs5435_54p_led_set(led_cdev, led_light_mode, led_reg[1], LED_TYPE_FAN); -} - - -static struct led_classdev cs5435_54p_leds[] = { - [LED_TYPE_SYS] = { - .name = "cs5435_54p_led::sys", - .default_trigger = "unused", - .brightness_set = cs5435_54p_led_sys_set, - .brightness_get = cs5435_54p_led_sys_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN] = { - .name = "cs5435_54p_led::fan", - .default_trigger = "unused", - .brightness_set = cs5435_54p_led_fan_set, - .brightness_get = cs5435_54p_led_fan_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - - [LED_TYPE_PSU1] = { - .name = "cs5435_54p_led::psu1", - .default_trigger = "unused", - .brightness_set = cs5435_54p_led_psu1_set, - .brightness_get = cs5435_54p_led_psu1_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_PSU2] = { - .name = "cs5435_54p_led::psu2", - .default_trigger = "unused", - .brightness_set = cs5435_54p_led_psu2_set, - .brightness_get = cs5435_54p_led_psu2_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - - [LED_TYPE_FAN1] = { - .name = "cs5435_54p_led::fan1", - .default_trigger = "unused", - .brightness_set = cs5435_54p_led_fanx_set, - .brightness_get = cs5435_54p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN2] = { - .name = "cs5435_54p_led::fan2", - .default_trigger = "unused", - .brightness_set = cs5435_54p_led_fanx_set, - .brightness_get = cs5435_54p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN3] = { - .name = "cs5435_54p_led::fan3", - .default_trigger = "unused", - .brightness_set = cs5435_54p_led_fanx_set, - .brightness_get = cs5435_54p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN4] = { - .name = "cs5435_54p_led::fan4", - .default_trigger = "unused", - .brightness_set = cs5435_54p_led_fanx_set, - .brightness_get = cs5435_54p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN5] = { - .name = "cs5435_54p_led::fan5", - .default_trigger = "unused", - .brightness_set = cs5435_54p_led_fanx_set, - .brightness_get = cs5435_54p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - } -}; - -static int cs5435_54p_led_suspend(struct platform_device *dev, - pm_message_t state) -{ - int i = 0; - - for (i = 0; i < ARRAY_SIZE(cs5435_54p_leds); i++) { - led_classdev_suspend(&cs5435_54p_leds[i]); - } - - return 0; -} - -static int cs5435_54p_led_resume(struct platform_device *dev) -{ - int i = 0; - - for (i = 0; i < ARRAY_SIZE(cs5435_54p_leds); i++) { - led_classdev_resume(&cs5435_54p_leds[i]); - } - - return 0; -} - -static int cs5435_54p_led_probe(struct platform_device *pdev) -{ - int ret, i; - - for (i = 0; i < ARRAY_SIZE(cs5435_54p_leds); i++) { - ret = led_classdev_register(&pdev->dev, &cs5435_54p_leds[i]); - - if (ret < 0) - break; - } - - /* Check if all LEDs were successfully registered */ - if (i != ARRAY_SIZE(cs5435_54p_leds)) { - int j; - - /* only unregister the LEDs that were successfully registered */ - for (j = 0; j < i; j++) { - led_classdev_unregister(&cs5435_54p_leds[i]); - } - } - - return ret; -} - -static int cs5435_54p_led_remove(struct platform_device *pdev) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(cs5435_54p_leds); i++) { - led_classdev_unregister(&cs5435_54p_leds[i]); - } - - return 0; -} - -static struct platform_driver cs5435_54p_led_driver = { - .probe = cs5435_54p_led_probe, - .remove = cs5435_54p_led_remove, - .suspend = cs5435_54p_led_suspend, - .resume = cs5435_54p_led_resume, - .driver = { - .name = DRVNAME, - .owner = THIS_MODULE, - }, -}; - -static int cs5435_54p_led_default(void) -{ - cig_cpld_write_register(0x30, 0x40);// system green led solid on -} - -static int __init cs5435_54p_led_init(void) -{ - int ret; - - ret = platform_driver_register(&cs5435_54p_led_driver); - if (ret < 0) { - goto exit; - } - - ledctl = kzalloc(sizeof(struct cs5435_54p_led_data), GFP_KERNEL); - if (!ledctl) { - ret = -ENOMEM; - platform_driver_unregister(&cs5435_54p_led_driver); - goto exit; - } - - mutex_init(&ledctl->update_lock); - - ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); - if (IS_ERR(ledctl->pdev)) { - ret = PTR_ERR(ledctl->pdev); - platform_driver_unregister(&cs5435_54p_led_driver); - kfree(ledctl); - goto exit; - } - - cs5435_54p_led_default(); - -exit: - return ret; -} - -static void __exit cs5435_54p_led_exit(void) -{ - platform_device_unregister(ledctl->pdev); - platform_driver_unregister(&cs5435_54p_led_driver); - kfree(ledctl); -} - -module_init(cs5435_54p_led_init); -module_exit(cs5435_54p_led_exit); - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs5435_54p_led driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-psu.c b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-psu.c deleted file mode 100644 index 5a7942653fc..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-psu.c +++ /dev/null @@ -1,946 +0,0 @@ -/* - * A hwmon driver for the CIG cs5435-54P Power Module - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "i2c-algo-lpc.h" - - - -#define MAX_FAN_DUTY_CYCLE 100 - -/* Address scanned */ -static const unsigned short normal_i2c[] = {I2C_CLIENT_END }; - -/* This is additional data */ -struct cs5435_54p_psu_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; - unsigned long last_updated; /* In jiffies */ - - /* Registers value */ - u8 vout_mode; - u16 v_in; - u16 v_out; - u16 i_in; - u16 i_out; - u16 p_in; - u16 p_out; - u16 temp_input[3]; - u8 temp_fault; - u8 fan_fault; - u16 fan_duty_cycle[2]; - u16 fan_speed[2]; - u8 mfr_id[8]; - u8 mfr_model[20]; - u8 mfr_serial[20]; - u8 psu_is_present; - u8 psu_is_good; - struct i2c_client *client; - struct bin_attribute *bin; /* eeprom data */ -}; - -static int two_complement_to_int(u16 data, u8 valid_bit, int mask); -static ssize_t set_fan_duty_cycle(struct device *dev, struct device_attribute *dev_attr, const char *buf, size_t count); -static ssize_t for_linear_data(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_fan_fault(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_fan_warning(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_temp_fault(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_temp_warning(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_vout_data(struct device *dev, struct device_attribute *dev_attr, char *buf); -static int cs5435_54p_psu_read_byte(struct i2c_client *client, u8 reg); -static int cs5435_54p_psu_read_word(struct i2c_client *client, u8 reg); -static int cs5435_54p_psu_write_word(struct i2c_client *client, u8 reg, u16 value); -static int cs5435_54p_psu_read_block(struct i2c_client *client, u8 command, u8 *data, int data_len); -static struct cs5435_54p_psu_data *cs5435_54p_psu_update_device(struct device *dev); -static ssize_t for_ascii(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_status(struct device *dev, struct device_attribute *dev_attr, char *buf); - -enum cs5435_54p_psu_sysfs_attributes { - PSU_V_IN, - PSU_V_OUT, - PSU_I_IN, - PSU_I_OUT, - PSU_P_IN, - PSU_P_OUT, - PSU_TEMP1_INPUT, - PSU_TEMP2_INPUT, - PSU_TEMP3_INPUT, - PSU_TEMP_FAULT, - PSU_TEMP_WARN, - PSU_FAN1_FAULT, - PSU_FAN1_WARN, - PSU_FAN1_DUTY_CYCLE, - PSU_FAN1_SPEED, - PSU_MFR_ID, - PSU_MFR_MODEL, - PSU_MFR_SERIAL, - PSU_PRESENT, - PSU_P_GOOD, -}; - -static int two_complement_to_int(u16 data, u8 valid_bit, int mask) -{ - u16 valid_data = data & mask; - - bool is_negative = valid_data >> (valid_bit - 1); - return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data; -} - -static ssize_t set_fan_duty_cycle(struct device *dev, struct device_attribute \ - *dev_attr, const char *buf, size_t count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct i2c_client *client = to_i2c_client(dev); - struct cs5435_54p_psu_data *data = i2c_get_clientdata(client); - int nr = (attr->index == PSU_FAN1_DUTY_CYCLE) ? 0 : 1; - long speed; - int error; - - if (data->valid != 1) - { - return -ENODEV; - } - - error = kstrtol(buf, 10, &speed); - if (error) - return error; - - if (speed < 0 || speed > MAX_FAN_DUTY_CYCLE) - return -EINVAL; - - - mutex_lock(&data->update_lock); - data->fan_duty_cycle[nr] = speed; - cs5435_54p_psu_write_word(client, 0x3B + nr, data->fan_duty_cycle[nr]); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t for_linear_data(struct device *dev, struct device_attribute *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs5435_54p_psu_data *data = cs5435_54p_psu_update_device(dev); - - u16 value = 0; - int exponent, mantissa; - int multiplier = 1000; - - if (data->valid != 1) - { - return -ENODEV; - } - - switch (attr->index) { - case PSU_V_IN: - value = data->v_in; - break; - case PSU_I_IN: - value = data->i_in; - break; - case PSU_I_OUT: - value = data->i_out; - break; - case PSU_P_IN: - value = data->p_in; - break; - case PSU_P_OUT: - value = data->p_out; - break; - case PSU_TEMP1_INPUT: - value = data->temp_input[0]; - break; - case PSU_TEMP2_INPUT: - value = data->temp_input[1]; - break; - case PSU_TEMP3_INPUT: - value = data->temp_input[2]; - break; - case PSU_FAN1_DUTY_CYCLE: - multiplier = 1; - value = data->fan_duty_cycle[0]; - break; - case PSU_FAN1_SPEED: - multiplier = 1; - value = data->fan_speed[0]; - break; - default: - break; - } - - exponent = two_complement_to_int(value >> 11, 5, 0x1f); - mantissa = two_complement_to_int(value & 0x7ff, 11, 0x7ff); - - return (exponent >= 0) ? sprintf(buf, "%d\n", \ - (mantissa << exponent) * multiplier) : \ - sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent)); -} - -static ssize_t for_fan_fault(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs5435_54p_psu_data *data = cs5435_54p_psu_update_device(dev); - - if (data->valid != 1) - { - return -ENODEV; - } - - u8 shift = (attr->index == PSU_FAN1_FAULT) ? 7 : 6; - - return sprintf(buf, "%d\n", data->fan_fault >> shift); -} - -static ssize_t for_fan_warning(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs5435_54p_psu_data *data = cs5435_54p_psu_update_device(dev); - - if (data->valid != 1) - { - return -ENODEV; - } - - u8 shift = (attr->index == PSU_FAN1_WARN) ? 5 : 4; - - return sprintf(buf, "%d\n", data->fan_fault >> shift); -} - -static ssize_t for_temp_fault(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs5435_54p_psu_data *data = cs5435_54p_psu_update_device(dev); - - if (data->valid != 1) - { - return -ENODEV; - } - - - - return sprintf(buf, "%d\n", data->temp_fault >> 7); -} - -static ssize_t for_temp_warning(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs5435_54p_psu_data *data = cs5435_54p_psu_update_device(dev); - if (data->valid != 1) - { - return -ENODEV; - } - - - return sprintf(buf, "%d\n", data->temp_fault >> 6); -} -static ssize_t for_vout_data(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct cs5435_54p_psu_data *data = cs5435_54p_psu_update_device(dev); - int exponent, mantissa; - int multiplier = 1000; - if (data->valid != 1) - { - return -ENODEV; - } - - - exponent = two_complement_to_int(data->vout_mode, 5, 0x1f); - mantissa = data->v_out; - - return (exponent > 0) ? sprintf(buf, "%d\n", \ - (mantissa << exponent) * multiplier) : \ - sprintf(buf, "%d\n", ((mantissa * multiplier) >> (-exponent))); -} - -static ssize_t for_ascii(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs5435_54p_psu_data *data = cs5435_54p_psu_update_device(dev); - u8 *ptr = NULL; - - if (data->valid != 1) - { - return -ENODEV; - } - - switch (attr->index) { - case PSU_MFR_ID: - ptr = data->mfr_id + 1; - break; - case PSU_MFR_MODEL: - ptr = data->mfr_model + 1; - break; - case PSU_MFR_SERIAL: - ptr = data->mfr_serial + 1; - break; - default: - return 0; - } - return sprintf(buf, "%s\n", ptr); -} - - -static ssize_t for_status(struct device *dev, struct device_attribute *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs5435_54p_psu_data *data = cs5435_54p_psu_update_device(dev); - u8 *ptr = NULL; - - u8 status = 0; - - if (attr->index == PSU_PRESENT) { - status = data->psu_is_present; - } - else { /* PSU_POWER_GOOD */ - if (!data->valid) { - return -ENODEV; - } - - status = data->psu_is_good; - } - - return sprintf(buf, "%d\n", status); -} - - -static int cs5435_54p_psu_read_byte(struct i2c_client *client, u8 reg) -{ - return i2c_smbus_read_byte_data(client, reg); -} - -static int cs5435_54p_psu_read_word(struct i2c_client *client, u8 reg) -{ - return i2c_smbus_read_word_data(client, reg); -} - -static int cs5435_54p_psu_write_word(struct i2c_client *client, u8 reg, \ - u16 value) -{ - union i2c_smbus_data data; - data.word = value; - return i2c_smbus_xfer(client->adapter, client->addr, - client->flags |= I2C_CLIENT_PEC, - I2C_SMBUS_WRITE, reg, - I2C_SMBUS_WORD_DATA, &data); - -} - -static int cs5435_54p_psu_read_block(struct i2c_client *client, u8 command, \ - u8 *data, int data_len) -{ - int result = i2c_smbus_read_i2c_block_data(client, command, data_len, - data); - if (unlikely(result < 0)) - goto abort; - if (unlikely(result != data_len)) { - result = -EIO; - goto abort; - } - - result = 0; -abort: - return result; - -} - -struct reg_data_byte { - u8 reg; - u8 *value; -}; - -struct reg_data_word { - u8 reg; - u16 *value; -}; - - - -#define EEPROM_NAME "psu_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ - -/* Platform dependent --- */ -static ssize_t psu_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ - int status, retry = 3; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(100); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; - -} - - -static ssize_t psu_page_write(struct i2c_client *client,const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - - - while (count) { - ssize_t status; - - status = psu_eeprom_write(client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - - return retval; -} - - - -static ssize_t psu_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct cs5435_54p_psu_data *data; - ssize_t retval = 0; - struct i2c_client *client; - - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - client = to_i2c_client(container_of(kobj, struct device, kobj)); - - mutex_lock(&data->update_lock); - retval = psu_page_write(client, buf, off, count); - mutex_unlock(&data->update_lock); - return retval; -} - - -static ssize_t psu_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ - int status, retry = 3; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(100); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - -abort: - return status; -} - - - -static ssize_t psu_page_read(struct i2c_client *client,char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - printk("Count = 0, return"); - return count; - } - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - - - while (count) { - ssize_t status; - - status = psu_eeprom_read(client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - - return retval; - -} - - -static ssize_t psu_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct cs5435_54p_psu_data *data; - struct i2c_client *client; - ssize_t retval = 0; - - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - client = to_i2c_client(container_of(kobj, struct device, kobj)); - mutex_lock(&data->update_lock); - retval = psu_page_read(client, buf, off, count); - mutex_unlock(&data->update_lock); - - return retval; -} - - - -static int psu_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = psu_bin_read; - eeprom->write = psu_bin_write; - eeprom->size = EEPROM_SIZE; - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - - -static int psu_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - - -static int psu_i2c_check_functionality(struct i2c_client *client) -{ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_I2C_BLOCK); -} - - - -static int psu_eeprom_probe(struct i2c_client *client, const struct i2c_device_id *dev_id) -{ - int status; - - struct cs5435_54p_psu_data *data; - - if (!psu_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(*data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - i2c_set_clientdata(client, data); - data->valid = 0; - mutex_init(&data->update_lock); - - data->bin = kzalloc(sizeof(struct bin_attribute), GFP_KERNEL); - if (!data->bin) { - status = -ENOMEM; - goto eeprom_bin_error; - } - - /* init eeprom */ - status = psu_sysfs_eeprom_init(&client->dev.kobj, data->bin); - if (status) { - status = -ENOMEM; - goto sys_init_error; - } - - dev_info(&client->dev, "psu eeprom '%s'\n", client->name); - - return 0; - - sys_init_error: - kfree(data->bin); - - eeprom_bin_error: - kfree(data); - - exit: - return status; -} - - - - -static struct cs5435_54p_psu_data *cs5435_54p_psu_update_device(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cs5435_54p_psu_data *data = i2c_get_clientdata(client); - - - mutex_lock(&data->update_lock); - - - if (time_after(jiffies, data->last_updated)) { - int i, status; - u8 command; - struct reg_data_byte regs_byte[] = { - {0x20, &data->vout_mode}, - {0x81, &data->fan_fault}, - {0x7d, &data->temp_fault}, - }; - struct reg_data_word regs_word[] = { - {0x88, &data->v_in}, - {0x8b, &data->v_out}, - {0x89, &data->i_in}, - {0x8c, &data->i_out}, - {0x96, &data->p_out}, - {0x97, &data->p_in}, - {0x8d, &(data->temp_input[0])}, - {0x8e, &(data->temp_input[1])}, - {0x3b, &(data->fan_duty_cycle[0])}, - {0x90, &(data->fan_speed[0])}, - }; - data->valid = 1; - - dev_dbg(&client->dev, "start data update\n"); - - /* one milliseconds from now */ - data->last_updated = jiffies + HZ / 1000; - - for (i = 0; i < ARRAY_SIZE(regs_byte); i++) { - status = cs5435_54p_psu_read_byte(client, - regs_byte[i].reg); - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", - regs_byte[i].reg, status); - *(regs_byte[i].value) = 0; - data->valid = 0; - } else { - *(regs_byte[i].value) = status; - } - } - - for (i = 0; i < ARRAY_SIZE(regs_word); i++) - { - status = cs5435_54p_psu_read_word(client,regs_word[i].reg); - if (status < 0) - { - dev_dbg(&client->dev, "reg %d, err %d\n", - regs_word[i].reg, status); - *(regs_word[i].value) = 0; - data->valid = 0; - } - else - { - *(regs_word[i].value) = status; - } - } - - command = 0x99; /* PSU mfr_id */ - status = cs5435_54p_psu_read_block(client, command, - data->mfr_id, ARRAY_SIZE(data->mfr_id) - 1); - data->mfr_id[ARRAY_SIZE(data->mfr_id) - 1] = '\0'; - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", command, status); - memset(data->mfr_id, 0, sizeof(data->mfr_id)); - data->valid = 0; - } - - command = 0x9a; /* PSU mfr_model */ - status = cs5435_54p_psu_read_block(client, command, - data->mfr_model, ARRAY_SIZE(data->mfr_model) - 1); - data->mfr_model[ARRAY_SIZE(data->mfr_model) - 1] = '\0'; - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", command, status); - memset(data->mfr_model, 0, sizeof(data->mfr_id)); - data->valid = 0; - } - - command = 0x9e; /* PSU mfr_serial */ - status = cs5435_54p_psu_read_block(client, command, - data->mfr_serial, ARRAY_SIZE(data->mfr_serial) - 1); - data->mfr_serial[ARRAY_SIZE(data->mfr_serial) - 1] = '\0'; - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", command, status); - memset(data->mfr_serial, 0, sizeof(data->mfr_id)); - data->valid = 0; - } - - data->psu_is_present = strlen(data->mfr_id) > 1 ? 1:0; - if(data->psu_is_present) - { - data->psu_is_good = ((data->fan_fault) || (data->temp_fault))? 0:1; - } - else - { - data->valid = 0; - data->psu_is_good = 0; - } - } - - mutex_unlock(&data->update_lock); - - return data; - -} - -/* sysfs attributes for hwmon */ -static SENSOR_DEVICE_ATTR(psu_v_in, S_IRUGO, for_linear_data, NULL, PSU_V_IN); -static SENSOR_DEVICE_ATTR(psu_v_out, S_IRUGO, for_vout_data, NULL, PSU_V_OUT); -static SENSOR_DEVICE_ATTR(psu_i_in, S_IRUGO, for_linear_data, NULL, PSU_I_IN); -static SENSOR_DEVICE_ATTR(psu_i_out, S_IRUGO, for_linear_data, NULL, PSU_I_OUT); -static SENSOR_DEVICE_ATTR(psu_p_in, S_IRUGO, for_linear_data, NULL, PSU_P_IN); -static SENSOR_DEVICE_ATTR(psu_p_out, S_IRUGO, for_linear_data, NULL, PSU_P_OUT); -static SENSOR_DEVICE_ATTR(psu_temp1_input, S_IRUGO, for_linear_data, NULL, PSU_TEMP1_INPUT); -static SENSOR_DEVICE_ATTR(psu_temp2_input, S_IRUGO, for_linear_data, NULL, PSU_TEMP2_INPUT); -static SENSOR_DEVICE_ATTR(psu_temp3_input, S_IRUGO, for_linear_data, NULL, PSU_TEMP3_INPUT); -static SENSOR_DEVICE_ATTR(psu_temp_fault, S_IRUGO, for_temp_fault, NULL, PSU_TEMP_FAULT); -static SENSOR_DEVICE_ATTR(psu_temp_warning, S_IRUGO, for_temp_warning, NULL, PSU_TEMP_WARN); -static SENSOR_DEVICE_ATTR(psu_fan1_fault, S_IRUGO, for_fan_fault, NULL, PSU_FAN1_FAULT); -static SENSOR_DEVICE_ATTR(psu_fan1_warning, S_IRUGO, for_fan_warning, NULL, PSU_FAN1_WARN); -static SENSOR_DEVICE_ATTR(psu_fan1_duty_cycle_percentage, S_IWUSR | S_IRUGO, for_linear_data, set_fan_duty_cycle, PSU_FAN1_DUTY_CYCLE); -static SENSOR_DEVICE_ATTR(psu_fan1_speed_rpm, S_IRUGO, for_linear_data, NULL, PSU_FAN1_SPEED); -static SENSOR_DEVICE_ATTR(psu_mfr_id, S_IRUGO, for_ascii, NULL, PSU_MFR_ID); -static SENSOR_DEVICE_ATTR(psu_mfr_model, S_IRUGO, for_ascii, NULL, PSU_MFR_MODEL); -static SENSOR_DEVICE_ATTR(psu_mfr_serial, S_IRUGO, for_ascii, NULL, PSU_MFR_SERIAL); -static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, for_status, NULL, PSU_PRESENT); -static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, for_status, NULL, PSU_P_GOOD); - - - -static struct attribute *cs5435_54p_psu_attributes[] = { - &sensor_dev_attr_psu_v_in.dev_attr.attr, - &sensor_dev_attr_psu_v_out.dev_attr.attr, - &sensor_dev_attr_psu_i_in.dev_attr.attr, - &sensor_dev_attr_psu_i_out.dev_attr.attr, - &sensor_dev_attr_psu_p_in.dev_attr.attr, - &sensor_dev_attr_psu_p_out.dev_attr.attr, - &sensor_dev_attr_psu_temp1_input.dev_attr.attr, - &sensor_dev_attr_psu_temp2_input.dev_attr.attr, - &sensor_dev_attr_psu_temp3_input.dev_attr.attr, - &sensor_dev_attr_psu_temp_fault.dev_attr.attr, - &sensor_dev_attr_psu_temp_warning.dev_attr.attr, - &sensor_dev_attr_psu_fan1_fault.dev_attr.attr, - &sensor_dev_attr_psu_fan1_warning.dev_attr.attr, - &sensor_dev_attr_psu_fan1_duty_cycle_percentage.dev_attr.attr, - &sensor_dev_attr_psu_fan1_speed_rpm.dev_attr.attr, - &sensor_dev_attr_psu_mfr_id.dev_attr.attr, - &sensor_dev_attr_psu_mfr_model.dev_attr.attr, - &sensor_dev_attr_psu_mfr_serial.dev_attr.attr, - &sensor_dev_attr_psu_present.dev_attr.attr, - &sensor_dev_attr_psu_power_good.dev_attr.attr, - NULL -}; - -static const struct attribute_group cs5435_54p_psu_group = { - .attrs = cs5435_54p_psu_attributes, -}; - - -static int psu_register_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int status; - - - struct cs5435_54p_psu_data *data; - - if (!psu_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(*data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - i2c_set_clientdata(client, data); - data->valid = 0; - mutex_init(&data->update_lock); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &cs5435_54p_psu_group); - if (status) - goto exit_sysfs_create_group; - - cs5435_54p_sysfs_add_client(client); - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_hwmon_device_register; - } - - /* init eeprom */ - - return 0; - - exit_hwmon_device_register: - sysfs_remove_group(&client->dev.kobj, &cs5435_54p_psu_group); - exit_sysfs_create_group: - kfree(data); - exit: - return status; - -} - - -static int cs5435_54p_psu_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int status; - - if((client->addr == 0x52) ||(client->addr == 0x53)) - { - status = psu_eeprom_probe(client, id); - } - else if((client->addr == 0x5a) ||(client->addr == 0x5b)) - { - status = psu_register_probe(client, id); - } - return status; -} - -static int cs5435_54p_psu_remove(struct i2c_client *client) -{ - cs5435_54p_sysfs_remove_client(client); - - if((client->addr == 0x52) ||(client->addr == 0x53)) - { - struct cs5435_54p_psu_data *data; - data = i2c_get_clientdata(client); - psu_sysfs_eeprom_cleanup(&client->dev.kobj,data->bin); - kfree(data); - } - else if((client->addr == 0x5a) ||(client->addr == 0x5b)) - { - struct cs5435_54p_psu_data *data; - data = i2c_get_clientdata(client); - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &cs5435_54p_psu_group); - kfree(data); - } - - return 0; -} - -enum psu_index -{ - cs5435_54p_psu1, - cs5435_54p_psu2 -}; - -static const struct i2c_device_id cs5435_54p_psu_id[] = { - { "cs5435_54p_psu1", cs5435_54p_psu1 }, - { "cs5435_54p_psu2", cs5435_54p_psu2 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, cs5435_54p_psu_id); - -static struct i2c_driver cs5435_54p_psu_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "cs5435_54p_psu", - }, - .probe = cs5435_54p_psu_probe, - .remove = cs5435_54p_psu_remove, - .id_table = cs5435_54p_psu_id, - .address_list = normal_i2c, -}; - -module_i2c_driver(cs5435_54p_psu_driver); - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs5435_54p_psu driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-sfp.c b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-sfp.c deleted file mode 100644 index 3bdb3d2de79..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-sfp.c +++ /dev/null @@ -1,1713 +0,0 @@ -/* - * A hwmon driver for the CIG cs5435-54P SFP Module - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "i2c-algo-lpc.h" - -#define DRIVER_NAME "cs5435_54p_sfp" /* Platform dependent */ - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 3 -#define I2C_RW_RETRY_INTERVAL 100 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) -#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 -#define SFF8472_10G_BASE_MASK 0xF0 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 -#define QSFP_RESET_ADDR 0x1b -#define QSFP_INTER_ADDR 0x1a -#define QSFP_LPMODE_ADDR 0x1c - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int cig_cpld_read_register(u8 reg_off, u8 *val); -extern int cig_cpld_write_register(u8 reg_off, u8 val); - -static ssize_t qsfp_reset_read(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_reset_write(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_inter_read(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_lpmode_read(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_lpmode_write(struct device *dev, struct device_attribute *da, const char *buf, size_t count); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL, - QSFPRESET, - QSFPINT, - QSFPLPMODE -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static SENSOR_DEVICE_ATTR(sfp_reset, S_IWUSR | S_IRUGO, qsfp_reset_read, qsfp_reset_write, QSFPRESET); -static SENSOR_DEVICE_ATTR(sfp_inter, S_IRUGO, qsfp_inter_read, NULL, QSFPINT); -static SENSOR_DEVICE_ATTR(sfp_lpmode, S_IWUSR | S_IRUGO, qsfp_lpmode_read, qsfp_lpmode_write, QSFPLPMODE); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - &sensor_dev_attr_sfp_reset.dev_attr.attr, - &sensor_dev_attr_sfp_inter.dev_attr.attr, - &sensor_dev_attr_sfp_lpmode.dev_attr.attr, - NULL -}; - -/* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); -static struct attribute *sfp_msa_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - NULL -}; - -/* SFP ddm attributes for sysfs */ -static struct attribute *sfp_ddm_attributes[] = { - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -cs5435_54p_sfp1, cs5435_54p_sfp2, cs5435_54p_sfp3, cs5435_54p_sfp4, -cs5435_54p_sfp5, cs5435_54p_sfp6, cs5435_54p_sfp7, cs5435_54p_sfp8, -cs5435_54p_sfp9, cs5435_54p_sfp10, cs5435_54p_sfp11, cs5435_54p_sfp12, -cs5435_54p_sfp13, cs5435_54p_sfp14, cs5435_54p_sfp15, cs5435_54p_sfp16, -cs5435_54p_sfp17, cs5435_54p_sfp18, cs5435_54p_sfp19, cs5435_54p_sfp20, -cs5435_54p_sfp21, cs5435_54p_sfp22, cs5435_54p_sfp23, cs5435_54p_sfp24, -cs5435_54p_sfp25, cs5435_54p_sfp26, cs5435_54p_sfp27, cs5435_54p_sfp28, -cs5435_54p_sfp29, cs5435_54p_sfp30, cs5435_54p_sfp31, cs5435_54p_sfp32, -cs5435_54p_sfp33, cs5435_54p_sfp34, cs5435_54p_sfp35, cs5435_54p_sfp36, -cs5435_54p_sfp37, cs5435_54p_sfp38, cs5435_54p_sfp39, cs5435_54p_sfp40, -cs5435_54p_sfp41, cs5435_54p_sfp42, cs5435_54p_sfp43, cs5435_54p_sfp44, -cs5435_54p_sfp45, cs5435_54p_sfp46, cs5435_54p_sfp47, cs5435_54p_sfp48, -cs5435_54p_sfp49, cs5435_54p_sfp50, cs5435_54p_sfp51, cs5435_54p_sfp52, -cs5435_54p_sfp53, cs5435_54p_sfp54, cs5435_54p_sfp55, cs5435_54p_sfp56 -}; - -#define I2C_DEV_ID(x) { #x, x} - -static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(cs5435_54p_sfp1), -I2C_DEV_ID(cs5435_54p_sfp2), -I2C_DEV_ID(cs5435_54p_sfp3), -I2C_DEV_ID(cs5435_54p_sfp4), -I2C_DEV_ID(cs5435_54p_sfp5), -I2C_DEV_ID(cs5435_54p_sfp6), -I2C_DEV_ID(cs5435_54p_sfp7), -I2C_DEV_ID(cs5435_54p_sfp8), -I2C_DEV_ID(cs5435_54p_sfp9), -I2C_DEV_ID(cs5435_54p_sfp10), -I2C_DEV_ID(cs5435_54p_sfp11), -I2C_DEV_ID(cs5435_54p_sfp12), -I2C_DEV_ID(cs5435_54p_sfp13), -I2C_DEV_ID(cs5435_54p_sfp14), -I2C_DEV_ID(cs5435_54p_sfp15), -I2C_DEV_ID(cs5435_54p_sfp16), -I2C_DEV_ID(cs5435_54p_sfp17), -I2C_DEV_ID(cs5435_54p_sfp18), -I2C_DEV_ID(cs5435_54p_sfp19), -I2C_DEV_ID(cs5435_54p_sfp20), -I2C_DEV_ID(cs5435_54p_sfp21), -I2C_DEV_ID(cs5435_54p_sfp22), -I2C_DEV_ID(cs5435_54p_sfp23), -I2C_DEV_ID(cs5435_54p_sfp24), -I2C_DEV_ID(cs5435_54p_sfp25), -I2C_DEV_ID(cs5435_54p_sfp26), -I2C_DEV_ID(cs5435_54p_sfp27), -I2C_DEV_ID(cs5435_54p_sfp28), -I2C_DEV_ID(cs5435_54p_sfp29), -I2C_DEV_ID(cs5435_54p_sfp30), -I2C_DEV_ID(cs5435_54p_sfp31), -I2C_DEV_ID(cs5435_54p_sfp32), -I2C_DEV_ID(cs5435_54p_sfp33), -I2C_DEV_ID(cs5435_54p_sfp34), -I2C_DEV_ID(cs5435_54p_sfp35), -I2C_DEV_ID(cs5435_54p_sfp36), -I2C_DEV_ID(cs5435_54p_sfp37), -I2C_DEV_ID(cs5435_54p_sfp38), -I2C_DEV_ID(cs5435_54p_sfp39), -I2C_DEV_ID(cs5435_54p_sfp40), -I2C_DEV_ID(cs5435_54p_sfp41), -I2C_DEV_ID(cs5435_54p_sfp42), -I2C_DEV_ID(cs5435_54p_sfp43), -I2C_DEV_ID(cs5435_54p_sfp44), -I2C_DEV_ID(cs5435_54p_sfp45), -I2C_DEV_ID(cs5435_54p_sfp46), -I2C_DEV_ID(cs5435_54p_sfp47), -I2C_DEV_ID(cs5435_54p_sfp48), -I2C_DEV_ID(cs5435_54p_sfp49), -I2C_DEV_ID(cs5435_54p_sfp50), -I2C_DEV_ID(cs5435_54p_sfp51), -I2C_DEV_ID(cs5435_54p_sfp52), -I2C_DEV_ID(cs5435_54p_sfp53), -I2C_DEV_ID(cs5435_54p_sfp54), -I2C_DEV_ID(cs5435_54p_sfp55), -I2C_DEV_ID(cs5435_54p_sfp56), -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); - -/* - * list of valid port types - * note OOM_PORT_TYPE_NOT_PRESENT to indicate no - * module is present in this port - */ -typedef enum oom_driver_port_type_e { - OOM_DRIVER_PORT_TYPE_INVALID, - OOM_DRIVER_PORT_TYPE_NOT_PRESENT, - OOM_DRIVER_PORT_TYPE_SFP, - OOM_DRIVER_PORT_TYPE_SFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP, - OOM_DRIVER_PORT_TYPE_QSFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP28 -} oom_driver_port_type_t; - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct sfp_msa_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[6]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss - 3 => device id - 4 => 10G Ethernet Compliance Codes - to distinguish SFP or SFP+ - 5 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -}; - -struct sfp_ddm_data { - struct eeprom_data eeprom; -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - oom_driver_port_type_t port_type; - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct sfp_msa_data *msa; - struct sfp_ddm_data *ddm; - struct qsfp_data *qsfp; - - struct i2c_client *client; -}; - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - - - -static int cig_cpld_write_sfp_register(u8 sfp_reg_addr, u8 sfp_write_reg_data) -{ - u8 sfp_read_status = 0; - u8 wait_time_out = WAIT_TIME_OUT_COUNT; - - cig_cpld_write_register(ADDR_REG_SFP_STATUS_ADDR, sfp_reg_addr << 1); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_TX, sfp_write_reg_data); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_COMMAND, 0x80); - do{ - cig_cpld_read_register(ADDR_REG_SFP_STATUS_STATUS, &sfp_read_status); - udelay(60); - wait_time_out--; - if(wait_time_out == 0) - break; - }while(sfp_read_status != 0x02); - - if(wait_time_out == 0) - return -1; - - return 1; -} - - -static int cig_cpld_read_sfp_register(u8 sfp_reg_addr, u8 *sfp_read_reg_data) -{ - u8 sfp_read_status = 0; - u8 wait_time_out = WAIT_TIME_OUT_COUNT; - - cig_cpld_write_register(ADDR_REG_SFP_STATUS_ADDR, sfp_reg_addr << 1 | 1); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_COMMAND, 0x80); - do{ - udelay(60); - cig_cpld_read_register(ADDR_REG_SFP_STATUS_STATUS, &sfp_read_status); - wait_time_out--; - if(wait_time_out == 0) - break; - }while(sfp_read_status != 0x01); - - cig_cpld_read_register(ADDR_REG_SFP_STATUS_RX,sfp_read_reg_data); - - if(wait_time_out == 0) - return -1; - - return 1; -} - - - - - - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - int i = 0, j = 0, status = -1; - unsigned char cpld_reg_data = 0,cpld_reg_addr = 0; - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - data->present = 0; - - udelay(6000); - - /* Read present status of port 1~48(SFP port) */ - for (i = 0; i < 6; i++) { - cpld_reg_addr = 1 + i; - - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - - data->present |= (u64)cpld_reg_data << (i*8); - - DEBUG_PRINT("Present status = 0x%lx\r\n", data->present); - } - - /* Read present status of port 49-56(QSFP port) */ - cpld_reg_addr = 25; - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - else { - data->present |= (u64)cpld_reg_data << 48; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static struct sfp_port_data *sfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0, j = 0; - int status = -1; - unsigned char cpld_reg_data = 0,cpld_reg_addr = 0; - - if (time_before(jiffies, data->msa->last_updated + HZ + HZ / 2) && data->msa->valid) { - return data; - } - - DEBUG_PRINT("Starting cs5435_54p sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->msa->valid = 0; - memset(data->msa->status, 0, sizeof(data->msa->status)); - - udelay(6000); - - /* Read status of port 1~48(SFP port) */ - for (i = 0; i < 6; i++) { - cpld_reg_addr = 13+i; - - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - - data->msa->status[0] |= (u64)cpld_reg_data << (i * 8); - - DEBUG_PRINT("tx rx status[0] = 0x%lx\r\n", data->msa->status[0]); - } - - - for (i = 0; i < 6; i++) { - cpld_reg_addr = 19+i; - - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - - data->msa->status[1] |= (u64)cpld_reg_data << (i * 8); - - DEBUG_PRINT("tx rx status[1] = 0x%lx\r\n", data->msa->status[1]); - } - - for (i = 0; i < 6; i++) { - cpld_reg_addr = 7+i; - - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - - data->msa->status[2] |= (u64)cpld_reg_data << (i * 8); - - DEBUG_PRINT("tx rx status[2] = 0x%lx\r\n", data->msa->status[2]); - } - - data->msa->valid = 1; - data->msa->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - unsigned char cpld_reg_data = 0,cpld_reg_addr = 0,cpld_reg_bit = 0,cpld_reg_val = 0; - long disable; - int error; - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_set_tx_disable(dev, da, buf, count); - } - - error = kstrtol(buf, 10, &disable); - if (error) { - return error; - } - - mutex_lock(&data->update_lock); - - udelay(6000); - - if(data->port <= 48) { - cpld_reg_addr = 19 + data->port / 8; - cpld_reg_bit = 1 << ((data->port) % 8); - } - - /* Read current status */ - error = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - - /* Update tx_disable status */ - if (disable) { - data->msa->status[1] |= BIT_INDEX(data->port); - cpld_reg_data |= cpld_reg_bit; - } - else { - data->msa->status[1] &= ~ BIT_INDEX(data->port); - cpld_reg_data &= ~cpld_reg_bit; - } - - error = cig_cpld_write_sfp_register(cpld_reg_addr,cpld_reg_data); - - mutex_unlock(&data->update_lock); - return count; -} -/* Platform dependent --- */ - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return !(data->present & BIT_INDEX(data->port)); /* Platform dependent */ -} - -/* Platform dependent +++ */ -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[7] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 56 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5], - values[6]); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d\n", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *sfp_update_port_type(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - u8 buf = 0; - int status; - - mutex_lock(&data->update_lock); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - if (buf != SFF8024_DEVICE_ID_SFP) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - status = sfp_eeprom_read(client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); - data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; - break; - } - case DRIVER_TYPE_QSFP: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); - switch (buf) { - case SFF8024_DEVICE_ID_QSFP: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; - break; - case SFF8024_DEVICE_ID_QSFP_PLUS: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - case SFF8024_DEVICE_ID_QSFP28: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - default: - data->port_type = buf; - break; - } - - break; - } - default: - break; - } - - mutex_unlock(&data->update_lock); - return data; -} - -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - if (!present) { - /* port is not present */ - return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); - } - - sfp_update_port_type(dev); - return sprintf(buf, "%d\n", data->port_type); -} - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - DEBUG_PRINT(""); - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - DEBUG_PRINT(""); - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - DEBUG_PRINT(""); - goto exit; - } - } - msleep(200); - DEBUG_PRINT(""); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - DEBUG_PRINT(""); - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - DEBUG_PRINT(""); - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - DEBUG_PRINT(""); - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_inter_read(struct device *dev, struct device_attribute *da, char *buf) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_INTER_ADDR, &cpld_reg_data); - index = data->port - 48; - index = 1 << index; - val = (cpld_reg_data & index) > 0 ? 1 : 0; - - printk("inter read:data->port = %d, index = %hhu, cpld_reg_data = %hhu\n", data->port, index, cpld_reg_data); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", val); -} - - -static ssize_t qsfp_reset_read(struct device *dev, struct device_attribute *da, char *buf) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_RESET_ADDR, &cpld_reg_data); - index = data->port - 48; - index = 1 << index; - val = (cpld_reg_data & index) > 0 ? 1 : 0; - - printk("reset read:data->port = %d, index = %hhu, cpld_reg_data = %hhu\n", data->port, index, cpld_reg_data); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_reset_write(struct device *dev, struct device_attribute *da, const char *buf, size_t count) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - long usrdata; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - ret = kstrtol(buf, 10, &usrdata); - if (ret) { - return ret; - } - - usrdata = usrdata > 0 ? 1 : 0; - index = data->port - 48; - - DEBUG_PRINT("usrdata = %u, index = %hhu\n", usrdata, index); - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_RESET_ADDR, &cpld_reg_data); - if (ret == 1) - { - - DEBUG_PRINT("cpld_reg_data = %x\n", cpld_reg_data); - cpld_reg_data &= ~(1 << index); - cpld_reg_data |= usrdata << index; - - DEBUG_PRINT("cpld_reg_data = %x\n", cpld_reg_data); - ret = cig_cpld_write_sfp_register(QSFP_RESET_ADDR, cpld_reg_data); - if (1 != ret) - { - DEBUG_PRINT("write failed\n"); - } - } - else - { - DEBUG_PRINT("read failed\n"); - } - - mutex_unlock(&data->update_lock); - - if (ret != 1) - return -1; - - return count; -} - - - - -static ssize_t qsfp_lpmode_read(struct device *dev, struct device_attribute *da, char *buf) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_LPMODE_ADDR, &cpld_reg_data); - index = data->port - 48; - index = 1 << index; - val = (cpld_reg_data & index) > 0 ? 1 : 0; - - printk("lpmode read:data->port = %d, index = %hhu, cpld_reg_data = %hhu\n", data->port, index, cpld_reg_data); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_lpmode_write(struct device *dev, struct device_attribute *da, const char *buf, size_t count) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - long usrdata; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - ret = kstrtol(buf, 10, &usrdata); - if (ret) { - return ret; - } - - usrdata = usrdata > 0 ? 1 : 0; - index = data->port - 48; - - DEBUG_PRINT("usrdata = %u, index = %hhu\n", usrdata, index); - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_LPMODE_ADDR, &cpld_reg_data); - if (ret == 1) - { - - DEBUG_PRINT("cpld_reg_data = %x\n", cpld_reg_data); - cpld_reg_data &= ~(1 << index); - cpld_reg_data |= usrdata << index; - - DEBUG_PRINT("cpld_reg_data = %x\n", cpld_reg_data); - ret = cig_cpld_write_sfp_register(QSFP_LPMODE_ADDR, cpld_reg_data); - if (1 != ret) - { - DEBUG_PRINT("write failed\n"); - } - } - else - { - DEBUG_PRINT("read failed\n"); - } - - mutex_unlock(&data->update_lock); - - if (ret != 1) - return -1; - - return count; -} - - - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT(""); - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - DEBUG_PRINT(""); - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - DEBUG_PRINT(""); - data = qsfp_update_tx_rx_status(dev); - DEBUG_PRINT(""); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - DEBUG_PRINT(""); - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - DEBUG_PRINT(""); - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - data->qsfp->status[1] = disable & 0xF; - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status; - char ddm; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (status == 0) { - /* port is not present */ - return -ENODEV; - } - - status = sfp_eeprom_read(client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); - if (unlikely(status < 0)) { - return status; - } - - return sprintf(buf, "%d\n", !!(ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK)); -} - -/* Platform dependent +++ */ -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0, index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("driver type = (%d)", data->driver_type); - if (data->driver_type == DRIVER_TYPE_QSFP) { - DEBUG_PRINT(""); - return qsfp_show_tx_rx_status(dev, da, buf); - } - - DEBUG_PRINT(""); - data = sfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - if(attr->index == RX_LOS_ALL) { - int i = 0; - u8 values[6] = {0}; - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = (u8)(data->msa->status[2] >> (i * 8)); - } - - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } - - switch (attr->index) { - case TX_FAULT: - index = 0; - break; - case TX_DISABLE: - index = 1; - break; - case RX_LOS: - index = 2; - break; - default: - break; - } - - val = !!(data->msa->status[index] & BIT_INDEX(data->port)); - return sprintf(buf, "%d\n", val); -} -/* Platform dependent --- */ -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} - - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_write(data, buf, off, count); -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_read(data, buf, off, count); -} - -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; - eeprom->size = EEPROM_SIZE; - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; - -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} - -static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_msa_data **data) -{ - int status; - struct sfp_msa_data *msa; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); - if (!msa) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = msa; - dev_info(&client->dev, "sfp msa '%s'\n", client->name); - - cs5435_54p_sysfs_add_client(client); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); -exit_free: - kfree(msa); -exit: - - return status; -} - -static const struct attribute_group sfp_ddm_group = { - .attrs = sfp_ddm_attributes, -}; - -static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_ddm_data **data) -{ - int status; - struct sfp_ddm_data *ddm; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); - if (!ddm) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = ddm; - dev_info(&client->dev, "sfp ddm '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); -exit_free: - kfree(ddm); -exit: - - return status; -} - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); - if (status) { - goto exit_remove; - } - - /* Bring QSFPs out of reset */ - //cig_lpc_write(0x62, 0x15, 0x3F); - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct sfp_port_data *data = NULL; - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - - if (dev_id->driver_data >= cs5435_54p_sfp1 && dev_id->driver_data <= cs5435_54p_sfp48) { - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_MSA; - return sfp_msa_probe(client, dev_id, &data->msa); - } - else if (client->addr == SFP_EEPROM_A2_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_DDM; - return sfp_ddm_probe(client, dev_id, &data->ddm); - } - } - else { /* cs5435_54p_sfp49 ~ cs5435_54p_sfp56 */ - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_QSFP; - return qsfp_probe(client, dev_id, &data->qsfp); - } - } - - return -ENODEV; -} -/* Platform dependent --- */ - -static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); - kfree(data); - return 0; -} - -static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - cs5435_54p_sysfs_remove_client(client); - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_SFP_DDM: - return sfp_ddm_remove(client, data->ddm); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); - } - - return 0; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver cs5435_54p_sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -module_i2c_driver(cs5435_54p_sfp_driver); - - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs5435_54p_sfp driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-sysfs.c b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-sysfs.c deleted file mode 100644 index 0ba8836cf33..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/modules/x86-64-cig-cs5435-54p-sysfs.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * A hwmon driver for the CIG cs5435-54P sysfs Module - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "i2c-algo-lpc.h" - - -static LIST_HEAD(sysfs_client_list); -static struct mutex list_lock; - -struct sysfs_client_node { - struct i2c_client *client; - struct list_head list; -}; - -#define DEVICE_NAME "cigfs" -static int dev_major; -static struct class *dev_class; -static struct cdev *dev_cdev; -static struct device *dev_device; -static struct class *psu_class; -static struct class *sfp_class; - - -void cs5435_54p_sysfs_add_client(struct i2c_client *client) -{ - struct sysfs_client_node *node = kzalloc(sizeof(struct sysfs_client_node), GFP_KERNEL); - - if (!node) { - dev_dbg(&client->dev, "Can't allocate sysfs_client_node (0x%x)\n", client->addr); - return; - } - node->client = client; - - mutex_lock(&list_lock); - list_add(&node->list, &sysfs_client_list); - mutex_unlock(&list_lock); -} - -EXPORT_SYMBOL(cs5435_54p_sysfs_add_client); - -void cs5435_54p_sysfs_remove_client(struct i2c_client *client) -{ - struct list_head *list_node = NULL; - struct sysfs_client_node *sysfs_node = NULL; - int found = 0; - - mutex_lock(&list_lock); - - list_for_each(list_node, &sysfs_client_list) - { - sysfs_node = list_entry(list_node, struct sysfs_client_node, list); - if (IS_ERR(sysfs_node)) - { - break; - } - if (sysfs_node->client == client) { - found = 1; - break; - } - } - if (found) { - list_del(list_node); - kfree(sysfs_node); - } - - mutex_unlock(&list_lock); -} - -EXPORT_SYMBOL(cs5435_54p_sysfs_remove_client); - -struct class * cs5435_54p_sysfs_create_symclass(char *cls_name) -{ - int rc = 0; - struct class *my_class; -/**************************************************************************************/ - my_class = class_create(THIS_MODULE,cls_name); - if (IS_ERR(my_class)) { - pr_err("failed to create my class\n"); - } - return my_class; - -/**************************************************************************************/ -} - -void cs5435_54p_sysfs_delete_symclass(struct class *my_class) -{ -/**************************************************************************************/ - - if (IS_ERR(my_class)) { - pr_err("Pointer is invaild\n"); - } - class_destroy(my_class); - -/**************************************************************************************/ -} - - - - - -int cs5435_54p_sysfs_create_symlink(struct class *my_class,char * driver_name,char *device_name) -{ - struct list_head *list_node = NULL; - struct sysfs_client_node *sysfs_node = NULL; - int ret = -EPERM; - int rc = 0; - - mutex_lock(&list_lock); - list_for_each(list_node, &sysfs_client_list) - { - sysfs_node = list_entry(list_node, struct sysfs_client_node, list); - if (!strcmp(sysfs_node->client->name,driver_name)) { - rc = sysfs_create_link(&my_class->p->subsys.kobj, &sysfs_node->client->dev.kobj,device_name); - if(rc) - { - pr_err("failed to create symlink %d\n",rc); - } - break; - } - } - mutex_unlock(&list_lock); - return ret; -} - - -int cs5435_54p_sysfs_delete_symlink(struct class *my_class,char * driver_name,char *device_name) -{ - struct list_head *list_node = NULL; - struct sysfs_client_node *sysfs_node = NULL; - int ret = -EPERM; - int rc = 0; - - mutex_lock(&list_lock); - list_for_each(list_node, &sysfs_client_list) - { - sysfs_node = list_entry(list_node, struct sysfs_client_node, list); - if (!strcmp(sysfs_node->client->name,driver_name)) { - sysfs_remove_link(&my_class->p->subsys.kobj,device_name); - break; - } - } - mutex_unlock(&list_lock); - return ret; -} - - -static int cs5435_54p_sysfs_open(struct inode *inode, struct file *file) -{ - return 0; -} - - - -static ssize_t cs5435_54p_sysfs_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos) -{ - char str[10],name[18],port[8]; - int ret; - int i; - memset(str, 0, sizeof(str)); - ret = copy_from_user(str, buf, count); - if (ret) - { - printk(KERN_ERR "copy_from_user fail\n"); - return -EINVAL; - } - - if(!strncmp(str,"start",5)) - { - psu_class = cs5435_54p_sysfs_create_symclass("psu"); - cs5435_54p_sysfs_create_symlink(psu_class,"cs5435_54p_psu1","psu1"); - cs5435_54p_sysfs_create_symlink(psu_class,"cs5435_54p_psu2","psu2"); - sfp_class = cs5435_54p_sysfs_create_symclass("swps"); - for(i = 1; i <= 48;i++) - { - memset(name,0xff,sizeof(name)); - memset(port,0xff,sizeof(port)); - snprintf(name,sizeof(name),"cs5435_54p_sfp%d",i); - snprintf(port,sizeof(port),"port%d",i); - cs5435_54p_sysfs_create_symlink(sfp_class,name,port); - } - } - else if(!strncmp(str,"stop",4)) - { - cs5435_54p_sysfs_delete_symlink(psu_class,"cs5435_54p_psu1","psu1"); - cs5435_54p_sysfs_delete_symlink(psu_class,"cs5435_54p_psu2","psu2"); - cs5435_54p_sysfs_delete_symclass(psu_class); - - for(i = 1; i <= 48;i++) - { - memset(name,0xff,sizeof(name)); - memset(port,0xff,sizeof(port)); - snprintf(name,sizeof(name),"cs5435_54p_sfp%d",i); - snprintf(port,sizeof(port),"port%d",i); - cs5435_54p_sysfs_delete_symlink(sfp_class,name,port); - } - cs5435_54p_sysfs_delete_symclass(sfp_class); - } - return count; -} - - -static struct file_operations cs5435_54p_sysfs_fops = { - .owner = THIS_MODULE, - .open = cs5435_54p_sysfs_open, - .write = cs5435_54p_sysfs_write, -}; - - -static int __init cs5435_54p_sysfs_init(void) -{ - int result = 0; - int err = 0; - dev_t dev = MKDEV(dev_major, 0); - - if (dev_major) - result = register_chrdev_region(dev, 1, DEVICE_NAME); - else { - result = alloc_chrdev_region(&dev, 0, 1, DEVICE_NAME); - dev_major = MAJOR(dev); - } - if (result < 0) - { - printk("unable to get major %d\n", dev_major); - err= -EINVAL; - } - printk("get major is %d\n", dev_major); - if (dev_major == 0) - dev_major = result; - - dev_cdev= kmalloc(sizeof(struct cdev), GFP_KERNEL); - if(IS_ERR(dev_cdev)) { - err= -ENOMEM; - } - - cdev_init(dev_cdev, &cs5435_54p_sysfs_fops); - dev_cdev->owner = THIS_MODULE; - dev_cdev->ops = &cs5435_54p_sysfs_fops; - err = cdev_add(dev_cdev, dev, 1); - if (err) - { - printk("error %d add fpga ", err); - goto err_malloc; - } - - dev_class = class_create(THIS_MODULE, DEVICE_NAME); - if (IS_ERR(dev_class)) - { - printk("Err:failed in creating class.\n"); - goto err_cdev_add; - } - - dev_device = device_create(dev_class, NULL, MKDEV(dev_major, 0), NULL, DEVICE_NAME); - if (IS_ERR(dev_device)) - { - printk("Err:failed in creating device.\n"); - goto err_class_crt; - } - - mutex_init(&list_lock); - - return err; - - err_class_crt: - cdev_del(dev_cdev); - err_cdev_add: - kfree(dev_cdev); - err_malloc: - unregister_chrdev_region(MKDEV(dev_major,0), 1); - - return err; - -} - -static void __exit cs5435_54p_sysfs_exit(void) -{ - cdev_del(dev_cdev); - printk("cdev_del ok\n"); - device_destroy(dev_class, MKDEV(dev_major, 0)); - - class_destroy(dev_class); - - if(dev_cdev != NULL) - kfree(dev_cdev); - - unregister_chrdev_region(MKDEV(dev_major, 0), 1); - printk("cs5435_54p_sysfs_exit...\r\n"); -} - - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs5435-54p-sysfs driver"); -MODULE_LICENSE("GPL"); - -module_init(cs5435_54p_sysfs_init); -module_exit(cs5435_54p_sysfs_exit); - - diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/service/cs5435-platform-init.service b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/service/cs5435-platform-init.service deleted file mode 100644 index b609a2be45c..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/service/cs5435-platform-init.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Cig CS5435-54P Platform initialization service -Before=pmon.service -DefaultDependencies=no - -[Service] -Type=oneshot -ExecStart=/usr/local/bin/cig_cs5435_util.py install -ExecStop=/usr/local/bin/cig_cs5435_util.py clean -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/service/cs5435-platform-misc.service b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/service/cs5435-platform-misc.service deleted file mode 100644 index 852ab5689a7..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/service/cs5435-platform-misc.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Cig CS5435-54P Platform miscellaneous service -After=cs5435-platform-init.service -DefaultDependencies=no - -[Service] -ExecStart=/usr/local/bin/cig_cs5435_misc.py -KillSignal=SIGKILL -SuccessExitStatus=SIGKILL - -# Resource Limitations -LimitCORE=infinity - -[Install] -WantedBy=multi-user.target diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/setup.py b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/setup.py deleted file mode 100755 index 1d4fa7f3645..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/setup.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -import os -import sys -from setuptools import setup -os.listdir - -setup( - name='cs5435-54p', - version='1.0.0', - description='Module to initialize Cig CS5435-54P platforms', - - packages=['cs5435-54p'], - package_dir={'cs5435-54p': 'cs5435-54p/classes'}, - ) diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/utils/cig_cs5435_misc.py b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/utils/cig_cs5435_misc.py deleted file mode 100755 index 0a1a887642d..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/utils/cig_cs5435_misc.py +++ /dev/null @@ -1,574 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2018 Cambridge, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os -import commands -import sys, getopt -import logging -import re -import time -import datetime -from collections import namedtuple -from threading import Thread - -DEBUG = False -i2c_prefix = '/sys/bus/i2c/devices/' -leds_prefix = '/sys/devices/platform/cs5435_54p_led/leds/' -fans_prefix = '/sys/devices/platform/cs5435_54p_fan/' -fansdir_prefix = fans_prefix + 'fan{}_direction' - -ageing_controlfile = '/etc/sonic/agcontrol' -AGFlag = 0 - - -platform_misc_log = '/var/log/platform_misc.log' -misclogger = logging.getLogger('platform_misc') -misclogger.setLevel(logging.INFO) -miscformatter = logging.Formatter('%(asctime)s-%(levelname)s-%(message)s') - -if not os.path.isfile(platform_misc_log): - try: - os.mknod(platform_misc_log) - except: - print 'Failed to creat platform_misc.log' - -fileHandler = logging.FileHandler(platform_misc_log) -fileHandler.setLevel(logging.INFO) -fileHandler.setFormatter(miscformatter) -misclogger.addHandler(fileHandler) - - -starttime = datetime.datetime.now() -IsGetlswt = 0 -coretemp_prefix = '/sys/class/hwmon/hwmon1/' -coretemp_ps = [] -psu1_p = '/sys/bus/i2c/devices/5-005a/psu_present' -psu2_p = '/sys/bus/i2c/devices/5-005b/psu_present' -psu1_d = '/sys/bus/i2c/devices/5-0052/psu_eeprom' -psu2_d = '/sys/bus/i2c/devices/5-0053/psu_eeprom' -psu1led_d = leds_prefix + 'cs5435_54p_led::psu1/brightness' -psu2led_d = leds_prefix + 'cs5435_54p_led::psu2/brightness' -cs5435_ledpath = {'fan':leds_prefix + 'cs5435_54p_led::fan/brightness', - 'fan1':leds_prefix + 'cs5435_54p_led::fan1/brightness', - 'fan2':leds_prefix + 'cs5435_54p_led::fan2/brightness', - 'fan3':leds_prefix + 'cs5435_54p_led::fan3/brightness', - 'fan4':leds_prefix + 'cs5435_54p_led::fan4/brightness', - 'fan5':leds_prefix + 'cs5435_54p_led::fan5/brightness', - 'psu1':leds_prefix + 'cs5435_54p_led::psu1/brightness', - 'psu2':leds_prefix + 'cs5435_54p_led::psu2/brightness', - 'sys':leds_prefix + 'cs5435_54p_led::sys/brightness'} - - -def system_read_filestr(node): - with open(node, 'r') as f: - try: - str = f.read() - except IOError as e: - misclogger.error('Failed to get node, str={}'.format(node)) - return "0" - return str - - -def system_bright_leds(dev, colour): - global AGFlag - - if AGFlag == 1: - return - - cmd = 'echo {} > {}'.format(colour, dev) - log_os_system(cmd, 1) - return - -''' -1: front in tail out -0: front out tail in -''' -def system_getpsu_direction(dev): - try: - with open(dev) as f: - f.seek(0x30) - str = f.read(2) - except IOError as e: - misclogger.error('Failed to get psu eep') - return 1 - if str == 'AA': ## front in tail out - return 1 - elif str == 'RA':## tail in front out - return 0 - else: - misclogger.error('Failed to get psu eep, str={}'.format(str)) - return -1 - - -def system_get_cputype(): - cmdretfd = os.popen("lscpu | grep 'Model name'") - retstring = cmdretfd.read() - endindex = retstring.find('@') - 1 - startindex = retstring[:endindex].rfind(' ') + 1 - cputype = retstring[startindex:endindex] - - return cputype - - -def system_init_coretemppath(): - global coretemp_ps - - cmdstr = "ls {} | grep 'input'".format(coretemp_prefix) - cmdretfd = os.popen(cmdstr) - - coretemppss = cmdretfd.read().splitlines() - if len(coretemppss) < 3: - cputype = system_get_cputype() - misclogger.error('Failed to init core temperature path.' - ' cpu type = {}, num thermal = {}'.format(cputype, len(coretemp_ps))) - return 1 - - for i in range(0,3): - coretemp_ps.append(coretemp_prefix + coretemppss[i]) - - print coretemp_ps - - return 0 - - -class cs5435_fanattr: - def __init__(self, name): - self.name = name - self.direction = 0 - self.direction_p = '' - self.rear = 0 - self.rear_p = '' - self.front = 0 - self.front_p = '' - self.fault = 0 - self.fault_p = '' - self.status = 0 - self.setpath() - self.updatedevice() - - return - - def setpath(self): - self.direction_p = fans_prefix + '{}_direction'.format(self.name) - self.rear_p = fans_prefix + '{}_rear_speed_rpm'.format(self.name) - self.front_p = fans_prefix + '{}_front_speed_rpm'.format(self.name) - self.fault_p = fans_prefix + '{}_fault'.format(self.name) - - return - - def updatedevice(self): - self.direction = int(system_read_filestr(self.direction_p)) - self.rear = int(system_read_filestr(self.rear_p)) - self.front = int(system_read_filestr(self.front_p)) - self.fault = int(system_read_filestr(self.fault_p)) - - return - - def checkspeedrpm(self, speedrpm): - frontrpmexp = speedrpm * 21000 / 100 - rearrpmexp = speedrpm * 19000 / 100 - deviationfront = abs(frontrpmexp - self.front) / float(frontrpmexp) - deviationrear = abs(rearrpmexp - self.rear) / float(rearrpmexp) - - if deviationfront < 0.3 and deviationrear < 0.3: - return 0 - else: - misclogger.error(':{} speed wrong. frontexp is {}, but rpm is {}.rearexp is {}, but rpm is {}'.format(self.name, frontrpmexp, self.front, rearrpmexp, self.rear)) - return 1 - - def checkstatus(self, speedrpm, totaldirct): - speedstatus = self.checkspeedrpm(speedrpm) - if self.direction != totaldirct: - self.status = 1 - misclogger.error(':{} direction = {}.fan direction is not ok.'.format(self.name, self.direction)) - elif speedstatus != 0: - self.status = 1 - elif self.fault != 0: - misclogger.error(':{} fault.'.format(self.name)) - self.status = 1 - else: - self.status = 0 - - if self.status == 1: - system_bright_leds(cs5435_ledpath[self.name], 3) - else: - system_bright_leds(cs5435_ledpath[self.name], 1) - - return self.status - -cs5435_fanattrnodes = [] - - -class cs5435_psuattr: - def __init__(self, name): - self.name = name - self.direction = 0 - self.direction_p = '' - self.present = 0 - self.present_p = '' - self.status = 0 - - self.setpath() - self.updatepresent() - self.updatedirection() - - return - - def setpath(self): - if self.name == 'psu1': - self.present_p = psu1_p - self.direction_p = psu1_d - if self.name == 'psu2': - self.present_p = psu2_p - self.direction_p = psu2_d - - return - - def updatepresent(self): - self.present = int(system_read_filestr(self.present_p)) - - return - - def updatedirection(self): - if self.present == 1: - self.direction = system_getpsu_direction(self.direction_p) - else: - self.direction = 2 - - return - - def checkstatus(self, totaldirct): - if self.present != 1: - self.status = 1 - misclogger.error(':{} not present.'.format(self.name)) - elif self.direction == 2: - self.status = 0 - misclogger.info(':{} direction need to be update.'.format(self.name)) - elif self.direction != totaldirct: - self.status = 1 - misclogger.info(':{} direction is wrong.'.format(self.name)) - else: - self.status = 0 - - if self.status == 1: - system_bright_leds(cs5435_ledpath[self.name], 3) - else: - system_bright_leds(cs5435_ledpath[self.name], 1) - - return self.status - -cs5435_psuattrnodes = [] - - - -def my_log(txt): - if DEBUG == True: - print "[ROY]"+txt - return - -def device_exist(): - ret1, log = log_os_system("ls "+i2c_prefix+"5-005a", 0) - ret2, log = log_os_system("ls "+i2c_prefix+"5-005b", 0) - ret3, log = log_os_system("ls "+leds_prefix+"cs5435_54p_led*", 0) - return not(ret1 or ret2 or ret3) - - -def log_os_system(cmd, show): - logging.info('Run :'+cmd) - status, output = commands.getstatusoutput(cmd) - my_log (cmd +"with result:" + str(status)) - my_log (" output:"+output) - if status: - logging.info('Failed :'+cmd) - if show: - print('Failed :'+cmd) - return status, output - - -def system_get_coretemp(): - temp1 = system_read_filestr(coretemp_ps[0]).strip() - temp2 = system_read_filestr(coretemp_ps[1]).strip() - temp3 = system_read_filestr(coretemp_ps[2]).strip() - - return int(temp1), int(temp2), int(temp3) - -def system_get_boardtemp(): - for i in range(0,16): - temp1path = "/sys/bus/i2c/devices/5-004a/hwmon/hwmon%d/temp1_input" % i - if os.access(temp1path, os.F_OK): - break - for i in range(0,16): - temp2path = "/sys/bus/i2c/devices/5-004b/hwmon/hwmon%d/temp1_input" % i - if os.access(temp2path, os.F_OK): - break - temp1 = system_read_filestr(temp1path).strip() - temp2 = system_read_filestr(temp2path).strip() - - return int(temp1), int(temp2) - - -def system_get_lswtemp(): - global IsGetlswt - global starttime - if IsGetlswt == 0: - now = datetime.datetime.now() - misclogger.info("time wait.") - misclogger.info("start = {}, now = {}.".format(starttime, now)) - if (now - starttime).seconds > 150: - misclogger.info("time = ".format((now - starttime).seconds)) - IsGetlswt = 1 - - return 25 - -# chp = subprocess.Popen("docker ps --filter name=syncd", shell=True, stdout=subprocess.PIPE) -# if chp.poll() is None: -# misclogger.info("No subp.") -# chp.kill() -# -# return 25 - -# retstring = chp.stdout.read() -# chp.kill() -# if 'Up' not in retstring: -# misclogger.info("lsw not up.") -# -# return 25 - - status, output = log_os_system('npx_diag swc show temperature', 1) - if status: - misclogger.error('failed to show lsw temperature') - - return 25 - - output = output.strip() - if output.find("it 0, temperature ") > 0: - startindex = output.find('temperature') + len('temperature') + 1 - endindex = output[startindex:].find(" ") - endindex = startindex + endindex - temp = output[startindex:endindex] - b = temp.find('.') - if b > 0: - temp=temp[:b] - temp = int(temp) - else: - misclogger.error("Failed to get temperature.") - temp = 0 - - return int(temp) - -def system_monitor_temperature(): - - ctemp1, ctemp2, ctemp3 = system_get_coretemp() - btemp1, btemp2 = system_get_boardtemp() - ltemp = system_get_lswtemp() - fan_speed_str = system_cs5435_getfanexspeed() - fan_speed = int(fan_speed_str) - policy = 'stay' - pos = 0 - #speed c1 c2 c3 b1 b2 lsw - fan_policy_up = ([30, 40000, 40000, 40000, 42000, 35000, 95], - [40, 44000, 44000, 44000, 44000, 39000, 96], - [50, 49000, 49000, 49000, 47000, 44000, 91], - [60, 52000, 52000, 52000, 51500, 47500, 92], - [70, 53000, 53000, 53000, 52000, 49000, 93], - [100,999999,999999,999999,999999,999999,999]) - - fan_policy_down=([30, 0, 0, 0, 0, 0, 0], - [40, 34000, 34000, 34000, 34000, 30000, 80], - [50, 38000, 38000, 38000, 37000, 33000, 81], - [60, 44000, 44000, 44000, 43000, 39000, 84], - [70, 44000, 44000, 44000, 43000, 40000, 84], - [100, 48000, 48000, 48000, 46000, 42000, 85],) - - for policytable in fan_policy_up: - if fan_speed <= policytable[0]: - break - pos = pos + 1 - fan_speed = policytable[0] - if (ctemp1 < policytable[1]) and (ctemp2 < policytable[2]) and (ctemp3 < policytable[3]) and (btemp1 < policytable[4]) and (btemp2 < policytable[5]) and (ltemp < policytable[6]): - policy = 'stay' - policytable = fan_policy_down[pos] - if (ctemp1 < policytable[1]) and (ctemp2 < policytable[2]) and (ctemp3 < policytable[3]) and (btemp1 < policytable[4]) and (btemp2 < policytable[5]) and (ltemp < policytable[6]): - policy = 'down' - else: - policy = 'up' - - if policy == 'up': - misclogger.info("speed = %d." % fan_speed) - misclogger.info("core1 = %d, core2 = %d, core3 = %d." % (ctemp1, ctemp2, ctemp3)) - misclogger.info("board1 = %d, board2 = %d." % (btemp1, btemp2)) - misclogger.info("lsw = %d" % ltemp) - fan_speed = fan_policy_down[pos + 1][0] - misclogger.info("fan policy: up. speedexp = {}".format(fan_speed)) - - if policy == 'stay': - fan_speed = fan_policy_down[pos] - return - - if policy == 'down': - misclogger.info("speed = %d." % fan_speed) - misclogger.info("core1 = %d, core2 = %d, core3 = %d." % (ctemp1, ctemp2, ctemp3)) - misclogger.info("board1 = %d, board2 = %d." % (btemp1, btemp2)) - misclogger.info("lsw = %d" % ltemp) - fan_speed = fan_policy_down[pos - 1][0] - misclogger.info("fan policy: down.speedexp = {}".format(fan_speed)) - - cmd = "echo %d > /sys/devices/platform/cs5435_54p_fan/fan_duty_cycle_percentage" % fan_speed - status, output = log_os_system(cmd, 1) - if status: - misclogger.error("set fan speed fault") - - return - - -def system_cs5435_setfanexspeed(num): - fanspeednode = fans_prefix + 'fan_duty_cycle_percentage' - numstr = str(num) - with open(fanspeednode, 'w') as f: - f.write(numstr) - - -def system_cs5435_getfanexspeed(): - fanspeednode = fans_prefix + 'fan_duty_cycle_percentage' - fanspeedstr = system_read_filestr(fanspeednode) - fanspeedexp = int(fanspeedstr) - - return fanspeedexp - - -def system_cs5435_getdirection(): - global cs5435_fanattrnodes - direction = 0 - - for fan in cs5435_fanattrnodes: - direction = direction + fan.direction - - if direction > 2: - direction = 1 - else: - direction = 0 - - return direction - - -def system_check_psusdirection(): - global cs5435_psuattrnodes - cs5435totaldirct = system_cs5435_getdirection() - psutatus = 0 - - for psu in cs5435_psuattrnodes: - psu.updatedirection() - psu.checkstatus(cs5435totaldirct) - psutatus = psu.status + psutatus - - return (psutatus != 0) - - -def system_check_psuspresent(): - global cs5435_psuattrnodes - cs5435totaldirct = system_cs5435_getdirection() - psutatus = 0 - - for psu in cs5435_psuattrnodes: - psu.updatepresent() - psu.checkstatus(cs5435totaldirct) - psutatus = psu.status + psutatus - - return (psutatus != 0) - - -def system_check_fansstate(): - global cs5435_fanattrnodes - global cs5435_ledpath - cs5435totaldirct = system_cs5435_getdirection() - fanstatus = 0 - fanexspeed = 0 - - fanexspeed = system_cs5435_getfanexspeed() - - for fan in cs5435_fanattrnodes: - fan.updatedevice() - fan.checkstatus(fanexspeed, cs5435totaldirct) - fanstatus = fanstatus + fan.status - - if fanstatus > 0: - misclogger.error(':fan error.set fans speed 100.') - system_cs5435_setfanexspeed(100) - system_bright_leds(cs5435_ledpath['fan'], 3) - else: - system_bright_leds(cs5435_ledpath['fan'], 1) - - return (fanstatus != 0) - - -def system_misc_polling(threadName,delay): - for count in range(1,5): - if device_exist() == False: - time.sleep(delay+3) - print "%s: %s, count=%d" % ( threadName, time.ctime(time.time()), count) - else: - break - - if count == 4: - return - - status, output = log_os_system("echo 1 > /sys/devices/platform/cs5435_54p_led/leds/cs5435_54p_led::sys/brightness", 1) - status, output = log_os_system("hwconfig -cfp 1", 1) - - global AGFlag - if os.access(ageing_controlfile, os.F_OK): - AGFlag = 1 - else: - AGFlag = 0 - - os.system('csw_daemon &') - - - global cs5435_fanattrnodes - global cs5435_psuattrnodes - - for num in range(1,6): - name = 'fan{}'.format(num) - fannode = cs5435_fanattr(name) - cs5435_fanattrnodes.append(fannode) - for num in range(1,3): - name = 'psu{}'.format(num) - psunode = cs5435_psuattr(name) - cs5435_psuattrnodes.append(psunode) - - tempcontrol = system_init_coretemppath() - - misclogger.info("%s: %s misc start." % ( threadName, time.ctime(time.time()))) - count = 0 - while 1: - count = count + 1 - ret = system_check_psuspresent() - ret = system_check_fansstate() - - if count % 10 == 0: - misclogger.info(": adjust fans and check psu direction.") - system_check_psusdirection() - if tempcontrol == 0: - system_monitor_temperature() - count = 0 - time.sleep(delay) - - return - -if __name__ == '__main__': - target=system_misc_polling("Thread-misc",10) - diff --git a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/utils/cig_cs5435_util.py b/platform/nephos/sonic-platform-modules-cig/cs5435-54p/utils/cig_cs5435_util.py deleted file mode 100755 index 03302592257..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs5435-54p/utils/cig_cs5435_util.py +++ /dev/null @@ -1,563 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2018 Cambridge, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -""" -Usage: %(scriptName)s [options] command object - -options: - -h | --help : this help message - -d | --debug : run with debug mode - -f | --force : ignore error during installation or clean -command: - install : install drivers and generate related sysfs nodes - clean : uninstall drivers and remove related sysfs nodes - show : show all systen status - sff : dump SFP eeprom - set : change board setting with fan|led|sfp -""" - -import os -import commands -import sys, getopt -import logging -import re -import time -from collections import namedtuple - - - - -PROJECT_NAME = 'cs5435_54p' -version = '0.1.1' -verbose = False -DEBUG = False -args = [] -ALL_DEVICE = {} -DEVICE_NO = {'led':9, 'fan':5, 'thermal':4, 'psu':2, 'sfp':54} -FORCE = 0 -CPU_TYPE = 'C3308' - -if DEBUG == True: - print sys.argv[0] - print 'ARGV :', sys.argv[1:] - - -def main(): - global DEBUG - global args - global FORCE - - if len(sys.argv)<2: - show_help() - - options, args = getopt.getopt(sys.argv[1:], 'hdf', ['help', - 'debug', - 'force', - ]) - if DEBUG == True: - print options - print args - print len(sys.argv) - - for opt, arg in options: - if opt in ('-h', '--help'): - show_help() - elif opt in ('-d', '--debug'): - DEBUG = True - logging.basicConfig(level=logging.INFO) - elif opt in ('-f', '--force'): - FORCE = 1 - else: - logging.info('no option') - for arg in args: - if arg == 'install': - do_install() - elif arg == 'clean': - do_uninstall() - elif arg == 'show': - device_traversal() - elif arg == 'sff': - if len(args)!=2: - show_eeprom_help() - elif int(args[1]) ==0 or int(args[1]) > DEVICE_NO['sfp']: - show_eeprom_help() - else: - show_eeprom(args[1]) - return - elif arg == 'set': - if len(args)<3: - show_set_help() - else: - set_device(args[1:]) - return - else: - show_help() - - - return 0 - -def show_help(): - print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]} - sys.exit(0) - -def show_set_help(): - cmd = sys.argv[0].split("/")[-1]+ " " + args[0] - print cmd +" [led|sfp|fan]" - print " use \""+ cmd + " led 0-4 \" to set led color" - print " use \""+ cmd + " fan 0-100\" to set fan duty percetage" - print " use \""+ cmd + " sfp 1-54 {0|1}\" to set sfp# tx_disable" - sys.exit(0) - -def show_eeprom_help(): - cmd = sys.argv[0].split("/")[-1]+ " " + args[0] - print " use \""+ cmd + " 1-54 \" to dump sfp# eeprom" - sys.exit(0) - -def my_log(txt): - if DEBUG == True: - print "[ROY]"+txt - return - -def log_os_system(cmd, show): - logging.info('Run :'+cmd) - status, output = commands.getstatusoutput(cmd) - my_log (cmd +"with result:" + str(status)) - my_log (" output:"+output) - if status: - logging.info('Failed :'+cmd) - if show: - print('Failed :'+cmd) - return status, output - -def driver_check(): - for count in range(1,5): - time.sleep(1) - ret, lsmod = log_os_system("lsmod| grep i2c_i801", 0) - if len(lsmod) > 2: - log_os_system("rmmod i2c_i801", 0) - break - - ret, lsmod = log_os_system("lsmod| grep i2c_designware_platform", 0) - if len(lsmod) > 2: - log_os_system("rmmod i2c_designware_platform", 0) - log_os_system("modprobe i2c-designware-platform", 0) - - ret, lsmod = log_os_system("lsmod| grep cig", 0) - logging.info('mods:'+lsmod) - if len(lsmod) ==0: - return False - return True - - - -kos = [ - 'depmod', - 'modprobe i2c_dev', - 'modprobe i2c_mux_pca954x force_deselect_on_exit=1', - 'modprobe x86-64-cig-cs5435-54p-sysfs ' , - 'modprobe x86-64-cig-cs5435-54p-cpld ' , - 'modprobe x86-64-cig-cs5435-54p-fan' , - 'modprobe x86-64-cig-cs5435-54p-psu' , - 'modprobe x86-64-cig-cs5435-54p-sfp' , - 'modprobe x86-64-cig-cs5435-54p-led' ] - -def driver_install(): - global FORCE - - for i in range(0,len(kos)): - if i == 4: - ret, CPU_TYPE = log_os_system("cat /proc/cpuinfo | grep \"model name\" | cut -b 32-39 | head -n 1", 0) - if CPU_TYPE=='i3-6100U': - kos[i] =kos[i] + 'board_id=1' - ret, CPU_TYPE = log_os_system("cat /proc/cpuinfo | grep \"model name\" | cut -b 36-40 | head -n 1", 0) - if CPU_TYPE=='C3758' or CPU_TYPE=='C3308': - kos[i] =kos[i] + 'board_id=2' - - status, output = log_os_system(kos[i], 1) - if status: - if FORCE == 0: - return status - return 0 - -def driver_uninstall(): - global FORCE - for i in range(0,len(kos)): - rm = kos[-(i+1)].replace("modprobe", "modprobe -rq") - rm = rm.replace("insmod", "rmmod") - status, output = log_os_system(rm, 1) - if status: - if FORCE == 0: - return status - return 0 - -led_prefix ='/sys/class/leds/'+PROJECT_NAME+'_led::' -hwmon_types = {'led': ['sys','fan','fan1','fan2','fan3','fan4','fan5','psu1','psu2']} -hwmon_nodes = {'led': ['brightness'] } -hwmon_prefix ={'led': led_prefix} - -i2c_prefix = '/sys/bus/i2c/devices/' -i2c_bus = {'thermal': ['4-0048','4-0049', '5-004a', '5-004b'] , - 'psu': ['5-005a','5-005b'], - 'sfp': ['-0050']} -i2c_nodes = {'thermal': ['hwmon/hwmon*/temp1_input'] , - 'psu': ['psu_present ', 'psu_power_good'] , - 'sfp': ['sfp_is_present ', 'sfp_tx_disable']} - -fan_prefix ='/sys/bus/platform/devices/'+PROJECT_NAME+'_fan' -fan_types = {'fan': ['fan1','fan2', 'fan3', 'fan4', 'fan5']} -fan_nodes = {'fan': ['state', 'front_speed_rpm', 'rear_speed_rpm', 'fault']} - - -sfp_map = [8,9,10,11,12,13,14,15,16, - 17,18,19,20,21,22,23,24,25,26, - 27,28,29,30,31,32,33,34,35,36, - 37,38,39,40,41,42,43,44,45,46, - 47,48,49,50,51,52,53,54,55,56, - 57,60,61,62,63] - -mknod =[ - 'echo pca9548 0x71 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo pca9548 0x73 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo pca9548 0x74 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo pca9548 0x75 > /sys/bus/i2c/devices/i2c-3/new_device', - 'echo pca9548 0x76 > /sys/bus/i2c/devices/i2c-3/new_device', - 'echo pca9548 0x77 > /sys/bus/i2c/devices/i2c-3/new_device', - 'echo lm75 0x48 > /sys/bus/i2c/devices/i2c-4/new_device', - 'echo lm75 0x49 > /sys/bus/i2c/devices/i2c-4/new_device', - 'echo lm75 0x4a > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo lm75 0x4b > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo cs5435_54p_psu1 0x5a > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo cs5435_54p_psu2 0x5b > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo cs5435_54p_psu1 0x52 > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo cs5435_54p_psu2 0x53 > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo 24c128 0x57 > /sys/bus/i2c/devices/i2c-7/new_device'] - -port = 0 - -def device_install(): - global FORCE - global port - for i in range(0,len(mknod)): - #all nodes need times to built new i2c buses - time.sleep(1) - - status, output = log_os_system(mknod[i], 1) - if status: - print output - if FORCE == 0: - return status - - for i in range(0,len(sfp_map)): - if (i == 50): - port = port + 3 - else: - port = port + 1 - - - status, output =log_os_system("echo cs5435_54p_sfp"+str(port)+" 0x50 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1) - if status: - print output - if FORCE == 0: - return status - - if port <= 48: - status, output =log_os_system("echo cs5435_54p_sfp"+str(port)+" 0x51 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1) - if status: - print output - if FORCE == 0: - return status - - return - -def device_uninstall(): - global FORCE - - for i in range(0,len(sfp_map)): - target = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/delete_device" - status, output =log_os_system("echo 0x50 > "+ target, 1) - if status: - print output - if FORCE == 0: - return status - - nodelist = mknod - - for i in range(len(nodelist)): - target = nodelist[-(i+1)] - temp = target.split() - del temp[1] - temp[-1] = temp[-1].replace('new_device', 'delete_device') - status, output = log_os_system(" ".join(temp), 1) - if status: - print output - if FORCE == 0: - return status - - return - -def system_ready(): - if driver_check() == False: - return False - if not device_exist(): - return False - return True - -def do_install(): - print "Checking system...." - if driver_check() == False: - print "No driver, installing...." - status = driver_install() - if status: - if FORCE == 0: - return status - else: - print PROJECT_NAME.upper()+" drivers detected...." - if not device_exist(): - print "No device, installing...." - status = device_install() - if status: - if FORCE == 0: - return status - else: - print PROJECT_NAME.upper()+" devices detected...." - return - -def do_uninstall(): - print "Checking system...." - if not device_exist(): - print PROJECT_NAME.upper() +" has no device installed...." - else: - print "Removing device...." - status = device_uninstall() - if status: - if FORCE == 0: - return status - - if driver_check()== False : - print PROJECT_NAME.upper() +" has no driver installed...." - else: - print "Removing installed driver...." - status = driver_uninstall() - if status: - if FORCE == 0: - return status - - return - -def devices_info(): - global DEVICE_NO - global ALL_DEVICE - global i2c_bus, hwmon_types, fan_types - for key in DEVICE_NO: - ALL_DEVICE[key]= {} - for i in range(0,DEVICE_NO[key]): - ALL_DEVICE[key][key+str(i+1)] = [] - - for key in i2c_bus: - buses = i2c_bus[key] - nodes = i2c_nodes[key] - for i in range(0,len(buses)): - for j in range(0,len(nodes)): - if 'sfp' == key: - for k in range(0,DEVICE_NO[key]): - node = key+str(k+1) - path = i2c_prefix+ str(sfp_map[k])+ buses[i]+"/"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][node].append(path) - else: - node = key+str(i+1) - path = i2c_prefix+ buses[i]+"/"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][node].append(path) - - for key in hwmon_types: - itypes = hwmon_types[key] - nodes = hwmon_nodes[key] - for i in range(0,len(itypes)): - for j in range(0,len(nodes)): - node = key+"_"+itypes[i] - path = hwmon_prefix[key]+ itypes[i]+"/"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][ key+str(i+1)].append(path) - - for key in fan_types: - itypes = fan_types[key] - nodes = fan_nodes[key] - for i in range(0,len(itypes)): - for j in range(0,len(nodes)): - node = key+"_"+itypes[i] - path = fan_prefix+"/"+ itypes[i]+"_"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][ key+str(i+1)].append(path) - - #show dict all in the order - if DEBUG == True: - for i in sorted(ALL_DEVICE.keys()): - print(i+": ") - for j in sorted(ALL_DEVICE[i].keys()): - print(" "+j) - for k in (ALL_DEVICE[i][j]): - print(" "+" "+k) - return - -def show_eeprom(index): - if system_ready()==False: - print("System's not ready.") - print("Please install first!") - return - - if len(ALL_DEVICE)==0: - devices_info() - node = ALL_DEVICE['sfp'] ['sfp'+str(index)][0] - node = node.replace(node.split("/")[-1], 'sfp_eeprom') - # check if got hexdump command in current environment - ret, log = log_os_system("which hexdump", 0) - ret, log2 = log_os_system("which busybox hexdump", 0) - if len(log): - hex_cmd = 'hexdump' - elif len(log2): - hex_cmd = ' busybox hexdump' - else: - log = 'Failed : no hexdump cmd!!' - logging.info(log) - print log - return 1 - - print node + ":" - ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1) - if ret==0: - print log - else: - print "**********device no found**********" - return - -def set_device(args): - global DEVICE_NO - global ALL_DEVICE - if system_ready()==False: - print("System's not ready.") - print("Please install first!") - return - - if len(ALL_DEVICE)==0: - devices_info() - - if args[0]=='led': - if int(args[1])>4: - show_set_help() - return - #print ALL_DEVICE['led'] - for i in range(0,len(ALL_DEVICE['led'])): - for k in (ALL_DEVICE['led']['led'+str(i+1)]): - ret, log = log_os_system("echo "+args[1]+" >"+k, 1) - if ret: - return ret - elif args[0]=='fan': - if int(args[1])>100: - show_set_help() - return - #print ALL_DEVICE['fan'] - #fan1~6 is all fine, all fan share same setting - node = ALL_DEVICE['fan'] ['fan1'][0] - node = node.replace(node.split("/")[-1], 'fan_duty_cycle_percentage') - ret, log = log_os_system("cat "+ node, 1) - if ret==0: - print ("Previous fan duty: " + log.strip() +"%") - ret, log = log_os_system("echo "+args[1]+" >"+node, 1) - if ret==0: - print ("Current fan duty: " + args[1] +"%") - return ret - elif args[0]=='sfp': - if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0: - show_set_help() - return - if len(args)<2: - show_set_help() - return - - if int(args[2])>1: - show_set_help() - return - - #print ALL_DEVICE[args[0]] - for i in range(0,len(ALL_DEVICE[args[0]])): - for j in ALL_DEVICE[args[0]][args[0]+str(args[1])]: - if j.find('tx_disable')!= -1: - ret, log = log_os_system("echo "+args[2]+" >"+ j, 1) - if ret: - return ret - - return - -def get_value(input): - digit = re.findall('\d+', input) - return int(digit[0]) - - -def get_ledname(ledx): - name_table={'led1':'SYS','led2':'FSTUS','led3':'FAN1','led4':'FAN2','led5':'FAN3','led6':'FAN4','led7':'FAN5','led8':'PSU1','led9':'PSU2'} - if name_table.has_key(ledx): - name = name_table[ledx] - else: - name = ledx - return name - - -def device_traversal(): - if system_ready()==False: - print("System's not ready.") - print("Please install first!") - return - - if len(ALL_DEVICE)==0: - devices_info() - for i in sorted(ALL_DEVICE.keys()): - print("============================================") - print(i.upper()+": ") - print("============================================") - - for j in sorted(ALL_DEVICE[i].keys(), key=get_value): - nwnamex = get_ledname(j) - if nwnamex == j: - print " "+j+":", - else: - print " "+nwnamex+":", - for k in (ALL_DEVICE[i][j]): - ret, log = log_os_system("cat "+k, 0) - func = k.split("/")[-1].strip() - func = re.sub(j+'_','',func,1) - func = re.sub(i.lower()+'_','',func,1) - if ret==0: - print func+"="+log+" ", - else: - print func+"="+"X"+" ", - print - print("----------------------------------------------------------------") - - - print - return - -def device_exist(): - ret1, log = log_os_system("ls "+i2c_prefix+"*0077", 0) - ret2, log = log_os_system("ls "+i2c_prefix+"i2c-3", 0) - return not(ret1 or ret2) - - -if __name__ == "__main__": - main() diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/classes/__init__.py b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/classes/__init__.py deleted file mode 100755 index e69de29bb2d..00000000000 diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/classes/fanutil.py b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/classes/fanutil.py deleted file mode 100755 index e69de29bb2d..00000000000 diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/classes/thermalutil.py b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/classes/thermalutil.py deleted file mode 100755 index e69de29bb2d..00000000000 diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/Makefile b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/Makefile deleted file mode 100644 index e37e985a214..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -obj-m :=x86-64-cig-cs6436-54p-sysfs.o \ - x86-64-cig-cs6436-54p-cpld.o \ - x86-64-cig-cs6436-54p-fan.o \ - x86-64-cig-cs6436-54p-led.o \ - x86-64-cig-cs6436-54p-psu.o \ - x86-64-cig-cs6436-54p-sfp.o diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/i2c-algo-lpc.h b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/i2c-algo-lpc.h deleted file mode 100644 index 749aa94ef93..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/i2c-algo-lpc.h +++ /dev/null @@ -1,222 +0,0 @@ -/* -------------------------------------------------------------------- - - * A hwmon driver for the CIG cs6436-54P - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* -------------------------------------------------------------------- */ - -#ifndef I2C_LPC_H -#define I2C_LPC_H 1 - -/* ----- Control register bits ---------------------------------------- */ -#define I2C_LPC_PIN 0x80 -#define I2C_LPC_ESO 0x40 -#define I2C_LPC_ES1 0x20 -#define I2C_LPC_ES2 0x10 -#define I2C_LPC_ENI 0x08 - -#define I2C_LPC_STO 0x40 -#define I2C_LPC_ACK 0x01 - -/*command register*/ -#define I2C_LPC_STA 0x80 -#define I2C_LPC_ABT 0x40 - -/*status register*/ -#define I2C_LPC_TBE 0x02 -#define I2C_LPC_IBB 0x80 -#define I2C_LPC_RBF 0x01 -#define I2C_LPC_TD 0x08 - -#define I2C_LPC_START I2C_LPC_STA -#define I2C_LPC_STOP I2C_LPC_STO -#define I2C_LPC_REPSTART I2C_LPC_STA -#define I2C_LPC_IDLE - -/* ----- Status register bits ----------------------------------------- */ -/*#define I2C_LPC_PIN 0x80 as above*/ - -#define I2C_LPC_INI 0x40 /* 1 if not initialized */ -#define I2C_LPC_STS 0x20 -#define I2C_LPC_BER 0x10 -#define I2C_LPC_AD0 0x08 -#define I2C_LPC_LRB 0x08 -#define I2C_LPC_AAS 0x04 -#define I2C_LPC_LAB 0x02 -#define I2C_LPC_BB 0x80 - -/* ----- Chip clock frequencies --------------------------------------- */ -#define I2C_LPC_CLK3 0x00 -#define I2C_LPC_CLK443 0x10 -#define I2C_LPC_CLK6 0x14 -#define I2C_LPC_CLK 0x18 -#define I2C_LPC_CLK12 0x1c - -/* ----- transmission frequencies ------------------------------------- */ -#define I2C_LPC_TRNS90 0x00 /* 90 kHz */ -#define I2C_LPC_TRNS45 0x01 /* 45 kHz */ -#define I2C_LPC_TRNS11 0x02 /* 11 kHz */ -#define I2C_LPC_TRNS15 0x03 /* 1.5 kHz */ - - -#define I2C_LPC_OWNADR 0 -#define I2C_LPC_INTREG I2C_LPC_ES2 -#define I2C_LPC_CLKREG I2C_LPC_ES1 - -#define I2C_LPC_REG_TEST 0x01 -#define I2C_LPC_REG_BUS_SEL 0x80 -#define I2C_LPC_REG_DEVICE_ADDR 0x81 -#define I2C_LPC_REG_BYTE_COUNT 0x83 -#define I2C_LPC_REG_COMMAND 0x84 -#define I2C_LPC_REG_STATUS 0x85 -#define I2C_LPC_REG_DATA_RX1 0x86 -#define I2C_LPC_REG_DATA_RX2 0x87 -#define I2C_LPC_REG_DATA_RX3 0x88 -#define I2C_LPC_REG_DATA_RX4 0x89 -#define I2C_LPC_REG_DATA_TX1 0x8a -#define I2C_LPC_REG_DATA_TX2 0x8b -#define I2C_LPC_REG_DATA_TX3 0x8c -#define I2C_LPC_REG_DATA_TX4 0x8d - - -#define ADDR_REG_SFP_STATUS_ADDR 0X62 //reg addr +R/W# //1031 -#define ADDR_REG_SFP_STATUS_TX 0X63 // write data -#define ADDR_REG_SFP_STATUS_RX 0X64 //read data -#define ADDR_REG_SFP_STATUS_COMMAND 0X65 //cmd bit7=1,go -#define ADDR_REG_SFP_STATUS_STATUS 0X66 //status - -#define CPLD_MASTER_INTERRUPT_STATUS_REG 0x20 -#define CPLD_MASTER_INTERRUPT_MASK_REG 0x21 -#define CPLD_MASTER_INTERRUPT_ALL 0x3f -#define CPLD_MASTER_INTERRUPT_CPLD2 0x20 -#define CPLD_MASTER_INTERRUPT_CPLD1 0x10 -#define CPLD_MASTER_INTERRUPT_PSU2 0x08 -#define CPLD_MASTER_INTERRUPT_PSU1 0x04 -#define CPLD_MASTER_INTERRUPT_6320 0x02 -#define CPLD_MASTER_INTERRUPT_LSW 0x01 - - - -#define CPLD_SLAVE1_INTERRUPT_STATUS_L_REG 0x20 -#define CPLD_SLAVE1_INTERRUPT_STATUS_H_REG 0x21 -#define CPLD_SLAVE2_INTERRUPT_STATUS_L_REG 0x22 -#define CPLD_SLAVE2_INTERRUPT_STATUS_H_REG 0x23 -#define CPLD_SLAVE1_INTERRUPT_MASK_REG 0x24 -#define CPLD_SLAVE2_INTERRUPT_MASK_REG 0x25 - - -#define CPLD_SLAVE1_PRESENT08_REG 0x01 -#define CPLD_SLAVE1_PRESENT16_REG 0x02 -#define CPLD_SLAVE1_PRESENT24_REG 0x03 -#define CPLD_SLAVE2_PRESENT32_REG 0x04 -#define CPLD_SLAVE2_PRESENT40_REG 0x05 -#define CPLD_SLAVE2_PRESENT48_REG 0x06 - -#define CPLD_SLAVE1_RX_LOST08_REG 0x07 -#define CPLD_SLAVE1_RX_LOST16_REG 0x08 -#define CPLD_SLAVE1_RX_LOST24_REG 0x09 -#define CPLD_SLAVE2_RX_LOST32_REG 0x0a -#define CPLD_SLAVE2_RX_LOST40_REG 0x0b -#define CPLD_SLAVE2_RX_LOST48_REG 0x0c - -#define CPLD_SLAVE1_TX_FAULT08_REG 0x0d -#define CPLD_SLAVE1_TX_FAULT16_REG 0x0e -#define CPLD_SLAVE1_TX_FAULT24_REG 0x0f -#define CPLD_SLAVE2_TX_FAULT32_REG 0x10 -#define CPLD_SLAVE2_TX_FAULT40_REG 0x11 -#define CPLD_SLAVE2_TX_FAULT48_REG 0x12 - -#define CPLD_SLAVE2_PRESENT56_REG 0x19 -#define CPLD_SLAVE2_QSFP_CR56_REG 0x1a - - -#define CPLD_SLAVE1_INTERRUPT_PRESENT08 0x0001 -#define CPLD_SLAVE1_INTERRUPT_PRESENT16 0x0002 -#define CPLD_SLAVE1_INTERRUPT_PRESENT24 0x0004 -#define CPLD_SLAVE2_INTERRUPT_PRESENT32 0x0001 -#define CPLD_SLAVE2_INTERRUPT_PRESENT40 0x0002 -#define CPLD_SLAVE2_INTERRUPT_PRESENT48 0x0004 - -#define CPLD_SLAVE2_INTERRUPT_QSFP_CR56 0x0200 -#define CPLD_SLAVE2_INTERRUPT_PRESENT56 0x0400 - -#define CPLD_SLAVE1_INTERRUPT_RX_LOST08 0x0008 -#define CPLD_SLAVE1_INTERRUPT_RX_LOST16 0x0010 -#define CPLD_SLAVE1_INTERRUPT_RX_LOST24 0x0020 -#define CPLD_SLAVE2_INTERRUPT_RX_LOST32 0x0008 -#define CPLD_SLAVE2_INTERRUPT_RX_LOST40 0x0010 -#define CPLD_SLAVE2_INTERRUPT_RX_LOST48 0x0020 - -#define CPLD_SLAVE1_INTERRUPT_TX_FAULT08 0x0040 -#define CPLD_SLAVE1_INTERRUPT_TX_FAULT16 0x0080 -#define CPLD_SLAVE1_INTERRUPT_TX_FAULT24 0x0100 -#define CPLD_SLAVE2_INTERRUPT_TX_FAULT32 0x0040 -#define CPLD_SLAVE2_INTERRUPT_TX_FAULT40 0x0080 -#define CPLD_SLAVE2_INTERRUPT_TX_FAULT48 0x0100 - - - - - - - -#define WAIT_TIME_OUT_COUNT 100 - - -struct i2c_algo_lpc_data { - void *data; /* private data for lolevel routines */ - void (*setlpc) (void *data, int ctl, int val); - int (*getlpc) (void *data, int ctl); - int (*getown) (void *data); - int (*getclock) (void *data); - void (*waitforpin) (void *data); - - int (*xfer_begin) (void *data); - int (*xfer_end) (void *data); - - /* Multi-master lost arbitration back-off delay (msecs) - * This should be set by the bus adapter or knowledgable client - * if bus is multi-mastered, else zero - */ - unsigned long lab_mdelay; -}; - - -struct subsys_private { - struct kset subsys; - struct kset *devices_kset; - struct list_head interfaces; - struct mutex mutex; - - struct kset *drivers_kset; - struct klist klist_devices; - struct klist klist_drivers; - struct blocking_notifier_head bus_notifier; - unsigned int drivers_autoprobe:1; - struct bus_type *bus; - - struct kset glue_dirs; - struct class *class; -}; - -void cs6436_54p_sysfs_add_client(struct i2c_client *client); -void cs6436_54p_sysfs_remove_client(struct i2c_client *client); - - -#endif /* I2C_LPC8584_H */ diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-cpld.c b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-cpld.c deleted file mode 100644 index 1c7930b3d26..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-cpld.c +++ /dev/null @@ -1,2202 +0,0 @@ -/* - * A hwmon driver for the CIG cs6436-54P CPLD - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "i2c-algo-lpc.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef CPLD_USER -# include -#else -# include -#endif - -#include -#include -#include -#include -#include -#include -#include - - - - - -/********************************************** Start ********************************************************/ - -/* - * ISA bus. - */ - -static void platform_isa_bus_release(struct device * dev) -{ - return ; -} - - -static struct device isa_bus = { - .init_name = "lpc-isa", - .release = platform_isa_bus_release, -}; - -struct isa_dev { - struct device dev; - struct device *next; - unsigned int id; -}; - -#define to_isa_dev(x) container_of((x), struct isa_dev, dev) - -static int isa_bus_match(struct device *dev, struct device_driver *driver) -{ - struct isa_driver *isa_driver = to_isa_driver(driver); - - if (dev->platform_data == isa_driver) { - if (!isa_driver->match || - isa_driver->match(dev, to_isa_dev(dev)->id)) - return 1; - dev->platform_data = NULL; - } - return 0; -} - -static int isa_bus_probe(struct device *dev) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->probe) - return isa_driver->probe(dev, to_isa_dev(dev)->id); - - return 0; -} - -static int isa_bus_remove(struct device *dev) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->remove) - return isa_driver->remove(dev, to_isa_dev(dev)->id); - - return 0; -} - -static void isa_bus_shutdown(struct device *dev) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->shutdown) - isa_driver->shutdown(dev, to_isa_dev(dev)->id); -} - -static int isa_bus_suspend(struct device *dev, pm_message_t state) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->suspend) - return isa_driver->suspend(dev, to_isa_dev(dev)->id, state); - - return 0; -} - -static int isa_bus_resume(struct device *dev) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->resume) - return isa_driver->resume(dev, to_isa_dev(dev)->id); - - return 0; -} - -static struct bus_type isa_bus_type = { - .name = "lpc-isa", - .match = isa_bus_match, - .probe = isa_bus_probe, - .remove = isa_bus_remove, - .shutdown = isa_bus_shutdown, - .suspend = isa_bus_suspend, - .resume = isa_bus_resume -}; - -static void isa_dev_release(struct device *dev) -{ - kfree(to_isa_dev(dev)); -} - -void lpc_unregister_driver(struct isa_driver *isa_driver) -{ - struct device *dev = isa_driver->devices; - - while (dev) { - struct device *tmp = to_isa_dev(dev)->next; - device_unregister(dev); - dev = tmp; - } - driver_unregister(&isa_driver->driver); -} - - -int lpc_register_driver(struct isa_driver *isa_driver, unsigned int ndev) -{ - int error; - unsigned int id; - - isa_driver->driver.bus = &isa_bus_type; - isa_driver->devices = NULL; - - error = driver_register(&isa_driver->driver); - if (error) - return error; - - for (id = 0; id < ndev; id++) { - struct isa_dev *isa_dev; - - isa_dev = kzalloc(sizeof *isa_dev, GFP_KERNEL); - if (!isa_dev) { - error = -ENOMEM; - break; - } - - isa_dev->dev.parent = &isa_bus; - isa_dev->dev.bus = &isa_bus_type; - - dev_set_name(&isa_dev->dev, "%s.%u", - isa_driver->driver.name, id); - isa_dev->dev.platform_data = isa_driver; - isa_dev->dev.release = isa_dev_release; - isa_dev->id = id; - - isa_dev->dev.coherent_dma_mask = DMA_BIT_MASK(24); - isa_dev->dev.dma_mask = &isa_dev->dev.coherent_dma_mask; - - error = device_register(&isa_dev->dev); - if (error) { - put_device(&isa_dev->dev); - break; - } - - if (isa_dev->dev.platform_data) { - isa_dev->next = isa_driver->devices; - isa_driver->devices = &isa_dev->dev; - } else - device_unregister(&isa_dev->dev); - } - - if (!error && !isa_driver->devices) - error = -ENODEV; - - if (error) - isa_unregister_driver(isa_driver); - - return error; -} - - -int lpc_bus_init(void) -{ - int error; - - error = bus_register(&isa_bus_type); - if (!error) { - error = device_register(&isa_bus); - if (error) - bus_unregister(&isa_bus_type); - } - return error; -} - -void lpc_bus_exit(void) -{ - - device_unregister(&isa_bus); - - bus_unregister(&isa_bus_type); -} - - -/********************************************** End ********************************************************/ - - - - - - -/********************************************** Start ********************************************************/ -/* - * module parameters: - */ -static int i2c_debug = 0; -static struct mutex lpc_lock; - - -#define DEB2(x) if (i2c_debug == 2) x -#define DEB3(x) if (i2c_debug == 3) x - /* print several statistical values */ -#define DEBPROTO(x) if (i2c_debug == 9) x; - /* debug the protocol by showing transferred bits */ -#define DEF_TIMEOUT 160 - - - -/* setting states on the bus with the right timing: */ - -#define set_lpc(adap, ctl, val) adap->setlpc(adap->data, ctl, val) -#define get_lpc(adap, ctl) adap->getlpc(adap->data, ctl) -#define get_own(adap) adap->getown(adap->data) -#define get_clock(adap) adap->getclock(adap->data) -#define i2c_outaddr(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DEVICE_ADDR, val) - -#define i2c_outbyte1(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DATA_TX1, val) -#define i2c_outbyte2(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DATA_TX2, val) -#define i2c_outbyte3(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DATA_TX3, val) -#define i2c_outbyte4(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DATA_TX4, val) -#define i2c_inbyte1(adap) adap->getlpc(adap->data, I2C_LPC_REG_DATA_RX1) -#define i2c_inbyte2(adap) adap->getlpc(adap->data, I2C_LPC_REG_DATA_RX2) -#define i2c_inbyte3(adap) adap->getlpc(adap->data, I2C_LPC_REG_DATA_RX3) -#define i2c_inbyte4(adap) adap->getlpc(adap->data, I2C_LPC_REG_DATA_RX4) - - - -#define LPC_FPRINTF_LOG_PATH "/tmp/file.log" -struct file *lpc_fprintf_file = NULL; - -static int lpc_fprintf_debug(const char *fmt, ...) -{ - char lpc_fprintf_buf[256]={0}; - struct va_format vaf; - va_list args; - int r; - mm_segment_t old_fs; - struct timeval tv; - struct rtc_time tm; - - do_gettimeofday(&tv); - - rtc_time_to_tm(tv.tv_sec,&tm); - - va_start(args, fmt); - vaf.fmt = fmt; - vaf.va = &args; - r=snprintf(lpc_fprintf_buf,sizeof(lpc_fprintf_buf),"[%04d.%08d] %pV\n",tm.tm_sec, (int)tv.tv_usec, &vaf); - va_end(args); - old_fs = get_fs(); - set_fs(KERNEL_DS); - vfs_write(lpc_fprintf_file, (char *)&lpc_fprintf_buf, strlen(lpc_fprintf_buf), &lpc_fprintf_file->f_pos); - set_fs(old_fs); - memset(lpc_fprintf_buf,0x0,sizeof(lpc_fprintf_buf)); - return r; - -} - - - -static int lpc_fprintf_init(void) -{ - printk("lpc_fprintf_init.\n"); - - if(lpc_fprintf_file == NULL) - lpc_fprintf_file = filp_open(LPC_FPRINTF_LOG_PATH, O_RDWR | O_APPEND | O_CREAT, 0644); - - if (IS_ERR(lpc_fprintf_file)) { - printk("Error occured while opening file %s, exiting...\n", LPC_FPRINTF_LOG_PATH); - return -1; - } - - return 0; -} - -static int lpc_fprintf_exit(void) -{ - printk("lpc_fprintf_exit.\n"); - - if(lpc_fprintf_file != NULL) - filp_close(lpc_fprintf_file, NULL); - - return 0; -} - - -/* other auxiliary functions */ - - -void print_reg(struct i2c_algo_lpc_data *adap) -{ - unsigned char status; - DEBPROTO(lpc_fprintf_debug("================================================\n");) - status = get_lpc(adap, I2C_LPC_REG_BUS_SEL); - DEBPROTO(lpc_fprintf_debug("%s select reg %x : %x\n",__func__,I2C_LPC_REG_BUS_SEL, status);) - status = get_lpc(adap, I2C_LPC_REG_BYTE_COUNT); - DEBPROTO(lpc_fprintf_debug("%s count reg %x : %x\n",__func__,I2C_LPC_REG_BYTE_COUNT, status);) - - status = get_lpc(adap, I2C_LPC_REG_COMMAND); - DEBPROTO(lpc_fprintf_debug("%s command reg %x : %x\n",__func__,I2C_LPC_REG_COMMAND, status);) - status = get_lpc(adap, I2C_LPC_REG_DEVICE_ADDR); - DEBPROTO(lpc_fprintf_debug("%s address reg %x : %x\n",__func__,I2C_LPC_REG_DEVICE_ADDR, status);) - - status = get_lpc(adap, I2C_LPC_REG_STATUS); - DEBPROTO(lpc_fprintf_debug("%s status reg %x : %x\n",__func__,I2C_LPC_REG_STATUS, status);) -} - - - -static void i2c_repstart(struct i2c_algo_lpc_data *adap) -{ - DEBPROTO(lpc_fprintf_debug("%s :\n",__func__);) - set_lpc(adap, I2C_LPC_REG_COMMAND, I2C_LPC_REPSTART); -} - -static void i2c_stop(struct i2c_algo_lpc_data *adap) -{ - DEBPROTO(lpc_fprintf_debug("%s :\n",__func__);) - set_lpc(adap, I2C_LPC_REG_COMMAND, I2C_LPC_STOP); - udelay(60); - set_lpc(adap, I2C_LPC_REG_COMMAND, 0x00); -} - - - - -static void i2c_start(struct i2c_algo_lpc_data *adap) -{ - print_reg(adap); - - set_lpc(adap, I2C_LPC_REG_COMMAND, I2C_LPC_START); - - print_reg(adap); -} - - - - -static int wait_for_bb(struct i2c_algo_lpc_data *adap) -{ - - int timeout = DEF_TIMEOUT; - int status; - - while (--timeout) { - status = get_lpc(adap, I2C_LPC_REG_STATUS); - - DEBPROTO(lpc_fprintf_debug("%s : Waiting for bus free status : %x\n",__func__,status);) - - if(status == I2C_LPC_TD) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is free status : %x\n",__func__,status);) - break; - } - } - - if (timeout == 0) { - DEBPROTO(lpc_fprintf_debug("%s : Timeout for free busy status : %x\n",__func__,status);) - return -ETIMEDOUT; - } - - - - return 0; -} - - -static int wait_for_be(int mode,struct i2c_algo_lpc_data *adap) -{ - - int timeout = DEF_TIMEOUT; - unsigned char status; - - - while (--timeout) { - - status = get_lpc(adap, I2C_LPC_REG_STATUS); - - DEBPROTO(lpc_fprintf_debug("%s : Waiting for bus empty status : %x\n",__func__,status);) - - if(mode == 1) - { - if((status & I2C_LPC_IBB) && (status & I2C_LPC_TBE)) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is empty status : %x\n",__func__,status);) - break; - } - } - else - { - if(status & I2C_LPC_TD) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is empty status : %x\n",__func__,status);) - break; - } - } - - status = get_lpc(adap, I2C_LPC_REG_TEST); - - DEBPROTO(lpc_fprintf_debug("%s : The test register data : %x\n",__func__,status);) - udelay(1); /* wait for 100 us */ - } - - if (timeout == 0) { - DEBPROTO(lpc_fprintf_debug("%s : Timeout waiting for Bus Empty\n",__func__);) - return -ETIMEDOUT; - } - - return 0; -} - - -static int wait_for_bf(struct i2c_algo_lpc_data *adap) -{ - - int timeout = DEF_TIMEOUT; - int status; - - - while (--timeout) { - status = get_lpc(adap, I2C_LPC_REG_STATUS); - - DEBPROTO(lpc_fprintf_debug("%s : Waiting for bus full status : %x\n",__func__,status);) - - if(status & I2C_LPC_RBF) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is full status : %x\n",__func__,status);) - break; - } - - status = get_lpc(adap, I2C_LPC_REG_TEST); - - DEBPROTO(lpc_fprintf_debug("%s : The test register data : %x\n",__func__,status);) - udelay(1); /* wait for 100 us */ - } - - if (timeout == 0) { - DEBPROTO(lpc_fprintf_debug("%s : Timeout waiting for Bus Full\n",__func__);) - return -ETIMEDOUT; - } - - return 0; -} - -static int wait_for_td(struct i2c_algo_lpc_data *adap) -{ - - int timeout = DEF_TIMEOUT; - int status=0; - - while (--timeout) { - udelay(4); - status = get_lpc(adap, I2C_LPC_REG_STATUS); - - DEBPROTO(lpc_fprintf_debug("%s : Waiting for bus done status : %x\n",__func__,status);) - - if(status == I2C_LPC_TD) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is done status : %x\n",__func__,status);) - break; - } - } - - if (timeout == 0) { - DEBPROTO(lpc_fprintf_debug("%s : Timeout waiting for Bus Done\n",__func__);) - return -ETIMEDOUT; - } - - return 0; -} - - - -static int wait_for_pin(struct i2c_algo_lpc_data *adap, int *status) -{ - int timeout = DEF_TIMEOUT; - *status = get_lpc(adap, I2C_LPC_REG_STATUS); - - while ((*status & I2C_LPC_TBE) && --timeout) { - *status = get_lpc(adap, I2C_LPC_REG_STATUS); - } - - if (timeout == 0) - return -ETIMEDOUT; - - - return 0; -} - - -static int lpc_doAddress(struct i2c_algo_lpc_data *adap,struct i2c_msg *msg) -{ - unsigned short flags = msg->flags; - unsigned char addr; - - addr = msg->addr << 1; - if (flags & I2C_M_RD) - { - addr |= 1; - DEBPROTO(lpc_fprintf_debug("step 7 : read mode then write device address 0x%x\n",addr);) - } - else - { - DEBPROTO(lpc_fprintf_debug("step 2 : write mode then write device address 0x%x\n",addr);) - } - - if (flags & I2C_M_REV_DIR_ADDR) - { - addr ^= 1; - - } - i2c_outaddr(adap, addr); - return 0; - -} - - -static int lpc_sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) -{ - struct i2c_algo_lpc_data *adap = i2c_adap->algo_data; - int i = 0,timeout=0; - - unsigned int count = msg->len; - unsigned char *buf = msg->buf; - - do{ - lpc_doAddress(adap,msg); - set_lpc(adap, I2C_LPC_REG_BYTE_COUNT, (count-i) >= 4 ? 4:(count - i)); - DEBPROTO(lpc_fprintf_debug("step 3 : write register count %x\n",count);) - - if((count -i) >= 4) - { - i2c_outbyte1(adap, buf[i+0] & 0xff); - i2c_outbyte2(adap, buf[i+1] & 0xff); - i2c_outbyte3(adap, buf[i+2] & 0xff); - i2c_outbyte4(adap, buf[i+3] & 0xff); - - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+1,buf[i+1]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+2,buf[i+2]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+3,buf[i+3]);) - i += 4; - } - else if((count -i) == 3) - { - i2c_outbyte1(adap, buf[i+0] & 0xff); - i2c_outbyte2(adap, buf[i+1] & 0xff); - i2c_outbyte3(adap, buf[i+2] & 0xff); - - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+1,buf[i+1]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+2,buf[i+2]);) - - i += 3; - } - else if((count -i) == 2) - { - i2c_outbyte1(adap, buf[i+0] & 0xff); - i2c_outbyte2(adap, buf[i+1] & 0xff); - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+1,buf[i+1]);) - i += 2; - } - else if((count -i) == 1) - { - i2c_outbyte1(adap, buf[i+0] & 0xff); - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+0,buf[i+0]);) - i += 1; - } - - /* Send START */ - DEBPROTO(lpc_fprintf_debug("step 5-1 : Delay 6mS \n");) - udelay(6000); - DEBPROTO(lpc_fprintf_debug("step 5-2 : Start to transfrom \n");) - i2c_stop(adap); - i2c_start(adap); - DEBPROTO(lpc_fprintf_debug("step 5-3 : Start done\n");) - - udelay(400); - DEBPROTO(lpc_fprintf_debug("step 6 : Waiting for BE\n");) - timeout = wait_for_td(adap); - if (timeout) { - DEBPROTO(lpc_fprintf_debug("step 6 : Timeout waiting for BE \n");) - return -EREMOTEIO; - } - }while (i < count); - - if(i == count) - { - DEBPROTO(lpc_fprintf_debug("Writen %d bytes successd !\n",count);) - return i; - } - else - { - DEBPROTO(lpc_fprintf_debug("Writen %d bytes failed \n",count);) - return -EIO; - } -} - -static int lpc_readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) -{ - int i=0,timeout=0; - struct i2c_algo_lpc_data *adap = i2c_adap->algo_data; - - unsigned int count = msg->len; - unsigned char *buf = msg->buf; - - do{ - lpc_doAddress(adap,msg); - set_lpc(adap, I2C_LPC_REG_BYTE_COUNT, (count-i) >= 4 ? 4:(count - i)); - DEBPROTO(lpc_fprintf_debug("step 8 : write register count %d\n",count);) - - /* Send START */ - DEBPROTO(lpc_fprintf_debug("step 9-1 : Delay 6mS\n");) - udelay(6000); - DEBPROTO(lpc_fprintf_debug("step 9-2 : Start to receive data\n");) - i2c_stop(adap); - i2c_start(adap); - DEBPROTO(lpc_fprintf_debug("step 9-3 : Start done\n");) - - udelay(400); - DEBPROTO(lpc_fprintf_debug("step 10 : Waiting for TD\n");) - timeout = wait_for_td(adap); - if (timeout) { - DEBPROTO(lpc_fprintf_debug("step 10 : Timeout waiting for TD \n");) - return -EREMOTEIO; - } - - if((count -i) >= 4) - { - buf[i+0] = 0xff & i2c_inbyte1(adap); - buf[i+1] = 0xff & i2c_inbyte2(adap); - buf[i+2] = 0xff & i2c_inbyte3(adap); - buf[i+3] = 0xff & i2c_inbyte4(adap); - - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+1,buf[i+1]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+2,buf[i+2]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+3,buf[i+3]);) - - i += 4; - } - else if((count -i) == 3) - { - buf[i+0] = 0xff & i2c_inbyte1(adap); - buf[i+1] = 0xff & i2c_inbyte2(adap); - buf[i+2] = 0xff & i2c_inbyte3(adap); - - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+1,buf[i+1]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+2,buf[i+2]);) - - i += 3; - } - else if((count -i) == 2) - { - buf[i+0] = 0xff & i2c_inbyte1(adap); - buf[i+1] = 0xff & i2c_inbyte2(adap); - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+1,buf[i+1]);) - i += 2; - } - else if((count -i) == 1) - { - buf[i+0] = 0xff & i2c_inbyte1(adap); - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+0,buf[i+0]);) - i += 1; - } - - - }while(i < count); - - if(i == count) - { - DEBPROTO(lpc_fprintf_debug("Read %d bytes successd !\n",count);) - return i; - } - else - { - DEBPROTO(lpc_fprintf_debug("Read %d bytes failed \n",count);) - return -EIO; - } -} - - -struct cpld_client_node { - struct i2c_client *client; - struct list_head list; -}; -#define LPC_I2C_MAX_NCHANS 6 - - -struct lpc_iic { - struct i2c_adapter *virt_adaps[LPC_I2C_MAX_NCHANS]; - u8 last_chan; /* last register value */ -}; - - -static int lpc_master_xfer(struct i2c_adapter *i2c_adap, - struct i2c_msg *msgs, - int num) -{ - struct i2c_algo_lpc_data *adap = i2c_adap->algo_data; - struct i2c_msg *pmsg; - int i; - int ret=0; - - mutex_lock(&lpc_lock); - - if (adap->xfer_begin) - adap->xfer_begin(&i2c_adap->nr); - - - for (i = 0;ret >= 0 && i < num; i++) { - pmsg = &msgs[i]; - - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n", - pmsg->flags & I2C_M_RD ? "read" : "write", - pmsg->len, pmsg->addr, i + 1, num);) - - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n", - i, msgs[i].addr, msgs[i].flags, msgs[i].len);) - - if (pmsg->flags & I2C_M_RD) { - ret = lpc_readbytes(i2c_adap, pmsg); - - if (ret != pmsg->len) { - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: fail: " - "only read %d bytes.\n",ret)); - } else { - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: read %d bytes.\n",ret)); - } - } else { - - ret = lpc_sendbytes(i2c_adap, pmsg); - - if (ret != pmsg->len) { - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: fail: " - "only wrote %d bytes.\n",ret)); - } else { - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: wrote %d bytes.\n",ret)); - } - } - } - - if (adap->xfer_end) - adap->xfer_end(&i2c_adap->nr); - - mutex_unlock(&lpc_lock); - - DEBPROTO(lpc_fprintf_debug("ret = 0x%x num = 0x%x i = 0x%x.\n",ret,num,i)); - - return ret = (ret < 0) ? ret : num; -} - - -static u32 lpc_func(struct i2c_adapter *adap) -{ - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_QUICK; -} - -/* exported algorithm data: */ -static const struct i2c_algorithm lpc_algo = { - .master_xfer = lpc_master_xfer, - //.smbus_xfer = lpc_smbus_xfer, - .functionality = lpc_func, -}; - - -/********************************************** End ********************************************************/ - - - - - - -/********************************************** Start ********************************************************/ -#define DEFAULT_BASE 0x0a00 - -static int lpc_base= 0x0a00; -static u8 __iomem *lpc_base_iomem; - -static int lpc_irq; -static int lpc_clock = 0x1c; -static int lpc_own = 0x55; -static int lpc_mmapped; - -static unsigned long lpc_base_addr = 0x0a00; -static unsigned int lpc_io_space_size = 2; - -static unsigned long LPC_INDEX_REG; -static unsigned long LPC_DATA_REG; - - -/* notice : removed static struct i2c_lpc_iic gpi; code - - this module in real supports only one device, due to missing arguments - in some functions, called from the algo-lpc module. Sometimes it's - need to be rewriten - but for now just remove this for simpler reading */ - -static wait_queue_head_t lpc_wait; -static int lpc_pending; -static spinlock_t lock; -static spinlock_t lpc_slock; - -static struct i2c_adapter lpc_iic_ops; - -struct cpld_dev_type { - struct resource *io_resource; - struct semaphore sem; - struct cdev cdev; -}; - -struct cpld_dev_type *cpld_device; - - -/* ----- local functions ---------------------------------------------- */ - -static void lpc_cpld_setbyte(void *data, int ctl, int val) -{ - outb(ctl, LPC_INDEX_REG); - mb(); - - outb(val, LPC_DATA_REG); - mb(); -} - -static int lpc_cpld_getbyte(void *data, int ctl) -{ - u8 val = 0; - - outb(ctl, LPC_INDEX_REG); - mb(); - - val = inb(LPC_DATA_REG); - mb(); - - return val; -} - -static void lpc_iic_setbyte(void *data, int ctl, int val) -{ - if (!cpld_device) - { - return ; - } - - if (down_interruptible(&cpld_device->sem)) - { - return ; - } - - - lpc_cpld_setbyte(data,ctl,val); - - up(&cpld_device->sem); - DEBPROTO(lpc_fprintf_debug("%s REG[%x] = %x\n",__func__,ctl,val);) -} - - -static int lpc_iic_getbyte(void *data, int ctl) -{ - u8 val = 0; - if (!cpld_device) - return -ENOTTY; - - if (down_interruptible(&cpld_device->sem)) - return -ERESTARTSYS; - - val = lpc_cpld_getbyte(data,ctl); - - up(&cpld_device->sem); - DEBPROTO(lpc_fprintf_debug("%s REG[%x] = %x\n",__func__,ctl,val);) - return val; -} - -int cig_cpld_read_register(u8 reg_off, u8 *val) -{ - if (!cpld_device) - return -ENOTTY; - - if (down_interruptible(&cpld_device->sem)) - return -ERESTARTSYS; - - *val = lpc_cpld_getbyte(cpld_device, reg_off); - - up(&cpld_device->sem); - - return 0; -} -EXPORT_SYMBOL(cig_cpld_read_register); - -int cig_cpld_write_register(u8 reg_off, u8 val) -{ - if (!cpld_device) - return -ENOTTY; - - if (down_interruptible(&cpld_device->sem)) - return -ERESTARTSYS; - - lpc_cpld_setbyte(cpld_device, reg_off, val); - up(&cpld_device->sem); - return 0; -} -EXPORT_SYMBOL(cig_cpld_write_register); - - - -static int lpc_iic_getown(void *data) -{ - return (lpc_own); -} - - -static int lpc_iic_getclock(void *data) -{ - return (lpc_clock); -} - -static void lpc_iic_waitforpin(void *data) -{ - DEFINE_WAIT(wait); - int timeout = 2; - unsigned long flags; - - if (lpc_irq > 0) { - spin_lock_irqsave(&lock, flags); - if (lpc_pending == 0) { - spin_unlock_irqrestore(&lock, flags); - prepare_to_wait(&lpc_wait, &wait, TASK_INTERRUPTIBLE); - if (schedule_timeout(timeout*HZ)) { - spin_lock_irqsave(&lock, flags); - if (lpc_pending == 1) { - lpc_pending = 0; - } - spin_unlock_irqrestore(&lock, flags); - } - finish_wait(&lpc_wait, &wait); - } else { - lpc_pending = 0; - spin_unlock_irqrestore(&lock, flags); - } - } else { - udelay(100); - } -} - - -static irqreturn_t lpc_iic_handler(int this_irq, void *dev_id) { - spin_lock(&lock); - lpc_pending = 1; - spin_unlock(&lock); - wake_up_interruptible(&lpc_wait); - return IRQ_HANDLED; -} - -static int board_id = 0; - - -static int lpc_iic_select(void *data) -{ - unsigned int chan_id=0; - chan_id = *(unsigned int *)data; - chan_id -= 2; - DEBPROTO(lpc_fprintf_debug("step 1 : selest channel id = %d\n",chan_id);) - lpc_iic_setbyte(data,I2C_LPC_REG_BUS_SEL,chan_id); - - return 0; -} - -static int lpc_iic_deselect(void *data) -{ - - unsigned int chan_id=0; - chan_id = *(unsigned int *)data; - chan_id -= 2; - DEBPROTO(lpc_fprintf_debug("step last :deselect channel id = %d\n",chan_id);) - - return 0; -} - - -/* ------------------------------------------------------------------------ - * Encapsulate the above functions in the correct operations structure. - * This is only done when more than one hardware adapter is supported. - */ -static struct i2c_algo_lpc_data lpc_iic_data = { - .setlpc = lpc_iic_setbyte, - .getlpc = lpc_iic_getbyte, - .getown = lpc_iic_getown, - .getclock = lpc_iic_getclock, - .waitforpin = lpc_iic_waitforpin, - .xfer_begin = lpc_iic_select, - .xfer_end = lpc_iic_deselect, -}; - -#include - -static struct i2c_adapter lpc_iic_arr_ops[LPC_I2C_MAX_NCHANS] = {0}; - -static void dummy_setscl(void *data, int state) -{ - return; -} - -static void dummy_setsda(void *data, int state) -{ - return; - -} - -static int dummy_getscl(void *data) -{ - return 1; - -} - -static int dummy_getsda(void *data) -{ - return 1; -} - - -static struct i2c_algo_bit_data dummy_algo_data = { - .setsda = dummy_setsda, - .setscl = dummy_setscl, - .getsda = dummy_getsda, - .getscl = dummy_getscl, - .udelay = 50, - .timeout = HZ, -}; - - -static int dummy_xfer(struct i2c_adapter *i2c_adap, - struct i2c_msg *msgs, - int num) -{ - return 1; -} - -static u32 dummy_func(struct i2c_adapter *adap) -{ - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_QUICK; -} - - -static const struct i2c_algorithm dummy_algo = { - .master_xfer = dummy_xfer, - .functionality = dummy_func, -}; - - - -static struct i2c_adapter i2c_dummy = { - .owner = THIS_MODULE, - .class = I2C_CLASS_HWMON, - .algo_data = &dummy_algo_data, - .algo = &dummy_algo, - .name = "i2c_dummy", -}; - - -static int lpc_iic_match(struct device *dev, unsigned int id) -{ - /* sanity checks for lpc_mmapped I/O */ - - DEB2(printk("lpc_iic_match\n");) - - - if (lpc_base < DEFAULT_BASE) { - dev_err(dev, "incorrect lpc_base address (%#x) specified " - "for lpc_mmapped I/O\n", lpc_base); - return 0; - } - - if (lpc_base == 0) { - lpc_base = DEFAULT_BASE; - } - return 1; -} - -static int lpc_iic_probe(struct device *dev, unsigned int id) -{ - int rval,num; - - lpc_fprintf_init(); - - DEB2(printk("lpc_iic_probe\n");) - - mutex_init(&lpc_lock); - - for(num = 0; num < LPC_I2C_MAX_NCHANS;num++) - { - lpc_iic_arr_ops[num].dev.parent = dev; - lpc_iic_arr_ops[num].owner = THIS_MODULE; - lpc_iic_arr_ops[num].class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - lpc_iic_arr_ops[num].algo = &lpc_algo; - lpc_iic_arr_ops[num].algo_data = &lpc_iic_data, - lpc_iic_arr_ops[num].nr=num; - snprintf(lpc_iic_arr_ops[num].name, sizeof(lpc_iic_arr_ops[num].name), "i2c-%d-lpc", i2c_adapter_id(&lpc_iic_arr_ops[num])); - rval |= i2c_add_adapter(&lpc_iic_arr_ops[num]); - DEB2(printk("%s\n",lpc_iic_arr_ops[num].name);) - } - - return 0; -} - -static int lpc_iic_remove(struct device *dev, unsigned int id) -{ - int num; - DEB2(printk("lpc_iic_remove\n")); - - lpc_fprintf_exit(); - for(num = LPC_I2C_MAX_NCHANS - 1; num >= 0 ;num--) - i2c_del_adapter(&lpc_iic_arr_ops[num]); - - - return 0; -} - -static struct isa_driver i2c_lpc_driver = { - .match = lpc_iic_match, - .probe = lpc_iic_probe, - .remove = lpc_iic_remove, - .driver = { - .owner = THIS_MODULE, - .name = "lpc-iic", - }, -}; - -/********************************************** End ********************************************************/ - - - - - - -/********************************************** Start ********************************************************/ - -static int cpld_major = 0; -static int cpld_minor = 0; - -struct cpld_rw_msg { - unsigned char addr; - unsigned char data; -}; - - -static struct cpld_rw_msg param_read = {-1}; -static struct cpld_rw_msg param_write = {-1}; -static struct cpld_rw_msg param_reads = {-1}; -static struct cpld_rw_msg param_writes = {-1}; - -void cpld_sysfs_kobj_release(struct kobject *kobj) -{ - return; -} - -int cpld_sysfs_add_attr(struct kobject* kobj, char* attr_name) -{ - - struct attribute *attr; - - attr = kmalloc(sizeof(struct attribute), GFP_KERNEL); - attr->name = attr_name; - attr->mode = 0644; - - return sysfs_create_file(kobj, attr); -} - -static int cig_cpld_write_slave_cpld_register(u8 reg_addr, u8 reg_data); -static int cig_cpld_read_slave_cpld_register(u8 reg_addr, u8 *reg_data); - - -static ssize_t cpld_sysfs_show(struct kobject *kobj, struct attribute *attr, char *buffer) -{ - u8 val=0,ret=0,year=0,month=0,day=0,cpld_m=0,cpld_1=0,cpld_2=0; - - if (0 == strcmp(attr->name, "read")) - { - val = lpc_iic_getbyte(NULL,param_read.addr); - ret = sprintf(buffer,"read : addr = 0x%x val = 0x%x\n",param_read.addr, val); - - } - else if (0 == strcmp(attr->name, "write")) - { - lpc_iic_setbyte(NULL, param_write.addr,param_write.data); - ret = sprintf(buffer,"write : addr = 0x%x val = 0x%x\n",param_write.addr, param_write.data); - } - else if (0 == strcmp(attr->name, "version")) - { - cpld_m = lpc_iic_getbyte(NULL, 0x02); - year = lpc_iic_getbyte(NULL, 0x03); - month = lpc_iic_getbyte(NULL, 0x04); - day = lpc_iic_getbyte(NULL, 0x05); - - cig_cpld_read_slave_cpld_register(0x1d,&cpld_1); - cig_cpld_read_slave_cpld_register(0x1e,&cpld_2); - - ret = sprintf(buffer,"Main CPLD version : V%02x\n"\ - "Main CPLD date : 20%02x-%02x-%02x\n"\ - "Slave 1 CPLD version : V%02x\n"\ - "Slave 2 CPLD version : V%02x\n",cpld_m,year,month,day,cpld_1,cpld_2); - } - if (0 == strcmp(attr->name, "reads")) - { - ret = cig_cpld_read_slave_cpld_register(param_reads.addr,&val); - if (ret < 0) - printk("ERROR:Failed to read slave cpld.\n"); - ret = sprintf(buffer,"reads : addr = 0x%x val = 0x%x\n",param_reads.addr, val); - - } - else if (0 == strcmp(attr->name, "writes")) - { - ret = cig_cpld_write_slave_cpld_register(param_writes.addr,param_writes.data); - if (ret < 0) - printk("ERROR:Failed to read slave cpld.\n"); - ret = sprintf(buffer,"writes : addr = 0x%x val = 0x%x\n",param_writes.addr, param_writes.data); - } - - - return ret; - -} - -static ssize_t cpld_sysfs_store(struct kobject *kobj, struct attribute *attr, const char *buffer, size_t count) -{ - int param[3]; - - if (0 == strcmp(attr->name, "read")) - { - sscanf(buffer, "0x%02x", ¶m[0]); - param_read.addr = param[0]; - } - else if (0 == strcmp(attr->name, "write")) - { - sscanf(buffer, "0x%2x 0x%02x", ¶m[0], ¶m[1]); - param_write.addr = param[0]; - param_write.data = param[1]; - } - if (0 == strcmp(attr->name, "reads")) - { - sscanf(buffer, "0x%02x", ¶m[0]); - param_reads.addr = param[0]; - } - else if (0 == strcmp(attr->name, "writes")) - { - sscanf(buffer, "0x%2x 0x%02x", ¶m[0], ¶m[1]); - param_writes.addr = param[0]; - param_writes.data = param[1]; - } - return count; -} - - - -static struct sysfs_ops cpld_sysfs_ops = -{ - .show = cpld_sysfs_show, - .store = cpld_sysfs_store, -}; - -static struct kobj_type cpld_kobj_type = -{ - .release = cpld_sysfs_kobj_release, - .sysfs_ops = &cpld_sysfs_ops, - .default_attrs = NULL, -}; - - -static const char driver_name[] = "cpld_drv"; -static atomic_t cpld_available = ATOMIC_INIT(1); -static struct class *cpld_class; -static struct device *cpld_dev; - - - -#define CPLD_IOC_MAGIC '[' - -#define CPLD_IOC_RDREG _IOR(CPLD_IOC_MAGIC, 0, struct cpld_rw_msg) -#define CPLD_IOC_WRREG _IOW(CPLD_IOC_MAGIC, 1, struct cpld_rw_msg) - -#define CPLD_IOC_MAXNR 2 - - -int cpld_open(struct inode *inode, struct file *filp) -{ - struct cpld_dev_type *dev; - - if (! atomic_dec_and_test(&cpld_available)) { - atomic_inc(&cpld_available); - return -EBUSY; - } - - dev = container_of(inode->i_cdev, struct cpld_dev_type, cdev); - filp->private_data = dev; - - return 0; -} - -int cpld_release(struct inode *inode, struct file *flip) -{ - atomic_inc(&cpld_available); - return 0; -} - - -long cpld_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - int rc = 0; - int err = 0; - struct cpld_dev_type *dev = (struct cpld_dev_type *)filp->private_data; - struct cpld_rw_msg msg; - - if (_IOC_TYPE(cmd) != CPLD_IOC_MAGIC) - return -ENOTTY; - if (_IOC_NR(cmd) > CPLD_IOC_MAXNR) - return -ENOTTY; - - if (_IOC_DIR(cmd) & _IOC_READ) - err = !access_ok(VERIFY_WRITE, (void __user *)arg, _IOC_SIZE(cmd)); - if (_IOC_DIR(cmd) & _IOC_WRITE) - err = !access_ok(VERIFY_READ, (void __user *)arg, _IOC_SIZE(cmd)); - if (err) - return -EFAULT; - - if (down_interruptible(&dev->sem)) - return -ERESTARTSYS; - - switch(cmd){ - case CPLD_IOC_RDREG: - rc = copy_from_user(&msg, (void __user *)arg, sizeof(msg)); - if (!rc) { - msg.data = lpc_cpld_getbyte(dev, msg.addr); - rc = copy_to_user((void __user *)arg, &msg, sizeof(msg)); - } - break; - - case CPLD_IOC_WRREG: - rc = copy_from_user(&msg, (void __user *)arg, sizeof(msg)); - if (!rc) { - lpc_cpld_setbyte(dev, msg.addr, msg.data); - } - break; - default: - rc = -ENOTTY; - break; - } - up(&dev->sem); - - return rc; -} - -struct file_operations cpld_fops = { - .owner = THIS_MODULE, - .open = cpld_open, - .unlocked_ioctl = cpld_ioctl, - .release = cpld_release, -}; - - -static void cpld_setup_cdev(struct cpld_dev_type *dev) -{ - int err, devno = MKDEV(cpld_major, cpld_minor); - - cdev_init(&dev->cdev, &cpld_fops); - dev->cdev.owner = THIS_MODULE; - dev->cdev.ops = &cpld_fops; - err = cdev_add(&dev->cdev, devno, 1); - - if (err) - DEB2(printk(KERN_NOTICE "Error %d adding cpld", err);) -} -/********************************************** End ********************************************************/ - - - - -/********************************************** Start ********************************************************/ -#include -#include -#include - -static spinlock_t irq_inter_lock; -static struct delayed_work irq_inter_work; -static unsigned long irq_inter_delay; - - -static int cig_cpld_write_slave_cpld_register(u8 reg_addr, u8 reg_data) -{ - u8 read_status = 0; - u8 wait_time_out = WAIT_TIME_OUT_COUNT; - DEB2(printk("<=======write=========>")); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_ADDR, reg_addr << 1); - DEB2(printk("[62]=%x\n",reg_addr << 1)); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_TX, reg_data); - DEB2(printk("[63]=%x\n",reg_data)); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_COMMAND, 0x80); - DEB2(printk("[65]=%x\n",0x80)); - do{ - cig_cpld_read_register(ADDR_REG_SFP_STATUS_STATUS, &read_status); - DEB2(printk("[66]=%x\n",read_status)); - udelay(60); - wait_time_out--; - if(wait_time_out == 0) - break; - }while(read_status != 0x02); - DEB2(printk("<=======write=========>")); - - - if(wait_time_out == 0) - return -1; - - return 1; -} - - -static int cig_cpld_read_slave_cpld_register(u8 reg_addr, u8 *reg_data) -{ - u8 read_status = 0; - u8 wait_time_out = WAIT_TIME_OUT_COUNT; - DEB2(printk("<========read=========>")); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_ADDR, reg_addr << 1 | 1); - DEB2(printk("[62]=%x\n",reg_addr << 1 | 1)); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_COMMAND, 0x80); - DEB2(printk("[65]=%x\n",0x80)); - do{ - udelay(60); - cig_cpld_read_register(ADDR_REG_SFP_STATUS_STATUS, &read_status); - DEB2(printk("[66]=%x\n",read_status)); - wait_time_out--; - if(wait_time_out == 0) - break; - }while(read_status != 0x01); - - cig_cpld_read_register(ADDR_REG_SFP_STATUS_RX,reg_data); - DEB2(printk("[64]=%x\n",*reg_data)); - DEB2(printk("<========read=========>")); - - if(wait_time_out == 0) - return -1; - - return 1; -} - - - -struct sock *nlsk = NULL; -extern struct net init_net; -#define NETLINK_TEST 26 -#define MSG_LEN 125 -#define USER_PORT 100 -static u32 irq_present_status_low_current,irq_present_status_low_next; -static u32 irq_present_status_high_current,irq_present_status_high_next; -static u32 irq_tx_fault_status_low_current,irq_tx_fault_status_low_next; -static u32 irq_tx_fault_status_high_current,irq_tx_fault_status_high_next; -static u32 irq_rx_lost_status_low_current,irq_rx_lost_status_low_next; -static u32 irq_rx_lost_status_high_current,irq_rx_lost_status_high_next; - -static u8 irq_present_qsfp_current,irq_present_qsfp_next; -static u8 irq_interrupt_qsfp_current,irq_interrupt_qsfp_next; - -struct input_dev *cpld_input_dev; - - - -int send_usrmsg(char *pbuf, uint16_t len) -{ - struct sk_buff *nl_skb; - struct nlmsghdr *nlh; - - int ret; - - - nl_skb = nlmsg_new(len, GFP_ATOMIC); - if(!nl_skb) - { - printk("netlink alloc failure\n"); - return -1; - } - - - nlh = nlmsg_put(nl_skb, 0, 0, NETLINK_TEST, len, 0); - if(nlh == NULL) - { - printk("nlmsg_put failaure \n"); - nlmsg_free(nl_skb); - return -1; - } - - memcpy(nlmsg_data(nlh), pbuf, len); - ret = netlink_unicast(nlsk, nl_skb, USER_PORT, MSG_DONTWAIT); - - return ret; -} - -static void netlink_rcv_msg(struct sk_buff *skb) -{ - - struct nlmsghdr *nlh = NULL; - char *umsg = NULL; - char kmsg[1024] = {0}; - char kmsg_tmp[16] = {0}; - u8 i = 0; - u8 tmp[3]={0}; - - if(skb->len >= nlmsg_total_size(0)) - { - nlh = nlmsg_hdr(skb); - umsg = NLMSG_DATA(nlh); - if(umsg) - { - for(i = 0;i < 24;i++) - { - if(!(irq_present_status_low_current & (0x1 << i))) - { - tmp[0] = 1; - } - else - { - tmp[0] = 0; - } - - if(!(irq_rx_lost_status_low_current & (0x1 << i))) - { - tmp[1] = 1; - } - else - { - tmp[1] = 0; - } - - if(!(irq_tx_fault_status_low_current & (0x1 << i))) - { - tmp[2] = 1; - } - else - { - tmp[2] = 0; - } - memset(kmsg_tmp,0xff,sizeof(kmsg_tmp)); - sprintf(kmsg_tmp,"sfp%02d:%1d:%1d:%1d ",i+1,tmp[0],tmp[1],tmp[2]); - strcat(kmsg,kmsg_tmp); - } - - for(i = 0;i < 24;i++) - { - if(!(irq_present_status_high_current & (0x1 << i))) - { - tmp[0] = 1; - } - else - { - tmp[0] = 0; - } - - if(!(irq_rx_lost_status_high_current & (0x1 << i))) - { - tmp[1] = 1; - } - else - { - tmp[1] = 0; - } - - if(!(irq_tx_fault_status_high_current & (0x1 << i))) - { - tmp[2] = 1; - } - else - { - tmp[2] = 0; - } - memset(kmsg_tmp,0xff,sizeof(kmsg_tmp)); - sprintf(kmsg_tmp,"sfp%02d:%1d:%1d:%1d ",i+25,tmp[0],tmp[1],tmp[2]); - strcat(kmsg,kmsg_tmp); - } - - - for(i = 0;i < 8;i++) - { - if(!(irq_present_qsfp_current & (0x1 << i))) - { - tmp[0] = 1; - } - else - { - tmp[0] = 0; - } - - if(!(irq_interrupt_qsfp_current & (0x1 << i))) - { - tmp[1] = 1; - } - else - { - tmp[1] = 0; - } - - memset(kmsg_tmp,0xff,sizeof(kmsg_tmp)); - sprintf(kmsg_tmp,"qsfp%02d:%1d:%1d:%1d ",i+49,tmp[0],tmp[1],0); - strcat(kmsg,kmsg_tmp); - } - - printk("kernel recv from user: %s\n", umsg); - send_usrmsg(kmsg, strlen(kmsg)); - } - } - - return ; -} - - - -struct netlink_kernel_cfg cfg = { - .input = netlink_rcv_msg, /* set recv callback */ -}; - - - -#define RANGE_OF_BYTE_SHIFT(to_arg,shift,from_arg) {to_arg &= ~(0xff << shift); to_arg |= from_arg << shift;} - - -static void irq_inter_wapper(struct work_struct * work) -{ - - u8 m_data = 0; - u8 data_high8 = 0,data_low8 = 0; - u16 data_16 = 0; - u8 status = 0; - u8 i = 0; - char kmsg[64]={0}; - u8 tmp[3] = {0}; - - DEB2(printk("CPLD_MASTER_INTERRUPT\r\n")); - - m_data = lpc_iic_getbyte(NULL,CPLD_MASTER_INTERRUPT_STATUS_REG); - lpc_iic_setbyte(NULL,CPLD_MASTER_INTERRUPT_STATUS_REG,0xff); - - cig_cpld_write_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_MASK_REG,0xff); - cig_cpld_write_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_MASK_REG,0xff); - if(!(m_data & CPLD_MASTER_INTERRUPT_CPLD1)) - { - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_STATUS_H_REG,&data_high8); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_STATUS_L_REG,&data_low8); - data_16 = data_low8 | data_high8 << 8; - if( - !(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT08) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT16) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT24) - ) - { - if(!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT08)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT08\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_PRESENT08_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_low_current,0,status); - - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT16)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT16\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_PRESENT16_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_low_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT24)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT24\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_PRESENT24_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_low_current,16,status); - } - DEB2(printk("irq_present_status_low_next = %08x irq_present_status_low_current = %08x \n",irq_present_status_low_next,irq_present_status_low_current)); - } - - if( - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST08) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST16) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST24) - ) - { - if(!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST08)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_RX_LOST08\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_RX_LOST08_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_low_current,0,status); - - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST16)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT16\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_RX_LOST16_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_low_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST24)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT24\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_RX_LOST24_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_low_current,16,status); - } - DEB2(printk("irq_rx_lost_status_low_next = %08x irq_rx_lost_status_low_current = %08x \n",irq_rx_lost_status_low_next,irq_rx_lost_status_low_current)); - } - - if( - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST08) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST16) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST24) - ) - { - if(!(data_16 & CPLD_SLAVE1_INTERRUPT_TX_FAULT08)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_TX_FAULT08\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_TX_FAULT08_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_low_current,0,status); - - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_TX_FAULT16)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_TX_FAULT16\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_TX_FAULT16_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_low_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_TX_FAULT24)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_TX_FAULT24\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_TX_FAULT24_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_low_current,16,status); - } - DEB2(printk("irq_tx_fault_status_low_next = %08x irq_tx_fault_status_low_current = %08x \n",irq_tx_fault_status_low_next,irq_tx_fault_status_low_current)); - - } - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_CPLD2)) - { - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_STATUS_H_REG,&data_high8); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_STATUS_L_REG,&data_low8); - data_16 = data_low8 | data_high8 << 8; - if( - !(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT32) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT40) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT48) - ) - { - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT32)) - { - DEB2(printk("CPLD_SLAVE2_PRESENT32_REG\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT32_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_high_current,0,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT40)) - { - DEB2(printk("CPLD_SLAVE2_PRESENT40_REG\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT40_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_high_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT48)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT48\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT48_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_high_current,16,status); - } - } - - if( - !(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST32) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST40) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST48) - ) - { - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST32)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_RX_LOST32\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_RX_LOST32_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_high_current,0,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST40)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT40\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_RX_LOST40_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_high_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST48)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT48\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_RX_LOST48_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_high_current,16,status); - } - - } - - if( - !(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT32) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT40) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT48) - ) - { - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT32)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_RX_LOST32\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_TX_FAULT32_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_high_current,0,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT40)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT40\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_TX_FAULT40_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_high_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT48)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT48\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_TX_FAULT48_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_high_current,16,status); - } - } - - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT56)) - { - DEB2(printk("CPLD_SLAVE2_PRESENT56_REG\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT56_REG,&status); - irq_present_qsfp_current = status; - } - - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_QSFP_CR56)) - { - DEB2(printk("CPLD_SLAVE2_QSFP_CR56_REG\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_QSFP_CR56_REG,&status); - irq_interrupt_qsfp_current = status; - } - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_LSW)) - { - DEB2(printk("CPLD_MASTER_INTERRUPT_LSW\r\n")); - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_PSU1)) - { - DEB2(printk("CPLD_MASTER_INTERRUPT_PSU1\r\n")); - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_PSU2)) - { - DEB2(printk("CPLD_MASTER_INTERRUPT_PSU2\r\n")); - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_6320)) - { - DEB2(printk("CPLD_MASTER_INTERRUPT_6320\r\n")); - } - cig_cpld_write_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_MASK_REG,0x0); - cig_cpld_write_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_MASK_REG,0x0); - - memset(tmp,0xff,sizeof(tmp)); - - for(i = 0;i < 24;i++) - { - if(!(irq_present_status_low_current & (0x1 << i)) && (irq_present_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d is present\r\n",i+1)); - tmp[0] = 1; - } - else if((irq_present_status_low_current & (0x1 << i)) && !(irq_present_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d is absent\r\n",i+1)); - tmp[0] = 0; - } - - if(!(irq_tx_fault_status_low_current & (0x1 << i)) && (irq_tx_fault_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d transmission is right\r\n",i+1)); - tmp[1] = 1; - } - else if((irq_tx_fault_status_low_current & (0x1 << i)) && !(irq_tx_fault_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d transmission is fault\r\n",i+1)); - tmp[1] = 0; - } - - if(!(irq_rx_lost_status_low_current & (0x1 << i)) && (irq_rx_lost_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d optical is meet\r\n",i+1)); - tmp[2] = 1; - } - else if((irq_rx_lost_status_low_current & (0x1 << i)) && !(irq_rx_lost_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d optical is lost\r\n",i+1)); - tmp[2] = 0; - } - - if((tmp[0] != 0xff) || (tmp[1] != 0xff) || (tmp[2] != 0xff)) - { - memset(kmsg,0xff,sizeof(kmsg)); - snprintf(kmsg,sizeof(kmsg),"sfp%02d:%1d:%1d:%1d ",i+1,(tmp[0] == 0xff) ? 0:tmp[0],(tmp[1] == 0xff) ? 0:tmp[1],(tmp[2] == 0xff) ? 0:tmp[2]); - break; - } - } - - memset(tmp,0xff,sizeof(tmp)); - for(i = 0;i < 24;i++) - { - if(!(irq_present_status_high_current & (0x1 << i)) && (irq_present_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d is present\r\n",i+25)); - tmp[0] = 1; - } - else if((irq_present_status_high_current & (0x1 << i)) && !(irq_present_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d is absent\r\n",i+25)); - tmp[0] = 0; - - } - - if(!(irq_rx_lost_status_high_current & (0x1 << i)) && (irq_rx_lost_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d optical is meet\r\n",i+25)); - tmp[1] = 1; - } - else if((irq_rx_lost_status_high_current & (0x1 << i)) && !(irq_rx_lost_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d optical is lost\r\n",i+25)); - tmp[1] = 0; - } - - if(!(irq_tx_fault_status_high_current & (0x1 << i)) && (irq_tx_fault_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d transmission is right\r\n",i+25)); - tmp[2] = 1; - } - else if((irq_tx_fault_status_high_current & (0x1 << i)) && !(irq_tx_fault_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d transmission is fault\r\n",i+25)); - tmp[2] = 0; - } - - if((tmp[0] != 0xff) || (tmp[1] != 0xff) || (tmp[2] != 0xff)) - { - memset(kmsg,0xff,sizeof(kmsg)); - snprintf(kmsg,sizeof(kmsg),"sfp%02d:%1d:%1d:%1d ",i+25,(tmp[0] == 0xff) ? 0:tmp[0],(tmp[1] == 0xff) ? 0:tmp[1],(tmp[2] == 0xff) ? 0:tmp[2]); - break; - } - } - - memset(tmp,0xff,sizeof(tmp)); - for(i = 0 ; i < 8; i++) - { - if(!(irq_present_qsfp_current & (0x1 << i)) && (irq_present_qsfp_next & (0x1 << i))) - { - DEB2(printk("SFP%d is present\r\n",i+49)); - tmp[0] = 1; - } - else if((irq_present_qsfp_current & (0x1 << i)) && !(irq_present_qsfp_next & (0x1 << i))) - { - DEB2(printk("SFP%d is absent\r\n",i+49)); - tmp[0] = 0; - } - - if(!(irq_interrupt_qsfp_current & (0x1 << i)) && (irq_interrupt_qsfp_next & (0x1 << i))) - { - DEB2(printk("SFP%d interrupt is occured \r\n",i+49)); - tmp[1] = 1; - } - else if((irq_interrupt_qsfp_current & (0x1 << i)) && !(irq_interrupt_qsfp_next & (0x1 << i))) - { - DEB2(printk("SFP%d interrupt is cleaned\r\n",i+49)); - tmp[1] = 0; - } - - if((tmp[0] != 0xff) || (tmp[1] != 0xff)) - { - memset(kmsg,0xff,sizeof(kmsg)); - snprintf(kmsg,sizeof(kmsg),"qsfp%02d:%1d:%1d:%1d ",i+49,(tmp[0] == 0xff) ? 0:tmp[0],(tmp[1] == 0xff) ? 0:tmp[1],0); - break; - } - } - - - irq_present_status_low_next = irq_present_status_low_current; - irq_rx_lost_status_low_next = irq_rx_lost_status_low_current; - irq_tx_fault_status_low_next = irq_tx_fault_status_low_current; - irq_present_status_high_next = irq_present_status_high_current; - irq_rx_lost_status_high_next = irq_rx_lost_status_high_current; - irq_tx_fault_status_high_next = irq_tx_fault_status_high_current; - irq_present_qsfp_next = irq_present_qsfp_current; - irq_interrupt_qsfp_next = irq_interrupt_qsfp_current; - - send_usrmsg(kmsg, strlen(kmsg)); -} - -static void disableIrq(unsigned short maskReg, unsigned short mask) -{ - u8 data = 0; - - data = lpc_iic_getbyte(NULL,maskReg); - data |= mask; - lpc_iic_setbyte(NULL,maskReg, data); -} - -static void enableIrq(unsigned short maskReg, unsigned short mask) -{ - unsigned short data; - - data = lpc_iic_getbyte(NULL,maskReg); - data &= ~mask; - lpc_iic_setbyte(NULL,maskReg, data); -} - - -static irqreturn_t irq_inter_isr(int irq, void *handle) -{ - - /* - * use keventd context to read the event fifo registers - * Schedule readout at least 25ms after notification for - * REVID < 4 - */ - - schedule_delayed_work(&irq_inter_work, irq_inter_delay); - - return IRQ_HANDLED; -} - - -#define CIG_CPLD_CHR_NAME "cpld" - - -static int __init cpld_init(void) -{ - int rval,rc=0; - dev_t dev; - u8 s_data; - - DEB2(printk("cpld_init\n");) - -/**************************************************************************************/ - - LPC_INDEX_REG = lpc_base_addr; - LPC_DATA_REG = lpc_base_addr + 1; - - cpld_device = kzalloc(sizeof(struct cpld_dev_type), GFP_KERNEL); - if (!cpld_device) - goto error3; - cpld_device->io_resource = request_region(lpc_base_addr, - lpc_io_space_size, "lpc-i2c"); - if (!cpld_device->io_resource) { - printk("lpc: claim I/O resource fail\n"); - goto error2; - } - sema_init(&cpld_device->sem, 1); - - if (cpld_major) { - dev = MKDEV(cpld_major, cpld_minor); - rc = register_chrdev_region(dev, 1, CIG_CPLD_CHR_NAME); - } else { - rc = alloc_chrdev_region(&dev, cpld_major, 1, CIG_CPLD_CHR_NAME); - cpld_major = MAJOR(dev); - } - - cpld_setup_cdev(cpld_device); - - cpld_class = class_create(THIS_MODULE,CIG_CPLD_CHR_NAME); - if (!cpld_class) { - DEB2(printk("failed to create class\n");) - goto error1; - } - - cpld_class->p->subsys.kobj.ktype= &cpld_kobj_type; - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "read"); - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "write"); - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "reads"); - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "writes"); - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "version"); - - cpld_dev = device_create(cpld_class, NULL, dev, NULL, CIG_CPLD_CHR_NAME); - -/**************************************************************************************/ - - rval = lpc_bus_init(); - rval = lpc_register_driver(&i2c_lpc_driver, 1); - -/**************************************************************************************/ - return 0; -error1: - cdev_del(&cpld_device->cdev); - unregister_chrdev_region(dev, 1); -error2: - release_resource(cpld_device->io_resource); -error3: - kfree(cpld_device); - - return rc; -} - -static void __exit cpld_exit(void) -{ - DEB2(printk("cpld_exit\n")); - - lpc_unregister_driver(&i2c_lpc_driver); - lpc_bus_exit(); - dev_t devno = MKDEV(cpld_major, cpld_minor); - - cdev_del(&cpld_device->cdev); - if (cpld_class) { - device_destroy(cpld_class, devno); - class_destroy(cpld_class); - } - - if (cpld_device) { - if (cpld_device->io_resource) - release_resource(cpld_device->io_resource); - - kfree(cpld_device); - } - unregister_chrdev_region(devno, 1); - - -} - -module_param(cpld_major, int, S_IRUGO); -module_param(cpld_minor, int, S_IRUGO); -module_param(i2c_debug, int, S_IRUGO); -module_param(board_id, int, S_IRUGO); - -module_init(cpld_init); -module_exit(cpld_exit); - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs6436-54p-cpld driver"); -MODULE_LICENSE("GPL"); - - -/********************************************** End ********************************************************/ - - - diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-fan.c b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-fan.c deleted file mode 100644 index 881cb7304b0..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-fan.c +++ /dev/null @@ -1,521 +0,0 @@ -/* - * A hwmon driver for the CIG cs6436-54p fan - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -#define FAN_SPEED_DUTY_TO_CPLD_STEP 10 - -static struct cs6436_54p_fan_data *cs6436_54p_fan_update_device(struct device *dev); -static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); -static ssize_t set_fan_direction(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); - - -extern int cig_cpld_write_register(u8 reg_off, u8 val); -extern int cig_cpld_read_register(u8 reg_off, u8 *val); - -/* fan related data, the index should match sysfs_fan_attributes - */ -static const u8 fan_reg[] = { - 0x41, /* fan enable/disable */ - 0x40, /* fan PWM(for all fan) */ - 0x42, /* front fan 1 speed(rpm) */ - 0x44, /* front fan 2 speed(rpm) */ - 0x46, /* front fan 3 speed(rpm) */ - 0x48, /* front fan 4 speed(rpm) */ - 0x4a, /* front fan 5 speed(rpm) */ - 0x43, /* rear fan 1 speed(rpm) */ - 0x45, /* rear fan 2 speed(rpm) */ - 0x47, /* rear fan 3 speed(rpm) */ - 0x49, /* rear fan 4 speed(rpm) */ - 0x4b, /* rear fan 5 speed(rpm) */ - 0x4c, /* fan direction rear to front or front to rear */ -}; - - -/* Each client has this additional data */ -struct cs6436_54p_fan_data { - struct platform_device *pdev; - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* != 0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */ -}; - -static struct cs6436_54p_fan_data *fan_data = NULL; - -enum fan_id { - FAN1_ID, - FAN2_ID, - FAN3_ID, - FAN4_ID, - FAN5_ID, -}; - -enum sysfs_fan_attributes { - FAN_STATE_REG, - FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */ - FAN1_FRONT_SPEED_RPM, - FAN2_FRONT_SPEED_RPM, - FAN3_FRONT_SPEED_RPM, - FAN4_FRONT_SPEED_RPM, - FAN5_FRONT_SPEED_RPM, - FAN1_REAR_SPEED_RPM, - FAN2_REAR_SPEED_RPM, - FAN3_REAR_SPEED_RPM, - FAN4_REAR_SPEED_RPM, - FAN5_REAR_SPEED_RPM, - FAN_DIRECTION, - FAN1_STATE, - FAN2_STATE, - FAN3_STATE, - FAN4_STATE, - FAN5_STATE, - FAN1_FAULT, - FAN2_FAULT, - FAN3_FAULT, - FAN4_FAULT, - FAN5_FAULT, - FAN1_DIRECTION, - FAN2_DIRECTION, - FAN3_DIRECTION, - FAN4_DIRECTION, - FAN5_DIRECTION, -}; - -/* Define attributes - */ -#define DECLARE_FAN_STATE_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_state, S_IRUGO, fan_show_value, NULL, FAN##index##_STATE) -#define DECLARE_FAN_STATE_ATTR(index) &sensor_dev_attr_fan##index##_state.dev_attr.attr - -#define DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_fault, S_IRUGO, fan_show_value, NULL, FAN##index##_FAULT) -#define DECLARE_FAN_FAULT_ATTR(index) &sensor_dev_attr_fan##index##_fault.dev_attr.attr - -#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE) -#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr - -#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_front_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\ - static SENSOR_DEVICE_ATTR(fan##index##_rear_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM) -#define DECLARE_FAN_SPEED_RPM_ATTR(index) &sensor_dev_attr_fan##index##_front_speed_rpm.dev_attr.attr, \ - &sensor_dev_attr_fan##index##_rear_speed_rpm.dev_attr.attr - -#define DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_direction, S_IWUSR | S_IRUGO, fan_show_value, set_fan_direction, FAN##index##_DIRECTION) -#define DECLARE_FAN_DIRECTION_ATTR(index) &sensor_dev_attr_fan##index##_direction.dev_attr.attr - - -/* 5 fan state attributes in this platform */ -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(1); -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(2); -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(3); -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(4); -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(5); - - -/* 5 fan fault attributes in this platform */ -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(4); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(5); - -/* 5 fan speed(rpm) attributes in this platform */ -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(4); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(5); - -/* 1 fan duty cycle attribute in this platform */ -DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(); - -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(1); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(2); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(3); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(4); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5); - - -static struct attribute *cs6436_54p_fan_attributes[] = { - /* fan related attributes */ - DECLARE_FAN_STATE_ATTR(1), - DECLARE_FAN_STATE_ATTR(2), - DECLARE_FAN_STATE_ATTR(3), - DECLARE_FAN_STATE_ATTR(4), - DECLARE_FAN_STATE_ATTR(5), - DECLARE_FAN_FAULT_ATTR(1), - DECLARE_FAN_FAULT_ATTR(2), - DECLARE_FAN_FAULT_ATTR(3), - DECLARE_FAN_FAULT_ATTR(4), - DECLARE_FAN_FAULT_ATTR(5), - DECLARE_FAN_SPEED_RPM_ATTR(1), - DECLARE_FAN_SPEED_RPM_ATTR(2), - DECLARE_FAN_SPEED_RPM_ATTR(3), - DECLARE_FAN_SPEED_RPM_ATTR(4), - DECLARE_FAN_SPEED_RPM_ATTR(5), - DECLARE_FAN_DUTY_CYCLE_ATTR(), - DECLARE_FAN_DIRECTION_ATTR(1), - DECLARE_FAN_DIRECTION_ATTR(2), - DECLARE_FAN_DIRECTION_ATTR(3), - DECLARE_FAN_DIRECTION_ATTR(4), - DECLARE_FAN_DIRECTION_ATTR(5), - NULL -}; - -#define FAN_MAX_DUTY_CYCLE 100 -#define FAN_REG_VAL_TO_SPEED_RPM_STEP 100 - -/* fan utility functions - */ -static u32 reg_val_to_duty_cycle(u8 reg_val) -{ - if (reg_val -== 0xFF) { - return 100; - } - return ((u32)(reg_val) * 100)/ 255; -} - -static u8 duty_cycle_to_reg_val(u8 duty_cycle) -{ - if (duty_cycle >= FAN_MAX_DUTY_CYCLE) { - return 0xFF; - } - - return 255 / 10 * (duty_cycle / 10); -} - -static u32 reg_val_to_speed_rpm(u8 reg_val) -{ - return (u32)reg_val * FAN_REG_VAL_TO_SPEED_RPM_STEP; -} - -static u8 reg_val_to_is_state(u8 reg_val, enum fan_id id) -{ - u8 mask = (1 << id); - - reg_val &= mask; - - return reg_val ? 0 : 1; -} - -static u8 is_fan_fault(struct cs6436_54p_fan_data *data, enum fan_id id) -{ - u8 ret = 1; - int front_fan_index = FAN1_FRONT_SPEED_RPM + id; - int rear_fan_index = FAN1_REAR_SPEED_RPM + id; - - /* Check if the speed of front or rear fan is ZERO, - */ - if (reg_val_to_speed_rpm(data->reg_val[front_fan_index]) && - reg_val_to_speed_rpm(data->reg_val[rear_fan_index])) { - ret = 0; - } - - return ret; -} - - -static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - int error, value; - - error = kstrtoint(buf, 10, &value); - if (error) - return error; - - if (value <= 0 || value > FAN_MAX_DUTY_CYCLE) - return -EINVAL; - - cig_cpld_write_register(fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); - - return count; -} - -static ssize_t set_fan_direction(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - int error, value,fan_index; - u8 mask,reg_val; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - fan_index = attr->index - FAN1_DIRECTION; - error = kstrtoint(buf, 10, &value); - if (error) - return error; - - if (!(value == 0 || value == 1)) - return -EINVAL; - - - cig_cpld_read_register(fan_reg[FAN_DIRECTION],®_val); - - if(value == 1) - { - reg_val |= (1 << fan_index); - } - else - { - reg_val &= ~(1 << fan_index); - } - - cig_cpld_write_register(fan_reg[FAN_DIRECTION], reg_val); - - return count; -} - - - - - -static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - - cs6436_54p_fan_update_device(dev); - - struct cs6436_54p_fan_data *data = fan_data; - - ssize_t ret = 0; - - if (data->valid) { - switch (attr->index) { - - case FAN1_STATE: - case FAN2_STATE: - case FAN3_STATE: - case FAN4_STATE: - case FAN5_STATE: - //printk("FAN_STATE_REG: 0x%x\n", data->reg_val[FAN_STATE_REG]); - //printk("index: %d\n", attr->index); - ret = sprintf(buf, "%d\n", - reg_val_to_is_state(data->reg_val[FAN_STATE_REG], - attr->index - FAN1_STATE)); - break; - case FAN_DUTY_CYCLE_PERCENTAGE: - { - u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]); - ret = sprintf(buf, "%u\n", duty_cycle); - break; - } - case FAN1_FRONT_SPEED_RPM: - case FAN2_FRONT_SPEED_RPM: - case FAN3_FRONT_SPEED_RPM: - case FAN4_FRONT_SPEED_RPM: - case FAN5_FRONT_SPEED_RPM: - case FAN1_REAR_SPEED_RPM: - case FAN2_REAR_SPEED_RPM: - case FAN3_REAR_SPEED_RPM: - case FAN4_REAR_SPEED_RPM: - case FAN5_REAR_SPEED_RPM: -// printk("FAN_seed_REG: 0x%x\n", data->reg_val[attr->index]); -// printk("index: %d\n", attr->index); - ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index])); - break; - - case FAN1_FAULT: - case FAN2_FAULT: - case FAN3_FAULT: - case FAN4_FAULT: - case FAN5_FAULT: - ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT)); - break; - case FAN1_DIRECTION: - case FAN2_DIRECTION: - case FAN3_DIRECTION: - case FAN4_DIRECTION: - case FAN5_DIRECTION: - ret = sprintf(buf, "%d\n",reg_val_to_is_state(data->reg_val[FAN_DIRECTION],attr->index - FAN1_DIRECTION)); - break; - default: - break; - } - } - - return ret; -} - -static const struct attribute_group cs6436_54p_fan_group = { - .attrs = cs6436_54p_fan_attributes, -}; - -static struct cs6436_54p_fan_data *cs6436_54p_fan_update_device(struct device *dev) -{ - struct cs6436_54p_fan_data *data = fan_data; - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || - !data->valid) { - int i; - - data->valid = 0; - - /* Update fan data - */ - for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) { - u8 status; - (void)cig_cpld_read_register(fan_reg[i], &status); - - if (status < 0) { - data->valid = 0; - mutex_unlock(&data->update_lock); - return data; - } - else { - data->reg_val[i] = status; - } - } - - data->last_updated = jiffies; - data->valid = 1; - } - - mutex_unlock(&data->update_lock); - - return data; -} - -static int cs6436_54p_fan_probe(struct platform_device *pdev) -{ - int status = -1; - /* Register sysfs hooks */ - status = sysfs_create_group(&pdev->dev.kobj, &cs6436_54p_fan_group); - if (status) { - goto exit; - - } - - fan_data->hwmon_dev = hwmon_device_register(&pdev->dev); - if (IS_ERR(fan_data->hwmon_dev)) { - status = PTR_ERR(fan_data->hwmon_dev); - goto exit_remove; - } - - dev_info(&pdev->dev, "cs6436_54p_fan\n"); - - return 0; - -exit_remove: - sysfs_remove_group(&pdev->dev.kobj, &cs6436_54p_fan_group); -exit: - return status; -} - -static int cs6436_54p_fan_remove(struct platform_device *pdev) -{ - hwmon_device_unregister(fan_data->hwmon_dev); - sysfs_remove_group(&fan_data->pdev->dev.kobj, &cs6436_54p_fan_group); - - return 0; -} - -#define DRVNAME "cs6436_54p_fan" - -static struct platform_driver cs6436_54p_fan_driver = { - .probe = cs6436_54p_fan_probe, - .remove = cs6436_54p_fan_remove, - .driver = { - .name = DRVNAME, - .owner = THIS_MODULE, - }, -}; - - - - - -static int __init cs6436_54p_fan_init(void) -{ - int ret; - - cig_cpld_write_register(0x40, duty_cycle_to_reg_val(50)); - - ret = platform_driver_register(&cs6436_54p_fan_driver); - if (ret < 0) { - goto exit; - } - - fan_data = kzalloc(sizeof(struct cs6436_54p_fan_data), GFP_KERNEL); - if (!fan_data) { - ret = -ENOMEM; - platform_driver_unregister(&cs6436_54p_fan_driver); - goto exit; - } - - mutex_init(&fan_data->update_lock); - fan_data->valid = 0; - - fan_data->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); - if (IS_ERR(fan_data->pdev)) { - ret = PTR_ERR(fan_data->pdev); - platform_driver_unregister(&cs6436_54p_fan_driver); - kfree(fan_data); - goto exit; - } - -exit: - return ret; -} - -static void __exit cs6436_54p_fan_exit(void) -{ - platform_device_unregister(fan_data->pdev); - platform_driver_unregister(&cs6436_54p_fan_driver); - kfree(fan_data); -} - -MODULE_AUTHOR("CIG"); -MODULE_DESCRIPTION("cs6436_54p_fan driver"); -MODULE_LICENSE("GPL"); - -module_init(cs6436_54p_fan_init); -module_exit(cs6436_54p_fan_exit); - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs6436_54p_fan driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-led.c b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-led.c deleted file mode 100644 index 74c8b6d0b10..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-led.c +++ /dev/null @@ -1,594 +0,0 @@ -/* - * A hwmon driver for the CIG cs6436-54P LED - * - * Copyright (C) 2018 Cambridge, Inc. - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/*#define DEBUG*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -extern int cig_cpld_write_register(u8 reg_off, u8 val); - -extern int cig_cpld_read_register(u8 reg_off, u8 *val); - -extern void led_classdev_unregister(struct led_classdev *led_cdev); -extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); -extern void led_classdev_resume(struct led_classdev *led_cdev); -extern void led_classdev_suspend(struct led_classdev *led_cdev); - -#define DRVNAME "cs6436_54p_led" - -struct cs6436_54p_led_data { - struct platform_device *pdev; - struct mutex update_lock; - char valid; /* != 0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 reg_val[6]; /* 0: system & location - 1: PSU1 &PSU12 - 2: fan & management - 3: console & ToD - 4-5 : fan1-fan5*/ -}; - -static struct cs6436_54p_led_data *ledctl = NULL; - -/* LED related data - */ -#define LED_TYPE_PSU1_REG_MASK 0x0C -#define LED_MODE_PSU1_GREEN_MASK 0x08 -#define LED_MODE_PSU1_RED_MASK 0x04 -#define LED_MODE_PSU1_AMBER_MASK 0x0C -#define LED_MODE_PSU1_OFF_MASK 0x00 - -#define LED_TYPE_PSU2_REG_MASK 0x30 -#define LED_MODE_PSU2_GREEN_MASK 0x20 -#define LED_MODE_PSU2_RED_MASK 0x10 -#define LED_MODE_PSU2_AMBER_MASK 0x30 -#define LED_MODE_PSU2_OFF_MASK 0x00 - -#define LED_TYPE_SYS_REG_MASK 0xF0 -#define LED_MODE_SYS_GREEN_MASK 0x40 -#define LED_MODE_SYS_RED_MASK 0x20 -#define LED_MODE_SYS_AMBER_MASK 0x60 -#define LED_MODE_SYS_AMBER_FLASHING_MASK 0x70 -#define LED_MODE_SYS_OFF_MASK 0x00 - -#define LED_TYPE_RES_REG_MASK 0x0F -#define LED_MODE_RES_GREEN_MASK 0x04 -#define LED_MODE_RES_RED_MASK 0x02 -#define LED_MODE_RES_AMBER_MASK 0x06 -#define LED_MODE_RES_AMBER_FLASHING_MASK 0x07 -#define LED_MODE_RES_OFF_MASK 0x00 - -#define LED_TYPE_FAN_REG_MASK 0x03 -#define LED_MODE_FAN_GREEN_MASK 0x02 -#define LED_MODE_FAN_RED_MASK 0x01 -#define LED_MODE_FAN_AMBER_MASK 0x03 -#define LED_MODE_FAN_OFF_MASK 0x00 - -#define LED_TYPE_FAN1_REG_MASK 0x03 -#define LED_TYPE_FAN2_REG_MASK 0x0C -#define LED_TYPE_FAN3_REG_MASK 0x30 -#define LED_TYPE_FAN4_REG_MASK 0xC0 -#define LED_TYPE_FAN5_REG_MASK 0x03 - -#define LED_MODE_FANX_GREEN_MASK 0x02 -#define LED_MODE_FANX_RED_MASK 0x01 -#define LED_MODE_FANX_AMBER_MASK 0x03 -#define LED_MODE_FANX_OFF_MASK 0x00 - -enum led_type { - LED_TYPE_SYS, - LED_TYPE_PSU2, - LED_TYPE_PSU1, - LED_TYPE_FAN, - LED_TYPE_FAN1, - LED_TYPE_FAN2, - LED_TYPE_FAN3, - LED_TYPE_FAN4, - LED_TYPE_FAN5, -}; - -static const u8 led_reg[] = { - 0x30, /* system & reserved*/ - 0x31, /* fan & PSU1 & PSU2 */ - 0x32, /* FAN5 LED */ - 0x33, /* FAN1-4 LED */ -}; - - -enum led_light_mode { - LED_MODE_OFF = 0, - LED_MODE_GREEN, - LED_MODE_AMBER, - LED_MODE_RED, - LED_MODE_GREEN_BLINK, - LED_MODE_AMBER_BLINK, - LED_MODE_RED_BLINK, - LED_MODE_GREEN_FLASHING, - LED_MODE_AMBER_FLASHING, - LED_MODE_RED_FLASHING, - LED_MODE_AUTO, - LED_MODE_UNKNOWN -}; - -struct led_type_mode { - enum led_type type; - int type_mask; - enum led_light_mode mode; - int mode_mask; -}; - -static struct led_type_mode led_type_mode_data[] = { -{LED_TYPE_PSU1, LED_TYPE_PSU1_REG_MASK, LED_MODE_GREEN, LED_MODE_PSU1_GREEN_MASK}, -{LED_TYPE_PSU1, LED_TYPE_PSU1_REG_MASK, LED_MODE_AMBER, LED_MODE_PSU1_AMBER_MASK}, -{LED_TYPE_PSU1, LED_TYPE_PSU1_REG_MASK, LED_MODE_RED, LED_MODE_PSU1_RED_MASK}, -{LED_TYPE_PSU1, LED_TYPE_PSU1_REG_MASK, LED_MODE_OFF, LED_MODE_PSU1_OFF_MASK}, - -{LED_TYPE_PSU2, LED_TYPE_PSU2_REG_MASK, LED_MODE_GREEN, LED_MODE_PSU2_GREEN_MASK}, -{LED_TYPE_PSU2, LED_TYPE_PSU2_REG_MASK, LED_MODE_AMBER, LED_MODE_PSU2_AMBER_MASK}, -{LED_TYPE_PSU2, LED_TYPE_PSU2_REG_MASK, LED_MODE_RED, LED_MODE_PSU2_RED_MASK}, -{LED_TYPE_PSU2, LED_TYPE_PSU2_REG_MASK, LED_MODE_OFF, LED_MODE_PSU2_OFF_MASK}, - -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_GREEN, LED_MODE_SYS_GREEN_MASK}, -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_AMBER, LED_MODE_SYS_AMBER_MASK}, -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_RED, LED_MODE_SYS_RED_MASK}, -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_AMBER_FLASHING, LED_MODE_SYS_AMBER_FLASHING_MASK}, -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_OFF, LED_MODE_SYS_OFF_MASK}, - -{LED_TYPE_FAN, LED_TYPE_FAN_REG_MASK, LED_MODE_GREEN, LED_MODE_FAN_GREEN_MASK}, -{LED_TYPE_FAN, LED_TYPE_FAN_REG_MASK, LED_MODE_AMBER, LED_MODE_FAN_AMBER_MASK}, -{LED_TYPE_FAN, LED_TYPE_FAN_REG_MASK, LED_MODE_RED, LED_MODE_FAN_RED_MASK}, -{LED_TYPE_FAN, LED_TYPE_FAN_REG_MASK, LED_MODE_OFF, LED_MODE_FAN_OFF_MASK}, - -{LED_TYPE_FAN1, LED_TYPE_FAN1_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 0}, -{LED_TYPE_FAN1, LED_TYPE_FAN1_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 0}, -{LED_TYPE_FAN1, LED_TYPE_FAN1_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 0}, -{LED_TYPE_FAN1, LED_TYPE_FAN1_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 0}, -{LED_TYPE_FAN2, LED_TYPE_FAN2_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 2}, -{LED_TYPE_FAN2, LED_TYPE_FAN2_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 2}, -{LED_TYPE_FAN2, LED_TYPE_FAN2_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 2}, -{LED_TYPE_FAN2, LED_TYPE_FAN2_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 2}, -{LED_TYPE_FAN3, LED_TYPE_FAN3_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 4}, -{LED_TYPE_FAN3, LED_TYPE_FAN3_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 4}, -{LED_TYPE_FAN3, LED_TYPE_FAN3_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 4}, -{LED_TYPE_FAN3, LED_TYPE_FAN3_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 4}, -{LED_TYPE_FAN4, LED_TYPE_FAN4_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 6}, -{LED_TYPE_FAN4, LED_TYPE_FAN4_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 6}, -{LED_TYPE_FAN4, LED_TYPE_FAN4_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 6}, -{LED_TYPE_FAN4, LED_TYPE_FAN4_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 6}, -{LED_TYPE_FAN5, LED_TYPE_FAN5_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 0}, -{LED_TYPE_FAN5, LED_TYPE_FAN5_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 0}, -{LED_TYPE_FAN5, LED_TYPE_FAN5_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 0}, -{LED_TYPE_FAN5, LED_TYPE_FAN5_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 0}, -}; - -struct fanx_info_s { - u8 cname; /* device name */ - enum led_type type; - u8 reg_id; /* map to led_reg & reg_val */ -}; - -static struct fanx_info_s fanx_info[] = { - {'1', LED_TYPE_FAN1, 3}, - {'2', LED_TYPE_FAN2, 3}, - {'3', LED_TYPE_FAN3, 3}, - {'4', LED_TYPE_FAN4, 3}, - {'5', LED_TYPE_FAN5, 2}, -}; - - -static int led_reg_val_to_light_mode(enum led_type type, u8 reg_val) { - int i; - - for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { - - if (type != led_type_mode_data[i].type) - continue; - - if ((led_type_mode_data[i].type_mask & reg_val) == - led_type_mode_data[i].mode_mask) - { - return led_type_mode_data[i].mode; - } - } - - return 0; -} - -static u8 led_light_mode_to_reg_val(enum led_type type, - enum led_light_mode mode, u8 reg_val) { - int i; - - for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { - if (type != led_type_mode_data[i].type) - continue; - - if (mode != led_type_mode_data[i].mode) - continue; - - reg_val = led_type_mode_data[i].mode_mask | - (reg_val & (~led_type_mode_data[i].type_mask)); - break; - } - - return reg_val; -} - -static void cs6436_54p_led_update(void) -{ - mutex_lock(&ledctl->update_lock); - - if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2) - || !ledctl->valid) { - int i; - - dev_dbg(&ledctl->pdev->dev, "Starting cs6436_54p_led update\n"); - - /* Update LED data - */ - for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { - u8 status; - cig_cpld_read_register(led_reg[i], &status); - - if (status < 0) { - ledctl->valid = 0; - dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg[i], status); - goto exit; - } - else - { - ledctl->reg_val[i] = status; - } - } - - ledctl->last_updated = jiffies; - ledctl->valid = 1; - } - -exit: - mutex_unlock(&ledctl->update_lock); -} - -static void cs6436_54p_led_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode, - u8 reg, enum led_type type) -{ - u8 reg_val; - mutex_lock(&ledctl->update_lock); - - cig_cpld_read_register(reg, ®_val); - if (reg_val < 0) { - dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val); - goto exit; - } - - reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val); - - cig_cpld_write_register(reg, reg_val); - - /* to prevent the slow-update issue */ - ledctl->valid = 0; - -exit: - mutex_unlock(&ledctl->update_lock); -} - -static void cs6436_54p_led_fanx_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - enum led_type led_type1; - int reg_id; - int i, nsize; - int ncount = sizeof(fanx_info)/sizeof(struct fanx_info_s); - - for(i=0;iname); - - if (led_cdev->name[nsize-1] == fanx_info[i].cname) - { - led_type1 = fanx_info[i].type; - reg_id = fanx_info[i].reg_id; - - cs6436_54p_led_set(led_cdev, led_light_mode, led_reg[reg_id], led_type1); - return; - } - } -} - - -static enum led_brightness cs6436_54p_led_fanx_get(struct led_classdev *cdev) -{ - enum led_type led_type1; - int reg_id; - int i, nsize; - int ncount = sizeof(fanx_info)/sizeof(struct fanx_info_s); - - for(i=0;iname); - - if (cdev->name[nsize-1] == fanx_info[i].cname) - { - led_type1 = fanx_info[i].type; - reg_id = fanx_info[i].reg_id; - cs6436_54p_led_update(); - return led_reg_val_to_light_mode(led_type1, ledctl->reg_val[reg_id]); - } - } - - return led_reg_val_to_light_mode(LED_TYPE_FAN1, ledctl->reg_val[5]); -} - - -static void cs6436_54p_led_psu1_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - cs6436_54p_led_set(led_cdev, led_light_mode, led_reg[1], LED_TYPE_PSU1); -} - -static enum led_brightness cs6436_54p_led_psu1_get(struct led_classdev *cdev) -{ - cs6436_54p_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_PSU1, ledctl->reg_val[1]); -} - -static void cs6436_54p_led_psu2_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - cs6436_54p_led_set(led_cdev, led_light_mode, led_reg[1], LED_TYPE_PSU2); -} - -static enum led_brightness cs6436_54p_led_psu2_get(struct led_classdev *cdev) -{ - cs6436_54p_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_PSU2, ledctl->reg_val[1]); -} - -static void cs6436_54p_led_sys_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - cs6436_54p_led_set(led_cdev, led_light_mode,led_reg[0], LED_TYPE_SYS); -} - -static enum led_brightness cs6436_54p_led_sys_get(struct led_classdev *cdev) -{ - cs6436_54p_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_SYS, ledctl->reg_val[0]); -} - - -static enum led_brightness cs6436_54p_led_fan_get(struct led_classdev *cdev) -{ - cs6436_54p_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_FAN, ledctl->reg_val[1]); -} - -static void cs6436_54p_led_fan_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - cs6436_54p_led_set(led_cdev, led_light_mode, led_reg[1], LED_TYPE_FAN); -} - - -static struct led_classdev cs6436_54p_leds[] = { - [LED_TYPE_SYS] = { - .name = "cs6436_54p_led::sys", - .default_trigger = "unused", - .brightness_set = cs6436_54p_led_sys_set, - .brightness_get = cs6436_54p_led_sys_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN] = { - .name = "cs6436_54p_led::fan", - .default_trigger = "unused", - .brightness_set = cs6436_54p_led_fan_set, - .brightness_get = cs6436_54p_led_fan_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - - [LED_TYPE_PSU1] = { - .name = "cs6436_54p_led::psu1", - .default_trigger = "unused", - .brightness_set = cs6436_54p_led_psu1_set, - .brightness_get = cs6436_54p_led_psu1_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_PSU2] = { - .name = "cs6436_54p_led::psu2", - .default_trigger = "unused", - .brightness_set = cs6436_54p_led_psu2_set, - .brightness_get = cs6436_54p_led_psu2_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - - [LED_TYPE_FAN1] = { - .name = "cs6436_54p_led::fan1", - .default_trigger = "unused", - .brightness_set = cs6436_54p_led_fanx_set, - .brightness_get = cs6436_54p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN2] = { - .name = "cs6436_54p_led::fan2", - .default_trigger = "unused", - .brightness_set = cs6436_54p_led_fanx_set, - .brightness_get = cs6436_54p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN3] = { - .name = "cs6436_54p_led::fan3", - .default_trigger = "unused", - .brightness_set = cs6436_54p_led_fanx_set, - .brightness_get = cs6436_54p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN4] = { - .name = "cs6436_54p_led::fan4", - .default_trigger = "unused", - .brightness_set = cs6436_54p_led_fanx_set, - .brightness_get = cs6436_54p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN5] = { - .name = "cs6436_54p_led::fan5", - .default_trigger = "unused", - .brightness_set = cs6436_54p_led_fanx_set, - .brightness_get = cs6436_54p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - } -}; - -static int cs6436_54p_led_suspend(struct platform_device *dev, - pm_message_t state) -{ - int i = 0; - - for (i = 0; i < ARRAY_SIZE(cs6436_54p_leds); i++) { - led_classdev_suspend(&cs6436_54p_leds[i]); - } - - return 0; -} - -static int cs6436_54p_led_resume(struct platform_device *dev) -{ - int i = 0; - - for (i = 0; i < ARRAY_SIZE(cs6436_54p_leds); i++) { - led_classdev_resume(&cs6436_54p_leds[i]); - } - - return 0; -} - -static int cs6436_54p_led_probe(struct platform_device *pdev) -{ - int ret, i; - - for (i = 0; i < ARRAY_SIZE(cs6436_54p_leds); i++) { - ret = led_classdev_register(&pdev->dev, &cs6436_54p_leds[i]); - - if (ret < 0) - break; - } - - /* Check if all LEDs were successfully registered */ - if (i != ARRAY_SIZE(cs6436_54p_leds)) { - int j; - - /* only unregister the LEDs that were successfully registered */ - for (j = 0; j < i; j++) { - led_classdev_unregister(&cs6436_54p_leds[i]); - } - } - - return ret; -} - -static int cs6436_54p_led_remove(struct platform_device *pdev) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(cs6436_54p_leds); i++) { - led_classdev_unregister(&cs6436_54p_leds[i]); - } - - return 0; -} - -static struct platform_driver cs6436_54p_led_driver = { - .probe = cs6436_54p_led_probe, - .remove = cs6436_54p_led_remove, - .suspend = cs6436_54p_led_suspend, - .resume = cs6436_54p_led_resume, - .driver = { - .name = DRVNAME, - .owner = THIS_MODULE, - }, -}; - -static int cs6436_54p_led_default(void) -{ - cig_cpld_write_register(0x30, 0x40);// system green led solid on -} - -static int __init cs6436_54p_led_init(void) -{ - int ret; - - ret = platform_driver_register(&cs6436_54p_led_driver); - if (ret < 0) { - goto exit; - } - - ledctl = kzalloc(sizeof(struct cs6436_54p_led_data), GFP_KERNEL); - if (!ledctl) { - ret = -ENOMEM; - platform_driver_unregister(&cs6436_54p_led_driver); - goto exit; - } - - mutex_init(&ledctl->update_lock); - - ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); - if (IS_ERR(ledctl->pdev)) { - ret = PTR_ERR(ledctl->pdev); - platform_driver_unregister(&cs6436_54p_led_driver); - kfree(ledctl); - goto exit; - } - - cs6436_54p_led_default(); - -exit: - return ret; -} - -static void __exit cs6436_54p_led_exit(void) -{ - platform_device_unregister(ledctl->pdev); - platform_driver_unregister(&cs6436_54p_led_driver); - kfree(ledctl); -} - -module_init(cs6436_54p_led_init); -module_exit(cs6436_54p_led_exit); - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs6436_54p_led driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-psu.c b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-psu.c deleted file mode 100644 index e8fc896ea13..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-psu.c +++ /dev/null @@ -1,943 +0,0 @@ -/* - * A hwmon driver for the CIG cs6436-54P Power Module - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "i2c-algo-lpc.h" - - - -#define MAX_FAN_DUTY_CYCLE 100 - -/* Address scanned */ -static const unsigned short normal_i2c[] = {I2C_CLIENT_END }; - -/* This is additional data */ -struct cs6436_54p_psu_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; - unsigned long last_updated; /* In jiffies */ - - /* Registers value */ - u8 vout_mode; - u16 v_in; - u16 v_out; - u16 i_in; - u16 i_out; - u16 p_in; - u16 p_out; - u16 temp_input[3]; - u8 temp_fault; - u8 fan_fault; - u16 fan_duty_cycle[2]; - u16 fan_speed[2]; - u8 mfr_id[8]; - u8 mfr_model[20]; - u8 mfr_serial[20]; - u8 psu_is_present; - u8 psu_is_good; - struct i2c_client *client; - struct bin_attribute *bin; /* eeprom data */ -}; - -static int two_complement_to_int(u16 data, u8 valid_bit, int mask); -static ssize_t set_fan_duty_cycle(struct device *dev, struct device_attribute *dev_attr, const char *buf, size_t count); -static ssize_t for_linear_data(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_fan_fault(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_fan_warning(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_temp_fault(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_temp_warning(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_vout_data(struct device *dev, struct device_attribute *dev_attr, char *buf); -static int cs6436_54p_psu_read_byte(struct i2c_client *client, u8 reg); -static int cs6436_54p_psu_read_word(struct i2c_client *client, u8 reg); -static int cs6436_54p_psu_write_word(struct i2c_client *client, u8 reg, u16 value); -static int cs6436_54p_psu_read_block(struct i2c_client *client, u8 command, u8 *data, int data_len); -static struct cs6436_54p_psu_data *cs6436_54p_psu_update_device(struct device *dev); -static ssize_t for_ascii(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_status(struct device *dev, struct device_attribute *dev_attr, char *buf); - -enum cs6436_54p_psu_sysfs_attributes { - PSU_V_IN, - PSU_V_OUT, - PSU_I_IN, - PSU_I_OUT, - PSU_P_IN, - PSU_P_OUT, - PSU_TEMP1_INPUT, - PSU_TEMP2_INPUT, - PSU_TEMP3_INPUT, - PSU_TEMP_FAULT, - PSU_TEMP_WARN, - PSU_FAN1_FAULT, - PSU_FAN1_WARN, - PSU_FAN1_DUTY_CYCLE, - PSU_FAN1_SPEED, - PSU_MFR_ID, - PSU_MFR_MODEL, - PSU_MFR_SERIAL, - PSU_PRESENT, - PSU_P_GOOD, -}; - -static int two_complement_to_int(u16 data, u8 valid_bit, int mask) -{ - u16 valid_data = data & mask; - - bool is_negative = valid_data >> (valid_bit - 1); - return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data; -} - -static ssize_t set_fan_duty_cycle(struct device *dev, struct device_attribute \ - *dev_attr, const char *buf, size_t count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct i2c_client *client = to_i2c_client(dev); - struct cs6436_54p_psu_data *data = i2c_get_clientdata(client); - int nr = (attr->index == PSU_FAN1_DUTY_CYCLE) ? 0 : 1; - long speed; - int error; - - if (data->valid != 1) - { - return -ENODEV; - } - - error = kstrtol(buf, 10, &speed); - if (error) - return error; - - if (speed < 0 || speed > MAX_FAN_DUTY_CYCLE) - return -EINVAL; - - - mutex_lock(&data->update_lock); - data->fan_duty_cycle[nr] = speed; - cs6436_54p_psu_write_word(client, 0x3B + nr, data->fan_duty_cycle[nr]); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t for_linear_data(struct device *dev, struct device_attribute *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs6436_54p_psu_data *data = cs6436_54p_psu_update_device(dev); - - u16 value = 0; - int exponent, mantissa; - int multiplier = 1000; - - if (data->valid != 1) - { - return -ENODEV; - } - - switch (attr->index) { - case PSU_V_IN: - value = data->v_in; - break; - case PSU_I_IN: - value = data->i_in; - break; - case PSU_I_OUT: - value = data->i_out; - break; - case PSU_P_IN: - value = data->p_in; - break; - case PSU_P_OUT: - value = data->p_out; - break; - case PSU_TEMP1_INPUT: - value = data->temp_input[0]; - break; - case PSU_TEMP2_INPUT: - value = data->temp_input[1]; - break; - case PSU_TEMP3_INPUT: - value = data->temp_input[2]; - break; - case PSU_FAN1_DUTY_CYCLE: - multiplier = 1; - value = data->fan_duty_cycle[0]; - break; - case PSU_FAN1_SPEED: - multiplier = 1; - value = data->fan_speed[0]; - break; - default: - break; - } - - exponent = two_complement_to_int(value >> 11, 5, 0x1f); - mantissa = two_complement_to_int(value & 0x7ff, 11, 0x7ff); - - return (exponent >= 0) ? sprintf(buf, "%d\n", \ - (mantissa << exponent) * multiplier) : \ - sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent)); -} - -static ssize_t for_fan_fault(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs6436_54p_psu_data *data = cs6436_54p_psu_update_device(dev); - - if (data->valid != 1) - { - return -ENODEV; - } - - u8 shift = (attr->index == PSU_FAN1_FAULT) ? 7 : 6; - - return sprintf(buf, "%d\n", data->fan_fault >> shift); -} - -static ssize_t for_fan_warning(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs6436_54p_psu_data *data = cs6436_54p_psu_update_device(dev); - - if (data->valid != 1) - { - return -ENODEV; - } - - u8 shift = (attr->index == PSU_FAN1_WARN) ? 5 : 4; - - return sprintf(buf, "%d\n", data->fan_fault >> shift); -} - -static ssize_t for_temp_fault(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs6436_54p_psu_data *data = cs6436_54p_psu_update_device(dev); - - if (data->valid != 1) - { - return -ENODEV; - } - - - - return sprintf(buf, "%d\n", data->temp_fault >> 7); -} - -static ssize_t for_temp_warning(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs6436_54p_psu_data *data = cs6436_54p_psu_update_device(dev); - if (data->valid != 1) - { - return -ENODEV; - } - - - return sprintf(buf, "%d\n", data->temp_fault >> 6); -} -static ssize_t for_vout_data(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct cs6436_54p_psu_data *data = cs6436_54p_psu_update_device(dev); - int exponent, mantissa; - int multiplier = 1000; - if (data->valid != 1) - { - return -ENODEV; - } - - - exponent = two_complement_to_int(data->vout_mode, 5, 0x1f); - mantissa = data->v_out; - - return (exponent > 0) ? sprintf(buf, "%d\n", \ - (mantissa << exponent) * multiplier) : \ - sprintf(buf, "%d\n", ((mantissa * multiplier) >> (-exponent))); -} - -static ssize_t for_ascii(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs6436_54p_psu_data *data = cs6436_54p_psu_update_device(dev); - u8 *ptr = NULL; - - if (data->valid != 1) - { - return -ENODEV; - } - - switch (attr->index) { - case PSU_MFR_ID: - ptr = data->mfr_id + 1; - break; - case PSU_MFR_MODEL: - ptr = data->mfr_model + 1; - break; - case PSU_MFR_SERIAL: - ptr = data->mfr_serial + 1; - break; - default: - return 0; - } - return sprintf(buf, "%s\n", ptr); -} - - -static ssize_t for_status(struct device *dev, struct device_attribute *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs6436_54p_psu_data *data = cs6436_54p_psu_update_device(dev); - u8 *ptr = NULL; - - u8 status = 0; - - if (attr->index == PSU_PRESENT) { - status = data->psu_is_present; - } - else { /* PSU_POWER_GOOD */ - if (!data->valid) { - return -ENODEV; - } - - status = data->psu_is_good; - } - - return sprintf(buf, "%d\n", status); -} - - -static int cs6436_54p_psu_read_byte(struct i2c_client *client, u8 reg) -{ - return i2c_smbus_read_byte_data(client, reg); -} - -static int cs6436_54p_psu_read_word(struct i2c_client *client, u8 reg) -{ - return i2c_smbus_read_word_data(client, reg); -} - -static int cs6436_54p_psu_write_word(struct i2c_client *client, u8 reg, \ - u16 value) -{ - union i2c_smbus_data data; - data.word = value; - return i2c_smbus_xfer(client->adapter, client->addr, - client->flags |= I2C_CLIENT_PEC, - I2C_SMBUS_WRITE, reg, - I2C_SMBUS_WORD_DATA, &data); - -} - -static int cs6436_54p_psu_read_block(struct i2c_client *client, u8 command, \ - u8 *data, int data_len) -{ - int result = i2c_smbus_read_i2c_block_data(client, command, data_len, - data); - if (unlikely(result < 0)) - goto abort; - if (unlikely(result != data_len)) { - result = -EIO; - goto abort; - } - - result = 0; -abort: - return result; - -} - -struct reg_data_byte { - u8 reg; - u8 *value; -}; - -struct reg_data_word { - u8 reg; - u16 *value; -}; - - - -#define EEPROM_NAME "psu_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ - -/* Platform dependent --- */ -static ssize_t psu_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ - int status, retry = 3; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(100); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; - -} - - -static ssize_t psu_page_write(struct i2c_client *client,const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - - - while (count) { - ssize_t status; - - status = psu_eeprom_write(client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - - return retval; -} - - - -static ssize_t psu_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct cs6436_54p_psu_data *data; - ssize_t retval = 0; - struct i2c_client *client; - - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - client = to_i2c_client(container_of(kobj, struct device, kobj)); - - mutex_lock(&data->update_lock); - retval = psu_page_write(client, buf, off, count); - mutex_unlock(&data->update_lock); - return retval; -} - - -static ssize_t psu_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ - int status, retry = 3; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(100); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - -abort: - return status; -} - - - -static ssize_t psu_page_read(struct i2c_client *client,char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - printk("Count = 0, return"); - return count; - } - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - - - while (count) { - ssize_t status; - - status = psu_eeprom_read(client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - - return retval; - -} - - -static ssize_t psu_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct cs6436_54p_psu_data *data; - struct i2c_client *client; - ssize_t retval = 0; - - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - client = to_i2c_client(container_of(kobj, struct device, kobj)); - mutex_lock(&data->update_lock); - retval = psu_page_read(client, buf, off, count); - mutex_unlock(&data->update_lock); - - return retval; -} - - - -static int psu_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = psu_bin_read; - eeprom->write = psu_bin_write; - eeprom->size = EEPROM_SIZE; - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - - -static int psu_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - - -static int psu_i2c_check_functionality(struct i2c_client *client) -{ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_I2C_BLOCK); -} - - - -static int psu_eeprom_probe(struct i2c_client *client, const struct i2c_device_id *dev_id) -{ - int status; - - struct cs6436_54p_psu_data *data; - - if (!psu_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(*data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - i2c_set_clientdata(client, data); - data->valid = 0; - mutex_init(&data->update_lock); - - data->bin = kzalloc(sizeof(struct bin_attribute), GFP_KERNEL); - if (!data->bin) { - status = -ENOMEM; - goto eeprom_bin_error; - } - - /* init eeprom */ - status = psu_sysfs_eeprom_init(&client->dev.kobj, data->bin); - if (status) { - status = -ENOMEM; - goto sys_init_error; - } - - dev_info(&client->dev, "psu eeprom '%s'\n", client->name); - - return 0; - - sys_init_error: - kfree(data->bin); - - eeprom_bin_error: - kfree(data); - - exit: - return status; -} - - - - -static struct cs6436_54p_psu_data *cs6436_54p_psu_update_device(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cs6436_54p_psu_data *data = i2c_get_clientdata(client); - - - mutex_lock(&data->update_lock); - - - if (time_after(jiffies, data->last_updated)) { - int i, status; - u8 command; - struct reg_data_byte regs_byte[] = { - {0x20, &data->vout_mode}, - {0x81, &data->fan_fault}, - {0x7d, &data->temp_fault}, - }; - struct reg_data_word regs_word[] = { - {0x88, &data->v_in}, - {0x8b, &data->v_out}, - {0x89, &data->i_in}, - {0x8c, &data->i_out}, - {0x96, &data->p_out}, - {0x97, &data->p_in}, - {0x8d, &(data->temp_input[0])}, - {0x8e, &(data->temp_input[1])}, - {0x3b, &(data->fan_duty_cycle[0])}, - {0x90, &(data->fan_speed[0])}, - }; - data->valid = 1; - - dev_dbg(&client->dev, "start data update\n"); - - /* one milliseconds from now */ - data->last_updated = jiffies + HZ / 1000; - - for (i = 0; i < ARRAY_SIZE(regs_byte); i++) { - status = cs6436_54p_psu_read_byte(client, - regs_byte[i].reg); - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", - regs_byte[i].reg, status); - *(regs_byte[i].value) = 0; - data->valid = 0; - } else { - *(regs_byte[i].value) = status; - } - } - - for (i = 0; i < ARRAY_SIZE(regs_word); i++) { - status = cs6436_54p_psu_read_word(client, - regs_word[i].reg); - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", - regs_word[i].reg, status); - *(regs_word[i].value) = 0; - data->valid = 0; - } else { - *(regs_word[i].value) = status; - } - } - - command = 0x99; /* PSU mfr_id */ - status = cs6436_54p_psu_read_block(client, command, - data->mfr_id, ARRAY_SIZE(data->mfr_id) - 1); - data->mfr_id[ARRAY_SIZE(data->mfr_id) - 1] = '\0'; - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", command, status); - memset(data->mfr_id, 0, sizeof(data->mfr_id)); - data->valid = 0; - } - - command = 0x9a; /* PSU mfr_model */ - status = cs6436_54p_psu_read_block(client, command, - data->mfr_model, ARRAY_SIZE(data->mfr_model) - 1); - data->mfr_model[ARRAY_SIZE(data->mfr_model) - 1] = '\0'; - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", command, status); - memset(data->mfr_model, 0, sizeof(data->mfr_id)); - data->valid = 0; - } - - command = 0x9e; /* PSU mfr_serial */ - status = cs6436_54p_psu_read_block(client, command, - data->mfr_serial, ARRAY_SIZE(data->mfr_serial) - 1); - data->mfr_serial[ARRAY_SIZE(data->mfr_serial) - 1] = '\0'; - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", command, status); - memset(data->mfr_serial, 0, sizeof(data->mfr_id)); - data->valid = 0; - } - - data->psu_is_present = strlen(data->mfr_id) > 1 ? 1:0; - if(data->psu_is_present) - { - data->psu_is_good = ((data->fan_fault) || (data->temp_fault))? 0:1; - } - else - { - data->valid = 0; - data->psu_is_good = 0; - } - } - - mutex_unlock(&data->update_lock); - - return data; - -} - -/* sysfs attributes for hwmon */ -static SENSOR_DEVICE_ATTR(psu_v_in, S_IRUGO, for_linear_data, NULL, PSU_V_IN); -static SENSOR_DEVICE_ATTR(psu_v_out, S_IRUGO, for_vout_data, NULL, PSU_V_OUT); -static SENSOR_DEVICE_ATTR(psu_i_in, S_IRUGO, for_linear_data, NULL, PSU_I_IN); -static SENSOR_DEVICE_ATTR(psu_i_out, S_IRUGO, for_linear_data, NULL, PSU_I_OUT); -static SENSOR_DEVICE_ATTR(psu_p_in, S_IRUGO, for_linear_data, NULL, PSU_P_IN); -static SENSOR_DEVICE_ATTR(psu_p_out, S_IRUGO, for_linear_data, NULL, PSU_P_OUT); -static SENSOR_DEVICE_ATTR(psu_temp1_input, S_IRUGO, for_linear_data, NULL, PSU_TEMP1_INPUT); -static SENSOR_DEVICE_ATTR(psu_temp2_input, S_IRUGO, for_linear_data, NULL, PSU_TEMP2_INPUT); -static SENSOR_DEVICE_ATTR(psu_temp3_input, S_IRUGO, for_linear_data, NULL, PSU_TEMP3_INPUT); -static SENSOR_DEVICE_ATTR(psu_temp_fault, S_IRUGO, for_temp_fault, NULL, PSU_TEMP_FAULT); -static SENSOR_DEVICE_ATTR(psu_temp_warning, S_IRUGO, for_temp_warning, NULL, PSU_TEMP_WARN); -static SENSOR_DEVICE_ATTR(psu_fan1_fault, S_IRUGO, for_fan_fault, NULL, PSU_FAN1_FAULT); -static SENSOR_DEVICE_ATTR(psu_fan1_warning, S_IRUGO, for_fan_warning, NULL, PSU_FAN1_WARN); -static SENSOR_DEVICE_ATTR(psu_fan1_duty_cycle_percentage, S_IWUSR | S_IRUGO, for_linear_data, set_fan_duty_cycle, PSU_FAN1_DUTY_CYCLE); -static SENSOR_DEVICE_ATTR(psu_fan1_speed_rpm, S_IRUGO, for_linear_data, NULL, PSU_FAN1_SPEED); -static SENSOR_DEVICE_ATTR(psu_mfr_id, S_IRUGO, for_ascii, NULL, PSU_MFR_ID); -static SENSOR_DEVICE_ATTR(psu_mfr_model, S_IRUGO, for_ascii, NULL, PSU_MFR_MODEL); -static SENSOR_DEVICE_ATTR(psu_mfr_serial, S_IRUGO, for_ascii, NULL, PSU_MFR_SERIAL); -static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, for_status, NULL, PSU_PRESENT); -static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, for_status, NULL, PSU_P_GOOD); - - - -static struct attribute *cs6436_54p_psu_attributes[] = { - &sensor_dev_attr_psu_v_in.dev_attr.attr, - &sensor_dev_attr_psu_v_out.dev_attr.attr, - &sensor_dev_attr_psu_i_in.dev_attr.attr, - &sensor_dev_attr_psu_i_out.dev_attr.attr, - &sensor_dev_attr_psu_p_in.dev_attr.attr, - &sensor_dev_attr_psu_p_out.dev_attr.attr, - &sensor_dev_attr_psu_temp1_input.dev_attr.attr, - &sensor_dev_attr_psu_temp2_input.dev_attr.attr, - &sensor_dev_attr_psu_temp3_input.dev_attr.attr, - &sensor_dev_attr_psu_temp_fault.dev_attr.attr, - &sensor_dev_attr_psu_temp_warning.dev_attr.attr, - &sensor_dev_attr_psu_fan1_fault.dev_attr.attr, - &sensor_dev_attr_psu_fan1_warning.dev_attr.attr, - &sensor_dev_attr_psu_fan1_duty_cycle_percentage.dev_attr.attr, - &sensor_dev_attr_psu_fan1_speed_rpm.dev_attr.attr, - &sensor_dev_attr_psu_mfr_id.dev_attr.attr, - &sensor_dev_attr_psu_mfr_model.dev_attr.attr, - &sensor_dev_attr_psu_mfr_serial.dev_attr.attr, - &sensor_dev_attr_psu_present.dev_attr.attr, - &sensor_dev_attr_psu_power_good.dev_attr.attr, - NULL -}; - -static const struct attribute_group cs6436_54p_psu_group = { - .attrs = cs6436_54p_psu_attributes, -}; - - -static int psu_register_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int status; - - - struct cs6436_54p_psu_data *data; - - if (!psu_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(*data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - i2c_set_clientdata(client, data); - data->valid = 0; - mutex_init(&data->update_lock); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &cs6436_54p_psu_group); - if (status) - goto exit_sysfs_create_group; - - cs6436_54p_sysfs_add_client(client); - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_hwmon_device_register; - } - - /* init eeprom */ - - return 0; - - exit_hwmon_device_register: - sysfs_remove_group(&client->dev.kobj, &cs6436_54p_psu_group); - exit_sysfs_create_group: - kfree(data); - exit: - return status; - -} - - -static int cs6436_54p_psu_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int status; - - if((client->addr == 0x52) ||(client->addr == 0x53)) - { - status = psu_eeprom_probe(client, id); - } - else if((client->addr == 0x5a) ||(client->addr == 0x5b)) - { - status = psu_register_probe(client, id); - } - return status; -} - -static int cs6436_54p_psu_remove(struct i2c_client *client) -{ - cs6436_54p_sysfs_remove_client(client); - - if((client->addr == 0x52) ||(client->addr == 0x53)) - { - struct cs6436_54p_psu_data *data; - data = i2c_get_clientdata(client); - psu_sysfs_eeprom_cleanup(&client->dev.kobj,data->bin); - kfree(data); - } - else if((client->addr == 0x5a) ||(client->addr == 0x5b)) - { - struct cs6436_54p_psu_data *data; - data = i2c_get_clientdata(client); - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &cs6436_54p_psu_group); - kfree(data); - } - - return 0; -} - -enum psu_index -{ - cs6436_54p_psu1, - cs6436_54p_psu2 -}; - -static const struct i2c_device_id cs6436_54p_psu_id[] = { - { "cs6436_54p_psu1", cs6436_54p_psu1 }, - { "cs6436_54p_psu2", cs6436_54p_psu2 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, cs6436_54p_psu_id); - -static struct i2c_driver cs6436_54p_psu_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "cs6436_54p_psu", - }, - .probe = cs6436_54p_psu_probe, - .remove = cs6436_54p_psu_remove, - .id_table = cs6436_54p_psu_id, - .address_list = normal_i2c, -}; - -module_i2c_driver(cs6436_54p_psu_driver); - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs6436_54p_psu driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-sfp.c b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-sfp.c deleted file mode 100644 index 5d02bd849a5..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-sfp.c +++ /dev/null @@ -1,1713 +0,0 @@ -/* - * A hwmon driver for the CIG cs6436-54P SFP Module - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "i2c-algo-lpc.h" - -#define DRIVER_NAME "cs6436_54p_sfp" /* Platform dependent */ - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 3 -#define I2C_RW_RETRY_INTERVAL 100 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) -#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 -#define SFF8472_10G_BASE_MASK 0xF0 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 -#define QSFP_RESET_ADDR 0x1b -#define QSFP_INTER_ADDR 0x1a -#define QSFP_LPMODE_ADDR 0x1c - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int cig_cpld_read_register(u8 reg_off, u8 *val); -extern int cig_cpld_write_register(u8 reg_off, u8 val); - -static ssize_t qsfp_reset_read(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_reset_write(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_inter_read(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_lpmode_read(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_lpmode_write(struct device *dev, struct device_attribute *da, const char *buf, size_t count); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL, - QSFPRESET, - QSFPINT, - QSFPLPMODE -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static SENSOR_DEVICE_ATTR(sfp_reset, S_IWUSR | S_IRUGO, qsfp_reset_read, qsfp_reset_write, QSFPRESET); -static SENSOR_DEVICE_ATTR(sfp_inter, S_IRUGO, qsfp_inter_read, NULL, QSFPINT); -static SENSOR_DEVICE_ATTR(sfp_lpmode, S_IWUSR | S_IRUGO, qsfp_lpmode_read, qsfp_lpmode_write, QSFPLPMODE); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - &sensor_dev_attr_sfp_reset.dev_attr.attr, - &sensor_dev_attr_sfp_inter.dev_attr.attr, - &sensor_dev_attr_sfp_lpmode.dev_attr.attr, - NULL -}; - -/* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); -static struct attribute *sfp_msa_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - NULL -}; - -/* SFP ddm attributes for sysfs */ -static struct attribute *sfp_ddm_attributes[] = { - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -cs6436_54p_sfp1, cs6436_54p_sfp2, cs6436_54p_sfp3, cs6436_54p_sfp4, -cs6436_54p_sfp5, cs6436_54p_sfp6, cs6436_54p_sfp7, cs6436_54p_sfp8, -cs6436_54p_sfp9, cs6436_54p_sfp10, cs6436_54p_sfp11, cs6436_54p_sfp12, -cs6436_54p_sfp13, cs6436_54p_sfp14, cs6436_54p_sfp15, cs6436_54p_sfp16, -cs6436_54p_sfp17, cs6436_54p_sfp18, cs6436_54p_sfp19, cs6436_54p_sfp20, -cs6436_54p_sfp21, cs6436_54p_sfp22, cs6436_54p_sfp23, cs6436_54p_sfp24, -cs6436_54p_sfp25, cs6436_54p_sfp26, cs6436_54p_sfp27, cs6436_54p_sfp28, -cs6436_54p_sfp29, cs6436_54p_sfp30, cs6436_54p_sfp31, cs6436_54p_sfp32, -cs6436_54p_sfp33, cs6436_54p_sfp34, cs6436_54p_sfp35, cs6436_54p_sfp36, -cs6436_54p_sfp37, cs6436_54p_sfp38, cs6436_54p_sfp39, cs6436_54p_sfp40, -cs6436_54p_sfp41, cs6436_54p_sfp42, cs6436_54p_sfp43, cs6436_54p_sfp44, -cs6436_54p_sfp45, cs6436_54p_sfp46, cs6436_54p_sfp47, cs6436_54p_sfp48, -cs6436_54p_sfp49, cs6436_54p_sfp50, cs6436_54p_sfp51, cs6436_54p_sfp52, -cs6436_54p_sfp53, cs6436_54p_sfp54, cs6436_54p_sfp55, cs6436_54p_sfp56 -}; - -#define I2C_DEV_ID(x) { #x, x} - -static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(cs6436_54p_sfp1), -I2C_DEV_ID(cs6436_54p_sfp2), -I2C_DEV_ID(cs6436_54p_sfp3), -I2C_DEV_ID(cs6436_54p_sfp4), -I2C_DEV_ID(cs6436_54p_sfp5), -I2C_DEV_ID(cs6436_54p_sfp6), -I2C_DEV_ID(cs6436_54p_sfp7), -I2C_DEV_ID(cs6436_54p_sfp8), -I2C_DEV_ID(cs6436_54p_sfp9), -I2C_DEV_ID(cs6436_54p_sfp10), -I2C_DEV_ID(cs6436_54p_sfp11), -I2C_DEV_ID(cs6436_54p_sfp12), -I2C_DEV_ID(cs6436_54p_sfp13), -I2C_DEV_ID(cs6436_54p_sfp14), -I2C_DEV_ID(cs6436_54p_sfp15), -I2C_DEV_ID(cs6436_54p_sfp16), -I2C_DEV_ID(cs6436_54p_sfp17), -I2C_DEV_ID(cs6436_54p_sfp18), -I2C_DEV_ID(cs6436_54p_sfp19), -I2C_DEV_ID(cs6436_54p_sfp20), -I2C_DEV_ID(cs6436_54p_sfp21), -I2C_DEV_ID(cs6436_54p_sfp22), -I2C_DEV_ID(cs6436_54p_sfp23), -I2C_DEV_ID(cs6436_54p_sfp24), -I2C_DEV_ID(cs6436_54p_sfp25), -I2C_DEV_ID(cs6436_54p_sfp26), -I2C_DEV_ID(cs6436_54p_sfp27), -I2C_DEV_ID(cs6436_54p_sfp28), -I2C_DEV_ID(cs6436_54p_sfp29), -I2C_DEV_ID(cs6436_54p_sfp30), -I2C_DEV_ID(cs6436_54p_sfp31), -I2C_DEV_ID(cs6436_54p_sfp32), -I2C_DEV_ID(cs6436_54p_sfp33), -I2C_DEV_ID(cs6436_54p_sfp34), -I2C_DEV_ID(cs6436_54p_sfp35), -I2C_DEV_ID(cs6436_54p_sfp36), -I2C_DEV_ID(cs6436_54p_sfp37), -I2C_DEV_ID(cs6436_54p_sfp38), -I2C_DEV_ID(cs6436_54p_sfp39), -I2C_DEV_ID(cs6436_54p_sfp40), -I2C_DEV_ID(cs6436_54p_sfp41), -I2C_DEV_ID(cs6436_54p_sfp42), -I2C_DEV_ID(cs6436_54p_sfp43), -I2C_DEV_ID(cs6436_54p_sfp44), -I2C_DEV_ID(cs6436_54p_sfp45), -I2C_DEV_ID(cs6436_54p_sfp46), -I2C_DEV_ID(cs6436_54p_sfp47), -I2C_DEV_ID(cs6436_54p_sfp48), -I2C_DEV_ID(cs6436_54p_sfp49), -I2C_DEV_ID(cs6436_54p_sfp50), -I2C_DEV_ID(cs6436_54p_sfp51), -I2C_DEV_ID(cs6436_54p_sfp52), -I2C_DEV_ID(cs6436_54p_sfp53), -I2C_DEV_ID(cs6436_54p_sfp54), -I2C_DEV_ID(cs6436_54p_sfp55), -I2C_DEV_ID(cs6436_54p_sfp56), -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); - -/* - * list of valid port types - * note OOM_PORT_TYPE_NOT_PRESENT to indicate no - * module is present in this port - */ -typedef enum oom_driver_port_type_e { - OOM_DRIVER_PORT_TYPE_INVALID, - OOM_DRIVER_PORT_TYPE_NOT_PRESENT, - OOM_DRIVER_PORT_TYPE_SFP, - OOM_DRIVER_PORT_TYPE_SFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP, - OOM_DRIVER_PORT_TYPE_QSFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP28 -} oom_driver_port_type_t; - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct sfp_msa_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[6]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss - 3 => device id - 4 => 10G Ethernet Compliance Codes - to distinguish SFP or SFP+ - 5 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -}; - -struct sfp_ddm_data { - struct eeprom_data eeprom; -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - oom_driver_port_type_t port_type; - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct sfp_msa_data *msa; - struct sfp_ddm_data *ddm; - struct qsfp_data *qsfp; - - struct i2c_client *client; -}; - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - - - -static int cig_cpld_write_sfp_register(u8 sfp_reg_addr, u8 sfp_write_reg_data) -{ - u8 sfp_read_status = 0; - u8 wait_time_out = WAIT_TIME_OUT_COUNT; - - cig_cpld_write_register(ADDR_REG_SFP_STATUS_ADDR, sfp_reg_addr << 1); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_TX, sfp_write_reg_data); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_COMMAND, 0x80); - do{ - cig_cpld_read_register(ADDR_REG_SFP_STATUS_STATUS, &sfp_read_status); - udelay(60); - wait_time_out--; - if(wait_time_out == 0) - break; - }while(sfp_read_status != 0x02); - - if(wait_time_out == 0) - return -1; - - return 1; -} - - -static int cig_cpld_read_sfp_register(u8 sfp_reg_addr, u8 *sfp_read_reg_data) -{ - u8 sfp_read_status = 0; - u8 wait_time_out = WAIT_TIME_OUT_COUNT; - - cig_cpld_write_register(ADDR_REG_SFP_STATUS_ADDR, sfp_reg_addr << 1 | 1); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_COMMAND, 0x80); - do{ - udelay(60); - cig_cpld_read_register(ADDR_REG_SFP_STATUS_STATUS, &sfp_read_status); - wait_time_out--; - if(wait_time_out == 0) - break; - }while(sfp_read_status != 0x01); - - cig_cpld_read_register(ADDR_REG_SFP_STATUS_RX,sfp_read_reg_data); - - if(wait_time_out == 0) - return -1; - - return 1; -} - - - - - - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - int i = 0, j = 0, status = -1; - unsigned char cpld_reg_data = 0,cpld_reg_addr = 0; - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - data->present = 0; - - udelay(6000); - - /* Read present status of port 1~48(SFP port) */ - for (i = 0; i < 6; i++) { - cpld_reg_addr = 1 + i; - - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - - data->present |= (u64)cpld_reg_data << (i*8); - - DEBUG_PRINT("Present status = 0x%lx\r\n", data->present); - } - - /* Read present status of port 49-56(QSFP port) */ - cpld_reg_addr = 25; - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - else { - data->present |= (u64)cpld_reg_data << 48; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static struct sfp_port_data *sfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0, j = 0; - int status = -1; - unsigned char cpld_reg_data = 0,cpld_reg_addr = 0; - - if (time_before(jiffies, data->msa->last_updated + HZ + HZ / 2) && data->msa->valid) { - return data; - } - - DEBUG_PRINT("Starting cs6436_54p sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->msa->valid = 0; - memset(data->msa->status, 0, sizeof(data->msa->status)); - - udelay(6000); - - /* Read status of port 1~48(SFP port) */ - for (i = 0; i < 6; i++) { - cpld_reg_addr = 13+i; - - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - - data->msa->status[0] |= (u64)cpld_reg_data << (i * 8); - - DEBUG_PRINT("tx rx status[0] = 0x%lx\r\n", data->msa->status[0]); - } - - - for (i = 0; i < 6; i++) { - cpld_reg_addr = 19+i; - - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - - data->msa->status[1] |= (u64)cpld_reg_data << (i * 8); - - DEBUG_PRINT("tx rx status[1] = 0x%lx\r\n", data->msa->status[1]); - } - - for (i = 0; i < 6; i++) { - cpld_reg_addr = 7+i; - - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - - data->msa->status[2] |= (u64)cpld_reg_data << (i * 8); - - DEBUG_PRINT("tx rx status[2] = 0x%lx\r\n", data->msa->status[2]); - } - - data->msa->valid = 1; - data->msa->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - unsigned char cpld_reg_data = 0,cpld_reg_addr = 0,cpld_reg_bit = 0,cpld_reg_val = 0; - long disable; - int error; - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_set_tx_disable(dev, da, buf, count); - } - - error = kstrtol(buf, 10, &disable); - if (error) { - return error; - } - - mutex_lock(&data->update_lock); - - udelay(6000); - - if(data->port <= 48) { - cpld_reg_addr = 19 + data->port / 8; - cpld_reg_bit = 1 << ((data->port) % 8); - } - - /* Read current status */ - error = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - - /* Update tx_disable status */ - if (disable) { - data->msa->status[1] |= BIT_INDEX(data->port); - cpld_reg_data |= cpld_reg_bit; - } - else { - data->msa->status[1] &= ~ BIT_INDEX(data->port); - cpld_reg_data &= ~cpld_reg_bit; - } - - error = cig_cpld_write_sfp_register(cpld_reg_addr,cpld_reg_data); - - mutex_unlock(&data->update_lock); - return count; -} -/* Platform dependent --- */ - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return !(data->present & BIT_INDEX(data->port)); /* Platform dependent */ -} - -/* Platform dependent +++ */ -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[7] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 56 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5], - values[6]); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d\n", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *sfp_update_port_type(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - u8 buf = 0; - int status; - - mutex_lock(&data->update_lock); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - if (buf != SFF8024_DEVICE_ID_SFP) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - status = sfp_eeprom_read(client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); - data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; - break; - } - case DRIVER_TYPE_QSFP: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); - switch (buf) { - case SFF8024_DEVICE_ID_QSFP: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; - break; - case SFF8024_DEVICE_ID_QSFP_PLUS: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - case SFF8024_DEVICE_ID_QSFP28: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - default: - data->port_type = buf; - break; - } - - break; - } - default: - break; - } - - mutex_unlock(&data->update_lock); - return data; -} - -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - if (!present) { - /* port is not present */ - return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); - } - - sfp_update_port_type(dev); - return sprintf(buf, "%d\n", data->port_type); -} - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - DEBUG_PRINT(""); - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - DEBUG_PRINT(""); - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - DEBUG_PRINT(""); - goto exit; - } - } - msleep(200); - DEBUG_PRINT(""); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - DEBUG_PRINT(""); - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - DEBUG_PRINT(""); - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - DEBUG_PRINT(""); - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_inter_read(struct device *dev, struct device_attribute *da, char *buf) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_INTER_ADDR, &cpld_reg_data); - index = data->port - 48; - index = 1 << index; - val = (cpld_reg_data & index) > 0 ? 1 : 0; - - printk("inter read:data->port = %d, index = %hhu, cpld_reg_data = %hhu\n", data->port, index, cpld_reg_data); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", val); -} - - -static ssize_t qsfp_reset_read(struct device *dev, struct device_attribute *da, char *buf) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_RESET_ADDR, &cpld_reg_data); - index = data->port - 48; - index = 1 << index; - val = (cpld_reg_data & index) > 0 ? 1 : 0; - - printk("reset read:data->port = %d, index = %hhu, cpld_reg_data = %hhu\n", data->port, index, cpld_reg_data); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_reset_write(struct device *dev, struct device_attribute *da, const char *buf, size_t count) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - long usrdata; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - ret = kstrtol(buf, 10, &usrdata); - if (ret) { - return ret; - } - - usrdata = usrdata > 0 ? 1 : 0; - index = data->port - 48; - - DEBUG_PRINT("usrdata = %u, index = %hhu\n", usrdata, index); - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_RESET_ADDR, &cpld_reg_data); - if (ret == 1) - { - - DEBUG_PRINT("cpld_reg_data = %x\n", cpld_reg_data); - cpld_reg_data &= ~(1 << index); - cpld_reg_data |= usrdata << index; - - DEBUG_PRINT("cpld_reg_data = %x\n", cpld_reg_data); - ret = cig_cpld_write_sfp_register(QSFP_RESET_ADDR, cpld_reg_data); - if (1 != ret) - { - DEBUG_PRINT("write failed\n"); - } - } - else - { - DEBUG_PRINT("read failed\n"); - } - - mutex_unlock(&data->update_lock); - - if (ret != 1) - return -1; - - return count; -} - - - - -static ssize_t qsfp_lpmode_read(struct device *dev, struct device_attribute *da, char *buf) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_LPMODE_ADDR, &cpld_reg_data); - index = data->port - 48; - index = 1 << index; - val = (cpld_reg_data & index) > 0 ? 1 : 0; - - printk("lpmode read:data->port = %d, index = %hhu, cpld_reg_data = %hhu\n", data->port, index, cpld_reg_data); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_lpmode_write(struct device *dev, struct device_attribute *da, const char *buf, size_t count) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - long usrdata; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - ret = kstrtol(buf, 10, &usrdata); - if (ret) { - return ret; - } - - usrdata = usrdata > 0 ? 1 : 0; - index = data->port - 48; - - DEBUG_PRINT("usrdata = %u, index = %hhu\n", usrdata, index); - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_LPMODE_ADDR, &cpld_reg_data); - if (ret == 1) - { - - DEBUG_PRINT("cpld_reg_data = %x\n", cpld_reg_data); - cpld_reg_data &= ~(1 << index); - cpld_reg_data |= usrdata << index; - - DEBUG_PRINT("cpld_reg_data = %x\n", cpld_reg_data); - ret = cig_cpld_write_sfp_register(QSFP_LPMODE_ADDR, cpld_reg_data); - if (1 != ret) - { - DEBUG_PRINT("write failed\n"); - } - } - else - { - DEBUG_PRINT("read failed\n"); - } - - mutex_unlock(&data->update_lock); - - if (ret != 1) - return -1; - - return count; -} - - - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT(""); - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - DEBUG_PRINT(""); - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - DEBUG_PRINT(""); - data = qsfp_update_tx_rx_status(dev); - DEBUG_PRINT(""); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - DEBUG_PRINT(""); - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - DEBUG_PRINT(""); - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - data->qsfp->status[1] = disable & 0xF; - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status; - char ddm; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (status == 0) { - /* port is not present */ - return -ENODEV; - } - - status = sfp_eeprom_read(client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); - if (unlikely(status < 0)) { - return status; - } - - return sprintf(buf, "%d\n", !!(ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK)); -} - -/* Platform dependent +++ */ -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0, index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("driver type = (%d)", data->driver_type); - if (data->driver_type == DRIVER_TYPE_QSFP) { - DEBUG_PRINT(""); - return qsfp_show_tx_rx_status(dev, da, buf); - } - - DEBUG_PRINT(""); - data = sfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - if(attr->index == RX_LOS_ALL) { - int i = 0; - u8 values[6] = {0}; - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = (u8)(data->msa->status[2] >> (i * 8)); - } - - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } - - switch (attr->index) { - case TX_FAULT: - index = 0; - break; - case TX_DISABLE: - index = 1; - break; - case RX_LOS: - index = 2; - break; - default: - break; - } - - val = !!(data->msa->status[index] & BIT_INDEX(data->port)); - return sprintf(buf, "%d\n", val); -} -/* Platform dependent --- */ -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} - - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_write(data, buf, off, count); -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_read(data, buf, off, count); -} - -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; - eeprom->size = EEPROM_SIZE; - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; - -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} - -static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_msa_data **data) -{ - int status; - struct sfp_msa_data *msa; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); - if (!msa) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = msa; - dev_info(&client->dev, "sfp msa '%s'\n", client->name); - - cs6436_54p_sysfs_add_client(client); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); -exit_free: - kfree(msa); -exit: - - return status; -} - -static const struct attribute_group sfp_ddm_group = { - .attrs = sfp_ddm_attributes, -}; - -static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_ddm_data **data) -{ - int status; - struct sfp_ddm_data *ddm; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); - if (!ddm) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = ddm; - dev_info(&client->dev, "sfp ddm '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); -exit_free: - kfree(ddm); -exit: - - return status; -} - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); - if (status) { - goto exit_remove; - } - - /* Bring QSFPs out of reset */ - //cig_lpc_write(0x62, 0x15, 0x3F); - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct sfp_port_data *data = NULL; - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - - if (dev_id->driver_data >= cs6436_54p_sfp1 && dev_id->driver_data <= cs6436_54p_sfp48) { - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_MSA; - return sfp_msa_probe(client, dev_id, &data->msa); - } - else if (client->addr == SFP_EEPROM_A2_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_DDM; - return sfp_ddm_probe(client, dev_id, &data->ddm); - } - } - else { /* cs6436_54p_sfp49 ~ cs6436_54p_sfp56 */ - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_QSFP; - return qsfp_probe(client, dev_id, &data->qsfp); - } - } - - return -ENODEV; -} -/* Platform dependent --- */ - -static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); - kfree(data); - return 0; -} - -static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - cs6436_54p_sysfs_remove_client(client); - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_SFP_DDM: - return sfp_ddm_remove(client, data->ddm); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); - } - - return 0; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver cs6436_54p_sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -module_i2c_driver(cs6436_54p_sfp_driver); - - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs6436_54p_sfp driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-sysfs.c b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-sysfs.c deleted file mode 100644 index 1383fcfd40f..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/modules/x86-64-cig-cs6436-54p-sysfs.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * A hwmon driver for the CIG cs6436-54P sysfs Module - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "i2c-algo-lpc.h" - - -static LIST_HEAD(sysfs_client_list); -static struct mutex list_lock; - -struct sysfs_client_node { - struct i2c_client *client; - struct list_head list; -}; - -#define DEVICE_NAME "cigfs" -static int dev_major; -static struct class *dev_class; -static struct cdev *dev_cdev; -static struct device *dev_device; -static struct class *psu_class; -static struct class *sfp_class; - - -void cs6436_54p_sysfs_add_client(struct i2c_client *client) -{ - struct sysfs_client_node *node = kzalloc(sizeof(struct sysfs_client_node), GFP_KERNEL); - - if (!node) { - dev_dbg(&client->dev, "Can't allocate sysfs_client_node (0x%x)\n", client->addr); - return; - } - node->client = client; - - mutex_lock(&list_lock); - list_add(&node->list, &sysfs_client_list); - mutex_unlock(&list_lock); -} - -EXPORT_SYMBOL(cs6436_54p_sysfs_add_client); - -void cs6436_54p_sysfs_remove_client(struct i2c_client *client) -{ - struct list_head *list_node = NULL; - struct sysfs_client_node *sysfs_node = NULL; - int found = 0; - - mutex_lock(&list_lock); - - list_for_each(list_node, &sysfs_client_list) - { - sysfs_node = list_entry(list_node, struct sysfs_client_node, list); - if (IS_ERR(sysfs_node)) - { - break; - } - if (sysfs_node->client == client) { - found = 1; - break; - } - } - if (found) { - list_del(list_node); - kfree(sysfs_node); - } - - mutex_unlock(&list_lock); -} - -EXPORT_SYMBOL(cs6436_54p_sysfs_remove_client); - -struct class * cs6436_54p_sysfs_create_symclass(char *cls_name) -{ - int rc = 0; - struct class *my_class; -/**************************************************************************************/ - my_class = class_create(THIS_MODULE,cls_name); - if (IS_ERR(my_class)) { - pr_err("failed to create my class\n"); - } - return my_class; - -/**************************************************************************************/ -} - -void cs6436_54p_sysfs_delete_symclass(struct class *my_class) -{ -/**************************************************************************************/ - - if (IS_ERR(my_class)) { - pr_err("Pointer is invaild\n"); - } - class_destroy(my_class); - -/**************************************************************************************/ -} - - - - - -int cs6436_54p_sysfs_create_symlink(struct class *my_class,char * driver_name,char *device_name) -{ - struct list_head *list_node = NULL; - struct sysfs_client_node *sysfs_node = NULL; - int ret = -EPERM; - int rc = 0; - - mutex_lock(&list_lock); - list_for_each(list_node, &sysfs_client_list) - { - sysfs_node = list_entry(list_node, struct sysfs_client_node, list); - if (!strcmp(sysfs_node->client->name,driver_name)) { - rc = sysfs_create_link(&my_class->p->subsys.kobj, &sysfs_node->client->dev.kobj,device_name); - if(rc) - { - pr_err("failed to create symlink %d\n",rc); - } - break; - } - } - mutex_unlock(&list_lock); - return ret; -} - - -int cs6436_54p_sysfs_delete_symlink(struct class *my_class,char * driver_name,char *device_name) -{ - struct list_head *list_node = NULL; - struct sysfs_client_node *sysfs_node = NULL; - int ret = -EPERM; - int rc = 0; - - mutex_lock(&list_lock); - list_for_each(list_node, &sysfs_client_list) - { - sysfs_node = list_entry(list_node, struct sysfs_client_node, list); - if (!strcmp(sysfs_node->client->name,driver_name)) { - sysfs_remove_link(&my_class->p->subsys.kobj,device_name); - break; - } - } - mutex_unlock(&list_lock); - return ret; -} - - -static int cs6436_54p_sysfs_open(struct inode *inode, struct file *file) -{ - return 0; -} - - - -static ssize_t cs6436_54p_sysfs_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos) -{ - char str[10],name[18],port[8]; - int ret; - int i; - memset(str, 0, sizeof(str)); - ret = copy_from_user(str, buf, count); - if (ret) - { - printk(KERN_ERR "copy_from_user fail\n"); - return -EINVAL; - } - - if(!strncmp(str,"start",5)) - { - psu_class = cs6436_54p_sysfs_create_symclass("psu"); - cs6436_54p_sysfs_create_symlink(psu_class,"cs6436_54p_psu1","psu1"); - cs6436_54p_sysfs_create_symlink(psu_class,"cs6436_54p_psu2","psu2"); - sfp_class = cs6436_54p_sysfs_create_symclass("swps"); - for(i = 1; i <= 48;i++) - { - memset(name,0xff,sizeof(name)); - memset(port,0xff,sizeof(port)); - snprintf(name,sizeof(name),"cs6436_54p_sfp%d",i); - snprintf(port,sizeof(port),"port%d",i); - cs6436_54p_sysfs_create_symlink(sfp_class,name,port); - } - } - else if(!strncmp(str,"stop",4)) - { - cs6436_54p_sysfs_delete_symlink(psu_class,"cs6436_54p_psu1","psu1"); - cs6436_54p_sysfs_delete_symlink(psu_class,"cs6436_54p_psu2","psu2"); - cs6436_54p_sysfs_delete_symclass(psu_class); - - for(i = 1; i <= 48;i++) - { - memset(name,0xff,sizeof(name)); - memset(port,0xff,sizeof(port)); - snprintf(name,sizeof(name),"cs6436_54p_sfp%d",i); - snprintf(port,sizeof(port),"port%d",i); - cs6436_54p_sysfs_delete_symlink(sfp_class,name,port); - } - cs6436_54p_sysfs_delete_symclass(sfp_class); - } - return count; -} - - -static struct file_operations cs6436_54p_sysfs_fops = { - .owner = THIS_MODULE, - .open = cs6436_54p_sysfs_open, - .write = cs6436_54p_sysfs_write, -}; - - -static int __init cs6436_54p_sysfs_init(void) -{ - int result = 0; - int err = 0; - dev_t dev = MKDEV(dev_major, 0); - - if (dev_major) - result = register_chrdev_region(dev, 1, DEVICE_NAME); - else { - result = alloc_chrdev_region(&dev, 0, 1, DEVICE_NAME); - dev_major = MAJOR(dev); - } - if (result < 0) - { - printk("unable to get major %d\n", dev_major); - err= -EINVAL; - } - printk("get major is %d\n", dev_major); - if (dev_major == 0) - dev_major = result; - - dev_cdev= kmalloc(sizeof(struct cdev), GFP_KERNEL); - if(IS_ERR(dev_cdev)) { - err= -ENOMEM; - } - - cdev_init(dev_cdev, &cs6436_54p_sysfs_fops); - dev_cdev->owner = THIS_MODULE; - dev_cdev->ops = &cs6436_54p_sysfs_fops; - err = cdev_add(dev_cdev, dev, 1); - if (err) - { - printk("error %d add fpga ", err); - goto err_malloc; - } - - dev_class = class_create(THIS_MODULE, DEVICE_NAME); - if (IS_ERR(dev_class)) - { - printk("Err:failed in creating class.\n"); - goto err_cdev_add; - } - - dev_device = device_create(dev_class, NULL, MKDEV(dev_major, 0), NULL, DEVICE_NAME); - if (IS_ERR(dev_device)) - { - printk("Err:failed in creating device.\n"); - goto err_class_crt; - } - - mutex_init(&list_lock); - - return err; - - err_class_crt: - cdev_del(dev_cdev); - err_cdev_add: - kfree(dev_cdev); - err_malloc: - unregister_chrdev_region(MKDEV(dev_major,0), 1); - - return err; - -} - -static void __exit cs6436_54p_sysfs_exit(void) -{ - cdev_del(dev_cdev); - printk("cdev_del ok\n"); - device_destroy(dev_class, MKDEV(dev_major, 0)); - - class_destroy(dev_class); - - if(dev_cdev != NULL) - kfree(dev_cdev); - - unregister_chrdev_region(MKDEV(dev_major, 0), 1); - printk("cs6436_54p_sysfs_exit...\r\n"); -} - - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs6436-54p-sysfs driver"); -MODULE_LICENSE("GPL"); - -module_init(cs6436_54p_sysfs_init); -module_exit(cs6436_54p_sysfs_exit); - - diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/service/cs6436-platform-init.service b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/service/cs6436-platform-init.service deleted file mode 100644 index ad18c2c2703..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/service/cs6436-platform-init.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Cig CS6436-54P Platform initialization service -Before=pmon.service -DefaultDependencies=no - -[Service] -Type=oneshot -ExecStart=/usr/local/bin/cig_cs6436_util.py install -ExecStop=/usr/local/bin/cig_cs6436_util.py clean -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/service/cs6436-platform-misc.service b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/service/cs6436-platform-misc.service deleted file mode 100644 index 33f99935cd9..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/service/cs6436-platform-misc.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Cig CS6436-54P Platform miscellaneous service -After=cs6436-platform-init.service -DefaultDependencies=no - -[Service] -ExecStart=/usr/local/bin/cig_cs6436_misc.py -KillSignal=SIGKILL -SuccessExitStatus=SIGKILL - -# Resource Limitations -LimitCORE=infinity - -[Install] -WantedBy=multi-user.target diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/setup.py b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/setup.py deleted file mode 100755 index 05ee2c6e36a..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/setup.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -import os -import sys -from setuptools import setup -os.listdir - -setup( - name='cs6436-54p', - version='1.0.0', - description='Module to initialize Cig CS6436-54P platforms', - - packages=['cs6436-54p'], - package_dir={'cs6436-54p': 'cs6436-54p/classes'}, - ) diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/utils/cig_cs6436_misc.py b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/utils/cig_cs6436_misc.py deleted file mode 100755 index b4627a081d7..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/utils/cig_cs6436_misc.py +++ /dev/null @@ -1,574 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2018 Cambridge, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os -import commands -import sys, getopt -import logging -import re -import time -import datetime -from collections import namedtuple -from threading import Thread - -DEBUG = False -i2c_prefix = '/sys/bus/i2c/devices/' -leds_prefix = '/sys/devices/platform/cs6436_54p_led/leds/' -fans_prefix = '/sys/devices/platform/cs6436_54p_fan/' -fansdir_prefix = fans_prefix + 'fan{}_direction' - -ageing_controlfile = '/etc/sonic/agcontrol' -AGFlag = 0 - - -platform_misc_log = '/var/log/platform_misc.log' -misclogger = logging.getLogger('platform_misc') -misclogger.setLevel(logging.INFO) -miscformatter = logging.Formatter('%(asctime)s-%(levelname)s-%(message)s') - -if not os.path.isfile(platform_misc_log): - try: - os.mknod(platform_misc_log) - except: - print 'Failed to creat platform_misc.log' - -fileHandler = logging.FileHandler(platform_misc_log) -fileHandler.setLevel(logging.INFO) -fileHandler.setFormatter(miscformatter) -misclogger.addHandler(fileHandler) - - -starttime = datetime.datetime.now() -IsGetlswt = 0 -coretemp_prefix = '/sys/class/hwmon/hwmon1/' -coretemp_ps = [] -psu1_p = '/sys/bus/i2c/devices/5-005a/psu_present' -psu2_p = '/sys/bus/i2c/devices/5-005b/psu_present' -psu1_d = '/sys/bus/i2c/devices/5-0052/psu_eeprom' -psu2_d = '/sys/bus/i2c/devices/5-0053/psu_eeprom' -psu1led_d = leds_prefix + 'cs6436_54p_led::psu1/brightness' -psu2led_d = leds_prefix + 'cs6436_54p_led::psu2/brightness' -cs6436_ledpath = {'fan':leds_prefix + 'cs6436_54p_led::fan/brightness', - 'fan1':leds_prefix + 'cs6436_54p_led::fan1/brightness', - 'fan2':leds_prefix + 'cs6436_54p_led::fan2/brightness', - 'fan3':leds_prefix + 'cs6436_54p_led::fan3/brightness', - 'fan4':leds_prefix + 'cs6436_54p_led::fan4/brightness', - 'fan5':leds_prefix + 'cs6436_54p_led::fan5/brightness', - 'psu1':leds_prefix + 'cs6436_54p_led::psu1/brightness', - 'psu2':leds_prefix + 'cs6436_54p_led::psu2/brightness', - 'sys':leds_prefix + 'cs6436_54p_led::sys/brightness'} - - -def system_read_filestr(node): - with open(node, 'r') as f: - try: - str = f.read() - except IOError as e: - misclogger.error('Failed to get node, str={}'.format(node)) - return "0" - return str - - -def system_bright_leds(dev, colour): - global AGFlag - - if AGFlag == 1: - return - - cmd = 'echo {} > {}'.format(colour, dev) - log_os_system(cmd, 1) - return - -''' -1: front in tail out -0: front out tail in -''' -def system_getpsu_direction(dev): - try: - with open(dev) as f: - f.seek(0x30) - str = f.read(2) - except IOError as e: - misclogger.error('Failed to get psu eep') - return 1 - if str == 'AA': ## front in tail out - return 1 - elif str == 'RA':## tail in front out - return 0 - else: - misclogger.error('Failed to get psu eep, str={}'.format(str)) - return -1 - - -def system_get_cputype(): - cmdretfd = os.popen("lscpu | grep 'Model name'") - retstring = cmdretfd.read() - endindex = retstring.find('@') - 1 - startindex = retstring[:endindex].rfind(' ') + 1 - cputype = retstring[startindex:endindex] - - return cputype - - -def system_init_coretemppath(): - global coretemp_ps - - cmdstr = "ls {} | grep 'input'".format(coretemp_prefix) - cmdretfd = os.popen(cmdstr) - - coretemppss = cmdretfd.read().splitlines() - if len(coretemppss) < 3: - cputype = system_get_cputype() - misclogger.error('Failed to init core temperature path.' - ' cpu type = {}, num thermal = {}'.format(cputype, len(coretemp_ps))) - return 1 - - for i in range(0,3): - coretemp_ps.append(coretemp_prefix + coretemppss[i]) - - print coretemp_ps - - return 0 - - -class cs6436_fanattr: - def __init__(self, name): - self.name = name - self.direction = 0 - self.direction_p = '' - self.rear = 0 - self.rear_p = '' - self.front = 0 - self.front_p = '' - self.fault = 0 - self.fault_p = '' - self.status = 0 - self.setpath() - self.updatedevice() - - return - - def setpath(self): - self.direction_p = fans_prefix + '{}_direction'.format(self.name) - self.rear_p = fans_prefix + '{}_rear_speed_rpm'.format(self.name) - self.front_p = fans_prefix + '{}_front_speed_rpm'.format(self.name) - self.fault_p = fans_prefix + '{}_fault'.format(self.name) - - return - - def updatedevice(self): - self.direction = int(system_read_filestr(self.direction_p)) - self.rear = int(system_read_filestr(self.rear_p)) - self.front = int(system_read_filestr(self.front_p)) - self.fault = int(system_read_filestr(self.fault_p)) - - return - - def checkspeedrpm(self, speedrpm): - frontrpmexp = speedrpm * 21000 / 100 - rearrpmexp = speedrpm * 19000 / 100 - deviationfront = abs(frontrpmexp - self.front) / float(frontrpmexp) - deviationrear = abs(rearrpmexp - self.rear) / float(rearrpmexp) - - if deviationfront < 0.3 and deviationrear < 0.3: - return 0 - else: - misclogger.error(':{} speed wrong. frontexp is {}, but rpm is {}.rearexp is {}, but rpm is {}'.format(self.name, frontrpmexp, self.front, rearrpmexp, self.rear)) - return 1 - - def checkstatus(self, speedrpm, totaldirct): - speedstatus = self.checkspeedrpm(speedrpm) - if self.direction != totaldirct: - self.status = 1 - misclogger.error(':{} direction = {}.fan direction is not ok.'.format(self.name, self.direction)) - elif speedstatus != 0: - self.status = 1 - elif self.fault != 0: - misclogger.error(':{} fault.'.format(self.name)) - self.status = 1 - else: - self.status = 0 - - if self.status == 1: - system_bright_leds(cs6436_ledpath[self.name], 3) - else: - system_bright_leds(cs6436_ledpath[self.name], 1) - - return self.status - -cs6436_fanattrnodes = [] - - -class cs6436_psuattr: - def __init__(self, name): - self.name = name - self.direction = 0 - self.direction_p = '' - self.present = 0 - self.present_p = '' - self.status = 0 - - self.setpath() - self.updatepresent() - self.updatedirection() - - return - - def setpath(self): - if self.name == 'psu1': - self.present_p = psu1_p - self.direction_p = psu1_d - if self.name == 'psu2': - self.present_p = psu2_p - self.direction_p = psu2_d - - return - - def updatepresent(self): - self.present = int(system_read_filestr(self.present_p)) - - return - - def updatedirection(self): - if self.present == 1: - self.direction = system_getpsu_direction(self.direction_p) - else: - self.direction = 2 - - return - - def checkstatus(self, totaldirct): - if self.present != 1: - self.status = 1 - misclogger.error(':{} not present.'.format(self.name)) - elif self.direction == 2: - self.status = 0 - misclogger.info(':{} direction need to be update.'.format(self.name)) - elif self.direction != totaldirct: - self.status = 1 - misclogger.info(':{} direction is wrong.'.format(self.name)) - else: - self.status = 0 - - if self.status == 1: - system_bright_leds(cs6436_ledpath[self.name], 3) - else: - system_bright_leds(cs6436_ledpath[self.name], 1) - - return self.status - -cs6436_psuattrnodes = [] - - - -def my_log(txt): - if DEBUG == True: - print "[ROY]"+txt - return - -def device_exist(): - ret1, log = log_os_system("ls "+i2c_prefix+"5-005a", 0) - ret2, log = log_os_system("ls "+i2c_prefix+"5-005b", 0) - ret3, log = log_os_system("ls "+leds_prefix+"cs6436_54p_led*", 0) - return not(ret1 or ret2 or ret3) - - -def log_os_system(cmd, show): - logging.info('Run :'+cmd) - status, output = commands.getstatusoutput(cmd) - my_log (cmd +"with result:" + str(status)) - my_log (" output:"+output) - if status: - logging.info('Failed :'+cmd) - if show: - print('Failed :'+cmd) - return status, output - - -def system_get_coretemp(): - temp1 = system_read_filestr(coretemp_ps[0]).strip() - temp2 = system_read_filestr(coretemp_ps[1]).strip() - temp3 = system_read_filestr(coretemp_ps[2]).strip() - - return int(temp1), int(temp2), int(temp3) - -def system_get_boardtemp(): - for i in range(0,16): - temp1path = "/sys/bus/i2c/devices/5-004a/hwmon/hwmon%d/temp1_input" % i - if os.access(temp1path, os.F_OK): - break - for i in range(0,16): - temp2path = "/sys/bus/i2c/devices/5-004b/hwmon/hwmon%d/temp1_input" % i - if os.access(temp2path, os.F_OK): - break - temp1 = system_read_filestr(temp1path).strip() - temp2 = system_read_filestr(temp2path).strip() - - return int(temp1), int(temp2) - - -def system_get_lswtemp(): - global IsGetlswt - global starttime - if IsGetlswt == 0: - now = datetime.datetime.now() - misclogger.info("time wait.") - misclogger.info("start = {}, now = {}.".format(starttime, now)) - if (now - starttime).seconds > 150: - misclogger.info("time = ".format((now - starttime).seconds)) - IsGetlswt = 1 - - return 25 - -# chp = subprocess.Popen("docker ps --filter name=syncd", shell=True, stdout=subprocess.PIPE) -# if chp.poll() is None: -# misclogger.info("No subp.") -# chp.kill() -# -# return 25 - -# retstring = chp.stdout.read() -# chp.kill() -# if 'Up' not in retstring: -# misclogger.info("lsw not up.") -# -# return 25 - - status, output = log_os_system('npx_diag swc show temperature', 1) - if status: - misclogger.error('failed to show lsw temperature') - - return 25 - - output = output.strip() - if output.find("it 0, temperature ") > 0: - startindex = output.find('temperature') + len('temperature') + 1 - endindex = output[startindex:].find(" ") - endindex = startindex + endindex - temp = output[startindex:endindex] - b = temp.find('.') - if b > 0: - temp=temp[:b] - temp = int(temp) - else: - misclogger.error("Failed to get temperature.") - temp = 0 - - return int(temp) - -def system_monitor_temperature(): - - ctemp1, ctemp2, ctemp3 = system_get_coretemp() - btemp1, btemp2 = system_get_boardtemp() - ltemp = system_get_lswtemp() - fan_speed_str = system_cs6436_getfanexspeed() - fan_speed = int(fan_speed_str) - policy = 'stay' - pos = 0 - #speed c1 c2 c3 b1 b2 lsw - fan_policy_up = ([30, 40000, 40000, 40000, 42000, 35000, 95], - [40, 44000, 44000, 44000, 44000, 39000, 96], - [50, 49000, 49000, 49000, 47000, 44000, 91], - [60, 52000, 52000, 52000, 51500, 47500, 92], - [70, 53000, 53000, 53000, 52000, 49000, 93], - [100,999999,999999,999999,999999,999999,999]) - - fan_policy_down=([30, 0, 0, 0, 0, 0, 0], - [40, 34000, 34000, 34000, 34000, 30000, 80], - [50, 38000, 38000, 38000, 37000, 33000, 81], - [60, 44000, 44000, 44000, 43000, 39000, 84], - [70, 44000, 44000, 44000, 43000, 40000, 84], - [100, 48000, 48000, 48000, 46000, 42000, 85],) - - for policytable in fan_policy_up: - if fan_speed <= policytable[0]: - break - pos = pos + 1 - fan_speed = policytable[0] - if (ctemp1 < policytable[1]) and (ctemp2 < policytable[2]) and (ctemp3 < policytable[3]) and (btemp1 < policytable[4]) and (btemp2 < policytable[5]) and (ltemp < policytable[6]): - policy = 'stay' - policytable = fan_policy_down[pos] - if (ctemp1 < policytable[1]) and (ctemp2 < policytable[2]) and (ctemp3 < policytable[3]) and (btemp1 < policytable[4]) and (btemp2 < policytable[5]) and (ltemp < policytable[6]): - policy = 'down' - else: - policy = 'up' - - if policy == 'up': - misclogger.info("speed = %d." % fan_speed) - misclogger.info("core1 = %d, core2 = %d, core3 = %d." % (ctemp1, ctemp2, ctemp3)) - misclogger.info("board1 = %d, board2 = %d." % (btemp1, btemp2)) - misclogger.info("lsw = %d" % ltemp) - fan_speed = fan_policy_down[pos + 1][0] - misclogger.info("fan policy: up. speedexp = {}".format(fan_speed)) - - if policy == 'stay': - fan_speed = fan_policy_down[pos] - return - - if policy == 'down': - misclogger.info("speed = %d." % fan_speed) - misclogger.info("core1 = %d, core2 = %d, core3 = %d." % (ctemp1, ctemp2, ctemp3)) - misclogger.info("board1 = %d, board2 = %d." % (btemp1, btemp2)) - misclogger.info("lsw = %d" % ltemp) - fan_speed = fan_policy_down[pos - 1][0] - misclogger.info("fan policy: down.speedexp = {}".format(fan_speed)) - - cmd = "echo {} > /sys/devices/platform/cs6436_54p_fan/fan_duty_cycle_percentage".format(fan_speed) - status, output = log_os_system(cmd, 1) - if status: - misclogger.error("set fan speed fault") - - return - - -def system_cs6436_setfanexspeed(num): - fanspeednode = fans_prefix + 'fan_duty_cycle_percentage' - numstr = str(num) - with open(fanspeednode, 'w') as f: - f.write(numstr) - - -def system_cs6436_getfanexspeed(): - fanspeednode = fans_prefix + 'fan_duty_cycle_percentage' - fanspeedstr = system_read_filestr(fanspeednode) - fanspeedexp = int(fanspeedstr) - - return fanspeedexp - - -def system_cs6436_getdirection(): - global cs6436_fanattrnodes - direction = 0 - - for fan in cs6436_fanattrnodes: - direction = direction + fan.direction - - if direction > 2: - direction = 1 - else: - direction = 0 - - return direction - - -def system_check_psusdirection(): - global cs6436_psuattrnodes - cs6436totaldirct = system_cs6436_getdirection() - psutatus = 0 - - for psu in cs6436_psuattrnodes: - psu.updatedirection() - psu.checkstatus(cs6436totaldirct) - psutatus = psu.status + psutatus - - return (psutatus != 0) - - -def system_check_psuspresent(): - global cs6436_psuattrnodes - cs6436totaldirct = system_cs6436_getdirection() - psutatus = 0 - - for psu in cs6436_psuattrnodes: - psu.updatepresent() - psu.checkstatus(cs6436totaldirct) - psutatus = psu.status + psutatus - - return (psutatus != 0) - - -def system_check_fansstate(): - global cs6436_fanattrnodes - global cs6436_ledpath - cs6436totaldirct = system_cs6436_getdirection() - fanstatus = 0 - fanexspeed = 0 - - fanexspeed = system_cs6436_getfanexspeed() - - for fan in cs6436_fanattrnodes: - fan.updatedevice() - fan.checkstatus(fanexspeed, cs6436totaldirct) - fanstatus = fanstatus + fan.status - - if fanstatus > 0: - misclogger.error(':fan error.set fans speed 100.') - system_cs6436_setfanexspeed(100) - system_bright_leds(cs6436_ledpath['fan'], 3) - else: - system_bright_leds(cs6436_ledpath['fan'], 1) - - return (fanstatus != 0) - - -def system_misc_polling(threadName,delay): - for count in range(1,5): - if device_exist() == False: - time.sleep(delay+3) - print "%s: %s, count=%d" % ( threadName, time.ctime(time.time()), count) - else: - break - - if count == 4: - return - - status, output = log_os_system("echo 1 > /sys/devices/platform/cs6436_54p_led/leds/cs6436_54p_led::sys/brightness", 1) - status, output = log_os_system("hwconfig -cfp 1", 1) - - global AGFlag - if os.access(ageing_controlfile, os.F_OK): - AGFlag = 1 - else: - AGFlag = 0 - - os.system('csw_daemon &') - - - global cs6436_fanattrnodes - global cs6436_psuattrnodes - - for num in range(1,6): - name = 'fan{}'.format(num) - fannode = cs6436_fanattr(name) - cs6436_fanattrnodes.append(fannode) - for num in range(1,3): - name = 'psu{}'.format(num) - psunode = cs6436_psuattr(name) - cs6436_psuattrnodes.append(psunode) - - tempcontrol = system_init_coretemppath() - - misclogger.info("%s: %s misc start." % ( threadName, time.ctime(time.time()))) - count = 0 - while 1: - count = count + 1 - ret = system_check_psuspresent() - ret = system_check_fansstate() - - if count % 10 == 0: - misclogger.info(": adjust fans and check psu direction.") - system_check_psusdirection() - if tempcontrol == 0: - system_monitor_temperature() - count = 0 - time.sleep(delay) - - return - -if __name__ == '__main__': - target=system_misc_polling("Thread-misc",10) - diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/utils/cig_cs6436_util.py b/platform/nephos/sonic-platform-modules-cig/cs6436-54p/utils/cig_cs6436_util.py deleted file mode 100755 index 81e6bb7c0b6..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-54p/utils/cig_cs6436_util.py +++ /dev/null @@ -1,565 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2018 Cambridge, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -""" -Usage: %(scriptName)s [options] command object - -options: - -h | --help : this help message - -d | --debug : run with debug mode - -f | --force : ignore error during installation or clean -command: - install : install drivers and generate related sysfs nodes - clean : uninstall drivers and remove related sysfs nodes - show : show all systen status - sff : dump SFP eeprom - set : change board setting with fan|led|sfp -""" - -import os -import commands -import sys, getopt -import logging -import re -import time -from collections import namedtuple - - - - -PROJECT_NAME = 'cs6436_54p' -version = '0.1.1' -verbose = False -DEBUG = False -args = [] -ALL_DEVICE = {} -DEVICE_NO = {'led':9, 'fan':5, 'thermal':4, 'psu':2, 'sfp':54} -FORCE = 0 -CPU_TYPE = 'C3308' - - -if DEBUG == True: - print sys.argv[0] - print 'ARGV :', sys.argv[1:] - - -def main(): - global DEBUG - global args - global FORCE - - if len(sys.argv)<2: - show_help() - - options, args = getopt.getopt(sys.argv[1:], 'hdf', ['help', - 'debug', - 'force', - ]) - if DEBUG == True: - print options - print args - print len(sys.argv) - - for opt, arg in options: - if opt in ('-h', '--help'): - show_help() - elif opt in ('-d', '--debug'): - DEBUG = True - logging.basicConfig(level=logging.INFO) - elif opt in ('-f', '--force'): - FORCE = 1 - else: - logging.info('no option') - for arg in args: - if arg == 'install': - do_install() - elif arg == 'clean': - do_uninstall() - elif arg == 'show': - device_traversal() - elif arg == 'sff': - if len(args)!=2: - show_eeprom_help() - elif int(args[1]) ==0 or int(args[1]) > DEVICE_NO['sfp']: - show_eeprom_help() - else: - show_eeprom(args[1]) - return - elif arg == 'set': - if len(args)<3: - show_set_help() - else: - set_device(args[1:]) - return - else: - show_help() - - - return 0 - -def show_help(): - print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]} - sys.exit(0) - -def show_set_help(): - cmd = sys.argv[0].split("/")[-1]+ " " + args[0] - print cmd +" [led|sfp|fan]" - print " use \""+ cmd + " led 0-4 \" to set led color" - print " use \""+ cmd + " fan 0-100\" to set fan duty percetage" - print " use \""+ cmd + " sfp 1-54 {0|1}\" to set sfp# tx_disable" - sys.exit(0) - -def show_eeprom_help(): - cmd = sys.argv[0].split("/")[-1]+ " " + args[0] - print " use \""+ cmd + " 1-54 \" to dump sfp# eeprom" - sys.exit(0) - -def my_log(txt): - if DEBUG == True: - print "[ROY]"+txt - return - -def log_os_system(cmd, show): - logging.info('Run :'+cmd) - status, output = commands.getstatusoutput(cmd) - my_log (cmd +"with result:" + str(status)) - my_log (" output:"+output) - if status: - logging.info('Failed :'+cmd) - if show: - print('Failed :'+cmd) - return status, output - -def driver_check(): - for count in range(1,5): - time.sleep(1) - ret, lsmod = log_os_system("lsmod| grep i2c_i801", 0) - if len(lsmod) > 2: - log_os_system("rmmod i2c_i801", 0) - break - - ret, lsmod = log_os_system("lsmod| grep i2c_designware_platform", 0) - if len(lsmod) > 2: - log_os_system("rmmod i2c_designware_platform", 0) - log_os_system("modprobe i2c-designware-platform", 0) - - ret, lsmod = log_os_system("lsmod| grep cig", 0) - logging.info('mods:'+lsmod) - if len(lsmod) ==0: - return False - return True - - - -kos = [ - 'depmod', - 'modprobe i2c_dev', - 'modprobe i2c_mux_pca954x force_deselect_on_exit=1', - 'modprobe x86-64-cig-cs6436-54p-sysfs ' , - 'modprobe x86-64-cig-cs6436-54p-cpld ' , - 'modprobe x86-64-cig-cs6436-54p-fan' , - 'modprobe x86-64-cig-cs6436-54p-psu' , - 'modprobe x86-64-cig-cs6436-54p-sfp' , - 'modprobe x86-64-cig-cs6436-54p-led' ] - -def driver_install(): - global FORCE - - for i in range(0,len(kos)): - if i == 4: - ret, CPU_TYPE = log_os_system("cat /proc/cpuinfo | grep \"model name\" | cut -b 32-39 | head -n 1", 0) - if CPU_TYPE=='i3-6100U': - kos[i] =kos[i] + 'board_id=1' - ret, CPU_TYPE = log_os_system("cat /proc/cpuinfo | grep \"model name\" | cut -b 36-40 | head -n 1", 0) - if CPU_TYPE=='C3758' or CPU_TYPE=='C3308': - kos[i] =kos[i] + 'board_id=2' - - status, output = log_os_system(kos[i], 1) - if status: - if FORCE == 0: - return status - return 0 - -def driver_uninstall(): - global FORCE - for i in range(0,len(kos)): - rm = kos[-(i+1)].replace("modprobe", "modprobe -rq") - rm = rm.replace("insmod", "rmmod") - status, output = log_os_system(rm, 1) - if status: - if FORCE == 0: - return status - return 0 - -led_prefix ='/sys/class/leds/'+PROJECT_NAME+'_led::' -hwmon_types = {'led': ['sys','fan','fan1','fan2','fan3','fan4','fan5','psu1','psu2']} -hwmon_nodes = {'led': ['brightness'] } -hwmon_prefix ={'led': led_prefix} - -i2c_prefix = '/sys/bus/i2c/devices/' -i2c_bus = {'thermal': ['4-0048','4-0049', '5-004a', '5-004b'] , - 'psu': ['5-005a','5-005b'], - 'sfp': ['-0050']} -i2c_nodes = {'thermal': ['hwmon/hwmon*/temp1_input'] , - 'psu': ['psu_present ', 'psu_power_good'] , - 'sfp': ['sfp_is_present ', 'sfp_tx_disable']} - -fan_prefix ='/sys/bus/platform/devices/'+PROJECT_NAME+'_fan' -fan_types = {'fan': ['fan1','fan2', 'fan3', 'fan4', 'fan5']} -fan_nodes = {'fan': ['state', 'front_speed_rpm', 'rear_speed_rpm', 'fault']} - - -sfp_map = [8,9,10,11,12,13,14,15,16, - 17,18,19,20,21,22,23,24,25,26, - 27,28,29,30,31,32,33,34,35,36, - 37,38,39,40,41,42,43,44,45,46, - 47,48,49,50,51,52,53,54,55,56, - 57,60,61,62,63] - -mknod =[ - 'echo pca9548 0x71 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo pca9548 0x73 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo pca9548 0x74 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo pca9548 0x75 > /sys/bus/i2c/devices/i2c-3/new_device', - 'echo pca9548 0x76 > /sys/bus/i2c/devices/i2c-3/new_device', - 'echo pca9548 0x77 > /sys/bus/i2c/devices/i2c-3/new_device', - 'echo lm75 0x48 > /sys/bus/i2c/devices/i2c-4/new_device', - 'echo lm75 0x49 > /sys/bus/i2c/devices/i2c-4/new_device', - 'echo lm75 0x4a > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo lm75 0x4b > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo cs6436_54p_psu1 0x5a > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo cs6436_54p_psu2 0x5b > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo cs6436_54p_psu1 0x52 > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo cs6436_54p_psu2 0x53 > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo 24c128 0x57 > /sys/bus/i2c/devices/i2c-7/new_device'] - -port = 0 - -def device_install(): - global FORCE - global port - - for i in range(0,len(mknod)): - #all nodes need times to built new i2c buses - time.sleep(1) - - status, output = log_os_system(mknod[i], 1) - if status: - print output - if FORCE == 0: - return status - - for i in range(0,len(sfp_map)): - if (i == 50): - port = port + 3 - else: - port = port + 1 - - - status, output =log_os_system("echo cs6436_54p_sfp"+str(port)+" 0x50 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1) - if status: - print output - if FORCE == 0: - return status - - if port <= 48: - status, output =log_os_system("echo cs6436_54p_sfp"+str(port)+" 0x51 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1) - if status: - print output - if FORCE == 0: - return status - - return - -def device_uninstall(): - global FORCE - - for i in range(0,len(sfp_map)): - target = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/delete_device" - status, output =log_os_system("echo 0x50 > "+ target, 1) - if status: - print output - if FORCE == 0: - return status - - nodelist = mknod - - for i in range(len(nodelist)): - target = nodelist[-(i+1)] - temp = target.split() - del temp[1] - temp[-1] = temp[-1].replace('new_device', 'delete_device') - status, output = log_os_system(" ".join(temp), 1) - if status: - print output - if FORCE == 0: - return status - - return - -def system_ready(): - if driver_check() == False: - return False - if not device_exist(): - return False - return True - -def do_install(): - print "Checking system...." - if driver_check() == False: - print "No driver, installing...." - status = driver_install() - if status: - if FORCE == 0: - return status - else: - print PROJECT_NAME.upper()+" drivers detected...." - if not device_exist(): - print "No device, installing...." - status = device_install() - if status: - if FORCE == 0: - return status - else: - print PROJECT_NAME.upper()+" devices detected...." - return - -def do_uninstall(): - print "Checking system...." - if not device_exist(): - print PROJECT_NAME.upper() +" has no device installed...." - else: - print "Removing device...." - status = device_uninstall() - if status: - if FORCE == 0: - return status - - if driver_check()== False : - print PROJECT_NAME.upper() +" has no driver installed...." - else: - print "Removing installed driver...." - status = driver_uninstall() - if status: - if FORCE == 0: - return status - - return - -def devices_info(): - global DEVICE_NO - global ALL_DEVICE - global i2c_bus, hwmon_types, fan_types - for key in DEVICE_NO: - ALL_DEVICE[key]= {} - for i in range(0,DEVICE_NO[key]): - ALL_DEVICE[key][key+str(i+1)] = [] - - for key in i2c_bus: - buses = i2c_bus[key] - nodes = i2c_nodes[key] - for i in range(0,len(buses)): - for j in range(0,len(nodes)): - if 'sfp' == key: - for k in range(0,DEVICE_NO[key]): - node = key+str(k+1) - path = i2c_prefix+ str(sfp_map[k])+ buses[i]+"/"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][node].append(path) - else: - node = key+str(i+1) - path = i2c_prefix+ buses[i]+"/"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][node].append(path) - - for key in hwmon_types: - itypes = hwmon_types[key] - nodes = hwmon_nodes[key] - for i in range(0,len(itypes)): - for j in range(0,len(nodes)): - node = key+"_"+itypes[i] - path = hwmon_prefix[key]+ itypes[i]+"/"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][ key+str(i+1)].append(path) - - for key in fan_types: - itypes = fan_types[key] - nodes = fan_nodes[key] - for i in range(0,len(itypes)): - for j in range(0,len(nodes)): - node = key+"_"+itypes[i] - path = fan_prefix+"/"+ itypes[i]+"_"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][ key+str(i+1)].append(path) - - #show dict all in the order - if DEBUG == True: - for i in sorted(ALL_DEVICE.keys()): - print(i+": ") - for j in sorted(ALL_DEVICE[i].keys()): - print(" "+j) - for k in (ALL_DEVICE[i][j]): - print(" "+" "+k) - return - -def show_eeprom(index): - if system_ready()==False: - print("System's not ready.") - print("Please install first!") - return - - if len(ALL_DEVICE)==0: - devices_info() - node = ALL_DEVICE['sfp'] ['sfp'+str(index)][0] - node = node.replace(node.split("/")[-1], 'sfp_eeprom') - # check if got hexdump command in current environment - ret, log = log_os_system("which hexdump", 0) - ret, log2 = log_os_system("which busybox hexdump", 0) - if len(log): - hex_cmd = 'hexdump' - elif len(log2): - hex_cmd = ' busybox hexdump' - else: - log = 'Failed : no hexdump cmd!!' - logging.info(log) - print log - return 1 - - print node + ":" - ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1) - if ret==0: - print log - else: - print "**********device no found**********" - return - -def set_device(args): - global DEVICE_NO - global ALL_DEVICE - if system_ready()==False: - print("System's not ready.") - print("Please install first!") - return - - if len(ALL_DEVICE)==0: - devices_info() - - if args[0]=='led': - if int(args[1])>4: - show_set_help() - return - #print ALL_DEVICE['led'] - for i in range(0,len(ALL_DEVICE['led'])): - for k in (ALL_DEVICE['led']['led'+str(i+1)]): - ret, log = log_os_system("echo "+args[1]+" >"+k, 1) - if ret: - return ret - elif args[0]=='fan': - if int(args[1])>100: - show_set_help() - return - #print ALL_DEVICE['fan'] - #fan1~6 is all fine, all fan share same setting - node = ALL_DEVICE['fan'] ['fan1'][0] - node = node.replace(node.split("/")[-1], 'fan_duty_cycle_percentage') - ret, log = log_os_system("cat "+ node, 1) - if ret==0: - print ("Previous fan duty: " + log.strip() +"%") - ret, log = log_os_system("echo "+args[1]+" >"+node, 1) - if ret==0: - print ("Current fan duty: " + args[1] +"%") - return ret - elif args[0]=='sfp': - if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0: - show_set_help() - return - if len(args)<2: - show_set_help() - return - - if int(args[2])>1: - show_set_help() - return - - #print ALL_DEVICE[args[0]] - for i in range(0,len(ALL_DEVICE[args[0]])): - for j in ALL_DEVICE[args[0]][args[0]+str(args[1])]: - if j.find('tx_disable')!= -1: - ret, log = log_os_system("echo "+args[2]+" >"+ j, 1) - if ret: - return ret - - return - -def get_value(input): - digit = re.findall('\d+', input) - return int(digit[0]) - - -def get_ledname(ledx): - name_table={'led1':'SYS','led2':'FSTUS','led3':'FAN1','led4':'FAN2','led5':'FAN3','led6':'FAN4','led7':'FAN5','led8':'PSU1','led9':'PSU2'} - if name_table.has_key(ledx): - name = name_table[ledx] - else: - name = ledx - return name - - -def device_traversal(): - if system_ready()==False: - print("System's not ready.") - print("Please install first!") - return - - if len(ALL_DEVICE)==0: - devices_info() - for i in sorted(ALL_DEVICE.keys()): - print("============================================") - print(i.upper()+": ") - print("============================================") - - for j in sorted(ALL_DEVICE[i].keys(), key=get_value): - nwnamex = get_ledname(j) - if nwnamex == j: - print " "+j+":", - else: - print " "+nwnamex+":", - for k in (ALL_DEVICE[i][j]): - ret, log = log_os_system("cat "+k, 0) - func = k.split("/")[-1].strip() - func = re.sub(j+'_','',func,1) - func = re.sub(i.lower()+'_','',func,1) - if ret==0: - print func+"="+log+" ", - else: - print func+"="+"X"+" ", - print - print("----------------------------------------------------------------") - - - print - return - -def device_exist(): - ret1, log = log_os_system("ls "+i2c_prefix+"*0077", 0) - ret2, log = log_os_system("ls "+i2c_prefix+"i2c-3", 0) - return not(ret1 or ret2) - - -if __name__ == "__main__": - main() diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/classes/__init__.py b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/classes/__init__.py deleted file mode 100755 index e69de29bb2d..00000000000 diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/classes/fanutil.py b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/classes/fanutil.py deleted file mode 100755 index e69de29bb2d..00000000000 diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/classes/thermalutil.py b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/classes/thermalutil.py deleted file mode 100755 index e69de29bb2d..00000000000 diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/Makefile b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/Makefile deleted file mode 100644 index b0b4f1f7df0..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -obj-m :=x86-64-cig-cs6436-56p-sysfs.o \ - x86-64-cig-cs6436-56p-cpld.o \ - x86-64-cig-cs6436-56p-fan.o \ - x86-64-cig-cs6436-56p-led.o \ - x86-64-cig-cs6436-56p-psu.o \ - x86-64-cig-cs6436-56p-sfp.o diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/i2c-algo-lpc.h b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/i2c-algo-lpc.h deleted file mode 100644 index 9f1acd52ea6..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/i2c-algo-lpc.h +++ /dev/null @@ -1,222 +0,0 @@ -/* -------------------------------------------------------------------- - - * A hwmon driver for the CIG cs6436-56P - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* -------------------------------------------------------------------- */ - -#ifndef I2C_LPC_H -#define I2C_LPC_H 1 - -/* ----- Control register bits ---------------------------------------- */ -#define I2C_LPC_PIN 0x80 -#define I2C_LPC_ESO 0x40 -#define I2C_LPC_ES1 0x20 -#define I2C_LPC_ES2 0x10 -#define I2C_LPC_ENI 0x08 - -#define I2C_LPC_STO 0x40 -#define I2C_LPC_ACK 0x01 - -/*command register*/ -#define I2C_LPC_STA 0x80 -#define I2C_LPC_ABT 0x40 - -/*status register*/ -#define I2C_LPC_TBE 0x02 -#define I2C_LPC_IBB 0x80 -#define I2C_LPC_RBF 0x01 -#define I2C_LPC_TD 0x08 - -#define I2C_LPC_START I2C_LPC_STA -#define I2C_LPC_STOP I2C_LPC_STO -#define I2C_LPC_REPSTART I2C_LPC_STA -#define I2C_LPC_IDLE - -/* ----- Status register bits ----------------------------------------- */ -/*#define I2C_LPC_PIN 0x80 as above*/ - -#define I2C_LPC_INI 0x40 /* 1 if not initialized */ -#define I2C_LPC_STS 0x20 -#define I2C_LPC_BER 0x10 -#define I2C_LPC_AD0 0x08 -#define I2C_LPC_LRB 0x08 -#define I2C_LPC_AAS 0x04 -#define I2C_LPC_LAB 0x02 -#define I2C_LPC_BB 0x80 - -/* ----- Chip clock frequencies --------------------------------------- */ -#define I2C_LPC_CLK3 0x00 -#define I2C_LPC_CLK443 0x10 -#define I2C_LPC_CLK6 0x14 -#define I2C_LPC_CLK 0x18 -#define I2C_LPC_CLK12 0x1c - -/* ----- transmission frequencies ------------------------------------- */ -#define I2C_LPC_TRNS90 0x00 /* 90 kHz */ -#define I2C_LPC_TRNS45 0x01 /* 45 kHz */ -#define I2C_LPC_TRNS11 0x02 /* 11 kHz */ -#define I2C_LPC_TRNS15 0x03 /* 1.5 kHz */ - - -#define I2C_LPC_OWNADR 0 -#define I2C_LPC_INTREG I2C_LPC_ES2 -#define I2C_LPC_CLKREG I2C_LPC_ES1 - -#define I2C_LPC_REG_TEST 0x01 -#define I2C_LPC_REG_BUS_SEL 0x80 -#define I2C_LPC_REG_DEVICE_ADDR 0x81 -#define I2C_LPC_REG_BYTE_COUNT 0x83 -#define I2C_LPC_REG_COMMAND 0x84 -#define I2C_LPC_REG_STATUS 0x85 -#define I2C_LPC_REG_DATA_RX1 0x86 -#define I2C_LPC_REG_DATA_RX2 0x87 -#define I2C_LPC_REG_DATA_RX3 0x88 -#define I2C_LPC_REG_DATA_RX4 0x89 -#define I2C_LPC_REG_DATA_TX1 0x8a -#define I2C_LPC_REG_DATA_TX2 0x8b -#define I2C_LPC_REG_DATA_TX3 0x8c -#define I2C_LPC_REG_DATA_TX4 0x8d - - -#define ADDR_REG_SFP_STATUS_ADDR 0X62 //reg addr +R/W# //1031 -#define ADDR_REG_SFP_STATUS_TX 0X63 // write data -#define ADDR_REG_SFP_STATUS_RX 0X64 //read data -#define ADDR_REG_SFP_STATUS_COMMAND 0X65 //cmd bit7=1,go -#define ADDR_REG_SFP_STATUS_STATUS 0X66 //status - -#define CPLD_MASTER_INTERRUPT_STATUS_REG 0x20 -#define CPLD_MASTER_INTERRUPT_MASK_REG 0x21 -#define CPLD_MASTER_INTERRUPT_ALL 0x3f -#define CPLD_MASTER_INTERRUPT_CPLD2 0x20 -#define CPLD_MASTER_INTERRUPT_CPLD1 0x10 -#define CPLD_MASTER_INTERRUPT_PSU2 0x08 -#define CPLD_MASTER_INTERRUPT_PSU1 0x04 -#define CPLD_MASTER_INTERRUPT_6320 0x02 -#define CPLD_MASTER_INTERRUPT_LSW 0x01 - - - -#define CPLD_SLAVE1_INTERRUPT_STATUS_L_REG 0x20 -#define CPLD_SLAVE1_INTERRUPT_STATUS_H_REG 0x21 -#define CPLD_SLAVE2_INTERRUPT_STATUS_L_REG 0x22 -#define CPLD_SLAVE2_INTERRUPT_STATUS_H_REG 0x23 -#define CPLD_SLAVE1_INTERRUPT_MASK_REG 0x24 -#define CPLD_SLAVE2_INTERRUPT_MASK_REG 0x25 - - -#define CPLD_SLAVE1_PRESENT08_REG 0x01 -#define CPLD_SLAVE1_PRESENT16_REG 0x02 -#define CPLD_SLAVE1_PRESENT24_REG 0x03 -#define CPLD_SLAVE2_PRESENT32_REG 0x04 -#define CPLD_SLAVE2_PRESENT40_REG 0x05 -#define CPLD_SLAVE2_PRESENT48_REG 0x06 - -#define CPLD_SLAVE1_RX_LOST08_REG 0x07 -#define CPLD_SLAVE1_RX_LOST16_REG 0x08 -#define CPLD_SLAVE1_RX_LOST24_REG 0x09 -#define CPLD_SLAVE2_RX_LOST32_REG 0x0a -#define CPLD_SLAVE2_RX_LOST40_REG 0x0b -#define CPLD_SLAVE2_RX_LOST48_REG 0x0c - -#define CPLD_SLAVE1_TX_FAULT08_REG 0x0d -#define CPLD_SLAVE1_TX_FAULT16_REG 0x0e -#define CPLD_SLAVE1_TX_FAULT24_REG 0x0f -#define CPLD_SLAVE2_TX_FAULT32_REG 0x10 -#define CPLD_SLAVE2_TX_FAULT40_REG 0x11 -#define CPLD_SLAVE2_TX_FAULT48_REG 0x12 - -#define CPLD_SLAVE2_PRESENT56_REG 0x19 -#define CPLD_SLAVE2_QSFP_CR56_REG 0x1a - - -#define CPLD_SLAVE1_INTERRUPT_PRESENT08 0x0001 -#define CPLD_SLAVE1_INTERRUPT_PRESENT16 0x0002 -#define CPLD_SLAVE1_INTERRUPT_PRESENT24 0x0004 -#define CPLD_SLAVE2_INTERRUPT_PRESENT32 0x0001 -#define CPLD_SLAVE2_INTERRUPT_PRESENT40 0x0002 -#define CPLD_SLAVE2_INTERRUPT_PRESENT48 0x0004 - -#define CPLD_SLAVE2_INTERRUPT_QSFP_CR56 0x0200 -#define CPLD_SLAVE2_INTERRUPT_PRESENT56 0x0400 - -#define CPLD_SLAVE1_INTERRUPT_RX_LOST08 0x0008 -#define CPLD_SLAVE1_INTERRUPT_RX_LOST16 0x0010 -#define CPLD_SLAVE1_INTERRUPT_RX_LOST24 0x0020 -#define CPLD_SLAVE2_INTERRUPT_RX_LOST32 0x0008 -#define CPLD_SLAVE2_INTERRUPT_RX_LOST40 0x0010 -#define CPLD_SLAVE2_INTERRUPT_RX_LOST48 0x0020 - -#define CPLD_SLAVE1_INTERRUPT_TX_FAULT08 0x0040 -#define CPLD_SLAVE1_INTERRUPT_TX_FAULT16 0x0080 -#define CPLD_SLAVE1_INTERRUPT_TX_FAULT24 0x0100 -#define CPLD_SLAVE2_INTERRUPT_TX_FAULT32 0x0040 -#define CPLD_SLAVE2_INTERRUPT_TX_FAULT40 0x0080 -#define CPLD_SLAVE2_INTERRUPT_TX_FAULT48 0x0100 - - - - - - - -#define WAIT_TIME_OUT_COUNT 100 - - -struct i2c_algo_lpc_data { - void *data; /* private data for lolevel routines */ - void (*setlpc) (void *data, int ctl, int val); - int (*getlpc) (void *data, int ctl); - int (*getown) (void *data); - int (*getclock) (void *data); - void (*waitforpin) (void *data); - - int (*xfer_begin) (void *data); - int (*xfer_end) (void *data); - - /* Multi-master lost arbitration back-off delay (msecs) - * This should be set by the bus adapter or knowledgable client - * if bus is multi-mastered, else zero - */ - unsigned long lab_mdelay; -}; - - -struct subsys_private { - struct kset subsys; - struct kset *devices_kset; - struct list_head interfaces; - struct mutex mutex; - - struct kset *drivers_kset; - struct klist klist_devices; - struct klist klist_drivers; - struct blocking_notifier_head bus_notifier; - unsigned int drivers_autoprobe:1; - struct bus_type *bus; - - struct kset glue_dirs; - struct class *class; -}; - -void cs6436_56p_sysfs_add_client(struct i2c_client *client); -void cs6436_56p_sysfs_remove_client(struct i2c_client *client); - - -#endif /* I2C_LPC8584_H */ diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/i2c-algo-lpc2iic.h b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/i2c-algo-lpc2iic.h deleted file mode 100644 index 6963bef734f..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/i2c-algo-lpc2iic.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -------------------------------------------------------------------- - - * A hwmon driver for the CIG cs6436-56P - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* -------------------------------------------------------------------- */ - - -#ifndef _LINUX_I2C_ALGO_LPC_H -#define _LINUX_I2C_ALGO_LPC_H - -struct i2c_algo_lpc_data { - void *data; /* private data for lolevel routines */ - void (*setlpc) (void *data, int ctl, int val); - int (*getlpc) (void *data, int ctl); - int (*getown) (void *data); - int (*getclock) (void *data); - void (*waitforpin) (void *data); - - int (*xfer_begin) (void *data); - int (*xfer_end) (void *data); - - /* Multi-master lost arbitration back-off delay (msecs) - * This should be set by the bus adapter or knowledgable client - * if bus is multi-mastered, else zero - */ - unsigned long lab_mdelay; -}; - -int lpc_add_iic_bus(struct i2c_adapter * adap, unsigned int id); - -#endif /* _LINUX_I2C_ALGO_LPC_H */ diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-cpld.c b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-cpld.c deleted file mode 100644 index dcff94085f0..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-cpld.c +++ /dev/null @@ -1,2204 +0,0 @@ -/* - * A hwmon driver for the CIG cs6436-56P CPLD - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "i2c-algo-lpc.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef CPLD_USER -# include -#else -# include -#endif - -#include -#include -#include -#include -#include -#include -#include - - - - - -/********************************************** Start ********************************************************/ - -/* - * ISA bus. - */ - -static void platform_isa_bus_release(struct device * dev) -{ - return ; -} - - -static struct device isa_bus = { - .init_name = "lpc-isa", - .release = platform_isa_bus_release, -}; - -struct isa_dev { - struct device dev; - struct device *next; - unsigned int id; -}; - -#define to_isa_dev(x) container_of((x), struct isa_dev, dev) - -static int isa_bus_match(struct device *dev, struct device_driver *driver) -{ - struct isa_driver *isa_driver = to_isa_driver(driver); - - if (dev->platform_data == isa_driver) { - if (!isa_driver->match || - isa_driver->match(dev, to_isa_dev(dev)->id)) - return 1; - dev->platform_data = NULL; - } - return 0; -} - -static int isa_bus_probe(struct device *dev) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->probe) - return isa_driver->probe(dev, to_isa_dev(dev)->id); - - return 0; -} - -static int isa_bus_remove(struct device *dev) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->remove) - return isa_driver->remove(dev, to_isa_dev(dev)->id); - - return 0; -} - -static void isa_bus_shutdown(struct device *dev) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->shutdown) - isa_driver->shutdown(dev, to_isa_dev(dev)->id); -} - -static int isa_bus_suspend(struct device *dev, pm_message_t state) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->suspend) - return isa_driver->suspend(dev, to_isa_dev(dev)->id, state); - - return 0; -} - -static int isa_bus_resume(struct device *dev) -{ - struct isa_driver *isa_driver = dev->platform_data; - - if (isa_driver->resume) - return isa_driver->resume(dev, to_isa_dev(dev)->id); - - return 0; -} - -static struct bus_type isa_bus_type = { - .name = "lpc-isa", - .match = isa_bus_match, - .probe = isa_bus_probe, - .remove = isa_bus_remove, - .shutdown = isa_bus_shutdown, - .suspend = isa_bus_suspend, - .resume = isa_bus_resume -}; - -static void isa_dev_release(struct device *dev) -{ - kfree(to_isa_dev(dev)); -} - -void lpc_unregister_driver(struct isa_driver *isa_driver) -{ - struct device *dev = isa_driver->devices; - - while (dev) { - struct device *tmp = to_isa_dev(dev)->next; - device_unregister(dev); - dev = tmp; - } - driver_unregister(&isa_driver->driver); -} - - -int lpc_register_driver(struct isa_driver *isa_driver, unsigned int ndev) -{ - int error; - unsigned int id; - - isa_driver->driver.bus = &isa_bus_type; - isa_driver->devices = NULL; - - error = driver_register(&isa_driver->driver); - if (error) - return error; - - for (id = 0; id < ndev; id++) { - struct isa_dev *isa_dev; - - isa_dev = kzalloc(sizeof *isa_dev, GFP_KERNEL); - if (!isa_dev) { - error = -ENOMEM; - break; - } - - isa_dev->dev.parent = &isa_bus; - isa_dev->dev.bus = &isa_bus_type; - - dev_set_name(&isa_dev->dev, "%s.%u", - isa_driver->driver.name, id); - isa_dev->dev.platform_data = isa_driver; - isa_dev->dev.release = isa_dev_release; - isa_dev->id = id; - - isa_dev->dev.coherent_dma_mask = DMA_BIT_MASK(24); - isa_dev->dev.dma_mask = &isa_dev->dev.coherent_dma_mask; - - error = device_register(&isa_dev->dev); - if (error) { - put_device(&isa_dev->dev); - break; - } - - if (isa_dev->dev.platform_data) { - isa_dev->next = isa_driver->devices; - isa_driver->devices = &isa_dev->dev; - } else - device_unregister(&isa_dev->dev); - } - - if (!error && !isa_driver->devices) - error = -ENODEV; - - if (error) - isa_unregister_driver(isa_driver); - - return error; -} - - -int lpc_bus_init(void) -{ - int error; - - error = bus_register(&isa_bus_type); - if (!error) { - error = device_register(&isa_bus); - if (error) - bus_unregister(&isa_bus_type); - } - return error; -} - -void lpc_bus_exit(void) -{ - - device_unregister(&isa_bus); - - bus_unregister(&isa_bus_type); -} - - -/********************************************** End ********************************************************/ - - - - - - -/********************************************** Start ********************************************************/ -/* - * module parameters: - */ -static int i2c_debug = 0; -static struct mutex lpc_lock; - - -#define DEB2(x) if (i2c_debug == 2) x -#define DEB3(x) if (i2c_debug == 3) x - /* print several statistical values */ -#define DEBPROTO(x) if (i2c_debug == 9) x; - /* debug the protocol by showing transferred bits */ -#define DEF_TIMEOUT 160 - - - -/* setting states on the bus with the right timing: */ - -#define set_lpc(adap, ctl, val) adap->setlpc(adap->data, ctl, val) -#define get_lpc(adap, ctl) adap->getlpc(adap->data, ctl) -#define get_own(adap) adap->getown(adap->data) -#define get_clock(adap) adap->getclock(adap->data) -#define i2c_outaddr(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DEVICE_ADDR, val) - -#define i2c_outbyte1(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DATA_TX1, val) -#define i2c_outbyte2(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DATA_TX2, val) -#define i2c_outbyte3(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DATA_TX3, val) -#define i2c_outbyte4(adap, val) adap->setlpc(adap->data, I2C_LPC_REG_DATA_TX4, val) -#define i2c_inbyte1(adap) adap->getlpc(adap->data, I2C_LPC_REG_DATA_RX1) -#define i2c_inbyte2(adap) adap->getlpc(adap->data, I2C_LPC_REG_DATA_RX2) -#define i2c_inbyte3(adap) adap->getlpc(adap->data, I2C_LPC_REG_DATA_RX3) -#define i2c_inbyte4(adap) adap->getlpc(adap->data, I2C_LPC_REG_DATA_RX4) - - - -#define LPC_FPRINTF_LOG_PATH "/tmp/file.log" -struct file *lpc_fprintf_file = NULL; - -static int lpc_fprintf_debug(const char *fmt, ...) -{ - char lpc_fprintf_buf[256]={0}; - struct va_format vaf; - va_list args; - int r; - mm_segment_t old_fs; - struct timeval tv; - struct rtc_time tm; - - do_gettimeofday(&tv); - - rtc_time_to_tm(tv.tv_sec,&tm); - - va_start(args, fmt); - vaf.fmt = fmt; - vaf.va = &args; - r=snprintf(lpc_fprintf_buf,sizeof(lpc_fprintf_buf),"[%04d.%08d] %pV\n",tm.tm_sec, (int)tv.tv_usec, &vaf); - va_end(args); - old_fs = get_fs(); - set_fs(KERNEL_DS); - vfs_write(lpc_fprintf_file, (char *)&lpc_fprintf_buf, strlen(lpc_fprintf_buf), &lpc_fprintf_file->f_pos); - set_fs(old_fs); - memset(lpc_fprintf_buf,0x0,sizeof(lpc_fprintf_buf)); - return r; - -} - - - -static int lpc_fprintf_init(void) -{ - printk("lpc_fprintf_init.\n"); - - if(lpc_fprintf_file == NULL) - lpc_fprintf_file = filp_open(LPC_FPRINTF_LOG_PATH, O_RDWR | O_APPEND | O_CREAT, 0644); - - if (IS_ERR(lpc_fprintf_file)) { - printk("Error occured while opening file %s, exiting...\n", LPC_FPRINTF_LOG_PATH); - return -1; - } - - return 0; -} - -static int lpc_fprintf_exit(void) -{ - printk("lpc_fprintf_exit.\n"); - - if(lpc_fprintf_file != NULL) - filp_close(lpc_fprintf_file, NULL); - - return 0; -} - - -/* other auxiliary functions */ - - -void print_reg(struct i2c_algo_lpc_data *adap) -{ - unsigned char status; - DEBPROTO(lpc_fprintf_debug("================================================\n");) - status = get_lpc(adap, I2C_LPC_REG_BUS_SEL); - DEBPROTO(lpc_fprintf_debug("%s select reg %x : %x\n",__func__,I2C_LPC_REG_BUS_SEL, status);) - status = get_lpc(adap, I2C_LPC_REG_BYTE_COUNT); - DEBPROTO(lpc_fprintf_debug("%s count reg %x : %x\n",__func__,I2C_LPC_REG_BYTE_COUNT, status);) - - status = get_lpc(adap, I2C_LPC_REG_COMMAND); - DEBPROTO(lpc_fprintf_debug("%s command reg %x : %x\n",__func__,I2C_LPC_REG_COMMAND, status);) - status = get_lpc(adap, I2C_LPC_REG_DEVICE_ADDR); - DEBPROTO(lpc_fprintf_debug("%s address reg %x : %x\n",__func__,I2C_LPC_REG_DEVICE_ADDR, status);) - - status = get_lpc(adap, I2C_LPC_REG_STATUS); - DEBPROTO(lpc_fprintf_debug("%s status reg %x : %x\n",__func__,I2C_LPC_REG_STATUS, status);) -} - - - -static void i2c_repstart(struct i2c_algo_lpc_data *adap) -{ - DEBPROTO(lpc_fprintf_debug("%s :\n",__func__);) - set_lpc(adap, I2C_LPC_REG_COMMAND, I2C_LPC_REPSTART); -} - -static void i2c_stop(struct i2c_algo_lpc_data *adap) -{ - DEBPROTO(lpc_fprintf_debug("%s :\n",__func__);) - set_lpc(adap, I2C_LPC_REG_COMMAND, I2C_LPC_STOP); - udelay(60); - set_lpc(adap, I2C_LPC_REG_COMMAND, 0x00); -} - - - - -static void i2c_start(struct i2c_algo_lpc_data *adap) -{ - print_reg(adap); - - set_lpc(adap, I2C_LPC_REG_COMMAND, I2C_LPC_START); - - print_reg(adap); -} - - - - -static int wait_for_bb(struct i2c_algo_lpc_data *adap) -{ - - int timeout = DEF_TIMEOUT; - int status; - - while (--timeout) { - status = get_lpc(adap, I2C_LPC_REG_STATUS); - - DEBPROTO(lpc_fprintf_debug("%s : Waiting for bus free status : %x\n",__func__,status);) - - if(status == I2C_LPC_TD) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is free status : %x\n",__func__,status);) - break; - } - } - - if (timeout == 0) { - DEBPROTO(lpc_fprintf_debug("%s : Timeout for free busy status : %x\n",__func__,status);) - return -ETIMEDOUT; - } - - - - return 0; -} - - -static int wait_for_be(int mode,struct i2c_algo_lpc_data *adap) -{ - - int timeout = DEF_TIMEOUT; - unsigned char status; - - - while (--timeout) { - - status = get_lpc(adap, I2C_LPC_REG_STATUS); - - DEBPROTO(lpc_fprintf_debug("%s : Waiting for bus empty status : %x\n",__func__,status);) - - if(mode == 1) - { - if((status & I2C_LPC_IBB) && (status & I2C_LPC_TBE)) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is empty status : %x\n",__func__,status);) - break; - } - } - else - { - if(status & I2C_LPC_TD) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is empty status : %x\n",__func__,status);) - break; - } - } - - status = get_lpc(adap, I2C_LPC_REG_TEST); - - DEBPROTO(lpc_fprintf_debug("%s : The test register data : %x\n",__func__,status);) - udelay(1); /* wait for 100 us */ - } - - if (timeout == 0) { - DEBPROTO(lpc_fprintf_debug("%s : Timeout waiting for Bus Empty\n",__func__);) - return -ETIMEDOUT; - } - - return 0; -} - - -static int wait_for_bf(struct i2c_algo_lpc_data *adap) -{ - - int timeout = DEF_TIMEOUT; - int status; - - - while (--timeout) { - status = get_lpc(adap, I2C_LPC_REG_STATUS); - - DEBPROTO(lpc_fprintf_debug("%s : Waiting for bus full status : %x\n",__func__,status);) - - if(status & I2C_LPC_RBF) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is full status : %x\n",__func__,status);) - break; - } - - status = get_lpc(adap, I2C_LPC_REG_TEST); - - DEBPROTO(lpc_fprintf_debug("%s : The test register data : %x\n",__func__,status);) - udelay(1); /* wait for 100 us */ - } - - if (timeout == 0) { - DEBPROTO(lpc_fprintf_debug("%s : Timeout waiting for Bus Full\n",__func__);) - return -ETIMEDOUT; - } - - return 0; -} - -static int wait_for_td(struct i2c_algo_lpc_data *adap) -{ - - int timeout = DEF_TIMEOUT; - int status=0; - - while (--timeout) { - udelay(4); - status = get_lpc(adap, I2C_LPC_REG_STATUS); - - DEBPROTO(lpc_fprintf_debug("%s : Waiting for bus done status : %x\n",__func__,status);) - - if(status == I2C_LPC_TD) - { - DEBPROTO(lpc_fprintf_debug("%s : Bus is done status : %x\n",__func__,status);) - break; - } - } - - if (timeout == 0) { - DEBPROTO(lpc_fprintf_debug("%s : Timeout waiting for Bus Done\n",__func__);) - return -ETIMEDOUT; - } - - return 0; -} - - - -static int wait_for_pin(struct i2c_algo_lpc_data *adap, int *status) -{ - int timeout = DEF_TIMEOUT; - *status = get_lpc(adap, I2C_LPC_REG_STATUS); - - while ((*status & I2C_LPC_TBE) && --timeout) { - *status = get_lpc(adap, I2C_LPC_REG_STATUS); - } - - if (timeout == 0) - return -ETIMEDOUT; - - - return 0; -} - - -static int lpc_doAddress(struct i2c_algo_lpc_data *adap,struct i2c_msg *msg) -{ - unsigned short flags = msg->flags; - unsigned char addr; - - addr = msg->addr << 1; - if (flags & I2C_M_RD) - { - addr |= 1; - DEBPROTO(lpc_fprintf_debug("step 7 : read mode then write device address 0x%x\n",addr);) - } - else - { - DEBPROTO(lpc_fprintf_debug("step 2 : write mode then write device address 0x%x\n",addr);) - } - - if (flags & I2C_M_REV_DIR_ADDR) - { - addr ^= 1; - - } - i2c_outaddr(adap, addr); - return 0; - -} - - -static int lpc_sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) -{ - struct i2c_algo_lpc_data *adap = i2c_adap->algo_data; - int i = 0,timeout=0; - - unsigned int count = msg->len; - unsigned char *buf = msg->buf; - - do{ - lpc_doAddress(adap,msg); - set_lpc(adap, I2C_LPC_REG_BYTE_COUNT, (count-i) >= 4 ? 4:(count - i)); - DEBPROTO(lpc_fprintf_debug("step 3 : write register count %x\n",count);) - - if((count -i) >= 4) - { - i2c_outbyte1(adap, buf[i+0] & 0xff); - i2c_outbyte2(adap, buf[i+1] & 0xff); - i2c_outbyte3(adap, buf[i+2] & 0xff); - i2c_outbyte4(adap, buf[i+3] & 0xff); - - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+1,buf[i+1]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+2,buf[i+2]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+3,buf[i+3]);) - i += 4; - } - else if((count -i) == 3) - { - i2c_outbyte1(adap, buf[i+0] & 0xff); - i2c_outbyte2(adap, buf[i+1] & 0xff); - i2c_outbyte3(adap, buf[i+2] & 0xff); - - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+1,buf[i+1]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+2,buf[i+2]);) - - i += 3; - } - else if((count -i) == 2) - { - i2c_outbyte1(adap, buf[i+0] & 0xff); - i2c_outbyte2(adap, buf[i+1] & 0xff); - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+1,buf[i+1]);) - i += 2; - } - else if((count -i) == 1) - { - i2c_outbyte1(adap, buf[i+0] & 0xff); - DEBPROTO(lpc_fprintf_debug("step 4 : Send data[%d] = %x\n",i+0,buf[i+0]);) - i += 1; - } - - /* Send START */ - DEBPROTO(lpc_fprintf_debug("step 5-1 : Delay 6mS \n");) - udelay(6000); - DEBPROTO(lpc_fprintf_debug("step 5-2 : Start to transfrom \n");) - i2c_stop(adap); - i2c_start(adap); - DEBPROTO(lpc_fprintf_debug("step 5-3 : Start done\n");) - - udelay(400); - DEBPROTO(lpc_fprintf_debug("step 6 : Waiting for BE\n");) - timeout = wait_for_td(adap); - if (timeout) { - DEBPROTO(lpc_fprintf_debug("step 6 : Timeout waiting for BE \n");) - return -EREMOTEIO; - } - }while (i < count); - - if(i == count) - { - DEBPROTO(lpc_fprintf_debug("Writen %d bytes successd !\n",count);) - return i; - } - else - { - DEBPROTO(lpc_fprintf_debug("Writen %d bytes failed \n",count);) - return -EIO; - } -} - -static int lpc_readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) -{ - int i=0,timeout=0; - struct i2c_algo_lpc_data *adap = i2c_adap->algo_data; - - unsigned int count = msg->len; - unsigned char *buf = msg->buf; - - do{ - lpc_doAddress(adap,msg); - set_lpc(adap, I2C_LPC_REG_BYTE_COUNT, (count-i) >= 4 ? 4:(count - i)); - DEBPROTO(lpc_fprintf_debug("step 8 : write register count %d\n",count);) - - /* Send START */ - DEBPROTO(lpc_fprintf_debug("step 9-1 : Delay 6mS\n");) - udelay(6000); - DEBPROTO(lpc_fprintf_debug("step 9-2 : Start to receive data\n");) - i2c_stop(adap); - i2c_start(adap); - DEBPROTO(lpc_fprintf_debug("step 9-3 : Start done\n");) - - udelay(400); - DEBPROTO(lpc_fprintf_debug("step 10 : Waiting for TD\n");) - timeout = wait_for_td(adap); - if (timeout) { - DEBPROTO(lpc_fprintf_debug("step 10 : Timeout waiting for TD \n");) - return -EREMOTEIO; - } - - if((count -i) >= 4) - { - buf[i+0] = 0xff & i2c_inbyte1(adap); - buf[i+1] = 0xff & i2c_inbyte2(adap); - buf[i+2] = 0xff & i2c_inbyte3(adap); - buf[i+3] = 0xff & i2c_inbyte4(adap); - - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+1,buf[i+1]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+2,buf[i+2]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+3,buf[i+3]);) - - i += 4; - } - else if((count -i) == 3) - { - buf[i+0] = 0xff & i2c_inbyte1(adap); - buf[i+1] = 0xff & i2c_inbyte2(adap); - buf[i+2] = 0xff & i2c_inbyte3(adap); - - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+1,buf[i+1]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+2,buf[i+2]);) - - i += 3; - } - else if((count -i) == 2) - { - buf[i+0] = 0xff & i2c_inbyte1(adap); - buf[i+1] = 0xff & i2c_inbyte2(adap); - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+0,buf[i+0]);) - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+1,buf[i+1]);) - i += 2; - } - else if((count -i) == 1) - { - buf[i+0] = 0xff & i2c_inbyte1(adap); - DEBPROTO(lpc_fprintf_debug("step 11 : Receive data[%d] = %x\n",i+0,buf[i+0]);) - i += 1; - } - - - }while(i < count); - - if(i == count) - { - DEBPROTO(lpc_fprintf_debug("Read %d bytes successd !\n",count);) - return i; - } - else - { - DEBPROTO(lpc_fprintf_debug("Read %d bytes failed \n",count);) - return -EIO; - } -} - - -struct cpld_client_node { - struct i2c_client *client; - struct list_head list; -}; -#define LPC_I2C_MAX_NCHANS 6 - - -struct lpc_iic { - struct i2c_adapter *virt_adaps[LPC_I2C_MAX_NCHANS]; - u8 last_chan; /* last register value */ -}; - - -static int lpc_master_xfer(struct i2c_adapter *i2c_adap, - struct i2c_msg *msgs, - int num) -{ - struct i2c_algo_lpc_data *adap = i2c_adap->algo_data; - struct i2c_msg *pmsg; - int i; - int ret=0; - - mutex_lock(&lpc_lock); - - if (adap->xfer_begin) - adap->xfer_begin(&i2c_adap->nr); - - - for (i = 0;ret >= 0 && i < num; i++) { - pmsg = &msgs[i]; - - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n", - pmsg->flags & I2C_M_RD ? "read" : "write", - pmsg->len, pmsg->addr, i + 1, num);) - - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n", - i, msgs[i].addr, msgs[i].flags, msgs[i].len);) - - if (pmsg->flags & I2C_M_RD) { - ret = lpc_readbytes(i2c_adap, pmsg); - - if (ret != pmsg->len) { - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: fail: " - "only read %d bytes.\n",ret)); - } else { - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: read %d bytes.\n",ret)); - } - } else { - - ret = lpc_sendbytes(i2c_adap, pmsg); - - if (ret != pmsg->len) { - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: fail: " - "only wrote %d bytes.\n",ret)); - } else { - DEBPROTO(lpc_fprintf_debug("lpc_xfer.o: wrote %d bytes.\n",ret)); - } - } - } - - if (adap->xfer_end) - adap->xfer_end(&i2c_adap->nr); - - mutex_unlock(&lpc_lock); - - DEBPROTO(lpc_fprintf_debug("ret = 0x%x num = 0x%x i = 0x%x.\n",ret,num,i)); - - return ret = (ret < 0) ? ret : num; -} - - -static u32 lpc_func(struct i2c_adapter *adap) -{ - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_QUICK; -} - -/* exported algorithm data: */ -static const struct i2c_algorithm lpc_algo = { - .master_xfer = lpc_master_xfer, - //.smbus_xfer = lpc_smbus_xfer, - .functionality = lpc_func, -}; - - -/********************************************** End ********************************************************/ - - - - - - -/********************************************** Start ********************************************************/ -#define DEFAULT_BASE 0x0a00 - -static int lpc_base= 0x0a00; -static u8 __iomem *lpc_base_iomem; - -static int lpc_irq; -static int lpc_clock = 0x1c; -static int lpc_own = 0x55; -static int lpc_mmapped; - -static unsigned long lpc_base_addr = 0x0a00; -static unsigned int lpc_io_space_size = 2; - -static unsigned long LPC_INDEX_REG; -static unsigned long LPC_DATA_REG; - - -/* notice : removed static struct i2c_lpc_iic gpi; code - - this module in real supports only one device, due to missing arguments - in some functions, called from the algo-lpc module. Sometimes it's - need to be rewriten - but for now just remove this for simpler reading */ - -static wait_queue_head_t lpc_wait; -static int lpc_pending; -static spinlock_t lock; -static spinlock_t lpc_slock; - -static struct i2c_adapter lpc_iic_ops; - -struct cpld_dev_type { - struct resource *io_resource; - struct semaphore sem; - struct cdev cdev; -}; - -struct cpld_dev_type *cpld_device; - - -/* ----- local functions ---------------------------------------------- */ - -static void lpc_cpld_setbyte(void *data, int ctl, int val) -{ - outb(ctl, LPC_INDEX_REG); - mb(); - - outb(val, LPC_DATA_REG); - mb(); -} - -static int lpc_cpld_getbyte(void *data, int ctl) -{ - u8 val = 0; - - outb(ctl, LPC_INDEX_REG); - mb(); - - val = inb(LPC_DATA_REG); - mb(); - - return val; -} - -static void lpc_iic_setbyte(void *data, int ctl, int val) -{ - if (!cpld_device) - { - return ; - } - - if (down_interruptible(&cpld_device->sem)) - { - return ; - } - - - lpc_cpld_setbyte(data,ctl,val); - - up(&cpld_device->sem); - DEBPROTO(lpc_fprintf_debug("%s REG[%x] = %x\n",__func__,ctl,val);) -} - - -static int lpc_iic_getbyte(void *data, int ctl) -{ - u8 val = 0; - if (!cpld_device) - return -ENOTTY; - - if (down_interruptible(&cpld_device->sem)) - return -ERESTARTSYS; - - val = lpc_cpld_getbyte(data,ctl); - - up(&cpld_device->sem); - DEBPROTO(lpc_fprintf_debug("%s REG[%x] = %x\n",__func__,ctl,val);) - return val; -} - -int cig_cpld_read_register(u8 reg_off, u8 *val) -{ - if (!cpld_device) - return -ENOTTY; - - if (down_interruptible(&cpld_device->sem)) - return -ERESTARTSYS; - - *val = lpc_cpld_getbyte(cpld_device, reg_off); - - up(&cpld_device->sem); - - return 0; -} -EXPORT_SYMBOL(cig_cpld_read_register); - -int cig_cpld_write_register(u8 reg_off, u8 val) -{ - if (!cpld_device) - return -ENOTTY; - - if (down_interruptible(&cpld_device->sem)) - return -ERESTARTSYS; - - lpc_cpld_setbyte(cpld_device, reg_off, val); - up(&cpld_device->sem); - return 0; -} -EXPORT_SYMBOL(cig_cpld_write_register); - - - -static int lpc_iic_getown(void *data) -{ - return (lpc_own); -} - - -static int lpc_iic_getclock(void *data) -{ - return (lpc_clock); -} - -static void lpc_iic_waitforpin(void *data) -{ - DEFINE_WAIT(wait); - int timeout = 2; - unsigned long flags; - - if (lpc_irq > 0) { - spin_lock_irqsave(&lock, flags); - if (lpc_pending == 0) { - spin_unlock_irqrestore(&lock, flags); - prepare_to_wait(&lpc_wait, &wait, TASK_INTERRUPTIBLE); - if (schedule_timeout(timeout*HZ)) { - spin_lock_irqsave(&lock, flags); - if (lpc_pending == 1) { - lpc_pending = 0; - } - spin_unlock_irqrestore(&lock, flags); - } - finish_wait(&lpc_wait, &wait); - } else { - lpc_pending = 0; - spin_unlock_irqrestore(&lock, flags); - } - } else { - udelay(100); - } -} - - -static irqreturn_t lpc_iic_handler(int this_irq, void *dev_id) { - spin_lock(&lock); - lpc_pending = 1; - spin_unlock(&lock); - wake_up_interruptible(&lpc_wait); - return IRQ_HANDLED; -} - -static int board_id = 0; - - -static int lpc_iic_select(void *data) -{ - unsigned int chan_id=0; - chan_id = *(unsigned int *)data; - chan_id -= 2; - DEBPROTO(lpc_fprintf_debug("step 1 : selest channel id = %d\n",chan_id);) - lpc_iic_setbyte(data,I2C_LPC_REG_BUS_SEL,chan_id); - - return 0; -} - -static int lpc_iic_deselect(void *data) -{ - - unsigned int chan_id=0; - chan_id = *(unsigned int *)data; - chan_id -= 2; - DEBPROTO(lpc_fprintf_debug("step last :deselect channel id = %d\n",chan_id);) - - return 0; -} - - -/* ------------------------------------------------------------------------ - * Encapsulate the above functions in the correct operations structure. - * This is only done when more than one hardware adapter is supported. - */ -static struct i2c_algo_lpc_data lpc_iic_data = { - .setlpc = lpc_iic_setbyte, - .getlpc = lpc_iic_getbyte, - .getown = lpc_iic_getown, - .getclock = lpc_iic_getclock, - .waitforpin = lpc_iic_waitforpin, - .xfer_begin = lpc_iic_select, - .xfer_end = lpc_iic_deselect, -}; - -#include - -static struct i2c_adapter lpc_iic_arr_ops[LPC_I2C_MAX_NCHANS] = {0}; - -static void dummy_setscl(void *data, int state) -{ - return; -} - -static void dummy_setsda(void *data, int state) -{ - return; - -} - -static int dummy_getscl(void *data) -{ - return 1; - -} - -static int dummy_getsda(void *data) -{ - return 1; -} - - -static struct i2c_algo_bit_data dummy_algo_data = { - .setsda = dummy_setsda, - .setscl = dummy_setscl, - .getsda = dummy_getsda, - .getscl = dummy_getscl, - .udelay = 50, - .timeout = HZ, -}; - - -static int dummy_xfer(struct i2c_adapter *i2c_adap, - struct i2c_msg *msgs, - int num) -{ - return 1; -} - -static u32 dummy_func(struct i2c_adapter *adap) -{ - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_QUICK; -} - - -static const struct i2c_algorithm dummy_algo = { - .master_xfer = dummy_xfer, - .functionality = dummy_func, -}; - - - -static struct i2c_adapter i2c_dummy = { - .owner = THIS_MODULE, - .class = I2C_CLASS_HWMON, - .algo_data = &dummy_algo_data, - .algo = &dummy_algo, - .name = "i2c_dummy", -}; - - -static int lpc_iic_match(struct device *dev, unsigned int id) -{ - /* sanity checks for lpc_mmapped I/O */ - - DEB2(printk("lpc_iic_match\n");) - - - if (lpc_base < DEFAULT_BASE) { - dev_err(dev, "incorrect lpc_base address (%#x) specified " - "for lpc_mmapped I/O\n", lpc_base); - return 0; - } - - if (lpc_base == 0) { - lpc_base = DEFAULT_BASE; - } - return 1; -} - -static int lpc_iic_probe(struct device *dev, unsigned int id) -{ - int rval,num; - - lpc_fprintf_init(); - - DEB2(printk("lpc_iic_probe\n");) - - mutex_init(&lpc_lock); - - for(num = 0; num < LPC_I2C_MAX_NCHANS;num++) - { - lpc_iic_arr_ops[num].dev.parent = dev; - lpc_iic_arr_ops[num].owner = THIS_MODULE; - lpc_iic_arr_ops[num].class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - lpc_iic_arr_ops[num].algo = &lpc_algo; - lpc_iic_arr_ops[num].algo_data = &lpc_iic_data, - lpc_iic_arr_ops[num].nr=num; - snprintf(lpc_iic_arr_ops[num].name, sizeof(lpc_iic_arr_ops[num].name), "i2c-%d-lpc", i2c_adapter_id(&lpc_iic_arr_ops[num])); - rval |= i2c_add_adapter(&lpc_iic_arr_ops[num]); - DEB2(printk("%s\n",lpc_iic_arr_ops[num].name);) - } - - return 0; -} - -static int lpc_iic_remove(struct device *dev, unsigned int id) -{ - int num; - DEB2(printk("lpc_iic_remove\n")); - - lpc_fprintf_exit(); - for(num = LPC_I2C_MAX_NCHANS - 1; num >= 0 ;num--) - i2c_del_adapter(&lpc_iic_arr_ops[num]); - - - return 0; -} - -static struct isa_driver i2c_lpc_driver = { - .match = lpc_iic_match, - .probe = lpc_iic_probe, - .remove = lpc_iic_remove, - .driver = { - .owner = THIS_MODULE, - .name = "lpc-iic", - }, -}; - -/********************************************** End ********************************************************/ - - - - - - -/********************************************** Start ********************************************************/ - -static int cpld_major = 0; -static int cpld_minor = 0; - -struct cpld_rw_msg { - unsigned char addr; - unsigned char data; -}; - - -static struct cpld_rw_msg param_read = {-1}; -static struct cpld_rw_msg param_write = {-1}; -static struct cpld_rw_msg param_reads = {-1}; -static struct cpld_rw_msg param_writes = {-1}; - -void cpld_sysfs_kobj_release(struct kobject *kobj) -{ - return; -} - -int cpld_sysfs_add_attr(struct kobject* kobj, char* attr_name) -{ - - struct attribute *attr; - - attr = kmalloc(sizeof(struct attribute), GFP_KERNEL); - attr->name = attr_name; - attr->mode = 0644; - - return sysfs_create_file(kobj, attr); -} - -static int cig_cpld_write_slave_cpld_register(u8 reg_addr, u8 reg_data); -static int cig_cpld_read_slave_cpld_register(u8 reg_addr, u8 *reg_data); - - -static ssize_t cpld_sysfs_show(struct kobject *kobj, struct attribute *attr, char *buffer) -{ - u8 val=0,ret=0,year=0,month=0,day=0,cpld_m=0,cpld_1=0,cpld_2=0; - - if (0 == strcmp(attr->name, "read")) - { - val = lpc_iic_getbyte(NULL,param_read.addr); - ret = sprintf(buffer,"read : addr = 0x%x val = 0x%x\n",param_read.addr, val); - - } - else if (0 == strcmp(attr->name, "write")) - { - lpc_iic_setbyte(NULL, param_write.addr,param_write.data); - ret = sprintf(buffer,"write : addr = 0x%x val = 0x%x\n",param_write.addr, param_write.data); - } - else if (0 == strcmp(attr->name, "version")) - { - cpld_m = lpc_iic_getbyte(NULL, 0x02); - year = lpc_iic_getbyte(NULL, 0x03); - month = lpc_iic_getbyte(NULL, 0x04); - day = lpc_iic_getbyte(NULL, 0x05); - - cig_cpld_read_slave_cpld_register(0x1d,&cpld_1); - cig_cpld_read_slave_cpld_register(0x1e,&cpld_2); - - ret = sprintf(buffer,"Main CPLD version : V%02x\n"\ - "Main CPLD date : 20%02x-%02x-%02x\n"\ - "Slave 1 CPLD version : V%02x\n"\ - "Slave 2 CPLD version : V%02x\n",cpld_m,year,month,day,cpld_1,cpld_2); - } - if (0 == strcmp(attr->name, "reads")) - { - ret = cig_cpld_read_slave_cpld_register(param_reads.addr,&val); - if (ret < 0) - printk("ERROR:Failed to read slave cpld.\n"); - ret = sprintf(buffer,"reads : addr = 0x%x val = 0x%x\n",param_reads.addr, val); - - } - else if (0 == strcmp(attr->name, "writes")) - { - ret = cig_cpld_write_slave_cpld_register(param_writes.addr,param_writes.data); - if (ret < 0) - printk("ERROR:Failed to read slave cpld.\n"); - ret = sprintf(buffer,"writes : addr = 0x%x val = 0x%x\n",param_writes.addr, param_writes.data); - } - - - return ret; - -} - -static ssize_t cpld_sysfs_store(struct kobject *kobj, struct attribute *attr, const char *buffer, size_t count) -{ - int param[3]; - - if (0 == strcmp(attr->name, "read")) - { - sscanf(buffer, "0x%02x", ¶m[0]); - param_read.addr = param[0]; - } - else if (0 == strcmp(attr->name, "write")) - { - sscanf(buffer, "0x%2x 0x%02x", ¶m[0], ¶m[1]); - param_write.addr = param[0]; - param_write.data = param[1]; - } - if (0 == strcmp(attr->name, "reads")) - { - sscanf(buffer, "0x%02x", ¶m[0]); - param_reads.addr = param[0]; - } - else if (0 == strcmp(attr->name, "writes")) - { - sscanf(buffer, "0x%2x 0x%02x", ¶m[0], ¶m[1]); - param_writes.addr = param[0]; - param_writes.data = param[1]; - } - return count; -} - - - -static struct sysfs_ops cpld_sysfs_ops = -{ - .show = cpld_sysfs_show, - .store = cpld_sysfs_store, -}; - -static struct kobj_type cpld_kobj_type = -{ - .release = cpld_sysfs_kobj_release, - .sysfs_ops = &cpld_sysfs_ops, - .default_attrs = NULL, -}; - - -static const char driver_name[] = "cpld_drv"; -static atomic_t cpld_available = ATOMIC_INIT(1); -static struct class *cpld_class; -static struct device *cpld_dev; - - - -#define CPLD_IOC_MAGIC '[' - -#define CPLD_IOC_RDREG _IOR(CPLD_IOC_MAGIC, 0, struct cpld_rw_msg) -#define CPLD_IOC_WRREG _IOW(CPLD_IOC_MAGIC, 1, struct cpld_rw_msg) - -#define CPLD_IOC_MAXNR 2 - - -int cpld_open(struct inode *inode, struct file *filp) -{ - struct cpld_dev_type *dev; - - if (! atomic_dec_and_test(&cpld_available)) { - atomic_inc(&cpld_available); - return -EBUSY; - } - - dev = container_of(inode->i_cdev, struct cpld_dev_type, cdev); - filp->private_data = dev; - - return 0; -} - -int cpld_release(struct inode *inode, struct file *flip) -{ - atomic_inc(&cpld_available); - return 0; -} - - -long cpld_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - int rc = 0; - int err = 0; - struct cpld_dev_type *dev = (struct cpld_dev_type *)filp->private_data; - struct cpld_rw_msg msg; - - if (_IOC_TYPE(cmd) != CPLD_IOC_MAGIC) - return -ENOTTY; - if (_IOC_NR(cmd) > CPLD_IOC_MAXNR) - return -ENOTTY; - - if (_IOC_DIR(cmd) & _IOC_READ) - err = !access_ok(VERIFY_WRITE, (void __user *)arg, _IOC_SIZE(cmd)); - if (_IOC_DIR(cmd) & _IOC_WRITE) - err = !access_ok(VERIFY_READ, (void __user *)arg, _IOC_SIZE(cmd)); - if (err) - return -EFAULT; - - if (down_interruptible(&dev->sem)) - return -ERESTARTSYS; - - switch(cmd){ - case CPLD_IOC_RDREG: - rc = copy_from_user(&msg, (void __user *)arg, sizeof(msg)); - if (!rc) { - msg.data = lpc_cpld_getbyte(dev, msg.addr); - rc = copy_to_user((void __user *)arg, &msg, sizeof(msg)); - } - break; - - case CPLD_IOC_WRREG: - rc = copy_from_user(&msg, (void __user *)arg, sizeof(msg)); - if (!rc) { - lpc_cpld_setbyte(dev, msg.addr, msg.data); - } - break; - default: - rc = -ENOTTY; - break; - } - up(&dev->sem); - - return rc; -} - -struct file_operations cpld_fops = { - .owner = THIS_MODULE, - .open = cpld_open, - .unlocked_ioctl = cpld_ioctl, - .release = cpld_release, -}; - - -static void cpld_setup_cdev(struct cpld_dev_type *dev) -{ - int err, devno = MKDEV(cpld_major, cpld_minor); - - cdev_init(&dev->cdev, &cpld_fops); - dev->cdev.owner = THIS_MODULE; - dev->cdev.ops = &cpld_fops; - err = cdev_add(&dev->cdev, devno, 1); - - if (err) - DEB2(printk(KERN_NOTICE "Error %d adding cpld", err);) -} -/********************************************** End ********************************************************/ - - - - -/********************************************** Start ********************************************************/ -#include -#include -#include - -static spinlock_t irq_inter_lock; -static struct delayed_work irq_inter_work; -static unsigned long irq_inter_delay; - - -static int cig_cpld_write_slave_cpld_register(u8 reg_addr, u8 reg_data) -{ - u8 read_status = 0; - u8 wait_time_out = WAIT_TIME_OUT_COUNT; - DEB2(printk("<=======write=========>")); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_ADDR, reg_addr << 1); - DEB2(printk("[62]=%x\n",reg_addr << 1)); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_TX, reg_data); - DEB2(printk("[63]=%x\n",reg_data)); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_COMMAND, 0x80); - DEB2(printk("[65]=%x\n",0x80)); - do{ - cig_cpld_read_register(ADDR_REG_SFP_STATUS_STATUS, &read_status); - DEB2(printk("[66]=%x\n",read_status)); - udelay(60); - wait_time_out--; - if(wait_time_out == 0) - break; - }while(read_status != 0x02); - DEB2(printk("<=======write=========>")); - - - if(wait_time_out == 0) - return -1; - - return 1; -} - - -static int cig_cpld_read_slave_cpld_register(u8 reg_addr, u8 *reg_data) -{ - u8 read_status = 0; - u8 wait_time_out = WAIT_TIME_OUT_COUNT; - DEB2(printk("<========read=========>")); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_ADDR, reg_addr << 1 | 1); - DEB2(printk("[62]=%x\n",reg_addr << 1 | 1)); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_COMMAND, 0x80); - DEB2(printk("[65]=%x\n",0x80)); - do{ - udelay(60); - cig_cpld_read_register(ADDR_REG_SFP_STATUS_STATUS, &read_status); - DEB2(printk("[66]=%x\n",read_status)); - wait_time_out--; - if(wait_time_out == 0) - break; - }while(read_status != 0x01); - - cig_cpld_read_register(ADDR_REG_SFP_STATUS_RX,reg_data); - DEB2(printk("[64]=%x\n",*reg_data)); - DEB2(printk("<========read=========>")); - - if(wait_time_out == 0) - return -1; - - return 1; -} - - - -struct sock *nlsk = NULL; -extern struct net init_net; -#define NETLINK_TEST 26 -#define MSG_LEN 125 -#define USER_PORT 100 -static u32 irq_present_status_low_current,irq_present_status_low_next; -static u32 irq_present_status_high_current,irq_present_status_high_next; -static u32 irq_tx_fault_status_low_current,irq_tx_fault_status_low_next; -static u32 irq_tx_fault_status_high_current,irq_tx_fault_status_high_next; -static u32 irq_rx_lost_status_low_current,irq_rx_lost_status_low_next; -static u32 irq_rx_lost_status_high_current,irq_rx_lost_status_high_next; - -static u8 irq_present_qsfp_current,irq_present_qsfp_next; -static u8 irq_interrupt_qsfp_current,irq_interrupt_qsfp_next; - -struct input_dev *cpld_input_dev; - - - -int send_usrmsg(char *pbuf, uint16_t len) -{ - struct sk_buff *nl_skb; - struct nlmsghdr *nlh; - - int ret; - - - nl_skb = nlmsg_new(len, GFP_ATOMIC); - if(!nl_skb) - { - printk("netlink alloc failure\n"); - return -1; - } - - - nlh = nlmsg_put(nl_skb, 0, 0, NETLINK_TEST, len, 0); - if(nlh == NULL) - { - printk("nlmsg_put failaure \n"); - nlmsg_free(nl_skb); - return -1; - } - - memcpy(nlmsg_data(nlh), pbuf, len); - ret = netlink_unicast(nlsk, nl_skb, USER_PORT, MSG_DONTWAIT); - - return ret; -} - -static void netlink_rcv_msg(struct sk_buff *skb) -{ - - struct nlmsghdr *nlh = NULL; - char *umsg = NULL; - char kmsg[1024] = {0}; - char kmsg_tmp[16] = {0}; - u8 i = 0; - u8 tmp[3]={0}; - - if(skb->len >= nlmsg_total_size(0)) - { - nlh = nlmsg_hdr(skb); - umsg = NLMSG_DATA(nlh); - if(umsg) - { - for(i = 0;i < 24;i++) - { - if(!(irq_present_status_low_current & (0x1 << i))) - { - tmp[0] = 1; - } - else - { - tmp[0] = 0; - } - - if(!(irq_rx_lost_status_low_current & (0x1 << i))) - { - tmp[1] = 1; - } - else - { - tmp[1] = 0; - } - - if(!(irq_tx_fault_status_low_current & (0x1 << i))) - { - tmp[2] = 1; - } - else - { - tmp[2] = 0; - } - memset(kmsg_tmp,0xff,sizeof(kmsg_tmp)); - sprintf(kmsg_tmp,"sfp%02d:%1d:%1d:%1d ",i+1,tmp[0],tmp[1],tmp[2]); - strcat(kmsg,kmsg_tmp); - } - - for(i = 0;i < 24;i++) - { - if(!(irq_present_status_high_current & (0x1 << i))) - { - tmp[0] = 1; - } - else - { - tmp[0] = 0; - } - - if(!(irq_rx_lost_status_high_current & (0x1 << i))) - { - tmp[1] = 1; - } - else - { - tmp[1] = 0; - } - - if(!(irq_tx_fault_status_high_current & (0x1 << i))) - { - tmp[2] = 1; - } - else - { - tmp[2] = 0; - } - memset(kmsg_tmp,0xff,sizeof(kmsg_tmp)); - sprintf(kmsg_tmp,"sfp%02d:%1d:%1d:%1d ",i+25,tmp[0],tmp[1],tmp[2]); - strcat(kmsg,kmsg_tmp); - } - - - for(i = 0;i < 8;i++) - { - if(!(irq_present_qsfp_current & (0x1 << i))) - { - tmp[0] = 1; - } - else - { - tmp[0] = 0; - } - - if(!(irq_interrupt_qsfp_current & (0x1 << i))) - { - tmp[1] = 1; - } - else - { - tmp[1] = 0; - } - - memset(kmsg_tmp,0xff,sizeof(kmsg_tmp)); - sprintf(kmsg_tmp,"qsfp%02d:%1d:%1d:%1d ",i+49,tmp[0],tmp[1],0); - strcat(kmsg,kmsg_tmp); - } - - printk("kernel recv from user: %s\n", umsg); - send_usrmsg(kmsg, strlen(kmsg)); - } - } - - return ; -} - - - -struct netlink_kernel_cfg cfg = { - .input = netlink_rcv_msg, /* set recv callback */ -}; - - - -#define RANGE_OF_BYTE_SHIFT(to_arg,shift,from_arg) {to_arg &= ~(0xff << shift); to_arg |= from_arg << shift;} - - -static void irq_inter_wapper(struct work_struct * work) -{ - - u8 m_data = 0; - u8 data_high8 = 0,data_low8 = 0; - u16 data_16 = 0; - u8 status = 0; - u8 i = 0; - char kmsg[64]={0}; - u8 tmp[3] = {0}; - - DEB2(printk("CPLD_MASTER_INTERRUPT\r\n")); - - m_data = lpc_iic_getbyte(NULL,CPLD_MASTER_INTERRUPT_STATUS_REG); - lpc_iic_setbyte(NULL,CPLD_MASTER_INTERRUPT_STATUS_REG,0xff); - - cig_cpld_write_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_MASK_REG,0xff); - cig_cpld_write_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_MASK_REG,0xff); - if(!(m_data & CPLD_MASTER_INTERRUPT_CPLD1)) - { - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_STATUS_H_REG,&data_high8); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_STATUS_L_REG,&data_low8); - data_16 = data_low8 | data_high8 << 8; - if( - !(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT08) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT16) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT24) - ) - { - if(!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT08)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT08\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_PRESENT08_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_low_current,0,status); - - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT16)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT16\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_PRESENT16_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_low_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT24)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT24\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_PRESENT24_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_low_current,16,status); - } - DEB2(printk("irq_present_status_low_next = %08x irq_present_status_low_current = %08x \n",irq_present_status_low_next,irq_present_status_low_current)); - } - - if( - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST08) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST16) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST24) - ) - { - if(!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST08)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_RX_LOST08\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_RX_LOST08_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_low_current,0,status); - - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST16)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT16\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_RX_LOST16_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_low_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST24)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT24\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_RX_LOST24_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_low_current,16,status); - } - DEB2(printk("irq_rx_lost_status_low_next = %08x irq_rx_lost_status_low_current = %08x \n",irq_rx_lost_status_low_next,irq_rx_lost_status_low_current)); - } - - if( - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST08) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST16) || - !(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST24) - ) - { - if(!(data_16 & CPLD_SLAVE1_INTERRUPT_TX_FAULT08)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_TX_FAULT08\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_TX_FAULT08_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_low_current,0,status); - - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_TX_FAULT16)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_TX_FAULT16\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_TX_FAULT16_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_low_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_TX_FAULT24)) - { - DEB2(printk("CPLD_SLAVE1_INTERRUPT_TX_FAULT24\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_TX_FAULT24_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_low_current,16,status); - } - DEB2(printk("irq_tx_fault_status_low_next = %08x irq_tx_fault_status_low_current = %08x \n",irq_tx_fault_status_low_next,irq_tx_fault_status_low_current)); - - } - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_CPLD2)) - { - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_STATUS_H_REG,&data_high8); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_STATUS_L_REG,&data_low8); - data_16 = data_low8 | data_high8 << 8; - if( - !(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT32) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT40) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT48) - ) - { - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT32)) - { - DEB2(printk("CPLD_SLAVE2_PRESENT32_REG\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT32_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_high_current,0,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT40)) - { - DEB2(printk("CPLD_SLAVE2_PRESENT40_REG\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT40_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_high_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT48)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT48\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT48_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_present_status_high_current,16,status); - } - } - - if( - !(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST32) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST40) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST48) - ) - { - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST32)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_RX_LOST32\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_RX_LOST32_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_high_current,0,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST40)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT40\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_RX_LOST40_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_high_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST48)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT48\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_RX_LOST48_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_high_current,16,status); - } - - } - - if( - !(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT32) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT40) || - !(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT48) - ) - { - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT32)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_RX_LOST32\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_TX_FAULT32_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_high_current,0,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT40)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT40\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_TX_FAULT40_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_high_current,8,status); - } - else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT48)) - { - DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT48\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_TX_FAULT48_REG,&status); - RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_high_current,16,status); - } - } - - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT56)) - { - DEB2(printk("CPLD_SLAVE2_PRESENT56_REG\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT56_REG,&status); - irq_present_qsfp_current = status; - } - - if(!(data_16 & CPLD_SLAVE2_INTERRUPT_QSFP_CR56)) - { - DEB2(printk("CPLD_SLAVE2_QSFP_CR56_REG\r\n")); - cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_QSFP_CR56_REG,&status); - irq_interrupt_qsfp_current = status; - } - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_LSW)) - { - DEB2(printk("CPLD_MASTER_INTERRUPT_LSW\r\n")); - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_PSU1)) - { - DEB2(printk("CPLD_MASTER_INTERRUPT_PSU1\r\n")); - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_PSU2)) - { - DEB2(printk("CPLD_MASTER_INTERRUPT_PSU2\r\n")); - } - else if(!(m_data & CPLD_MASTER_INTERRUPT_6320)) - { - DEB2(printk("CPLD_MASTER_INTERRUPT_6320\r\n")); - } - cig_cpld_write_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_MASK_REG,0x0); - cig_cpld_write_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_MASK_REG,0x0); - - memset(tmp,0xff,sizeof(tmp)); - - for(i = 0;i < 24;i++) - { - if(!(irq_present_status_low_current & (0x1 << i)) && (irq_present_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d is present\r\n",i+1)); - tmp[0] = 1; - } - else if((irq_present_status_low_current & (0x1 << i)) && !(irq_present_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d is absent\r\n",i+1)); - tmp[0] = 0; - } - - if(!(irq_tx_fault_status_low_current & (0x1 << i)) && (irq_tx_fault_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d transmission is right\r\n",i+1)); - tmp[1] = 1; - } - else if((irq_tx_fault_status_low_current & (0x1 << i)) && !(irq_tx_fault_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d transmission is fault\r\n",i+1)); - tmp[1] = 0; - } - - if(!(irq_rx_lost_status_low_current & (0x1 << i)) && (irq_rx_lost_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d optical is meet\r\n",i+1)); - tmp[2] = 1; - } - else if((irq_rx_lost_status_low_current & (0x1 << i)) && !(irq_rx_lost_status_low_next & (0x1 << i))) - { - DEB2(printk("SFP%d optical is lost\r\n",i+1)); - tmp[2] = 0; - } - - if((tmp[0] != 0xff) || (tmp[1] != 0xff) || (tmp[2] != 0xff)) - { - memset(kmsg,0xff,sizeof(kmsg)); - snprintf(kmsg,sizeof(kmsg),"sfp%02d:%1d:%1d:%1d ",i+1,(tmp[0] == 0xff) ? 0:tmp[0],(tmp[1] == 0xff) ? 0:tmp[1],(tmp[2] == 0xff) ? 0:tmp[2]); - break; - } - } - - memset(tmp,0xff,sizeof(tmp)); - for(i = 0;i < 24;i++) - { - if(!(irq_present_status_high_current & (0x1 << i)) && (irq_present_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d is present\r\n",i+25)); - tmp[0] = 1; - } - else if((irq_present_status_high_current & (0x1 << i)) && !(irq_present_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d is absent\r\n",i+25)); - tmp[0] = 0; - - } - - if(!(irq_rx_lost_status_high_current & (0x1 << i)) && (irq_rx_lost_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d optical is meet\r\n",i+25)); - tmp[1] = 1; - } - else if((irq_rx_lost_status_high_current & (0x1 << i)) && !(irq_rx_lost_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d optical is lost\r\n",i+25)); - tmp[1] = 0; - } - - if(!(irq_tx_fault_status_high_current & (0x1 << i)) && (irq_tx_fault_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d transmission is right\r\n",i+25)); - tmp[2] = 1; - } - else if((irq_tx_fault_status_high_current & (0x1 << i)) && !(irq_tx_fault_status_high_next & (0x1 << i))) - { - DEB2(printk("SFP%d transmission is fault\r\n",i+25)); - tmp[2] = 0; - } - - if((tmp[0] != 0xff) || (tmp[1] != 0xff) || (tmp[2] != 0xff)) - { - memset(kmsg,0xff,sizeof(kmsg)); - snprintf(kmsg,sizeof(kmsg),"sfp%02d:%1d:%1d:%1d ",i+25,(tmp[0] == 0xff) ? 0:tmp[0],(tmp[1] == 0xff) ? 0:tmp[1],(tmp[2] == 0xff) ? 0:tmp[2]); - break; - } - } - - memset(tmp,0xff,sizeof(tmp)); - for(i = 0 ; i < 8; i++) - { - if(!(irq_present_qsfp_current & (0x1 << i)) && (irq_present_qsfp_next & (0x1 << i))) - { - DEB2(printk("SFP%d is present\r\n",i+49)); - tmp[0] = 1; - } - else if((irq_present_qsfp_current & (0x1 << i)) && !(irq_present_qsfp_next & (0x1 << i))) - { - DEB2(printk("SFP%d is absent\r\n",i+49)); - tmp[0] = 0; - } - - if(!(irq_interrupt_qsfp_current & (0x1 << i)) && (irq_interrupt_qsfp_next & (0x1 << i))) - { - DEB2(printk("SFP%d interrupt is occured \r\n",i+49)); - tmp[1] = 1; - } - else if((irq_interrupt_qsfp_current & (0x1 << i)) && !(irq_interrupt_qsfp_next & (0x1 << i))) - { - DEB2(printk("SFP%d interrupt is cleaned\r\n",i+49)); - tmp[1] = 0; - } - - if((tmp[0] != 0xff) || (tmp[1] != 0xff)) - { - memset(kmsg,0xff,sizeof(kmsg)); - snprintf(kmsg,sizeof(kmsg),"qsfp%02d:%1d:%1d:%1d ",i+49,(tmp[0] == 0xff) ? 0:tmp[0],(tmp[1] == 0xff) ? 0:tmp[1],0); - break; - } - } - - - irq_present_status_low_next = irq_present_status_low_current; - irq_rx_lost_status_low_next = irq_rx_lost_status_low_current; - irq_tx_fault_status_low_next = irq_tx_fault_status_low_current; - irq_present_status_high_next = irq_present_status_high_current; - irq_rx_lost_status_high_next = irq_rx_lost_status_high_current; - irq_tx_fault_status_high_next = irq_tx_fault_status_high_current; - irq_present_qsfp_next = irq_present_qsfp_current; - irq_interrupt_qsfp_next = irq_interrupt_qsfp_current; - - send_usrmsg(kmsg, strlen(kmsg)); -} - -static void disableIrq(unsigned short maskReg, unsigned short mask) -{ - u8 data = 0; - - data = lpc_iic_getbyte(NULL,maskReg); - data |= mask; - lpc_iic_setbyte(NULL,maskReg, data); -} - -static void enableIrq(unsigned short maskReg, unsigned short mask) -{ - unsigned short data; - - data = lpc_iic_getbyte(NULL,maskReg); - data &= ~mask; - lpc_iic_setbyte(NULL,maskReg, data); -} - - -static irqreturn_t irq_inter_isr(int irq, void *handle) -{ - - /* - * use keventd context to read the event fifo registers - * Schedule readout at least 25ms after notification for - * REVID < 4 - */ - - schedule_delayed_work(&irq_inter_work, irq_inter_delay); - - return IRQ_HANDLED; -} - - -#define CIG_CPLD_CHR_NAME "cpld" - - -static int __init cpld_init(void) -{ - int rval,rc=0; - dev_t dev; - u8 s_data; - int isr_GPIO_num = 289; - - DEB2(printk("cpld_init\n");) - -/**************************************************************************************/ - - LPC_INDEX_REG = lpc_base_addr; - LPC_DATA_REG = lpc_base_addr + 1; - - cpld_device = kzalloc(sizeof(struct cpld_dev_type), GFP_KERNEL); - if (!cpld_device) - goto error3; - cpld_device->io_resource = request_region(lpc_base_addr, - lpc_io_space_size, "lpc-i2c"); - if (!cpld_device->io_resource) { - printk("lpc: claim I/O resource fail\n"); - goto error2; - } - sema_init(&cpld_device->sem, 1); - - if (cpld_major) { - dev = MKDEV(cpld_major, cpld_minor); - rc = register_chrdev_region(dev, 1, CIG_CPLD_CHR_NAME); - } else { - rc = alloc_chrdev_region(&dev, cpld_major, 1, CIG_CPLD_CHR_NAME); - cpld_major = MAJOR(dev); - } - - cpld_setup_cdev(cpld_device); - - cpld_class = class_create(THIS_MODULE,CIG_CPLD_CHR_NAME); - if (!cpld_class) { - DEB2(printk("failed to create class\n");) - goto error1; - } - - cpld_class->p->subsys.kobj.ktype= &cpld_kobj_type; - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "read"); - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "write"); - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "reads"); - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "writes"); - cpld_sysfs_add_attr(&cpld_class->p->subsys.kobj, "version"); - - cpld_dev = device_create(cpld_class, NULL, dev, NULL, CIG_CPLD_CHR_NAME); - -/**************************************************************************************/ - - rval = lpc_bus_init(); - rval = lpc_register_driver(&i2c_lpc_driver, 1); - -/**************************************************************************************/ - return 0; -error1: - cdev_del(&cpld_device->cdev); - unregister_chrdev_region(dev, 1); -error2: - release_resource(cpld_device->io_resource); -error3: - kfree(cpld_device); - - return rc; -} - -static void __exit cpld_exit(void) -{ - - DEB2(printk("cpld_exit\n")); - - lpc_unregister_driver(&i2c_lpc_driver); - lpc_bus_exit(); - dev_t devno = MKDEV(cpld_major, cpld_minor); - - cdev_del(&cpld_device->cdev); - if (cpld_class) { - device_destroy(cpld_class, devno); - class_destroy(cpld_class); - } - - if (cpld_device) { - if (cpld_device->io_resource) - release_resource(cpld_device->io_resource); - - kfree(cpld_device); - } - unregister_chrdev_region(devno, 1); - - -} - -module_param(cpld_major, int, S_IRUGO); -module_param(cpld_minor, int, S_IRUGO); -module_param(i2c_debug, int, S_IRUGO); -module_param(board_id, int, S_IRUGO); - -module_init(cpld_init); -module_exit(cpld_exit); - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs6436-56p-cpld driver"); -MODULE_LICENSE("GPL"); - - -/********************************************** End ********************************************************/ - - - diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-fan.c b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-fan.c deleted file mode 100644 index 33eaaa84030..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-fan.c +++ /dev/null @@ -1,521 +0,0 @@ -/* - * A hwmon driver for the CIG cs6436-56P fan - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -#define FAN_SPEED_DUTY_TO_CPLD_STEP 10 - -static struct cs6436_56p_fan_data *cs6436_56p_fan_update_device(struct device *dev); -static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); -static ssize_t set_fan_direction(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); - - -extern int cig_cpld_write_register(u8 reg_off, u8 val); -extern int cig_cpld_read_register(u8 reg_off, u8 *val); - -/* fan related data, the index should match sysfs_fan_attributes - */ -static const u8 fan_reg[] = { - 0x41, /* fan enable/disable */ - 0x40, /* fan PWM(for all fan) */ - 0x42, /* front fan 1 speed(rpm) */ - 0x44, /* front fan 2 speed(rpm) */ - 0x46, /* front fan 3 speed(rpm) */ - 0x48, /* front fan 4 speed(rpm) */ - 0x4a, /* front fan 5 speed(rpm) */ - 0x43, /* rear fan 1 speed(rpm) */ - 0x45, /* rear fan 2 speed(rpm) */ - 0x47, /* rear fan 3 speed(rpm) */ - 0x49, /* rear fan 4 speed(rpm) */ - 0x4b, /* rear fan 5 speed(rpm) */ - 0x4c, /* fan direction rear to front or front to rear */ -}; - - -/* Each client has this additional data */ -struct cs6436_56p_fan_data { - struct platform_device *pdev; - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* != 0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */ -}; - -static struct cs6436_56p_fan_data *fan_data = NULL; - -enum fan_id { - FAN1_ID, - FAN2_ID, - FAN3_ID, - FAN4_ID, - FAN5_ID, -}; - -enum sysfs_fan_attributes { - FAN_STATE_REG, - FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */ - FAN1_FRONT_SPEED_RPM, - FAN2_FRONT_SPEED_RPM, - FAN3_FRONT_SPEED_RPM, - FAN4_FRONT_SPEED_RPM, - FAN5_FRONT_SPEED_RPM, - FAN1_REAR_SPEED_RPM, - FAN2_REAR_SPEED_RPM, - FAN3_REAR_SPEED_RPM, - FAN4_REAR_SPEED_RPM, - FAN5_REAR_SPEED_RPM, - FAN_DIRECTION, - FAN1_STATE, - FAN2_STATE, - FAN3_STATE, - FAN4_STATE, - FAN5_STATE, - FAN1_FAULT, - FAN2_FAULT, - FAN3_FAULT, - FAN4_FAULT, - FAN5_FAULT, - FAN1_DIRECTION, - FAN2_DIRECTION, - FAN3_DIRECTION, - FAN4_DIRECTION, - FAN5_DIRECTION, -}; - -/* Define attributes - */ -#define DECLARE_FAN_STATE_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_state, S_IRUGO, fan_show_value, NULL, FAN##index##_STATE) -#define DECLARE_FAN_STATE_ATTR(index) &sensor_dev_attr_fan##index##_state.dev_attr.attr - -#define DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_fault, S_IRUGO, fan_show_value, NULL, FAN##index##_FAULT) -#define DECLARE_FAN_FAULT_ATTR(index) &sensor_dev_attr_fan##index##_fault.dev_attr.attr - -#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE) -#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr - -#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_front_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\ - static SENSOR_DEVICE_ATTR(fan##index##_rear_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM) -#define DECLARE_FAN_SPEED_RPM_ATTR(index) &sensor_dev_attr_fan##index##_front_speed_rpm.dev_attr.attr, \ - &sensor_dev_attr_fan##index##_rear_speed_rpm.dev_attr.attr - -#define DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_direction, S_IWUSR | S_IRUGO, fan_show_value, set_fan_direction, FAN##index##_DIRECTION) -#define DECLARE_FAN_DIRECTION_ATTR(index) &sensor_dev_attr_fan##index##_direction.dev_attr.attr - - -/* 5 fan state attributes in this platform */ -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(1); -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(2); -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(3); -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(4); -DECLARE_FAN_STATE_SENSOR_DEV_ATTR(5); - - -/* 5 fan fault attributes in this platform */ -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(4); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(5); - -/* 5 fan speed(rpm) attributes in this platform */ -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(4); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(5); - -/* 1 fan duty cycle attribute in this platform */ -DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(); - -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(1); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(2); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(3); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(4); -DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5); - - -static struct attribute *cs6436_56p_fan_attributes[] = { - /* fan related attributes */ - DECLARE_FAN_STATE_ATTR(1), - DECLARE_FAN_STATE_ATTR(2), - DECLARE_FAN_STATE_ATTR(3), - DECLARE_FAN_STATE_ATTR(4), - DECLARE_FAN_STATE_ATTR(5), - DECLARE_FAN_FAULT_ATTR(1), - DECLARE_FAN_FAULT_ATTR(2), - DECLARE_FAN_FAULT_ATTR(3), - DECLARE_FAN_FAULT_ATTR(4), - DECLARE_FAN_FAULT_ATTR(5), - DECLARE_FAN_SPEED_RPM_ATTR(1), - DECLARE_FAN_SPEED_RPM_ATTR(2), - DECLARE_FAN_SPEED_RPM_ATTR(3), - DECLARE_FAN_SPEED_RPM_ATTR(4), - DECLARE_FAN_SPEED_RPM_ATTR(5), - DECLARE_FAN_DUTY_CYCLE_ATTR(), - DECLARE_FAN_DIRECTION_ATTR(1), - DECLARE_FAN_DIRECTION_ATTR(2), - DECLARE_FAN_DIRECTION_ATTR(3), - DECLARE_FAN_DIRECTION_ATTR(4), - DECLARE_FAN_DIRECTION_ATTR(5), - NULL -}; - -#define FAN_MAX_DUTY_CYCLE 100 -#define FAN_REG_VAL_TO_SPEED_RPM_STEP 100 - -/* fan utility functions - */ -static u32 reg_val_to_duty_cycle(u8 reg_val) -{ - if (reg_val -== 0xFF) { - return 100; - } - return ((u32)(reg_val) * 100)/ 255; -} - -static u8 duty_cycle_to_reg_val(u8 duty_cycle) -{ - if (duty_cycle >= FAN_MAX_DUTY_CYCLE) { - return 0xFF; - } - - return 255 / 10 * (duty_cycle / 10); -} - -static u32 reg_val_to_speed_rpm(u8 reg_val) -{ - return (u32)reg_val * FAN_REG_VAL_TO_SPEED_RPM_STEP; -} - -static u8 reg_val_to_is_state(u8 reg_val, enum fan_id id) -{ - u8 mask = (1 << id); - - reg_val &= mask; - - return reg_val ? 0 : 1; -} - -static u8 is_fan_fault(struct cs6436_56p_fan_data *data, enum fan_id id) -{ - u8 ret = 1; - int front_fan_index = FAN1_FRONT_SPEED_RPM + id; - int rear_fan_index = FAN1_REAR_SPEED_RPM + id; - - /* Check if the speed of front or rear fan is ZERO, - */ - if (reg_val_to_speed_rpm(data->reg_val[front_fan_index]) && - reg_val_to_speed_rpm(data->reg_val[rear_fan_index])) { - ret = 0; - } - - return ret; -} - - -static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - int error, value; - - error = kstrtoint(buf, 10, &value); - if (error) - return error; - - if (value <= 0 || value > FAN_MAX_DUTY_CYCLE) - return -EINVAL; - - cig_cpld_write_register(fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); - - return count; -} - -static ssize_t set_fan_direction(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - int error, value,fan_index; - u8 mask,reg_val; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - fan_index = attr->index - FAN1_DIRECTION; - error = kstrtoint(buf, 10, &value); - if (error) - return error; - - if (!(value == 0 || value == 1)) - return -EINVAL; - - - cig_cpld_read_register(fan_reg[FAN_DIRECTION],®_val); - - if(value == 1) - { - reg_val |= (1 << fan_index); - } - else - { - reg_val &= ~(1 << fan_index); - } - - cig_cpld_write_register(fan_reg[FAN_DIRECTION], reg_val); - - return count; -} - - - - - -static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - - cs6436_56p_fan_update_device(dev); - - struct cs6436_56p_fan_data *data = fan_data; - - ssize_t ret = 0; - - if (data->valid) { - switch (attr->index) { - - case FAN1_STATE: - case FAN2_STATE: - case FAN3_STATE: - case FAN4_STATE: - case FAN5_STATE: - //printk("FAN_STATE_REG: 0x%x\n", data->reg_val[FAN_STATE_REG]); - //printk("index: %d\n", attr->index); - ret = sprintf(buf, "%d\n", - reg_val_to_is_state(data->reg_val[FAN_STATE_REG], - attr->index - FAN1_STATE)); - break; - case FAN_DUTY_CYCLE_PERCENTAGE: - { - u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]); - ret = sprintf(buf, "%u\n", duty_cycle); - break; - } - case FAN1_FRONT_SPEED_RPM: - case FAN2_FRONT_SPEED_RPM: - case FAN3_FRONT_SPEED_RPM: - case FAN4_FRONT_SPEED_RPM: - case FAN5_FRONT_SPEED_RPM: - case FAN1_REAR_SPEED_RPM: - case FAN2_REAR_SPEED_RPM: - case FAN3_REAR_SPEED_RPM: - case FAN4_REAR_SPEED_RPM: - case FAN5_REAR_SPEED_RPM: -// printk("FAN_seed_REG: 0x%x\n", data->reg_val[attr->index]); -// printk("index: %d\n", attr->index); - ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index])); - break; - - case FAN1_FAULT: - case FAN2_FAULT: - case FAN3_FAULT: - case FAN4_FAULT: - case FAN5_FAULT: - ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT)); - break; - case FAN1_DIRECTION: - case FAN2_DIRECTION: - case FAN3_DIRECTION: - case FAN4_DIRECTION: - case FAN5_DIRECTION: - ret = sprintf(buf, "%d\n",reg_val_to_is_state(data->reg_val[FAN_DIRECTION],attr->index - FAN1_DIRECTION)); - break; - default: - break; - } - } - - return ret; -} - -static const struct attribute_group cs6436_56p_fan_group = { - .attrs = cs6436_56p_fan_attributes, -}; - -static struct cs6436_56p_fan_data *cs6436_56p_fan_update_device(struct device *dev) -{ - struct cs6436_56p_fan_data *data = fan_data; - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || - !data->valid) { - int i; - - data->valid = 0; - - /* Update fan data - */ - for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) { - u8 status; - (void)cig_cpld_read_register(fan_reg[i], &status); - - if (status < 0) { - data->valid = 0; - mutex_unlock(&data->update_lock); - return data; - } - else { - data->reg_val[i] = status; - } - } - - data->last_updated = jiffies; - data->valid = 1; - } - - mutex_unlock(&data->update_lock); - - return data; -} - -static int cs6436_56p_fan_probe(struct platform_device *pdev) -{ - int status = -1; - /* Register sysfs hooks */ - status = sysfs_create_group(&pdev->dev.kobj, &cs6436_56p_fan_group); - if (status) { - goto exit; - - } - - fan_data->hwmon_dev = hwmon_device_register(&pdev->dev); - if (IS_ERR(fan_data->hwmon_dev)) { - status = PTR_ERR(fan_data->hwmon_dev); - goto exit_remove; - } - - dev_info(&pdev->dev, "cs6436_56p_fan\n"); - - return 0; - -exit_remove: - sysfs_remove_group(&pdev->dev.kobj, &cs6436_56p_fan_group); -exit: - return status; -} - -static int cs6436_56p_fan_remove(struct platform_device *pdev) -{ - hwmon_device_unregister(fan_data->hwmon_dev); - sysfs_remove_group(&fan_data->pdev->dev.kobj, &cs6436_56p_fan_group); - - return 0; -} - -#define DRVNAME "cs6436_56p_fan" - -static struct platform_driver cs6436_56p_fan_driver = { - .probe = cs6436_56p_fan_probe, - .remove = cs6436_56p_fan_remove, - .driver = { - .name = DRVNAME, - .owner = THIS_MODULE, - }, -}; - - - - - -static int __init cs6436_56p_fan_init(void) -{ - int ret; - - cig_cpld_write_register(0x40, duty_cycle_to_reg_val(50)); - - ret = platform_driver_register(&cs6436_56p_fan_driver); - if (ret < 0) { - goto exit; - } - - fan_data = kzalloc(sizeof(struct cs6436_56p_fan_data), GFP_KERNEL); - if (!fan_data) { - ret = -ENOMEM; - platform_driver_unregister(&cs6436_56p_fan_driver); - goto exit; - } - - mutex_init(&fan_data->update_lock); - fan_data->valid = 0; - - fan_data->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); - if (IS_ERR(fan_data->pdev)) { - ret = PTR_ERR(fan_data->pdev); - platform_driver_unregister(&cs6436_56p_fan_driver); - kfree(fan_data); - goto exit; - } - -exit: - return ret; -} - -static void __exit cs6436_56p_fan_exit(void) -{ - platform_device_unregister(fan_data->pdev); - platform_driver_unregister(&cs6436_56p_fan_driver); - kfree(fan_data); -} - -MODULE_AUTHOR("CIG"); -MODULE_DESCRIPTION("cs6436_56p_fan driver"); -MODULE_LICENSE("GPL"); - -module_init(cs6436_56p_fan_init); -module_exit(cs6436_56p_fan_exit); - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs6436_56p_fan driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-led.c b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-led.c deleted file mode 100644 index 2f442bac260..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-led.c +++ /dev/null @@ -1,593 +0,0 @@ -/* - * A hwmon driver for the CIG cs6436-56P LED - * - * Copyright (C) 2018 Cambridge, Inc. - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/*#define DEBUG*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -extern int cig_cpld_write_register(u8 reg_off, u8 val); - -extern int cig_cpld_read_register(u8 reg_off, u8 *val); - -extern void led_classdev_unregister(struct led_classdev *led_cdev); -extern void led_classdev_resume(struct led_classdev *led_cdev); -extern void led_classdev_suspend(struct led_classdev *led_cdev); - -#define DRVNAME "cs6436_56p_led" - -struct cs6436_56p_led_data { - struct platform_device *pdev; - struct mutex update_lock; - char valid; /* != 0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 reg_val[6]; /* 0: system & location - 1: PSU1 &PSU12 - 2: fan & management - 3: console & ToD - 4-5 : fan1-fan5*/ -}; - -static struct cs6436_56p_led_data *ledctl = NULL; - -/* LED related data - */ -#define LED_TYPE_PSU1_REG_MASK 0x0C -#define LED_MODE_PSU1_GREEN_MASK 0x08 -#define LED_MODE_PSU1_RED_MASK 0x04 -#define LED_MODE_PSU1_AMBER_MASK 0x0C -#define LED_MODE_PSU1_OFF_MASK 0x00 - -#define LED_TYPE_PSU2_REG_MASK 0x30 -#define LED_MODE_PSU2_GREEN_MASK 0x20 -#define LED_MODE_PSU2_RED_MASK 0x10 -#define LED_MODE_PSU2_AMBER_MASK 0x30 -#define LED_MODE_PSU2_OFF_MASK 0x00 - -#define LED_TYPE_SYS_REG_MASK 0xF0 -#define LED_MODE_SYS_GREEN_MASK 0x40 -#define LED_MODE_SYS_RED_MASK 0x20 -#define LED_MODE_SYS_AMBER_MASK 0x60 -#define LED_MODE_SYS_AMBER_FLASHING_MASK 0x70 -#define LED_MODE_SYS_OFF_MASK 0x00 - -#define LED_TYPE_RES_REG_MASK 0x0F -#define LED_MODE_RES_GREEN_MASK 0x04 -#define LED_MODE_RES_RED_MASK 0x02 -#define LED_MODE_RES_AMBER_MASK 0x06 -#define LED_MODE_RES_AMBER_FLASHING_MASK 0x07 -#define LED_MODE_RES_OFF_MASK 0x00 - -#define LED_TYPE_FAN_REG_MASK 0x03 -#define LED_MODE_FAN_GREEN_MASK 0x02 -#define LED_MODE_FAN_RED_MASK 0x01 -#define LED_MODE_FAN_AMBER_MASK 0x03 -#define LED_MODE_FAN_OFF_MASK 0x00 - -#define LED_TYPE_FAN1_REG_MASK 0x03 -#define LED_TYPE_FAN2_REG_MASK 0x0C -#define LED_TYPE_FAN3_REG_MASK 0x30 -#define LED_TYPE_FAN4_REG_MASK 0xC0 -#define LED_TYPE_FAN5_REG_MASK 0x03 - -#define LED_MODE_FANX_GREEN_MASK 0x02 -#define LED_MODE_FANX_RED_MASK 0x01 -#define LED_MODE_FANX_AMBER_MASK 0x03 -#define LED_MODE_FANX_OFF_MASK 0x00 - -enum led_type { - LED_TYPE_SYS, - LED_TYPE_PSU2, - LED_TYPE_PSU1, - LED_TYPE_FAN, - LED_TYPE_FAN1, - LED_TYPE_FAN2, - LED_TYPE_FAN3, - LED_TYPE_FAN4, - LED_TYPE_FAN5, -}; - -static const u8 led_reg[] = { - 0x30, /* system & reserved*/ - 0x31, /* fan & PSU1 & PSU2 */ - 0x32, /* FAN5 LED */ - 0x33, /* FAN1-4 LED */ -}; - - -enum led_light_mode { - LED_MODE_OFF = 0, - LED_MODE_GREEN, - LED_MODE_AMBER, - LED_MODE_RED, - LED_MODE_GREEN_BLINK, - LED_MODE_AMBER_BLINK, - LED_MODE_RED_BLINK, - LED_MODE_GREEN_FLASHING, - LED_MODE_AMBER_FLASHING, - LED_MODE_RED_FLASHING, - LED_MODE_AUTO, - LED_MODE_UNKNOWN -}; - -struct led_type_mode { - enum led_type type; - int type_mask; - enum led_light_mode mode; - int mode_mask; -}; - -static struct led_type_mode led_type_mode_data[] = { -{LED_TYPE_PSU1, LED_TYPE_PSU1_REG_MASK, LED_MODE_GREEN, LED_MODE_PSU1_GREEN_MASK}, -{LED_TYPE_PSU1, LED_TYPE_PSU1_REG_MASK, LED_MODE_AMBER, LED_MODE_PSU1_AMBER_MASK}, -{LED_TYPE_PSU1, LED_TYPE_PSU1_REG_MASK, LED_MODE_RED, LED_MODE_PSU1_RED_MASK}, -{LED_TYPE_PSU1, LED_TYPE_PSU1_REG_MASK, LED_MODE_OFF, LED_MODE_PSU1_OFF_MASK}, - -{LED_TYPE_PSU2, LED_TYPE_PSU2_REG_MASK, LED_MODE_GREEN, LED_MODE_PSU2_GREEN_MASK}, -{LED_TYPE_PSU2, LED_TYPE_PSU2_REG_MASK, LED_MODE_AMBER, LED_MODE_PSU2_AMBER_MASK}, -{LED_TYPE_PSU2, LED_TYPE_PSU2_REG_MASK, LED_MODE_RED, LED_MODE_PSU2_RED_MASK}, -{LED_TYPE_PSU2, LED_TYPE_PSU2_REG_MASK, LED_MODE_OFF, LED_MODE_PSU2_OFF_MASK}, - -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_GREEN, LED_MODE_SYS_GREEN_MASK}, -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_AMBER, LED_MODE_SYS_AMBER_MASK}, -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_RED, LED_MODE_SYS_RED_MASK}, -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_AMBER_FLASHING, LED_MODE_SYS_AMBER_FLASHING_MASK}, -{LED_TYPE_SYS, LED_TYPE_SYS_REG_MASK, LED_MODE_OFF, LED_MODE_SYS_OFF_MASK}, - -{LED_TYPE_FAN, LED_TYPE_FAN_REG_MASK, LED_MODE_GREEN, LED_MODE_FAN_GREEN_MASK}, -{LED_TYPE_FAN, LED_TYPE_FAN_REG_MASK, LED_MODE_AMBER, LED_MODE_FAN_AMBER_MASK}, -{LED_TYPE_FAN, LED_TYPE_FAN_REG_MASK, LED_MODE_RED, LED_MODE_FAN_RED_MASK}, -{LED_TYPE_FAN, LED_TYPE_FAN_REG_MASK, LED_MODE_OFF, LED_MODE_FAN_OFF_MASK}, - -{LED_TYPE_FAN1, LED_TYPE_FAN1_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 0}, -{LED_TYPE_FAN1, LED_TYPE_FAN1_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 0}, -{LED_TYPE_FAN1, LED_TYPE_FAN1_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 0}, -{LED_TYPE_FAN1, LED_TYPE_FAN1_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 0}, -{LED_TYPE_FAN2, LED_TYPE_FAN2_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 2}, -{LED_TYPE_FAN2, LED_TYPE_FAN2_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 2}, -{LED_TYPE_FAN2, LED_TYPE_FAN2_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 2}, -{LED_TYPE_FAN2, LED_TYPE_FAN2_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 2}, -{LED_TYPE_FAN3, LED_TYPE_FAN3_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 4}, -{LED_TYPE_FAN3, LED_TYPE_FAN3_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 4}, -{LED_TYPE_FAN3, LED_TYPE_FAN3_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 4}, -{LED_TYPE_FAN3, LED_TYPE_FAN3_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 4}, -{LED_TYPE_FAN4, LED_TYPE_FAN4_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 6}, -{LED_TYPE_FAN4, LED_TYPE_FAN4_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 6}, -{LED_TYPE_FAN4, LED_TYPE_FAN4_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 6}, -{LED_TYPE_FAN4, LED_TYPE_FAN4_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 6}, -{LED_TYPE_FAN5, LED_TYPE_FAN5_REG_MASK, LED_MODE_GREEN, LED_MODE_FANX_GREEN_MASK << 0}, -{LED_TYPE_FAN5, LED_TYPE_FAN5_REG_MASK, LED_MODE_RED, LED_MODE_FANX_RED_MASK << 0}, -{LED_TYPE_FAN5, LED_TYPE_FAN5_REG_MASK, LED_MODE_AMBER, LED_MODE_FANX_AMBER_MASK << 0}, -{LED_TYPE_FAN5, LED_TYPE_FAN5_REG_MASK, LED_MODE_OFF, LED_MODE_FANX_OFF_MASK << 0}, -}; - -struct fanx_info_s { - u8 cname; /* device name */ - enum led_type type; - u8 reg_id; /* map to led_reg & reg_val */ -}; - -static struct fanx_info_s fanx_info[] = { - {'1', LED_TYPE_FAN1, 3}, - {'2', LED_TYPE_FAN2, 3}, - {'3', LED_TYPE_FAN3, 3}, - {'4', LED_TYPE_FAN4, 3}, - {'5', LED_TYPE_FAN5, 2}, -}; - - -static int led_reg_val_to_light_mode(enum led_type type, u8 reg_val) { - int i; - - for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { - - if (type != led_type_mode_data[i].type) - continue; - - if ((led_type_mode_data[i].type_mask & reg_val) == - led_type_mode_data[i].mode_mask) - { - return led_type_mode_data[i].mode; - } - } - - return 0; -} - -static u8 led_light_mode_to_reg_val(enum led_type type, - enum led_light_mode mode, u8 reg_val) { - int i; - - for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { - if (type != led_type_mode_data[i].type) - continue; - - if (mode != led_type_mode_data[i].mode) - continue; - - reg_val = led_type_mode_data[i].mode_mask | - (reg_val & (~led_type_mode_data[i].type_mask)); - break; - } - - return reg_val; -} - -static void cs6436_56p_led_update(void) -{ - mutex_lock(&ledctl->update_lock); - - if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2) - || !ledctl->valid) { - int i; - - dev_dbg(&ledctl->pdev->dev, "Starting cs6436_56p_led update\n"); - - /* Update LED data - */ - for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { - u8 status; - cig_cpld_read_register(led_reg[i], &status); - - if (status < 0) { - ledctl->valid = 0; - dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg[i], status); - goto exit; - } - else - { - ledctl->reg_val[i] = status; - } - } - - ledctl->last_updated = jiffies; - ledctl->valid = 1; - } - -exit: - mutex_unlock(&ledctl->update_lock); -} - -static void cs6436_56p_led_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode, - u8 reg, enum led_type type) -{ - u8 reg_val; - mutex_lock(&ledctl->update_lock); - - cig_cpld_read_register(reg, ®_val); - if (reg_val < 0) { - dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val); - goto exit; - } - - reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val); - - cig_cpld_write_register(reg, reg_val); - - /* to prevent the slow-update issue */ - ledctl->valid = 0; - -exit: - mutex_unlock(&ledctl->update_lock); -} - -static void cs6436_56p_led_fanx_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - enum led_type led_type1; - int reg_id; - int i, nsize; - int ncount = sizeof(fanx_info)/sizeof(struct fanx_info_s); - - for(i=0;iname); - - if (led_cdev->name[nsize-1] == fanx_info[i].cname) - { - led_type1 = fanx_info[i].type; - reg_id = fanx_info[i].reg_id; - - cs6436_56p_led_set(led_cdev, led_light_mode, led_reg[reg_id], led_type1); - return; - } - } -} - - -static enum led_brightness cs6436_56p_led_fanx_get(struct led_classdev *cdev) -{ - enum led_type led_type1; - int reg_id; - int i, nsize; - int ncount = sizeof(fanx_info)/sizeof(struct fanx_info_s); - - for(i=0;iname); - - if (cdev->name[nsize-1] == fanx_info[i].cname) - { - led_type1 = fanx_info[i].type; - reg_id = fanx_info[i].reg_id; - cs6436_56p_led_update(); - return led_reg_val_to_light_mode(led_type1, ledctl->reg_val[reg_id]); - } - } - - return led_reg_val_to_light_mode(LED_TYPE_FAN1, ledctl->reg_val[5]); -} - - -static void cs6436_56p_led_psu1_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - cs6436_56p_led_set(led_cdev, led_light_mode, led_reg[1], LED_TYPE_PSU1); -} - -static enum led_brightness cs6436_56p_led_psu1_get(struct led_classdev *cdev) -{ - cs6436_56p_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_PSU1, ledctl->reg_val[1]); -} - -static void cs6436_56p_led_psu2_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - cs6436_56p_led_set(led_cdev, led_light_mode, led_reg[1], LED_TYPE_PSU2); -} - -static enum led_brightness cs6436_56p_led_psu2_get(struct led_classdev *cdev) -{ - cs6436_56p_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_PSU2, ledctl->reg_val[1]); -} - -static void cs6436_56p_led_sys_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - cs6436_56p_led_set(led_cdev, led_light_mode,led_reg[0], LED_TYPE_SYS); -} - -static enum led_brightness cs6436_56p_led_sys_get(struct led_classdev *cdev) -{ - cs6436_56p_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_SYS, ledctl->reg_val[0]); -} - - -static enum led_brightness cs6436_56p_led_fan_get(struct led_classdev *cdev) -{ - cs6436_56p_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_FAN, ledctl->reg_val[1]); -} - -static void cs6436_56p_led_fan_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - cs6436_56p_led_set(led_cdev, led_light_mode, led_reg[1], LED_TYPE_FAN); -} - - -static struct led_classdev cs6436_56p_leds[] = { - [LED_TYPE_SYS] = { - .name = "cs6436_56p_led::sys", - .default_trigger = "unused", - .brightness_set = cs6436_56p_led_sys_set, - .brightness_get = cs6436_56p_led_sys_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN] = { - .name = "cs6436_56p_led::fan", - .default_trigger = "unused", - .brightness_set = cs6436_56p_led_fan_set, - .brightness_get = cs6436_56p_led_fan_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - - [LED_TYPE_PSU1] = { - .name = "cs6436_56p_led::psu1", - .default_trigger = "unused", - .brightness_set = cs6436_56p_led_psu1_set, - .brightness_get = cs6436_56p_led_psu1_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_PSU2] = { - .name = "cs6436_56p_led::psu2", - .default_trigger = "unused", - .brightness_set = cs6436_56p_led_psu2_set, - .brightness_get = cs6436_56p_led_psu2_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - - [LED_TYPE_FAN1] = { - .name = "cs6436_56p_led::fan1", - .default_trigger = "unused", - .brightness_set = cs6436_56p_led_fanx_set, - .brightness_get = cs6436_56p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN2] = { - .name = "cs6436_56p_led::fan2", - .default_trigger = "unused", - .brightness_set = cs6436_56p_led_fanx_set, - .brightness_get = cs6436_56p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN3] = { - .name = "cs6436_56p_led::fan3", - .default_trigger = "unused", - .brightness_set = cs6436_56p_led_fanx_set, - .brightness_get = cs6436_56p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN4] = { - .name = "cs6436_56p_led::fan4", - .default_trigger = "unused", - .brightness_set = cs6436_56p_led_fanx_set, - .brightness_get = cs6436_56p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_FAN5] = { - .name = "cs6436_56p_led::fan5", - .default_trigger = "unused", - .brightness_set = cs6436_56p_led_fanx_set, - .brightness_get = cs6436_56p_led_fanx_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - } -}; - -static int cs6436_56p_led_suspend(struct platform_device *dev, - pm_message_t state) -{ - int i = 0; - - for (i = 0; i < ARRAY_SIZE(cs6436_56p_leds); i++) { - led_classdev_suspend(&cs6436_56p_leds[i]); - } - - return 0; -} - -static int cs6436_56p_led_resume(struct platform_device *dev) -{ - int i = 0; - - for (i = 0; i < ARRAY_SIZE(cs6436_56p_leds); i++) { - led_classdev_resume(&cs6436_56p_leds[i]); - } - - return 0; -} - -static int cs6436_56p_led_probe(struct platform_device *pdev) -{ - int ret, i; - - for (i = 0; i < ARRAY_SIZE(cs6436_56p_leds); i++) { - ret = led_classdev_register(&pdev->dev, &cs6436_56p_leds[i]); - - if (ret < 0) - break; - } - - /* Check if all LEDs were successfully registered */ - if (i != ARRAY_SIZE(cs6436_56p_leds)) { - int j; - - /* only unregister the LEDs that were successfully registered */ - for (j = 0; j < i; j++) { - led_classdev_unregister(&cs6436_56p_leds[i]); - } - } - - return ret; -} - -static int cs6436_56p_led_remove(struct platform_device *pdev) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(cs6436_56p_leds); i++) { - led_classdev_unregister(&cs6436_56p_leds[i]); - } - - return 0; -} - -static struct platform_driver cs6436_56p_led_driver = { - .probe = cs6436_56p_led_probe, - .remove = cs6436_56p_led_remove, - .suspend = cs6436_56p_led_suspend, - .resume = cs6436_56p_led_resume, - .driver = { - .name = DRVNAME, - .owner = THIS_MODULE, - }, -}; - -static int cs6436_56p_led_default(void) -{ - cig_cpld_write_register(0x30, 0x40);// system green led solid on -} - -static int __init cs6436_56p_led_init(void) -{ - int ret; - - ret = platform_driver_register(&cs6436_56p_led_driver); - if (ret < 0) { - goto exit; - } - - ledctl = kzalloc(sizeof(struct cs6436_56p_led_data), GFP_KERNEL); - if (!ledctl) { - ret = -ENOMEM; - platform_driver_unregister(&cs6436_56p_led_driver); - goto exit; - } - - mutex_init(&ledctl->update_lock); - - ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); - if (IS_ERR(ledctl->pdev)) { - ret = PTR_ERR(ledctl->pdev); - platform_driver_unregister(&cs6436_56p_led_driver); - kfree(ledctl); - goto exit; - } - - cs6436_56p_led_default(); - -exit: - return ret; -} - -static void __exit cs6436_56p_led_exit(void) -{ - platform_device_unregister(ledctl->pdev); - platform_driver_unregister(&cs6436_56p_led_driver); - kfree(ledctl); -} - -module_init(cs6436_56p_led_init); -module_exit(cs6436_56p_led_exit); - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs6436_56p_led driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-psu.c b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-psu.c deleted file mode 100644 index 1a4734d4ba2..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-psu.c +++ /dev/null @@ -1,943 +0,0 @@ -/* - * A hwmon driver for the CIG cs6436-56P Power Module - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "i2c-algo-lpc.h" - - - -#define MAX_FAN_DUTY_CYCLE 100 - -/* Address scanned */ -static const unsigned short normal_i2c[] = {I2C_CLIENT_END }; - -/* This is additional data */ -struct cs6436_56p_psu_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; - unsigned long last_updated; /* In jiffies */ - - /* Registers value */ - u8 vout_mode; - u16 v_in; - u16 v_out; - u16 i_in; - u16 i_out; - u16 p_in; - u16 p_out; - u16 temp_input[3]; - u8 temp_fault; - u8 fan_fault; - u16 fan_duty_cycle[2]; - u16 fan_speed[2]; - u8 mfr_id[8]; - u8 mfr_model[20]; - u8 mfr_serial[20]; - u8 psu_is_present; - u8 psu_is_good; - struct i2c_client *client; - struct bin_attribute *bin; /* eeprom data */ -}; - -static int two_complement_to_int(u16 data, u8 valid_bit, int mask); -static ssize_t set_fan_duty_cycle(struct device *dev, struct device_attribute *dev_attr, const char *buf, size_t count); -static ssize_t for_linear_data(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_fan_fault(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_fan_warning(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_temp_fault(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_temp_warning(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_vout_data(struct device *dev, struct device_attribute *dev_attr, char *buf); -static int cs6436_56p_psu_read_byte(struct i2c_client *client, u8 reg); -static int cs6436_56p_psu_read_word(struct i2c_client *client, u8 reg); -static int cs6436_56p_psu_write_word(struct i2c_client *client, u8 reg, u16 value); -static int cs6436_56p_psu_read_block(struct i2c_client *client, u8 command, u8 *data, int data_len); -static struct cs6436_56p_psu_data *cs6436_56p_psu_update_device(struct device *dev); -static ssize_t for_ascii(struct device *dev, struct device_attribute *dev_attr, char *buf); -static ssize_t for_status(struct device *dev, struct device_attribute *dev_attr, char *buf); - -enum cs6436_56p_psu_sysfs_attributes { - PSU_V_IN, - PSU_V_OUT, - PSU_I_IN, - PSU_I_OUT, - PSU_P_IN, - PSU_P_OUT, - PSU_TEMP1_INPUT, - PSU_TEMP2_INPUT, - PSU_TEMP3_INPUT, - PSU_TEMP_FAULT, - PSU_TEMP_WARN, - PSU_FAN1_FAULT, - PSU_FAN1_WARN, - PSU_FAN1_DUTY_CYCLE, - PSU_FAN1_SPEED, - PSU_MFR_ID, - PSU_MFR_MODEL, - PSU_MFR_SERIAL, - PSU_PRESENT, - PSU_P_GOOD, -}; - -static int two_complement_to_int(u16 data, u8 valid_bit, int mask) -{ - u16 valid_data = data & mask; - - bool is_negative = valid_data >> (valid_bit - 1); - return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data; -} - -static ssize_t set_fan_duty_cycle(struct device *dev, struct device_attribute \ - *dev_attr, const char *buf, size_t count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct i2c_client *client = to_i2c_client(dev); - struct cs6436_56p_psu_data *data = i2c_get_clientdata(client); - int nr = (attr->index == PSU_FAN1_DUTY_CYCLE) ? 0 : 1; - long speed; - int error; - - if (data->valid != 1) - { - return -ENODEV; - } - - error = kstrtol(buf, 10, &speed); - if (error) - return error; - - if (speed < 0 || speed > MAX_FAN_DUTY_CYCLE) - return -EINVAL; - - - mutex_lock(&data->update_lock); - data->fan_duty_cycle[nr] = speed; - cs6436_56p_psu_write_word(client, 0x3B + nr, data->fan_duty_cycle[nr]); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t for_linear_data(struct device *dev, struct device_attribute *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs6436_56p_psu_data *data = cs6436_56p_psu_update_device(dev); - - u16 value = 0; - int exponent, mantissa; - int multiplier = 1000; - - if (data->valid != 1) - { - return -ENODEV; - } - - switch (attr->index) { - case PSU_V_IN: - value = data->v_in; - break; - case PSU_I_IN: - value = data->i_in; - break; - case PSU_I_OUT: - value = data->i_out; - break; - case PSU_P_IN: - value = data->p_in; - break; - case PSU_P_OUT: - value = data->p_out; - break; - case PSU_TEMP1_INPUT: - value = data->temp_input[0]; - break; - case PSU_TEMP2_INPUT: - value = data->temp_input[1]; - break; - case PSU_TEMP3_INPUT: - value = data->temp_input[2]; - break; - case PSU_FAN1_DUTY_CYCLE: - multiplier = 1; - value = data->fan_duty_cycle[0]; - break; - case PSU_FAN1_SPEED: - multiplier = 1; - value = data->fan_speed[0]; - break; - default: - break; - } - - exponent = two_complement_to_int(value >> 11, 5, 0x1f); - mantissa = two_complement_to_int(value & 0x7ff, 11, 0x7ff); - - return (exponent >= 0) ? \ - sprintf(buf, "%d\n", (mantissa << exponent) * multiplier) :\ - sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent)); -} - -static ssize_t for_fan_fault(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs6436_56p_psu_data *data = cs6436_56p_psu_update_device(dev); - - if (data->valid != 1) - { - return -ENODEV; - } - - u8 shift = (attr->index == PSU_FAN1_FAULT) ? 7 : 6; - - return sprintf(buf, "%d\n", data->fan_fault >> shift); -} - -static ssize_t for_fan_warning(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs6436_56p_psu_data *data = cs6436_56p_psu_update_device(dev); - - if (data->valid != 1) - { - return -ENODEV; - } - - u8 shift = (attr->index == PSU_FAN1_WARN) ? 5 : 4; - - return sprintf(buf, "%d\n", data->fan_fault >> shift); -} - -static ssize_t for_temp_fault(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs6436_56p_psu_data *data = cs6436_56p_psu_update_device(dev); - - if (data->valid != 1) - { - return -ENODEV; - } - - - - return sprintf(buf, "%d\n", data->temp_fault >> 7); -} - -static ssize_t for_temp_warning(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs6436_56p_psu_data *data = cs6436_56p_psu_update_device(dev); - if (data->valid != 1) - { - return -ENODEV; - } - - - return sprintf(buf, "%d\n", data->temp_fault >> 6); -} -static ssize_t for_vout_data(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct cs6436_56p_psu_data *data = cs6436_56p_psu_update_device(dev); - int exponent, mantissa; - int multiplier = 1000; - if (data->valid != 1) - { - return -ENODEV; - } - - - exponent = two_complement_to_int(data->vout_mode, 5, 0x1f); - mantissa = data->v_out; - - return (exponent > 0) ? sprintf(buf, "%d\n", \ - (mantissa << exponent) * multiplier) : \ - sprintf(buf, "%d\n", ((mantissa * multiplier) >> (-exponent))); -} - -static ssize_t for_ascii(struct device *dev, struct device_attribute \ - *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs6436_56p_psu_data *data = cs6436_56p_psu_update_device(dev); - u8 *ptr = NULL; - - if (data->valid != 1) - { - return -ENODEV; - } - - switch (attr->index) { - case PSU_MFR_ID: - ptr = data->mfr_id + 1; - break; - case PSU_MFR_MODEL: - ptr = data->mfr_model + 1; - break; - case PSU_MFR_SERIAL: - ptr = data->mfr_serial + 1; - break; - default: - return 0; - } - return sprintf(buf, "%s\n", ptr); -} - - -static ssize_t for_status(struct device *dev, struct device_attribute *dev_attr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); - struct cs6436_56p_psu_data *data = cs6436_56p_psu_update_device(dev); - u8 *ptr = NULL; - - u8 status = 0; - - if (attr->index == PSU_PRESENT) { - status = data->psu_is_present; - } - else { /* PSU_POWER_GOOD */ - if (!data->valid) { - return -ENODEV; - } - - status = data->psu_is_good; - } - - return sprintf(buf, "%d\n", status); -} - - -static int cs6436_56p_psu_read_byte(struct i2c_client *client, u8 reg) -{ - return i2c_smbus_read_byte_data(client, reg); -} - -static int cs6436_56p_psu_read_word(struct i2c_client *client, u8 reg) -{ - return i2c_smbus_read_word_data(client, reg); -} - -static int cs6436_56p_psu_write_word(struct i2c_client *client, u8 reg, \ - u16 value) -{ - union i2c_smbus_data data; - data.word = value; - return i2c_smbus_xfer(client->adapter, client->addr, - client->flags |= I2C_CLIENT_PEC, - I2C_SMBUS_WRITE, reg, - I2C_SMBUS_WORD_DATA, &data); - -} - -static int cs6436_56p_psu_read_block(struct i2c_client *client, u8 command, \ - u8 *data, int data_len) -{ - int result = i2c_smbus_read_i2c_block_data(client, command, data_len, - data); - if (unlikely(result < 0)) - goto abort; - if (unlikely(result != data_len)) { - result = -EIO; - goto abort; - } - - result = 0; -abort: - return result; - -} - -struct reg_data_byte { - u8 reg; - u8 *value; -}; - -struct reg_data_word { - u8 reg; - u16 *value; -}; - - - -#define EEPROM_NAME "psu_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ - -/* Platform dependent --- */ -static ssize_t psu_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ - int status, retry = 3; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(100); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; - -} - - -static ssize_t psu_page_write(struct i2c_client *client,const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - - - while (count) { - ssize_t status; - - status = psu_eeprom_write(client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - - return retval; -} - - - -static ssize_t psu_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct cs6436_56p_psu_data *data; - ssize_t retval = 0; - struct i2c_client *client; - - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - client = to_i2c_client(container_of(kobj, struct device, kobj)); - - mutex_lock(&data->update_lock); - retval = psu_page_write(client, buf, off, count); - mutex_unlock(&data->update_lock); - return retval; -} - - -static ssize_t psu_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ - int status, retry = 3; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(100); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - -abort: - return status; -} - - - -static ssize_t psu_page_read(struct i2c_client *client,char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - printk("Count = 0, return"); - return count; - } - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - - - while (count) { - ssize_t status; - - status = psu_eeprom_read(client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - - return retval; - -} - - -static ssize_t psu_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct cs6436_56p_psu_data *data; - struct i2c_client *client; - ssize_t retval = 0; - - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - client = to_i2c_client(container_of(kobj, struct device, kobj)); - mutex_lock(&data->update_lock); - retval = psu_page_read(client, buf, off, count); - mutex_unlock(&data->update_lock); - - return retval; -} - - - -static int psu_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = psu_bin_read; - eeprom->write = psu_bin_write; - eeprom->size = EEPROM_SIZE; - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - - -static int psu_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - - -static int psu_i2c_check_functionality(struct i2c_client *client) -{ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_I2C_BLOCK); -} - - - -static int psu_eeprom_probe(struct i2c_client *client, const struct i2c_device_id *dev_id) -{ - int status; - - struct cs6436_56p_psu_data *data; - - if (!psu_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(*data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - i2c_set_clientdata(client, data); - data->valid = 0; - mutex_init(&data->update_lock); - - data->bin = kzalloc(sizeof(struct bin_attribute), GFP_KERNEL); - if (!data->bin) { - status = -ENOMEM; - goto eeprom_bin_error; - } - - /* init eeprom */ - status = psu_sysfs_eeprom_init(&client->dev.kobj, data->bin); - if (status) { - status = -ENOMEM; - goto sys_init_error; - } - - dev_info(&client->dev, "psu eeprom '%s'\n", client->name); - - return 0; - - sys_init_error: - kfree(data->bin); - - eeprom_bin_error: - kfree(data); - - exit: - return status; -} - - - - -static struct cs6436_56p_psu_data *cs6436_56p_psu_update_device(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cs6436_56p_psu_data *data = i2c_get_clientdata(client); - - - mutex_lock(&data->update_lock); - - - if (time_after(jiffies, data->last_updated)) { - int i, status; - u8 command; - struct reg_data_byte regs_byte[] = { - {0x20, &data->vout_mode}, - {0x81, &data->fan_fault}, - {0x7d, &data->temp_fault}, - }; - struct reg_data_word regs_word[] = { - {0x88, &data->v_in}, - {0x8b, &data->v_out}, - {0x89, &data->i_in}, - {0x8c, &data->i_out}, - {0x96, &data->p_out}, - {0x97, &data->p_in}, - {0x8d, &(data->temp_input[0])}, - {0x8e, &(data->temp_input[1])}, - {0x3b, &(data->fan_duty_cycle[0])}, - {0x90, &(data->fan_speed[0])}, - }; - data->valid = 1; - - dev_dbg(&client->dev, "start data update\n"); - - /* one milliseconds from now */ - data->last_updated = jiffies + HZ / 1000; - - for (i = 0; i < ARRAY_SIZE(regs_byte); i++) { - status = cs6436_56p_psu_read_byte(client, - regs_byte[i].reg); - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", - regs_byte[i].reg, status); - *(regs_byte[i].value) = 0; - data->valid = 0; - } else { - *(regs_byte[i].value) = status; - } - } - - for (i = 0; i < ARRAY_SIZE(regs_word); i++) { - status = cs6436_56p_psu_read_word(client, - regs_word[i].reg); - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", - regs_word[i].reg, status); - *(regs_word[i].value) = 0; - data->valid = 0; - } else { - *(regs_word[i].value) = status; - } - } - - command = 0x99; /* PSU mfr_id */ - status = cs6436_56p_psu_read_block(client, command, - data->mfr_id, ARRAY_SIZE(data->mfr_id) - 1); - data->mfr_id[ARRAY_SIZE(data->mfr_id) - 1] = '\0'; - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", command, status); - memset(data->mfr_id, 0, sizeof(data->mfr_id)); - data->valid = 0; - } - - command = 0x9a; /* PSU mfr_model */ - status = cs6436_56p_psu_read_block(client, command, - data->mfr_model, ARRAY_SIZE(data->mfr_model) - 1); - data->mfr_model[ARRAY_SIZE(data->mfr_model) - 1] = '\0'; - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", command, status); - memset(data->mfr_model, 0, sizeof(data->mfr_id)); - data->valid = 0; - } - - command = 0x9e; /* PSU mfr_serial */ - status = cs6436_56p_psu_read_block(client, command, - data->mfr_serial, ARRAY_SIZE(data->mfr_serial) - 1); - data->mfr_serial[ARRAY_SIZE(data->mfr_serial) - 1] = '\0'; - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", command, status); - memset(data->mfr_serial, 0, sizeof(data->mfr_id)); - data->valid = 0; - } - - data->psu_is_present = strlen(data->mfr_id) > 1 ? 1:0; - if(data->psu_is_present) - { - data->psu_is_good = ((data->fan_fault) || (data->temp_fault))? 0:1; - } - else - { - data->valid = 0; - data->psu_is_good = 0; - } - } - - mutex_unlock(&data->update_lock); - - return data; - -} - -/* sysfs attributes for hwmon */ -static SENSOR_DEVICE_ATTR(psu_v_in, S_IRUGO, for_linear_data, NULL, PSU_V_IN); -static SENSOR_DEVICE_ATTR(psu_v_out, S_IRUGO, for_vout_data, NULL, PSU_V_OUT); -static SENSOR_DEVICE_ATTR(psu_i_in, S_IRUGO, for_linear_data, NULL, PSU_I_IN); -static SENSOR_DEVICE_ATTR(psu_i_out, S_IRUGO, for_linear_data, NULL, PSU_I_OUT); -static SENSOR_DEVICE_ATTR(psu_p_in, S_IRUGO, for_linear_data, NULL, PSU_P_IN); -static SENSOR_DEVICE_ATTR(psu_p_out, S_IRUGO, for_linear_data, NULL, PSU_P_OUT); -static SENSOR_DEVICE_ATTR(psu_temp1_input, S_IRUGO, for_linear_data, NULL, PSU_TEMP1_INPUT); -static SENSOR_DEVICE_ATTR(psu_temp2_input, S_IRUGO, for_linear_data, NULL, PSU_TEMP2_INPUT); -static SENSOR_DEVICE_ATTR(psu_temp3_input, S_IRUGO, for_linear_data, NULL, PSU_TEMP3_INPUT); -static SENSOR_DEVICE_ATTR(psu_temp_fault, S_IRUGO, for_temp_fault, NULL, PSU_TEMP_FAULT); -static SENSOR_DEVICE_ATTR(psu_temp_warning, S_IRUGO, for_temp_warning, NULL, PSU_TEMP_WARN); -static SENSOR_DEVICE_ATTR(psu_fan1_fault, S_IRUGO, for_fan_fault, NULL, PSU_FAN1_FAULT); -static SENSOR_DEVICE_ATTR(psu_fan1_warning, S_IRUGO, for_fan_warning, NULL, PSU_FAN1_WARN); -static SENSOR_DEVICE_ATTR(psu_fan1_duty_cycle_percentage, S_IWUSR | S_IRUGO, for_linear_data, set_fan_duty_cycle, PSU_FAN1_DUTY_CYCLE); -static SENSOR_DEVICE_ATTR(psu_fan1_speed_rpm, S_IRUGO, for_linear_data, NULL, PSU_FAN1_SPEED); -static SENSOR_DEVICE_ATTR(psu_mfr_id, S_IRUGO, for_ascii, NULL, PSU_MFR_ID); -static SENSOR_DEVICE_ATTR(psu_mfr_model, S_IRUGO, for_ascii, NULL, PSU_MFR_MODEL); -static SENSOR_DEVICE_ATTR(psu_mfr_serial, S_IRUGO, for_ascii, NULL, PSU_MFR_SERIAL); -static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, for_status, NULL, PSU_PRESENT); -static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, for_status, NULL, PSU_P_GOOD); - - - -static struct attribute *cs6436_56p_psu_attributes[] = { - &sensor_dev_attr_psu_v_in.dev_attr.attr, - &sensor_dev_attr_psu_v_out.dev_attr.attr, - &sensor_dev_attr_psu_i_in.dev_attr.attr, - &sensor_dev_attr_psu_i_out.dev_attr.attr, - &sensor_dev_attr_psu_p_in.dev_attr.attr, - &sensor_dev_attr_psu_p_out.dev_attr.attr, - &sensor_dev_attr_psu_temp1_input.dev_attr.attr, - &sensor_dev_attr_psu_temp2_input.dev_attr.attr, - &sensor_dev_attr_psu_temp3_input.dev_attr.attr, - &sensor_dev_attr_psu_temp_fault.dev_attr.attr, - &sensor_dev_attr_psu_temp_warning.dev_attr.attr, - &sensor_dev_attr_psu_fan1_fault.dev_attr.attr, - &sensor_dev_attr_psu_fan1_warning.dev_attr.attr, - &sensor_dev_attr_psu_fan1_duty_cycle_percentage.dev_attr.attr, - &sensor_dev_attr_psu_fan1_speed_rpm.dev_attr.attr, - &sensor_dev_attr_psu_mfr_id.dev_attr.attr, - &sensor_dev_attr_psu_mfr_model.dev_attr.attr, - &sensor_dev_attr_psu_mfr_serial.dev_attr.attr, - &sensor_dev_attr_psu_present.dev_attr.attr, - &sensor_dev_attr_psu_power_good.dev_attr.attr, - NULL -}; - -static const struct attribute_group cs6436_56p_psu_group = { - .attrs = cs6436_56p_psu_attributes, -}; - - -static int psu_register_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int status; - - - struct cs6436_56p_psu_data *data; - - if (!psu_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(*data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - i2c_set_clientdata(client, data); - data->valid = 0; - mutex_init(&data->update_lock); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &cs6436_56p_psu_group); - if (status) - goto exit_sysfs_create_group; - - cs6436_56p_sysfs_add_client(client); - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_hwmon_device_register; - } - - /* init eeprom */ - - return 0; - - exit_hwmon_device_register: - sysfs_remove_group(&client->dev.kobj, &cs6436_56p_psu_group); - exit_sysfs_create_group: - kfree(data); - exit: - return status; - -} - - -static int cs6436_56p_psu_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int status; - - if((client->addr == 0x52) ||(client->addr == 0x53)) - { - status = psu_eeprom_probe(client, id); - } - else if((client->addr == 0x5a) ||(client->addr == 0x5b)) - { - status = psu_register_probe(client, id); - } - return status; -} - -static int cs6436_56p_psu_remove(struct i2c_client *client) -{ - cs6436_56p_sysfs_remove_client(client); - - if((client->addr == 0x52) ||(client->addr == 0x53)) - { - struct cs6436_56p_psu_data *data; - data = i2c_get_clientdata(client); - psu_sysfs_eeprom_cleanup(&client->dev.kobj,data->bin); - kfree(data); - } - else if((client->addr == 0x5a) ||(client->addr == 0x5b)) - { - struct cs6436_56p_psu_data *data; - data = i2c_get_clientdata(client); - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &cs6436_56p_psu_group); - kfree(data); - } - - return 0; -} - -enum psu_index -{ - cs6436_56p_psu1, - cs6436_56p_psu2 -}; - -static const struct i2c_device_id cs6436_56p_psu_id[] = { - { "cs6436_56p_psu1", cs6436_56p_psu1 }, - { "cs6436_56p_psu2", cs6436_56p_psu2 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, cs6436_56p_psu_id); - -static struct i2c_driver cs6436_56p_psu_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "cs6436_56p_psu", - }, - .probe = cs6436_56p_psu_probe, - .remove = cs6436_56p_psu_remove, - .id_table = cs6436_56p_psu_id, - .address_list = normal_i2c, -}; - -module_i2c_driver(cs6436_56p_psu_driver); - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs6436_56p_psu driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-sfp.c b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-sfp.c deleted file mode 100644 index 5665fa33048..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-sfp.c +++ /dev/null @@ -1,1713 +0,0 @@ -/* - * A hwmon driver for the CIG cs6436-56P SFP Module - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "i2c-algo-lpc.h" - -#define DRIVER_NAME "cs6436_56p_sfp" /* Platform dependent */ - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 3 -#define I2C_RW_RETRY_INTERVAL 100 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) -#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 -#define SFF8472_10G_BASE_MASK 0xF0 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 -#define QSFP_RESET_ADDR 0x1b -#define QSFP_INTER_ADDR 0x1a -#define QSFP_LPMODE_ADDR 0x1c - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int cig_cpld_read_register(u8 reg_off, u8 *val); -extern int cig_cpld_write_register(u8 reg_off, u8 val); - -static ssize_t qsfp_reset_read(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_reset_write(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_inter_read(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_lpmode_read(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_lpmode_write(struct device *dev, struct device_attribute *da, const char *buf, size_t count); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL, - QSFPRESET, - QSFPINT, - QSFPLPMODE -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static SENSOR_DEVICE_ATTR(sfp_reset, S_IWUSR | S_IRUGO, qsfp_reset_read, qsfp_reset_write, QSFPRESET); -static SENSOR_DEVICE_ATTR(sfp_inter, S_IRUGO, qsfp_inter_read, NULL, QSFPINT); -static SENSOR_DEVICE_ATTR(sfp_lpmode, S_IWUSR | S_IRUGO, qsfp_lpmode_read, qsfp_lpmode_write, QSFPLPMODE); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - &sensor_dev_attr_sfp_reset.dev_attr.attr, - &sensor_dev_attr_sfp_inter.dev_attr.attr, - &sensor_dev_attr_sfp_lpmode.dev_attr.attr, - NULL -}; - -/* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); -static struct attribute *sfp_msa_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - NULL -}; - -/* SFP ddm attributes for sysfs */ -static struct attribute *sfp_ddm_attributes[] = { - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -cs6436_56p_sfp1, cs6436_56p_sfp2, cs6436_56p_sfp3, cs6436_56p_sfp4, -cs6436_56p_sfp5, cs6436_56p_sfp6, cs6436_56p_sfp7, cs6436_56p_sfp8, -cs6436_56p_sfp9, cs6436_56p_sfp10, cs6436_56p_sfp11, cs6436_56p_sfp12, -cs6436_56p_sfp13, cs6436_56p_sfp14, cs6436_56p_sfp15, cs6436_56p_sfp16, -cs6436_56p_sfp17, cs6436_56p_sfp18, cs6436_56p_sfp19, cs6436_56p_sfp20, -cs6436_56p_sfp21, cs6436_56p_sfp22, cs6436_56p_sfp23, cs6436_56p_sfp24, -cs6436_56p_sfp25, cs6436_56p_sfp26, cs6436_56p_sfp27, cs6436_56p_sfp28, -cs6436_56p_sfp29, cs6436_56p_sfp30, cs6436_56p_sfp31, cs6436_56p_sfp32, -cs6436_56p_sfp33, cs6436_56p_sfp34, cs6436_56p_sfp35, cs6436_56p_sfp36, -cs6436_56p_sfp37, cs6436_56p_sfp38, cs6436_56p_sfp39, cs6436_56p_sfp40, -cs6436_56p_sfp41, cs6436_56p_sfp42, cs6436_56p_sfp43, cs6436_56p_sfp44, -cs6436_56p_sfp45, cs6436_56p_sfp46, cs6436_56p_sfp47, cs6436_56p_sfp48, -cs6436_56p_sfp49, cs6436_56p_sfp50, cs6436_56p_sfp51, cs6436_56p_sfp52, -cs6436_56p_sfp53, cs6436_56p_sfp54, cs6436_56p_sfp55, cs6436_56p_sfp56 -}; - -#define I2C_DEV_ID(x) { #x, x} - -static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(cs6436_56p_sfp1), -I2C_DEV_ID(cs6436_56p_sfp2), -I2C_DEV_ID(cs6436_56p_sfp3), -I2C_DEV_ID(cs6436_56p_sfp4), -I2C_DEV_ID(cs6436_56p_sfp5), -I2C_DEV_ID(cs6436_56p_sfp6), -I2C_DEV_ID(cs6436_56p_sfp7), -I2C_DEV_ID(cs6436_56p_sfp8), -I2C_DEV_ID(cs6436_56p_sfp9), -I2C_DEV_ID(cs6436_56p_sfp10), -I2C_DEV_ID(cs6436_56p_sfp11), -I2C_DEV_ID(cs6436_56p_sfp12), -I2C_DEV_ID(cs6436_56p_sfp13), -I2C_DEV_ID(cs6436_56p_sfp14), -I2C_DEV_ID(cs6436_56p_sfp15), -I2C_DEV_ID(cs6436_56p_sfp16), -I2C_DEV_ID(cs6436_56p_sfp17), -I2C_DEV_ID(cs6436_56p_sfp18), -I2C_DEV_ID(cs6436_56p_sfp19), -I2C_DEV_ID(cs6436_56p_sfp20), -I2C_DEV_ID(cs6436_56p_sfp21), -I2C_DEV_ID(cs6436_56p_sfp22), -I2C_DEV_ID(cs6436_56p_sfp23), -I2C_DEV_ID(cs6436_56p_sfp24), -I2C_DEV_ID(cs6436_56p_sfp25), -I2C_DEV_ID(cs6436_56p_sfp26), -I2C_DEV_ID(cs6436_56p_sfp27), -I2C_DEV_ID(cs6436_56p_sfp28), -I2C_DEV_ID(cs6436_56p_sfp29), -I2C_DEV_ID(cs6436_56p_sfp30), -I2C_DEV_ID(cs6436_56p_sfp31), -I2C_DEV_ID(cs6436_56p_sfp32), -I2C_DEV_ID(cs6436_56p_sfp33), -I2C_DEV_ID(cs6436_56p_sfp34), -I2C_DEV_ID(cs6436_56p_sfp35), -I2C_DEV_ID(cs6436_56p_sfp36), -I2C_DEV_ID(cs6436_56p_sfp37), -I2C_DEV_ID(cs6436_56p_sfp38), -I2C_DEV_ID(cs6436_56p_sfp39), -I2C_DEV_ID(cs6436_56p_sfp40), -I2C_DEV_ID(cs6436_56p_sfp41), -I2C_DEV_ID(cs6436_56p_sfp42), -I2C_DEV_ID(cs6436_56p_sfp43), -I2C_DEV_ID(cs6436_56p_sfp44), -I2C_DEV_ID(cs6436_56p_sfp45), -I2C_DEV_ID(cs6436_56p_sfp46), -I2C_DEV_ID(cs6436_56p_sfp47), -I2C_DEV_ID(cs6436_56p_sfp48), -I2C_DEV_ID(cs6436_56p_sfp49), -I2C_DEV_ID(cs6436_56p_sfp50), -I2C_DEV_ID(cs6436_56p_sfp51), -I2C_DEV_ID(cs6436_56p_sfp52), -I2C_DEV_ID(cs6436_56p_sfp53), -I2C_DEV_ID(cs6436_56p_sfp54), -I2C_DEV_ID(cs6436_56p_sfp55), -I2C_DEV_ID(cs6436_56p_sfp56), -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); - -/* - * list of valid port types - * note OOM_PORT_TYPE_NOT_PRESENT to indicate no - * module is present in this port - */ -typedef enum oom_driver_port_type_e { - OOM_DRIVER_PORT_TYPE_INVALID, - OOM_DRIVER_PORT_TYPE_NOT_PRESENT, - OOM_DRIVER_PORT_TYPE_SFP, - OOM_DRIVER_PORT_TYPE_SFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP, - OOM_DRIVER_PORT_TYPE_QSFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP28 -} oom_driver_port_type_t; - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct sfp_msa_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[6]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss - 3 => device id - 4 => 10G Ethernet Compliance Codes - to distinguish SFP or SFP+ - 5 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -}; - -struct sfp_ddm_data { - struct eeprom_data eeprom; -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - oom_driver_port_type_t port_type; - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct sfp_msa_data *msa; - struct sfp_ddm_data *ddm; - struct qsfp_data *qsfp; - - struct i2c_client *client; -}; - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - - - -static int cig_cpld_write_sfp_register(u8 sfp_reg_addr, u8 sfp_write_reg_data) -{ - u8 sfp_read_status = 0; - u8 wait_time_out = WAIT_TIME_OUT_COUNT; - - cig_cpld_write_register(ADDR_REG_SFP_STATUS_ADDR, sfp_reg_addr << 1); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_TX, sfp_write_reg_data); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_COMMAND, 0x80); - do{ - cig_cpld_read_register(ADDR_REG_SFP_STATUS_STATUS, &sfp_read_status); - udelay(60); - wait_time_out--; - if(wait_time_out == 0) - break; - }while(sfp_read_status != 0x02); - - if(wait_time_out == 0) - return -1; - - return 1; -} - - -static int cig_cpld_read_sfp_register(u8 sfp_reg_addr, u8 *sfp_read_reg_data) -{ - u8 sfp_read_status = 0; - u8 wait_time_out = WAIT_TIME_OUT_COUNT; - - cig_cpld_write_register(ADDR_REG_SFP_STATUS_ADDR, sfp_reg_addr << 1 | 1); - cig_cpld_write_register(ADDR_REG_SFP_STATUS_COMMAND, 0x80); - do{ - udelay(60); - cig_cpld_read_register(ADDR_REG_SFP_STATUS_STATUS, &sfp_read_status); - wait_time_out--; - if(wait_time_out == 0) - break; - }while(sfp_read_status != 0x01); - - cig_cpld_read_register(ADDR_REG_SFP_STATUS_RX,sfp_read_reg_data); - - if(wait_time_out == 0) - return -1; - - return 1; -} - - - - - - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - int i = 0, j = 0, status = -1; - unsigned char cpld_reg_data = 0,cpld_reg_addr = 0; - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - data->present = 0; - - udelay(6000); - - /* Read present status of port 1~48(SFP port) */ - for (i = 0; i < 6; i++) { - cpld_reg_addr = 1 + i; - - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - - data->present |= (u64)cpld_reg_data << (i*8); - - DEBUG_PRINT("Present status = 0x%lx\r\n", data->present); - } - - /* Read present status of port 49-56(QSFP port) */ - cpld_reg_addr = 25; - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - else { - data->present |= (u64)cpld_reg_data << 48; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static struct sfp_port_data *sfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0, j = 0; - int status = -1; - unsigned char cpld_reg_data = 0,cpld_reg_addr = 0; - - if (time_before(jiffies, data->msa->last_updated + HZ + HZ / 2) && data->msa->valid) { - return data; - } - - DEBUG_PRINT("Starting cs6436_56p sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->msa->valid = 0; - memset(data->msa->status, 0, sizeof(data->msa->status)); - - udelay(6000); - - /* Read status of port 1~48(SFP port) */ - for (i = 0; i < 6; i++) { - cpld_reg_addr = 13+i; - - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - - data->msa->status[0] |= (u64)cpld_reg_data << (i * 8); - - DEBUG_PRINT("tx rx status[0] = 0x%lx\r\n", data->msa->status[0]); - } - - - for (i = 0; i < 6; i++) { - cpld_reg_addr = 19+i; - - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - - data->msa->status[1] |= (u64)cpld_reg_data << (i * 8); - - DEBUG_PRINT("tx rx status[1] = 0x%lx\r\n", data->msa->status[1]); - } - - for (i = 0; i < 6; i++) { - cpld_reg_addr = 7+i; - - status = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_reg_addr, cpld_reg_data, status); - goto exit; - } - - data->msa->status[2] |= (u64)cpld_reg_data << (i * 8); - - DEBUG_PRINT("tx rx status[2] = 0x%lx\r\n", data->msa->status[2]); - } - - data->msa->valid = 1; - data->msa->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - unsigned char cpld_reg_data = 0,cpld_reg_addr = 0,cpld_reg_bit = 0,cpld_reg_val = 0; - long disable; - int error; - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_set_tx_disable(dev, da, buf, count); - } - - error = kstrtol(buf, 10, &disable); - if (error) { - return error; - } - - mutex_lock(&data->update_lock); - - udelay(6000); - - if(data->port <= 48) { - cpld_reg_addr = 19 + data->port / 8; - cpld_reg_bit = 1 << ((data->port) % 8); - } - - /* Read current status */ - error = cig_cpld_read_sfp_register(cpld_reg_addr, &cpld_reg_data); - - /* Update tx_disable status */ - if (disable) { - data->msa->status[1] |= BIT_INDEX(data->port); - cpld_reg_data |= cpld_reg_bit; - } - else { - data->msa->status[1] &= ~ BIT_INDEX(data->port); - cpld_reg_data &= ~cpld_reg_bit; - } - - error = cig_cpld_write_sfp_register(cpld_reg_addr,cpld_reg_data); - - mutex_unlock(&data->update_lock); - return count; -} -/* Platform dependent --- */ - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return !(data->present & BIT_INDEX(data->port)); /* Platform dependent */ -} - -/* Platform dependent +++ */ -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[7] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 56 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5], - values[6]); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d\n", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *sfp_update_port_type(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - u8 buf = 0; - int status; - - mutex_lock(&data->update_lock); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - if (buf != SFF8024_DEVICE_ID_SFP) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - status = sfp_eeprom_read(client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); - data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; - break; - } - case DRIVER_TYPE_QSFP: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); - switch (buf) { - case SFF8024_DEVICE_ID_QSFP: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; - break; - case SFF8024_DEVICE_ID_QSFP_PLUS: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - case SFF8024_DEVICE_ID_QSFP28: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - default: - data->port_type = buf; - break; - } - - break; - } - default: - break; - } - - mutex_unlock(&data->update_lock); - return data; -} - -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - if (!present) { - /* port is not present */ - return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); - } - - sfp_update_port_type(dev); - return sprintf(buf, "%d\n", data->port_type); -} - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - DEBUG_PRINT(""); - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - DEBUG_PRINT(""); - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - DEBUG_PRINT(""); - goto exit; - } - } - msleep(200); - DEBUG_PRINT(""); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - DEBUG_PRINT(""); - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - DEBUG_PRINT(""); - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - DEBUG_PRINT(""); - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_inter_read(struct device *dev, struct device_attribute *da, char *buf) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_INTER_ADDR, &cpld_reg_data); - index = data->port - 48; - index = 1 << index; - val = (cpld_reg_data & index) > 0 ? 1 : 0; - - printk("inter read:data->port = %d, index = %hhu, cpld_reg_data = %hhu\n", data->port, index, cpld_reg_data); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", val); -} - - -static ssize_t qsfp_reset_read(struct device *dev, struct device_attribute *da, char *buf) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_RESET_ADDR, &cpld_reg_data); - index = data->port - 48; - index = 1 << index; - val = (cpld_reg_data & index) > 0 ? 1 : 0; - - printk("reset read:data->port = %d, index = %hhu, cpld_reg_data = %hhu\n", data->port, index, cpld_reg_data); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_reset_write(struct device *dev, struct device_attribute *da, const char *buf, size_t count) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - long usrdata; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - ret = kstrtol(buf, 10, &usrdata); - if (ret) { - return ret; - } - - usrdata = usrdata > 0 ? 1 : 0; - index = data->port - 48; - - DEBUG_PRINT("usrdata = %u, index = %hhu\n", usrdata, index); - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_RESET_ADDR, &cpld_reg_data); - if (ret == 1) - { - - DEBUG_PRINT("cpld_reg_data = %x\n", cpld_reg_data); - cpld_reg_data &= ~(1 << index); - cpld_reg_data |= usrdata << index; - - DEBUG_PRINT("cpld_reg_data = %x\n", cpld_reg_data); - ret = cig_cpld_write_sfp_register(QSFP_RESET_ADDR, cpld_reg_data); - if (1 != ret) - { - DEBUG_PRINT("write failed\n"); - } - } - else - { - DEBUG_PRINT("read failed\n"); - } - - mutex_unlock(&data->update_lock); - - if (ret != 1) - return -1; - - return count; -} - - - - -static ssize_t qsfp_lpmode_read(struct device *dev, struct device_attribute *da, char *buf) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_LPMODE_ADDR, &cpld_reg_data); - index = data->port - 48; - index = 1 << index; - val = (cpld_reg_data & index) > 0 ? 1 : 0; - - printk("lpmode read:data->port = %d, index = %hhu, cpld_reg_data = %hhu\n", data->port, index, cpld_reg_data); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_lpmode_write(struct device *dev, struct device_attribute *da, const char *buf, size_t count) -{ - int present; - int status; - u8 val = 0; - int ret = 0; - u8 cpld_reg_data = 0; - u8 index = 0; - long usrdata; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - ret = kstrtol(buf, 10, &usrdata); - if (ret) { - return ret; - } - - usrdata = usrdata > 0 ? 1 : 0; - index = data->port - 48; - - DEBUG_PRINT("usrdata = %u, index = %hhu\n", usrdata, index); - - mutex_lock(&data->update_lock); - - udelay(6000); - /* Read current status */ - ret = cig_cpld_read_sfp_register(QSFP_LPMODE_ADDR, &cpld_reg_data); - if (ret == 1) - { - - DEBUG_PRINT("cpld_reg_data = %x\n", cpld_reg_data); - cpld_reg_data &= ~(1 << index); - cpld_reg_data |= usrdata << index; - - DEBUG_PRINT("cpld_reg_data = %x\n", cpld_reg_data); - ret = cig_cpld_write_sfp_register(QSFP_LPMODE_ADDR, cpld_reg_data); - if (1 != ret) - { - DEBUG_PRINT("write failed\n"); - } - } - else - { - DEBUG_PRINT("read failed\n"); - } - - mutex_unlock(&data->update_lock); - - if (ret != 1) - return -1; - - return count; -} - - - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT(""); - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - DEBUG_PRINT(""); - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - DEBUG_PRINT(""); - data = qsfp_update_tx_rx_status(dev); - DEBUG_PRINT(""); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - DEBUG_PRINT(""); - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - DEBUG_PRINT(""); - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - data->qsfp->status[1] = disable & 0xF; - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status; - char ddm; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (status == 0) { - /* port is not present */ - return -ENODEV; - } - - status = sfp_eeprom_read(client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); - if (unlikely(status < 0)) { - return status; - } - - return sprintf(buf, "%d\n", !!(ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK)); -} - -/* Platform dependent +++ */ -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0, index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("driver type = (%d)", data->driver_type); - if (data->driver_type == DRIVER_TYPE_QSFP) { - DEBUG_PRINT(""); - return qsfp_show_tx_rx_status(dev, da, buf); - } - - DEBUG_PRINT(""); - data = sfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - if(attr->index == RX_LOS_ALL) { - int i = 0; - u8 values[6] = {0}; - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = (u8)(data->msa->status[2] >> (i * 8)); - } - - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } - - switch (attr->index) { - case TX_FAULT: - index = 0; - break; - case TX_DISABLE: - index = 1; - break; - case RX_LOS: - index = 2; - break; - default: - break; - } - - val = !!(data->msa->status[index] & BIT_INDEX(data->port)); - return sprintf(buf, "%d\n", val); -} -/* Platform dependent --- */ -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} - - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_write(data, buf, off, count); -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_read(data, buf, off, count); -} - -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; - eeprom->size = EEPROM_SIZE; - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; - -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} - -static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_msa_data **data) -{ - int status; - struct sfp_msa_data *msa; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); - if (!msa) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = msa; - dev_info(&client->dev, "sfp msa '%s'\n", client->name); - - cs6436_56p_sysfs_add_client(client); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); -exit_free: - kfree(msa); -exit: - - return status; -} - -static const struct attribute_group sfp_ddm_group = { - .attrs = sfp_ddm_attributes, -}; - -static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_ddm_data **data) -{ - int status; - struct sfp_ddm_data *ddm; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); - if (!ddm) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = ddm; - dev_info(&client->dev, "sfp ddm '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); -exit_free: - kfree(ddm); -exit: - - return status; -} - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); - if (status) { - goto exit_remove; - } - - /* Bring QSFPs out of reset */ - //cig_lpc_write(0x62, 0x15, 0x3F); - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct sfp_port_data *data = NULL; - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - - if (dev_id->driver_data >= cs6436_56p_sfp1 && dev_id->driver_data <= cs6436_56p_sfp48) { - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_MSA; - return sfp_msa_probe(client, dev_id, &data->msa); - } - else if (client->addr == SFP_EEPROM_A2_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_DDM; - return sfp_ddm_probe(client, dev_id, &data->ddm); - } - } - else { /* cs6436_56p_sfp49 ~ cs6436_56p_sfp56 */ - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_QSFP; - return qsfp_probe(client, dev_id, &data->qsfp); - } - } - - return -ENODEV; -} -/* Platform dependent --- */ - -static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); - kfree(data); - return 0; -} - -static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - cs6436_56p_sysfs_remove_client(client); - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_SFP_DDM: - return sfp_ddm_remove(client, data->ddm); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); - } - - return 0; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver cs6436_56p_sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -module_i2c_driver(cs6436_56p_sfp_driver); - - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs6436_56p_sfp driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-sysfs.c b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-sysfs.c deleted file mode 100644 index 89f6bba3aab..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-sysfs.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * A hwmon driver for the CIG cs6436-56P sysfs Module - * - * Copyright (C) 2018 Cambridge, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "i2c-algo-lpc.h" - - -static LIST_HEAD(sysfs_client_list); -static struct mutex list_lock; - -struct sysfs_client_node { - struct i2c_client *client; - struct list_head list; -}; - -#define DEVICE_NAME "cigfs" -static int dev_major; -static struct class *dev_class; -static struct cdev *dev_cdev; -static struct device *dev_device; -static struct class *psu_class; -static struct class *sfp_class; - - -void cs6436_56p_sysfs_add_client(struct i2c_client *client) -{ - struct sysfs_client_node *node = kzalloc(sizeof(struct sysfs_client_node), GFP_KERNEL); - - if (!node) { - dev_dbg(&client->dev, "Can't allocate sysfs_client_node (0x%x)\n", client->addr); - return; - } - node->client = client; - - mutex_lock(&list_lock); - list_add(&node->list, &sysfs_client_list); - mutex_unlock(&list_lock); -} - -EXPORT_SYMBOL(cs6436_56p_sysfs_add_client); - -void cs6436_56p_sysfs_remove_client(struct i2c_client *client) -{ - struct list_head *list_node = NULL; - struct sysfs_client_node *sysfs_node = NULL; - int found = 0; - - mutex_lock(&list_lock); - - list_for_each(list_node, &sysfs_client_list) - { - sysfs_node = list_entry(list_node, struct sysfs_client_node, list); - if (IS_ERR(sysfs_node)) - { - break; - } - if (sysfs_node->client == client) { - found = 1; - break; - } - } - if (found) { - list_del(list_node); - kfree(sysfs_node); - } - - mutex_unlock(&list_lock); -} - -EXPORT_SYMBOL(cs6436_56p_sysfs_remove_client); - -struct class * cs6436_56p_sysfs_create_symclass(char *cls_name) -{ - int rc = 0; - struct class *my_class; -/**************************************************************************************/ - my_class = class_create(THIS_MODULE,cls_name); - if (IS_ERR(my_class)) { - pr_err("failed to create my class\n"); - } - return my_class; - -/**************************************************************************************/ -} - -void cs6436_56p_sysfs_delete_symclass(struct class *my_class) -{ -/**************************************************************************************/ - - if (IS_ERR(my_class)) { - pr_err("Pointer is invaild\n"); - } - class_destroy(my_class); - -/**************************************************************************************/ -} - - - - - -int cs6436_56p_sysfs_create_symlink(struct class *my_class,char * driver_name,char *device_name) -{ - struct list_head *list_node = NULL; - struct sysfs_client_node *sysfs_node = NULL; - int ret = -EPERM; - int rc = 0; - - mutex_lock(&list_lock); - list_for_each(list_node, &sysfs_client_list) - { - sysfs_node = list_entry(list_node, struct sysfs_client_node, list); - if (!strcmp(sysfs_node->client->name,driver_name)) { - rc = sysfs_create_link(&my_class->p->subsys.kobj, &sysfs_node->client->dev.kobj,device_name); - if(rc) - { - pr_err("failed to create symlink %d\n",rc); - } - break; - } - } - mutex_unlock(&list_lock); - return ret; -} - - -int cs6436_56p_sysfs_delete_symlink(struct class *my_class,char * driver_name,char *device_name) -{ - struct list_head *list_node = NULL; - struct sysfs_client_node *sysfs_node = NULL; - int ret = -EPERM; - int rc = 0; - - mutex_lock(&list_lock); - list_for_each(list_node, &sysfs_client_list) - { - sysfs_node = list_entry(list_node, struct sysfs_client_node, list); - if (!strcmp(sysfs_node->client->name,driver_name)) { - sysfs_remove_link(&my_class->p->subsys.kobj,device_name); - break; - } - } - mutex_unlock(&list_lock); - return ret; -} - - -static int cs6436_56p_sysfs_open(struct inode *inode, struct file *file) -{ - return 0; -} - - - -static ssize_t cs6436_56p_sysfs_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos) -{ - char str[10],name[18],port[8]; - int ret; - int i; - memset(str, 0, sizeof(str)); - ret = copy_from_user(str, buf, count); - if (ret) - { - printk(KERN_ERR "copy_from_user fail\n"); - return -EINVAL; - } - - if(!strncmp(str,"start",5)) - { - psu_class = cs6436_56p_sysfs_create_symclass("psu"); - cs6436_56p_sysfs_create_symlink(psu_class,"cs6436_56p_psu1","psu1"); - cs6436_56p_sysfs_create_symlink(psu_class,"cs6436_56p_psu2","psu2"); - sfp_class = cs6436_56p_sysfs_create_symclass("swps"); - for(i = 1; i <= 48;i++) - { - memset(name,0xff,sizeof(name)); - memset(port,0xff,sizeof(port)); - snprintf(name,sizeof(name),"cs6436_56p_sfp%d",i); - snprintf(port,sizeof(port),"port%d",i); - cs6436_56p_sysfs_create_symlink(sfp_class,name,port); - } - } - else if(!strncmp(str,"stop",4)) - { - cs6436_56p_sysfs_delete_symlink(psu_class,"cs6436_56p_psu1","psu1"); - cs6436_56p_sysfs_delete_symlink(psu_class,"cs6436_56p_psu2","psu2"); - cs6436_56p_sysfs_delete_symclass(psu_class); - - for(i = 1; i <= 48;i++) - { - memset(name,0xff,sizeof(name)); - memset(port,0xff,sizeof(port)); - snprintf(name,sizeof(name),"cs6436_56p_sfp%d",i); - snprintf(port,sizeof(port),"port%d",i); - cs6436_56p_sysfs_delete_symlink(sfp_class,name,port); - } - cs6436_56p_sysfs_delete_symclass(sfp_class); - } - return count; -} - - -static struct file_operations cs6436_56p_sysfs_fops = { - .owner = THIS_MODULE, - .open = cs6436_56p_sysfs_open, - .write = cs6436_56p_sysfs_write, -}; - - -static int __init cs6436_56p_sysfs_init(void) -{ - int result = 0; - int err = 0; - dev_t dev = MKDEV(dev_major, 0); - - if (dev_major) - result = register_chrdev_region(dev, 1, DEVICE_NAME); - else { - result = alloc_chrdev_region(&dev, 0, 1, DEVICE_NAME); - dev_major = MAJOR(dev); - } - if (result < 0) - { - printk("unable to get major %d\n", dev_major); - err= -EINVAL; - } - printk("get major is %d\n", dev_major); - if (dev_major == 0) - dev_major = result; - - dev_cdev= kmalloc(sizeof(struct cdev), GFP_KERNEL); - if(IS_ERR(dev_cdev)) { - err= -ENOMEM; - } - - cdev_init(dev_cdev, &cs6436_56p_sysfs_fops); - dev_cdev->owner = THIS_MODULE; - dev_cdev->ops = &cs6436_56p_sysfs_fops; - err = cdev_add(dev_cdev, dev, 1); - if (err) - { - printk("error %d add fpga ", err); - goto err_malloc; - } - - dev_class = class_create(THIS_MODULE, DEVICE_NAME); - if (IS_ERR(dev_class)) - { - printk("Err:failed in creating class.\n"); - goto err_cdev_add; - } - - dev_device = device_create(dev_class, NULL, MKDEV(dev_major, 0), NULL, DEVICE_NAME); - if (IS_ERR(dev_device)) - { - printk("Err:failed in creating device.\n"); - goto err_class_crt; - } - - mutex_init(&list_lock); - - return err; - - err_class_crt: - cdev_del(dev_cdev); - err_cdev_add: - kfree(dev_cdev); - err_malloc: - unregister_chrdev_region(MKDEV(dev_major,0), 1); - - return err; - -} - -static void __exit cs6436_56p_sysfs_exit(void) -{ - cdev_del(dev_cdev); - printk("cdev_del ok\n"); - device_destroy(dev_class, MKDEV(dev_major, 0)); - - class_destroy(dev_class); - - if(dev_cdev != NULL) - kfree(dev_cdev); - - unregister_chrdev_region(MKDEV(dev_major, 0), 1); - printk("cs6436_56p_sysfs_exit...\r\n"); -} - - -MODULE_AUTHOR("Zhang Peng "); -MODULE_DESCRIPTION("cs6436-56p-sysfs driver"); -MODULE_LICENSE("GPL"); - -module_init(cs6436_56p_sysfs_init); -module_exit(cs6436_56p_sysfs_exit); - - diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/service/cs6436-platform-init.service b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/service/cs6436-platform-init.service deleted file mode 100644 index 3936b54dee2..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/service/cs6436-platform-init.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Cig CS6436-56P Platform initialization service -Before=pmon.service -DefaultDependencies=no - -[Service] -Type=oneshot -ExecStart=/usr/local/bin/cig_cs6436_util.py install -ExecStop=/usr/local/bin/cig_cs6436_util.py clean -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/service/cs6436-platform-misc.service b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/service/cs6436-platform-misc.service deleted file mode 100644 index ed44bc0b343..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/service/cs6436-platform-misc.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Cig CS6436-56P Platform miscellaneous service -After=cs6436-platform-init.service -DefaultDependencies=no - -[Service] -ExecStart=/usr/local/bin/cig_cs6436_misc.py -KillSignal=SIGKILL -SuccessExitStatus=SIGKILL - -# Resource Limitations -LimitCORE=infinity - -[Install] -WantedBy=multi-user.target diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/setup.py b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/setup.py deleted file mode 100755 index c17c10c8319..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/setup.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -import os -import sys -from setuptools import setup -os.listdir - -setup( - name='cs6436-56p', - version='1.0.0', - description='Module to initialize Cig CS6436-56P platforms', - - packages=['cs6436-56p'], - package_dir={'cs6436-56p': 'cs6436-56p/classes'}, - ) diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/utils/cig_cs6436_misc.py b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/utils/cig_cs6436_misc.py deleted file mode 100755 index 56add80221b..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/utils/cig_cs6436_misc.py +++ /dev/null @@ -1,574 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2018 Cambridge, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os -import commands -import sys, getopt -import logging -import re -import time -import datetime -from collections import namedtuple -from threading import Thread - -DEBUG = False -i2c_prefix = '/sys/bus/i2c/devices/' -leds_prefix = '/sys/devices/platform/cs6436_56p_led/leds/' -fans_prefix = '/sys/devices/platform/cs6436_56p_fan/' -fansdir_prefix = fans_prefix + 'fan{}_direction' - -ageing_controlfile = '/etc/sonic/agcontrol' -AGFlag = 0 - - -platform_misc_log = '/var/log/platform_misc.log' -misclogger = logging.getLogger('platform_misc') -misclogger.setLevel(logging.INFO) -miscformatter = logging.Formatter('%(asctime)s-%(levelname)s-%(message)s') - -if not os.path.isfile(platform_misc_log): - try: - os.mknod(platform_misc_log) - except: - print 'Failed to creat platform_misc.log' - -fileHandler = logging.FileHandler(platform_misc_log) -fileHandler.setLevel(logging.INFO) -fileHandler.setFormatter(miscformatter) -misclogger.addHandler(fileHandler) - - -starttime = datetime.datetime.now() -IsGetlswt = 0 -coretemp_prefix = '/sys/class/hwmon/hwmon1/' -coretemp_ps = [] -psu1_p = '/sys/bus/i2c/devices/5-005a/psu_present' -psu2_p = '/sys/bus/i2c/devices/5-005b/psu_present' -psu1_d = '/sys/bus/i2c/devices/5-0052/psu_eeprom' -psu2_d = '/sys/bus/i2c/devices/5-0053/psu_eeprom' -psu1led_d = leds_prefix + 'cs6436_56p_led::psu1/brightness' -psu2led_d = leds_prefix + 'cs6436_56p_led::psu2/brightness' -cs6436_ledpath = {'fan':leds_prefix + 'cs6436_56p_led::fan/brightness', - 'fan1':leds_prefix + 'cs6436_56p_led::fan1/brightness', - 'fan2':leds_prefix + 'cs6436_56p_led::fan2/brightness', - 'fan3':leds_prefix + 'cs6436_56p_led::fan3/brightness', - 'fan4':leds_prefix + 'cs6436_56p_led::fan4/brightness', - 'fan5':leds_prefix + 'cs6436_56p_led::fan5/brightness', - 'psu1':leds_prefix + 'cs6436_56p_led::psu1/brightness', - 'psu2':leds_prefix + 'cs6436_56p_led::psu2/brightness', - 'sys':leds_prefix + 'cs6436_56p_led::sys/brightness'} - - -def system_read_filestr(node): - with open(node, 'r') as f: - try: - str = f.read() - except IOError as e: - misclogger.error('Failed to get node, str={}'.format(node)) - return "0" - return str - - -def system_bright_leds(dev, colour): - global AGFlag - - if AGFlag == 1: - return - - cmd = 'echo {} > {}'.format(colour, dev) - log_os_system(cmd, 1) - return - -''' -1: front in tail out -0: front out tail in -''' -def system_getpsu_direction(dev): - try: - with open(dev) as f: - f.seek(0x30) - str = f.read(2) - except IOError as e: - misclogger.error('Failed to get psu eep') - return 1 - if str == 'AA': ## front in tail out - return 1 - elif str == 'RA':## tail in front out - return 0 - else: - misclogger.error('Failed to get psu eep, str={}'.format(str)) - return -1 - - -def system_get_cputype(): - cmdretfd = os.popen("lscpu | grep 'Model name'") - retstring = cmdretfd.read() - endindex = retstring.find('@') - 1 - startindex = retstring[:endindex].rfind(' ') + 1 - cputype = retstring[startindex:endindex] - - return cputype - - -def system_init_coretemppath(): - global coretemp_ps - - cmdstr = "ls {} | grep 'input'".format(coretemp_prefix) - cmdretfd = os.popen(cmdstr) - - coretemppss = cmdretfd.read().splitlines() - if len(coretemppss) < 3: - cputype = system_get_cputype() - misclogger.error('Failed to init core temperature path.' - ' cpu type = {}, num thermal = {}'.format(cputype, len(coretemp_ps))) - return 1 - - for i in range(0,3): - coretemp_ps.append(coretemp_prefix + coretemppss[i]) - - print coretemp_ps - - return 0 - - -class cs6436_fanattr: - def __init__(self, name): - self.name = name - self.direction = 0 - self.direction_p = '' - self.rear = 0 - self.rear_p = '' - self.front = 0 - self.front_p = '' - self.fault = 0 - self.fault_p = '' - self.status = 0 - self.setpath() - self.updatedevice() - - return - - def setpath(self): - self.direction_p = fans_prefix + '{}_direction'.format(self.name) - self.rear_p = fans_prefix + '{}_rear_speed_rpm'.format(self.name) - self.front_p = fans_prefix + '{}_front_speed_rpm'.format(self.name) - self.fault_p = fans_prefix + '{}_fault'.format(self.name) - - return - - def updatedevice(self): - self.direction = int(system_read_filestr(self.direction_p)) - self.rear = int(system_read_filestr(self.rear_p)) - self.front = int(system_read_filestr(self.front_p)) - self.fault = int(system_read_filestr(self.fault_p)) - - return - - def checkspeedrpm(self, speedrpm): - frontrpmexp = speedrpm * 21000 / 100 - rearrpmexp = speedrpm * 19000 / 100 - deviationfront = abs(frontrpmexp - self.front) / float(frontrpmexp) - deviationrear = abs(rearrpmexp - self.rear) / float(rearrpmexp) - - if deviationfront < 0.3 and deviationrear < 0.3: - return 0 - else: - misclogger.error(':{} speed wrong. frontexp is {}, but rpm is {}.rearexp is {}, but rpm is {}'.format(self.name, frontrpmexp, self.front, rearrpmexp, self.rear)) - return 1 - - def checkstatus(self, speedrpm, totaldirct): - speedstatus = self.checkspeedrpm(speedrpm) - if self.direction != totaldirct: - self.status = 1 - misclogger.error(':{} direction = {}.fan direction is not ok.'.format(self.name, self.direction)) - elif speedstatus != 0: - self.status = 1 - elif self.fault != 0: - misclogger.error(':{} fault.'.format(self.name)) - self.status = 1 - else: - self.status = 0 - - if self.status == 1: - system_bright_leds(cs6436_ledpath[self.name], 3) - else: - system_bright_leds(cs6436_ledpath[self.name], 1) - - return self.status - -cs6436_fanattrnodes = [] - - -class cs6436_psuattr: - def __init__(self, name): - self.name = name - self.direction = 0 - self.direction_p = '' - self.present = 0 - self.present_p = '' - self.status = 0 - - self.setpath() - self.updatepresent() - self.updatedirection() - - return - - def setpath(self): - if self.name == 'psu1': - self.present_p = psu1_p - self.direction_p = psu1_d - if self.name == 'psu2': - self.present_p = psu2_p - self.direction_p = psu2_d - - return - - def updatepresent(self): - self.present = int(system_read_filestr(self.present_p)) - - return - - def updatedirection(self): - if self.present == 1: - self.direction = system_getpsu_direction(self.direction_p) - else: - self.direction = 2 - - return - - def checkstatus(self, totaldirct): - if self.present != 1: - self.status = 1 - misclogger.error(':{} not present.'.format(self.name)) - elif self.direction == 2: - self.status = 0 - misclogger.info(':{} direction need to be update.'.format(self.name)) - elif self.direction != totaldirct: - self.status = 1 - misclogger.info(':{} direction is wrong.'.format(self.name)) - else: - self.status = 0 - - if self.status == 1: - system_bright_leds(cs6436_ledpath[self.name], 3) - else: - system_bright_leds(cs6436_ledpath[self.name], 1) - - return self.status - -cs6436_psuattrnodes = [] - - - -def my_log(txt): - if DEBUG == True: - print "[ROY]"+txt - return - -def device_exist(): - ret1, log = log_os_system("ls "+i2c_prefix+"5-005a", 0) - ret2, log = log_os_system("ls "+i2c_prefix+"5-005b", 0) - ret3, log = log_os_system("ls "+leds_prefix+"cs6436_56p_led*", 0) - return not(ret1 or ret2 or ret3) - - -def log_os_system(cmd, show): - logging.info('Run :'+cmd) - status, output = commands.getstatusoutput(cmd) - my_log (cmd +"with result:" + str(status)) - my_log (" output:"+output) - if status: - logging.info('Failed :'+cmd) - if show: - print('Failed :'+cmd) - return status, output - - -def system_get_coretemp(): - temp1 = system_read_filestr(coretemp_ps[0]).strip() - temp2 = system_read_filestr(coretemp_ps[1]).strip() - temp3 = system_read_filestr(coretemp_ps[2]).strip() - - return int(temp1), int(temp2), int(temp3) - -def system_get_boardtemp(): - for i in range(0,16): - temp1path = "/sys/bus/i2c/devices/5-004a/hwmon/hwmon%d/temp1_input" % i - if os.access(temp1path, os.F_OK): - break - for i in range(0,16): - temp2path = "/sys/bus/i2c/devices/5-004b/hwmon/hwmon%d/temp1_input" % i - if os.access(temp2path, os.F_OK): - break - temp1 = system_read_filestr(temp1path).strip() - temp2 = system_read_filestr(temp2path).strip() - - return int(temp1), int(temp2) - - -def system_get_lswtemp(): - global IsGetlswt - global starttime - if IsGetlswt == 0: - now = datetime.datetime.now() - misclogger.info("time wait.") - misclogger.info("start = {}, now = {}.".format(starttime, now)) - if (now - starttime).seconds > 150: - misclogger.info("time = ".format((now - starttime).seconds)) - IsGetlswt = 1 - - return 25 - -# chp = subprocess.Popen("docker ps --filter name=syncd", shell=True, stdout=subprocess.PIPE) -# if chp.poll() is None: -# misclogger.info("No subp.") -# chp.kill() -# -# return 25 - -# retstring = chp.stdout.read() -# chp.kill() -# if 'Up' not in retstring: -# misclogger.info("lsw not up.") -# -# return 25 - - status, output = log_os_system('npx_diag swc show temperature', 1) - if status: - misclogger.error('failed to show lsw temperature') - - return 25 - - output = output.strip() - if output.find("it 0, temperature ") > 0: - startindex = output.find('temperature') + len('temperature') + 1 - endindex = output[startindex:].find(" ") - endindex = startindex + endindex - temp = output[startindex:endindex] - b = temp.find('.') - if b > 0: - temp=temp[:b] - temp = int(temp) - else: - misclogger.error("Failed to get temperature.") - temp = 0 - - return int(temp) - -def system_monitor_temperature(): - - ctemp1, ctemp2, ctemp3 = system_get_coretemp() - btemp1, btemp2 = system_get_boardtemp() - ltemp = system_get_lswtemp() - fan_speed_str = system_cs6436_getfanexspeed() - fan_speed = int(fan_speed_str) - policy = 'stay' - pos = 0 - #speed c1 c2 c3 b1 b2 lsw - fan_policy_up = ([30, 40000, 40000, 40000, 42000, 35000, 95], - [40, 44000, 44000, 44000, 44000, 39000, 96], - [50, 49000, 49000, 49000, 47000, 44000, 91], - [60, 52000, 52000, 52000, 51500, 47500, 92], - [70, 53000, 53000, 53000, 52000, 49000, 93], - [100,999999,999999,999999,999999,999999,999]) - - fan_policy_down=([30, 0, 0, 0, 0, 0, 0], - [40, 34000, 34000, 34000, 34000, 30000, 80], - [50, 38000, 38000, 38000, 37000, 33000, 81], - [60, 44000, 44000, 44000, 43000, 39000, 84], - [70, 44000, 44000, 44000, 43000, 40000, 84], - [100, 48000, 48000, 48000, 46000, 42000, 85],) - - for policytable in fan_policy_up: - if fan_speed <= policytable[0]: - break - pos = pos + 1 - fan_speed = policytable[0] - if (ctemp1 < policytable[1]) and (ctemp2 < policytable[2]) and (ctemp3 < policytable[3]) and (btemp1 < policytable[4]) and (btemp2 < policytable[5]) and (ltemp < policytable[6]): - policy = 'stay' - policytable = fan_policy_down[pos] - if (ctemp1 < policytable[1]) and (ctemp2 < policytable[2]) and (ctemp3 < policytable[3]) and (btemp1 < policytable[4]) and (btemp2 < policytable[5]) and (ltemp < policytable[6]): - policy = 'down' - else: - policy = 'up' - - if policy == 'up': - misclogger.info("speed = %d." % fan_speed) - misclogger.info("core1 = %d, core2 = %d, core3 = %d." % (ctemp1, ctemp2, ctemp3)) - misclogger.info("board1 = %d, board2 = %d." % (btemp1, btemp2)) - misclogger.info("lsw = %d" % ltemp) - fan_speed = fan_policy_down[pos + 1][0] - misclogger.info("fan policy: up. speedexp = {}".format(fan_speed)) - - if policy == 'stay': - fan_speed = fan_policy_down[pos] - return - - if policy == 'down': - misclogger.info("speed = %d." % fan_speed) - misclogger.info("core1 = %d, core2 = %d, core3 = %d." % (ctemp1, ctemp2, ctemp3)) - misclogger.info("board1 = %d, board2 = %d." % (btemp1, btemp2)) - misclogger.info("lsw = %d" % ltemp) - fan_speed = fan_policy_down[pos - 1][0] - misclogger.info("fan policy: down.speedexp = {}".format(fan_speed)) - - cmd = "echo %d > /sys/devices/platform/cs6436_56p_fan/fan_duty_cycle_percentage" % fan_speed - status, output = log_os_system(cmd, 1) - if status: - misclogger.error("set fan speed fault") - - return - - -def system_cs6436_setfanexspeed(num): - fanspeednode = fans_prefix + 'fan_duty_cycle_percentage' - numstr = str(num) - with open(fanspeednode, 'w') as f: - f.write(numstr) - - -def system_cs6436_getfanexspeed(): - fanspeednode = fans_prefix + 'fan_duty_cycle_percentage' - fanspeedstr = system_read_filestr(fanspeednode) - fanspeedexp = int(fanspeedstr) - - return fanspeedexp - - -def system_cs6436_getdirection(): - global cs6436_fanattrnodes - direction = 0 - - for fan in cs6436_fanattrnodes: - direction = direction + fan.direction - - if direction > 2: - direction = 1 - else: - direction = 0 - - return direction - - -def system_check_psusdirection(): - global cs6436_psuattrnodes - cs6436totaldirct = system_cs6436_getdirection() - psutatus = 0 - - for psu in cs6436_psuattrnodes: - psu.updatedirection() - psu.checkstatus(cs6436totaldirct) - psutatus = psu.status + psutatus - - return (psutatus != 0) - - -def system_check_psuspresent(): - global cs6436_psuattrnodes - cs6436totaldirct = system_cs6436_getdirection() - psutatus = 0 - - for psu in cs6436_psuattrnodes: - psu.updatepresent() - psu.checkstatus(cs6436totaldirct) - psutatus = psu.status + psutatus - - return (psutatus != 0) - - -def system_check_fansstate(): - global cs6436_fanattrnodes - global cs6436_ledpath - cs6436totaldirct = system_cs6436_getdirection() - fanstatus = 0 - fanexspeed = 0 - - fanexspeed = system_cs6436_getfanexspeed() - - for fan in cs6436_fanattrnodes: - fan.updatedevice() - fan.checkstatus(fanexspeed, cs6436totaldirct) - fanstatus = fanstatus + fan.status - - if fanstatus > 0: - misclogger.error(':fan error.set fans speed 100.') - system_cs6436_setfanexspeed(100) - system_bright_leds(cs6436_ledpath['fan'], 3) - else: - system_bright_leds(cs6436_ledpath['fan'], 1) - - return (fanstatus != 0) - - -def system_misc_polling(threadName,delay): - for count in range(1,5): - if device_exist() == False: - time.sleep(delay+3) - print "%s: %s, count=%d" % ( threadName, time.ctime(time.time()), count) - else: - break - - if count == 4: - return - - status, output = log_os_system("echo 1 > /sys/devices/platform/cs6436_56p_led/leds/cs6436_56p_led::sys/brightness", 1) - status, output = log_os_system("hwconfig -cfp 1", 1) - - global AGFlag - if os.access(ageing_controlfile, os.F_OK): - AGFlag = 1 - else: - AGFlag = 0 - - os.system('csw_daemon &') - - - global cs6436_fanattrnodes - global cs6436_psuattrnodes - - for num in range(1,6): - name = 'fan{}'.format(num) - fannode = cs6436_fanattr(name) - cs6436_fanattrnodes.append(fannode) - for num in range(1,3): - name = 'psu{}'.format(num) - psunode = cs6436_psuattr(name) - cs6436_psuattrnodes.append(psunode) - - tempcontrol = system_init_coretemppath() - - misclogger.info("%s: %s misc start." % ( threadName, time.ctime(time.time()))) - count = 0 - while 1: - count = count + 1 - ret = system_check_psuspresent() - ret = system_check_fansstate() - - if count % 10 == 0: - misclogger.info(": adjust fans and check psu direction.") - system_check_psusdirection() - if tempcontrol == 0: - system_monitor_temperature() - count = 0 - time.sleep(delay) - - return - -if __name__ == '__main__': - target=system_misc_polling("Thread-misc",10) - diff --git a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/utils/cig_cs6436_util.py b/platform/nephos/sonic-platform-modules-cig/cs6436-56p/utils/cig_cs6436_util.py deleted file mode 100755 index 86285c7e410..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/cs6436-56p/utils/cig_cs6436_util.py +++ /dev/null @@ -1,556 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2018 Cambridge, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -""" -Usage: %(scriptName)s [options] command object - -options: - -h | --help : this help message - -d | --debug : run with debug mode - -f | --force : ignore error during installation or clean -command: - install : install drivers and generate related sysfs nodes - clean : uninstall drivers and remove related sysfs nodes - show : show all systen status - sff : dump SFP eeprom - set : change board setting with fan|led|sfp -""" - -import os -import commands -import sys, getopt -import logging -import re -import time -from collections import namedtuple - - - - -PROJECT_NAME = 'cs6436_56p' -version = '0.1.1' -verbose = False -DEBUG = False -args = [] -ALL_DEVICE = {} -DEVICE_NO = {'led':9, 'fan':5, 'thermal':4, 'psu':2, 'sfp':56} -FORCE = 0 -CPU_TYPE = 'C3308' - -if DEBUG == True: - print sys.argv[0] - print 'ARGV :', sys.argv[1:] - - -def main(): - global DEBUG - global args - global FORCE - - if len(sys.argv)<2: - show_help() - - options, args = getopt.getopt(sys.argv[1:], 'hdf', ['help', - 'debug', - 'force', - ]) - if DEBUG == True: - print options - print args - print len(sys.argv) - - for opt, arg in options: - if opt in ('-h', '--help'): - show_help() - elif opt in ('-d', '--debug'): - DEBUG = True - logging.basicConfig(level=logging.INFO) - elif opt in ('-f', '--force'): - FORCE = 1 - else: - logging.info('no option') - for arg in args: - if arg == 'install': - do_install() - elif arg == 'clean': - do_uninstall() - elif arg == 'show': - device_traversal() - elif arg == 'sff': - if len(args)!=2: - show_eeprom_help() - elif int(args[1]) ==0 or int(args[1]) > DEVICE_NO['sfp']: - show_eeprom_help() - else: - show_eeprom(args[1]) - return - elif arg == 'set': - if len(args)<3: - show_set_help() - else: - set_device(args[1:]) - return - else: - show_help() - - - return 0 - -def show_help(): - print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]} - sys.exit(0) - -def show_set_help(): - cmd = sys.argv[0].split("/")[-1]+ " " + args[0] - print cmd +" [led|sfp|fan]" - print " use \""+ cmd + " led 0-4 \" to set led color" - print " use \""+ cmd + " fan 0-100\" to set fan duty percetage" - print " use \""+ cmd + " sfp 1-56 {0|1}\" to set sfp# tx_disable" - sys.exit(0) - -def show_eeprom_help(): - cmd = sys.argv[0].split("/")[-1]+ " " + args[0] - print " use \""+ cmd + " 1-56 \" to dump sfp# eeprom" - sys.exit(0) - -def my_log(txt): - if DEBUG == True: - print "[ROY]"+txt - return - -def log_os_system(cmd, show): - logging.info('Run :'+cmd) - status, output = commands.getstatusoutput(cmd) - my_log (cmd +"with result:" + str(status)) - my_log (" output:"+output) - if status: - logging.info('Failed :'+cmd) - if show: - print('Failed :'+cmd) - return status, output - -def driver_check(): - for count in range(1,5): - time.sleep(1) - ret, lsmod = log_os_system("lsmod| grep i2c_i801", 0) - if len(lsmod) > 2: - log_os_system("rmmod i2c_i801", 0) - break - - ret, lsmod = log_os_system("lsmod| grep i2c_designware_platform", 0) - if len(lsmod) > 2: - log_os_system("rmmod i2c_designware_platform", 0) - log_os_system("modprobe i2c-designware-platform", 0) - - ret, lsmod = log_os_system("lsmod| grep cig", 0) - logging.info('mods:'+lsmod) - if len(lsmod) ==0: - return False - return True - - - -kos = [ - 'depmod', - 'modprobe i2c_dev', - 'modprobe i2c_mux_pca954x force_deselect_on_exit=1', - 'modprobe x86-64-cig-cs6436-56p-sysfs ' , - 'modprobe x86-64-cig-cs6436-56p-cpld ' , - 'modprobe x86-64-cig-cs6436-56p-fan' , - 'modprobe x86-64-cig-cs6436-56p-psu' , - 'modprobe x86-64-cig-cs6436-56p-sfp' , - 'modprobe x86-64-cig-cs6436-56p-led' ] - -def driver_install(): - global FORCE - - for i in range(0,len(kos)): - if i == 4: - ret, CPU_TYPE = log_os_system("cat /proc/cpuinfo | grep \"model name\" | cut -b 32-39 | head -n 1", 0) - if CPU_TYPE=='i3-6100U': - kos[i] =kos[i] + 'board_id=1' - ret, CPU_TYPE = log_os_system("cat /proc/cpuinfo | grep \"model name\" | cut -b 36-40 | head -n 1", 0) - if CPU_TYPE=='C3758' or CPU_TYPE=='C3308': - kos[i] =kos[i] + 'board_id=2' - - status, output = log_os_system(kos[i], 1) - if status: - if FORCE == 0: - return status - return 0 - -def driver_uninstall(): - global FORCE - for i in range(0,len(kos)): - rm = kos[-(i+1)].replace("modprobe", "modprobe -rq") - rm = rm.replace("insmod", "rmmod") - status, output = log_os_system(rm, 1) - if status: - if FORCE == 0: - return status - return 0 - -led_prefix ='/sys/class/leds/'+PROJECT_NAME+'_led::' -hwmon_types = {'led': ['sys','fan','fan1','fan2','fan3','fan4','fan5','psu1','psu2']} -hwmon_nodes = {'led': ['brightness'] } -hwmon_prefix ={'led': led_prefix} - -i2c_prefix = '/sys/bus/i2c/devices/' -i2c_bus = {'thermal': ['4-0048','4-0049', '5-004a', '5-004b'] , - 'psu': ['5-005a','5-005b'], - 'sfp': ['-0050']} -i2c_nodes = {'thermal': ['hwmon/hwmon*/temp1_input'] , - 'psu': ['psu_present ', 'psu_power_good'] , - 'sfp': ['sfp_is_present ', 'sfp_tx_disable']} - -fan_prefix ='/sys/bus/platform/devices/'+PROJECT_NAME+'_fan' -fan_types = {'fan': ['fan1','fan2', 'fan3', 'fan4', 'fan5']} -fan_nodes = {'fan': ['state', 'front_speed_rpm', 'rear_speed_rpm', 'fault']} - - -sfp_map = [8,9,10,11,12,13,14,15,16, - 17,18,19,20,21,22,23,24,25,26, - 27,28,29,30,31,32,33,34,35,36, - 37,38,39,40,41,42,43,44,45,46, - 47,48,49,50,51,52,53,54,55,56, - 57,58,59,60,61,62,63] - -mknod =[ - 'echo pca9548 0x71 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo pca9548 0x73 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo pca9548 0x74 > /sys/bus/i2c/devices/i2c-2/new_device', - 'echo pca9548 0x75 > /sys/bus/i2c/devices/i2c-3/new_device', - 'echo pca9548 0x76 > /sys/bus/i2c/devices/i2c-3/new_device', - 'echo pca9548 0x77 > /sys/bus/i2c/devices/i2c-3/new_device', - 'echo lm75 0x48 > /sys/bus/i2c/devices/i2c-4/new_device', - 'echo lm75 0x49 > /sys/bus/i2c/devices/i2c-4/new_device', - 'echo lm75 0x4a > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo lm75 0x4b > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo cs6436_56p_psu1 0x5a > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo cs6436_56p_psu2 0x5b > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo cs6436_56p_psu1 0x52 > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo cs6436_56p_psu2 0x53 > /sys/bus/i2c/devices/i2c-5/new_device', - 'echo 24c128 0x57 > /sys/bus/i2c/devices/i2c-7/new_device'] - - -def device_install(): - global FORCE - - for i in range(0,len(mknod)): - #all nodes need times to built new i2c buses - time.sleep(1) - - status, output = log_os_system(mknod[i], 1) - if status: - print output - if FORCE == 0: - return status - - for i in range(0,len(sfp_map)): - status, output =log_os_system("echo cs6436_56p_sfp"+str(i+1)+" 0x50 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1) - if status: - print output - if FORCE == 0: - return status - - if i <= 47: - status, output =log_os_system("echo cs6436_56p_sfp"+str(i+1)+" 0x51 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1) - if status: - print output - if FORCE == 0: - return status - - return - -def device_uninstall(): - global FORCE - - for i in range(0,len(sfp_map)): - target = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/delete_device" - status, output =log_os_system("echo 0x50 > "+ target, 1) - if status: - print output - if FORCE == 0: - return status - - nodelist = mknod - - for i in range(len(nodelist)): - target = nodelist[-(i+1)] - temp = target.split() - del temp[1] - temp[-1] = temp[-1].replace('new_device', 'delete_device') - status, output = log_os_system(" ".join(temp), 1) - if status: - print output - if FORCE == 0: - return status - - return - -def system_ready(): - if driver_check() == False: - return False - if not device_exist(): - return False - return True - -def do_install(): - print "Checking system...." - if driver_check() == False: - print "No driver, installing...." - status = driver_install() - if status: - if FORCE == 0: - return status - else: - print PROJECT_NAME.upper()+" drivers detected...." - if not device_exist(): - print "No device, installing...." - status = device_install() - if status: - if FORCE == 0: - return status - else: - print PROJECT_NAME.upper()+" devices detected...." - return - -def do_uninstall(): - print "Checking system...." - if not device_exist(): - print PROJECT_NAME.upper() +" has no device installed...." - else: - print "Removing device...." - status = device_uninstall() - if status: - if FORCE == 0: - return status - - if driver_check()== False : - print PROJECT_NAME.upper() +" has no driver installed...." - else: - print "Removing installed driver...." - status = driver_uninstall() - if status: - if FORCE == 0: - return status - - return - -def devices_info(): - global DEVICE_NO - global ALL_DEVICE - global i2c_bus, hwmon_types, fan_types - for key in DEVICE_NO: - ALL_DEVICE[key]= {} - for i in range(0,DEVICE_NO[key]): - ALL_DEVICE[key][key+str(i+1)] = [] - - for key in i2c_bus: - buses = i2c_bus[key] - nodes = i2c_nodes[key] - for i in range(0,len(buses)): - for j in range(0,len(nodes)): - if 'sfp' == key: - for k in range(0,DEVICE_NO[key]): - node = key+str(k+1) - path = i2c_prefix+ str(sfp_map[k])+ buses[i]+"/"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][node].append(path) - else: - node = key+str(i+1) - path = i2c_prefix+ buses[i]+"/"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][node].append(path) - - for key in hwmon_types: - itypes = hwmon_types[key] - nodes = hwmon_nodes[key] - for i in range(0,len(itypes)): - for j in range(0,len(nodes)): - node = key+"_"+itypes[i] - path = hwmon_prefix[key]+ itypes[i]+"/"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][ key+str(i+1)].append(path) - - for key in fan_types: - itypes = fan_types[key] - nodes = fan_nodes[key] - for i in range(0,len(itypes)): - for j in range(0,len(nodes)): - node = key+"_"+itypes[i] - path = fan_prefix+"/"+ itypes[i]+"_"+ nodes[j] - my_log(node+": "+ path) - ALL_DEVICE[key][ key+str(i+1)].append(path) - - #show dict all in the order - if DEBUG == True: - for i in sorted(ALL_DEVICE.keys()): - print(i+": ") - for j in sorted(ALL_DEVICE[i].keys()): - print(" "+j) - for k in (ALL_DEVICE[i][j]): - print(" "+" "+k) - return - -def show_eeprom(index): - if system_ready()==False: - print("System's not ready.") - print("Please install first!") - return - - if len(ALL_DEVICE)==0: - devices_info() - node = ALL_DEVICE['sfp'] ['sfp'+str(index)][0] - node = node.replace(node.split("/")[-1], 'sfp_eeprom') - # check if got hexdump command in current environment - ret, log = log_os_system("which hexdump", 0) - ret, log2 = log_os_system("which busybox hexdump", 0) - if len(log): - hex_cmd = 'hexdump' - elif len(log2): - hex_cmd = ' busybox hexdump' - else: - log = 'Failed : no hexdump cmd!!' - logging.info(log) - print log - return 1 - - print node + ":" - ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1) - if ret==0: - print log - else: - print "**********device no found**********" - return - -def set_device(args): - global DEVICE_NO - global ALL_DEVICE - if system_ready()==False: - print("System's not ready.") - print("Please install first!") - return - - if len(ALL_DEVICE)==0: - devices_info() - - if args[0]=='led': - if int(args[1])>4: - show_set_help() - return - #print ALL_DEVICE['led'] - for i in range(0,len(ALL_DEVICE['led'])): - for k in (ALL_DEVICE['led']['led'+str(i+1)]): - ret, log = log_os_system("echo "+args[1]+" >"+k, 1) - if ret: - return ret - elif args[0]=='fan': - if int(args[1])>100: - show_set_help() - return - #print ALL_DEVICE['fan'] - #fan1~6 is all fine, all fan share same setting - node = ALL_DEVICE['fan'] ['fan1'][0] - node = node.replace(node.split("/")[-1], 'fan_duty_cycle_percentage') - ret, log = log_os_system("cat "+ node, 1) - if ret==0: - print ("Previous fan duty: " + log.strip() +"%") - ret, log = log_os_system("echo "+args[1]+" >"+node, 1) - if ret==0: - print ("Current fan duty: " + args[1] +"%") - return ret - elif args[0]=='sfp': - if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0: - show_set_help() - return - if len(args)<2: - show_set_help() - return - - if int(args[2])>1: - show_set_help() - return - - #print ALL_DEVICE[args[0]] - for i in range(0,len(ALL_DEVICE[args[0]])): - for j in ALL_DEVICE[args[0]][args[0]+str(args[1])]: - if j.find('tx_disable')!= -1: - ret, log = log_os_system("echo "+args[2]+" >"+ j, 1) - if ret: - return ret - - return - -def get_value(input): - digit = re.findall('\d+', input) - return int(digit[0]) - - -def get_ledname(ledx): - name_table={'led1':'SYS','led2':'FSTUS','led3':'FAN1','led4':'FAN2','led5':'FAN3','led6':'FAN4','led7':'FAN5','led8':'PSU1','led9':'PSU2'} - if name_table.has_key(ledx): - name = name_table[ledx] - else: - name = ledx - return name - - -def device_traversal(): - if system_ready()==False: - print("System's not ready.") - print("Please install first!") - return - - if len(ALL_DEVICE)==0: - devices_info() - for i in sorted(ALL_DEVICE.keys()): - print("============================================") - print(i.upper()+": ") - print("============================================") - - for j in sorted(ALL_DEVICE[i].keys(), key=get_value): - nwnamex = get_ledname(j) - if nwnamex == j: - print " "+j+":", - else: - print " "+nwnamex+":", - for k in (ALL_DEVICE[i][j]): - ret, log = log_os_system("cat "+k, 0) - func = k.split("/")[-1].strip() - func = re.sub(j+'_','',func,1) - func = re.sub(i.lower()+'_','',func,1) - if ret==0: - print func+"="+log+" ", - else: - print func+"="+"X"+" ", - print - print("----------------------------------------------------------------") - - - print - return - -def device_exist(): - ret1, log = log_os_system("ls "+i2c_prefix+"*0077", 0) - ret2, log = log_os_system("ls "+i2c_prefix+"i2c-3", 0) - return not(ret1 or ret2) - - -if __name__ == "__main__": - main() diff --git a/platform/nephos/sonic-platform-modules-cig/debian/changelog b/platform/nephos/sonic-platform-modules-cig/debian/changelog deleted file mode 100644 index 7a4aa7996fd..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -sonic-cig-platform-modules (1.0.0) unstable; urgency=low - - * Add support for CS6436-56P series - - -- developer Wed, 12 Sep 2018 10:00:00 +0800 diff --git a/platform/nephos/sonic-platform-modules-cig/debian/compat b/platform/nephos/sonic-platform-modules-cig/debian/compat deleted file mode 100644 index ec635144f60..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/platform/nephos/sonic-platform-modules-cig/debian/control b/platform/nephos/sonic-platform-modules-cig/debian/control deleted file mode 100644 index fc0c6736ffa..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/debian/control +++ /dev/null @@ -1,21 +0,0 @@ -Source: sonic-cig-platform-modules -Section: main -Priority: extra -Maintainer: yanglijie@cigtech.com -Build-Depends: debhelper (>= 8.0.0), bzip2 -Standards-Version: 3.9.3 - -Package: sonic-platform-cig-cs6436-56p -Architecture: amd64 -Depends: linux-image-4.19.0-12-2-amd64-unsigned -Description: kernel modules for platform devices such as fan, led, sfp - -Package: sonic-platform-cig-cs6436-54p -Architecture: amd64 -Depends: linux-image-4.19.0-12-2-amd64-unsigned -Description: kernel modules for platform devices such as fan, led, sfp - -Package: sonic-platform-cig-cs5435-54p -Architecture: amd64 -Depends: linux-image-4.19.0-12-2-amd64-unsigned -Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/nephos/sonic-platform-modules-cig/debian/rules b/platform/nephos/sonic-platform-modules-cig/debian/rules deleted file mode 100755 index b9ca7642b8b..00000000000 --- a/platform/nephos/sonic-platform-modules-cig/debian/rules +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -include /usr/share/dpkg/pkg-info.mk - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -export INSTALL_MOD_DIR:=extra - -PYTHON ?= python2 - -PACKAGE_PRE_NAME := sonic-platform-cig -KVERSION ?= $(shell uname -r) -KERNEL_SRC := /lib/modules/$(KVERSION) -MOD_SRC_DIR:= $(shell pwd) -MODULE_DIRS:= cs6436-56p cs6436-54p cs5435-54p -MODULE_DIR := modules -UTILS_DIR := utils -SERVICE_DIR := service -CLASSES_DIR := classes -CONF_DIR := conf - -%: - dh $@ --with systemd,python2,python3 --buildsystem=pybuild - -clean: - dh_testdir - dh_testroot - dh_clean - -build: - #make modules -C $(KERNEL_SRC)/build M=$(MODULE_SRC) - (for mod in $(MODULE_DIRS); do \ - make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ - $(PYTHON) $${mod}/setup.py build; \ - done) - -binary: binary-arch binary-indep - # Nothing to do - -binary-arch: - # Nothing to do - -#install: build - #dh_testdir - #dh_testroot - #dh_clean -k - #dh_installdirs - -binary-indep: - dh_testdir - dh_installdirs - - # Custom package commands - (for mod in $(MODULE_DIRS); do \ - dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} /$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ - dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod}/usr/local/bin; \ - dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system; \ - dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod}/etc/sonic; \ - cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ - cp $(MOD_SRC_DIR)/$${mod}/$(UTILS_DIR)/*.py debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/local/bin/; \ - cp $(MOD_SRC_DIR)/$${mod}/$(SERVICE_DIR)/*.service debian/$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system/; \ - $(PYTHON) $${mod}/setup.py install --root=$(MOD_SRC_DIR)/debian/$(PACKAGE_PRE_NAME)-$${mod} --install-layout=deb; \ - done) - # Resuming debhelper scripts - dh_testroot - dh_install - dh_installchangelogs - dh_installdocs - dh_systemd_enable - dh_installinit - dh_systemd_start - dh_link - dh_fixperms - dh_compress - dh_strip - dh_installdeb - dh_gencontrol - dh_md5sums - dh_builddeb -.PHONY: build binary binary-arch binary-indep clean diff --git a/platform/nephos/sonic-platform-modules-ingrasys/.gitignore b/platform/nephos/sonic-platform-modules-ingrasys/.gitignore deleted file mode 100644 index c6127b38c1a..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/.gitignore +++ /dev/null @@ -1,52 +0,0 @@ -# Prerequisites -*.d - -# Object files -*.o -*.ko -*.obj -*.elf - -# Linker output -*.ilk -*.map -*.exp - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - -# Debug files -*.dSYM/ -*.su -*.idb -*.pdb - -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf diff --git a/platform/nephos/sonic-platform-modules-ingrasys/LICENSE b/platform/nephos/sonic-platform-modules-ingrasys/LICENSE deleted file mode 100644 index 9cecc1d4669..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {one line to give the program's name and a brief idea of what it does.} - Copyright (C) {year} {name of author} - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - {project} Copyright (C) {year} {fullname} - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/platform/nephos/sonic-platform-modules-ingrasys/debian/changelog b/platform/nephos/sonic-platform-modules-ingrasys/debian/changelog deleted file mode 100644 index a3e3f92cc73..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/debian/changelog +++ /dev/null @@ -1,11 +0,0 @@ -platform-driver (1.0.0) unstable; urgency=low - - * Add support for S9130-32X, S9230-64X series - - -- developer Wed, 29 Mar 2017 11:00:00 +0800 - -platform-driver (1.0.0) unstable; urgency=low - - * Initial release (Closes: #nnnn) - - -- developer Wed, 05 Oct 2016 16:30:45 +0800 diff --git a/platform/nephos/sonic-platform-modules-ingrasys/debian/compat b/platform/nephos/sonic-platform-modules-ingrasys/debian/compat deleted file mode 100644 index ec635144f60..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/platform/nephos/sonic-platform-modules-ingrasys/debian/control b/platform/nephos/sonic-platform-modules-ingrasys/debian/control deleted file mode 100755 index 3db0b5f3505..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/debian/control +++ /dev/null @@ -1,15 +0,0 @@ -Source: platform-driver -Section: unknown -Priority: optional -Maintainer: Wade He -Build-Depends: debhelper (>= 9), dh-systemd -Standards-Version: 1.0.0 - -Package: sonic-platform-ingrasys-s9130-32x -Architecture: amd64 -Description: This package contains S9130-32X platform driver utility for SONiC project. - -Package: sonic-platform-ingrasys-s9230-64x -Architecture: amd64 -Description: This package contains S9230-64X platform driver utility for SONiC project. - diff --git a/platform/nephos/sonic-platform-modules-ingrasys/debian/rules b/platform/nephos/sonic-platform-modules-ingrasys/debian/rules deleted file mode 100755 index f03e1de42c1..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/debian/rules +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/make -f - -export INSTALL_MOD_DIR:=extra - -PACKAGE_PRE_NAME := sonic-platform-ingrasys -KVERSION ?= $(shell uname -r) -KERNEL_SRC := /lib/modules/$(KVERSION) -MOD_SRC_DIR:= $(shell pwd) -MODULE_DIRS:= s9130-32x s9230-64x -MODULE_DIR := modules -UTILS_DIR := utils -SERVICE_DIR := service -CONF_DIR := conf - -%: - dh $@ --with systemd - -override_dh_auto_build: - (for mod in $(MODULE_DIRS); do \ - make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ - done) - -override_dh_auto_install: - (for mod in $(MODULE_DIRS); do \ - dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} \ - $(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ - cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko \ - debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ - dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} usr/sbin; \ - cp $(MOD_SRC_DIR)/$${mod}/$(UTILS_DIR)/*.sh \ - debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/sbin; \ - dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} lib/systemd/system; \ - cp $(MOD_SRC_DIR)/$${mod}/$(SERVICE_DIR)/*.service \ - debian/$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system; \ - done) - -override_dh_clean: - dh_clean - (for mod in $(MODULE_DIRS); do \ - make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \ - done) - diff --git a/platform/nephos/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9130-32x.init b/platform/nephos/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9130-32x.init deleted file mode 100644 index a925faf45fa..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9130-32x.init +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -### BEGIN INIT INFO -# Provides: setup-board -# Required-Start: -# Required-Stop: -# Should-Start: -# Should-Stop: -# Default-Start: S -# Default-Stop: 0 6 -# Short-Description: Setup S9130-32X board. -### END INIT INFO - -case "$1" in -start) - echo -n "Setting up board... " - - depmod -a - - echo "done." - ;; - -stop) - - i2c_utils.sh i2c_deinit - - echo "done." - - ;; - -force-reload|restart) - echo "Not supported" - ;; - -*) - echo "Usage: /etc/init.d/sonic-platform-ingrasys-s9130-32x.init {start|stop}" - exit 1 - ;; -esac - -exit 0 diff --git a/platform/nephos/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9230-64x.init b/platform/nephos/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9230-64x.init deleted file mode 100644 index 4389aee5f77..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9230-64x.init +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -### BEGIN INIT INFO -# Provides: setup-board -# Required-Start: -# Required-Stop: -# Should-Start: -# Should-Stop: -# Default-Start: S -# Default-Stop: 0 6 -# Short-Description: Setup S9230-64X board. -### END INIT INFO - -case "$1" in -start) - echo -n "Setting up board... " - - depmod -a - - echo "done." - ;; - -stop) - - i2c_utils i2c_deinit - - echo "done." - - ;; - -force-reload|restart) - echo "Not supported" - ;; - -*) - echo "Usage: /etc/init.d/sonic-platform-ingrasys-s9230-64x.init {start|stop}" - exit 1 - ;; -esac - -exit 0 diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/README.md b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/README.md deleted file mode 100644 index 1b3b14db343..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/README.md +++ /dev/null @@ -1,167 +0,0 @@ -# Ingrasys S9130-32X Platform Driver for SONiC - -Copyright (C) 2016 Ingrasys, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - - -## Licensing terms - -The Licensing terms of the files within this project is split 2 parts. -The Linux kernel is released under the GNU General Public License version 2. -All other code is released under the GNU General Public License version 3. -Please see the LICENSE file for copies of both licenses. - -## Contents of this package - - - service/ - > Service config files for platform initialization and monitoring - - utils/ - > Scripts useful during platform bringup and sysfs function - - conf/ - > Platform configure files. - -## Kernel modules and drivers - -The driver for interacting with Ingrasys S9130-32X is contained in the I2C -kernel module and initialization script. The initialization script loads -the modules in the correct order. It has been built and tested against -the Linux 3.16 kernel. - -The initialization script will modprobe the needed modules, navigate to the -module's device directory in sysfs, and write configuration data to -the kernel module. - -### IGB - -This is OOB Ports on front panel for management plane. - -The IGB module must be loaded first on Ingrasys S9130-32X platform. - -### I2C i801 - -The I2C i801 on Ingrasys S9130-32X can be found in -`/sys/bus/i2c/devices/i2c-0/` - -This is I2C bus for power monitor, FAN controller, HWM and thermal sensors. - -### I2C PCA9548 -The PCA9548 module on S9130-32X can be found in -`/sys/bus/i2c/devices/i2c-1/` , `/sys/bus/i2c/devices/i2c-2/`, -`/sys/bus/i2c/devices/i2c-3/`, `/sys/bus/i2c/devices/i2c-4/`, -`/sys/bus/i2c/devices/i2c-5/`, `/sys/bus/i2c/devices/i2c-6/`, -`/sys/bus/i2c/devices/i2c-7/`, `/sys/bus/i2c/devices/i2c-8/` - -The pca9548 module for zQSFP module get/set functions, PSU information, -fan status and EEPROM. - -## Hardware components - -The hardware components are initialized in the init script on S9130-32X. -The following describes manual initialization as well as interaction. -The examples below are just for Ingrasys S9130-32X platform. - -### Hardware initialization - -When the sonic-platform-ingrasys-s9130-32x package is installed on the S9130-32X, -it is automatically initialized. If you want to manual initialization, the -utility command usage as follows: -``` - i2c_utils.sh i2c_init -``` - -### EEPROM - -The EEPROM is including the board SKU, model name, vendor name, serial number, -and other information can be accessed with the specific eeprom kernel module. -After using `modprobe eeprom_mb` to detect the eeprom, it will show up in sysfs. - -The hexdump utility can be used to decode the raw output of the EEPROM. -For example, -``` - bash# echo "mb_eeprom 0x51" > /sys/bus/i2c/devices/i2c-0/new_device - bash# cat /sys/bus/i2c/drivers/mb_eeprom/0-0051/eeprom | hexdump -C -``` - -### Front panel LEDs - -LEDs can be setup on/off by using i2c utility `/usr/sbin/i2c_utils.sh`. -Utility function command usage as follows: - -``` -Status LED: - i2c_utils.sh i2c_sys_led green|amber - -Fan status LED: - i2c_utils.sh i2c_fan_led green|amber on|off - -PSU1 status LED: - i2c_utils.sh i2c_psu1_led green|amber on|off - -PSU2 status LED: - i2c_utils.sh i2c_psu2_led green|amber on|off - -``` -QSFP Module Port LEDs control by ASIC library. - - -### Fan speed - -Fan speed are controlled by the w83795 kernel module. -It can be found in `/sys/class/hwmon/hwmon5/device/`. -If they were compiled as modules, you will need to modprobe w83795 for -their sysfs entries to show up. Each fan has an `fan_input` file -for reading the fan speed. And `pwm1` setting fan1 to fan4, -`pwm2` setting fan5 to fan8. - -There is docker-platform-monitor container installed fancontrol package that can -automatic control platform fan speed. - - -### Temperature sensors - -There is docker-platform-monitor container installed lm-sensors package that can -monitor platform temperature. And `sensors` command can show each -temperature sensors status. - -### Power supplies - -Power supplies status and its EEPROM info can be used i2c utility -`/usr/sbin/i2c_utils.sh` to get. -The usage as follows: -``` -PSU EEPROM: - i2c_utils.sh i2c_psu_eeprom_get - hexdump -C psu0.rom - hexdump -C psu1.rom - -PSU Status: - i2c_utils.sh i2c_psu_status -``` - -### QSFPs -QSFP modules are managed by the pca9548 kernel driver. -The i2c utility `/usr/sbin/i2c_utils.sh` can be used to get status and -module EEPROM informations. -The usage as follows: -``` -QSFP EEPROM: - i2c_utils.sh i2c_qsfp_eeprom_get [1-32] - -QSFP Insert Event: - i2c_utils.sh i2c_qsfp_eeprom_get [1-32] - 0 => not insert - 1 => inserted -``` - diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/Makefile b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/Makefile deleted file mode 100755 index 688bb466644..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -obj-m := eeprom_mb.o -obj-m += ingrasys_s9130_32x_psu.o diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/eeprom_mb.c b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/eeprom_mb.c deleted file mode 100755 index 528864d9338..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/eeprom_mb.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (C) 1998, 1999 Frodo Looijaard and - * Philip Edelbrock - * Copyright (C) 2003 Greg Kroah-Hartman - * Copyright (C) 2003 IBM Corp. - * Copyright (C) 2004 Jean Delvare - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -/* enable dev_dbg print out */ -//#define DEBUG - -#include -#include -#include -#include -#include -#include -#include - -/* Addresses to scan */ -static const unsigned short normal_i2c[] = { /*0x50, 0x51, 0x52, 0x53, 0x54, - 0x55, 0x56, 0x57,*/ I2C_CLIENT_END }; - -/* Size of EEPROM in bytes */ -#define EEPROM_SIZE 512 - -#define SLICE_BITS (6) -#define SLICE_SIZE (1 << SLICE_BITS) -#define SLICE_NUM (EEPROM_SIZE/SLICE_SIZE) - -/* Each client has this additional data */ -struct eeprom_data { - struct mutex update_lock; - u8 valid; /* bitfield, bit!=0 if slice is valid */ - unsigned long last_updated[SLICE_NUM]; /* In jiffies, 8 slices */ - u8 data[EEPROM_SIZE]; /* Register values */ -}; - - -static void mb_eeprom_update_client(struct i2c_client *client, u8 slice) -{ - struct eeprom_data *data = i2c_get_clientdata(client); - int i, j; - int ret; - int addr; - - mutex_lock(&data->update_lock); - - if (!(data->valid & (1 << slice)) || - time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { - dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); - - addr = slice << SLICE_BITS; - - ret = i2c_smbus_write_byte_data(client, (u8)((addr >> 8) & 0xFF), (u8)(addr & 0xFF)); - /* select the eeprom address */ - if (ret < 0) { - dev_err(&client->dev, "address set failed\n"); - goto exit; - } - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) { - goto exit; - } - - for (i = slice << SLICE_BITS; i < (slice + 1) << SLICE_BITS; i+= SLICE_SIZE) { - for (j = i; j < (i+SLICE_SIZE); j++) { - int res; - - res = i2c_smbus_read_byte(client); - if (res < 0) { - goto exit; - } - - data->data[j] = res & 0xFF; - } - } - - data->last_updated[slice] = jiffies; - data->valid |= (1 << slice); - } -exit: - mutex_unlock(&data->update_lock); -} - -static ssize_t mb_eeprom_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) -{ - struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); - struct eeprom_data *data = i2c_get_clientdata(client); - u8 slice; - - if (off > EEPROM_SIZE) { - return 0; - } - if (off + count > EEPROM_SIZE) { - count = EEPROM_SIZE - off; - } - if (count == 0) { - return 0; - } - - /* Only refresh slices which contain requested bytes */ - for (slice = off >> SLICE_BITS; slice <= (off + count - 1) >> SLICE_BITS; slice++) { - mb_eeprom_update_client(client, slice); - } - - memcpy(buf, &data->data[off], count); - - return count; -} - -static ssize_t mb_eeprom_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) -{ - struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); - struct eeprom_data *data = i2c_get_clientdata(client); - int ret; - int i; - u8 cmd; - u16 value16; - - dev_dbg(&client->dev, "mb_eeprom_write off=%d, count=%d\n", (int)off, (int)count); - - if (off > EEPROM_SIZE) { - return 0; - } - if (off + count > EEPROM_SIZE) { - count = EEPROM_SIZE - off; - } - if (count == 0) { - return 0; - } - - mutex_lock(&data->update_lock); - - for(i=0; i < count; i++) { - /* write command */ - cmd = (off >> 8) & 0xff; - value16 = off & 0xff; - value16 |= buf[i] << 8; - ret = i2c_smbus_write_word_data(client, cmd, value16); - - if (ret < 0) { - dev_err(&client->dev, "write address failed at %d \n", (int)off); - goto exit; - } - - off++; - - /* need to wait for write complete */ - udelay(10000); - } -exit: - mutex_unlock(&data->update_lock); - /* force to update client when reading */ - for(i=0; i < SLICE_NUM; i++) { - data->last_updated[i] = 0; - } - - return count; -} - -static struct bin_attribute mb_eeprom_attr = { - .attr = { - .name = "eeprom", - .mode = S_IRUGO | S_IWUSR, - }, - .size = EEPROM_SIZE, - .read = mb_eeprom_read, - .write = mb_eeprom_write, -}; - -/* Return 0 if detection is successful, -ENODEV otherwise */ -static int mb_eeprom_detect(struct i2c_client *client, struct i2c_board_info *info) -{ - struct i2c_adapter *adapter = client->adapter; - - /* EDID EEPROMs are often 24C00 EEPROMs, which answer to all - addresses 0x50-0x57, but we only care about 0x51 and 0x55. So decline - attaching to addresses >= 0x56 on DDC buses */ - if (!(adapter->class & I2C_CLASS_SPD) && client->addr >= 0x56) { - return -ENODEV; - } - - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE) - && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - return -ENODEV; - } - - strlcpy(info->type, "eeprom", I2C_NAME_SIZE); - - return 0; -} - -static int mb_eeprom_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct eeprom_data *data; - int err; - - if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } - - memset(data->data, 0xff, EEPROM_SIZE); - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - - /* create the sysfs eeprom file */ - err = sysfs_create_bin_file(&client->dev.kobj, &mb_eeprom_attr); - if (err) { - goto exit_kfree; - } - - return 0; - -exit_kfree: - kfree(data); -exit: - return err; -} - -static int mb_eeprom_remove(struct i2c_client *client) -{ - sysfs_remove_bin_file(&client->dev.kobj, &mb_eeprom_attr); - kfree(i2c_get_clientdata(client)); - - return 0; -} - -static const struct i2c_device_id mb_eeprom_id[] = { - { "mb_eeprom", 0 }, - { } -}; - -static struct i2c_driver mb_eeprom_driver = { - .driver = { - .name = "mb_eeprom", - }, - .probe = mb_eeprom_probe, - .remove = mb_eeprom_remove, - .id_table = mb_eeprom_id, - - .class = I2C_CLASS_DDC | I2C_CLASS_SPD, - .detect = mb_eeprom_detect, - .address_list = normal_i2c, -}; - -module_i2c_driver(mb_eeprom_driver); - -MODULE_AUTHOR("Wade "); -MODULE_DESCRIPTION("Ingrasys Mother Borad EEPROM driver"); -MODULE_LICENSE("GPL"); diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/ingrasys_s9130_32x_platform.h b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/ingrasys_s9130_32x_platform.h deleted file mode 100644 index 23dcf17a855..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/ingrasys_s9130_32x_platform.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef _S9130_32X_PLATFORM_H -#define _S9130_32X_PLATFORM_H - -#include - -// remove debug before release -#define DEBUG - -enum bus_order { - I2C_BUS_MAIN, - MUX_9548_0_CH0, - MUX_9548_0_CH1, - MUX_9548_0_CH2, - MUX_9548_0_CH3, - MUX_9548_0_CH4, - MUX_9548_0_CH5, - MUX_9548_0_CH6, - MUX_9548_0_CH7, - MUX_9548_1_CH0, - MUX_9548_1_CH1, - MUX_9548_1_CH2, - MUX_9548_1_CH3, - MUX_9548_1_CH4, - MUX_9548_1_CH5, - MUX_9548_1_CH6, - MUX_9548_1_CH7, - MUX_9546_0_CH0, - MUX_9546_0_CH1, - MUX_9546_0_CH2, - MUX_9546_0_CH3, - MUX_9546_1_CH0, - MUX_9546_1_CH1, - MUX_9546_1_CH2, - MUX_9546_1_CH3, - MUX_9548_2_CH0, - MUX_9548_2_CH1, - MUX_9548_2_CH2, - MUX_9548_2_CH3, - MUX_9548_2_CH4, - MUX_9548_2_CH5, - MUX_9548_2_CH6, - MUX_9548_2_CH7, - MUX_9548_3_CH0, - MUX_9548_3_CH1, - MUX_9548_3_CH2, - MUX_9548_3_CH3, - MUX_9548_3_CH4, - MUX_9548_3_CH5, - MUX_9548_3_CH6, - MUX_9548_3_CH7, - MUX_9548_4_CH0, - MUX_9548_4_CH1, - MUX_9548_4_CH2, - MUX_9548_4_CH3, - MUX_9548_4_CH4, - MUX_9548_4_CH5, - MUX_9548_4_CH6, - MUX_9548_4_CH7, - MUX_9548_5_CH0, - MUX_9548_5_CH1, - MUX_9548_5_CH2, - MUX_9548_5_CH3, - MUX_9548_5_CH4, - MUX_9548_5_CH5, - MUX_9548_5_CH6, - MUX_9548_5_CH7, - MUX_9548_6_CH0, - MUX_9548_6_CH1, - MUX_9548_6_CH2, - MUX_9548_6_CH3, - MUX_9548_6_CH4, - MUX_9548_6_CH5, - MUX_9548_6_CH6, - MUX_9548_6_CH7, - MUX_9548_7_CH0, - MUX_9548_7_CH1, - MUX_9548_7_CH2, - MUX_9548_7_CH3, - MUX_9548_7_CH4, - MUX_9548_7_CH5, - MUX_9548_7_CH6, - MUX_9548_7_CH7, - MUX_9548_8_CH0, - MUX_9548_8_CH1, - MUX_9548_8_CH2, - MUX_9548_8_CH3, - MUX_9548_8_CH4, - MUX_9548_8_CH5, - MUX_9548_8_CH6, - MUX_9548_8_CH7, - MUX_9548_9_CH0, - MUX_9548_9_CH1, - MUX_9548_9_CH2, - MUX_9548_9_CH3, - MUX_9548_9_CH4, - MUX_9548_9_CH5, - MUX_9548_9_CH6, - MUX_9548_9_CH7, - MUX_9548_10_CH0, - MUX_9548_10_CH1, - MUX_9548_10_CH2, - MUX_9548_10_CH3, - MUX_9548_10_CH4, - MUX_9548_10_CH5, - MUX_9548_10_CH6, - MUX_9548_10_CH7, -}; - -#define I2C_ADDR_MUX_9555_0 (0x20) -#define I2C_ADDR_MUX_9555_1 (0x24) -#define I2C_ADDR_MUX_9555_2 (0x25) -#define I2C_ADDR_MUX_9555_3 (0x26) -#define I2C_ADDR_MUX_9539_0 (0x76) -#define I2C_ADDR_MUX_9539_1 (0x76) -#define I2C_BUS_FAN_STATUS (I2C_BUS_MAIN) -#define I2C_BUS_SYS_LED (MUX_9548_1_CH1) - -#define NUM_OF_I2C_MUX (11) -#define NUM_OF_CPLD (5) -#define NUM_OF_QSFP_PORT (64) -#define NUM_OF_SFP_PORT (2) -#define QSFP_EEPROM_I2C_ADDR (0x50) - -enum gpio_reg { - REG_PORT0_IN, - REG_PORT1_IN, - REG_PORT0_OUT, - REG_PORT1_OUT, - REG_PORT0_POL, - REG_PORT1_POL, - REG_PORT0_DIR, - REG_PORT1_DIR, -}; - -struct ing_i2c_board_info { - int ch; - int size; - struct i2c_board_info *board_info; -}; - -struct i2c_init_data { - __u16 ch; - __u16 addr; - __u8 reg; - __u8 value; -}; - -#endif diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/ingrasys_s9130_32x_psu.c b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/ingrasys_s9130_32x_psu.c deleted file mode 100644 index edf92b67241..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/ingrasys_s9130_32x_psu.c +++ /dev/null @@ -1,388 +0,0 @@ -/* - * S9130-32x PSU driver - * - * Copyright (C) 2017 Ingrasys, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ingrasys_s9130_32x_platform.h" - -static ssize_t show_psu_eeprom(struct device *dev, - struct device_attribute *da, - char *buf); -static struct s9130_psu_data *s9130_psu_update_status(struct device *dev); -static struct s9130_psu_data *s9130_psu_update_eeprom(struct device *dev); -static int s9130_psu_read_block(struct i2c_client *client, - u8 command, - u8 *data, - int data_len); - - -#define DRIVER_NAME "psu" - -// Addresses scanned -static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; - -/* PSU EEPROM SIZE */ -#define EEPROM_SZ 256 -#define READ_EEPROM 1 -#define NREAD_EEPROM 0 - -static struct i2c_client pca9555_client; - -/* pca9555 gpio pin mapping */ -#define PSU2_PWROK 0 -#define PSU2_PRSNT_L 1 -#define PSU2_PWRON_L 2 -#define PSU1_PWROK 3 -#define PSU1_PRSNT_L 4 -#define PSU1_PWRON_L 5 -#define TMP_75_INT_L 6 - -/* Driver Private Data */ -struct s9130_psu_data { - struct mutex lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 index; /* PSU index */ - s32 status; /* IO expander value */ - char eeprom[EEPROM_SZ]; /* psu eeprom data */ - char psuABS; /* PSU absent */ - char psuPG; /* PSU power good */ -}; - -enum psu_index -{ - s9130_psu1, - s9130_psu2 -}; - -/* - * display power good attribute - */ -static ssize_t -show_psu_pg(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct s9130_psu_data *data = s9130_psu_update_status(dev); - unsigned int value; - - mutex_lock(&data->lock); - value = data->psuPG; - mutex_unlock(&data->lock); - - return sprintf(buf, "%d\n", value); -} - -/* - * display power absent attribute - */ -static ssize_t -show_psu_abs(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct s9130_psu_data *data = s9130_psu_update_status(dev); - unsigned int value; - - mutex_lock(&data->lock); - value = data->psuABS; - mutex_unlock(&data->lock); - - return sprintf(buf, "%d\n", value); -} - - -/* - * sysfs attributes for psu - */ -static DEVICE_ATTR(psu_pg, S_IRUGO, show_psu_pg, NULL); -static DEVICE_ATTR(psu_abs, S_IRUGO, show_psu_abs, NULL); -static DEVICE_ATTR(psu_eeprom, S_IRUGO, show_psu_eeprom, NULL); - -static struct attribute *s9130_psu_attributes[] = { - &dev_attr_psu_pg.attr, - &dev_attr_psu_abs.attr, - &dev_attr_psu_eeprom.attr, - NULL -}; - -/* - * display psu eeprom content - */ -static ssize_t -show_psu_eeprom(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct s9130_psu_data *data = s9130_psu_update_eeprom(dev); - - memcpy(buf, (char *)data->eeprom, EEPROM_SZ); - return EEPROM_SZ; -} - -static const struct attribute_group s9130_psu_group = { - .attrs = s9130_psu_attributes, -}; - -/* - * check gpio expander is accessible - */ -static int -pca9555_detect(struct i2c_client *client) -{ - if (i2c_smbus_read_byte_data(client, REG_PORT0_DIR) < 0) { - return -ENODEV; - } - - return 0; -} - -/* - * client address init - */ -static void -i2c_devices_client_address_init(struct i2c_client *client) -{ - pca9555_client = *client; - pca9555_client.addr = 0x25; -} - -static int -s9130_psu_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct s9130_psu_data *data; - int status, err; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct s9130_psu_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - memset(data, 0, sizeof(struct s9130_psu_data)); - i2c_set_clientdata(client, data); - data->valid = 0; - data->index = dev_id->driver_data; - mutex_init(&data->lock); - - i2c_devices_client_address_init(client); - - err = pca9555_detect(&pca9555_client); - if (err) { - return err; - } - - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &s9130_psu_group); - if (status) { - goto exit_free; - } - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &s9130_psu_group); -exit_free: - kfree(data); -exit: - - return status; -} - -static int -s9130_psu_remove(struct i2c_client *client) -{ - struct s9130_psu_data *data = i2c_get_clientdata(client); - - sysfs_remove_group(&client->dev.kobj, &s9130_psu_group); - kfree(data); - - return 0; -} - - -/* - * psu eeprom read utility - */ -static int -s9130_psu_read_block(struct i2c_client *client, - u8 command, - u8 *data, - int data_len) -{ - int i=0, ret=0; - int blk_max = 32; //max block read size - - /* read eeprom, 32 * 8 = 256 bytes */ - for (i=0; i < EEPROM_SZ/blk_max; i++) { - ret = i2c_smbus_read_i2c_block_data(client, (i*blk_max), blk_max, - data + (i*blk_max)); - if (ret < 0) { - return ret; - } - } - return ret; -} - -/* - * update eeprom content - */ -static struct s9130_psu_data -*s9130_psu_update_eeprom(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct s9130_psu_data *data = i2c_get_clientdata(client); - s32 status = 0; - int psu_pwrok = 0; - int psu_prsnt_l = 0; - - mutex_lock(&data->lock); - - if (time_after(jiffies, data->last_updated + 300 * HZ) - || !data->valid) { - - /* Read psu status */ - - status = i2c_smbus_read_word_data(&(pca9555_client), REG_PORT0_IN); - data->status = status; - - /*read psu status from io expander*/ - - if (data->index == s9130_psu1) { - psu_pwrok = PSU1_PWROK; - psu_prsnt_l = PSU1_PRSNT_L; - } else { - psu_pwrok = PSU2_PWROK; - psu_prsnt_l = PSU2_PRSNT_L; - } - data->psuPG = (status >> psu_pwrok) & 0x1; - data->psuABS = (status >> psu_prsnt_l) & 0x1; - - /* Read eeprom */ - if (!data->psuABS) { - //clear local eeprom data - memset(data->eeprom, 0, EEPROM_SZ); - - //read eeprom - status = s9130_psu_read_block(client, 0, data->eeprom, - ARRAY_SIZE(data->eeprom)); - - if (status < 0) { - memset(data->eeprom, 0, EEPROM_SZ); - dev_err(&client->dev, "Read eeprom failed, status=(%d)\n", status); - } else { - data->valid = 1; - } - } else { - memset(data->eeprom, 0, EEPROM_SZ); - } - data->last_updated = jiffies; - } - - mutex_unlock(&data->lock); - - return data; -} - -/* - * update psu status - */ -static struct s9130_psu_data -*s9130_psu_update_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct s9130_psu_data *data = i2c_get_clientdata(client); - s32 status = 0; - int psu_pwrok = 0; - int psu_prsnt_l = 0; - - mutex_lock(&data->lock); - - /* Read psu status */ - - status = i2c_smbus_read_word_data(&(pca9555_client), REG_PORT0_IN); - data->status = status; - - /*read psu status from io expander*/ - - if (data->index == s9130_psu1) { - psu_pwrok = PSU1_PWROK; - psu_prsnt_l = PSU1_PRSNT_L; - } else { - psu_pwrok = PSU2_PWROK; - psu_prsnt_l = PSU2_PRSNT_L; - } - data->psuPG = (status >> psu_pwrok) & 0x1; - data->psuABS = (status >> psu_prsnt_l) & 0x1; - - mutex_unlock(&data->lock); - - return data; -} - -static const struct i2c_device_id s9130_psu_id[] = { - { "psu1", s9130_psu1 }, - { "psu2", s9130_psu2 }, - {} -}; - -MODULE_DEVICE_TABLE(i2c, s9130_psu_id); - -static struct i2c_driver s9130_psu_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = s9130_psu_probe, - .remove = s9130_psu_remove, - .id_table = s9130_psu_id, - .address_list = normal_i2c, -}; - -static int __init s9130_psu_init(void) -{ - return i2c_add_driver(&s9130_psu_driver); -} - -static void __exit s9130_psu_exit(void) -{ - i2c_del_driver(&s9130_psu_driver); -} - -module_init(s9130_psu_init); -module_exit(s9130_psu_exit); - -MODULE_AUTHOR("Jason Tsai "); -MODULE_DESCRIPTION("S9130-32X psu driver"); -MODULE_LICENSE("GPL"); diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/service/qsfp-monitor.service b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/service/qsfp-monitor.service deleted file mode 100644 index 10b48f648b9..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/service/qsfp-monitor.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description= This QSFP Monitor service is to setup QSFP SI. -Requires=s9130-32x-monitor.service -After=s9130-32x-monitor.service - -[Service] -ExecStart=/usr/sbin/qsfp_monitor.sh -KillSignal=SIGKILL -SuccessExitStatus=SIGKILL - -# Resource Limitations -LimitCORE=infinity - -[Install] -WantedBy=multi-user.target diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/service/s9130-32x-monitor.service b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/service/s9130-32x-monitor.service deleted file mode 100644 index 3163b0af6f1..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/service/s9130-32x-monitor.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description= This Platform Monitor service is to initialize platform and monitor platform. -Before=platform-monitor.service -After=sysinit.target -Wants=fancontrol.service -Wants=qsfp-monitor.service -DefaultDependencies=no - -[Service] -ExecStartPre=/usr/sbin/i2c_utils.sh i2c_init -ExecStart=/usr/sbin/s9130_32x_monitor.sh -KillSignal=SIGKILL -SuccessExitStatus=SIGKILL - -# Resource Limitations -LimitCORE=infinity - -[Install] -WantedBy=multi-user.target diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/i2c_utils.sh b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/i2c_utils.sh deleted file mode 100755 index ea238e01729..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/i2c_utils.sh +++ /dev/null @@ -1,1720 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2016 Ingrasys, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# trun on for more debug output -#DEBUG="on" - -VERSION="1.1.0" -TRUE=200 -FALSE=404 - -EXEC_FUNC=${1} -COLOR_LED=${2} -QSFP_PORT=${2} -QSFP_ACTION=${2} -MB_EEPROM_ACTION=${2} -ONOFF_LED=${3} -FAN_TRAY=${4} - -############################################################ -# Distributor ID: Debian -# Description: Debian GNU/Linux 8.6 (jessie) -# Release: 8.6 -# Codename: jessie -# Linux debian 3.16.0-4-amd64 #1 -# SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux -############################################################ - -# Color Definition -COLOR_TITLE="\e[1;32m" ### Green ### -COLOR_WARNING="\e[1;33m" ### Yellow ### -COLOR_ERROR="\e[1;31m" ### Red ### -COLOR_END="\e[0m" ### END ### - -NUM_I801_DEVICE=0 - -# MAIN MUX PCA9548#0 0x73 -NUM_MUX_9548_0_CH0=$(( ${NUM_I801_DEVICE} + 1 )) # ucd9090 0x34 -NUM_MUX_9548_0_CH1=$(( ${NUM_I801_DEVICE} + 2 )) # PCA9539 0x76 for fp LED & HW ID -NUM_MUX_9548_0_CH7=$(( ${NUM_I801_DEVICE} + 8 )) # W83795 0x2F - -# FRU MUX PCA9545#1 0x72 -NUM_MUX_9545_1_CH0=$(( ${NUM_I801_DEVICE} + 9 )) # PSU2 0x50 -NUM_MUX_9545_1_CH1=$(( ${NUM_I801_DEVICE} + 10 )) # PSU1 0x50 -NUM_MUX_9545_1_CH2=$(( ${NUM_I801_DEVICE} + 11 )) # FAN board IO exander 0x20 -NUM_MUX_9545_1_CH3=$(( ${NUM_I801_DEVICE} + 12 )) # TMP75#0 0x4C TMP75#1 0x49 - -# HOST MUX PCA9548#2 0X70 -NUM_MUX_9548_2_CH0=$(( ${NUM_I801_DEVICE} + 13 )) # PCA9548#3 0x71 -NUM_MUX_9548_2_CH1=$(( ${NUM_I801_DEVICE} + 14 )) # PCA9548#4 0x71 -NUM_MUX_9548_2_CH2=$(( ${NUM_I801_DEVICE} + 15 )) # PCA9548#5 0x71 -NUM_MUX_9548_2_CH3=$(( ${NUM_I801_DEVICE} + 16 )) # PCA9548#6 0x71 -NUM_MUX_9548_2_CH4=$(( ${NUM_I801_DEVICE} + 17 )) # PCA9535#3~6 0x20~0x23 ZQSFP ABS/INT -NUM_MUX_9548_2_CH5=$(( ${NUM_I801_DEVICE} + 18 )) # PCA9535#7~10 0x20~0x23 ZQSFP LPMODE/RST -NUM_MUX_9548_3_CH0=$(( ${NUM_I801_DEVICE} + 21 )) # QSFP 0 EEPROM -NUM_MUX_9548_4_CH0=$(( ${NUM_I801_DEVICE} + 29 )) # QSFP 8 EEPROM -NUM_MUX_9548_5_CH0=$(( ${NUM_I801_DEVICE} + 37 )) # QSFP 16 EEPROM -NUM_MUX_9548_6_CH0=$(( ${NUM_I801_DEVICE} + 45 )) # QSFP 24 EEPROM - -# MUX Alias -I2C_BUS_MAIN=${NUM_I801_DEVICE} -I2C_BUS_HWM=${NUM_MUX_9548_0_CH7} -I2C_BUS_FAN_STATUS=${NUM_MUX_9545_1_CH2} -I2C_BUS_SYS_LED=${NUM_MUX_9548_0_CH1} -I2C_BUS_HW_ID=${NUM_MUX_9548_0_CH1} -I2C_BUS_BMC_HW_ID=${I2C_BUS_MAIN} -I2C_BUS_PSU_STAT=${I2C_BUS_MAIN} -I2C_BUS_FANTRAY_LED=${NUM_MUX_9545_1_CH2} -I2C_BUS_MB_EEPROM=${I2C_BUS_MAIN} -I2C_BUS_CB_EEPROM=${I2C_BUS_MAIN} -I2C_BUS_PSU1_EEPROM=${NUM_MUX_9545_1_CH1} -I2C_BUS_PSU2_EEPROM=${NUM_MUX_9545_1_CH0} - -PATH_SYS_I2C_DEVICES="/sys/bus/i2c/devices" -PATH_SYS_GPIO="/sys/class/gpio" -PATH_HWMON_ROOT_DEVICES="/sys/class/hwmon" -PATH_HWMON_W83795_DEVICE="${PATH_HWMON_ROOT_DEVICES}/hwmon5" -PATH_I801_DEVICE="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_I801_DEVICE}" -PATH_MUX_9548_0_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH0}" -PATH_MUX_9548_0_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH1}" -PATH_MUX_9548_0_CH7="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH7}" -PATH_MUX_9545_1_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9545_1_CH0}" -PATH_MUX_9545_1_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9545_1_CH1}" -PATH_MUX_9545_1_CH2="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9545_1_CH2}" -PATH_MUX_9545_1_CH3="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9545_1_CH3}" -PATH_MUX_9548_2_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH0}" -PATH_MUX_9548_2_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH1}" -PATH_MUX_9548_2_CH2="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH2}" -PATH_MUX_9548_2_CH3="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH3}" -PATH_MUX_9548_2_CH4="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH4}" -PATH_MUX_9548_2_CH5="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH5}" -PATH_MUX_9548_3_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_3_CH0}" -PATH_MUX_9548_4_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_4_CH0}" -PATH_MUX_9548_5_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_5_CH0}" -PATH_MUX_9548_6_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_6_CH0}" - -# I2C Address -### I2C MUX -I2C_ADDR_MUX_9548_0=0x73 # MAIN MUX -I2C_ADDR_MUX_9545_1=0x72 # FRU MUX -I2C_ADDR_MUX_9548_2=0x70 # HOST MUX -I2C_ADDR_MUX_9548_3=0x71 # ZQSFP MUX #1 EEPROM -I2C_ADDR_MUX_9548_4=0x71 # ZQSFP MUX #2 EEPROM -I2C_ADDR_MUX_9548_5=0x71 # ZQSFP MUX #3 EEPROM -I2C_ADDR_MUX_9548_6=0x71 # ZQSFP MUX #4 EEPROM -### GPIO Expander -I2C_ADDR_MUX_9539_0=0x76 # LED & HW ID -I2C_ADDR_MUX_9539_1=0x75 # BMC PRSNT & HWM reset -I2C_ADDR_MUX_9539_2=0x74 # SYS SEL & RST -I2C_ADDR_MUX_9535_3=0x20 # ZQSFP0~15 ABS -I2C_ADDR_MUX_9535_4=0x21 # ZQSFP16~31 ABS -I2C_ADDR_MUX_9535_5=0x22 # ZQSFP0~15 INT -I2C_ADDR_MUX_9535_6=0x23 # ZQSFP16~31 INT -I2C_ADDR_MUX_9535_7=0x20 # ZQSFP0~15 LPMODE -I2C_ADDR_MUX_9535_8=0x21 # ZQSFP16~31 LPMODE -I2C_ADDR_MUX_9535_9=0x22 # ZQSFP0~15 RST -I2C_ADDR_MUX_9535_10=0x23 # ZQSFP16~31 RST -I2C_ADDR_MUX_9535_11=0x20 # on FAN board, fan status and led config -I2C_ADDR_MUX_9555_12=0x24 # on BMC board, INT and HW ID -I2C_ADDR_MUX_9555_13=0x25 # on BMC board, PSU status -I2C_ADDR_MUX_9555_14=0x26 # on BMC board, RST and SEL -I2C_ADDR_MUX_9539_15=0x77 # on CPU board, STATUS and ERR from CPLD -### peripheral -I2C_ADDR_MB_EEPROM=0x55 # on main board -I2C_ADDR_CB_EEPROM=0x51 # on cpu board -I2C_ADDR_UCD9090=0x34 -I2C_ADDR_W83795=0x2F -I2C_ADDR_PSU1_EEPROM=0x50 -I2C_ADDR_PSU2_EEPROM=0x50 -I2C_ADDR_TMP75_REAR=0x4C -I2C_ADDR_TMP75_FRONT=0x49 -I2C_ADDR_TMP75_CB=0x4F # on cpu board -I2C_ADDR_TMP75_BB=0x4A # on bmc board -I2C_ADDR_QSFP_EEPROM=0x50 - -#sysfs -PATH_SYSFS_PSU1="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_PSU1_EEPROM}-$(printf "%04x" $I2C_ADDR_PSU1_EEPROM)" -PATH_SYSFS_PSU2="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_PSU2_EEPROM}-$(printf "%04x" $I2C_ADDR_PSU2_EEPROM)" - -#ACTIVE LOW enable flag -ACTIVE_LOW_EN=1 -ACTIVE_HIGH_EN=0 -#GPIO Direction In/Out -DIR_IN=in -DIR_OUT=out - -#Power Supply Status -PSU_DC_ON=1 -PSU_DC_OFF=0 -PSU_EXIST=1 -PSU_NOT_EXIST=0 - -# IO expander register -# direction -REG_PORT0_DIR=6 -REG_PORT1_DIR=7 -# polarity -REG_PORT0_POL=4 -REG_PORT1_POL=5 -# output -REG_PORT0_OUT=2 -REG_PORT1_OUT=3 -# input -REG_PORT0_IN=0 -REG_PORT1_IN=1 - -#ZQSFP GPIO sysfs index -ZQSFP_PORT0_ABS_GPIO_IDX=240 # 240~255 -ZQSFP_PORT16_ABS_GPIO_IDX=224 # 224~239 - -# switch port number range -MIN_PORT_NUM=1 -MAX_PORT_NUM=32 - -#GPIO Offset -GPIO_OFFSET=0 - -# Help usage function -function _help { - echo "=========================================================" - echo "# Description: Help Function" - echo "# Version : ${VERSION}" - echo "=========================================================" - echo "----------------------------------------------------" - echo "EX : ${0} help" - echo " : ${0} i2c_init" - echo " : ${0} i2c_deinit" - echo " : ${0} i2c_fan_speed_init" - echo " : ${0} i2c_io_exp_init" - echo " : ${0} i2c_gpio_init" - echo " : ${0} i2c_gpio_deinit" - echo " : ${0} i2c_led_test" - echo " : ${0} i2c_psu_eeprom_get" - echo " : ${0} i2c_mb_eeprom_get" - echo " : ${0} i2c_cb_eeprom_get" - echo " : ${0} i2c_eeprom_sync" - echo " : ${0} i2c_qsfp_eeprom_get [1-32]" - echo " : ${0} i2c_qsfp_eeprom_init new|delete" - echo " : ${0} i2c_mb_eeprom_init new|delete" - echo " : ${0} i2c_cb_eeprom_init new|delete" - echo " : ${0} i2c_qsfp_status_get [1-32]" - echo " : ${0} i2c_qsfp_type_get [1-32]" - echo " : ${0} i2c_board_type_get" - echo " : ${0} i2c_bmc_board_type_get" - echo " : ${0} i2c_psu_status" - echo " : ${0} i2c_led_psu_status_set" - echo " : ${0} i2c_led_fan_status_set" - echo " : ${0} i2c_led_fan_tray_status_set" - echo " : ${0} i2c_test_all" - echo " : ${0} i2c_sys_led green|amber" - echo " : ${0} i2c_fan_led green|amber on|off" - echo " : ${0} i2c_psu1_led green|amber on|off" - echo " : ${0} i2c_psu2_led green|amber on|off" - echo " : ${0} i2c_fan_tray_led green|amber on|off [1-4]" - echo "----------------------------------------------------" -} - -#Pause function -function _pause { - read -p "$*" -} - -#Retry command function -function _retry { - local i - for i in {1..5}; - do - eval "${*}" && break || echo "retry"; sleep 1; - done -} - -#I2C Init -function _i2c_init { - echo "=========================================================" - echo "# Description: I2C Init" - echo "=========================================================" - - #rmmod i2c_ismt - _util_rmmod i2c_i801 - modprobe i2c_i801 disable_features=0x10 - modprobe i2c_dev - modprobe i2c_mux_pca954x force_deselect_on_exit=1 - - # add MUX PCA9548#0 on I801, assume to be i2c-1~8 - if [ ! -e ${PATH_MUX_9548_0_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_0}' > ${PATH_I801_DEVICE}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_0} already init." - fi - # add MUX PCA9545#1 on I801, assume to be i2c-9~12 - if [ ! -e ${PATH_MUX_9545_1_CH0} ]; then - _retry "echo 'pca9545 ${I2C_ADDR_MUX_9545_1}' > ${PATH_I801_DEVICE}/new_device" - else - echo "pca9545 ${I2C_ADDR_MUX_9545_1} already init." - fi - # add MUX PCA9548#2 on I801, assume to be i2c-13~20 - if [ ! -e ${PATH_MUX_9548_2_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_2}' > ${PATH_I801_DEVICE}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_2} already init." - fi - # add MUX PCA9548#3 on PCA9548#2 CH0, assume to be i2c-21~28 - if [ ! -e ${PATH_MUX_9548_3_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_3}' > ${PATH_MUX_9548_2_CH0}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_3} already init." - fi - # add MUX PCA9548#4 on PCA9548#2 CH1, assume to be i2c-29~36 - if [ ! -e ${PATH_MUX_9548_4_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_4}' > ${PATH_MUX_9548_2_CH1}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_4} already init." - fi - # add MUX PCA9548#5 on PCA9548#2 CH2, assume to be i2c-37~44 - if [ ! -e ${PATH_MUX_9548_5_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_5}' > ${PATH_MUX_9548_2_CH2}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_5} already init." - fi - # add MUX PCA9548#6 on PCA9548#2 CH3, assume to be i2c-45~52 - if [ ! -e ${PATH_MUX_9548_6_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_6}' > ${PATH_MUX_9548_2_CH3}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_6} already init." - fi - - _i2c_hwm_init - _util_rmmod eeprom - modprobe eeprom_mb - modprobe gpio-pca953x - _i2c_io_exp_init - rmmod gpio_ich - _i2c_gpio_init - modprobe gpio_ich - _i2c_sensors_init - _i2c_psu_init - - # Init LED_CLR register (pull shift register out of reset), should be after io exp init - _port_led_clr_init - _i2c_qsfp_eeprom_init "new" - _i2c_mb_eeprom_init "new" - _i2c_cb_eeprom_init "new" - _i2c_fan_speed_init - _i2c_led_psu_status_set - _i2c_led_fan_status_set - - # sync eeprom content - _i2c_eeprom_sync - - # trun on sys led - echo "led_sys setup..." - COLOR_LED="green" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_sys_led - - _config_rmem -} - -#I2C Deinit -function _i2c_deinit { - echo "i2c deinit..." - _i2c_gpio_deinit - for mod in coretemp jc42 w83795 eeprom eeprom_mb gpio-pca953x i2c_mux_pca954x i2c_i801 ingrasys_s9130_32x_psu; - do - _util_rmmod $mod - done - echo "Done" -} - -function _i2c_sensors_init { - echo "SENSORS init..." - local dev_path - # to make sure hwmon index in sysfs as expected, - # need to remove kernel module and then probe them in expected order - # remove all sensors kernel module - _util_rmmod coretemp - _util_rmmod jc42 - _util_rmmod w83795 - # probe coretemp kernel module - modprobe coretemp - # probe hwmon kernel module - modprobe w83795 - # add tmp75 to sysfs - ####Main board thermal - dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9545_1_CH3}-$(printf "%04x" ${I2C_ADDR_TMP75_REAR})" - if ! [ -L ${dev_path} ]; then - echo "tmp75 ${I2C_ADDR_TMP75_REAR}" > ${PATH_MUX_9545_1_CH3}/new_device # hwmon1 - else - echo "${dev_path} already exist" - fi - sleep 0.5 - dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9545_1_CH3}-$(printf "%04x" ${I2C_ADDR_TMP75_FRONT})" - if ! [ -L ${dev_path} ]; then - echo "tmp75 ${I2C_ADDR_TMP75_FRONT}" > ${PATH_MUX_9545_1_CH3}/new_device #hwmon2 - else - echo "${dev_path} already exist" - fi - sleep 0.5 - ####BMC board thermal - dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_0_CH7}-$(printf "%04x" ${I2C_ADDR_TMP75_BB})" - if ! [ -L ${dev_path} ]; then - echo "tmp75 ${I2C_ADDR_TMP75_BB}" > ${PATH_MUX_9548_0_CH7}/new_device #hwmon3 - else - echo "${dev_path} already exist" - fi - sleep 0.5 - ####CPU board thermal - dev_path="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MAIN}-$(printf "%04x" ${I2C_ADDR_TMP75_CB})" - if ! [ -L ${dev_path} ]; then - echo "tmp75 ${I2C_ADDR_TMP75_CB}" > ${PATH_I801_DEVICE}/new_device #hwmon4 - else - echo "${dev_path} already exist" - fi - sleep 0.5 - # add w83795 to sysfs - dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_0_CH7}-$(printf "%04x" ${I2C_ADDR_W83795})" - if ! [ -L ${dev_path} ]; then - echo "w83795adg ${I2C_ADDR_W83795}" > ${PATH_MUX_9548_0_CH7}/new_device #hwmon5 - else - echo "${dev_path} already exist" - fi - sleep 0.5 - - # probe jc42 kernel module - modprobe jc42 - - echo "Done" -} - -function _port_led_clr_init { - echo "port led init..." - # gpio pin on GPIO MUX PCA9539#2 I/O 0.2 - # pull high to out of reset - output_reg=${REG_PORT0_OUT} - mask=0x04 - value=0x04 - _util_i2cset -m ${mask} -y ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${output_reg} ${value} - echo "Done" -} - -#FAN Speed Init -function _i2c_fan_speed_init { - echo -n "FAN SPEED INIT..." - if [ -e "${PATH_HWMON_W83795_DEVICE}" ]; then - # init fan speed - echo 120 > ${PATH_HWMON_W83795_DEVICE}/device/pwm1 - echo 120 > ${PATH_HWMON_W83795_DEVICE}/device/pwm2 - echo "SUCCESS" - else - echo "FAIL" - fi -} - -# HWM init -function _i2c_hwm_init { - echo "HWM INIT..." - # select bank0 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x80 - # SW reset, Disable monitor - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x01 0x9C - # disable TR5/TR6 DTS - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x04 0x0 - # enable FANIN1~8 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x06 0xFF - # disable FANIN9~14 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x07 0x00 - # CLKIN clock frequency set as 48Mhz - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x01 0x1C - # select bank 2 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x82 - # set PWM mode in FOMC - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x0F 0x00 - # set 25KHz fan output frequency in F1OPFP&F2OPFP - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x18 0x84 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x19 0x84 -} - -#Temperature sensor Init -function _i2c_temp_init { - echo "TEMP INIT..." - # enable temp monitor on w83795 - # select bank0 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x80 - # enable TR4 temperature monitoring - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x05 0x40 - # disable TR5/TR6 DTS - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x04 0x0 - echo "Done" -} - -#VOLMON Init -function _i2c_volmon_init { - echo "VOLMON INIT..." - # enable voltage monitor on w83795 - # VSEN1 P0V9 - # VSEN2 VDD - # VSEN3 P1V2 - # VSEN4 P1V8 - # select bank0 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x80 - # enable vsen1~4, disable vsen5~8 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x02 0x0F - # enable 3VDD,VBAT - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x03 0x50 - echo "Done" -} - -#FANIN Init -function _i2c_fan_init { - echo "FANIN INIT..." - # enable fan monitor on w83795 - # 4 fantray with 8 FANIN - # select bank0 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x80 - # enable FANIN1~8 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x06 0xFF - # disable FANIN9~14 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x07 0x00 - - # select bank 2 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x82 - # set PWM mode in FOMC - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x0F 0x00 - - echo "Done" -} - -#IO Expander Init -function _i2c_io_exp_init { - echo "=========================================================" - echo "# Description: I2C IO Expender Init" - echo "=========================================================" - - # need to init BMC io expander first due to some io expander are reset default - echo "Init BMC INT & HW ID IO Expander" - # all input - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_12} ${REG_PORT0_DIR} 0xFF - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_12} ${REG_PORT1_DIR} 0xFF - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_12} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_12} ${REG_PORT1_POL} 0x00 - - echo "Init BMC PSU status IO Expander" - # PWRON default 0 (ACTIVE_LOW) - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_13} ${REG_PORT0_OUT} 0x00 - # default 0 (ACTIVE_LOW) - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_13} ${REG_PORT1_OUT} 0x00 - # I/O 0.2 0.5 output(PWRON), rest input - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_13} ${REG_PORT0_DIR} 0xDB - # I/O 1.0~1.1 input, 1.2~1.4 output (1.5~1.7 not enable) - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_13} ${REG_PORT1_DIR} 0xE3 - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_13} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_13} ${REG_PORT1_POL} 0x00 - - echo "Init BMC RST and SEL IO Expander" - # RST default is 1 (ACTIVE_LOW) - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_14} ${REG_PORT0_OUT} 0x3F - # SEL default is 0 (HOST), EN default is 1 (ACTIVE_HIGH) - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_14} ${REG_PORT1_OUT} 0x1F - # I/O 0.0~0.5 output, 0.6~0.7 not use - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_14} ${REG_PORT0_DIR} 0xC0 - # all output - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_14} ${REG_PORT1_DIR} 0x00 - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_14} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_14} ${REG_PORT1_POL} 0x00 - - echo "Init System LED & HW ID IO Expander" - # I/O_0.x for System LED default 0, I/O_1.x for HW ID - _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT0_OUT} 0x00 - # System LED => all output - _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT0_DIR} 0x00 - # HW ID => all input - _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT1_DIR} 0xFF - _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT1_POL} 0x00 - - echo "Init System PRSNT and HWM RST IO Expander" - # HWM_RST_L default 1 (ACTIVE_LOW) - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_1} ${REG_PORT0_OUT} 0x04 - # all input expect HWM_RST_L (0.2) - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_1} ${REG_PORT0_DIR} 0xFB - # port1 not used - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_1} ${REG_PORT1_DIR} 0xFF - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_1} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_1} ${REG_PORT1_POL} 0x00 - - echo "Init System SEL and RST IO Expander" - # RST 0.0~0.3 default 1 (ACTIVE low), rest default 0 - # SEL set to value 0 (host) - # LED_CLR also do init in _port_led_clr_init - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT0_OUT} 0x0F - # RST 1.6~1.7 default 1 (ACTIVE low), INT 1.0~1.4 default 1 (ACTIVE low) - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT1_OUT} 0xDF - # all output, but MAC_RST_L 0.0 need to set as input to prevent reboot issue - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT0_DIR} 0x09 - # RST 1.5 !~ 1.7 output, rest are input - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT1_DIR} 0x1F - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT1_POL} 0x00 - - echo "Init FAN Board Status IO Expander" - # LED_G_L set to 0, LED_Y_L set to 1 (ACTIVE_LOW) - _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9535_11} ${REG_PORT0_OUT} 0x22 - _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9535_11} ${REG_PORT1_OUT} 0x22 - # DIR/ABS is input, LED_Y/LED_G is output - _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9535_11} ${REG_PORT0_DIR} 0xCC - _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9535_11} ${REG_PORT1_DIR} 0xCC - _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9535_11} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9535_11} ${REG_PORT1_POL} 0x00 - - echo "Init CPU CPLD IO Expander" - # all input - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_15} ${REG_PORT0_DIR} 0xFF - # all input - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_15} ${REG_PORT1_DIR} 0xFF - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_15} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_15} ${REG_PORT1_POL} 0x00 - - echo "Init ZQSFP IO Expender" - - echo "set ZQSFP ABS" - #zQSFP 0-15 ABS - # all input - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_3} ${REG_PORT0_DIR} 0xFF - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_3} ${REG_PORT1_DIR} 0xFF - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_3} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_3} ${REG_PORT1_POL} 0x00 - #zQSFP 16-31 ABS - # all input - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_4} ${REG_PORT0_DIR} 0xFF - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_4} ${REG_PORT1_DIR} 0xFF - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_4} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_4} ${REG_PORT1_POL} 0x00 - - echo "set ZQSFP INT" - #zQSFP 0-15 INT - # all input - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_5} ${REG_PORT0_DIR} 0xFF - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_5} ${REG_PORT1_DIR} 0xFF - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_5} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_5} ${REG_PORT1_POL} 0x00 - #zQSFP 16-31 INT - # all input - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_6} ${REG_PORT0_DIR} 0xFF - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_6} ${REG_PORT1_DIR} 0xFF - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_6} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_6} ${REG_PORT1_POL} 0x00 - - echo "set ZQSFP LP_MODE = 0" - #ZQSFP 0-15 LP_MODE - # default is 0 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_7} ${REG_PORT0_OUT} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_7} ${REG_PORT1_OUT} 0x00 - # all output - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_7} ${REG_PORT0_DIR} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_7} ${REG_PORT1_DIR} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_7} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_7} ${REG_PORT1_POL} 0x00 - #ZQSFP 16-31 LP_MODE - # default is 0 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_8} ${REG_PORT0_OUT} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_8} ${REG_PORT1_OUT} 0x00 - # all output - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_8} ${REG_PORT0_DIR} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_8} ${REG_PORT1_DIR} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_8} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_8} ${REG_PORT1_POL} 0x00 - - echo "set ZQSFP RST = 1" - #ZQSFP 0-15 RST - # default is 1 (ACTIVE_LOW) - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_9} ${REG_PORT0_OUT} 0xFF - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_9} ${REG_PORT1_OUT} 0xFF - # all output - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_9} ${REG_PORT0_DIR} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_9} ${REG_PORT1_DIR} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_9} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_9} ${REG_PORT1_POL} 0x00 - #ZQSFP 16-31 RST - # default is 1 (ACTIVE_LOW) - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_10} ${REG_PORT0_OUT} 0xFF - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_10} ${REG_PORT1_OUT} 0xFF - # all output - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_10} ${REG_PORT0_DIR} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_10} ${REG_PORT1_DIR} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_10} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_10} ${REG_PORT1_POL} 0x00 - -} - -# To set the global variable GPIO_OFFSET -function _set_gpio_offset { - GPIO_OFFSET=0 - for d in `ls /sys/class/gpio/ | grep gpiochip` - do - gpiochip_no=${d##gpiochip} - if [ $gpiochip_no -gt 255 ]; then - GPIO_OFFSET=256 - break - fi - done - #echo "set GPIO_OFFSET=${GPIO_OFFSET}" -} - -#GPIO Init -function _i2c_gpio_init { - local i=0 - local start=255 - local end=255 - local ch_num=16 - - #ABS Port 0-15 - echo "pca9535 ${I2C_ADDR_MUX_9535_3}" > ${PATH_MUX_9548_2_CH4}/new_device - _set_gpio_offset - start=$[ ${start}+${GPIO_OFFSET} ] - end=$[ ${end}+${GPIO_OFFSET} ] - start=$[ ${end}-${ch_num}+1] - for (( i=$start; i<=$end; i++ )) - do - _util_gpio_export ${i} ${DIR_IN} ${ACTIVE_LOW_EN} - done - - #ABS Port 16-31 - end=$[ ${start}-1] - echo "pca9535 ${I2C_ADDR_MUX_9535_4}" > ${PATH_MUX_9548_2_CH4}/new_device - start=$[ ${end}-${ch_num}+1] - for (( i=$start; i<=$end; i++ )) - do - _util_gpio_export ${i} ${DIR_IN} ${ACTIVE_LOW_EN} - done - - #INT Port 0-15 - end=$[ ${start}-1] - echo "pca9535 ${I2C_ADDR_MUX_9535_5}" > ${PATH_MUX_9548_2_CH4}/new_device - start=$[ ${end}-${ch_num}+1] - for (( i=$start; i<=$end; i++ )) - do - _util_gpio_export ${i} ${DIR_IN} ${ACTIVE_LOW_EN} - done - - #INT Port 16-31 - end=$[ ${start}-1] - echo "pca9535 ${I2C_ADDR_MUX_9535_6}" > ${PATH_MUX_9548_2_CH4}/new_device - start=$[ ${end}-${ch_num}+1] - for (( i=$start; i<=$end; i++ )) - do - _util_gpio_export ${i} ${DIR_IN} ${ACTIVE_LOW_EN} - done - - #LP Mode Port 0-15 - end=$[ ${start}-1] - echo "pca9535 ${I2C_ADDR_MUX_9535_7}" > ${PATH_MUX_9548_2_CH5}/new_device - start=$[ ${end}-${ch_num}+1] - for (( i=$start; i<=$end; i++ )) - do - _util_gpio_export ${i} ${DIR_OUT} ${ACTIVE_HIGH_EN} - done - - #LP Mode Port 16-31 - end=$[ ${start}-1] - echo "pca9535 ${I2C_ADDR_MUX_9535_8}" > ${PATH_MUX_9548_2_CH5}/new_device - start=$[ ${end}-${ch_num}+1] - for (( i=$start; i<=$end; i++ )) - do - _util_gpio_export ${i} ${DIR_OUT} ${ACTIVE_HIGH_EN} - done - - #RESET Port 0-15 - end=$[ ${start}-1] - echo "pca9535 ${I2C_ADDR_MUX_9535_9}" > ${PATH_MUX_9548_2_CH5}/new_device - start=$[ ${end}-${ch_num}+1] - for (( i=$start; i<=$end; i++ )) - do - # need to set value to low (became ACTIVE_HIGH) to take port out of reset - _util_gpio_export ${i} ${DIR_OUT} ${ACTIVE_LOW_EN} 0 - done - - #RESET Port 16-31 - end=$[ ${start}-1] - echo "pca9535 ${I2C_ADDR_MUX_9535_10}" > ${PATH_MUX_9548_2_CH5}/new_device - start=$[ ${end}-${ch_num}+1] - for (( i=$start; i<=$end; i++ )) - do - # need to set value to low (became ACTIVE_HIGH) to take port out of reset - _util_gpio_export ${i} ${DIR_OUT} ${ACTIVE_LOW_EN} 0 - done -} - -#GPIO DeInit -function _i2c_gpio_deinit { - echo ${I2C_ADDR_MUX_9535_3} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH4}/delete_device - echo ${I2C_ADDR_MUX_9535_4} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH4}/delete_device - echo ${I2C_ADDR_MUX_9535_5} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH4}/delete_device - echo ${I2C_ADDR_MUX_9535_6} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH4}/delete_device - echo ${I2C_ADDR_MUX_9535_7} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH5}/delete_device - echo ${I2C_ADDR_MUX_9535_8} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH5}/delete_device - echo ${I2C_ADDR_MUX_9535_9} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH5}/delete_device - echo ${I2C_ADDR_MUX_9535_10} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH5}/delete_device -} - -#Set FAN Tray LED -function _i2c_led_fan_tray_status_set { - echo "FAN Tray Status Setup" - #FAN Status get - FAN1_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan8_alarm` - FAN2_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan7_alarm` - FAN3_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan6_alarm` - FAN4_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan5_alarm` - FAN5_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan4_alarm` - FAN6_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan3_alarm` - FAN7_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan2_alarm` - FAN8_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan1_alarm` - - # check if io expander for fan tray exist - result=`i2cget -y ${I2C_BUS_FANTRAY_LED} ${I2C_ADDR_MUX_9535_11} ${REG_PORT0_IN} 2>/dev/null` - err_code=$? - if [ "$err_code" != "0" ]; then - echo "fan tray not exist!" - return - fi - - if [ "${FAN1_ALARM}" == "0" ] && [ "${FAN2_ALARM}" == "0" ]; then - FAN_TRAY=1 - echo "FAN_TRAY${FAN_TRAY}..." - COLOR_LED="green" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - COLOR_LED="amber" - ONOFF_LED="off" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - else - FAN_TRAY=1 - echo "FAN_TRAY${FAN_TRAY}..." - COLOR_LED="green" - ONOFF_LED="off" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - COLOR_LED="amber" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - fi - - if [ "${FAN3_ALARM}" == "0" ] && [ "${FAN4_ALARM}" == "0" ]; then - FAN_TRAY=2 - echo "FAN_TRAY${FAN_TRAY}..." - COLOR_LED="green" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - COLOR_LED="amber" - ONOFF_LED="off" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - else - FAN_TRAY=2 - echo "FAN_TRAY${FAN_TRAY}..." - COLOR_LED="green" - ONOFF_LED="off" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - COLOR_LED="amber" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - fi - - if [ "${FAN5_ALARM}" == "0" ] && [ "${FAN6_ALARM}" == "0" ]; then - FAN_TRAY=3 - echo "FAN_TRAY${FAN_TRAY}..." - COLOR_LED="green" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - COLOR_LED="amber" - ONOFF_LED="off" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - else - FAN_TRAY=3 - echo "FAN_TRAY${FAN_TRAY}..." - COLOR_LED="green" - ONOFF_LED="off" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - COLOR_LED="amber" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - fi - - if [ "${FAN7_ALARM}" == "0" ] && [ "${FAN8_ALARM}" == "0" ]; then - FAN_TRAY=4 - echo "FAN_TRAY${FAN_TRAY}..." - COLOR_LED="green" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - COLOR_LED="amber" - ONOFF_LED="off" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - else - FAN_TRAY=4 - echo "FAN_TRAY${FAN_TRAY}..." - COLOR_LED="green" - ONOFF_LED="off" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - COLOR_LED="amber" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_tray_led - fi -} - -#Set FAN LED -function _i2c_led_fan_status_set { - echo "FAN Status Setup" - #PSU Status set - FAN1_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan1_alarm` - FAN2_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan2_alarm` - FAN3_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan3_alarm` - FAN4_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan4_alarm` - FAN5_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan5_alarm` - FAN6_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan6_alarm` - FAN7_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan7_alarm` - FAN8_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan8_alarm` - - echo "led_fan setup..." - # all fan ok - if [ "${FAN1_ALARM}" == "0" ] && [ "${FAN2_ALARM}" == "0" ] \ - && [ "${FAN3_ALARM}" == "0" ] && [ "${FAN4_ALARM}" == "0" ] \ - && [ "${FAN5_ALARM}" == "0" ] && [ "${FAN6_ALARM}" == "0" ] \ - && [ "${FAN7_ALARM}" == "0" ] && [ "${FAN8_ALARM}" == "0" ]; then - COLOR_LED="green" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_led - # all fan fail - elif [ "${FAN1_ALARM}" == "1" ] && [ "${FAN2_ALARM}" == "1" ] \ - && [ "${FAN3_ALARM}" == "1" ] && [ "${FAN4_ALARM}" == "1" ] \ - && [ "${FAN5_ALARM}" == "1" ] && [ "${FAN6_ALARM}" == "1" ] \ - && [ "${FAN7_ALARM}" == "1" ] && [ "${FAN8_ALARM}" == "1" ]; then - COLOR_LED="green" - ONOFF_LED="off" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_led - # partial fan fail - else - COLOR_LED="amber" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_fan_led - fi -} - -#Set Power Supply LED -function _i2c_led_psu_status_set { - echo "PSU LED Status Setup" - - #PSU Status set - _i2c_psu_status - - #PSU1 Status - echo "led_psu1 setup..." - if [ "${psu1Exist}" == ${PSU_EXIST} ]; then - if [ "${psu1PwGood}" == ${PSU_DC_ON} ]; then - COLOR_LED="green" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_psu1_led - else - COLOR_LED="amber" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_psu1_led - fi - else - COLOR_LED="green" - ONOFF_LED="off" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_psu1_led - fi - - #PSU2 Status - echo "led_psu2 setup..." - if [ "${psu2Exist}" == ${PSU_EXIST} ]; then - if [ "${psu2PwGood}" == ${PSU_DC_ON} ]; then - COLOR_LED="green" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_psu2_led - else - COLOR_LED="amber" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_psu2_led - fi - else - COLOR_LED="green" - ONOFF_LED="off" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_psu2_led - fi -} - -#LED Test -function _i2c_led_test { - echo "=========================================================" - echo "# Description: I2C SYSTEM LED TEST..." - echo "=========================================================" - local output_reg=${REG_PORT0_OUT} - local mask=0xFF - local value=0xFF - - #sys led (green) - # set sys_led_g (0.7) = 1 - mask=0x80 - value=0x80 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check SYS LED green light and Press [Enter] key to continue...' - #sys led (amber) - # set sys_led_g (0.7) = 0 - mask=0x80 - value=0x00 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check SYS LED amber light and Press [Enter] key to continue...' - - #FAN led (green) - # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 0 - mask=0x60 - value=0x40 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check FAN LED green light and Press [Enter] key to continue...' - #FAN led (amber) - # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 1 - mask=0x60 - value=0x60 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check FAN LED amber light and Press [Enter] key to continue...' - - #PSU1 led (green) - # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 0 - mask=0x18 - value=0x10 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check PSU1 LED green light and Press [Enter] key to continue...' - #PSU1 led (amber) - # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 1 - mask=0x18 - value=0x18 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check PSU1 LED amber light and Press [Enter] key to continue...' - - #PSU2 led (green) - # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 0 - mask=0x06 - value=0x04 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check PSU2 LED green light and Press [Enter] key to continue...' - #PSU2 led (amber) - # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 1 - mask=0x06 - value=0x06 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check PSU2 LED amber light and Press [Enter] key to continue...' - - #Turn OFF All LED (can't trun off system led) - # set set fan_led_en (0.6), psu1_pwr_ok_oe (0.4), psu0_pwr_ok_oe (0.2) = 0 - mask=0x54 - value=0x00 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check turn off all LEDs (exclude SYS LED) and Press [Enter] key to continue...' - - # restore sys led - COLOR_LED="green" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_sys_led - - echo "Done" -} - -#Set QSFP Port variable -function _qsfp_port_i2c_var_set { - local port=$1 - case ${port} in - 1|2|3|4|5|6|7|8) - i2cbus=${NUM_MUX_9548_2_CH4} - eeprombusbase=${NUM_MUX_9548_3_CH0} - gpioBase=$((${GPIO_OFFSET}+${ZQSFP_PORT0_ABS_GPIO_IDX})) - #gpioBase=${ZQSFP_PORT0_ABS_GPIO_IDX} - ;; - 9|10|11|12|13|14|15|16) - i2cbus=${NUM_MUX_9548_2_CH4} - eeprombusbase=${NUM_MUX_9548_4_CH0} - gpioBase=$((${GPIO_OFFSET}+${ZQSFP_PORT0_ABS_GPIO_IDX})) - #gpioBase=${ZQSFP_PORT0_ABS_GPIO_IDX} - ;; - 17|18|19|20|21|22|23|24) - i2cbus=${NUM_MUX_9548_2_CH4} - eeprombusbase=${NUM_MUX_9548_5_CH0} - gpioBase=$((${GPIO_OFFSET}+${ZQSFP_PORT16_ABS_GPIO_IDX})) - #gpioBase=${ZQSFP_PORT16_ABS_GPIO_IDX} - ;; - 25|26|27|28|29|30|31|32) - i2cbus=${NUM_MUX_9548_2_CH4} - eeprombusbase=${NUM_MUX_9548_6_CH0} - gpioBase=$((${GPIO_OFFSET}+${ZQSFP_PORT16_ABS_GPIO_IDX})) - #gpioBase=${ZQSFP_PORT16_ABS_GPIO_IDX} - ;; - *) - echo "Please input 1~32" - exit - ;; - esac -} - -#Set QSFP Port variable -function _qsfp_eeprom_var_set { - local port=$1 - # port 1 => zqsfp0 - # port 2 => zqsfp1 - # ... - eeprombusidx=$(( (${port} - 1) % 8)) - eeprombus=$(( ${eeprombusbase} + ${eeprombusidx} )) - eepromAddr=${I2C_ADDR_QSFP_EEPROM} -} - -#Get QSFP EEPROM Information -function _i2c_qsfp_eeprom_get { - - # input parameter validation - _util_input_check "${QSFP_PORT}" "${MIN_PORT_NUM}" "${MAX_PORT_NUM}" - - _util_get_qsfp_abs - - if [ $status = 0 ]; then - exit - fi - - _qsfp_eeprom_var_set ${QSFP_PORT} - - cat ${PATH_SYS_I2C_DEVICES}/$eeprombus-$(printf "%04x" $eepromAddr)/eeprom | hexdump -C -} - -#Init QSFP EEPROM -function _i2c_qsfp_eeprom_init { - echo "QSFP EEPROM INIT..." - - #Action check - action=$1 - if [ -z "${action}" ]; then - echo "No action, skip" - return - elif [ "${action}" != "new" ] && [ "${action}" != "delete" ]; then - echo "Error action, skip" - return - fi - - #Init 1-32 ports EEPROM - local i - for i in {1..32}; - do - _qsfp_port_i2c_var_set ${i} - - _qsfp_eeprom_var_set ${i} - - if [ "${action}" == "new" ] && \ - ! [ -L ${PATH_SYS_I2C_DEVICES}/$eeprombus-$(printf "%04x" $eepromAddr) ]; then - echo "sff8436 $eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eeprombus/new_device - elif [ "${action}" == "delete" ] && \ - [ -L ${PATH_SYS_I2C_DEVICES}/$eeprombus-$(printf "%04x" $eepromAddr) ]; then - echo "$eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eeprombus/delete_device - fi - done - echo "Done" -} - -#Init Main Board EEPROM -function _i2c_mb_eeprom_init { - echo -n "Main Board EEPROM INIT..." - - #Action check - action=$1 - if [ -z "${action}" ]; then - echo "No action, skip" - return - elif [ "${action}" != "new" ] && [ "${action}" != "delete" ]; then - echo "Error action, skip" - return - fi - - #Init mb EEPROM - if [ "${action}" == "new" ] && \ - ! [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM) ]; then - echo "mb_eeprom ${I2C_ADDR_MB_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_MB_EEPROM}/new_device - elif [ "${action}" == "delete" ] && \ - [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM) ]; then - echo "$I2C_ADDR_MB_EEPROM" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_MB_EEPROM}/delete_device - fi - echo "Done" -} - -#Init CPU Board EEPROM -function _i2c_cb_eeprom_init { - echo -n "CPU Board EEPROM INIT..." - - #Action check - action=$1 - if [ -z "${action}" ]; then - echo "No action, skip" - return - elif [ "${action}" != "new" ] && [ "${action}" != "delete" ]; then - echo "Error action, skip" - return - fi - - #Init cpu EEPROM - if [ "${action}" == "new" ] && \ - ! [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM) ]; then - echo "mb_eeprom ${I2C_ADDR_CB_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CB_EEPROM}/new_device - elif [ "${action}" == "delete" ] && \ - [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM) ]; then - echo "$I2C_ADDR_CB_EEPROM" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CB_EEPROM}/delete_device - fi - echo "Done" -} - - -#get QSFP Status -function _i2c_qsfp_status_get { - - # input parameter validation - _util_input_check "${QSFP_PORT}" "${MIN_PORT_NUM}" "${MAX_PORT_NUM}" - - local stat - _util_get_qsfp_abs - echo "status=$status" -} - -#get QSFP Type -function _i2c_qsfp_type_get { - - # input parameter validation - _util_input_check "${QSFP_PORT}" "${MIN_PORT_NUM}" "${MAX_PORT_NUM}" - - _qsfp_port_i2c_var_set ${QSFP_PORT} - - _qsfp_eeprom_var_set ${QSFP_PORT} - - #Get QSFP EEPROM info - qsfp_info=$(base64 ${PATH_SYS_I2C_DEVICES}/$eeprombus-$(printf "%04x" $eepromAddr)/eeprom) - - identifier=$(echo $qsfp_info | base64 -d -i | hexdump -s 128 -n 1 -e '"%x"') - connector=$(echo $qsfp_info | base64 -d -i | hexdump -s 130 -n 1 -e '"%x"') - transceiver=$(echo $qsfp_info | base64 -d -i | hexdump -s 131 -n 1 -e '"%x"') - - echo "identifier=$identifier" - echo "connector=$connector" - echo "transceiver=$transceiver" -} - -#Init PSU Kernel Module -function _i2c_psu_init { - echo "=========================================================" - echo "# Description: I2C PSU Init" - echo "=========================================================" - modprobe ingrasys_s9130_32x_psu - - echo "psu1 ${I2C_ADDR_PSU1_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_PSU1_EEPROM}/new_device - echo "psu2 ${I2C_ADDR_PSU2_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_PSU2_EEPROM}/new_device -} - -#Get PSU EEPROM Information -function _i2c_psu_eeprom_get { - local eeprom_psu1="" - local eeprom_psu2="" - - echo "=========================================================" - echo "# Description: I2C PSU EEPROM Get..." - echo "=========================================================" - - eeprom_psu1="${PATH_SYSFS_PSU1}/psu_eeprom" - cat ${eeprom_psu1} | hexdump -C - - eeprom_psu2="${PATH_SYSFS_PSU2}/psu_eeprom" - cat ${eeprom_psu2} | hexdump -C -} - -#Get Main Board EEPROM Information -function _i2c_mb_eeprom_get { - echo "=========================================================" - echo "# Description: I2C MB EEPROM Get..." - echo "=========================================================" - _i2c_sys_eeprom_get mb -} - -#Get CPU Board EEPROM Information -function _i2c_cb_eeprom_get { - echo "=========================================================" - echo "# Description: I2C CB EEPROM Get..." - echo "=========================================================" - _i2c_sys_eeprom_get cb -} - -#Get system EEPROM Information -##input: "cb" for cpu board, "mb" for main board -function _i2c_sys_eeprom_get { - local eeprom_dev - - if [ "$1" == "cb" ]; then - eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM)/eeprom" - elif [ "$1" == "mb" ]; then - eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM)/eeprom" - else - echo "wrong eeprom type" - return - fi - - # check if eeprom device exist in sysfs - if [ ! -f ${eeprom_dev} ]; then - echo "eeprom device not init" - return - fi - - cat ${eeprom_dev} | hexdump -C - echo "Done" -} - -#sync eeprom content between mb and cb eeprom -function _i2c_eeprom_sync { - echo "=========================================================" - echo "# Description: EEPROM sync..." - echo "=========================================================" - - local mb_eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM)/eeprom" - local cb_eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM)/eeprom" - - # check if eeprom device exist in sysfs - if [[ ! -f ${mb_eeprom_dev} || ! -f ${cb_eeprom_dev} ]]; then - echo "eeprom device not init" - return - fi - - ## check if MB eeprom is empty - if [ ! -z "$(cat ${mb_eeprom_dev} | hexdump -n2 | grep ffff)" ]; then - echo "copy cb eeprom to mb eeprom..." - cat ${cb_eeprom_dev} > ${mb_eeprom_dev} - else - echo "no need to sync" - fi - - echo "Done" -} - -#Set System Status LED -function _i2c_sys_led { - # only green/amber, on/off can't control - if [ "${COLOR_LED}" == "green" ]; then - # set sys_led_g (0.7) = 1 - output_reg=${REG_PORT0_OUT} - mask=0x80 - value=0x80 - elif [ "${COLOR_LED}" == "amber" ]; then - # set sys_led_g (0.7) = 0 - output_reg=${REG_PORT0_OUT} - mask=0x80 - value=0x00 - else - echo "Invalid Parameters, Exit!!!" - _help - exit ${FALSE} - fi - - #apply to io expander - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - echo "Done" -} - -#Set FAN LED -function _i2c_fan_led { - if [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "on" ]; then - # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 0 - output_reg=${REG_PORT0_OUT} - mask=0x60 - value=0x40 - elif [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "off" ]; then - # set fan_led_en (0.6) = 0 & fan_led_y (0.5) = 0 - output_reg=${REG_PORT0_OUT} - mask=0x60 - value=0x00 - elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "on" ]; then - # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 1 - output_reg=${REG_PORT0_OUT} - mask=0x60 - value=0x60 - elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "off" ]; then - # set fan_led_en (0.6) = 0 & fan_led_y (0.5) = 1 - output_reg=${REG_PORT0_OUT} - mask=0x60 - value=0x20 - else - echo "Invalid Parameters, Exit!!!" - _help - exit ${FALSE} - fi - - #apply to io expander - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - echo "Done" -} - -#Set PSU1 LED -function _i2c_psu1_led { - if [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "on" ]; then - # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 0 - output_reg=${REG_PORT0_OUT} - mask=0x18 - value=0x10 - elif [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "off" ]; then - # set psu1_pwr_ok_oe (0.4) = 0 & psu1_led_y (0.3) = 0 - output_reg=${REG_PORT0_OUT} - mask=0x18 - value=0x00 - elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "on" ]; then - # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 1 - output_reg=${REG_PORT0_OUT} - mask=0x18 - value=0x18 - elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "off" ]; then - # set psu1_pwr_ok_oe (0.4) = 0 & psu1_led_y (0.3) = 1 - output_reg=${REG_PORT0_OUT} - mask=0x18 - value=0x08 - else - echo "Invalid Parameters, Exit!!!" - _help - exit ${FALSE} - fi - - #apply to io expander - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - echo "Done" -} - -#Set PSU2 LED -function _i2c_psu2_led { - if [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "on" ]; then - # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 0 - output_reg=${REG_PORT0_OUT} - mask=0x06 - value=0x04 - elif [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "off" ]; then - # set psu0_pwr_ok_oe (0.2) = 0 & psu0_led_y (0.1) = 0 - output_reg=${REG_PORT0_OUT} - mask=0x06 - value=0x00 - elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "on" ]; then - # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 1 - output_reg=${REG_PORT0_OUT} - mask=0x06 - value=0x06 - elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "off" ]; then - # set psu0_pwr_ok_oe (0.2) = 0 & psu0_led_y (0.1) = 1 - output_reg=${REG_PORT0_OUT} - mask=0x06 - value=0x02 - else - echo "Invalid Parameters, Exit!!!" - _help - exit ${FALSE} - fi - - #apply to io expander - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - echo "Done" -} - -#Set FAN Tray LED -function _i2c_fan_tray_led { - - i2cAddr=${I2C_ADDR_MUX_9535_11} - output_reg=${REG_PORT0_OUT} - - case ${FAN_TRAY} in - 4) - output_reg=${REG_PORT0_OUT} - if [ "${COLOR_LED}" == "green" ]; then - mask=0x01 - elif [ "${COLOR_LED}" == "amber" ]; then - mask=0x02 - fi - ;; - 3) - output_reg=${REG_PORT0_OUT} - if [ "${COLOR_LED}" == "green" ]; then - mask=0x10 - elif [ "${COLOR_LED}" == "amber" ]; then - mask=0x20 - fi - ;; - 2) - output_reg=${REG_PORT1_OUT} - if [ "${COLOR_LED}" == "green" ]; then - mask=0x01 - elif [ "${COLOR_LED}" == "amber" ]; then - mask=0x02 - fi - ;; - 1) - output_reg=${REG_PORT1_OUT} - if [ "${COLOR_LED}" == "green" ]; then - mask=0x10 - elif [ "${COLOR_LED}" == "amber" ]; then - mask=0x20 - fi - ;; - *) - echo "Please input 1~4" - exit - ;; - esac - - if [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "on" ]; then - _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0x00 - elif [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "off" ]; then - _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0x33 - elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "on" ]; then - _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0x00 - elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "off" ]; then - _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0x33 - else - echo "Invalid Parameters, Exit!!!" - _help - exit ${FALSE} - fi - - echo "Done" -} - -#Get Board Version and Type -function _i2c_board_type_get { - # read input port 1 value from io expander - input_reg=${REG_PORT1_IN} - boardType=`i2cget -y ${I2C_BUS_HW_ID} ${I2C_ADDR_MUX_9539_0} ${input_reg}` - boardBuildRev=$((($boardType) & 0x03)) - boardHwRev=$((($boardType) >> 2 & 0x03)) - boardId=$((($boardType) >> 4)) - printf "MAIN_BOARD BOARD_ID is 0x%02x, HW Rev %d, Build Rev %d\n" $boardId $boardHwRev $boardBuildRev -} - -#Get BMC Board Version and Type -function _i2c_bmc_board_type_get { - # read input port 1 value from io expander - input_reg=${REG_PORT1_IN} - boardType=`i2cget -y ${I2C_BUS_BMC_HW_ID} ${I2C_ADDR_MUX_9555_12} ${input_reg}` - boardBuildRev=$((($boardType) & 0x03)) - boardHwRev=$((($boardType) >> 2 & 0x03)) - boardId=$((($boardType) >> 4)) - printf "BMC_BOARD BOARD_ID is 0x%02x, HW Rev %d, Build Rev %d\n" $boardId $boardHwRev $boardBuildRev -} - -#Get PSU Status -function _i2c_psu_status { - local psu_abs="" - - psu1PwGood=`cat ${PATH_SYSFS_PSU1}/psu_pg` - psu_abs=`cat ${PATH_SYSFS_PSU1}/psu_abs` - if [ "$psu_abs" == "0" ]; then - psu1Exist=1 - else - psu1Exist=0 - fi - - psu2PwGood=`cat ${PATH_SYSFS_PSU2}/psu_pg` - psu_abs=`cat ${PATH_SYSFS_PSU2}/psu_abs` - if [ "$psu_abs" == "0" ]; then - psu2Exist=1 - else - psu2Exist=0 - fi - - printf "PSU1 Exist:%x PSU1 PW Good:%d\n" $psu1Exist $psu1PwGood - printf "PSU2 Exist:%d PSU2 PW Good:%d\n" $psu2Exist $psu2PwGood -} - -#util functions -function _util_i2cset { - if [ "$DEBUG" == "on" ]; then - i2cset $@ - else - i2cset $@ 1>/dev/null - fi -} - -function _util_rmmod { - local mod=$1 - [ "$(lsmod | grep "^$mod ")" != "" ] && rmmod $mod -} - -# get qsfp presence -function _util_get_qsfp_abs { - _qsfp_port_i2c_var_set ${QSFP_PORT} - - #status: 0 -> Down, 1 -> Up (ACTIVE_LOW_EN) - status=`cat /sys/class/gpio/gpio$(( $(($gpioBase + (${QSFP_PORT} - 1) % 16 )) ))/value` -} - -# gpio init util function -function _util_gpio_export { - local gpio_n=$1 - local direction=$2 - local active_low=$3 - local value=$4 - - if [ -z "${gpio_n}" ]; then - echo "[gpio_init] gpio_n(${gpio_n}) is not provided" - return - fi - if [[ ${gpio_n} < 0 || ${gpio_n} > $(( 255+${GPIO_OFFSET} )) ]]; then - echo "[gpio_init] gpio_n(${gpio_n}) is invalid value" - return - fi - - #export gpio - echo ${gpio_n} > /sys/class/gpio/export - #set gpio direction - echo ${direction} > /sys/class/gpio/gpio${gpio_n}/direction - #set gpio active_low - echo ${active_low} > /sys/class/gpio/gpio${gpio_n}/active_low - #set value - if [ ! -z "${value}" ]; then - echo ${value} > /sys/class/gpio/gpio${gpio_n}/value - fi -} - -# valid input number -function _util_input_check { - # input parameter validation - if [[ $1 -lt $2 || $1 -gt $3 ]]; then - echo "Please input number $2~$3" - exit - fi -} - -#Increase read socket buffer for CoPP Test -function _config_rmem { - echo "109430400" > /proc/sys/net/core/rmem_max -} - -#Main Function -function _main { - tart_time_str=`date` - start_time_sec=$(date +%s) - - _set_gpio_offset - if [ "${EXEC_FUNC}" == "help" ]; then - _help - elif [ "${EXEC_FUNC}" == "i2c_init" ]; then - _i2c_init - elif [ "${EXEC_FUNC}" == "i2c_deinit" ]; then - _i2c_deinit - elif [ "${EXEC_FUNC}" == "i2c_fan_speed_init" ]; then - _i2c_fan_speed_init - elif [ "${EXEC_FUNC}" == "i2c_io_exp_init" ]; then - _i2c_io_exp_init - elif [ "${EXEC_FUNC}" == "i2c_gpio_init" ]; then - _i2c_gpio_init - elif [ "${EXEC_FUNC}" == "i2c_gpio_deinit" ]; then - _i2c_gpio_deinit - elif [ "${EXEC_FUNC}" == "i2c_led_test" ]; then - _i2c_led_test - elif [ "${EXEC_FUNC}" == "i2c_mb_eeprom_get" ]; then - _i2c_mb_eeprom_get - elif [ "${EXEC_FUNC}" == "i2c_cb_eeprom_get" ]; then - _i2c_cb_eeprom_get - elif [ "${EXEC_FUNC}" == "i2c_eeprom_sync" ]; then - _i2c_eeprom_sync - elif [ "${EXEC_FUNC}" == "i2c_psu_eeprom_get" ]; then - _i2c_psu_eeprom_get - elif [ "${EXEC_FUNC}" == "i2c_qsfp_eeprom_get" ]; then - _i2c_qsfp_eeprom_get - elif [ "${EXEC_FUNC}" == "i2c_qsfp_eeprom_init" ]; then - _i2c_qsfp_eeprom_init ${QSFP_ACTION} - elif [ "${EXEC_FUNC}" == "i2c_mb_eeprom_init" ]; then - _i2c_mb_eeprom_init ${MB_EEPROM_ACTION} - elif [ "${EXEC_FUNC}" == "i2c_cb_eeprom_init" ]; then - _i2c_cb_eeprom_init ${MB_EEPROM_ACTION} - elif [ "${EXEC_FUNC}" == "i2c_qsfp_status_get" ]; then - _i2c_qsfp_status_get - elif [ "${EXEC_FUNC}" == "i2c_qsfp_type_get" ]; then - _i2c_qsfp_type_get - elif [ "${EXEC_FUNC}" == "i2c_led_psu_status_set" ]; then - _i2c_led_psu_status_set - elif [ "${EXEC_FUNC}" == "i2c_led_fan_status_set" ]; then - _i2c_led_fan_status_set - elif [ "${EXEC_FUNC}" == "i2c_led_fan_tray_status_set" ]; then - _i2c_led_fan_tray_status_set - elif [ "${EXEC_FUNC}" == "i2c_sys_led" ]; then - _i2c_sys_led - elif [ "${EXEC_FUNC}" == "i2c_fan_led" ]; then - _i2c_fan_led - elif [ "${EXEC_FUNC}" == "i2c_fan_tray_led" ]; then - _i2c_fan_tray_led - elif [ "${EXEC_FUNC}" == "i2c_psu1_led" ]; then - _i2c_psu1_led - elif [ "${EXEC_FUNC}" == "i2c_psu2_led" ]; then - _i2c_psu2_led - elif [ "${EXEC_FUNC}" == "i2c_board_type_get" ]; then - _i2c_board_type_get - elif [ "${EXEC_FUNC}" == "i2c_bmc_board_type_get" ]; then - _i2c_bmc_board_type_get - elif [ "${EXEC_FUNC}" == "i2c_psu_status" ]; then - _i2c_psu_status - elif [ "${EXEC_FUNC}" == "i2c_test_all" ]; then - _i2c_init - _i2c_led_test - _i2c_psu_eeprom_get - _i2c_mb_eeprom_get - _i2c_cb_eeprom_get - _i2c_board_type_get - _i2c_bmc_board_type_get - _i2c_psu_status - else - echo "Invalid Parameters, Exit!!!" - _help - exit ${FALSE} - fi - - if [ "$DEBUG" == "on" ]; then - echo "-----------------------------------------------------" - end_time_str=`date` - end_time_sec=$(date +%s) - diff_time=$[ ${end_time_sec} - ${start_time_sec} ] - echo "Start Time: ${start_time_str} (${start_time_sec})" - echo "End Time : ${end_time_str} (${end_time_sec})" - echo "Total Execution Time: ${diff_time} sec" - - echo "done!!!" - fi -} - -_main diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/qsfp_monitor.sh b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/qsfp_monitor.sh deleted file mode 100755 index 7776493bc20..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/qsfp_monitor.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/bash -# Copyright (C) 2017 Ingrasys, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -INTERVAL=3 -I2C_UTILS="/usr/sbin/i2c_utils.sh" -QSFP_SI_SCRIPT="/usr/sbin/qsfp_si_cfg.sh" -QSFP_ARRAY=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) - -#QSFP SI monitor -function _qsfp_si_monitor { - local i - local status - for i in {0..31}; - do - status=`${I2C_UTILS} i2c_qsfp_status_get $(expr $i + 1) | egrep '^status=.*$' | sed -e 's/status=//g'` - if [ "${status}" == "1" ]; then - _qsfp_type_check $i - fi - done -} - -#QSFP type -function _qsfp_type_check { - local port=$1 - local qsfp_type=`${I2C_UTILS} i2c_qsfp_type_get $(expr $port + 1)` - local identifier=`echo "$qsfp_type" | grep '^identifier=.*$' | sed -e 's/identifier=//g'` - if [ "${identifier}" == "11" ]; then - connector=`echo "$qsfp_type" | grep '^connector=.*$' | sed -e 's/connector=//g'` - case ${connector} in - 21|23) - #DAC - if [ "${QSFP_ARRAY[$port]}" != "${connector}" ]; then - echo "Change Port $(expr $port + 1) to DAC" - QSFP_ARRAY[$port]=${connector} - ${QSFP_SI_SCRIPT} dac $port >/dev/null - fi - ;; - *) - #Optical - if [ "${QSFP_ARRAY[$port]}" != "${connector}" ]; then - echo "Change Port $(expr $port + 1) to Optical" - QSFP_ARRAY[$port]=${connector} - ${QSFP_SI_SCRIPT} optical $port >/dev/null - fi - ;; - esac - fi -} - -#Docker exist check -function _docker_swss_check { - while true - do - # Check if syncd starts - result=`sonic-db-cli ASIC_DB HLEN HIDDEN` - if [ "$result" == "3" ]; then - return - fi - sleep $INTERVAL - done -} - -#Docker exist check -function _qsfp_si_cfg_script_check { - - if [ -f ${QSFP_SI_SCRIPT} ] && [ -x ${QSFP_SI_SCRIPT} ]; then - echo "SI Script exists. Start monitor." - return - else - echo "SI Script not exist. Exit monitor." - exit - fi -} - -# main function -function _main { - #Check SI Script - _qsfp_si_cfg_script_check - #Check docker swss is running - _docker_swss_check - while true - do - _qsfp_si_monitor - # Sleep while still handling signals - sleep $INTERVAL & - wait $! - done -} - -_main - diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/s9130_32x_monitor.sh b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/s9130_32x_monitor.sh deleted file mode 100755 index 974da6d5001..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/s9130_32x_monitor.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# Copyright (C) 2016 Ingrasys, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -INTERVAL=5 -I2C_UTILS="/usr/sbin/i2c_utils.sh" - - -# LED status monitor -function _led_monitor { - ${I2C_UTILS} i2c_led_fan_status_set >/dev/null - ${I2C_UTILS} i2c_led_psu_status_set >/dev/null - ${I2C_UTILS} i2c_led_fan_tray_status_set >/dev/null -} - -# main function -function _main { - while true - do - _led_monitor - # Sleep while still handling signals - sleep $INTERVAL & - wait $! - done -} - -_main \ No newline at end of file diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/README.md b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/README.md deleted file mode 100644 index d1a2d5464ae..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/README.md +++ /dev/null @@ -1,182 +0,0 @@ -# Ingrasys S9230-64X Platform Driver for SONiC - -Copyright (C) 2016 Ingrasys, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - - -## Licensing terms - -The Licensing terms of the files within this project is split 2 parts. -The Linux kernel is released under the GNU General Public License version 2. -All other code is released under the GNU General Public License version 3. -Please see the LICENSE file for copies of both licenses. - -## Contents of this package - - - service/ - > Service config files for platform initialization and monitoring - - utils/ - > Scripts useful during platform bringup and sysfs function - - conf/ - > Platform configure files. - -## Kernel modules and drivers - -The driver for interacting with Ingrasys S9230-64X is contained in the I2C -kernel module and initialization script. The initialization script loads -the modules in the correct order. It has been built and tested against -the Linux 3.16 kernel. - -The initialization script will modprobe the needed modules, navigate to the -module's device directory in sysfs, and write configuration data to -the kernel module. - -### IGB - -This is OOB Ports on front panel for management plane. - -The IGB module must be loaded first on Ingrasys S9230-64X platform. - -### I2C i801 - -The I2C i801 on Ingrasys S9230-64X can be found in -`/sys/bus/i2c/devices/i2c-0/` - -This is I2C bus for power monitor, FAN controller, HWM and thermal sensors. - -### I2C PCA9548 -The PCA9548 module on S9230-64X can be found in -`/sys/bus/i2c/devices/i2c-1/` , `/sys/bus/i2c/devices/i2c-2/`, -`/sys/bus/i2c/devices/i2c-3/`, `/sys/bus/i2c/devices/i2c-4/`, -`/sys/bus/i2c/devices/i2c-5/`, `/sys/bus/i2c/devices/i2c-6/`, -`/sys/bus/i2c/devices/i2c-7/`, `/sys/bus/i2c/devices/i2c-8/` - -The pca9548 module for CPLD get/set functions, PSU information, -fan status and EEPROM. - -## Hardware components - -The hardware components are initialized in the init script on S9230-64X. -The following describes manual initialization as well as interaction. -The examples below are just for Ingrasys S9230-64X platform. - -### Hardware initialization - -When the sonic-platform-ingrasys-s9230-64X package is installed on the S9230-64X, -it is automatically initialized. If you want to manual initialization, the -utility command usage as follows: -``` - i2c_utils.sh i2c_init -``` - -### EEPROM - -The EEPROM is including the board SKU, model name, vendor name, serial number, -and other information can be accessed with the specific eeprom kernel module. -After using `modprobe eeprom_mb` to detect the eeprom, it will show up in sysfs. - -The hexdump utility can be used to decode the raw output of the EEPROM. -For example, -``` - bash# echo "mb_eeprom 0x55" > /sys/bus/i2c/devices/i2c-0/new_device - bash# cat /sys/bus/i2c/drivers/mb_eeprom/0-0055/eeprom | hexdump -C -``` - -### Front panel LEDs - -LEDs can be setup on/off by using i2c utility `/usr/sbin/i2c_utils.sh`. -Utility function command usage as follows: - -``` -Status LED: - i2c_utils.sh i2c_sys_led green|amber - -Fan status LED: - i2c_utils.sh i2c_fan_led green|amber on|off - -PSU1 status LED: - i2c_utils.sh i2c_psu1_led green|amber on|off - -PSU2 status LED: - i2c_utils.sh i2c_psu2_led green|amber on|off - -``` -QSFP Module Port LEDs control by ASIC library. - - -### Fan speed - -Fan speed are controlled by the w83795 kernel module. -It can be found in `/sys/class/hwmon/hwmon7/device/`. -If they were compiled as modules, you will need to modprobe w83795 for -their sysfs entries to show up. Each fan has an `fan_input` file -for reading the fan speed. And `pwm1` setting fan1 to fan4, -`pwm2` setting fan5 to fan8. - -There is docker-platform-monitor container installed fancontrol package that can -automatic control platform fan speed. - - -### Temperature sensors - -There is docker-platform-monitor container installed lm-sensors package that can -monitor platform temperature. And `sensors` command can show each -temperature sensors status. - -### Power supplies - -Power supplies status and its EEPROM info can be used i2c utility -`/usr/sbin/i2c_utils.sh` to get. -The usage as follows: -``` -PSU EEPROM: - i2c_utils.sh i2c_psu_eeprom_get - hexdump -C psu0.rom - hexdump -C psu1.rom - -PSU Status: - i2c_utils.sh i2c_psu_status -``` - -### QSFPs -QSFP modules are managed by the CPLD 1~5 according to port number. -The i2c utility `/usr/sbin/i2c_utils.sh` can be used to get status and -module EEPROM informations. -The usage as follows: -``` -QSFP EEPROM: - i2c_utils.sh i2c_qsfp_eeprom_get [1-64] - -QSFP Insert Event: - i2c_utils.sh i2c_qsfp_status_get [1-64] - 0 => not insert - 1 => inserted -``` - -### SFP+ -SFP+ modules are managed by the CPLD 1~2 according to port number. -The i2c utility `/usr/sbin/i2c_utils.sh` can be used to get status and -module EEPROM informations. -The usage as follows: -``` -SFP EEPROM: - i2c_utils.sh i2c_sfp_eeprom_get [1-2] - -SFP Insert Event: - i2c_utils.sh i2c_sfp_status_get [1-2] - 0 => not insert - 1 => inserted -``` - diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/Makefile b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/Makefile deleted file mode 100755 index 3107674e871..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -obj-m := eeprom_mb.o -obj-m += ingrasys_s9230_64x_i2c_cpld.o -obj-m += ingrasys_s9230_64x_psu.o diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/eeprom_mb.c b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/eeprom_mb.c deleted file mode 100755 index 528864d9338..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/eeprom_mb.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (C) 1998, 1999 Frodo Looijaard and - * Philip Edelbrock - * Copyright (C) 2003 Greg Kroah-Hartman - * Copyright (C) 2003 IBM Corp. - * Copyright (C) 2004 Jean Delvare - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -/* enable dev_dbg print out */ -//#define DEBUG - -#include -#include -#include -#include -#include -#include -#include - -/* Addresses to scan */ -static const unsigned short normal_i2c[] = { /*0x50, 0x51, 0x52, 0x53, 0x54, - 0x55, 0x56, 0x57,*/ I2C_CLIENT_END }; - -/* Size of EEPROM in bytes */ -#define EEPROM_SIZE 512 - -#define SLICE_BITS (6) -#define SLICE_SIZE (1 << SLICE_BITS) -#define SLICE_NUM (EEPROM_SIZE/SLICE_SIZE) - -/* Each client has this additional data */ -struct eeprom_data { - struct mutex update_lock; - u8 valid; /* bitfield, bit!=0 if slice is valid */ - unsigned long last_updated[SLICE_NUM]; /* In jiffies, 8 slices */ - u8 data[EEPROM_SIZE]; /* Register values */ -}; - - -static void mb_eeprom_update_client(struct i2c_client *client, u8 slice) -{ - struct eeprom_data *data = i2c_get_clientdata(client); - int i, j; - int ret; - int addr; - - mutex_lock(&data->update_lock); - - if (!(data->valid & (1 << slice)) || - time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { - dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); - - addr = slice << SLICE_BITS; - - ret = i2c_smbus_write_byte_data(client, (u8)((addr >> 8) & 0xFF), (u8)(addr & 0xFF)); - /* select the eeprom address */ - if (ret < 0) { - dev_err(&client->dev, "address set failed\n"); - goto exit; - } - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) { - goto exit; - } - - for (i = slice << SLICE_BITS; i < (slice + 1) << SLICE_BITS; i+= SLICE_SIZE) { - for (j = i; j < (i+SLICE_SIZE); j++) { - int res; - - res = i2c_smbus_read_byte(client); - if (res < 0) { - goto exit; - } - - data->data[j] = res & 0xFF; - } - } - - data->last_updated[slice] = jiffies; - data->valid |= (1 << slice); - } -exit: - mutex_unlock(&data->update_lock); -} - -static ssize_t mb_eeprom_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) -{ - struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); - struct eeprom_data *data = i2c_get_clientdata(client); - u8 slice; - - if (off > EEPROM_SIZE) { - return 0; - } - if (off + count > EEPROM_SIZE) { - count = EEPROM_SIZE - off; - } - if (count == 0) { - return 0; - } - - /* Only refresh slices which contain requested bytes */ - for (slice = off >> SLICE_BITS; slice <= (off + count - 1) >> SLICE_BITS; slice++) { - mb_eeprom_update_client(client, slice); - } - - memcpy(buf, &data->data[off], count); - - return count; -} - -static ssize_t mb_eeprom_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) -{ - struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); - struct eeprom_data *data = i2c_get_clientdata(client); - int ret; - int i; - u8 cmd; - u16 value16; - - dev_dbg(&client->dev, "mb_eeprom_write off=%d, count=%d\n", (int)off, (int)count); - - if (off > EEPROM_SIZE) { - return 0; - } - if (off + count > EEPROM_SIZE) { - count = EEPROM_SIZE - off; - } - if (count == 0) { - return 0; - } - - mutex_lock(&data->update_lock); - - for(i=0; i < count; i++) { - /* write command */ - cmd = (off >> 8) & 0xff; - value16 = off & 0xff; - value16 |= buf[i] << 8; - ret = i2c_smbus_write_word_data(client, cmd, value16); - - if (ret < 0) { - dev_err(&client->dev, "write address failed at %d \n", (int)off); - goto exit; - } - - off++; - - /* need to wait for write complete */ - udelay(10000); - } -exit: - mutex_unlock(&data->update_lock); - /* force to update client when reading */ - for(i=0; i < SLICE_NUM; i++) { - data->last_updated[i] = 0; - } - - return count; -} - -static struct bin_attribute mb_eeprom_attr = { - .attr = { - .name = "eeprom", - .mode = S_IRUGO | S_IWUSR, - }, - .size = EEPROM_SIZE, - .read = mb_eeprom_read, - .write = mb_eeprom_write, -}; - -/* Return 0 if detection is successful, -ENODEV otherwise */ -static int mb_eeprom_detect(struct i2c_client *client, struct i2c_board_info *info) -{ - struct i2c_adapter *adapter = client->adapter; - - /* EDID EEPROMs are often 24C00 EEPROMs, which answer to all - addresses 0x50-0x57, but we only care about 0x51 and 0x55. So decline - attaching to addresses >= 0x56 on DDC buses */ - if (!(adapter->class & I2C_CLASS_SPD) && client->addr >= 0x56) { - return -ENODEV; - } - - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE) - && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - return -ENODEV; - } - - strlcpy(info->type, "eeprom", I2C_NAME_SIZE); - - return 0; -} - -static int mb_eeprom_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct eeprom_data *data; - int err; - - if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } - - memset(data->data, 0xff, EEPROM_SIZE); - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - - /* create the sysfs eeprom file */ - err = sysfs_create_bin_file(&client->dev.kobj, &mb_eeprom_attr); - if (err) { - goto exit_kfree; - } - - return 0; - -exit_kfree: - kfree(data); -exit: - return err; -} - -static int mb_eeprom_remove(struct i2c_client *client) -{ - sysfs_remove_bin_file(&client->dev.kobj, &mb_eeprom_attr); - kfree(i2c_get_clientdata(client)); - - return 0; -} - -static const struct i2c_device_id mb_eeprom_id[] = { - { "mb_eeprom", 0 }, - { } -}; - -static struct i2c_driver mb_eeprom_driver = { - .driver = { - .name = "mb_eeprom", - }, - .probe = mb_eeprom_probe, - .remove = mb_eeprom_remove, - .id_table = mb_eeprom_id, - - .class = I2C_CLASS_DDC | I2C_CLASS_SPD, - .detect = mb_eeprom_detect, - .address_list = normal_i2c, -}; - -module_i2c_driver(mb_eeprom_driver); - -MODULE_AUTHOR("Wade "); -MODULE_DESCRIPTION("Ingrasys Mother Borad EEPROM driver"); -MODULE_LICENSE("GPL"); diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_i2c_cpld.c b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_i2c_cpld.c deleted file mode 100644 index 7d832fc0149..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_i2c_cpld.c +++ /dev/null @@ -1,1259 +0,0 @@ -/* - * A i2c cpld driver for the ingrasys_s9230_64x - * - * Copyright (C) 2017 Ingrasys Technology Corporation. - * Leo Lin - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ingrasys_s9230_64x_i2c_cpld.h" - -#ifdef DEBUG -#define DEBUG_PRINT(fmt, args...) \ - printk(KERN_INFO "%s:%s[%d]: " fmt "\r\n", \ - __FILE__, __func__, __LINE__, ##args) -#else -#define DEBUG_PRINT(fmt, args...) -#endif - -#define I2C_READ_BYTE_DATA(ret, lock, i2c_client, reg) \ -{ \ - mutex_lock(lock); \ - ret = i2c_smbus_read_byte_data(i2c_client, reg); \ - mutex_unlock(lock); \ -} -#define I2C_WRITE_BYTE_DATA(ret, lock, i2c_client, reg, val) \ -{ \ - mutex_lock(lock); \ - ret = i2c_smbus_write_byte_data(i2c_client, reg, val); \ - mutex_unlock(lock); \ -} - -/* CPLD sysfs attributes index */ -enum s9230_64x_cpld_sysfs_attributes { - CPLD_ACCESS_REG, - CPLD_REGISTER_VAL, - CPLD_PORT_START, - CPLD_PORTS, - CPLD_VERSION, - CPLD_ID, - CPLD_BOARD_TYPE, - CPLD_EXT_BOARD_TYPE, - CPLD_QSFP_PORT_STATUS_1, - CPLD_QSFP_PORT_STATUS_2, - CPLD_QSFP_PORT_STATUS_3, - CPLD_QSFP_PORT_STATUS_4, - CPLD_QSFP_PORT_STATUS_5, - CPLD_QSFP_PORT_STATUS_6, - CPLD_QSFP_PORT_STATUS_7, - CPLD_QSFP_PORT_STATUS_8, - CPLD_QSFP_PORT_STATUS_9, - CPLD_QSFP_PORT_STATUS_10, - CPLD_QSFP_PORT_STATUS_11, - CPLD_QSFP_PORT_STATUS_12, - CPLD_QSFP_PORT_STATUS_13, - CPLD_QSFP_PORT_CONFIG_1, - CPLD_QSFP_PORT_CONFIG_2, - CPLD_QSFP_PORT_CONFIG_3, - CPLD_QSFP_PORT_CONFIG_4, - CPLD_QSFP_PORT_CONFIG_5, - CPLD_QSFP_PORT_CONFIG_6, - CPLD_QSFP_PORT_CONFIG_7, - CPLD_QSFP_PORT_CONFIG_8, - CPLD_QSFP_PORT_CONFIG_9, - CPLD_QSFP_PORT_CONFIG_10, - CPLD_QSFP_PORT_CONFIG_11, - CPLD_QSFP_PORT_CONFIG_12, - CPLD_QSFP_PORT_CONFIG_13, - CPLD_QSFP_PORT_INTERRUPT, - CPLD_SFP_PORT_STATUS, - CPLD_SFP_PORT_CONFIG, - CPLD_10GMUX_CONFIG, - CPLD_BMC_STATUS, - CPLD_BMC_WATCHDOG, - CPLD_USB_STATUS, -}; - -/* CPLD sysfs attributes hook functions */ -static ssize_t read_access_register(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_access_register(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_register_value(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_register_value(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t get_qsfp_port_start(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t get_qsfp_ports(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_cpld_version(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_cpld_id(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_board_type(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_ext_board_type(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_qsfp_port_status(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_qsfp_port_config(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_qsfp_port_config(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_qsfp_port_interrupt(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_sfp_port_status(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_sfp_port_config(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_sfp_port_config(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_10gmux_config(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_10gmux_config(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_bmc_status(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_bmc_watchdog(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_bmc_watchdog(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_usb_status(struct device *dev, - struct device_attribute *da, char *buf); - -static LIST_HEAD(cpld_client_list); /* client list for cpld */ -static struct mutex list_lock; /* mutex for client list */ - -struct cpld_client_node { - struct i2c_client *client; - struct list_head list; -}; - -struct cpld_data { - int index; /* CPLD index */ - struct mutex access_lock; /* mutex for cpld access */ - u8 access_reg; /* register to access */ -}; - -/* CPLD device id and data */ -static const struct i2c_device_id ingrasys_i2c_cpld_id[] = { - { "ingrasys_cpld1", cpld1 }, - { "ingrasys_cpld2", cpld2 }, - { "ingrasys_cpld3", cpld3 }, - { "ingrasys_cpld4", cpld4 }, - { "ingrasys_cpld5", cpld5 }, - {} -}; - -/* Addresses scanned for ingrasys_i2c_cpld */ -static const unsigned short cpld_i2c_addr[] = { 0x33, I2C_CLIENT_END }; - -/* define all support register access of cpld in attribute */ -static SENSOR_DEVICE_ATTR(cpld_access_register, S_IWUSR | S_IRUGO, - read_access_register, write_access_register, CPLD_ACCESS_REG); -static SENSOR_DEVICE_ATTR(cpld_register_value, S_IWUSR | S_IRUGO, - read_register_value, write_register_value, CPLD_REGISTER_VAL); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_start, S_IRUGO, - get_qsfp_port_start, NULL, CPLD_PORT_START); -static SENSOR_DEVICE_ATTR(cpld_qsfp_ports, S_IRUGO, - get_qsfp_ports, NULL, CPLD_PORTS); -static SENSOR_DEVICE_ATTR(cpld_version, S_IRUGO, - read_cpld_version, NULL, CPLD_VERSION); -static SENSOR_DEVICE_ATTR(cpld_id, S_IRUGO, read_cpld_id, NULL, CPLD_ID); -static SENSOR_DEVICE_ATTR(cpld_board_type, S_IRUGO, - read_board_type, NULL, CPLD_BOARD_TYPE); -static SENSOR_DEVICE_ATTR(cpld_ext_board_type, S_IRUGO, - read_ext_board_type, NULL, CPLD_EXT_BOARD_TYPE); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_1, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_1); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_2, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_2); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_3, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_3); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_4, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_4); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_5, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_5); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_6, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_6); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_7, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_7); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_8, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_8); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_9, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_9); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_10, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_10); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_11, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_11); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_12, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_12); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_13, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_13); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_1, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, CPLD_QSFP_PORT_CONFIG_1); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_2, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_2); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_3, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_3); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_4, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_4); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_5, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_5); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_6, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_6); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_7, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_7); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_8, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_8); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_9, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_9); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_10, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_10); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_11, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_11); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_12, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_12); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_13, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_13); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_interrupt, S_IRUGO, - read_qsfp_port_interrupt, NULL, CPLD_QSFP_PORT_INTERRUPT); -static SENSOR_DEVICE_ATTR(cpld_sfp_port_status, S_IRUGO, - read_sfp_port_status, NULL, CPLD_SFP_PORT_STATUS); -static SENSOR_DEVICE_ATTR(cpld_sfp_port_config, S_IWUSR | S_IRUGO, - read_sfp_port_config, write_sfp_port_config, CPLD_SFP_PORT_CONFIG); -static SENSOR_DEVICE_ATTR(cpld_10gmux_config, S_IWUSR | S_IRUGO, - read_10gmux_config, write_10gmux_config, - CPLD_10GMUX_CONFIG); -static SENSOR_DEVICE_ATTR(cpld_bmc_status, S_IRUGO, - read_bmc_status, NULL, CPLD_BMC_STATUS); -static SENSOR_DEVICE_ATTR(cpld_bmc_watchdog, S_IWUSR | S_IRUGO, - read_bmc_watchdog, write_bmc_watchdog, - CPLD_BMC_WATCHDOG); -static SENSOR_DEVICE_ATTR(cpld_usb_status, S_IRUGO, - read_usb_status, NULL, CPLD_USB_STATUS); - - -/* define support attributes of cpldx , total 5 */ -/* cpld 1 */ -static struct attribute *s9230_64x_cpld1_attributes[] = { - &sensor_dev_attr_cpld_access_register.dev_attr.attr, - &sensor_dev_attr_cpld_register_value.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_start.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_ports.dev_attr.attr, - &sensor_dev_attr_cpld_version.dev_attr.attr, - &sensor_dev_attr_cpld_id.dev_attr.attr, - &sensor_dev_attr_cpld_board_type.dev_attr.attr, - &sensor_dev_attr_cpld_ext_board_type.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_interrupt.dev_attr.attr, - &sensor_dev_attr_cpld_sfp_port_status.dev_attr.attr, - &sensor_dev_attr_cpld_sfp_port_config.dev_attr.attr, - &sensor_dev_attr_cpld_10gmux_config.dev_attr.attr, - &sensor_dev_attr_cpld_bmc_status.dev_attr.attr, - &sensor_dev_attr_cpld_bmc_watchdog.dev_attr.attr, - &sensor_dev_attr_cpld_usb_status.dev_attr.attr, - NULL -}; -/* cpld 2 */ -static struct attribute *s9230_64x_cpld2_attributes[] = { - &sensor_dev_attr_cpld_access_register.dev_attr.attr, - &sensor_dev_attr_cpld_register_value.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_start.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_ports.dev_attr.attr, - &sensor_dev_attr_cpld_version.dev_attr.attr, - &sensor_dev_attr_cpld_id.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_13.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_13.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_interrupt.dev_attr.attr, - &sensor_dev_attr_cpld_sfp_port_status.dev_attr.attr, - &sensor_dev_attr_cpld_sfp_port_config.dev_attr.attr, - NULL -}; -/* cpld 3 / cpld 4 / cpld 5 */ -static struct attribute *s9230_64x_cpld345_attributes[] = { -&sensor_dev_attr_cpld_access_register.dev_attr.attr, - &sensor_dev_attr_cpld_register_value.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_start.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_ports.dev_attr.attr, - &sensor_dev_attr_cpld_version.dev_attr.attr, - &sensor_dev_attr_cpld_id.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_13.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_13.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_interrupt.dev_attr.attr, - NULL -}; - -/* cpld 1 attributes group */ -static const struct attribute_group s9230_64x_cpld1_group = { - .attrs = s9230_64x_cpld1_attributes, -}; -/* cpld 2 attributes group */ -static const struct attribute_group s9230_64x_cpld2_group = { - .attrs = s9230_64x_cpld2_attributes, -}; -/* cpld 3/4/5 attributes group */ -static const struct attribute_group s9230_64x_cpld345_group = { - .attrs = s9230_64x_cpld345_attributes, -}; - -/* read access register from cpld data */ -static ssize_t read_access_register(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); - u8 reg = data->access_reg; - - return sprintf(buf, "0x%x\n", reg); -} - -/* write access register to cpld data */ -static ssize_t write_access_register(struct device *dev, - struct device_attribute *da, - const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - - if (kstrtou8(buf, 0, ®) < 0) - return -EINVAL; - - data->access_reg = reg; - return count; -} - -/* read the value of access register in cpld data */ -static ssize_t read_register_value(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); - u8 reg = data->access_reg; - int reg_val; - - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - - if (reg_val < 0) - return -1; - - return sprintf(buf, "0x%x\n", reg_val); -} - -/* wrtie the value to access register in cpld data */ -static ssize_t write_register_value(struct device *dev, - struct device_attribute *da, - const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - int ret = -EIO; - u8 reg = data->access_reg; - u8 reg_val; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, client, reg, reg_val); - - return count; -} - -/* get qsfp port start number of the cpld device */ -/* the start number use to tranlate qsfp port to cpld port */ -/* the cpld port use to access the qsfp port register in cpld */ -static ssize_t get_qsfp_port_start(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); - int port_base_num; - - if (attr->index == CPLD_PORT_START) { - if (data->index == cpld1) { - port_base_num = 1; - } else { - port_base_num = CPLD_1_PORT_NUM + - CPLD_2_PORT_NUM*(data->index - 1) + 1; - } - return sprintf(buf, "%d\n", port_base_num); - } - return -1; -} - -/* get total qsfp port which contain register in the cpld device */ -static ssize_t get_qsfp_ports(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); - int ports; - - if (attr->index == CPLD_PORTS) { - if (data->index == cpld1) - ports = CPLD_1_PORT_NUM; - else - ports = CPLD_2_PORT_NUM; - return sprintf(buf, "%d\n", ports); - } - return -1; -} - -/* get cpdl version register value */ -static ssize_t read_cpld_version(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); - u8 reg; - int reg_val; - - if (attr->index == CPLD_VERSION) { - reg = CPLD_VERSION_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get cpdl id register value */ -static ssize_t read_cpld_id(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); - u8 reg; - int reg_val; - - if (attr->index == CPLD_ID) { - reg = CPLD_ID_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get board type register value */ -static ssize_t read_board_type(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); - u8 reg; - int reg_val; - - if (attr->index == CPLD_BOARD_TYPE) { - reg = CPLD_BOARD_TYPE_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get extend board type register value */ -static ssize_t read_ext_board_type(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); - u8 reg; - int reg_val; - - if (attr->index == CPLD_EXT_BOARD_TYPE) { - reg = CPLD_EXT_BOARD_TYPE_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get qsfp port status register value */ -static ssize_t read_qsfp_port_status(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index >= CPLD_QSFP_PORT_STATUS_1 && - attr->index <= CPLD_QSFP_PORT_STATUS_13) { - reg = CPLD_QSFP_PORT_STATUS_BASE_REG + - (attr->index - CPLD_QSFP_PORT_STATUS_1); - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get qsfp port config register value */ -static ssize_t read_qsfp_port_config(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); - u8 reg; - int reg_val; - - if (attr->index >= CPLD_QSFP_PORT_CONFIG_1 && - attr->index <= CPLD_QSFP_PORT_CONFIG_13) { - reg = CPLD_QSFP_PORT_CONFIG_BASE_REG + - (attr->index - CPLD_QSFP_PORT_CONFIG_1); - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to qsfp port config register */ -static ssize_t write_qsfp_port_config(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); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index >= CPLD_QSFP_PORT_CONFIG_1 && - attr->index <= CPLD_QSFP_PORT_CONFIG_13) { - reg = CPLD_QSFP_PORT_CONFIG_BASE_REG + - (attr->index - CPLD_QSFP_PORT_CONFIG_1); - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get qsfp port interrupt register value */ -static ssize_t read_qsfp_port_interrupt(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); - u8 reg; - int reg_val; - - if (attr->index == CPLD_QSFP_PORT_INTERRUPT) { - reg = CPLD_QSFP_PORT_INTERRUPT_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get sfp port status register value */ -static ssize_t read_sfp_port_status(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_SFP_PORT_STATUS) { - reg = CPLD_SFP_PORT_STATUS_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get sfp port config register value */ -static ssize_t read_sfp_port_config(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); - u8 reg; - int reg_val; - - if (attr->index == CPLD_SFP_PORT_CONFIG) { - reg = CPLD_SFP_PORT_CONFIG_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to sfp port config register */ -static ssize_t write_sfp_port_config(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); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index == CPLD_SFP_PORT_CONFIG) { - reg = CPLD_SFP_PORT_CONFIG_REG; - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get 10g mux config register value */ -static ssize_t read_10gmux_config(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); - u8 reg; - int reg_val; - - if (attr->index == CPLD_10GMUX_CONFIG) { - reg = CPLD_10GMUX_CONFIG_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to 10g mux config register */ -static ssize_t write_10gmux_config(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); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index == CPLD_10GMUX_CONFIG) { - reg = CPLD_10GMUX_CONFIG_REG; - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get bmc status register value */ -static ssize_t read_bmc_status(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_BMC_STATUS) { - reg = CPLD_BMC_STATUS_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get bmc watchdog register value */ -static ssize_t read_bmc_watchdog(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); - u8 reg; - int reg_val; - - if (attr->index == CPLD_BMC_WATCHDOG) { - reg = CPLD_BMC_WATCHDOG_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to bmc watchdog register */ -static ssize_t write_bmc_watchdog(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); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index == CPLD_BMC_WATCHDOG) { - reg = CPLD_BMC_WATCHDOG_REG; - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get usb status register value */ -static ssize_t read_usb_status(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_USB_STATUS) { - reg = CPLD_USB_STATUS_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* add valid cpld client to list */ -static void ingrasys_i2c_cpld_add_client(struct i2c_client *client) -{ - struct cpld_client_node *node = NULL; - - node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); - if (!node) { - dev_info(&client->dev, - "Can't allocate cpld_client_node for index %d\n", - client->addr); - return; - } - - node->client = client; - - mutex_lock(&list_lock); - list_add(&node->list, &cpld_client_list); - mutex_unlock(&list_lock); -} - -/* remove exist cpld client in list */ -static void ingrasys_i2c_cpld_remove_client(struct i2c_client *client) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int found = 0; - - mutex_lock(&list_lock); - list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, - struct cpld_client_node, list); - - if (cpld_node->client == client) { - found = 1; - break; - } - } - - if (found) { - list_del(list_node); - kfree(cpld_node); - } - mutex_unlock(&list_lock); -} - -/* cpld drvier probe */ -static int ingrasys_i2c_cpld_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int status; - struct cpld_data *data = NULL; - int ret = -EPERM; - int err; - int idx; - - data = kzalloc(sizeof(struct cpld_data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - /* init cpld data for client */ - i2c_set_clientdata(client, data); - mutex_init(&data->access_lock); - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_info(&client->dev, - "i2c_check_functionality failed (0x%x)\n", - client->addr); - status = -EIO; - goto exit; - } - - /* get cpld id from device */ - ret = i2c_smbus_read_byte_data(client, CPLD_ID_REG); - - if (ret < 0) { - dev_info(&client->dev, - "fail to get cpld id (0x%x) at addr (0x%x)\n", - CPLD_ID_REG, client->addr); - status = -EIO; - goto exit; - } - - CPLD_ID_ID_GET(ret, idx); - - if (INVALID(idx, cpld1, cpld5)) { - dev_info(&client->dev, - "cpld id %d(device) not valid\n", idx); - //status = -EPERM; - //goto exit; - } - -#if 0 - /* change client name for each cpld with index */ - snprintf(client->name, sizeof(client->name), "%s_%d", client->name, - data->index); -#endif - - data->index = dev_id->driver_data; - - /* register sysfs hooks for different cpld group */ - dev_info(&client->dev, "probe cpld with index %d\n", data->index); - switch (data->index) { - case cpld1: - status = sysfs_create_group(&client->dev.kobj, - &s9230_64x_cpld1_group); - break; - case cpld2: - status = sysfs_create_group(&client->dev.kobj, - &s9230_64x_cpld2_group); - break; - case cpld3: - case cpld4: - case cpld5: - status = sysfs_create_group(&client->dev.kobj, - &s9230_64x_cpld345_group); - break; - default: - status = -EINVAL; - } - - if (status) - goto exit; - - dev_info(&client->dev, "chip found\n"); - - /* add probe chip to client list */ - ingrasys_i2c_cpld_add_client(client); - - return 0; -exit: - sysfs_remove_group(&client->dev.kobj, &s9230_64x_cpld345_group); - return status; -} - -/* cpld drvier remove */ -static int ingrasys_i2c_cpld_remove(struct i2c_client *client) -{ - struct cpld_data *data = i2c_get_clientdata(client); - - switch (data->index) { - case cpld1: - sysfs_remove_group(&client->dev.kobj, &s9230_64x_cpld1_group); - break; - case cpld2: - sysfs_remove_group(&client->dev.kobj, &s9230_64x_cpld2_group); - break; - case cpld3: - case cpld4: - case cpld5: - sysfs_remove_group(&client->dev.kobj, - &s9230_64x_cpld345_group); - break; - } - - ingrasys_i2c_cpld_remove_client(client); - return 0; -} - -MODULE_DEVICE_TABLE(i2c, ingrasys_i2c_cpld_id); - -static struct i2c_driver ingrasys_i2c_cpld_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "ingrasys_i2c_cpld", - }, - .probe = ingrasys_i2c_cpld_probe, - .remove = ingrasys_i2c_cpld_remove, - .id_table = ingrasys_i2c_cpld_id, - .address_list = cpld_i2c_addr, -}; - -/* provid cpld register read */ -/* cpld_idx indicate the index of cpld device */ -int ingrasys_i2c_cpld_read(u8 cpld_idx, - u8 reg) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EPERM; - struct cpld_data *data; - - list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, - struct cpld_client_node, list); - data = i2c_get_clientdata(cpld_node->client); - if (data->index == cpld_idx) { - DEBUG_PRINT("cpld_idx=%d, read reg 0x%02x", - cpld_idx, reg); - I2C_READ_BYTE_DATA(ret, &data->access_lock, - cpld_node->client, reg); - DEBUG_PRINT("cpld_idx=%d, read reg 0x%02x = 0x%02x", - cpld_idx, reg, ret); - break; - } - } - - return ret; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_read); - -/* provid cpld register write */ -/* cpld_idx indicate the index of cpld device */ -int ingrasys_i2c_cpld_write(u8 cpld_idx, - u8 reg, - u8 value) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EIO; - struct cpld_data *data; - - list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, - struct cpld_client_node, list); - data = i2c_get_clientdata(cpld_node->client); - - if (data->index == cpld_idx) { - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - cpld_node->client, - reg, value); - DEBUG_PRINT("cpld_idx=%d, write reg 0x%02x val 0x%02x, ret=%d", - cpld_idx, reg, value, ret); - break; - } - } - - return ret; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_write); - -/* provid qsfp port status register read */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_get_qsfp_port_status_val(u8 port_num) -{ - u8 cpld_idx, cpld_port, reg; - int reg_val; - - if (INVALID(port_num, QSFP_MIN_PORT_NUM, QSFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - QSFP_TO_CPLD_IDX(port_num, cpld_idx, cpld_port); - reg = QSFP_PORT_STATUS_REG(cpld_port); - DEBUG_PRINT("port_num=%d, cpld_idx=%d, cpld_port=%d, reg=0x%x", - port_num, cpld_idx, cpld_port, reg); - reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg); - return reg_val; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_get_qsfp_port_status_val); - -/* provid qsfp port config register read */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_get_qsfp_port_config_val(u8 port_num) -{ - u8 cpld_idx, cpld_port, reg; - int reg_val; - - if (INVALID(port_num, QSFP_MIN_PORT_NUM, QSFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - QSFP_TO_CPLD_IDX(port_num, cpld_idx, cpld_port); - reg = QSFP_PORT_CONFIG_REG(cpld_port); - DEBUG_PRINT("port_num=%d, cpld_idx=%d, cpld_port=%d, reg=0x%x", - port_num, cpld_idx, cpld_port, reg); - reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg); - return reg_val; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_get_qsfp_port_config_val); - -/* provid qsfp port config register write */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_set_qsfp_port_config_val(u8 port_num, - u8 reg_val) -{ - u8 cpld_idx, cpld_port, reg, ret; - - if (INVALID(port_num, QSFP_MIN_PORT_NUM, QSFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - QSFP_TO_CPLD_IDX(port_num, cpld_idx, cpld_port); - reg = QSFP_PORT_CONFIG_REG(cpld_port); - DEBUG_PRINT("port_num=%d, cpld_idx=%d, cpld_port=%d, reg=0x%x", - port_num, cpld_idx, cpld_port, reg); - ret = ingrasys_i2c_cpld_write(cpld_idx, reg, reg_val); - return ret; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_set_qsfp_port_config_val); - -/* provid sfp port status register read */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_get_sfp_port_status_val(u8 port_num) -{ - u8 cpld_idx, reg; - int reg_val; - - if (INVALID(port_num, SFP_MIN_PORT_NUM, SFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - SFP_TO_CPLD_IDX(port_num, cpld_idx); - reg = CPLD_SFP_PORT_STATUS_REG; - DEBUG_PRINT("port_num=%d, cpld_idx=%d, reg=0x%x", - port_num, cpld_idx, reg); - reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg); - return reg_val; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_get_sfp_port_status_val); - -/* provid qsfp port config register read */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_get_sfp_port_config_val(u8 port_num) -{ - u8 cpld_idx, reg; - int reg_val; - - if (INVALID(port_num, SFP_MIN_PORT_NUM, SFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - SFP_TO_CPLD_IDX(port_num, cpld_idx); - reg = CPLD_SFP_PORT_CONFIG_REG; - DEBUG_PRINT("port_num=%d, cpld_idx=%d, reg=0x%x", - port_num, cpld_idx, reg); - reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg); - return reg_val; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_get_sfp_port_config_val); - -/* provid qsfp port config register write */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_set_sfp_port_config_val(u8 port_num, - u8 reg_val) -{ - u8 cpld_idx, reg, ret; - - if (INVALID(port_num, SFP_MIN_PORT_NUM, SFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - SFP_TO_CPLD_IDX(port_num, cpld_idx); - reg = CPLD_SFP_PORT_CONFIG_REG; - DEBUG_PRINT("port_num=%d, cpld_idx=%d, reg=0x%x", - port_num, cpld_idx, reg); - ret = ingrasys_i2c_cpld_write(cpld_idx, reg, reg_val); - return ret; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_set_sfp_port_config_val); - -static int __init ingrasys_i2c_cpld_init(void) -{ - mutex_init(&list_lock); - return i2c_add_driver(&ingrasys_i2c_cpld_driver); -} - -static void __exit ingrasys_i2c_cpld_exit(void) -{ - i2c_del_driver(&ingrasys_i2c_cpld_driver); -} - -MODULE_AUTHOR("Leo Lin "); -MODULE_DESCRIPTION("ingrasys_i2c_cpld driver"); -MODULE_LICENSE("GPL"); - -module_init(ingrasys_i2c_cpld_init); -module_exit(ingrasys_i2c_cpld_exit); - diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_i2c_cpld.h b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_i2c_cpld.h deleted file mode 100644 index e0e53174d67..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_i2c_cpld.h +++ /dev/null @@ -1,223 +0,0 @@ -/* header file for i2c cpld driver of ingrasys_s9230_64x - * - * Copyright (C) 2017 Ingrasys Technology Corporation. - * Leo Lin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef INGRASYS_S9230_64X_I2C_CPLD_H -#define INGRASYS_S9230_64X_I2C_CPLD_H - -/* CPLD device index value */ -enum cpld_id { - cpld1, - cpld2, - cpld3, - cpld4, - cpld5 -}; - -/* port number on CPLD */ -#define CPLD_1_PORT_NUM 12 -#define CPLD_2_PORT_NUM 13 - -/* QSFP port number */ -#define QSFP_MAX_PORT_NUM 64 -#define QSFP_MIN_PORT_NUM 1 - -/* SFP+ port number */ -#define SFP_MAX_PORT_NUM 2 -#define SFP_MIN_PORT_NUM 1 - - -/* CPLD registers */ -#define CPLD_BOARD_TYPE_REG 0x0 -#define CPLD_EXT_BOARD_TYPE_REG 0x7 -#define CPLD_VERSION_REG 0x1 -#define CPLD_ID_REG 0x2 -#define CPLD_QSFP_PORT_STATUS_BASE_REG 0x20 -#define CPLD_QSFP_PORT_CONFIG_BASE_REG 0x30 -#define CPLD_QSFP_PORT_INTERRUPT_REG 0x40 -#define CPLD_SFP_PORT_STATUS_REG 0x2F -#define CPLD_SFP_PORT_CONFIG_REG 0x3F -#define CPLD_QSFP_PORT_INTERRUPT_REG 0x40 -#define CPLD_10GMUX_CONFIG_REG 0x41 -#define CPLD_BMC_STATUS_REG 0x42 -#define CPLD_BMC_WATCHDOG_REG 0x43 -#define CPLD_USB_STATUS_REG 0x44 -#define CPLD_REST_CONTROL_REG 0x4A - - -/* bit definition for register value */ -enum CPLD_QSFP_PORT_STATUS_BITS { - CPLD_QSFP_PORT_STATUS_INT_BIT, - CPLD_QSFP_PORT_STATUS_ABS_BIT, -}; -enum CPLD_QSFP_PORT_CONFIG_BITS { - CPLD_QSFP_PORT_CONFIG_RESET_BIT, - CPLD_QSFP_PORT_CONFIG_RESERVE_BIT, - CPLD_QSFP_PORT_CONFIG_LPMODE_BIT, -}; -enum CPLD_SFP_PORT_STATUS_BITS { - CPLD_SFP_PORT_STATUS_PRESENT_BIT, - CPLD_SFP_PORT_STATUS_TXFAULT_BIT, - CPLD_SFP_PORT_STATUS_RXLOS_BIT, -}; -enum CPLD_SFP_PORT_CONFIG_BITS { - CPLD_SFP_PORT_CONFIG_TXDIS_BIT, - CPLD_SFP_PORT_CONFIG_RS_BIT, - CPLD_SFP_PORT_CONFIG_TS_BIT, -}; -enum CPLD_10GMUX_CONFIG_BITS { - CPLD_10GMUX_CONFIG_ENSMB_BIT, - CPLD_10GMUX_CONFIG_ENINPUT_BIT, - CPLD_10GMUX_CONFIG_SEL1_BIT, - CPLD_10GMUX_CONFIG_SEL0_BIT, -}; -enum CPLD_BMC_WATCHDOG_BITS { - CPLD_10GMUX_CONFIG_ENTIMER_BIT, - CPLD_10GMUX_CONFIG_TIMEOUT_BIT, -}; -enum CPLD_RESET_CONTROL_BITS { - CPLD_RESET_CONTROL_SWRST_BIT, - CPLD_RESET_CONTROL_CP2104RST_BIT, - CPLD_RESET_CONTROL_82P33814RST_BIT, - CPLD_RESET_CONTROL_BMCRST_BIT, -}; - -/* bit field structure for register value */ -struct cpld_reg_board_type_t { - u8 build_rev:2; - u8 hw_rev:2; - u8 board_id:4; -}; - -struct cpld_reg_version_t { - u8 revision:6; - u8 release:1; - u8 reserve:1; -}; - -struct cpld_reg_id_t { - u8 id:3; - u8 release:5; -}; - -/* common manipulation */ -#define INVALID(i, min, max) ((i < min) || (i > max) ? 1u : 0u) -#define READ_BIT(val, bit) ((0u == (val & (1<bf_name) -#define READ_BF_1(bf_struct, val, bf_name, bf_value) \ - bf_struct bf; \ - bf.data = val; \ - bf_value = bf.bf_name -#define BOARD_TYPE_BUILD_REV_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, build_rev, res) -#define BOARD_TYPE_HW_REV_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, hw_rev, res) -#define BOARD_TYPE_BOARD_ID_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, board_id, res) -#define CPLD_VERSION_REV_GET(val, res) \ - READ_BF(cpld_reg_version_t, val, revision, res) -#define CPLD_VERSION_REL_GET(val, res) \ - READ_BF(cpld_reg_version_t, val, release, res) -#define CPLD_ID_ID_GET(val, res) \ - READ_BF(cpld_reg_id_t, val, id, res) -#define CPLD_ID_REL_GET(val, res) \ - READ_BF(cpld_reg_id_t, val, release, res) -/* QSFP/SFP registers manipulation */ -#define QSFP_TO_CPLD_IDX(qsfp_port, cpld_index, cpld_port) \ -{ \ - if (QSFP_MIN_PORT_NUM <= qsfp_port && qsfp_port <= CPLD_1_PORT_NUM) { \ - cpld_index = cpld1; \ - cpld_port = qsfp_port - 1; \ - } else if (CPLD_1_PORT_NUM < qsfp_port \ - && qsfp_port <= QSFP_MAX_PORT_NUM) { \ - cpld_index = cpld2 + (qsfp_port - 1 - CPLD_1_PORT_NUM) \ - / CPLD_2_PORT_NUM; \ - cpld_port = (qsfp_port - 1 - CPLD_1_PORT_NUM) % \ - CPLD_2_PORT_NUM; \ - } else { \ - cpld_index = 0; \ - cpld_port = 0; \ - } \ -} -#define SFP_TO_CPLD_IDX(sfp_port, cpld_index) \ - (cpld_index = sfp_port - SFP_MIN_PORT_NUM) -#define QSFP_PORT_STATUS_REG(cpld_port) \ - (CPLD_QSFP_PORT_STATUS_BASE_REG + cpld_port) -#define QSFP_PORT_CONFIG_REG(cpld_port) \ - (CPLD_QSFP_PORT_CONFIG_BASE_REG + cpld_port) -#define QSFP_PORT_INT_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_QSFP_PORT_STATUS_INT_BIT) -#define QSFP_PORT_ABS_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_QSFP_PORT_STATUS_ABS_BIT) -#define QSFP_PORT_RESET_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_LPMODE_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define QSFP_PORT_RESET_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_RESET_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_LPMODE_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define QSFP_PORT_LPMODE_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define SFP_PORT_PRESENT_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_SFP_PORT_STATUS_PRESENT_BIT) - -#define SFP_PORT_TXFAULT_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_SFP_PORT_STATUS_TXFAULT_BIT) -#define SFP_PORT_RXLOS_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_SFP_PORT_STATUS_RXLOS_BIT) -#define SFP_PORT_TXDIS_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_SFP_PORT_CONFIG_TXDIS_BIT) -#define SFP_PORT_RS_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_RS_BIT) -#define SFP_PORT_TS_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TS_BIT) -#define SFP_PORT_TXDIS_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TXDIS_BIT) -#define SFP_PORT_TXDIS_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TXDIS_BIT) -#define SFP_PORT_RS_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_RS_BIT) -#define SFP_PORT_RS_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_RS_BIT) -#define SFP_PORT_TS_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TS_BIT) -#define SFP_PORT_TS_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TS_BIT) - -/* CPLD access functions */ -extern int ingrasys_i2c_cpld_get_qsfp_port_status_val(u8 port_num); -extern int ingrasys_i2c_cpld_get_qsfp_port_config_val(u8 port_num); -extern int ingrasys_i2c_cpld_set_qsfp_port_config_val(u8 port_num, u8 reg_val); -extern int ingrasys_i2c_cpld_get_sfp_port_status_val(u8 port_num); -extern int ingrasys_i2c_cpld_get_sfp_port_config_val(u8 port_num); -extern int ingrasys_i2c_cpld_set_sfp_port_config_val(u8 port_num, u8 reg_val); -extern u8 fp_port_to_phy_port(u8 fp_port); -#endif - diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_platform.h b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_platform.h deleted file mode 100644 index a14853fdae9..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_platform.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef _S9230_64X_PLATFORM_H -#define _S9230_64X_PLATFORM_H - -#include - -// remove debug before release -#define DEBUG - -enum bus_order { - I2C_BUS_MAIN, - MUX_9548_0_CH0, - MUX_9548_0_CH1, - MUX_9548_0_CH2, - MUX_9548_0_CH3, - MUX_9548_0_CH4, - MUX_9548_0_CH5, - MUX_9548_0_CH6, - MUX_9548_0_CH7, - MUX_9548_1_CH0, - MUX_9548_1_CH1, - MUX_9548_1_CH2, - MUX_9548_1_CH3, - MUX_9548_1_CH4, - MUX_9548_1_CH5, - MUX_9548_1_CH6, - MUX_9548_1_CH7, - MUX_9546_0_CH0, - MUX_9546_0_CH1, - MUX_9546_0_CH2, - MUX_9546_0_CH3, - MUX_9546_1_CH0, - MUX_9546_1_CH1, - MUX_9546_1_CH2, - MUX_9546_1_CH3, - MUX_9548_2_CH0, - MUX_9548_2_CH1, - MUX_9548_2_CH2, - MUX_9548_2_CH3, - MUX_9548_2_CH4, - MUX_9548_2_CH5, - MUX_9548_2_CH6, - MUX_9548_2_CH7, - MUX_9548_3_CH0, - MUX_9548_3_CH1, - MUX_9548_3_CH2, - MUX_9548_3_CH3, - MUX_9548_3_CH4, - MUX_9548_3_CH5, - MUX_9548_3_CH6, - MUX_9548_3_CH7, - MUX_9548_4_CH0, - MUX_9548_4_CH1, - MUX_9548_4_CH2, - MUX_9548_4_CH3, - MUX_9548_4_CH4, - MUX_9548_4_CH5, - MUX_9548_4_CH6, - MUX_9548_4_CH7, - MUX_9548_5_CH0, - MUX_9548_5_CH1, - MUX_9548_5_CH2, - MUX_9548_5_CH3, - MUX_9548_5_CH4, - MUX_9548_5_CH5, - MUX_9548_5_CH6, - MUX_9548_5_CH7, - MUX_9548_6_CH0, - MUX_9548_6_CH1, - MUX_9548_6_CH2, - MUX_9548_6_CH3, - MUX_9548_6_CH4, - MUX_9548_6_CH5, - MUX_9548_6_CH6, - MUX_9548_6_CH7, - MUX_9548_7_CH0, - MUX_9548_7_CH1, - MUX_9548_7_CH2, - MUX_9548_7_CH3, - MUX_9548_7_CH4, - MUX_9548_7_CH5, - MUX_9548_7_CH6, - MUX_9548_7_CH7, - MUX_9548_8_CH0, - MUX_9548_8_CH1, - MUX_9548_8_CH2, - MUX_9548_8_CH3, - MUX_9548_8_CH4, - MUX_9548_8_CH5, - MUX_9548_8_CH6, - MUX_9548_8_CH7, - MUX_9548_9_CH0, - MUX_9548_9_CH1, - MUX_9548_9_CH2, - MUX_9548_9_CH3, - MUX_9548_9_CH4, - MUX_9548_9_CH5, - MUX_9548_9_CH6, - MUX_9548_9_CH7, - MUX_9548_10_CH0, - MUX_9548_10_CH1, - MUX_9548_10_CH2, - MUX_9548_10_CH3, - MUX_9548_10_CH4, - MUX_9548_10_CH5, - MUX_9548_10_CH6, - MUX_9548_10_CH7, -}; - -#define I2C_ADDR_MUX_9555_0 (0x20) -#define I2C_ADDR_MUX_9555_1 (0x24) -#define I2C_ADDR_MUX_9555_2 (0x25) -#define I2C_ADDR_MUX_9555_3 (0x26) -#define I2C_ADDR_MUX_9539_0 (0x76) -#define I2C_ADDR_MUX_9539_1 (0x76) -#define I2C_BUS_FAN_STATUS (I2C_BUS_MAIN) -#define I2C_BUS_SYS_LED (MUX_9548_1_CH1) - -#define NUM_OF_I2C_MUX (11) -#define NUM_OF_CPLD (5) -#define NUM_OF_QSFP_PORT (64) -#define NUM_OF_SFP_PORT (2) -#define QSFP_EEPROM_I2C_ADDR (0x50) - -enum gpio_reg { - REG_PORT0_IN, - REG_PORT1_IN, - REG_PORT0_OUT, - REG_PORT1_OUT, - REG_PORT0_POL, - REG_PORT1_POL, - REG_PORT0_DIR, - REG_PORT1_DIR, -}; - -struct ing_i2c_board_info { - int ch; - int size; - struct i2c_board_info *board_info; -}; - -struct i2c_init_data { - __u16 ch; - __u16 addr; - __u8 reg; - __u8 value; -}; - -#endif diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_psu.c b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_psu.c deleted file mode 100644 index 694b57bd748..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_psu.c +++ /dev/null @@ -1,388 +0,0 @@ -/* - * S9230-64x PSU driver - * - * Copyright (C) 2017 Ingrasys, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ingrasys_s9230_64x_platform.h" - -static ssize_t show_psu_eeprom(struct device *dev, - struct device_attribute *da, - char *buf); -static struct s9230_psu_data *s9230_psu_update_status(struct device *dev); -static struct s9230_psu_data *s9230_psu_update_eeprom(struct device *dev); -static int s9230_psu_read_block(struct i2c_client *client, - u8 command, - u8 *data, - int data_len); - - -#define DRIVER_NAME "psu" - -// Addresses scanned -static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; - -/* PSU EEPROM SIZE */ -#define EEPROM_SZ 256 -#define READ_EEPROM 1 -#define NREAD_EEPROM 0 - -static struct i2c_client pca9555_client; - -/* pca9555 gpio pin mapping */ -#define PSU2_PWROK 0 -#define PSU2_PRSNT_L 1 -#define PSU2_PWRON_L 2 -#define PSU1_PWROK 3 -#define PSU1_PRSNT_L 4 -#define PSU1_PWRON_L 5 -#define TMP_75_INT_L 6 - -/* Driver Private Data */ -struct s9230_psu_data { - struct mutex lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 index; /* PSU index */ - s32 status; /* IO expander value */ - char eeprom[EEPROM_SZ]; /* psu eeprom data */ - char psuABS; /* PSU absent */ - char psuPG; /* PSU power good */ -}; - -enum psu_index -{ - s9230_psu1, - s9230_psu2 -}; - -/* - * display power good attribute - */ -static ssize_t -show_psu_pg(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct s9230_psu_data *data = s9230_psu_update_status(dev); - unsigned int value; - - mutex_lock(&data->lock); - value = data->psuPG; - mutex_unlock(&data->lock); - - return sprintf(buf, "%d\n", value); -} - -/* - * display power absent attribute - */ -static ssize_t -show_psu_abs(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct s9230_psu_data *data = s9230_psu_update_status(dev); - unsigned int value; - - mutex_lock(&data->lock); - value = data->psuABS; - mutex_unlock(&data->lock); - - return sprintf(buf, "%d\n", value); -} - - -/* - * sysfs attributes for psu - */ -static DEVICE_ATTR(psu_pg, S_IRUGO, show_psu_pg, NULL); -static DEVICE_ATTR(psu_abs, S_IRUGO, show_psu_abs, NULL); -static DEVICE_ATTR(psu_eeprom, S_IRUGO, show_psu_eeprom, NULL); - -static struct attribute *s9230_psu_attributes[] = { - &dev_attr_psu_pg.attr, - &dev_attr_psu_abs.attr, - &dev_attr_psu_eeprom.attr, - NULL -}; - -/* - * display psu eeprom content - */ -static ssize_t -show_psu_eeprom(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct s9230_psu_data *data = s9230_psu_update_eeprom(dev); - - memcpy(buf, (char *)data->eeprom, EEPROM_SZ); - return EEPROM_SZ; -} - -static const struct attribute_group s9230_psu_group = { - .attrs = s9230_psu_attributes, -}; - -/* - * check gpio expander is accessible - */ -static int -pca9555_detect(struct i2c_client *client) -{ - if (i2c_smbus_read_byte_data(client, REG_PORT0_DIR) < 0) { - return -ENODEV; - } - - return 0; -} - -/* - * client address init - */ -static void -i2c_devices_client_address_init(struct i2c_client *client) -{ - pca9555_client = *client; - pca9555_client.addr = 0x25; -} - -static int -s9230_psu_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct s9230_psu_data *data; - int status, err; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct s9230_psu_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - memset(data, 0, sizeof(struct s9230_psu_data)); - i2c_set_clientdata(client, data); - data->valid = 0; - data->index = dev_id->driver_data; - mutex_init(&data->lock); - - i2c_devices_client_address_init(client); - - err = pca9555_detect(&pca9555_client); - if (err) { - return err; - } - - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &s9230_psu_group); - if (status) { - goto exit_free; - } - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &s9230_psu_group); -exit_free: - kfree(data); -exit: - - return status; -} - -static int -s9230_psu_remove(struct i2c_client *client) -{ - struct s9230_psu_data *data = i2c_get_clientdata(client); - - sysfs_remove_group(&client->dev.kobj, &s9230_psu_group); - kfree(data); - - return 0; -} - - -/* - * psu eeprom read utility - */ -static int -s9230_psu_read_block(struct i2c_client *client, - u8 command, - u8 *data, - int data_len) -{ - int i=0, ret=0; - int blk_max = 32; //max block read size - - /* read eeprom, 32 * 8 = 256 bytes */ - for (i=0; i < EEPROM_SZ/blk_max; i++) { - ret = i2c_smbus_read_i2c_block_data(client, (i*blk_max), blk_max, - data + (i*blk_max)); - if (ret < 0) { - return ret; - } - } - return ret; -} - -/* - * update eeprom content - */ -static struct s9230_psu_data -*s9230_psu_update_eeprom(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct s9230_psu_data *data = i2c_get_clientdata(client); - s32 status = 0; - int psu_pwrok = 0; - int psu_prsnt_l = 0; - - mutex_lock(&data->lock); - - if (time_after(jiffies, data->last_updated + 300 * HZ) - || !data->valid) { - - /* Read psu status */ - - status = i2c_smbus_read_word_data(&(pca9555_client), REG_PORT0_IN); - data->status = status; - - /*read psu status from io expander*/ - - if (data->index == s9230_psu1) { - psu_pwrok = PSU1_PWROK; - psu_prsnt_l = PSU1_PRSNT_L; - } else { - psu_pwrok = PSU2_PWROK; - psu_prsnt_l = PSU2_PRSNT_L; - } - data->psuPG = (status >> psu_pwrok) & 0x1; - data->psuABS = (status >> psu_prsnt_l) & 0x1; - - /* Read eeprom */ - if (!data->psuABS) { - //clear local eeprom data - memset(data->eeprom, 0, EEPROM_SZ); - - //read eeprom - status = s9230_psu_read_block(client, 0, data->eeprom, - ARRAY_SIZE(data->eeprom)); - - if (status < 0) { - memset(data->eeprom, 0, EEPROM_SZ); - dev_err(&client->dev, "Read eeprom failed, status=(%d)\n", status); - } else { - data->valid = 1; - } - } else { - memset(data->eeprom, 0, EEPROM_SZ); - } - data->last_updated = jiffies; - } - - mutex_unlock(&data->lock); - - return data; -} - -/* - * update psu status - */ -static struct s9230_psu_data -*s9230_psu_update_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct s9230_psu_data *data = i2c_get_clientdata(client); - s32 status = 0; - int psu_pwrok = 0; - int psu_prsnt_l = 0; - - mutex_lock(&data->lock); - - /* Read psu status */ - - status = i2c_smbus_read_word_data(&(pca9555_client), REG_PORT0_IN); - data->status = status; - - /*read psu status from io expander*/ - - if (data->index == s9230_psu1) { - psu_pwrok = PSU1_PWROK; - psu_prsnt_l = PSU1_PRSNT_L; - } else { - psu_pwrok = PSU2_PWROK; - psu_prsnt_l = PSU2_PRSNT_L; - } - data->psuPG = (status >> psu_pwrok) & 0x1; - data->psuABS = (status >> psu_prsnt_l) & 0x1; - - mutex_unlock(&data->lock); - - return data; -} - -static const struct i2c_device_id s9230_psu_id[] = { - { "psu1", s9230_psu1 }, - { "psu2", s9230_psu2 }, - {} -}; - -MODULE_DEVICE_TABLE(i2c, s9230_psu_id); - -static struct i2c_driver s9230_psu_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = s9230_psu_probe, - .remove = s9230_psu_remove, - .id_table = s9230_psu_id, - .address_list = normal_i2c, -}; - -static int __init s9230_psu_init(void) -{ - return i2c_add_driver(&s9230_psu_driver); -} - -static void __exit s9230_psu_exit(void) -{ - i2c_del_driver(&s9230_psu_driver); -} - -module_init(s9230_psu_init); -module_exit(s9230_psu_exit); - -MODULE_AUTHOR("Jason Tsai "); -MODULE_DESCRIPTION("S9230-64X psu driver"); -MODULE_LICENSE("GPL"); diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/service/qsfp-monitor.service b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/service/qsfp-monitor.service deleted file mode 100644 index cf4a6a8ad41..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/service/qsfp-monitor.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description= This QSFP Monitor service is to setup QSFP SI. -Requires=s9230-64x-monitor.service -After=s9230-64x-monitor.service - -[Service] -ExecStart=/usr/sbin/qsfp_monitor.sh -KillSignal=SIGKILL -SuccessExitStatus=SIGKILL - -# Resource Limitations -LimitCORE=infinity - -[Install] -WantedBy=multi-user.target diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/service/s9230-64x-monitor.service b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/service/s9230-64x-monitor.service deleted file mode 100644 index 5caf968e659..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/service/s9230-64x-monitor.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description= This Platform Monitor service is to initialize platform and monitor platform. -Before=platform-monitor.service -After=sysinit.target -Wants=fancontrol.service -Wants=qsfp-monitor.service -DefaultDependencies=no - -[Service] -ExecStartPre=/usr/sbin/i2c_utils.sh i2c_init -ExecStart=/usr/sbin/s9230_64x_monitor.sh -KillSignal=SIGKILL -SuccessExitStatus=SIGKILL - -# Resource Limitations -LimitCORE=infinity - -[Install] -WantedBy=multi-user.target diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/i2c_utils.sh b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/i2c_utils.sh deleted file mode 100755 index e899e64a7c3..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/i2c_utils.sh +++ /dev/null @@ -1,1850 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2016 Ingrasys, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# trun on for more debug output -#DEBUG="on" - -VERSION="1.0.0" -TRUE=200 -FALSE=404 - -EXEC_FUNC=${1} -COLOR_LED=${2} -QSFP_PORT=${2} -SFP_PORT=${2} -QSFP_ACTION=${2} -SFP_ACTION=${2} -MB_EEPROM_ACTION=${2} -TARGET_10G_MUX=${2} -ONOFF_LED=${3} -FAN_TRAY=${4} - -############################################################ -# Distributor ID: Debian -# Description: Debian GNU/Linux 8.6 (jessie) -# Release: 8.6 -# Codename: jessie -# Linux debian 3.16.0-4-amd64 #1 -# SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux -############################################################ - -# Color Definition -COLOR_TITLE="\e[1;32m" ### Green ### -COLOR_WARNING="\e[1;33m" ### Yellow ### -COLOR_ERROR="\e[1;31m" ### Red ### -COLOR_END="\e[0m" ### END ### - -NUM_I801_DEVICE=0 - -# PCA9548#0 0x70 -NUM_MUX_9548_0_CH0=$(( ${NUM_I801_DEVICE} + 1 )) # CPLD1 -NUM_MUX_9548_0_CH1=$(( ${NUM_I801_DEVICE} + 2 )) # CPLD2 -NUM_MUX_9548_0_CH2=$(( ${NUM_I801_DEVICE} + 3 )) # CPLD3 -NUM_MUX_9548_0_CH3=$(( ${NUM_I801_DEVICE} + 4 )) # CPLD4 -NUM_MUX_9548_0_CH4=$(( ${NUM_I801_DEVICE} + 5 )) # CPLD5 -NUM_MUX_9548_0_CH5=$(( ${NUM_I801_DEVICE} + 6 )) # LM75_1 LM75_2 -NUM_MUX_9548_0_CH6=$(( ${NUM_I801_DEVICE} + 7 )) # LM75_3 LM75_4 - -# PCA9548#1 0x73 -NUM_MUX_9548_1_CH0=$(( ${NUM_I801_DEVICE} + 9 )) # UCD9090 -NUM_MUX_9548_1_CH1=$(( ${NUM_I801_DEVICE} + 10 )) # PCA9539 0x76 for FP LED & HW ID -NUM_MUX_9548_1_CH2=$(( ${NUM_I801_DEVICE} + 11 )) # PCA9539 0x76 for SYS control -NUM_MUX_9548_1_CH4=$(( ${NUM_I801_DEVICE} + 13 )) # 10G Mux -NUM_MUX_9548_1_CH7=$(( ${NUM_I801_DEVICE} + 16 )) # HWM & TMP75 on BMC - -# PCA9546#0 0X72 -NUM_MUX_9546_0_CH0=$(( ${NUM_I801_DEVICE} + 17 )) # PSU1 0x58 -NUM_MUX_9546_0_CH1=$(( ${NUM_I801_DEVICE} + 18 )) # PSU2 0x58 -NUM_MUX_9546_0_CH2=$(( ${NUM_I801_DEVICE} + 19 )) # PCA9548#2 0x71 -NUM_MUX_9546_0_CH3=$(( ${NUM_I801_DEVICE} + 20 )) # PCA9546#1 0x71 - -# PCA9546#1 0X71 -NUM_MUX_9546_1_CH0=$(( ${NUM_I801_DEVICE} + 21 )) # SFP0 EEPROM 0x50 -NUM_MUX_9546_1_CH1=$(( ${NUM_I801_DEVICE} + 22 )) # SFP1 EEPROM 0x50 - -# PCA9548#2 0X71 -NUM_MUX_9548_2_CH0=$(( ${NUM_I801_DEVICE} + 25 )) # PCA9548#3 0x74 -NUM_MUX_9548_2_CH1=$(( ${NUM_I801_DEVICE} + 26 )) # PCA9548#4 0x74 -NUM_MUX_9548_2_CH2=$(( ${NUM_I801_DEVICE} + 27 )) # PCA9548#5 0x74 -NUM_MUX_9548_2_CH3=$(( ${NUM_I801_DEVICE} + 28 )) # PCA9548#6 0x74 -NUM_MUX_9548_2_CH4=$(( ${NUM_I801_DEVICE} + 29 )) # PCA9548#7 0x74 -NUM_MUX_9548_2_CH5=$(( ${NUM_I801_DEVICE} + 30 )) # PCA9548#8 0x74 -NUM_MUX_9548_2_CH6=$(( ${NUM_I801_DEVICE} + 31 )) # PCA9548#9 0x74 -NUM_MUX_9548_2_CH7=$(( ${NUM_I801_DEVICE} + 32 )) # PCA9548#10 0x74 - -# PCA9548#3~10 0X74 -NUM_MUX_9548_3_CH0=$(( ${NUM_I801_DEVICE} + 33 )) # QSFP 0 EEPROM -NUM_MUX_9548_4_CH0=$(( ${NUM_I801_DEVICE} + 41 )) # QSFP 8 EEPROM -NUM_MUX_9548_5_CH0=$(( ${NUM_I801_DEVICE} + 49 )) # QSFP 16 EEPROM -NUM_MUX_9548_6_CH0=$(( ${NUM_I801_DEVICE} + 57 )) # QSFP 24 EEPROM -NUM_MUX_9548_7_CH0=$(( ${NUM_I801_DEVICE} + 65 )) # QSFP 32 EEPROM -NUM_MUX_9548_8_CH0=$(( ${NUM_I801_DEVICE} + 73 )) # QSFP 40 EEPROM -NUM_MUX_9548_9_CH0=$(( ${NUM_I801_DEVICE} + 81 )) # QSFP 48 EEPROM -NUM_MUX_9548_10_CH0=$(( ${NUM_I801_DEVICE} + 89 )) # QSFP 56 EEPROM - -# MUX Alias -I2C_BUS_MAIN=${NUM_I801_DEVICE} -I2C_BUS_HWM=${NUM_MUX_9548_1_CH7} -I2C_BUS_FAN_STATUS=${I2C_BUS_MAIN} -I2C_BUS_SYS_LED=${NUM_MUX_9548_1_CH1} -I2C_BUS_HW_ID=${NUM_MUX_9548_1_CH1} -I2C_BUS_BMC_HW_ID=${I2C_BUS_MAIN} -I2C_BUS_PSU_STAT=${I2C_BUS_MAIN} -I2C_BUS_FANTRAY_LED=${I2C_BUS_MAIN} -I2C_BUS_MB_EEPROM=${I2C_BUS_MAIN} -I2C_BUS_CB_EEPROM=${I2C_BUS_MAIN} -I2C_BUS_PSU1_EEPROM=${NUM_MUX_9546_0_CH1} -I2C_BUS_PSU2_EEPROM=${NUM_MUX_9546_0_CH0} -I2C_BUS_CPLD1=${NUM_MUX_9548_0_CH0} -I2C_BUS_CPLD2=${NUM_MUX_9548_0_CH1} -I2C_BUS_CPLD3=${NUM_MUX_9548_0_CH2} -I2C_BUS_CPLD4=${NUM_MUX_9548_0_CH3} -I2C_BUS_CPLD5=${NUM_MUX_9548_0_CH4} -I2C_BUS_10GMUX=${NUM_MUX_9548_1_CH4} - -# I2C BUS path -PATH_SYS_I2C_DEVICES="/sys/bus/i2c/devices" -PATH_HWMON_ROOT_DEVICES="/sys/class/hwmon" -# TODO: need to verify HWM deivce path after board ready -PATH_HWMON_W83795_DEVICE="${PATH_HWMON_ROOT_DEVICES}/hwmon7" -PATH_I801_DEVICE="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_I801_DEVICE}" -PATH_MUX_9548_0_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH0}" -PATH_MUX_9548_0_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH1}" -PATH_MUX_9548_0_CH2="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH2}" -PATH_MUX_9548_0_CH3="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH3}" -PATH_MUX_9548_0_CH4="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH4}" -PATH_MUX_9548_0_CH5="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH5}" -PATH_MUX_9548_0_CH6="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH6}" -PATH_MUX_9548_1_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CH0}" -PATH_MUX_9548_1_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CH1}" -PATH_MUX_9548_1_CH2="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CH2}" -PATH_MUX_9548_1_CH7="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CH7}" -PATH_MUX_9546_0_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9546_0_CH0}" -PATH_MUX_9546_0_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9546_0_CH1}" -PATH_MUX_9546_0_CH2="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9546_0_CH2}" -PATH_MUX_9546_0_CH3="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9546_0_CH3}" -PATH_MUX_9546_1_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9546_1_CH0}" -PATH_MUX_9546_1_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9546_1_CH1}" -PATH_MUX_9548_2_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH0}" -PATH_MUX_9548_2_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH1}" -PATH_MUX_9548_2_CH2="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH2}" -PATH_MUX_9548_2_CH3="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH3}" -PATH_MUX_9548_2_CH4="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH4}" -PATH_MUX_9548_2_CH5="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH5}" -PATH_MUX_9548_2_CH6="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH6}" -PATH_MUX_9548_2_CH7="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH7}" -PATH_MUX_9548_3_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_3_CH0}" -PATH_MUX_9548_4_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_4_CH0}" -PATH_MUX_9548_5_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_5_CH0}" -PATH_MUX_9548_6_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_6_CH0}" -PATH_MUX_9548_7_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_7_CH0}" -PATH_MUX_9548_8_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_8_CH0}" -PATH_MUX_9548_9_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_9_CH0}" -PATH_MUX_9548_10_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_10_CH0}" -PATH_CPLD1_DEVICE="${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CPLD1}" -PATH_CPLD2_DEVICE="${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CPLD2}" -PATH_CPLD3_DEVICE="${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CPLD3}" -PATH_CPLD4_DEVICE="${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CPLD4}" -PATH_CPLD5_DEVICE="${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CPLD5}" -PATH_10GMUX=${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_10GMUX} - - -# I2C Address -### I2C MUX -I2C_ADDR_MUX_9548_0=0x70 -I2C_ADDR_MUX_9548_1=0x73 -I2C_ADDR_MUX_9546_0=0x72 -I2C_ADDR_MUX_9546_1=0x71 -I2C_ADDR_MUX_9548_2=0x71 -I2C_ADDR_MUX_9548_3=0x74 -I2C_ADDR_MUX_9548_4=0x74 -I2C_ADDR_MUX_9548_5=0x74 -I2C_ADDR_MUX_9548_6=0x74 -I2C_ADDR_MUX_9548_7=0x74 -I2C_ADDR_MUX_9548_8=0x74 -I2C_ADDR_MUX_9548_9=0x74 -I2C_ADDR_MUX_9548_10=0x74 - -### GPIO Expander -I2C_ADDR_MUX_9539_0=0x76 # LED & HW ID -I2C_ADDR_MUX_9539_1=0x76 # SYS config -I2C_ADDR_MUX_9539_2=0x77 # on CPU board, STATUS and ERR from CPLD -I2C_ADDR_MUX_9555_0=0x20 # on FAN board, fan status and led config -I2C_ADDR_MUX_9555_1=0x24 # on BMC board, INT and HW ID -I2C_ADDR_MUX_9555_2=0x25 # on BMC board, PSU status -I2C_ADDR_MUX_9555_3=0x26 # on BMC board, RST and SEL -I2C_ADDR_MUX_9555_3=0x26 # on BMC board, RST and SEL - - -### peripheral -I2C_ADDR_MB_EEPROM=0x55 # on main board -I2C_ADDR_CB_EEPROM=0x51 # on cpu board -I2C_ADDR_UCD9090=0x34 -I2C_ADDR_W83795=0x2F -I2C_ADDR_PSU1_EEPROM=0x50 -I2C_ADDR_PSU2_EEPROM=0x50 -I2C_ADDR_LM75_1=0x4D # Rear Panel -I2C_ADDR_LM75_2=0x4E # Rear MAC -I2C_ADDR_LM75_3=0x4D # Front Panel -I2C_ADDR_LM75_4=0x4E # Front MAC -I2C_ADDR_TMP75_CB=0x4F # on cpu board -I2C_ADDR_TMP75_BB=0x4A # on bmc board -I2C_ADDR_QSFP_EEPROM=0x50 -I2C_ADDR_SFP_EEPROM=0x50 -I2C_ADDR_CPLD=0x33 -I2C_ADDR_10GMUX=0x67 - -#sysfs -PATH_SYSFS_PSU1="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_PSU1_EEPROM}-$(printf "%04x" $I2C_ADDR_PSU1_EEPROM)" -PATH_SYSFS_PSU2="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_PSU2_EEPROM}-$(printf "%04x" $I2C_ADDR_PSU2_EEPROM)" - -#ACTIVE LOW enable flag -ACTIVE_LOW_EN=1 -ACTIVE_HIGH_EN=0 -#GPIO Direction In/Out -DIR_IN=in -DIR_OUT=out - -#Power Supply Status -PSU_DC_ON=1 -PSU_DC_OFF=0 -PSU_EXIST=1 -PSU_NOT_EXIST=0 - -# IO expander register -# direction -REG_PORT0_DIR=6 -REG_PORT1_DIR=7 -# polarity -REG_PORT0_POL=4 -REG_PORT1_POL=5 -# output -REG_PORT0_OUT=2 -REG_PORT1_OUT=3 -# input -REG_PORT0_IN=0 -REG_PORT1_IN=1 - -# qsfp port number range -MIN_QSFP_PORT_NUM=1 -MAX_QSFP_PORT_NUM=64 - -# sfp+ port number range -MIN_SFP_PORT_NUM=1 -MAX_SFP_PORT_NUM=2 - -# CPLD access -# port status -CPLD_QSFP_STATUS_KEY=cpld_qsfp_port_status -CPLD_SFP_STATUS_KEY=cpld_sfp_port_status -# bit define -CPLD_QSFP_STATUS_ABS_BIT=1 -CPLD_SFP_STATUS_PRES_BIT=0 - -# Help usage function -function _help { - echo "=========================================================" - echo "# Description: Help Function" - echo "=========================================================" - echo "----------------------------------------------------" - echo "EX : ${0} help" - echo " : ${0} i2c_init" - echo " : ${0} i2c_deinit" - echo " : ${0} i2c_fan_speed_init" - echo " : ${0} i2c_io_exp_init" - echo " : ${0} i2c_led_test" - echo " : ${0} i2c_psu_eeprom_get" - echo " : ${0} i2c_mb_eeprom_get" - echo " : ${0} i2c_cb_eeprom_get" - #echo " : ${0} i2c_eeprom_sync" - echo " : ${0} i2c_qsfp_eeprom_get [${MIN_QSFP_PORT_NUM}-${MAX_QSFP_PORT_NUM}]" - echo " : ${0} i2c_sfp_eeprom_get [${MIN_SFP_PORT_NUM}-${MAX_SFP_PORT_NUM}]" - echo " : ${0} i2c_qsfp_eeprom_init new|delete" - echo " : ${0} i2c_sfp_eeprom_init new|delete" - echo " : ${0} i2c_mb_eeprom_init new|delete" - echo " : ${0} i2c_cb_eeprom_init new|delete" - echo " : ${0} i2c_qsfp_status_get [${MIN_QSFP_PORT_NUM}-${MAX_QSFP_PORT_NUM}]" - echo " : ${0} i2c_sfp_status_get [${MIN_SFP_PORT_NUM}-${MAX_SFP_PORT_NUM}]" - echo " : ${0} i2c_qsfp_type_get [${MIN_QSFP_PORT_NUM}-${MAX_QSFP_PORT_NUM}]" - echo " : ${0} i2c_sfp_type_get [${MIN_SFP_PORT_NUM}-${MAX_SFP_PORT_NUM}]" - echo " : ${0} i2c_board_type_get" - echo " : ${0} i2c_bmc_board_type_get" - echo " : ${0} i2c_cpld_version" - echo " : ${0} i2c_psu_status" - echo " : ${0} i2c_led_psu_status_set" - echo " : ${0} i2c_led_fan_status_set" - echo " : ${0} i2c_led_fan_tray_status_set" - echo " : ${0} i2c_test_all" - echo " : ${0} i2c_sys_led green|amber" - echo " : ${0} i2c_fan_led green|amber|off" - echo " : ${0} i2c_psu1_led green|amber|off" - echo " : ${0} i2c_psu2_led green|amber|off" - echo " : ${0} i2c_fan_tray_led green|amber on|off [1-4]" - echo " : ${0} i2c_10g_mux cpu|fp" - echo "----------------------------------------------------" -} - -#Pause function -function _pause { - read -p "$*" -} - -#Retry command function -function _retry { - local i - for i in {1..5}; - do - eval "${*}" && break || echo "retry"; sleep 1; - done -} - -#logical(front panel) to physical (falcon core) port mapping -function _port_logic2phy { - - local logic_port=$1 - local phy_port=0 - - if (( $logic_port >=1 && $logic_port <= 32 )) ; then - phy_port=$(( (logic_port-1)/2*4 + (logic_port-1)%2 + 1)) - elif (( $logic_port >=33 && $logic_port <= 64 )) ; then - phy_port=$(( (((logic_port-1)%32))/2*4 + (logic_port-1)%2 + 3)) - fi - - echo $phy_port -} - -#I2C Init -function _i2c_init { - echo "=========================================================" - echo "# Description: I2C Init" - echo "=========================================================" - - #rmmod i2c_ismt - _util_rmmod i2c_i801 - modprobe i2c_i801 - modprobe i2c_dev - modprobe i2c_mux_pca954x force_deselect_on_exit=1 - - # add MUX PCA9548#0 on I801, assume to be i2c-1~8 - if [ ! -e ${PATH_MUX_9548_0_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_0}' > ${PATH_I801_DEVICE}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_0} already init." - fi - - # add MUX PCA9548#1 on I801, assume to be i2c-9~16 - if [ ! -e ${PATH_MUX_9548_1_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_1}' > ${PATH_I801_DEVICE}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_1} already init." - fi - - # add MUX PCA9546#0 on I801, assume to be i2c-17~20 - if [ ! -e ${PATH_MUX_9546_0_CH0} ]; then - _retry "echo 'pca9546 ${I2C_ADDR_MUX_9546_0}' > ${PATH_I801_DEVICE}/new_device" - else - echo "pca9546 ${I2C_ADDR_MUX_9546_0} already init." - fi - - # add MUX PCA9546#1 on PCA9546#0 CH3, assume to be i2c-21~24 - if [ ! -e ${PATH_MUX_9546_1_CH0} ]; then - _retry "echo 'pca9546 ${I2C_ADDR_MUX_9546_1}' > ${PATH_MUX_9546_0_CH3}/new_device" - else - echo "pca9546 ${I2C_ADDR_MUX_9546_1} already init." - fi - - # add MUX PCA9548#2 on PCA9546#0 CH2, assume to be i2c-25~32 - if [ ! -e ${PATH_MUX_9548_2_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_2}' > ${PATH_MUX_9546_0_CH2}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_2} already init." - fi - - # add MUX PCA9548#3 on PCA9548#2 CH0, assume to be i2c-33~40 - if [ ! -e ${PATH_MUX_9548_3_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_3}' > ${PATH_MUX_9548_2_CH0}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_3} already init." - fi - - # add MUX PCA9548#4 on PCA9548#2 CH1, assume to be i2c-41~48 - if [ ! -e ${PATH_MUX_9548_4_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_4}' > ${PATH_MUX_9548_2_CH1}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_4} already init." - fi - - # add MUX PCA9548#5 on PCA9548#2 CH2, assume to be i2c-49~56 - if [ ! -e ${PATH_MUX_9548_5_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_5}' > ${PATH_MUX_9548_2_CH2}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_5} already init." - fi - - # add MUX PCA9548#6 on PCA9548#2 CH3, assume to be i2c-57~64 - if [ ! -e ${PATH_MUX_9548_6_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_6}' > ${PATH_MUX_9548_2_CH3}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_6} already init." - fi - - # add MUX PCA9548#7 on PCA9548#2 CH4, assume to be i2c-65~72 - if [ ! -e ${PATH_MUX_9548_7_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_7}' > ${PATH_MUX_9548_2_CH4}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_7} already init." - fi - - # add MUX PCA9548#8 on PCA9548#2 CH5, assume to be i2c-73~80 - if [ ! -e ${PATH_MUX_9548_8_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_8}' > ${PATH_MUX_9548_2_CH5}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_8} already init." - fi - - # add MUX PCA9548#9 on PCA9548#2 CH6, assume to be i2c-81~88 - if [ ! -e ${PATH_MUX_9548_9_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_9}' > ${PATH_MUX_9548_2_CH6}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_9} already init." - fi - - # add MUX PCA9548#10 on PCA9548#2 CH7, assume to be i2c-89~96 - if [ ! -e ${PATH_MUX_9548_10_CH0} ]; then - _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_10}' > ${PATH_MUX_9548_2_CH7}/new_device" - else - echo "pca9548 ${I2C_ADDR_MUX_9548_10} already init." - fi - - _i2c_hwm_init - _util_rmmod eeprom - modprobe eeprom_mb - modprobe gpio-pca953x - _i2c_io_exp_init - _i2c_sensors_init - _i2c_cpld_init - _i2c_psu_init - - _i2c_qsfp_eeprom_init "new" - _i2c_sfp_eeprom_init "new" - _i2c_mb_eeprom_init "new" - _i2c_cb_eeprom_init "new" - _i2c_fan_speed_init - _i2c_led_psu_status_set - _i2c_led_fan_status_set - - # trun on sys led - echo "led_sys setup..." - COLOR_LED="green" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_sys_led - - _config_rmem -} - -#I2C Deinit -function _i2c_deinit { - echo "i2c deinit..." - for mod in coretemp jc42 w83795 eeprom eeprom_mb gpio-pca953x i2c_mux_pca954x i2c_i801 ingrasys_s9230_64x_psu; - do - _util_rmmod $mod - done - echo "Done" -} - -function _i2c_cpld_init { - echo "CPLD init..." - _util_rmmod ingrasys_s9230_64x_i2c_cpld - modprobe ingrasys_s9230_64x_i2c_cpld - - # add cpld 1~5 to sysfs - for i in {1..5}; - do - local cpld_bus="I2C_BUS_CPLD${i}" - local cpld_path="PATH_CPLD${i}_DEVICE" - dev_path="${PATH_SYS_I2C_DEVICES}/${!cpld_bus}-$(printf "%04x" ${I2C_ADDR_CPLD})" - if ! [ -L ${dev_path} ]; then - echo "ingrasys_cpld${i} ${I2C_ADDR_CPLD}" > ${!cpld_path}/new_device - else - echo "${dev_path} already exist" - fi - done - - echo "Done" -} - -function _i2c_sensors_init { - echo "SENSORS init..." - local dev_path - # to make sure hwmon index in sysfs as expected, - # need to remove kernel module and then probe them in expected order - # remove all sensors kernel module - _util_rmmod coretemp - _util_rmmod jc42 - _util_rmmod w83795 - # probe coretemp kernel module - modprobe coretemp - # probe hwmon kernel module - modprobe w83795 - # add lm75 to sysfs - ####Main board thermal - ####lm75_1 - dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_0_CH5}-$(printf "%04x" ${I2C_ADDR_LM75_1})" - if ! [ -L ${dev_path} ]; then - echo "lm75 ${I2C_ADDR_LM75_1}" > ${PATH_MUX_9548_0_CH5}/new_device # hwmon1 - else - echo "${dev_path} already exist" - fi - ####lm75_2 - dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_0_CH5}-$(printf "%04x" ${I2C_ADDR_LM75_2})" - if ! [ -L ${dev_path} ]; then - echo "lm75 ${I2C_ADDR_LM75_2}" > ${PATH_MUX_9548_0_CH5}/new_device #hwmon2 - else - echo "${dev_path} already exist" - fi - ####lm75_3 - dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_0_CH6}-$(printf "%04x" ${I2C_ADDR_LM75_3})" - if ! [ -L ${dev_path} ]; then - echo "lm75 ${I2C_ADDR_LM75_1}" > ${PATH_MUX_9548_0_CH6}/new_device # hwmon3 - else - echo "${dev_path} already exist" - fi - ####lm75_4 - dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_0_CH6}-$(printf "%04x" ${I2C_ADDR_LM75_4})" - if ! [ -L ${dev_path} ]; then - echo "lm75 ${I2C_ADDR_LM75_4}" > ${PATH_MUX_9548_0_CH6}/new_device #hwmon4 - else - echo "${dev_path} already exist" - fi - ####BMC board thermal - dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_1_CH7}-$(printf "%04x" ${I2C_ADDR_TMP75_BB})" - if ! [ -L ${dev_path} ]; then - echo "tmp75 ${I2C_ADDR_TMP75_BB}" > ${PATH_MUX_9548_1_CH7}/new_device #hwmon5 - else - echo "${dev_path} already exist" - fi - ####CPU board thermal - dev_path="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MAIN}-$(printf "%04x" ${I2C_ADDR_TMP75_CB})" - if ! [ -L ${dev_path} ]; then - echo "tmp75 ${I2C_ADDR_TMP75_CB}" > ${PATH_I801_DEVICE}/new_device #hwmon6 - else - echo "${dev_path} already exist" - fi - # add w83795 to sysfs - dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_1_CH7}-$(printf "%04x" ${I2C_ADDR_W83795})" - if ! [ -L ${dev_path} ]; then - echo "w83795adg ${I2C_ADDR_W83795}" > ${PATH_MUX_9548_1_CH7}/new_device #hwmon7 - else - echo "${dev_path} already exist" - fi - - # probe jc42 kernel module - modprobe jc42 - - echo "Done" -} - -#FAN Speed Init -function _i2c_fan_speed_init { - echo -n "FAN SPEED INIT..." - if [ -e "${PATH_HWMON_W83795_DEVICE}" ]; then - # init fan speed - echo 120 > ${PATH_HWMON_W83795_DEVICE}/device/pwm2 - echo "SUCCESS" - else - echo "FAIL" - fi -} - -# HWM init -function _i2c_hwm_init { - echo "HWM INIT..." - # select bank0 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x80 - # SW reset, Disable monitor - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x01 0x9C - # disable TR5/TR6 DTS - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x04 0x0 - # enable FANIN1~8 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x06 0xFF - # disable FANIN9~14 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x07 0x00 - # CLKIN clock frequency set as 48Mhz - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x01 0x1C - # select bank 2 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x82 - # set PWM mode in FOMC - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x0F 0x00 - # set 25KHz fan output frequency in F1OPFP&F2OPFP - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x18 0x84 - _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x19 0x84 -} - -#IO Expander Init -function _i2c_io_exp_init { - echo "=========================================================" - echo "# Description: I2C IO Expender Init" - echo "=========================================================" - - # need to init BMC io expander first due to some io expander are reset default - echo "Init BMC INT & HW ID IO Expander" - # all input - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_1} ${REG_PORT0_DIR} 0xFF - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_1} ${REG_PORT1_DIR} 0xFF - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_1} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_1} ${REG_PORT1_POL} 0x00 - - echo "Init BMC PSU status IO Expander" - # PWRON default 0 (ACTIVE_LOW) - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_2} ${REG_PORT0_OUT} 0x00 - # default 0 (ACTIVE_LOW) - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_2} ${REG_PORT1_OUT} 0x00 - # I/O 0.2 0.5 output(PWRON), rest input - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_2} ${REG_PORT0_DIR} 0xDB - # I/O 1.0~1.1 input, 1.2~1.4 output (1.5~1.7 not enable) - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_2} ${REG_PORT1_DIR} 0xE3 - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_2} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_2} ${REG_PORT1_POL} 0x00 - - echo "Init BMC RST and SEL IO Expander" - # RST default is 1 (ACTIVE_LOW) - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_3} ${REG_PORT0_OUT} 0x3F - # SEL default is 0 (HOST), EN default is 1 (ACTIVE_HIGH) - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_3} ${REG_PORT1_OUT} 0x1F - # I/O 0.0~0.5 output, 0.6~0.7 not use - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_3} ${REG_PORT0_DIR} 0xC0 - # all output - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_3} ${REG_PORT1_DIR} 0x00 - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_3} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_3} ${REG_PORT1_POL} 0x00 - - echo "Init System LED & HW ID IO Expander" - # I/O_0.x for System LED default 0, I/O_1.x for HW ID - _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT0_OUT} 0x00 - # System LED => all output - _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT0_DIR} 0x00 - # HW ID => all input - _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT1_DIR} 0xFF - _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT1_POL} 0x00 - - echo "Init FAN Board Status IO Expander" - # LED_G_H set to 1, LED_Y_G set to 0 (ACTIVE_HIGH) - _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9555_0} ${REG_PORT0_OUT} 0x11 - _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9555_0} ${REG_PORT1_OUT} 0x11 - # DIR/ABS is input, LED_Y/LED_G is output - _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9555_0} ${REG_PORT0_DIR} 0xCC - _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9555_0} ${REG_PORT1_DIR} 0xCC - _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9555_0} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9555_0} ${REG_PORT1_POL} 0x00 - - echo "Init System SEL and RST IO Expander" - # RST 0.0~0.3 default 1 (ACTIVE low), rest default 0 - # SEL set to value 0 (host) - # LED_CLR set to 0 will clear all switch LED bitmap, set to 1 here - _util_i2cset -y -r ${NUM_MUX_9548_1_CH2} ${I2C_ADDR_MUX_9539_1} ${REG_PORT0_OUT} 0x0F - # RST 1.6~1.7 default 1 (ACTIVE low), INT 1.0~1.4 default 1 (ACTIVE low) - _util_i2cset -y -r ${NUM_MUX_9548_1_CH2} ${I2C_ADDR_MUX_9539_1} ${REG_PORT1_OUT} 0xDF - # all output, but MAC_RST_L 0.0 need to set as input to prevent reboot issue - _util_i2cset -y -r ${NUM_MUX_9548_1_CH2} ${I2C_ADDR_MUX_9539_1} ${REG_PORT0_DIR} 0x09 - # RST 1.5 !~ 1.7 output, rest are input - _util_i2cset -y -r ${NUM_MUX_9548_1_CH2} ${I2C_ADDR_MUX_9539_1} ${REG_PORT1_DIR} 0x1F - _util_i2cset -y -r ${NUM_MUX_9548_1_CH2} ${I2C_ADDR_MUX_9539_1} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${NUM_MUX_9548_1_CH2} ${I2C_ADDR_MUX_9539_1} ${REG_PORT1_POL} 0x00 - - echo "Init CPU CPLD IO Expander" - # all input - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT0_DIR} 0xFF - # all input - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT1_DIR} 0xFF - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT0_POL} 0x00 - _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT1_POL} 0x00 -} - -#Set FAN Tray LED -function _i2c_led_fan_tray_status_set { - echo "FAN Tray Status Setup" - #FAN Status get - FAN1_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan1_alarm` - FAN2_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan3_alarm` - FAN3_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan5_alarm` - FAN4_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan7_alarm` - - # check if io expander for fan tray exist - result=`i2cget -y ${I2C_BUS_FANTRAY_LED} ${I2C_ADDR_MUX_9555_0} ${REG_PORT0_IN} 2>/dev/null` - err_code=$? - if [ "$err_code" != "0" ]; then - echo "fan tray not exist!" - return - fi - - for FAN_TRAY in {1..4}; - do - FAN_ALARM="FAN${FAN_TRAY}_ALARM" - if [ "${!FAN_ALARM}" == "0" ]; then - COLOR_LED="green" - ONOFF_LED="on" - _i2c_fan_tray_led - - COLOR_LED="amber" - ONOFF_LED="off" - _i2c_fan_tray_led - - echo "set [FAN TRAY ${FAN_TRAY}] [Green]=on [Amber]=off" - else - COLOR_LED="green" - ONOFF_LED="off" - _i2c_fan_tray_led - - COLOR_LED="amber" - ONOFF_LED="on" - _i2c_fan_tray_led - - echo "set [FAN TRAY ${FAN_TRAY}] [Green]=off [Amber]=on" - fi - done -} - -#Set FAN LED -function _i2c_led_fan_status_set { - echo "FAN Status Setup" - #PSU Status set - FAN1_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan1_alarm` - FAN3_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan3_alarm` - FAN5_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan5_alarm` - FAN7_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan7_alarm` - - echo "led_fan setup..." - # all fan ok - if [ "${FAN1_ALARM}" == "0" ] \ - && [ "${FAN3_ALARM}" == "0" ] \ - && [ "${FAN5_ALARM}" == "0" ] \ - && [ "${FAN7_ALARM}" == "0" ]; then - COLOR_LED="green" - echo "${COLOR_LED}" - _i2c_fan_led - # all fan fail - elif [ "${FAN1_ALARM}" == "1" ] \ - && [ "${FAN3_ALARM}" == "1" ] \ - && [ "${FAN5_ALARM}" == "1" ] \ - && [ "${FAN7_ALARM}" == "1" ] ; then - COLOR_LED="amber" - echo "${COLOR_LED}" - _i2c_fan_led - # partial fan fail - else - COLOR_LED="amber" - echo "${COLOR_LED}" - _i2c_fan_led - fi -} - -#Set Power Supply LED -function _i2c_led_psu_status_set { - echo "PSU LED Status Setup" - - #PSU Status set - _i2c_psu_status - - #PSU1 Status - echo "led_psu1 setup..." - if [ "${psu1Exist}" == ${PSU_EXIST} ]; then - if [ "${psu1PwGood}" == ${PSU_DC_ON} ]; then - COLOR_LED="green" - echo "${COLOR_LED}" - _i2c_psu1_led - else - COLOR_LED="amber" - echo "${COLOR_LED}" - _i2c_psu1_led - fi - else - COLOR_LED="off" - echo "${COLOR_LED}" - _i2c_psu1_led - fi - - #PSU2 Status - echo "led_psu2 setup..." - if [ "${psu2Exist}" == ${PSU_EXIST} ]; then - if [ "${psu2PwGood}" == ${PSU_DC_ON} ]; then - COLOR_LED="green" - echo "${COLOR_LED}" - _i2c_psu2_led - else - COLOR_LED="amber" - echo "${COLOR_LED}" - _i2c_psu2_led - fi - else - COLOR_LED="off" - echo "${COLOR_LED}" - _i2c_psu2_led - fi -} - -#LED Test -function _i2c_led_test { - echo "=========================================================" - echo "# Description: I2C SYSTEM LED TEST..." - echo "=========================================================" - local output_reg=${REG_PORT0_OUT} - local mask=0xFF - local value=0xFF - - #sys led (green) - # set sys_led_g (0.7) = 1 - mask=0x80 - value=0x80 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check SYS LED green light and Press [Enter] key to continue...' - #sys led (amber) - # set sys_led_g (0.7) = 0 - mask=0x80 - value=0x00 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check SYS LED amber light and Press [Enter] key to continue...' - - #FAN led (green) - # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 0 - mask=0x60 - value=0x60 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check FAN LED green light and Press [Enter] key to continue...' - #FAN led (amber) - # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 1 - mask=0x60 - value=0x40 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check FAN LED amber light and Press [Enter] key to continue...' - - #PSU1 led (green) - # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 0 - mask=0x18 - value=0x18 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check PSU1 LED green light and Press [Enter] key to continue...' - #PSU1 led (amber) - # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 1 - mask=0x18 - value=0x10 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check PSU1 LED amber light and Press [Enter] key to continue...' - - #PSU2 led (green) - # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 0 - mask=0x06 - value=0x06 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check PSU2 LED green light and Press [Enter] key to continue...' - #PSU2 led (amber) - # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 1 - mask=0x06 - value=0x04 - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check PSU2 LED amber light and Press [Enter] key to continue...' - - #Turn OFF All LED (can't trun off system led) - # set set fan_led_en (0.6), psu1_pwr_ok_oe (0.4), psu0_pwr_ok_oe (0.2) = 0 - mask=0xFF - value=$((2#00000011)) - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - _pause 'Check turn off all LEDs (exclude SYS LED) and Press [Enter] key to continue...' - - # restore sys led - COLOR_LED="green" - ONOFF_LED="on" - echo "${COLOR_LED} ${ONOFF_LED}" - _i2c_sys_led -} - -#Set QSFP Port cpld variable -function _qsfp_cpld_var_set { - local port=$1 - local reg_port_base - local reg_port_shift - if [[ $1 -le 12 && $1 -ge 1 ]]; then - cpld_index=1 - reg_port_base=0 - elif [[ $1 -le 25 && $1 -ge 13 ]]; then - cpld_index=2 - reg_port_base=12 - elif [[ $1 -le 38 && $1 -ge 26 ]]; then - cpld_index=3 - reg_port_base=25 - elif [[ $1 -le 51 && $1 -ge 39 ]]; then - cpld_index=4 - reg_port_base=38 - elif [[ $1 -le 64 && $1 -ge 52 ]]; then - cpld_index=5 - reg_port_base=51 - else - echo "invalid port number" - fi - - cpld_port_index=$(( $port - $reg_port_base )) -} - -#Set QSFP Port eeporm variable -function _qsfp_eeprom_var_set { - local port=$1 - local eeprombusbase - local eeprombusshift - # port 1 => zqsfp0 - # port 2 => zqsfp1 - # ... - local port_group=$(( ($port - 1) / 8 )) - - case ${port_group} in - 0) - eeprombusbase=${NUM_MUX_9548_3_CH0} - ;; - 1) - eeprombusbase=${NUM_MUX_9548_4_CH0} - ;; - 2) - eeprombusbase=${NUM_MUX_9548_5_CH0} - ;; - 3) - eeprombusbase=${NUM_MUX_9548_6_CH0} - ;; - 4) - eeprombusbase=${NUM_MUX_9548_7_CH0} - ;; - 5) - eeprombusbase=${NUM_MUX_9548_8_CH0} - ;; - 6) - eeprombusbase=${NUM_MUX_9548_9_CH0} - ;; - 7) - eeprombusbase=${NUM_MUX_9548_10_CH0} - ;; - *) - ;; - esac - - eeprombusshift=$(( (${port} - 1) % 8)) - eepromBus=$(( ${eeprombusbase} + ${eeprombusshift} )) - eepromAddr=${I2C_ADDR_QSFP_EEPROM} -} - - -#Set SFP Port cpld variable -function _sfp_cpld_var_set { - local port=$1 - case ${port} in - 1) - cpld_index=1 - ;; - 2) - cpld_index=2 - ;; - *) - ;; - esac -} - -#Set QSFP Port eeporm variable -function _sfp_eeprom_var_set { - local port=$1 - - case ${port} in - 1) - eepromBus=${NUM_MUX_9546_1_CH0} - ;; - 2) - eepromBus=${NUM_MUX_9546_1_CH1} - ;; - *) - ;; - esac - - eepromAddr=${I2C_ADDR_SFP_EEPROM} -} - -#Get QSFP EEPROM Information -function _i2c_qsfp_eeprom_get { - local phy_port=0 - - #get physical port - phy_port=$(_port_logic2phy $QSFP_PORT) - - # input parameter validation - _util_input_check "${QSFP_PORT}" "${MIN_QSFP_PORT_NUM}" "${MAX_QSFP_PORT_NUM}" - - _qsfp_eeprom_var_set ${phy_port} - - _util_get_qsfp_abs - - if [ $status = 0 ]; then - exit - fi - - - cat ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr)/eeprom | hexdump -C -} - -#Init QSFP EEPROM -function _i2c_qsfp_eeprom_init { - echo "QSFP EEPROM INIT..." - - #Action check - action=$1 - if [ -z "${action}" ]; then - echo "No action, skip" - return - elif [ "${action}" != "new" ] && [ "${action}" != "delete" ]; then - echo "Error action, skip" - return - fi - - #Init 1-64 ports EEPROM - local i - for i in {1..64}; - do - _qsfp_eeprom_var_set ${i} - - if [ "${action}" == "new" ] && \ - ! [ -L ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr) ]; then - echo "sff8436 $eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/new_device - elif [ "${action}" == "delete" ] && \ - [ -L ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr) ]; then - echo "$eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/delete_device - fi - done - echo "Done" -} - -#Get SFP EEPROM Information -function _i2c_sfp_eeprom_get { - - # input parameter validation - _util_input_check "${SFP_PORT}" "${MIN_SFP_PORT_NUM}" "${MAX_SFP_PORT_NUM}" - _util_get_sfp_pres - - if [ $status = 0 ]; then - exit - fi - - _sfp_eeprom_var_set ${SFP_PORT} - - cat ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr)/eeprom | hexdump -C -} - -#Init SFP EEPROM -function _i2c_sfp_eeprom_init { - echo "SFP EEPROM INIT..." - - #Action check - action=$1 - if [ -z "${action}" ]; then - echo "No action, skip" - return - elif [ "${action}" != "new" ] && [ "${action}" != "delete" ]; then - echo "Error action, skip" - return - fi - - #Init 1-2 sfp+ EEPROM - local i - for i in {1..2}; - do - _sfp_eeprom_var_set ${i} - - if [ "${action}" == "new" ] && \ - ! [ -L ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr) ]; then - echo "sff8436 $eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/new_device - elif [ "${action}" == "delete" ] && \ - [ -L ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr) ]; then - echo "$eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/delete_device - fi - done - echo "Done" -} - -#Init Main Board EEPROM -function _i2c_mb_eeprom_init { - echo -n "Main Board EEPROM INIT..." - - #Action check - action=$1 - if [ -z "${action}" ]; then - echo "No action, skip" - return - elif [ "${action}" != "new" ] && [ "${action}" != "delete" ]; then - echo "Error action, skip" - return - fi - - #Init mb EEPROM - if [ "${action}" == "new" ] && \ - ! [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM) ]; then - echo "mb_eeprom ${I2C_ADDR_MB_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_MB_EEPROM}/new_device - elif [ "${action}" == "delete" ] && \ - [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM) ]; then - echo "$I2C_ADDR_MB_EEPROM" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_MB_EEPROM}/delete_device - fi - echo "Done" -} - -#Init CPU Board EEPROM -function _i2c_cb_eeprom_init { - echo -n "CPU Board EEPROM INIT..." - - #Action check - action=$1 - if [ -z "${action}" ]; then - echo "No action, skip" - return - elif [ "${action}" != "new" ] && [ "${action}" != "delete" ]; then - echo "Error action, skip" - return - fi - - #Init cpu EEPROM - if [ "${action}" == "new" ] && \ - ! [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM) ]; then - echo "mb_eeprom ${I2C_ADDR_CB_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CB_EEPROM}/new_device - elif [ "${action}" == "delete" ] && \ - [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM) ]; then - echo "$I2C_ADDR_CB_EEPROM" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CB_EEPROM}/delete_device - fi - echo "Done" -} - -#Init PSU Kernel Module -function _i2c_psu_init { - echo "=========================================================" - echo "# Description: I2C PSU Init" - echo "=========================================================" - modprobe ingrasys_s9230_64x_psu - - echo "psu1 ${I2C_ADDR_PSU1_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_PSU1_EEPROM}/new_device - echo "psu2 ${I2C_ADDR_PSU2_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_PSU2_EEPROM}/new_device -} - -#Deinit PSU Kernel Module -function _i2c_psu_deinit { - echo "${I2C_ADDR_PSU1_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_PSU1_EEPROM}/delete_device - echo "${I2C_ADDR_PSU2_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_PSU2_EEPROM}/delete_device - _util_rmmod ingrasys_s9230_64x_psu -} - -#get QSFP Status -function _i2c_qsfp_status_get { - - # input parameter validation - _util_input_check "${QSFP_PORT}" "${MIN_QSFP_PORT_NUM}" "${MAX_QSFP_PORT_NUM}" - - local stat - _util_get_qsfp_abs - echo "status=$status" -} - -#get QSFP Type -function _i2c_qsfp_type_get { - local phy_port=0 - - phy_port=$(_port_logic2phy ${QSFP_PORT}) - - # input parameter validation - _util_input_check "${QSFP_PORT}" "${MIN_QSFP_PORT_NUM}" "${MAX_QSFP_PORT_NUM}" - - #_qsfp_eeprom_var_set ${QSFP_PORT} - _qsfp_eeprom_var_set ${phy_port} - - #Get QSFP EEPROM info - qsfp_info=$(base64 ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr)/eeprom) - - identifier=$(echo $qsfp_info | base64 -d -i | hexdump -s 128 -n 1 -e '"%x"') - connector=$(echo $qsfp_info | base64 -d -i | hexdump -s 130 -n 1 -e '"%x"') - transceiver=$(echo $qsfp_info | base64 -d -i | hexdump -s 131 -n 1 -e '"%x"') - - echo "identifier=$identifier" - echo "connector=$connector" - echo "transceiver=$transceiver" -} - -function _i2c_sfp_status_get { - - # input parameter validation - _util_input_check "${SFP_PORT}" "${MIN_SFP_PORT_NUM}" "${MAX_SFP_PORT_NUM}" - - local stat - _util_get_sfp_pres - #status: 0 -> Down, 1 -> Up - if [ $status = 0 ]; then - stat="down" - else - stat="up" - fi - echo "status is $stat" -} - -#get SFP Type -function _i2c_sfp_type_get { - - # input parameter validation - _util_input_check "${SFP_PORT}" "${MIN_SFP_PORT_NUM}" "${MAX_SFP_PORT_NUM}" - - _sfp_eeprom_var_set ${SFP_PORT} - - #Get QSFP EEPROM info - sfp_info=$(base64 ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr)/eeprom) - - identifier=$(echo $sfp_info | base64 -d -i | hexdump -s 128 -n 1 -e '"%x"') - connector=$(echo $sfp_info | base64 -d -i | hexdump -s 130 -n 1 -e '"%x"') - transceiver=$(echo $sfp_info | base64 -d -i | hexdump -s 131 -n 1 -e '"%x"') - - echo "identifier=$identifier" - echo "connector=$connector" - echo "transceiver=$transceiver" -} - -#Get PSU EEPROM Information -function _i2c_psu_eeprom_get { - local eeprom_psu1="" - local eeprom_psu2="" - - echo "=========================================================" - echo "# Description: I2C PSU EEPROM Get..." - echo "=========================================================" - - eeprom_psu1="${PATH_SYSFS_PSU1}/psu_eeprom" - cat ${eeprom_psu1} | hexdump -C - - eeprom_psu2="${PATH_SYSFS_PSU2}/psu_eeprom" - cat ${eeprom_psu2} | hexdump -C -} - -#Get Main Board EEPROM Information -function _i2c_mb_eeprom_get { - echo "=========================================================" - echo "# Description: I2C MB EEPROM Get..." - echo "=========================================================" - _i2c_sys_eeprom_get mb -} - -#Get CPU Board EEPROM Information -function _i2c_cb_eeprom_get { - echo "=========================================================" - echo "# Description: I2C CB EEPROM Get..." - echo "=========================================================" - _i2c_sys_eeprom_get cb -} - -#Get system EEPROM Information -##input: "cb" for cpu board, "mb" for main board -function _i2c_sys_eeprom_get { - local eeprom_dev - - if [ "$1" == "cb" ]; then - eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM)/eeprom" - elif [ "$1" == "mb" ]; then - eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM)/eeprom" - else - echo "wrong eeprom type" - return - fi - - # check if eeprom device exist in sysfs - if [ ! -f ${eeprom_dev} ]; then - echo "eeprom device not init" - return - fi - - cat ${eeprom_dev} | hexdump -C - echo "Done" -} - -#sync eeprom content between mb and cb eeprom -function _i2c_eeprom_sync { - echo "=========================================================" - echo "# Description: EEPROM sync..." - echo "=========================================================" - - local mb_eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM)/eeprom" - local cb_eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM)/eeprom" - - # check if eeprom device exist in sysfs - if [[ ! -f ${mb_eeprom_dev} || ! -f ${cb_eeprom_dev} ]]; then - echo "eeprom device not init" - return - fi - - ## check if MB eeprom is empty - if [ ! -z "$(cat ${mb_eeprom_dev} | hexdump -n2 | grep ffff)" ]; then - echo "copy cb eeprom to mb eeprom..." - cat ${cb_eeprom_dev} > ${mb_eeprom_dev} - else - echo "no need to sync" - fi - - echo "Done" -} - -#Set System Status LED -function _i2c_sys_led { - # only green/amber, on/off can't control - if [ "${COLOR_LED}" == "green" ]; then - # set sys_led_g (0.7) = 1 - output_reg=${REG_PORT0_OUT} - mask=0x80 - value=0x80 - elif [ "${COLOR_LED}" == "amber" ]; then - # set sys_led_g (0.7) = 0 - output_reg=${REG_PORT0_OUT} - mask=0x80 - value=0x00 - else - echo "Invalid Parameters, Exit!!!" - _help - exit ${FALSE} - fi - - #apply to io expander - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - echo "Done" -} - -#Set FAN LED -function _i2c_fan_led { - if [ "${COLOR_LED}" == "green" ]; then - # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 0 - output_reg=${REG_PORT0_OUT} - mask=0x60 - value=0x60 - elif [ "${COLOR_LED}" == "amber" ]; then - # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 1 - output_reg=${REG_PORT0_OUT} - mask=0x60 - value=0x40 - elif [ "${COLOR_LED}" == "off" ]; then - # set fan_led_en (0.6) = 0 & fan_led_y (0.5) = 0 - output_reg=${REG_PORT0_OUT} - mask=0x60 - value=0x00 - else - echo "Invalid Parameters, Exit!!!" - _help - exit ${FALSE} - fi - - #apply to io expander - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - echo "Done" -} - -#Set PSU1 LED -function _i2c_psu1_led { - if [ "${COLOR_LED}" == "green" ]; then - # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 0 - output_reg=${REG_PORT0_OUT} - mask=0x18 - value=0x18 - elif [ "${COLOR_LED}" == "amber" ]; then - # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 1 - output_reg=${REG_PORT0_OUT} - mask=0x18 - value=0x10 - elif [ "${COLOR_LED}" == "off" ]; then - # set psu1_pwr_ok_oe (0.4) = 0 & psu1_led_y (0.3) = 0 - output_reg=${REG_PORT0_OUT} - mask=0x18 - value=0x00 - else - echo "Invalid Parameters, Exit!!!" - _help - exit ${FALSE} - fi - - #apply to io expander - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - echo "Done" -} - -#Set PSU2 LED -function _i2c_psu2_led { - if [ "${COLOR_LED}" == "green" ]; then - # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 0 - output_reg=${REG_PORT0_OUT} - mask=0x06 - value=0x06 - elif [ "${COLOR_LED}" == "amber" ]; then - # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 1 - output_reg=${REG_PORT0_OUT} - mask=0x06 - value=0x04 - elif [ "${COLOR_LED}" == "off" ]; then - # set psu0_pwr_ok_oe (0.2) = 0 & psu0_led_y (0.1) = 0 - output_reg=${REG_PORT0_OUT} - mask=0x06 - value=0x00 - else - echo "Invalid Parameters, Exit!!!" - _help - exit ${FALSE} - fi - - #apply to io expander - _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value} - echo "Done" -} - -#Set FAN Tray LED -function _i2c_fan_tray_led { - - i2cAddr=${I2C_ADDR_MUX_9555_0} - output_reg=${REG_PORT0_OUT} - - case ${FAN_TRAY} in - 1) - output_reg=${REG_PORT0_OUT} - if [ "${COLOR_LED}" == "green" ]; then - mask=0x01 - elif [ "${COLOR_LED}" == "amber" ]; then - mask=0x02 - fi - ;; - 2) - output_reg=${REG_PORT0_OUT} - if [ "${COLOR_LED}" == "green" ]; then - mask=0x10 - elif [ "${COLOR_LED}" == "amber" ]; then - mask=0x20 - fi - ;; - 3) - output_reg=${REG_PORT1_OUT} - if [ "${COLOR_LED}" == "green" ]; then - mask=0x01 - elif [ "${COLOR_LED}" == "amber" ]; then - mask=0x02 - fi - ;; - 4) - output_reg=${REG_PORT1_OUT} - if [ "${COLOR_LED}" == "green" ]; then - mask=0x10 - elif [ "${COLOR_LED}" == "amber" ]; then - mask=0x20 - fi - ;; - *) - echo "Please input 1~4" - exit - ;; - esac - - # LED PIN value is ACTIVE HIGH - if [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "on" ]; then - _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0xff - elif [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "off" ]; then - _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0x00 - elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "on" ]; then - _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0xff - elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "off" ]; then - _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0x00 - else - echo "Invalid Parameters, Exit!!!" - _help - exit ${FALSE} - fi - - echo "Done" -} - -#Get Board Version and Type -function _i2c_board_type_get { - # read input port 1 value from io expander - input_reg=${REG_PORT1_IN} - boardType=`i2cget -y ${I2C_BUS_HW_ID} ${I2C_ADDR_MUX_9539_0} ${input_reg}` - boardBuildRev=$((($boardType) & 0x03)) - boardHwRev=$((($boardType) >> 2 & 0x03)) - boardId=$((($boardType) >> 4)) - printf "MAIN_BOARD BOARD_ID is 0x%02x, HW Rev 0x%02x, Build Rev 0x%02x\n" $boardId $boardHwRev $boardBuildRev -} - -#Get BMC Board Version and Type -function _i2c_bmc_board_type_get { - # read input port 1 value from io expander - input_reg=${REG_PORT1_IN} - boardType=`i2cget -y ${I2C_BUS_BMC_HW_ID} ${I2C_ADDR_MUX_9555_1} ${input_reg}` - boardBuildRev=$((($boardType) & 0x03)) - boardHwRev=$((($boardType) >> 2 & 0x03)) - boardId=$((($boardType) >> 4)) - printf "BMC_BOARD BOARD_ID is 0x%02x, HW Rev 0x%02x, Build Rev 0x%02x\n" $boardId $boardHwRev $boardBuildRev -} - -#Get CPLD Version -function _i2c_cpld_version { - echo "=========================================================" - echo "# Description: CPLD Version" - echo "=========================================================" - - for i in {1..5}; - do - local cpld_bus="I2C_BUS_CPLD${i}" - local cpld_path="PATH_CPLD${i}_DEVICE" - local file_path="${PATH_SYS_I2C_DEVICES}/${!cpld_bus}-$(printf "%04x" ${I2C_ADDR_CPLD})/cpld_version" - printf "[CPLD %d] %s\n" ${i} $(cat ${file_path}) - done -} - -#Get PSU Status -function _i2c_psu_status { - local psu_abs="" - - psu1PwGood=`cat ${PATH_SYSFS_PSU1}/psu_pg` - psu_abs=`cat ${PATH_SYSFS_PSU1}/psu_abs` - if [ "$psu_abs" == "0" ]; then - psu1Exist=1 - else - psu1Exist=0 - fi - - psu2PwGood=`cat ${PATH_SYSFS_PSU2}/psu_pg` - psu_abs=`cat ${PATH_SYSFS_PSU2}/psu_abs` - if [ "$psu_abs" == "0" ]; then - psu2Exist=1 - else - psu2Exist=0 - fi - - printf "PSU1 Exist:%x PSU1 PW Good:%d\n" $psu1Exist $psu1PwGood - printf "PSU2 Exist:%d PSU2 PW Good:%d\n" $psu2Exist $psu2PwGood -} - -#Get register value from CPLD -function _i2c_cpld_reg_read { - local idx=$1 - local file_name=$2 - local cpld_i2c_addr=${I2C_ADDR_CPLD} - local reg_file_path - - case ${idx} in - 1) - cpld_i2c_bus=${I2C_BUS_CPLD1} - ;; - 2) - cpld_i2c_bus=${I2C_BUS_CPLD2} - ;; - 3) - cpld_i2c_bus=${I2C_BUS_CPLD3} - ;; - 4) - cpld_i2c_bus=${I2C_BUS_CPLD4} - ;; - 5) - cpld_i2c_bus=${I2C_BUS_CPLD5} - ;; - *) - echo "invalid cpld index" - exit - ;; - esac - - reg_file_path="${PATH_SYS_I2C_DEVICES}/${cpld_i2c_bus}-$(printf "%04x" ${cpld_i2c_addr})/${file_name}" - cpld_reg_val=`cat ${reg_file_path}` -} - -#util functions -function _util_i2cset { - if [ "$DEBUG" == "on" ]; then - i2cset $@ - else - i2cset $@ 1>/dev/null - fi -} - -function _i2c_set { - local i2c_bus=$1 - local i2c_addr=$2 - local reg=$3 - local mask=$4 - local value=$5 - - echo `i2cset -m $mask -y -r ${i2c_bus} ${i2c_addr} ${reg} ${value}` -} - -function _util_rmmod { - local mod=$1 - [ "$(lsmod | grep "^$mod ")" != "" ] && rmmod $mod -} - -# get qsfp presence -function _util_get_qsfp_abs { - local phy_port=0 - - #get physical port - phy_port=$(_port_logic2phy $QSFP_PORT) - - # read status from cpld - #_qsfp_cpld_var_set ${QSFP_PORT} - _qsfp_cpld_var_set ${phy_port} - cpld_reg_file_name="${CPLD_QSFP_STATUS_KEY}_${cpld_port_index}" - _i2c_cpld_reg_read ${cpld_index} ${cpld_reg_file_name} - #status: 0 -> Down, 1 -> Up (ACTIVE_LOW in ABS_BIT) - status=$(( $(( $((${cpld_reg_val})) & (1 << ($CPLD_QSFP_STATUS_ABS_BIT)) ))?0:1 )) -} - -# get sfp presence -function _util_get_sfp_pres { - - # read status from cpld - _sfp_cpld_var_set ${SFP_PORT} - cpld_reg_file_name="${CPLD_SFP_STATUS_KEY}" - _i2c_cpld_reg_read ${cpld_index} ${cpld_reg_file_name} - #status: 0 -> Down, 1 -> Up (ACTIVE_LOW in PRES_BIT) - status=$(( $(( $((${cpld_reg_val})) & (1 << ($CPLD_SFP_STATUS_PRES_BIT)) ))?0:1 )) -} - -# valid input number -function _util_input_check { - # input parameter validation - if [[ $1 -lt $2 || $1 -gt $3 ]]; then - echo "Please input number $2~$3" - exit - fi -} - -# clear all switch port led bitmap -function _util_port_led_clear { - echo "port led clear..." - # gpio pin on GPIO MUX PCA9539#1 I/O 0.2 - # pull low to reset bitamp - output_reg=${REG_PORT0_OUT} - mask=0x04 - value=0x00 - _util_i2cset -m ${mask} -y ${NUM_MUX_9548_1_CH2} ${I2C_ADDR_MUX_9539_1} ${output_reg} ${value} - echo "Done" -} - -#Increase read socket buffer for CoPP Test -function _config_rmem { - echo "109430400" > /proc/sys/net/core/rmem_max -} - -#Set 10G Mux to CPU or Front Panel -function _i2c_10g_mux { - - echo "=========================================================" - echo "# Description: 10G Mux" - echo "=========================================================" - - local target=${TARGET_10G_MUX} - local i2c_bus=${I2C_BUS_10GMUX} - local i2c_addr=${I2C_ADDR_10GMUX} - local reg=0 - local mask=0xff - local value=0 - local file_10g_mux="${PATH_CPLD1_DEVICE}/${I2C_BUS_CPLD1}-$(printf "%04x" ${I2C_ADDR_CPLD})/cpld_10gmux_config" - - #get current 10g mux register value on CPLD - value=`cat ${file_10g_mux}` - - if [ "${target}" == "cpu" ]; then - #Set XE0: slave address access - _i2c_set $i2c_bus $i2c_addr 0x06 $mask 0x18 - #Set XE0: CH4 D_IN0-S_OUTA0 EQ - _i2c_set $i2c_bus $i2c_addr 0x2c $mask 0x00 - #Set XE0: CH5 NC-S_OUTB0 DEM - _i2c_set $i2c_bus $i2c_addr 0x35 $mask 0x80 - #Set XE0: CH5 NC-S_OUTB0 VOD - _i2c_set $i2c_bus $i2c_addr 0x34 $mask 0xab - #Set XE0: CH1 D_OUT0-S_INB0 EQ - _i2c_set $i2c_bus $i2c_addr 0x16 $mask 0x01 - #Set XE0: CH1 D_OUT0-S_INB0 DEM - _i2c_set $i2c_bus $i2c_addr 0x18 0x1f 0x80 - #Set XE0: CH1 D_OUT0-S_INB0 VOD - _i2c_set $i2c_bus $i2c_addr 0x17 $mask 0xab - #Set XE1: CH6 D_IN1-S_OUTA1 EQ - _i2c_set $i2c_bus $i2c_addr 0x3a $mask 0x00 - #Set XE1: CH7 NC-S_OUTB1 EQ - _i2c_set $i2c_bus $i2c_addr 0x41 $mask 0x00 - #Set XE1: CH7 NC-S_OUTB1 DEM - _i2c_set $i2c_bus $i2c_addr 0x43 $mask 0x80 - #Set XE1: CH7 NC-S_OUTB1 VOD - _i2c_set $i2c_bus $i2c_addr 0x42 $mask 0xab - #Set XE1: CH3 D_OUT1-S_INB1 EQ - _i2c_set $i2c_bus $i2c_addr 0x24 $mask 0x01 - #Set XE1: CH3 D_OUT1-S_INB1 DEM - _i2c_set $i2c_bus $i2c_addr 0x26 $mask 0x80 - #Set XE1: CH3 D_OUT1-S_INB1 VOD - _i2c_set $i2c_bus $i2c_addr 0x25 $mask 0xab - #Enable auto negotiation of XE ports - eval "npx_diag 'phy set mdio portlist=129,130 devad=0x7 addr=0x11 data=0x80'" - eval "npx_diag 'phy set mdio portlist=129,130 devad=0x7 addr=0x10 data=0x01'" - eval "npx_diag 'phy set mdio portlist=129,130 devad=0x7 addr=0x0 data=0x3200'" - eval "npx_diag 'phy set mdio portlist=129,130 devad=0x1 addr=0x96 data=0x2'" - #delay 1 sec - sleep 1 - - #switch 10G MUX to cpu on CPLD - value=$(( value & 0xf3 )) - echo "$(printf 0x"%x" ${value})" > ${file_10g_mux} - - echo "Switch 10G Mux to [CPU]" - - elif [ "${COLOR_LED}" == "fp" ]; then - #Set XE0: slave address access - _i2c_set $i2c_bus $i2c_addr 0x06 $mask 0x18 - #Set XE0: CH4 D_IN0-S_OUTA0 EQ - _i2c_set $i2c_bus $i2c_addr 0x2c $mask 0x00 - #Set XE0: CH4 D_IN0-S_OUTA0 DEM - _i2c_set $i2c_bus $i2c_addr 0x2e $mask 0x80 - #Set XE0: CH4 D_IN0-S_OUTA0 VOD - _i2c_set $i2c_bus $i2c_addr 0x2d $mask 0xab - #Set XE0: CH0 NC-S_INA0 EQ - _i2c_set $i2c_bus $i2c_addr 0x0f $mask 0x00 - #Set XE0: CH1 D_OUT0-S_INB0 DEM - _i2c_set $i2c_bus $i2c_addr 0x18 0x18 0x80 - #Set XE0: CH1 D_OUT0-S_INB0 VOD - _i2c_set $i2c_bus $i2c_addr 0x17 $mask 0xab - #Set XE1: CH6 D_IN1-S_OUTA1 EQ - _i2c_set $i2c_bus $i2c_addr 0x3a $mask 0x00 - #Set XE1: CH6 D_IN1-S_OUTA1 DEM - _i2c_set $i2c_bus $i2c_addr 0x3c $mask 0x80 - #Set XE1: CH6 D_IN1-S_OUTA1 VOD - _i2c_set $i2c_bus $i2c_addr 0x3b $mask 0xab - #Set XE1: CH2 NC-S_INA1 EQ - _i2c_set $i2c_bus $i2c_addr 0x1d $mask 0x00 - #Set XE1: CH3 D_OUT1-S_INB1 DEM - _i2c_set $i2c_bus $i2c_addr 0x26 $mask 0x80 - #Set XE1: CH3 D_OUT1-S_INB1 VOD - _i2c_set $i2c_bus $i2c_addr 0x25 $mask 0xab - #Enable auto negotiation of XE ports - eval "npx_diag 'phy set mdio portlist=129,130 devad=0x7 addr=0x11 data=0x0'" - eval "npx_diag 'phy set mdio portlist=129,130 devad=0x7 addr=0x10 data=0x0'" - eval "npx_diag 'phy set mdio portlist=129,130 devad=0x7 addr=0x0 data=0x2200'" - eval "npx_diag 'phy set mdio portlist=129,130 devad=0x1 addr=0x96 data=0x2200'" - #delay 1 sec - sleep 1 - - #switch 10G MUX to front panel on CPLD - value=$(( value | 0x0c )) - echo "$(printf 0x"%x" ${value})" > ${file_10g_mux} - - echo "Switch 10G Mux to [Front Panel]" - else - echo "invalid target, please set target to cpu/fp" - fi -} - -#Main Function -function _main { - tart_time_str=`date` - start_time_sec=$(date +%s) - - if [ "${EXEC_FUNC}" == "help" ]; then - _help - elif [ "${EXEC_FUNC}" == "i2c_init" ]; then - _i2c_init - elif [ "${EXEC_FUNC}" == "i2c_deinit" ]; then - _i2c_deinit - elif [ "${EXEC_FUNC}" == "i2c_fan_speed_init" ]; then - _i2c_fan_speed_init - elif [ "${EXEC_FUNC}" == "i2c_io_exp_init" ]; then - _i2c_io_exp_init - elif [ "${EXEC_FUNC}" == "i2c_led_test" ]; then - _i2c_led_test - elif [ "${EXEC_FUNC}" == "i2c_mb_eeprom_get" ]; then - _i2c_mb_eeprom_get - elif [ "${EXEC_FUNC}" == "i2c_cb_eeprom_get" ]; then - _i2c_cb_eeprom_get - elif [ "${EXEC_FUNC}" == "i2c_eeprom_sync" ]; then - _i2c_eeprom_sync - elif [ "${EXEC_FUNC}" == "i2c_psu_eeprom_get" ]; then - _i2c_psu_eeprom_get - elif [ "${EXEC_FUNC}" == "i2c_qsfp_eeprom_get" ]; then - _i2c_qsfp_eeprom_get - elif [ "${EXEC_FUNC}" == "i2c_sfp_eeprom_get" ]; then - _i2c_sfp_eeprom_get - elif [ "${EXEC_FUNC}" == "i2c_qsfp_eeprom_init" ]; then - _i2c_qsfp_eeprom_init ${QSFP_ACTION} - elif [ "${EXEC_FUNC}" == "i2c_sfp_eeprom_init" ]; then - _i2c_sfp_eeprom_init ${SFP_ACTION} - elif [ "${EXEC_FUNC}" == "i2c_mb_eeprom_init" ]; then - _i2c_mb_eeprom_init ${MB_EEPROM_ACTION} - elif [ "${EXEC_FUNC}" == "i2c_cb_eeprom_init" ]; then - _i2c_cb_eeprom_init ${MB_EEPROM_ACTION} - elif [ "${EXEC_FUNC}" == "i2c_qsfp_status_get" ]; then - _i2c_qsfp_status_get - elif [ "${EXEC_FUNC}" == "i2c_sfp_status_get" ]; then - _i2c_sfp_status_get - elif [ "${EXEC_FUNC}" == "i2c_qsfp_type_get" ]; then - _i2c_qsfp_type_get - elif [ "${EXEC_FUNC}" == "i2c_sfp_type_get" ]; then - _i2c_sfp_type_get - elif [ "${EXEC_FUNC}" == "i2c_led_psu_status_set" ]; then - _i2c_led_psu_status_set - elif [ "${EXEC_FUNC}" == "i2c_led_fan_status_set" ]; then - _i2c_led_fan_status_set - elif [ "${EXEC_FUNC}" == "i2c_led_fan_tray_status_set" ]; then - _i2c_led_fan_tray_status_set - elif [ "${EXEC_FUNC}" == "i2c_sys_led" ]; then - _i2c_sys_led - elif [ "${EXEC_FUNC}" == "i2c_fan_led" ]; then - _i2c_fan_led - elif [ "${EXEC_FUNC}" == "i2c_fan_tray_led" ]; then - _i2c_fan_tray_led - elif [ "${EXEC_FUNC}" == "i2c_psu1_led" ]; then - _i2c_psu1_led - elif [ "${EXEC_FUNC}" == "i2c_psu2_led" ]; then - _i2c_psu2_led - elif [ "${EXEC_FUNC}" == "i2c_board_type_get" ]; then - _i2c_board_type_get - elif [ "${EXEC_FUNC}" == "i2c_bmc_board_type_get" ]; then - _i2c_bmc_board_type_get - elif [ "${EXEC_FUNC}" == "i2c_cpld_version" ]; then - _i2c_cpld_version - elif [ "${EXEC_FUNC}" == "i2c_psu_status" ]; then - _i2c_psu_status - elif [ "${EXEC_FUNC}" == "i2c_test_all" ]; then - _i2c_init - _i2c_led_test - _i2c_psu_eeprom_get - _i2c_mb_eeprom_get - _i2c_cb_eeprom_get - _i2c_board_type_get - _i2c_bmc_board_type_get - _i2c_cpld_version - _i2c_psu_status - elif [ "${EXEC_FUNC}" == "i2c_10g_mux" ]; then - _i2c_10g_mux - else - echo "Invalid Parameters, Exit!!!" - _help - exit ${FALSE} - fi - - if [ "$DEBUG" == "on" ]; then - echo "-----------------------------------------------------" - end_time_str=`date` - end_time_sec=$(date +%s) - diff_time=$[ ${end_time_sec} - ${start_time_sec} ] - echo "Start Time: ${start_time_str} (${start_time_sec})" - echo "End Time : ${end_time_str} (${end_time_sec})" - echo "Total Execution Time: ${diff_time} sec" - - echo "done!!!" - fi -} - -_main diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/qsfp_monitor.sh b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/qsfp_monitor.sh deleted file mode 100755 index 9213d115f65..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/qsfp_monitor.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash -# Copyright (C) 2017 Ingrasys, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -INTERVAL=3 -I2C_UTILS="/usr/sbin/i2c_utils.sh" -QSFP_SI_SCRIPT="/usr/sbin/qsfp_si_cfg.sh" -QSFP_ARRAY=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \ - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) - -#QSFP SI monitor -function _qsfp_si_monitor { - local i - local status - for i in {0..63}; - do - status=`${I2C_UTILS} i2c_qsfp_status_get $(expr $i + 1) | egrep '^status=.*$' | sed -e 's/status=//g'` - if [ "${status}" == "1" ]; then - _qsfp_type_check $i - fi - done -} - -#QSFP type -function _qsfp_type_check { - local port=$1 - local qsfp_type=`${I2C_UTILS} i2c_qsfp_type_get $(expr $port + 1)` - local identifier=`echo "$qsfp_type" | grep '^identifier=.*$' | sed -e 's/identifier=//g'` - if [ "${identifier}" == "11" ]; then - connector=`echo "$qsfp_type" | grep '^connector=.*$' | sed -e 's/connector=//g'` - case ${connector} in - 21|23) - #DAC - if [ "${QSFP_ARRAY[$port]}" != "${connector}" ]; then - echo "Change Port $(expr $port + 1) to DAC" - QSFP_ARRAY[$port]=${connector} - ${QSFP_SI_SCRIPT} dac $port >/dev/null - fi - ;; - *) - #Optical - if [ "${QSFP_ARRAY[$port]}" != "${connector}" ]; then - echo "Change Port $(expr $port + 1) to Optical" - QSFP_ARRAY[$port]=${connector} - ${QSFP_SI_SCRIPT} optical $port >/dev/null - fi - ;; - esac - fi -} - -#Docker exist check -function _docker_swss_check { - while true - do - # Check if syncd starts - result=`sonic-db-cli ASIC_DB HLEN HIDDEN` - if [ "$result" == "3" ]; then - return - fi - sleep $INTERVAL - done -} - -#Docker exist check -function _qsfp_si_cfg_script_check { - - if [ -f ${QSFP_SI_SCRIPT} ] && [ -x ${QSFP_SI_SCRIPT} ]; then - echo "SI Script exists. Start monitor." - return - else - echo "SI Script not exist. Exit monitor." - exit - fi -} - -# main function -function _main { - #Check SI Script - _qsfp_si_cfg_script_check - #Check docker swss is running - _docker_swss_check - while true - do - _qsfp_si_monitor - # Sleep while still handling signals - sleep $INTERVAL & - wait $! - done -} - -_main - diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/s9230_64x_monitor.sh b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/s9230_64x_monitor.sh deleted file mode 100755 index 8bfb2232800..00000000000 --- a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/s9230_64x_monitor.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# Copyright (C) 2016 Ingrasys, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -INTERVAL=5 -I2C_UTILS="/usr/sbin/i2c_utils.sh" - - -# LED status monitor -function _led_monitor { - ${I2C_UTILS} i2c_led_fan_status_set >/dev/null - ${I2C_UTILS} i2c_led_psu_status_set >/dev/null - ${I2C_UTILS} i2c_led_fan_tray_status_set >/dev/null -} - -# main function -function _main { - while true - do - _led_monitor - # Sleep while still handling signals - sleep $INTERVAL & - wait $! - done -} - -_main diff --git a/platform/nephos/sonic-platform-modules-pegatron/LICENSE b/platform/nephos/sonic-platform-modules-pegatron/LICENSE deleted file mode 100644 index a23cc2b232c..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/LICENSE +++ /dev/null @@ -1,16 +0,0 @@ -Copyright (C) 2016 Microsoft, Inc -Copyright (C) 2018 Pegatron Corporation. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/platform/nephos/sonic-platform-modules-pegatron/README.md b/platform/nephos/sonic-platform-modules-pegatron/README.md deleted file mode 100644 index 32444b4b891..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/README.md +++ /dev/null @@ -1 +0,0 @@ -platform drivers of Pegatron products for the SONiC project diff --git a/platform/nephos/sonic-platform-modules-pegatron/common/modules/pegatron_hwmon_mcu.c b/platform/nephos/sonic-platform-modules-pegatron/common/modules/pegatron_hwmon_mcu.c deleted file mode 100644 index 76cbd884470..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/common/modules/pegatron_hwmon_mcu.c +++ /dev/null @@ -1,1374 +0,0 @@ -/* - * A MCU driver connect to hwmon - * - * Copyright (C) 2018 Pegatron Corporation. - * Peter5_Lin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#undef pega_DEBUG -/*#define pega_DEBUG*/ -#ifdef pega_DEBUG -#define DBG(x) x -#else -#define DBG(x) -#endif /* DEBUG */ - -#define FW_UPGRADE_COMMAND 0xA5 -#define FAN_DISABLE_COMMAND 0x20 -#define FAN_ENABLE_COMMAND 0x21 -#define FAN_LED_SETTO_MANUAL_COMMAND 0x30 -#define FAN_LED_SETTO_AUTO_COMMAND 0x31 -#define FAN_LED_GREENON_COMMAND 0x40 -#define FAN_LED_GREENOFF_COMMAND 0x41 -#define FAN_LED_AMBERON_COMMAND 0x50 -#define FAN_LED_AMBEROFF_COMMAND 0x51 -#define SMART_FAN_ENABLE_BIT 0 -#define SMART_FAN_SETTING_ENABLE_BIT 0 -#define SA56004X_REMOTE_TEMP_ALERT_BIT 4 -#define I2C_FANBOARD_TIMEOUT_BIT 0 -#define ALERT_MODE_BIT 0 -#define GET_BIT(data, bit, value) value = (data >> bit) & 0x1 -#define SET_BIT(data, bit) data |= (1 << bit) -#define CLEAR_BIT(data, bit) data &= ~(1 << bit) - -enum chips -{ - mercedes3 = 0, - cadillac, - porsche, -}; - -enum fan_alert -{ - FAN_OUTER_RPM_OVER_ALERT_BIT = 0, - FAN_OUTER_RPM_UNDER_ALERT_BIT, - FAN_INNER_RPM_OVER_ALERT_BIT, - FAN_INNER_RPM_UNDER_ALERT_BIT, - FAN_CONNECT_ALERT_BIT, - FAN_DISCONNECT_ALERT_BIT, -}; - -enum fan_status -{ - FAN_ALERT_BIT = 2, - FAN_LED_AMBER_BIT, - FAN_LED_GREEN_BIT, - FAN_LED_AUTO_BIT, - FAN_ENABLE_BIT, - FAN_PRESENT_BIT, -}; - -enum hwmon_mcu_register -{ - MB_FW_UG_REG = 0, - FB_FW_UG_REG, - MB_HW_VER_REG, - FB_HW_SKUVER_REG, - MB_FW_VER_REG, - FB_FW_VER_REG, - - FAN_PWM_REG = 16, - - SF_ENABLE_REG, - SF_SETTING_ENABLE_REG, - SF_DEVICE_REG, - SF_UPDATE_REG, - SF_TEMP_MAX_REG, - SF_TEMP_MID_REG, - SF_TEMP_MIN_REG, - SF_PWM_MAX_REG, - SF_PWM_MID_REG, - SF_PWM_MIN_REG, - - FAN1_INNER_RPM_REG = 32, - FAN2_INNER_RPM_REG, - FAN3_INNER_RPM_REG, - FAN4_INNER_RPM_REG, - FAN5_INNER_RPM_REG, - - FAN1_OUTER_RPM_REG = 48, - FAN2_OUTER_RPM_REG, - FAN3_OUTER_RPM_REG, - FAN4_OUTER_RPM_REG, - FAN5_OUTER_RPM_REG, - - FAN1_STATUS_REG = 64, - FAN2_STATUS_REG, - FAN3_STATUS_REG, - FAN4_STATUS_REG, - FAN5_STATUS_REG, - - ADC_UNDER_VOL_ALERT_REG = 80, - ADC_OVER_VOL_ALERT_REG, - TS_OVER_TEMP_ALERT_REG, - - FAN1_ALERT_REG, - FAN2_ALERT_REG, - FAN3_ALERT_REG, - FAN4_ALERT_REG, - FAN5_ALERT_REG, - - I2C_BUS_ALERT_REG, - ALERT_MODE_REG, - - MONITOR_ADC_VOLTAGE_REG = 96, - - LM_0X49_TEMP_REG = 112, - LM_0X48_TEMP_REG, - SA56004X_LOCAL_TEMP_REG, - SA56004X_REMOTE_TEMP_REG, - -}; - -static struct mutex pega_hwmon_mcu_lock; - -static int pega_hwmon_mcu_read(struct i2c_client *client, u8 reg) -{ - int data = -EPERM; - - mutex_lock(&pega_hwmon_mcu_lock); - - data = i2c_smbus_read_word_data(client, reg); - - mutex_unlock(&pega_hwmon_mcu_lock); - - return data; -} - -static int pega_hwmon_mcu_write(struct i2c_client *client, u8 reg, u8 val) -{ - int ret = -EIO; - - mutex_lock(&pega_hwmon_mcu_lock); - - ret = i2c_smbus_write_byte_data(client, reg, val); - - mutex_unlock(&pega_hwmon_mcu_lock); - - return ret; -} - -static ssize_t mainBoardUpgrade(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = MB_FW_UG_REG; - long val = 0; - - if (kstrtol(buf, 16, &val)) - { - return -EINVAL; - } - - if(val) - pega_hwmon_mcu_write(client, reg, FW_UPGRADE_COMMAND); - else - pega_hwmon_mcu_write(client, reg, 0xff); - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, FW_UPGRADE_COMMAND)); - - return count; -} - -static ssize_t fanBoardUpgrade(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = FB_FW_UG_REG; - long val = 0; - - if (kstrtol(buf, 16, &val)) - { - return -EINVAL; - } - - if(val) - pega_hwmon_mcu_write(client, reg, FW_UPGRADE_COMMAND); - else - pega_hwmon_mcu_write(client, reg, 0xff); - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, FW_UPGRADE_COMMAND)); - - return count; -} - -static ssize_t get_MB_HW_version(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = MB_HW_VER_REG; - - data = pega_hwmon_mcu_read(client, reg); - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - data &= 0x1f; - - return sprintf(buf, "%02x\n", data); -} - -static ssize_t get_FB_HW_version(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = FB_HW_SKUVER_REG; - - data = pega_hwmon_mcu_read(client, reg); - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - data = (data >> 5) & 0x7; - - return sprintf(buf, "%02x\n", data); -} - -static ssize_t get_FB_boardId(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = FB_HW_SKUVER_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - data &= 0x1f; - - return sprintf(buf, "%02x\n", data); -} - -static ssize_t get_MB_FW_version(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, major_ver = 0, minor_ver = 0; - u8 reg = MB_FW_VER_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - major_ver = (data >> 4) & 0xf; - minor_ver = data & 0xf; - - return sprintf(buf, "%d.%d\n", major_ver, minor_ver); -} - -static ssize_t get_FB_FW_version(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, major_ver = 0, minor_ver = 0; - u8 reg = FB_FW_VER_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - major_ver = (data >> 4) & 0xf; - minor_ver = data & 0xf; - - return sprintf(buf, "%d.%d\n", major_ver, minor_ver); -} - -static ssize_t get_fan_PWM(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = FAN_PWM_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%d\n", data); -} - -static ssize_t set_fan_pwm(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = FAN_PWM_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, val: %x\r\n", __func__, client->addr, reg, val)); - pega_hwmon_mcu_write(client, reg, val); - - return count; -} - -static ssize_t get_smartFan_enable(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, val = 0; - u8 reg = SF_ENABLE_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, SMART_FAN_ENABLE_BIT, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t set_smartFan_enable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_ENABLE_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - if(val) - SET_BIT(data, SMART_FAN_ENABLE_BIT); - else - CLEAR_BIT(data, SMART_FAN_ENABLE_BIT); - pega_hwmon_mcu_write(client, reg, data); - - return count; -} - -static ssize_t get_smartFan_setting_enable(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, val = 0; - u8 reg = SF_SETTING_ENABLE_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, SMART_FAN_SETTING_ENABLE_BIT, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t set_smartFan_setting_enable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_SETTING_ENABLE_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - if(val) - SET_BIT(data, SMART_FAN_SETTING_ENABLE_BIT); - else - CLEAR_BIT(data, SMART_FAN_SETTING_ENABLE_BIT); - pega_hwmon_mcu_write(client, reg, data); - - return count; -} - -static ssize_t get_smartFan_device(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_DEVICE_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%x\n", data); -} - -static ssize_t set_smartFan_device(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_DEVICE_REG; - long val = 0; - - if (kstrtol(buf, 16, &val)) - { - return -EINVAL; - } - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, val)); - - pega_hwmon_mcu_write(client, reg, val); - - return count; -} - -static ssize_t get_smartFan_update(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_UPDATE_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%d\n", data); -} - -static ssize_t set_smartFan_update(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_UPDATE_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, val)); - - pega_hwmon_mcu_write(client, reg, val); - - return count; -} - -static ssize_t get_smartFan_max_temp(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_TEMP_MAX_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%d\n", data); -} - -static ssize_t set_smartFan_max_temp(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_TEMP_MAX_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, val)); - - pega_hwmon_mcu_write(client, reg, val); - - return count; -} - -static ssize_t get_smartFan_mid_temp(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_TEMP_MID_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%d\n", data); -} - -static ssize_t set_smartFan_mid_temp(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_TEMP_MID_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, val)); - - pega_hwmon_mcu_write(client, reg, val); - - return count; -} - -static ssize_t get_smartFan_min_temp(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_TEMP_MID_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%d\n", data); -} - -static ssize_t set_smartFan_min_temp(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_TEMP_MID_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, val)); - - pega_hwmon_mcu_write(client, reg, val); - - return count; -} - -static ssize_t get_smartFan_max_pwm(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_PWM_MAX_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%d\n", data); -} - -static ssize_t set_smartFan_max_pwm(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_PWM_MAX_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, val)); - - pega_hwmon_mcu_write(client, reg, val); - - return count; -} - -static ssize_t get_smartFan_mid_pwm(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_PWM_MID_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%d\n", data); -} - -static ssize_t set_smartFan_mid_pwm(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_PWM_MID_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, val)); - - pega_hwmon_mcu_write(client, reg, val); - - return count; -} - -static ssize_t get_smartFan_min_pwm(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_PWM_MIN_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%d\n", data); -} - -static ssize_t set_smartFan_min_pwm(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_PWM_MIN_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, val)); - - pega_hwmon_mcu_write(client, reg, val); - - return count; -} - -static ssize_t get_fan_inner_rpm(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); - u16 data = 0; - u8 reg = FAN1_INNER_RPM_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%d\n", data); -} - -static ssize_t get_fan_outer_rpm(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); - u16 data = 0; - u8 reg = FAN1_OUTER_RPM_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%d\n", data); -} - -static ssize_t get_fan_present(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); - u8 data = 0, val = 0; - u8 reg = FAN1_STATUS_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, FAN_PRESENT_BIT, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t get_fan_enable(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); - u8 data = 0, val = 0; - u8 reg = FAN1_STATUS_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, FAN_ENABLE_BIT, val); - - return sprintf(buf, "%d\n", val); -} - - -static ssize_t set_fan_enable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_PWM_MID_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, val: %x\r\n", __func__, client->addr, reg, val)); - - if(val) - pega_hwmon_mcu_write(client, reg, FAN_ENABLE_COMMAND); - else - pega_hwmon_mcu_write(client, reg, FAN_DISABLE_COMMAND); - - return count; -} - -static ssize_t get_fan_led_auto(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); - u8 data = 0, val = 0; - u8 reg = FAN1_STATUS_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, FAN_LED_AUTO_BIT, val); - - return sprintf(buf, "%d\n", val); -} - - -static ssize_t set_fan_led_auto(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_PWM_MID_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, val: %x\r\n", __func__, client->addr, reg, val)); - - if(val) - pega_hwmon_mcu_write(client, reg, FAN_LED_SETTO_AUTO_COMMAND); - else - pega_hwmon_mcu_write(client, reg, FAN_LED_SETTO_MANUAL_COMMAND); - - return count; -} - -static ssize_t get_fan_led_green(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); - u8 data = 0, val = 0; - u8 reg = FAN1_STATUS_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, FAN_LED_GREEN_BIT, val); - - return sprintf(buf, "%d\n", val); -} - - -static ssize_t set_fan_led_green(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_PWM_MID_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, val: %x\r\n", __func__, client->addr, reg, val)); - - if(val) - pega_hwmon_mcu_write(client, reg, FAN_LED_GREENON_COMMAND); - else - pega_hwmon_mcu_write(client, reg, FAN_LED_GREENOFF_COMMAND); - - return count; -} - -static ssize_t get_fan_led_amber(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); - u8 data = 0, val = 0; - u8 reg = FAN1_STATUS_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, FAN_LED_AMBER_BIT, val); - - return sprintf(buf, "%d\n", val); -} - - -static ssize_t set_fan_led_amber(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = SF_PWM_MID_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, val: %x\r\n", __func__, client->addr, reg, val)); - - if(val) - pega_hwmon_mcu_write(client, reg, FAN_LED_AMBERON_COMMAND); - else - pega_hwmon_mcu_write(client, reg, FAN_LED_AMBEROFF_COMMAND); - - return count; -} - -static ssize_t get_fan_status_alert(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); - u8 data = 0, val = 0; - u8 reg = FAN1_STATUS_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, FAN_ALERT_BIT, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t get_adc_under_vol_alert(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); - u8 data = 0, val = 0; - u8 reg = ADC_UNDER_VOL_ALERT_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, attr->index, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t get_adc_over_vol_alert(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); - u8 data = 0, val = 0; - u8 reg = ADC_OVER_VOL_ALERT_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, attr->index, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t get_temp_alert(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); - u8 data = 0, val = 0; - u8 reg = TS_OVER_TEMP_ALERT_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, SA56004X_REMOTE_TEMP_ALERT_BIT + attr->index, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t get_fan_outerRPMOver_alert(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); - u8 data = 0, val = 0; - u8 reg = FAN1_ALERT_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, FAN_OUTER_RPM_OVER_ALERT_BIT, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t get_fan_outerRPMUnder_alert(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); - u8 data = 0, val = 0; - u8 reg = FAN1_ALERT_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, FAN_OUTER_RPM_UNDER_ALERT_BIT, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t get_fan_innerRPMOver_alert(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); - u8 data = 0, val = 0; - u8 reg = FAN1_ALERT_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, FAN_INNER_RPM_OVER_ALERT_BIT, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t get_fan_innerRPMUnder_alert(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); - u8 data = 0, val = 0; - u8 reg = FAN1_ALERT_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, FAN_INNER_RPM_UNDER_ALERT_BIT, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t get_fan_connect_alert(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); - u8 data = 0, val = 0; - u8 reg = FAN1_ALERT_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, FAN_CONNECT_ALERT_BIT, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t get_fan_disconnect_alert(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); - u8 data = 0, val = 0; - u8 reg = FAN1_ALERT_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, FAN_DISCONNECT_ALERT_BIT, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t get_i2c_timeout(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); - u8 data = 0, val = 0; - u8 reg = I2C_BUS_ALERT_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, I2C_FANBOARD_TIMEOUT_BIT + attr->index, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t get_alert_mode(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); - u8 data = 0, val = 0; - u8 reg = ALERT_MODE_REG; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, ALERT_MODE_BIT, val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t set_alert_mode(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0; - u8 reg = ALERT_MODE_REG; - long val = 0; - - if (kstrtol(buf, 10, &val)) - { - return -EINVAL; - } - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, val: %x\r\n", __func__, client->addr, reg, val)); - - if(val) - SET_BIT(data, ALERT_MODE_BIT); - else - CLEAR_BIT(data, ALERT_MODE_BIT); - pega_hwmon_mcu_write(client, reg, data); - - return count; -} - -static ssize_t get_adc_vol(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); - u16 data = 0, reg = MONITOR_ADC_VOLTAGE_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%d.%02d\n", data/1000, (data/10)%12); -} - -static ssize_t get_hwmon_temp(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); - u8 data = 0; - u8 reg = LM_0X49_TEMP_REG + attr->index; - - data = pega_hwmon_mcu_read(client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%d\n", data); -} -#define SET_FAN_ATTR(_num) \ - static SENSOR_DEVICE_ATTR(fan##_num##_inner_rpm, S_IRUGO, get_fan_inner_rpm, NULL, _num-1); \ - static SENSOR_DEVICE_ATTR(fan##_num##_outer_rpm, S_IRUGO, get_fan_outer_rpm, NULL, _num-1); \ - static SENSOR_DEVICE_ATTR(fan##_num##_present, S_IRUGO, get_fan_present, NULL, _num-1); \ - static SENSOR_DEVICE_ATTR(fan##_num##_enable, S_IRUGO | S_IWUSR, get_fan_enable, set_fan_enable, _num-1); \ - static SENSOR_DEVICE_ATTR(fan##_num##_led_auto, S_IRUGO | S_IWUSR, get_fan_led_auto, set_fan_led_auto, _num-1); \ - static SENSOR_DEVICE_ATTR(fan##_num##_led_green, S_IRUGO | S_IWUSR, get_fan_led_green, set_fan_led_green, _num-1); \ - static SENSOR_DEVICE_ATTR(fan##_num##_led_amber, S_IRUGO | S_IWUSR, get_fan_led_amber, set_fan_led_amber, _num-1); \ - static SENSOR_DEVICE_ATTR(fan##_num##_status_alert, S_IRUGO, get_fan_status_alert, NULL, _num-1); \ - static SENSOR_DEVICE_ATTR(fan##_num##_outerRPMOver_alert, S_IRUGO, get_fan_outerRPMOver_alert, NULL, _num-1); \ - static SENSOR_DEVICE_ATTR(fan##_num##_outerRPMUnder_alert, S_IRUGO, get_fan_outerRPMUnder_alert, NULL, _num-1); \ - static SENSOR_DEVICE_ATTR(fan##_num##_innerRPMOver_alert, S_IRUGO, get_fan_innerRPMOver_alert, NULL, _num-1); \ - static SENSOR_DEVICE_ATTR(fan##_num##_innerRPMUnder_alert, S_IRUGO, get_fan_innerRPMUnder_alert, NULL, _num-1); \ - static SENSOR_DEVICE_ATTR(fan##_num##_connect_alert, S_IRUGO, get_fan_connect_alert, NULL, _num-1); \ - static SENSOR_DEVICE_ATTR(fan##_num##_disconnect_alert, S_IRUGO, get_fan_disconnect_alert, NULL, _num-1) - -SET_FAN_ATTR(1);SET_FAN_ATTR(2);SET_FAN_ATTR(3);SET_FAN_ATTR(4);SET_FAN_ATTR(5); - -#define SET_ADC_ATTR(_num) \ - static SENSOR_DEVICE_ATTR(ADC##_num##_under_alert, S_IRUGO, get_adc_under_vol_alert, NULL, _num-1); \ - static SENSOR_DEVICE_ATTR(ADC##_num##_over_alert, S_IRUGO, get_adc_over_vol_alert, NULL, _num-1); \ - static SENSOR_DEVICE_ATTR(ADC##_num##_vol, S_IRUGO, get_adc_vol, NULL, 8-_num) - -SET_ADC_ATTR(1);SET_ADC_ATTR(2);SET_ADC_ATTR(3);SET_ADC_ATTR(4);SET_ADC_ATTR(5);SET_ADC_ATTR(6);SET_ADC_ATTR(7);SET_ADC_ATTR(8); - -static SENSOR_DEVICE_ATTR(mb_fw_upgrade, S_IWUSR, NULL, mainBoardUpgrade, 0); -static SENSOR_DEVICE_ATTR(fb_fw_upgrade, S_IWUSR, NULL, fanBoardUpgrade, 0); -static SENSOR_DEVICE_ATTR(mb_hw_version, S_IRUGO, get_MB_HW_version, NULL, 0); -static SENSOR_DEVICE_ATTR(fb_hw_version, S_IRUGO, get_FB_HW_version, NULL, 0); -static SENSOR_DEVICE_ATTR(fb_board_id, S_IRUGO, get_FB_boardId, NULL, 0); -static SENSOR_DEVICE_ATTR(mb_fw_version, S_IRUGO, get_MB_FW_version, NULL, 0); -static SENSOR_DEVICE_ATTR(fb_fw_version, S_IRUGO, get_FB_FW_version, NULL, 0); -static SENSOR_DEVICE_ATTR(fan_pwm, S_IRUGO | S_IWUSR, get_fan_PWM, set_fan_pwm, 0); - -static SENSOR_DEVICE_ATTR(smartFan_enable, S_IRUGO | S_IWUSR, get_smartFan_enable, set_smartFan_enable, 0); -static SENSOR_DEVICE_ATTR(smartFan_setting_enable, S_IRUGO | S_IWUSR, get_smartFan_setting_enable, set_smartFan_setting_enable, 0); -static SENSOR_DEVICE_ATTR(smartFan_device, S_IRUGO | S_IWUSR, get_smartFan_device, set_smartFan_device, 0); -static SENSOR_DEVICE_ATTR(smartFan_update, S_IRUGO | S_IWUSR, get_smartFan_update, set_smartFan_update, 0); -static SENSOR_DEVICE_ATTR(smartFan_max_temp, S_IRUGO | S_IWUSR, get_smartFan_max_temp, set_smartFan_max_temp, 0); -static SENSOR_DEVICE_ATTR(smartFan_mid_temp, S_IRUGO | S_IWUSR, get_smartFan_mid_temp, set_smartFan_mid_temp, 0); -static SENSOR_DEVICE_ATTR(smartFan_min_temp, S_IRUGO | S_IWUSR, get_smartFan_min_temp, set_smartFan_min_temp, 0); -static SENSOR_DEVICE_ATTR(smartFan_max_pwm, S_IRUGO | S_IWUSR, get_smartFan_max_pwm, set_smartFan_max_pwm, 0); -static SENSOR_DEVICE_ATTR(smartFan_mid_pwm, S_IRUGO | S_IWUSR, get_smartFan_mid_pwm, set_smartFan_mid_pwm, 0); -static SENSOR_DEVICE_ATTR(smartFan_min_pwm, S_IRUGO | S_IWUSR, get_smartFan_min_pwm, set_smartFan_min_pwm, 0); - -static SENSOR_DEVICE_ATTR(lm75_49_temp_alert, S_IRUGO, get_temp_alert, NULL, 3); -static SENSOR_DEVICE_ATTR(lm75_48_temp_alert, S_IRUGO, get_temp_alert, NULL, 2); -static SENSOR_DEVICE_ATTR(SA56004X_Ltemp_alert, S_IRUGO, get_temp_alert, NULL, 1); -static SENSOR_DEVICE_ATTR(SA56004X_Rtemp_alert, S_IRUGO, get_temp_alert, NULL, 0); - -static SENSOR_DEVICE_ATTR(i2c_fb_timeout, S_IRUGO, get_i2c_timeout, NULL, 0); -static SENSOR_DEVICE_ATTR(i2c_remote_timeout, S_IRUGO, get_i2c_timeout, NULL, 1); -static SENSOR_DEVICE_ATTR(i2c_local_timeout, S_IRUGO, get_i2c_timeout, NULL, 2); -static SENSOR_DEVICE_ATTR(i2c_lm75_48_timeout, S_IRUGO, get_i2c_timeout, NULL, 3); -static SENSOR_DEVICE_ATTR(i2c_lm75_49_timeout, S_IRUGO, get_i2c_timeout, NULL, 4); -static SENSOR_DEVICE_ATTR(alert_mode, S_IRUGO | S_IWUSR, get_alert_mode, set_alert_mode, 0); - -static SENSOR_DEVICE_ATTR(lm75_49_temp, S_IRUGO, get_hwmon_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(lm75_48_temp, S_IRUGO, get_hwmon_temp, NULL, 1); -static SENSOR_DEVICE_ATTR(SA56004_local_temp, S_IRUGO, get_hwmon_temp, NULL, 2); -static SENSOR_DEVICE_ATTR(SA56004_remote_temp, S_IRUGO, get_hwmon_temp, NULL, 3); - -static struct attribute *pega_hwmon_mcu_attributes[] = { - &sensor_dev_attr_mb_fw_upgrade.dev_attr.attr, - &sensor_dev_attr_fb_fw_upgrade.dev_attr.attr, - &sensor_dev_attr_mb_hw_version.dev_attr.attr, - &sensor_dev_attr_fb_hw_version.dev_attr.attr, - &sensor_dev_attr_fb_board_id.dev_attr.attr, - &sensor_dev_attr_mb_fw_version.dev_attr.attr, - &sensor_dev_attr_fb_fw_version.dev_attr.attr, - &sensor_dev_attr_fan_pwm.dev_attr.attr, - - &sensor_dev_attr_smartFan_enable.dev_attr.attr, - &sensor_dev_attr_smartFan_setting_enable.dev_attr.attr, - &sensor_dev_attr_smartFan_device.dev_attr.attr, - &sensor_dev_attr_smartFan_update.dev_attr.attr, - &sensor_dev_attr_smartFan_max_temp.dev_attr.attr, - &sensor_dev_attr_smartFan_mid_temp.dev_attr.attr, - &sensor_dev_attr_smartFan_min_temp.dev_attr.attr, - &sensor_dev_attr_smartFan_max_pwm.dev_attr.attr, - &sensor_dev_attr_smartFan_mid_pwm.dev_attr.attr, - &sensor_dev_attr_smartFan_min_pwm.dev_attr.attr, - - &sensor_dev_attr_fan1_inner_rpm.dev_attr.attr, - &sensor_dev_attr_fan2_inner_rpm.dev_attr.attr, - &sensor_dev_attr_fan3_inner_rpm.dev_attr.attr, - &sensor_dev_attr_fan4_inner_rpm.dev_attr.attr, - &sensor_dev_attr_fan5_inner_rpm.dev_attr.attr, - - &sensor_dev_attr_fan1_outer_rpm.dev_attr.attr, - &sensor_dev_attr_fan2_outer_rpm.dev_attr.attr, - &sensor_dev_attr_fan3_outer_rpm.dev_attr.attr, - &sensor_dev_attr_fan4_outer_rpm.dev_attr.attr, - &sensor_dev_attr_fan5_outer_rpm.dev_attr.attr, - - &sensor_dev_attr_fan1_present.dev_attr.attr, - &sensor_dev_attr_fan2_present.dev_attr.attr, - &sensor_dev_attr_fan3_present.dev_attr.attr, - &sensor_dev_attr_fan4_present.dev_attr.attr, - &sensor_dev_attr_fan5_present.dev_attr.attr, - - &sensor_dev_attr_fan1_enable.dev_attr.attr, - &sensor_dev_attr_fan2_enable.dev_attr.attr, - &sensor_dev_attr_fan3_enable.dev_attr.attr, - &sensor_dev_attr_fan4_enable.dev_attr.attr, - &sensor_dev_attr_fan5_enable.dev_attr.attr, - - &sensor_dev_attr_fan1_led_auto.dev_attr.attr, - &sensor_dev_attr_fan2_led_auto.dev_attr.attr, - &sensor_dev_attr_fan3_led_auto.dev_attr.attr, - &sensor_dev_attr_fan4_led_auto.dev_attr.attr, - &sensor_dev_attr_fan5_led_auto.dev_attr.attr, - - &sensor_dev_attr_fan1_led_green.dev_attr.attr, - &sensor_dev_attr_fan2_led_green.dev_attr.attr, - &sensor_dev_attr_fan3_led_green.dev_attr.attr, - &sensor_dev_attr_fan4_led_green.dev_attr.attr, - &sensor_dev_attr_fan5_led_green.dev_attr.attr, - - &sensor_dev_attr_fan1_led_amber.dev_attr.attr, - &sensor_dev_attr_fan2_led_amber.dev_attr.attr, - &sensor_dev_attr_fan3_led_amber.dev_attr.attr, - &sensor_dev_attr_fan4_led_amber.dev_attr.attr, - &sensor_dev_attr_fan5_led_amber.dev_attr.attr, - - &sensor_dev_attr_fan1_status_alert.dev_attr.attr, - &sensor_dev_attr_fan2_status_alert.dev_attr.attr, - &sensor_dev_attr_fan3_status_alert.dev_attr.attr, - &sensor_dev_attr_fan4_status_alert.dev_attr.attr, - &sensor_dev_attr_fan5_status_alert.dev_attr.attr, - - &sensor_dev_attr_ADC1_under_alert.dev_attr.attr, - &sensor_dev_attr_ADC2_under_alert.dev_attr.attr, - &sensor_dev_attr_ADC3_under_alert.dev_attr.attr, - &sensor_dev_attr_ADC4_under_alert.dev_attr.attr, - &sensor_dev_attr_ADC5_under_alert.dev_attr.attr, - &sensor_dev_attr_ADC6_under_alert.dev_attr.attr, - &sensor_dev_attr_ADC7_under_alert.dev_attr.attr, - &sensor_dev_attr_ADC8_under_alert.dev_attr.attr, - - &sensor_dev_attr_ADC1_over_alert.dev_attr.attr, - &sensor_dev_attr_ADC2_over_alert.dev_attr.attr, - &sensor_dev_attr_ADC3_over_alert.dev_attr.attr, - &sensor_dev_attr_ADC4_over_alert.dev_attr.attr, - &sensor_dev_attr_ADC5_over_alert.dev_attr.attr, - &sensor_dev_attr_ADC6_over_alert.dev_attr.attr, - &sensor_dev_attr_ADC7_over_alert.dev_attr.attr, - &sensor_dev_attr_ADC8_over_alert.dev_attr.attr, - - &sensor_dev_attr_lm75_48_temp_alert.dev_attr.attr, - &sensor_dev_attr_lm75_49_temp_alert.dev_attr.attr, - &sensor_dev_attr_SA56004X_Ltemp_alert.dev_attr.attr, - &sensor_dev_attr_SA56004X_Rtemp_alert.dev_attr.attr, - - &sensor_dev_attr_fan1_outerRPMOver_alert.dev_attr.attr, - &sensor_dev_attr_fan2_outerRPMOver_alert.dev_attr.attr, - &sensor_dev_attr_fan3_outerRPMOver_alert.dev_attr.attr, - &sensor_dev_attr_fan4_outerRPMOver_alert.dev_attr.attr, - &sensor_dev_attr_fan5_outerRPMOver_alert.dev_attr.attr, - - &sensor_dev_attr_fan1_outerRPMUnder_alert.dev_attr.attr, - &sensor_dev_attr_fan2_outerRPMUnder_alert.dev_attr.attr, - &sensor_dev_attr_fan3_outerRPMUnder_alert.dev_attr.attr, - &sensor_dev_attr_fan4_outerRPMUnder_alert.dev_attr.attr, - &sensor_dev_attr_fan5_outerRPMUnder_alert.dev_attr.attr, - - &sensor_dev_attr_fan1_innerRPMOver_alert.dev_attr.attr, - &sensor_dev_attr_fan2_innerRPMOver_alert.dev_attr.attr, - &sensor_dev_attr_fan3_innerRPMOver_alert.dev_attr.attr, - &sensor_dev_attr_fan4_innerRPMOver_alert.dev_attr.attr, - &sensor_dev_attr_fan5_innerRPMOver_alert.dev_attr.attr, - - &sensor_dev_attr_fan1_innerRPMUnder_alert.dev_attr.attr, - &sensor_dev_attr_fan2_innerRPMUnder_alert.dev_attr.attr, - &sensor_dev_attr_fan3_innerRPMUnder_alert.dev_attr.attr, - &sensor_dev_attr_fan4_innerRPMUnder_alert.dev_attr.attr, - &sensor_dev_attr_fan5_innerRPMUnder_alert.dev_attr.attr, - - &sensor_dev_attr_fan1_connect_alert.dev_attr.attr, - &sensor_dev_attr_fan2_connect_alert.dev_attr.attr, - &sensor_dev_attr_fan3_connect_alert.dev_attr.attr, - &sensor_dev_attr_fan4_connect_alert.dev_attr.attr, - &sensor_dev_attr_fan5_connect_alert.dev_attr.attr, - - &sensor_dev_attr_fan1_disconnect_alert.dev_attr.attr, - &sensor_dev_attr_fan2_disconnect_alert.dev_attr.attr, - &sensor_dev_attr_fan3_disconnect_alert.dev_attr.attr, - &sensor_dev_attr_fan4_disconnect_alert.dev_attr.attr, - &sensor_dev_attr_fan5_disconnect_alert.dev_attr.attr, - - &sensor_dev_attr_i2c_fb_timeout.dev_attr.attr, - &sensor_dev_attr_i2c_remote_timeout.dev_attr.attr, - &sensor_dev_attr_i2c_local_timeout.dev_attr.attr, - &sensor_dev_attr_i2c_lm75_48_timeout.dev_attr.attr, - &sensor_dev_attr_i2c_lm75_49_timeout.dev_attr.attr, - &sensor_dev_attr_alert_mode.dev_attr.attr, - - &sensor_dev_attr_ADC1_vol.dev_attr.attr, - &sensor_dev_attr_ADC2_vol.dev_attr.attr, - &sensor_dev_attr_ADC3_vol.dev_attr.attr, - &sensor_dev_attr_ADC4_vol.dev_attr.attr, - &sensor_dev_attr_ADC5_vol.dev_attr.attr, - &sensor_dev_attr_ADC6_vol.dev_attr.attr, - &sensor_dev_attr_ADC7_vol.dev_attr.attr, - &sensor_dev_attr_ADC8_vol.dev_attr.attr, - - &sensor_dev_attr_lm75_49_temp.dev_attr.attr, - &sensor_dev_attr_lm75_48_temp.dev_attr.attr, - &sensor_dev_attr_SA56004_local_temp.dev_attr.attr, - &sensor_dev_attr_SA56004_remote_temp.dev_attr.attr, - - NULL -}; - -static const struct attribute_group pega_hwmon_mcu_group = { .attrs = pega_hwmon_mcu_attributes}; - -static int pega_hwmon_mcu_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int status; - - status = sysfs_create_group(&client->dev.kobj, &pega_hwmon_mcu_group); - - if (status) { - goto exit; - } - - dev_info(&client->dev, "chip found\n"); - - return 0; - -exit: - return status; -} - -static int pega_hwmon_mcu_remove(struct i2c_client *client) -{ - sysfs_remove_group(&client->dev.kobj, &pega_hwmon_mcu_group); - return 0; -} - -static const struct i2c_device_id pega_hwmon_mcu_id[] = { - { "porsche_hwmon_mcu", porsche }, - {} -}; -MODULE_DEVICE_TABLE(i2c, pega_hwmon_mcu_id); - -static struct i2c_driver pega_hwmon_mcu_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "pegatron_hwmon_mcu", - }, - .probe = pega_hwmon_mcu_probe, - .remove = pega_hwmon_mcu_remove, - .id_table = pega_hwmon_mcu_id, -}; - -static int __init pega_hwmon_mcu_init(void) -{ - mutex_init(&pega_hwmon_mcu_lock); - - return i2c_add_driver(&pega_hwmon_mcu_driver); -} - -static void __exit pega_hwmon_mcu_exit(void) -{ - i2c_del_driver(&pega_hwmon_mcu_driver); -} - -MODULE_AUTHOR("Peter5 Lin "); -MODULE_DESCRIPTION("pega_hwmon_mcu driver"); -MODULE_LICENSE("GPL"); - -module_init(pega_hwmon_mcu_init); -module_exit(pega_hwmon_mcu_exit); \ No newline at end of file diff --git a/platform/nephos/sonic-platform-modules-pegatron/debian/changelog b/platform/nephos/sonic-platform-modules-pegatron/debian/changelog deleted file mode 100644 index 39ecd34d960..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -sonic-pegatron-platform-modules (0.1) unstable; urgency=low - - * Initial release - - -- Pegatron Mon, 12 Mar 2018 15:22:37 +0800 diff --git a/platform/nephos/sonic-platform-modules-pegatron/debian/compat b/platform/nephos/sonic-platform-modules-pegatron/debian/compat deleted file mode 100644 index ec635144f60..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/platform/nephos/sonic-platform-modules-pegatron/debian/control b/platform/nephos/sonic-platform-modules-pegatron/debian/control deleted file mode 100755 index 8fc19980fc1..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/debian/control +++ /dev/null @@ -1,12 +0,0 @@ -Source: sonic-pegatron-platform-modules -Section: main -Priority: extra -Maintainer: Pegatron -Build-Depends: debhelper (>= 8.0.0), bzip2 -Standards-Version: 3.9.3 - -Package: sonic-platform-pegatron-porsche -Architecture: amd64 -Depends: linux-image-4.19.0-12-2-amd64-unsigned -Description: kernel modules for platform devices such as fan, led, sfp - diff --git a/platform/nephos/sonic-platform-modules-pegatron/debian/rules b/platform/nephos/sonic-platform-modules-pegatron/debian/rules deleted file mode 100755 index 472ec939a47..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/debian/rules +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -include /usr/share/dpkg/pkg-info.mk - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -export INSTALL_MOD_DIR:=extra - -PYTHON ?= python2 - -PACKAGE_PRE_NAME := sonic-platform-pegatron -KVERSION ?= $(shell uname -r) -KERNEL_SRC := /lib/modules/$(KVERSION) -MOD_SRC_DIR:= $(shell pwd) -MODULE_DIRS:= porsche -MODULE_DIR := modules -UTILS_DIR := utils -SERVICE_DIR := service -SCRIPTS_DIR := scripts -CONF_DIR := conf - -%: - dh $@ --with systemd,python2,python3 --buildsystem=pybuild - -clean: - dh_testdir - dh_testroot - dh_clean - -build: - #make modules -C $(KERNEL_SRC)/build M=$(MODULE_SRC) - (for mod in $(MODULE_DIRS); do \ - make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ - #$(PYTHON) $${mod}/setup.py build; \ - done) - -binary: binary-arch binary-indep - # Nothing to do - -binary-arch: - # Nothing to do - -#install: build - #dh_testdir - #dh_testroot - #dh_clean -k - #dh_installdirs - -binary-indep: - dh_testdir - dh_installdirs - - # Custom package commands - (for mod in $(MODULE_DIRS); do \ - dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ - dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod}/usr/local/bin; \ - dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod}/usr/bin; \ - dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system; \ - cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ - cp $(MOD_SRC_DIR)/$${mod}/$(UTILS_DIR)/* debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/local/bin/; \ - cp $(MOD_SRC_DIR)/$${mod}/$(SERVICE_DIR)/*.service debian/$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system/; \ - cp $(MOD_SRC_DIR)/$${mod}/$(SCRIPTS_DIR)/* debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/bin/; \ - #$(PYTHON) $${mod}/setup.py install --root=$(MOD_SRC_DIR)/debian/$(PACKAGE_PRE_NAME)-$${mod} --install-layout=deb; \ - done) - # Resuming debhelper scripts - dh_testroot - dh_install - dh_installchangelogs - dh_installdocs - dh_systemd_enable - dh_installinit - dh_systemd_start - dh_link - dh_fixperms - dh_compress - dh_strip - dh_installdeb - dh_gencontrol - dh_md5sums - dh_builddeb -.PHONY: build binary binary-arch binary-indep clean diff --git a/platform/nephos/sonic-platform-modules-pegatron/porsche/modules/Makefile b/platform/nephos/sonic-platform-modules-pegatron/porsche/modules/Makefile deleted file mode 100644 index 60e882a586d..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/porsche/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-m:=pegatron_porsche_cpld.o pegatron_hwmon_mcu.o pegatron_porsche_sfp.o diff --git a/platform/nephos/sonic-platform-modules-pegatron/porsche/modules/pegatron_hwmon_mcu.c b/platform/nephos/sonic-platform-modules-pegatron/porsche/modules/pegatron_hwmon_mcu.c deleted file mode 120000 index 1357104478a..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/porsche/modules/pegatron_hwmon_mcu.c +++ /dev/null @@ -1 +0,0 @@ -../../common/modules/pegatron_hwmon_mcu.c \ No newline at end of file diff --git a/platform/nephos/sonic-platform-modules-pegatron/porsche/modules/pegatron_porsche_cpld.c b/platform/nephos/sonic-platform-modules-pegatron/porsche/modules/pegatron_porsche_cpld.c deleted file mode 100644 index 154a68dcb83..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/porsche/modules/pegatron_porsche_cpld.c +++ /dev/null @@ -1,1132 +0,0 @@ -/* - * A CPLD driver for the porsche - * - * Copyright (C) 2018 Pegatron Corporation. - * Peter5_Lin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#undef pegatron_porsche_DEBUG -/*#define pegatron_porsche_DEBUG*/ -#ifdef pegatron_porsche_DEBUG -#define DBG(x) x -#else -#define DBG(x) -#endif /* DEBUG */ - -#define CPLD_SFP_MAX_GROUP 3 -#define SFP_PORT_MAX_NUM 54 -#define SFP_EEPROM_SIZE 256 -#define QSFP_FIRST_PORT 48 -#define CPLDA_SFP_NUM 24 -#define CPLDB_SFP_NUM 12 -#define CPLDC_SFP_NUM 18 -#define CPLDA_ADDRESS 0x74 -#define CPLDB_ADDRESS 0x75 -#define CPLDC_ADDRESS 0x76 -#define CPLD_VERSION_REG 0x0 -#define SYNC_CONTROL_REG 0x1 -#define CPLD_SYS_PWR_LED_REG 0xD -#define CPLD_LOC_FAN_LED_REG 0xE -#define CPLD_EEPROM_WRITE_REG 0x12 -#define CPLD_PSU_REG 0x15 -#define SFP_13_36_SCL_BASE 0x4 -#define SFP_1_12_SCL_BASE 0x2 -#define SFP_37_54_SCL_BASE 0x5 -#define SFP_13_36_STATUS_BASE 0x8 -#define SFP_1_12_STATUS_BASE 0x5 -#define SFP_37_54_STATUS_BASE 0x9 -#define QSFP_PRESENT_ADDRESS 0xF -#define QSFP_RESET_ADDRESS_BASE 0x10 -#define QSFP_MODSELN_ADDRESS 0x17 -#define QSFP_LOW_POWER_ADDRESS 0x18 -#define CPLD_SERIAL_LED_BIT 2 -#define CPLD_EEPROM_WRITE_BIT 2 -#define SFP_PRESENT_BASE 0 -#define SFP_RXLOSS_BASE 1 -#define SFP_TXFAULT_BASE 2 -#define SFP_TXDISABLE_BASE 3 -#define CPLD_PSU_PWOK_BASE 0 -#define CPLD_PSU_PRESENT_BASE 2 -#define GET_BIT(data, bit, value) value = (data >> bit) & 0x1 -#define SET_BIT(data, bit) data |= (1 << bit) -#define CLEAR_BIT(data, bit) data &= ~(1 << bit) - -static LIST_HEAD(cpld_client_list); -static struct mutex list_lock; -/* Addresses scanned for pegatron_porsche_cpld - */ -static const unsigned short normal_i2c[] = { CPLDA_ADDRESS, CPLDB_ADDRESS, CPLDC_ADDRESS, I2C_CLIENT_END }; - -struct cpld_client_node { - struct i2c_client *client; - struct list_head list; -}; - -int pegatron_porsche_cpld_read(unsigned short addr, u8 reg) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int data = -EPERM; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client->addr == addr) { - data = i2c_smbus_read_byte_data(cpld_node->client, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, addr, reg, data)); - break; - } - } - - mutex_unlock(&list_lock); - - return data; -} -EXPORT_SYMBOL(pegatron_porsche_cpld_read); - -int pegatron_porsche_cpld_write(unsigned short addr, u8 reg, u8 val) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EIO; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client->addr == addr) { - ret = i2c_smbus_write_byte_data(cpld_node->client, reg, val); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, addr, reg, val)); - break; - } - } - - mutex_unlock(&list_lock); - - return ret; -} -EXPORT_SYMBOL(pegatron_porsche_cpld_write); - -static ssize_t read_cpld_HWversion(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, reg = CPLD_VERSION_REG; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%02x\n", (data >> 5) & 0x7); -} - -static ssize_t read_cpld_SWversion(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, reg = CPLD_VERSION_REG; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - - return sprintf(buf, "%02x\n", (data & 0x1f)); -} - -static ssize_t show_allled_ctrl(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, reg = SYNC_CONTROL_REG; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - data &= 0x3; - - return sprintf(buf, "%02x\n", data); -} - -static ssize_t set_allled_ctrl(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, reg = SYNC_CONTROL_REG; - long val = 0; - - if (kstrtol(buf, 16, &val)) - { - return -EINVAL; - } - - data = pegatron_porsche_cpld_read(client->addr, reg); - data = val | (data & 0xfc); - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - pegatron_porsche_cpld_write(client->addr, reg, data); - - return count; -} - -static ssize_t show_serial_led(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, val = 0, reg = SYNC_CONTROL_REG; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, CPLD_SERIAL_LED_BIT, val); - - return sprintf(buf, "%02x\n", val); -} - -static ssize_t set_serial_led(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, reg = SYNC_CONTROL_REG; - long val = 0; - - if (kstrtol(buf, 16, &val)) - { - return -EINVAL; - } - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - if(val) - SET_BIT(data, CPLD_SERIAL_LED_BIT); - else - CLEAR_BIT(data, CPLD_SERIAL_LED_BIT); - - pegatron_porsche_cpld_write(client->addr, reg, data); - - return count; -} - -static ssize_t show_sys_led(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, reg = CPLD_SYS_PWR_LED_REG; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - data = (data >> 5) & 0x7; - - return sprintf(buf, "%02x\n", data); -} - -static ssize_t set_sys_led(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, reg = CPLD_SYS_PWR_LED_REG; - long val = 0; - - if (kstrtol(buf, 16, &val)) - { - return -EINVAL; - } - - data = pegatron_porsche_cpld_read(client->addr, reg); - data = (val << 5) | (data & 0x1f); - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - pegatron_porsche_cpld_write(client->addr, reg, data); - - return count; -} -static ssize_t show_pwr_led(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, reg = CPLD_SYS_PWR_LED_REG; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - data = (data >> 2) & 0x7; - - return sprintf(buf, "%02x\n", data); -} - -static ssize_t set_pwr_led(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, reg = CPLD_SYS_PWR_LED_REG; - long val = 0; - - - if (kstrtol(buf, 16, &val)) - { - return -EINVAL; - } - - data = pegatron_porsche_cpld_read(client->addr, reg); - data = (val << 2) | (data & 0xe3); - - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - pegatron_porsche_cpld_write(client->addr, reg, data); - - return count; -} -static ssize_t show_loc_led(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, reg = CPLD_LOC_FAN_LED_REG; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - data = (data>>4) & 0x3; - - return sprintf(buf, "%02x\n", data); -} - -static ssize_t set_loc_led(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, reg = CPLD_LOC_FAN_LED_REG; - long val = 0; - - if (kstrtol(buf, 16, &val)) - { - return -EINVAL; - } - - data = pegatron_porsche_cpld_read(client->addr, reg); - data = (val << 4) | (data & 0xf); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - pegatron_porsche_cpld_write(client->addr, reg, data); - - return count; -} - -static ssize_t show_fan_led(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, reg = CPLD_LOC_FAN_LED_REG; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - data &= 0x7; - - return sprintf(buf, "%02x\n", data); -} - -static ssize_t set_fan_led(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, reg = CPLD_LOC_FAN_LED_REG; - long val = 0; - - if (kstrtol(buf, 16, &val)) - { - return -EINVAL; - } - - data = pegatron_porsche_cpld_read(client->addr, reg); - data = val | (data & 0xf8); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - pegatron_porsche_cpld_write(client->addr, reg, data); - - return count; -} - -static ssize_t show_eeprom_write_enable(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, val = 0, reg = CPLD_EEPROM_WRITE_REG; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, reg, val); - - return sprintf(buf, "%02x\n", val); -} - -static ssize_t set_eeprom_write_enable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, reg = CPLD_EEPROM_WRITE_REG; - long val = 0; - - if (kstrtol(buf, 16, &val)) - { - return -EINVAL; - } - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - if(val) - SET_BIT(data, CPLD_EEPROM_WRITE_BIT); - else - CLEAR_BIT(data, CPLD_EEPROM_WRITE_BIT); - - pegatron_porsche_cpld_write(client->addr, reg, data); - - return count; -} - -static ssize_t read_psu_present(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); - u8 data = 0, val = 0, reg = CPLD_PSU_REG; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, (CPLD_PSU_PRESENT_BASE + attr->index), val); - - return sprintf(buf, "%02x\n", val); -} - -static ssize_t read_psu_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - u8 data = 0, val=0, reg = CPLD_PSU_REG; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, (CPLD_PSU_PWOK_BASE + attr->index), val); - - return sprintf(buf, "%02x\n", val); -} - -#define GET_SFP_STATUS_ADDRESS(idx, reg) \ - if(idx < CPLDB_SFP_NUM) \ - reg = SFP_1_12_STATUS_BASE + (idx / 2); \ - else if(idx < CPLDA_SFP_NUM + CPLDB_SFP_NUM) \ - reg = SFP_13_36_STATUS_BASE + ((idx-CPLDB_SFP_NUM) / 2); \ - else \ - reg = SFP_37_54_STATUS_BASE + ((idx-CPLDB_SFP_NUM-CPLDA_SFP_NUM) / 2) - -static ssize_t get_sfp_present(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); - u8 reg = 0, data = 0, val = 0; - - GET_SFP_STATUS_ADDRESS(attr->index, reg); - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, SFP_PRESENT_BASE + 4*(attr->index % 2), val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t get_sfp_tx_disable(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); - u8 reg = 0, data = 0, val = 0; - - GET_SFP_STATUS_ADDRESS(attr->index, reg); - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, SFP_TXDISABLE_BASE + 4*(attr->index % 2), val); - - return sprintf(buf, "%d\n", val); -} -static ssize_t set_sfp_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - u8 reg = 0, data = 0; - long val = 0; - - if (kstrtol(buf, 16, &val)) - { - return -EINVAL; - } - - GET_SFP_STATUS_ADDRESS(attr->index, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - data = pegatron_porsche_cpld_read(client->addr, reg); - - if(val) - SET_BIT(data, SFP_TXDISABLE_BASE + 4*(attr->index % 2)); - else - CLEAR_BIT(data, SFP_TXDISABLE_BASE + 4*(attr->index % 2)); - - pegatron_porsche_cpld_write(client->addr, reg, data); - - return count; -} -static ssize_t get_sfp_rx_loss(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); - u8 reg = 0, data = 0, val = 0; - - GET_SFP_STATUS_ADDRESS(attr->index, reg); - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, SFP_RXLOSS_BASE + 4*(attr->index % 2), val); - - return sprintf(buf, "%d\n", val); -} -static ssize_t get_sfp_tx_fault(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); - u8 reg = 0, data = 0, val = 0; - - GET_SFP_STATUS_ADDRESS(attr->index, reg); - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, SFP_TXFAULT_BASE + 4*(attr->index % 2), val); - - return sprintf(buf, "%d\n",val); -} - -static ssize_t get_qsfp_present(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); - u8 data = 0, val = 0, reg = QSFP_PRESENT_ADDRESS; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, (attr->index % QSFP_FIRST_PORT), val); - - return sprintf(buf, "%d\n", val); -} - -static ssize_t get_qsfp_reset(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); - u8 reg = (QSFP_RESET_ADDRESS_BASE + attr->index % QSFP_FIRST_PORT / 4), data =0; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - data = (data >> ((attr->index % QSFP_FIRST_PORT % 4)*2)) & 0x3; - - return sprintf(buf, "%d\n", data); -} - -static ssize_t set_qsfp_reset(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); - u8 reg = (QSFP_RESET_ADDRESS_BASE + attr->index % QSFP_FIRST_PORT / 4), data = 0; - long val = 0; - - if (kstrtol(buf, 16, &val)) - { - return -EINVAL; - } - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - data = (val & 0x3) << ((attr->index % QSFP_FIRST_PORT % 4)*2); - - pegatron_porsche_cpld_write(client->addr, reg, data); - - return count; -} - -static ssize_t get_qsfp_lowpower(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); - u8 data = 0, val = 0, reg = QSFP_LOW_POWER_ADDRESS; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, (attr->index % QSFP_FIRST_PORT), val); - return sprintf(buf, "%02x\n", val); -} - -static ssize_t set_qsfp_lowpower(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); - u8 data = 0, reg = QSFP_LOW_POWER_ADDRESS; - long val = 0; - - if (kstrtol(buf, 16, &val)) - { - return -EINVAL; - } - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - if(val) - SET_BIT(data, (attr->index % QSFP_FIRST_PORT)); - else - CLEAR_BIT(data, (attr->index % QSFP_FIRST_PORT)); - - pegatron_porsche_cpld_write(client->addr, reg, data); - - return count; -} - -static ssize_t get_qsfp_modeseln(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); - u8 data = 0, val = 0, reg = QSFP_MODSELN_ADDRESS; - - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - GET_BIT(data, (attr->index % QSFP_FIRST_PORT), val); - return sprintf(buf, "%02x\n", val); -} - -static ssize_t set_qsfp_modeseln(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); - u8 data = 0, reg = QSFP_MODSELN_ADDRESS; - long val = 0; - - if (kstrtol(buf, 16, &val)) - { - return -EINVAL; - } - data = pegatron_porsche_cpld_read(client->addr, reg); - DBG(printk(KERN_ALERT "%s - addr: 0x%x, reg: %x, data: %x\r\n", __func__, client->addr, reg, data)); - if(val) - SET_BIT(data, (attr->index % QSFP_FIRST_PORT)); - else - CLEAR_BIT(data, (attr->index % QSFP_FIRST_PORT)); - - pegatron_porsche_cpld_write(client->addr, reg, data); - - return count; -} - -static SENSOR_DEVICE_ATTR(cpld_hw_version, S_IRUGO, read_cpld_HWversion, NULL, 0); -static SENSOR_DEVICE_ATTR(cpld_sw_version, S_IRUGO, read_cpld_SWversion, NULL, 0); -static SENSOR_DEVICE_ATTR(cpld_allled_ctrl, S_IRUGO | S_IWUSR, show_allled_ctrl, set_allled_ctrl, 0); -static SENSOR_DEVICE_ATTR(serial_led_enable, S_IRUGO | S_IWUSR, show_serial_led, set_serial_led, 0); -static SENSOR_DEVICE_ATTR(sys_led, S_IRUGO | S_IWUSR, show_sys_led, set_sys_led, 0); -static SENSOR_DEVICE_ATTR(pwr_led, S_IRUGO | S_IWUSR, show_pwr_led, set_pwr_led, 0); -static SENSOR_DEVICE_ATTR(loc_led, S_IRUGO | S_IWUSR, show_loc_led, set_loc_led, 0); -static SENSOR_DEVICE_ATTR(fan_led, S_IRUGO | S_IWUSR, show_fan_led, set_fan_led, 0); -static SENSOR_DEVICE_ATTR(eeprom_write_enable, S_IRUGO | S_IWUSR, show_eeprom_write_enable, set_eeprom_write_enable, 0); -static SENSOR_DEVICE_ATTR(psu_1_present, S_IRUGO, read_psu_present, NULL, 1); -static SENSOR_DEVICE_ATTR(psu_2_present, S_IRUGO, read_psu_present, NULL, 0); -static SENSOR_DEVICE_ATTR(psu_1_status, S_IRUGO, read_psu_status, NULL, 1); -static SENSOR_DEVICE_ATTR(psu_2_status, S_IRUGO, read_psu_status, NULL, 0); - -#define SET_SFP_ATTR(_num) \ - static SENSOR_DEVICE_ATTR(sfp##_num##_present, S_IRUGO, get_sfp_present, NULL, _num-1); \ - static SENSOR_DEVICE_ATTR(sfp##_num##_tx_disable, S_IRUGO | S_IWUSR, get_sfp_tx_disable, set_sfp_tx_disable, _num-1); \ - static SENSOR_DEVICE_ATTR(sfp##_num##_rx_loss, S_IRUGO, get_sfp_rx_loss, NULL, _num-1); \ - static SENSOR_DEVICE_ATTR(sfp##_num##_tx_fault, S_IRUGO, get_sfp_tx_fault, NULL, _num-1) - -#define SET_QSFP_ATTR(_num) \ - static SENSOR_DEVICE_ATTR(sfp##_num##_present, S_IRUGO, get_qsfp_present, NULL, _num-1); \ - static SENSOR_DEVICE_ATTR(sfp##_num##_reset, S_IRUGO | S_IWUSR, get_qsfp_reset, set_qsfp_reset, _num-1); \ - static SENSOR_DEVICE_ATTR(sfp##_num##_lowpower, S_IRUGO | S_IWUSR, get_qsfp_lowpower, set_qsfp_lowpower, _num-1); \ - static SENSOR_DEVICE_ATTR(sfp##_num##_modeseln, S_IRUGO | S_IWUSR, get_qsfp_modeseln, set_qsfp_modeseln, _num-1) - -SET_SFP_ATTR(1);SET_SFP_ATTR(2);SET_SFP_ATTR(3);SET_SFP_ATTR(4);SET_SFP_ATTR(5);SET_SFP_ATTR(6);SET_SFP_ATTR(7);SET_SFP_ATTR(8);SET_SFP_ATTR(9); -SET_SFP_ATTR(10);SET_SFP_ATTR(11);SET_SFP_ATTR(12);SET_SFP_ATTR(13);SET_SFP_ATTR(14);SET_SFP_ATTR(15);SET_SFP_ATTR(16);SET_SFP_ATTR(17);SET_SFP_ATTR(18); -SET_SFP_ATTR(19);SET_SFP_ATTR(20);SET_SFP_ATTR(21);SET_SFP_ATTR(22);SET_SFP_ATTR(23);SET_SFP_ATTR(24);SET_SFP_ATTR(25);SET_SFP_ATTR(26);SET_SFP_ATTR(27); -SET_SFP_ATTR(28);SET_SFP_ATTR(29);SET_SFP_ATTR(30);SET_SFP_ATTR(31);SET_SFP_ATTR(32);SET_SFP_ATTR(33);SET_SFP_ATTR(34);SET_SFP_ATTR(35);SET_SFP_ATTR(36); -SET_SFP_ATTR(37);SET_SFP_ATTR(38);SET_SFP_ATTR(39);SET_SFP_ATTR(40);SET_SFP_ATTR(41);SET_SFP_ATTR(42);SET_SFP_ATTR(43);SET_SFP_ATTR(44);SET_SFP_ATTR(45); -SET_SFP_ATTR(46);SET_SFP_ATTR(47);SET_SFP_ATTR(48); -SET_QSFP_ATTR(49);SET_QSFP_ATTR(50);SET_QSFP_ATTR(51);SET_QSFP_ATTR(52);SET_QSFP_ATTR(53);SET_QSFP_ATTR(54); - -static struct attribute *pegatron_porsche_cpldA_attributes[] = { - &sensor_dev_attr_cpld_hw_version.dev_attr.attr, - &sensor_dev_attr_cpld_sw_version.dev_attr.attr, - - &sensor_dev_attr_sfp13_present.dev_attr.attr, - &sensor_dev_attr_sfp13_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp13_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp13_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp14_present.dev_attr.attr, - &sensor_dev_attr_sfp14_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp14_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp14_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp15_present.dev_attr.attr, - &sensor_dev_attr_sfp15_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp15_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp15_tx_fault.dev_attr.attr, - - - &sensor_dev_attr_sfp16_present.dev_attr.attr, - &sensor_dev_attr_sfp16_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp16_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp16_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp17_present.dev_attr.attr, - &sensor_dev_attr_sfp17_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp17_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp17_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp18_present.dev_attr.attr, - &sensor_dev_attr_sfp18_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp18_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp18_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp19_present.dev_attr.attr, - &sensor_dev_attr_sfp19_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp19_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp19_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp20_present.dev_attr.attr, - &sensor_dev_attr_sfp20_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp20_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp20_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp21_present.dev_attr.attr, - &sensor_dev_attr_sfp21_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp21_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp21_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp22_present.dev_attr.attr, - &sensor_dev_attr_sfp22_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp22_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp22_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp23_present.dev_attr.attr, - &sensor_dev_attr_sfp23_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp23_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp23_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp24_present.dev_attr.attr, - &sensor_dev_attr_sfp24_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp24_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp24_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp25_present.dev_attr.attr, - &sensor_dev_attr_sfp25_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp25_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp25_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp26_present.dev_attr.attr, - &sensor_dev_attr_sfp26_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp26_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp26_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp27_present.dev_attr.attr, - &sensor_dev_attr_sfp27_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp27_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp27_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp28_present.dev_attr.attr, - &sensor_dev_attr_sfp28_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp28_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp28_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp29_present.dev_attr.attr, - &sensor_dev_attr_sfp29_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp29_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp29_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp30_present.dev_attr.attr, - &sensor_dev_attr_sfp30_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp30_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp30_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp31_present.dev_attr.attr, - &sensor_dev_attr_sfp31_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp31_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp31_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp32_present.dev_attr.attr, - &sensor_dev_attr_sfp32_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp32_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp32_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp33_present.dev_attr.attr, - &sensor_dev_attr_sfp33_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp33_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp33_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp34_present.dev_attr.attr, - &sensor_dev_attr_sfp34_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp34_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp34_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp35_present.dev_attr.attr, - &sensor_dev_attr_sfp35_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp35_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp35_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp36_present.dev_attr.attr, - &sensor_dev_attr_sfp36_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp36_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp36_tx_fault.dev_attr.attr, - - NULL -}; - -static struct attribute *pegatron_porsche_cpldB_attributes[] = { - &sensor_dev_attr_cpld_hw_version.dev_attr.attr, - &sensor_dev_attr_cpld_sw_version.dev_attr.attr, - &sensor_dev_attr_cpld_allled_ctrl.dev_attr.attr, - &sensor_dev_attr_serial_led_enable.dev_attr.attr, - &sensor_dev_attr_sys_led.dev_attr.attr, - &sensor_dev_attr_pwr_led.dev_attr.attr, - &sensor_dev_attr_loc_led.dev_attr.attr, - &sensor_dev_attr_fan_led.dev_attr.attr, - &sensor_dev_attr_eeprom_write_enable.dev_attr.attr, - &sensor_dev_attr_psu_1_present.dev_attr.attr, - &sensor_dev_attr_psu_2_present.dev_attr.attr, - &sensor_dev_attr_psu_1_status.dev_attr.attr, - &sensor_dev_attr_psu_2_status.dev_attr.attr, - - &sensor_dev_attr_sfp1_present.dev_attr.attr, - &sensor_dev_attr_sfp1_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp1_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp1_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp2_present.dev_attr.attr, - &sensor_dev_attr_sfp2_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp2_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp2_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp3_present.dev_attr.attr, - &sensor_dev_attr_sfp3_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp3_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp3_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp4_present.dev_attr.attr, - &sensor_dev_attr_sfp4_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp4_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp4_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp5_present.dev_attr.attr, - &sensor_dev_attr_sfp5_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp5_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp5_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp6_present.dev_attr.attr, - &sensor_dev_attr_sfp6_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp6_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp6_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp7_present.dev_attr.attr, - &sensor_dev_attr_sfp7_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp7_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp7_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp8_present.dev_attr.attr, - &sensor_dev_attr_sfp8_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp8_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp8_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp9_present.dev_attr.attr, - &sensor_dev_attr_sfp9_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp9_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp9_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp10_present.dev_attr.attr, - &sensor_dev_attr_sfp10_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp10_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp10_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp11_present.dev_attr.attr, - &sensor_dev_attr_sfp11_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp11_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp11_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp12_present.dev_attr.attr, - &sensor_dev_attr_sfp12_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp12_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp12_tx_fault.dev_attr.attr, - NULL -}; - -static struct attribute *pegatron_porsche_cpldC_attributes[] = { - &sensor_dev_attr_cpld_hw_version.dev_attr.attr, - &sensor_dev_attr_cpld_sw_version.dev_attr.attr, - - &sensor_dev_attr_sfp37_present.dev_attr.attr, - &sensor_dev_attr_sfp37_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp37_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp37_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp38_present.dev_attr.attr, - &sensor_dev_attr_sfp38_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp38_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp38_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp39_present.dev_attr.attr, - &sensor_dev_attr_sfp39_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp39_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp39_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp40_present.dev_attr.attr, - &sensor_dev_attr_sfp40_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp40_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp40_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp41_present.dev_attr.attr, - &sensor_dev_attr_sfp41_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp41_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp41_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp42_present.dev_attr.attr, - &sensor_dev_attr_sfp42_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp42_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp42_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp43_present.dev_attr.attr, - &sensor_dev_attr_sfp43_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp43_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp43_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp44_present.dev_attr.attr, - &sensor_dev_attr_sfp44_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp44_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp44_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp45_present.dev_attr.attr, - &sensor_dev_attr_sfp45_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp45_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp45_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp46_present.dev_attr.attr, - &sensor_dev_attr_sfp46_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp46_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp46_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp47_present.dev_attr.attr, - &sensor_dev_attr_sfp47_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp47_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp47_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp48_present.dev_attr.attr, - &sensor_dev_attr_sfp48_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp48_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp48_tx_fault.dev_attr.attr, - - &sensor_dev_attr_sfp49_present.dev_attr.attr, - &sensor_dev_attr_sfp49_lowpower.dev_attr.attr, - &sensor_dev_attr_sfp49_modeseln.dev_attr.attr, - &sensor_dev_attr_sfp49_reset.dev_attr.attr, - - &sensor_dev_attr_sfp50_present.dev_attr.attr, - &sensor_dev_attr_sfp50_lowpower.dev_attr.attr, - &sensor_dev_attr_sfp50_modeseln.dev_attr.attr, - &sensor_dev_attr_sfp50_reset.dev_attr.attr, - - &sensor_dev_attr_sfp51_present.dev_attr.attr, - &sensor_dev_attr_sfp51_lowpower.dev_attr.attr, - &sensor_dev_attr_sfp51_modeseln.dev_attr.attr, - &sensor_dev_attr_sfp51_reset.dev_attr.attr, - - &sensor_dev_attr_sfp52_present.dev_attr.attr, - &sensor_dev_attr_sfp52_lowpower.dev_attr.attr, - &sensor_dev_attr_sfp52_modeseln.dev_attr.attr, - &sensor_dev_attr_sfp52_reset.dev_attr.attr, - - &sensor_dev_attr_sfp53_present.dev_attr.attr, - &sensor_dev_attr_sfp53_lowpower.dev_attr.attr, - &sensor_dev_attr_sfp53_modeseln.dev_attr.attr, - &sensor_dev_attr_sfp53_reset.dev_attr.attr, - - &sensor_dev_attr_sfp54_present.dev_attr.attr, - &sensor_dev_attr_sfp54_lowpower.dev_attr.attr, - &sensor_dev_attr_sfp54_modeseln.dev_attr.attr, - &sensor_dev_attr_sfp54_reset.dev_attr.attr, - NULL -}; - -static const struct attribute_group pegatron_porsche_cpldA_group = { .attrs = pegatron_porsche_cpldA_attributes}; -static const struct attribute_group pegatron_porsche_cpldB_group = { .attrs = pegatron_porsche_cpldB_attributes}; -static const struct attribute_group pegatron_porsche_cpldC_group = { .attrs = pegatron_porsche_cpldC_attributes}; - -static void pegatron_porsche_cpld_add_client(struct i2c_client *client) -{ - struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); - - if (!node) { - dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); - return; - } - - node->client = client; - - mutex_lock(&list_lock); - list_add(&node->list, &cpld_client_list); - mutex_unlock(&list_lock); -} - -static void pegatron_porsche_cpld_remove_client(struct i2c_client *client) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int found = 0; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client == client) { - found = 1; - break; - } - } - - if (found) { - list_del(list_node); - kfree(cpld_node); - } - - mutex_unlock(&list_lock); -} - -static int pegatron_porsche_cpld_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int status; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_dbg(&client->dev, "i2c_check_functionality failed (0x%x)\n", client->addr); - status = -EIO; - goto exit; - } - - /* Register sysfs hooks */ - switch(client->addr) - { - case CPLDA_ADDRESS: - status = sysfs_create_group(&client->dev.kobj, &pegatron_porsche_cpldA_group); - break; - case CPLDB_ADDRESS: - status = sysfs_create_group(&client->dev.kobj, &pegatron_porsche_cpldB_group); - break; - case CPLDC_ADDRESS: - status = sysfs_create_group(&client->dev.kobj, &pegatron_porsche_cpldC_group); - break; - default: - dev_dbg(&client->dev, "i2c_check_CPLD failed (0x%x)\n", client->addr); - status = -EIO; - goto exit; - break; - } - - if (status) { - goto exit; - } - - dev_info(&client->dev, "chip found\n"); - pegatron_porsche_cpld_add_client(client); - - return 0; - -exit: - return status; -} - -static int pegatron_porsche_cpld_remove(struct i2c_client *client) -{ - switch(client->addr) - { - case CPLDA_ADDRESS: - sysfs_remove_group(&client->dev.kobj, &pegatron_porsche_cpldA_group); - break; - case CPLDB_ADDRESS: - sysfs_remove_group(&client->dev.kobj, &pegatron_porsche_cpldB_group); - break; - case CPLDC_ADDRESS: - sysfs_remove_group(&client->dev.kobj, &pegatron_porsche_cpldC_group); - break; - default: - dev_dbg(&client->dev, "i2c_remove_CPLD failed (0x%x)\n", client->addr); - break; - } - - - pegatron_porsche_cpld_remove_client(client); - return 0; -} - -static const struct i2c_device_id pegatron_porsche_cpld_id[] = { - { "porsche_cpld", 0 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, pegatron_porsche_cpld_id); - -static struct i2c_driver pegatron_porsche_cpld_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "pegatron_porsche_cpld", - }, - .probe = pegatron_porsche_cpld_probe, - .remove = pegatron_porsche_cpld_remove, - .id_table = pegatron_porsche_cpld_id, - .address_list = normal_i2c, -}; - -static int __init pegatron_porsche_cpld_init(void) -{ - mutex_init(&list_lock); - - return i2c_add_driver(&pegatron_porsche_cpld_driver); -} - -static void __exit pegatron_porsche_cpld_exit(void) -{ - i2c_del_driver(&pegatron_porsche_cpld_driver); -} - -MODULE_AUTHOR("Peter5 Lin "); -MODULE_DESCRIPTION("pegatron_porsche_cpld driver"); -MODULE_LICENSE("GPL"); - -module_init(pegatron_porsche_cpld_init); -module_exit(pegatron_porsche_cpld_exit); diff --git a/platform/nephos/sonic-platform-modules-pegatron/porsche/modules/pegatron_porsche_sfp.c b/platform/nephos/sonic-platform-modules-pegatron/porsche/modules/pegatron_porsche_sfp.c deleted file mode 100644 index 5d5d64b15e1..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/porsche/modules/pegatron_porsche_sfp.c +++ /dev/null @@ -1,431 +0,0 @@ -/* - * A SFP driver for the porsche platform - * - * Copyright (C) 2018 Pegatron Corporation. - * Peter5_Lin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#undef PEGA_DEBUG -/*#define PEGA_DEBUG*/ -#ifdef PEGA_DEBUG -#define DBG(x) x -#else -#define DBG(x) -#endif /* DEBUG */ - -#define SFP_EEPROM_SIZE 256 -#define SFP_EEPROM_A0_ADDR 0x50 -#define SFP_EEPROM_A2_ADDR 0x51 -#define SFP_EEPROM_BUS_TYPE I2C_SMBUS_I2C_BLOCK_DATA -#define CPLDA_SFP_NUM 24 -#define CPLDB_SFP_NUM 12 -#define CPLDC_SFP_NUM 18 -#define CPLDA_ADDRESS 0x74 -#define CPLDB_ADDRESS 0x75 -#define CPLDC_ADDRESS 0x76 -#define SFP_13_36_SCL_BASE 0x4 -#define SFP_1_12_SCL_BASE 0x2 -#define SFP_37_54_SCL_BASE 0x5 -#define QSFP_I2C_ENABLE_BASE 0x17 -#define GET_BIT(data, bit, value) value = (data >> bit) & 0x1 -#define SET_BIT(data, bit) data |= (1 << bit) -#define CLEAR_BIT(data, bit) data &= ~(1 << bit) - -enum cpld_croups { cpld_group_a, cpld_group_b, cpld_group_c}; - -static const unsigned short normal_i2c[] = { SFP_EEPROM_A0_ADDR, SFP_EEPROM_A2_ADDR, I2C_CLIENT_END }; -static char *SFP_CPLD_GROUPA_MAPPING[CPLDA_SFP_NUM][16]={0}; -static char *SFP_CPLD_GROUPB_MAPPING[CPLDB_SFP_NUM][16]={0}; -static char *SFP_CPLD_GROUPC_MAPPING[CPLDC_SFP_NUM][16]={0}; - -/* - * This parameter is to help this driver avoid blocking other drivers out - * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C - * clock, one 256 byte read takes about 1/43 second which is excessive; - * but the 1/170 second it takes at 400 kHz may be quite reasonable; and - * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. - * - * This value is forced to be a power of two so that writes align on pages. - */ -static unsigned io_limit = 128; -module_param(io_limit, uint, 0); -MODULE_PARM_DESC(io_limit, "Maximum bytes per I/O (default 128)"); - -/* - * Specs often allow 5 msec for a page write, sometimes 20 msec; - * it's important to recover from write timeouts. - */ -static unsigned write_timeout = 25; -module_param(write_timeout, uint, 0); -MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)"); - - -struct porsche_sfp_data { - struct mutex lock; - struct bin_attribute bin; - int use_smbus; - kernel_ulong_t driver_data; - - struct i2c_client *client; -}; - -extern int pegatron_porsche_cpld_read(unsigned short cpld_addr, u8 reg); -extern int pegatron_porsche_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -static ssize_t porsche_sfp_eeprom_read(struct porsche_sfp_data *data, char *buf, - unsigned offset, size_t count) -{ - struct i2c_msg msg[2]; - u8 msgbuf[2]; - struct i2c_client *client = data->client; - unsigned long timeout, read_time; - int status; - - memset(msg, 0, sizeof(msg)); - - if (count > io_limit) - count = io_limit; - - /* Smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - read_time = jiffies; - switch (data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_read_i2c_block_data(client, offset, - count, buf); - break; - case I2C_SMBUS_WORD_DATA: - status = i2c_smbus_read_word_data(client, offset); - if (status >= 0) { - buf[0] = status & 0xff; - if (count == 2) - buf[1] = status >> 8; - status = count; - } - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_read_byte_data(client, offset); - if (status >= 0) { - buf[0] = status; - status = count; - } - break; - default: - status = i2c_transfer(client->adapter, msg, 2); - if (status == 2) - status = count; - } - dev_dbg(&client->dev, "read %zu@%d --> %d (%ld)\n", - count, offset, status, jiffies); - - if (status == count) - return count; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(read_time, timeout)); - - return -ETIMEDOUT; -} - -static ssize_t porsche_sfp_read(struct porsche_sfp_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) - return count; - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->lock); - - while (count) { - ssize_t status; - - status = porsche_sfp_eeprom_read(data, buf, off, count); - if (status <= 0) { - if (retval == 0) - retval = status; - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->lock); - - return retval; -} - -static ssize_t -porsche_sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int i; - u8 cpldData = 0; - struct porsche_sfp_data *data; - - /*SFP 1-12*/ - for(i=0; iattr.name, SFP_CPLD_GROUPB_MAPPING[i])) - { - pegatron_porsche_cpld_write(CPLDB_ADDRESS, SFP_1_12_SCL_BASE, i+1); - goto check_done; - } - } - /*SFP 13-36*/ - for(i=0; iattr.name, SFP_CPLD_GROUPA_MAPPING[i])) - { - pegatron_porsche_cpld_write(CPLDA_ADDRESS, SFP_13_36_SCL_BASE, i+1); - goto check_done; - } - } - - /*SFP 37-54*/ - for(i=0; iattr.name, SFP_CPLD_GROUPC_MAPPING[i])) - { - /* Enable QSFP i2c function */ - if(i >= 12) - { - cpldData = 0xff; - cpldData = pegatron_porsche_cpld_read(CPLDC_ADDRESS, QSFP_I2C_ENABLE_BASE); - CLEAR_BIT(cpldData, i-12); - pegatron_porsche_cpld_write(CPLDC_ADDRESS, QSFP_I2C_ENABLE_BASE, cpldData); - } - pegatron_porsche_cpld_write(CPLDC_ADDRESS, SFP_37_54_SCL_BASE, i+1); - goto check_done; - } - } - -check_done: - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - return porsche_sfp_read(data, buf, off, count); -} - -#define SFP_EEPROM_ATTR(_num) \ - static struct bin_attribute sfp##_num##_eeprom_attr = { \ - .attr = { \ - .name = __stringify(sfp##_num##_eeprom), \ - .mode = S_IRUGO\ - }, \ - .size = SFP_EEPROM_SIZE, \ - .read = porsche_sfp_bin_read, \ - } - -SFP_EEPROM_ATTR(1);SFP_EEPROM_ATTR(2);SFP_EEPROM_ATTR(3);SFP_EEPROM_ATTR(4);SFP_EEPROM_ATTR(5);SFP_EEPROM_ATTR(6);SFP_EEPROM_ATTR(7);SFP_EEPROM_ATTR(8);SFP_EEPROM_ATTR(9); -SFP_EEPROM_ATTR(10);SFP_EEPROM_ATTR(11);SFP_EEPROM_ATTR(12);SFP_EEPROM_ATTR(13);SFP_EEPROM_ATTR(14);SFP_EEPROM_ATTR(15);SFP_EEPROM_ATTR(16);SFP_EEPROM_ATTR(17);SFP_EEPROM_ATTR(18); -SFP_EEPROM_ATTR(19);SFP_EEPROM_ATTR(20);SFP_EEPROM_ATTR(21);SFP_EEPROM_ATTR(22);SFP_EEPROM_ATTR(23);SFP_EEPROM_ATTR(24);SFP_EEPROM_ATTR(25);SFP_EEPROM_ATTR(26);SFP_EEPROM_ATTR(27); -SFP_EEPROM_ATTR(28);SFP_EEPROM_ATTR(29);SFP_EEPROM_ATTR(30);SFP_EEPROM_ATTR(31);SFP_EEPROM_ATTR(32);SFP_EEPROM_ATTR(33);SFP_EEPROM_ATTR(34);SFP_EEPROM_ATTR(35);SFP_EEPROM_ATTR(36); -SFP_EEPROM_ATTR(37);SFP_EEPROM_ATTR(38);SFP_EEPROM_ATTR(39);SFP_EEPROM_ATTR(40);SFP_EEPROM_ATTR(41);SFP_EEPROM_ATTR(42);SFP_EEPROM_ATTR(43);SFP_EEPROM_ATTR(44);SFP_EEPROM_ATTR(45); -SFP_EEPROM_ATTR(46);SFP_EEPROM_ATTR(47);SFP_EEPROM_ATTR(48);SFP_EEPROM_ATTR(49);SFP_EEPROM_ATTR(50);SFP_EEPROM_ATTR(51);SFP_EEPROM_ATTR(52);SFP_EEPROM_ATTR(53);SFP_EEPROM_ATTR(54); - -static struct bin_attribute *porsche_cpldA_sfp_epprom_attributes[] = { - &sfp13_eeprom_attr, &sfp14_eeprom_attr, &sfp15_eeprom_attr, &sfp16_eeprom_attr, &sfp17_eeprom_attr, &sfp18_eeprom_attr, &sfp19_eeprom_attr, &sfp20_eeprom_attr, - &sfp21_eeprom_attr, &sfp22_eeprom_attr, &sfp23_eeprom_attr, &sfp24_eeprom_attr, &sfp25_eeprom_attr, &sfp26_eeprom_attr, &sfp27_eeprom_attr, &sfp28_eeprom_attr, - &sfp29_eeprom_attr, &sfp30_eeprom_attr, &sfp31_eeprom_attr, &sfp32_eeprom_attr, &sfp33_eeprom_attr, &sfp34_eeprom_attr, &sfp35_eeprom_attr, &sfp36_eeprom_attr, - NULL -}; - -static struct bin_attribute *porsche_cpldB_sfp_epprom_attributes[] = { - &sfp1_eeprom_attr, &sfp2_eeprom_attr, &sfp3_eeprom_attr, &sfp4_eeprom_attr, &sfp5_eeprom_attr, &sfp6_eeprom_attr, &sfp7_eeprom_attr, &sfp8_eeprom_attr, - &sfp9_eeprom_attr, &sfp10_eeprom_attr, &sfp11_eeprom_attr, &sfp12_eeprom_attr, - NULL -}; - -static struct bin_attribute *porsche_cpldC_sfp_epprom_attributes[] = { - &sfp37_eeprom_attr, &sfp38_eeprom_attr, &sfp39_eeprom_attr, &sfp40_eeprom_attr, &sfp41_eeprom_attr, &sfp42_eeprom_attr, &sfp43_eeprom_attr, &sfp44_eeprom_attr, - &sfp45_eeprom_attr, &sfp46_eeprom_attr, &sfp47_eeprom_attr, &sfp48_eeprom_attr, &sfp49_eeprom_attr, &sfp50_eeprom_attr, &sfp51_eeprom_attr, &sfp52_eeprom_attr, - &sfp53_eeprom_attr, &sfp54_eeprom_attr, - NULL -}; - -static const struct attribute_group porsche_sfpA_group = { .bin_attrs = porsche_cpldA_sfp_epprom_attributes}; -static const struct attribute_group porsche_sfpB_group = { .bin_attrs = porsche_cpldB_sfp_epprom_attributes}; -static const struct attribute_group porsche_sfpC_group = { .bin_attrs = porsche_cpldC_sfp_epprom_attributes}; - -static int porsche_sfp_device_probe(struct i2c_client *client, const struct i2c_device_id *dev_id) -{ - int use_smbus = SFP_EEPROM_BUS_TYPE; - struct porsche_sfp_data *data; - int err, i; - unsigned num_addresses; - kernel_ulong_t magic; - - data = kzalloc(sizeof(struct porsche_sfp_data) , GFP_KERNEL); - if (!data) - return -ENOMEM; - - mutex_init(&data->lock); - data->use_smbus = use_smbus; - /* - * Export the EEPROM bytes through sysfs, since that's convenient. - * By default, only root should see the data (maybe passwords etc) - */ - - data->client = client; - data->driver_data = dev_id->driver_data; - - sysfs_bin_attr_init(&data->bin); - - switch(dev_id->driver_data) - { - case cpld_group_a: - err = sysfs_create_group(&client->dev.kobj, &porsche_sfpA_group); - if (err) - goto err_clients; - break; - case cpld_group_b: - err = sysfs_create_group(&client->dev.kobj, &porsche_sfpB_group); - if (err) - goto err_clients; - break; - case cpld_group_c: - err = sysfs_create_group(&client->dev.kobj, &porsche_sfpC_group); - if (err) - goto err_clients; - break; - default: - printk(KERN_ALERT "i2c_check_CPLD failed\n"); - err = -EIO; - break; - } - - i2c_set_clientdata(client, data); - - return 0; - -err_clients: - kfree(data); - return err; -} - -static int porsche_sfp_device_remove(struct i2c_client *client) -{ - struct porsche_sfp_data *data; - int i; - - data = i2c_get_clientdata(client); - - switch(data->driver_data) - { - case cpld_group_a: - sysfs_remove_group(&client->dev.kobj, &porsche_sfpA_group); - break; - case cpld_group_b: - sysfs_remove_group(&client->dev.kobj, &porsche_sfpB_group); - break; - case cpld_group_c: - sysfs_remove_group(&client->dev.kobj, &porsche_sfpC_group); - break; - default: - dev_dbg(&client->dev, "i2c_remove_CPLD failed (0x%x)\n", client->addr); - break; - } - - - return 0; -} - -static const struct i2c_device_id porsche_sfp_id[] = { - { "porsche_sfpA", cpld_group_a }, - { "porsche_sfpB", cpld_group_b }, - { "porsche_sfpC", cpld_group_c }, - {} -}; -MODULE_DEVICE_TABLE(i2c, porsche_sfp_id); - -static struct i2c_driver porsche_sfp_driver = { - .driver = { - .name = "pegatron_porsche_sfp", - }, - .probe = porsche_sfp_device_probe, - .remove = porsche_sfp_device_remove, - .id_table = porsche_sfp_id, - .address_list = normal_i2c, -}; - -static int __init porsche_sfp_init(void) -{ - int i; - - /*SFP 1-12*/ - for(i=0; i"); -MODULE_DESCRIPTION("porsche_cpld_mux driver"); -MODULE_LICENSE("GPL"); - -module_init(porsche_sfp_init); -module_exit(porsche_sfp_exit); - diff --git a/platform/nephos/sonic-platform-modules-pegatron/porsche/scripts/sensors b/platform/nephos/sonic-platform-modules-pegatron/porsche/scripts/sensors deleted file mode 100755 index 7f9426a0c5e..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/porsche/scripts/sensors +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -docker exec -i pmon sensors "$@" - -#To probe sensors not part of lm-sensors -if [ -r /usr/local/bin/porsche_sensors.py ]; then - python /usr/local/bin/porsche_sensors.py get_sensors -fi diff --git a/platform/nephos/sonic-platform-modules-pegatron/porsche/service/porsche-platform-init.service b/platform/nephos/sonic-platform-modules-pegatron/porsche/service/porsche-platform-init.service deleted file mode 100644 index 8e6f4344715..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/porsche/service/porsche-platform-init.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Pegastron porsche Platform initialization service -After=local-fs.target -DefaultDependencies=no - -[Service] -Type=oneshot -ExecStart=/usr/local/bin/pegatron_porsche_util.py install -ExecStop=/usr/local/bin/pegatron_porsche_util.py uninstall -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target diff --git a/platform/nephos/sonic-platform-modules-pegatron/porsche/utils/pegatron_porsche_util.py b/platform/nephos/sonic-platform-modules-pegatron/porsche/utils/pegatron_porsche_util.py deleted file mode 100755 index 16662081d0c..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/porsche/utils/pegatron_porsche_util.py +++ /dev/null @@ -1,209 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2018 Pegatron, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import sys, getopt -import logging -import os -import commands -import threading - -DEBUG = False - -SFP_MAX_NUM = 48 -CPLDA_SFP_NUM = 24 -CPLDB_SFP_NUM = 12 -CPLDC_SFP_NUM = 18 - -kernel_module = ['i2c_dev', 'i2c-mux-pca954x force_deselect_on_exit=1', 'at24', 'pegatron_porsche_cpld', 'pegatron_hwmon_mcu', 'pegatron_porsche_sfp'] -moduleID = ['pca9544', 'pca9544', '24c02', 'porsche_hwmon_mcu', 'porsche_cpld', 'porsche_cpld', 'porsche_cpld', 'porsche_sfpA', 'porsche_sfpB', 'porsche_sfpC'] -i2c_check_node = ['i2c-0', 'i2c-1'] -device_address = ['0x72', '0x73', '0x54', '0x70', '0x74', '0x75', '0x76', '0x50', '0x50', '0x50'] -device_node= ['i2c-2', 'i2c-6', 'i2c-4', 'i2c-5', 'i2c-6', 'i2c-7', 'i2c-8', 'i2c-6', 'i2c-7', 'i2c-8'] - -i2c_prefix = '/sys/bus/i2c/devices/' -cpld_bus = ['6-0074', '7-0075', '8-0076'] -led_nodes = ['sys_led', 'pwr_led', 'loc_led', 'fan_led', "cpld_allled_ctrl", "serial_led_enable"] - -def dbg_print(string): - if DEBUG == True: - print string - return - -def do_cmd(cmd, show): - logging.info('Run :' + cmd) - status, output = commands.getstatusoutput(cmd) - dbg_print(cmd + "with result:" + str(status)) - dbg_print("output:" + output) - if status: - logging.info('Failed :' + cmd) - if show: - print('Failed :' + cmd) - return status, output - -def check_device_position(num): - for i in range(0, len(i2c_check_node)): - status, output = do_cmd("echo " + moduleID[num] + " " + device_address[num] + " > " + i2c_prefix + i2c_check_node[i] + "/new_device", 0) - status, output = do_cmd("ls " + i2c_prefix + device_node[num], 0) - device_node[num] = i2c_check_node[i] - - if status: - status, output = do_cmd("echo " + device_address[num] + " > " + i2c_prefix + i2c_check_node[i] + "/delete_device", 0) - else: - return - - return - -def install_device(): - for i in range(0, len(moduleID)): - if moduleID[i] == "pca9544": - check_device_position(i) - else: - status, output = do_cmd("echo " + moduleID[i] + " " + device_address[i] + " > " + i2c_prefix + device_node[i] + "/new_device", 1) - - return - -def check_driver(): - for i in range(0, len(kernel_module)): - status, output = do_cmd("lsmod | grep " + kernel_module[i], 0) - if status: - status, output = do_cmd("modprobe " + kernel_module[i], 1) - - return - -def do_install(): - status, output = do_cmd("depmod -a", 1) - - check_driver() - install_device() - - return - -def do_uninstall(): - for i in range(0, len(kernel_module)): - status, output = do_cmd("modprobe -r " + kernel_module[i], 1) - - for i in range(0, len(moduleID)): - status, output = do_cmd("echo " + device_address[i] + " > " + i2c_prefix + i2c_check_node[i] + "/delete_device", 0) - - return - -led_command = {'sys_led': {'green':'0', 'amber':'1', 'off':'2', 'blink_green':'3', 'blink_amber':'4'}, - 'pwr_led': {'green':'0', 'amber':'1', 'off':'2', 'blink_green':'3', 'blink_amber':'4'}, - 'loc_led': {'on':'0', 'off':'1', 'blink':'2'}, - 'fan_led': {'green':'0', 'amber':'1', 'off':'2', 'blink_green':'3', 'blink_amber':'4'}, - 'cpld_allled_ctrl': {'off':'0', 'mix':'1', 'amber':'2', 'normal':'3'}, - 'serial_led_enable': {'disable':'0', 'enable':'1'}} - -def set_led(args): - """ - Usage: %(scriptName)s set led object command - - object: - sys_led : set SYS led [command: off|green|amber|blink_green|blink_amber] - pwr_led : set PWR led [command: off|green|amber|blink_green|blink_amber] - loc_led : set LOCATOR led [command: off|on|blink] - fan_led : set FAN led [command: off|green|amber|blink_green|blink_amber] - """ - if args[0] not in led_command: - print set_led.__doc__ - sys.exit(0) - - for i in range(0,len(led_nodes)): - if args[0] == led_nodes[i]: - node = i2c_prefix + cpld_bus[1] + '/'+ led_nodes[i] - - command = led_command[args[0]] - data = command[args[1]] - - status, output = do_cmd("echo "+ str(data) + " > "+ node, 1) - - return - -def set_device(args): - """ - Usage: %(scriptName)s command object - - command: - led : set status led sys_led|pwr_led|loc_led|mst_led|fan_led|digit_led - """ - - if args[0] == 'led': - set_led(args[1:]) - return - else: - print set_device.__doc__ - - return - -device_init = {'led': [['led', 'sys_led', 'green'], ['led', 'pwr_led', 'green'], ['led', 'fan_led', 'green'], ['led', 'cpld_allled_ctrl', 'normal'], ['led', 'serial_led_enable', 'enable']]} - -def pega_init(): - #set led - for i in range(0,len(device_init['led'])): - set_device(device_init['led'][i]) - - #set tx_disable - for x in range(0, SFP_MAX_NUM-1): - if x < CPLDB_SFP_NUM: - bus = cpld_bus[1] - elif x < CPLDB_SFP_NUM + CPLDA_SFP_NUM: - bus = cpld_bus[0] - else: - bus = cpld_bus[2] - - nodes = i2c_prefix + bus + '/sfp' + str(x+1) + '_tx_disable' - dbg_print("SFP_TX_DISABLE NODES: " + nodes) - status, output = do_cmd("echo 0 > "+ nodes, 1) - - return - -def main(): - """ - Usage: %(scriptName)s command object - - command: - install : install drivers and generate related sysfs nodes - clean : uninstall drivers and remove related sysfs nodes - set : change board setting [led] - debug : debug info [on/off] - """ - - if len(sys.argv)<2: - print main.__doc__ - - for arg in sys.argv[1:]: - if arg == 'install': - do_install() - pega_init() - elif arg == 'uninstall': - do_uninstall() - elif arg == 'set': - if len(sys.argv[2:])<1: - print main.__doc__ - else: - set_device(sys.argv[2:]) - return - elif arg == 'debug': - if sys.argv[2] == 'on': - DEBUG = True - else: - DEBUG = False - else: - print main.__doc__ - -if __name__ == "__main__": - main() diff --git a/platform/nephos/sonic-platform-modules-pegatron/porsche/utils/porsche_sensors.py b/platform/nephos/sonic-platform-modules-pegatron/porsche/utils/porsche_sensors.py deleted file mode 100755 index 40e23ef01b7..00000000000 --- a/platform/nephos/sonic-platform-modules-pegatron/porsche/utils/porsche_sensors.py +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/python - -import os -import sys -import logging - -FAN_NUM = 5 -sensors_path = '/sys/bus/i2c/devices/5-0070/' -sensors_nodes = {'fan_rpm': ['_inner_rpm', '_outer_rpm'], - 'fan_vol': ['ADC8_vol', 'ADC7_vol','ADC6_vol', 'ADC5_vol','ADC4_vol', 'ADC3_vol'], - 'temp':['lm75_49_temp', 'lm75_48_temp', 'SA56004_local_temp','SA56004_remote_temp']} -sensors_type = {'fan_rpm': ['Inner RPM', 'Outer RPM'], - 'fan_vol': ['P0.2', 'P0.6','P0.1', 'P1.5','P0.7', 'P1.6'], - 'temp':['lm75_49_temp', 'lm75_48_temp', 'SA56004_local_temp','SA56004_remote_temp']} - -# Get sysfs attribute -def get_attr_value(attr_path): - retval = 'ERR' - if (not os.path.isfile(attr_path)): - return retval - - try: - with open(attr_path, 'r') as fd: - retval = fd.read() - except Exception as error: - logging.error("Unable to open ", attr_path, " file !") - - retval = retval.rstrip('\r\n') - fd.close() - return retval - -def get_fan_status(number): - attr_value = get_attr_value(sensors_path + "fan" + str(number+1) + "_present") - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - - if(attr_value == 0): - string = "Connect" - else: - string = "Disconnect" - return string - -def get_fan_alert(number): - attr_value = get_attr_value(sensors_path + "fan" + str(number+1) + "_status_alert") - if (attr_value != 'ERR'): - attr_value = int(attr_value, 16) - - if(attr_value == 0): - string = "Normal" - else: - string = "Abnormal" - return string - -def get_fan_inner_rpm(number): - return get_attr_value(sensors_path + "fan" + str(number+1) + "_inner_rpm") - -def get_fan_outer_rpm(number): - return get_attr_value(sensors_path + "fan" + str(number+1) + "_outer_rpm") - -def get_fan(): - for i in range(0,FAN_NUM): - print " " - #status - string = get_fan_status(i) - print "FAN " + str(i+1) + ":" + ' ' + string - if string=='Disconnect': - continue - - #alert - string = get_fan_alert(i) - print " Status:"+ ' ' + string - - #inner rpm - string = get_fan_inner_rpm(i) - print " Inner RPM:"+ string.rjust(10) + ' RPM' - - #outer rpm - string = get_fan_outer_rpm(i) - print " Outer RPM:"+ string.rjust(10) + ' RPM' - - return - -def get_hwmon(): - print " " - string = get_attr_value(sensors_path + "lm75_48_temp") - print "Sensor A: " + string + " C" - - string = get_attr_value(sensors_path + "lm75_49_temp") - print "Sensor B: " + string + " C" - - return - -def get_voltage(): - print " " - nodes = sensors_nodes['fan_vol'] - types = sensors_type['fan_vol'] - for i in range(0,len(nodes)): - string = get_attr_value(sensors_path + nodes[i]) - print types[i] + ': ' + string + " V" - - return - -def init_fan(): - return - -def main(): - """ - Usage: %(scriptName)s command object - - command: - install : install drivers and generate related sysfs nodes - clean : uninstall drivers and remove related sysfs nodes - show : show all systen status - set : change board setting with fan|led|sfp - """ - - if len(sys.argv)<2: - print main.__doc__ - - for arg in sys.argv[1:]: - if arg == 'fan_init': - init_fan() - elif arg == 'get_sensors': - ver = get_attr_value(sensors_path + "fb_hw_version") - print 'HW Version: ' + ver - ver = get_attr_value(sensors_path + "fb_fw_version") - print 'SW Version: ' + ver - get_fan() - get_hwmon() - get_voltage() - elif arg == 'fan_set': - if len(sys.argv[1:])<1: - print main.__doc__ - else: - set_fan(sys.argv[1:]) - return - else: - print main.__doc__ - -if __name__ == "__main__": - main() diff --git a/platform/vpp b/platform/vpp index 11fe72b86cd..4c917cd33d0 160000 --- a/platform/vpp +++ b/platform/vpp @@ -1 +1 @@ -Subproject commit 11fe72b86cd7d1001a2201ac5d98a273e2815d04 +Subproject commit 4c917cd33d037d06c80950d9fdbf38d3e5a6aaeb diff --git a/src/sonic-sairedis b/src/sonic-sairedis index 19d25d08f84..b4e1c6460a9 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit 19d25d08f8481a1ab55838e25ae5cd73b0bf30f8 +Subproject commit b4e1c6460a9b5c79e0ef5df60ce4d7d2083d430b diff --git a/src/sonic-swss b/src/sonic-swss index e30cd2dc605..6bb5cb6971e 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit e30cd2dc605fbf21735a6f3b0e5c1de92cd52711 +Subproject commit 6bb5cb6971e93d5e217a18ba0ead85a022cb3d95 diff --git a/src/sonic-utilities b/src/sonic-utilities index 62785863034..92c5971e19d 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit 627858630348effec301290da9054313ec54c2ef +Subproject commit 92c5971e19daa9178f742237dccc81114a5010b0