The sai lib (C lib) uses P4 thrift to configure the soft switch as described below:
The sai_api lib is currently under development. In the meantime, please include sai.h, check the unit test folder for example. In the sai_adapter dir run:
./install_deps.sh
make
SAI Tests were written using the ptf framework. The directory is divided to tests (ready and passing tests), wip_tests for work in progress.
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-softswitch/targets/P4-SAI/ run:
- veth_setup_ptf.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/p4-softswitch/targets/P4-SAI/logs/
- running the script: log_aggregation.py (found in the target dir) will merge the bridge and router logs together.
- 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.
For P4 new features testing, it is possible to bypass implementing new SAI C implementations, and just update the thirft implementation in python. use the python thrift server found in test/sai_thrift_development_python_server/. If you decide to do so, run the sai p4 thrift server with: tests/sai_thrift_development_python_server/sai_rpc_server.sh
- 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-softswitch/thrift_src/gen-cpp/bm/Standard.h