Skip to content

Commit

Permalink
Add scheduler groups support to virtual switch (sonic-net#132)
Browse files Browse the repository at this point in the history
* Add scheduler groups support to virtual switch

* Fix bug in transfer list

* Address comments

* Addressing comments

* Fix Makefile

* Fix tests in sairedis
  • Loading branch information
kcudnik authored Dec 2, 2016
1 parent 96bcb63 commit e90bf4f
Show file tree
Hide file tree
Showing 15 changed files with 438 additions and 61 deletions.
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ AC_ARG_WITH(sai,
bcm) sai=bcm ;;
mlnx) sai=mlnx ;;
cavm) sai=cavm ;;
vs) sai=vs ;;
*) AC_MSG_ERROR(bad value ${withval} for --with-sai) ;;
esac])
AM_CONDITIONAL(SAIBCM, test x$sai = xbcm)
AM_CONDITIONAL(SAIMLNX, test x$sai = xmlnx)
AM_CONDITIONAL(SAICAVM, test x$sai = xcavm)
AM_CONDITIONAL(SAIVS, test x$sai = xvs)

AC_ARG_ENABLE(rpcserver,
[ --enable-rpcserver Compile with thrift rpcserver included],
Expand Down
2 changes: 2 additions & 0 deletions lib/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ bin_PROGRAMS = tests
tests_SOURCES = tests.cpp
tests_CPPFLAGS = $(DBGFLAGS) $(AM_CPPFLAGS) $(CFLAGS_COMMON)
tests_LDADD = -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/lib/src/.libs -lsairedis -L$(top_srcdir)/meta/.libs -lsaimetadata

TESTS = tests
10 changes: 8 additions & 2 deletions lib/src/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,19 @@ service_method_table_t test_services = {
profile_get_next_value
};

void test_sai_linking()
{
// NOTE: this is just testing whether test application will
// link against libsairedis, this api requires running redis db
// with enabled unix socket
sai_api_initialize(0, (service_method_table_t*)&test_services);
}

int main()
{
swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_DEBUG);

SWSS_LOG_ENTER();

sai_api_initialize(0, (service_method_table_t*)&test_services);

return 0;
}
3 changes: 2 additions & 1 deletion meta/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ bin_PROGRAMS = tests

tests_SOURCES = tests.cpp
tests_CPPFLAGS = $(DBGFLAGS) $(AM_CPPFLAGS) $(CFLAGS_COMMON)
tests_LDADD = -lhiredis -lswsscommon -lsai -lpthread -L$(top_dir)/meta/.libs -lsaimetadata
tests_LDADD = -lhiredis -lswsscommon -lpthread -L$(top_dir)/meta/.libs -lsaimetadata

TESTS = tests
#.PHONY: runtests
#
#runtests:
Expand Down
6 changes: 6 additions & 0 deletions meta/saiserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ sai_status_t transfer_list(

if (dst_element.count >= src_element.count)
{
if (src_element.list == NULL && src_element.count > 0)
{
SWSS_LOG_ERROR("source list is NULL when count is %u, wrong db insert?", src_element.count);
throw std::runtime_error("source list is NULL when count is not zero, wrong db insert?");
}

transfer_primitive(src_element.count, dst_element.count);

for (size_t i = 0; i < src_element.count; i++)
Expand Down
3 changes: 2 additions & 1 deletion meta/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,9 @@ void test_fdb_entry_create()
status = meta_sai_create_fdb_entry(&fdb_entry, 4, list1, &dummy_success_sai_create_fdb_entry);
META_ASSERT_FAIL(status);

// packet action is now optional
SWSS_LOG_NOTICE("missing mandatory attribute");
status = meta_sai_create_fdb_entry(&fdb_entry, 2, list1, &dummy_success_sai_create_fdb_entry);
status = meta_sai_create_fdb_entry(&fdb_entry, 1, list1, &dummy_success_sai_create_fdb_entry);
META_ASSERT_FAIL(status);

attr2.value.oid = create_dummy_object_id(SAI_OBJECT_TYPE_HASH);
Expand Down
2 changes: 2 additions & 0 deletions saiplayer/saiplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,8 @@ void handle_get_response(
SWSS_LOG_DEBUG("list match");

match_redis_with_rec(object_type, get_attr_count, get_attr_list, attr_count, attr_list);

// TODO primitive values are not matched (recording vs switch/vs), we can add that check
}

void performSleep(const std::string& line)
Expand Down
8 changes: 7 additions & 1 deletion syncd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ if SAICAVM
SAIFLAGS = -DCAVMSAI
endif

if SAIVS
SAILIB=-L$(top_srcdir)/vslib/src/.libs -lsaivs
else
SAILIB=-lsai
endif

syncd_SOURCES = \
syncd.cpp \
syncd_cli.cpp \
Expand All @@ -30,7 +36,7 @@ syncd_SOURCES = \
syncd_counters.cpp

syncd_CPPFLAGS = $(DBGFLAGS) $(AM_CPPFLAGS) $(CFLAGS_COMMON) $(SAIFLAGS)
syncd_LDADD = -lhiredis -lswsscommon -lsai -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata
syncd_LDADD = -lhiredis -lswsscommon $(SAILIB) -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata

if SAITHRIFT
SAI_RPC_INCLUDE_DIR = ../libsaiserver/include
Expand Down
2 changes: 1 addition & 1 deletion syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ sai_status_t handle_generic(

if (create == NULL)
{
SWSS_LOG_ERROR("create function is not defined for object type %x", object_type);
SWSS_LOG_ERROR("create function is not defined for object type %s", sai_serialize_object_type(object_type).c_str());
exit_and_notify(EXIT_FAILURE);
}

Expand Down
4 changes: 2 additions & 2 deletions syncd/syncd_hard_reinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ void trapGroupWorkaround(

if (create == NULL)
{
SWSS_LOG_ERROR("create function is not defined for object type %llx", objectType);
SWSS_LOG_ERROR("create function is not defined for object type %s", sai_serialize_object_type(objectType).c_str());

exit_and_notify(EXIT_FAILURE);
}
Expand Down Expand Up @@ -477,7 +477,7 @@ sai_object_id_t processSingleVid(sai_object_id_t vid)

if (create == NULL)
{
SWSS_LOG_ERROR("create function is not defined for object type %llx", objectType);
SWSS_LOG_ERROR("create function is not defined for object type %s", sai_serialize_object_type(objectType).c_str());

exit_and_notify(EXIT_FAILURE);
}
Expand Down
2 changes: 2 additions & 0 deletions vslib/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ bin_PROGRAMS = tests
tests_SOURCES = tests.cpp
tests_CPPFLAGS = $(DBGFLAGS) $(AM_CPPFLAGS) $(CFLAGS_COMMON)
tests_LDADD = -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/vslib/src/.libs -lsaivs -L$(top_srcdir)/meta/.libs -lsaimetadata

TESTS = tests
11 changes: 4 additions & 7 deletions vslib/src/sai_vs_generic_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ ObjectHash g_objectHash;

uint64_t real_ids[SAI_OBJECT_TYPE_MAX];

#define VS_OID_FLAG 0x8000000000000000

void reset_id_counter()
{
SWSS_LOG_ENTER();
Expand All @@ -30,18 +28,17 @@ sai_object_id_t vs_create_real_object_id(
// count from zero for each type separetly
uint64_t real_id = real_ids[object_type]++;

sai_object_id_t object_id = (((sai_object_id_t)object_type) << 48) | real_id | VS_OID_FLAG;
sai_object_id_t object_id = (((sai_object_id_t)object_type) << 32) | real_id;

SWSS_LOG_DEBUG("created RID %llx", object_id);

return object_id;
}

sai_object_type_t sai_object_type_query(_In_ sai_object_id_t object_id)
sai_object_type_t sai_object_type_query(
_In_ sai_object_id_t object_id)
{
object_id = object_id & ~VS_OID_FLAG;

sai_object_type_t object_type = (sai_object_type_t)(object_id >> 48);
sai_object_type_t object_type = (sai_object_type_t)(object_id >> 32);

if (object_type <= SAI_OBJECT_TYPE_NULL ||
object_type >= SAI_OBJECT_TYPE_MAX)
Expand Down
4 changes: 2 additions & 2 deletions vslib/src/sai_vs_generic_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ sai_status_t internal_vs_generic_get(

if (ait == attrHash.end())
{
SWSS_LOG_ERROR("Get failed, attribute not found, object type: %d: id: %s, attr_id: %s",
object_type,
SWSS_LOG_ERROR("Get failed, attribute not found, object type: %s: id: %s, attr_id: %s",
sai_serialize_object_type(object_type).c_str(),
serialized_object_id.c_str(),
str_attr_id.c_str());

Expand Down
Loading

0 comments on commit e90bf4f

Please sign in to comment.