Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions syncd/VendorSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,26 @@ sai_status_t VendorSai::apiInitialize(
return SAI_STATUS_FAILURE;
}

#ifdef HAVE_SAI_QUERY_STATS_ST_CAPABILITY
// BROADCOM_LEGACY_SAI_COMPAT: Allow platforms to disable sai_query_stats_st_capability at runtime
// via sai.profile key SAI_STATS_ST_CAPABILITY_SUPPORTED=0.
// Needed for legacy ASICs (e.g. Tomahawk-1/BCM56960) where the SAI function
// pointer is non-null but the internal ST platform driver is uninitialized,
// causing a SIGSEGV in brcm_sai_st_pd_ctr_cap_list_get.
if (m_globalApis.query_stats_st_capability != nullptr &&
m_service_method_table.profile_get_value != nullptr)
{
const char *stCapVal = m_service_method_table.profile_get_value(
0, "SAI_STATS_ST_CAPABILITY_SUPPORTED");
if (stCapVal != nullptr && std::string(stCapVal) == "0")
{
SWSS_LOG_NOTICE("SAI_STATS_ST_CAPABILITY_SUPPORTED=0 in sai.profile,"
" disabling query_stats_st_capability for this platform");
m_globalApis.query_stats_st_capability = nullptr;
}
}
#endif

m_apiInitialized = true;

return status;
Expand Down
1 change: 1 addition & 0 deletions tests/aspell.en.pws
Original file line number Diff line number Diff line change
Expand Up @@ -493,3 +493,4 @@ SNR
tparam
ICMP
UDP
SIGSEGV
30 changes: 30 additions & 0 deletions unittest/syncd/TestVendorSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1807,3 +1807,33 @@ TEST_F(VendorSaiTest, bulk_eni_trusted_vni_entry)
EXPECT_EQ(SAI_STATUS_NOT_SUPPORTED,
m_vsai->bulkSet(0, e, nullptr, SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, nullptr));
}

// BROADCOM_LEGACY_SAI_COMPAT tests ------------------------------------------------------------------------------------

static const char* profile_get_value_no_st_capability(
_In_ sai_switch_profile_id_t profile_id,
_In_ const char* variable)
{
SWSS_LOG_ENTER();

if (variable == NULL)
return NULL;

if (std::string(variable) == "SAI_STATS_ST_CAPABILITY_SUPPORTED")
return "0";

return nullptr;
}

static sai_service_method_table_t test_services_no_st_capability = {
profile_get_value_no_st_capability,
profile_get_next_value
};

TEST(VendorSai, statsStCapabilityProfileKeyProcessed)
{
// BROADCOM_LEGACY_SAI_COMPAT: SAI_STATS_ST_CAPABILITY_SUPPORTED=0 in sai.profile
// should be processed during apiInitialize without breaking initialization
VendorSai sai;
EXPECT_EQ(SAI_STATUS_SUCCESS, sai.apiInitialize(0, &test_services_no_st_capability));
}
Loading