Skip to content

Commit

Permalink
do not use sai_query_api_version if vendor sai does not support in Ve…
Browse files Browse the repository at this point in the history
…ndorSai.cpp (sonic-net#1064)

introduce function check if sai_query_api_version exists or not configure.ac.
If not, then do not call this function in the syncd.

Signed-off-by: Guohan Lu <lguohan@gmail.com>
  • Loading branch information
lguohan committed Jun 13, 2022
1 parent 9b0f773 commit 48cccb4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ AM_COND_IF([SYNCD], [
AM_COND_IF([SAIVS], [], [
SAVED_FLAGS="$CXXFLAGS"
CXXFLAGS="-lsai -I$srcdir/SAI/inc -I$srcdir/SAI/experimental -I$srcdir/SAI/meta"
AC_CHECK_FUNC(sai_query_api_version, [
AC_CHECK_FUNCS(sai_query_api_version, [
AC_MSG_CHECKING([SAI headers API version and library version check])
AC_TRY_RUN([
extern "C" {
Expand Down
10 changes: 6 additions & 4 deletions syncd/VendorSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ sai_status_t VendorSai::initialize(
return SAI_STATUS_INVALID_PARAMETER;
}

#ifdef HAVE_SAI_QUERY_API_VERSION
sai_api_version_t version{};
auto status = sai_query_api_version(&version);
if (status != SAI_STATUS_SUCCESS)
auto api_status = sai_query_api_version(&version);
if (api_status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("failed to query SAI API version");

return status;
return api_status;
}

SWSS_LOG_NOTICE("SAI API version: %" PRId64, version);
Expand All @@ -76,10 +77,11 @@ sai_status_t VendorSai::initialize(

return SAI_STATUS_FAILURE;
}
#endif

memcpy(&m_service_method_table, service_method_table, sizeof(m_service_method_table));

status = sai_api_initialize(flags, service_method_table);
auto status = sai_api_initialize(flags, service_method_table);

if (status == SAI_STATUS_SUCCESS)
{
Expand Down

0 comments on commit 48cccb4

Please sign in to comment.