From f9b719809d5a4ab3e4e44d0920da2de6ac9983b1 Mon Sep 17 00:00:00 2001 From: "Nadiya.Stetskovych" Date: Mon, 24 Apr 2017 12:59:42 +0300 Subject: [PATCH 1/3] Cavm platfrom modules insmod on start Signed-off-by: Nadiya.Stetskovych --- files/build_templates/swss.service.j2 | 2 ++ platform/cavium/cavm_platform_modules/Makefile | 1 + 2 files changed, 3 insertions(+) diff --git a/files/build_templates/swss.service.j2 b/files/build_templates/swss.service.j2 index 1fc9127f260e..27892cef85e6 100644 --- a/files/build_templates/swss.service.j2 +++ b/files/build_templates/swss.service.j2 @@ -24,6 +24,7 @@ ExecStartPre=/sbin/modprobe i2c-dev ExecStartPre=/bin/bash -c "/usr/share/sonic/device/$(sonic-cfggen -v platform)/hw-management start" {% elif sonic_asic_platform == 'cavium' %} ExecStartPre=/etc/init.d/xpnet.sh start +ExecStartPre=/usr/bin/accton_as7512_util.py install {% endif %} ExecStartPre=/usr/bin/{{docker_container_name}}.sh start @@ -40,6 +41,7 @@ ExecStopPost=/usr/bin/mst stop {% elif sonic_asic_platform == 'cavium' %} ExecStopPost=/etc/init.d/xpnet.sh stop ExecStopPost=/etc/init.d/xpnet.sh start +ExecStopPost=/usr/bin/accton_as7512_util.py clean {% endif %} [Install] diff --git a/platform/cavium/cavm_platform_modules/Makefile b/platform/cavium/cavm_platform_modules/Makefile index 515c1571abde..f736765e8ae1 100644 --- a/platform/cavium/cavm_platform_modules/Makefile +++ b/platform/cavium/cavm_platform_modules/Makefile @@ -21,6 +21,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : cp SONiC/AS7512-32X/module/*.ko $(DEB_BUILD_DIR)/lib/modules/$(KVERSION) cp SONiC/AS7512-32X/accton_as7512_util.py $(DEB_BUILD_DIR)/usr/bin + chmod +x $(DEB_BUILD_DIR)/usr/bin/accton_as7512_util.py cp -r DEBIAN $(DEB_BUILD_DIR) dpkg-deb -b $(DEB_BUILD_DIR) $(MAIN_TARGET) From 6cb573f1e96e7f9225d26f7e1ca545e45d5c3cc4 Mon Sep 17 00:00:00 2001 From: "Nadiya.Stetskovych" Date: Mon, 24 Apr 2017 13:06:59 +0300 Subject: [PATCH 2/3] Add as77512 platform utils Signed-off-by: Nadiya.Stetskovych --- .../plugins/eeprom.py | 33 +++++++++++++++++++ .../plugins/sfputil.py | 25 ++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 device/accton/x86_64-accton_as7512_32x-r0/plugins/eeprom.py create mode 100644 device/accton/x86_64-accton_as7512_32x-r0/plugins/sfputil.py diff --git a/device/accton/x86_64-accton_as7512_32x-r0/plugins/eeprom.py b/device/accton/x86_64-accton_as7512_32x-r0/plugins/eeprom.py new file mode 100644 index 000000000000..26990541231f --- /dev/null +++ b/device/accton/x86_64-accton_as7512_32x-r0/plugins/eeprom.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +############################################################################# +# Cavium +# +# Platform and model specific eeprom subclass, inherits from the base class, +# and provides the followings: +# - the eeprom format definition +# - specific encoder/decoder if there is special need +############################################################################# + +try: + import 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" + super(board, self).__init__(self.eeprom_path, 0, '', True) + diff --git a/device/accton/x86_64-accton_as7512_32x-r0/plugins/sfputil.py b/device/accton/x86_64-accton_as7512_32x-r0/plugins/sfputil.py new file mode 100644 index 000000000000..378a18c6b8bd --- /dev/null +++ b/device/accton/x86_64-accton_as7512_32x-r0/plugins/sfputil.py @@ -0,0 +1,25 @@ +#! /usr/bin/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 = {} + _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): + self.port_to_eeprom_mapping[x] = eeprom_path.format(x + 18) + sfputilbase.__init__(self, port_num) From f85b7c1f28d77b67937fa88056cf48be7dffee74 Mon Sep 17 00:00:00 2001 From: "Nadiya.Stetskovych" Date: Mon, 1 May 2017 00:38:40 +0300 Subject: [PATCH 3/3] Move platform related init to platform modules Signed-off-by: Nadiya.Stetskovych --- files/build_templates/swss.service.j2 | 2 -- platform/cavium/cavm_platform_modules/Makefile | 4 ++++ .../as7512-platform-init.service | 13 +++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 platform/cavium/cavm_platform_modules/as7512-platform-init.service diff --git a/files/build_templates/swss.service.j2 b/files/build_templates/swss.service.j2 index 27892cef85e6..1fc9127f260e 100644 --- a/files/build_templates/swss.service.j2 +++ b/files/build_templates/swss.service.j2 @@ -24,7 +24,6 @@ ExecStartPre=/sbin/modprobe i2c-dev ExecStartPre=/bin/bash -c "/usr/share/sonic/device/$(sonic-cfggen -v platform)/hw-management start" {% elif sonic_asic_platform == 'cavium' %} ExecStartPre=/etc/init.d/xpnet.sh start -ExecStartPre=/usr/bin/accton_as7512_util.py install {% endif %} ExecStartPre=/usr/bin/{{docker_container_name}}.sh start @@ -41,7 +40,6 @@ ExecStopPost=/usr/bin/mst stop {% elif sonic_asic_platform == 'cavium' %} ExecStopPost=/etc/init.d/xpnet.sh stop ExecStopPost=/etc/init.d/xpnet.sh start -ExecStopPost=/usr/bin/accton_as7512_util.py clean {% endif %} [Install] diff --git a/platform/cavium/cavm_platform_modules/Makefile b/platform/cavium/cavm_platform_modules/Makefile index f736765e8ae1..13ab41926e38 100644 --- a/platform/cavium/cavm_platform_modules/Makefile +++ b/platform/cavium/cavm_platform_modules/Makefile @@ -5,6 +5,7 @@ SHELL = /bin/bash MAIN_TARGET = cavm_platform_modules.deb DEB_BUILD_DIR = cavm-platform-modules-deb SCRIPT_SRC = $(DEB_BUILD_DIR)/ +SYSTEMD_DIR = /etc/systemd/system $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # get sources @@ -18,10 +19,13 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : popd mkdir -p $(DEB_BUILD_DIR)/lib/modules/$(KVERSION) mkdir -p $(DEB_BUILD_DIR)/usr/bin + mkdir -p $(DEB_BUILD_DIR)$(SYSTEMD_DIR)/multi-user.target.wants/ cp SONiC/AS7512-32X/module/*.ko $(DEB_BUILD_DIR)/lib/modules/$(KVERSION) cp SONiC/AS7512-32X/accton_as7512_util.py $(DEB_BUILD_DIR)/usr/bin chmod +x $(DEB_BUILD_DIR)/usr/bin/accton_as7512_util.py + cp as7512-platform-init.service $(DEB_BUILD_DIR)$(SYSTEMD_DIR) + ln -s $(SYSTEMD_DIR)/as7512-platform-init.service $(DEB_BUILD_DIR)$(SYSTEMD_DIR)/multi-user.target.wants/as7512-platform-init.service cp -r DEBIAN $(DEB_BUILD_DIR) dpkg-deb -b $(DEB_BUILD_DIR) $(MAIN_TARGET) diff --git a/platform/cavium/cavm_platform_modules/as7512-platform-init.service b/platform/cavium/cavm_platform_modules/as7512-platform-init.service new file mode 100644 index 000000000000..69f03c0b2e45 --- /dev/null +++ b/platform/cavium/cavm_platform_modules/as7512-platform-init.service @@ -0,0 +1,13 @@ +[Unit] +Description=Accton AS7512-32X Platform initialization service +Before=pmon.service +DefaultDependencies=no + +[Service] +Type=oneshot +ExecStart=/usr/bin/accton_as7512_util.py install +ExecStop=/usr/bin/accton_as7512_util.py clean +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target