Skip to content

Commit c0a948d

Browse files
authored
Add WRED specific comparison logic (sonic-net#413)
* Add WRED specific comparison logic * Add test file
1 parent 1b6a661 commit c0a948d

File tree

4 files changed

+111
-1
lines changed

4 files changed

+111
-1
lines changed

syncd/syncd_applyview.cpp

+60
Original file line numberDiff line numberDiff line change
@@ -3412,6 +3412,62 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForBufferPool(
34123412
return nullptr;
34133413
}
34143414

3415+
std::shared_ptr<SaiObj> findCurrentBestMatchForWred(
3416+
_In_ const AsicView &currentView,
3417+
_In_ const AsicView &temporaryView,
3418+
_In_ const std::shared_ptr<const SaiObj> &temporaryObj,
3419+
_In_ const std::vector<sai_object_compare_info_t> &candidateObjects)
3420+
{
3421+
SWSS_LOG_ENTER();
3422+
3423+
/*
3424+
* For WRED we will first if it's assigned to any of the queues.
3425+
*/
3426+
3427+
auto tmpQueues = temporaryView.getObjectsByObjectType(SAI_OBJECT_TYPE_QUEUE);
3428+
3429+
for (auto tmpQueue: tmpQueues)
3430+
{
3431+
auto tmpWredProfileIdAttr = tmpQueue->tryGetSaiAttr(SAI_QUEUE_ATTR_WRED_PROFILE_ID);
3432+
3433+
if (tmpWredProfileIdAttr == nullptr)
3434+
continue; // no WRED attribute on queue
3435+
3436+
if (tmpWredProfileIdAttr->getOid() != temporaryObj->getVid())
3437+
continue; // not this queue
3438+
3439+
if (tmpQueue->getObjectStatus() != SAI_OBJECT_STATUS_MATCHED)
3440+
continue; // we only look for matched queues
3441+
3442+
// we found matched queue with this WRED
3443+
3444+
// we can use tmp VID since object is matched and both vids are the same
3445+
auto curQueue = currentView.oOids.at(tmpQueue->getVid());
3446+
3447+
auto curWredProfileIdAttr = curQueue->tryGetSaiAttr(SAI_QUEUE_ATTR_WRED_PROFILE_ID);
3448+
3449+
if (curWredProfileIdAttr == nullptr)
3450+
continue; // current queue has no WRED attribute
3451+
3452+
if (curWredProfileIdAttr->getOid() == SAI_NULL_OBJECT_ID)
3453+
continue; // WRED is NULL on current queue
3454+
3455+
for (auto c: candidateObjects)
3456+
{
3457+
if (c.obj->getVid() != curWredProfileIdAttr->getOid())
3458+
continue;
3459+
3460+
SWSS_LOG_INFO("found best WRED based on queue %s", c.obj->str_object_id.c_str());
3461+
3462+
return c.obj;
3463+
}
3464+
}
3465+
3466+
SWSS_LOG_NOTICE("failed to find best candidate for WRED using queue");
3467+
3468+
return nullptr;
3469+
}
3470+
34153471
std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObjectUsingGraph(
34163472
_In_ const AsicView &currentView,
34173473
_In_ const AsicView &temporaryView,
@@ -3456,6 +3512,10 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObjectUsingGraph(
34563512
candidate = findCurrentBestMatchForBufferPool(currentView, temporaryView, temporaryObj, candidateObjects);
34573513
break;
34583514

3515+
case SAI_OBJECT_TYPE_WRED:
3516+
candidate = findCurrentBestMatchForWred(currentView, temporaryView, temporaryObj, candidateObjects);
3517+
break;
3518+
34593519
default:
34603520
break;
34613521
}

tests/aspellcheck.pl

+6
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,16 @@ sub RunAspell
103103
last;
104104
}
105105

106+
chomp $res;
107+
next if $res =~ /^\*?$/;
108+
109+
print "$res\n";
106110
next if not $res =~ /^\s*&\s*(\S+)/;
107111

108112
my $word = $1;
109113

114+
next if $word =~ /^wred$/i;
115+
110116
chomp $res;
111117

112118
my $where = "??";

tests/brcm.pl

+29-1
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,38 @@ sub test_brcm_config_acl
373373
play "config_acl2.rec", 0;
374374
}
375375

376+
sub test_brcm_warm_wred_queue
377+
{
378+
fresh_start;
379+
380+
play "wred_queue.rec";
381+
play "wred_queue.rec", 0;
382+
play "wred_queue.rec", 0;
383+
play "wred_queue.rec", 0;
384+
play "wred_queue.rec", 0;
385+
play "wred_queue.rec", 0;
386+
play "wred_queue.rec", 0;
387+
388+
fresh_start;
389+
390+
play "wred_queue.rec";
391+
392+
request_warm_shutdown;
393+
start_syncd_warm;
394+
395+
play "wred_queue.rec", 0;
396+
397+
request_warm_shutdown;
398+
399+
start_syncd_warm;
400+
401+
play "wred_queue.rec", 0;
402+
}
403+
376404
# RUN TESTS
377405

378406
test_brcm_config_acl;
379-
407+
test_brcm_warm_wred_queue;
380408
test_brcm_warm_boot_full_empty;
381409
test_brcm_warm_boot_small_buffer;
382410
test_brcm_warm_boot_empty;

tests/brcm/wred_queue.rec

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2017-06-14.01:55:46.541806|#|recording on: ./sairedis.2017-06-14.01:55:46.541389.rec
2+
2017-06-14.01:55:46.543987|a|INIT_VIEW
3+
2017-06-14.01:55:46.551164|A|SAI_STATUS_SUCCESS
4+
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
5+
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
6+
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
7+
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
8+
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
9+
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
10+
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
11+
2017-06-14.01:56:34.647623|s|SAI_OBJECT_TYPE_QUEUE:oid:0x1500000000006f|SAI_QUEUE_ATTR_WRED_PROFILE_ID=oid:0x13000000000001
12+
2017-06-14.01:56:34.684390|s|SAI_OBJECT_TYPE_QUEUE:oid:0x15000000000070|SAI_QUEUE_ATTR_WRED_PROFILE_ID=oid:0x13000000000001
13+
2017-06-14.01:56:34.647623|s|SAI_OBJECT_TYPE_QUEUE:oid:0x15000000000071|SAI_QUEUE_ATTR_WRED_PROFILE_ID=oid:0x13000000000002
14+
2017-06-14.01:56:34.684390|s|SAI_OBJECT_TYPE_QUEUE:oid:0x15000000000072|SAI_QUEUE_ATTR_WRED_PROFILE_ID=oid:0x13000000000002
15+
2017-06-14.01:56:06.151337|a|APPLY_VIEW
16+
2017-06-14.01:56:06.156740|A|SAI_STATUS_SUCCESS

0 commit comments

Comments
 (0)