diff --git a/lib/inc/sairedis.h b/lib/inc/sairedis.h index a971a3e61d56..1d9f64eb41c1 100644 --- a/lib/inc/sairedis.h +++ b/lib/inc/sairedis.h @@ -5,18 +5,6 @@ extern "C" { #include "sai.h" } -#define SYNCD_INIT_VIEW "INIT_VIEW" -#define SYNCD_APPLY_VIEW "APPLY_VIEW" -#define SYNCD_INSPECT_ASIC "SYNCD_INSPECT_ASIC" -#define ASIC_STATE_TABLE "ASIC_STATE" -#define TEMP_PREFIX "TEMP_" - -// Messages for processing queries from libsairedis to syncd -const std::string attrEnumValuesCapabilityQuery("attr_enum_values_capability_query"); -const std::string attrEnumValuesCapabilityResponse("attr_enum_values_capability_response"); -const std::string objectTypeGetAvailabilityQuery("object_type_get_availability_query"); -const std::string objectTypeGetAvailabilityResponse("object_type_get_availability_response"); - typedef enum _sai_redis_notify_syncd_t { SAI_REDIS_NOTIFY_SYNCD_INIT_VIEW, @@ -125,146 +113,4 @@ typedef enum _sai_redis_switch_attr_t } sai_redis_switch_attr_t; -/* - * Those bulk APIs are provided as static functions since current SAI 0.9.4 - * doesn't support bulk API. Also note that SDK don't support bulk route API - * yet, so those APIs are introduced here to reduce number of calls to redis, - * in syncd bulk API will be splitted to separate call's until proper SDK - * support will be added. - * - * Currently bulk operation type is skipped, and all operation must end with - * success. - */ - -#ifndef SAI_STATUS_NOT_EXECUTED -#define SAI_STATUS_NOT_EXECUTED SAI_STATUS_CODE(0x00000017L) -#endif - -#ifndef SAI_COMMON_API_BULK_SET -#define SAI_COMMON_API_BULK_CREATE 4 -#define SAI_COMMON_API_BULK_REMOVE 5 -#define SAI_COMMON_API_BULK_SET 6 -#define SAI_COMMON_API_BULK_GET 7 -#endif - -/** - * @brief Bulk create route entry - * - * @param[in] object_count Number of objects to create - * @param[in] route_entry List of object to create - * @param[in] attr_count List of attr_count. Caller passes the number - * of attribute for each object to create. - * @param[in] attr_list List of attributes for every object. - * @param[in] mode Bulk operation error handling mode - * @param[out] object_statuses List of status for every object. Caller needs to - * allocate the buffer - * - * @return #SAI_STATUS_SUCCESS on success when all objects are created or - * #SAI_STATUS_FAILURE when any of the objects fails to create. When there is - * failure, Caller is expected to go through the list of returned statuses to - * find out which fails and which succeeds. - */ -sai_status_t sai_bulk_create_route_entry( - _In_ uint32_t object_count, - _In_ const sai_route_entry_t *route_entry, - _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); - -/** - * @brief Bulk remove route entry - * - * @param[in] object_count Number of objects to remove - * @param[in] route_entry List of objects to remove - * @param[in] mode Bulk operation error handling mode - * @param[out] object_statuses List of status for every object. Caller needs to - * allocate the buffer - * - * @return #SAI_STATUS_SUCCESS on success when all objects are removed or - * #SAI_STATUS_FAILURE when any of the objects fails to remove. When there is - * failure, Caller is expected to go through the list of returned statuses to - * find out which fails and which succeeds. - */ -sai_status_t sai_bulk_remove_route_entry( - _In_ uint32_t object_count, - _In_ const sai_route_entry_t *route_entry, - _In_ sai_bulk_op_error_mode_t mode, - _Out_ sai_status_t *object_statuses); - -/** - * @brief Bulk set attribute on route entry - * - * @param[in] object_count Number of objects to set attribute - * @param[in] route_entry List of objects to set attribute - * @param[in] attr_list List of attributes to set on objects, one attribute per object - * @param[in] mode Bulk operation error handling mode - * @param[out] object_statuses List of status for every object. Caller needs to - * allocate the buffer - * - * @return #SAI_STATUS_SUCCESS on success when all objects are removed or - * #SAI_STATUS_FAILURE when any of the objects fails to remove. When there is - * failure, Caller is expected to go through the list of returned statuses to - * find out which fails and which succeeds. - */ -sai_status_t sai_bulk_set_route_entry_attribute( - _In_ uint32_t object_count, - _In_ const sai_route_entry_t *route_entry, - _In_ const sai_attribute_t *attr_list, - _In_ sai_bulk_op_error_mode_t mode, - _Out_ sai_status_t *object_statuses); - -/** - * @brief Bulk get attribute on route entry - * - * @param[in] object_count Number of objects to set attribute - * @param[in] route_entry List of objects to set attribute - * @param[in] attr_count List of attr_count. Caller passes the number - * of attribute for each object to get - * @param[inout] attr_list List of attributes to set on objects, one attribute per object - * @param[in] mode Bulk operation error handling mode - * @param[out] object_statuses List of status for every object. Caller needs to - * allocate the buffer - * - * @return #SAI_STATUS_SUCCESS on success when all objects are removed or - * #SAI_STATUS_FAILURE when any of the objects fails to remove. When there is - * failure, Caller is expected to go through the list of returned statuses to - * find out which fails and which succeeds. - */ -sai_status_t sai_bulk_get_route_entry_attribute( - _In_ uint32_t object_count, - _In_ const sai_route_entry_t *route_entry, - _In_ const uint32_t *attr_count, - _Inout_ sai_attribute_t **attr_list, - _In_ sai_bulk_op_error_mode_t mode, - _Out_ sai_status_t *object_statuses); - -sai_status_t sai_bulk_create_next_hop_group_members( - _In_ sai_object_id_t switch_id, - _In_ uint32_t object_count, - _In_ const uint32_t *attr_count, - _In_ const sai_attribute_t **attrs, - _In_ sai_bulk_op_error_mode_t mode, - _Out_ sai_object_id_t *object_id, - _Out_ sai_status_t *object_statuses); - -sai_status_t sai_bulk_remove_next_hop_group_members( - _In_ uint32_t object_count, - _In_ const sai_object_id_t *object_id, - _In_ sai_bulk_op_error_mode_t mode, - _Out_ sai_status_t *object_statuses); - -sai_status_t sai_bulk_create_fdb_entry( - _In_ uint32_t object_count, - _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_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_error_mode_t mode, - _Out_ sai_status_t *object_statuses); #endif // __SAIREDIS__ diff --git a/lib/inc/sairediscommon.h b/lib/inc/sairediscommon.h new file mode 100644 index 000000000000..ad401cc97aa9 --- /dev/null +++ b/lib/inc/sairediscommon.h @@ -0,0 +1,18 @@ +#ifndef __SAIREDISCOMMON__ +#define __SAIREDISCOMMON__ + +// TODO those defines are shared via syncd and sairedis + +#define SYNCD_INIT_VIEW "INIT_VIEW" +#define SYNCD_APPLY_VIEW "APPLY_VIEW" +#define SYNCD_INSPECT_ASIC "SYNCD_INSPECT_ASIC" +#define ASIC_STATE_TABLE "ASIC_STATE" +#define TEMP_PREFIX "TEMP_" + +// Messages for processing queries from libsairedis to syncd +#define STRING_ATTR_ENUM_VALUES_CAPABILITY_QUERY "attr_enum_values_capability_query" +#define STRING_ATTR_ENUM_VALUES_CAPABILITY_RESPONSE "attr_enum_values_capability_response" +#define STRING_OBJECT_TYPE_GET_AVAILABILITY_QUERY "object_type_get_availability_query" +#define STRING_OBJECT_TYPE_GET_AVAILABILITY_RESPONSE "object_type_get_availability_response" + +#endif // __SAIREDISCOMMON__ diff --git a/lib/src/sai_redis_fdb.cpp b/lib/src/sai_redis_fdb.cpp index 684a72d6241f..810a41e7f3f0 100644 --- a/lib/src/sai_redis_fdb.cpp +++ b/lib/src/sai_redis_fdb.cpp @@ -137,7 +137,7 @@ sai_status_t redis_dummy_create_fdb_entry( return SAI_STATUS_SUCCESS; } -sai_status_t sai_bulk_create_fdb_entry( +sai_status_t redis_bulk_create_fdb_entry( _In_ uint32_t object_count, _In_ const sai_fdb_entry_t *fdb_entry, _In_ const uint32_t *attr_count, @@ -251,7 +251,7 @@ sai_status_t sai_bulk_create_fdb_entry( object_statuses); } -sai_status_t sai_bulk_remove_fdb_entry( +sai_status_t redis_bulk_remove_fdb_entry( _In_ uint32_t object_count, _In_ const sai_fdb_entry_t *fdb_entry, _In_ sai_bulk_op_error_mode_t mode, diff --git a/lib/src/sai_redis_interfacequery.cpp b/lib/src/sai_redis_interfacequery.cpp index 31f8a5d80720..6481fae85508 100644 --- a/lib/src/sai_redis_interfacequery.cpp +++ b/lib/src/sai_redis_interfacequery.cpp @@ -1,5 +1,6 @@ #include "sai_redis.h" #include "sairedis.h" +#include "sairediscommon.h" #include "meta/sai_serialize.h" #include "meta/saiattributelist.h" @@ -308,7 +309,7 @@ sai_status_t sai_query_attribute_enum_values_capability( // This query will not put any data into the ASIC view, just into the // message queue - g_asicState->set(switch_id_str, query_arguments, attrEnumValuesCapabilityQuery); + g_asicState->set(switch_id_str, query_arguments, STRING_ATTR_ENUM_VALUES_CAPABILITY_QUERY); swss::Select callback; callback.addSelectable(g_redisGetConsumer.get()); @@ -333,7 +334,7 @@ sai_status_t sai_query_attribute_enum_values_capability( SWSS_LOG_DEBUG("Received response: op = %s, key = %s", message_type.c_str(), status_str.c_str()); // Ignore messages that are not in response to our query - if (message_type != attrEnumValuesCapabilityResponse) + if (message_type != STRING_ATTR_ENUM_VALUES_CAPABILITY_RESPONSE) { continue; } @@ -449,7 +450,7 @@ sai_status_t sai_object_type_get_availability( // This query will not put any data into the ASIC view, just into the // message queue - g_asicState->set(switch_id_str, query_arguments, objectTypeGetAvailabilityQuery); + g_asicState->set(switch_id_str, query_arguments, STRING_OBJECT_TYPE_GET_AVAILABILITY_QUERY); swss::Select callback; callback.addSelectable(g_redisGetConsumer.get()); @@ -474,7 +475,7 @@ sai_status_t sai_object_type_get_availability( SWSS_LOG_DEBUG("Received response: op = %s, key = %s", message_type.c_str(), status_str.c_str()); // Ignore messages that are not in response to our query - if (message_type != objectTypeGetAvailabilityResponse) + if (message_type != STRING_OBJECT_TYPE_GET_AVAILABILITY_RESPONSE) { continue; } diff --git a/lib/src/sai_redis_nexthopgroup.cpp b/lib/src/sai_redis_nexthopgroup.cpp index 44907cecca06..da9767cfad87 100644 --- a/lib/src/sai_redis_nexthopgroup.cpp +++ b/lib/src/sai_redis_nexthopgroup.cpp @@ -1,6 +1,6 @@ #include "sai_redis.h" -sai_status_t sai_bulk_create_next_hop_group_members( +sai_status_t redis_bulk_create_next_hop_group_members( _In_ sai_object_id_t switch_id, _In_ uint32_t object_count, _In_ const uint32_t *attr_count, @@ -23,7 +23,7 @@ sai_status_t sai_bulk_create_next_hop_group_members( object_statuses); } -sai_status_t sai_bulk_remove_next_hop_group_members( +sai_status_t redis_bulk_remove_next_hop_group_members( _In_ uint32_t object_count, _In_ const sai_object_id_t *object_id, _In_ sai_bulk_op_error_mode_t mode, @@ -48,6 +48,6 @@ const sai_next_hop_group_api_t redis_next_hop_group_api = { REDIS_GENERIC_QUAD_API(next_hop_group) REDIS_GENERIC_QUAD_API(next_hop_group_member) - sai_bulk_create_next_hop_group_members, - sai_bulk_remove_next_hop_group_members, + redis_bulk_create_next_hop_group_members, + redis_bulk_remove_next_hop_group_members, }; diff --git a/lib/src/sai_redis_route.cpp b/lib/src/sai_redis_route.cpp index 4121742fc5a0..fa454c6bf8c0 100644 --- a/lib/src/sai_redis_route.cpp +++ b/lib/src/sai_redis_route.cpp @@ -20,7 +20,7 @@ sai_status_t redis_dummy_create_route_entry( return SAI_STATUS_SUCCESS; } -sai_status_t sai_bulk_create_route_entry( +sai_status_t redis_bulk_create_route_entry( _In_ uint32_t object_count, _In_ const sai_route_entry_t *route_entry, _In_ const uint32_t *attr_count, @@ -149,7 +149,7 @@ sai_status_t redis_dummy_remove_route_entry( return SAI_STATUS_SUCCESS; } -sai_status_t sai_bulk_remove_route_entry( +sai_status_t redis_bulk_remove_route_entry( _In_ uint32_t object_count, _In_ const sai_route_entry_t *route_entry, _In_ sai_bulk_op_error_mode_t mode, @@ -252,7 +252,7 @@ sai_status_t redis_dummy_set_route_entry( return SAI_STATUS_SUCCESS; } -sai_status_t sai_bulk_set_route_entry_attribute( +sai_status_t redis_bulk_set_route_entry_attribute( _In_ uint32_t object_count, _In_ const sai_route_entry_t *route_entry, _In_ const sai_attribute_t *attr_list, @@ -355,7 +355,7 @@ sai_status_t sai_bulk_set_route_entry_attribute( object_statuses); } -sai_status_t sai_bulk_get_route_entry_attribute( +sai_status_t redis_bulk_get_route_entry_attribute( _In_ uint32_t object_count, _In_ const sai_route_entry_t *route_entry, _In_ const uint32_t *attr_count, @@ -376,8 +376,8 @@ 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, + redis_bulk_create_route_entry, + redis_bulk_remove_route_entry, + redis_bulk_set_route_entry_attribute, + redis_bulk_get_route_entry_attribute, }; diff --git a/lib/src/sai_redis_switch.cpp b/lib/src/sai_redis_switch.cpp index e1e8f8b15e99..0273ede2eb70 100644 --- a/lib/src/sai_redis_switch.cpp +++ b/lib/src/sai_redis_switch.cpp @@ -1,5 +1,6 @@ #include "sai_redis.h" #include "sairedis.h" +#include "sairediscommon.h" #include "meta/sai_serialize.h" diff --git a/saidump/saidump.cpp b/saidump/saidump.cpp index 428638e10046..cb2d83378d7b 100644 --- a/saidump/saidump.cpp +++ b/saidump/saidump.cpp @@ -9,7 +9,7 @@ extern "C" { #include "swss/table.h" #include "meta/sai_serialize.h" -#include "sairedis.h" +#include "sairediscommon.h" #include diff --git a/saiplayer/saiplayer.cpp b/saiplayer/saiplayer.cpp index bc678981cecd..b4a840242efe 100644 --- a/saiplayer/saiplayer.cpp +++ b/saiplayer/saiplayer.cpp @@ -12,6 +12,7 @@ extern "C" { #include "swss/logger.h" #include "swss/tokenize.h" #include "sairedis.h" +#include "sairediscommon.h" #include #include @@ -962,6 +963,10 @@ sai_status_t handle_bulk_route( { SWSS_LOG_ENTER(); + sai_route_api_t *route_api = NULL; + + sai_api_query(SAI_API_ROUTE, (void**)&route_api); + std::vector routes; for (size_t i = 0; i < object_ids.size(); ++i) @@ -980,7 +985,7 @@ sai_status_t handle_bulk_route( statuses.resize(recorded_statuses.size()); - if (api == (sai_common_api_t)SAI_COMMON_API_BULK_SET) + if (api == SAI_COMMON_API_BULK_SET) { /* * TODO: since SDK don't support bulk route api yet, we just use our @@ -1001,7 +1006,7 @@ sai_status_t handle_bulk_route( attrs.push_back(a->get_attr_list()[0]); } - sai_status_t status = sai_bulk_set_route_entry_attribute( + sai_status_t status = route_api->set_route_entries_attribute( (uint32_t)routes.size(), routes.data(), attrs.data(), @@ -1035,7 +1040,7 @@ sai_status_t handle_bulk_route( return status; } - else if (api == (sai_common_api_t)SAI_COMMON_API_BULK_CREATE) + else if (api == SAI_COMMON_API_BULK_CREATE) { std::vector attr_count; @@ -1050,7 +1055,7 @@ sai_status_t handle_bulk_route( SWSS_LOG_NOTICE("executing BULK route create with %zu routes", attr_count.size()); - sai_status_t status = sai_bulk_create_route_entry( + sai_status_t status = route_api->create_route_entries( (uint32_t)routes.size(), routes.data(), attr_count.data(), @@ -1100,8 +1105,8 @@ void processBulk( return; } - if (api != (sai_common_api_t)SAI_COMMON_API_BULK_SET && - api != (sai_common_api_t)SAI_COMMON_API_BULK_CREATE) + if (api != SAI_COMMON_API_BULK_SET && + api != SAI_COMMON_API_BULK_CREATE) { SWSS_LOG_THROW("bulk common api %d is not supported yet, FIXME", api); } @@ -1173,7 +1178,7 @@ void processBulk( uint32_t attr_count = list->get_attr_count(); - if (api != (sai_common_api_t)SAI_COMMON_API_BULK_GET) + if (api != SAI_COMMON_API_BULK_GET) { translate_local_to_redis(object_type, attr_count, attr_list); } @@ -1291,10 +1296,10 @@ int replay(int argc, char **argv) api = SAI_COMMON_API_SET; break; case 'S': - processBulk((sai_common_api_t)SAI_COMMON_API_BULK_SET, line); + processBulk(SAI_COMMON_API_BULK_SET, line); continue; case 'C': - processBulk((sai_common_api_t)SAI_COMMON_API_BULK_CREATE, line); + processBulk(SAI_COMMON_API_BULK_CREATE, line); continue; case 'g': api = SAI_COMMON_API_GET; diff --git a/syncd/syncd.cpp b/syncd/syncd.cpp index a69114e6ce57..fed18336e55b 100644 --- a/syncd/syncd.cpp +++ b/syncd/syncd.cpp @@ -1,6 +1,6 @@ #include "syncd.h" #include "syncd_saiswitch.h" -#include "sairedis.h" +#include "sairediscommon.h" #include "syncd_flex_counter.h" #include "swss/tokenize.h" #include @@ -2714,15 +2714,15 @@ sai_status_t handle_bulk_generic( SWSS_LOG_THROW("invalid object_type: %s", sai_serialize_object_type(object_type).c_str()); } - if (api == (sai_common_api_t)SAI_COMMON_API_BULK_SET) + if (api == SAI_COMMON_API_BULK_SET) { status = handle_non_object_id(meta_key, SAI_COMMON_API_SET, attr_count, attr_list); } - else if (api == (sai_common_api_t)SAI_COMMON_API_BULK_CREATE) + else if (api == SAI_COMMON_API_BULK_CREATE) { status = handle_non_object_id(meta_key, SAI_COMMON_API_CREATE, attr_count, attr_list); } - else if (api == (sai_common_api_t)SAI_COMMON_API_BULK_REMOVE) + else if (api == SAI_COMMON_API_BULK_REMOVE) { status = handle_non_object_id(meta_key, SAI_COMMON_API_REMOVE, attr_count, attr_list); } @@ -2906,7 +2906,7 @@ sai_status_t processAttrEnumValuesCapabilityQuery( if (values.size() != 3) { SWSS_LOG_ERROR("Invalid input: expected 3 arguments, received %zu", values.size()); - getResponse->set(sai_serialize_status(SAI_STATUS_INVALID_PARAMETER), {}, attrEnumValuesCapabilityResponse); + getResponse->set(sai_serialize_status(SAI_STATUS_INVALID_PARAMETER), {}, STRING_ATTR_ENUM_VALUES_CAPABILITY_RESPONSE); return SAI_STATUS_INVALID_PARAMETER; } @@ -2951,7 +2951,7 @@ sai_status_t processAttrEnumValuesCapabilityQuery( SWSS_LOG_DEBUG("Sending response: capabilities = '%s', count = %d", serialized_enum_capabilities.c_str(), enum_values_capability.count); } - getResponse->set(sai_serialize_status(status), response_payload, attrEnumValuesCapabilityResponse); + getResponse->set(sai_serialize_status(status), response_payload, STRING_ATTR_ENUM_VALUES_CAPABILITY_RESPONSE); return status; } @@ -3002,7 +3002,7 @@ sai_status_t processObjectTypeGetAvailabilityQuery( SWSS_LOG_DEBUG("Sending response: count = %lu", count); } - getResponse->set(sai_serialize_status(status), response_payload, objectTypeGetAvailabilityResponse); + getResponse->set(sai_serialize_status(status), response_payload, STRING_OBJECT_TYPE_GET_AVAILABILITY_RESPONSE); return status; } @@ -3072,15 +3072,15 @@ sai_status_t processEvent( } else if (op == "bulkset") { - return processBulkEvent((sai_common_api_t)SAI_COMMON_API_BULK_SET, kco); + return processBulkEvent(SAI_COMMON_API_BULK_SET, kco); } else if (op == "bulkcreate") { - return processBulkEvent((sai_common_api_t)SAI_COMMON_API_BULK_CREATE, kco); + return processBulkEvent(SAI_COMMON_API_BULK_CREATE, kco); } else if (op == "bulkremove") { - return processBulkEvent((sai_common_api_t)SAI_COMMON_API_BULK_REMOVE, kco); + return processBulkEvent(SAI_COMMON_API_BULK_REMOVE, kco); } else if (op == "notify") { @@ -3098,11 +3098,11 @@ sai_status_t processEvent( { return processFdbFlush(kco); } - else if (op == attrEnumValuesCapabilityQuery) + else if (op == STRING_ATTR_ENUM_VALUES_CAPABILITY_QUERY) { return processAttrEnumValuesCapabilityQuery(kco); } - else if (op == objectTypeGetAvailabilityQuery) + else if (op == STRING_OBJECT_TYPE_GET_AVAILABILITY_RESPONSE) { return processObjectTypeGetAvailabilityQuery(kco); } diff --git a/syncd/syncd_applyview.cpp b/syncd/syncd_applyview.cpp index 798d656b28c3..532f1d14be3b 100644 --- a/syncd/syncd_applyview.cpp +++ b/syncd/syncd_applyview.cpp @@ -1,5 +1,5 @@ #include "syncd.h" -#include "sairedis.h" +#include "sairediscommon.h" #include "swss/table.h" #include "swss/logger.h" #include "swss/dbconnector.h" diff --git a/syncd/syncd_hard_reinit.cpp b/syncd/syncd_hard_reinit.cpp index 22eab973f2cb..680be29d7573 100644 --- a/syncd/syncd_hard_reinit.cpp +++ b/syncd/syncd_hard_reinit.cpp @@ -1,5 +1,5 @@ #include "syncd.h" -#include "sairedis.h" +#include "sairediscommon.h" #include #include diff --git a/syncd/syncd_notifications.cpp b/syncd/syncd_notifications.cpp index 46426428432a..157245fdf3eb 100644 --- a/syncd/syncd_notifications.cpp +++ b/syncd/syncd_notifications.cpp @@ -1,5 +1,5 @@ #include "syncd.h" -#include "sairedis.h" +#include "sairediscommon.h" #include #include diff --git a/syncd/syncd_saiswitch.cpp b/syncd/syncd_saiswitch.cpp index 148d0469a857..6b77f6ae12fd 100644 --- a/syncd/syncd_saiswitch.cpp +++ b/syncd/syncd_saiswitch.cpp @@ -1,6 +1,6 @@ #include "syncd.h" #include "syncd_saiswitch.h" -#include "sairedis.h" +#include "sairediscommon.h" #include #include diff --git a/syncd/tests.cpp b/syncd/tests.cpp index cac9667f7740..34b97d4924c1 100644 --- a/syncd/tests.cpp +++ b/syncd/tests.cpp @@ -9,6 +9,7 @@ extern "C" { #include "swss/schema.h" #include "swss/redisreply.h" #include "sairedis.h" +#include "sairediscommon.h" #include "sai_redis.h" #include "meta/sai_serialize.h" #include "syncd.h" @@ -19,6 +20,21 @@ extern "C" { #include #include +// TODO remove when SAI will introduce bulk APIs to those objects +sai_status_t redis_bulk_create_fdb_entry( + _In_ uint32_t object_count, + _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_error_mode_t mode, + _Out_ sai_status_t *object_statuses); + +sai_status_t redis_bulk_remove_fdb_entry( + _In_ uint32_t object_count, + _In_ const sai_fdb_entry_t *fdb_entry, + _In_ sai_bulk_op_error_mode_t mode, + _Out_ sai_status_t *object_statuses); + #define ASSERT_SUCCESS(format,...) \ if ((status)!=SAI_STATUS_SUCCESS) \ SWSS_LOG_THROW(format ": %s", ##__VA_ARGS__, sai_serialize_status(status).c_str()); @@ -171,7 +187,7 @@ void bulk_nhgm_consumer_worker() if (op == "bulkcreate") { - sai_status_t status = processBulkEvent((sai_common_api_t)SAI_COMMON_API_BULK_CREATE, kco); + sai_status_t status = processBulkEvent(SAI_COMMON_API_BULK_CREATE, kco); ASSERT_SUCCESS("Failed to processBulkEvent"); break; } @@ -257,7 +273,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_ERROR_MODE_IGNORE_ERROR, object_id.data(), statuses.data()); + sai_next_hop_group_api->create_next_hop_group_members(switch_id, count, nhgm_attrs_count.data(), nhgm_attrs_array.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++) { @@ -277,7 +293,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_ERROR_MODE_IGNORE_ERROR, statuses.data()); + status = sai_next_hop_group_api->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"); } @@ -377,7 +393,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() + status = redis_bulk_create_fdb_entry(count, fdbs.data(), fdb_attrs_count.data(), fdb_attrs_array.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++) @@ -387,7 +403,7 @@ void test_bulk_fdb_create() } // Remove route entry - status = sai_bulk_remove_fdb_entry(count, fdbs.data(), SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, statuses.data()); + status = redis_bulk_remove_fdb_entry(count, fdbs.data(), SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, statuses.data()); ASSERT_SUCCESS("Failed to bulk remove route entry"); } @@ -476,7 +492,7 @@ void test_bulk_route_set() } std::vector statuses(count); - status = sai_bulk_create_route_entry(count, routes.data(), route_attrs_count.data(), route_attrs_array.data(), SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, statuses.data()); + status = sai_route_api->create_route_entries(count, routes.data(), route_attrs_count.data(), route_attrs_array.data(), SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, statuses.data()); ASSERT_SUCCESS("Failed to create route"); for (size_t j = 0; j < statuses.size(); j++) { @@ -505,7 +521,7 @@ void test_bulk_route_set() attr.value.s32 = SAI_PACKET_ACTION_FORWARD; } - status = sai_bulk_set_route_entry_attribute( + status = sai_route_api->set_route_entries_attribute( count, routes.data(), attrs.data(), @@ -525,7 +541,7 @@ void test_bulk_route_set() // if after consume we get pop we get expected parameters // Remove route entry - status = sai_bulk_remove_route_entry(count, routes.data(), SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, statuses.data()); + status = sai_route_api->remove_route_entries(count, routes.data(), SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, statuses.data()); ASSERT_SUCCESS("Failed to bulk remove route entry"); }