From 5c2dd1068abd681b1ffaca2d0a006c08a0440e68 Mon Sep 17 00:00:00 2001 From: kaiyu22 Date: Fri, 7 Apr 2017 09:38:20 +0800 Subject: [PATCH 1/2] [platform]: Add plugins for ingrasys * Adding two utilities: eeprom.py and sfputil.py Signed-off-by: Sam Yang --- .../plugins/eeprom.py | 22 +++++++ .../plugins/sfputil.py | 60 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/eeprom.py create mode 100644 device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/sfputil.py diff --git a/device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/eeprom.py b/device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/eeprom.py new file mode 100644 index 000000000000..83bf65a389bd --- /dev/null +++ b/device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/eeprom.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +############################################################################# +# Ingrasys S9100 +# +# Platform and model specific eeprom subclass, inherits from the base class, +# and provides the followings: +# - the eeprom format definition +# - specific encoder/decoder if there is special need +############################################################################# + +try: + from sonic_eeprom import eeprom_tlvinfo +except ImportError, e: + raise ImportError (str(e) + "- required module not found") + + +class board(eeprom_tlvinfo.TlvInfoDecoder): + + def __init__(self, name, path, cpld_root, ro): + self.eeprom_path = "/sys/class/i2c-adapter/i2c-9/9-0054/eeprom" + super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/sfputil.py b/device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/sfputil.py new file mode 100644 index 000000000000..5bbc5d77e863 --- /dev/null +++ b/device/ingrasys/x86_64-ingrasys_s9100-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 = { + 0: 11, + 1: 10, + 2: 13, + 3: 12, + 4: 15, + 5: 14, + 6: 17, + 7: 16, + 8: 19, + 9: 18, + 10: 21, + 11: 20, + 12: 23, + 13: 22, + 14: 25, + 15: 24, + 16: 27, + 17: 26, + 18: 29, + 19: 28, + 20: 31, + 21: 30, + 22: 33, + 23: 32, + 24: 35, + 25: 34, + 26: 37, + 27: 36, + 28: 39, + 29: 38, + 30: 41, + 31: 40 + } + + _qsfp_ports = range(0, ports_in_block + 1) + + def __init__(self, port_num): + # Override port_to_eeprom_mapping for class initialization + eeprom_path = '/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom' + for x in range(0, self.port_end + 1): + port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x]) + self.port_to_eeprom_mapping[x] = port_eeprom_path + sfputilbase.__init__(self, port_num) From 3b5fb54cb6cbcd60e1fce1b7cfd10b63766c41ad Mon Sep 17 00:00:00 2001 From: kaiyu22 Date: Mon, 10 Apr 2017 09:48:57 +0800 Subject: [PATCH 2/2] [platform]: Add plugins for ingrasys * Updated sfputil.py Signed-off-by: Sam Yang --- device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/sfputil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/sfputil.py b/device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/sfputil.py index 5bbc5d77e863..f45502ab9ab4 100644 --- a/device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/sfputil.py +++ b/device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/sfputil.py @@ -54,7 +54,7 @@ class sfputil(sfputilbase): def __init__(self, port_num): # Override port_to_eeprom_mapping for class initialization eeprom_path = '/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom' - for x in range(0, self.port_end + 1): + for x in range(self.port_start, self.port_end + 1): port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x]) self.port_to_eeprom_mapping[x] = port_eeprom_path sfputilbase.__init__(self, port_num)