Skip to content

Commit

Permalink
[Dynamic Buffer Calc] Enhance the field checking in table handling (s…
Browse files Browse the repository at this point in the history
…onic-net#1680)

* Fix a typo in test_buffer_dynamic.py and enhance a field name check
* Use "else if" instead of "if"

Signed-off-by: Stephen Sun <stephens@nvidia.com>
  • Loading branch information
stephenxs authored Mar 26, 2021
1 parent de5fb41 commit 242189b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions cfgmgr/buffermgrdyn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1376,15 +1376,15 @@ task_process_status BufferMgrDynamic::handleBufferPoolTable(KeyOpFieldsValuesTup
{
bufferPool.dynamic_size = false;
}
if (field == buffer_pool_xoff_field_name)
else if (field == buffer_pool_xoff_field_name)
{
newSHPSize = value;
}
if (field == buffer_pool_mode_field_name)
else if (field == buffer_pool_mode_field_name)
{
bufferPool.mode = value;
}
if (field == buffer_pool_type_field_name)
else if (field == buffer_pool_type_field_name)
{
bufferPool.ingress = (value == buffer_value_ingress);
}
Expand Down Expand Up @@ -1503,32 +1503,32 @@ task_process_status BufferMgrDynamic::handleBufferProfileTable(KeyOpFieldsValues
return task_process_status::task_failed;
}
}
if (field == buffer_xon_field_name)
else if (field == buffer_xon_field_name)
{
profileApp.xon = value;
}
if (field == buffer_xoff_field_name)
else if (field == buffer_xoff_field_name)
{
profileApp.xoff = value;
profileApp.lossless = true;
}
if (field == buffer_xon_offset_field_name)
else if (field == buffer_xon_offset_field_name)
{
profileApp.xon_offset = value;
}
if (field == buffer_size_field_name)
else if (field == buffer_size_field_name)
{
profileApp.size = value;
}
if (field == buffer_dynamic_th_field_name)
else if (field == buffer_dynamic_th_field_name)
{
profileApp.threshold = value;
}
if (field == buffer_static_th_field_name)
else if (field == buffer_static_th_field_name)
{
profileApp.threshold = value;
}
if (field == buffer_headroom_type_field_name)
else if (field == buffer_headroom_type_field_name)
{
profileApp.dynamic_calculated = (value == "dynamic");
if (profileApp.dynamic_calculated)
Expand Down Expand Up @@ -1692,6 +1692,13 @@ task_process_status BufferMgrDynamic::handleOneBufferPgEntry(const string &key,
bufferPg.static_configured = true;
bufferPg.configured_profile_name = profileName;
}

if (field != buffer_profile_field_name)
{
SWSS_LOG_ERROR("BUFFER_PG: Invalid field %s", field.c_str());
return task_process_status::task_invalid_entry;
}

fvVector.emplace_back(field, value);
SWSS_LOG_INFO("Inserting BUFFER_PG table field %s value %s", field.c_str(), value.c_str());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_buffer_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def test_headroomOverride(self, dvs, testlog):
self.app_db.wait_for_deleted_entry("BUFFER_PG_TABLE", "Ethernet0:6")

# readd lossless PG with dynamic profile
self.config_db.update_entry('BUFFER_PG', 'Ethernet0|3-4', {'profie': 'NULL'})
self.config_db.update_entry('BUFFER_PG', 'Ethernet0|3-4', {'profile': 'NULL'})
self.app_db.wait_for_field_match("BUFFER_PG_TABLE", "Ethernet0:3-4", {"profile": "[BUFFER_PROFILE_TABLE:" + expectedProfile + "]"})

# remove the headroom override profile
Expand Down

0 comments on commit 242189b

Please sign in to comment.