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

Consolidate device-specific files; install as a Debian package #316

Merged
merged 27 commits into from
Feb 27, 2017
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ba73c46
Move device-specific files from sonic-config-engine to new directory …
jleveque Feb 17, 2017
9b75dd4
Add device-specific files from external sonic-utilities
jleveque Feb 17, 2017
a4a8eb3
Remove ACS-S6000; Move files under Force10-S6000
jleveque Feb 17, 2017
f0f223c
Add files for Arista-7050-QX32 and Force10-S6100
jleveque Feb 17, 2017
30a33b2
sonic-config-engine no longer installs device-specific files
jleveque Feb 18, 2017
cbcf87a
[All platforms]: Move sensors.conf from under HW SKU dirs to under pl…
jleveque Feb 18, 2017
06adc00
[All platforms]: eeprom.py and sfputil.py now reference new SONiC uti…
jleveque Feb 18, 2017
d0fc7e4
Now building sonic-utilities as SONIC_PYTHON_STDEB_DEBS
jleveque Feb 18, 2017
caa3e82
Add files for creating sonic-device-data Debian package
jleveque Feb 21, 2017
c7ae52a
Fix full version string
jleveque Feb 21, 2017
2779789
Fix source path
jleveque Feb 21, 2017
af632c0
Rearrange sonic-device-data directory for clean build of Debian package
jleveque Feb 22, 2017
ef6d089
Re-add existing platform-specific files to sonic-config-engine for no…
jleveque Feb 23, 2017
163a4e0
Mount platform and hwsku directories in every docker
jleveque Feb 23, 2017
457f98c
Install sonic-device-data in OneImage; Refactor sonic-utilities depen…
jleveque Feb 23, 2017
90e5031
Move eeprom.py and sfputil.py files to respective <platform>/plugins …
jleveque Feb 23, 2017
707b1eb
Add files for Arista-7060-CX32S and INGRASYS-S9100-C32
jleveque Feb 24, 2017
11288e3
Add device-specific SAI profiles from sonic-sairedis repo
jleveque Feb 24, 2017
e6b88af
Move file to proper device
jleveque Feb 24, 2017
7a78611
Update sonic-utilities submodule pointer
jleveque Feb 24, 2017
394e0b2
Reorder steps and update apt so that extra apt repos are available be…
jleveque Feb 24, 2017
9313b68
Update sonic-utilities submodule pointer
jleveque Feb 25, 2017
9d26f8c
Remove explicit install of sonic-utilities dependencies
jleveque Feb 26, 2017
ebe7ecd
Fix version mismatch with sonic-device-data package
jleveque Feb 26, 2017
cd1c126
Add sonic-device-data to base image; cleanup rule
jleveque Feb 26, 2017
038635a
Reference new name of sonic-utilities Debian package.
jleveque Feb 27, 2017
c75df06
Fix typos, grammar and formatting in README.md
jleveque Feb 27, 2017
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ src/snmpd/*
!src/snmpd/Makefile
src/thrift/*
!src/thrift/Makefile
src/sonic-device-data/src/device/

# Autogenerated Dockerfiles
dockers/docker-database/Dockerfile
Expand Down
33 changes: 33 additions & 0 deletions device/accton/x86_64-accton_as7512_32x-r0/AS7512/port_config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# name lanes
Ethernet0 16,17,18,19
Ethernet4 20,21,22,23
Ethernet8 24,25,26,27
Ethernet12 28,29,30,31
Ethernet16 32,33,34,35
Ethernet20 36,37,38,39
Ethernet24 40,41,42,43
Ethernet28 44,45,46,47
Ethernet32 0,1,2,3
Ethernet36 4,5,6,7
Ethernet40 8,9,10,11
Ethernet44 12,13,14,15
Ethernet48 48,49,50,51
Ethernet52 52,53,54,55
Ethernet56 56,57,58,59
Ethernet60 60,61,62,63
Ethernet64 127,126,125,124
Ethernet68 123,122,121,120
Ethernet72 115,114,113,112
Ethernet76 119,118,117,116
Ethernet80 79,78,77,76
Ethernet84 75,74,73,72
Ethernet88 64,65,66,67
Ethernet92 71,70,68,69
Ethernet96 111,110,109,108
Ethernet100 107,106,105,104
Ethernet104 103,102,101,100
Ethernet108 99,98,97,96
Ethernet112 95,94,93,92
Ethernet116 91,90,89,88
Ethernet120 87,86,85,84
Ethernet124 83,82,81,80
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# name lanes alias
Ethernet0 125,126,127,128 Ethernet1/1
Ethernet4 121,122,123,124 Ethernet2/1
Ethernet8 13,14,15,16 Ethernet3/1
Ethernet12 9,10,11,12 Ethernet4/1
Ethernet16 17,18,19,20 Ethernet5/1
Ethernet20 21,22,23,24 Ethernet6/1
Ethernet24 25,26,27,28 Ethernet7/1
Ethernet28 29,30,31,32 Ethernet8/1
Ethernet32 37,38,39,40 Ethernet9/1
Ethernet36 33,34,35,36 Ethernet10/1
Ethernet40 45,46,47,48 Ethernet11/1
Ethernet44 41,42,43,44 Ethernet12/1
Ethernet48 53,54,55,56 Ethernet13/1
Ethernet52 49,50,51,52 Ethernet14/1
Ethernet56 69,70,71,72 Ethernet15/1
Ethernet60 65,66,67,68 Ethernet16/1
Ethernet64 77,78,79,80 Ethernet17/1
Ethernet68 73,74,75,76 Ethernet18/1
Ethernet72 93,94,95,96 Ethernet19/1
Ethernet76 89,90,91,92 Ethernet20/1
Ethernet80 101,102,103,104 Ethernet21/1
Ethernet84 97,98,99,100 Ethernet22/1
Ethernet88 109,110,111,112 Ethernet23/1
Ethernet92 105,106,107,108 Ethernet24/1
Ethernet96 61,62,63,64 Ethernet25
Ethernet100 57,58,59,60 Ethernet26
Ethernet104 81,82,83,84 Ethernet27
Ethernet108 85,86,87,88 Ethernet28
Ethernet112 117,118,119,120 Ethernet29
Ethernet116 113,114,115,116 Ethernet30
Ethernet120 5,6,7,8 Ethernet31
Ethernet124 1,2,3,4 Ethernet32
220 changes: 220 additions & 0 deletions device/arista/x86_64-arista_7050_qx32/plugins/eeprom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
#!/usr/bin/env python

#############################################################################
# Arista 7050-QX32
#
# 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
import subprocess
import re
import struct
import zlib
import StringIO
from sonic_eeprom import eeprom_base
from sonic_eeprom import eeprom_tlvinfo
except ImportError, e:
raise ImportError (str(e) + "- required module not found")

def showMac( m ):
return ":".join([m[0:2], m[2:4], m[4:6], m[6:8], m[8:10], m[10:12]])

typeMap = {
"END" : ( "00", None, None, None, False ),
"SKU" : ( "03", None, None, None, False ),
"MAC" : ( "05", None, showMac, None, False ),
"SerialNumber" : ( "0E", None, None, None, False ),
}

idToNameMap = {}
for k, v in typeMap.iteritems():
idToNameMap[ v[0] ] = k

class board(eeprom_tlvinfo.TlvInfoDecoder):
_TLV_INFO_MAX_LEN = 256
_TLV_HDR_ENABLED = 0

pFdl = None

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

def _decode_eeprom(self, e):
# For format 0002 and more recent fdls use the new Prefdl class
data = e[0:4]
if data in ("0002", "0003"):
fp = StringIO.StringIO(e[4:])
self.pFdl = PreFdl( fp, data, data )

def decode_eeprom(self, e):
self._decode_eeprom(e)
return self.pFdl.show()

def is_checksum_valid(self, e):
self._decode_eeprom(e)
return (True, self.pFdl.get_crc())

def serial_number_str(self, e):
self._decode_eeprom(e)
return self.pFdl.get_field('SerialNumber')

def mgmtaddrstr(self,e):
self._decode_eeprom(e)
return self.pFdl.get_field('MAC')

def crc32( data ):
return struct.unpack("I",struct.pack("i",zlib.crc32( data )))[0]

def validSerial( x ):
x = x.replace( " ", "" )
x = x.replace( "-", "" )
# All serial numbers are upper case
x = x.upper()
if re.compile( "[A-Z]{3}\d{4}[A-Z0-9]{4}$" ).match( x ):
return x
return None

class PreFdlField( ):
def __init__( self, name, valid, show, optionName, data=None, append=False ):
self.name = name
if valid:
self.valid = valid
else:
self.valid = lambda x: x
self.show = show
self.optionName = optionName
self.data = []
self.append = append
if data:
self.dataIs( data )

def dataIs( self, data ):
vd = self.valid( data )
if not vd:
raise InvalidPrefdlData( "Invalid %s: %s" % ( self.name, data ) )
if self.append:
self.data.append( vd )
else:
self.data = [ vd ]

class TlvField( PreFdlField ):
def __init__( self, name ):
args = typeMap.get( name )
valid = None
show = None
optionName = None
append = False
if args:
self.id, valid, show, optionName, append = args
PreFdlField.__init__( self, name, valid, show, optionName, append=append )


class PreFdl():
def __init__( self, fp=None, preFdlStr=None, version="0002" ):
# populate the required fields
self.requiredFields = []
self.mac = None
self.serial = None

if version == "0002":
preFdlStr, offset = self.initPreFdl2( fp, preFdlStr )
elif version == "0003":
preFdlStr, offset = self.initPreFdl3( fp, preFdlStr )
else:
raise NotImplementedError(
"Only Prefdl data format version 0002 or 0003 are supported" )

# populate the tlv fileds
self.tlvFields = {}
for k in typeMap.keys():
self.tlvFields[ k ] = TlvField( k )

# create the map option to field
self.optionMap = {}
for f in self.requiredFields + self.tlvFields.values():
# Do not add the option from TLV if already added by required fields
if f.optionName and f.optionName not in self.optionMap:
self.optionMap[ f.optionName ] = f

# save the current tlv fields
if fp:
while True:
tlv = fp.read( 6 )
( id, lengthStr ) = ( tlv[0:2], tlv[2:6] )
length = int( lengthStr, base=16 )
bytes = fp.read( length )
what = None if id not in idToNameMap.keys() else idToNameMap[ id ]
if what and what != "END":
self.tlvFields[ what ].dataIs( bytes )
preFdlStr += tlv + bytes
offset += 6 + length
if what == "END":
# End of the tlv list
break
self.crc = fp.read( 8 )
# Check the CRC
computed = crc32( preFdlStr )
if int( self.crc, 16 ) != computed:
raise Exception( "Invalid CRC -- saw %s expected %8X" %
( self.crc, computed ) )

# Initialize and parse fixed section for prefdl version 2. Return the offset
# to where the TLV section starts.
def initPreFdl2( self, fp, preFdlStr ):
# if we start with an existing file
if fp:
# if no preFdlStr is specified, read the fixed section, 30 bytes.
# Otherwise, only the 4 byte data version section was written and
# read the remaining 26 bytes from the fixed section.
if not preFdlStr:
preFdlStr = fp.read( 30 ).strip()
elif preFdlStr == "0002":
preFdlStr += fp.read( 26 ).strip()
else:
raise ValueError( "preFdlStr arg has invalid data format" )
if len( preFdlStr ) < 12:
fatal( "prefdl is too short exiting" )
data = None if not preFdlStr else preFdlStr[ 16:16 + 11 ]
self.requiredFields.append(
PreFdlField( "SerialNumber", validSerial, None, None, data ) )
return preFdlStr, 30

# Initialize and parse fixed section for prefdl version 3. Return the offset
# to where the TLV section starts.
def initPreFdl3( self, fp, preFdlStr ):
# if we start with an existing file
currPtr = 0
if fp and not preFdlStr:
preFdlStr = fp.read( 4 ).strip()
if len( preFdlStr ) < 4:
fatal( "prefdl is too short exiting" )
return preFdlStr, 4

def show( self ):
for f in self.requiredFields + self.tlvFields.values():
for d in f.data:
dStr = d if f.show is None else f.show( d )
print "%s: %s" % ( f.name, dStr )

def get_field( self, name ):
for f in self.requiredFields + self.tlvFields.values():
for d in f.data:
if f.name == name:
dStr = d if f.show is None else f.show( d )
return dStr

def get_crc( self ):
return self.crc

27 changes: 27 additions & 0 deletions device/arista/x86_64-arista_7050_qx32/plugins/sfputil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env 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

eeprom_offset = 10

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/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom'
for x in range(0, self.port_end + 1):
self.port_to_eeprom_mapping[x] = eeprom_path.format(x + self.eeprom_offset)
sfputilbase.__init__(self, port_num)
Loading