Skip to content

Commit

Permalink
DellEMC: S5248F - Platform API 2.0 implementation (#7930)
Browse files Browse the repository at this point in the history
#### Why I did it
Support API 2.0 for S5248F platform

#### How I did it
Making changes to S5248F platform specific directory

Co-authored-by: Arun LK <Arun_L_K@dell.com>
  • Loading branch information
arunlk-dell and Arun LK authored Jun 28, 2021
1 parent 9f114ca commit 1d9fd82
Show file tree
Hide file tree
Showing 20 changed files with 2,916 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"skip_thermalctld": true,
"skip_ledd": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ def pci_get_value(resource, offset):
mm.close()
return val

def pci_mem_write(memmap, offset, data):
""" Write PCI device """
memmap.seek(offset)
memmap.write(struct.pack('I', data))

def pci_set_value(resource, val, offset):
""" Set a value to PCI device """
with open(resource, 'w+b') as filed:
memmap = None
try:
memmap = mmap.mmap(filed.fileno(), 0)
pci_mem_write(memmap, offset, val)
except EnvironmentError:
pass
if memmap is not None:
memmap.close()

# Read I2C device

def i2c_get(bus, i2caddr, ofs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ s5248f/scripts/sensors usr/bin
s5248f/scripts/qsfp_irq_enable.py usr/bin
s5248f/cfg/s5248f-modules.conf etc/modules-load.d
s5248f/systemd/platform-modules-s5248f.service etc/systemd/system
s5248f/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-dellemc_s5248f_c3538-r0
common/platform_reboot usr/share/sonic/device/x86_64-dellemc_s5248f_c3538-r0
common/fw-updater usr/local/bin
common/onie_mode_set usr/local/bin
Expand Down
10 changes: 10 additions & 0 deletions platform/broadcom/sonic-platform-modules-dell/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ override_dh_auto_build:
python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
cd $(MOD_SRC_DIR); \
elif [ $$mod = "s5248f" ]; then \
cp $(COMMON_DIR)/ipmihelper.py $(MOD_SRC_DIR)/$${mod}/sonic_platform/ipmihelper.py; \
cd $(MOD_SRC_DIR)/$${mod}; \
python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
cd $(MOD_SRC_DIR); \
elif [ $$mod = "z9332f" ]; then \
cp $(COMMON_DIR)/ipmihelper.py $(MOD_SRC_DIR)/$${mod}/sonic_platform/ipmihelper.py; \
cd $(MOD_SRC_DIR)/$${mod}; \
Expand Down Expand Up @@ -103,6 +108,11 @@ override_dh_clean:
rm -f $(MOD_SRC_DIR)/$${mod}/modules/*.whl; \
rm -rf $(MOD_SRC_DIR)/$${mod}/build; \
rm -rf $(MOD_SRC_DIR)/$${mod}/build/*.egg-info; \
elif [ $$mod = "s5248f" ]; then \
rm -f $(MOD_SRC_DIR)/$${mod}/sonic_platform/ipmihelper.py; \
rm -f $(MOD_SRC_DIR)/$${mod}/modules/*.whl; \
rm -rf $(MOD_SRC_DIR)/$${mod}/build; \
rm -rf $(MOD_SRC_DIR)/$${mod}/build/*.egg-info; \
elif [ $$mod = "z9332f" ]; then \
rm -f $(MOD_SRC_DIR)/$${mod}/sonic_platform/ipmihelper.py; \
rm -f $(MOD_SRC_DIR)/$${mod}/modules/*.whl; \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ switch_board_modsel() {
done
}

install_python_api_package() {
device="/usr/share/sonic/device"
platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)

rv=$(pip3 install $device/$platform/sonic_platform-1.0-py3-none-any.whl)
}

remove_python_api_package() {
rv=$(pip3 show sonic-platform > /dev/null 2>/dev/null)
if [ $? -eq 0 ]; then
rv=$(pip3 uninstall -y sonic-platform > /dev/null 2>/dev/null)
fi
}

platform_firmware_versions() {
FIRMWARE_VERSION_FILE=/var/log/firmware_versions
rm -rf ${FIRMWARE_VERSION_FILE}
Expand Down Expand Up @@ -146,13 +160,15 @@ if [ "$1" == "init" ]; then
switch_board_modsel
switch_board_led_default
#/usr/bin/qsfp_irq_enable.py
install_python_api_package
platform_firmware_versions

elif [ "$1" == "deinit" ]; then
sys_eeprom "delete_device"
switch_board_qsfp "delete_device"
switch_board_qsfp_mux "delete_device"

remove_python_api_package
modprobe -r i2c-mux-pca954x
modprobe -r i2c-dev
else
Expand Down
30 changes: 30 additions & 0 deletions platform/broadcom/sonic-platform-modules-dell/s5248f/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from setuptools import setup

setup(
name='sonic-platform',
version='1.0',
description='SONiC platform API implementation on DellEmc Platforms',
license='Apache 2.0',
author='SONiC Team',
author_email='linuxnetdev@microsoft.com',
url='https://github.com/Azure/sonic-buildimage',
maintainer='DellEMC',
maintainer_email='dell-sonic@dell.com',
packages=[
'sonic_platform',
],
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Plugins',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3.7',
'Topic :: Utilities',
],
keywords='sonic SONiC platform PLATFORM',
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__all__ = ["platform", "chassis", "sfp", "eeprom", "component", "thermal", "psu", "fan", "fan_drawer", "watchdog"]
from sonic_platform import *

Loading

0 comments on commit 1d9fd82

Please sign in to comment.