From 744fe1f47e582861ee0c03a5677412af9c3b46c4 Mon Sep 17 00:00:00 2001 From: lkunjumon Date: Tue, 2 Feb 2021 17:22:09 +0530 Subject: [PATCH 1/7] Adding tg4810m Hwsku --- .../delta/arm64-delta_tg4810m-r0/default_sku | 1 + .../delta_tg4810m/buffers_defaults_t1.j2 | 45 +++ .../delta_tg4810m/port_config.ini | 49 +++ .../delta_tg4810m/profile.ini | 1 + .../delta_tg4810m/sai.profile | 3 + .../delta/arm64-delta_tg4810m-r0/fancontrol | 10 + .../arm64-delta_tg4810m-r0/plugins/eeprom.py | 14 + .../plugins/led_control.py | 99 ++++++ .../arm64-delta_tg4810m-r0/plugins/psuutil.py | 74 +++++ .../arm64-delta_tg4810m-r0/plugins/sfputil.py | 291 ++++++++++++++++++ .../delta/arm64-delta_tg4810m-r0/sensors.conf | 19 ++ .../thermal_policy.json | 72 +++++ 12 files changed, 678 insertions(+) create mode 100644 device/delta/arm64-delta_tg4810m-r0/default_sku create mode 100644 device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/buffers_defaults_t1.j2 create mode 100644 device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/port_config.ini create mode 100644 device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/profile.ini create mode 100644 device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/sai.profile create mode 100644 device/delta/arm64-delta_tg4810m-r0/fancontrol create mode 100644 device/delta/arm64-delta_tg4810m-r0/plugins/eeprom.py create mode 100644 device/delta/arm64-delta_tg4810m-r0/plugins/led_control.py create mode 100644 device/delta/arm64-delta_tg4810m-r0/plugins/psuutil.py create mode 100644 device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py create mode 100644 device/delta/arm64-delta_tg4810m-r0/sensors.conf create mode 100644 device/delta/arm64-delta_tg4810m-r0/thermal_policy.json diff --git a/device/delta/arm64-delta_tg4810m-r0/default_sku b/device/delta/arm64-delta_tg4810m-r0/default_sku new file mode 100644 index 000000000..ae8103360 --- /dev/null +++ b/device/delta/arm64-delta_tg4810m-r0/default_sku @@ -0,0 +1 @@ +delta_tg4810m t1 diff --git a/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/buffers_defaults_t1.j2 b/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/buffers_defaults_t1.j2 new file mode 100644 index 000000000..38e34eb57 --- /dev/null +++ b/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/buffers_defaults_t1.j2 @@ -0,0 +1,45 @@ +{%- set default_cable = '300m' %} + +{%- macro generate_port_lists(PORT_ALL) %} + {# Generate list of ports #} + {% for port_idx in range(0,32) %} + {% if PORT_ALL.append("Ethernet%d" % (port_idx * 4)) %}{% endif %} + {% endfor %} +{%- endmacro %} + +{%- macro generate_buffer_pool_and_profiles() %} + "BUFFER_POOL": { + "ingress_lossless_pool": { + "size": "12766208", + "type": "ingress", + "mode": "dynamic" + }, + "egress_lossless_pool": { + "size": "12766208", + "type": "egress", + "mode": "static" + }, + "egress_lossy_pool": { + "size": "7326924", + "type": "egress", + "mode": "dynamic" + } + }, + "BUFFER_PROFILE": { + "ingress_lossy_profile": { + "pool":"[BUFFER_POOL|ingress_lossless_pool]", + "size":"0", + "dynamic_th":"3" + }, + "egress_lossless_profile": { + "pool":"[BUFFER_POOL|egress_lossless_pool]", + "size":"0", + "static_th":"12766208" + }, + "egress_lossy_profile": { + "pool":"[BUFFER_POOL|egress_lossy_pool]", + "size":"1518", + "dynamic_th":"3" + } + }, +{%- endmacro %} diff --git a/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/port_config.ini b/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/port_config.ini new file mode 100644 index 000000000..4b945491e --- /dev/null +++ b/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/port_config.ini @@ -0,0 +1,49 @@ +# name lanes alias index speed +Ethernet0 0 Ethernet0 1 10000 +Ethernet1 1 Ethernet1 2 10000 +Ethernet2 2 Ethernet2 3 10000 +Ethernet3 3 Ethernet3 4 10000 +Ethernet4 4 Ethernet4 5 10000 +Ethernet5 5 Ethernet5 6 10000 +Ethernet6 6 Ethernet6 7 10000 +Ethernet7 7 Ethernet7 8 10000 +Ethernet8 8 Ethernet8 9 10000 +Ethernet9 9 Ethernet9 10 10000 +Ethernet10 10 Ethernet10 11 10000 +Ethernet11 11 Ethernet11 12 10000 +Ethernet12 12 Ethernet12 13 10000 +Ethernet13 13 Ethernet13 14 10000 +Ethernet14 14 Ethernet14 15 10000 +Ethernet15 15 Ethernet15 16 10000 +Ethernet16 16 Ethernet16 17 10000 +Ethernet17 17 Ethernet17 18 10000 +Ethernet18 18 Ethernet18 19 10000 +Ethernet19 19 Ethernet19 20 10000 +Ethernet20 20 Ethernet20 21 10000 +Ethernet21 21 Ethernet21 22 10000 +Ethernet22 22 Ethernet22 23 10000 +Ethernet23 23 Ethernet23 24 10000 +Ethernet24 24 Ethernet24 25 10000 +Ethernet25 25 Ethernet25 26 10000 +Ethernet26 26 Ethernet26 27 10000 +Ethernet27 27 Ethernet27 28 10000 +Ethernet28 28 Ethernet28 29 10000 +Ethernet29 29 Ethernet29 30 10000 +Ethernet30 30 Ethernet30 31 10000 +Ethernet31 31 Ethernet31 32 10000 +Ethernet32 32 Ethernet32 33 10000 +Ethernet33 33 Ethernet33 34 10000 +Ethernet34 34 Ethernet34 35 10000 +Ethernet35 35 Ethernet35 36 10000 +Ethernet36 36 Ethernet36 37 10000 +Ethernet37 37 Ethernet37 38 10000 +Ethernet38 38 Ethernet38 39 10000 +Ethernet39 39 Ethernet39 40 10000 +Ethernet40 40 Ethernet40 41 10000 +Ethernet41 41 Ethernet41 42 10000 +Ethernet42 42 Ethernet42 43 10000 +Ethernet43 43 Ethernet43 44 10000 +Ethernet44 44 Ethernet44 45 10000 +Ethernet45 45 Ethernet45 46 10000 +Ethernet46 46 Ethernet46 47 10000 +Ethernet47 47 Ethernet47 48 10000 diff --git a/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/profile.ini b/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/profile.ini new file mode 100644 index 000000000..e9212edea --- /dev/null +++ b/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/profile.ini @@ -0,0 +1 @@ +switchMacAddress=00:50:b6:50:51:86 diff --git a/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/sai.profile b/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/sai.profile new file mode 100644 index 000000000..6d4768469 --- /dev/null +++ b/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/sai.profile @@ -0,0 +1,3 @@ +mode=1 +hwId=ALDRIN2XL +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/profile.ini diff --git a/device/delta/arm64-delta_tg4810m-r0/fancontrol b/device/delta/arm64-delta_tg4810m-r0/fancontrol new file mode 100644 index 000000000..719eb374d --- /dev/null +++ b/device/delta/arm64-delta_tg4810m-r0/fancontrol @@ -0,0 +1,10 @@ +# Configuration file for tg4810m +INTERVAL=10 +DEVPATH=hwmon1=devices/platform/cp0/cp0:config-space@f2000000/f2701000.i2c/i2c-0/0-002e hwmon3=devices/virtual/thermal/thermal_zone1 +DEVNAME=hwmon1=adt7473 hwmon3=f2400078.thermal +FCTEMPS=hwmon1/device/pwm3=hwmon1/device/temp1_input hwmon1/device/pwm2=hwmon3/temp1_input hwmon1/device/pwm1=hwmon1/device/temp2_input +FCFANS=hwmon1/device/pwm3=hwmon1/device/fan3_input hwmon1/device/pwm2=hwmon1/device/fan2_input hwmon1/device/pwm1=hwmon1/device/fan1_input +MINTEMP=hwmon1/device/pwm3=20 hwmon1/device/pwm2=20 hwmon1/device/pwm1=20 +MAXTEMP=hwmon1/device/pwm3=60 hwmon1/device/pwm2=60 hwmon1/device/pwm1=60 +MINSTART=hwmon1/device/pwm3=150 hwmon1/device/pwm2=150 hwmon1/device/pwm1=150 +MINSTOP=hwmon1/device/pwm3=0 hwmon1/device/pwm2=0 hwmon1/device/pwm1=0 diff --git a/device/delta/arm64-delta_tg4810m-r0/plugins/eeprom.py b/device/delta/arm64-delta_tg4810m-r0/plugins/eeprom.py new file mode 100644 index 000000000..8095d0f26 --- /dev/null +++ b/device/delta/arm64-delta_tg4810m-r0/plugins/eeprom.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +try: + import os + 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-0/0-0057/eeprom" + if not os.path.exists(self.eeprom_path): + os.system("echo 24c64 0x57 > /sys/class/i2c-adapter/i2c-0/new_device") + super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/delta/arm64-delta_tg4810m-r0/plugins/led_control.py b/device/delta/arm64-delta_tg4810m-r0/plugins/led_control.py new file mode 100644 index 000000000..7d579bc26 --- /dev/null +++ b/device/delta/arm64-delta_tg4810m-r0/plugins/led_control.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python +# led_control.py +# Platform-specific LED control functionality for SONiC + +try: + from sonic_led.led_control_base import LedControlBase + import swsssdk + import threading + import os + import logging + import struct + import time + from socket import * + from select import * + import sonic_platform.platform + import sonic_platform.chassis +except ImportError as e: + raise ImportError(str(e) + " - required module not found") + +smbus_present = 1 +try: + import smbus +except ImportError as e: + smbus_present = 0 + +class LedControl(LedControlBase): + """Platform specific LED control class""" + def __init__(self): + self.chassis = sonic_platform.platform.Platform().get_chassis() + self._initDefaultConfig() + + def _initDefaultConfig(self): + self._initLed() + + def gpio_led_write(self,gpio_led_path, value): + try: + gpio_file = open(gpio_led_path + "/brightness", 'w') + print(gpio_led_path) + gpio_file.write(str(value)) + gpio_file.close + except IOError as e: + print "error: unable to open gpio file: %s" % str(e) + + def _initLed(self): + # Front Panel LEDs setting + fan_led=0xf + psu_led=0xf + sys_led=0xf + + while True: + # Front Panel FAN LED + if ( self.chassis.get_fan(0).get_status() == self.chassis.get_fan(1).get_status() == self.chassis.get_fan(2).get_status() == True ): + if ( fan_led != 0x1 ): + self.gpio_led_write("/sys/class/leds/fanLedGreen",1) + self.gpio_led_write("/sys/class/leds/fanLedAmber",0) + fan_led = 0x1 + else : + if ( fan_led != 0x0 ): + self.gpio_led_write("/sys/class/leds/fanLedAmber",1) + self.gpio_led_write("/sys/class/leds/fanLedGreen",0) + fan_led = 0x0 + + # Front Panel PSU LED + if ( self.chassis.get_psu(0).get_status() == self.chassis.get_psu(1).get_status() == True ): + if ( psu_led != 0x1 ): + self.gpio_led_write("/sys/class/leds/psuLedGreen",1) + self.gpio_led_write("/sys/class/leds/psuLedAmber",0) + psu_led = 0x1 + else : + if ( psu_led != 0x0 ): + self.gpio_led_write("/sys/class/leds/psuLedAmber",1) + self.gpio_led_write("/sys/class/leds/psuLedGreen",0) + psu_led = 0x0 + + # Front Panel system LED + if ( fan_led == psu_led == 0x1 ) : + if ( sys_led != 0x1 ): + self.gpio_led_write("/sys/class/leds/sysLedGreen",1) + self.gpio_led_write("/sys/class/leds/sysLedAmber",0) + sys_led = 0x1 + else: + if ( sys_led != 0x0 ): + self.gpio_led_write("/sys/class/leds/sysLedAmber",1) + self.gpio_led_write("/sys/class/leds/sysLedGreen",0) + sys_led = 0x0 + + time.sleep(6) + + # Helper method to map SONiC port name to index + def _port_name_to_index(self, port_name): + # Strip "Ethernet" off port name + if not port_name.startswith(self.SONIC_PORT_NAME_PREFIX): + return -1 + port_idx = int(port_name[len(self.SONIC_PORT_NAME_PREFIX):]) + return port_idx + + # called when port states change- implementation of port_link_state_change() method if needed + def port_link_state_change(self, portname, state): + return diff --git a/device/delta/arm64-delta_tg4810m-r0/plugins/psuutil.py b/device/delta/arm64-delta_tg4810m-r0/plugins/psuutil.py new file mode 100644 index 000000000..3a07425c6 --- /dev/null +++ b/device/delta/arm64-delta_tg4810m-r0/plugins/psuutil.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +# psuutil.py +# Platform-specific PSU functionality for SONiC + +import sys +import os.path + +if sys.version_info[0] < 3: + import commands as cmd +else: + import subprocess as cmd + +smbus_present = 1 +try: + import smbus +except ImportError as e: + smbus_present = 0 + +try: + from sonic_psu.psu_base import PsuBase +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +class PsuUtil(PsuBase): + """Platform-specific PSUutil class""" + def __init__(self): + PsuBase.__init__(self) + MAX_PSUS = 2 + + def get_num_psus(self): + MAX_PSUS = 2 + return MAX_PSUS + + def get_psu_status(self, index): + if index is None: + return False + if smbus_present == 0: + cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 2 0x41 0xa') + psustatus = int(psustatus, 16) + else : + bus = smbus.SMBus(2) + DEVICE_ADDRESS = 0x41 + DEVICE_REG = 0xa + psustatus = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG) + if index == 1: + psustatus = psustatus&4 + if psustatus == 4 : + return True + if index == 2: + psustatus = psustatus&8 + if psustatus == 8 : + return True + return False + + def get_psu_presence(self, index): + if index is None: + return False + if smbus_present == 0: + cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 2 0x41 0xa') + psustatus = int(psustatus, 16) + else : + bus = smbus.SMBus(2) + DEVICE_ADDRESS = 0x41 + DEVICE_REG = 0xa + psustatus = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG) + if index == 1: + psustatus = psustatus&1 + if psustatus == 0 : + return True + if index == 2: + psustatus = psustatus&2 + if psustatus == 0 : + return True + return False diff --git a/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py b/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py new file mode 100644 index 000000000..da711c68a --- /dev/null +++ b/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py @@ -0,0 +1,291 @@ +#!/usr/bin/env python +# sfputil.py +# Platform-specific SFP functionality for SONiC +try: + import os + import time + import re + import sys + import glob + from sonic_sfp.sfputilbase import SfpUtilBase +except ImportError, e: + raise ImportError (str(e) + "- required module not found") + +if sys.version_info[0] < 3: + import commands as cmd +else: + import subprocess as cmd + +smbus_present = 1 +try: + import smbus +except ImportError, e: + smbus_present = 0 + +class SfpUtil(SfpUtilBase): + """Platform specific sfputil class""" + _port_start = 1 + _port_end = 48 + ports_in_block = 48 + _port_to_eeprom_mapping = {} + port_to_i2c_mapping = { + } + #_qsfp_ports = range(_port_start, ports_in_block + 1) + _qsfp_ports = {} + _changed_ports = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] + + def __init__(self): + + # SFP Tx Enable + if smbus_present == 0 : + os.system("i2cset -y 2 0x41 0x31 0x00") + os.system("i2cset -y 2 0x41 0x32 0x00") + os.system("i2cset -y 2 0x41 0x33 0x00") + os.system("i2cset -y 2 0x41 0x34 0x00") + os.system("i2cset -y 2 0x41 0x35 0x00") + os.system("i2cset -y 2 0x41 0x36 0x00") + else : + bus = smbus.SMBus(2) + DEVICE_ADDRESS = 0x41 + DEVICEREG = 0x31 + OPTIC_E = 0x00 + bus.write_byte_data(DEVICE_ADDRESS, DEVICEREG, OPTIC_E) + DEVICEREG = 0x32 + bus.write_byte_data(DEVICE_ADDRESS, DEVICEREG, OPTIC_E) + DEVICEREG = 0x33 + bus.write_byte_data(DEVICE_ADDRESS, DEVICEREG, OPTIC_E) + DEVICEREG = 0x34 + bus.write_byte_data(DEVICE_ADDRESS, DEVICEREG, OPTIC_E) + DEVICEREG = 0x35 + bus.write_byte_data(DEVICE_ADDRESS, DEVICEREG, OPTIC_E) + DEVICEREG = 0x36 + bus.write_byte_data(DEVICE_ADDRESS, DEVICEREG, OPTIC_E) + + # Mux Ordering + mux_dev = sorted(glob.glob("/sys/class/i2c-adapter/i2c-1/i2c-*[0-9]*")) + # Enable optoe2 Driver + eeprom_path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom" + bus_path = "/sys/class/i2c-adapter/i2c-{0}/" + y = 0 + for x in range(self.port_start, self.port_end + 1): + mux_dev_num = mux_dev[y] + self.port_to_i2c_mapping[x] = mux_dev_num.split('-')[-1] + #print x + #print self.port_to_i2c_mapping[x] + physical_port = int(self.port_to_i2c_mapping[x]) - 2 + y = y + 1 + port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x]) + if not os.path.exists(port_eeprom_path): + bus_dev_path = bus_path.format(self.port_to_i2c_mapping[x]) + #print(bus_dev_path) + os.system("echo optoe2 0x50 > " + bus_dev_path + "/new_device") + self.port_to_eeprom_mapping[physical_port] = port_eeprom_path + self._port_to_eeprom_mapping[physical_port] = port_eeprom_path + #print self._port_to_eeprom_mapping[physical_port] + SfpUtilBase.__init__(self) + + def reset(self, port_num): + # Check for invalid port_num + if port_num < self._port_start or port_num > self._port_end: + return False + path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/sfp_port_reset" + port_ps = path.format(self.port_to_i2c_mapping[port_num]) + try: + reg_file = open(port_ps, 'w') + except IOError as e: + print "Error: unable to open file: %s" % str(e) + return False + #toggle reset + reg_file.seek(0) + reg_file.write('1') + time.sleep(1) + reg_file.seek(0) + reg_file.write('0') + reg_file.close() + return True + + def set_low_power_mode(self, port_nuM, lpmode): + raise NotImplementedError + + def get_low_power_mode(self, port_num): + raise NotImplementedError + + def get_presence(self, port_num): + # Check for invalid port_num + if port_num < self._port_start or port_num > self._port_end: + return False + if port_num >=1 and port_num <=8: + prt = port_num -1 + DEVICE_REG = 0x3a + if port_num >=9 and port_num <=16: + prt = port_num % 9 + DEVICE_REG = 0x3b + if port_num >=17 and port_num <=24: + prt = port_num % 17 + DEVICE_REG = 0x3c + if port_num >=25 and port_num <=32: + prt = port_num % 25 + DEVICE_REG = 0x3d + if port_num >=33 and port_num <=40: + prt = port_num % 33 + DEVICE_REG = 0x3e + if port_num >=41 and port_num <=48: + prt = port_num % 41 + DEVICE_REG = 0x3f + + pos = [1,2,4,8,16,32,64,128] + bit_pos = pos[prt] + if smbus_present == 0: + #Read PSU presence register + cmdstatus, sfpstatus = cmd.getstatusoutput("i2cget -y 2 0x41 "+ hex(DEVICE_REG) + " " ) #Verify CPLD register logic + sfpstatus = int(sfpstatus, 16) + else : + bus = smbus.SMBus(2) + DEVICE_ADDRESS = 0x41 + sfpstatus = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG) + sfpstatus = sfpstatus&(bit_pos) + #print "checking presence" + #print bit_pos + #print sfpstatus + #print port_num + if sfpstatus == 0: + #print "sfp found" + return True + return False + + def read_porttab_mappings(self, porttabfile): + logical = [] + logical_to_physical = {} + physical_to_logical = {} + last_fp_port_index = 0 + last_portname = "" + first = 1 + port_pos_in_file = 0 + parse_fmt_port_config_ini = False + + try: + f = open(porttabfile) + except: + raise + + parse_fmt_port_config_ini = (os.path.basename(porttabfile) == "port_config.ini") + # Read the porttab file and generate dicts + # with mapping for future reference. + # + # TODO: Refactor this to use the portconfig.py module that now + # exists as part of the sonic-config-engine package. + title = [] + for line in f: + line.strip() + if re.search("^#", line) is not None: + # The current format is: # name lanes alias index speed + # Where the ordering of the columns can vary + title = line.split()[1:] + continue + + # Parsing logic for 'port_config.ini' file + if (parse_fmt_port_config_ini): + portname = line.split()[0] + + if "index" in title: + fp_port_index = int(line.split()[title.index("index")]) + # Leave the old code for backward compatibility + elif len(line.split()) >= 4: + fp_port_index = int(line.split()[3]) + else: + fp_port_index = portname.split("Ethernet").pop() + fp_port_index = int(fp_port_index.split("s").pop(0))+1 + #print(fp_port_index) + else: # Parsing logic for older 'portmap.ini' file + fp_port_index = portname.split("Ethernet").pop() + fp_port_index = int(fp_port_index.split("s").pop(0))+1 + + if ((len(self.sfp_ports) > 0) and (fp_port_index not in self.sfp_ports)): + continue + + if first == 1: + # Initialize last_[physical|logical]_port + # to the first valid port + last_fp_port_index = fp_port_index + last_portname = portname + first = 0 + + logical.append(portname) + + logical_to_physical[portname] = [fp_port_index] + if physical_to_logical.get(fp_port_index) is None: + physical_to_logical[fp_port_index] = [portname] + else: + physical_to_logical[fp_port_index].append( + portname) + + if (fp_port_index - last_fp_port_index) > 1: + # last port was a gang port + for p in range(last_fp_port_index+1, fp_port_index): + logical_to_physical[last_portname].append(p) + if physical_to_logical.get(p) is None: + physical_to_logical[p] = [last_portname] + else: + physical_to_logical[p].append(last_portname) + + last_fp_port_index = fp_port_index + last_portname = portname + + port_pos_in_file += 1 + + self.logical = logical + self.logical_to_physical = logical_to_physical + self.physical_to_logical = physical_to_logical + #print(self.logical_to_physical) + + + @property + def port_start(self): + return self._port_start + + @property + def port_end(self): + return self._port_end + + @property + def qsfp_ports(self): + return self._qsfp_ports + + @property + def port_to_eeprom_mapping(self): + return self._port_to_eeprom_mapping + + def get_transceiver_change_event(self, timeout): + port_dict = {} + port = 0 + + if timeout == 0: + cd_ms = sys.maxint + else: + cd_ms = timeout + changed_port = 0 + #poll per second + while cd_ms > 0: + for port_num in range(1,48): + sfpstatus = self.get_presence(port_num) + if sfpstatus==0 : + port_dict[str(port_num)]= '1' + if self._changed_ports[port_num] == 0: + changed_port = 1 + self._changed_ports[port_num] = 1 + else : + port_dict[str(port_num)] = '0' + if self._changed_ports[port_num] == 1: + changed_port = 1 + self._changed_ports[port_num] = 0 + if changed_port != 0: + break + time.sleep(1) + cd_ms = cd_ms - 1000 + + if changed_port: + return True, port_dict + else: + return True, {} + return False, {} + diff --git a/device/delta/arm64-delta_tg4810m-r0/sensors.conf b/device/delta/arm64-delta_tg4810m-r0/sensors.conf new file mode 100644 index 000000000..8bb0acc4f --- /dev/null +++ b/device/delta/arm64-delta_tg4810m-r0/sensors.conf @@ -0,0 +1,19 @@ +chip "adt7473-*" + label fan1 "rear fan 1" + label fan2 "rear fan 2" + label fan3 "read fan 3" + ignore fan4 + ignore in1 + +chip "lm75a-i2c-*-4a" + label temp1 "MAC temp sensor" + set temp1_max 65 + set temp1_crit 75 + +chip "lm75a-i2c-*-4b" + label temp1 "Board temp sensor" + set temp2_max 65 + set temp2_crit 75 + +chip "armada_thermal-*" + ignore temp1 diff --git a/device/delta/arm64-delta_tg4810m-r0/thermal_policy.json b/device/delta/arm64-delta_tg4810m-r0/thermal_policy.json new file mode 100644 index 000000000..922527028 --- /dev/null +++ b/device/delta/arm64-delta_tg4810m-r0/thermal_policy.json @@ -0,0 +1,72 @@ +{ + "thermal_control_algorithm": { + "run_at_boot_up": "false", + "fan_speed_when_suspend": "35" + }, + "info_types": [ + { + "type": "fan_info" + }, + { + "type": "psu_info" + }, + { + "type": "chassis_info" + } + ], + "policies": [ + { + "name": "any fan absence", + "conditions": [ + { + "type": "fan.any.absence" + } + ], + "actions": [ + { + "type": "thermal_control.control", + "status": "false" + }, + { + "type": "fan.all.set_speed", + "speed": "100" + } + ] + }, + { + "name": "any psu absence", + "conditions": [ + { + "type": "psu.any.absence" + } + ], + "actions": [ + { + "type": "thermal_control.control", + "status": "false" + }, + { + "type": "fan.all.set_speed", + "speed": "30" + } + ] + }, + { + "name": "all fan and psu presence", + "conditions": [ + { + "type": "fan.all.presence" + }, + { + "type": "psu.all.presence" + } + ], + "actions": [ + { + "type": "fan.all.set_speed", + "speed": "30" + } + ] + } + ] +} From d586bd7c58e0cdd4550837a79aa3306f233723fe Mon Sep 17 00:00:00 2001 From: lkunjumon Date: Wed, 10 Feb 2021 10:41:14 +0530 Subject: [PATCH 2/7] update sfputil --- device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py b/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py index da711c68a..087be8a78 100644 --- a/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py +++ b/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py @@ -70,8 +70,6 @@ def __init__(self): for x in range(self.port_start, self.port_end + 1): mux_dev_num = mux_dev[y] self.port_to_i2c_mapping[x] = mux_dev_num.split('-')[-1] - #print x - #print self.port_to_i2c_mapping[x] physical_port = int(self.port_to_i2c_mapping[x]) - 2 y = y + 1 port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x]) From b21954b5fc1c7446173ba8e01278ba97cbf9a0cb Mon Sep 17 00:00:00 2001 From: lkunjumon Date: Fri, 5 Mar 2021 20:08:45 +0530 Subject: [PATCH 3/7] Fix LGTM issues --- device/delta/arm64-delta_tg4810m-r0/plugins/led_control.py | 5 ----- device/delta/arm64-delta_tg4810m-r0/plugins/psuutil.py | 2 -- device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py | 1 - 3 files changed, 8 deletions(-) diff --git a/device/delta/arm64-delta_tg4810m-r0/plugins/led_control.py b/device/delta/arm64-delta_tg4810m-r0/plugins/led_control.py index 7d579bc26..734d6d507 100644 --- a/device/delta/arm64-delta_tg4810m-r0/plugins/led_control.py +++ b/device/delta/arm64-delta_tg4810m-r0/plugins/led_control.py @@ -4,11 +4,6 @@ try: from sonic_led.led_control_base import LedControlBase - import swsssdk - import threading - import os - import logging - import struct import time from socket import * from select import * diff --git a/device/delta/arm64-delta_tg4810m-r0/plugins/psuutil.py b/device/delta/arm64-delta_tg4810m-r0/plugins/psuutil.py index 3a07425c6..4f69648e5 100644 --- a/device/delta/arm64-delta_tg4810m-r0/plugins/psuutil.py +++ b/device/delta/arm64-delta_tg4810m-r0/plugins/psuutil.py @@ -3,7 +3,6 @@ # Platform-specific PSU functionality for SONiC import sys -import os.path if sys.version_info[0] < 3: import commands as cmd @@ -25,7 +24,6 @@ class PsuUtil(PsuBase): """Platform-specific PSUutil class""" def __init__(self): PsuBase.__init__(self) - MAX_PSUS = 2 def get_num_psus(self): MAX_PSUS = 2 diff --git a/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py b/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py index 087be8a78..4708136e4 100644 --- a/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py +++ b/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py @@ -255,7 +255,6 @@ def port_to_eeprom_mapping(self): def get_transceiver_change_event(self, timeout): port_dict = {} - port = 0 if timeout == 0: cd_ms = sys.maxint From e565ac74eb67088617ffaa3bacbb0a48475ca269 Mon Sep 17 00:00:00 2001 From: lkunjumon Date: Fri, 5 Mar 2021 22:24:45 +0530 Subject: [PATCH 4/7] Adding pice check support --- device/delta/arm64-delta_tg4810m-r0/plugins/pcie.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 device/delta/arm64-delta_tg4810m-r0/plugins/pcie.yaml diff --git a/device/delta/arm64-delta_tg4810m-r0/plugins/pcie.yaml b/device/delta/arm64-delta_tg4810m-r0/plugins/pcie.yaml new file mode 100644 index 000000000..726b078c3 --- /dev/null +++ b/device/delta/arm64-delta_tg4810m-r0/plugins/pcie.yaml @@ -0,0 +1,10 @@ +- bus: '00' + dev: '00' + fn: '0' + id: '0110' + name: 'PCI bridge: Marvell Technology Group Ltd. Device 0110' +- bus: '01' + dev: '00' + fn: '0' + id: cc1e + name: 'Ethernet controller: Marvell Technology Group Ltd. Device cc1e' From b599060f05eea424989d3cc2fed6e0ef36f1113a Mon Sep 17 00:00:00 2001 From: lkunjumon Date: Fri, 5 Mar 2021 22:39:39 +0530 Subject: [PATCH 5/7] Reading base mac from eeprom --- device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/profile.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/profile.ini b/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/profile.ini index e9212edea..e69de29bb 100644 --- a/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/profile.ini +++ b/device/delta/arm64-delta_tg4810m-r0/delta_tg4810m/profile.ini @@ -1 +0,0 @@ -switchMacAddress=00:50:b6:50:51:86 From 7210feb8d9c1b78eb58c241f3dbecca190eea8f1 Mon Sep 17 00:00:00 2001 From: lkunjumon Date: Fri, 5 Mar 2021 23:35:22 +0530 Subject: [PATCH 6/7] lgtm fix --- device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py | 1 - 1 file changed, 1 deletion(-) diff --git a/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py b/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py index 4708136e4..7471fb95c 100644 --- a/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py +++ b/device/delta/arm64-delta_tg4810m-r0/plugins/sfputil.py @@ -284,5 +284,4 @@ def get_transceiver_change_event(self, timeout): return True, port_dict else: return True, {} - return False, {} From 1a3ab256fd6d141d6a83562a63e00fa2dd5f8ee9 Mon Sep 17 00:00:00 2001 From: lkunjumon Date: Sat, 6 Mar 2021 00:47:21 +0530 Subject: [PATCH 7/7] lgtm fix --- device/delta/arm64-delta_tg4810m-r0/plugins/led_control.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/device/delta/arm64-delta_tg4810m-r0/plugins/led_control.py b/device/delta/arm64-delta_tg4810m-r0/plugins/led_control.py index 734d6d507..7fe91422c 100644 --- a/device/delta/arm64-delta_tg4810m-r0/plugins/led_control.py +++ b/device/delta/arm64-delta_tg4810m-r0/plugins/led_control.py @@ -12,11 +12,6 @@ except ImportError as e: raise ImportError(str(e) + " - required module not found") -smbus_present = 1 -try: - import smbus -except ImportError as e: - smbus_present = 0 class LedControl(LedControlBase): """Platform specific LED control class"""