Skip to content

Commit e6616ce

Browse files
[buffermgrd]: Update PG profile on cable length change
Why I did it: When the cable length of a port changes, the Buffer PG profile isn't automatically updated. This causes a mismatch between the actual cable length and the buffer configuration, potentially leading to inefficient or incorrect buffer allocation. How I did it: The fix ensures that whenever a valid cable length is set, the buffer profile is recalculated and updated accordingly (by calling doSpeedUpdateTask). This maintains alignment between the hardware setup and buffer management. How to verify it: Can be verified by running below test test_buffer_traditional.py::TestBuffer::test_update_buffer_pg_for_cable_len_change Which release branch to backport (provide reason below if selected): 202505 Tested branch (Please provide the tested image version): 202505 Signed-off-by: Jithender Kondam <[email protected]>
1 parent a2decc5 commit e6616ce

File tree

2 files changed

+91
-2
lines changed

2 files changed

+91
-2
lines changed

cfgmgr/buffermgr.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,15 @@ void BufferMgr::readPgProfileLookupFile(string file)
100100

101101
task_process_status BufferMgr::doCableTask(string port, string cable_length)
102102
{
103-
m_cableLenLookup[port] = cable_length;
104-
SWSS_LOG_INFO("Cable length set to %s for port %s", m_cableLenLookup[port].c_str(), port.c_str());
103+
104+
if (cable_length != "None" && m_cableLenLookup[port] != cable_length)
105+
{
106+
m_cableLenLookup[port] = cable_length;
107+
SWSS_LOG_INFO("Cable length set to %s for port %s", m_cableLenLookup[port].c_str(), port.c_str());
108+
// The return status is ignored
109+
doSpeedUpdateTask(port);
110+
}
111+
105112
return task_process_status::task_success;
106113
}
107114

tests/test_buffer_traditional.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,3 +446,85 @@ def test_config_db_buffer_pg_update(self, dvs: DockerVirtualSwitch, setup_teardo
446446
else:
447447
self.config_db.delete_entry("PORT_QOS_MAP", self.INTF)
448448

449+
def test_update_buffer_pg_for_cable_len_change(self, dvs: DockerVirtualSwitch, setup_teardown_test):
450+
"""
451+
Test to verify that buffermgrd correctly updated the buffer_pg entry of a given port when cable length is
452+
updated.
453+
"""
454+
455+
orig_port_qos_map = None
456+
orig_cable_len = None
457+
orig_fvs_port = None
458+
459+
# Test parameters
460+
test_cable_len = "300m"
461+
test_speed = "100000"
462+
test_port_pfc_enable = "3,4"
463+
464+
try:
465+
##################################
466+
## Save original configurations ##
467+
##################################
468+
469+
# Save original cable length
470+
fvs_cable_len = self.config_db.get_entry("CABLE_LENGTH", "AZURE")
471+
orig_cable_len = fvs_cable_len.get(self.INTF) if fvs_cable_len else None
472+
473+
# Save original port speed and admin status
474+
orig_fvs_port = self.config_db.get_entry("PORT", self.INTF)
475+
orig_port_speed = orig_fvs_port.get("speed") if orig_fvs_port else None
476+
orig_port_status = orig_fvs_port.get("admin_status") if orig_fvs_port else None
477+
478+
# Save original port qos map
479+
fvs_qos_map = self.config_db.get_entry("PORT_QOS_MAP", self.INTF)
480+
orig_port_qos_map = fvs_qos_map if fvs_qos_map else None
481+
482+
######################################
483+
## Send configurations to CONFIG_DB ##
484+
######################################
485+
486+
# Configure PFC enable
487+
self.set_port_qos_table(self.INTF, test_port_pfc_enable)
488+
489+
# Configure cable length
490+
self.change_cable_len(test_cable_len)
491+
492+
# Wait for buffermgrd to process the changes
493+
time.sleep(2)
494+
495+
##################
496+
## Verification ##
497+
##################
498+
499+
# Verify BUFFER_PG table entry in CONFIG_DB without port qos map entry
500+
pg_field_key = "{}|{}".format(self.INTF, test_port_pfc_enable.replace(',', '-'))
501+
fvs_buffer_pg = self.config_db.get_entry("BUFFER_PG", pg_field_key)
502+
503+
# Check if fvs_buffer_pg profile is not equal to expected dynamic profile
504+
expected_profile = "pg_lossless_{}_{}_profile".format(test_speed, test_cable_len)
505+
if fvs_buffer_pg.get("profile") != expected_profile:
506+
assert False, "BUFFER_PG profile {} is not {}".format(fvs_buffer_pg.get("profile"), expected_profile)
507+
508+
finally:
509+
###############################
510+
## Revert to original values ##
511+
###############################
512+
513+
# Revert cable length
514+
if orig_cable_len:
515+
self.change_cable_len(orig_cable_len)
516+
else:
517+
self.config_db.delete_entry("CABLE_LENGTH", "AZURE")
518+
519+
# Revert to original PORT configuration
520+
if orig_fvs_port:
521+
self.config_db.update_entry("PORT", self.INTF, orig_fvs_port)
522+
else:
523+
self.config_db.delete_entry("PORT", self.INTF)
524+
525+
# Revert port qos map
526+
if orig_port_qos_map:
527+
self.config_db.update_entry("PORT_QOS_MAP", self.INTF, orig_port_qos_map)
528+
else:
529+
self.config_db.delete_entry("PORT_QOS_MAP", self.INTF)
530+

0 commit comments

Comments
 (0)