SAI
SAI copied to clipboard
[SAI-PTF] Need generic/common approach to initialized Ports when setup environment
Summary
For initializing the ports when setting up the switch for some basic test configurations. Initializing the port by the method 'remove-recreate' does not work on some platforms. We also need a more generic/common way to get the setting for the initialization process.
Details
There is code for init the port createPorts
def createPorts(self):
"""
Create ports after reading from the port config file
"""
...
self.port_list = attr['port_list'].idlist
for port in self.port_list:
sai_thrift_remove_port(self.client, port)
...
sai_thrift_create_port(self.client,
hw_lane_list=sai_list,
fec_mode=fec_mode,
auto_neg_mode=auto_neg_mode,
speed=port['speed'],
admin_state=True)
Procedure is not a common way for all hardware platforms.
Take SONiC for example in some platform
#1. SAI_SWITCH_ATTR_PORT_LIST
|G|SAI_STATUS_SUCCESS|SAI_SWITCH_ATTR_PORT_LIST
#2. Check attrs
|G|SAI_STATUS_SUCCESS|SAI_PORT_ATTR_HW_LANE_LIST
|G|SAI_STATUS_SUCCESS|SAI_PORT_ATTR_NUMBER_OF_INGRESS_PRIORITY_GROUPS=8
#3. set the attr as needed
|s|SAI_OBJECT_TYPE_PORT:oid:0x100000000001f|SAI_PORT_ATTR_MTU=9122
#4. turn admin state
|s|SAI_OBJECT_TYPE_PORT:oid:0x100000000001f|SAI_PORT_ATTR_ADMIN_STATE=true
Relate ERROR
None
Need right configuration for port init
Meanwhile, here is the configuration below, we might load those configurations according to different hardware platforms
hw_lane_list=sai_list,
fec_mode=fec_mode,
auto_neg_mode=auto_neg_mode,
speed=port['speed'],
admin_state=True)
Relate ERROR
Here are the errors when using the new configuration to create the port. We need to use more parameters if need to create a port
ERR saiserverv2#saiserver: [none] SAI_API_PORT:****_sai_create_port:5074 Invalid lane config (4) passed for lane 2
Proposal
Note: This is a temp solution, it is just a workaround, which can help bypass the current issue with a hardware-specific configuration, but we should not use this way finally, there should be some common approach to initialize ports across platforms. We need to spend more time on how to make it (maybe like SONiC).
We skip the recreate process by leveraging the multi-platform architecture. Make the Test class inherit from PlatformSaiHelper
class L2TrunkToTrunkVlanTest(PlatformSaiHelper):
Note: this is just a temp solution, the multi-platform architecture should not be used in this situation, it should be designed for platform-specific features, like some experimental features in certain platforms, but not to compromise the platform's variation or defect. Skipped the recreate
def recreate_ports(self):
"""
Method to recreate the port.
"""
#port recreates not support, an error happened.
print("*****SaiHelperBase::recreate_ports does not support.")
Sample Code or Pull Requests for the proposal
https://github.com/opencomputeproject/SAI/pull/1601 https://github.com/opencomputeproject/SAI/pull/1599