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

[platform] Add as7512 sfp/eeprom utils #531

Merged
merged 3 commits into from
May 18, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
33 changes: 33 additions & 0 deletions device/accton/x86_64-accton_as7512_32x-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python

#############################################################################
# Cavium
#
# 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:
import exceptions
import binascii
import time
import optparse
import warnings
import os
import sys
from sonic_eeprom import eeprom_base
from sonic_eeprom import eeprom_tlvinfo
import subprocess
except ImportError, e:
raise ImportError (str(e) + "- required module not found")

class board(eeprom_tlvinfo.TlvInfoDecoder):

_TLV_INFO_MAX_LEN = 256

def __init__(self, name, path, cpld_root, ro):
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
super(board, self).__init__(self.eeprom_path, 0, '', True)

25 changes: 25 additions & 0 deletions device/accton/x86_64-accton_as7512_32x-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#! /usr/bin/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 = {}
_qsfp_ports = range(0, ports_in_block + 1)

def __init__(self, port_num):
# Override port_to_eeprom_mapping for class initialization
eeprom_path = '/sys/bus/i2c/devices/{0}-0050/sfp_eeprom'
for x in range(self.port_start, self.port_end + 1):
self.port_to_eeprom_mapping[x] = eeprom_path.format(x + 18)
sfputilbase.__init__(self, port_num)
2 changes: 2 additions & 0 deletions files/build_templates/swss.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ExecStartPre=/sbin/modprobe i2c-dev
ExecStartPre=/bin/bash -c "/usr/share/sonic/device/$(sonic-cfggen -v platform)/hw-management start"
{% elif sonic_asic_platform == 'cavium' %}
ExecStartPre=/etc/init.d/xpnet.sh start
ExecStartPre=/usr/bin/accton_as7512_util.py install
{% endif %}

ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
Expand All @@ -40,6 +41,7 @@ ExecStopPost=/usr/bin/mst stop
{% elif sonic_asic_platform == 'cavium' %}
ExecStopPost=/etc/init.d/xpnet.sh stop
ExecStopPost=/etc/init.d/xpnet.sh start
ExecStopPost=/usr/bin/accton_as7512_util.py clean
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this asic related or peripheral related? usually, this only contains asic related init.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is peripheral related

Copy link
Collaborator

Choose a reason for hiding this comment

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

in this case, can it be moved to the the as7512 platform package instead of here?

{% endif %}

[Install]
Expand Down
1 change: 1 addition & 0 deletions platform/cavium/cavm_platform_modules/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :

cp SONiC/AS7512-32X/module/*.ko $(DEB_BUILD_DIR)/lib/modules/$(KVERSION)
cp SONiC/AS7512-32X/accton_as7512_util.py $(DEB_BUILD_DIR)/usr/bin
chmod +x $(DEB_BUILD_DIR)/usr/bin/accton_as7512_util.py
cp -r DEBIAN $(DEB_BUILD_DIR)
dpkg-deb -b $(DEB_BUILD_DIR) $(MAIN_TARGET)

Expand Down