Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dynamic Buffer Calc] Avoid creating lossy PG for admin down ports during initialization #1776

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions cfgmgr/buffermgrdyn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,12 @@ task_process_status BufferMgrDynamic::doUpdatePgTask(const string &pg_key, const

case PORT_ADMIN_DOWN:
SWSS_LOG_NOTICE("Skip setting BUFFER_PG for %s because the port is administratively down", port.c_str());
if (!m_portInitDone)
{
// In case the port is admin down during initialization, the PG will be removed from the port,
// which effectively notifies bufferOrch to add the item to the m_ready_list
m_applBufferPgTable.del(pg_key);
}
break;

default:
Expand Down Expand Up @@ -1862,9 +1868,19 @@ task_process_status BufferMgrDynamic::handleOneBufferPgEntry(const string &key,
}
else
{
SWSS_LOG_NOTICE("Inserting BUFFER_PG table entry %s into APPL_DB directly", key.c_str());
m_applBufferPgTable.set(key, fvVector);
bufferPg.running_profile_name = bufferPg.configured_profile_name;
port_info_t &portInfo = m_portInfoLookup[port];
if (PORT_ADMIN_DOWN != portInfo.state)
{
SWSS_LOG_NOTICE("Inserting BUFFER_PG table entry %s into APPL_DB directly", key.c_str());
m_applBufferPgTable.set(key, fvVector);
bufferPg.running_profile_name = bufferPg.configured_profile_name;
}
else if (!m_portInitDone)
{
// In case the port is admin down during initialization, the PG will be removed from the port,
// which effectively notifies bufferOrch to add the item to the m_ready_list
m_applBufferPgTable.del(key);
}
}

if (!bufferPg.configured_profile_name.empty())
Expand Down
6 changes: 3 additions & 3 deletions cfgmgr/buffermgrdyn.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ typedef struct {
} buffer_pg_t;

typedef enum {
// Port is admin down. All PGs programmed to APPL_DB should be removed from the port
stephenxs marked this conversation as resolved.
Show resolved Hide resolved
PORT_ADMIN_DOWN,
// Port is under initializing, which means its info hasn't been comprehensive for calculating headroom
PORT_INITIALIZING,
// All necessary information for calculating headroom is ready
PORT_READY,
// Port is admin down. All PGs programmed to APPL_DB should be removed from the port
PORT_ADMIN_DOWN
PORT_READY
} port_state_t;

typedef struct {
Expand Down
14 changes: 13 additions & 1 deletion tests/test_buffer_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,9 @@ def test_sharedHeadroomPool(self, dvs, testlog):
def test_shutdownPort(self, dvs, testlog):
self.setup_db(dvs)

lossy_pg_reference_config_db = '[BUFFER_PROFILE|ingress_lossy_profile]'
lossy_pg_reference_appl_db = '[BUFFER_PROFILE_TABLE:ingress_lossy_profile]'

# Startup interface
dvs.runcmd('config interface startup Ethernet0')

Expand All @@ -558,14 +561,23 @@ def test_shutdownPort(self, dvs, testlog):

# Shutdown port and check whether all the PGs have been removed
dvs.runcmd("config interface shutdown Ethernet0")
self.app_db.wait_for_deleted_entry("BUFFER_PG_TABLE", "Ethernet0:0")
self.app_db.wait_for_deleted_entry("BUFFER_PG_TABLE", "Ethernet0:3-4")
self.app_db.wait_for_deleted_entry("BUFFER_PROFILE", expectedProfile)

# Add another PG when port is administratively down
# Add extra lossy and lossless PGs when a port is administratively down
self.config_db.update_entry('BUFFER_PG', 'Ethernet0|1', {'profile': lossy_pg_reference_config_db})
self.config_db.update_entry('BUFFER_PG', 'Ethernet0|6', {'profile': 'NULL'})

# Make sure they have not been added to APPL_DB
time.sleep(30)
self.app_db.wait_for_deleted_entry("BUFFER_PG_TABLE", "Ethernet0:1")
self.app_db.wait_for_deleted_entry("BUFFER_PG_TABLE", "Ethernet0:6")

# Startup port and check whether all the PGs haved been added
dvs.runcmd("config interface startup Ethernet0")
self.app_db.wait_for_field_match("BUFFER_PG_TABLE", "Ethernet0:0", {"profile": lossy_pg_reference_appl_db})
self.app_db.wait_for_field_match("BUFFER_PG_TABLE", "Ethernet0:1", {"profile": lossy_pg_reference_appl_db})
self.app_db.wait_for_field_match("BUFFER_PG_TABLE", "Ethernet0:3-4", {"profile": "[BUFFER_PROFILE_TABLE:" + expectedProfile + "]"})
self.app_db.wait_for_field_match("BUFFER_PG_TABLE", "Ethernet0:6", {"profile": "[BUFFER_PROFILE_TABLE:" + expectedProfile + "]"})

Expand Down