diff --git a/SAI b/SAI index f214adef0..054085547 160000 --- a/SAI +++ b/SAI @@ -1 +1 @@ -Subproject commit f214adef0f336cb991bad4461e626dc039f01878 +Subproject commit 054085547c2042b95ab0fa1a75a44da3288b26bf diff --git a/meta/Meta.cpp b/meta/Meta.cpp index a9851d201..92ba95f7c 100644 --- a/meta/Meta.cpp +++ b/meta/Meta.cpp @@ -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, diff --git a/meta/Meta.h b/meta/Meta.h index ce8a0a2dd..c93ae7a59 100644 --- a/meta/Meta.h +++ b/meta/Meta.h @@ -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: /* diff --git a/meta/SaiSerialize.cpp b/meta/SaiSerialize.cpp index 72596c96e..3896519fc 100644 --- a/meta/SaiSerialize.cpp +++ b/meta/SaiSerialize.cpp @@ -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) { @@ -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; } @@ -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) @@ -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; } diff --git a/meta/sai_serialize.h b/meta/sai_serialize.h index ed7eb91dc..4c9c51e3d 100644 --- a/meta/sai_serialize.h +++ b/meta/sai_serialize.h @@ -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); @@ -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); diff --git a/syncd/VendorSai.cpp b/syncd/VendorSai.cpp index c0cb5683a..bb6734256 100644 --- a/syncd/VendorSai.cpp +++ b/syncd/VendorSai.cpp @@ -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( @@ -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( @@ -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( diff --git a/unittest/meta/TestMeta.cpp b/unittest/meta/TestMeta.cpp index 0b0d35b25..d31ed4a4d 100644 --- a/unittest/meta/TestMeta.cpp +++ b/unittest/meta/TestMeta.cpp @@ -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()); + + sai_prefix_compression_entry_t* e = nullptr; + + EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai.remove(e)); +} diff --git a/unittest/meta/TestSaiSerialize.cpp b/unittest/meta/TestSaiSerialize.cpp index b7e0c97d6..ab7521db0 100644 --- a/unittest/meta/TestSaiSerialize.cpp +++ b/unittest/meta/TestSaiSerialize.cpp @@ -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); +} diff --git a/unittest/syncd/TestVendorSai.cpp b/unittest/syncd/TestVendorSai.cpp index 63977e713..f14d280a4 100644 --- a/unittest/syncd/TestVendorSai.cpp +++ b/unittest/syncd/TestVendorSai.cpp @@ -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)); +}