Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[syncd] Implement bulk set support #1422

Merged
merged 11 commits into from
Dec 10, 2024
59 changes: 59 additions & 0 deletions syncd/Syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,61 @@ sai_status_t Syncd::processBulkOidCreate(
return status;
}

sai_status_t Syncd::processBulkOidSet(
_In_ sai_object_type_t objectType,
_In_ sai_bulk_op_error_mode_t mode,
_In_ const std::vector<std::string>& objectIds,
_In_ const std::vector<std::shared_ptr<saimeta::SaiAttributeList>>& attributes,
_Out_ std::vector<sai_status_t>& statuses)
{
SWSS_LOG_ENTER();

sai_status_t status = SAI_STATUS_SUCCESS;
uint32_t object_count = static_cast<uint32_t>(objectIds.size());

if (!object_count)
{
SWSS_LOG_ERROR("container with objectIds is empty in processBulkOidSet");
return SAI_STATUS_FAILURE;
}

std::vector<sai_object_id_t> objectVids(object_count);
std::vector<sai_object_id_t> objectRids(object_count);

std::vector<sai_attribute_t> attr_list(object_count);

for (size_t idx = 0; idx < object_count; idx++)
{
sai_deserialize_object_id(objectIds[idx], objectVids[idx]);
objectRids[idx] = m_translator->translateVidToRid(objectVids[idx]);

const auto attr_count = attributes[idx]->get_attr_count();
if (attr_count != 1)
{
SWSS_LOG_THROW("bulkSet api requires one attribute per object");
}

attr_list[idx] = *attributes[idx]->get_attr_list();
}

status = m_vendorSai->bulkSet(
objectType,
object_count,
objectRids.data(),
attr_list.data(),
mode,
statuses.data());

if (status == SAI_STATUS_NOT_IMPLEMENTED || status == SAI_STATUS_NOT_SUPPORTED)
{
SWSS_LOG_ERROR("bulkSet api is not implemented or not supported, object_type = %s",
sai_serialize_object_type(objectType).c_str());
return status;
kcudnik marked this conversation as resolved.
Show resolved Hide resolved
}

return status;
}

sai_status_t Syncd::processBulkOidRemove(
_In_ sai_object_type_t objectType,
_In_ sai_bulk_op_error_mode_t mode,
Expand Down Expand Up @@ -2113,6 +2168,10 @@ sai_status_t Syncd::processBulkOid(
all = processBulkOidCreate(objectType, mode, objectIds, attributes, statuses);
break;

case SAI_COMMON_API_BULK_SET:
all = processBulkOidSet(objectType, mode, objectIds, attributes, statuses);
break;

case SAI_COMMON_API_BULK_REMOVE:
all = processBulkOidRemove(objectType, mode, objectIds, statuses);
break;
Expand Down
7 changes: 7 additions & 0 deletions syncd/Syncd.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ namespace syncd
_In_ const std::vector<std::shared_ptr<saimeta::SaiAttributeList>>& attributes,
_Out_ std::vector<sai_status_t>& statuses);

sai_status_t processBulkOidSet(
_In_ sai_object_type_t objectType,
_In_ sai_bulk_op_error_mode_t mode,
_In_ const std::vector<std::string>& objectIds,
_In_ const std::vector<std::shared_ptr<saimeta::SaiAttributeList>>& attributes,
_Out_ std::vector<sai_status_t>& statuses);

sai_status_t processBulkOidRemove(
_In_ sai_object_type_t objectType,
_In_ sai_bulk_op_error_mode_t mode,
Expand Down
37 changes: 35 additions & 2 deletions syncd/VendorSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,42 @@ sai_status_t VendorSai::bulkSet(
SWSS_LOG_ENTER();
VENDOR_CHECK_API_INITIALIZED();

SWSS_LOG_ERROR("not supported by SAI");
sai_bulk_object_set_attribute_fn ptr;

return SAI_STATUS_NOT_SUPPORTED;
switch (object_type)
{
case SAI_OBJECT_TYPE_PORT:
ptr = m_apis.port_api->set_ports_attribute;
break;

case SAI_OBJECT_TYPE_NEXT_HOP:
ptr = m_apis.next_hop_api->set_next_hops_attribute;
break;

case SAI_OBJECT_TYPE_TUNNEL:
ptr = m_apis.tunnel_api->set_tunnels_attribute;
break;

case SAI_OBJECT_TYPE_NEXT_HOP_GROUP_MEMBER:
ptr = m_apis.next_hop_group_api->set_next_hop_group_members_attribute;
break;

default:
SWSS_LOG_ERROR("not implemented %s, FIXME", sai_serialize_object_type(object_type).c_str());
return SAI_STATUS_NOT_IMPLEMENTED;
}

if (!ptr)
{
SWSS_LOG_INFO("create bulk not supported from SAI, object_type = %s", sai_serialize_object_type(object_type).c_str());
return SAI_STATUS_NOT_SUPPORTED;
}

return ptr(object_count,
object_id,
attr_list,
mode,
object_statuses);
}

sai_status_t VendorSai::bulkGet(
Expand Down
10 changes: 9 additions & 1 deletion tests/BCM56850.pl
Original file line number Diff line number Diff line change
Expand Up @@ -594,13 +594,20 @@ sub test_bulk_fdb
play "bulk_fdb.rec"
}

sub test_bulk_object
sub test_emulated_bulk_object
{
fresh_start;

play "bulk_object.rec"
}

sub test_bulk_object
{
fresh_start_bulk;

play "bulk_object.rec"
}

sub test_depreacated_enums
{
fresh_start;
Expand Down Expand Up @@ -871,6 +878,7 @@ sub test_acl_pre_match_999
test_bulk_route;
test_bulk_neighbor;
test_bulk_fdb;
test_emulated_bulk_object;
test_bulk_object;
test_brcm_config_acl;
test_brcm_warm_wred_queue;
Expand Down
3 changes: 3 additions & 0 deletions tests/BCM56850/bulk_object.rec
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
2017-06-14.01:55:46.543987|a|INIT_VIEW
2017-06-14.01:55:46.551164|A|SAI_STATUS_SUCCESS
2017-06-14.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
2018-11-05.23:55:47.743415|g|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_PORT_LIST=32:oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0
2018-11-05.23:55:47.749126|G|SAI_STATUS_SUCCESS|SAI_SWITCH_ATTR_PORT_LIST=32:oid:0x1000000000002,oid:0x1000000000003,oid:0x1000000000004,oid:0x1000000000005,oid:0x1000000000006,oid:0x1000000000007,oid:0x1000000000008,oid:0x1000000000009,oid:0x100000000000a,oid:0x100000000000b,oid:0x100000000000c,oid:0x100000000000d,oid:0x100000000000e,oid:0x100000000000f,oid:0x1000000000010,oid:0x1000000000011,oid:0x1000000000012,oid:0x1000000000013,oid:0x1000000000014,oid:0x1000000000015,oid:0x1000000000016,oid:0x1000000000017,oid:0x1000000000018,oid:0x1000000000019,oid:0x100000000001a,oid:0x100000000001b,oid:0x100000000001c,oid:0x100000000001d,oid:0x100000000001e,oid:0x100000000001f,oid:0x1000000000020,oid:0x1000000000021
2017-06-14.01:55:56.555975|S|SAI_OBJECT_TYPE_PORT||oid:0x1000000000002|SAI_PORT_ATTR_ADMIN_STATE=true||oid:0x1000000000003|SAI_PORT_ATTR_ADMIN_STATE=false||oid:0x1000000000004|SAI_PORT_ATTR_ADMIN_STATE=true
2017-06-14.01:55:56.555975|C|SAI_OBJECT_TYPE_NEXT_HOP_GROUP||oid:0x5000000000005|SAI_NEXT_HOP_GROUP_ATTR_TYPE=SAI_NEXT_HOP_GROUP_TYPE_DYNAMIC_UNORDERED_ECMP||oid:0x5000000000006|SAI_NEXT_HOP_GROUP_ATTR_TYPE=SAI_NEXT_HOP_GROUP_TYPE_DYNAMIC_UNORDERED_ECMP||oid:0x5000000000007|SAI_NEXT_HOP_GROUP_ATTR_TYPE=SAI_NEXT_HOP_GROUP_TYPE_DYNAMIC_UNORDERED_ECMP
2017-06-14.01:55:56.555975|S|SAI_OBJECT_TYPE_NEXT_HOP_GROUP||oid:0x5000000000005|SAI_NEXT_HOP_GROUP_ATTR_SET_SWITCHOVER=true||oid:0x5000000000006|SAI_NEXT_HOP_GROUP_ATTR_SET_SWITCHOVER=true||oid:0x5000000000007|SAI_NEXT_HOP_GROUP_ATTR_SET_SWITCHOVER=true
2017-06-14.01:55:56.555975|R|SAI_OBJECT_TYPE_NEXT_HOP_GROUP||oid:0x5000000000005||oid:0x5000000000006||oid:0x5000000000007
Expand Down
Loading