diff --git a/Makefile b/Makefile index ccfefc6c18..cd9c91a7bf 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # SONiC make file NOJESSIE ?= 1 -NOSTRETCH ?= 0 +NOSTRETCH ?= 1 NOBUSTER ?= 0 NOBULLSEYE ?= 0 diff --git a/build_debian.sh b/build_debian.sh index 1486be65c0..a855470c35 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -518,7 +518,7 @@ sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install 'setup sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install 'wheel==0.35.1' # docker Python API package is needed by Ansible docker module as well as some SONiC applications -sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install 'docker==5.0.3' +sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install 'docker==6.1.1' # Install scapy sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install 'scapy==2.4.4' diff --git a/device/accton/x86_64-accton_as4625_54p-r0/Accton-AS4625-54P/hr4-as4625-48x1G+6x10G.config.bcm b/device/accton/x86_64-accton_as4625_54p-r0/Accton-AS4625-54P/hr4-as4625-48x1G+6x10G.config.bcm new file mode 100644 index 0000000000..1ad25c4ffa --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/Accton-AS4625-54P/hr4-as4625-48x1G+6x10G.config.bcm @@ -0,0 +1,386 @@ +stable_size=76303168 + +#polarity/lanemap is using TH2 style. +#core_clock_frequency=496 +core_clock_frequency=266 +#core_clock_frequency=893 +#dpp_clock_ratio=2:3 + +core_clock_to_pm_clock_factor=2 + +oversubscribe_mode=2 +#port_gmii_mode_1=1 #Q mode + +ptp_ts_pll_fref=50000000 +ptp_bs_fref_0=50000000 +ptp_bs_fref_1=50000000 + +pbmp_xport_xe=0x1FFE00FFFFFFFFFFFF + +parity_enable=0 +mem_cache_enable=1 + +l2_mem_entries=32768 +l3_mem_entries=49152 +fpem_mem_entries=16384 +l2xmsg_mode=1 +port_flex_enable=1 + + +l3_alpm_enable=2 +ipv6_lpm_128b_enable=1 +ifp_inports_support_enable=1 + +num_ipv6_lpm_128b_entries=512 + + +dport_map_port_25=1 +dport_map_port_26=2 +dport_map_port_27=3 +dport_map_port_28=4 +dport_map_port_29=5 +dport_map_port_30=6 +dport_map_port_31=7 +dport_map_port_32=8 +portmap_25=25:1 +portmap_26=26:1 +portmap_27=27:1 +portmap_28=28:1 +portmap_29=29:1 +portmap_30=30:1 +portmap_31=31:1 +portmap_32=32:1 +port_phy_addr_25=0x00 +port_phy_addr_26=0x01 +port_phy_addr_27=0x02 +port_phy_addr_28=0x03 +port_phy_addr_29=0x04 +port_phy_addr_30=0x05 +port_phy_addr_31=0x06 +port_phy_addr_32=0x07 +phy_port_primary_and_offset_25=0x1900 +phy_port_primary_and_offset_26=0x1901 +phy_port_primary_and_offset_27=0x1902 +phy_port_primary_and_offset_28=0x1903 +phy_port_primary_and_offset_29=0x1904 +phy_port_primary_and_offset_30=0x1905 +phy_port_primary_and_offset_31=0x1906 +phy_port_primary_and_offset_32=0x1907 +phy_chain_rx_lane_map_physical{25.0}=0x3210 +phy_chain_rx_lane_map_physical{26.0}=0x3210 +phy_chain_rx_lane_map_physical{27.0}=0x3210 +phy_chain_rx_lane_map_physical{28.0}=0x3210 +phy_chain_rx_lane_map_physical{29.0}=0x3210 +phy_chain_rx_lane_map_physical{30.0}=0x3210 +phy_chain_rx_lane_map_physical{31.0}=0x3210 +phy_chain_rx_lane_map_physical{32.0}=0x3210 +phy_chain_tx_lane_map_physical{25.0}=0x3210 +phy_chain_tx_lane_map_physical{26.0}=0x3210 +phy_chain_tx_lane_map_physical{27.0}=0x3210 +phy_chain_tx_lane_map_physical{28.0}=0x3210 +phy_chain_tx_lane_map_physical{29.0}=0x3210 +phy_chain_tx_lane_map_physical{30.0}=0x3210 +phy_chain_tx_lane_map_physical{31.0}=0x3210 +phy_chain_tx_lane_map_physical{32.0}=0x3210 +phy_chain_rx_polarity_flip_physical{25.0}=0x0 +phy_chain_rx_polarity_flip_physical{26.0}=0x0 +phy_chain_rx_polarity_flip_physical{27.0}=0x0 +phy_chain_rx_polarity_flip_physical{28.0}=0x0 +phy_chain_rx_polarity_flip_physical{29.0}=0x0 +phy_chain_rx_polarity_flip_physical{30.0}=0x0 +phy_chain_rx_polarity_flip_physical{31.0}=0x0 +phy_chain_rx_polarity_flip_physical{32.0}=0x0 +phy_chain_tx_polarity_flip_physical{25.0}=0x0 +phy_chain_tx_polarity_flip_physical{26.0}=0x0 +phy_chain_tx_polarity_flip_physical{27.0}=0x0 +phy_chain_tx_polarity_flip_physical{28.0}=0x0 +phy_chain_tx_polarity_flip_physical{29.0}=0x0 +phy_chain_tx_polarity_flip_physical{30.0}=0x0 +phy_chain_tx_polarity_flip_physical{31.0}=0x0 +phy_chain_tx_polarity_flip_physical{32.0}=0x0 + + +dport_map_port_33=9 +dport_map_port_34=10 +dport_map_port_35=11 +dport_map_port_36=12 +dport_map_port_37=13 +dport_map_port_38=14 +dport_map_port_39=15 +dport_map_port_40=16 +portmap_33=33:1 +portmap_34=34:1 +portmap_35=35:1 +portmap_36=36:1 +portmap_37=37:1 +portmap_38=38:1 +portmap_39=39:1 +portmap_40=40:1 +port_phy_addr_33=0x20 +port_phy_addr_34=0x21 +port_phy_addr_35=0x22 +port_phy_addr_36=0x23 +port_phy_addr_37=0x24 +port_phy_addr_38=0x25 +port_phy_addr_39=0x26 +port_phy_addr_40=0x27 +phy_port_primary_and_offset_33=0x2100 +phy_port_primary_and_offset_34=0x2101 +phy_port_primary_and_offset_35=0x2102 +phy_port_primary_and_offset_36=0x2103 +phy_port_primary_and_offset_37=0x2104 +phy_port_primary_and_offset_38=0x2105 +phy_port_primary_and_offset_39=0x2106 +phy_port_primary_and_offset_40=0x2107 +phy_chain_rx_lane_map_physical{33.0}=0x3210 +phy_chain_rx_lane_map_physical{34.0}=0x3210 +phy_chain_rx_lane_map_physical{35.0}=0x3210 +phy_chain_rx_lane_map_physical{36.0}=0x3210 +phy_chain_rx_lane_map_physical{37.0}=0x3210 +phy_chain_rx_lane_map_physical{38.0}=0x3210 +phy_chain_rx_lane_map_physical{39.0}=0x3210 +phy_chain_rx_lane_map_physical{40.0}=0x3210 +phy_chain_tx_lane_map_physical{33.0}=0x3210 +phy_chain_tx_lane_map_physical{34.0}=0x3210 +phy_chain_tx_lane_map_physical{35.0}=0x3210 +phy_chain_tx_lane_map_physical{36.0}=0x3210 +phy_chain_tx_lane_map_physical{37.0}=0x3210 +phy_chain_tx_lane_map_physical{38.0}=0x3210 +phy_chain_tx_lane_map_physical{39.0}=0x3210 +phy_chain_tx_lane_map_physical{40.0}=0x3210 +phy_chain_rx_polarity_flip_physical{33.0}=0x0 +phy_chain_rx_polarity_flip_physical{34.0}=0x0 +phy_chain_rx_polarity_flip_physical{35.0}=0x0 +phy_chain_rx_polarity_flip_physical{36.0}=0x0 +phy_chain_rx_polarity_flip_physical{37.0}=0x0 +phy_chain_rx_polarity_flip_physical{38.0}=0x0 +phy_chain_rx_polarity_flip_physical{39.0}=0x0 +phy_chain_rx_polarity_flip_physical{40.0}=0x0 +phy_chain_tx_polarity_flip_physical{33.0}=0x0 +phy_chain_tx_polarity_flip_physical{34.0}=0x0 +phy_chain_tx_polarity_flip_physical{35.0}=0x0 +phy_chain_tx_polarity_flip_physical{36.0}=0x0 +phy_chain_tx_polarity_flip_physical{37.0}=0x0 +phy_chain_tx_polarity_flip_physical{38.0}=0x0 +phy_chain_tx_polarity_flip_physical{39.0}=0x0 +phy_chain_tx_polarity_flip_physical{40.0}=0x0 + + + +#MQ16_1 +#port_gmii_mode_17=1 #Q mode +dport_map_port_41=17 +dport_map_port_42=18 +dport_map_port_43=19 +dport_map_port_44=20 +dport_map_port_45=21 +dport_map_port_46=22 +dport_map_port_47=23 +dport_map_port_48=24 +portmap_41=41:1 +portmap_42=42:1 +portmap_43=43:1 +portmap_44=44:1 +portmap_45=49:1 +portmap_46=50:1 +portmap_47=51:1 +portmap_48=52:1 +port_phy_addr_41=0x40 +port_phy_addr_42=0x41 +port_phy_addr_43=0x42 +port_phy_addr_44=0x43 +port_phy_addr_45=0x44 +port_phy_addr_46=0x45 +port_phy_addr_47=0x46 +port_phy_addr_48=0x47 +phy_port_primary_and_offset_41=0x2900 +phy_port_primary_and_offset_42=0x2901 +phy_port_primary_and_offset_43=0x2902 +phy_port_primary_and_offset_44=0x2903 +phy_port_primary_and_offset_45=0x2904 +phy_port_primary_and_offset_46=0x2905 +phy_port_primary_and_offset_47=0x2906 +phy_port_primary_and_offset_48=0x2907 +phy_chain_rx_lane_map_physical{41.0}=0x3210 +phy_chain_rx_lane_map_physical{42.0}=0x3210 +phy_chain_rx_lane_map_physical{43.0}=0x3210 +phy_chain_rx_lane_map_physical{44.0}=0x3210 +phy_chain_rx_lane_map_physical{45.0}=0x3210 +phy_chain_rx_lane_map_physical{46.0}=0x3210 +phy_chain_rx_lane_map_physical{47.0}=0x3210 +phy_chain_rx_lane_map_physical{48.0}=0x3210 +phy_chain_tx_lane_map_physical{41.0}=0x3210 +phy_chain_tx_lane_map_physical{42.0}=0x3210 +phy_chain_tx_lane_map_physical{43.0}=0x3210 +phy_chain_tx_lane_map_physical{44.0}=0x3210 +phy_chain_tx_lane_map_physical{45.0}=0x3210 +phy_chain_tx_lane_map_physical{46.0}=0x3210 +phy_chain_tx_lane_map_physical{47.0}=0x3210 +phy_chain_tx_lane_map_physical{48.0}=0x3210 +phy_chain_rx_polarity_flip_physical{41.0}=0x0 +phy_chain_rx_polarity_flip_physical{42.0}=0x0 +phy_chain_rx_polarity_flip_physical{43.0}=0x0 +phy_chain_rx_polarity_flip_physical{44.0}=0x0 +phy_chain_rx_polarity_flip_physical{45.0}=0x0 +phy_chain_rx_polarity_flip_physical{46.0}=0x0 +phy_chain_rx_polarity_flip_physical{47.0}=0x0 +phy_chain_rx_polarity_flip_physical{48.0}=0x0 +phy_chain_tx_polarity_flip_physical{41.0}=0x0 +phy_chain_tx_polarity_flip_physical{42.0}=0x0 +phy_chain_tx_polarity_flip_physical{43.0}=0x0 +phy_chain_tx_polarity_flip_physical{44.0}=0x0 +phy_chain_tx_polarity_flip_physical{45.0}=0x0 +phy_chain_tx_polarity_flip_physical{46.0}=0x0 +phy_chain_tx_polarity_flip_physical{47.0}=0x0 +phy_chain_tx_polarity_flip_physical{48.0}=0x0 + + +#GPHY0 +dport_map_port_1=25 +dport_map_port_2=26 +dport_map_port_3=27 +dport_map_port_4=28 +portmap_1=1:1 +portmap_2=2:1 +portmap_3=3:1 +portmap_4=4:1 +phy_port_primary_and_offset_1=0x0100 +phy_port_primary_and_offset_2=0x0101 +phy_port_primary_and_offset_3=0x0102 +phy_port_primary_and_offset_4=0x0103 + + +#GPHY1 +dport_map_port_5=29 +dport_map_port_6=30 +dport_map_port_7=31 +dport_map_port_8=32 +portmap_5=5:1 +portmap_6=6:1 +portmap_7=7:1 +portmap_8=8:1 +phy_port_primary_and_offset_5=0x0500 +phy_port_primary_and_offset_6=0x0501 +phy_port_primary_and_offset_7=0x0502 +phy_port_primary_and_offset_8=0x0503 + + +#GPHY2 +dport_map_port_9=33 +dport_map_port_10=34 +dport_map_port_11=35 +dport_map_port_12=36 +portmap_9=9:1 +portmap_10=10:1 +portmap_11=11:1 +portmap_12=12:1 +phy_port_primary_and_offset_9=0x0900 +phy_port_primary_and_offset_10=0x0901 +phy_port_primary_and_offset_11=0x0902 +phy_port_primary_and_offset_12=0x0903 + + +#GPHY3 +dport_map_port_13=37 +dport_map_port_14=38 +dport_map_port_15=39 +dport_map_port_16=40 +portmap_13=13:1 +portmap_14=14:1 +portmap_15=15:1 +portmap_16=16:1 +phy_port_primary_and_offset_13=0x0d00 +phy_port_primary_and_offset_14=0x0d01 +phy_port_primary_and_offset_15=0x0d02 +phy_port_primary_and_offset_16=0x0d03 + + +#GPHY4 +dport_map_port_17=41 +dport_map_port_18=42 +dport_map_port_19=43 +dport_map_port_20=44 +portmap_17=17:1 +portmap_18=18:1 +portmap_19=19:1 +portmap_20=20:1 +phy_port_primary_and_offset_17=0x1100 +phy_port_primary_and_offset_18=0x1101 +phy_port_primary_and_offset_19=0x1102 +phy_port_primary_and_offset_20=0x1103 + + +#GPHY5 +dport_map_port_21=45 +dport_map_port_22=46 +dport_map_port_23=47 +dport_map_port_24=48 +portmap_21=21:1 +portmap_22=22:1 +portmap_23=23:1 +portmap_24=24:1 +phy_port_primary_and_offset_21=0x1500 +phy_port_primary_and_offset_22=0x1501 +phy_port_primary_and_offset_23=0x1502 +phy_port_primary_and_offset_24=0x1503 + + +#PHYx TSC-F16-0, TSC2 +dport_map_port_57=49 +dport_map_port_58=50 +dport_map_port_59=51 +dport_map_port_60=52 +portmap_57=57:10 +portmap_58=58:10 +portmap_59=59:10 +portmap_60=60:10 +phy_chain_tx_lane_map_physical{57.0}=0x3210 +phy_chain_tx_lane_map_physical{58.0}=0x3210 +phy_chain_tx_lane_map_physical{59.0}=0x3210 +phy_chain_tx_lane_map_physical{60.0}=0x3210 +phy_chain_rx_lane_map_physical{57.0}=0x3210 +phy_chain_rx_lane_map_physical{58.0}=0x3210 +phy_chain_rx_lane_map_physical{59.0}=0x3210 +phy_chain_rx_lane_map_physical{60.0}=0x3210 +phy_chain_tx_polarity_flip_physical{57.0}=0x0 +phy_chain_tx_polarity_flip_physical{58.0}=0x0 +phy_chain_tx_polarity_flip_physical{59.0}=0x0 +phy_chain_tx_polarity_flip_physical{60.0}=0x0 +phy_chain_rx_polarity_flip_physical{57.0}=0x0 +phy_chain_rx_polarity_flip_physical{58.0}=0x0 +phy_chain_rx_polarity_flip_physical{59.0}=0x0 +phy_chain_rx_polarity_flip_physical{60.0}=0x0 + + +#PHYx TSC-M16-0, TSC3 +dport_map_port_61=53 +dport_map_port_62=54 +#dport_map_port_63=55 +#dport_map_port_64=56 +portmap_61=61:10 +portmap_62=62:10 +#portmap_63=63:10 +#portmap_64=64:10 +phy_chain_tx_lane_map_physical{61.0}=0x3210 +phy_chain_tx_lane_map_physical{62.0}=0x3210 +phy_chain_tx_lane_map_physical{63.0}=0x3210 +phy_chain_tx_lane_map_physical{64.0}=0x3210 +phy_chain_rx_lane_map_physical{61.0}=0x3210 +phy_chain_rx_lane_map_physical{62.0}=0x3210 +#phy_chain_rx_lane_map_physical{63.0}=0x3210 +#phy_chain_rx_lane_map_physical{64.0}=0x3210 +phy_chain_tx_polarity_flip_physical{61.0}=0x0 +phy_chain_tx_polarity_flip_physical{62.0}=0x0 +phy_chain_tx_polarity_flip_physical{63.0}=0x0 +phy_chain_tx_polarity_flip_physical{64.0}=0x0 +phy_chain_rx_polarity_flip_physical{61.0}=0x0 +phy_chain_rx_polarity_flip_physical{62.0}=0x0 +#phy_chain_rx_polarity_flip_physical{63.0}=0x0 +#phy_chain_rx_polarity_flip_physical{64.0}=0x0 + + + +# MerlinCore-Q SerDes +#port_gmii_mode=1 means that the device is running in QSGMII +port_gmii_mode{25}=1 +port_gmii_mode{41}=1 diff --git a/device/accton/x86_64-accton_as4625_54p-r0/Accton-AS4625-54P/hwsku.json b/device/accton/x86_64-accton_as4625_54p-r0/Accton-AS4625-54P/hwsku.json new file mode 100644 index 0000000000..64ddd8089b --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/Accton-AS4625-54P/hwsku.json @@ -0,0 +1,321 @@ +{ + "interfaces": { + "Ethernet0": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet1": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet2": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet3": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet4": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet5": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet6": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet7": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet8": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet9": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet10": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet11": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet12": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet13": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet14": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet15": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet16": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet17": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet18": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet19": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet20": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet21": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet22": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet23": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet24": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet25": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet26": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet27": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet28": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet29": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet30": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet31": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet32": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet33": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet34": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet35": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet36": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet37": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet38": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet39": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet40": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet41": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet42": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet43": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet44": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet45": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet46": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet47": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet48": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off" + }, + + "Ethernet49": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off" + }, + + "Ethernet50": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off" + }, + + "Ethernet51": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off" + }, + + "Ethernet52": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off" + }, + + "Ethernet53": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off" + } + } +} diff --git a/device/accton/x86_64-accton_as4625_54p-r0/Accton-AS4625-54P/port_config.ini b/device/accton/x86_64-accton_as4625_54p-r0/Accton-AS4625-54P/port_config.ini new file mode 100644 index 0000000000..a88d9f0d23 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/Accton-AS4625-54P/port_config.ini @@ -0,0 +1,55 @@ +# name lanes alias index speed autoneg +Ethernet0 25 Eth1(Port1) 1 1000 on +Ethernet1 26 Eth2(Port2) 2 1000 on +Ethernet2 27 Eth3(Port3) 3 1000 on +Ethernet3 28 Eth4(Port4) 4 1000 on +Ethernet4 29 Eth5(Port5) 5 1000 on +Ethernet5 30 Eth6(Port6) 6 1000 on +Ethernet6 31 Eth7(Port7) 7 1000 on +Ethernet7 32 Eth8(Port8) 8 1000 on +Ethernet8 33 Eth9(Port9) 9 1000 on +Ethernet9 34 Eth10(Port10) 10 1000 on +Ethernet10 35 Eth11(Port11) 11 1000 on +Ethernet11 36 Eth12(Port12) 12 1000 on +Ethernet12 37 Eth13(Port13) 13 1000 on +Ethernet13 38 Eth14(Port14) 14 1000 on +Ethernet14 39 Eth15(Port15) 15 1000 on +Ethernet15 40 Eth16(Port16) 16 1000 on +Ethernet16 41 Eth17(Port17) 17 1000 on +Ethernet17 42 Eth18(Port18) 18 1000 on +Ethernet18 43 Eth19(Port19) 19 1000 on +Ethernet19 44 Eth20(Port20) 20 1000 on +Ethernet20 49 Eth21(Port21) 21 1000 on +Ethernet21 50 Eth22(Port22) 22 1000 on +Ethernet22 51 Eth23(Port23) 23 1000 on +Ethernet23 52 Eth24(Port24) 24 1000 on +Ethernet24 1 Eth25(Port25) 25 1000 on +Ethernet25 2 Eth26(Port26) 26 1000 on +Ethernet26 3 Eth27(Port27) 27 1000 on +Ethernet27 4 Eth28(Port28) 28 1000 on +Ethernet28 5 Eth29(Port29) 29 1000 on +Ethernet29 6 Eth30(Port30) 30 1000 on +Ethernet30 7 Eth31(Port31) 31 1000 on +Ethernet31 8 Eth32(Port32) 32 1000 on +Ethernet32 9 Eth33(Port33) 33 1000 on +Ethernet33 10 Eth34(Port34) 34 1000 on +Ethernet34 11 Eth35(Port35) 35 1000 on +Ethernet35 12 Eth36(Port36) 36 1000 on +Ethernet36 13 Eth37(Port37) 37 1000 on +Ethernet37 14 Eth38(Port38) 38 1000 on +Ethernet38 15 Eth39(Port39) 39 1000 on +Ethernet39 16 Eth40(Port40) 40 1000 on +Ethernet40 17 Eth41(Port41) 41 1000 on +Ethernet41 18 Eth42(Port42) 42 1000 on +Ethernet42 19 Eth43(Port43) 43 1000 on +Ethernet43 20 Eth44(Port44) 44 1000 on +Ethernet44 21 Eth45(Port45) 45 1000 on +Ethernet45 22 Eth46(Port46) 46 1000 on +Ethernet46 23 Eth47(Port47) 47 1000 on +Ethernet47 24 Eth48(Port48) 48 1000 on +Ethernet48 57 Eth49(Port49) 49 10000 off +Ethernet49 58 Eth50(Port50) 50 10000 off +Ethernet50 59 Eth51(Port51) 51 10000 off +Ethernet51 60 Eth52(Port52) 52 10000 off +Ethernet52 61 Eth53(Port53) 53 10000 off +Ethernet53 62 Eth54(Port54) 54 10000 off diff --git a/device/accton/x86_64-accton_as4625_54p-r0/Accton-AS4625-54P/sai.profile b/device/accton/x86_64-accton_as4625_54p-r0/Accton-AS4625-54P/sai.profile new file mode 100644 index 0000000000..93c1ebcec2 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/Accton-AS4625-54P/sai.profile @@ -0,0 +1 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/hr4-as4625-48x1G+6x10G.config.bcm diff --git a/device/accton/x86_64-accton_as4625_54p-r0/custom_led.bin b/device/accton/x86_64-accton_as4625_54p-r0/custom_led.bin new file mode 100644 index 0000000000..f1cc4a1136 Binary files /dev/null and b/device/accton/x86_64-accton_as4625_54p-r0/custom_led.bin differ diff --git a/device/accton/x86_64-accton_as4625_54p-r0/default_sku b/device/accton/x86_64-accton_as4625_54p-r0/default_sku new file mode 100644 index 0000000000..cfcb3278f4 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/default_sku @@ -0,0 +1 @@ +Accton-AS4625-54P t1 diff --git a/device/accton/x86_64-accton_as4625_54p-r0/installer.conf b/device/accton/x86_64-accton_as4625_54p-r0/installer.conf new file mode 100644 index 0000000000..85bb317cc9 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/installer.conf @@ -0,0 +1,4 @@ +CONSOLE_PORT=0x3f8 +CONSOLE_DEV=0 +CONSOLE_SPEED=115200 +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="pcie_aspm=off intel_iommu=off modprobe.blacklist=i2c-ismt,i2c_ismt,i2c-i801,i2c_i801" diff --git a/device/accton/x86_64-accton_as4625_54p-r0/led_proc_init.soc b/device/accton/x86_64-accton_as4625_54p-r0/led_proc_init.soc new file mode 100644 index 0000000000..5bef973ed2 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/led_proc_init.soc @@ -0,0 +1,3 @@ +m0 load 0 0x3800 /usr/share/sonic/platform/custom_led.bin +led start +led auto on diff --git a/device/accton/x86_64-accton_as4625_54p-r0/pcie.yaml b/device/accton/x86_64-accton_as4625_54p-r0/pcie.yaml new file mode 100644 index 0000000000..b7482437b9 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/pcie.yaml @@ -0,0 +1,149 @@ +- bus: '00' + dev: '00' + fn: '0' + id: '1980' + name: 'Host bridge: Intel Corporation Atom Processor C3000 Series System Agent (rev + 11)' +- bus: '00' + dev: '04' + fn: '0' + id: 19a1 + name: 'Host bridge: Intel Corporation Atom Processor C3000 Series Error Registers + (rev 11)' +- bus: '00' + dev: '05' + fn: '0' + id: 19a2 + name: 'Generic system peripheral [0807]: Intel Corporation Atom Processor C3000 + Series Root Complex Event Collector (rev 11)' +- bus: '00' + dev: '06' + fn: '0' + id: 19a3 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series Integrated QAT + Root Port (rev 11)' +- bus: '00' + dev: 09 + fn: '0' + id: 19a4 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root + Port #0 (rev 11)' +- bus: '00' + dev: 0e + fn: '0' + id: 19a8 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root + Port #4 (rev 11)' +- bus: '00' + dev: 0f + fn: '0' + id: 19a9 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root + Port #5 (rev 11)' +- bus: '00' + dev: '12' + fn: '0' + id: 19ac + name: 'System peripheral: Intel Corporation Atom Processor C3000 Series SMBus Contoller + - Host (rev 11)' +- bus: '00' + dev: '14' + fn: '0' + id: 19c2 + name: 'SATA controller: Intel Corporation Atom Processor C3000 Series SATA Controller + 1 (rev 11)' +- bus: '00' + dev: '15' + fn: '0' + id: 19d0 + name: 'USB controller: Intel Corporation Atom Processor C3000 Series USB 3.0 xHCI + Controller (rev 11)' +- bus: '00' + dev: '16' + fn: '0' + id: 19d1 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series Integrated LAN + Root Port #0 (rev 11)' +- bus: '00' + dev: '17' + fn: '0' + id: 19d2 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series Integrated LAN + Root Port #1 (rev 11)' +- bus: '00' + dev: '18' + fn: '0' + id: 19d3 + name: 'Communication controller: Intel Corporation Atom Processor C3000 Series ME + HECI 1 (rev 11)' +- bus: '00' + dev: 1f + fn: '0' + id: 19dc + name: 'ISA bridge: Intel Corporation Atom Processor C3000 Series LPC or eSPI (rev + 11)' +- bus: '00' + dev: 1f + fn: '1' + id: 19dd + name: 'Memory controller: Intel Corporation Atom Processor C3000 Series Primary + to Side Band (P2SB) Bridge (rev 11)' +- bus: '00' + dev: 1f + fn: '2' + id: 19de + name: 'Memory controller: Intel Corporation Atom Processor C3000 Series Power Management + Controller (rev 11)' +- bus: '00' + dev: 1f + fn: '4' + id: 19df + name: 'SMBus: Intel Corporation Atom Processor C3000 Series SMBus controller (rev + 11)' +- bus: '00' + dev: 1f + fn: '5' + id: 19e0 + name: 'Serial bus controller [0c80]: Intel Corporation Atom Processor C3000 Series + SPI Controller (rev 11)' +- bus: '01' + dev: '00' + fn: '0' + id: 19e2 + name: 'Co-processor: Intel Corporation Atom Processor C3000 Series QuickAssist Technology + (rev 11)' +- bus: '02' + dev: '00' + fn: '0' + id: '1533' + name: 'Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev + 03)' +- bus: '03' + dev: '00' + fn: '0' + id: b277 + name: 'Ethernet controller: Broadcom Inc. and subsidiaries Device b277 (rev 02)' +- bus: '05' + dev: '00' + fn: '0' + id: 15c3 + name: 'Ethernet controller: Intel Corporation Ethernet Connection X553 Backplane + (rev 11)' +- bus: '05' + dev: '00' + fn: '1' + id: 15c3 + name: 'Ethernet controller: Intel Corporation Ethernet Connection X553 Backplane + (rev 11)' +- bus: '07' + dev: '00' + fn: '0' + id: 15c3 + name: 'Ethernet controller: Intel Corporation Ethernet Connection X553 Backplane + (rev 11)' +- bus: '07' + dev: '00' + fn: '1' + id: 15c3 + name: 'Ethernet controller: Intel Corporation Ethernet Connection X553 Backplane + (rev 11)' diff --git a/device/accton/x86_64-accton_as4625_54p-r0/platform.json b/device/accton/x86_64-accton_as4625_54p-r0/platform.json new file mode 100644 index 0000000000..74a720f7fa --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/platform.json @@ -0,0 +1,853 @@ +{ + "chassis": { + "name": "4625-54P", + "components": [ + { + "name": "MB_CPLD" + }, + { + "name": "BIOS" + } + ], + "fans": [ + { + "name": "FAN-1", + "speed": { + "controllable": true, + "minimum": 25 + }, + "status_led": { + "available": false + } + }, + { + "name": "FAN-2", + "speed": { + "controllable": true, + "minimum": 25 + }, + "status_led": { + "available": false + } + }, + { + "name": "FAN-3", + "speed": { + "controllable": true, + "minimum": 25 + }, + "status_led": { + "available": false + } + } + ], + "fan_drawers":[ + { + "name": "FanTray-1", + "num_fans" : 1, + "fans": [ + { + "name": "FAN-1", + "speed": { + "controllable": true, + "minimum": 25 + }, + "status_led": { + "available": false + } + } + ] + }, + { + "name": "FanTray-2", + "num_fans" : 1, + "fans": [ + { + "name": "FAN-2", + "speed": { + "controllable": true, + "minimum": 25 + }, + "status_led": { + "available": false + } + } + ] + }, + { + "name": "FanTray-3", + "num_fans" : 1, + "fans": [ + { + "name": "FAN-3", + "speed": { + "controllable": true, + "minimum": 25 + }, + "status_led": { + "available": false + } + } + ] + } + ], + "psus": [ + { + "name": "PSU-1", + "fans": [ + { + "name": "PSU-1 FAN-1" + } + ], + "thermals": [ + { + "name": "PSU-1 temp sensor 1", + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name": "PSU-1 temp sensor 2", + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + } + ], + "temperature": true, + "temperature_high_threshold": true + }, + { + "name": "PSU-2", + "fans": [ + { + "name": "PSU-2 FAN-1" + } + ], + "thermals": [ + { + "name": "PSU-2 temp sensor 1", + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name": "PSU-2 temp sensor 2", + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + } + ], + "temperature": true, + "temperature_high_threshold": true + } + ], + "thermals": [ + { + "name": "MB_Temp(0x4a)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + + }, + { + "name": "MB_Temp(0x4b)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name": "MB_Temp(0x4d)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name": "MB_Temp(0x4e)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name": "MB_Temp(0x4f)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name" : "CPU Package Temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name" : "CPU Core 0 Temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name" : "CPU Core 1 Temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name" : "CPU Core 2 Temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name" : "CPU Core 3 Temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + } + ], + "sfps": [ + { + "name": "Ethernet0" + }, + { + "name": "Ethernet1" + }, + { + "name": "Ethernet2" + }, + { + "name": "Ethernet3" + }, + { + "name": "Ethernet4" + }, + { + "name": "Ethernet5" + }, + { + "name": "Ethernet6" + }, + { + "name": "Ethernet7" + }, + { + "name": "Ethernet8" + }, + { + "name": "Ethernet9" + }, + { + "name": "Ethernet10" + }, + { + "name": "Ethernet11" + }, + { + "name": "Ethernet12" + }, + { + "name": "Ethernet13" + }, + { + "name": "Ethernet14" + }, + { + "name": "Ethernet15" + }, + { + "name": "Ethernet16" + }, + { + "name": "Ethernet17" + }, + { + "name": "Ethernet18" + }, + { + "name": "Ethernet19" + }, + { + "name": "Ethernet20" + }, + { + "name": "Ethernet21" + }, + { + "name": "Ethernet22" + }, + { + "name": "Ethernet23" + }, + { + "name": "Ethernet24" + }, + { + "name": "Ethernet25" + }, + { + "name": "Ethernet26" + }, + { + "name": "Ethernet27" + }, + { + "name": "Ethernet28" + }, + { + "name": "Ethernet29" + }, + { + "name": "Ethernet30" + }, + { + "name": "Ethernet31" + }, + { + "name": "Ethernet32" + }, + { + "name": "Ethernet33" + }, + { + "name": "Ethernet34" + }, + { + "name": "Ethernet35" + }, + { + "name": "Ethernet36" + }, + { + "name": "Ethernet37" + }, + { + "name": "Ethernet38" + }, + { + "name": "Ethernet39" + }, + { + "name": "Ethernet40" + }, + { + "name": "Ethernet41" + }, + { + "name": "Ethernet42" + }, + { + "name": "Ethernet43" + }, + { + "name": "Ethernet44" + }, + { + "name": "Ethernet45" + }, + { + "name": "Ethernet46" + }, + { + "name": "Ethernet47" + }, + { + "name": "Ethernet48" + }, + { + "name": "Ethernet49" + }, + { + "name": "Ethernet50" + }, + { + "name": "Ethernet51" + }, + { + "name": "Ethernet52" + }, + { + "name": "Ethernet53" + } + ] + }, + "interfaces": { + "Ethernet0": { + "index": "1", + "lanes": "25", + "breakout_modes": { + "1x1G": ["Eth1(Port1)"] + } + }, + + "Ethernet1": { + "index": "2", + "lanes": "26", + "breakout_modes": { + "1x1G": ["Eth2(Port2)"] + } + }, + + "Ethernet2": { + "index": "3", + "lanes": "27", + "breakout_modes": { + "1x1G": ["Eth3(Port3)"] + } + }, + + "Ethernet3": { + "index": "4", + "lanes": "28", + "breakout_modes": { + "1x1G": ["Eth4(Port4)"] + } + }, + + "Ethernet4": { + "index": "5", + "lanes": "29", + "breakout_modes": { + "1x1G": ["Eth5(Port5)"] + } + }, + + "Ethernet5": { + "index": "6", + "lanes": "30", + "breakout_modes": { + "1x1G": ["Eth6(Port6)"] + } + }, + + "Ethernet6": { + "index": "7", + "lanes": "31", + "breakout_modes": { + "1x1G": ["Eth7(Port7)"] + } + }, + + "Ethernet7": { + "index": "8", + "lanes": "32", + "breakout_modes": { + "1x1G": ["Eth8(Port8)"] + } + }, + + "Ethernet8": { + "index": "9", + "lanes": "33", + "breakout_modes": { + "1x1G": ["Eth9(Port9)"] + } + }, + + "Ethernet9": { + "index": "10", + "lanes": "34", + "breakout_modes": { + "1x1G": ["Eth10(Port10)"] + } + }, + + "Ethernet10": { + "index": "11", + "lanes": "35", + "breakout_modes": { + "1x1G": ["Eth11(Port11)"] + } + }, + + "Ethernet11": { + "index": "12", + "lanes": "36", + "breakout_modes": { + "1x1G": ["Eth12(Port12)"] + } + }, + + "Ethernet12": { + "index": "13", + "lanes": "37", + "breakout_modes": { + "1x1G": ["Eth13(Port13)"] + } + }, + + "Ethernet13": { + "index": "14", + "lanes": "38", + "breakout_modes": { + "1x1G": ["Eth14(Port14)"] + } + }, + + "Ethernet14": { + "index": "15", + "lanes": "39", + "breakout_modes": { + "1x1G": ["Eth15(Port15)"] + } + }, + + "Ethernet15": { + "index": "16", + "lanes": "40", + "breakout_modes": { + "1x1G": ["Eth16(Port16)"] + } + }, + + "Ethernet16": { + "index": "17", + "lanes": "41", + "breakout_modes": { + "1x1G": ["Eth17(Port17)"] + } + }, + + "Ethernet17": { + "index": "18", + "lanes": "42", + "breakout_modes": { + "1x1G": ["Eth18(Port18)"] + } + }, + + "Ethernet18": { + "index": "19", + "lanes": "43", + "breakout_modes": { + "1x1G": ["Eth19(Port19)"] + } + }, + + "Ethernet19": { + "index": "20", + "lanes": "44", + "breakout_modes": { + "1x1G": ["Eth20(Port20)"] + } + }, + + "Ethernet20": { + "index": "21", + "lanes": "49", + "breakout_modes": { + "1x1G": ["Eth21(Port21)"] + } + }, + + "Ethernet21": { + "index": "22", + "lanes": "50", + "breakout_modes": { + "1x1G": ["Eth22(Port22)"] + } + }, + + "Ethernet22": { + "index": "23", + "lanes": "51", + "breakout_modes": { + "1x1G": ["Eth23(Port23)"] + } + }, + + "Ethernet23": { + "index": "24", + "lanes": "52", + "breakout_modes": { + "1x1G": ["Eth24(Port24)"] + } + }, + + "Ethernet24": { + "index": "25", + "lanes": "1", + "breakout_modes": { + "1x1G": ["Eth25(Port25)"] + } + }, + + "Ethernet25": { + "index": "26", + "lanes": "2", + "breakout_modes": { + "1x1G": ["Eth26(Port26)"] + } + }, + + "Ethernet26": { + "index": "27", + "lanes": "3", + "breakout_modes": { + "1x1G": ["Eth27(Port27)"] + } + }, + + "Ethernet27": { + "index": "28", + "lanes": "4", + "breakout_modes": { + "1x1G": ["Eth28(Port28)"] + } + }, + + "Ethernet28": { + "index": "29", + "lanes": "5", + "breakout_modes": { + "1x1G": ["Eth29(Port29)"] + } + }, + + "Ethernet29": { + "index": "30", + "lanes": "6", + "breakout_modes": { + "1x1G": ["Eth30(Port30)"] + } + }, + + "Ethernet30": { + "index": "31", + "lanes": "7", + "breakout_modes": { + "1x1G": ["Eth31(Port31)"] + } + }, + + "Ethernet31": { + "index": "32", + "lanes": "8", + "breakout_modes": { + "1x1G": ["Eth32(Port32)"] + } + }, + + "Ethernet32": { + "index": "33", + "lanes": "9", + "breakout_modes": { + "1x1G": ["Eth33(Port33)"] + } + }, + + "Ethernet33": { + "index": "34", + "lanes": "10", + "breakout_modes": { + "1x1G": ["Eth34(Port34)"] + } + }, + + "Ethernet34": { + "index": "35", + "lanes": "11", + "breakout_modes": { + "1x1G": ["Eth35(Port35)"] + } + }, + + "Ethernet35": { + "index": "36", + "lanes": "12", + "breakout_modes": { + "1x1G": ["Eth36(Port36)"] + } + }, + + "Ethernet36": { + "index": "37", + "lanes": "13", + "breakout_modes": { + "1x1G": ["Eth37(Port37)"] + } + }, + + "Ethernet37": { + "index": "38", + "lanes": "14", + "breakout_modes": { + "1x1G": ["Eth38(Port38)"] + } + }, + + "Ethernet38": { + "index": "39", + "lanes": "15", + "breakout_modes": { + "1x1G": ["Eth39(Port39)"] + } + }, + + "Ethernet39": { + "index": "40", + "lanes": "16", + "breakout_modes": { + "1x1G": ["Eth40(Port40)"] + } + }, + + "Ethernet40": { + "index": "41", + "lanes": "17", + "breakout_modes": { + "1x1G": ["Eth41(Port41)"] + } + }, + + "Ethernet41": { + "index": "42", + "lanes": "18", + "breakout_modes": { + "1x1G": ["Eth42(Port42)"] + } + }, + + "Ethernet42": { + "index": "43", + "lanes": "19", + "breakout_modes": { + "1x1G": ["Eth43(Port43)"] + } + }, + + "Ethernet43": { + "index": "44", + "lanes": "20", + "breakout_modes": { + "1x1G": ["Eth44(Port44)"] + } + }, + + "Ethernet44": { + "index": "45", + "lanes": "21", + "breakout_modes": { + "1x1G": ["Eth45(Port45)"] + } + }, + + "Ethernet45": { + "index": "46", + "lanes": "22", + "breakout_modes": { + "1x1G": ["Eth46(Port46)"] + } + }, + + "Ethernet46": { + "index": "47", + "lanes": "23", + "breakout_modes": { + "1x1G": ["Eth47(Port47)"] + } + }, + + "Ethernet47": { + "index": "48", + "lanes": "24", + "breakout_modes": { + "1x1G": ["Eth48(Port48)"] + } + }, + + "Ethernet48": { + "index": "49", + "lanes": "57", + "breakout_modes": { + "1x10G[1G]": ["Eth49(Port49)"] + } + }, + + "Ethernet49": { + "index": "50", + "lanes": "58", + "breakout_modes": { + "1x10G[1G]": ["Eth50(Port50)"] + } + }, + + "Ethernet50": { + "index": "51", + "lanes": "59", + "breakout_modes": { + "1x10G[1G]": ["Eth51(Port51)"] + } + }, + + "Ethernet51": { + "index": "52", + "lanes": "60", + "breakout_modes": { + "1x10G[1G]": ["Eth52(Port52)"] + } + }, + + "Ethernet52": { + "index": "53", + "lanes": "61", + "breakout_modes": { + "1x10G[1G]": ["Eth53(Port53)"] + } + }, + + "Ethernet53": { + "index": "54", + "lanes": "62", + "breakout_modes": { + "1x10G[1G]": ["Eth54(Port54)"] + } + } + } +} diff --git a/device/accton/x86_64-accton_as4625_54p-r0/platform_asic b/device/accton/x86_64-accton_as4625_54p-r0/platform_asic new file mode 100644 index 0000000000..9604676527 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/platform_asic @@ -0,0 +1 @@ +broadcom diff --git a/device/accton/x86_64-accton_as4625_54p-r0/platform_components.json b/device/accton/x86_64-accton_as4625_54p-r0/platform_components.json new file mode 100644 index 0000000000..c22530cc12 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/platform_components.json @@ -0,0 +1,10 @@ +{ + "chassis": { + "4625-54P-O-AC-F": { + "component": { + "MB_CPLD": { }, + "BIOS": { } + } + } + } +} diff --git a/device/accton/x86_64-accton_as4625_54p-r0/plugins/ssd_util.py b/device/accton/x86_64-accton_as4625_54p-r0/plugins/ssd_util.py new file mode 100644 index 0000000000..4b173c5e38 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/plugins/ssd_util.py @@ -0,0 +1,24 @@ +# ssd_util.py +# +# Platform-specific SSD interface for SONiC +## + +try: + from sonic_platform_base.sonic_ssd.ssd_generic import SsdUtil as MainSsdUtil +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +NOT_AVAILABLE = "N/A" + +class SsdUtil(MainSsdUtil): + """Platform-specific SsdUtil class""" + + def __init__(self, diskdev): + super(SsdUtil, self).__init__(diskdev) + + # If it has no vendor tool to read SSD information, + # ssd_util.py will use generic SSD information + # for vendor SSD information. + if self.vendor_ssd_info == NOT_AVAILABLE: + self.vendor_ssd_info = self.ssd_info + diff --git a/device/accton/x86_64-accton_as4625_54p-r0/pmon_daemon_control.json b/device/accton/x86_64-accton_as4625_54p-r0/pmon_daemon_control.json new file mode 100644 index 0000000000..79344cad0b --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/pmon_daemon_control.json @@ -0,0 +1,4 @@ +{ + "skip_ledd": true, + "skip_xcvrd_cmis_mgr": true +} diff --git a/device/accton/x86_64-accton_as4625_54p-r0/sensors.conf b/device/accton/x86_64-accton_as4625_54p-r0/sensors.conf new file mode 100644 index 0000000000..1f4571ec60 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/sensors.conf @@ -0,0 +1,50 @@ +# libsensors configuration file for as4625 +# ------------------------------------------------ +# +bus "i2c-3" "i2c-1-mux (chan_id 1)" +bus "i2c-8" "i2c-1-mux (chan_id 6)" +bus "i2c-9" "i2c-1-mux (chan_id 7)" + +chip "ym2651-i2c-*-58" + label in3 "PSU 1 Voltage" + label fan1 "PSU 1 Fan" + label temp1 "PSU 1 Temperature" + label power2 "PSU 1 Power" + label curr2 "PSU 1 Current" + +chip "ym2651-i2c-*-59" + label in3 "PSU 2 Voltage" + label fan1 "PSU 2 Fan" + label temp1 "PSU 2 Temperature" + label power2 "PSU 2 Power" + label curr2 "PSU 2 Current" + +chip "as4625_fan-*" + label fan1 "Fan 1" + label fan2 "Fan 2" + label fan3 "Fan 3" + +chip "lm75-i2c-*-4a" + label temp1 "MB_Temp(0x4a)" + +chip "lm75-i2c-*-4b" + label temp1 "MB_Temp(0x4b)" + +chip "lm75-i2c-*-4d" + label temp1 "MB_Temp(0x4d)" + +chip "lm75-i2c-*-4e" + label temp1 "MB_Temp(0x4e)" + +chip "lm75-i2c-*-4f" + label temp1 "MB_Temp(0x4f)" + +chip "coretemp-isa-0000" + label temp2 "Core 0" + label temp4 "Core 0" + label temp6 "Core 1" + label temp8 "Core 1" + label temp10 "Core 2" + label temp12 "Core 2" + label temp14 "Core 3" + label temp16 "Core 3" diff --git a/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/__init__.py b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/__init__.py new file mode 100644 index 0000000000..cea4c512bf --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/__init__.py @@ -0,0 +1,2 @@ +__all__ = [ 'platform', 'chassis', 'component', 'eeprom', 'psu', 'sfp', 'thermal', 'fan', 'fan_drawer' ] +from . import platform diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/chassis.py b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/chassis.py similarity index 73% rename from device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/chassis.py rename to device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/chassis.py index 1c97d0e878..fe8319089b 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/chassis.py +++ b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/chassis.py @@ -5,45 +5,45 @@ # provides the Chassis information which are available in the platform # ############################################################################# - import sys import subprocess try: from sonic_platform_base.chassis_base import ChassisBase + from .helper import APIHelper from .event import SfpEvent - from sonic_py_common import device_info - except ImportError as e: raise ImportError(str(e) + "- required module not found") -NUM_FAN_TRAY = 6 +NUM_FAN_TRAY = 3 +NUM_FAN = 1 NUM_PSU = 2 -NUM_THERMAL = 4 -NUM_PORT = 58 -NUM_COMPONENT = 4 - +NUM_THERMAL = 10 +PORT_START = 1 +PORT_END = 54 +NUM_COMPONENT = 2 HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/" PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/" REBOOT_CAUSE_FILE = "reboot-cause.txt" PREV_REBOOT_CAUSE_FILE = "previous-reboot-cause.txt" HOST_CHK_CMD = ["which", "systemctl"] -SYSLED_FNODE= "/sys/class/leds/accton_as7326_56x_led::diag/brightness" +SYSLED_FNODE= "/sys/class/leds/as4625_led::sys/brightness" + SYSLED_MODES = { - "0" : "STATUS_LED_COLOR_OFF", "1" : "STATUS_LED_COLOR_GREEN", - "3" : "STATUS_LED_COLOR_RED", - "5" : "STATUS_LED_COLOR_GREEN_BLINK" + "2" : "STATUS_LED_COLOR_GREEN_BLINKING", + "3" : "STATUS_LED_COLOR_AMBER" } - class Chassis(ChassisBase): """Platform-specific Chassis class""" def __init__(self): ChassisBase.__init__(self) + self._api_helper = APIHelper() + self.is_host = self._api_helper.is_host() + self.config_data = {} - (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() self.__initialize_fan() self.__initialize_psu() @@ -54,9 +54,10 @@ def __init__(self): def __initialize_sfp(self): from sonic_platform.sfp import Sfp - for index in range(NUM_PORT): - sfp = Sfp(index) - self._sfp_list.append(sfp) + for index in range(1, PORT_END+1): + sfp_module = Sfp(index, 'SFP') + self._sfp_list.append(sfp_module) + self._sfpevent = SfpEvent(self._sfp_list) self.sfp_module_initialized = True @@ -69,13 +70,13 @@ def __initialize_fan(self): def __initialize_psu(self): from sonic_platform.psu import Psu - for index in range(NUM_PSU): + for index in range(0, NUM_PSU): psu = Psu(index) self._psu_list.append(psu) def __initialize_thermals(self): from sonic_platform.thermal import Thermal - for index in range(NUM_THERMAL): + for index in range(0, NUM_THERMAL): thermal = Thermal(index) self._thermal_list.append(thermal) @@ -85,32 +86,13 @@ def __initialize_eeprom(self): def __initialize_components(self): from sonic_platform.component import Component - for index in range(NUM_COMPONENT): + for index in range(0, NUM_COMPONENT): component = Component(index) self._component_list.append(component) - def __initialize_watchdog(self): - self._watchdog = Watchdog() - def __is_host(self): return subprocess.call(HOST_CHK_CMD) == 0 - def __read_txt_file(self, file_path): - try: - with open(file_path, 'r') as fd: - return fd.read().strip() - except IOError: - pass - return None - - def __write_txt_file(self, file_path, value): - try: - with open(file_path, 'w') as fd: - fd.write(str(value)) - except Exception: - return False - return True - def get_name(self): """ Retrieves the name of the device @@ -127,6 +109,23 @@ def get_presence(self): """ return True + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + Returns: + integer: The 1-based relative physical position in parent + device or -1 if cannot determine the position + """ + return -1 + + def is_replaceable(self): + """ + Indicate whether Chassis is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + def get_status(self): """ Retrieves the operational status of the device @@ -134,6 +133,7 @@ def get_status(self): A boolean value, True if device is operating properly, False if not """ return True + def get_base_mac(self): """ Retrieves the base MAC address for the chassis @@ -172,6 +172,7 @@ def get_system_eeprom_info(self): 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 @@ -179,29 +180,19 @@ def get_reboot_cause(self): is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used to pass a description of the reboot cause. """ - description = 'None' - - reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE) if self.__is_host( - ) else (PMON_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE) - prev_reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + PREV_REBOOT_CAUSE_FILE) if self.__is_host( - ) else (PMON_REBOOT_CAUSE_PATH + PREV_REBOOT_CAUSE_FILE) - sw_reboot_cause = self.__read_txt_file(reboot_cause_path) or "Unknown" - prev_sw_reboot_cause = self.__read_txt_file(prev_reboot_cause_path) or "Unknown" + reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE) + sw_reboot_cause = self._api_helper.read_txt_file( + reboot_cause_path) or "Unknown" - if sw_reboot_cause != "Unknown": - reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE - description = sw_reboot_cause - elif prev_reboot_cause_path != "Unknown": - reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE - description = prev_sw_reboot_cause - return (reboot_cause, description) + return ('REBOOT_CAUSE_NON_HARDWARE', sw_reboot_cause) def get_change_event(self, timeout=0): # SFP event if not self.sfp_module_initialized: self.__initialize_sfp() + return self._sfpevent.get_sfp_event(timeout) def get_sfp(self, index): @@ -227,29 +218,11 @@ def get_sfp(self, index): index, len(self._sfp_list))) return sfp - def get_position_in_parent(self): - """ - Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position - for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned - Returns: - integer: The 1-based relative physical position in parent device or -1 if cannot determine the position - """ - return -1 - - def is_replaceable(self): - """ - Indicate whether this device is replaceable. - Returns: - bool: True if it is replaceable. - """ - return False - - def initizalize_system_led(self): return True def get_status_led(self): - val = self.__read_txt_file(SYSLED_FNODE) + val = self._api_helper.read_txt_file(SYSLED_FNODE) return SYSLED_MODES[val] if val in SYSLED_MODES else "UNKNOWN" def set_status_led(self, color): @@ -261,4 +234,20 @@ def set_status_led(self, color): if mode is None: return False else: - return self.__write_txt_file(SYSLED_FNODE, mode) + return self._api_helper.write_txt_file(SYSLED_FNODE, mode) + + def get_port_or_cage_type(self, port): + from sonic_platform_base.sfp_base import SfpBase + if port in range(1, 49): + return SfpBase.SFP_PORT_TYPE_BIT_RJ45 + elif port in range(49, 55): + return SfpBase.SFP_PORT_TYPE_BIT_SFP | SfpBase.SFP_PORT_TYPE_BIT_SFP_PLUS | SfpBase.SFP_PORT_TYPE_BIT_SFP28 + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + return 'N/A' diff --git a/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/component.py b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/component.py new file mode 100644 index 0000000000..2819137456 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/component.py @@ -0,0 +1,152 @@ +############################################################################# +# Edgecore +# +# Component contains an implementation of SONiC Platform Base API and +# provides the components firmware management function +# +############################################################################# +try: + from sonic_platform_base.component_base import ComponentBase + from .helper import APIHelper +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +CPLD_PATH_MAPPING = { + "CPLD_MAJOR": "/sys/bus/i2c/devices/0-0064/version_major", + "CPLD_MINOR": "/sys/bus/i2c/devices/0-0064/version_minor" +} + +BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version" +COMPONENT_LIST= [ + ("MB_CPLD", "Mainboard CPLD(0x64)"), + ("BIOS", "Basic Input/Output System") +] + +class Component(ComponentBase): + """Platform-specific Component class""" + + DEVICE_TYPE = "component" + + def __init__(self, component_index=0): + self._api_helper=APIHelper() + ComponentBase.__init__(self) + self.index = component_index + self.name = self.get_name() + + def __get_bios_version(self): + # Retrieves the BIOS firmware version + try: + with open(BIOS_VERSION_PATH, 'r') as fd: + return fd.read().strip() + except Exception as e: + print('Get exception when read bios') + return None + + def __get_cpld_version(self): + # Retrieves the CPLD firmware version + cpld_version = dict() + version_list = list() + for index, cpld_name in enumerate(CPLD_PATH_MAPPING): + try: + cpld_path = "{}".format(CPLD_PATH_MAPPING[cpld_name]) + cpld_version_raw = self._api_helper.read_txt_file(cpld_path) + version_list.append("{:x}".format(int(cpld_version_raw,10))) + except Exception as e: + print('Get exception when read cpld (%s)', cpld_path) + cpld_version["MB_CPLD"] = 'None' + return cpld_version + + cpld_version["MB_CPLD"] = version_list[0] + '.' + version_list[1] + return cpld_version + + def get_name(self): + """ + Retrieves the name of the component + Returns: + A string containing the name of the component + """ + return COMPONENT_LIST[self.index][0] + + def get_description(self): + """ + Retrieves the description of the component + Returns: + A string containing the description of the component + """ + return COMPONENT_LIST[self.index][1] + + def get_firmware_version(self): + """ + Retrieves the firmware version of module + Returns: + string: The firmware versions of the module + """ + if self.name == "BIOS": + fw_version = self.__get_bios_version() + elif "CPLD" in self.name: + cpld_version = self.__get_cpld_version() + fw_version = cpld_version.get(self.name) + + return fw_version + + def install_firmware(self, image_path): + """ + Install firmware to module + Args: + image_path: A string, path to firmware image + Returns: + A boolean, True if install successfully, False if not + """ + raise NotImplementedError + + def get_presence(self): + """ + Retrieves the presence of the device + Returns: + bool: True if device is present, False if not + """ + return True + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + return 'N/A' + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return 'N/A' + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + return True + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + If the agent cannot determine the parent-relative position + for some reason, or if the associated value of + entPhysicalContainedIn is'0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device + or -1 if cannot determine the position + """ + return -1 + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/eeprom.py b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/eeprom.py similarity index 89% rename from device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/eeprom.py rename to device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/eeprom.py index d0bffe53a2..b89e54d6bb 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/eeprom.py +++ b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/eeprom.py @@ -2,11 +2,12 @@ import os import sys import re - from sonic_platform_base.sonic_eeprom import eeprom_tlvinfo if sys.version_info[0] >= 3: from io import StringIO else: from cStringIO import StringIO + + from sonic_platform_base.sonic_eeprom import eeprom_tlvinfo except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -19,13 +20,7 @@ class Tlv(eeprom_tlvinfo.TlvInfoDecoder): EEPROM_DECODE_HEADLINES = 6 def __init__(self): - #self._eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom" - exists = os.path.isfile('/sys/bus/i2c/devices/0-0056/eeprom') - if (exists is True): - self._eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom" - else: - self._eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom" - + self._eeprom_path = "/sys/bus/i2c/devices/7-0051/eeprom" super(Tlv, self).__init__(self._eeprom_path, 0, '', True) self._eeprom = self._load_eeprom() @@ -37,8 +32,8 @@ def __parse_output(self, decode_output): for line in lines: try: - match = re.search('(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)([\S]+)', - line) + match = re.search( + '(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)(.+)', line) if match is not None: idx = match.group(1) value = match.group(3).rstrip('\0') diff --git a/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/event.py b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/event.py new file mode 100644 index 0000000000..6e8c08ce20 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/event.py @@ -0,0 +1,117 @@ +try: + import time + from sonic_py_common.logger import Logger + from .sfp import Sfp +except ImportError as e: + raise ImportError(repr(e) + " - required module not found") + +POLL_INTERVAL_IN_SEC = 1 + +# SFP errors that will block eeprom accessing +SFP_BLOCKING_ERRORS = [ + Sfp.SFP_ERROR_BIT_I2C_STUCK, + Sfp.SFP_ERROR_BIT_BAD_EEPROM, + Sfp.SFP_ERROR_BIT_UNSUPPORTED_CABLE, + Sfp.SFP_ERROR_BIT_HIGH_TEMP, + Sfp.SFP_ERROR_BIT_BAD_CABLE +] + +class SfpEvent: + ''' Listen to insert/remove sfp events ''' + + def __init__(self, sfp_list): + self._sfp_list = sfp_list + self._logger = Logger() + self._sfp_change_event_data = {'present': 0} + + def get_presence_bitmap(self): + bitmap = 0 + for sfp in self._sfp_list: + modpres = sfp.get_presence() + i=sfp.get_position_in_parent() - 1 + if modpres: + bitmap = bitmap | (1 << i) + return bitmap + + def get_sfp_event(self, timeout=2000): + port_dict = {} + change_dict = {} + change_dict['sfp'] = port_dict + + if timeout < 1000: + cd_ms = 1000 + else: + cd_ms = timeout + + while cd_ms > 0: + bitmap = self.get_presence_bitmap() + changed_ports = self._sfp_change_event_data['present'] ^ bitmap + if changed_ports != 0: + break + time.sleep(POLL_INTERVAL_IN_SEC) + # timeout=0 means wait for event forever + if timeout != 0: + cd_ms = cd_ms - POLL_INTERVAL_IN_SEC * 1000 + + if changed_ports != 0: + for sfp in self._sfp_list: + i=sfp.get_position_in_parent() - 1 + if (changed_ports & (1 << i)) == 0: + continue + + if (bitmap & (1 << i)) == 0: + port_dict[i+1] = '0' + else: + sfp_state_bits = self.get_sfp_state_bits(sfp, True) + sfp_state_bits = self.check_sfp_blocking_errors(sfp_state_bits) + + port_dict[i+1] = str(sfp_state_bits) + + # Update the cache dict + self._sfp_change_event_data['present'] = bitmap + return True, change_dict + else: + return True, change_dict + + def get_sfp_state_bits(self, sfp, present): + sfp_state_bits = 0 + + if present is True: + sfp_state_bits |= Sfp.SFP_STATUS_BIT_INSERTED + else: + return sfp_state_bits + + status = sfp.refresh() + if status is not True: + if status is None: + sfp_state_bits |= Sfp.SFP_ERROR_BIT_I2C_STUCK + return sfp_state_bits + else: + sfp_state_bits |= Sfp.SFP_ERROR_BIT_BAD_EEPROM + return sfp_state_bits + + status = sfp.validate_eeprom() + if status is None: + sfp_state_bits |= Sfp.SFP_ERROR_BIT_I2C_STUCK + return sfp_state_bits + elif status is not True: + sfp_state_bits |= Sfp.SFP_ERROR_BIT_BAD_EEPROM + return sfp_state_bits + + status = sfp.validate_temperature() + if status is None: + sfp_state_bits |= Sfp.SFP_ERROR_BIT_I2C_STUCK + return sfp_state_bits + elif status is not True: + sfp_state_bits |= Sfp.SFP_ERROR_BIT_HIGH_TEMP + return sfp_state_bits + + return sfp_state_bits + + def check_sfp_blocking_errors(self, sfp_state_bits): + for i in SFP_BLOCKING_ERRORS: + if (i & sfp_state_bits) == 0: + continue + sfp_state_bits |= Sfp.SFP_ERROR_BIT_BLOCKING + + return sfp_state_bits diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan.py b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/fan.py similarity index 51% rename from device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan.py rename to device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/fan.py index c64d953b75..b780ed8be1 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan.py +++ b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/fan.py @@ -5,81 +5,82 @@ # provides the fan status which are available in the platform # ############################################################################# +import glob try: from sonic_platform_base.fan_base import FanBase except ImportError as e: raise ImportError(str(e) + "- required module not found") -FAN_MAX_RPM = 25500 PSU_FAN_MAX_RPM = 25500 SPEED_TOLERANCE = 15 -CPLD_I2C_PATH = "/sys/bus/i2c/devices/11-0066/fan" -PSU_I2C_PATH = "/sys/bus/i2c/devices/{}-00{}/" -PSU_HWMON_I2C_MAPPING = { + +FAN_HWMON_I2C_PATH = "/sys/devices/platform/as4625_fan/hwmon/hwmon*/fan" + +I2C_PATH ="/sys/bus/i2c/devices/{}-00{}/" +PSU_PMBUS_I2C_MAPPING = { 0: { - "bus": 17, - "addr": "59" + "num": 8, + "addr": "58" }, 1: { - "bus": 13, - "addr": "5b" - }, + "num": 9, + "addr": "59" + } } -PSU_CPLD_I2C_MAPPING = { +PSU_EEPROM_I2C_MAPPING = { 0: { - "bus": 17, - "addr": "51" + "num": 8, + "addr": "50" }, 1: { - "bus": 13, - "addr": "53" - }, + "num": 9, + "addr": "51" + } } -FAN_NAME_LIST = ["FAN-1F", "FAN-1R", "FAN-2F", "FAN-2R", - "FAN-3F", "FAN-3R", "FAN-4F", "FAN-4R", - "FAN-5F", "FAN-5R", "FAN-6F", "FAN-6R"] - class Fan(FanBase): """Platform-specific Fan class""" - def __init__(self, - fan_tray_index, - fan_index=0, - is_psu_fan=False, - psu_index=0): + def __init__(self, fan_tray_index, fan_index=0, is_psu_fan=False, psu_index=0): self.fan_index = fan_index self.fan_tray_index = fan_tray_index self.is_psu_fan = is_psu_fan - self.psu_index = psu_index - if self.is_psu_fan: - psu_i2c_bus = PSU_HWMON_I2C_MAPPING[psu_index]["bus"] - psu_i2c_addr = PSU_HWMON_I2C_MAPPING[psu_index]["addr"] - self.psu_hwmon_path = PSU_I2C_PATH.format(psu_i2c_bus, - psu_i2c_addr) - psu_i2c_bus = PSU_CPLD_I2C_MAPPING[psu_index]["bus"] - psu_i2c_addr = PSU_CPLD_I2C_MAPPING[psu_index]["addr"] - self.cpld_path = PSU_I2C_PATH.format(psu_i2c_bus, psu_i2c_addr) + if not self.is_psu_fan: + self.hwmon_path = FAN_HWMON_I2C_PATH + else: + self.psu_index = psu_index + i2c_num = PSU_PMBUS_I2C_MAPPING[self.psu_index]['num'] + i2c_addr = PSU_PMBUS_I2C_MAPPING[self.psu_index]['addr'] + self.hwmon_path = I2C_PATH.format(i2c_num, i2c_addr) + + i2c_num = PSU_EEPROM_I2C_MAPPING[self.psu_index]['num'] + i2c_addr = PSU_EEPROM_I2C_MAPPING[self.psu_index]['addr'] + self.psu_eeprom_path = I2C_PATH.format(i2c_num, i2c_addr) FanBase.__init__(self) def __read_txt_file(self, file_path): - try: - with open(file_path, 'r') as fd: - return fd.read().strip() - except IOError: - pass - return "" + for filename in glob.glob(file_path): + try: + with open(filename, 'r') as fd: + data = fd.readline().rstrip() + if len(data) > 0: + return data + except IOError as e: + pass + + return None def __write_txt_file(self, file_path, value): - try: - with open(file_path, 'w') as fd: - fd.write(str(value)) - except Exception: - return False + for filename in glob.glob(file_path): + try: + with open(filename, 'w') as fd: + fd.write(str(value)) + except IOError: + return False return True def get_direction(self): @@ -89,15 +90,20 @@ def get_direction(self): A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST depending on fan direction """ - if not self.is_psu_fan: - val = self.__read_txt_file( - CPLD_I2C_PATH + str(self.fan_tray_index+1) + "_direction") - direction = self.FAN_DIRECTION_EXHAUST if ( - val == "0") else self.FAN_DIRECTION_INTAKE + if self.is_psu_fan: #For PSU + dir_str = "{}{}".format(self.psu_eeprom_path,'psu_fan_dir') else: - val = self.__read_txt_file(self.psu_hwmon_path + "psu_fan_dir") - direction = self.FAN_DIRECTION_EXHAUST if ( - val == "F2B") else self.FAN_DIRECTION_INTAKE + dir_str = "{}{}{}".format(self.hwmon_path, self.fan_tray_index+1, '_dir') + + val = self.__read_txt_file(dir_str) + if val is not None: + if val == 'B2F': + direction = self.FAN_DIRECTION_INTAKE + else: + direction = self.FAN_DIRECTION_EXHAUST + else: + direction = self.FAN_DIRECTION_NOT_APPLICABLE + return direction def get_speed(self): @@ -106,18 +112,34 @@ def get_speed(self): Returns: An integer, the percentage of full fan speed, in the range 0 (off) to 100 (full speed) + """ speed = 0 if self.is_psu_fan: - speed = self.__read_txt_file( - self.psu_hwmon_path + "psu_fan1_speed_rpm") - speed = (int(speed, 10)) * 100 / PSU_FAN_MAX_RPM - speed = 100 if (speed > 100) else speed - elif self.get_presence(): - speed = self.__read_txt_file(CPLD_I2C_PATH + str( - self.fan_index * 10 + self.fan_tray_index + 1) + "_input") - speed = (int(speed, 10)) * 100 / FAN_MAX_RPM - speed = 100 if (speed > 100) else speed + path = "{}{}".format(self.hwmon_path, 'fan1_input') + rpm = self.__read_txt_file(path) + if rpm is not None: + speed = (int(rpm, 10)) * 100 / PSU_FAN_MAX_RPM + if speed > 100: + speed = 100 + else: + return 0 + + else: + input_path = "{}{}{}".format(self.hwmon_path, self.fan_tray_index+1, '_input') + input = self.__read_txt_file(input_path) + target_rpm_path = "{}{}{}".format(self.hwmon_path, self.fan_tray_index+1, '_target_rpm') + target_rpm = self.__read_txt_file(target_rpm_path) + pwm = self.get_target_speed() + + if input is None or target_rpm is None or pwm is None: + return 0 + + if int(target_rpm) > 0: + speed = pwm * int(input) / int(target_rpm) + if speed > 100: + speed = 100 + return int(speed) def get_target_speed(self): @@ -126,12 +148,21 @@ def get_target_speed(self): Returns: An integer, the percentage of full fan speed, in the range 0 (off) to 100 (full speed) + Note: speed_pc = pwm_target/255*100 + 0 : when PWM mode is use pwm : when pwm mode is not use """ - return self.get_speed() + if not self.is_psu_fan and self.get_presence(): + speed_path = "{}{}{}".format(self.hwmon_path, self.fan_tray_index+1, '_pwm') + speed = self.__read_txt_file(speed_path) + if speed is None: + return 0 + return int(speed) + else: + return self.get_speed() def get_speed_tolerance(self): """ @@ -150,11 +181,12 @@ def set_speed(self, speed): in the range 0 (off) to 100 (full speed) Returns: A boolean, True if speed is set successfully, False if not + """ if not self.is_psu_fan and self.get_presence(): - return self.__write_txt_file( - CPLD_I2C_PATH + "_duty_cycle_percentage", int(speed)) + speed_path = "{}{}{}".format(self.hwmon_path, self.fan_tray_index+1, '_pwm') + return self.__write_txt_file(speed_path, int(speed)) return False @@ -167,7 +199,7 @@ def set_status_led(self, color): Returns: bool: True if status LED state is set successfully, False if not """ - return False #Not supported + return False #Not supported def get_status_led(self): """ @@ -175,14 +207,16 @@ def get_status_led(self): Returns: A string, one of the predefined STATUS_LED_COLOR_* strings above """ - status=self.get_presence() - if status is None: - return self.STATUS_LED_COLOR_OFF + if not self.is_psu_fan: + return None + + if self.get_presence() is not True: + return None return { - 1: self.STATUS_LED_COLOR_GREEN, - 0: self.STATUS_LED_COLOR_RED - }.get(status, self.STATUS_LED_COLOR_OFF) + True: self.STATUS_LED_COLOR_GREEN, + False: self.STATUS_LED_COLOR_AMBER + }.get(self.get_status(), self.STATUS_LED_COLOR_AMBER) def get_name(self): """ @@ -190,25 +224,26 @@ def get_name(self): Returns: string: The name of the device """ - fan_name = FAN_NAME_LIST[self.fan_tray_index*2 + self.fan_index] \ - if not self.is_psu_fan \ - else "PSU-{} FAN-{}".format(self.psu_index+1, self.fan_index+1) + if self.is_psu_fan: + return "PSU-{} FAN-{}".format(self.psu_index+1, self.fan_index+1) - return fan_name + return "FAN-{}".format(self.fan_tray_index+1) def get_presence(self): """ - Retrieves the presence of the PSU + Retrieves the presence of the FAN Returns: - bool: True if PSU is present, False if not + bool: True if FAN is present, False if not """ if self.is_psu_fan: - val = self.__read_txt_file(self.cpld_path + "psu_present") - return int(val, 10) == 1 - - val = self.__read_txt_file( - CPLD_I2C_PATH + str(self.fan_tray_index + 1) + "_present") - return int(val, 10)==1 + present_path = "{}{}".format(self.psu_eeprom_path, 'psu_present') + val = self.__read_txt_file(present_path) + if val is not None: + return int(val, 10) == 1 + else: + return False + else: + return True def get_status(self): """ @@ -217,17 +252,26 @@ def get_status(self): A boolean value, True if device is operating properly, False if not """ if self.is_psu_fan: - psu_fan_path= "{}{}".format(self.psu_hwmon_path, 'psu_fan1_fault') + if self.get_presence() is not True: + return None + + power_path = "{}{}".format(self.psu_eeprom_path, 'psu_power_good') + val = self.__read_txt_file(power_path) + if val is not None: + if int(val, 10) != 1: + return False + + psu_fan_path= "{}{}".format(self.hwmon_path, 'fan1_input') val=self.__read_txt_file(psu_fan_path) if val is not None: - return int(val, 10)==0 + return int(val, 10) != 0 else: return False - else: - path = "{}{}{}".format(CPLD_I2C_PATH, self.fan_tray_index+1, '_fault') + else: + path = "{}{}{}".format(self.hwmon_path, self.fan_tray_index+1, '_fault') val=self.__read_txt_file(path) if val is not None: - return int(val, 10)==0 + return int(val, 10) == 0 else: return False @@ -237,9 +281,9 @@ def get_model(self): Returns: string: Model/part number of device """ - + return "N/A" - + def get_serial(self): """ Retrieves the serial number of the device @@ -248,6 +292,14 @@ def get_serial(self): """ return "N/A" + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + def get_position_in_parent(self): """ Retrieves 1-based relative physical position in parent device. @@ -258,13 +310,5 @@ def get_position_in_parent(self): integer: The 1-based relative physical position in parent device or -1 if cannot determine the position """ - return (self.fan_index+1) \ + return (self.fan_tray_index+1) \ if not self.is_psu_fan else (self.psu_index+1) - - def is_replaceable(self): - """ - Indicate whether this device is replaceable. - Returns: - bool: True if it is replaceable. - """ - return True if not self.is_psu_fan else False diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan_drawer.py b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/fan_drawer.py similarity index 69% rename from device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan_drawer.py rename to device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/fan_drawer.py index e21163c106..f07c67be07 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan_drawer.py +++ b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/fan_drawer.py @@ -10,22 +10,20 @@ except ImportError as e: raise ImportError(str(e) + "- required module not found") -FANS_PER_FANTRAY = 2 - +FANS_PER_FANTRAY = 1 class FanDrawer(FanDrawerBase): """Platform-specific Fan class""" def __init__(self, fantray_index): - FanDrawerBase.__init__(self) - # FanTray is 0-based in platforms self.fantrayindex = fantray_index - self.__initialize_fan_drawer() - + # FanTray is 0-based in platforms + self.__initialize_fan() - def __initialize_fan_drawer(self): + def __initialize_fan(self): from sonic_platform.fan import Fan + for i in range(FANS_PER_FANTRAY): self._fan_list.append(Fan(self.fantrayindex, i)) @@ -35,7 +33,7 @@ def get_name(self): Returns: string: The name of the device """ - return "FanTray{}".format(self.fantrayindex+1) + return "FanTray-{}".format(self.fantrayindex + 1) def get_presence(self): """ @@ -67,7 +65,13 @@ def get_status(self): Returns: A boolean value, True if device is operating properly, False if not """ - return self._fan_list[0].get_status() + from sonic_platform.fan import Fan + + for fan in self._fan_list: + if not fan.get_status(): + return False + + return True def get_position_in_parent(self): """ @@ -79,7 +83,29 @@ def get_position_in_parent(self): integer: The 1-based relative physical position in parent device or -1 if cannot determine the position """ - return (self.fantrayindex+1) + return self.fantrayindex+1 + + def get_status_led(self): + """ + Gets the state of the fan status LED + Returns: + A string, one of the predefined STATUS_LED_COLOR_* strings above + """ + return { + True: self.STATUS_LED_COLOR_GREEN, + False: self.STATUS_LED_COLOR_AMBER + }.get(self.get_status(), self.STATUS_LED_COLOR_AMBER) + + def set_status_led(self, color): + """ + Sets the state of the fan module status LED + Args: + color: A string representing the color with which to set the + fan module status LED + Returns: + bool: True if status LED state is set successfully, False if not + """ + return False #Not supported def is_replaceable(self): """ @@ -87,4 +113,4 @@ def is_replaceable(self): Returns: bool: True if it is replaceable. """ - return True + return False diff --git a/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/helper.py b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/helper.py new file mode 100644 index 0000000000..28e01d6e45 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/helper.py @@ -0,0 +1,324 @@ +import os +import struct +import json +import fcntl +from mmap import * +from sonic_py_common import device_info +from sonic_py_common.general import getstatusoutput_noshell +from sonic_py_common import logger +from threading import Lock +from typing import cast + +HOST_CHK_CMD = ["docker"] +EMPTY_STRING = "" + +class APIHelper(): + + def __init__(self): + (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() + + def is_host(self): + try: + status, output = getstatusoutput_noshell(HOST_CHK_CMD) + return status == 0 + except Exception: + return False + + def pci_get_value(self, resource, offset): + status = True + result = "" + try: + fd = os.open(resource, os.O_RDWR) + mm = mmap(fd, 0) + mm.seek(int(offset)) + read_data_stream = mm.read(4) + result = struct.unpack('I', read_data_stream) + except Exception: + status = False + return status, result + + def run_interactive_command(self, cmd): + try: + os.system(cmd) + except Exception: + return False + return True + + def read_txt_file(self, file_path): + try: + with open(file_path, encoding='unicode_escape', errors='replace') as fd: + data = fd.read() + ret = data.strip() + if len(ret) > 0: + return ret + except IOError: + pass + return None + + def write_txt_file(self, file_path, value): + try: + with open(file_path, 'w') as fd: + fd.write(str(value)) + fd.flush() + except IOError: + return False + return True +class FileLock: + + def __init__(self, lock_file): + self._lock_file = lock_file + self._thread_lock = Lock() + self.is_locked = False + + def acquire(self): + with self._thread_lock: + if self.is_locked: + return + + fd = os.open(self._lock_file, flags=(os.O_RDWR | os.O_CREAT | os.O_TRUNC)) + fcntl.flock(fd, fcntl.LOCK_EX) + self._lock_file_fd = fd + self.is_locked = True + + def release(self): + with self._thread_lock: + if self.is_locked: + fd = cast(int, self._lock_file_fd) + self._lock_file_fd = None + fcntl.flock(fd, fcntl.LOCK_UN) + os.close(fd) + self.is_locked = False + + def __enter__(self): + self.acquire() + return self + + def __exit__(self, exc_type, exc_val, traceback): + self.release() + + def __del__(self): + self.release() + + +DEVICE_THRESHOLD_JSON_PATH = "/tmp/device_threshold.json" +HIGH_THRESHOLD_FIELD = 'high_threshold' +LOW_THRESHOLD_FIELD = 'low_threshold' +HIGH_CRIT_THRESHOLD_FIELD = 'high_critical_threshold' +LOW_CRIT_THRESHOLD_FIELD = 'low_critical_threshold' +NOT_AVAILABLE = 'N/A' + +class DeviceThreshold: + + def __init__(self, th_name = NOT_AVAILABLE): + self.flock = FileLock("{}.lock".format(DEVICE_THRESHOLD_JSON_PATH)) + self.name = th_name + self.__log = logger.Logger(log_identifier="DeviceThreshold") + + self.__db_data = {} + try: + with self.flock: + with open(DEVICE_THRESHOLD_JSON_PATH, "r") as db_file: + self.__db_data = json.load(db_file) + except Exception as e: + pass + + @property + def HIGH_THRESHOLD_FIELD(self): + return HIGH_THRESHOLD_FIELD + + @property + def LOW_THRESHOLD_FIELD(self): + return LOW_THRESHOLD_FIELD + + @property + def HIGH_CRIT_THRESHOLD_FIELD(self): + return HIGH_CRIT_THRESHOLD_FIELD + + @property + def LOW_CRIT_THRESHOLD_FIELD(self): + return LOW_CRIT_THRESHOLD_FIELD + + @property + def NOT_AVAILABLE(self): + return NOT_AVAILABLE + + def __get_data(self, field): + """ + Retrieves data frome JSON file by field + + Args : + field: String + + Returns: + A string if getting is successfully, 'N/A' if not + """ + if self.name not in self.__db_data.keys(): + return NOT_AVAILABLE + + if field not in self.__db_data[self.name].keys(): + return NOT_AVAILABLE + + return self.__db_data[self.name][field] + + def __set_data(self, field, new_val): + """ + Set data to JSON file by field + + Args : + field: String + new_val: String + + Returns: + A boolean, True if setting is set successfully, False if not + """ + if self.name not in self.__db_data.keys(): + self.__db_data[self.name] = {} + + old_val = self.__db_data[self.name].get(field, None) + if old_val is not None and old_val == new_val: + return True + + self.__db_data[self.name][field] = new_val + + try: + with self.flock: + db_data = {} + mode = "w+" + if os.path.exists(DEVICE_THRESHOLD_JSON_PATH): + mode = "r+" + with open(DEVICE_THRESHOLD_JSON_PATH, mode) as db_file: + if mode == "r+": + db_data = json.load(db_file) + + if self.name not in db_data.keys(): + db_data[self.name] = {} + + db_data[self.name][field] = new_val + + if mode == "r+": + db_file.seek(0) + # erase old data + db_file.truncate(0) + # write all data + json.dump(db_data, db_file, indent=4) + except Exception as e: + self.__log.log_error('{}'.format(str(e))) + return False + + return True + + def get_high_threshold(self): + """ + Retrieves the high threshold temperature from JSON file. + + Returns: + string : the high threshold temperature of thermal, + e.g. "30.125" + """ + return self.__get_data(HIGH_THRESHOLD_FIELD) + + def set_high_threshold(self, temperature): + """ + Sets the high threshold temperature of thermal + Args : + temperature: A string of temperature, e.g. "30.125" + Returns: + A boolean, True if threshold is set successfully, False if not + """ + if isinstance(temperature, str) is not True: + raise TypeError('The parameter requires string type.') + + try: + if temperature != NOT_AVAILABLE: + tmp = float(temperature) + except ValueError: + raise ValueError('The parameter requires a float string. ex:\"30.1\"') + + return self.__set_data(HIGH_THRESHOLD_FIELD, temperature) + + def get_low_threshold(self): + """ + Retrieves the low threshold temperature from JSON file. + + Returns: + string : the low threshold temperature of thermal, + e.g. "30.125" + """ + return self.__get_data(LOW_THRESHOLD_FIELD) + + def set_low_threshold(self, temperature): + """ + Sets the low threshold temperature of thermal + Args : + temperature: A string of temperature, e.g. "30.125" + Returns: + A boolean, True if threshold is set successfully, False if not + """ + if isinstance(temperature, str) is not True: + raise TypeError('The parameter requires string type.') + + try: + if temperature != NOT_AVAILABLE: + tmp = float(temperature) + except ValueError: + raise ValueError('The parameter requires a float string. ex:\"30.1\"') + + return self.__set_data(LOW_THRESHOLD_FIELD, temperature) + + def get_high_critical_threshold(self): + """ + Retrieves the high critical threshold temperature from JSON file. + + Returns: + string : the high critical threshold temperature of thermal, + e.g. "30.125" + """ + return self.__get_data(HIGH_CRIT_THRESHOLD_FIELD) + + def set_high_critical_threshold(self, temperature): + """ + Sets the high critical threshold temperature of thermal + Args : + temperature: A string of temperature, e.g. "30.125" + Returns: + A boolean, True if threshold is set successfully, False if not + """ + if isinstance(temperature, str) is not True: + raise TypeError('The parameter requires string type.') + + try: + if temperature != NOT_AVAILABLE: + tmp = float(temperature) + except ValueError: + raise ValueError('The parameter requires a float string. ex:\"30.1\"') + + return self.__set_data(HIGH_CRIT_THRESHOLD_FIELD, temperature) + + def get_low_critical_threshold(self): + """ + Retrieves the low critical threshold temperature from JSON file. + + Returns: + string : the low critical threshold temperature of thermal, + e.g. "30.125" + """ + return self.__get_data(LOW_CRIT_THRESHOLD_FIELD) + + def set_low_critical_threshold(self, temperature): + """ + Sets the low critical threshold temperature of thermal + Args : + temperature: A string of temperature, e.g. "30.125" + Returns: + A boolean, True if threshold is set successfully, False if not + """ + if isinstance(temperature, str) is not True: + raise TypeError('The parameter requires string type.') + + try: + if temperature != NOT_AVAILABLE: + tmp = float(temperature) + except ValueError: + raise ValueError('The parameter requires a float string. ex:\"30.1\"') + + return self.__set_data(LOW_CRIT_THRESHOLD_FIELD, temperature) \ No newline at end of file diff --git a/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/pcie.py b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/pcie.py new file mode 100644 index 0000000000..e4da32adf9 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/pcie.py @@ -0,0 +1,19 @@ +############################################################################# +# Edgecore +# +# Module contains an implementation of SONiC Platform Base API and +# provides the fan status which are available in the platform +# Base PCIe class +############################################################################# + +try: + from sonic_platform_base.sonic_pcie.pcie_common import PcieUtil +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Pcie(PcieUtil): + """Edgecore Platform-specific PCIe class""" + + def __init__(self, platform_path): + PcieUtil.__init__(self, platform_path) diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/platform.py b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/platform.py similarity index 99% rename from device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/platform.py rename to device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/platform.py index 2f2c2a447f..aa5ab500dd 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/platform.py +++ b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/platform.py @@ -12,7 +12,6 @@ except ImportError as e: raise ImportError(str(e) + "- required module not found") - class Platform(PlatformBase): """Platform-specific Platform class""" diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/psu.py b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/psu.py similarity index 50% rename from device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/psu.py rename to device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/psu.py index 44566aba1f..28c021a613 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/psu.py +++ b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/psu.py @@ -11,69 +11,66 @@ try: from sonic_platform_base.psu_base import PsuBase from sonic_platform.thermal import Thermal + from .helper import APIHelper except ImportError as e: raise ImportError(str(e) + "- required module not found") -I2C_PATH = "/sys/bus/i2c/devices/{}-00{}/" - -PSU_NAME_LIST = ["PSU-1", "PSU-2"] -PSU_NUM_FAN = [1, 1] -PSU_HWMON_I2C_MAPPING = { +I2C_PATH ="/sys/bus/i2c/devices/{}-00{}/" +PSU_PMBUS_I2C_MAPPING = { 0: { - "bus": 17, - "addr": "59" + "num": 8, + "addr": "58" }, 1: { - "bus": 13, - "addr": "5b" - }, + "num": 9, + "addr": "59" + } } -PSU_CPLD_I2C_MAPPING = { +PSU_EEPROM_I2C_MAPPING = { 0: { - "bus": 17, - "addr": "51" + "num": 8, + "addr": "50" }, 1: { - "bus": 13, - "addr": "53" - }, + "num": 9, + "addr": "51" + } } -NUM_FAN_TRAY = 6 - +PSU_NUM_FAN = [1, 1] +THERMAL_COUNT_PER_PSU = 2 class Psu(PsuBase): """Platform-specific Psu class""" def __init__(self, psu_index=0): PsuBase.__init__(self) + self._api_helper = APIHelper() self.index = psu_index - bus = PSU_HWMON_I2C_MAPPING[self.index]["bus"] - addr = PSU_HWMON_I2C_MAPPING[self.index]["addr"] - self.hwmon_path = I2C_PATH.format(bus, addr) + self.i2c_num = PSU_PMBUS_I2C_MAPPING[self.index]["num"] + self.i2c_addr = PSU_PMBUS_I2C_MAPPING[self.index]["addr"] + self.pmbus_path = I2C_PATH.format(self.i2c_num, self.i2c_addr) + + self.i2c_num = PSU_EEPROM_I2C_MAPPING[self.index]["num"] + self.i2c_addr = PSU_EEPROM_I2C_MAPPING[self.index]["addr"] + self.eeprom_path = I2C_PATH.format(self.i2c_num, self.i2c_addr) - bus = PSU_CPLD_I2C_MAPPING[self.index]["bus"] - addr = PSU_CPLD_I2C_MAPPING[self.index]["addr"] - self.cpld_path = I2C_PATH.format(bus, addr) self.__initialize_fan() + self.__initialize_thermal() def __initialize_fan(self): from sonic_platform.fan import Fan - self._fan_list.append( - Fan(NUM_FAN_TRAY + self.index, - is_psu_fan=True, - psu_index=self.index)) - self._thermal_list.append(Thermal(is_psu=True, psu_index=self.index)) - - def __read_txt_file(self, file_path): - try: - with open(file_path, 'r') as fd: - return fd.read().strip() - except IOError: - pass - return None + for fan_index in range(0, PSU_NUM_FAN[self.index]): + fan = Fan(fan_index, 0, is_psu_fan=True, psu_index=self.index) + self._fan_list.append(fan) + + def __initialize_thermal(self): + from sonic_platform.thermal import Thermal + for thermal_id in range(0, THERMAL_COUNT_PER_PSU): + thermal = Thermal(thermal_index=thermal_id, is_psu=True, psu_index=self.index) + self._thermal_list.append(thermal) def get_voltage(self): """ @@ -82,23 +79,31 @@ def get_voltage(self): A float number, the output voltage in volts, e.g. 12.1 """ - val = self.__read_txt_file(self.hwmon_path + "psu_v_out") - if val is not None: - return float(val)/ 1000 - else: + if self.get_status() is not True: return 0 + vout_path = "{}{}".format(self.pmbus_path, 'psu_v_out') + vout_val=self._api_helper.read_txt_file(vout_path) + if vout_val is not None: + return float(vout_val) / 1000 + else: + return None + def get_current(self): """ Retrieves present electric current supplied by PSU Returns: A float number, the electric current in amperes, e.g 15.4 """ - val = self.__read_txt_file(self.hwmon_path + "psu_i_out") + if self.get_status() is not True: + return 0 + + iout_path = "{}{}".format(self.pmbus_path, 'psu_i_out') + val = self._api_helper.read_txt_file(iout_path) if val is not None: - return float(val)/1000 + return float(val) / 1000 else: - return 0 + return None def get_power(self): """ @@ -106,11 +111,15 @@ def get_power(self): Returns: A float number, the power in watts, e.g. 302.6 """ - val = self.__read_txt_file(self.hwmon_path + "psu_p_out") + if self.get_status() is not True: + return 0 + + pout_path = "{}{}".format(self.pmbus_path, 'psu_p_out') + val = self._api_helper.read_txt_file(pout_path) if val is not None: - return float(val)/1000 + return float(val) / 1000 else: - return 0 + return None def get_powergood_status(self): """ @@ -131,7 +140,7 @@ def set_status_led(self, color): bool: True if status LED state is set successfully, False if not """ - return False #Controlled by HW + return True #Controlled by HW def get_status_led(self): """ @@ -139,14 +148,13 @@ def get_status_led(self): Returns: A string, one of the predefined STATUS_LED_COLOR_* strings above """ - status=self.get_status() - if status is None: - return self.STATUS_LED_COLOR_OFF + if self.get_presence() is not True: + return None return { - 1: self.STATUS_LED_COLOR_GREEN, - 0: self.STATUS_LED_COLOR_RED - }.get(status, self.STATUS_LED_COLOR_OFF) + True: self.STATUS_LED_COLOR_GREEN, + False: self.STATUS_LED_COLOR_AMBER + }.get(self.get_status(), None) def get_temperature(self): """ @@ -155,16 +163,15 @@ def get_temperature(self): A float number of current temperature in Celsius up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - return self._thermal_list[0].get_temperature() + if self.get_status() is not True: + return None - def get_temperature_high_threshold(self): - """ - Retrieves the high threshold temperature of PSU - Returns: - A float number, the high threshold temperature of PSU in Celsius - up to nearest thousandth of one degree Celsius, e.g. 30.125 - """ - return False #Not supported + temp_path = "{}{}".format(self.pmbus_path, 'psu_temp2_input') + val = self._api_helper.read_txt_file(temp_path) + if val is not None: + return float(val) / 1000 + else: + return None def get_voltage_high_threshold(self): """ @@ -173,11 +180,15 @@ def get_voltage_high_threshold(self): A float number, the high threshold output voltage in volts, e.g. 12.1 """ - val = self.__read_txt_file(self.hwmon_path + "psu_mfr_vout_max") - if val is not None: - return float(val)/ 1000 + if self.get_status() is not True: + return None + + vout_path = "{}{}".format(self.pmbus_path, 'psu_mfr_vout_max') + vout_val = self._api_helper.read_txt_file(vout_path) + if vout_val is not None: + return float(vout_val) / 1000 else: - return 0 + return None def get_voltage_low_threshold(self): """ @@ -186,11 +197,32 @@ def get_voltage_low_threshold(self): A float number, the low threshold output voltage in volts, e.g. 12.1 """ - val = self.__read_txt_file(self.hwmon_path + "psu_mfr_vout_min") + if self.get_status() is not True: + return None + + vout_path = "{}{}".format(self.pmbus_path, 'psu_mfr_vout_min') + vout_val = self._api_helper.read_txt_file(vout_path) + if vout_val is not None: + return float(vout_val) / 1000 + else: + return None + + def get_maximum_supplied_power(self): + """ + Retrieves the maximum supplied power by PSU + Returns: + A float number, the maximum power output in Watts. + e.g. 1200.1 + """ + if self.get_status() is not True: + return None + + pout_path = "{}{}".format(self.pmbus_path, 'psu_mfr_pout_max') + val = self._api_helper.read_txt_file(pout_path) if val is not None: - return float(val)/ 1000 + return float(val) / 1000 else: - return 0 + return None def get_name(self): """ @@ -198,7 +230,7 @@ def get_name(self): Returns: string: The name of the device """ - return PSU_NAME_LIST[self.index] + return "PSU-{}".format(self.index+1) def get_presence(self): """ @@ -206,11 +238,12 @@ def get_presence(self): Returns: bool: True if PSU is present, False if not """ - val = self.__read_txt_file(self.cpld_path + "psu_present") + presence_path = "{}{}".format(self.eeprom_path, 'psu_present') + val = self._api_helper.read_txt_file(presence_path) if val is not None: return int(val, 10) == 1 else: - return 0 + return False def get_status(self): """ @@ -218,11 +251,12 @@ def get_status(self): Returns: A boolean value, True if device is operating properly, False if not """ - val = self.__read_txt_file(self.cpld_path + "psu_power_good") + power_path = "{}{}".format(self.eeprom_path, 'psu_power_good') + val = self._api_helper.read_txt_file(power_path) if val is not None: return int(val, 10) == 1 else: - return 0 + return False def get_model(self): """ @@ -230,7 +264,12 @@ def get_model(self): Returns: string: Model/part number of device """ - model = self.__read_txt_file(self.cpld_path + "psu_model_name") + if self.get_status() is not True: + return "N/A" + + model_path = "{}{}".format(self.eeprom_path, 'psu_model_name') + model = self._api_helper.read_txt_file(model_path) + if model is None: return "N/A" return model @@ -241,24 +280,55 @@ def get_serial(self): Returns: string: Serial number of device """ - serial = self.__read_txt_file(self.cpld_path + "psu_serial_number") + if self.get_status() is not True: + return "N/A" + + serial_path = "{}{}".format(self.eeprom_path, 'psu_serial_numer') + serial = self._api_helper.read_txt_file(serial_path) + if serial is None: return "N/A" return serial + def is_replaceable(self): + """ + Indicate whether Chassis is replaceable. + Returns: + bool: True if it is replaceable. + """ + return True + def get_position_in_parent(self): """ - Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position - for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned + Retrieves 1-based relative physical position in parent device. + If the agent cannot determine the parent-relative position + for some reason, or if the associated value of + entPhysicalContainedIn is'0', then the value '-1' is returned Returns: - integer: The 1-based relative physical position in parent device or -1 if cannot determine the position + integer: The 1-based relative physical position in parent device + or -1 if cannot determine the position """ return self.index+1 - def is_replaceable(self): + def get_temperature_high_threshold(self): """ - Indicate whether this device is replaceable. + Retrieves the high threshold temperature of PSU Returns: - bool: True if it is replaceable. + A float number, the high threshold temperature of PSU in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - return True + return self._thermal_list[0].get_high_threshold() + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + revision_path = "{}{}".format(self.pmbus_path, 'psu_mfr_revision') + revision = self._api_helper.read_txt_file(revision_path) + if revision is not None: + return revision + else: + return 'N/A' diff --git a/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/sfp.py b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/sfp.py new file mode 100644 index 0000000000..cc0afb5424 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/sfp.py @@ -0,0 +1,283 @@ +############################################################################# +# Edgecore +# +# Sfp contains an implementation of SONiC Platform Base API and +# provides the sfp device status which are available in the platform +# +############################################################################# +import subprocess + +try: + from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase + from sonic_platform_base.sonic_sfp.sfputilhelper import SfpUtilHelper + from sonic_py_common import device_info + from .helper import APIHelper +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +#Edge-core definitions +CPLD1_I2C_PATH = "/sys/bus/i2c/devices/0-0064/" +I2C_EEPROM_PATH = '/sys/bus/i2c/devices/{0}-0050/eeprom' + +OPTOE1_TYPE_LIST = [ + 0x0D, # QSFP+ or later + 0x11 # QSFP28 or later +] +OPTOE2_TYPE_LIST = [ + 0x03 # SFP/SFP+/SFP28 and later +] +OPTOE3_TYPE_LIST = [ + 0x18, # QSFP-DD + 0x19, # OSFP + 0x1E # QSFP+ or later with CMIS +] + +class Sfp(SfpOptoeBase): + """Platform-specific Sfp class""" + HOST_CHK_CMD = ["which", "systemctl"] + + # Path to sysfs + PLATFORM_ROOT_PATH = "/usr/share/sonic/device" + PMON_HWSKU_PATH = "/usr/share/sonic/hwsku" + + SFP_PORT_START = 49 + SFP_PORT_END = 54 + + _port_to_i2c_mapping = { + 49: [10], + 50: [11], + 51: [12], + 52: [13], + 53: [14], + 54: [15] + } + + def __init__(self, sfp_index=1, sfp_name=None): + SfpOptoeBase.__init__(self) + self.index = sfp_index + self.port_num = self.index + self._api_helper = APIHelper() + self._name = sfp_name + + if self.SFP_PORT_START <= self.port_num <= self.SFP_PORT_END: + self.eeprom_path = I2C_EEPROM_PATH.format(self._port_to_i2c_mapping[self.port_num][0]) + SfpOptoeBase.__init__(self) + self.refresh() + + def get_eeprom_path(self): + return self.eeprom_path + + def __is_host(self): + return subprocess.call(self.HOST_CHK_CMD) == 0 + + def reset(self): + """ + Reset SFP and return all user module settings to their default srate. + Returns: + A boolean, True if successful, False if not + """ + return False # SFP port doesn't support this feature + + def get_reset_status(self): + """ + Retrieves the reset status of SFP + Returns: + A Boolean, True if reset enabled, False if disabled + """ + return False # SFP port doesn't support this feature + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + sfputil_helper = SfpUtilHelper() + port_config_file_path = device_info.get_path_to_port_config_file() + sfputil_helper.read_porttab_mappings(port_config_file_path) + name = sfputil_helper.logical[self.index-1] or "Unknown" + return name + + def get_presence(self): + """ + Retrieves the presence of the device + Returns: + bool: True if device is present, False if not + """ + if self.port_num < self.SFP_PORT_START: + return False + + present_path = "{}{}{}".format(CPLD1_I2C_PATH, '/module_present_', self.port_num) + val = self._api_helper.read_txt_file(present_path) + if val is not None: + return int(val, 10) == 1 + else: + return False + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + return self.get_presence() + + def refresh(self): + self.refresh_xcvr_api() + return True + + def get_lpmode(self): + """ + Retrieves the lpmode (low power mode) status of this SFP + Returns: + A Boolean, True if lpmode is enabled, False if disabled + """ + # SFP doesn't support this feature + return False + + def set_lpmode(self, lpmode): + """ + Sets the lpmode (low power mode) of SFP + Args: + lpmode: A Boolean, True to enable lpmode, False to disable it + Note : lpmode can be overridden by set_power_override + Returns: + A boolean, True if lpmode is set successfully, False if not + """ + # SFP doesn't support this feature + return False + + def get_power_override(self): + """ + Retrieves the power-override status of this SFP + Returns: + A Boolean, True if power-override is enabled, False if disabled + """ + # SFP doesn't support this feature + return False + + def get_position_in_parent(self): + """Retrieves 1-based relative physical position in parent device.""" + return self.port_num + + def is_replaceable(self): + """ + Retrieves if replaceable + Returns: + A boolean value, True if replaceable + """ + return True + + def validate_eeprom_sfp(self): + checksum_test = 0 + eeprom_raw = self.read_eeprom(0, 96) + if eeprom_raw is None: + return None + + for i in range(0, 63): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + if checksum_test != eeprom_raw[63]: + return False + + checksum_test = 0 + for i in range(64, 95): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + if checksum_test != eeprom_raw[95]: + return False + + api = self.get_xcvr_api() + if api is None: + return False + + if api.is_flat_memory(): + return True + + checksum_test = 0 + eeprom_raw = self.read_eeprom(384, 96) + if eeprom_raw is None: + return None + + for i in range(0, 95): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + if checksum_test != eeprom_raw[95]: + return False + + return True + + def validate_eeprom(self): + id_byte_raw = self.read_eeprom(0, 1) + if id_byte_raw is None: + return None + + return self.validate_eeprom_sfp() + + def validate_temperature(self): + temperature = self.get_temperature() + if temperature is None: + return None + + threshold_dict = self.get_transceiver_threshold_info() + if threshold_dict is None: + return None + + if isinstance(temperature, float) is not True: + return True + + if isinstance(threshold_dict['temphighalarm'], float) is not True: + return True + + return threshold_dict['temphighalarm'] > temperature + + def update_sfp_type(self): + """ + The sfp type would not change. + Don't need to update sfp type + """ + pass + + def __get_error_description(self): + if not self.get_presence(): + return self.SFP_STATUS_UNPLUGGED + + err_stat = self.SFP_STATUS_BIT_INSERTED + + status = self.validate_eeprom() + if status is not True: + err_state |= self.SFP_ERROR_BIT_BAD_EEPROM + + status = self.validate_temperature() + if status is not True: + err_state |= self.SFP_ERROR_BIT_HIGH_TEMP + + if err_stat is self.SFP_STATUS_BIT_INSERTED: + return self.SFP_STATUS_OK + else: + err_desc = str() + for key in self.SFP_ERROR_BIT_TO_DESCRIPTION_DICT: + if (err_stat & key) != 0: + if len(err_desc) > 0: + err_desc += '|' + err_desc += self.SFP_ERROR_BIT_TO_DESCRIPTION_DICT[key] + + return err_desc + + def get_error_description(self): + """ + Retrives the error descriptions of the SFP module + Returns: + String that represents the current error descriptions of vendor specific errors + In case there are multiple errors, they should be joined by '|', + like: "Bad EEPROM|Unsupported cable" + """ + if self.port_num < 49: + # RJ45 doesn't support this feature + return "Not implemented" + else: + api = self.get_xcvr_api() + if api is not None: + try: + return api.get_error_description() + except NotImplementedError: + return self.__get_error_description() + else: + return self.__get_error_description() diff --git a/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/thermal.py b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/thermal.py new file mode 100644 index 0000000000..79d2813dd2 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/thermal.py @@ -0,0 +1,540 @@ +############################################################################# +# Edgecore +# +# Thermal contains an implementation of SONiC Platform Base API and +# provides the thermal device status which are available in the platform +# +############################################################################# + +import os +import os.path +import glob + +try: + from sonic_platform_base.thermal_base import ThermalBase + from .helper import APIHelper + from .helper import DeviceThreshold +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +THERMAL_COUNT_PER_PSU = 2 +THERMAL_I2C_PATH = "/sys/bus/i2c/devices/{}-00{}/hwmon/hwmon*/" +CPU_SYSFS_PATH = "/sys/devices/platform/coretemp.0/hwmon/hwmon*/" + +I2C_PATH = "/sys/bus/i2c/devices/{}-00{}/" +PSU_PMBUS_I2C_MAPPING = { + 0: { + "num": 8, + "addr": "58" + }, + 1: { + "num": 9, + "addr": "59" + } +} + +PSU_EEPROM_I2C_MAPPING = { + 0: { + "num": 8, + "addr": "50" + }, + 1: { + "num": 9, + "addr": "51" + } +} + +THERMAL_I2C_MAPPING = { + 0: { + "num": 3, + "addr": "4a" + }, + 1: { + "num": 3, + "addr": "4b" + }, + 2: { + "num": 3, + "addr": "4d" + }, + 3: { + "num": 3, + "addr": "4e" + }, + 4: { + "num": 3, + "addr": "4f" + } +} + +class Thermal(ThermalBase): + """Platform-specific Thermal class""" + THERMAL_NAME_LIST = [ + "MB_Temp(0x4a)", + "MB_Temp(0x4b)", + "MB_Temp(0x4d)", + "MB_Temp(0x4e)", + "MB_Temp(0x4f)", + "CPU Package Temp", + "CPU Core 0 Temp", + "CPU Core 1 Temp", + "CPU Core 2 Temp", + "CPU Core 3 Temp" + ] + + PSU_THERMAL_NAME_LIST = [ + "PSU-1 temp sensor 1", + "PSU-1 temp sensor 2", + "PSU-2 temp sensor 1", + "PSU-2 temp sensor 2" + ] + + def __init__(self, thermal_index=0, is_psu=False, psu_index=0): + self.index = thermal_index + self.is_psu = is_psu + self.psu_index = psu_index + self.is_cpu = False + self.min_temperature = None + self.max_temperature = None + self.pcb_id = self.__get_pcb_id() + + self.conf = DeviceThreshold(self.get_name()) + # Default thresholds + self.default_threshold = { + 0: { # PCB_ID 0: AS4625-54P + self.THERMAL_NAME_LIST[0] : { + self.conf.HIGH_THRESHOLD_FIELD : '67.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '72.0' }, + self.THERMAL_NAME_LIST[1] : { + self.conf.HIGH_THRESHOLD_FIELD : '67.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '72.0' }, + self.THERMAL_NAME_LIST[2] : { + self.conf.HIGH_THRESHOLD_FIELD : '73.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '78.0' }, + self.THERMAL_NAME_LIST[3] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '80.0' }, + self.THERMAL_NAME_LIST[4] : { + self.conf.HIGH_THRESHOLD_FIELD : '69.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '74.0' }, + self.THERMAL_NAME_LIST[5] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.THERMAL_NAME_LIST[6] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.THERMAL_NAME_LIST[7] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.THERMAL_NAME_LIST[8] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.THERMAL_NAME_LIST[9] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.PSU_THERMAL_NAME_LIST[0] : { + self.conf.HIGH_THRESHOLD_FIELD : '70.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '90.0' }, + self.PSU_THERMAL_NAME_LIST[1] : { + self.conf.HIGH_THRESHOLD_FIELD : '70.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '101.0' }, + self.PSU_THERMAL_NAME_LIST[2] : { + self.conf.HIGH_THRESHOLD_FIELD : '70.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '90.0' }, + self.PSU_THERMAL_NAME_LIST[3] : { + self.conf.HIGH_THRESHOLD_FIELD : '70.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '101.0' } + }, + 1: { # PCB_ID 1: AS4625-54T-F2B + self.THERMAL_NAME_LIST[0] : { + self.conf.HIGH_THRESHOLD_FIELD : '65.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '70.0' }, + self.THERMAL_NAME_LIST[1] : { + self.conf.HIGH_THRESHOLD_FIELD : '65.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '70.0' }, + self.THERMAL_NAME_LIST[2] : { + self.conf.HIGH_THRESHOLD_FIELD : '62.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '67.0' }, + self.THERMAL_NAME_LIST[3] : { + self.conf.HIGH_THRESHOLD_FIELD : '70.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '75.0' }, + self.THERMAL_NAME_LIST[4] : { + self.conf.HIGH_THRESHOLD_FIELD : '65.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '70.0' }, + self.THERMAL_NAME_LIST[5] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.THERMAL_NAME_LIST[6] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.THERMAL_NAME_LIST[7] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.THERMAL_NAME_LIST[8] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.THERMAL_NAME_LIST[9] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.PSU_THERMAL_NAME_LIST[0] : { + self.conf.HIGH_THRESHOLD_FIELD : '65.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '83.0' }, + self.PSU_THERMAL_NAME_LIST[1] : { + self.conf.HIGH_THRESHOLD_FIELD : '65.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '77.0' }, + self.PSU_THERMAL_NAME_LIST[2] : { + self.conf.HIGH_THRESHOLD_FIELD : '65.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '83.0' }, + self.PSU_THERMAL_NAME_LIST[3] : { + self.conf.HIGH_THRESHOLD_FIELD : '65.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '77.0' } + }, + 2: { # PCB_ID 2: AS4625-54T-B2F + self.THERMAL_NAME_LIST[0] : { + self.conf.HIGH_THRESHOLD_FIELD : '65.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '70.0' }, + self.THERMAL_NAME_LIST[1] : { + self.conf.HIGH_THRESHOLD_FIELD : '67.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '72.0' }, + self.THERMAL_NAME_LIST[2] : { + self.conf.HIGH_THRESHOLD_FIELD : '66.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '71.0' }, + self.THERMAL_NAME_LIST[3] : { + self.conf.HIGH_THRESHOLD_FIELD : '73.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '78.0' }, + self.THERMAL_NAME_LIST[4] : { + self.conf.HIGH_THRESHOLD_FIELD : '66.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '71.0' }, + self.THERMAL_NAME_LIST[5] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.THERMAL_NAME_LIST[6] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.THERMAL_NAME_LIST[7] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.THERMAL_NAME_LIST[8] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.THERMAL_NAME_LIST[9] : { + self.conf.HIGH_THRESHOLD_FIELD : '75.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '95.0' }, + self.PSU_THERMAL_NAME_LIST[0] : { + self.conf.HIGH_THRESHOLD_FIELD : '65.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '83.0' }, + self.PSU_THERMAL_NAME_LIST[1] : { + self.conf.HIGH_THRESHOLD_FIELD : '65.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '77.0' }, + self.PSU_THERMAL_NAME_LIST[2] : { + self.conf.HIGH_THRESHOLD_FIELD : '65.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '83.0' }, + self.PSU_THERMAL_NAME_LIST[3] : { + self.conf.HIGH_THRESHOLD_FIELD : '65.0', + self.conf.HIGH_CRIT_THRESHOLD_FIELD : '77.0' } + }, + } + + if self.index in range(5,10): + self.is_cpu = True + + if self.is_psu: + self.i2c_num = PSU_PMBUS_I2C_MAPPING[self.psu_index]["num"] + self.i2c_addr = PSU_PMBUS_I2C_MAPPING[self.psu_index]["addr"] + self.pmbus_path = I2C_PATH.format(self.i2c_num, self.i2c_addr) + + self.i2c_num = PSU_EEPROM_I2C_MAPPING[self.psu_index]["num"] + self.i2c_addr = PSU_EEPROM_I2C_MAPPING[self.psu_index]["addr"] + self.eeprom_path = I2C_PATH.format(self.i2c_num, self.i2c_addr) + elif self.is_cpu: + self.ss_index = 0 + coretemp_list = self.__get_coretemp_list() + if coretemp_list is not None and len(coretemp_list) >= 5: + self.ss_index = coretemp_list[self.index-5] + self.hwmon_path = CPU_SYSFS_PATH + else: + # Set sysfs path + self.i2c_num = THERMAL_I2C_MAPPING[self.index]["num"] + self.i2c_addr = THERMAL_I2C_MAPPING[self.index]["addr"] + self.hwmon_path = THERMAL_I2C_PATH.format(self.i2c_num, self.i2c_addr) + + def __get_coretemp_list(self): + coretemp_path = "{}{}".format(CPU_SYSFS_PATH, "temp*_input") + coretemp_files = glob.glob(coretemp_path) + + for (idx, file) in enumerate(coretemp_files): + file = file[file.rfind("/")+1:] # Discard its directory, keep file name + file = file.strip("temp").strip("_input") # Discard temp_input, keep the index string + coretemp_files[idx] = int(file) + + coretemp_files.sort() + return coretemp_files + + def __read_txt_file(self, file_path): + for filename in glob.glob(file_path): + try: + with open(filename, 'r') as fd: + data = fd.readline().rstrip() + if len(data) > 0: + return data + except IOError as e: + pass + + return None + + def __get_temp(self, path, temp_file): + file_path = os.path.join(path, temp_file) + raw_temp = self.__read_txt_file(file_path) + if raw_temp is not None: + return float(raw_temp) / 1000 + else: + return None + + def __set_threshold(self, path, file_name, temperature): + if self.is_psu: + return True + + file_path = os.path.join(path, file_name) + for filename in glob.glob(file_path): + try: + with open(filename, 'w') as fd: + fd.write(str(temperature)) + return True + except IOError as e: + print("IOError") + + def __get_pcb_id(self): + cpld_path = I2C_PATH.format('0', '64') + 'pcb_id' + pcb_id = self.__read_txt_file(cpld_path) + if pcb_id is not None: + return int(pcb_id) + + return None + + 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 + """ + if self.is_cpu: + ss_file = "temp{}_input".format(self.ss_index) + current = self.__get_temp(self.hwmon_path, ss_file) + elif self.is_psu: + if not self.get_presence(): + return None + + power_path = "{}{}".format(self.eeprom_path, 'psu_power_good') + val = self.__read_txt_file(power_path) + if val is not None: + if int(val, 10) != 1: + return None + + # The base index start from 2 since temp1_input is not used by the PSU + ss_file = "temp{}_input".format(self.index + 2) + current = self.__get_temp(self.pmbus_path, ss_file) + else: + current = self.__get_temp(self.hwmon_path, "temp1_input") + + if current is None: + return current + + if self.min_temperature is None or current < self.min_temperature: + self.min_temperature = current + + if self.max_temperature is None or current > self.max_temperature: + self.max_temperature = current + + return current + + def get_high_critical_threshold(self): + """ + Retrieves the high critical threshold temperature of thermal + + Returns: + A float number, the high critical threshold temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + value = self.conf.get_high_critical_threshold() + if value != self.conf.NOT_AVAILABLE: + return float(value) + + default_value = self.default_threshold[self.pcb_id][self.get_name()][self.conf.HIGH_CRIT_THRESHOLD_FIELD] + if default_value != self.conf.NOT_AVAILABLE: + return float(default_value) + + raise NotImplementedError + + def set_high_critical_threshold(self, temperature): + """ + Sets the critical 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 + """ + try: + value = float(temperature) + except: + return False + + try: + self.conf.set_high_critical_threshold(str(value)) + except: + return False + + return True + + 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 + """ + value = self.conf.get_high_threshold() + if value != self.conf.NOT_AVAILABLE: + return float(value) + + default_value = self.default_threshold[self.pcb_id][self.get_name()][self.conf.HIGH_THRESHOLD_FIELD] + if default_value != self.conf.NOT_AVAILABLE: + return float(default_value) + + raise NotImplementedError + + 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 + """ + try: + value = float(temperature) + except: + return False + + try: + self.conf.set_high_threshold(str(value)) + except: + return False + + return True + + def get_name(self): + """ + Retrieves the name of the thermal device + Returns: + string: The name of the thermal device + """ + if self.is_psu: + return self.PSU_THERMAL_NAME_LIST[self.index + self.psu_index * THERMAL_COUNT_PER_PSU] + else: + return self.THERMAL_NAME_LIST[self.index] + + def get_presence(self): + """ + Retrieves the presence of the Thermal + Returns: + bool: True if Thermal is present, False if not + """ + if self.is_cpu: + return True + elif self.is_psu: + path = "{}{}".format(self.eeprom_path, "psu_present") + val = self.__read_txt_file(path) + return int(val, 10) == 1 + else: + path = "{}{}".format(self.hwmon_path, "temp1_input") + val = self.__read_txt_file(path) + if val is not None: + return True + else: + return False + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + if self.is_cpu: + return True + elif self.is_psu: + if not self.get_presence(): + return None + + path = "{}{}".format(self.pmbus_path, "psu_temp_fault") + val = self.__read_txt_file(path) + if val is None: + return False + else: + return int(val, 10) == 0 + else: + if self.get_temperature() is None: + return False + else: + return True + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + + return "N/A" + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return "N/A" + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + If the agent cannot determine the parent-relative position + for some reason, or if the associated value of + entPhysicalContainedIn is'0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device + or -1 if cannot determine the position + """ + return self.index+1 + + def is_replaceable(self): + """ + Retrieves whether thermal module is replaceable + Returns: + A boolean value, True if replaceable, False if not + """ + return False + + def get_minimum_recorded(self): + """ Retrieves the minimum recorded temperature of thermal + Returns: A float number, the minimum recorded temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.min_temperature is None: + self.get_temperature() + + return self.min_temperature + + def get_maximum_recorded(self): + """ Retrieves the maximum recorded temperature of thermal + Returns: A float number, the maximum recorded temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.max_temperature is None: + self.get_temperature() + + return self.max_temperature diff --git a/device/accton/x86_64-accton_as4625_54p-r0/system_health_monitoring_config.json b/device/accton/x86_64-accton_as4625_54p-r0/system_health_monitoring_config.json new file mode 100644 index 0000000000..7aa53bcf4d --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54p-r0/system_health_monitoring_config.json @@ -0,0 +1,14 @@ +{ + "services_to_ignore": [], + "devices_to_ignore": [ + "asic", + "psu.temperature" + ], + "user_defined_checkers": [], + "polling_interval": 60, + "led_color": { + "fault": "STATUS_LED_COLOR_AMBER", + "normal": "STATUS_LED_COLOR_GREEN", + "booting": "STATUS_LED_COLOR_GREEN_BLINKING" + } +} diff --git a/device/accton/x86_64-accton_as4625_54t-r0/Accton-AS4625-54T/hr4-as4625-48x1G+6x10G.config.bcm b/device/accton/x86_64-accton_as4625_54t-r0/Accton-AS4625-54T/hr4-as4625-48x1G+6x10G.config.bcm new file mode 100644 index 0000000000..1ad25c4ffa --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/Accton-AS4625-54T/hr4-as4625-48x1G+6x10G.config.bcm @@ -0,0 +1,386 @@ +stable_size=76303168 + +#polarity/lanemap is using TH2 style. +#core_clock_frequency=496 +core_clock_frequency=266 +#core_clock_frequency=893 +#dpp_clock_ratio=2:3 + +core_clock_to_pm_clock_factor=2 + +oversubscribe_mode=2 +#port_gmii_mode_1=1 #Q mode + +ptp_ts_pll_fref=50000000 +ptp_bs_fref_0=50000000 +ptp_bs_fref_1=50000000 + +pbmp_xport_xe=0x1FFE00FFFFFFFFFFFF + +parity_enable=0 +mem_cache_enable=1 + +l2_mem_entries=32768 +l3_mem_entries=49152 +fpem_mem_entries=16384 +l2xmsg_mode=1 +port_flex_enable=1 + + +l3_alpm_enable=2 +ipv6_lpm_128b_enable=1 +ifp_inports_support_enable=1 + +num_ipv6_lpm_128b_entries=512 + + +dport_map_port_25=1 +dport_map_port_26=2 +dport_map_port_27=3 +dport_map_port_28=4 +dport_map_port_29=5 +dport_map_port_30=6 +dport_map_port_31=7 +dport_map_port_32=8 +portmap_25=25:1 +portmap_26=26:1 +portmap_27=27:1 +portmap_28=28:1 +portmap_29=29:1 +portmap_30=30:1 +portmap_31=31:1 +portmap_32=32:1 +port_phy_addr_25=0x00 +port_phy_addr_26=0x01 +port_phy_addr_27=0x02 +port_phy_addr_28=0x03 +port_phy_addr_29=0x04 +port_phy_addr_30=0x05 +port_phy_addr_31=0x06 +port_phy_addr_32=0x07 +phy_port_primary_and_offset_25=0x1900 +phy_port_primary_and_offset_26=0x1901 +phy_port_primary_and_offset_27=0x1902 +phy_port_primary_and_offset_28=0x1903 +phy_port_primary_and_offset_29=0x1904 +phy_port_primary_and_offset_30=0x1905 +phy_port_primary_and_offset_31=0x1906 +phy_port_primary_and_offset_32=0x1907 +phy_chain_rx_lane_map_physical{25.0}=0x3210 +phy_chain_rx_lane_map_physical{26.0}=0x3210 +phy_chain_rx_lane_map_physical{27.0}=0x3210 +phy_chain_rx_lane_map_physical{28.0}=0x3210 +phy_chain_rx_lane_map_physical{29.0}=0x3210 +phy_chain_rx_lane_map_physical{30.0}=0x3210 +phy_chain_rx_lane_map_physical{31.0}=0x3210 +phy_chain_rx_lane_map_physical{32.0}=0x3210 +phy_chain_tx_lane_map_physical{25.0}=0x3210 +phy_chain_tx_lane_map_physical{26.0}=0x3210 +phy_chain_tx_lane_map_physical{27.0}=0x3210 +phy_chain_tx_lane_map_physical{28.0}=0x3210 +phy_chain_tx_lane_map_physical{29.0}=0x3210 +phy_chain_tx_lane_map_physical{30.0}=0x3210 +phy_chain_tx_lane_map_physical{31.0}=0x3210 +phy_chain_tx_lane_map_physical{32.0}=0x3210 +phy_chain_rx_polarity_flip_physical{25.0}=0x0 +phy_chain_rx_polarity_flip_physical{26.0}=0x0 +phy_chain_rx_polarity_flip_physical{27.0}=0x0 +phy_chain_rx_polarity_flip_physical{28.0}=0x0 +phy_chain_rx_polarity_flip_physical{29.0}=0x0 +phy_chain_rx_polarity_flip_physical{30.0}=0x0 +phy_chain_rx_polarity_flip_physical{31.0}=0x0 +phy_chain_rx_polarity_flip_physical{32.0}=0x0 +phy_chain_tx_polarity_flip_physical{25.0}=0x0 +phy_chain_tx_polarity_flip_physical{26.0}=0x0 +phy_chain_tx_polarity_flip_physical{27.0}=0x0 +phy_chain_tx_polarity_flip_physical{28.0}=0x0 +phy_chain_tx_polarity_flip_physical{29.0}=0x0 +phy_chain_tx_polarity_flip_physical{30.0}=0x0 +phy_chain_tx_polarity_flip_physical{31.0}=0x0 +phy_chain_tx_polarity_flip_physical{32.0}=0x0 + + +dport_map_port_33=9 +dport_map_port_34=10 +dport_map_port_35=11 +dport_map_port_36=12 +dport_map_port_37=13 +dport_map_port_38=14 +dport_map_port_39=15 +dport_map_port_40=16 +portmap_33=33:1 +portmap_34=34:1 +portmap_35=35:1 +portmap_36=36:1 +portmap_37=37:1 +portmap_38=38:1 +portmap_39=39:1 +portmap_40=40:1 +port_phy_addr_33=0x20 +port_phy_addr_34=0x21 +port_phy_addr_35=0x22 +port_phy_addr_36=0x23 +port_phy_addr_37=0x24 +port_phy_addr_38=0x25 +port_phy_addr_39=0x26 +port_phy_addr_40=0x27 +phy_port_primary_and_offset_33=0x2100 +phy_port_primary_and_offset_34=0x2101 +phy_port_primary_and_offset_35=0x2102 +phy_port_primary_and_offset_36=0x2103 +phy_port_primary_and_offset_37=0x2104 +phy_port_primary_and_offset_38=0x2105 +phy_port_primary_and_offset_39=0x2106 +phy_port_primary_and_offset_40=0x2107 +phy_chain_rx_lane_map_physical{33.0}=0x3210 +phy_chain_rx_lane_map_physical{34.0}=0x3210 +phy_chain_rx_lane_map_physical{35.0}=0x3210 +phy_chain_rx_lane_map_physical{36.0}=0x3210 +phy_chain_rx_lane_map_physical{37.0}=0x3210 +phy_chain_rx_lane_map_physical{38.0}=0x3210 +phy_chain_rx_lane_map_physical{39.0}=0x3210 +phy_chain_rx_lane_map_physical{40.0}=0x3210 +phy_chain_tx_lane_map_physical{33.0}=0x3210 +phy_chain_tx_lane_map_physical{34.0}=0x3210 +phy_chain_tx_lane_map_physical{35.0}=0x3210 +phy_chain_tx_lane_map_physical{36.0}=0x3210 +phy_chain_tx_lane_map_physical{37.0}=0x3210 +phy_chain_tx_lane_map_physical{38.0}=0x3210 +phy_chain_tx_lane_map_physical{39.0}=0x3210 +phy_chain_tx_lane_map_physical{40.0}=0x3210 +phy_chain_rx_polarity_flip_physical{33.0}=0x0 +phy_chain_rx_polarity_flip_physical{34.0}=0x0 +phy_chain_rx_polarity_flip_physical{35.0}=0x0 +phy_chain_rx_polarity_flip_physical{36.0}=0x0 +phy_chain_rx_polarity_flip_physical{37.0}=0x0 +phy_chain_rx_polarity_flip_physical{38.0}=0x0 +phy_chain_rx_polarity_flip_physical{39.0}=0x0 +phy_chain_rx_polarity_flip_physical{40.0}=0x0 +phy_chain_tx_polarity_flip_physical{33.0}=0x0 +phy_chain_tx_polarity_flip_physical{34.0}=0x0 +phy_chain_tx_polarity_flip_physical{35.0}=0x0 +phy_chain_tx_polarity_flip_physical{36.0}=0x0 +phy_chain_tx_polarity_flip_physical{37.0}=0x0 +phy_chain_tx_polarity_flip_physical{38.0}=0x0 +phy_chain_tx_polarity_flip_physical{39.0}=0x0 +phy_chain_tx_polarity_flip_physical{40.0}=0x0 + + + +#MQ16_1 +#port_gmii_mode_17=1 #Q mode +dport_map_port_41=17 +dport_map_port_42=18 +dport_map_port_43=19 +dport_map_port_44=20 +dport_map_port_45=21 +dport_map_port_46=22 +dport_map_port_47=23 +dport_map_port_48=24 +portmap_41=41:1 +portmap_42=42:1 +portmap_43=43:1 +portmap_44=44:1 +portmap_45=49:1 +portmap_46=50:1 +portmap_47=51:1 +portmap_48=52:1 +port_phy_addr_41=0x40 +port_phy_addr_42=0x41 +port_phy_addr_43=0x42 +port_phy_addr_44=0x43 +port_phy_addr_45=0x44 +port_phy_addr_46=0x45 +port_phy_addr_47=0x46 +port_phy_addr_48=0x47 +phy_port_primary_and_offset_41=0x2900 +phy_port_primary_and_offset_42=0x2901 +phy_port_primary_and_offset_43=0x2902 +phy_port_primary_and_offset_44=0x2903 +phy_port_primary_and_offset_45=0x2904 +phy_port_primary_and_offset_46=0x2905 +phy_port_primary_and_offset_47=0x2906 +phy_port_primary_and_offset_48=0x2907 +phy_chain_rx_lane_map_physical{41.0}=0x3210 +phy_chain_rx_lane_map_physical{42.0}=0x3210 +phy_chain_rx_lane_map_physical{43.0}=0x3210 +phy_chain_rx_lane_map_physical{44.0}=0x3210 +phy_chain_rx_lane_map_physical{45.0}=0x3210 +phy_chain_rx_lane_map_physical{46.0}=0x3210 +phy_chain_rx_lane_map_physical{47.0}=0x3210 +phy_chain_rx_lane_map_physical{48.0}=0x3210 +phy_chain_tx_lane_map_physical{41.0}=0x3210 +phy_chain_tx_lane_map_physical{42.0}=0x3210 +phy_chain_tx_lane_map_physical{43.0}=0x3210 +phy_chain_tx_lane_map_physical{44.0}=0x3210 +phy_chain_tx_lane_map_physical{45.0}=0x3210 +phy_chain_tx_lane_map_physical{46.0}=0x3210 +phy_chain_tx_lane_map_physical{47.0}=0x3210 +phy_chain_tx_lane_map_physical{48.0}=0x3210 +phy_chain_rx_polarity_flip_physical{41.0}=0x0 +phy_chain_rx_polarity_flip_physical{42.0}=0x0 +phy_chain_rx_polarity_flip_physical{43.0}=0x0 +phy_chain_rx_polarity_flip_physical{44.0}=0x0 +phy_chain_rx_polarity_flip_physical{45.0}=0x0 +phy_chain_rx_polarity_flip_physical{46.0}=0x0 +phy_chain_rx_polarity_flip_physical{47.0}=0x0 +phy_chain_rx_polarity_flip_physical{48.0}=0x0 +phy_chain_tx_polarity_flip_physical{41.0}=0x0 +phy_chain_tx_polarity_flip_physical{42.0}=0x0 +phy_chain_tx_polarity_flip_physical{43.0}=0x0 +phy_chain_tx_polarity_flip_physical{44.0}=0x0 +phy_chain_tx_polarity_flip_physical{45.0}=0x0 +phy_chain_tx_polarity_flip_physical{46.0}=0x0 +phy_chain_tx_polarity_flip_physical{47.0}=0x0 +phy_chain_tx_polarity_flip_physical{48.0}=0x0 + + +#GPHY0 +dport_map_port_1=25 +dport_map_port_2=26 +dport_map_port_3=27 +dport_map_port_4=28 +portmap_1=1:1 +portmap_2=2:1 +portmap_3=3:1 +portmap_4=4:1 +phy_port_primary_and_offset_1=0x0100 +phy_port_primary_and_offset_2=0x0101 +phy_port_primary_and_offset_3=0x0102 +phy_port_primary_and_offset_4=0x0103 + + +#GPHY1 +dport_map_port_5=29 +dport_map_port_6=30 +dport_map_port_7=31 +dport_map_port_8=32 +portmap_5=5:1 +portmap_6=6:1 +portmap_7=7:1 +portmap_8=8:1 +phy_port_primary_and_offset_5=0x0500 +phy_port_primary_and_offset_6=0x0501 +phy_port_primary_and_offset_7=0x0502 +phy_port_primary_and_offset_8=0x0503 + + +#GPHY2 +dport_map_port_9=33 +dport_map_port_10=34 +dport_map_port_11=35 +dport_map_port_12=36 +portmap_9=9:1 +portmap_10=10:1 +portmap_11=11:1 +portmap_12=12:1 +phy_port_primary_and_offset_9=0x0900 +phy_port_primary_and_offset_10=0x0901 +phy_port_primary_and_offset_11=0x0902 +phy_port_primary_and_offset_12=0x0903 + + +#GPHY3 +dport_map_port_13=37 +dport_map_port_14=38 +dport_map_port_15=39 +dport_map_port_16=40 +portmap_13=13:1 +portmap_14=14:1 +portmap_15=15:1 +portmap_16=16:1 +phy_port_primary_and_offset_13=0x0d00 +phy_port_primary_and_offset_14=0x0d01 +phy_port_primary_and_offset_15=0x0d02 +phy_port_primary_and_offset_16=0x0d03 + + +#GPHY4 +dport_map_port_17=41 +dport_map_port_18=42 +dport_map_port_19=43 +dport_map_port_20=44 +portmap_17=17:1 +portmap_18=18:1 +portmap_19=19:1 +portmap_20=20:1 +phy_port_primary_and_offset_17=0x1100 +phy_port_primary_and_offset_18=0x1101 +phy_port_primary_and_offset_19=0x1102 +phy_port_primary_and_offset_20=0x1103 + + +#GPHY5 +dport_map_port_21=45 +dport_map_port_22=46 +dport_map_port_23=47 +dport_map_port_24=48 +portmap_21=21:1 +portmap_22=22:1 +portmap_23=23:1 +portmap_24=24:1 +phy_port_primary_and_offset_21=0x1500 +phy_port_primary_and_offset_22=0x1501 +phy_port_primary_and_offset_23=0x1502 +phy_port_primary_and_offset_24=0x1503 + + +#PHYx TSC-F16-0, TSC2 +dport_map_port_57=49 +dport_map_port_58=50 +dport_map_port_59=51 +dport_map_port_60=52 +portmap_57=57:10 +portmap_58=58:10 +portmap_59=59:10 +portmap_60=60:10 +phy_chain_tx_lane_map_physical{57.0}=0x3210 +phy_chain_tx_lane_map_physical{58.0}=0x3210 +phy_chain_tx_lane_map_physical{59.0}=0x3210 +phy_chain_tx_lane_map_physical{60.0}=0x3210 +phy_chain_rx_lane_map_physical{57.0}=0x3210 +phy_chain_rx_lane_map_physical{58.0}=0x3210 +phy_chain_rx_lane_map_physical{59.0}=0x3210 +phy_chain_rx_lane_map_physical{60.0}=0x3210 +phy_chain_tx_polarity_flip_physical{57.0}=0x0 +phy_chain_tx_polarity_flip_physical{58.0}=0x0 +phy_chain_tx_polarity_flip_physical{59.0}=0x0 +phy_chain_tx_polarity_flip_physical{60.0}=0x0 +phy_chain_rx_polarity_flip_physical{57.0}=0x0 +phy_chain_rx_polarity_flip_physical{58.0}=0x0 +phy_chain_rx_polarity_flip_physical{59.0}=0x0 +phy_chain_rx_polarity_flip_physical{60.0}=0x0 + + +#PHYx TSC-M16-0, TSC3 +dport_map_port_61=53 +dport_map_port_62=54 +#dport_map_port_63=55 +#dport_map_port_64=56 +portmap_61=61:10 +portmap_62=62:10 +#portmap_63=63:10 +#portmap_64=64:10 +phy_chain_tx_lane_map_physical{61.0}=0x3210 +phy_chain_tx_lane_map_physical{62.0}=0x3210 +phy_chain_tx_lane_map_physical{63.0}=0x3210 +phy_chain_tx_lane_map_physical{64.0}=0x3210 +phy_chain_rx_lane_map_physical{61.0}=0x3210 +phy_chain_rx_lane_map_physical{62.0}=0x3210 +#phy_chain_rx_lane_map_physical{63.0}=0x3210 +#phy_chain_rx_lane_map_physical{64.0}=0x3210 +phy_chain_tx_polarity_flip_physical{61.0}=0x0 +phy_chain_tx_polarity_flip_physical{62.0}=0x0 +phy_chain_tx_polarity_flip_physical{63.0}=0x0 +phy_chain_tx_polarity_flip_physical{64.0}=0x0 +phy_chain_rx_polarity_flip_physical{61.0}=0x0 +phy_chain_rx_polarity_flip_physical{62.0}=0x0 +#phy_chain_rx_polarity_flip_physical{63.0}=0x0 +#phy_chain_rx_polarity_flip_physical{64.0}=0x0 + + + +# MerlinCore-Q SerDes +#port_gmii_mode=1 means that the device is running in QSGMII +port_gmii_mode{25}=1 +port_gmii_mode{41}=1 diff --git a/device/accton/x86_64-accton_as4625_54t-r0/Accton-AS4625-54T/hwsku.json b/device/accton/x86_64-accton_as4625_54t-r0/Accton-AS4625-54T/hwsku.json new file mode 100644 index 0000000000..64ddd8089b --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/Accton-AS4625-54T/hwsku.json @@ -0,0 +1,321 @@ +{ + "interfaces": { + "Ethernet0": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet1": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet2": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet3": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet4": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet5": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet6": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet7": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet8": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet9": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet10": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet11": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet12": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet13": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet14": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet15": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet16": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet17": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet18": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet19": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet20": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet21": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet22": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet23": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet24": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet25": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet26": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet27": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet28": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet29": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet30": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet31": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet32": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet33": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet34": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet35": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet36": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet37": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet38": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet39": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet40": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet41": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet42": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet43": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet44": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet45": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet46": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet47": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45", + "autoneg": "on" + }, + + "Ethernet48": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off" + }, + + "Ethernet49": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off" + }, + + "Ethernet50": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off" + }, + + "Ethernet51": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off" + }, + + "Ethernet52": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off" + }, + + "Ethernet53": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off" + } + } +} diff --git a/device/accton/x86_64-accton_as4625_54t-r0/Accton-AS4625-54T/port_config.ini b/device/accton/x86_64-accton_as4625_54t-r0/Accton-AS4625-54T/port_config.ini new file mode 100644 index 0000000000..a88d9f0d23 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/Accton-AS4625-54T/port_config.ini @@ -0,0 +1,55 @@ +# name lanes alias index speed autoneg +Ethernet0 25 Eth1(Port1) 1 1000 on +Ethernet1 26 Eth2(Port2) 2 1000 on +Ethernet2 27 Eth3(Port3) 3 1000 on +Ethernet3 28 Eth4(Port4) 4 1000 on +Ethernet4 29 Eth5(Port5) 5 1000 on +Ethernet5 30 Eth6(Port6) 6 1000 on +Ethernet6 31 Eth7(Port7) 7 1000 on +Ethernet7 32 Eth8(Port8) 8 1000 on +Ethernet8 33 Eth9(Port9) 9 1000 on +Ethernet9 34 Eth10(Port10) 10 1000 on +Ethernet10 35 Eth11(Port11) 11 1000 on +Ethernet11 36 Eth12(Port12) 12 1000 on +Ethernet12 37 Eth13(Port13) 13 1000 on +Ethernet13 38 Eth14(Port14) 14 1000 on +Ethernet14 39 Eth15(Port15) 15 1000 on +Ethernet15 40 Eth16(Port16) 16 1000 on +Ethernet16 41 Eth17(Port17) 17 1000 on +Ethernet17 42 Eth18(Port18) 18 1000 on +Ethernet18 43 Eth19(Port19) 19 1000 on +Ethernet19 44 Eth20(Port20) 20 1000 on +Ethernet20 49 Eth21(Port21) 21 1000 on +Ethernet21 50 Eth22(Port22) 22 1000 on +Ethernet22 51 Eth23(Port23) 23 1000 on +Ethernet23 52 Eth24(Port24) 24 1000 on +Ethernet24 1 Eth25(Port25) 25 1000 on +Ethernet25 2 Eth26(Port26) 26 1000 on +Ethernet26 3 Eth27(Port27) 27 1000 on +Ethernet27 4 Eth28(Port28) 28 1000 on +Ethernet28 5 Eth29(Port29) 29 1000 on +Ethernet29 6 Eth30(Port30) 30 1000 on +Ethernet30 7 Eth31(Port31) 31 1000 on +Ethernet31 8 Eth32(Port32) 32 1000 on +Ethernet32 9 Eth33(Port33) 33 1000 on +Ethernet33 10 Eth34(Port34) 34 1000 on +Ethernet34 11 Eth35(Port35) 35 1000 on +Ethernet35 12 Eth36(Port36) 36 1000 on +Ethernet36 13 Eth37(Port37) 37 1000 on +Ethernet37 14 Eth38(Port38) 38 1000 on +Ethernet38 15 Eth39(Port39) 39 1000 on +Ethernet39 16 Eth40(Port40) 40 1000 on +Ethernet40 17 Eth41(Port41) 41 1000 on +Ethernet41 18 Eth42(Port42) 42 1000 on +Ethernet42 19 Eth43(Port43) 43 1000 on +Ethernet43 20 Eth44(Port44) 44 1000 on +Ethernet44 21 Eth45(Port45) 45 1000 on +Ethernet45 22 Eth46(Port46) 46 1000 on +Ethernet46 23 Eth47(Port47) 47 1000 on +Ethernet47 24 Eth48(Port48) 48 1000 on +Ethernet48 57 Eth49(Port49) 49 10000 off +Ethernet49 58 Eth50(Port50) 50 10000 off +Ethernet50 59 Eth51(Port51) 51 10000 off +Ethernet51 60 Eth52(Port52) 52 10000 off +Ethernet52 61 Eth53(Port53) 53 10000 off +Ethernet53 62 Eth54(Port54) 54 10000 off diff --git a/device/accton/x86_64-accton_as4625_54t-r0/Accton-AS4625-54T/sai.profile b/device/accton/x86_64-accton_as4625_54t-r0/Accton-AS4625-54T/sai.profile new file mode 100644 index 0000000000..93c1ebcec2 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/Accton-AS4625-54T/sai.profile @@ -0,0 +1 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/hr4-as4625-48x1G+6x10G.config.bcm diff --git a/device/accton/x86_64-accton_as4625_54t-r0/custom_led.bin b/device/accton/x86_64-accton_as4625_54t-r0/custom_led.bin new file mode 100644 index 0000000000..f1cc4a1136 Binary files /dev/null and b/device/accton/x86_64-accton_as4625_54t-r0/custom_led.bin differ diff --git a/device/accton/x86_64-accton_as4625_54t-r0/default_sku b/device/accton/x86_64-accton_as4625_54t-r0/default_sku new file mode 100644 index 0000000000..2e1af1dd6f --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/default_sku @@ -0,0 +1 @@ +Accton-AS4625-54T t1 diff --git a/device/accton/x86_64-accton_as4625_54t-r0/installer.conf b/device/accton/x86_64-accton_as4625_54t-r0/installer.conf new file mode 100644 index 0000000000..85bb317cc9 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/installer.conf @@ -0,0 +1,4 @@ +CONSOLE_PORT=0x3f8 +CONSOLE_DEV=0 +CONSOLE_SPEED=115200 +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="pcie_aspm=off intel_iommu=off modprobe.blacklist=i2c-ismt,i2c_ismt,i2c-i801,i2c_i801" diff --git a/device/accton/x86_64-accton_as4625_54t-r0/led_proc_init.soc b/device/accton/x86_64-accton_as4625_54t-r0/led_proc_init.soc new file mode 100644 index 0000000000..5bef973ed2 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/led_proc_init.soc @@ -0,0 +1,3 @@ +m0 load 0 0x3800 /usr/share/sonic/platform/custom_led.bin +led start +led auto on diff --git a/device/accton/x86_64-accton_as4625_54t-r0/pcie.yaml b/device/accton/x86_64-accton_as4625_54t-r0/pcie.yaml new file mode 100644 index 0000000000..b7482437b9 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/pcie.yaml @@ -0,0 +1,149 @@ +- bus: '00' + dev: '00' + fn: '0' + id: '1980' + name: 'Host bridge: Intel Corporation Atom Processor C3000 Series System Agent (rev + 11)' +- bus: '00' + dev: '04' + fn: '0' + id: 19a1 + name: 'Host bridge: Intel Corporation Atom Processor C3000 Series Error Registers + (rev 11)' +- bus: '00' + dev: '05' + fn: '0' + id: 19a2 + name: 'Generic system peripheral [0807]: Intel Corporation Atom Processor C3000 + Series Root Complex Event Collector (rev 11)' +- bus: '00' + dev: '06' + fn: '0' + id: 19a3 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series Integrated QAT + Root Port (rev 11)' +- bus: '00' + dev: 09 + fn: '0' + id: 19a4 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root + Port #0 (rev 11)' +- bus: '00' + dev: 0e + fn: '0' + id: 19a8 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root + Port #4 (rev 11)' +- bus: '00' + dev: 0f + fn: '0' + id: 19a9 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root + Port #5 (rev 11)' +- bus: '00' + dev: '12' + fn: '0' + id: 19ac + name: 'System peripheral: Intel Corporation Atom Processor C3000 Series SMBus Contoller + - Host (rev 11)' +- bus: '00' + dev: '14' + fn: '0' + id: 19c2 + name: 'SATA controller: Intel Corporation Atom Processor C3000 Series SATA Controller + 1 (rev 11)' +- bus: '00' + dev: '15' + fn: '0' + id: 19d0 + name: 'USB controller: Intel Corporation Atom Processor C3000 Series USB 3.0 xHCI + Controller (rev 11)' +- bus: '00' + dev: '16' + fn: '0' + id: 19d1 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series Integrated LAN + Root Port #0 (rev 11)' +- bus: '00' + dev: '17' + fn: '0' + id: 19d2 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series Integrated LAN + Root Port #1 (rev 11)' +- bus: '00' + dev: '18' + fn: '0' + id: 19d3 + name: 'Communication controller: Intel Corporation Atom Processor C3000 Series ME + HECI 1 (rev 11)' +- bus: '00' + dev: 1f + fn: '0' + id: 19dc + name: 'ISA bridge: Intel Corporation Atom Processor C3000 Series LPC or eSPI (rev + 11)' +- bus: '00' + dev: 1f + fn: '1' + id: 19dd + name: 'Memory controller: Intel Corporation Atom Processor C3000 Series Primary + to Side Band (P2SB) Bridge (rev 11)' +- bus: '00' + dev: 1f + fn: '2' + id: 19de + name: 'Memory controller: Intel Corporation Atom Processor C3000 Series Power Management + Controller (rev 11)' +- bus: '00' + dev: 1f + fn: '4' + id: 19df + name: 'SMBus: Intel Corporation Atom Processor C3000 Series SMBus controller (rev + 11)' +- bus: '00' + dev: 1f + fn: '5' + id: 19e0 + name: 'Serial bus controller [0c80]: Intel Corporation Atom Processor C3000 Series + SPI Controller (rev 11)' +- bus: '01' + dev: '00' + fn: '0' + id: 19e2 + name: 'Co-processor: Intel Corporation Atom Processor C3000 Series QuickAssist Technology + (rev 11)' +- bus: '02' + dev: '00' + fn: '0' + id: '1533' + name: 'Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev + 03)' +- bus: '03' + dev: '00' + fn: '0' + id: b277 + name: 'Ethernet controller: Broadcom Inc. and subsidiaries Device b277 (rev 02)' +- bus: '05' + dev: '00' + fn: '0' + id: 15c3 + name: 'Ethernet controller: Intel Corporation Ethernet Connection X553 Backplane + (rev 11)' +- bus: '05' + dev: '00' + fn: '1' + id: 15c3 + name: 'Ethernet controller: Intel Corporation Ethernet Connection X553 Backplane + (rev 11)' +- bus: '07' + dev: '00' + fn: '0' + id: 15c3 + name: 'Ethernet controller: Intel Corporation Ethernet Connection X553 Backplane + (rev 11)' +- bus: '07' + dev: '00' + fn: '1' + id: 15c3 + name: 'Ethernet controller: Intel Corporation Ethernet Connection X553 Backplane + (rev 11)' diff --git a/device/accton/x86_64-accton_as4625_54t-r0/platform.json b/device/accton/x86_64-accton_as4625_54t-r0/platform.json new file mode 100644 index 0000000000..71c01ba299 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/platform.json @@ -0,0 +1,853 @@ +{ + "chassis": { + "name": "4625-54T", + "components": [ + { + "name": "MB_CPLD" + }, + { + "name": "BIOS" + } + ], + "fans": [ + { + "name": "FAN-1", + "speed": { + "controllable": true, + "minimum": 25 + }, + "status_led": { + "available": false + } + }, + { + "name": "FAN-2", + "speed": { + "controllable": true, + "minimum": 25 + }, + "status_led": { + "available": false + } + }, + { + "name": "FAN-3", + "speed": { + "controllable": true, + "minimum": 25 + }, + "status_led": { + "available": false + } + } + ], + "fan_drawers":[ + { + "name": "FanTray-1", + "num_fans" : 1, + "fans": [ + { + "name": "FAN-1", + "speed": { + "controllable": true, + "minimum": 25 + }, + "status_led": { + "available": false + } + } + ] + }, + { + "name": "FanTray-2", + "num_fans" : 1, + "fans": [ + { + "name": "FAN-2", + "speed": { + "controllable": true, + "minimum": 25 + }, + "status_led": { + "available": false + } + } + ] + }, + { + "name": "FanTray-3", + "num_fans" : 1, + "fans": [ + { + "name": "FAN-3", + "speed": { + "controllable": true, + "minimum": 25 + }, + "status_led": { + "available": false + } + } + ] + } + ], + "psus": [ + { + "name": "PSU-1", + "fans": [ + { + "name": "PSU-1 FAN-1" + } + ], + "thermals": [ + { + "name": "PSU-1 temp sensor 1", + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name": "PSU-1 temp sensor 2", + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + } + ], + "temperature": true, + "temperature_high_threshold": true + }, + { + "name": "PSU-2", + "fans": [ + { + "name": "PSU-2 FAN-1" + } + ], + "thermals": [ + { + "name": "PSU-2 temp sensor 1", + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name": "PSU-2 temp sensor 2", + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + } + ], + "temperature": true, + "temperature_high_threshold": true + } + ], + "thermals": [ + { + "name": "MB_Temp(0x4a)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + + }, + { + "name": "MB_Temp(0x4b)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name": "MB_Temp(0x4d)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name": "MB_Temp(0x4e)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name": "MB_Temp(0x4f)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name" : "CPU Package Temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name" : "CPU Core 0 Temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name" : "CPU Core 1 Temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name" : "CPU Core 2 Temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + }, + { + "name" : "CPU Core 3 Temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false + } + ], + "sfps": [ + { + "name": "Ethernet0" + }, + { + "name": "Ethernet1" + }, + { + "name": "Ethernet2" + }, + { + "name": "Ethernet3" + }, + { + "name": "Ethernet4" + }, + { + "name": "Ethernet5" + }, + { + "name": "Ethernet6" + }, + { + "name": "Ethernet7" + }, + { + "name": "Ethernet8" + }, + { + "name": "Ethernet9" + }, + { + "name": "Ethernet10" + }, + { + "name": "Ethernet11" + }, + { + "name": "Ethernet12" + }, + { + "name": "Ethernet13" + }, + { + "name": "Ethernet14" + }, + { + "name": "Ethernet15" + }, + { + "name": "Ethernet16" + }, + { + "name": "Ethernet17" + }, + { + "name": "Ethernet18" + }, + { + "name": "Ethernet19" + }, + { + "name": "Ethernet20" + }, + { + "name": "Ethernet21" + }, + { + "name": "Ethernet22" + }, + { + "name": "Ethernet23" + }, + { + "name": "Ethernet24" + }, + { + "name": "Ethernet25" + }, + { + "name": "Ethernet26" + }, + { + "name": "Ethernet27" + }, + { + "name": "Ethernet28" + }, + { + "name": "Ethernet29" + }, + { + "name": "Ethernet30" + }, + { + "name": "Ethernet31" + }, + { + "name": "Ethernet32" + }, + { + "name": "Ethernet33" + }, + { + "name": "Ethernet34" + }, + { + "name": "Ethernet35" + }, + { + "name": "Ethernet36" + }, + { + "name": "Ethernet37" + }, + { + "name": "Ethernet38" + }, + { + "name": "Ethernet39" + }, + { + "name": "Ethernet40" + }, + { + "name": "Ethernet41" + }, + { + "name": "Ethernet42" + }, + { + "name": "Ethernet43" + }, + { + "name": "Ethernet44" + }, + { + "name": "Ethernet45" + }, + { + "name": "Ethernet46" + }, + { + "name": "Ethernet47" + }, + { + "name": "Ethernet48" + }, + { + "name": "Ethernet49" + }, + { + "name": "Ethernet50" + }, + { + "name": "Ethernet51" + }, + { + "name": "Ethernet52" + }, + { + "name": "Ethernet53" + } + ] + }, + "interfaces": { + "Ethernet0": { + "index": "1", + "lanes": "25", + "breakout_modes": { + "1x1G": ["Eth1(Port1)"] + } + }, + + "Ethernet1": { + "index": "2", + "lanes": "26", + "breakout_modes": { + "1x1G": ["Eth2(Port2)"] + } + }, + + "Ethernet2": { + "index": "3", + "lanes": "27", + "breakout_modes": { + "1x1G": ["Eth3(Port3)"] + } + }, + + "Ethernet3": { + "index": "4", + "lanes": "28", + "breakout_modes": { + "1x1G": ["Eth4(Port4)"] + } + }, + + "Ethernet4": { + "index": "5", + "lanes": "29", + "breakout_modes": { + "1x1G": ["Eth5(Port5)"] + } + }, + + "Ethernet5": { + "index": "6", + "lanes": "30", + "breakout_modes": { + "1x1G": ["Eth6(Port6)"] + } + }, + + "Ethernet6": { + "index": "7", + "lanes": "31", + "breakout_modes": { + "1x1G": ["Eth7(Port7)"] + } + }, + + "Ethernet7": { + "index": "8", + "lanes": "32", + "breakout_modes": { + "1x1G": ["Eth8(Port8)"] + } + }, + + "Ethernet8": { + "index": "9", + "lanes": "33", + "breakout_modes": { + "1x1G": ["Eth9(Port9)"] + } + }, + + "Ethernet9": { + "index": "10", + "lanes": "34", + "breakout_modes": { + "1x1G": ["Eth10(Port10)"] + } + }, + + "Ethernet10": { + "index": "11", + "lanes": "35", + "breakout_modes": { + "1x1G": ["Eth11(Port11)"] + } + }, + + "Ethernet11": { + "index": "12", + "lanes": "36", + "breakout_modes": { + "1x1G": ["Eth12(Port12)"] + } + }, + + "Ethernet12": { + "index": "13", + "lanes": "37", + "breakout_modes": { + "1x1G": ["Eth13(Port13)"] + } + }, + + "Ethernet13": { + "index": "14", + "lanes": "38", + "breakout_modes": { + "1x1G": ["Eth14(Port14)"] + } + }, + + "Ethernet14": { + "index": "15", + "lanes": "39", + "breakout_modes": { + "1x1G": ["Eth15(Port15)"] + } + }, + + "Ethernet15": { + "index": "16", + "lanes": "40", + "breakout_modes": { + "1x1G": ["Eth16(Port16)"] + } + }, + + "Ethernet16": { + "index": "17", + "lanes": "41", + "breakout_modes": { + "1x1G": ["Eth17(Port17)"] + } + }, + + "Ethernet17": { + "index": "18", + "lanes": "42", + "breakout_modes": { + "1x1G": ["Eth18(Port18)"] + } + }, + + "Ethernet18": { + "index": "19", + "lanes": "43", + "breakout_modes": { + "1x1G": ["Eth19(Port19)"] + } + }, + + "Ethernet19": { + "index": "20", + "lanes": "44", + "breakout_modes": { + "1x1G": ["Eth20(Port20)"] + } + }, + + "Ethernet20": { + "index": "21", + "lanes": "49", + "breakout_modes": { + "1x1G": ["Eth21(Port21)"] + } + }, + + "Ethernet21": { + "index": "22", + "lanes": "50", + "breakout_modes": { + "1x1G": ["Eth22(Port22)"] + } + }, + + "Ethernet22": { + "index": "23", + "lanes": "51", + "breakout_modes": { + "1x1G": ["Eth23(Port23)"] + } + }, + + "Ethernet23": { + "index": "24", + "lanes": "52", + "breakout_modes": { + "1x1G": ["Eth24(Port24)"] + } + }, + + "Ethernet24": { + "index": "25", + "lanes": "1", + "breakout_modes": { + "1x1G": ["Eth25(Port25)"] + } + }, + + "Ethernet25": { + "index": "26", + "lanes": "2", + "breakout_modes": { + "1x1G": ["Eth26(Port26)"] + } + }, + + "Ethernet26": { + "index": "27", + "lanes": "3", + "breakout_modes": { + "1x1G": ["Eth27(Port27)"] + } + }, + + "Ethernet27": { + "index": "28", + "lanes": "4", + "breakout_modes": { + "1x1G": ["Eth28(Port28)"] + } + }, + + "Ethernet28": { + "index": "29", + "lanes": "5", + "breakout_modes": { + "1x1G": ["Eth29(Port29)"] + } + }, + + "Ethernet29": { + "index": "30", + "lanes": "6", + "breakout_modes": { + "1x1G": ["Eth30(Port30)"] + } + }, + + "Ethernet30": { + "index": "31", + "lanes": "7", + "breakout_modes": { + "1x1G": ["Eth31(Port31)"] + } + }, + + "Ethernet31": { + "index": "32", + "lanes": "8", + "breakout_modes": { + "1x1G": ["Eth32(Port32)"] + } + }, + + "Ethernet32": { + "index": "33", + "lanes": "9", + "breakout_modes": { + "1x1G": ["Eth33(Port33)"] + } + }, + + "Ethernet33": { + "index": "34", + "lanes": "10", + "breakout_modes": { + "1x1G": ["Eth34(Port34)"] + } + }, + + "Ethernet34": { + "index": "35", + "lanes": "11", + "breakout_modes": { + "1x1G": ["Eth35(Port35)"] + } + }, + + "Ethernet35": { + "index": "36", + "lanes": "12", + "breakout_modes": { + "1x1G": ["Eth36(Port36)"] + } + }, + + "Ethernet36": { + "index": "37", + "lanes": "13", + "breakout_modes": { + "1x1G": ["Eth37(Port37)"] + } + }, + + "Ethernet37": { + "index": "38", + "lanes": "14", + "breakout_modes": { + "1x1G": ["Eth38(Port38)"] + } + }, + + "Ethernet38": { + "index": "39", + "lanes": "15", + "breakout_modes": { + "1x1G": ["Eth39(Port39)"] + } + }, + + "Ethernet39": { + "index": "40", + "lanes": "16", + "breakout_modes": { + "1x1G": ["Eth40(Port40)"] + } + }, + + "Ethernet40": { + "index": "41", + "lanes": "17", + "breakout_modes": { + "1x1G": ["Eth41(Port41)"] + } + }, + + "Ethernet41": { + "index": "42", + "lanes": "18", + "breakout_modes": { + "1x1G": ["Eth42(Port42)"] + } + }, + + "Ethernet42": { + "index": "43", + "lanes": "19", + "breakout_modes": { + "1x1G": ["Eth43(Port43)"] + } + }, + + "Ethernet43": { + "index": "44", + "lanes": "20", + "breakout_modes": { + "1x1G": ["Eth44(Port44)"] + } + }, + + "Ethernet44": { + "index": "45", + "lanes": "21", + "breakout_modes": { + "1x1G": ["Eth45(Port45)"] + } + }, + + "Ethernet45": { + "index": "46", + "lanes": "22", + "breakout_modes": { + "1x1G": ["Eth46(Port46)"] + } + }, + + "Ethernet46": { + "index": "47", + "lanes": "23", + "breakout_modes": { + "1x1G": ["Eth47(Port47)"] + } + }, + + "Ethernet47": { + "index": "48", + "lanes": "24", + "breakout_modes": { + "1x1G": ["Eth48(Port48)"] + } + }, + + "Ethernet48": { + "index": "49", + "lanes": "57", + "breakout_modes": { + "1x10G[1G]": ["Eth49(Port49)"] + } + }, + + "Ethernet49": { + "index": "50", + "lanes": "58", + "breakout_modes": { + "1x10G[1G]": ["Eth50(Port50)"] + } + }, + + "Ethernet50": { + "index": "51", + "lanes": "59", + "breakout_modes": { + "1x10G[1G]": ["Eth51(Port51)"] + } + }, + + "Ethernet51": { + "index": "52", + "lanes": "60", + "breakout_modes": { + "1x10G[1G]": ["Eth52(Port52)"] + } + }, + + "Ethernet52": { + "index": "53", + "lanes": "61", + "breakout_modes": { + "1x10G[1G]": ["Eth53(Port53)"] + } + }, + + "Ethernet53": { + "index": "54", + "lanes": "62", + "breakout_modes": { + "1x10G[1G]": ["Eth54(Port54)"] + } + } + } +} diff --git a/device/accton/x86_64-accton_as4625_54t-r0/platform_asic b/device/accton/x86_64-accton_as4625_54t-r0/platform_asic new file mode 100644 index 0000000000..9604676527 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/platform_asic @@ -0,0 +1 @@ +broadcom diff --git a/device/accton/x86_64-accton_as4625_54t-r0/platform_components.json b/device/accton/x86_64-accton_as4625_54t-r0/platform_components.json new file mode 100644 index 0000000000..59e502d039 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/platform_components.json @@ -0,0 +1,10 @@ +{ + "chassis": { + "4625-54T-O-AC-F": { + "component": { + "MB_CPLD": { }, + "BIOS": { } + } + } + } +} diff --git a/device/accton/x86_64-accton_as4625_54t-r0/plugins/ssd_util.py b/device/accton/x86_64-accton_as4625_54t-r0/plugins/ssd_util.py new file mode 100644 index 0000000000..4b173c5e38 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/plugins/ssd_util.py @@ -0,0 +1,24 @@ +# ssd_util.py +# +# Platform-specific SSD interface for SONiC +## + +try: + from sonic_platform_base.sonic_ssd.ssd_generic import SsdUtil as MainSsdUtil +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +NOT_AVAILABLE = "N/A" + +class SsdUtil(MainSsdUtil): + """Platform-specific SsdUtil class""" + + def __init__(self, diskdev): + super(SsdUtil, self).__init__(diskdev) + + # If it has no vendor tool to read SSD information, + # ssd_util.py will use generic SSD information + # for vendor SSD information. + if self.vendor_ssd_info == NOT_AVAILABLE: + self.vendor_ssd_info = self.ssd_info + diff --git a/device/accton/x86_64-accton_as4625_54t-r0/pmon_daemon_control.json b/device/accton/x86_64-accton_as4625_54t-r0/pmon_daemon_control.json new file mode 100644 index 0000000000..79344cad0b --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/pmon_daemon_control.json @@ -0,0 +1,4 @@ +{ + "skip_ledd": true, + "skip_xcvrd_cmis_mgr": true +} diff --git a/device/accton/x86_64-accton_as4625_54t-r0/sensors.conf b/device/accton/x86_64-accton_as4625_54t-r0/sensors.conf new file mode 100644 index 0000000000..1f4571ec60 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/sensors.conf @@ -0,0 +1,50 @@ +# libsensors configuration file for as4625 +# ------------------------------------------------ +# +bus "i2c-3" "i2c-1-mux (chan_id 1)" +bus "i2c-8" "i2c-1-mux (chan_id 6)" +bus "i2c-9" "i2c-1-mux (chan_id 7)" + +chip "ym2651-i2c-*-58" + label in3 "PSU 1 Voltage" + label fan1 "PSU 1 Fan" + label temp1 "PSU 1 Temperature" + label power2 "PSU 1 Power" + label curr2 "PSU 1 Current" + +chip "ym2651-i2c-*-59" + label in3 "PSU 2 Voltage" + label fan1 "PSU 2 Fan" + label temp1 "PSU 2 Temperature" + label power2 "PSU 2 Power" + label curr2 "PSU 2 Current" + +chip "as4625_fan-*" + label fan1 "Fan 1" + label fan2 "Fan 2" + label fan3 "Fan 3" + +chip "lm75-i2c-*-4a" + label temp1 "MB_Temp(0x4a)" + +chip "lm75-i2c-*-4b" + label temp1 "MB_Temp(0x4b)" + +chip "lm75-i2c-*-4d" + label temp1 "MB_Temp(0x4d)" + +chip "lm75-i2c-*-4e" + label temp1 "MB_Temp(0x4e)" + +chip "lm75-i2c-*-4f" + label temp1 "MB_Temp(0x4f)" + +chip "coretemp-isa-0000" + label temp2 "Core 0" + label temp4 "Core 0" + label temp6 "Core 1" + label temp8 "Core 1" + label temp10 "Core 2" + label temp12 "Core 2" + label temp14 "Core 3" + label temp16 "Core 3" diff --git a/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/__init__.py b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/__init__.py new file mode 120000 index 0000000000..c7aee89566 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/__init__.py @@ -0,0 +1 @@ +../../x86_64-accton_as4625_54p-r0/sonic_platform/__init__.py \ No newline at end of file diff --git a/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/chassis.py b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/chassis.py new file mode 120000 index 0000000000..4d6ee0c9d9 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/chassis.py @@ -0,0 +1 @@ +../../x86_64-accton_as4625_54p-r0/sonic_platform/chassis.py \ No newline at end of file diff --git a/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/component.py b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/component.py new file mode 120000 index 0000000000..54bba41bdb --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/component.py @@ -0,0 +1 @@ +../../x86_64-accton_as4625_54p-r0/sonic_platform/component.py \ No newline at end of file diff --git a/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/eeprom.py b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/eeprom.py new file mode 120000 index 0000000000..43446f8898 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/eeprom.py @@ -0,0 +1 @@ +../../x86_64-accton_as4625_54p-r0/sonic_platform/eeprom.py \ No newline at end of file diff --git a/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/event.py b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/event.py new file mode 120000 index 0000000000..cdd9015c49 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/event.py @@ -0,0 +1 @@ +../../x86_64-accton_as4625_54p-r0/sonic_platform/event.py \ No newline at end of file diff --git a/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/fan.py b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/fan.py new file mode 120000 index 0000000000..3fb15ca467 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/fan.py @@ -0,0 +1 @@ +../../x86_64-accton_as4625_54p-r0/sonic_platform/fan.py \ No newline at end of file diff --git a/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/fan_drawer.py b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/fan_drawer.py new file mode 120000 index 0000000000..51f29dbb53 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/fan_drawer.py @@ -0,0 +1 @@ +../../x86_64-accton_as4625_54p-r0/sonic_platform/fan_drawer.py \ No newline at end of file diff --git a/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/helper.py b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/helper.py new file mode 120000 index 0000000000..cbc0d3e4ab --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/helper.py @@ -0,0 +1 @@ +../../x86_64-accton_as4625_54p-r0/sonic_platform/helper.py \ No newline at end of file diff --git a/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/pcie.py b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/pcie.py new file mode 120000 index 0000000000..908a466e68 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/pcie.py @@ -0,0 +1 @@ +../../x86_64-accton_as4625_54p-r0/sonic_platform/pcie.py \ No newline at end of file diff --git a/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/platform.py b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/platform.py new file mode 120000 index 0000000000..8f613376ff --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/platform.py @@ -0,0 +1 @@ +../../x86_64-accton_as4625_54p-r0/sonic_platform/platform.py \ No newline at end of file diff --git a/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/psu.py b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/psu.py new file mode 120000 index 0000000000..4c5a8cb13e --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/psu.py @@ -0,0 +1 @@ +../../x86_64-accton_as4625_54p-r0/sonic_platform/psu.py \ No newline at end of file diff --git a/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/sfp.py b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/sfp.py new file mode 120000 index 0000000000..8886af08e0 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/sfp.py @@ -0,0 +1 @@ +../../x86_64-accton_as4625_54p-r0/sonic_platform/sfp.py \ No newline at end of file diff --git a/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/thermal.py b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/thermal.py new file mode 120000 index 0000000000..b26d132186 --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/sonic_platform/thermal.py @@ -0,0 +1 @@ +../../x86_64-accton_as4625_54p-r0/sonic_platform/thermal.py \ No newline at end of file diff --git a/device/accton/x86_64-accton_as4625_54t-r0/system_health_monitoring_config.json b/device/accton/x86_64-accton_as4625_54t-r0/system_health_monitoring_config.json new file mode 100644 index 0000000000..7aa53bcf4d --- /dev/null +++ b/device/accton/x86_64-accton_as4625_54t-r0/system_health_monitoring_config.json @@ -0,0 +1,14 @@ +{ + "services_to_ignore": [], + "devices_to_ignore": [ + "asic", + "psu.temperature" + ], + "user_defined_checkers": [], + "polling_interval": 60, + "led_color": { + "fault": "STATUS_LED_COLOR_AMBER", + "normal": "STATUS_LED_COLOR_GREEN", + "booting": "STATUS_LED_COLOR_GREEN_BLINKING" + } +} diff --git a/device/accton/x86_64-accton_as5835_54x-r0/Accton-AS5835-54X/hwsku.json b/device/accton/x86_64-accton_as5835_54x-r0/Accton-AS5835-54X/hwsku.json new file mode 100644 index 0000000000..910eea614e --- /dev/null +++ b/device/accton/x86_64-accton_as5835_54x-r0/Accton-AS5835-54X/hwsku.json @@ -0,0 +1,219 @@ +{ + "interfaces": { + "Ethernet0": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet1": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet2": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet3": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet4": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet5": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet6": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet7": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet8": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet9": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet10": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet11": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet12": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet13": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet14": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet15": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet16": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet17": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet18": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet19": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet20": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet21": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet22": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet23": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet24": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet25": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet26": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet27": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet28": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet29": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet30": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet31": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet32": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet33": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet34": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet35": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet36": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet37": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet38": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet39": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet40": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet41": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet42": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet43": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet44": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet45": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet46": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet47": { + "default_brkout_mode": "1x10G[1G]" + }, + + "Ethernet48": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet52": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet56": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet60": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet64": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet68": { + "default_brkout_mode": "1x100G[40G]" + } + } +} diff --git a/device/accton/x86_64-accton_as5835_54x-r0/Accton-AS5835-54X/mv2-as5835-48x10G+6x100G.config.bcm b/device/accton/x86_64-accton_as5835_54x-r0/Accton-AS5835-54X/mv2-as5835-48x10G+6x100G.config.bcm index fb40d79491..df0ee2d162 100644 --- a/device/accton/x86_64-accton_as5835_54x-r0/Accton-AS5835-54X/mv2-as5835-48x10G+6x100G.config.bcm +++ b/device/accton/x86_64-accton_as5835_54x-r0/Accton-AS5835-54X/mv2-as5835-48x10G+6x100G.config.bcm @@ -241,6 +241,9 @@ phy_chain_tx_polarity_flip_physical{36.0}=0x0 #FC9 dport_map_port_27=49 +dport_map_port_28=52 +dport_map_port_29=53 +dport_map_port_30=54 portmap_27=37:100:4 phy_chain_rx_lane_map_physical{37.0}=0x2130 phy_chain_rx_lane_map_physical{38.0}=0x2130 diff --git a/device/accton/x86_64-accton_as5835_54x-r0/Accton-AS5835-54X/port_config.ini b/device/accton/x86_64-accton_as5835_54x-r0/Accton-AS5835-54X/port_config.ini index 99de7329aa..77f192083b 100644 --- a/device/accton/x86_64-accton_as5835_54x-r0/Accton-AS5835-54X/port_config.ini +++ b/device/accton/x86_64-accton_as5835_54x-r0/Accton-AS5835-54X/port_config.ini @@ -1,55 +1,55 @@ -# name lanes alias index speed -Ethernet0 1 tenGigE1 1 10000 -Ethernet1 2 tenGigE2 2 10000 -Ethernet2 3 tenGigE3 3 10000 -Ethernet3 4 tenGigE4 4 10000 -Ethernet4 5 tenGigE5 5 10000 -Ethernet5 6 tenGigE6 6 10000 -Ethernet6 7 tenGigE7 7 10000 -Ethernet7 8 tenGigE8 8 10000 -Ethernet8 9 tenGigE9 9 10000 -Ethernet9 10 tenGigE10 10 10000 -Ethernet10 11 tenGigE11 11 10000 -Ethernet11 12 tenGigE12 12 10000 -Ethernet12 13 tenGigE13 13 10000 -Ethernet13 14 tenGigE14 14 10000 -Ethernet14 15 tenGigE15 15 10000 -Ethernet15 16 tenGigE16 16 10000 -Ethernet16 17 tenGigE17 17 10000 -Ethernet17 18 tenGigE18 18 10000 -Ethernet18 19 tenGigE19 19 10000 -Ethernet19 20 tenGigE20 20 10000 -Ethernet20 21 tenGigE21 21 10000 -Ethernet21 22 tenGigE22 22 10000 -Ethernet22 23 tenGigE23 23 10000 -Ethernet23 24 tenGigE24 24 10000 -Ethernet24 53 tenGigE25 25 10000 -Ethernet25 54 tenGigE26 26 10000 -Ethernet26 55 tenGigE27 27 10000 -Ethernet27 56 tenGigE28 28 10000 -Ethernet28 57 tenGigE29 29 10000 -Ethernet29 58 tenGigE30 30 10000 -Ethernet30 59 tenGigE31 31 10000 -Ethernet31 60 tenGigE32 32 10000 -Ethernet32 61 tenGigE33 33 10000 -Ethernet33 62 tenGigE34 34 10000 -Ethernet34 63 tenGigE35 35 10000 -Ethernet35 64 tenGigE36 36 10000 -Ethernet36 65 tenGigE37 37 10000 -Ethernet37 66 tenGigE38 38 10000 -Ethernet38 67 tenGigE39 39 10000 -Ethernet39 68 tenGigE40 40 10000 -Ethernet40 69 tenGigE41 41 10000 -Ethernet41 70 tenGigE42 42 10000 -Ethernet42 71 tenGigE43 43 10000 -Ethernet43 72 tenGigE44 44 10000 -Ethernet44 73 tenGigE45 45 10000 -Ethernet45 74 tenGigE46 46 10000 -Ethernet46 75 tenGigE47 47 10000 -Ethernet47 76 tenGigE48 48 10000 -Ethernet48 37,38,39,40 hundredGigE49 49 100000 -Ethernet52 29,30,31,32 hundredGigE50 50 100000 -Ethernet56 33,34,35,36 hundredGigE51 51 100000 -Ethernet60 49,50,51,52 hundredGigE52 52 100000 -Ethernet64 45,46,47,48 hundredGigE53 53 100000 -Ethernet68 41,42,43,44 hundredGigE54 54 100000 +# name lanes alias index speed +Ethernet0 1 Eth1(Port1) 1 10000 +Ethernet1 2 Eth2(Port2) 2 10000 +Ethernet2 3 Eth3(Port3) 3 10000 +Ethernet3 4 Eth4(Port4) 4 10000 +Ethernet4 5 Eth5(Port5) 5 10000 +Ethernet5 6 Eth6(Port6) 6 10000 +Ethernet6 7 Eth7(Port7) 7 10000 +Ethernet7 8 Eth8(Port8) 8 10000 +Ethernet8 9 Eth9(Port9) 9 10000 +Ethernet9 10 Eth10(Port10) 10 10000 +Ethernet10 11 Eth11(Port11) 11 10000 +Ethernet11 12 Eth12(Port12) 12 10000 +Ethernet12 13 Eth13(Port13) 13 10000 +Ethernet13 14 Eth14(Port14) 14 10000 +Ethernet14 15 Eth15(Port15) 15 10000 +Ethernet15 16 Eth16(Port16) 16 10000 +Ethernet16 17 Eth17(Port17) 17 10000 +Ethernet17 18 Eth18(Port18) 18 10000 +Ethernet18 19 Eth19(Port19) 19 10000 +Ethernet19 20 Eth20(Port20) 20 10000 +Ethernet20 21 Eth21(Port21) 21 10000 +Ethernet21 22 Eth22(Port22) 22 10000 +Ethernet22 23 Eth23(Port23) 23 10000 +Ethernet23 24 Eth24(Port24) 24 10000 +Ethernet24 53 Eth25(Port25) 25 10000 +Ethernet25 54 Eth26(Port26) 26 10000 +Ethernet26 55 Eth27(Port27) 27 10000 +Ethernet27 56 Eth28(Port28) 28 10000 +Ethernet28 57 Eth29(Port29) 29 10000 +Ethernet29 58 Eth30(Port30) 30 10000 +Ethernet30 59 Eth31(Port31) 31 10000 +Ethernet31 60 Eth32(Port32) 32 10000 +Ethernet32 61 Eth33(Port33) 33 10000 +Ethernet33 62 Eth34(Port34) 34 10000 +Ethernet34 63 Eth35(Port35) 35 10000 +Ethernet35 64 Eth36(Port36) 36 10000 +Ethernet36 65 Eth37(Port37) 37 10000 +Ethernet37 66 Eth38(Port38) 38 10000 +Ethernet38 67 Eth39(Port39) 39 10000 +Ethernet39 68 Eth40(Port40) 40 10000 +Ethernet40 69 Eth41(Port41) 41 10000 +Ethernet41 70 Eth42(Port42) 42 10000 +Ethernet42 71 Eth43(Port43) 43 10000 +Ethernet43 72 Eth44(Port44) 44 10000 +Ethernet44 73 Eth45(Port45) 45 10000 +Ethernet45 74 Eth46(Port46) 46 10000 +Ethernet46 75 Eth47(Port47) 47 10000 +Ethernet47 76 Eth48(Port48) 48 10000 +Ethernet48 37,38,39,40 Eth49(Port49) 49 100000 +Ethernet52 29,30,31,32 Eth50(Port50) 50 100000 +Ethernet56 33,34,35,36 Eth51(Port51) 51 100000 +Ethernet60 49,50,51,52 Eth52(Port52) 52 100000 +Ethernet64 45,46,47,48 Eth53(Port53) 53 100000 +Ethernet68 41,42,43,44 Eth54(Port54) 54 100000 diff --git a/device/accton/x86_64-accton_as5835_54x-r0/installer.conf b/device/accton/x86_64-accton_as5835_54x-r0/installer.conf index 735fa7992d..85bb317cc9 100644 --- a/device/accton/x86_64-accton_as5835_54x-r0/installer.conf +++ b/device/accton/x86_64-accton_as5835_54x-r0/installer.conf @@ -1,4 +1,4 @@ CONSOLE_PORT=0x3f8 CONSOLE_DEV=0 CONSOLE_SPEED=115200 -ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off modprobe.blacklist=i2c-ismt,i2c_ismt,i2c-i801,i2c_i801" +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="pcie_aspm=off intel_iommu=off modprobe.blacklist=i2c-ismt,i2c_ismt,i2c-i801,i2c_i801" diff --git a/device/accton/x86_64-accton_as5835_54x-r0/media_settings.json b/device/accton/x86_64-accton_as5835_54x-r0/media_settings.json new file mode 100644 index 0000000000..ef930baab8 --- /dev/null +++ b/device/accton/x86_64-accton_as5835_54x-r0/media_settings.json @@ -0,0 +1,400 @@ +{ + "PORT_MEDIA_SETTINGS": { + "1": { + "Default": { + "preemphasis": { + "lane0": "0x000b2f01" + } + } + }, + "2": { + "Default": { + "preemphasis": { + "lane0": "0x000b2f01" + } + } + }, + "3": { + "Default": { + "preemphasis": { + "lane0": "0x000b2f01" + } + } + }, + "4": { + "Default": { + "preemphasis": { + "lane0": "0x000b2f01" + } + } + }, + "5": { + "Default": { + "preemphasis": { + "lane0": "0x000b2f01" + } + } + }, + "6": { + "Default": { + "preemphasis": { + "lane0": "0x000b2f01" + } + } + }, + "7": { + "Default": { + "preemphasis": { + "lane0": "0x000b2f01" + } + } + }, + "8": { + "Default": { + "preemphasis": { + "lane0": "0x000a2e01" + } + } + }, + "9": { + "Default": { + "preemphasis": { + "lane0": "0x000a2e01" + } + } + }, + "10": { + "Default": { + "preemphasis": { + "lane0": "0x000a2e01" + } + } + }, + "11": { + "Default": { + "preemphasis": { + "lane0": "0x000a2d01" + } + } + }, + "12": { + "Default": { + "preemphasis": { + "lane0": "0x00092a01" + } + } + }, + "13": { + "Default": { + "preemphasis": { + "lane0": "0x00092a01" + } + } + }, + "14": { + "Default": { + "preemphasis": { + "lane0": "0x00092a01" + } + } + }, + "15": { + "Default": { + "preemphasis": { + "lane0": "0x00092a01" + } + } + }, + "16": { + "Default": { + "preemphasis": { + "lane0": "0x00082a01" + } + } + }, + "17": { + "Default": { + "preemphasis": { + "lane0": "0x00082a01" + } + } + }, + "18": { + "Default": { + "preemphasis": { + "lane0": "0x00082801" + } + } + }, + "19": { + "Default": { + "preemphasis": { + "lane0": "0x00082801" + } + } + }, + "20": { + "Default": { + "preemphasis": { + "lane0": "0x00062501" + } + } + }, + "21": { + "Default": { + "preemphasis": { + "lane0": "0x00062501" + } + } + }, + "22": { + "Default": { + "preemphasis": { + "lane0": "0x00062801" + } + } + }, + "23": { + "Default": { + "preemphasis": { + "lane0": "0x00062601" + } + } + }, + "24": { + "Default": { + "preemphasis": { + "lane0": "0x00062501" + } + } + }, + "25": { + "Default": { + "preemphasis": { + "lane0": "0x00062a01" + } + } + }, + "26": { + "Default": { + "preemphasis": { + "lane0": "0x00062801" + } + } + }, + "27": { + "Default": { + "preemphasis": { + "lane0": "0x00062901" + } + } + }, + "28": { + "Default": { + "preemphasis": { + "lane0": "0x00062901" + } + } + }, + "29": { + "Default": { + "preemphasis": { + "lane0": "0x00062801" + } + } + }, + "30": { + "Default": { + "preemphasis": { + "lane0": "0x00062901" + } + } + }, + "31": { + "Default": { + "preemphasis": { + "lane0": "0x00062b01" + } + } + }, + "32": { + "Default": { + "preemphasis": { + "lane0": "0x00062901" + } + } + }, + "33": { + "Default": { + "preemphasis": { + "lane0": "0x00062801" + } + } + }, + "34": { + "Default": { + "preemphasis": { + "lane0": "0x00062901" + } + } + }, + "35": { + "Default": { + "preemphasis": { + "lane0": "0x00062801" + } + } + }, + "36": { + "Default": { + "preemphasis": { + "lane0": "0x00062801" + } + } + }, + "37": { + "Default": { + "preemphasis": { + "lane0": "0x00062701" + } + } + }, + "38": { + "Default": { + "preemphasis": { + "lane0": "0x00062901" + } + } + }, + "39": { + "Default": { + "preemphasis": { + "lane0": "0x00062801" + } + } + }, + "40": { + "Default": { + "preemphasis": { + "lane0": "0x00062901" + } + } + }, + "41": { + "Default": { + "preemphasis": { + "lane0": "0x00062901" + } + } + }, + "42": { + "Default": { + "preemphasis": { + "lane0": "0x00062b01" + } + } + }, + "43": { + "Default": { + "preemphasis": { + "lane0": "0x00062b01" + } + } + }, + "44": { + "Default": { + "preemphasis": { + "lane0": "0x00062b01" + } + } + }, + "45": { + "Default": { + "preemphasis": { + "lane0": "0x00062b01" + } + } + }, + "46": { + "Default": { + "preemphasis": { + "lane0": "0x00072b01" + } + } + }, + "47": { + "Default": { + "preemphasis": { + "lane0": "0x00072b01" + } + } + }, + "48": { + "Default": { + "preemphasis": { + "lane0": "0x00072b01" + } + } + }, + "49": { + "Default": { + "preemphasis": { + "lane0": "0x00194605", + "lane1": "0x00194605", + "lane2": "0x00194605", + "lane3": "0x00194605" + } + } + }, + "50": { + "Default": { + "preemphasis": { + "lane0": "0x00194506", + "lane1": "0x00194506", + "lane2": "0x00194506", + "lane3": "0x00194506" + } + } + }, + "51": { + "Default": { + "preemphasis": { + "lane0": "0x00194506", + "lane1": "0x00194506", + "lane2": "0x00194506", + "lane3": "0x00194506" + } + } + }, + "52": { + "Default": { + "preemphasis": { + "lane0": "0x00194506", + "lane1": "0x00194506", + "lane2": "0x00194506", + "lane3": "0x00194506" + } + } + }, + "53": { + "Default": { + "preemphasis": { + "lane0": "0x00194506", + "lane1": "0x00194506", + "lane2": "0x00194506", + "lane3": "0x00194506" + } + } + }, + "54": { + "Default": { + "preemphasis": { + "lane0": "0x00194506", + "lane1": "0x00194506", + "lane2": "0x00194506", + "lane3": "0x00194506" + } + } + } + } +} \ No newline at end of file diff --git a/device/accton/x86_64-accton_as5835_54x-r0/pcie.yaml b/device/accton/x86_64-accton_as5835_54x-r0/pcie.yaml new file mode 100644 index 0000000000..f9e26c35ff --- /dev/null +++ b/device/accton/x86_64-accton_as5835_54x-r0/pcie.yaml @@ -0,0 +1,161 @@ +- bus: '00' + dev: '00' + fn: '0' + id: '1980' + name: 'Host bridge: Intel Corporation Atom Processor C3000 Series System Agent (rev + 11)' +- bus: '00' + dev: '04' + fn: '0' + id: 19a1 + name: 'Host bridge: Intel Corporation Atom Processor C3000 Series Error Registers + (rev 11)' +- bus: '00' + dev: '05' + fn: '0' + id: 19a2 + name: 'Generic system peripheral [0807]: Intel Corporation Atom Processor C3000 + Series Root Complex Event Collector (rev 11)' +- bus: '00' + dev: '06' + fn: '0' + id: 19a3 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series Integrated QAT + Root Port (rev 11)' +- bus: '00' + dev: 09 + fn: '0' + id: 19a4 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root + Port #0 (rev 11)' +- bus: '00' + dev: 0b + fn: '0' + id: 19a6 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root + Port #2 (rev 11)' +- bus: '00' + dev: 0e + fn: '0' + id: 19a8 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root + Port #4 (rev 11)' +- bus: '00' + dev: '10' + fn: '0' + id: 19aa + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root + Port #6 (rev 11)' +- bus: '00' + dev: '12' + fn: '0' + id: 19ac + name: 'System peripheral: Intel Corporation Atom Processor C3000 Series SMBus Contoller + - Host (rev 11)' +- bus: '00' + dev: '13' + fn: '0' + id: 19b2 + name: 'SATA controller: Intel Corporation Atom Processor C3000 Series SATA Controller + 0 (rev 11)' +- bus: '00' + dev: '15' + fn: '0' + id: 19d0 + name: 'USB controller: Intel Corporation Atom Processor C3000 Series USB 3.0 xHCI + Controller (rev 11)' +- bus: '00' + dev: '16' + fn: '0' + id: 19d1 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series Integrated LAN + Root Port #0 (rev 11)' +- bus: '00' + dev: '17' + fn: '0' + id: 19d2 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series Integrated LAN + Root Port #1 (rev 11)' +- bus: '00' + dev: '18' + fn: '0' + id: 19d3 + name: 'Communication controller: Intel Corporation Atom Processor C3000 Series ME + HECI 1 (rev 11)' +- bus: '00' + dev: 1a + fn: '0' + id: 19d8 + name: 'Serial controller: Intel Corporation Atom Processor C3000 Series HSUART Controller + (rev 11)' +- bus: '00' + dev: 1a + fn: '1' + id: 19d8 + name: 'Serial controller: Intel Corporation Atom Processor C3000 Series HSUART Controller + (rev 11)' +- bus: '00' + dev: 1a + fn: '2' + id: 19d8 + name: 'Serial controller: Intel Corporation Atom Processor C3000 Series HSUART Controller + (rev 11)' +- bus: '00' + dev: 1f + fn: '0' + id: 19dc + name: 'ISA bridge: Intel Corporation Atom Processor C3000 Series LPC or eSPI (rev + 11)' +- bus: '00' + dev: 1f + fn: '1' + id: 19dd + name: 'Memory controller: Intel Corporation Atom Processor C3000 Series Primary + to Side Band (P2SB) Bridge (rev 11)' +- bus: '00' + dev: 1f + fn: '2' + id: 19de + name: 'Memory controller: Intel Corporation Atom Processor C3000 Series Power Management + Controller (rev 11)' +- bus: '00' + dev: 1f + fn: '4' + id: 19df + name: 'SMBus: Intel Corporation Atom Processor C3000 Series SMBus controller (rev + 11)' +- bus: '00' + dev: 1f + fn: '5' + id: 19e0 + name: 'Serial bus controller [0c80]: Intel Corporation Atom Processor C3000 Series + SPI Controller (rev 11)' +- bus: '01' + dev: '00' + fn: '0' + id: 19e2 + name: 'Co-processor: Intel Corporation Atom Processor C3000 Series QuickAssist Technology + (rev 11)' +- bus: '02' + dev: '00' + fn: '0' + id: b771 + name: 'Ethernet controller: Broadcom Inc. and subsidiaries Device b771 (rev 01)' +- bus: '05' + dev: '00' + fn: '0' + id: '1533' + name: 'Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev + 03)' +- bus: '06' + dev: '00' + fn: '0' + id: 15c2 + name: 'Ethernet controller: Intel Corporation Ethernet Connection X553 Backplane + (rev 11)' +- bus: 08 + dev: '00' + fn: '0' + id: 15e5 + name: 'Ethernet controller: Intel Corporation Ethernet Connection X553 1GbE (rev + 11)' diff --git a/device/accton/x86_64-accton_as5835_54x-r0/pddf/pd-plugin.json b/device/accton/x86_64-accton_as5835_54x-r0/pddf/pd-plugin.json new file mode 100644 index 0000000000..93cfc75899 --- /dev/null +++ b/device/accton/x86_64-accton_as5835_54x-r0/pddf/pd-plugin.json @@ -0,0 +1,66 @@ +{ + + "XCVR": + { + "xcvr_present": + { + "i2c": + { + "valmap-SFP28": {"1":true, "0":false }, + "valmap-QSFP28": {"1":true, "0":false} + } + } + }, + "PSU": + { + "psu_present": + { + "i2c": + { + "valmap": { "1":true, "0":false } + } + }, + + "psu_power_good": + { + "i2c": + { + "valmap": { "1": true, "0":false } + } + }, + + "psu_fan_dir": + { + "i2c": + { + "valmap": { "F2B":"exhaust", "B2F":"intake" } + } + }, + + "PSU_FAN_MAX_SPEED":"18000" + }, + + "FAN": + { + "direction": + { + "i2c": + { + "valmap": {"1":"intake", "0":"exhaust"} + } + }, + + "present": + { + "i2c": + { + "valmap": {"1":true, "0":false} + } + }, + + "duty_cycle_to_pwm": "lambda dc: (dc/5)", + + "pwm_to_duty_cycle": "lambda pwm: (pwm*5)" + } + +} diff --git a/device/accton/x86_64-accton_as5835_54x-r0/pddf/pddf-device.json b/device/accton/x86_64-accton_as5835_54x-r0/pddf/pddf-device.json new file mode 100644 index 0000000000..973ac4c119 --- /dev/null +++ b/device/accton/x86_64-accton_as5835_54x-r0/pddf/pddf-device.json @@ -0,0 +1,2899 @@ +{ + "PLATFORM": + { + "num_psus":2, + "num_fantrays":5, + "num_fans_pertray":2, + "num_ports":54, + "num_temps": 9, + "pddf_dev_types": + { + "description":"AS5835-54X - Below is the list of supported PDDF device types (chip names) for various components. If any component uses some other driver, we will create the client using 'echo > /new_device' method", + "CPLD": + [ + "i2c_cpld" + ], + "PSU": + [ + "psu_eeprom", + "psu_pmbus" + ], + "FAN": + [ + "fan_ctrl", + "fan_eeprom" + ], + "PORT_MODULE": + [ + "pddf_xcvr" + ] + }, + "std_kos": + [ + "i2c-i801", + "i2c-ismt", + "i2c_dev", + "i2c_mux_pca954x", + "optoe" + ], + "pddf_kos": + [ + "pddf_client_module", + "pddf_cpld_module", + "pddf_cpld_driver", + "pddf_mux_module", + "pddf_xcvr_module", + "pddf_xcvr_driver_module", + "pddf_psu_driver_module", + "pddf_psu_module", + "pddf_fan_driver_module", + "pddf_fan_module", + "pddf_led_module", + "pddf_sysstatus_module" + ], + "custom_kos": + [ + "pddf_custom_psu" + ] + }, + + "SYSTEM": + { + "dev_info": {"device_type":"CPU", "device_name":"ROOT_COMPLEX", "device_parent":null}, + "i2c": + { + "CONTROLLERS": + [ + { "dev_name":"i2c-1", "dev":"SMBUS1" } + ] + } + }, + + "SMBUS1": + { + "dev_info": {"device_type": "SMBUS", "device_name": "SMBUS1", "device_parent": "SYSTEM"}, + "i2c": + { + "topo_info": {"dev_addr": "0x1"}, + "DEVICES": + [ + {"dev": "EEPROM1"}, + {"dev": "CPU_CPLD"}, + {"dev": "MUX1"} + ] + } + }, + + "EEPROM1": + { + "dev_info": {"device_type": "EEPROM", "device_name": "EEPROM1", "device_parent": "SMBUS1"}, + "i2c": + { + "topo_info": {"parent_bus": "0x1", "dev_addr": "0x57", "dev_type": "24c02"}, + "dev_attr": {"access_mode": "BLOCK"}, + "attr_list": [ + {"attr_name": "eeprom"} + ] + } + }, + + "CPU_CPLD": + { + "dev_info": { "device_type":"CPLD", "device_name":"CPU_CPLD", "device_parent":"SMBUS1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x1", "dev_addr":"0x65", "dev_type":"i2c_cpld"}, + "dev_attr": { } + } + }, + + "MUX1": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX1", "device_parent":"SMBUS1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x1", "dev_addr":"0x77", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0x2", "idle_state":"-2"}, + "channel": + [ + { "chn":"0", "dev":"MUX2" }, + { "chn":"0", "dev":"MUX3" }, + { "chn":"0", "dev":"MUX4" }, + { "chn":"1", "dev":"CPLD1" }, + { "chn":"1", "dev":"CPLD2" }, + { "chn":"1", "dev":"CPLD3" }, + { "chn":"1", "dev":"FAN-CTRL" }, + { "chn":"1", "dev":"MUX5" } + ] + } + }, + "MUX2": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX2", "device_parent":"MUX1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2", "dev_addr":"0x70", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0xa", "idle_state":"-2"}, + "channel": + [ + { "chn":"1", "dev":"PSU1" }, + { "chn":"2", "dev":"PSU2" } + ] + } + }, + + "PSU1": + { + "dev_info": { "device_type":"PSU", "device_name":"PSU1", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"1", "num_psu_fans": "1"}, + "i2c": + { + "interface": + [ + { "itf":"pmbus", "dev":"PSU1-PMBUS" }, + { "itf":"eeprom", "dev":"PSU1-EEPROM" } + ] + } + }, + + "PSU1-PMBUS": + { + "dev_info": { "device_type":"PSU-PMBUS", "device_name":"PSU1-PMBUS", "device_parent":"MUX2", "virt_parent":"PSU1"}, + "i2c": + { + "topo_info":{ "parent_bus":"0xb", "dev_addr":"0x58", "dev_type":"psu_pmbus"}, + "attr_list": + [ + { "attr_name":"psu_present", "attr_devaddr":"0x60", "attr_devtype":"cpld", "attr_offset":"0x2", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"psu_model_name", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x9a", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"10" }, + { "attr_name":"psu_power_good", "attr_devaddr":"0x60", "attr_devtype":"cpld", "attr_offset":"0x2", "attr_mask":"0x2", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"psu_mfr_id", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0X99", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"10" }, + { "attr_name":"psu_fan_dir", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0xc3", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"5"}, + { "attr_name":"psu_v_out", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8b", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_min", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0xa4", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_max", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0xa5", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_i_out", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_p_out", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_p_out_max", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0xa7", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_temp1_input", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} + ] + } + }, + + "PSU1-EEPROM": + { + "dev_info": { "device_type":"PSU-EEPROM", "device_name":"PSU1-EEPROM", "device_parent":"MUX2", "virt_parent":"PSU1"}, + "i2c": + { + "topo_info":{ "parent_bus":"0xb", "dev_addr":"0x50", "dev_type":"psu_eeprom"}, + "attr_list": + [ + { "attr_name":"psu_serial_num", "attr_devaddr":"0x50", "attr_devtype":"eeprom", "attr_offset":"0x35", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"19" } + ] + } + }, + + "PSU2": + { + "dev_info": { "device_type":"PSU", "device_name":"PSU2", "device_parent":"MUX2" }, + "dev_attr": { "dev_idx":"2", "num_psu_fans":"1"}, + "i2c": + { + "interface": + [ + { "itf":"pmbus", "dev":"PSU2-PMBUS"}, + { "itf":"eeprom", "dev":"PSU2-EEPROM" } + ] + } + }, + + "PSU2-PMBUS": + { + "dev_info": {"device_type":"PSU-PMBUS", "device_name":"PSU2-PMBUS", "device_parent":"MUX2", "virt_parent":"PSU2"}, + "i2c": + { + "topo_info": { "parent_bus":"0xc", "dev_addr":"0x5b", "dev_type":"psu_pmbus"}, + "attr_list": + [ + { "attr_name":"psu_present", "attr_devaddr":"0x60", "attr_devtype":"cpld", "attr_offset":"0x2", "attr_mask":"0x10", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"psu_model_name", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x9a", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"10" }, + { "attr_name":"psu_power_good", "attr_devaddr":"0x60", "attr_devtype":"cpld", "attr_offset":"0x2", "attr_mask":"0x20", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"psu_mfr_id", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0X99", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"10" }, + { "attr_name":"psu_fan_dir", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xc3", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"5"}, + { "attr_name":"psu_v_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8b", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_min", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa4", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_max", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa5", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_i_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_p_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_p_out_max", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa7", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_temp1_input", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} + ] + } + }, + + "PSU2-EEPROM": + { + "dev_info": { "device_type":"PSU-EEPROM", "device_name":"PSU2-EEPROM", "device_parent":"MUX2", "virt_parent":"PSU2"}, + "i2c": + { + "topo_info":{ "parent_bus":"0xc", "dev_addr":"0x53", "dev_type":"psu_eeprom"}, + "attr_list": + [ + { "attr_name":"psu_serial_num", "attr_devaddr":"0x53", "attr_devtype":"eeprom", "attr_offset":"0x35", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"19" } + ] + } + }, + "MUX3": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX3", "device_parent":"MUX1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2", "dev_addr":"0x72", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0x12", "idle_state":"-2"}, + "channel": + [ + { "chn":"0", "dev":"PORT51" }, + { "chn":"1", "dev":"PORT54" }, + { "chn":"2", "dev":"PORT49" }, + { "chn":"3", "dev":"PORT50" }, + { "chn":"4", "dev":"PORT52" }, + { "chn":"5", "dev":"PORT53" } + ] + } + }, + + "PORT51": + { + "dev_info": { "device_type":"QSFP28", "device_name":"PORT51", "device_parent":"MUX3"}, + "dev_attr": { "dev_idx":"51"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT51-EEPROM" }, + { "itf":"control", "dev":"PORT51-CTRL" } + ] + } + }, + "PORT51-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT51-EEPROM", "device_parent":"MUX3", "virt_parent":"PORT51"}, + "i2c": + { + "topo_info": { "parent_bus":"0x12", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT51-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT51-CTRL", "device_parent":"MUX3", "virt_parent":"PORT51"}, + "i2c": + { + "topo_info": { "parent_bus":"0x12", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x14", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_reset", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3","attr_offset":"0x15", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_intr_status", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3","attr_offset":"0x13", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x16", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"} + ] + } + }, + + "PORT54": + { + "dev_info": { "device_type":"QSFP28", "device_name":"PORT54", "device_parent":"MUX3"}, + "dev_attr": { "dev_idx":"54"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT54-EEPROM" }, + { "itf":"control", "dev":"PORT54-CTRL" } + ] + } + }, + "PORT54-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT54-EEPROM", "device_parent":"MUX3", "virt_parent":"PORT54"}, + "i2c": + { + "topo_info": { "parent_bus":"0x13", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT54-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT54-CTRL", "device_parent":"MUX3", "virt_parent":"PORT54"}, + "i2c": + { + "topo_info": { "parent_bus":"0x13", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3","attr_offset":"0x14", "attr_mask":"0x5", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_reset", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3","attr_offset":"0x15", "attr_mask":"0x5", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_intr_status", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3","attr_offset":"0x13", "attr_mask":"0x5", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x16", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"} + ] + } + }, + + "PORT49": + { + "dev_info": { "device_type":"QSFP28", "device_name":"PORT49", "device_parent":"MUX3"}, + "dev_attr": { "dev_idx":"49"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT49-EEPROM" }, + { "itf":"control", "dev":"PORT49-CTRL" } + ] + } + }, + "PORT49-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT49-EEPROM", "device_parent":"MUX3", "virt_parent":"PORT49"}, + "i2c": + { + "topo_info": { "parent_bus":"0x14", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT49-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT49-CTRL", "device_parent":"MUX3", "virt_parent":"PORT49"}, + "i2c": + { + "topo_info": { "parent_bus":"0x14", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x14", "attr_mask":"0x0", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_reset", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x15", "attr_mask":"0x0", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_intr_status", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x13", "attr_mask":"0x0", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x16", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"} + ] + } + }, + + "PORT50": + { + "dev_info": { "device_type":"QSFP28", "device_name":"PORT50", "device_parent":"MUX3"}, + "dev_attr": { "dev_idx":"50"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT50-EEPROM" }, + { "itf":"control", "dev":"PORT50-CTRL" } + ] + } + }, + "PORT50-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT50-EEPROM", "device_parent":"MUX3", "virt_parent":"PORT50"}, + "i2c": + { + "topo_info": { "parent_bus":"0x15", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + + "PORT50-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT50-CTRL", "device_parent":"MUX3", "virt_parent":"PORT50"}, + "i2c": + { + "topo_info": { "parent_bus":"0x15", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x14", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_reset", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x15", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_intr_status", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x13", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3","attr_offset":"0x16", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"} + ] + } + }, + + "PORT52": + { + "dev_info": { "device_type":"QSFP28", "device_name":"PORT52", "device_parent":"MUX3"}, + "dev_attr": { "dev_idx":"52"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT52-EEPROM" }, + { "itf":"control", "dev":"PORT52-CTRL" } + ] + } + }, + "PORT52-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT52-EEPROM", "device_parent":"MUX3", "virt_parent":"PORT52"}, + "i2c": + { + "topo_info": { "parent_bus":"0x16", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT52-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT52-CTRL", "device_parent":"MUX3", "virt_parent":"PORT52"}, + "i2c": + { + "topo_info": { "parent_bus":"0x16", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x14", "attr_mask":"0x3", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_reset", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x15", "attr_mask":"0x3", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_intr_status", "attr_devaddr":"0x62", "attr_devtype":"cpld","attr_devname":"CPLD3", "attr_offset":"0x13", "attr_mask":"0x3", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x16", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"} + ] + } + }, + + "PORT53": + { + "dev_info": { "device_type":"QSFP28", "device_name":"PORT53", "device_parent":"MUX3"}, + "dev_attr": { "dev_idx":"53"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT53-EEPROM" }, + { "itf":"control", "dev":"PORT53-CTRL" } + ] + } + }, + "PORT53-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT53-EEPROM", "device_parent":"MUX3", "virt_parent":"PORT53"}, + "i2c": + { + "topo_info": { "parent_bus":"0x17", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT53-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT53-CTRL", "device_parent":"MUX3", "virt_parent":"PORT53"}, + "i2c": + { + "topo_info": { "parent_bus":"0x17", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3","attr_offset":"0x14", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_reset", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x15", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_intr_status", "attr_devaddr":"0x62", "attr_devtype":"cpld","attr_devname":"CPLD3", "attr_offset":"0x13", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3","attr_offset":"0x16", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"} + ] + } + }, + + + "CPLD1": + { + "dev_info": { "device_type":"CPLD", "device_name":"CPLD1", "device_parent":"MUX1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3", "dev_addr":"0x60", "dev_type":"i2c_cpld"}, + "dev_attr":{} + } + }, + "CPLD2": + { + "dev_info": { "device_type":"CPLD", "device_name":"CPLD2", "device_parent":"MUX1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3", "dev_addr":"0x61", "dev_type":"i2c_cpld"}, + "dev_attr":{} + } + }, + "CPLD3": + { + "dev_info": { "device_type":"CPLD", "device_name":"CPLD3", "device_parent":"MUX1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3", "dev_addr":"0x62", "dev_type":"i2c_cpld"}, + "dev_attr":{} + } + }, + + "FAN-CTRL": + { + "dev_info": { "device_type":"FAN", "device_name":"FAN-CTRL", "device_parent":"MUX1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3", "dev_addr":"0x63", "dev_type":"fan_ctrl"}, + "dev_attr": { "num_fantrays":"5"}, + "attr_list": + [ + { "attr_name":"fan1_present", "attr_devtype":"FAN-CTRL", "attr_offset":"0x02", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan2_present", "attr_devtype":"FAN-CTRL", "attr_offset":"0x02", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan3_present", "attr_devtype":"FAN-CTRL", "attr_offset":"0x02", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan4_present", "attr_devtype":"FAN-CTRL", "attr_offset":"0x02", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan5_present", "attr_devtype":"FAN-CTRL", "attr_offset":"0x02", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan6_present", "attr_devtype":"FAN-CTRL", "attr_offset":"0x02", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan7_present", "attr_devtype":"FAN-CTRL", "attr_offset":"0x02", "attr_mask":"0x8", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan8_present", "attr_devtype":"FAN-CTRL", "attr_offset":"0x02", "attr_mask":"0x8", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan9_present", "attr_devtype":"FAN-CTRL", "attr_offset":"0x02", "attr_mask":"0x10", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan10_present", "attr_devtype":"FAN-CTRL", "attr_offset":"0x02","attr_mask":"0x10", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan1_direction", "attr_devtype":"FAN-CTRL", "attr_offset":"0x03", "attr_mask":"0x1", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"fan2_direction", "attr_devtype":"FAN-CTRL", "attr_offset":"0x03", "attr_mask":"0x1", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"fan3_direction", "attr_devtype":"FAN-CTRL", "attr_offset":"0x03", "attr_mask":"0x2", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"fan4_direction", "attr_devtype":"FAN-CTRL", "attr_offset":"0x03", "attr_mask":"0x2", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"fan5_direction", "attr_devtype":"FAN-CTRL", "attr_offset":"0x03", "attr_mask":"0x4", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"fan6_direction", "attr_devtype":"FAN-CTRL", "attr_offset":"0x03", "attr_mask":"0x4", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"fan7_direction", "attr_devtype":"FAN-CTRL", "attr_offset":"0x03", "attr_mask":"0x8", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"fan8_direction", "attr_devtype":"FAN-CTRL", "attr_offset":"0x03", "attr_mask":"0x8", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"fan9_direction", "attr_devtype":"FAN-CTRL", "attr_offset":"0x03", "attr_mask":"0x10", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"fan10_direction", "attr_devtype":"FAN-CTRL", "attr_offset":"0x03", "attr_mask":"0x10", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"fan1_input", "attr_devtype":"FAN-CTRL", "attr_offset":"0x07", "attr_mask":"0xFF", "attr_len":"1", "attr_mult":"150", "attr_is_divisor":0}, + { "attr_name":"fan2_input", "attr_devtype":"FAN-CTRL", "attr_offset":"0x0C", "attr_mask":"0xFF", "attr_len":"1", "attr_mult":"150", "attr_is_divisor":0}, + { "attr_name":"fan3_input", "attr_devtype":"FAN-CTRL", "attr_offset":"0x08", "attr_mask":"0xFF", "attr_len":"1", "attr_mult":"150", "attr_is_divisor":0}, + { "attr_name":"fan4_input", "attr_devtype":"FAN-CTRL", "attr_offset":"0x0D", "attr_mask":"0xFF", "attr_len":"1", "attr_mult":"150", "attr_is_divisor":0}, + { "attr_name":"fan5_input", "attr_devtype":"FAN-CTRL", "attr_offset":"0x09", "attr_mask":"0xFF", "attr_len":"1", "attr_mult":"150", "attr_is_divisor":0}, + { "attr_name":"fan6_input", "attr_devtype":"FAN-CTRL", "attr_offset":"0x0E", "attr_mask":"0xFF", "attr_len":"1", "attr_mult":"150", "attr_is_divisor":0}, + { "attr_name":"fan7_input", "attr_devtype":"FAN-CTRL", "attr_offset":"0x0A", "attr_mask":"0xFF", "attr_len":"1", "attr_mult":"150" , "attr_is_divisor":0}, + { "attr_name":"fan8_input", "attr_devtype":"FAN-CTRL", "attr_offset":"0x0F", "attr_mask":"0xFF", "attr_len":"1", "attr_mult":"150" , "attr_is_divisor":0}, + { "attr_name":"fan9_input", "attr_devtype":"FAN-CTRL", "attr_offset":"0x0B", "attr_mask":"0xFF", "attr_len":"1", "attr_mult":"150" , "attr_is_divisor":0}, + { "attr_name":"fan10_input", "attr_devtype":"FAN-CTRL", "attr_offset":"0x10", "attr_mask":"0xFF", "attr_len":"1", "attr_mult":"150" , "attr_is_divisor":0}, + { "attr_name":"fan1_pwm", "attr_devtype":"FAN-CTRL", "attr_offset":"0x06", "attr_mask":"0x1F", "attr_len":"1" }, + { "attr_name":"fan2_pwm", "attr_devtype":"FAN-CTRL", "attr_offset":"0x06", "attr_mask":"0x1F", "attr_len":"1" }, + { "attr_name":"fan3_pwm", "attr_devtype":"FAN-CTRL", "attr_offset":"0x06", "attr_mask":"0x1F", "attr_len":"1" }, + { "attr_name":"fan4_pwm", "attr_devtype":"FAN-CTRL", "attr_offset":"0x06", "attr_mask":"0x1F", "attr_len":"1" }, + { "attr_name":"fan5_pwm", "attr_devtype":"FAN-CTRL", "attr_offset":"0x06", "attr_mask":"0x1F", "attr_len":"1" }, + { "attr_name":"fan6_pwm", "attr_devtype":"FAN-CTRL", "attr_offset":"0x06", "attr_mask":"0x1F", "attr_len":"1" }, + { "attr_name":"fan7_pwm", "attr_devtype":"FAN-CTRL", "attr_offset":"0x06", "attr_mask":"0x1F", "attr_len":"1" }, + { "attr_name":"fan8_pwm", "attr_devtype":"FAN-CTRL", "attr_offset":"0x06", "attr_mask":"0x1F", "attr_len":"1" }, + { "attr_name":"fan9_pwm", "attr_devtype":"FAN-CTRL", "attr_offset":"0x06", "attr_mask":"0x1F", "attr_len":"1" }, + { "attr_name":"fan10_pwm", "attr_devtype":"FAN-CTRL", "attr_offset":"0x06", "attr_mask":"0x1F", "attr_len":"1" } + ] + } + }, + + "MUX4": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX4", "device_parent":"MUX1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2", "dev_addr":"0x71", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0x1a", "idle_state":"-2"}, + "channel": + [ + { "chn":"0", "dev":"TEMP1" }, + { "chn":"1", "dev":"TEMP2" }, + { "chn":"2", "dev":"TEMP3" }, + { "chn":"3", "dev":"TEMP4" } + ] + } + }, + + "TEMP1" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP1", "device_parent":"MUX4"}, + "dev_attr": { "display_name":"CB_temp(0x4B)"}, + "i2c": + { + "topo_info": { "parent_bus":"0x1a", "dev_addr":"0x4B", "dev_type":"lm75"}, + "attr_list": + [ + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_max_hyst"}, + { "attr_name": "temp1_input"} + ] + } + }, + "TEMP2" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP2", "device_parent":"MUX4"}, + "dev_attr": { "display_name":"MB_FrontMiddle_temp(0x4C)"}, + "i2c": + { + "topo_info": { "parent_bus":"0x1b", "dev_addr":"0x4C", "dev_type":"lm75"}, + "attr_list": + [ + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_max_hyst"}, + { "attr_name": "temp1_input"} + ] + } + }, + "TEMP3" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP3", "device_parent":"MUX4"}, + "dev_attr": { "display_name":"MB_RearLeft_temp(0x49)"}, + "i2c": + { + "topo_info": { "parent_bus":"0x1c", "dev_addr":"0x49", "dev_type":"lm75"}, + "attr_list": + [ + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_max_hyst"}, + { "attr_name": "temp1_input"} + ] + } + }, + "TEMP4" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP4", "device_parent":"MUX4"}, + "dev_attr": { "display_name":"MB_RearLeft_temp(0x4A)"}, + "i2c": + { + "topo_info": { "parent_bus":"0x1d", "dev_addr":"0x4A", "dev_type":"lm75"}, + "attr_list": + [ + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_max_hyst"}, + { "attr_name": "temp1_input"} + ] + } + }, + "TEMP5" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP5"}, + "dev_attr": { "display_name":"CPU_Package_temp"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon1"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp1_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_input"} + ] + } + }, + "TEMP6" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP6"}, + "dev_attr": { "display_name":"CPU_Core_0_temp"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon1"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp4_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp4_max"}, + { "attr_name": "temp1_input", "drv_attr_name":"temp4_input"} + ] + } + }, + "TEMP7" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP7"}, + "dev_attr": { "display_name":"CPU_Core_1_temp"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon1"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp8_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp8_max"}, + { "attr_name": "temp1_input", "drv_attr_name":"temp8_input"} + ] + } + }, + "TEMP8" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP8"}, + "dev_attr": { "display_name":"CPU_Core_2_temp"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon1"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp10_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp10_max"}, + { "attr_name": "temp1_input", "drv_attr_name":"temp10_input"} + ] + } + }, + "TEMP9" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP9"}, + "dev_attr": { "display_name":"CPU_Core_3_temp"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon1"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp14_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp14_max"}, + { "attr_name": "temp1_input", "drv_attr_name":"temp14_input"} + ] + } + }, + "SYSSTATUS": + { + "dev_info":{ "device_type":"SYSSTAT", "device_name":"SYSSTATUS"}, + "dev_attr":{ }, + "attr_list": + [ + + { "attr_name":"board_info","attr_devaddr":"0x60", "attr_offset":"0x0","attr_mask":"0xff","attr_len":"0x1"}, + { "attr_name":"cpld1_version","attr_devaddr":"0x60","attr_offset":"0x1","attr_mask":"0xff","attr_len":"0x1"}, + { "attr_name":"cpld2_version","attr_devaddr":"0x61","attr_offset":"0x1","attr_mask":"0xff","attr_len":"0x1"}, + { "attr_name":"cpld3version","attr_devaddr":"0x62","attr_offset":"0x1","attr_mask":"0xff","attr_len":"0x1"}, + { "attr_name":"fan_cpld_version","attr_devaddr":"0x63","attr_offset":"0x1","attr_mask":"0xff","attr_len":"0x1"} + + ] + }, + + "MUX5": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX5", "device_parent":"MUX1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3", "dev_addr":"0x70", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0x22", "idle_state":"-2"}, + "channel": + [ + { "chn":"0", "dev":"MUX6" }, + { "chn":"1", "dev":"MUX7" }, + { "chn":"2", "dev":"MUX8" }, + { "chn":"3", "dev":"MUX9" }, + { "chn":"4", "dev":"MUX10" }, + { "chn":"5", "dev":"MUX11" } + ] + } + }, + "MUX6": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX6", "device_parent":"MUX5"}, + "i2c": + { + "topo_info": { "parent_bus":"0x22", "dev_addr":"0x71", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0x2a", "idle_state":"-2"}, + "channel": + [ + { "chn":"0", "dev":"PORT1" }, + { "chn":"1", "dev":"PORT2" }, + { "chn":"2", "dev":"PORT3" }, + { "chn":"3", "dev":"PORT4" }, + { "chn":"4", "dev":"PORT5" }, + { "chn":"5", "dev":"PORT6" }, + { "chn":"6", "dev":"PORT7" }, + { "chn":"7", "dev":"PORT8" } + ] + } + }, + "MUX7": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX7", "device_parent":"MUX5"}, + "i2c": + { + "topo_info": { "parent_bus":"0x23", "dev_addr":"0x72", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0x32", "idle_state":"-2"}, + "channel": + [ + { "chn":"0", "dev":"PORT9" }, + { "chn":"1", "dev":"PORT10" }, + { "chn":"2", "dev":"PORT11" }, + { "chn":"3", "dev":"PORT12" }, + { "chn":"4", "dev":"PORT13" }, + { "chn":"5", "dev":"PORT14" }, + { "chn":"6", "dev":"PORT15" }, + { "chn":"7", "dev":"PORT16" } + ] + } + }, + "MUX8": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX8", "device_parent":"MUX5"}, + "i2c": + { + "topo_info": { "parent_bus":"0x24", "dev_addr":"0x73", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0x3a", "idle_state":"-2"}, + "channel": + [ + { "chn":"0", "dev":"PORT17" }, + { "chn":"1", "dev":"PORT18" }, + { "chn":"2", "dev":"PORT19" }, + { "chn":"3", "dev":"PORT20" }, + { "chn":"4", "dev":"PORT21" }, + { "chn":"5", "dev":"PORT22" }, + { "chn":"6", "dev":"PORT23" }, + { "chn":"7", "dev":"PORT24" } + ] + } + }, + "MUX9": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX9", "device_parent":"MUX5"}, + "i2c": + { + "topo_info": { "parent_bus":"0x25", "dev_addr":"0x74", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0x42", "idle_state":"-2"}, + "channel": + [ + { "chn":"0", "dev":"PORT25" }, + { "chn":"1", "dev":"PORT26" }, + { "chn":"2", "dev":"PORT27" }, + { "chn":"3", "dev":"PORT28" }, + { "chn":"4", "dev":"PORT29" }, + { "chn":"5", "dev":"PORT30" }, + { "chn":"6", "dev":"PORT31" }, + { "chn":"7", "dev":"PORT32" } + ] + } + }, + "MUX10": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX10", "device_parent":"MUX5"}, + "i2c": + { + "topo_info": { "parent_bus":"0x26", "dev_addr":"0x75", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0x4a", "idle_state":"-2"}, + "channel": + [ + { "chn":"0", "dev":"PORT33" }, + { "chn":"1", "dev":"PORT34" }, + { "chn":"2", "dev":"PORT35" }, + { "chn":"3", "dev":"PORT36" }, + { "chn":"4", "dev":"PORT37" }, + { "chn":"5", "dev":"PORT38" }, + { "chn":"6", "dev":"PORT39" }, + { "chn":"7", "dev":"PORT40" } + ] + } + }, + "MUX11": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX11", "device_parent":"MUX5"}, + "i2c": + { + "topo_info": { "parent_bus":"0x27", "dev_addr":"0x76", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0x52", "idle_state":"-2"}, + "channel": + [ + { "chn":"0", "dev":"PORT41" }, + { "chn":"1", "dev":"PORT42" }, + { "chn":"2", "dev":"PORT43" }, + { "chn":"3", "dev":"PORT44" }, + { "chn":"4", "dev":"PORT45" }, + { "chn":"5", "dev":"PORT46" }, + { "chn":"6", "dev":"PORT47" }, + { "chn":"7", "dev":"PORT48" } + ] + } + }, + + "PORT1": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT1", "device_parent":"MUX6"}, + "dev_attr": { "dev_idx":"1"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT1-EEPROM" }, + { "itf":"control", "dev":"PORT1-CTRL" } + ] + } + }, + "PORT1-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT1-EEPROM", "device_parent":"MUX6", "virt_parent":"PORT1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2a", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT1-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT1-CTRL", "device_parent":"MUX6", "virt_parent":"PORT1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2a", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x8", "attr_mask":"0x0", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0D", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x12", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x17", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"} + ] + } + }, + + "PORT2": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT2", "device_parent":"MUX6"}, + "dev_attr": { "dev_idx":"2"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT2-EEPROM" }, + { "itf":"control", "dev":"PORT2-CTRL" } + ] + } + }, + "PORT2-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT2-EEPROM", "device_parent":"MUX6", "virt_parent":"PORT2"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2b", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT2-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT2-CTRL", "device_parent":"MUX6", "virt_parent":"PORT2"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2b", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x8", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0D", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x12", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x17", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"} + ] + } + }, + + "PORT3": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT3", "device_parent":"MUX6"}, + "dev_attr": { "dev_idx":"3"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT3-EEPROM" }, + { "itf":"control", "dev":"PORT3-CTRL" } + ] + } + }, + "PORT3-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT3-EEPROM", "device_parent":"MUX6", "virt_parent":"PORT3"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2c", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT3-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT3-CTRL", "device_parent":"MUX6", "virt_parent":"PORT3"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2c", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x8", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0D", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x12", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x17", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"} + ] + } + }, + + "PORT4": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT4", "device_parent":"MUX6"}, + "dev_attr": { "dev_idx":"4"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT4-EEPROM" }, + { "itf":"control", "dev":"PORT4-CTRL" } + ] + } + }, + "PORT4-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT4-EEPROM", "device_parent":"MUX6", "virt_parent":"PORT4"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2d", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT4-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT4-CTRL", "device_parent":"MUX6", "virt_parent":"PORT4"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2d", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x8", "attr_mask":"0x3", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0D", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x12", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x17", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"} + ] + } + }, + + "PORT5": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT5", "device_parent":"MUX6"}, + "dev_attr": { "dev_idx":"5"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT5-EEPROM" }, + { "itf":"control", "dev":"PORT5-CTRL" } + ] + } + }, + "PORT5-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT5-EEPROM", "device_parent":"MUX6", "virt_parent":"PORT5"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2e", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT5-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT5-CTRL", "device_parent":"MUX6", "virt_parent":"PORT5"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2e", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x8", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0D", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x12", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x17", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"} + ] + } + }, + + "PORT6": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT6", "device_parent":"MUX6"}, + "dev_attr": { "dev_idx":"6"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT6-EEPROM" }, + { "itf":"control", "dev":"PORT6-CTRL" } + ] + } + }, + "PORT6-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT6-EEPROM", "device_parent":"MUX6", "virt_parent":"PORT6"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2f", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT6-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT6-CTRL", "device_parent":"MUX6", "virt_parent":"PORT6"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2f", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x8", "attr_mask":"0x5", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0D", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x12", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x17", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"} + ] + } + }, + + "PORT7": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT7", "device_parent":"MUX6"}, + "dev_attr": { "dev_idx":"7"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT7-EEPROM" }, + { "itf":"control", "dev":"PORT7-CTRL" } + ] + } + }, + "PORT7-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT7-EEPROM", "device_parent":"MUX6", "virt_parent":"PORT7"}, + "i2c": + { + "topo_info": { "parent_bus":"0x30", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT7-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT7-CTRL", "device_parent":"MUX6", "virt_parent":"PORT7"}, + "i2c": + { + "topo_info": { "parent_bus":"0x30", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x8", "attr_mask":"0x6", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0D", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x12", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x17", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"} + ] + } + }, + + "PORT8": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT8", "device_parent":"MUX6"}, + "dev_attr": { "dev_idx":"8"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT8-EEPROM" }, + { "itf":"control", "dev":"PORT8-CTRL" } + ] + } + }, + "PORT8-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT8-EEPROM", "device_parent":"MUX6", "virt_parent":"PORT8"}, + "i2c": + { + "topo_info": { "parent_bus":"0x31", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT8-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT8-CTRL", "device_parent":"MUX6", "virt_parent":"PORT8"}, + "i2c": + { + "topo_info": { "parent_bus":"0x31", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x8", "attr_mask":"0x7", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0D", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x12", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x17", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"} + ] + } + }, + + "PORT9": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT9", "device_parent":"MUX7"}, + "dev_attr": { "dev_idx":"9"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT9-EEPROM" }, + { "itf":"control", "dev":"PORT9-CTRL" } + ] + } + }, + "PORT9-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT9-EEPROM", "device_parent":"MUX7", "virt_parent":"PORT9"}, + "i2c": + { + "topo_info": { "parent_bus":"0x32", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT9-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT9-CTRL", "device_parent":"MUX7", "virt_parent":"PORT9"}, + "i2c": + { + "topo_info": { "parent_bus":"0x32", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x09", "attr_mask":"0x0", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0E", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x13", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x18", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"} + ] + } + }, + + "PORT10": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT10", "device_parent":"MUX7"}, + "dev_attr": { "dev_idx":"10"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT10-EEPROM" }, + { "itf":"control", "dev":"PORT10-CTRL" } + ] + } + }, + "PORT10-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT10-EEPROM", "device_parent":"MUX7", "virt_parent":"PORT10"}, + "i2c": + { + "topo_info": { "parent_bus":"0x33", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT10-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT10-CTRL", "device_parent":"MUX7", "virt_parent":"PORT10"}, + "i2c": + { + "topo_info": { "parent_bus":"0x33", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x09", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0E", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x13", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x18", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"} + ] + } + }, + + "PORT11": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT11", "device_parent":"MUX7"}, + "dev_attr": { "dev_idx":"11"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT11-EEPROM" }, + { "itf":"control", "dev":"PORT11-CTRL" } + ] + } + }, + "PORT11-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT11-EEPROM", "device_parent":"MUX7", "virt_parent":"PORT11"}, + "i2c": + { + "topo_info": { "parent_bus":"0x34", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT11-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT11-CTRL", "device_parent":"MUX7", "virt_parent":"PORT11"}, + "i2c": + { + "topo_info": { "parent_bus":"0x34", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x09", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0E", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x13", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x18", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"} + ] + } + }, + + "PORT12": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT12", "device_parent":"MUX7"}, + "dev_attr": { "dev_idx":"12"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT12-EEPROM" }, + { "itf":"control", "dev":"PORT12-CTRL" } + ] + } + }, + "PORT12-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT12-EEPROM", "device_parent":"MUX7", "virt_parent":"PORT12"}, + "i2c": + { + "topo_info": { "parent_bus":"0x35", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT12-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT12-CTRL", "device_parent":"MUX7", "virt_parent":"PORT12"}, + "i2c": + { + "topo_info": { "parent_bus":"0x35", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x09", "attr_mask":"0x3", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0E", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x13", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x18", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"} + ] + } + }, + + "PORT13": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT13", "device_parent":"MUX7"}, + "dev_attr": { "dev_idx":"13"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT13-EEPROM" }, + { "itf":"control", "dev":"PORT13-CTRL" } + ] + } + }, + "PORT13-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT13-EEPROM", "device_parent":"MUX7", "virt_parent":"PORT13"}, + "i2c": + { + "topo_info": { "parent_bus":"0x36", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT13-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT13-CTRL", "device_parent":"MUX7", "virt_parent":"PORT13"}, + "i2c": + { + "topo_info": { "parent_bus":"0x36", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x09", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0E", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x13", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x18", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"} + ] + } + }, + + "PORT14": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT14", "device_parent":"MUX7"}, + "dev_attr": { "dev_idx":"14"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT14-EEPROM" }, + { "itf":"control", "dev":"PORT14-CTRL" } + ] + } + }, + "PORT14-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT14-EEPROM", "device_parent":"MUX7", "virt_parent":"PORT14"}, + "i2c": + { + "topo_info": { "parent_bus":"0x37", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT14-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT14-CTRL", "device_parent":"MUX7", "virt_parent":"PORT14"}, + "i2c": + { + "topo_info": { "parent_bus":"0x37", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x09", "attr_mask":"0x5", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0E", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x13", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x18", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"} + ] + } + }, + + "PORT15": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT15", "device_parent":"MUX7"}, + "dev_attr": { "dev_idx":"15"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT15-EEPROM" }, + { "itf":"control", "dev":"PORT15-CTRL" } + ] + } + }, + "PORT15-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT15-EEPROM", "device_parent":"MUX7", "virt_parent":"PORT15"}, + "i2c": + { + "topo_info": { "parent_bus":"0x38", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT15-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT15-CTRL", "device_parent":"MUX7", "virt_parent":"PORT15"}, + "i2c": + { + "topo_info": { "parent_bus":"0x38", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x09", "attr_mask":"0x6", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0E", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x13", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x18", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"} + ] + } + }, + + "PORT16": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT16", "device_parent":"MUX7"}, + "dev_attr": { "dev_idx":"16"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT16-EEPROM" }, + { "itf":"control", "dev":"PORT16-CTRL" } + ] + } + }, + "PORT16-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT16-EEPROM", "device_parent":"MUX7", "virt_parent":"PORT16"}, + "i2c": + { + "topo_info": { "parent_bus":"0x39", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT16-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT16-CTRL", "device_parent":"MUX7", "virt_parent":"PORT16"}, + "i2c": + { + "topo_info": { "parent_bus":"0x39", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x09", "attr_mask":"0x7", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0E", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x13", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x18", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"} + ] + } + }, + + "PORT17": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT17", "device_parent":"MUX8"}, + "dev_attr": { "dev_idx":"17"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT17-EEPROM" }, + { "itf":"control", "dev":"PORT17-CTRL" } + ] + } + }, + "PORT17-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT17-EEPROM", "device_parent":"MUX8", "virt_parent":"PORT17"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3a", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT17-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT17-CTRL", "device_parent":"MUX8", "virt_parent":"PORT17"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3a", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0A", "attr_mask":"0x0", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0F", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x14", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x19", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"} + ] + } + }, + + "PORT18": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT18", "device_parent":"MUX8"}, + "dev_attr": { "dev_idx":"18"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT18-EEPROM" }, + { "itf":"control", "dev":"PORT18-CTRL" } + ] + } + }, + "PORT18-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT18-EEPROM", "device_parent":"MUX8", "virt_parent":"PORT18"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3b", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT18-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT18-CTRL", "device_parent":"MUX8", "virt_parent":"PORT18"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3b", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0A", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0F", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x14", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x19", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"} + ] + } + }, + + "PORT19": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT19", "device_parent":"MUX8"}, + "dev_attr": { "dev_idx":"19"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT19-EEPROM" }, + { "itf":"control", "dev":"PORT19-CTRL" } + ] + } + }, + "PORT19-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT19-EEPROM", "device_parent":"MUX8", "virt_parent":"PORT19"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3c", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT19-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT19-CTRL", "device_parent":"MUX8", "virt_parent":"PORT19"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3c", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0A", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0F", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x14", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x19", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"} + ] + } + }, + + "PORT20": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT20", "device_parent":"MUX8"}, + "dev_attr": { "dev_idx":"20"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT20-EEPROM" }, + { "itf":"control", "dev":"PORT20-CTRL" } + ] + } + }, + "PORT20-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT20-EEPROM", "device_parent":"MUX8", "virt_parent":"PORT20"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3d", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT20-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT20-CTRL", "device_parent":"MUX8", "virt_parent":"PORT20"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3d", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0A", "attr_mask":"0x3", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0F", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x14", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x19", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"} + ] + } + }, + + "PORT21": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT21", "device_parent":"MUX8"}, + "dev_attr": { "dev_idx":"21"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT21-EEPROM" }, + { "itf":"control", "dev":"PORT21-CTRL" } + ] + } + }, + "PORT21-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT21-EEPROM", "device_parent":"MUX8", "virt_parent":"PORT21"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3e", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT21-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT21-CTRL", "device_parent":"MUX8", "virt_parent":"PORT21"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3e", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0A", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0F", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x14", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x19", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"} + ] + } + }, + + "PORT22": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT22", "device_parent":"MUX8"}, + "dev_attr": { "dev_idx":"22"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT22-EEPROM" }, + { "itf":"control", "dev":"PORT22-CTRL" } + ] + } + }, + "PORT22-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT22-EEPROM", "device_parent":"MUX8", "virt_parent":"PORT22"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3f", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT22-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT22-CTRL", "device_parent":"MUX8", "virt_parent":"PORT22"}, + "i2c": + { + "topo_info": { "parent_bus":"0x3f", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0A", "attr_mask":"0x5", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0F", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x14", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x19", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"} + ] + } + }, + + "PORT23": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT23", "device_parent":"MUX8"}, + "dev_attr": { "dev_idx":"23"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT23-EEPROM" }, + { "itf":"control", "dev":"PORT23-CTRL" } + ] + } + }, + "PORT23-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT23-EEPROM", "device_parent":"MUX8", "virt_parent":"PORT23"}, + "i2c": + { + "topo_info": { "parent_bus":"0x40", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT23-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT23-CTRL", "device_parent":"MUX8", "virt_parent":"PORT23"}, + "i2c": + { + "topo_info": { "parent_bus":"0x40", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0A", "attr_mask":"0x6", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0F", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x14", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x19", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"} + ] + } + }, + + "PORT24": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT24", "device_parent":"MUX8"}, + "dev_attr": { "dev_idx":"24"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT24-EEPROM" }, + { "itf":"control", "dev":"PORT24-CTRL" } + ] + } + }, + "PORT24-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT24-EEPROM", "device_parent":"MUX8", "virt_parent":"PORT24"}, + "i2c": + { + "topo_info": { "parent_bus":"0x41", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT24-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT24-CTRL", "device_parent":"MUX8", "virt_parent":"PORT24"}, + "i2c": + { + "topo_info": { "parent_bus":"0x41", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0A", "attr_mask":"0x7", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0F", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x14", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x19", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"} + ] + } + }, + + "PORT25": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT25", "device_parent":"MUX9"}, + "dev_attr": { "dev_idx":"25"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT25-EEPROM" }, + { "itf":"control", "dev":"PORT25-CTRL" } + ] + } + }, + "PORT25-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT25-EEPROM", "device_parent":"MUX9", "virt_parent":"PORT25"}, + "i2c": + { + "topo_info": { "parent_bus":"0x42", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT25-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT25-CTRL", "device_parent":"MUX9", "virt_parent":"PORT25"}, + "i2c": + { + "topo_info": { "parent_bus":"0x42", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x0B", "attr_mask":"0x0", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x10", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x15", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x1A", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"} + ] + } + }, + + "PORT26": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT26", "device_parent":"MUX9"}, + "dev_attr": { "dev_idx":"26"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT26-EEPROM" }, + { "itf":"control", "dev":"PORT26-CTRL" } + ] + } + }, + "PORT26-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT26-EEPROM", "device_parent":"MUX9", "virt_parent":"PORT26"}, + "i2c": + { + "topo_info": { "parent_bus":"0x43", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT26-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT26-CTRL", "device_parent":"MUX9", "virt_parent":"PORT26"}, + "i2c": + { + "topo_info": { "parent_bus":"0x43", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x0B", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x10", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x15", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x1A", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"} + ] + } + }, + + "PORT27": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT27", "device_parent":"MUX9"}, + "dev_attr": { "dev_idx":"27"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT27-EEPROM" }, + { "itf":"control", "dev":"PORT27-CTRL" } + ] + } + }, + "PORT27-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT27-EEPROM", "device_parent":"MUX9", "virt_parent":"PORT27"}, + "i2c": + { + "topo_info": { "parent_bus":"0x44", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT27-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT27-CTRL", "device_parent":"MUX9", "virt_parent":"PORT27"}, + "i2c": + { + "topo_info": { "parent_bus":"0x44", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x0B", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x10", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld","attr_devname":"CPLD2", "attr_offset":"0x15", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x1A", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"} + ] + } + }, + + "PORT28": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT28", "device_parent":"MUX9"}, + "dev_attr": { "dev_idx":"28"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT28-EEPROM" }, + { "itf":"control", "dev":"PORT28-CTRL" } + ] + } + }, + "PORT28-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT28-EEPROM", "device_parent":"MUX9", "virt_parent":"PORT28"}, + "i2c": + { + "topo_info": { "parent_bus":"0x45", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT28-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT28-CTRL", "device_parent":"MUX9", "virt_parent":"PORT28"}, + "i2c": + { + "topo_info": { "parent_bus":"0x45", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x0B", "attr_mask":"0x3", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x10", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x15", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x1A", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"} + ] + } + }, + + "PORT29": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT29", "device_parent":"MUX9"}, + "dev_attr": { "dev_idx":"29"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT29-EEPROM" }, + { "itf":"control", "dev":"PORT29-CTRL" } + ] + } + }, + "PORT29-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT29-EEPROM", "device_parent":"MUX9", "virt_parent":"PORT29"}, + "i2c": + { + "topo_info": { "parent_bus":"0x46", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT29-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT29-CTRL", "device_parent":"MUX9", "virt_parent":"PORT29"}, + "i2c": + { + "topo_info": { "parent_bus":"0x46", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x0B", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x10", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x15", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x1A", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"} + ] + } + }, + + "PORT30": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT30", "device_parent":"MUX9"}, + "dev_attr": { "dev_idx":"30"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT30-EEPROM" }, + { "itf":"control", "dev":"PORT30-CTRL" } + ] + } + }, + "PORT30-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT30-EEPROM", "device_parent":"MUX9", "virt_parent":"PORT30"}, + "i2c": + { + "topo_info": { "parent_bus":"0x47", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT30-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT30-CTRL", "device_parent":"MUX9", "virt_parent":"PORT30"}, + "i2c": + { + "topo_info": { "parent_bus":"0x47", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0B", "attr_mask":"0x5", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x10", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld","attr_devname":"CPLD2", "attr_offset":"0x15", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x1A", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"} + ] + } + }, + + "PORT31": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT31", "device_parent":"MUX9"}, + "dev_attr": { "dev_idx":"31"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT31-EEPROM" }, + { "itf":"control", "dev":"PORT31-CTRL" } + ] + } + }, + "PORT31-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT31-EEPROM", "device_parent":"MUX9", "virt_parent":"PORT31"}, + "i2c": + { + "topo_info": { "parent_bus":"0x48", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT31-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT31-CTRL", "device_parent":"MUX9", "virt_parent":"PORT31"}, + "i2c": + { + "topo_info": { "parent_bus":"0x48", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x0B", "attr_mask":"0x6", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x10", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x15", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2","attr_offset":"0x1A", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"} + ] + } + }, + + "PORT32": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT32", "device_parent":"MUX9"}, + "dev_attr": { "dev_idx":"32"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT32-EEPROM" }, + { "itf":"control", "dev":"PORT32-CTRL" } + ] + } + }, + "PORT32-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT32-EEPROM", "device_parent":"MUX9", "virt_parent":"PORT32"}, + "i2c": + { + "topo_info": { "parent_bus":"0x49", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT32-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT32-CTRL", "device_parent":"MUX9", "virt_parent":"PORT32"}, + "i2c": + { + "topo_info": { "parent_bus":"0x49", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0B", "attr_mask":"0x7", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x10", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld","attr_devname":"CPLD2", "attr_offset":"0x15", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x1A", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"} + ] + } + }, + + "PORT33": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT33", "device_parent":"MUX10"}, + "dev_attr": { "dev_idx":"33"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT33-EEPROM" }, + { "itf":"control", "dev":"PORT33-CTRL" } + ] + } + }, + "PORT33-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT33-EEPROM", "device_parent":"MUX10", "virt_parent":"PORT33"}, + "i2c": + { + "topo_info": { "parent_bus":"0x4a", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT33-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT33-CTRL", "device_parent":"MUX10", "virt_parent":"PORT33"}, + "i2c": + { + "topo_info": { "parent_bus":"0x4a", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0C", "attr_mask":"0x0", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x11", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x16", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x1B", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"} + ] + } + }, + + "PORT34": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT34", "device_parent":"MUX10"}, + "dev_attr": { "dev_idx":"34"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT34-EEPROM" }, + { "itf":"control", "dev":"PORT34-CTRL" } + ] + } + }, + "PORT34-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT34-EEPROM", "device_parent":"MUX10", "virt_parent":"PORT34"}, + "i2c": + { + "topo_info": { "parent_bus":"0x4b", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT34-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT34-CTRL", "device_parent":"MUX10", "virt_parent":"PORT34"}, + "i2c": + { + "topo_info": { "parent_bus":"0x4b", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0C", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x11", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x16", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x1B", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"} + ] + } + }, + + "PORT35": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT35", "device_parent":"MUX10"}, + "dev_attr": { "dev_idx":"35"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT35-EEPROM" }, + { "itf":"control", "dev":"PORT35-CTRL" } + ] + } + }, + "PORT35-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT35-EEPROM", "device_parent":"MUX10", "virt_parent":"PORT35"}, + "i2c": + { + "topo_info": { "parent_bus":"0x4c", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT35-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT35-CTRL", "device_parent":"MUX10", "virt_parent":"PORT35"}, + "i2c": + { + "topo_info": { "parent_bus":"0x4c", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0C", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x11", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x16", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x1B", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"} + ] + } + }, + + "PORT36": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT36", "device_parent":"MUX10"}, + "dev_attr": { "dev_idx":"36"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT36-EEPROM" }, + { "itf":"control", "dev":"PORT36-CTRL" } + ] + } + }, + "PORT36-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT36-EEPROM", "device_parent":"MUX10", "virt_parent":"PORT36"}, + "i2c": + { + "topo_info": { "parent_bus":"0x4d", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT36-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT36-CTRL", "device_parent":"MUX10", "virt_parent":"PORT36"}, + "i2c": + { + "topo_info": { "parent_bus":"0x4d", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0C", "attr_mask":"0x3", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x11", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x16", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x1B", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"} + ] + } + }, + + "PORT37": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT37", "device_parent":"MUX10"}, + "dev_attr": { "dev_idx":"37"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT37-EEPROM" }, + { "itf":"control", "dev":"PORT37-CTRL" } + ] + } + }, + "PORT37-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT37-EEPROM", "device_parent":"MUX10", "virt_parent":"PORT37"}, + "i2c": + { + "topo_info": { "parent_bus":"0x4e", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT37-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT37-CTRL", "device_parent":"MUX10", "virt_parent":"PORT37"}, + "i2c": + { + "topo_info": { "parent_bus":"0x4e", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0C", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x11", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x16", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x1B", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"} + ] + } + }, + + "PORT38": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT38", "device_parent":"MUX10"}, + "dev_attr": { "dev_idx":"38"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT38-EEPROM" }, + { "itf":"control", "dev":"PORT38-CTRL" } + ] + } + }, + "PORT38-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT38-EEPROM", "device_parent":"MUX10", "virt_parent":"PORT38"}, + "i2c": + { + "topo_info": { "parent_bus":"0x4f", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT38-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT38-CTRL", "device_parent":"MUX10", "virt_parent":"PORT38"}, + "i2c": + { + "topo_info": { "parent_bus":"0x4f", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x0C", "attr_mask":"0x5", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x11", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x16", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x61", "attr_devtype":"cpld", "attr_devname":"CPLD2", "attr_offset":"0x1B", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"} + ] + } + }, + + "PORT39": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT39", "device_parent":"MUX10"}, + "dev_attr": { "dev_idx":"39"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT39-EEPROM" }, + { "itf":"control", "dev":"PORT39-CTRL" } + ] + } + }, + "PORT39-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT39-EEPROM", "device_parent":"MUX10", "virt_parent":"PORT39"}, + "i2c": + { + "topo_info": { "parent_bus":"0x50", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT39-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT39-CTRL", "device_parent":"MUX10", "virt_parent":"PORT39"}, + "i2c": + { + "topo_info": { "parent_bus":"0x50", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x06", "attr_mask":"0x0", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x09", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0C", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0F", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"} + ] + } + }, + + "PORT40": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT40", "device_parent":"MUX10"}, + "dev_attr": { "dev_idx":"40"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT40-EEPROM" }, + { "itf":"control", "dev":"PORT40-CTRL" } + ] + } + }, + "PORT40-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT40-EEPROM", "device_parent":"MUX10", "virt_parent":"PORT40"}, + "i2c": + { + "topo_info": { "parent_bus":"0x51", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT40-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT40-CTRL", "device_parent":"MUX10", "virt_parent":"PORT40"}, + "i2c": + { + "topo_info": { "parent_bus":"0x51", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x06", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x09", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0C", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0F", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"} + ] + } + }, + + "PORT41": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT41", "device_parent":"MUX11"}, + "dev_attr": { "dev_idx":"41"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT41-EEPROM" }, + { "itf":"control", "dev":"PORT41-CTRL" } + ] + } + }, + "PORT41-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT41-EEPROM", "device_parent":"MUX11", "virt_parent":"PORT41"}, + "i2c": + { + "topo_info": { "parent_bus":"0x52", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT41-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT41-CTRL", "device_parent":"MUX11", "virt_parent":"PORT41"}, + "i2c": + { + "topo_info": { "parent_bus":"0x52", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x06", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x09", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0C", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0F", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"} + ] + } + }, + + "PORT42": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT42", "device_parent":"MUX11"}, + "dev_attr": { "dev_idx":"42"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT42-EEPROM" }, + { "itf":"control", "dev":"PORT42-CTRL" } + ] + } + }, + "PORT42-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT42-EEPROM", "device_parent":"MUX11", "virt_parent":"PORT42"}, + "i2c": + { + "topo_info": { "parent_bus":"0x53", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT42-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT42-CTRL", "device_parent":"MUX11", "virt_parent":"PORT42"}, + "i2c": + { + "topo_info": { "parent_bus":"0x53", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x06", "attr_mask":"0x3", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x09", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0C", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0F", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"} + ] + } + }, + + "PORT43": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT43", "device_parent":"MUX11"}, + "dev_attr": { "dev_idx":"43"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT43-EEPROM" }, + { "itf":"control", "dev":"PORT43-CTRL" } + ] + } + }, + "PORT43-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT43-EEPROM", "device_parent":"MUX11", "virt_parent":"PORT43"}, + "i2c": + { + "topo_info": { "parent_bus":"0x54", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT43-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT43-CTRL", "device_parent":"MUX11", "virt_parent":"PORT43"}, + "i2c": + { + "topo_info": { "parent_bus":"0x54", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3","attr_offset":"0x06", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3","attr_offset":"0x09", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3","attr_offset":"0x0C", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3","attr_offset":"0x0F", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"} + ] + } + }, + + "PORT44": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT44", "device_parent":"MUX11"}, + "dev_attr": { "dev_idx":"44"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT44-EEPROM" }, + { "itf":"control", "dev":"PORT44-CTRL" } + ] + } + }, + "PORT44-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT44-EEPROM", "device_parent":"MUX11", "virt_parent":"PORT44"}, + "i2c": + { + "topo_info": { "parent_bus":"0x55", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT44-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT44-CTRL", "device_parent":"MUX11", "virt_parent":"PORT44"}, + "i2c": + { + "topo_info": { "parent_bus":"0x55", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x06", "attr_mask":"0x5", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x09", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0C", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0F", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"} + ] + } + }, + + "PORT45": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT45", "device_parent":"MUX11"}, + "dev_attr": { "dev_idx":"45"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT45-EEPROM" }, + { "itf":"control", "dev":"PORT45-CTRL" } + ] + } + }, + "PORT45-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT45-EEPROM", "device_parent":"MUX11", "virt_parent":"PORT45"}, + "i2c": + { + "topo_info": { "parent_bus":"0x56", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT45-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT45-CTRL", "device_parent":"MUX11", "virt_parent":"PORT45"}, + "i2c": + { + "topo_info": { "parent_bus":"0x56", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x06", "attr_mask":"0x6", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x09", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0C", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0F", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"} + ] + } + }, + + "PORT46": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT46", "device_parent":"MUX11"}, + "dev_attr": { "dev_idx":"46"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT46-EEPROM" }, + { "itf":"control", "dev":"PORT46-CTRL" } + ] + } + }, + "PORT46-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT46-EEPROM", "device_parent":"MUX11", "virt_parent":"PORT46"}, + "i2c": + { + "topo_info": { "parent_bus":"0x57", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT46-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT46-CTRL", "device_parent":"MUX11", "virt_parent":"PORT46"}, + "i2c": + { + "topo_info": { "parent_bus":"0x57", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x06", "attr_mask":"0x7", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x09", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0C", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0F", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"} + ] + } + }, + + "PORT47": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT47", "device_parent":"MUX11"}, + "dev_attr": { "dev_idx":"47"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT47-EEPROM" }, + { "itf":"control", "dev":"PORT47-CTRL" } + ] + } + }, + "PORT47-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT47-EEPROM", "device_parent":"MUX11", "virt_parent":"PORT47"}, + "i2c": + { + "topo_info": { "parent_bus":"0x58", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT47-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT47-CTRL", "device_parent":"MUX11", "virt_parent":"PORT47"}, + "i2c": + { + "topo_info": { "parent_bus":"0x58", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x07", "attr_mask":"0x0", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0A", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0D", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x10", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"} + ] + } + }, + + "PORT48": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT48", "device_parent":"MUX11"}, + "dev_attr": { "dev_idx":"48"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT48-EEPROM" }, + { "itf":"control", "dev":"PORT48-CTRL" } + ] + } + }, + "PORT48-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT48-EEPROM", "device_parent":"MUX11", "virt_parent":"PORT48"}, + "i2c": + { + "topo_info": { "parent_bus":"0x59", "dev_addr":"0x50", "dev_type":"optoe1"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT48-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT48-CTRL", "device_parent":"MUX11", "virt_parent":"PORT48"}, + "i2c": + { + "topo_info": { "parent_bus":"0x59", "dev_addr":"0x53", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_present", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x07", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0A", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x0D", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x62", "attr_devtype":"cpld", "attr_devname":"CPLD3", "attr_offset":"0x10", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"} + ] + } + }, + + "LOC_LED": + { + "dev_info": { "device_type":"LED", "device_name":"LOC_LED"}, + "dev_attr": { "index":"0", "flag": "rw"}, + "i2c" : + { + "attr_list": + [ + {"attr_name":"amber", "descr": "" , "bits" : "5:4", "value" : "0x0", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x0A"}, + {"attr_name":"off", "descr": "" , "bits" : "5:4", "value" : "0x1", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x0A"} + + ] + } + }, + "DIAG_LED": + { + "dev_info": { "device_type":"LED", "device_name":"DIAG_LED"}, + "dev_attr": { "index":"0", "flag": "rw"}, + "i2c" : + { + "attr_list": + [ + {"attr_name":"green", "descr": "" , "bits" : "3:2", "value" : "0x2", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x0A"}, + {"attr_name":"amber", "descr": "" , "bits" : "3:2", "value" : "0x1", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x0A"}, + {"attr_name":"off", "descr": "" , "bits" : "3:2", "value" : "0x3", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x0A"} + ] + } + } +} diff --git a/device/accton/x86_64-accton_as5835_54x-r0/pddf_support b/device/accton/x86_64-accton_as5835_54x-r0/pddf_support new file mode 100644 index 0000000000..e69de29bb2 diff --git a/device/accton/x86_64-accton_as5835_54x-r0/platform.json b/device/accton/x86_64-accton_as5835_54x-r0/platform.json new file mode 100644 index 0000000000..c69ab55381 --- /dev/null +++ b/device/accton/x86_64-accton_as5835_54x-r0/platform.json @@ -0,0 +1,843 @@ +{ + "chassis": { + "name": "5835-54X", + "thermal_manager":false, + "status_led": { + "controllable": true, + "colors": ["green", "amber", "off"] + }, + "components": [ + { + "name": "MB_CPLD1" + }, + { + "name": "MB_CPLD2" + }, + { + "name": "MB_CPLD3" + }, + { + "name": "FAN_CPLD" + }, + { + "name": "CPU_CPLD" + }, + { + "name": "BIOS" + } + ], + "fans": [ + { + "name": "FAN-1F" + }, + { + "name": "FAN-1R" + }, + { + "name": "FAN-2F" + }, + { + "name": "FAN-2R" + }, + { + "name": "FAN-3F" + }, + { + "name": "FAN-3R" + }, + { + "name": "FAN-4F" + }, + { + "name": "FAN-4R" + }, + { + "name": "FAN-5F" + }, + { + "name": "FAN-5R" + } + ], + "fan_drawers":[ + { + "name": "FanTray1", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-1F" + }, + { + "name": "FAN-1R" + } + ] + }, + { + "name": "FanTray2", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-2F" + }, + { + "name": "FAN-2R" + } + ] + }, + { + "name": "FanTray3", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-3F" + }, + { + "name": "FAN-3R" + } + ] + }, + { + "name": "FanTray4", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-4F" + }, + { + "name": "FAN-4R" + } + ] + }, + { + "name": "FanTray5", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-5F" + }, + { + "name": "FAN-5R" + } + ] + } + ], + "psus": [ + { + "name": "PSU-1", + "fans": [ + { + "name": "PSU-1 FAN-1" + } + ], + "thermals": [ + { + "name": "PSU-1 temp sensor 1", + "controllable": false, + "low-threshold": false, + "high-threshold": false, + "low-crit-threshold": false, + "high-crit-threshold": false + } + ], + "temperature": true, + "temperature_high_threshold": true + }, + { + "name": "PSU-2", + "fans": [ + { + "name": "PSU-2 FAN-1" + } + ], + "thermals": [ + { + "name": "PSU-2 temp sensor 1", + "controllable": false, + "low-threshold": false, + "high-threshold": false, + "low-crit-threshold": false, + "high-crit-threshold": false + } + ], + "temperature": true, + "temperature_high_threshold": true + } + ], + "thermals": [ + { + "name": "CB_temp(0x4B)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false + }, + { + "name": "MB_FrontMiddle_temp(0x4C)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false + }, + { + "name": "MB_RearLeft_temp(0x4A)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false + }, + { + "name": "MB_RearLeft_temp(0x49)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false + }, + { + "name": "CPU_Package_temp", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + }, + { + "name": "CPU_Core_0_temp", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + }, + { + "name": "CPU_Core_1_temp", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + }, + { + "name": "CPU_Core_2_temp", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + }, + { + "name": "CPU_Core_3_temp", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + } + ], + "sfps": [ + { + "name": "Ethernet0" + }, + { + "name": "Ethernet1" + }, + { + "name": "Ethernet2" + }, + { + "name": "Ethernet3" + }, + { + "name": "Ethernet4" + }, + { + "name": "Ethernet5" + }, + { + "name": "Ethernet6" + }, + { + "name": "Ethernet7" + }, + { + "name": "Ethernet8" + }, + { + "name": "Ethernet9" + }, + { + "name": "Ethernet10" + }, + { + "name": "Ethernet11" + }, + { + "name": "Ethernet12" + }, + { + "name": "Ethernet13" + }, + { + "name": "Ethernet14" + }, + { + "name": "Ethernet15" + }, + { + "name": "Ethernet16" + }, + { + "name": "Ethernet17" + }, + { + "name": "Ethernet18" + }, + { + "name": "Ethernet19" + }, + { + "name": "Ethernet20" + }, + { + "name": "Ethernet21" + }, + { + "name": "Ethernet22" + }, + { + "name": "Ethernet23" + }, + { + "name": "Ethernet24" + }, + { + "name": "Ethernet25" + }, + { + "name": "Ethernet26" + }, + { + "name": "Ethernet27" + }, + { + "name": "Ethernet28" + }, + { + "name": "Ethernet29" + }, + { + "name": "Ethernet30" + }, + { + "name": "Ethernet31" + }, + { + "name": "Ethernet32" + }, + { + "name": "Ethernet33" + }, + { + "name": "Ethernet34" + }, + { + "name": "Ethernet35" + }, + { + "name": "Ethernet36" + }, + { + "name": "Ethernet37" + }, + { + "name": "Ethernet38" + }, + { + "name": "Ethernet39" + }, + { + "name": "Ethernet40" + }, + { + "name": "Ethernet41" + }, + { + "name": "Ethernet42" + }, + { + "name": "Ethernet43" + }, + { + "name": "Ethernet44" + }, + { + "name": "Ethernet45" + }, + { + "name": "Ethernet46" + }, + { + "name": "Ethernet47" + }, + { + "name": "Ethernet48" + }, + { + "name": "Ethernet52" + }, + { + "name": "Ethernet56" + }, + { + "name": "Ethernet60" + }, + { + "name": "Ethernet64" + }, + { + "name": "Ethernet68" + } + ] + }, + "interfaces": { + "Ethernet0": { + "index": "1", + "lanes": "1", + "breakout_modes": { + "1x10G[1G]": ["Eth1(Port1)"] + } + }, + + "Ethernet1": { + "index": "2", + "lanes": "2", + "breakout_modes": { + "1x10G[1G]": ["Eth2(Port2)"] + } + }, + + "Ethernet2": { + "index": "3", + "lanes": "3", + "breakout_modes": { + "1x10G[1G]": ["Eth3(Port3)"] + } + }, + + "Ethernet3": { + "index": "4", + "lanes": "4", + "breakout_modes": { + "1x10G[1G]": ["Eth4(Port4)"] + } + }, + + "Ethernet4": { + "index": "5", + "lanes": "5", + "breakout_modes": { + "1x10G[1G]": ["Eth5(Port5)"] + } + }, + + "Ethernet5": { + "index": "6", + "lanes": "6", + "breakout_modes": { + "1x10G[1G]": ["Eth6(Port6)"] + } + }, + + "Ethernet6": { + "index": "7", + "lanes": "7", + "breakout_modes": { + "1x10G[1G]": ["Eth7(Port7)"] + } + }, + + "Ethernet7": { + "index": "8", + "lanes": "8", + "breakout_modes": { + "1x10G[1G]": ["Eth8(Port8)"] + } + }, + + "Ethernet8": { + "index": "9", + "lanes": "9", + "breakout_modes": { + "1x10G[1G]": ["Eth9(Port9)"] + } + }, + + "Ethernet9": { + "index": "10", + "lanes": "10", + "breakout_modes": { + "1x10G[1G]": ["Eth10(Port10)"] + } + }, + + "Ethernet10": { + "index": "11", + "lanes": "11", + "breakout_modes": { + "1x10G[1G]": ["Eth11(Port11)"] + } + }, + + "Ethernet11": { + "index": "12", + "lanes": "12", + "breakout_modes": { + "1x10G[1G]": ["Eth12(Port12)"] + } + }, + + "Ethernet12": { + "index": "13", + "lanes": "13", + "breakout_modes": { + "1x10G[1G]": ["Eth13(Port13)"] + } + }, + + "Ethernet13": { + "index": "14", + "lanes": "14", + "breakout_modes": { + "1x10G[1G]": ["Eth14(Port14)"] + } + }, + + "Ethernet14": { + "index": "15", + "lanes": "15", + "breakout_modes": { + "1x10G[1G]": ["Eth15(Port15)"] + } + }, + + "Ethernet15": { + "index": "16", + "lanes": "16", + "breakout_modes": { + "1x10G[1G]": ["Eth16(Port16)"] + } + }, + + "Ethernet16": { + "index": "17", + "lanes": "17", + "breakout_modes": { + "1x10G[1G]": ["Eth17(Port17)"] + } + }, + + "Ethernet17": { + "index": "18", + "lanes": "18", + "breakout_modes": { + "1x10G[1G]": ["Eth18(Port18)"] + } + }, + + "Ethernet18": { + "index": "19", + "lanes": "19", + "breakout_modes": { + "1x10G[1G]": ["Eth19(Port19)"] + } + }, + + "Ethernet19": { + "index": "20", + "lanes": "20", + "breakout_modes": { + "1x10G[1G]": ["Eth20(Port20)"] + } + }, + + "Ethernet20": { + "index": "21", + "lanes": "21", + "breakout_modes": { + "1x10G[1G]": ["Eth21(Port21)"] + } + }, + + "Ethernet21": { + "index": "22", + "lanes": "22", + "breakout_modes": { + "1x10G[1G]": ["Eth22(Port22)"] + } + }, + + "Ethernet22": { + "index": "23", + "lanes": "23", + "breakout_modes": { + "1x10G[1G]": ["Eth23(Port23)"] + } + }, + + "Ethernet23": { + "index": "24", + "lanes": "24", + "breakout_modes": { + "1x10G[1G]": ["Eth24(Port24)"] + } + }, + + "Ethernet24": { + "index": "25", + "lanes": "53", + "breakout_modes": { + "1x10G[1G]": ["Eth25(Port25)"] + } + }, + + "Ethernet25": { + "index": "26", + "lanes": "54", + "breakout_modes": { + "1x10G[1G]": ["Eth26(Port26)"] + } + }, + + "Ethernet26": { + "index": "27", + "lanes": "55", + "breakout_modes": { + "1x10G[1G]": ["Eth27(Port27)"] + } + }, + + "Ethernet27": { + "index": "28", + "lanes": "56", + "breakout_modes": { + "1x10G[1G]": ["Eth28(Port28)"] + } + }, + + "Ethernet28": { + "index": "29", + "lanes": "57", + "breakout_modes": { + "1x10G[1G]": ["Eth29(Port29)"] + } + }, + + "Ethernet29": { + "index": "30", + "lanes": "58", + "breakout_modes": { + "1x10G[1G]": ["Eth30(Port30)"] + } + }, + + "Ethernet30": { + "index": "31", + "lanes": "59", + "breakout_modes": { + "1x10G[1G]": ["Eth31(Port31)"] + } + }, + + "Ethernet31": { + "index": "32", + "lanes": "60", + "breakout_modes": { + "1x10G[1G]": ["Eth32(Port32)"] + } + }, + + "Ethernet32": { + "index": "33", + "lanes": "61", + "breakout_modes": { + "1x10G[1G]": ["Eth33(Port33)"] + } + }, + + "Ethernet33": { + "index": "34", + "lanes": "62", + "breakout_modes": { + "1x10G[1G]": ["Eth34(Port34)"] + } + }, + + "Ethernet34": { + "index": "35", + "lanes": "63", + "breakout_modes": { + "1x10G[1G]": ["Eth35(Port35)"] + } + }, + + "Ethernet35": { + "index": "36", + "lanes": "64", + "breakout_modes": { + "1x10G[1G]": ["Eth36(Port36)"] + } + }, + + "Ethernet36": { + "index": "37", + "lanes": "65", + "breakout_modes": { + "1x10G[1G]": ["Eth37(Port37)"] + } + }, + + "Ethernet37": { + "index": "38", + "lanes": "66", + "breakout_modes": { + "1x10G[1G]": ["Eth38(Port38)"] + } + }, + + "Ethernet38": { + "index": "39", + "lanes": "67", + "breakout_modes": { + "1x10G[1G]": ["Eth39(Port39)"] + } + }, + + "Ethernet39": { + "index": "40", + "lanes": "68", + "breakout_modes": { + "1x10G[1G]": ["Eth40(Port40)"] + } + }, + + "Ethernet40": { + "index": "41", + "lanes": "69", + "breakout_modes": { + "1x10G[1G]": ["Eth41(Port41)"] + } + }, + + "Ethernet41": { + "index": "42", + "lanes": "70", + "breakout_modes": { + "1x10G[1G]": ["Eth42(Port42)"] + } + }, + + "Ethernet42": { + "index": "43", + "lanes": "71", + "breakout_modes": { + "1x10G[1G]": ["Eth43(Port43)"] + } + }, + + "Ethernet43": { + "index": "44", + "lanes": "72", + "breakout_modes": { + "1x10G[1G]": ["Eth44(Port44)"] + } + }, + + "Ethernet44": { + "index": "45", + "lanes": "73", + "breakout_modes": { + "1x10G[1G]": ["Eth45(Port45)"] + } + }, + + "Ethernet45": { + "index": "46", + "lanes": "74", + "breakout_modes": { + "1x10G[1G]": ["Eth46(Port46)"] + } + }, + + "Ethernet46": { + "index": "47", + "lanes": "75", + "breakout_modes": { + "1x10G[1G]": ["Eth47(Port47)"] + } + }, + + "Ethernet47": { + "index": "48", + "lanes": "76", + "breakout_modes": { + "1x10G[1G]": ["Eth48(Port48)"] + } + }, + + "Ethernet48": { + "index": "49,49,49,49", + "lanes": "37,38,39,40", + "breakout_modes": { + "1x100G[40G]": ["Eth49(Port49)"], + "2x50G": ["Eth49/1(Port49)", "Eth49/2(Port49)"], + "4x25G": ["Eth49/1(Port49)", "Eth49/2(Port49)", "Eth49/3(Port49)", "Eth49/4(Port49)"], + "4x10G": ["Eth49/1(Port49)", "Eth49/2(Port49)", "Eth49/3(Port49)", "Eth49/4(Port49)"] + } + }, + + "Ethernet52": { + "index": "50,50,50,50", + "lanes": "29,30,31,32", + "breakout_modes": { + "1x100G[40G]": ["Eth50(Port50)"] + } + }, + + "Ethernet56": { + "index": "51,51,51,51", + "lanes": "33,34,35,36", + "breakout_modes": { + "1x100G[40G]": ["Eth51(Port51)"] + } + }, + + "Ethernet60": { + "index": "52,52,52,52", + "lanes": "49,50,51,52", + "breakout_modes": { + "1x100G[40G]": ["Eth52(Port52)"], + "2x50G": ["Eth52/1(Port52)", "Eth52/2(Port52)"], + "4x25G": ["Eth52/1(Port52)", "Eth52/2(Port52)", "Eth52/3(Port52)", "Eth52/4(Port52)"], + "4x10G": ["Eth52/1(Port52)", "Eth52/2(Port52)", "Eth52/3(Port52)", "Eth52/4(Port52)"] + } + }, + + "Ethernet64": { + "index": "53,53,53,53", + "lanes": "45,46,47,48", + "breakout_modes": { + "1x100G[40G]": ["Eth53(Port53)"] + } + }, + + "Ethernet68": { + "index": "54,54,54,54", + "lanes": "41,42,43,44", + "breakout_modes": { + "1x100G[40G]": ["Eth54(Port54)"] + } + } + } +} diff --git a/device/accton/x86_64-accton_as5835_54x-r0/platform_components.json b/device/accton/x86_64-accton_as5835_54x-r0/platform_components.json new file mode 100644 index 0000000000..16f6f73dd7 --- /dev/null +++ b/device/accton/x86_64-accton_as5835_54x-r0/platform_components.json @@ -0,0 +1,14 @@ +{ + "chassis": { + "5835-54X-O-AC-F": { + "component": { + "MB_CPLD1": { }, + "MB_CPLD2": { }, + "MB_CPLD3": { }, + "FAN_CPLD": { }, + "CPU_CPLD": { }, + "BIOS": { } + } + } + } +} diff --git a/device/accton/x86_64-accton_as5835_54x-r0/plugins/ssd_util.py b/device/accton/x86_64-accton_as5835_54x-r0/plugins/ssd_util.py new file mode 100755 index 0000000000..4b173c5e38 --- /dev/null +++ b/device/accton/x86_64-accton_as5835_54x-r0/plugins/ssd_util.py @@ -0,0 +1,24 @@ +# ssd_util.py +# +# Platform-specific SSD interface for SONiC +## + +try: + from sonic_platform_base.sonic_ssd.ssd_generic import SsdUtil as MainSsdUtil +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +NOT_AVAILABLE = "N/A" + +class SsdUtil(MainSsdUtil): + """Platform-specific SsdUtil class""" + + def __init__(self, diskdev): + super(SsdUtil, self).__init__(diskdev) + + # If it has no vendor tool to read SSD information, + # ssd_util.py will use generic SSD information + # for vendor SSD information. + if self.vendor_ssd_info == NOT_AVAILABLE: + self.vendor_ssd_info = self.ssd_info + diff --git a/device/accton/x86_64-accton_as5835_54x-r0/pmon_daemon_control.json b/device/accton/x86_64-accton_as5835_54x-r0/pmon_daemon_control.json index a3b204e20d..94592fa8ce 100644 --- a/device/accton/x86_64-accton_as5835_54x-r0/pmon_daemon_control.json +++ b/device/accton/x86_64-accton_as5835_54x-r0/pmon_daemon_control.json @@ -1,5 +1,3 @@ { - "skip_ledd": true, - "skip_pcied": true + "skip_ledd": true } - diff --git a/device/accton/x86_64-accton_as5835_54x-r0/sensors.conf b/device/accton/x86_64-accton_as5835_54x-r0/sensors.conf index 38cf89fc68..4d132ef2a9 100644 --- a/device/accton/x86_64-accton_as5835_54x-r0/sensors.conf +++ b/device/accton/x86_64-accton_as5835_54x-r0/sensors.conf @@ -39,13 +39,13 @@ chip "as5835_54x_fan-*" chip "lm75-i2c-*-49" - label temp1 "Main Board Temperature" + label temp1 "MB_RearLeft_temp" chip "lm75-i2c-*-4a" - label temp1 "Main Board Temperature" + label temp1 "MB_RearRight_temp" chip "lm75-i2c-*-4c" - label temp1 "Main Board Temperature" + label temp1 "MB_FrontMiddle_temp" chip "lm75-i2c-*-4b" - label temp1 "CPU Board Temperature" + label temp1 "CB_temp" diff --git a/device/accton/x86_64-accton_as5835_54x-r0/sonic_platform/fan.py b/device/accton/x86_64-accton_as5835_54x-r0/sonic_platform/fan.py index 8cb1c17fdf..43ce61559a 100644 --- a/device/accton/x86_64-accton_as5835_54x-r0/sonic_platform/fan.py +++ b/device/accton/x86_64-accton_as5835_54x-r0/sonic_platform/fan.py @@ -44,7 +44,7 @@ FAN_NAME_LIST = ["FAN-1F", "FAN-1R", "FAN-2F", "FAN-2R", - "FAN-3F", "FAN-3R", "FAN-4F", "FAN-4R", + "FAN-3F", "FAN-3R", "FAN-4F", "FAN-4R", "FAN-5F", "FAN-5R"] class Fan(FanBase): @@ -61,7 +61,7 @@ def __init__(self, fan_tray_index, fan_index=0, is_psu_fan=False, psu_index=0): self.psu_i2c_addr = PSU_HWMON_I2C_MAPPING[self.psu_index]['addr'] self.psu_hwmon_path = I2C_PATH.format( self.psu_i2c_num, self.psu_i2c_addr) - + self.psu_i2c_num = PSU_CPLD_I2C_MAPPING[self.psu_index]['num'] self.psu_i2c_addr = PSU_CPLD_I2C_MAPPING[self.psu_index]['addr'] self.psu_cpld_path = I2C_PATH.format( @@ -77,7 +77,7 @@ def get_direction(self): A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST depending on fan direction """ - + if not self.is_psu_fan: dir_str = "{}{}{}".format(CPLD_FAN_I2C_PATH, self.fan_tray_index+1, '_direction') @@ -91,17 +91,17 @@ def get_direction(self): direction=self.FAN_DIRECTION_EXHAUST else: #For PSU dir_str = "{}{}".format(self.psu_hwmon_path,'psu_fan_dir') - + val=self._api_helper.read_txt_file(dir_str) - if val is not None: + if val is not None: if val=='F2B': direction=self.FAN_DIRECTION_EXHAUST else: direction=self.FAN_DIRECTION_INTAKE else: direction=self.FAN_DIRECTION_EXHAUST - + return direction def get_speed(self): @@ -122,12 +122,12 @@ def get_speed(self): speed=100 else: return 0 - elif self.get_presence(): + elif self.get_presence(): speed_path = "{}{}".format(CPLD_FAN_I2C_PATH, '_duty_cycle_percentage') speed=self._api_helper.read_txt_file(speed_path) if speed is None: return 0 - + return int(speed) def get_target_speed(self): @@ -164,8 +164,8 @@ def set_speed(self, speed): A boolean, True if speed is set successfully, False if not """ - - if not self.is_psu_fan and self.get_presence(): + + if not self.is_psu_fan and self.get_presence(): speed_path = "{}{}".format(CPLD_FAN_I2C_PATH, '_duty_cycle_percentage') return self._api_helper.write_txt_file(speed_path, int(speed)) @@ -181,21 +181,20 @@ def set_status_led(self, color): bool: True if status LED state is set successfully, False if not """ return False #Not supported - + def get_status_led(self): """ Gets the state of the fan status LED Returns: A string, one of the predefined STATUS_LED_COLOR_* strings above """ - status=self.get_presence() - if status is None: - return self.STATUS_LED_COLOR_OFF + if self.is_psu_fan: + return None return { - 1: self.STATUS_LED_COLOR_GREEN, - 0: self.STATUS_LED_COLOR_RED - }.get(status, self.STATUS_LED_COLOR_OFF) + True: self.STATUS_LED_COLOR_GREEN, + False: self.STATUS_LED_COLOR_RED + }.get(self.get_status(), self.STATUS_LED_COLOR_RED) def get_name(self): """ @@ -208,20 +207,18 @@ def get_name(self): else "PSU-{} FAN-{}".format(self.psu_index+1, self.fan_index+1) return fan_name - + def get_presence(self): """ Retrieves the presence of the FAN Returns: bool: True if FAN is present, False if not """ - - if self.is_psu_fan: present_path="{}{}".format(self.psu_cpld_path, 'psu_present') else: present_path = "{}{}{}".format(CPLD_FAN_I2C_PATH, self.fan_tray_index+1, '_present') - + val=self._api_helper.read_txt_file(present_path) if val is not None: return int(val, 10)==1 @@ -235,30 +232,34 @@ def get_status(self): A boolean value, True if device is operating properly, False if not """ if self.is_psu_fan: + psu_path = "{}{}".format(self.psu_cpld_path, 'psu_power_good') + val = self._api_helper.read_txt_file(psu_path) + if val is None or int(val, 10)==0: + return False + psu_fan_path= "{}{}".format(self.psu_hwmon_path, 'psu_fan1_fault') val=self._api_helper.read_txt_file(psu_fan_path) if val is not None: return int(val, 10)==0 else: return False - else: - path = "{}{}{}".format(CPLD_FAN_I2C_PATH, self.fan_tray_index+1, '_fault') + else: + sys_index = self.fan_index * 10 + self.fan_tray_index+1 + path = "{}{}{}".format(CPLD_FAN_I2C_PATH, sys_index, '_fault') val=self._api_helper.read_txt_file(path) if val is not None: return int(val, 10)==0 else: return False - def get_model(self): """ Retrieves the model number (or part number) of the device Returns: string: Model/part number of device """ - return "N/A" - + def get_serial(self): """ Retrieves the serial number of the device diff --git a/device/accton/x86_64-accton_as5835_54x-r0/sonic_platform/fan_drawer.py b/device/accton/x86_64-accton_as5835_54x-r0/sonic_platform/fan_drawer.py index 17d339ee55..cc1e87337e 100644 --- a/device/accton/x86_64-accton_as5835_54x-r0/sonic_platform/fan_drawer.py +++ b/device/accton/x86_64-accton_as5835_54x-r0/sonic_platform/fan_drawer.py @@ -22,7 +22,7 @@ def __init__(self, fantray_index): # FanTray is 0-based in platforms self.fantrayindex = fantray_index self.__initialize_fan_drawer() - + def __initialize_fan_drawer(self): from sonic_platform.fan import Fan @@ -67,7 +67,13 @@ def get_status(self): Returns: A boolean value, True if device is operating properly, False if not """ - return self._fan_list[0].get_status() + from sonic_platform.fan import Fan + + for fan in self._fan_list: + if not fan.get_status(): + return False + + return True def get_position_in_parent(self): """ @@ -88,3 +94,25 @@ def is_replaceable(self): bool: True if it is replaceable. """ return True + + def set_status_led(self, color): + """ + Sets the state of the fan module status LED + Args: + color: A string representing the color with which to set the + fan module status LED + Returns: + bool: True if status LED state is set successfully, False if not + """ + return False # Not supported + + def get_status_led(self): + """ + Gets the state of the fan status LED + Returns: + A string, one of the predefined STATUS_LED_COLOR_* strings above + """ + return { + True: self.STATUS_LED_COLOR_GREEN, + False: self.STATUS_LED_COLOR_RED + }.get(self.get_status(), self.STATUS_LED_COLOR_RED) diff --git a/device/accton/x86_64-accton_as5835_54x-r0/system_health_monitoring_config.json b/device/accton/x86_64-accton_as5835_54x-r0/system_health_monitoring_config.json index 5f3b3b07e7..4ea184946b 100644 --- a/device/accton/x86_64-accton_as5835_54x-r0/system_health_monitoring_config.json +++ b/device/accton/x86_64-accton_as5835_54x-r0/system_health_monitoring_config.json @@ -1,15 +1,17 @@ -{ - "services_to_ignore": [], - "devices_to_ignore": [ - "asic", - "psu.temperature" - - ], - "user_defined_checkers": [], - "polling_interval": 60, - "led_color": { - "fault": "STATUS_LED_COLOR_AMBER", - "normal": "STATUS_LED_COLOR_GREEN", - "booting": "STATUS_LED_COLOR_GREEN" - } -} +{ + "services_to_ignore": [], + "devices_to_ignore": [ + "asic", + "psu.voltage", + "psu.temperature", + "PSU1_FAN1.speed", + "PSU2_FAN1.speed" + ], + "user_defined_checkers": [], + "polling_interval": 60, + "led_color": { + "fault": "amber", + "normal": "green", + "booting": "off" + } +} diff --git a/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/hwsku.json b/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/hwsku.json new file mode 100644 index 0000000000..839db8e8aa --- /dev/null +++ b/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/hwsku.json @@ -0,0 +1,227 @@ +{ + "interfaces": { + "Ethernet0": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet1": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet2": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet3": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet4": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet5": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet6": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet7": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet8": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet9": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet10": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet11": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet12": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet13": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet14": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet15": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet16": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet17": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet18": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet19": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet20": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet21": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet22": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet23": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet24": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet25": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet26": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet27": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet28": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet29": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet30": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet31": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet32": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet33": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet34": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet35": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet36": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet37": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet38": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet39": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet40": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet41": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet42": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet43": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet44": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet45": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet46": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet47": { + "default_brkout_mode": "1x25G" + }, + + "Ethernet48": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet52": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet56": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet60": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet64": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet68": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet72": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet76": { + "default_brkout_mode": "1x100G[40G]" + } + } +} diff --git a/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/port_config.ini b/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/port_config.ini index 10c55c5aee..24a9549179 100755 --- a/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/port_config.ini +++ b/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/port_config.ini @@ -1,57 +1,57 @@ # name lanes alias index speed -Ethernet0 3 twentyfiveGigE1 1 25000 -Ethernet1 2 twentyfiveGigE2 2 25000 -Ethernet2 4 twentyfiveGigE3 3 25000 -Ethernet3 8 twentyfiveGigE4 4 25000 -Ethernet4 7 twentyfiveGigE5 5 25000 -Ethernet5 1 twentyfiveGigE6 6 25000 -Ethernet6 5 twentyfiveGigE7 7 25000 -Ethernet7 16 twentyfiveGigE8 8 25000 -Ethernet8 6 twentyfiveGigE9 9 25000 -Ethernet9 14 twentyfiveGigE10 10 25000 -Ethernet10 13 twentyfiveGigE11 11 25000 -Ethernet11 15 twentyfiveGigE12 12 25000 -Ethernet12 23 twentyfiveGigE13 13 25000 -Ethernet13 22 twentyfiveGigE14 14 25000 -Ethernet14 24 twentyfiveGigE15 15 25000 -Ethernet15 32 twentyfiveGigE16 16 25000 -Ethernet16 31 twentyfiveGigE17 17 25000 -Ethernet17 21 twentyfiveGigE18 18 25000 -Ethernet18 29 twentyfiveGigE19 19 25000 -Ethernet19 36 twentyfiveGigE20 20 25000 -Ethernet20 30 twentyfiveGigE21 21 25000 -Ethernet21 34 twentyfiveGigE22 22 25000 -Ethernet22 33 twentyfiveGigE23 23 25000 -Ethernet23 35 twentyfiveGigE24 24 25000 -Ethernet24 43 twentyfiveGigE25 25 25000 -Ethernet25 42 twentyfiveGigE26 26 25000 -Ethernet26 44 twentyfiveGigE27 27 25000 -Ethernet27 52 twentyfiveGigE28 28 25000 -Ethernet28 51 twentyfiveGigE29 29 25000 -Ethernet29 41 twentyfiveGigE30 30 25000 -Ethernet30 49 twentyfiveGigE31 31 25000 -Ethernet31 60 twentyfiveGigE32 32 25000 -Ethernet32 50 twentyfiveGigE33 33 25000 -Ethernet33 58 twentyfiveGigE34 34 25000 -Ethernet34 57 twentyfiveGigE35 35 25000 -Ethernet35 59 twentyfiveGigE36 36 25000 -Ethernet36 62 twentyfiveGigE37 37 25000 -Ethernet37 63 twentyfiveGigE38 38 25000 -Ethernet38 64 twentyfiveGigE39 39 25000 -Ethernet39 65 twentyfiveGigE40 40 25000 -Ethernet40 66 twentyfiveGigE41 41 25000 -Ethernet41 61 twentyfiveGigE42 42 25000 -Ethernet42 68 twentyfiveGigE43 43 25000 -Ethernet43 69 twentyfiveGigE44 44 25000 -Ethernet44 67 twentyfiveGigE45 45 25000 -Ethernet45 71 twentyfiveGigE46 46 25000 -Ethernet46 72 twentyfiveGigE47 47 25000 -Ethernet47 70 twentyfiveGigE48 48 25000 -Ethernet48 77,78,79,80 hundredGigE49 49 100000 -Ethernet52 85,86,87,88 hundredGigE50 50 100000 -Ethernet56 93,94,95,96 hundredGigE51 51 100000 -Ethernet60 97,98,99,100 hundredGigE52 52 100000 -Ethernet64 105,106,107,108 hundredGigE53 53 100000 -Ethernet68 113,114,115,116 hundredGigE54 54 100000 -Ethernet72 121,122,123,124 hundredGigE55 55 100000 -Ethernet76 125,126,127,128 hundredGigE56 56 100000 +Ethernet0 3 Eth1(Port1) 1 25000 +Ethernet1 2 Eth2(Port2) 2 25000 +Ethernet2 4 Eth3(Port3) 3 25000 +Ethernet3 8 Eth4(Port4) 4 25000 +Ethernet4 7 Eth5(Port5) 5 25000 +Ethernet5 1 Eth6(Port6) 6 25000 +Ethernet6 5 Eth7(Port7) 7 25000 +Ethernet7 16 Eth8(Port8) 8 25000 +Ethernet8 6 Eth9(Port9) 9 25000 +Ethernet9 14 Eth10(Port10) 10 25000 +Ethernet10 13 Eth11(Port11) 11 25000 +Ethernet11 15 Eth12(Port12) 12 25000 +Ethernet12 23 Eth13(Port13) 13 25000 +Ethernet13 22 Eth14(Port14) 14 25000 +Ethernet14 24 Eth15(Port15) 15 25000 +Ethernet15 32 Eth16(Port16) 16 25000 +Ethernet16 31 Eth17(Port17) 17 25000 +Ethernet17 21 Eth18(Port18) 18 25000 +Ethernet18 29 Eth19(Port19) 19 25000 +Ethernet19 36 Eth20(Port20) 20 25000 +Ethernet20 30 Eth21(Port21) 21 25000 +Ethernet21 34 Eth22(Port22) 22 25000 +Ethernet22 33 Eth23(Port23) 23 25000 +Ethernet23 35 Eth24(Port24) 24 25000 +Ethernet24 43 Eth25(Port25) 25 25000 +Ethernet25 42 Eth26(Port26) 26 25000 +Ethernet26 44 Eth27(Port27) 27 25000 +Ethernet27 52 Eth28(Port28) 28 25000 +Ethernet28 51 Eth29(Port29) 29 25000 +Ethernet29 41 Eth30(Port30) 30 25000 +Ethernet30 49 Eth31(Port31) 31 25000 +Ethernet31 60 Eth32(Port32) 32 25000 +Ethernet32 50 Eth33(Port33) 33 25000 +Ethernet33 58 Eth34(Port34) 34 25000 +Ethernet34 57 Eth35(Port35) 35 25000 +Ethernet35 59 Eth36(Port36) 36 25000 +Ethernet36 62 Eth37(Port37) 37 25000 +Ethernet37 63 Eth38(Port38) 38 25000 +Ethernet38 64 Eth39(Port39) 39 25000 +Ethernet39 65 Eth40(Port40) 40 25000 +Ethernet40 66 Eth41(Port41) 41 25000 +Ethernet41 61 Eth42(Port42) 42 25000 +Ethernet42 68 Eth43(Port43) 43 25000 +Ethernet43 69 Eth44(Port44) 44 25000 +Ethernet44 67 Eth45(Port45) 45 25000 +Ethernet45 71 Eth46(Port46) 46 25000 +Ethernet46 72 Eth47(Port47) 47 25000 +Ethernet47 70 Eth48(Port48) 48 25000 +Ethernet48 77,78,79,80 Eth49(Port49) 49 100000 +Ethernet52 85,86,87,88 Eth50(Port50) 50 100000 +Ethernet56 93,94,95,96 Eth51(Port51) 51 100000 +Ethernet60 97,98,99,100 Eth52(Port52) 52 100000 +Ethernet64 105,106,107,108 Eth53(Port53) 53 100000 +Ethernet68 113,114,115,116 Eth54(Port54) 54 100000 +Ethernet72 121,122,123,124 Eth55(Port55) 55 100000 +Ethernet76 125,126,127,128 Eth56(Port56) 56 100000 diff --git a/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/td3-as7326-48x25G+8x100G.config.bcm b/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/td3-as7326-48x25G+8x100G.config.bcm index 21ca8a2fa5..ea081e7255 100755 --- a/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/td3-as7326-48x25G+8x100G.config.bcm +++ b/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/td3-as7326-48x25G+8x100G.config.bcm @@ -34,6 +34,15 @@ skip_L2_USER_ENTRY=0 bcm_tunnel_term_compatible_mode=1 l3_alpm_ipv6_128b_bkt_rsvd=1 +#vxlan +use_all_splithorizon_groups=1 +riot_enable=1 +sai_tunnel_support=1 +riot_overlay_l3_intf_mem_size=4096 +riot_overlay_l3_egress_mem_size=32768 +riot_overlay_ecmp_resilient_hash_size=16384 +flow_init_mode=1 + dport_map_port_1=6 dport_map_port_2=2 dport_map_port_3=1 diff --git a/device/accton/x86_64-accton_as7326_56x-r0/media_settings.json b/device/accton/x86_64-accton_as7326_56x-r0/media_settings.json new file mode 100644 index 0000000000..f25c782810 --- /dev/null +++ b/device/accton/x86_64-accton_as7326_56x-r0/media_settings.json @@ -0,0 +1,420 @@ +{ + "PORT_MEDIA_SETTINGS": { + "1": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "2": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "3": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "4": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "5": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "6": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "7": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "8": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "9": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "10": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "11": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "12": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "13": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "14": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "15": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "16": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "17": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "18": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "19": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "20": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "21": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "22": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "23": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "24": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "25": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "26": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "27": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "28": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "29": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "30": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "31": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "32": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "33": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "34": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "35": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "36": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "37": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "38": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "39": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "40": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "41": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "42": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "43": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "44": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "45": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "46": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "47": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "48": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + } + }, + "49": { + "Default": { + "preemphasis": { + "lane0": "0x14410a", + "lane1": "0x14410a", + "lane2": "0x14410a", + "lane3": "0x14410a" + } + } + }, + "50": { + "Default": { + "preemphasis": { + "lane0": "0x14410a", + "lane1": "0x14410a", + "lane2": "0x14410a", + "lane3": "0x14410a" + } + } + }, + "51": { + "Default": { + "preemphasis": { + "lane0": "0x14410a", + "lane1": "0x14410a", + "lane2": "0x14410a", + "lane3": "0x14410a" + } + } + }, + "52": { + "Default": { + "preemphasis": { + "lane0": "0x14410a", + "lane1": "0x14410a", + "lane2": "0x14410a", + "lane3": "0x14410a" + } + } + }, + "53": { + "Default": { + "preemphasis": { + "lane0": "0x14410a", + "lane1": "0x14410a", + "lane2": "0x14410a", + "lane3": "0x14410a" + } + } + }, + "54": { + "Default": { + "preemphasis": { + "lane0": "0x14410a", + "lane1": "0x14410a", + "lane2": "0x14410a", + "lane3": "0x14410a" + } + } + }, + "55": { + "Default": { + "preemphasis": { + "lane0": "0x14410a", + "lane1": "0x14410a", + "lane2": "0x14410a", + "lane3": "0x14410a" + } + } + }, + "56": { + "Default": { + "preemphasis": { + "lane0": "0x14410a", + "lane1": "0x14410a", + "lane2": "0x14410a", + "lane3": "0x14410a" + } + } + } + } +} diff --git a/device/accton/x86_64-accton_as7326_56x-r0/pcie.yaml b/device/accton/x86_64-accton_as7326_56x-r0/pcie.yaml new file mode 100644 index 0000000000..6f1be3817a --- /dev/null +++ b/device/accton/x86_64-accton_as7326_56x-r0/pcie.yaml @@ -0,0 +1,465 @@ +- bus: '00' + dev: '00' + fn: '0' + id: 6f00 + name: 'Host bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DMI2 + (rev 03)' +- bus: '00' + dev: '01' + fn: '0' + id: 6f02 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 1 (rev 03)' +- bus: '00' + dev: '01' + fn: '1' + id: 6f03 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 1 (rev 03)' +- bus: '00' + dev: '02' + fn: '0' + id: 6f04 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 2 (rev 03)' +- bus: '00' + dev: '02' + fn: '1' + id: 6f05 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 2 (rev 03)' +- bus: '00' + dev: '02' + fn: '2' + id: 6f06 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 2 (rev 03)' +- bus: '00' + dev: '02' + fn: '3' + id: 6f07 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 2 (rev 03)' +- bus: '00' + dev: '03' + fn: '0' + id: 6f08 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 3 (rev 03)' +- bus: '00' + dev: '03' + fn: '1' + id: 6f09 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 3 (rev 03)' +- bus: '00' + dev: '03' + fn: '2' + id: 6f0a + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 3 (rev 03)' +- bus: '00' + dev: '03' + fn: '3' + id: 6f0b + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 3 (rev 03)' +- bus: '00' + dev: '05' + fn: '0' + id: 6f28 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Map/VTd_Misc/System Management (rev 03)' +- bus: '00' + dev: '05' + fn: '1' + id: 6f29 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D IIO Hot Plug (rev 03)' +- bus: '00' + dev: '05' + fn: '2' + id: 6f2a + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D IIO RAS/Control Status/Global Errors (rev 03)' +- bus: '00' + dev: '05' + fn: '4' + id: 6f2c + name: 'PIC: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D I/O APIC (rev + 03)' +- bus: '00' + dev: '14' + fn: '0' + id: 8c31 + name: 'USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB + xHCI (rev 05)' +- bus: '00' + dev: '16' + fn: '0' + id: 8c3a + name: 'Communication controller: Intel Corporation 8 Series/C220 Series Chipset + Family MEI Controller #1 (rev 04)' +- bus: '00' + dev: '16' + fn: '1' + id: 8c3b + name: 'Communication controller: Intel Corporation 8 Series/C220 Series Chipset + Family MEI Controller #2 (rev 04)' +- bus: '00' + dev: 1c + fn: '0' + id: 8c10 + name: 'PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express + Root Port #1 (rev d5)' +- bus: '00' + dev: 1c + fn: '1' + id: 8c12 + name: 'PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express + Root Port #2 (rev d5)' +- bus: '00' + dev: 1d + fn: '0' + id: 8c26 + name: 'USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB + EHCI #1 (rev 05)' +- bus: '00' + dev: 1f + fn: '0' + id: 8c54 + name: 'ISA bridge: Intel Corporation C224 Series Chipset Family Server Standard + SKU LPC Controller (rev 05)' +- bus: '00' + dev: 1f + fn: '2' + id: 8c02 + name: 'SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port + SATA Controller 1 [AHCI mode] (rev 05)' +- bus: '00' + dev: 1f + fn: '3' + id: 8c22 + name: 'SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller + (rev 05)' +- bus: '03' + dev: '00' + fn: '0' + id: 6f50 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 0' +- bus: '03' + dev: '00' + fn: '1' + id: 6f51 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 1' +- bus: '03' + dev: '00' + fn: '2' + id: 6f52 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 2' +- bus: '03' + dev: '00' + fn: '3' + id: 6f53 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 3' +- bus: '05' + dev: '00' + fn: '0' + id: 15ab + name: 'Ethernet controller: Intel Corporation Ethernet Connection X552 10 GbE Backplane' +- bus: '05' + dev: '00' + fn: '1' + id: 15ab + name: 'Ethernet controller: Intel Corporation Ethernet Connection X552 10 GbE Backplane' +- bus: '07' + dev: '00' + fn: '0' + id: b873 + name: 'Ethernet controller: Broadcom Inc. and subsidiaries Device b873 (rev 01)' +- bus: 0b + dev: '00' + fn: '0' + id: 165f + name: 'Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme BCM5720 2-port + Gigabit Ethernet PCIe' +- bus: ff + dev: 0b + fn: '0' + id: 6f81 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link 0/1 (rev 03)' +- bus: ff + dev: 0b + fn: '1' + id: 6f36 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link 0/1 (rev 03)' +- bus: ff + dev: 0b + fn: '2' + id: 6f37 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link 0/1 (rev 03)' +- bus: ff + dev: 0b + fn: '3' + id: 6f76 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link Debug (rev 03)' +- bus: ff + dev: 0c + fn: '0' + id: 6fe0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0c + fn: '1' + id: 6fe1 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0c + fn: '2' + id: 6fe2 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0c + fn: '3' + id: 6fe3 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '0' + id: 6ff8 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '4' + id: 6ffc + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '5' + id: 6ffd + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '6' + id: 6ffe + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: '10' + fn: '0' + id: 6f1d + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R2PCIe Agent (rev 03)' +- bus: ff + dev: '10' + fn: '1' + id: 6f34 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R2PCIe Agent (rev 03)' +- bus: ff + dev: '10' + fn: '5' + id: 6f1e + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Ubox (rev 03)' +- bus: ff + dev: '10' + fn: '6' + id: 6f7d + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Ubox (rev 03)' +- bus: ff + dev: '10' + fn: '7' + id: 6f1f + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Ubox (rev 03)' +- bus: ff + dev: '12' + fn: '0' + id: 6fa0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Home Agent 0 (rev 03)' +- bus: ff + dev: '12' + fn: '1' + id: 6f30 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Home Agent 0 (rev 03)' +- bus: ff + dev: '13' + fn: '0' + id: 6fa8 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Target Address/Thermal/RAS (rev 03)' +- bus: ff + dev: '13' + fn: '1' + id: 6f71 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Target Address/Thermal/RAS (rev 03)' +- bus: ff + dev: '13' + fn: '2' + id: 6faa + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '3' + id: 6fab + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '4' + id: 6fac + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '5' + id: 6fad + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '6' + id: 6fae + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Broadcast (rev 03)' +- bus: ff + dev: '13' + fn: '7' + id: 6faf + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Global Broadcast (rev 03)' +- bus: ff + dev: '14' + fn: '0' + id: 6fb0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 0 Thermal Control (rev 03)' +- bus: ff + dev: '14' + fn: '1' + id: 6fb1 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 1 Thermal Control (rev 03)' +- bus: ff + dev: '14' + fn: '2' + id: 6fb2 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 0 Error (rev 03)' +- bus: ff + dev: '14' + fn: '3' + id: 6fb3 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 1 Error (rev 03)' +- bus: ff + dev: '14' + fn: '4' + id: 6fbc + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '14' + fn: '5' + id: 6fbd + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '14' + fn: '6' + id: 6fbe + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '14' + fn: '7' + id: 6fbf + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '15' + fn: '0' + id: 6fb4 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 2 Thermal Control (rev 03)' +- bus: ff + dev: '15' + fn: '1' + id: 6fb5 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 3 Thermal Control (rev 03)' +- bus: ff + dev: '15' + fn: '2' + id: 6fb6 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 2 Error (rev 03)' +- bus: ff + dev: '15' + fn: '3' + id: 6fb7 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 3 Error (rev 03)' +- bus: ff + dev: 1e + fn: '0' + id: 6f98 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '1' + id: 6f99 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '2' + id: 6f9a + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '3' + id: 6fc0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '4' + id: 6f9c + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1f + fn: '0' + id: 6f88 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1f + fn: '2' + id: 6f8a + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' diff --git a/device/accton/x86_64-accton_as7326_56x-r0/pddf/pd-plugin.json b/device/accton/x86_64-accton_as7326_56x-r0/pddf/pd-plugin.json index 317cf23b73..aacab4674f 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/pddf/pd-plugin.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/pddf/pd-plugin.json @@ -34,7 +34,7 @@ { "i2c": { - "valmap": { "F2B":"EXHAUST", "B2F":"INTAKE" } + "valmap": { "F2B":"exhaust", "B2F":"intake" } } }, @@ -47,7 +47,7 @@ { "i2c": { - "valmap": {"1":"INTAKE", "0":"EXHAUST"} + "valmap": {"1":"intake", "0":"exhaust"} } }, @@ -61,7 +61,7 @@ "duty_cycle_to_pwm": "lambda dc: ((dc*100)/625 -1)", - "pwm_to_duty_cycle": "lambda pwm: (((pwm+1)*625+75)/100)" + "pwm_to_duty_cycle": "lambda pwm: (((pwm+1)*625)/100)" } } diff --git a/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json b/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json index 857b4e1c4c..85d219c3bc 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json @@ -5,7 +5,7 @@ "num_fantrays":6, "num_fans_pertray":2, "num_ports":58, - "num_temps": 4, + "num_temps": 5, "pddf_dev_types": { "description":"AS7326-56X - Below is the list of supported PDDF device types (chip names) for various components. If any component uses some other driver, we will create the client using 'echo > /new_device' method", @@ -202,12 +202,14 @@ { "attr_name":"psu_present", "attr_devaddr":"0x60", "attr_devtype":"cpld", "attr_offset":"0x2", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, { "attr_name":"psu_power_good", "attr_devaddr":"0x60", "attr_devtype":"cpld", "attr_offset":"0x2", "attr_mask":"0x4", "attr_cmpval":"0x4", "attr_len":"1"}, { "attr_name":"psu_mfr_id", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0X99", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"10" }, - { "attr_name":"psu_fan_dir", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xc3", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"5"}, { "attr_name":"psu_v_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8b", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_i_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_p_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, - { "attr_name":"psu_temp1_input", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} + { "attr_name":"psu_temp1_input", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_min", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa4", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_max", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa5", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_temp1_high_threshold", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa8", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} ] } }, @@ -221,7 +223,8 @@ "attr_list": [ { "attr_name":"psu_model_name", "attr_devaddr":"0x53", "attr_devtype":"eeprom", "attr_offset":"0x15", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"11" }, - { "attr_name":"psu_serial_num", "attr_devaddr":"0x53", "attr_devtype":"eeprom", "attr_offset":"0x2e", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"17" } + { "attr_name":"psu_serial_num", "attr_devaddr":"0x53", "attr_devtype":"eeprom", "attr_offset":"0x2e", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"17" }, + { "attr_name":"psu_fan_dir", "attr_devaddr":"0x53", "attr_devtype":"eeprom", "attr_offset":"0xc3", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"5"} ] } @@ -251,12 +254,14 @@ { "attr_name":"psu_present", "attr_devaddr":"0x60", "attr_devtype":"cpld", "attr_offset":"0x2", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, { "attr_name":"psu_power_good", "attr_devaddr":"0x60", "attr_devtype":"cpld", "attr_offset":"0x2", "attr_mask":"0x8", "attr_cmpval":"0x8", "attr_len":"1"}, { "attr_name":"psu_mfr_id", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0X99", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"10" }, - { "attr_name":"psu_fan_dir", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0xc3", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"5"}, { "attr_name":"psu_v_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8b", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_i_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_p_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, - { "attr_name":"psu_temp1_input", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} + { "attr_name":"psu_temp1_input", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_min", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0xa4", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_max", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0xa5", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_temp1_high_threshold", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0xa8", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} ] } }, @@ -269,7 +274,8 @@ "attr_list": [ { "attr_name":"psu_model_name", "attr_devaddr":"0x51", "attr_devtype":"eeprom", "attr_offset":"0x15", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"11" }, - { "attr_name":"psu_serial_num", "attr_devaddr":"0x51", "attr_devtype":"eeprom", "attr_offset":"0x2e", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"17" } + { "attr_name":"psu_serial_num", "attr_devaddr":"0x51", "attr_devtype":"eeprom", "attr_offset":"0x2e", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"17" }, + { "attr_name":"psu_fan_dir", "attr_devaddr":"0x51", "attr_devtype":"eeprom", "attr_offset":"0xc3", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"5"} ] } }, @@ -360,6 +366,22 @@ ] } }, + "TEMP5" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP5"}, + "dev_attr": { "display_name":"coretemp-isa-0000"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon0"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp1_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_input"} + ] + } + }, + "FAN-CTRL": { "dev_info": { "device_type":"FAN", "device_name":"FAN-CTRL", "device_parent":"MUX2"}, @@ -2911,36 +2933,36 @@ "LOC_LED": { "dev_info": { "device_type":"LED", "device_name":"LOC_LED"}, - "dev_attr": { "index":"0"}, + "dev_attr": { "index":"0", "flag": "rw"}, "i2c" : { "attr_list": [ - {"attr_name":"STATUS_LED_COLOR_BLUE_BLINK", "descr": "" , "bits" : "5:0", "value" : "0x27", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, - {"attr_name":"STATUS_LED_COLOR_GREEN_BLINK", "descr": "" , "bits" : "5:0", "value" : "0x17", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, - {"attr_name":"STATUS_LED_COLOR_AMBER_BLINK", "descr": "" , "bits" : "5:0", "value" : "0xf", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, - {"attr_name":"STATUS_LED_COLOR_BLUE", "descr": "" , "bits" : "5:0", "value" : "0x3", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, - {"attr_name":"STATUS_LED_COLOR_GREEN", "descr": "" , "bits" : "5:0", "value" : "0x5", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, - {"attr_name":"STATUS_LED_COLOR_AMBER", "descr": "" , "bits" : "5:0", "value" : "0x6", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, - {"attr_name":"STATUS_LED_COLOR_OFF", "descr": "" , "bits" : "5:0", "value" : "0xf", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"} + {"attr_name":"blue_blink", "descr": "" , "bits" : "5:0", "value" : "0x27", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, + {"attr_name":"green_blink", "descr": "" , "bits" : "5:0", "value" : "0x17", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, + {"attr_name":"amber_blink", "descr": "" , "bits" : "5:0", "value" : "0xf", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, + {"attr_name":"blue", "descr": "" , "bits" : "5:0", "value" : "0x3", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, + {"attr_name":"green", "descr": "" , "bits" : "5:0", "value" : "0x5", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, + {"attr_name":"amber", "descr": "" , "bits" : "5:0", "value" : "0x6", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, + {"attr_name":"off", "descr": "" , "bits" : "5:0", "value" : "0xf", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"} ] } }, "DIAG_LED": { "dev_info": { "device_type":"LED", "device_name":"DIAG_LED"}, - "dev_attr": { "index":"0"}, + "dev_attr": { "index":"0", "flag": "rw"}, "i2c" : { "attr_list": [ - {"attr_name":"STATUS_LED_COLOR_BLUE_BLINK", "descr": "" , "bits" : "5:0", "value" : "0x27", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, - {"attr_name":"STATUS_LED_COLOR_GREEN_BLINK", "descr": "" , "bits" : "5:0", "value" : "0x17", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, - {"attr_name":"STATUS_LED_COLOR_AMBER_BLINK", "descr": "" , "bits" : "5:0", "value" : "0xf", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, - {"attr_name":"STATUS_LED_COLOR_BLUE", "descr": "" , "bits" : "5:0", "value" : "0x3", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, - {"attr_name":"STATUS_LED_COLOR_GREEN", "descr": "" , "bits" : "5:0", "value" : "0x5", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, - {"attr_name":"STATUS_LED_COLOR_AMBER", "descr": "" , "bits" : "5:0", "value" : "0x6", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, - {"attr_name":"STATUS_LED_COLOR_OFF", "descr": "" , "bits" : "5:0", "value" : "0x7", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"} + {"attr_name":"blue_blink", "descr": "" , "bits" : "5:0", "value" : "0x27", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, + {"attr_name":"green_blink", "descr": "" , "bits" : "5:0", "value" : "0x17", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, + {"attr_name":"amber_blink", "descr": "" , "bits" : "5:0", "value" : "0xf", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, + {"attr_name":"blue", "descr": "" , "bits" : "5:0", "value" : "0x3", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, + {"attr_name":"green", "descr": "" , "bits" : "5:0", "value" : "0x5", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, + {"attr_name":"amber", "descr": "" , "bits" : "5:0", "value" : "0x6", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, + {"attr_name":"off", "descr": "" , "bits" : "5:0", "value" : "0x7", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"} ] } diff --git a/device/accton/x86_64-accton_as7326_56x-r0/platform.json b/device/accton/x86_64-accton_as7326_56x-r0/platform.json new file mode 100644 index 0000000000..99dd8305c2 --- /dev/null +++ b/device/accton/x86_64-accton_as7326_56x-r0/platform.json @@ -0,0 +1,961 @@ +{ + "chassis": { + "name": "7326-56X", + "thermal_manager":false, + "components": [ + { + "name": "MB_CPLD1" + }, + { + "name": "MB_CPLD2" + }, + { + "name": "MB_CPLD3" + }, + { + "name": "FAN_CPLD" + }, + { + "name": "CPU_CPLD" + }, + { + "name": "BIOS" + } + ], + "fans": [ + { + "name": "FAN-1F", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-1R", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-2F", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-2R", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-3F", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-3R", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-4F", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-4R", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-5F", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-5R", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-6F", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-6R", + "speed": { + "controllable": true, + "minimum": 32 + } + } + ], + "fan_drawers":[ + { + "name": "FanTray1", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-1F", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-1R", + "speed": { + "controllable": true, + "minimum": 32 + } + } + ] + }, + { + "name": "FanTray2", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-2F", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-2R", + "speed": { + "controllable": true, + "minimum": 32 + } + } + ] + }, + { + "name": "FanTray3", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-3F", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-3R", + "speed": { + "controllable": true, + "minimum": 32 + } + } + ] + }, + { + "name": "FanTray4", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-4F", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-4R", + "speed": { + "controllable": true, + "minimum": 32 + } + } + ] + }, + { + "name": "FanTray5", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-5F", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-5R", + "speed": { + "controllable": true, + "minimum": 32 + } + } + ] + }, + { + "name": "FanTray6", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-6F", + "speed": { + "controllable": true, + "minimum": 32 + } + }, + { + "name": "FAN-6R", + "speed": { + "controllable": true, + "minimum": 32 + } + } + ] + } + ], + "psus": [ + { + "name": "PSU-1", + "fans": [ + { + "name": "PSU-1 FAN-1" + } + ], + "thermals": [ + { + "name": "PSU-1 temp sensor 1", + "controllable": false, + "low-threshold": false, + "high-threshold": false, + "low-crit-threshold": false, + "high-crit-threshold": false + } + ], + "temperature": true, + "temperature_high_threshold": true + }, + { + "name": "PSU-2", + "fans": [ + { + "name": "PSU-2 FAN-1" + } + ], + "thermals": [ + { + "name": "PSU-2 temp sensor 1", + "controllable": false, + "low-threshold": false, + "high-threshold": false, + "low-crit-threshold": false, + "high-crit-threshold": false + } + ], + "temperature": true, + "temperature_high_threshold": true + } + ], + "thermals": [ + { + "name": "CB_temp(0x4B)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false + }, + { + "name": "MB_FrontMAC_temp(0x49)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false + }, + { + "name": "MB_LeftCenter_temp(0x4A)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false + }, + { + "name": "MB_RearMAC_temp(0x48)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false + }, + { + "name": "coretemp-isa-0000", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + } + ], + "sfps": [ + { + "name": "Ethernet0" + }, + { + "name": "Ethernet1" + }, + { + "name": "Ethernet2" + }, + { + "name": "Ethernet3" + }, + { + "name": "Ethernet4" + }, + { + "name": "Ethernet5" + }, + { + "name": "Ethernet6" + }, + { + "name": "Ethernet7" + }, + { + "name": "Ethernet8" + }, + { + "name": "Ethernet9" + }, + { + "name": "Ethernet10" + }, + { + "name": "Ethernet11" + }, + { + "name": "Ethernet12" + }, + { + "name": "Ethernet13" + }, + { + "name": "Ethernet14" + }, + { + "name": "Ethernet15" + }, + { + "name": "Ethernet16" + }, + { + "name": "Ethernet17" + }, + { + "name": "Ethernet18" + }, + { + "name": "Ethernet19" + }, + { + "name": "Ethernet20" + }, + { + "name": "Ethernet21" + }, + { + "name": "Ethernet22" + }, + { + "name": "Ethernet23" + }, + { + "name": "Ethernet24" + }, + { + "name": "Ethernet25" + }, + { + "name": "Ethernet26" + }, + { + "name": "Ethernet27" + }, + { + "name": "Ethernet28" + }, + { + "name": "Ethernet29" + }, + { + "name": "Ethernet30" + }, + { + "name": "Ethernet31" + }, + { + "name": "Ethernet32" + }, + { + "name": "Ethernet33" + }, + { + "name": "Ethernet34" + }, + { + "name": "Ethernet35" + }, + { + "name": "Ethernet36" + }, + { + "name": "Ethernet37" + }, + { + "name": "Ethernet38" + }, + { + "name": "Ethernet39" + }, + { + "name": "Ethernet40" + }, + { + "name": "Ethernet41" + }, + { + "name": "Ethernet42" + }, + { + "name": "Ethernet43" + }, + { + "name": "Ethernet44" + }, + { + "name": "Ethernet45" + }, + { + "name": "Ethernet46" + }, + { + "name": "Ethernet47" + }, + { + "name": "Ethernet48" + }, + { + "name": "Ethernet52" + }, + { + "name": "Ethernet56" + }, + { + "name": "Ethernet60" + }, + { + "name": "Ethernet64" + }, + { + "name": "Ethernet68" + }, + { + "name": "Ethernet72" + }, + { + "name": "Ethernet76" + } + ] + }, + "interfaces": { + "Ethernet0": { + "index": "1", + "lanes": "3", + "breakout_modes": { + "1x25G": ["Eth1(Port1)"] + } + }, + + "Ethernet1": { + "index": "2", + "lanes": "2", + "breakout_modes": { + "1x25G": ["Eth2(Port2)"] + } + }, + + "Ethernet2": { + "index": "3", + "lanes": "4", + "breakout_modes": { + "1x25G": ["Eth3(Port3)"] + } + }, + + "Ethernet3": { + "index": "4", + "lanes": "8", + "breakout_modes": { + "1x25G": ["Eth4(Port4)"] + } + }, + + "Ethernet4": { + "index": "5", + "lanes": "7", + "breakout_modes": { + "1x25G": ["Eth5(Port5)"] + } + }, + + "Ethernet5": { + "index": "6", + "lanes": "1", + "breakout_modes": { + "1x25G": ["Eth6(Port6)"] + } + }, + + "Ethernet6": { + "index": "7", + "lanes": "5", + "breakout_modes": { + "1x25G": ["Eth7(Port7)"] + } + }, + + "Ethernet7": { + "index": "8", + "lanes": "16", + "breakout_modes": { + "1x25G": ["Eth8(Port8)"] + } + }, + + "Ethernet8": { + "index": "9", + "lanes": "6", + "breakout_modes": { + "1x25G": ["Eth9(Port9)"] + } + }, + + "Ethernet9": { + "index": "10", + "lanes": "14", + "breakout_modes": { + "1x25G": ["Eth10(Port10)"] + } + }, + + "Ethernet10": { + "index": "11", + "lanes": "13", + "breakout_modes": { + "1x25G": ["Eth11(Port11)"] + } + }, + + "Ethernet11": { + "index": "12", + "lanes": "15", + "breakout_modes": { + "1x25G": ["Eth12(Port12)"] + } + }, + + "Ethernet12": { + "index": "13", + "lanes": "23", + "breakout_modes": { + "1x25G": ["Eth13(Port13)"] + } + }, + + "Ethernet13": { + "index": "14", + "lanes": "22", + "breakout_modes": { + "1x25G": ["Eth14(Port14)"] + } + }, + + "Ethernet14": { + "index": "15", + "lanes": "24", + "breakout_modes": { + "1x25G": ["Eth15(Port15)"] + } + }, + + "Ethernet15": { + "index": "16", + "lanes": "32", + "breakout_modes": { + "1x25G": ["Eth16(Port16)"] + } + }, + + "Ethernet16": { + "index": "17", + "lanes": "31", + "breakout_modes": { + "1x25G": ["Eth17(Port17)"] + } + }, + + "Ethernet17": { + "index": "18", + "lanes": "21", + "breakout_modes": { + "1x25G": ["Eth18(Port18)"] + } + }, + + "Ethernet18": { + "index": "19", + "lanes": "29", + "breakout_modes": { + "1x25G": ["Eth19(Port19)"] + } + }, + + "Ethernet19": { + "index": "20", + "lanes": "36", + "breakout_modes": { + "1x25G": ["Eth20(Port20)"] + } + }, + + "Ethernet20": { + "index": "21", + "lanes": "30", + "breakout_modes": { + "1x25G": ["Eth21(Port21)"] + } + }, + + "Ethernet21": { + "index": "22", + "lanes": "34", + "breakout_modes": { + "1x25G": ["Eth22(Port22)"] + } + }, + + "Ethernet22": { + "index": "23", + "lanes": "33", + "breakout_modes": { + "1x25G": ["Eth23(Port23)"] + } + }, + + "Ethernet23": { + "index": "24", + "lanes": "35", + "breakout_modes": { + "1x25G": ["Eth24(Port24)"] + } + }, + + "Ethernet24": { + "index": "25", + "lanes": "43", + "breakout_modes": { + "1x25G": ["Eth25(Port25)"] + } + }, + + "Ethernet25": { + "index": "26", + "lanes": "42", + "breakout_modes": { + "1x25G": ["Eth26(Port26)"] + } + }, + + "Ethernet26": { + "index": "27", + "lanes": "44", + "breakout_modes": { + "1x25G": ["Eth27(Port27)"] + } + }, + + "Ethernet27": { + "index": "28", + "lanes": "52", + "breakout_modes": { + "1x25G": ["Eth28(Port28)"] + } + }, + + "Ethernet28": { + "index": "29", + "lanes": "51", + "breakout_modes": { + "1x25G": ["Eth29(Port29)"] + } + }, + + "Ethernet29": { + "index": "30", + "lanes": "41", + "breakout_modes": { + "1x25G": ["Eth30(Port30)"] + } + }, + + "Ethernet30": { + "index": "31", + "lanes": "49", + "breakout_modes": { + "1x25G": ["Eth31(Port31)"] + } + }, + + "Ethernet31": { + "index": "32", + "lanes": "60", + "breakout_modes": { + "1x25G": ["Eth32(Port32)"] + } + }, + + "Ethernet32": { + "index": "33", + "lanes": "50", + "breakout_modes": { + "1x25G": ["Eth33(Port33)"] + } + }, + + "Ethernet33": { + "index": "34", + "lanes": "58", + "breakout_modes": { + "1x25G": ["Eth34(Port34)"] + } + }, + + "Ethernet34": { + "index": "35", + "lanes": "57", + "breakout_modes": { + "1x25G": ["Eth35(Port35)"] + } + }, + + "Ethernet35": { + "index": "36", + "lanes": "59", + "breakout_modes": { + "1x25G": ["Eth36(Port36)"] + } + }, + + "Ethernet36": { + "index": "37", + "lanes": "62", + "breakout_modes": { + "1x25G": ["Eth37(Port37)"] + } + }, + + "Ethernet37": { + "index": "38", + "lanes": "63", + "breakout_modes": { + "1x25G": ["Eth38(Port38)"] + } + }, + + "Ethernet38": { + "index": "39", + "lanes": "64", + "breakout_modes": { + "1x25G": ["Eth39(Port39)"] + } + }, + + "Ethernet39": { + "index": "40", + "lanes": "65", + "breakout_modes": { + "1x25G": ["Eth40(Port40)"] + } + }, + + "Ethernet40": { + "index": "41", + "lanes": "66", + "breakout_modes": { + "1x25G": ["Eth41(Port41)"] + } + }, + + "Ethernet41": { + "index": "42", + "lanes": "61", + "breakout_modes": { + "1x25G": ["Eth42(Port42)"] + } + }, + + "Ethernet42": { + "index": "43", + "lanes": "68", + "breakout_modes": { + "1x25G": ["Eth43(Port43)"] + } + }, + + "Ethernet43": { + "index": "44", + "lanes": "69", + "breakout_modes": { + "1x25G": ["Eth44(Port44)"] + } + }, + + "Ethernet44": { + "index": "45", + "lanes": "67", + "breakout_modes": { + "1x25G": ["Eth45(Port45)"] + } + }, + + "Ethernet45": { + "index": "46", + "lanes": "71", + "breakout_modes": { + "1x25G": ["Eth46(Port46)"] + } + }, + + "Ethernet46": { + "index": "47", + "lanes": "72", + "breakout_modes": { + "1x25G": ["Eth47(Port47)"] + } + }, + + "Ethernet47": { + "index": "48", + "lanes": "70", + "breakout_modes": { + "1x25G": ["Eth48(Port48)"] + } + }, + + "Ethernet48": { + "index": "49,49,49,49", + "lanes": "77,78,79,80", + "breakout_modes": { + "1x100G[40G]": ["Eth49(Port49)"], + "2x50G": ["Eth49/1(Port49)", "Eth49/2(Port49)"], + "4x25G": ["Eth49/1(Port49)", "Eth49/2(Port49)", "Eth49/3(Port49)", "Eth49/4(Port49)"], + "4x10G": ["Eth49/1(Port49)", "Eth49/2(Port49)", "Eth49/3(Port49)", "Eth49/4(Port49)"] + } + }, + + "Ethernet52": { + "index": "50,50,50,50", + "lanes": "85,86,87,88", + "breakout_modes": { + "1x100G[40G]": ["Eth50(Port50)"], + "2x50G": ["Eth50/1(Port50)", "Eth50/2(Port50)"], + "4x25G": ["Eth50/1(Port50)", "Eth50/2(Port50)", "Eth50/3(Port50)", "Eth50/4(Port50)"], + "4x10G": ["Eth50/1(Port50)", "Eth50/2(Port50)", "Eth50/3(Port50)", "Eth50/4(Port50)"] + } + }, + + "Ethernet56": { + "index": "51,51,51,51", + "lanes": "93,94,95,96", + "breakout_modes": { + "1x100G[40G]": ["Eth51(Port51)"], + "2x50G": ["Eth51/1(Port51)", "Eth51/2(Port51)"], + "4x25G": ["Eth51/1(Port51)", "Eth51/2(Port51)", "Eth51/3(Port51)", "Eth51/4(Port51)"], + "4x10G": ["Eth51/1(Port51)", "Eth51/2(Port51)", "Eth51/3(Port51)", "Eth51/4(Port51)"] + } + }, + + "Ethernet60": { + "index": "52,52,52,52", + "lanes": "97,98,99,100", + "breakout_modes": { + "1x100G[40G]": ["Eth52(Port52)"], + "2x50G": ["Eth52/1(Port52)", "Eth52/2(Port52)"], + "4x25G": ["Eth52/1(Port52)", "Eth52/2(Port52)", "Eth52/3(Port52)", "Eth52/4(Port52)"], + "4x10G": ["Eth52/1(Port52)", "Eth52/2(Port52)", "Eth52/3(Port52)", "Eth52/4(Port52)"] + } + }, + + "Ethernet64": { + "index": "53,53,53,53", + "lanes": "105,106,107,108", + "breakout_modes": { + "1x100G[40G]": ["Eth53(Port53)"], + "2x50G": ["Eth53/1(Port53)", "Eth53/2(Port53)"], + "4x25G": ["Eth53/1(Port53)", "Eth53/2(Port53)", "Eth53/3(Port53)", "Eth53/4(Port53)"], + "4x10G": ["Eth53/1(Port53)", "Eth53/2(Port53)", "Eth53/3(Port53)", "Eth53/4(Port53)"] + } + }, + + "Ethernet68": { + "index": "54,54,54,54", + "lanes": "113,114,115,116", + "breakout_modes": { + "1x100G[40G]": ["Eth54(Port54)"], + "2x50G": ["Eth54/1(Port54)", "Eth54/2(Port54)"], + "4x25G": ["Eth54/1(Port54)", "Eth54/2(Port54)", "Eth54/3(Port54)", "Eth54/4(Port54)"], + "4x10G": ["Eth54/1(Port54)", "Eth54/2(Port54)", "Eth54/3(Port54)", "Eth54/4(Port54)"] + } + }, + + "Ethernet72": { + "index": "55,55,55,55", + "lanes": "121,122,123,124", + "breakout_modes": { + "1x100G[40G]": ["Eth55(Port55)"], + "2x50G": ["Eth55/1(Port55)", "Eth55/2(Port55)"], + "4x25G": ["Eth55/1(Port55)", "Eth55/2(Port55)", "Eth55/3(Port55)", "Eth55/4(Port55)"], + "4x10G": ["Eth55/1(Port55)", "Eth55/2(Port55)", "Eth55/3(Port55)", "Eth55/4(Port55)"] + } + }, + + "Ethernet76": { + "index": "56,56,56,56", + "lanes": "125,126,127,128", + "breakout_modes": { + "1x100G[40G]": ["Eth56(Port56)"], + "2x50G": ["Eth56/1(Port56)", "Eth56/2(Port56)"], + "4x25G": ["Eth56/1(Port56)", "Eth56/2(Port56)", "Eth56/3(Port56)", "Eth56/4(Port56)"], + "4x10G": ["Eth56/1(Port56)", "Eth56/2(Port56)", "Eth56/3(Port56)", "Eth56/4(Port56)"] + } + } + } +} diff --git a/device/accton/x86_64-accton_as7326_56x-r0/platform_components.json b/device/accton/x86_64-accton_as7326_56x-r0/platform_components.json new file mode 100644 index 0000000000..c32d4ac00d --- /dev/null +++ b/device/accton/x86_64-accton_as7326_56x-r0/platform_components.json @@ -0,0 +1,14 @@ +{ + "chassis": { + "7326-56X-O-AC-F": { + "component": { + "MB_CPLD1": { }, + "MB_CPLD2": { }, + "MB_CPLD3": { }, + "FAN_CPLD": { }, + "CPU_CPLD": { }, + "BIOS": { } + } + } + } +} diff --git a/device/accton/x86_64-accton_as7326_56x-r0/plugins/sfputil.py b/device/accton/x86_64-accton_as7326_56x-r0/plugins/sfputil.py index 965e876691..26ddfca49e 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/plugins/sfputil.py +++ b/device/accton/x86_64-accton_as7326_56x-r0/plugins/sfputil.py @@ -4,6 +4,7 @@ # try: + import sys import time import string from ctypes import create_string_buffer @@ -205,7 +206,10 @@ def set_low_power_mode(self, port_num, lpmode): # Fill in write buffer regval = 0x3 if lpmode else 0x1 # 0x3:Low Power Mode, 0x1:High Power Mode buffer = create_string_buffer(1) - buffer[0] = chr(regval) + if sys.version_info[0] >= 3: + buffer[0] = regval + else: + buffer[0] = chr(regval) # Write to eeprom eeprom = open(self.port_to_eeprom_mapping[port_num], "r+b") @@ -220,6 +224,22 @@ def set_low_power_mode(self, port_num, lpmode): eeprom.close() time.sleep(0.01) + def __read_txt_file(self, file_path): + try: + with open(file_path, 'r') as fd: + return fd.read().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 Exception: + return False + return True + def reset(self, port_num): if port_num < self.qsfp_port_start or port_num > self.qsfp_port_end: return False @@ -228,21 +248,20 @@ def reset(self, port_num): cpld_ps = self._cpld_mapping[cpld_i] path = "/sys/bus/i2c/devices/{0}/module_reset_{1}" port_ps = path.format(cpld_ps, port_num) - self.__port_to_mod_rst = port_ps - try: - reg_file = open(self.__port_to_mod_rst, 'r+', buffering=0) - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False + + ret = self.__write_txt_file( + self.__port_to_mod_rst, 1) + if ret is not True: + return ret - # toggle reset - reg_file.seek(0) - reg_file.write('1') time.sleep(1) - reg_file.seek(0) - reg_file.write('0') - reg_file.close() + ret = self.__write_txt_file( + self.__port_to_mod_rst, 0) + + if ret is not True: + return ret + time.sleep(0.1) return True diff --git a/device/accton/x86_64-accton_as7326_56x-r0/plugins/ssd_util.py b/device/accton/x86_64-accton_as7326_56x-r0/plugins/ssd_util.py new file mode 100755 index 0000000000..4b173c5e38 --- /dev/null +++ b/device/accton/x86_64-accton_as7326_56x-r0/plugins/ssd_util.py @@ -0,0 +1,24 @@ +# ssd_util.py +# +# Platform-specific SSD interface for SONiC +## + +try: + from sonic_platform_base.sonic_ssd.ssd_generic import SsdUtil as MainSsdUtil +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +NOT_AVAILABLE = "N/A" + +class SsdUtil(MainSsdUtil): + """Platform-specific SsdUtil class""" + + def __init__(self, diskdev): + super(SsdUtil, self).__init__(diskdev) + + # If it has no vendor tool to read SSD information, + # ssd_util.py will use generic SSD information + # for vendor SSD information. + if self.vendor_ssd_info == NOT_AVAILABLE: + self.vendor_ssd_info = self.ssd_info + diff --git a/device/accton/x86_64-accton_as7326_56x-r0/pmon_daemon_control.json b/device/accton/x86_64-accton_as7326_56x-r0/pmon_daemon_control.json index a3b204e20d..44bad64942 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/pmon_daemon_control.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/pmon_daemon_control.json @@ -1,5 +1,4 @@ { - "skip_ledd": true, - "skip_pcied": true + "skip_ledd": true } diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/__init__.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/__init__.py deleted file mode 100644 index 73a7720e89..0000000000 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -__all__ = [ "platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal", "fan", "fan_drawer" ] -from . import platform diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/sfp.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/sfp.py deleted file mode 100644 index 16fe60bfb6..0000000000 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/sfp.py +++ /dev/null @@ -1,625 +0,0 @@ -############################################################################# -# Edgecore -# -# Sfp contains an implementation of SONiC Platform Base API and -# provides the sfp device status which are available in the platform -# -############################################################################# - -import time -import sys -import subprocess -from ctypes import create_string_buffer - -try: - from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase - from sonic_platform_base.sonic_sfp.sfputilhelper import SfpUtilHelper -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -CPLD_ADDR_MAPPING = { - 0: { - "bus": 18, - "addr": "60" - }, # port 31-56 - 1: { - "bus": 12, - "addr": "62" - }, # port 1-30 -} -CPLD_I2C_PATH = "/sys/bus/i2c/devices/{}-00{}/" - -class Sfp(SfpOptoeBase): - """Platform-specific Sfp class""" - - # Port number - PORT_START = 1 - PORT_END = 58 - - # Path to sysfs - PLATFORM_ROOT_PATH = "/usr/share/sonic/device" - PMON_HWSKU_PATH = "/usr/share/sonic/hwsku" - HOST_CHK_CMD = ["which", "systemctl"] - - PLATFORM = "x86_64-accton_as7326_56x-r0" - HWSKU = "Accton-AS7326-56X" - - _port_to_i2c_mapping = { - 1: [42], - 2: [41], - 3: [44], - 4: [43], - 5: [47], - 6: [45], - 7: [46], - 8: [50], - 9: [48], - 10: [49], - 11: [52], - 12: [51], - 13: [53], - 14: [56], - 15: [55], - 16: [54], - 17: [58], - 18: [57], - 19: [60], - 20: [59], - 21: [61], - 22: [63], - 23: [62], - 24: [64], - 25: [66], - 26: [68], - 27: [65], - 28: [67], - 29: [69], - 30: [71], - 31: [72], - 32: [70], - 33: [74], - 34: [73], - 35: [76], - 36: [75], - 37: [77], - 38: [79], - 39: [78], - 40: [80], - 41: [81], - 42: [82], - 43: [84], - 44: [85], - 45: [83], - 46: [87], - 47: [88], - 48: [86], - 49: [25], - 50: [26], - 51: [27], - 52: [28], - 53: [29], - 54: [30], - 55: [31], - 56: [32], - 57: [22], - 58: [23] - } - - def __init__(self, sfp_index=0): - SfpOptoeBase.__init__(self) - # Init index - self.index = sfp_index - self.port_num = self.index + 1 - - cpld_idx = 0 if self.port_num > 30 else 1 - bus = CPLD_ADDR_MAPPING[cpld_idx]["bus"] - addr = CPLD_ADDR_MAPPING[cpld_idx]["addr"] - self.cpld_path = CPLD_I2C_PATH.format(bus, addr) - - # Init eeprom path - eeprom_path = '/sys/bus/i2c/devices/{0}-0050/eeprom' - self.port_to_eeprom_mapping = {} - for x in range(self.PORT_START, self.PORT_END + 1): - self.port_to_eeprom_mapping[x] = eeprom_path.format( - self._port_to_i2c_mapping[x][0]) - - def get_eeprom_path(self): - return self.port_to_eeprom_mapping[self.port_num] - - def __read_txt_file(self, file_path): - try: - with open(file_path, 'r') as fd: - return fd.read().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 Exception: - return False - return True - - def __is_host(self): - return subprocess.call(self.HOST_CHK_CMD) == 0 - - def __get_path_to_port_config_file(self): - platform_path = "/".join([self.PLATFORM_ROOT_PATH, self.PLATFORM]) - hwsku_path = "/".join( - [platform_path, - self.HWSKU]) if self.__is_host() else self.PMON_HWSKU_PATH - return "/".join([hwsku_path, "port_config.ini"]) - - def __read_eeprom_specific_bytes(self, offset, num_bytes): - sysfsfile_eeprom = None - eeprom_raw = [] - for i in range(0, num_bytes): - eeprom_raw.append("0x00") - - sysfs_sfp_i2c_client_eeprom_path = self.port_to_eeprom_mapping[ - self.port_num] - try: - sysfsfile_eeprom = open( - sysfs_sfp_i2c_client_eeprom_path, mode="rb", buffering=0) - sysfsfile_eeprom.seek(offset) - raw = sysfsfile_eeprom.read(num_bytes) - for n in range(0, num_bytes): - if sys.version_info[0] >= 3: - eeprom_raw[n] = hex(raw[n])[2:].zfill(2) - else: - eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) - except Exception: - pass - finally: - if sysfsfile_eeprom: - sysfsfile_eeprom.close() - - return eeprom_raw - - def get_reset_status(self): - """ - Retrieves the reset status of SFP - Returns: - A Boolean, True if reset enabled, False if disabled - """ - if self.port_num <= 48 or self.port_num >=57: - return False # SPF port doesn't support this feature - - val = self.__read_txt_file( - self.cpld_path + "module_reset_" + str(self.port_num)) - return int(val, 10) == 1 - - def get_rx_los(self): - """ - Retrieves the RX LOS (lost-of-signal) status of SFP - Returns: - A Boolean, True if SFP has RX LOS, False if not. - Note : RX LOS status is latched until a call to get_rx_los or a reset. - """ - if self.port_num <= 48 or self.port_num >=57: - rx_los = self.__read_txt_file( - self.cpld_path + "module_rx_los_" + str(self.port_num)) - if int(rx_los, 10) == 1: - return [True] - else: - return [False] - #status_control_raw = self.__read_eeprom_specific_bytes( - # SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) - #if status_control_raw: - # data = int(status_control_raw[0], 16) - # rx_los = (sffbase().test_bit(data, 1) != 0) - else: - rx_los_list = [] - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( - QSFP_CHANNL_RX_LOS_STATUS_OFFSET, - QSFP_CHANNL_RX_LOS_STATUS_WIDTH) if self.get_presence( - ) else None - if dom_channel_monitor_raw is not None: - rx_los_data = int(dom_channel_monitor_raw[0], 16) - rx_los_list.append(rx_los_data & 0x01 != 0) - rx_los_list.append(rx_los_data & 0x02 != 0) - rx_los_list.append(rx_los_data & 0x04 != 0) - rx_los_list.append(rx_los_data & 0x08 != 0) - return rx_los_list - else: - return [False]*4 - - def get_tx_fault(self): - """ - Retrieves the TX fault status of SFP - - Returns: - A list of boolean values, representing the TX fault status - of each available channel, value is True if SFP channel - has TX fault, False if not. - E.g., for a tranceiver with four channels: [False, False, True, False] - Note : TX fault status is lached until a call to get_tx_fault or a reset. - """ - tx_fault = False - if self.port_num <= 48 or self.port_num >=57: - tx_fault = self.__read_txt_file( - self.cpld_path + "module_tx_fault_" + str(self.port_num)) - if int(tx_fault, 10) == 1: - return [True] - else: - return [False] - #status_control_raw = self.__read_eeprom_specific_bytes( - # SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) - #if status_control_raw: - # data = int(status_control_raw[0], 16) - # tx_fault = (sffbase().test_bit(data, 2) != 0) - else: - tx_fault_list = [] - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( - QSFP_CHANNL_TX_FAULT_STATUS_OFFSET, - QSFP_CHANNL_TX_FAULT_STATUS_WIDTH) if self.get_presence( - ) else None - if dom_channel_monitor_raw is not None: - tx_fault_data = int(dom_channel_monitor_raw[0], 16) - tx_fault_list.append(tx_fault_data & 0x01 != 0) - tx_fault_list.append(tx_fault_data & 0x02 != 0) - tx_fault_list.append(tx_fault_data & 0x04 != 0) - tx_fault_list.append(tx_fault_data & 0x08 != 0) - return tx_fault_list - else: - return [False]*4 - - - def get_tx_disable(self): - """ - Retrieves the tx_disable status of this SFP - Returns: - A list of boolean values, representing the TX disable status - of each available channel, value is True if SFP channel - is TX disabled, False if not. - E.g., for a tranceiver with four channels: [False, False, True, False] - """ - if self.port_num <= 48 or self.port_num >=57: - tx_disable = False - - status_control_raw = self.__read_eeprom_specific_bytes( - SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) - if status_control_raw: - cpld_val = self.__read_txt_file( - self.cpld_path + "module_tx_disable_" + str(self.port_num)) - tx_disable_hard = (int(cpld_val, 10) == 1) - data = int(status_control_raw[0], 16) - #tx_disable_hard = (sffbase().test_bit( - # data, SFP_TX_DISABLE_HARD_BIT) != 0) - tx_disable_soft = (sffbase().test_bit( - data, SFP_TX_DISABLE_SOFT_BIT) != 0) - tx_disable = tx_disable_hard | tx_disable_soft - if tx_disable==0: - return [False] - else: - return [True] - - else: - return [False] - - else: - tx_disable_list = [] - - sfpd_obj = sff8436Dom() - if sfpd_obj is None: - return [False] - - dom_control_raw = self.__read_eeprom_specific_bytes( - QSFP_CONTROL_OFFSET, - QSFP_CONTROL_WIDTH) if self.get_presence() else None - if dom_control_raw is not None: - dom_control_data = sfpd_obj.parse_control_bytes( - dom_control_raw, 0) - tx_disable_list.append( - 'On' == dom_control_data['data']['TX1Disable']['value']) - tx_disable_list.append( - 'On' == dom_control_data['data']['TX2Disable']['value']) - tx_disable_list.append( - 'On' == dom_control_data['data']['TX3Disable']['value']) - tx_disable_list.append( - 'On' == dom_control_data['data']['TX4Disable']['value']) - return tx_disable_list - else: - return [False]*4 - - def get_tx_disable_channel(self): - """ - Retrieves the TX disabled channels in this SFP - Returns: - A hex of 4 bits (bit 0 to bit 3 as channel 0 to channel 3) to represent - TX channels which have been disabled in this SFP. - As an example, a returned value of 0x5 indicates that channel 0 - and channel 2 have been disabled. - """ - tx_disable_list = self.get_tx_disable() - if tx_disable_list is None: - return 0 - tx_disabled = 0 - for i in range(len(tx_disable_list)): - if tx_disable_list[i]: - tx_disabled |= 1 << i - return tx_disabled - - def get_lpmode(self): - """ - Retrieves the lpmode (low power mode) status of this SFP - Returns: - A Boolean, True if lpmode is enabled, False if disabled - """ - if self.port_num <= 48 or self.port_num >= 57: - # SFP doesn't support this feature - return False - - power_set = self.get_power_set() - power_override = self.get_power_override() - return power_set and power_override - - def get_power_set(self): - - if self.port_num <= 48 or self.port_num >= 57: - # SFP doesn't support this feature - return False - else: - power_set = False - - sfpd_obj = sff8436Dom() - if sfpd_obj is None: - return False - - dom_control_raw = self.__read_eeprom_specific_bytes( - QSFP_CONTROL_OFFSET, - QSFP_CONTROL_WIDTH) if self.get_presence() else None - if dom_control_raw is not None: - dom_control_data = sfpd_obj.parse_control_bytes( - dom_control_raw, 0) - power_set = ( - 'On' == dom_control_data['data']['PowerSet']['value']) - - return power_set - - def get_power_override(self): - """ - Retrieves the power-override status of this SFP - Returns: - A Boolean, True if power-override is enabled, False if disabled - """ - if self.port_num <= 48 or self.port_num >= 57: - return False # SFP doesn't support this feature - else: - power_override = False - - sfpd_obj = sff8436Dom() - if sfpd_obj is None: - return False - - dom_control_raw = self.__read_eeprom_specific_bytes( - QSFP_CONTROL_OFFSET, - QSFP_CONTROL_WIDTH) if self.get_presence() else None - if dom_control_raw is not None: - dom_control_data = sfpd_obj.parse_control_bytes( - dom_control_raw, 0) - power_override = ( - 'On' == dom_control_data['data']['PowerOverride']['value']) - - return power_override - - def reset(self): - """ - Reset SFP and return all user module settings to their default srate. - Returns: - A boolean, True if successful, False if not - """ - # Check for invalid port_num - if self.port_num <= 48 or self.port_num >=57: - return False # SFP doesn't support this feature - - ret = self.__write_txt_file( - self.cpld_path + "module_reset_" + str(self.port_num), 1) - if ret is not True: - return ret - - time.sleep(0.01) - ret = self.__write_txt_file( - self.cpld_path + "module_reset_" + str(self.port_num), 0) - time.sleep(0.2) - return ret - - def tx_disable(self, tx_disable): - """ - Disable SFP TX for all channels - Args: - tx_disable : A Boolean, True to enable tx_disable mode, False to disable - tx_disable mode. - Returns: - A boolean, True if tx_disable is set successfully, False if not - """ - if self.port_num <= 48 or self.port_num >=57: - ret = self.__write_txt_file( - self.cpld_path + "module_tx_disable_" + str(self.port_num), 1 - if tx_disable else 0) - time.sleep(0.01) - return ret - else: - if not self.get_presence(): - return False - - sysfsfile_eeprom = None - try: - tx_disable_ctl = 0xf if tx_disable else 0x0 - buffer = create_string_buffer(1) - if sys.version_info[0] >= 3: - buffer[0] = tx_disable_ctl - else: - buffer[0] = chr(tx_disable_ctl) - # Write to eeprom - sysfsfile_eeprom = open( - self.port_to_eeprom_mapping[self.port_num], "r+b") - sysfsfile_eeprom.seek(QSFP_CONTROL_OFFSET) - sysfsfile_eeprom.write(buffer[0]) - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - finally: - if sysfsfile_eeprom is not None: - sysfsfile_eeprom.close() - time.sleep(0.01) - return True - - def tx_disable_channel(self, channel, disable): - """ - Sets the tx_disable for specified SFP channels - Args: - channel : A hex of 4 bits (bit 0 to bit 3) which represent channel 0 to 3, - e.g. 0x5 for channel 0 and channel 2. - disable : A boolean, True to disable TX channels specified in channel, - False to enable - Returns: - A boolean, True if successful, False if not - """ - - if self.port_num <= 48 or self.port_num >=57: - return False # SFP doesn't support this feature - else: - if not self.get_presence(): - return False - - sysfsfile_eeprom = None - try: - channel_state = self.get_tx_disable_channel() - - for i in range(4): - channel_mask = (1 << i) - if not (channel & channel_mask): - continue - - if disable: - channel_state |= channel_mask - else: - channel_state &= ~channel_mask - - buffer = create_string_buffer(1) - if sys.version_info[0] >= 3: - buffer[0] = channel_state - else: - buffer[0] = chr(channel_state) - # Write to eeprom - sysfsfile_eeprom = open( - self.port_to_eeprom_mapping[self.port_num], "r+b") - sysfsfile_eeprom.seek(QSFP_CONTROL_OFFSET) - sysfsfile_eeprom.write(buffer[0]) - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - finally: - if sysfsfile_eeprom is not None: - sysfsfile_eeprom.close() - time.sleep(0.01) - return True - - def set_lpmode(self, lpmode): - """ - Sets the lpmode (low power mode) of SFP - Args: - lpmode: A Boolean, True to enable lpmode, False to disable it - Note : lpmode can be overridden by set_power_override - Returns: - A boolean, True if lpmode is set successfully, False if not - """ - if self.port_num <= 48 or self.port_num >=57: - return False # SFP doesn't support this feature - - if lpmode: - return self.set_power_override(True, True) - else: - return self.set_power_override(True, False) - - def set_power_override(self, power_override, power_set): - """ - Sets SFP power level using power_override and power_set - Args: - power_override : - A Boolean, True to override set_lpmode and use power_set - to control SFP power, False to disable SFP power control - through power_override/power_set and use set_lpmode - to control SFP power. - power_set : - Only valid when power_override is True. - A Boolean, True to set SFP to low power mode, False to set - SFP to high power mode. - Returns: - A boolean, True if power-override and power_set are set successfully, - False if not - """ - if self.port_num <= 48 or self.port_num >=57: - return False # SFP doesn't support this feature - else: - if not self.get_presence(): - return False - try: - power_override_bit = (1 << 0) if power_override else 0 - power_set_bit = (1 << 1) if power_set else (1 << 3) - - buffer = create_string_buffer(1) - if sys.version_info[0] >= 3: - buffer[0] = (power_override_bit | power_set_bit) - else: - buffer[0] = chr(power_override_bit | power_set_bit) - # Write to eeprom - with open(self.port_to_eeprom_mapping[self.port_num], - "r+b") as fd: - fd.seek(QSFP_POWEROVERRIDE_OFFSET) - fd.write(buffer[0]) - time.sleep(0.01) - except Exception: - print("Error: unable to open file: %s" % str(e)) - return False - return True - - def get_name(self): - """ - Retrieves the name of the device - Returns: - string: The name of the device - """ - sfputil_helper = SfpUtilHelper() - sfputil_helper.read_porttab_mappings( - self.__get_path_to_port_config_file()) - name = sfputil_helper.logical[self.index] or "Unknown" - return name - - def get_presence(self): - """ - Retrieves the presence of the device - Returns: - bool: True if device is present, False if not - """ - val = self.__read_txt_file( - self.cpld_path + "module_present_" + str(self.port_num)) - return val == '1' - - def get_status(self): - """ - Retrieves the operational status of the device - Returns: - A boolean value, True if device is operating properly, False if not - """ - return self.get_presence() - - def get_position_in_parent(self): - """ - Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position - for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned - Returns: - integer: The 1-based relative physical position in parent device or -1 if cannot determine the position - """ - return self.port_num - - def is_replaceable(self): - """ - Indicate whether this device is replaceable. - Returns: - bool: True if it is replaceable. - """ - return True diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/thermal.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/thermal.py deleted file mode 100644 index b2233e7b5a..0000000000 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/thermal.py +++ /dev/null @@ -1,232 +0,0 @@ -############################################################################# -# Edgecore -# -# Thermal contains an implementation of SONiC Platform Base API and -# provides the thermal device status which are available in the platform -# -############################################################################# - -import os -import os.path -import glob - -try: - from sonic_platform_base.thermal_base import ThermalBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -PSU_I2C_PATH = "/sys/bus/i2c/devices/{}-00{}/" -PSU_HWMON_I2C_MAPPING = { - 0: { - "bus": 17, - "addr": "59" - }, - 1: { - "bus": 13, - "addr": "5b" - }, -} - -PSU_CPLD_I2C_MAPPING = { - 0: { - "bus": 17, - "addr": "51" - }, - 1: { - "bus": 13, - "addr": "53" - }, -} - - -class Thermal(ThermalBase): - """Platform-specific Thermal class""" - - THERMAL_NAME_LIST = [] - PSU_THERMAL_NAME_LIST = [] - SYSFS_PATH = "/sys/bus/i2c/devices" - - def __init__(self, thermal_index=0, is_psu=False, psu_index=0): - self.index = thermal_index - self.is_psu = is_psu - self.psu_index = psu_index - - if self.is_psu: - psu_i2c_bus = PSU_HWMON_I2C_MAPPING[psu_index]["bus"] - psu_i2c_addr = PSU_HWMON_I2C_MAPPING[psu_index]["addr"] - self.psu_hwmon_path = PSU_I2C_PATH.format(psu_i2c_bus, - psu_i2c_addr) - psu_i2c_bus = PSU_CPLD_I2C_MAPPING[psu_index]["bus"] - psu_i2c_addr = PSU_CPLD_I2C_MAPPING[psu_index]["addr"] - self.cpld_path = PSU_I2C_PATH.format(psu_i2c_bus, psu_i2c_addr) - - # Add thermal name - self.THERMAL_NAME_LIST.append("Temp sensor 1") - self.THERMAL_NAME_LIST.append("Temp sensor 2") - self.THERMAL_NAME_LIST.append("Temp sensor 3") - self.THERMAL_NAME_LIST.append("Temp sensor 4") - self.PSU_THERMAL_NAME_LIST.append("PSU-1 temp sensor 1") - self.PSU_THERMAL_NAME_LIST.append("PSU-2 temp sensor 1") - - # Set hwmon path - i2c_path = { - 0: "15-0048/hwmon/hwmon*/", - 1: "15-0049/hwmon/hwmon*/", - 2: "15-004a/hwmon/hwmon*/", - 3: "15-004b/hwmon/hwmon*/" - }.get(self.index, None) - - self.hwmon_path = "{}/{}".format(self.SYSFS_PATH, i2c_path) - self.ss_key = self.THERMAL_NAME_LIST[self.index] - self.ss_index = 1 - - def __read_txt_file(self, file_path): - for filename in glob.glob(file_path): - try: - with open(filename, 'r') as fd: - return fd.readline().rstrip() - except IOError as e: - pass - - def __get_temp(self, temp_file): - if not self.is_psu: - temp_file_path = os.path.join(self.hwmon_path, temp_file) - else: - temp_file_path = temp_file - - raw_temp = self.__read_txt_file(temp_file_path) - return float(raw_temp) / 1000 - - def __set_threshold(self, file_name, temperature): - if self.is_psu: - return True - - 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 - """ - if not self.is_psu: - temp_file = "temp{}_input".format(self.ss_index) - else: - temp_file = self.psu_hwmon_path + "psu_temp1_input" - - 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 - """ - if self.is_psu: - return 0 - - temp_file = "temp{}_max".format(self.ss_index) - return self.__get_temp(temp_file) - - def set_high_threshold(self, temperature): - """ - Sets the high threshold temperature of thermal - Args : - temperature: A float number up to nearest thousandth of one degree Celsius, - e.g. 30.125 - Returns: - A boolean, True if threshold is set successfully, False if not - """ - temp_file = "temp{}_max".format(self.ss_index) - temperature = temperature *1000 - self.__set_threshold(temp_file, temperature) - - return True - - def get_name(self): - """ - Retrieves the name of the thermal device - Returns: - string: The name of the thermal device - """ - if self.is_psu: - return self.PSU_THERMAL_NAME_LIST[self.psu_index] - else: - 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 - """ - if self.is_psu: - val = self.__read_txt_file(self.cpld_path + "psu_present") - return int(val, 10) == 1 - - temp_file = "temp{}_input".format(self.ss_index) - temp_file_path = os.path.join(self.hwmon_path, temp_file) - raw_txt = self.__read_txt_file(temp_file_path) - return raw_txt != None - - 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 self.is_psu: - temp_file = self.psu_hwmon_path + "psu_temp_fault" - return self.get_presence() and (not int( - self.__read_txt_file(temp_file))) - - file_str = "temp{}_input".format(self.ss_index) - file_path = os.path.join(self.hwmon_path, file_str) - - raw_txt = self.__read_txt_file(file_path) - if raw_txt is None: - return False - else: - return int(raw_txt) != 0 - - def get_model(self): - """ - Retrieves the model number (or part number) of the device - Returns: - string: Model/part number of device - """ - - return "N/A" - - def get_serial(self): - """ - Retrieves the serial number of the device - Returns: - string: Serial number of device - """ - return "N/A" - - def get_position_in_parent(self): - """ - Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position - for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned - Returns: - integer: The 1-based relative physical position in parent device or -1 if cannot determine the position - """ - return self.index+1 - - def is_replaceable(self): - """ - Retrieves whether thermal module is replaceable - Returns: - A boolean value, True if replaceable, False if not - """ - return False diff --git a/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json b/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json index 18d47b22a9..5aacf0c3bb 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json @@ -2,14 +2,14 @@ "services_to_ignore": [], "devices_to_ignore": [ "asic", + "psu.voltage", "psu.temperature" - ], "user_defined_checkers": [], "polling_interval": 60, "led_color": { - "fault": "STATUS_LED_COLOR_RED", - "normal": "STATUS_LED_COLOR_GREEN", - "booting": "STATUS_LED_COLOR_GREEN_BLINK" + "fault": "red", + "normal": "green", + "booting": "green_blink" } } diff --git a/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/hwsku.json b/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/hwsku.json new file mode 100644 index 0000000000..5a86530164 --- /dev/null +++ b/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/hwsku.json @@ -0,0 +1,132 @@ +{ + "interfaces": { + "Ethernet0": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet4": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet8": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet12": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet16": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet20": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet24": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet28": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet32": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet36": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet40": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet44": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet48": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet52": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet56": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet60": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet64": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet68": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet72": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet76": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet80": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet84": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet88": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet92": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet96": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet100": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet104": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet108": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet112": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet116": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet120": { + "default_brkout_mode": "1x100G[40G]" + }, + + "Ethernet124": { + "default_brkout_mode": "1x100G[40G]" + } + } +} + diff --git a/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/port_config.ini b/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/port_config.ini index c12f3b3ba2..f761c2c5ae 100755 --- a/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/port_config.ini +++ b/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/port_config.ini @@ -1,33 +1,33 @@ # name lanes alias index speed -Ethernet0 1,2,3,4 hundredGigE1 1 100000 -Ethernet4 5,6,7,8 hundredGigE2 2 100000 -Ethernet8 9,10,11,12 hundredGigE3 3 100000 -Ethernet12 13,14,15,16 hundredGigE4 4 100000 -Ethernet16 17,18,19,20 hundredGigE5 5 100000 -Ethernet20 21,22,23,24 hundredGigE6 6 100000 -Ethernet24 25,26,27,28 hundredGigE7 7 100000 -Ethernet28 29,30,31,32 hundredGigE8 8 100000 -Ethernet32 33,34,35,36 hundredGigE9 9 100000 -Ethernet36 37,38,39,40 hundredGigE10 10 100000 -Ethernet40 41,42,43,44 hundredGigE11 11 100000 -Ethernet44 45,46,47,48 hundredGigE12 12 100000 -Ethernet48 49,50,51,52 hundredGigE13 13 100000 -Ethernet52 53,54,55,56 hundredGigE14 14 100000 -Ethernet56 57,58,59,60 hundredGigE15 15 100000 -Ethernet60 61,62,63,64 hundredGigE16 16 100000 -Ethernet64 65,66,67,68 hundredGigE17 17 100000 -Ethernet68 69,70,71,72 hundredGigE18 18 100000 -Ethernet72 73,74,75,76 hundredGigE19 19 100000 -Ethernet76 77,78,79,80 hundredGigE20 20 100000 -Ethernet80 81,82,83,84 hundredGigE21 21 100000 -Ethernet84 85,86,87,88 hundredGigE22 22 100000 -Ethernet88 89,90,91,92 hundredGigE23 23 100000 -Ethernet92 93,94,95,96 hundredGigE24 24 100000 -Ethernet96 97,98,99,100 hundredGigE25 25 100000 -Ethernet100 101,102,103,104 hundredGigE26 26 100000 -Ethernet104 105,106,107,108 hundredGigE27 27 100000 -Ethernet108 109,110,111,112 hundredGigE28 28 100000 -Ethernet112 113,114,115,116 hundredGigE29 29 100000 -Ethernet116 117,118,119,120 hundredGigE30 30 100000 -Ethernet120 121,122,123,124 hundredGigE31 31 100000 -Ethernet124 125,126,127,128 hundredGigE32 32 100000 +Ethernet0 1,2,3,4 Eth1(Port1) 1 100000 +Ethernet4 5,6,7,8 Eth2(Port2) 2 100000 +Ethernet8 9,10,11,12 Eth3(Port3) 3 100000 +Ethernet12 13,14,15,16 Eth4(Port4) 4 100000 +Ethernet16 17,18,19,20 Eth5(Port5) 5 100000 +Ethernet20 21,22,23,24 Eth6(Port6) 6 100000 +Ethernet24 25,26,27,28 Eth7(Port7) 7 100000 +Ethernet28 29,30,31,32 Eth8(Port8) 8 100000 +Ethernet32 33,34,35,36 Eth9(Port9) 9 100000 +Ethernet36 37,38,39,40 Eth10(Port10) 10 100000 +Ethernet40 41,42,43,44 Eth11(Port11) 11 100000 +Ethernet44 45,46,47,48 Eth12(Port12) 12 100000 +Ethernet48 49,50,51,52 Eth13(Port13) 13 100000 +Ethernet52 53,54,55,56 Eth14(Port14) 14 100000 +Ethernet56 57,58,59,60 Eth15(Port15) 15 100000 +Ethernet60 61,62,63,64 Eth16(Port16) 16 100000 +Ethernet64 65,66,67,68 Eth17(Port17) 17 100000 +Ethernet68 69,70,71,72 Eth18(Port18) 18 100000 +Ethernet72 73,74,75,76 Eth19(Port19) 19 100000 +Ethernet76 77,78,79,80 Eth20(Port20) 20 100000 +Ethernet80 81,82,83,84 Eth21(Port21) 21 100000 +Ethernet84 85,86,87,88 Eth22(Port22) 22 100000 +Ethernet88 89,90,91,92 Eth23(Port23) 23 100000 +Ethernet92 93,94,95,96 Eth24(Port24) 24 100000 +Ethernet96 97,98,99,100 Eth25(Port25) 25 100000 +Ethernet100 101,102,103,104 Eth26(Port26) 26 100000 +Ethernet104 105,106,107,108 Eth27(Port27) 27 100000 +Ethernet108 109,110,111,112 Eth28(Port28) 28 100000 +Ethernet112 113,114,115,116 Eth29(Port29) 29 100000 +Ethernet116 117,118,119,120 Eth30(Port30) 30 100000 +Ethernet120 121,122,123,124 Eth31(Port31) 31 100000 +Ethernet124 125,126,127,128 Eth32(Port32) 32 100000 diff --git a/device/accton/x86_64-accton_as7726_32x-r0/pcie.yaml b/device/accton/x86_64-accton_as7726_32x-r0/pcie.yaml new file mode 100644 index 0000000000..c019a23aa0 --- /dev/null +++ b/device/accton/x86_64-accton_as7726_32x-r0/pcie.yaml @@ -0,0 +1,471 @@ +- bus: '00' + dev: '00' + fn: '0' + id: 6f00 + name: 'Host bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DMI2 + (rev 03)' +- bus: '00' + dev: '01' + fn: '0' + id: 6f02 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 1 (rev 03)' +- bus: '00' + dev: '01' + fn: '1' + id: 6f03 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 1 (rev 03)' +- bus: '00' + dev: '02' + fn: '0' + id: 6f04 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 2 (rev 03)' +- bus: '00' + dev: '02' + fn: '1' + id: 6f05 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 2 (rev 03)' +- bus: '00' + dev: '02' + fn: '2' + id: 6f06 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 2 (rev 03)' +- bus: '00' + dev: '02' + fn: '3' + id: 6f07 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 2 (rev 03)' +- bus: '00' + dev: '03' + fn: '0' + id: 6f08 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 3 (rev 03)' +- bus: '00' + dev: '03' + fn: '1' + id: 6f09 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 3 (rev 03)' +- bus: '00' + dev: '03' + fn: '2' + id: 6f0a + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 3 (rev 03)' +- bus: '00' + dev: '03' + fn: '3' + id: 6f0b + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 3 (rev 03)' +- bus: '00' + dev: '05' + fn: '0' + id: 6f28 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Map/VTd_Misc/System Management (rev 03)' +- bus: '00' + dev: '05' + fn: '1' + id: 6f29 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D IIO Hot Plug (rev 03)' +- bus: '00' + dev: '05' + fn: '2' + id: 6f2a + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D IIO RAS/Control Status/Global Errors (rev 03)' +- bus: '00' + dev: '05' + fn: '4' + id: 6f2c + name: 'PIC: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D I/O APIC (rev + 03)' +- bus: '00' + dev: '14' + fn: '0' + id: 8c31 + name: 'USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB + xHCI (rev 05)' +- bus: '00' + dev: '16' + fn: '0' + id: 8c3a + name: 'Communication controller: Intel Corporation 8 Series/C220 Series Chipset + Family MEI Controller #1 (rev 04)' +- bus: '00' + dev: '16' + fn: '1' + id: 8c3b + name: 'Communication controller: Intel Corporation 8 Series/C220 Series Chipset + Family MEI Controller #2 (rev 04)' +- bus: '00' + dev: 1c + fn: '0' + id: 8c10 + name: 'PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express + Root Port #1 (rev d5)' +- bus: '00' + dev: 1c + fn: '1' + id: 8c12 + name: 'PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express + Root Port #2 (rev d5)' +- bus: '00' + dev: 1c + fn: '4' + id: 8c18 + name: 'PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express + Root Port #5 (rev d5)' +- bus: '00' + dev: 1d + fn: '0' + id: 8c26 + name: 'USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB + EHCI #1 (rev 05)' +- bus: '00' + dev: 1f + fn: '0' + id: 8c54 + name: 'ISA bridge: Intel Corporation C224 Series Chipset Family Server Standard + SKU LPC Controller (rev 05)' +- bus: '00' + dev: 1f + fn: '2' + id: 8c02 + name: 'SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port + SATA Controller 1 [AHCI mode] (rev 05)' +- bus: '00' + dev: 1f + fn: '3' + id: 8c22 + name: 'SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller + (rev 05)' +- bus: '03' + dev: '00' + fn: '0' + id: 6f50 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 0' +- bus: '03' + dev: '00' + fn: '1' + id: 6f51 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 1' +- bus: '03' + dev: '00' + fn: '2' + id: 6f52 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 2' +- bus: '03' + dev: '00' + fn: '3' + id: 6f53 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 3' +- bus: '05' + dev: '00' + fn: '0' + id: 15ab + name: 'Ethernet controller: Intel Corporation Ethernet Connection X552 10 GbE Backplane' +- bus: '05' + dev: '00' + fn: '1' + id: 15ab + name: 'Ethernet controller: Intel Corporation Ethernet Connection X552 10 GbE Backplane' +- bus: '07' + dev: '00' + fn: '0' + id: b870 + name: 'Ethernet controller: Broadcom Inc. and subsidiaries Device b870 (rev 01)' +- bus: 0b + dev: '00' + fn: '0' + id: 165f + name: 'Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme BCM5720 2-port + Gigabit Ethernet PCIe' +- bus: ff + dev: 0b + fn: '0' + id: 6f81 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link 0/1 (rev 03)' +- bus: ff + dev: 0b + fn: '1' + id: 6f36 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link 0/1 (rev 03)' +- bus: ff + dev: 0b + fn: '2' + id: 6f37 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link 0/1 (rev 03)' +- bus: ff + dev: 0b + fn: '3' + id: 6f76 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link Debug (rev 03)' +- bus: ff + dev: 0c + fn: '0' + id: 6fe0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0c + fn: '1' + id: 6fe1 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0c + fn: '2' + id: 6fe2 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0c + fn: '3' + id: 6fe3 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '0' + id: 6ff8 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '4' + id: 6ffc + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '5' + id: 6ffd + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '6' + id: 6ffe + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: '10' + fn: '0' + id: 6f1d + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R2PCIe Agent (rev 03)' +- bus: ff + dev: '10' + fn: '1' + id: 6f34 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R2PCIe Agent (rev 03)' +- bus: ff + dev: '10' + fn: '5' + id: 6f1e + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Ubox (rev 03)' +- bus: ff + dev: '10' + fn: '6' + id: 6f7d + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Ubox (rev 03)' +- bus: ff + dev: '10' + fn: '7' + id: 6f1f + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Ubox (rev 03)' +- bus: ff + dev: '12' + fn: '0' + id: 6fa0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Home Agent 0 (rev 03)' +- bus: ff + dev: '12' + fn: '1' + id: 6f30 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Home Agent 0 (rev 03)' +- bus: ff + dev: '13' + fn: '0' + id: 6fa8 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Target Address/Thermal/RAS (rev 03)' +- bus: ff + dev: '13' + fn: '1' + id: 6f71 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Target Address/Thermal/RAS (rev 03)' +- bus: ff + dev: '13' + fn: '2' + id: 6faa + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '3' + id: 6fab + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '4' + id: 6fac + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '5' + id: 6fad + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '6' + id: 6fae + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Broadcast (rev 03)' +- bus: ff + dev: '13' + fn: '7' + id: 6faf + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Global Broadcast (rev 03)' +- bus: ff + dev: '14' + fn: '0' + id: 6fb0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 0 Thermal Control (rev 03)' +- bus: ff + dev: '14' + fn: '1' + id: 6fb1 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 1 Thermal Control (rev 03)' +- bus: ff + dev: '14' + fn: '2' + id: 6fb2 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 0 Error (rev 03)' +- bus: ff + dev: '14' + fn: '3' + id: 6fb3 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 1 Error (rev 03)' +- bus: ff + dev: '14' + fn: '4' + id: 6fbc + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '14' + fn: '5' + id: 6fbd + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '14' + fn: '6' + id: 6fbe + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '14' + fn: '7' + id: 6fbf + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '15' + fn: '0' + id: 6fb4 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 2 Thermal Control (rev 03)' +- bus: ff + dev: '15' + fn: '1' + id: 6fb5 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 3 Thermal Control (rev 03)' +- bus: ff + dev: '15' + fn: '2' + id: 6fb6 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 2 Error (rev 03)' +- bus: ff + dev: '15' + fn: '3' + id: 6fb7 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 3 Error (rev 03)' +- bus: ff + dev: 1e + fn: '0' + id: 6f98 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '1' + id: 6f99 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '2' + id: 6f9a + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '3' + id: 6fc0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '4' + id: 6f9c + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1f + fn: '0' + id: 6f88 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1f + fn: '2' + id: 6f8a + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' diff --git a/device/accton/x86_64-accton_as7726_32x-r0/pddf/pd-plugin.json b/device/accton/x86_64-accton_as7726_32x-r0/pddf/pd-plugin.json index b4e2cc4ac8..d79bdb4d52 100644 --- a/device/accton/x86_64-accton_as7726_32x-r0/pddf/pd-plugin.json +++ b/device/accton/x86_64-accton_as7726_32x-r0/pddf/pd-plugin.json @@ -34,7 +34,7 @@ { "i2c": { - "valmap": { "F2B":"EXHAUST", "B2F":"INTAKE" } + "valmap": { "F2B":"exhaust", "B2F":"intake" } } }, @@ -47,7 +47,7 @@ { "i2c": { - "valmap": {"1":"EXHAUST", "0":"INTAKE"} + "valmap": {"1":"exhaust", "0":"intake"} } }, @@ -61,7 +61,7 @@ "duty_cycle_to_pwm": "lambda dc: ((dc*100)/625 -1)", - "pwm_to_duty_cycle": "lambda pwm: (((pwm+1)*625+75)/100)" + "pwm_to_duty_cycle": "lambda pwm: (((pwm+1)*625)/100)" } } diff --git a/device/accton/x86_64-accton_as7726_32x-r0/pddf/pddf-device.json b/device/accton/x86_64-accton_as7726_32x-r0/pddf/pddf-device.json index b73f22b541..54c372df19 100644 --- a/device/accton/x86_64-accton_as7726_32x-r0/pddf/pddf-device.json +++ b/device/accton/x86_64-accton_as7726_32x-r0/pddf/pddf-device.json @@ -4,8 +4,8 @@ "num_psus":2, "num_fantrays":6, "num_fans_pertray":2, - "num_ports":34, - "num_temps":5, + "num_ports":32, + "num_temps":10, "pddf_dev_types": { "description":"AS7726 - Below is the list of supported PDDF device types (chip names) for various components. If any component uses some other driver, we will create the client using 'echo > /new_device' method", @@ -1657,7 +1657,11 @@ { "attr_name":"psu_i_out", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_p_out", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, - { "attr_name":"psu_temp1_input", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} + { "attr_name":"psu_temp1_input", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_max", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0xa5", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_min", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0xa4", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_p_out_max", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0xa7", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_temp1_high_threshold", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0xa8", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} ] } }, @@ -1705,7 +1709,11 @@ { "attr_name":"psu_i_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_p_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, - { "attr_name":"psu_temp1_input", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} + { "attr_name":"psu_temp1_input", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_max", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa5", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_min", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa4", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_p_out_max", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa7", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_temp1_high_threshold", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa8", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} ] } }, @@ -1865,7 +1873,82 @@ ] } }, - + "TEMP6" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP6"}, + "dev_attr": { "display_name":"CPU_Package_temp"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon0"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp1_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_input"} + ] + } + }, + + "TEMP7" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP7"}, + "dev_attr": { "display_name":"CPU_Core_0_temp"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon0"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp2_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp2_max"}, + { "attr_name": "temp1_input", "drv_attr_name":"temp2_input"} + ] + } + }, + "TEMP8" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP8"}, + "dev_attr": { "display_name":"CPU_Core_1_temp"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon0"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp3_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp3_max"}, + { "attr_name": "temp1_input", "drv_attr_name":"temp3_input"} + ] + } + }, + "TEMP9" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP9"}, + "dev_attr": { "display_name":"CPU_Core_2_temp"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon0"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp4_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp4_max"}, + { "attr_name": "temp1_input", "drv_attr_name":"temp4_input"} + ] + } + }, + "TEMP10" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP10"}, + "dev_attr": { "display_name":"CPU_Core_3_temp"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon0"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp5_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp5_max"}, + { "attr_name": "temp1_input", "drv_attr_name":"temp5_input"} + ] + } + }, "SYSSTATUS": { "dev_info":{ "device_type":"SYSSTAT", "device_name":"SYSSTATUS"}, @@ -1890,12 +1973,12 @@ "LOC_LED": { "dev_info": { "device_type":"LED", "device_name":"LOC_LED"}, - "dev_attr": { "index":"0"}, + "dev_attr": { "index":"0", "flag": "rw"}, "i2c" : { "attr_list": [ - {"attr_name":"STATUS_LED_COLOR_BLUE", "descr" : "", "bits" : "7", "value" : "0x0", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x41"}, - {"attr_name":"STATUS_LED_COLOR_OFF", "descr" : "", "bits" : "7", "value" : "0x1", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x41"} + {"attr_name":"blue", "descr" : "", "bits" : "7", "value" : "0x0", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x41"}, + {"attr_name":"off", "descr" : "", "bits" : "7", "value" : "0x1", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x41"} ] } }, @@ -1903,13 +1986,13 @@ "DIAG_LED": { "dev_info": { "device_type":"LED", "device_name":"DIAG_LED"}, - "dev_attr": { "index":"0"}, + "dev_attr": { "index":"0", "flag": "rw"}, "i2c" : { "attr_list": [ - {"attr_name":"STATUS_LED_COLOR_GREEN", "descr" : "", "bits" : "1:0", "value" : "0x2", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x41"}, - {"attr_name":"STATUS_LED_COLOR_RED", "descr" : "" ,"bits" : "1:0", "value" : "0x1", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x41"}, - {"attr_name":"STATUS_LED_COLOR_OFF", "descr" : "" ,"bits" : "1:0", "value" : "0x3", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x41"} + {"attr_name":"green", "descr" : "", "bits" : "1:0", "value" : "0x2", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x41"}, + {"attr_name":"red", "descr" : "" ,"bits" : "1:0", "value" : "0x1", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x41"}, + {"attr_name":"off", "descr" : "" ,"bits" : "1:0", "value" : "0x3", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x41"} ] } diff --git a/device/accton/x86_64-accton_as7726_32x-r0/platform.json b/device/accton/x86_64-accton_as7726_32x-r0/platform.json new file mode 100644 index 0000000000..a0e25f83a8 --- /dev/null +++ b/device/accton/x86_64-accton_as7726_32x-r0/platform.json @@ -0,0 +1,902 @@ +{ + "chassis": { + "name": "7726-32X", + "thermal_manager":false, + "status_led": { + "controllable": true, + "colors": ["green", "red", "off"] + }, + "components": [ + { + "name": "MB_CPLD1" + }, + { + "name": "MB_CPLD2" + }, + { + "name": "MB_CPLD3" + }, + { + "name": "FAN_CPLD" + }, + { + "name": "CPU_CPLD" + }, + { + "name": "BIOS" + } + ], + "fans": [ + { + "name": "FAN-1F", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-1R", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-2F", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-2R", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-3F", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-3R", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-4F", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-4R", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-5F", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-5R", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-6F", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-6R", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + } + ], + "fan_drawers":[ + { + "name": "FanTray1", + "status_led": { + "controllable": false + }, + "num_fans" : 2, + "fans": [ + { + "name": "FAN-1F", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-1R", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + } + ] + }, + { + "name": "FanTray2", + "status_led": { + "controllable": false + }, + "num_fans" : 2, + "fans": [ + { + "name": "FAN-2F", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-2R", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + } + ] + }, + { + "name": "FanTray3", + "status_led": { + "controllable": false + }, + "num_fans" : 2, + "fans": [ + { + "name": "FAN-3F", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-3R", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + } + ] + }, + { + "name": "FanTray4", + "status_led": { + "controllable": false + }, + "num_fans" : 2, + "fans": [ + { + "name": "FAN-4F", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-4R", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + } + ] + }, + { + "name": "FanTray5", + "status_led": { + "controllable": false + }, + "num_fans" : 2, + "fans": [ + { + "name": "FAN-5F", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-5R", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + } + ] + }, + { + "name": "FanTray6", + "status_led": { + "controllable": false + }, + "num_fans" : 2, + "fans": [ + { + "name": "FAN-6F", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + }, + { + "name": "FAN-6R", + "speed": { + "controllable": true, + "minimum": 32 + }, + "status_led": { + "controllable": false + } + } + ] + } + ], + "psus": [ + { + "name": "PSU-1", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "PSU-1 FAN-1" + } + ], + "thermals": [ + { + "name": "PSU-1 temp sensor 1", + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false + } + ] + }, + { + "name": "PSU-2", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "PSU-2 FAN-1" + } + ], + "thermals": [ + { + "name": "PSU-2 temp sensor 2", + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false + } + ] + } + ], + "thermals": [ + { + "name": "CB_temp(0x4B)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false + }, + { + "name": "FB_temp(0x4C)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false + }, + { + "name": "MB_FrontMAC_temp(0x49)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false + }, + { + "name": "MB_LeftCenter_temp(0x4A)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false + }, + { + "name": "MB_RearMAC_temp(0x48)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": false + }, + { + "name": "CPU_Package_temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + }, + { + "name": "CPU_Core_0_temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + }, + { + "name": "CPU_Core_1_temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + }, + { + "name": "CPU_Core_2_temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + }, + { + "name": "CPU_Core_3_temp", + "controllable": false, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + } + ], + "sfps": [ + { + "name": "Ethernet0" + }, + { + "name": "Ethernet4" + }, + { + "name": "Ethernet8" + }, + { + "name": "Ethernet12" + }, + { + "name": "Ethernet16" + }, + { + "name": "Ethernet20" + }, + { + "name": "Ethernet24" + }, + { + "name": "Ethernet28" + }, + { + "name": "Ethernet32" + }, + { + "name": "Ethernet36" + }, + { + "name": "Ethernet40" + }, + { + "name": "Ethernet44" + }, + { + "name": "Ethernet48" + }, + { + "name": "Ethernet52" + }, + { + "name": "Ethernet56" + }, + { + "name": "Ethernet60" + }, + { + "name": "Ethernet64" + }, + { + "name": "Ethernet68" + }, + { + "name": "Ethernet72" + }, + { + "name": "Ethernet76" + }, + { + "name": "Ethernet80" + }, + { + "name": "Ethernet84" + }, + { + "name": "Ethernet88" + }, + { + "name": "Ethernet92" + }, + { + "name": "Ethernet96" + }, + { + "name": "Ethernet100" + }, + { + "name": "Ethernet104" + }, + { + "name": "Ethernet108" + }, + { + "name": "Ethernet112" + }, + { + "name": "Ethernet116" + }, + { + "name": "Ethernet120" + }, + { + "name": "Ethernet124" + } + ] + }, + "interfaces": { + "Ethernet0": { + "index": "1,1,1,1", + "lanes": "1,2,3,4", + "breakout_modes": { + "1x100G[40G]": ["Eth1(Port1)"], + "2x50G": ["Eth1/1(Port1)", "Eth1/2(Port1)"], + "4x25G": ["Eth1/1(Port1)", "Eth1/2(Port1)", "Eth1/3(Port1)", "Eth1/4(Port1)"], + "4x10G": ["Eth1/1(Port1)", "Eth1/2(Port1)", "Eth1/3(Port1)", "Eth1/4(Port1)"] + } + }, + + "Ethernet4": { + "index": "2,2,2,2", + "lanes": "5,6,7,8", + "breakout_modes": { + "1x100G[40G]": ["Eth2(Port2)"], + "2x50G": ["Eth2/1(Port2)", "Eth2/2(Port2)"], + "4x25G": ["Eth2/1(Port2)", "Eth2/2(Port2)", "Eth2/3(Port2)", "Eth2/4(Port2)"], + "4x10G": ["Eth2/1(Port2)", "Eth2/2(Port2)", "Eth2/3(Port2)", "Eth2/4(Port2)"] + } + }, + + "Ethernet8": { + "index": "3,3,3,3", + "lanes": "9,10,11,12", + "breakout_modes": { + "1x100G[40G]": ["Eth3(Port3)"], + "2x50G": ["Eth3/1(Port3)", "Eth3/2(Port3)"], + "4x25G": ["Eth3/1(Port3)", "Eth3/2(Port3)", "Eth3/3(Port3)", "Eth3/4(Port3)"], + "4x10G": ["Eth3/1(Port3)", "Eth3/2(Port3)", "Eth3/3(Port3)", "Eth3/4(Port3)"] + } + }, + + "Ethernet12": { + "index": "4,4,4,4", + "lanes": "13,14,15,16", + "breakout_modes": { + "1x100G[40G]": ["Eth4(Port4)"], + "2x50G": ["Eth4/1(Port4)", "Eth4/2(Port4)"], + "4x25G": ["Eth4/1(Port4)", "Eth4/2(Port4)", "Eth4/3(Port4)", "Eth4/4(Port4)"], + "4x10G": ["Eth4/1(Port4)", "Eth4/2(Port4)", "Eth4/3(Port4)", "Eth4/4(Port4)"] + } + }, + + "Ethernet16": { + "index": "5,5,5,5", + "lanes": "17,18,19,20", + "breakout_modes": { + "1x100G[40G]": ["Eth5(Port5)"], + "2x50G": ["Eth5/1(Port5)", "Eth5/2(Port5)"], + "4x25G": ["Eth5/1(Port5)", "Eth5/2(Port5)", "Eth5/3(Port5)", "Eth5/4(Port5)"], + "4x10G": ["Eth5/1(Port5)", "Eth5/2(Port5)", "Eth5/3(Port5)", "Eth5/4(Port5)"] + } + }, + + "Ethernet20": { + "index": "6,6,6,6", + "lanes": "21,22,23,24", + "breakout_modes": { + "1x100G[40G]": ["Eth6(Port6)"], + "2x50G": ["Eth6/1(Port6)", "Eth6/2(Port6)"], + "4x25G": ["Eth6/1(Port6)", "Eth6/2(Port6)", "Eth6/3(Port6)", "Eth6/4(Port6)"], + "4x10G": ["Eth6/1(Port6)", "Eth6/2(Port6)", "Eth6/3(Port6)", "Eth6/4(Port6)"] + } + }, + + "Ethernet24": { + "index": "7,7,7,7", + "lanes": "25,26,27,28", + "breakout_modes": { + "1x100G[40G]": ["Eth7(Port7)"], + "2x50G": ["Eth7/1(Port7)", "Eth7/2(Port7)"], + "4x25G": ["Eth7/1(Port7)", "Eth7/2(Port7)", "Eth7/3(Port7)", "Eth7/4(Port7)"], + "4x10G": ["Eth7/1(Port7)", "Eth7/2(Port7)", "Eth7/3(Port7)", "Eth7/4(Port7)"] + } + }, + + "Ethernet28": { + "index": "8,8,8,8", + "lanes": "29,30,31,32", + "breakout_modes": { + "1x100G[40G]": ["Eth8(Port8)"], + "2x50G": ["Eth8/1(Port8)", "Eth8/2(Port8)"], + "4x25G": ["Eth8/1(Port8)", "Eth8/2(Port8)", "Eth8/3(Port8)", "Eth8/4(Port8)"], + "4x10G": ["Eth8/1(Port8)", "Eth8/2(Port8)", "Eth8/3(Port8)", "Eth8/4(Port8)"] + } + }, + + "Ethernet32": { + "index": "9,9,9,9", + "lanes": "33,34,35,36", + "breakout_modes": { + "1x100G[40G]": ["Eth9(Port9)"], + "2x50G": ["Eth9/1(Port9)", "Eth9/2(Port9)"], + "4x25G": ["Eth9/1(Port9)", "Eth9/2(Port9)", "Eth9/3(Port9)", "Eth9/4(Port9)"], + "4x10G": ["Eth9/1(Port9)", "Eth9/2(Port9)", "Eth9/3(Port9)", "Eth9/4(Port9)"] + } + }, + + "Ethernet36": { + "index": "10,10,10,10", + "lanes": "37,38,39,40", + "breakout_modes": { + "1x100G[40G]": ["Eth10(Port10)"], + "2x50G": ["Eth10/1(Port10)", "Eth10/2(Port10)"], + "4x25G": ["Eth10/1(Port10)", "Eth10/2(Port10)", "Eth10/3(Port10)", "Eth10/4(Port10)"], + "4x10G": ["Eth10/1(Port10)", "Eth10/2(Port10)", "Eth10/3(Port10)", "Eth10/4(Port10)"] + } + }, + + "Ethernet40": { + "index": "11,11,11,11", + "lanes": "41,42,43,44", + "breakout_modes": { + "1x100G[40G]": ["Eth11(Port11)"], + "2x50G": ["Eth11/1(Port11)", "Eth11/2(Port11)"], + "4x25G": ["Eth11/1(Port11)", "Eth11/2(Port11)", "Eth11/3(Port11)", "Eth11/4(Port11)"], + "4x10G": ["Eth11/1(Port11)", "Eth11/2(Port11)", "Eth11/3(Port11)", "Eth11/4(Port11)"] + } + }, + + "Ethernet44": { + "index": "12,12,12,12", + "lanes": "45,46,47,48", + "breakout_modes": { + "1x100G[40G]": ["Eth12(Port12)"], + "2x50G": ["Eth12/1(Port12)", "Eth12/2(Port12)"], + "4x25G": ["Eth12/1(Port12)", "Eth12/2(Port12)", "Eth12/3(Port12)", "Eth12/4(Port12)"], + "4x10G": ["Eth12/1(Port12)", "Eth12/2(Port12)", "Eth12/3(Port12)", "Eth12/4(Port12)"] + } + }, + + "Ethernet48": { + "index": "13,13,13,13", + "lanes": "49,50,51,52", + "breakout_modes": { + "1x100G[40G]": ["Eth13(Port13)"], + "2x50G": ["Eth13/1(Port13)", "Eth13/2(Port13)"], + "4x25G": ["Eth13/1(Port13)", "Eth13/2(Port13)", "Eth13/3(Port13)", "Eth13/4(Port13)"], + "4x10G": ["Eth13/1(Port13)", "Eth13/2(Port13)", "Eth13/3(Port13)", "Eth13/4(Port13)"] + } + }, + + "Ethernet52": { + "index": "14,14,14,14", + "lanes": "53,54,55,56", + "breakout_modes": { + "1x100G[40G]": ["Eth14(Port14)"], + "2x50G": ["Eth14/1(Port14)", "Eth14/2(Port14)"], + "4x25G": ["Eth14/1(Port14)", "Eth14/2(Port14)", "Eth14/3(Port14)", "Eth14/4(Port14)"], + "4x10G": ["Eth14/1(Port14)", "Eth14/2(Port14)", "Eth14/3(Port14)", "Eth14/4(Port14)"] + } + }, + + "Ethernet56": { + "index": "15,15,15,15", + "lanes": "57,58,59,60", + "breakout_modes": { + "1x100G[40G]": ["Eth15(Port15)"], + "2x50G": ["Eth15/1(Port15)", "Eth15/2(Port15)"], + "4x25G": ["Eth15/1(Port15)", "Eth15/2(Port15)", "Eth15/3(Port15)", "Eth15/4(Port15)"], + "4x10G": ["Eth15/1(Port15)", "Eth15/2(Port15)", "Eth15/3(Port15)", "Eth15/4(Port15)"] + } + }, + + "Ethernet60": { + "index": "16,16,16,16", + "lanes": "61,62,63,64", + "breakout_modes": { + "1x100G[40G]": ["Eth16(Port16)"], + "2x50G": ["Eth16/1(Port16)", "Eth16/2(Port16)"], + "4x25G": ["Eth16/1(Port16)", "Eth16/2(Port16)", "Eth16/3(Port16)", "Eth16/4(Port16)"], + "4x10G": ["Eth16/1(Port16)", "Eth16/2(Port16)", "Eth16/3(Port16)", "Eth16/4(Port16)"] + } + }, + + "Ethernet64": { + "index": "17,17,17,17", + "lanes": "65,66,67,68", + "breakout_modes": { + "1x100G[40G]": ["Eth17(Port17)"], + "2x50G": ["Eth17/1(Port17)", "Eth17/2(Port17)"], + "4x25G": ["Eth17/1(Port17)", "Eth17/2(Port17)", "Eth17/3(Port17)", "Eth17/4(Port17)"], + "4x10G": ["Eth17/1(Port17)", "Eth17/2(Port17)", "Eth17/3(Port17)", "Eth17/4(Port17)"] + } + }, + + "Ethernet68": { + "index": "18,18,18,18", + "lanes": "69,70,71,72", + "breakout_modes": { + "1x100G[40G]": ["Eth18(Port18)"], + "2x50G": ["Eth18/1(Port18)", "Eth18/2(Port18)"], + "4x25G": ["Eth18/1(Port18)", "Eth18/2(Port18)", "Eth18/3(Port18)", "Eth18/4(Port18)"], + "4x10G": ["Eth18/1(Port18)", "Eth18/2(Port18)", "Eth18/3(Port18)", "Eth18/4(Port18)"] + } + }, + + "Ethernet72": { + "index": "19,19,19,19", + "lanes": "73,74,75,76", + "breakout_modes": { + "1x100G[40G]": ["Eth19(Port19)"], + "2x50G": ["Eth19/1(Port19)", "Eth19/2(Port19)"], + "4x25G": ["Eth19/1(Port19)", "Eth19/2(Port19)", "Eth19/3(Port19)", "Eth19/4(Port19)"], + "4x10G": ["Eth19/1(Port19)", "Eth19/2(Port19)", "Eth19/3(Port19)", "Eth19/4(Port19)"] + } + }, + + "Ethernet76": { + "index": "20,20,20,20", + "lanes": "77,78,79,80", + "breakout_modes": { + "1x100G[40G]": ["Eth20(Port20)"], + "2x50G": ["Eth20/1(Port20)", "Eth20/2(Port20)"], + "4x25G": ["Eth20/1(Port20)", "Eth20/2(Port20)", "Eth20/3(Port20)", "Eth20/4(Port20)"], + "4x10G": ["Eth20/1(Port20)", "Eth20/2(Port20)", "Eth20/3(Port20)", "Eth20/4(Port20)"] + } + }, + + "Ethernet80": { + "index": "21,21,21,21", + "lanes": "81,82,83,84", + "breakout_modes": { + "1x100G[40G]": ["Eth21(Port21)"], + "2x50G": ["Eth21/1(Port21)", "Eth21/2(Port21)"], + "4x25G": ["Eth21/1(Port21)", "Eth21/2(Port21)", "Eth21/3(Port21)", "Eth21/4(Port21)"], + "4x10G": ["Eth21/1(Port21)", "Eth21/2(Port21)", "Eth21/3(Port21)", "Eth21/4(Port21)"] + } + }, + + "Ethernet84": { + "index": "22,22,22,22", + "lanes": "85,86,87,88", + "breakout_modes": { + "1x100G[40G]": ["Eth22(Port22)"], + "2x50G": ["Eth22/1(Port22)", "Eth22/2(Port22)"], + "4x25G": ["Eth22/1(Port22)", "Eth22/2(Port22)", "Eth22/3(Port22)", "Eth22/4(Port22)"], + "4x10G": ["Eth22/1(Port22)", "Eth22/2(Port22)", "Eth22/3(Port22)", "Eth22/4(Port22)"] + } + }, + + "Ethernet88": { + "index": "23,23,23,23", + "lanes": "89,90,91,92", + "breakout_modes": { + "1x100G[40G]": ["Eth23(Port23)"], + "2x50G": ["Eth23/1(Port23)", "Eth23/2(Port23)"], + "4x25G": ["Eth23/1(Port23)", "Eth23/2(Port23)", "Eth23/3(Port23)", "Eth23/4(Port23)"], + "4x10G": ["Eth23/1(Port23)", "Eth23/2(Port23)", "Eth23/3(Port23)", "Eth23/4(Port23)"] + } + }, + + "Ethernet92": { + "index": "24,24,24,24", + "lanes": "93,94,95,96", + "breakout_modes": { + "1x100G[40G]": ["Eth24(Port24)"], + "2x50G": ["Eth24/1(Port24)", "Eth24/2(Port24)"], + "4x25G": ["Eth24/1(Port24)", "Eth24/2(Port24)", "Eth24/3(Port24)", "Eth24/4(Port24)"], + "4x10G": ["Eth24/1(Port24)", "Eth24/2(Port24)", "Eth24/3(Port24)", "Eth24/4(Port24)"] + } + }, + + "Ethernet96": { + "index": "25,25,25,25", + "lanes": "97,98,99,100", + "breakout_modes": { + "1x100G[40G]": ["Eth25(Port25)"], + "2x50G": ["Eth25/1(Port25)", "Eth25/2(Port25)"], + "4x25G": ["Eth25/1(Port25)", "Eth25/2(Port25)", "Eth25/3(Port25)", "Eth25/4(Port25)"], + "4x10G": ["Eth25/1(Port25)", "Eth25/2(Port25)", "Eth25/3(Port25)", "Eth25/4(Port25)"] + } + }, + + "Ethernet100": { + "index": "26,26,26,26", + "lanes": "101,102,103,104", + "breakout_modes": { + "1x100G[40G]": ["Eth26(Port26)"], + "2x50G": ["Eth26/1(Port26)", "Eth26/2(Port26)"], + "4x25G": ["Eth26/1(Port26)", "Eth26/2(Port26)", "Eth26/3(Port26)", "Eth26/4(Port26)"], + "4x10G": ["Eth26/1(Port26)", "Eth26/2(Port26)", "Eth26/3(Port26)", "Eth26/4(Port26)"] + } + }, + + "Ethernet104": { + "index": "27,27,27,27", + "lanes": "105,106,107,108", + "breakout_modes": { + "1x100G[40G]": ["Eth27(Port27)"], + "2x50G": ["Eth27/1(Port27)", "Eth27/2(Port27)"], + "4x25G": ["Eth27/1(Port27)", "Eth27/2(Port27)", "Eth27/3(Port27)", "Eth27/4(Port27)"], + "4x10G": ["Eth27/1(Port27)", "Eth27/2(Port27)", "Eth27/3(Port27)", "Eth27/4(Port27)"] + } + }, + + "Ethernet108": { + "index": "28,28,28,28", + "lanes": "109,110,111,112", + "breakout_modes": { + "1x100G[40G]": ["Eth28(Port28)"], + "2x50G": ["Eth28/1(Port28)", "Eth28/2(Port28)"], + "4x25G": ["Eth28/1(Port28)", "Eth28/2(Port28)", "Eth28/3(Port28)", "Eth28/4(Port28)"], + "4x10G": ["Eth28/1(Port28)", "Eth28/2(Port28)", "Eth28/3(Port28)", "Eth28/4(Port28)"] + } + }, + + "Ethernet112": { + "index": "29,29,29,29", + "lanes": "113,114,115,116", + "breakout_modes": { + "1x100G[40G]": ["Eth29(Port29)"], + "2x50G": ["Eth29/1(Port29)", "Eth29/2(Port29)"], + "4x25G": ["Eth29/1(Port29)", "Eth29/2(Port29)", "Eth29/3(Port29)", "Eth29/4(Port29)"], + "4x10G": ["Eth29/1(Port29)", "Eth29/2(Port29)", "Eth29/3(Port29)", "Eth29/4(Port29)"] + } + }, + + "Ethernet116": { + "index": "30,30,30,30", + "lanes": "117,118,119,120", + "breakout_modes": { + "1x100G[40G]": ["Eth30(Port30)"], + "2x50G": ["Eth30/1(Port30)", "Eth30/2(Port30)"], + "4x25G": ["Eth30/1(Port30)", "Eth30/2(Port30)", "Eth30/3(Port30)", "Eth30/4(Port30)"], + "4x10G": ["Eth30/1(Port30)", "Eth30/2(Port30)", "Eth30/3(Port30)", "Eth30/4(Port30)"] + } + }, + + "Ethernet120": { + "index": "31,31,31,31", + "lanes": "121,122,123,124", + "breakout_modes": { + "1x100G[40G]": ["Eth31(Port31)"], + "2x50G": ["Eth31/1(Port31)", "Eth31/2(Port31)"], + "4x25G": ["Eth31/1(Port31)", "Eth31/2(Port31)", "Eth31/3(Port31)", "Eth31/4(Port31)"], + "4x10G": ["Eth31/1(Port31)", "Eth31/2(Port31)", "Eth31/3(Port31)", "Eth31/4(Port31)"] + } + }, + + "Ethernet124": { + "index": "32,32,32,32", + "lanes": "125,126,127,128", + "breakout_modes": { + "1x100G[40G]": ["Eth32(Port32)"], + "2x50G": ["Eth32/1(Port32)", "Eth32/2(Port32)"], + "4x25G": ["Eth32/1(Port32)", "Eth32/2(Port32)", "Eth32/3(Port32)", "Eth32/4(Port32)"], + "4x10G": ["Eth32/1(Port32)", "Eth32/2(Port32)", "Eth32/3(Port32)", "Eth32/4(Port32)"] + } + } + } +} + diff --git a/device/accton/x86_64-accton_as7726_32x-r0/platform_components.json b/device/accton/x86_64-accton_as7726_32x-r0/platform_components.json new file mode 100644 index 0000000000..bf9378baeb --- /dev/null +++ b/device/accton/x86_64-accton_as7726_32x-r0/platform_components.json @@ -0,0 +1,14 @@ +{ + "chassis": { + "7726-32X-O-AC-F": { + "component": { + "MB_CPLD1": { }, + "MB_CPLD2": { }, + "MB_CPLD3": { }, + "FAN_CPLD": { }, + "CPU_CPLD": { }, + "BIOS": { } + } + } + } +} diff --git a/device/accton/x86_64-accton_as7726_32x-r0/plugins/ssd_util.py b/device/accton/x86_64-accton_as7726_32x-r0/plugins/ssd_util.py new file mode 100755 index 0000000000..4b173c5e38 --- /dev/null +++ b/device/accton/x86_64-accton_as7726_32x-r0/plugins/ssd_util.py @@ -0,0 +1,24 @@ +# ssd_util.py +# +# Platform-specific SSD interface for SONiC +## + +try: + from sonic_platform_base.sonic_ssd.ssd_generic import SsdUtil as MainSsdUtil +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +NOT_AVAILABLE = "N/A" + +class SsdUtil(MainSsdUtil): + """Platform-specific SsdUtil class""" + + def __init__(self, diskdev): + super(SsdUtil, self).__init__(diskdev) + + # If it has no vendor tool to read SSD information, + # ssd_util.py will use generic SSD information + # for vendor SSD information. + if self.vendor_ssd_info == NOT_AVAILABLE: + self.vendor_ssd_info = self.ssd_info + diff --git a/device/accton/x86_64-accton_as7726_32x-r0/pmon_daemon_control.json b/device/accton/x86_64-accton_as7726_32x-r0/pmon_daemon_control.json index a3b204e20d..44bad64942 100644 --- a/device/accton/x86_64-accton_as7726_32x-r0/pmon_daemon_control.json +++ b/device/accton/x86_64-accton_as7726_32x-r0/pmon_daemon_control.json @@ -1,5 +1,4 @@ { - "skip_ledd": true, - "skip_pcied": true + "skip_ledd": true } diff --git a/device/accton/x86_64-accton_as7726_32x-r0/system_health_monitoring_config.json b/device/accton/x86_64-accton_as7726_32x-r0/system_health_monitoring_config.json new file mode 100644 index 0000000000..2eb552f83f --- /dev/null +++ b/device/accton/x86_64-accton_as7726_32x-r0/system_health_monitoring_config.json @@ -0,0 +1,13 @@ +{ + "services_to_ignore": [], + "devices_to_ignore": [ + "asic" + ], + "user_defined_checkers": [], + "polling_interval": 60, + "led_color": { + "fault": "amber", + "normal": "green", + "booting": "off" + } +} diff --git a/platform/broadcom/one-image.mk b/platform/broadcom/one-image.mk index 59a3259c99..2b9749dcea 100644 --- a/platform/broadcom/one-image.mk +++ b/platform/broadcom/one-image.mk @@ -45,6 +45,8 @@ $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \ $(ACCTON_AS5835_54T_PLATFORM_MODULE) \ $(ACCTON_AS7312_54XS_PLATFORM_MODULE) \ $(ACCTON_AS7315_27XB_PLATFORM_MODULE) \ + $(ACCTON_AS4625_54P_PLATFORM_MODULE) \ + $(ACCTON_AS4625_54T_PLATFORM_MODULE) \ $(INVENTEC_D7032Q28B_PLATFORM_MODULE) \ $(INVENTEC_D7054Q28B_PLATFORM_MODULE) \ $(INVENTEC_D7264Q28B_PLATFORM_MODULE) \ diff --git a/platform/broadcom/platform-modules-accton.mk b/platform/broadcom/platform-modules-accton.mk index 85e7ff1f56..f812fa92d5 100755 --- a/platform/broadcom/platform-modules-accton.mk +++ b/platform/broadcom/platform-modules-accton.mk @@ -20,6 +20,8 @@ ACCTON_AS9726_32D_PLATFORM_MODULE_VERSION = 1.1 ACCTON_AS5835_54T_PLATFORM_MODULE_VERSION = 1.1 ACCTON_AS7312_54XS_PLATFORM_MODULE_VERSION = 1.1 ACCTON_AS7315_27XB_PLATFORM_MODULE_VERSION = 1.1 +ACCTON_AS4625_54P_PLATFORM_MODULE_VERSION = 1.1 +ACCTON_AS4625_54T_PLATFORM_MODULE_VERSION = 1.1 export ACCTON_AS7712_32X_PLATFORM_MODULE_VERSION export ACCTON_AS5712_54X_PLATFORM_MODULE_VERSION @@ -41,6 +43,8 @@ export ACCTON_AS9726_32D_PLATFORM_MODULE_VERSION export ACCTON_AS5835_54T_PLATFORM_MODULE_VERSION export ACCTON_AS7312_54XS_PLATFORM_MODULE_VERSION export ACCTON_AS7315_27XB_PLATFORM_MODULE_VERSION +export ACCTON_AS4625_54P_PLATFORM_MODULE_VERSION +export ACCTON_AS4625_54T_PLATFORM_MODULE_VERSION ACCTON_AS7712_32X_PLATFORM_MODULE = sonic-platform-accton-as7712-32x_$(ACCTON_AS7712_32X_PLATFORM_MODULE_VERSION)_amd64.deb $(ACCTON_AS7712_32X_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-accton @@ -123,3 +127,11 @@ $(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_AS ACCTON_AS7315_27XB_PLATFORM_MODULE = sonic-platform-accton-as7315-27xb_$(ACCTON_AS7315_27XB_PLATFORM_MODULE_VERSION)_amd64.deb $(ACCTON_AS7315_27XB_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as7315_27xb-r0 $(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_AS7315_27XB_PLATFORM_MODULE))) + +ACCTON_AS4625_54P_PLATFORM_MODULE = sonic-platform-accton-as4625-54p_$(ACCTON_AS4625_54P_PLATFORM_MODULE_VERSION)_amd64.deb +$(ACCTON_AS4625_54P_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as4625_54p-r0 +$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_AS4625_54P_PLATFORM_MODULE))) + +ACCTON_AS4625_54T_PLATFORM_MODULE = sonic-platform-accton-as4625-54t_$(ACCTON_AS4625_54T_PLATFORM_MODULE_VERSION)_amd64.deb +$(ACCTON_AS4625_54T_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as4625_54t-r0 +$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_AS4625_54T_PLATFORM_MODULE))) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54p/classes/__init__.py b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/classes/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/Makefile b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/Makefile new file mode 100644 index 0000000000..d8965ece86 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/Makefile @@ -0,0 +1,16 @@ +ifneq ($(KERNELRELEASE),) +obj-m:= x86-64-accton-as4625-54p-cpld.o x86-64-accton-as4625-54p-fan.o \ + x86-64-accton-as4625-54p-psu.o x86-64-accton-as4625-54p-leds.o ym2651y.o + +else +ifeq (,$(KERNEL_SRC)) +$(error KERNEL_SRC is not defined) +else +KERNELDIR:=$(KERNEL_SRC) +endif +PWD:=$(shell pwd) +default: + $(MAKE) -C $(KERNELDIR) M=$(PWD) modules +clean: + rm -rf *.o *.mod.o *.mod.o *.ko .*cmd .tmp_versions Module.markers Module.symvers modules.order +endif diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-cpld.c b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-cpld.c new file mode 100644 index 0000000000..5c5ff42b2d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-cpld.c @@ -0,0 +1,571 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as4625 CPLD1/CPLD2/CPLD3 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +enum cpld_type { + as4625_cpld1 +}; + +struct as4625_cpld_data { + enum cpld_type type; + struct device *hwmon_dev; + struct mutex update_lock; +}; + +static const struct i2c_device_id as4625_cpld_id[] = { + { "as4625_cpld1", as4625_cpld1 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, as4625_cpld_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as4625_cpld_sysfs_attributes { + VERSION_MAJOR, + VERSION_MINOR, + PCB_ID, + PCB_VERSION, + POWER_ENABLE_MAINBOARD, + POWER_ENABLE_POE, + ACCESS, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_TXDISABLE_ATTR_ID(49), + TRANSCEIVER_TXDISABLE_ATTR_ID(50), + TRANSCEIVER_TXDISABLE_ATTR_ID(51), + TRANSCEIVER_TXDISABLE_ATTR_ID(52), + TRANSCEIVER_TXDISABLE_ATTR_ID(53), + TRANSCEIVER_TXDISABLE_ATTR_ID(54), + TRANSCEIVER_RXLOS_ATTR_ID(49), + TRANSCEIVER_RXLOS_ATTR_ID(50), + TRANSCEIVER_RXLOS_ATTR_ID(51), + TRANSCEIVER_RXLOS_ATTR_ID(52), + TRANSCEIVER_RXLOS_ATTR_ID(53), + TRANSCEIVER_RXLOS_ATTR_ID(54), + TRANSCEIVER_TXFAULT_ATTR_ID(49), + TRANSCEIVER_TXFAULT_ATTR_ID(50), + TRANSCEIVER_TXFAULT_ATTR_ID(51), + TRANSCEIVER_TXFAULT_ATTR_ID(52), + TRANSCEIVER_TXFAULT_ATTR_ID(53), + TRANSCEIVER_TXFAULT_ATTR_ID(54) +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t set_control(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as4625_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as4625_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_control, MODULE_TXDISABLE_##index); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index) +#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_present_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version_major, S_IRUGO, show_version, NULL, VERSION_MAJOR); +static SENSOR_DEVICE_ATTR(version_minor, S_IRUGO, show_version, NULL, VERSION_MINOR); +static SENSOR_DEVICE_ATTR(pcb_id, S_IRUGO, show_version, NULL, PCB_ID); +static SENSOR_DEVICE_ATTR(pcb_version, S_IRUGO, show_version, NULL, PCB_VERSION); +static SENSOR_DEVICE_ATTR(pwr_enable_mb, S_IRUGO | S_IWUSR, show_status, set_control, POWER_ENABLE_MAINBOARD); +static SENSOR_DEVICE_ATTR(pwr_enable_poe, S_IRUGO | S_IWUSR, show_status, set_control, POWER_ENABLE_POE); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); + +/* transceiver attributes */ +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(49); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(50); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(51); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(52); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(53); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(54); + +static struct attribute *as4625_cpld1_attributes[] = { + &sensor_dev_attr_version_major.dev_attr.attr, + &sensor_dev_attr_version_minor.dev_attr.attr, + &sensor_dev_attr_pcb_id.dev_attr.attr, + &sensor_dev_attr_pcb_version.dev_attr.attr, + &sensor_dev_attr_pwr_enable_mb.dev_attr.attr, + &sensor_dev_attr_pwr_enable_poe.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + DECLARE_SFP_TRANSCEIVER_ATTR(49), + DECLARE_SFP_TRANSCEIVER_ATTR(50), + DECLARE_SFP_TRANSCEIVER_ATTR(51), + DECLARE_SFP_TRANSCEIVER_ATTR(52), + DECLARE_SFP_TRANSCEIVER_ATTR(53), + DECLARE_SFP_TRANSCEIVER_ATTR(54), + NULL +}; + +static const struct attribute_group as4625_cpld1_group = { + .attrs = as4625_cpld1_attributes, +}; + +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as4625_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0, reverse = 0; + + switch (attr->index) { + case MODULE_TXDISABLE_49 ... MODULE_TXDISABLE_54: + reg = 0x5; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_49); + break; + case MODULE_PRESENT_49 ... MODULE_PRESENT_54: + reg = 0x6; + mask = 0x1 << (attr->index - MODULE_PRESENT_49); + reverse = 1; + break; + case MODULE_RXLOS_49 ... MODULE_RXLOS_54: + reg = 0x7; + mask = 0x1 << (attr->index - MODULE_RXLOS_49); + break; + case MODULE_TXFAULT_49 ... MODULE_TXFAULT_54: + reg = 0x8; + mask = 0x1 << (attr->index - MODULE_TXFAULT_49); + break; + case POWER_ENABLE_MAINBOARD: + reg = 0x3; + mask = 0x1; + reverse = 1; + break; + case POWER_ENABLE_POE: + reg = 0x21; + mask = 0x1; + break; + default: + return 0; + } + + mutex_lock(&data->update_lock); + status = as4625_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", reverse ? !(status & mask) : !!(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t set_control(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as4625_cpld_data *data = i2c_get_clientdata(client); + long value; + int status; + u8 reg = 0, mask = 0; + + status = kstrtol(buf, 10, &value); + if (status) { + return status; + } + + switch (attr->index) { + case MODULE_TXDISABLE_49 ... MODULE_TXDISABLE_54: + reg = 0x5; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_49); + break; + case POWER_ENABLE_MAINBOARD: + reg = 0x3; + mask = 0x1; + value = !value; + break; + case POWER_ENABLE_POE: + reg = 0x21; + mask = 0x1; + break; + default: + return -EINVAL; + } + + /* Read current status */ + mutex_lock(&data->update_lock); + status = as4625_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + + /* Update tx_disable status */ + if (value) + status |= mask; + else + status &= ~mask; + + status = as4625_cpld_write_internal(client, reg, status); + if (unlikely(status < 0)) { + goto exit; + } + + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as4625_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as4625_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static void as4625_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as4625_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf) +{ + int val = 0, reg = 0; + struct i2c_client *client = to_i2c_client(dev); + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + switch (attr->index) { + case PCB_ID: + case PCB_VERSION: + reg = 0x0; + break; + case VERSION_MAJOR: + reg = 0x1; + break; + case VERSION_MINOR: + reg = 0x2; + break; + default: + break; + } + + val = i2c_smbus_read_byte_data(client, reg); + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", + client->addr, val); + return val; + } + + if (attr->index == PCB_ID) + val = (val >> 3) & 0x7; /* bit 3-5 */ + else if (attr->index == PCB_VERSION) + val &= 0x7; /* bit 0-2 */ + + return sprintf(buf, "%d\n", val); +} + +/* + * I2C init/probing/exit functions + */ +static int as4625_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + struct as4625_cpld_data *data; + int ret = -ENODEV; + const struct attribute_group *group = NULL; + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto exit; + + data = kzalloc(sizeof(struct as4625_cpld_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->type = id->driver_data; + + /* Register sysfs hooks */ + switch (data->type) { + case as4625_cpld1: + group = &as4625_cpld1_group; + break; + default: + break; + } + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_free; + } + } + + as4625_cpld_add_client(client); + return 0; + +exit_free: + kfree(data); +exit: + return ret; +} + +static int as4625_cpld_remove(struct i2c_client *client) +{ + struct as4625_cpld_data *data = i2c_get_clientdata(client); + const struct attribute_group *group = NULL; + + as4625_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as4625_cpld1: + group = &as4625_cpld1_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } + + kfree(data); + return 0; +} + +static int as4625_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as4625_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as4625_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as4625_cpld_read_internal(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as4625_cpld_read); + +int as4625_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as4625_cpld_write_internal(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as4625_cpld_write); + +static struct i2c_driver as4625_cpld_driver = { + .driver = { + .name = "as4625_cpld", + .owner = THIS_MODULE, + }, + .probe = as4625_cpld_probe, + .remove = as4625_cpld_remove, + .id_table = as4625_cpld_id, +}; + +static int __init as4625_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as4625_cpld_driver); +} + +static void __exit as4625_cpld_exit(void) +{ + i2c_del_driver(&as4625_cpld_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("Accton I2C CPLD driver"); +MODULE_LICENSE("GPL"); + +module_init(as4625_cpld_init); +module_exit(as4625_cpld_exit); diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-fan.c b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-fan.c new file mode 100644 index 0000000000..7bc0d5b838 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-fan.c @@ -0,0 +1,416 @@ +/* + * A hwmon driver for the Accton as4625 fan + * + * Copyright (C) 2016 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as4625_fan" + +#define FAN_STATUS_I2C_ADDR 0x64 + +static struct as4625_fan_data *as4625_fan_update_device(struct device *dev); +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +extern int as4625_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as4625_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +/* fan related data, the index should match sysfs_fan_attributes + */ +static const u8 fan_reg[] = { + 0x40, /* fan-1 PWM */ + 0x41, /* fan-2 PWM */ + 0x42, /* fan-3 PWM */ + 0x46, /* fan-1 speed(rpm) */ + 0x47, /* fan-2 speed(rpm) */ + 0x48, /* fan-3 speed(rpm) */ + 0x00 /* fan direction, 001: AS4625-54T (F2B), 010: AS4625-54T (B2F) */ +}; + +static const int fan_target_speed_f2b[] = { + 0, 1350, 2550, 3900, 6450, 7800, 9150, 10500, + 11850, 13050, 14400, 15600, 16950, 18150, 19650, 23000 +}; + +static const int fan_target_speed_b2f[] = { + 0, 3150, 5850, 8100, 12150, 13650, 15000, 16350, + 17850, 19050, 19950, 20700, 21450, 22200, 22800, 23400 +}; + +/* fan data */ +struct as4625_fan_data { + struct platform_device *pdev; + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */ +}; + +struct as4625_fan_data *data = NULL; + +enum fan_id { + FAN1_ID, + FAN2_ID, + FAN3_ID +}; + +enum sysfs_fan_attributes { + FAN1_PWM, + FAN2_PWM, + FAN3_PWM, + FAN1_INPUT, + FAN2_INPUT, + FAN3_INPUT, + FAN1_FAULT, + FAN2_FAULT, + FAN3_FAULT, + FAN1_DIR, + FAN2_DIR, + FAN3_DIR, + FAN1_TARGET_RPM, + FAN2_TARGET_RPM, + FAN3_TARGET_RPM +}; + +/* Define attributes + */ +#define DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_fault, S_IRUGO, fan_show_value, NULL, FAN##index##_FAULT) +#define DECLARE_FAN_FAULT_ATTR(index) &sensor_dev_attr_fan##index##_fault.dev_attr.attr + +#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_pwm, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_PWM) +#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_pwm.dev_attr.attr + +#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_input, S_IRUGO, fan_show_value, NULL, FAN##index##_INPUT) +#define DECLARE_FAN_SPEED_RPM_ATTR(index) &sensor_dev_attr_fan##index##_input.dev_attr.attr + +#define DECLARE_FAN_DIR_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_dir, S_IRUGO, fan_show_value, NULL, FAN##index##_DIR) +#define DECLARE_FAN_DIR_ATTR(index) &sensor_dev_attr_fan##index##_dir.dev_attr.attr + +#define DECLARE_FAN_TARGET_RPM_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_target_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_TARGET_RPM) +#define DECLARE_FAN_TARGET_RPM_ATTR(index) &sensor_dev_attr_fan##index##_target_rpm.dev_attr.attr + +/* 3 fan fault attributes in this platform */ +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3); + +/* 3 fan speed(rpm) attributes in this platform */ +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3); + +/* 3 fan duty cycle attribute in this platform */ +DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(1); +DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(2); +DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(3); + +/* 3 fan direction attribute in this platform */ +DECLARE_FAN_DIR_SENSOR_DEV_ATTR(1); +DECLARE_FAN_DIR_SENSOR_DEV_ATTR(2); +DECLARE_FAN_DIR_SENSOR_DEV_ATTR(3); + +/* 3 fan target speed attribute in this platform */ +DECLARE_FAN_TARGET_RPM_SENSOR_DEV_ATTR(1); +DECLARE_FAN_TARGET_RPM_SENSOR_DEV_ATTR(2); +DECLARE_FAN_TARGET_RPM_SENSOR_DEV_ATTR(3); + +static struct attribute *as4625_fan_attributes[] = { + /* fan related attributes */ + DECLARE_FAN_FAULT_ATTR(1), + DECLARE_FAN_FAULT_ATTR(2), + DECLARE_FAN_FAULT_ATTR(3), + DECLARE_FAN_DUTY_CYCLE_ATTR(1), + DECLARE_FAN_DUTY_CYCLE_ATTR(2), + DECLARE_FAN_DUTY_CYCLE_ATTR(3), + DECLARE_FAN_SPEED_RPM_ATTR(1), + DECLARE_FAN_SPEED_RPM_ATTR(2), + DECLARE_FAN_SPEED_RPM_ATTR(3), + DECLARE_FAN_DIR_ATTR(1), + DECLARE_FAN_DIR_ATTR(2), + DECLARE_FAN_DIR_ATTR(3), + DECLARE_FAN_TARGET_RPM_ATTR(1), + DECLARE_FAN_TARGET_RPM_ATTR(2), + DECLARE_FAN_TARGET_RPM_ATTR(3), + NULL +}; + +#define FAN_DUTY_CYCLE_REG_MASK 0x0F +#define FAN_MAX_DUTY_CYCLE 100 +#define FAN_REG_VAL_TO_SPEED_RPM_STEP 150 + +static int as4625_fan_read_value(u8 reg) +{ + return as4625_cpld_read(FAN_STATUS_I2C_ADDR, reg); +} + +static int as4625_fan_write_value(u8 reg, u8 value) +{ + return as4625_cpld_write(FAN_STATUS_I2C_ADDR, reg, value); +} + +/* fan utility functions + */ +static u32 reg_val_to_duty_cycle(u8 reg_val) +{ + reg_val &= FAN_DUTY_CYCLE_REG_MASK; + return (u32)(reg_val+1) * 625 / 100; +} + +static u8 duty_cycle_to_reg_val(u8 duty_cycle) +{ + if (duty_cycle == 0) { + return 0; + } + else if (duty_cycle > FAN_MAX_DUTY_CYCLE) { + duty_cycle = FAN_MAX_DUTY_CYCLE; + } + + return ((u32)duty_cycle * 100 / 625) - 1; +} + +static u32 reg_val_to_speed_rpm(u8 reg_val) +{ + return (u32)reg_val * FAN_REG_VAL_TO_SPEED_RPM_STEP; +} + +static u8 is_fan_fault(struct as4625_fan_data *data, enum fan_id id) +{ + return !reg_val_to_speed_rpm(data->reg_val[FAN1_INPUT + id]); +} + +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int error, value, reg; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + error = kstrtoint(buf, 10, &value); + if (error) + return error; + + if (value < 0 || value > FAN_MAX_DUTY_CYCLE) + return -EINVAL; + + mutex_lock(&data->update_lock); + + reg = fan_reg[attr->index - FAN1_PWM]; + as4625_fan_write_value(reg, duty_cycle_to_reg_val(value)); + data->valid = 0; + + mutex_unlock(&data->update_lock); + return count; +} + +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + ssize_t ret = 0; + + mutex_lock(&data->update_lock); + + data = as4625_fan_update_device(dev); + if (data->valid) { + switch (attr->index) { + case FAN1_PWM: + case FAN2_PWM: + case FAN3_PWM: + { + u32 duty_cycle; + duty_cycle = reg_val_to_duty_cycle(data->reg_val[attr->index]); + ret = sprintf(buf, "%u\n", duty_cycle); + break; + } + case FAN1_INPUT: + case FAN2_INPUT: + case FAN3_INPUT: + ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index])); + break; + case FAN1_FAULT: + case FAN2_FAULT: + case FAN3_FAULT: + ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT)); + break; + case FAN1_DIR: + case FAN2_DIR: + case FAN3_DIR: + { + u8 board_id = (data->reg_val[6] >> 3) & 0x7; + ret = sprintf(buf, "%s\n", (board_id == 2) ? "B2F" : "F2B"); + break; + } + case FAN1_TARGET_RPM: + case FAN2_TARGET_RPM: + case FAN3_TARGET_RPM: + { + u8 board_id = (data->reg_val[6] >> 3) & 0x7; + const int *target = NULL; + int pwm_index = FAN1_PWM + (attr->index - FAN1_TARGET_RPM); + target = (board_id == 2) ? fan_target_speed_b2f : fan_target_speed_f2b; + ret = sprintf(buf, "%d\n", target[data->reg_val[pwm_index] & 0xF]); + break; + } + default: + break; + } + } + + mutex_unlock(&data->update_lock); + + return ret; +} + +static const struct attribute_group as4625_fan_group = { + .attrs = as4625_fan_attributes, +}; + +static struct as4625_fan_data *as4625_fan_update_device(struct device *dev) +{ + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || + !data->valid) { + int i; + + dev_dbg(&data->pdev->dev, "Starting as4625_fan update\n"); + data->valid = 0; + + /* Update fan data + */ + for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) { + int status = as4625_fan_read_value(fan_reg[i]); + + if (status < 0) { + data->valid = 0; + mutex_unlock(&data->update_lock); + dev_dbg(&data->pdev->dev, "reg %d, err %d\n", fan_reg[i], status); + return data; + } + else { + data->reg_val[i] = status; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + return data; +} + +static int as4625_fan_probe(struct platform_device *pdev) +{ + int status; + + data->hwmon_dev = hwmon_device_register_with_info(&pdev->dev, + DRVNAME, NULL, NULL, NULL); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + return status; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&data->hwmon_dev->kobj, &as4625_fan_group); + if (status) + goto exit_remove; + + dev_info(&pdev->dev, "device created\n"); + return 0; + +exit_remove: + hwmon_device_unregister(data->hwmon_dev); + return status; +} + +static int as4625_fan_remove(struct platform_device *pdev) +{ + sysfs_remove_group(&data->hwmon_dev->kobj, &as4625_fan_group); + hwmon_device_unregister(data->hwmon_dev); + return 0; +} + +static struct platform_driver as4625_fan_driver = { + .probe = as4625_fan_probe, + .remove = as4625_fan_remove, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +static int __init as4625_fan_init(void) +{ + int ret; + + data = kzalloc(sizeof(struct as4625_fan_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto alloc_err; + } + + mutex_init(&data->update_lock); + data->valid = 0; + + ret = platform_driver_register(&as4625_fan_driver); + if (ret < 0) + goto dri_reg_err; + + data->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(data->pdev)) { + ret = PTR_ERR(data->pdev); + goto dev_reg_err; + } + + return 0; + +dev_reg_err: + platform_driver_unregister(&as4625_fan_driver); +dri_reg_err: + kfree(data); +alloc_err: + return ret; +} + +static void __exit as4625_fan_exit(void) +{ + platform_device_unregister(data->pdev); + platform_driver_unregister(&as4625_fan_driver); + kfree(data); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as4625_fan driver"); +MODULE_LICENSE("GPL"); + +module_init(as4625_fan_init); +module_exit(as4625_fan_exit); diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-leds.c b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-leds.c new file mode 100644 index 0000000000..dfb6388598 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-leds.c @@ -0,0 +1,403 @@ +/* + * A LED driver for the as4625_led + * + * Copyright (C) 2016 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as4625_led" + +extern int as4625_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as4625_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +struct as4625_led_data { + struct platform_device *pdev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[2]; /* Register value, 0 = System/LOC/PSU0 LED + 1 = PSU1/FAN/POE LED */ +}; + +static struct as4625_led_data *ledctl = NULL; + +#define LED_CNTRLER_I2C_ADDRESS (0x64) + +#define LED_TYPE_SYS_REG_MASK (0xF0) +#define LED_MODE_SYS_GREEN_BLINK_VALUE (0x60) +#define LED_MODE_SYS_GREEN_VALUE (0x20) +#define LED_MODE_SYS_AMBER_VALUE (0x80) +#define LED_MODE_SYS_AMBER_BLINK_VALUE (0x90) +#define LED_MODE_SYS_OFF_VALUE (0x00) + +#define LED_TYPE_LOC_REG_MASK (0x0C) +#define LED_MODE_LOC_GREEN_VALUE (0x04) +#define LED_MODE_LOC_AMBER_VALUE (0x08) +#define LED_MODE_LOC_OFF_VALUE (0x00) +#define LED_MODE_LOC_OFF_VALUE_1 (0x0C) + +#define LED_TYPE_POE_REG_MASK (0x03) +#define LED_MODE_POE_OFF_VALUE (0x00) +#define LED_MODE_POE_OFF_VALUE_1 (0x03) +#define LED_MODE_POE_GREEN_VALUE (0x01) +#define LED_MODE_POE_AMBER_VALUE (0x02) + +static const u8 led_reg[] = { + 0x30, /* System/LOC/PSU0 LED */ + 0x31 /* PSU1/FAN/POE LED */ +}; + +enum led_type { + LED_TYPE_SYS, + LED_TYPE_LOC, + LED_TYPE_PSU1, + LED_TYPE_PSU2, + LED_TYPE_FAN, + LED_TYPE_POE +}; + +/* FAN/PSU/DIAG/RELEASE led mode */ +enum led_light_mode { + LED_MODE_OFF = 0, + LED_MODE_GREEN, + LED_MODE_GREEN_BLINK, + LED_MODE_AMBER, + LED_MODE_AMBER_BLINK, + LED_MODE_RED, + LED_MODE_RED_BLINK, + LED_MODE_BLUE, + LED_MODE_BLUE_BLINK, + LED_MODE_AUTO, + LED_MODE_UNKNOWN +}; + +struct led_type_mode { + enum led_type type; + enum led_light_mode mode; + int type_mask; + int mode_value; +}; + +static struct led_type_mode led_type_mode_data[] = { + {LED_TYPE_SYS, LED_MODE_GREEN_BLINK, LED_TYPE_SYS_REG_MASK, LED_MODE_SYS_GREEN_BLINK_VALUE}, + {LED_TYPE_SYS, LED_MODE_GREEN, LED_TYPE_SYS_REG_MASK, LED_MODE_SYS_GREEN_VALUE}, + {LED_TYPE_SYS, LED_MODE_AMBER_BLINK, LED_TYPE_SYS_REG_MASK, LED_MODE_SYS_AMBER_BLINK_VALUE}, + {LED_TYPE_SYS, LED_MODE_AMBER, LED_TYPE_SYS_REG_MASK, LED_MODE_SYS_AMBER_VALUE}, + {LED_TYPE_SYS, LED_MODE_OFF, LED_TYPE_SYS_REG_MASK, LED_MODE_SYS_OFF_VALUE}, + {LED_TYPE_LOC, LED_MODE_OFF, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_OFF_VALUE}, + {LED_TYPE_LOC, LED_MODE_OFF, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_OFF_VALUE_1}, + {LED_TYPE_LOC, LED_MODE_GREEN, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_GREEN_VALUE}, + {LED_TYPE_LOC, LED_MODE_AMBER, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_AMBER_VALUE}, + {LED_TYPE_POE, LED_MODE_OFF, LED_TYPE_POE_REG_MASK, LED_MODE_POE_OFF_VALUE}, + {LED_TYPE_POE, LED_MODE_OFF, LED_TYPE_POE_REG_MASK, LED_MODE_POE_OFF_VALUE_1}, + {LED_TYPE_POE, LED_MODE_GREEN, LED_TYPE_POE_REG_MASK, LED_MODE_POE_GREEN_VALUE}, + {LED_TYPE_POE, LED_MODE_AMBER, LED_TYPE_POE_REG_MASK, LED_MODE_POE_AMBER_VALUE} +}; + +static int led_reg_val_to_light_mode(enum led_type type, u8 reg_val) { + int i; + + for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { + if (type != led_type_mode_data[i].type) { + continue; + } + + if ((led_type_mode_data[i].type_mask & reg_val) == + led_type_mode_data[i].mode_value) { + return led_type_mode_data[i].mode; + } + } + + return LED_MODE_UNKNOWN; +} + +static u8 led_light_mode_to_reg_val(enum led_type type, + enum led_light_mode mode, u8 reg_val) { + int i; + + for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { + int type_mask, mode_value; + + if (type != led_type_mode_data[i].type) + continue; + + if (mode != led_type_mode_data[i].mode) + continue; + + type_mask = led_type_mode_data[i].type_mask; + mode_value = led_type_mode_data[i].mode_value; + reg_val = (reg_val & ~type_mask) | mode_value; + } + + return reg_val; +} + +static int as4625_led_read_value(u8 reg) +{ + return as4625_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); +} + +static int as4625_led_write_value(u8 reg, u8 value) +{ + return as4625_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); +} + +static void as4625_led_update(void) +{ + mutex_lock(&ledctl->update_lock); + + if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2) + || !ledctl->valid) { + int i; + + dev_dbg(&ledctl->pdev->dev, "Starting as4625_led update\n"); + ledctl->valid = 0; + + /* Update LED data + */ + for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { + int status = as4625_led_read_value(led_reg[i]); + + if (status < 0) { + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg[i], status); + goto exit; + } + else { + ledctl->reg_val[i] = status; + } + } + + ledctl->last_updated = jiffies; + ledctl->valid = 1; + } + +exit: + mutex_unlock(&ledctl->update_lock); +} + +static void as4625_led_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode, + u8 reg, enum led_type type) +{ + int reg_val; + + mutex_lock(&ledctl->update_lock); + reg_val = as4625_led_read_value(reg); + + if (reg_val < 0) { + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val); + goto exit; + } + + reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val); + as4625_led_write_value(reg, reg_val); + ledctl->valid = 0; + +exit: + mutex_unlock(&ledctl->update_lock); +} + +static void as4625_led_auto_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ +} + +static enum led_brightness as4625_led_auto_get(struct led_classdev *cdev) +{ + return LED_MODE_AUTO; +} + +static void as4625_led_sys_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + as4625_led_set(led_cdev, led_light_mode, led_reg[0], LED_TYPE_SYS); +} + +static enum led_brightness as4625_led_sys_get(struct led_classdev *cdev) +{ + as4625_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_SYS, ledctl->reg_val[0]); +} + +static enum led_brightness as4625_led_loc_get(struct led_classdev *cdev) +{ + as4625_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[0]); +} + +static void as4625_led_loc_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + as4625_led_set(led_cdev, led_light_mode, led_reg[0], LED_TYPE_LOC); +} + +static enum led_brightness as4625_led_poe_get(struct led_classdev *cdev) +{ + as4625_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_POE, ledctl->reg_val[1]); +} + +static void as4625_led_poe_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + as4625_led_set(led_cdev, led_light_mode, led_reg[1], LED_TYPE_POE); +} + +static struct led_classdev as4625_leds[] = { + [LED_TYPE_SYS] = { + .name = "as4625_led::sys", + .default_trigger = "unused", + .brightness_set = as4625_led_sys_set, + .brightness_get = as4625_led_sys_get, + .max_brightness = LED_MODE_AMBER_BLINK, + }, + [LED_TYPE_LOC] = { + .name = "as4625_led::loc", + .default_trigger = "unused", + .brightness_set = as4625_led_loc_set, + .brightness_get = as4625_led_loc_get, + .max_brightness = LED_MODE_AMBER, + }, + [LED_TYPE_PSU1] = { + .name = "as4625_led::psu1", + .default_trigger = "unused", + .brightness_set = as4625_led_auto_set, + .brightness_get = as4625_led_auto_get, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_PSU2] = { + .name = "as4625_led::psu2", + .default_trigger = "unused", + .brightness_set = as4625_led_auto_set, + .brightness_get = as4625_led_auto_get, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_FAN] = { + .name = "as4625_led::fan", + .default_trigger = "unused", + .brightness_set = as4625_led_auto_set, + .brightness_get = as4625_led_auto_get, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_POE] = { + .name = "as4625_led::poe", + .default_trigger = "unused", + .brightness_set = as4625_led_poe_set, + .brightness_get = as4625_led_poe_get, + .max_brightness = LED_MODE_AMBER, + } +}; + +static int as4625_led_probe(struct platform_device *pdev) +{ + int ret, i; + + for (i = 0; i < ARRAY_SIZE(as4625_leds); i++) { + ret = led_classdev_register(&pdev->dev, &as4625_leds[i]); + + if (ret < 0) { + break; + } + } + + /* Check if all LEDs were successfully registered */ + if (i != ARRAY_SIZE(as4625_leds)){ + int j; + + /* only unregister the LEDs that were successfully registered */ + for (j = 0; j < i; j++) { + led_classdev_unregister(&as4625_leds[i]); + } + } + + return ret; +} + +static int as4625_led_remove(struct platform_device *pdev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(as4625_leds); i++) { + led_classdev_unregister(&as4625_leds[i]); + } + + return 0; +} + +static struct platform_driver as4625_led_driver = { + .probe = as4625_led_probe, + .remove = as4625_led_remove, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +static int __init as4625_led_init(void) +{ + int ret; + + ret = platform_driver_register(&as4625_led_driver); + if (ret < 0) { + goto exit; + } + + ledctl = kzalloc(sizeof(struct as4625_led_data), GFP_KERNEL); + if (!ledctl) { + ret = -ENOMEM; + goto exit_driver; + } + + mutex_init(&ledctl->update_lock); + + ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(ledctl->pdev)) { + ret = PTR_ERR(ledctl->pdev); + goto exit_free; + } + + return 0; + +exit_free: + kfree(ledctl); +exit_driver: + platform_driver_unregister(&as4625_led_driver); +exit: + return ret; +} + +static void __exit as4625_led_exit(void) +{ + platform_device_unregister(ledctl->pdev); + platform_driver_unregister(&as4625_led_driver); + kfree(ledctl); +} + +late_initcall(as4625_led_init); +module_exit(as4625_led_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as4625_led driver"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-psu.c b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-psu.c new file mode 100644 index 0000000000..1dccbb2632 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-psu.c @@ -0,0 +1,389 @@ +/* + * An hwmon driver for accton as4625_54p Power Module + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define __STDC_WANT_LIB_EXT1__ 1 +#include + +#define DRVNAME "as4625_54p_psu" + +#define PSU_STATUS_I2C_ADDR 0x64 +#define PSU_STATUS_I2C_REG_OFFSET 0x4 + +#define MODEL_NAME_LEN 13 +#define MODEL_NAME_REG_OFFSET 0x15 + +#define SERIAL_NUM_LEN 9 +#define SERIAL_NUM_REG_OFFSET 0x35 + +#define IS_POWER_GOOD(id, value) (!!(value & BIT(id*4+2))) +#define IS_PRESENT(id, value) (!(value & BIT(id*4))) + +#define FAN_DIR_LEN 3 +const char FAN_DIR_F2B[] = "F2B"; +const char FAN_DIR_B2F[] = "B2F"; + +static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_string(struct device *dev, struct device_attribute *da, char *buf); +extern int as4625_cpld_read(unsigned short cpld_addr, u8 reg); + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +/* Each client has this additional data + */ +struct as4625_54p_psu_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 index; /* PSU index */ + u8 status; /* Status(present/power_good) register read from CPLD */ + char model_name[MODEL_NAME_LEN+1]; /* Model name, read from eeprom */ + char serial[SERIAL_NUM_LEN+1]; /* Serial number, read from eeprom*/ + char fan_dir[FAN_DIR_LEN+1]; +}; + +static struct as4625_54p_psu_data *as4625_54p_psu_update_device(struct device *dev); + +enum as4625_54p_psu_sysfs_attributes { + PSU_PRESENT, + PSU_MODEL_NAME, + PSU_POWER_GOOD, + PSU_SERIAL_NUMBER, + PSU_FAN_DIR +}; + +/* sysfs attributes for hwmon + */ +static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); +static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_string, NULL, PSU_MODEL_NAME); +static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); +static SENSOR_DEVICE_ATTR(psu_serial_numer, S_IRUGO, show_string, NULL, PSU_SERIAL_NUMBER); +static SENSOR_DEVICE_ATTR(psu_fan_dir, S_IRUGO, show_string, NULL, PSU_FAN_DIR); + +static struct attribute *as4625_54p_psu_attributes[] = { + &sensor_dev_attr_psu_present.dev_attr.attr, + &sensor_dev_attr_psu_model_name.dev_attr.attr, + &sensor_dev_attr_psu_power_good.dev_attr.attr, + &sensor_dev_attr_psu_serial_numer.dev_attr.attr, + &sensor_dev_attr_psu_fan_dir.dev_attr.attr, + NULL +}; + +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as4625_54p_psu_data *data = i2c_get_clientdata(client); + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + u8 status = 0; + + mutex_lock(&data->update_lock); + + data = as4625_54p_psu_update_device(dev); + if (!data->valid) { + mutex_unlock(&data->update_lock); + return sprintf(buf, "0\n"); + } + + if (attr->index == PSU_PRESENT) { + status = IS_PRESENT(data->index, data->status); + } + else { /* PSU_POWER_GOOD */ + status = IS_POWER_GOOD(data->index, data->status); + } + + mutex_unlock(&data->update_lock); + return sprintf(buf, "%d\n", status); +} + +static ssize_t show_string(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as4625_54p_psu_data *data = i2c_get_clientdata(client); + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + char *ptr = NULL; + int ret = 0; + + mutex_lock(&data->update_lock); + + data = as4625_54p_psu_update_device(dev); + if (!data->valid) { + ret = -EIO; + goto exit; + } + + switch (attr->index) { + case PSU_MODEL_NAME: + ptr = data->model_name; + break; + case PSU_SERIAL_NUMBER: + ptr = data->serial; + break; + case PSU_FAN_DIR: + ptr = data->fan_dir; + break; + default: + ret = -EINVAL; + goto exit; + } + + ret = sprintf(buf, "%s\n", ptr); + +exit: + mutex_unlock(&data->update_lock); + return ret; +} + +static const struct attribute_group as4625_54p_psu_group = { + .attrs = as4625_54p_psu_attributes, +}; + +static int as4625_54p_psu_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as4625_54p_psu_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as4625_54p_psu_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + data->valid = 0; + data->index = dev_id->driver_data; + mutex_init(&data->update_lock); + i2c_set_clientdata(client, data); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as4625_54p_psu_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register_with_info(&client->dev, + DRVNAME, NULL, NULL, NULL); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: psu '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as4625_54p_psu_group); +exit_free: + kfree(data); +exit: + return status; +} + +static int as4625_54p_psu_remove(struct i2c_client *client) +{ + struct as4625_54p_psu_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as4625_54p_psu_group); + kfree(data); + + return 0; +} + +enum psu_index +{ + as4625_54p_psu1, + as4625_54p_psu2 +}; + +static const struct i2c_device_id as4625_54p_psu_id[] = { + { "as4625_54p_psu1", as4625_54p_psu1 }, + { "as4625_54p_psu2", as4625_54p_psu2 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as4625_54p_psu_id); + +static struct i2c_driver as4625_54p_psu_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = DRVNAME, + }, + .probe = as4625_54p_psu_probe, + .remove = as4625_54p_psu_remove, + .id_table = as4625_54p_psu_id, + .address_list = normal_i2c, +}; + +static int as4625_54p_psu_read_byte(struct i2c_client *client, u8 command, u8 *data) +{ + int status = 0; + int retry_count = 5; + + while (retry_count) { + status = i2c_smbus_read_byte_data(client, command); + if (unlikely(status < 0)) { + msleep(10); + retry_count--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); + goto abort; + } + + *data = (u8)status; + +abort: + return status; +} + +static int as4625_54p_psu_read_bytes(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ + int ret = 0; + + while (data_len) { + ssize_t status; + + status = as4625_54p_psu_read_byte(client, command, data); + if (status <= 0) { + ret = status; + break; + } + + data += 1; + command += 1; + data_len -= 1; + } + + return ret; +} + +static struct as4625_54p_psu_data *as4625_54p_psu_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as4625_54p_psu_data *data = i2c_get_clientdata(client); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + int status; + + dev_dbg(&client->dev, "Starting as4625_54p update\n"); + data->valid = 0; + + /* Read psu status */ + status = as4625_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); + + if (status < 0) { + dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); + goto exit; + } + else { + data->status = status; + } + + #ifdef __STDC_LIB_EXT1__ + memset_s(data->model_name, sizeof(data->model_name), 0, sizeof(data->model_name)); + #else + memset(data->model_name, 0, sizeof(data->model_name)); + #endif + #ifdef __STDC_LIB_EXT1__ + memset_s(data->serial, sizeof(data->serial), 0, sizeof(data->serial)); + #else + memset(data->serial, 0, sizeof(data->serial)); + #endif + #ifdef __STDC_LIB_EXT1__ + memset_s(data->fan_dir, sizeof(data->fan_dir), 0, sizeof(data->fan_dir)); + #else + memset(data->fan_dir, 0, sizeof(data->fan_dir)); + #endif + + if (IS_POWER_GOOD(data->index, data->status)) { + /* Read model name */ + status = as4625_54p_psu_read_bytes(client, MODEL_NAME_REG_OFFSET, data->model_name, + ARRAY_SIZE(data->model_name)-1); + if (status < 0) { + data->model_name[0] = '\0'; + dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr); + goto exit; + } + + /* Read serial number */ + status = as4625_54p_psu_read_bytes(client, SERIAL_NUM_REG_OFFSET, data->serial, + ARRAY_SIZE(data->serial)-1); + if (status < 0) { + data->serial[0] = '\0'; + dev_dbg(&client->dev, "unable to read serial number from (0x%x)\n", client->addr); + goto exit; + } + else { + data->serial[ARRAY_SIZE(data->serial)-1] = '\0'; + } + + if (strncmp(data->model_name, "UP1K21R-1085G", ARRAY_SIZE(data->model_name)-1) == 0) + memcpy(data->fan_dir, FAN_DIR_F2B, sizeof(FAN_DIR_F2B)); + else + data->fan_dir[0] = '\0'; + } + + data->last_updated = jiffies; + data->valid = 1; + } + +exit: + return data; +} + +module_i2c_driver(as4625_54p_psu_driver); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as4625_54p_psu driver"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/ym2651y.c b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/ym2651y.c new file mode 120000 index 0000000000..f4d67640cc --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/ym2651y.c @@ -0,0 +1 @@ +../../common/modules/ym2651y.c \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54p/service/as4625-54p-platform-init.service b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/service/as4625-54p-platform-init.service new file mode 100644 index 0000000000..2912050a96 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/service/as4625-54p-platform-init.service @@ -0,0 +1,17 @@ +[Unit] +Description=Accton AS4625-54P Platform initialization service +Before=pmon.service determine-reboot-cause.service system-health.service +After=sysinit.target +DefaultDependencies=no + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/local/bin/accton_as4625_54p_util.py install +ExecStop=/usr/local/bin/accton_as4625_54p_util.py clean + +# Resource Limitations +LimitCORE=infinity + +[Install] +WantedBy=multi-user.target diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54p/service/as4625-54p-platform-monitor.service b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/service/as4625-54p-platform-monitor.service new file mode 100644 index 0000000000..02985c2416 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/service/as4625-54p-platform-monitor.service @@ -0,0 +1,16 @@ +[Unit] +Description=Accton AS4625-54P Platform Monitoring service +Before=pmon.service +After=as4625-54p-platform-init.service +Requires=as4625-54p-platform-init.service + +[Service] +ExecStart=/usr/local/bin/accton_as4625_54p_monitor.py +KillSignal=SIGKILL +SuccessExitStatus=SIGKILL + +# Resource Limitations +LimitCORE=infinity + +[Install] +WantedBy=multi-user.target diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54p/setup.py b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/setup.py new file mode 100644 index 0000000000..2e97a7fa8d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/setup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +import os +from setuptools import setup +os.listdir + +setup( + name='as4625_54p', + version='1.0', + description='Module to initialize Accton AS4625-54P platforms', + + packages=['as4625_54p'], + package_dir={'as4625_54p': 'as4625-54p/classes'}, +) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54p/sonic_platform_setup.py b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/sonic_platform_setup.py new file mode 100644 index 0000000000..98c962923a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/sonic_platform_setup.py @@ -0,0 +1,30 @@ +from setuptools import setup + +DEVICE_NAME = 'accton' +HW_SKU = 'x86_64-accton_as4625_54p-r0' + +setup( + name='sonic-platform', + version='1.0', + description='SONiC platform API implementation on Accton Platforms', + license='Apache 2.0', + author='SONiC Team', + author_email='linuxnetdev@microsoft.com', + url='https://github.com/Azure/sonic-buildimage', + packages=['sonic_platform'], + package_dir={ + 'sonic_platform': '../../../../device/{}/{}/sonic_platform'.format(DEVICE_NAME, HW_SKU)}, + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Environment :: Plugins', + 'Intended Audience :: Developers', + 'Intended Audience :: Information Technology', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: Apache Software License', + 'Natural Language :: English', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python :: 3.7', + 'Topic :: Utilities', + ], + keywords='sonic SONiC platform PLATFORM', +) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54p/utils/accton_as4625_54p_monitor.py b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/utils/accton_as4625_54p_monitor.py new file mode 100755 index 0000000000..5899acee1b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/utils/accton_as4625_54p_monitor.py @@ -0,0 +1,275 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -* +# Copyright (c) 2019 Edgecore Networks Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT +# LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS +# FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. +# +# See the Apache Version 2.0 License for specific language governing +# permissions and limitations under the License. +# ------------------------------------------------------------------ + +try: + import sys + import logging + import logging.config + import logging.handlers + import time + import sonic_platform.platform + from sonic_platform.helper import APIHelper +except ImportError as e: + raise ImportError('%s - required module not found' % str(e)) + +# Deafults +VERSION = '1.0' +FUNCTION_NAME = '/usr/local/bin/accton_as4625_54p_monitor' +I2C_PATH = "/sys/bus/i2c/devices/{}-00{}/" + +FAN_SPEED_DEFAULT = 38 +FAN_SPEED_MAX = 100 + +ERROR_CONFIG_LOGGING = 1 +ERROR_CHASSIS_LOAD = 2 +ERROR_DEVICE_MONITOR_LOAD = 3 + +global log_file +global log_level + +platform_chassis = None + +def configure_logging(log_file, log_level): + """Needs a logger and a logger level.""" + # set up logging to file + logging.basicConfig( + filename=log_file, + filemode='w', + level=log_level, + format='[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s', + datefmt='%H:%M:%S') + # set up logging to console + if log_level == logging.DEBUG: + console = logging.StreamHandler() + console.setLevel(log_level) + formatter = logging.Formatter( + '%(name)-12s: %(levelname)-8s %(message)s') + console.setFormatter(formatter) + logging.getLogger('').addHandler(console) + + sys_handler = logging.handlers.SysLogHandler( + address='/dev/log') + sys_handler.setLevel(logging.WARNING) + logging.getLogger('').addHandler(sys_handler) + +# Instantiate platform-specific Chassis class +def load_platform_chassis(): + global platform_chassis + + # Load new platform api class + if platform_chassis: + return True + + try: + platform_chassis = sonic_platform.platform.Platform().get_chassis() + except Exception as e: + logging.error("Failed to instantiate Chassis: %s", repr(e)) + + if not platform_chassis: + return False + + return True + +THERMAL_1_ON_MAIN_BROAD = '0x4a' +THERMAL_2_ON_MAIN_BROAD = '0x4b' +THERMAL_3_ON_MAIN_BROAD = '0x4d' +THERMAL_5_ON_MAIN_BROAD = '0x4f' + +# Temperature Policy +class device_monitor(object): + PWM_STATE_NORMAL = 0 + PWM_STATE_CRITICAL = 1 + + def __init__(self, chassis): + self._api_helper = APIHelper() + self.chassis = chassis + self.warning = False + self.shutdown = False + self.fan_failed = False + self.pwm_state = self.PWM_STATE_NORMAL + + self._set_all_fan_speed(self._get_default_speed()) + + def _set_all_fan_speed(self, speed): + ret = True + + for drawer_index, drawer in enumerate(self.chassis.get_all_fan_drawers()): + for fan_index, fan in enumerate(drawer.get_all_fans()): + if fan.set_speed(speed) is not True: + logging.error("fan.set_speed error, drawer(%d)-fan(%d)", drawer_index, fan_index) + ret = False + + return ret + + def _get_default_speed(self): + return FAN_SPEED_DEFAULT + + def _get_fan_speed(self): + return { + self.PWM_STATE_NORMAL: FAN_SPEED_DEFAULT, + self.PWM_STATE_CRITICAL: FAN_SPEED_MAX + }.get(self.pwm_state, self._get_default_speed()) + + def _get_system_temperature(self): + sys_thermals = [ + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_5_ON_MAIN_BROAD + ] + + sys_temp = 0 + for thermal in self.chassis.get_all_thermals(): + for item in sys_thermals: + if item in thermal.get_name(): + sys_temp += thermal.get_temperature() + break + + return sys_temp + + def _get_system_low_threshold(self): + return 135 + + def _get_system_high_threshold(self): + return 202 + + def _refresh_thermal_status(self): + # check if current state is valid + if (self.pwm_state < self.PWM_STATE_NORMAL or + self.pwm_state > self.PWM_STATE_CRITICAL): + self.pwm_state = self.PWM_STATE_NORMAL + + # check system temperature + temperature = self._get_system_temperature() + if temperature > self._get_system_high_threshold(): + self.warning = True + else: + self.warning = False + + if self.pwm_state == self.PWM_STATE_CRITICAL: + if temperature < self._get_system_low_threshold(): + self.pwm_state = self.PWM_STATE_NORMAL + else: + if temperature > self._get_system_high_threshold(): + self.pwm_state = self.PWM_STATE_CRITICAL + logging.warning("system temperature(%d) reach high threshold(%d)", + temperature, self._get_system_high_threshold()) + + # check temperature of each thermal + for thermal in self.chassis.get_all_thermals(): + temperature = thermal.get_temperature() + + if temperature >= thermal.get_high_critical_threshold(): + self.warning = True + self.shutdown = True + logging.critical("thermal(%s) temperature(%d) reach shutdown threshold(%d)", + thermal.get_name(), temperature, + thermal.get_high_critical_threshold()) + elif temperature >= thermal.get_high_threshold(): + self.warning = True + logging.warning("thermal(%s) temperature(%d) reach high threshold(%d)", + thermal.get_name(), temperature, + thermal.get_high_threshold()) + + if self.warning is True or self.shutdown is True: + self.pwm_state = self.PWM_STATE_CRITICAL + + return True + + def _refresh_fan_status(self): + self.fan_failed = False + for drawer_index, drawer in enumerate(self.chassis.get_all_fan_drawers()): + for fan_index, fan in enumerate(drawer.get_all_fans()): + if fan.get_presence() is not True: + self.fan_failed = True + logging.error("drawer(%d)-fan(%d) is not present", + drawer_index, fan_index) + break + + if fan.get_status() is not True: + self.fan_failed = True + logging.error("drawer(%d)-fan(%d) is not operational ", + drawer_index, fan_index) + break + + return True + + def manage_fans(self): + try: + prev_warning = self.warning + self._refresh_fan_status() + self._refresh_thermal_status() + except: + self._set_all_fan_speed(FAN_SPEED_MAX) + logging.error("Error occurred while updating fan and thermal status") + return + + if self.fan_failed is True: + self._set_all_fan_speed(FAN_SPEED_MAX) + else: + self._set_all_fan_speed(self._get_fan_speed()) + + if prev_warning != self.warning: + if self.warning is True: + logging.warning('Alarm for temperature high is detected') + else: + logging.info('Alarm for temperature high is cleared') + + if self.shutdown is True: + # critical case*/ + logging.critical( + 'Alarm-Critical for temperature critical is detected, disable PoE') + path = I2C_PATH.format('0', '64') + 'pwr_enable_poe' + self._api_helper.write_txt_file(path, 0) + + logging.critical( + 'Alarm-Critical for temperature critical is detected, shutdown DUT') + path = I2C_PATH.format('0', '64') + 'pwr_enable_mb' + time.sleep(2) + self._api_helper.write_txt_file(path, 0) + + return + +def main(argv): + global platform_chassis + + # configure logging + try: + log_file = '%s.log' % FUNCTION_NAME + log_level = logging.INFO + configure_logging(log_file, log_level) + except: + print("Failed to configure logging") + sys.exit(ERROR_CONFIG_LOGGING) + + # Load platform-specific Chassis class + if not load_platform_chassis(): + sys.exit(ERROR_CHASSIS_LOAD) + + try: + monitor = device_monitor(platform_chassis) + except: + logging.error("Failed to instantiate device_monitor") + sys.exit(ERROR_DEVICE_MONITOR_LOAD) + + # Loop forever, doing something useful hopefully: + while True: + monitor.manage_fans() + time.sleep(10) # 10sec + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54p/utils/accton_as4625_54p_util.py b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/utils/accton_as4625_54p_util.py new file mode 100755 index 0000000000..e79e3c75a0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54p/utils/accton_as4625_54p_util.py @@ -0,0 +1,402 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2019 Accton Networks, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +Usage: %(scriptName)s [options] command object + +options: + -h | --help : this help message + -d | --debug : run with debug mode + -f | --force : ignore error during installation or clean +command: + install : install drivers and generate related sysfs nodes + clean : uninstall drivers and remove related sysfs nodes + show : show all systen status + sff : dump SFP eeprom + set : change board setting with fan|led|sfp +""" + +import subprocess +import getopt +import sys +import logging +import time +import os + +PROJECT_NAME = 'as4625_54p' +DEBUG = False +ARGS = [] +FORCE = 0 +LED_MODE_OFF = 0 +LED_MODE_GREEN = 1 # Default value for LOC LED +LED_LOC_PATH = "/sys/class/leds/as4625_led::loc/brightness" + +def main(): + global DEBUG + global ARGS + global FORCE + + if len(sys.argv) < 2: + return 0 + + (options, ARGS) = getopt.getopt(sys.argv[1:], 'hdf', + ['help','debug', 'force']) + if DEBUG == True: + print(options) + print(ARGS) + print(len(sys.argv)) + + for arg in ARGS: + if arg == 'install': + do_install() + elif arg == 'clean': + do_uninstall() + elif arg == 'api': + do_sonic_platform_install() + elif arg == 'api_clean': + do_sonic_platform_clean() + return 0 + +def log_os_system(cmd, show): + logging.info('Run :' + cmd) + status, output = subprocess.getstatusoutput(cmd) + if status: + logging.info('Failed :' + cmd) + if show: + print('Failed :' + cmd) + return (status, output) + +def driver_check(): + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) + logging.info('mods:'+lsmod) + if ret : + return False + else : + return True + +def new_device(driver, addr, bus, devdir): + if not os.path.exists(os.path.join(bus, devdir)): + try: + with open("%s/new_device" % bus, "w") as f: + f.write("%s 0x%x\n" % (driver, addr)) + f.flush() + except Exception as e: + print("Unexpected error initialize device %s:0x%x:%s: %s" % (driver, addr, bus, e)) + return None + + if not os.path.exists(os.path.join(bus, devdir)): + return False + elif driver.find('pca954') != -1: + if not os.path.exists(os.path.join(bus, devdir, "channel-0")): + delete_device(addr, bus, devdir) + return False + elif os.path.exists(os.path.join(bus, devdir, "idle_state")): + try: + with open(os.path.join(bus, devdir, "idle_state"), "w") as f: + f.write("-2\n") + except Exception as e: + return False + else: + print("Device %s:%x:%s already exists." % (driver, addr, bus)) + return False + + return True + +def delete_device(addr, bus, devdir): + if os.path.exists(os.path.join(bus, devdir)): + try: + with open("%s/delete_device" % bus, "w") as f: + f.write("%s\n" % addr) + f.flush() + except Exception as e: + print("Unexpected error delete device 0x%x:%s: %s" % (addr, bus, e)) + return None + else: + print("Device %x:%s does not exist." % (addr, bus)) + return True + + return True + +def new_i2c_device(driver, addr, bus_number): + bus = '/sys/bus/i2c/devices/i2c-%d' % bus_number + devdir = "%d-%4.4x" % (bus_number, addr) + return new_device(driver, addr, bus, devdir) + +def delete_i2c_device(addr, bus_number): + bus = '/sys/bus/i2c/devices/i2c-%d' % bus_number + devdir = "%d-%4.4x" % (bus_number, addr) + return delete_device(addr, bus, devdir) + +def new_i2c_devices(new_device_list): + for (driver, addr, bus_number) in new_device_list: + for i in range(0, 30): + if new_i2c_device(driver, addr, bus_number) is not True: + time.sleep(1) + continue + else: + break + else: + return False + + return True + +def new_sfp_devices(sfp_bus_list, driver): + for bus_number in sfp_bus_list: + for i in range(0, 30): + if new_i2c_device(driver, 0x50, bus_number) is not True: + time.sleep(1) + continue + else: + break + else: + return False + + return True + +def delete_i2c_devices(delete_device_list): + ret = True + + for (driver, addr, bus_number) in delete_device_list: + if delete_i2c_device(addr, bus_number) is not True: + ret = False + continue + + return ret + +def delete_sfp_devices(sfp_bus_list): + ret = True + + for bus_number in sfp_bus_list: + if delete_i2c_device(0x50, bus_number) is not True: + ret = False + continue + + return ret + +kos = [ + 'depmod -ae', + 'modprobe i2c_dev', + 'modprobe i2c_i801', + 'modprobe i2c_ismt', + 'modprobe i2c_mux_pca954x', + 'modprobe x86-64-accton-as4625-54p-cpld', + 'modprobe x86-64-accton-as4625-54p-fan', + 'modprobe x86-64-accton-as4625-54p-leds', + 'modprobe x86-64-accton-as4625-54p-psu', + 'modprobe optoe', + 'modprobe ym2651y'] + +def driver_install(): + global FORCE + + for i in range(0,len(kos)): + status, output = log_os_system(kos[i], 1) + if status: + if FORCE == 0: + return status + return 0 + +def driver_uninstall(): + global FORCE + for i in reversed(range(0,len(kos))): + rm = kos[i].replace("modprobe", "modprobe -rq") + rm = rm.replace("insmod", "rmmod") + lst = rm.split(" ") + if len(lst) > 3: + del(lst[3]) + rm = " ".join(lst) + status, output = log_os_system(rm, 1) + if status: + if FORCE == 0: + return status + return 0 + +def write_txt_file(file_path, value): + try: + with open(file_path, 'w') as fd: + fd.write(value) + except IOError as e: + print("Error write value to file: %s" % str(e)) + return False + return True + +i2c_prefix = '/sys/bus/i2c/devices/' + +i2c_device_list = [ + # initialize multiplexer (PCA9548) + ('pca9548', 0x70, 1), + ('pca9548', 0x71, 1), + + # initialize CPLD + ('as4625_cpld1', 0x64, 0), + + # initiate PSU-1 AC Power + ('as4625_54p_psu1', 0x50, 8), + ('umec_up1k21r', 0x58, 8), + + # initiate PSU-2 AC Power + ('as4625_54p_psu2', 0x51, 9), + ('umec_up1k21r', 0x59, 9), + + # inititate LM75 + ('lm75', 0x4A, 3), + ('lm75', 0x4B, 3), + ('lm75', 0x4D, 3), + ('lm75', 0x4E, 3), + ('lm75', 0x4F, 3), + + # initiate IDPROM + ('24c02', 0x51, 7) +] + +sfp_bus_list = [ 10, 11, 12, 13, 14, 15 ] + +def device_install(): + global FORCE + + if new_i2c_devices(i2c_device_list) is not True: + return 1 + + if new_sfp_devices(sfp_bus_list, 'optoe2') is not True: + return 1 + + for p in range(len(sfp_bus_list)): + path = "/sys/bus/i2c/devices/{0}-0050/port_name".format(sfp_bus_list[p]) + if write_txt_file(path, 'port{0}'.format(p+49)) is not True: + return 1 + + return + +def device_uninstall(): + global FORCE + + if delete_sfp_devices(sfp_bus_list) is not True: + return 1 + + if delete_i2c_devices(i2c_device_list[::-1]) is not True: + return 1 + + return + +PLATFORM_ROOT_PATH = '/usr/share/sonic/device' +PLATFORM_API2_WHL_FILE_PY3 ='sonic_platform-1.0-py3-none-any.whl' +def do_sonic_platform_install(): + device_path = "{}{}{}{}".format(PLATFORM_ROOT_PATH, '/x86_64-accton_', PROJECT_NAME, '-r0') + SONIC_PLATFORM_BSP_WHL_PKG_PY3 = "/".join([device_path, PLATFORM_API2_WHL_FILE_PY3]) + + #Check API2.0 on py whl file + status, output = log_os_system("pip3 show sonic-platform > /dev/null 2>&1", 0) + if status: + if os.path.exists(SONIC_PLATFORM_BSP_WHL_PKG_PY3): + status, output = log_os_system("pip3 install "+ SONIC_PLATFORM_BSP_WHL_PKG_PY3, 1) + if status: + print("Error: Failed to install {}".format(PLATFORM_API2_WHL_FILE_PY3)) + return status + else: + print("Successfully installed {} package".format(PLATFORM_API2_WHL_FILE_PY3)) + else: + print('{} is not found'.format(PLATFORM_API2_WHL_FILE_PY3)) + else: + print('{} has installed'.format(PLATFORM_API2_WHL_FILE_PY3)) + +def do_sonic_platform_clean(): + status, output = log_os_system("pip3 show sonic-platform > /dev/null 2>&1", 0) + if status: + print('{} does not install, not need to uninstall'.format(PLATFORM_API2_WHL_FILE_PY3)) + + else: + status, output = log_os_system("pip3 uninstall sonic-platform -y", 0) + if status: + print('Error: Failed to uninstall {}'.format(PLATFORM_API2_WHL_FILE_PY3)) + return status + else: + print('{} is uninstalled'.format(PLATFORM_API2_WHL_FILE_PY3)) + + return + +def set_loc_led(color): + global FORCE + + if os.path.exists(LED_LOC_PATH): + cmd = 'echo {} > {}'.format(color, LED_LOC_PATH) + try: + status, output = log_os_system(cmd, 1) + if status: + print(output) + if FORCE == 0: + return status + except Exception as e: + print({}.format(e)) + else: + print('{} does not exist.'.format(LED_LOC_PATH)) + + return + +def do_install(): + print('Checking system....') + if driver_check() is False: + print('No driver, installing....') + status = driver_install() + if status: + if FORCE == 0: + return status + else: + print(PROJECT_NAME.upper() + ' drivers detected....') + if not device_exist(): + print('No device, installing....') + status = device_install() + if status: + if FORCE == 0: + return status + else: + print(PROJECT_NAME.upper() + ' devices detected....') + + set_loc_led(LED_MODE_OFF) + + do_sonic_platform_install() + + return + +def do_uninstall(): + print('Checking system....') + if not device_exist(): + print(PROJECT_NAME.upper() + ' has no device installed....') + else: + print('Removing device....') + status = device_uninstall() + if status and FORCE == 0: + return status + + if driver_check() is False: + print(PROJECT_NAME.upper() + ' has no driver installed....') + else: + print('Removing installed driver....') + status = driver_uninstall() + if status and FORCE == 0: + return status + + do_sonic_platform_clean() + + return None + +def device_exist(): + ret1 = log_os_system('ls ' + i2c_prefix + '*0070', 0) + ret2 = log_os_system('ls ' + i2c_prefix + 'i2c-2', 0) + return not (ret1[0] or ret2[0]) + +if __name__ == '__main__': + main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54t/classes/__init__.py b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/classes/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/Makefile b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/Makefile new file mode 100644 index 0000000000..2e596deaa2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/Makefile @@ -0,0 +1,16 @@ +ifneq ($(KERNELRELEASE),) +obj-m:= x86-64-accton-as4625-54t-cpld.o x86-64-accton-as4625-54t-fan.o \ + x86-64-accton-as4625-54t-psu.o x86-64-accton-as4625-54t-leds.o ym2651y.o + +else +ifeq (,$(KERNEL_SRC)) +$(error KERNEL_SRC is not defined) +else +KERNELDIR:=$(KERNEL_SRC) +endif +PWD:=$(shell pwd) +default: + $(MAKE) -C $(KERNELDIR) M=$(PWD) modules +clean: + rm -rf *.o *.mod.o *.mod.o *.ko .*cmd .tmp_versions Module.markers Module.symvers modules.order +endif diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/x86-64-accton-as4625-54t-cpld.c b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/x86-64-accton-as4625-54t-cpld.c new file mode 120000 index 0000000000..d944bb8b29 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/x86-64-accton-as4625-54t-cpld.c @@ -0,0 +1 @@ +../../as4625-54p/modules/x86-64-accton-as4625-54p-cpld.c \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/x86-64-accton-as4625-54t-fan.c b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/x86-64-accton-as4625-54t-fan.c new file mode 120000 index 0000000000..9b73f7a09c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/x86-64-accton-as4625-54t-fan.c @@ -0,0 +1 @@ +../../as4625-54p/modules/x86-64-accton-as4625-54p-fan.c \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/x86-64-accton-as4625-54t-leds.c b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/x86-64-accton-as4625-54t-leds.c new file mode 120000 index 0000000000..e5303ebb4f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/x86-64-accton-as4625-54t-leds.c @@ -0,0 +1 @@ +../../as4625-54p/modules/x86-64-accton-as4625-54p-leds.c \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/x86-64-accton-as4625-54t-psu.c b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/x86-64-accton-as4625-54t-psu.c new file mode 100644 index 0000000000..fa2f74f8a4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/x86-64-accton-as4625-54t-psu.c @@ -0,0 +1,391 @@ +/* + * An hwmon driver for accton as4625_54t Power Module + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define __STDC_WANT_LIB_EXT1__ 1 +#include + +#define DRVNAME "as4625_54t_psu" + +#define PSU_STATUS_I2C_ADDR 0x64 +#define PSU_STATUS_I2C_REG_OFFSET 0x4 + +#define MODEL_NAME_LEN 15 +#define MODEL_NAME_REG_OFFSET 0x15 + +#define SERIAL_NUM_LEN 9 +#define SERIAL_NUM_REG_OFFSET 0x35 + +#define IS_POWER_GOOD(id, value) (!!(value & BIT(id*4+2))) +#define IS_PRESENT(id, value) (!(value & BIT(id*4))) + +#define FAN_DIR_LEN 3 +const char FAN_DIR_F2B[] = "F2B"; +const char FAN_DIR_B2F[] = "B2F"; + +static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_string(struct device *dev, struct device_attribute *da, char *buf); +extern int as4625_cpld_read(unsigned short cpld_addr, u8 reg); + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +/* Each client has this additional data + */ +struct as4625_54t_psu_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 index; /* PSU index */ + u8 status; /* Status(present/power_good) register read from CPLD */ + char model_name[MODEL_NAME_LEN+1]; /* Model name, read from eeprom */ + char serial[SERIAL_NUM_LEN+1]; /* Serial number, read from eeprom*/ + char fan_dir[FAN_DIR_LEN+1]; +}; + +static struct as4625_54t_psu_data *as4625_54t_psu_update_device(struct device *dev); + +enum as4625_54t_psu_sysfs_attributes { + PSU_PRESENT, + PSU_MODEL_NAME, + PSU_POWER_GOOD, + PSU_SERIAL_NUMBER, + PSU_FAN_DIR +}; + +/* sysfs attributes for hwmon + */ +static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); +static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_string, NULL, PSU_MODEL_NAME); +static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); +static SENSOR_DEVICE_ATTR(psu_serial_numer, S_IRUGO, show_string, NULL, PSU_SERIAL_NUMBER); +static SENSOR_DEVICE_ATTR(psu_fan_dir, S_IRUGO, show_string, NULL, PSU_FAN_DIR); + +static struct attribute *as4625_54t_psu_attributes[] = { + &sensor_dev_attr_psu_present.dev_attr.attr, + &sensor_dev_attr_psu_model_name.dev_attr.attr, + &sensor_dev_attr_psu_power_good.dev_attr.attr, + &sensor_dev_attr_psu_serial_numer.dev_attr.attr, + &sensor_dev_attr_psu_fan_dir.dev_attr.attr, + NULL +}; + +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as4625_54t_psu_data *data = i2c_get_clientdata(client); + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + u8 status = 0; + + mutex_lock(&data->update_lock); + + data = as4625_54t_psu_update_device(dev); + if (!data->valid) { + mutex_unlock(&data->update_lock); + return sprintf(buf, "0\n"); + } + + if (attr->index == PSU_PRESENT) { + status = IS_PRESENT(data->index, data->status); + } + else { /* PSU_POWER_GOOD */ + status = IS_POWER_GOOD(data->index, data->status); + } + + mutex_unlock(&data->update_lock); + return sprintf(buf, "%d\n", status); +} + +static ssize_t show_string(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as4625_54t_psu_data *data = i2c_get_clientdata(client); + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + char *ptr = NULL; + int ret = 0; + + mutex_lock(&data->update_lock); + + data = as4625_54t_psu_update_device(dev); + if (!data->valid) { + ret = -EIO; + goto exit; + } + + switch (attr->index) { + case PSU_MODEL_NAME: + ptr = data->model_name; + break; + case PSU_SERIAL_NUMBER: + ptr = data->serial; + break; + case PSU_FAN_DIR: + ptr = data->fan_dir; + break; + default: + ret = -EINVAL; + goto exit; + } + + ret = sprintf(buf, "%s\n", ptr); + +exit: + mutex_unlock(&data->update_lock); + return ret; +} + +static const struct attribute_group as4625_54t_psu_group = { + .attrs = as4625_54t_psu_attributes, +}; + +static int as4625_54t_psu_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as4625_54t_psu_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as4625_54t_psu_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + data->valid = 0; + data->index = dev_id->driver_data; + mutex_init(&data->update_lock); + i2c_set_clientdata(client, data); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as4625_54t_psu_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register_with_info(&client->dev, + DRVNAME, NULL, NULL, NULL); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: psu '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as4625_54t_psu_group); +exit_free: + kfree(data); +exit: + return status; +} + +static int as4625_54t_psu_remove(struct i2c_client *client) +{ + struct as4625_54t_psu_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as4625_54t_psu_group); + kfree(data); + + return 0; +} + +enum psu_index +{ + as4625_54t_psu1, + as4625_54t_psu2 +}; + +static const struct i2c_device_id as4625_54t_psu_id[] = { + { "as4625_54t_psu1", as4625_54t_psu1 }, + { "as4625_54t_psu2", as4625_54t_psu2 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as4625_54t_psu_id); + +static struct i2c_driver as4625_54t_psu_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = DRVNAME, + }, + .probe = as4625_54t_psu_probe, + .remove = as4625_54t_psu_remove, + .id_table = as4625_54t_psu_id, + .address_list = normal_i2c, +}; + +static int as4625_54t_psu_read_byte(struct i2c_client *client, u8 command, u8 *data) +{ + int status = 0; + int retry_count = 5; + + while (retry_count) { + status = i2c_smbus_read_byte_data(client, command); + if (unlikely(status < 0)) { + msleep(10); + retry_count--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); + goto abort; + } + + *data = (u8)status; + +abort: + return status; +} + +static int as4625_54t_psu_read_bytes(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ + int ret = 0; + + while (data_len) { + ssize_t status; + + status = as4625_54t_psu_read_byte(client, command, data); + if (status <= 0) { + ret = status; + break; + } + + data += 1; + command += 1; + data_len -= 1; + } + + return ret; +} + +static struct as4625_54t_psu_data *as4625_54t_psu_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as4625_54t_psu_data *data = i2c_get_clientdata(client); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + int status; + + dev_dbg(&client->dev, "Starting as4625_54t update\n"); + data->valid = 0; + + /* Read psu status */ + status = as4625_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); + + if (status < 0) { + dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); + goto exit; + } + else { + data->status = status; + } + + #ifdef __STDC_LIB_EXT1__ + memset_s(data->model_name, sizeof(data->model_name), 0, sizeof(data->model_name)); + #else + memset(data->model_name, 0, sizeof(data->model_name)); + #endif + #ifdef __STDC_LIB_EXT1__ + memset_s(data->serial, sizeof(data->serial), 0, sizeof(data->serial)); + #else + memset(data->serial, 0, sizeof(data->serial)); + #endif + #ifdef __STDC_LIB_EXT1__ + memset_s(data->fan_dir, sizeof(data->fan_dir), 0, sizeof(data->fan_dir)); + #else + memset(data->fan_dir, 0, sizeof(data->fan_dir)); + #endif + + if (IS_POWER_GOOD(data->index, data->status)) { + /* Read model name */ + status = as4625_54t_psu_read_bytes(client, MODEL_NAME_REG_OFFSET, data->model_name, + ARRAY_SIZE(data->model_name)-1); + if (status < 0) { + data->model_name[0] = '\0'; + dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr); + goto exit; + } + + /* Read serial number */ + status = as4625_54t_psu_read_bytes(client, SERIAL_NUM_REG_OFFSET, data->serial, + ARRAY_SIZE(data->serial)-1); + if (status < 0) { + data->serial[0] = '\0'; + dev_dbg(&client->dev, "unable to read serial number from (0x%x)\n", client->addr); + goto exit; + } + else { + data->serial[ARRAY_SIZE(data->serial)-1] = '\0'; + } + + if (strncmp(data->model_name, "UPD1501SA-1179G", ARRAY_SIZE(data->model_name)-1) == 0) + memcpy(data->fan_dir, FAN_DIR_F2B, sizeof(FAN_DIR_F2B)); + else if (strncmp(data->model_name, "UPD1501SA-1279G", ARRAY_SIZE(data->model_name)-1) == 0) + memcpy(data->fan_dir, FAN_DIR_B2F, sizeof(FAN_DIR_B2F)); + else + data->fan_dir[0] = '\0'; + } + + data->last_updated = jiffies; + data->valid = 1; + } + +exit: + return data; +} + +module_i2c_driver(as4625_54t_psu_driver); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as4625_54t_psu driver"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/ym2651y.c b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/ym2651y.c new file mode 120000 index 0000000000..f4d67640cc --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/ym2651y.c @@ -0,0 +1 @@ +../../common/modules/ym2651y.c \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54t/service/as4625-54t-platform-init.service b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/service/as4625-54t-platform-init.service new file mode 100644 index 0000000000..cf7abbfb93 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/service/as4625-54t-platform-init.service @@ -0,0 +1,17 @@ +[Unit] +Description=Accton AS4625-54T Platform initialization service +Before=pmon.service determine-reboot-cause.service system-health.service +After=sysinit.target +DefaultDependencies=no + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/local/bin/accton_as4625_54t_util.py install +ExecStop=/usr/local/bin/accton_as4625_54t_util.py clean + +# Resource Limitations +LimitCORE=infinity + +[Install] +WantedBy=multi-user.target diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54t/service/as4625-54t-platform-monitor.service b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/service/as4625-54t-platform-monitor.service new file mode 100644 index 0000000000..5e31a85fad --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/service/as4625-54t-platform-monitor.service @@ -0,0 +1,16 @@ +[Unit] +Description=Accton AS4625-54T Platform Monitoring service +Before=pmon.service +After=as4625-54t-platform-init.service +Requires=as4625-54t-platform-init.service + +[Service] +ExecStart=/usr/local/bin/accton_as4625_54t_monitor.py +KillSignal=SIGKILL +SuccessExitStatus=SIGKILL + +# Resource Limitations +LimitCORE=infinity + +[Install] +WantedBy=multi-user.target diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54t/setup.py b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/setup.py new file mode 100644 index 0000000000..941f53b542 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/setup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +import os +from setuptools import setup +os.listdir + +setup( + name='as4625_54t', + version='1.0', + description='Module to initialize Accton AS4625-54T platforms', + + packages=['as4625_54t'], + package_dir={'as4625_54t': 'as4625-54t/classes'}, +) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54t/sonic_platform_setup.py b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/sonic_platform_setup.py new file mode 100644 index 0000000000..7b6debe777 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/sonic_platform_setup.py @@ -0,0 +1,30 @@ +from setuptools import setup + +DEVICE_NAME = 'accton' +HW_SKU = 'x86_64-accton_as4625_54t-r0' + +setup( + name='sonic-platform', + version='1.0', + description='SONiC platform API implementation on Accton Platforms', + license='Apache 2.0', + author='SONiC Team', + author_email='linuxnetdev@microsoft.com', + url='https://github.com/Azure/sonic-buildimage', + packages=['sonic_platform'], + package_dir={ + 'sonic_platform': '../../../../device/{}/{}/sonic_platform'.format(DEVICE_NAME, HW_SKU)}, + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Environment :: Plugins', + 'Intended Audience :: Developers', + 'Intended Audience :: Information Technology', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: Apache Software License', + 'Natural Language :: English', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python :: 3.7', + 'Topic :: Utilities', + ], + keywords='sonic SONiC platform PLATFORM', +) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54t/utils/accton_as4625_54t_monitor.py b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/utils/accton_as4625_54t_monitor.py new file mode 100755 index 0000000000..ab479a7595 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/utils/accton_as4625_54t_monitor.py @@ -0,0 +1,307 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -* +# Copyright (c) 2019 Edgecore Networks Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT +# LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS +# FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. +# +# See the Apache Version 2.0 License for specific language governing +# permissions and limitations under the License. +# ------------------------------------------------------------------ + +try: + import sys + import logging + import logging.config + import logging.handlers + import time + import sonic_platform.platform + from sonic_platform.helper import APIHelper +except ImportError as e: + raise ImportError('%s - required module not found' % str(e)) + +# Deafults +VERSION = '1.0' +FUNCTION_NAME = '/usr/local/bin/accton_as4625_54t_monitor' +I2C_PATH = "/sys/bus/i2c/devices/{}-00{}/" + +FAN_SPEED_DEFAULT_F2B = 38 +FAN_SPEED_DEFAULT_B2F = 25 +FAN_SPEED_MAX = 100 + +ERROR_CONFIG_LOGGING = 1 +ERROR_CHASSIS_LOAD = 2 +ERROR_DEVICE_MONITOR_LOAD = 3 + +global log_file +global log_level + +platform_chassis = None + +def configure_logging(log_file, log_level): + """Needs a logger and a logger level.""" + # set up logging to file + logging.basicConfig( + filename=log_file, + filemode='w', + level=log_level, + format='[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s', + datefmt='%H:%M:%S') + # set up logging to console + if log_level == logging.DEBUG: + console = logging.StreamHandler() + console.setLevel(log_level) + formatter = logging.Formatter( + '%(name)-12s: %(levelname)-8s %(message)s') + console.setFormatter(formatter) + logging.getLogger('').addHandler(console) + + sys_handler = logging.handlers.SysLogHandler( + address='/dev/log') + sys_handler.setLevel(logging.WARNING) + logging.getLogger('').addHandler(sys_handler) + +# Instantiate platform-specific Chassis class +def load_platform_chassis(): + global platform_chassis + + # Load new platform api class + if platform_chassis: + return True + + try: + platform_chassis = sonic_platform.platform.Platform().get_chassis() + except Exception as e: + logging.error("Failed to instantiate Chassis: %s", repr(e)) + + if not platform_chassis: + return False + + return True + +THERMAL_1_ON_MAIN_BROAD = '0x4a' +THERMAL_2_ON_MAIN_BROAD = '0x4b' +THERMAL_3_ON_MAIN_BROAD = '0x4d' +THERMAL_5_ON_MAIN_BROAD = '0x4f' + +# Temperature Policy +class device_monitor(object): + PWM_STATE_NORMAL = 0 + PWM_STATE_CRITICAL = 1 + + PCB_ID_AS4625_54T_F2B = 1 + PCB_ID_AS4625_54T_B2F = 2 + + def __init__(self, chassis): + self._api_helper = APIHelper() + self.chassis = chassis + self.warning = False + self.shutdown = False + self.fan_failed = False + self.pwm_state = self.PWM_STATE_NORMAL + + self.pcb_id = self._get_pcb_id() + if (self.pcb_id < self.PCB_ID_AS4625_54T_F2B or + self.pcb_id > self.PCB_ID_AS4625_54T_B2F): + self.pcb_id = self.PCB_ID_AS4625_54T_F2B + + self._set_all_fan_speed(self._get_default_speed()) + + def _get_pcb_id(self): + cpld_path = I2C_PATH.format('0', '64') + 'pcb_id' + pcb_id = self._api_helper.read_txt_file(cpld_path) + if pcb_id is not None: + return int(pcb_id) + + return None + + def _set_all_fan_speed(self, speed): + ret = True + + for drawer_index, drawer in enumerate(self.chassis.get_all_fan_drawers()): + for fan_index, fan in enumerate(drawer.get_all_fans()): + if fan.set_speed(speed) is not True: + logging.error("fan.set_speed error, drawer(%d)-fan(%d)", drawer_index, fan_index) + ret = False + + return ret + + def _get_default_speed(self): + return { + self.PCB_ID_AS4625_54T_F2B: FAN_SPEED_DEFAULT_F2B, + self.PCB_ID_AS4625_54T_B2F: FAN_SPEED_DEFAULT_B2F + }.get(self.pcb_id, max(FAN_SPEED_DEFAULT_F2B, FAN_SPEED_DEFAULT_B2F)) + + def _get_fan_speed(self): + speed_dict = { + self.PCB_ID_AS4625_54T_F2B: { + self.PWM_STATE_NORMAL: FAN_SPEED_DEFAULT_F2B, + self.PWM_STATE_CRITICAL: FAN_SPEED_MAX + }, + self.PCB_ID_AS4625_54T_B2F: { + self.PWM_STATE_NORMAL: FAN_SPEED_DEFAULT_B2F, + self.PWM_STATE_CRITICAL: FAN_SPEED_MAX + } + } + return speed_dict[self.pcb_id].get(self.pwm_state, self._get_default_speed()) + + def _get_system_temperature(self): + sys_thermals = [ + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_5_ON_MAIN_BROAD + ] + + sys_temp = 0 + for thermal in self.chassis.get_all_thermals(): + for item in sys_thermals: + if item in thermal.get_name(): + sys_temp += thermal.get_temperature() + break + + return sys_temp + + def _get_system_low_threshold(self): + LOW_THRESHOLD_F2B = 111 + LOW_THRESHOLD_B2F = 116 + return { + self.PCB_ID_AS4625_54T_F2B: LOW_THRESHOLD_F2B, + self.PCB_ID_AS4625_54T_B2F: LOW_THRESHOLD_B2F + }.get(self.pcb_id, min(LOW_THRESHOLD_F2B, LOW_THRESHOLD_B2F)) + + def _get_system_high_threshold(self): + HIGH_THRESHOLD_F2B = 186 + HIGH_THRESHOLD_B2F = 184 + return { + self.PCB_ID_AS4625_54T_F2B: HIGH_THRESHOLD_F2B, + self.PCB_ID_AS4625_54T_B2F: HIGH_THRESHOLD_B2F + }.get(self.pcb_id, min(HIGH_THRESHOLD_F2B, HIGH_THRESHOLD_B2F)) + + def _refresh_thermal_status(self): + # check if current state is valid + if (self.pwm_state < self.PWM_STATE_NORMAL or + self.pwm_state > self.PWM_STATE_CRITICAL): + self.pwm_state = self.PWM_STATE_NORMAL + + # check system temperature + temperature = self._get_system_temperature() + if temperature > self._get_system_high_threshold(): + self.warning = True + else: + self.warning = False + + if self.pwm_state == self.PWM_STATE_CRITICAL: + if temperature < self._get_system_low_threshold(): + self.pwm_state = self.PWM_STATE_NORMAL + else: + if temperature > self._get_system_high_threshold(): + self.pwm_state = self.PWM_STATE_CRITICAL + logging.warning("system temperature(%d) reach high threshold(%d)", + temperature, self._get_system_high_threshold()) + + # check temperature of each thermal + for thermal in self.chassis.get_all_thermals(): + temperature = thermal.get_temperature() + + if temperature >= thermal.get_high_critical_threshold(): + self.warning = True + self.shutdown = True + logging.critical("thermal(%s) temperature(%d) reach shutdown threshold(%d)", + thermal.get_name(), temperature, + thermal.get_high_critical_threshold()) + elif temperature >= thermal.get_high_threshold(): + self.warning = True + logging.warning("thermal(%s) temperature(%d) reach high threshold(%d)", + thermal.get_name(), temperature, + thermal.get_high_threshold()) + + if self.warning is True or self.shutdown is True: + self.pwm_state = self.PWM_STATE_CRITICAL + + return True + + def _refresh_fan_status(self): + self.fan_failed = False + for drawer_index, drawer in enumerate(self.chassis.get_all_fan_drawers()): + for fan_index, fan in enumerate(drawer.get_all_fans()): + if fan.get_presence() is not True: + self.fan_failed = True + logging.error("drawer(%d)-fan(%d) is not present", + drawer_index, fan_index) + break + + if fan.get_status() is not True: + self.fan_failed = True + logging.error("drawer(%d)-fan(%d) is not operational ", + drawer_index, fan_index) + break + + return True + + def manage_fans(self): + try: + prev_warning = self.warning + self._refresh_fan_status() + self._refresh_thermal_status() + except: + self._set_all_fan_speed(FAN_SPEED_MAX) + logging.error("Error occurred while updating fan and thermal status") + return + + if self.fan_failed is True: + self._set_all_fan_speed(FAN_SPEED_MAX) + else: + self._set_all_fan_speed(self._get_fan_speed()) + + if prev_warning != self.warning: + if self.warning is True: + logging.warning('Alarm for temperature high is detected') + else: + logging.info('Alarm for temperature high is cleared') + + if self.shutdown is True: + # critical case*/ + logging.critical( + 'Alarm-Critical for temperature critical is detected, shutdown DUT') + path = I2C_PATH.format('0', '64') + 'pwr_enable_mb' + time.sleep(2) + self._api_helper.write_txt_file(path, 0) + + return + +def main(argv): + global platform_chassis + + # configure logging + try: + log_file = '%s.log' % FUNCTION_NAME + log_level = logging.INFO + configure_logging(log_file, log_level) + except: + print("Failed to configure logging") + sys.exit(ERROR_CONFIG_LOGGING) + + # Load platform-specific Chassis class + if not load_platform_chassis(): + sys.exit(ERROR_CHASSIS_LOAD) + + try: + monitor = device_monitor(platform_chassis) + except: + logging.error("Failed to instantiate device_monitor") + sys.exit(ERROR_DEVICE_MONITOR_LOAD) + + # Loop forever, doing something useful hopefully: + while True: + monitor.manage_fans() + time.sleep(10) # 10sec + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4625-54t/utils/accton_as4625_54t_util.py b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/utils/accton_as4625_54t_util.py new file mode 100755 index 0000000000..8ed54983a1 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4625-54t/utils/accton_as4625_54t_util.py @@ -0,0 +1,402 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2019 Accton Networks, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +Usage: %(scriptName)s [options] command object + +options: + -h | --help : this help message + -d | --debug : run with debug mode + -f | --force : ignore error during installation or clean +command: + install : install drivers and generate related sysfs nodes + clean : uninstall drivers and remove related sysfs nodes + show : show all systen status + sff : dump SFP eeprom + set : change board setting with fan|led|sfp +""" + +import subprocess +import getopt +import sys +import logging +import time +import os + +PROJECT_NAME = 'as4625_54t' +DEBUG = False +ARGS = [] +FORCE = 0 +LED_MODE_OFF = 0 +LED_MODE_GREEN = 1 # Default value for LOC LED +LED_LOC_PATH = "/sys/class/leds/as4625_led::loc/brightness" + +def main(): + global DEBUG + global ARGS + global FORCE + + if len(sys.argv) < 2: + return 0 + + (options, ARGS) = getopt.getopt(sys.argv[1:], 'hdf', + ['help','debug', 'force']) + if DEBUG == True: + print(options) + print(ARGS) + print(len(sys.argv)) + + for arg in ARGS: + if arg == 'install': + do_install() + elif arg == 'clean': + do_uninstall() + elif arg == 'api': + do_sonic_platform_install() + elif arg == 'api_clean': + do_sonic_platform_clean() + return 0 + +def log_os_system(cmd, show): + logging.info('Run :' + cmd) + status, output = subprocess.getstatusoutput(cmd) + if status: + logging.info('Failed :' + cmd) + if show: + print('Failed :' + cmd) + return (status, output) + +def driver_check(): + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) + logging.info('mods:'+lsmod) + if ret : + return False + else : + return True + +def new_device(driver, addr, bus, devdir): + if not os.path.exists(os.path.join(bus, devdir)): + try: + with open("%s/new_device" % bus, "w") as f: + f.write("%s 0x%x\n" % (driver, addr)) + f.flush() + except Exception as e: + print("Unexpected error initialize device %s:0x%x:%s: %s" % (driver, addr, bus, e)) + return None + + if not os.path.exists(os.path.join(bus, devdir)): + return False + elif driver.find('pca954') != -1: + if not os.path.exists(os.path.join(bus, devdir, "channel-0")): + delete_device(addr, bus, devdir) + return False + elif os.path.exists(os.path.join(bus, devdir, "idle_state")): + try: + with open(os.path.join(bus, devdir, "idle_state"), "w") as f: + f.write("-2\n") + except Exception as e: + return False + else: + print("Device %s:%x:%s already exists." % (driver, addr, bus)) + return False + + return True + +def delete_device(addr, bus, devdir): + if os.path.exists(os.path.join(bus, devdir)): + try: + with open("%s/delete_device" % bus, "w") as f: + f.write("%s\n" % addr) + f.flush() + except Exception as e: + print("Unexpected error delete device 0x%x:%s: %s" % (addr, bus, e)) + return None + else: + print("Device %x:%s does not exist." % (addr, bus)) + return True + + return True + +def new_i2c_device(driver, addr, bus_number): + bus = '/sys/bus/i2c/devices/i2c-%d' % bus_number + devdir = "%d-%4.4x" % (bus_number, addr) + return new_device(driver, addr, bus, devdir) + +def delete_i2c_device(addr, bus_number): + bus = '/sys/bus/i2c/devices/i2c-%d' % bus_number + devdir = "%d-%4.4x" % (bus_number, addr) + return delete_device(addr, bus, devdir) + +def new_i2c_devices(new_device_list): + for (driver, addr, bus_number) in new_device_list: + for i in range(0, 30): + if new_i2c_device(driver, addr, bus_number) is not True: + time.sleep(1) + continue + else: + break + else: + return False + + return True + +def new_sfp_devices(sfp_bus_list, driver): + for bus_number in sfp_bus_list: + for i in range(0, 30): + if new_i2c_device(driver, 0x50, bus_number) is not True: + time.sleep(1) + continue + else: + break + else: + return False + + return True + +def delete_i2c_devices(delete_device_list): + ret = True + + for (driver, addr, bus_number) in delete_device_list: + if delete_i2c_device(addr, bus_number) is not True: + ret = False + continue + + return ret + +def delete_sfp_devices(sfp_bus_list): + ret = True + + for bus_number in sfp_bus_list: + if delete_i2c_device(0x50, bus_number) is not True: + ret = False + continue + + return ret + +kos = [ + 'depmod -ae', + 'modprobe i2c_dev', + 'modprobe i2c_i801', + 'modprobe i2c_ismt', + 'modprobe i2c_mux_pca954x', + 'modprobe x86-64-accton-as4625-54t-cpld', + 'modprobe x86-64-accton-as4625-54t-fan', + 'modprobe x86-64-accton-as4625-54t-leds', + 'modprobe x86-64-accton-as4625-54t-psu', + 'modprobe optoe', + 'modprobe ym2651y'] + +def driver_install(): + global FORCE + + for i in range(0,len(kos)): + status, output = log_os_system(kos[i], 1) + if status: + if FORCE == 0: + return status + return 0 + +def driver_uninstall(): + global FORCE + for i in reversed(range(0,len(kos))): + rm = kos[i].replace("modprobe", "modprobe -rq") + rm = rm.replace("insmod", "rmmod") + lst = rm.split(" ") + if len(lst) > 3: + del(lst[3]) + rm = " ".join(lst) + status, output = log_os_system(rm, 1) + if status: + if FORCE == 0: + return status + return 0 + +def write_txt_file(file_path, value): + try: + with open(file_path, 'w') as fd: + fd.write(value) + except IOError as e: + print("Error write value to file: %s" % str(e)) + return False + return True + +i2c_prefix = '/sys/bus/i2c/devices/' + +i2c_device_list = [ + # initialize multiplexer (PCA9548) + ('pca9548', 0x70, 1), + ('pca9548', 0x71, 1), + + # initialize CPLD + ('as4625_cpld1', 0x64, 0), + + # initiate PSU-1 AC Power + ('as4625_54t_psu1', 0x50, 8), + ('umec_upd150sa', 0x58, 8), + + # initiate PSU-2 AC Power + ('as4625_54t_psu2', 0x51, 9), + ('umec_upd150sa', 0x59, 9), + + # inititate LM75 + ('lm75', 0x4A, 3), + ('lm75', 0x4B, 3), + ('lm75', 0x4D, 3), + ('lm75', 0x4E, 3), + ('lm75', 0x4F, 3), + + # initiate IDPROM + ('24c02', 0x51, 7) +] + +sfp_bus_list = [ 10, 11, 12, 13, 14, 15 ] + +def device_install(): + global FORCE + + if new_i2c_devices(i2c_device_list) is not True: + return 1 + + if new_sfp_devices(sfp_bus_list, 'optoe2') is not True: + return 1 + + for p in range(len(sfp_bus_list)): + path = "/sys/bus/i2c/devices/{0}-0050/port_name".format(sfp_bus_list[p]) + if write_txt_file(path, 'port{0}'.format(p+49)) is not True: + return 1 + + return + +def device_uninstall(): + global FORCE + + if delete_sfp_devices(sfp_bus_list) is not True: + return 1 + + if delete_i2c_devices(i2c_device_list[::-1]) is not True: + return 1 + + return + +PLATFORM_ROOT_PATH = '/usr/share/sonic/device' +PLATFORM_API2_WHL_FILE_PY3 ='sonic_platform-1.0-py3-none-any.whl' +def do_sonic_platform_install(): + device_path = "{}{}{}{}".format(PLATFORM_ROOT_PATH, '/x86_64-accton_', PROJECT_NAME, '-r0') + SONIC_PLATFORM_BSP_WHL_PKG_PY3 = "/".join([device_path, PLATFORM_API2_WHL_FILE_PY3]) + + #Check API2.0 on py whl file + status, output = log_os_system("pip3 show sonic-platform > /dev/null 2>&1", 0) + if status: + if os.path.exists(SONIC_PLATFORM_BSP_WHL_PKG_PY3): + status, output = log_os_system("pip3 install "+ SONIC_PLATFORM_BSP_WHL_PKG_PY3, 1) + if status: + print("Error: Failed to install {}".format(PLATFORM_API2_WHL_FILE_PY3)) + return status + else: + print("Successfully installed {} package".format(PLATFORM_API2_WHL_FILE_PY3)) + else: + print('{} is not found'.format(PLATFORM_API2_WHL_FILE_PY3)) + else: + print('{} has installed'.format(PLATFORM_API2_WHL_FILE_PY3)) + +def do_sonic_platform_clean(): + status, output = log_os_system("pip3 show sonic-platform > /dev/null 2>&1", 0) + if status: + print('{} does not install, not need to uninstall'.format(PLATFORM_API2_WHL_FILE_PY3)) + + else: + status, output = log_os_system("pip3 uninstall sonic-platform -y", 0) + if status: + print('Error: Failed to uninstall {}'.format(PLATFORM_API2_WHL_FILE_PY3)) + return status + else: + print('{} is uninstalled'.format(PLATFORM_API2_WHL_FILE_PY3)) + + return + +def set_loc_led(color): + global FORCE + + if os.path.exists(LED_LOC_PATH): + cmd = 'echo {} > {}'.format(color, LED_LOC_PATH) + try: + status, output = log_os_system(cmd, 1) + if status: + print(output) + if FORCE == 0: + return status + except Exception as e: + print({}.format(e)) + else: + print('{} does not exist.'.format(LED_LOC_PATH)) + + return + +def do_install(): + print('Checking system....') + if driver_check() is False: + print('No driver, installing....') + status = driver_install() + if status: + if FORCE == 0: + return status + else: + print(PROJECT_NAME.upper() + ' drivers detected....') + if not device_exist(): + print('No device, installing....') + status = device_install() + if status: + if FORCE == 0: + return status + else: + print(PROJECT_NAME.upper() + ' devices detected....') + + set_loc_led(LED_MODE_OFF) + + do_sonic_platform_install() + + return + +def do_uninstall(): + print('Checking system....') + if not device_exist(): + print(PROJECT_NAME.upper() + ' has no device installed....') + else: + print('Removing device....') + status = device_uninstall() + if status and FORCE == 0: + return status + + if driver_check() is False: + print(PROJECT_NAME.upper() + ' has no driver installed....') + else: + print('Removing installed driver....') + status = driver_uninstall() + if status and FORCE == 0: + return status + + do_sonic_platform_clean() + + return None + +def device_exist(): + ret1 = log_os_system('ls ' + i2c_prefix + '*0070', 0) + ret2 = log_os_system('ls ' + i2c_prefix + 'i2c-2', 0) + return not (ret1[0] or ret2[0]) + +if __name__ == '__main__': + main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/classes/fanutil.py index b8b4820f9e..c67b5bb67f 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/classes/fanutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/classes/fanutil.py @@ -42,7 +42,7 @@ class FanUtil(object): FAN_NODE_NUM_OF_MAP = 2 FAN_NODE_FAULT_IDX_OF_MAP = 1 FAN_NODE_DIR_IDX_OF_MAP = 2 - + BASE_VAL_PATH = '/sys/bus/i2c/devices/3-0063/{0}' FAN_DUTY_PATH = '/sys/bus/i2c/devices/3-0063/fan_duty_cycle_percentage' @@ -54,12 +54,7 @@ class FanUtil(object): key2 = fan node index (interger) starting from 1 value = path to fan device file (string) """ _fan_to_device_path_mapping = {} - -#fan1_direction -#fan1_fault -#fan1_present - #(FAN_NUM_2_IDX, FAN_NODE_DUTY_IDX_OF_MAP): 'fan2_duty_cycle_percentage', _fan_to_device_node_mapping = { (FAN_NUM_1_IDX, FAN_NODE_FAULT_IDX_OF_MAP): 'fan1_fault', (FAN_NUM_1_IDX, FAN_NODE_DIR_IDX_OF_MAP): 'fan1_direction', @@ -174,14 +169,10 @@ def get_fan_to_device_path(self, fan_num, node_num): def get_fan_fault(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_FAULT_IDX_OF_MAP) - #def get_fan_speed(self, fan_num): - # return self._get_fan_node_val(fan_num, self.FAN_NODE_SPEED_IDX_OF_MAP) - def get_fan_dir(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_DIR_IDX_OF_MAP) def get_fan_duty_cycle(self): - #duty_path = self.FAN_DUTY_PATH try: val_file = open(self.FAN_DUTY_PATH) except IOError as e: @@ -203,9 +194,6 @@ def set_fan_duty_cycle(self, val): fan_file.close() return True - #def get_fanr_fault(self, fan_num): - # return self._get_fan_node_val(fan_num, self.FANR_NODE_FAULT_IDX_OF_MAP) - def get_fanr_speed(self, fan_num): return self._get_fan_node_val(fan_num, self.FANR_NODE_SPEED_IDX_OF_MAP) @@ -218,9 +206,5 @@ def get_fan_status(self, fan_num): logging.debug('GET. FAN fault. fan_num, %d', fan_num) return False - #if self.get_fanr_fault(fan_num) is not None and self.get_fanr_fault(fan_num) > 0: - # logging.debug('GET. FANR fault. fan_num, %d', fan_num) - # return False - return True diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/Makefile b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/Makefile index ec29de5fe7..eafc97032e 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/Makefile +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/Makefile @@ -1,8 +1,11 @@ ifneq ($(KERNELRELEASE),) obj-m:= accton_as5835_54x_cpld.o accton_as5835_54x_psu.o \ accton_as5835_54x_fan.o accton_as5835_54x_leds.o \ - ym2651y.o + ym2651y.o pddf_custom_psu.o +CFLAGS_pddf_custom_psu.o := -I$(M)/../../../../pddf/i2c/modules/include +KBUILD_EXTRA_SYMBOLS := $(M)/../../../../pddf/i2c/Module.symvers.PDDF + else ifeq (,$(KERNEL_SRC)) $(error KERNEL_SRC is not defined) diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/pddf_custom_psu.c b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/pddf_custom_psu.c new file mode 100644 index 0000000000..1591267b01 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/pddf_custom_psu.c @@ -0,0 +1,117 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "pddf_psu_defs.h" + +ssize_t pddf_show_custom_psu_v_out(struct device *dev, struct device_attribute *da, char *buf); +extern PSU_SYSFS_ATTR_DATA access_psu_v_out; + +static int two_complement_to_int(u16 data, u8 valid_bit, int mask) +{ + u16 valid_data = data & mask; + bool is_negative = valid_data >> (valid_bit - 1); + + return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data; +} + +static u8 psu_get_vout_mode(struct i2c_client *client) +{ + u8 status = 0, retry = 10; + uint8_t offset = 0x20; // VOUT_MODE + + while (retry) { + status = i2c_smbus_read_byte_data((struct i2c_client *)client, offset); + if (unlikely(status < 0)) { + msleep(60); + retry--; + continue; + } + break; + } + + if (status < 0) + { + printk(KERN_ERR "%s: Get PSU Vout mode failed\n", __func__); + return 0; + } + else + { + /*printk(KERN_ERR "%s: vout_mode reg value 0x%x\n", __func__, status);*/ + return status; + } +} + +static u16 psu_get_v_out(struct i2c_client *client) +{ + u16 status = 0, retry = 10; + uint8_t offset = 0x8b; // READ_VOUT + + while (retry) { + status = i2c_smbus_read_word_data((struct i2c_client *)client, offset); + if (unlikely(status < 0)) { + msleep(60); + retry--; + continue; + } + break; + } + + if (status < 0) + { + printk(KERN_ERR "%s: Get PSU Vout failed\n", __func__); + return 0; + } + else + { + /*printk(KERN_ERR "%s: vout reg value 0x%x\n", __func__, status);*/ + return status; + } +} + +ssize_t pddf_show_custom_psu_v_out(struct device *dev, struct device_attribute *da, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + int exponent, mantissa; + int multiplier = 1000; + + u16 value = psu_get_v_out(client); + u8 vout_mode = psu_get_vout_mode(client); + + exponent = two_complement_to_int(vout_mode, 5, 0x1f); + mantissa = value; + if (exponent >= 0) + return sprintf(buf, "%d\n", (mantissa << exponent) * multiplier); + else + return sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent)); +} + + + +static int __init pddf_custom_psu_init(void) +{ + access_psu_v_out.show = pddf_show_custom_psu_v_out; + access_psu_v_out.do_get = NULL; + return 0; +} + +static void __exit pddf_custom_psu_exit(void) +{ + return; +} + +MODULE_AUTHOR("Broadcom"); +MODULE_DESCRIPTION("pddf custom psu api"); +MODULE_LICENSE("GPL"); + +module_init(pddf_custom_psu_init); +module_exit(pddf_custom_psu_exit); + diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/service/as5835-54x-pddf-platform-monitor.service b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/service/as5835-54x-pddf-platform-monitor.service new file mode 100644 index 0000000000..ddd8d6abbb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/service/as5835-54x-pddf-platform-monitor.service @@ -0,0 +1,16 @@ +[Unit] +Description=Accton AS5835-54X Platform Monitoring service +Before=pmon.service +After=pddf-platform-init.service +DefaultDependencies=no + +[Service] +ExecStart=/usr/local/bin/accton_as5835_54x_pddf_monitor.py +KillSignal=SIGKILL +SuccessExitStatus=SIGKILL + +# Resource Limitations +LimitCORE=infinity + +[Install] +WantedBy=multi-user.target diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/service/as5835-54x-platform-monitor.service b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/service/as5835-54x-platform-monitor.service index d522a0ca53..5e0805a598 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/service/as5835-54x-platform-monitor.service +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/service/as5835-54x-platform-monitor.service @@ -1,6 +1,6 @@ [Unit] Description=Accton AS5835-54X Platform Monitoring service -Before=pmon.service +Before=pmon.service system-health.service After=sysinit.target DefaultDependencies=no diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/service/pddf-platform-init.service b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/service/pddf-platform-init.service new file mode 120000 index 0000000000..0fd9f25b6c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/service/pddf-platform-init.service @@ -0,0 +1 @@ +../../../../pddf/i2c/service/pddf-platform-init.service \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/__init__.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/__init__.py new file mode 100644 index 0000000000..cdc3b813f6 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/__init__.py @@ -0,0 +1,3 @@ +# All the derived classes for PDDF +__all__ = ["platform", "chassis", "sfp", "psu", "thermal", "fan"] +from . import platform diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/chassis.py new file mode 100644 index 0000000000..9bd98ed18c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/chassis.py @@ -0,0 +1,128 @@ +#!/usr/bin/env python + +############################################################################# +# PDDF +# Module contains an implementation of SONiC Chassis API +# +############################################################################# + +try: + import sys + from sonic_platform_pddf_base.pddf_chassis import PddfChassis + from .event import SfpEvent + from .helper import APIHelper +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +NUM_COMPONENT = 6 +HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/" +PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/" +REBOOT_CAUSE_FILE = "reboot-cause.txt" + +class Chassis(PddfChassis): + """ + PDDF Platform-specific Chassis class + """ + + SYSLED_DEV_NAME = "DIAG_LED" + + def __init__(self, pddf_data=None, pddf_plugin_data=None): + PddfChassis.__init__(self, pddf_data, pddf_plugin_data) + self.__initialize_components() + self._api_helper = APIHelper() + self._sfpevent = SfpEvent(self.get_all_sfps()) + + def __initialize_components(self): + from sonic_platform.component import Component + for index in range(NUM_COMPONENT): + component = Component(index) + self._component_list.append(component) + + # Provide the functions/variables below for which implementation is to be overwritten + def get_change_event(self, timeout=0): + return self._sfpevent.get_sfp_event(timeout) + + def get_reboot_cause(self): + """ + Retrieves the cause of the previous reboot + Returns: + A tuple (string, string) where the first element is a string + containing the cause of the previous reboot. This string must be + one of the predefined strings in this class. If the first string + is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used + to pass a description of the reboot cause. + """ + + reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE) + sw_reboot_cause = self._api_helper.read_txt_file( + reboot_cause_path) or "Unknown" + + + return ('REBOOT_CAUSE_NON_HARDWARE', sw_reboot_cause) + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position + for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device or -1 if cannot determine the position + """ + return -1 + + + def get_sfp(self, index): + """ + Retrieves sfp represented by (1-based) index + + Args: + index: An integer, the index (1-based) of the sfp to retrieve. + The index should be the sequence of a physical port in a chassis, + starting from 1. + For example, 1 for Ethernet0, 2 for Ethernet4 and so on. + + Returns: + An object derived from SfpBase representing the specified sfp + """ + sfp = None + + try: + # The index will start from 1 + sfp = self._sfp_list[index-1] + except IndexError: + sys.stderr.write("SFP index {} out of range (1-{})\n".format( + index, len(self._sfp_list))) + return sfp + + def initizalize_system_led(self): + return + + def get_status_led(self): + return self.get_system_led(self.SYSLED_DEV_NAME) + + def set_status_led(self, color): + return self.set_system_led(self.SYSLED_DEV_NAME, color) + + def get_port_or_cage_type(self, port): + from sonic_platform_base.sfp_base import SfpBase + if port in range(1, 49): + return SfpBase.SFP_PORT_TYPE_BIT_SFP | SfpBase.SFP_PORT_TYPE_BIT_SFP_PLUS + else: + return SfpBase.SFP_PORT_TYPE_BIT_QSFP | SfpBase.SFP_PORT_TYPE_BIT_QSFP_PLUS | SfpBase.SFP_PORT_TYPE_BIT_QSFP28 + + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + return 'N/A' \ No newline at end of file diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/component.py similarity index 79% rename from device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/component.py rename to platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/component.py index 75c2d3b918..d0932600c1 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/component.py @@ -1,36 +1,41 @@ ############################################################################# -# Edgecore -# +# # Component contains an implementation of SONiC Platform Base API and # provides the components firmware management function # ############################################################################# try: + import subprocess from sonic_platform_base.component_base import ComponentBase except ImportError as e: raise ImportError(str(e) + "- required module not found") CPLD_ADDR_MAPPING = { - "CPLD-1": "18-0060", - "CPLD-2": "12-0062", - "CPLD-3": "19-0064", + "MB_CPLD1": ['3', '0x60'], + "MB_CPLD2": ['3', '0x61'], + "MB_CPLD3": ['3', '0x62'], + "FAN_CPLD": ['3', '0x63'], + "CPU_CPLD": ['1', '0x65'] } SYSFS_PATH = "/sys/bus/i2c/devices/" BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version" -COMPONENT_NAME_LIST = ["CPLD-1", "CPLD-2", "CPLD-3", "BIOS"] -COMPONENT_DES_LIST = [ - "CPLD-1", "CPLD-2", "CPLD-3", "Basic Input/Output System" +COMPONENT_LIST= [ + ("MB_CPLD1", "Mainboard CPLD(0x60)"), + ("MB_CPLD2", "Mainboard CPLD(0x61)"), + ("MB_CPLD3", "Mainboard CPLD(0x62)"), + ("FAN_CPLD", "Fan board CPLD(0x63)"), + ("CPU_CPLD", "CPU CPLD(0x65)"), + ("BIOS", "Basic Input/Output System") + ] - class Component(ComponentBase): """Platform-specific Component class""" DEVICE_TYPE = "component" def __init__(self, component_index=0): - ComponentBase.__init__(self) self.index = component_index self.name = self.get_name() @@ -42,26 +47,16 @@ def __get_bios_version(self): return bios_version.strip() except Exception as e: return None - - def __get_sysfs_value(self, addr, name): - # Retrieves the cpld register value - try: - with open(SYSFS_PATH + addr + '/' + name, 'r') as fd: - return fd.read().strip() - except Exception as e: - return None - + def __get_cpld_version(self): # Retrieves the CPLD firmware version cpld_version = dict() for cpld_name in CPLD_ADDR_MAPPING: - try: - cpld_addr = CPLD_ADDR_MAPPING[cpld_name] - cpld_version_raw = self.__get_sysfs_value(cpld_addr, "version") - cpld_version[cpld_name] = "{}".format( - int(cpld_version_raw, 16)) - except Exception as e: - cpld_version[cpld_name] = 'None' + cmd = "i2cget -f -y {0} {1} 0x1".format(CPLD_ADDR_MAPPING[cpld_name][0], CPLD_ADDR_MAPPING[cpld_name][1]) + status, value = subprocess.getstatusoutput(cmd) + if not status: + cpld_version_raw = value.rstrip() + cpld_version[cpld_name] = "{}".format(int(cpld_version_raw,16)) return cpld_version @@ -71,7 +66,7 @@ def get_name(self): Returns: A string containing the name of the component """ - return COMPONENT_NAME_LIST[self.index] + return COMPONENT_LIST[self.index][0] def get_description(self): """ @@ -79,7 +74,7 @@ def get_description(self): Returns: A string containing the description of the component """ - return COMPONENT_DES_LIST[self.index] + return COMPONENT_LIST[self.index][1] def get_firmware_version(self): """ diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/eeprom.py new file mode 100644 index 0000000000..a87ecc9f6f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/eeprom.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +try: + from sonic_platform_pddf_base.pddf_eeprom import PddfEeprom +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Eeprom(PddfEeprom): + + def __init__(self, pddf_data=None, pddf_plugin_data=None): + PddfEeprom.__init__(self, pddf_data, pddf_plugin_data) + + # Provide the functions/variables below for which implementation is to be overwritten diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/event.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/event.py similarity index 94% rename from device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/event.py rename to platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/event.py index 3d6f81518a..d5dac6d7f7 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/event.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/event.py @@ -18,7 +18,7 @@ def get_presence_bitmap(self): bitmap = 0 for sfp in self._sfp_list: modpres = sfp.get_presence() - i=sfp.port_num-1 + i=sfp.get_position_in_parent() - 1 if modpres: bitmap = bitmap | (1 << i) return bitmap @@ -45,7 +45,7 @@ def get_sfp_event(self, timeout=2000): if changed_ports != 0: for sfp in self._sfp_list: - i=sfp.port_num-1 + i=sfp.get_position_in_parent() - 1 if (changed_ports & (1 << i)): if (bitmap & (1 << i)) == 0: port_dict[i+1] = '0' diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/fan.py new file mode 100644 index 0000000000..7aa6ebb387 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/fan.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + + +try: + from sonic_platform_pddf_base.pddf_fan import PddfFan +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +FAN_NAME_LIST = ["FAN-1F", "FAN-1R", "FAN-2F", "FAN-2R", + "FAN-3F", "FAN-3R", "FAN-4F", "FAN-4R", + "FAN-5F", "FAN-5R"] + +class Fan(PddfFan): + """PDDF Platform-Specific Fan class""" + + def __init__(self, tray_idx, fan_idx=0, pddf_data=None, pddf_plugin_data=None, is_psu_fan=False, psu_index=0): + # idx is 0-based + PddfFan.__init__(self, tray_idx, fan_idx, pddf_data, pddf_plugin_data, is_psu_fan, psu_index) + + # Provide the functions/variables below for which implementation is to be overwritten + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + fan_name = FAN_NAME_LIST[(self.fantray_index-1)*2 + self.fan_index-1] \ + if not self.is_psu_fan \ + else "PSU-{} FAN-{}".format(self.fans_psu_index, self.fan_index) + + return fan_name + + + + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + + return "N/A" + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return "N/A" + + def get_target_speed(self): + """ + Retrieves the target (expected) speed of the fan + + Returns: + An integer, the percentage of full fan speed, in the range 0 (off) + to 100 (full speed) + """ + if self.is_psu_fan: + return super().get_speed() + else: + return super().get_target_speed() diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/fan_drawer.py new file mode 100644 index 0000000000..e4e37f9620 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/fan_drawer.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + + +try: + from sonic_platform_pddf_base.pddf_fan_drawer import PddfFanDrawer +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class FanDrawer(PddfFanDrawer): + """PDDF Platform-Specific Fan-Drawer class""" + + def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None): + # idx is 0-based + PddfFanDrawer.__init__(self, tray_idx, pddf_data, pddf_plugin_data) + + # Provide the functions/variables below for which implementation is to be overwritten + def get_name(self): + """ + Retrieves the fan drawer name + Returns: + string: The name of the device + """ + return "FanTray{}".format(self.fantray_index) + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + return self._fan_list[0].get_model() + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return self._fan_list[0].get_serial() + diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/helper.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/helper.py new file mode 100644 index 0000000000..24c8739340 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/helper.py @@ -0,0 +1,318 @@ +import os +import struct +import json +import fcntl +from mmap import * +from sonic_py_common import device_info +from sonic_py_common import logger +from threading import Lock +from typing import cast +from sonic_py_common.general import getstatusoutput_noshell_pipe +from sonic_py_common.general import getstatusoutput_noshell + +HOST_CHK_CMD = ["docker"] +EMPTY_STRING = "" + + +class APIHelper(): + + def __init__(self): + (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() + + def is_host(self): + try: + status, output = getstatusoutput_noshell(HOST_CHK_CMD) + return status == 0 + except Exception: + return False + + def pci_get_value(self, resource, offset): + status = True + result = "" + try: + fd = os.open(resource, os.O_RDWR) + mm = mmap(fd, 0) + mm.seek(int(offset)) + read_data_stream = mm.read(4) + result = struct.unpack('I', read_data_stream) + except Exception: + status = False + return status, result + + def read_txt_file(self, file_path): + try: + with open(file_path, 'r', errors='replace') as fd: + data = fd.read() + ret = data.strip() + if len(ret) > 0: + return ret + except IOError: + pass + return None + + def write_txt_file(self, file_path, value): + try: + with open(file_path, 'w') as fd: + fd.write(str(value)) + except IOError: + return False + return True + +class FileLock: + """ + Due to pmon docker not installing the py-filelock, this class + implements a simple file lock feature. + Ref: https://github.com/tox-dev/py-filelock/blob/main/src/filelock/ + """ + + def __init__(self, lock_file): + self._lock_file = lock_file + self._thread_lock = Lock() + self.is_locked = False + + def acquire(self): + with self._thread_lock: + if self.is_locked: + return + + fd = os.open(self._lock_file, flags=(os.O_RDWR | os.O_CREAT | os.O_TRUNC)) + fcntl.flock(fd, fcntl.LOCK_EX) + self._lock_file_fd = fd + self.is_locked = True + + def release(self): + with self._thread_lock: + if self.is_locked: + fd = cast(int, self._lock_file_fd) + self._lock_file_fd = None + fcntl.flock(fd, fcntl.LOCK_UN) + os.close(fd) + self.is_locked = False + + def __enter__(self): + self.acquire() + return self + + def __exit__(self, exc_type, exc_val, traceback): + self.release() + + def __del__(self): + self.release() + + +DEVICE_THRESHOLD_JSON_PATH = "/tmp/device_threshold.json" + +class DeviceThreshold: + HIGH_THRESHOLD = 'high_threshold' + LOW_THRESHOLD = 'low_threshold' + HIGH_CRIT_THRESHOLD = 'high_critical_threshold' + LOW_CRIT_THRESHOLD = 'low_critical_threshold' + NOT_AVAILABLE = 'N/A' + + def __init__(self, th_name = NOT_AVAILABLE): + self.flock = FileLock("{}.lock".format(DEVICE_THRESHOLD_JSON_PATH)) + self.name = th_name + self.__log = logger.Logger(log_identifier="DeviceThreshold") + + self.__db_data = {} + self.__db_mtime = 0 + + def __reload_db(self): + try: + db_data = {} + with self.flock: + with open(DEVICE_THRESHOLD_JSON_PATH, "r") as db_file: + db_data = json.load(db_file) + except Exception as e: + self.__log.log_warning('{}'.format(str(e))) + return None + + return db_data + + def __get_data(self, field): + """ + Retrieves data frome JSON file by field + + Args : + field: String + + Returns: + A string if getting is successfully, 'N/A' if not + """ + if os.path.exists(DEVICE_THRESHOLD_JSON_PATH): + new_mtime = os.path.getmtime(DEVICE_THRESHOLD_JSON_PATH) + if new_mtime != self.__db_mtime: + new_data = self.__reload_db() + if new_data is not None: + self.__db_data = new_data + self.__db_mtime = new_mtime + + if self.name not in self.__db_data.keys(): + return self.NOT_AVAILABLE + + if field not in self.__db_data[self.name].keys(): + return self.NOT_AVAILABLE + + return self.__db_data[self.name][field] + + def __set_data(self, field, new_val): + """ + Set data to JSON file by field + + Args : + field: String + new_val: String + + Returns: + A boolean, True if setting is set successfully, False if not + """ + if self.name not in self.__db_data.keys(): + self.__db_data[self.name] = {} + + old_val = self.__db_data[self.name].get(field, None) + if old_val is not None and old_val == new_val: + return True + + self.__db_data[self.name][field] = new_val + + try: + with self.flock: + db_data = {} + mode = "r+" if os.path.exists(DEVICE_THRESHOLD_JSON_PATH) else "w+" + with open(DEVICE_THRESHOLD_JSON_PATH, mode) as db_file: + if mode == "r+": + db_data = json.load(db_file) + + if self.name not in db_data.keys(): + db_data[self.name] = {} + + db_data[self.name][field] = new_val + + if mode == "r+": + db_file.seek(0) + # erase old data + db_file.truncate(0) + # write all data + json.dump(db_data, db_file, indent=4) + self.__db_mtime = os.path.getmtime(DEVICE_THRESHOLD_JSON_PATH) + except Exception as e: + self.__log.log_error('{}'.format(str(e))) + return False + + return True + + def get_high_threshold(self): + """ + Retrieves the high threshold temperature from JSON file. + + Returns: + string : the high threshold temperature of thermal, + e.g. "30.125" + """ + return self.__get_data(self.HIGH_THRESHOLD) + + def set_high_threshold(self, temperature): + """ + Sets the high threshold temperature of thermal + Args : + temperature: A string of temperature, e.g. "30.125" + Returns: + A boolean, True if threshold is set successfully, False if not + """ + if isinstance(temperature, str) is not True: + raise TypeError('The parameter requires string type.') + + try: + if temperature != self.NOT_AVAILABLE: + float(temperature) + except ValueError: + raise ValueError('The parameter requires a float string. ex:\"30.1\"') + + return self.__set_data(self.HIGH_THRESHOLD, temperature) + + def get_low_threshold(self): + """ + Retrieves the low threshold temperature from JSON file. + + Returns: + string : the low threshold temperature of thermal, + e.g. "30.125" + """ + return self.__get_data(self.LOW_THRESHOLD) + + def set_low_threshold(self, temperature): + """ + Sets the low threshold temperature of thermal + Args : + temperature: A string of temperature, e.g. "30.125" + Returns: + A boolean, True if threshold is set successfully, False if not + """ + if isinstance(temperature, str) is not True: + raise TypeError('The parameter requires string type.') + + try: + if temperature != self.NOT_AVAILABLE: + float(temperature) + except ValueError: + raise ValueError('The parameter requires a float string. ex:\"30.1\"') + + return self.__set_data(self.LOW_THRESHOLD, temperature) + + def get_high_critical_threshold(self): + """ + Retrieves the high critical threshold temperature from JSON file. + + Returns: + string : the high critical threshold temperature of thermal, + e.g. "30.125" + """ + return self.__get_data(self.HIGH_CRIT_THRESHOLD) + + def set_high_critical_threshold(self, temperature): + """ + Sets the high critical threshold temperature of thermal + Args : + temperature: A string of temperature, e.g. "30.125" + Returns: + A boolean, True if threshold is set successfully, False if not + """ + if isinstance(temperature, str) is not True: + raise TypeError('The parameter requires string type.') + + try: + if temperature != self.NOT_AVAILABLE: + float(temperature) + except ValueError: + raise ValueError('The parameter requires a float string. ex:\"30.1\"') + + return self.__set_data(self.HIGH_CRIT_THRESHOLD, temperature) + + def get_low_critical_threshold(self): + """ + Retrieves the low critical threshold temperature from JSON file. + + Returns: + string : the low critical threshold temperature of thermal, + e.g. "30.125" + """ + return self.__get_data(self.LOW_CRIT_THRESHOLD) + + def set_low_critical_threshold(self, temperature): + """ + Sets the low critical threshold temperature of thermal + Args : + temperature: A string of temperature, e.g. "30.125" + Returns: + A boolean, True if threshold is set successfully, False if not + """ + if isinstance(temperature, str) is not True: + raise TypeError('The parameter requires string type.') + + try: + if temperature != self.NOT_AVAILABLE: + float(temperature) + except ValueError: + raise ValueError('The parameter requires a float string. ex:\"30.1\"') + + return self.__set_data(self.LOW_CRIT_THRESHOLD, temperature) diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/pcie.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/pcie.py new file mode 100644 index 0000000000..e4da32adf9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/pcie.py @@ -0,0 +1,19 @@ +############################################################################# +# Edgecore +# +# Module contains an implementation of SONiC Platform Base API and +# provides the fan status which are available in the platform +# Base PCIe class +############################################################################# + +try: + from sonic_platform_base.sonic_pcie.pcie_common import PcieUtil +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Pcie(PcieUtil): + """Edgecore Platform-specific PCIe class""" + + def __init__(self, platform_path): + PcieUtil.__init__(self, platform_path) diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/platform.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/platform.py new file mode 100644 index 0000000000..406b1179ae --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/platform.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +############################################################################# +# PDDF +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# + + +try: + from sonic_platform_pddf_base.pddf_platform import PddfPlatform +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Platform(PddfPlatform): + """ + PDDF Platform-Specific Platform Class + """ + + def __init__(self): + PddfPlatform.__init__(self) + + # Provide the functions/variables below for which implementation is to be overwritten diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/psu.py new file mode 100644 index 0000000000..a05923cc83 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/psu.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python +# + + +try: + from sonic_platform_pddf_base.pddf_psu import PddfPsu +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + + +class Psu(PddfPsu): + """PDDF Platform-Specific PSU class""" + + PLATFORM_PSU_CAPACITY = 1200 + + def __init__(self, index, pddf_data=None, pddf_plugin_data=None): + PddfPsu.__init__(self, index, pddf_data, pddf_plugin_data) + + # Provide the functions/variables below for which implementation is to be overwritten + def get_voltage_high_threshold(self): + """ + Retrieves the high threshold PSU voltage output + Returns: + A float number, the high threshold output voltage in volts, + e.g. 12.1 + """ + return 14.72 + + def get_voltage_low_threshold(self): + """ + Retrieves the low threshold PSU voltage output + Returns: + A float number, the low threshold output voltage in volts, + e.g. 12.1 + """ + return 7.68 + + def get_name(self): + return "PSU-{}".format(self.psu_index) + + def get_maximum_supplied_power(self): + """ + Retrieves the maximum supplied power by PSU (or PSU capacity) + Returns: + A float number, the maximum power output in Watts. + e.g. 1200.1 + """ + return float(self.PLATFORM_PSU_CAPACITY) + + def get_capacity(self): + """ + Gets the capacity (maximum output power) of the PSU in watts + + Returns: + An integer, the capacity of PSU + """ + return (self.PLATFORM_PSU_CAPACITY) + + def get_type(self): + """ + Gets the type of the PSU + Returns: + A string, the type of PSU (AC/DC) + """ + return "AC" + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + + Returns: + string: Model/part number of device + """ + model = super().get_model() + if model and model.strip() == "": + return None + + return model + + def get_serial(self): + """ + Retrieves the serial number of the device + + Returns: + string: Serial number of device + """ + serial = super().get_serial() + if serial and serial.strip() == "": + return None + + return serial + + def get_voltage(self): + """ + Retrieves current PSU voltage output + + Returns: + A float number, the output voltage in volts, + e.g. 12.1 + """ + if self.get_status() is not True: + return 0.0 + + return super().get_voltage() + + def get_current(self): + """ + Retrieves present electric current supplied by PSU + + Returns: + A float number, electric current in amperes, + e.g. 15.4 + """ + if self.get_status() is not True: + return 0.0 + + return super().get_current() + + def get_power(self): + """ + Retrieves current energy supplied by PSU + + Returns: + A float number, the power in watts, + e.g. 302.6 + """ + if self.get_status() is not True: + return 0.0 + + return super().get_power() diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/sfp.py new file mode 100644 index 0000000000..b94e5d257c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/sfp.py @@ -0,0 +1,197 @@ +#!/usr/bin/env python + +try: + import natsort + from sonic_platform_pddf_base.pddf_sfp import PddfSfp + from sonic_platform_base.sonic_sfp.sfputilhelper import SfpUtilHelper + from sonic_py_common import device_info +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + + +class Sfp(PddfSfp): + """ + PDDF Platform-Specific Sfp class + """ + + SFP_TYPE_CODE_LIST = [ + 0x03, # SFP/SFP+/SFP28 + 0x0b # DWDM-SFP/SFP+ + ] + QSFP_TYPE_CODE_LIST = [ + 0x0c, # QSFP + 0x0d, # QSFP+ or later + 0x11, # QSFP28 or later + 0xe1 # QSFP28 EDFA + ] + + def __init__(self, index, pddf_data=None, pddf_plugin_data=None): + PddfSfp.__init__(self, index, pddf_data, pddf_plugin_data) + self.index = index + 1 + + # Provide the functions/variables below for which implementation is to be overwritten + def __get_path_to_port_config_file(self): + platform, hwsku = device_info.get_platform_and_hwsku() + hwsku_path = "/".join(["/usr/share/sonic/platform",hwsku]) + return "/".join([hwsku_path, "port_config.ini"]) + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + sfputil_helper = SfpUtilHelper() + sfputil_helper.read_porttab_mappings( + self.__get_path_to_port_config_file()) + + logical_port_list = sfputil_helper.logical + logical_port_list = natsort.natsorted(logical_port_list) + name = logical_port_list[self.port_index-1] or "Unknown" + + return name + + def get_position_in_parent(self): + """Retrieves 1-based relative physical position in parent device.""" + return self.port_index + + def __validate_eeprom_sfp(self): + checksum_test = 0 + eeprom_raw = self.read_eeprom(0, 96) + if eeprom_raw is None: + return None + + for i in range(0, 63): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[63]: + return False + + checksum_test = 0 + for i in range(64, 95): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[95]: + return False + + api = self.get_xcvr_api() + if api is None: + return False + + if api.is_flat_memory(): + return True + + checksum_test = 0 + eeprom_raw = self.read_eeprom(384, 96) + if eeprom_raw is None: + return None + + for i in range(0, 95): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[95]: + return False + + return True + + def __validate_eeprom_qsfp(self): + checksum_test = 0 + eeprom_raw = self.read_eeprom(128, 96) + if eeprom_raw is None: + return None + + for i in range(0, 63): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[63]: + return False + + checksum_test = 0 + for i in range(64, 95): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[95]: + return False + + api = self.get_xcvr_api() + if api is None: + return False + + if api.is_flat_memory(): + return True + + return True + + def validate_eeprom(self): + id_byte_raw = self.read_eeprom(0, 1) + if id_byte_raw is None: + return None + + id = id_byte_raw[0] + if id in self.QSFP_TYPE_CODE_LIST: + return self.__validate_eeprom_qsfp() + elif id in self.SFP_TYPE_CODE_LIST: + return self.__validate_eeprom_sfp() + else: + return False + + def validate_temperature(self): + temperature = self.get_temperature() + if temperature is None: + return None + + threshold_dict = self.get_transceiver_threshold_info() + if threshold_dict is None: + return None + + if isinstance(temperature, float) is not True: + return True + + if isinstance(threshold_dict['temphighalarm'], float) is not True: + return True + + return threshold_dict['temphighalarm'] > temperature + + def __get_error_description(self): + if not self.get_presence(): + return self.SFP_STATUS_UNPLUGGED + + err_stat = self.SFP_STATUS_BIT_INSERTED + + status = self.validate_eeprom() + if status is not True: + err_stat = (err_stat | self.SFP_ERROR_BIT_BAD_EEPROM) + + status = self.validate_temperature() + if status is not True: + err_stat = (err_stat | self.SFP_ERROR_BIT_HIGH_TEMP) + + if err_stat is self.SFP_STATUS_BIT_INSERTED: + return self.SFP_STATUS_OK + else: + err_desc = '' + cnt = 0 + for key in self.SFP_ERROR_BIT_TO_DESCRIPTION_DICT: + if (err_stat & key) != 0: + if cnt > 0: + err_desc = err_desc + "|" + cnt = cnt + 1 + err_desc = err_desc + self.SFP_ERROR_BIT_TO_DESCRIPTION_DICT[key] + + return err_desc + + def get_error_description(self): + """ + Retrives the error descriptions of the SFP module + Returns: + String that represents the current error descriptions of vendor specific errors + In case there are multiple errors, they should be joined by '|', + like: "Bad EEPROM|Unsupported cable" + """ + try: + ret = super().get_error_description() + if ret is not None: + return ret + except NotImplementedError: + pass + return self.__get_error_description() diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/thermal.py new file mode 100644 index 0000000000..cdd6c0993e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/thermal.py @@ -0,0 +1,290 @@ +#!/usr/bin/env python + + +try: + from sonic_platform_pddf_base.pddf_thermal import PddfThermal + from .helper import DeviceThreshold +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +NOT_AVAILABLE = DeviceThreshold.NOT_AVAILABLE +HIGH_THRESHOLD = DeviceThreshold.HIGH_THRESHOLD +LOW_THRESHOLD = DeviceThreshold.LOW_THRESHOLD +HIGH_CRIT_THRESHOLD = DeviceThreshold.HIGH_CRIT_THRESHOLD +LOW_CRIT_THRESHOLD = DeviceThreshold.LOW_CRIT_THRESHOLD + +DEFAULT_THRESHOLD = { + 'CB_temp(0x4B)' : { + HIGH_THRESHOLD : '80.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : NOT_AVAILABLE, + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'MB_FrontMiddle_temp(0x4C)' : { + HIGH_THRESHOLD : '80.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : NOT_AVAILABLE, + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'MB_RearLeft_temp(0x49)' : { + HIGH_THRESHOLD : '80.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : NOT_AVAILABLE, + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'MB_RearLeft_temp(0x4A)' : { + HIGH_THRESHOLD : '80.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : NOT_AVAILABLE, + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'CPU_Package_temp' : { + HIGH_THRESHOLD : '82.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : '104.0', + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'CPU_Core_0_temp' : { + HIGH_THRESHOLD : '82.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : '104.0', + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'CPU_Core_1_temp' : { + HIGH_THRESHOLD : '82.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : '104.0', + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'CPU_Core_2_temp' : { + HIGH_THRESHOLD : '82.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : '104.0', + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'CPU_Core_3_temp' : { + HIGH_THRESHOLD : '82.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : '104.0', + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'PSU-1 temp sensor 1' : { + HIGH_THRESHOLD : '80.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : NOT_AVAILABLE, + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'PSU-2 temp sensor 1' : { + HIGH_THRESHOLD : '80.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : NOT_AVAILABLE, + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + } +} + +class Thermal(PddfThermal): + """PDDF Platform-Specific Thermal class""" + + def __init__(self, index, pddf_data=None, pddf_plugin_data=None, is_psu_thermal=False, psu_index=0): + PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data, is_psu_thermal, psu_index) + + self.pddf_obj = pddf_data + self.thermal_obj_name = "TEMP{}".format(self.thermal_index) + self.thermal_obj = self.pddf_obj.data[self.thermal_obj_name] + + # Threshold Configuration + self.__conf = DeviceThreshold(self.get_name()) + # Default threshold. + self.__default_threshold = DEFAULT_THRESHOLD[self.get_name()] + self.min_temperature = None + self.max_temperature = None + + # Provide the functions/variables below for which implementation is to be overwritten + def get_name(self): + if self.is_psu_thermal: + return "PSU-{0} temp sensor 1".format(self.thermals_psu_index) + else: + if 'dev_attr' in self.thermal_obj.keys(): + if 'display_name' in self.thermal_obj['dev_attr']: + return str(self.thermal_obj['dev_attr']['display_name']) + + # In case of errors + return "Temp sensor {0}".format(self.thermal_index) + + def get_status(self): + get_temp=self.get_temperature() + + if get_temp is not None: + return True if get_temp else False + + def get_temperature(self): + current = super().get_temperature() + + if self.min_temperature is None or \ + current < self.min_temperature: + self.min_temperature = current + + if self.max_temperature is None or \ + current > self.max_temperature: + self.max_temperature = current + + return current + + def set_high_threshold(self, temperature): + try: + value = float(temperature) + except Exception: + return False + + # The new value can not be more than the default value. + default_value = self.__default_threshold[HIGH_THRESHOLD] + if default_value != NOT_AVAILABLE: + if value > float(default_value): + return False + + try: + self.__conf.set_high_threshold(str(value)) + except Exception: + return False + + return True + + def get_high_threshold(self): + value = self.__conf.get_high_threshold() + if value != NOT_AVAILABLE: + return float(value) + + default_value = self.__default_threshold[HIGH_THRESHOLD] + if default_value != NOT_AVAILABLE: + return float(default_value) + + return super().get_high_threshold() + + def set_low_threshold(self, temperature): + try: + value = float(temperature) + except Exception: + return False + + # The new value can not be less than the default value. + default_value = self.__default_threshold[LOW_THRESHOLD] + if default_value != NOT_AVAILABLE: + if value < float(default_value): + return False + + try: + self.__conf.set_low_threshold(str(value)) + except Exception: + return False + + return True + + def get_low_threshold(self): + value = self.__conf.get_low_threshold() + if value != NOT_AVAILABLE: + return float(value) + + default_value = self.__default_threshold[LOW_THRESHOLD] + if default_value != NOT_AVAILABLE: + return float(default_value) + + raise NotImplementedError + + def set_high_critical_threshold(self, temperature): + try: + value = float(temperature) + except Exception: + return False + + # The new value can not be more than the default value. + default_value = self.__default_threshold[HIGH_CRIT_THRESHOLD] + if default_value != NOT_AVAILABLE: + if value > float(default_value): + return False + + try: + self.__conf.set_high_critical_threshold(str(value)) + except Exception: + return False + + return True + + def get_high_critical_threshold(self): + value = self.__conf.get_high_critical_threshold() + if value != NOT_AVAILABLE: + return float(value) + + default_value = self.__default_threshold[HIGH_CRIT_THRESHOLD] + if default_value != NOT_AVAILABLE: + return float(default_value) + return super().get_high_critical_threshold() + + def set_low_critical_threshold(self, temperature): + try: + value = float(temperature) + except Exception: + return False + + # The new value can not be less than the default value. + default_value = self.__default_threshold[LOW_CRIT_THRESHOLD] + if default_value != NOT_AVAILABLE: + if value < float(default_value): + return False + + try: + self.__conf.set_low_critical_threshold(str(value)) + except Exception: + return False + + return True + + def get_low_critical_threshold(self): + value = self.__conf.get_low_critical_threshold() + if value != NOT_AVAILABLE: + return float(value) + + default_value = self.__default_threshold[LOW_CRIT_THRESHOLD] + if default_value != NOT_AVAILABLE: + return float(default_value) + + raise NotImplementedError + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + return 'N/A' + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return 'N/A' + + def get_minimum_recorded(self): + """ + Retrieves the minimum recorded temperature of thermal + Returns: + A float number, the minimum recorded temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.min_temperature is None: + self.get_temperature() + + return self.min_temperature + + def get_maximum_recorded(self): + """ + Retrieves the maximum recorded temperature of thermal + Returns: + A float number, the maximum recorded temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.max_temperature is None: + self.get_temperature() + + return self.max_temperature diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/watchdog.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/watchdog.py new file mode 100644 index 0000000000..88660b1a1f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform/watchdog.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +############################################################################# +# +# Module contains an implementation of platform specific watchdog API's +# +############################################################################# + +try: + from sonic_platform_pddf_base.pddf_watchdog import PddfWatchdog +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +class Watchdog(PddfWatchdog): + """ + PDDF Platform-specific Chassis class + """ + + def __init__(self): + PddfWatchdog.__init__(self) + self.timeout= 180 + + # Provide the functions/variables below for which implementation is to be overwritten diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform_setup.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform_setup.py index a775511c64..22bd354ea6 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform_setup.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/sonic_platform_setup.py @@ -1,8 +1,5 @@ from setuptools import setup -DEVICE_NAME = 'accton' -HW_SKU = 'x86_64-accton_as5835_54x-r0' - setup( name='sonic-platform', version='1.0', @@ -11,13 +8,7 @@ author='SONiC Team', author_email='linuxnetdev@microsoft.com', url='https://github.com/Azure/sonic-buildimage', - maintainer='Jostar Yang', - maintainer_email='jostar_yang@accton.com', - packages=[ - 'sonic_platform', - ], - package_dir={ - 'sonic_platform': '../../../../device/{}/{}/sonic_platform'.format(DEVICE_NAME, HW_SKU)}, + packages=['sonic_platform'], classifiers=[ 'Development Status :: 3 - Alpha', 'Environment :: Plugins', diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/accton_as5835_54x_pddf_monitor.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/accton_as5835_54x_pddf_monitor.py new file mode 100755 index 0000000000..02be5a0972 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/accton_as5835_54x_pddf_monitor.py @@ -0,0 +1,241 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2019 Accton Technology Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# ------------------------------------------------------------------ +# HISTORY: +# mm/dd/yyyy (A.D.) +# 05/29/2019: Brandon Chuang, changed for as5835-54x. +# 08/03/2020: Jostar Yang, change to call PDDF API . +# ------------------------------------------------------------------ + +try: + import sys, getopt + import logging + import logging.config + import time + import signal + from sonic_platform import platform +except ImportError as e: + raise ImportError('%s - required module not found' % str(e)) + +# Deafults +VERSION = '1.0' +FUNCTION_NAME = 'accton_as5835_54x_monitor' +DUTY_MAX = 100 + +platform_chassis = None + +test_temp = 0 +test_temp_list = [0, 0, 0, 0] +test_temp_revert=0 +temp_test_data=0 + +# Make a class we can use to capture stdout and sterr in the log +class accton_as5835_54x_monitor(object): + # static temp var + _ori_temp = 0 + _new_perc = 0 + + def __init__(self, log_file, log_level): + """Needs a logger and a logger level.""" + # set up logging to file + logging.basicConfig( + filename=log_file, + filemode='w', + level=log_level, + format= '[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s', + datefmt='%H:%M:%S' + ) + + # set up logging to console + if log_level == logging.DEBUG: + console = logging.StreamHandler() + console.setLevel(log_level) + formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') + console.setFormatter(formatter) + logging.getLogger('').addHandler(console) + + logging.debug('SET. logfile:%s / loglevel:%d', log_file, log_level) + + def manage_fans(self): + global platform_chassis + global test_temp_list + global temp_test_data + global test_temp + + THERMAL_NUM_MAX=4 + FAN_LEV1_UP_TEMP = 57700 # temperature + FAN_LEV1_SPEED_PERC = DUTY_MAX # percentage*/ + + FAN_LEV2_UP_TEMP = 53000 + FAN_LEV2_DOWN_TEMP = 52700 + FAN_LEV2_SPEED_PERC = 80 + + FAN_LEV3_UP_TEMP = 49500 + FAN_LEV3_DOWN_TEMP = 47700 + FAN_LEV3_SPEED_PERC = 65 + + FAN_LEV4_DOWN_TEMP = 42700 + FAN_LEV4_SPEED_PERC = 40 + + FAN_NUM=2 + FAN_TRAY_NUM=5 + + if test_temp_revert==0: + temp_test_data=temp_test_data+2000 + else: + temp_test_data=temp_test_data-2000 + + if test_temp==0: + temp2=platform_chassis.get_thermal(1).get_temperature()*1000 + if temp2 is None: + return False + + temp3=platform_chassis.get_thermal(2).get_temperature()*1000 + if temp3 is None: + return False + + new_temp = (temp2 + temp3) / 2 + else: + thermal_val=[0,0,0,0] + for i in range (THERMAL_NUM_MAX): + thermal_val[i]=test_temp_list[i] + thermal_val[i]= thermal_val[i] + temp_test_data + + + new_temp = (thermal_val[1] + thermal_val[2])/2 + logging.debug("Test case:thermal_val[1]=%d, thermal_val[2]=%d, get new_temp=%d", thermal_val[1], thermal_val[2],new_temp) + + for x in range(FAN_TRAY_NUM * FAN_NUM): + #fan_stat = platform_chassis.get_fan(x).get_status() or not platform_chassis.get_fan(x).get_speed_rpm() + + #if fan_stat is None: + # return False + #if fan_stat is False: + fan_stat=True + if not platform_chassis.get_fan(x).get_status() or not platform_chassis.get_fan(x).get_speed_rpm(): + self._new_perc = FAN_LEV1_SPEED_PERC + logging.debug('INFO. SET new_perc to %d (FAN fault. fan_num:%d)', self._new_perc, x+1) + fan_stat=False + break + logging.debug('INFO. fan_stat is True (fan_num:%d)', x+1) + + if fan_stat==True: + diff = new_temp - self._ori_temp + if diff == 0: + logging.debug('INFO. RETURN. THERMAL temp not changed. %d / %d (new_temp / ori_temp)', new_temp, self._ori_temp) + return True + else: + if diff >= 0: + is_up = True + logging.debug('INFO. THERMAL temp UP %d / %d (new_temp / ori_temp)', new_temp, self._ori_temp) + else: + is_up = False + logging.debug('INFO. THERMAL temp DOWN %d / %d (new_temp / ori_temp)', new_temp, self._ori_temp) + + if is_up is True: + if new_temp >= FAN_LEV1_UP_TEMP: + self._new_perc = FAN_LEV1_SPEED_PERC + elif new_temp >= FAN_LEV2_UP_TEMP: + self._new_perc = FAN_LEV2_SPEED_PERC + elif new_temp >= FAN_LEV3_UP_TEMP: + self._new_perc = FAN_LEV3_SPEED_PERC + else: + self._new_perc = FAN_LEV4_SPEED_PERC + logging.debug('INFO. SET. FAN_SPEED as %d (new THERMAL temp:%d)', self._new_perc, new_temp) + else: + if new_temp <= FAN_LEV4_DOWN_TEMP: + self._new_perc = FAN_LEV4_SPEED_PERC + elif new_temp <= FAN_LEV3_DOWN_TEMP: + self._new_perc = FAN_LEV3_SPEED_PERC + elif new_temp <= FAN_LEV2_DOWN_TEMP: + self._new_perc = FAN_LEV2_SPEED_PERC + else: + self._new_perc = FAN_LEV1_SPEED_PERC + logging.debug('INFO. SET. FAN_SPEED as %d (new THERMAL temp:%d)', self._new_perc, new_temp) + + cur_perc= platform_chassis.get_fan(0).get_speed() + #cur_perc = fan.get_fan_duty_cycle() + if cur_perc == self._new_perc: + logging.debug('INFO. RETURN. FAN speed not changed. %d / %d (new_perc / ori_perc)', self._new_perc, cur_perc) + return True + + #set_stat = fan.set_fan_duty_cycle(self._new_perc) + set_stat = platform_chassis.get_fan(0).set_speed(self._new_perc) + if set_stat is True: + logging.debug('INFO: PASS. set_fan_duty_cycle (%d)', self._new_perc) + else: + logging.debug('INFO: FAIL. set_fan_duty_cycle (%d)', self._new_perc) + + logging.debug('INFO: GET. ori_perc is %d. ori_temp is %d', cur_perc, self._ori_temp) + self._ori_temp = new_temp + logging.debug('INFO: UPDATE. ori_perc to %d. ori_temp to %d', cur_perc, self._ori_temp) + + return True + +def handler(signum, frame): + logging.debug('INFO:Cause signal %d, set fan speed max.', signum) + platform_chassis.get_fan(0).set_speed(DUTY_MAX) + sys.exit(0) + +def main(argv): + global test_temp + + log_file = '%s.log' % FUNCTION_NAME + log_level = logging.INFO + if len(sys.argv) != 1: + try: + opts, args = getopt.getopt(argv,'hdlt:',['lfile=']) + except getopt.GetoptError: + print('Usage: %s [-d] [-l ]' % sys.argv[0]) + return 0 + for opt, arg in opts: + if opt == '-h': + print('Usage: %s [-d] [-l ]' % sys.argv[0]) + return 0 + elif opt in ('-d', '--debug'): + log_level = logging.DEBUG + elif opt in ('-l', '--lfile'): + log_file = arg + + if sys.argv[1]== '-t': + if len(sys.argv)!=6: + print("temp test, need input 4 temp") + return 0 + i=0 + for x in range(2, 6): + test_temp_list[i]= int(sys.argv[x])*1000 + i=i+1 + test_temp = 1 + log_level = logging.DEBUG + print(test_temp_list) + + global platform_chassis + platform_chassis = platform.Platform().get_chassis() + + + signal.signal(signal.SIGINT, handler) + signal.signal(signal.SIGTERM, handler) + monitor = accton_as5835_54x_monitor(log_file, log_level) + + # Loop forever, doing something useful hopefully: + while True: + monitor.manage_fans() + time.sleep(10) + +if __name__ == '__main__': + main(sys.argv[1:]) \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/accton_as5835_54x_util.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/accton_as5835_54x_util.py index 5292d1ec3b..af4b7c0c33 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/accton_as5835_54x_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/accton_as5835_54x_util.py @@ -386,6 +386,8 @@ def do_sonic_platform_clean(): else: print('{} is uninstalled'.format(PLATFORM_API2_WHL_FILE_PY3)) + return + def do_install(): print("Checking system....") if driver_check() == False: diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/pddf_post_device_create.sh b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/pddf_post_device_create.sh new file mode 100755 index 0000000000..c1a6660f9e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/pddf_post_device_create.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set_qsfp_reset_to_normal_state() +{ + i2cset -y -f 3 0x62 0x15 0x3f &>/dev/null +} + + +set_sfp_tx_disable_to_disable() +{ + i2cset -y -f 3 0x61 0x12 0x0 &>/dev/null + i2cset -y -f 3 0x61 0x13 0x0 &>/dev/null + i2cset -y -f 3 0x61 0x14 0x0 &>/dev/null + i2cset -y -f 3 0x61 0x15 0x0 &>/dev/null + i2cset -y -f 3 0x61 0x16 0x0 &>/dev/null + i2cset -y -f 3 0x62 0xc 0x0 &>/dev/null + i2cset -y -f 3 0x62 0xd 0x0 &>/dev/null +} + +set_system_led_diag_loc_to_off() +{ + i2cset -y -f 3 0x60 0xa 0x1c &>/dev/null +} + +set_qsfp_reset_to_normal_state +set_sfp_tx_disable_to_disable +set_system_led_diag_loc_to_off diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/pddf_switch_svc.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/pddf_switch_svc.py new file mode 100755 index 0000000000..c7dad91bae --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/pddf_switch_svc.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python +# Script to stop and start the respective platforms default services. +# This will be used while switching the pddf->non-pddf mode and vice versa +from sonic_py_common.general import getstatusoutput_noshell + +def check_pddf_support(): + return True + +def stop_platform_svc(): + + status, output = getstatusoutput_noshell(["systemctl", "stop", "as5835-54x-platform-monitor-fan.service"]) + if status: + print("Stop as5835-54x-platform-fan.service failed %d"%status) + return False + + status, output = getstatusoutput_noshell(["systemctl", "stop", "as5835-54x-platform-monitor-psu.service"]) + if status: + print("Stop as5835-54x-platform-psu.service failed %d"%status) + return False + + status, output = getstatusoutput_noshell(["systemctl", "stop", "as5835-54x-platform-monitor.service"]) + if status: + print("Stop as5835-54x-platform-init.service failed %d"%status) + return False + status, output = getstatusoutput_noshell(["systemctl", "disable", "as5835-54x-platform-monitor.service"]) + if status: + print("Disable as5835-54x-platform-monitor.service failed %d"%status) + return False + + status, output = getstatusoutput_noshell(["/usr/local/bin/accton_as5835_54x_util.py", "clean"]) + if status: + print("accton_as5835_54x_util.py clean command failed %d"%status) + return False + + # HACK , stop the pddf-platform-init service if it is active + status, output = getstatusoutput_noshell(["systemctl", "stop", "pddf-platform-init.service"]) + if status: + print("Stop pddf-platform-init.service along with other platform serives failed %d"%status) + return False + + return True + +def start_platform_svc(): + status, output = getstatusoutput_noshell(["/usr/local/bin/accton_as5835_54x_util.py", "install"]) + if status: + print("accton_as5835_54x_util.py install command failed %d"%status) + return False + + status, output = getstatusoutput_noshell(["systemctl", "enable", "as5835-54x-platform-monitor.service"]) + if status: + print("Enable as5835-54x-platform-monitor.service failed %d"%status) + return False + status, output = getstatusoutput_noshell(["systemctl", "start" ,"as5835-54x-platform-monitor-fan.service"]) + if status: + print("Start as5835-54x-platform-monitor-fan.service failed %d"%status) + return False + + status, output = getstatusoutput_noshell(["systemctl", "start", "as5835-54x-platform-monitor-psu.service"]) + if status: + print("Start as5835-54x-platform-monitor-psu.service failed %d"%status) + return False + + return True + +def start_platform_pddf(): + status, output = getstatusoutput_noshell(["systemctl", "start", "pddf-platform-init.service"]) + if status: + print("Start pddf-platform-init.service failed %d"%status) + return False + + return True + +def stop_platform_pddf(): + status, output = getstatusoutput_noshell(["systemctl", "stop", "pddf-platform-init.service"]) + if status: + print("Stop pddf-platform-init.service failed %d"%status) + return False + + return True + +def main(): + pass + +if __name__ == "__main__": + main() + diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_psu.c index 8c2ece6200..9dbd061c9e 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_psu.c @@ -34,8 +34,10 @@ #include #include +#define MAX_MODEL_NAME 16 +#define MAX_SERIAL_NUMBER 18 static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_string(struct device *dev, struct device_attribute *da, char *buf); static int as7326_56x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); extern int as7326_56x_cpld_read(unsigned short cpld_addr, u8 reg); @@ -52,7 +54,8 @@ struct as7326_56x_psu_data { unsigned long last_updated; /* In jiffies */ u8 index; /* PSU index */ u8 status; /* Status(present/power_good) register read from CPLD */ - char model_name[9]; /* Model name, read from eeprom */ + char model_name[MAX_MODEL_NAME+1]; /* Model name, read from eeprom */ + char serial_number[MAX_SERIAL_NUMBER+1]; }; static struct as7326_56x_psu_data *as7326_56x_psu_update_device(struct device *dev); @@ -60,18 +63,21 @@ static struct as7326_56x_psu_data *as7326_56x_psu_update_device(struct device *d enum as7326_56x_psu_sysfs_attributes { PSU_PRESENT, PSU_MODEL_NAME, + PSU_SERIAL_NUMBER, PSU_POWER_GOOD }; /* sysfs attributes for hwmon */ static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); -static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_model_name,NULL, PSU_MODEL_NAME); +static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_string, NULL, PSU_MODEL_NAME); +static SENSOR_DEVICE_ATTR(psu_serial_number, S_IRUGO, show_string, NULL, PSU_SERIAL_NUMBER); static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); static struct attribute *as7326_56x_psu_attributes[] = { &sensor_dev_attr_psu_present.dev_attr.attr, &sensor_dev_attr_psu_model_name.dev_attr.attr, + &sensor_dev_attr_psu_serial_number.dev_attr.attr, &sensor_dev_attr_psu_power_good.dev_attr.attr, NULL }; @@ -83,6 +89,10 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, struct as7326_56x_psu_data *data = as7326_56x_psu_update_device(dev); u8 status = 0; + if (!data->valid) { + return -EIO; + } + if (attr->index == PSU_PRESENT) { status = !(data->status >> (1-data->index) & 0x1); } @@ -93,12 +103,27 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, return sprintf(buf, "%d\n", status); } -static ssize_t show_model_name(struct device *dev, struct device_attribute *da, - char *buf) +static ssize_t show_string(struct device *dev, struct device_attribute *da, + char *buf) { + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct as7326_56x_psu_data *data = as7326_56x_psu_update_device(dev); + char *ptr = NULL; - return sprintf(buf, "%s\n", data->model_name); + if (!data->valid) { + return -EIO; + } + + if (attr->index == PSU_MODEL_NAME) { + ptr = data->model_name; + } + else if (attr->index == PSU_SERIAL_NUMBER) { + ptr = data->serial_number; + } + else { + return -EIO; + } + return sprintf(buf, "%s\n", ptr); } static const struct attribute_group as7326_56x_psu_group = { @@ -219,6 +244,112 @@ static int as7326_56x_psu_read_block(struct i2c_client *client, u8 command, u8 * return result; } +enum psu_type { + PSU_TYPE_AC_110V, + PSU_TYPE_DC_48V, + PSU_TYPE_DC_12V, + PSU_TYPE_AC_ACBEL_FSF019, + PSU_TYPE_AC_ACBEL_FSF045 +}; + +struct model_name_info { + enum psu_type type; + u8 offset; + u8 length; + char* model_name; +}; + +struct serial_number_info { + enum psu_type type; + u8 offset; + u8 length; + char* serial_number; +}; + +struct model_name_info models[] = { + {PSU_TYPE_AC_110V, 0x20, 8, "YM-2651Y"}, + {PSU_TYPE_DC_48V, 0x20, 8, "YM-2651V"}, + {PSU_TYPE_DC_12V, 0x00, 11, "PSU-12V-750"}, + {PSU_TYPE_AC_ACBEL_FSF019, 0x15, 10, "FSF019-"}, + {PSU_TYPE_AC_ACBEL_FSF045, 0x15, 10, "FSF045-"} +}; + +struct serial_number_info serials[] = { + {PSU_TYPE_AC_110V, 0x2e, 18, "YM-2651Y"}, + {PSU_TYPE_DC_48V, 0x2e, 18, "YM-2651V"}, + {PSU_TYPE_DC_12V, 0x2e, 18, "PSU-12V-750"}, + {PSU_TYPE_AC_ACBEL_FSF019, 0x2e, 16, "FSF019-"}, + {PSU_TYPE_AC_ACBEL_FSF045, 0x2e, 16, "FSF045-"} +}; + +static int as7326_56x_psu_model_name_get(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as7326_56x_psu_data *data = i2c_get_clientdata(client); + int i, status; + + for (i = 0; i < ARRAY_SIZE(models); i++) { + memset(data->model_name, 0, sizeof(data->model_name)); + + status = as7326_56x_psu_read_block(client, models[i].offset, + data->model_name, models[i].length); + if (status < 0) { + data->model_name[0] = '\0'; + dev_dbg(&client->dev, "unable to read model name from (0x%x) offset(0x%x)\n", + client->addr, models[i].offset); + return status; + } + else { + data->model_name[models[i].length] = '\0'; + } + + /* Determine if the model name is known, if not, read next index + */ + if (strncmp(data->model_name, models[i].model_name, strlen(models[i].model_name)) == 0) { + return 0; + } + else { + data->model_name[0] = '\0'; + } + } + + return -ENODATA; +} + +static int as7326_56x_psu_serial_number_get(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as7326_56x_psu_data *data = i2c_get_clientdata(client); + int i, status; + + for (i = 0; i < ARRAY_SIZE(models); i++) { + memset(data->serial_number, 0, sizeof(data->serial_number)); + + status = as7326_56x_psu_read_block(client, serials[i].offset, + data->serial_number, serials[i].length); + if (status < 0) { + data->serial_number[0] = '\0'; + dev_dbg(&client->dev, "unable to read serial_number from (0x%x) offset(0x%x)\n", + client->addr, serials[i].offset); + return status; + } + else { + data->serial_number[serials[i].length] = '\0'; + } + + /* Determine if the model name is known, if not, read next index + */ + if (strncmp(data->model_name, models[i].model_name, strlen(models[i].model_name)) == 0) { + return 0; + } + else { + data->serial_number[0] = '\0'; + } + } + + return -ENODATA; +} + static struct as7326_56x_psu_data *as7326_56x_psu_update_device(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -231,6 +362,7 @@ static struct as7326_56x_psu_data *as7326_56x_psu_update_device(struct device *d int status; int power_good = 0; + data->valid = 0; dev_dbg(&client->dev, "Starting as7326_56x update\n"); /* Read psu status */ @@ -238,6 +370,7 @@ static struct as7326_56x_psu_data *as7326_56x_psu_update_device(struct device *d if (status < 0) { dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); + goto exit; } else { data->status = status; @@ -245,18 +378,15 @@ static struct as7326_56x_psu_data *as7326_56x_psu_update_device(struct device *d /* Read model name */ memset(data->model_name, 0, sizeof(data->model_name)); + memset(data->serial_number, 0, sizeof(data->serial_number)); power_good = (data->status >> (3-data->index) & 0x1); if (power_good) { - status = as7326_56x_psu_read_block(client, 0x20, data->model_name, - ARRAY_SIZE(data->model_name)-1); - - if (status < 0) { - data->model_name[0] = '\0'; - dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr); + if (as7326_56x_psu_model_name_get(dev) < 0) { + goto exit; } - else { - data->model_name[ARRAY_SIZE(data->model_name)-1] = '\0'; + if (as7326_56x_psu_serial_number_get(dev) < 0) { + goto exit; } } @@ -264,6 +394,7 @@ static struct as7326_56x_psu_data *as7326_56x_psu_update_device(struct device *d data->valid = 1; } +exit: mutex_unlock(&data->update_lock); return data; diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_i2c_cpld.c b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_i2c_cpld.c index 70d9a66aff..a67d6607ed 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_i2c_cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_i2c_cpld.c @@ -760,7 +760,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, return 0; } - if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_56) { + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_58) { revert = 1; } diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c index 18c3edf72a..54e19007a8 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c @@ -13,57 +13,81 @@ ssize_t pddf_get_custom_psu_model_name(struct device *dev, struct device_attribute *da, char *buf); ssize_t pddf_get_custom_psu_serial_num(struct device *dev, struct device_attribute *da, char *buf); +ssize_t pddf_get_custom_psu_fan_dir(struct device *dev, struct device_attribute *da, char *buf); extern PSU_SYSFS_ATTR_DATA access_psu_model_name; extern PSU_SYSFS_ATTR_DATA access_psu_serial_num; +extern PSU_SYSFS_ATTR_DATA access_psu_fan_dir; -#define MAX_MODEL_NAME 16 -#define MAX_SERIAL_NUMBER 19 +#define MAX_MODEL_NAME 13 +#define MAX_SERIAL_NUMBER 18 +#define FAN_DIR_LEN 3 + +const char FAN_DIR_F2B[] = "F2B"; +const char FAN_DIR_B2F[] = "B2F"; +const char FAN_DIR_UNKNOWN[] = ""; enum psu_type { - PSU_TYPE_AC_110V, - PSU_TYPE_DC_48V, - PSU_TYPE_DC_12V, - PSU_TYPE_AC_ACBEL_FSF019, - PSU_TYPE_AC_ACBEL_FSF045 + PSU_TYPE_ACBEL_FSF019_AC_F2B, // FSF019-611G + PSU_TYPE_ACBEL_FSF045_AC_B2F, // FSH045-611G + PSU_TYPE_3Y_YM2651YBR_AC_F2B, // YM-2651Y-BR + PSU_TYPE_3Y_YM2651YB01R_AC_F2B, // YM-2651Y-B01R + PSU_TYPE_3Y_YM2651YCR_AC_B2F, // YM-2651Y-CR + PSU_TYPE_3Y_YM2651YC01R_AC_B2F, // YM-2651Y-C01R + PSU_TYPE_3Y_YM2651VBR_DC_F2B, // YM-2651V-BR + PSU_TYPE_3Y_YM2651VCR_DC_B2F, // YM-2651V-CR + PSU_TYPE_3Y_YM2651_SERIES }; struct model_name_info { + char* model_name; enum psu_type type; u8 offset; u8 length; u8 chk_length; - char* model_name; }; - struct serial_number_info { - enum psu_type type; u8 offset; u8 length; - u8 chk_length; - char* serial_number; }; -struct model_name_info models[] = { -{PSU_TYPE_AC_110V, 0x20, 8, 8, "YM-2651Y"}, -{PSU_TYPE_DC_48V, 0x20, 8, 8, "YM-2651V"}, -{PSU_TYPE_DC_12V, 0x00, 11, 11, "PSU-12V-750"}, -{PSU_TYPE_AC_ACBEL_FSF019, 0x15, 10, 7, "FSF019-"}, -{PSU_TYPE_AC_ACBEL_FSF045, 0x15, 10, 7, "FSF045-"} - +struct fan_dir_info { + char* model_name; + u8 model_length; + enum psu_type type; + const char* fan_dir; +}; +const struct model_name_info models[] = { + { "FSF019", PSU_TYPE_ACBEL_FSF019_AC_F2B, 0x20, 13, 6 }, + { "FSF045", PSU_TYPE_ACBEL_FSF045_AC_B2F, 0x20, 13, 6 }, + { "YM-2651", PSU_TYPE_3Y_YM2651_SERIES, 0x20, 13, 7 } }; -struct serial_number_info serials[] = { -{PSU_TYPE_AC_110V, 0x2e, 18, 18, "YM-2651Y"}, -{PSU_TYPE_DC_48V, 0x2e, 18, 18, "YM-2651V"}, -{PSU_TYPE_DC_12V, 0x2e, 18, 18, "PSU-12V-750"}, -{PSU_TYPE_AC_ACBEL_FSF019, 0x2e, 16, 16, "FSF019-"}, -{PSU_TYPE_AC_ACBEL_FSF019, 0x2e, 16, 16, "FSF045-"} +const struct fan_dir_info fan_dirs[] = { + { "FSF019", 6, PSU_TYPE_ACBEL_FSF019_AC_F2B, FAN_DIR_F2B }, + { "FSF045", 6, PSU_TYPE_ACBEL_FSF045_AC_B2F, FAN_DIR_B2F }, + { "YM-2651Y-BR", 11, PSU_TYPE_3Y_YM2651YBR_AC_F2B, FAN_DIR_F2B }, + { "YM-2651Y-B01R", 13, PSU_TYPE_3Y_YM2651YB01R_AC_F2B, FAN_DIR_F2B }, + { "YM-2651Y-CR", 11, PSU_TYPE_3Y_YM2651YCR_AC_B2F, FAN_DIR_B2F }, + { "YM-2651Y-C01R", 13, PSU_TYPE_3Y_YM2651YC01R_AC_B2F, FAN_DIR_B2F }, + { "YM-2651V-BR", 11, PSU_TYPE_3Y_YM2651VBR_DC_F2B, FAN_DIR_F2B }, + { "YM-2651V-CR", 11, PSU_TYPE_3Y_YM2651VCR_DC_B2F, FAN_DIR_B2F } +}; +const struct serial_number_info serials[] = { + [PSU_TYPE_ACBEL_FSF019_AC_F2B] = { 0x2e, 16 }, + [PSU_TYPE_ACBEL_FSF045_AC_B2F] = { 0x2e, 16 }, + [PSU_TYPE_3Y_YM2651YBR_AC_F2B] = { 0x2e, 18 }, + [PSU_TYPE_3Y_YM2651YB01R_AC_F2B] = { 0x2e, 18 }, + [PSU_TYPE_3Y_YM2651YCR_AC_B2F] = { 0x2e, 18 }, + [PSU_TYPE_3Y_YM2651YC01R_AC_B2F] = { 0x35, 18 }, + [PSU_TYPE_3Y_YM2651VBR_DC_F2B] = { 0x2e, 18 }, + [PSU_TYPE_3Y_YM2651VCR_DC_B2F] = { 0x2e, 18 } }; struct pddf_psu_data { char model_name[MAX_MODEL_NAME+1]; char serial_number[MAX_SERIAL_NUMBER+1]; + char fan_dir[FAN_DIR_LEN+1]; }; @@ -96,53 +120,118 @@ static int pddf_psu_read_block(struct i2c_client *client, u8 command, u8 *data, return result; } -ssize_t pddf_get_custom_psu_serial_num(struct device *dev, struct device_attribute *da, char *buf) +/* Get type and model_name + */ +static int pddf_get_model_name_and_type(struct i2c_client *client, enum psu_type *get_type, struct pddf_psu_data *get_data) { - struct i2c_client *client = to_i2c_client(dev); - struct pddf_psu_data data; + char model_name[MAX_MODEL_NAME+1]; int i, status; - + enum psu_type type; + + get_data->model_name[0]='\0'; + *get_type = PSU_TYPE_ACBEL_FSF019_AC_F2B; for (i = 0; i < ARRAY_SIZE(models); i++) { - memset(data.serial_number, 0, sizeof(data.serial_number)); - + model_name[0]='\0'; + if ((models[i].length+1) > ARRAY_SIZE(model_name)) { + dev_dbg(&client->dev, + "invalid models[%d].length(%d), should not exceed the size of data->model_name(%ld)\n", + i, models[i].length, ARRAY_SIZE(model_name)); + continue; + } + status = pddf_psu_read_block(client, models[i].offset, - data.model_name, models[i].length); + model_name, models[i].length); if (status < 0) { - data.model_name[0] = '\0'; + model_name[0] = '\0'; dev_dbg(&client->dev, "unable to read model name from (0x%x) offset(0x%x)\n", client->addr, models[i].offset); return status; } else { - data.model_name[models[i].length] = '\0'; + model_name[models[i].length>=(sizeof(model_name)-1)?(sizeof(model_name)-1):models[i].length] = '\0'; } /* Determine if the model name is known, if not, read next index */ - if (strncmp(data.model_name, models[i].model_name, models[i].chk_length) == 0) { - status = pddf_psu_read_block(client, serials[i].offset, - data.serial_number, serials[i].length); - - if (status < 0) { - data.serial_number[0] = '\0'; - dev_dbg(&client->dev, "unable to read serial num from (0x%x) offset(0x%x)\n", - client->addr, serials[i].offset); - return status; - } - else { - data.serial_number[serials[i].length] = '\0'; - return sprintf(buf, "%s\n", data.serial_number); - } - - return 0; + if (strncmp(model_name, models[i].model_name, models[i].chk_length) == 0) { + type = models[i].type; + break; } else { - data.serial_number[0] = '\0'; + model_name[0] = '\0'; } } - return -ENODATA; + /* Remove useless characters for PSU_TYPE_3Y_YM2651_SERIES */ + if (type == PSU_TYPE_3Y_YM2651_SERIES) { + model_name[8] = '-'; + if (!isgraph(model_name[11])) + model_name[11] = '\0'; + else + model_name[MAX_MODEL_NAME] = '\0'; + } + /* Remove useless characters for PSU_TYPE_ACBEL_FSF* */ + else if ((type == PSU_TYPE_ACBEL_FSF019_AC_F2B) || (type == PSU_TYPE_ACBEL_FSF045_AC_B2F)) { + memmove(&model_name[7], &model_name[9], ARRAY_SIZE(model_name)-9); + model_name[6] = '-'; + model_name[11] = '\0'; + } + else + return -ENODEV; + + /* Determine fan direction and correct the PSU type */ + for (i = 0; i < ARRAY_SIZE(fan_dirs); i++) { + if ((fan_dirs[i].model_length+1) > ARRAY_SIZE(model_name)) { + dev_dbg(&client->dev, + "invalid fan_dirs[%d].model_length(%d), should not exceed the size of data->model_name(%ld)\n", + i, fan_dirs[i].model_length, ARRAY_SIZE(model_name)); + continue; + } + if (strncmp(model_name, fan_dirs[i].model_name, fan_dirs[i].model_length) == 0) { + type = fan_dirs[i].type; + break; + } + } + if (type >= PSU_TYPE_3Y_YM2651_SERIES) + { + return -ENODEV; + } + + *get_type = type; + memcpy(get_data->model_name, model_name, strlen(model_name)>=sizeof(get_data->model_name)?sizeof(get_data->model_name):strlen(model_name)); + get_data->model_name[strlen(model_name)>=(sizeof(get_data->model_name)-1)?(sizeof(get_data->model_name)-1):strlen(model_name)]='\0'; + return 0; +} + +ssize_t pddf_get_custom_psu_serial_num(struct device *dev, struct device_attribute *da, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct pddf_psu_data data; + int status; + enum psu_type type; + + data.serial_number[0]='\0'; + + status = pddf_get_model_name_and_type(client, &type, &data); + if (status < 0) + { + return -ENODEV; + } + + status = pddf_psu_read_block(client, serials[type].offset, + data.serial_number, serials[type].length); + if (status < 0) { + data.serial_number[0] = '\0'; + dev_dbg(&client->dev, "unable to read serial num from (0x%x) offset(0x%x)\n", + client->addr, serials[type].offset); + return status; + } + else { + data.serial_number[serials[type].length >= (sizeof(data.serial_number)-1)?(sizeof(data.serial_number)-1):serials[type].length] = '\0'; + } + + return sprintf(buf, "%s\n", data.serial_number); } @@ -150,34 +239,39 @@ ssize_t pddf_get_custom_psu_model_name(struct device *dev, struct device_attribu { struct i2c_client *client = to_i2c_client(dev); struct pddf_psu_data data; - int i, status; + int status; + enum psu_type type; + + status = pddf_get_model_name_and_type(client, &type, &data); + if (status < 0) + { + return -ENODEV; + } - for (i = 0; i < ARRAY_SIZE(models); i++) { - memset(data.model_name, 0, sizeof(data.model_name)); + return sprintf(buf, "%s\n", data.model_name); - status = pddf_psu_read_block(client, models[i].offset, - data.model_name, models[i].length); - if (status < 0) { - data.model_name[0] = '\0'; - dev_dbg(&client->dev, "unable to read model name from (0x%x) offset(0x%x)\n", - client->addr, models[i].offset); - return status; - } - else { - data.model_name[models[i].length] = '\0'; - } +} - /* Determine if the model name is known, if not, read next index - */ - if (strncmp(data.model_name, models[i].model_name, models[i].chk_length) == 0) { - return sprintf(buf, "%s\n", data.model_name); - } - else { - data.model_name[0] = '\0'; - } - } +ssize_t pddf_get_custom_psu_fan_dir(struct device *dev, struct device_attribute *da, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct pddf_psu_data data; + int status; + enum psu_type type; - return -ENODATA; + status = pddf_get_model_name_and_type(client, &type, &data); + if (status < 0) + { + return -ENODEV; + } + + if (type < PSU_TYPE_3Y_YM2651_SERIES) + { + memcpy(data.fan_dir, fan_dirs[type].fan_dir, sizeof(data.fan_dir)); + return sprintf(buf, "%s\n", data.fan_dir); + } + else + return -ENODEV; } @@ -188,6 +282,9 @@ static int __init pddf_custom_psu_init(void) access_psu_model_name.show = pddf_get_custom_psu_model_name; access_psu_model_name.do_get = NULL; + + access_psu_fan_dir.show = pddf_get_custom_psu_fan_dir; + access_psu_fan_dir.do_get = NULL; return 0; } diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/service/as7326-56x-pddf-platform-monitor.service b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/service/as7326-56x-pddf-platform-monitor.service index 03351824b7..49236706de 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/service/as7326-56x-pddf-platform-monitor.service +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/service/as7326-56x-pddf-platform-monitor.service @@ -1,6 +1,6 @@ [Unit] Description=Accton AS7326-56X Platform Monitoring service -Before=pmon.service +Before=pmon.service system-health.service After=pddf-platform-init.service DefaultDependencies=no diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/service/as7326-platform-monitor.service b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/service/as7326-platform-monitor.service index 9da8370471..51da61e5d9 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/service/as7326-platform-monitor.service +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/service/as7326-platform-monitor.service @@ -1,6 +1,6 @@ [Unit] Description=Accton AS7326-56X Platform Monitoring service -Before=pmon.service +Before=pmon.service system-health.service After=as7326-platform-handle_mac.service DefaultDependencies=no diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/chassis.py index feb1fbdb56..a471e33089 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/chassis.py @@ -8,58 +8,58 @@ try: import sys - import time from sonic_platform_pddf_base.pddf_chassis import PddfChassis + from .event import SfpEvent + from .helper import APIHelper except ImportError as e: raise ImportError(str(e) + "- required module not found") +NUM_COMPONENT = 6 +HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/" +PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/" +REBOOT_CAUSE_FILE = "reboot-cause.txt" class Chassis(PddfChassis): """ PDDF Platform-specific Chassis class """ + SYSLED_DEV_NAME = "DIAG_LED" def __init__(self, pddf_data=None, pddf_plugin_data=None): PddfChassis.__init__(self, pddf_data, pddf_plugin_data) + self.__initialize_components() + self._api_helper = APIHelper() + self._sfpevent = SfpEvent(self.get_all_sfps()) + + def __initialize_components(self): + from sonic_platform.component import Component + for index in range(NUM_COMPONENT): + component = Component(index) + self._component_list.append(component) # Provide the functions/variables below for which implementation is to be overwritten - sfp_change_event_data = {'valid': 0, 'last': 0, 'present': 0} - def get_change_event(self, timeout=2000): - now = time.time() - port_dict = {} - change_dict = {} - change_dict['sfp'] = port_dict - - if timeout < 1000: - timeout = 1000 - timeout = timeout / float(1000) # Convert to secs - - if now < (self.sfp_change_event_data['last'] + timeout) and self.sfp_change_event_data['valid']: - return True, change_dict - - bitmap = 0 - for i in range(58): - modpres = self.get_sfp(i+1).get_presence() - if modpres: - bitmap = bitmap | (1 << i) - - changed_ports = self.sfp_change_event_data['present'] ^ bitmap - if changed_ports: - for i in range(58): - if (changed_ports & (1 << i)): - if (bitmap & (1 << i)) == 0: - port_dict[i+1] = '0' - else: - port_dict[i+1] = '1' - - - # Update teh cache dict - self.sfp_change_event_data['present'] = bitmap - self.sfp_change_event_data['last'] = now - self.sfp_change_event_data['valid'] = 1 - return True, change_dict - else: - return True, change_dict + def get_change_event(self, timeout=0): + return self._sfpevent.get_sfp_event(timeout) + + def get_reboot_cause(self): + """ + Retrieves the cause of the previous reboot + + Returns: + A tuple (string, string) where the first element is a string + containing the cause of the previous reboot. This string must be + one of the predefined strings in this class. If the first string + is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used + to pass a description of the reboot cause. + """ + + reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE) + sw_reboot_cause = self._api_helper.read_txt_file( + reboot_cause_path) or "Unknown" + + + return ('REBOOT_CAUSE_NON_HARDWARE', sw_reboot_cause) + def get_sfp(self, index): """ @@ -83,3 +83,50 @@ def get_sfp(self, index): sys.stderr.write("SFP index {} out of range (1-{})\n".format( index, len(self._sfp_list))) return sfp + + def initizalize_system_led(self): + return + + def get_status_led(self): + return self.get_system_led(self.SYSLED_DEV_NAME) + + def set_status_led(self, color): + return self.set_system_led(self.SYSLED_DEV_NAME, color) + + def get_port_or_cage_type(self, port): + from sonic_platform_base.sfp_base import SfpBase + if port in range(1, 49): + return SfpBase.SFP_PORT_TYPE_BIT_SFP | SfpBase.SFP_PORT_TYPE_BIT_SFP_PLUS | SfpBase.SFP_PORT_TYPE_BIT_SFP28 + elif port in range(49, 57): + return SfpBase.SFP_PORT_TYPE_BIT_QSFP | SfpBase.SFP_PORT_TYPE_BIT_QSFP_PLUS | SfpBase.SFP_PORT_TYPE_BIT_QSFP28 + else: + return SfpBase.SFP_PORT_TYPE_BIT_SFP + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + If the agent cannot determine the parent-relative position + for some reason, or if the associated value of + entPhysicalContainedIn is'0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device + or -1 if cannot determine the position + """ + return -1 + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + return 'N/A' \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/component.py new file mode 100644 index 0000000000..8feb4f1c0c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/component.py @@ -0,0 +1,156 @@ +############################################################################# +# +# Component contains an implementation of SONiC Platform Base API and +# provides the components firmware management function +# +############################################################################# + +try: + import subprocess + from sonic_platform_base.component_base import ComponentBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +CPLD_ADDR_MAPPING = { + "MB_CPLD1": ['18', '0x60'], + "MB_CPLD2": ['12', '0x62'], + "MB_CPLD3": ['19', '0x64'], + "FAN_CPLD": ['11', '0x66'], + "CPU_CPLD": ['0', '0x65'] +} +SYSFS_PATH = "/sys/bus/i2c/devices/" +BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version" +COMPONENT_LIST= [ + ("MB_CPLD1", "Mainboard CPLD(0x60)"), + ("MB_CPLD2", "Mainboard CPLD(0x62)"), + ("MB_CPLD3", "Mainboard CPLD(0x64)"), + ("FAN_CPLD", "Fan board CPLD(0x66)"), + ("CPU_CPLD", "CPU CPLD(0x65)"), + ("BIOS", "Basic Input/Output System") + +] + +class Component(ComponentBase): + """Platform-specific Component class""" + + DEVICE_TYPE = "component" + + def __init__(self, component_index=0): + self.index = component_index + self.name = self.get_name() + + def __get_bios_version(self): + # Retrieves the BIOS firmware version + try: + with open(BIOS_VERSION_PATH, 'r') as fd: + bios_version = fd.read() + return bios_version.strip() + except Exception as e: + return None + + def __get_cpld_version(self): + # Retrieves the CPLD firmware version + cpld_version = dict() + for cpld_name in CPLD_ADDR_MAPPING: + cmd = "i2cget -f -y {0} {1} 0x1".format(CPLD_ADDR_MAPPING[cpld_name][0], CPLD_ADDR_MAPPING[cpld_name][1]) + status, value = subprocess.getstatusoutput(cmd) + if not status: + cpld_version_raw = value.rstrip() + cpld_version[cpld_name] = "{}".format(int(cpld_version_raw,16)) + + return cpld_version + + def get_name(self): + """ + Retrieves the name of the component + Returns: + A string containing the name of the component + """ + return COMPONENT_LIST[self.index][0] + + def get_description(self): + """ + Retrieves the description of the component + Returns: + A string containing the description of the component + """ + return COMPONENT_LIST[self.index][1] + + def get_firmware_version(self): + """ + Retrieves the firmware version of module + Returns: + string: The firmware versions of the module + """ + fw_version = None + + if self.name == "BIOS": + fw_version = self.__get_bios_version() + elif "CPLD" in self.name: + cpld_version = self.__get_cpld_version() + fw_version = cpld_version.get(self.name) + + return fw_version + + def install_firmware(self, image_path): + """ + Install firmware to module + Args: + image_path: A string, path to firmware image + Returns: + A boolean, True if install successfully, False if not + """ + raise NotImplementedError + + def get_presence(self): + """ + Retrieves the presence of the device + Returns: + bool: True if device is present, False if not + """ + return True + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + return 'N/A' + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return 'N/A' + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + return True + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + If the agent cannot determine the parent-relative position + for some reason, or if the associated value of + entPhysicalContainedIn is'0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device + or -1 if cannot determine the position + """ + return -1 + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/eeprom.py index a87ecc9f6f..b0fbd57ac7 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/eeprom.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/eeprom.py @@ -12,3 +12,4 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None): PddfEeprom.__init__(self, pddf_data, pddf_plugin_data) # Provide the functions/variables below for which implementation is to be overwritten + diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/event.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/event.py new file mode 100644 index 0000000000..d5dac6d7f7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/event.py @@ -0,0 +1,60 @@ +try: + import time + from sonic_py_common.logger import Logger +except ImportError as e: + raise ImportError(repr(e) + " - required module not found") + +POLL_INTERVAL_IN_SEC = 1 + +class SfpEvent: + ''' Listen to insert/remove sfp events ''' + + def __init__(self, sfp_list): + self._sfp_list = sfp_list + self._logger = Logger() + self._sfp_change_event_data = {'present': 0} + + def get_presence_bitmap(self): + bitmap = 0 + for sfp in self._sfp_list: + modpres = sfp.get_presence() + i=sfp.get_position_in_parent() - 1 + if modpres: + bitmap = bitmap | (1 << i) + return bitmap + + def get_sfp_event(self, timeout=2000): + port_dict = {} + change_dict = {} + change_dict['sfp'] = port_dict + + if timeout < 1000: + cd_ms = 1000 + else: + cd_ms = timeout + + while cd_ms > 0: + bitmap = self.get_presence_bitmap() + changed_ports = self._sfp_change_event_data['present'] ^ bitmap + if changed_ports != 0: + break + time.sleep(POLL_INTERVAL_IN_SEC) + # timeout=0 means wait for event forever + if timeout != 0: + cd_ms = cd_ms - POLL_INTERVAL_IN_SEC * 1000 + + if changed_ports != 0: + for sfp in self._sfp_list: + i=sfp.get_position_in_parent() - 1 + if (changed_ports & (1 << i)): + if (bitmap & (1 << i)) == 0: + port_dict[i+1] = '0' + else: + port_dict[i+1] = '1' + + + # Update the cache dict + self._sfp_change_event_data['present'] = bitmap + return True, change_dict + else: + return True, change_dict diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan.py index 23d8be5a8a..694593d030 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan.py @@ -6,6 +6,9 @@ except ImportError as e: raise ImportError(str(e) + "- required module not found") +FAN_NAME_LIST = ["FAN-1F", "FAN-1R", "FAN-2F", "FAN-2R", + "FAN-3F", "FAN-3R", "FAN-4F", "FAN-4R", + "FAN-5F", "FAN-5R", "FAN-6F", "FAN-6R"] class Fan(PddfFan): """PDDF Platform-Specific Fan class""" @@ -15,5 +18,48 @@ def __init__(self, tray_idx, fan_idx=0, pddf_data=None, pddf_plugin_data=None, i PddfFan.__init__(self, tray_idx, fan_idx, pddf_data, pddf_plugin_data, is_psu_fan, psu_index) # Provide the functions/variables below for which implementation is to be overwritten - # Since AS4630 psu_fan airflow direction cant be read from sysfs, it is fixed as 'F2B' or 'intake' + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + fan_name = FAN_NAME_LIST[(self.fantray_index-1)*2 + self.fan_index-1] \ + if not self.is_psu_fan \ + else "PSU-{} FAN-{}".format(self.fans_psu_index, self.fan_index) + + return fan_name + + + + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + + return "N/A" + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return "N/A" + + def get_target_speed(self): + """ + Retrieves the target (expected) speed of the fan + + Returns: + An integer, the percentage of full fan speed, in the range 0 (off) + to 100 (full speed) + """ + if self.is_psu_fan: + return super().get_speed() + else: + return super().get_target_speed() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan_drawer.py index 3b9bb607f6..f1e5c6edbc 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan_drawer.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan_drawer.py @@ -15,3 +15,28 @@ def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None): PddfFanDrawer.__init__(self, tray_idx, pddf_data, pddf_plugin_data) # Provide the functions/variables below for which implementation is to be overwritten + + def get_name(self): + """ + Retrieves the fan drawer name + Returns: + string: The name of the device + """ + return "FanTray{}".format(self.fantray_index) + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + return self._fan_list[0].get_model() + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return self._fan_list[0].get_serial() + diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/helper.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/helper.py new file mode 100644 index 0000000000..c3b0f1d2f4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/helper.py @@ -0,0 +1,54 @@ +import os +import struct +import subprocess +from mmap import * +from sonic_py_common import device_info +from sonic_py_common.general import getstatusoutput_noshell + +HOST_CHK_CMD = ["docker"] +EMPTY_STRING = "" + + +class APIHelper(): + + def __init__(self): + (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() + + def is_host(self): + try: + status, output = getstatusoutput_noshell(HOST_CHK_CMD) + return status == 0 + except Exception: + return False + + def pci_get_value(self, resource, offset): + status = True + result = "" + try: + fd = os.open(resource, os.O_RDWR) + mm = mmap(fd, 0) + mm.seek(int(offset)) + read_data_stream = mm.read(4) + result = struct.unpack('I', read_data_stream) + except Exception: + status = False + return status, result + + def read_txt_file(self, file_path): + try: + with open(file_path, 'r', errors='replace') as fd: + data = fd.read() + ret = data.strip() + if len(ret) > 0: + return ret + except IOError: + pass + return None + + def write_txt_file(self, file_path, value): + try: + with open(file_path, 'w') as fd: + fd.write(str(value)) + except IOError: + return False + return True diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/pcie.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/pcie.py new file mode 100644 index 0000000000..e4da32adf9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/pcie.py @@ -0,0 +1,19 @@ +############################################################################# +# Edgecore +# +# Module contains an implementation of SONiC Platform Base API and +# provides the fan status which are available in the platform +# Base PCIe class +############################################################################# + +try: + from sonic_platform_base.sonic_pcie.pcie_common import PcieUtil +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Pcie(PcieUtil): + """Edgecore Platform-specific PCIe class""" + + def __init__(self, platform_path): + PcieUtil.__init__(self, platform_path) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py index 1b260fccae..899d37be99 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py @@ -26,10 +26,79 @@ def get_maximum_supplied_power(self): """ return float(self.PLATFORM_PSU_CAPACITY) - def get_type(self): + def get_name(self): + return "PSU-{}".format(self.psu_index) + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + return 'N/A' + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + + Returns: + string: Model/part number of device + """ + model = super().get_model() + if model and model.strip() == "": + return None + + return model + + def get_serial(self): + """ + Retrieves the serial number of the device + + Returns: + string: Serial number of device + """ + serial = super().get_serial() + if serial and serial.strip() == "": + return None + + return serial + + def get_voltage(self): + """ + Retrieves current PSU voltage output + + Returns: + A float number, the output voltage in volts, + e.g. 12.1 + """ + if self.get_status() is not True: + return 0.0 + + return super().get_voltage() + + def get_current(self): """ - Gets the type of the PSU + Retrieves present electric current supplied by PSU + + Returns: + A float number, electric current in amperes, + e.g. 15.4 + """ + if self.get_status() is not True: + return 0.0 + + return super().get_current() + + def get_power(self): + """ + Retrieves current energy supplied by PSU + Returns: - A string, the type of PSU (AC/DC) + A float number, the power in watts, + e.g. 302.6 """ - return "DC" + if self.get_status() is not True: + return 0.0 + + return super().get_power() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py index d9b6e491be..837d060e99 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py @@ -1,7 +1,10 @@ #!/usr/bin/env python try: + import natsort from sonic_platform_pddf_base.pddf_sfp import PddfSfp + from sonic_platform_base.sonic_sfp.sfputilhelper import SfpUtilHelper + from sonic_py_common import device_info except ImportError as e: raise ImportError (str(e) + "- required module not found") @@ -11,7 +14,185 @@ class Sfp(PddfSfp): PDDF Platform-Specific Sfp class """ + SFP_TYPE_CODE_LIST = [ + 0x03, # SFP/SFP+/SFP28 + 0x0b # DWDM-SFP/SFP+ + ] + QSFP_TYPE_CODE_LIST = [ + 0x0c, # QSFP + 0x0d, # QSFP+ or later + 0x11, # QSFP28 or later + 0xe1 # QSFP28 EDFA + ] + def __init__(self, index, pddf_data=None, pddf_plugin_data=None): PddfSfp.__init__(self, index, pddf_data, pddf_plugin_data) + self.index = self.port_index # Provide the functions/variables below for which implementation is to be overwritten + def __get_path_to_port_config_file(self): + platform, hwsku = device_info.get_platform_and_hwsku() + hwsku_path = "/".join(["/usr/share/sonic/platform",hwsku]) + return "/".join([hwsku_path, "port_config.ini"]) + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + sfputil_helper = SfpUtilHelper() + sfputil_helper.read_porttab_mappings( + self.__get_path_to_port_config_file()) + + logical_port_list = sfputil_helper.logical + logical_port_list = natsort.natsorted(logical_port_list) + name = logical_port_list[self.port_index-1] or "Unknown" + + return name + + def get_position_in_parent(self): + """Retrieves 1-based relative physical position in parent device.""" + return self.port_index + + def __validate_eeprom_sfp(self): + checksum_test = 0 + eeprom_raw = self.read_eeprom(0, 96) + if eeprom_raw is None: + return None + + for i in range(0, 63): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[63]: + return False + + checksum_test = 0 + for i in range(64, 95): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[95]: + return False + + api = self.get_xcvr_api() + if api is None: + return False + + if api.is_flat_memory(): + return True + + checksum_test = 0 + eeprom_raw = self.read_eeprom(384, 96) + if eeprom_raw is None: + return None + + for i in range(0, 95): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[95]: + return False + + return True + + def __validate_eeprom_qsfp(self): + checksum_test = 0 + eeprom_raw = self.read_eeprom(128, 96) + if eeprom_raw is None: + return None + + for i in range(0, 63): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[63]: + return False + + checksum_test = 0 + for i in range(64, 95): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[95]: + return False + + api = self.get_xcvr_api() + if api is None: + return False + + if api.is_flat_memory(): + return True + + return True + + def validate_eeprom(self): + id_byte_raw = self.read_eeprom(0, 1) + if id_byte_raw is None: + return None + + id = id_byte_raw[0] + if id in self.QSFP_TYPE_CODE_LIST: + return self.__validate_eeprom_qsfp() + elif id in self.SFP_TYPE_CODE_LIST: + return self.__validate_eeprom_sfp() + else: + return False + + def validate_temperature(self): + temperature = self.get_temperature() + if temperature is None: + return None + + threshold_dict = self.get_transceiver_threshold_info() + if threshold_dict is None: + return None + + if isinstance(temperature, float) is not True: + return True + + if isinstance(threshold_dict['temphighalarm'], float) is not True: + return True + + return threshold_dict['temphighalarm'] > temperature + + def __get_error_description(self): + if not self.get_presence(): + return self.SFP_STATUS_UNPLUGGED + + err_stat = self.SFP_STATUS_BIT_INSERTED + + status = self.validate_eeprom() + if status is not True: + err_stat = (err_stat | self.SFP_ERROR_BIT_BAD_EEPROM) + + status = self.validate_temperature() + if status is not True: + err_stat = (err_stat | self.SFP_ERROR_BIT_HIGH_TEMP) + + if err_stat is self.SFP_STATUS_BIT_INSERTED: + return self.SFP_STATUS_OK + else: + err_desc = '' + cnt = 0 + for key in self.SFP_ERROR_BIT_TO_DESCRIPTION_DICT: + if (err_stat & key) != 0: + if cnt > 0: + err_desc = err_desc + "|" + cnt = cnt + 1 + err_desc = err_desc + self.SFP_ERROR_BIT_TO_DESCRIPTION_DICT[key] + + return err_desc + + def get_error_description(self): + """ + Retrives the error descriptions of the SFP module + + Returns: + String that represents the current error descriptions of vendor specific errors + In case there are multiple errors, they should be joined by '|', + like: "Bad EEPROM|Unsupported cable" + """ + try: + ret = super().get_error_description() + if ret is not None: + return ret + except NotImplementedError: + pass + return self.__get_error_description() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/thermal.py index 77d6ec7ae8..328ce462e3 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/thermal.py @@ -13,5 +13,82 @@ class Thermal(PddfThermal): def __init__(self, index, pddf_data=None, pddf_plugin_data=None, is_psu_thermal=False, psu_index=0): PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data, is_psu_thermal, psu_index) + + self.pddf_obj = pddf_data + self.thermal_obj_name = "TEMP{}".format(self.thermal_index) + self.thermal_obj = self.pddf_obj.data[self.thermal_obj_name] + self.min_temperature = None + self.max_temperature = None # Provide the functions/variables below for which implementation is to be overwritten + def get_name(self): + if self.is_psu_thermal: + return "PSU-{0} temp sensor 1".format(self.thermals_psu_index) + else: + if 'dev_attr' in self.thermal_obj.keys(): + if 'display_name' in self.thermal_obj['dev_attr']: + return str(self.thermal_obj['dev_attr']['display_name']) + + # In case of errors + return "Temp sensor {0}".format(self.thermal_index) + + def get_status(self): + get_temp=self.get_temperature() + + if get_temp is not None: + return True if get_temp else False + + def get_temperature(self): + current = super().get_temperature() + + if self.min_temperature is None or \ + current < self.min_temperature: + self.min_temperature = current + + if self.max_temperature is None or \ + current > self.max_temperature: + self.max_temperature = current + + return current + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + + return "N/A" + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return "N/A" + + def get_minimum_recorded(self): + """ + Retrieves the minimum recorded temperature of thermal + Returns: + A float number, the minimum recorded temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.min_temperature is None: + self.get_temperature() + + return self.min_temperature + + def get_maximum_recorded(self): + """ + Retrieves the maximum recorded temperature of thermal + Returns: + A float number, the maximum recorded temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.max_temperature is None: + self.get_temperature() + + return self.max_temperature + diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_pddf_monitor.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_pddf_monitor.py index 7f3add4e4d..0db5471b0b 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_pddf_monitor.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_pddf_monitor.py @@ -30,6 +30,7 @@ import logging.handlers import time from sonic_platform import platform + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError('%s - required module not found' % str(e)) @@ -294,15 +295,46 @@ def main(argv): global platform_chassis platform_chassis = platform.Platform().get_chassis() + #cmd_str = ["i2cset", "-y", "-f", "11", "0x66", "0x33", "0x0"] + #status, output = getstatusoutput_noshell(cmd_str) + #if status: + # print("Warning: Fan speed watchdog could not be disabled") + + cmd_str = ["i2cset", "-y", "-f", "11", "0x66", "0x33", "0x1"] + status, output = getstatusoutput_noshell(cmd_str) + if status: + print("Warning: Fan speed watchdog could not be enabled") + + #Timer need to be set after enable. + #if set timer is eralier than enable wdt. Speed will become to wdt speed after 6sec. + cmd_str = ["i2cset", "-y", "-f", "11", "0x66", "0x31", "0xF0"] + status, output = getstatusoutput_noshell(cmd_str) + if status: + print("Warning: Fan speed watchdog timer could not be disabled") platform_chassis.get_fan(0).set_speed(38) print("set default fan speed to 37.5%") monitor = device_monitor(log_file, log_level) + + cmd_kick = ["i2cset", "-y", "-f", "11", "0x66", "0x31", "0xF0"] #kick WDT + cmd_check_wdt = ["i2cget", "-y", "-f", "11", "0x66", "0x33"] while True: monitor.manage_fans() + getstatusoutput_noshell(cmd_kick) time.sleep(5) + #polling to check fan-wdt status + status, output = getstatusoutput_noshell(cmd_check_wdt) + if status is not None: + val= int(output,16) + if (val & 0x1) == 0: + logging.warning('Detect Fan-WDT disable') + logging.warning('Try to enable Fan-WDT') + cmd_str = ["i2cset", "-y", "-f", "11", "0x66", "0x33", "0x1"] + getstatusoutput_noshell(cmd_str) + cmd_str = ["i2cset", "-y", "-f", "11", "0x66", "0x31", "0xF0"] + getstatusoutput_noshell(cmd_str) if __name__ == '__main__': diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py index f4335bd445..f934743254 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py @@ -100,9 +100,9 @@ def show_help(): def dis_i2c_ir3570a(addr): - cmd = ["i2cset", "-y", "0", "0x"+"%x"%addr, "0xE5", "0x01"] + cmd = ["i2cset", "-y", "-a", "0", "0x"+"%x"%addr, "0xE5", "0x01"] status, output = getstatusoutput_noshell(cmd) - cmd = ["i2cset", "-y", "0", "0x"+"%x"%addr, "0x12", "0x02"] + cmd = ["i2cset", "-y", "-a", "0", "0x"+"%x"%addr, "0x12", "0x02"] status, output = getstatusoutput_noshell(cmd) return status diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/pddf_post_device_create.sh b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/pddf_post_device_create.sh deleted file mode 100755 index bfa5455953..0000000000 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/pddf_post_device_create.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set_pca_mux_idle_disconnect() -{ - echo -2 | tee /sys/bus/i2c/drivers/pca954x/*-00*/idle_state >& /dev/null - if [ $? -ne 0 ]; then - echo Fail to set pca954x mux idle disconnect - exit 2 - fi -} - -set_pca_mux_idle_disconnect diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_fan.c index 0341b3802b..bc8e112360 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_fan.c @@ -45,7 +45,6 @@ static struct as7726_32x_fan_data *as7726_32x_fan_update_device(struct device *d static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, char *buf); /* fan related data, the index should match sysfs_fan_attributes */ @@ -294,7 +293,7 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, if (value < 0 || value > FAN_MAX_DUTY_CYCLE) return -EINVAL; - as7726_32x_fan_write_value(client, 0x33, 0); /* Disable fan speed watch dog */ + //as7726_32x_fan_write_value(client, 0x33, 0); /* Disable fan speed watch dog */ as7726_32x_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); return count; } diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_psu.c index f4da01e86d..3736cc8da0 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_psu.c @@ -34,8 +34,10 @@ #include #include +#define MAX_MODEL_NAME 16 +#define MAX_SERIAL_NUMBER 18 static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_string(struct device *dev, struct device_attribute *da, char *buf); static int as7726_32x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); extern int as7726_32x_cpld_read(unsigned short cpld_addr, u8 reg); @@ -52,7 +54,8 @@ struct as7726_32x_psu_data { unsigned long last_updated; /* In jiffies */ u8 index; /* PSU index */ u8 status; /* Status(present/power_good) register read from CPLD */ - char model_name[9]; /* Model name, read from eeprom */ + char model_name[MAX_MODEL_NAME+1]; /* Model name, read from eeprom */ + char serial_number[MAX_SERIAL_NUMBER+1]; }; static struct as7726_32x_psu_data *as7726_32x_psu_update_device(struct device *dev); @@ -60,18 +63,21 @@ static struct as7726_32x_psu_data *as7726_32x_psu_update_device(struct device *d enum as7726_32x_psu_sysfs_attributes { PSU_PRESENT, PSU_MODEL_NAME, + PSU_SERIAL_NUMBER, PSU_POWER_GOOD }; /* sysfs attributes for hwmon */ static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); -static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_model_name,NULL, PSU_MODEL_NAME); +static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_string, NULL, PSU_MODEL_NAME); +static SENSOR_DEVICE_ATTR(psu_serial_number, S_IRUGO, show_string, NULL, PSU_SERIAL_NUMBER); static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); static struct attribute *as7726_32x_psu_attributes[] = { &sensor_dev_attr_psu_present.dev_attr.attr, &sensor_dev_attr_psu_model_name.dev_attr.attr, + &sensor_dev_attr_psu_serial_number.dev_attr.attr, &sensor_dev_attr_psu_power_good.dev_attr.attr, NULL }; @@ -83,6 +89,10 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, struct as7726_32x_psu_data *data = as7726_32x_psu_update_device(dev); u8 status = 0; + if (!data->valid) { + return -EIO; + } + if (attr->index == PSU_PRESENT) { status = !(data->status >> (1-data->index) & 0x1); } @@ -93,12 +103,27 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, return sprintf(buf, "%d\n", status); } -static ssize_t show_model_name(struct device *dev, struct device_attribute *da, - char *buf) +static ssize_t show_string(struct device *dev, struct device_attribute *da, + char *buf) { + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct as7726_32x_psu_data *data = as7726_32x_psu_update_device(dev); + char *ptr = NULL; - return sprintf(buf, "%s\n", data->model_name); + if (!data->valid) { + return -EIO; + } + + if (attr->index == PSU_MODEL_NAME) { + ptr = data->model_name; + } + else if (attr->index == PSU_SERIAL_NUMBER) { + ptr = data->serial_number; + } + else { + return -EIO; + } + return sprintf(buf, "%s\n", ptr); } static const struct attribute_group as7726_32x_psu_group = { @@ -219,6 +244,112 @@ static int as7726_32x_psu_read_block(struct i2c_client *client, u8 command, u8 * return result; } +enum psu_type { + PSU_TYPE_AC_110V, + PSU_TYPE_DC_48V, + PSU_TYPE_DC_12V, + PSU_TYPE_AC_ACBEL_FSF019, + PSU_TYPE_AC_ACBEL_FSF045 +}; + +struct model_name_info { + enum psu_type type; + u8 offset; + u8 length; + char* model_name; +}; + +struct serial_number_info { + enum psu_type type; + u8 offset; + u8 length; + char* serial_number; +}; +struct model_name_info models[] = { + {PSU_TYPE_AC_110V, 0x20, 8, "YM-2651Y"}, + {PSU_TYPE_DC_48V, 0x20, 8, "YM-2651V"}, + {PSU_TYPE_DC_12V, 0x00, 11, "PSU-12V-750"}, + {PSU_TYPE_AC_ACBEL_FSF019, 0x15, 10, "FSF019-"}, + {PSU_TYPE_AC_ACBEL_FSF045, 0x15, 10, "FSF045-"} +}; + +struct serial_number_info serials[] = { + {PSU_TYPE_AC_110V, 0x2e, 18, "YM-2651Y"}, + {PSU_TYPE_DC_48V, 0x2e, 18, "YM-2651V"}, + {PSU_TYPE_DC_12V, 0x2e, 18, "PSU-12V-750"}, + {PSU_TYPE_AC_ACBEL_FSF019, 0x2e, 16, "FSF019-"}, + {PSU_TYPE_AC_ACBEL_FSF045, 0x2e, 16, "FSF045-"} +}; + + +static int as7726_32x_psu_model_name_get(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as7726_32x_psu_data *data = i2c_get_clientdata(client); + int i, status; + + for (i = 0; i < ARRAY_SIZE(models); i++) { + memset(data->model_name, 0, sizeof(data->model_name)); + + status = as7726_32x_psu_read_block(client, models[i].offset, + data->model_name, models[i].length); + if (status < 0) { + data->model_name[0] = '\0'; + dev_dbg(&client->dev, "unable to read model name from (0x%x) offset(0x%x)\n", + client->addr, models[i].offset); + return status; + } + else { + data->model_name[models[i].length] = '\0'; + } + + /* Determine if the model name is known, if not, read next index + */ + if (strncmp(data->model_name, models[i].model_name, strlen(models[i].model_name)) == 0) { + return 0; + } + else { + data->model_name[0] = '\0'; + } + } + + return -ENODATA; +} + +static int as7726_32x_psu_serial_number_get(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as7726_32x_psu_data *data = i2c_get_clientdata(client); + int i, status; + + for (i = 0; i < ARRAY_SIZE(models); i++) { + memset(data->serial_number, 0, sizeof(data->serial_number)); + + status = as7726_32x_psu_read_block(client, serials[i].offset, + data->serial_number, serials[i].length); + if (status < 0) { + data->serial_number[0] = '\0'; + dev_dbg(&client->dev, "unable to read serial_number from (0x%x) offset(0x%x)\n", + client->addr, serials[i].offset); + return status; + } + else { + data->serial_number[serials[i].length] = '\0'; + } + + /* Determine if the model name is known, if not, read next index + */ + if (strncmp(data->model_name, models[i].model_name, strlen(models[i].model_name)) == 0) { + return 0; + } + else { + data->serial_number[0] = '\0'; + } + } + + return -ENODATA; +} + static struct as7726_32x_psu_data *as7726_32x_psu_update_device(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -231,6 +362,7 @@ static struct as7726_32x_psu_data *as7726_32x_psu_update_device(struct device *d int status; int power_good = 0; + data->valid = 0; dev_dbg(&client->dev, "Starting as7726_32x update\n"); /* Read psu status */ @@ -238,6 +370,7 @@ static struct as7726_32x_psu_data *as7726_32x_psu_update_device(struct device *d if (status < 0) { dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); + goto exit; } else { data->status = status; @@ -245,17 +378,15 @@ static struct as7726_32x_psu_data *as7726_32x_psu_update_device(struct device *d /* Read model name */ memset(data->model_name, 0, sizeof(data->model_name)); + memset(data->serial_number, 0, sizeof(data->serial_number)); power_good = (data->status >> (3-data->index) & 0x1); if (power_good) { - status = as7726_32x_psu_read_block(client, 0x20, data->model_name, - ARRAY_SIZE(data->model_name)-1); - if (status < 0) { - data->model_name[0] = '\0'; - dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr); + if (as7726_32x_psu_model_name_get(dev) < 0) { + goto exit; } - else { - data->model_name[ARRAY_SIZE(data->model_name)-1] = '\0'; + if (as7726_32x_psu_serial_number_get(dev) < 0) { + goto exit; } } @@ -263,6 +394,7 @@ static struct as7726_32x_psu_data *as7726_32x_psu_update_device(struct device *d data->valid = 1; } +exit: mutex_unlock(&data->update_lock); return data; diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/service/as7726-32x-pddf-platform-monitor.service b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/service/as7726-32x-pddf-platform-monitor.service index a4aa842519..127e775bee 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/service/as7726-32x-pddf-platform-monitor.service +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/service/as7726-32x-pddf-platform-monitor.service @@ -1,6 +1,6 @@ [Unit] Description=Accton AS7726-32X Platform Monitoring service -Before=pmon.service +Before=pmon.service system-health.service After=pddf-platform-init.service DefaultDependencies=no diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/service/as7726-32x-platform-monitor.service b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/service/as7726-32x-platform-monitor.service index 5b04ad4101..2cdb614d6f 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/service/as7726-32x-platform-monitor.service +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/service/as7726-32x-platform-monitor.service @@ -1,6 +1,6 @@ [Unit] Description=Accton AS7726-32X Platform Monitoring service -Before=pmon.service +Before=pmon.service system-health.service After=as7726-32x-platform-handle_mac.service DefaultDependencies=no diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/chassis.py index 8ff20a7605..c0cfc5c79c 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/chassis.py @@ -8,58 +8,59 @@ try: import sys - import time from sonic_platform_pddf_base.pddf_chassis import PddfChassis + from .event import SfpEvent + from .helper import APIHelper except ImportError as e: raise ImportError(str(e) + "- required module not found") +NUM_COMPONENT = 6 +HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/" +PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/" +REBOOT_CAUSE_FILE = "reboot-cause.txt" class Chassis(PddfChassis): """ PDDF Platform-specific Chassis class """ + SYSLED_DEV_NAME = "DIAG_LED" + def __init__(self, pddf_data=None, pddf_plugin_data=None): PddfChassis.__init__(self, pddf_data, pddf_plugin_data) + self.__initialize_components() + self._api_helper = APIHelper() + self._sfpevent = SfpEvent(self.get_all_sfps()) + + + def __initialize_components(self): + from sonic_platform.component import Component + for index in range(NUM_COMPONENT): + component = Component(index) + self._component_list.append(component) # Provide the functions/variables below for which implementation is to be overwritten - sfp_change_event_data = {'valid': 0, 'last': 0, 'present': 0} - def get_change_event(self, timeout=2000): - now = time.time() - port_dict = {} - change_dict = {} - change_dict['sfp'] = port_dict - - if timeout < 1000: - timeout = 1000 - timeout = timeout / float(1000) # Convert to secs - - if now < (self.sfp_change_event_data['last'] + timeout) and self.sfp_change_event_data['valid']: - return True, change_dict - - bitmap = 0 - for i in range(34): - modpres = self.get_sfp(i+1).get_presence() - if modpres: - bitmap = bitmap | (1 << i) - - changed_ports = self.sfp_change_event_data['present'] ^ bitmap - if changed_ports: - for i in range(34): - if (changed_ports & (1 << i)): - if (bitmap & (1 << i)) == 0: - port_dict[i+1] = '0' - else: - port_dict[i+1] = '1' - - - # Update teh cache dict - self.sfp_change_event_data['present'] = bitmap - self.sfp_change_event_data['last'] = now - self.sfp_change_event_data['valid'] = 1 - return True, change_dict - else: - return True, change_dict + def get_change_event(self, timeout=0): + return self._sfpevent.get_sfp_event(timeout) + + def get_reboot_cause(self): + """ + Retrieves the cause of the previous reboot + + Returns: + A tuple (string, string) where the first element is a string + containing the cause of the previous reboot. This string must be + one of the predefined strings in this class. If the first string + is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used + to pass a description of the reboot cause. + """ + + reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE) + sw_reboot_cause = self._api_helper.read_txt_file( + reboot_cause_path) or "Unknown" + + + return ('REBOOT_CAUSE_NON_HARDWARE', sw_reboot_cause) def get_sfp(self, index): @@ -84,3 +85,48 @@ def get_sfp(self, index): sys.stderr.write("SFP index {} out of range (1-{})\n".format( index, len(self._sfp_list))) return sfp + + def initizalize_system_led(self): + return + + def get_status_led(self): + return self.get_system_led(self.SYSLED_DEV_NAME) + + def set_status_led(self, color): + return self.set_system_led(self.SYSLED_DEV_NAME, color) + + def get_port_or_cage_type(self, port): + from sonic_platform_base.sfp_base import SfpBase + if port in range(1, 32): + return SfpBase.SFP_PORT_TYPE_BIT_QSFP | SfpBase.SFP_PORT_TYPE_BIT_QSFP_PLUS | SfpBase.SFP_PORT_TYPE_BIT_QSFP28 + else: + return SfpBase.SFP_PORT_TYPE_BIT_SFP | SfpBase.SFP_PORT_TYPE_BIT_SFP_PLUS + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + If the agent cannot determine the parent-relative position + for some reason, or if the associated value of + entPhysicalContainedIn is'0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device + or -1 if cannot determine the position + """ + return -1 + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + return self._eeprom.revision_str() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/component.py new file mode 100644 index 0000000000..704b4e2208 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/component.py @@ -0,0 +1,191 @@ +############################################################################# +# +# Component contains an implementation of SONiC Platform Base API and +# provides the components firmware management function +# +############################################################################# + +try: + import os + import json + from sonic_platform_base.component_base import ComponentBase + from sonic_py_common.general import getstatusoutput_noshell +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +CPLD_ADDR_MAPPING = { + "MB_CPLD1": ['11', '0x60'], + "MB_CPLD2": ['12', '0x62'], + "MB_CPLD3": ['13', '0x64'], + "FAN_CPLD": ['54', '0x66'], + "CPU_CPLD": ['0', '0x65'], +} +SYSFS_PATH = "/sys/bus/i2c/devices/" +BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version" +COMPONENT_LIST= [ + ("MB_CPLD1", "Mainboard CPLD(0x60)"), + ("MB_CPLD2", "Mainboard CPLD(0x62)"), + ("MB_CPLD3", "Mainboard CPLD(0x64)"), + ("FAN_CPLD", "Fan board CPLD(0x66)"), + ("CPU_CPLD", "CPU CPLD(0x65)"), + ("BIOS", "Basic Input/Output System") + +] + +class Component(ComponentBase): + """Platform-specific Component class""" + + DEVICE_TYPE = "component" + + def __init__(self, component_index=0): + self.index = component_index + self.name = self.get_name() + + def __get_bios_version(self): + # Retrieves the BIOS firmware version + try: + with open(BIOS_VERSION_PATH, 'r') as fd: + bios_version = fd.read() + return bios_version.strip() + except Exception as e: + return None + + def __get_cpld_version(self): + # Retrieves the CPLD firmware version + cpld_version = dict() + for cpld_name in CPLD_ADDR_MAPPING: + cmd = ["i2cget", "-f", "-y", CPLD_ADDR_MAPPING[cpld_name][0], CPLD_ADDR_MAPPING[cpld_name][1], "0x1"] + status, value = getstatusoutput_noshell(cmd) + if not status: + cpld_version_raw = value.rstrip() + cpld_version[cpld_name] = "{}".format(int(cpld_version_raw,16)) + + return cpld_version + + def get_name(self): + """ + Retrieves the name of the component + Returns: + A string containing the name of the component + """ + return COMPONENT_LIST[self.index][0] + + def get_description(self): + """ + Retrieves the description of the component + Returns: + A string containing the description of the component + """ + return COMPONENT_LIST[self.index][1] + + def get_firmware_version(self): + """ + Retrieves the firmware version of module + Returns: + string: The firmware versions of the module + """ + fw_version = None + + if self.name == "BIOS": + fw_version = self.__get_bios_version() + elif "CPLD" in self.name: + cpld_version = self.__get_cpld_version() + fw_version = cpld_version.get(self.name) + + return fw_version + + def install_firmware(self, image_path): + """ + Install firmware to module + Args: + image_path: A string, path to firmware image + Returns: + A boolean, True if install successfully, False if not + """ + ret, output = getstatusoutput_noshell(["tar", "-C", "/tmp", "-xzf", image_path ] ) + if ret != 0 : + print("Installation failed because of wrong image package") + return False + + if False == os.path.exists("/tmp/install.json") : + print("Installation failed without jsonfile") + return False + + input_file = open ('/tmp/install.json') + json_array = json.load(input_file) + ret = 1 + for item in json_array: + if item.get('id')==None or item.get('path')==None: + continue + if self.name == item['id'] and item['path'] and item.get('cpu'): + print( "Find", item['id'], item['path'], item['cpu'] ) + ret, output = getstatusoutput_noshell(["/tmp/run_install.sh", item['id'], item['path'], item['cpu'] ]) + if ret==0: + break + elif self.name == item['id'] and item['path']: + print( "Find", item['id'], item['path'] ) + ret, output = getstatusoutput_noshell(["/tmp/run_install.sh", item['id'], item['path'] ]) + if ret==0: + break + + if ret==0: + return True + else : + return False + + def get_presence(self): + """ + Retrieves the presence of the device + Returns: + bool: True if device is present, False if not + """ + return True + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + return 'N/A' + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return 'N/A' + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + return True + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + If the agent cannot determine the parent-relative position + for some reason, or if the associated value of + entPhysicalContainedIn is'0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device + or -1 if cannot determine the position + """ + return -1 + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + + + + + diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/event.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/event.py new file mode 100644 index 0000000000..1a2f60dbb6 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/event.py @@ -0,0 +1,109 @@ +try: + import time + from sonic_py_common.logger import Logger + from .sfp import Sfp +except ImportError as e: + raise ImportError(repr(e) + " - required module not found") + +POLL_INTERVAL_IN_SEC = 1 + +# SFP errors that will block eeprom accessing +SFP_BLOCKING_ERRORS = [ + Sfp.SFP_ERROR_BIT_I2C_STUCK, + Sfp.SFP_ERROR_BIT_BAD_EEPROM, + Sfp.SFP_ERROR_BIT_UNSUPPORTED_CABLE, + Sfp.SFP_ERROR_BIT_HIGH_TEMP, + Sfp.SFP_ERROR_BIT_BAD_CABLE +] + +class SfpEvent: + ''' Listen to insert/remove sfp events ''' + + def __init__(self, sfp_list): + self._sfp_list = sfp_list + self._logger = Logger() + self._sfp_change_event_data = {'present': 0} + + def get_presence_bitmap(self): + bitmap = 0 + for sfp in self._sfp_list: + modpres = sfp.get_presence() + i=sfp.get_position_in_parent() - 1 + if modpres: + bitmap = bitmap | (1 << i) + return bitmap + + def get_sfp_event(self, timeout=2000): + port_dict = {} + change_dict = {} + change_dict['sfp'] = port_dict + + if timeout < 1000: + cd_ms = 1000 + else: + cd_ms = timeout + + while cd_ms > 0: + bitmap = self.get_presence_bitmap() + changed_ports = self._sfp_change_event_data['present'] ^ bitmap + if changed_ports != 0: + break + time.sleep(POLL_INTERVAL_IN_SEC) + # timeout=0 means wait for event forever + if timeout != 0: + cd_ms = cd_ms - POLL_INTERVAL_IN_SEC * 1000 + + if changed_ports != 0: + for sfp in self._sfp_list: + i=sfp.get_position_in_parent() - 1 + if (changed_ports & (1 << i)) == 0: + continue + + if (bitmap & (1 << i)) == 0: + port_dict[i+1] = '0' + else: + # sfp.refresh_optoe_dev_class() + sfp_state_bits = self.get_sfp_state_bits(sfp, True) + sfp_state_bits = self.check_sfp_blocking_errors(sfp_state_bits) + + port_dict[i+1] = str(sfp_state_bits) + + # Update the cache dict + self._sfp_change_event_data['present'] = bitmap + return True, change_dict + else: + return True, change_dict + + def get_sfp_state_bits(self, sfp, present): + sfp_state_bits = 0 + + if present is True: + sfp_state_bits |= Sfp.SFP_STATUS_BIT_INSERTED + else: + return sfp_state_bits + + status = sfp.validate_eeprom() + if status is None: + sfp_state_bits |= Sfp.SFP_ERROR_BIT_I2C_STUCK + return sfp_state_bits + elif status is not True: + sfp_state_bits |= Sfp.SFP_ERROR_BIT_BAD_EEPROM + return sfp_state_bits + + status = sfp.validate_temperature() + if status is None: + sfp_state_bits |= Sfp.SFP_ERROR_BIT_I2C_STUCK + return sfp_state_bits + elif status is not True: + sfp_state_bits |= Sfp.SFP_ERROR_BIT_HIGH_TEMP + return sfp_state_bits + + return sfp_state_bits + + def check_sfp_blocking_errors(self, sfp_state_bits): + for i in SFP_BLOCKING_ERRORS: + if (i & sfp_state_bits) == 0: + continue + sfp_state_bits |= Sfp.SFP_ERROR_BIT_BLOCKING + + return sfp_state_bits diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/fan.py index 23d8be5a8a..46df75e256 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/fan.py @@ -6,6 +6,9 @@ except ImportError as e: raise ImportError(str(e) + "- required module not found") +FAN_NAME_LIST = ["FAN-1F", "FAN-1R", "FAN-2F", "FAN-2R", + "FAN-3F", "FAN-3R", "FAN-4F", "FAN-4R", + "FAN-5F", "FAN-5R", "FAN-6F", "FAN-6R"] class Fan(PddfFan): """PDDF Platform-Specific Fan class""" @@ -15,5 +18,61 @@ def __init__(self, tray_idx, fan_idx=0, pddf_data=None, pddf_plugin_data=None, i PddfFan.__init__(self, tray_idx, fan_idx, pddf_data, pddf_plugin_data, is_psu_fan, psu_index) # Provide the functions/variables below for which implementation is to be overwritten - # Since AS4630 psu_fan airflow direction cant be read from sysfs, it is fixed as 'F2B' or 'intake' + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + fan_name = FAN_NAME_LIST[(self.fantray_index-1)*2 + self.fan_index-1] \ + if not self.is_psu_fan \ + else "PSU-{} FAN-{}".format(self.fans_psu_index, self.fan_index) + return fan_name + + + + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + + return "N/A" + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return "N/A" + + def get_target_speed(self): + """ + Retrieves the target (expected) speed of the fan + + Returns: + An integer, the percentage of full fan speed, in the range 0 (off) + to 100 (full speed) + """ + if self.is_psu_fan: + return super().get_speed() + else: + return super().get_target_speed() + + 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 = super().get_direction() + if direction is not None and len(direction) > 0: + return direction + + return 'N/A' diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/fan_drawer.py index 3b9bb607f6..e4e37f9620 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/fan_drawer.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/fan_drawer.py @@ -15,3 +15,27 @@ def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None): PddfFanDrawer.__init__(self, tray_idx, pddf_data, pddf_plugin_data) # Provide the functions/variables below for which implementation is to be overwritten + def get_name(self): + """ + Retrieves the fan drawer name + Returns: + string: The name of the device + """ + return "FanTray{}".format(self.fantray_index) + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + return self._fan_list[0].get_model() + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return self._fan_list[0].get_serial() + diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/helper.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/helper.py new file mode 100644 index 0000000000..b5e2e5a226 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/helper.py @@ -0,0 +1,368 @@ +import os +import struct +import json +import fcntl +from mmap import * +from sonic_py_common import device_info +from sonic_py_common import logger +from threading import Lock +from typing import cast +from sonic_py_common.general import getstatusoutput_noshell_pipe +from sonic_py_common.general import getstatusoutput_noshell + +HOST_CHK_CMD = ["docker"] +EMPTY_STRING = "" + + +class APIHelper(): + + def __init__(self): + (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() + + def is_host(self): + try: + status, output = getstatusoutput_noshell(HOST_CHK_CMD) + return status == 0 + except Exception: + return False + + def pci_get_value(self, resource, offset): + status = True + result = "" + try: + fd = os.open(resource, os.O_RDWR) + mm = mmap(fd, 0) + mm.seek(int(offset)) + read_data_stream = mm.read(4) + result = struct.unpack('I', read_data_stream) + except Exception: + status = False + return status, result + + def run_interactive_command(self, cmd): + try: + os.system(cmd) + except Exception: + return False + return True + + def read_txt_file(self, file_path): + try: + with open(file_path, 'r', errors='replace') as fd: + data = fd.read() + ret = data.strip() + if len(ret) > 0: + return ret + except IOError: + pass + return None + + def write_txt_file(self, file_path, value): + try: + with open(file_path, 'w') as fd: + fd.write(str(value)) + except IOError: + return False + return True + + def ipmi_raw(self, netfn, cmd): + status = True + result = "" + try: + err, raw_data = getstatusoutput_noshell_pipe(['ipmitool', 'raw', str(netfn), str(cmd)]) + if err == [0]: + result = raw_data.strip() + else: + status = False + except Exception: + status = False + return status, result + + def ipmi_fru_id(self, id, key=None): + status = True + result = "" + try: + if (key is None): + err, raw_data = getstatusoutput_noshell_pipe(['ipmitool', 'fru', 'print', str(id)]) + else: + err, raw_data = getstatusoutput_noshell_pipe(['ipmitool', 'fru', 'print', str(id)], ['grep', str(key)]) + if err == [0] or err == [0, 0]: + result = raw_data.strip() + else: + status = False + except Exception: + status = False + return status, result + + def ipmi_set_ss_thres(self, id, threshold_key, value): + status = True + result = "" + try: + err, raw_data = getstatusoutput_noshell_pipe(['ipmitool', 'sensor', 'thresh', str(id), str(threshold_key), str(value)]) + if err == [0]: + result = raw_data.strip() + else: + status = False + except Exception: + status = False + return status, result + + +class FileLock: + """ + Due to pmon docker not installing the py-filelock, this class + implements a simple file lock feature. + Ref: https://github.com/tox-dev/py-filelock/blob/main/src/filelock/ + """ + + def __init__(self, lock_file): + self._lock_file = lock_file + self._thread_lock = Lock() + self.is_locked = False + + def acquire(self): + with self._thread_lock: + if self.is_locked: + return + + fd = os.open(self._lock_file, flags=(os.O_RDWR | os.O_CREAT | os.O_TRUNC)) + fcntl.flock(fd, fcntl.LOCK_EX) + self._lock_file_fd = fd + self.is_locked = True + + def release(self): + with self._thread_lock: + if self.is_locked: + fd = cast(int, self._lock_file_fd) + self._lock_file_fd = None + fcntl.flock(fd, fcntl.LOCK_UN) + os.close(fd) + self.is_locked = False + + def __enter__(self): + self.acquire() + return self + + def __exit__(self, exc_type, exc_val, traceback): + self.release() + + def __del__(self): + self.release() + + +DEVICE_THRESHOLD_JSON_PATH = "/tmp/device_threshold.json" + +class DeviceThreshold: + HIGH_THRESHOLD = 'high_threshold' + LOW_THRESHOLD = 'low_threshold' + HIGH_CRIT_THRESHOLD = 'high_critical_threshold' + LOW_CRIT_THRESHOLD = 'low_critical_threshold' + NOT_AVAILABLE = 'N/A' + + def __init__(self, th_name = NOT_AVAILABLE): + self.flock = FileLock("{}.lock".format(DEVICE_THRESHOLD_JSON_PATH)) + self.name = th_name + self.__log = logger.Logger(log_identifier="DeviceThreshold") + + self.__db_data = {} + self.__db_mtime = 0 + + def __reload_db(self): + try: + db_data = {} + with self.flock: + with open(DEVICE_THRESHOLD_JSON_PATH, "r") as db_file: + db_data = json.load(db_file) + except Exception as e: + self.__log.log_warning('{}'.format(str(e))) + return None + + return db_data + + def __get_data(self, field): + """ + Retrieves data frome JSON file by field + + Args : + field: String + + Returns: + A string if getting is successfully, 'N/A' if not + """ + if os.path.exists(DEVICE_THRESHOLD_JSON_PATH): + new_mtime = os.path.getmtime(DEVICE_THRESHOLD_JSON_PATH) + if new_mtime != self.__db_mtime: + new_data = self.__reload_db() + if new_data is not None: + self.__db_data = new_data + self.__db_mtime = new_mtime + + if self.name not in self.__db_data.keys(): + return self.NOT_AVAILABLE + + if field not in self.__db_data[self.name].keys(): + return self.NOT_AVAILABLE + + return self.__db_data[self.name][field] + + def __set_data(self, field, new_val): + """ + Set data to JSON file by field + + Args : + field: String + new_val: String + + Returns: + A boolean, True if setting is set successfully, False if not + """ + if self.name not in self.__db_data.keys(): + self.__db_data[self.name] = {} + + old_val = self.__db_data[self.name].get(field, None) + if old_val is not None and old_val == new_val: + return True + + self.__db_data[self.name][field] = new_val + + try: + with self.flock: + db_data = {} + mode = "r+" if os.path.exists(DEVICE_THRESHOLD_JSON_PATH) else "w+" + with open(DEVICE_THRESHOLD_JSON_PATH, mode) as db_file: + if mode == "r+": + db_data = json.load(db_file) + + if self.name not in db_data.keys(): + db_data[self.name] = {} + + db_data[self.name][field] = new_val + + if mode == "r+": + db_file.seek(0) + # erase old data + db_file.truncate(0) + # write all data + json.dump(db_data, db_file, indent=4) + self.__db_mtime = os.path.getmtime(DEVICE_THRESHOLD_JSON_PATH) + except Exception as e: + self.__log.log_error('{}'.format(str(e))) + return False + + return True + + def get_high_threshold(self): + """ + Retrieves the high threshold temperature from JSON file. + + Returns: + string : the high threshold temperature of thermal, + e.g. "30.125" + """ + return self.__get_data(self.HIGH_THRESHOLD) + + def set_high_threshold(self, temperature): + """ + Sets the high threshold temperature of thermal + Args : + temperature: A string of temperature, e.g. "30.125" + Returns: + A boolean, True if threshold is set successfully, False if not + """ + if isinstance(temperature, str) is not True: + raise TypeError('The parameter requires string type.') + + try: + if temperature != self.NOT_AVAILABLE: + float(temperature) + except ValueError: + raise ValueError('The parameter requires a float string. ex:\"30.1\"') + + return self.__set_data(self.HIGH_THRESHOLD, temperature) + + def get_low_threshold(self): + """ + Retrieves the low threshold temperature from JSON file. + + Returns: + string : the low threshold temperature of thermal, + e.g. "30.125" + """ + return self.__get_data(self.LOW_THRESHOLD) + + def set_low_threshold(self, temperature): + """ + Sets the low threshold temperature of thermal + Args : + temperature: A string of temperature, e.g. "30.125" + Returns: + A boolean, True if threshold is set successfully, False if not + """ + if isinstance(temperature, str) is not True: + raise TypeError('The parameter requires string type.') + + try: + if temperature != self.NOT_AVAILABLE: + float(temperature) + except ValueError: + raise ValueError('The parameter requires a float string. ex:\"30.1\"') + + return self.__set_data(self.LOW_THRESHOLD, temperature) + + def get_high_critical_threshold(self): + """ + Retrieves the high critical threshold temperature from JSON file. + + Returns: + string : the high critical threshold temperature of thermal, + e.g. "30.125" + """ + return self.__get_data(self.HIGH_CRIT_THRESHOLD) + + def set_high_critical_threshold(self, temperature): + """ + Sets the high critical threshold temperature of thermal + Args : + temperature: A string of temperature, e.g. "30.125" + Returns: + A boolean, True if threshold is set successfully, False if not + """ + if isinstance(temperature, str) is not True: + raise TypeError('The parameter requires string type.') + + try: + if temperature != self.NOT_AVAILABLE: + float(temperature) + except ValueError: + raise ValueError('The parameter requires a float string. ex:\"30.1\"') + + return self.__set_data(self.HIGH_CRIT_THRESHOLD, temperature) + + def get_low_critical_threshold(self): + """ + Retrieves the low critical threshold temperature from JSON file. + + Returns: + string : the low critical threshold temperature of thermal, + e.g. "30.125" + """ + return self.__get_data(self.LOW_CRIT_THRESHOLD) + + def set_low_critical_threshold(self, temperature): + """ + Sets the low critical threshold temperature of thermal + Args : + temperature: A string of temperature, e.g. "30.125" + Returns: + A boolean, True if threshold is set successfully, False if not + """ + if isinstance(temperature, str) is not True: + raise TypeError('The parameter requires string type.') + + try: + if temperature != self.NOT_AVAILABLE: + float(temperature) + except ValueError: + raise ValueError('The parameter requires a float string. ex:\"30.1\"') + + return self.__set_data(self.LOW_CRIT_THRESHOLD, temperature) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/pcie.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/pcie.py new file mode 100644 index 0000000000..e4da32adf9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/pcie.py @@ -0,0 +1,19 @@ +############################################################################# +# Edgecore +# +# Module contains an implementation of SONiC Platform Base API and +# provides the fan status which are available in the platform +# Base PCIe class +############################################################################# + +try: + from sonic_platform_base.sonic_pcie.pcie_common import PcieUtil +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Pcie(PcieUtil): + """Edgecore Platform-specific PCIe class""" + + def __init__(self, platform_path): + PcieUtil.__init__(self, platform_path) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/psu.py index a2a3302065..a349319d4a 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/psu.py @@ -11,34 +11,120 @@ class Psu(PddfPsu): """PDDF Platform-Specific PSU class""" - PLATFORM_PSU_CAPACITY = 1200 - def __init__(self, index, pddf_data=None, pddf_plugin_data=None): PddfPsu.__init__(self, index, pddf_data, pddf_plugin_data) # Provide the functions/variables below for which implementation is to be overwritten - def get_maximum_supplied_power(self): + def get_voltage_high_threshold(self): + """ + Retrieves the high threshold PSU voltage output + Returns: + A float number, the high threshold output voltage in volts, + e.g. 12.1 + """ + return 14.72 + + def get_voltage_low_threshold(self): + """ + Retrieves the low threshold PSU voltage output + Returns: + A float number, the low threshold output voltage in volts, + e.g. 12.1 + """ + return 7.68 + + def get_name(self): + return "PSU-{}".format(self.psu_index) + + def get_temperature_high_threshold(self): + """ + Retrieves the high threshold temperature of PSU + Returns: + A float number, the high threshold temperature of PSU in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + threshold = super().get_temperature_high_threshold() + + for psu_thermal_idx in range(self.num_psu_thermals): + try: + tmp = self._thermal_list[psu_thermal_idx].get_high_threshold() + if threshold > tmp or threshold == 0.0: + threshold = tmp + except Exception: + pass + + return threshold + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device """ - Retrieves the maximum supplied power by PSU (or PSU capacity) + return 'N/A' + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: - A float number, the maximum power output in Watts. - e.g. 1200.1 + string: Model/part number of device """ - return float(self.PLATFORM_PSU_CAPACITY) + model = super().get_model() + if model and model.strip() == "": + return None - def get_capacity(self): + return model + + def get_serial(self): """ - Gets the capacity (maximum output power) of the PSU in watts + Retrieves the serial number of the device Returns: - An integer, the capacity of PSU + string: Serial number of device """ - return (self.PLATFORM_PSU_CAPACITY) + serial = super().get_serial() + if serial and serial.strip() == "": + return None + + return serial - def get_type(self): + def get_voltage(self): """ - Gets the type of the PSU + Retrieves current PSU voltage output + Returns: - A string, the type of PSU (AC/DC) + A float number, the output voltage in volts, + e.g. 12.1 """ - return "AC" + if self.get_status() is not True: + return 0.0 + + return super().get_voltage() + + def get_current(self): + """ + Retrieves present electric current supplied by PSU + + Returns: + A float number, electric current in amperes, + e.g. 15.4 + """ + if self.get_status() is not True: + return 0.0 + + return super().get_current() + + def get_power(self): + """ + Retrieves current energy supplied by PSU + + Returns: + A float number, the power in watts, + e.g. 302.6 + """ + if self.get_status() is not True: + return 0.0 + + return super().get_power() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/sfp.py index d9b6e491be..a0189bfcbc 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/sfp.py @@ -1,7 +1,10 @@ #!/usr/bin/env python try: + import natsort from sonic_platform_pddf_base.pddf_sfp import PddfSfp + from sonic_platform_base.sonic_sfp.sfputilhelper import SfpUtilHelper + from sonic_py_common import device_info except ImportError as e: raise ImportError (str(e) + "- required module not found") @@ -11,7 +14,180 @@ class Sfp(PddfSfp): PDDF Platform-Specific Sfp class """ + SFP_TYPE_CODE_LIST = [ + 0x03, # SFP/SFP+/SFP28 + 0x0b # DWDM-SFP/SFP+ + ] + QSFP_TYPE_CODE_LIST = [ + 0x0c, # QSFP + 0x0d, # QSFP+ or later + 0x11, # QSFP28 or later + 0xe1 # QSFP28 EDFA + ] + def __init__(self, index, pddf_data=None, pddf_plugin_data=None): PddfSfp.__init__(self, index, pddf_data, pddf_plugin_data) + self.index = self.port_index # Provide the functions/variables below for which implementation is to be overwritten + def __get_path_to_port_config_file(self): + platform, hwsku = device_info.get_platform_and_hwsku() + hwsku_path = "/".join(["/usr/share/sonic/platform",hwsku]) + return "/".join([hwsku_path, "port_config.ini"]) + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + sfputil_helper = SfpUtilHelper() + sfputil_helper.read_porttab_mappings( + self.__get_path_to_port_config_file()) + + logical_port_list = sfputil_helper.logical + logical_port_list = natsort.natsorted(logical_port_list) + name = logical_port_list[self.port_index-1] or "Unknown" + + return name + + def __validate_eeprom_sfp(self): + checksum_test = 0 + eeprom_raw = self.read_eeprom(0, 96) + if eeprom_raw is None: + return None + + for i in range(0, 63): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[63]: + return False + + checksum_test = 0 + for i in range(64, 95): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[95]: + return False + + api = self.get_xcvr_api() + if api is None: + return False + + if api.is_flat_memory(): + return True + + checksum_test = 0 + eeprom_raw = self.read_eeprom(384, 96) + if eeprom_raw is None: + return None + + for i in range(0, 95): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[95]: + return False + + return True + + def __validate_eeprom_qsfp(self): + checksum_test = 0 + eeprom_raw = self.read_eeprom(128, 96) + if eeprom_raw is None: + return None + + for i in range(0, 63): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[63]: + return False + + checksum_test = 0 + for i in range(64, 95): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[95]: + return False + + api = self.get_xcvr_api() + if api is None: + return False + + if api.is_flat_memory(): + return True + + return True + + def validate_eeprom(self): + id_byte_raw = self.read_eeprom(0, 1) + if id_byte_raw is None: + return None + + id = id_byte_raw[0] + if id in self.QSFP_TYPE_CODE_LIST: + return self.__validate_eeprom_qsfp() + elif id in self.SFP_TYPE_CODE_LIST: + return self.__validate_eeprom_sfp() + else: + return False + + def validate_temperature(self): + temperature = self.get_temperature() + if temperature is None: + return None + + threshold_dict = self.get_transceiver_threshold_info() + if threshold_dict is None: + return None + + if isinstance(temperature, float) is not True: + return True + + if isinstance(threshold_dict['temphighalarm'], float) is not True: + return True + + return threshold_dict['temphighalarm'] > temperature + + def __get_error_description(self): + if not self.get_presence(): + return self.SFP_STATUS_UNPLUGGED + + err_stat = self.SFP_STATUS_BIT_INSERTED + + status = self.validate_eeprom() + if status is not True: + err_stat = (err_stat | self.SFP_ERROR_BIT_BAD_EEPROM) + + status = self.validate_temperature() + if status is not True: + err_stat = (err_stat | self.SFP_ERROR_BIT_HIGH_TEMP) + + if err_stat is self.SFP_STATUS_BIT_INSERTED: + return self.SFP_STATUS_OK + else: + err_desc = '' + cnt = 0 + for key in self.SFP_ERROR_BIT_TO_DESCRIPTION_DICT: + if (err_stat & key) != 0: + if cnt > 0: + err_desc = err_desc + "|" + cnt = cnt + 1 + err_desc = err_desc + self.SFP_ERROR_BIT_TO_DESCRIPTION_DICT[key].replace(" ", "_") + + return err_desc + + def get_error_description(self): + """ + Retrives the error descriptions of the SFP module + Returns: + String that represents the current error descriptions of vendor specific errors + In case there are multiple errors, they should be joined by '|', + like: "Bad EEPROM|Unsupported cable" + """ + try: + ret = super().get_error_description() + if ret is not None: + return ret + except NotImplementedError: + pass + return self.__get_error_description() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/thermal.py index 77d6ec7ae8..6bf478bbda 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/sonic_platform/thermal.py @@ -3,15 +3,294 @@ try: from sonic_platform_pddf_base.pddf_thermal import PddfThermal + from .helper import DeviceThreshold except ImportError as e: raise ImportError(str(e) + "- required module not found") +NOT_AVAILABLE = DeviceThreshold.NOT_AVAILABLE +HIGH_THRESHOLD = DeviceThreshold.HIGH_THRESHOLD +LOW_THRESHOLD = DeviceThreshold.LOW_THRESHOLD +HIGH_CRIT_THRESHOLD = DeviceThreshold.HIGH_CRIT_THRESHOLD +LOW_CRIT_THRESHOLD = DeviceThreshold.LOW_CRIT_THRESHOLD +DEFAULT_THRESHOLD = { + 'CB_temp(0x4B)' : { + HIGH_THRESHOLD : '80.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : NOT_AVAILABLE, + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'FB_temp(0x4C)' : { + HIGH_THRESHOLD : '80.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : NOT_AVAILABLE, + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'MB_FrontMAC_temp(0x49)' : { + HIGH_THRESHOLD : '80.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : NOT_AVAILABLE, + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'MB_LeftCenter_temp(0x4A)' : { + HIGH_THRESHOLD : '80.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : NOT_AVAILABLE, + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'MB_RearMAC_temp(0x48)' : { + HIGH_THRESHOLD : '80.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : NOT_AVAILABLE, + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'CPU_Package_temp' : { + HIGH_THRESHOLD : '82.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : '104.0', + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'CPU_Core_0_temp' : { + HIGH_THRESHOLD : '82.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : '104.0', + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'CPU_Core_1_temp' : { + HIGH_THRESHOLD : '82.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : '104.0', + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'CPU_Core_2_temp' : { + HIGH_THRESHOLD : '82.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : '104.0', + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'CPU_Core_3_temp' : { + HIGH_THRESHOLD : '82.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : '104.0', + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'PSU-1 temp sensor 1' : { + HIGH_THRESHOLD : '80.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : NOT_AVAILABLE, + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + }, + 'PSU-2 temp sensor 1' : { + HIGH_THRESHOLD : '80.0', + LOW_THRESHOLD : NOT_AVAILABLE, + HIGH_CRIT_THRESHOLD : NOT_AVAILABLE, + LOW_CRIT_THRESHOLD : NOT_AVAILABLE + } +} class Thermal(PddfThermal): """PDDF Platform-Specific Thermal class""" def __init__(self, index, pddf_data=None, pddf_plugin_data=None, is_psu_thermal=False, psu_index=0): PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data, is_psu_thermal, psu_index) + # Threshold Configuration + self.__conf = DeviceThreshold(self.get_name()) + # Default threshold. + self.__default_threshold = DEFAULT_THRESHOLD[self.get_name()] + self.min_temperature = None + self.max_temperature = None + + self.pddf_obj = pddf_data + self.thermal_obj_name = "TEMP{}".format(self.thermal_index) + self.thermal_obj = self.pddf_obj.data[self.thermal_obj_name] # Provide the functions/variables below for which implementation is to be overwritten + def get_name(self): + if self.is_psu_thermal: + return "PSU-{0} temp sensor 1".format(self.thermals_psu_index) + else: + if 'dev_attr' in self.thermal_obj.keys(): + if 'display_name' in self.thermal_obj['dev_attr']: + return str(self.thermal_obj['dev_attr']['display_name']) + + # In case of errors + return "Temp sensor {0}".format(self.thermal_index) + + def get_status(self): + get_temp=self.get_temperature() + + if get_temp is not None: + return True if get_temp else False + + def get_temperature(self): + current = super().get_temperature() + + if self.min_temperature is None or \ + current < self.min_temperature: + self.min_temperature = current + + if self.max_temperature is None or \ + current > self.max_temperature: + self.max_temperature = current + + return current + + def set_high_threshold(self, temperature): + try: + value = float(temperature) + except Exception: + return False + + # The new value can not be more than the default value. + default_value = self.__default_threshold[HIGH_THRESHOLD] + if default_value != NOT_AVAILABLE: + if value > float(default_value): + return False + + try: + self.__conf.set_high_threshold(str(value)) + except Exception: + return False + + return True + + def get_high_threshold(self): + value = self.__conf.get_high_threshold() + if value != NOT_AVAILABLE: + return float(value) + + default_value = self.__default_threshold[HIGH_THRESHOLD] + if default_value != NOT_AVAILABLE: + return float(default_value) + + raise NotImplementedError + + def set_low_threshold(self, temperature): + try: + value = float(temperature) + except Exception: + return False + + # The new value can not be less than the default value. + default_value = self.__default_threshold[LOW_THRESHOLD] + if default_value != NOT_AVAILABLE: + if value < float(default_value): + return False + + try: + self.__conf.set_low_threshold(str(value)) + except Exception: + return False + + return True + + def get_low_threshold(self): + value = self.__conf.get_low_threshold() + if value != NOT_AVAILABLE: + return float(value) + + default_value = self.__default_threshold[LOW_THRESHOLD] + if default_value != NOT_AVAILABLE: + return float(default_value) + + raise NotImplementedError + + def set_high_critical_threshold(self, temperature): + try: + value = float(temperature) + except Exception: + return False + + # The new value can not be more than the default value. + default_value = self.__default_threshold[HIGH_CRIT_THRESHOLD] + if default_value != NOT_AVAILABLE: + if value > float(default_value): + return False + + try: + self.__conf.set_high_critical_threshold(str(value)) + except Exception: + return False + + return True + + def get_high_critical_threshold(self): + value = self.__conf.get_high_critical_threshold() + if value != NOT_AVAILABLE: + return float(value) + + default_value = self.__default_threshold[HIGH_CRIT_THRESHOLD] + if default_value != NOT_AVAILABLE: + return float(default_value) + + raise NotImplementedError + + def set_low_critical_threshold(self, temperature): + try: + value = float(temperature) + except Exception: + return False + + # The new value can not be less than the default value. + default_value = self.__default_threshold[LOW_CRIT_THRESHOLD] + if default_value != NOT_AVAILABLE: + if value < float(default_value): + return False + + try: + self.__conf.set_low_critical_threshold(str(value)) + except Exception: + return False + + return True + + def get_low_critical_threshold(self): + value = self.__conf.get_low_critical_threshold() + if value != NOT_AVAILABLE: + return float(value) + + default_value = self.__default_threshold[LOW_CRIT_THRESHOLD] + if default_value != NOT_AVAILABLE: + return float(default_value) + + raise NotImplementedError + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + return 'N/A' + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return 'N/A' + + def get_minimum_recorded(self): + """ + Retrieves the minimum recorded temperature of thermal + Returns: + A float number, the minimum recorded temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.min_temperature is None: + self.get_temperature() + + return self.min_temperature + + def get_maximum_recorded(self): + """ + Retrieves the maximum recorded temperature of thermal + Returns: + A float number, the maximum recorded temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.max_temperature is None: + self.get_temperature() + + return self.max_temperature diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_pddf_monitor.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_pddf_monitor.py index 2b18ac646a..5d27ba134a 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_pddf_monitor.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_pddf_monitor.py @@ -21,6 +21,7 @@ # 4/20/2018: Jostar modify for as7726_32x # 12/03/2018:Jostar modify for as7726_32x thermal plan # 11/16/2020:Jostar modify for as7726_32x thermal plan based on PDDF +# 11/19/2023:Jostar modify to add kick fan-wdt # ------------------------------------------------------------------ try: @@ -32,6 +33,7 @@ import logging.handlers import time from sonic_platform import platform + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError('%s - required module not found' % str(e)) @@ -162,7 +164,7 @@ def manage_fans(self): } fan_dir= platform_chassis.get_fan(0).get_direction() - if fan_dir == 'EXHAUST': + if fan_dir == 'exhaust': fan_policy = fan_policy_f2b else: fan_policy = fan_policy_b2f @@ -305,15 +307,47 @@ def main(argv): global platform_chassis platform_chassis = platform.Platform().get_chassis() - + #cmd_str = ["i2cset", "-y", "-f", "54", "0x66", "0x33", "0x0"] + #status, output = getstatusoutput_noshell(cmd_str) + #if status: + # print("Warning: Fan speed watchdog could not be disabled") + + cmd_str = ["i2cset", "-y", "-f", "54", "0x66", "0x33", "0x1"] + status, output = getstatusoutput_noshell(cmd_str) + if status: + print("Warning: Fan speed watchdog could not be enabled") + + #Timer need to be set after enable. + #if set timer is eralier than enable wdt. Speed will become to wdt speed after 6sec. + cmd_str = ["i2cset", "-y", "-f", "54", "0x66", "0x31", "0xF0"] + status, output = getstatusoutput_noshell(cmd_str) + if status: + print("Warning: Fan speed watchdog timer could not be disabled") + platform_chassis.get_fan(0).set_speed(38) print("set default fan speed to 37.5%") monitor = device_monitor(log_file, log_level) + + cmd_kick = ["i2cset", "-y", "-f", "54", "0x66", "0x31", "0xF0"] #kick WDT + cmd_check_wdt = ["i2cget", "-y", "-f", "54", "0x66", "0x33"] # Loop forever, doing something useful hopefully: while True: monitor.manage_fans() + getstatusoutput_noshell(cmd_kick) time.sleep(10) + #polling to check fan-wdt status + status, output = getstatusoutput_noshell(cmd_check_wdt) + if status is not None: + val= int(output,16) + if (val & 0x1) == 0: + logging.warning('Detect Fan-WDT disable') + logging.warning('Try to enable Fan-WDT') + cmd_str = ["i2cset", "-y", "-f", "54", "0x66", "0x33", "0x1"] + getstatusoutput_noshell(cmd_str) + cmd_str = ["i2cset", "-y", "-f", "54", "0x66", "0x31", "0xF0"] + getstatusoutput_noshell(cmd_str) + if __name__ == '__main__': main(sys.argv[1:]) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_util.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_util.py index 949f1230de..0386e74001 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_util.py @@ -16,22 +16,27 @@ # along with this program. If not, see . """ -Usage: %(scriptName)s [options] command object - -options: - -h | --help : this help message - -d | --debug : run with debug mode - -f | --force : ignore error during installation or clean -command: - install : install drivers and generate related sysfs nodes - clean : uninstall drivers and remove related sysfs nodes +usage: accton_as7726_32x_util.py [-h] [-d] [-f] {install,clean,threshold} ... + +AS7726-32X Platform Utility + +optional arguments: + -h, --help show this help message and exit + -d, --debug run with debug mode + -f, --force ignore error during installation or clean + +Utility Command: + {install,clean,threshold} + install : install drivers and generate related sysfs nodes + clean : uninstall drivers and remove related sysfs nodes + threshold : modify thermal threshold """ import subprocess -import getopt import sys import logging import re import time +import argparse from sonic_py_common.general import getstatusoutput_noshell PROJECT_NAME = 'as7726_32x' @@ -109,37 +114,44 @@ def main(): global DEBUG global args global FORCE + global THRESHOLD_RANGE_LOW, THRESHOLD_RANGE_HIGH + + util_parser = argparse.ArgumentParser(description="AS7726-32X Platform Utility") + util_parser.add_argument("-d", "--debug", dest='debug', action='store_true', default=False, + help="run with debug mode") + util_parser.add_argument("-f", "--force", dest='force', action='store_true', default=False, + help="ignore error during installation or clean") + subcommand = util_parser.add_subparsers(dest='cmd', title='Utility Command', required=True) + subcommand.add_parser('install', help=': install drivers and generate related sysfs nodes') + subcommand.add_parser('clean', help=': uninstall drivers and remove related sysfs nodes') + threshold_parser = subcommand.add_parser('threshold', help=': modify thermal threshold') + threshold_parser.add_argument("-l", dest='list', action='store_true', default=False, + help="list avaliable thermal") + threshold_parser.add_argument("-t", dest='thermal', type=str, metavar='THERMAL_NAME', + help="thermal name, ex: -t 'Temp sensor 1'") + threshold_parser.add_argument("-ht", dest='high_threshold', type=restricted_float, + metavar='THRESHOLD_VALUE', + help="high threshold: %.1f ~ %.1f" % (THRESHOLD_RANGE_LOW, THRESHOLD_RANGE_HIGH)) + threshold_parser.add_argument("-hct", dest='high_crit_threshold', type=restricted_float, + metavar='THRESHOLD_VALUE', + help="high critical threshold : %.1f ~ %.1f" % (THRESHOLD_RANGE_LOW, THRESHOLD_RANGE_HIGH)) + args = util_parser.parse_args() - if len(sys.argv)<2: - show_help() - - options, args = getopt.getopt(sys.argv[1:], 'hdf', ['help', - 'debug', - 'force', - ]) if DEBUG == True: - print(options) print(args) print((len(sys.argv))) - for opt, arg in options: - if opt in ('-h', '--help'): - show_help() - elif opt in ('-d', '--debug'): - DEBUG = True - logging.basicConfig(level=logging.INFO) - elif opt in ('-f', '--force'): - FORCE = 1 - else: - logging.info('no option') - for arg in args: - if arg == 'install': - do_install() - elif arg == 'clean': - do_uninstall() - else: - show_help() + DEBUG = args.debug + if DEBUG: + logging.basicConfig(level=logging.INFO) + FORCE = 1 if args.force else 0 + if args.cmd == 'install': + do_install() + elif args.cmd == 'clean': + do_uninstall() + elif args.cmd == 'threshold': + do_threshold() return 0 @@ -365,5 +377,162 @@ def device_exist(): ret2, log = log_os_system("ls "+i2c_prefix+"i2c-2", 0) return not(ret1 or ret2) +THRESHOLD_RANGE_LOW = 30.0 +THRESHOLD_RANGE_HIGH = 110.0 +# Code to initialize chassis object +init_chassis_code = \ + "import sonic_platform.platform\n"\ + "platform = sonic_platform.platform.Platform()\n"\ + "chassis = platform.get_chassis()\n\n" + +# Looking for thermal +looking_for_thermal_code = \ + "thermal = None\n"\ + "all_thermals = chassis.get_all_thermals()\n"\ + "for psu in chassis.get_all_psus():\n"\ + " all_thermals += psu.get_all_thermals()\n"\ + "for tmp in all_thermals:\n"\ + " if '{}' == tmp.get_name():\n"\ + " thermal = tmp\n"\ + " break\n"\ + "if thermal == None:\n"\ + " print('{} not found!')\n"\ + " exit(1)\n\n" + +def avaliable_thermals(): + global init_chassis_code + + get_all_thermal_name_code = \ + "thermal_list = []\n"\ + "all_thermals = chassis.get_all_thermals()\n"\ + "for psu in chassis.get_all_psus():\n"\ + " all_thermals += psu.get_all_thermals()\n"\ + "for tmp in all_thermals:\n"\ + " thermal_list.append(tmp.get_name())\n"\ + "print(str(thermal_list)[1:-1])\n" + + all_code = "{}{}".format(init_chassis_code, get_all_thermal_name_code) + + status, output = getstatusoutput_noshell(["docker", "exec", "pmon", "python3", "-c", all_code]) + if status != 0: + return "" + return output + +def restricted_float(x): + global THRESHOLD_RANGE_LOW, THRESHOLD_RANGE_HIGH + + try: + x = float(x) + except ValueError: + raise argparse.ArgumentTypeError("%r not a floating-point literal" % (x,)) + + if x < THRESHOLD_RANGE_LOW or x > THRESHOLD_RANGE_HIGH: + raise argparse.ArgumentTypeError("%r not in range [%.1f ~ %.1f]" % + (x, THRESHOLD_RANGE_LOW, THRESHOLD_RANGE_HIGH)) + + return x + +def get_high_threshold(name): + global init_chassis_code, looking_for_thermal_code + + get_high_threshold_code = \ + "try:\n"\ + " print(thermal.get_high_threshold())\n"\ + " exit(0)\n"\ + "except NotImplementedError:\n"\ + " print('Not implement the get_high_threshold method!')\n"\ + " exit(1)" + + all_code = "{}{}{}".format(init_chassis_code, looking_for_thermal_code.format(name, name), + get_high_threshold_code) + + status, output = getstatusoutput_noshell(["docker", "exec", "pmon", "python3", "-c", all_code]) + if status == 1: + return None + + return float(output) + +def get_high_crit_threshold(name): + global init_chassis_code, looking_for_thermal_code + + get_high_crit_threshold_code = \ + "try:\n"\ + " print(thermal.get_high_critical_threshold())\n"\ + " exit(0)\n"\ + "except NotImplementedError:\n"\ + " print('Not implement the get_high_critical_threshold method!')\n"\ + " exit(1)" + + all_code = "{}{}{}".format(init_chassis_code, looking_for_thermal_code.format(name, name), + get_high_crit_threshold_code) + + status, output = getstatusoutput_noshell(["docker", "exec", "pmon", "python3", "-c", all_code]) + if status == 1: + return None + + return float(output) + +def do_threshold(): + global args, init_chassis_code, looking_for_thermal_code + + if args.list: + print("Thermals: " + avaliable_thermals()) + return + + if args.thermal is None: + print("The following arguments are required: -t") + return + + set_threshold_code = "" + if args.high_threshold is not None: + if args.high_crit_threshold is not None and \ + args.high_threshold >= args.high_crit_threshold: + print("Invalid Threshold!(High threshold can not be more than " \ + "or equal to high critical threshold.)") + exit(1) + + high_crit = get_high_crit_threshold(args.thermal) + if high_crit is not None and \ + args.high_threshold >= high_crit: + print("Invalid Threshold!(High threshold can not be more than " \ + "or equal to high critical threshold.)") + exit(1) + + set_threshold_code += \ + "try:\n"\ + " if thermal.set_high_threshold({}) is False:\n"\ + " print('{}: set_high_threshold failure!')\n"\ + " exit(1)\n"\ + "except NotImplementedError:\n"\ + " print('Not implement the set_high_threshold method!')\n"\ + "print('Apply the new high threshold successfully.')\n"\ + "\n".format(args.high_threshold, args.thermal) + + if args.high_crit_threshold is not None: + high = get_high_threshold(args.thermal) + if high is not None and \ + args.high_crit_threshold <= high: + print("Invalid Threshold!(High critical threshold can not " \ + "be less than or equal to high threshold.)") + exit(1) + + set_threshold_code += \ + "try:\n"\ + " if thermal.set_high_critical_threshold({}) is False:\n"\ + " print('{}: set_high_critical_threshold failure!')\n"\ + " exit(1)\n"\ + "except NotImplementedError:\n"\ + " print('Not implement the set_high_critical_threshold method!')\n"\ + "print('Apply the new high critical threshold successfully.')\n"\ + "\n".format(args.high_crit_threshold, args.thermal) + + if set_threshold_code == "": + return + + all_code = "{}{}{}".format(init_chassis_code, looking_for_thermal_code.format(args.thermal, args.thermal), set_threshold_code) + + status, output = getstatusoutput_noshell(["docker", "exec", "pmon", "python3", "-c", all_code]) + print(output) + if __name__ == "__main__": main() diff --git a/platform/broadcom/sonic-platform-modules-accton/common/modules/ym2651y.c b/platform/broadcom/sonic-platform-modules-accton/common/modules/ym2651y.c index 20cef5d61a..66e7ad1186 100755 --- a/platform/broadcom/sonic-platform-modules-accton/common/modules/ym2651y.c +++ b/platform/broadcom/sonic-platform-modules-accton/common/modules/ym2651y.c @@ -43,7 +43,9 @@ enum chips { YM2401, YM2851, YM1401A, - YPEB1200AM + YPEB1200AM, + UMEC_UPD150SA, + UMEC_UP1K21R }; /* Each client has this additional data @@ -62,7 +64,7 @@ struct ym2651y_data { u16 i_out; /* Register value */ u16 p_out; /* Register value */ u8 vout_mode; /* Register value */ - u16 temp; /* Register value */ + u16 temp_input[3]; /* Register value */ u16 fan_speed; /* Register value */ u16 fan_duty_cycle[2]; /* Register value */ u8 fan_dir[4]; /* Register value */ @@ -112,6 +114,8 @@ enum ym2651y_sysfs_attributes { PSU_P_OUT, PSU_P_OUT_UV, /*In Unit of microVolt, instead of mini.*/ PSU_TEMP1_INPUT, + PSU_TEMP2_INPUT, + PSU_TEMP3_INPUT, PSU_FAN1_SPEED, PSU_FAN1_DUTY_CYCLE, PSU_PMBUS_REVISION, @@ -141,6 +145,8 @@ static SENSOR_DEVICE_ATTR(psu_v_out, S_IRUGO, show_vout, NULL, PSU_V_OU static SENSOR_DEVICE_ATTR(psu_i_out, S_IRUGO, show_linear, NULL, PSU_I_OUT); static SENSOR_DEVICE_ATTR(psu_p_out, S_IRUGO, show_linear, NULL, PSU_P_OUT); static SENSOR_DEVICE_ATTR(psu_temp1_input, S_IRUGO, show_linear, NULL, PSU_TEMP1_INPUT); +static SENSOR_DEVICE_ATTR(psu_temp2_input, S_IRUGO, show_linear, NULL, PSU_TEMP2_INPUT); +static SENSOR_DEVICE_ATTR(psu_temp3_input, S_IRUGO, show_linear, NULL, PSU_TEMP3_INPUT); static SENSOR_DEVICE_ATTR(psu_fan1_speed_rpm, S_IRUGO, show_linear, NULL, PSU_FAN1_SPEED); static SENSOR_DEVICE_ATTR(psu_fan1_duty_cycle_percentage, S_IWUSR | S_IRUGO, show_linear, set_fan_duty_cycle, PSU_FAN1_DUTY_CYCLE); static SENSOR_DEVICE_ATTR(psu_fan_dir, S_IRUGO, show_ascii, NULL, PSU_FAN_DIRECTION); @@ -164,8 +170,12 @@ static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_vout, NULL, PSU_V_OUT); static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, show_linear, NULL, PSU_I_OUT); static SENSOR_DEVICE_ATTR(power2_input, S_IRUGO, show_linear, NULL, PSU_P_OUT_UV); static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_linear, NULL, PSU_TEMP1_INPUT); +static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_linear, NULL, PSU_TEMP2_INPUT); +static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_linear, NULL, PSU_TEMP3_INPUT); static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_linear, NULL, PSU_FAN1_SPEED); static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_word, NULL, PSU_TEMP_FAULT); +static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_word, NULL, PSU_TEMP_FAULT); +static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_word, NULL, PSU_TEMP_FAULT); static struct attribute *ym2651y_attributes[] = { &sensor_dev_attr_psu_power_on.dev_attr.attr, @@ -177,6 +187,8 @@ static struct attribute *ym2651y_attributes[] = { &sensor_dev_attr_psu_i_out.dev_attr.attr, &sensor_dev_attr_psu_p_out.dev_attr.attr, &sensor_dev_attr_psu_temp1_input.dev_attr.attr, + &sensor_dev_attr_psu_temp2_input.dev_attr.attr, + &sensor_dev_attr_psu_temp3_input.dev_attr.attr, &sensor_dev_attr_psu_fan1_speed_rpm.dev_attr.attr, &sensor_dev_attr_psu_fan1_duty_cycle_percentage.dev_attr.attr, &sensor_dev_attr_psu_fan_dir.dev_attr.attr, @@ -199,8 +211,12 @@ static struct attribute *ym2651y_attributes[] = { &sensor_dev_attr_in3_input.dev_attr.attr, &sensor_dev_attr_power2_input.dev_attr.attr, &sensor_dev_attr_temp1_input.dev_attr.attr, + &sensor_dev_attr_temp2_input.dev_attr.attr, + &sensor_dev_attr_temp3_input.dev_attr.attr, &sensor_dev_attr_fan1_input.dev_attr.attr, &sensor_dev_attr_temp1_fault.dev_attr.attr, + &sensor_dev_attr_temp2_fault.dev_attr.attr, + &sensor_dev_attr_temp3_fault.dev_attr.attr, NULL }; @@ -293,7 +309,9 @@ static ssize_t show_linear(struct device *dev, struct device_attribute *da, value = data->p_out; break; case PSU_TEMP1_INPUT: - value = data->temp; + case PSU_TEMP2_INPUT: + case PSU_TEMP3_INPUT: + value = data->temp_input[attr->index - PSU_TEMP1_INPUT]; break; case PSU_FAN1_SPEED: value = data->fan_speed; @@ -506,6 +524,8 @@ static const struct i2c_device_id ym2651y_id[] = { { "ym2851", YM2851 }, { "ym1401a",YM1401A}, { "ype1200am", YPEB1200AM }, + { "umec_upd150sa", UMEC_UPD150SA }, + { "umec_up1k21r", UMEC_UP1K21R }, {} }; MODULE_DEVICE_TABLE(i2c, ym2651y_id); @@ -586,7 +606,9 @@ static struct ym2651y_data *ym2651y_update_device(struct device *dev) {0x8b, &data->v_out}, {0x8c, &data->i_out}, {0x96, &data->p_out}, - {0x8d, &data->temp}, + {0x8d, &(data->temp_input[0])}, + {0x8e, &(data->temp_input[1])}, + {0x8f, &(data->temp_input[2])}, {0x3b, &(data->fan_duty_cycle[0])}, {0x3c, &(data->fan_duty_cycle[1])}, {0x90, &data->fan_speed}, @@ -620,10 +642,18 @@ static struct ym2651y_data *ym2651y_update_device(struct device *dev) /* Read word data */ for (i = 0; i < ARRAY_SIZE(regs_word); i++) { + /* To prevent hardware errors, + access to temp2_input and temp3_input should be skipped + if the chip ID is not in the following list. */ + if (regs_word[i].reg == 0x8e || regs_word[i].reg == 0x8f) { + if (data->chip != UMEC_UPD150SA && + data->chip != UMEC_UP1K21R) { + continue; + } + } status = ym2651y_read_word(client, regs_word[i].reg); - if (status < 0) - { + if (status < 0) { dev_dbg(&client->dev, "reg %d, err %d\n", regs_word[i].reg, status); *(regs_word[i].value) = 0; @@ -667,7 +697,7 @@ static struct ym2651y_data *ym2651y_update_device(struct device *dev) status = ym2651y_read_block(client, command, data->mfr_model, buf+1); if ((buf+1) >= (ARRAY_SIZE(data->mfr_model)-1)) - { + { data->mfr_model[ARRAY_SIZE(data->mfr_model)-1] = '\0'; } else diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/control b/platform/broadcom/sonic-platform-modules-accton/debian/control index 4410a2f077..1d9f3c85cf 100755 --- a/platform/broadcom/sonic-platform-modules-accton/debian/control +++ b/platform/broadcom/sonic-platform-modules-accton/debian/control @@ -84,3 +84,11 @@ Description: kernel modules for platform devices such as fan, led, sfp Package: sonic-platform-accton-as7315-27xb Architecture: amd64 Description: kernel modules for platform devices such as fan, led, sfp + +Package: sonic-platform-accton-as4625-54p +Architecture: amd64 +Description: kernel modules for platform devices such as fan, led, sfp + +Package: sonic-platform-accton-as4625-54t +Architecture: amd64 +Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/rules b/platform/broadcom/sonic-platform-modules-accton/debian/rules index 8cd7611bb6..c47aa3b3e6 100755 --- a/platform/broadcom/sonic-platform-modules-accton/debian/rules +++ b/platform/broadcom/sonic-platform-modules-accton/debian/rules @@ -22,6 +22,7 @@ MOD_SRC_DIR:= $(shell pwd) MODULE_DIRS := as7712-32x as5712-54x as7816-64x as7716-32x as7716-32xb as7312-54x MODULE_DIRS += as7326-56x as6712-32x as7726-32x as4630-54pe as4630-54te minipack as5812-54x MODULE_DIRS += as5835-54x as9716-32d as9726-32d as5835-54t as7312-54xs as7315-27xb as5812-54t +MODULE_DIRS += as4625-54p as4625-54t MODULE_DIR := modules UTILS_DIR := utils SERVICE_DIR := service diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as4625-54p.install b/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as4625-54p.install new file mode 100644 index 0000000000..77cc3234f2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as4625-54p.install @@ -0,0 +1 @@ +as4625-54p/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-accton_as4625_54p-r0 diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as4625-54t.install b/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as4625-54t.install new file mode 100644 index 0000000000..811c0f4cfb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as4625-54t.install @@ -0,0 +1 @@ +as4625-54t/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-accton_as4625_54t-r0 diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as5835-54x.install b/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as5835-54x.install index d108eb582c..a234273ab7 100644 --- a/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as5835-54x.install +++ b/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as5835-54x.install @@ -1,2 +1 @@ -as5835-54x/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-accton_as5835_54x-r0 - +as5835-54x/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-accton_as5835_54x-r0/pddf diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as5835-54x.postinst b/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as5835-54x.postinst new file mode 100644 index 0000000000..c478bcac28 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as5835-54x.postinst @@ -0,0 +1,9 @@ +# Special arrangement to make PDDF mode default +# Disable monitor, monitor-fan, monitor-psu (not enabling them would imply they will be disabled by default) +# Enable pddf-platform-monitor +depmod -a +depmod -a +systemctl enable pddf-platform-init.service +systemctl start pddf-platform-init.service +systemctl enable as5835-54x-pddf-platform-monitor.service +systemctl start as5835-54x-pddf-platform-monitor.service diff --git a/platform/pddf/i2c/debian/rules b/platform/pddf/i2c/debian/rules index edca93ee06..4ddbbdfd24 100755 --- a/platform/pddf/i2c/debian/rules +++ b/platform/pddf/i2c/debian/rules @@ -18,7 +18,7 @@ PACKAGE_PRE_NAME := sonic-platform-pddf KVERSION ?= $(shell uname -r) KERNEL_SRC := /lib/modules/$(KVERSION) MOD_SRC_DIR:= $(shell pwd) -MODULE_DIRS:= client cpld cpld/driver cpldmux cpldmux/driver fan fan/driver mux gpio led psu psu/driver sysstatus xcvr xcvr/driver +MODULE_DIRS:= client cpld cpld/driver cpldmux cpldmux/driver fpgai2c fpgai2c/driver fpgapci fpgapci/driver fpgapci/algos fan fan/driver mux gpio led psu psu/driver sysstatus xcvr xcvr/driver MODULE_DIR:= modules UTILS_DIR := utils SERVICE_DIR := service diff --git a/platform/pddf/i2c/modules/Makefile b/platform/pddf/i2c/modules/Makefile index ebfce193c2..a936ff9756 100644 --- a/platform/pddf/i2c/modules/Makefile +++ b/platform/pddf/i2c/modules/Makefile @@ -1 +1 @@ -obj-m := client/ cpld/ cpldmux/ xcvr/ mux/ gpio/ psu/ fan/ led/ sysstatus/ +obj-m := client/ cpld/ cpldmux/ fpgai2c/ fpgapci/ xcvr/ mux/ gpio/ psu/ fan/ led/ sysstatus/ diff --git a/platform/pddf/i2c/modules/fan/driver/pddf_fan_api.c b/platform/pddf/i2c/modules/fan/driver/pddf_fan_api.c index 0fecee963e..76b35a7e8a 100644 --- a/platform/pddf/i2c/modules/fan/driver/pddf_fan_api.c +++ b/platform/pddf/i2c/modules/fan/driver/pddf_fan_api.c @@ -330,6 +330,106 @@ int fan_cpld_client_read(FAN_DATA_ATTR *udata) return status; } +int fan_cpld_client_write(FAN_DATA_ATTR *udata, uint32_t val) +{ + int status = 0; + + if (udata->len==1) + { + status = board_i2c_cpld_write(udata->devaddr, udata->offset, val); + } + else + { + /* Get the I2C client for the CPLD */ + struct i2c_client *client_ptr=NULL; + client_ptr = (struct i2c_client *)get_device_table(udata->devname); + if (client_ptr) + { + if (udata->len==2) + { + uint8_t val_lsb = val & 0xFF; + uint8_t val_hsb = (val >> 8) & 0xFF; + /* TODO: Check this logic for LE and BE */ + status = i2c_smbus_write_byte_data(client_ptr, udata->offset, val_lsb); + if (status==0) status = i2c_smbus_write_byte_data(client_ptr, udata->offset+1, val_hsb); + } + else + printk(KERN_ERR "PDDF_FAN: Doesn't support block CPLD write yet"); + } + else + printk(KERN_ERR "Unable to get the client handle for %s\n", udata->devname); + } + + return status; +} + +int fan_fpgai2c_client_read(FAN_DATA_ATTR *udata) +{ + int status = -1; + + if (udata!=NULL) + { + if (udata->len==1) + { + status = board_i2c_fpga_read(udata->devaddr , udata->offset); + /*printk(KERN_ERR "### Reading offset 0x%x from 0x%x device ... val 0x%x\n", udata->offset, udata->devaddr, status);*/ + } + else + { + /* Get the I2C client for the FPGAI2C */ + struct i2c_client *client_ptr=NULL; + client_ptr = (struct i2c_client *)get_device_table(udata->devname); + if (client_ptr) + { + if (udata->len==2) + { + status = i2c_smbus_read_word_swapped(client_ptr, udata->offset); + } + else + printk(KERN_ERR "PDDF_FAN: Doesn't support block FPGAI2C read yet"); + } + else + printk(KERN_ERR "Unable to get the client handle for %s\n", udata->devname); + } + + } + + return status; +} + +int fan_fpgai2c_client_write(FAN_DATA_ATTR *udata, uint32_t val) +{ + int status = 0; + + if (udata->len==1) + { + status = board_i2c_fpga_write(udata->devaddr, udata->offset, val); + } + else + { + /* Get the I2C client for the FPGAI2C */ + struct i2c_client *client_ptr=NULL; + client_ptr = (struct i2c_client *)get_device_table(udata->devname); + if (client_ptr) + { + if (udata->len==2) + { + uint8_t val_lsb = val & 0xFF; + uint8_t val_hsb = (val >> 8) & 0xFF; + /* TODO: Check this logic for LE and BE */ + status = i2c_smbus_write_byte_data(client_ptr, udata->offset, val_lsb); + if (status==0) status = i2c_smbus_write_byte_data(client_ptr, udata->offset+1, val_hsb); + } + else + printk(KERN_ERR "PDDF_FAN: Doesn't support block FPGAI2C write yet"); + } + else + printk(KERN_ERR "Unable to get the client handle for %s\n", udata->devname); + } + + return status; +} + int sonic_i2c_get_fan_present_default(void *client, FAN_DATA_ATTR *udata, void *info) { @@ -341,6 +441,10 @@ int sonic_i2c_get_fan_present_default(void *client, FAN_DATA_ATTR *udata, void * { val = fan_cpld_client_read(udata); } + else if (strcmp(udata->devtype, "fpgai2c") == 0) + { + val = fan_fpgai2c_client_read(udata); + } else { val = i2c_smbus_read_byte_data((struct i2c_client *)client, udata->offset); @@ -365,6 +469,10 @@ int sonic_i2c_get_fan_rpm_default(void *client, FAN_DATA_ATTR *udata, void *info { val = fan_cpld_client_read(udata); } + else if (strcmp(udata->devtype, "fpgai2c") == 0) + { + val = fan_fpgai2c_client_read(udata); + } else { if (udata->len == 1) @@ -395,18 +503,26 @@ int sonic_i2c_get_fan_rpm_default(void *client, FAN_DATA_ATTR *udata, void *info int sonic_i2c_get_fan_direction_default(void *client, FAN_DATA_ATTR *udata, void *info) { int status = 0; - uint32_t val = 0; + int val = 0; struct fan_attr_info *painfo = (struct fan_attr_info *)info; if (strcmp(udata->devtype, "cpld") == 0) { val = fan_cpld_client_read(udata); } + else if (strcmp(udata->devtype, "fpgai2c") == 0) + { + val = fan_fpgai2c_client_read(udata); + } else { val = i2c_smbus_read_byte_data((struct i2c_client *)client, udata->offset); } - painfo->val.intval = ((val & udata->mask) == udata->cmpval); + + if (val < 0) + status = val; + else + painfo->val.intval = ((val & udata->mask) == udata->cmpval); return status; } @@ -415,7 +531,7 @@ int sonic_i2c_get_fan_direction_default(void *client, FAN_DATA_ATTR *udata, void int sonic_i2c_set_fan_pwm_default(struct i2c_client *client, FAN_DATA_ATTR *udata, void *info) { int status = 0; - uint32_t val = 0; + int val = 0; struct fan_attr_info *painfo = (struct fan_attr_info *)info; val = painfo->val.intval & udata->mask; @@ -427,52 +543,31 @@ int sonic_i2c_set_fan_pwm_default(struct i2c_client *client, FAN_DATA_ATTR *udat if (strcmp(udata->devtype, "cpld") == 0) { - if (udata->len==1) - { - status = board_i2c_cpld_write(udata->devaddr , udata->offset, val); - } - else - { - /* Get the I2C client for the CPLD */ - struct i2c_client *client_ptr=NULL; - client_ptr = (struct i2c_client *)get_device_table(udata->devname); - if (client_ptr) - { - if (udata->len==2) - { - uint8_t val_lsb = val & 0xFF; - uint8_t val_hsb = (val >> 8) & 0xFF; - /* TODO: Check this logic for LE and BE */ - i2c_smbus_write_byte_data(client, udata->offset, val_lsb); - i2c_smbus_write_byte_data(client, udata->offset+1, val_hsb); - } - else - printk(KERN_ERR "PDDF_FAN: Doesn't support block CPLD write yet"); - } - else - printk(KERN_ERR "Unable to get the client handle for %s\n", udata->devname); - } - + status = fan_cpld_client_write(udata, val); + } + else if (strcmp(udata->devtype, "fpgai2c") == 0) + { + status = fan_fpgai2c_client_write(udata, val); } else { if (udata->len == 1) - i2c_smbus_write_byte_data(client, udata->offset, val); + status = i2c_smbus_write_byte_data(client, udata->offset, val); else if (udata->len == 2) { uint8_t val_lsb = val & 0xFF; uint8_t val_hsb = (val >> 8) & 0xFF; /* TODO: Check this logic for LE and BE */ - i2c_smbus_write_byte_data(client, udata->offset, val_lsb); - i2c_smbus_write_byte_data(client, udata->offset+1, val_hsb); + status = i2c_smbus_write_byte_data(client, udata->offset, val_lsb); + if (status == 0) status = i2c_smbus_write_byte_data(client, udata->offset+1, val_hsb); } else { printk(KERN_DEBUG "%s: pwm should be of len 1/2 bytes. Not setting the pwm as the length is %d\n", __FUNCTION__, udata->len); } } - - return status; + + return status; } @@ -486,6 +581,10 @@ int sonic_i2c_get_fan_pwm_default(void *client, FAN_DATA_ATTR *udata, void *info { val = fan_cpld_client_read(udata); } + else if (strcmp(udata->devtype, "fpgai2c") == 0) + { + val = fan_fpgai2c_client_read(udata); + } else { if (udata->len == 1) @@ -520,6 +619,10 @@ int sonic_i2c_get_fan_fault_default(void *client, FAN_DATA_ATTR *udata, void *in { val = fan_cpld_client_read(udata); } + else if (strcmp(udata->devtype, "fpgai2c") == 0) + { + val = fan_fpgai2c_client_read(udata); + } else { val = i2c_smbus_read_byte_data((struct i2c_client *)client, udata->offset); diff --git a/platform/pddf/i2c/modules/fpgai2c/Makefile b/platform/pddf/i2c/modules/fpgai2c/Makefile new file mode 100644 index 0000000000..2fe22efb7c --- /dev/null +++ b/platform/pddf/i2c/modules/fpgai2c/Makefile @@ -0,0 +1,4 @@ +obj-m := driver/ +obj-m += pddf_fpgai2c_module.o + +ccflags-y:= -I$(M)/modules/include diff --git a/platform/pddf/i2c/modules/fpgai2c/driver/Makefile b/platform/pddf/i2c/modules/fpgai2c/driver/Makefile new file mode 100644 index 0000000000..409bf0aa47 --- /dev/null +++ b/platform/pddf/i2c/modules/fpgai2c/driver/Makefile @@ -0,0 +1,5 @@ +TARGET = pddf_fpgai2c_driver + +obj-m := $(TARGET).o + +ccflags-y := -I$(M)/modules/include diff --git a/platform/pddf/i2c/modules/fpgai2c/driver/pddf_fpgai2c_driver.c b/platform/pddf/i2c/modules/fpgai2c/driver/pddf_fpgai2c_driver.c new file mode 100644 index 0000000000..b3092e5ee8 --- /dev/null +++ b/platform/pddf/i2c/modules/fpgai2c/driver/pddf_fpgai2c_driver.c @@ -0,0 +1,228 @@ +/* + * + * 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. + * + * Description: + * A pddf kernel driver module for FPGA connected to the CPU by I2C bus + */ + +#include +#include +#include +#include +#include +#include "pddf_fpgai2c_defs.h" + +extern PDDF_FPGAI2C_DATA pddf_fpgai2c_data; + + +static LIST_HEAD(fpgai2c_client_list); +static struct mutex list_lock; + +struct fpgai2c_client_node { + struct i2c_client *client; + struct list_head list; +}; + +int board_i2c_fpga_read(unsigned short fpga_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct fpgai2c_client_node *fpga_node = NULL; + int ret = -EPERM; + + + mutex_lock(&list_lock); + + list_for_each(list_node, &fpgai2c_client_list) + { + fpga_node = list_entry(list_node, struct fpgai2c_client_node, list); + + if (fpga_node->client->addr == fpga_addr) { + ret = i2c_smbus_read_byte_data(fpga_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(board_i2c_fpga_read); + +int board_i2c_fpga_write(unsigned short fpga_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct fpgai2c_client_node *fpga_node = NULL; + int ret = -EIO; + + + mutex_lock(&list_lock); + + list_for_each(list_node, &fpgai2c_client_list) + { + fpga_node = list_entry(list_node, struct fpgai2c_client_node, list); + + if (fpga_node->client->addr == fpga_addr) { + ret = i2c_smbus_write_byte_data(fpga_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(board_i2c_fpga_write); + +ssize_t regval_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + int len = 0; + struct i2c_client *client = to_i2c_client(dev); + + mutex_lock(&pddf_fpgai2c_data.fpga_lock); + // Put code here to read the register value and print it + if (pddf_fpgai2c_data.reg_addr!=0) + len = sprintf(buf, "0x%2.2x\n", board_i2c_fpga_read(client->addr, pddf_fpgai2c_data.reg_addr)); + else + len = sprintf(buf, "xx\n"); + + mutex_unlock(&pddf_fpgai2c_data.fpga_lock); + return len; +} + +static DEVICE_ATTR_RO(regval); + +static struct attribute *fpgai2c_attrs[] = { + &dev_attr_regval.attr, + NULL, +}; + +static struct attribute_group fpgai2c_attribute_group = { + .attrs = fpgai2c_attrs, +}; + + + + +/* Addresses scanned for board_i2c_fpga + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +static void board_i2c_fpga_add_client(struct i2c_client *client) +{ + struct fpgai2c_client_node *node = kzalloc(sizeof(struct fpgai2c_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate fpgai2c_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &fpgai2c_client_list); + mutex_unlock(&list_lock); +} + +static void board_i2c_fpga_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct fpgai2c_client_node *fpga_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &fpgai2c_client_list) + { + fpga_node = list_entry(list_node, struct fpgai2c_client_node, list); + + if (fpga_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(fpga_node); + } + + mutex_unlock(&list_lock); +} + +static int board_i2c_fpga_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + dev_dbg(&client->dev, "i2c_check_functionality failed (0x%x)\n", client->addr); + status = -EIO; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &fpgai2c_attribute_group); + if (status) { + goto exit; + } + + dev_dbg(&client->dev, "chip found\n"); + board_i2c_fpga_add_client(client); + + return 0; + +exit: + return status; +} + +static int board_i2c_fpga_remove(struct i2c_client *client) +{ + sysfs_remove_group(&client->dev.kobj, &fpgai2c_attribute_group); + board_i2c_fpga_remove_client(client); + + return 0; +} + +static const struct i2c_device_id board_i2c_fpga_id[] = { + { "i2c_fpga", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, board_i2c_fpga_id); + +static struct i2c_driver board_i2c_fpga_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "i2c_fpga", + }, + .probe = board_i2c_fpga_probe, + .remove = board_i2c_fpga_remove, + .id_table = board_i2c_fpga_id, + .address_list = normal_i2c, +}; + +static int __init board_i2c_fpga_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&board_i2c_fpga_driver); +} + +static void __exit board_i2c_fpga_exit(void) +{ + i2c_del_driver(&board_i2c_fpga_driver); +} + +MODULE_AUTHOR("Broadcom"); +MODULE_DESCRIPTION("board_i2c_fpga driver"); +MODULE_LICENSE("GPL"); + +module_init(board_i2c_fpga_init); +module_exit(board_i2c_fpga_exit); diff --git a/platform/pddf/i2c/modules/fpgai2c/pddf_fpgai2c_module.c b/platform/pddf/i2c/modules/fpgai2c/pddf_fpgai2c_module.c new file mode 100644 index 0000000000..303f209dca --- /dev/null +++ b/platform/pddf/i2c/modules/fpgai2c/pddf_fpgai2c_module.c @@ -0,0 +1,220 @@ +/* + * + * 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. + * + * Description: + * A pddf kernel module to create I2C client for an I2CFPGA + */ + +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "pddf_client_defs.h" +#include "pddf_fpgai2c_defs.h" + +PDDF_FPGAI2C_DATA pddf_fpgai2c_data={0}; +EXPORT_SYMBOL(pddf_fpgai2c_data); + +static ssize_t do_device_operation(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +static ssize_t store_pddf_fpgai2c_data(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +static ssize_t show_pddf_fpgai2c_data(struct device *dev, struct device_attribute *da, char *buf); + +extern void *get_device_table(char *name); +extern void delete_device_table(char *name); + + +/* MUX CLIENT DATA */ +PDDF_DATA_ATTR(dev_ops, S_IWUSR, NULL, do_device_operation, PDDF_CHAR, 8, NULL, (void*)&pddf_data); +PDDF_DATA_ATTR(reg_addr, S_IWUSR|S_IRUGO, show_pddf_fpgai2c_data, store_pddf_fpgai2c_data, PDDF_USHORT, sizeof(unsigned short), (void*)&pddf_fpgai2c_data.reg_addr, NULL); + + + +static struct attribute *fpgai2c_attributes[] = { + &attr_dev_ops.dev_attr.attr, + &attr_reg_addr.dev_attr.attr, + NULL +}; + +static const struct attribute_group pddf_fpgai2c_client_data_group = { + .attrs = fpgai2c_attributes, +}; + + +static ssize_t store_pddf_fpgai2c_data(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int ret = 0; + int num = 0; + PDDF_ATTR *ptr = (PDDF_ATTR *)da; + + ret = kstrtoint(buf,16,&num); + if (ret==0) + { + mutex_lock(&pddf_fpgai2c_data.fpga_lock); + *(unsigned short *)(ptr->addr) = (unsigned short)num; + mutex_unlock(&pddf_fpgai2c_data.fpga_lock); + pddf_dbg(FPGAI2C, KERN_ERR "Stored value: 0x%x, num: 0x%x\n", *(int*)(ptr->addr), num); + } + + return count; +} + +ssize_t show_pddf_fpgai2c_data(struct device *dev, struct device_attribute *da, char *buf) +{ + int ret = 0; + PDDF_ATTR *ptr = (PDDF_ATTR *)da; + pddf_dbg(FPGAI2C, KERN_ERR "[ READ ] DATA ATTR PTR TYPE:%d, ADDR=%p\n", ptr->type, ptr->addr); + + mutex_lock(&pddf_fpgai2c_data.fpga_lock); + ret = sprintf(buf, "0x%x\n", *(unsigned short *)(ptr->addr)); + mutex_unlock(&pddf_fpgai2c_data.fpga_lock); + + return ret; +} + +static ssize_t do_device_operation(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + PDDF_ATTR *ptr = (PDDF_ATTR *)da; + NEW_DEV_ATTR *device_ptr = (NEW_DEV_ATTR *)(ptr->data); + struct i2c_adapter *adapter; + static struct i2c_board_info board_info; + struct i2c_client *client_ptr; + + if (strncmp(buf, "add", strlen(buf)-1)==0) + { + adapter = i2c_get_adapter(device_ptr->parent_bus); + + if (strncmp(device_ptr->dev_type, "i2c_fpga", strlen("i2c_fpga"))==0) + { + board_info = (struct i2c_board_info) { + .platform_data = (void *)NULL, + }; + + board_info.addr = device_ptr->dev_addr; + strcpy(board_info.type, device_ptr->dev_type); + + client_ptr = i2c_new_client_device(adapter, &board_info); + + if (!IS_ERR(client_ptr)) { + i2c_put_adapter(adapter); + pddf_dbg(FPGAI2C, KERN_ERR "Created %s client: 0x%p\n", device_ptr->i2c_name, (void *)client_ptr); + add_device_table(device_ptr->i2c_name, (void*)client_ptr); + } + else { + i2c_put_adapter(adapter); + goto free_data; + } + + } + else + { + printk(KERN_ERR "%s: Unsupported type of fpga device id - unable to add i2c client\n", __FUNCTION__); + } + } + else if (strncmp(buf, "delete", strlen(buf)-1)==0) + { + /*Get the i2c_client handle for the created client*/ + client_ptr = (struct i2c_client *)get_device_table(device_ptr->i2c_name); + if (client_ptr) + { + pddf_dbg(FPGAI2C, KERN_ERR "Removing %s client: 0x%p\n", device_ptr->i2c_name, (void *)client_ptr); + i2c_unregister_device(client_ptr); + delete_device_table(device_ptr->i2c_name); + } + else + { + printk(KERN_ERR "Unable to get the client handle for %s\n", device_ptr->i2c_name); + } + } + else + { + printk(KERN_ERR "PDDF_ERROR: %s: Invalid value for dev_ops %s", __FUNCTION__, buf); + } + +free_data: + /*TODO: free the device_ptr->data is dynamically allocated*/ +#ifdef __STDC_LIB_EXT1__ + memset_s(device_ptr, sizeof(NEW_DEV_ATTR), 0 , sizeof(NEW_DEV_ATTR)); +#else + memset(device_ptr, 0 , sizeof(NEW_DEV_ATTR)); +#endif + + return count; +} + + +static struct kobject *fpgai2c_kobj; + +int __init fpgai2c_data_init(void) +{ + struct kobject *device_kobj; + int ret = 0; + + + pddf_dbg(FPGAI2C, "FPGAI2C_DATA MODULE.. init\n"); + + device_kobj = get_device_i2c_kobj(); + if(!device_kobj) + return -ENOMEM; + + fpgai2c_kobj = kobject_create_and_add("fpgai2c", device_kobj); + if(!fpgai2c_kobj) + return -ENOMEM; + + + ret = sysfs_create_group(fpgai2c_kobj, &pddf_clients_data_group); + if (ret) + { + kobject_put(fpgai2c_kobj); + return ret; + } + pddf_dbg(FPGAI2C, "CREATED PDDF I2C CLIENTS CREATION SYSFS GROUP\n"); + + mutex_init(&pddf_fpgai2c_data.fpga_lock); + + ret = sysfs_create_group(fpgai2c_kobj, &pddf_fpgai2c_client_data_group); + if (ret) + { + sysfs_remove_group(fpgai2c_kobj, &pddf_clients_data_group); + kobject_put(fpgai2c_kobj); + return ret; + } + pddf_dbg(FPGAI2C, "CREATED PDDF I2C CLIENTS CREATION SYSFS GROUP\n"); + return ret; +} + +void __exit fpgai2c_data_exit(void) +{ + pddf_dbg(FPGAI2C, "FPGAI2C_DATA MODULE.. exit\n"); + sysfs_remove_group(fpgai2c_kobj, &pddf_fpgai2c_client_data_group); + sysfs_remove_group(fpgai2c_kobj, &pddf_clients_data_group); + kobject_put(fpgai2c_kobj); + pddf_dbg(FPGAI2C, KERN_ERR "%s: Removed the kobjects for 'fpgai2c'\n",__FUNCTION__); + return; +} + +module_init(fpgai2c_data_init); +module_exit(fpgai2c_data_exit); + +MODULE_AUTHOR("Broadcom"); +MODULE_DESCRIPTION("fpgai2c platform data"); +MODULE_LICENSE("GPL"); diff --git a/platform/pddf/i2c/modules/fpgapci/Makefile b/platform/pddf/i2c/modules/fpgapci/Makefile new file mode 100644 index 0000000000..12b9830cef --- /dev/null +++ b/platform/pddf/i2c/modules/fpgapci/Makefile @@ -0,0 +1,4 @@ +obj-m := driver/ algos/ +obj-m += pddf_fpgapci_module.o + +ccflags-y:= -I$(M)/modules/include diff --git a/platform/pddf/i2c/modules/fpgapci/algos/Makefile b/platform/pddf/i2c/modules/fpgapci/algos/Makefile new file mode 100644 index 0000000000..91d6954711 --- /dev/null +++ b/platform/pddf/i2c/modules/fpgapci/algos/Makefile @@ -0,0 +1,4 @@ +# Sample driver for Xilinx 7021 FPGA device +obj-m += pddf_xilinx_device_7021_algo.o + +ccflags-y := -I$(M)/modules/include diff --git a/platform/pddf/i2c/modules/fpgapci/algos/pddf_xilinx_device_7021_algo.c b/platform/pddf/i2c/modules/fpgapci/algos/pddf_xilinx_device_7021_algo.c new file mode 100644 index 0000000000..dc2f52bf16 --- /dev/null +++ b/platform/pddf/i2c/modules/fpgapci/algos/pddf_xilinx_device_7021_algo.c @@ -0,0 +1,417 @@ +/* +* +* Licensed under the GNU General Public License Version 2 +* +* 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. +* +*/ + +/* +* pddf_xilinx_device_7021_algo.c +* Description: +* A sample i2c driver algorithms for Xilinx Corporation Device 7021 FPGA adapters +* +*********************************************************************************/ +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include "pddf_i2c_algo.h" + +#define DEBUG 0 + +enum { + STATE_DONE = 0, + STATE_INIT, + STATE_ADDR, + STATE_ADDR10, + STATE_START, + STATE_WRITE, + STATE_READ, + STATE_STOP, + STATE_ERROR, +}; + +/* registers */ +#define FPGAI2C_REG_PRELOW 0 +#define FPGAI2C_REG_PREHIGH 1 +#define FPGAI2C_REG_CONTROL 2 +#define FPGAI2C_REG_DATA 3 +#define FPGAI2C_REG_CMD 4 /* write only */ +#define FPGAI2C_REG_STATUS 4 /* read only, same address as FPGAI2C_REG_CMD */ +#define FPGAI2C_REG_VER 5 + +#define FPGAI2C_REG_CTRL_IEN 0x40 +#define FPGAI2C_REG_CTRL_EN 0x80 + +#define FPGAI2C_REG_CMD_START 0x91 +#define FPGAI2C_REG_CMD_STOP 0x41 +#define FPGAI2C_REG_CMD_READ 0x21 +#define FPGAI2C_REG_CMD_WRITE 0x11 +#define FPGAI2C_REG_CMD_READ_ACK 0x21 +#define FPGAI2C_REG_CMD_READ_NACK 0x29 +#define FPGAI2C_REG_CMD_IACK 0x01 + +#define FPGAI2C_REG_STAT_IF 0x01 +#define FPGAI2C_REG_STAT_TIP 0x02 +#define FPGAI2C_REG_STAT_ARBLOST 0x20 +#define FPGAI2C_REG_STAT_BUSY 0x40 +#define FPGAI2C_REG_STAT_NACK 0x80 + +struct fpgalogic_i2c { + void __iomem *base; + u32 reg_shift; + u32 reg_io_width; + wait_queue_head_t wait; + struct i2c_msg *msg; + int pos; + int nmsgs; + int state; /* see STATE_ */ + int ip_clock_khz; + int bus_clock_khz; + void (*reg_set)(struct fpgalogic_i2c *i2c, int reg, u8 value); + u8 (*reg_get)(struct fpgalogic_i2c *i2c, int reg); + u32 timeout; + struct mutex lock; +}; +static struct fpgalogic_i2c fpgalogic_i2c[I2C_PCI_MAX_BUS]; +extern void __iomem * fpga_ctl_addr; +extern int (*ptr_fpgapci_read)(uint32_t); +extern int (*ptr_fpgapci_write)(uint32_t, uint32_t); +extern int (*pddf_i2c_pci_add_numbered_bus)(struct i2c_adapter *, int); + +void i2c_get_mutex(struct fpgalogic_i2c *i2c) +{ + mutex_lock(&i2c->lock); +} + +/** + * i2c_release_mutex - release mutex + */ +void i2c_release_mutex(struct fpgalogic_i2c *i2c) +{ + mutex_unlock(&i2c->lock); +} + +static void fpgai2c_reg_set_8(struct fpgalogic_i2c *i2c, int reg, u8 value) +{ + iowrite8(value, i2c->base + (reg << i2c->reg_shift)); +} + +static inline u8 fpgai2c_reg_get_8(struct fpgalogic_i2c *i2c, int reg) +{ + return ioread8(i2c->base + (reg << i2c->reg_shift)); +} + +static inline void fpgai2c_reg_set(struct fpgalogic_i2c *i2c, int reg, u8 value) +{ + i2c->reg_set(i2c, reg, value); + udelay(100); +} + +static inline u8 fpgai2c_reg_get(struct fpgalogic_i2c *i2c, int reg) +{ + udelay(100); + return i2c->reg_get(i2c, reg); +} + + +/* + * i2c_get_mutex must be called prior to calling this function. + */ +static int fpgai2c_poll(struct fpgalogic_i2c *i2c) +{ + u8 stat = fpgai2c_reg_get(i2c, FPGAI2C_REG_STATUS); + struct i2c_msg *msg = i2c->msg; + u8 addr; + + /* Ready? */ + if (stat & FPGAI2C_REG_STAT_TIP) + return -EBUSY; + + if (i2c->state == STATE_DONE || i2c->state == STATE_ERROR) { + /* Stop has been sent */ + fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, FPGAI2C_REG_CMD_IACK); + if (i2c->state == STATE_ERROR) + return -EIO; + return 0; + } + + /* Error? */ + if (stat & FPGAI2C_REG_STAT_ARBLOST) { + i2c->state = STATE_ERROR; + fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, FPGAI2C_REG_CMD_STOP); + return -EAGAIN; + } + + if (i2c->state == STATE_INIT) { + if (stat & FPGAI2C_REG_STAT_BUSY) + return -EBUSY; + + i2c->state = STATE_ADDR; + } + + if (i2c->state == STATE_ADDR) { + /* 10 bit address? */ + if (i2c->msg->flags & I2C_M_TEN) { + addr = 0xf0 | ((i2c->msg->addr >> 7) & 0x6); + i2c->state = STATE_ADDR10; + } else { + addr = (i2c->msg->addr << 1); + i2c->state = STATE_START; + } + + /* Set read bit if necessary */ + addr |= (i2c->msg->flags & I2C_M_RD) ? 1 : 0; + + fpgai2c_reg_set(i2c, FPGAI2C_REG_DATA, addr); + fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, FPGAI2C_REG_CMD_START); + + return 0; + } + + /* Second part of 10 bit addressing */ + if (i2c->state == STATE_ADDR10) { + fpgai2c_reg_set(i2c, FPGAI2C_REG_DATA, i2c->msg->addr & 0xff); + fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, FPGAI2C_REG_CMD_WRITE); + + i2c->state = STATE_START; + return 0; + } + + if (i2c->state == STATE_START || i2c->state == STATE_WRITE) { + i2c->state = (msg->flags & I2C_M_RD) ? STATE_READ : STATE_WRITE; + + if (stat & FPGAI2C_REG_STAT_NACK) { + i2c->state = STATE_ERROR; + fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, FPGAI2C_REG_CMD_STOP); + return -ENXIO; + } + } else { + msg->buf[i2c->pos++] = fpgai2c_reg_get(i2c, FPGAI2C_REG_DATA); + } + if (i2c->pos >= msg->len) { + i2c->nmsgs--; + i2c->msg++; + i2c->pos = 0; + msg = i2c->msg; + + if (i2c->nmsgs) { + if (!(msg->flags & I2C_M_NOSTART)) { + i2c->state = STATE_ADDR; + return 0; + } else { + i2c->state = (msg->flags & I2C_M_RD) + ? STATE_READ : STATE_WRITE; + } + } else { + i2c->state = STATE_DONE; + fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, FPGAI2C_REG_CMD_STOP); + return 0; + } + } + + if (i2c->state == STATE_READ) { + fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, i2c->pos == (msg->len - 1) ? + FPGAI2C_REG_CMD_READ_NACK : FPGAI2C_REG_CMD_READ_ACK); + } else { + fpgai2c_reg_set(i2c, FPGAI2C_REG_DATA, msg->buf[i2c->pos++]); + fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, FPGAI2C_REG_CMD_WRITE); + } + + return 0; +} + +static int fpgai2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) +{ + struct fpgalogic_i2c *i2c = i2c_get_adapdata(adap); + int ret; + unsigned long timeout = jiffies + msecs_to_jiffies(1000); + + i2c->msg = msgs; + i2c->pos = 0; + i2c->nmsgs = num; + i2c->state = STATE_INIT; + + /* Handle the transfer */ + while (time_before(jiffies, timeout)) { + i2c_get_mutex(i2c); + ret = fpgai2c_poll(i2c); + i2c_release_mutex(i2c); + + if (i2c->state == STATE_DONE || i2c->state == STATE_ERROR) + return (i2c->state == STATE_DONE) ? num : ret; + + if (ret == 0) + timeout = jiffies + HZ; + + usleep_range(5, 15); + } + printk("[%s] ERROR STATE_ERROR\n", __FUNCTION__); + + i2c->state = STATE_ERROR; + + return -ETIMEDOUT; + +} + +static u32 fpgai2c_func(struct i2c_adapter *adap) +{ +/* a typical full-I2C adapter would use the following */ + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; +} + +static const struct i2c_algorithm fpgai2c_algorithm= { + .master_xfer = fpgai2c_xfer, /*write I2C messages */ + .functionality = fpgai2c_func, /* what the adapter supports */ +}; + +static int fpgai2c_init(struct fpgalogic_i2c *i2c) +{ + int prescale; + int diff; + u8 ctrl; + + i2c->reg_set = fpgai2c_reg_set_8; + i2c->reg_get = fpgai2c_reg_get_8; + + ctrl = fpgai2c_reg_get(i2c, FPGAI2C_REG_CONTROL); + /* make sure the device is disabled */ + fpgai2c_reg_set(i2c, FPGAI2C_REG_CONTROL, ctrl & ~(FPGAI2C_REG_CTRL_EN|FPGAI2C_REG_CTRL_IEN)); + + /* + * I2C Frequency depends on host clock + * input clock of 100MHz + * prescale to 100MHz / ( 5*100kHz) -1 = 199 = 0x4F 100000/(5*100)-1=199=0xc7 + */ + prescale = (i2c->ip_clock_khz / (5 * i2c->bus_clock_khz)) - 1; + prescale = clamp(prescale, 0, 0xffff); + + diff = i2c->ip_clock_khz / (5 * (prescale + 1)) - i2c->bus_clock_khz; + if (abs(diff) > i2c->bus_clock_khz / 10) { + printk("[%s] ERROR Unsupported clock settings: core: %d KHz, bus: %d KHz\n", + __FUNCTION__, i2c->ip_clock_khz, i2c->bus_clock_khz); + return -EINVAL; + } + + fpgai2c_reg_set(i2c, FPGAI2C_REG_PRELOW, prescale & 0xff); + fpgai2c_reg_set(i2c, FPGAI2C_REG_PREHIGH, prescale >> 8); + + /* Init the device */ + fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, FPGAI2C_REG_CMD_IACK); + fpgai2c_reg_set(i2c, FPGAI2C_REG_CONTROL, ctrl | FPGAI2C_REG_CTRL_EN); + + /* Initialize interrupt handlers if not already done */ + init_waitqueue_head(&i2c->wait); + return 0; +} + +static int adap_data_init(struct i2c_adapter *adap, int i2c_ch_index) +{ + struct fpgapci_devdata *pci_privdata = 0; + pci_privdata = (struct fpgapci_devdata*) dev_get_drvdata(adap->dev.parent); + + if (pci_privdata == 0) { + printk("[%s]: ERROR pci_privdata is 0\n", __FUNCTION__); + return -1; + } +#if DEBUG + pddf_dbg(FPGA, KERN_INFO "[%s] index: [%d] fpga_data__base_addr:0x%0x8lx" + " fpgapci_bar_len:0x%08lx fpga_i2c_ch_base_addr:0x%08lx ch_size=0x%x supported_i2c_ch=%d", + __FUNCTION__, i2c_ch_index, pci_privdata->fpga_data_base_addr, + pci_privdata->bar_length, pci_privdata->fpga_i2c_ch_base_addr, + pci_privdata->fpga_i2c_ch_size, pci_privdata->max_fpga_i2c_ch); +#endif + if (i2c_ch_index >= pci_privdata->max_fpga_i2c_ch || pci_privdata->max_fpga_i2c_ch > I2C_PCI_MAX_BUS) { + printk("[%s]: ERROR i2c_ch_index=%d max_ch_index=%d out of range: %d\n", + __FUNCTION__, i2c_ch_index, pci_privdata->max_fpga_i2c_ch, I2C_PCI_MAX_BUS); + return -1; + } +#ifdef __STDC_LIB_EXT1__ + memset_s(&fpgalogic_i2c[i2c_ch_index], sizeof(fpgalogic_i2c[0]), 0, sizeof(fpgalogic_i2c[0])); +#else + memset(&fpgalogic_i2c[i2c_ch_index], 0, sizeof(fpgalogic_i2c[0])); +#endif + /* Initialize driver's itnernal data structures */ + fpgalogic_i2c[i2c_ch_index].reg_shift = 0; /* 8 bit registers */ + fpgalogic_i2c[i2c_ch_index].reg_io_width = 1; /* 8 bit read/write */ + fpgalogic_i2c[i2c_ch_index].timeout = 500;//1000;//1ms + fpgalogic_i2c[i2c_ch_index].ip_clock_khz = 100000;//100000;/* input clock of 100MHz */ + fpgalogic_i2c[i2c_ch_index].bus_clock_khz = 100; + fpgalogic_i2c[i2c_ch_index].base = pci_privdata->fpga_i2c_ch_base_addr + + i2c_ch_index* pci_privdata->fpga_i2c_ch_size; + mutex_init(&fpgalogic_i2c[i2c_ch_index].lock); + fpgai2c_init(&fpgalogic_i2c[i2c_ch_index]); + + + adap->algo_data = &fpgalogic_i2c[i2c_ch_index]; + i2c_set_adapdata(adap, &fpgalogic_i2c[i2c_ch_index]); + return 0; +} + +static int pddf_i2c_pci_add_numbered_bus_default (struct i2c_adapter *adap, int i2c_ch_index) +{ + int ret = 0; + + adap_data_init(adap, i2c_ch_index); + adap->algo = &fpgai2c_algorithm; + + ret = i2c_add_numbered_adapter(adap); + return ret; +} + +/* + * FPGAPCI APIs + */ +int board_i2c_fpgapci_read(uint32_t offset) +{ + int data; + data=ioread32(fpga_ctl_addr+offset); + return data; +} + + +int board_i2c_fpgapci_write(uint32_t offset, uint32_t value) +{ + iowrite32(value, fpga_ctl_addr+offset); + return (0); +} + + +static int __init pddf_xilinx_device_7021_algo_init(void) +{ + pddf_dbg(FPGA, KERN_INFO "[%s]\n", __FUNCTION__); + pddf_i2c_pci_add_numbered_bus = pddf_i2c_pci_add_numbered_bus_default; + ptr_fpgapci_read = board_i2c_fpgapci_read; + ptr_fpgapci_write = board_i2c_fpgapci_write; + return 0; +} + +static void __exit pddf_xilinx_device_7021_algo_exit(void) +{ + pddf_dbg(FPGA, KERN_INFO "[%s]\n", __FUNCTION__); + + pddf_i2c_pci_add_numbered_bus = NULL; + ptr_fpgapci_read = NULL; + ptr_fpgapci_write = NULL; + return; +} + + +module_init (pddf_xilinx_device_7021_algo_init); +module_exit (pddf_xilinx_device_7021_algo_exit); +MODULE_DESCRIPTION("Xilinx Corporation Device 7021 FPGAPCIe I2C-Bus algorithm"); +MODULE_LICENSE("GPL"); diff --git a/platform/pddf/i2c/modules/fpgapci/driver/Makefile b/platform/pddf/i2c/modules/fpgapci/driver/Makefile new file mode 100644 index 0000000000..1ea8b61273 --- /dev/null +++ b/platform/pddf/i2c/modules/fpgapci/driver/Makefile @@ -0,0 +1,4 @@ +TARGET = pddf_fpgapci_driver +obj-m := $(TARGET).o + +ccflags-y := -I$(M)/modules/include diff --git a/platform/pddf/i2c/modules/fpgapci/driver/pddf_fpgapci_driver.c b/platform/pddf/i2c/modules/fpgapci/driver/pddf_fpgapci_driver.c new file mode 100644 index 0000000000..630981522b --- /dev/null +++ b/platform/pddf/i2c/modules/fpgapci/driver/pddf_fpgapci_driver.c @@ -0,0 +1,352 @@ +/* +* +* Licensed under the GNU General Public License Version 2 +* +* 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. +* +*/ + +/* +* pddf_fpgapci_driver.c +* Description: +* This is a PDDF FPGAPCIe driver whic creates the PCIE device and add +* the i2c adapters to it. It uses the adapter creation and fpgapcie +* read/write functions defined separately in another kernel module. +* +************************************************************************/ +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include //siginfo +#include //rcu_read_lock +#include //kernel_version +#include +#include +#include +#include +#include +#include "pddf_fpgapci_defs.h" +#include "pddf_client_defs.h" +#include "pddf_i2c_algo.h" + + + +#define DEBUG 0 +int (*pddf_i2c_pci_add_numbered_bus)(struct i2c_adapter *, int) = NULL; +int (*ptr_fpgapci_read)(uint32_t) = NULL; +int (*ptr_fpgapci_write)(uint32_t, uint32_t) = NULL; +EXPORT_SYMBOL(pddf_i2c_pci_add_numbered_bus); +EXPORT_SYMBOL(ptr_fpgapci_read); +EXPORT_SYMBOL(ptr_fpgapci_write); + +FPGA_OPS_DATA pddf_fpga_ops_data={0}; + +#define DRIVER_NAME "pddf_fpgapci" +#define MAX_PCI_NUM_BARS 6 + +struct pci_driver pddf_fpgapci_driver; +struct pci_device_id *pddf_fpgapci_ids=NULL; +int total_i2c_pci_bus=0; +int FPGAPCI_BAR_INDEX = -1; + +void __iomem * fpga_ctl_addr = NULL; +EXPORT_SYMBOL(fpga_ctl_addr); + +static int pddf_fpgapci_probe(struct pci_dev *dev, const struct pci_device_id *id); +static void pddf_fpgapci_remove(struct pci_dev *dev); +static int map_bars(struct fpgapci_devdata *pci_privdata, struct pci_dev *dev); +static void free_bars(struct fpgapci_devdata *pci_privdata, struct pci_dev *dev); +static int pddf_pci_add_adapter(struct pci_dev *dev); + +/* each i2c bus is represented in linux using struct i2c_adapter */ +static struct i2c_adapter i2c_pci_adap[I2C_PCI_MAX_BUS]; + +static int pddf_pci_add_adapter(struct pci_dev *dev) +{ + int i; + + total_i2c_pci_bus = pddf_fpga_ops_data.virt_i2c_ch; + pddf_dbg(FPGA, KERN_INFO "[%s] total_i2c_pci_bus=%d\n", __FUNCTION__, total_i2c_pci_bus); +#ifdef __STDC_LIB_EXT1__ + memset_s(&i2c_pci_adap, sizeof(i2c_pci_adap), 0, sizeof(i2c_pci_adap)); +#else + memset(&i2c_pci_adap, 0, sizeof(i2c_pci_adap)); +#endif + + for (i = 0 ; i < total_i2c_pci_bus; i ++) { + + i2c_pci_adap[i].owner = THIS_MODULE; + i2c_pci_adap[i].class = I2C_CLASS_HWMON | I2C_CLASS_SPD; + + /* /dev/i2c-xxx for FPGA LOGIC I2C channel controller 1-7 */ + i2c_pci_adap[i].nr = i + pddf_fpga_ops_data.virt_bus ; + sprintf( i2c_pci_adap[ i ].name, "i2c-pci-%d", i ); + + /* set up the sysfs linkage to our parent device */ + i2c_pci_adap[i].dev.parent = &dev->dev; + + /* Add the bus via the algorithm code */ + + if( (pddf_i2c_pci_add_numbered_bus!=NULL) && (pddf_i2c_pci_add_numbered_bus( &i2c_pci_adap[ i ], i ) != 0 )) + { + pddf_dbg(FPGA, KERN_ERR "Cannot add bus %d to algorithm layer\n", i ); + return( -ENODEV ); + } + pddf_dbg(FPGA, KERN_INFO "[%s] Registered bus id: %s\n", __FUNCTION__, kobject_name(&i2c_pci_adap[ i ].dev.kobj)); + } + + return 0; +} + +static void pddf_pci_del_adapter(void) +{ + int i; + for( i = 0; i < total_i2c_pci_bus; i++ ){ + i2c_del_adapter(&i2c_pci_adap[i]); + } +} + +static int map_bars(struct fpgapci_devdata *pci_privdata, struct pci_dev *dev) +{ + unsigned long barFlags, barStart, barEnd, barLen; + int i; + + for (i=0; i < MAX_PCI_NUM_BARS; i++) { + if((barLen=pci_resource_len(dev, i)) !=0 && (barStart=pci_resource_start(dev, i)) !=0 ) { + barFlags = pci_resource_flags(dev, i); + barEnd = pci_resource_end(dev, i); + pddf_dbg(FPGA, KERN_INFO "[%s] PCI_BASE_ADDRESS_%d 0x%08lx-0x%08lx bar_len=0x%lx" + " flags 0x%08lx IO_mapped=%s Mem_mapped=%s\n", __FUNCTION__, + i, barStart, barEnd, barLen, barFlags, (barFlags & IORESOURCE_IO)? "Yes": "No", + (barFlags & IORESOURCE_MEM)? "Yes" : "No"); + FPGAPCI_BAR_INDEX=i; + break; + } + } + + if (FPGAPCI_BAR_INDEX != -1) { + pci_privdata->bar_length = barLen; + pci_privdata->fpga_data_base_addr = ioremap_cache (barStart + pddf_fpga_ops_data.data_base_offset, + pddf_fpga_ops_data.data_size); + fpga_ctl_addr = pci_privdata->fpga_data_base_addr; + + pci_privdata->fpga_i2c_ch_base_addr = ioremap_cache (barStart + pddf_fpga_ops_data.i2c_ch_base_offset, + I2C_PCI_MAX_BUS * pddf_fpga_ops_data.i2c_ch_size); + pci_privdata->max_fpga_i2c_ch = pddf_fpga_ops_data.virt_i2c_ch; + pci_privdata->fpga_i2c_ch_size = pddf_fpga_ops_data.i2c_ch_size; + } else { + pddf_dbg(FPGA, KERN_INFO "[%s] Failed to find BAR\n", __FUNCTION__); + return (-1); + } + pddf_dbg(FPGA, KERN_INFO "[%s] fpga_ctl_addr:0x%p fpga_data__base_addr:0x%p" + " bar_index[%d] fpgapci_bar_len:0x%08lx fpga_i2c_ch_base_addr:0x%p supported_i2c_ch=%d", + __FUNCTION__, fpga_ctl_addr, pci_privdata->fpga_data_base_addr, FPGAPCI_BAR_INDEX, + pci_privdata->bar_length, pci_privdata->fpga_i2c_ch_base_addr, pci_privdata->max_fpga_i2c_ch); + + return 0; +} + +static void free_bars(struct fpgapci_devdata *pci_privdata, struct pci_dev *dev) +{ + pci_iounmap(dev, pci_privdata->fpga_data_base_addr); + pci_privdata->fpga_i2c_ch_base_addr = NULL; +} + +static int pddf_pci_config_data(struct pci_dev *dev) +{ + unsigned short vendorId=0xFFFF, deviceId=0xFFFF; + char revisionId=0xFF, classDev=0xFF, classProg=0xFF; + char irqLine=0xFF, irqPin=0xFF; + + pddf_dbg(FPGA, KERN_INFO "[%s] PCI Config Data\n", __FUNCTION__); + + /* accessing the configuration region of the PCI device */ + pci_read_config_word(dev, PCI_VENDOR_ID, &vendorId); + pci_read_config_word(dev, PCI_DEVICE_ID, &deviceId); + pci_read_config_byte(dev, PCI_REVISION_ID, &revisionId); + pci_read_config_byte(dev, PCI_CLASS_PROG, &classProg); + pci_read_config_byte(dev, PCI_CLASS_DEVICE, &classDev); + + pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irqPin); + if(pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irqLine)) { + pddf_dbg(FPGA, KERN_ERR "\tPCI_INTERRUPT_LINE Error\n"); + } + + pddf_dbg(FPGA, KERN_INFO "\t[venId, devId]=[0x%x;0x%x] [group, class]=[%x;%x]\n", + vendorId, deviceId, classProg, classDev); + pddf_dbg(FPGA, KERN_INFO "\trevsionId=0x%x, irq_line=0x%x, irq_support=%s\n", + revisionId, irqLine, (irqPin == 0)? "No":"Yes"); + + return (0); +} + + +static int pddf_fpgapci_probe(struct pci_dev *dev, const struct pci_device_id *id) +{ + struct fpgapci_devdata *pci_privdata = 0; + int err = 0; + pddf_dbg(FPGA, KERN_INFO "[%s]\n", __FUNCTION__); + + if ((err = pci_enable_device(dev))) { + pddf_dbg(FPGA, KERN_ERR "[%s] pci_enable_device failed. dev:%s err:%#x\n", + __FUNCTION__, pci_name(dev), err); + return (err); + } + + /* Enable DMA */ + pci_set_master(dev); + + /* Request MMIO/IOP resources - reserve PCI I/O and memory resources + DRIVE_NAME shows up in /proc/iomem + */ + if ((err = pci_request_regions(dev, DRIVER_NAME)) < 0) { + pddf_dbg(FPGA, KERN_ERR "[%s] pci_request_regions failed. dev:%s err:%#x\n", + __FUNCTION__, pci_name(dev), err); + goto error_pci_req; + } + + pci_privdata = kzalloc(sizeof(struct fpgapci_devdata), GFP_KERNEL); + + if (!pci_privdata) { + pddf_dbg(FPGA, KERN_ERR "[%s] couldn't allocate pci_privdata memory", __FUNCTION__); + goto error_pci_req; + } + + pci_privdata->pci_dev = dev; + dev_set_drvdata(&dev->dev, (void*)pci_privdata); + pddf_pci_config_data(dev); + + if (map_bars(pci_privdata, dev)) { + pddf_dbg(FPGA, KERN_ERR "error_map_bars\n"); + goto error_map_bars; + } + pddf_pci_add_adapter(dev); + return (0); + +/* ERROR HANDLING */ +error_map_bars: + pci_release_regions(dev); +error_pci_req: + pci_disable_device(dev); + return -ENODEV; + +} + +static void pddf_fpgapci_remove(struct pci_dev *dev) +{ + struct fpgapci_devdata *pci_privdata = 0; + + if (dev == 0) { + pddf_dbg(FPGA, KERN_ERR "[%s]: dev is 0\n", __FUNCTION__); + return; + } + + pci_privdata = (struct fpgapci_devdata*) dev_get_drvdata(&dev->dev); + + if (pci_privdata == 0) { + pddf_dbg(FPGA, KERN_ERR "[%s]: pci_privdata is 0\n", __FUNCTION__); + return; + } + + pddf_pci_del_adapter(); + free_bars (pci_privdata, dev); + pci_disable_device(dev); + pci_release_regions(dev); + kfree (pci_privdata); +} + + +/* Initialize the driver module (but not any device) and register + * the module with the kernel PCI subsystem. */ +int pddf_fpgapci_register(FPGA_OPS_DATA* ptr_ops_data) +{ + + memcpy(&pddf_fpga_ops_data, ptr_ops_data, sizeof(FPGA_OPS_DATA)); +#if DEBUG + pddf_dbg(FPGA, KERN_INFO "[%s]: pddf_fpga_ops_data vendor_id=0x%x device_id=0x%x virt_bus=0x%x " + " data_base_offset=0x%x data_size=0x%x i2c_ch_base_offset=0x%x i2c_ch_size=0x%x virt_i2c_ch=%d", + __FUNCTION__, pddf_fpga_ops_data.vendor_id, pddf_fpga_ops_data.device_id, + pddf_fpga_ops_data.virt_bus, pddf_fpga_ops_data.data_base_offset, pddf_fpga_ops_data.data_size, + pddf_fpga_ops_data.i2c_ch_base_offset, pddf_fpga_ops_data.i2c_ch_size, + pddf_fpga_ops_data.virt_i2c_ch); +#endif + struct pci_device_id fpgapci_ids[2] = { + {PCI_DEVICE(pddf_fpga_ops_data.vendor_id, pddf_fpga_ops_data.device_id)}, + {0, }, + }; + + int size = sizeof(struct pci_device_id) * 2; + + if ((pddf_fpgapci_ids=kmalloc(size, GFP_KERNEL)) == NULL) { + pddf_dbg(FPGA, KERN_INFO "%s kmalloc failed\n", __FUNCTION__); + return 0; + } + + memcpy(pddf_fpgapci_ids, fpgapci_ids, size); + + pddf_fpgapci_driver.name=DRIVER_NAME; + pddf_fpgapci_driver.id_table=pddf_fpgapci_ids; + pddf_fpgapci_driver.probe=pddf_fpgapci_probe; + pddf_fpgapci_driver.remove=pddf_fpgapci_remove; + + if (pci_register_driver(&pddf_fpgapci_driver)) { + pddf_dbg(FPGA, KERN_INFO "%s: pci_unregister_driver\n", __FUNCTION__); + pci_unregister_driver(&pddf_fpgapci_driver); + return -ENODEV; + } + return 0; +} + +EXPORT_SYMBOL(pddf_fpgapci_register); + +static int __init pddf_fpgapci_driver_init(void) +{ + pddf_dbg(FPGA, KERN_INFO "[%s]\n", __FUNCTION__); + + return 0; +} + +static void __exit pddf_fpgapci_driver_exit(void) +{ + pddf_dbg(FPGA, KERN_INFO "[%s]\n", __FUNCTION__); + + if (pddf_fpgapci_ids) { + /* unregister this driver from the PCI bus driver */ + pci_unregister_driver(&pddf_fpgapci_driver); + kfree(pddf_fpgapci_ids); + } + +} + + +module_init (pddf_fpgapci_driver_init); +module_exit (pddf_fpgapci_driver_exit); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Broadcom"); +MODULE_DESCRIPTION ("PDDF Driver for FPGAPCI Logic I2C bus"); +MODULE_SUPPORTED_DEVICE ("PDDF FPGAPCI Logic I2C bus"); diff --git a/platform/pddf/i2c/modules/fpgapci/pddf_fpgapci_module.c b/platform/pddf/i2c/modules/fpgapci/pddf_fpgapci_module.c new file mode 100644 index 0000000000..72ec97c1e2 --- /dev/null +++ b/platform/pddf/i2c/modules/fpgapci/pddf_fpgapci_module.c @@ -0,0 +1,142 @@ +/* + * + * 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. + * + * A pddf kernel module to create sysfs for fpga + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "pddf_client_defs.h" +#include "pddf_fpgapci_defs.h" + +FPGA_OPS_DATA tmp_pddf_fpga_ops_data={0}; +extern int pddf_fpgapci_register(FPGA_OPS_DATA *ptr); + +/************************************************************************** + * FPGA SYSFS Attributes + **************************************************************************/ +static ssize_t dev_operation(struct device *dev, struct device_attribute *da, const char *buf, size_t count); + +PDDF_DATA_ATTR(vendor_id, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_UINT32, sizeof(uint32_t), (void*)&tmp_pddf_fpga_ops_data.vendor_id, NULL); +PDDF_DATA_ATTR(device_id, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_UINT32, sizeof(uint32_t), (void*)&tmp_pddf_fpga_ops_data.device_id, NULL); +PDDF_DATA_ATTR(virt_bus, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_UINT32, sizeof(uint32_t), (void*)&tmp_pddf_fpga_ops_data.virt_bus, NULL); +PDDF_DATA_ATTR(data_base_offset, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_UINT32, sizeof(uint32_t), (void*)&tmp_pddf_fpga_ops_data.data_base_offset, NULL); +PDDF_DATA_ATTR(data_size, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_UINT32, sizeof(uint32_t), (void*)&tmp_pddf_fpga_ops_data.data_size, NULL); +PDDF_DATA_ATTR(i2c_ch_base_offset, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_UINT32, sizeof(uint32_t), (void*)&tmp_pddf_fpga_ops_data.i2c_ch_base_offset, NULL); +PDDF_DATA_ATTR(i2c_ch_size, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_UINT32, sizeof(uint32_t), (void*)&tmp_pddf_fpga_ops_data.i2c_ch_size, NULL); +PDDF_DATA_ATTR(virt_i2c_ch, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_UINT32, sizeof(uint32_t), (void*)&tmp_pddf_fpga_ops_data.virt_i2c_ch, NULL); +PDDF_DATA_ATTR(dev_ops , S_IWUSR|S_IRUGO, show_pddf_data, + dev_operation, PDDF_CHAR, NAME_SIZE, (void*)&tmp_pddf_fpga_ops_data, NULL); + +struct attribute* attrs_fpgapci[]={ + &attr_vendor_id.dev_attr.attr, + &attr_device_id.dev_attr.attr, + &attr_virt_bus.dev_attr.attr, + &attr_data_base_offset.dev_attr.attr, + &attr_data_size.dev_attr.attr, + &attr_i2c_ch_base_offset.dev_attr.attr, + &attr_i2c_ch_size.dev_attr.attr, + &attr_virt_i2c_ch.dev_attr.attr, + &attr_dev_ops.dev_attr.attr, + NULL, +}; +struct attribute_group attr_group_fpgapci={ + .attrs = attrs_fpgapci, +}; + +ssize_t dev_operation(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + if(strncmp(buf, "fpgapci_init", strlen("fpgapci_init"))==0 ) { + struct pddf_data_attribute *_ptr = (struct pddf_data_attribute *)da; + FPGA_OPS_DATA* pddf_fpga_ops_data=(FPGA_OPS_DATA*)_ptr->addr; + pddf_dbg(FPGA, KERN_INFO "%s: pddf_fpga_ops_data vendor_id=0x%x device_id=0x%x virt_bus=0x%x:%d " + " data_base_offset=0x%x data_size=0x%x i2c_ch_base_offset=0x%x i2c_ch_size=0x%x virt_i2c_ch=%d", + __FUNCTION__, pddf_fpga_ops_data->vendor_id, pddf_fpga_ops_data->device_id, + pddf_fpga_ops_data->virt_bus, pddf_fpga_ops_data->virt_bus, + pddf_fpga_ops_data->data_base_offset, pddf_fpga_ops_data->data_size, + pddf_fpga_ops_data->i2c_ch_base_offset, pddf_fpga_ops_data->i2c_ch_size, pddf_fpga_ops_data->virt_i2c_ch); + + pddf_fpgapci_register(pddf_fpga_ops_data); + } + else { + pddf_dbg(FPGA, KERN_ERR "PDDF_ERROR %s: Invalid value for dev_ops %s\n", __FUNCTION__, buf); + } + return(count); +} + + +#define KOBJ_FREE(obj) \ + if(obj) kobject_put(obj); \ + + +int __init pddf_fpga_data_init(void) +{ + int ret = 0; + struct kobject *device_kobj; + + pddf_dbg(FPGA, KERN_INFO "%s ..\n", __FUNCTION__); + + device_kobj = get_device_i2c_kobj(); + if(!device_kobj) { + pddf_dbg(FPGA, KERN_ERR "%s get_device_i2c_kobj failed ..\n", __FUNCTION__); + return -ENOMEM; + } + fpgapci_kobj = kobject_create_and_add("fpgapci", device_kobj); + if(!fpgapci_kobj) { + pddf_dbg(FPGA, KERN_ERR "%s create fpgapci kobj failed ..\n", __FUNCTION__); + return -ENOMEM; + } + + ret = sysfs_create_group(fpgapci_kobj, &attr_group_fpgapci); + if (ret) + { + pddf_dbg(FPGA, KERN_ERR "%s create fpga sysfs attributes failed ..\n", __FUNCTION__); + return ret; + } + + + return (0); + +} + +void __exit pddf_fpga_data_exit(void) +{ + pddf_dbg(FPGA, KERN_INFO "%s ..\n", __FUNCTION__); + KOBJ_FREE(fpgapci_kobj) + return; +} + + +module_init(pddf_fpga_data_init); +module_exit(pddf_fpga_data_exit); + +MODULE_AUTHOR("Broadcom"); +MODULE_DESCRIPTION("fpga platform data"); +MODULE_LICENSE("GPL"); diff --git a/platform/pddf/i2c/modules/include/pddf_client_defs.h b/platform/pddf/i2c/modules/include/pddf_client_defs.h index 1c98a73e6e..cb26dd1ab4 100644 --- a/platform/pddf/i2c/modules/include/pddf_client_defs.h +++ b/platform/pddf/i2c/modules/include/pddf_client_defs.h @@ -28,10 +28,13 @@ #define CLIENT "PDDF_CLIENT" #define CPLD "PDDF_CPLD" #define CPLDMUX "PDDF_CPLDMUX" +#define FPGAI2C "PDDF_FPGAI2C" #define MUX "PDDF_MUX" #define GPIO "PDDF_GPIO" #define SYSSTATUS "PDDF_SYSSTATUS" #define XCVR "PDDF_XCVR" +#define FPGA "PDDF_FPGAPCI" + #define PDDF_DEBUG #ifdef PDDF_DEBUG diff --git a/platform/pddf/i2c/modules/include/pddf_fan_defs.h b/platform/pddf/i2c/modules/include/pddf_fan_defs.h index 7765e54462..066e956e11 100644 --- a/platform/pddf/i2c/modules/include/pddf_fan_defs.h +++ b/platform/pddf/i2c/modules/include/pddf_fan_defs.h @@ -88,4 +88,6 @@ typedef struct FAN_PDATA extern int board_i2c_cpld_read(unsigned short cpld_addr, u8 reg); extern int board_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int board_i2c_fpga_read(unsigned short cpld_addr, u8 reg); +extern int board_i2c_fpga_write(unsigned short cpld_addr, u8 reg, u8 value); #endif diff --git a/platform/pddf/i2c/modules/include/pddf_fpgai2c_defs.h b/platform/pddf/i2c/modules/include/pddf_fpgai2c_defs.h new file mode 100644 index 0000000000..bc3cbc2b7b --- /dev/null +++ b/platform/pddf/i2c/modules/include/pddf_fpgai2c_defs.h @@ -0,0 +1,30 @@ +/* + * Copyright 2019 Broadcom. + * The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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. + * + * Description: + * Platform FPGA I2C defines/structures header file + */ + +#ifndef __PDDF_FPGAI2C_DEFS_H__ +#define __PDDF_FPGAI2C_DEFS_H__ + +/* FPGAI2C DATA - DATA FOR I2C FPGA CLIENT READ/WRITE*/ +typedef struct FPGAI2C_DATA +{ + struct mutex fpga_lock; + uint16_t reg_addr; +}PDDF_FPGAI2C_DATA; + + +#endif //__PDDF_FPGAI2C_DEFS_H__ diff --git a/platform/pddf/i2c/modules/include/pddf_fpgapci_defs.h b/platform/pddf/i2c/modules/include/pddf_fpgapci_defs.h new file mode 100644 index 0000000000..c745bbd09f --- /dev/null +++ b/platform/pddf/i2c/modules/include/pddf_fpgapci_defs.h @@ -0,0 +1,49 @@ +/* + * + * 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. + * + * Description: + * Platform FPGAPCI defines/structures header file + */ + +#ifndef __PDDF_FPGAPCI_DEFS_H__ +#define __PDDF_FPGAPCI_DEFS_H__ + + +// FPGA +typedef struct +{ + uint32_t vendor_id; + uint32_t device_id; + uint32_t virt_bus; + uint32_t virt_i2c_ch; + uint32_t data_base_offset; + uint32_t data_size; + uint32_t i2c_ch_base_offset; + uint32_t i2c_ch_size; +} FPGA_OPS_DATA; + +/***************************************** + * kobj list + *****************************************/ + +struct kobject *fpgapci_kobj=NULL; + +/***************************************** + * Static Data provided from user + * space JSON data file + *****************************************/ +#define NAME_SIZE 32 + + + + +#endif diff --git a/platform/pddf/i2c/modules/include/pddf_i2c_algo.h b/platform/pddf/i2c/modules/include/pddf_i2c_algo.h new file mode 100644 index 0000000000..3526b45651 --- /dev/null +++ b/platform/pddf/i2c/modules/include/pddf_i2c_algo.h @@ -0,0 +1,36 @@ +/* + * + * Description: + * This is the required header file for customed i2c algorithms + */ + +#ifndef __PDDF_I2C_ALGO_H__ +#define __PDDF_I2C_ALGO_H__ +#include "pddf_client_defs.h" + +/* max number of adapters */ +#define I2C_PCI_MAX_BUS 16 + +/** + * struct fpgapci_devdata - PCI device data structure + * support one device per PCIe + */ +struct fpgapci_devdata { + struct pci_dev *pci_dev; + + /* kernels virtual addr for fpga_data_base_addr */ + void * __iomem fpga_data_base_addr; + + /* kernels virtual addr. for the i2c_ch_base_addr */ + void * __iomem fpga_i2c_ch_base_addr; + + /* size per i2c_ch */ + int fpga_i2c_ch_size; + + /* number of supported virtual i2c buses */ + int max_fpga_i2c_ch; + + size_t bar_length; +}; + +#endif diff --git a/platform/pddf/i2c/modules/include/pddf_led_defs.h b/platform/pddf/i2c/modules/include/pddf_led_defs.h index 1603f8c5af..0056cf537e 100644 --- a/platform/pddf/i2c/modules/include/pddf_led_defs.h +++ b/platform/pddf/i2c/modules/include/pddf_led_defs.h @@ -33,6 +33,7 @@ struct kobject *cur_state_kobj=NULL; * space JSON data file *****************************************/ #define NAME_SIZE 32 +#define VALUE_SIZE 5 typedef enum { STATUS_LED_COLOR_GREEN, STATUS_LED_COLOR_GREEN_BLINK, @@ -42,20 +43,24 @@ typedef enum { STATUS_LED_COLOR_AMBER_BLINK, STATUS_LED_COLOR_BLUE, STATUS_LED_COLOR_BLUE_BLINK, + STATUS_LED_COLOR_YELLOW, + STATUS_LED_COLOR_YELLOW_BLINK, STATUS_LED_COLOR_OFF, MAX_LED_STATUS }LED_STATUS; char* LED_STATUS_STR[] = { - "STATUS_LED_COLOR_GREEN", - "STATUS_LED_COLOR_GREEN_BLINK", - "STATUS_LED_COLOR_RED", - "STATUS_LED_COLOR_RED_BLINK", - "STATUS_LED_COLOR_AMBER", - "STATUS_LED_COLOR_AMBER_BLINK", - "STATUS_LED_COLOR_BLUE", - "STATUS_LED_COLOR_BLUE_BLINK", - "STATUS_LED_COLOR_OFF" + "green", + "green_blink", + "red", + "red_blink", + "amber", + "amber_blink", + "blue", + "blue_blink", + "yellow", + "yellow_blink", + "off" }; @@ -71,7 +76,10 @@ typedef struct int swpld_addr; int swpld_addr_offset; MASK_BITS bits; - unsigned short value; + u8 reg_values[VALUE_SIZE]; + char value[NAME_SIZE]; + char attr_devtype[NAME_SIZE]; + char attr_devname[NAME_SIZE]; } LED_DATA; typedef struct @@ -88,6 +96,8 @@ typedef struct LED_DATA data[MAX_LED_STATUS]; int swpld_addr; int swpld_addr_offset; + char attr_devtype[NAME_SIZE]; + char attr_devname[NAME_SIZE]; } LED_OPS_DATA; typedef enum{ diff --git a/platform/pddf/i2c/modules/include/pddf_psu_api.h b/platform/pddf/i2c/modules/include/pddf_psu_api.h index 762863f028..24e4ea02e7 100644 --- a/platform/pddf/i2c/modules/include/pddf_psu_api.h +++ b/platform/pddf/i2c/modules/include/pddf_psu_api.h @@ -24,18 +24,8 @@ extern void get_psu_duplicate_sysfs(int idx, char *str); extern ssize_t psu_show_default(struct device *dev, struct device_attribute *da, char *buf); extern ssize_t psu_store_default(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -extern int sonic_i2c_get_psu_present_default(void *client, PSU_DATA_ATTR *adata, void *data); -extern int sonic_i2c_get_psu_power_good_default(void *client, PSU_DATA_ATTR *adata, void *data); -extern int sonic_i2c_get_psu_model_name_default(void *client, PSU_DATA_ATTR *adata, void *data); -extern int sonic_i2c_get_psu_mfr_id_default(void *client, PSU_DATA_ATTR *adata, void *data); -extern int sonic_i2c_get_psu_serial_num_default(void *client, PSU_DATA_ATTR *adata, void *data); -extern int sonic_i2c_get_psu_fan_dir_default(void *client, PSU_DATA_ATTR *adata, void *data); -extern int sonic_i2c_get_psu_v_out_default(void *client, PSU_DATA_ATTR *adata, void *data); -extern int sonic_i2c_get_psu_i_out_default(void *client, PSU_DATA_ATTR *adata, void *data); -extern int sonic_i2c_get_psu_p_out_default(void *client, PSU_DATA_ATTR *adata, void *data); -extern int sonic_i2c_get_psu_fan1_speed_rpm_default(void *client, PSU_DATA_ATTR *adata, void *data); -extern int sonic_i2c_get_psu_temp1_input_default(void *client, PSU_DATA_ATTR *adata, void *data); -extern int sonic_i2c_get_psu_v_in_default(void *client, PSU_DATA_ATTR *adata, void *data); -extern int sonic_i2c_get_psu_i_in_default(void *client, PSU_DATA_ATTR *adata, void *data); +extern int sonic_i2c_get_psu_byte_default(void *client, PSU_DATA_ATTR *adata, void *data); +extern int sonic_i2c_get_psu_block_default(void *client, PSU_DATA_ATTR *adata, void *data); +extern int sonic_i2c_get_psu_word_default(void *client, PSU_DATA_ATTR *adata, void *data); #endif diff --git a/platform/pddf/i2c/modules/include/pddf_psu_driver.h b/platform/pddf/i2c/modules/include/pddf_psu_driver.h index a2aa3f41d3..a94cf7441d 100644 --- a/platform/pddf/i2c/modules/include/pddf_psu_driver.h +++ b/platform/pddf/i2c/modules/include/pddf_psu_driver.h @@ -27,12 +27,17 @@ enum psu_sysfs_attributes { PSU_SERIAL_NUM, PSU_FAN_DIR, PSU_V_OUT, + PSU_V_OUT_MIN, + PSU_V_OUT_MAX, PSU_I_OUT, PSU_P_OUT, /* This is in micro watts to comply with lm-sensors */ + PSU_P_OUT_MAX, PSU_FAN1_SPEED, PSU_TEMP1_INPUT, + PSU_TEMP1_HIGH_THRESHOLD, PSU_V_IN, PSU_I_IN, + PSU_P_IN, PSU_ATTR_MAX }; diff --git a/platform/pddf/i2c/modules/led/pddf_led_module.c b/platform/pddf/i2c/modules/led/pddf_led_module.c index 362467e5ab..f419af3372 100644 --- a/platform/pddf/i2c/modules/led/pddf_led_module.c +++ b/platform/pddf/i2c/modules/led/pddf_led_module.c @@ -16,6 +16,7 @@ * A pddf kernel module to manage various LEDs of a switch */ +#define __STDC_WANT_LIB_EXT1__ 1 #include #include #include @@ -37,618 +38,689 @@ LED_OPS_DATA loc_led_ops_data[1]= {0}; LED_OPS_DATA* fantray_led_ops_data=NULL; LED_OPS_DATA temp_data={0}; LED_OPS_DATA* dev_list[LED_TYPE_MAX] = { - sys_led_ops_data, - NULL, - fan_led_ops_data, - NULL, - diag_led_ops_data, - loc_led_ops_data, + sys_led_ops_data, + NULL, + fan_led_ops_data, + NULL, + diag_led_ops_data, + loc_led_ops_data, }; int num_psus = 0; int num_fantrays = 0; extern int board_i2c_cpld_read(unsigned short cpld_addr, u8 reg); extern int board_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int board_i2c_fpga_read(unsigned short cpld_addr, u8 reg); +extern int board_i2c_fpga_write(unsigned short cpld_addr, u8 reg, u8 value); + extern ssize_t show_pddf_data(struct device *dev, struct device_attribute *da, char *buf); extern ssize_t store_pddf_data(struct device *dev, struct device_attribute *da, const char *buf, size_t count); static LED_STATUS find_state_index(const char* state_str) { - int index; - char *ptr = (char *)state_str; - while (*ptr && *ptr!= '\n' && *ptr !='\0') ptr++; - *ptr='\0'; - for ( index = 0; index < MAX_LED_STATUS; index++) { - /*int rc = strcmp(state_str, LED_STATUS_STR[index]) ;*/ - if (strcmp(state_str, LED_STATUS_STR[index]) == 0 ) { - return index; - } - } - return MAX_LED_STATUS; + int index; + char *ptr = (char *)state_str; + while (*ptr && *ptr!= '\n' && *ptr !='\0') ptr++; + *ptr='\0'; + for ( index = 0; index < MAX_LED_STATUS; index++) { + if (strcmp(state_str, LED_STATUS_STR[index]) == 0 ) { + return index; + } + } + return MAX_LED_STATUS; } static LED_TYPE get_dev_type(char* name) { - LED_TYPE ret = LED_TYPE_MAX; - if(strcasecmp(name, "SYS_LED")==0) { - ret = LED_SYS; - } else if(strcasecmp(name, "FAN_LED")==0) { - ret = LED_FAN; - } else if(strstr(name, "PSU_LED")) { - ret = LED_PSU; - } else if(strcasecmp(name, "DIAG_LED")==0) { - ret = LED_DIAG; - } else if(strcasecmp(name, "LOC_LED")==0) { - ret = LED_LOC; - } else if(strstr(name, "FANTRAY_LED")) { - ret = LED_FANTRAY; - } + LED_TYPE ret = LED_TYPE_MAX; + if(strcasecmp(name, "SYS_LED") == 0) { + ret = LED_SYS; + } else if(strcasecmp(name, "FAN_LED") == 0) { + ret = LED_FAN; + } else if(strstr(name, "PSU_LED")) { + ret = LED_PSU; + } else if(strcasecmp(name, "DIAG_LED") == 0) { + ret = LED_DIAG; + } else if(strcasecmp(name, "LOC_LED") == 0) { + ret = LED_LOC; + } else if(strstr(name, "FANTRAY_LED")) { + ret = LED_FANTRAY; + } #if DEBUG > 1 - pddf_dbg(LED, KERN_INFO "LED get_dev_type: %s; %d\n", name, ret); + pddf_dbg(LED, KERN_INFO "LED get_dev_type: %s; %d\n", name, ret); #endif - return (ret); + return (ret); } static int dev_index_check(LED_TYPE type, int index) { #if DEBUG - pddf_dbg(LED, "dev_index_check: type:%s index:%d num_psus:%d num_fantrays:%d\n", - LED_TYPE_STR[type], index, num_psus, num_fantrays); + pddf_dbg(LED, "dev_index_check: type:%s index:%d num_psus:%d num_fantrays:%d\n", + LED_TYPE_STR[type], index, num_psus, num_fantrays); #endif - switch(type) - { - case LED_PSU: - if(index >= num_psus) return (-1); - break; - case LED_FANTRAY: - if(index >= num_fantrays) return (-1); - break; - default: - if(index >= 1) return (-1); - break; - } - return (0); + switch(type) + { + case LED_PSU: + if(index >= num_psus) return (-1); + break; + case LED_FANTRAY: + if(index >= num_fantrays) return (-1); + break; + default: + if(index >= 1) return (-1); + break; + } + return (0); } static LED_OPS_DATA* find_led_ops_data(struct device_attribute *da) { - struct pddf_data_attribute *_ptr = (struct pddf_data_attribute *)da; - LED_OPS_DATA* ptr=(LED_OPS_DATA*)_ptr->addr; - LED_TYPE led_type; - if(!ptr || strlen(ptr->device_name)==0 ) return(NULL); - - - if((led_type=get_dev_type(ptr->device_name))==LED_TYPE_MAX) { - printk(KERN_ERR "PDDF_LED ERROR *%s Unsupported Led Type\n", __func__); - return(NULL); - } - if(dev_index_check(led_type, ptr->index)==-1) { - printk(KERN_ERR "PDDF_LED ERROR %s invalid index: %d for type:%s\n", __func__, ptr->index, ptr->device_name); - return(NULL); - } + struct pddf_data_attribute *_ptr = (struct pddf_data_attribute *)da; + LED_OPS_DATA* ptr = (LED_OPS_DATA*)_ptr->addr; + LED_TYPE led_type; + if(!ptr || strlen(ptr->device_name) == 0 ) return (NULL); + + if((led_type=get_dev_type(ptr->device_name)) == LED_TYPE_MAX) { + printk(KERN_ERR "PDDF_LED ERROR *%s Unsupported Led Type\n", __func__); + return (NULL); + } + if(dev_index_check(led_type, ptr->index) == -1) { + printk(KERN_ERR "PDDF_LED ERROR %s invalid index: %d for type:%s\n", __func__, ptr->index, ptr->device_name); + return (NULL); + } #if DEBUG > 1 - pddf_dbg(LED, "find_led_ops_data: name:%s; index=%d tempAddr:%p actualAddr:%p\n", - ptr->device_name, ptr->index, ptr, dev_list[led_type]+ptr->index); + pddf_dbg(LED, "find_led_ops_data: name:%s; index=%d tempAddr:%p actualAddr:%p\n", + ptr->device_name, ptr->index, ptr, dev_list[led_type]+ptr->index); #endif - return (dev_list[led_type]+ptr->index); + return (dev_list[led_type]+ptr->index); } static void print_led_data(LED_OPS_DATA *ptr, LED_STATUS state) { int i = 0; - if(!ptr) return ; - pddf_dbg(LED, KERN_INFO "Print %s index:%d num_psus:%d num_fantrays:%d ADDR=%p\n", - ptr->device_name, ptr->index, num_psus, num_fantrays, ptr); - pddf_dbg(LED, KERN_INFO "\tindex: %d\n", ptr->index); - pddf_dbg(LED, KERN_INFO "\tcur_state: %d; %s \n", ptr->cur_state.state, ptr->cur_state.color); - for (i = 0; i< MAX_LED_STATUS; i++) { - if(ptr->data[i].swpld_addr && (i == state || state == -1)) { - pddf_dbg(LED, KERN_INFO "\t\t[%s]: addr/offset:0x%x;0x%x color:%s; value:%x; mask_bits: 0x%x; pos:%d\n", - LED_STATUS_STR[i], - ptr->data[i].swpld_addr, ptr->data[i].swpld_addr_offset, - LED_STATUS_STR[i], ptr->data[i].value, ptr->data[i].bits.mask_bits, ptr->data[i].bits.pos); - } + if(!ptr) return ; + pddf_dbg(LED, KERN_INFO "Print %s index:%d num_psus:%d num_fantrays:%d ADDR=%p\n", + ptr->device_name, ptr->index, num_psus, num_fantrays, ptr); + pddf_dbg(LED, KERN_INFO "\tindex: %d\n", ptr->index); + pddf_dbg(LED, KERN_INFO "\tdevtype/devname: %s:%s\n", ptr->attr_devtype, ptr->attr_devname); + pddf_dbg(LED, KERN_INFO "\tcur_state: %d; %s \n", ptr->cur_state.state, ptr->cur_state.color); + for (i = 0; i< MAX_LED_STATUS; i++) { + if(ptr->data[i].swpld_addr && (i == state || state == -1)) { + pddf_dbg(LED, KERN_INFO "\t\t[%s]: addr/offset:0x%x;0x%x color:%s; value:[%s][0x%x][0x%x] mask_bits: 0x%x;" + "pos:%d attr_devtype:%s attr_devname:%s\n",LED_STATUS_STR[i], ptr->data[i].swpld_addr, + ptr->data[i].swpld_addr_offset, LED_STATUS_STR[i], ptr->data[i].value, + ptr->data[i].reg_values[0], ptr->data[i].reg_values[1], ptr->data[i].bits.mask_bits, + ptr->data[i].bits.pos, ptr->data[i].attr_devtype, ptr->data[i].attr_devname); } + } } - + ssize_t get_status_led(struct device_attribute *da) { - int ret=0; - struct pddf_data_attribute *_ptr = (struct pddf_data_attribute *)da; - LED_OPS_DATA* temp_data_ptr=(LED_OPS_DATA*)_ptr->addr; - LED_OPS_DATA* ops_ptr=find_led_ops_data(da); - uint32_t color_val=0, sys_val=0; - int state=0; - if (!ops_ptr) { - pddf_dbg(LED, KERN_ERR "ERROR %s: Cannot find LED Ptr", __func__); - return (-1); - } - if (ops_ptr->swpld_addr == 0x0) { - pddf_dbg(LED, KERN_ERR "ERROR %s: device: %s %d not configured\n", __func__, - temp_data_ptr->device_name, temp_data_ptr->index); - return (-1); - } - sys_val = board_i2c_cpld_read(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset); - if (sys_val < 0) - return sys_val; - - strcpy(temp_data.cur_state.color, "None"); - for (state=0; statedata[state].bits.mask_bits); - if ((color_val ^ (ops_ptr->data[state].value<data[state].bits.pos))==0) { - strcpy(temp_data.cur_state.color, LED_STATUS_STR[state]); - } - } -#if DEBUG > 1 - pddf_dbg(LED, KERN_ERR "Get : %s:%d addr/offset:0x%x; 0x%x value=0x%x [%s]\n", - ops_ptr->device_name, ops_ptr->index, - ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset, sys_val, - temp_data.cur_state.color); -#endif + int ret=0; + struct pddf_data_attribute *_ptr = (struct pddf_data_attribute *)da; + LED_OPS_DATA* temp_data_ptr=(LED_OPS_DATA*)_ptr->addr; + LED_OPS_DATA* ops_ptr=find_led_ops_data(da); + uint32_t color_val=0, sys_val=0; + int state=0; + int cpld_type=0; + int j; + + if (!ops_ptr) { + pddf_dbg(LED, KERN_ERR "ERROR %s: Cannot find LED Ptr", __func__); + return (-1); + } + + if (ops_ptr->swpld_addr == 0x0) { + pddf_dbg(LED, KERN_ERR "ERROR %s: device: %s %d not configured\n", __func__, + temp_data_ptr->device_name, temp_data_ptr->index); + return (-1); + } + + if (strcmp(ops_ptr->attr_devtype, "cpld") == 0) { + cpld_type = 1; + sys_val = board_i2c_cpld_read(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset); + } else if (strcmp(ops_ptr->attr_devtype, "fpgai2c") == 0) { + sys_val = board_i2c_fpga_read(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset); + } else { + pddf_dbg(LED, KERN_ERR "ERROR %s: %s %d devtype:%s 0x%x:0x%x not configured\n",__func__, + ops_ptr->device_name, ops_ptr->index, ops_ptr->attr_devtype, ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset); + return (-1); + } + + if (sys_val < 0) { + pddf_dbg(LED, KERN_ERR "ERROR %s: %s %d devtype:%s 0x%x:0x%x read failed\n",__func__, + ops_ptr->device_name, ops_ptr->index, ops_ptr->attr_devtype, ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset); + return sys_val; + } - return(ret); + strcpy(temp_data.cur_state.color, "None"); + for (state=0; statedata[state].bits.mask_bits); + for (j = 0; j < VALUE_SIZE && ops_ptr->data[state].reg_values[j] != 0xff; j++) { + if ((color_val ^ (ops_ptr->data[state].reg_values[j] << ops_ptr->data[state].bits.pos)) == 0) { + strcpy(temp_data.cur_state.color, LED_STATUS_STR[state]); + break; + } + } + } +#if DEBUG + pddf_dbg(LED, KERN_ERR "Get : %s:%d addr/offset:0x%x; 0x%x devtype:%s;%s value=0x%x [%s]\n", + ops_ptr->device_name, ops_ptr->index, ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset, + ops_ptr->attr_devtype, cpld_type? "cpld": "fpgai2c", sys_val, temp_data.cur_state.color); +#endif + return(ret); } ssize_t set_status_led(struct device_attribute *da) { - int ret=0; - uint32_t sys_val=0, new_val=0; - LED_STATUS cur_state = MAX_LED_STATUS; - struct pddf_data_attribute *_ptr = (struct pddf_data_attribute *)da; - LED_OPS_DATA* temp_data_ptr=(LED_OPS_DATA*)_ptr->addr; - LED_OPS_DATA* ops_ptr=find_led_ops_data(da); - char* _buf=temp_data_ptr->cur_state.color; - - if (!ops_ptr) { - pddf_dbg(LED, KERN_ERR "PDDF_LED ERROR %s: Cannot find LED Ptr", __func__); - return (-1); - } - if (ops_ptr->swpld_addr == 0x0) { - pddf_dbg(LED, KERN_ERR "PDDF_LED ERROR %s: device: %s %d not configured\n", - __func__, ops_ptr->device_name, ops_ptr->index); - return (-1); - } - pddf_dbg(LED, KERN_ERR "%s: Set [%s;%d] color[%s]\n", __func__, - temp_data_ptr->device_name, temp_data_ptr->index, - temp_data_ptr->cur_state.color); - cur_state = find_state_index(_buf); - - if (cur_state == MAX_LED_STATUS) { - pddf_dbg(LED, KERN_ERR "ERROR %s: not supported: %s\n", _buf, __func__); - return (-1); + int ret=0; + uint32_t sys_val=0, new_val=0, read_val=0; + LED_STATUS cur_state = MAX_LED_STATUS; + struct pddf_data_attribute *_ptr = (struct pddf_data_attribute *)da; + LED_OPS_DATA* temp_data_ptr=(LED_OPS_DATA*)_ptr->addr; + LED_OPS_DATA* ops_ptr=find_led_ops_data(da); + char* _buf=temp_data_ptr->cur_state.color; + int cpld_type = 0; + + if (!ops_ptr) { + pddf_dbg(LED, KERN_ERR "PDDF_LED ERROR %s: Cannot find LED Ptr", __func__); + return (-1); + } + + if (ops_ptr->swpld_addr == 0x0) { + pddf_dbg(LED, KERN_ERR "PDDF_LED ERROR %s: device: %s %d not configured\n", + __func__, ops_ptr->device_name, ops_ptr->index); + return (-1); + } + + pddf_dbg(LED, KERN_ERR "%s: Set [%s;%d] color[%s]\n", __func__, + temp_data_ptr->device_name, temp_data_ptr->index, + temp_data_ptr->cur_state.color); + cur_state = find_state_index(_buf); + + if (cur_state == MAX_LED_STATUS) { + pddf_dbg(LED, KERN_ERR "ERROR %s: not supported: %s\n", _buf, __func__); + return (-1); + } + + if (ops_ptr->data[cur_state].swpld_addr != 0x0) { + if (strcmp(ops_ptr->data[cur_state].attr_devtype, "cpld") == 0) { + cpld_type = 1; + sys_val = board_i2c_cpld_read(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset); + } else if (strcmp(ops_ptr->data[cur_state].attr_devtype, "fpgai2c") == 0) { + sys_val = board_i2c_fpga_read(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset); + } else { + pddf_dbg(LED, KERN_ERR "ERROR %s: %s %d devtype:%s not configured\n",__func__, + ops_ptr->device_name, ops_ptr->index, ops_ptr->attr_devtype); + return (-1); } - if(ops_ptr->data[cur_state].swpld_addr != 0x0) { - sys_val = board_i2c_cpld_read(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset); - if (sys_val < 0) - return sys_val; - - new_val = (sys_val & ops_ptr->data[cur_state].bits.mask_bits) | - (ops_ptr->data[cur_state].value << ops_ptr->data[cur_state].bits.pos); - - } else { - pddf_dbg(LED, KERN_ERR "ERROR %s: %s %d state %d; %s not configured\n",__func__, - ops_ptr->device_name, ops_ptr->index, cur_state, _buf); - return (-1); - } - - board_i2c_cpld_write(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset, new_val); - pddf_dbg(LED, KERN_INFO "Set color:%s; 0x%x:0x%x sys_val:0x%x new_val:0x%x read:0x%x\n", - LED_STATUS_STR[cur_state], - ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset, - sys_val, new_val, - ret = board_i2c_cpld_read(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset)); - if (ret < 0) - { - pddf_dbg(LED, KERN_ERR "PDDF_LED ERROR %s: Error %d in reading from cpld(0x%x) offset 0x%x\n", __FUNCTION__, ret, ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset); - return ret; - } - return(ret); + if (sys_val < 0) + return sys_val; + + new_val = (sys_val & ops_ptr->data[cur_state].bits.mask_bits) | + (ops_ptr->data[cur_state].reg_values[0] << ops_ptr->data[cur_state].bits.pos); + + } else { + pddf_dbg(LED, KERN_ERR "ERROR %s: %s %d devtype:%s state %d; %s not configured\n",__func__, + ops_ptr->device_name, ops_ptr->index, ops_ptr->attr_devtype, cur_state, _buf); + return (-1); + } + + if (strcmp(ops_ptr->data[cur_state].attr_devtype, "cpld") == 0) { + ret = board_i2c_cpld_write(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset, new_val); + read_val = board_i2c_cpld_read(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset); + } else if (strcmp(ops_ptr->data[cur_state].attr_devtype, "fpgai2c") == 0) { + ret = board_i2c_fpga_write(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset, (uint8_t)new_val); + read_val = board_i2c_fpga_read(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset); + } else { + pddf_dbg(LED, KERN_ERR "ERROR %s: %s %d devtype:%s not configured\n",__func__, + ops_ptr->device_name, ops_ptr->index, ops_ptr->attr_devtype); + return (-1); + } + +#if DEBUG + pddf_dbg(LED, KERN_INFO "Set color:%s; 0x%x:0x%x sys_val:0x%x new_val:0x%x devtype:%s w_ret:0x%x read:0x%x devtype:%s\n", + LED_STATUS_STR[cur_state], ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset, sys_val, new_val, + cpld_type? "cpld":"fpgai2c", ret, read_val, ops_ptr->data[cur_state].attr_devtype); +#endif + + return(ret); } ssize_t show_pddf_data(struct device *dev, struct device_attribute *da, char *buf) { - int ret = 0; - struct pddf_data_attribute *ptr = (struct pddf_data_attribute *)da; - switch(ptr->type) - { - case PDDF_CHAR: - ret = sprintf(buf, "%s\n", ptr->addr); - break; - case PDDF_INT_DEC: - ret = sprintf(buf, "%d\n", *(int*)(ptr->addr)); - break; - case PDDF_INT_HEX: - ret = sprintf(buf, "0x%x\n", *(int*)(ptr->addr)); - break; - case PDDF_USHORT: - ret = sprintf(buf, "0x%x\n", *(unsigned short *)(ptr->addr)); - break; - case PDDF_UINT32: - ret = sprintf(buf, "0x%x\n", *(uint32_t *)(ptr->addr)); - break; - default: - break; - } + int ret = 0; + struct pddf_data_attribute *ptr = (struct pddf_data_attribute *)da; + switch (ptr->type) + { + case PDDF_CHAR: + ret = sprintf(buf, "%s\n", ptr->addr); + break; + case PDDF_INT_DEC: + ret = sprintf(buf, "%d\n", *(int*)(ptr->addr)); + break; + case PDDF_INT_HEX: + ret = sprintf(buf, "0x%x\n", *(int*)(ptr->addr)); + break; + case PDDF_USHORT: + ret = sprintf(buf, "0x%x\n", *(unsigned short *)(ptr->addr)); + break; + case PDDF_UINT32: + ret = sprintf(buf, "0x%x\n", *(uint32_t *)(ptr->addr)); + break; + default: + break; + } #if DEBUG > 1 - pddf_dbg(LED, "[ READ ] DATA ATTR PTR [%s] TYPE:%d, Value:[%s]\n", - ptr->dev_attr.attr.name, ptr->type, buf); + pddf_dbg(LED, "[ READ ] DATA ATTR PTR [%s] TYPE:%d, Value:[%s]\n", + ptr->dev_attr.attr.name, ptr->type, buf); #endif - return ret; + return ret; } ssize_t store_pddf_data(struct device *dev, struct device_attribute *da, const char *buf, size_t count) { - int ret = 0, num = 0; - struct pddf_data_attribute *ptr = (struct pddf_data_attribute *)da; - switch(ptr->type) - { - case PDDF_CHAR: - strncpy(ptr->addr, buf, strlen(buf)-1); // to discard newline char form buf - ptr->addr[strlen(buf)-1] = '\0'; + int ret = 0, num = 0; + struct pddf_data_attribute *ptr = (struct pddf_data_attribute *)da; + switch (ptr->type) + { + case PDDF_CHAR: + strncpy(ptr->addr, buf, strlen(buf)-1); // to discard newline char form buf + ptr->addr[strlen(buf)-1] = '\0'; #if DEBUG - pddf_dbg(LED, KERN_ERR "[ WRITE ] ATTR PTR [%s] PDDF_CHAR VALUE:%s\n", - ptr->dev_attr.attr.name, ptr->addr); + pddf_dbg(LED, KERN_ERR "[ WRITE ] ATTR PTR [%s] PDDF_CHAR VALUE:%s\n", + ptr->dev_attr.attr.name, ptr->addr); #endif - break; - case PDDF_INT_DEC: - ret = kstrtoint(buf,10,&num); - if (ret==0) - *(int *)(ptr->addr) = num; + break; + case PDDF_INT_DEC: + ret = kstrtoint(buf,10,&num); + if (ret==0) + *(int *)(ptr->addr) = num; #if DEBUG - pddf_dbg(LED, KERN_ERR "[ WRITE ] ATTR PTR [%s] PDDF_DEC VALUE:%d\n", - ptr->dev_attr.attr.name, *(int *)(ptr->addr)); + pddf_dbg(LED, KERN_ERR "[ WRITE ] ATTR PTR [%s] PDDF_DEC VALUE:%d\n", + ptr->dev_attr.attr.name, *(int *)(ptr->addr)); #endif - break; - case PDDF_INT_HEX: - ret = kstrtoint(buf,16,&num); - if (ret==0) - *(int *)(ptr->addr) = num; + break; + case PDDF_INT_HEX: + ret = kstrtoint(buf,16,&num); + if (ret==0) + *(int *)(ptr->addr) = num; #if DEBUG - pddf_dbg(LED, KERN_ERR "[ WRITE ] ATTR PTR [%s] PDDF_HEX VALUE:0x%x\n", - ptr->dev_attr.attr.name, *(int *)(ptr->addr)); + pddf_dbg(LED, KERN_ERR "[ WRITE ] ATTR PTR [%s] PDDF_HEX VALUE:0x%x\n", + ptr->dev_attr.attr.name, *(int *)(ptr->addr)); #endif - break; - case PDDF_USHORT: - ret = kstrtoint(buf,16,&num); - if (ret==0) - *(unsigned short *)(ptr->addr) = (unsigned short)num; + break; + case PDDF_USHORT: + ret = kstrtoint(buf,16,&num); + if (ret==0) + *(unsigned short *)(ptr->addr) = (unsigned short)num; #if DEBUG - pddf_dbg(LED, KERN_ERR "[ WRITE ] ATTR PTR [%s] PDDF_USHORT VALUE:%x\n", - ptr->dev_attr.attr.name, *(unsigned short *)(ptr->addr)); + pddf_dbg(LED, KERN_ERR "[ WRITE ] ATTR PTR [%s] PDDF_USHORT VALUE:%x\n", + ptr->dev_attr.attr.name, *(unsigned short *)(ptr->addr)); #endif - break; - case PDDF_UINT32: - ret = kstrtoint(buf,16,&num); - if (ret==0) - *(uint32_t *)(ptr->addr) = (uint32_t)num; + break; + case PDDF_UINT32: + ret = kstrtoint(buf,16,&num); + if (ret==0) + *(uint32_t *)(ptr->addr) = (uint32_t)num; #if DEBUG - pddf_dbg(LED, KERN_ERR "[ WRITE ] ATTR PTR [%s] PDDF_UINT32 VALUE:%d\n", - ptr->dev_attr.attr.name, *(uint32_t *)(ptr->addr)); + pddf_dbg(LED, KERN_ERR "[ WRITE ] ATTR PTR [%s] PDDF_UINT32 VALUE:%d\n", + ptr->dev_attr.attr.name, *(uint32_t *)(ptr->addr)); #endif - break; - default: - break; - } - return count; + break; + default: + break; + } + return count; } static int load_led_ops_data(struct device_attribute *da, LED_STATUS state) { - struct pddf_data_attribute *_ptr = (struct pddf_data_attribute *)da; - LED_OPS_DATA* ptr=(LED_OPS_DATA*)_ptr->addr; - LED_TYPE led_type; - LED_OPS_DATA* ops_ptr=NULL; - if(!ptr || strlen(ptr->device_name)==0 ) { - pddf_dbg(LED, KERN_INFO "SYSTEM_LED: load_led_ops_data return -1 device_name:%s\n", ptr? ptr->device_name:"NULL"); - return(-1); - } - if(ptr->device_name) + struct pddf_data_attribute *_ptr = (struct pddf_data_attribute *)da; + LED_OPS_DATA* ptr = (LED_OPS_DATA*)_ptr->addr; + LED_TYPE led_type; + LED_OPS_DATA* ops_ptr = NULL; + int i = 0; + char *token = NULL, *value_ptr = NULL; + + if(!ptr || strlen(ptr->device_name)==0 ) { + pddf_dbg(LED, KERN_INFO "SYSTEM_LED: load_led_ops_data return -1 device_name:%s\n", ptr? ptr->device_name:"NULL"); + return(-1); + } + + if(ptr->device_name) { - pddf_dbg(LED, KERN_INFO "[%s]: load_led_ops_data: index=%d addr=0x%x;0x%x valu=0x%x\n", - ptr->device_name, ptr->index, ptr->swpld_addr, ptr->swpld_addr_offset, ptr->data[0].value); - } - if((led_type=get_dev_type(ptr->device_name))==LED_TYPE_MAX) { - pddf_dbg(LED, KERN_ERR "PDDF_LED ERROR *%s Unsupported Led Type\n", __func__); - return(-1); - } - if(dev_index_check(led_type, ptr->index)==-1) { - pddf_dbg(LED, KERN_ERR "PDDF_LED ERROR %s invalid index: %d for type:%d\n", __func__, ptr->index, led_type); - return(-1); - } - ops_ptr = dev_list[led_type]+ptr->index; - - memcpy(ops_ptr->device_name, ptr->device_name, sizeof(ops_ptr->device_name)); - ops_ptr->index = ptr->index; - memcpy(&ops_ptr->data[state], &ptr->data[0], sizeof(LED_DATA)); - ops_ptr->data[state].swpld_addr = ptr->swpld_addr; - ops_ptr->data[state].swpld_addr_offset = ptr->swpld_addr_offset; - ops_ptr->swpld_addr = ptr->swpld_addr; - ops_ptr->swpld_addr_offset = ptr->swpld_addr_offset; - - print_led_data(dev_list[led_type]+ptr->index, state); - - memset(ptr, 0, sizeof(LED_OPS_DATA)); - return (0); + pddf_dbg(LED, KERN_INFO "[%s]: load_led_ops_data: index=%d addr=0x%x;0x%x devtype:%s devname=%s valu=%s\n", + ptr->device_name, ptr->index, ptr->swpld_addr, ptr->swpld_addr_offset, ptr->attr_devtype, ptr->attr_devname, ptr->data[0].value); + } + if((led_type=get_dev_type(ptr->device_name))==LED_TYPE_MAX) { + pddf_dbg(LED, KERN_ERR "PDDF_LED ERROR *%s Unsupported Led Type\n", __func__); + return(-1); + } + if(dev_index_check(led_type, ptr->index)==-1) { + pddf_dbg(LED, KERN_ERR "PDDF_LED ERROR %s invalid index: %d for type:%d\n", __func__, ptr->index, led_type); + return(-1); + } + ops_ptr = dev_list[led_type]+ptr->index; + + memcpy(ops_ptr->device_name, ptr->device_name, sizeof(ops_ptr->device_name)); + ops_ptr->index = ptr->index; + memcpy(&ops_ptr->data[state], &ptr->data[0], sizeof(LED_DATA)); + ops_ptr->data[state].swpld_addr = ptr->swpld_addr; + ops_ptr->data[state].swpld_addr_offset = ptr->swpld_addr_offset; + ops_ptr->swpld_addr = ptr->swpld_addr; + ops_ptr->swpld_addr_offset = ptr->swpld_addr_offset; + memcpy(ops_ptr->data[state].attr_devtype, ptr->attr_devtype, sizeof(ops_ptr->data[state].attr_devtype)); + memcpy(ops_ptr->data[state].attr_devname, ptr->attr_devname, sizeof(ops_ptr->data[state].attr_devname)); + memcpy(ops_ptr->attr_devtype, ptr->attr_devtype, sizeof(ops_ptr->attr_devtype)); + memcpy(ops_ptr->attr_devname, ptr->attr_devname, sizeof(ops_ptr->attr_devname)); +#ifdef __STDC_LIB_EXT1__ + memset_s(ops_ptr->data[state].reg_values, sizeof(ops_ptr->data[state].reg_values), 0xff, sizeof(ops_ptr->data[state].reg_values)); +#else + memset(ops_ptr->data[state].reg_values, 0xff, sizeof(ops_ptr->data[state].reg_values)); +#endif + value_ptr = kzalloc(sizeof(ops_ptr->data[state].value), GFP_KERNEL); + if (value_ptr) { + memcpy(value_ptr, ops_ptr->data[state].value, sizeof(ops_ptr->data[state].value)); + while((token = strsep((char**)&value_ptr,";")) != NULL && i < VALUE_SIZE) { + if (kstrtou8(token, 16, &ops_ptr->data[state].reg_values[i])) { + pddf_dbg(LED, KERN_ERR "load_led_ops_data: [%s] conversion error\n", token); + } + i++; + } + kfree(value_ptr); + } + + print_led_data(dev_list[led_type]+ptr->index, state); + + memset(ptr, 0, sizeof(LED_OPS_DATA)); + return (0); } static int show_led_ops_data(struct device_attribute *da) { - LED_OPS_DATA* ops_ptr=find_led_ops_data(da); - print_led_data(ops_ptr, -1); - return(0); + LED_OPS_DATA* ops_ptr = find_led_ops_data(da); + print_led_data(ops_ptr, -1); + return(0); } static int verify_led_ops_data(struct device_attribute *da) { - struct pddf_data_attribute *_ptr = (struct pddf_data_attribute *)da; - LED_OPS_DATA* ptr=(LED_OPS_DATA*)_ptr->addr; - LED_OPS_DATA* ops_ptr=find_led_ops_data(da); + struct pddf_data_attribute *_ptr = (struct pddf_data_attribute *)da; + LED_OPS_DATA* ptr=(LED_OPS_DATA*)_ptr->addr; + LED_OPS_DATA* ops_ptr=find_led_ops_data(da); - if(ops_ptr) - memcpy(ptr, ops_ptr, sizeof(LED_OPS_DATA)); - else + if(ops_ptr) + memcpy(ptr, ops_ptr, sizeof(LED_OPS_DATA)); + else { - pddf_dbg(LED, "SYSTEM_LED: verify_led_ops_data: Failed to find ops_ptr name:%s; index=%d\n", ptr->device_name, ptr->index); + pddf_dbg(LED, "SYSTEM_LED: verify_led_ops_data: Failed to find ops_ptr name:%s; index=%d\n", ptr->device_name, ptr->index); } - return (0); + return (0); } ssize_t dev_operation(struct device *dev, struct device_attribute *da, const char *buf, size_t count) { #if DEBUG - pddf_dbg(LED, KERN_INFO "dev_operation [%s]\n", buf); + pddf_dbg(LED, KERN_INFO "dev_operation [%s]\n", buf); #endif - if(strstr(buf, "STATUS_LED_COLOR")!= NULL) { - LED_STATUS index = find_state_index(buf); - if (index < MAX_LED_STATUS ) { - load_led_ops_data(da, index); - } else { - printk(KERN_ERR "PDDF_ERROR %s: Invalid state for dev_ops %s", __FUNCTION__, buf); - } - } - else if(strncmp(buf, "show", strlen("show"))==0 ) { - show_led_ops_data(da); - } - else if(strncmp(buf, "verify", strlen("verify"))==0 ) { - verify_led_ops_data(da); - } - else if(strncmp(buf, "get_status", strlen("get_status"))==0 ) { - get_status_led(da); - } - else if(strncmp(buf, "set_status", strlen("set_status"))==0 ) { - set_status_led(da); - } - else { - printk(KERN_ERR "PDDF_ERROR %s: Invalid value for dev_ops %s", __FUNCTION__, buf); - } - return(count); + if(strncmp(buf, "show", strlen("show")) == 0) { + show_led_ops_data(da); + } + else if(strncmp(buf, "verify", strlen("verify")) == 0) { + verify_led_ops_data(da); + } + else if(strncmp(buf, "get_status", strlen("get_status")) == 0) { + get_status_led(da); + } + else if(strncmp(buf, "set_status", strlen("set_status")) == 0) { + set_status_led(da); + } + else { + LED_STATUS index = find_state_index(buf); + if (index < MAX_LED_STATUS) { + load_led_ops_data(da, index); + } else { + printk(KERN_ERR "PDDF_ERROR: %s: Invalid value for dev_ops %s\n", __FUNCTION__, buf); + } + } + return (count); } ssize_t store_config_data(struct device *dev, struct device_attribute *da, const char *buf, size_t count) { - int ret, num; - struct pddf_data_attribute *ptr = (struct pddf_data_attribute *)da; - if(strncmp(ptr->dev_attr.attr.name, "num_psus", strlen("num_psus"))==0 ) { - ret = kstrtoint(buf,10,&num); - if (ret==0) - *(int *)(ptr->addr) = num; - if(psu_led_ops_data == NULL) { - if ((psu_led_ops_data = kzalloc(num * sizeof(LED_OPS_DATA), GFP_KERNEL)) == NULL) { - printk(KERN_ERR "PDDF_LED ERROR failed to allocate memory for PSU LED\n"); - return (count); - } - pddf_dbg(LED, "Allocate PSU LED Memory ADDR=%p\n", psu_led_ops_data); - dev_list[LED_PSU]=psu_led_ops_data; - } + int ret, num; + struct pddf_data_attribute *ptr = (struct pddf_data_attribute *)da; + if(strncmp(ptr->dev_attr.attr.name, "num_psus", strlen("num_psus")) == 0) { + ret = kstrtoint(buf,10,&num); + if (ret==0) + *(int *)(ptr->addr) = num; + if (psu_led_ops_data == NULL) { + if ((psu_led_ops_data = kzalloc(num * sizeof(LED_OPS_DATA), GFP_KERNEL)) == NULL) { + printk(KERN_ERR "PDDF_LED ERROR failed to allocate memory for PSU LED\n"); + return (count); + } + pddf_dbg(LED, "Allocate PSU LED Memory ADDR=%p\n", psu_led_ops_data); + dev_list[LED_PSU]=psu_led_ops_data; + } #if DEBUG pddf_dbg(LED, "[ WRITE ] ATTR CONFIG [%s] VALUE:%d; %d\n", - ptr->dev_attr.attr.name, num, num_psus); + ptr->dev_attr.attr.name, num, num_psus); #endif - return(count); - } - if(strncmp(ptr->dev_attr.attr.name, "num_fantrays", strlen("num_fantrays"))==0 ) { - ret = kstrtoint(buf,10,&num); - if (ret==0) - *(int *)(ptr->addr) = num; - if (fantray_led_ops_data == NULL) { - if ((fantray_led_ops_data = kzalloc(num * sizeof(LED_OPS_DATA), GFP_KERNEL)) == NULL) { - printk(KERN_ERR "PDDF_LED ERROR failed to allocate memory for FANTRAY LED\n"); - return (count); - } - pddf_dbg(LED, "Allocate FanTray LED Memory ADDR=%p\n", fantray_led_ops_data); - dev_list[LED_FANTRAY]=fantray_led_ops_data; - } + return(count); + } + if (strncmp(ptr->dev_attr.attr.name, "num_fantrays", strlen("num_fantrays")) ==0) { + ret = kstrtoint(buf, 10, &num); + if (ret == 0) + *(int *)(ptr->addr) = num; + if (fantray_led_ops_data == NULL) { + if ((fantray_led_ops_data = kzalloc(num * sizeof(LED_OPS_DATA), GFP_KERNEL)) == NULL) { + printk(KERN_ERR "PDDF_LED ERROR failed to allocate memory for FANTRAY LED\n"); + return (count); + } + pddf_dbg(LED, "Allocate FanTray LED Memory ADDR=%p\n", fantray_led_ops_data); + dev_list[LED_FANTRAY]=fantray_led_ops_data; + } #if DEBUG pddf_dbg(LED, "[ WRITE ] ATTR CONFIG [%s] VALUE:%d; %d\n", - ptr->dev_attr.attr.name, num, num_fantrays); + ptr->dev_attr.attr.name, num, num_fantrays); #endif - return(count); - } return (count); + } + return (count); } ssize_t store_bits_data(struct device *dev, struct device_attribute *da, const char *buf, size_t count) { - int len = 0, num1 = 0, num2 = 0, i=0, rc1=0, rc2=0; - char mask=0xFF; - char *pptr=NULL; - char bits[NAME_SIZE]; - struct pddf_data_attribute *ptr = (struct pddf_data_attribute *)da; - MASK_BITS* bits_ptr=(MASK_BITS*)(ptr->addr); - strncpy(bits_ptr->bits, buf, strlen(buf)-1); // to discard newline char form buf - bits_ptr->bits[strlen(buf)-1] = '\0'; - if((pptr=strstr(buf,":")) != NULL) { - len=pptr-buf; + int len = 0, num1 = 0, num2 = 0, i=0, rc1=0, rc2=0; + char mask=0xFF; + char *pptr=NULL; + char bits[NAME_SIZE]; + struct pddf_data_attribute *ptr = (struct pddf_data_attribute *)da; + MASK_BITS* bits_ptr=(MASK_BITS*)(ptr->addr); + strncpy(bits_ptr->bits, buf, strlen(buf)-1); // to discard newline char form buf + bits_ptr->bits[strlen(buf)-1] = '\0'; + if((pptr=strstr(buf,":")) != NULL) { + len = pptr-buf; sprintf(bits, buf); - bits[len]='\0'; - rc1=kstrtoint(bits,16,&num1); - if (rc1==0) + bits[len] = '\0'; + rc1 = kstrtoint(bits, 16, &num1); + if (rc1 == 0) { sprintf(bits, ++pptr); - rc2=kstrtoint(bits,16,&num2); - if (rc2==0) + rc2 = kstrtoint(bits, 16, &num2); + if (rc2 == 0) { for (i=num2; i<=num1; i++) { - mask &= ~(1 << i); + mask &= ~(1 << i); } bits_ptr->mask_bits = mask; bits_ptr->pos = num2; } } - } else { - rc1=kstrtoint(buf,16,&num1); - if (rc1==0) + } else { + rc1 = kstrtoint(buf, 16, &num1); + if (rc1 == 0) { bits_ptr->mask_bits = mask & ~(1 << num1); bits_ptr->pos = num1; } - } + } #if DEBUG - pddf_dbg(LED, KERN_ERR "[ WRITE ] ATTR PTR Bits [%s] VALUE:%s mask:0x%x; pos:0x%x\n", - ptr->dev_attr.attr.name, bits_ptr->bits, bits_ptr->mask_bits, bits_ptr->pos); + pddf_dbg(LED, KERN_ERR "[ WRITE ] ATTR PTR Bits [%s] VALUE:%s mask:0x%x; pos:0x%x\n", + ptr->dev_attr.attr.name, bits_ptr->bits, bits_ptr->mask_bits, bits_ptr->pos); #endif - return (count); + return (count); } /************************************************************************** - * platform/ attributes + * platform/ attributes **************************************************************************/ -PDDF_LED_DATA_ATTR(platform, num_psus, S_IWUSR|S_IRUGO, show_pddf_data, - store_config_data, PDDF_INT_DEC, sizeof(int), (void*)&num_psus); -PDDF_LED_DATA_ATTR(platform, num_fantrays, S_IWUSR|S_IRUGO, show_pddf_data, - store_config_data, PDDF_INT_DEC, sizeof(int), (void*)&num_fantrays); +PDDF_LED_DATA_ATTR(platform, num_psus, S_IWUSR|S_IRUGO, show_pddf_data, + store_config_data, PDDF_INT_DEC, sizeof(int), (void*)&num_psus); +PDDF_LED_DATA_ATTR(platform, num_fantrays, S_IWUSR|S_IRUGO, show_pddf_data, + store_config_data, PDDF_INT_DEC, sizeof(int), (void*)&num_fantrays); struct attribute* attrs_platform[]={ - &pddf_dev_platform_attr_num_psus.dev_attr.attr, - &pddf_dev_platform_attr_num_fantrays.dev_attr.attr, - NULL, + &pddf_dev_platform_attr_num_psus.dev_attr.attr, + &pddf_dev_platform_attr_num_fantrays.dev_attr.attr, + NULL, }; struct attribute_group attr_group_platform={ - .attrs = attrs_platform, + .attrs = attrs_platform, }; /************************************************************************** - * led/ attributes + * led/ attributes **************************************************************************/ -PDDF_LED_DATA_ATTR(dev, device_name, S_IWUSR|S_IRUGO, show_pddf_data, - store_pddf_data, PDDF_CHAR, NAME_SIZE, (void*)&temp_data.device_name); -PDDF_LED_DATA_ATTR(dev, index, S_IWUSR|S_IRUGO, show_pddf_data, - store_pddf_data, PDDF_INT_DEC, sizeof(int), (void*)&temp_data.index); -PDDF_LED_DATA_ATTR(dev, swpld_addr, S_IWUSR|S_IRUGO, show_pddf_data, - store_pddf_data, PDDF_INT_HEX, sizeof(int), (void*)&temp_data.swpld_addr); -PDDF_LED_DATA_ATTR(dev, swpld_addr_offset, S_IWUSR|S_IRUGO, show_pddf_data, - store_pddf_data, PDDF_INT_HEX, sizeof(int), (void*)&temp_data.swpld_addr_offset); -PDDF_LED_DATA_ATTR(dev, dev_ops , S_IWUSR, NULL, - dev_operation, PDDF_CHAR, NAME_SIZE, (void*)&temp_data); - -struct attribute* attrs_dev[]={ - &pddf_dev_dev_attr_device_name.dev_attr.attr, - &pddf_dev_dev_attr_index.dev_attr.attr, - &pddf_dev_dev_attr_swpld_addr.dev_attr.attr, - &pddf_dev_dev_attr_swpld_addr_offset.dev_attr.attr, - &pddf_dev_dev_attr_dev_ops.dev_attr.attr, - NULL, -}; -struct attribute_group attr_group_dev={ - .attrs = attrs_dev, -}; +PDDF_LED_DATA_ATTR(dev, device_name, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_CHAR, NAME_SIZE, (void*)&temp_data.device_name); +PDDF_LED_DATA_ATTR(dev, attr_devtype, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_CHAR, NAME_SIZE, (void*)&temp_data.attr_devtype); +PDDF_LED_DATA_ATTR(dev, attr_devname, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_CHAR, NAME_SIZE, (void*)&temp_data.attr_devname); +PDDF_LED_DATA_ATTR(dev, index, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_INT_DEC, sizeof(int), (void*)&temp_data.index); +PDDF_LED_DATA_ATTR(dev, swpld_addr, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_INT_HEX, sizeof(int), (void*)&temp_data.swpld_addr); +PDDF_LED_DATA_ATTR(dev, swpld_addr_offset, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_INT_HEX, sizeof(int), (void*)&temp_data.swpld_addr_offset); +PDDF_LED_DATA_ATTR(dev, dev_ops , S_IWUSR, NULL, + dev_operation, PDDF_CHAR, NAME_SIZE, (void*)&temp_data); + +struct attribute* attrs_dev[] = { + &pddf_dev_dev_attr_device_name.dev_attr.attr, + &pddf_dev_dev_attr_attr_devtype.dev_attr.attr, + &pddf_dev_dev_attr_attr_devname.dev_attr.attr, + &pddf_dev_dev_attr_index.dev_attr.attr, + &pddf_dev_dev_attr_swpld_addr.dev_attr.attr, + &pddf_dev_dev_attr_swpld_addr_offset.dev_attr.attr, + &pddf_dev_dev_attr_dev_ops.dev_attr.attr, + NULL, +}; + +struct attribute_group attr_group_dev = { + .attrs = attrs_dev, +}; /************************************************************************** - * state_attr/ attributes + * state_attr/ attributes **************************************************************************/ #define LED_DEV_STATE_ATTR_GROUP(name, func) \ - PDDF_LED_DATA_ATTR(name, bits, S_IWUSR|S_IRUGO, show_pddf_data, \ - store_bits_data, PDDF_CHAR, NAME_SIZE, func.bits.bits); \ - PDDF_LED_DATA_ATTR(name, value, S_IWUSR|S_IRUGO, show_pddf_data, \ - store_pddf_data, PDDF_USHORT, sizeof(unsigned short), func.value); \ - struct attribute* attrs_##name[]={ \ - &pddf_dev_##name##_attr_bits.dev_attr.attr, \ - &pddf_dev_##name##_attr_value.dev_attr.attr, \ - NULL, \ - }; \ - struct attribute_group attr_group_##name={ \ - .attrs = attrs_##name, \ - }; \ + PDDF_LED_DATA_ATTR(name, bits, S_IWUSR|S_IRUGO, show_pddf_data, \ + store_bits_data, PDDF_CHAR, NAME_SIZE, func.bits.bits); \ + PDDF_LED_DATA_ATTR(name, value, S_IWUSR|S_IRUGO, show_pddf_data, \ + store_pddf_data, PDDF_CHAR, NAME_SIZE, func.value); \ + struct attribute* attrs_##name[]={ \ + &pddf_dev_##name##_attr_bits.dev_attr.attr, \ + &pddf_dev_##name##_attr_value.dev_attr.attr, \ + NULL, \ + }; \ + struct attribute_group attr_group_##name={ \ + .attrs = attrs_##name, \ + }; \ LED_DEV_STATE_ATTR_GROUP(state_attr, (void*)&temp_data.data[0]) /************************************************************************** - * cur_state/ attributes + * cur_state/ attributes **************************************************************************/ -PDDF_LED_DATA_ATTR(cur_state, color, S_IWUSR|S_IRUGO, show_pddf_data, - store_pddf_data, PDDF_CHAR, NAME_SIZE, (void*)&temp_data.cur_state.color); +PDDF_LED_DATA_ATTR(cur_state, color, S_IWUSR|S_IRUGO, show_pddf_data, + store_pddf_data, PDDF_CHAR, NAME_SIZE, (void*)&temp_data.cur_state.color); -struct attribute* attrs_cur_state[]={ - &pddf_dev_cur_state_attr_color.dev_attr.attr, - NULL, +struct attribute* attrs_cur_state[] = { + &pddf_dev_cur_state_attr_color.dev_attr.attr, + NULL, }; + struct attribute_group attr_group_cur_state={ - .attrs = attrs_cur_state, + .attrs = attrs_cur_state, }; /*************************************************************************/ #define KOBJ_FREE(obj) \ - if(obj) kobject_put(obj); \ + if(obj) kobject_put(obj); \ void free_kobjs(void) { - KOBJ_FREE(cur_state_kobj) - KOBJ_FREE(state_attr_kobj) - KOBJ_FREE(led_kobj) - KOBJ_FREE(platform_kobj) + KOBJ_FREE(cur_state_kobj) + KOBJ_FREE(state_attr_kobj) + KOBJ_FREE(led_kobj) + KOBJ_FREE(platform_kobj) } int KBOJ_CREATE(char* name, struct kobject* parent, struct kobject** child) { - if (parent) { - *child = kobject_create_and_add(name, parent); - } else { - printk(KERN_ERR "PDDF_LED ERROR to create %s kobj; null parent\n", name); - free_kobjs(); - return (-ENOMEM); - } - return (0); + if (parent) { + *child = kobject_create_and_add(name, parent); + } else { + printk(KERN_ERR "PDDF_LED ERROR to create %s kobj; null parent\n", name); + free_kobjs(); + return (-ENOMEM); + } + return (0); } -int LED_DEV_ATTR_CREATE(struct kobject *kobj, const struct attribute_group *attr, const char* name) +int LED_DEV_ATTR_CREATE(struct kobject *kobj, const struct attribute_group *attr, const char* name) { - int status = sysfs_create_group(kobj, attr); - if(status) { - pddf_dbg(LED, KERN_ERR "Driver ERROR: sysfs_create %s failed rc=%d\n", name, status); - } + int status = sysfs_create_group(kobj, attr); + if(status) { + pddf_dbg(LED, KERN_ERR "Driver ERROR: sysfs_create %s failed rc=%d\n", name, status); + } return (status); } static int __init led_init(void) { - struct kobject *device_kobj; - pddf_dbg(LED, KERN_INFO "PDDF GENERIC LED MODULE init..\n"); - - device_kobj = get_device_i2c_kobj(); - if(!device_kobj) - return -ENOMEM; - - KBOJ_CREATE("platform", device_kobj, &platform_kobj); - KBOJ_CREATE("led", device_kobj, &led_kobj); - KBOJ_CREATE("state_attr", led_kobj, &state_attr_kobj); - KBOJ_CREATE("cur_state", led_kobj, &cur_state_kobj); - - LED_DEV_ATTR_CREATE(platform_kobj, &attr_group_platform, "attr_group_platform"); - LED_DEV_ATTR_CREATE(led_kobj, &attr_group_dev, "attr_group_dev"); - LED_DEV_ATTR_CREATE(state_attr_kobj, &attr_group_state_attr, "attr_group_state_attr"); - LED_DEV_ATTR_CREATE(cur_state_kobj, &attr_group_cur_state, "attr_group_cur_state"); - return (0); + struct kobject *device_kobj; + pddf_dbg(LED, KERN_INFO "PDDF GENERIC LED MODULE init..\n"); + + device_kobj = get_device_i2c_kobj(); + if(!device_kobj) + return -ENOMEM; + + KBOJ_CREATE("platform", device_kobj, &platform_kobj); + KBOJ_CREATE("led", device_kobj, &led_kobj); + KBOJ_CREATE("state_attr", led_kobj, &state_attr_kobj); + KBOJ_CREATE("cur_state", led_kobj, &cur_state_kobj); + + LED_DEV_ATTR_CREATE(platform_kobj, &attr_group_platform, "attr_group_platform"); + LED_DEV_ATTR_CREATE(led_kobj, &attr_group_dev, "attr_group_dev"); + LED_DEV_ATTR_CREATE(state_attr_kobj, &attr_group_state_attr, "attr_group_state_attr"); + LED_DEV_ATTR_CREATE(cur_state_kobj, &attr_group_cur_state, "attr_group_cur_state"); + return (0); } static void __exit led_exit(void) { - pddf_dbg(LED, "PDDF GENERIC LED MODULE exit..\n"); - free_kobjs(); - if(psu_led_ops_data) kfree(psu_led_ops_data); - if(fantray_led_ops_data) kfree(fantray_led_ops_data); + pddf_dbg(LED, "PDDF GENERIC LED MODULE exit..\n"); + free_kobjs(); + if(psu_led_ops_data) kfree(psu_led_ops_data); + if(fantray_led_ops_data) kfree(fantray_led_ops_data); } module_init(led_init); diff --git a/platform/pddf/i2c/modules/psu/driver/pddf_psu_api.c b/platform/pddf/i2c/modules/psu/driver/pddf_psu_api.c index b358370f80..99a8eafbaa 100644 --- a/platform/pddf/i2c/modules/psu/driver/pddf_psu_api.c +++ b/platform/pddf/i2c/modules/psu/driver/pddf_psu_api.c @@ -119,7 +119,7 @@ int psu_update_attr(struct device *dev, struct psu_attr_info *data, PSU_DATA_ATT mutex_lock(&data->update_lock); - if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || !data->valid) + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || !data->valid) { dev_dbg(&client->dev, "Starting update for %s\n", data->name); @@ -171,7 +171,7 @@ ssize_t psu_show_default(struct device *dev, struct device_attribute *da, char * { ptr = (PSU_SYSFS_ATTR_DATA *)pdata->psu_attrs[i].access_data; get_psu_duplicate_sysfs(ptr->index , new_str); - if ( strcmp(attr->dev_attr.attr.name, pdata->psu_attrs[i].aname) == 0 || strcmp(attr->dev_attr.attr.name, new_str) == 0 ) + if ( strcmp(attr->dev_attr.attr.name, pdata->psu_attrs[i].aname) == 0 || strcmp(attr->dev_attr.attr.name, new_str) == 0 ) { sysfs_attr_info = &data->attr_info[i]; usr_data = &pdata->psu_attrs[i]; @@ -201,9 +201,12 @@ ssize_t psu_show_default(struct device *dev, struct device_attribute *da, char * return sprintf(buf, "%s\n", sysfs_attr_info->val.strval); break; case PSU_V_OUT: + case PSU_V_OUT_MIN: + case PSU_V_OUT_MAX: case PSU_I_OUT: case PSU_V_IN: case PSU_I_IN: + case PSU_P_OUT_MAX: multiplier = 1000; value = sysfs_attr_info->val.shortval; exponent = two_complement_to_int(value >> 11, 5, 0x1f); @@ -214,6 +217,7 @@ ssize_t psu_show_default(struct device *dev, struct device_attribute *da, char * return sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent)); break; + case PSU_P_IN: case PSU_P_OUT: multiplier = 1000000; value = sysfs_attr_info->val.shortval; @@ -233,9 +237,10 @@ ssize_t psu_show_default(struct device *dev, struct device_attribute *da, char * return sprintf(buf, "%d\n", (mantissa << exponent)); else return sprintf(buf, "%d\n", (mantissa) / (1 << -exponent)); - + break; case PSU_TEMP1_INPUT: + case PSU_TEMP1_HIGH_THRESHOLD: multiplier = 1000; value = sysfs_attr_info->val.shortval; exponent = two_complement_to_int(value >> 11, 5, 0x1f); @@ -244,7 +249,7 @@ ssize_t psu_show_default(struct device *dev, struct device_attribute *da, char * return sprintf(buf, "%d\n", (mantissa << exponent) * multiplier); else return sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent)); - + break; default: printk(KERN_ERR "%s: Unable to find attribute index for %s\n", __FUNCTION__, usr_data->aname); @@ -293,134 +298,36 @@ ssize_t psu_store_default(struct device *dev, struct device_attribute *da, const return count; } -int sonic_i2c_get_psu_present_default(void *client, PSU_DATA_ATTR *adata, void *data) +int sonic_i2c_get_psu_byte_default(void *client, PSU_DATA_ATTR *adata, void *data) { int status = 0; int val = 0; struct psu_attr_info *padata = (struct psu_attr_info *)data; - - - if (strncmp(adata->devtype, "cpld", strlen("cpld")) == 0) - { - val = board_i2c_cpld_read(adata->devaddr , adata->offset); - if (val < 0) - return val; - padata->val.intval = ((val & adata->mask) == adata->cmpval); - psu_dbg(KERN_ERR "%s: status_value = 0x%x\n", __FUNCTION__, padata->val.intval); - } - return status; -} -int sonic_i2c_get_psu_power_good_default(void *client, PSU_DATA_ATTR *adata, void *data) -{ - int status = 0; - int val = 0; - struct psu_attr_info *padata = (struct psu_attr_info *)data; - if (strncmp(adata->devtype, "cpld", strlen("cpld")) == 0) - { + { val = board_i2c_cpld_read(adata->devaddr , adata->offset); if (val < 0) return val; padata->val.intval = ((val & adata->mask) == adata->cmpval); - psu_dbg(KERN_ERR "%s: status_value = 0x%x\n", __FUNCTION__, padata->val.intval); + psu_dbg(KERN_ERR "%s: byte_value = 0x%x\n", __FUNCTION__, padata->val.intval); } return status; } -int sonic_i2c_get_psu_model_name_default(void *client, PSU_DATA_ATTR *adata, void *data) -{ - int status = 0, retry = 10; - struct psu_attr_info *padata = (struct psu_attr_info *)data; - char model[32]=""; //temporary placeholder for model name - uint8_t offset = (uint8_t)adata->offset; - int data_len = adata->len; - - while (retry) - { - status = i2c_smbus_read_i2c_block_data((struct i2c_client *)client, offset, data_len-1, model); - if (unlikely(status<0)) - { - msleep(60); - retry--; - continue; - } - break; - } - - if (status < 0) - { - model[0] = '\0'; - dev_dbg(&((struct i2c_client *)client)->dev, "unable to read model name from (0x%x)\n", ((struct i2c_client *)client)->addr); - } - else - { - model[data_len-1] = '\0'; - } - - if (strncmp(adata->devtype, "pmbus", strlen("pmbus")) == 0) - strncpy(padata->val.strval, model+1, data_len-1); - else - strncpy(padata->val.strval, model, data_len); - - psu_dbg(KERN_ERR "%s: status = %d, model_name : %s\n", __FUNCTION__, status, padata->val.strval); - return 0; -} - -int sonic_i2c_get_psu_mfr_id_default(void *client, PSU_DATA_ATTR *adata, void *data) -{ - - int status = 0, retry = 10; - struct psu_attr_info *padata = (struct psu_attr_info *)data; - char mfr_id[16] = ""; // temporary place holder for mfr_id - uint8_t offset = (uint8_t)adata->offset; - int data_len = adata->len; - - while (retry) - { - status = i2c_smbus_read_i2c_block_data((struct i2c_client *)client, offset, data_len-1, mfr_id); - if (unlikely(status<0)) - { - msleep(60); - retry--; - continue; - } - break; - } - - if (status < 0) - { - mfr_id[0] = '\0'; - dev_dbg(&((struct i2c_client *)client)->dev, "unable to read mfr_id from (0x%x)\n", ((struct i2c_client *)client)->addr); - } - else - { - mfr_id[data_len-1] = '\0'; - } - - if (strncmp(adata->devtype, "pmbus", strlen("pmbus")) == 0) - strncpy(padata->val.strval, mfr_id+1, data_len-1); - else - strncpy(padata->val.strval, mfr_id, data_len); - - psu_dbg(KERN_ERR "%s: status = %d, mfr_id : %s\n", __FUNCTION__, status, padata->val.strval); - return 0; -} - -int sonic_i2c_get_psu_serial_num_default(void *client, PSU_DATA_ATTR *adata, void *data) +int sonic_i2c_get_psu_block_default(void *client, PSU_DATA_ATTR *adata, void *data) { - int status = 0, retry = 10; struct psu_attr_info *padata = (struct psu_attr_info *)data; - char serial[32] = ""; // temporary string to store the serial num + char buf[32]=""; //temporary placeholder for block data uint8_t offset = (uint8_t)adata->offset; int data_len = adata->len; while (retry) { - status = i2c_smbus_read_i2c_block_data((struct i2c_client *)client, offset, data_len-1, serial); + status = i2c_smbus_read_i2c_block_data((struct i2c_client *)client, offset, data_len-1, buf); if (unlikely(status<0)) { msleep(60); @@ -430,190 +337,26 @@ int sonic_i2c_get_psu_serial_num_default(void *client, PSU_DATA_ATTR *adata, voi break; } - if (status < 0) - { - serial[0] = '\0'; - dev_dbg(&((struct i2c_client *)client)->dev, "unable to read serial num from (0x%x)\n", ((struct i2c_client *)client)->addr); - } - else + if (status < 0) { - serial[data_len-1] = '\0'; + buf[0] = '\0'; + dev_dbg(&((struct i2c_client *)client)->dev, "unable to read block of data from (0x%x)\n", ((struct i2c_client *)client)->addr); } - - if (strncmp(adata->devtype, "pmbus", strlen("pmbus")) == 0) - strncpy(padata->val.strval, serial+1, data_len-1); else - strncpy(padata->val.strval, serial, data_len); - - psu_dbg(KERN_ERR "%s: status = %d, serial_num : %s\n", __FUNCTION__, status, padata->val.strval); - return 0; -} - -int sonic_i2c_get_psu_fan_dir_default(void *client, PSU_DATA_ATTR *adata, void *data) -{ - - int status = 0, retry = 10; - struct psu_attr_info *padata = (struct psu_attr_info *)data; - char fan_dir[5] = ""; - uint8_t offset = (uint8_t)adata->offset; - int data_len = adata->len; - - while (retry) { - status = i2c_smbus_read_i2c_block_data((struct i2c_client *)client, offset, data_len-1, fan_dir); - if (unlikely(status<0)) - { - msleep(60); - retry--; - continue; - } - break; - } - - if (status < 0) - { - fan_dir[0] = '\0'; - dev_dbg(&((struct i2c_client *)client)->dev, "unable to read fan_dir from (0x%x)\n", ((struct i2c_client *)client)->addr); - } - else - { - fan_dir[data_len-1] = '\0'; + buf[data_len-1] = '\0'; } if (strncmp(adata->devtype, "pmbus", strlen("pmbus")) == 0) - strncpy(padata->val.strval, fan_dir+1, data_len-1); + strncpy(padata->val.strval, buf+1, data_len-1); else - strncpy(padata->val.strval, fan_dir, data_len); - - psu_dbg(KERN_ERR "%s: status = %d, fan_dir : %s\n", __FUNCTION__, status, padata->val.strval); - return 0; -} - -int sonic_i2c_get_psu_v_out_default(void *client, PSU_DATA_ATTR *adata, void *data) -{ - - int status = 0, retry = 10; - struct psu_attr_info *padata = (struct psu_attr_info *)data; - uint8_t offset = (uint8_t)adata->offset; - - while (retry) { - status = i2c_smbus_read_word_data((struct i2c_client *)client, offset); - if (unlikely(status < 0)) { - msleep(60); - retry--; - continue; - } - break; - } - - if (status < 0) - { - padata->val.shortval = 0; - dev_dbg(&((struct i2c_client *)client)->dev, "unable to read v_out from (0x%x)\n", ((struct i2c_client *)client)->addr); - } - else - { - padata->val.shortval = status; - } - - psu_dbg(KERN_ERR "%s: v_out : %d\n", __FUNCTION__, padata->val.shortval); - return 0; -} - -int sonic_i2c_get_psu_i_out_default(void *client, PSU_DATA_ATTR *adata, void *data) -{ - - int status = 0, retry = 10; - struct psu_attr_info *padata = (struct psu_attr_info *)data; - uint8_t offset = (uint8_t)adata->offset; - - while (retry) { - status = i2c_smbus_read_word_data((struct i2c_client *)client, offset); - if (unlikely(status < 0)) { - msleep(60); - retry--; - continue; - } - break; - } - - if (status < 0) - { - padata->val.shortval = 0; - dev_dbg(&((struct i2c_client *)client)->dev, "unable to read i_out from (0x%x)\n", ((struct i2c_client *)client)->addr); - } - else - { - padata->val.shortval = status; - } - - psu_dbg(KERN_ERR "%s: i_out : %d\n", __FUNCTION__, padata->val.shortval); - return 0; -} - -int sonic_i2c_get_psu_p_out_default(void *client, PSU_DATA_ATTR *adata, void *data) -{ - - int status = 0, retry = 10; - struct psu_attr_info *padata = (struct psu_attr_info *)data; - uint8_t offset = (uint8_t)adata->offset; - - while (retry) { - status = i2c_smbus_read_word_data((struct i2c_client *)client, offset); - if (unlikely(status < 0)) { - msleep(60); - retry--; - continue; - } - break; - } - - if (status < 0) - { - padata->val.shortval = 0; - dev_dbg(&((struct i2c_client *)client)->dev, "unable to read p_out from (0x%x)\n", ((struct i2c_client *)client)->addr); - } - else - { - padata->val.shortval = status; - } - - psu_dbg(KERN_ERR "%s: p_out : %d\n", __FUNCTION__, padata->val.shortval); - return 0; -} - -int sonic_i2c_get_psu_v_in_default(void *client, PSU_DATA_ATTR *adata, void *data) -{ - - int status = 0, retry = 10; - struct psu_attr_info *padata = (struct psu_attr_info *)data; - uint8_t offset = (uint8_t)adata->offset; - - while (retry) { - status = i2c_smbus_read_word_data((struct i2c_client *)client, offset); - if (unlikely(status < 0)) { - msleep(60); - retry--; - continue; - } - break; - } + strncpy(padata->val.strval, buf, data_len); - if (status < 0) - { - padata->val.shortval = 0; - dev_dbg(&((struct i2c_client *)client)->dev, "unable to read v_in from (0x%x)\n", ((struct i2c_client *)client)->addr); - } - else - { - padata->val.shortval = status; - } - - psu_dbg(KERN_ERR "%s: v_in : %d\n", __FUNCTION__, padata->val.shortval); + psu_dbg(KERN_ERR "%s: status = %d, buf block: %s\n", __FUNCTION__, status, padata->val.strval); return 0; } -int sonic_i2c_get_psu_i_in_default(void *client, PSU_DATA_ATTR *adata, void *data) +int sonic_i2c_get_psu_word_default(void *client, PSU_DATA_ATTR *adata, void *data) { int status = 0, retry = 10; @@ -630,78 +373,16 @@ int sonic_i2c_get_psu_i_in_default(void *client, PSU_DATA_ATTR *adata, void *dat break; } - if (status < 0) + if (status < 0) { padata->val.shortval = 0; - dev_dbg(&((struct i2c_client *)client)->dev, "unable to read i_in from (0x%x)\n", ((struct i2c_client *)client)->addr); - } - else - { - padata->val.shortval = status; + dev_dbg(&((struct i2c_client *)client)->dev, "unable to read a word from (0x%x)\n", ((struct i2c_client *)client)->addr); } - - psu_dbg(KERN_ERR "%s: i_in : %d\n", __FUNCTION__, padata->val.shortval); - return 0; -} - -int sonic_i2c_get_psu_fan1_speed_rpm_default(void *client, PSU_DATA_ATTR *adata, void *data) -{ - - int status = 0, retry = 10; - struct psu_attr_info *padata = (struct psu_attr_info *)data; - uint8_t offset = (uint8_t)adata->offset; - - while (retry) { - status = i2c_smbus_read_word_data((struct i2c_client *)client, offset); - if (unlikely(status < 0)) { - msleep(60); - retry--; - continue; - } - break; - } - - if (status < 0) - { - padata->val.shortval = 0; - dev_dbg(&((struct i2c_client *)client)->dev, "unable to read fan1_speed_rpm from (0x%x)\n", ((struct i2c_client *)client)->addr); - } - else - { - padata->val.shortval = status; - } - - psu_dbg(KERN_ERR "%s: fan1_speed_rpm : %d\n", __FUNCTION__, padata->val.shortval); - return 0; -} - -int sonic_i2c_get_psu_temp1_input_default(void *client, PSU_DATA_ATTR *adata, void *data) -{ - - int status = 0, retry = 10; - struct psu_attr_info *padata = (struct psu_attr_info *)data; - uint8_t offset = (uint8_t)adata->offset; - - while (retry) { - status = i2c_smbus_read_word_data((struct i2c_client *)client, offset); - if (unlikely(status < 0)) { - msleep(60); - retry--; - continue; - } - break; - } - - if (status < 0) - { - padata->val.shortval = 0; - dev_dbg(&((struct i2c_client *)client)->dev, "unable to read temp1_input from (0x%x)\n", ((struct i2c_client *)client)->addr); - } - else + else { padata->val.shortval = status; } - psu_dbg(KERN_ERR "%s: temp1_input : %d\n", __FUNCTION__, padata->val.shortval); + psu_dbg(KERN_ERR "%s: word value : %d\n", __FUNCTION__, padata->val.shortval); return 0; } diff --git a/platform/pddf/i2c/modules/psu/driver/pddf_psu_driver.c b/platform/pddf/i2c/modules/psu/driver/pddf_psu_driver.c index dc7edb92a3..bd26f13e9b 100644 --- a/platform/pddf/i2c/modules/psu/driver/pddf_psu_driver.c +++ b/platform/pddf/i2c/modules/psu/driver/pddf_psu_driver.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * - * A pddf kernel module driver for PSU + * A pddf kernel module driver for PSU */ #include @@ -53,45 +53,59 @@ struct pddf_ops_t pddf_psu_ops = { EXPORT_SYMBOL(pddf_psu_ops); -PSU_SYSFS_ATTR_DATA access_psu_present = {PSU_PRESENT, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_present_default, NULL, NULL, NULL, NULL, NULL}; +PSU_SYSFS_ATTR_DATA access_psu_present = {PSU_PRESENT, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_byte_default, NULL, NULL, NULL, NULL, NULL}; EXPORT_SYMBOL(access_psu_present); -PSU_SYSFS_ATTR_DATA access_psu_model_name = {PSU_MODEL_NAME, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_model_name_default, NULL, NULL, NULL, NULL, NULL}; +PSU_SYSFS_ATTR_DATA access_psu_model_name = {PSU_MODEL_NAME, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_block_default, NULL, NULL, NULL, NULL, NULL}; EXPORT_SYMBOL(access_psu_model_name); -PSU_SYSFS_ATTR_DATA access_psu_power_good = {PSU_POWER_GOOD, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_power_good_default, NULL, NULL, NULL, NULL, NULL}; +PSU_SYSFS_ATTR_DATA access_psu_power_good = {PSU_POWER_GOOD, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_byte_default, NULL, NULL, NULL, NULL, NULL}; EXPORT_SYMBOL(access_psu_power_good); -PSU_SYSFS_ATTR_DATA access_psu_mfr_id = {PSU_MFR_ID, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_mfr_id_default, NULL, NULL, NULL, NULL, NULL}; +PSU_SYSFS_ATTR_DATA access_psu_mfr_id = {PSU_MFR_ID, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_block_default, NULL, NULL, NULL, NULL, NULL}; EXPORT_SYMBOL(access_psu_mfr_id); -PSU_SYSFS_ATTR_DATA access_psu_serial_num = {PSU_SERIAL_NUM, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_serial_num_default, NULL, NULL, NULL, NULL, NULL}; +PSU_SYSFS_ATTR_DATA access_psu_serial_num = {PSU_SERIAL_NUM, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_block_default, NULL, NULL, NULL, NULL, NULL}; EXPORT_SYMBOL(access_psu_serial_num); -PSU_SYSFS_ATTR_DATA access_psu_fan_dir = {PSU_FAN_DIR, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_fan_dir_default, NULL, NULL, NULL, NULL, NULL}; +PSU_SYSFS_ATTR_DATA access_psu_fan_dir = {PSU_FAN_DIR, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_block_default, NULL, NULL, NULL, NULL, NULL}; EXPORT_SYMBOL(access_psu_fan_dir); -PSU_SYSFS_ATTR_DATA access_psu_v_out = {PSU_V_OUT, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_v_out_default, NULL, NULL, NULL, NULL, NULL}; +PSU_SYSFS_ATTR_DATA access_psu_v_out = {PSU_V_OUT, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_word_default, NULL, NULL, NULL, NULL, NULL}; EXPORT_SYMBOL(access_psu_v_out); -PSU_SYSFS_ATTR_DATA access_psu_i_out = {PSU_I_OUT, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_i_out_default, NULL, NULL, NULL, NULL, NULL}; +PSU_SYSFS_ATTR_DATA access_psu_v_out_min = {PSU_V_OUT_MIN, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_word_default, NULL, NULL, NULL, NULL, NULL}; +EXPORT_SYMBOL(access_psu_v_out_min); + +PSU_SYSFS_ATTR_DATA access_psu_v_out_max = {PSU_V_OUT_MAX, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_word_default, NULL, NULL, NULL, NULL, NULL}; +EXPORT_SYMBOL(access_psu_v_out_max); + +PSU_SYSFS_ATTR_DATA access_psu_i_out = {PSU_I_OUT, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_word_default, NULL, NULL, NULL, NULL, NULL}; EXPORT_SYMBOL(access_psu_i_out); -PSU_SYSFS_ATTR_DATA access_psu_p_out = {PSU_P_OUT, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_p_out_default, NULL, NULL, NULL, NULL, NULL}; +PSU_SYSFS_ATTR_DATA access_psu_p_out = {PSU_P_OUT, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_word_default, NULL, NULL, NULL, NULL, NULL}; EXPORT_SYMBOL(access_psu_p_out); -PSU_SYSFS_ATTR_DATA access_psu_fan1_speed_rpm = {PSU_FAN1_SPEED, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_fan1_speed_rpm_default, NULL, NULL, NULL, NULL, NULL}; +PSU_SYSFS_ATTR_DATA access_psu_p_out_max = {PSU_P_OUT_MAX, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_word_default, NULL, NULL, NULL, NULL, NULL}; +EXPORT_SYMBOL(access_psu_p_out_max); + +PSU_SYSFS_ATTR_DATA access_psu_fan1_speed_rpm = {PSU_FAN1_SPEED, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_word_default, NULL, NULL, NULL, NULL, NULL}; EXPORT_SYMBOL(access_psu_fan1_speed_rpm); -PSU_SYSFS_ATTR_DATA access_psu_temp1_input = {PSU_TEMP1_INPUT, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_temp1_input_default, NULL, NULL, NULL, NULL, NULL}; +PSU_SYSFS_ATTR_DATA access_psu_temp1_input = {PSU_TEMP1_INPUT, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_word_default, NULL, NULL, NULL, NULL, NULL}; EXPORT_SYMBOL(access_psu_temp1_input); -PSU_SYSFS_ATTR_DATA access_psu_v_in = {PSU_V_IN, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_v_in_default, NULL, NULL, NULL, NULL, NULL}; +PSU_SYSFS_ATTR_DATA access_psu_temp1_high_threshold = {PSU_TEMP1_HIGH_THRESHOLD, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_word_default, NULL, NULL, NULL, NULL, NULL}; +EXPORT_SYMBOL(access_psu_temp1_high_threshold); + +PSU_SYSFS_ATTR_DATA access_psu_v_in = {PSU_V_IN, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_word_default, NULL, NULL, NULL, NULL, NULL}; EXPORT_SYMBOL(access_psu_v_in); -PSU_SYSFS_ATTR_DATA access_psu_i_in = {PSU_I_IN, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_i_in_default, NULL, NULL, NULL, NULL, NULL}; +PSU_SYSFS_ATTR_DATA access_psu_i_in = {PSU_I_IN, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_word_default, NULL, NULL, NULL, NULL, NULL}; EXPORT_SYMBOL(access_psu_i_in); +PSU_SYSFS_ATTR_DATA access_psu_p_in = {PSU_P_IN, S_IRUGO, psu_show_default, NULL, sonic_i2c_get_psu_word_default, NULL, NULL, NULL, NULL, NULL}; +EXPORT_SYMBOL(access_psu_p_in); PSU_SYSFS_ATTR_DATA_ENTRY psu_sysfs_attr_data_tbl[]= { @@ -102,12 +116,17 @@ PSU_SYSFS_ATTR_DATA_ENTRY psu_sysfs_attr_data_tbl[]= { "psu_serial_num" , &access_psu_serial_num}, { "psu_fan_dir" , &access_psu_fan_dir}, { "psu_v_out" , &access_psu_v_out}, + { "psu_v_out_min" , &access_psu_v_out_min}, + { "psu_v_out_max" , &access_psu_v_out_max}, { "psu_i_out" , &access_psu_i_out}, { "psu_p_out" , &access_psu_p_out}, + { "psu_p_out_max" , &access_psu_p_out_max}, { "psu_fan1_speed_rpm" , &access_psu_fan1_speed_rpm}, { "psu_temp1_input" , &access_psu_temp1_input}, - { "psu_v_in" , &access_psu_v_in}, - { "psu_i_in" , &access_psu_i_in} + { "psu_temp1_high_threshold" , &access_psu_temp1_high_threshold}, + { "psu_v_in" , &access_psu_v_in}, + { "psu_i_in" , &access_psu_i_in}, + { "psu_p_in" , &access_psu_p_in} }; void *get_psu_access_data(char *name) @@ -232,7 +251,7 @@ static int psu_probe(struct i2c_client *client, dev_info(&client->dev, "%s: psu '%s'\n", dev_name(data->hwmon_dev), client->name); - + /* Add a support for post probe function */ if (pddf_psu_ops.post_probe) { @@ -293,7 +312,7 @@ static int psu_remove(struct i2c_client *client) printk(KERN_DEBUG "%s: Freeing platform data\n", __FUNCTION__); kfree(platdata); } - + if (pddf_psu_ops.post_remove) { ret = (pddf_psu_ops.post_remove)(client); @@ -364,7 +383,7 @@ int psu_init(void) } EXPORT_SYMBOL(psu_init); -void __exit psu_exit(void) +void psu_exit(void) { pddf_dbg(PSU, "GENERIC_PSU_DRIVER.. exit\n"); if (pddf_psu_ops.pre_exit) (pddf_psu_ops.pre_exit)(); diff --git a/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_api.c b/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_api.c index a7be64328c..18303cc788 100644 --- a/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_api.c +++ b/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_api.c @@ -40,6 +40,10 @@ extern XCVR_SYSFS_ATTR_OPS xcvr_ops[]; extern void *get_device_table(char *name); +extern int (*ptr_fpgapci_read)(uint32_t); +extern int (*ptr_fpgapci_write)(uint32_t, uint32_t); + + int get_xcvr_module_attr_data(struct i2c_client *client, struct device *dev, struct device_attribute *da); @@ -146,6 +150,148 @@ int xcvr_i2c_cpld_write(XCVR_ATTR *info, uint32_t val) return status; } +int xcvr_i2c_fpga_read(XCVR_ATTR *info) +{ + int status = -1; + int retry = 10; + + if (info!=NULL) + { + /* Get the I2C client for the CPLD */ + struct i2c_client *client_ptr=NULL; + client_ptr = (struct i2c_client *)get_device_table(info->devname); + if (client_ptr) + { + if (info->len==1) + { + while(retry) + { + status = i2c_smbus_read_byte_data(client_ptr , info->offset); + if (unlikely(status < 0)) + { + msleep(60); + retry--; + continue; + } + break; + } + } + else if (info->len==2) + { + retry = 10; + while(retry) + { + status = i2c_smbus_read_word_swapped(client_ptr, info->offset); + if (unlikely(status < 0)) + { + msleep(60); + retry--; + continue; + } + break; + } + } + else + printk(KERN_ERR "PDDF_XCVR: Doesn't support block FPGAI2C read yet"); + } + else + printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname); + } + + return status; +} + +int xcvr_i2c_fpga_write(XCVR_ATTR *info, uint32_t val) +{ + int status = 0; + unsigned int val_mask = 0, dnd_value = 0; + uint32_t reg; + struct i2c_client *client_ptr = NULL; + + val_mask = BIT_INDEX(info->mask); + /* Get the I2C client for the CPLD */ + client_ptr = (struct i2c_client *)get_device_table(info->devname); + + if (client_ptr) + { + if (info->len == 1) + status = i2c_smbus_read_byte_data(client_ptr, info->offset); + else if (info->len == 2) + status = i2c_smbus_read_word_swapped(client_ptr, info->offset); + else + { + printk(KERN_ERR "PDDF_XCVR: Doesn't support block FPGAI2C read yet"); + status = -1; + } + } + else + { + printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname); + status = -1; + } + + if (status < 0) + return status; + else + { + msleep(60); + dnd_value = status & ~val_mask; + if (((val == 1) && (info->cmpval != 0)) || ((val == 0) && (info->cmpval == 0))) + reg = dnd_value | val_mask; + else + reg = dnd_value; + if (info->len == 1) + status = i2c_smbus_write_byte_data(client_ptr, info->offset, (uint8_t)reg); + else if (info->len == 2) + status = i2c_smbus_write_word_swapped(client_ptr, info->offset, (uint16_t)reg); + else + { + printk(KERN_ERR "PDDF_XCVR: Doesn't support block FPGAI2C write yet"); + status = -1; + } + } + return status; +} + +int xcvr_fpgapci_read(XCVR_ATTR *info) +{ + int reg_val= 0; + uint32_t offset = 0; + + if (ptr_fpgapci_read == NULL) { + printk(KERN_ERR "PDDF_XCVR: Doesn't support FPGAPCI read yet"); + return (-1); + } + + offset = info->devaddr + info->offset; + reg_val = ptr_fpgapci_read(offset); + return reg_val; +} + +int xcvr_fpgapci_write(XCVR_ATTR *info, uint32_t val) +{ + int status= 0; + uint32_t reg, val_mask = 0, dnd_value = 0, reg_val; + uint32_t offset = 0; + + if (ptr_fpgapci_read == NULL || ptr_fpgapci_write == NULL) { + printk(KERN_ERR "PDDF_XCVR: Doesn't support FPGAPCI read or write yet"); + return (-1); + } + + offset = info->devaddr + info->offset; + val_mask = BIT_INDEX(info->mask); + reg_val = ptr_fpgapci_read(offset); + dnd_value = reg_val & ~val_mask; + + if (((val == 1) && (info->cmpval != 0)) || ((val == 0) && (info->cmpval == 0))) + reg = dnd_value | val_mask; + else + reg = dnd_value; + + status = ptr_fpgapci_write(offset, reg); + return status; +} int sonic_i2c_get_mod_pres(struct i2c_client *client, XCVR_ATTR *info, struct xcvr_data *data) { @@ -164,6 +310,31 @@ int sonic_i2c_get_mod_pres(struct i2c_client *client, XCVR_ATTR *info, struct xc sfp_dbg(KERN_INFO "\nMod presence :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset); } } + else if ( strcmp(info->devtype, "fpgai2c") == 0) + { + status = xcvr_i2c_fpga_read(info); + + if (status < 0) + return status; + else + { + modpres = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0; + sfp_dbg(KERN_INFO "\nMod presence :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset); + } + } + else if ( strcmp(info->devtype, "fpgapci") == 0) + { + status = xcvr_fpgapci_read(info); + + if (status < 0) + return status; + else + { + modpres = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0; + sfp_dbg(KERN_INFO "\nMod presence :0x%x, status= 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset); + } + } + else if(strcmp(info->devtype, "eeprom") == 0) { /* get client client for eeprom - Not Applicable */ @@ -189,6 +360,30 @@ int sonic_i2c_get_mod_reset(struct i2c_client *client, XCVR_ATTR *info, struct x sfp_dbg(KERN_INFO "\nMod Reset :0x%x, reg_value = 0x%x\n", modreset, status); } } + else if ( strcmp(info->devtype, "fpgai2c") == 0) + { + status = xcvr_i2c_fpga_read(info); + + if (status < 0) + return status; + else + { + modreset = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0; + sfp_dbg(KERN_INFO "\nMod reset :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset); + } + } + else if ( strcmp(info->devtype, "fpgapci") == 0) + { + status = xcvr_fpgapci_read(info); + sfp_dbg(KERN_INFO "\n[%s] status=%x\n", __FUNCTION__, status); + if (status < 0) + return status; + else + { + modreset = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0; + sfp_dbg(KERN_INFO "\nMod reset :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modreset, status, info->devaddr, info->mask, info->offset); + } + } else if(strcmp(info->devtype, "eeprom") == 0) { /* get client client for eeprom - Not Applicable */ @@ -214,6 +409,31 @@ int sonic_i2c_get_mod_intr_status(struct i2c_client *client, XCVR_ATTR *info, st sfp_dbg(KERN_INFO "\nModule Interrupt :0x%x, reg_value = 0x%x\n", mod_intr, status); } } + else if ( strcmp(info->devtype, "fpgai2c") == 0) + { + status = xcvr_i2c_fpga_read(info); + + if (status < 0) + return status; + else + { + mod_intr = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0; + sfp_dbg(KERN_INFO "\nModule Interrupt :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset); + } + } + else if ( strcmp(info->devtype, "fpgapci") == 0) + { + status = xcvr_fpgapci_read(info); + sfp_dbg(KERN_INFO "\n[%s] status=%x\n", __FUNCTION__, status); + if (status < 0) + return status; + else + { + mod_intr = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0; + sfp_dbg(KERN_INFO "\nModule Interrupt :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", mod_intr, status, info->devaddr, info->mask, info->offset); + } + } + else if(strcmp(info->devtype, "eeprom") == 0) { /* get client client for eeprom - Not Applicable */ @@ -240,6 +460,30 @@ int sonic_i2c_get_mod_lpmode(struct i2c_client *client, XCVR_ATTR *info, struct sfp_dbg(KERN_INFO "\nModule LPmode :0x%x, reg_value = 0x%x\n", lpmode, status); } } + else if ( strcmp(info->devtype, "fpgai2c") == 0) + { + status = xcvr_i2c_fpga_read(info); + + if (status < 0) + return status; + else + { + lpmode = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0; + sfp_dbg(KERN_INFO "\nModule LPmode :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset); + } + } + else if ( strcmp(info->devtype, "fpgapci") == 0) + { + status = xcvr_fpgapci_read(info); + sfp_dbg(KERN_INFO "\n[%s] status=%x\n", __FUNCTION__, status); + if (status < 0) + return status; + else + { + lpmode = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0; + sfp_dbg(KERN_INFO "\nlpmode :0x%x, reg_val = 0x%x, op=0x%x, mask=0x%x, offset=0x%x\n", lpmode, status, status & BIT_INDEX(info->mask), info->mask, info->offset); + } + } else if (strcmp(info->devtype, "eeprom") == 0) { /* get client client for eeprom - Not Applicable */ @@ -266,6 +510,18 @@ int sonic_i2c_get_mod_rxlos(struct i2c_client *client, XCVR_ATTR *info, struct x sfp_dbg(KERN_INFO "\nModule RxLOS :0x%x, reg_value = 0x%x\n", rxlos, status); } } + else if ( strcmp(info->devtype, "fpgai2c") == 0) + { + status = xcvr_i2c_fpga_read(info); + + if (status < 0) + return status; + else + { + rxlos = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0; + sfp_dbg(KERN_INFO "\nModule RxLOS :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset); + } + } data->rxlos = rxlos; return 0; @@ -287,6 +543,18 @@ int sonic_i2c_get_mod_txdisable(struct i2c_client *client, XCVR_ATTR *info, stru sfp_dbg(KERN_INFO "\nModule TxDisable :0x%x, reg_value = 0x%x\n", txdis, status); } } + else if ( strcmp(info->devtype, "fpgai2c") == 0) + { + status = xcvr_i2c_fpga_read(info); + + if (status < 0) + return status; + else + { + txdis = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0; + sfp_dbg(KERN_INFO "\nModule TxDisable :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset); + } + } data->txdisable = txdis; return 0; @@ -309,6 +577,18 @@ int sonic_i2c_get_mod_txfault(struct i2c_client *client, XCVR_ATTR *info, struct } } + else if ( strcmp(info->devtype, "fpgai2c") == 0) + { + status = xcvr_i2c_fpga_read(info); + + if (status < 0) + return status; + else + { + txflt = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0; + sfp_dbg(KERN_INFO "\nModule Txfault :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset); + } + } data->txfault = txflt; return 0; @@ -322,6 +602,14 @@ int sonic_i2c_set_mod_reset(struct i2c_client *client, XCVR_ATTR *info, struct x { status = xcvr_i2c_cpld_write(info, data->reset); } + else if (strcmp(info->devtype, "fpgai2c") == 0) + { + status = xcvr_i2c_fpga_write(info, data->reset); + } + else if (strcmp(info->devtype, "fpgapci") == 0) + { + status = xcvr_fpgapci_write(info, data->reset); + } else { printk(KERN_ERR "Error: Invalid device type (%s) to set xcvr reset\n", info->devtype); @@ -339,6 +627,14 @@ int sonic_i2c_set_mod_lpmode(struct i2c_client *client, XCVR_ATTR *info, struct { status = xcvr_i2c_cpld_write(info, data->lpmode); } + else if (strcmp(info->devtype, "fpgai2c") == 0) + { + status = xcvr_i2c_fpga_write(info, data->lpmode); + } + else if (strcmp(info->devtype, "fpgapci") == 0) + { + status = xcvr_fpgapci_write(info, data->lpmode); + } else { printk(KERN_ERR "Error: Invalid device type (%s) to set xcvr lpmode\n", info->devtype); @@ -356,6 +652,10 @@ int sonic_i2c_set_mod_txdisable(struct i2c_client *client, XCVR_ATTR *info, stru { status = xcvr_i2c_cpld_write(info, data->txdisable); } + else if (strcmp(info->devtype, "fpgai2c") == 0) + { + status = xcvr_i2c_fpga_write(info, data->txdisable); + } else { printk(KERN_ERR "Error: Invalid device type (%s) to set xcvr txdisable\n", info->devtype); diff --git a/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_driver.c b/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_driver.c index 7ce1bca94b..be4a01acf1 100644 --- a/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_driver.c +++ b/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_driver.c @@ -278,7 +278,7 @@ int xcvr_init(void) } EXPORT_SYMBOL(xcvr_init); -void __exit xcvr_exit(void) +void xcvr_exit(void) { pddf_dbg(XCVR, "PDDF XCVR DRIVER.. exit\n"); if (pddf_xcvr_ops.pre_exit) (pddf_xcvr_ops.pre_exit)(); @@ -288,9 +288,9 @@ void __exit xcvr_exit(void) } EXPORT_SYMBOL(xcvr_exit); +module_init(xcvr_init); +module_exit(xcvr_exit); + MODULE_AUTHOR("Broadcom"); MODULE_DESCRIPTION("Driver for transceiver operations"); MODULE_LICENSE("GPL"); - -module_init(xcvr_init); -module_exit(xcvr_exit); diff --git a/platform/pddf/i2c/utils/pddf_util.py b/platform/pddf/i2c/utils/pddf_util.py index d3ee5e43ac..7943f8b77f 100755 --- a/platform/pddf/i2c/utils/pddf_util.py +++ b/platform/pddf/i2c/utils/pddf_util.py @@ -203,7 +203,9 @@ def config_pddf_utils(): if not os.path.exists(SONIC_PLATFORM_BSP_WHL_PKG_BK): # bsp 2.0 classes are installed. Take a backup and copy pddf 2.0 whl pkg log_os_system('mv '+SONIC_PLATFORM_BSP_WHL_PKG+' '+SONIC_PLATFORM_BSP_WHL_PKG_BK, 1) + log_os_system('sync', 1) shutil.copy(SONIC_PLATFORM_PDDF_WHL_PKG, SONIC_PLATFORM_BSP_WHL_PKG) + log_os_system('sync', 1) # uninstall the existing bsp whl pkg status, output = log_os_system("pip3 uninstall sonic-platform -y &> /dev/null", 1) if status: @@ -328,6 +330,7 @@ def create_pddf_log_files(): log_os_system("sudo touch /var/log/pddf/cpldmux.txt", 1) log_os_system("sudo touch /var/log/pddf/client.txt", 1) log_os_system("sudo touch /var/log/pddf/mux.txt", 1) + log_os_system("sudo touch /var/log/pddf/fpgapci.txt", 1) def driver_install(): global FORCE diff --git a/platform/pddf/i2c/utils/pddfparse.py b/platform/pddf/i2c/utils/pddfparse.py index 1a5774f44f..70f2b4e017 100755 --- a/platform/pddf/i2c/utils/pddfparse.py +++ b/platform/pddf/i2c/utils/pddfparse.py @@ -18,19 +18,6 @@ dirname = os.path.dirname(os.path.realpath(__file__)) -color_map = { - "STATUS_LED_COLOR_GREEN" : "green", - "STATUS_LED_COLOR_RED" : "red", - "STATUS_LED_COLOR_AMBER" : "amber", - "STATUS_LED_COLOR_BLUE" : "blue", - "STATUS_LED_COLOR_GREEN_BLINK" : "blinking green", - "STATUS_LED_COLOR_RED_BLINK" : "blinking red", - "STATUS_LED_COLOR_AMBER_BLINK" : "blinking amber", - "STATUS_LED_COLOR_BLUE_BLINK" : "blinking blue", - "STATUS_LED_COLOR_OFF" : "off" -} - - class PddfParse(): def __init__(self): if not os.path.exists("/usr/share/sonic/platform"): @@ -128,7 +115,7 @@ def get_led_color(self): except IOError: return ("Error") - return (color_map[color]) + return (color) ################################################################################################################### # CREATE DEFS @@ -262,6 +249,30 @@ def create_cpld_device(self, dev, ops): return create_ret.append(ret) + def create_fpgai2c_device(self, dev, ops): + create_ret = [] + ret = 0 + if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['FPGAI2C']: + ret = self.create_device(dev['i2c']['topo_info'], "pddf/devices/fpgai2c", ops) + if ret!=0: + return create_ret.append(ret) + + cmd= "echo '%s' > /sys/kernel/pddf/devices/fpgai2c/i2c_name"%(dev['dev_info']['device_name']) + ret = self.runcmd(cmd) + if ret!=0: + return create_ret.append(ret) + cmd= "echo 'add' > /sys/kernel/pddf/devices/fpgai2c/dev_ops" + ret = self.runcmd(cmd) + if ret!=0: + return create_ret.append(ret) + else: + cmd= "echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'], int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) + ret = self.runcmd(cmd) + if ret!=0: + return create_ret.append(ret) + + return create_ret.append(ret) + def create_cpldmux_device(self, dev, ops): create_ret = [] ret = 0 @@ -436,7 +447,19 @@ def create_eeprom_device(self, dev, ops): return create_ret.append(ret) - ################################################################################################################### + def create_fpgapci_device(self, dev, ops): + create_ret = [] + ret = 0 + ret = self.create_device(dev['i2c']['dev_attr'], "pddf/devices/fpgapci", ops) + if ret!=0: + return create_ret.append(ret) + + cmd = "echo 'fpgapci_init' > /sys/kernel/pddf/devices/fpgapci/dev_ops" + ret = self.runcmd(cmd) + return create_ret.append(ret) + + + ################################################################################################################################# # DELETE DEFS ################################################################################################################### def delete_eeprom_device(self, dev, ops): @@ -494,6 +517,16 @@ def delete_cpld_device(self, dev, ops): int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) self.runcmd(cmd) + def delete_fpgai2c_device(self, dev, ops): + if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['FPGAI2C']: + cmd= "echo '%s' > /sys/kernel/pddf/devices/fpgai2c/i2c_name"%(dev['dev_info']['device_name']) + self.runcmd(cmd) + cmd= "echo 'delete' > /sys/kernel/pddf/devices/fpgai2c/dev_ops" + self.runcmd(cmd) + else: + cmd= "echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device" % (int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) + self.runcmd(cmd) + def delete_cpldmux_device(self, dev, ops): if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['CPLDMUX']: cmd = "echo '%s' > /sys/kernel/pddf/devices/cpldmux/i2c_name" % (dev['dev_info']['device_name']) @@ -534,7 +567,9 @@ def delete_psu_device(self, dev, ops): self.delete_psu_i2c_device(dev, ops) return - ################################################################################################################### + def delete_fpgapci_device(self, dev, ops): + return + ################################################################################################################################# # SHOW ATTRIBIUTES DEFS ################################################################################################################### def is_led_device_configured(self, device_name, attr_name): @@ -844,8 +879,8 @@ def dump_sysfs_obj(self, obj, key_type): for entry in obj[key]: print("\t"+entry) - def add_list_sysfs_obj(self, obj, KEY, list): - for sysfs in list: + def add_list_sysfs_obj(self, obj, KEY, extra_list): + for sysfs in extra_list: if not sysfs in obj[KEY]: obj[KEY].append(sysfs) @@ -854,11 +889,12 @@ def sysfs_attr(self, key, value, path, obj, obj_key): if not sysfs_path in obj[obj_key]: obj[obj_key].append(sysfs_path) - def sysfs_device(self, attr, path, obj, obj_key): + def sysfs_device(self, attr, path, obj, obj_key, exceptions=[]): for key in attr.keys(): - sysfs_path = "/sys/kernel/%s/%s" % (path, key) - if not sysfs_path in obj[obj_key]: - obj[obj_key].append(sysfs_path) + if key not in exceptions: + sysfs_path = "/sys/kernel/%s/%s" % (path, key) + if not sysfs_path in obj[obj_key]: + obj[obj_key].append(sysfs_path) def show_eeprom_device(self, dev, ops): return @@ -868,14 +904,14 @@ def show_mux_device(self, dev, ops): if not KEY in self.sysfs_obj: self.sysfs_obj[KEY] = [] self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/mux", self.sysfs_obj, KEY) - self.sysfs_device(dev['i2c']['dev_attr'], "pddf/devices/mux", self.sysfs_obj, KEY) + self.sysfs_device(dev['i2c']['dev_attr'], "pddf/devices/mux", self.sysfs_obj, KEY, ['idle_state']) sysfs_path = "/sys/kernel/pddf/devices/mux/dev_ops" if not sysfs_path in self.sysfs_obj[KEY]: self.sysfs_obj[KEY].append(sysfs_path) - list = ['/sys/kernel/pddf/devices/mux/i2c_type', + extra_list = ['/sys/kernel/pddf/devices/mux/i2c_type', '/sys/kernel/pddf/devices/mux/i2c_name', '/sys/kernel/pddf/devices/mux/error'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) + self.add_list_sysfs_obj(self.sysfs_obj, KEY, extra_list) def show_gpio_device(self, dev, ops): KEY = 'gpio' @@ -886,10 +922,10 @@ def show_gpio_device(self, dev, ops): sysfs_path = "/sys/kernel/pddf/devices/gpio/dev_ops" if not sysfs_path in self.sysfs_obj[KEY]: self.sysfs_obj[KEY].append(sysfs_path) - list = ['/sys/kernel/pddf/devices/gpio/i2c_type', + extra_list = ['/sys/kernel/pddf/devices/gpio/i2c_type', '/sys/kernel/pddf/devices/gpio/i2c_name', '/sys/kernel/pddf/devices/gpio/error'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) + self.add_list_sysfs_obj(self.sysfs_obj, KEY, extra_list) def show_psu_i2c_device(self, dev, ops): KEY = 'psu' @@ -906,12 +942,11 @@ def show_psu_i2c_device(self, dev, ops): sysfs_path = "/sys/kernel/pddf/devices/psu/i2c/dev_ops" if not sysfs_path in self.sysfs_obj[KEY]: self.sysfs_obj[KEY].append(sysfs_path) - list = ['/sys/kernel/pddf/devices/psu/i2c/i2c_type', + extra_list = ['/sys/kernel/pddf/devices/psu/i2c/i2c_type', '/sys/kernel/pddf/devices/fan/i2c/i2c_name', '/sys/kernel/pddf/devices/psu/i2c/error', '/sys/kernel/pddf/devices/psu/i2c/attr_ops'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) - + self.add_list_sysfs_obj(self.sysfs_obj, KEY, extra_list) def show_psu_device(self, dev, ops): self.show_psu_i2c_device(dev, ops) @@ -921,8 +956,8 @@ def show_client_device(self): KEY = 'client' if not KEY in self.sysfs_obj: self.sysfs_obj[KEY] = [] - list = ['/sys/kernel/pddf/devices/showall'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) + extra_list = ['/sys/kernel/pddf/devices/showall'] + self.add_list_sysfs_obj(self.sysfs_obj, KEY, extra_list) def show_fan_device(self, dev, ops): KEY = 'fan' @@ -931,16 +966,16 @@ def show_fan_device(self, dev, ops): if not KEY in self.sysfs_obj: self.sysfs_obj[KEY] = [] - self.sysfs_device(dev['i2c']['topo_info'], path, self.sysfs_obj, KEY) + self.sysfs_device(dev['i2c']['topo_info'], path, self.sysfs_obj, KEY, ['client_type']) self.sysfs_device(dev['i2c']['dev_attr'], path, self.sysfs_obj, KEY) for attr in dev['i2c']['attr_list']: self.sysfs_device(attr, path, self.sysfs_obj, KEY) - list = ['/sys/kernel/pddf/devices/fan/i2c/i2c_type', + extra_list = ['/sys/kernel/pddf/devices/fan/i2c/i2c_type', '/sys/kernel/pddf/devices/fan/i2c/i2c_name', '/sys/kernel/pddf/devices/fan/i2c/error', '/sys/kernel/pddf/devices/fan/i2c/attr_ops', '/sys/kernel/pddf/devices/fan/i2c/dev_ops'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) + self.add_list_sysfs_obj(self.sysfs_obj, KEY, extra_list) def show_temp_sensor_device(self, dev, ops): return @@ -960,18 +995,18 @@ def show_xcvr_i2c_device(self, dev, ops): if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PORT_MODULE']: if not KEY in self.sysfs_obj: self.sysfs_obj[KEY] = [] - self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/xcvr/i2c", self.sysfs_obj, KEY) + self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/xcvr/i2c", self.sysfs_obj, KEY, ['client_type']) for attr in dev['i2c']['attr_list']: self.sysfs_device(attr, "pddf/devices/xcvr/i2c", self.sysfs_obj, KEY) sysfs_path = "/sys/kernel/pddf/devices/xcvr/i2c/dev_ops" if not sysfs_path in self.sysfs_obj[KEY]: self.sysfs_obj[KEY].append(sysfs_path) - list = ['/sys/kernel/pddf/devices/xcvr/i2c/i2c_type', + extra_list = ['/sys/kernel/pddf/devices/xcvr/i2c/i2c_type', '/sys/kernel/pddf/devices/xcvr/i2c/i2c_name', '/sys/kernel/pddf/devices/xcvr/i2c/error', '/sys/kernel/pddf/devices/xcvr/i2c/attr_ops'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) + self.add_list_sysfs_obj(self.sysfs_obj, KEY, extra_list) def show_xcvr_device(self, dev, ops): self.show_xcvr_i2c_device(dev, ops) @@ -986,10 +1021,25 @@ def show_cpld_device(self, dev, ops): sysfs_path = "/sys/kernel/pddf/devices/cpld/dev_ops" if not sysfs_path in self.sysfs_obj[KEY]: self.sysfs_obj[KEY].append(sysfs_path) - list = ['/sys/kernel/pddf/devices/cpld/i2c_type', + extra_list = ['/sys/kernel/pddf/devices/cpld/i2c_type', '/sys/kernel/pddf/devices/cpld/i2c_name', '/sys/kernel/pddf/devices/cpld/error'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) + self.add_list_sysfs_obj(self.sysfs_obj, KEY, extra_list) + + def show_fpgai2c_device(self, dev, ops): + KEY ='fpgai2c' + if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['FPGAI2C']: + if not KEY in self.sysfs_obj: + self.sysfs_obj[KEY] = [] + self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/fpgai2c", self.sysfs_obj, KEY) + sysfs_path = "/sys/kernel/pddf/devices/fpgai2c/dev_ops" + if not sysfs_path in self.sysfs_obj[KEY]: + self.sysfs_obj[KEY].append(sysfs_path) + extra_list = ['/sys/kernel/pddf/devices/fpgai2c/i2c_type', + '/sys/kernel/pddf/devices/fpgai2c/i2c_name', + '/sys/kernel/pddf/devices/fpgai2c/error'] + self.add_list_sysfs_obj(self.sysfs_obj, KEY, extra_list) + def show_led_platform_device(self, key, ops): if ops['attr'] == 'all' or ops['attr'] == 'PLATFORM': @@ -1006,21 +1056,36 @@ def show_led_device(self, key, ops): if not KEY in self.sysfs_obj: self.sysfs_obj[KEY] = [] path="pddf/devices/led" - for attr in self.data[key]['i2c']['attr_list']: - self.sysfs_attr('device_name', self.data[key]['dev_info']['device_name'],path,self.sysfs_obj,KEY) - self.sysfs_attr('swpld_addr', self.data[key]['dev_info']['device_name'],path,self.sysfs_obj, KEY) - self.sysfs_attr('swpld_addr_offset',self.data[key]['dev_info']['device_name'], - path,self.sysfs_obj, KEY) - self.sysfs_device(self.data[key]['dev_attr'], path, self.sysfs_obj, KEY) - for attr_key in attr.keys(): - attr_path = "pddf/devices/led/" + attr['attr_name'] - if (attr_key != 'attr_name' and attr_key != 'swpld_addr' and attr_key != 'swpld_addr_offset'): - self.sysfs_attr(attr_key, attr[attr_key], attr_path, self.sysfs_obj, KEY) + self.sysfs_attr('device_name', self.data[key]['dev_info']['device_name'], path, self.sysfs_obj, KEY) + self.sysfs_attr('swpld_addr', self.data[key]['dev_info']['device_name'], path, self.sysfs_obj, KEY) + self.sysfs_attr('swpld_addr_offset', self.data[key]['dev_info']['device_name'], path, self.sysfs_obj, KEY) + state_attr_path="pddf/devices/led/state_attr" + self.sysfs_attr('bits', self.data[key]['dev_info']['device_name'], state_attr_path, self.sysfs_obj, KEY) + self.sysfs_attr('value', self.data[key]['dev_info']['device_name'], state_attr_path, self.sysfs_obj, KEY) sysfs_path="/sys/kernel/pddf/devices/led/dev_ops" if not sysfs_path in self.sysfs_obj[KEY]: self.sysfs_obj[KEY].append(sysfs_path) - list=['/sys/kernel/pddf/devices/led/cur_state/color'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) + extra_list=['/sys/kernel/pddf/devices/led/cur_state/color'] + self.add_list_sysfs_obj(self.sysfs_obj, KEY, extra_list) + + + def show_fpgapci_device(self, dev, ops): + KEY ='fpgapci' + if dev['dev_info']['device_type'] in self.data['PLATFORM']['pddf_dev_types']['FPGAPCIE']: + if not KEY in self.sysfs_obj: + self.sysfs_obj[KEY] = [] + sysfs_path = "/sys/kernel/pddf/devices/fpgapci" + if not sysfs_path in self.sysfs_obj[KEY]: + self.sysfs_obj[KEY].append(sysfs_path) + extra_list = ['/sys/kernel/pddf/devices/fpgapci/vendor_id', + '/sys/kernel/pddf/devices/fpgapci/virt_bus', + '/sys/kernel/pddf/devices/fpgapci/device_id', + '/sys/kernel/pddf/devices/fpgapci/data_base_offset', + '/sys/kernel/pddf/devices/fpgapci/data_size', + '/sys/kernel/pddf/devices/fpgapci/i2c_ch_base_offset', + '/sys/kernel/pddf/devices/fpgapci/i2c_ch_size', + '/sys/kernel/pddf/devices/fpgapci/virt_i2c_ch'] + self.add_list_sysfs_obj(self.sysfs_obj, KEY, extra_list) def validate_xcvr_device(self, dev, ops): @@ -1059,7 +1124,7 @@ def validate_eeprom_device(self, dev, ops): print(ret_val) def validate_mux_device(self, dev, ops): - devtype_list = ['pca9548', 'pca954x'] + devtype_list = ['pca9548', 'pca9545', 'pca9546', 'pca954x'] dev_channels = ["0", "1", "2", "3", "4", "5", "6", "7"] ret_val = "mux failed" @@ -1077,6 +1142,13 @@ def validate_cpld_device(self, dev, ops): ret_val = "cpld success" print(ret_val) + def validate_fpgai2c_device(self, dev, ops): + devtype_list = ['i2c_fpga'] + ret_val = "fpgai2c failed" + + if dev['i2c']['topo_info']['dev_type'] in devtype_list: + ret_val = "fpgai2c success" + print(ret_val) def validate_sysstatus_device(self, dev, ops): dev_attribs = ['board_info', 'cpld1_version', 'power_module_status', 'system_reset5', @@ -1284,7 +1356,7 @@ def modules_validation(self, validate_type): else: print("Loaded") else: - print(validate_type + " not configured" ) + print(validate_type + " not configured") @@ -1530,7 +1602,28 @@ def cpu_parse_reverse(self, bus, ops): val.extend(ret) return val + def fpgapci_parse(self, dev, ops): + val = [] + ret = getattr(self, ops['cmd']+"_fpgapci_device")(dev, ops) + if ret: + if str(ret[0]).isdigit(): + if ret[0]!=0: + # in case if 'create' functions + print("{}_fpgapci_device() cmd failed".format(ops['cmd'])) + return ret + else: + val.extend(ret) + for bus in dev['i2c']['channel']: + ret = self.dev_parse(self.data[bus['dev']], ops) + if ret: + if str(ret[0]).isdigit(): + if ret[0]!=0: + # in case if 'create' functions + return ret + else: + val.extend(ret) + return val # 'create' and 'show_attr' ops returns an array # 'delete', 'show' and 'validate' ops return None @@ -1542,6 +1635,9 @@ def dev_parse(self, dev, ops): else: return self.cpu_parse(dev, ops) + if attr['device_type'] == 'FPGAPCIE': + return self.fpgapci_parse(dev, ops) + if attr['device_type'] == 'EEPROM': return self.eeprom_parse(dev, ops) @@ -1568,6 +1664,9 @@ def dev_parse(self, dev, ops): attr['device_type'] == 'QSFP-DD': return self.optic_parse(dev, ops) + if attr['device_type'] == 'FPGAI2C': + return self.fpgai2c_parse(dev, ops) + if attr['device_type'] == 'CPLD': return self.cpld_parse(dev, ops) @@ -1589,9 +1688,10 @@ def is_supported_sysled_state(self, sysled_name, sysled_state): return False, "[FAILED]: Invalid color" - def create_attr(self, key, value, path): - cmd = "echo '%s' > /sys/kernel/%s/%s" % (value, path, key) - self.runcmd(cmd) + def create_attr(self, key, value, path, exceptions=[]): + if key not in exceptions: + cmd = "echo '%s' > /sys/kernel/%s/%s" % (value, path, key) + self.runcmd(cmd) def create_led_platform_device(self, key, ops): if ops['attr'] == 'all' or ops['attr'] == 'PLATFORM': @@ -1601,16 +1701,23 @@ def create_led_platform_device(self, key, ops): def create_led_device(self, key, ops): if ops['attr']=='all' or ops['attr']==self.data[key]['dev_info']['device_name']: - path="pddf/devices/led" + path = "pddf/devices/led" + ops_state = "" + if 'bmc' in self.data[key]: + return for attr in self.data[key]['i2c']['attr_list']: self.create_attr('device_name', self.data[key]['dev_info']['device_name'], path) - self.create_device(self.data[key]['dev_attr'], path, ops) + self.create_attr('index', self.data[key]['dev_attr']['index'], path) + #attr_devtype and attr_devname are optional in json file. + #if attr_devtype is not defined, it means it is "cpld" + if 'attr_devtype' not in attr.keys(): + self.create_attr('attr_devtype', 'cpld', path) for attr_key in attr.keys(): - if (attr_key == 'swpld_addr_offset' or attr_key == 'swpld_addr'): + if (attr_key == 'swpld_addr_offset' or attr_key == 'swpld_addr' or \ + attr_key == 'attr_devtype' or attr_key == 'attr_devname' ): self.create_attr(attr_key, attr[attr_key], path) - elif (attr_key != 'attr_name' and attr_key != 'descr' and - attr_key != 'attr_devtype' and attr_key != 'attr_devname'): - state_path=path+'/state_attr' + elif (attr_key != 'attr_name' and attr_key != 'descr' and attr_key != 'state'): + state_path = path+'/state_attr' self.create_attr(attr_key, attr[attr_key],state_path) cmd="echo '" + attr['attr_name']+"' > /sys/kernel/pddf/devices/led/dev_ops" self.runcmd(cmd) diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_chassis.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_chassis.py index ef211b9933..4ed6a22e9f 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_chassis.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_chassis.py @@ -193,32 +193,30 @@ def get_reboot_cause(self): ############################################## # System LED methods ############################################## + # APIs used by PDDF. Use them for debugging front panel + # system LED and fantray LED issues def set_system_led(self, led_device_name, color): - result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color) - if result == False: + """ + Sets the color of an LED device in PDDF + Args: + led_device_name: a pre-defined LED device name list used in pddf-device.json. + color: A string representing the color with which to set a LED + Returns: + bool: True if the LED state is set successfully, False if not + """ + result, msg = self.pddf_obj.set_system_led_color(led_device_name, color) + if not result and msg: print(msg) - return (False) - - index = self.pddf_obj.data[led_device_name]['dev_attr']['index'] - device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name'] - self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('color', color, self.pddf_obj.get_led_cur_state_path()) - self.pddf_obj.create_attr('dev_ops', 'set_status', self.pddf_obj.get_led_path()) - return (True) + return (result) def get_system_led(self, led_device_name): - if led_device_name not in self.pddf_obj.data.keys(): - status = "[FAILED] " + led_device_name + " is not configured" - return (status) - - index = self.pddf_obj.data[led_device_name]['dev_attr']['index'] - device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name'] - self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('dev_ops', 'get_status', self.pddf_obj.get_led_path()) - color = self.pddf_obj.get_led_color() - return (color) + """ + Gets the color of an LED device in PDDF + Returns: + string: color of LED or message if failed. + """ + result, output = self.pddf_obj.get_system_led_color(led_device_name) + return (output) ############################################## # Other methods diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_eeprom.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_eeprom.py index ab5063d495..4f236a7917 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_eeprom.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_eeprom.py @@ -6,9 +6,12 @@ try: from sonic_eeprom import eeprom_tlvinfo + import os except ImportError as e: raise ImportError(str(e) + "- required module not found") +CACHE_ROOT = '/var/cache/sonic/decode-syseeprom' +CACHE_FILE = 'syseeprom_cache' class PddfEeprom(eeprom_tlvinfo.TlvInfoDecoder): _TLV_INFO_MAX_LEN = 256 @@ -29,6 +32,20 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None): super(PddfEeprom, self).__init__(self.eeprom_path, 0, '', True) self.eeprom_tlv_dict = dict() + + # Create the cache directory if not created + if not os.path.exists(CACHE_ROOT): + try: + os.makedirs(CACHE_ROOT) + except Exception as e: + print("Error in creating Eeprom cache directory - {}".format(str(e))) + + # Assign cache_name in eeprom_base.py + try: + self.set_cache_name(os.path.join(CACHE_ROOT, CACHE_FILE)) + except: + pass + try: self.eeprom_data = self.read_eeprom() except: @@ -37,6 +54,11 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None): else: eeprom = self.eeprom_data + try: + self.update_cache(eeprom) + except: + pass + if not self.is_valid_tlvinfo_header(eeprom): return diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_fan.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_fan.py index c0e95c8969..e0a0ad1e68 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_fan.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_fan.py @@ -26,6 +26,7 @@ class PddfFan(FanBase): def __init__(self, tray_idx, fan_idx=0, pddf_data=None, pddf_plugin_data=None, is_psu_fan=False, psu_index=0): # idx is 0-based + FanBase.__init__(self) if not pddf_data or not pddf_plugin_data: raise ValueError('PDDF JSON data error') @@ -99,7 +100,7 @@ def get_direction(self): device = "PSU{}".format(self.fans_psu_index) output = self.pddf_obj.get_attr_name_output(device, "psu_fan_dir") if not output: - return False + return None mode = output['mode'] val = output['status'] @@ -117,7 +118,7 @@ def get_direction(self): attr = "fan" + str(idx) + "_direction" output = self.pddf_obj.get_attr_name_output("FAN-CTRL", attr) if not output: - return False + return None mode = output['mode'] val = output['status'] @@ -168,7 +169,7 @@ def get_speed(self): if output['status'].isalpha(): return 0 else: - fpwm = int(output['status']) + fpwm = int(float(output['status'])) pwm_to_dc = eval(self.plugin_data['FAN']['pwm_to_duty_cycle']) speed_percentage = int(round(pwm_to_dc(fpwm))) @@ -190,10 +191,11 @@ def get_speed_rpm(self): return 0 output['status'] = output['status'].rstrip() - if output['status'].isalpha(): - return 0 - else: + + if output['status'].replace('.', '', 1).isdigit(): speed = int(float(output['status'])) + else: + return 0 rpm_speed = speed return rpm_speed @@ -237,7 +239,7 @@ def get_target_speed(self): if output['status'].isalpha(): return 0 else: - fpwm = int(output['status']) + fpwm = int(float(output['status'])) pwm_to_dc = eval(self.plugin_data['FAN']['pwm_to_duty_cycle']) speed_percentage = int(round(pwm_to_dc(fpwm))) @@ -295,38 +297,53 @@ def set_speed(self, speed): return status def set_status_led(self, color): - index = str(self.fantray_index-1) - led_device_name = "FANTRAY{}".format(self.fantray_index) + "_LED" - - result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color) - if result == False: - print(msg) - return (False) - - device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name'] - self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('color', color, self.pddf_obj.get_led_cur_state_path()) - self.pddf_obj.create_attr('dev_ops', 'set_status', self.pddf_obj.get_led_path()) - return (True) + result = False + if self.is_psu_fan: + # Usually no led for psu_fan hence raise a NotImplementedError + raise NotImplementedError + else: + # Usually there is no led for psu_fan + led_device_name = "FANTRAY{}".format(self.fantray_index) + "_LED" + result, msg = self.pddf_obj.set_system_led_color(led_device_name, color) + return (result) def get_status_led(self): - index = str(self.fantray_index-1) - fan_led_device = "FANTRAY{}".format(self.fantray_index) + "_LED" + if self.is_psu_fan: + # Usually no led for psu_fan hence raise a NotImplementedError + raise NotImplementedError + else: + fan_led_device = "FANTRAY{}".format(self.fantray_index) + "_LED" + if (not fan_led_device in self.pddf_obj.data.keys()): + # Implement a generic status_led color scheme + if self.get_status(): + return self.STATUS_LED_COLOR_GREEN + else: + return self.STATUS_LED_COLOR_OFF + + result, color = self.pddf_obj.get_system_led_color(fan_led_device) + return (color) + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + Returns: + integer: The 1-based relative physical position in parent + device or -1 if cannot determine the position + """ + # self.fan_index represents the fan index in a Fantray as well as in the PSU + return self.fan_index - if fan_led_device not in self.pddf_obj.data.keys(): - # Implement a generic status_led color scheme - if self.get_status(): - return self.STATUS_LED_COLOR_GREEN - else: - return self.STATUS_LED_COLOR_OFF - - device_name = self.pddf_obj.data[fan_led_device]['dev_info']['device_name'] - self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('dev_ops', 'get_status', self.pddf_obj.get_led_path()) - color = self.pddf_obj.get_led_color() - return (color) + def is_replaceable(self): + """ + Indicate whether Fan (inside a Fantray) is replaceable + Returns: + bool: True if it is replaceable. + """ + # Usually a psu-fan is not replaceable + if self.is_psu_fan: + return False + else: + return True def dump_sysfs(self): return self.pddf_obj.cli_dump_dsysfs('fan') diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_fan_drawer.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_fan_drawer.py index f88e833408..477d343fb1 100755 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_fan_drawer.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_fan_drawer.py @@ -78,33 +78,19 @@ def get_position_in_parent(self): return self.fantray_index def get_status_led(self): - led_device_name = "FANTRAY{}".format(self.fantray_index) + "_LED" - - if led_device_name not in self.pddf_obj.data.keys(): + fan_led_device = "FANTRAY{}".format(self.fantray_index) + "_LED" + if (not fan_led_device in self.pddf_obj.data.keys()): # Implement a generic status_led color scheme if self.get_status(): return self.STATUS_LED_COLOR_GREEN else: return self.STATUS_LED_COLOR_OFF - device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name'] - self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('index', str(self.fantray_index-1), self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('dev_ops', 'get_status', self.pddf_obj.get_led_path()) - color = self.pddf_obj.get_led_color() + result, color = self.pddf_obj.get_system_led_color(fan_led_device) return (color) def set_status_led(self, color): result = False led_device_name = "FANTRAY{}".format(self.fantray_index) + "_LED" - result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color) - if result == False: - print(msg) - return (False) - - device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name'] - self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('index', str(self.fantray_index-1), self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('color', color, self.pddf_obj.get_led_cur_state_path()) - self.pddf_obj.create_attr('dev_ops', 'set_status', self.pddf_obj.get_led_path()) - return (True) + result, msg = self.pddf_obj.set_system_led_color(led_device_name, color) + return (result) diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_psu.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_psu.py index bbe7dc0a1a..01d12a81ff 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_psu.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_psu.py @@ -11,9 +11,17 @@ # - psu_serial_num # - psu_fan_dir # - psu_v_out +# - psu_v_out_min +# - psu_v_out_max # - psu_i_out # - psu_p_out +# - psu_p_out_max # - psu_fan1_speed_rpm +# - psu_temp1_input +# - psu_temp1_high_threshold +# - psu_v_in +# - psu_i_in +# - psu_p_in ############################################################################# @@ -129,6 +137,10 @@ def get_serial(self): serial = output['status'] + # strip_non_ascii + stripped = (c for c in serial if 0 < ord(c) < 127) + serial = ''.join(stripped) + return serial.rstrip('\n') def get_status(self): @@ -168,6 +180,10 @@ def get_mfr_id(self): mfr = output['status'] + # strip_non_ascii + stripped = (c for c in mfr if 0 < ord(c) < 127) + mfr = ''.join(stripped) + return mfr.rstrip('\n') def get_voltage(self): @@ -234,23 +250,17 @@ def get_powergood_status(self): return self.get_status() def set_status_led(self, color): - index = str(self.psu_index-1) + if 'psu_led_color' in self.plugin_data['PSU']: + led_color_map = self.plugin_data['PSU']['psu_led_color']['colmap'] + if color in led_color_map: + # change the color properly + new_color = led_color_map[color] + color = new_color led_device_name = "PSU{}".format(self.psu_index) + "_LED" - - result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color) - if result == False: - print(msg) - return (False) - - device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name'] - self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('color', color, self.pddf_obj.get_led_cur_state_path()) - self.pddf_obj.create_attr('dev_ops', 'set_status', self.pddf_obj.get_led_path()) - return (True) + result, msg = self.pddf_obj.set_system_led_color(led_device_name, color) + return (result) def get_status_led(self): - index = str(self.psu_index-1) psu_led_device = "PSU{}_LED".format(self.psu_index) if psu_led_device not in self.pddf_obj.data.keys(): # Implement a generic status_led color scheme @@ -259,11 +269,7 @@ def get_status_led(self): else: return self.STATUS_LED_COLOR_OFF - device_name = self.pddf_obj.data[psu_led_device]['dev_info']['device_name'] - self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path()) - self.pddf_obj.create_attr('dev_ops', 'get_status', self.pddf_obj.get_led_path()) - color = self.pddf_obj.get_led_color() + result, color = self.pddf_obj.get_system_led_color(psu_led_device) return (color) def get_temperature(self): @@ -319,5 +325,99 @@ def get_input_current(self): # current in mA return float(i_in)/1000 + def get_input_power(self): + """ + Retrieves current energy supplied to the PSU + Returns: + A float number, the power in watts, e.g. 302.6 + """ + device = "PSU{}".format(self.psu_index) + output = self.pddf_obj.get_attr_name_output(device, "psu_p_in") + if not output: + return 0.0 + + p_in = output['status'] + + # power is returned in micro watts + return float(p_in)/1000000 + + def get_temperature_high_threshold(self): + """ + Retrieves the high threshold temperature of PSU + Returns: + A float number, the high threshold temperature of PSU in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + device = "PSU{}".format(self.psu_index) + output = self.pddf_obj.get_attr_name_output(device, "psu_temp1_high_threshold") + if not output: + return 0.0 + + temp_high_thresh = output['status'] + return float(temp_high_thresh)/1000 + + def get_voltage_high_threshold(self): + """ + Retrieves the high threshold PSU voltage output + Returns: + A float number, the high threshold output voltage in volts, + e.g. 12.1 + """ + device = "PSU{}".format(self.psu_index) + output = self.pddf_obj.get_attr_name_output(device, "psu_v_out_max") + if not output: + return 0.0 + + v_out_max = output['status'] + return float(v_out_max)/1000 + + def get_voltage_low_threshold(self): + """ + Retrieves the low threshold PSU voltage output + Returns: + A float number, the low threshold output voltage in volts, + e.g. 12.1 + """ + device = "PSU{}".format(self.psu_index) + output = self.pddf_obj.get_attr_name_output(device, "psu_v_out_min") + if not output: + return 0.0 + + v_out_min = output['status'] + return float(v_out_min)/1000 + + def get_maximum_supplied_power(self): + """ + Retrieves the maximum supplied power by PSU + Returns: + A float number, the maximum power output in Watts. + e.g. 1200.1 + """ + device = "PSU{}".format(self.psu_index) + output = self.pddf_obj.get_attr_name_output(device, "psu_p_out_max") + if not output: + return 0.0 + + p_out_max = output['status'] + # max power is in milliwatts + return float(p_out_max)/1000 + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + Returns: + integer: The 1-based relative physical position in parent + device or -1 if cannot determine the position + """ + return self.psu_index + + def is_replaceable(self): + """ + Indicate whether PSU is replaceable. + Returns: + bool: True if it is replaceable. + """ + return True + def dump_sysfs(self): return self.pddf_obj.cli_dump_dsysfs('psu') diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py index be286bd9ea..86d706f582 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py @@ -40,6 +40,7 @@ def __init__(self, index, pddf_data=None, pddf_plugin_data=None): print("Invalid port index %d" % index) return + # 1-based port index self.port_index = index+1 self.device = 'PORT{}'.format(self.port_index) self.sfp_type = self.pddf_obj.get_device_type(self.device) @@ -204,7 +205,9 @@ def get_lpmode(self): lpmode = super().get_lpmode() elif xcvr_id == 0x11 or xcvr_id == 0x0d or xcvr_id == 0x0c: # QSFP28, QSFP+, QSFP - power_set = self.get_power_set() + # get_power_set() is not defined in the optoe_base class + api = self.get_xcvr_api() + power_set = api.get_power_set() power_override = self.get_power_override() # By default the lpmode pin is pulled high as mentioned in the sff community return power_set if power_override else True @@ -342,11 +345,28 @@ def set_lpmode(self, lpmode): elif xcvr_id == 0x11 or xcvr_id == 0x0d or xcvr_id == 0x0c: # QSFP28, QSFP+, QSFP if lpmode is True: - self.set_power_override(True, True) + status = self.set_power_override(True, True) else: - self.set_power_override(True, False) + status = self.set_power_override(True, False) return status + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + Returns: + integer: The 1-based relative physical position in parent + device or -1 if cannot determine the position + """ + return self.port_index + + def is_replaceable(self): + """ + Indicate whether the SFP is replaceable. + Returns: + bool: True if it is replaceable. + """ + return True + def dump_sysfs(self): return self.pddf_obj.cli_dump_dsysfs('xcvr') diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py index b94a66ca46..7be5ccb38d 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py @@ -13,7 +13,7 @@ try: from sonic_platform_base.thermal_base import ThermalBase - import os + from subprocess import getstatusoutput except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -141,9 +141,11 @@ def set_high_threshold(self, temperature): return None cmd = "echo '%d' > %s" % (temperature * 1000, node) - os.system(cmd) - - return (True) + ret, _ = getstatusoutput(cmd) + if ret == 0: + return (True) + else: + return (False) else: raise NotImplementedError @@ -154,9 +156,11 @@ def set_low_threshold(self, temperature): print("ERROR %s does not exist" % node) return None cmd = "echo '%d' > %s" % (temperature * 1000, node) - os.system(cmd) - - return (True) + ret, _ = getstatusoutput(cmd) + if ret == 0: + return (True) + else: + return (False) else: raise NotImplementedError @@ -210,19 +214,40 @@ def get_low_critical_threshold(self): else: raise NotImplementedError + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + Returns: + integer: The 1-based relative physical position in parent + device or -1 if cannot determine the position + """ + return self.thermal_index + + def is_replaceable(self): + """ + Indicate whether Thermal is replaceable. + Returns: + bool: True if it is replaceable. + """ + # Usually thermal sensor is not replaceable + return False + # Helper Functions def get_temp_label(self): + label = None if 'bmc' in self.pddf_obj.data[self.thermal_obj_name].keys(): - return None + return label else: if self.thermal_obj_name in self.pddf_obj.data.keys(): dev = self.pddf_obj.data[self.thermal_obj_name] - topo_info = dev['i2c']['topo_info'] - label = "%s-i2c-%d-%x" % (topo_info['dev_type'], int(topo_info['parent_bus'], 0), + if 'topo_info' in dev['i2c']: + topo_info = dev['i2c']['topo_info'] + label = "%s-i2c-%d-%x" % (topo_info['dev_type'], int(topo_info['parent_bus'], 0), int(topo_info['dev_addr'], 0)) - return (label) - else: - return None + elif 'path_info' in dev['i2c']: + label = self.get_name() + + return (label) def dump_sysfs(self): return self.pddf_obj.cli_dump_dsysfs('temp-sensors') diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py index 352ad1b174..a4c6e04ca4 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py @@ -16,19 +16,6 @@ dirname = os.path.dirname(os.path.realpath(__file__)) -color_map = { - "STATUS_LED_COLOR_GREEN": "green", - "STATUS_LED_COLOR_RED": "red", - "STATUS_LED_COLOR_AMBER": "amber", - "STATUS_LED_COLOR_BLUE": "blue", - "STATUS_LED_COLOR_GREEN_BLINK": "blinking green", - "STATUS_LED_COLOR_RED_BLINK": "blinking red", - "STATUS_LED_COLOR_AMBER_BLINK": "blinking amber", - "STATUS_LED_COLOR_BLUE_BLINK": "blinking blue", - "STATUS_LED_COLOR_OFF": "off" -} - - class PddfApi(): def __init__(self): if not os.path.exists("/usr/share/sonic/platform"): @@ -123,10 +110,12 @@ def get_led_color(self): color = f.read().strip("\r\n") except IOError: return ("Error") - - return (color_map[color]) + return color def get_led_color_devtype(self, key): + if 'bmc' in self.data[key]: + return 'bmc' + attr_list = self.data[key]['i2c']['attr_list'] for attr in attr_list: if 'attr_devtype' in attr: @@ -163,8 +152,8 @@ def get_led_color_from_gpio(self, led_device_name): for attr in attr_list: if int(attr['value'].strip(), 16) == value: - return(color_map[attr['attr_name']]) - return (color_map['STATUS_LED_COLOR_OFF']) + return (attr['attr_name']) + return ("off") def get_led_color_from_cpld(self, led_device_name): index = self.data[led_device_name]['dev_attr']['index'] @@ -174,6 +163,12 @@ def get_led_color_from_cpld(self, led_device_name): self.create_attr('dev_ops', 'get_status', self.get_led_path()) return self.get_led_color() + def get_led_color_from_bmc(self, led_device_name): + for bmc_attr in self.data[led_device_name]['bmc']['ipmitool']['attr_list']: + if (self.bmc_get_cmd(bmc_attr) == str(int(bmc_attr['value'], 16))): + return (bmc_attr['attr_name']) + return ("off") + def set_led_color_from_gpio(self, led_device_name, color): attr_list = self.data[led_device_name]['i2c']['attr_list'] for attr in attr_list: @@ -196,9 +191,9 @@ def set_led_color_from_gpio(self, led_device_name, color): cmd = "echo {} > {}".format(_value, attr_path) self.runcmd(cmd) except Exception as e: - print("Invalid gpio path : " + attr_path) - return (False) - return (True) + msg = "Invalid gpio path : " + attr_path + return (False, msg) + return (True, "Success") def set_led_color_from_cpld(self, led_device_name, color): index = self.data[led_device_name]['dev_attr']['index'] @@ -207,26 +202,42 @@ def set_led_color_from_cpld(self, led_device_name, color): self.create_attr('index', index, self.get_led_path()) self.create_attr('color', color, self.get_led_cur_state_path()) self.create_attr('dev_ops', 'set_status', self.get_led_path()) - return (True) + return (True, "Success") def get_system_led_color(self, led_device_name): if led_device_name not in self.data.keys(): - status = "[FAILED] " + led_device_name + " is not configured" - return (status) + msg = led_device_name + " is not configured" + return (False, msg) dtype = self.get_led_color_devtype(led_device_name) if dtype == 'gpio': color = self.get_led_color_from_gpio(led_device_name) - elif dtype == 'cpld': + elif dtype == 'bmc': + color = self.get_led_color_from_bmc(led_device_name) + else: + # This case takes care of CPLD as well as I2CFPGA color = self.get_led_color_from_cpld(led_device_name) - return color + + return (True, color) def set_system_led_color(self, led_device_name, color): - result, msg = self.is_supported_sysled_state(led_device_name, color) - if result == False: - print(msg) - return (result) + # Check if the device is configured + if led_device_name not in self.data.keys(): + msg = led_device_name + " is not configured" + return (False, msg) + + # Check for the write permission + if 'flag' in self.data[led_device_name]['dev_attr']: + if self.data[led_device_name]['dev_attr']['flag'] == 'ro': + return (False, "Set LED operation not supported or handled separately") + + found = False + for attr in self.data[led_device_name]['i2c']['attr_list']: + if attr['attr_name'] == color: + found = True + if not found: + return (False, "Invalid color") dtype = self.get_led_color_devtype(led_device_name) @@ -391,7 +402,6 @@ def show_attr_fan_device(self, dev, ops): ret.append(dsysfs_path) return ret - # This is only valid for LM75 def show_attr_temp_sensor_device(self, dev, ops): ret = [] if 'i2c' not in dev.keys(): @@ -406,19 +416,25 @@ def show_attr_temp_sensor_device(self, dev, ops): for attr in attr_list: if attr_name == attr['attr_name'] or attr_name == 'all': - path = self.show_device_sysfs(dev, ops)+"/%d-00%x/" % (int(dev['i2c']['topo_info']['parent_bus'], 0), - int(dev['i2c']['topo_info']['dev_addr'], 0)) if 'drv_attr_name' in attr.keys(): real_name = attr['drv_attr_name'] else: real_name = attr['attr_name'] - if (os.path.exists(path)): - full_path = glob.glob(path + 'hwmon/hwmon*/' + real_name)[0] - dsysfs_path = full_path - if dsysfs_path not in self.data_sysfs_obj[KEY]: - self.data_sysfs_obj[KEY].append(dsysfs_path) - ret.append(full_path) + if 'topo_info' in dev['i2c']: + path = self.show_device_sysfs(dev, ops)+"/%d-00%x/"%(int(dev['i2c']['topo_info']['parent_bus'], 0), + int(dev['i2c']['topo_info']['dev_addr'], 0)) + if (os.path.exists(path)): + full_path = glob.glob(path + 'hwmon/hwmon*/' + real_name)[0] + elif 'path_info' in dev['i2c']: + path = dev['i2c']['path_info']['sysfs_base_path'] + if (os.path.exists(path)): + full_path = "/".join([path, real_name]) + + dsysfs_path = full_path + if dsysfs_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(dsysfs_path) + ret.append(full_path) return ret def show_attr_sysstatus_device(self, dev, ops): @@ -804,14 +820,6 @@ def dev_parse(self, dev, ops): if attr['device_type'] == 'SYSSTAT': return self.sysstatus_parse(dev, ops) - def is_supported_sysled_state(self, sysled_name, sysled_state): - if sysled_name not in self.data.keys(): - return False, "[FAILED] " + sysled_name + " is not configured" - for attr in self.data[sysled_name]['i2c']['attr_list']: - if attr['attr_name'] == sysled_state: - return True, "supported" - return False, "[FAILED]: Invalid color" - def create_attr(self, key, value, path): cmd = "echo '%s' > /sys/kernel/%s/%s" % (value, path, key) self.runcmd(cmd) diff --git a/rules/hiredis.mk b/rules/hiredis.mk index 71a18a1d6a..a97e0bf1bb 100644 --- a/rules/hiredis.mk +++ b/rules/hiredis.mk @@ -1,7 +1,7 @@ # libhiredis package -HIREDIS_VERSION = 0.14.0 -HIREDIS_VERSION_FULL = $(HIREDIS_VERSION)-3~bpo9+1 +HIREDIS_VERSION = 0.14.1 +HIREDIS_VERSION_FULL = ${HIREDIS_VERSION}-1 export HIREDIS_VERSION HIREDIS_VERSION_FULL @@ -12,6 +12,7 @@ SONIC_MAKE_DEBS += $(LIBHIREDIS) LIBHIREDIS_DEV = libhiredis-dev_$(HIREDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb $(eval $(call add_derived_package,$(LIBHIREDIS),$(LIBHIREDIS_DEV))) -LIBHIREDIS_DBG = libhiredis-dbg_$(HIREDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb LIBHIREDIS_DBG = libhiredis0.14-dbgsym_$(HIREDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb $(eval $(call add_derived_package,$(LIBHIREDIS),$(LIBHIREDIS_DBG))) + +export LIBHIREDIS LIBHIREDIS_DEV LIBHIREDIS_DBG diff --git a/rules/isc-dhcp.mk b/rules/isc-dhcp.mk index 1a1ad54678..5dc98d5d56 100644 --- a/rules/isc-dhcp.mk +++ b/rules/isc-dhcp.mk @@ -1,7 +1,7 @@ # isc-dhcp packages ISC_DHCP_VERSION = 4.4.1 -ISC_DHCP_VERSION_FULL = ${ISC_DHCP_VERSION}-2.3 +ISC_DHCP_VERSION_FULL = ${ISC_DHCP_VERSION}-2.3+deb11u2 export ISC_DHCP_VERSION ISC_DHCP_VERSION_FULL diff --git a/sonic-slave-bullseye/Dockerfile.j2 b/sonic-slave-bullseye/Dockerfile.j2 index f4f24d847e..ef18f51468 100644 --- a/sonic-slave-bullseye/Dockerfile.j2 +++ b/sonic-slave-bullseye/Dockerfile.j2 @@ -549,10 +549,6 @@ RUN cd /usr/src/gtest && cmake . && make -C /usr/src/gtest RUN mkdir /var/run/sshd EXPOSE 22 -# Install depot-tools (for git-retry) -RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /usr/share/depot_tools -ENV PATH /usr/share/depot_tools:$PATH - # Install dependencies for dhcp relay test RUN pip3 install parameterized==0.8.1 RUN pip3 install pyfakefs diff --git a/sonic-slave-stretch/Dockerfile.j2 b/sonic-slave-stretch/Dockerfile.j2 index 1397df1c73..4d7ace180d 100644 --- a/sonic-slave-stretch/Dockerfile.j2 +++ b/sonic-slave-stretch/Dockerfile.j2 @@ -354,7 +354,7 @@ RUN pip2 install Pympler==0.8 RUN pip3 install pyang==2.4.0 # For mgmt-framework build -RUN pip2 install mmh3 +RUN pip2 install mmh3==2.5.1 # Install dependencies for isc-dhcp-relay build RUN apt-get -y build-dep isc-dhcp diff --git a/src/hiredis/Makefile b/src/hiredis/Makefile index ab257e5e08..7e94e2c091 100644 --- a/src/hiredis/Makefile +++ b/src/hiredis/Makefile @@ -2,18 +2,18 @@ SHELL = /bin/bash .SHELLFLAGS += -e -MAIN_TARGET = libhiredis0.14_$(HIREDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb -DERIVED_TARGETS = libhiredis0.14-dbgsym_$(HIREDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb libhiredis-dev_$(HIREDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb +MAIN_TARGET = $(LIBHIREDIS) +DERIVED_TARGETS = $(LIBHIREDIS_DBG) $(LIBHIREDIS_DEV) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : - rm -rf hiredis-$(HIREDIS_VERSION) + # Remove any stale files + rm -rf ./hiredis-$(HIREDIS_VERSION) - wget -O hiredis_$(HIREDIS_VERSION).orig.tar.gz http://http.debian.net/debian/pool/main/h/hiredis/hiredis_$(HIREDIS_VERSION).orig.tar.gz - wget -O hiredis_$(HIREDIS_VERSION_FULL).debian.tar.xz http://http.debian.net/debian/pool/main/h/hiredis/hiredis_$(HIREDIS_VERSION_FULL).debian.tar.xz - wget -O hiredis_$(HIREDIS_VERSION_FULL).dsc http://http.debian.net/debian/pool/main/h/hiredis/hiredis_$(HIREDIS_VERSION_FULL).dsc + # Get hiredis release, debian files + dget -u http://http.debian.net/debian/pool/main/h/hiredis/hiredis_$(HIREDIS_VERSION_FULL).dsc - dpkg-source -x hiredis_$(HIREDIS_VERSION_FULL).dsc - pushd hiredis-$(HIREDIS_VERSION) + # Build source and Debian packages + pushd ./hiredis-$(HIREDIS_VERSION) ifeq ($(CROSS_BUILD_ENVIRON), y) dpkg-buildpackage -rfakeroot -d -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) else @@ -21,6 +21,7 @@ else endif popd + # Move the newly-built .deb packages to the destination directory mv $* $(DERIVED_TARGETS) $(DEST)/ $(addprefix $(DEST)/, $(DERIVED_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET) diff --git a/src/isc-dhcp/Makefile b/src/isc-dhcp/Makefile index c908ddeeed..22d6801cca 100644 --- a/src/isc-dhcp/Makefile +++ b/src/isc-dhcp/Makefile @@ -10,7 +10,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : rm -rf ./isc-dhcp-$(ISC_DHCP_VERSION) # Get isc-dhcp release, debian files - dget http://deb.debian.org/debian/pool/main/i/isc-dhcp/isc-dhcp_$(ISC_DHCP_VERSION_FULL).dsc + dget -u http://deb.debian.org/debian/pool/main/i/isc-dhcp/isc-dhcp_$(ISC_DHCP_VERSION_FULL).dsc pushd ./isc-dhcp-$(ISC_DHCP_VERSION) # Create a git repository here for stg to apply patches diff --git a/src/sonic-device-data/tests/permitted_list b/src/sonic-device-data/tests/permitted_list index 01ed79c41f..a2a166d776 100644 --- a/src/sonic-device-data/tests/permitted_list +++ b/src/sonic-device-data/tests/permitted_list @@ -322,3 +322,4 @@ sai_mdio_access_clause22 cmic_dma_abort_in_cold_boot hybrid_pfc_deadlock_enable sai_pfc_dlr_init_capability +core_clock_to_pm_clock_factor \ No newline at end of file diff --git a/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp b/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp index be5a19ad5a..00bde81e2d 100644 --- a/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp +++ b/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp @@ -19,6 +19,8 @@ using namespace std; using namespace swss; using json = nlohmann::json; +const string g_stored_year = "2024"; + vector createEventParams(vector params, vector luaCodes) { vector eventParams; for(long unsigned int i = 0; i < params.size(); i++) { @@ -85,13 +87,16 @@ TEST(syslog_parser, matching_regex_timestamp) { event_params_t expectedDict; expectedDict["message"] = "test_message"; expectedDict["other_data"] = "test_data"; - expectedDict["timestamp"] = "2022-07-21T02:10:00.000000Z"; + // Adding stored year to messages as syslog don't contain year + expectedDict["timestamp"] = g_stored_year + "-07-21T02:10:00.000000Z"; unique_ptr parser(new SyslogParser()); parser->m_regexList = regexList; lua_State* luaState = luaL_newstate(); luaL_openlibs(luaState); + parser->m_timestampFormatter->m_storedTimestamp = "010100:00:00.000000"; + parser->m_timestampFormatter->m_storedYear = g_stored_year; bool success = parser->parseMessage("Jul 21 02:10:00.000000 message test_message other_data test_data", tag, paramDict, luaState); EXPECT_EQ(true, success); EXPECT_EQ("test_tag", tag); @@ -186,13 +191,15 @@ TEST(syslog_parser, lua_code_valid_2) { expectedDict["ip"] = "10.10.24.216"; expectedDict["major-code"] = "6"; expectedDict["minor-code"] = "2"; - expectedDict["timestamp"] = "2022-12-03T12:36:24.503424Z"; + expectedDict["timestamp"] = g_stored_year + "-12-03T12:36:24.503424Z"; unique_ptr parser(new SyslogParser()); parser->m_regexList = regexList; lua_State* luaState = luaL_newstate(); luaL_openlibs(luaState); + parser->m_timestampFormatter->m_storedTimestamp = "010100:00:00.000000"; + parser->m_timestampFormatter->m_storedYear = g_stored_year; bool success = parser->parseMessage("Dec 3 12:36:24.503424 NOTIFICATION: received from neighbor 10.10.24.216 active 6/2 (Administrative Shutdown) 0 bytes", tag, paramDict, luaState); EXPECT_EQ(true, success); EXPECT_EQ("test_tag", tag); @@ -253,13 +260,22 @@ TEST(timestampFormatter, changeTimestampFormat) { vector timestampTwo = { "Jan", "1", "00:00:00.000000" }; vector timestampThree = { "Dec", "31", "23:59:59.000000" }; + formatter->m_storedTimestamp = "010100:00:00.000000"; + formatter->m_storedYear = g_stored_year; + string formattedTimestampOne = formatter->changeTimestampFormat(timestampOne); - EXPECT_EQ("2022-07-20T10:09:40.230874Z", formattedTimestampOne); + string expectedTimestampOne = g_stored_year + "-07-20T10:09:40.230874Z"; + + EXPECT_EQ(expectedTimestampOne, formattedTimestampOne); EXPECT_EQ("072010:09:40.230874", formatter->m_storedTimestamp); + formatter->m_storedTimestamp = "010100:00:00.000000"; + formatter->m_storedYear = g_stored_year; + string formattedTimestampTwo = formatter->changeTimestampFormat(timestampTwo); - EXPECT_EQ("2022-01-01T00:00:00.000000Z", formattedTimestampTwo); + string expectedTimestampTwo = g_stored_year + "-01-01T00:00:00.000000Z"; + EXPECT_EQ(expectedTimestampTwo, formattedTimestampTwo); formatter->m_storedTimestamp = "010100:00:00.000000"; formatter->m_storedYear = "2025"; diff --git a/src/system-health/health_checker/service_checker.py b/src/system-health/health_checker/service_checker.py index ed6c7296fd..df6005cc0f 100644 --- a/src/system-health/health_checker/service_checker.py +++ b/src/system-health/health_checker/service_checker.py @@ -26,13 +26,13 @@ class ServiceChecker(HealthChecker): CRITICAL_PROCESSES_PATH = 'etc/supervisor/critical_processes' # Command to get merged directory of a container - GET_CONTAINER_FOLDER_CMD = ['docker', 'inspect', '', '--format', "{{.GraphDriver.Data.MergedDir}}"] + GET_CONTAINER_FOLDER_CMD = 'docker inspect {} --format "{{{{.GraphDriver.Data.MergedDir}}}}"' # Command to query the status of monit service. - CHECK_MONIT_SERVICE_CMD = ['systemctl', 'is-active', 'monit.service'] + CHECK_MONIT_SERVICE_CMD = 'systemctl is-active monit.service' # Command to get summary of critical system service. - CHECK_CMD = ['monit', 'summary', '-B'] + CHECK_CMD = 'monit summary -B' MIN_CHECK_CMD_LINES = 3 # Expect status for different system service category. @@ -172,8 +172,7 @@ def _update_container_critical_processes(self, container, critical_process_list) self.need_save_cache = True def _get_container_folder(self, container): - ServiceChecker.GET_CONTAINER_FOLDER_CMD[2] = str(container) - container_folder = utils.run_command(ServiceChecker.GET_CONTAINER_FOLDER_CMD) + container_folder = utils.run_command(ServiceChecker.GET_CONTAINER_FOLDER_CMD.format(container)) if container_folder is None: return container_folder @@ -339,7 +338,7 @@ def check_process_existence(self, container_name, critical_process_list, config, # We are using supervisorctl status to check the critical process status. We cannot leverage psutil here because # it not always possible to get process cmdline in supervisor.conf. E.g, cmdline of orchagent is "/usr/bin/orchagent", # however, in supervisor.conf it is "/usr/bin/orchagent.sh" - cmd = ['docker', 'exec', str(container_name), 'bash', '-c', "supervisorctl status"] + cmd = 'docker exec {} bash -c "supervisorctl status"'.format(container_name) process_status = utils.run_command(cmd) if process_status is None: for process_name in critical_process_list: diff --git a/src/system-health/health_checker/sysmonitor.py b/src/system-health/health_checker/sysmonitor.py index e4dbc68ebf..e69d289fc5 100755 --- a/src/system-health/health_checker/sysmonitor.py +++ b/src/system-health/health_checker/sysmonitor.py @@ -235,7 +235,7 @@ def get_app_ready_status(self, service): #Gets the service properties def run_systemctl_show(self, service): - command = ['systemctl', 'show', str(service), '--property=Id,LoadState,UnitFileState,Type,ActiveState,SubState,Result'] + command = ('systemctl show {} --property=Id,LoadState,UnitFileState,Type,ActiveState,SubState,Result'.format(service)) output = utils.run_command(command) srv_properties = output.split('\n') prop_dict = {} diff --git a/src/system-health/health_checker/utils.py b/src/system-health/health_checker/utils.py index 338ef1d3af..00e7754e1e 100644 --- a/src/system-health/health_checker/utils.py +++ b/src/system-health/health_checker/utils.py @@ -8,7 +8,7 @@ def run_command(command): :return: Output of the shell command. """ try: - process = subprocess.Popen(command, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = subprocess.Popen(command, shell=True, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return process.communicate()[0] except Exception: return None diff --git a/src/system-health/tests/test_system_health.py b/src/system-health/tests/test_system_health.py index 73beb99cae..687781ea2a 100644 --- a/src/system-health/tests/test_system_health.py +++ b/src/system-health/tests/test_system_health.py @@ -536,10 +536,10 @@ def test_manager(mock_hw_info, mock_service_info, mock_udc_info): manager._set_system_led(chassis, manager.config, 'normal') def test_utils(): - output = utils.run_command(['some', 'invalid', 'command']) + output = utils.run_command('some invalid command') assert not output - output = utils.run_command(['ls']) + output = utils.run_command('ls') assert output