Skip to content
Open

Ops #33

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
Language: Cpp
BasedOnStyle: Google
BinPackArguments: false
BinPackParameters: false
DerivePointerAlignment: false
PointerAlignment: Right
...
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "switchsai/submodules/SAI"]
path = switchsai/submodules/SAI
url = https://github.com/p4lang/SAI
[submodule "switchsai/submodules/ocpsai"]
path = switchsai/submodules/ocpsai
url = https://github.com/p4lang/ocpsai.git
105 changes: 105 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Config file for automatic testing at travis-ci.org

sudo: required

dist: trusty

language: c

# My very smart trick to force inclusion of the veth kernel module
# (even though we do not use docker at all her)
services:
- docker

env:
global:
- PYP_ADD="/usr/local/lib/python2.7/dist-packages:/usr/local/lib/python2.7/site-packages"
matrix:
- TEST_SCENARIO=switch
- TEST_SCENARIO=of

# There is probably some redundant stuff in this list. If you find one, remove
# it
addons:
apt:
packages:
- libjudy-dev
- libgmp-dev
- libpcap-dev
- libboost-dev
- libboost-test-dev
- libboost-program-options-dev
- libboost-system-dev
- libboost-filesystem-dev
- libboost-thread-dev
- libboost-test-dev
- libevent-dev
- automake
- libtool
- flex
- bison
- pkg-config
- g++
- libssl-dev
- doxygen
- git
- libedit-dev
- libevent-dev
- libfreetype6-dev
- libpng-dev
- libyaml-0-2
- libbz2-dev
- libnl-route-3-dev
- openssl
- pkg-config
- python-dev
- python-matplotlib
- python-numpy
- python-pip
- python-scipy
- python-setuptools
- python-yaml

# need to replace github ssh references with https
before_install:
- git submodule update --init --recursive
- sudo apt-get install ethtool
- sudo pip install --upgrade pip
- sudo pip install --upgrade thrift
- sudo pip install ctypesgen
- sudo pip install crc16

# install bmv2 before p4c-bmv2 to get nanomsg
install:
- wget https://s3-us-west-2.amazonaws.com/p4lang/thrift_bin.tar.gz
- tar -xzvf thrift_bin.tar.gz -C $HOME/
- export PATH=$PATH:$HOME/thrift/bin/
- export LDFLAGS="$LDFLAGS -L$HOME/thrift/lib"
- export CPPFLAGS="$CPPFLAGS -I$HOME/thrift/include"
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/thrift/lib
- mkdir install_tmp && cd install_tmp/
- sudo apt-get remove python-scapy
- git clone https://github.com/p4lang/scapy-vxlan.git && cd scapy-vxlan && sudo python setup.py install && cd ..
- cd .. && sudo rm -rf install_tmp/
- bash CI/travis/install-ptf.sh
- bash CI/travis/install-bmv2.sh
- bash CI/travis/install-p4c-bmv2.sh
- bash CI/travis/install-p4ofagent.sh
- export CPPFLAGS="$CPPFLAGS -I$HOME/p4ofagent/include"
- export LDFLAGS="$LDFLAGS -L$HOME/p4ofagent/lib"
- git clone https://github.com/floodlight/oftest.git oftest_tmp
- export PYTHONPATH=$PYP_ADD:$PYTHONPATH
- sudo ldconfig
- ./autogen.sh

before_script:
- cp CI/travis/veth_setup.sh tools/
- cd tools; sudo ./veth_setup.sh; sudo ./veth_disable_ipv6.sh; cd ..

script:
- if [ "$TEST_SCENARIO" = "switch" ] ; then ./configure --with-bmv2 --with-switchsai; fi
- if [ "$TEST_SCENARIO" = "of" ] ; then ./configure --with-bmv2 --with-of; fi
- make -j2
- if [ "$TEST_SCENARIO" = "switch" ] ; then ./CI/travis/run_switch_tests.sh; fi
- if [ "$TEST_SCENARIO" = "of" ] ; then ./CI/travis/run_of_tests.sh; fi

12 changes: 12 additions & 0 deletions CI/travis/install-bmv2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e
git clone https://github.com/p4lang/behavioral-model.git bmv2_tmp
cd bmv2_tmp
bash travis/install-nanomsg.sh
sudo ldconfig
bash travis/install-nnpy.sh
./autogen.sh
./configure 'CXXFLAGS=-O0' --with-pdfixed
make -j2 && sudo make install
cd ..
rm -rf bmv2_tmp
8 changes: 8 additions & 0 deletions CI/travis/install-p4c-bmv2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e
git clone https://github.com/p4lang/p4c-bm.git p4c-bmv2
cd p4c-bmv2
git submodule update --init --recursive
sudo pip install -r requirements.txt
sudo python setup.py install
cd ..
17 changes: 17 additions & 0 deletions CI/travis/install-p4ofagent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -e
git clone https://github.com/p4lang/p4ofagent.git p4ofagent_tmp
cd p4ofagent_tmp
git submodule update --init
cd submodules/indigo/
find -name ".gitmodules" -type f -exec sed -i 's/git@github.com:/https:\/\/github.com\//' {} \;
git submodule update --init
cd submodules/bigcode/
find -name ".gitmodules" -type f -exec sed -i 's/git@github.com:/https:\/\/github.com\//' {} \;
cd ../../../../
./autogen.sh
./configure --prefix=$HOME/p4ofagent
make p4ofagent CPPFLAGS="-D_BMV2_ -I$HOME/bmv2/include"
make install
cd ..
rm -rf p4ofagent_tmp
6 changes: 6 additions & 0 deletions CI/travis/install-ptf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e
git clone https://github.com/p4lang/ptf.git
cd ptf
sudo python setup.py install
cd ..
5 changes: 5 additions & 0 deletions CI/travis/run_of_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sudo ./bmv2/run_bm.sh &>/dev/null &
sleep 10
sudo ./bmv2/run_drivers.sh &>/dev/null &
sleep 10
sudo ./bmv2/run_of_tests.sh --oft-path oftest_tmp/oft
17 changes: 17 additions & 0 deletions CI/travis/run_switch_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
sudo ./bmv2/run_bm.sh &>/dev/null &
sleep 10
sudo ./bmv2/run_drivers.sh &>/dev/null &
sleep 10
sudo ./bmv2/run_tests.sh --test-dir tests/ptf-tests/api-tests
sudo killall bmswitchp4_drivers lt-bmswitchp4_drivers simple_switch lt-simple_switch; echo 0
sudo ./bmv2/run_bm.sh &>/dev/null &
sleep 10
sudo ./bmv2/run_drivers.sh &>/dev/null &
sleep 10
sudo ./bmv2/run_tests.sh --test-dir tests/ptf-tests/sai-tests
sudo killall bmswitchp4_drivers lt-bmswitchp4_drivers simple_switch lt-simple_switch; echo 0
sudo ./bmv2/run_bm.sh &>/dev/null &
sleep 10
sudo ./bmv2/run_drivers.sh &>/dev/null &
sleep 10
sudo ./bmv2/run_tests.sh
38 changes: 38 additions & 0 deletions CI/travis/veth_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
noOfVeths=18
if [ $# -eq 1 ]; then
noOfVeths=$1
fi
echo "No of Veths is $noOfVeths"
idx=0
let "vethpairs=$noOfVeths/2"
while [ $idx -lt $vethpairs ]
do
#1 2 3 4 5 6 7 125
intf0="veth$(($idx*2))"
intf1="veth$(($idx*2+1))"
idx=$((idx + 1))
if ! ip link show $intf0 &> /dev/null; then
ip link add name $intf0 type veth peer name $intf1
ip link set dev $intf0 up
ip link set dev $intf1 up
TOE_OPTIONS="rx tx sg tso ufo gso gro rxvlan txvlan"
for TOE_OPTION in $TOE_OPTIONS; do
/sbin/ethtool --offload $intf0 "$TOE_OPTION" off
/sbin/ethtool --offload $intf1 "$TOE_OPTION" off
done
fi
done
idx=125
intf0="veth$(($idx*2))"
intf1="veth$(($idx*2+1))"
if ! ip link show $intf0 &> /dev/null; then
ip link add name $intf0 type veth peer name $intf1
ip link set dev $intf0 up
ip link set dev $intf1 up
TOE_OPTIONS="rx tx sg tso ufo gso gro rxvlan txvlan"
for TOE_OPTION in $TOE_OPTIONS; do
/sbin/ethtool --offload $intf0 "$TOE_OPTION" off
/sbin/ethtool --offload $intf1 "$TOE_OPTION" off
done
fi
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
# P4FLAGS = -I .

SUBDIRS = p4src switchapi switchsai switchlink
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ Running switch in bmv2 without p4factory
You can now run `switch.p4` in bmv2 without cloning `p4factory`. In order to do
this you first need to install [bmv2]
(https://github.com/p4lang/behavioral-model) and its compiler [p4c-bmv2]
(https://github.com/p4lang/p4c-bm) on your system. Additionally, if you plan on
running the tests for `switch.p4`, please make sure you install [PTF]
(https://github.com/p4lang/p4c-bm) on your system. Note that when running
`./configure` for bmv2, you need to provide the `--with-pdfixed` option, as
switch requires the PD library. Additionally, if you plan on running the tests
for `switch.p4`, please make sure you install [PTF]
(https://github.com/p4lang/ptf) with `sudo python setup.py install`.

Once this is done, you can follow this steps:
Expand Down
8 changes: 8 additions & 0 deletions bmv2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This scripts are generated by configure
run_bm.sh
run_drivers.sh
run_tests.sh

gen-py.tar.lz
p4_pd
switch.json
39 changes: 39 additions & 0 deletions bmv2/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4

AM_CPPFLAGS += -DBMV2
AM_CPPFLAGS += -I$(top_builddir)/p4-build
AM_CPPFLAGS += -isystem$(includedir)

lib_LTLIBRARIES = libbmswitchp4.la
libbmswitchp4_la_CPPFLAGS = $(AM_CPPFLAGS)
libbmswitchp4_la_LIBADD =
if WITH_SWITCHLINK
libbmswitchp4_la_LIBADD += @top_builddir@/switchlink/libswitchlink.la
endif
if WITH_SWITCHSAI
libbmswitchp4_la_LIBADD += @top_builddir@/switchsai/libbmswitchsai.la
endif
if WITH_SWITCHAPI
libbmswitchp4_la_LIBADD += @top_builddir@/switchapi/libbmswitchapi.la
endif
if WITH_OF
libbmswitchp4_la_LIBADD += @top_builddir@/p4-build/bmv2/libof.la
endif
libbmswitchp4_la_LIBADD += \
@top_builddir@/p4-build/bmv2/libpd.la \
@top_builddir@/p4-build/bmv2/libpdthrift.la \
-lbmpdfixed -lbmpdfixedthrift $(THRIFT_LIB)
libbmswitchp4_la_SOURCES = \
bmv2_init.c

bin_PROGRAMS = bmswitchp4_drivers
bmswitchp4_drivers_CPPFLAGS = $(AM_CPPFLAGS)
bmswitchp4_drivers_LDADD = \
libbmswitchp4.la
if WITH_OF
bmswitchp4_drivers_LDADD += \
-lp4ofagent @top_builddir@/p4-build/bmv2/libof.la \
-lbmpdfixed -lpthread -lm
endif
bmswitchp4_drivers_SOURCES = \
main.c
Loading