P51 - Lab 1, Introduction To Netfpga: DR Noa Zilberman Lent, 2018/19
P51 - Lab 1, Introduction To Netfpga: DR Noa Zilberman Lent, 2018/19
Dr Noa Zilberman
Lent, 2018/19
The goal of this lab is to introduce you to the NetFPGA platform, and to provide hands
on experience both in using the platform and developing for it. We begin with the
Verilog based workflow, and follow with the P4 based workflow.
1 Background
The demand-led growth of cloud computing and datacenter networks has meant that
many constituent technologies are beyond the budget of the research community. In
order to make and validate timely, relevant research contributions, the wider research
community requires accessible evaluation, experimentation and demonstration environ-
ments with specification comparable to the subsystems of the most massive datacenter
networks.
The NetFPGA is an open platform enabling researchers and instructors to build high-
speed, hardware-accelerated networking systems. The most prominent NetFPGA success
is OpenFlow, which in turn has reignited the Software Defined Networking movement.
NetFPGA enabled OpenFlow by providing a widely available open-source development
platform capable of line-rate operation and was, until its commercial uptake, the refer-
ence platform for OpenFlow.
NetFPGA enables rapid prototyping of high bandwidth devices, using flexible, open-
source IPs. Specifically, we use NetFPGA SUME, an open-source FPGA-based PCIe
board, designed for the research community. NetFPGA SUME has I/O capabilities for
100Gbps operation as a networking device, stand alone computing unit or for test and
measurement.
2 Development Machines
During the course you will use an assigned development machine. Each pair will be
assigned different machines. All the machines are located in the Practical Classroom
(SW02). This provides access to the machines, so you can change the physical connec-
tivity according to the experiment.
1
1. On a computer in the Practical Classroom, log in using your own UIS credentials.
3. Limit the permissions of the private key: chmod 600 p51 key
Important: The IP addresses noted above should not be used for anything
except for communication with the machines. The network interfaces as-
signed for the tests use different IP addresses.
3 Test Setup
Each of the development machines is equipped as follows:
• Optical fibers - duplex fibres with separate strands for transmitting and receiving.
The network port markings noted above apply only to Figure 1. The name of the port
on each machine may differ, (e.g.,eth2, eth3 ).
In a typical setup, each NIC port will be connected to a NetFPGA SUME port, e.g.
intl0 to nf0, and intl1 to nf1.
2
Figure 1: Development Platform
3
5 Using NetFPGA - Verilog Design Flow
This section provides step-by-step instructions how to access and test a NetFPGA design.
To this end, we will be using the verilog Reference Switch design studied in class.
2. cd ~/NetFPGA-SUME-live/tools/
vim settings.sh
source settings.sh
cd $DRIVER_FOLDER
make
cd $APPS_FOLDER
make
cd $SUME_FOLDER/tools/scripts
chmod +x run_load_image.sh
./run_load_image.sh $NF_DESIGN_DIR/bitfiles/reference_switch.bit
Note that you may need to reset the machine if this is the first time the board is
programmed after power up. This allows the PCIe bus to properly identify and
enumerate the board. The first time the board is programmed after reset (not
power up!), you may see a message “rmmod: ERROR: Module sume riffa is not
currently loaded”. It can be ignored.
4
5.2 Simple Debug
1. Check if the board is recognized by the host:
cd $APPS_FOLDER
./rwaxi
Note that the return value may change - 0x0001da02 is the ID of the output port
lookup module. You module(s) may use a different value.
cd $APPS_FOLDER
make register_read.sh
cd $NF_DESIGN_DIR/sw/host/apps/
./register_read.sh
cd $APPS_FOLDER
./rwaxi -a 0x44010008
cd $APPS_FOLDER
./rwaxi -a 0x44010010 -w 0xabcdabcd
5
cd $APPS_FOLDER
./rwaxi -a 0x4401000C -w 0x55555555
./rwaxi -a 0x4401000C
Will return:
chmod +x <filename>
1. Compiling an IP core:
This step is required only for new IP cores or when changes are made to the tcl
file of the core. There is no need to run make if only the HDL files were modified.
cd $SUME_FOLDER
make
This step if typically required only once: after the git repository is cloned or pulled.
It is also required if the make clean command was called.
4. Building a project:
cd $NF_DESIGN_DIR\
make
The result of this step is the programming (bit) file. This step takes 45 minutes
or more. Do not run it during class. You can run the next section independently.
6
5.4 Testing a design
This section covers simple design testing of the NetFPGA platform, focusing on func-
tionality. Performance testing will be discussed later in the course. There is no need to
generate the bit file to do this section, a bit file was already generated for you.
For each NetFPGA design, functional tests need to be written. The tests are located
under $NF DESIGN DIR/test. Each test has a dedicated folder called hw/sim/both major minor,
for example both simple broadcast or both learning sw. The test itself is written in
python, in a file called run.py. The NetFPGA test environment (python based as well)
calls this file when invoked.
The NetFPGA Reference Switch is a Learning Switch, meaning that forwarding is
done based on MAC addresses that the switch sees in incoming packets and associates
with ports. For example, is a packet with source MAC address aa : bb : cc : dd : ee : f f
is received on Port 1, the switch will save in its lookup table an entry equivalent to
“aa : bb : cc : dd : ee : f f , Port 1”, and the next time a packet arrives with a destination
MAC address aa : bb : cc : dd : ee : f f it will know to send it to port 1. When the
destination MAC address is not in the lookup table, the switch uses broadcast: it sends
the packet on all ports (except for the incoming port).
The test both simple broadcast tests the switch’s broadcast operation, and the test
both learning sw tests both broadcast and learning. Read the file run.py under each test
to learn how exactly it is done.
The following describes the steps for running a simulation, without GUI:
cd $SUME_FOLDER/tools/scripts
./nf_test.py sim --major learning --minor sw
The following describes the steps for running a simulation, with GUI (Vivado xsim):
cd $SUME_FOLDER/tools/scripts
./nf_test.py sim --major learning --minor sw --gui
Note that using xsim is not mandatory. You can also change the environment and
use Modelsim, and a license for that is available. The following describes the steps for
running a hardware test:
1. Connect port 0 of the NIC to port 0 of NetFPGA using a fibre.
3. Check what are the interfaces names of your NIC (These can also be config-
ures/modified, but it is not mandatory):
ifconfig -a
vim $NF_DESIGN_DIR/test/global/setup
vim $NF_DESIGN_DIR/test/connections/conn
7
Note that connections/conn file reflects the physical (external) connectivity be-
tween the NIC’s ports and NetFPGA’s ports.
cd $SUME_FOLDER/tools/scripts
./nf_test.py hw --major learning --minor sw
If the hardware test fails, check your fibres and transceivers. Pay attention to any
error messages.
The Reference Switch also works as a normal switch, enabling to connect multiple
devices. For the following exercise you should work with another team, so two machines
are used. We refer to those as Machine A and machine B.
5. Check that the connectivity between both machines works. From Machine A ping
Machine B:
ping 10.0.0.101
6. You can also check the same in the opposite direction. From Machine B ping
Machine A:
ping 10.0.0.100
8
6.1 Accessing and programming the board
1. Login to the development machine:
2. Edit bashrc to use Vivado 2018.2. This step needs to be done only the first time
you connect to the machine:
vim ~/.bashrc
source /opt/Xilinx/Vivado/2018.2/settings64.sh\\
Exit the ssh connection and connect again to the machine. Note that sourcing
bashrc again (without exiting current session) will lead to problems.
3. cd ~/P4-NetFPGA/tools/
vim settings.sh
4. Make sure that NF PROJECT NAME is set to “simple sume switch”
5. Make sure that P4 PROJECT NAME is set to “switch calc”
6. Load the environment settings (can be added to ˜/.bashrc):
source settings.sh
cd $DRIVER_FOLDER
make
cd $APPS_FOLDER
make
cd $NF_DESIGN_DIR/bitfiles
source program_switch.sh
Note that you may need to reset the machine if this is the first time the board is
programmed after power up. This allows the PCIe bus to properly identify and
enumerate the board. The first time the board is programmed after reset (not
power up!), you may see a message “rmmod: ERROR: Module sume riffa is not
currently loaded”. It can be ignored.
10. The board is now programmed and ready.
9
6.2 Simple Debug
1. Check if the board is recognized by the host:
cd $APPS_FOLDER
./rwaxi
Note that the return value may change - 0x0000032 is the ID of the output port
lookup module. You module(s) may use a different value.
cd $APPS_FOLDER
make register_read
cd $NF_DESIGN_DIR/sw/host/apps/
./register_read.sh
cd $APPS_FOLDER
./rwaxi -a 0x44010008
cd $APPS_FOLDER
./rwaxi -a 0x44010010 -w 0xabcdabcd
10
cd $APPS_FOLDER
./rwaxi -a 0x4401000C -w 0x55555555
./rwaxi -a 0x4401000C
Will return:
chmod +x <filename>
1. Compiling an IP core:
This step is required only for new IP cores or when changes are made to the tcl
file of the core. There is no need to run make if only the HDL files were modified.
cd $SUME_FOLDER
make
This step if typically required only once: after the git repository is cloned or pulled.
It is also required if the make clean command was called.
cd $P4_PROJECT_DIR/src
vim <filename>.p4
11
5. Add entries to the tables you defined in the P4 program:
cd $P4_PROJECT_DIR/src
vim commands.txt
6. Run the P4-SDNet compiler to generate the resulting HDL and an initial simulation
framework:
7. Generate the scripts that configure the table entries (current release requires that
you run simulation first, see next section):
8. Wrap SDNet output in wrapper module and install as a NetFPGA library core:
cd $P4_PROJECT_DIR
make uninstall_sdnet && make install_sdnet
9. Building a project:
cd $NF_DESIGN_DIR
make
The result of this step is the programming (bit) file. This step takes 45 minutes
or more. Do not run it during class.
12
cd $P4_PROJECT_DIR/nf_sume_sdnet_ip/SimpleSumeSwitch
./vivado_sim.bash
The following describes the steps for running a simulation of the P4 code in the SDNet
environment, with GUI:
cd $P4_PROJECT_DIR/nf_sume_sdnet_ip/SimpleSumeSwitch
./vivado_sim_waveform.bash
The following describes the steps for running a simulation of the entire NetFPGA
design:
cd $P4_PROJECT_DIR
make config_writes
2. Wrap SDNet output in a wrapper module and install as a NetFPGA library core:
cd $P4_PROJECT_DIR
make uninstall_sdnet && make install_sdnet
cd $NF_DESIGN_DIR/test/sim_switch_default
make
cd $SUME_FOLDER/tools/scripts/
./nf_test.py sim --major switch --minor default
To run a simulation with GUI (Vivado xsim), replace the last stage with:
cd $SUME_FOLDER/tools/scripts
./nf_test.py sim --major switch --minor default --gui
Note that using xsim is not mandatory. You can also change the environment and use
Modelsim, and a license for that is available.
The following describes the steps for running a hardware test:
3. Check what are the interfaces names of your NIC (These can also be config-
ures/modified, but it is not mandatory):
13
ifconfig -a
vim $NF_DESIGN_DIR/test/global/setup
vim $NF_DESIGN_DIR/test/connections/conn
Note that connections/conn file reflects the physical (external) connectivity be-
tween the NIC’s ports and NetFPGA’s ports.
5. To run a P4 program test (e.g., switch calc), use help run test to see test specific
commands:
cd $P4_PROJECT_DIR/sw/hw_test_tool
./switch_calc_tester.py
help run_test
run_test 2 + 3
6. To run a NetFPGA hardware test (generic test, not used in this example):
cd $SUME_FOLDER/tools/scripts
./nf_test.py hw --major <name> --minor <name>
If the hardware test fails, check your fibres and transceivers. Pay attention to any
error messages.
7 Common Issues
• Problem: Vivado’s GUI does not open.
Solution: 1) make sure to ssh using -X.
2) edit ˜/.bashrc. comment the line export DISPLAY=:0.
14
cd $P4_PROJECT_DIR && make config_writes
cd $NF_DESIGN_DIR/test/sim_<major>_<minor> && make
cd $P4_PROJECT_DIR && make install_sdnet
Note that packet reorder may cause a failure. You should also consider running the
simulation for a longer time if packets have not arrived. Make sure all configuration
writes are completed before any packets are sent.
8 Useful links
• NetFPGA Repository: https://github.com/NetFPGA/NetFPGA-SUME-live/
15