Skip to content

Commit

Permalink
Extended BFN platform SFP APIs implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Andriy Kokhan committed Nov 30, 2021
1 parent 1bdac55 commit 40c3f00
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 64 deletions.
65 changes: 34 additions & 31 deletions device/barefoot/x86_64-accton_as9516_32d-r0/platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,97 +107,100 @@
],
"sfps": [
{
"name": "Ethernet0"
"name": "sfp1"
},
{
"name": "Ethernet8"
"name": "sfp2"
},
{
"name": "Ethernet16"
"name": "sfp3"
},
{
"name": "Ethernet32"
"name": "sfp4"
},
{
"name": "Ethernet40"
"name": "sfp5"
},
{
"name": "Ethernet48"
"name": "sfp6"
},
{
"name": "Ethernet56"
"name": "sfp7"
},
{
"name": "Ethernet64"
"name": "sfp8"
},
{
"name": "Ethernet72"
"name": "sfp9"
},
{
"name": "Ethernet80"
"name": "sfp10"
},
{
"name": "Ethernet88"
"name": "sfp11"
},
{
"name": "Ethernet96"
"name": "sfp12"
},
{
"name": "Ethernet104"
"name": "sfp13"
},
{
"name": "Ethernet112"
"name": "sfp14"
},
{
"name": "Ethernet120"
"name": "sfp15"
},
{
"name": "Ethernet128"
"name": "sfp16"
},
{
"name": "Ethernet136"
"name": "sfp17"
},
{
"name": "Ethernet144"
"name": "sfp18"
},
{
"name": "Ethernet152"
"name": "sfp19"
},
{
"name": "Ethernet160"
"name": "sfp20"
},
{
"name": "Ethernet168"
"name": "sfp21"
},
{
"name": "Ethernet176"
"name": "sfp22"
},
{
"name": "Ethernet184"
"name": "sfp23"
},
{
"name": "Ethernet192"
"name": "sfp24"
},
{
"name": "Ethernet200"
"name": "sfp25"
},
{
"name": "Ethernet208"
"name": "sfp26"
},
{
"name": "Ethernet216"
"name": "sfp27"
},
{
"name": "Ethernet224"
"name": "sfp28"
},
{
"name": "Ethernet232"
"name": "sfp29"
},
{
"name": "Ethernet240"
"name": "sfp30"
},
{
"name": "Ethernet248"
"name": "sfp31"
},
{
"name": "sfp32"
}
]
},
Expand Down
64 changes: 32 additions & 32 deletions device/barefoot/x86_64-accton_wedge100bf_32x-r0/platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,100 +110,100 @@
],
"sfps": [
{
"name": "Ethernet0"
"name": "sfp1"
},
{
"name": "Ethernet4"
"name": "sfp2"
},
{
"name": "Ethernet8"
"name": "sfp3"
},
{
"name": "Ethernet12"
"name": "sfp4"
},
{
"name": "Ethernet16"
"name": "sfp5"
},
{
"name": "Ethernet20"
"name": "sfp6"
},
{
"name": "Ethernet24"
"name": "sfp7"
},
{
"name": "Ethernet28"
"name": "sfp8"
},
{
"name": "Ethernet32"
"name": "sfp9"
},
{
"name": "Ethernet36"
"name": "sfp10"
},
{
"name": "Ethernet40"
"name": "sfp11"
},
{
"name": "Ethernet44"
"name": "sfp12"
},
{
"name": "Ethernet48"
"name": "sfp13"
},
{
"name": "Ethernet52"
"name": "sfp14"
},
{
"name": "Ethernet56"
"name": "sfp15"
},
{
"name": "Ethernet60"
"name": "sfp16"
},
{
"name": "Ethernet64"
"name": "sfp17"
},
{
"name": "Ethernet68"
"name": "sfp18"
},
{
"name": "Ethernet72"
"name": "sfp19"
},
{
"name": "Ethernet76"
"name": "sfp20"
},
{
"name": "Ethernet80"
"name": "sfp21"
},
{
"name": "Ethernet84"
"name": "sfp22"
},
{
"name": "Ethernet88"
"name": "sfp23"
},
{
"name": "Ethernet92"
"name": "sfp24"
},
{
"name": "Ethernet96"
"name": "sfp25"
},
{
"name": "Ethernet100"
"name": "sfp26"
},
{
"name": "Ethernet104"
"name": "sfp27"
},
{
"name": "Ethernet108"
"name": "sfp28"
},
{
"name": "Ethernet112"
"name": "sfp29"
},
{
"name": "Ethernet116"
"name": "sfp30"
},
{
"name": "Ethernet120"
"name": "sfp31"
},
{
"name": "Ethernet124"
"name": "sfp32"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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

Expand Down Expand Up @@ -60,10 +61,13 @@ def __init__(self):

def update_port_info(self):
def qsfp_max_port_get(client):
return client.pltfm_mgr.pltfm_mgr_qsfp_get_max_port();
return client.pltfm_mgr.pltfm_mgr_qsfp_get_max_port()

if self.QSFP_PORT_END == 0:
platform = device_info.get_platform()
self.QSFP_PORT_END = thrift_try(qsfp_max_port_get)
if platform in ["x86_64-accton_as9516_32d-r0", "x86_64-accton_as9516bf_32d-r0"]:
self.QSFP_PORT_END -= 1
self.PORT_END = self.QSFP_PORT_END
self.PORTS_IN_BLOCK = self.QSFP_PORT_END

Expand Down Expand Up @@ -237,6 +241,7 @@ def get_transceiver_change_event(timeout=0):
return Sfp.sfputil.get_transceiver_change_event()

def __init__(self, port_num):
self.index = port_num
self.port_num = port_num
SfpBase.__init__(self)

Expand Down Expand Up @@ -270,6 +275,40 @@ def get_transceiver_threshold_info(self):
def get_change_event(self, timeout=0):
return Sfp.get_transceiver_change_event(timeout)

def is_replaceable(self):
"""
Indicate whether this device is replaceable.
Returns:
bool: True if it is replaceable.
"""
return True

def get_name(self):
"""
Retrieves the name of the device
Returns:
string: The name of the device
"""
return "sfp{}".format(self.index)

def get_model(self):
"""
Retrieves the model number (or part number) of the device
Returns:
string: Model/part number of device
"""
info = self.get_transceiver_info()
return info.get("model", "N/A")

def get_serial(self):
"""
Retrieves the serial number of the device
Returns:
string: Serial number of device
"""
info = self.get_transceiver_info()
return info.get("serial", "N/A")

def sfp_list_get():
sfp_list = []
for index in range(Sfp.port_start(), Sfp.port_end() + 1):
Expand Down

0 comments on commit 40c3f00

Please sign in to comment.