From 90412883593666c60ff6c3fbc5872ecc7d9968e9 Mon Sep 17 00:00:00 2001 From: Haiyang Zheng Date: Thu, 15 Jun 2017 10:31:13 -0700 Subject: [PATCH 01/45] [build_debian]: Add dbus package to update timezone (#702) Signed-off-by: Hiayang Zheng haiyang.z@alibaba.inc --- build_debian.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build_debian.sh b/build_debian.sh index eed63e6eb070..71f849151a94 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -176,6 +176,7 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in sudo \ vim \ tcpdump \ + dbus \ ntp \ ntpstat \ openssh-server \ From c1c8a122bea2aac5eefc8d19ada0beed059daed5 Mon Sep 17 00:00:00 2001 From: Polly Hsu Date: Fri, 16 Jun 2017 01:33:42 +0800 Subject: [PATCH 02/45] [Accton]: Add a new supported device and platform, AS7712-32X (#662) * platform/broadcom: Add a new supported device and platform, AS7712-32X * Switch Vendor: Edge-core * Switch SKU: AS7712-32X * ASIC Vendor: Broadcom * Swich ASIC: Tomahawk * Port Configuration: 32x100G * SONiC Image: SONiC-ONIE-Broadcom Signed-off-by: polly_hsu@accton.com --- .../Accton-AS7712-32X/port_config.ini | 33 + .../Accton-AS7712-32X/sai.profile | 2 + .../installer.conf | 3 + .../x86_64-accton_as7712_32x-r0/minigraph.xml | 1074 ++++++++++++++++ platform/broadcom/one-image.mk | 3 +- platform/broadcom/platform-modules-accton.mk | 14 + platform/broadcom/rules.mk | 1 + .../sonic-platform-modules-accton/.gitignore | 33 + .../sonic-platform-modules-accton/LICENSE | 16 + .../sonic-platform-modules-accton/README.md | 1 + .../as7712-32x/cfg/as7712_32x-modules.conf | 13 + .../as7712-32x/modules/Makefile | 2 + .../modules/accton_as7712_32x_fan.c | 452 +++++++ .../modules/accton_as7712_32x_psu.c | 293 +++++ .../modules/accton_as7712_32x_sfp.c | 1083 +++++++++++++++++ .../as7712-32x/modules/accton_i2c_cpld.c | 259 ++++ .../modules/leds-accton_as7712_32x.c | 443 +++++++ .../as7712-32x/modules/ym2651y.c | 589 +++++++++ .../scripts/as7712_32x_platform_init.sh | 3 + .../debian/changelog | 5 + .../debian/compat | 1 + .../debian/control | 11 + .../debian/platform-modules-as7712-32x.init | 44 + .../platform-modules-as7712-32x.install | 2 + .../debian/rules | 36 + 25 files changed, 4415 insertions(+), 1 deletion(-) create mode 100644 device/accton/x86_64-accton_as7712_32x-r0/Accton-AS7712-32X/port_config.ini create mode 100644 device/accton/x86_64-accton_as7712_32x-r0/Accton-AS7712-32X/sai.profile create mode 100644 device/accton/x86_64-accton_as7712_32x-r0/installer.conf create mode 100644 device/accton/x86_64-accton_as7712_32x-r0/minigraph.xml create mode 100644 platform/broadcom/platform-modules-accton.mk create mode 100644 platform/broadcom/sonic-platform-modules-accton/.gitignore create mode 100644 platform/broadcom/sonic-platform-modules-accton/LICENSE create mode 100644 platform/broadcom/sonic-platform-modules-accton/README.md create mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/cfg/as7712_32x-modules.conf create mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/Makefile create mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_fan.c create mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_psu.c create mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_sfp.c create mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_i2c_cpld.c create mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/leds-accton_as7712_32x.c create mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/ym2651y.c create mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/scripts/as7712_32x_platform_init.sh create mode 100644 platform/broadcom/sonic-platform-modules-accton/debian/changelog create mode 100644 platform/broadcom/sonic-platform-modules-accton/debian/compat create mode 100644 platform/broadcom/sonic-platform-modules-accton/debian/control create mode 100644 platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.init create mode 100644 platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.install create mode 100644 platform/broadcom/sonic-platform-modules-accton/debian/rules diff --git a/device/accton/x86_64-accton_as7712_32x-r0/Accton-AS7712-32X/port_config.ini b/device/accton/x86_64-accton_as7712_32x-r0/Accton-AS7712-32X/port_config.ini new file mode 100644 index 000000000000..1fa6d21d9609 --- /dev/null +++ b/device/accton/x86_64-accton_as7712_32x-r0/Accton-AS7712-32X/port_config.ini @@ -0,0 +1,33 @@ +# name lanes alias +Ethernet0 49,50,51,52 hundredGigE1 +Ethernet4 53,54,55,56 hundredGigE2 +Ethernet8 57,58,59,60 hundredGigE3 +Ethernet12 61,62,63,64 hundredGigE4 +Ethernet16 65,66,67,68 hundredGigE5 +Ethernet20 69,70,71,72 hundredGigE6 +Ethernet24 73,74,75,76 hundredGigE7 +Ethernet28 77,78,79,80 hundredGigE8 +Ethernet32 33,34,35,36 hundredGigE9 +Ethernet36 37,38,39,40 hundredGigE10 +Ethernet40 41,42,43,44 hundredGigE11 +Ethernet44 45,46,47,48 hundredGigE12 +Ethernet48 81,82,83,84 hundredGigE13 +Ethernet52 85,86,87,88 hundredGigE14 +Ethernet56 89,90,91,92 hundredGigE15 +Ethernet60 93,94,95,96 hundredGigE16 +Ethernet64 97,98,99,100 hundredGigE17 +Ethernet68 101,102,103,104 hundredGigE18 +Ethernet72 105,106,107,108 hundredGigE19 +Ethernet76 109,110,111,112 hundredGigE20 +Ethernet80 17,18,19,20 hundredGigE21 +Ethernet84 21,22,23,24 hundredGigE22 +Ethernet88 25,26,27,28 hundredGigE23 +Ethernet92 29,30,31,32 hundredGigE24 +Ethernet96 113,114,115,116 hundredGigE25 +Ethernet100 117,118,119,120 hundredGigE26 +Ethernet104 121,122,123,124 hundredGigE27 +Ethernet108 125,126,127,128 hundredGigE28 +Ethernet112 1,2,3,4 hundredGigE29 +Ethernet116 5,6,7,8 hundredGigE30 +Ethernet120 9,10,11,12 hundredGigE31 +Ethernet124 13,14,15,16 hundredGigE32 diff --git a/device/accton/x86_64-accton_as7712_32x-r0/Accton-AS7712-32X/sai.profile b/device/accton/x86_64-accton_as7712_32x-r0/Accton-AS7712-32X/sai.profile new file mode 100644 index 000000000000..5ed350f24d7f --- /dev/null +++ b/device/accton/x86_64-accton_as7712_32x-r0/Accton-AS7712-32X/sai.profile @@ -0,0 +1,2 @@ +SAI_INIT_CONFIG_FILE=/etc/bcm/th-as7712-32x100G.config.bcm + diff --git a/device/accton/x86_64-accton_as7712_32x-r0/installer.conf b/device/accton/x86_64-accton_as7712_32x-r0/installer.conf new file mode 100644 index 000000000000..14404194ef53 --- /dev/null +++ b/device/accton/x86_64-accton_as7712_32x-r0/installer.conf @@ -0,0 +1,3 @@ +CONSOLE_PORT=0x2f8 +CONSOLE_DEV=1 +CONSOLE_SPEED=115200 diff --git a/device/accton/x86_64-accton_as7712_32x-r0/minigraph.xml b/device/accton/x86_64-accton_as7712_32x-r0/minigraph.xml new file mode 100644 index 000000000000..025985c83675 --- /dev/null +++ b/device/accton/x86_64-accton_as7712_32x-r0/minigraph.xml @@ -0,0 +1,1074 @@ + + + + + + ARISTA01T0 + 10.0.0.33 + switch1 + 10.0.0.32 + 1 + 180 + 60 + + + switch1 + 10.0.0.0 + ARISTA01T2 + 10.0.0.1 + 1 + 180 + 60 + + + ARISTA02T0 + 10.0.0.35 + switch1 + 10.0.0.34 + 1 + 180 + 60 + + + switch1 + 10.0.0.2 + ARISTA02T2 + 10.0.0.3 + 1 + 180 + 60 + + + ARISTA03T0 + 10.0.0.37 + switch1 + 10.0.0.36 + 1 + 180 + 60 + + + switch1 + 10.0.0.4 + ARISTA03T2 + 10.0.0.5 + 1 + 180 + 60 + + + ARISTA04T0 + 10.0.0.39 + switch1 + 10.0.0.38 + 1 + 180 + 60 + + + switch1 + 10.0.0.6 + ARISTA04T2 + 10.0.0.7 + 1 + 180 + 60 + + + ARISTA05T0 + 10.0.0.41 + switch1 + 10.0.0.40 + 1 + 180 + 60 + + + switch1 + 10.0.0.8 + ARISTA05T2 + 10.0.0.9 + 1 + 180 + 60 + + + ARISTA06T0 + 10.0.0.43 + switch1 + 10.0.0.42 + 1 + 180 + 60 + + + switch1 + 10.0.0.10 + ARISTA06T2 + 10.0.0.11 + 1 + 180 + 60 + + + ARISTA07T0 + 10.0.0.45 + switch1 + 10.0.0.44 + 1 + 180 + 60 + + + switch1 + 10.0.0.12 + ARISTA07T2 + 10.0.0.13 + 1 + 180 + 60 + + + ARISTA08T0 + 10.0.0.47 + switch1 + 10.0.0.46 + 1 + 180 + 60 + + + switch1 + 10.0.0.14 + ARISTA08T2 + 10.0.0.15 + 1 + 180 + 60 + + + ARISTA09T0 + 10.0.0.49 + switch1 + 10.0.0.48 + 1 + 180 + 60 + + + switch1 + 10.0.0.16 + ARISTA09T2 + 10.0.0.17 + 1 + 180 + 60 + + + ARISTA10T0 + 10.0.0.51 + switch1 + 10.0.0.50 + 1 + 180 + 60 + + + switch1 + 10.0.0.18 + ARISTA10T2 + 10.0.0.19 + 1 + 180 + 60 + + + ARISTA11T0 + 10.0.0.53 + switch1 + 10.0.0.52 + 1 + 180 + 60 + + + switch1 + 10.0.0.20 + ARISTA11T2 + 10.0.0.21 + 1 + 180 + 60 + + + ARISTA12T0 + 10.0.0.55 + switch1 + 10.0.0.54 + 1 + 180 + 60 + + + switch1 + 10.0.0.22 + ARISTA12T2 + 10.0.0.23 + 1 + 180 + 60 + + + ARISTA13T0 + 10.0.0.57 + switch1 + 10.0.0.56 + 1 + 180 + 60 + + + switch1 + 10.0.0.24 + ARISTA13T2 + 10.0.0.25 + 1 + 180 + 60 + + + ARISTA14T0 + 10.0.0.59 + switch1 + 10.0.0.58 + 1 + 180 + 60 + + + switch1 + 10.0.0.26 + ARISTA14T2 + 10.0.0.27 + 1 + 180 + 60 + + + ARISTA15T0 + 10.0.0.61 + switch1 + 10.0.0.60 + 1 + 180 + 60 + + + switch1 + 10.0.0.28 + ARISTA15T2 + 10.0.0.29 + 1 + 180 + 60 + + + ARISTA16T0 + 10.0.0.63 + switch1 + 10.0.0.62 + 1 + 180 + 60 + + + switch1 + 10.0.0.30 + ARISTA16T2 + 10.0.0.31 + 1 + 180 + 60 + + + + + 65100 + switch1 + + +
10.0.0.33
+ + +
+ +
10.0.0.1
+ + +
+ +
10.0.0.35
+ + +
+ +
10.0.0.3
+ + +
+ +
10.0.0.37
+ + +
+ +
10.0.0.5
+ + +
+ +
10.0.0.39
+ + +
+ +
10.0.0.7
+ + +
+ +
10.0.0.41
+ + +
+ +
10.0.0.9
+ + +
+ +
10.0.0.43
+ + +
+ +
10.0.0.11
+ + +
+ +
10.0.0.45
+ + +
+ +
10.0.0.13
+ + +
+ +
10.0.0.47
+ + +
+ +
10.0.0.15
+ + +
+ +
10.0.0.49
+ + +
+ +
10.0.0.17
+ + +
+ +
10.0.0.51
+ + +
+ +
10.0.0.19
+ + +
+ +
10.0.0.53
+ + +
+ +
10.0.0.21
+ + +
+ +
10.0.0.55
+ + +
+ +
10.0.0.23
+ + +
+ +
10.0.0.57
+ + +
+ +
10.0.0.25
+ + +
+ +
10.0.0.59
+ + +
+ +
10.0.0.27
+ + +
+ +
10.0.0.61
+ + +
+ +
10.0.0.29
+ + +
+ +
10.0.0.63
+ + +
+ +
10.0.0.31
+ + +
+
+ +
+ + 64001 + ARISTA01T0 + + + + 65200 + ARISTA01T2 + + + + 64002 + ARISTA02T0 + + + + 65200 + ARISTA02T2 + + + + 64003 + ARISTA03T0 + + + + 65200 + ARISTA03T2 + + + + 64004 + ARISTA04T0 + + + + 65200 + ARISTA04T2 + + + + 64005 + ARISTA05T0 + + + + 65200 + ARISTA05T2 + + + + 64006 + ARISTA06T0 + + + + 65200 + ARISTA06T2 + + + + 64007 + ARISTA07T0 + + + + 65200 + ARISTA07T2 + + + + 64008 + ARISTA08T0 + + + + 65200 + ARISTA08T2 + + + + 64009 + ARISTA09T0 + + + + 65200 + ARISTA09T2 + + + + 64010 + ARISTA10T0 + + + + 65200 + ARISTA10T2 + + + + 64011 + ARISTA11T0 + + + + 65200 + ARISTA11T2 + + + + 64012 + ARISTA12T0 + + + + 65200 + ARISTA12T2 + + + + 64013 + ARISTA13T0 + + + + 65200 + ARISTA13T2 + + + + 64014 + ARISTA14T0 + + + + 65200 + ARISTA14T2 + + + + 64015 + ARISTA15T0 + + + + 65200 + ARISTA15T2 + + + + 64016 + ARISTA16T0 + + + + 65200 + ARISTA16T2 + + +
+
+ + + + + + HostIP + Loopback0 + + 10.1.0.32/32 + + 10.1.0.32/32 + + + + + + + + switch1 + + + + + + Ethernet0 + 10.0.0.0/31 + + + + Ethernet4 + 10.0.0.2/31 + + + + Ethernet8 + 10.0.0.4/31 + + + + Ethernet12 + 10.0.0.6/31 + + + + Ethernet16 + 10.0.0.8/31 + + + + Ethernet20 + 10.0.0.10/31 + + + + Ethernet24 + 10.0.0.12/31 + + + + Ethernet28 + 10.0.0.14/31 + + + + Ethernet32 + 10.0.0.16/31 + + + + Ethernet36 + 10.0.0.18/31 + + + + Ethernet40 + 10.0.0.20/31 + + + + Ethernet44 + 10.0.0.22/31 + + + + Ethernet48 + 10.0.0.24/31 + + + + Ethernet52 + 10.0.0.26/31 + + + + Ethernet56 + 10.0.0.28/31 + + + + Ethernet60 + 10.0.0.30/31 + + + + Ethernet64 + 10.0.0.32/31 + + + + Ethernet68 + 10.0.0.34/31 + + + + Ethernet72 + 10.0.0.36/31 + + + + Ethernet76 + 10.0.0.38/31 + + + + Ethernet80 + 10.0.0.40/31 + + + + Ethernet84 + 10.0.0.42/31 + + + + Ethernet88 + 10.0.0.44/31 + + + + Ethernet92 + 10.0.0.46/31 + + + + Ethernet96 + 10.0.0.48/31 + + + + Ethernet100 + 10.0.0.50/31 + + + + Ethernet104 + 10.0.0.52/31 + + + + Ethernet108 + 10.0.0.54/31 + + + + Ethernet112 + 10.0.0.56/31 + + + + Ethernet116 + 10.0.0.58/31 + + + + Ethernet120 + 10.0.0.60/31 + + + + Ethernet124 + 10.0.0.62/31 + + + + + + + + + + + + DeviceInterfaceLink + switch1 + Ethernet0 + ARISTA01T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet4 + ARISTA02T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet8 + ARISTA03T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet12 + ARISTA04T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet16 + ARISTA05T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet20 + ARISTA06T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet24 + ARISTA07T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet28 + ARISTA08T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet32 + ARISTA09T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet36 + ARISTA10T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet40 + ARISTA11T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet44 + ARISTA12T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet48 + ARISTA13T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet52 + ARISTA14T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet56 + ARISTA15T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet60 + ARISTA16T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet64 + ARISTA01T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet68 + ARISTA02T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet72 + ARISTA03T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet76 + ARISTA04T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet80 + ARISTA05T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet84 + ARISTA06T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet88 + ARISTA07T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet92 + ARISTA08T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet96 + ARISTA09T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet100 + ARISTA10T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet104 + ARISTA11T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet108 + ARISTA12T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet112 + ARISTA13T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet116 + ARISTA14T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet120 + ARISTA15T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet124 + ARISTA16T0 + Ethernet1 + + + + + switch1 + Accton-AS7712-32X + + + + + + + switch1 + + + DhcpResources + + + + + NtpResources + + 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org + + + SyslogResources + + + + + + + + + switch1 + Accton-AS7712-32X +
diff --git a/platform/broadcom/one-image.mk b/platform/broadcom/one-image.mk index 3af81b325d77..600e1159b400 100644 --- a/platform/broadcom/one-image.mk +++ b/platform/broadcom/one-image.mk @@ -9,6 +9,7 @@ $(SONIC_ONE_IMAGE)_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \ $(DELL_S6100_PLATFORM_MODULE) \ $(INGRASYS_S8900_54XC_PLATFORM_MODULE) \ $(INGRASYS_S8900_64XC_PLATFORM_MODULE) \ - $(INGRASYS_S9100_PLATFORM_MODULE) + $(INGRASYS_S9100_PLATFORM_MODULE) \ + $(ACCTON_AS7712_32X_PLATFORM_MODULE) $(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_IMAGES) SONIC_INSTALLERS += $(SONIC_ONE_IMAGE) diff --git a/platform/broadcom/platform-modules-accton.mk b/platform/broadcom/platform-modules-accton.mk new file mode 100644 index 000000000000..00128a20f8d2 --- /dev/null +++ b/platform/broadcom/platform-modules-accton.mk @@ -0,0 +1,14 @@ +# Accton Platform modules + +ACCTON_AS7712_32X_PLATFORM_MODULE_VERSION = 1.0 + +export ACCTON_AS7712_32X_PLATFORM_MODULE_VERSION + +ACCTON_AS7712_32X_PLATFORM_MODULE = platform-modules-as7712-32x_$(ACCTON_AS7712_32X_PLATFORM_MODULE_VERSION)_amd64.deb +$(ACCTON_AS7712_32X_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-accton +$(ACCTON_AS7712_32X_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) +$(ACCTON_AS7712_32X_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as7712_32x-r0 +SONIC_DPKG_DEBS += $(ACCTON_AS7712_32X_PLATFORM_MODULE) + +$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE))) + diff --git a/platform/broadcom/rules.mk b/platform/broadcom/rules.mk index 18ba86d1c0ce..3f0d523d4204 100755 --- a/platform/broadcom/rules.mk +++ b/platform/broadcom/rules.mk @@ -4,6 +4,7 @@ include $(PLATFORM_PATH)/platform-modules-s6000.mk include $(PLATFORM_PATH)/platform-modules-dell.mk include $(PLATFORM_PATH)/platform-modules-arista.mk include $(PLATFORM_PATH)/platform-modules-ingrasys.mk +include $(PLATFORM_PATH)/platform-modules-accton.mk include $(PLATFORM_PATH)/docker-orchagent-brcm.mk include $(PLATFORM_PATH)/docker-syncd-brcm.mk include $(PLATFORM_PATH)/docker-syncd-brcm-rpc.mk diff --git a/platform/broadcom/sonic-platform-modules-accton/.gitignore b/platform/broadcom/sonic-platform-modules-accton/.gitignore new file mode 100644 index 000000000000..f805e810e5c6 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/.gitignore @@ -0,0 +1,33 @@ +# Object files +*.o +*.ko +*.obj +*.elf + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su diff --git a/platform/broadcom/sonic-platform-modules-accton/LICENSE b/platform/broadcom/sonic-platform-modules-accton/LICENSE new file mode 100644 index 000000000000..bc693f7a4c40 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/LICENSE @@ -0,0 +1,16 @@ +Copyright (C) 2016 Microsoft, Inc +Copyright (C) 2017 Accton Technology Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/platform/broadcom/sonic-platform-modules-accton/README.md b/platform/broadcom/sonic-platform-modules-accton/README.md new file mode 100644 index 000000000000..743db0cb238f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/README.md @@ -0,0 +1 @@ +platform drivers for AS7712_32X for the SONiC project diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/cfg/as7712_32x-modules.conf b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/cfg/as7712_32x-modules.conf new file mode 100644 index 000000000000..cf2c5fa775bd --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/cfg/as7712_32x-modules.conf @@ -0,0 +1,13 @@ +# /etc/modules: kernel modules to load at boot time. +# +# This file contains the names of kernel modules that should be loaded +# at boot time, one per line. Lines beginning with "#" are ignored. + +i2c_dev +i2c_mux_pca954x +accton_i2c_cpld +accton_as7712_32x_fan +accton_as7712_32x_sfp +leds-accton_as7712_32x +accton_as7712_32x_psu + diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/Makefile b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/Makefile new file mode 100644 index 000000000000..83319ec62e58 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/Makefile @@ -0,0 +1,2 @@ +obj-m:=accton_as7712_32x_fan.o accton_as7712_32x_sfp.o leds-accton_as7712_32x.o \ + accton_as7712_32x_psu.o accton_i2c_cpld.o ym2651y.o \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_fan.c new file mode 100644 index 000000000000..52db1e9dc028 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_fan.c @@ -0,0 +1,452 @@ +/* + * A hwmon driver for the Accton as7712 32x fan + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as7712_32x_fan" + +static struct as7712_32x_fan_data *as7712_32x_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 accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int accton_i2c_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[] = { + 0x0F, /* fan 1-6 present status */ + 0x11, /* fan PWM(for all fan) */ + 0x12, /* front fan 1 speed(rpm) */ + 0x13, /* front fan 2 speed(rpm) */ + 0x14, /* front fan 3 speed(rpm) */ + 0x15, /* front fan 4 speed(rpm) */ + 0x16, /* front fan 5 speed(rpm) */ + 0x17, /* front fan 6 speed(rpm) */ + 0x22, /* rear fan 1 speed(rpm) */ + 0x23, /* rear fan 2 speed(rpm) */ + 0x24, /* rear fan 3 speed(rpm) */ + 0x25, /* rear fan 4 speed(rpm) */ + 0x26, /* rear fan 5 speed(rpm) */ + 0x27, /* rear fan 6 speed(rpm) */ +}; + +/* Each client has this additional data */ +struct as7712_32x_fan_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */ +}; + +enum fan_id { + FAN1_ID, + FAN2_ID, + FAN3_ID, + FAN4_ID, + FAN5_ID, + FAN6_ID +}; + +enum sysfs_fan_attributes { + FAN_PRESENT_REG, + FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */ + FAN1_FRONT_SPEED_RPM, + FAN2_FRONT_SPEED_RPM, + FAN3_FRONT_SPEED_RPM, + FAN4_FRONT_SPEED_RPM, + FAN5_FRONT_SPEED_RPM, + FAN6_FRONT_SPEED_RPM, + FAN1_REAR_SPEED_RPM, + FAN2_REAR_SPEED_RPM, + FAN3_REAR_SPEED_RPM, + FAN4_REAR_SPEED_RPM, + FAN5_REAR_SPEED_RPM, + FAN6_REAR_SPEED_RPM, + FAN1_PRESENT, + FAN2_PRESENT, + FAN3_PRESENT, + FAN4_PRESENT, + FAN5_PRESENT, + FAN6_PRESENT, + FAN1_FAULT, + FAN2_FAULT, + FAN3_FAULT, + FAN4_FAULT, + FAN5_FAULT, + FAN6_FAULT +}; + +/* 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_DIRECTION_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_direction, S_IRUGO, fan_show_value, NULL, FAN##index##_DIRECTION) +#define DECLARE_FAN_DIRECTION_ATTR(index) &sensor_dev_attr_fan##index##_direction.dev_attr.attr + +#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE) +#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr + +#define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) +#define DECLARE_FAN_PRESENT_ATTR(index) &sensor_dev_attr_fan##index##_present.dev_attr.attr + +#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_front_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\ + static SENSOR_DEVICE_ATTR(fan##index##_rear_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM) +#define DECLARE_FAN_SPEED_RPM_ATTR(index) &sensor_dev_attr_fan##index##_front_speed_rpm.dev_attr.attr, \ + &sensor_dev_attr_fan##index##_rear_speed_rpm.dev_attr.attr + +/* 6 fan fault attributes in this platform */ +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(4); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(5); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(6); +/* 6 fan speed(rpm) attributes in this platform */ +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(4); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(5); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(6); +/* 6 fan present attributes in this platform */ +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(1); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(2); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(3); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(4); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(5); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(6); +/* 1 fan duty cycle attribute in this platform */ +DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(); + +static struct attribute *as7712_32x_fan_attributes[] = { + /* fan related attributes */ + DECLARE_FAN_FAULT_ATTR(1), + DECLARE_FAN_FAULT_ATTR(2), + DECLARE_FAN_FAULT_ATTR(3), + DECLARE_FAN_FAULT_ATTR(4), + DECLARE_FAN_FAULT_ATTR(5), + DECLARE_FAN_FAULT_ATTR(6), + DECLARE_FAN_SPEED_RPM_ATTR(1), + DECLARE_FAN_SPEED_RPM_ATTR(2), + DECLARE_FAN_SPEED_RPM_ATTR(3), + DECLARE_FAN_SPEED_RPM_ATTR(4), + DECLARE_FAN_SPEED_RPM_ATTR(5), + DECLARE_FAN_SPEED_RPM_ATTR(6), + DECLARE_FAN_PRESENT_ATTR(1), + DECLARE_FAN_PRESENT_ATTR(2), + DECLARE_FAN_PRESENT_ATTR(3), + DECLARE_FAN_PRESENT_ATTR(4), + DECLARE_FAN_PRESENT_ATTR(5), + DECLARE_FAN_PRESENT_ATTR(6), + DECLARE_FAN_DUTY_CYCLE_ATTR(), + NULL +}; + +#define FAN_DUTY_CYCLE_REG_MASK 0xF +#define FAN_MAX_DUTY_CYCLE 100 +#define FAN_REG_VAL_TO_SPEED_RPM_STEP 100 + +static int as7712_32x_fan_read_value(struct i2c_client *client, u8 reg) +{ + return i2c_smbus_read_byte_data(client, reg); +} + +static int as7712_32x_fan_write_value(struct i2c_client *client, u8 reg, u8 value) +{ + return i2c_smbus_write_byte_data(client, reg, value); +} + +/* fan utility functions + */ +static u32 reg_val_to_duty_cycle(u8 reg_val) +{ + reg_val &= FAN_DUTY_CYCLE_REG_MASK; + return ((u32)(reg_val+1) * 625 + 75)/ 100; +} + +static u8 duty_cycle_to_reg_val(u8 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 reg_val_to_is_present(u8 reg_val, enum fan_id id) +{ + u8 mask = (1 << id); + + reg_val &= mask; + + return reg_val ? 0 : 1; +} + +static u8 is_fan_fault(struct as7712_32x_fan_data *data, enum fan_id id) +{ + u8 ret = 1; + int front_fan_index = FAN1_FRONT_SPEED_RPM + id; + int rear_fan_index = FAN1_REAR_SPEED_RPM + id; + + /* Check if the speed of front or rear fan is ZERO, + */ + if (reg_val_to_speed_rpm(data->reg_val[front_fan_index]) && + reg_val_to_speed_rpm(data->reg_val[rear_fan_index])) { + ret = 0; + } + + return ret; +} + +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int error, value; + struct i2c_client *client = to_i2c_client(dev); + + error = kstrtoint(buf, 10, &value); + if (error) + return error; + + if (value < 0 || value > FAN_MAX_DUTY_CYCLE) + return -EINVAL; + + as7712_32x_fan_write_value(client, 0x33, 0); /* Disable fan speed watch dog */ + as7712_32x_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); + return count; +} + +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as7712_32x_fan_data *data = as7712_32x_fan_update_device(dev); + ssize_t ret = 0; + + if (data->valid) { + switch (attr->index) { + case FAN_DUTY_CYCLE_PERCENTAGE: + { + u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]); + ret = sprintf(buf, "%u\n", duty_cycle); + break; + } + case FAN1_FRONT_SPEED_RPM: + case FAN2_FRONT_SPEED_RPM: + case FAN3_FRONT_SPEED_RPM: + case FAN4_FRONT_SPEED_RPM: + case FAN5_FRONT_SPEED_RPM: + case FAN6_FRONT_SPEED_RPM: + case FAN1_REAR_SPEED_RPM: + case FAN2_REAR_SPEED_RPM: + case FAN3_REAR_SPEED_RPM: + case FAN4_REAR_SPEED_RPM: + case FAN5_REAR_SPEED_RPM: + case FAN6_REAR_SPEED_RPM: + ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index])); + break; + case FAN1_PRESENT: + case FAN2_PRESENT: + case FAN3_PRESENT: + case FAN4_PRESENT: + case FAN5_PRESENT: + case FAN6_PRESENT: + ret = sprintf(buf, "%d\n", + reg_val_to_is_present(data->reg_val[FAN_PRESENT_REG], + attr->index - FAN1_PRESENT)); + break; + case FAN1_FAULT: + case FAN2_FAULT: + case FAN3_FAULT: + case FAN4_FAULT: + case FAN5_FAULT: + case FAN6_FAULT: + ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT)); + break; + default: + break; + } + } + + return ret; +} + +static const struct attribute_group as7712_32x_fan_group = { + .attrs = as7712_32x_fan_attributes, +}; + +static struct as7712_32x_fan_data *as7712_32x_fan_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as7712_32x_fan_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || + !data->valid) { + int i; + + dev_dbg(&client->dev, "Starting as7712_32x_fan update\n"); + data->valid = 0; + + /* Update fan data + */ + for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) { + int status = as7712_32x_fan_read_value(client, fan_reg[i]); + + if (status < 0) { + data->valid = 0; + mutex_unlock(&data->update_lock); + dev_dbg(&client->dev, "reg %d, err %d\n", fan_reg[i], status); + return data; + } + else { + data->reg_val[i] = status; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +static int as7712_32x_fan_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as7712_32x_fan_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as7712_32x_fan_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as7712_32x_fan_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: fan '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as7712_32x_fan_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as7712_32x_fan_remove(struct i2c_client *client) +{ + struct as7712_32x_fan_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as7712_32x_fan_group); + + return 0; +} + +/* Addresses to scan */ +static const unsigned short normal_i2c[] = { 0x66, I2C_CLIENT_END }; + +static const struct i2c_device_id as7712_32x_fan_id[] = { + { "as7712_32x_fan", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as7712_32x_fan_id); + +static struct i2c_driver as7712_32x_fan_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = DRVNAME, + }, + .probe = as7712_32x_fan_probe, + .remove = as7712_32x_fan_remove, + .id_table = as7712_32x_fan_id, + .address_list = normal_i2c, +}; + +static int __init as7712_32x_fan_init(void) +{ + extern int platform_accton_as7712_32x(void); + if (!platform_accton_as7712_32x()) { + return -ENODEV; + } + + return i2c_add_driver(&as7712_32x_fan_driver); +} + +static void __exit as7712_32x_fan_exit(void) +{ + i2c_del_driver(&as7712_32x_fan_driver); +} + +module_init(as7712_32x_fan_init); +module_exit(as7712_32x_fan_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as7712_32x_fan driver"); +MODULE_LICENSE("GPL"); + diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_psu.c new file mode 100644 index 000000000000..8c9230ab2d24 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_psu.c @@ -0,0 +1,293 @@ +/* + * An hwmon driver for accton as7712_32x 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 + +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 int as7712_32x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); +extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { 0x50, 0x53, I2C_CLIENT_END }; + +/* Each client has this additional data + */ +struct as7712_32x_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[9]; /* Model name, read from eeprom */ +}; + +static struct as7712_32x_psu_data *as7712_32x_psu_update_device(struct device *dev); + +enum as7712_32x_psu_sysfs_attributes { + PSU_PRESENT, + PSU_MODEL_NAME, + 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_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); + +static struct attribute *as7712_32x_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, + NULL +}; + +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as7712_32x_psu_data *data = as7712_32x_psu_update_device(dev); + u8 status = 0; + + if (attr->index == PSU_PRESENT) { + status = !(data->status >> (1-data->index) & 0x1); + } + else { /* PSU_POWER_GOOD */ + status = (data->status >> (3-data->index) & 0x1); + } + + return sprintf(buf, "%d\n", status); +} + +static ssize_t show_model_name(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct as7712_32x_psu_data *data = as7712_32x_psu_update_device(dev); + + return sprintf(buf, "%s\n", data->model_name); +} + +static const struct attribute_group as7712_32x_psu_group = { + .attrs = as7712_32x_psu_attributes, +}; + +static int as7712_32x_psu_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as7712_32x_psu_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as7712_32x_psu_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + data->index = dev_id->driver_data; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as7712_32x_psu_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: psu '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as7712_32x_psu_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as7712_32x_psu_remove(struct i2c_client *client) +{ + struct as7712_32x_psu_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as7712_32x_psu_group); + kfree(data); + + return 0; +} + +enum psu_index +{ + as7712_32x_psu1, + as7712_32x_psu2 +}; + +static const struct i2c_device_id as7712_32x_psu_id[] = { + { "as7712_32x_psu1", as7712_32x_psu1 }, + { "as7712_32x_psu2", as7712_32x_psu2 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as7712_32x_psu_id); + +static struct i2c_driver as7712_32x_psu_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "as7712_32x_psu", + }, + .probe = as7712_32x_psu_probe, + .remove = as7712_32x_psu_remove, + .id_table = as7712_32x_psu_id, + .address_list = normal_i2c, +}; + +static int as7712_32x_psu_read_block(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ + int result = 0; + int retry_count = 5; + + while (retry_count) { + retry_count--; + + result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + + if (unlikely(result < 0)) { + msleep(10); + continue; + } + + if (unlikely(result != data_len)) { + result = -EIO; + msleep(10); + continue; + } + + result = 0; + break; + } + + return result; +} + +static struct as7712_32x_psu_data *as7712_32x_psu_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as7712_32x_psu_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + int status; + int power_good = 0; + + dev_dbg(&client->dev, "Starting as7712_32x update\n"); + + /* Read psu status */ + status = accton_i2c_cpld_read(0x60, 0x2); + + if (status < 0) { + dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); + } + else { + data->status = status; + } + + /* Read model name */ + memset(data->model_name, 0, sizeof(data->model_name)); + power_good = (data->status >> (3-data->index) & 0x1); + + if (power_good) { + status = as7712_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); + } + else { + data->model_name[ARRAY_SIZE(data->model_name)-1] = '\0'; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +static int __init as7712_32x_psu_init(void) +{ + extern int platform_accton_as7712_32x(void); + if (!platform_accton_as7712_32x()) { + return -ENODEV; + } + + return i2c_add_driver(&as7712_32x_psu_driver); +} + +static void __exit as7712_32x_psu_exit(void) +{ + i2c_del_driver(&as7712_32x_psu_driver); +} + +module_init(as7712_32x_psu_init); +module_exit(as7712_32x_psu_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as7712_32x_psu driver"); +MODULE_LICENSE("GPL"); + diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_sfp.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_sfp.c new file mode 100644 index 000000000000..4366d2a6ea1d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_sfp.c @@ -0,0 +1,1083 @@ +/* + * SFP driver for accton as7712_32x sfp + * + * Copyright (C) Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME "as7712_32x_sfp" + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#define NUM_OF_SFP_PORT 32 +#define EEPROM_NAME "sfp_eeprom" +#define EEPROM_SIZE 256 /* 256 byte eeprom */ +#define BIT_INDEX(i) (1ULL << (i)) +#define USE_I2C_BLOCK_READ 1 +#define I2C_RW_RETRY_COUNT 3 +#define I2C_RW_RETRY_INTERVAL 100 /* ms */ + +#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) +#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) + +#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 +#define SFF8024_DEVICE_ID_SFP 0x3 +#define SFF8024_DEVICE_ID_QSFP 0xC +#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD +#define SFF8024_DEVICE_ID_QSFP28 0x11 + +#define SFF8472_DIAG_MON_TYPE_ADDR 92 +#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 +#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 +#define SFF8472_10G_BASE_MASK 0xF0 + +#define SFF8436_RX_LOS_ADDR 3 +#define SFF8436_TX_FAULT_ADDR 4 +#define SFF8436_TX_DISABLE_ADDR 86 + +static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); +static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); +extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { SFP_EEPROM_A0_I2C_ADDR, SFP_EEPROM_A2_I2C_ADDR, I2C_CLIENT_END }; + +#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) + +enum port_numbers { +sfp1, sfp2, sfp3, sfp4, sfp5, sfp6, sfp7, sfp8, +sfp9, sfp10, sfp11, sfp12, sfp13, sfp14, sfp15, sfp16, +sfp17, sfp18, sfp19, sfp20, sfp21, sfp22, sfp23, sfp24, +sfp25, sfp26, sfp27, sfp28, sfp29, sfp30, sfp31, sfp32 +}; + +static const struct i2c_device_id sfp_device_id[] = { +{ "sfp1", sfp1 }, { "sfp2", sfp2 }, { "sfp3", sfp3 }, { "sfp4", sfp4 }, +{ "sfp5", sfp5 }, { "sfp6", sfp6 }, { "sfp7", sfp7 }, { "sfp8", sfp8 }, +{ "sfp9", sfp9 }, { "sfp10", sfp10 }, { "sfp11", sfp11 }, { "sfp12", sfp12 }, +{ "sfp13", sfp13 }, { "sfp14", sfp14 }, { "sfp15", sfp15 }, { "sfp16", sfp16 }, +{ "sfp17", sfp17 }, { "sfp18", sfp18 }, { "sfp19", sfp19 }, { "sfp20", sfp20 }, +{ "sfp21", sfp21 }, { "sfp22", sfp22 }, { "sfp23", sfp23 }, { "sfp24", sfp24 }, +{ "sfp25", sfp25 }, { "sfp26", sfp26 }, { "sfp27", sfp27 }, { "sfp28", sfp28 }, +{ "sfp29", sfp29 }, { "sfp30", sfp30 }, { "sfp31", sfp31 }, { "sfp32", sfp32 }, +{} +}; +MODULE_DEVICE_TABLE(i2c, sfp_device_id); + +/* + * list of valid port types + * note OOM_PORT_TYPE_NOT_PRESENT to indicate no + * module is present in this port + */ +typedef enum oom_driver_port_type_e { + OOM_DRIVER_PORT_TYPE_INVALID, + OOM_DRIVER_PORT_TYPE_NOT_PRESENT, + OOM_DRIVER_PORT_TYPE_SFP, + OOM_DRIVER_PORT_TYPE_SFP_PLUS, + OOM_DRIVER_PORT_TYPE_QSFP, + OOM_DRIVER_PORT_TYPE_QSFP_PLUS, + OOM_DRIVER_PORT_TYPE_QSFP28 +} oom_driver_port_type_t; + +enum driver_type_e { + DRIVER_TYPE_SFP_MSA, + DRIVER_TYPE_SFP_DDM, + DRIVER_TYPE_QSFP +}; + +/* Each client has this additional data + */ +struct eeprom_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + struct bin_attribute bin; /* eeprom data */ +}; + +struct sfp_msa_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u64 status[2]; /* index 0 => device id + 1 => 10G Ethernet Compliance Codes + to distinguish SFP or SFP+ + 2 => DIAGNOSTIC MONITORING TYPE */ + struct eeprom_data eeprom; +}; + +struct sfp_ddm_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u64 status[3]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss */ + struct eeprom_data eeprom; +}; + +struct qsfp_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 status[3]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss */ + + u8 device_id; + struct eeprom_data eeprom; +}; + +struct sfp_port_data { + struct mutex update_lock; + enum driver_type_e driver_type; + int port; /* CPLD port index */ + oom_driver_port_type_t port_type; + u64 present; /* present status, bit0:port0, bit1:port1 and so on */ + + struct sfp_msa_data *msa; + struct sfp_ddm_data *ddm; + struct qsfp_data *qsfp; + + struct i2c_client *client; +}; + +enum sfp_sysfs_attributes { + PRESENT, + PRESENT_ALL, + PORT_NUMBER, + PORT_TYPE, + DDM_IMPLEMENTED, + TX_FAULT, + TX_FAULT1, + TX_FAULT2, + TX_FAULT3, + TX_FAULT4, + TX_DISABLE, + TX_DISABLE1, + TX_DISABLE2, + TX_DISABLE3, + TX_DISABLE4, + TX_DISABLE_ALL, + RX_LOS, + RX_LOS1, + RX_LOS2, + RX_LOS3, + RX_LOS4, + RX_LOS_ALL +}; + +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); +} + +static struct sfp_port_data *sfp_update_present(struct i2c_client *client) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + int i = 0; + int status = -1; + u8 regs[] = {0x30, 0x31, 0x32, 0x33}; + + DEBUG_PRINT("Starting sfp present status update"); + mutex_lock(&data->update_lock); + + /* Read present status of port 1~32 */ + data->present = 0; + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = accton_i2c_cpld_read(0x60, regs[i]); + + if (status < 0) { + DEBUG_PRINT("cpld(0x60) reg(0x%x) err %d", regs[i], status); + goto exit; + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); + data->present |= (u64)status << (i*8); + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); +exit: + mutex_unlock(&data->update_lock); + return data; +} + +static struct sfp_port_data *sfp_update_tx_rx_status(struct device *dev) +{ + return NULL; +} + +static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + return 0; +} + +static int sfp_is_port_present(struct i2c_client *client, int port) +{ + struct sfp_port_data *data = sfp_update_present(client); + return (data->present & BIT_INDEX(data->port)) ? 0 : 1; +} + +static ssize_t show_present(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + if (PRESENT_ALL == attr->index) { + + } + + /* PRESENT */ + return sprintf(buf, "%d\n", sfp_is_port_present(client, data->port)); +} + +static struct sfp_port_data *sfp_update_port_type(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + u8 buf = 0; + int status; + + mutex_lock(&data->update_lock); + + switch (data->driver_type) { + case DRIVER_TYPE_SFP_MSA: + { + status = sfp_eeprom_read(data->client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); + if (status < 0) { + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + if (buf != SFF8024_DEVICE_ID_SFP) { + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + status = sfp_eeprom_read(data->client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); + if (status < 0) { + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); + data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; + break; + } + case DRIVER_TYPE_QSFP: + { + status = sfp_eeprom_read(data->client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); + if (status < 0) { + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); + switch (buf) { + case SFF8024_DEVICE_ID_QSFP: + data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; + break; + case SFF8024_DEVICE_ID_QSFP_PLUS: + data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; + break; + case SFF8024_DEVICE_ID_QSFP28: + data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; + break; + default: + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + break; + } + default: + break; + } + + mutex_unlock(&data->update_lock); + return data; +} + +static ssize_t show_port_type(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + if (!sfp_is_port_present(client, data->port)) { + return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); + } + + sfp_update_port_type(dev); + return sprintf(buf, "%d\n", data->port_type); +} + +static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int i, status = -1; + u8 buf = 0; + u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; + + if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { + return data; + } + + dev_dbg(dev, "Starting sfp tx rx status update"); + mutex_lock(&data->update_lock); + data->qsfp->valid = 0; + memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); + + /* Notify device to update tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(data->client, reg[i], &buf, sizeof(buf)); + if (status < 0) { + goto exit; + } + } + msleep(200); + + /* Read actual tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(data->client, reg[i], &buf, sizeof(buf)); + if (status < 0) { + goto exit; + } + + DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); + data->qsfp->status[i] = (buf & 0xF); + } + + data->qsfp->valid = 1; + data->qsfp->last_updated = jiffies; + mutex_unlock(&data->update_lock); + return data; + +exit: + mutex_unlock(&data->update_lock); + return NULL; +} + +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + u8 val = 0; + struct i2c_client *client = to_i2c_client(dev); + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct sfp_port_data *data = i2c_get_clientdata(client); + + if (!sfp_is_port_present(client, data->port)) { + return -ENODEV; + } + + data = qsfp_update_tx_rx_status(dev); + if (!data) { + return -EIO; + } + + switch (attr->index) { + case TX_FAULT1: + case TX_FAULT2: + case TX_FAULT3: + case TX_FAULT4: + val = (data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)) ? 1 : 0; + break; + case TX_DISABLE1: + case TX_DISABLE2: + case TX_DISABLE3: + case TX_DISABLE4: + val = (data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)) ? 1 : 0; + break; + case TX_DISABLE_ALL: + val = ((data->qsfp->status[1] & 0xF) == 0xF) ? 1 : 0; + break; + + case RX_LOS1: + case RX_LOS2: + case RX_LOS3: + case RX_LOS4: + val = (data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)) ? 1 : 0; + break; + default: + break; + } + + return sprintf(buf, "%d\n", val); +} + +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + long disable; + int result; + struct i2c_client *client = to_i2c_client(dev); + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct sfp_port_data *data; + + result = kstrtol(buf, 10, &disable); + if (result) { + return result; + } + + data = qsfp_update_tx_rx_status(dev); + if (!data) { + return -EIO; + } + + mutex_lock(&data->update_lock); + + DEBUG_PRINT ("%s-%d: disable:%u %d==%d %u\r\n", __FUNCTION__, __LINE__, + disable, attr->index, TX_DISABLE_ALL, data->qsfp->status[1]); + + if (attr->index == TX_DISABLE_ALL) + { + data->qsfp->status[1] = disable? 0xF:0; + } + else + { + if (disable) { + data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); + } + else { + data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); + } + } + DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); + result = sfp_eeprom_write(client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); + mutex_unlock(&data->update_lock); + return count; +} + +static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + char ddm; + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + if (!sfp_is_port_present(client, data->port)) { + return -ENODEV; + } + + status = sfp_eeprom_read(data->client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); + if (status < 0) { + return -EIO; + } + + return sprintf(buf, "%d\n", (ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK) ? 1 : 0); +} + +static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + u8 val = 0, index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct sfp_port_data *data; + + data = sfp_update_tx_rx_status(dev); + if (!data) { + return -EIO; + } + + switch (attr->index) { + case TX_FAULT: + index = 0; + break; + case TX_DISABLE: + index = 1; + break; + case RX_LOS: + index = 2; + break; + default: + break; + } + + val = (data->ddm->status[index] & BIT_INDEX(data->port)) ? 1 : 0; + return sprintf(buf, "%d\n", val); +} + +/* SFP/QSFP common attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); +static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); +static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); +static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT); + +/* QSFP attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); +static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); +static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); +static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); +static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); +static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); +static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); +static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); +static SENSOR_DEVICE_ATTR(sfp_tx_disable_all, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE_ALL); +static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); +static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); +static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); +static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); +static struct attribute *qsfp_attributes[] = { + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_port_type.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable_all.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, + NULL +}; + +/* SFP msa attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); +static struct attribute *sfp_msa_attributes[] = { + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_port_type.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, + NULL +}; + +/* SFP ddm attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); +static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); +static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); +static struct attribute *sfp_ddm_attributes[] = { + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + NULL +}; + +static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int result, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + result = i2c_smbus_write_i2c_block_data(client, command, data_len, data); + if (result < 0) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(result < 0)) { + return result; + } + + return data_len; +#else + int result, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + result = i2c_smbus_write_byte_data(client, command, *data); + if (result < 0) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(result < 0)) { + return result; + } + + return 1; +#endif + + +} + + +static ssize_t sfp_port_write(struct sfp_port_data *data, + const char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + return count; + } + + /* + * Write data to chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_write(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; +} + + +static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + struct sfp_port_data *data; + DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + return sfp_port_write(data, buf, off, count); +} + +static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int result, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + if (result < 0) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(result < 0)) + goto abort; + if (unlikely(result != data_len)) { + result = -EIO; + goto abort; + } + + //result = data_len; + +abort: + return result; +#else + int result, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + result = i2c_smbus_read_byte_data(client, command); + if (result < 0) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(result < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, result); + goto abort; + } + + *data = (u8)result; + result = 1; + +abort: + return result; +#endif +} + +static ssize_t sfp_port_read(struct sfp_port_data *data, + char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + DEBUG_PRINT("Count = 0, return"); + return count; + } + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_read(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; + +} + +static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + struct sfp_port_data *data; + DEBUG_PRINT("offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + return sfp_port_read(data, buf, off, count); +} + +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +{ + int err; + + sysfs_bin_attr_init(eeprom); + eeprom->attr.name = EEPROM_NAME; + eeprom->attr.mode = S_IWUSR | S_IRUGO; + eeprom->read = sfp_bin_read; + eeprom->write = sfp_bin_write; + eeprom->size = EEPROM_SIZE; + + /* Create eeprom file */ + err = sysfs_create_bin_file(kobj, eeprom); + if (err) { + return err; + } + + return 0; +} + +static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) +{ + sysfs_remove_bin_file(kobj, eeprom); + return 0; +} + +static const struct attribute_group sfp_msa_group = { + .attrs = sfp_msa_attributes, +}; + +static int sfp_i2c_check_functionality(struct i2c_client *client) +{ +#if USE_I2C_BLOCK_READ + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); +#else + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); +#endif +} + +static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct sfp_msa_data **data) +{ + int status; + struct sfp_msa_data *msa; + + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } + + msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); + if (!msa) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); + if (status) { + goto exit_remove; + } + + *data = msa; + dev_info(&client->dev, "sfp msa '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); +exit_free: + kfree(msa); +exit: + + return status; +} + +static const struct attribute_group sfp_ddm_group = { + .attrs = sfp_ddm_attributes, +}; + +static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct sfp_ddm_data **data) +{ + int status; + struct sfp_ddm_data *ddm; + + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } + + ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); + if (!ddm) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); + if (status) { + goto exit_remove; + } + + *data = ddm; + dev_info(&client->dev, "sfp ddm '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); +exit_free: + kfree(ddm); +exit: + + return status; +} + +static const struct attribute_group qsfp_group = { + .attrs = qsfp_attributes, +}; + +static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct qsfp_data **data) +{ + int status; + struct qsfp_data *qsfp; + + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } + + qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); + if (!qsfp) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &qsfp_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); + if (status) { + goto exit_remove; + } + + /* Bring QSFPs out of reset + as6712_32x_i2c_cpld_write(0x62, 0x4, 0xFF); + as6712_32x_i2c_cpld_write(0x62, 0x5, 0xFF); + as6712_32x_i2c_cpld_write(0x64, 0x4, 0xFF); + as6712_32x_i2c_cpld_write(0x64, 0x5, 0xFF);*/ + + *data = qsfp; + dev_info(&client->dev, "qsfp '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &qsfp_group); +exit_free: + kfree(qsfp); +exit: + + return status; +} + +static int sfp_device_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct sfp_port_data *data = NULL; + + data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); + if (!data) { + return -ENOMEM; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->port = dev_id->driver_data; + data->client = client; + + if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { + return -ENODEV; + } + + data->driver_type = DRIVER_TYPE_QSFP; + return qsfp_probe(client, dev_id, &data->qsfp); +} + +static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); + kfree(data); + return 0; +} + +static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); + kfree(data); + return 0; +} + +static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &qsfp_group); + kfree(data); + return 0; +} + +static int sfp_device_remove(struct i2c_client *client) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + + switch (data->driver_type) { + case DRIVER_TYPE_SFP_MSA: + return sfp_msa_remove(client, data->msa); + case DRIVER_TYPE_SFP_DDM: + return sfp_ddm_remove(client, data->ddm); + case DRIVER_TYPE_QSFP: + return qfp_remove(client, data->qsfp); + } + + return 0; +} + +static struct i2c_driver sfp_driver = { + .driver = { + .name = DRIVER_NAME, + }, + .probe = sfp_device_probe, + .remove = sfp_device_remove, + .id_table = sfp_device_id, + .address_list = normal_i2c, +}; + +static int __init sfp_init(void) +{ + extern int platform_accton_as7712_32x(void); + if (!platform_accton_as7712_32x()) { + return -ENODEV; + } + + return i2c_add_driver(&sfp_driver); +} + +static void __exit sfp_exit(void) +{ + i2c_del_driver(&sfp_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton as7712_32x_sfp driver"); +MODULE_LICENSE("GPL"); + +module_init(sfp_init); +module_exit(sfp_exit); + diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_i2c_cpld.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_i2c_cpld.c new file mode 100644 index 000000000000..b25bf1c2aff4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_i2c_cpld.c @@ -0,0 +1,259 @@ +/* + * A hwmon driver for the accton_i2c_cpld + * + * 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 + +#define CPLD_VERSION_REG 0x1 + +enum as5712_54x_cpld_sysfs_attributes { + CPLD_READ_VERSION, + CPLD_BYTE_ACCESS, + CPLD_DUMP_ALL, +}; + +static ssize_t read_cpld_version(struct device *dev, struct device_attribute *da, + char *buf); +int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); + + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +/* Addresses scanned for accton_i2c_cpld + */ +static const unsigned short normal_i2c[] = { 0x31, 0x35, 0x60, 0x61, 0x62, I2C_CLIENT_END }; + +static SENSOR_DEVICE_ATTR(cpld_get_version, S_IRUGO, read_cpld_version, NULL, CPLD_READ_VERSION); + +static struct attribute *as5712_54x_cpld_attributes[] = { + &sensor_dev_attr_cpld_get_version.dev_attr.attr, + NULL +}; + +static const struct attribute_group as5712_54x_cpld_group = { + .attrs = as5712_54x_cpld_attributes, +}; + +static ssize_t read_cpld_version(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + unsigned short cpld_reg = CPLD_VERSION_REG; + u8 reg; + + if(attr->index == CPLD_READ_VERSION) { + reg = accton_i2c_cpld_read(client->addr, cpld_reg); + return sprintf(buf, "%02x\n",reg); + } + return -1 ; +} + + +static void accton_i2c_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 accton_i2c_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static int accton_i2c_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + dev_dbg(&client->dev, "i2c_check_functionality failed (0x%x)\n", client->addr); + status = -EIO; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as5712_54x_cpld_group); + if (status) { + goto exit; + } + + dev_info(&client->dev, "chip found\n"); + accton_i2c_cpld_add_client(client); + + return 0; +exit: + return status; +} + +static int accton_i2c_cpld_remove(struct i2c_client *client) +{ + sysfs_remove_group(&client->dev.kobj, &as5712_54x_cpld_group); + + accton_i2c_cpld_remove_client(client); + return 0; +} + +static const struct i2c_device_id accton_i2c_cpld_id[] = { + { "accton_i2c_cpld", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, accton_i2c_cpld_id); + +static struct i2c_driver accton_i2c_cpld_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "accton_i2c_cpld", + }, + .probe = accton_i2c_cpld_probe, + .remove = accton_i2c_cpld_remove, + .id_table = accton_i2c_cpld_id, + .address_list = normal_i2c, +}; + +int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_read_byte_data(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(accton_i2c_cpld_read); + +int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(accton_i2c_cpld_write); + +static int __init accton_i2c_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&accton_i2c_cpld_driver); +} + +static void __exit accton_i2c_cpld_exit(void) +{ + i2c_del_driver(&accton_i2c_cpld_driver); +} + +static struct dmi_system_id as7712_dmi_table[] = { + { + .ident = "Accton AS7712", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Accton"), + DMI_MATCH(DMI_PRODUCT_NAME, "AS7712"), + }, + } +}; + +int platform_accton_as7712_32x(void) +{ + return dmi_check_system(as7712_dmi_table); +} +EXPORT_SYMBOL(platform_accton_as7712_32x); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton_i2c_cpld driver"); +MODULE_LICENSE("GPL"); + +module_init(accton_i2c_cpld_init); +module_exit(accton_i2c_cpld_exit); diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/leds-accton_as7712_32x.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/leds-accton_as7712_32x.c new file mode 100644 index 000000000000..8b14437bca35 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/leds-accton_as7712_32x.c @@ -0,0 +1,443 @@ +/* + * A LED driver for the accton_as7712_32x_led + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*#define DEBUG*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); +extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +extern void led_classdev_unregister(struct led_classdev *led_cdev); +extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); +extern void led_classdev_resume(struct led_classdev *led_cdev); +extern void led_classdev_suspend(struct led_classdev *led_cdev); + +#define DRVNAME "accton_as7712_32x_led" + +struct accton_as7712_32x_led_data { + struct platform_device *pdev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[1]; /* only 1 register*/ +}; + +static struct accton_as7712_32x_led_data *ledctl = NULL; + +/* LED related data + */ + +#define LED_CNTRLER_I2C_ADDRESS (0x60) + +#define LED_TYPE_DIAG_REG_MASK (0x3) +#define LED_MODE_DIAG_GREEN_VALUE (0x02) +#define LED_MODE_DIAG_RED_VALUE (0x01) +#define LED_MODE_DIAG_AMBER_VALUE (0x00) /*It's yellow actually. Green+Red=Yellow*/ +#define LED_MODE_DIAG_OFF_VALUE (0x03) + + +#define LED_TYPE_LOC_REG_MASK (0x80) +#define LED_MODE_LOC_ON_VALUE (0) +#define LED_MODE_LOC_OFF_VALUE (0x80) + +enum led_type { + LED_TYPE_DIAG, + LED_TYPE_LOC, + LED_TYPE_FAN, + LED_TYPE_PSU1, + LED_TYPE_PSU2 +}; + +struct led_reg { + u32 types; + u8 reg_addr; +}; + +static const struct led_reg led_reg_map[] = { + {(1<update_lock); + + if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2) + || !ledctl->valid) { + int i; + + dev_dbg(&ledctl->pdev->dev, "Starting accton_as7712_32x_led update\n"); + + /* Update LED data + */ + for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { + int status = accton_as7712_32x_led_read_value(led_reg_map[i].reg_addr); + + if (status < 0) { + ledctl->valid = 0; + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg_map[i].reg_addr, status); + goto exit; + } + else + { + ledctl->reg_val[i] = status; + } + } + + ledctl->last_updated = jiffies; + ledctl->valid = 1; + } + +exit: + mutex_unlock(&ledctl->update_lock); +} + +static void accton_as7712_32x_led_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode, + enum led_type type) +{ + int reg_val; + u8 reg ; + mutex_lock(&ledctl->update_lock); + + if( !accton_getLedReg(type, ®)) + { + dev_dbg(&ledctl->pdev->dev, "Not match item for %d.\n", type); + } + + reg_val = accton_as7712_32x_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); + accton_as7712_32x_led_write_value(reg, reg_val); + + /* to prevent the slow-update issue */ + ledctl->valid = 0; + +exit: + mutex_unlock(&ledctl->update_lock); +} + + +static void accton_as7712_32x_led_diag_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as7712_32x_led_set(led_cdev, led_light_mode, LED_TYPE_DIAG); +} + +static enum led_brightness accton_as7712_32x_led_diag_get(struct led_classdev *cdev) +{ + accton_as7712_32x_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_DIAG, ledctl->reg_val[0]); +} + +static void accton_as7712_32x_led_loc_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as7712_32x_led_set(led_cdev, led_light_mode, LED_TYPE_LOC); +} + +static enum led_brightness accton_as7712_32x_led_loc_get(struct led_classdev *cdev) +{ + accton_as7712_32x_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[0]); +} + +static void accton_as7712_32x_led_auto_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ +} + +static enum led_brightness accton_as7712_32x_led_auto_get(struct led_classdev *cdev) +{ + return LED_MODE_AUTO; +} + +static struct led_classdev accton_as7712_32x_leds[] = { + [LED_TYPE_DIAG] = { + .name = "accton_as7712_32x_led::diag", + .default_trigger = "unused", + .brightness_set = accton_as7712_32x_led_diag_set, + .brightness_get = accton_as7712_32x_led_diag_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_RED, + }, + [LED_TYPE_LOC] = { + .name = "accton_as7712_32x_led::loc", + .default_trigger = "unused", + .brightness_set = accton_as7712_32x_led_loc_set, + .brightness_get = accton_as7712_32x_led_loc_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_BLUE, + }, + [LED_TYPE_FAN] = { + .name = "accton_as7712_32x_led::fan", + .default_trigger = "unused", + .brightness_set = accton_as7712_32x_led_auto_set, + .brightness_get = accton_as7712_32x_led_auto_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_PSU1] = { + .name = "accton_as7712_32x_led::psu1", + .default_trigger = "unused", + .brightness_set = accton_as7712_32x_led_auto_set, + .brightness_get = accton_as7712_32x_led_auto_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_PSU2] = { + .name = "accton_as7712_32x_led::psu2", + .default_trigger = "unused", + .brightness_set = accton_as7712_32x_led_auto_set, + .brightness_get = accton_as7712_32x_led_auto_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, +}; + +static int accton_as7712_32x_led_suspend(struct platform_device *dev, + pm_message_t state) +{ + int i = 0; + + for (i = 0; i < ARRAY_SIZE(accton_as7712_32x_leds); i++) { + led_classdev_suspend(&accton_as7712_32x_leds[i]); + } + + return 0; +} + +static int accton_as7712_32x_led_resume(struct platform_device *dev) +{ + int i = 0; + + for (i = 0; i < ARRAY_SIZE(accton_as7712_32x_leds); i++) { + led_classdev_resume(&accton_as7712_32x_leds[i]); + } + + return 0; +} + +static int accton_as7712_32x_led_probe(struct platform_device *pdev) +{ + int ret, i; + + for (i = 0; i < ARRAY_SIZE(accton_as7712_32x_leds); i++) { + ret = led_classdev_register(&pdev->dev, &accton_as7712_32x_leds[i]); + + if (ret < 0) + break; + } + + /* Check if all LEDs were successfully registered */ + if (i != ARRAY_SIZE(accton_as7712_32x_leds)){ + int j; + + /* only unregister the LEDs that were successfully registered */ + for (j = 0; j < i; j++) { + led_classdev_unregister(&accton_as7712_32x_leds[i]); + } + } + + return ret; +} + +static int accton_as7712_32x_led_remove(struct platform_device *pdev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(accton_as7712_32x_leds); i++) { + led_classdev_unregister(&accton_as7712_32x_leds[i]); + } + + return 0; +} + +static struct platform_driver accton_as7712_32x_led_driver = { + .probe = accton_as7712_32x_led_probe, + .remove = accton_as7712_32x_led_remove, + .suspend = accton_as7712_32x_led_suspend, + .resume = accton_as7712_32x_led_resume, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +static int __init accton_as7712_32x_led_init(void) +{ + int ret; + + extern int platform_accton_as7712_32x(void); + if (!platform_accton_as7712_32x()) { + return -ENODEV; + } + + ret = platform_driver_register(&accton_as7712_32x_led_driver); + if (ret < 0) { + goto exit; + } + + ledctl = kzalloc(sizeof(struct accton_as7712_32x_led_data), GFP_KERNEL); + if (!ledctl) { + ret = -ENOMEM; + platform_driver_unregister(&accton_as7712_32x_led_driver); + goto exit; + } + + mutex_init(&ledctl->update_lock); + + ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(ledctl->pdev)) { + ret = PTR_ERR(ledctl->pdev); + platform_driver_unregister(&accton_as7712_32x_led_driver); + kfree(ledctl); + goto exit; + } + +exit: + return ret; +} + +static void __exit accton_as7712_32x_led_exit(void) +{ + platform_device_unregister(ledctl->pdev); + platform_driver_unregister(&accton_as7712_32x_led_driver); + kfree(ledctl); +} + +module_init(accton_as7712_32x_led_init); +module_exit(accton_as7712_32x_led_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton_as7712_32x_led driver"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/ym2651y.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/ym2651y.c new file mode 100644 index 000000000000..2745b095b7e2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/ym2651y.c @@ -0,0 +1,589 @@ +/* + * An hwmon driver for the 3Y Power YM-2651Y 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 + +#define MAX_FAN_DUTY_CYCLE 100 + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { 0x58, 0x5b, I2C_CLIENT_END }; + +/* Each client has this additional data + */ +struct ym2651y_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 capability; /* Register value */ + u16 status_word; /* Register value */ + u8 fan_fault; /* Register value */ + u8 over_temp; /* Register value */ + u16 v_out; /* Register value */ + u16 i_out; /* Register value */ + u16 p_out; /* Register value */ + u16 temp; /* Register value */ + u16 fan_speed; /* Register value */ + u16 fan_duty_cycle[2]; /* Register value */ + u8 fan_dir[4]; /* Register value */ + u8 pmbus_revision; /* Register value */ + u8 mfr_id[10]; /* Register value */ + u8 mfr_model[10]; /* Register value */ + u8 mfr_revsion[3]; /* Register value */ + u16 mfr_vin_min; /* Register value */ + u16 mfr_vin_max; /* Register value */ + u16 mfr_iin_max; /* Register value */ + u16 mfr_iout_max; /* Register value */ + u16 mfr_pin_max; /* Register value */ + u16 mfr_pout_max; /* Register value */ + u16 mfr_vout_min; /* Register value */ + u16 mfr_vout_max; /* Register value */ +}; + +static ssize_t show_byte(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_word(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_linear(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_fan_fault(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_over_temp(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_ascii(struct device *dev, struct device_attribute *da, + char *buf); +static struct ym2651y_data *ym2651y_update_device(struct device *dev); +static ssize_t set_fan_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static int ym2651y_write_word(struct i2c_client *client, u8 reg, u16 value); + +enum ym2651y_sysfs_attributes { + PSU_POWER_ON = 0, + PSU_TEMP_FAULT, + PSU_POWER_GOOD, + PSU_FAN1_FAULT, + PSU_FAN_DIRECTION, + PSU_OVER_TEMP, + PSU_V_OUT, + PSU_I_OUT, + PSU_P_OUT, + PSU_TEMP1_INPUT, + PSU_FAN1_SPEED, + PSU_FAN1_DUTY_CYCLE, + PSU_PMBUS_REVISION, + PSU_MFR_ID, + PSU_MFR_MODEL, + PSU_MFR_REVISION, + PSU_MFR_VIN_MIN, + PSU_MFR_VIN_MAX, + PSU_MFR_VOUT_MIN, + PSU_MFR_VOUT_MAX, + PSU_MFR_IIN_MAX, + PSU_MFR_IOUT_MAX, + PSU_MFR_PIN_MAX, + PSU_MFR_POUT_MAX +}; + +/* sysfs attributes for hwmon + */ +static SENSOR_DEVICE_ATTR(psu_power_on, S_IRUGO, show_word, NULL, PSU_POWER_ON); +static SENSOR_DEVICE_ATTR(psu_temp_fault, S_IRUGO, show_word, NULL, PSU_TEMP_FAULT); +static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_word, NULL, PSU_POWER_GOOD); +static SENSOR_DEVICE_ATTR(psu_fan1_fault, S_IRUGO, show_fan_fault, NULL, PSU_FAN1_FAULT); +static SENSOR_DEVICE_ATTR(psu_over_temp, S_IRUGO, show_over_temp, NULL, PSU_OVER_TEMP); +static SENSOR_DEVICE_ATTR(psu_v_out, S_IRUGO, show_linear, NULL, PSU_V_OUT); +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_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); +static SENSOR_DEVICE_ATTR(psu_pmbus_revision, S_IRUGO, show_byte, NULL, PSU_PMBUS_REVISION); +static SENSOR_DEVICE_ATTR(psu_mfr_id, S_IRUGO, show_ascii, NULL, PSU_MFR_ID); +static SENSOR_DEVICE_ATTR(psu_mfr_model, S_IRUGO, show_ascii, NULL, PSU_MFR_MODEL); +static SENSOR_DEVICE_ATTR(psu_mfr_revision, S_IRUGO, show_ascii, NULL, PSU_MFR_REVISION); +static SENSOR_DEVICE_ATTR(psu_mfr_vin_min, S_IRUGO, show_linear, NULL, PSU_MFR_VIN_MIN); +static SENSOR_DEVICE_ATTR(psu_mfr_vin_max, S_IRUGO, show_linear, NULL, PSU_MFR_VIN_MAX); +static SENSOR_DEVICE_ATTR(psu_mfr_vout_min, S_IRUGO, show_linear, NULL, PSU_MFR_VOUT_MIN); +static SENSOR_DEVICE_ATTR(psu_mfr_vout_max, S_IRUGO, show_linear, NULL, PSU_MFR_VOUT_MAX); +static SENSOR_DEVICE_ATTR(psu_mfr_iin_max, S_IRUGO, show_linear, NULL, PSU_MFR_IIN_MAX); +static SENSOR_DEVICE_ATTR(psu_mfr_iout_max, S_IRUGO, show_linear, NULL, PSU_MFR_IOUT_MAX); +static SENSOR_DEVICE_ATTR(psu_mfr_pin_max, S_IRUGO, show_linear, NULL, PSU_MFR_PIN_MAX); +static SENSOR_DEVICE_ATTR(psu_mfr_pout_max, S_IRUGO, show_linear, NULL, PSU_MFR_POUT_MAX); + +static struct attribute *ym2651y_attributes[] = { + &sensor_dev_attr_psu_power_on.dev_attr.attr, + &sensor_dev_attr_psu_temp_fault.dev_attr.attr, + &sensor_dev_attr_psu_power_good.dev_attr.attr, + &sensor_dev_attr_psu_fan1_fault.dev_attr.attr, + &sensor_dev_attr_psu_over_temp.dev_attr.attr, + &sensor_dev_attr_psu_v_out.dev_attr.attr, + &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_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, + &sensor_dev_attr_psu_pmbus_revision.dev_attr.attr, + &sensor_dev_attr_psu_mfr_id.dev_attr.attr, + &sensor_dev_attr_psu_mfr_model.dev_attr.attr, + &sensor_dev_attr_psu_mfr_revision.dev_attr.attr, + &sensor_dev_attr_psu_mfr_vin_min.dev_attr.attr, + &sensor_dev_attr_psu_mfr_vin_max.dev_attr.attr, + &sensor_dev_attr_psu_mfr_pout_max.dev_attr.attr, + &sensor_dev_attr_psu_mfr_iin_max.dev_attr.attr, + &sensor_dev_attr_psu_mfr_pin_max.dev_attr.attr, + &sensor_dev_attr_psu_mfr_vout_min.dev_attr.attr, + &sensor_dev_attr_psu_mfr_vout_max.dev_attr.attr, + &sensor_dev_attr_psu_mfr_iout_max.dev_attr.attr, + NULL +}; + +static ssize_t show_byte(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct ym2651y_data *data = ym2651y_update_device(dev); + + return (attr->index == PSU_PMBUS_REVISION) ? sprintf(buf, "%d\n", data->pmbus_revision) : + sprintf(buf, "0\n"); +} + +static ssize_t show_word(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct ym2651y_data *data = ym2651y_update_device(dev); + u16 status = 0; + + switch (attr->index) { + case PSU_POWER_ON: /* psu_power_on, low byte bit 6 of status_word, 0=>ON, 1=>OFF */ + status = (data->status_word & 0x40) ? 0 : 1; + break; + case PSU_TEMP_FAULT: /* psu_temp_fault, low byte bit 2 of status_word, 0=>Normal, 1=>temp fault */ + status = (data->status_word & 0x4) >> 2; + break; + case PSU_POWER_GOOD: /* psu_power_good, high byte bit 3 of status_word, 0=>OK, 1=>FAIL */ + status = (data->status_word & 0x800) ? 0 : 1; + break; + } + + return sprintf(buf, "%d\n", status); +} + +static int two_complement_to_int(u16 data, u8 valid_bit, int mask) +{ + u16 valid_data = data & mask; + bool is_negative = valid_data >> (valid_bit - 1); + + return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data; +} + +static ssize_t set_fan_duty_cycle(struct device *dev, struct device_attribute *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 ym2651y_data *data = i2c_get_clientdata(client); + int nr = (attr->index == PSU_FAN1_DUTY_CYCLE) ? 0 : 1; + long speed; + int error; + + error = kstrtol(buf, 10, &speed); + if (error) + return error; + + if (speed < 0 || speed > MAX_FAN_DUTY_CYCLE) + return -EINVAL; + + mutex_lock(&data->update_lock); + data->fan_duty_cycle[nr] = speed; + ym2651y_write_word(client, 0x3B + nr, data->fan_duty_cycle[nr]); + mutex_unlock(&data->update_lock); + + return count; +} + +static ssize_t show_linear(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct ym2651y_data *data = ym2651y_update_device(dev); + + u16 value = 0; + int exponent, mantissa; + int multiplier = 1000; + + switch (attr->index) { + case PSU_V_OUT: + value = data->v_out; + break; + case PSU_I_OUT: + value = data->i_out; + break; + case PSU_P_OUT: + value = data->p_out; + break; + case PSU_TEMP1_INPUT: + value = data->temp; + break; + case PSU_FAN1_SPEED: + value = data->fan_speed; + multiplier = 1; + break; + case PSU_FAN1_DUTY_CYCLE: + value = data->fan_duty_cycle[0]; + multiplier = 1; + break; + case PSU_MFR_VIN_MIN: + value = data->mfr_vin_min; + break; + case PSU_MFR_VIN_MAX: + value = data->mfr_vin_max; + break; + case PSU_MFR_VOUT_MIN: + value = data->mfr_vout_min; + break; + case PSU_MFR_VOUT_MAX: + value = data->mfr_vout_max; + break; + case PSU_MFR_PIN_MAX: + value = data->mfr_pin_max; + break; + case PSU_MFR_POUT_MAX: + value = data->mfr_pout_max; + break; + case PSU_MFR_IOUT_MAX: + value = data->mfr_iout_max; + break; + case PSU_MFR_IIN_MAX: + value = data->mfr_iin_max; + break; + } + + exponent = two_complement_to_int(value >> 11, 5, 0x1f); + mantissa = two_complement_to_int(value & 0x7ff, 11, 0x7ff); + + return (exponent >= 0) ? sprintf(buf, "%d\n", (mantissa << exponent) * multiplier) : + sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent)); +} + +static ssize_t show_fan_fault(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct ym2651y_data *data = ym2651y_update_device(dev); + + u8 shift = (attr->index == PSU_FAN1_FAULT) ? 7 : 6; + + return sprintf(buf, "%d\n", data->fan_fault >> shift); +} + +static ssize_t show_over_temp(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct ym2651y_data *data = ym2651y_update_device(dev); + + return sprintf(buf, "%d\n", data->over_temp >> 7); +} + +static ssize_t show_ascii(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct ym2651y_data *data = ym2651y_update_device(dev); + u8 *ptr = NULL; + + switch (attr->index) { + case PSU_FAN_DIRECTION: /* psu_fan_dir */ + ptr = data->fan_dir; + break; + case PSU_MFR_ID: /* psu_mfr_id */ + ptr = data->mfr_id; + break; + case PSU_MFR_MODEL: /* psu_mfr_model */ + ptr = data->mfr_model; + break; + case PSU_MFR_REVISION: /* psu_mfr_revision */ + ptr = data->mfr_revsion; + break; + default: + return 0; + } + + return sprintf(buf, "%s\n", ptr); +} + +static const struct attribute_group ym2651y_group = { + .attrs = ym2651y_attributes, +}; + +static int ym2651y_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct ym2651y_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_BYTE_DATA | + I2C_FUNC_SMBUS_WORD_DATA | + I2C_FUNC_SMBUS_I2C_BLOCK)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct ym2651y_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &ym2651y_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: psu '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &ym2651y_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int ym2651y_remove(struct i2c_client *client) +{ + struct ym2651y_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &ym2651y_group); + kfree(data); + + return 0; +} + +static const struct i2c_device_id ym2651y_id[] = { + { "ym2651", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, ym2651y_id); + +static struct i2c_driver ym2651y_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "ym2651", + }, + .probe = ym2651y_probe, + .remove = ym2651y_remove, + .id_table = ym2651y_id, + .address_list = normal_i2c, +}; + +static int ym2651y_read_byte(struct i2c_client *client, u8 reg) +{ + return i2c_smbus_read_byte_data(client, reg); +} + +static int ym2651y_read_word(struct i2c_client *client, u8 reg) +{ + return i2c_smbus_read_word_data(client, reg); +} + +static int ym2651y_write_word(struct i2c_client *client, u8 reg, u16 value) +{ + return i2c_smbus_write_word_data(client, reg, value); +} + +static int ym2651y_read_block(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ + int result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + + if (unlikely(result < 0)) + goto abort; + if (unlikely(result != data_len)) { + result = -EIO; + goto abort; + } + + result = 0; + +abort: + return result; +} + +struct reg_data_byte { + u8 reg; + u8 *value; +}; + +struct reg_data_word { + u8 reg; + u16 *value; +}; + +static struct ym2651y_data *ym2651y_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct ym2651y_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + int i, status; + u8 command; + u8 fan_dir[5] = {0}; + struct reg_data_byte regs_byte[] = { {0x19, &data->capability}, + {0x7d, &data->over_temp}, + {0x81, &data->fan_fault}, + {0x98, &data->pmbus_revision}}; + struct reg_data_word regs_word[] = { {0x79, &data->status_word}, + {0x8b, &data->v_out}, + {0x8c, &data->i_out}, + {0x96, &data->p_out}, + {0x8d, &data->temp}, + {0x3b, &(data->fan_duty_cycle[0])}, + {0x3c, &(data->fan_duty_cycle[1])}, + {0x90, &data->fan_speed}, + {0xa0, &data->mfr_vin_min}, + {0xa1, &data->mfr_vin_max}, + {0xa2, &data->mfr_iin_max}, + {0xa3, &data->mfr_pin_max}, + {0xa4, &data->mfr_vout_min}, + {0xa5, &data->mfr_vout_max}, + {0xa6, &data->mfr_iout_max}, + {0xa7, &data->mfr_pout_max}}; + + dev_dbg(&client->dev, "Starting ym2651 update\n"); + + /* Read byte data */ + for (i = 0; i < ARRAY_SIZE(regs_byte); i++) { + status = ym2651y_read_byte(client, regs_byte[i].reg); + + if (status < 0) + { + dev_dbg(&client->dev, "reg %d, err %d\n", + regs_byte[i].reg, status); + } + else { + *(regs_byte[i].value) = status; + } + } + + /* Read word data */ + for (i = 0; i < ARRAY_SIZE(regs_word); i++) { + status = ym2651y_read_word(client, regs_word[i].reg); + + if (status < 0) + { + dev_dbg(&client->dev, "reg %d, err %d\n", + regs_word[i].reg, status); + } + else { + *(regs_word[i].value) = status; + } + } + + /* Read fan_direction */ + command = 0xC3; + status = ym2651y_read_block(client, command, fan_dir, ARRAY_SIZE(fan_dir)-1); + + if (status < 0) { + dev_dbg(&client->dev, "reg %d, err %d\n", command, status); + } + + strncpy(data->fan_dir, fan_dir+1, ARRAY_SIZE(data->fan_dir)-1); + data->fan_dir[ARRAY_SIZE(data->fan_dir)-1] = '\0'; + + /* Read mfr_id */ + command = 0x99; + status = ym2651y_read_block(client, command, data->mfr_id, + ARRAY_SIZE(data->mfr_id)-1); + data->mfr_id[ARRAY_SIZE(data->mfr_id)-1] = '\0'; + + if (status < 0) + dev_dbg(&client->dev, "reg %d, err %d\n", command, status); + + /* Read mfr_model */ + command = 0x9a; + status = ym2651y_read_block(client, command, data->mfr_model, + ARRAY_SIZE(data->mfr_model)-1); + data->mfr_model[ARRAY_SIZE(data->mfr_model)-1] = '\0'; + + if (status < 0) + dev_dbg(&client->dev, "reg %d, err %d\n", command, status); + + /* Read mfr_revsion */ + command = 0x9b; + status = ym2651y_read_block(client, command, data->mfr_revsion, + ARRAY_SIZE(data->mfr_revsion)-1); + data->mfr_revsion[ARRAY_SIZE(data->mfr_revsion)-1] = '\0'; + + if (status < 0) + dev_dbg(&client->dev, "reg %d, err %d\n", command, status); + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +module_i2c_driver(ym2651y_driver); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("3Y Power YM-2651Y driver"); +MODULE_LICENSE("GPL"); + + diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/scripts/as7712_32x_platform_init.sh b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/scripts/as7712_32x_platform_init.sh new file mode 100644 index 000000000000..448f2ec341a4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/scripts/as7712_32x_platform_init.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "TO-DO: as7712-32x driver setting" diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/changelog b/platform/broadcom/sonic-platform-modules-accton/debian/changelog new file mode 100644 index 000000000000..6a687800eeac --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/debian/changelog @@ -0,0 +1,5 @@ +sonic-accton-platform-modules (1.0) unstable; urgency=low + + * Initial release + + -- Polly Hsu Tue, 9 May 2017 17:54:11 -0800 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/compat b/platform/broadcom/sonic-platform-modules-accton/debian/compat new file mode 100644 index 000000000000..ec635144f600 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/debian/compat @@ -0,0 +1 @@ +9 diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/control b/platform/broadcom/sonic-platform-modules-accton/debian/control new file mode 100644 index 000000000000..755c58612bb0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/debian/control @@ -0,0 +1,11 @@ +Source: sonic-accton-platform-modules +Section: main +Priority: extra +Maintainer: polly_hsu +Build-Depends: debhelper (>= 8.0.0), bzip2 +Standards-Version: 3.9.3 + +Package: platform-modules-as7712-32x +Architecture: amd64 +Depends: linux-image-3.16.0-4-amd64 +Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.init b/platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.init new file mode 100644 index 000000000000..c54b2a3e310d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.init @@ -0,0 +1,44 @@ +#!/bin/bash + +### BEGIN INIT INFO +# Provides: setup-board +# Required-Start: +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: S +# Default-Stop: 0 6 +# Short-Description: Setup AS7712-32X board. +### END INIT INFO + +case "$1" in +start) + echo -n "Setting up board... " + + modprobe i2c_dev + modprobe i2c_mux_pca954x + modprobe accton_i2c_cpld + modprobe accton_as7712_32x_fan + modprobe accton_as7712_32x_sfp + modprobe leds-accton_as7712_32x + modprobe accton_as7712_32x_psu + + echo "done." + ;; + +stop) + echo "done." + + ;; + +force-reload|restart) + echo "Not supported" + ;; + +*) + echo "Usage: /etc/init.d/platform-modules-as7712-32x.init {start|stop}" + exit 1 + ;; +esac + +exit 0 diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.install b/platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.install new file mode 100644 index 000000000000..39abf57e2f65 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.install @@ -0,0 +1,2 @@ +as7712-32x/scripts/as7712_32x_platform_init.sh usr/local/bin +as7712-32x/cfg/as7712_32x-modules.conf etc/modules-load.d diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/rules b/platform/broadcom/sonic-platform-modules-accton/debian/rules new file mode 100644 index 000000000000..a1026ca62832 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/debian/rules @@ -0,0 +1,36 @@ +#!/usr/bin/make -f + +export INSTALL_MOD_DIR:=extra + +KVERSION ?= $(shell uname -r) +KERNEL_SRC := /lib/modules/$(KVERSION) +MOD_SRC_DIR:= $(shell pwd) +MODULE_DIRS:= as7712-32x + +%: + dh $@ + +override_dh_auto_build: + (for mod in $(MODULE_DIRS); do \ + make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ + done) + + + +override_dh_auto_install: + (for mod in $(MODULE_DIRS); do \ + dh_installdirs -pplatform-modules-$${mod} \ + $(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ + cp $(MOD_SRC_DIR)/$${mod}/modules/*.ko \ + debian/platform-modules-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ + mkdir -p debian/platform-modules-$${mod}/etc/bcm; \ + done) + +override_dh_usrlocal: + +override_dh_clean: + dh_clean + (for mod in $(MODULE_DIRS); do \ + make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \ + done) + From 7472cd303e622fe3dba3202d97f9909eb8436081 Mon Sep 17 00:00:00 2001 From: lguohan Date: Fri, 16 Jun 2017 00:05:41 -0700 Subject: [PATCH 03/45] [image]: load platform specific settings in sonic-to-sonic upgrade (#710) --- .../dell/x86_64-dell_s6000_s1220-r0/installer.conf | 4 ++++ installer/x86_64/install.sh | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/device/dell/x86_64-dell_s6000_s1220-r0/installer.conf b/device/dell/x86_64-dell_s6000_s1220-r0/installer.conf index eb135bee0ff1..a8fef6185912 100644 --- a/device/dell/x86_64-dell_s6000_s1220-r0/installer.conf +++ b/device/dell/x86_64-dell_s6000_s1220-r0/installer.conf @@ -1,5 +1,7 @@ ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="processor.max_cstate=1 intel_idle.max_cstate=0" +if [ "$install_env" = "onie" ]; then + echo "Replace ONIE reboot with Dell reset commands" # set I2C GPIO mux @@ -21,3 +23,5 @@ i2cset -y 0 0x31 1 0xfd EOF chmod a+x /sbin/reboot + +fi diff --git a/installer/x86_64/install.sh b/installer/x86_64/install.sh index 18669893bcb5..f7d1dbb29a6f 100755 --- a/installer/x86_64/install.sh +++ b/installer/x86_64/install.sh @@ -36,7 +36,14 @@ if [ $(id -u) -ne 0 ] fi # get running machine from conf file -[ -r /etc/machine.conf ] && . /etc/machine.conf +if [ -r /etc/machine.conf ]; then + . /etc/machine.conf +elif [ -r /host/machine.conf ]; then + . /host/machine.conf +else + echo "cannot find machine.conf" + exit 1 +fi echo "onie_platform: $onie_platform" @@ -57,9 +64,10 @@ if [ -d "/etc/sonic" ]; then else echo "Installing SONiC in ONIE" install_env="onie" - [ -r platforms/$onie_platform ] && source platforms/$onie_platform fi +[ -r platforms/$onie_platform ] && . platforms/$onie_platform + # Install demo on same block device as ONIE onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//') blk_dev=$(echo $onie_dev | sed -e 's/[1-9][0-9]*$//' | sed -e 's/\([0-9]\)\(p\)/\1/') From 7267da3ff866dd1d13e90b2631a2b32034c9dba7 Mon Sep 17 00:00:00 2001 From: Andriy Moroz Date: Fri, 16 Jun 2017 10:35:36 +0300 Subject: [PATCH 04/45] [submodule]: Update sairedis submodule (#712) Include fix for saithrift port split parsing --- src/sonic-sairedis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-sairedis b/src/sonic-sairedis index f02e667d03f7..1eeb716837bb 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit f02e667d03f7840132c9dd210254cff2b2e0ad1d +Subproject commit 1eeb716837bb4e6cd4d179e3654ee67e74cf5736 From 6867458058cf94fe6a8aa2685160db535061449e Mon Sep 17 00:00:00 2001 From: sihuihan88 Date: Fri, 16 Jun 2017 07:25:40 -0700 Subject: [PATCH 05/45] [docker-ptf]: Install exabgp in docker ptf (#709) --- dockers/docker-ptf/Dockerfile.j2 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dockers/docker-ptf/Dockerfile.j2 b/dockers/docker-ptf/Dockerfile.j2 index c546ad2fab9c..59360ee4fa2e 100644 --- a/dockers/docker-ptf/Dockerfile.j2 +++ b/dockers/docker-ptf/Dockerfile.j2 @@ -45,7 +45,8 @@ RUN sed --in-place 's/httpredir.debian.org/debian-archive.trafficmanager.net/' / ipython \ git \ iputils-ping \ - hping3 + hping3 \ + curl ## Reinstall scapy by version from p4lang RUN git clone https://github.com/p4lang/scapy-vxlan.git && cd scapy-vxlan && python setup.py install @@ -78,6 +79,8 @@ RUN rm -rf /debs \ && pip install pysubnettree \ && pip install paramiko \ && pip install parallel-ssh \ + && pip install flask \ + && pip install exabgp==3.4.17\ && mkdir -p /opt \ && cd /opt \ && wget https://raw.githubusercontent.com/p4lang/ptf/master/ptf_nn/ptf_nn_agent.py From 897cc2bbb55a6d90ff5ef5aa4ca2d97e8ab10019 Mon Sep 17 00:00:00 2001 From: lguohan Date: Sun, 18 Jun 2017 14:38:31 -0700 Subject: [PATCH 06/45] [platform]: fix file mode for acction platform to create clean build (#714) --- platform/broadcom/sonic-platform-modules-accton/debian/rules | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 platform/broadcom/sonic-platform-modules-accton/debian/rules diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/rules b/platform/broadcom/sonic-platform-modules-accton/debian/rules old mode 100644 new mode 100755 From 2f231f36538886b43d0963fc6e793ef920a8a2b4 Mon Sep 17 00:00:00 2001 From: lguohan Date: Sun, 18 Jun 2017 15:52:49 -0700 Subject: [PATCH 07/45] [image]: expand dockerfs.tar.gz directly on to disk without intermediate file (#715) --- installer/x86_64/install.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/installer/x86_64/install.sh b/installer/x86_64/install.sh index f7d1dbb29a6f..ca8c4d3e47e7 100755 --- a/installer/x86_64/install.sh +++ b/installer/x86_64/install.sh @@ -422,12 +422,11 @@ else fi # Decompress the file for the file system directly to the partition -unzip $ONIE_INSTALLER_PAYLOAD -d $demo_mnt/$image_dir +unzip -o $ONIE_INSTALLER_PAYLOAD -x "$FILESYSTEM_DOCKERFS" -d $demo_mnt/$image_dir -if [ -f $demo_mnt/$image_dir/$FILESYSTEM_DOCKERFS ]; then - TAR_EXTRA_OPTION="--numeric-owner" - cd $demo_mnt/$image_dir && mkdir -p $DOCKERFS_DIR && tar x $TAR_EXTRA_OPTION -f $FILESYSTEM_DOCKERFS -C $DOCKERFS_DIR && rm -f $FILESYSTEM_DOCKERFS; cd $OLDPWD -fi +TAR_EXTRA_OPTION="--numeric-owner" +mkdir -p $demo_mnt/$image_dir/$DOCKERFS_DIR +unzip -op $ONIE_INSTALLER_PAYLOAD "$FILESYSTEM_DOCKERFS" | tar xz $TAR_EXTRA_OPTION -f - -C $demo_mnt/$image_dir/$DOCKERFS_DIR # Create loop device for /var/log to limit its size to $VAR_LOG_SIZE MB if [ -f $demo_mnt/disk-img/var-log.ext4 ]; then From 4a780f4a6ac30e91d6b7a8dc71f87a4902a23367 Mon Sep 17 00:00:00 2001 From: lguohan Date: Sun, 18 Jun 2017 16:54:13 -0700 Subject: [PATCH 08/45] [submodule]: update swss/sairedis/swss-common submodule (#716) fix bug for logrotate sairedis log --- files/image_config/logrotate.d/rsyslog | 15 ++++++++++++++- src/sonic-sairedis | 2 +- src/sonic-swss | 2 +- src/sonic-swss-common | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/files/image_config/logrotate.d/rsyslog b/files/image_config/logrotate.d/rsyslog index a212ddfce15c..4693288f18cc 100644 --- a/files/image_config/logrotate.d/rsyslog +++ b/files/image_config/logrotate.d/rsyslog @@ -1,7 +1,6 @@ /var/log/syslog /var/log/quagga/*.log /var/log/teamd.log -/var/log/swss/*.rec { rotate 7 daily @@ -18,6 +17,20 @@ kill -HUP $(cat /var/run/rsyslogd.pid) endscript } +/var/log/swss/*.rec +{ + rotate 7 + daily + maxsize 20M + missingok + notifempty + compress + delaycompress + sharedscripts + postrotate + pgrep -x orchagent | xargs /bin/kill -HUP 2>/dev/null || true + endscript +} /var/log/mail.info /var/log/mail.warn /var/log/mail.err diff --git a/src/sonic-sairedis b/src/sonic-sairedis index 1eeb716837bb..b865912105f2 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit 1eeb716837bb4e6cd4d179e3654ee67e74cf5736 +Subproject commit b865912105f2f80ee2516899e6367f863d5f6235 diff --git a/src/sonic-swss b/src/sonic-swss index b893b4f70b79..002adc7bdea0 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit b893b4f70b79f5a87674e3a67a64accff0dd9437 +Subproject commit 002adc7bdea0894eb11835374463eb9c2f208790 diff --git a/src/sonic-swss-common b/src/sonic-swss-common index ececc0a99ce1..345576ea38cc 160000 --- a/src/sonic-swss-common +++ b/src/sonic-swss-common @@ -1 +1 @@ -Subproject commit ececc0a99ce1c188007b5b59de1bb11a06dd006d +Subproject commit 345576ea38cc511b265825b445c48dbfbf444792 From 35cec022e6f51e7a8ceb218578b6e48baf0b0544 Mon Sep 17 00:00:00 2001 From: lguohan Date: Mon, 19 Jun 2017 11:17:30 -0700 Subject: [PATCH 09/45] [submodule]: update sonic-swss (#719) --- src/sonic-swss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-swss b/src/sonic-swss index 002adc7bdea0..316b33371dcb 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit 002adc7bdea0894eb11835374463eb9c2f208790 +Subproject commit 316b33371dcbccd3d81fa6987170be3e7a3a1536 From 493edb45848564c9489a3f4fad4a46446bd59862 Mon Sep 17 00:00:00 2001 From: lguohan Date: Mon, 19 Jun 2017 22:16:05 -0700 Subject: [PATCH 10/45] [image]: add debian security update in the apt source list (#724) --- .../sources.list.d/debian_archive_trafficmanager_net_debian.list | 1 + 1 file changed, 1 insertion(+) diff --git a/files/image_config/apt/sources.list.d/debian_archive_trafficmanager_net_debian.list b/files/image_config/apt/sources.list.d/debian_archive_trafficmanager_net_debian.list index 503897133ca3..d5ecf56d4069 100644 --- a/files/image_config/apt/sources.list.d/debian_archive_trafficmanager_net_debian.list +++ b/files/image_config/apt/sources.list.d/debian_archive_trafficmanager_net_debian.list @@ -1 +1,2 @@ deb http://debian-archive.trafficmanager.net/debian/ jessie main contrib non-free +deb http://debian-archive.trafficmanager.net/debian-security/ jessie/updates main contrib non-free From fe56389a0f8d9350744038f560e66a70a159bb07 Mon Sep 17 00:00:00 2001 From: lguohan Date: Mon, 19 Jun 2017 22:16:21 -0700 Subject: [PATCH 11/45] [submodule]: update sonic-platform-daemons (#722) --- src/sonic-platform-daemons | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-platform-daemons b/src/sonic-platform-daemons index bd7c31075765..dac4bf5a242f 160000 --- a/src/sonic-platform-daemons +++ b/src/sonic-platform-daemons @@ -1 +1 @@ -Subproject commit bd7c310757658396ccfaaf653ede4a931b3d4154 +Subproject commit dac4bf5a242fe3c10d750378b7aaf6d41ac573ee From 894976e15569d6cc109b0c523e4b3409dc0735be Mon Sep 17 00:00:00 2001 From: lguohan Date: Mon, 19 Jun 2017 22:16:50 -0700 Subject: [PATCH 12/45] [platform]: turn on/off four leds for breakout-able front panel ports (#723) turn on/off four leds for breakout-able front panel ports on arista 7050 qx32 platform --- .../plugins/led_control.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/device/arista/x86_64-arista_7050_qx32/plugins/led_control.py b/device/arista/x86_64-arista_7050_qx32/plugins/led_control.py index e246a2e61581..9b8fd2f79186 100644 --- a/device/arista/x86_64-arista_7050_qx32/plugins/led_control.py +++ b/device/arista/x86_64-arista_7050_qx32/plugins/led_control.py @@ -48,21 +48,23 @@ def port_link_state_change(self, port, state): if qsfp_index <= 0: return - # QSFP indices 1-24 are breakout-capable and have four LEDs, + # QSFP indices 1-24 are breakout-capable and have four LEDs, and each LED indicate one lane. # whereas indices 25-32 are not breakout-capable, and only have one if qsfp_index <= self.QSFP_BREAKOUT_END_IDX: - led_sysfs_path = self.LED_SYSFS_PATH_BREAKOUT_CAPABLE.format(qsfp_index, 1) + # assuming 40G, then we need to control four lanes + led_sysfs_paths = [ self.LED_SYSFS_PATH_BREAKOUT_CAPABLE.format(qsfp_index, i) for i in range(1, 5) ] else: - led_sysfs_path = self.LED_SYSFS_PATH_NO_BREAKOUT.format(qsfp_index) + led_sysfs_paths = [ self.LED_SYSFS_PATH_NO_BREAKOUT.format(qsfp_index) ] - led_file = open(led_sysfs_path, "w") + for led_sysfs_path in led_sysfs_paths: + led_file = open(led_sysfs_path, "w") - if state == "up": - led_file.write("%d" % self.LED_COLOR_GREEN) - else: - led_file.write("%d" % self.LED_COLOR_OFF) + if state == "up": + led_file.write("%d" % self.LED_COLOR_GREEN) + else: + led_file.write("%d" % self.LED_COLOR_OFF) - led_file.close() + led_file.close() # Constructor def __init__(self): From cc218b34510b11bc73bbb87dbab68fcfee2caa7d Mon Sep 17 00:00:00 2001 From: sihuihan88 Date: Tue, 20 Jun 2017 12:22:30 -0700 Subject: [PATCH 13/45] [sonic-quagga]:update submodule (#718) Signed-off-by: Sihui Han --- src/sonic-quagga | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-quagga b/src/sonic-quagga index 5da3e26ecddf..df6b70902b4c 160000 --- a/src/sonic-quagga +++ b/src/sonic-quagga @@ -1 +1 @@ -Subproject commit 5da3e26ecddfec6f5983f34b27056b64f67e09d3 +Subproject commit df6b70902b4c29447ac52277cf6d5b7f6abca71e From c2c232a1619845108985292ee854bb9e6a954ed5 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Tue, 20 Jun 2017 16:37:07 -0700 Subject: [PATCH 14/45] Add Broadcom LED microprocessor initialization for Dell S6000 (#726) * Add Broadcom LED microprocessor initialization for Dell S6000 * Increase bcmcmd timeout to 60 seconds --- .../led_proc_init.soc | 43 +++++++++++++++++++ platform/broadcom/docker-syncd-brcm/start.sh | 7 +++ 2 files changed, 50 insertions(+) create mode 100644 device/dell/x86_64-dell_s6000_s1220-r0/led_proc_init.soc diff --git a/device/dell/x86_64-dell_s6000_s1220-r0/led_proc_init.soc b/device/dell/x86_64-dell_s6000_s1220-r0/led_proc_init.soc new file mode 100644 index 000000000000..ddda7bdb639a --- /dev/null +++ b/device/dell/x86_64-dell_s6000_s1220-r0/led_proc_init.soc @@ -0,0 +1,43 @@ +# LED microprocessor initialization for Dell s6000 + +led 0 stop +led 0 prog 02 31 60 F7 02 01 28 60 F6 D6 F7 70 28 67 44 06 F6 06 F6 80 D2 35 74 06 86 F8 3A 40 67 80 67 44 06 F6 67 80 67 80 67 3C D2 32 70 1C D2 34 70 1C 67 44 06 F6 67 80 67 80 67 80 67 3C 06 F7 F2 01 60 F7 77 11 32 08 97 71 4C 77 80 57 67 61 32 00 32 01 B7 97 71 5C 95 75 74 85 77 7C 02 0A 50 77 56 06 F6 D2 17 75 6C 12 88 FE F6 57 06 F6 E2 17 12 D4 F8 57 16 F8 CA 05 74 80 77 7C 22 0E 87 57 22 0F 87 57 +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_0_3 REMAP_PORT_3=0x31 REMAP_PORT_2=0 REMAP_PORT_1=0 REMAP_PORT_0=0 +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_4_7 REMAP_PORT_7=0x32 REMAP_PORT_6=0 REMAP_PORT_5=0 REMAP_PORT_4=0 +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_8_11 REMAP_PORT_9=0 REMAP_PORT_8=0 REMAP_PORT_11=0x34 REMAP_PORT_10=0 +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_12_15 REMAP_PORT_15=0x33 REMAP_PORT_14=0 REMAP_PORT_13=0 REMAP_PORT_12=0 +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_16_19 REMAP_PORT_19=0x16 REMAP_PORT_18=0x15 REMAP_PORT_17=0x18 REMAP_PORT_16=0x17 +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_20_23 REMAP_PORT_23=0x11 REMAP_PORT_22=0x12 REMAP_PORT_21=0x13 REMAP_PORT_20=0x14 +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_24_27 REMAP_PORT_27=9 REMAP_PORT_26=0xa REMAP_PORT_25=0xb REMAP_PORT_24=0xc +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_28_31 REMAP_PORT_31=0xe REMAP_PORT_30=0xd REMAP_PORT_29=0x10 REMAP_PORT_28=0xf +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_32_35 REMAP_PORT_35=0x2e REMAP_PORT_34=0x2d REMAP_PORT_33=0x30 REMAP_PORT_32=0x2f +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_36_39 REMAP_PORT_39=0x29 REMAP_PORT_38=0x2a REMAP_PORT_37=0x2b REMAP_PORT_36=0x2c +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_40_43 REMAP_PORT_43=6 REMAP_PORT_42=5 REMAP_PORT_41=8 REMAP_PORT_40=7 +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_44_47 REMAP_PORT_47=1 REMAP_PORT_46=2 REMAP_PORT_45=3 REMAP_PORT_44=4 +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_48_51 REMAP_PORT_51=0x26 REMAP_PORT_50=0x25 REMAP_PORT_49=0x28 REMAP_PORT_48=0x27 +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_52_55 REMAP_PORT_55=0x21 REMAP_PORT_54=0x22 REMAP_PORT_53=0x23 REMAP_PORT_52=0x24 +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_56_59 REMAP_PORT_59=0x19 REMAP_PORT_58=0x1a REMAP_PORT_57=0x1b REMAP_PORT_56=0x1c +modreg CMIC_LEDUP0_PORT_ORDER_REMAP_60_63 REMAP_PORT_63=0x1e REMAP_PORT_62=0x1d REMAP_PORT_61=0x20 REMAP_PORT_60=0x1f +led 0 auto on +led 0 start + +led 1 stop +led 1 prog 02 31 60 F7 02 01 28 60 F6 D6 F7 70 28 67 44 06 F6 06 F6 80 D2 35 74 06 86 F8 3A 40 67 80 67 44 06 F6 67 80 67 80 67 3C D2 32 70 1C D2 34 70 1C 67 44 06 F6 67 80 67 80 67 80 67 3C 06 F7 F2 01 60 F7 77 11 32 08 97 71 4C 77 80 57 67 61 32 00 32 01 B7 97 71 5C 95 75 74 85 77 7C 02 0A 50 77 56 06 F6 D2 17 75 6C 12 88 FE F6 57 06 F6 E2 17 12 D4 F8 57 16 F8 CA 05 74 80 77 7C 22 0E 87 57 22 0F 87 57 +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_0_3 REMAP_PORT_3=0x1e REMAP_PORT_2=0x1d REMAP_PORT_1=0x20 REMAP_PORT_0=0x1f +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_4_7 REMAP_PORT_7=0x19 REMAP_PORT_6=0x1a REMAP_PORT_5=0x1b REMAP_PORT_4=0x1c +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_8_11 REMAP_PORT_9=0x23 REMAP_PORT_8=0x24 REMAP_PORT_11=0x21 REMAP_PORT_10=0x22 +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_12_15 REMAP_PORT_15=0x26 REMAP_PORT_14=0x25 REMAP_PORT_13=0x28 REMAP_PORT_12=0x27 +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_16_19 REMAP_PORT_19=0x16 REMAP_PORT_18=0x15 REMAP_PORT_17=0x18 REMAP_PORT_16=0x17 +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_20_23 REMAP_PORT_23=0x11 REMAP_PORT_22=0x12 REMAP_PORT_21=0x13 REMAP_PORT_20=0x14 +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_24_27 REMAP_PORT_27=0x34 REMAP_PORT_26=0 REMAP_PORT_25=0 REMAP_PORT_24=0 +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_28_31 REMAP_PORT_31=0x33 REMAP_PORT_30=0 REMAP_PORT_29=0 REMAP_PORT_28=0 +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_32_35 REMAP_PORT_35=0x2e REMAP_PORT_34=0x2d REMAP_PORT_33=0x30 REMAP_PORT_32=0x2f +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_36_39 REMAP_PORT_39=0x29 REMAP_PORT_38=0x2a REMAP_PORT_37=0x2b REMAP_PORT_36=0x2c +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_40_43 REMAP_PORT_43=0x31 REMAP_PORT_42=0 REMAP_PORT_41=0 REMAP_PORT_40=0 +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_44_47 REMAP_PORT_47=0x32 REMAP_PORT_46=0 REMAP_PORT_45=0 REMAP_PORT_44=0 +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_48_51 REMAP_PORT_51=9 REMAP_PORT_50=0xa REMAP_PORT_49=0xb REMAP_PORT_48=0xc +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_52_55 REMAP_PORT_55=0xe REMAP_PORT_54=0xd REMAP_PORT_53=0x10 REMAP_PORT_52=0xf +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_56_59 REMAP_PORT_59=6 REMAP_PORT_58=5 REMAP_PORT_57=8 REMAP_PORT_56=7 +modreg CMIC_LEDUP1_PORT_ORDER_REMAP_60_63 REMAP_PORT_63=1 REMAP_PORT_62=2 REMAP_PORT_61=3 REMAP_PORT_60=4 +led 1 auto on +led 1 start diff --git a/platform/broadcom/docker-syncd-brcm/start.sh b/platform/broadcom/docker-syncd-brcm/start.sh index 96e2a9128081..6f9b69ff8d40 100755 --- a/platform/broadcom/docker-syncd-brcm/start.sh +++ b/platform/broadcom/docker-syncd-brcm/start.sh @@ -1,8 +1,15 @@ #!/usr/bin/env bash +PLATFORM_DIR=/usr/share/sonic/platform + rm -f /var/run/rsyslogd.pid supervisorctl start rsyslogd supervisorctl start syncd +# If this platform has an initialization file for the Broadcom LED microprocessor, load it +if [ -r ${PLATFORM_DIR}/led_proc_init.soc ]; then + /usr/bin/bcmcmd -t 60 "rcload ${PLATFORM_DIR}/led_proc_init.soc" +fi + From 6feef14f2e5e2a06a3f0aa1153feed80b41fa357 Mon Sep 17 00:00:00 2001 From: Samuel Angebault Date: Tue, 20 Jun 2017 20:39:42 -0700 Subject: [PATCH 15/45] [platform]: Update sonic-platform-modules-arista (#727) --- platform/broadcom/sonic-platform-modules-arista | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/broadcom/sonic-platform-modules-arista b/platform/broadcom/sonic-platform-modules-arista index 393e5e1f19fd..75e84737680f 160000 --- a/platform/broadcom/sonic-platform-modules-arista +++ b/platform/broadcom/sonic-platform-modules-arista @@ -1 +1 @@ -Subproject commit 393e5e1f19fd33853bb375d70a10fa7cf4613e4a +Subproject commit 75e84737680f5451eb9c947d01968b972d989bb3 From c4133e166b09e9787228a2edbf7e31955f25fd37 Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Tue, 20 Jun 2017 20:50:51 -0700 Subject: [PATCH 16/45] [Broadcom]: Update SAI package to support Accton-AS7712-C32 (#720) --- platform/broadcom/sai.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index 74baaa712f10..130520298120 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,9 +1,9 @@ -BRCM_SAI = libsaibcm_2.1.5.1-11-20170605231900.43_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/libsaibcm_2.1.5.1-11-20170605231900.43_amd64.deb?sv=2015-04-05&sr=b&sig=NNBDS1OSXn2w4dNSbqBbJnqXTrqH7YAkKIa%2Fi9yaOJs%3D&se=2031-02-12T23%3A22%3A01Z&sp=r" +BRCM_SAI = libsaibcm_2.1.5.1-12-20170607194342.44_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/libsaibcm_2.1.5.1-12-20170607194342.44_amd64.deb?sv=2015-04-05&sr=b&sig=gJJVxVT2o%2Bm14%2BwCBYFmBfcrDCzBA4b4iSmDKxnS13o%3D&se=2031-02-26T17%3A39%3A50Z&sp=r" -BRCM_SAI_DEV = libsaibcm-dev_2.1.5.1-11-20170605231900.43_amd64.deb +BRCM_SAI_DEV = libsaibcm-dev_2.1.5.1-12-20170607194342.44_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/libsaibcm-dev_2.1.5.1-11-20170605231900.43_amd64.deb?sv=2015-04-05&sr=b&sig=jxozueiuQdOuJdEfC9%2BWSfFXSL68FQVwL%2FM5Obfj3gs%3D&se=2031-02-12T23%3A21%3A35Z&sp=r" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/libsaibcm-dev_2.1.5.1-12-20170607194342.44_amd64.deb?sv=2015-04-05&sr=b&sig=AfYK3Qz%2FTV61E89u0kASm7wF3LEiqaZb%2Fde2jvbw9yk%3D&se=2031-02-26T17%3A40%3A14Z&sp=r" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV) $(BRCM_SAI)_DEPENDS += $(BRCM_OPENNSL) From 66859385b676d9b1c504ac0d492ba2b033e8bf33 Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Wed, 21 Jun 2017 11:52:16 +0800 Subject: [PATCH 17/45] =?UTF-8?q?Remove=20exsiting=20sonic-platform-module?= =?UTF-8?q?s-accton=20and=20apply=20submodule=20add=E2=80=A6=20(#717)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove exsiting sonic-platform-modules-accton and apply submodule adding on this folder. * Remove redundant commnet * Remove folder platform/broadcom/sonic-platform-modules-accton. * Add this dir for submodule. --- .gitmodules | 3 + .../plugins/eeprom.py | 24 + .../plugins/sfputil.py | 60 + platform/broadcom/platform-modules-accton.mk | 5 +- .../broadcom/sonic-platform-modules-accton | 1 + .../sonic-platform-modules-accton/.gitignore | 33 - .../sonic-platform-modules-accton/LICENSE | 16 - .../sonic-platform-modules-accton/README.md | 1 - .../as7712-32x/cfg/as7712_32x-modules.conf | 13 - .../as7712-32x/modules/Makefile | 2 - .../modules/accton_as7712_32x_fan.c | 452 ------- .../modules/accton_as7712_32x_psu.c | 293 ----- .../modules/accton_as7712_32x_sfp.c | 1083 ----------------- .../as7712-32x/modules/accton_i2c_cpld.c | 259 ---- .../modules/leds-accton_as7712_32x.c | 443 ------- .../as7712-32x/modules/ym2651y.c | 589 --------- .../scripts/as7712_32x_platform_init.sh | 3 - .../debian/changelog | 5 - .../debian/compat | 1 - .../debian/control | 11 - .../debian/platform-modules-as7712-32x.init | 44 - .../platform-modules-as7712-32x.install | 2 - .../debian/rules | 36 - 23 files changed, 89 insertions(+), 3290 deletions(-) create mode 100644 device/accton/x86_64-accton_as7712_32x-r0/plugins/eeprom.py create mode 100644 device/accton/x86_64-accton_as7712_32x-r0/plugins/sfputil.py create mode 160000 platform/broadcom/sonic-platform-modules-accton delete mode 100644 platform/broadcom/sonic-platform-modules-accton/.gitignore delete mode 100644 platform/broadcom/sonic-platform-modules-accton/LICENSE delete mode 100644 platform/broadcom/sonic-platform-modules-accton/README.md delete mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/cfg/as7712_32x-modules.conf delete mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/Makefile delete mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_fan.c delete mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_psu.c delete mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_sfp.c delete mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_i2c_cpld.c delete mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/leds-accton_as7712_32x.c delete mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/ym2651y.c delete mode 100644 platform/broadcom/sonic-platform-modules-accton/as7712-32x/scripts/as7712_32x_platform_init.sh delete mode 100644 platform/broadcom/sonic-platform-modules-accton/debian/changelog delete mode 100644 platform/broadcom/sonic-platform-modules-accton/debian/compat delete mode 100644 platform/broadcom/sonic-platform-modules-accton/debian/control delete mode 100644 platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.init delete mode 100644 platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.install delete mode 100755 platform/broadcom/sonic-platform-modules-accton/debian/rules diff --git a/.gitmodules b/.gitmodules index 99938c4abaca..454019f9ebdd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -63,3 +63,6 @@ [submodule "src/sonic-platform-daemons"] path = src/sonic-platform-daemons url = https://github.com/Azure/sonic-platform-daemons +[submodule "platform/broadcom/sonic-platform-modules-accton"] + path = platform/broadcom/sonic-platform-modules-accton + url = https://github.com/edge-core/sonic-platform-modules-accton.git diff --git a/device/accton/x86_64-accton_as7712_32x-r0/plugins/eeprom.py b/device/accton/x86_64-accton_as7712_32x-r0/plugins/eeprom.py new file mode 100644 index 000000000000..7681caafeef4 --- /dev/null +++ b/device/accton/x86_64-accton_as7712_32x-r0/plugins/eeprom.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +try: + import exceptions + import binascii + import time + import optparse + import warnings + import os + import sys + from sonic_eeprom import eeprom_base + from sonic_eeprom import eeprom_tlvinfo + import subprocess +except ImportError, e: + raise ImportError (str(e) + "- required module not found") + +class board(eeprom_tlvinfo.TlvInfoDecoder): + _TLV_INFO_MAX_LEN = 256 + def __init__(self, name, path, cpld_root, ro): + self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom" + #Two i2c buses might get flipped order, check them both. + if not os.path.exists(self.eeprom_path): + self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom" + super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/accton/x86_64-accton_as7712_32x-r0/plugins/sfputil.py b/device/accton/x86_64-accton_as7712_32x-r0/plugins/sfputil.py new file mode 100644 index 000000000000..6dc35d72bb21 --- /dev/null +++ b/device/accton/x86_64-accton_as7712_32x-r0/plugins/sfputil.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +try: + from sonic_sfp.sfputilbase import sfputilbase +except ImportError, e: + raise ImportError (str(e) + "- required module not found") + + +class sfputil(sfputilbase): + """Platform specific sfputil class""" + + port_start = 0 + port_end = 31 + ports_in_block = 32 + + port_to_eeprom_mapping = {} + port_to_i2c_mapping = { + 9 : 18, + 10 : 19, + 11 : 20, + 12 : 21, + 1 : 22, + 2 : 23, + 3 : 24, + 4 : 25, + 6 : 26, + 5 : 27, + 8 : 28, + 7 : 29, + 13 : 30, + 14 : 31, + 15 : 32, + 16 : 33, + 17 : 34, + 18 : 35, + 19 : 36, + 20 : 37, + 25 : 38, + 26 : 39, + 27 : 40, + 28 : 41, + 29 : 42, + 30 : 43, + 31 : 44, + 32 : 45, + 21 : 46, + 22 : 47, + 23 : 48, + 24 : 49, + } + + _qsfp_ports = range(0, ports_in_block + 1) + + def __init__(self, port_num): + # Override port_to_eeprom_mapping for class initialization + eeprom_path = '/sys/bus/i2c/devices/{0}-0050/sfp_eeprom' + for x in range(self.port_start, self.port_end + 1): + port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x+1]) + self.port_to_eeprom_mapping[x] = port_eeprom_path + sfputilbase.__init__(self, port_num) diff --git a/platform/broadcom/platform-modules-accton.mk b/platform/broadcom/platform-modules-accton.mk index 00128a20f8d2..e5357c5e9f14 100644 --- a/platform/broadcom/platform-modules-accton.mk +++ b/platform/broadcom/platform-modules-accton.mk @@ -4,11 +4,8 @@ ACCTON_AS7712_32X_PLATFORM_MODULE_VERSION = 1.0 export ACCTON_AS7712_32X_PLATFORM_MODULE_VERSION -ACCTON_AS7712_32X_PLATFORM_MODULE = platform-modules-as7712-32x_$(ACCTON_AS7712_32X_PLATFORM_MODULE_VERSION)_amd64.deb +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 $(ACCTON_AS7712_32X_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) $(ACCTON_AS7712_32X_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as7712_32x-r0 SONIC_DPKG_DEBS += $(ACCTON_AS7712_32X_PLATFORM_MODULE) - -$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE))) - diff --git a/platform/broadcom/sonic-platform-modules-accton b/platform/broadcom/sonic-platform-modules-accton new file mode 160000 index 000000000000..99607d63220d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton @@ -0,0 +1 @@ +Subproject commit 99607d63220de336a61d81f6b4d1e64062761abe diff --git a/platform/broadcom/sonic-platform-modules-accton/.gitignore b/platform/broadcom/sonic-platform-modules-accton/.gitignore deleted file mode 100644 index f805e810e5c6..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/.gitignore +++ /dev/null @@ -1,33 +0,0 @@ -# Object files -*.o -*.ko -*.obj -*.elf - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - -# Debug files -*.dSYM/ -*.su diff --git a/platform/broadcom/sonic-platform-modules-accton/LICENSE b/platform/broadcom/sonic-platform-modules-accton/LICENSE deleted file mode 100644 index bc693f7a4c40..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/LICENSE +++ /dev/null @@ -1,16 +0,0 @@ -Copyright (C) 2016 Microsoft, Inc -Copyright (C) 2017 Accton Technology Corporation - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/platform/broadcom/sonic-platform-modules-accton/README.md b/platform/broadcom/sonic-platform-modules-accton/README.md deleted file mode 100644 index 743db0cb238f..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/README.md +++ /dev/null @@ -1 +0,0 @@ -platform drivers for AS7712_32X for the SONiC project diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/cfg/as7712_32x-modules.conf b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/cfg/as7712_32x-modules.conf deleted file mode 100644 index cf2c5fa775bd..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/cfg/as7712_32x-modules.conf +++ /dev/null @@ -1,13 +0,0 @@ -# /etc/modules: kernel modules to load at boot time. -# -# This file contains the names of kernel modules that should be loaded -# at boot time, one per line. Lines beginning with "#" are ignored. - -i2c_dev -i2c_mux_pca954x -accton_i2c_cpld -accton_as7712_32x_fan -accton_as7712_32x_sfp -leds-accton_as7712_32x -accton_as7712_32x_psu - diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/Makefile b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/Makefile deleted file mode 100644 index 83319ec62e58..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -obj-m:=accton_as7712_32x_fan.o accton_as7712_32x_sfp.o leds-accton_as7712_32x.o \ - accton_as7712_32x_psu.o accton_i2c_cpld.o ym2651y.o \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_fan.c deleted file mode 100644 index 52db1e9dc028..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_fan.c +++ /dev/null @@ -1,452 +0,0 @@ -/* - * A hwmon driver for the Accton as7712 32x fan - * - * Copyright (C) 2014 Accton Technology Corporation. - * Brandon Chuang - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRVNAME "as7712_32x_fan" - -static struct as7712_32x_fan_data *as7712_32x_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 accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_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[] = { - 0x0F, /* fan 1-6 present status */ - 0x11, /* fan PWM(for all fan) */ - 0x12, /* front fan 1 speed(rpm) */ - 0x13, /* front fan 2 speed(rpm) */ - 0x14, /* front fan 3 speed(rpm) */ - 0x15, /* front fan 4 speed(rpm) */ - 0x16, /* front fan 5 speed(rpm) */ - 0x17, /* front fan 6 speed(rpm) */ - 0x22, /* rear fan 1 speed(rpm) */ - 0x23, /* rear fan 2 speed(rpm) */ - 0x24, /* rear fan 3 speed(rpm) */ - 0x25, /* rear fan 4 speed(rpm) */ - 0x26, /* rear fan 5 speed(rpm) */ - 0x27, /* rear fan 6 speed(rpm) */ -}; - -/* Each client has this additional data */ -struct as7712_32x_fan_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* != 0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */ -}; - -enum fan_id { - FAN1_ID, - FAN2_ID, - FAN3_ID, - FAN4_ID, - FAN5_ID, - FAN6_ID -}; - -enum sysfs_fan_attributes { - FAN_PRESENT_REG, - FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */ - FAN1_FRONT_SPEED_RPM, - FAN2_FRONT_SPEED_RPM, - FAN3_FRONT_SPEED_RPM, - FAN4_FRONT_SPEED_RPM, - FAN5_FRONT_SPEED_RPM, - FAN6_FRONT_SPEED_RPM, - FAN1_REAR_SPEED_RPM, - FAN2_REAR_SPEED_RPM, - FAN3_REAR_SPEED_RPM, - FAN4_REAR_SPEED_RPM, - FAN5_REAR_SPEED_RPM, - FAN6_REAR_SPEED_RPM, - FAN1_PRESENT, - FAN2_PRESENT, - FAN3_PRESENT, - FAN4_PRESENT, - FAN5_PRESENT, - FAN6_PRESENT, - FAN1_FAULT, - FAN2_FAULT, - FAN3_FAULT, - FAN4_FAULT, - FAN5_FAULT, - FAN6_FAULT -}; - -/* 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_DIRECTION_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_direction, S_IRUGO, fan_show_value, NULL, FAN##index##_DIRECTION) -#define DECLARE_FAN_DIRECTION_ATTR(index) &sensor_dev_attr_fan##index##_direction.dev_attr.attr - -#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE) -#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr - -#define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) -#define DECLARE_FAN_PRESENT_ATTR(index) &sensor_dev_attr_fan##index##_present.dev_attr.attr - -#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index) \ - static SENSOR_DEVICE_ATTR(fan##index##_front_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\ - static SENSOR_DEVICE_ATTR(fan##index##_rear_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM) -#define DECLARE_FAN_SPEED_RPM_ATTR(index) &sensor_dev_attr_fan##index##_front_speed_rpm.dev_attr.attr, \ - &sensor_dev_attr_fan##index##_rear_speed_rpm.dev_attr.attr - -/* 6 fan fault attributes in this platform */ -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(4); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(5); -DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(6); -/* 6 fan speed(rpm) attributes in this platform */ -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(4); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(5); -DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(6); -/* 6 fan present attributes in this platform */ -DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(1); -DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(2); -DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(3); -DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(4); -DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(5); -DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(6); -/* 1 fan duty cycle attribute in this platform */ -DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(); - -static struct attribute *as7712_32x_fan_attributes[] = { - /* fan related attributes */ - DECLARE_FAN_FAULT_ATTR(1), - DECLARE_FAN_FAULT_ATTR(2), - DECLARE_FAN_FAULT_ATTR(3), - DECLARE_FAN_FAULT_ATTR(4), - DECLARE_FAN_FAULT_ATTR(5), - DECLARE_FAN_FAULT_ATTR(6), - DECLARE_FAN_SPEED_RPM_ATTR(1), - DECLARE_FAN_SPEED_RPM_ATTR(2), - DECLARE_FAN_SPEED_RPM_ATTR(3), - DECLARE_FAN_SPEED_RPM_ATTR(4), - DECLARE_FAN_SPEED_RPM_ATTR(5), - DECLARE_FAN_SPEED_RPM_ATTR(6), - DECLARE_FAN_PRESENT_ATTR(1), - DECLARE_FAN_PRESENT_ATTR(2), - DECLARE_FAN_PRESENT_ATTR(3), - DECLARE_FAN_PRESENT_ATTR(4), - DECLARE_FAN_PRESENT_ATTR(5), - DECLARE_FAN_PRESENT_ATTR(6), - DECLARE_FAN_DUTY_CYCLE_ATTR(), - NULL -}; - -#define FAN_DUTY_CYCLE_REG_MASK 0xF -#define FAN_MAX_DUTY_CYCLE 100 -#define FAN_REG_VAL_TO_SPEED_RPM_STEP 100 - -static int as7712_32x_fan_read_value(struct i2c_client *client, u8 reg) -{ - return i2c_smbus_read_byte_data(client, reg); -} - -static int as7712_32x_fan_write_value(struct i2c_client *client, u8 reg, u8 value) -{ - return i2c_smbus_write_byte_data(client, reg, value); -} - -/* fan utility functions - */ -static u32 reg_val_to_duty_cycle(u8 reg_val) -{ - reg_val &= FAN_DUTY_CYCLE_REG_MASK; - return ((u32)(reg_val+1) * 625 + 75)/ 100; -} - -static u8 duty_cycle_to_reg_val(u8 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 reg_val_to_is_present(u8 reg_val, enum fan_id id) -{ - u8 mask = (1 << id); - - reg_val &= mask; - - return reg_val ? 0 : 1; -} - -static u8 is_fan_fault(struct as7712_32x_fan_data *data, enum fan_id id) -{ - u8 ret = 1; - int front_fan_index = FAN1_FRONT_SPEED_RPM + id; - int rear_fan_index = FAN1_REAR_SPEED_RPM + id; - - /* Check if the speed of front or rear fan is ZERO, - */ - if (reg_val_to_speed_rpm(data->reg_val[front_fan_index]) && - reg_val_to_speed_rpm(data->reg_val[rear_fan_index])) { - ret = 0; - } - - return ret; -} - -static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - int error, value; - struct i2c_client *client = to_i2c_client(dev); - - error = kstrtoint(buf, 10, &value); - if (error) - return error; - - if (value < 0 || value > FAN_MAX_DUTY_CYCLE) - return -EINVAL; - - as7712_32x_fan_write_value(client, 0x33, 0); /* Disable fan speed watch dog */ - as7712_32x_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); - return count; -} - -static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct as7712_32x_fan_data *data = as7712_32x_fan_update_device(dev); - ssize_t ret = 0; - - if (data->valid) { - switch (attr->index) { - case FAN_DUTY_CYCLE_PERCENTAGE: - { - u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]); - ret = sprintf(buf, "%u\n", duty_cycle); - break; - } - case FAN1_FRONT_SPEED_RPM: - case FAN2_FRONT_SPEED_RPM: - case FAN3_FRONT_SPEED_RPM: - case FAN4_FRONT_SPEED_RPM: - case FAN5_FRONT_SPEED_RPM: - case FAN6_FRONT_SPEED_RPM: - case FAN1_REAR_SPEED_RPM: - case FAN2_REAR_SPEED_RPM: - case FAN3_REAR_SPEED_RPM: - case FAN4_REAR_SPEED_RPM: - case FAN5_REAR_SPEED_RPM: - case FAN6_REAR_SPEED_RPM: - ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index])); - break; - case FAN1_PRESENT: - case FAN2_PRESENT: - case FAN3_PRESENT: - case FAN4_PRESENT: - case FAN5_PRESENT: - case FAN6_PRESENT: - ret = sprintf(buf, "%d\n", - reg_val_to_is_present(data->reg_val[FAN_PRESENT_REG], - attr->index - FAN1_PRESENT)); - break; - case FAN1_FAULT: - case FAN2_FAULT: - case FAN3_FAULT: - case FAN4_FAULT: - case FAN5_FAULT: - case FAN6_FAULT: - ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT)); - break; - default: - break; - } - } - - return ret; -} - -static const struct attribute_group as7712_32x_fan_group = { - .attrs = as7712_32x_fan_attributes, -}; - -static struct as7712_32x_fan_data *as7712_32x_fan_update_device(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct as7712_32x_fan_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || - !data->valid) { - int i; - - dev_dbg(&client->dev, "Starting as7712_32x_fan update\n"); - data->valid = 0; - - /* Update fan data - */ - for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) { - int status = as7712_32x_fan_read_value(client, fan_reg[i]); - - if (status < 0) { - data->valid = 0; - mutex_unlock(&data->update_lock); - dev_dbg(&client->dev, "reg %d, err %d\n", fan_reg[i], status); - return data; - } - else { - data->reg_val[i] = status; - } - } - - data->last_updated = jiffies; - data->valid = 1; - } - - mutex_unlock(&data->update_lock); - - return data; -} - -static int as7712_32x_fan_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct as7712_32x_fan_data *data; - int status; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct as7712_32x_fan_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - i2c_set_clientdata(client, data); - data->valid = 0; - mutex_init(&data->update_lock); - - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as7712_32x_fan_group); - if (status) { - goto exit_free; - } - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - dev_info(&client->dev, "%s: fan '%s'\n", - dev_name(data->hwmon_dev), client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &as7712_32x_fan_group); -exit_free: - kfree(data); -exit: - - return status; -} - -static int as7712_32x_fan_remove(struct i2c_client *client) -{ - struct as7712_32x_fan_data *data = i2c_get_clientdata(client); - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as7712_32x_fan_group); - - return 0; -} - -/* Addresses to scan */ -static const unsigned short normal_i2c[] = { 0x66, I2C_CLIENT_END }; - -static const struct i2c_device_id as7712_32x_fan_id[] = { - { "as7712_32x_fan", 0 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, as7712_32x_fan_id); - -static struct i2c_driver as7712_32x_fan_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = DRVNAME, - }, - .probe = as7712_32x_fan_probe, - .remove = as7712_32x_fan_remove, - .id_table = as7712_32x_fan_id, - .address_list = normal_i2c, -}; - -static int __init as7712_32x_fan_init(void) -{ - extern int platform_accton_as7712_32x(void); - if (!platform_accton_as7712_32x()) { - return -ENODEV; - } - - return i2c_add_driver(&as7712_32x_fan_driver); -} - -static void __exit as7712_32x_fan_exit(void) -{ - i2c_del_driver(&as7712_32x_fan_driver); -} - -module_init(as7712_32x_fan_init); -module_exit(as7712_32x_fan_exit); - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("as7712_32x_fan driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_psu.c deleted file mode 100644 index 8c9230ab2d24..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_psu.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * An hwmon driver for accton as7712_32x 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 - -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 int as7712_32x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { 0x50, 0x53, I2C_CLIENT_END }; - -/* Each client has this additional data - */ -struct as7712_32x_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[9]; /* Model name, read from eeprom */ -}; - -static struct as7712_32x_psu_data *as7712_32x_psu_update_device(struct device *dev); - -enum as7712_32x_psu_sysfs_attributes { - PSU_PRESENT, - PSU_MODEL_NAME, - 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_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); - -static struct attribute *as7712_32x_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, - NULL -}; - -static ssize_t show_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct as7712_32x_psu_data *data = as7712_32x_psu_update_device(dev); - u8 status = 0; - - if (attr->index == PSU_PRESENT) { - status = !(data->status >> (1-data->index) & 0x1); - } - else { /* PSU_POWER_GOOD */ - status = (data->status >> (3-data->index) & 0x1); - } - - return sprintf(buf, "%d\n", status); -} - -static ssize_t show_model_name(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct as7712_32x_psu_data *data = as7712_32x_psu_update_device(dev); - - return sprintf(buf, "%s\n", data->model_name); -} - -static const struct attribute_group as7712_32x_psu_group = { - .attrs = as7712_32x_psu_attributes, -}; - -static int as7712_32x_psu_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct as7712_32x_psu_data *data; - int status; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct as7712_32x_psu_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - i2c_set_clientdata(client, data); - data->valid = 0; - data->index = dev_id->driver_data; - mutex_init(&data->update_lock); - - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as7712_32x_psu_group); - if (status) { - goto exit_free; - } - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - dev_info(&client->dev, "%s: psu '%s'\n", - dev_name(data->hwmon_dev), client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &as7712_32x_psu_group); -exit_free: - kfree(data); -exit: - - return status; -} - -static int as7712_32x_psu_remove(struct i2c_client *client) -{ - struct as7712_32x_psu_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as7712_32x_psu_group); - kfree(data); - - return 0; -} - -enum psu_index -{ - as7712_32x_psu1, - as7712_32x_psu2 -}; - -static const struct i2c_device_id as7712_32x_psu_id[] = { - { "as7712_32x_psu1", as7712_32x_psu1 }, - { "as7712_32x_psu2", as7712_32x_psu2 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, as7712_32x_psu_id); - -static struct i2c_driver as7712_32x_psu_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "as7712_32x_psu", - }, - .probe = as7712_32x_psu_probe, - .remove = as7712_32x_psu_remove, - .id_table = as7712_32x_psu_id, - .address_list = normal_i2c, -}; - -static int as7712_32x_psu_read_block(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ - int result = 0; - int retry_count = 5; - - while (retry_count) { - retry_count--; - - result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - - if (unlikely(result < 0)) { - msleep(10); - continue; - } - - if (unlikely(result != data_len)) { - result = -EIO; - msleep(10); - continue; - } - - result = 0; - break; - } - - return result; -} - -static struct as7712_32x_psu_data *as7712_32x_psu_update_device(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct as7712_32x_psu_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->last_updated + HZ + HZ / 2) - || !data->valid) { - int status; - int power_good = 0; - - dev_dbg(&client->dev, "Starting as7712_32x update\n"); - - /* Read psu status */ - status = accton_i2c_cpld_read(0x60, 0x2); - - if (status < 0) { - dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); - } - else { - data->status = status; - } - - /* Read model name */ - memset(data->model_name, 0, sizeof(data->model_name)); - power_good = (data->status >> (3-data->index) & 0x1); - - if (power_good) { - status = as7712_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); - } - else { - data->model_name[ARRAY_SIZE(data->model_name)-1] = '\0'; - } - } - - data->last_updated = jiffies; - data->valid = 1; - } - - mutex_unlock(&data->update_lock); - - return data; -} - -static int __init as7712_32x_psu_init(void) -{ - extern int platform_accton_as7712_32x(void); - if (!platform_accton_as7712_32x()) { - return -ENODEV; - } - - return i2c_add_driver(&as7712_32x_psu_driver); -} - -static void __exit as7712_32x_psu_exit(void) -{ - i2c_del_driver(&as7712_32x_psu_driver); -} - -module_init(as7712_32x_psu_init); -module_exit(as7712_32x_psu_exit); - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("as7712_32x_psu driver"); -MODULE_LICENSE("GPL"); - diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_sfp.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_sfp.c deleted file mode 100644 index 4366d2a6ea1d..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_sfp.c +++ /dev/null @@ -1,1083 +0,0 @@ -/* - * SFP driver for accton as7712_32x sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as7712_32x_sfp" - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define NUM_OF_SFP_PORT 32 -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 -#define I2C_RW_RETRY_COUNT 3 -#define I2C_RW_RETRY_INTERVAL 100 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) -#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 -#define SFF8472_10G_BASE_MASK 0xF0 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { SFP_EEPROM_A0_I2C_ADDR, SFP_EEPROM_A2_I2C_ADDR, I2C_CLIENT_END }; - -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -sfp1, sfp2, sfp3, sfp4, sfp5, sfp6, sfp7, sfp8, -sfp9, sfp10, sfp11, sfp12, sfp13, sfp14, sfp15, sfp16, -sfp17, sfp18, sfp19, sfp20, sfp21, sfp22, sfp23, sfp24, -sfp25, sfp26, sfp27, sfp28, sfp29, sfp30, sfp31, sfp32 -}; - -static const struct i2c_device_id sfp_device_id[] = { -{ "sfp1", sfp1 }, { "sfp2", sfp2 }, { "sfp3", sfp3 }, { "sfp4", sfp4 }, -{ "sfp5", sfp5 }, { "sfp6", sfp6 }, { "sfp7", sfp7 }, { "sfp8", sfp8 }, -{ "sfp9", sfp9 }, { "sfp10", sfp10 }, { "sfp11", sfp11 }, { "sfp12", sfp12 }, -{ "sfp13", sfp13 }, { "sfp14", sfp14 }, { "sfp15", sfp15 }, { "sfp16", sfp16 }, -{ "sfp17", sfp17 }, { "sfp18", sfp18 }, { "sfp19", sfp19 }, { "sfp20", sfp20 }, -{ "sfp21", sfp21 }, { "sfp22", sfp22 }, { "sfp23", sfp23 }, { "sfp24", sfp24 }, -{ "sfp25", sfp25 }, { "sfp26", sfp26 }, { "sfp27", sfp27 }, { "sfp28", sfp28 }, -{ "sfp29", sfp29 }, { "sfp30", sfp30 }, { "sfp31", sfp31 }, { "sfp32", sfp32 }, -{} -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); - -/* - * list of valid port types - * note OOM_PORT_TYPE_NOT_PRESENT to indicate no - * module is present in this port - */ -typedef enum oom_driver_port_type_e { - OOM_DRIVER_PORT_TYPE_INVALID, - OOM_DRIVER_PORT_TYPE_NOT_PRESENT, - OOM_DRIVER_PORT_TYPE_SFP, - OOM_DRIVER_PORT_TYPE_SFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP, - OOM_DRIVER_PORT_TYPE_QSFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP28 -} oom_driver_port_type_t; - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct sfp_msa_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[2]; /* index 0 => device id - 1 => 10G Ethernet Compliance Codes - to distinguish SFP or SFP+ - 2 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -}; - -struct sfp_ddm_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - struct eeprom_data eeprom; -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - oom_driver_port_type_t port_type; - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct sfp_msa_data *msa; - struct sfp_ddm_data *ddm; - struct qsfp_data *qsfp; - - struct i2c_client *client; -}; - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - TX_DISABLE_ALL, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0; - int status = -1; - u8 regs[] = {0x30, 0x31, 0x32, 0x33}; - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - - /* Read present status of port 1~32 */ - data->present = 0; - - for (i = 0; i < ARRAY_SIZE(regs); i++) { - status = accton_i2c_cpld_read(0x60, regs[i]); - - if (status < 0) { - DEBUG_PRINT("cpld(0x60) reg(0x%x) err %d", regs[i], status); - goto exit; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); - data->present |= (u64)status << (i*8); - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return data; -} - -static struct sfp_port_data *sfp_update_tx_rx_status(struct device *dev) -{ - return NULL; -} - -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - return 0; -} - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = sfp_update_present(client); - return (data->present & BIT_INDEX(data->port)) ? 0 : 1; -} - -static ssize_t show_present(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - if (PRESENT_ALL == attr->index) { - - } - - /* PRESENT */ - return sprintf(buf, "%d\n", sfp_is_port_present(client, data->port)); -} - -static struct sfp_port_data *sfp_update_port_type(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - u8 buf = 0; - int status; - - mutex_lock(&data->update_lock); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - { - status = sfp_eeprom_read(data->client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (status < 0) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - if (buf != SFF8024_DEVICE_ID_SFP) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - status = sfp_eeprom_read(data->client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); - if (status < 0) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); - data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; - break; - } - case DRIVER_TYPE_QSFP: - { - status = sfp_eeprom_read(data->client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (status < 0) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); - switch (buf) { - case SFF8024_DEVICE_ID_QSFP: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; - break; - case SFF8024_DEVICE_ID_QSFP_PLUS: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - case SFF8024_DEVICE_ID_QSFP28: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - default: - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - break; - } - default: - break; - } - - mutex_unlock(&data->update_lock); - return data; -} - -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - if (!sfp_is_port_present(client, data->port)) { - return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); - } - - sfp_update_port_type(dev); - return sprintf(buf, "%d\n", data->port_type); -} - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - dev_dbg(dev, "Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(data->client, reg[i], &buf, sizeof(buf)); - if (status < 0) { - goto exit; - } - } - msleep(200); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(data->client, reg[i], &buf, sizeof(buf)); - if (status < 0) { - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - mutex_unlock(&data->update_lock); - return data; - -exit: - mutex_unlock(&data->update_lock); - return NULL; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0; - struct i2c_client *client = to_i2c_client(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct sfp_port_data *data = i2c_get_clientdata(client); - - if (!sfp_is_port_present(client, data->port)) { - return -ENODEV; - } - - data = qsfp_update_tx_rx_status(dev); - if (!data) { - return -EIO; - } - - switch (attr->index) { - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = (data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)) ? 1 : 0; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = (data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)) ? 1 : 0; - break; - case TX_DISABLE_ALL: - val = ((data->qsfp->status[1] & 0xF) == 0xF) ? 1 : 0; - break; - - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = (data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)) ? 1 : 0; - break; - default: - break; - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int result; - struct i2c_client *client = to_i2c_client(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct sfp_port_data *data; - - result = kstrtol(buf, 10, &disable); - if (result) { - return result; - } - - data = qsfp_update_tx_rx_status(dev); - if (!data) { - return -EIO; - } - - mutex_lock(&data->update_lock); - - DEBUG_PRINT ("%s-%d: disable:%u %d==%d %u\r\n", __FUNCTION__, __LINE__, - disable, attr->index, TX_DISABLE_ALL, data->qsfp->status[1]); - - if (attr->index == TX_DISABLE_ALL) - { - data->qsfp->status[1] = disable? 0xF:0; - } - else - { - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - result = sfp_eeprom_write(client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status; - char ddm; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - if (!sfp_is_port_present(client, data->port)) { - return -ENODEV; - } - - status = sfp_eeprom_read(data->client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); - if (status < 0) { - return -EIO; - } - - return sprintf(buf, "%d\n", (ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK) ? 1 : 0); -} - -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0, index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct sfp_port_data *data; - - data = sfp_update_tx_rx_status(dev); - if (!data) { - return -EIO; - } - - switch (attr->index) { - case TX_FAULT: - index = 0; - break; - case TX_DISABLE: - index = 1; - break; - case RX_LOS: - index = 2; - break; - default: - break; - } - - val = (data->ddm->status[index] & BIT_INDEX(data->port)) ? 1 : 0; - return sprintf(buf, "%d\n", val); -} - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable_all, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE_ALL); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); -static struct attribute *sfp_msa_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, - NULL -}; - -/* SFP ddm attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); -static struct attribute *sfp_ddm_attributes[] = { - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - NULL -}; - -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int result, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - result = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (result < 0) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(result < 0)) { - return result; - } - - return data_len; -#else - int result, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - result = i2c_smbus_write_byte_data(client, command, *data); - if (result < 0) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(result < 0)) { - return result; - } - - return 1; -#endif - - -} - - -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} - - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - return sfp_port_write(data, buf, off, count); -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int result, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (result < 0) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(result < 0)) - goto abort; - if (unlikely(result != data_len)) { - result = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return result; -#else - int result, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - result = i2c_smbus_read_byte_data(client, command); - if (result < 0) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(result < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, result); - goto abort; - } - - *data = (u8)result; - result = 1; - -abort: - return result; -#endif -} - -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - return sfp_port_read(data, buf, off, count); -} - -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; - eeprom->size = EEPROM_SIZE; - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; - -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} - -static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_msa_data **data) -{ - int status; - struct sfp_msa_data *msa; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); - if (!msa) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = msa; - dev_info(&client->dev, "sfp msa '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); -exit_free: - kfree(msa); -exit: - - return status; -} - -static const struct attribute_group sfp_ddm_group = { - .attrs = sfp_ddm_attributes, -}; - -static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_ddm_data **data) -{ - int status; - struct sfp_ddm_data *ddm; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); - if (!ddm) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = ddm; - dev_info(&client->dev, "sfp ddm '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); -exit_free: - kfree(ddm); -exit: - - return status; -} - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); - if (status) { - goto exit_remove; - } - - /* Bring QSFPs out of reset - as6712_32x_i2c_cpld_write(0x62, 0x4, 0xFF); - as6712_32x_i2c_cpld_write(0x62, 0x5, 0xFF); - as6712_32x_i2c_cpld_write(0x64, 0x4, 0xFF); - as6712_32x_i2c_cpld_write(0x64, 0x5, 0xFF);*/ - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct sfp_port_data *data = NULL; - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - - if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { - return -ENODEV; - } - - data->driver_type = DRIVER_TYPE_QSFP; - return qsfp_probe(client, dev_id, &data->qsfp); -} - -static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); - kfree(data); - return 0; -} - -static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_SFP_DDM: - return sfp_ddm_remove(client, data->ddm); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); - } - - return 0; -} - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - extern int platform_accton_as7712_32x(void); - if (!platform_accton_as7712_32x()) { - return -ENODEV; - } - - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as7712_32x_sfp driver"); -MODULE_LICENSE("GPL"); - -module_init(sfp_init); -module_exit(sfp_exit); - diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_i2c_cpld.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_i2c_cpld.c deleted file mode 100644 index b25bf1c2aff4..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_i2c_cpld.c +++ /dev/null @@ -1,259 +0,0 @@ -/* - * A hwmon driver for the accton_i2c_cpld - * - * 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 - -#define CPLD_VERSION_REG 0x1 - -enum as5712_54x_cpld_sysfs_attributes { - CPLD_READ_VERSION, - CPLD_BYTE_ACCESS, - CPLD_DUMP_ALL, -}; - -static ssize_t read_cpld_version(struct device *dev, struct device_attribute *da, - char *buf); -int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); - - -static LIST_HEAD(cpld_client_list); -static struct mutex list_lock; - -struct cpld_client_node { - struct i2c_client *client; - struct list_head list; -}; - -/* Addresses scanned for accton_i2c_cpld - */ -static const unsigned short normal_i2c[] = { 0x31, 0x35, 0x60, 0x61, 0x62, I2C_CLIENT_END }; - -static SENSOR_DEVICE_ATTR(cpld_get_version, S_IRUGO, read_cpld_version, NULL, CPLD_READ_VERSION); - -static struct attribute *as5712_54x_cpld_attributes[] = { - &sensor_dev_attr_cpld_get_version.dev_attr.attr, - NULL -}; - -static const struct attribute_group as5712_54x_cpld_group = { - .attrs = as5712_54x_cpld_attributes, -}; - -static ssize_t read_cpld_version(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - unsigned short cpld_reg = CPLD_VERSION_REG; - u8 reg; - - if(attr->index == CPLD_READ_VERSION) { - reg = accton_i2c_cpld_read(client->addr, cpld_reg); - return sprintf(buf, "%02x\n",reg); - } - return -1 ; -} - - -static void accton_i2c_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 accton_i2c_cpld_remove_client(struct i2c_client *client) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int found = 0; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client == client) { - found = 1; - break; - } - } - - if (found) { - list_del(list_node); - kfree(cpld_node); - } - - mutex_unlock(&list_lock); -} - -static int accton_i2c_cpld_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int status; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_dbg(&client->dev, "i2c_check_functionality failed (0x%x)\n", client->addr); - status = -EIO; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as5712_54x_cpld_group); - if (status) { - goto exit; - } - - dev_info(&client->dev, "chip found\n"); - accton_i2c_cpld_add_client(client); - - return 0; -exit: - return status; -} - -static int accton_i2c_cpld_remove(struct i2c_client *client) -{ - sysfs_remove_group(&client->dev.kobj, &as5712_54x_cpld_group); - - accton_i2c_cpld_remove_client(client); - return 0; -} - -static const struct i2c_device_id accton_i2c_cpld_id[] = { - { "accton_i2c_cpld", 0 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, accton_i2c_cpld_id); - -static struct i2c_driver accton_i2c_cpld_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "accton_i2c_cpld", - }, - .probe = accton_i2c_cpld_probe, - .remove = accton_i2c_cpld_remove, - .id_table = accton_i2c_cpld_id, - .address_list = normal_i2c, -}; - -int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EPERM; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_read_byte_data(cpld_node->client, reg); - break; - } - } - - mutex_unlock(&list_lock); - - return ret; -} -EXPORT_SYMBOL(accton_i2c_cpld_read); - -int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EIO; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); - break; - } - } - - mutex_unlock(&list_lock); - - return ret; -} -EXPORT_SYMBOL(accton_i2c_cpld_write); - -static int __init accton_i2c_cpld_init(void) -{ - mutex_init(&list_lock); - return i2c_add_driver(&accton_i2c_cpld_driver); -} - -static void __exit accton_i2c_cpld_exit(void) -{ - i2c_del_driver(&accton_i2c_cpld_driver); -} - -static struct dmi_system_id as7712_dmi_table[] = { - { - .ident = "Accton AS7712", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Accton"), - DMI_MATCH(DMI_PRODUCT_NAME, "AS7712"), - }, - } -}; - -int platform_accton_as7712_32x(void) -{ - return dmi_check_system(as7712_dmi_table); -} -EXPORT_SYMBOL(platform_accton_as7712_32x); - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton_i2c_cpld driver"); -MODULE_LICENSE("GPL"); - -module_init(accton_i2c_cpld_init); -module_exit(accton_i2c_cpld_exit); diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/leds-accton_as7712_32x.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/leds-accton_as7712_32x.c deleted file mode 100644 index 8b14437bca35..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/leds-accton_as7712_32x.c +++ /dev/null @@ -1,443 +0,0 @@ -/* - * A LED driver for the accton_as7712_32x_led - * - * Copyright (C) 2014 Accton Technology Corporation. - * Brandon Chuang - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/*#define DEBUG*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -extern void led_classdev_unregister(struct led_classdev *led_cdev); -extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); -extern void led_classdev_resume(struct led_classdev *led_cdev); -extern void led_classdev_suspend(struct led_classdev *led_cdev); - -#define DRVNAME "accton_as7712_32x_led" - -struct accton_as7712_32x_led_data { - struct platform_device *pdev; - struct mutex update_lock; - char valid; /* != 0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 reg_val[1]; /* only 1 register*/ -}; - -static struct accton_as7712_32x_led_data *ledctl = NULL; - -/* LED related data - */ - -#define LED_CNTRLER_I2C_ADDRESS (0x60) - -#define LED_TYPE_DIAG_REG_MASK (0x3) -#define LED_MODE_DIAG_GREEN_VALUE (0x02) -#define LED_MODE_DIAG_RED_VALUE (0x01) -#define LED_MODE_DIAG_AMBER_VALUE (0x00) /*It's yellow actually. Green+Red=Yellow*/ -#define LED_MODE_DIAG_OFF_VALUE (0x03) - - -#define LED_TYPE_LOC_REG_MASK (0x80) -#define LED_MODE_LOC_ON_VALUE (0) -#define LED_MODE_LOC_OFF_VALUE (0x80) - -enum led_type { - LED_TYPE_DIAG, - LED_TYPE_LOC, - LED_TYPE_FAN, - LED_TYPE_PSU1, - LED_TYPE_PSU2 -}; - -struct led_reg { - u32 types; - u8 reg_addr; -}; - -static const struct led_reg led_reg_map[] = { - {(1<update_lock); - - if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2) - || !ledctl->valid) { - int i; - - dev_dbg(&ledctl->pdev->dev, "Starting accton_as7712_32x_led update\n"); - - /* Update LED data - */ - for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { - int status = accton_as7712_32x_led_read_value(led_reg_map[i].reg_addr); - - if (status < 0) { - ledctl->valid = 0; - dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg_map[i].reg_addr, status); - goto exit; - } - else - { - ledctl->reg_val[i] = status; - } - } - - ledctl->last_updated = jiffies; - ledctl->valid = 1; - } - -exit: - mutex_unlock(&ledctl->update_lock); -} - -static void accton_as7712_32x_led_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode, - enum led_type type) -{ - int reg_val; - u8 reg ; - mutex_lock(&ledctl->update_lock); - - if( !accton_getLedReg(type, ®)) - { - dev_dbg(&ledctl->pdev->dev, "Not match item for %d.\n", type); - } - - reg_val = accton_as7712_32x_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); - accton_as7712_32x_led_write_value(reg, reg_val); - - /* to prevent the slow-update issue */ - ledctl->valid = 0; - -exit: - mutex_unlock(&ledctl->update_lock); -} - - -static void accton_as7712_32x_led_diag_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - accton_as7712_32x_led_set(led_cdev, led_light_mode, LED_TYPE_DIAG); -} - -static enum led_brightness accton_as7712_32x_led_diag_get(struct led_classdev *cdev) -{ - accton_as7712_32x_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_DIAG, ledctl->reg_val[0]); -} - -static void accton_as7712_32x_led_loc_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ - accton_as7712_32x_led_set(led_cdev, led_light_mode, LED_TYPE_LOC); -} - -static enum led_brightness accton_as7712_32x_led_loc_get(struct led_classdev *cdev) -{ - accton_as7712_32x_led_update(); - return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[0]); -} - -static void accton_as7712_32x_led_auto_set(struct led_classdev *led_cdev, - enum led_brightness led_light_mode) -{ -} - -static enum led_brightness accton_as7712_32x_led_auto_get(struct led_classdev *cdev) -{ - return LED_MODE_AUTO; -} - -static struct led_classdev accton_as7712_32x_leds[] = { - [LED_TYPE_DIAG] = { - .name = "accton_as7712_32x_led::diag", - .default_trigger = "unused", - .brightness_set = accton_as7712_32x_led_diag_set, - .brightness_get = accton_as7712_32x_led_diag_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_RED, - }, - [LED_TYPE_LOC] = { - .name = "accton_as7712_32x_led::loc", - .default_trigger = "unused", - .brightness_set = accton_as7712_32x_led_loc_set, - .brightness_get = accton_as7712_32x_led_loc_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_BLUE, - }, - [LED_TYPE_FAN] = { - .name = "accton_as7712_32x_led::fan", - .default_trigger = "unused", - .brightness_set = accton_as7712_32x_led_auto_set, - .brightness_get = accton_as7712_32x_led_auto_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_PSU1] = { - .name = "accton_as7712_32x_led::psu1", - .default_trigger = "unused", - .brightness_set = accton_as7712_32x_led_auto_set, - .brightness_get = accton_as7712_32x_led_auto_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, - [LED_TYPE_PSU2] = { - .name = "accton_as7712_32x_led::psu2", - .default_trigger = "unused", - .brightness_set = accton_as7712_32x_led_auto_set, - .brightness_get = accton_as7712_32x_led_auto_get, - .flags = LED_CORE_SUSPENDRESUME, - .max_brightness = LED_MODE_AUTO, - }, -}; - -static int accton_as7712_32x_led_suspend(struct platform_device *dev, - pm_message_t state) -{ - int i = 0; - - for (i = 0; i < ARRAY_SIZE(accton_as7712_32x_leds); i++) { - led_classdev_suspend(&accton_as7712_32x_leds[i]); - } - - return 0; -} - -static int accton_as7712_32x_led_resume(struct platform_device *dev) -{ - int i = 0; - - for (i = 0; i < ARRAY_SIZE(accton_as7712_32x_leds); i++) { - led_classdev_resume(&accton_as7712_32x_leds[i]); - } - - return 0; -} - -static int accton_as7712_32x_led_probe(struct platform_device *pdev) -{ - int ret, i; - - for (i = 0; i < ARRAY_SIZE(accton_as7712_32x_leds); i++) { - ret = led_classdev_register(&pdev->dev, &accton_as7712_32x_leds[i]); - - if (ret < 0) - break; - } - - /* Check if all LEDs were successfully registered */ - if (i != ARRAY_SIZE(accton_as7712_32x_leds)){ - int j; - - /* only unregister the LEDs that were successfully registered */ - for (j = 0; j < i; j++) { - led_classdev_unregister(&accton_as7712_32x_leds[i]); - } - } - - return ret; -} - -static int accton_as7712_32x_led_remove(struct platform_device *pdev) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(accton_as7712_32x_leds); i++) { - led_classdev_unregister(&accton_as7712_32x_leds[i]); - } - - return 0; -} - -static struct platform_driver accton_as7712_32x_led_driver = { - .probe = accton_as7712_32x_led_probe, - .remove = accton_as7712_32x_led_remove, - .suspend = accton_as7712_32x_led_suspend, - .resume = accton_as7712_32x_led_resume, - .driver = { - .name = DRVNAME, - .owner = THIS_MODULE, - }, -}; - -static int __init accton_as7712_32x_led_init(void) -{ - int ret; - - extern int platform_accton_as7712_32x(void); - if (!platform_accton_as7712_32x()) { - return -ENODEV; - } - - ret = platform_driver_register(&accton_as7712_32x_led_driver); - if (ret < 0) { - goto exit; - } - - ledctl = kzalloc(sizeof(struct accton_as7712_32x_led_data), GFP_KERNEL); - if (!ledctl) { - ret = -ENOMEM; - platform_driver_unregister(&accton_as7712_32x_led_driver); - goto exit; - } - - mutex_init(&ledctl->update_lock); - - ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); - if (IS_ERR(ledctl->pdev)) { - ret = PTR_ERR(ledctl->pdev); - platform_driver_unregister(&accton_as7712_32x_led_driver); - kfree(ledctl); - goto exit; - } - -exit: - return ret; -} - -static void __exit accton_as7712_32x_led_exit(void) -{ - platform_device_unregister(ledctl->pdev); - platform_driver_unregister(&accton_as7712_32x_led_driver); - kfree(ledctl); -} - -module_init(accton_as7712_32x_led_init); -module_exit(accton_as7712_32x_led_exit); - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton_as7712_32x_led driver"); -MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/ym2651y.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/ym2651y.c deleted file mode 100644 index 2745b095b7e2..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/ym2651y.c +++ /dev/null @@ -1,589 +0,0 @@ -/* - * An hwmon driver for the 3Y Power YM-2651Y 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 - -#define MAX_FAN_DUTY_CYCLE 100 - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { 0x58, 0x5b, I2C_CLIENT_END }; - -/* Each client has this additional data - */ -struct ym2651y_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 capability; /* Register value */ - u16 status_word; /* Register value */ - u8 fan_fault; /* Register value */ - u8 over_temp; /* Register value */ - u16 v_out; /* Register value */ - u16 i_out; /* Register value */ - u16 p_out; /* Register value */ - u16 temp; /* Register value */ - u16 fan_speed; /* Register value */ - u16 fan_duty_cycle[2]; /* Register value */ - u8 fan_dir[4]; /* Register value */ - u8 pmbus_revision; /* Register value */ - u8 mfr_id[10]; /* Register value */ - u8 mfr_model[10]; /* Register value */ - u8 mfr_revsion[3]; /* Register value */ - u16 mfr_vin_min; /* Register value */ - u16 mfr_vin_max; /* Register value */ - u16 mfr_iin_max; /* Register value */ - u16 mfr_iout_max; /* Register value */ - u16 mfr_pin_max; /* Register value */ - u16 mfr_pout_max; /* Register value */ - u16 mfr_vout_min; /* Register value */ - u16 mfr_vout_max; /* Register value */ -}; - -static ssize_t show_byte(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t show_word(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t show_linear(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t show_fan_fault(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t show_over_temp(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t show_ascii(struct device *dev, struct device_attribute *da, - char *buf); -static struct ym2651y_data *ym2651y_update_device(struct device *dev); -static ssize_t set_fan_duty_cycle(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); -static int ym2651y_write_word(struct i2c_client *client, u8 reg, u16 value); - -enum ym2651y_sysfs_attributes { - PSU_POWER_ON = 0, - PSU_TEMP_FAULT, - PSU_POWER_GOOD, - PSU_FAN1_FAULT, - PSU_FAN_DIRECTION, - PSU_OVER_TEMP, - PSU_V_OUT, - PSU_I_OUT, - PSU_P_OUT, - PSU_TEMP1_INPUT, - PSU_FAN1_SPEED, - PSU_FAN1_DUTY_CYCLE, - PSU_PMBUS_REVISION, - PSU_MFR_ID, - PSU_MFR_MODEL, - PSU_MFR_REVISION, - PSU_MFR_VIN_MIN, - PSU_MFR_VIN_MAX, - PSU_MFR_VOUT_MIN, - PSU_MFR_VOUT_MAX, - PSU_MFR_IIN_MAX, - PSU_MFR_IOUT_MAX, - PSU_MFR_PIN_MAX, - PSU_MFR_POUT_MAX -}; - -/* sysfs attributes for hwmon - */ -static SENSOR_DEVICE_ATTR(psu_power_on, S_IRUGO, show_word, NULL, PSU_POWER_ON); -static SENSOR_DEVICE_ATTR(psu_temp_fault, S_IRUGO, show_word, NULL, PSU_TEMP_FAULT); -static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_word, NULL, PSU_POWER_GOOD); -static SENSOR_DEVICE_ATTR(psu_fan1_fault, S_IRUGO, show_fan_fault, NULL, PSU_FAN1_FAULT); -static SENSOR_DEVICE_ATTR(psu_over_temp, S_IRUGO, show_over_temp, NULL, PSU_OVER_TEMP); -static SENSOR_DEVICE_ATTR(psu_v_out, S_IRUGO, show_linear, NULL, PSU_V_OUT); -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_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); -static SENSOR_DEVICE_ATTR(psu_pmbus_revision, S_IRUGO, show_byte, NULL, PSU_PMBUS_REVISION); -static SENSOR_DEVICE_ATTR(psu_mfr_id, S_IRUGO, show_ascii, NULL, PSU_MFR_ID); -static SENSOR_DEVICE_ATTR(psu_mfr_model, S_IRUGO, show_ascii, NULL, PSU_MFR_MODEL); -static SENSOR_DEVICE_ATTR(psu_mfr_revision, S_IRUGO, show_ascii, NULL, PSU_MFR_REVISION); -static SENSOR_DEVICE_ATTR(psu_mfr_vin_min, S_IRUGO, show_linear, NULL, PSU_MFR_VIN_MIN); -static SENSOR_DEVICE_ATTR(psu_mfr_vin_max, S_IRUGO, show_linear, NULL, PSU_MFR_VIN_MAX); -static SENSOR_DEVICE_ATTR(psu_mfr_vout_min, S_IRUGO, show_linear, NULL, PSU_MFR_VOUT_MIN); -static SENSOR_DEVICE_ATTR(psu_mfr_vout_max, S_IRUGO, show_linear, NULL, PSU_MFR_VOUT_MAX); -static SENSOR_DEVICE_ATTR(psu_mfr_iin_max, S_IRUGO, show_linear, NULL, PSU_MFR_IIN_MAX); -static SENSOR_DEVICE_ATTR(psu_mfr_iout_max, S_IRUGO, show_linear, NULL, PSU_MFR_IOUT_MAX); -static SENSOR_DEVICE_ATTR(psu_mfr_pin_max, S_IRUGO, show_linear, NULL, PSU_MFR_PIN_MAX); -static SENSOR_DEVICE_ATTR(psu_mfr_pout_max, S_IRUGO, show_linear, NULL, PSU_MFR_POUT_MAX); - -static struct attribute *ym2651y_attributes[] = { - &sensor_dev_attr_psu_power_on.dev_attr.attr, - &sensor_dev_attr_psu_temp_fault.dev_attr.attr, - &sensor_dev_attr_psu_power_good.dev_attr.attr, - &sensor_dev_attr_psu_fan1_fault.dev_attr.attr, - &sensor_dev_attr_psu_over_temp.dev_attr.attr, - &sensor_dev_attr_psu_v_out.dev_attr.attr, - &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_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, - &sensor_dev_attr_psu_pmbus_revision.dev_attr.attr, - &sensor_dev_attr_psu_mfr_id.dev_attr.attr, - &sensor_dev_attr_psu_mfr_model.dev_attr.attr, - &sensor_dev_attr_psu_mfr_revision.dev_attr.attr, - &sensor_dev_attr_psu_mfr_vin_min.dev_attr.attr, - &sensor_dev_attr_psu_mfr_vin_max.dev_attr.attr, - &sensor_dev_attr_psu_mfr_pout_max.dev_attr.attr, - &sensor_dev_attr_psu_mfr_iin_max.dev_attr.attr, - &sensor_dev_attr_psu_mfr_pin_max.dev_attr.attr, - &sensor_dev_attr_psu_mfr_vout_min.dev_attr.attr, - &sensor_dev_attr_psu_mfr_vout_max.dev_attr.attr, - &sensor_dev_attr_psu_mfr_iout_max.dev_attr.attr, - NULL -}; - -static ssize_t show_byte(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct ym2651y_data *data = ym2651y_update_device(dev); - - return (attr->index == PSU_PMBUS_REVISION) ? sprintf(buf, "%d\n", data->pmbus_revision) : - sprintf(buf, "0\n"); -} - -static ssize_t show_word(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct ym2651y_data *data = ym2651y_update_device(dev); - u16 status = 0; - - switch (attr->index) { - case PSU_POWER_ON: /* psu_power_on, low byte bit 6 of status_word, 0=>ON, 1=>OFF */ - status = (data->status_word & 0x40) ? 0 : 1; - break; - case PSU_TEMP_FAULT: /* psu_temp_fault, low byte bit 2 of status_word, 0=>Normal, 1=>temp fault */ - status = (data->status_word & 0x4) >> 2; - break; - case PSU_POWER_GOOD: /* psu_power_good, high byte bit 3 of status_word, 0=>OK, 1=>FAIL */ - status = (data->status_word & 0x800) ? 0 : 1; - break; - } - - return sprintf(buf, "%d\n", status); -} - -static int two_complement_to_int(u16 data, u8 valid_bit, int mask) -{ - u16 valid_data = data & mask; - bool is_negative = valid_data >> (valid_bit - 1); - - return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data; -} - -static ssize_t set_fan_duty_cycle(struct device *dev, struct device_attribute *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 ym2651y_data *data = i2c_get_clientdata(client); - int nr = (attr->index == PSU_FAN1_DUTY_CYCLE) ? 0 : 1; - long speed; - int error; - - error = kstrtol(buf, 10, &speed); - if (error) - return error; - - if (speed < 0 || speed > MAX_FAN_DUTY_CYCLE) - return -EINVAL; - - mutex_lock(&data->update_lock); - data->fan_duty_cycle[nr] = speed; - ym2651y_write_word(client, 0x3B + nr, data->fan_duty_cycle[nr]); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t show_linear(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct ym2651y_data *data = ym2651y_update_device(dev); - - u16 value = 0; - int exponent, mantissa; - int multiplier = 1000; - - switch (attr->index) { - case PSU_V_OUT: - value = data->v_out; - break; - case PSU_I_OUT: - value = data->i_out; - break; - case PSU_P_OUT: - value = data->p_out; - break; - case PSU_TEMP1_INPUT: - value = data->temp; - break; - case PSU_FAN1_SPEED: - value = data->fan_speed; - multiplier = 1; - break; - case PSU_FAN1_DUTY_CYCLE: - value = data->fan_duty_cycle[0]; - multiplier = 1; - break; - case PSU_MFR_VIN_MIN: - value = data->mfr_vin_min; - break; - case PSU_MFR_VIN_MAX: - value = data->mfr_vin_max; - break; - case PSU_MFR_VOUT_MIN: - value = data->mfr_vout_min; - break; - case PSU_MFR_VOUT_MAX: - value = data->mfr_vout_max; - break; - case PSU_MFR_PIN_MAX: - value = data->mfr_pin_max; - break; - case PSU_MFR_POUT_MAX: - value = data->mfr_pout_max; - break; - case PSU_MFR_IOUT_MAX: - value = data->mfr_iout_max; - break; - case PSU_MFR_IIN_MAX: - value = data->mfr_iin_max; - break; - } - - exponent = two_complement_to_int(value >> 11, 5, 0x1f); - mantissa = two_complement_to_int(value & 0x7ff, 11, 0x7ff); - - return (exponent >= 0) ? sprintf(buf, "%d\n", (mantissa << exponent) * multiplier) : - sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent)); -} - -static ssize_t show_fan_fault(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct ym2651y_data *data = ym2651y_update_device(dev); - - u8 shift = (attr->index == PSU_FAN1_FAULT) ? 7 : 6; - - return sprintf(buf, "%d\n", data->fan_fault >> shift); -} - -static ssize_t show_over_temp(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct ym2651y_data *data = ym2651y_update_device(dev); - - return sprintf(buf, "%d\n", data->over_temp >> 7); -} - -static ssize_t show_ascii(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct ym2651y_data *data = ym2651y_update_device(dev); - u8 *ptr = NULL; - - switch (attr->index) { - case PSU_FAN_DIRECTION: /* psu_fan_dir */ - ptr = data->fan_dir; - break; - case PSU_MFR_ID: /* psu_mfr_id */ - ptr = data->mfr_id; - break; - case PSU_MFR_MODEL: /* psu_mfr_model */ - ptr = data->mfr_model; - break; - case PSU_MFR_REVISION: /* psu_mfr_revision */ - ptr = data->mfr_revsion; - break; - default: - return 0; - } - - return sprintf(buf, "%s\n", ptr); -} - -static const struct attribute_group ym2651y_group = { - .attrs = ym2651y_attributes, -}; - -static int ym2651y_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct ym2651y_data *data; - int status; - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA | - I2C_FUNC_SMBUS_WORD_DATA | - I2C_FUNC_SMBUS_I2C_BLOCK)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct ym2651y_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &ym2651y_group); - if (status) { - goto exit_free; - } - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - dev_info(&client->dev, "%s: psu '%s'\n", - dev_name(data->hwmon_dev), client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &ym2651y_group); -exit_free: - kfree(data); -exit: - - return status; -} - -static int ym2651y_remove(struct i2c_client *client) -{ - struct ym2651y_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &ym2651y_group); - kfree(data); - - return 0; -} - -static const struct i2c_device_id ym2651y_id[] = { - { "ym2651", 0 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, ym2651y_id); - -static struct i2c_driver ym2651y_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "ym2651", - }, - .probe = ym2651y_probe, - .remove = ym2651y_remove, - .id_table = ym2651y_id, - .address_list = normal_i2c, -}; - -static int ym2651y_read_byte(struct i2c_client *client, u8 reg) -{ - return i2c_smbus_read_byte_data(client, reg); -} - -static int ym2651y_read_word(struct i2c_client *client, u8 reg) -{ - return i2c_smbus_read_word_data(client, reg); -} - -static int ym2651y_write_word(struct i2c_client *client, u8 reg, u16 value) -{ - return i2c_smbus_write_word_data(client, reg, value); -} - -static int ym2651y_read_block(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ - int result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - - if (unlikely(result < 0)) - goto abort; - if (unlikely(result != data_len)) { - result = -EIO; - goto abort; - } - - result = 0; - -abort: - return result; -} - -struct reg_data_byte { - u8 reg; - u8 *value; -}; - -struct reg_data_word { - u8 reg; - u16 *value; -}; - -static struct ym2651y_data *ym2651y_update_device(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct ym2651y_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->last_updated + HZ + HZ / 2) - || !data->valid) { - int i, status; - u8 command; - u8 fan_dir[5] = {0}; - struct reg_data_byte regs_byte[] = { {0x19, &data->capability}, - {0x7d, &data->over_temp}, - {0x81, &data->fan_fault}, - {0x98, &data->pmbus_revision}}; - struct reg_data_word regs_word[] = { {0x79, &data->status_word}, - {0x8b, &data->v_out}, - {0x8c, &data->i_out}, - {0x96, &data->p_out}, - {0x8d, &data->temp}, - {0x3b, &(data->fan_duty_cycle[0])}, - {0x3c, &(data->fan_duty_cycle[1])}, - {0x90, &data->fan_speed}, - {0xa0, &data->mfr_vin_min}, - {0xa1, &data->mfr_vin_max}, - {0xa2, &data->mfr_iin_max}, - {0xa3, &data->mfr_pin_max}, - {0xa4, &data->mfr_vout_min}, - {0xa5, &data->mfr_vout_max}, - {0xa6, &data->mfr_iout_max}, - {0xa7, &data->mfr_pout_max}}; - - dev_dbg(&client->dev, "Starting ym2651 update\n"); - - /* Read byte data */ - for (i = 0; i < ARRAY_SIZE(regs_byte); i++) { - status = ym2651y_read_byte(client, regs_byte[i].reg); - - if (status < 0) - { - dev_dbg(&client->dev, "reg %d, err %d\n", - regs_byte[i].reg, status); - } - else { - *(regs_byte[i].value) = status; - } - } - - /* Read word data */ - for (i = 0; i < ARRAY_SIZE(regs_word); i++) { - status = ym2651y_read_word(client, regs_word[i].reg); - - if (status < 0) - { - dev_dbg(&client->dev, "reg %d, err %d\n", - regs_word[i].reg, status); - } - else { - *(regs_word[i].value) = status; - } - } - - /* Read fan_direction */ - command = 0xC3; - status = ym2651y_read_block(client, command, fan_dir, ARRAY_SIZE(fan_dir)-1); - - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", command, status); - } - - strncpy(data->fan_dir, fan_dir+1, ARRAY_SIZE(data->fan_dir)-1); - data->fan_dir[ARRAY_SIZE(data->fan_dir)-1] = '\0'; - - /* Read mfr_id */ - command = 0x99; - status = ym2651y_read_block(client, command, data->mfr_id, - ARRAY_SIZE(data->mfr_id)-1); - data->mfr_id[ARRAY_SIZE(data->mfr_id)-1] = '\0'; - - if (status < 0) - dev_dbg(&client->dev, "reg %d, err %d\n", command, status); - - /* Read mfr_model */ - command = 0x9a; - status = ym2651y_read_block(client, command, data->mfr_model, - ARRAY_SIZE(data->mfr_model)-1); - data->mfr_model[ARRAY_SIZE(data->mfr_model)-1] = '\0'; - - if (status < 0) - dev_dbg(&client->dev, "reg %d, err %d\n", command, status); - - /* Read mfr_revsion */ - command = 0x9b; - status = ym2651y_read_block(client, command, data->mfr_revsion, - ARRAY_SIZE(data->mfr_revsion)-1); - data->mfr_revsion[ARRAY_SIZE(data->mfr_revsion)-1] = '\0'; - - if (status < 0) - dev_dbg(&client->dev, "reg %d, err %d\n", command, status); - - data->last_updated = jiffies; - data->valid = 1; - } - - mutex_unlock(&data->update_lock); - - return data; -} - -module_i2c_driver(ym2651y_driver); - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("3Y Power YM-2651Y driver"); -MODULE_LICENSE("GPL"); - - diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/scripts/as7712_32x_platform_init.sh b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/scripts/as7712_32x_platform_init.sh deleted file mode 100644 index 448f2ec341a4..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/scripts/as7712_32x_platform_init.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -echo "TO-DO: as7712-32x driver setting" diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/changelog b/platform/broadcom/sonic-platform-modules-accton/debian/changelog deleted file mode 100644 index 6a687800eeac..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -sonic-accton-platform-modules (1.0) unstable; urgency=low - - * Initial release - - -- Polly Hsu Tue, 9 May 2017 17:54:11 -0800 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/compat b/platform/broadcom/sonic-platform-modules-accton/debian/compat deleted file mode 100644 index ec635144f600..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/control b/platform/broadcom/sonic-platform-modules-accton/debian/control deleted file mode 100644 index 755c58612bb0..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/debian/control +++ /dev/null @@ -1,11 +0,0 @@ -Source: sonic-accton-platform-modules -Section: main -Priority: extra -Maintainer: polly_hsu -Build-Depends: debhelper (>= 8.0.0), bzip2 -Standards-Version: 3.9.3 - -Package: platform-modules-as7712-32x -Architecture: amd64 -Depends: linux-image-3.16.0-4-amd64 -Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.init b/platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.init deleted file mode 100644 index c54b2a3e310d..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.init +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -### BEGIN INIT INFO -# Provides: setup-board -# Required-Start: -# Required-Stop: -# Should-Start: -# Should-Stop: -# Default-Start: S -# Default-Stop: 0 6 -# Short-Description: Setup AS7712-32X board. -### END INIT INFO - -case "$1" in -start) - echo -n "Setting up board... " - - modprobe i2c_dev - modprobe i2c_mux_pca954x - modprobe accton_i2c_cpld - modprobe accton_as7712_32x_fan - modprobe accton_as7712_32x_sfp - modprobe leds-accton_as7712_32x - modprobe accton_as7712_32x_psu - - echo "done." - ;; - -stop) - echo "done." - - ;; - -force-reload|restart) - echo "Not supported" - ;; - -*) - echo "Usage: /etc/init.d/platform-modules-as7712-32x.init {start|stop}" - exit 1 - ;; -esac - -exit 0 diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.install b/platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.install deleted file mode 100644 index 39abf57e2f65..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/debian/platform-modules-as7712-32x.install +++ /dev/null @@ -1,2 +0,0 @@ -as7712-32x/scripts/as7712_32x_platform_init.sh usr/local/bin -as7712-32x/cfg/as7712_32x-modules.conf etc/modules-load.d diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/rules b/platform/broadcom/sonic-platform-modules-accton/debian/rules deleted file mode 100755 index a1026ca62832..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/debian/rules +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/make -f - -export INSTALL_MOD_DIR:=extra - -KVERSION ?= $(shell uname -r) -KERNEL_SRC := /lib/modules/$(KVERSION) -MOD_SRC_DIR:= $(shell pwd) -MODULE_DIRS:= as7712-32x - -%: - dh $@ - -override_dh_auto_build: - (for mod in $(MODULE_DIRS); do \ - make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ - done) - - - -override_dh_auto_install: - (for mod in $(MODULE_DIRS); do \ - dh_installdirs -pplatform-modules-$${mod} \ - $(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ - cp $(MOD_SRC_DIR)/$${mod}/modules/*.ko \ - debian/platform-modules-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ - mkdir -p debian/platform-modules-$${mod}/etc/bcm; \ - done) - -override_dh_usrlocal: - -override_dh_clean: - dh_clean - (for mod in $(MODULE_DIRS); do \ - make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \ - done) - From dd104e1b5216f5332ffcb7c40c160be7695e3ce4 Mon Sep 17 00:00:00 2001 From: lguohan Date: Tue, 20 Jun 2017 22:45:36 -0700 Subject: [PATCH 18/45] [submodule]: update sonic-platform-daemons submodule (#731) --- src/sonic-platform-daemons | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-platform-daemons b/src/sonic-platform-daemons index dac4bf5a242f..d68c286ba7c9 160000 --- a/src/sonic-platform-daemons +++ b/src/sonic-platform-daemons @@ -1 +1 @@ -Subproject commit dac4bf5a242fe3c10d750378b7aaf6d41ac573ee +Subproject commit d68c286ba7c984c98ebfafc2bb5fe24905659e5f From 95906a64903ed8b02f9a021287dce443125bd2e4 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Wed, 21 Jun 2017 11:02:25 -0700 Subject: [PATCH 19/45] [installer] Copy old config files rather than only minigraph (#730) --- .../base_image_files/bgp_neighbor | 55 ------------------- files/image_config/platform/rc.local | 7 ++- rules/docker-fpm-quagga.mk | 1 - src/sonic-utilities | 2 +- 4 files changed, 6 insertions(+), 59 deletions(-) delete mode 100755 dockers/docker-fpm-quagga/base_image_files/bgp_neighbor diff --git a/dockers/docker-fpm-quagga/base_image_files/bgp_neighbor b/dockers/docker-fpm-quagga/base_image_files/bgp_neighbor deleted file mode 100755 index d6bd67a0a02d..000000000000 --- a/dockers/docker-fpm-quagga/base_image_files/bgp_neighbor +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -e - -usage(){ - echo "Usage: $0 " - exit 255 -} - -[[ $# -ne 2 ]] && usage - -COMMAND=$1 -NEIGHBOR_IP=$2 - -if [ "$COMMAND" == "shutdown" ]; then - CMD_PREFIX="" -elif [ "$COMMAND" == "startup" ]; then - CMD_PREFIX="no" -else - usage -fi - -ASN=`vtysh -c "show ip bgp summary" | sed -n "s/.*AS number \([0-9]\+\).*/\1/p"` -if [ -z "$ASN" ]; then - exit 255 -fi - -[ -f /etc/sonic/bgp_admin.yml ] || echo "bgp_admin_state:" > /etc/sonic/bgp_admin.yml - -# Operate on all ipv4 neighbors when "neighbor_ip" = 0.0.0.0 -if [ "$NEIGHBOR_IP" == "0.0.0.0" ] ; then - for NEIGHBOR in `vtysh -c "show run" | grep nei | grep -oE "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | sort | uniq`; do - vtysh -c "configure terminal" -c "router bgp $ASN" -c "$CMD_PREFIX neighbor $NEIGHBOR shutdown" - - # Save admin state in config file - sed -i "/^\s*$NEIGHBOR:/d" /etc/sonic/bgp_admin.yml - if [ "$COMMAND" == "startup" ]; then - echo " $NEIGHBOR: on" >> /etc/sonic/bgp_admin.yml - else - echo " $NEIGHBOR: off" >> /etc/sonic/bgp_admin.yml - fi - done - -else - # Examine bgp neighbor exists first - vtysh -c "show ip bgp neighbor $NEIGHBOR_IP" | grep -q "BGP neighbor is" - - vtysh -c "configure terminal" -c "router bgp $ASN" -c "$CMD_PREFIX neighbor $NEIGHBOR_IP shutdown" - - # Save admin state in config file - sed -i "/^\s*$NEIGHBOR_IP:/d" /etc/sonic/bgp_admin.yml - if [ "$COMMAND" == "startup" ]; then - echo " $NEIGHBOR_IP: on" >> /etc/sonic/bgp_admin.yml - else - echo " $NEIGHBOR_IP: off" >> /etc/sonic/bgp_admin.yml - fi -fi diff --git a/files/image_config/platform/rc.local b/files/image_config/platform/rc.local index 26f59bf94aad..dad2510ce756 100755 --- a/files/image_config/platform/rc.local +++ b/files/image_config/platform/rc.local @@ -29,8 +29,11 @@ if [ -f /host/image-$sonic_version/platform/firsttime ]; then exit 0 fi - # Try to take minigraph saved during installation - if [ -f /host/minigraph.xml ]; then + # Try to take old configuration saved during installation + if [ -d /host/old_config ]; then + rm -f /host/old_config/sonic_version.yml + mv -f /host/old_config/* /etc/sonic/ + elif [ -f /host/minigraph.xml ]; then mv /host/minigraph.xml /etc/sonic/ else cp /usr/share/sonic/device/$platform/minigraph.xml /etc/sonic/ diff --git a/rules/docker-fpm-quagga.mk b/rules/docker-fpm-quagga.mk index 1e95c96e001b..a9c0511ba173 100644 --- a/rules/docker-fpm-quagga.mk +++ b/rules/docker-fpm-quagga.mk @@ -11,4 +11,3 @@ $(DOCKER_FPM_QUAGGA)_RUN_OPT += --net=host --privileged -t $(DOCKER_FPM_QUAGGA)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro $(DOCKER_FPM_QUAGGA)_BASE_IMAGE_FILES += vtysh:/usr/bin/vtysh -$(DOCKER_FPM_QUAGGA)_BASE_IMAGE_FILES += bgp_neighbor:/usr/bin/bgp_neighbor diff --git a/src/sonic-utilities b/src/sonic-utilities index c1b48a6a28f9..0ad528043019 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit c1b48a6a28f9897ebfebf9989b5cb4a472cf1967 +Subproject commit 0ad52804301903664dfe8f84ef1666101c950cd2 From 3268946de53a56ef68dfb07eacca5b8e5543e6bb Mon Sep 17 00:00:00 2001 From: sihuihan88 Date: Wed, 21 Jun 2017 18:52:50 -0700 Subject: [PATCH 20/45] [BGPD]: add bgp dynamic neighbor configuration (#708) * add bgp dynamic neighbor configuration * [bgpd]: update as comments * update as comment * update to deployment_id_asn_map * minor change --- dockers/docker-fpm-quagga/bgpd.conf.j2 | 17 + dockers/docker-fpm-quagga/start.sh | 4 +- .../build_templates/sonic_debian_extension.j2 | 3 + .../asn/deployment_id_asn_map.yml | 2 + src/sonic-config-engine/minigraph.py | 26 +- .../tests/t0-sample-bgp-speaker.xml | 346 ++++++++++++++++++ src/sonic-config-engine/tests/test_cfggen.py | 11 + 7 files changed, 403 insertions(+), 6 deletions(-) create mode 100644 files/image_config/asn/deployment_id_asn_map.yml create mode 100644 src/sonic-config-engine/tests/t0-sample-bgp-speaker.xml diff --git a/dockers/docker-fpm-quagga/bgpd.conf.j2 b/dockers/docker-fpm-quagga/bgpd.conf.j2 index 0c848939df9d..e898ce72ae1f 100644 --- a/dockers/docker-fpm-quagga/bgpd.conf.j2 +++ b/dockers/docker-fpm-quagga/bgpd.conf.j2 @@ -19,6 +19,10 @@ log facility local4 ! ! bgp multiple-instance ! +route-map FROM_BGP_SPEAKER_V4 permit 10 +! +route-map TO_BGP_SPEAKER_V4 deny 10 +! router bgp {{ minigraph_bgp_asn }} bgp log-neighbor-changes bgp bestpath as-path multipath-relax @@ -65,6 +69,19 @@ router bgp {{ minigraph_bgp_asn }} {% endif %} {% endfor %} {% endblock bgp_sessions %} +{% block bgp_peers_with_range %} +{% for bgp_peer in minigraph_bgp_peers_with_range %} + neighbor {{ bgp_peer['name'] }} peer-group + neighbor {{ bgp_peer['name'] }} passive + neighbor {{ bgp_peer['name'] }} remote-as {{deployment_id_asn_map[deployment_id] }} + neighbor {{ bgp_peer['name'] }} ebgp-multihop 255 + neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound + neighbor {{ bgp_peer['name'] }} update-source Loopback0 + neighbor {{ bgp_peer['name'] }} route-map FROM_BGP_SPEAKER_V4 in + neighbor {{ bgp_peer['name'] }} route-map TO_BGP_SPEAKER_V4 out + bgp listen range {{ bgp_peer['ip_range'] }} peer-group {{ bgp_peer['name'] }} +{% endfor %} +{% endblock bgp_peers_with_range %} ! {% if minigraph_bgp_asn is not none %} maximum-paths 64 diff --git a/dockers/docker-fpm-quagga/start.sh b/dockers/docker-fpm-quagga/start.sh index bc3fbf4e907a..c7df6f20999d 100755 --- a/dockers/docker-fpm-quagga/start.sh +++ b/dockers/docker-fpm-quagga/start.sh @@ -2,9 +2,9 @@ mkdir -p /etc/quagga if [ -f /etc/sonic/bgp_admin.yml ]; then - sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/bgp_admin.yml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/quagga/bgpd.conf + sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/bgp_admin.yml -y /etc/sonic/deployment_id_asn_map.yml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/quagga/bgpd.conf else - sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/quagga/bgpd.conf + sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/deployment_id_asn_map.yml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/quagga/bgpd.conf fi sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/zebra.conf.j2 > /etc/quagga/zebra.conf diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 00398654b12c..647a73b5ce1c 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -138,6 +138,9 @@ sudo bash -c "echo ' all: off' >> $FILESYSTEM_ROOT/etc/sonic/bgp_admin.yml" # Copy SNMP configuration files sudo cp $IMAGE_CONFIGS/snmp/snmp.yml $FILESYSTEM_ROOT/etc/sonic/ +# Copy ASN configuration files +sudo cp $IMAGE_CONFIGS/asn/deployment_id_asn_map.yml $FILESYSTEM_ROOT/etc/sonic/ + # Copy sudoers configuration file sudo cp $IMAGE_CONFIGS/sudoers/sudoers $FILESYSTEM_ROOT/etc/ diff --git a/files/image_config/asn/deployment_id_asn_map.yml b/files/image_config/asn/deployment_id_asn_map.yml new file mode 100644 index 000000000000..36168f828954 --- /dev/null +++ b/files/image_config/asn/deployment_id_asn_map.yml @@ -0,0 +1,2 @@ +deployment_id_asn_map: + "1" : 65432 diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 7dc060900886..d552eb906364 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -244,6 +244,7 @@ def parse_dpg(dpg, hname): def parse_cpg(cpg, hname): bgp_sessions = [] myasn = None + bgp_peers_with_range = [] for child in cpg: tag = child.tag if tag == str(QName(ns, "PeeringSessions")): @@ -270,12 +271,22 @@ def parse_cpg(cpg, hname): hostname = router.find(str(QName(ns1, "Hostname"))).text if hostname == hname: myasn = int(asn) + peers = router.find(str(QName(ns1, "Peers"))) + for bgpPeer in peers.findall(str(QName(ns, "BGPPeer"))): + addr = bgpPeer.find(str(QName(ns, "Address"))).text + if bgpPeer.find(str(QName(ns1, "PeersRange"))) is not None: + name = bgpPeer.find(str(QName(ns1, "Name"))).text + ip_range = bgpPeer.find(str(QName(ns1, "PeersRange"))).text + bgp_peers_with_range.append({ + 'name': name, + 'ip_range': ip_range + }) else: for bgp_session in bgp_sessions: if hostname == bgp_session['name']: bgp_session['asn'] = int(asn) - return bgp_sessions, myasn + return bgp_sessions, myasn, bgp_peers_with_range def parse_meta(meta, hname): @@ -284,6 +295,7 @@ def parse_meta(meta, hname): ntp_servers = [] mgmt_routes = [] erspan_dst = [] + deployment_id = None device_metas = meta.find(str(QName(ns, "Devices"))) for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))): if device.find(str(QName(ns1, "Name"))).text == hname: @@ -302,7 +314,9 @@ def parse_meta(meta, hname): mgmt_routes = value_group elif name == "ErspanDestinationIpv4": erspan_dst = value_group - return syslog_servers, dhcp_servers, ntp_servers, mgmt_routes, erspan_dst + elif name == "DeploymentId": + deployment_id = value + return syslog_servers, dhcp_servers, ntp_servers, mgmt_routes, erspan_dst, deployment_id def get_console_info(devices, dev, port): @@ -396,6 +410,8 @@ def parse_xml(filename, platform=None, port_config_file=None): ntp_servers = [] mgmt_routes = [] erspan_dst = [] + bgp_peers_with_range = None + deployment_id = None hwsku_qn = QName(ns, "HwSku") hostname_qn = QName(ns, "Hostname") @@ -411,13 +427,13 @@ def parse_xml(filename, platform=None, port_config_file=None): if child.tag == str(QName(ns, "DpgDec")): (intfs, lo_intfs, mgmt_intf, vlans, pcs, acls) = parse_dpg(child, hostname) elif child.tag == str(QName(ns, "CpgDec")): - (bgp_sessions, bgp_asn) = parse_cpg(child, hostname) + (bgp_sessions, bgp_asn, bgp_peers_with_range) = parse_cpg(child, hostname) elif child.tag == str(QName(ns, "PngDec")): (neighbors, devices, console_dev, console_port, mgmt_dev, mgmt_port) = parse_png(child, hostname) elif child.tag == str(QName(ns, "UngDec")): (u_neighbors, u_devices, _, _, _, _) = parse_png(child, hostname) elif child.tag == str(QName(ns, "MetadataDeclaration")): - (syslog_servers, dhcp_servers, ntp_servers, mgmt_routes, erspan_dst) = parse_meta(child, hostname) + (syslog_servers, dhcp_servers, ntp_servers, mgmt_routes, erspan_dst, deployment_id) = parse_meta(child, hostname) Tree = lambda: defaultdict(Tree) @@ -428,6 +444,7 @@ def parse_xml(filename, platform=None, port_config_file=None): # TODO: alternatively (preferred), implement class containers for multiple-attribute entries, enabling sort by attr results['minigraph_bgp'] = sorted(bgp_sessions, key=lambda x: x['addr']) results['minigraph_bgp_asn'] = bgp_asn + results['minigraph_bgp_peers_with_range'] = bgp_peers_with_range # TODO: sort does not work properly on all interfaces of varying lengths. Need to sort by integer group(s). phyport_intfs = [] @@ -466,6 +483,7 @@ def parse_xml(filename, platform=None, port_config_file=None): results['ntp_servers'] = ntp_servers results['forced_mgmt_routes'] = mgmt_routes results['erspan_dst'] = erspan_dst + results['deployment_id'] = deployment_id return results diff --git a/src/sonic-config-engine/tests/t0-sample-bgp-speaker.xml b/src/sonic-config-engine/tests/t0-sample-bgp-speaker.xml new file mode 100644 index 000000000000..b5e373ddd868 --- /dev/null +++ b/src/sonic-config-engine/tests/t0-sample-bgp-speaker.xml @@ -0,0 +1,346 @@ + + + + + + false + switch-t0 + 10.0.0.56 + ARISTA01T1 + 10.0.0.57 + 1 + 180 + 60 + + + switch-t0 + FC00::71 + ARISTA01T1 + FC00::72 + 1 + 180 + 60 + + + false + switch-t0 + 10.0.0.58 + ARISTA02T1 + 10.0.0.59 + 1 + 180 + 60 + + + switch-t0 + FC00::75 + ARISTA02T1 + FC00::76 + 1 + 180 + 60 + + + false + switch-t0 + 10.0.0.60 + ARISTA03T1 + 10.0.0.61 + 1 + 180 + 60 + + + switch-t0 + FC00::79 + ARISTA03T1 + FC00::7A + 1 + 180 + 60 + + + false + switch-t0 + 10.0.0.62 + ARISTA04T1 + 10.0.0.63 + 1 + 180 + 60 + + + switch-t0 + FC00::7D + ARISTA04T1 + FC00::7E + 1 + 180 + 60 + + + + + 65100 + switch-t0 + + +
10.0.0.57
+ + + +
+ +
10.0.0.59
+ + + +
+ +
10.0.0.61
+ + + +
+ +
10.0.0.63
+ + + +
+ +
10.1.0.32
+ BGPSLBPassive + 10.10.10.10/26 +
+
+ +
+ + 64600 + ARISTA01T1 + + + + 64600 + ARISTA02T1 + + + + 64600 + ARISTA03T1 + + + + 64600 + ARISTA04T1 + + +
+
+ + + + + + HostIP + Loopback0 + + 10.1.0.32/32 + + 10.1.0.32/32 + + + HostIP1 + Loopback0 + + FC00:1::32/128 + + FC00:1::32/128 + + + + + HostIP + eth0 + + 10.0.0.100/24 + + 10.0.0.100/24 + + + + + + + switch-t0 + + + PortChannel01 + fortyGigE0/112 + + + + PortChannel02 + fortyGigE0/116 + + + + PortChannel03 + fortyGigE0/120 + + + + PortChannel04 + fortyGigE0/124 + + + + + + Vlan1000 + fortyGigE0/4;fortyGigE0/8;fortyGigE0/12;fortyGigE0/16;fortyGigE0/20;fortyGigE0/24;fortyGigE0/28;fortyGigE0/32;fortyGigE0/36;fortyGigE0/40;fortyGigE0/44;fortyGigE0/48;fortyGigE0/52;fortyGigE0/56;fortyGigE0/60;fortyGigE0/64;fortyGigE0/68;fortyGigE0/72;fortyGigE0/76;fortyGigE0/80;fortyGigE0/84;fortyGigE0/88;fortyGigE0/92;fortyGigE0/96 + False + 0.0.0.0/0 + + 1000 + 1000 + 192.168.0.0/27 + + + + + + PortChannel01 + 10.0.0.56/31 + + + + PortChannel01 + FC00::71/126 + + + + PortChannel02 + 10.0.0.58/31 + + + + PortChannel02 + FC00::75/126 + + + + PortChannel03 + 10.0.0.60/31 + + + + PortChannel03 + FC00::79/126 + + + + PortChannel04 + 10.0.0.62/31 + + + + PortChannel04 + FC00::7D/126 + + + + Vlan1000 + 192.168.0.1/27 + + + + + + + PortChannel01;PortChannel02;PortChannel03;PortChannel04 + + DataAcl + + + + + + + + + + DeviceInterfaceLink + ARISTA01T1 + Ethernet1/1 + switch-t0 + fortyGigE0/112 + + + DeviceInterfaceLink + ARISTA02T1 + Ethernet1/1 + switch-t0 + fortyGigE0/116 + + + DeviceInterfaceLink + ARISTA03T1 + Ethernet1/1 + switch-t0 + fortyGigE0/120 + + + DeviceInterfaceLink + ARISTA04T1 + Ethernet1/1 + switch-t0 + fortyGigE0/124 + + + + + switch-t0 + Force10-S6000 + + + ARISTA01T1 + Arista + + + ARISTA02T1 + Arista + + + ARISTA03T1 + Arista + + + ARISTA04T1 + Arista + + + + + + + switch-t0 + + + ErspanDestinationIpv4 + + 2.2.2.2 + + + DeploymentId + 1 + + + + + + + switch-t0 + Force10-S6000 +
diff --git a/src/sonic-config-engine/tests/test_cfggen.py b/src/sonic-config-engine/tests/test_cfggen.py index a4ad6cb806fc..9a305fd72aac 100644 --- a/src/sonic-config-engine/tests/test_cfggen.py +++ b/src/sonic-config-engine/tests/test_cfggen.py @@ -11,6 +11,7 @@ def setUp(self): self.sample_graph_t0 = os.path.join(self.test_dir, 't0-sample-graph.xml') self.sample_graph_simple = os.path.join(self.test_dir, 'simple-sample-graph.xml') self.sample_graph_pc_test = os.path.join(self.test_dir, 'pc-test-graph.xml') + self.sample_graph_bgp_speaker = os.path.join(self.test_dir, 't0-sample-bgp-speaker.xml') self.port_config = os.path.join(self.test_dir, 't0-sample-port-config.ini') def run_script(self, argument): @@ -97,3 +98,13 @@ def test_minigraph_neighbors(self): argument = '-m "' + self.sample_graph_t0 + '" -p "' + self.port_config + '" -v minigraph_neighbors' output = self.run_script(argument) self.assertEqual(output.strip(), "{'Ethernet116': {'name': 'ARISTA02T1', 'port': 'Ethernet1/1'}, 'Ethernet124': {'name': 'ARISTA04T1', 'port': 'Ethernet1/1'}, 'Ethernet112': {'name': 'ARISTA01T1', 'port': 'Ethernet1/1'}, 'Ethernet120': {'name': 'ARISTA03T1', 'port': 'Ethernet1/1'}}") + + def test_minigraph_peers_with_range(self): + argument = '-m "' + self.sample_graph_bgp_speaker + '" -p "' + self.port_config + '" -v minigraph_bgp_peers_with_range' + output = self.run_script(argument) + self.assertEqual(output.strip(), "[{'name': 'BGPSLBPassive', 'ip_range': '10.10.10.10/26'}]") + + def test_minigraph_deployment_id(self): + argument = '-m "' + self.sample_graph_bgp_speaker + '" -p "' + self.port_config + '" -v deployment_id' + output = self.run_script(argument) + self.assertEqual(output.strip(), "1") From 629362cad7b080fe738a4aafab6852a58e50160d Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Wed, 21 Jun 2017 18:53:28 -0700 Subject: [PATCH 21/45] [docker-syncd-brcm]: Sleep to allow syncd to create socket before calling bcmcmd (#733) * [docker-syncd-brcm]: Sleep to allow syncd to create socket before calling bcmcmd * Instead of fixed sleep interval, continually check for presence of socket --- platform/broadcom/docker-syncd-brcm/start.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/platform/broadcom/docker-syncd-brcm/start.sh b/platform/broadcom/docker-syncd-brcm/start.sh index 6f9b69ff8d40..742cf8223132 100755 --- a/platform/broadcom/docker-syncd-brcm/start.sh +++ b/platform/broadcom/docker-syncd-brcm/start.sh @@ -10,6 +10,14 @@ supervisorctl start syncd # If this platform has an initialization file for the Broadcom LED microprocessor, load it if [ -r ${PLATFORM_DIR}/led_proc_init.soc ]; then + # Wait until syncd has created the socket for bcmcmd to connect to + while true; do + if [ -e /var/run/sswsyncd/sswsyncd.socket ]; then + break + fi + sleep 1 + done + /usr/bin/bcmcmd -t 60 "rcload ${PLATFORM_DIR}/led_proc_init.soc" fi From a8e3d9745f31ea795e1b88e690364608e5462dd8 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Wed, 21 Jun 2017 23:49:15 -0700 Subject: [PATCH 22/45] [sonic-cfggen]: Support multiple input yaml files with -y option (#729) --- src/sonic-config-engine/sonic-cfggen | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sonic-config-engine/sonic-cfggen b/src/sonic-config-engine/sonic-cfggen index 822f02d7fcc2..c0ce51d4bf80 100755 --- a/src/sonic-config-engine/sonic-cfggen +++ b/src/sonic-config-engine/sonic-cfggen @@ -49,7 +49,7 @@ def main(): parser=argparse.ArgumentParser(description="Render configuration file from minigraph data and jinja2 template.") parser.add_argument("-m", "--minigraph", help="minigraph xml file") parser.add_argument("-p", "--port-config", help="port config file, used with -m") - parser.add_argument("-y", "--yaml", help="yaml file that contains addtional variables") + parser.add_argument("-y", "--yaml", help="yaml file that contains addtional variables", action='append', default=[]) parser.add_argument("-a", "--additional-data", help="addition data, in json string") group = parser.add_mutually_exclusive_group() group.add_argument("-t", "--template", help="render the data with the template file") @@ -79,8 +79,8 @@ def main(): else: data.update(parse_xml(minigraph)) - if args.yaml != None: - with open(args.yaml, 'r') as stream: + for yaml_file in args.yaml: + with open(yaml_file, 'r') as stream: additional_data = yaml.load(stream) data.update(additional_data) From 5c852704fea4e51f3bcc95999a23f9eb3d0b21cf Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Thu, 22 Jun 2017 14:34:15 -0700 Subject: [PATCH 23/45] [sonic-cfggen]: Fix minigraph.py when port_alias_map absent (#738) --- src/sonic-config-engine/minigraph.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index d552eb906364..8d3e82ea1233 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -127,10 +127,7 @@ def parse_dpg(dpg, hname): intfs = [] for ipintf in ipintfs.findall(str(QName(ns, "IPInterface"))): intfalias = ipintf.find(str(QName(ns, "AttachTo"))).text - if port_alias_map.has_key(intfalias): - intfname = port_alias_map[intfalias] - else: - intfname = intfalias + intfname = port_alias_map.get(intfalias, intfalias) ipprefix = ipintf.find(str(QName(ns, "Prefix"))).text ipn = ipaddress.IPNetwork(ipprefix) ipaddr = ipn.ip @@ -198,7 +195,7 @@ def parse_dpg(dpg, hname): pcintfmbr = pcintf.find(str(QName(ns, "AttachTo"))).text pcmbr_list = pcintfmbr.split(';') for i, member in enumerate(pcmbr_list): - pcmbr_list[i] = port_alias_map[member] + pcmbr_list[i] = port_alias_map.get(member, member) pcs[pcintfname] = {'name': pcintfname, 'members': pcmbr_list} vlanintfs = child.find(str(QName(ns, "VlanInterfaces"))) @@ -210,7 +207,7 @@ def parse_dpg(dpg, hname): vintfmbr = vintf.find(str(QName(ns, "AttachTo"))).text vmbr_list = vintfmbr.split(';') for i, member in enumerate(vmbr_list): - vmbr_list[i] = port_alias_map[member] + vmbr_list[i] = port_alias_map.get(member, member) vlan_attributes = {'name': vintfname, 'members': vmbr_list, 'vlanid': vlanid} sonic_vlan_name = "Vlan%s" % vlanid vlans[sonic_vlan_name] = vlan_attributes From 4bdcac8e4f12d92f3c70f45ee8e0ed6f4599ad93 Mon Sep 17 00:00:00 2001 From: lguohan Date: Thu, 22 Jun 2017 19:50:24 -0700 Subject: [PATCH 24/45] [bgp]: move allowas-in into ipv6 section to enable allowas-in for ipv6 (#741) --- dockers/docker-fpm-quagga/bgpd.conf.j2 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dockers/docker-fpm-quagga/bgpd.conf.j2 b/dockers/docker-fpm-quagga/bgpd.conf.j2 index e898ce72ae1f..5f53d9698b2e 100644 --- a/dockers/docker-fpm-quagga/bgpd.conf.j2 +++ b/dockers/docker-fpm-quagga/bgpd.conf.j2 @@ -57,11 +57,16 @@ router bgp {{ minigraph_bgp_asn }} {% if bgp_admin_state and bgp_admin_state.has_key(bgp_session['addr']) and bgp_admin_state[bgp_session['addr']]==False or bgp_admin_state and not bgp_admin_state.has_key(bgp_session['addr']) and bgp_admin_state.has_key('all') and bgp_admin_state['all']==False %} neighbor {{ bgp_session['addr'] }} shutdown {% endif %} +{% if bgp_session['addr'] | ipv4 %} {% if minigraph_devices[inventory_hostname]['type'] == 'ToRRouter' %} neighbor {{ bgp_session['addr'] }} allowas-in 1 {% endif %} +{% endif %} {% if bgp_session['addr'] | ipv6 %} address-family ipv6 +{% if minigraph_devices[inventory_hostname]['type'] == 'ToRRouter' %} + neighbor {{ bgp_session['addr'] }} allowas-in 1 +{% endif %} neighbor {{ bgp_session['addr'] }} activate maximum-paths 64 exit-address-family From d1b12dc0ca13728c279e0db4a2ba0cb92fbdfde0 Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Thu, 22 Jun 2017 21:26:33 -0700 Subject: [PATCH 25/45] [swss]: Sleep 5 min regardless of arp_update return code (#743) - arp_update return code is not guaranteed to be true/false. When there is no VLAN, arp_update will return true. When there are VLANs, arp_update will return false because the command arping returns 1 due to the option '-w 0'. - This script should be run every 5 minutes regardless of the return code. --- dockers/docker-orchagent/supervisord.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-orchagent/supervisord.conf b/dockers/docker-orchagent/supervisord.conf index 770fda701029..a04238472c4c 100644 --- a/dockers/docker-orchagent/supervisord.conf +++ b/dockers/docker-orchagent/supervisord.conf @@ -60,7 +60,7 @@ stdout_logfile=syslog stderr_logfile=syslog [program:arp_update] -command=bash -c "/usr/bin/arp_update && sleep 300" +command=bash -c "/usr/bin/arp_update; sleep 300" priority=8 autostart=false autorestart=true From 350718ee77a4c7522ea0ddd649f67d19c2940c43 Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Fri, 23 Jun 2017 07:27:50 +0300 Subject: [PATCH 26/45] [Mellanox]: Update SAI version (#740) - Initialize ECMP default hashing with IPv6 packets --- platform/mellanox/mlnx-sai.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/mellanox/mlnx-sai.mk b/platform/mellanox/mlnx-sai.mk index 67bc173ae8a6..8d3712cb1378 100644 --- a/platform/mellanox/mlnx-sai.mk +++ b/platform/mellanox/mlnx-sai.mk @@ -1,7 +1,7 @@ # Mellanox SAI MLNX_SAI_VERSION = 161120 -MLNX_SAI_REVISION = 579c19acf3b9bed181ac713fcf92302f4ebae422 +MLNX_SAI_REVISION = b57b458ff060adb2b1df629e330431a391a3b83e export MLNX_SAI_VERSION MLNX_SAI_REVISION From 00c494f0235b0f73ce31a645d64cce792973a564 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Fri, 23 Jun 2017 01:08:25 -0700 Subject: [PATCH 27/45] [sonic-cfggen]: Add default IP deny rule in translate_acl (#734) - Add IPv4 implicit rule: deny ip any any This implicit rule has lowest priority and ensures that the device denies all unmatched IP traffic. --- .../tests/sample_output/rules_for_dataacl.json | 16 ++++++++++++---- .../tests/sample_output/rules_for_everflow.json | 2 +- src/sonic-config-engine/translate_acl | 15 +++++++++++++-- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/sonic-config-engine/tests/sample_output/rules_for_dataacl.json b/src/sonic-config-engine/tests/sample_output/rules_for_dataacl.json index 48fa240c9dc6..709468f9d945 100644 --- a/src/sonic-config-engine/tests/sample_output/rules_for_dataacl.json +++ b/src/sonic-config-engine/tests/sample_output/rules_for_dataacl.json @@ -1,6 +1,6 @@ [ { - "ACL_RULE_TABLE:dataacl:Rule_1":{ + "ACL_RULE_TABLE:DATAACL:RULE_1":{ "IP_PROTOCOL":17, "PACKET_ACTION":"FORWARD", "SRC_IP":"10.0.0.0/8", @@ -9,7 +9,7 @@ "OP":"SET" }, { - "ACL_RULE_TABLE:dataacl:Rule_3":{ + "ACL_RULE_TABLE:DATAACL:RULE_3":{ "IP_PROTOCOL":17, "PACKET_ACTION":"FORWARD", "SRC_IP":"25.0.0.0/8", @@ -18,7 +18,7 @@ "OP":"SET" }, { - "ACL_RULE_TABLE:dataacl:Rule_2":{ + "ACL_RULE_TABLE:DATAACL:RULE_2":{ "IP_PROTOCOL":17, "PACKET_ACTION":"FORWARD", "SRC_IP":"100.64.0.0/10", @@ -27,12 +27,20 @@ "OP":"SET" }, { - "ACL_RULE_TABLE:dataacl:Rule_4":{ + "ACL_RULE_TABLE:DATAACL:RULE_4":{ "IP_PROTOCOL":6, "PACKET_ACTION":"FORWARD", "TCP_FLAGS":"0x10/0x10", "priority":9996 }, "OP":"SET" + }, + { + "ACL_RULE_TABLE:DATAACL:DEFAULT_RULE":{ + "ETHER_TYPE":"0x0800", + "PACKET_ACTION":"DROP", + "priority":1 + }, + "OP":"SET" } ] \ No newline at end of file diff --git a/src/sonic-config-engine/tests/sample_output/rules_for_everflow.json b/src/sonic-config-engine/tests/sample_output/rules_for_everflow.json index c31965e31e27..2f39a0dcc4a3 100644 --- a/src/sonic-config-engine/tests/sample_output/rules_for_everflow.json +++ b/src/sonic-config-engine/tests/sample_output/rules_for_everflow.json @@ -1,6 +1,6 @@ [ { - "ACL_RULE_TABLE:everflow:Rule_1":{ + "ACL_RULE_TABLE:EVERFLOW:RULE_1":{ "DST_IP":"127.0.0.1/32", "IP_PROTOCOL":6, "L4_DST_PORT":0, diff --git a/src/sonic-config-engine/translate_acl b/src/sonic-config-engine/translate_acl index 584db7b64488..696a433730a9 100755 --- a/src/sonic-config-engine/translate_acl +++ b/src/sonic-config-engine/translate_acl @@ -13,11 +13,21 @@ def dump_json(filename, data): with open(filename, 'w') as outfile: json.dump(data, outfile, indent=4, sort_keys=True, separators=(',', ':')) +def default_deny_rule(table_name): + rule_props = {} + rule_data = {} + rule_data["ACL_RULE_TABLE:"+table_name.upper()+":DEFAULT_RULE"] = rule_props + rule_data["OP"] = "SET" + rule_props["priority"] = 1 + rule_props["ETHER_TYPE"] = "0x0800" + rule_props["PACKET_ACTION"] = "DROP" + return rule_data + def generate_rule_json(table_name, rule, max_priority, mirror): rule_idx = rule.config.sequence_id rule_props = {} rule_data = {} - rule_data["ACL_RULE_TABLE:"+table_name+":Rule_"+str(rule_idx)] = rule_props + rule_data["ACL_RULE_TABLE:"+table_name.upper()+":RULE_"+str(rule_idx)] = rule_props rule_data["OP"] = "SET" rule_props["priority"] = max_priority - rule_idx @@ -120,7 +130,8 @@ def generate_table_json(aclset, aclname, ports, mirror, max_priority, output_pat rule_props = generate_rule_json(table_name, aclentry, max_priority, mirror) if rule_props: rule_data.append(rule_props) - + if not mirror: + rule_data.append(default_deny_rule(table_name)) dump_json(os.path.join(output_path, "rules_for_"+table_name+".json"), rule_data) def translate_acl_fixed_port(filename, output_path, port, max_priority): From 22819d9983cdad5d331422c6dd12e151fe2b14ad Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Fri, 23 Jun 2017 15:23:00 -0700 Subject: [PATCH 28/45] [docker-platform-monitor]: Add fancontrol (#735) --- dockers/docker-platform-monitor/Dockerfile.j2 | 3 ++- dockers/docker-platform-monitor/start.sh | 22 ++++++++++++++----- .../docker-platform-monitor/supervisord.conf | 10 ++++++++- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/dockers/docker-platform-monitor/Dockerfile.j2 b/dockers/docker-platform-monitor/Dockerfile.j2 index 9b407bdef6bc..423181a3c589 100755 --- a/dockers/docker-platform-monitor/Dockerfile.j2 +++ b/dockers/docker-platform-monitor/Dockerfile.j2 @@ -6,7 +6,8 @@ ENV DEBIAN_FRONTEND=noninteractive # Update apt's package index files RUN apt-get update -RUN apt-get install -y python-pip sensord +# Install required packages +RUN apt-get install -y python-pip sensord fancontrol {% if docker_platform_monitor_debs.strip() %} # Copy built Debian packages diff --git a/dockers/docker-platform-monitor/start.sh b/dockers/docker-platform-monitor/start.sh index b550cc037a5d..cfcf17e4a192 100755 --- a/dockers/docker-platform-monitor/start.sh +++ b/dockers/docker-platform-monitor/start.sh @@ -1,16 +1,26 @@ #!/usr/bin/env bash -mkdir -p /etc/sensors.d -if [ -e /usr/share/sonic/platform/sensors.conf ]; then - /bin/cp -rf /usr/share/sonic/platform/sensors.conf /etc/sensors.d/ -fi - mkdir -p /var/sonic echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status rm -f /var/run/rsyslogd.pid supervisorctl start rsyslogd -supervisorctl start lm-sensors + +# If this platform has an lm-sensors config file, copy it to it's proper place +# and start lm-sensors +if [ -e /usr/share/sonic/platform/sensors.conf ]; then + mkdir -p /etc/sensors.d + /bin/cp -f /usr/share/sonic/platform/sensors.conf /etc/sensors.d/ + supervisorctl start lm-sensors +fi + +# If this platform has a fancontrol config file, copy it to it's proper place +# and start fancontrol +if [ -e /usr/share/sonic/platform/fancontrol ]; then + /bin/cp -f /usr/share/sonic/platform/fancontrol /etc/ + supervisorctl start fancontrol +fi + supervisorctl start ledd diff --git a/dockers/docker-platform-monitor/supervisord.conf b/dockers/docker-platform-monitor/supervisord.conf index 051829eae65f..2753dceb652d 100644 --- a/dockers/docker-platform-monitor/supervisord.conf +++ b/dockers/docker-platform-monitor/supervisord.conf @@ -27,9 +27,17 @@ autorestart=false stdout_logfile=syslog stderr_logfile=syslog +[program:fancontrol] +command=/usr/sbin/fancontrol +priority=4 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog + [program:ledd] command=/usr/bin/ledd -priority=6 +priority=5 autostart=false stdout_logfile=syslog stderr_logfile=syslog From 0cdad949e5d382a142f52629caf4420bb7d1c7d5 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Fri, 23 Jun 2017 22:53:15 -0700 Subject: [PATCH 29/45] Fix typo in README (#750) * Fix typo in README * Fix comment * Fix README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c2d30cf6bae..c3d58ae1b538 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ To build SONiC installer image and docker images, run the following commands: **NOTE**: We recommend reserving 50G free space to build one platform. -The SONIiC installer contains all docker images needed. SONiC use one image for all switches devices of a same ASIC vendor. The supported ASIC vendors are: +The SONiC installer contains all docker images needed. SONiC uses one image for all devices of a same ASIC vendor. The supported ASIC vendors are: - PLATFORM=broadcom - PLATFORM=marvell (*pending*) From 017eea8a874cee17b1eb08d9b46e7235b96cfcc1 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Sat, 24 Jun 2017 12:05:04 -0700 Subject: [PATCH 30/45] [DHCP Relay]: Add support for custom Option 82 circuit_id of the form ':' (#747) * Add docker-dhcp-relay/Dockerfile to .gitignore * Add isc-dhcp-relay .deb package to image build process, along with my Option 82 patch * Install custom isc-dhcp-relay in dhcp_relay docker * Install isc-dhcp-relay build dependencies in sonic-slave Docker container * Copy the built .deb package to the destination directory * Add dependencies for isc-dhcp-relay * Change Option 82 string to ':' * Install dependencies of .deb files implicitly in Dockerfile * Remove unused line * Remove unnecessary space --- .gitignore | 1 + .../{Dockerfile => Dockerfile.j2} | 13 +- dockers/docker-dhcp-relay/isc-dhcp-relay.j2 | 4 +- rules/docker-dhcp-relay.mk | 3 +- rules/isc-dhcp.mk | 13 + sonic-slave/Dockerfile | 3 + src/isc-dhcp/Makefile | 30 ++ ...d-remote_id-and-bridge-iface-support.patch | 289 ++++++++++++++++++ 8 files changed, 351 insertions(+), 5 deletions(-) rename dockers/docker-dhcp-relay/{Dockerfile => Dockerfile.j2} (51%) create mode 100644 rules/isc-dhcp.mk create mode 100644 src/isc-dhcp/Makefile create mode 100644 src/isc-dhcp/isc-dhcp-4.3.1_dhcrelay-custom-circuit_id-remote_id-and-bridge-iface-support.patch diff --git a/.gitignore b/.gitignore index 2222458d1026..dd8befe10436 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ src/sonic-device-data/src/device/ dockers/docker-base/Dockerfile dockers/docker-config-engine/Dockerfile dockers/docker-database/Dockerfile +dockers/docker-dhcp-relay/Dockerfile dockers/docker-fpm-frr/Dockerfile dockers/docker-fpm-gobgp/Dockerfile dockers/docker-fpm-quagga/Dockerfile diff --git a/dockers/docker-dhcp-relay/Dockerfile b/dockers/docker-dhcp-relay/Dockerfile.j2 similarity index 51% rename from dockers/docker-dhcp-relay/Dockerfile rename to dockers/docker-dhcp-relay/Dockerfile.j2 index c3f9f298983e..1a7b7854d554 100644 --- a/dockers/docker-dhcp-relay/Dockerfile +++ b/dockers/docker-dhcp-relay/Dockerfile.j2 @@ -6,8 +6,17 @@ ENV DEBIAN_FRONTEND=noninteractive # Update apt's cache of available packages RUN apt-get update -# Install isc-dhcp-relay Debian package -RUN apt-get -y install isc-dhcp-relay +{% if docker_dhcp_relay_debs.strip() -%} +# Copy built Debian packages +{%- for deb in docker_dhcp_relay_debs.split(' ') %} +COPY debs/{{ deb }} debs/ +{%- endfor %} + +# Install built Debian packages and implicitly install their dependencies +{%- for deb in docker_dhcp_relay_debs.split(' ') %} +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt debs/{{ deb }} +{%- endfor %} +{%- endif %} # Clean up RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y diff --git a/dockers/docker-dhcp-relay/isc-dhcp-relay.j2 b/dockers/docker-dhcp-relay/isc-dhcp-relay.j2 index 05e633b7602f..0b8366d5844e 100644 --- a/dockers/docker-dhcp-relay/isc-dhcp-relay.j2 +++ b/dockers/docker-dhcp-relay/isc-dhcp-relay.j2 @@ -24,6 +24,6 @@ INTERFACES=" {%- endif %} {%- endfor %}" -# '-a' option provides option 82 circuit id information -OPTIONS="-a" +# '-a' option provides option 82 circuit_id and remote_id information +OPTIONS="-a \"%h:%p\" \"\"" diff --git a/rules/docker-dhcp-relay.mk b/rules/docker-dhcp-relay.mk index 7a7a1afeb4db..44d3904d7394 100644 --- a/rules/docker-dhcp-relay.mk +++ b/rules/docker-dhcp-relay.mk @@ -2,8 +2,9 @@ DOCKER_DHCP_RELAY = docker-dhcp-relay.gz $(DOCKER_DHCP_RELAY)_PATH = $(DOCKERS_PATH)/docker-dhcp-relay +$(DOCKER_DHCP_RELAY)_DEPENDS += $(ISC_DHCP_COMMON) $(ISC_DHCP_RELAY) $(DOCKER_DHCP_RELAY)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE) -SONIC_SIMPLE_DOCKER_IMAGES += $(DOCKER_DHCP_RELAY) +SONIC_DOCKER_IMAGES += $(DOCKER_DHCP_RELAY) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_DHCP_RELAY) diff --git a/rules/isc-dhcp.mk b/rules/isc-dhcp.mk new file mode 100644 index 000000000000..bfceb7676622 --- /dev/null +++ b/rules/isc-dhcp.mk @@ -0,0 +1,13 @@ +# isc-dhcp packages + +ISC_DHCP_VERSION = 4.3.1-6 + +export ISC_DHCP_VERSION + +ISC_DHCP_COMMON = isc-dhcp-common_$(ISC_DHCP_VERSION)_amd64.deb +$(ISC_DHCP_COMMON)_SRC_PATH = $(SRC_PATH)/isc-dhcp +SONIC_MAKE_DEBS += $(ISC_DHCP_COMMON) + +ISC_DHCP_RELAY = isc-dhcp-relay_$(ISC_DHCP_VERSION)_amd64.deb +$(eval $(call add_derived_package,$(ISC_DHCP_COMMON),$(ISC_DHCP_RELAY))) + diff --git a/sonic-slave/Dockerfile b/sonic-slave/Dockerfile index ee37f57ee0b5..5757eb1d8693 100644 --- a/sonic-slave/Dockerfile +++ b/sonic-slave/Dockerfile @@ -216,6 +216,9 @@ RUN apt-get update && apt-get install -y \ # For sonic config engine testing pyangbind +# Install dependencies for building isc-dhcp-relay +RUN apt-get -y build-dep isc-dhcp + RUN cd /usr/src/gtest && cmake . && make -C /usr/src/gtest RUN mkdir /var/run/sshd diff --git a/src/isc-dhcp/Makefile b/src/isc-dhcp/Makefile new file mode 100644 index 000000000000..b043c0bb266c --- /dev/null +++ b/src/isc-dhcp/Makefile @@ -0,0 +1,30 @@ +.ONESHELL: +SHELL = /bin/bash +.SHELLFLAGS += -e + +MAIN_TARGET = isc-dhcp-common_$(ISC_DHCP_VERSION)_amd64.deb +DERIVED_TARGETS = isc-dhcp-relay_$(ISC_DHCP_VERSION)_amd64.deb + +$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : + # Remove any stale files + rm -rf ./isc-dhcp + + # Clone isc-dhcp repo + git clone git://anonscm.debian.org/pkg-dhcp/isc-dhcp.git + pushd ./isc-dhcp + git checkout -f debian/4.3.1-6 + popd + + # Apply patch + patch -p1 < isc-dhcp-4.3.1_dhcrelay-custom-circuit_id-remote_id-and-bridge-iface-support.patch + + # Build source and Debian packages + pushd ./isc-dhcp + dpkg-buildpackage -rfakeroot -b -us -uc + 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/isc-dhcp-4.3.1_dhcrelay-custom-circuit_id-remote_id-and-bridge-iface-support.patch b/src/isc-dhcp/isc-dhcp-4.3.1_dhcrelay-custom-circuit_id-remote_id-and-bridge-iface-support.patch new file mode 100644 index 000000000000..8d28751da63c --- /dev/null +++ b/src/isc-dhcp/isc-dhcp-4.3.1_dhcrelay-custom-circuit_id-remote_id-and-bridge-iface-support.patch @@ -0,0 +1,289 @@ +This patch adds the following functionality to dhcrelay in isc-dhcp v4.3.1-6: +* Add customizable Circuit ID and Remote ID fields +* Support for obtaining name of physical interface of interfaces that are part of a bridge interface + +diff -ruN a/isc-dhcp/relay/dhcrelay.c b/isc-dhcp/relay/dhcrelay.c +--- a/isc-dhcp/relay/dhcrelay.c 2014-08-06 22:35:02.000000000 +0000 ++++ b/isc-dhcp/relay/dhcrelay.c 2017-06-08 21:39:53.856192546 +0000 +@@ -73,6 +73,8 @@ + did not match any known circuit ID. */ + int missing_circuit_id = 0; /* Circuit ID option in matching RAI option + was missing. */ ++const char *agent_circuit_id_fmt = NULL; /* Circuit ID custom format string. */ ++const char *agent_remote_id_fmt = NULL; /* Remote ID custom format string. */ + int max_hop_count = 10; /* Maximum hop count */ + + #ifdef DHCPv6 +@@ -140,9 +142,19 @@ + static const char url[] = + "For info, please visit https://www.isc.org/software/dhcp/"; + ++#define DHCRELAY_OPTION82_USAGE \ ++"circuit_id/remote_id interpreted sequences are:\n" \ ++"\n" \ ++" %%%% A single %%\n" \ ++" %%h Hostname of device\n" \ ++" %%p Name of interface that generated the request\n" \ ++" %%P Hardware address of interface that generated the request\n" \ ++" %%C Client hardware address\n" \ ++" %%I DHCP relay agent IP Address\n" \ ++ + #ifdef DHCPv6 + #define DHCRELAY_USAGE \ +-"Usage: dhcrelay [-4] [-d] [-q] [-a] [-D]\n"\ ++"Usage: dhcrelay [-4] [-d] [-q] [-a ] [-D]\n"\ + " [-A ] [-c ] [-p ]\n" \ + " [-pf ] [--no-pid]\n"\ + " [-m append|replace|forward|discard]\n" \ +@@ -154,14 +166,15 @@ + " -l lower0 [ ... -l lowerN]\n" \ + " -u upper0 [ ... -u upperN]\n" \ + " lower (client link): [address%%]interface[#index]\n" \ +-" upper (server link): [address%%]interface" ++" upper (server link): [address%%]interface\n\n" DHCRELAY_OPTION82_USAGE + #else + #define DHCRELAY_USAGE \ +-"Usage: dhcrelay [-d] [-q] [-a] [-D] [-A ] [-c ] [-p ]\n" \ +-" [-pf ] [--no-pid]\n" \ ++"Usage: dhcrelay [-d] [-q] [-a ] [-D]\n" \ ++" [-A ] [-c ] [-p ]\n" \ ++" [-pf ] [--no-pid]\n"\ + " [-m append|replace|forward|discard]\n" \ + " [-i interface0 [ ... -i interfaceN]\n" \ +-" server0 [ ... serverN]\n\n" ++" server0 [ ... serverN]\n\n" DHCRELAY_OPTION82_USAGE + #endif + + static void usage() { +@@ -287,6 +300,15 @@ + local_family_set = 1; + local_family = AF_INET; + #endif ++ if (++i == argc) ++ usage(); ++ ++ if (argv[i] != NULL && argv[i][0] != '-') ++ agent_circuit_id_fmt = argv[i++]; ++ ++ if (argv[i] != NULL && argv[i][0] != '-') ++ agent_remote_id_fmt = argv[i]; ++ + add_agent_options = 1; + } else if (!strcmp(argv[i], "-A")) { + #ifdef DHCPv6 +@@ -937,6 +959,166 @@ + return (-1); + } + ++static int ++_bridgefdbquery(const char *hwAddr, char *interface, int *vlanid) { ++ ++#define xstr(s) str(s) ++#define str(s) #s ++#define FDB_STRING_LEN 100 ++#define FDB_BUFFER_LEN (FDB_STRING_LEN + 1) ++ ++/* ++ * Format for sscanf() to read the 1st, 3th, and 5th ++ * space-delimited fields ++ * ++ * bridge fdb show output ++ * 6c:64:1a:00:06:13 dev swp35 vlan 0 master bridge permanent ++ */ ++#define FDB_LINE_FORMAT "%" xstr(FDB_STRING_LEN) "s %*s " \ ++ "%" xstr(FDB_STRING_LEN) "s %*s %d %*s" ++ ++ char cmdstr[FDB_BUFFER_LEN]; ++ char buf[FDB_BUFFER_LEN]; ++ char macAddr[FDB_BUFFER_LEN]; ++ ++ if ((interface == NULL) || (vlanid == NULL)) { ++ return 0; ++ } ++ sprintf(cmdstr, "bridge fdb show | grep -m 1 %s", hwAddr); ++ FILE *cmd = popen(cmdstr, "r"); ++ ++ if (cmd != NULL) { ++ while (fgets(buf, sizeof(buf), cmd)) { ++ sscanf(buf, FDB_LINE_FORMAT, macAddr, interface, vlanid); ++ log_debug ("bridgefdbquery: macAddr:%s interface: %s vlanid %d", ++ macAddr, ++ interface, *vlanid); ++ } ++ pclose(cmd); ++ return 0; ++ } ++ ++ return -1; ++} ++ ++/* ++ * Format the message that will be used by circuit_id and remote_id ++ */ ++static int ++format_relay_agent_rfc3046_msg(struct interface_info *ip, struct dhcp_packet *packet, ++ const char *format, char *msg, size_t msgn) { ++ size_t len = 0; ++ char hostname[HOST_NAME_MAX + 1] = { 0 }; ++ char ifname[IFNAMSIZ + 1] = { 0 }; ++ char *buf = msg; ++ ++ for ( ; format && *format && len < msgn; ++format) { ++ size_t strn = 0; ++ const char *str = NULL; ++ ++ if (*format == '%') { ++ switch (*++format) { ++ case '\0': ++ --format; ++ break; ++ ++ case '%': /* A literal '%' */ ++ str = "%"; ++ break; ++ ++ case 'h': /* Hostname */ ++ gethostname(hostname, HOST_NAME_MAX); ++ str = hostname; ++ break; ++ ++ case 'p': /* Name of interface that we received the request from */ ++ /* ++ * Query FDB to identify the exact physical interface only when source MAC address ++ * is present and '20: DHCP relay agent IP address' (giaddr) is not present ++ */ ++ if (packet->htype && !packet->giaddr.s_addr) { ++ int ret = 0, vlanid = 0; ++ ++ ret = _bridgefdbquery(print_hw_addr(packet->htype, packet->hlen, packet->chaddr), ++ ip->name, ++ &vlanid); ++ ++ if (ret < 0) { ++ log_debug("MAC Address: %s (interface:%s vlan:%d) not found in bridge fdb show", ++ print_hw_addr (packet->htype, packet->hlen, packet->chaddr), ++ ip->name, ++ vlanid); ++ strncpy(ifname, ip->name, IFNAMSIZ); ++ } ++ else if (strlen(ip->name) > 0) { ++ char cmdstr[256] = { 0 }; ++ char cmdout[256] = { 0 }; ++ ++ log_debug("Adding option 82 interface name for MAC Address: %s as %s", ++ print_hw_addr (packet->htype, packet->hlen, packet->chaddr), ++ ip->name); ++ ++ // Translate SONiC interface name to vendor alias ++ sprintf(cmdstr, "sonic-cfggen -m /etc/sonic/minigraph.xml -v \"minigraph_ports['%s'].alias\"", ip->name); ++ ++ FILE *cmd = popen(cmdstr, "r"); ++ ++ if (cmd != NULL) { ++ while (fgets(cmdout, sizeof(cmdout), cmd)) { ++ // Strip any trailing newline ++ if (cmdout[strlen(cmdout) - 1] == '\n') ++ cmdout[strlen(cmdout) - 1] = '\0'; ++ ++ log_debug ("Retrieved alias %s for interface %s", buf, ip->name); ++ } ++ ++ pclose(cmd); ++ } ++ ++ strncpy(ifname, cmdout, IFNAMSIZ); ++ } ++ ++ str = ifname; ++ } ++ break; ++ ++ case 'P': /* Physical address of interface that we received the request from */ ++ str = print_hw_addr(ip->hw_address.hbuf[0], ip->hw_address.hlen - 1, &ip->hw_address.hbuf[1]); ++ break; ++ ++ case 'C': /* 24: Client hardware address */ ++ str = print_hw_addr(packet->htype, packet->hlen, packet->chaddr); ++ break; ++ ++ case 'I': /* 20: DHCP relay agent IP address */ ++ str = inet_ntoa(packet->giaddr); ++ break; ++ ++ default: ++ log_error("Option %%%c is unrecognized and will not be formatted!", *format); ++ continue; ++ } ++ ++ if (str) ++ strn = strlen(str); ++ } else { ++ str = format; ++ strn += 1; ++ } ++ ++ // Do we have room? ++ if ((strn+len) > msgn) { ++ return 0; ++ } ++ ++ memcpy(buf+len, str, strn); ++ len += strn; ++ } ++ ++ return len; ++} ++ ++ + /* + * Examine a packet to see if it's a candidate to have a Relay + * Agent Information option tacked onto its tail. If it is, tack +@@ -948,6 +1130,8 @@ + int is_dhcp = 0, mms; + unsigned optlen; + u_int8_t *op, *nextop, *sp, *max, *end_pad = NULL; ++ char circuit_id_buf[255] = { '\0', }; ++ char remote_id_buf[255] = { '\0', }; + + /* If we're not adding agent options to packets, we can skip + this. */ +@@ -1077,6 +1261,38 @@ + op = sp; + #endif + ++ /* option82: custom string for circuit_id */ ++ if (agent_circuit_id_fmt) { ++ size_t len = 0; ++ ++ len = format_relay_agent_rfc3046_msg(ip, packet, agent_circuit_id_fmt, ++ circuit_id_buf, sizeof(circuit_id_buf)); ++ ++ if (len > 0) { ++ ip->circuit_id = (uint8_t *)circuit_id_buf; ++ ip->circuit_id_len = len; ++ ++ log_debug("sending on %s option82:circuit_id='%s'(%d)", ++ ip->name, (char *)ip->circuit_id, ip->circuit_id_len); ++ } ++ } ++ ++ /* option82: custom string for remote_id */ ++ if (agent_remote_id_fmt) { ++ size_t len = 0; ++ ++ len = format_relay_agent_rfc3046_msg(ip, packet, agent_remote_id_fmt, ++ remote_id_buf, sizeof(remote_id_buf)); ++ ++ if (len > 0) { ++ ip->remote_id = (uint8_t *)remote_id_buf; ++ ip->remote_id_len = len; ++ ++ log_debug("sending on %s option82:remote_id='%s'(%d)", ++ ip->name, (char *)ip->remote_id, ip->remote_id_len); ++ } ++ } ++ + /* Sanity check. Had better not ever happen. */ + if ((ip->circuit_id_len > 255) ||(ip->circuit_id_len < 1)) + log_fatal("Circuit ID length %d out of range [1-255] on " + From fbb2e410e9b87a2f8b04ca911052825b695aee05 Mon Sep 17 00:00:00 2001 From: Polly Hsu Date: Sun, 25 Jun 2017 05:07:15 +0800 Subject: [PATCH 31/45] [Accton]: Add a new supported device and platform AS7716-32X (#732) Switch Vendor: Edge-core Switch SKU: AS7716-32X ASIC Vendor: Broadcom Swich ASIC: Tomahawk Port Configuration: 32x100G SONiC Image: SONiC-ONIE-Broadcom Signed-off-by: polly_hsu@accton.com --- .../Accton-AS7716-32X/port_config.ini | 33 + .../Accton-AS7716-32X/sai.profile | 2 + .../installer.conf | 3 + .../x86_64-accton_as7716_32x-r0/minigraph.xml | 1074 +++++++++++++++++ 4 files changed, 1112 insertions(+) create mode 100644 device/accton/x86_64-accton_as7716_32x-r0/Accton-AS7716-32X/port_config.ini create mode 100644 device/accton/x86_64-accton_as7716_32x-r0/Accton-AS7716-32X/sai.profile create mode 100644 device/accton/x86_64-accton_as7716_32x-r0/installer.conf create mode 100644 device/accton/x86_64-accton_as7716_32x-r0/minigraph.xml diff --git a/device/accton/x86_64-accton_as7716_32x-r0/Accton-AS7716-32X/port_config.ini b/device/accton/x86_64-accton_as7716_32x-r0/Accton-AS7716-32X/port_config.ini new file mode 100644 index 000000000000..1fa6d21d9609 --- /dev/null +++ b/device/accton/x86_64-accton_as7716_32x-r0/Accton-AS7716-32X/port_config.ini @@ -0,0 +1,33 @@ +# name lanes alias +Ethernet0 49,50,51,52 hundredGigE1 +Ethernet4 53,54,55,56 hundredGigE2 +Ethernet8 57,58,59,60 hundredGigE3 +Ethernet12 61,62,63,64 hundredGigE4 +Ethernet16 65,66,67,68 hundredGigE5 +Ethernet20 69,70,71,72 hundredGigE6 +Ethernet24 73,74,75,76 hundredGigE7 +Ethernet28 77,78,79,80 hundredGigE8 +Ethernet32 33,34,35,36 hundredGigE9 +Ethernet36 37,38,39,40 hundredGigE10 +Ethernet40 41,42,43,44 hundredGigE11 +Ethernet44 45,46,47,48 hundredGigE12 +Ethernet48 81,82,83,84 hundredGigE13 +Ethernet52 85,86,87,88 hundredGigE14 +Ethernet56 89,90,91,92 hundredGigE15 +Ethernet60 93,94,95,96 hundredGigE16 +Ethernet64 97,98,99,100 hundredGigE17 +Ethernet68 101,102,103,104 hundredGigE18 +Ethernet72 105,106,107,108 hundredGigE19 +Ethernet76 109,110,111,112 hundredGigE20 +Ethernet80 17,18,19,20 hundredGigE21 +Ethernet84 21,22,23,24 hundredGigE22 +Ethernet88 25,26,27,28 hundredGigE23 +Ethernet92 29,30,31,32 hundredGigE24 +Ethernet96 113,114,115,116 hundredGigE25 +Ethernet100 117,118,119,120 hundredGigE26 +Ethernet104 121,122,123,124 hundredGigE27 +Ethernet108 125,126,127,128 hundredGigE28 +Ethernet112 1,2,3,4 hundredGigE29 +Ethernet116 5,6,7,8 hundredGigE30 +Ethernet120 9,10,11,12 hundredGigE31 +Ethernet124 13,14,15,16 hundredGigE32 diff --git a/device/accton/x86_64-accton_as7716_32x-r0/Accton-AS7716-32X/sai.profile b/device/accton/x86_64-accton_as7716_32x-r0/Accton-AS7716-32X/sai.profile new file mode 100644 index 000000000000..fb1105b47f7a --- /dev/null +++ b/device/accton/x86_64-accton_as7716_32x-r0/Accton-AS7716-32X/sai.profile @@ -0,0 +1,2 @@ +SAI_INIT_CONFIG_FILE=/etc/bcm/th-as7716-32x100G.config.bcm + diff --git a/device/accton/x86_64-accton_as7716_32x-r0/installer.conf b/device/accton/x86_64-accton_as7716_32x-r0/installer.conf new file mode 100644 index 000000000000..925a32fc0c3a --- /dev/null +++ b/device/accton/x86_64-accton_as7716_32x-r0/installer.conf @@ -0,0 +1,3 @@ +CONSOLE_PORT=0x3f8 +CONSOLE_DEV=0 +CONSOLE_SPEED=115200 diff --git a/device/accton/x86_64-accton_as7716_32x-r0/minigraph.xml b/device/accton/x86_64-accton_as7716_32x-r0/minigraph.xml new file mode 100644 index 000000000000..e197d4cd7178 --- /dev/null +++ b/device/accton/x86_64-accton_as7716_32x-r0/minigraph.xml @@ -0,0 +1,1074 @@ + + + + + + ARISTA01T0 + 10.0.0.33 + switch1 + 10.0.0.32 + 1 + 180 + 60 + + + switch1 + 10.0.0.0 + ARISTA01T2 + 10.0.0.1 + 1 + 180 + 60 + + + ARISTA02T0 + 10.0.0.35 + switch1 + 10.0.0.34 + 1 + 180 + 60 + + + switch1 + 10.0.0.2 + ARISTA02T2 + 10.0.0.3 + 1 + 180 + 60 + + + ARISTA03T0 + 10.0.0.37 + switch1 + 10.0.0.36 + 1 + 180 + 60 + + + switch1 + 10.0.0.4 + ARISTA03T2 + 10.0.0.5 + 1 + 180 + 60 + + + ARISTA04T0 + 10.0.0.39 + switch1 + 10.0.0.38 + 1 + 180 + 60 + + + switch1 + 10.0.0.6 + ARISTA04T2 + 10.0.0.7 + 1 + 180 + 60 + + + ARISTA05T0 + 10.0.0.41 + switch1 + 10.0.0.40 + 1 + 180 + 60 + + + switch1 + 10.0.0.8 + ARISTA05T2 + 10.0.0.9 + 1 + 180 + 60 + + + ARISTA06T0 + 10.0.0.43 + switch1 + 10.0.0.42 + 1 + 180 + 60 + + + switch1 + 10.0.0.10 + ARISTA06T2 + 10.0.0.11 + 1 + 180 + 60 + + + ARISTA07T0 + 10.0.0.45 + switch1 + 10.0.0.44 + 1 + 180 + 60 + + + switch1 + 10.0.0.12 + ARISTA07T2 + 10.0.0.13 + 1 + 180 + 60 + + + ARISTA08T0 + 10.0.0.47 + switch1 + 10.0.0.46 + 1 + 180 + 60 + + + switch1 + 10.0.0.14 + ARISTA08T2 + 10.0.0.15 + 1 + 180 + 60 + + + ARISTA09T0 + 10.0.0.49 + switch1 + 10.0.0.48 + 1 + 180 + 60 + + + switch1 + 10.0.0.16 + ARISTA09T2 + 10.0.0.17 + 1 + 180 + 60 + + + ARISTA10T0 + 10.0.0.51 + switch1 + 10.0.0.50 + 1 + 180 + 60 + + + switch1 + 10.0.0.18 + ARISTA10T2 + 10.0.0.19 + 1 + 180 + 60 + + + ARISTA11T0 + 10.0.0.53 + switch1 + 10.0.0.52 + 1 + 180 + 60 + + + switch1 + 10.0.0.20 + ARISTA11T2 + 10.0.0.21 + 1 + 180 + 60 + + + ARISTA12T0 + 10.0.0.55 + switch1 + 10.0.0.54 + 1 + 180 + 60 + + + switch1 + 10.0.0.22 + ARISTA12T2 + 10.0.0.23 + 1 + 180 + 60 + + + ARISTA13T0 + 10.0.0.57 + switch1 + 10.0.0.56 + 1 + 180 + 60 + + + switch1 + 10.0.0.24 + ARISTA13T2 + 10.0.0.25 + 1 + 180 + 60 + + + ARISTA14T0 + 10.0.0.59 + switch1 + 10.0.0.58 + 1 + 180 + 60 + + + switch1 + 10.0.0.26 + ARISTA14T2 + 10.0.0.27 + 1 + 180 + 60 + + + ARISTA15T0 + 10.0.0.61 + switch1 + 10.0.0.60 + 1 + 180 + 60 + + + switch1 + 10.0.0.28 + ARISTA15T2 + 10.0.0.29 + 1 + 180 + 60 + + + ARISTA16T0 + 10.0.0.63 + switch1 + 10.0.0.62 + 1 + 180 + 60 + + + switch1 + 10.0.0.30 + ARISTA16T2 + 10.0.0.31 + 1 + 180 + 60 + + + + + 65100 + switch1 + + +
10.0.0.33
+ + +
+ +
10.0.0.1
+ + +
+ +
10.0.0.35
+ + +
+ +
10.0.0.3
+ + +
+ +
10.0.0.37
+ + +
+ +
10.0.0.5
+ + +
+ +
10.0.0.39
+ + +
+ +
10.0.0.7
+ + +
+ +
10.0.0.41
+ + +
+ +
10.0.0.9
+ + +
+ +
10.0.0.43
+ + +
+ +
10.0.0.11
+ + +
+ +
10.0.0.45
+ + +
+ +
10.0.0.13
+ + +
+ +
10.0.0.47
+ + +
+ +
10.0.0.15
+ + +
+ +
10.0.0.49
+ + +
+ +
10.0.0.17
+ + +
+ +
10.0.0.51
+ + +
+ +
10.0.0.19
+ + +
+ +
10.0.0.53
+ + +
+ +
10.0.0.21
+ + +
+ +
10.0.0.55
+ + +
+ +
10.0.0.23
+ + +
+ +
10.0.0.57
+ + +
+ +
10.0.0.25
+ + +
+ +
10.0.0.59
+ + +
+ +
10.0.0.27
+ + +
+ +
10.0.0.61
+ + +
+ +
10.0.0.29
+ + +
+ +
10.0.0.63
+ + +
+ +
10.0.0.31
+ + +
+
+ +
+ + 64001 + ARISTA01T0 + + + + 65200 + ARISTA01T2 + + + + 64002 + ARISTA02T0 + + + + 65200 + ARISTA02T2 + + + + 64003 + ARISTA03T0 + + + + 65200 + ARISTA03T2 + + + + 64004 + ARISTA04T0 + + + + 65200 + ARISTA04T2 + + + + 64005 + ARISTA05T0 + + + + 65200 + ARISTA05T2 + + + + 64006 + ARISTA06T0 + + + + 65200 + ARISTA06T2 + + + + 64007 + ARISTA07T0 + + + + 65200 + ARISTA07T2 + + + + 64008 + ARISTA08T0 + + + + 65200 + ARISTA08T2 + + + + 64009 + ARISTA09T0 + + + + 65200 + ARISTA09T2 + + + + 64010 + ARISTA10T0 + + + + 65200 + ARISTA10T2 + + + + 64011 + ARISTA11T0 + + + + 65200 + ARISTA11T2 + + + + 64012 + ARISTA12T0 + + + + 65200 + ARISTA12T2 + + + + 64013 + ARISTA13T0 + + + + 65200 + ARISTA13T2 + + + + 64014 + ARISTA14T0 + + + + 65200 + ARISTA14T2 + + + + 64015 + ARISTA15T0 + + + + 65200 + ARISTA15T2 + + + + 64016 + ARISTA16T0 + + + + 65200 + ARISTA16T2 + + +
+
+ + + + + + HostIP + Loopback0 + + 10.1.0.32/32 + + 10.1.0.32/32 + + + + + + + + switch1 + + + + + + Ethernet0 + 10.0.0.0/31 + + + + Ethernet4 + 10.0.0.2/31 + + + + Ethernet8 + 10.0.0.4/31 + + + + Ethernet12 + 10.0.0.6/31 + + + + Ethernet16 + 10.0.0.8/31 + + + + Ethernet20 + 10.0.0.10/31 + + + + Ethernet24 + 10.0.0.12/31 + + + + Ethernet28 + 10.0.0.14/31 + + + + Ethernet32 + 10.0.0.16/31 + + + + Ethernet36 + 10.0.0.18/31 + + + + Ethernet40 + 10.0.0.20/31 + + + + Ethernet44 + 10.0.0.22/31 + + + + Ethernet48 + 10.0.0.24/31 + + + + Ethernet52 + 10.0.0.26/31 + + + + Ethernet56 + 10.0.0.28/31 + + + + Ethernet60 + 10.0.0.30/31 + + + + Ethernet64 + 10.0.0.32/31 + + + + Ethernet68 + 10.0.0.34/31 + + + + Ethernet72 + 10.0.0.36/31 + + + + Ethernet76 + 10.0.0.38/31 + + + + Ethernet80 + 10.0.0.40/31 + + + + Ethernet84 + 10.0.0.42/31 + + + + Ethernet88 + 10.0.0.44/31 + + + + Ethernet92 + 10.0.0.46/31 + + + + Ethernet96 + 10.0.0.48/31 + + + + Ethernet100 + 10.0.0.50/31 + + + + Ethernet104 + 10.0.0.52/31 + + + + Ethernet108 + 10.0.0.54/31 + + + + Ethernet112 + 10.0.0.56/31 + + + + Ethernet116 + 10.0.0.58/31 + + + + Ethernet120 + 10.0.0.60/31 + + + + Ethernet124 + 10.0.0.62/31 + + + + + + + + + + + + DeviceInterfaceLink + switch1 + Ethernet0 + ARISTA01T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet4 + ARISTA02T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet8 + ARISTA03T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet12 + ARISTA04T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet16 + ARISTA05T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet20 + ARISTA06T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet24 + ARISTA07T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet28 + ARISTA08T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet32 + ARISTA09T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet36 + ARISTA10T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet40 + ARISTA11T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet44 + ARISTA12T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet48 + ARISTA13T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet52 + ARISTA14T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet56 + ARISTA15T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet60 + ARISTA16T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet64 + ARISTA01T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet68 + ARISTA02T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet72 + ARISTA03T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet76 + ARISTA04T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet80 + ARISTA05T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet84 + ARISTA06T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet88 + ARISTA07T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet92 + ARISTA08T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet96 + ARISTA09T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet100 + ARISTA10T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet104 + ARISTA11T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet108 + ARISTA12T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet112 + ARISTA13T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet116 + ARISTA14T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet120 + ARISTA15T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet124 + ARISTA16T0 + Ethernet1 + + + + + switch1 + Accton-AS7716-32X + + + + + + + switch1 + + + DhcpResources + + + + + NtpResources + + 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org + + + SyslogResources + + + + + + + + + switch1 + Accton-AS7716-32X +
From b92fc2a5c9c678cdbaa43f487ef394188322688f Mon Sep 17 00:00:00 2001 From: Marian Pritsak Date: Mon, 26 Jun 2017 17:32:20 +0300 Subject: [PATCH 32/45] [.gitignore]: Update src, config engine (#754) Signed-off-by: marian-pritsak --- .gitignore | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index dd8befe10436..2ab113a44eff 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,13 @@ src/snmpd/* src/thrift/* !src/thrift/Makefile src/sonic-device-data/src/device/ +src/sonic-device-data/src/debian/ +src/igb/* +!src/igb/Makefile +src/mpdecimal/* +!src/mpdecimal/Makefile +src/python3/* +!src/python3/Makefile # Autogenerated Dockerfiles dockers/docker-base/Dockerfile @@ -43,3 +50,8 @@ platform/*/docker-syncd-*-rpc/Dockerfile # Installer-related files and directories installer/x86_64/platforms/ + +# Config engine +src/sonic-config-engine/**/*.pyc +src/sonic-config-engine/build +src/sonic-config-engine/sonic_config_engine.egg-info From fd730d803710414db218a658eefd3bef1ff4d380 Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Mon, 26 Jun 2017 18:58:53 +0300 Subject: [PATCH 33/45] [submodule]: update sonic-swss (#755) --- src/sonic-swss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-swss b/src/sonic-swss index 316b33371dcb..179daacb2162 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit 316b33371dcbccd3d81fa6987170be3e7a3a1536 +Subproject commit 179daacb2162bd769587070ae8ad4f9ded97d549 From 2d97c6a0a7dc6a67788b4b5ac5b88f2a24826c3e Mon Sep 17 00:00:00 2001 From: pavel-shirshov Date: Mon, 26 Jun 2017 21:28:16 -0700 Subject: [PATCH 34/45] [sonic-swss-common]: Submodule update (#759) --- src/sonic-swss-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-swss-common b/src/sonic-swss-common index 345576ea38cc..4f917f2cc345 160000 --- a/src/sonic-swss-common +++ b/src/sonic-swss-common @@ -1 +1 @@ -Subproject commit 345576ea38cc511b265825b445c48dbfbf444792 +Subproject commit 4f917f2cc345c54d1bf9d9f01d96e4c01071ac9a From 5310e7a9d7f5be14e0e1304856e52567772fe7d8 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Mon, 26 Jun 2017 21:28:51 -0700 Subject: [PATCH 35/45] [mgmt slave] Install correct version of python-cffi (#760) --- sonic-mgmt/Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sonic-mgmt/Dockerfile b/sonic-mgmt/Dockerfile index f462b99cdf45..69c29eb4c716 100644 --- a/sonic-mgmt/Dockerfile +++ b/sonic-mgmt/Dockerfile @@ -26,6 +26,9 @@ RUN apt-get install -y default-jre # For syslog test RUN apt-get install -y rsyslog psmisc +# Remove cffi 1.5.2, will install 1.10.0 by pip later +RUN apt-get remove -y python-cffi python-cffi-backend + RUN easy_install pip RUN pip install ipaddr \ @@ -37,6 +40,7 @@ RUN pip install ipaddr \ pyasn1==0.1.9 \ pysnmp==4.2.5 \ jinja2==2.7.2 \ + cffi==1.10.0 \ paramiko==2.1.2 RUN git clone https://github.com/ansible/ansible From 3798262c1a7d4bc983876ea45f2096a27f58ecf8 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Tue, 27 Jun 2017 17:59:36 -0700 Subject: [PATCH 36/45] [DHCP Relay]: Fix Option 82 string - Remove quotes; add MAC address of receiving port as remote_id (#763) --- dockers/docker-dhcp-relay/isc-dhcp-relay.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-dhcp-relay/isc-dhcp-relay.j2 b/dockers/docker-dhcp-relay/isc-dhcp-relay.j2 index 0b8366d5844e..3b76073fa8c6 100644 --- a/dockers/docker-dhcp-relay/isc-dhcp-relay.j2 +++ b/dockers/docker-dhcp-relay/isc-dhcp-relay.j2 @@ -25,5 +25,5 @@ INTERFACES=" {%- endfor %}" # '-a' option provides option 82 circuit_id and remote_id information -OPTIONS="-a \"%h:%p\" \"\"" +OPTIONS="-a %h:%p %P" From 15f245c1c92e91d6bc04dfc1cf8fee5f73d274ef Mon Sep 17 00:00:00 2001 From: lguohan Date: Tue, 27 Jun 2017 20:34:34 -0700 Subject: [PATCH 37/45] [platform]: add front panel index in port_config.ini for s6100 (#752) * add front panel index in port_config.ini --- .../Force10-S6100/port_config.ini | 130 +++++++++--------- src/sonic-utilities | 2 +- 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/device/dell/x86_64-dell_s6100_c2538-r0/Force10-S6100/port_config.ini b/device/dell/x86_64-dell_s6100_c2538-r0/Force10-S6100/port_config.ini index dcdd6548c198..8b09a1e71f74 100644 --- a/device/dell/x86_64-dell_s6100_c2538-r0/Force10-S6100/port_config.ini +++ b/device/dell/x86_64-dell_s6100_c2538-r0/Force10-S6100/port_config.ini @@ -1,65 +1,65 @@ -# name lanes alias -Ethernet0 101,102 fortyGigE1/1/1 -Ethernet1 103,104 fortyGigE1/1/2 -Ethernet2 97,98 fortyGigE1/1/3 -Ethernet3 99,100 fortyGigE1/1/4 -Ethernet4 69,70 fortyGigE1/1/5 -Ethernet5 71,72 fortyGigE1/1/6 -Ethernet6 65,66 fortyGigE1/1/7 -Ethernet7 67,68 fortyGigE1/1/8 -Ethernet8 53,54 fortyGigE1/1/9 -Ethernet9 55,56 fortyGigE1/1/10 -Ethernet10 49,50 fortyGigE1/1/11 -Ethernet11 51,52 fortyGigE1/1/12 -Ethernet12 21,22 fortyGigE1/1/13 -Ethernet13 23,24 fortyGigE1/1/14 -Ethernet14 17,18 fortyGigE1/1/15 -Ethernet15 19,20 fortyGigE1/1/16 -Ethernet16 25,26 fortyGigE1/2/1 -Ethernet17 27,28 fortyGigE1/2/2 -Ethernet18 29,30 fortyGigE1/2/3 -Ethernet19 31,32 fortyGigE1/2/4 -Ethernet20 57,58 fortyGigE1/2/5 -Ethernet21 59,60 fortyGigE1/2/6 -Ethernet22 61,62 fortyGigE1/2/7 -Ethernet23 63,64 fortyGigE1/2/8 -Ethernet24 73,74 fortyGigE1/2/9 -Ethernet25 75,76 fortyGigE1/2/10 -Ethernet26 77,78 fortyGigE1/2/11 -Ethernet27 79,80 fortyGigE1/2/12 -Ethernet28 105,106 fortyGigE1/2/13 -Ethernet29 107,108 fortyGigE1/2/14 -Ethernet30 109,110 fortyGigE1/2/15 -Ethernet31 111,112 fortyGigE1/2/16 -Ethernet32 13,14 fortyGigE1/3/1 -Ethernet33 15,16 fortyGigE1/3/2 -Ethernet34 9,10 fortyGigE1/3/3 -Ethernet35 11,12 fortyGigE1/3/4 -Ethernet36 125,126 fortyGigE1/3/5 -Ethernet37 127,128 fortyGigE1/3/6 -Ethernet38 121,122 fortyGigE1/3/7 -Ethernet39 123,124 fortyGigE1/3/8 -Ethernet40 93,94 fortyGigE1/3/9 -Ethernet41 95,96 fortyGigE1/3/10 -Ethernet42 89,90 fortyGigE1/3/11 -Ethernet43 91,92 fortyGigE1/3/12 -Ethernet44 45,46 fortyGigE1/3/13 -Ethernet45 47,48 fortyGigE1/3/14 -Ethernet46 41,42 fortyGigE1/3/15 -Ethernet47 43,44 fortyGigE1/3/16 -Ethernet48 113,114 fortyGigE1/4/1 -Ethernet49 115,116 fortyGigE1/4/2 -Ethernet50 117,118 fortyGigE1/4/3 -Ethernet51 119,120 fortyGigE1/4/4 -Ethernet52 1,2 fortyGigE1/4/5 -Ethernet53 3,4 fortyGigE1/4/6 -Ethernet54 5,6 fortyGigE1/4/7 -Ethernet55 7,8 fortyGigE1/4/8 -Ethernet56 33,34 fortyGigE1/4/9 -Ethernet57 35,36 fortyGigE1/4/10 -Ethernet58 37,38 fortyGigE1/4/11 -Ethernet59 39,40 fortyGigE1/4/12 -Ethernet60 81,82 fortyGigE1/4/13 -Ethernet61 83,84 fortyGigE1/4/14 -Ethernet62 85,86 fortyGigE1/4/15 -Ethernet63 87,88 fortyGigE1/4/16 +# name lanes alias index +Ethernet0 101,102 fortyGigE1/1/1 0 +Ethernet1 103,104 fortyGigE1/1/2 1 +Ethernet2 97,98 fortyGigE1/1/3 2 +Ethernet3 99,100 fortyGigE1/1/4 3 +Ethernet4 69,70 fortyGigE1/1/5 4 +Ethernet5 71,72 fortyGigE1/1/6 5 +Ethernet6 65,66 fortyGigE1/1/7 6 +Ethernet7 67,68 fortyGigE1/1/8 7 +Ethernet8 53,54 fortyGigE1/1/9 8 +Ethernet9 55,56 fortyGigE1/1/10 9 +Ethernet10 49,50 fortyGigE1/1/11 10 +Ethernet11 51,52 fortyGigE1/1/12 11 +Ethernet12 21,22 fortyGigE1/1/13 12 +Ethernet13 23,24 fortyGigE1/1/14 13 +Ethernet14 17,18 fortyGigE1/1/15 14 +Ethernet15 19,20 fortyGigE1/1/16 15 +Ethernet16 25,26 fortyGigE1/2/1 16 +Ethernet17 27,28 fortyGigE1/2/2 17 +Ethernet18 29,30 fortyGigE1/2/3 18 +Ethernet19 31,32 fortyGigE1/2/4 19 +Ethernet20 57,58 fortyGigE1/2/5 20 +Ethernet21 59,60 fortyGigE1/2/6 21 +Ethernet22 61,62 fortyGigE1/2/7 22 +Ethernet23 63,64 fortyGigE1/2/8 23 +Ethernet24 73,74 fortyGigE1/2/9 24 +Ethernet25 75,76 fortyGigE1/2/10 25 +Ethernet26 77,78 fortyGigE1/2/11 26 +Ethernet27 79,80 fortyGigE1/2/12 27 +Ethernet28 105,106 fortyGigE1/2/13 28 +Ethernet29 107,108 fortyGigE1/2/14 29 +Ethernet30 109,110 fortyGigE1/2/15 30 +Ethernet31 111,112 fortyGigE1/2/16 31 +Ethernet32 13,14 fortyGigE1/3/1 32 +Ethernet33 15,16 fortyGigE1/3/2 33 +Ethernet34 9,10 fortyGigE1/3/3 34 +Ethernet35 11,12 fortyGigE1/3/4 35 +Ethernet36 125,126 fortyGigE1/3/5 36 +Ethernet37 127,128 fortyGigE1/3/6 37 +Ethernet38 121,122 fortyGigE1/3/7 38 +Ethernet39 123,124 fortyGigE1/3/8 39 +Ethernet40 93,94 fortyGigE1/3/9 40 +Ethernet41 95,96 fortyGigE1/3/10 41 +Ethernet42 89,90 fortyGigE1/3/11 42 +Ethernet43 91,92 fortyGigE1/3/12 43 +Ethernet44 45,46 fortyGigE1/3/13 44 +Ethernet45 47,48 fortyGigE1/3/14 45 +Ethernet46 41,42 fortyGigE1/3/15 46 +Ethernet47 43,44 fortyGigE1/3/16 47 +Ethernet48 113,114 fortyGigE1/4/1 48 +Ethernet49 115,116 fortyGigE1/4/2 49 +Ethernet50 117,118 fortyGigE1/4/3 50 +Ethernet51 119,120 fortyGigE1/4/4 51 +Ethernet52 1,2 fortyGigE1/4/5 52 +Ethernet53 3,4 fortyGigE1/4/6 53 +Ethernet54 5,6 fortyGigE1/4/7 54 +Ethernet55 7,8 fortyGigE1/4/8 55 +Ethernet56 33,34 fortyGigE1/4/9 56 +Ethernet57 35,36 fortyGigE1/4/10 57 +Ethernet58 37,38 fortyGigE1/4/11 58 +Ethernet59 39,40 fortyGigE1/4/12 59 +Ethernet60 81,82 fortyGigE1/4/13 60 +Ethernet61 83,84 fortyGigE1/4/14 61 +Ethernet62 85,86 fortyGigE1/4/15 62 +Ethernet63 87,88 fortyGigE1/4/16 63 diff --git a/src/sonic-utilities b/src/sonic-utilities index 0ad528043019..5d8f98eeae60 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit 0ad52804301903664dfe8f84ef1666101c950cd2 +Subproject commit 5d8f98eeae60f1b5c6c5d6ad7cb4c31019558efd From e68d9a2a5968ff170ecf4b1dc3217563a307ec64 Mon Sep 17 00:00:00 2001 From: lguohan Date: Thu, 29 Jun 2017 01:38:05 -0700 Subject: [PATCH 38/45] [igb]: change download url to azure storage url (#770) --- src/igb/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/igb/Makefile b/src/igb/Makefile index afa7a676748b..e814ce0a7db7 100644 --- a/src/igb/Makefile +++ b/src/igb/Makefile @@ -6,7 +6,7 @@ MAIN_TARGET = igb.ko $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : rm -rf ./igb-$(IGB_DRIVER_VERSION) - wget -O igb-$(IGB_DRIVER_VERSION).tar.gz "https://downloadmirror.intel.com/13663/eng/igb-$(IGB_DRIVER_VERSION).tar.gz" + wget -O igb-$(IGB_DRIVER_VERSION).tar.gz "https://sonicstorage.blob.core.windows.net/packages/igb-5.3.5.4.tar.gz?sv=2015-04-05&sr=b&sig=Y7pO2Y%2FLTdQe1XucyRhMZdbHV5duAdvRYOqgJ5D7l4c%3D&se=2031-03-08T08%3A31%3A39Z&sp=r" tar xzf igb-$(IGB_DRIVER_VERSION).tar.gz # Patch From 3ac724ecb030786462308c2d53ba66d65a8ea184 Mon Sep 17 00:00:00 2001 From: pavel-shirshov Date: Thu, 29 Jun 2017 01:40:22 -0700 Subject: [PATCH 39/45] [baseimage]: Increase net.core.rmem_max to 2097152 (#767) * Increase net.core.rmem_max to 2097152 --- build_debian.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build_debian.sh b/build_debian.sh index 71f849151a94..1e18ec45afbc 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -265,6 +265,8 @@ set /files/etc/sysctl.conf/net.ipv6.conf.default.accept_dad 0 set /files/etc/sysctl.conf/net.ipv6.conf.all.accept_dad 0 set /files/etc/sysctl.conf/net.ipv6.conf.eth0.accept_ra_defrtr 0 + +set /files/etc/sysctl.conf/net.core.rmem_max 2097152 " -r $FILESYSTEM_ROOT ## docker-py is needed by Ansible docker module From 3f570a4cbf050389d5106373b7746e4443b54913 Mon Sep 17 00:00:00 2001 From: wadelnn Date: Thu, 29 Jun 2017 16:41:12 +0800 Subject: [PATCH 40/45] Update Ingrasys platform submodule (#764) * Remove specific fancontrol service. Signed-off-by: Wade He --- platform/broadcom/sonic-platform-modules-ingrasys | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/broadcom/sonic-platform-modules-ingrasys b/platform/broadcom/sonic-platform-modules-ingrasys index 8d0229c94865..50471fdaaa48 160000 --- a/platform/broadcom/sonic-platform-modules-ingrasys +++ b/platform/broadcom/sonic-platform-modules-ingrasys @@ -1 +1 @@ -Subproject commit 8d0229c94865228eff63c0d79396d0b924d7c6b1 +Subproject commit 50471fdaaa4849c19a97d8623971450f09903d5d From 39bd495ea93351a5e71444c86f3f4d1cfff07deb Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Thu, 29 Jun 2017 10:50:53 -0700 Subject: [PATCH 41/45] [Broadcom]: Update SAI package to support Celestica Seastone DX010 and Accton AS7716 (#768) --- platform/broadcom/sai.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index 130520298120..fc2503fa41b4 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,9 +1,9 @@ -BRCM_SAI = libsaibcm_2.1.5.1-12-20170607194342.44_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/libsaibcm_2.1.5.1-12-20170607194342.44_amd64.deb?sv=2015-04-05&sr=b&sig=gJJVxVT2o%2Bm14%2BwCBYFmBfcrDCzBA4b4iSmDKxnS13o%3D&se=2031-02-26T17%3A39%3A50Z&sp=r" +BRCM_SAI = libsaibcm_2.1.5.1-14-20170627090913.47_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/libsaibcm_2.1.5.1-14-20170627090913.47_amd64.deb?sv=2015-04-05&sr=b&sig=MqrcsnIaaFfekaAqcjgbi0mDl94BJ9eRsslLJrp23q8%3D&se=2031-03-06T22%3A29%3A19Z&sp=r" -BRCM_SAI_DEV = libsaibcm-dev_2.1.5.1-12-20170607194342.44_amd64.deb +BRCM_SAI_DEV = libsaibcm-dev_2.1.5.1-14-20170627090913.47_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/libsaibcm-dev_2.1.5.1-12-20170607194342.44_amd64.deb?sv=2015-04-05&sr=b&sig=AfYK3Qz%2FTV61E89u0kASm7wF3LEiqaZb%2Fde2jvbw9yk%3D&se=2031-02-26T17%3A40%3A14Z&sp=r" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/libsaibcm-dev_2.1.5.1-14-20170627090913.47_amd64.deb?sv=2015-04-05&sr=b&sig=GyAwaEdgSFGXbbFq%2FN2RgSKQ5%2Fc73NgxKMMKq3RVZw0%3D&se=2031-03-06T22%3A29%3A48Z&sp=r" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV) $(BRCM_SAI)_DEPENDS += $(BRCM_OPENNSL) From bce5446dc4098af2b5d45a7b721509a42e47a89d Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 29 Jun 2017 16:37:37 -0700 Subject: [PATCH 42/45] [LLDP]: Port description (TLV 4) now contains ':' (#772) --- dockers/docker-lldp-sv2/lldpd.conf.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-lldp-sv2/lldpd.conf.j2 b/dockers/docker-lldp-sv2/lldpd.conf.j2 index 1943c04ed73f..e3d37d091150 100644 --- a/dockers/docker-lldp-sv2/lldpd.conf.j2 +++ b/dockers/docker-lldp-sv2/lldpd.conf.j2 @@ -1,3 +1,3 @@ {% for member in minigraph_ports.keys() %} -configure ports {{member}} lldp portidsubtype local {{minigraph_ports[member]['alias']}} +configure ports {{ member }} lldp portidsubtype local {{ minigraph_ports[member]['alias'] }} description {{ minigraph_neighbors[member]['name'] }}:{{ minigraph_neighbors[member]['port'] }} {% endfor %} From e31e1f77779e960874d193e310f2a38d84d422b3 Mon Sep 17 00:00:00 2001 From: lguohan Date: Thu, 29 Jun 2017 22:21:12 -0700 Subject: [PATCH 43/45] [sonic-slave]: install docker-ce 17.03.02 stable version (#774) --- sonic-slave/Dockerfile | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sonic-slave/Dockerfile b/sonic-slave/Dockerfile index 5757eb1d8693..20a7fbad89eb 100644 --- a/sonic-slave/Dockerfile +++ b/sonic-slave/Dockerfile @@ -228,8 +228,21 @@ EXPOSE 22 RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /usr/share/depot_tools ENV PATH /usr/share/depot_tools:$PATH -# Install docker engine 1.13.0 inside docker and enable experimental feature -RUN curl -sSL https://get.docker.com/ | sh && apt-get install -y --force-yes -q docker-engine=1.13.0-0~debian-jessie +# Install docker engine 17.03.2~ce-0 inside docker and enable experimental feature +RUN apt-get update +RUN apt-get install -y \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg2 \ + software-properties-common +RUN curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - +RUN add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/debian \ + $(lsb_release -cs) \ + stable" +RUN apt-get update +RUN apt-get install -y docker-ce=17.03.2~ce-0~debian-jessie RUN echo "DOCKER_OPTS=\"--experimental\"" >> /etc/default/docker # Add user From e904b3bf46bd34c86b46889f9f9c644c8ba6cc48 Mon Sep 17 00:00:00 2001 From: lguohan Date: Fri, 30 Jun 2017 10:28:39 -0700 Subject: [PATCH 44/45] [device]: add minigraph and LED support for Arista 7050 QX32S (#773) --- .../port_config.ini | 0 .../sai.profile | 0 .../x86_64-arista_7050_qx32s/minigraph.xml | 1079 +++++++++++++++++ .../plugins/led_control.py | 84 ++ 4 files changed, 1163 insertions(+) rename device/arista/x86_64-arista_7050_qx32s/{Arista-7050-QX32S => Arista-7050-QX-32S}/port_config.ini (100%) rename device/arista/x86_64-arista_7050_qx32s/{Arista-7050-QX32S => Arista-7050-QX-32S}/sai.profile (100%) create mode 100644 device/arista/x86_64-arista_7050_qx32s/minigraph.xml create mode 100644 device/arista/x86_64-arista_7050_qx32s/plugins/led_control.py diff --git a/device/arista/x86_64-arista_7050_qx32s/Arista-7050-QX32S/port_config.ini b/device/arista/x86_64-arista_7050_qx32s/Arista-7050-QX-32S/port_config.ini similarity index 100% rename from device/arista/x86_64-arista_7050_qx32s/Arista-7050-QX32S/port_config.ini rename to device/arista/x86_64-arista_7050_qx32s/Arista-7050-QX-32S/port_config.ini diff --git a/device/arista/x86_64-arista_7050_qx32s/Arista-7050-QX32S/sai.profile b/device/arista/x86_64-arista_7050_qx32s/Arista-7050-QX-32S/sai.profile similarity index 100% rename from device/arista/x86_64-arista_7050_qx32s/Arista-7050-QX32S/sai.profile rename to device/arista/x86_64-arista_7050_qx32s/Arista-7050-QX-32S/sai.profile diff --git a/device/arista/x86_64-arista_7050_qx32s/minigraph.xml b/device/arista/x86_64-arista_7050_qx32s/minigraph.xml new file mode 100644 index 000000000000..efd30582947a --- /dev/null +++ b/device/arista/x86_64-arista_7050_qx32s/minigraph.xml @@ -0,0 +1,1079 @@ + + + + + + ARISTA01T0 + 10.0.0.33 + switch1 + 10.0.0.32 + 1 + 180 + 60 + + + switch1 + 10.0.0.0 + ARISTA01T2 + 10.0.0.1 + 1 + 180 + 60 + + + ARISTA02T0 + 10.0.0.35 + switch1 + 10.0.0.34 + 1 + 180 + 60 + + + switch1 + 10.0.0.2 + ARISTA02T2 + 10.0.0.3 + 1 + 180 + 60 + + + ARISTA03T0 + 10.0.0.37 + switch1 + 10.0.0.36 + 1 + 180 + 60 + + + switch1 + 10.0.0.4 + ARISTA03T2 + 10.0.0.5 + 1 + 180 + 60 + + + ARISTA04T0 + 10.0.0.39 + switch1 + 10.0.0.38 + 1 + 180 + 60 + + + switch1 + 10.0.0.6 + ARISTA04T2 + 10.0.0.7 + 1 + 180 + 60 + + + ARISTA05T0 + 10.0.0.41 + switch1 + 10.0.0.40 + 1 + 180 + 60 + + + switch1 + 10.0.0.8 + ARISTA05T2 + 10.0.0.9 + 1 + 180 + 60 + + + ARISTA06T0 + 10.0.0.43 + switch1 + 10.0.0.42 + 1 + 180 + 60 + + + switch1 + 10.0.0.10 + ARISTA06T2 + 10.0.0.11 + 1 + 180 + 60 + + + ARISTA07T0 + 10.0.0.45 + switch1 + 10.0.0.44 + 1 + 180 + 60 + + + switch1 + 10.0.0.12 + ARISTA07T2 + 10.0.0.13 + 1 + 180 + 60 + + + ARISTA08T0 + 10.0.0.47 + switch1 + 10.0.0.46 + 1 + 180 + 60 + + + switch1 + 10.0.0.14 + ARISTA08T2 + 10.0.0.15 + 1 + 180 + 60 + + + ARISTA09T0 + 10.0.0.49 + switch1 + 10.0.0.48 + 1 + 180 + 60 + + + switch1 + 10.0.0.16 + ARISTA09T2 + 10.0.0.17 + 1 + 180 + 60 + + + ARISTA10T0 + 10.0.0.51 + switch1 + 10.0.0.50 + 1 + 180 + 60 + + + switch1 + 10.0.0.18 + ARISTA10T2 + 10.0.0.19 + 1 + 180 + 60 + + + ARISTA11T0 + 10.0.0.53 + switch1 + 10.0.0.52 + 1 + 180 + 60 + + + switch1 + 10.0.0.20 + ARISTA11T2 + 10.0.0.21 + 1 + 180 + 60 + + + ARISTA12T0 + 10.0.0.55 + switch1 + 10.0.0.54 + 1 + 180 + 60 + + + switch1 + 10.0.0.22 + ARISTA12T2 + 10.0.0.23 + 1 + 180 + 60 + + + ARISTA13T0 + 10.0.0.57 + switch1 + 10.0.0.56 + 1 + 180 + 60 + + + switch1 + 10.0.0.24 + ARISTA13T2 + 10.0.0.25 + 1 + 180 + 60 + + + ARISTA14T0 + 10.0.0.59 + switch1 + 10.0.0.58 + 1 + 180 + 60 + + + switch1 + 10.0.0.26 + ARISTA14T2 + 10.0.0.27 + 1 + 180 + 60 + + + ARISTA15T0 + 10.0.0.61 + switch1 + 10.0.0.60 + 1 + 180 + 60 + + + switch1 + 10.0.0.28 + ARISTA15T2 + 10.0.0.29 + 1 + 180 + 60 + + + ARISTA16T0 + 10.0.0.63 + switch1 + 10.0.0.62 + 1 + 180 + 60 + + + switch1 + 10.0.0.30 + ARISTA16T2 + 10.0.0.31 + 1 + 180 + 60 + + + + + 65100 + switch1 + + +
10.0.0.33
+ + +
+ +
10.0.0.1
+ + +
+ +
10.0.0.35
+ + +
+ +
10.0.0.3
+ + +
+ +
10.0.0.37
+ + +
+ +
10.0.0.5
+ + +
+ +
10.0.0.39
+ + +
+ +
10.0.0.7
+ + +
+ +
10.0.0.41
+ + +
+ +
10.0.0.9
+ + +
+ +
10.0.0.43
+ + +
+ +
10.0.0.11
+ + +
+ +
10.0.0.45
+ + +
+ +
10.0.0.13
+ + +
+ +
10.0.0.47
+ + +
+ +
10.0.0.15
+ + +
+ +
10.0.0.49
+ + +
+ +
10.0.0.17
+ + +
+ +
10.0.0.51
+ + +
+ +
10.0.0.19
+ + +
+ +
10.0.0.53
+ + +
+ +
10.0.0.21
+ + +
+ +
10.0.0.55
+ + +
+ +
10.0.0.23
+ + +
+ +
10.0.0.57
+ + +
+ +
10.0.0.25
+ + +
+ +
10.0.0.59
+ + +
+ +
10.0.0.27
+ + +
+ +
10.0.0.61
+ + +
+ +
10.0.0.29
+ + +
+ +
10.0.0.63
+ + +
+ +
10.0.0.31
+ + +
+
+ +
+ + 64001 + ARISTA01T0 + + + + 65200 + ARISTA01T2 + + + + 64002 + ARISTA02T0 + + + + 65200 + ARISTA02T2 + + + + 64003 + ARISTA03T0 + + + + 65200 + ARISTA03T2 + + + + 64004 + ARISTA04T0 + + + + 65200 + ARISTA04T2 + + + + 64005 + ARISTA05T0 + + + + 65200 + ARISTA05T2 + + + + 64006 + ARISTA06T0 + + + + 65200 + ARISTA06T2 + + + + 64007 + ARISTA07T0 + + + + 65200 + ARISTA07T2 + + + + 64008 + ARISTA08T0 + + + + 65200 + ARISTA08T2 + + + + 64009 + ARISTA09T0 + + + + 65200 + ARISTA09T2 + + + + 64010 + ARISTA10T0 + + + + 65200 + ARISTA10T2 + + + + 64011 + ARISTA11T0 + + + + 65200 + ARISTA11T2 + + + + 64012 + ARISTA12T0 + + + + 65200 + ARISTA12T2 + + + + 64013 + ARISTA13T0 + + + + 65200 + ARISTA13T2 + + + + 64014 + ARISTA14T0 + + + + 65200 + ARISTA14T2 + + + + 64015 + ARISTA15T0 + + + + 65200 + ARISTA15T2 + + + + 64016 + ARISTA16T0 + + + + 65200 + ARISTA16T2 + + +
+
+ + + + + + HostIP + Loopback0 + + 10.1.0.32/32 + + 10.1.0.32/32 + + + + + + + + switch1 + + + + + + Ethernet1/1 + 10.0.0.0/31 + + + + Ethernet2/1 + 10.0.0.2/31 + + + + Ethernet3/1 + 10.0.0.4/31 + + + + Ethernet4/1 + 10.0.0.6/31 + + + + Ethernet5/1 + 10.0.0.8/31 + + + + Ethernet6/1 + 10.0.0.10/31 + + + + Ethernet7/1 + 10.0.0.12/31 + + + + Ethernet8/1 + 10.0.0.14/31 + + + + Ethernet9/1 + 10.0.0.16/31 + + + + Ethernet10/1 + 10.0.0.18/31 + + + + Ethernet11/1 + 10.0.0.20/31 + + + + Ethernet12/1 + 10.0.0.22/31 + + + + Ethernet13/1 + 10.0.0.24/31 + + + + Ethernet14/1 + 10.0.0.26/31 + + + + Ethernet15/1 + 10.0.0.28/31 + + + + Ethernet16/1 + 10.0.0.30/31 + + + + Ethernet17/1 + 10.0.0.32/31 + + + + Ethernet18/1 + 10.0.0.34/31 + + + + Ethernet19/1 + 10.0.0.36/31 + + + + Ethernet20/1 + 10.0.0.38/31 + + + + Ethernet21/1 + 10.0.0.40/31 + + + + Ethernet22/1 + 10.0.0.42/31 + + + + Ethernet23/1 + 10.0.0.44/31 + + + + Ethernet24/1 + 10.0.0.46/31 + + + + Ethernet25 + 10.0.0.48/31 + + + + Ethernet26 + 10.0.0.50/31 + + + + Ethernet27 + 10.0.0.52/31 + + + + Ethernet28 + 10.0.0.54/31 + + + + Ethernet29 + 10.0.0.56/31 + + + + Ethernet30 + 10.0.0.58/31 + + + + Ethernet31 + 10.0.0.60/31 + + + + Ethernet32 + 10.0.0.62/31 + + + + + + + + + + + + DeviceInterfaceLink + switch1 + Ethernet1/1 + ARISTA01T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet2/1 + ARISTA02T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet3/1 + ARISTA03T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet4/1 + ARISTA04T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet5/1 + ARISTA05T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet6/1 + ARISTA06T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet7/1 + ARISTA07T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet8/1 + ARISTA08T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet9/1 + ARISTA09T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet10/1 + ARISTA10T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet11/1 + ARISTA11T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet12/1 + ARISTA12T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet13/1 + ARISTA13T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet14/1 + ARISTA14T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet15/1 + ARISTA15T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet16/1 + ARISTA16T2 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet17/1 + ARISTA01T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet18/1 + ARISTA02T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet19/1 + ARISTA03T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet20/1 + ARISTA04T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet21/1 + ARISTA05T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet22/1 + ARISTA06T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet23/1 + ARISTA07T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet24/1 + ARISTA08T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet25 + ARISTA09T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet26 + ARISTA10T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet27 + ARISTA11T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet28 + ARISTA12T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet29 + ARISTA13T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet30 + ARISTA14T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet31 + ARISTA15T0 + Ethernet1 + + + DeviceInterfaceLink + switch1 + Ethernet32 + ARISTA16T0 + Ethernet1 + + + + + switch1 + Arista-7050-QX-32S + + + + + + + switch1 + + + DhcpResources + + + + + NtpResources + + 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org + + + SyslogResources + + + + + ErspanDestinationIpv4 + + 2.2.2.2 + + + + + + + switch1 + Arista-7050-QX-32S +
diff --git a/device/arista/x86_64-arista_7050_qx32s/plugins/led_control.py b/device/arista/x86_64-arista_7050_qx32s/plugins/led_control.py new file mode 100644 index 000000000000..582eaacbf918 --- /dev/null +++ b/device/arista/x86_64-arista_7050_qx32s/plugins/led_control.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python +# +# led_control.py +# +# Platform-specific LED control functionality for SONiC +# + +try: + from sonic_led.led_control_base import LedControlBase +except ImportError, e: + raise ImportError (str(e) + " - required module not found") + + +class LedControl(LedControlBase): + """Platform specific LED control class""" + + SONIC_PORT_NAME_PREFIX = "Ethernet" + + LED_SYSFS_PATH_BREAKOUT_CAPABLE = "/sys/class/leds/qsfp{0}_{1}/brightness" + LED_SYSFS_PATH_NO_BREAKOUT = "/sys/class/leds/qsfp{0}/brightness" + + QSFP_BREAKOUT_START_IDX = 1 + QSFP_BREAKOUT_END_IDX = 24 + QSFP_NO_BREAKOUT_START_IDX = 25 + QSFP_NO_BREAKOUT_END_IDX = 32 + + LED_QSFP_OFFSET = 4 + + LED_COLOR_OFF = 0 + LED_COLOR_GREEN = 1 + LED_COLOR_YELLOW = 2 + + # Helper method to map SONiC port name to Arista QSFP index + def _port_name_to_qsfp_index(self, port_name): + # Strip "Ethernet" off port name + if not port_name.startswith(self.SONIC_PORT_NAME_PREFIX): + return -1 + + sonic_port_num = int(port_name[len(self.SONIC_PORT_NAME_PREFIX):]) + + # SONiC port nums are 0-based and increment by 4 + # Arista QSFP indices are 1-based and increment by 1 + return ((sonic_port_num/4) + 1) + + # Concrete implementation of port_link_state_change() method + def port_link_state_change(self, port, state): + qsfp_index = self._port_name_to_qsfp_index(port) + + # Ignore invalid QSFP indices + if qsfp_index <= 0: + return + + # QSFP indices 1-24 are breakout-capable and have four LEDs, and each LED indicate one lane. + # whereas indices 25-32 are not breakout-capable, and only have one + if qsfp_index <= self.QSFP_BREAKOUT_END_IDX: + # assuming 40G, then we need to control four lanes + led_sysfs_paths = [ self.LED_SYSFS_PATH_BREAKOUT_CAPABLE.format(qsfp_index + self.LED_QSFP_OFFSET, i) for i in range(1, 5) ] + else: + led_sysfs_paths = [ self.LED_SYSFS_PATH_NO_BREAKOUT.format(qsfp_index + self.LED_QSFP_OFFSET) ] + + for led_sysfs_path in led_sysfs_paths: + led_file = open(led_sysfs_path, "w") + + if state == "up": + led_file.write("%d" % self.LED_COLOR_GREEN) + else: + led_file.write("%d" % self.LED_COLOR_OFF) + + led_file.close() + + # Constructor + def __init__(self): + # Initialize: Turn all front panel QSFP LEDs off + for qsfp_index in range(self.QSFP_BREAKOUT_START_IDX, self.QSFP_BREAKOUT_END_IDX + 1): + for lane in range(1, 5): + led_sysfs_path = self.LED_SYSFS_PATH_BREAKOUT_CAPABLE.format(qsfp_index + self.LED_QSFP_OFFSET, lane) + with open(led_sysfs_path, 'w') as led_file: + led_file.write("%d" % self.LED_COLOR_OFF) + + for qsfp_index in range(self.QSFP_NO_BREAKOUT_START_IDX, self.QSFP_NO_BREAKOUT_END_IDX + 1): + led_sysfs_path = self.LED_SYSFS_PATH_NO_BREAKOUT.format(qsfp_index + self.LED_QSFP_OFFSET) + with open(led_sysfs_path, 'w') as led_file: + led_file.write("%d" % self.LED_COLOR_OFF) + From bce4b70987286a1e9071a7eaca2f168f97240a1d Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Fri, 30 Jun 2017 22:33:31 +0000 Subject: [PATCH 45/45] Update submodules: sairedis, swss --- src/sonic-sairedis | 2 +- src/sonic-swss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sonic-sairedis b/src/sonic-sairedis index a8f7f0287a41..38f5ce8bc884 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit a8f7f0287a41740dc12a7bfec62f68de5874ed31 +Subproject commit 38f5ce8bc88452314e97c10dfd4221f79d106a78 diff --git a/src/sonic-swss b/src/sonic-swss index 83363a7e9ee2..009c8620d306 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit 83363a7e9ee27292160261a30c7b0f0e6fbe6a1b +Subproject commit 009c8620d30672d1039fbf299027b7c5a78ff5a4