Skip to content

Commit

Permalink
[submodule] Update SAI to lates origin master (#1466)
Browse files Browse the repository at this point in the history
Will include updates on other components to accommodate for changes
  • Loading branch information
kcudnik authored Nov 20, 2024
1 parent fc376d5 commit 526bca3
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 1 deletion.
19 changes: 19 additions & 0 deletions meta/Meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3154,6 +3154,25 @@ sai_status_t Meta::meta_sai_validate_meter_bucket_entry(
return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t Meta::meta_sai_validate_prefix_compression_entry(
_In_ const sai_prefix_compression_entry_t* prefix_compression_entry,
_In_ bool create,
_In_ bool get)
{
SWSS_LOG_ENTER();

if (prefix_compression_entry == NULL)
{
SWSS_LOG_ERROR("prefix_compression_entry pointer is NULL");

return SAI_STATUS_INVALID_PARAMETER;
}

// TODO FIX ME

return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t Meta::meta_generic_validation_create(
_In_ const sai_object_meta_key_t& meta_key,
_In_ sai_object_id_t switch_id,
Expand Down
5 changes: 5 additions & 0 deletions meta/Meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,11 @@ namespace saimeta
_In_ bool create,
_In_ bool get = false);

sai_status_t meta_sai_validate_prefix_compression_entry(
_In_ const sai_prefix_compression_entry_t* prefix_compression_entry,
_In_ bool create,
_In_ bool get = false);

public:

/*
Expand Down
35 changes: 35 additions & 0 deletions meta/SaiSerialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,20 @@ std::string sai_serialize_meter_bucket_entry(
return j.dump();
}

std::string sai_serialize_prefix_compression_entry(
_In_ const sai_prefix_compression_entry_t &prefix_compression_entry)
{
SWSS_LOG_ENTER();

json j;

j["switch_id"] = sai_serialize_object_id(prefix_compression_entry.switch_id);
j["prefix_table_id"] = sai_serialize_object_id(prefix_compression_entry.prefix_table_id);
j["prefix"] = sai_serialize_ip_prefix(prefix_compression_entry.prefix);

return j.dump();
}

std::string sai_serialize_flow_entry(
_In_ const sai_flow_entry_t &flow_entry)
{
Expand Down Expand Up @@ -2662,6 +2676,10 @@ static bool sai_serialize_object_entry(
key = sai_serialize_mcast_fdb_entry(key_entry.mcast_fdb_entry);
return true;

case SAI_OBJECT_TYPE_PREFIX_COMPRESSION_ENTRY:
key = sai_serialize_prefix_compression_entry(key_entry.prefix_compression_entry);
return true;

default:
return false;
}
Expand Down Expand Up @@ -4451,6 +4469,19 @@ void sai_deserialize_meter_bucket_entry(
sai_deserialize_number(j["meter_class"], meter_bucket_entry.meter_class);
}

void sai_deserialize_prefix_compression_entry(
_In_ const std::string& s,
_Out_ sai_prefix_compression_entry_t& prefix_compression_entry)
{
SWSS_LOG_ENTER();

json j = json::parse(s);

sai_deserialize_object_id(j["switch_id"], prefix_compression_entry.switch_id);
sai_deserialize_object_id(j["prefix_table_id"], prefix_compression_entry.prefix_table_id);
sai_deserialize_ip_prefix(j["prefix"], prefix_compression_entry.prefix);
}

void sai_deserialize_flow_entry(
_In_ const std::string& s,
_Out_ sai_flow_entry_t &flow_entry)
Expand Down Expand Up @@ -4902,6 +4933,10 @@ bool sai_deserialize_object_entry(
sai_deserialize_mcast_fdb_entry(object_id, meta_key.objectkey.key.mcast_fdb_entry);
return true;

case SAI_OBJECT_TYPE_PREFIX_COMPRESSION_ENTRY:
sai_deserialize_prefix_compression_entry(object_id, meta_key.objectkey.key.prefix_compression_entry);
return true;

default:
return false;
}
Expand Down
7 changes: 7 additions & 0 deletions meta/sai_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ std::string sai_serialize_fdb_entry(
std::string sai_serialize_meter_bucket_entry(
_In_ const sai_meter_bucket_entry_t &meter_bucket_entry);

std::string sai_serialize_prefix_compression_entry(
_In_ const sai_prefix_compression_entry_t &prefix_compression_entry);

std::string sai_serialize_flow_entry(
_In_ const sai_flow_entry_t &flow_entry);

Expand Down Expand Up @@ -440,6 +443,10 @@ void sai_deserialize_meter_bucket_entry(
_In_ const std::string& s,
_Out_ sai_meter_bucket_entry_t& meter_bucket_entry);

void sai_deserialize_prefix_compression_entry(
_In_ const std::string& s,
_Out_ sai_prefix_compression_entry_t& prefix_compression_entry);

void sai_deserialize_flow_entry(
_In_ const std::string& s,
_Out_ sai_flow_entry_t &flow_entry);
Expand Down
64 changes: 64 additions & 0 deletions syncd/VendorSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,33 @@ sai_status_t VendorSai::bulkCreate(
object_statuses);
}

sai_status_t VendorSai::bulkCreate(
_In_ uint32_t object_count,
_In_ const sai_prefix_compression_entry_t* entries,
_In_ const uint32_t *attr_count,
_In_ const sai_attribute_t **attr_list,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses)
{
MUTEX();
SWSS_LOG_ENTER();
VENDOR_CHECK_API_INITIALIZED();

if (!m_apis.prefix_compression_api->create_prefix_compression_entries)
{
SWSS_LOG_INFO("create_prefix_compression_entries is not supported");
return SAI_STATUS_NOT_SUPPORTED;
}

return m_apis.prefix_compression_api->create_prefix_compression_entries(
object_count,
entries,
attr_count,
attr_list,
mode,
object_statuses);
}

// BULK REMOVE

sai_status_t VendorSai::bulkRemove(
Expand Down Expand Up @@ -1403,6 +1430,29 @@ sai_status_t VendorSai::bulkRemove(
object_statuses);
}

sai_status_t VendorSai::bulkRemove(
_In_ uint32_t object_count,
_In_ const sai_prefix_compression_entry_t *entries,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses)
{
MUTEX();
SWSS_LOG_ENTER();
VENDOR_CHECK_API_INITIALIZED();

if (!m_apis.prefix_compression_api->remove_prefix_compression_entries)
{
SWSS_LOG_INFO("remove_prefix_compression_entries is not supported");
return SAI_STATUS_NOT_SUPPORTED;
}

return m_apis.prefix_compression_api->remove_prefix_compression_entries(
object_count,
entries,
mode,
object_statuses);
}

// BULK SET

sai_status_t VendorSai::bulkSet(
Expand Down Expand Up @@ -1681,6 +1731,20 @@ sai_status_t VendorSai::bulkSet(
return SAI_STATUS_NOT_SUPPORTED;
}

sai_status_t VendorSai::bulkSet(
_In_ uint32_t object_count,
_In_ const sai_prefix_compression_entry_t *entries,
_In_ const sai_attribute_t *attr_list,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses)
{
MUTEX();
SWSS_LOG_ENTER();
VENDOR_CHECK_API_INITIALIZED();

return SAI_STATUS_NOT_SUPPORTED;
}

// NON QUAD API

sai_status_t VendorSai::flushFdbEntries(
Expand Down
9 changes: 9 additions & 0 deletions unittest/meta/TestMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1841,3 +1841,12 @@ TEST(Meta, remove_meter_bucket_entry)

EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai.remove(e));
}

TEST(Meta, remove_prefix_compression_entry)
{
Meta sai(std::make_shared<MetaTestSaiInterface>());

sai_prefix_compression_entry_t* e = nullptr;

EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai.remove(e));
}
11 changes: 11 additions & 0 deletions unittest/meta/TestSaiSerialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,3 +1347,14 @@ TEST(SaiSerialize, serialize_number)
EXPECT_EQ(sn, -0x12345678);
EXPECT_EQ(u, 0x12345678);
}

TEST(SaiSerialize, sai_serialize_prefix_compression_entry)
{
sai_prefix_compression_entry_t e;

memset(&e, 0, sizeof(e));

auto s = sai_serialize_prefix_compression_entry(e);

sai_deserialize_prefix_compression_entry(s, e);
}
15 changes: 15 additions & 0 deletions unittest/syncd/TestVendorSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1543,3 +1543,18 @@ TEST(VendorSai, bulk_meter_rules)
EXPECT_EQ(SAI_STATUS_SUCCESS, sai.remove((sai_object_type_t)SAI_OBJECT_TYPE_METER_POLICY, meter_policy0));
EXPECT_EQ(SAI_STATUS_SUCCESS, sai.remove((sai_object_type_t)SAI_OBJECT_TYPE_METER_POLICY, meter_policy1));
}

TEST_F(VendorSaiTest, bulk_prefix_compression_entry)
{
sai_prefix_compression_entry_t *e = nullptr;

// metadata will fail
EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER,
m_vsai->bulkCreate(0, e, nullptr, nullptr, SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, nullptr));

EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER,
m_vsai->bulkRemove(0, e, SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, nullptr));

EXPECT_EQ(SAI_STATUS_NOT_SUPPORTED,
m_vsai->bulkSet(0, e, nullptr, SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, nullptr));
}

0 comments on commit 526bca3

Please sign in to comment.