Skip to content

Commit

Permalink
[syncd] Enable bulk api for neighbor entries
Browse files Browse the repository at this point in the history
SAI 1.11.0 added support for bulk neighbor entries. Adding support for
neighbor bulk operations to syncd.
* added neighbor entry capability to bulk operations in syncd
* added unit tests for neighbor bulk operations
* added code coverage for neighbor bulk operations

Signed-off-by: Nikola Dancejic <[email protected]>
  • Loading branch information
Ndancejic committed Aug 13, 2024
1 parent fbe3fc7 commit 57b8e6f
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 6 deletions.
5 changes: 0 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ AC_PROG_LIBTOOL
AC_HEADER_STDC
AM_PATH_PYTHON3
AX_PYTHON3_DEVEL
AX_CODE_COVERAGE
AX_ADD_AM_MACRO_STATIC([])

AM_CONDITIONAL(SONIC_ASIC_PLATFORM_BAREFOOT, test x$CONFIGURED_PLATFORM = xbarefoot)
Expand All @@ -29,10 +28,6 @@ AM_CONDITIONAL(DEBUG, test x$debug = xtrue)

AM_COND_IF([DEBUG], AC_SUBST(DBGFLAGS, "-ggdb -DDEBUG"), AC_SUBST(DBGFLAGS, "-g"))

AM_COND_IF([DEBUG],
[AM_COND_IF([CODE_COVERAGE_ENABLED],
AC_MSG_ERROR("Flag conflict --enable-debug 'DEBUG' and --enable-code-coverage 'NDEBUG'"))])

AC_ARG_WITH(sai,
[ --with-sai=vs compiling against specific SAI],
[case "${withval}" in
Expand Down
52 changes: 52 additions & 0 deletions saiplayer/SaiPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,23 @@ sai_status_t SaiPlayer::handle_bulk_entry(
}
break;

case SAI_OBJECT_TYPE_NEIGHBOR_ENTRY:
{
std::vector<sai_neighbor_entry_t> entries(object_count);

for (size_t it = 0; it < object_count; it++)
{
sai_deserialize_neighbor_entry(object_ids[it], entries[it]);

entries[it].switch_id = translate_local_to_redis(entries[it].switch_id);
entries[it].rif_id = translate_local_to_redis(entries[it].rif_id);
}

CALL_BULK_CREATE_API_WITH_TIMER("neighbor_entry");

}
break;

case SAI_OBJECT_TYPE_FDB_ENTRY:
{

Expand Down Expand Up @@ -1876,6 +1893,23 @@ sai_status_t SaiPlayer::handle_bulk_entry(
}
break;

case SAI_OBJECT_TYPE_NEIGHBOR_ENTRY:
{
std::vector<sai_neighbor_entry_t> entries(object_count);

for (size_t it = 0; it < object_count; it++)
{
sai_deserialize_neighbor_entry(object_ids[it], entries[it]);

entries[it].switch_id = translate_local_to_redis(entries[it].switch_id);
entries[it].rif_id = translate_local_to_redis(entries[it].rif_id);
}

CALL_BULK_REMOVE_API_WITH_TIMER("neighbor_entry");

}
break;

case SAI_OBJECT_TYPE_FDB_ENTRY:
{

Expand Down Expand Up @@ -2061,6 +2095,23 @@ sai_status_t SaiPlayer::handle_bulk_entry(
}
break;

case SAI_OBJECT_TYPE_NEIGHBOR_ENTRY:
{
std::vector<sai_neighbor_entry_t> entries(object_count);

for (size_t it = 0; it < object_count; it++)
{
sai_deserialize_neighbor_entry(object_ids[it], entries[it]);

entries[it].switch_id = translate_local_to_redis(entries[it].switch_id);
entries[it].rif_id = translate_local_to_redis(entries[it].rif_id);
}

CALL_BULK_SET_API_WITH_TIMER("neighbor_entry");

}
break;

case SAI_OBJECT_TYPE_FDB_ENTRY:
{

Expand Down Expand Up @@ -2452,6 +2503,7 @@ void SaiPlayer::processBulk(
switch ((int)object_type)
{
case SAI_OBJECT_TYPE_ROUTE_ENTRY:
case SAI_OBJECT_TYPE_NEIGHBOR_ENTRY:
case SAI_OBJECT_TYPE_FDB_ENTRY:
case SAI_OBJECT_TYPE_NAT_ENTRY:
case SAI_OBJECT_TYPE_DIRECTION_LOOKUP_ENTRY:
Expand Down
4 changes: 4 additions & 0 deletions syncd/Syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1790,6 +1790,10 @@ sai_status_t Syncd::processBulkEntry(
sai_deserialize_route_entry(objectIds[idx], metaKey.objectkey.key.route_entry);
break;

case SAI_OBJECT_TYPE_NEIGHBOR_ENTRY:
sai_deserialize_neighbor_entry(objectIds[idx], metaKey.objectkey.key.neighbor_entry);
break;

case SAI_OBJECT_TYPE_NAT_ENTRY:
sai_deserialize_nat_entry(objectIds[idx], metaKey.objectkey.key.nat_entry);
break;
Expand Down
2 changes: 2 additions & 0 deletions syncd/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,8 @@ int main()

test_bulk_fdb_create();

test_bulk_neighbor_set();

test_bulk_route_set();

sai_api_uninitialize();
Expand Down
8 changes: 8 additions & 0 deletions tests/BCM56850.pl
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,13 @@ sub test_bulk_route
play "bulk_route.rec"
}

sub test_bulk_neighbor
{
fresh_start;

play "bulk_neighbor.rec"
}

sub test_bulk_fdb
{
fresh_start;
Expand Down Expand Up @@ -862,6 +869,7 @@ sub test_acl_pre_match_999
test_acl_mask;
test_empty_lag_buffer_acl;
test_bulk_route;
test_bulk_neighbor;
test_bulk_fdb;
test_bulk_object;
test_brcm_config_acl;
Expand Down
12 changes: 12 additions & 0 deletions tests/BCM56850/bulk_neighbor.rec
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
2024-05-22.01:55:46.541806|#|recording on: ./sairedis.2024-05-22.01:55:46.541389.rec
2024-05-22.01:55:46.543987|a|INIT_VIEW
2024-05-22.01:55:46.551164|A|SAI_STATUS_SUCCESS
2024-05-22.01:55:46.555975|c|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_INIT_SWITCH=true|SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY=0x417890|SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY=0x4179f0|SAI_SWITCH_ATTR_SWITCH_SHUTDOWN_REQUEST_NOTIFY=0x417b50
2024-05-22.01:56:05.508992|c|SAI_OBJECT_TYPE_VIRTUAL_ROUTER:oid:0x3000000000004
2024-05-22.01:56:05.708992|c|SAI_OBJECT_TYPE_PORT:oid:0x20000000006ee|SAI_PORT_ATTR_SPEED=10000|SAI_PORT_ATTR_HW_LANE_LIST=1:202
2024-05-22.01:56:05.805336|c|SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000727|SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID=oid:0x3000000000004|SAI_ROUTER_INTERFACE_ATTR_SRC_MAC_ADDRESS=00:E0:EC:C2:AF:7A|SAI_ROUTER_INTERFACE_ATTR_TYPE=SAI_ROUTER_INTERFACE_TYPE_PORT|SAI_ROUTER_INTERFACE_ATTR_PORT_ID=oid:0x20000000006ee|SAI_ROUTER_INTERFACE_ATTR_MTU=9100|SAI_ROUTER_INTERFACE_ATTR_NAT_ZONE_ID=0
2024-05-22.01:56:06.105336|C|SAI_OBJECT_TYPE_NEIGHBOR_ENTRY||{"ip":"10.0.0.57","rif":"oid:0x6000000000727","switch_id":"oid:0x21000000000000"}|SAI_NEIGHBOR_ENTRY_ATTR_DST_MAC_ADDRESS=FF:FF:FF:FF:FF:FF||{"ip":"10.0.0.59","rif":"oid:0x6000000000727","switch_id":"oid:0x21000000000000"}|SAI_NEIGHBOR_ENTRY_ATTR_DST_MAC_ADDRESS=FF:FF:FF:FF:FF:FF
2024-05-22.01:56:06.205336|S|SAI_OBJECT_TYPE_NEIGHBOR_ENTRY||{"ip":"10.0.0.57","rif":"oid:0x6000000000727","switch_id":"oid:0x21000000000000"}|SAI_NEIGHBOR_ENTRY_ATTR_DST_MAC_ADDRESS=FF:FF:FF:FF:FF:00||{"ip":"10.0.0.59","rif":"oid:0x6000000000727","switch_id":"oid:0x21000000000000"}|SAI_NEIGHBOR_ENTRY_ATTR_DST_MAC_ADDRESS=FF:FF:FF:FF:FF:00
2024-05-22.01:56:06.205336|R|SAI_OBJECT_TYPE_NEIGHBOR_ENTRY||{"ip":"10.0.0.57","rif":"oid:0x6000000000727","switch_id":"oid:0x21000000000000"}||{"ip":"10.0.0.59","rif":"oid:0x6000000000727","switch_id":"oid:0x21000000000000"}
2024-05-22.01:56:06.151337|a|APPLY_VIEW
2024-05-22.01:56:06.156740|A|SAI_STATUS_SUCCESS
5 changes: 5 additions & 0 deletions unittest/lib/test_sai_redis_neighbor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ TEST(libsairedis, neighbor)
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_neighbor_entry_attribute(0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_neighbor_entry_attribute(0,0,0));

EXPECT_NE(SAI_STATUS_SUCCESS, api->create_neighbor_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_neighbor_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_neighbor_entries_attribute(0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_neighbor_entries_attribute(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0));

EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, api->remove_all_neighbor_entries(0));
}
5 changes: 5 additions & 0 deletions unittest/vslib/test_sai_vs_neighbor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ TEST(libsaivs, neighbor)
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_neighbor_entry_attribute(0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_neighbor_entry_attribute(0,0,0));

EXPECT_NE(SAI_STATUS_SUCCESS, api->create_neighbor_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_neighbor_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_neighbor_entries_attribute(0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_neighbor_entries_attribute(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0));

EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, api->remove_all_neighbor_entries(0));
}

0 comments on commit 57b8e6f

Please sign in to comment.