Skip to content

Commit

Permalink
Add more attr logging in DashSai
Browse files Browse the repository at this point in the history
For better debugging
  • Loading branch information
kcudnik committed Oct 21, 2023
1 parent 951f7eb commit bc9d1f8
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions dash-pipeline/SAI/src/dashsai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,11 @@ sai_status_t DashSai::createSwitch(

for (uint32_t i = 0; i < attr_count; i++)
{
DASH_LOG_WARN("attr id %d is NOT IMPLEMENTED, ignored", attr_list[i].id);
auto *md = sai_metadata_get_attr_metadata(SAI_OBJECT_TYPE_SWITCH, attr_list[i].id);

const char* attrName = md ? md->attridname : "unknown";

DASH_LOG_WARN("attr id %d %s is NOT IMPLEMENTED, ignored", attr_list[i].id, attrName);

if (attr_list[i].id == SAI_SWITCH_ATTR_SWITCH_HARDWARE_INFO)
{
Expand Down Expand Up @@ -311,6 +315,10 @@ sai_status_t DashSai::setSwitchAttribute(
DASH_LOG_ENTER();
DASH_CHECK_API_INITIALIZED();

auto *md = sai_metadata_get_attr_metadata(SAI_OBJECT_TYPE_SWITCH, attr->id);

const char* attrName = md ? md->attridname : "unknown";

switch (attr->id)
{
case SAI_SWITCH_ATTR_SWITCH_STATE_CHANGE_NOTIFY:
Expand All @@ -321,13 +329,13 @@ sai_status_t DashSai::setSwitchAttribute(
case SAI_SWITCH_ATTR_QUEUE_PFC_DEADLOCK_NOTIFY:
case SAI_SWITCH_ATTR_BFD_SESSION_STATE_CHANGE_NOTIFY:

DASH_LOG_NOTICE("setting dummy notification callback (attr id: %d)", attr->id);
DASH_LOG_NOTICE("setting dummy notification callback (attr id: %d %s)", attr->id, attrName);

return SAI_STATUS_SUCCESS;

default:

DASH_LOG_ERROR("set attr %d NOT IMPLEMENTED", attr->id);
DASH_LOG_ERROR("set attr %d %s NOT IMPLEMENTED", attr->id, attrName);

return SAI_STATUS_NOT_IMPLEMENTED;
}
Expand Down Expand Up @@ -714,7 +722,11 @@ sai_status_t DashSai::create(

*objectId = m_objectIdManager->allocateNewObjectId(objectType, m_switchId);

DASH_LOG_WARN("creating dummy object for object type %d: 0x%lx", objectType, *objectId);
auto* ot = sai_metadata_get_object_type_info(objectType);

const char* otName = ot ? ot->objecttypename : "unknown";

DASH_LOG_WARN("creating dummy object for object type %d %s: 0x%lx", objectType, otName, *objectId);

return SAI_STATUS_SUCCESS;
}
Expand Down Expand Up @@ -745,7 +757,11 @@ sai_status_t DashSai::set(
if (objectType == SAI_OBJECT_TYPE_SWITCH)
return setSwitchAttribute(objectId, attr);

DASH_LOG_WARN("dummy set: 0x%lx, attr id: %d", objectId, attr->id);
auto *md = sai_metadata_get_attr_metadata(objectType, attr->id);

const char* attrName = md ? md->attridname : "unknown";

DASH_LOG_WARN("dummy set: 0x%lx, attr id: %d %s", objectId, attr->id, attrName);

return SAI_STATUS_SUCCESS;
}
Expand All @@ -765,7 +781,11 @@ sai_status_t DashSai::get(
if (objectType == SAI_OBJECT_TYPE_SWITCH)
return getSwitchAttribute(objectId, attr_count, attr_list);

DASH_LOG_ERROR("not implemented for object type %d", objectType);
auto* ot = sai_metadata_get_object_type_info(objectType);

const char* otName = ot ? ot->objecttypename : "unknown";

DASH_LOG_ERROR("not implemented for object type %d %s", objectType, otName);

return SAI_STATUS_NOT_IMPLEMENTED;
}

0 comments on commit bc9d1f8

Please sign in to comment.