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]: sfputil BFN platform module #3324

Merged
merged 1 commit into from
Aug 13, 2019
Merged
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
@@ -1,33 +1,33 @@
# name lanes alias speed autoneg fec
Ethernet0 0,1,2,3 Ethernet0 100000 0 rs
Ethernet4 4,5,6,7 Ethernet4 100000 0 rs
Ethernet8 8,9,10,11 Ethernet8 100000 0 rs
Ethernet12 12,13,14,15 Ethernet12 100000 0 rs
Ethernet16 16,17,18,19 Ethernet16 100000 0 rs
Ethernet20 20,21,22,23 Ethernet20 100000 0 rs
Ethernet24 24,25,26,27 Ethernet24 100000 0 rs
Ethernet28 28,29,30,31 Ethernet28 100000 0 rs
Ethernet32 32,33,34,35 Ethernet32 100000 0 rs
Ethernet36 36,37,38,39 Ethernet36 100000 0 rs
Ethernet40 40,41,42,43 Ethernet40 100000 0 rs
Ethernet44 44,45,46,47 Ethernet44 100000 0 rs
Ethernet48 48,49,50,51 Ethernet48 100000 0 rs
Ethernet52 52,53,54,55 Ethernet52 100000 0 rs
Ethernet56 56,57,58,59 Ethernet56 100000 0 rs
Ethernet60 60,61,62,63 Ethernet60 100000 0 rs
Ethernet64 64,65,66,67 Ethernet64 100000 0 rs
Ethernet68 68,69,70,71 Ethernet68 100000 0 rs
Ethernet72 72,73,74,75 Ethernet72 100000 0 rs
Ethernet76 76,77,78,79 Ethernet76 100000 0 rs
Ethernet80 80,81,82,83 Ethernet80 100000 0 rs
Ethernet84 84,85,86,87 Ethernet84 100000 0 rs
Ethernet88 88,89,90,91 Ethernet88 100000 0 rs
Ethernet92 92,93,94,95 Ethernet92 100000 0 rs
Ethernet96 96,97,98,99 Ethernet96 100000 0 rs
Ethernet100 100,101,102,103 Ethernet100 100000 0 rs
Ethernet104 104,105,106,107 Ethernet104 100000 0 rs
Ethernet108 108,109,110,111 Ethernet108 100000 0 rs
Ethernet112 112,113,114,115 Ethernet112 100000 0 rs
Ethernet116 116,117,118,119 Ethernet116 100000 0 rs
Ethernet120 120,121,122,123 Ethernet120 100000 0 rs
Ethernet124 124,125,126,127 Ethernet124 100000 0 rs
# name lanes alias index speed autoneg fec
Ethernet0 0,1,2,3 Ethernet0 1 100000 0 rs
Ethernet4 4,5,6,7 Ethernet4 2 100000 0 rs
Ethernet8 8,9,10,11 Ethernet8 3 100000 0 rs
Ethernet12 12,13,14,15 Ethernet12 4 100000 0 rs
Ethernet16 16,17,18,19 Ethernet16 5 100000 0 rs
Ethernet20 20,21,22,23 Ethernet20 6 100000 0 rs
Ethernet24 24,25,26,27 Ethernet24 7 100000 0 rs
Ethernet28 28,29,30,31 Ethernet28 8 100000 0 rs
Ethernet32 32,33,34,35 Ethernet32 9 100000 0 rs
Ethernet36 36,37,38,39 Ethernet36 10 100000 0 rs
Ethernet40 40,41,42,43 Ethernet40 11 100000 0 rs
Ethernet44 44,45,46,47 Ethernet44 12 100000 0 rs
Ethernet48 48,49,50,51 Ethernet48 13 100000 0 rs
Ethernet52 52,53,54,55 Ethernet52 14 100000 0 rs
Ethernet56 56,57,58,59 Ethernet56 15 100000 0 rs
Ethernet60 60,61,62,63 Ethernet60 16 100000 0 rs
Ethernet64 64,65,66,67 Ethernet64 17 100000 0 rs
Ethernet68 68,69,70,71 Ethernet68 18 100000 0 rs
Ethernet72 72,73,74,75 Ethernet72 19 100000 0 rs
Ethernet76 76,77,78,79 Ethernet76 20 100000 0 rs
Ethernet80 80,81,82,83 Ethernet80 21 100000 0 rs
Ethernet84 84,85,86,87 Ethernet84 22 100000 0 rs
Ethernet88 88,89,90,91 Ethernet88 23 100000 0 rs
Ethernet92 92,93,94,95 Ethernet92 24 100000 0 rs
Ethernet96 96,97,98,99 Ethernet96 25 100000 0 rs
Ethernet100 100,101,102,103 Ethernet100 26 100000 0 rs
Ethernet104 104,105,106,107 Ethernet104 27 100000 0 rs
Ethernet108 108,109,110,111 Ethernet108 28 100000 0 rs
Ethernet112 112,113,114,115 Ethernet112 29 100000 0 rs
Ethernet116 116,117,118,119 Ethernet116 30 100000 0 rs
Ethernet120 120,121,122,123 Ethernet120 31 100000 0 rs
Ethernet124 124,125,126,127 Ethernet124 32 100000 0 rs
167 changes: 167 additions & 0 deletions device/barefoot/x86_64-accton_wedge100bf_32x-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#!/usr/bin/env python

try:
import os
import sys
import importlib
import time

sys.path.append(os.path.dirname(__file__))
import pltfm_mgr_rpc
from pltfm_mgr_rpc.ttypes import *

from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.protocol import TMultiplexedProtocol

from sonic_sfp.sfputilbase import SfpUtilBase
except ImportError as e:
raise ImportError (str(e) + "- required module not found")

thrift_server = 'localhost'
transport = None
pltfm_mgr = None

SFP_EEPROM_CACHE = "/var/run/platform/sfp/cache"

class SfpUtil(SfpUtilBase):
"""Platform-specific SfpUtil class"""

PORT_START = 1
PORT_END = 0
PORTS_IN_BLOCK = 0
QSFP_PORT_START = 1
QSFP_PORT_END = 0
EEPROM_OFFSET = 0

@property
def port_start(self):
self.update_port_info()
return self.PORT_START

@property
def port_end(self):
self.update_port_info()
return self.PORT_END

@property
def qsfp_ports(self):
self.update_port_info()
return range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1)

@property
def port_to_eeprom_mapping(self):
print "dependency on sysfs has been removed"
raise Exception()

def __init__(self):
if not os.path.exists(os.path.dirname(SFP_EEPROM_CACHE)):
try:
os.makedirs(os.path.dirname(SFP_EEPROM_CACHE))
except OSError as e:
if e.errno != errno.EEXIST:
raise

open(SFP_EEPROM_CACHE, 'ab').close()

SfpUtilBase.__init__(self)

def update_port_info(self):
global pltfm_mgr

if self.QSFP_PORT_END == 0:
self.thrift_setup()
self.QSFP_PORT_END = pltfm_mgr.pltfm_mgr_qsfp_get_max_port();
self.PORT_END = self.QSFP_PORT_END
self.PORTS_IN_BLOCK = self.QSFP_PORT_END
self.thrift_teardown()

def thrift_setup(self):
global thrift_server, transport, pltfm_mgr
transport = TSocket.TSocket(thrift_server, 9090)

transport = TTransport.TBufferedTransport(transport)
bprotocol = TBinaryProtocol.TBinaryProtocol(transport)

pltfm_mgr_client_module = importlib.import_module(".".join(["pltfm_mgr_rpc", "pltfm_mgr_rpc"]))
pltfm_mgr_protocol = TMultiplexedProtocol.TMultiplexedProtocol(bprotocol, "pltfm_mgr_rpc")
pltfm_mgr = pltfm_mgr_client_module.Client(pltfm_mgr_protocol)

transport.open()

def thrift_teardown(self):
global transport
transport.close()

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

presence = False

try:
self.thrift_setup()
presence = pltfm_mgr.pltfm_mgr_qsfp_presence_get(port_num)
self.thrift_teardown()
except Exception as e:
print e.__doc__
print e.message

return presence

def get_low_power_mode(self, port_num):
# Check for invalid port_num
if port_num < self.port_start or port_num > self.port_end:
return False

self.thrift_setup()
lpmode = pltfm_mgr.pltfm_mgr_qsfp_lpmode_get(port_num)
self.thrift_teardown()
return lpmode

def set_low_power_mode(self, port_num, lpmode):
# Check for invalid port_num
if port_num < self.port_start or port_num > self.port_end:
return False

self.thrift_setup()
status = pltfm_mgr.pltfm_mgr_qsfp_lpmode_set(port_num, lpmode)
self.thrift_teardown()
return status

def reset(self, port_num):
# Check for invalid port_num
if port_num < self.port_start or port_num > self.port_end:
return False

self.thrift_setup()
status = pltfm_mgr.pltfm_mgr_qsfp_reset(port_num, True)
status = pltfm_mgr.pltfm_mgr_qsfp_reset(port_num, False)
self.thrift_teardown()
return status

def get_transceiver_change_event(self, timeout=0):
phy_port_dict = {}
status = True
# TODO: Process transceiver plug-in/out event
time.sleep(1)
return status, phy_port_dict

def _get_port_eeprom_path(self, port_num, devid):
eeprom_path = None

self.thrift_setup()
presence = pltfm_mgr.pltfm_mgr_qsfp_presence_get(port_num)
if presence == True:
eeprom_cache = open(SFP_EEPROM_CACHE, 'wb')
eeprom_hex = pltfm_mgr.pltfm_mgr_qsfp_info_get(port_num)
eeprom_raw = bytearray.fromhex(eeprom_hex)
eeprom_cache.write(eeprom_raw)
eeprom_cache.close()
eeprom_path = SFP_EEPROM_CACHE
self.thrift_teardown()

return eeprom_path

Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
# name lanes alias speed autoneg fec
Ethernet0 0,1,2,3 Ethernet0 100000 0 rs
Ethernet4 4,5,6,7 Ethernet4 100000 0 rs
Ethernet8 8,9,10,11 Ethernet8 100000 0 rs
Ethernet12 12,13,14,15 Ethernet12 100000 0 rs
Ethernet16 16,17,18,19 Ethernet16 100000 0 rs
Ethernet20 20,21,22,23 Ethernet20 100000 0 rs
Ethernet24 24,25,26,27 Ethernet24 100000 0 rs
Ethernet28 28,29,30,31 Ethernet28 100000 0 rs
Ethernet32 32,33,34,35 Ethernet32 100000 0 rs
Ethernet36 36,37,38,39 Ethernet36 100000 0 rs
Ethernet40 40,41,42,43 Ethernet40 100000 0 rs
Ethernet44 44,45,46,47 Ethernet44 100000 0 rs
Ethernet48 48,49,50,51 Ethernet48 100000 0 rs
Ethernet52 52,53,54,55 Ethernet52 100000 0 rs
Ethernet56 56,57,58,59 Ethernet56 100000 0 rs
Ethernet60 60,61,62,63 Ethernet60 100000 0 rs
Ethernet64 64,65,66,67 Ethernet64 100000 0 rs
Ethernet68 68,69,70,71 Ethernet68 100000 0 rs
Ethernet72 72,73,74,75 Ethernet72 100000 0 rs
Ethernet76 76,77,78,79 Ethernet76 100000 0 rs
Ethernet80 80,81,82,83 Ethernet80 100000 0 rs
Ethernet84 84,85,86,87 Ethernet84 100000 0 rs
Ethernet88 88,89,90,91 Ethernet88 100000 0 rs
Ethernet92 92,93,94,95 Ethernet92 100000 0 rs
Ethernet96 96,97,98,99 Ethernet96 100000 0 rs
Ethernet100 100,101,102,103 Ethernet100 100000 0 rs
Ethernet104 104,105,106,107 Ethernet104 100000 0 rs
Ethernet108 108,109,110,111 Ethernet108 100000 0 rs
Ethernet112 112,113,114,115 Ethernet112 100000 0 rs
Ethernet116 116,117,118,119 Ethernet116 100000 0 rs
Ethernet120 120,121,122,123 Ethernet120 100000 0 rs
Ethernet124 124,125,126,127 Ethernet124 100000 0 rs
Ethernet128 128,129,130,131 Ethernet128 100000 0 rs
Ethernet132 132,133,134,135 Ethernet132 100000 0 rs
Ethernet136 136,137,138,139 Ethernet136 100000 0 rs
Ethernet140 140,141,142,143 Ethernet140 100000 0 rs
Ethernet144 144,145,146,147 Ethernet144 100000 0 rs
Ethernet148 148,149,150,151 Ethernet148 100000 0 rs
Ethernet152 152,153,154,155 Ethernet152 100000 0 rs
Ethernet156 156,157,158,159 Ethernet156 100000 0 rs
Ethernet160 160,161,162,163 Ethernet169 100000 0 rs
Ethernet164 164,165,166,167 Ethernet164 100000 0 rs
Ethernet168 168,169,170,171 Ethernet168 100000 0 rs
Ethernet172 172,173,174,175 Ethernet172 100000 0 rs
Ethernet176 176,177,178,179 Ethernet176 100000 0 rs
Ethernet180 180,181,182,183 Ethernet180 100000 0 rs
Ethernet184 184,185,186,187 Ethernet184 100000 0 rs
Ethernet188 188,189,190,191 Ethernet188 100000 0 rs
Ethernet192 192,193,194,195 Ethernet192 100000 0 rs
Ethernet196 196,197,198,199 Ethernet196 100000 0 rs
Ethernet200 200,201,202,203 Ethernet200 100000 0 rs
Ethernet204 204,205,206,207 Ethernet204 100000 0 rs
Ethernet208 208,209,210,211 Ethernet208 100000 0 rs
Ethernet212 212,213,214,215 Ethernet212 100000 0 rs
Ethernet216 216,217,218,219 Ethernet216 100000 0 rs
Ethernet220 220,221,222,223 Ethernet220 100000 0 rs
Ethernet224 224,225,226,227 Ethernet224 100000 0 rs
Ethernet228 228,229,230,231 Ethernet228 100000 0 rs
Ethernet232 232,233,234,235 Ethernet232 100000 0 rs
Ethernet236 236,237,238,239 Ethernet236 100000 0 rs
Ethernet240 240,241,242,243 Ethernet240 100000 0 rs
Ethernet244 244,245,246,247 Ethernet244 100000 0 rs
Ethernet248 248,249,250,251 Ethernet248 100000 0 rs
Ethernet252 252,253,254,255 Etherner252 100000 0 rs
# name lanes alias index speed autoneg fec
Ethernet0 0,1,2,3 Ethernet0 1 100000 0 rs
Ethernet4 4,5,6,7 Ethernet4 2 100000 0 rs
Ethernet8 8,9,10,11 Ethernet8 3 100000 0 rs
Ethernet12 12,13,14,15 Ethernet12 4 100000 0 rs
Ethernet16 16,17,18,19 Ethernet16 5 100000 0 rs
Ethernet20 20,21,22,23 Ethernet20 6 100000 0 rs
Ethernet24 24,25,26,27 Ethernet24 7 100000 0 rs
Ethernet28 28,29,30,31 Ethernet28 8 100000 0 rs
Ethernet32 32,33,34,35 Ethernet32 9 100000 0 rs
Ethernet36 36,37,38,39 Ethernet36 10 100000 0 rs
Ethernet40 40,41,42,43 Ethernet40 11 100000 0 rs
Ethernet44 44,45,46,47 Ethernet44 12 100000 0 rs
Ethernet48 48,49,50,51 Ethernet48 13 100000 0 rs
Ethernet52 52,53,54,55 Ethernet52 14 100000 0 rs
Ethernet56 56,57,58,59 Ethernet56 15 100000 0 rs
Ethernet60 60,61,62,63 Ethernet60 16 100000 0 rs
Ethernet64 64,65,66,67 Ethernet64 17 100000 0 rs
Ethernet68 68,69,70,71 Ethernet68 18 100000 0 rs
Ethernet72 72,73,74,75 Ethernet72 19 100000 0 rs
Ethernet76 76,77,78,79 Ethernet76 20 100000 0 rs
Ethernet80 80,81,82,83 Ethernet80 21 100000 0 rs
Ethernet84 84,85,86,87 Ethernet84 22 100000 0 rs
Ethernet88 88,89,90,91 Ethernet88 23 100000 0 rs
Ethernet92 92,93,94,95 Ethernet92 24 100000 0 rs
Ethernet96 96,97,98,99 Ethernet96 25 100000 0 rs
Ethernet100 100,101,102,103 Ethernet100 26 100000 0 rs
Ethernet104 104,105,106,107 Ethernet104 27 100000 0 rs
Ethernet108 108,109,110,111 Ethernet108 28 100000 0 rs
Ethernet112 112,113,114,115 Ethernet112 29 100000 0 rs
Ethernet116 116,117,118,119 Ethernet116 30 100000 0 rs
Ethernet120 120,121,122,123 Ethernet120 31 100000 0 rs
Ethernet124 124,125,126,127 Ethernet124 32 100000 0 rs
Ethernet128 128,129,130,131 Ethernet128 33 100000 0 rs
Ethernet132 132,133,134,135 Ethernet132 34 100000 0 rs
Ethernet136 136,137,138,139 Ethernet136 35 100000 0 rs
Ethernet140 140,141,142,143 Ethernet140 36 100000 0 rs
Ethernet144 144,145,146,147 Ethernet144 37 100000 0 rs
Ethernet148 148,149,150,151 Ethernet148 38 100000 0 rs
Ethernet152 152,153,154,155 Ethernet152 39 100000 0 rs
Ethernet156 156,157,158,159 Ethernet156 40 100000 0 rs
Ethernet160 160,161,162,163 Ethernet169 41 100000 0 rs
Ethernet164 164,165,166,167 Ethernet164 42 100000 0 rs
Ethernet168 168,169,170,171 Ethernet168 43 100000 0 rs
Ethernet172 172,173,174,175 Ethernet172 44 100000 0 rs
Ethernet176 176,177,178,179 Ethernet176 45 100000 0 rs
Ethernet180 180,181,182,183 Ethernet180 46 100000 0 rs
Ethernet184 184,185,186,187 Ethernet184 47 100000 0 rs
Ethernet188 188,189,190,191 Ethernet188 48 100000 0 rs
Ethernet192 192,193,194,195 Ethernet192 49 100000 0 rs
Ethernet196 196,197,198,199 Ethernet196 50 100000 0 rs
Ethernet200 200,201,202,203 Ethernet200 51 100000 0 rs
Ethernet204 204,205,206,207 Ethernet204 52 100000 0 rs
Ethernet208 208,209,210,211 Ethernet208 53 100000 0 rs
Ethernet212 212,213,214,215 Ethernet212 54 100000 0 rs
Ethernet216 216,217,218,219 Ethernet216 55 100000 0 rs
Ethernet220 220,221,222,223 Ethernet220 56 100000 0 rs
Ethernet224 224,225,226,227 Ethernet224 57 100000 0 rs
Ethernet228 228,229,230,231 Ethernet228 58 100000 0 rs
Ethernet232 232,233,234,235 Ethernet232 59 100000 0 rs
Ethernet236 236,237,238,239 Ethernet236 60 100000 0 rs
Ethernet240 240,241,242,243 Ethernet240 61 100000 0 rs
Ethernet244 244,245,246,247 Ethernet244 62 100000 0 rs
Ethernet248 248,249,250,251 Ethernet248 63 100000 0 rs
Ethernet252 252,253,254,255 Etherner252 64 100000 0 rs