Skip to content

Commit

Permalink
Add WRED specific comparison logic (#413)
Browse files Browse the repository at this point in the history
* Add WRED specific comparison logic

* Add test file
  • Loading branch information
kcudnik authored Jan 30, 2019
1 parent 1b6a661 commit c0a948d
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 1 deletion.
60 changes: 60 additions & 0 deletions syncd/syncd_applyview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3412,6 +3412,62 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForBufferPool(
return nullptr;
}

std::shared_ptr<SaiObj> findCurrentBestMatchForWred(
_In_ const AsicView &currentView,
_In_ const AsicView &temporaryView,
_In_ const std::shared_ptr<const SaiObj> &temporaryObj,
_In_ const std::vector<sai_object_compare_info_t> &candidateObjects)
{
SWSS_LOG_ENTER();

/*
* For WRED we will first if it's assigned to any of the queues.
*/

auto tmpQueues = temporaryView.getObjectsByObjectType(SAI_OBJECT_TYPE_QUEUE);

for (auto tmpQueue: tmpQueues)
{
auto tmpWredProfileIdAttr = tmpQueue->tryGetSaiAttr(SAI_QUEUE_ATTR_WRED_PROFILE_ID);

if (tmpWredProfileIdAttr == nullptr)
continue; // no WRED attribute on queue

if (tmpWredProfileIdAttr->getOid() != temporaryObj->getVid())
continue; // not this queue

if (tmpQueue->getObjectStatus() != SAI_OBJECT_STATUS_MATCHED)
continue; // we only look for matched queues

// we found matched queue with this WRED

// we can use tmp VID since object is matched and both vids are the same
auto curQueue = currentView.oOids.at(tmpQueue->getVid());

auto curWredProfileIdAttr = curQueue->tryGetSaiAttr(SAI_QUEUE_ATTR_WRED_PROFILE_ID);

if (curWredProfileIdAttr == nullptr)
continue; // current queue has no WRED attribute

if (curWredProfileIdAttr->getOid() == SAI_NULL_OBJECT_ID)
continue; // WRED is NULL on current queue

for (auto c: candidateObjects)
{
if (c.obj->getVid() != curWredProfileIdAttr->getOid())
continue;

SWSS_LOG_INFO("found best WRED based on queue %s", c.obj->str_object_id.c_str());

return c.obj;
}
}

SWSS_LOG_NOTICE("failed to find best candidate for WRED using queue");

return nullptr;
}

std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObjectUsingGraph(
_In_ const AsicView &currentView,
_In_ const AsicView &temporaryView,
Expand Down Expand Up @@ -3456,6 +3512,10 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObjectUsingGraph(
candidate = findCurrentBestMatchForBufferPool(currentView, temporaryView, temporaryObj, candidateObjects);
break;

case SAI_OBJECT_TYPE_WRED:
candidate = findCurrentBestMatchForWred(currentView, temporaryView, temporaryObj, candidateObjects);
break;

default:
break;
}
Expand Down
6 changes: 6 additions & 0 deletions tests/aspellcheck.pl
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,16 @@ sub RunAspell
last;
}

chomp $res;
next if $res =~ /^\*?$/;

print "$res\n";
next if not $res =~ /^\s*&\s*(\S+)/;

my $word = $1;

next if $word =~ /^wred$/i;

chomp $res;

my $where = "??";
Expand Down
30 changes: 29 additions & 1 deletion tests/brcm.pl
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,38 @@ sub test_brcm_config_acl
play "config_acl2.rec", 0;
}

sub test_brcm_warm_wred_queue
{
fresh_start;

play "wred_queue.rec";
play "wred_queue.rec", 0;
play "wred_queue.rec", 0;
play "wred_queue.rec", 0;
play "wred_queue.rec", 0;
play "wred_queue.rec", 0;
play "wred_queue.rec", 0;

fresh_start;

play "wred_queue.rec";

request_warm_shutdown;
start_syncd_warm;

play "wred_queue.rec", 0;

request_warm_shutdown;

start_syncd_warm;

play "wred_queue.rec", 0;
}

# RUN TESTS

test_brcm_config_acl;

test_brcm_warm_wred_queue;
test_brcm_warm_boot_full_empty;
test_brcm_warm_boot_small_buffer;
test_brcm_warm_boot_empty;
Expand Down
16 changes: 16 additions & 0 deletions tests/brcm/wred_queue.rec
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
2017-06-14.01:55:46.541806|#|recording on: ./sairedis.2017-06-14.01:55:46.541389.rec
2017-06-14.01:55:46.543987|a|INIT_VIEW
2017-06-14.01:55:46.551164|A|SAI_STATUS_SUCCESS
2017-06-14.01:55:46.555975|c|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_INIT_SWITCH=true|SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY=0x417890|SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY=0x4179f0|SAI_SWITCH_ATTR_SWITCH_SHUTDOWN_REQUEST_NOTIFY=0x417b50
2017-06-14.01:56:05.520538|g|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_PORT_LIST=32:oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0
2017-06-14.01:56:05.525938|G|SAI_STATUS_SUCCESS|SAI_SWITCH_ATTR_PORT_LIST=32:oid:0x1000000000002,oid:0x1000000000003,oid:0x1000000000004,oid:0x1000000000005,oid:0x1000000000006,oid:0x1000000000007,oid:0x1000000000008,oid:0x1000000000009,oid:0x100000000000a,oid:0x100000000000b,oid:0x100000000000c,oid:0x100000000000d,oid:0x100000000000e,oid:0x100000000000f,oid:0x1000000000010,oid:0x1000000000011,oid:0x1000000000012,oid:0x1000000000013,oid:0x1000000000014,oid:0x1000000000015,oid:0x1000000000016,oid:0x1000000000017,oid:0x1000000000018,oid:0x1000000000019,oid:0x100000000001a,oid:0x100000000001b,oid:0x100000000001c,oid:0x100000000001d,oid:0x100000000001e,oid:0x100000000001f,oid:0x1000000000020,oid:0x1000000000021
2017-06-14.01:56:06.534160|g|SAI_OBJECT_TYPE_PORT:oid:0x1000000000002|SAI_PORT_ATTR_QOS_QUEUE_LIST=20:oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0
2017-06-14.01:56:06.536525|G|SAI_STATUS_SUCCESS|SAI_PORT_ATTR_QOS_QUEUE_LIST=20:oid:0x1500000000006c,oid:0x1500000000006d,oid:0x1500000000006e,oid:0x1500000000006f,oid:0x15000000000070,oid:0x15000000000071,oid:0x15000000000072,oid:0x15000000000073,oid:0x15000000000074,oid:0x15000000000075,oid:0x15000000000078,oid:0x15000000000079,oid:0x1500000000007a,oid:0x1500000000007b,oid:0x1500000000007c,oid:0x1500000000007d,oid:0x1500000000007e,oid:0x1500000000007f,oid:0x15000000000080,oid:0x15000000000081
2017-06-14.01:56:25.743148|c|SAI_OBJECT_TYPE_WRED:oid:0x13000000000001|SAI_WRED_ATTR_GREEN_DROP_PROBABILITY=100|SAI_WRED_ATTR_YELLOW_DROP_PROBABILITY=100|SAI_WRED_ATTR_WEIGHT=0|SAI_WRED_ATTR_ECN_MARK_MODE=SAI_ECN_MARK_MODE_ALL|SAI_WRED_ATTR_GREEN_MAX_THRESHOLD=184320|SAI_WRED_ATTR_GREEN_MIN_THRESHOLD=184320|SAI_WRED_ATTR_RED_MAX_THRESHOLD=512000|SAI_WRED_ATTR_RED_MIN_THRESHOLD=512000|SAI_WRED_ATTR_GREEN_ENABLE=true|SAI_WRED_ATTR_YELLOW_ENABLE=true|SAI_WRED_ATTR_YELLOW_MAX_THRESHOLD=512000|SAI_WRED_ATTR_YELLOW_MIN_THRESHOLD=512000
2017-06-14.01:56:25.743148|c|SAI_OBJECT_TYPE_WRED:oid:0x13000000000002|SAI_WRED_ATTR_GREEN_DROP_PROBABILITY=100|SAI_WRED_ATTR_YELLOW_DROP_PROBABILITY=100|SAI_WRED_ATTR_WEIGHT=0|SAI_WRED_ATTR_ECN_MARK_MODE=SAI_ECN_MARK_MODE_ALL|SAI_WRED_ATTR_GREEN_MAX_THRESHOLD=184320|SAI_WRED_ATTR_GREEN_MIN_THRESHOLD=184320|SAI_WRED_ATTR_RED_MAX_THRESHOLD=512000|SAI_WRED_ATTR_RED_MIN_THRESHOLD=512000|SAI_WRED_ATTR_GREEN_ENABLE=true|SAI_WRED_ATTR_YELLOW_ENABLE=true|SAI_WRED_ATTR_YELLOW_MAX_THRESHOLD=512000|SAI_WRED_ATTR_YELLOW_MIN_THRESHOLD=512000
2017-06-14.01:56:34.647623|s|SAI_OBJECT_TYPE_QUEUE:oid:0x1500000000006f|SAI_QUEUE_ATTR_WRED_PROFILE_ID=oid:0x13000000000001
2017-06-14.01:56:34.684390|s|SAI_OBJECT_TYPE_QUEUE:oid:0x15000000000070|SAI_QUEUE_ATTR_WRED_PROFILE_ID=oid:0x13000000000001
2017-06-14.01:56:34.647623|s|SAI_OBJECT_TYPE_QUEUE:oid:0x15000000000071|SAI_QUEUE_ATTR_WRED_PROFILE_ID=oid:0x13000000000002
2017-06-14.01:56:34.684390|s|SAI_OBJECT_TYPE_QUEUE:oid:0x15000000000072|SAI_QUEUE_ATTR_WRED_PROFILE_ID=oid:0x13000000000002
2017-06-14.01:56:06.151337|a|APPLY_VIEW
2017-06-14.01:56:06.156740|A|SAI_STATUS_SUCCESS

0 comments on commit c0a948d

Please sign in to comment.