-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added Behavioral Model * Updated readme adapter diagram * Update README.md * Update README.md Fixed links, rename sai_object to sai_adapter in readme * Update README.md * update namespace for SAI_arch * Update README.md * fixed logger for direct include of sai.h * Changed Behavioral_Model dir name to BM, minor fixes * added BM folder * Update README.md * removed external learn app * added teaming support module * renamed BM to lowercase bm * backup * . * Added behavioral-model as git submodule * Update README.md * Changed P4 target name to lower case * removed P4 test dir * fixed some makefiles * fixed target relocation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * rename build_p4_target.sh * rename build_p4_target.sh
- Loading branch information
Showing
193 changed files
with
54,044 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
|
||
# Python byet code | ||
*.pyc | ||
|
||
build/* | ||
lib* | ||
|
||
# Emacs | ||
*~ | ||
|
||
*.pcap | ||
|
||
# Tags | ||
GPATH | ||
GRTAGS | ||
GSYMS | ||
GTAGS | ||
|
||
tools/bm_runtime/ | ||
|
||
# Files generated by autotools | ||
.deps | ||
Makefile | ||
Makefile.in | ||
configure | ||
config.log | ||
config.h | ||
aclocal.m4 | ||
autom4te.cache/ | ||
compile | ||
config.h.in | ||
config.status | ||
depcomp | ||
install-sh | ||
missing | ||
stamp-h1 | ||
targets/simple_router/simple_router | ||
test-driver | ||
.dirstamp | ||
tests/test_* | ||
!tests/test_*.cpp | ||
!tests/testdata/*.pcap | ||
*.log | ||
*.trs | ||
config.guess | ||
config.sub | ||
ltmain.sh | ||
m4/ltoptions.m4 | ||
m4/ltsugar.m4 | ||
m4/ltversion.m4 | ||
m4/lt~obsolete.m4 | ||
py-compile | ||
.libs | ||
|
||
*.ts | ||
|
||
# gcov | ||
*.gcno | ||
*.gcda | ||
*.gcov | ||
|
||
# doxygen | ||
doxygen-out | ||
|
||
# thrift | ||
gen-cpp | ||
gen-py | ||
|
||
VERSION-build | ||
|
||
# dist archives | ||
*.tar.gz |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# SAI BEHAVIORAL MODEL | ||
This repository clearly defines widely accepted network switch behaviour. | ||
The switch behavioral model provides a commom framework for all network vendors and users. | ||
It meant to describe the standard ethernet switch features and flows. | ||
The model enables for both users and vendors to experiance the SAI switch model using SAI API over P4 soft switch. | ||
|
||
## Repository Structure | ||
The repository consist of: | ||
|
||
### [P4 soft-switch](p4-sai/) | ||
P4_14 source files to be complied by the p4c complier | ||
Can be independently configured via the CLI interface. | ||
### [SAI adapter](sai_adapter/) | ||
C source files implementation for the SAI API build for P4 soft switch model. | ||
SAI lib | ||
Tests frameworks: PTF, unittests. |
Submodule behavioral-model
added at
55b2b0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# backup behavioral-model original configs | ||
mv -f behavioral-model/configure.ac configure_bak.ac | ||
mv -f behavioral-model/targets/Makefile.am Makefile_bak.am | ||
cp -f p4-sai/bm_config/configure.ac behavioral-model/configure.ac | ||
cp -f p4-sai/bm_config/Makefile.am behavioral-model/targets/Makefile.am | ||
|
||
rm -rf behavioral-model/targets/p4-sai | ||
mv p4-sai behavioral-model/targets/. | ||
# make behavioral model, p4-sai target. | ||
|
||
cd behavioral-model/ | ||
./autogen.sh | ||
./configure | ||
make | ||
|
||
# return original config files | ||
cd - | ||
mv -f Makefile_bak.am behavioral-model/targets/Makefile.am | ||
mv -f configure_bak.ac behavioral-model/configure.ac | ||
|
||
# return compiled target | ||
mv behavioral-model/targets/p4-sai . | ||
|
||
# edit relative paths | ||
# cp simple_switch simple_switch_bak | ||
sed -i 's/P4\/SAI\/bm\/behavioral-model\/targets\/p4-sai/p4-sai/g' simple_switch | ||
sed -i 's/\.\.\/\.\.\/src\/bm_runtime\/\.libs\/libbmruntime\.a/\.\.\/behavioral-model\/src\/bm_runtime\/\.libs\/libbmruntime\.a/g' simple_switch | ||
sed -i 's/\.\.\/\.\.\/thrift_src\/\.libs/\.\.\/behavioral-model\/thrift_src\/\.libs/g' simple_switch | ||
rm runtime_CLI | ||
ln -s ../behavioral-model/tools/runtime_CLI.py runtime_CLI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/build | ||
/simple_switch | ||
/*.pcap | ||
sswitch_runtime | ||
simple_switch_CLI | ||
log.txt | ||
tests/CLI_tests/run_one_test.py | ||
log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# in case the src dir is used as the build dir | ||
exclude_files=gen-cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
SUBDIRS = . | ||
|
||
simple_switch_thrift_py_files = \ | ||
gen-py/sswitch_runtime/constants.py \ | ||
gen-py/sswitch_runtime/__init__.py \ | ||
gen-py/sswitch_runtime/SimpleSwitch.py \ | ||
gen-py/sswitch_runtime/ttypes.py | ||
simple_switch_thrift_files = \ | ||
gen-cpp/bm/simple_switch_constants.cpp \ | ||
gen-cpp/bm/simple_switch_constants.h \ | ||
gen-cpp/bm/SimpleSwitch.cpp \ | ||
gen-cpp/bm/SimpleSwitch.h \ | ||
gen-cpp/bm/simple_switch_types.cpp \ | ||
gen-cpp/bm/simple_switch_types.h | ||
|
||
BUILT_SOURCES = $(simple_switch_thrift_files) $(simple_switch_thrift_py_files) | ||
|
||
sswitchpydir = $(pythondir)/sswitch_runtime | ||
nodist_sswitchpy_PYTHON = $(simple_switch_thrift_py_files) | ||
|
||
python_PYTHON = sswitch_CLI.py | ||
|
||
# See | ||
# http://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Installation-Directory-Variables.html | ||
edit = sed \ | ||
-e 's|@pythondir[@]|$(pythondir)|g' | ||
|
||
simple_switch_CLI: Makefile | ||
rm -f $@ $@.tmp | ||
$(edit) $(srcdir)/$@.in >$@.tmp | ||
chmod +x $@.tmp | ||
chmod a-w $@.tmp | ||
mv $@.tmp $@ | ||
|
||
simple_switch_CLI: simple_switch_CLI.in | ||
|
||
EXTRA_DIST = \ | ||
simple_switch_CLI.in \ | ||
sswitch_CLI | ||
|
||
bin_SCRIPTS = \ | ||
simple_switch_CLI | ||
|
||
AM_CPPFLAGS += \ | ||
-I$(srcdir)/thrift/src/ \ | ||
-I$(builddir)/gen-cpp | ||
|
||
libsimpleswitch_la_LIBADD = \ | ||
$(top_builddir)/src/bm_sim/libbmsim.la \ | ||
$(top_builddir)/src/bf_lpm_trie/libbflpmtrie.la \ | ||
$(top_builddir)/src/BMI/libbmi.la \ | ||
$(top_builddir)/third_party/jsoncpp/libjson.la \ | ||
-lboost_system $(THRIFT_LIB) -lboost_program_options | ||
|
||
noinst_LTLIBRARIES = libsimpleswitch.la | ||
|
||
libsimpleswitch_la_SOURCES = \ | ||
simple_switch.cpp simple_switch.h primitives.cpp \ | ||
thrift/src/SimpleSwitch_server.cpp | ||
|
||
bin_PROGRAMS = simple_switch | ||
|
||
simple_switch_LDADD = \ | ||
$(top_builddir)/src/bm_runtime/libbmruntime.la \ | ||
$(top_builddir)/thrift_src/libruntimestubs.la \ | ||
libsimpleswitch.la \ | ||
libsimpleswitch_thrift.la | ||
|
||
simple_switch_SOURCES = main.cpp | ||
|
||
lib_LTLIBRARIES = libsimpleswitch_thrift.la | ||
|
||
nodist_libsimpleswitch_thrift_la_SOURCES = \ | ||
$(simple_switch_thrift_files) | ||
|
||
# See http://www.gnu.org/software/automake/manual/html_node/Multiple-Outputs.html | ||
|
||
THRIFT_IDL = $(srcdir)/thrift/simple_switch.thrift | ||
|
||
EXTRA_DIST += $(THRIFT_IDL) | ||
|
||
# We copy the generated Python code to srcdir/ if we have permissions (i.e. not | ||
# for 'make distcheck'). This is to ensure we can run the CLI easily. Maybe I | ||
# will think of a better solution later. | ||
thrift_files.ts: $(THRIFT_IDL) | ||
@rm -f thrift_files.tmp | ||
@touch thrift_files.tmp | ||
@mkdir -p $(builddir)/gen-cpp/bm | ||
$(THRIFT) -out $(builddir)/gen-cpp/bm --gen cpp -r $(THRIFT_IDL) | ||
$(THRIFT) -o $(builddir) --gen py -r $(THRIFT_IDL) | ||
if mkdir $(srcdir)/sswitch_runtime.test 2>/dev/null; then \ | ||
rm -rf $(srcdir)/sswitch_runtime/; \ | ||
cp -r $(builddir)/gen-py/sswitch_runtime/ $(srcdir)/; \ | ||
rm -rf $(srcdir)/sswitch_runtime.test; else :; \ | ||
fi | ||
@mv -f thrift_files.tmp $@ | ||
|
||
$(BUILT_SOURCES): thrift_files.ts | ||
## Recover from the removal of $@ | ||
@if test -f $@; then :; else \ | ||
trap 'rm -rf thrift_files.lock thrift_files.ts' 1 2 13 15; \ | ||
## mkdir is a portable test-and-set | ||
if mkdir thrift_files.lock 2>/dev/null; then \ | ||
## This code is being executed by the first process. | ||
rm -f thrift_files.ts; \ | ||
$(MAKE) $(AM_MAKEFLAGS) thrift_files.ts; \ | ||
result=$$?; rm -rf thrift_files.lock; exit $$result; \ | ||
else \ | ||
## This code is being executed by the follower processes. | ||
## Wait until the first process is done. | ||
while test -d thrift_files.lock; do sleep 1; done; \ | ||
## Succeed if and only if the first process succeeded. | ||
test -f thrift_files.ts; \ | ||
fi; \ | ||
fi | ||
|
||
nodist_pkginclude_HEADERS = \ | ||
gen-cpp/bm/simple_switch_constants.h \ | ||
gen-cpp/bm/SimpleSwitch.h \ | ||
gen-cpp/bm/simple_switch_types.h | ||
|
||
|
||
CLEANFILES = $(BUILT_SOURCES) \ | ||
thrift_files.ts \ | ||
gen-cpp/bm/SimpleSwitch_server.skeleton.cpp \ | ||
$(bin_SCRIPTS) | ||
|
||
# I used to do a rm on gen-cpp, but it was removing a .deps directory, instead I | ||
# am adding the skeleton file to CLEANFILES | ||
clean-local: | ||
rm -rf gen-py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# P4 SOFT SWITCH MODEL | ||
This repository contains P4 implementation of SAI behavioural model, forked from [p4lang/behavioural_model](https://github.com/p4lang/behavioral-model/). | ||
<a name="p4"></a> | ||
|
||
The Model is meant to provide a conformal behavioural SAI(https://github.com/opencomputeproject/SAI) model. | ||
It implements SAI 1.0 on top of soft switch coded via P4. | ||
|
||
## Compiling P4 Behavioural model | ||
For list of dependencies and build instructions: | ||
[p4lang/behavioural_model](https://github.com/p4lang/behavioral-model/). | ||
|
||
### Compiling P4 target | ||
Due to current behavioral-model implemntation, targets can only be complied in the bm/behavioral-model/targets/ dir. | ||
First time/every target (cpp) change, use: | ||
`bm/build_target.sh` | ||
|
||
### Create virtual interfaces | ||
To create the virtual interfaces and hosts. ```veth_setup.sh``` and remove them by ```veth_teardown.sh``` | ||
|
||
### Compiling P4 code | ||
If any editing to the P4 program was made, before running it you first need to transform the P4 code into a json representation which can be consumed by the software switch. This | ||
representation will tell bmv2 which tables to initialize, how to configure the | ||
parser, ... It is produced by the [p4c-bm](https://github.com/p4lang/p4c-bm) | ||
tool. Please take a look at the | ||
[README](https://github.com/p4lang/p4c-bm/blob/master/README.rst) for this repo | ||
to find out how to install it. Once this is done, | ||
use the script that is found inside the P4-SAI target directory as follows: | ||
|
||
./compile_json.sh | ||
### Running P4 program | ||
running the switch can be done with the following command: ```run_server.sh``` found in P4-SAI target directory. | ||
This script also implements some default configurations found in: p4src/DefaultConfig.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SUBDIRS = $(MAYBE_SECONDARY_TARGETS) p4-sai |
Oops, something went wrong.