Skip to content

Commit

Permalink
Dataplane telemetry support in SONiC (#328)
Browse files Browse the repository at this point in the history
* initial barefoot checkin october 2017

* Revert "Merge branch 'master' of https://github.com/Azure/sonic-sairedis into rel_6_0"

This reverts commit c48a7a2, reversing
changes made to aa5bf64.

* missed integration diffs

* Added new attr type support to sairedis. Also, some fixes for compilation issues

* Changes to add new DTel api support in sairedis

* Add new file to generate Dtel specific SAI stub API

* Missed adding a file in the last commit

* Fix ref point for SAI

* Updated SAI repo to point to dtel_exp

* Changes to handle new additions to DTel experimental SAI. Not compiled yet

* handle platform specific lins in different directory (@runtime)

* force order of library path to look for platform dir before lib dir

* Change SAI branch refpoint

* Update SAI submodule refpoint

* enable fast-boot for barefoot platforms

* Update ref point for SAI

* SONiC changes due to DTel experimental SAI changes

* allow Makefile to build for other platforms - restore it original for non-bfn platforms

* allow clean build

* Revert "allow clean build"

This reverts commit adfdb86.

* Revert "allow Makefile to build for other platforms - restore it original for non-bfn platforms"

This reverts commit d6b0ca3.

* makefile cleanup towards upstream

* Support for platforms based on Barefoot Networks' device (#304)

* search for exact string - newer onie versions match multiple lines

* Will need to revert this

Should work without this change. Untested for now

* SONiC sairedis changes needed to work with SAIv1.3

* Fix SAI path in gitmodules and add a comment

* Remove sai thrift build hack

* enable fast-boot for barefoot platforms

* enable fast-boot for barefoot platforms

* Add missing sai rpc hdr file path for bfn

* Update SAI ref points

* Multi p4 profile support for bfn sde (#5)

* Remove code duplicated in merge

* Keep fn in same order as azure master (#8)

* Address review comment

* Link just bfn sai lib and shorten linking command by removing other libraries linked at compile time (#6)

* Link only bfn sai lib

* all unresolved symbols resolved at runtime

* Preload some bfn libraries on syncd startup

* Build fix

* also remove commented code

* Convert tabs to spaces

* Fix alignment

* Address upstream comment

* BFN: link with just sai library for saisdkdump

* Address review comments
  • Loading branch information
shruthi9 authored and lguohan committed Jul 12, 2018
1 parent c808a0f commit c2c5e7c
Show file tree
Hide file tree
Showing 19 changed files with 157 additions and 10 deletions.
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ AC_PROG_CXX
AC_PROG_LIBTOOL
AC_HEADER_STDC

AM_CONDITIONAL(sonic_asic_platform_barefoot, test x$CONFIGURED_PLATFORM = xbarefoot)

AC_ARG_ENABLE(debug,
[ --enable-debug turn on debugging],
[case "${enableval}" in
Expand Down
1 change: 1 addition & 0 deletions lib/inc/sai_redis.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ extern const sai_udf_api_t redis_udf_api;
extern const sai_virtual_router_api_t redis_virtual_router_api;
extern const sai_vlan_api_t redis_vlan_api;
extern const sai_wred_api_t redis_wred_api;
extern const sai_dtel_api_t redis_dtel_api;

#define UNREFERENCED_PARAMETER(X)

Expand Down
1 change: 1 addition & 0 deletions lib/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ libsairedis_la_SOURCES = \
sai_redis_fdb.cpp \
sai_redis_hash.cpp \
sai_redis_hostintf.cpp \
sai_redis_dtel.cpp \
sai_redis_interfacequery.cpp \
sai_redis_lag.cpp \
sai_redis_mirror.cpp \
Expand Down
16 changes: 16 additions & 0 deletions lib/src/sai_redis_dtel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "sai_redis.h"

REDIS_GENERIC_QUAD(DTEL,dtel);
REDIS_GENERIC_QUAD(DTEL_QUEUE_REPORT,dtel_queue_report);
REDIS_GENERIC_QUAD(DTEL_INT_SESSION,dtel_int_session);
REDIS_GENERIC_QUAD(DTEL_REPORT_SESSION,dtel_report_session);
REDIS_GENERIC_QUAD(DTEL_EVENT,dtel_event);

const sai_dtel_api_t redis_dtel_api = {

REDIS_GENERIC_QUAD_API(dtel)
REDIS_GENERIC_QUAD_API(dtel_queue_report)
REDIS_GENERIC_QUAD_API(dtel_int_session)
REDIS_GENERIC_QUAD_API(dtel_report_session)
REDIS_GENERIC_QUAD_API(dtel_event)
};
1 change: 1 addition & 0 deletions lib/src/sai_redis_interfacequery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ sai_status_t sai_api_query(
API_CASE(VIRTUAL_ROUTER,virtual_router);
API_CASE(VLAN,vlan);
API_CASE(WRED,wred);
API_CASE(DTEL,dtel);

default:
SWSS_LOG_ERROR("Invalid API type %d", sai_api_id);
Expand Down
1 change: 0 additions & 1 deletion lib/src/sai_redis_port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ sai_status_t redis_clear_port_pool_stats(
return SAI_STATUS_NOT_IMPLEMENTED;
}


REDIS_GENERIC_QUAD(PORT,port);
REDIS_GENERIC_QUAD(PORT_POOL,port_pool);

Expand Down
22 changes: 22 additions & 0 deletions meta/sai_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,7 @@ sai_status_t meta_generic_validation_create(

// ACL ACTION

case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_BOOL:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_INT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT16:
Expand Down Expand Up @@ -1305,6 +1306,9 @@ sai_status_t meta_generic_validation_create(
case SAI_ATTR_VALUE_TYPE_ACL_RESOURCE_LIST:
VALIDATION_LIST(md, value.aclresource);
break;
case SAI_ATTR_VALUE_TYPE_IP_ADDRESS_LIST:
VALIDATION_LIST(md, value.ipaddrlist);
break;

case SAI_ATTR_VALUE_TYPE_UINT32_RANGE:

Expand Down Expand Up @@ -1910,6 +1914,7 @@ sai_status_t meta_generic_validation_set(

// ACL ACTION

case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_BOOL:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_INT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT16:
Expand Down Expand Up @@ -1983,6 +1988,9 @@ sai_status_t meta_generic_validation_set(
case SAI_ATTR_VALUE_TYPE_ACL_RESOURCE_LIST:
VALIDATION_LIST(md, value.aclresource);
break;
case SAI_ATTR_VALUE_TYPE_IP_ADDRESS_LIST:
VALIDATION_LIST(md, value.ipaddrlist);
break;

case SAI_ATTR_VALUE_TYPE_UINT32_RANGE:

Expand Down Expand Up @@ -2308,6 +2316,7 @@ sai_status_t meta_generic_validation_get(

// ACL ACTION

case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_BOOL:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_INT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT16:
Expand Down Expand Up @@ -2353,6 +2362,9 @@ sai_status_t meta_generic_validation_get(
case SAI_ATTR_VALUE_TYPE_ACL_RESOURCE_LIST:
VALIDATION_LIST(md, value.aclresource);
break;
case SAI_ATTR_VALUE_TYPE_IP_ADDRESS_LIST:
VALIDATION_LIST(md, value.ipaddrlist);
break;

case SAI_ATTR_VALUE_TYPE_UINT32_RANGE:
case SAI_ATTR_VALUE_TYPE_INT32_RANGE:
Expand Down Expand Up @@ -2647,6 +2659,7 @@ void meta_generic_validation_post_create(

// ACL ACTION

case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_BOOL:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_INT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT16:
Expand Down Expand Up @@ -2682,6 +2695,7 @@ void meta_generic_validation_post_create(
case SAI_ATTR_VALUE_TYPE_UINT32_LIST:
case SAI_ATTR_VALUE_TYPE_INT32_LIST:
case SAI_ATTR_VALUE_TYPE_QOS_MAP_LIST:
case SAI_ATTR_VALUE_TYPE_IP_ADDRESS_LIST:
case SAI_ATTR_VALUE_TYPE_UINT32_RANGE:
case SAI_ATTR_VALUE_TYPE_INT32_RANGE:
case SAI_ATTR_VALUE_TYPE_ACL_RESOURCE_LIST:
Expand Down Expand Up @@ -2783,6 +2797,7 @@ void meta_generic_validation_post_remove(

// ACL ACTION

case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_BOOL:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_INT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT16:
Expand Down Expand Up @@ -2817,6 +2832,7 @@ void meta_generic_validation_post_remove(
case SAI_ATTR_VALUE_TYPE_UINT32_LIST:
case SAI_ATTR_VALUE_TYPE_INT32_LIST:
case SAI_ATTR_VALUE_TYPE_QOS_MAP_LIST:
case SAI_ATTR_VALUE_TYPE_IP_ADDRESS_LIST:
case SAI_ATTR_VALUE_TYPE_UINT32_RANGE:
case SAI_ATTR_VALUE_TYPE_INT32_RANGE:
case SAI_ATTR_VALUE_TYPE_ACL_RESOURCE_LIST:
Expand Down Expand Up @@ -3012,6 +3028,7 @@ void meta_generic_validation_post_set(

// ACL ACTION

case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_BOOL:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_INT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT16:
Expand Down Expand Up @@ -3068,6 +3085,7 @@ void meta_generic_validation_post_set(
case SAI_ATTR_VALUE_TYPE_UINT32_LIST:
case SAI_ATTR_VALUE_TYPE_INT32_LIST:
case SAI_ATTR_VALUE_TYPE_QOS_MAP_LIST:
case SAI_ATTR_VALUE_TYPE_IP_ADDRESS_LIST:
case SAI_ATTR_VALUE_TYPE_UINT32_RANGE:
case SAI_ATTR_VALUE_TYPE_INT32_RANGE:
case SAI_ATTR_VALUE_TYPE_ACL_RESOURCE_LIST:
Expand Down Expand Up @@ -3319,6 +3337,7 @@ void meta_generic_validation_post_get(

// ACL ACTION

case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_BOOL:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_INT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT16:
Expand Down Expand Up @@ -3367,6 +3386,9 @@ void meta_generic_validation_post_get(
case SAI_ATTR_VALUE_TYPE_ACL_RESOURCE_LIST:
VALIDATION_LIST_GET(md, value.aclresource);
break;
case SAI_ATTR_VALUE_TYPE_IP_ADDRESS_LIST:
VALIDATION_LIST_GET(md, value.ipaddrlist);
break;

case SAI_ATTR_VALUE_TYPE_UINT32_RANGE:

Expand Down
46 changes: 46 additions & 0 deletions meta/saiserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ sai_status_t transfer_attribute(
RETURN_ON_ERROR(transfer_list(src_attr.value.aclresource, dst_attr.value.aclresource, countOnly));
break;

case SAI_ATTR_VALUE_TYPE_IP_ADDRESS_LIST:
RETURN_ON_ERROR(transfer_list(src_attr.value.ipaddrlist, dst_attr.value.ipaddrlist, countOnly));
break;

/* ACL FIELD DATA */

Expand Down Expand Up @@ -323,6 +326,11 @@ sai_status_t transfer_attribute(

/* ACL ACTION DATA */

case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_BOOL:
transfer_primitive(src_attr.value.aclaction.enable, dst_attr.value.aclaction.enable);
transfer_primitive(src_attr.value.aclaction.parameter.booldata, dst_attr.value.aclaction.parameter.booldata);
break;

case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT8:
transfer_primitive(src_attr.value.aclaction.enable, dst_attr.value.aclaction.enable);
transfer_primitive(src_attr.value.aclaction.parameter.u8, dst_attr.value.aclaction.parameter.u8);
Expand Down Expand Up @@ -904,6 +912,15 @@ std::string sai_serialize_list(

}

std::string sai_serialize_ip_address_list(
_In_ const sai_ip_address_list_t& list,
_In_ bool countOnly)
{
SWSS_LOG_ENTER();

return sai_serialize_list(list, countOnly, [&](sai_ip_address_t item) { return sai_serialize_ip_address(item);} );
}

std::string sai_serialize_enum_list(
_In_ const sai_s32_list_t& list,
_In_ const sai_enum_metadata_t* meta,
Expand Down Expand Up @@ -1065,6 +1082,9 @@ std::string sai_serialize_acl_action(

switch (meta.attrvaluetype)
{
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_BOOL:
return sai_serialize_bool(action.parameter.booldata);

case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT8:
return sai_serialize_number(action.parameter.u8);

Expand Down Expand Up @@ -1269,6 +1289,9 @@ std::string sai_serialize_attr_value(
case SAI_ATTR_VALUE_TYPE_ACL_RESOURCE_LIST:
return sai_serialize_acl_resource_list(attr.value.aclresource, countOnly);

case SAI_ATTR_VALUE_TYPE_IP_ADDRESS_LIST:
return sai_serialize_ip_address_list(attr.value.ipaddrlist, countOnly);

// ACL FIELD DATA

case SAI_ATTR_VALUE_TYPE_ACL_FIELD_DATA_BOOL:
Expand All @@ -1288,6 +1311,7 @@ std::string sai_serialize_attr_value(

// ACL ACTION DATA

case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_BOOL:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_INT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT16:
Expand Down Expand Up @@ -1982,6 +2006,16 @@ void sai_deserialize_ip_address(
SWSS_LOG_THROW("invalid ip address %s", s.c_str());
}

void sai_deserialize_ip_address_list(
_In_ const std::string& s,
_Out_ sai_ip_address_list_t& list,
_In_ bool countOnly)
{
SWSS_LOG_ENTER();

sai_deserialize_list(s, list, countOnly, [&](const std::string sitem, sai_ip_address_t& item) { sai_deserialize_ip_address(sitem, item);} );
}

template <typename T>
void sai_deserialize_range(
_In_ const std::string& s,
Expand Down Expand Up @@ -2113,6 +2147,9 @@ void sai_deserialize_acl_action(

switch (meta.attrvaluetype)
{
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_BOOL:
return sai_deserialize_bool(s, action.parameter.booldata);

case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT8:
return sai_deserialize_number(s, action.parameter.u8);

Expand Down Expand Up @@ -2247,6 +2284,9 @@ void sai_deserialize_attr_value(
case SAI_ATTR_VALUE_TYPE_ACL_RESOURCE_LIST:
return sai_deserialize_acl_resource_list(s, attr.value.aclresource, countOnly);

case SAI_ATTR_VALUE_TYPE_IP_ADDRESS_LIST:
return sai_deserialize_ip_address_list(s, attr.value.ipaddrlist, countOnly);

// ACL FIELD DATA

case SAI_ATTR_VALUE_TYPE_ACL_FIELD_DATA_BOOL:
Expand All @@ -2266,6 +2306,7 @@ void sai_deserialize_attr_value(

// ACL ACTION DATA

case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_BOOL:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_INT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT16:
Expand Down Expand Up @@ -2688,6 +2729,10 @@ void sai_deserialize_free_attribute_value(
sai_free_list(attr.value.aclresource);
break;

case SAI_ATTR_VALUE_TYPE_IP_ADDRESS_LIST:
sai_free_list(attr.value.ipaddrlist);
break;

/* ACL FIELD DATA */

case SAI_ATTR_VALUE_TYPE_ACL_FIELD_DATA_BOOL:
Expand All @@ -2713,6 +2758,7 @@ void sai_deserialize_free_attribute_value(

/* ACL ACTION DATA */

case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_BOOL:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_INT8:
case SAI_ATTR_VALUE_TYPE_ACL_ACTION_DATA_UINT16:
Expand Down
4 changes: 4 additions & 0 deletions saidiscovery/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ endif
if SAIVS
SAILIB=-L$(top_srcdir)/vslib/src/.libs -lsaivs
else
if sonic_asic_platform_barefoot
SAILIB=-L/opt/bfn/install/lib -lswitchsai -lswitchapi -lbf_switchd_lib -ltofinopdfixed_thrift -ldriver -lbfutils -lbfsys -lbfutils -L/opt/bfn/install/lib/tofinopd/switch -lpd -lpdcli -lpdthrift
else
SAILIB=-lsai
endif
endif

saidiscovery_SOURCES = saidiscovery.cpp

Expand Down
4 changes: 4 additions & 0 deletions saiplayer/saiplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ void match_list_lengths(
CHECK_LIST(value.qosmap);
break;

case SAI_ATTR_VALUE_TYPE_IP_ADDRESS_LIST:
CHECK_LIST(value.ipaddrlist);
break;

case SAI_ATTR_VALUE_TYPE_ACL_FIELD_DATA_OBJECT_LIST:
CHECK_LIST(value.aclfield.data.objlist);
break;
Expand Down
6 changes: 6 additions & 0 deletions saisdkdump/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ else
DBGFLAGS = -g
endif


if SAIVS
SAILIB=-L$(top_srcdir)/vslib/src/.libs -lsaivs
else
if sonic_asic_platform_barefoot
AM_LDFLAGS = -Wl,-unresolved-symbols=ignore-in-shared-libs
SAILIB=-L/opt/bfn/install/lib -lswitchsai
else
SAILIB=-lsai
endif
endif

saisdkdump_SOURCES = saisdkdump.cpp
saisdkdump_CPPFLAGS = $(DBGFLAGS) $(AM_CPPFLAGS) $(CFLAGS_COMMON) $(SAIFLAGS)
Expand Down
6 changes: 6 additions & 0 deletions syncd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ endif
if SAIVS
SAILIB=-L$(top_srcdir)/vslib/src/.libs -lsaivs
else
if sonic_asic_platform_barefoot
AM_CPPFLAGS += -I/opt/bfn/install/include
AM_LDFLAGS = -Wl,-unresolved-symbols=ignore-in-shared-libs
SAILIB=-L/opt/bfn/install/lib -lswitchsai
else
SAILIB=-lsai
endif
endif

syncd_SOURCES = \
main.cpp \
Expand Down
Loading

0 comments on commit c2c5e7c

Please sign in to comment.