Skip to content

Commit

Permalink
adapt v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lguohan committed Dec 18, 2017
1 parent 4240c87 commit 446d36d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 30 deletions.
4 changes: 2 additions & 2 deletions lib/inc/sairedis.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__
16 changes: 8 additions & 8 deletions lib/src/sai_redis_fdb.cpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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<std::mutex> lock(g_apimutex);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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<std::mutex> lock(g_apimutex);
Expand Down
12 changes: 0 additions & 12 deletions lib/src/sai_redis_route.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 13 additions & 8 deletions syncd/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void test_bulk_next_hop_group_member_create()
std::vector<sai_status_t> statuses(count);
std::vector<sai_object_id_t> 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++)
{
Expand All @@ -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");
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -367,7 +372,7 @@ void test_bulk_fdb_create()

std::vector<sai_status_t> 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++)
{
Expand All @@ -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");
}

Expand Down Expand Up @@ -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");
}

Expand Down

0 comments on commit 446d36d

Please sign in to comment.