Skip to content

Commit ccf706b

Browse files
committed
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]>
1 parent 0d45adb commit ccf706b

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-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

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

55+
SFP_PORT_TYPE_BIT_RJ45 = 0x00000001
56+
SFP_PORT_TYPE_BIT_SFP = 0x00000002
57+
SFP_PORT_TYPE_BIT_XFP = 0x00000004
58+
SFP_PORT_TYPE_BIT_SFP_PLUS = 0x00000008
59+
SFP_PORT_TYPE_BIT_QSFP = 0x00000010
60+
SFP_PORT_TYPE_BIT_CFP = 0x00000020
61+
SFP_PORT_TYPE_BIT_QSFP_PLUS = 0x00000040
62+
SFP_PORT_TYPE_BIT_QSFP28 = 0x00000080
63+
SFP_PORT_TYPE_BIT_SFP28 = 0x00000100
64+
SFP_PORT_TYPE_BIT_CFP2 = 0x00000200
65+
SFP_PORT_TYPE_BIT_QSFP56 = 0x00000400
66+
SFP_PORT_TYPE_BIT_QSFPDD = 0x00000800
67+
SFP_PORT_TYPE_BIT_OSFP = 0x00001000
68+
SFP_PORT_TYPE_BIT_SFP_DD = 0x00002000
69+
5570
def __init__(self):
5671
# List of ThermalBase-derived objects representing all thermals
5772
# available on the SFP

0 commit comments

Comments
 (0)