p4lang: switch-更完善的P4例子
10/16/2016 发现CI/travis目录下面有依赖工具的安装脚本,供参考
switch是个参考的switch例子,很多表可以参考,并且生成了SAI等API供调用。
首先要参照前面两篇文章安装BMv2(p4-behavioral-model)和p4c-bmv2(p4c-bm)
安装PTF: git clone https://github.com/p4lang/ptf.git cd ptf; sudo python setup.py install
安装switch: git clone https://github.com/p4lang/switch.git cd switch git submodule update --init --recursive ./autogen.sh ./configure --with-bmv2 --with-switchsai make #如果在configure步骤找不到bm相关头文件,需要进入behavioral-model项目执行sudo make install
运行: sudo tools/veth_setup.sh sudo bmv2/run_bm.sh 新窗口: sudo bmv2/run_drivers.sh
测试脚本: sudo ./bmv2/run_tests.sh --test-dir tests/ptf-tests/pd-tests # for the PD tests sudo ./bmv2/run_tests.sh --test-dir tests/ptf-tests/api-tests # for the switchapi tests sudo ./bmv2/run_tests.sh --test-dir tests/ptf-tests/sai-tests # for the switchsai tests
BMv2的命令行调试工具: bm_CLI #show_ports, show_tables, switch_info...
switch支持的功能列表参见:https://github.com/p4lang/switch/tree/master/p4src