From 446d36d939eb7e92d83e44437d10fa7de5a92329 Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Mon, 18 Dec 2017 22:27:26 +0000 Subject: [PATCH] adapt v1.2 --- lib/inc/sairedis.h | 4 ++-- lib/src/sai_redis_fdb.cpp | 16 ++++++++-------- lib/src/sai_redis_route.cpp | 12 ------------ syncd/tests.cpp | 21 +++++++++++++-------- 4 files changed, 23 insertions(+), 30 deletions(-) diff --git a/lib/inc/sairedis.h b/lib/inc/sairedis.h index 4763f9c38..88409e8aa 100644 --- a/lib/inc/sairedis.h +++ b/lib/inc/sairedis.h @@ -237,12 +237,12 @@ sai_status_t sai_bulk_create_fdb_entry( _In_ const sai_fdb_entry_t *fdb_entry, _In_ const uint32_t *attr_count, _In_ const sai_attribute_t *const *attr_list, - _In_ sai_bulk_op_type_t type, + _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses); sai_status_t sai_bulk_remove_fdb_entry( _In_ uint32_t object_count, _In_ const sai_fdb_entry_t *fdb_entry, - _In_ sai_bulk_op_type_t type, + _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses); #endif // __SAIREDIS__ diff --git a/lib/src/sai_redis_fdb.cpp b/lib/src/sai_redis_fdb.cpp index 5c262bef3..a896dc3e8 100644 --- a/lib/src/sai_redis_fdb.cpp +++ b/lib/src/sai_redis_fdb.cpp @@ -1,5 +1,5 @@ #include "sai_redis.h" -#include "meta/saiserialize.h" +#include "meta/sai_serialize.h" sai_status_t redis_flush_fdb_entries( _In_ sai_object_id_t switch_id, @@ -44,7 +44,7 @@ sai_status_t sai_bulk_create_fdb_entry( _In_ const sai_fdb_entry_t *fdb_entry, _In_ const uint32_t *attr_count, _In_ const sai_attribute_t *const *attr_list, - _In_ sai_bulk_op_type_t type, + _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses) { std::lock_guard lock(g_apimutex); @@ -79,16 +79,16 @@ sai_status_t sai_bulk_create_fdb_entry( return SAI_STATUS_INVALID_PARAMETER; } - switch (type) + switch (mode) { - case SAI_BULK_OP_TYPE_STOP_ON_ERROR: - case SAI_BULK_OP_TYPE_INGORE_ERROR: + case SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR: + case SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR: // ok break; default: - SWSS_LOG_ERROR("invalid bulk operation type %d", type); + SWSS_LOG_ERROR("invalid bulk operation mode %d", mode); return SAI_STATUS_INVALID_PARAMETER; } @@ -133,7 +133,7 @@ sai_status_t sai_bulk_create_fdb_entry( idx, serialized_object_ids[idx].c_str()); - if (type == SAI_BULK_OP_TYPE_STOP_ON_ERROR) + if (mode == SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR) { SWSS_LOG_NOTICE("stop on error since previous operation failed"); break; @@ -156,7 +156,7 @@ sai_status_t sai_bulk_create_fdb_entry( sai_status_t sai_bulk_remove_fdb_entry( _In_ uint32_t object_count, _In_ const sai_fdb_entry_t *fdb_entry, - _In_ sai_bulk_op_type_t type, + _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses) { std::lock_guard lock(g_apimutex); diff --git a/lib/src/sai_redis_route.cpp b/lib/src/sai_redis_route.cpp index 03cf54f84..348e1a4a6 100644 --- a/lib/src/sai_redis_route.cpp +++ b/lib/src/sai_redis_route.cpp @@ -3,18 +3,6 @@ #include "meta/sai_serialize.h" #include "meta/saiattributelist.h" -REDIS_GENERIC_QUAD_ENTRY(ROUTE_ENTRY,route_entry); - -const sai_route_api_t redis_route_api = { - - REDIS_GENERIC_QUAD_API(route_entry) - - sai_bulk_create_route_entry, - sai_bulk_remove_route_entry, - sai_bulk_set_route_entry_attribute, - sai_bulk_get_route_entry_attribute -}; - sai_status_t redis_dummy_create_route_entry( _In_ const sai_route_entry_t *route_entry, _In_ uint32_t attr_count, diff --git a/syncd/tests.cpp b/syncd/tests.cpp index 648d397c6..6146960a6 100644 --- a/syncd/tests.cpp +++ b/syncd/tests.cpp @@ -251,7 +251,7 @@ void test_bulk_next_hop_group_member_create() std::vector statuses(count); std::vector object_id(count); sai_bulk_create_next_hop_group_members(switch_id, count, nhgm_attrs_count.data(), nhgm_attrs_array.data() - , SAI_BULK_OP_TYPE_INGORE_ERROR, object_id.data(), statuses.data()); + , SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, object_id.data(), statuses.data()); ASSERT_SUCCESS("Failed to bulk create nhgm"); for (size_t j = 0; j < statuses.size(); j++) { @@ -271,7 +271,7 @@ void test_bulk_next_hop_group_member_create() assert(created_attrs[1].value.oid == nhgm_attrs[i][1].value.oid); } - status = sai_bulk_remove_next_hop_group_members(count, object_id.data(), SAI_BULK_OP_TYPE_INGORE_ERROR, statuses.data()); + status = sai_bulk_remove_next_hop_group_members(count, object_id.data(), SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, statuses.data()); ASSERT_SUCCESS("Failed to bulk remove nhgm"); } @@ -331,13 +331,18 @@ void test_bulk_fdb_create() std::string bridge_port_key = sai_serialize_object_meta_key(meta_key_bridge_port); ObjectAttrHash[bridge_port_key] = { }; + // bridge + sai_object_id_t bridge = create_dummy_object_id(SAI_OBJECT_TYPE_BRIDGE); + object_reference_insert(bridge); + sai_object_meta_key_t meta_key_bridge = { .objecttype = SAI_OBJECT_TYPE_BRIDGE, .objectkey = { .key = { .object_id = bridge } } }; + std::string bridge_key = sai_serialize_object_meta_key(meta_key_bridge); + ObjectAttrHash[bridge_key] = { }; + sai_fdb_entry_t fdb_entry; fdb_entry.switch_id = switch_id; memset(fdb_entry.mac_address, 0, sizeof(sai_mac_t)); fdb_entry.mac_address[0] = 0xD; - fdb_entry.bridge_type = SAI_FDB_ENTRY_BRIDGE_TYPE_1Q; - fdb_entry.vlan_id = (unsigned short)(1011 + i); - fdb_entry.bridge_id = SAI_NULL_OBJECT_ID; + fdb_entry.bv_id = bridge; fdbs.push_back(fdb_entry); @@ -367,7 +372,7 @@ void test_bulk_fdb_create() std::vector statuses(count); status = sai_bulk_create_fdb_entry(count, fdbs.data(), fdb_attrs_count.data(), fdb_attrs_array.data() - , SAI_BULK_OP_TYPE_INGORE_ERROR, statuses.data()); + , SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, statuses.data()); ASSERT_SUCCESS("Failed to create fdb"); for (size_t j = 0; j < statuses.size(); j++) { @@ -376,7 +381,7 @@ void test_bulk_fdb_create() } // Remove route entry - status = sai_bulk_remove_fdb_entry(count, fdbs.data(), SAI_BULK_OP_TYPE_INGORE_ERROR, statuses.data()); + status = sai_bulk_remove_fdb_entry(count, fdbs.data(), SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, statuses.data()); ASSERT_SUCCESS("Failed to bulk remove route entry"); } @@ -515,7 +520,7 @@ void test_bulk_route_set() // if after consume we get pop we get expectd parameters // Remove route entry - status = sai_bulk_remove_route_entry(count, routes.data(), SAI_BULK_OP_TYPE_INGORE_ERROR, statuses.data()); + status = sai_bulk_remove_route_entry(count, routes.data(), SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, statuses.data()); ASSERT_SUCCESS("Failed to bulk remove route entry"); }