diff --git a/platform/barefoot/docker-ptf.mk b/platform/barefoot/docker-ptf.mk new file mode 100644 index 00000000000..bae52dc14bd --- /dev/null +++ b/platform/barefoot/docker-ptf.mk @@ -0,0 +1,7 @@ +# docker image for docker-ptf + +DOCKER_PTF = docker-ptf.gz +$(DOCKER_PTF)_PATH = $(DOCKERS_PATH)/docker-ptf +$(DOCKER_PTF)_DEPENDS += $(LIBTHRIFT_0_13_0) $(PYTHON3_THRIFT_0_13_0) $(PTF) $(PYTHON_SAITHRIFT) +SONIC_DOCKER_IMAGES += $(DOCKER_PTF) +SONIC_BUSTER_DOCKERS += $(DOCKER_PTF) diff --git a/platform/barefoot/docker-syncd-bfn-rpc.mk b/platform/barefoot/docker-syncd-bfn-rpc.mk index fe1f498d5ad..71c21f1f7da 100644 --- a/platform/barefoot/docker-syncd-bfn-rpc.mk +++ b/platform/barefoot/docker-syncd-bfn-rpc.mk @@ -2,7 +2,7 @@ DOCKER_SYNCD_BFN_RPC = docker-syncd-bfn-rpc.gz $(DOCKER_SYNCD_BFN_RPC)_PATH = $(PLATFORM_PATH)/docker-syncd-bfn-rpc -$(DOCKER_SYNCD_BFN_RPC)_DEPENDS += $(SYNCD_RPC) $(LIBTHRIFT) $(PTF) +$(DOCKER_SYNCD_BFN_RPC)_DEPENDS += $(SYNCD_RPC) $(LIBTHRIFT_0_13_0) $(PTF) $(DOCKER_SYNCD_BFN_RPC)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) ifeq ($(INSTALL_DEBUG_TOOLS), y) $(DOCKER_SYNCD_BFN_RPC)_DEPENDS += $(SYNCD_RPC_DBG) \ diff --git a/platform/barefoot/libsaithrift-dev.mk b/platform/barefoot/libsaithrift-dev.mk index 0289a41b291..57109729057 100644 --- a/platform/barefoot/libsaithrift-dev.mk +++ b/platform/barefoot/libsaithrift-dev.mk @@ -1,20 +1,29 @@ +SAITHRIFT_PATCHES = saithrift-patches +$(SAITHRIFT_PATCHES)_SRC_PATH = $(PLATFORM_PATH)/saithrift-patches +SONIC_MAKE_FILES += $(SAITHRIFT_PATCHES) + # libsaithrift-dev package +SAITHRIFT_VER = 0.9.4 +LIBSAITHRIFT_DEV = libsaithrift-dev_$(SAITHRIFT_VER)_$(CONFIGURED_ARCH).deb +$(LIBSAITHRIFT_DEV)_SRC_PATH = $(SRC_PATH)/sonic-sairedis/SAI +$(LIBSAITHRIFT_DEV)_DEPENDS += $(LIBTHRIFT_0_13_0) $(LIBTHRIFT_DEV_0_13_0) \ + $(PYTHON3_THRIFT_0_13_0) $(THRIFT_COMPILER_0_13_0) \ + $(LIBSAIVS) $(LIBSAIVS_DEV) $(LIBSAIMETADATA) $(LIBSAIMETADATA_DEV) -SAI_VER = 0.9.4 +$(LIBSAITHRIFT_DEV)_UNINSTALLS = $(LIBSAIVS_DEV) +$(LIBSAITHRIFT_DEV)_BUILD_ENV = platform=vs +$(LIBSAITHRIFT_DEV)_AFTER_FILES = $(SAITHRIFT_PATCHES) -LIBSAITHRIFT_DEV = libsaithrift-dev_$(SAI_VER)_amd64.deb -$(LIBSAITHRIFT_DEV)_SRC_PATH = $(SRC_PATH)/sonic-sairedis/SAI -$(LIBSAITHRIFT_DEV)_DEPENDS += $(LIBTHRIFT) $(LIBTHRIFT_DEV) $(PYTHON_THRIFT) $(THRIFT_COMPILER) $(BFN_SAI) $(BFN_SAI_DEV) -$(LIBSAITHRIFT_DEV)_RDEPENDS += $(LIBTHRIFT) $(BFN_SAI) +$(LIBSAITHRIFT_DEV)_RDEPENDS += $(LIBTHRIFT_0_13_0) $(BFN_SAI) SONIC_DPKG_DEBS += $(LIBSAITHRIFT_DEV) -PYTHON_SAITHRIFT = python-saithrift_$(SAI_VER)_amd64.deb +PYTHON_SAITHRIFT = python-saithrift_$(SAITHRIFT_VER)_amd64.deb $(eval $(call add_extra_package,$(LIBSAITHRIFT_DEV),$(PYTHON_SAITHRIFT))) -SAISERVER = saiserver_$(SAI_VER)_amd64.deb -$(SAISERVER)_RDEPENDS += $(LIBTHRIFT) $(BRCM_SAI) +SAISERVER = saiserver_$(SAITHRIFT_VER)_amd64.deb +$(SAISERVER)_RDEPENDS += $(LIBTHRIFT_0_13_0) $(BFN_SAI) $(eval $(call add_extra_package,$(LIBSAITHRIFT_DEV),$(SAISERVER))) -SAISERVER_DBG = saiserver-dbg_$(SAI_VER)_amd64.deb +SAISERVER_DBG = saiserver-dbg_$(SAITHRIFT_VER)_amd64.deb $(SAISERVER_DBG)_RDEPENDS += $(SAISERVER) $(eval $(call add_extra_package,$(LIBSAITHRIFT_DEV),$(SAISERVER_DBG))) diff --git a/platform/barefoot/rules.mk b/platform/barefoot/rules.mk index 98dcef0f7b8..021952bb2ed 100644 --- a/platform/barefoot/rules.mk +++ b/platform/barefoot/rules.mk @@ -11,6 +11,7 @@ include $(PLATFORM_PATH)/one-aboot.mk include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk include $(PLATFORM_PATH)/bfn-platform.mk +include $(PLATFORM_PATH)/docker-ptf.mk #include $(PLATFORM_PATH)/bfn-platform-wnc.mk #include $(PLATFORM_PATH)/bfn-platform-ingrasys.mk include $(PLATFORM_PATH)/bfn-modules.mk @@ -24,7 +25,8 @@ $(SYNCD)_DEPENDS += $(BFN_SAI) $(BFN_INGRASYS_PLATFORM) $(BFN_PLATFORM) $(SYNCD)_UNINSTALLS += $(BFN_SAI) ifeq ($(ENABLE_SYNCD_RPC),y) -$(SYNCD)_DEPENDS += $(LIBSAITHRIFT_DEV) +$(SYNCD)_DEPENDS := $(filter-out $(LIBTHRIFT_DEV),$($(SYNCD)_DEPENDS)) +$(SYNCD)_DEPENDS += $(LIBSAITHRIFT_DEV) $(LIBTHRIFT_0_13_0_DEV) endif # Runtime dependency on sai is set only for syncd diff --git a/platform/barefoot/saithrift-patches/0001-Replace-unions-with-structs-in-thrift.patch b/platform/barefoot/saithrift-patches/0001-Replace-unions-with-structs-in-thrift.patch new file mode 100644 index 00000000000..fb7ef8a6b51 --- /dev/null +++ b/platform/barefoot/saithrift-patches/0001-Replace-unions-with-structs-in-thrift.patch @@ -0,0 +1,70 @@ +From e3100ea5a82eff680cab00801463e9b39f108f98 Mon Sep 17 00:00:00 2001 +From: Your Name +Date: Wed, 14 Jul 2021 14:25:27 +0000 +Subject: [PATCH 1/3] Replace unions with structs in thrift + +--- + test/saithrift/src/switch_sai.thrift | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/test/saithrift/src/switch_sai.thrift b/test/saithrift/src/switch_sai.thrift +index a9e1d28..0c24b71 100644 +--- a/test/saithrift/src/switch_sai.thrift ++++ b/test/saithrift/src/switch_sai.thrift +@@ -48,7 +48,7 @@ struct sai_thrift_vlan_port_t { + 2: sai_thrift_vlan_tagging_mode_t tagging_mode; + } + +-union sai_thrift_ip_t { ++struct sai_thrift_ip_t { + 1: sai_thrift_ip4_t ip4; + 2: sai_thrift_ip6_t ip6; + } +@@ -79,7 +79,7 @@ struct sai_thrift_s32_list_t { + 2: list s32list; + } + +-union sai_thrift_acl_mask_t { ++struct sai_thrift_acl_mask_t { + 1: byte u8; + 2: byte s8; + 3: i16 u16; +@@ -91,7 +91,7 @@ union sai_thrift_acl_mask_t { + 9: sai_thrift_ip6_t ip6; + } + +-union sai_thrift_acl_data_t { ++struct sai_thrift_acl_data_t { + 1: byte u8; + 2: byte s8; + 3: i16 u16; +@@ -112,7 +112,7 @@ struct sai_thrift_acl_field_data_t + 3: sai_thrift_acl_data_t data; + } + +-union sai_thrift_acl_parameter_t { ++struct sai_thrift_acl_parameter_t { + 1: byte u8; + 2: byte s8; + 3: i16 u16; +@@ -161,7 +161,7 @@ struct sai_thrift_fdb_values_t { + 2: sai_thrift_fdb_entry_t thrift_fdb_entry; + } + +-union sai_thrift_attribute_value_t { ++struct sai_thrift_attribute_value_t { + 1: bool booldata; + 2: string chardata; + 3: byte u8; +@@ -207,7 +207,7 @@ struct sai_thrift_attribute_list_t { + 2: i32 attr_count; // redundant + } + +-union sai_thrift_result_data_t { ++struct sai_thrift_result_data_t { + 1: sai_thrift_object_list_t objlist; + 2: sai_thrift_object_id_t oid; + 3: i16 u16; +-- +2.17.1 + diff --git a/platform/barefoot/saithrift-patches/0002-Use-std-shared_ptr-instead-of-boost.patch b/platform/barefoot/saithrift-patches/0002-Use-std-shared_ptr-instead-of-boost.patch new file mode 100644 index 00000000000..d30962e7d24 --- /dev/null +++ b/platform/barefoot/saithrift-patches/0002-Use-std-shared_ptr-instead-of-boost.patch @@ -0,0 +1,25 @@ +From 18589cf200ab4789f41a2caab03f3f913229a573 Mon Sep 17 00:00:00 2001 +From: Your Name +Date: Wed, 14 Jul 2021 14:26:13 +0000 +Subject: [PATCH 2/3] Use std::shared_ptr instead of boost + +--- + test/saithrift/src/switch_sai_rpc_server.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test/saithrift/src/switch_sai_rpc_server.cpp b/test/saithrift/src/switch_sai_rpc_server.cpp +index 0df9b3d..e990c50 100644 +--- a/test/saithrift/src/switch_sai_rpc_server.cpp ++++ b/test/saithrift/src/switch_sai_rpc_server.cpp +@@ -74,7 +74,7 @@ using namespace ::apache::thrift::protocol; + using namespace ::apache::thrift::transport; + using namespace ::apache::thrift::server; + +-using boost::shared_ptr; ++using std::shared_ptr; + + using namespace ::switch_sai; + +-- +2.17.1 + diff --git a/platform/barefoot/saithrift-patches/0003-include-algorithm.patch b/platform/barefoot/saithrift-patches/0003-include-algorithm.patch new file mode 100644 index 00000000000..ac7b1999469 --- /dev/null +++ b/platform/barefoot/saithrift-patches/0003-include-algorithm.patch @@ -0,0 +1,24 @@ +From aaaa75aa529433f6c4c111df4db9e88b514a8664 Mon Sep 17 00:00:00 2001 +From: Your Name +Date: Wed, 14 Jul 2021 14:27:44 +0000 +Subject: [PATCH 3/3] include algorithm + +--- + test/saithrift/src/saiserver.cpp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/test/saithrift/src/saiserver.cpp b/test/saithrift/src/saiserver.cpp +index 5ccf6e9..947f7ef 100644 +--- a/test/saithrift/src/saiserver.cpp ++++ b/test/saithrift/src/saiserver.cpp +@@ -5,6 +5,7 @@ + #include + #include + #include ++#include + #include + #include + #include +-- +2.17.1 + diff --git a/platform/barefoot/saithrift-patches/Makefile b/platform/barefoot/saithrift-patches/Makefile new file mode 100644 index 00000000000..625317dcb5f --- /dev/null +++ b/platform/barefoot/saithrift-patches/Makefile @@ -0,0 +1,19 @@ +SHELL = /bin/bash +.ONESHELL: +.SHELLFLAGS += -e + +MAIN_TARGET = saithrift-patches + +$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : +# To add some BFN specific patches to SAI under sonic-sairedis while sai is not updated +SRC_DIR = ../saithrift-patches +DST_DIR = ../../../src/sonic-sairedis/SAI.patch/ + +$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : + # copy patches to SAI + mkdir -p $(DST_DIR) + cp -f $(SRC_DIR)/* $(DST_DIR) + + touch $(DEST)/saithrift-patches + + diff --git a/platform/barefoot/saithrift-patches/series b/platform/barefoot/saithrift-patches/series new file mode 100644 index 00000000000..a6f701dc046 --- /dev/null +++ b/platform/barefoot/saithrift-patches/series @@ -0,0 +1,3 @@ +0001-Replace-unions-with-structs-in-thrift.patch +0002-Use-std-shared_ptr-instead-of-boost.patch +0003-include-algorithm.patch \ No newline at end of file diff --git a/slave.mk b/slave.mk index c247e50114b..bf4083f9885 100644 --- a/slave.mk +++ b/slave.mk @@ -507,6 +507,7 @@ SONIC_TARGET_LIST += $(addprefix $(DEBS_PATH)/, $(SONIC_MAKE_DEBS)) # SONIC_DPKG_DEBS += $(SOME_NEW_DEB) $(addprefix $(DEBS_PATH)/, $(SONIC_DPKG_DEBS)) : $(DEBS_PATH)/% : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS))) \ $$(addprefix $(DEBS_PATH)/,$$($$*_AFTER)) \ + $$(addprefix $(FILES_PATH)/,$$($$*_AFTER_FILES)) \ $(call dpkg_depend,$(DEBS_PATH)/%.dep ) $(HEADER)