Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for ET6448M pmon2.0 #53

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{# this file empty temporarily until qos supported SAI Marvell #}
{}
20 changes: 20 additions & 0 deletions device/marvell/armhf-marvell_et6448m_52x-r0/pcie.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- bus: '00'
dev: '01'
fn: '0'
id: '6820'
name: 'PCI bridge: Marvell Technology Group Ltd. Device 6820 (rev 0a)'
- bus: '00'
dev: '02'
fn: '0'
id: '6820'
name: 'PCI bridge: Marvell Technology Group Ltd. Device 6820 (rev 0a)'
- bus: '01'
dev: '00'
fn: '0'
id: c804
name: 'Ethernet controller: Marvell Technology Group Ltd. Device c804'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think w shoudl add only c804 ac3x chips, and not all are requireed

- bus: '02'
dev: '00'
fn: '0'
id: c804
name: 'Ethernet controller: Marvell Technology Group Ltd. Device c804'
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"chassis": {
"et6448m": {
"component": {
"U-Boot": { },
"System-CPLD": { }
}
}
}
}
132 changes: 132 additions & 0 deletions device/marvell/armhf-marvell_et6448m_52x-r0/plugins/led_control.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#
# led_control.py
#
# Platform-specific LED control functionality for SONiC
#

try:
from sonic_led.led_control_base import LedControlBase
import os
import time
import syslog
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


def DBG_PRINT(str):
syslog.openlog("Led")
syslog.syslog(syslog.LOG_INFO, str)
syslog.closelog()


class LedControl(LedControlBase):
"""Platform specific LED control class"""

# Constructor
def __init__(self):
self.chassis = sonic_platform.platform.Platform().get_chassis()
self._initDefaultConfig()

def _initDefaultConfig(self):
# The fan tray leds and system led managed by new chassis class API
# leaving only a couple other front panel leds to be done old style
DBG_PRINT("starting system leds")
self._initSystemLed()
DBG_PRINT(" led done")

def _set_i2c_register(self, reg_file, value):
# On successful write, the value read will be written on
# reg_name and on failure returns 'ERR'
rv = 'ERR'

if (not os.path.isfile(reg_file)):
return rv
try:
with open(reg_file, 'w') as fd:
rv = fd.write(str(value))
except Exception as e:
rv = 'ERR'

return rv

def _initSystemLed(self):
# Front Panel System LEDs setting
oldfan = 0xf
oldpsu = 0xf

# Write sys led
if smbus_present == 0:
DBG_PRINT(" PMON LED SET ERROR -> smbus present = 0 ")
else:
bus = smbus.SMBus(0)
DEVICE_ADDRESS = 0x41
DEVICEREG = 0x7
bus.write_byte_data(DEVICE_ADDRESS, DEVICEREG, 0x02)
DBG_PRINT(" System LED set O.K. ")

while True:
# Front Panel FAN Panel LED setting in register 0x08
if (self.chassis.get_fan(0).get_status() == self.chassis.get_fan(1).get_status() == True):
if (os.path.isfile("/sys/class/gpio/fanLedAmber/value")):
if oldfan != 0x1:
self._set_i2c_register("/sys/class/gpio/fanLedAmber/value", 0)
self._set_i2c_register("/sys/class/gpio/fanLedGreen/value", 1)
oldfan = 0x1
else:
oldfan = 0xf
else:
if (os.path.isfile("/sys/class/gpio/fanLedGreen/value")):
if oldfan != 0x0:
self._set_i2c_register("/sys/class/gpio/fanLedGreen/value", 0)
self._set_i2c_register("/sys/class/gpio/fanLedAmber/value", 1)
oldfan = 0x0
else:
oldfan = 0xf

# Front Panel PSU Panel LED setting in register 0x09
if (self.chassis.get_psu(0).get_status() == self.chassis.get_psu(1).get_status() == True):
if (os.path.isfile("/sys/class/gpio/psuLedAmber/value")):
if oldpsu != 0x1:
self._set_i2c_register("/sys/class/gpio/psuLedAmber/value", 0)
self._set_i2c_register("/sys/class/gpio/psuLedGreen/value", 1)
oldpsu = 0x1
else:
oldpsu = 0xf
else:
if (os.path.isfile("/sys/class/gpio/psuLedGreen/value")):
if oldpsu != 0x0:
self._set_i2c_register("/sys/class/gpio/psuLedGreen/value", 0)
self._set_i2c_register("/sys/class/gpio/psuLedAmber/value", 1)
oldpsu = 0x0
else:
oldpsu = 0xf
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

def _port_state_to_mode(self, port_idx, state):
DBG_PRINT("_port_state_to_mode")

def _port_led_mode_update(self, port_idx, ledMode):
DBG_PRINT("_port_led_mode_update")

# called when port states change- implementation of port_link_state_change() method if needed
def port_link_state_change(self, portname, state):
# DBG_PRINT("port_link_state_change ")
return

This file was deleted.

65 changes: 65 additions & 0 deletions device/marvell/armhf-marvell_et6448m_52x-r0/thermal_policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"thermal_control_algorithm": {
"run_at_boot_up": "false",
"fan_speed_when_suspend": "50"
},
"info_types": [
{
"type": "fan_info"
},
{
"type": "thermal_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": "all fan presence",
"conditions": [
{
"type": "fan.all.presence"
}
],
"actions": [
{
"type": "thermal.temp_check_and_set_all_fan_speed",
"default_speed": "50",
"hightemp_speed": "100"
}
]
},
{
"name": "temp over high critical threshold",
"conditions": [
{
"type": "thermal.over.high_critical_threshold"
}
],
"actions": [
{
"type": "switch.shutdown"
}
]
}
]
}
65 changes: 52 additions & 13 deletions platform/marvell-armhf/sonic-platform-et6448m/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,62 @@
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

include /usr/share/dpkg/pkg-info.mk
#--------------------------------------------------------

# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
PACKAGE_PRE_NAME := sonic-platform
MOD_SRC_DIR:= $(shell pwd)
MODULE_DIRS:= et6448m
UTILS_DIR := utils
SERVICE_DIR := service
PLATFORM_DIR := sonic_platform

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
%:
dh $@ --with systemd,python3 --buildsystem=pybuild

clean:
dh_testdir
dh_testroot
dh_clean

%:
dh $@
build:
(for mod in $(MODULE_DIRS); do \
python3 $${mod}/setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}; \
done)

binary: binary-arch binary-indep
# Nothing to do

binary-arch:
# Nothing to do

binary-indep:
dh_testdir
dh_installdirs

# Custom package commands
(for mod in $(MODULE_DIRS); do \
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} /usr/local/bin; \
cp $(MOD_SRC_DIR)/$${mod}/$(SERVICE_DIR)/*.service debian/$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system/; \
cp $(MOD_SRC_DIR)/$${mod}/$(UTILS_DIR)/* debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/local/bin/; \
python3 $${mod}/setup.py install --root=$(MOD_SRC_DIR)/debian/$(PACKAGE_PRE_NAME)-$${mod} --install-layout=deb; \
done)

# dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 )
#override_dh_auto_configure:
# dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
# Resuming debhelper scripts
dh_testroot
dh_install
dh_installchangelogs
dh_installdocs
dh_systemd_enable
dh_installinit
dh_systemd_start
dh_link
dh_fixperms
dh_compress
dh_strip
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb

.PHONY: build binary binary-arch binary-indep clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
et6448m_plt_setup.sh usr/sbin
et6448m/scripts/et6448m-init.sh usr/local/bin
et6448m/service/et6448m-init.service etc/systemd/system
et6448m/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/armhf-marvell_et6448m_52x-r0
entropy.py etc/
inband_mgmt.sh etc/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this script packed ?

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# postinst script for sonic-platform-et6448m
#
# see: dh_installdeb(1)

sh /usr/sbin/et6448m_plt_setup.sh
systemctl enable et6448m-init.service
systemctl start et6448m-init.service

exit 0

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

# Platform init script for ET6448M

# Load required kernel-mode drivers
load_kernel_drivers() {
# Remove modules loaded during Linux init
# FIX-ME: This will be removed in the future when Linux init no longer loads these
rmmod i2c_mux_gpio
rmmod i2c_dev
rmmod i2c_mv64xxx

# Carefully control the load order here to ensure consistent i2c bus numbering
modprobe i2c_mv64xxx
modprobe i2c_dev
modprobe i2c_mux_gpio
modprobe eeprom
}


et6448m_profile()
{
MAC_ADDR=$(sudo decode-syseeprom -m)
sed -i "s/switchMacAddress=.*/switchMacAddress=$MAC_ADDR/g" /usr/share/sonic/device/armhf-marvell_et6448m_52x-r0/et6448m/profile.ini
echo "et6448m: Updating switch mac address ${MAC_ADDR}"
}

# - Main entry

# Install kernel drivers required for i2c bus access
load_kernel_drivers

# LOGIC to enumerate SFP eeprom devices - send 0x50 to kernel i2c driver - initialize devices
# the mux may be enumerated at number 4 or 5 so we check for the mux and skip if needed

# Get list of the mux channels
ismux_bus=$(i2cdetect -l|grep mux|cut -f1)

# Enumerate the SFP eeprom device on each mux channel
for mux in ${ismux_bus}
do
echo optoe2 0x50 > /sys/class/i2c-adapter/${mux}/new_device
done

# Enumerate fan eeprom devices
echo eeprom 0x55 > /sys/class/i2c-adapter/i2c-0/new_device
echo eeprom 0x56 > /sys/class/i2c-adapter/i2c-0/new_device

# Enumerate PSU eeprom devices
echo eeprom 0x50 > /sys/class/i2c-adapter/i2c-1/new_device
echo eeprom 0x51 > /sys/class/i2c-adapter/i2c-1/new_device

# Enable optical SFP Tx
i2cset -y -m 0x0f 0 0x41 0x5 0x00

# Ensure switch is programmed with chassis base MAC addr
et6448m_profile

echo "et6448m - completed platform init script"
exit 0
Loading