Skip to content

Commit a6e3f1c

Browse files
saithriftv2: link VPP libraries for platform=vpp + bookworm/py3 build fixes (#2299)
Context / motivation This PR is part of the SAIVPP unit-test framework: a Docker harness (docker-sai-test-vpp) that runs the upstream OCP sai_test PTF suite against the real VPP SAI backend (libsaivs) in one container — VPP + saiserver + PTF + veth/AF_PACKET topology. That work is documented in our devdocs under sonic-sairedis/.azure-pipelines/docker-sai-test-vpp/devdocs/ (see progress.md). To run the suite, saiserver (saithriftv2) must build and link against the VPP SAI backend on a bookworm/python3 toolchain. Upstream saithriftv2 only has a vs link line and a python2.7 install path, so it does not build for the vpp platform on bookworm. This is Phase 1, Task 2 of the SAIVPP UT HLD (the saithriftv2 Makefile work). What this change does Build/packaging only, no test logic: test/saithriftv2/Makefile — add a platform=vpp link line that pulls in the 5 VPP libraries SaiVppXlate.c requires (-lvlib -lvlibapi -lvppapiclient -lvlibmemoryclient -lvppinfra) plus -lswsscommon; also add -lswsscommon to the vs line. test/saithriftv2/src/saiserver.cpp — enable SWSS debug logging at startup (swss::Logger to STDOUT), so the harness captures a high-level SAI RPC trace in saiserver.log (used throughout our debugging). debian/python-saithrift.install — install the Python bindings from the python3 dist-packages path so the package builds on bookworm (was hardcoded to python2.7/site-packages). test/saithriftv2/convert_header.py — fix an enum __str__ that did split(".")[1] and threw an IndexError on some enum names; use self.name instead. Scope / risk 4 files, +11/−3 — build flags, a packaging path, a logging init, and a one-line stringification fix. No change to SAI semantics, RPC surface, or test logic. The vpp link line is new (additive); the vs line only gains -lswsscommon.
1 parent 084e554 commit a6e3f1c

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

debian/python-saithrift.install

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
debian/usr/local/lib/python2.7/site-packages/* /usr/lib/python2.7/dist-packages/
1+
#compatiable with bookworm python 3.11 environment and build with python3
2+
debian/usr/local/local/lib/python3*/dist-packages/* /usr/lib/python3/dist-packages/

test/saithriftv2/Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ CTYPESGEN = /usr/local/bin/ctypesgen.py
3838
endif
3939

4040
ifeq ($(platform),vs)
41-
LIBS = -lthrift -lpthread -lsaivs -lsaimeta -lsaimetadata -lzmq
41+
LIBS = -lthrift -lpthread -lsaivs -lsaimeta -lsaimetadata -lzmq -lswsscommon
42+
else ifeq ($(platform),vpp)
43+
LIBS = -lthrift -lpthread -lsaivs -lsaimeta -lsaimetadata -lzmq \
44+
-lvlib -lvlibapi -lvppapiclient -lvlibmemoryclient -lvppinfra -lswsscommon
4245
else
4346
LIBS = -lthrift -lpthread -lsai -lsaimetadata
4447
endif
@@ -74,18 +77,23 @@ $(METADIR)sai.thrift:
7477
# rm gen-cpp/gen-py is needed since thrift don't override existing files
7578
# even if sai.thrift file changed :(
7679

77-
$(CPP_SOURCES): $(METADIR)sai.thrift
80+
gen-cpp/sai_rpc.cpp: $(METADIR)sai.thrift
7881
rm -rf gen-cpp
7982
$(THRIFT) -o ./ --gen cpp -r $^
8083

81-
$(PY_SOURCES): $(METADIR)sai.thrift
84+
$(filter-out gen-cpp/sai_rpc.cpp, $(CPP_SOURCES)): gen-cpp/sai_rpc.cpp
85+
86+
gen-py/sai/sai_rpc.py: $(METADIR)sai.thrift
8287
rm -rf gen-py
8388
$(THRIFT) -o ./ --gen py -r $^
8489
$(INSTALL) -vCD $(METADIR)sai_adapter.py gen-py/sai/sai_adapter.py
8590

91+
$(filter-out gen-py/sai/sai_rpc.py, $(PY_SOURCES)): gen-py/sai/sai_rpc.py
92+
8693
# TODO should depend on ../../inc/sai*.h ../../experimental/sai*.h and not /usr/include/sai/sai*.h
8794

8895
$(SAI_PY_HEADERS): $(SAI_HEADERS)
96+
mkdir -p gen-py/sai
8997
$(CTYPESGEN) --output-language=py32 -I/usr/include -I$(SAI_HEADER_DIR) -I../../experimental -I../../custom --include /usr/include/linux/limits.h $^ -o $@
9098
python3 convert_header.py -i $(SAI_PY_HEADERS) -o ./new_header.py
9199
mv $(SAI_PY_HEADERS) ./sai_headers.py.bk
@@ -97,7 +105,7 @@ $(METADIR)saimetadata.h:
97105
$(ODIR)/%.o: gen-cpp/%.cpp
98106
$(CXX) $(CPPFLAGS) -c $< -o $@
99107

100-
$(ODIR)/sai_rpc_server.o: $(METADIR)sai_rpc_frontend.cpp $(METADIR)saimetadata.h
108+
$(ODIR)/sai_rpc_server.o: $(METADIR)sai_rpc_frontend.cpp $(METADIR)saimetadata.h $(CPP_SOURCES)
101109
$(CXX) $(CPPFLAGS) -c $(METADIR)sai_rpc_frontend.cpp -o $@ -I$(METADIR) -I./gen-cpp -I../../inc -I../../experimental -I../../custom
102110

103111
$(ODIR)/saiserver.o: src/saiserver.cpp src/switch_sai_rpc_server.h $(CPP_SOURCES)

test/saithriftv2/convert_header.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class sai_common_api(SAIEnum):
4747
import enum
4848
class SAIEnum(enum.IntEnum):
4949
def __str__(self):
50-
return super().__str__().split(\".\")[1]\n"""
50+
return self.name\n"""
5151
ENUM_PREFIX = "enum__sai_"
5252
SAI_NAME = "SAI"
5353
ENUM_TYPE = "= c_int"

0 commit comments

Comments
 (0)