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

Support get_port_or_cage_type #288

Merged
merged 2 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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

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

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