Skip to content

Commit

Permalink
[syncd] [vs] [sairedis] Add support for bulk api in init view (sonic-…
Browse files Browse the repository at this point in the history
…net#591)

* [syncd] [vs] [sairedis] Add support for bulk api in init view

* Fix spelling
  • Loading branch information
kcudnik authored Apr 8, 2020
1 parent 48ef314 commit b0ee63d
Show file tree
Hide file tree
Showing 9 changed files with 302 additions and 25 deletions.
10 changes: 7 additions & 3 deletions lib/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ endif

lib_LTLIBRARIES = libsairedis.la

libsairedis_la_SOURCES = \
noinst_LIBRARIES = libSaiRedis.a
libSaiRedis_a_SOURCES = \
Context.cpp \
ContextConfigContainer.cpp \
ContextConfig.cpp \
Expand All @@ -31,7 +32,9 @@ libsairedis_la_SOURCES = \
Recorder.cpp \
RedisRemoteSaiInterface.cpp \
Utils.cpp \
SkipRecordAttrContainer.cpp \
SkipRecordAttrContainer.cpp

libsairedis_la_SOURCES = \
sai_redis_acl.cpp \
sai_redis_bfd.cpp \
sai_redis_bmtor.cpp \
Expand Down Expand Up @@ -77,9 +80,10 @@ libsairedis_la_SOURCES = \
sai_redis_vlan.cpp \
sai_redis_wred.cpp

libSaiRedis_a_CPPFLAGS = $(DBGFLAGS) $(AM_CPPFLAGS) $(CFLAGS_COMMON)

libsairedis_la_CPPFLAGS = $(DBGFLAGS) $(AM_CPPFLAGS) $(CFLAGS_COMMON)
libsairedis_la_LIBADD = -lhiredis -lswsscommon
libsairedis_la_LIBADD = -lhiredis -lswsscommon libSaiRedis.a


bin_PROGRAMS = tests
Expand Down
19 changes: 17 additions & 2 deletions lib/src/RedisRemoteSaiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,8 @@ sai_status_t RedisRemoteSaiInterface::bulkRemove(
// value: object_attrs
std::string key = serializedObjectType + ":" + std::to_string(entries.size());

m_recorder->recordBulkGenericRemove(serializedObjectType, entries);

m_redisChannel->set(key, entries, REDIS_ASIC_STATE_COMMAND_BULK_REMOVE);

return waitForBulkResponse(SAI_COMMON_API_BULK_REMOVE, (uint32_t)serialized_object_ids.size(), object_statuses);
Expand Down Expand Up @@ -1291,7 +1293,11 @@ sai_status_t RedisRemoteSaiInterface::bulkSet(
* with previous
*/

std::string key = sai_serialize_object_type(object_type) + ":" + std::to_string(entries.size());
auto serializedObjectType = sai_serialize_object_type(object_type);

std::string key = serializedObjectType + ":" + std::to_string(entries.size());

m_recorder->recordBulkGenericSet(serializedObjectType, entries);

m_redisChannel->set(key, entries, REDIS_ASIC_STATE_COMMAND_BULK_SET);

Expand Down Expand Up @@ -1364,6 +1370,15 @@ sai_status_t RedisRemoteSaiInterface::bulkCreate(
{
auto entry = SaiAttributeList::serialize_attr_list(object_type, attr_count[idx], attr_list[idx], false);

if (entry.empty())
{
// make sure that we put object into db
// even if there are no attributes set
swss::FieldValueTuple null("NULL", "NULL");

entry.push_back(null);
}

std::string str_attr = joinFieldValues(entry);

swss::FieldValueTuple fvtNoStatus(serialized_object_ids[idx] , str_attr);
Expand All @@ -1381,7 +1396,7 @@ sai_status_t RedisRemoteSaiInterface::bulkCreate(
// value: object_attrs
std::string key = str_object_type + ":" + std::to_string(entries.size());

// TODO record
m_recorder->recordBulkGenericCreate(str_object_type, entries);

m_redisChannel->set(key, entries, REDIS_ASIC_STATE_COMMAND_BULK_CREATE);

Expand Down
59 changes: 53 additions & 6 deletions syncd/Syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,12 +573,6 @@ sai_status_t Syncd::processBulkQuadEvent(
{
SWSS_LOG_ENTER();

if (isInitViewMode())
{
SWSS_LOG_THROW("bulk api (%s) is not supported in init view mode, FIXME",
sai_serialize_common_api(api).c_str());
}

const std::string& key = kfvKey(kco); // objectType:count

std::string strObjectType = key.substr(0, key.find(":"));
Expand Down Expand Up @@ -644,6 +638,11 @@ sai_status_t Syncd::processBulkQuadEvent(
}
}

if (isInitViewMode())
{
return processBulkQuadEventInInitViewMode(objectType, objectIds, api, attributes);
}

auto info = sai_metadata_get_object_type_info(objectType);

if (info->isobjectid)
Expand All @@ -656,6 +655,54 @@ sai_status_t Syncd::processBulkQuadEvent(
}
}

sai_status_t Syncd::processBulkQuadEventInInitViewMode(
_In_ sai_object_type_t objectType,
_In_ const std::vector<std::string> &object_ids,
_In_ sai_common_api_t api,
_In_ const std::vector<std::shared_ptr<saimeta::SaiAttributeList>> &attributes)
{
SWSS_LOG_ENTER();

auto info = sai_metadata_get_object_type_info(objectType);

switch (api)
{
case SAI_COMMON_API_BULK_CREATE:
case SAI_COMMON_API_BULK_REMOVE:
case SAI_COMMON_API_BULK_SET:

if (info->isnonobjectid)
{
sendApiResponse(api, SAI_STATUS_SUCCESS);
return SAI_STATUS_SUCCESS;
}

switch (objectType)
{
case SAI_OBJECT_TYPE_SWITCH:
case SAI_OBJECT_TYPE_PORT:
case SAI_OBJECT_TYPE_SCHEDULER_GROUP:
case SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP:

SWSS_LOG_THROW("%s is not supported in init view mode",
sai_serialize_object_type(objectType).c_str());

default:

sendApiResponse(api, SAI_STATUS_SUCCESS);
return SAI_STATUS_SUCCESS;
}

case SAI_COMMON_API_BULK_GET:
SWSS_LOG_THROW("GET bulk api is not implemented in init view mode, FIXME");

default:

SWSS_LOG_THROW("common bulk api (%s) is not implemented in init view mode",
sai_serialize_common_api(api).c_str());
}
}

sai_status_t Syncd::processBulkEntry(
_In_ sai_object_type_t objectType,
_In_ const std::vector<std::string> &objectIds,
Expand Down
6 changes: 6 additions & 0 deletions syncd/Syncd.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ namespace syncd
_In_ sai_common_api_t api,
_In_ const std::vector<std::shared_ptr<saimeta::SaiAttributeList>> &attributes);

sai_status_t processBulkQuadEventInInitViewMode(
_In_ sai_object_type_t objectType,
_In_ const std::vector<std::string> &object_ids,
_In_ sai_common_api_t api,
_In_ const std::vector<std::shared_ptr<saimeta::SaiAttributeList>> &attributes);

sai_status_t processOid(
_In_ sai_object_type_t objectType,
_In_ const std::string &strObjectId,
Expand Down
5 changes: 1 addition & 4 deletions syncd/TimerWatchdog.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __TIMER_WATCHDOG_H__
#define __TIMER_WATCHDOG_H__
#pragma once

#include <thread>
#include <atomic>
Expand Down Expand Up @@ -56,5 +55,3 @@ class TimerWatchdog
Callback m_callback;

};

#endif // __TIMER_WATCHDOG_H__
34 changes: 34 additions & 0 deletions syncd/lanemap.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
; comment
# comment
eth0:29,30,31,32
eth1:25,26,27,28
eth2:37,38,39,40
eth3:33,34,35,36
eth4:41,42,43,44
eth5:45,46,47,48
eth6:5,6,7,8
eth7:1,2,3,4
eth8:9,10,11,12
eth9:13,14,15,16
eth10:21,22,23,24
eth11:17,18,19,20
eth12:249,50,51,52
eth13:353,54,55,56
eth14:461,62,63,64
eth15:557,58,59,60
eth16:665,66,67,68
eth17:769,70,71,72
eth18:877,78,79,80
eth19:973,74,75,76
eth20:105,106,107,108
eth21:109,110,111,112
eth22:117,118,119,120
eth23:113,114,115,116
eth24:121,122,123,124
eth25:125,126,127,128
eth26:85,86,87,88
eth27:81,82,83,84
eth28:89,90,91,92
eth29:93,94,95,96
eth30:97,98,99,100
eth31:101,102,103,104
4 changes: 4 additions & 0 deletions syncd/testprofile.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SAI_WARM_BOOT_READ_FILE=./sai_warmboot.bin
SAI_WARM_BOOT_WRITE_FILE=./sai_warmboot.bin
SAI_VS_SWITCH_TYPE=SAI_VS_SWITCH_TYPE_BCM56850
SAI_VS_INTERFACE_LANE_MAP_FILE=lanemap.ini
Loading

0 comments on commit b0ee63d

Please sign in to comment.