Skip to content

Commit

Permalink
update dynamic buffer test (sonic-net#14229)
Browse files Browse the repository at this point in the history
update dynamic buffer test due to the algorithm calculating headroom is changed
The relevant PR: sonic-net/sonic-swss#3235

Change-Id: I29ad3c4d0b9af0c1357c0890328201c3254cbba2
  • Loading branch information
JibinBao authored Oct 21, 2024
1 parent 6c00999 commit dc8cfed
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions tests/qos/test_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from tests.common.utilities import wait_until
from tests.common.helpers.assertions import pytest_assert, pytest_require
from tests.common.fixtures.conn_graph_facts import conn_graph_facts # noqa F401
from tests.common.mellanox_data import is_mellanox_device
from tests.common.mellanox_data import is_mellanox_device, get_chip_type
from tests.common.innovium_data import is_innovium_device
from tests.common.plugins.loganalyzer.loganalyzer import LogAnalyzer
from tests.common.utilities import check_qos_db_fv_reference_with_table
Expand Down Expand Up @@ -3250,7 +3250,6 @@ def mellanox_calculate_headroom_data(duthost, port_to_test):

speed_of_light = 198000000
minimal_packet_size = 64
cell_occupancy = 0
worst_case_factor = 0
propagation_delay = 0
bytes_on_cable = 0
Expand All @@ -3262,7 +3261,7 @@ def mellanox_calculate_headroom_data(duthost, port_to_test):
pipeline_latency = PIPELINE_LATENCY

if is_8lane:
pipeline_latency = PIPELINE_LATENCY * 2 - 1024
pipeline_latency = PIPELINE_LATENCY * 2
speed_overhead = port_mtu
else:
speed_overhead = 0
Expand All @@ -3272,8 +3271,12 @@ def mellanox_calculate_headroom_data(duthost, port_to_test):
else:
worst_case_factor = (2 * CELL_SIZE) / (1 + CELL_SIZE)

cell_occupancy = (100 - SMALL_PACKET_PERCENTAGE +
SMALL_PACKET_PERCENTAGE * worst_case_factor) / 100
worst_case_factor = math.ceil(worst_case_factor)

small_packet_percentage_by_byte = 100 * minimal_packet_size / (
(SMALL_PACKET_PERCENTAGE * minimal_packet_size + (100 - SMALL_PACKET_PERCENTAGE) * LOSSLESS_MTU) / 100)
byte_num_in_headroom_per_byte_on_cable = (100 - small_packet_percentage_by_byte
+ small_packet_percentage_by_byte * worst_case_factor) / 100

if gearbox_delay == 0:
bytes_on_gearbox = 0
Expand All @@ -3285,12 +3288,19 @@ def mellanox_calculate_headroom_data(duthost, port_to_test):
if not use_default_peer_response_time:
peer_response_time = (float(pause_quanta)) * 512 / (1024 * 8)
bytes_on_cable = 2 * (float(cable_length)) * port_speed * \
1000000000 / speed_of_light / (8 * 1024)
1000000000 / speed_of_light / (8 * 1000)

if get_chip_type(duthost) in ["spectrum4", "spectrum5"]:
kb_on_tile = port_speed / 1000 * 120 / 8
else:
kb_on_tile = 0
logging.debug(f"kb_on_tile = {kb_on_tile}")

propagation_delay = port_mtu + bytes_on_cable + 2 * \
bytes_on_gearbox + MAC_PHY_DELAY + peer_response_time * 1024
bytes_on_gearbox + MAC_PHY_DELAY + peer_response_time * 1024 + kb_on_tile

# Calculate the xoff and xon and then round up at 1024 bytes
xoff_value = LOSSLESS_MTU + propagation_delay * cell_occupancy
xoff_value = LOSSLESS_MTU + propagation_delay * byte_num_in_headroom_per_byte_on_cable
xoff_value = math.ceil(xoff_value / 1024) * 1024
xon_value = pipeline_latency
xon_value = math.ceil(xon_value / 1024) * 1024
Expand Down

0 comments on commit dc8cfed

Please sign in to comment.