Skip to content

Commit

Permalink
support dx010
Browse files Browse the repository at this point in the history
  • Loading branch information
richardyu-ms committed Jun 19, 2022
1 parent 562ddc6 commit 2414533
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions test/sai_test/config/port_configer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from ptf import config
from sai_utils import * # pylint: disable=wildcard-import; lgtm[py/polluting-import]
from sai_thrift.sai_adapter import *
import pdb


def t0_port_config_helper(test_obj, is_recreate_bridge=True, is_create_hostIf=True):
Expand Down Expand Up @@ -52,6 +53,7 @@ def t0_port_config_helper(test_obj, is_recreate_bridge=True, is_create_hostIf=Tr
default_trap_group = attr['default_trap_group']

port_list = configer.get_port_list()
configer.turn_on_port_admin_state(port_list)
configer.turn_up_and_check_ports(port_list)
default_1q_bridge_id = configer.get_default_1q_bridge()
bridge_port_list = configer.get_bridge_port_list(default_1q_bridge_id)
Expand All @@ -70,8 +72,6 @@ def t0_port_config_helper(test_obj, is_recreate_bridge=True, is_create_hostIf=Tr
test_obj.host_intf_table_id = host_intf_table_id
test_obj.hostif_list = hostif_list

configer.turn_on_port_admin_state(port_list)

test_obj.dev_port_list = dev_port_list
test_obj.portConfigs = portConfigs
test_obj.default_trap_group = default_trap_group
Expand Down Expand Up @@ -357,7 +357,7 @@ def turn_on_port_admin_state(self, port_list):
print("Set port...")
for i, port in enumerate(port_list):
sai_thrift_set_port_attribute(
self.client, port_oid=port, mtu=PORT_MTU, admin_state=True)
self.client, port_oid=port, mtu=PORT_MTU, admin_state=True, fec_mode=SAI_PORT_FEC_MODE_RS)

def turn_up_and_check_ports(self, port_list):
'''
Expand All @@ -370,23 +370,21 @@ def turn_up_and_check_ports(self, port_list):

# For brcm devices, need to init and setup the ports at once after start the switch.
retries = 10
for port_id in port_list:
try:
sai_thrift_set_port_attribute(
self.client, port_oid=port_id, admin_state=True)
except BaseException as e:
print("Cannot setup port admin state, error {}".format(e))

for num_of_tries in range(retries):
all_ports_are_up = True
time.sleep(1)
for port_id in port_list:
port_attr = sai_thrift_get_port_attribute(
self.client, port_id, oper_status=True)
port_attr = sai_thrift_get_port_attribute(self.client, port_id, oper_status=True)
if port_attr['oper_status'] != SAI_PORT_OPER_STATUS_UP:
all_ports_are_up = False
time.sleep(1)
print("port is down: {}".format(port_attr['oper_status']))
print("port {} is down, status: {}. Reset Admin State.".format(port_id, port_attr['oper_status']))
sai_thrift_set_port_attribute(
self.client,
port_oid=port_id,
mtu=PORT_MTU,
admin_state=True,
fec_mode=SAI_PORT_FEC_MODE_RS)
if all_ports_are_up:
print("Retry {} times turn up port.".format(num_of_tries))
break
Expand Down

0 comments on commit 2414533

Please sign in to comment.