The data plane codes in P4 are at ./switch/, and the controller codes in C are at ./ctrl.
Compile the code
make
./contrlAfter running ./contrl, create another new shell and type the instructions below to enable port to CPU on P4's side:
sudo su
source ~/bf-sde-9.13.0/set_sde.bash
bfshell
ucli
pm
port-del 21/0
port-add 21/0 10G NONE
port-enb 21/0
# bf-sde.pm> show
# this instruction can see the corresponding number of the port (example: 9/0 → 132)
# also can see how many frames are sent (TX) or received (RX) on desired port
# Ctrl+\ to exit bfshell
Use ifconfig -a to see all interfaces
First four interfaces are corresponded to 21/0 ~ 21/3
Use ifconfig <interface_name> up to get interface up
Set the subnets of two p4 ports (selected from 9/0 ~ 9/3) to 192.168.1.2/24 and 192.168.2.2/24
Don't forget to set default gateway like below:
sudo ip route add default via <gateway>(example: 192.168.1.1) dev eth0