Skip to content

Commit

Permalink
Added multi asic support
Browse files Browse the repository at this point in the history
  • Loading branch information
sreejithsreekumaran committed Dec 20, 2024
1 parent ea43434 commit 2e63ae4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
15 changes: 9 additions & 6 deletions tests/common/snappi_tests/common_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def get_wred_profiles(host_ans, asic_value=None):
return None


def config_wred(host_ans, kmin, kmax, pmax, gdrop=None, profile=None, asic_value=None):
def config_wred(host_ans, kmin, kmax, pmax, kdrop=None, profile=None, asic_value=None):
"""
Config a WRED/ECN profile of a SONiC switch
Args:
Expand All @@ -457,10 +457,10 @@ def config_wred(host_ans, kmin, kmax, pmax, gdrop=None, profile=None, asic_value
if not isinstance(kmin, int) or \
not isinstance(kmax, int) or \
not isinstance(pmax, int) or \
(gdrop is not None and not isinstance(gdrop, int)):
(kdrop is not None and not isinstance(kdrop, int)):
return False

if kmin < 0 or kmax < 0 or pmax < 0 or pmax > 100 or kmin > kmax or (gdrop and (gdrop < 0 or gdrop > 100)):
if kmin < 0 or kmax < 0 or pmax < 0 or pmax > 100 or kmin > kmax or (kdrop and (kdrop < 0 or kdrop > 100)):
return False
profiles = get_wred_profiles(host_ans, asic_value)
""" Cannot find any WRED/ECN profiles """
Expand All @@ -479,6 +479,7 @@ def config_wred(host_ans, kmin, kmax, pmax, gdrop=None, profile=None, asic_value

kmax_arg = '-{}max'.format(color[0])
kmin_arg = '-{}min'.format(color[0])
kdrop_arg = '-{}drop'.format(color[0])

for p in profiles:
""" This is not the profile to configure """
Expand All @@ -487,7 +488,7 @@ def config_wred(host_ans, kmin, kmax, pmax, gdrop=None, profile=None, asic_value

kmin_old = int(profiles[p]['{}_min_threshold'.format(color)])
kmax_old = int(profiles[p]['{}_max_threshold'.format(color)])
gdrop_old = int(profiles[p]['{}_drop_probability'.format(color)])
kdrop_old = int(profiles[p]['{}_drop_probability'.format(color)])

if kmin_old > kmax_old:
return False
Expand All @@ -496,10 +497,12 @@ def config_wred(host_ans, kmin, kmax, pmax, gdrop=None, profile=None, asic_value

kmax_cmd = ' '.join(['sudo ecnconfig -p {}', kmax_arg, '{}'])
kmin_cmd = ' '.join(['sudo ecnconfig -p {}', kmin_arg, '{}'])
kdrop_cmd = ' '.join(['sudo ecnconfig -p {}', kdrop_arg, '{}'])

if asic_value is not None:
kmax_cmd = ' '.join(['sudo ip netns exec', asic_value, 'ecnconfig -p {}', kmax_arg, '{}'])
kmin_cmd = ' '.join(['sudo ip netns exec', asic_value, 'ecnconfig -p {}', kmin_arg, '{}'])
kdrop_cmd = ' '.join(['sudo ip netns exec', asic_value, 'ecnconfig -p {}', kdrop_arg, '{}'])
if asic_type == 'broadcom':
disable_packet_aging(host_ans, asic_value)

Expand All @@ -510,8 +513,8 @@ def config_wred(host_ans, kmin, kmax, pmax, gdrop=None, profile=None, asic_value
host_ans.shell(kmin_cmd.format(p, kmin))
host_ans.shell(kmax_cmd.format(p, kmax))

if gdrop and gdrop != gdrop_old:
host_ans.shell('sudo ecnconfig -p {} -gdrop {}'.format(p, gdrop))
if kdrop and kdrop != kdrop_old:
host_ans.shell(kdrop_cmd.format(p, kdrop))

return True

Expand Down
7 changes: 6 additions & 1 deletion tests/snappi_tests/multidut/ecn/files/multidut_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,10 @@ def run_ecn_marking_with_pfc_quanta_variance(
"flow_traffic_type": traffic_flow_mode.FIXED_PACKETS
}

asic_namespace = None
if duthost.is_multi_asic:
asic = duthost.get_port_asic_instance(dut_port)
asic_namespace = asic.namespace
gmin, gmax, gdrop = test_ecn_config

# Configure WRED/ECN thresholds
Expand All @@ -724,7 +728,8 @@ def run_ecn_marking_with_pfc_quanta_variance(
kmin=gmin * 1024 * 1024,
kmax=gmax * 1024 * 1024,
pmax=0,
gdrop=gdrop)
kdrop=gdrop,
asic_value=asic_namespace)

pytest_assert(config_result is True, 'Failed to configure WRED/ECN at the DUT')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
is_snappi_multidut, get_snappi_ports_multi_dut, get_snappi_ports_single_dut # noqa: F401
from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, \
lossless_prio_list, disable_pfcwd # noqa F401
from tests.snappi_tests.files.helper import multidut_port_info, setup_ports_and_dut # noqa: F401
from tests.snappi_tests.files.helper import multidut_port_info, setup_ports_and_dut, enable_debug_shell # noqa: F401
from tests.snappi_tests.multidut.ecn.files.multidut_helper import run_ecn_marking_with_pfc_quanta_variance
from tests.common.snappi_tests.snappi_test_params import SnappiTestParams
logger = logging.getLogger(__name__)
Expand Down

0 comments on commit 2e63ae4

Please sign in to comment.