Skip to content

Commit

Permalink
Add log attr name in auto generated dash api
Browse files Browse the repository at this point in the history
Also using metadata
  • Loading branch information
kcudnik committed Oct 21, 2023
1 parent f83d737 commit 951f7eb
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions dash-pipeline/SAI/templates/saiapi.cpp.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include "utils.h"
#include "saiimpl.h"

extern "C" {
#include "saimetadata.h"
}

using namespace dash::utils;

{% set registered_group = [] %}
Expand Down Expand Up @@ -63,6 +67,10 @@ static sai_status_t dash_sai_create_{{ table.name }}(
// Copy P4 table keys from appropriate SAI attributes
for (uint32_t i = 0; i < attr_count; i++)
{
auto *md = sai_metadata_get_attr_metadata((sai_object_type_t)SAI_OBJECT_TYPE_{{ table.name | upper }}, attr_list[i].id);

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

switch(attr_list[i].id)
{
{% for key in table['keys'] %}
Expand Down Expand Up @@ -120,7 +128,7 @@ static sai_status_t dash_sai_create_{{ table.name }}(
{% endif %}
{% endif %}
default:
DASH_LOG_ERROR("attribute [%d] %d not supported yet", i, attr_list[i].id);
DASH_LOG_ERROR("attribute [%d] %d %s not supported yet", i, attr_list[i].id, attrName);
break;
}
}
Expand Down Expand Up @@ -163,6 +171,10 @@ static sai_status_t dash_sai_create_{{ table.name }}(

for (uint32_t i = 0; i < attr_count; i++)
{
auto *md = sai_metadata_get_attr_metadata((sai_object_type_t)SAI_OBJECT_TYPE_{{ table.name | upper }}, attr_list[i].id);

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

switch(attr_list[i].id)
{
{% for param in table.actionParams %}
Expand All @@ -188,7 +200,7 @@ static sai_status_t dash_sai_create_{{ table.name }}(
{% endif %}
{% endfor %}
default:
DASH_LOG_ERROR("attribute [%d] %d not supported yet", i, attr_list[i].id);
DASH_LOG_ERROR("attribute [%d] %d %s not supported yet", i, attr_list[i].id, attrName);
break;
}
}
Expand Down Expand Up @@ -387,6 +399,10 @@ static sai_status_t dash_sai_create_{{ table.name }}(

for (uint32_t i = 0; i < attr_count; i++)
{
auto *md = sai_metadata_get_attr_metadata((sai_object_type_t)SAI_OBJECT_TYPE_{{ table.name | upper }}, attr_list[i].id);

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

switch(attr_list[i].id)
{
{% for param in table.actionParams %}
Expand All @@ -412,7 +428,7 @@ static sai_status_t dash_sai_create_{{ table.name }}(
{% endif %}
{% endfor %}
default:
DASH_LOG_ERROR("attribute [%d] %d not supported yet", i, attr_list[i].id);
DASH_LOG_ERROR("attribute [%d] %d %s not supported yet", i, attr_list[i].id, attrName);
break;
}
}
Expand Down

0 comments on commit 951f7eb

Please sign in to comment.