The sai lib (C lib) uses P4 thrift to configure the soft switch.
install_deps.sh
will install python depencdecies../autogen.sh
./configure
make
make install
will install sai lib to default lib folder (usually /usr/local/lib/).
SAI Tests were written using the ptf framework.
First, run make from this location. This will build the sai library, generate the needed thrift and ctypesgen files, and will build the C thrift server, needed to run the tests. \
Now, follow these steps to run the PTF tests:
-
In SAI-P4-BM/tree/master/p4-switch/sai-p4-target run:
- veth_setup.sh - to configure virtual ports.
- run_server.sh - to start the P4 BM server.
-
Start new terminal and run the sai thrift server:
SAI-P4-BM/sai_adapter/test/sai_thrift_server/run_server.sh -
Start another new terminal and run the PTF tests directly, or by one the test shell scripts found in the ptf test folder: tests/ptf_tests/run_ptf_l2.sh
During the tests, the following logs are outputted:
- BM server logs can be found under SAI-P4-BM/tree/master/p4-switch/sai-p4-target/logs
- thrift server log is outputted to SAI-P4-BM/sai_adapter/test/sai_thrift_server/logs/log.txt
- PTF log is stdout.
For new Soft Switch features ("HW" flows), please follow the SAI-P4-BM/p4-softswitch readme.
- in sai_object_interface.h create C function decleration.
- in sai_object_interface.cpp create the function link, with the sai_object pointer.
- in sai_object.h add a static decleration for the function.
- for new/unimplemented api, also add the sai_api decleration, and link in the sai_api_query in the sai_object.h, and sai.c files.
- Add the function implementation to a .cpp file in the src/ dir, under the sai_object namespace.
- the sai_object uses the switch_meta_data.h to manage the runtime information regarding the sai_object_ids etc...
- to configure the BM tables, use the P4 thrift API is found (after p4-sofswitch compliation) in /SAI-P4-BM/p4-switch/behavioral-model/thrift_src/gen-cpp/bm/Standard.h