Skip to content

Commit

Permalink
[orchagent] Enhance checks to detect if Path Tracing is supported
Browse files Browse the repository at this point in the history
- Move the logic to detect if Path Tracing is supported or not to a separate function
- Verify also if TAM, TAM INT and TAM report objects are supported by the switch

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
  • Loading branch information
cscarpitta committed Oct 26, 2023
1 parent 47bf698 commit 5b57173
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 3 deletions.
82 changes: 79 additions & 3 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,80 @@ static void getPortSerdesAttr(PortSerdesAttrMap_t &map, const PortConfig &port)
}
}

static bool isPathTracingSupported()
{
/*
* Path Tracing is supported when three conditions are met:
*
* 1. The switch supports SAI_OBJECT_TYPE_TAM, SAI_OBJECT_TYPE_TAM_INT and SAI_OBJECT_TYPE_TAM_REPORT
* 2. SAI_OBJECT_TYPE_PORT supports SAI_PORT_ATTR_PATH_TRACING_INTF attribute
* 3. SAI_OBJECT_TYPE_PORT supports SAI_PORT_ATTR_PATH_TRACING_TIMESTAMP_TYPE attribute
* 4. SAI_OBJECT_TYPE_PORT supports SAI_PORT_ATTR_TAM_OBJECT attribute
*/

/* First, query switch capabilities */
sai_attribute_t attr;
std::vector<sai_int32_t> switchCapabilities;
std::vector<sai_int32_t> switchCapabilities(SAI_OBJECT_TYPE_MAX);
attr.id = SAI_SWITCH_ATTR_SUPPORTED_OBJECT_TYPE_LIST;
attr.value.s32list.count = static_cast<uint32_t>(switchCapabilities.size());
attr.value.s32list.list = switchCapabilities.data();

bool is_tam_supported = false;
bool is_tam_int_supported = false;
bool is_tam_report_supported = false;
auto status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &attr);
if (status == SAI_STATUS_SUCCESS)
{
for (std::uint32_t i = 0; i < attr.value.s32list.count; i++)
{
switch(static_cast<sai_object_type_t>(attr.value.s32list.list[i]))
{
case SAI_OBJECT_TYPE_TAM:
is_tam_supported = true;
break;
case SAI_OBJECT_TYPE_TAM_INT:
is_tam_int_supported = true;
break;
case SAI_OBJECT_TYPE_TAM_REPORT:
is_tam_report_supported = true;
break;
default:
/* Received an attribute in which we are not interested, ignoring it */
break;
}
}
}
else
{
SWSS_LOG_ERROR(
"Failed to get a list of supported switch capabilities. Error=%d", status
);
return false;
}

/* Then verify if the three conditions are met */
if (!is_tam_supported || !is_tam_int_supported || !is_tam_report_supported)
return false;

if (!gSwitchOrch->querySwitchCapability(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_PATH_TRACING_INTF))
{
return false;
}

if (!gSwitchOrch->querySwitchCapability(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_PATH_TRACING_TIMESTAMP_TYPE))
{
return false;
}

if (!gSwitchOrch->querySwitchCapability(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_TAM_OBJECT))
{
return false;
}

return true;
}

// Port OA ------------------------------------------------------------------------------------------------------------

/*
Expand Down Expand Up @@ -593,17 +667,19 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi

/* Query Path Tracing capability */
vector<FieldValueTuple> fvVector;
if (gSwitchOrch->querySwitchCapability(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_PATH_TRACING_INTF) &&
gSwitchOrch->querySwitchCapability(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_PATH_TRACING_TIMESTAMP_TYPE) &&
gSwitchOrch->querySwitchCapability(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_TAM_OBJECT))
if (isPathTracingSupported())
{
SWSS_LOG_INFO("Path Tracing is supported");
/* Set PATH_TRACING_CAPABLE = true in STATE DB */
fvVector.emplace_back(SWITCH_CAPABILITY_TABLE_PATH_TRACING_CAPABLE, "true");
m_isPathTracingSupported = true;
}
else
{
SWSS_LOG_INFO("Path Tracing is not supported");
/* Set PATH_TRACING_CAPABLE = false in STATE DB */
fvVector.emplace_back(SWITCH_CAPABILITY_TABLE_PATH_TRACING_CAPABLE, "false");
m_isPathTracingSupported = false;
}
gSwitchOrch->set_switch_capability(fvVector);

Expand Down
2 changes: 2 additions & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,8 @@ class PortsOrch : public Orch, public Subject
sai_object_id_t m_ptTam = SAI_NULL_OBJECT_ID;
uint32_t m_ptTamRefCount = 0;
map<string, sai_object_id_t> m_portPtTam;
// Define whether the switch supports or not Path Tracing
bool m_isPathTracingSupported = false;

private:
// Port config aggregator
Expand Down

0 comments on commit 5b57173

Please sign in to comment.