Skip to content
nithishkgnani edited this page Dec 24, 2021 · 27 revisions

Getting Started Guide

If you have not already done so, you will need to fill out the registration form in order to gain access to the P4->NetFPGA github repository.


Steps for initial setup:

  1. Go to the NetFPGA SUME System Setup wiki page and follow the instructions. Make sure to install all of the required dependencies.

    • Important: This project uses Vivado 2018.2. You will likely run into issues if you do not use this version of Vivado. Also, make sure to check the box indicating that you would like to install the SDK when installing Vivado.

    • Additional Dependencies (used in a couple of tests):

      • sudo apt-get install python-matplotlib
      • sudo apt-get install python-pip
      • sudo pip install ascii_graph
      • sudo apt-get install libc6-dev-i386
  2. You will need to have the licenses listed below installed in the path of your XILINXD_LICENSE_FILE environment variable. If you do not already have them you can submit a request through the Xilinx University Program to obtain them for free if you are associated with a university. In the request specify that you would like to have all of the licenses and tools necessary to use the P4->NetFPGA toolchain.

    • Xilinx Vivado
    • Xilinx P4-SDNet
    • Xilinx 10G MAC
  3. Obtain NetFPGA SUME board. Academic users may submit a request to purchase the SUME board at a discounted price by filling out this request form. Other users can purchase the SUME board through the Digilent website.

  4. Obtain and install Xilinx SDNet v2018.2. SDNet is restricted access, so it is only available on request. You can make a request here.

  5. Clone the repository:

    $ git clone https://github.com/NetFPGA/P4-NetFPGA-live.git P4-NetFPGA

    We recommended that you keep your repository updated with the latest changes from P4-NetFPGA-live. Although, if you would like to checkout a stable version see the release notes and checkout a particular tag:

    $ git pull --tags
    $ git checkout v1.2.0
    
  6. Update environment variables:

    • Edit P4-NetFPGA/tools/settings.sh. Update SUME_FOLDER to point to the installation location of the repo. Update P4_PROJECT_NAME to the name of the project you wish to work on.
  7. Environment Setup: It is recommended that users add the following lines to their ~/.bashrc file (adjusted to use your specific paths). And run $ source ~/.bashrc

##### Vivado #####
source /opt/Xilinx/Vivado/2018.2/settings64.sh

#### P4-NetFPGA #####
source ~/projects/P4-NetFPGA-live/tools/settings.sh

#### SDNet ####
export PATH=/opt/Xilinx/SDNet/2018.2/bin:$PATH
source /opt/Xilinx/SDNet/2018.2/settings64.sh

# point to Vivado license file and SDNet license file
export XILINXD_LICENSE_FILE= ...

# set DISPLAY env variable so that xsct works properly from cmdline
if [ -z "$DISPLAY" ]; then
    export DISPLAY=dummy
fi

  1. Build the SUME hardware library cores and some software to access registers:

    $ cd $SUME_FOLDER/lib/hw/xilinx/cores/tcam_v1_1_0/ && make update && make

    $ cd $SUME_FOLDER/lib/hw/xilinx/cores/cam_v1_1_0/ && make update && make

    $ cd $SUME_SDNET/sw/sume && make

    $ cd $SUME_FOLDER && make

  2. Build and load the SUME drivers:

    [root@nf-test109 ~]# cd $DRIVER_FOLDER
    [root@nf-test109 sume_riffa_v1_0_0]# make all
    [root@nf-test109 sume_riffa_v1_0_0]# make install
    [root@nf-test109 sume_riffa_v1_0_0]# modprobe sume_riffa
    [root@nf-test109 sume_riffa_v1_0_0]# lsmod | grep sume_riffa

Environment Variables

The NetFPGA-SUME-SDNet/tools/settings.sh script exports all of the environment variables used for the project. Here are some of the important ones:

  • $P4_PROJECT_NAME - The name of the P4 project currently being used. This name is used to identify both the name of the P4 project directory as well as the top level P4 source file.

  • $NF_PROJECT_NAME - The name of the SUME project directory that contains all of the files pertaining to testing and HDL development for the SUME platform. Currently, the only supported target is simple_sume_switch. Each P4 project should have its own local copy of simple_sume_switch.

  • $SUME_FOLDER - This should be set to the installation location of the P4-NetFPGA-live repository. This is the top level folder.

  • $SUME-SDNET - This is the main directory of the project that contains all of the scripts, templates, and tools that are used in the workflow. It also contains all of the P4 projects. It is located in P4-NetFPGA-live/contrib-projects/

  • $P4_PROJECT_DIR - Identifies the directory of the current P4 project being used.

  • $NF_DESIGN_DIR - Identifies the directory of the local simple_sume_switch

These environment variables can be used to easily navigate the directory structure.


P4_PROJECT_DIR Directory Description

${P4_PROJECT_DIR}
|-- src: contains the P4 source files and the commands.txt file
|-- testdata: contains the gen_testdata.py script
|-- sw: contains various software that is generated by the tools and any user software
|   |-- API: contains the API files generated by SDNet for interacting with the
|   |        tables in the P4 program. 
|   |-- CLI: run $ ./P4_SWITCH_CLI.py to start up an interactive command line tool
|   |        that can be used to query compile time information about the generated
|   |        design, as well as interact with the physical switch on the FPGA (i.e.
|   |        read/write registers, add/remove table entries, etc.)
|-- simple_sume_switch: the SUME project that contains SUME simulation infrastructure
|       as well as some source HDL files.
|-- nf_sume_sdnet_ip: the directory that is created by SDNet. It contains all of the
|       generated verilog files and a testbench that can be used for initial verification.

Tips:

  • Creating a New P4 Project: Run the following command when you would like to create a new P4 project. It will create a template project in $SUME_SDNET/projects/ to get you up and running quickly.

    $ $SUME_SDNET/bin/make_new_p4_proj.py <P4_PROJECT_NAME>

  • Review the reference projects in $SUME_SDNET/projects/ and go through the tutorial assignments.

  • Setting up Xilinx Licenses: There are two types of Xilinx licenses, node locked and floating licenses.

    • Node locked license:

      1. Generate the node locked license from the Xilinx license generation web page. Make sure to use the hostname and HostID (i.e. MAC address) of the machine on which you wish to use the Xilinx tool.
      2. Download the license onto your machine and add the path to it to your XILINXD_LICENSE_FILE environment variable.
    • Floating license:

      1. Generate the floating license from the Xilinx license generation web page. Make sure to use the hostname and HostID (i.e. MAC address) of the machine that will serve as the license server.
      2. Download the Xilinx license management tools (at the bottom of this page) onto the license server machine.
        • Alternatively, if you plan to install SDNet on the machine you plan to use as the license server then you can just use the license tools bundled with the install and there is no need to download these separately.
      3. Unzip the tools. For Ubuntu 14.04 you may also need to install lsb: $ sudo apt-get install lsb
      4. Run the following command to start the license server utility $ sudo /path/to/linux_flexlm_v11.13.1.3/lnx64.o/lmgrd -c /path/to/Xilinx.lic -l /path/to/Xilinx_licenses.log (Where Xilinx_licenses.log is a just a log file for the license utility)
        • Or if you are using the license tools bundled with the SDNet installation: $ sudo /path/to/SDNet/2017.1/bin/unwrapped/lnx64.o/lmgrd -c /path/to/Xilinx.lic -l /path/to/Xilinx_licenses.log
      5. This will start up the license utility on the default port 2100.
      6. Set the Xilinx license environment variables.
      export XILINXD_LICENSE_FILE=2100@<server_name>