Skip to content

Commit 912797e

Browse files
authored
Support get_port_or_cage_type (sonic-net#288)
* 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 <[email protected]> * Add comments to explain the types Signed-off-by: Stephen Sun <[email protected]>
1 parent d8abf47 commit 912797e

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

sonic_platform_base/chassis_base.py

+22-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import sys
99
from . import device_base
10-
10+
from . import sfp_base
1111

1212
class ChassisBase(device_base.DeviceBase):
1313
"""
@@ -498,6 +498,27 @@ def get_sfp(self, index):
498498

499499
return sfp
500500

501+
502+
def get_port_or_cage_type(self, index):
503+
"""
504+
Retrieves sfp port or cage type corresponding to physical port <index>
505+
506+
Args:
507+
index: An integer (>=0), the index of the sfp to retrieve.
508+
The index should correspond to the physical port in a chassis.
509+
For example:-
510+
1 for Ethernet0, 2 for Ethernet4 and so on for one platform.
511+
0 for Ethernet0, 1 for Ethernet4 and so on for another platform.
512+
513+
Returns:
514+
The masks of all types of port or cage that can be supported on the port
515+
Types are defined in sfp_base.py
516+
Eg.
517+
Both SFP and SFP+ are supported on the port, the return value should be 0x0a
518+
which is 0x02 | 0x08
519+
"""
520+
raise NotImplementedError
521+
501522
##############################################
502523
# System LED methods
503524
##############################################
@@ -582,4 +603,3 @@ def get_change_event(self, timeout=0):
582603
status='6' Bad cable.
583604
"""
584605
raise NotImplementedError
585-

sonic_platform_base/sfp_base.py

+19
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,25 @@ class SfpBase(device_base.DeviceBase):
5252
SFP_ERROR_BIT_BAD_CABLE: SFP_ERROR_DESCRIPTION_BAD_CABLE
5353
}
5454

55+
# Port types that are used by the chassis API ChassisBase.get_port_or_cage_type()
56+
# It's possible that multiple types are supported on one port.
57+
# In that case, the result will be logical OR of all the supported types
58+
# Check example in ChassisBase.get_port_or_cage_type()
59+
SFP_PORT_TYPE_BIT_RJ45 = 0x00000001
60+
SFP_PORT_TYPE_BIT_SFP = 0x00000002
61+
SFP_PORT_TYPE_BIT_XFP = 0x00000004
62+
SFP_PORT_TYPE_BIT_SFP_PLUS = 0x00000008
63+
SFP_PORT_TYPE_BIT_QSFP = 0x00000010
64+
SFP_PORT_TYPE_BIT_CFP = 0x00000020
65+
SFP_PORT_TYPE_BIT_QSFP_PLUS = 0x00000040
66+
SFP_PORT_TYPE_BIT_QSFP28 = 0x00000080
67+
SFP_PORT_TYPE_BIT_SFP28 = 0x00000100
68+
SFP_PORT_TYPE_BIT_CFP2 = 0x00000200
69+
SFP_PORT_TYPE_BIT_QSFP56 = 0x00000400
70+
SFP_PORT_TYPE_BIT_QSFPDD = 0x00000800
71+
SFP_PORT_TYPE_BIT_OSFP = 0x00001000
72+
SFP_PORT_TYPE_BIT_SFP_DD = 0x00002000
73+
5574
def __init__(self):
5675
# List of ThermalBase-derived objects representing all thermals
5776
# available on the SFP

0 commit comments

Comments
 (0)