Skip to content

Commit b0ee63d

Browse files
authored
[syncd] [vs] [sairedis] Add support for bulk api in init view (sonic-net#591)
* [syncd] [vs] [sairedis] Add support for bulk api in init view * Fix spelling
1 parent 48ef314 commit b0ee63d

File tree

9 files changed

+302
-25
lines changed

9 files changed

+302
-25
lines changed

lib/src/Makefile.am

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ endif
88

99
lib_LTLIBRARIES = libsairedis.la
1010

11-
libsairedis_la_SOURCES = \
11+
noinst_LIBRARIES = libSaiRedis.a
12+
libSaiRedis_a_SOURCES = \
1213
Context.cpp \
1314
ContextConfigContainer.cpp \
1415
ContextConfig.cpp \
@@ -31,7 +32,9 @@ libsairedis_la_SOURCES = \
3132
Recorder.cpp \
3233
RedisRemoteSaiInterface.cpp \
3334
Utils.cpp \
34-
SkipRecordAttrContainer.cpp \
35+
SkipRecordAttrContainer.cpp
36+
37+
libsairedis_la_SOURCES = \
3538
sai_redis_acl.cpp \
3639
sai_redis_bfd.cpp \
3740
sai_redis_bmtor.cpp \
@@ -77,9 +80,10 @@ libsairedis_la_SOURCES = \
7780
sai_redis_vlan.cpp \
7881
sai_redis_wred.cpp
7982

83+
libSaiRedis_a_CPPFLAGS = $(DBGFLAGS) $(AM_CPPFLAGS) $(CFLAGS_COMMON)
8084

8185
libsairedis_la_CPPFLAGS = $(DBGFLAGS) $(AM_CPPFLAGS) $(CFLAGS_COMMON)
82-
libsairedis_la_LIBADD = -lhiredis -lswsscommon
86+
libsairedis_la_LIBADD = -lhiredis -lswsscommon libSaiRedis.a
8387

8488

8589
bin_PROGRAMS = tests

lib/src/RedisRemoteSaiInterface.cpp

+17-2
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,8 @@ sai_status_t RedisRemoteSaiInterface::bulkRemove(
10641064
// value: object_attrs
10651065
std::string key = serializedObjectType + ":" + std::to_string(entries.size());
10661066

1067+
m_recorder->recordBulkGenericRemove(serializedObjectType, entries);
1068+
10671069
m_redisChannel->set(key, entries, REDIS_ASIC_STATE_COMMAND_BULK_REMOVE);
10681070

10691071
return waitForBulkResponse(SAI_COMMON_API_BULK_REMOVE, (uint32_t)serialized_object_ids.size(), object_statuses);
@@ -1291,7 +1293,11 @@ sai_status_t RedisRemoteSaiInterface::bulkSet(
12911293
* with previous
12921294
*/
12931295

1294-
std::string key = sai_serialize_object_type(object_type) + ":" + std::to_string(entries.size());
1296+
auto serializedObjectType = sai_serialize_object_type(object_type);
1297+
1298+
std::string key = serializedObjectType + ":" + std::to_string(entries.size());
1299+
1300+
m_recorder->recordBulkGenericSet(serializedObjectType, entries);
12951301

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

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

1373+
if (entry.empty())
1374+
{
1375+
// make sure that we put object into db
1376+
// even if there are no attributes set
1377+
swss::FieldValueTuple null("NULL", "NULL");
1378+
1379+
entry.push_back(null);
1380+
}
1381+
13671382
std::string str_attr = joinFieldValues(entry);
13681383

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

1384-
// TODO record
1399+
m_recorder->recordBulkGenericCreate(str_object_type, entries);
13851400

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

syncd/Syncd.cpp

+53-6
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,6 @@ sai_status_t Syncd::processBulkQuadEvent(
573573
{
574574
SWSS_LOG_ENTER();
575575

576-
if (isInitViewMode())
577-
{
578-
SWSS_LOG_THROW("bulk api (%s) is not supported in init view mode, FIXME",
579-
sai_serialize_common_api(api).c_str());
580-
}
581-
582576
const std::string& key = kfvKey(kco); // objectType:count
583577

584578
std::string strObjectType = key.substr(0, key.find(":"));
@@ -644,6 +638,11 @@ sai_status_t Syncd::processBulkQuadEvent(
644638
}
645639
}
646640

641+
if (isInitViewMode())
642+
{
643+
return processBulkQuadEventInInitViewMode(objectType, objectIds, api, attributes);
644+
}
645+
647646
auto info = sai_metadata_get_object_type_info(objectType);
648647

649648
if (info->isobjectid)
@@ -656,6 +655,54 @@ sai_status_t Syncd::processBulkQuadEvent(
656655
}
657656
}
658657

658+
sai_status_t Syncd::processBulkQuadEventInInitViewMode(
659+
_In_ sai_object_type_t objectType,
660+
_In_ const std::vector<std::string> &object_ids,
661+
_In_ sai_common_api_t api,
662+
_In_ const std::vector<std::shared_ptr<saimeta::SaiAttributeList>> &attributes)
663+
{
664+
SWSS_LOG_ENTER();
665+
666+
auto info = sai_metadata_get_object_type_info(objectType);
667+
668+
switch (api)
669+
{
670+
case SAI_COMMON_API_BULK_CREATE:
671+
case SAI_COMMON_API_BULK_REMOVE:
672+
case SAI_COMMON_API_BULK_SET:
673+
674+
if (info->isnonobjectid)
675+
{
676+
sendApiResponse(api, SAI_STATUS_SUCCESS);
677+
return SAI_STATUS_SUCCESS;
678+
}
679+
680+
switch (objectType)
681+
{
682+
case SAI_OBJECT_TYPE_SWITCH:
683+
case SAI_OBJECT_TYPE_PORT:
684+
case SAI_OBJECT_TYPE_SCHEDULER_GROUP:
685+
case SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP:
686+
687+
SWSS_LOG_THROW("%s is not supported in init view mode",
688+
sai_serialize_object_type(objectType).c_str());
689+
690+
default:
691+
692+
sendApiResponse(api, SAI_STATUS_SUCCESS);
693+
return SAI_STATUS_SUCCESS;
694+
}
695+
696+
case SAI_COMMON_API_BULK_GET:
697+
SWSS_LOG_THROW("GET bulk api is not implemented in init view mode, FIXME");
698+
699+
default:
700+
701+
SWSS_LOG_THROW("common bulk api (%s) is not implemented in init view mode",
702+
sai_serialize_common_api(api).c_str());
703+
}
704+
}
705+
659706
sai_status_t Syncd::processBulkEntry(
660707
_In_ sai_object_type_t objectType,
661708
_In_ const std::vector<std::string> &objectIds,

syncd/Syncd.h

+6
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ namespace syncd
155155
_In_ sai_common_api_t api,
156156
_In_ const std::vector<std::shared_ptr<saimeta::SaiAttributeList>> &attributes);
157157

158+
sai_status_t processBulkQuadEventInInitViewMode(
159+
_In_ sai_object_type_t objectType,
160+
_In_ const std::vector<std::string> &object_ids,
161+
_In_ sai_common_api_t api,
162+
_In_ const std::vector<std::shared_ptr<saimeta::SaiAttributeList>> &attributes);
163+
158164
sai_status_t processOid(
159165
_In_ sai_object_type_t objectType,
160166
_In_ const std::string &strObjectId,

syncd/TimerWatchdog.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef __TIMER_WATCHDOG_H__
2-
#define __TIMER_WATCHDOG_H__
1+
#pragma once
32

43
#include <thread>
54
#include <atomic>
@@ -56,5 +55,3 @@ class TimerWatchdog
5655
Callback m_callback;
5756

5857
};
59-
60-
#endif // __TIMER_WATCHDOG_H__

syncd/lanemap.ini

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

syncd/testprofile.ini

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SAI_WARM_BOOT_READ_FILE=./sai_warmboot.bin
2+
SAI_WARM_BOOT_WRITE_FILE=./sai_warmboot.bin
3+
SAI_VS_SWITCH_TYPE=SAI_VS_SWITCH_TYPE_BCM56850
4+
SAI_VS_INTERFACE_LANE_MAP_FILE=lanemap.ini

0 commit comments

Comments
 (0)