Skip to content

Commit

Permalink
Support get_port_or_cage_type (#288)
Browse files Browse the repository at this point in the history
* Support get_port_or_cage_type

The API returns the masks of all types of port or cage that can be supported on the port
All the types are defined in sfp_base.SfpBase

Signed-off-by: Stephen Sun <stephens@nvidia.com>

* Add comments to explain the types

Signed-off-by: Stephen Sun <stephens@nvidia.com>
  • Loading branch information
stephenxs committed Jul 8, 2022
1 parent d8abf47 commit 912797e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
24 changes: 22 additions & 2 deletions sonic_platform_base/chassis_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import sys
from . import device_base

from . import sfp_base

class ChassisBase(device_base.DeviceBase):
"""
Expand Down Expand Up @@ -498,6 +498,27 @@ def get_sfp(self, index):

return sfp


def get_port_or_cage_type(self, index):
"""
Retrieves sfp port or cage type corresponding to physical port <index>
Args:
index: An integer (>=0), the index of the sfp to retrieve.
The index should correspond to the physical port in a chassis.
For example:-
1 for Ethernet0, 2 for Ethernet4 and so on for one platform.
0 for Ethernet0, 1 for Ethernet4 and so on for another platform.
Returns:
The masks of all types of port or cage that can be supported on the port
Types are defined in sfp_base.py
Eg.
Both SFP and SFP+ are supported on the port, the return value should be 0x0a
which is 0x02 | 0x08
"""
raise NotImplementedError

##############################################
# System LED methods
##############################################
Expand Down Expand Up @@ -582,4 +603,3 @@ def get_change_event(self, timeout=0):
status='6' Bad cable.
"""
raise NotImplementedError

19 changes: 19 additions & 0 deletions sonic_platform_base/sfp_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ class SfpBase(device_base.DeviceBase):
SFP_ERROR_BIT_BAD_CABLE: SFP_ERROR_DESCRIPTION_BAD_CABLE
}

# Port types that are used by the chassis API ChassisBase.get_port_or_cage_type()
# It's possible that multiple types are supported on one port.
# In that case, the result will be logical OR of all the supported types
# Check example in ChassisBase.get_port_or_cage_type()
SFP_PORT_TYPE_BIT_RJ45 = 0x00000001
SFP_PORT_TYPE_BIT_SFP = 0x00000002
SFP_PORT_TYPE_BIT_XFP = 0x00000004
SFP_PORT_TYPE_BIT_SFP_PLUS = 0x00000008
SFP_PORT_TYPE_BIT_QSFP = 0x00000010
SFP_PORT_TYPE_BIT_CFP = 0x00000020
SFP_PORT_TYPE_BIT_QSFP_PLUS = 0x00000040
SFP_PORT_TYPE_BIT_QSFP28 = 0x00000080
SFP_PORT_TYPE_BIT_SFP28 = 0x00000100
SFP_PORT_TYPE_BIT_CFP2 = 0x00000200
SFP_PORT_TYPE_BIT_QSFP56 = 0x00000400
SFP_PORT_TYPE_BIT_QSFPDD = 0x00000800
SFP_PORT_TYPE_BIT_OSFP = 0x00001000
SFP_PORT_TYPE_BIT_SFP_DD = 0x00002000

def __init__(self):
# List of ThermalBase-derived objects representing all thermals
# available on the SFP
Expand Down

0 comments on commit 912797e

Please sign in to comment.