Skip to content

Commit

Permalink
Add sai-thrift support to enable/disable CREDIT WATCHDOG for Voq swit…
Browse files Browse the repository at this point in the history
…ch (#2010) (#2072)

sonic-mgmt Qos tests disables the TX for the destination ports to induce the shared buffer full, nominal headroom full a, ingress drop and egress drop.

Voq systems like BCM DNX has credit watchdog timer running periodically to check if voq's and flush the data in the voq to prevent the data being stuck forever in the voq. So to avoid the credit watchdog timer flushing the voq during sonic-mgmt Qos tests, we need to disable the credit watchdog timer and enable it back after the test.

The SAI attribute SAI_SWITCH_ATTR_CREDIT_WD was not present in the older SAI versions and got added in SAI 10.X. So this PR adds the sai-thrift support to enable or disable the SAI_SWITCH_ATTR_CREDIT_WD for Voq systems.

Signed-off-by: saksarav <sakthivadivu.saravanaraj@nokia.com>
  • Loading branch information
saksarav-nokia committed Sep 13, 2024
1 parent 2587c3b commit e0e9787
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/saithrift/src/switch_sai_rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,29 @@ class switch_sai_rpcHandler : virtual public switch_sai_rpcIf {
}
attr_list.push_back(thrift_port_list_attribute);
free(port_list_object_attribute.value.objlist.list);

sai_attribute_t switch_attr;
switch_attr.id = SAI_SWITCH_ATTR_TYPE;
status = switch_api->get_switch_attribute(gSwitchId, 1, &switch_attr);
if (status != SAI_STATUS_SUCCESS) {
SAI_THRIFT_LOG_ERR("get_switch_attribute failed!!!");
return;
}
if (switch_attr.value.u32 != SAI_SWITCH_TYPE_VOQ) {
return;
}
switch_attr.id = SAI_SWITCH_ATTR_CREDIT_WD;
status = switch_api->get_switch_attribute(gSwitchId, 1, &switch_attr);
if (status != SAI_STATUS_SUCCESS) {
SAI_THRIFT_LOG_ERR("get_switch_attribute failed!!!");
return;
}

sai_thrift_attribute_t credit_wd_attribute;
thrift_attr_list.attr_count = 2;
credit_wd_attribute.id = SAI_SWITCH_ATTR_CREDIT_WD;
credit_wd_attribute.value.booldata = switch_attr.value.booldata;
attr_list.push_back(credit_wd_attribute);
}

sai_thrift_status_t sai_thrift_set_switch_attribute(const sai_thrift_attribute_t& thrift_attr) {
Expand All @@ -1609,6 +1632,19 @@ class switch_sai_rpcHandler : virtual public switch_sai_rpcIf {
return status;
}

if (thrift_attr.id == SAI_SWITCH_ATTR_CREDIT_WD)
{
attr.id = SAI_SWITCH_ATTR_TYPE;
status = switch_api->get_switch_attribute(gSwitchId, 1, &attr);
if (status != SAI_STATUS_SUCCESS) {
SAI_THRIFT_LOG_ERR("get_switch_attribute failed!!!");
return status;
}
if (attr.value.u32 != SAI_SWITCH_TYPE_VOQ) {
SAI_THRIFT_LOG_ERR("Switch is not VOQ switch!!!");
return SAI_STATUS_NOT_SUPPORTED;
}
}
sai_thrift_parse_switch_attribute(thrift_attr, &attr);

status = switch_api->set_switch_attribute(gSwitchId, &attr);
Expand Down Expand Up @@ -1640,6 +1676,10 @@ class switch_sai_rpcHandler : virtual public switch_sai_rpcIf {
attr->value.u32 = thrift_attr.value.u32;
break;

case SAI_SWITCH_ATTR_CREDIT_WD:
attr->value.booldata = thrift_attr.value.booldata;
break;

default:
printf("unknown thrift_attr id: %d\n", thrift_attr.id);
}
Expand Down
2 changes: 2 additions & 0 deletions test/saithrift/tests/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def switch_init(client):
attr = sai_thrift_attribute_t(id=SAI_PORT_ATTR_ADMIN_STATE, value=attr_value)
client.sai_thrift_set_port_attribute(port_id, attr)
sai_port_list.append(port_id)
elif attribute.id == SAI_SWITCH_ATTR_CREDIT_WD
print "Credit Watchdog: " + attribute.value.booldata
else:
print "unknown switch attribute"
attr_value = sai_thrift_attribute_value_t(mac=router_mac)
Expand Down

0 comments on commit e0e9787

Please sign in to comment.