To verify the functionality of a P4 program <testname>.p4 (along with input packet data <packetname>_in.pcap|user) using the behavioral model, complete the following steps:
- Compile the P4 program using p4c-vitisnet.
This generates a JSON file that can be used in the behavioral model:
p4c-vitisnet <testname>.p4 -o <json_name>.json
- Create a <testcase>.txt text file containing a command to run the
traffic data, ensuring that the input packet data file follows the <name>_in.pcap|user naming convention. If
there are any tables in the P4 program, the table entries should be added to
this testcase file (before the run_traffic command):
echo "run_traffic <packetname>" > <testcase>.txt
table_add <table_name> <action_name> <key0> <key1> <key2>... => <response0> <response1>...
For example:
table_add FiveTuple InsertVLAN 0x6e39cb7c 0x945e726d 0x06 0xc4aa 0x8ca2 => 0x3 0x1 0x060
- Run the run-p4bm-vitisnet application to
generate outputs from the model:
run-p4bm-vitisnet -j <json_name>.json -s <testcase>.txt
vivado -mode batch -source cli_example.tcl
where the TCL script cli_example.tcl is:
exec p4c-vitisnet $::env(XILINX_VIVADO)/data/ip/xilinx/vitis_net_p4_v1_0/example_design/examples/five_tuple/fiveTuple.p4 -o cli_example.json
exec cp $::env(XILINX_VIVADO)/data/ip/xilinx/vitis_net_p4_v1_0/example_design/examples/five_tuple/traffic_in.user .
exec run-p4bm-vitisnet -p 9091 -s $::env(XILINX_VIVADO)/data/ip/xilinx/vitis_net_p4_v1_0/example_design/examples/five_tuple/cli_commands.txt -j cli_example.json
exec ls -l traffic_out.user traffic_out.meta