diff --git a/device/inventec/x86_64-inventec_d7032q28b-r0/led_proc_init.soc b/device/inventec/x86_64-inventec_d7032q28b-r0/led_proc_init.soc
new file mode 100644
index 00000000000..39ae1f24792
--- /dev/null
+++ b/device/inventec/x86_64-inventec_d7032q28b-r0/led_proc_init.soc
@@ -0,0 +1,136 @@
+m CMIC_LEDUP0_PORT_ORDER_REMAP_0_3 REMAP_PORT_0=31
+m CMIC_LEDUP0_PORT_ORDER_REMAP_0_3 REMAP_PORT_1=30
+m CMIC_LEDUP0_PORT_ORDER_REMAP_0_3 REMAP_PORT_2=29
+m CMIC_LEDUP0_PORT_ORDER_REMAP_0_3 REMAP_PORT_3=28
+m CMIC_LEDUP0_PORT_ORDER_REMAP_4_7 REMAP_PORT_4=27
+m CMIC_LEDUP0_PORT_ORDER_REMAP_4_7 REMAP_PORT_5=26
+m CMIC_LEDUP0_PORT_ORDER_REMAP_4_7 REMAP_PORT_6=25
+m CMIC_LEDUP0_PORT_ORDER_REMAP_4_7 REMAP_PORT_7=24
+m CMIC_LEDUP0_PORT_ORDER_REMAP_8_11 REMAP_PORT_8=23
+m CMIC_LEDUP0_PORT_ORDER_REMAP_8_11 REMAP_PORT_9=22
+m CMIC_LEDUP0_PORT_ORDER_REMAP_8_11 REMAP_PORT_10=21
+m CMIC_LEDUP0_PORT_ORDER_REMAP_8_11 REMAP_PORT_11=20
+m CMIC_LEDUP0_PORT_ORDER_REMAP_12_15 REMAP_PORT_12=19
+m CMIC_LEDUP0_PORT_ORDER_REMAP_12_15 REMAP_PORT_13=18
+m CMIC_LEDUP0_PORT_ORDER_REMAP_12_15 REMAP_PORT_14=17
+m CMIC_LEDUP0_PORT_ORDER_REMAP_12_15 REMAP_PORT_15=16
+m CMIC_LEDUP0_PORT_ORDER_REMAP_16_19 REMAP_PORT_16=15
+m CMIC_LEDUP0_PORT_ORDER_REMAP_16_19 REMAP_PORT_17=14
+m CMIC_LEDUP0_PORT_ORDER_REMAP_16_19 REMAP_PORT_18=13
+m CMIC_LEDUP0_PORT_ORDER_REMAP_16_19 REMAP_PORT_19=12
+m CMIC_LEDUP0_PORT_ORDER_REMAP_20_23 REMAP_PORT_20=11
+m CMIC_LEDUP0_PORT_ORDER_REMAP_20_23 REMAP_PORT_21=10
+m CMIC_LEDUP0_PORT_ORDER_REMAP_20_23 REMAP_PORT_22=9
+m CMIC_LEDUP0_PORT_ORDER_REMAP_20_23 REMAP_PORT_23=8
+m CMIC_LEDUP0_PORT_ORDER_REMAP_24_27 REMAP_PORT_24=7
+m CMIC_LEDUP0_PORT_ORDER_REMAP_24_27 REMAP_PORT_25=6
+m CMIC_LEDUP0_PORT_ORDER_REMAP_24_27 REMAP_PORT_26=5
+m CMIC_LEDUP0_PORT_ORDER_REMAP_24_27 REMAP_PORT_27=4
+m CMIC_LEDUP0_PORT_ORDER_REMAP_28_31 REMAP_PORT_28=3
+m CMIC_LEDUP0_PORT_ORDER_REMAP_28_31 REMAP_PORT_29=2
+m CMIC_LEDUP0_PORT_ORDER_REMAP_28_31 REMAP_PORT_30=1
+m CMIC_LEDUP0_PORT_ORDER_REMAP_28_31 REMAP_PORT_31=0
+m CMIC_LEDUP0_PORT_ORDER_REMAP_32_35 REMAP_PORT_32=63
+m CMIC_LEDUP0_PORT_ORDER_REMAP_32_35 REMAP_PORT_33=62
+m CMIC_LEDUP0_PORT_ORDER_REMAP_32_35 REMAP_PORT_34=61
+m CMIC_LEDUP0_PORT_ORDER_REMAP_32_35 REMAP_PORT_35=60
+m CMIC_LEDUP0_PORT_ORDER_REMAP_36_39 REMAP_PORT_36=59
+m CMIC_LEDUP0_PORT_ORDER_REMAP_36_39 REMAP_PORT_37=58
+m CMIC_LEDUP0_PORT_ORDER_REMAP_36_39 REMAP_PORT_38=57
+m CMIC_LEDUP0_PORT_ORDER_REMAP_36_39 REMAP_PORT_39=56
+m CMIC_LEDUP0_PORT_ORDER_REMAP_40_43 REMAP_PORT_40=55
+m CMIC_LEDUP0_PORT_ORDER_REMAP_40_43 REMAP_PORT_41=54
+m CMIC_LEDUP0_PORT_ORDER_REMAP_40_43 REMAP_PORT_42=53
+m CMIC_LEDUP0_PORT_ORDER_REMAP_40_43 REMAP_PORT_43=52
+m CMIC_LEDUP0_PORT_ORDER_REMAP_44_47 REMAP_PORT_44=51
+m CMIC_LEDUP0_PORT_ORDER_REMAP_44_47 REMAP_PORT_45=50
+m CMIC_LEDUP0_PORT_ORDER_REMAP_44_47 REMAP_PORT_46=49
+m CMIC_LEDUP0_PORT_ORDER_REMAP_44_47 REMAP_PORT_47=48
+m CMIC_LEDUP0_PORT_ORDER_REMAP_48_51 REMAP_PORT_48=47
+m CMIC_LEDUP0_PORT_ORDER_REMAP_48_51 REMAP_PORT_49=46
+m CMIC_LEDUP0_PORT_ORDER_REMAP_48_51 REMAP_PORT_50=45
+m CMIC_LEDUP0_PORT_ORDER_REMAP_48_51 REMAP_PORT_51=44
+m CMIC_LEDUP0_PORT_ORDER_REMAP_52_55 REMAP_PORT_52=43
+m CMIC_LEDUP0_PORT_ORDER_REMAP_52_55 REMAP_PORT_53=42
+m CMIC_LEDUP0_PORT_ORDER_REMAP_52_55 REMAP_PORT_54=41
+m CMIC_LEDUP0_PORT_ORDER_REMAP_52_55 REMAP_PORT_55=40
+m CMIC_LEDUP0_PORT_ORDER_REMAP_56_59 REMAP_PORT_56=39
+m CMIC_LEDUP0_PORT_ORDER_REMAP_56_59 REMAP_PORT_57=38
+m CMIC_LEDUP0_PORT_ORDER_REMAP_56_59 REMAP_PORT_58=37
+m CMIC_LEDUP0_PORT_ORDER_REMAP_56_59 REMAP_PORT_59=36
+m CMIC_LEDUP0_PORT_ORDER_REMAP_60_63 REMAP_PORT_60=35
+m CMIC_LEDUP0_PORT_ORDER_REMAP_60_63 REMAP_PORT_61=34
+m CMIC_LEDUP0_PORT_ORDER_REMAP_60_63 REMAP_PORT_62=33
+m CMIC_LEDUP0_PORT_ORDER_REMAP_60_63 REMAP_PORT_63=32
+m CMIC_LEDUP1_PORT_ORDER_REMAP_0_3 REMAP_PORT_0=3
+m CMIC_LEDUP1_PORT_ORDER_REMAP_0_3 REMAP_PORT_1=2
+m CMIC_LEDUP1_PORT_ORDER_REMAP_0_3 REMAP_PORT_2=1
+m CMIC_LEDUP1_PORT_ORDER_REMAP_0_3 REMAP_PORT_3=0
+m CMIC_LEDUP1_PORT_ORDER_REMAP_4_7 REMAP_PORT_4=7
+m CMIC_LEDUP1_PORT_ORDER_REMAP_4_7 REMAP_PORT_5=6
+m CMIC_LEDUP1_PORT_ORDER_REMAP_4_7 REMAP_PORT_6=5
+m CMIC_LEDUP1_PORT_ORDER_REMAP_4_7 REMAP_PORT_7=4
+m CMIC_LEDUP1_PORT_ORDER_REMAP_8_11 REMAP_PORT_8=11
+m CMIC_LEDUP1_PORT_ORDER_REMAP_8_11 REMAP_PORT_9=10
+m CMIC_LEDUP1_PORT_ORDER_REMAP_8_11 REMAP_PORT_10=9
+m CMIC_LEDUP1_PORT_ORDER_REMAP_8_11 REMAP_PORT_11=8
+m CMIC_LEDUP1_PORT_ORDER_REMAP_12_15 REMAP_PORT_12=15
+m CMIC_LEDUP1_PORT_ORDER_REMAP_12_15 REMAP_PORT_13=14
+m CMIC_LEDUP1_PORT_ORDER_REMAP_12_15 REMAP_PORT_14=13
+m CMIC_LEDUP1_PORT_ORDER_REMAP_12_15 REMAP_PORT_15=12
+m CMIC_LEDUP1_PORT_ORDER_REMAP_16_19 REMAP_PORT_16=19
+m CMIC_LEDUP1_PORT_ORDER_REMAP_16_19 REMAP_PORT_17=18
+m CMIC_LEDUP1_PORT_ORDER_REMAP_16_19 REMAP_PORT_18=17
+m CMIC_LEDUP1_PORT_ORDER_REMAP_16_19 REMAP_PORT_19=16
+m CMIC_LEDUP1_PORT_ORDER_REMAP_20_23 REMAP_PORT_20=23
+m CMIC_LEDUP1_PORT_ORDER_REMAP_20_23 REMAP_PORT_21=22
+m CMIC_LEDUP1_PORT_ORDER_REMAP_20_23 REMAP_PORT_22=21
+m CMIC_LEDUP1_PORT_ORDER_REMAP_20_23 REMAP_PORT_23=20
+m CMIC_LEDUP1_PORT_ORDER_REMAP_24_27 REMAP_PORT_24=27
+m CMIC_LEDUP1_PORT_ORDER_REMAP_24_27 REMAP_PORT_25=26
+m CMIC_LEDUP1_PORT_ORDER_REMAP_24_27 REMAP_PORT_26=25
+m CMIC_LEDUP1_PORT_ORDER_REMAP_24_27 REMAP_PORT_27=24
+m CMIC_LEDUP1_PORT_ORDER_REMAP_28_31 REMAP_PORT_28=31
+m CMIC_LEDUP1_PORT_ORDER_REMAP_28_31 REMAP_PORT_29=30
+m CMIC_LEDUP1_PORT_ORDER_REMAP_28_31 REMAP_PORT_30=29
+m CMIC_LEDUP1_PORT_ORDER_REMAP_28_31 REMAP_PORT_31=28
+m CMIC_LEDUP1_PORT_ORDER_REMAP_32_35 REMAP_PORT_32=35
+m CMIC_LEDUP1_PORT_ORDER_REMAP_32_35 REMAP_PORT_33=34
+m CMIC_LEDUP1_PORT_ORDER_REMAP_32_35 REMAP_PORT_34=33
+m CMIC_LEDUP1_PORT_ORDER_REMAP_32_35 REMAP_PORT_35=32
+m CMIC_LEDUP1_PORT_ORDER_REMAP_36_39 REMAP_PORT_36=39
+m CMIC_LEDUP1_PORT_ORDER_REMAP_36_39 REMAP_PORT_37=38
+m CMIC_LEDUP1_PORT_ORDER_REMAP_36_39 REMAP_PORT_38=37
+m CMIC_LEDUP1_PORT_ORDER_REMAP_36_39 REMAP_PORT_39=36
+m CMIC_LEDUP1_PORT_ORDER_REMAP_40_43 REMAP_PORT_40=43
+m CMIC_LEDUP1_PORT_ORDER_REMAP_40_43 REMAP_PORT_41=42
+m CMIC_LEDUP1_PORT_ORDER_REMAP_40_43 REMAP_PORT_42=41
+m CMIC_LEDUP1_PORT_ORDER_REMAP_40_43 REMAP_PORT_43=40
+m CMIC_LEDUP1_PORT_ORDER_REMAP_44_47 REMAP_PORT_44=47
+m CMIC_LEDUP1_PORT_ORDER_REMAP_44_47 REMAP_PORT_45=46
+m CMIC_LEDUP1_PORT_ORDER_REMAP_44_47 REMAP_PORT_46=45
+m CMIC_LEDUP1_PORT_ORDER_REMAP_44_47 REMAP_PORT_47=44
+m CMIC_LEDUP1_PORT_ORDER_REMAP_48_51 REMAP_PORT_48=51
+m CMIC_LEDUP1_PORT_ORDER_REMAP_48_51 REMAP_PORT_49=50
+m CMIC_LEDUP1_PORT_ORDER_REMAP_48_51 REMAP_PORT_50=49
+m CMIC_LEDUP1_PORT_ORDER_REMAP_48_51 REMAP_PORT_51=48
+m CMIC_LEDUP1_PORT_ORDER_REMAP_52_55 REMAP_PORT_52=55
+m CMIC_LEDUP1_PORT_ORDER_REMAP_52_55 REMAP_PORT_53=54
+m CMIC_LEDUP1_PORT_ORDER_REMAP_52_55 REMAP_PORT_54=53
+m CMIC_LEDUP1_PORT_ORDER_REMAP_52_55 REMAP_PORT_55=52
+m CMIC_LEDUP1_PORT_ORDER_REMAP_56_59 REMAP_PORT_56=59
+m CMIC_LEDUP1_PORT_ORDER_REMAP_56_59 REMAP_PORT_57=58
+m CMIC_LEDUP1_PORT_ORDER_REMAP_56_59 REMAP_PORT_58=57
+m CMIC_LEDUP1_PORT_ORDER_REMAP_56_59 REMAP_PORT_59=56
+m CMIC_LEDUP1_PORT_ORDER_REMAP_60_63 REMAP_PORT_60=63
+m CMIC_LEDUP1_PORT_ORDER_REMAP_60_63 REMAP_PORT_61=62
+m CMIC_LEDUP1_PORT_ORDER_REMAP_60_63 REMAP_PORT_62=61
+m CMIC_LEDUP1_PORT_ORDER_REMAP_60_63 REMAP_PORT_63=60
+
+led 0 stop
+led 0 prog 02 00 60 F1 12 00 DE F6 70 10 67 47 67 42 77 06 06 F2 60 F0 12 00 06 F0 4A 04 27 67 42 4A 03 27 67 42 4A 07 27 67 42 4A 00 27 67 42 DE F4 70 34 86 F0 77 16 12 00 DE F8 70 40 67 4A 67 42 77 36 3E F1 87 86 F1 81 57 17 27 57 07 27 57 00 00 00
+led 0 start
+
+led 1 stop
+led 1 prog 02 00 60 F1 12 00 DE F6 70 10 67 47 67 42 77 06 06 F2 60 F0 12 00 06 F0 4A 04 27 67 42 4A 03 27 67 42 4A 07 27 67 42 4A 00 27 67 42 DE F4 70 34 86 F0 77 16 12 00 DE F8 70 40 67 4A 67 42 77 36 3E F1 87 86 F1 81 57 17 27 57 07 27 57 00 00 00
+led 1 start
diff --git a/device/inventec/x86_64-inventec_d7032q28b-r0/plugins/sfputil.py b/device/inventec/x86_64-inventec_d7032q28b-r0/plugins/sfputil.py
index 645c76b9f0d..599c8dbd959 100644
--- a/device/inventec/x86_64-inventec_d7032q28b-r0/plugins/sfputil.py
+++ b/device/inventec/x86_64-inventec_d7032q28b-r0/plugins/sfputil.py
@@ -16,6 +16,8 @@ class SfpUtil(SfpUtilBase):
PORT_START = 0
PORT_END = 31
PORTS_IN_BLOCK = 32
+ QSFP_PORT_START = 0
+ QSFP_PORT_END = 31
_port_to_eeprom_mapping = {}
port_to_i2c_mapping = {
@@ -61,6 +63,14 @@ def port_start(self):
def port_end(self):
return self.PORT_END
+ @property
+ def qsfp_port_start(self):
+ return self.QSFP_PORT_START
+
+ @property
+ def qsfp_port_end(self):
+ return self.QSFP_PORT_END
+
@property
def qsfp_ports(self):
return range(0, self.PORTS_IN_BLOCK + 1)
diff --git a/platform/broadcom/sonic-platform-modules-inventec/common/utils/led_proc.py b/platform/broadcom/sonic-platform-modules-inventec/common/utils/led_proc.py
new file mode 100644
index 00000000000..d7846f5148c
--- /dev/null
+++ b/platform/broadcom/sonic-platform-modules-inventec/common/utils/led_proc.py
@@ -0,0 +1,326 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2018 Inventec, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+import os
+import time
+import syslog
+import re
+from sonic_sfp.bcmshell import bcmshell
+
+# =====================================================================
+# global variable init
+# =====================================================================
+
+# define data ram address
+PORT_DATA_OFFSET_ADDR = 0xA0
+PORT_DATA_START_ADDR = 0xF2
+TOTAL_SCAN_BITS_ADDR = 0xF4
+SYNC_START_LEN_ADDR = 0xF6
+SYNC_STOP_LEN_ADDR = 0xF8
+# bit streaming rule for CPLD decode
+TOTAL_SCAN_BITS = None
+SYNC_S = None
+SYNC_P = None
+# define port data for bit streaming
+BIT_LINK = None
+BIT_FAULT = None
+BIT_TX = None
+BIT_RX = None
+BIT_SPEED0 = None
+BIT_SPEED1 = None
+# define port speed
+SPEED_100G = 100
+SPEED_40G = 40
+SPEED_25G = 25
+SPEED_10G = 10
+# the amount of LED processor
+AMOUNT_LED_UP = None
+# define board type
+INV_REDWOOD = "SONiC-Inventec-d7032-100"
+INV_CYPRESS = "SONiC-Inventec-d7054"
+INV_SEQUOIA = ""
+BOARD_TPYE = ""
+EAGLE_CORE = []
+
+PORT_LIST = []
+
+# port status that is auto update by chip in data ram
+# there are two byte to indicate each port status
+'''
+RX equ 0x0 ; received packet
+TX equ 0x1 ; transmitted packet
+COLL equ 0x2 ; collision indicator
+SPEED_C equ 0x3 ; 100 Mbps
+SPEED_M equ 0x4 ; 1000 Mbps
+DUPLEX equ 0x5 ; half/full duplex
+FLOW equ 0x6 ; flow control capable
+LINKUP equ 0x7 ; link down/up status
+LINKEN equ 0x8 ; link disabled/enabled status
+ZERO equ 0xE ; always 0
+ONE equ 0xF ; always 1
+'''
+STATUS_ENABLE = 1<<0
+STATUS_RX = 1<<0
+STATUS_TX = 1<<1
+
+# object is to execute bcm shell command
+BCM_SHELL = None
+
+
+
+# =====================================================================
+# class object
+# =====================================================================
+class Led():
+
+ up = None
+ pfw = None
+
+ def __init__(self, led_number, program_fw):
+ self.up = led_number
+ self.pfw = program_fw
+
+ def led_start(self):
+ BCM_SHELL.cmd("led {0} start".format(self.up))
+ syslog.syslog(syslog.LOG_INFO, "Start Led({0})".format(self.up))
+
+ def led_stop(self):
+ BCM_SHELL.cmd("led {0} stop".format(self.up))
+ syslog.syslog(syslog.LOG_INFO, "Stop Led({0})".format(self.up))
+
+ def load_prog(self):
+ BCM_SHELL.cmd("led {0} prog {1}".format(self.up, self.pfw))
+ syslog.syslog(syslog.LOG_INFO, "Load Led({0}) program firmware".format(self.up))
+
+ def write_port_data(self, addr, data):
+ BCM_SHELL.cmd("setreg CMIC_LEDUP{0}_DATA_RAM({1}) {2}".format(self.up, addr, data))
+ syslog.syslog(syslog.LOG_DEBUG, "Write Led({0}) data_ram({1}): {2}".format(self.up, addr, data))
+
+ def read_data_ram(self, offset):
+ return_string = BCM_SHELL.run("getreg CMIC_LEDUP{0}_DATA_RAM({1})".format(self.up, offset))
+ for line in return_string.split("\n"):
+ re_obj = re.search(r"\.+)\>",line)
+ if re_obj is not None:
+ syslog.syslog(syslog.LOG_DEBUG, "Read Led({0}) data_ram({1}): {2}".format(self.up, offset, re_obj.group("data")))
+ return int(re_obj.group("data"), 16)
+
+ return None
+
+
+# =====================================================================
+# Function
+# =====================================================================
+def _remap_registers():
+
+ fp = open('/usr/share/sonic/device/x86_64-inventec_d7032q28b-r0/led_proc_init.soc', "r")
+ content = fp.readlines()
+ fp.close()
+ err = False
+
+ for line in content:
+ try:
+ BCM_SHELL.cmd(line.rstrip())
+ except Exception, e:
+ err = True
+ syslog.syslog(syslog.LOG_ERR, "remap register abnormal: {0}".format(str(e)))
+
+ if not err:
+ syslog.syslog(syslog.LOG_DEBUG, "remap Led registers successfully")
+
+
+
+def _update_port_list():
+
+ global PORT_LIST
+ PORT_LIST = []
+ number = 0
+ count = 0
+
+ content = BCM_SHELL.run("ps")
+ for line in content.split("\n"):
+ re_obj = re.search(r"(?P(xe|ce)\d+)\(\s*(?P\d+)\)\s+(?P(up|down|!ena)).+\s+(?P\d+)G",line)
+ if re_obj is not None:
+ if int(re_obj.group("bcm_id")) not in EAGLE_CORE:
+ PORT_LIST.append({"port_id":number, "name":re_obj.group("port_name"), "bcm_id":int(re_obj.group("bcm_id")), "link":re_obj.group("link"), "speed":int(re_obj.group("speed"))})
+ number += 1
+
+ content = BCM_SHELL.run("led status")
+ for line in content.split("\n"):
+ re_obj = re.search(r"(?P\d+).+(?P\d)\:(?P\d+)",line)
+ if re_obj is not None:
+ if int(re_obj.group("bcm_id")) not in EAGLE_CORE:
+ PORT_LIST[count]["led_up"] = int(re_obj.group("led_up"))
+ PORT_LIST[count]["offset"] = int(re_obj.group("offset"))
+ count += 1
+
+ if number is not count:
+ PORT_LIST = []
+ syslog.syslog(syslog.LOG_ERR, "The amount of port is not match")
+ else:
+ syslog.syslog(syslog.LOG_DEBUG, "update port list successfully")
+
+
+
+def _lookup_led_index(p):
+
+ index = 0
+ for port in PORT_LIST:
+ if p["bcm_id"] == port["bcm_id"]:
+ break
+ if p["led_up"] == port["led_up"]:
+ index += 1
+ return index + PORT_DATA_OFFSET_ADDR
+
+
+
+def _led_init():
+
+ global BOARD_TPYE
+ global AMOUNT_LED_UP
+ global BIT_LINK
+ global BIT_FAULT
+ global BIT_TX
+ global BIT_RX
+ global BIT_SPEED0
+ global BIT_SPEED1
+ global EAGLE_CORE
+ global TOTAL_SCAN_BITS
+ global SYNC_S
+ global SYNC_P
+
+ cmd = "uname -n"
+ platform = os.popen(cmd).read()
+
+ if platform.rstrip() == INV_REDWOOD:
+ BOARD_TPYE = "inventec_d7032q28b"
+ AMOUNT_LED_UP = 2
+ BIT_RX = 1<<0 #0x01
+ BIT_TX = 1<<1 #0x02
+ BIT_SPEED0 = 1<<3 #0x08
+ BIT_SPEED1 = 1<<4 #0x10
+ BIT_FAULT = 1<<6 #0x40
+ BIT_LINK = 1<<7 #0x80
+ TOTAL_SCAN_BITS = 32*1*4
+ SYNC_S = 15
+ SYNC_P = 3
+ EAGLE_CORE = [66, 100]
+ _remap_registers()
+
+ elif platform.rstrip() == INV_CYPRESS:
+ BOARD_TPYE = "inventec_d7054q28b"
+ AMOUNT_LED_UP = 2
+ BIT_LINK = 1<<0 #0x01
+ BIT_FAULT = 1<<1 #0x02
+ BIT_SPEED0 = 1<<2 #0x04
+ EAGLE_CORE = [66, 100]
+
+ elif platform.rstrip() == INV_SEQUOIA:
+ BOARD_TPYE = "inventec_d7264q28b"
+ AMOUNT_LED_UP = 4
+
+ else:
+ BOARD_TPYE = "not found"
+
+ syslog.syslog(syslog.LOG_INFO, "Device: {0}".format(BOARD_TPYE))
+ syslog.syslog(syslog.LOG_DEBUG, "led_amount: {0}".format(AMOUNT_LED_UP))
+
+
+
+if __name__ == "__main__":
+
+ waitSyncd = True
+ retryCount = 0
+ syslog.openlog("led_proc", syslog.LOG_PID, facility=syslog.LOG_DAEMON)
+
+ while waitSyncd:
+ try:
+ BCM_SHELL = bcmshell()
+ waitSyncd = False
+ except Exception, e:
+ syslog.syslog(syslog.LOG_WARNING, "{0}, Retry times({1})".format(str(e),retryCount))
+ retryCount += 1
+ time.sleep(5)
+
+
+ _led_init()
+ led_obj = []
+ for idx in range(AMOUNT_LED_UP):
+ led_obj.append(Led(idx, ""))
+ syslog.syslog(syslog.LOG_DEBUG, "create object led({0}) successfully".format(idx))
+
+ if BOARD_TPYE == "inventec_d7032q28b":
+ led_obj[idx].write_port_data(PORT_DATA_START_ADDR, PORT_DATA_OFFSET_ADDR)
+ led_obj[idx].write_port_data(TOTAL_SCAN_BITS_ADDR, TOTAL_SCAN_BITS)
+ led_obj[idx].write_port_data(SYNC_START_LEN_ADDR, SYNC_S)
+ led_obj[idx].write_port_data(SYNC_STOP_LEN_ADDR, SYNC_P)
+
+
+ reset_sec = 2
+ count_down = 0
+ queue_active = []
+ port_data = None
+ while True:
+ if count_down == 0:
+ queue_active = []
+ _update_port_list()
+ for port in PORT_LIST:
+ if port["link"] == "up":
+ queue_active.append(port)
+ else:
+ port_data = 0
+ # redwood bit streaming for CPLD decode is only use led up0
+ led_obj[0].write_port_data(PORT_DATA_OFFSET_ADDR + port["port_id"], port_data)
+ count_down = reset_sec
+ else:
+ for port in queue_active:
+ port_data = 0
+
+ if BOARD_TPYE == "inventec_d7032q28b":
+ port_data |= BIT_LINK
+ addr = 2*(port["offset"]-1)
+ byte1 = led_obj[port["led_up"]].read_data_ram(addr)
+ byte2 = led_obj[port["led_up"]].read_data_ram(addr+1)
+ if byte1&STATUS_RX:
+ port_data |= BIT_RX
+ if byte1&STATUS_TX:
+ port_data |= BIT_TX
+ if port["speed"] == SPEED_100G:
+ port_data |= BIT_SPEED0
+ port_data |= BIT_SPEED1
+ elif port["speed"] == SPEED_40G:
+ port_data |= BIT_SPEED1
+ elif port["speed"] == SPEED_25G:
+ port_data |= BIT_SPEED0
+ else:
+ pass
+
+ # redwood bit streaming for CPLD decode is only use led up0
+ led_obj[0].write_port_data(PORT_DATA_OFFSET_ADDR + port["port_id"], port_data)
+ continue
+
+ elif BOARD_TPYE == "inventec_d7054q28b":
+ if port["speed"] != SPEED_100G and port["speed"] != SPEED_25G:
+ port_data |= BIT_SPEED0
+
+ led_index = _lookup_led_index(port)
+ led_obj[port["led_up"]].write_port_data(led_index, port_data)
+
+ time.sleep(0.5)
+ count_down -= 1
+
+ syslog.closelog()
+
diff --git a/platform/broadcom/sonic-platform-modules-inventec/common/utils/transceiver_monitor.py b/platform/broadcom/sonic-platform-modules-inventec/common/utils/transceiver_monitor.py
new file mode 100644
index 00000000000..22d71fe9249
--- /dev/null
+++ b/platform/broadcom/sonic-platform-modules-inventec/common/utils/transceiver_monitor.py
@@ -0,0 +1,291 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2018 Inventec, Inc.
+#
+# Editor: James Huang ( Huang.James@inventec.com )
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Usage: %(scriptName)s [options] command object
+
+Auto detecting the transceiver and set the correct if_type value
+
+options:
+ -h | --help : this help message
+ -d | --debug : run with debug mode
+
+"""
+
+try:
+ import os
+ import commands
+ import sys, getopt
+ import logging
+ import re
+ import time
+ import datetime
+ import syslog
+ from sfputil import SfpUtil
+ from sonic_sfp.bcmshell import bcmshell
+
+except ImportError as e:
+ raise ImportError("%s - required module not found" % str(e))
+
+DEBUG = False
+args = []
+INV_REDWOOD_PLATFORM = "SONiC-Inventec-d7032-100"
+INV_CYPRESS_PLATFORM = "SONiC-Inventec-d7054"
+INV_SEQORIA_PLATFORM = "SONiC-Inventec-d7264"
+
+transceiver_type_dict = {
+ "FCBG110SD1C03": "SR",
+ "FCBG110SD1C05": "SR",
+ "FTLX8571D3BCL": "SR",
+ "FTLX8574D3BCL": "SR",
+ "AFBR-709DMZ": "SR",
+ "AFBR-709SMZ": "SR",
+ "FTLX8571D3BCV": "SR",
+ "FTLX1471D3BCL": "SR",
+ "FTLX1871M3BCL": "SR",
+ "FTLF8536P4BCL": "SR",
+ "FCBG125SD1C05": "SR",
+ "FCBG125SD1C30": "SR",
+ "FCBG410QB1C03-1E": "SR4",
+ "FCBG4100QB1C030-1E": "SR4",
+ "885350163": "SR4",
+ "88535017": "SR4",
+ "FTL410QE2C": "SR4",
+ "FTL410QD3C": "SR4",
+ "FTL410QD2C": "SR4",
+ "AFBR-79E3PZ": "SR4",
+ "AFBR-79Q4Z": "SR4",
+ "FTL4C1QE1C": "SR4",
+ "FTLC9551REPM": "SR4",
+ "FTLC1151RDPL": "SR4",
+ "L0HSF006-SD-R": "KR",
+ "L0HSF007-SD-R": "KR",
+ "L0HSF008-SD-R": "KR",
+ "L0HQF009-SD-R": "KR"
+ }
+
+
+initial_command = []
+
+def show_help():
+ print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
+ sys.exit(0)
+
+def log_message( string ):
+ syslog.openlog("transceiver_monitor", syslog.LOG_PID, facility=syslog.LOG_DAEMON)
+ syslog.syslog(syslog.LOG_NOTICE, string)
+
+class BCMUtil(bcmshell):
+
+ port_to_bcm_mapping = dict()
+ sal_config_list = dict()
+ eagle_list = []
+
+ def get_port_to_bcm_mapping(self):
+ if self.port_to_bcm_mapping is None:
+ return dict()
+ else:
+ return self.port_to_bcm_mapping
+
+ def show_port_to_bcm_mapping(self):
+ print self.port_to_bcm_mapping
+
+ def get_eagle_port(self):
+ return self.eagle_list
+
+ def parsing_eagle_port(self):
+ name = os.popen("uname -n").read().strip()
+ if name is not None:
+ if name == INV_REDWOOD_PLATFORM:
+ self.eagle_list = [66,100]
+ elif name == INV_CYPRESS_PLATFORM:
+ self.eagle_list = [66,100]
+ elif name == INV_SEQORIA_PLATFORM:
+ self.eagle_list = [66,100]
+ else:
+ self.eagle_list = []
+
+ def get_sal_config_list(self):
+ return self.sal_config_list
+
+ def show_sal_config_list(self):
+ print self.sal_config_list
+
+ def initial_sal_config_list( self ):
+ content = self.run("config")
+ for line in content.split("\n"):
+ ConfigObject = re.search(r"portmap\_(?P\d+)\=(?P\d+)\:\d+",line)
+ if ConfigObject is not None:
+ if int(ConfigObject.group("bcm_id")) not in self.get_eagle_port():
+ self.get_sal_config_list()[int(ConfigObject.group("bcm_id"))]={"lane": int(ConfigObject.group("lane_id")), "speed": None, "portname": None}
+
+ def parsing_port_list(self):
+ content = self.run("ps")
+ count = 0
+ for line in content.split("\n"):
+ PSObject = re.search(r"(?P(xe|ce)\d+)\(\s*(?P\d+)\).+\s+(?P\d+)G",line)
+ if PSObject is not None:
+ if int(PSObject.group("bcm_id")) not in self.get_eagle_port():
+ if self.get_sal_config_list().has_key(int(PSObject.group("bcm_id"))):
+ self.get_sal_config_list()[int(PSObject.group("bcm_id"))]["portname"] = PSObject.group("port_name")
+ self.get_sal_config_list()[int(PSObject.group("bcm_id"))]["speed"] = int(PSObject.group("speed"))
+ self.port_to_bcm_mapping[count] = int(PSObject.group("bcm_id"))
+ count = count +1
+
+
+ def execute_command(self, cmd):
+ self.cmd(cmd)
+
+class TransceiverUtil(SfpUtil):
+
+ transceiver_port_mapping = dict()
+
+ def get_transceiver_port_mapping(self):
+ return self.transceiver_port_mapping
+
+ def show_transceiver_port_mapping(self):
+ print self.transceiver_port_mapping
+
+ def get_bcm_port_name(self, index):
+ if self.transceiver_port_mapping.has_key(index) and bcm_obj.get_sal_config_list().has_key(self.transceiver_port_mapping[index]["bcm"]):
+ return bcm_obj.get_sal_config_list()[self.transceiver_port_mapping[index]["bcm"]]["portname"]
+ else:
+ return ""
+
+ def get_port_to_i2c_mapping(self):
+ if self.port_to_i2c_mapping is None:
+ return dict()
+ else:
+ return self.port_to_i2c_mapping
+
+ def show_port_to_i2c_mapping(self):
+ print self.port_to_i2c_mapping
+
+ def get_eeprom_partNum(self, portNum):
+ tempdict = dict()
+ tempdict = self.get_eeprom_dict(portNum)
+ self.get_eeprom_partNum_from_parser_eeprom_dict(tempdict)
+
+ def get_eeprom_dict_info(self, portNum):
+ return self.get_eeprom_dict(portNum)
+
+ def get_eeprom_partNum_from_parser_eeprom_dict(self, tempdict ):
+ if tempdict is not None:
+ if tempdict["interface"]["data"].has_key("VendorPN"):
+ return tempdict["interface"]["data"]["VendorPN"]
+ elif tempdict["interface"]["data"].has_key("Vendor PN"):
+ return tempdict["interface"]["data"]["Vendor PN"]
+ else:
+ return None
+ else:
+ return None
+
+ def get_transceiver_type(self, pn ):
+ if pn is not None:
+ if transceiver_type_dict.has_key(pn.upper()):
+ return transceiver_type_dict[pn.upper()]
+ else:
+ return None
+ def set_transceiver_type( self, portNum, pn ):
+ type = self.get_transceiver_type( pn )
+ if type is not None:
+ bcm_obj.execute_command( "port %s if=%s" % ( self.get_bcm_port_name(portNum), type ) )
+ log_message( "Detecting port {0} need to change interface type {1} ({2})".format(self.get_bcm_port_name(portNum), type, self.get_transceiver_port_mapping()[portNum]["pn"]) )
+
+ def initial_transceiver_port_mapping(self):
+ for index in self.get_port_to_i2c_mapping().keys():
+ if self.transceiver_port_mapping.has_key(index) is False :
+ i2cValue = self.get_port_to_i2c_mapping()[index]
+ bcmValue = bcm_obj.get_port_to_bcm_mapping()[index]
+ self.transceiver_port_mapping[index]={"i2c": i2cValue, "bcm": bcmValue , "pn": None}
+
+ def set_power_mode_for_QSFP(self):
+ for index in self.get_port_to_i2c_mapping().keys():
+ if index >= self.qsfp_port_start and index <= self.qsfp_port_end :
+ self.set_low_power_mode(index, False)
+
+def main():
+ try:
+ global DEBUG
+ global transceiver_obj
+ global bcm_obj
+
+ initalNotOK = True
+ retestCount = 0
+ while initalNotOK :
+ try:
+ transceiver_obj = TransceiverUtil()
+ bcm_obj = BCMUtil()
+ initalNotOK = False
+ except Exception, e:
+ log_message("Exception. The warning is {0}, Retry again ({1})".format(str(e),retestCount) )
+ retestCount = retestCount + 1
+ time.sleep(5)
+
+ log_message( "Object initialed successfully" )
+
+ options, args = getopt.getopt(sys.argv[1:], 'hd', ['help',
+ 'debug'
+ ])
+ for opt, arg in options:
+ if opt in ('-h', '--help'):
+ show_help()
+ elif opt in ('-d', '--debug'):
+ DEBUG = True
+ logging.basicConfig(level=logging.INFO)
+ else:
+ logging.info("no option")
+
+ # Before loop, You could execute specific command to initial chip
+ for cmd_index in initial_command :
+ bcm_obj.execute_command(cmd_index)
+
+ # Initial the sal config list
+ bcm_obj.parsing_eagle_port()
+ bcm_obj.initial_sal_config_list()
+ bcm_obj.parsing_port_list()
+ # bcm_obj.show_port_to_bcm_mapping()
+ # bcm_obj.show_sal_config_list()
+
+ # Initial the transceiver_obj
+ transceiver_obj.initial_transceiver_port_mapping()
+ # transceiver_obj.show_transceiver_port_mapping()
+
+ transceiver_obj.set_power_mode_for_QSFP()
+
+ while 1 :
+ bcm_obj.parsing_port_list()
+ for index in transceiver_obj.get_port_to_i2c_mapping().keys():
+ info = transceiver_obj.get_eeprom_dict_info(index)
+ value = transceiver_obj.get_eeprom_partNum_from_parser_eeprom_dict(info)
+ if transceiver_obj.get_transceiver_port_mapping().has_key(index) is not False and transceiver_obj.get_transceiver_port_mapping()[index]["pn"] <> value:
+ transceiver_obj.get_transceiver_port_mapping()[index]["pn"] = value
+ transceiver_obj.set_transceiver_type(index,value)
+ #transceiver_obj.show_transceiver_port_mapping()
+ time.sleep(1)
+
+ except (Exception, KeyboardInterrupt) as e:
+ log_message("Terminating this python daemon ({0})".format(e))
+ syslog.closelog()
+ del transceiver_obj
+ del bcm_obj
+
+if __name__ == "__main__":
+ main()
+
diff --git a/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7032q28b.init b/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7032q28b.init
index 5df1bb44412..97fee8c3ad5 100644
--- a/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7032q28b.init
+++ b/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7032q28b.init
@@ -11,18 +11,40 @@
# Short-Description: Setup Inventec d7032q28b board.
### END INIT INFO
+DIR=/usr/share/sonic/device/x86_64-inventec_d7032q28b-r0/plugins
+MONITOR_DAEMON=$DIR/transceiver_monitor.py
+MONITOR_DAEMON_NAME=transceiver_monitor
+LED_DAEMON=$DIR/led_proc.py
+LED_DAEMON_NAME=led_proc
+
+# The process ID of the script when it runs is stored here:
+MONITOR_PIDFILE=/var/run/$MONITOR_DAEMON_NAME.pid
+LED_PIDFILE=/var/run/$LED_DAEMON_NAME.pid
+
+do_monitor_start() {
+ /sbin/start-stop-daemon --quiet --oknodo --pidfile $LED_PIDFILE --make-pidfile --startas $LED_DAEMON --start --background -- $DAEMON_OPTS
+ /sbin/start-stop-daemon --quiet --oknodo --pidfile $MONITOR_PIDFILE --make-pidfile --startas $MONITOR_DAEMON --start --background -- $DAEMON_OPTS
+}
+
+do_monitor_stop() {
+ /sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $MONITOR_PIDFILE --retry 10
+ /sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $LED_PIDFILE --retry 10
+}
+
case "$1" in
start)
echo -n "Setting up board... "
depmod -a
/usr/local/bin/inventec_d7032_util.py -f install
+ do_monitor_${1}
echo "done."
;;
stop)
/usr/local/bin/inventec_d7032_util.py -f clean
+ do_monitor_${1}
echo "done."
;;
diff --git a/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7032q28b.install b/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7032q28b.install
index 0864a728ea7..c716a9d0d8b 100644
--- a/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7032q28b.install
+++ b/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7032q28b.install
@@ -1 +1,3 @@
d7032q28b/utils/inventec_d7032_util.py usr/local/bin
+common/utils/transceiver_monitor.py usr/share/sonic/device/x86_64-inventec_d7032q28b-r0/plugins
+common/utils/led_proc.py usr/share/sonic/device/x86_64-inventec_d7032q28b-r0/plugins
diff --git a/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7032q28b.upstart b/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7032q28b.upstart
deleted file mode 100644
index cbb96a664f6..00000000000
--- a/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7032q28b.upstart
+++ /dev/null
@@ -1,5 +0,0 @@
-description "SONiC platform service"
-
-respawn
-
-exec /usr/local/bin/inventec_d7032_util.py -f install
diff --git a/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7054q28b.init b/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7054q28b.init
index 20341f8527e..a6e3e88f20d 100644
--- a/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7054q28b.init
+++ b/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7054q28b.init
@@ -11,18 +11,40 @@
# Short-Description: Setup Inventec d7054q28b board.
### END INIT INFO
+DIR=/usr/share/sonic/device/x86_64-inventec_d7054q28b-r0/plugins
+MONITOR_DAEMON=$DIR/transceiver_monitor.py
+MONITOR_DAEMON_NAME=transceiver_monitor
+LED_DAEMON=$DIR/led_proc.py
+LED_DAEMON_NAME=led_proc
+
+# The process ID of the script when it runs is stored here:
+MONITOR_PIDFILE=/var/run/$MONITOR_DAEMON_NAME.pid
+LED_PIDFILE=/var/run/$LED_DAEMON_NAME.pid
+
+do_monitor_start() {
+ /sbin/start-stop-daemon --quiet --oknodo --pidfile $LED_PIDFILE --make-pidfile --startas $LED_DAEMON --start --background -- $DAEMON_OPTS
+ /sbin/start-stop-daemon --quiet --oknodo --pidfile $MONITOR_PIDFILE --make-pidfile --startas $MONITOR_DAEMON --start --background -- $DAEMON_OPTS
+}
+
+do_monitor_stop() {
+ /sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $MONITOR_PIDFILE --retry 10
+ /sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $LED_PIDFILE --retry 10
+}
+
case "$1" in
start)
echo -n "Setting up board... "
depmod -a
/usr/local/bin/inventec_d7054_util.py -f install
+ do_monitor_${1}
echo "done."
;;
stop)
/usr/local/bin/inventec_d7054_util.py -f clean
+ do_monitor_${1}
echo "done."
;;
diff --git a/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7054q28b.install b/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7054q28b.install
index 42bf3f23c80..699a5ef4141 100644
--- a/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7054q28b.install
+++ b/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7054q28b.install
@@ -1 +1,4 @@
d7054q28b/utils/inventec_d7054_util.py usr/local/bin
+common/utils/transceiver_monitor.py usr/share/sonic/device/x86_64-inventec_d7054q28b-r0/plugins
+common/utils/led_proc.py usr/share/sonic/device/x86_64-inventec_d7054q28b-r0/plugins
+
diff --git a/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7054q28b.upstart b/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7054q28b.upstart
deleted file mode 100644
index 9f185f47b62..00000000000
--- a/platform/broadcom/sonic-platform-modules-inventec/debian/platform-modules-d7054q28b.upstart
+++ /dev/null
@@ -1,5 +0,0 @@
-description "SONiC platform service"
-
-respawn
-
-exec /usr/local/bin/inventec_d7054_util.py -f install