From bb09ebe977608de7b05601a9d3a5a974bc2f18f6 Mon Sep 17 00:00:00 2001 From: FSSec <114483310+FSSec@users.noreply.github.com> Date: Sun, 18 Dec 2022 06:48:02 +0800 Subject: [PATCH] [FS][arm64] support new boars s5800-48t4s and s5800-48t8s-mars8p (#12994) Adding platform support for FS s5800-48t4s and s5800-48t8s-mars8p. Both s5800-48t4s and s5800-48t8s-mars8p have 48 * 10/100/1000 Base-T ports, 4 * 10GE SFP+ Ports on Centec TsingMa. s5800-48t4s is different from s5800-48t8s-mars8p in that: The phy chip used by s5800-48t4s is Marvell 88e1680; The phy chip used by s5800-48t4s-mars8p is Centec ctc21108; --- .../S5800-48t4s-mars8p-board.json | 444 +++++++ .../S5800-48t4s-mars8p-chip-profile.txt | 131 ++ .../S5800-48t4s-mars8p-datapath.txt | 281 +++++ .../S5800-48t4s-mars8p/buffers.json.j2 | 70 ++ .../S5800-48t4s-mars8p/pg_profile_lookup.ini | 21 + .../S5800-48t4s-mars8p/port_config.ini | 53 + .../S5800-48t4s-mars8p/qos.json.j2 | 1 + .../S5800-48t4s-mars8p/sai.profile | 4 + .../S5800-48t4s/S5800-48t4s-board.json | 471 +++++++ .../S5800-48t4s/S5800-48t4s-chip-profile.txt | 131 ++ .../S5800-48t4s/S5800-48t4s-datapath.txt | 281 +++++ .../S5800-48t4s/buffers.json.j2 | 70 ++ .../S5800-48t4s/pg_profile_lookup.ini | 21 + .../S5800-48t4s/port_config.ini | 53 + .../S5800-48t4s/qos.json.j2 | 1 + .../S5800-48t4s/sai.profile | 4 + device/fs/arm64-fs_s5800_48t4s-r0/default_sku | 1 + device/fs/arm64-fs_s5800_48t4s-r0/fancontrol | 12 + .../fs/arm64-fs_s5800_48t4s-r0/installer.conf | 0 .../fs/arm64-fs_s5800_48t4s-r0/platform_asic | 1 + .../platform_components.json | 8 + .../arm64-fs_s5800_48t4s-r0/platform_reboot | 13 + .../arm64-fs_s5800_48t4s-r0/plugins/eeprom.py | 22 + .../plugins/led_control.py | 98 ++ .../plugins/psuutil.py | 72 ++ .../plugins/sfputil.py | 166 +++ .../pmon_daemon_control.json | 3 + platform/centec-arm64/one-image.mk | 1 + platform/centec-arm64/platform-modules-fs.mk | 12 + platform/centec-arm64/rules.mk | 1 + .../48t4s/modules/Makefile | 3 + .../48t4s/modules/fs_s5800_48t4s_platform.c | 1101 +++++++++++++++++ .../48t4s/service/48t4s_platform.service | 13 + .../sonic-platform-modules-fs/48t4s/setup.py | 15 + .../48t4s/sonic_platform/__init__.py | 3 + .../48t4s/sonic_platform/chassis.py | 242 ++++ .../48t4s/sonic_platform/eeprom.py | 111 ++ .../48t4s/sonic_platform/fan.py | 186 +++ .../48t4s/sonic_platform/fan_drawer.py | 36 + .../48t4s/sonic_platform/led.py | 42 + .../48t4s/sonic_platform/platform.py | 21 + .../48t4s/sonic_platform/psu.py | 46 + .../48t4s/sonic_platform/sfp.py | 103 ++ .../48t4s/sonic_platform/thermal.py | 118 ++ .../sonic-platform-modules-fs/LICENSE | 15 + .../sonic-platform-modules-fs/README.md | 1 + .../debian/changelog | 6 + .../sonic-platform-modules-fs/debian/compat | 1 + .../sonic-platform-modules-fs/debian/control | 11 + .../debian/platform-modules-s5800-48t4s.init | 80 ++ .../platform-modules-s5800-48t4s.install | 1 + .../platform-modules-s5800-48t4s.postinst | 9 + .../sonic-platform-modules-fs/debian/rules | 98 ++ .../sonic-platform-modules-fs/fan | 1 + .../sonic-platform-modules-fs/pca954x | 1 + platform/centec-arm64/sonic_fit.its | 7 + 56 files changed, 4718 insertions(+) create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/S5800-48t4s-mars8p-board.json create mode 100755 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/S5800-48t4s-mars8p-chip-profile.txt create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/S5800-48t4s-mars8p-datapath.txt create mode 100755 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/buffers.json.j2 create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/pg_profile_lookup.ini create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/port_config.ini create mode 100755 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/qos.json.j2 create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/sai.profile create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/S5800-48t4s-board.json create mode 100755 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/S5800-48t4s-chip-profile.txt create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/S5800-48t4s-datapath.txt create mode 100755 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/buffers.json.j2 create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/pg_profile_lookup.ini create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/port_config.ini create mode 100755 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/qos.json.j2 create mode 100755 device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/sai.profile create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/default_sku create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/fancontrol create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/installer.conf create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/platform_asic create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/platform_components.json create mode 100755 device/fs/arm64-fs_s5800_48t4s-r0/platform_reboot create mode 100755 device/fs/arm64-fs_s5800_48t4s-r0/plugins/eeprom.py create mode 100755 device/fs/arm64-fs_s5800_48t4s-r0/plugins/led_control.py create mode 100755 device/fs/arm64-fs_s5800_48t4s-r0/plugins/psuutil.py create mode 100755 device/fs/arm64-fs_s5800_48t4s-r0/plugins/sfputil.py create mode 100644 device/fs/arm64-fs_s5800_48t4s-r0/pmon_daemon_control.json create mode 100644 platform/centec-arm64/platform-modules-fs.mk create mode 100755 platform/centec-arm64/sonic-platform-modules-fs/48t4s/modules/Makefile create mode 100755 platform/centec-arm64/sonic-platform-modules-fs/48t4s/modules/fs_s5800_48t4s_platform.c create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/48t4s/service/48t4s_platform.service create mode 100755 platform/centec-arm64/sonic-platform-modules-fs/48t4s/setup.py create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/__init__.py create mode 100755 platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/chassis.py create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/eeprom.py create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/fan.py create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/fan_drawer.py create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/led.py create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/platform.py create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/psu.py create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/sfp.py create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/thermal.py create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/LICENSE create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/README.md create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/debian/changelog create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/debian/compat create mode 100755 platform/centec-arm64/sonic-platform-modules-fs/debian/control create mode 100755 platform/centec-arm64/sonic-platform-modules-fs/debian/platform-modules-s5800-48t4s.init create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/debian/platform-modules-s5800-48t4s.install create mode 100644 platform/centec-arm64/sonic-platform-modules-fs/debian/platform-modules-s5800-48t4s.postinst create mode 100755 platform/centec-arm64/sonic-platform-modules-fs/debian/rules create mode 120000 platform/centec-arm64/sonic-platform-modules-fs/fan create mode 120000 platform/centec-arm64/sonic-platform-modules-fs/pca954x diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/S5800-48t4s-mars8p-board.json b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/S5800-48t4s-mars8p-board.json new file mode 100644 index 0000000000..acdebf5fbf --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/S5800-48t4s-mars8p-board.json @@ -0,0 +1,444 @@ +{ + "fibers" : [ + { + "fiber_flg" : "E_FIBER_SFP", + "mode" : "E_FIBER_ASIC_ASIC", + "cs" : "0 0 0", + "en_mode" : "E_FIBER_EN_SYSFS", + "en" : "sfp_enable", + "sysfs_path" : "/sys/class/sfp/sfp1/", + "sync_fiber_present" : 1 + }, + { + "fiber_flg" : "E_FIBER_SFP", + "mode" : "E_FIBER_ASIC_ASIC", + "cs" : "0 0 1", + "en_mode" : "E_FIBER_EN_SYSFS", + "en" : "sfp_enable", + "sysfs_path" : "/sys/class/sfp/sfp2/", + "sync_fiber_present" : 1 + }, + { + "fiber_flg" : "E_FIBER_SFP", + "mode" : "E_FIBER_ASIC_ASIC", + "cs" : "0 0 2", + "en_mode" : "E_FIBER_EN_SYSFS", + "en" : "sfp_enable", + "sysfs_path" : "/sys/class/sfp/sfp3/", + "sync_fiber_present" : 1 + }, + { + "fiber_flg" : "E_FIBER_SFP", + "mode" : "E_FIBER_ASIC_ASIC", + "cs" : "0 0 3", + "en_mode" : "E_FIBER_EN_SYSFS", + "en" : "sfp_enable", + "sysfs_path" : "/sys/class/sfp/sfp4/", + "sync_fiber_present" : 1 + } + ], + "macleds" : { + "polarity" : 1, + "maps" : [ + { + "port_id" : 14, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port52/brightness" + }, + { + "port_id" : 15, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port51/brightness" + }, + { + "port_id" : 12, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port50/brightness" + }, + { + "port_id" : 13, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port49/brightness" + } + ] + }, + "phys" : [ + { + "macid" : 1, + "busid" : 0, + "addr" : 1, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 0, + "busid" : 0, + "addr" : 0, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 3, + "busid" : 0, + "addr" : 3, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 2, + "busid" : 0, + "addr" : 2, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 5, + "busid" : 0, + "addr" : 5, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 4, + "busid" : 0, + "addr" : 4, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 7, + "busid" : 0, + "addr" : 7, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 6, + "busid" : 0, + "addr" : 6, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 17, + "busid" : 0, + "addr" : 9, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 16, + "busid" : 0, + "addr" : 8, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 19, + "busid" : 0, + "addr" : 11, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 18, + "busid" : 0, + "addr" : 10, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 21, + "busid" : 0, + "addr" : 13, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 20, + "busid" : 0, + "addr" : 12, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 23, + "busid" : 0, + "addr" : 15, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 22, + "busid" : 0, + "addr" : 14, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 9, + "busid" : 1, + "addr" : 1, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 8, + "busid" : 1, + "addr" : 0, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 11, + "busid" : 1, + "addr" : 3, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 10, + "busid" : 1, + "addr" : 2, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 33, + "busid" : 1, + "addr" : 5, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 32, + "busid" : 1, + "addr" : 4, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 35, + "busid" : 1, + "addr" : 7, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 34, + "busid" : 1, + "addr" : 6, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 37, + "busid" : 1, + "addr" : 9, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 36, + "busid" : 1, + "addr" : 8, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 39, + "busid" : 1, + "addr" : 11, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 38, + "busid" : 1, + "addr" : 10, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 41, + "busid" : 1, + "addr" : 13, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 40, + "busid" : 1, + "addr" : 12, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 43, + "busid" : 1, + "addr" : 15, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 42, + "busid" : 1, + "addr" : 14, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 25, + "busid" : 2, + "addr" : 1, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 24, + "busid" : 2, + "addr" : 0, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 27, + "busid" : 2, + "addr" : 3, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 26, + "busid" : 2, + "addr" : 2, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 49, + "busid" : 2, + "addr" : 5, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 48, + "busid" : 2, + "addr" : 4, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 51, + "busid" : 2, + "addr" : 7, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 50, + "busid" : 2, + "addr" : 6, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 53, + "busid" : 3, + "addr" : 1, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 52, + "busid" : 3, + "addr" : 0, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 55, + "busid" : 3, + "addr" : 3, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 54, + "busid" : 3, + "addr" : 2, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 57, + "busid" : 3, + "addr" : 5, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 56, + "busid" : 3, + "addr" : 4, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 59, + "busid" : 3, + "addr" : 7, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 58, + "busid" : 3, + "addr" : 6, + "base_port" : 0, + "last_port" : 7 + } + ], + "ffe" : { + "board_material" : "BOARD_MATERIAL_M4", + "config" : [ + { + "serdes_id" : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], + "is_dac" : 0, + "speed" : [1000, 100, 10], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 100, 15, 0] + }, + { + "serdes_id" : [12, 13, 14, 15], + "is_dac" : 0, + "speed" : [10000, 1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [2, 92, 15, 0] + }, + { + "serdes_id" : [12, 13, 14, 15], + "is_dac" : 1, + "speed" : [10000, 1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [8, 174, 0, 0] + } + ] + } +} diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/S5800-48t4s-mars8p-chip-profile.txt b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/S5800-48t4s-mars8p-chip-profile.txt new file mode 100755 index 0000000000..176a413f39 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/S5800-48t4s-mars8p-chip-profile.txt @@ -0,0 +1,131 @@ +#----------------- SDK Feature Support -------------- +[MPLS_SUPPORT] = 1; +[APS_SUPPORT] = 1; +[OAM_SUPPORT] = 1; +[PTP_SUPPORT] = 0; +[SYNCE_SUPPORT] = 0; +[STACKING_SUPPORT] = 1; +[BPE_SUPPORT] = 0; +[IPFIX_SUPPORT] = 1; +[MONITOR_SUPPORT] = 1; +[OVERLAY_SUPPORT] = 1; +[EFD_SUPPORT] = 1; +[FCOE_SUPPORT] = 0; +[TRILL_SUPPORT] = 0; +[WLAN_SUPPORT] = 1; +[NPM_SUPPORT] = 1; +[DOT1AE_SUPPORT] = 1; +[DTEL_SUPPORT] = 0; +[FDBSYNC_SUPPORT] = 1; + +#----------------- Chip Init Parameter -------------- +#Local chip number and global chip id +[Local chip_num] = 1 +[Local chip0] = 0 +[Local chip1] = 1 + +#Cut through mode 0: Disable; 1:10/40/100G; 2:1/10/100G; 3:1/10/40G; other:Flex, refer to CUT_THROUGH_BITMAP +[CUT_THROUGH_SPEED] = 0 +#Flex cut through mode, speed enable by bitmap, refer to ctc_port_speed_t, Notice: 10M/100M/1G treat as the same speed +[CUT_THROUGH_BITMAP] = 0 + +#Network cpu port +[CPU_NETWORK_PORT_EN] = 0 +[CPU_NETWORK_PORT_ID] = 47 + +#Enable parity error and multi-bit ecc recover +[ECC_RECOVER_EN] = 0 +[TCAM_SCAN_EN] = 0 + +#----------------- KNET Init Parameter -------------- +[KNET_EN] = 0 + +#----------------- RESILIENT HASH Init Parameter -------------- +[RESILIENT_HASH_EN] = 0 + +#----------------- FTM Init Parameter -------------- +#0: default; 1: layer3; 2: ipv6 +[FTM Profile] = 0 + +#----------------- Interrupt Init Parameter -------------- +#0: pin, 1: msi +[Interrupt_mode] = 1 +[IRQ] = 69 + +#----------------- NextHop Init Parameter -------------- +#0: SDK work in pizzbox (single chip system), 1: SDK work in multi-chip system +[Nexthop Edit Mode] = 0 +[External Nexthop Number] = 16384 +[MPLS Tunnel Number] = 1024 + +#----------------- L2 Init Parameter -------------- +[FDB Hw Learning] = 0 +[Logic Port Num] = 1024 +#0: 128 instance per port, 1: 64 instance per port, 2: 32 instance per port +[STP MODE] = 0 +[MAX_FID_NUM] = 5120 +#STEP:Sync fdb count per second +[FDB_SYNC_STEP] = 100 + +#----------------- Port Init Parameter -------------- +[PORT_STATS_ACL_EN] = 0 + +#----------------- Stats Init Parameter -------------- +[STATS_PORT_EN] = 0 +[STATS_ECMP_EN] = 0 + +#----------------- BPE Init Parameter -------------- +[BPE_BR_PORT_EXTENDER_EN] = 0 +[BPE_BR_UC_MAX_ECID] = 1024 +[BPE_BR_MC_MAX_ECID] = 4096 +[BPE_BR_PORT_BASE] = 0 + +#----------------- Ipuc Init Parameter -------------- +#0: tcam use prefix 16; 1: tcam use prefix 8 +[IPUC_TCAM_PREFIX_8] = 1 + +#----------------- QoS Init Parameter -------------- +#QoS policer number support 1K/2K/4K/8K, default 4K +[QOS_POLICER_NUM] = 4096 +#QoS port queue number support 16/8/8 BPE/4 BPE, +#When resrc_profile.cfg exist, queue number valid, +#Default 8 queue mode +#8 queue = 8 +#16 queue = 16 +#4 queue BPE = 17 +#8 queue BPE = 18 +[QOS_PORT_QUEUE_NUM] = 8 +#QoS port extend queue number support 0/4, default 0 +[QOS_PORT_EXT_QUEUE_NUM] = 0 +#QoS CPU reason queue number support 128/64/32, default 128 +[QOS_CPU_QUEUE_NUM] = 128 +[QOS_INGRESS_VLAN_POLICER_NUM] = 0 +[QOS_EGRESS_VLAN_POLICER_NUM] = 0 +[QOS_POLICER_MERGE_MODE] = 0 +#QOS service queue mode, default 0,0:logic scr port + dstport enq 1:service id + dstport enq +[QOS_SERVICE_QUEUE_MODE] = 0 +#Global enable logic dst port + dstport enq +[QOS_SERVICE_QUEUE_EGRESS_EN] = 0 + +#----------------- Stacking Init Parameter -------------- +#0: normal mode; 1: spine-leaf mode +[FABRIC MODE] = 0 +[STACKING VERSION] = 1 + +#----------------- SDK&SAI Debug Level Init Parameter -------------- +# SDK_DEBUG_TO_SYSLOG should be enable, 1 : enable ; 0 : disable +[SDK_DEBUG_TO_SYSLOG] = 0; + +# Level same as SAI_LOG_LEVEL : 0 : debug ; 1 : info ; 2 : notice ; 3 : warning ; 4 : error ; 5 : critical +[DEBUG_LOG_LEVEL_SDK] = 1 ; +[DEBUG_LOG_LEVEL_SAI] = 0; + +# CTC_ERROR_RETURN(g_error_on) in SDK to syslog, 1 : enable ; 0 : disable +[DEBUG_SDK_G_ERROR_ON] = 0; + +# SDK debug module id (scope from 1 ~47,detail to see sdk_debug_module_t.csv),default all modules +[DEBUG_SDK_MODULE] = 0; + +# part of SDK, 1 : enable in part ; 0 : disable in part +[DEBUG_SDK_CTC] = 0; +[DEBUG_SDK_SYS] = 1; diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/S5800-48t4s-mars8p-datapath.txt b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/S5800-48t4s-mars8p-datapath.txt new file mode 100644 index 0000000000..1c7f707498 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/S5800-48t4s-mars8p-datapath.txt @@ -0,0 +1,281 @@ +#Generated by 'CTC DataPath Tools' on Thu Aug 12 17:34:17 2021 +#Version 1.0, Supported by TsingMa SDK + + +#SERDES_MODE : 0-NONE, 1-XFI, 2-SGMII, 3-Not Support, 4-QSGMII, 5-XAUI, 6-DXAUI, 7-XLG, 8-CG, 9-SGMII2G5 +# 10-USXGMII-S, 11-USXGMII-M2G5, 12-USXGMII-M5G, 13-XXVG, 14-LG, 15-100BASE-FX +#SERDES_RX_POLY: 0-Normal, 1-Inverse +#SERDES_SWITCH : 0-Not Support Dynamic Switch, 1-Support Dynamic Switch + +[WLAN_ENABLE] = 1 +[DOT1AE_ENABLE] = 1 + +[CORE_PLLA] = 600 +#{ +[SERDES_ITEM] +#repeat 32 step 6 +[SERDES_ID] = 0 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 1 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 2 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 3 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 4 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 5 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 6 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 7 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 8 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 9 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 10 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 11 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 12 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 13 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 14 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 15 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 16 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 17 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 18 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 19 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 20 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 21 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 22 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 23 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 24 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 25 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 26 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 1 + +[SERDES_ID] = 27 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 1 + +[SERDES_ID] = 28 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 29 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 30 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 1 + +[SERDES_ID] = 31 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 1 + +#repeat end +#} + + +#[SERDES_TO_LPORT] +#{ +# | QSGMII/USXGMII-M2G5 | USXGMII-M5G | USXGMII-S | 100BASE-FX | SGMII/SGMII2G5/XFI | XAUI/DXAUI | XLG | XXVG | LG | CG +#---------|---------------------|-------------|-----------|------------|--------------------|------------|-----|------|----|--- +#serdes 0 |0 /1 /2 /3 |0 /1 |0 |0 |0 |0 |0 |NA |NA |NA +#serdes 1 |4 /5 /6 /7 |4 /5 |1 |1 |1 |0 |0 |NA |NA |NA +#serdes 2 |16/17/18/19 |16/17 |2 |2 |2 |0 |0 |NA |NA |NA +#serdes 3 |20/21/22/23 |20/21 |3 |3 |3 |0 |0 |NA |NA |NA +#serdes 4 |8 /9 /10/11 |8 /9 |8 |8 |8 |8 |8 |NA |NA |NA +#serdes 5 |32/33/34/35 |32/33 |9 |9 |9 |8 |8 |NA |NA |NA +#serdes 6 |36/37/38/39 |36/37 |10 |10 |10 |8 |8 |NA |NA |NA +#serdes 7 |40/41/42/43 |40/41 |11 |11 |11 |8 |8 |NA |NA |NA +#serdes 8 |24/25/26/27 |24/25 |24 |24 |24 |24 |24 |NA |NA |NA +#serdes 9 |48/49/50/51 |48/49 |25 |25 |25 |24 |24 |NA |NA |NA +#serdes 10|52/53/54/55 |52/53 |26 |26 |26 |24 |24 |NA |NA |NA +#serdes 11|56/57/58/59 |56/57 |27 |27 |27 |24 |24 |NA |NA |NA +#serdes 12|NA |NA |NA |12 |12 |12 |12 |NA |NA |NA +#serdes 13|NA |NA |NA |13 |13 |12 |12 |NA |NA |NA +#serdes 14|NA |NA |NA |14 |14 |12 |12 |NA |NA |NA +#serdes 15|NA |NA |NA |15 |15 |12 |12 |NA |NA |NA +#serdes 16|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 17|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 18|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 19|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 20|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 21|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 22|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 23|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 24|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 25|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 26|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 27|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 28|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 29|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 30|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#serdes 31|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#} diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/buffers.json.j2 b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/buffers.json.j2 new file mode 100755 index 0000000000..08e21e428b --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/buffers.json.j2 @@ -0,0 +1,70 @@ +{# Default values which will be used if no actual configura available #} +{% set default_cable = '40m' %} +{% set default_ports_num = 54 -%} + +{# Port configuration to cable length look-up table #} +{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #} +{# Roles described in the minigraph #} +{% set ports2cable = { + 'torrouter_server' : '5m', + 'leafrouter_torrouter' : '40m', + 'spinerouter_leafrouter' : '300m' + } +%} + +{%- macro cable_length(port_name) -%} + {%- set cable_len = [] -%} + {%- for local_port in DEVICE_NEIGHBOR -%} + {%- if local_port == port_name -%} + {%- if DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} + {%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} + {%- set neighbor_role = neighbor.type -%} + {%- set roles1 = switch_role + '_' + neighbor_role %} + {%- set roles2 = neighbor_role + '_' + switch_role -%} + {%- set roles1 = roles1 | lower -%} + {%- set roles2 = roles2 | lower -%} + {%- if roles1 in ports2cable -%} + {%- if cable_len.append(ports2cable[roles1]) -%}{%- endif -%} + {%- elif roles2 in ports2cable -%} + {%- if cable_len.append(ports2cable[roles2]) -%}{%- endif -%} + {%- endif -%} + {%- endif -%} + {%- endif -%} + {%- endfor -%} + {%- if cable_len -%} + {{ cable_len.0 }} + {%- else -%} + {{ default_cable }} + {%- endif -%} +{% endmacro %} + +{%- if DEVICE_METADATA is defined %} +{%- set switch_role = DEVICE_METADATA['localhost']['type'] %} +{%- endif -%} + +{# Generate list of ports if not defined #} +{% if PORT is not defined %} + {% set PORT = [] %} + {% for port_idx in range(1,default_ports_num+1) %} + {% if PORT.append("Ethernet%d" % (port_idx)) %}{% endif %} + {% endfor %} +{% endif -%} + +{% set port_names_list = [] %} +{% for port in PORT %} + {%- if port_names_list.append(port) %}{% endif %} +{% endfor %} +{% set port_names = port_names_list | join(',') -%} + +{ + "CABLE_LENGTH": { + "AZURE": { + {% for port in PORT %} + {% set cable = cable_length(port) -%} + "{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %} + + {% endfor %} + } + } +} + diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/pg_profile_lookup.ini b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/pg_profile_lookup.ini new file mode 100644 index 0000000000..a65244e69b --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/pg_profile_lookup.ini @@ -0,0 +1,21 @@ +# PG lossless profiles. +# speed cable size xon xoff threshold + 1000 5m 34816 18432 16384 0 + 10000 5m 34816 18432 16384 0 + 25000 5m 34816 18432 16384 0 + 40000 5m 34816 18432 16384 0 + 50000 5m 34816 18432 16384 0 + 100000 5m 36864 18432 18432 0 + 1000 40m 36864 18432 18432 0 + 10000 40m 36864 18432 18432 0 + 25000 40m 39936 18432 21504 0 + 40000 40m 41984 18432 23552 0 + 50000 40m 41984 18432 23552 0 + 100000 40m 54272 18432 35840 0 + 1000 300m 49152 18432 30720 0 + 10000 300m 49152 18432 30720 0 + 25000 300m 71680 18432 53248 0 + 40000 300m 94208 18432 75776 0 + 50000 300m 94208 18432 75776 0 + 100000 300m 184320 18432 165888 0 + diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/port_config.ini b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/port_config.ini new file mode 100644 index 0000000000..928267bee6 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/port_config.ini @@ -0,0 +1,53 @@ +# name lanes alias index speed fec +Ethernet0 1 eth-0-1 0 1000 none +Ethernet1 0 eth-0-2 1 1000 none +Ethernet2 3 eth-0-3 2 1000 none +Ethernet3 2 eth-0-4 3 1000 none +Ethernet4 5 eth-0-5 4 1000 none +Ethernet5 4 eth-0-6 5 1000 none +Ethernet6 7 eth-0-7 6 1000 none +Ethernet7 6 eth-0-8 7 1000 none +Ethernet8 17 eth-0-9 8 1000 none +Ethernet9 16 eth-0-10 9 1000 none +Ethernet10 19 eth-0-11 10 1000 none +Ethernet11 18 eth-0-12 11 1000 none +Ethernet12 21 eth-0-13 12 1000 none +Ethernet13 20 eth-0-14 13 1000 none +Ethernet14 23 eth-0-15 14 1000 none +Ethernet15 22 eth-0-16 15 1000 none +Ethernet16 9 eth-0-17 16 1000 none +Ethernet17 8 eth-0-18 17 1000 none +Ethernet18 11 eth-0-19 18 1000 none +Ethernet19 10 eth-0-20 19 1000 none +Ethernet20 33 eth-0-21 20 1000 none +Ethernet21 32 eth-0-22 21 1000 none +Ethernet22 35 eth-0-23 22 1000 none +Ethernet23 34 eth-0-24 23 1000 none +Ethernet24 37 eth-0-25 24 1000 none +Ethernet25 36 eth-0-26 25 1000 none +Ethernet26 39 eth-0-27 26 1000 none +Ethernet27 38 eth-0-28 27 1000 none +Ethernet28 41 eth-0-29 28 1000 none +Ethernet29 40 eth-0-30 29 1000 none +Ethernet30 43 eth-0-31 30 1000 none +Ethernet31 42 eth-0-32 31 1000 none +Ethernet32 25 eth-0-33 32 1000 none +Ethernet33 24 eth-0-34 33 1000 none +Ethernet34 27 eth-0-35 34 1000 none +Ethernet35 26 eth-0-36 35 1000 none +Ethernet36 49 eth-0-37 36 1000 none +Ethernet37 48 eth-0-38 37 1000 none +Ethernet38 51 eth-0-39 38 1000 none +Ethernet39 50 eth-0-40 39 1000 none +Ethernet40 53 eth-0-41 40 1000 none +Ethernet41 52 eth-0-42 41 1000 none +Ethernet42 55 eth-0-43 42 1000 none +Ethernet43 54 eth-0-44 43 1000 none +Ethernet44 57 eth-0-45 44 1000 none +Ethernet45 56 eth-0-46 45 1000 none +Ethernet46 59 eth-0-47 46 1000 none +Ethernet47 58 eth-0-48 47 1000 none +Ethernet48 13 eth-0-49 48 10000 none +Ethernet49 12 eth-0-50 49 10000 none +Ethernet50 15 eth-0-51 50 10000 none +Ethernet51 14 eth-0-52 51 10000 none diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/qos.json.j2 b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/qos.json.j2 new file mode 100755 index 0000000000..3e548325ea --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/qos.json.j2 @@ -0,0 +1 @@ +{%- include 'qos_config.j2' %} diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/sai.profile b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/sai.profile new file mode 100644 index 0000000000..8e358ee9bf --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s-mars8p/sai.profile @@ -0,0 +1,4 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/S5800-48t4s-mars8p-chip-profile.txt +SAI_HW_PORT_PROFILE_ID_CONFIG_FILE=/usr/share/sonic/hwsku/S5800-48t4s-mars8p-datapath.txt +SAI_PLATFORM_CFG_FILE=/usr/share/sonic/hwsku/S5800-48t4s-mars8p-board.json +SAI_PHY_DRIVER_PATH=/usr/lib/phy_drv/E530-48t4x-mars8p \ No newline at end of file diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/S5800-48t4s-board.json b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/S5800-48t4s-board.json new file mode 100644 index 0000000000..7d1c4927f4 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/S5800-48t4s-board.json @@ -0,0 +1,471 @@ +{ + "fibers" : [ + { + "fiber_flg" : "E_FIBER_SFP", + "mode" : "E_FIBER_ASIC_ASIC", + "cs" : "0 0 0", + "en_mode" : "E_FIBER_EN_SYSFS", + "en" : "sfp_enable", + "sysfs_path" : "/sys/class/sfp/sfp1/", + "sync_fiber_present" : 1 + }, + { + "fiber_flg" : "E_FIBER_SFP", + "mode" : "E_FIBER_ASIC_ASIC", + "cs" : "0 0 1", + "en_mode" : "E_FIBER_EN_SYSFS", + "en" : "sfp_enable", + "sysfs_path" : "/sys/class/sfp/sfp2/", + "sync_fiber_present" : 1 + }, + { + "fiber_flg" : "E_FIBER_SFP", + "mode" : "E_FIBER_ASIC_ASIC", + "cs" : "0 0 2", + "en_mode" : "E_FIBER_EN_SYSFS", + "en" : "sfp_enable", + "sysfs_path" : "/sys/class/sfp/sfp3/", + "sync_fiber_present" : 1 + }, + { + "fiber_flg" : "E_FIBER_SFP", + "mode" : "E_FIBER_ASIC_ASIC", + "cs" : "0 0 3", + "en_mode" : "E_FIBER_EN_SYSFS", + "en" : "sfp_enable", + "sysfs_path" : "/sys/class/sfp/sfp4/", + "sync_fiber_present" : 1 + } + ], + "macleds" : { + "polarity" : 1, + "maps" : [ + { + "port_id" : 14, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port52/brightness" + }, + { + "port_id" : 15, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port51/brightness" + }, + { + "port_id" : 12, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port50/brightness" + }, + { + "port_id" : 13, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port49/brightness" + } + ] + }, + "phys" : [ + { + "macid" : 1, + "busid" : 0, + "addr" : 1, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 0, + "busid" : 0, + "addr" : 0, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 3, + "busid" : 0, + "addr" : 3, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 2, + "busid" : 0, + "addr" : 2, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 5, + "busid" : 0, + "addr" : 5, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 4, + "busid" : 0, + "addr" : 4, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 7, + "busid" : 0, + "addr" : 7, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 6, + "busid" : 0, + "addr" : 6, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 17, + "busid" : 0, + "addr" : 9, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 16, + "busid" : 0, + "addr" : 8, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 19, + "busid" : 0, + "addr" : 11, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 18, + "busid" : 0, + "addr" : 10, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 21, + "busid" : 0, + "addr" : 13, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 20, + "busid" : 0, + "addr" : 12, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 23, + "busid" : 0, + "addr" : 15, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 22, + "busid" : 0, + "addr" : 14, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 9, + "busid" : 1, + "addr" : 1, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 8, + "busid" : 1, + "addr" : 0, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 11, + "busid" : 1, + "addr" : 3, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 10, + "busid" : 1, + "addr" : 2, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 33, + "busid" : 1, + "addr" : 5, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 32, + "busid" : 1, + "addr" : 4, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 35, + "busid" : 1, + "addr" : 7, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 34, + "busid" : 1, + "addr" : 6, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 37, + "busid" : 1, + "addr" : 9, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 36, + "busid" : 1, + "addr" : 8, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 39, + "busid" : 1, + "addr" : 11, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 38, + "busid" : 1, + "addr" : 10, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 41, + "busid" : 1, + "addr" : 13, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 40, + "busid" : 1, + "addr" : 12, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 43, + "busid" : 1, + "addr" : 15, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 42, + "busid" : 1, + "addr" : 14, + "base_port" : 8, + "last_port" : 15 + }, + { + "macid" : 25, + "busid" : 2, + "addr" : 1, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 24, + "busid" : 2, + "addr" : 0, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 27, + "busid" : 2, + "addr" : 3, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 26, + "busid" : 2, + "addr" : 2, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 49, + "busid" : 2, + "addr" : 5, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 48, + "busid" : 2, + "addr" : 4, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 51, + "busid" : 2, + "addr" : 7, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 50, + "busid" : 2, + "addr" : 6, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 53, + "busid" : 3, + "addr" : 1, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 52, + "busid" : 3, + "addr" : 0, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 55, + "busid" : 3, + "addr" : 3, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 54, + "busid" : 3, + "addr" : 2, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 57, + "busid" : 3, + "addr" : 5, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 56, + "busid" : 3, + "addr" : 4, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 59, + "busid" : 3, + "addr" : 7, + "base_port" : 0, + "last_port" : 7 + }, + { + "macid" : 58, + "busid" : 3, + "addr" : 6, + "base_port" : 0, + "last_port" : 7 + } + ], + "ffe" : { + "board_material" : "BOARD_MATERIAL_M4", + "config" : [ + { + "serdes_id" : [12, 13, 14, 15], + "is_dac" : 0, + "speed" : [10000, 1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [2, 92, 15, 0] + }, + { + "serdes_id" : [12, 13, 14, 15], + "is_dac" : 1, + "speed" : [10000, 1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [8, 174, 0, 0] + } + ] + }, + "chip_interrupt" : { + "intr_mode" : 1, + "intr_group_config" : [ + { + "group" : 0, + "irq" : 0, + "prio" : 120, + "desc" : "json msi interrupt group", + "interval" : 1000 + } + ], + "intr_config" : [ + { "group" : 0, "intr" : 0 }, + { "group" : 0, "intr" : 1 }, + { "group" : -1, "intr" : 2 }, + { "group" : 0, "intr" : 3 }, + { "group" : 0, "intr" : 4 }, + { "group" : 0, "intr" : 5 }, + { "group" : 0, "intr" : 6 }, + { "group" : 0, "intr" : 7 }, + { "group" : 0, "intr" : 9 }, + { "group" : 0, "intr" : 10 }, + { "group" : 0, "intr" : 11 }, + { "group" : 0, "intr" : 21 }, + { "group" : 0, "intr" : 17 }, + { "group" : 0, "intr" : 12 }, + { "group" : 0, "intr" : 13 }, + { "group" : 0, "intr" : 14 }, + { "group" : 0, "intr" : 15 }, + { "group" : -1, "intr" : 16 }, + { "group" : 0, "intr" : 20 }, + { "group" : 0, "intr" : 18 }, + { "group" : 0, "intr" : 22 } + ] + } +} diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/S5800-48t4s-chip-profile.txt b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/S5800-48t4s-chip-profile.txt new file mode 100755 index 0000000000..5cdf7ee0d2 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/S5800-48t4s-chip-profile.txt @@ -0,0 +1,131 @@ +#----------------- SDK Feature Support -------------- +[MPLS_SUPPORT] = 1; +[APS_SUPPORT] = 1; +[OAM_SUPPORT] = 1; +[PTP_SUPPORT] = 0; +[SYNCE_SUPPORT] = 0; +[STACKING_SUPPORT] = 1; +[BPE_SUPPORT] = 0; +[IPFIX_SUPPORT] = 1; +[MONITOR_SUPPORT] = 1; +[OVERLAY_SUPPORT] = 1; +[EFD_SUPPORT] = 1; +[FCOE_SUPPORT] = 0; +[TRILL_SUPPORT] = 0; +[WLAN_SUPPORT] = 1; +[NPM_SUPPORT] = 1; +[DOT1AE_SUPPORT] = 1; +[DTEL_SUPPORT] = 0; +[FDBSYNC_SUPPORT] = 1; + +#----------------- Chip Init Parameter -------------- +#Local chip number and global chip id +[Local chip_num] = 1 +[Local chip0] = 0 +[Local chip1] = 1 + +#Cut through mode 0: Disable; 1:10/40/100G; 2:1/10/100G; 3:1/10/40G; other:Flex, refer to CUT_THROUGH_BITMAP +[CUT_THROUGH_SPEED] = 0 +#Flex cut through mode, speed enable by bitmap, refer to ctc_port_speed_t, Notice: 10M/100M/1G treat as the same speed +[CUT_THROUGH_BITMAP] = 0 + +#Network cpu port +[CPU_NETWORK_PORT_EN] = 0 +[CPU_NETWORK_PORT_ID] = 47 + +#Enable parity error and multi-bit ecc recover +[ECC_RECOVER_EN] = 0 +[TCAM_SCAN_EN] = 0 + +#----------------- KNET Init Parameter -------------- +[KNET_EN] = 0 + +#----------------- RESILIENT HASH Init Parameter -------------- +[RESILIENT_HASH_EN] = 0 + +#----------------- FTM Init Parameter -------------- +#0: not use; 1: default; 2: layer3; 3: ipv6 +[FTM Profile] = 0 + +#----------------- Interrupt Init Parameter -------------- +#0: pin, 1: msi +[Interrupt_mode] = 1 +[IRQ] = 69 + +#----------------- NextHop Init Parameter -------------- +#0: SDK work in pizzbox (single chip system), 1: SDK work in multi-chip system +[Nexthop Edit Mode] = 0 +[External Nexthop Number] = 16384 +[MPLS Tunnel Number] = 1024 + +#----------------- L2 Init Parameter -------------- +[FDB Hw Learning] = 0 +[Logic Port Num] = 1024 +#0: 128 instance per port, 1: 64 instance per port, 2: 32 instance per port +[STP MODE] = 0 +[MAX_FID_NUM] = 5120 +#STEP:Sync fdb count per second +[FDB_SYNC_STEP] = 100 + +#----------------- Port Init Parameter -------------- +[PORT_STATS_ACL_EN] = 0 + +#----------------- Stats Init Parameter -------------- +[STATS_PORT_EN] = 0 +[STATS_ECMP_EN] = 0 + +#----------------- BPE Init Parameter -------------- +[BPE_BR_PORT_EXTENDER_EN] = 0 +[BPE_BR_UC_MAX_ECID] = 1024 +[BPE_BR_MC_MAX_ECID] = 4096 +[BPE_BR_PORT_BASE] = 0 + +#----------------- Ipuc Init Parameter -------------- +#0: tcam use prefix 16; 1: tcam use prefix 8 +[IPUC_TCAM_PREFIX_8] = 1 + +#----------------- QoS Init Parameter -------------- +#QoS policer number support 1K/2K/4K/8K, default 4K +[QOS_POLICER_NUM] = 4096 +#QoS port queue number support 16/8/8 BPE/4 BPE, +#When resrc_profile.cfg exist, queue number valid, +#Default 8 queue mode +#8 queue = 8 +#16 queue = 16 +#4 queue BPE = 17 +#8 queue BPE = 18 +[QOS_PORT_QUEUE_NUM] = 8 +#QoS port extend queue number support 0/4, default 0 +[QOS_PORT_EXT_QUEUE_NUM] = 0 +#QoS CPU reason queue number support 128/64/32, default 128 +[QOS_CPU_QUEUE_NUM] = 128 +[QOS_INGRESS_VLAN_POLICER_NUM] = 0 +[QOS_EGRESS_VLAN_POLICER_NUM] = 0 +[QOS_POLICER_MERGE_MODE] = 0 +#QOS service queue mode, default 0,0:logic scr port + dstport enq 1:service id + dstport enq +[QOS_SERVICE_QUEUE_MODE] = 0 +#Global enable logic dst port + dstport enq +[QOS_SERVICE_QUEUE_EGRESS_EN] = 0 + +#----------------- Stacking Init Parameter -------------- +#0: normal mode; 1: spine-leaf mode +[FABRIC MODE] = 0 +[STACKING VERSION] = 1 + +#----------------- SDK&SAI Debug Level Init Parameter -------------- +# SDK_DEBUG_TO_SYSLOG should be enable, 1 : enable ; 0 : disable +[SDK_DEBUG_TO_SYSLOG] = 0; + +# Level same as SAI_LOG_LEVEL : 0 : debug ; 1 : info ; 2 : notice ; 3 : warning ; 4 : error ; 5 : critical +[DEBUG_LOG_LEVEL_SDK] = 1 ; +[DEBUG_LOG_LEVEL_SAI] = 0; + +# CTC_ERROR_RETURN(g_error_on) in SDK to syslog, 1 : enable ; 0 : disable +[DEBUG_SDK_G_ERROR_ON] = 0; + +# SDK debug module id (scope from 1 ~47,detail to see sdk_debug_module_t.csv),default all modules +[DEBUG_SDK_MODULE] = 0; + +# part of SDK, 1 : enable in part ; 0 : disable in part +[DEBUG_SDK_CTC] = 0; +[DEBUG_SDK_SYS] = 1; diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/S5800-48t4s-datapath.txt b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/S5800-48t4s-datapath.txt new file mode 100644 index 0000000000..5f29c5a3b8 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/S5800-48t4s-datapath.txt @@ -0,0 +1,281 @@ +#Generated by 'CTC DataPath Tools' on Fri Aug 9 14:48:37 2019 +#Version 1.0, Supported by TsingMa SDK + + +#SERDES_MODE : 0-NONE, 1-XFI, 2-SGMII, 3-Not Support, 4-QSGMII, 5-XAUI, 6-DXAUI, 7-XLG, 8-CG, 9-SGMII2G5 +# 10-USXGMII-S, 11-USXGMII-M2G5, 12-USXGMII-M5G, 13-XXVG, 14-LG, 15-100BASE-FX +#SERDES_RX_POLY: 0-Normal, 1-Inverse +#SERDES_SWITCH : 0-Not Support Dynamic Switch, 1-Support Dynamic Switch + +[WLAN_ENABLE] = 1 +[DOT1AE_ENABLE] = 1 + +[CORE_PLLA] = 600 +#{ +[SERDES_ITEM] +#repeat 32 step 6 +[SERDES_ID] = 0 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 1 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 2 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 3 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 4 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 5 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 6 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 7 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 8 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 9 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 10 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 11 +[SERDES_MODE] = 4 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 0 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 12 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 13 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 14 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 15 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 16 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 17 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 18 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 19 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 20 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 21 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 22 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 23 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 24 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 25 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 26 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 1 + +[SERDES_ID] = 27 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 1 + +[SERDES_ID] = 28 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 29 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 + +[SERDES_ID] = 30 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 1 + +[SERDES_ID] = 31 +[SERDES_MODE] = 3 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 1 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 1 + +#repeat end +#} + + +[SERDES_TO_LPORT] +#{ + | QSGMII/USXGMII-M2G5 | USXGMII-M5G | USXGMII-S | 100BASE-FX | SGMII/SGMII2G5/XFI | XAUI/DXAUI | XLG | XXVG | LG | CG +---------|---------------------|-------------|-----------|------------|--------------------|------------|-----|------|----|--- +serdes 0 |0 /1 /2 /3 |0 /1 |0 |0 |0 |0 |0 |NA |NA |NA +serdes 1 |4 /5 /6 /7 |4 /5 |1 |1 |1 |0 |0 |NA |NA |NA +serdes 2 |16/17/18/19 |16/17 |2 |2 |2 |0 |0 |NA |NA |NA +serdes 3 |20/21/22/23 |20/21 |3 |3 |3 |0 |0 |NA |NA |NA +serdes 4 |8 /9 /10/11 |8 /9 |8 |8 |8 |8 |8 |NA |NA |NA +serdes 5 |32/33/34/35 |32/33 |9 |9 |9 |8 |8 |NA |NA |NA +serdes 6 |36/37/38/39 |36/37 |10 |10 |10 |8 |8 |NA |NA |NA +serdes 7 |40/41/42/43 |40/41 |11 |11 |11 |8 |8 |NA |NA |NA +serdes 8 |24/25/26/27 |24/25 |24 |24 |24 |24 |24 |NA |NA |NA +serdes 9 |48/49/50/51 |48/49 |25 |25 |25 |24 |24 |NA |NA |NA +serdes 10|52/53/54/55 |52/53 |26 |26 |26 |24 |24 |NA |NA |NA +serdes 11|56/57/58/59 |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 12|NA |NA |NA |12 |12 |12 |12 |NA |NA |NA +serdes 13|NA |NA |NA |13 |13 |12 |12 |NA |NA |NA +serdes 14|NA |NA |NA |14 |14 |12 |12 |NA |NA |NA +serdes 15|NA |NA |NA |15 |15 |12 |12 |NA |NA |NA +serdes 16|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 17|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 18|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 19|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 20|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 21|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 22|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 23|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 24|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 25|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 26|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 27|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 28|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 29|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 30|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +serdes 31|NA |NA |NA |NA |NA |NA |NA |NA |NA |NA +#} diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/buffers.json.j2 b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/buffers.json.j2 new file mode 100755 index 0000000000..08e21e428b --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/buffers.json.j2 @@ -0,0 +1,70 @@ +{# Default values which will be used if no actual configura available #} +{% set default_cable = '40m' %} +{% set default_ports_num = 54 -%} + +{# Port configuration to cable length look-up table #} +{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #} +{# Roles described in the minigraph #} +{% set ports2cable = { + 'torrouter_server' : '5m', + 'leafrouter_torrouter' : '40m', + 'spinerouter_leafrouter' : '300m' + } +%} + +{%- macro cable_length(port_name) -%} + {%- set cable_len = [] -%} + {%- for local_port in DEVICE_NEIGHBOR -%} + {%- if local_port == port_name -%} + {%- if DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} + {%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} + {%- set neighbor_role = neighbor.type -%} + {%- set roles1 = switch_role + '_' + neighbor_role %} + {%- set roles2 = neighbor_role + '_' + switch_role -%} + {%- set roles1 = roles1 | lower -%} + {%- set roles2 = roles2 | lower -%} + {%- if roles1 in ports2cable -%} + {%- if cable_len.append(ports2cable[roles1]) -%}{%- endif -%} + {%- elif roles2 in ports2cable -%} + {%- if cable_len.append(ports2cable[roles2]) -%}{%- endif -%} + {%- endif -%} + {%- endif -%} + {%- endif -%} + {%- endfor -%} + {%- if cable_len -%} + {{ cable_len.0 }} + {%- else -%} + {{ default_cable }} + {%- endif -%} +{% endmacro %} + +{%- if DEVICE_METADATA is defined %} +{%- set switch_role = DEVICE_METADATA['localhost']['type'] %} +{%- endif -%} + +{# Generate list of ports if not defined #} +{% if PORT is not defined %} + {% set PORT = [] %} + {% for port_idx in range(1,default_ports_num+1) %} + {% if PORT.append("Ethernet%d" % (port_idx)) %}{% endif %} + {% endfor %} +{% endif -%} + +{% set port_names_list = [] %} +{% for port in PORT %} + {%- if port_names_list.append(port) %}{% endif %} +{% endfor %} +{% set port_names = port_names_list | join(',') -%} + +{ + "CABLE_LENGTH": { + "AZURE": { + {% for port in PORT %} + {% set cable = cable_length(port) -%} + "{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %} + + {% endfor %} + } + } +} + diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/pg_profile_lookup.ini b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/pg_profile_lookup.ini new file mode 100644 index 0000000000..a65244e69b --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/pg_profile_lookup.ini @@ -0,0 +1,21 @@ +# PG lossless profiles. +# speed cable size xon xoff threshold + 1000 5m 34816 18432 16384 0 + 10000 5m 34816 18432 16384 0 + 25000 5m 34816 18432 16384 0 + 40000 5m 34816 18432 16384 0 + 50000 5m 34816 18432 16384 0 + 100000 5m 36864 18432 18432 0 + 1000 40m 36864 18432 18432 0 + 10000 40m 36864 18432 18432 0 + 25000 40m 39936 18432 21504 0 + 40000 40m 41984 18432 23552 0 + 50000 40m 41984 18432 23552 0 + 100000 40m 54272 18432 35840 0 + 1000 300m 49152 18432 30720 0 + 10000 300m 49152 18432 30720 0 + 25000 300m 71680 18432 53248 0 + 40000 300m 94208 18432 75776 0 + 50000 300m 94208 18432 75776 0 + 100000 300m 184320 18432 165888 0 + diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/port_config.ini b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/port_config.ini new file mode 100644 index 0000000000..928267bee6 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/port_config.ini @@ -0,0 +1,53 @@ +# name lanes alias index speed fec +Ethernet0 1 eth-0-1 0 1000 none +Ethernet1 0 eth-0-2 1 1000 none +Ethernet2 3 eth-0-3 2 1000 none +Ethernet3 2 eth-0-4 3 1000 none +Ethernet4 5 eth-0-5 4 1000 none +Ethernet5 4 eth-0-6 5 1000 none +Ethernet6 7 eth-0-7 6 1000 none +Ethernet7 6 eth-0-8 7 1000 none +Ethernet8 17 eth-0-9 8 1000 none +Ethernet9 16 eth-0-10 9 1000 none +Ethernet10 19 eth-0-11 10 1000 none +Ethernet11 18 eth-0-12 11 1000 none +Ethernet12 21 eth-0-13 12 1000 none +Ethernet13 20 eth-0-14 13 1000 none +Ethernet14 23 eth-0-15 14 1000 none +Ethernet15 22 eth-0-16 15 1000 none +Ethernet16 9 eth-0-17 16 1000 none +Ethernet17 8 eth-0-18 17 1000 none +Ethernet18 11 eth-0-19 18 1000 none +Ethernet19 10 eth-0-20 19 1000 none +Ethernet20 33 eth-0-21 20 1000 none +Ethernet21 32 eth-0-22 21 1000 none +Ethernet22 35 eth-0-23 22 1000 none +Ethernet23 34 eth-0-24 23 1000 none +Ethernet24 37 eth-0-25 24 1000 none +Ethernet25 36 eth-0-26 25 1000 none +Ethernet26 39 eth-0-27 26 1000 none +Ethernet27 38 eth-0-28 27 1000 none +Ethernet28 41 eth-0-29 28 1000 none +Ethernet29 40 eth-0-30 29 1000 none +Ethernet30 43 eth-0-31 30 1000 none +Ethernet31 42 eth-0-32 31 1000 none +Ethernet32 25 eth-0-33 32 1000 none +Ethernet33 24 eth-0-34 33 1000 none +Ethernet34 27 eth-0-35 34 1000 none +Ethernet35 26 eth-0-36 35 1000 none +Ethernet36 49 eth-0-37 36 1000 none +Ethernet37 48 eth-0-38 37 1000 none +Ethernet38 51 eth-0-39 38 1000 none +Ethernet39 50 eth-0-40 39 1000 none +Ethernet40 53 eth-0-41 40 1000 none +Ethernet41 52 eth-0-42 41 1000 none +Ethernet42 55 eth-0-43 42 1000 none +Ethernet43 54 eth-0-44 43 1000 none +Ethernet44 57 eth-0-45 44 1000 none +Ethernet45 56 eth-0-46 45 1000 none +Ethernet46 59 eth-0-47 46 1000 none +Ethernet47 58 eth-0-48 47 1000 none +Ethernet48 13 eth-0-49 48 10000 none +Ethernet49 12 eth-0-50 49 10000 none +Ethernet50 15 eth-0-51 50 10000 none +Ethernet51 14 eth-0-52 51 10000 none diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/qos.json.j2 b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/qos.json.j2 new file mode 100755 index 0000000000..3e548325ea --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/qos.json.j2 @@ -0,0 +1 @@ +{%- include 'qos_config.j2' %} diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/sai.profile b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/sai.profile new file mode 100755 index 0000000000..a252163610 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/S5800-48t4s/sai.profile @@ -0,0 +1,4 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/S5800-48t4s-chip-profile.txt +SAI_HW_PORT_PROFILE_ID_CONFIG_FILE=/usr/share/sonic/hwsku/S5800-48t4s-datapath.txt +SAI_PLATFORM_CFG_FILE=/usr/share/sonic/hwsku/S5800-48t4s-board.json +SAI_PHY_DRIVER_PATH=/usr/lib/phy_drv/E530-48t4x-p diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/default_sku b/device/fs/arm64-fs_s5800_48t4s-r0/default_sku new file mode 100644 index 0000000000..527c2478a2 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/default_sku @@ -0,0 +1 @@ +S5800-48t4s-mars8p l2 diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/fancontrol b/device/fs/arm64-fs_s5800_48t4s-r0/fancontrol new file mode 100644 index 0000000000..4fbc9cba36 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/fancontrol @@ -0,0 +1,12 @@ +# Configuration file generated by pwmconfig, changes will be lost +INTERVAL=10 +DEVPATH=hwmon1=devices/platform/soc/soc:fan-ctc5236 +DEVNAME=hwmon1=ctc5236fan +FCTEMPS=hwmon1/pwm1=hwmon1/temp1_input hwmon1/pwm2=hwmon1/temp1_input hwmon1/pwm3=hwmon1/temp1_input +FCFANS=hwmon1/pwm1=hwmon1/fan1_input hwmon1/pwm2=hwmon1/fan2_input hwmon1/pwm3=hwmon1/fan3_input +MINTEMP=hwmon1/pwm1=30 hwmon1/pwm2=30 hwmon1/pwm3=30 +MAXTEMP=hwmon1/pwm1=90 hwmon1/pwm2=90 hwmon1/pwm3=90 +MINSTART=hwmon1/pwm1=12 hwmon1/pwm2=12 hwmon1/pwm3=12 +MINSTOP=hwmon1/pwm1=6 hwmon1/pwm2=6 hwmon1/pwm3=6 +MINPWM=hwmon1/pwm1=6 hwmon1/pwm2=6 hwmon1/pwm3=6 +MAXPWM=hwmon1/pwm1=18 hwmon1/pwm2=18 hwmon1/pwm3=18 diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/installer.conf b/device/fs/arm64-fs_s5800_48t4s-r0/installer.conf new file mode 100644 index 0000000000..e69de29bb2 diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/platform_asic b/device/fs/arm64-fs_s5800_48t4s-r0/platform_asic new file mode 100644 index 0000000000..74dac3505e --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/platform_asic @@ -0,0 +1 @@ +centec diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/platform_components.json b/device/fs/arm64-fs_s5800_48t4s-r0/platform_components.json new file mode 100644 index 0000000000..fb48f6ae33 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/platform_components.json @@ -0,0 +1,8 @@ +{ + "chassis": { + "S5800-48t4s": { + "component": { + } + } + } +} diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/platform_reboot b/device/fs/arm64-fs_s5800_48t4s-r0/platform_reboot new file mode 100755 index 0000000000..abb89fdc19 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/platform_reboot @@ -0,0 +1,13 @@ +#!/usr/bin/python + +def main(): + # reboot the system + with open('/sys/class/gpio/export', 'w') as file: + file.write('502\n') + with open('/sys/class/gpio/gpio502/direction', 'w') as file: + file.write('out\n') + with open('/sys/class/gpio/gpio502/value', 'w') as file: + file.write('1\n') + +if __name__ == "__main__": + main() diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/plugins/eeprom.py b/device/fs/arm64-fs_s5800_48t4s-r0/plugins/eeprom.py new file mode 100755 index 0000000000..e5203721b6 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/plugins/eeprom.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +############################################################################# +# FS S5800-48T4S +# +# 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 = "/dev/mtd3" + super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/plugins/led_control.py b/device/fs/arm64-fs_s5800_48t4s-r0/plugins/led_control.py new file mode 100755 index 0000000000..53ace37775 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/plugins/led_control.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +# +# led_control.py +# +# Platform-specific LED control functionality for SONiC +# + +try: + from sonic_led.led_control_base import LedControlBase + import syslog + from socket import * + from select import * +except ImportError as e: + raise ImportError(str(e) + " - required module not found") + + +def DBG_PRINT(str): + syslog.openlog("fs-led") + syslog.syslog(syslog.LOG_INFO, str) + syslog.closelog() + + +class LedControl(LedControlBase): + """Platform specific LED control class""" + + + # Helper method to map SONiC port name to index + def _port_name_to_index(self, port_name): + # Strip "Ethernet" off port name + if not port_name.startswith(self.SONIC_PORT_NAME_PREFIX): + return -1 + + port_idx = int(port_name[len(self.SONIC_PORT_NAME_PREFIX):]) + return port_idx + 1 + + def _port_state_to_mode(self, port_idx, state): + if state == "up": + return self.LED_MODE_UP[0] if (port_idx < 49) else self.LED_MODE_UP[1] + else: + return self.LED_MODE_DOWN[0] if (port_idx < 49) else self.LED_MODE_DOWN[1] + + def _port_led_mode_update(self, port_idx, ledMode): + with open(self.f_led.format("port{}".format(port_idx)), 'w') as led_file: + led_file.write(str(ledMode)) + + def _initSystemLed(self): + try: + with open(self.f_led.format("system"), 'w') as led_file: + led_file.write("1") + DBG_PRINT("init system led to normal") + with open(self.f_led.format("idn"), 'w') as led_file: + led_file.write("1") + DBG_PRINT("init idn led to off") + except IOError as e: + DBG_PRINT(str(e)) + + def _initPanelLed(self): + with open(self.f_led.format("port1"), 'r') as led_file: + shouldInit = (int(led_file.read()) == 0) + + if shouldInit == True: + for idx in range(1, 53): + defmode = self._port_state_to_mode(idx, "down") + with open(self.f_led.format("port{}".format(idx)), 'w') as led_file: + led_file.write(str(defmode)) + DBG_PRINT("init port{} led to mode={}".format(idx, defmode)) + + def _initDefaultConfig(self): + DBG_PRINT("start init led") + + self._initSystemLed() + self._initPanelLed() + + DBG_PRINT("init led done") + + + # Concrete implementation of port_link_state_change() method + def port_link_state_change(self, portname, state): + port_idx = self._port_name_to_index(portname) + ledMode = self._port_state_to_mode(port_idx, state) + with open(self.f_led.format("port{}".format(port_idx)), 'r') as led_file: + saveMode = int(led_file.read()) + + if ledMode == saveMode: + return + + self._port_led_mode_update(port_idx, ledMode) + DBG_PRINT("update {} led mode from {} to {}".format(portname, saveMode, ledMode)) + + + # Constructor + def __init__(self): + self.SONIC_PORT_NAME_PREFIX = "Ethernet" + self.LED_MODE_UP = [2, 11] + self.LED_MODE_DOWN = [1, 7] + + self.f_led = "/sys/class/leds/{}/brightness" + self._initDefaultConfig() diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/plugins/psuutil.py b/device/fs/arm64-fs_s5800_48t4s-r0/plugins/psuutil.py new file mode 100755 index 0000000000..d4aad1b806 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/plugins/psuutil.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python + +############################################################################# +# FS +# +# Module contains an implementation of SONiC PSU Base API and +# provides the PSUs status which are available in the platform +# +############################################################################# + +try: + from sonic_psu.psu_base import PsuBase +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +class PsuUtil(PsuBase): + """Platform-specific PSUutil class""" + + def __init__(self): + PsuBase.__init__(self) + + self.psu_path = "/sys/class/psu/psu{}/" + self.psu_presence = "psu_presence" + self.psu_oper_status = "psu_status" + + def get_num_psus(self): + """ + Retrieves the number of PSUs available on the device + + :return: An integer, the number of PSUs available on the device + """ + return 2 + + def get_psu_status(self, index): + """ + Retrieves the oprational status of power supply unit (PSU) defined + by 1-based index + + :param index: An integer, 1-based index of the PSU of which to query status + :return: Boolean, True if PSU is operating properly, False if PSU is faulty + """ + if index is None: + return False + + status = 0 + try: + with open(self.psu_path.format(index) + self.psu_oper_status, 'r') as power_status: + status = int(power_status.read()) + except IOError: + return False + + return status == 1 + + def get_psu_presence(self, index): + """ + Retrieves the presence status of power supply unit (PSU) defined + by 1-based index + + :param index: An integer, 1-based index of the PSU of which to query status + :return: Boolean, True if PSU is plugged, False if not + """ + if index is None: + return False + + status = 0 + try: + with open(self.psu_path.format(index) + self.psu_presence, 'r') as presence_status: + status = int(presence_status.read()) + except IOError: + return False + + return status == 1 diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/plugins/sfputil.py b/device/fs/arm64-fs_s5800_48t4s-r0/plugins/sfputil.py new file mode 100755 index 0000000000..37ef56e9a3 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/plugins/sfputil.py @@ -0,0 +1,166 @@ +#!/usr/bin/env python + +# sfputil.py +# +# Platform-specific SFP transceiver interface for SONiC +# + +try: + import time + from socket import * + from select import * + from sonic_sfp.sfputilbase import SfpUtilBase +except ImportError as e: + raise ImportError("%s - required module not found" % str(e)) + + +def DBG_PRINT(str): + print(str + "\n") + +SFP_STATUS_INSERTED = '1' +SFP_STATUS_REMOVED = '0' + +class SfpUtil(SfpUtilBase): + """Platform-specific SfpUtil class""" + + @property + def port_start(self): + return self.PORT_START + + @property + def port_end(self): + return self.PORT_END + + @property + def sfp_base(self): + return self.SFP_BASE + + @property + def qsfp_ports(self): + return () + + @property + def port_to_eeprom_mapping(self): + return self.eeprom_mapping + + def is_logical_port(self, port_name): + return True + + def get_eeprom_data(self, port): + ret = None + port_num = self.get_logical_to_physical(port)[0] + 1 + if port_num < self.port_start or port_num > self.port_end: + return ret + if port_num < self.sfp_base: + return ret + try: + with open(self.eeprom_mapping[port_num], 'r') as eeprom_file: + ret = eeprom_file.read() + except IOError as e: + DBG_PRINT(str(e)) + + return ret + + def __init__(self): + self.SONIC_PORT_NAME_PREFIX = "Ethernet" + self.PORT_START = 0 + self.PORT_END = 51 + self.SFP_BASE = 48 + self.PORTS_IN_BLOCK = 52 + self.logical = [] + self.physical_to_logical = {} + self.logical_to_physical = {} + self.logical_to_asic = {} + self.data = {'valid':0, 'last':0} + + self.eeprom_mapping = {} + self.f_sfp_present = "/sys/class/sfp/sfp{}/sfp_presence" + self.f_sfp_enable = "/sys/class/sfp/sfp{}/sfp_enable" + for x in range(self.port_start, self.sfp_base): + self.eeprom_mapping[x] = None + for x in range(self.sfp_base, self.port_end + 1): + self.eeprom_mapping[x] = "/sys/class/sfp/sfp{}/sfp_eeprom".format(x - self.sfp_base + 1) + self.presence = {} + for x in range(self.sfp_base, self.port_end + 1): + self.presence[x] = False; + + SfpUtilBase.__init__(self) + + for x in range(self.sfp_base, self.port_end + 1): + self.logical.append('Ethernet' + str(x)) + + 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 + if port_num < self.sfp_base: + return False + try: + with open(self.f_sfp_present.format(port_num - self.sfp_base + 1), 'r') as sfp_file: + return 1 == int(sfp_file.read()) + except IOError as e: + DBG_PRINT(str(e)) + + return False + + def get_low_power_mode(self, port_num): + # Check for invalid port_num + if port_num < self.port_start or port_num > self.port_end: + return False + + return False + + def set_low_power_mode(self, port_num, lpmode): + # Check for invalid port_num + if port_num < self.port_start or port_num > self.port_end: + return False + + return False + + def reset(self, port_num): + # Check for invalid port_num + if port_num < self.port_start or port_num > self.port_end: + return False + + return False + + + def read_porttab_mappings(self, porttabfile, asic_inst = 0): + for x in range(self.sfp_base, self.port_end + 1): + self.logical_to_physical['Ethernet' + str(x)] = [x] + self.logical_to_asic['Ethernet' + str(x)] = 0 + self.physical_to_logical[x] = ['Ethernet' + str(x)] + + def get_transceiver_change_event(self, timeout=2000): + now = time.time() + port_dict = {} + + if timeout < 1000: + timeout = 1000 + timeout = (timeout) / float(1000) # Convert to secs + + if now < (self.data['last'] + timeout) and self.data['valid']: + return True, {} + + for x in range(self.sfp_base, self.port_end + 1): + presence = self.get_presence(x) + if presence != self.presence[x]: + self.presence[x] = presence + # index in port_config.ini + if presence: + port_dict[x] = SFP_STATUS_INSERTED + else: + port_dict[x] = SFP_STATUS_REMOVED + + if bool(port_dict): + self.data['last'] = now + self.data['valid'] = 1 + return True, port_dict + else: + time.sleep(0.5) + return True, {} + + def get_transceiver_info_dict(self, port_num): + transceiver_info_dict = SfpUtilBase.get_transceiver_info_dict(self, port_num) + transceiver_info_dict['vendor_rev'] = transceiver_info_dict['hardware_rev'] + return transceiver_info_dict diff --git a/device/fs/arm64-fs_s5800_48t4s-r0/pmon_daemon_control.json b/device/fs/arm64-fs_s5800_48t4s-r0/pmon_daemon_control.json new file mode 100644 index 0000000000..0db3279e44 --- /dev/null +++ b/device/fs/arm64-fs_s5800_48t4s-r0/pmon_daemon_control.json @@ -0,0 +1,3 @@ +{ + +} diff --git a/platform/centec-arm64/one-image.mk b/platform/centec-arm64/one-image.mk index 87fd7627b5..3bcb9258fc 100755 --- a/platform/centec-arm64/one-image.mk +++ b/platform/centec-arm64/one-image.mk @@ -10,6 +10,7 @@ $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(CENTEC_E530_48T4X_P_PLATFORM_MODULE) $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(CENTEC_E530_24X2C_PLATFORM_MODULE) $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(CENTEC_E530_48S4X_PLATFORM_MODULE) $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(CENTEC_E530_24X2Q_PLATFORM_MODULE) +$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(FS_S5800_48T4S_PLATFORM_MODULE) ifeq ($(INSTALL_DEBUG_TOOLS),y) $(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_DBG_IMAGES) diff --git a/platform/centec-arm64/platform-modules-fs.mk b/platform/centec-arm64/platform-modules-fs.mk new file mode 100644 index 0000000000..5942eabe20 --- /dev/null +++ b/platform/centec-arm64/platform-modules-fs.mk @@ -0,0 +1,12 @@ +# fs s5800_48t4s Platform modules + +FS_S5800_48T4S_PLATFORM_MODULE_VERSION =1.0 + +export FS_S5800_48T4S_PLATFORM_MODULE_VERSION + +FS_S5800_48T4S_PLATFORM_MODULE = platform-modules-s5800-48t4s_$(FS_S5800_48T4S_PLATFORM_MODULE_VERSION)_arm64.deb + +$(FS_S5800_48T4S_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-fs +$(FS_S5800_48T4S_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) +$(FS_S5800_48T4S_PLATFORM_MODULE)_PLATFORM = arm64-fs_s5800_48t4s-r0 +SONIC_DPKG_DEBS += $(FS_S5800_48T4S_PLATFORM_MODULE) diff --git a/platform/centec-arm64/rules.mk b/platform/centec-arm64/rules.mk index fe047bc484..d88670f130 100755 --- a/platform/centec-arm64/rules.mk +++ b/platform/centec-arm64/rules.mk @@ -6,6 +6,7 @@ include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk include $(PLATFORM_PATH)/tsingma-bsp.mk include $(PLATFORM_PATH)/platform-modules-centec-e530.mk +include $(PLATFORM_PATH)/platform-modules-fs.mk SONIC_ALL += $(SONIC_ONE_IMAGE) \ $(DOCKER_FPM) diff --git a/platform/centec-arm64/sonic-platform-modules-fs/48t4s/modules/Makefile b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/modules/Makefile new file mode 100755 index 0000000000..99efe08a76 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/modules/Makefile @@ -0,0 +1,3 @@ +KBUILD_EXTRA_SYMBOLS = /sonic/platform/centec-arm64/sonic-platform-modules-fs/pca954x/Module.symvers + +obj-m := fs_s5800_48t4s_platform.o diff --git a/platform/centec-arm64/sonic-platform-modules-fs/48t4s/modules/fs_s5800_48t4s_platform.c b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/modules/fs_s5800_48t4s_platform.c new file mode 100755 index 0000000000..17c229b1fd --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/modules/fs_s5800_48t4s_platform.c @@ -0,0 +1,1101 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SEP(XXX) 1 + +#if SEP("defines") + +#define CTC_GPIO_BASE 496 +int xirq_gpio_0 = 0; +int xirq_gpio_1 = 0; +int xirq_gpio_6 = 0; +int xirq_gpio_7 = 0; +int xirq_gpio_15 = 0; +#define IS_INVALID_PTR(_PTR_) ((_PTR_ == NULL) || IS_ERR(_PTR_)) +#define IS_VALID_PTR(_PTR_) (!IS_INVALID_PTR(_PTR_)) +#define SFP_NUM 4 +#define PORT_NUM (48+SFP_NUM) +#endif + +#if SEP("ctc:pinctl") +u8 ctc_gpio_set(u8 gpio_pin, u8 val) +{ + gpio_set_value_cansleep(gpio_pin + CTC_GPIO_BASE, val); + return 0; +} + +u8 ctc_gpio_get(u8 gpio_pin) +{ + return gpio_get_value_cansleep(gpio_pin + CTC_GPIO_BASE); +} + +u8 ctc_gpio_direction_config(u8 gpio_pin, u8 dir,u8 default_out) +{ + return dir ? gpio_direction_input(gpio_pin + CTC_GPIO_BASE) + : gpio_direction_output(gpio_pin + CTC_GPIO_BASE,default_out); +} + +static void ctc_pincrtl_init(void) +{ + /* configure mgmt-phy reset-pin output on product, mgmt-phy release must before this */ + ctc_gpio_direction_config(4, 0, 1); + /* configure power-up pin output on product */ + ctc_gpio_direction_config(6, 0, 0); + /* configure phy interrupt pin input */ + ctc_gpio_direction_config(0, 1, 0); + ctc_gpio_direction_config(1, 1, 0); + /* configure phy reset-pin output, for release phy */ + ctc_gpio_direction_config(5, 0, 1); + + return; +} + +static void ctc_irq_init(void) +{ + struct device_node *xnp; + for_each_node_by_type(xnp, "ctc-irq") + { + if (of_device_is_compatible(xnp, "centec,ctc-irq")) + { + xirq_gpio_0 = irq_of_parse_and_map(xnp, 0); + printk(KERN_INFO "ctc-irq GPIO0 IRQ is %d\n", xirq_gpio_0); + xirq_gpio_1 = irq_of_parse_and_map(xnp, 1); + printk(KERN_INFO "ctc-irq GPIO1 IRQ is %d\n", xirq_gpio_1); + xirq_gpio_15 = irq_of_parse_and_map(xnp, 2); + printk(KERN_INFO "ctc-irq GPIO15 IRQ is %d\n", xirq_gpio_15); + } + } + return; +} +#endif + +#if SEP("i2c:smbus") +static int s5800_48t4s_smbus_read_reg(struct i2c_client *client, unsigned char reg, unsigned char* value) +{ + int ret = 0; + + if (IS_INVALID_PTR(client)) + { + printk(KERN_CRIT "invalid i2c client"); + return -1; + } + + ret = i2c_smbus_read_byte_data(client, reg); + if (ret >= 0) { + *value = (unsigned char)ret; + } + else + { + *value = 0; + printk(KERN_CRIT "i2c_smbus op failed: ret=%d reg=%d\n",ret ,reg); + return ret; + } + + return 0; +} + +static int s5800_48t4s_smbus_write_reg(struct i2c_client *client, unsigned char reg, unsigned char value) +{ + int ret = 0; + + if (IS_INVALID_PTR(client)) + { + printk(KERN_CRIT "invalid i2c client"); + return -1; + } + + ret = i2c_smbus_write_byte_data(client, reg, value); + if (ret != 0) + { + printk(KERN_CRIT "i2c_smbus op failed: ret=%d reg=%d\n",ret ,reg); + return ret; + } + + return 0; +} +#endif + +#if SEP("i2c:master") +static struct i2c_adapter *i2c_adp_master = NULL; /* i2c-1-cpu */ + +static int s5800_48t4s_init_i2c_master(void) +{ + /* find i2c-core master */ + i2c_adp_master = i2c_get_adapter(0); + if(IS_INVALID_PTR(i2c_adp_master)) + { + i2c_adp_master = NULL; + printk(KERN_CRIT "s5800_48t4s_init_i2c_master can't find i2c-core bus\n"); + return -1; + } + + return 0; +} + +static int s5800_48t4s_exit_i2c_master(void) +{ + /* uninstall i2c-core master */ + if(IS_VALID_PTR(i2c_adp_master)) { + i2c_put_adapter(i2c_adp_master); + i2c_adp_master = NULL; + } + + return 0; +} +#endif + +//TODO!!! +#if SEP("i2c:gpio") +static struct i2c_adapter *i2c_adp_gpio0 = NULL; /* gpio0 */ +static struct i2c_board_info i2c_dev_gpio0 = { + I2C_BOARD_INFO("i2c-gpio0", 0x22), +}; +static struct i2c_client *i2c_client_gpio0 = NULL; + +static int s5800_48t4s_init_i2c_gpio(void) +{ + int ret = 0; + + if (IS_INVALID_PTR(i2c_adp_master)) + { + printk(KERN_CRIT "s5800_48t4s_init_i2c_gpio can't find i2c-core bus\n"); + return -1; + } + + i2c_adp_gpio0 = i2c_get_adapter(0); + if(IS_INVALID_PTR(i2c_adp_gpio0)) + { + i2c_adp_gpio0 = NULL; + printk(KERN_CRIT "get s5800_48t4s gpio0 i2c-adp failed\n"); + return -1; + } + + i2c_client_gpio0 = i2c_new_client_device(i2c_adp_gpio0, &i2c_dev_gpio0); + if(IS_INVALID_PTR(i2c_client_gpio0)) + { + i2c_client_gpio0 = NULL; + printk(KERN_CRIT "create s5800_48t4s board i2c client gpio0 failed\n"); + return -1; + } + + /* gpio0 */ + /* tx enable and release mac led and close indicate led */ + ret = s5800_48t4s_smbus_write_reg(i2c_client_gpio0, 0x02, 0xf0); + /* bank 0 : output bank 1 : input */ + ret += s5800_48t4s_smbus_write_reg(i2c_client_gpio0, 0x06, 0x00); + ret += s5800_48t4s_smbus_write_reg(i2c_client_gpio0, 0x07, 0xff); + + if (ret) + { + printk(KERN_CRIT "init s5800_48t4s board i2c gpio config failed\n"); + return -1; + } + + return 0; +} + +static int s5800_48t4s_exit_i2c_gpio(void) +{ + if(IS_VALID_PTR(i2c_client_gpio0)) { + i2c_unregister_device(i2c_client_gpio0); + i2c_client_gpio0 = NULL; + } + + if(IS_VALID_PTR(i2c_adp_gpio0)) + { + i2c_put_adapter(i2c_adp_gpio0); + i2c_adp_gpio0 = NULL; + } + + return 0; +} +#endif + + +#if SEP("drivers:psu") +static struct class* psu_class = NULL; +static struct device* psu_dev_psu1 = NULL; +static struct device* psu_dev_psu2 = NULL; + +static ssize_t s5800_48t4s_psu_read_presence(struct device *dev, struct device_attribute *attr, char *buf) +{ + int ret = 0; + unsigned char present_no = 0; + unsigned char present = 0; + unsigned char value = 0; + struct i2c_client *i2c_psu_client = NULL; + + if (psu_dev_psu1 == dev) + { + i2c_psu_client = i2c_client_gpio0; + present_no = 9; + } + else if (psu_dev_psu2 == dev) + { + i2c_psu_client = i2c_client_gpio0; + present_no = 13; + } + else + { + return sprintf(buf, "Error: unknown psu device\n"); + } + + if (IS_INVALID_PTR(i2c_psu_client)) + { + return sprintf(buf, "Error: psu i2c-adapter invalid\n"); + } + + ret = s5800_48t4s_smbus_read_reg(i2c_psu_client, present_no/8, &present); + if (ret != 0) + { + return sprintf(buf, "Error: read psu data:%s failed\n", attr->attr.name); + } + + value = ((present & (1<<(present_no%8))) ? 1 : 0 ); + + return sprintf(buf, "%d\n", value); +} + +static ssize_t s5800_48t4s_psu_read_status(struct device *dev, struct device_attribute *attr, char *buf) +{ + int ret = 0; + unsigned char workstate_no = 0; + unsigned char workstate = 0; + unsigned char value = 0; + struct i2c_client *i2c_psu_client = NULL; + + if (psu_dev_psu1 == dev) + { + i2c_psu_client = i2c_client_gpio0; + workstate_no = 11; + } + else if (psu_dev_psu2 == dev) + { + i2c_psu_client = i2c_client_gpio0; + workstate_no = 15; + } + else + { + return sprintf(buf, "Error: unknown psu device\n"); + } + + if (IS_INVALID_PTR(i2c_psu_client)) + { + return sprintf(buf, "Error: psu i2c-adapter invalid\n"); + } + + ret = s5800_48t4s_smbus_read_reg(i2c_psu_client, workstate_no/8, &workstate); + if (ret != 0) + { + return sprintf(buf, "Error: read psu data:%s failed\n", attr->attr.name); + } + + value = ((workstate & (1<<(workstate_no%8))) ? 0 : 1 ); + + return sprintf(buf, "%d\n", value); +} + +static DEVICE_ATTR(psu_presence, S_IRUGO, s5800_48t4s_psu_read_presence, NULL); +static DEVICE_ATTR(psu_status, S_IRUGO, s5800_48t4s_psu_read_status, NULL); + +static int s5800_48t4s_init_psu(void) +{ + int ret = 0; + + psu_class = class_create(THIS_MODULE, "psu"); + if (IS_INVALID_PTR(psu_class)) + { + psu_class = NULL; + printk(KERN_CRIT "create s5800_48t4s class psu failed\n"); + return -1; + } + + psu_dev_psu1 = device_create(psu_class, NULL, MKDEV(222,0), NULL, "psu1"); + if (IS_INVALID_PTR(psu_dev_psu1)) + { + psu_dev_psu1 = NULL; + printk(KERN_CRIT "create s5800_48t4s psu1 device failed\n"); + return -1; + } + + psu_dev_psu2 = device_create(psu_class, NULL, MKDEV(222,1), NULL, "psu2"); + if (IS_INVALID_PTR(psu_dev_psu2)) + { + psu_dev_psu2 = NULL; + printk(KERN_CRIT "create s5800_48t4s psu2 device failed\n"); + return -1; + } + + ret = device_create_file(psu_dev_psu1, &dev_attr_psu_presence); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s psu1 device attr:presence failed\n"); + return -1; + } + + ret = device_create_file(psu_dev_psu1, &dev_attr_psu_status); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s psu1 device attr:status failed\n"); + return -1; + } + + ret = device_create_file(psu_dev_psu2, &dev_attr_psu_presence); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s psu2 device attr:presence failed\n"); + return -1; + } + + ret = device_create_file(psu_dev_psu2, &dev_attr_psu_status); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s psu2 device attr:status failed\n"); + return -1; + } + + return 0; +} + +static int s5800_48t4s_exit_psu(void) +{ + if (IS_VALID_PTR(psu_dev_psu1)) + { + device_remove_file(psu_dev_psu1, &dev_attr_psu_presence); + device_remove_file(psu_dev_psu1, &dev_attr_psu_status); + device_destroy(psu_class, MKDEV(222,0)); + } + + if (IS_VALID_PTR(psu_dev_psu2)) + { + device_remove_file(psu_dev_psu2, &dev_attr_psu_presence); + device_remove_file(psu_dev_psu2, &dev_attr_psu_status); + device_destroy(psu_class, MKDEV(222,1)); + } + + if (IS_VALID_PTR(psu_class)) + { + class_destroy(psu_class); + psu_class = NULL; + } + + return 0; +} +#endif + +#if SEP("drivers:leds") +extern void s5800_48t4s_led_set(struct led_classdev *led_cdev, enum led_brightness set_value); +extern enum led_brightness s5800_48t4s_led_get(struct led_classdev *led_cdev); +extern void s5800_48t4s_led_port_set(struct led_classdev *led_cdev, enum led_brightness set_value); +extern enum led_brightness s5800_48t4s_led_port_get(struct led_classdev *led_cdev); + +static struct led_classdev led_dev_system = { + .name = "system", + .brightness_set = s5800_48t4s_led_set, + .brightness_get = s5800_48t4s_led_get, +}; +static struct led_classdev led_dev_idn = { + .name = "idn", + .brightness_set = s5800_48t4s_led_set, + .brightness_get = s5800_48t4s_led_get, +}; +static struct led_classdev led_dev_fan1 = { + .name = "fan1", + .brightness_set = s5800_48t4s_led_set, + .brightness_get = s5800_48t4s_led_get, +}; +static struct led_classdev led_dev_fan2 = { + .name = "fan2", + .brightness_set = s5800_48t4s_led_set, + .brightness_get = s5800_48t4s_led_get, +}; +static struct led_classdev led_dev_fan3 = { + .name = "fan3", + .brightness_set = s5800_48t4s_led_set, + .brightness_get = s5800_48t4s_led_get, +}; +static struct led_classdev led_dev_fan4 = { + .name = "fan4", + .brightness_set = s5800_48t4s_led_set, + .brightness_get = s5800_48t4s_led_get, +}; +static struct led_classdev led_dev_psu1 = { + .name = "psu1", + .brightness_set = s5800_48t4s_led_set, + .brightness_get = s5800_48t4s_led_get, +}; +static struct led_classdev led_dev_psu2 = { + .name = "psu2", + .brightness_set = s5800_48t4s_led_set, + .brightness_get = s5800_48t4s_led_get, +}; +static struct led_classdev led_dev_port[PORT_NUM] = { +{ .name = "port1", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port2", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port3", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port4", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port5", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port6", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port7", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port8", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port9", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port10", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port11", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port12", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port13", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port14", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port15", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port16", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port17", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port18", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port19", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port20", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port21", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port22", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port23", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port24", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port25", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port26", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port27", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port28", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port29", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port30", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port31", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port32", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port33", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port34", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port35", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port36", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port37", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port38", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port39", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port40", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port41", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port42", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port43", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port44", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port45", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port46", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port47", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port48", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port49", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port50", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port51", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +{ .name = "port52", .brightness_set = s5800_48t4s_led_port_set, .brightness_get = s5800_48t4s_led_port_get,}, +}; +static unsigned char port_led_mode[PORT_NUM] = {0}; + +void s5800_48t4s_led_set(struct led_classdev *led_cdev, enum led_brightness set_value) +{ + int ret = 0; + unsigned char reg = 0; + unsigned char mask = 0; + unsigned char shift = 0; + unsigned char led_value = 0; + struct i2c_client *i2c_led_client = i2c_client_gpio0; + + if (0 == strcmp(led_dev_system.name, led_cdev->name)) + { + reg = 0x2; + mask = 0x60; + shift = 5; + } + else if (0 == strcmp(led_dev_idn.name, led_cdev->name)) + { + reg = 0x2; + mask = 0x10; + shift = 4; + } + else if (0 == strcmp(led_dev_fan1.name, led_cdev->name)) + { + goto not_support; + } + else if (0 == strcmp(led_dev_fan2.name, led_cdev->name)) + { + goto not_support; + } + else if (0 == strcmp(led_dev_fan3.name, led_cdev->name)) + { + goto not_support; + } + else if (0 == strcmp(led_dev_fan4.name, led_cdev->name)) + { + goto not_support; + } + else if (0 == strcmp(led_dev_psu1.name, led_cdev->name)) + { + goto not_support; + } + else if (0 == strcmp(led_dev_psu2.name, led_cdev->name)) + { + goto not_support; + } + else + { + goto not_support; + } + + ret = s5800_48t4s_smbus_read_reg(i2c_led_client, reg, &led_value); + if (ret != 0) + { + printk(KERN_CRIT "Error: read %s led attr failed\n", led_cdev->name); + return; + } + + led_value = ((led_value & (~mask)) | ((set_value << shift) & (mask))); + + ret = s5800_48t4s_smbus_write_reg(i2c_led_client, reg, led_value); + if (ret != 0) + { + printk(KERN_CRIT "Error: write %s led attr failed\n", led_cdev->name); + return; + } + + return; + +not_support: + + printk(KERN_INFO "Error: led not support device:%s\n", led_cdev->name); + return; +} + +enum led_brightness s5800_48t4s_led_get(struct led_classdev *led_cdev) +{ + int ret = 0; + unsigned char reg = 0; + unsigned char mask = 0; + unsigned char shift = 0; + unsigned char led_value = 0; + struct i2c_client *i2c_led_client = i2c_client_gpio0; + + if (0 == strcmp(led_dev_system.name, led_cdev->name)) + { + reg = 0x2; + mask = 0x60; + shift = 5; + } + else if (0 == strcmp(led_dev_idn.name, led_cdev->name)) + { + reg = 0x2; + mask = 0x10; + shift = 4; + } + else if (0 == strcmp(led_dev_fan1.name, led_cdev->name)) + { + goto not_support; + } + else if (0 == strcmp(led_dev_fan2.name, led_cdev->name)) + { + goto not_support; + } + else if (0 == strcmp(led_dev_fan3.name, led_cdev->name)) + { + goto not_support; + } + else if (0 == strcmp(led_dev_fan4.name, led_cdev->name)) + { + goto not_support; + } + else if (0 == strcmp(led_dev_psu1.name, led_cdev->name)) + { + goto not_support; + } + else if (0 == strcmp(led_dev_psu2.name, led_cdev->name)) + { + goto not_support; + } + else + { + goto not_support; + } + + ret = s5800_48t4s_smbus_read_reg(i2c_led_client, reg, &led_value); + if (ret != 0) + { + printk(KERN_CRIT "Error: read %s led attr failed\n", led_cdev->name); + return 0; + } + + led_value = ((led_value & mask) >> shift); + + return led_value; + +not_support: + + printk(KERN_INFO "Error: not support device:%s\n", led_cdev->name); + return 0; +} + +void s5800_48t4s_led_port_set(struct led_classdev *led_cdev, enum led_brightness set_value) +{ + int portNum = 0; + + sscanf(led_cdev->name, "port%d", &portNum); + + port_led_mode[portNum-1] = set_value; + + return; +} + +enum led_brightness s5800_48t4s_led_port_get(struct led_classdev *led_cdev) +{ + int portNum = 0; + + sscanf(led_cdev->name, "port%d", &portNum); + + return port_led_mode[portNum-1]; +} + +static int s5800_48t4s_init_led(void) +{ + int ret = 0; + int i = 0; + + ret = led_classdev_register(NULL, &led_dev_system); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s led_dev_system device failed\n"); + return -1; + } + + ret = led_classdev_register(NULL, &led_dev_idn); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s led_dev_idn device failed\n"); + return -1; + } + + ret = led_classdev_register(NULL, &led_dev_fan1); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s led_dev_fan1 device failed\n"); + return -1; + } + + ret = led_classdev_register(NULL, &led_dev_fan2); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s led_dev_fan2 device failed\n"); + return -1; + } + + ret = led_classdev_register(NULL, &led_dev_fan3); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s led_dev_fan3 device failed\n"); + return -1; + } + + ret = led_classdev_register(NULL, &led_dev_fan4); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s led_dev_fan4 device failed\n"); + return -1; + } + + ret = led_classdev_register(NULL, &led_dev_psu1); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s led_dev_psu1 device failed\n"); + return -1; + } + + ret = led_classdev_register(NULL, &led_dev_psu2); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s led_dev_psu2 device failed\n"); + return -1; + } + + for (i=0; i SFP_NUM)) + { + printk(KERN_CRIT "sfp read presence, invalid port number!\n"); + buf[0] = '\0'; + return 0; + } + + spin_lock_irqsave(&(sfp_info[portNum].lock), flags); + presence = sfp_info[portNum].presence; + spin_unlock_irqrestore(&(sfp_info[portNum].lock), flags); + return sprintf(buf, "%d\n", presence); +} + +static ssize_t s5800_48t4s_sfp_write_presence(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) +{ + int portNum = 0; + const char *name = dev_name(dev); + unsigned long flags = 0; + int presence = simple_strtol(buf, NULL, 10); + + sscanf(name, "sfp%d", &portNum); + + if ((portNum < 1) || (portNum > SFP_NUM)) + { + printk(KERN_CRIT "sfp read presence, invalid port number!\n"); + return size; + } + + spin_lock_irqsave(&(sfp_info[portNum].lock), flags); + sfp_info[portNum].presence = presence; + spin_unlock_irqrestore(&(sfp_info[portNum].lock), flags); + + return size; +} + +static ssize_t s5800_48t4s_sfp_read_enable(struct device *dev, struct device_attribute *attr, char *buf) +{ + int ret = 0; + unsigned char value = 0; + unsigned char reg_no = 0; + unsigned char input_bank = 0; + int portNum = 0; + const char *name = dev_name(dev); + struct i2c_client *i2c_sfp_client = NULL; + + sscanf(name, "sfp%d", &portNum); + + if ((portNum < 1) || (portNum > SFP_NUM)) + { + printk(KERN_CRIT "sfp read enable, invalid port number!\n"); + value = 0; + } + + reg_no = portNum - 1; + i2c_sfp_client = i2c_client_gpio0; + + input_bank = (reg_no/8) + 0x2; + ret = s5800_48t4s_smbus_read_reg(i2c_sfp_client, input_bank, &value); + if (ret != 0) + { + return sprintf(buf, "Error: read sfp enable: %s failed\n", attr->attr.name); + } + + value = ((value & (1<<(reg_no%8))) ? 0 : 1 ); + + return sprintf(buf, "%d\n", value); +} + +static ssize_t s5800_48t4s_sfp_write_enable(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) +{ + int ret = 0; + unsigned char value = 0; + unsigned char set_value = simple_strtol(buf, NULL, 10); + unsigned char reg_no = 0; + unsigned char input_bank = 0; + unsigned char output_bank = 0; + int portNum = 0; + const char *name = dev_name(dev); + struct i2c_client *i2c_sfp_client = NULL; + + sscanf(name, "sfp%d", &portNum); + + if ((portNum < 1) || (portNum > SFP_NUM)) + { + printk(KERN_CRIT "sfp read enable, invalid port number!\n"); + return size; + } + + reg_no = portNum - 1; + i2c_sfp_client = i2c_client_gpio0; + + set_value = ((set_value > 0) ? 0 : 1); + + input_bank = (reg_no/8) + 0x2; + ret = s5800_48t4s_smbus_read_reg(i2c_sfp_client, input_bank, &value); + if (ret != 0) + { + printk(KERN_CRIT "Error: read %s enable failed\n", name); + return size; + } + + if (set_value) + { + value = (value | (1<<(reg_no % 8))); + } + else + { + value = (value & (~(1<<(reg_no % 8)))); + } + + output_bank = (reg_no/8) + 0x2; + ret = s5800_48t4s_smbus_write_reg(i2c_sfp_client, output_bank, value); + if (ret != 0) + { + printk(KERN_CRIT "Error: write %s enable failed\n", name); + return size; + } + + return size; +} + +static ssize_t s5800_48t4s_sfp_read_eeprom(struct device *dev, struct device_attribute *attr, char *buf) +{ + int portNum = 0; + const char *name = dev_name(dev); + unsigned long flags = 0; + size_t size = 0; + + sscanf(name, "sfp%d", &portNum); + + if ((portNum < 1) || (portNum > SFP_NUM)) + { + printk(KERN_CRIT "sfp read eeprom, invalid port number!\n"); + buf[0] = '\0'; + return 0; + } + + spin_lock_irqsave(&(sfp_info[portNum].lock), flags); + memcpy(buf, sfp_info[portNum].data, sfp_info[portNum].data_len); + size = sfp_info[portNum].data_len; + spin_unlock_irqrestore(&(sfp_info[portNum].lock), flags); + + return size; +} + +static ssize_t s5800_48t4s_sfp_write_eeprom(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) +{ + int portNum = 0; + const char *name = dev_name(dev); + unsigned long flags = 0; + + sscanf(name, "sfp%d", &portNum); + + if ((portNum < 1) || (portNum > SFP_NUM)) + { + printk(KERN_CRIT "sfp write eeprom, invalid port number!\n"); + return size; + } + + spin_lock_irqsave(&(sfp_info[portNum].lock), flags); + memcpy(sfp_info[portNum].data, buf, size); + sfp_info[portNum].data_len = size; + spin_unlock_irqrestore(&(sfp_info[portNum].lock), flags); + + return size; +} + +static DEVICE_ATTR(sfp_presence, S_IRUGO|S_IWUSR, s5800_48t4s_sfp_read_presence, s5800_48t4s_sfp_write_presence); +static DEVICE_ATTR(sfp_enable, S_IRUGO|S_IWUSR, s5800_48t4s_sfp_read_enable, s5800_48t4s_sfp_write_enable); +static DEVICE_ATTR(sfp_eeprom, S_IRUGO|S_IWUSR, s5800_48t4s_sfp_read_eeprom, s5800_48t4s_sfp_write_eeprom); +static int s5800_48t4s_init_sfp(void) +{ + int ret = 0; + int i = 0; + + sfp_class = class_create(THIS_MODULE, "sfp"); + if (IS_INVALID_PTR(sfp_class)) + { + sfp_class = NULL; + printk(KERN_CRIT "create s5800_48t4s class sfp failed\n"); + return -1; + } + + for (i=1; i<=SFP_NUM; i++) + { + memset(&(sfp_info[i].data), 0, MAX_SFP_EEPROM_DATA_LEN+1); + sfp_info[i].data_len = 0; + spin_lock_init(&(sfp_info[i].lock)); + + sfp_dev[i] = device_create(sfp_class, NULL, MKDEV(223,i), NULL, "sfp%d", i); + if (IS_INVALID_PTR(sfp_dev[i])) + { + sfp_dev[i] = NULL; + printk(KERN_CRIT "create s5800_48t4s sfp[%d] device failed\n", i); + continue; + } + + ret = device_create_file(sfp_dev[i], &dev_attr_sfp_presence); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s sfp[%d] device attr:presence failed\n", i); + continue; + } + + ret = device_create_file(sfp_dev[i], &dev_attr_sfp_enable); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s sfp[%d] device attr:enable failed\n", i); + continue; + } + + ret = device_create_file(sfp_dev[i], &dev_attr_sfp_eeprom); + if (ret != 0) + { + printk(KERN_CRIT "create s5800_48t4s sfp[%d] device attr:eeprom failed\n", i); + continue; + } + } + + return ret; +} + +static int s5800_48t4s_exit_sfp(void) +{ + int i = 0; + + for (i=1; i<=SFP_NUM; i++) + { + if (IS_VALID_PTR(sfp_dev[i])) + { + device_remove_file(sfp_dev[i], &dev_attr_sfp_presence); + device_remove_file(sfp_dev[i], &dev_attr_sfp_enable); + device_remove_file(sfp_dev[i], &dev_attr_sfp_eeprom); + device_destroy(sfp_class, MKDEV(223,i)); + sfp_dev[i] = NULL; + } + } + + if (IS_VALID_PTR(sfp_class)) + { + class_destroy(sfp_class); + sfp_class = NULL; + } + + return 0; +} +#endif + +static int s5800_48t4s_init(void) +{ + int ret = 0; + int failed = 0; + + printk(KERN_ALERT "install s5800_48t4s board dirver...\n"); + + ctc_irq_init(); + ctc_pincrtl_init(); + + ret = s5800_48t4s_init_i2c_master(); + if (ret != 0) + { + failed = 1; + } + + ret = s5800_48t4s_init_i2c_gpio(); + if (ret != 0) + { + failed = 1; + } + + ret = s5800_48t4s_init_psu(); + if (ret != 0) + { + failed = 1; + } + + ret = s5800_48t4s_init_led(); + if (ret != 0) + { + failed = 1; + } + + ret = s5800_48t4s_init_sfp(); + if (ret != 0) + { + failed = 1; + } + + if (failed) + printk(KERN_INFO "install s5800_48t4s board driver failed\n"); + else + printk(KERN_ALERT "install s5800_48t4s board dirver...ok\n"); + + return 0; +} + +static void s5800_48t4s_exit(void) +{ + printk(KERN_INFO "uninstall s5800_48t4s board dirver...\n"); + + s5800_48t4s_exit_sfp(); + s5800_48t4s_exit_led(); + s5800_48t4s_exit_psu(); + s5800_48t4s_exit_i2c_gpio(); + s5800_48t4s_exit_i2c_master(); +} + +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_AUTHOR("sec "); +MODULE_DESCRIPTION("s5800-48t4s board driver"); +module_init(s5800_48t4s_init); +module_exit(s5800_48t4s_exit); diff --git a/platform/centec-arm64/sonic-platform-modules-fs/48t4s/service/48t4s_platform.service b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/service/48t4s_platform.service new file mode 100644 index 0000000000..31b085f991 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/service/48t4s_platform.service @@ -0,0 +1,13 @@ +[Unit] +Description=FS modules init +After=local-fs.target +Before=syncd.service + +[Service] +Type=oneshot +ExecStart=-/etc/init.d/platform-modules-s5800-48t4s start +ExecStop=-/etc/init.d/platform-modules-s5800-48t4s stop +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/platform/centec-arm64/sonic-platform-modules-fs/48t4s/setup.py b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/setup.py new file mode 100755 index 0000000000..fd62ac3f63 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/setup.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +import os +from setuptools import setup +os.listdir + +setup( + name='sonic_platform', + version='1.0', + description='Module to initialize fs s5800-48t4s platforms', + + packages=['sonic_platform'], + package_dir={'sonic_platform': 'sonic_platform'}, +) + diff --git a/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/__init__.py b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/__init__.py new file mode 100644 index 0000000000..eee2e873db --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/__init__.py @@ -0,0 +1,3 @@ +__all__ = ["platform", "chassis", "sfp", "eeprom", "psu", "thermal", "fan", "fan_drawer", "led"] +from . import platform + diff --git a/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/chassis.py b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/chassis.py new file mode 100755 index 0000000000..8f9f2aec64 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/chassis.py @@ -0,0 +1,242 @@ +#!/usr/bin/env python +# +# Name: chassis.py, version: 1.0 +# +# Description: Module contains the definitions of SONiC platform APIs +# + +try: + import os + import re + import time + from sonic_platform_base.chassis_base import ChassisBase + from sonic_platform.eeprom import Eeprom + from sonic_platform.fan_drawer import FanDrawer + from sonic_platform.thermal import Thermal + from sonic_platform.sfp import Sfp + from sonic_platform.psu import Psu + +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +NUM_FAN_TRAY = 1 +NUM_THERMAL = 1 +NUM_PORT = 52 +NUM_PSU = 2 + +REBOOT_CAUSE_DIR = "/host/reboot-cause/" +REBOOT_CAUSE_FILE = os.path.join(REBOOT_CAUSE_DIR, "reboot-cause.txt") + +class Chassis(ChassisBase): + + # System status LED + _led = None + + def __init__(self): + ChassisBase.__init__(self) + + self.sfp_presence = {} + + # Initialize EEPROM + self._eeprom = Eeprom() + # Initialize FAN + for i in range(NUM_FAN_TRAY): + fandrawer = FanDrawer(i) + self._fan_drawer_list.append(fandrawer) + self._fan_list.extend(fandrawer._fan_list) + # Initialize THERMAL + for index in range(0, NUM_THERMAL): + thermal = Thermal(index) + self._thermal_list.append(thermal) + # Initialize SFP + for index in range(0, NUM_PORT): + sfp = Sfp(index) + self._sfp_list.append(sfp) + self.sfp_presence[int(index)] = False + # Initialize PSU + for index in range(0, NUM_PSU): + psu = Psu(index + 1) + self._psu_list.append(psu) + +############################################## +# Device methods +############################################## + + def get_name(self): + """ + Retrieves the name of the chassis + Returns: + string: The name of the chassis + """ + return self._eeprom.modelstr() + + def get_presence(self): + """ + Retrieves the presence of the chassis + Returns: + bool: True if chassis is present, False if not + """ + return True + + def get_model(self): + """ + Retrieves the model number (or part number) of the chassis + Returns: + string: Model/part number of chassis + """ + return self._eeprom.part_number_str() + + def get_serial(self): + """ + Retrieves the serial number of the chassis + Returns: + string: Serial number of chassis + """ + return self._eeprom.serial_number_str() + + def get_status(self): + """ + Retrieves the operational status of the chassis + Returns: + bool: A boolean value, True if chassis is operating properly + False if not + """ + return True + +############################################## +# Chassis methods +############################################## + + def get_base_mac(self): + """ + Retrieves the base MAC address for the chassis + + Returns: + A string containing the MAC address in the format + 'XX:XX:XX:XX:XX:XX' + """ + return self._eeprom.base_mac_addr() + + def get_serial_number(self): + """ + Retrieves the hardware serial number for the chassis + + Returns: + A string containing the hardware serial number for this chassis. + """ + return self._eeprom.serial_number_str() + + def get_system_eeprom_info(self): + """ + Retrieves the full content of system EEPROM information for the chassis + + Returns: + A dictionary where keys are the type code defined in + OCP ONIE TlvInfo EEPROM format and values are their corresponding + values. + Ex. { '0x21':'AG9064', '0x22':'V1.0', '0x23':'AG9064-0109867821', + '0x24':'001c0f000fcd0a', '0x25':'02/03/2018 16:22:00', + '0x26':'01', '0x27':'REV01', '0x28':'AG9064-C2358-16G'} + """ + return self._eeprom.system_eeprom_info() + + def get_reboot_cause(self): + """ + Retrieves the cause of the previous reboot + Returns: + A tuple (string, string) where the first element is a string + containing the cause of the previous reboot. This string must be + one of the predefined strings in this class. If the first string + is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used + to pass a description of the reboot cause. + """ + if os.path.exists(REBOOT_CAUSE_FILE): + with open(REBOOT_CAUSE_FILE) as reboot_cause_file: + reboot_cause = reboot_cause_file.readline() + if re.search(r'User issued', reboot_cause) is None: + return (self.REBOOT_CAUSE_POWER_LOSS, None) + else: + return (self.REBOOT_CAUSE_NON_HARDWARE, None) + else: + return (self.REBOOT_CAUSE_POWER_LOSS, None) + + def get_change_event(self, timeout=2000): + """ + Returns a nested dictionary containing all devices which have + experienced a change at chassis level + + Args: + timeout: Timeout in milliseconds (optional). If timeout == 0, + this method will block until a change is detected. + + Returns: + (bool, dict): + - True if call successful, False if not; + - A nested dictionary where key is a device type, + value is a dictionary with key:value pairs in the + format of {'device_id':'device_event'}, + where device_id is the device ID for this device and + device_event, + status='1' represents device inserted, + status='0' represents device removed. + Ex. {'fan':{'0':'0', '2':'1'}, 'sfp':{'11':'0'}} + indicates that fan 0 has been removed, fan 2 + has been inserted and sfp 11 has been removed. + """ + SFP_STATUS_INSERTED = '1' + SFP_STATUS_REMOVED = '0' + + old = time.time() + timeout = (timeout) / float(1000) # Convert to secs + port_dict = {} + + while time.time() - old < timeout or timeout == 0: + for sfp in self._sfp_list: + sfp_presence = sfp.get_presence() + if sfp_presence != self.sfp_presence[sfp._index]: + self.sfp_presence[sfp._index] = sfp_presence + if sfp_presence: + port_dict[sfp._index] = SFP_STATUS_INSERTED + else: + port_dict[sfp._index] = SFP_STATUS_REMOVED + + if not bool(port_dict): + time.sleep(0.5) + else: + break + + ret_dict = {'sfp': port_dict} + return True, ret_dict + + def get_num_psus(self): + return len(self._psu_list) + + def get_psu(self, psu_index): + return self._psu_list[psu_index] + + def initizalize_system_led(self): + from .led import SystemLed + Chassis._led = SystemLed() + + def set_status_led(self, color): + """ + Sets the state of the system LED + + Args: + color: A string representing the color with which to set the + system LED + + Returns: + bool: True if system LED state is set successfully, False if not + """ + return False if not Chassis._led else Chassis._led.set_status(color) + + def get_status_led(self): + """ + Gets the state of the system LED + + Returns: + A string, one of the valid LED color strings which could be vendor + specified. + """ + return None if not Chassis._led else Chassis._led.get_status() diff --git a/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/eeprom.py b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/eeprom.py new file mode 100644 index 0000000000..77e3e82df1 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/eeprom.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python +# +# Name: eeprom.py, version: 1.0 +# +# Description: Module contains the definitions of SONiC platform APIs +# + +try: + from sonic_eeprom import eeprom_tlvinfo + import binascii +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +class Eeprom(eeprom_tlvinfo.TlvInfoDecoder): + + def __init__(self): + self.__eeprom_path = "/dev/mtd3" + super(Eeprom, self).__init__(self.__eeprom_path, 0, '', True) + self.__eeprom_tlv_dict = dict() + try: + self.open_eeprom() + self.__eeprom_data = self.read_eeprom() + except: + self.__eeprom_data = "N/A" + raise RuntimeError("Eeprom is not Programmed") + else: + eeprom = self.__eeprom_data + + if not self.is_valid_tlvinfo_header(eeprom): + return + + total_length = (eeprom[9] << 8) | eeprom[10] + tlv_index = self._TLV_INFO_HDR_LEN + tlv_end = self._TLV_INFO_HDR_LEN + total_length + + while (tlv_index + 2) < len(eeprom) and tlv_index < tlv_end: + if not self.is_valid_tlv(eeprom[tlv_index:]): + break + + tlv = eeprom[tlv_index:tlv_index + 2 + + eeprom[tlv_index + 1]] + code = "0x%02X" % (tlv[0]) + + if tlv[0] == self._TLV_CODE_VENDOR_EXT: + value = str((tlv[2] << 24) | (tlv[3] << 16) | + (tlv[4] << 8) | tlv[5]) + value += str(tlv[6:6 + tlv[1]]) + else: + name, value = self.decoder(None, tlv) + + self.__eeprom_tlv_dict[code] = value + if eeprom[tlv_index] == self._TLV_CODE_CRC_32: + break + + tlv_index += eeprom[tlv_index+1] + 2 + + def serial_number_str(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_SERIAL_NUMBER) + if not is_valid: + return "N/A" + return results[2].decode('ascii') + + def base_mac_addr(self): + (is_valid, t) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_MAC_BASE) + if not is_valid or t[1] != 6: + return super(TlvInfoDecoder, self).switchaddrstr(e) + + return ":".join([binascii.b2a_hex(T) for T in t[2]]) + + def modelstr(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_PRODUCT_NAME) + if not is_valid: + return "N/A" + + return results[2].decode('ascii') + + def part_number_str(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_PART_NUMBER) + if not is_valid: + return "N/A" + + return results[2].decode('ascii') + + def serial_tag_str(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_SERVICE_TAG) + if not is_valid: + return "N/A" + + return results[2].decode('ascii') + + def revision_str(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_DEVICE_VERSION) + if not is_valid: + return "N/A" + + return results[2].decode('ascii') + + def system_eeprom_info(self): + """ + Returns a dictionary, where keys are the type code defined in + ONIE EEPROM format and values are their corresponding values + found in the system EEPROM. + """ + return self.__eeprom_tlv_dict + diff --git a/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/fan.py b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/fan.py new file mode 100644 index 0000000000..f9d866f196 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/fan.py @@ -0,0 +1,186 @@ +#!/usr/bin/env python + +############################################################################# +# Celestica +# +# Module contains an implementation of SONiC Platform Base API and +# provides the fan status which are available in the platform +# +############################################################################# + +import math +import os.path + +try: + from sonic_platform_base.fan_base import FanBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +FAN_PATH = "/sys/class/hwmon/hwmon1/" +FAN_MAX_PWM = 255 +FAN_FAN_PWM = "pwm{}" +FAN_FAN_INPUT = "fan{}_input" +FAN_MAX_RPM = 9000 +FAN_NAME_LIST = ["FAN-1", "FAN-2", "FAN-3", "FAN-4"] + +class Fan(FanBase): + """Platform-specific Fan class""" + + def __init__(self, fan_tray_index, fan_index=0): + self.fan_index = fan_index + self.fan_tray_index = fan_tray_index + + FanBase.__init__(self) + + def __read_txt_file(self, file_path): + try: + with open(file_path, 'r') as fd: + data = fd.read() + return data.strip() + except IOError: + pass + return "" + + def __write_txt_file(self, file_path, value): + try: + with open(file_path, 'w') as fd: + fd.write(str(value)) + except IOError: + return False + return True + + def __search_file_by_name(self, directory, file_name): + for dirpath, dirnames, files in os.walk(directory): + for name in files: + file_path = os.path.join(dirpath, name) + if name in file_name: + return file_path + return None + + def get_direction(self): + """ + Retrieves the direction of fan + Returns: + A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST + depending on fan direction + """ + direction = self.FAN_DIRECTION_EXHAUST + return direction + + def get_speed(self): + """ + Retrieves the speed of fan as a percentage of full speed + Returns: + An integer, the percentage of full fan speed, in the range 0 (off) + to 100 (full speed) + + Note: + speed = pwm_in/255*100 + """ + speed = 0 + fan_speed_sysfs_name = "fan{}_input".format(self.fan_index+1) + fan_speed_sysfs_path = self.__search_file_by_name( + FAN_PATH, fan_speed_sysfs_name) + fan_speed_rpm = self.__read_txt_file(fan_speed_sysfs_path) or 0 + speed = math.ceil(float(fan_speed_rpm) * 100 / FAN_MAX_RPM) + + return int(speed) + + def get_target_speed(self): + """ + Retrieves the target (expected) speed of the fan + Returns: + An integer, the percentage of full fan speed, in the range 0 (off) + to 100 (full speed) + + Note: + speed_pc = pwm_target/255*100 + + 0 : when PWM mode is use + pwm : when pwm mode is not use + """ + # target = 0 + # fan_target_sysfs_name = "pwm{}".format(self.fan_index+1) + # fan_target_sysfs_path = self.__search_file_by_name( + # FAN_PATH, fan_target_sysfs_name) + # fan_target_pwm = self.__read_txt_file(fan_target_sysfs_path) or 0 + # target = math.ceil(float(fan_target_pwm) * 100 / FAN_MAX_PWM) + + # return target + speed = 0 + fan_speed_sysfs_name = "fan{}_input".format(self.fan_index+1) + fan_speed_sysfs_path = self.__search_file_by_name( + FAN_PATH, fan_speed_sysfs_name) + fan_speed_rpm = self.__read_txt_file(fan_speed_sysfs_path) or 0 + speed = math.ceil(float(fan_speed_rpm) * 100 / FAN_MAX_RPM) + + return speed + + def get_speed_tolerance(self): + """ + Retrieves the speed tolerance of the fan + Returns: + An integer, the percentage of variance from target speed which is + considered tolerable + """ + return 10 + + def set_speed(self, speed): + """ + Sets the fan speed + Args: + speed: An integer, the percentage of full fan speed to set fan to, + in the range 0 (off) to 100 (full speed) + Returns: + A boolean, True if speed is set successfully, False if not + + Note: + Depends on pwm or target mode is selected: + 1) pwm = speed_pc * 255 <-- Currently use this mode. + 2) target_pwm = speed_pc * 100 / 255 + 2.1) set pwm{}_enable to 3 + + """ + pwm = speed * 255 / 100 + fan_target_sysfs_name = "pwm{}".format(self.fan_index+1) + fan_target_sysfs_path = self.__search_file_by_name( + FAN_PATH, fan_target_sysfs_name) + return self.__write_txt_file(fan_target_sysfs_path, int(pwm)) + + def set_status_led(self, color): + """ + Sets the state of the fan module status LED + Args: + color: A string representing the color with which to set the + fan module status LED + Returns: + bool: always True + """ + return True + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + fan_name = FAN_NAME_LIST[self.fan_index] + + return fan_name + + def get_presence(self): + """ + Retrieves the presence of the FAN + Returns: + bool: always True + """ + + return True + + def get_status(self): + """ + Retrieves the status of the FAN + Returns: + bool: always True + """ + return True diff --git a/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/fan_drawer.py b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/fan_drawer.py new file mode 100644 index 0000000000..7cc8403b78 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/fan_drawer.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +######################################################################## +# FS S5800 48t4s +# +# Module contains an implementation of SONiC Platform Base API and +# provides the Fan-Drawers' information available in the platform. +# +######################################################################## + +try: + from sonic_platform_base.fan_drawer_base import FanDrawerBase + from sonic_platform.fan import Fan +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +FS_FANS_PER_FANTRAY = 3 + + +class FanDrawer(FanDrawerBase): + """FS S5800 48t4s Platform-specific Fan class""" + + def __init__(self, fantray_index): + + FanDrawerBase.__init__(self) + self.fantrayindex = fantray_index + for i in range(FS_FANS_PER_FANTRAY): + self._fan_list.append(Fan(fantray_index, i)) + + def get_name(self): + """ + Retrieves the fan drawer name + Returns: + string: The name of the device + """ + return "FanTray{}".format(self.fantrayindex) diff --git a/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/led.py b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/led.py new file mode 100644 index 0000000000..032097a14c --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/led.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +############################################################################# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the led status which are available in the platform +# +############################################################################# + +class SystemLed(object): + STATUS_LED_COLOR_GREEN = 'green' + STATUS_LED_COLOR_ORANGE = 'orange' + STATUS_LED_COLOR_OFF = 'off' + + SYSTEM_LED_PATH = '/sys/class/leds/system/brightness' + + def set_status(self, color): + status = False + + if color == SystemLed.STATUS_LED_COLOR_GREEN: + with open(SystemLed.SYSTEM_LED_PATH, 'w') as led: + led.write('1') + status = True + elif color == SystemLed.STATUS_LED_COLOR_OFF: + with open(SystemLed.SYSTEM_LED_PATH, 'w') as led: + led.write('3') + status = True + elif color == SystemLed.STATUS_LED_COLOR_ORANGE: + with open(SystemLed.SYSTEM_LED_PATH, 'w') as led: + led.write('2') + status = True + + return status + + def get_status(self): + with open(SystemLed.SYSTEM_LED_PATH, 'r') as led: + if led.read().rstrip('\n') == '1': + return SystemLed.STATUS_LED_COLOR_GREEN + elif led.read().rstrip('\n') == '3': + return SystemLed.STATUS_LED_COLOR_OFF + else: + return SystemLed.STATUS_LED_COLOR_ORANGE diff --git a/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/platform.py b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/platform.py new file mode 100644 index 0000000000..e03a1e33a6 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/platform.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# +# Name: platform.py, version: 1.0 +# +# Description: Module contains the definitions of SONiC platform APIs for FS S5800-48t4s +# + + +try: + from sonic_platform_base.platform_base import PlatformBase + from sonic_platform.chassis import Chassis +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Platform(PlatformBase): + + def __init__(self): + PlatformBase.__init__(self) + self._chassis = Chassis() + diff --git a/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/psu.py b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/psu.py new file mode 100644 index 0000000000..812b2f7406 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/psu.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python + +from __future__ import print_function + +import imp +import os + +try: + from sonic_platform_base.psu_base import PsuBase + from sonic_py_common import device_info +except ImportError as e: + raise ImportError("%s - required module not found" % e) + +USR_SHARE_SONIC_PATH = "/usr/share/sonic" +HOST_DEVICE_PATH = USR_SHARE_SONIC_PATH + "/device" +CONTAINER_PLATFORM_PATH = USR_SHARE_SONIC_PATH + "/platform" + +class Psu(PsuBase): + """FS Platform-specific PSU class""" + + def __init__(self, index): + self._index = index + self._fan_list = [] + PsuBase.__init__(self) + + if os.path.isdir(CONTAINER_PLATFORM_PATH): + platform_path = CONTAINER_PLATFORM_PATH + else: + platform = device_info.get_platform() + if platform is None: + return + platform_path = os.path.join(HOST_DEVICE_PATH, platform) + + module_file = "/".join([platform_path, "plugins", "psuutil.py"]) + module = imp.load_source("psuutil", module_file) + psu_util_class = getattr(module, "PsuUtil") + self._psuutil = psu_util_class() + + def _get_psuutil(self): + return self._psuutil + + def get_presence(self): + return self._get_psuutil().get_psu_presence(self._index) + + def get_powergood_status(self): + return self._get_psuutil().get_psu_status(self._index) diff --git a/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/sfp.py b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/sfp.py new file mode 100644 index 0000000000..545f457256 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/sfp.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python + +from __future__ import print_function + +import imp +import os + +try: + from sonic_platform_base.sfp_base import SfpBase + from sonic_py_common import device_info +except ImportError as e: + raise ImportError("%s - required module not found" % e) + +USR_SHARE_SONIC_PATH = "/usr/share/sonic" +HOST_DEVICE_PATH = USR_SHARE_SONIC_PATH + "/device" +CONTAINER_PLATFORM_PATH = USR_SHARE_SONIC_PATH + "/platform" + +class Sfp(SfpBase): + """ + Platform-specific sfp class + + Unimplemented methods: + - get_model + - get_serial + - get_status + - get_transceiver_info + - get_transceiver_bulk_status + - get_transceiver_threshold_info + - get_reset_status + - get_rx_los + - get_tx_fault + - get_tx_disable_channel + - get_power_override + - get_temperature + - get_voltage + - get_tx_bias + - get_rx_power + - get_tx_power + - tx_disable_channel + - set_power_override + """ + + def __init__(self, index): + self._index = index + SfpBase.__init__(self) + + if os.path.isdir(CONTAINER_PLATFORM_PATH): + platform_path = CONTAINER_PLATFORM_PATH + else: + platform = device_info.get_platform() + if platform is None: + return + platform_path = os.path.join(HOST_DEVICE_PATH, platform) + + module_file = "/".join([platform_path, "plugins", "sfputil.py"]) + module = imp.load_source("sfputil", module_file) + sfp_util_class = getattr(module, "SfpUtil") + self._sfputil = sfp_util_class() + + def get_id(self): + return self._index + + def get_name(self): + return "Ethernet{}".format(self._index) + + def get_lpmode(self): + return False + + def set_lpmode(self, lpmode): + return False + + def get_tx_disable(self): + return False + + def tx_disable(self, tx_disable): + return False + + def reset(self): + pass + + def clear_interrupt(self): + return False + + def get_interrupt_file(self): + return None + + def _get_sfputil(self): + return self._sfputil + + def get_presence(self): + return self._get_sfputil().get_presence(self._index) + + def get_transceiver_info(self): + return self._get_sfputil().get_transceiver_info_dict(self._index) + + def get_transceiver_bulk_status(self): + return self._get_sfputil().get_transceiver_dom_info_dict(self._index) + + def get_transceiver_threshold_info(self): + return self._get_sfputil().get_transceiver_dom_threshold_info_dict(self._index) + + def get_transceiver_change_event(self, timeout): + return self._get_sfputil().get_transceiver_change_event(timeout) diff --git a/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/thermal.py b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/thermal.py new file mode 100644 index 0000000000..ca4e359692 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/48t4s/sonic_platform/thermal.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python + +############################################################################# +# Celestica +# +# Thermal contains an implementation of SONiC Platform Base API and +# provides the thermal device status which are available in the platform +# +############################################################################# + +import os +import os.path + +try: + from sonic_platform_base.thermal_base import ThermalBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Thermal(ThermalBase): + """Platform-specific Thermal class""" + + THERMAL_NAME_LIST = [] + CPUBOARD_SS_PATH = "/sys/class/hwmon/hwmon1" + + def __init__(self, thermal_index): + self.index = thermal_index + self.high_threshold = float(112) + + # Add thermal name + self.THERMAL_NAME_LIST.append("ASIC") + + # Set hwmon path + self.ss_index, self.hwmon_path = 1, self.CPUBOARD_SS_PATH + self.ss_key = self.THERMAL_NAME_LIST[self.index - 1] + + def __read_txt_file(self, file_path): + try: + with open(file_path, 'r') as fd: + data = fd.read() + return data.strip() + except IOError: + raise IOError("Unable to open %s file !" % file_path) + + def __get_temp(self, temp_file): + temp_file_path = os.path.join(self.hwmon_path, temp_file) + raw_temp = self.__read_txt_file(temp_file_path) + temp = float(raw_temp)/1000 + return float("{:.3f}".format(temp)) + + def __set_threshold(self, file_name, temperature): + temp_file_path = os.path.join(self.hwmon_path, file_name) + try: + with open(temp_file_path, 'w') as fd: + fd.write(str(temperature)) + return True + except IOError: + return False + + def get_temperature(self): + """ + Retrieves current temperature reading from thermal + Returns: + A float number of current temperature in Celsius up to nearest thousandth + of one degree Celsius, e.g. 30.125 + """ + temp_file = "temp{}_input".format(self.ss_index) + return self.__get_temp(temp_file) + + def get_high_threshold(self): + """ + Retrieves the high threshold temperature of thermal + Returns: + A float number, the high threshold temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + return self.high_threshold + + def set_high_threshold(self, temperature): + """ + Sets the high threshold temperature of thermal + Args : + temperature: A float number up to nearest thousandth of one degree Celsius, + e.g. 30.125 + Returns: + A boolean, True if threshold is set successfully, False if not + """ + self.high_threshold = float(temperature) + return True + + def get_name(self): + """ + Retrieves the name of the thermal device + Returns: + string: The name of the thermal device + """ + return self.THERMAL_NAME_LIST[self.index] + + def get_presence(self): + """ + Retrieves the presence of the PSU + Returns: + bool: True if PSU is present, False if not + """ + temp_file = "temp{}_input".format(self.ss_index) + temp_file_path = os.path.join(self.hwmon_path, temp_file) + return os.path.isfile(temp_file_path) + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + if not self.get_presence(): + return False + + return True diff --git a/platform/centec-arm64/sonic-platform-modules-fs/LICENSE b/platform/centec-arm64/sonic-platform-modules-fs/LICENSE new file mode 100644 index 0000000000..d017e95859 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/LICENSE @@ -0,0 +1,15 @@ +Copyright (C) 2022 FS + +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/centec-arm64/sonic-platform-modules-fs/README.md b/platform/centec-arm64/sonic-platform-modules-fs/README.md new file mode 100644 index 0000000000..ad5cf82611 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/README.md @@ -0,0 +1 @@ +platform drivers for FS for the SONiC project diff --git a/platform/centec-arm64/sonic-platform-modules-fs/debian/changelog b/platform/centec-arm64/sonic-platform-modules-fs/debian/changelog new file mode 100644 index 0000000000..17e65377f1 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/debian/changelog @@ -0,0 +1,6 @@ +sonic-platform-modules-fs (1.0) unstable; urgency=low + + * Initial release + + -- Sec Mon, 22 Nov 2022 14:50:00 +0800 + diff --git a/platform/centec-arm64/sonic-platform-modules-fs/debian/compat b/platform/centec-arm64/sonic-platform-modules-fs/debian/compat new file mode 100644 index 0000000000..ec635144f6 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/debian/compat @@ -0,0 +1 @@ +9 diff --git a/platform/centec-arm64/sonic-platform-modules-fs/debian/control b/platform/centec-arm64/sonic-platform-modules-fs/debian/control new file mode 100755 index 0000000000..22fb3f4a08 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/debian/control @@ -0,0 +1,11 @@ +Source: sonic-platform-modules-fs +Section: main +Priority: extra +Maintainer: Sec +Build-Depends: debhelper (>= 8.0.0), bzip2 +Standards-Version: 3.9.3 + +Package: platform-modules-s5800-48t4s +Architecture: arm64 +Depends: linux-image-5.10.0-18-2-arm64-unsigned +Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/centec-arm64/sonic-platform-modules-fs/debian/platform-modules-s5800-48t4s.init b/platform/centec-arm64/sonic-platform-modules-fs/debian/platform-modules-s5800-48t4s.init new file mode 100755 index 0000000000..3cdf4c0d07 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/debian/platform-modules-s5800-48t4s.init @@ -0,0 +1,80 @@ +#!/bin/bash +# This script load/unload fs kernel modules + +### BEGIN INIT INFO +# Provides: platform-modules-s5800-48t4s +# Required-Start: +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: S +# Default-Stop: 0 6 +# Short-Description: Load FS kernel modules +### END INIT INFO + +function install_python_api_package() +{ + device="/usr/share/sonic/device" + platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) + + rv=$(pip3 show sonic-platform > /dev/null 2>/dev/null) + if [ $? -ne 0 ]; then + rv=$(pip3 install $device/$platform/sonic_platform-1.0-py3-none-any.whl) + fi +} + +function load_kernel_modules() +{ + hwaddr=`fw_printenv ethaddr | awk -F = '{print $2}'` + if [ "$hwaddr" != "" ]; then + ifconfig eth0 hw ether $hwaddr + fi + depmod -a + modprobe ctc-i2c-mux-pca954x + modprobe fs_s5800_48t4s_platform + modprobe fan-ctc5236 + modprobe dal + modprobe tun + modprobe tap +} + +function remove_kernel_modules() +{ + modprobe -r tap + modprobe -r tun + modprobe -r dal + modprobe -r fan-ctc5236 + modprobe -r fs_s5800_48t4s_platform + modprobe -r ctc-i2c-mux-pca954x +} + +case "$1" in +start) + echo -n "Load FS kernel modules... " + + load_kernel_modules + install_python_api_package + + echo "done." + ;; + +stop) + echo -n "Unload FS kernel modules... " + + remove_kernel_modules + + echo "done." + ;; + +force-reload|restart) + echo "Not supported" + ;; + +*) + echo "Usage: /etc/init.d/platform-modules-s5800-48t4s {start|stop}" + exit 1 + ;; +esac + +exit 0 + diff --git a/platform/centec-arm64/sonic-platform-modules-fs/debian/platform-modules-s5800-48t4s.install b/platform/centec-arm64/sonic-platform-modules-fs/debian/platform-modules-s5800-48t4s.install new file mode 100644 index 0000000000..21ef746646 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/debian/platform-modules-s5800-48t4s.install @@ -0,0 +1 @@ +48t4s/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/arm64-fs_s5800_48t4s-r0 diff --git a/platform/centec-arm64/sonic-platform-modules-fs/debian/platform-modules-s5800-48t4s.postinst b/platform/centec-arm64/sonic-platform-modules-fs/debian/platform-modules-s5800-48t4s.postinst new file mode 100644 index 0000000000..c85215345e --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/debian/platform-modules-s5800-48t4s.postinst @@ -0,0 +1,9 @@ +#!/bin/bash + +hw_ver=`dd if=/dev/mtd2 bs=1 skip=4115 count=1 2>/dev/null | hexdump | awk '{print $2}'` +if [[ 0x$hw_ver -ge 0x30 ]] && [[ 0x$hw_ver -ne 0x44 ]]; then + sed -i "s/S5800-48t4s /S5800-48t4s-mars8p /g" /usr/share/sonic/device/arm64-fs_s5800_48t4s-r0/default_sku +fi + +systemctl enable 48t4s_platform.service +systemctl start 48t4s_platform.service diff --git a/platform/centec-arm64/sonic-platform-modules-fs/debian/rules b/platform/centec-arm64/sonic-platform-modules-fs/debian/rules new file mode 100755 index 0000000000..9f3d645288 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/debian/rules @@ -0,0 +1,98 @@ +#!/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 + +PACKAGE_PRE_NAME := platform-modules-s5800 +KVERSION ?= $(shell uname -r) +KERNEL_SRC := /lib/modules/$(KVERSION) +MOD_SRC_DIR:= $(shell pwd) +MODULE_DIRS:= 48t4s +MODULE_DIR := modules +SERVICE_DIR := service +CLASSES_DIR := classes +CONF_DIR := conf +KDAL_DIR := ../../centec/centec-dal/ +FAN_DIR := fan +PCA954X_DIR := pca954x + +%: + dh $@ + +clean: + dh_testdir + dh_testroot + dh_clean + +build: + #make modules -C $(KERNEL_SRC)/build M=$(MODULE_SRC) + (for mod in $(KDAL_DIR); do \ + make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/; \ + done) + (for mod in $(FAN_DIR); do \ + make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/; \ + done) + (for mod in $(PCA954X_DIR); do \ + make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/; \ + done) + (for mod in $(MODULE_DIRS); do \ + make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ + cd $${mod}; \ + python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ + cd -; \ + 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} lib/systemd/system; \ + dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} etc; \ + cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ + cp $(MOD_SRC_DIR)/$(KDAL_DIR)/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ + cp $(MOD_SRC_DIR)/$(FAN_DIR)/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ + cp $(MOD_SRC_DIR)/$(PCA954X_DIR)/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ + cp $(MOD_SRC_DIR)/$${mod}/$(SERVICE_DIR)/*.service debian/$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system/; \ + 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/centec-arm64/sonic-platform-modules-fs/fan b/platform/centec-arm64/sonic-platform-modules-fs/fan new file mode 120000 index 0000000000..c9511fa725 --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/fan @@ -0,0 +1 @@ +../sonic-platform-modules-e530/fan \ No newline at end of file diff --git a/platform/centec-arm64/sonic-platform-modules-fs/pca954x b/platform/centec-arm64/sonic-platform-modules-fs/pca954x new file mode 120000 index 0000000000..bbd3e1a72e --- /dev/null +++ b/platform/centec-arm64/sonic-platform-modules-fs/pca954x @@ -0,0 +1 @@ +../sonic-platform-modules-e530/pca954x/ \ No newline at end of file diff --git a/platform/centec-arm64/sonic_fit.its b/platform/centec-arm64/sonic_fit.its index d2cc17650f..0f96550c88 100644 --- a/platform/centec-arm64/sonic_fit.its +++ b/platform/centec-arm64/sonic_fit.its @@ -79,5 +79,12 @@ ramdisk = "initramfs"; fdt = "ctc_fdt"; }; + + arm64-fs_s5800_48t4s-r0 { + description = "config for arm64-fs_s5800_48t4s-r0"; + kernel = "kernel_ctc"; + ramdisk = "initramfs"; + fdt = "ctc_fdt"; + }; }; };