diff --git a/.gitmodules b/.gitmodules
index 9e8fd47eb..00efc6e63 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,6 +4,3 @@
[submodule "test/saithrift/ctypesgen"]
path = test/saithrift/ctypesgen
url = https://github.com/davidjamesca/ctypesgen
-[submodule "bm/behavioral-model"]
- path = bm/behavioral-model
- url = https://github.com/p4lang/behavioral-model.git
diff --git a/bm/.gitignore b/bm/.gitignore
deleted file mode 100644
index e8c6df86c..000000000
--- a/bm/.gitignore
+++ /dev/null
@@ -1,100 +0,0 @@
-# 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
diff --git a/bm/.gitmodules b/bm/.gitmodules
deleted file mode 100644
index e69de29bb..000000000
diff --git a/bm/README.md b/bm/README.md
deleted file mode 100644
index a09cc8261..000000000
--- a/bm/README.md
+++ /dev/null
@@ -1,19 +0,0 @@
-# ** WARNING ** THIS DIRECTORY IS DEPRECATED AND WILL BE REMOVED END OF 2023
-# ** WARNING ** USE tests/saithriftv2 and sonic-net/DASH repo for bmv2/p4 model
-
-# 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.
diff --git a/bm/behavioral-model b/bm/behavioral-model
deleted file mode 160000
index 55b2b04fb..000000000
--- a/bm/behavioral-model
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 55b2b04fb3dbeb2762142db73627f3918f7bf7f2
diff --git a/bm/build_p4_target.sh b/bm/build_p4_target.sh
deleted file mode 100755
index a9dfb33c3..000000000
--- a/bm/build_p4_target.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/bash
-
-echo
-echo "** WARNING ** THIS DIRECTORY IS DEPRECATED AND WILL BE REMOVED END OF 2023"
-echo "** WARNING ** USE tests/saithriftv2 and sonic-net/DASH repo for bmv2/p4 model"
-echo
-
-sleep 10
-
-# 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
diff --git a/bm/p4-sai/.gitignore b/bm/p4-sai/.gitignore
deleted file mode 100644
index 1a844457c..000000000
--- a/bm/p4-sai/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-/build
-/simple_switch
-/*.pcap
-sswitch_runtime
-simple_switch_CLI
-log.txt
-tests/CLI_tests/run_one_test.py
-log*
\ No newline at end of file
diff --git a/bm/p4-sai/CPPLINT.cfg b/bm/p4-sai/CPPLINT.cfg
deleted file mode 100644
index 0499afd8c..000000000
--- a/bm/p4-sai/CPPLINT.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-# in case the src dir is used as the build dir
-exclude_files=gen-cpp
diff --git a/bm/p4-sai/Makefile.am b/bm/p4-sai/Makefile.am
deleted file mode 100644
index 95db5615e..000000000
--- a/bm/p4-sai/Makefile.am
+++ /dev/null
@@ -1,131 +0,0 @@
-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
diff --git a/bm/p4-sai/README.md b/bm/p4-sai/README.md
deleted file mode 100644
index 5f9168a12..000000000
--- a/bm/p4-sai/README.md
+++ /dev/null
@@ -1,33 +0,0 @@
-# P4 SOFT SWITCH MODEL
-This repository contains P4 implementation of SAI behavioural model, forked from [p4lang/behavioural_model](https://github.com/p4lang/behavioral-model/).
-
-
-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
diff --git a/bm/p4-sai/bm_config/Makefile.am b/bm/p4-sai/bm_config/Makefile.am
deleted file mode 100644
index 1b3565b86..000000000
--- a/bm/p4-sai/bm_config/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-SUBDIRS = $(MAYBE_SECONDARY_TARGETS) p4-sai
diff --git a/bm/p4-sai/bm_config/configure.ac b/bm/p4-sai/bm_config/configure.ac
deleted file mode 100644
index 5d92243b4..000000000
--- a/bm/p4-sai/bm_config/configure.ac
+++ /dev/null
@@ -1,271 +0,0 @@
-# -*- Autoconf -*-
-# Process this file with autoconf to produce a configure script.
-
-AC_PREREQ([2.68])
-AC_INIT([bm], [m4_esyscmd(tools/get_version.sh)],
- [antonin@barefootnetworks.com])
-AM_INIT_AUTOMAKE([foreign subdir-objects])
-AC_CONFIG_SRCDIR([src/bm_sim/checksums.cpp])
-AC_CONFIG_HEADERS([config.h])
-
-AC_SUBST([BM_VERSION], [AC_PACKAGE_VERSION])
-
-# Pyhton is optional to the package
-AM_PATH_PYTHON([2.7],, [:])
-
-coverage_enabled=no
-AC_ARG_ENABLE([coverage],
- AS_HELP_STRING([--enable-coverage], [Enable code coverage tracking]))
-AS_IF([test "x$enable_coverage" = "xyes"], [
- coverage_enabled=yes
- AC_DEFINE([COVERAGE], [], ["Link with gcov."])
- COVERAGE_FLAGS="-coverage"
-])
-
-AC_SUBST([COVERAGE_FLAGS])
-
-AC_ARG_WITH([targets],
- AS_HELP_STRING([--without-targets], [Do not build targets]),
- [], [want_targets=yes])
-
-AM_CONDITIONAL([COND_TARGETS], [test "$want_targets" = yes])
-
-want_stress_tests=no
-AC_ARG_WITH([stress_tests],
- AS_HELP_STRING([--with-stress-tests], [Include stress tests]),
- [want_stress_tests=yes], [])
-
-AM_CONDITIONAL([COND_STRESS_TESTS], [test "$want_stress_tests" = yes])
-
-want_pdfixed=no
-AC_ARG_WITH([pdfixed],
- AS_HELP_STRING([--with-pdfixed], [Build pdfixed for bmv2]),
- [want_pdfixed=yes], [])
-
-AM_CONDITIONAL([COND_PDFIXED], [test "$want_pdfixed" = yes])
-
-MY_CPPFLAGS=""
-
-AC_ARG_WITH([nanomsg],
- AS_HELP_STRING([--with-nanomsg], [Build Nanomsg RPC service, if disabled then you must have some other way of controlling the switch]),
- [want_nanomsg="$withval"], [want_nanomsg=yes])
-
-AM_CONDITIONAL([COND_NANOMSG], [test "$want_nanomsg" = yes])
-
-debugger_enabled=no
-AC_ARG_ENABLE([debugger],
- AS_HELP_STRING([--enable-debugger], [Enable bmv2 remote debugger]))
-AS_IF([test "x$enable_debugger" = "xyes"], [
- AS_IF([test "$want_nanomsg" = "yes"], [
- debugger_enabled=yes
- MY_CPPFLAGS="$MY_CPPFLAGS -DBMDEBUG_ON"
- ], [
- AC_MSG_ERROR([Cannot use debugger without nanomsg])
- ])
-])
-
-logging_macros_enabled=no
-AC_ARG_ENABLE([logging_macros],
- AS_HELP_STRING([--disable-logging-macros],
- [Disable compile time debug and trace logging macros]))
-AS_IF([test "x$enable_logging_macros" != "xno"], [
- logging_macros_enabled=yes
- MY_CPPFLAGS="$MY_CPPFLAGS -DBMLOG_DEBUG_ON -DBMLOG_TRACE_ON"
-])
-
-# BMELOG_ON is defined by default, since it is required for some tests
-elogger_enabled=no
-AC_ARG_ENABLE([elogger],
- AS_HELP_STRING([--disable-elogger],
- [Disable nanomsg event logger (some unit tests may fail)]))
-
-AS_IF([test "x$enable_elogger" != "xno"], [
- AS_IF([test "$want_nanomsg" = "yes"], [
- elogger_enabled=yes
- MY_CPPFLAGS="$MY_CPPFLAGS -DBMELOG_ON"
- ], [
- AC_MSG_WARN([Cannot use elogger without nanomsg])
- ])
-])
-
-AC_ARG_ENABLE([undeterministic_tests],
- AS_HELP_STRING([--disable-undeterministic-tests],
- [Skip undeterministic tests (e.g. queueing) when running "make check"]))
-AM_CONDITIONAL([SKIP_UNDETERMINISTIC_TESTS],
- [test "x$enable_undeterministic_tests" = "xno"])
-
-AC_ARG_WITH([thrift],
- AS_HELP_STRING([--with-thrift], [Build Thrift RPC service, if disabled then you must have some other way of controlling the switch]),
- [want_thrift="$withval"], [want_thrift=yes])
-
-AM_CONDITIONAL([COND_THRIFT], [test "$want_thrift" = yes])
-
-want_pi=no
-AC_ARG_WITH([pi],
- AS_HELP_STRING([--with-pi], [Build PI implementation for bmv2, this implementation is not the one included in the PI repository (which is the recommended one)]),
- [want_pi=yes], [])
-
-AM_CONDITIONAL([COND_PI], [test "$want_pi" = yes])
-
-# Checks for programs.
-AC_PROG_CXX
-AC_PROG_CC
-LT_INIT
-
-AC_CONFIG_MACRO_DIR([m4])
-
-# enforce -std=c++11
-AX_CXX_COMPILE_STDCXX_11([noext],[mandatory])
-
-# Checks for header files.
-AC_LANG_PUSH(C)
-AC_LANG_PUSH(C++)
-
-# Thrift
-want_p4thrift=no
-AC_ARG_WITH([p4thrift],
- AS_HELP_STRING([--with-p4thrift], [Use p4lang version of Thrift]),
- [want_p4thrift=yes], [])
-
-AS_IF([test "$want_thrift" = no && test "$want_p4thrift" = yes],
- [AC_MSG_ERROR(cannot use --with-p4thrift if Thrift is disabled)])
-
-AS_IF([test "$want_thrift" = no && test "$want_pdfixed" = yes],
- [AC_MSG_ERROR(cannot use --with-pdfixed if Thrift is disabled)])
-
-AS_IF([test "$want_thrift" = yes], [
- AS_IF([test "$want_p4thrift" = yes], [
- AC_PATH_PROG([THRIFT], [p4thrift], [])
- AC_SUBST([THRIFT_LIB], ["-lp4thrift"])
- MY_CPPFLAGS="$MY_CPPFLAGS -DP4THRIFT"
- AC_CHECK_HEADER([p4thrift/P4Thrift.h], [], [AC_MSG_ERROR([P4Thrift headers not found. Install P4Thrift from http://github.com/p4lang/thrift/])])
- ], [
- AC_PATH_PROG([THRIFT], [thrift], [])
- AC_SUBST([THRIFT_LIB], ["-lthrift"])
- AC_CHECK_HEADER([thrift/Thrift.h], [], [AC_MSG_ERROR([Thrift headers not found. Install Thrift from http://thrift.apache.org/docs/install/])])
- ])
- AS_IF([test x"$THRIFT" = x], [AC_MSG_ERROR([cannot find thrift])])
- MY_CPPFLAGS="$MY_CPPFLAGS -DBMTHRIFT_ON"
-])
-
-AS_IF([test "$want_pi" = yes], [
- PI_url=https://github.com/p4lang/PI/
- AC_CHECK_HEADERS([PI/pi.h PI/target/pi_imp.h PI/p4info.h], [],
- [AC_MSG_ERROR([Cannot find PI headers, did you install $PI_url])])
-])
-
-AM_CONDITIONAL([P4THRIFT], [test "$want_p4thrift" = yes])
-
-AC_CHECK_HEADERS([algorithm array cassert cmath queue \
-cstdio string sys/stat.h sys/types.h ctime tuple unistd.h unordered_map \
-utility vector], [], [AC_MSG_ERROR([Missing header file])])
-
-AS_IF([test "$want_nanomsg" = yes], [
- AC_CHECK_LIB([nanomsg], [nn_errno], [], [AC_MSG_ERROR([Missing libnanomsg])])
- MY_CPPFLAGS="$MY_CPPFLAGS -DBMNANOMSG_ON"
-])
-
-# Check for pthread, libjudy, libgmp, libpcap
-AX_PTHREAD([], [AC_MSG_ERROR([Missing pthread library])])
-AC_CHECK_LIB([Judy], [Judy1Next], [], [AC_MSG_ERROR([Missing libJudy])])
-AC_CHECK_LIB([gmp], [__gmpz_init], [], [AC_MSG_ERROR([Missing libgmp])])
-AC_CHECK_LIB([pcap], [pcap_create], [], [AC_MSG_ERROR([Missing libpcap])])
-AC_CHECK_LIB([pcap], [pcap_set_immediate_mode], [pcap_fix=yes], [pcap_fix=no])
-if test -n "$COVERAGE_FLAGS"; then
- AC_CHECK_LIB([gcov], [__gcov_init], [], [AC_MSG_ERROR([Missing gcov library])])
-fi
-
-AC_MSG_CHECKING(for compiler atomic support)
-AC_LINK_IFELSE(
- [AC_LANG_SOURCE(
- [[#include
- int main() {
- struct C { int x; int y; };
- std::atomic c;
- C c1 = c.load();
- C c2;
- do { c2.x = c1.x + 1; c2.y = c1.y + 1; }
- while (!c.compare_exchange_weak(c1, c2));
- return 0;
- }
- ]])],
- [AC_MSG_RESULT(yes)],
- [AC_MSG_RESULT(no)
- AC_MSG_NOTICE([using -latomic])
- AX_CXX_CHECK_LIB([atomic], [__atomic_load_4], [], AC_MSG_ERROR([Missing latomic]))
- ])
-
-AM_CONDITIONAL([WITH_PCAP_FIX], [test "$pcap_fix" = "yes"])
-
-# C++ libraries are harder (http://nerdland.net/2009/07/detecting-c-libraries-with-autotools/),
-# so use headers to check
-AC_CHECK_HEADER([boost/thread.hpp], [], [AC_MSG_ERROR([Boost threading headers not found])])
-# need to check at least for the libboost_thread since it is -mt.so
-AX_CXX_CHECK_LIB([boost_thread], [boost::thread], [],
- [AX_CXX_CHECK_LIB([boost_thread-mt], [boost::thread],
- [LIBS="-lboost_thread-mt $LIBS"],
- [AC_MSG_ERROR([Missing boost thread library])])])
-AC_CHECK_HEADER([boost/multiprecision/gmp.hpp], [], [AC_MSG_ERROR([Missing boost Multiprecision headers])])
-AC_CHECK_HEADER([boost/program_options.hpp], [], [AC_MSG_ERROR([Missing boost program options header])])
-AC_CHECK_HEADER([boost/functional/hash.hpp], [], [AC_MSG_ERROR([Missing boost functional hash header])])
-AC_CHECK_HEADER([boost/filesystem.hpp], [], [AC_MSG_ERROR([Missing boost filesystem header])])
-
-AC_SUBST([AM_CPPFLAGS], ["$MY_CPPFLAGS \
- -I\$(top_srcdir)/include \
- -isystem\$(top_srcdir)/third_party/jsoncpp/include \
- -isystem\$(top_srcdir)/third_party/spdlog"])
-
-AC_SUBST([AM_CXXFLAGS], ["$PTHREAD_CFLAGS -Wall -Werror -Wextra"])
-AC_SUBST([AM_CFLAGS], ["$PTHREAD_CFLAGS"])
-
-# Checks for typedefs, structures, and compiler characteristics.
-# not supported by autoconf 2.68, add to m4/ ?
-# AC_CHECK_HEADER_STDBOOL
-AC_TYPE_SIZE_T
-AC_TYPE_UINT64_T
-AC_LANG_POP(C++)
-
-# Generate makefiles
-AC_CONFIG_FILES([Makefile
- thrift_src/Makefile
- third_party/Makefile
- third_party/gtest/Makefile
- third_party/jsoncpp/Makefile
- third_party/spdlog/Makefile
- include/Makefile
- src/Makefile
- src/bf_lpm_trie/Makefile
- src/bm_sim/Makefile
- src/bm_runtime/Makefile
- src/BMI/Makefile
- src/bm_apps/Makefile
- src/bm_apps/examples/Makefile
- targets/Makefile
- targets/p4-sai/Makefile
- tests/Makefile
- tests/stress_tests/Makefile
- tools/Makefile
- pdfixed/Makefile
- pdfixed/include/Makefile
- PI/Makefile])
-
-# Generate other files
-AC_CONFIG_FILES([tests/utils.cpp
- src/bm_sim/version.cpp
- mininet/stress_test_ipv4.py])
-
-AC_OUTPUT
-
-AS_ECHO("")
-AS_ECHO("Features recap ......................")
-AS_ECHO("Coverage enabled .............. : $coverage_enabled")
-AS_ECHO("Logging macros enabled ........ : $logging_macros_enabled")
-AS_ECHO("With Nanomsg .................. : $want_nanomsg")
-AS_ECHO("Event logger enabled .......... : $elogger_enabled")
-AS_ECHO("Debugger enabled .............. : $debugger_enabled")
-AS_ECHO("With Thrift ................... : $want_thrift")
-AS_IF([test "$want_thrift" = yes], [
-AS_ECHO(" With p4Thrift ............... : $want_p4thrift")
-])
-AS_ECHO("With pdfixed .................. : $want_pdfixed")
-AS_ECHO("With PI ....................... : $want_pi")
diff --git a/bm/p4-sai/compile_json.sh b/bm/p4-sai/compile_json.sh
deleted file mode 100755
index c1923ac9d..000000000
--- a/bm/p4-sai/compile_json.sh
+++ /dev/null
@@ -1 +0,0 @@
-p4c-bmv2 --p4-v1.1 --json sai.json p4src/sai.p4
\ No newline at end of file
diff --git a/bm/p4-sai/copy_to_cpu_test_commands.txt b/bm/p4-sai/copy_to_cpu_test_commands.txt
deleted file mode 100644
index 980c0702b..000000000
--- a/bm/p4-sai/copy_to_cpu_test_commands.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-table_add table_l2_trap action_set_trap_id 00:00:00:00:01:00 => 5
-table_add table_trap_id action_copy_to_cpu 5 =>
-table_add table_fdb action_set_egress_br_port 00:00:00:00:01:00 1 => 3
diff --git a/bm/p4-sai/docs/JSON_format.md b/bm/p4-sai/docs/JSON_format.md
deleted file mode 100644
index 2bda54068..000000000
--- a/bm/p4-sai/docs/JSON_format.md
+++ /dev/null
@@ -1,384 +0,0 @@
-# BMv2 JSON input format
-
-All bmv2 target switches take as input a JSON file, whose format is essentially
-target independent. The format is very simple and several examples can be found
-in this repository, including [here]
-(../targets/simple_router/simple_router.json).
-
-This documents attempt to describe the expected JSON schema and the constraints
-on each attribute. There is some ongoing work to write a formal JSON schema as
-per [this specification] (http://json-schema.org/).
-
-## General information
-
-Tentative support for signed fields (with a 2 complement representation) has
-been added to bmv2, although they are not supported in P4 1.0 or by the [p4c-bm
-compiler] (https://github.com/p4lang/p4c-bm). However, signed constants (in
-expressions, or as primitive arguments) are always supported.
-Arithmetic is done with infinite precision, but when a value is copied into a
-field, it is truncated based on the field's bitwidth.
-
-## Format
-
-### The type value object
-
-You will see many places where a JSON object with 2 attributes, `type` and
-`value`, is expected (for example, action primitive arguments). This is the
-convention we follow:
-- if `type` is `field`, `value` is a JSON 2-tuple, where the first item is the
-header instance name and the second is the field member name.
-- if `type` is `hexstr`, `value` is a bitstring written in hexadecimal (big
-endian order); it can be prefixed with a negative sign, for negative values.
-- if `type` is `bool`, `value` is either `true` or `false`.
-- if `type` is a named P4 type (`header`, `header_stack`, `calculation`,
-`register_array`, `meter_array`, `counter_array`), `value` is a string
-corresponding to the name of the designated object.
-- if `type` is `lookahead` (parser only), `value` is a JSON 2-tuple, where the
-first item is the bit offset for the lookahead and the second item is the
-bitwidth.
-- if `type` is `expression`, `value` is a JSON object with 3 attributes:
- - `op`: the operation performed (`+`, `-`, `*`, `<<`, `>>`, `==`, `!=`, `>`,
- `>=`, `<`, `<=`, `and`, `or`, `not`, `&`, `|`, `^`, `~`, `valid`)
- - `left`: the left side of the operation, or `null` if unary operation
- - `right`: the right side of the operation
-
-For an expression, `left` and `right` will themselves be JSON objects, where the
-`value` attribute can be one of `field`, `hexstr`, `header`, `expression`,
-`bool`.
-
-bmv2 also supports these recently-added operations:
- - data-to-bool conversion (`op` is `d2b`): unary operation which can be used
-to explicitly convert a data value (i.e. a value that can be read from /
-written to a field, or a value obtained from runtime action data, or a value
-obtained from a JSON `hexstr`) to a boolean value. Note that implicit
-conversions are not supported.
- - bool-to-data conversion (`op` is `b2d`): unary operation which can be used
-to explicitly convert a boolean value to a data value. Note that implicit
-conversions are not supported.
- - 2-complement modulo (`op` is `two_comp_mod`): given a source data value and
-a width data value, produces a third data value which is the signed value of the
-source given a 2-complement representation with that width. For example,
-`two_comp_mod(257, 8) == 1` and `two_comp_mod(-129, 8) == 127`.
- - ternary operator (`op` is `?`): in addition to `left` and `right`, the JSON
-object has a fourth attribute, `cond` (condition), which is itself an
-expression. For example, in `(hA.f1 == 9) ? 3 : 4`, `cond` would be the JSON
-representation of `(hA.f1 == 9)`, `left` would be the JSON representation of `3`
-and `right` would be the JSON representation of `4`.
-
-For field references, some special values are allowed. They are called "hidden
-fields". For now, we only support one kind of hidden fields: `.$valid$`. This field is a 1-bit field which encodes the validity of the
-corresponding header. It is a read-only field. It can be used just like any
-other field; in particular as part of a match-table key or in a control-flow
-condition. In the long run, this field will completely replace the valid match
-type and the `valid()` built-in (in expressions), but we are not there yet.
-
-
-The attributes of the root JSON dictionary are:
-
-### `header_types`
-
-It is a JSON array of all the header types defined in the P4 program. Each array
-item has the following attributes:
-- `name`: fully qualified P4 name of the header type
-- `id`: a unique integer (unique with respect to other header types)
-- `fields`: a JSON array of JSON 2-tuples (field member name, field width in
-bits). Note that the JSON 2-tuples can optionally be JSON 3-tuples if you want
-to experiment with signed fields support. In this case, the third element of the
-tuples is a boolean value, which is `true` iff the field is signed. A signed
-field needs to have a bitwidth of at least 2!
-
-### `headers`
-
-It is a JSON array of all the header instances (including metadata) declared in
-the P4 program. Each array item has the following attributes:
-- `name`
-- `id`: a unique integer (unique with respect to other header instances)
-- `header_type`: the `name` of the header type for this header instance
-- `metadata`: a boolean value, `true` iff the instance is a metadata instance
-
-### `header_stacks`
-
-It is a JSON array of all the header stacks declared in the P4 program. Each
-array item has the following attributes:
-- `name`
-- `id`: a unique integer (unique with respect to other header stacks)
-- `header_type`: the `name` of the header type for this stack
-- `header_ids`: a JSON array of integers; each integer being the unique `id` of
-a header instance included in the stack. These ids have to be in the correct
-order: stack[0], stack[1], ...
-
-### `parsers`
-
-It is a JSON array of all the parsers declared in the P4 program. Each array
-item has the following attributes:
-- `name`
-- `id`: a unique integer (unique with respect to other parsers)
-- `init_state`: the name of the start state for the parser
-- `parse_states`: a JSON array of JSON objects. Each of these objects stores the
-information for a given parse state in the program, which is used by the current
-parser. The attributes for these objects are:
- - `name`
- - `id`: a unique integer; note that it has to be unique with respect to *all*
- parse states in the JSON file, not just the parse states included in this
- parser object
- - `parser_ops`: a JSON array of the operations (set or extract) performed in
- this parse state, in the correct order. Each parser operation is represented
- by a JSON object, whose attributes are:
- - `op`: the type of operation, either `extract` or `set`
- - `parameters`: a JSON array of objects encoding the parameters to the
- parser operation. Each parameter object has 2 string attributes: `type` for
- the parameter type and `value` for its value. Depending on the type of
- operation, the constraints are different. An extract operation only takes
- one parameter, of type `regular` (extraction to a regular header instance)
- or `stack` (extraction to the end of a header stack). `value` is then the
- name of the header instance or stack. On the other hand, a set operation
- takes exactly 2 parameters. The first one needs to be of type `field` with
- the appropriate value. The second one can be of type `field`, `hexstr`,
- `lookahead` or `expression`, with the appropriate value (see [here]
- (#the-type-value-object)).
- - `transition_key`: a JSON array (in the correct order) of objects which
- describe the different fields of the parse state transition key. Each object
- has 2 attributes, `type` and `value`, where `type` can be either
- `field`, `stack_field` (for a field of the last extracted instance in a
- stack) or `lookahead` (see [here] (#the-type-value-object)).
- - `transitions`: a JSON array of objects encoding each parse state
- transition. The different attributes for these objects are:
- - `type`: either `default` (for the default transition), `hexstr` (for a
- regular hexstring value-based transition) or `parse_vset` (for a parse
- value-set).
- - `value`: only relevant if the `type` attribute is `hexstr`, in which case
- it is the hexstring value for the transition, or `parse_vset`, in which case
- it is the name of the corresponding parse value-set. Set to `null` if `type`
- is `hexstr`.
- - `mask`: only relevant if the `type` attribute is `hexstr` or `parse_vset`
- (`null` if `type` is `default`). It can either be a hexstring (to be used as
- a mask and ANDed with the key and the value) or `null`. For a parse
- value-set, the mask will be ANDed with each value in the set when checking
- for a match.
- - `next_state`: the name of the next parse state, or `null` if this is the
- last state in the parser.
-
-For values and masks, make sure that you use the correct format. They need to be
-the concatenation (in the right order) of all byte padded fields (padded with
-`0` bits). For example, if the transition key consists of a 12-bit field and a
-2-bit field, each value will need to have 3 bytes (2 for the first field, 1 for
-the second one). If the transition value is `0xaba`, `0x3`, the `value`
-attribute will be set to `0x0aba03`.
-
-### `parse_vsets`
-
-It is a JSON array of all the parse value-sets declared in the P4 program. Each
-array item has the following attributes:
-- `name`
-- `id`: a unique integer (unique with respect to other parse value-sets)
-- `compressed_bitwidth`: the bitwidth of the values which can be added to the
-set. Note that this bitwidth does not include any padding.
-
-### `deparsers`
-
-It is a JSON array of all the deparsers declared in the P4 program (or inferred
-from P4 parsers). Each array item has the following attributes:
-- `name`
-- `id`: a unique integer (unique with respect to other deparsers)
-- `order`: a JSON array of sorted header instance names. When the target switch
-invokes a deparser, the headers will be serialized in this order, and non-valid
-headers will be skipped.
-
-### `meter_arrays`
-
-It is a JSON array of all the meter arrays declared in the P4 program. Each
-array item has the following attributes:
-- `name`
-- `id`: a unique integer (unique with respect to other meter arrays)
-- `type`: either `bytes` or `packets`
-- `rate_count`: the number of rates for the meters. By default P4 uses 2-rate
-3-color meters
-- `size`: the number of meter instances in the array
-- `is_direct`: a boolean indicating whether this is a direct meter array
-- `binding`: if the meter array is direct, the name of the table it is attached
-to
-- `result_target`: a 2-tuple representing the field where the meter result
-(color) will be stored; only taken into account if `is_direct` is `true`.
-
-### `counter_arrays`
-
-It is a JSON array of all the counter arrays declared in the P4 program. Each
-array item has the following attributes:
-- `name`
-- `id`: a unique integer (unique with respect to other counter arrays)
-- `size`: the number of counter instances in the array
-- `is_direct`: a boolean indicating whether this is a direct counter array
-- `binding`: if the counter array is direct, the name of the table it is
-attached to
-
-Unlike for meter arrays, there is no `type` attribute because bmv2 counters
-always count both bytes and packets.
-
-### `register_arrays`
-
-It is a JSON array of all the register arrays declared in the P4 program. Each
-array item has the following attributes:
-- `name`
-- `id`: a unique integer (unique with respect to other register arrays)
-- `size`: the number of register instances in the array
-- `bitwidth`: the width in bits of each register cell
-
-### `actions`
-
-It is a JSON array of all the actions declared in the P4 program. Each array
-item has the following attributes:
-- `name`
-- `id`: a unique integer (unique with respect to other actions)
-- `runtime_data`: a JSON array of objects, each one representing a named
-parameter of the action. Each object has exactly 2 attributes:
- - `name`: the P4 name of the parameter
- - `bitwidth`: the integral width, in bits, of the parameter
-- `primitives`: a JSON array of objects, each one representing a primitive
-call, with the following attributes:
- - `op`: the primitive name. This primitive has to be supported by the target.
- - `parameters`: a JSON array of the arguments passed to the primitive (has to
- match the target primitive definition). Each argument is represented by a JSON
- object with the following attributes:
- - `type`: one of `hexstr`, `runtime_data`, `header`, `field`, `calculation`,
- `meter_array`, `counter_array`, `register_array`, `header_stack`,
- `expression`, `extern`
- - `value`: the appropriate parameter value. If `type` is `runtime_data`,
- this is an integer representing an index into the `runtime_data` (attribute
- of action) array. If `type` is `extern`, this is the name of the extern
- instance. See [here] (#the-type-value-object) for other types.
-
-*Important note about extern instance methods*: even though in P4 these are
-invoked using object-oriented style, bmv2 treats them as regular primitives for
-which the first parameter is the extern instance. For example, if the P4 call is
-`extern1.methodA(x, y)`, where `extern1` is an extern instance of type
-`my_extern_type`, the bmv2 compiler needs to translate this into a call to
-primitive `_my_extern_type_methodA`, with the first parameter being `{"type":
-"extern", "value": "extern1"}` and the second parameter being the appropriate
-representation for `x` and `y`.
-
-### `pipelines`
-
-It is a JSON array of all the top control flows (ingress, egress) in the P4
-program. Each array item has the following attributes:
-- `name`
-- `id`: a unique integer (unique with respect to other pipelines)
-- `init_table`: the name of the first table of the pipeline
-- `tables`: a JSON array of JSON objects. Each of these objects stores the
-information for a given P4 table, which is used by the current pipeline. The
-attributes for these objects are:
- - `name`
- - `id`: a unique integer; note that it has to be unique with respect to *all*
- tables in the JSON file, not just the tables included in this parser object
- - `match_type`: one of `exact`, `lpm` or `ternary`
- - `type`: the implementation for the table, one of `simple`, `indirect`
- (action profiles), `indirect_ws` (action profiles with dynamic selector)
- - `max_size`: an integer representing the size of the table
- - `with_counters`: a boolean, `true` iff the match table has direct counters
- - `support_timeout`: a boolean, `true` iff the match table supports ageing
- - `key`: the lookup key format, represented by a JSON array. Each member of
- the array is a JSON object with the following attributes:
- - `match_type`: one of `valid`, `exact`, `lpm`, `ternary`
- - `target`: the field reference as a 2-tuple (or header as a string if
- `match_type` if `valid`)
- - `mask`: the static mask to be applied to the field, or null. Just like for
- the parser transition key, make sure that this mask is byte-padded and has
- the same width (in bytes) as the corresponding field (1 byte if `match_type`
- is `valid`).
- - `actions`: the list of actions (order does not matter) supporyed by this
- table
- - `next_tables`: maps each action tp a next table name. Alternatively, maps
- special string `__HIT__` and `__MISS__` to a next table name.
- - `direct_meters`: the name of the associated direct meter array, or null if
- the match table has no associated meter array
- - `default_entry`: an optional JSON item which can force the default entry for
- the table to be set when loading the JSON, without intervention from the
- control plane. It has the following attributes:
- - `action_id`: the id of the default action
- - `action_const`: an optional boolean value which is `true` iff the control
- plane is not allowed to change the default action function. Default value is
- `false`.
- - `action_data`: an optional JSON array where each entry is the hexstring
- value for an action argument. The size of the array needs to match the
- number of parameters expected by the action function with id `action_id`.
- - `action_entry_const`: an optional boolean value which is `true` iff the
- control plane is not allowed to modify the action entry (action function +
- action data). Default value is `false`. This attribute is ignored if the
- `action_data` attribute it missing.
-- `conditionals`: a JSON array of JSON objects. Each of these objects stores the
-information for a given P4 condition, which is used by the current pipeline. The
-attributes for these objects are:
- - `name`
- - `id`: a unique integer; note that it has to be unique with respect to *all*
- conditions in the JSON file, not just the conditions included in this parser
- object
- - `expression`: the expression for the condition. See [here]
- (#the-type-value-object) for more information on expressions format.
-
-If the table `type` is `indirect_ws`, the `selector` attribute is also
-required for the table. It needs to be a JSON object with these attributes:
- - `algo`: the hash algorithm used for group member selection (has to be
- supported by target switch)
- - `input`: a JSON array of objects with the following attributes:
- - `type`: has to be `field`
- - `value`: the field reference
-
-The `match_type` for the table needs to follow the following rules:
-- If one match field is `ternary`, the table `match_type` has to be `ternary`
-- If one match field is `lpm`, the table `match_type` is either `ternary` or
-`lpm`
-Note that it is not correct to have more than one `lpm` match field in the same
-table.
-
-### `calculations`
-
-It is a JSON array of all the named calculations in the P4 program. In
-particular, they are used for checksums. Each array item has the following
-attributes:
-- `name`
-- `id`: a unique integer (unique with respect to other calculations)
-- `algo`: the hash algorithm used (has to be supported by target switch)
-- `input`: a JSON array of objects with the following attributes:
- - `type`: one of `field`, `hexstr`, `header`, `payload`
- - `value`: the appropriate value or reference (see [here]
- (#the-type-value-object))
-
-If `type` is `payload`, all the headers present after the last included header
-(or after the enclosing header of the last included field) will be included in
-the input, as well as the packet payload. This is necessary for TCP checksum
-computation.
-
-If a header is not valid when the calculation is evaluated, it will be skipped.
-
-### `checksums`
-
-It is a JSON array of all the checksums in the P4 program. Each array item has
-the following attributes:
-- `name`
-- `id`: a unique integer (unique with respect to other checksums)
-- `target`: the field where the checksum result is written
-- `type`: always set to `generic`
-- `calculation`: the name of the calculation to use to compute the checksum
-- `if_cond`: null if the checksum needs to be updated unconditionally, otherwise
-a boolean expression, which will determine whether or not the checksum gets
-updated. See [here]
- (#the-type-value-object) for more information on expressions format.
-
-### `learn_lists`
-
-Not documented yet, use empty JSON array.
-
-### `extern_instances`
-
-It is a JSON array of all the extern instances in the P4 program. Each array
-item has the following attributes:
-- `name`
-- `id`: a unique integer (unique with respect to other extern instances)
-- `type`: the name of the extern type, the target switch needs to support this
-type
-- `attribute_values`: a JSON array with the initial values for the attributes of
-this extern instance. Each array item has the following attributes:
- - `name`: the name of the attribute
- - `type`: the type of the attribute, only `hexstr` (integral values), `string`
- (for character sequences) and `expression` are supported for now
- - `value`: the initial value for the attribute
diff --git a/bm/p4-sai/docs/SAI_arch.PNG b/bm/p4-sai/docs/SAI_arch.PNG
deleted file mode 100644
index 8d06f645e..000000000
Binary files a/bm/p4-sai/docs/SAI_arch.PNG and /dev/null differ
diff --git a/bm/p4-sai/docs/p4dbg_user_guide.md b/bm/p4-sai/docs/p4dbg_user_guide.md
deleted file mode 100644
index 4d3bb9744..000000000
--- a/bm/p4-sai/docs/p4dbg_user_guide.md
+++ /dev/null
@@ -1,282 +0,0 @@
-
-
-**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
-
-- [P4 Debugger (p4dbg) user guide](#p4-debugger-p4dbg-user-guide)
- - [List of commands](#list-of-commands)
- - [General information about the debugger](#general-information-about-the-debugger)
- - [The packet id](#the-packet-id)
- - [Special field names](#special-field-names)
- - [A more detailed list of commands](#a-more-detailed-list-of-commands)
- - [`set_wp (w)`](#set_wp-w)
- - [`unset_wp`](#unset_wp)
- - [`show_wps`](#show_wps)
- - [`break (b)`](#break-b)
- - [`delete (d)`](#delete-d)
- - [`show_bps`](#show_bps)
- - [`continue (c)`](#continue-c)
- - [`next (n)`](#next-n)
- - [`print (p)`](#print-p)
- - [`backtrace (bt)`](#backtrace-bt)
- - [`break_packet_in`](#break_packet_in)
- - [`remove_packet_in`](#remove_packet_in)
- - [`stop_packet_in`](#stop_packet_in)
- - [`resume_packet_in`](#resume_packet_in)
- - [`filter_notifications`](#filter_notifications)
- - [`reset`](#reset)
- - [`skip` -- experimental](#skip----experimental)
- - [`skip_all` -- experimental](#skip_all----experimental)
- - [`CLI` -- experimental](#cli----experimental)
- - [Future extensions](#future-extensions)
-
-
-
-# P4 Debugger (p4dbg) user guide
-
-## List of commands
-
-Here is a full list of commands with a short description. More details will be
-found for each command later in this document. The last 3 commands (`skip`,
-`skip_all` and `CLI`) are still experimental.
-
-| Command name | Short | Description |
-| ---------------------- | ----- | ----------- |
-| `set_wp` | `w` | Sets a watchpoint on a field |
-| `unset_wp` | `N/A` | Unsets watchpoint |
-| `show_wps` | `N/A` | Lists active watchpoints |
-| `break` | `b` | Breaks at a specific "P4 object" |
-| `delete` | `d` | Deletes breakpoint |
-| `show_bps` | `N/A` | Lists active breakpoints |
-| `continue` | `c` | Starts / resumes packet processing at the switch |
-| `next` | `n` | Go to next update (field or “P4 context”) |
-| `print` | `p` | Prints the value of a field |
-| `backtrace` | `bt` | Prints a backtrace of “P4 contexts” entered by the packet |
-| `break_packet_in` | `N/A` | Breaks every time a packet enters the switch |
-| `remove_packet_in` | `N/A` | Undoes the break_packet_in command |
-| `stop_packet_in` | `N/A` | Prevents the switch from accepting any more packets |
-| `resume_packet_in` | `N/A` | Undoes the stop_packet_in command |
-| `filter_notifications` | `N/A` | Restricts the received notifications to a subset of packets |
-| `reset` | `N/A` | Resets all the debugger’s state |
-| `skip` (exp) | `N/A` | Skips all future notifications for the current packet |
-| `skip_all` (exp) | `N/A` | Skips all future notifications for the current packet and its descendants |
-| `CLI` (exp) | `N/A` | Connects to the switch using the Runtime CLI and issues a command |
-
-## General information about the debugger
-
-### The packet id
-
-Each packet going through the switch can be identified using its "full packet
-id", which is of the form `.`. Note that every time you receive an
-event notification in the debugger, the packet id will be included in the
-displayed message. The `` is incremented by one every time a new packet is
-received by the switch. The `` is incremented by one every time a new
-packet is generated by the switch in response to the same incoming packet. The
-first packet received by the switch on any ingress port will have id `0.0`. The
-second packet will have id `1.0`, and so on… So when is the `` ever used?
-Let’s assume your target switch supports multicast and that packet `3.0` is
-replicated 3 times (i.e. out of 3 different ports). Each one of these 3 copies
-will receive a different ``, but the `` will remain the same. In our
-case, the three full packet ids will be `3.1`, `3.2` and `3.3`. The same goes
-for mirroring.
-
-The debugger keeps track of the "current packet id", which is the id of the last
-packet for which an event notification was received by the debugger. For several
-commands (e.g. `print`), the packet id can be omitted from the parameters which
-will cause the debugger to use the stored "current packet id".
-
-### Special field names
-
-The debugger lets you access some special fields which are not part of the
-headers or metadata. All these special names start with character `$`. We only
-support one for now, `$cond`, which holds the result of the last P4 condition
-evaluated by the switch. In the future, we plan on adding other such special
-fields (e.g. `$action`, for the last action selected by a table lookup). Note
-that all these special fields have a 32-bit width.
-
-## A more detailed list of commands
-
-### `set_wp (w)`
-Usage: `set_wp `
-For example,
-```
-set_wp ipv4.srcAddr
-w ipv4.srcAddr
-```
-
-Sets a watchpoint on the provided field. For every packet, the switch will stop
-running every time the field is written to, and the debugger will be
-notified. Of course this does not apply to packets for which notifications are
-being filtered out (see the `filter_notifications` command) or are being skipped
-(see `skip` and `skip_all`). Note that a notification is generated every time a
-write is done on the field, even if the field actually keeps the same value.
-The field name can take the special value `$cond`, which holds the result of the
-last condition evaluated.
-
-### `unset_wp`
-Usage: `unset_wp `
-For example,
-```
-unset_wp ipv4.srcAddr
-```
-
-Unsets a watchpoint which was previously set with the `set_wp` command. The
-debugger will stop notifying the user when a write operation is performed on the
-field.
-
-### `show_wps`
-Usage: `show_wps`
-
-Prints a list of all the currently active watchpoints.
-
-### `break (b)`
-Usage: `break `
-For example,
-```
-break parser start
-break pipeline ingress
-b table ipv4_lpm
-```
-
-Sets a breakpoint on a given P4 object. Every time a packet is about to "enter"
-this object, the switch will pause and the debugger will be notified. The valid
-"p4 object types" are: parser, parse_state, pipeline, table, condition, action,
-deparser.
-
-### `delete (d)`
-Usage: `delete `
-For example,
-```
-delete parser start
-d pipeline ingress
-```
-
-Removes a breakpoint which was previously set with the break command. See
-`break` command description for more details and the list of valid "p4 object
-types".
-
-### `show_bps`
-Usage: `show_bps`
-
-Prints a list of all the currently active breakpoints.
-
-### `continue (c)`
-Usage: `continue`
-
-Starts or resumes packet processing. The switch will continue processing packet
-until the next watchpoint or breakpoint event, at which point it will once again
-stop all packet processing. If you forgot to set a watchpoint or breakpoint
-before issuing the `continue` command you can still pause the switch by sending
-an Interrupt (`Ctrl-C`) to the debugger process; you will then be able to set a
-watchpoint.
-
-### `next (n)`
-Usage: `next`
-
-Resumes packet processing until the next event. An event is either a field
-modification or a packet entering a P4 object (e.g. a table). Unlike the
-`continue` command, which will only stop the switch for watchpoints and
-breakpoints set by the user, `next` will stop for all events, unless the packet
-triggering this event has been explicitly excluded using the
-`filter_notifications` or `skip(_all)` commands.
-
-### `print (p)`
-Usage: `print `
-
-Prints the value of a field for a given packet. The packet id needs to follow
-the format `.`. If the packet id is omitted, the debugger will use the
-"current packet id", which is the id of the last packet for which a notification
-was received.
-
-### `backtrace (bt)`
-Usage: `backtrace `
-
-Returns the list of P4 objects that the packet is currently traversing, in
-descending order. The packet id can be omitted and the "current packet id" will
-be used.
-
-Here are examples of possible outputs:
- - `parser 'parser' -> parse state 'parse_ethernet'`
- - `pipeline 'ingress' -> table 'ipv4_lpm' -> action 'set_nhop'`
-
-### `break_packet_in`
-Usage: `break_packet_in`
-
-When using this command, the switch will break every time a new packet is
-created, unless the corresponding packet id was excluded (see
-`filter_notifications`). This new packet can either be a new incoming packet
-(i.e. with a new ``) or a new "copy" of the same incoming packet (i.e. same
-`` but new ``).
-
-### `remove_packet_in`
-Usage: `remove_packet_in`
-
-Cancels `break_packet_in`. No effect if `break_packet_in` was not previously
-called.
-
-### `stop_packet_in`
-Usage: `stop_packet_in`
-
-Prevents the switch from accepting any more incoming packets. Note that this
-does not apply to new "copies" of a packet already being processed by the
-switch.
-
-### `resume_packet_in`
-Usage: `resume_packet_in`
-
-Cancels `stop_packet_in`. No effect if `stop_packet_in` was not previously
-called.
-
-### `filter_notifications`
-Usage: `filter_notifications *`
-For example,
-```
-filter_notifications 7.0
-filter_notifications 8.1 8.2 10.0
-filter_notifications 8
-filter_notifications 8 11.0 13
-filter_notifications
-```
-
-Limit the event notifications displayed by the debugger to those concerning one
-of these packet ids. A packet id in the list can either be a regular full packet
-id of the form `.` or simply a ``, in which case all
-notifications for packets with this `` will be taken into account
-(independently of the value of the ``). When `filter_notifications` is
-used without any arguments (i.e. no packet ids specified), the notifications
-filter will be reset and all notifications will once again be displayed by the
-debugger.
-
-### `reset`
-Usage: `reset`
-
-Resets all the debugger's state (e.g. watchpoints, breakpoints, notification
-filters...).
-
-### `skip` -- experimental
-Usage: `skip`
-
-Skips all future notifications for the "current packet id". Cannot be undone.
-
-### `skip_all` -- experimental
-Usage: `skip_all`
-
-Skips all future notifications for the "current packet id" and all the packets
-sharing the same ``. Cannot be undone.
-
-### `CLI` -- experimental
-Usage: `CLI `
-For example,
-```
-CLI table_dump ipv4_lpm
-```
-
-Opens a Thrift connection to the switch and issues a standard runtime CLI
-command. Only "standard" commands are supported (no multicast PRE support).
-
-## Future extensions
-
-We are planning on supporting the following features in the future:
- - support for stateful objects (meters, counters, registers)
- - better P4 code integration: display current P4 code, line breakpoints
- - conditional watchpoints / breakpoints (e.g. iff packet has IPv4 address
- 10.0.0.1)
diff --git a/bm/p4-sai/docs/simple_switch.md b/bm/p4-sai/docs/simple_switch.md
deleted file mode 100644
index 521e21d16..000000000
--- a/bm/p4-sai/docs/simple_switch.md
+++ /dev/null
@@ -1,95 +0,0 @@
-# The BMv2 Simple Switch target
-
-The bmv2 framework lets developpers implement their own P4-programmable
-architecture as a software switch. The simple_switch architecture is the
-de-facto architecture for most users, as it is roughly equivalent to the
-"abstract switch model" described in the P4_14 spec.
-
-This document aims at providing P4 programmers with important information
-regarding the simple_switch architecture.
-
-## Intrinsic metadata
-
-Each architecture usually defines its own intrinsic metadata fields, which are
-used in addition to the standard metadata fields to offer more advanced
-features. In the case of simple_switch, we have two separate intrinsic metadata
-headers. These headers are not strictly required by the architecture as it is
-possible to write a P4 program and run it through simple_switch without them
-being defined. However, their presence is required to enable some features of
-simple_switch. For most of these fields, there is no strict requirement as to
-the bitwidth, but we recommend that you follow our suggestions below. Some of
-these intrinsic metadata fields can be accessed (read and / or write) directly,
-others should only be accessed through primitive actions.
-
-### `intrinsic_metadata` header
-
-We recommend that you define and instantiate this metadata header for every P4
-program that you write for the simple_switch architecture, with the following
-P4-14 code:
-```
-header_type intrinsic_metadata_t {
- fields {
- ingress_global_timestamp : 48;
- lf_field_list : 8;
- mcast_grp : 16;
- egress_rid : 16;
- resubmit_flag : 8;
- recirculate_flag : 8;
- }
-}
-metadata intrinsic_metadata_t intrinsic_metadata;
-```
-- `ingress_global_timestamp`: a timestamp, in microseconds, set when the packet
-shows up on ingress. The clock is set to 0 every time the switch starts. This
-field can be read directly from either pipeline (ingress and egress) but should
-not be written to.
-- `lf_field_list`: used to store the learn id when calling `generate_digest`; do
-not access directly.
-- `mcast_grp`: needed for the multicast feature. This field needs to be written
-in the ingress pipeline when you wish the packet to be multicast. A value of 0
-means no multicast. This value must be one of a valid multicast group configured
-through bmv2 runtime interfaces.
-- `egress_rid`: needed for the multicast feature. This field is only valid in
-the egress pipeline and can only be read from. It is used to uniquely identify
-multicast copies of the same ingress packet.
-- `resubmit_flag`: should not be accessed directly. It is set by the `resubmit`
-action primitive and is required for the resubmit feature. As a remainder,
-`resubmit` needs to be called in the ingress pipeline.
-- `recirculate_flag`: should not be accessed directly. It is set by the
-`recirculate` action primitive and is required for the recirculate feature. As a
-remainder, `recirculate` needs to be called from the egress pipeline.
-
-### `queueing_metadata` header
-
-You only need to define this P4 header if you want to access queueing
-information - as a remainder, the packet is queued between the ingress and
-egress pipelines. Note that this header is "all or nothing". Either you do not
-define it or you define it with all its fields (there are 4 of them). We
-recommend that you use the following P4_14 code:
-```
-header_type queueing_metadata_t {
- fields {
- enq_timestamp : 48;
- enq_qdepth : 16;
- deq_timedelta : 32;
- deq_qdepth : 16;
- }
-}
-metadata queueing_metadata_t queueing_metadata;
-```
-Of course, all of these fields can only be accessed from the egress pipeline and
-they are read-only.
-- `enq_timestamp`: a timestamp, in microseconds, set when the packet is first
-enqueued.
-- `enq_qdepth`: the depth of the queue when the packet was first enqueued.
-- `deq_timedelta`: the time, in microseconds, that the packet spent in the
-queue.
-- `deq_qdepth`: the depth of queue when the packet was dequeued.
-
-## Supported primitive actions
-
-We mostly support the standard P4_14 primitive actions. One difference is that
-optional parameters are not supported in bmv2, so all parameters are always
-required (see `resubmit` for example).
-The full list of primitives can be seen in this [C++ source file]
-(../targets/simple_switch/primitives.cpp).
diff --git a/bm/p4-sai/install_sai_bm.sh b/bm/p4-sai/install_sai_bm.sh
deleted file mode 100644
index c7f2ffcf4..000000000
--- a/bm/p4-sai/install_sai_bm.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-# 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
-
-cp -rf 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 p4-sai/bm_config/Makefile_bak.am behavioral-model/targets/Makefile.am
-mv -f p4-sai/bm_config/configure_bak.ac behavioral-model/configure.ac
\ No newline at end of file
diff --git a/bm/p4-sai/main.cpp b/bm/p4-sai/main.cpp
deleted file mode 100644
index a8ca095fe..000000000
--- a/bm/p4-sai/main.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Copyright 2013-present Barefoot Networks, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Antonin Bas (antonin@barefootnetworks.com)
- *
- */
-
-/* Switch instance */
-
-#include
-#include
-#include
-
-#include "simple_switch.h"
-
-namespace {
-SimpleSwitch *simple_switch;
-bm::TargetParserBasic *simple_switch_parser;
-} // namespace
-
-namespace sswitch_runtime {
-shared_ptr get_handler(SimpleSwitch *sw);
-} // namespace sswitch_runtime
-
-int
-main(int argc, char* argv[]) {
- simple_switch = new SimpleSwitch();
- simple_switch_parser = new bm::TargetParserBasic();
- simple_switch_parser->add_flag_option("enable-swap",
- "enable JSON swapping at runtime");
- int status = simple_switch->init_from_command_line_options(
- argc, argv, simple_switch_parser);
- if (status != 0) std::exit(status);
-
- bool enable_swap_flag = false;
- if (simple_switch_parser->get_flag_option("enable-swap", &enable_swap_flag)
- != bm::TargetParserBasic::ReturnCode::SUCCESS)
- std::exit(1);
- if (enable_swap_flag) simple_switch->enable_config_swap();
-
- int thrift_port = simple_switch->get_runtime_port();
- bm_runtime::start_server(simple_switch, thrift_port);
- using ::sswitch_runtime::SimpleSwitchIf;
- using ::sswitch_runtime::SimpleSwitchProcessor;
- bm_runtime::add_service(
- "simple_switch", sswitch_runtime::get_handler(simple_switch));
- simple_switch->start_and_return();
-
- while (true) std::this_thread::sleep_for(std::chrono::seconds(100));
-
- return 0;
-}
diff --git a/bm/p4-sai/p4src/DefaultConfig.txt b/bm/p4-sai/p4src/DefaultConfig.txt
deleted file mode 100644
index f3132b9d0..000000000
--- a/bm/p4-sai/p4src/DefaultConfig.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-table_set_default table_ingress_lag action_set_l2if
-// table_set_default table_port_PVID action_set_pvid 1
-// table_set_default table_port_mode table action_set_port_mode 0
-table_set_default table_port_configurations action_set_port_configurations 1 0 1514 0 0
-table_set_default table_port_ingress_l2_interface_type _drop
-table_set_default table_subport_ingress_l2_interface_type _drop
-table_set_default table_bridge_id_1q action_set_bridge_id_vid
-table_set_default table_ingress_vlan_filtering _drop
-table_set_default table_port_set_packet_vid_internal action_set_packet_vid
-table_set_default table_learn_fdb action_learn_mac
-
-table_set_default table_drop_tagged_internal _nop
-table_set_default table_drop_untagged_internal _nop
-table_add table_drop_tagged_internal _drop 1 =>
-table_add table_drop_untagged_internal _drop 1 =>
-
-table_set_default table_l2_trap action_set_trap_id 0xff
-table_set_default table_trap_id _nop
-table_set_default table_egress_clone_internal _nop
-table_add table_egress_clone_internal action_cpu_encap 1 =>
-
-table_add table_port_ingress_interface_type action_set_l2_if_type 0 => 3 0
-table_add table_port_ingress_interface_type action_set_l2_if_type 1 => 3 1
-table_add table_port_ingress_interface_type action_set_l2_if_type 2 => 3 2
-table_add table_port_ingress_interface_type action_set_l2_if_type 3 => 3 3
-table_add table_port_ingress_interface_type action_set_l2_if_type 4 => 3 4
-table_add table_port_ingress_interface_type action_set_l2_if_type 5 => 3 5
-table_add table_port_ingress_interface_type action_set_l2_if_type 6 => 3 6
-table_add table_port_ingress_interface_type action_set_l2_if_type 7 => 3 7
-
-table_add table_egress_br_port_to_if action_forward_set_outIfType 0 => 0 0
-table_add table_egress_br_port_to_if action_forward_set_outIfType 1 => 1 0
-table_add table_egress_br_port_to_if action_forward_set_outIfType 2 => 2 0
-table_add table_egress_br_port_to_if action_forward_set_outIfType 3 => 3 0
-table_add table_egress_br_port_to_if action_forward_set_outIfType 4 => 4 0
-table_add table_egress_br_port_to_if action_forward_set_outIfType 5 => 5 0
-table_add table_egress_br_port_to_if action_forward_set_outIfType 6 => 6 0
-table_add table_egress_br_port_to_if action_forward_set_outIfType 7 => 7 0
-
-table_add table_port_set_packet_vid_internal action_set_packet_vid 1 =>
-table_add table_ingress_vlan_filtering _nop 0 1 =>
-table_add table_ingress_vlan_filtering _nop 1 1 =>
-table_add table_ingress_vlan_filtering _nop 2 1 =>
-table_add table_ingress_vlan_filtering _nop 3 1 =>
-table_add table_ingress_vlan_filtering _nop 4 1 =>
-table_add table_ingress_vlan_filtering _nop 5 1 =>
-table_add table_ingress_vlan_filtering _nop 6 1 =>
-table_add table_ingress_vlan_filtering _nop 7 1 =>
-
-table_set_default table_egress_vlan_filtering _drop
-table_add table_egress_vlan_filtering _nop 0 1 =>
-
-table_set_default table_xSTP_instance action_set_stp_id 1
-
-table_set_default table_mc_lookup_mode action_set_mcast_lookup_mode 0
-table_set_default table_mc_fdb action_set_mc_fdb_miss
-table_set_default table_mc_l2_sg_g action_set_mc_fdb_miss
-
-
-table_set_default table_fdb action_set_unknown_unicast 1
-table_set_default table_broadcast action_forward_mc_set_if_list 1 0
-table_set_default table_flood action_forward_mc_set_if_list 1 0
-
-mc_node_create 0 0 1 2 3 4 5 6 7
-mc_mgrp_create 1
-mc_node_associate 1 0
\ No newline at end of file
diff --git a/bm/p4-sai/p4src/DefaultConfigMirror.txt b/bm/p4-sai/p4src/DefaultConfigMirror.txt
deleted file mode 100644
index 81bf2971c..000000000
--- a/bm/p4-sai/p4src/DefaultConfigMirror.txt
+++ /dev/null
@@ -1 +0,0 @@
-mirroring_add 8 8
\ No newline at end of file
diff --git a/bm/p4-sai/p4src/actions.p4 b/bm/p4-sai/p4src/actions.p4
deleted file mode 100644
index 546babce3..000000000
--- a/bm/p4-sai/p4src/actions.p4
+++ /dev/null
@@ -1,173 +0,0 @@
-#include "defines.p4"
-// primitives
-action _drop() {
- drop();
-}
-
-action _nop() {
- no_op();
-}
-
-// ingres L2
-action action_set_lag_l2if(in bit is_lag, in bit<6> l2_if) { // , in bit<16> lag_id
- ingress_metadata.is_lag = is_lag;
- // ingress_metadata.lag_id = lag_id;
- ingress_metadata.l2_if = l2_if;
-}
-
-action action_set_trap_id(in bit<11> trap_id) {
- ingress_metadata.trap_id = trap_id;
-}
-
-action action_copy_to_cpu() {
- clone_ingress_pkt_to_egress(COPY_TO_CPU_MIRROR_ID, redirect_FL);
-}
-
-action action_trap_to_cpu() {
- clone_ingress_pkt_to_egress(COPY_TO_CPU_MIRROR_ID, redirect_FL);
- drop();
-}
-
-// ingres L2
-action action_set_l2if() {
- ingress_metadata.l2_if =standard_metadata.ingress_port;
-}
-
-action action_set_packet_vid(){
- ingress_metadata.vid = vlan.vid;
-}
-
-action action_set_port_configurations(in bit<12> pvid, in bit bind_mode, in bit<32> mtu, in bit drop_tagged, in bit drop_untagged) {
- ingress_metadata.vid = pvid;
- ingress_metadata.bind_mode = bind_mode;
- ingress_metadata.mtu = mtu;
- ingress_metadata.drop_tagged = drop_tagged;
- ingress_metadata.drop_untagged = drop_untagged;
-}
-
-action action_set_l2_if_type(in bit<2> l2_if_type, in bit<8> bridge_port){
- // L2_BRIDGE_PORT_WDT
- ingress_metadata.l2_if_type = l2_if_type;
- ingress_metadata.bridge_port = bridge_port;
-}
-
-action action_set_bridge_id(in bit<12> bridge_id){
- ingress_metadata.bridge_id = bridge_id;
-}
-
-
-action action_set_bridge_id_vid(){
- ingress_metadata.bridge_id =ingress_metadata.vid;
-}
-
-action action_set_bridge_id_with_vid() {
- ingress_metadata.bridge_id = ingress_metadata.vid;
-}
-
-action action_set_mcast_lookup_mode(in bit<2> mcast_mode){
- ingress_metadata.mcast_mode =mcast_mode;
-}
-
-action action_set_stp_state(in bit<3> stp_state){//need to enforce STP state
- ingress_metadata.stp_state = stp_state;
-}
-
-action action_set_stp_id(in bit<3> stp_id){
- ingress_metadata.stp_id = stp_id;
-}
-
-action action_go_to_in_l3_if_table(){
- no_op();
-}
-//action action_go_to_fdb_table(){
-// no_op();
-//}
-
-//modify_field (ingress_metadata.,);
-
-// L2
-action action_learn_mac() {
- ingress_metadata.trap_id = MAC_LEARN_RECEIVER; //TODO, should this be configurable to support hostif interface(?)
- clone_ingress_pkt_to_egress(COPY_TO_CPU_MIRROR_ID, redirect_FL);
-}
-
-action action_set_egress_br_port(in bit<8> br_port){
- egress_metadata.bridge_port = br_port;
-}
-
-action action_set_vlan(in bit<12> vid) {
- ingress_metadata.vid = vid;
-}
-
-action action_forward_set_outIfType(in bit<6> out_if,in bit<1> out_if_type){
- egress_metadata.out_if = out_if;
- egress_metadata.out_if_type = out_if_type;
- standard_metadata.egress_spec = out_if;
-}
-
-action action_set_unknown_unicast(in bit<1> unknown_unicast) {
- ingress_metadata.unknown_unicast = unknown_unicast;
-}
-
-//action action_ste_fdb_miss(in bit mc_fdb_miss){
-// ingress_metadata.mc_fdb_miss = mc_fdb_miss;
-//}
-
-action action_forward(in bit<6> br_port) {
- // standard_metadata.egress_spec = port; //need to map bride port to interface
- egress_metadata.bridge_port = br_port;
-}
-
-action action_forward_mc_set_if_list(in bit<16> mcast_grp, in bit<1> go_to_router){
- // TODO add set egress if list
- modify_field(intrinsic_metadata.mcast_grp, mcast_grp);
- modify_field(ingress_metadata.go_to_router, go_to_router);
-}
-
-action action_set_egress_stp_state(in bit<2> stp_state){
- egress_metadata.stp_state = stp_state;
-}
-
-action action_forward_vlan_untag(){
- ethernet.etherType = vlan.etherType;
- remove_header(vlan);
-}
-
-action action_forward_vlan_tag(in bit<3> pcp, in bit cfi, in bit<12> vid){
- add_header(vlan);
- vlan.pcp = pcp;
- vlan.cfi = cfi;
- vlan.vid = vid;
- vlan.etherType = ethernet.etherType;
- ethernet.etherType = VLAN_TYPE;
- // egress_metadata.tag_mode = tag_mode;
-}
-
-action action_set_lag_hash_size(in bit<6> lag_size) {
- modify_field_with_hash_based_offset(egress_metadata.hash_val, 0, lag_hash, lag_size);
-}
-
-action action_set_out_port(in bit<6> port){
- standard_metadata.egress_spec = port;
-}
-
-//action broadcast() {
-// modify_field(egress_metadata.mcast_grp, 1);
-//}
-
-action set_egr(in bit<6> egress_spec) {
- modify_field(standard_metadata.egress_spec, egress_spec);
-}
-
-// mc
-action action_set_mc_fdb_miss() {
- ingress_metadata.mc_fdb_miss=1;
-}
-
-action action_cpu_encap() {
- add_header(cpu_header);
- cpu_header.ingress_port = standard_metadata.ingress_port;
- cpu_header.trap_id = ingress_metadata.trap_id;
- cpu_header.bridge_id = ingress_metadata.bridge_id;
- cpu_header.bridge_port = ingress_metadata.bridge_port;
-}
\ No newline at end of file
diff --git a/bm/p4-sai/p4src/defines.p4 b/bm/p4-sai/p4src/defines.p4
deleted file mode 100644
index d37744b0a..000000000
--- a/bm/p4-sai/p4src/defines.p4
+++ /dev/null
@@ -1,55 +0,0 @@
-// defines
-
-// genreal
-#define TRUE 1
-#define FALSE 0
-#define MAC_LEARN_RECEIVER 512
-
-// Mirroring and traps
-#define COPY_TO_CPU_MIRROR_ID 8
-
-// header/metadata fields width
-#define LAG_WDT 16
-#define L2_BRIDGE_NUM_WDT 3 // TODO
-#define L2_BRIDGE_PORT_WDT 8 // TODO
-#define VID_WDT 12
-#define PACKET_TYPE_WDT 2 // TODO
-
-// table size
-#define FDB_TABLE_SIZE 512 // TODO
-
-//phy
-#define PHY_PORT_NUM 64 // TODO
-#define PHY_PORT_NUM_WDT 6 // TODO
-
-
-//port
-#define PORT_MODE_SUBPORT 0x1
-#define PORT_MODE_PORT 0x0
-
-//bridge ports
-//#define 1Q_BRIDGE_PORT_ROUTER 100
-
-// L2
-// L2_IF_TYPE
-#define L2_ROUTER_TYPE 0x1
-#define L2_1D_BRIDGE 0x2
-#define L2_1Q_BRIDGE 0x3
-
-
-// STP STATE
-#define STP_FORWARDING 1 // TODO
-#define STP_DISCARDING 0 // TODO
-#define TAG
-
-
-#define MAC_BASE_MC_LOOKUP 0
-#define SG_IP_BASE_MC_LOOKUP 2
-#define G_IP_BASE_MC_LOOKUP 1 //need to add
-
-
-// OUT_IF TYPE
-#define OUT_IF_IS_PORT 0
-#define OUT_IF_IS_LAG 1 // TODO
-#define OUT_IF_IS_ROUTER 2 // TODO
-
diff --git a/bm/p4-sai/p4src/field_lists.p4 b/bm/p4-sai/p4src/field_lists.p4
deleted file mode 100644
index c906d1cdc..000000000
--- a/bm/p4-sai/p4src/field_lists.p4
+++ /dev/null
@@ -1,47 +0,0 @@
-field_list mac_learn_digest {
- ethernet.srcAddr;
- ingress_metadata.bridge_id; // TODO
- standard_metadata.ingress_port; // TODO
-}
-
-field_list_calculation ipv4_checksum {
- input {
- ipv4_checksum_list;
- }
- algorithm : csum16;
- output_width : 16;
-}
-
-field_list ipv4_checksum_list {
- ipv4.version;
- ipv4.ihl;
- ipv4.diffserv;
- ipv4.ipv4_length;
- ipv4.id;
- ipv4.flags;
- ipv4.offset;
- ipv4.ttl;
- ipv4.protocol;
- ipv4.srcAddr;
- ipv4.dstAddr;
-}
-
-field_list lag_hash_fieldlist {
- ethernet.srcAddr;
- ipv4.id;
-}
-
-field_list_calculation lag_hash {
- input {
- lag_hash_fieldlist;
- }
- algorithm : xor8; //TODO: change to lag_hash
- output_width : 1; //TODO: LOG2(NUM_OF_PORTS)
-}
-
-field_list redirect_FL {
- standard_metadata;
- ingress_metadata.trap_id;
- ingress_metadata.bridge_id;
- ingress_metadata.bridge_port;
-}
\ No newline at end of file
diff --git a/bm/p4-sai/p4src/headers.p4 b/bm/p4-sai/p4src/headers.p4
deleted file mode 100644
index 75a62b0cb..000000000
--- a/bm/p4-sai/p4src/headers.p4
+++ /dev/null
@@ -1,124 +0,0 @@
-#include "defines.p4"
-
-header_type ethernet_t {
- fields {
- bit<48> dstAddr;
- bit<48> srcAddr;
- bit<16> etherType;
- }
-}
-header_type vlan_t {
- fields {
- bit<3> pcp;
- bit cfi;
- bit<12> vid;
- bit<16> etherType;
- }
- //length 4;
- //max_length 4;
-}
-header_type ipv4_t {
- fields {
- bit<4> version;
- bit<4> ihl;
- bit<8> diffserv;
- bit<16> ipv4_length;
- bit<16> id;
- bit<3> flags;
- bit<13> offset;
- bit<8> ttl;
- bit<8> protocol;
- bit<16> checksum;
- bit<32> srcAddr;
- bit<32> dstAddr;
- }
- //length ihl * 4;
- //max_length 32;
-}
-header_type tcp_t {
- fields {
- bit<16> srcPort;
- bit<16> dstPort;
- bit<32> seqNo;
- bit<32> ackNo;
- bit<4> dataOffset;
- bit<4> res;
- bit<8> flags;
- bit<16> window;
- bit<16> checksum;
- bit<16> urgentPtr;
- }
-}
-
-header_type udp_t {
- fields {
- bit<16> srcPort;
- bit<16> dstPort;
- bit<16> length_;
- bit<16> checksum;
- }
-}
-
-
-header_type ingress_metadata_t {
- fields {
- bit<6> port; //PHY_PORT_NUM_WDT
- bit<6> l2_if; //PHY_PORT_NUM_WDT
- bit is_tagged;
- bit is_lag;
- bit<16> lag_id; // LAG_WDT
- bit bind_mode;
- bit<2> l2_if_type;
- bit<8> bridge_port; //L2_BRIDGE_PORT_WDT
- bit<12> bridge_id; //L2_BRIDGE_NUM_WDT
- bit<2> stp_state;
- bit<3> stp_id; // TODO size?
- bit<12> vid;
- bit<1> unknown_unicast;
- bit<2> mcast_mode;
- bit<1> mc_fdb_miss;
- bit ipmc;
- bit isip;
- bit go_to_router;
- bit<32> mtu;
- bit drop_tagged;
- bit drop_untagged;
- bit<11> trap_id;
- }
-}
-
-
-
-header_type egress_metadata_t {
- fields {
- bit out_if_type;
- bit<6> out_if; // PHY_PORT_NUM_WDT TODO remove? same as standard_metadata.egress_spec?
- bit<2> stp_state; // same as ingress? duplication?
- bit tag_mode;
- bit<6> hash_val;// TODO for egress lag table, when it is set?
- bit<4> mcast_grp;
- bit<8> bridge_port; //L2_BRIDGE_PORT_WDT
- }
-}
-
-header_type intrinsic_metadata_t {
- fields {
- bit <48> ingress_global_timestamp;
- bit <8> lf_field_list;
- bit <16> mcast_grp;
- bit <16> egress_rid;
- bit <8> resubmit_flag;
- bit <8> recirculate_flag;
- }
-}
-
-metadata intrinsic_metadata_t intrinsic_metadata;
-
-header_type cpu_header_t {
- fields {
- bit<16> trap_id;
- bit<16> bridge_id;
- bit<8> ingress_port;
- bit<8> bridge_port;
- }
-}
\ No newline at end of file
diff --git a/bm/p4-sai/p4src/parser.p4 b/bm/p4-sai/p4src/parser.p4
deleted file mode 100644
index c78de8e64..000000000
--- a/bm/p4-sai/p4src/parser.p4
+++ /dev/null
@@ -1,73 +0,0 @@
-// Parser Defintion file.
-// Defines how stream of bytes
-// that enters the switch,
-// get parsed into meaningfull packets.
-
-#define TCP_PROTOCOL_NUM 0x06
-#define UDP_PROTOCOL_NUM 0x11
-#define VLAN_TYPE 0x8100
-#define IPV4_TYPE 0x0800
-
-
-// parser starts here
-// check if needs to add clone_to_cpu encapsulation
-parser start {
- return select(current(0, 64)) {
- 0 : parse_cpu_header;
- default: parse_ethernet;
- }
-}
-
-
-parser parse_cpu_header {
- extract(cpu_header);
- return parse_ethernet;
-}
-
-// ethernet parser - decide next layer according the ethertype
-parser parse_ethernet {
- extract(ethernet);
- set_metadata(ingress_metadata.is_tagged,0);
- return select(latest.etherType) {
- VLAN_TYPE : parse_vlan;
- IPV4_TYPE : parse_ipv4;
- default: ingress;
- }
-}
-
-parser parse_vlan {
- extract(vlan);
- set_metadata(ingress_metadata.is_tagged, (bit)(vlan.vid >> 11) | (bit)(vlan.vid >> 10) | (bit)(vlan.vid >> 9) | (bit)(vlan.vid >> 8) | (bit)(vlan.vid >> 7) | (bit)(vlan.vid >> 6) | (bit)(vlan.vid >> 5) | (bit)(vlan.vid >> 4) | (bit)(vlan.vid >> 3) | (bit)(vlan.vid >> 2) | (bit)(vlan.vid >> 1) | (bit)(vlan.vid)); //if vid==0 not tagged. TODO: need to do this better (maybe add parser support for casting boolean)
- return select(latest.etherType) {
- IPV4_TYPE : parse_ipv4;
- default: ingress;
- }
-}
-
-// IPv4 parser, decide next layer according to protocol field
-parser parse_ipv4 {
- extract(ipv4);
- set_metadata(ingress_metadata.isip,1);
- return post_parse_ipv4 ;
-}
-
-parser post_parse_ipv4 {
- return select(ipv4.protocol) {
- TCP_PROTOCOL_NUM : parse_tcp;
- UDP_PROTOCOL_NUM : parse_udp;
- default : ingress;
- }
-}
-
-
-// TCP parser, next layer are irrelvant for us, thus not included
-// (cosidered payload data).
-parser parse_udp {
- extract(udp);
- return ingress;
-}
-
-parser parse_tcp {
- extract(tcp);
- return ingress;
-}
diff --git a/bm/p4-sai/p4src/sai.p4 b/bm/p4-sai/p4src/sai.p4
deleted file mode 100644
index 1c2400ff7..000000000
--- a/bm/p4-sai/p4src/sai.p4
+++ /dev/null
@@ -1,170 +0,0 @@
-// This is P4 sample source for sai
-// Fill in these files with your P4 code
-
-
-// includes
-#include "headers.p4"
-#include "parser.p4"
-#include "tables.p4"
-#include "actions.p4"
-#include "defines.p4"
-#include "field_lists.p4"
-
-// headers
-header ethernet_t ethernet;
-header vlan_t vlan;
-header ipv4_t ipv4;
-header tcp_t tcp;
-header udp_t udp;
-header cpu_header_t cpu_header;
-
-// metadata
-metadata ingress_metadata_t ingress_metadata;
-metadata egress_metadata_t egress_metadata;
-
-control ingress {
- // phy
- control_ingress_port(); //bridging
- if((ingress_metadata.l2_if_type == L2_1Q_BRIDGE) or (ingress_metadata.l2_if_type == L2_1D_BRIDGE)) {
- control_bridge();
- }
-
- // router
- if ((ingress_metadata.l2_if_type == L2_ROUTER_TYPE) or (ingress_metadata.go_to_router == 1)) {
- control_router_flow();
- }
-
- //todo: bridge after router
-}
-
-control control_bridge {
- if(ingress_metadata.l2_if_type == L2_1D_BRIDGE){
- control_1d_bridge_flow();
- } else{
- control_1q_bridge_flow();
- }
-
- // control_learn_fdb();
- if((ethernet.dstAddr&0x010000000000)==0x0){ //unicast
- control_unicast_fdb();
- } else if(ethernet.dstAddr==0xffffffffffff){ //broadcast
- control_bc_fdb();
- } else { //multicast
- control_mc_fdb();
- }
-}
-
-control control_ingress_port{
- apply(table_ingress_lag); //TODO: rename table?
- apply(table_port_configurations);
- // apply(table_accepted_frame_type);
- if (ingress_metadata.is_tagged==1) {
- // apply(table_port_PVID);
- // } else {
- apply(table_port_set_packet_vid_internal);
- apply(table_drop_tagged_internal);
- } else {
- apply(table_drop_untagged_internal);
- }
- // apply(table_port_mode);
- apply(table_l2_trap);
- apply(table_trap_id); //TODO: move this
- // apply(table_check_port_mtu; //TODO
- //apply(table_ingress_acl); // TODO
- if(ingress_metadata.bind_mode == PORT_MODE_PORT)
- apply(table_port_ingress_interface_type);
- else
- apply(table_subport_ingress_interface_type);
-}
-
-control control_1d_bridge_flow{
- apply(table_bridge_id_1d);
- apply(table_vbridge_STP);
-}
-
-control control_1q_bridge_flow{
- apply(table_bridge_id_1q);
- apply(table_ingress_vlan_filtering);
- apply(table_xSTP_instance);
- apply(table_xSTP);
-}
-
-control control_router_flow{
- // TODO
-}
-
-// control control_learn_fdb{
-// apply(table_learn_fdb);
-// }
-
-control control_unicast_fdb{
- apply(table_learn_fdb); //TODO: is this only relevant for unicast?
- apply(table_l3_interface){//should be for unicast only TDB
- miss{
- apply(table_fdb) {
- miss {
- apply(table_flood);
- }
- }
- }
- }
-}
-
-control control_bc_fdb{
- apply(table_broadcast);
-}
-
-control control_mc_fdb{
- apply(table_mc_lookup_mode);
- //non ip multicast
- if((ingress_metadata.isip==0) or (ingress_metadata.mcast_mode==MAC_BASE_MC_LOOKUP))//non ip or multicast mode == FDB
- apply(table_mc_fdb);
- else if((ingress_metadata.isip==1) and (ingress_metadata.mcast_mode==SG_IP_BASE_MC_LOOKUP))
- apply(table_mc_l2_sg_g);
- //TBD add * G table
- //FDB miss flow
- if(ingress_metadata.mc_fdb_miss==1)
- {
- //non ip
- if(ingress_metadata.isip==1)
- apply(table_unknown_multicast_ipv4);
- else
- apply(table_unknown_multicast_nonip);
-
- }
-}
-
-
-control egress{
- if(ingress_metadata.l2_if_type == L2_1D_BRIDGE){
- apply(table_egress_vbridge_STP);
- }
- if(ingress_metadata.l2_if_type == L2_1Q_BRIDGE){
- apply(table_egress_xSTP);
- apply(table_egress_vlan_filtering);
- }
-
- apply(table_egress_br_port_to_if);
- if(ingress_metadata.l2_if_type == L2_1D_BRIDGE){
- apply(table_egress_set_vlan);
- }
- apply(table_egress_vlan_tag);
-
- if (egress_metadata.out_if_type == OUT_IF_IS_LAG) {
- apply(table_lag_hash);
- apply(table_egress_lag);
- }
- else if(egress_metadata.out_if == OUT_IF_IS_ROUTER){
- control_1q_egress_uni_router();
- }
- //apply(egress_acl); // TODO
- //if((egress_metadata.stp_state == STP_FORWARDING) and (egress_metadata.tag_mode == TAG) ){
- // TODO: go to egress
- //}
- apply(table_egress_clone_internal);
-}
-
-control control_1q_egress_uni_router {
-
-}
-
diff --git a/bm/p4-sai/p4src/tables.p4 b/bm/p4-sai/p4src/tables.p4
deleted file mode 100644
index 65a9be5f9..000000000
--- a/bm/p4-sai/p4src/tables.p4
+++ /dev/null
@@ -1,312 +0,0 @@
-#include "defines.p4"
-
-// PORT
-table table_ingress_lag {
- reads {
- standard_metadata.ingress_port : exact;
- }
- actions {action_set_lag_l2if;action_set_l2if;}//mattyk update
- size : PHY_PORT_NUM;
-}
-
-table table_drop_tagged_internal {
- reads {
- ingress_metadata.drop_tagged : exact;
- }
- actions {_drop;_nop;}
- size: 1;
-}
-table table_drop_untagged_internal {
- reads {
- ingress_metadata.drop_untagged : exact;
- }
- actions {_drop;_nop;}
- size: 1;
-}
-
-table table_l2_trap {
- reads {
- ethernet.dstAddr : exact;
- }
- actions {action_set_trap_id;}
-}
-
-table table_trap_id { //TODO: move this?
- reads {
- ingress_metadata.trap_id : exact;
- }
- actions {_drop;_nop;action_copy_to_cpu;action_trap_to_cpu;}
-}
-
-table table_port_configurations {
- reads {
- ingress_metadata.l2_if : exact;
- }
- actions {action_set_port_configurations;}
-}
-
-table table_port_set_packet_vid_internal {
- reads {
- ingress_metadata.is_tagged : exact;
- }
- actions {action_set_packet_vid;}
- size : 1;
-}
-
-
-table table_port_ingress_interface_type {// should be
- reads {
- ingress_metadata.l2_if: exact;
- }
- actions {action_set_l2_if_type; _drop;}
-}
-
-table table_subport_ingress_interface_type {
- reads {
- ingress_metadata.l2_if : exact;
- ingress_metadata.vid : exact;
- }
- actions {action_set_l2_if_type; _drop;}
-}
-
-
-//-----------
-// ingress 1d bridge
-//-----------
-table table_bridge_id_1d {
- reads {
- ingress_metadata.bridge_port : exact;
- }
- actions {action_set_bridge_id; _drop;}
-}
-
-table table_vbridge_STP {
- reads {
- ingress_metadata.bridge_port : exact;
- }
- actions {action_set_stp_state;}
- //size : 1; TODO
-}
-//-----------
-// ingress 1q bridge
-//-----------
-table table_bridge_id_1q {
- reads {
- ingress_metadata.vid : exact;
- }
- actions {action_set_bridge_id;action_set_bridge_id_vid;}//why drop
-}
-
-table table_ingress_vlan_filtering{
- reads{
- ingress_metadata.bridge_port : exact;
- ingress_metadata.vid : exact;
- }
- actions{_drop;_nop;}
-}
-
-table table_mc_lookup_mode{
- reads{
- ingress_metadata.vid : exact;
- }
- actions{action_set_mcast_lookup_mode;}
-}
-
-table table_xSTP_instance{
- reads{
- ingress_metadata.vid : exact;
- }
- actions{action_set_stp_id;}
-}
-
-table table_xSTP {
- reads {
- ingress_metadata.bridge_port : exact;
- ingress_metadata.stp_id : exact;
- }
- actions {action_set_stp_state;_drop;}
- //size : 1; TODO
-}
-
-//-----------
-// fdb
-//-----------
-
-table table_learn_fdb {
- reads {
- ethernet.srcAddr : exact;
- ingress_metadata.bridge_id : exact;
- }
- actions {_nop;action_learn_mac;}
- //size : 1; TODO
-}
-
-table table_l3_interface {
- reads {
- ethernet.dstAddr : exact;
- ingress_metadata.bridge_id : exact;
- }
- actions {action_set_egress_br_port;}//action_go_to_fdb_table;}
- //size : 1; TODO
-}
-
-//---------
-// unicast:
-//---------
-table table_fdb { // TODO ask if can be melded into l3 interface table...
- reads {
- ethernet.dstAddr : exact;
- ingress_metadata.bridge_id : exact;
- }
- actions {action_set_egress_br_port;action_set_unknown_unicast;}
- size : FDB_TABLE_SIZE;
-}
-
-//table table_l3_if{ // TODO - definition
-// reads{
-// ethernet.dstAddr : exact;
-// ingress_metadata.bridge_id : exact;
-// }
-// actions{action_forward;}//action_go_to_fdb_table;}
-//}
-
-//---------
-// multicast:
-//---------
-table table_mc_fdb{
- reads{
- ethernet.dstAddr : exact;
- ingress_metadata.bridge_id : exact;
- }
- actions{action_forward_mc_set_if_list;action_set_mc_fdb_miss;}
-}
-
-table table_mc_l2_sg_g{// IP MC
- reads{
- ingress_metadata.bridge_id : exact;
- ipv4.srcAddr : exact;
- ipv4.dstAddr : exact;
- }
- actions{action_forward_mc_set_if_list;action_set_mc_fdb_miss;}
-}
-
-table table_unknown_multicast_nonip{
- reads{
- ingress_metadata.bridge_id : exact;
- }
- actions{action_forward_mc_set_if_list;}
-}
-
-table table_unknown_multicast_ipv4{
- reads{
- ingress_metadata.bridge_id : exact;
- }
- actions{action_forward_mc_set_if_list;}
-}
-
-//table table_unknown_multicast_ipv6{
-// reads{
-// ingress_metadata.bridge_id : exact;
-// }
-// actions{action_forward_mc_set_if_list;}
-//}
-
-table table_broadcast{
- reads{
- ingress_metadata.bridge_id : exact;
- }
- actions{action_forward_mc_set_if_list;}
-}
-
-table table_flood {
- reads {
- ingress_metadata.bridge_id : exact;
- }
- actions{action_forward_mc_set_if_list;}
-}
-
-//-----------
-// egress 1d bridge
-//-----------
-
-table table_egress_vbridge_STP {
- reads {
- egress_metadata.bridge_port : exact;
- }
- actions {action_set_egress_stp_state; _drop;}
- //size : 1; // TODO
-}
-
-table table_egress_vlan_tag {
- reads {
- egress_metadata.out_if : exact;
- ingress_metadata.vid : exact;
- vlan : valid;
- }
- actions {action_forward_vlan_tag; action_forward_vlan_untag; _drop;_nop;}
- //size : 1; // TODO
-}
-
-//-----------
-// egress 1q bridge
-//-----------
-
-table table_egress_xSTP{
- reads{
- egress_metadata.bridge_port : exact;
- ingress_metadata.stp_id : exact;
- }
- actions {action_set_egress_stp_state; _drop;}
-}
-
-table table_egress_vlan_filtering {
- reads{
- egress_metadata.bridge_port : exact;
- ingress_metadata.vid : exact;
- }
- actions{_drop; _nop; }
-}
-
-// --------------
-// egress bridge
-// --------------
-table table_egress_br_port_to_if {
- reads {
- egress_metadata.bridge_port : exact;
- }
- actions {action_forward_set_outIfType; _drop;}
-}
-
-table table_egress_set_vlan {
- reads {
- egress_metadata.bridge_port : exact;
- }
- actions {action_set_vlan;}
-}
-
-//-----------
-// egress lag/phy
-//-----------
-table table_lag_hash { //TODO: FW flow to add ports as lag, should edit this table with lag size
- reads {
- egress_metadata.out_if : exact;
- }
- actions {action_set_lag_hash_size;}
-}
-
-table table_egress_lag {
- reads {
- egress_metadata.out_if : exact;
- egress_metadata.hash_val : exact;
- }
- actions {action_set_out_port; _drop;}
- //size : 1; // TODO
-}
-
-table table_egress_clone_internal {
- reads {
- standard_metadata.instance_type : exact;
- }
- actions {_nop; action_cpu_encap;}
- // size: 16;
-}
\ No newline at end of file
diff --git a/bm/p4-sai/primitives.cpp b/bm/p4-sai/primitives.cpp
deleted file mode 100644
index 63280332a..000000000
--- a/bm/p4-sai/primitives.cpp
+++ /dev/null
@@ -1,364 +0,0 @@
-/* Copyright 2013-present Barefoot Networks, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Antonin Bas (antonin@barefootnetworks.com)
- *
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-template
-using ActionPrimitive = bm::ActionPrimitive;
-
-using bm::Data;
-using bm::Field;
-using bm::Header;
-using bm::MeterArray;
-using bm::CounterArray;
-using bm::RegisterArray;
-using bm::NamedCalculation;
-using bm::HeaderStack;
-
-class modify_field : public ActionPrimitive {
- void operator ()(Data &dst, const Data &src) {
- bm::core::assign()(dst, src);
- }
-};
-
-REGISTER_PRIMITIVE(modify_field);
-
-class modify_field_rng_uniform
- : public ActionPrimitive {
- void operator ()(Data &f, const Data &b, const Data &e) {
- // TODO(antonin): a little hacky, fix later if there is a need using GMP
- // random fns
- using engine = std::default_random_engine;
- using hash = std::hash;
- static thread_local engine generator(hash()(std::this_thread::get_id()));
- using distrib64 = std::uniform_int_distribution;
- distrib64 distribution(b.get_uint64(), e.get_uint64());
- f.set(distribution(generator));
- }
-};
-
-REGISTER_PRIMITIVE(modify_field_rng_uniform);
-
-class add_to_field : public ActionPrimitive {
- void operator ()(Field &f, const Data &d) {
- f.add(f, d);
- }
-};
-
-REGISTER_PRIMITIVE(add_to_field);
-
-class subtract_from_field : public ActionPrimitive {
- void operator ()(Field &f, const Data &d) {
- f.sub(f, d);
- }
-};
-
-REGISTER_PRIMITIVE(subtract_from_field);
-
-class add : public ActionPrimitive {
- void operator ()(Data &f, const Data &d1, const Data &d2) {
- f.add(d1, d2);
- }
-};
-
-REGISTER_PRIMITIVE(add);
-
-class subtract : public ActionPrimitive {
- void operator ()(Data &f, const Data &d1, const Data &d2) {
- f.sub(d1, d2);
- }
-};
-
-REGISTER_PRIMITIVE(subtract);
-
-class bit_xor : public ActionPrimitive {
- void operator ()(Data &f, const Data &d1, const Data &d2) {
- f.bit_xor(d1, d2);
- }
-};
-
-REGISTER_PRIMITIVE(bit_xor);
-
-class bit_or : public ActionPrimitive {
- void operator ()(Data &f, const Data &d1, const Data &d2) {
- f.bit_or(d1, d2);
- }
-};
-
-REGISTER_PRIMITIVE(bit_or);
-
-class bit_and : public ActionPrimitive {
- void operator ()(Data &f, const Data &d1, const Data &d2) {
- f.bit_and(d1, d2);
- }
-};
-
-REGISTER_PRIMITIVE(bit_and);
-
-class shift_left :
- public ActionPrimitive {
- void operator ()(Data &f, const Data &d1, const Data &d2) {
- f.shift_left(d1, d2);
- }
-};
-
-REGISTER_PRIMITIVE(shift_left);
-
-class shift_right :
- public ActionPrimitive {
- void operator ()(Data &f, const Data &d1, const Data &d2) {
- f.shift_right(d1, d2);
- }
-};
-
-REGISTER_PRIMITIVE(shift_right);
-
-class drop : public ActionPrimitive<> {
- void operator ()() {
- get_field("standard_metadata.egress_spec").set(511);
- if (get_phv().has_field("intrinsic_metadata.mcast_grp")) {
- get_field("intrinsic_metadata.mcast_grp").set(0);
- }
- }
-};
-
-REGISTER_PRIMITIVE(drop);
-
-class exit_ : public ActionPrimitive<> {
- void operator ()() {
- get_packet().mark_for_exit();
- }
-};
-
-REGISTER_PRIMITIVE_W_NAME("exit", exit_);
-
-class generate_digest : public ActionPrimitive {
- void operator ()(const Data &receiver, const Data &learn_id) {
- // discared receiver for now
- (void) receiver;
- get_field("intrinsic_metadata.lf_field_list").set(learn_id);
- }
-};
-
-REGISTER_PRIMITIVE(generate_digest);
-
-class add_header : public ActionPrimitive {
- void operator ()(Header &hdr) {
- // TODO(antonin): reset header to 0?
- if (!hdr.is_valid()) {
- hdr.reset();
- hdr.mark_valid();
- // updated the length packet register (register 0)
- auto &packet = get_packet();
- packet.set_register(0, packet.get_register(0) + hdr.get_nbytes_packet());
- }
- }
-};
-
-REGISTER_PRIMITIVE(add_header);
-
-class add_header_fast : public ActionPrimitive {
- void operator ()(Header &hdr) {
- hdr.mark_valid();
- }
-};
-
-REGISTER_PRIMITIVE(add_header_fast);
-
-class remove_header : public ActionPrimitive {
- void operator ()(Header &hdr) {
- if (hdr.is_valid()) {
- // updated the length packet register (register 0)
- auto &packet = get_packet();
- packet.set_register(0, packet.get_register(0) - hdr.get_nbytes_packet());
- hdr.mark_invalid();
- }
- }
-};
-
-REGISTER_PRIMITIVE(remove_header);
-
-class copy_header : public ActionPrimitive {
- void operator ()(Header &dst, const Header &src) {
- bm::core::assign_header()(dst, src);
- }
-};
-
-REGISTER_PRIMITIVE(copy_header);
-
-/* standard_metadata.clone_spec will contain the mirror id (16 LSB) and the
- field list id to copy (16 MSB) */
-class clone_ingress_pkt_to_egress
- : public ActionPrimitive {
- void operator ()(const Data &clone_spec, const Data &field_list_id) {
- Field &f_clone_spec = get_field("standard_metadata.clone_spec");
- f_clone_spec.shift_left(field_list_id, 16);
- f_clone_spec.add(f_clone_spec, clone_spec);
- }
-};
-
-REGISTER_PRIMITIVE(clone_ingress_pkt_to_egress);
-
-class clone_egress_pkt_to_egress
- : public ActionPrimitive {
- void operator ()(const Data &clone_spec, const Data &field_list_id) {
- Field &f_clone_spec = get_field("standard_metadata.clone_spec");
- f_clone_spec.shift_left(field_list_id, 16);
- f_clone_spec.add(f_clone_spec, clone_spec);
- }
-};
-
-REGISTER_PRIMITIVE(clone_egress_pkt_to_egress);
-
-class resubmit : public ActionPrimitive {
- void operator ()(const Data &field_list_id) {
- if (get_phv().has_field("intrinsic_metadata.resubmit_flag")) {
- get_phv().get_field("intrinsic_metadata.resubmit_flag")
- .set(field_list_id);
- }
- }
-};
-
-REGISTER_PRIMITIVE(resubmit);
-
-class recirculate : public ActionPrimitive {
- void operator ()(const Data &field_list_id) {
- if (get_phv().has_field("intrinsic_metadata.recirculate_flag")) {
- get_phv().get_field("intrinsic_metadata.recirculate_flag")
- .set(field_list_id);
- }
- }
-};
-
-REGISTER_PRIMITIVE(recirculate);
-
-class modify_field_with_hash_based_offset
- : public ActionPrimitive {
- void operator ()(Data &dst, const Data &base,
- const NamedCalculation &hash, const Data &size) {
- uint64_t v =
- (hash.output(get_packet()) % size.get()) + base.get();
- dst.set(v);
- }
-};
-
-REGISTER_PRIMITIVE(modify_field_with_hash_based_offset);
-
-class no_op : public ActionPrimitive<> {
- void operator ()() {
- // nothing
- }
-};
-
-REGISTER_PRIMITIVE(no_op);
-
-class execute_meter
- : public ActionPrimitive {
- void operator ()(MeterArray &meter_array, const Data &idx, Field &dst) {
- dst.set(meter_array.execute_meter(get_packet(), idx.get_uint()));
- }
-};
-
-REGISTER_PRIMITIVE(execute_meter);
-
-class count : public ActionPrimitive {
- void operator ()(CounterArray &counter_array, const Data &idx) {
- counter_array.get_counter(idx.get_uint()).increment_counter(get_packet());
- }
-};
-
-REGISTER_PRIMITIVE(count);
-
-class register_read
- : public ActionPrimitive {
- void operator ()(Field &dst, const RegisterArray &src, const Data &idx) {
- dst.set(src[idx.get_uint()]);
- }
-};
-
-REGISTER_PRIMITIVE(register_read);
-
-class register_write
- : public ActionPrimitive {
- void operator ()(RegisterArray &dst, const Data &idx, const Data &src) {
- dst[idx.get_uint()].set(src);
- }
-};
-
-REGISTER_PRIMITIVE(register_write);
-
-class push : public ActionPrimitive {
- void operator ()(HeaderStack &stack, const Data &num) {
- stack.push_front(num.get_uint());
- }
-};
-
-REGISTER_PRIMITIVE(push);
-
-class pop : public ActionPrimitive {
- void operator ()(HeaderStack &stack, const Data &num) {
- stack.pop_front(num.get_uint());
- }
-};
-
-REGISTER_PRIMITIVE(pop);
-
-// I cannot name this "truncate" and register it with the usual
-// REGISTER_PRIMITIVE macro, because of a name conflict:
-//
-// In file included from /usr/include/boost/config/stdlib/libstdcpp3.hpp:77:0,
-// from /usr/include/boost/config.hpp:44,
-// from /usr/include/boost/cstdint.hpp:36,
-// from /usr/include/boost/multiprecision/number.hpp:9,
-// from /usr/include/boost/multiprecision/gmp.hpp:9,
-// from ../../src/bm_sim/include/bm_sim/bignum.h:25,
-// from ../../src/bm_sim/include/bm_sim/data.h:32,
-// from ../../src/bm_sim/include/bm_sim/fields.h:28,
-// from ../../src/bm_sim/include/bm_sim/phv.h:34,
-// from ../../src/bm_sim/include/bm_sim/actions.h:34,
-// from primitives.cpp:21:
-// /usr/include/unistd.h:993:12: note: declared here
-// extern int truncate (const char *__file, __off_t __length)
-class truncate_ : public ActionPrimitive {
- void operator ()(const Data &truncated_length) {
- get_packet().truncate(truncated_length.get());
- }
-};
-
-REGISTER_PRIMITIVE_W_NAME("truncate", truncate_);
-
-// dummy function, which ensures that this unit is not discarded by the linker
-// it is being called by the constructor of SimpleSwitch
-// the previous alternative was to have all the primitives in a header file (the
-// primitives could also be placed in simple_switch.cpp directly), but I need
-// this dummy function if I want to keep the primitives in their own file
-int import_primitives() {
- return 0;
-}
diff --git a/bm/p4-sai/run_server.sh b/bm/p4-sai/run_server.sh
deleted file mode 100755
index 35ad83ec0..000000000
--- a/bm/p4-sai/run_server.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-set -m
-rm -rf log.txt
-sudo -v
-# sudo ./simple_switch -i 0@sw_port0 -i 1@sw_port1 -i 2@sw_port2 -i 3@sw_port3 -i 4@sw_port4 -i 5@sw_port5 -i 6@sw_port6 -i 7@sw_port7 -i 8@cpu_port --log-file log --log-flush sai.json &
-sudo ./simple_switch -i 0@sw_port0 -i 1@sw_port1 -i 2@sw_port2 -i 3@sw_port3 -i 4@sw_port4 -i 5@sw_port5 -i 6@sw_port6 -i 7@sw_port7 -i 8@cpu_port --log-file log --log-flush --pcap sai.json &
-sleep 2
-./runtime_CLI --pre SimplePreLAG < p4src/DefaultConfig.txt
-./sswitch_CLI < p4src/DefaultConfigMirror.txt
-fg
\ No newline at end of file
diff --git a/bm/p4-sai/runtime_CLI b/bm/p4-sai/runtime_CLI
deleted file mode 120000
index ecc87a5c4..000000000
--- a/bm/p4-sai/runtime_CLI
+++ /dev/null
@@ -1 +0,0 @@
-../behavioral-model/tools/runtime_CLI.py
\ No newline at end of file
diff --git a/bm/p4-sai/sai.json b/bm/p4-sai/sai.json
deleted file mode 100644
index 5fc4ea0df..000000000
--- a/bm/p4-sai/sai.json
+++ /dev/null
@@ -1,3792 +0,0 @@
-{
- "header_types": [
- {
- "name": "standard_metadata_t",
- "id": 0,
- "fields": [
- [
- "ingress_port",
- 9
- ],
- [
- "packet_length",
- 32
- ],
- [
- "egress_spec",
- 9
- ],
- [
- "egress_port",
- 9
- ],
- [
- "egress_instance",
- 32
- ],
- [
- "instance_type",
- 32
- ],
- [
- "clone_spec",
- 32
- ],
- [
- "_padding",
- 5
- ]
- ],
- "length_exp": null,
- "max_length": null
- },
- {
- "name": "ethernet_t",
- "id": 1,
- "fields": [
- [
- "dstAddr",
- 48
- ],
- [
- "srcAddr",
- 48
- ],
- [
- "etherType",
- 16
- ]
- ],
- "length_exp": null,
- "max_length": null
- },
- {
- "name": "vlan_t",
- "id": 2,
- "fields": [
- [
- "pcp",
- 3
- ],
- [
- "cfi",
- 1
- ],
- [
- "vid",
- 12
- ],
- [
- "etherType",
- 16
- ]
- ],
- "length_exp": null,
- "max_length": null
- },
- {
- "name": "ipv4_t",
- "id": 3,
- "fields": [
- [
- "version",
- 4
- ],
- [
- "ihl",
- 4
- ],
- [
- "diffserv",
- 8
- ],
- [
- "ipv4_length",
- 16
- ],
- [
- "id",
- 16
- ],
- [
- "flags",
- 3
- ],
- [
- "offset",
- 13
- ],
- [
- "ttl",
- 8
- ],
- [
- "protocol",
- 8
- ],
- [
- "checksum",
- 16
- ],
- [
- "srcAddr",
- 32
- ],
- [
- "dstAddr",
- 32
- ]
- ],
- "length_exp": null,
- "max_length": null
- },
- {
- "name": "tcp_t",
- "id": 4,
- "fields": [
- [
- "srcPort",
- 16
- ],
- [
- "dstPort",
- 16
- ],
- [
- "seqNo",
- 32
- ],
- [
- "ackNo",
- 32
- ],
- [
- "dataOffset",
- 4
- ],
- [
- "res",
- 4
- ],
- [
- "flags",
- 8
- ],
- [
- "window",
- 16
- ],
- [
- "checksum",
- 16
- ],
- [
- "urgentPtr",
- 16
- ]
- ],
- "length_exp": null,
- "max_length": null
- },
- {
- "name": "udp_t",
- "id": 5,
- "fields": [
- [
- "srcPort",
- 16
- ],
- [
- "dstPort",
- 16
- ],
- [
- "length_",
- 16
- ],
- [
- "checksum",
- 16
- ]
- ],
- "length_exp": null,
- "max_length": null
- },
- {
- "name": "ingress_metadata_t",
- "id": 6,
- "fields": [
- [
- "port",
- 6
- ],
- [
- "l2_if",
- 6
- ],
- [
- "is_tagged",
- 1
- ],
- [
- "is_lag",
- 1
- ],
- [
- "lag_id",
- 16
- ],
- [
- "bind_mode",
- 1
- ],
- [
- "l2_if_type",
- 2
- ],
- [
- "bridge_port",
- 8
- ],
- [
- "bridge_id",
- 12
- ],
- [
- "stp_state",
- 2
- ],
- [
- "stp_id",
- 3
- ],
- [
- "vid",
- 12
- ],
- [
- "unknown_unicast",
- 1
- ],
- [
- "mcast_mode",
- 2
- ],
- [
- "mc_fdb_miss",
- 1
- ],
- [
- "ipmc",
- 1
- ],
- [
- "isip",
- 1
- ],
- [
- "go_to_router",
- 1
- ],
- [
- "mtu",
- 32
- ],
- [
- "drop_tagged",
- 1
- ],
- [
- "drop_untagged",
- 1
- ],
- [
- "trap_id",
- 11
- ],
- [
- "_padding",
- 6
- ]
- ],
- "length_exp": null,
- "max_length": null
- },
- {
- "name": "egress_metadata_t",
- "id": 7,
- "fields": [
- [
- "out_if_type",
- 1
- ],
- [
- "out_if",
- 6
- ],
- [
- "stp_state",
- 2
- ],
- [
- "tag_mode",
- 1
- ],
- [
- "hash_val",
- 6
- ],
- [
- "mcast_grp",
- 4
- ],
- [
- "bridge_port",
- 8
- ],
- [
- "_padding",
- 4
- ]
- ],
- "length_exp": null,
- "max_length": null
- },
- {
- "name": "intrinsic_metadata_t",
- "id": 8,
- "fields": [
- [
- "ingress_global_timestamp",
- 48
- ],
- [
- "lf_field_list",
- 8
- ],
- [
- "mcast_grp",
- 16
- ],
- [
- "egress_rid",
- 16
- ],
- [
- "resubmit_flag",
- 8
- ],
- [
- "recirculate_flag",
- 8
- ]
- ],
- "length_exp": null,
- "max_length": null
- },
- {
- "name": "cpu_header_t",
- "id": 9,
- "fields": [
- [
- "trap_id",
- 16
- ],
- [
- "bridge_id",
- 16
- ],
- [
- "ingress_port",
- 8
- ],
- [
- "bridge_port",
- 8
- ]
- ],
- "length_exp": null,
- "max_length": null
- }
- ],
- "headers": [
- {
- "name": "standard_metadata",
- "id": 0,
- "header_type": "standard_metadata_t",
- "metadata": true
- },
- {
- "name": "intrinsic_metadata",
- "id": 1,
- "header_type": "intrinsic_metadata_t",
- "metadata": true
- },
- {
- "name": "ethernet",
- "id": 2,
- "header_type": "ethernet_t",
- "metadata": false
- },
- {
- "name": "vlan",
- "id": 3,
- "header_type": "vlan_t",
- "metadata": false
- },
- {
- "name": "ipv4",
- "id": 4,
- "header_type": "ipv4_t",
- "metadata": false
- },
- {
- "name": "tcp",
- "id": 5,
- "header_type": "tcp_t",
- "metadata": false
- },
- {
- "name": "udp",
- "id": 6,
- "header_type": "udp_t",
- "metadata": false
- },
- {
- "name": "cpu_header",
- "id": 7,
- "header_type": "cpu_header_t",
- "metadata": false
- },
- {
- "name": "ingress_metadata",
- "id": 8,
- "header_type": "ingress_metadata_t",
- "metadata": true
- },
- {
- "name": "egress_metadata",
- "id": 9,
- "header_type": "egress_metadata_t",
- "metadata": true
- }
- ],
- "header_stacks": [],
- "parsers": [
- {
- "name": "parser",
- "id": 0,
- "init_state": "start",
- "parse_states": [
- {
- "name": "parse_udp",
- "id": 0,
- "parser_ops": [
- {
- "op": "extract",
- "parameters": [
- {
- "type": "regular",
- "value": "udp"
- }
- ]
- }
- ],
- "transition_key": [],
- "transitions": [
- {
- "type": "default",
- "value": null,
- "mask": null,
- "next_state": null
- }
- ]
- },
- {
- "name": "parse_vlan",
- "id": 1,
- "parser_ops": [
- {
- "op": "extract",
- "parameters": [
- {
- "type": "regular",
- "value": "vlan"
- }
- ]
- },
- {
- "op": "set",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "is_tagged"
- ]
- },
- {
- "type": "expression",
- "value": {
- "type": "expression",
- "value": {
- "op": "|",
- "left": {
- "type": "expression",
- "value": {
- "op": "|",
- "left": {
- "type": "expression",
- "value": {
- "op": "|",
- "left": {
- "type": "expression",
- "value": {
- "op": "|",
- "left": {
- "type": "expression",
- "value": {
- "op": "|",
- "left": {
- "type": "expression",
- "value": {
- "op": "|",
- "left": {
- "type": "expression",
- "value": {
- "op": "|",
- "left": {
- "type": "expression",
- "value": {
- "op": "|",
- "left": {
- "type": "expression",
- "value": {
- "op": "|",
- "left": {
- "type": "expression",
- "value": {
- "op": "|",
- "left": {
- "type": "expression",
- "value": {
- "op": "|",
- "left": {
- "type": "expression",
- "value": {
- "op": ">>",
- "left": {
- "type": "field",
- "value": [
- "vlan",
- "vid"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0xb"
- }
- }
- },
- "right": {
- "type": "expression",
- "value": {
- "op": ">>",
- "left": {
- "type": "field",
- "value": [
- "vlan",
- "vid"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0xa"
- }
- }
- }
- }
- },
- "right": {
- "type": "expression",
- "value": {
- "op": ">>",
- "left": {
- "type": "field",
- "value": [
- "vlan",
- "vid"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x9"
- }
- }
- }
- }
- },
- "right": {
- "type": "expression",
- "value": {
- "op": ">>",
- "left": {
- "type": "field",
- "value": [
- "vlan",
- "vid"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x8"
- }
- }
- }
- }
- },
- "right": {
- "type": "expression",
- "value": {
- "op": ">>",
- "left": {
- "type": "field",
- "value": [
- "vlan",
- "vid"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x7"
- }
- }
- }
- }
- },
- "right": {
- "type": "expression",
- "value": {
- "op": ">>",
- "left": {
- "type": "field",
- "value": [
- "vlan",
- "vid"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x6"
- }
- }
- }
- }
- },
- "right": {
- "type": "expression",
- "value": {
- "op": ">>",
- "left": {
- "type": "field",
- "value": [
- "vlan",
- "vid"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x5"
- }
- }
- }
- }
- },
- "right": {
- "type": "expression",
- "value": {
- "op": ">>",
- "left": {
- "type": "field",
- "value": [
- "vlan",
- "vid"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x4"
- }
- }
- }
- }
- },
- "right": {
- "type": "expression",
- "value": {
- "op": ">>",
- "left": {
- "type": "field",
- "value": [
- "vlan",
- "vid"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x3"
- }
- }
- }
- }
- },
- "right": {
- "type": "expression",
- "value": {
- "op": ">>",
- "left": {
- "type": "field",
- "value": [
- "vlan",
- "vid"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x2"
- }
- }
- }
- }
- },
- "right": {
- "type": "expression",
- "value": {
- "op": ">>",
- "left": {
- "type": "field",
- "value": [
- "vlan",
- "vid"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x1"
- }
- }
- }
- }
- },
- "right": {
- "type": "field",
- "value": [
- "vlan",
- "vid"
- ]
- }
- }
- }
- }
- ]
- }
- ],
- "transition_key": [
- {
- "type": "field",
- "value": [
- "vlan",
- "etherType"
- ]
- }
- ],
- "transitions": [
- {
- "type": "hexstr",
- "value": "0x0800",
- "mask": null,
- "next_state": "parse_ipv4"
- },
- {
- "type": "default",
- "value": null,
- "mask": null,
- "next_state": null
- }
- ]
- },
- {
- "name": "start",
- "id": 2,
- "parser_ops": [],
- "transition_key": [
- {
- "type": "lookahead",
- "value": [
- 0,
- 64
- ]
- }
- ],
- "transitions": [
- {
- "type": "hexstr",
- "value": "0x0000000000000000",
- "mask": null,
- "next_state": "parse_cpu_header"
- },
- {
- "type": "default",
- "value": null,
- "mask": null,
- "next_state": "parse_ethernet"
- }
- ]
- },
- {
- "name": "parse_ipv4",
- "id": 3,
- "parser_ops": [
- {
- "op": "extract",
- "parameters": [
- {
- "type": "regular",
- "value": "ipv4"
- }
- ]
- },
- {
- "op": "set",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "isip"
- ]
- },
- {
- "type": "hexstr",
- "value": "0x1"
- }
- ]
- }
- ],
- "transition_key": [],
- "transitions": [
- {
- "type": "default",
- "value": null,
- "mask": null,
- "next_state": "post_parse_ipv4"
- }
- ]
- },
- {
- "name": "parse_tcp",
- "id": 4,
- "parser_ops": [
- {
- "op": "extract",
- "parameters": [
- {
- "type": "regular",
- "value": "tcp"
- }
- ]
- }
- ],
- "transition_key": [],
- "transitions": [
- {
- "type": "default",
- "value": null,
- "mask": null,
- "next_state": null
- }
- ]
- },
- {
- "name": "parse_cpu_header",
- "id": 5,
- "parser_ops": [
- {
- "op": "extract",
- "parameters": [
- {
- "type": "regular",
- "value": "cpu_header"
- }
- ]
- }
- ],
- "transition_key": [],
- "transitions": [
- {
- "type": "default",
- "value": null,
- "mask": null,
- "next_state": "parse_ethernet"
- }
- ]
- },
- {
- "name": "parse_ethernet",
- "id": 6,
- "parser_ops": [
- {
- "op": "extract",
- "parameters": [
- {
- "type": "regular",
- "value": "ethernet"
- }
- ]
- },
- {
- "op": "set",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "is_tagged"
- ]
- },
- {
- "type": "hexstr",
- "value": "0x0"
- }
- ]
- }
- ],
- "transition_key": [
- {
- "type": "field",
- "value": [
- "ethernet",
- "etherType"
- ]
- }
- ],
- "transitions": [
- {
- "type": "hexstr",
- "value": "0x8100",
- "mask": null,
- "next_state": "parse_vlan"
- },
- {
- "type": "hexstr",
- "value": "0x0800",
- "mask": null,
- "next_state": "parse_ipv4"
- },
- {
- "type": "default",
- "value": null,
- "mask": null,
- "next_state": null
- }
- ]
- },
- {
- "name": "post_parse_ipv4",
- "id": 7,
- "parser_ops": [],
- "transition_key": [
- {
- "type": "field",
- "value": [
- "ipv4",
- "protocol"
- ]
- }
- ],
- "transitions": [
- {
- "type": "hexstr",
- "value": "0x06",
- "mask": null,
- "next_state": "parse_tcp"
- },
- {
- "type": "hexstr",
- "value": "0x11",
- "mask": null,
- "next_state": "parse_udp"
- },
- {
- "type": "default",
- "value": null,
- "mask": null,
- "next_state": null
- }
- ]
- }
- ]
- }
- ],
- "parse_vsets": [],
- "deparsers": [
- {
- "name": "deparser",
- "id": 0,
- "order": [
- "cpu_header",
- "ethernet",
- "vlan",
- "ipv4",
- "tcp",
- "udp"
- ]
- }
- ],
- "meter_arrays": [],
- "actions": [
- {
- "name": "action_set_l2if",
- "id": 0,
- "runtime_data": [],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "l2_if"
- ]
- },
- {
- "type": "field",
- "value": [
- "standard_metadata",
- "ingress_port"
- ]
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_egress_stp_state",
- "id": 1,
- "runtime_data": [
- {
- "name": "stp_state",
- "bitwidth": 2
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "egress_metadata",
- "stp_state"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- }
- ]
- },
- {
- "name": "action_forward_vlan_untag",
- "id": 2,
- "runtime_data": [],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ethernet",
- "etherType"
- ]
- },
- {
- "type": "field",
- "value": [
- "vlan",
- "etherType"
- ]
- }
- ]
- },
- {
- "op": "remove_header",
- "parameters": [
- {
- "type": "header",
- "value": "vlan"
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_port_configurations",
- "id": 3,
- "runtime_data": [
- {
- "name": "pvid",
- "bitwidth": 12
- },
- {
- "name": "bind_mode",
- "bitwidth": 1
- },
- {
- "name": "mtu",
- "bitwidth": 32
- },
- {
- "name": "drop_tagged",
- "bitwidth": 1
- },
- {
- "name": "drop_untagged",
- "bitwidth": 1
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "vid"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "bind_mode"
- ]
- },
- {
- "type": "runtime_data",
- "value": 1
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "mtu"
- ]
- },
- {
- "type": "runtime_data",
- "value": 2
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "drop_tagged"
- ]
- },
- {
- "type": "runtime_data",
- "value": 3
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "drop_untagged"
- ]
- },
- {
- "type": "runtime_data",
- "value": 4
- }
- ]
- }
- ]
- },
- {
- "name": "action_forward_vlan_tag",
- "id": 4,
- "runtime_data": [
- {
- "name": "pcp",
- "bitwidth": 3
- },
- {
- "name": "cfi",
- "bitwidth": 1
- },
- {
- "name": "vid",
- "bitwidth": 12
- }
- ],
- "primitives": [
- {
- "op": "add_header",
- "parameters": [
- {
- "type": "header",
- "value": "vlan"
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "vlan",
- "pcp"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "vlan",
- "cfi"
- ]
- },
- {
- "type": "runtime_data",
- "value": 1
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "vlan",
- "vid"
- ]
- },
- {
- "type": "runtime_data",
- "value": 2
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "vlan",
- "etherType"
- ]
- },
- {
- "type": "field",
- "value": [
- "ethernet",
- "etherType"
- ]
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ethernet",
- "etherType"
- ]
- },
- {
- "type": "hexstr",
- "value": "0x8100"
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_l2_if_type",
- "id": 5,
- "runtime_data": [
- {
- "name": "l2_if_type",
- "bitwidth": 2
- },
- {
- "name": "bridge_port",
- "bitwidth": 8
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "l2_if_type"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "bridge_port"
- ]
- },
- {
- "type": "runtime_data",
- "value": 1
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_out_port",
- "id": 6,
- "runtime_data": [
- {
- "name": "port",
- "bitwidth": 6
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "standard_metadata",
- "egress_spec"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_packet_vid",
- "id": 7,
- "runtime_data": [],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "vid"
- ]
- },
- {
- "type": "field",
- "value": [
- "vlan",
- "vid"
- ]
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_mc_fdb_miss",
- "id": 8,
- "runtime_data": [],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "mc_fdb_miss"
- ]
- },
- {
- "type": "hexstr",
- "value": "0x1"
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_bridge_id",
- "id": 9,
- "runtime_data": [
- {
- "name": "bridge_id",
- "bitwidth": 12
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "bridge_id"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_bridge_id_vid",
- "id": 10,
- "runtime_data": [],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "bridge_id"
- ]
- },
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "vid"
- ]
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_mcast_lookup_mode",
- "id": 11,
- "runtime_data": [
- {
- "name": "mcast_mode",
- "bitwidth": 2
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "mcast_mode"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_stp_state",
- "id": 12,
- "runtime_data": [
- {
- "name": "stp_state",
- "bitwidth": 3
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "stp_state"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_vlan",
- "id": 13,
- "runtime_data": [
- {
- "name": "vid",
- "bitwidth": 12
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "vid"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_stp_id",
- "id": 14,
- "runtime_data": [
- {
- "name": "stp_id",
- "bitwidth": 3
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "stp_id"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- }
- ]
- },
- {
- "name": "action_learn_mac",
- "id": 15,
- "runtime_data": [],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "trap_id"
- ]
- },
- {
- "type": "hexstr",
- "value": "0x200"
- }
- ]
- },
- {
- "op": "clone_ingress_pkt_to_egress",
- "parameters": [
- {
- "type": "hexstr",
- "value": "0x8"
- },
- {
- "type": "hexstr",
- "value": "0x1"
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_egress_br_port",
- "id": 16,
- "runtime_data": [
- {
- "name": "br_port",
- "bitwidth": 8
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "egress_metadata",
- "bridge_port"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- }
- ]
- },
- {
- "name": "_drop",
- "id": 17,
- "runtime_data": [],
- "primitives": [
- {
- "op": "drop",
- "parameters": []
- }
- ]
- },
- {
- "name": "action_cpu_encap",
- "id": 18,
- "runtime_data": [],
- "primitives": [
- {
- "op": "add_header",
- "parameters": [
- {
- "type": "header",
- "value": "cpu_header"
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "cpu_header",
- "ingress_port"
- ]
- },
- {
- "type": "field",
- "value": [
- "standard_metadata",
- "ingress_port"
- ]
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "cpu_header",
- "trap_id"
- ]
- },
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "trap_id"
- ]
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "cpu_header",
- "bridge_id"
- ]
- },
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "bridge_id"
- ]
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "cpu_header",
- "bridge_port"
- ]
- },
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "bridge_port"
- ]
- }
- ]
- }
- ]
- },
- {
- "name": "_nop",
- "id": 19,
- "runtime_data": [],
- "primitives": [
- {
- "op": "no_op",
- "parameters": []
- }
- ]
- },
- {
- "name": "action_set_lag_l2if",
- "id": 20,
- "runtime_data": [
- {
- "name": "is_lag",
- "bitwidth": 1
- },
- {
- "name": "l2_if",
- "bitwidth": 6
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "is_lag"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "l2_if"
- ]
- },
- {
- "type": "runtime_data",
- "value": 1
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_trap_id",
- "id": 21,
- "runtime_data": [
- {
- "name": "trap_id",
- "bitwidth": 11
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "trap_id"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- }
- ]
- },
- {
- "name": "action_trap_to_cpu",
- "id": 22,
- "runtime_data": [],
- "primitives": [
- {
- "op": "clone_ingress_pkt_to_egress",
- "parameters": [
- {
- "type": "hexstr",
- "value": "0x8"
- },
- {
- "type": "hexstr",
- "value": "0x1"
- }
- ]
- },
- {
- "op": "drop",
- "parameters": []
- }
- ]
- },
- {
- "name": "action_set_unknown_unicast",
- "id": 23,
- "runtime_data": [
- {
- "name": "unknown_unicast",
- "bitwidth": 1
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "unknown_unicast"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- }
- ]
- },
- {
- "name": "action_copy_to_cpu",
- "id": 24,
- "runtime_data": [],
- "primitives": [
- {
- "op": "clone_ingress_pkt_to_egress",
- "parameters": [
- {
- "type": "hexstr",
- "value": "0x8"
- },
- {
- "type": "hexstr",
- "value": "0x1"
- }
- ]
- }
- ]
- },
- {
- "name": "action_forward_set_outIfType",
- "id": 25,
- "runtime_data": [
- {
- "name": "out_if",
- "bitwidth": 6
- },
- {
- "name": "out_if_type",
- "bitwidth": 1
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "egress_metadata",
- "out_if"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "egress_metadata",
- "out_if_type"
- ]
- },
- {
- "type": "runtime_data",
- "value": 1
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "standard_metadata",
- "egress_spec"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- }
- ]
- },
- {
- "name": "action_forward_mc_set_if_list",
- "id": 26,
- "runtime_data": [
- {
- "name": "mcast_grp",
- "bitwidth": 16
- },
- {
- "name": "go_to_router",
- "bitwidth": 1
- }
- ],
- "primitives": [
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "intrinsic_metadata",
- "mcast_grp"
- ]
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- },
- {
- "op": "modify_field",
- "parameters": [
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "go_to_router"
- ]
- },
- {
- "type": "runtime_data",
- "value": 1
- }
- ]
- }
- ]
- },
- {
- "name": "action_set_lag_hash_size",
- "id": 27,
- "runtime_data": [
- {
- "name": "lag_size",
- "bitwidth": 6
- }
- ],
- "primitives": [
- {
- "op": "modify_field_with_hash_based_offset",
- "parameters": [
- {
- "type": "field",
- "value": [
- "egress_metadata",
- "hash_val"
- ]
- },
- {
- "type": "hexstr",
- "value": "0x0"
- },
- {
- "type": "calculation",
- "value": "lag_hash"
- },
- {
- "type": "runtime_data",
- "value": 0
- }
- ]
- }
- ]
- }
- ],
- "pipelines": [
- {
- "name": "ingress",
- "id": 0,
- "init_table": "table_ingress_lag",
- "tables": [
- {
- "name": "table_ingress_lag",
- "id": 0,
- "match_type": "exact",
- "type": "simple",
- "max_size": 64,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "standard_metadata",
- "ingress_port"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_lag_l2if",
- "action_set_l2if"
- ],
- "next_tables": {
- "action_set_lag_l2if": "table_port_configurations",
- "action_set_l2if": "table_port_configurations"
- },
- "base_default_next": "table_port_configurations"
- },
- {
- "name": "table_drop_tagged_internal",
- "id": 1,
- "match_type": "exact",
- "type": "simple",
- "max_size": 1,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "drop_tagged"
- ],
- "mask": null
- }
- ],
- "actions": [
- "_drop",
- "_nop"
- ],
- "next_tables": {
- "_drop": "table_l2_trap",
- "_nop": "table_l2_trap"
- },
- "base_default_next": "table_l2_trap"
- },
- {
- "name": "table_drop_untagged_internal",
- "id": 2,
- "match_type": "exact",
- "type": "simple",
- "max_size": 1,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "drop_untagged"
- ],
- "mask": null
- }
- ],
- "actions": [
- "_drop",
- "_nop"
- ],
- "next_tables": {
- "_drop": "table_l2_trap",
- "_nop": "table_l2_trap"
- },
- "base_default_next": "table_l2_trap"
- },
- {
- "name": "table_l2_trap",
- "id": 3,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ethernet",
- "dstAddr"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_trap_id"
- ],
- "next_tables": {
- "action_set_trap_id": "table_trap_id"
- },
- "base_default_next": "table_trap_id"
- },
- {
- "name": "table_trap_id",
- "id": 4,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "trap_id"
- ],
- "mask": null
- }
- ],
- "actions": [
- "_drop",
- "_nop",
- "action_copy_to_cpu",
- "action_trap_to_cpu"
- ],
- "next_tables": {
- "_drop": "_condition_1",
- "_nop": "_condition_1",
- "action_copy_to_cpu": "_condition_1",
- "action_trap_to_cpu": "_condition_1"
- },
- "base_default_next": "_condition_1"
- },
- {
- "name": "table_port_configurations",
- "id": 5,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "l2_if"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_port_configurations"
- ],
- "next_tables": {
- "action_set_port_configurations": "_condition_0"
- },
- "base_default_next": "_condition_0"
- },
- {
- "name": "table_port_set_packet_vid_internal",
- "id": 6,
- "match_type": "exact",
- "type": "simple",
- "max_size": 1,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "is_tagged"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_packet_vid"
- ],
- "next_tables": {
- "action_set_packet_vid": "table_drop_tagged_internal"
- },
- "base_default_next": "table_drop_tagged_internal"
- },
- {
- "name": "table_port_ingress_interface_type",
- "id": 7,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "l2_if"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_l2_if_type",
- "_drop"
- ],
- "next_tables": {
- "action_set_l2_if_type": "_condition_2",
- "_drop": "_condition_2"
- },
- "base_default_next": "_condition_2"
- },
- {
- "name": "table_subport_ingress_interface_type",
- "id": 8,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "l2_if"
- ],
- "mask": null
- },
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "vid"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_l2_if_type",
- "_drop"
- ],
- "next_tables": {
- "action_set_l2_if_type": "_condition_2",
- "_drop": "_condition_2"
- },
- "base_default_next": "_condition_2"
- },
- {
- "name": "table_bridge_id_1d",
- "id": 9,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "bridge_port"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_bridge_id",
- "_drop"
- ],
- "next_tables": {
- "action_set_bridge_id": "table_vbridge_STP",
- "_drop": "table_vbridge_STP"
- },
- "base_default_next": "table_vbridge_STP"
- },
- {
- "name": "table_vbridge_STP",
- "id": 10,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "bridge_port"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_stp_state"
- ],
- "next_tables": {
- "action_set_stp_state": "_condition_4"
- },
- "base_default_next": "_condition_4"
- },
- {
- "name": "table_bridge_id_1q",
- "id": 11,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "vid"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_bridge_id",
- "action_set_bridge_id_vid"
- ],
- "next_tables": {
- "action_set_bridge_id": "table_ingress_vlan_filtering",
- "action_set_bridge_id_vid": "table_ingress_vlan_filtering"
- },
- "base_default_next": "table_ingress_vlan_filtering"
- },
- {
- "name": "table_ingress_vlan_filtering",
- "id": 12,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "bridge_port"
- ],
- "mask": null
- },
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "vid"
- ],
- "mask": null
- }
- ],
- "actions": [
- "_drop",
- "_nop"
- ],
- "next_tables": {
- "_drop": "table_xSTP_instance",
- "_nop": "table_xSTP_instance"
- },
- "base_default_next": "table_xSTP_instance"
- },
- {
- "name": "table_mc_lookup_mode",
- "id": 13,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "vid"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_mcast_lookup_mode"
- ],
- "next_tables": {
- "action_set_mcast_lookup_mode": "_condition_6"
- },
- "base_default_next": "_condition_6"
- },
- {
- "name": "table_xSTP_instance",
- "id": 14,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "vid"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_stp_id"
- ],
- "next_tables": {
- "action_set_stp_id": "table_xSTP"
- },
- "base_default_next": "table_xSTP"
- },
- {
- "name": "table_xSTP",
- "id": 15,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "bridge_port"
- ],
- "mask": null
- },
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "stp_id"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_stp_state",
- "_drop"
- ],
- "next_tables": {
- "action_set_stp_state": "_condition_4",
- "_drop": "_condition_4"
- },
- "base_default_next": "_condition_4"
- },
- {
- "name": "table_learn_fdb",
- "id": 16,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ethernet",
- "srcAddr"
- ],
- "mask": null
- },
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "bridge_id"
- ],
- "mask": null
- }
- ],
- "actions": [
- "_nop",
- "action_learn_mac"
- ],
- "next_tables": {
- "_nop": "table_l3_interface",
- "action_learn_mac": "table_l3_interface"
- },
- "base_default_next": "table_l3_interface"
- },
- {
- "name": "table_l3_interface",
- "id": 17,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ethernet",
- "dstAddr"
- ],
- "mask": null
- },
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "bridge_id"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_egress_br_port"
- ],
- "next_tables": {
- "__HIT__": null,
- "__MISS__": "table_fdb"
- },
- "base_default_next": null
- },
- {
- "name": "table_fdb",
- "id": 18,
- "match_type": "exact",
- "type": "simple",
- "max_size": 512,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ethernet",
- "dstAddr"
- ],
- "mask": null
- },
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "bridge_id"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_egress_br_port",
- "action_set_unknown_unicast"
- ],
- "next_tables": {
- "__HIT__": null,
- "__MISS__": "table_flood"
- },
- "base_default_next": null
- },
- {
- "name": "table_mc_fdb",
- "id": 19,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ethernet",
- "dstAddr"
- ],
- "mask": null
- },
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "bridge_id"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_forward_mc_set_if_list",
- "action_set_mc_fdb_miss"
- ],
- "next_tables": {
- "action_forward_mc_set_if_list": "_condition_8",
- "action_set_mc_fdb_miss": "_condition_8"
- },
- "base_default_next": "_condition_8"
- },
- {
- "name": "table_mc_l2_sg_g",
- "id": 20,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "bridge_id"
- ],
- "mask": null
- },
- {
- "match_type": "exact",
- "target": [
- "ipv4",
- "srcAddr"
- ],
- "mask": null
- },
- {
- "match_type": "exact",
- "target": [
- "ipv4",
- "dstAddr"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_forward_mc_set_if_list",
- "action_set_mc_fdb_miss"
- ],
- "next_tables": {
- "action_forward_mc_set_if_list": "_condition_8",
- "action_set_mc_fdb_miss": "_condition_8"
- },
- "base_default_next": "_condition_8"
- },
- {
- "name": "table_unknown_multicast_nonip",
- "id": 21,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "bridge_id"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_forward_mc_set_if_list"
- ],
- "next_tables": {
- "action_forward_mc_set_if_list": null
- },
- "base_default_next": null
- },
- {
- "name": "table_unknown_multicast_ipv4",
- "id": 22,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "bridge_id"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_forward_mc_set_if_list"
- ],
- "next_tables": {
- "action_forward_mc_set_if_list": null
- },
- "base_default_next": null
- },
- {
- "name": "table_broadcast",
- "id": 23,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "bridge_id"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_forward_mc_set_if_list"
- ],
- "next_tables": {
- "action_forward_mc_set_if_list": null
- },
- "base_default_next": null
- },
- {
- "name": "table_flood",
- "id": 24,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "bridge_id"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_forward_mc_set_if_list"
- ],
- "next_tables": {
- "action_forward_mc_set_if_list": null
- },
- "base_default_next": null
- }
- ],
- "conditionals": [
- {
- "name": "_condition_0",
- "id": 0,
- "expression": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ingress_metadata",
- "is_tagged"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x1"
- }
- }
- },
- "true_next": "table_port_set_packet_vid_internal",
- "false_next": "table_drop_untagged_internal"
- },
- {
- "name": "_condition_1",
- "id": 1,
- "expression": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ingress_metadata",
- "bind_mode"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x0"
- }
- }
- },
- "true_next": "table_port_ingress_interface_type",
- "false_next": "table_subport_ingress_interface_type"
- },
- {
- "name": "_condition_2",
- "id": 2,
- "expression": {
- "type": "expression",
- "value": {
- "op": "or",
- "left": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ingress_metadata",
- "l2_if_type"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x3"
- }
- }
- },
- "right": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ingress_metadata",
- "l2_if_type"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x2"
- }
- }
- }
- }
- },
- "true_next": "_condition_3",
- "false_next": null
- },
- {
- "name": "_condition_3",
- "id": 3,
- "expression": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ingress_metadata",
- "l2_if_type"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x2"
- }
- }
- },
- "true_next": "table_bridge_id_1d",
- "false_next": "table_bridge_id_1q"
- },
- {
- "name": "_condition_4",
- "id": 4,
- "expression": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "expression",
- "value": {
- "op": "&",
- "left": {
- "type": "field",
- "value": [
- "ethernet",
- "dstAddr"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x10000000000"
- }
- }
- },
- "right": {
- "type": "hexstr",
- "value": "0x0"
- }
- }
- },
- "true_next": "table_learn_fdb",
- "false_next": "_condition_5"
- },
- {
- "name": "_condition_5",
- "id": 5,
- "expression": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ethernet",
- "dstAddr"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0xffffffffffff"
- }
- }
- },
- "true_next": "table_broadcast",
- "false_next": "table_mc_lookup_mode"
- },
- {
- "name": "_condition_6",
- "id": 6,
- "expression": {
- "type": "expression",
- "value": {
- "op": "or",
- "left": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ingress_metadata",
- "isip"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x0"
- }
- }
- },
- "right": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ingress_metadata",
- "mcast_mode"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x0"
- }
- }
- }
- }
- },
- "true_next": "table_mc_fdb",
- "false_next": "_condition_7"
- },
- {
- "name": "_condition_7",
- "id": 7,
- "expression": {
- "type": "expression",
- "value": {
- "op": "and",
- "left": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ingress_metadata",
- "isip"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x1"
- }
- }
- },
- "right": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ingress_metadata",
- "mcast_mode"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x2"
- }
- }
- }
- }
- },
- "true_next": "table_mc_l2_sg_g",
- "false_next": "_condition_8"
- },
- {
- "name": "_condition_8",
- "id": 8,
- "expression": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ingress_metadata",
- "mc_fdb_miss"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x1"
- }
- }
- },
- "true_next": "_condition_9",
- "false_next": null
- },
- {
- "name": "_condition_9",
- "id": 9,
- "expression": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ingress_metadata",
- "isip"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x1"
- }
- }
- },
- "true_next": "table_unknown_multicast_ipv4",
- "false_next": "table_unknown_multicast_nonip"
- }
- ]
- },
- {
- "name": "egress",
- "id": 1,
- "init_table": "_condition_11",
- "tables": [
- {
- "name": "table_egress_vbridge_STP",
- "id": 25,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "egress_metadata",
- "bridge_port"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_egress_stp_state",
- "_drop"
- ],
- "next_tables": {
- "action_set_egress_stp_state": "_condition_12",
- "_drop": "_condition_12"
- },
- "base_default_next": "_condition_12"
- },
- {
- "name": "table_egress_vlan_tag",
- "id": 26,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "egress_metadata",
- "out_if"
- ],
- "mask": null
- },
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "vid"
- ],
- "mask": null
- },
- {
- "match_type": "valid",
- "target": "vlan",
- "mask": null
- }
- ],
- "actions": [
- "action_forward_vlan_tag",
- "action_forward_vlan_untag",
- "_drop",
- "_nop"
- ],
- "next_tables": {
- "action_forward_vlan_tag": "_condition_14",
- "action_forward_vlan_untag": "_condition_14",
- "_drop": "_condition_14",
- "_nop": "_condition_14"
- },
- "base_default_next": "_condition_14"
- },
- {
- "name": "table_egress_xSTP",
- "id": 27,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "egress_metadata",
- "bridge_port"
- ],
- "mask": null
- },
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "stp_id"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_egress_stp_state",
- "_drop"
- ],
- "next_tables": {
- "action_set_egress_stp_state": "table_egress_vlan_filtering",
- "_drop": "table_egress_vlan_filtering"
- },
- "base_default_next": "table_egress_vlan_filtering"
- },
- {
- "name": "table_egress_vlan_filtering",
- "id": 28,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "egress_metadata",
- "bridge_port"
- ],
- "mask": null
- },
- {
- "match_type": "exact",
- "target": [
- "ingress_metadata",
- "vid"
- ],
- "mask": null
- }
- ],
- "actions": [
- "_drop",
- "_nop"
- ],
- "next_tables": {
- "_drop": "table_egress_br_port_to_if",
- "_nop": "table_egress_br_port_to_if"
- },
- "base_default_next": "table_egress_br_port_to_if"
- },
- {
- "name": "table_egress_br_port_to_if",
- "id": 29,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "egress_metadata",
- "bridge_port"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_forward_set_outIfType",
- "_drop"
- ],
- "next_tables": {
- "action_forward_set_outIfType": "_condition_13",
- "_drop": "_condition_13"
- },
- "base_default_next": "_condition_13"
- },
- {
- "name": "table_egress_set_vlan",
- "id": 30,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "egress_metadata",
- "bridge_port"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_vlan"
- ],
- "next_tables": {
- "action_set_vlan": "table_egress_vlan_tag"
- },
- "base_default_next": "table_egress_vlan_tag"
- },
- {
- "name": "table_lag_hash",
- "id": 31,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "egress_metadata",
- "out_if"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_lag_hash_size"
- ],
- "next_tables": {
- "action_set_lag_hash_size": "table_egress_lag"
- },
- "base_default_next": "table_egress_lag"
- },
- {
- "name": "table_egress_lag",
- "id": 32,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "egress_metadata",
- "out_if"
- ],
- "mask": null
- },
- {
- "match_type": "exact",
- "target": [
- "egress_metadata",
- "hash_val"
- ],
- "mask": null
- }
- ],
- "actions": [
- "action_set_out_port",
- "_drop"
- ],
- "next_tables": {
- "action_set_out_port": "table_egress_clone_internal",
- "_drop": "table_egress_clone_internal"
- },
- "base_default_next": "table_egress_clone_internal"
- },
- {
- "name": "table_egress_clone_internal",
- "id": 33,
- "match_type": "exact",
- "type": "simple",
- "max_size": 16384,
- "with_counters": false,
- "direct_meters": null,
- "support_timeout": false,
- "key": [
- {
- "match_type": "exact",
- "target": [
- "standard_metadata",
- "instance_type"
- ],
- "mask": null
- }
- ],
- "actions": [
- "_nop",
- "action_cpu_encap"
- ],
- "next_tables": {
- "_nop": null,
- "action_cpu_encap": null
- },
- "base_default_next": null
- }
- ],
- "conditionals": [
- {
- "name": "_condition_11",
- "id": 10,
- "expression": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ingress_metadata",
- "l2_if_type"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x2"
- }
- }
- },
- "true_next": "table_egress_vbridge_STP",
- "false_next": "_condition_12"
- },
- {
- "name": "_condition_12",
- "id": 11,
- "expression": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ingress_metadata",
- "l2_if_type"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x3"
- }
- }
- },
- "true_next": "table_egress_xSTP",
- "false_next": "table_egress_br_port_to_if"
- },
- {
- "name": "_condition_13",
- "id": 12,
- "expression": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "ingress_metadata",
- "l2_if_type"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x2"
- }
- }
- },
- "true_next": "table_egress_set_vlan",
- "false_next": "table_egress_vlan_tag"
- },
- {
- "name": "_condition_14",
- "id": 13,
- "expression": {
- "type": "expression",
- "value": {
- "op": "==",
- "left": {
- "type": "field",
- "value": [
- "egress_metadata",
- "out_if_type"
- ]
- },
- "right": {
- "type": "hexstr",
- "value": "0x1"
- }
- }
- },
- "true_next": "table_lag_hash",
- "false_next": "table_egress_clone_internal"
- }
- ]
- }
- ],
- "calculations": [
- {
- "name": "lag_hash",
- "id": 0,
- "input": [
- {
- "type": "field",
- "value": [
- "ethernet",
- "srcAddr"
- ]
- },
- {
- "type": "field",
- "value": [
- "ipv4",
- "id"
- ]
- }
- ],
- "algo": "xor8"
- }
- ],
- "checksums": [],
- "learn_lists": [],
- "field_lists": [
- {
- "id": 1,
- "name": "redirect_FL",
- "elements": [
- {
- "type": "field",
- "value": [
- "standard_metadata",
- "ingress_port"
- ]
- },
- {
- "type": "field",
- "value": [
- "standard_metadata",
- "packet_length"
- ]
- },
- {
- "type": "field",
- "value": [
- "standard_metadata",
- "egress_spec"
- ]
- },
- {
- "type": "field",
- "value": [
- "standard_metadata",
- "egress_port"
- ]
- },
- {
- "type": "field",
- "value": [
- "standard_metadata",
- "egress_instance"
- ]
- },
- {
- "type": "field",
- "value": [
- "standard_metadata",
- "instance_type"
- ]
- },
- {
- "type": "field",
- "value": [
- "standard_metadata",
- "clone_spec"
- ]
- },
- {
- "type": "field",
- "value": [
- "standard_metadata",
- "_padding"
- ]
- },
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "trap_id"
- ]
- },
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "bridge_id"
- ]
- },
- {
- "type": "field",
- "value": [
- "ingress_metadata",
- "bridge_port"
- ]
- }
- ]
- }
- ],
- "counter_arrays": [],
- "register_arrays": [],
- "force_arith": [
- [
- "standard_metadata",
- "ingress_port"
- ],
- [
- "standard_metadata",
- "packet_length"
- ],
- [
- "standard_metadata",
- "egress_spec"
- ],
- [
- "standard_metadata",
- "egress_port"
- ],
- [
- "standard_metadata",
- "egress_instance"
- ],
- [
- "standard_metadata",
- "instance_type"
- ],
- [
- "standard_metadata",
- "clone_spec"
- ],
- [
- "standard_metadata",
- "_padding"
- ],
- [
- "intrinsic_metadata",
- "ingress_global_timestamp"
- ],
- [
- "intrinsic_metadata",
- "lf_field_list"
- ],
- [
- "intrinsic_metadata",
- "mcast_grp"
- ],
- [
- "intrinsic_metadata",
- "egress_rid"
- ],
- [
- "intrinsic_metadata",
- "resubmit_flag"
- ],
- [
- "intrinsic_metadata",
- "recirculate_flag"
- ]
- ]
-}
\ No newline at end of file
diff --git a/bm/p4-sai/simple_switch.cpp b/bm/p4-sai/simple_switch.cpp
deleted file mode 100644
index d73bbe9f4..000000000
--- a/bm/p4-sai/simple_switch.cpp
+++ /dev/null
@@ -1,531 +0,0 @@
-/* Copyright 2013-present Barefoot Networks, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Antonin Bas (antonin@barefootnetworks.com)
- *
- */
-
-#include
-#include
-#include
-
-#include
-
-#include
-#include
-#include
-
-#include "simple_switch.h"
-
-namespace {
-
-struct hash_ex {
- uint32_t operator()(const char *buf, size_t s) const {
- const int p = 16777619;
- int hash = 2166136261;
-
- for (size_t i = 0; i < s; i++)
- hash = (hash ^ buf[i]) * p;
-
- hash += hash << 13;
- hash ^= hash >> 7;
- hash += hash << 3;
- hash ^= hash >> 17;
- hash += hash << 5;
- return static_cast(hash);
- }
-};
-
-struct bmv2_hash {
- uint64_t operator()(const char *buf, size_t s) const {
- return bm::hash::xxh64(buf, s);
- }
-};
-
-struct xor8 {
- uint32_t operator()(const char *buf, size_t s) const {
- int result = 0;
- for (size_t i = 0; i(pre);
-
- add_required_field("standard_metadata", "ingress_port");
- add_required_field("standard_metadata", "packet_length");
- add_required_field("standard_metadata", "instance_type");
- add_required_field("standard_metadata", "egress_spec");
- add_required_field("standard_metadata", "clone_spec");
- add_required_field("standard_metadata", "egress_port");
-
- force_arith_field("standard_metadata", "ingress_port");
- force_arith_field("standard_metadata", "packet_length");
- force_arith_field("standard_metadata", "instance_type");
- force_arith_field("standard_metadata", "egress_spec");
- force_arith_field("standard_metadata", "clone_spec");
-
- force_arith_field("queueing_metadata", "enq_timestamp");
- force_arith_field("queueing_metadata", "enq_qdepth");
- force_arith_field("queueing_metadata", "deq_timedelta");
- force_arith_field("queueing_metadata", "deq_qdepth");
-
- force_arith_field("intrinsic_metadata", "ingress_global_timestamp");
- force_arith_field("intrinsic_metadata", "lf_field_list");
- force_arith_field("intrinsic_metadata", "mcast_grp");
- force_arith_field("intrinsic_metadata", "resubmit_flag");
- force_arith_field("intrinsic_metadata", "egress_rid");
- force_arith_field("intrinsic_metadata", "recirculate_flag");
-
- import_primitives();
-}
-
-#define PACKET_LENGTH_REG_IDX 0
-
-int
-SimpleSwitch::receive_(int port_num, const char *buffer, int len) {
- static int pkt_id = 0;
-
- // this is a good place to call this, because blocking this thread will not
- // block the processing of existing packet instances, which is a requirement
- if (do_swap() == 0) {
- check_queueing_metadata();
- }
-
- // we limit the packet buffer to original size + 512 bytes, which means we
- // cannot add more than 512 bytes of header data to the packet, which should
- // be more than enough
- auto packet = new_packet_ptr(port_num, pkt_id++, len,
- bm::PacketBuffer(len + 512, buffer, len));
-
- BMELOG(packet_in, *packet);
-
- PHV *phv = packet->get_phv();
- // many current P4 programs assume this
- // it is also part of the original P4 spec
- phv->reset_metadata();
-
- // setting standard metadata
-
- phv->get_field("standard_metadata.ingress_port").set(port_num);
- // using packet register 0 to store length, this register will be updated for
- // each add_header / remove_header primitive call
- packet->set_register(PACKET_LENGTH_REG_IDX, len);
- phv->get_field("standard_metadata.packet_length").set(len);
- Field &f_instance_type = phv->get_field("standard_metadata.instance_type");
- f_instance_type.set(PKT_INSTANCE_TYPE_NORMAL);
-
- if (phv->has_field("intrinsic_metadata.ingress_global_timestamp")) {
- phv->get_field("intrinsic_metadata.ingress_global_timestamp")
- .set(get_ts().count());
- }
-
- input_buffer.push_front(std::move(packet));
- return 0;
-}
-
-void
-SimpleSwitch::start_and_return_() {
- check_queueing_metadata();
-
- std::thread t1(&SimpleSwitch::ingress_thread, this);
- t1.detach();
- for (size_t i = 0; i < nb_egress_threads; i++) {
- std::thread t2(&SimpleSwitch::egress_thread, this, i);
- t2.detach();
- }
- std::thread t3(&SimpleSwitch::transmit_thread, this);
- t3.detach();
-}
-
-void
-SimpleSwitch::reset_target_state_() {
- bm::Logger::get()->debug("Resetting simple_switch target-specific state");
- get_component()->reset_state();
-}
-
-int
-SimpleSwitch::set_egress_queue_depth(int port, const size_t depth_pkts) {
- egress_buffers.set_capacity(port, depth_pkts);
- return 0;
-}
-
-int
-SimpleSwitch::set_all_egress_queue_depths(const size_t depth_pkts) {
- for (int i = 0; i < max_port; i++) {
- set_egress_queue_depth(i, depth_pkts);
- }
- return 0;
-}
-
-int
-SimpleSwitch::set_egress_queue_rate(int port, const uint64_t rate_pps) {
- egress_buffers.set_rate(port, rate_pps);
- return 0;
-}
-
-int
-SimpleSwitch::set_all_egress_queue_rates(const uint64_t rate_pps) {
- for (int i = 0; i < max_port; i++) {
- set_egress_queue_rate(i, rate_pps);
- }
- return 0;
-}
-
-uint64_t
-SimpleSwitch::get_time_elapsed_us() const {
- return get_ts().count();
-}
-
-uint64_t
-SimpleSwitch::get_time_since_epoch_us() const {
- auto tp = clock::now();
- return duration_cast(tp.time_since_epoch()).count();
-}
-
-void
-SimpleSwitch::transmit_thread() {
- while (1) {
- std::unique_ptr packet;
- output_buffer.pop_back(&packet);
- BMELOG(packet_out, *packet);
- BMLOG_DEBUG_PKT(*packet, "Transmitting packet of size {} out of port {}",
- packet->get_data_size(), packet->get_egress_port());
- transmit_fn(packet->get_egress_port(),
- packet->data(), packet->get_data_size());
- }
-}
-
-ts_res
-SimpleSwitch::get_ts() const {
- return duration_cast(clock::now() - start);
-}
-
-void
-SimpleSwitch::enqueue(int egress_port, std::unique_ptr &&packet) {
- packet->set_egress_port(egress_port);
-
- PHV *phv = packet->get_phv();
-
- if (with_queueing_metadata) {
- phv->get_field("queueing_metadata.enq_timestamp").set(get_ts().count());
- phv->get_field("queueing_metadata.enq_qdepth")
- .set(egress_buffers.size(egress_port));
- }
-
-#ifdef SSWITCH_PRIORITY_QUEUEING_ON
- size_t priority =
- phv->get_field(SSWITCH_PRIORITY_QUEUEING_SRC).get();
- if (priority >= SSWITCH_PRIORITY_QUEUEING_NB_QUEUES) {
- bm::Logger::get()->error("Priority out of range, dropping packet");
- return;
- }
- egress_buffers.push_front(
- egress_port, SSWITCH_PRIORITY_QUEUEING_NB_QUEUES - 1 - priority,
- std::move(packet));
-#else
- egress_buffers.push_front(egress_port, std::move(packet));
-#endif
-}
-
-// used for ingress cloning, resubmit
-std::unique_ptr
-SimpleSwitch::copy_ingress_pkt(
- const std::unique_ptr &packet,
- PktInstanceType copy_type, p4object_id_t field_list_id) {
- std::unique_ptr packet_copy = packet->clone_no_phv_ptr();
- PHV *phv_copy = packet_copy->get_phv();
- phv_copy->reset_metadata();
- FieldList *field_list = this->get_field_list(field_list_id);
- field_list->copy_fields_between_phvs(phv_copy, packet->get_phv());
- phv_copy->get_field("standard_metadata.instance_type").set(copy_type);
- return packet_copy;
-}
-
-void
-SimpleSwitch::check_queueing_metadata() {
- bool enq_timestamp_e = field_exists("queueing_metadata", "enq_timestamp");
- bool enq_qdepth_e = field_exists("queueing_metadata", "enq_qdepth");
- bool deq_timedelta_e = field_exists("queueing_metadata", "deq_timedelta");
- bool deq_qdepth_e = field_exists("queueing_metadata", "deq_qdepth");
- if (enq_timestamp_e || enq_qdepth_e || deq_timedelta_e || deq_qdepth_e) {
- if (enq_timestamp_e && enq_qdepth_e && deq_timedelta_e && deq_qdepth_e)
- with_queueing_metadata = true;
- else
- bm::Logger::get()->warn(
- "Your JSON input defines some but not all queueing metadata fields");
- }
-}
-
-void
-SimpleSwitch::ingress_thread() {
- PHV *phv;
-
- while (1) {
- std::unique_ptr packet;
- input_buffer.pop_back(&packet);
-
- // TODO(antonin): only update these if swapping actually happened?
- Parser *parser = this->get_parser("parser");
- Pipeline *ingress_mau = this->get_pipeline("ingress");
-
- phv = packet->get_phv();
-
- int ingress_port = packet->get_ingress_port();
- (void) ingress_port;
- BMLOG_DEBUG_PKT(*packet, "Processing packet received on port {}",
- ingress_port);
-
- /* This looks like it comes out of the blue. However this is needed for
- ingress cloning. The parser updates the buffer state (pops the parsed
- headers) to make the deparser's job easier (the same buffer is
- re-used). But for ingress cloning, the original packet is needed. This
- kind of looks hacky though. Maybe a better solution would be to have the
- parser leave the buffer unchanged, and move the pop logic to the
- deparser. TODO? */
- const Packet::buffer_state_t packet_in_state = packet->save_buffer_state();
- parser->parse(packet.get());
-
- ingress_mau->apply(packet.get());
-
- packet->reset_exit();
-
- Field &f_egress_spec = phv->get_field("standard_metadata.egress_spec");
- int egress_spec = f_egress_spec.get_int();
-
- Field &f_clone_spec = phv->get_field("standard_metadata.clone_spec");
- unsigned int clone_spec = f_clone_spec.get_uint();
-
- int learn_id = 0;
- unsigned int mgid = 0u;
-
- if (phv->has_field("intrinsic_metadata.lf_field_list")) {
- Field &f_learn_id = phv->get_field("intrinsic_metadata.lf_field_list");
- learn_id = f_learn_id.get_int();
- }
-
- // detect mcast support, if this is true we assume that other fields needed
- // for mcast are also defined
- if (phv->has_field("intrinsic_metadata.mcast_grp")) {
- Field &f_mgid = phv->get_field("intrinsic_metadata.mcast_grp");
- mgid = f_mgid.get_uint();
- }
-
- int egress_port;
-
- // INGRESS CLONING
- if (clone_spec) {
- BMLOG_DEBUG_PKT(*packet, "Cloning packet at ingress");
- egress_port = get_mirroring_mapping(clone_spec & 0xFFFF);
- f_clone_spec.set(0);
- if (egress_port >= 0) {
- const Packet::buffer_state_t packet_out_state =
- packet->save_buffer_state();
- packet->restore_buffer_state(packet_in_state);
- p4object_id_t field_list_id = clone_spec >> 16;
- auto packet_copy = copy_ingress_pkt(
- packet, PKT_INSTANCE_TYPE_INGRESS_CLONE, field_list_id);
- // we need to parse again
- // the alternative would be to pay the (huge) price of PHV copy for
- // every ingress packet
- parser->parse(packet_copy.get());
- enqueue(egress_port, std::move(packet_copy));
- packet->restore_buffer_state(packet_out_state);
- }
- }
- // LEARNING
- if (learn_id > 0) {
- get_learn_engine()->learn(learn_id, *packet.get());
- }
-
- // RESUBMIT
- if (phv->has_field("intrinsic_metadata.resubmit_flag")) {
- Field &f_resubmit = phv->get_field("intrinsic_metadata.resubmit_flag");
- if (f_resubmit.get_int()) {
- BMLOG_DEBUG_PKT(*packet, "Resubmitting packet");
- // get the packet ready for being parsed again at the beginning of
- // ingress
- packet->restore_buffer_state(packet_in_state);
- p4object_id_t field_list_id = f_resubmit.get_int();
- f_resubmit.set(0);
- // TODO(antonin): a copy is not needed here, but I don't yet have an
- // optimized way of doing this
- auto packet_copy = copy_ingress_pkt(
- packet, PKT_INSTANCE_TYPE_RESUBMIT, field_list_id);
- input_buffer.push_front(std::move(packet_copy));
- continue;
- }
- }
-
- Field &f_instance_type = phv->get_field("standard_metadata.instance_type");
-
- // MULTICAST
- int instance_type = f_instance_type.get_int();
- if (mgid != 0) {
- BMLOG_DEBUG_PKT(*packet, "Multicast requested for packet");
- Field &f_rid = phv->get_field("intrinsic_metadata.egress_rid");
- const auto pre_out = pre->replicate({mgid});
- auto packet_size = packet->get_register(PACKET_LENGTH_REG_IDX);
- for (const auto &out : pre_out) {
- egress_port = out.egress_port;
- // if (ingress_port == egress_port) continue; // pruning
- phv->get_field("egress_metadata.bridge_port").set(egress_port);
- BMLOG_DEBUG_PKT(*packet, "Replicating packet on bridge port {}", egress_port);
- f_rid.set(out.rid);
- f_instance_type.set(PKT_INSTANCE_TYPE_REPLICATION);
- std::unique_ptr packet_copy = packet->clone_with_phv_ptr();
- packet_copy->set_register(PACKET_LENGTH_REG_IDX, packet_size);
- enqueue(egress_port, std::move(packet_copy));
- }
- f_instance_type.set(instance_type);
-
- // when doing multicast, we discard the original packet
- continue;
- }
-
- egress_port = egress_spec;
- BMLOG_DEBUG_PKT(*packet, "Egress port is {}", egress_port);
-
- if (egress_port == 511) { // drop packet
- BMLOG_DEBUG_PKT(*packet, "Dropping packet at the end of ingress");
- continue;
- }
-
- enqueue(egress_port, std::move(packet));
- }
-}
-
-void
-SimpleSwitch::egress_thread(size_t worker_id) {
- PHV *phv;
-
- while (1) {
- std::unique_ptr packet;
- size_t port;
- egress_buffers.pop_back(worker_id, &port, &packet);
-
- Deparser *deparser = this->get_deparser("deparser");
- Pipeline *egress_mau = this->get_pipeline("egress");
-
- phv = packet->get_phv();
-
- if (with_queueing_metadata) {
- auto enq_timestamp =
- phv->get_field("queueing_metadata.enq_timestamp").get();
- phv->get_field("queueing_metadata.deq_timedelta").set(
- get_ts().count() - enq_timestamp);
- phv->get_field("queueing_metadata.deq_qdepth").set(
- egress_buffers.size(port));
- }
-
- phv->get_field("standard_metadata.egress_port").set(port);
-
- Field &f_egress_spec = phv->get_field("standard_metadata.egress_spec");
-
- phv->get_field("standard_metadata.packet_length").set(
- packet->get_register(PACKET_LENGTH_REG_IDX));
-
- egress_mau->apply(packet.get());
-
- Field &f_clone_spec = phv->get_field("standard_metadata.clone_spec");
- unsigned int clone_spec = f_clone_spec.get_uint();
-
- // EGRESS CLONING
- if (clone_spec) {
- BMLOG_DEBUG_PKT(*packet, "Cloning packet at egress");
- int egress_port = get_mirroring_mapping(clone_spec & 0xFFFF);
- if (egress_port >= 0) {
- f_clone_spec.set(0);
- p4object_id_t field_list_id = clone_spec >> 16;
- std::unique_ptr packet_copy =
- packet->clone_with_phv_reset_metadata_ptr();
- PHV *phv_copy = packet_copy->get_phv();
- FieldList *field_list = this->get_field_list(field_list_id);
- field_list->copy_fields_between_phvs(phv_copy, phv);
- phv_copy->get_field("standard_metadata.instance_type")
- .set(PKT_INSTANCE_TYPE_EGRESS_CLONE);
- enqueue(egress_port, std::move(packet_copy));
- }
- }
-
- // TODO(antonin): should not be done like this in egress pipeline
- int egress_spec = f_egress_spec.get_int();
- if (egress_spec == 511) { // drop packet
- BMLOG_DEBUG_PKT(*packet, "Dropping packet at the end of egress");
- continue;
- }
-
- // yonatanp. since cloned packet get passed egress_spec, they will update their egress_spec. in order to bypass it and allow I2E clonnig, I've added a
- // P4 flag, to know if this is a cloned packet or not. There probably exists a better solution, Hopefully after changing to P4_16 this won't be needed.
- if (phv->get_field("standard_metadata.instance_type").get_int() != PKT_INSTANCE_TYPE_INGRESS_CLONE) {
- packet->set_egress_port(egress_spec);
- BMLOG_DEBUG_PKT(*packet, "Changed egress port at egress pipeline to {}", egress_spec);
- }
-
- deparser->deparse(packet.get());
-
- // RECIRCULATE
- if (phv->has_field("intrinsic_metadata.recirculate_flag")) {
- Field &f_recirc = phv->get_field("intrinsic_metadata.recirculate_flag");
- if (f_recirc.get_int()) {
- BMLOG_DEBUG_PKT(*packet, "Recirculating packet");
- p4object_id_t field_list_id = f_recirc.get_int();
- f_recirc.set(0);
- FieldList *field_list = this->get_field_list(field_list_id);
- // TODO(antonin): just like for resubmit, there is no need for a copy
- // here, but it is more convenient for this first prototype
- std::unique_ptr packet_copy = packet->clone_no_phv_ptr();
- PHV *phv_copy = packet_copy->get_phv();
- phv_copy->reset_metadata();
- field_list->copy_fields_between_phvs(phv_copy, phv);
- phv_copy->get_field("standard_metadata.instance_type")
- .set(PKT_INSTANCE_TYPE_RECIRC);
- size_t packet_size = packet_copy->get_data_size();
- packet_copy->set_register(PACKET_LENGTH_REG_IDX, packet_size);
- phv_copy->get_field("standard_metadata.packet_length").set(packet_size);
- input_buffer.push_front(std::move(packet_copy));
- continue;
- }
- }
-
- output_buffer.push_front(std::move(packet));
- }
-}
diff --git a/bm/p4-sai/simple_switch.h b/bm/p4-sai/simple_switch.h
deleted file mode 100644
index 915137bb4..000000000
--- a/bm/p4-sai/simple_switch.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/* Copyright 2013-present Barefoot Networks, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Antonin Bas (antonin@barefootnetworks.com)
- *
- */
-
-#ifndef SIMPLE_SWITCH_SIMPLE_SWITCH_H_
-#define SIMPLE_SWITCH_SIMPLE_SWITCH_H_
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-// TODO(antonin)
-// experimental support for priority queueing
-// to enable it, uncomment this flag
-// you can also choose the field from which the priority value will be read, as
-// well as the number of priority queues per port
-// PRIORITY 0 IS THE LOWEST PRIORITY
-// #define SSWITCH_PRIORITY_QUEUEING_ON
-
-#ifdef SSWITCH_PRIORITY_QUEUEING_ON
-#define SSWITCH_PRIORITY_QUEUEING_NB_QUEUES 8
-#define SSWITCH_PRIORITY_QUEUEING_SRC "intrinsic_metadata.priority"
-#endif
-
-using ts_res = std::chrono::microseconds;
-using std::chrono::duration_cast;
-using ticks = std::chrono::nanoseconds;
-
-using bm::Switch;
-using bm::Queue;
-using bm::Packet;
-using bm::PHV;
-using bm::Parser;
-using bm::Deparser;
-using bm::Pipeline;
-using bm::McSimplePreLAG;
-using bm::Field;
-using bm::FieldList;
-using bm::packet_id_t;
-using bm::p4object_id_t;
-
-
-class SimpleSwitch : public Switch {
- public:
- using mirror_id_t = int;
-
- private:
- using clock = std::chrono::high_resolution_clock;
-
- public:
- // by default, swapping is off
- explicit SimpleSwitch(int max_port = 256, bool enable_swap = false);
-
- int receive_(int port_num, const char *buffer, int len) override;
-
- void start_and_return_() override;
-
- void reset_target_state_() override;
-
- int mirroring_mapping_add(mirror_id_t mirror_id, int egress_port) {
- mirroring_map[mirror_id] = egress_port;
- return 0;
- }
-
- int mirroring_mapping_delete(mirror_id_t mirror_id) {
- return mirroring_map.erase(mirror_id);
- }
-
- int mirroring_mapping_get(mirror_id_t mirror_id) const {
- return get_mirroring_mapping(mirror_id);
- }
-
- int set_egress_queue_depth(int port, const size_t depth_pkts);
- int set_all_egress_queue_depths(const size_t depth_pkts);
-
- int set_egress_queue_rate(int port, const uint64_t rate_pps);
- int set_all_egress_queue_rates(const uint64_t rate_pps);
-
- // returns the number of microseconds elapsed since the switch started
- uint64_t get_time_elapsed_us() const;
-
- // returns the number of microseconds elasped since the clock's epoch
- uint64_t get_time_since_epoch_us() const;
-
- private:
- static constexpr size_t nb_egress_threads = 4u;
-
- enum PktInstanceType {
- PKT_INSTANCE_TYPE_NORMAL,
- PKT_INSTANCE_TYPE_INGRESS_CLONE,
- PKT_INSTANCE_TYPE_EGRESS_CLONE,
- PKT_INSTANCE_TYPE_COALESCED,
- PKT_INSTANCE_TYPE_RECIRC,
- PKT_INSTANCE_TYPE_REPLICATION,
- PKT_INSTANCE_TYPE_RESUBMIT,
- };
-
- struct EgressThreadMapper {
- explicit EgressThreadMapper(size_t nb_threads)
- : nb_threads(nb_threads) { }
-
- size_t operator()(size_t egress_port) const {
- return egress_port % nb_threads;
- }
-
- size_t nb_threads;
- };
-
- private:
- void ingress_thread();
- void egress_thread(size_t worker_id);
- void transmit_thread();
-
- int get_mirroring_mapping(mirror_id_t mirror_id) const {
- const auto it = mirroring_map.find(mirror_id);
- if (it == mirroring_map.end()) return -1;
- return it->second;
- }
-
- ts_res get_ts() const;
-
- // TODO(antonin): switch to pass by value?
- void enqueue(int egress_port, std::unique_ptr &&pkt);
-
- std::unique_ptr copy_ingress_pkt(
- const std::unique_ptr &pkt,
- PktInstanceType copy_type, p4object_id_t field_list_id);
-
- void check_queueing_metadata();
-
- private:
- int max_port;
- Queue > input_buffer;
-#ifdef SSWITCH_PRIORITY_QUEUEING_ON
- bm::QueueingLogicPriRL, EgressThreadMapper>
-#else
- bm::QueueingLogicRL, EgressThreadMapper>
-#endif
- egress_buffers;
- Queue > output_buffer;
- std::shared_ptr pre;
- clock::time_point start;
- std::unordered_map mirroring_map;
- bool with_queueing_metadata{false};
-};
-
-#endif // SIMPLE_SWITCH_SIMPLE_SWITCH_H_
diff --git a/bm/p4-sai/simple_switch_CLI.in b/bm/p4-sai/simple_switch_CLI.in
deleted file mode 100644
index 88a56ce3f..000000000
--- a/bm/p4-sai/simple_switch_CLI.in
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/env python2
-
-# Copyright 2013-present Barefoot Networks, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-#
-# Antonin Bas (antonin@barefootnetworks.com)
-#
-#
-
-# This is just a wrapper script around sswitch_CLI.py
-# It makes sure that the script works correctly no matter where Python
-# dependencies are installed
-
-import sys
-sys.path.append("@pythondir@")
-
-import sswitch_CLI
-sswitch_CLI.main()
diff --git a/bm/p4-sai/sswitch_CLI b/bm/p4-sai/sswitch_CLI
deleted file mode 100755
index 7ac78afb6..000000000
--- a/bm/p4-sai/sswitch_CLI
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-
-THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
-json=""
-if [ $# -eq 1 ]; then
- echo "Using JSON input $1"
- json="--json $1"
-fi
-port=""
-if [ $# -eq 2 ]; then
- echo "Using Thrift port $2"
- port="--thrift-port $2"
-else
- echo "No Thrift port specified, using CLI default"
-fi
-if [ $# -gt 2 ]; then
- echo "Invalid number of arguments"
- echo "Usage: $0 [ []]"
- exit 1
-fi
-
-CLI=$THIS_DIR/sswitch_CLI.py
-TOOLS_DIR=$THIS_DIR/../../tools/
-
-PYTHONPATH=$PYTHONPATH:$TOOLS_DIR python $CLI $json $port
diff --git a/bm/p4-sai/sswitch_CLI.py b/bm/p4-sai/sswitch_CLI.py
deleted file mode 100644
index c0965804e..000000000
--- a/bm/p4-sai/sswitch_CLI.py
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/usr/bin/env python2
-
-# Copyright 2013-present Barefoot Networks, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-#
-# Antonin Bas (antonin@barefootnetworks.com)
-#
-#
-
-import runtime_CLI
-
-import sys
-import os
-
-from sswitch_runtime import SimpleSwitch
-
-class SimpleSwitchAPI(runtime_CLI.RuntimeAPI):
- @staticmethod
- def get_thrift_services():
- return [("simple_switch", SimpleSwitch.Client)]
-
- def __init__(self, pre_type, standard_client, mc_client, sswitch_client):
- runtime_CLI.RuntimeAPI.__init__(self, pre_type,
- standard_client, mc_client)
- self.sswitch_client = sswitch_client
-
- def do_set_queue_depth(self, line):
- "Set depth of one / all egress queue(s): set_queue_depth []"
- args = line.split()
- depth = int(args[0])
- if len(args) > 1:
- port = int(args[1])
- self.sswitch_client.set_egress_queue_depth(port, depth)
- else:
- self.sswitch_client.set_all_egress_queue_depths(depth)
-
- def do_set_queue_rate(self, line):
- "Set rate of one / all egress queue(s): set_queue_rate []"
- args = line.split()
- rate = int(args[0])
- if len(args) > 1:
- port = int(args[1])
- self.sswitch_client.set_egress_queue_rate(port, rate)
- else:
- self.sswitch_client.set_all_egress_queue_rates(rate)
-
- def do_mirroring_add(self, line):
- "Add mirroring mapping: mirroring_add "
- args = line.split()
- mirror_id, egress_port = int(args[0]), int(args[1])
- self.sswitch_client.mirroring_mapping_add(mirror_id, egress_port)
-
- def do_mirroring_delete(self, line):
- "Delete mirroring mapping: mirroring_delete "
- mirror_id = int(line)
- self.sswitch_client.mirroring_mapping_delete(mirror_id)
-
- def do_get_time_elapsed(self, line):
- "Get time elapsed (in microseconds) since the switch started: get_time_elapsed"
- print self.sswitch_client.get_time_elapsed_us()
-
- def do_get_time_since_epoch(self, line):
- "Get time elapsed (in microseconds) since the switch clock's epoch: get_time_since_epoch"
- print self.sswitch_client.get_time_since_epoch_us()
-
-def main():
- args = runtime_CLI.get_parser().parse_args()
-
- args.pre = runtime_CLI.PreType.SimplePreLAG
-
- services = runtime_CLI.RuntimeAPI.get_thrift_services(args.pre)
- services.extend(SimpleSwitchAPI.get_thrift_services())
-
- standard_client, mc_client, sswitch_client = runtime_CLI.thrift_connect(
- args.thrift_ip, args.thrift_port, services
- )
-
- runtime_CLI.load_json_config(standard_client, args.json)
-
- SimpleSwitchAPI(args.pre, standard_client, mc_client, sswitch_client).cmdloop()
-
-if __name__ == '__main__':
- main()
diff --git a/bm/p4-sai/thrift/simple_switch.thrift b/bm/p4-sai/thrift/simple_switch.thrift
deleted file mode 100644
index 1242b7a85..000000000
--- a/bm/p4-sai/thrift/simple_switch.thrift
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Copyright 2013-present Barefoot Networks, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Antonin Bas (antonin@barefootnetworks.com)
- *
- */
-
-namespace cpp sswitch_runtime
-namespace py sswitch_runtime
-
-service SimpleSwitch {
-
- i32 mirroring_mapping_add(1:i32 mirror_id, 2:i32 egress_port);
- i32 mirroring_mapping_delete(1:i32 mirror_id);
- i32 mirroring_mapping_get_egress_port(1:i32 mirror_id);
-
- i32 set_egress_queue_depth(1:i32 port_num, 2:i32 depth_pkts);
- i32 set_all_egress_queue_depths(1:i32 depth_pkts);
- i32 set_egress_queue_rate(1:i32 port_num, 2:i64 rate_pps);
- i32 set_all_egress_queue_rates(1:i64 rate_pps);
-
- // these methods are here as an experiment, prefer get_time_elapsed_us() when
- // possible
- i64 get_time_elapsed_us();
- i64 get_time_since_epoch_us();
-
-}
diff --git a/bm/p4-sai/thrift/src/SimpleSwitch_server.cpp b/bm/p4-sai/thrift/src/SimpleSwitch_server.cpp
deleted file mode 100644
index a3be4649d..000000000
--- a/bm/p4-sai/thrift/src/SimpleSwitch_server.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/* Copyright 2013-present Barefoot Networks, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Antonin Bas (antonin@barefootnetworks.com)
- *
- */
-
-#include
-
-#ifdef P4THRIFT
-#include
-#include
-#include
-#include
-
-namespace thrift_provider = p4::thrift;
-#else
-#include
-#include
-#include
-#include
-
-namespace thrift_provider = apache::thrift;
-#endif
-
-#include
-#include
-
-#include "simple_switch.h"
-
-namespace sswitch_runtime {
-
-class SimpleSwitchHandler : virtual public SimpleSwitchIf {
- public:
- explicit SimpleSwitchHandler(SimpleSwitch *sw)
- : switch_(sw) { }
-
- int32_t mirroring_mapping_add(const int32_t mirror_id,
- const int32_t egress_port) {
- bm::Logger::get()->trace("mirroring_mapping_add");
- return switch_->mirroring_mapping_add(mirror_id, egress_port);
- }
-
- int32_t mirroring_mapping_delete(const int32_t mirror_id) {
- bm::Logger::get()->trace("mirroring_mapping_delete");
- return switch_->mirroring_mapping_delete(mirror_id);
- }
-
- int32_t mirroring_mapping_get_egress_port(const int32_t mirror_id) {
- bm::Logger::get()->trace("mirroring_mapping_get_egress_port");
- return switch_->mirroring_mapping_get(mirror_id);
- }
-
- int32_t set_egress_queue_depth(const int32_t port_num,
- const int32_t depth_pkts) {
- bm::Logger::get()->trace("set_egress_queue_depth");
- return switch_->set_egress_queue_depth(port_num,
- static_cast(depth_pkts));
- }
-
- int32_t set_all_egress_queue_depths(const int32_t depth_pkts) {
- bm::Logger::get()->trace("set_all_egress_queue_depths");
- return switch_->set_all_egress_queue_depths(
- static_cast(depth_pkts));
- }
-
- int32_t set_egress_queue_rate(const int32_t port_num,
- const int64_t rate_pps) {
- bm::Logger::get()->trace("set_egress_queue_rate");
- return switch_->set_egress_queue_rate(port_num,
- static_cast(rate_pps));
- }
-
- int32_t set_all_egress_queue_rates(const int64_t rate_pps) {
- bm::Logger::get()->trace("set_all_egress_queue_rates");
- return switch_->set_all_egress_queue_rates(static_cast(rate_pps));
- }
-
- int64_t get_time_elapsed_us() {
- bm::Logger::get()->trace("get_time_elapsed_us");
- // cast from unsigned to signed
- return static_cast(switch_->get_time_elapsed_us());
- }
-
- int64_t get_time_since_epoch_us() {
- bm::Logger::get()->trace("get_time_since_epoch_us");
- // cast from unsigned to signed
- return static_cast(switch_->get_time_since_epoch_us());
- }
-
- private:
- SimpleSwitch *switch_;
-};
-
-boost::shared_ptr get_handler(SimpleSwitch *sw) {
- return boost::shared_ptr(new SimpleSwitchHandler(sw));
-}
-
-} // namespace sswitch_runtime
diff --git a/bm/p4-sai/veth_setup.sh b/bm/p4-sai/veth_setup.sh
deleted file mode 100755
index ca73da0a4..000000000
--- a/bm/p4-sai/veth_setup.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/bash
-sudo -v
-for idx in 0 1 2 3 4; do
- intf0="sw_port$(($idx))"
- intf1="host_port0"
- net="host$(($idx))"
- ip="10.0.0.$(($idx))/24"
- if ! ip link show $intf0 &> /dev/null; then
- sudo ip link add name $intf0 type veth peer name $intf1
- sudo ip link set dev $intf0 up
- sudo ip netns add $net
- sudo ip link set dev $intf1 netns $net
- sudo ip netns exec $net ip link set dev $intf1 up
- sudo ip netns exec $net ip address add $ip dev $intf1
- fi
-done
-
-# Last host will have 3 ports, to enable LACP and lag
-net="host5"
-sudo ip netns add $net
-for port_idx in 0 1 2; do
- idx=port_idx+5
- intf0="sw_port$(($idx))"
- intf1="host_port$(($port_idx))"
- ip="10.0.0.$(($idx))/24"
- if ! ip link show $intf0 &> /dev/null; then
- sudo ip link add name $intf0 type veth peer name $intf1
- sudo ip link set dev $intf0 up
- sudo ip link set dev $intf1 netns $net
- sudo ip netns exec $net ip link set dev $intf1 up
- sudo ip netns exec $net ip address add $ip dev $intf1
- fi
-done
-
-intf0="cpu_port"
-intf1="host_port"
-net="hostif_net"
-sudo ip link add name $intf0 type veth peer name $intf1
-sudo ip link set dev $intf0 up
-sudo ip netns add $net
-sudo ip link set dev $intf1 netns $net
-sudo ip netns exec $net ip link set dev $intf1 up
-
diff --git a/bm/p4-sai/veth_teardown.sh b/bm/p4-sai/veth_teardown.sh
deleted file mode 100755
index 4fd7bfb09..000000000
--- a/bm/p4-sai/veth_teardown.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-sudo -v
-
-for idx in 0 1 2 3 4 5; do
- intf0="sw_port$(($idx))"
- net="host$(($idx))"
- if sudo ip link show $intf0 &> /dev/null; then
- sudo ip link delete $intf0 type veth
- fi
- if sudo ip netns show $net &> /dev/null; then
- sudo ip netns delete $net
- fi
-done
-
-for idx in 6 7; do
- intf0="sw_port$(($idx))"
- if sudo ip link show $intf0 &> /dev/null; then
- sudo ip link delete $intf0 type veth
- fi
-done
-
-intf0="cpu_port"
-intf1="host_port"
-net="hostif_net"
-if sudo ip link show $intf0 &> /dev/null; then
- sudo ip link delete $intf0 type veth
-fi
-if sudo ip link show $intf1 &> /dev/null; then
- sudo ip link delete $intf1 type veth
-fi
-if sudo ip netns show $net &> /dev/null; then
- sudo ip netns delete $net
-fi
\ No newline at end of file
diff --git a/bm/sai_adapter/README.md b/bm/sai_adapter/README.md
deleted file mode 100644
index 50a66091b..000000000
--- a/bm/sai_adapter/README.md
+++ /dev/null
@@ -1,57 +0,0 @@
-# SAI API
-The sai lib (C lib) uses P4 thrift to configure the soft switch as described below:
-
-## Including the SAI lib
-The sai_api lib is currently under development.
-In the meantime, please include sai.h, check the [unit test](test/unittest) folder for example.
-Please build it from the src folder using "make".
-
-## PTF tests
-SAI Tests were written using the [ptf](https://github.com/p4lang/ptf) framework.
-The directory is divided to tests (ready and passing tests), wip_tests for work in progress.
-
-### Runing the tests
-First, run make from this location. This will build the sai library, generate the needed thrift and ctypesgen files, and will build the C thrift server, needed to run the tests. \\
-ctypesgen will be needed for this (python wrapper for the C header files used by ptf), and can be easily installed with pip:
-```shell
-pip install ctypesgen
-```
-or from source: [ctypesgen](https://github.com/davidjamesca/ctypesgen).
-
-Now, follow these steps to run the PTF tests:
-1. In SAI-P4-BM/tree/master/p4-softswitch/targets/P4-SAI/ run:
- 1. veth_setup.sh - to configure virtual ports.
- 2. run_server.sh - to start the P4 BM server.
-
-2. Start new terminal and run the sai thrift server:
- SAI-P4-BM/sai_adapter/test/sai_thrift_server/run_server.sh
-
-3. Start another new terminal and run the [PTF tests](test/ptf_tests/) directly, or by one the test shell scripts found in the ptf test folder: tests/ptf_tests/run_ptf.sh
-
-### LOGS
-During the tests, the following logs are outputted:
-1) BM server log can be found under SAI-P4-BM/p4-softswitch/targets/P4-SAI/log.txt
-2) thrift server log is outputted to SAI-P4-BM/sai_adapter/test/sai_thrift_server/logs/log.txt
-3) PTF log is stdout.
-
-# SAI BM Contribution Guide
-## Adding BM functionaity
-For new Soft Switch features ("HW" flows), please follow the [SAI-P4-BM/p4-softswitch](../SAI-P4-BM/p4-softswitch/) readme.
-### Python development server
-For P4 new features testing, it is possible to bypass implementing new SAI C implementations, and just update the thirft implementation in python.
-use the [python thrift server](test/sai_thrift_development_python_server/) found in test/sai_thrift_development_python_server/.
-If you decide to do so, run the sai p4 thrift server with:
-tests/sai_thrift_development_python_server/sai_rpc_server.sh
-
-## Implementing new SAI functionaity:
-* in [sai_adapter_interface.h](inc/sai_adapter_interface.h) create C function decleration.
-* in [sai_adapter_interface.cpp](src/sai_adapter_interface.cpp) create the function link, with the sai_object pointer.
-* in [sai_adapter.h](inc/sai_adapter.h) add a static decleration for the function.
-* for new/unimplemented api, also add the sai_api decleration, and link in the sai_api_query in the sai_object.h, and sai.c files.
-* Add the function implementation to a .cpp file in the [src/](src/) dir, under the sai_object namespace.
-* For PTF testing:
- * add thrift function implementation to the [sai_thrift_server](test/sai_thrift_server).
- * add PTF test in [test/ptf_tests/](test/ptf_tests/).
-### Additional information
-* the sai_object uses the [switch_meta_data.h](inc/switch_meta_data.h) to manage the runtime information regarding the sai_object_ids etc...
-* to configure the BM tables, use the P4 thrift API is found (after p4-sofswitch compliation) in /SAI-P4-BM/p4-softswitch/thrift_src/gen-cpp/bm/Standard.h
diff --git a/bm/sai_adapter/inc/sai_adapter.h b/bm/sai_adapter/inc/sai_adapter.h
deleted file mode 100644
index 3aab783e8..000000000
--- a/bm/sai_adapter/inc/sai_adapter.h
+++ /dev/null
@@ -1,223 +0,0 @@
-#ifndef SAI_ADAPTER_H
-#define SAI_ADAPTER_H
-
-
-// SAI
-#ifdef __cplusplus
-extern "C" {
-#endif
-// TUN/TAP if
-#include "tun_if.h"
-#include
-#ifdef __cplusplus
-}
-#endif
-
-// INTERNAL
-#include "switch_meta_data.h"
-
-// thrift bm clinet
-#include
-#include
-#include
-#include
-#include
-#include
-
-// LOG
-#include "../inc/spdlog/spdlog.h"
-
-// General
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-using namespace std;
-using namespace ::apache::thrift;
-using namespace ::apache::thrift::protocol;
-using namespace ::apache::thrift::transport;
-
-using namespace bm_runtime::standard;
-
-const int bm_port = 9090;
-const int32_t cxt_id = 0;
-
-// static StandardClient* bm_client_ptr;
-// static sai_id_map_t* sai_id_map_ptr;
-string parse_param(uint64_t param, uint32_t num_of_bytes);
-BmMatchParam parse_exact_match_param(uint64_t param, uint32_t num_of_bytes);
-BmMatchParam parse_valid_match_param(bool param);
-uint64_t parse_mac_64(uint8_t const mac_8[6]);
-
-class sai_adapter {
- public:
- // thrift
- boost::shared_ptr socket;
- boost::shared_ptr transport;
- boost::shared_ptr bprotocol;
- boost::shared_ptr protocol;
- StandardClient bm_client;
- // generals
- sai_id_map_t sai_id_map;
- Switch_metadata switch_metadata;
- vector switch_list;
- uint32_t list[8] = {0, 1, 2, 3, 4, 5, 6, 7};
- // logger
- std::shared_ptr logger_o;
- static vector *switch_list_ptr;
- static sai_id_map_t *sai_id_map_ptr;
- static StandardClient *bm_client_ptr;
- static Switch_metadata *switch_metadata_ptr;
- static std::shared_ptr *logger;
- // switch
- static sai_status_t create_switch(sai_object_id_t *switch_id,
- uint32_t attr_count,
- const sai_attribute_t *attr_list);
- static sai_status_t get_switch_attribute(sai_object_id_t switch_id,
- sai_uint32_t attr_count,
- sai_attribute_t *attr_list);
- // port functions
- static sai_status_t create_port(sai_object_id_t *port_id,
- sai_object_id_t switch_id,
- uint32_t attr_count,
- const sai_attribute_t *attr_list);
- static sai_status_t remove_port(sai_object_id_t port_id);
- static sai_status_t set_port_attribute(sai_object_id_t port_id,
- const sai_attribute_t *attr);
- static sai_status_t get_port_attribute(sai_object_id_t port_id,
- uint32_t attr_count,
- sai_attribute_t *attr_list);
- static void config_port(Port_obj *port);
- static void set_parsed_port_attribute(Port_obj *port,
- sai_attribute_t attribute);
- static void get_parsed_port_attribute(Port_obj *port,
- sai_attribute_t *attribute);
- // bridge functions
- static sai_status_t create_bridge(sai_object_id_t *bridge_id,
- sai_object_id_t switch_id,
- uint32_t attr_count,
- const sai_attribute_t *attr_list);
- static sai_status_t remove_bridge(sai_object_id_t bridge_id);
- static sai_status_t get_bridge_attribute(sai_object_id_t bridge_id,
- uint32_t attr_count,
- sai_attribute_t *attr_list);
-
- // bridge_port functions
- static sai_status_t create_bridge_port(sai_object_id_t *bridge_port_id,
- sai_object_id_t switch_id,
- uint32_t attr_count,
- const sai_attribute_t *attr_list);
- static sai_status_t remove_bridge_port(sai_object_id_t bridge_port_id);
- static sai_status_t get_bridge_port_attribute(sai_object_id_t bridge_port_id,
- uint32_t attr_count,
- sai_attribute_t *attr_list);
- // fdb
- static sai_status_t create_fdb_entry(const sai_fdb_entry_t *fdb_entry,
- uint32_t attr_count,
- const sai_attribute_t *attr_list);
- static sai_status_t remove_fdb_entry(const sai_fdb_entry_t *fdb_entry);
- // vlan
- static sai_status_t create_vlan(sai_object_id_t *vlan_id,
- sai_object_id_t switch_id,
- uint32_t attr_count,
- const sai_attribute_t *attr_list);
- static sai_status_t remove_vlan(sai_object_id_t vlan_id);
- static sai_status_t set_vlan_attribute(sai_object_id_t vlan_id,
- const sai_attribute_t *attr);
- static sai_status_t get_vlan_attribute(sai_object_id_t vlan_id,
- const uint32_t attr_count,
- sai_attribute_t *attr_list);
- static sai_status_t create_vlan_member(sai_object_id_t *vlan_member_id,
- sai_object_id_t switch_id,
- uint32_t attr_count,
- const sai_attribute_t *attr_list);
- static sai_status_t remove_vlan_member(sai_object_id_t vlan_member_id);
- static sai_status_t set_vlan_member_attribute(sai_object_id_t vlan_member_id,
- const sai_attribute_t *attr);
- static sai_status_t get_vlan_member_attribute(sai_object_id_t vlan_member_id,
- const uint32_t attr_count,
- sai_attribute_t *attr_list);
- static sai_status_t get_vlan_stats(sai_object_id_t vlan_id,
- const sai_vlan_stat_t *counter_ids,
- uint32_t number_of_counters,
- uint64_t *counters);
- static sai_status_t clear_vlan_stats(sai_object_id_t vlan_id,
- const sai_vlan_stat_t *counter_ids,
- uint32_t number_of_counters);
- // lag
- static sai_status_t create_lag(sai_object_id_t *lag_id,
- sai_object_id_t switch_id, uint32_t attr_count,
- const sai_attribute_t *attr_list);
- static sai_status_t remove_lag(sai_object_id_t lag_id);
- static sai_status_t create_lag_member(sai_object_id_t *lag_member_id,
- sai_object_id_t switch_id,
- uint32_t attr_count,
- const sai_attribute_t *attr_list);
- static sai_status_t remove_lag_member(sai_object_id_t lag_member_id);
-
- // hostif
- static sai_status_t create_hostif(sai_object_id_t *hif_id,
- sai_object_id_t switch_id,
- uint32_t attr_count,
- const sai_attribute_t *attr_list);
- static sai_status_t remove_hostif(sai_object_id_t hif_id);
- static sai_status_t create_hostif_table_entry(
- sai_object_id_t *hif_table_entry, sai_object_id_t switch_id,
- uint32_t attr_count, const sai_attribute_t *attr_list);
- static sai_status_t remove_hostif_table_entry(
- sai_object_id_t hif_table_entry);
- static sai_status_t create_hostif_trap_group(
- sai_object_id_t *hostif_trap_group_id, sai_object_id_t switch_id,
- uint32_t attr_count, const sai_attribute_t *attr_list);
- static sai_status_t remove_hostif_trap_group(
- sai_object_id_t hostif_trap_group_id);
- static sai_status_t create_hostif_trap(sai_object_id_t *hostif_trap_id,
- sai_object_id_t switch_id,
- uint32_t attr_count,
- const sai_attribute_t *attr_list);
- static sai_status_t remove_hostif_trap(sai_object_id_t hostif_trap_id);
-
- // api s
- sai_port_api_t port_api;
- sai_bridge_api_t bridge_api;
- sai_fdb_api_t fdb_api;
- sai_switch_api_t switch_api;
- sai_vlan_api_t vlan_api;
- sai_lag_api_t lag_api;
- sai_hostif_api_t hostif_api;
- sai_adapter();
- ~sai_adapter();
- sai_status_t sai_api_query(sai_api_t sai_api_id, void **api_method_table);
-
- private:
- // sai_object_id_t switch_id;
- pcap_t *adapter_pcap;
- // sai adapter threading handlers
- std::thread SaiAdapterThread;
- static bool pcap_loop_started;
- static std::mutex m;
- std::condition_variable cv;
- void startSaiAdapterMain();
- void endSaiAdapterMain();
- void SaiAdapterMain();
- void release_pcap_lock();
- //
- void PacketSniffer();
- void internal_init_switch();
- static uint32_t get_bridge_id_from_fdb_entry(
- const sai_fdb_entry_t *fdb_entry);
- static void packetHandler(u_char *, const struct pcap_pkthdr *,
- const u_char *);
- void adapter_create_fdb_entry(sai_object_id_t, sai_mac_t,
- sai_fdb_entry_bridge_type_t, sai_vlan_id_t,
- sai_object_id_t);
- void learn_mac(uint32_t, uint8_t *);
-};
-
-#endif
\ No newline at end of file
diff --git a/bm/sai_adapter/inc/sai_adapter_interface.h b/bm/sai_adapter/inc/sai_adapter_interface.h
deleted file mode 100644
index b3ecce7c9..000000000
--- a/bm/sai_adapter/inc/sai_adapter_interface.h
+++ /dev/null
@@ -1,109 +0,0 @@
-#ifndef SAI_ADAPTER_INTERFACE_H
-#define SAI_ADAPTER_INTERFACE_H
-#include
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-typedef void *S_O_Handle;
-S_O_Handle create_sai_adapter();
-void free_sai_adapter(S_O_Handle);
-
-// api
-sai_status_t sai_adapter_api_query(S_O_Handle, sai_api_t, void **);
-
-// switch
-sai_status_t sai_adapter_create_switch(S_O_Handle, sai_object_id_t *, uint32_t,
- const sai_attribute_t *);
-sai_status_t sai_adapter_get_switch_attribute(S_O_Handle, sai_object_id_t,
- sai_uint32_t, sai_attribute_t *);
-
-// port
-sai_status_t sai_adapter_create_port(S_O_Handle, sai_object_id_t *,
- sai_object_id_t, uint32_t,
- const sai_attribute_t *);
-sai_status_t sai_adapter_remove_port(S_O_Handle, sai_object_id_t);
-sai_status_t sai_adapter_set_port_attribute(S_O_Handle, sai_object_id_t port_id,
- sai_attribute_t *);
-sai_status_t sai_adapter_get_port_attribute(S_O_Handle, sai_object_id_t port_id,
- uint32_t, sai_attribute_t *);
-
-// bridge
-sai_status_t sai_adapter_create_bridge(S_O_Handle, sai_object_id_t *,
- sai_object_id_t, uint32_t,
- const sai_attribute_t *);
-sai_status_t sai_adapter_remove_bridge(S_O_Handle, sai_object_id_t);
-sai_status_t sai_adapter_get_bridge_attribute(S_O_Handle,
- sai_object_id_t bridge_id,
- uint32_t, sai_attribute_t *);
-
-// bridge_port
-sai_status_t sai_adapter_create_bridge_port(S_O_Handle, sai_object_id_t *,
- sai_object_id_t, uint32_t,
- const sai_attribute_t *);
-sai_status_t sai_adapter_remove_bridge_port(S_O_Handle, sai_object_id_t);
-sai_status_t sai_adapter_get_bridge_port_attribute(
- S_O_Handle, sai_object_id_t bridge_port_id, uint32_t, sai_attribute_t *);
-
-// FDB
-sai_status_t sai_adapter_create_fdb_entry(S_O_Handle, sai_fdb_entry_t *,
- uint32_t, const sai_attribute_t *);
-sai_status_t sai_adapter_remove_fdb_entry(S_O_Handle, sai_fdb_entry_t *);
-
-// VLAN
-sai_status_t sai_adapter_create_vlan(S_O_Handle, sai_object_id_t *,
- sai_object_id_t, uint32_t,
- const sai_attribute_t *);
-sai_status_t sai_adapter_remove_vlan(S_O_Handle, sai_object_id_t);
-sai_status_t sai_adapter_set_vlan_attribute(S_O_Handle, sai_object_id_t,
- const sai_attribute_t *);
-sai_status_t sai_adapter_get_vlan_attribute(S_O_Handle, sai_object_id_t,
- const uint32_t, sai_attribute_t *);
-sai_status_t sai_adapter_create_vlan_member(S_O_Handle, sai_object_id_t *,
- sai_object_id_t, uint32_t,
- const sai_attribute_t *);
-sai_status_t sai_adapter_remove_vlan_member(S_O_Handle, sai_object_id_t);
-sai_status_t sai_adapter_set_vlan_member_attribute(S_O_Handle, sai_object_id_t,
- const sai_attribute_t *);
-sai_status_t sai_adapter_get_vlan_member_attribute(S_O_Handle, sai_object_id_t,
- const uint32_t,
- sai_attribute_t *);
-sai_status_t sai_adapter_get_vlan_stats(S_O_Handle, sai_object_id_t,
- const sai_vlan_stat_t *, uint32_t,
- uint64_t *);
-sai_status_t sai_adapter_clear_vlan_stats(S_O_Handle, sai_object_id_t,
- const sai_vlan_stat_t *, uint32_t);
-
-// LAG
-sai_status_t sai_adapter_create_lag(S_O_Handle, sai_object_id_t *,
- sai_object_id_t, uint32_t,
- const sai_attribute_t *);
-sai_status_t sai_adapter_remove_lag(S_O_Handle, sai_object_id_t);
-sai_status_t sai_adapter_create_lag_member(S_O_Handle, sai_object_id_t *,
- sai_object_id_t, uint32_t,
- const sai_attribute_t *);
-sai_status_t sai_adapter_remove_lag_member(S_O_Handle, sai_object_id_t);
-
-// hostif
-sai_status_t sai_adapter_create_hostif(S_O_Handle, sai_object_id_t *,
- sai_object_id_t, uint32_t,
- const sai_attribute_t *);
-sai_status_t sai_adapter_remove_hostif(S_O_Handle, sai_object_id_t);
-sai_status_t sai_adapter_create_hostif_table_entry(S_O_Handle,
- sai_object_id_t *,
- sai_object_id_t, uint32_t,
- const sai_attribute_t *);
-sai_status_t sai_adapter_remove_hostif_table_entry(S_O_Handle, sai_object_id_t);
-sai_status_t sai_adapter_create_hostif_trap_group(S_O_Handle, sai_object_id_t *,
- sai_object_id_t, uint32_t,
- const sai_attribute_t *);
-sai_status_t sai_adapter_remove_hostif_trap_group(S_O_Handle, sai_object_id_t);
-sai_status_t sai_adapter_create_hostif_trap(S_O_Handle, sai_object_id_t *,
- sai_object_id_t, uint32_t,
- const sai_attribute_t *);
-sai_status_t sai_adapter_remove_hostif_trap(S_O_Handle, sai_object_id_t);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
\ No newline at end of file
diff --git a/bm/sai_adapter/inc/spdlog/async_logger.h b/bm/sai_adapter/inc/spdlog/async_logger.h
deleted file mode 100644
index 1c42fd9ce..000000000
--- a/bm/sai_adapter/inc/spdlog/async_logger.h
+++ /dev/null
@@ -1,77 +0,0 @@
-//
-// Copyright(c) 2015 Gabi Melman.
-// Distributed under the MIT License (http://opensource.org/licenses/MIT)
-//
-
-#pragma once
-
-// Very fast asynchronous logger (millions of logs per second on an average desktop)
-// Uses pre allocated lockfree queue for maximum throughput even under large number of threads.
-// Creates a single back thread to pop messages from the queue and log them.
-//
-// Upon each log write the logger:
-// 1. Checks if its log level is enough to log the message
-// 2. Push a new copy of the message to a queue (or block the caller until space is available in the queue)
-// 3. will throw spdlog_ex upon log exceptions
-// Upon destruction, logs all remaining messages in the queue before destructing..
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-namespace spdlog
-{
-
-namespace details
-{
-class async_log_helper;
-}
-
-class async_logger :public logger
-{
-public:
- template
- async_logger(const std::string& name,
- const It& begin,
- const It& end,
- size_t queue_size,
- const async_overflow_policy overflow_policy = async_overflow_policy::block_retry,
- const std::function& worker_warmup_cb = nullptr,
- const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(),
- const std::function& worker_teardown_cb = nullptr);
-
- async_logger(const std::string& logger_name,
- sinks_init_list sinks,
- size_t queue_size,
- const async_overflow_policy overflow_policy = async_overflow_policy::block_retry,
- const std::function& worker_warmup_cb = nullptr,
- const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(),
- const std::function& worker_teardown_cb = nullptr);
-
- async_logger(const std::string& logger_name,
- sink_ptr single_sink,
- size_t queue_size,
- const async_overflow_policy overflow_policy = async_overflow_policy::block_retry,
- const std::function& worker_warmup_cb = nullptr,
- const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(),
- const std::function& worker_teardown_cb = nullptr);
-
- //Wait for the queue to be empty, and flush synchronously
- //Warning: this can potentialy last forever as we wait it to complete
- void flush() override;
-protected:
- void _sink_it(details::log_msg& msg) override;
- void _set_formatter(spdlog::formatter_ptr msg_formatter) override;
- void _set_pattern(const std::string& pattern) override;
-
-private:
- std::unique_ptr _async_log_helper;
-};
-}
-
-
-#include
diff --git a/bm/sai_adapter/inc/spdlog/common.h b/bm/sai_adapter/inc/spdlog/common.h
deleted file mode 100644
index a0a227ef6..000000000
--- a/bm/sai_adapter/inc/spdlog/common.h
+++ /dev/null
@@ -1,143 +0,0 @@
-//
-// Copyright(c) 2015 Gabi Melman.
-// Distributed under the MIT License (http://opensource.org/licenses/MIT)
-//
-
-#pragma once
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
-#include
-#include
-#endif
-
-#include
-
-//visual studio upto 2013 does not support noexcept nor constexpr
-#if defined(_MSC_VER) && (_MSC_VER < 1900)
-#define SPDLOG_NOEXCEPT throw()
-#define SPDLOG_CONSTEXPR
-#else
-#define SPDLOG_NOEXCEPT noexcept
-#define SPDLOG_CONSTEXPR constexpr
-#endif
-
-#if defined(__GNUC__) || defined(__clang__)
-#define SPDLOG_DEPRECATED __attribute__((deprecated))
-#elif defined(_MSC_VER)
-#define SPDLOG_DEPRECATED __declspec(deprecated)
-#else
-#define SPDLOG_DEPRECATED
-#endif
-
-
-#include
-
-namespace spdlog
-{
-
-class formatter;
-
-namespace sinks
-{
-class sink;
-}
-
-using log_clock = std::chrono::system_clock;
-using sink_ptr = std::shared_ptr < sinks::sink >;
-using sinks_init_list = std::initializer_list < sink_ptr >;
-using formatter_ptr = std::shared_ptr;
-#if defined(SPDLOG_NO_ATOMIC_LEVELS)
-using level_t = details::null_atomic_int;
-#else
-using level_t = std::atomic;
-#endif
-
-using log_err_handler = std::function;
-
-//Log level enum
-namespace level
-{
-typedef enum
-{
- trace = 0,
- debug = 1,
- info = 2,
- warn = 3,
- err = 4,
- critical = 5,
- off = 6
-} level_enum;
-
-static const char* level_names[] { "trace", "debug", "info", "warning", "error", "critical", "off" };
-
-static const char* short_level_names[] { "T", "D", "I", "W", "E", "C", "O" };
-
-inline const char* to_str(spdlog::level::level_enum l)
-{
- return level_names[l];
-}
-
-inline const char* to_short_str(spdlog::level::level_enum l)
-{
- return short_level_names[l];
-}
-} //level
-
-
-//
-// Async overflow policy - block by default.
-//
-enum class async_overflow_policy
-{
- block_retry, // Block / yield / sleep until message can be enqueued
- discard_log_msg // Discard the message it enqueue fails
-};
-
-
-//
-// Log exception
-//
-namespace details
-{
-namespace os
-{
-std::string errno_str(int err_num);
-}
-}
-class spdlog_ex: public std::exception
-{
-public:
- spdlog_ex(const std::string& msg):_msg(msg)
- {}
- spdlog_ex(const std::string& msg, int last_errno)
- {
- _msg = msg + ": " + details::os::errno_str(last_errno);
- }
- const char* what() const SPDLOG_NOEXCEPT override
- {
- return _msg.c_str();
- }
-private:
- std::string _msg;
-
-};
-
-//
-// wchar support for windows file names (SPDLOG_WCHAR_FILENAMES must be defined)
-//
-#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
-using filename_t = std::wstring;
-#else
-using filename_t = std::string;
-#endif
-
-
-} //spdlog
diff --git a/bm/sai_adapter/inc/spdlog/details/async_log_helper.h b/bm/sai_adapter/inc/spdlog/details/async_log_helper.h
deleted file mode 100644
index deb8dcc60..000000000
--- a/bm/sai_adapter/inc/spdlog/details/async_log_helper.h
+++ /dev/null
@@ -1,378 +0,0 @@
-//
-// Copyright(c) 2015 Gabi Melman.
-// Distributed under the MIT License (http://opensource.org/licenses/MIT)
-//
-
-// async log helper :
-// Process logs asynchronously using a back thread.
-//
-// If the internal queue of log messages reaches its max size,
-// then the client call will block until there is more room.
-//
-// If the back thread throws during logging, a spdlog::spdlog_ex exception
-// will be thrown in client's thread when tries to log the next message
-
-#pragma once
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace spdlog
-{
-namespace details
-{
-
-class async_log_helper
-{
- // Async msg to move to/from the queue
- // Movable only. should never be copied
- enum class async_msg_type
- {
- log,
- flush,
- terminate
- };
- struct async_msg
- {
- std::string logger_name;
- level::level_enum level;
- log_clock::time_point time;
- size_t thread_id;
- std::string txt;
- async_msg_type msg_type;
-
- async_msg() = default;
- ~async_msg() = default;
-
-
-async_msg(async_msg&& other) SPDLOG_NOEXCEPT:
- logger_name(std::move(other.logger_name)),
- level(std::move(other.level)),
- time(std::move(other.time)),
- txt(std::move(other.txt)),
- msg_type(std::move(other.msg_type))
- {}
-
- async_msg(async_msg_type m_type) :msg_type(m_type)
- {}
-
- async_msg& operator=(async_msg&& other) SPDLOG_NOEXCEPT
- {
- logger_name = std::move(other.logger_name);
- level = other.level;
- time = std::move(other.time);
- thread_id = other.thread_id;
- txt = std::move(other.txt);
- msg_type = other.msg_type;
- return *this;
- }
-
- // never copy or assign. should only be moved..
- async_msg(const async_msg&) = delete;
- async_msg& operator=(const async_msg& other) = delete;
-
- // construct from log_msg
- async_msg(const details::log_msg& m) :
- level(m.level),
- time(m.time),
- thread_id(m.thread_id),
- txt(m.raw.data(), m.raw.size()),
- msg_type(async_msg_type::log)
- {
-#ifndef SPDLOG_NO_NAME
- logger_name = *m.logger_name;
-#endif
- }
-
-
- // copy into log_msg
- void fill_log_msg(log_msg &msg)
- {
- msg.logger_name = &logger_name;
- msg.level = level;
- msg.time = time;
- msg.thread_id = thread_id;
- msg.raw << txt;
- }
- };
-
-public:
-
- using item_type = async_msg;
- using q_type = details::mpmc_bounded_queue;
-
- using clock = std::chrono::steady_clock;
-
-
- async_log_helper(formatter_ptr formatter,
- const std::vector& sinks,
- size_t queue_size,
- const log_err_handler err_handler,
- const async_overflow_policy overflow_policy = async_overflow_policy::block_retry,
- const std::function& worker_warmup_cb = nullptr,
- const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(),
- const std::function& worker_teardown_cb = nullptr);
-
- void log(const details::log_msg& msg);
-
- // stop logging and join the back thread
- ~async_log_helper();
-
- void set_formatter(formatter_ptr);
-
- void flush(bool wait_for_q);
-
-
-private:
- formatter_ptr _formatter;
- std::vector> _sinks;
-
- // queue of messages to log
- q_type _q;
-
- log_err_handler _err_handler;
-
- bool _flush_requested;
-
- bool _terminate_requested;
-
-
- // overflow policy
- const async_overflow_policy _overflow_policy;
-
- // worker thread warmup callback - one can set thread priority, affinity, etc
- const std::function _worker_warmup_cb;
-
- // auto periodic sink flush parameter
- const std::chrono::milliseconds _flush_interval_ms;
-
- // worker thread teardown callback
- const std::function _worker_teardown_cb;
-
- // worker thread
- std::thread _worker_thread;
-
- void push_msg(async_msg&& new_msg);
-
- // worker thread main loop
- void worker_loop();
-
- // pop next message from the queue and process it. will set the last_pop to the pop time
- // return false if termination of the queue is required
- bool process_next_msg(log_clock::time_point& last_pop, log_clock::time_point& last_flush);
-
- void handle_flush_interval(log_clock::time_point& now, log_clock::time_point& last_flush);
-
- // sleep,yield or return immediatly using the time passed since last message as a hint
- static void sleep_or_yield(const spdlog::log_clock::time_point& now, const log_clock::time_point& last_op_time);
-
- // wait until the queue is empty
- void wait_empty_q();
-
-};
-}
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// async_sink class implementation
-///////////////////////////////////////////////////////////////////////////////
-inline spdlog::details::async_log_helper::async_log_helper(
- formatter_ptr formatter,
- const std::vector& sinks,
- size_t queue_size,
- log_err_handler err_handler,
- const async_overflow_policy overflow_policy,
- const std::function& worker_warmup_cb,
- const std::chrono::milliseconds& flush_interval_ms,
- const std::function& worker_teardown_cb):
- _formatter(formatter),
- _sinks(sinks),
- _q(queue_size),
- _err_handler(err_handler),
- _flush_requested(false),
- _terminate_requested(false),
- _overflow_policy(overflow_policy),
- _worker_warmup_cb(worker_warmup_cb),
- _flush_interval_ms(flush_interval_ms),
- _worker_teardown_cb(worker_teardown_cb),
- _worker_thread(&async_log_helper::worker_loop, this)
-{}
-
-// Send to the worker thread termination message(level=off)
-// and wait for it to finish gracefully
-inline spdlog::details::async_log_helper::~async_log_helper()
-{
- try
- {
- push_msg(async_msg(async_msg_type::terminate));
- _worker_thread.join();
- }
- catch (...) // don't crash in destructor
- {}
-}
-
-
-//Try to push and block until succeeded (if the policy is not to discard when the queue is full)
-inline void spdlog::details::async_log_helper::log(const details::log_msg& msg)
-{
- push_msg(async_msg(msg));
-}
-
-inline void spdlog::details::async_log_helper::push_msg(details::async_log_helper::async_msg&& new_msg)
-{
- if (!_q.enqueue(std::move(new_msg)) && _overflow_policy != async_overflow_policy::discard_log_msg)
- {
- auto last_op_time = details::os::now();
- auto now = last_op_time;
- do
- {
- now = details::os::now();
- sleep_or_yield(now, last_op_time);
- }
- while (!_q.enqueue(std::move(new_msg)));
- }
-}
-
-// optionally wait for the queue be empty and request flush from the sinks
-inline void spdlog::details::async_log_helper::flush(bool wait_for_q)
-{
- push_msg(async_msg(async_msg_type::flush));
- if(wait_for_q)
- wait_empty_q(); //return only make after the above flush message was processed
-}
-
-inline void spdlog::details::async_log_helper::worker_loop()
-{
- try
- {
- if (_worker_warmup_cb) _worker_warmup_cb();
- auto last_pop = details::os::now();
- auto last_flush = last_pop;
- while(process_next_msg(last_pop, last_flush));
- if (_worker_teardown_cb) _worker_teardown_cb();
- }
- catch (const std::exception &ex)
- {
- _err_handler(ex.what());
- }
- catch (...)
- {
- _err_handler("Unknown exception");
- }
-}
-
-// process next message in the queue
-// return true if this thread should still be active (while no terminate msg was received)
-inline bool spdlog::details::async_log_helper::process_next_msg(log_clock::time_point& last_pop, log_clock::time_point& last_flush)
-{
- async_msg incoming_async_msg;
-
- if (_q.dequeue(incoming_async_msg))
- {
- last_pop = details::os::now();
- switch (incoming_async_msg.msg_type)
- {
- case async_msg_type::flush:
- _flush_requested = true;
- break;
-
- case async_msg_type::terminate:
- _flush_requested = true;
- _terminate_requested = true;
- break;
-
- default:
- log_msg incoming_log_msg;
- incoming_async_msg.fill_log_msg(incoming_log_msg);
- _formatter->format(incoming_log_msg);
- for (auto &s : _sinks)
- {
- if(s->should_log( incoming_log_msg.level))
- {
- s->log(incoming_log_msg);
- }
- }
- }
- return true;
- }
-
- // Handle empty queue..
- // This is the only place where the queue can terminate or flush to avoid losing messages already in the queue
- else
- {
- auto now = details::os::now();
- handle_flush_interval(now, last_flush);
- sleep_or_yield(now, last_pop);
- return !_terminate_requested;
- }
-}
-
-// flush all sinks if _flush_interval_ms has expired
-inline void spdlog::details::async_log_helper::handle_flush_interval(log_clock::time_point& now, log_clock::time_point& last_flush)
-{
- auto should_flush = _flush_requested || (_flush_interval_ms != std::chrono::milliseconds::zero() && now - last_flush >= _flush_interval_ms);
- if (should_flush)
- {
- for (auto &s : _sinks)
- s->flush();
- now = last_flush = details::os::now();
- _flush_requested = false;
- }
-}
-
-inline void spdlog::details::async_log_helper::set_formatter(formatter_ptr msg_formatter)
-{
- _formatter = msg_formatter;
-}
-
-
-// spin, yield or sleep. use the time passed since last message as a hint
-inline void spdlog::details::async_log_helper::sleep_or_yield(const spdlog::log_clock::time_point& now, const spdlog::log_clock::time_point& last_op_time)
-{
- using namespace std::this_thread;
- using std::chrono::milliseconds;
- using std::chrono::microseconds;
-
- auto time_since_op = now - last_op_time;
-
- // spin upto 50 micros
- if (time_since_op <= microseconds(50))
- return;
-
- // yield upto 150 micros
- if (time_since_op <= microseconds(100))
- return std::this_thread::yield();
-
- // sleep for 20 ms upto 200 ms
- if (time_since_op <= milliseconds(200))
- return sleep_for(milliseconds(20));
-
- // sleep for 200 ms
- return sleep_for(milliseconds(200));
-}
-
-// wait for the queue to be empty
-inline void spdlog::details::async_log_helper::wait_empty_q()
-{
- auto last_op = details::os::now();
- while (_q.approx_size() > 0)
- {
- sleep_or_yield(details::os::now(), last_op);
- }
-}
-
-
-
diff --git a/bm/sai_adapter/inc/spdlog/details/async_logger_impl.h b/bm/sai_adapter/inc/spdlog/details/async_logger_impl.h
deleted file mode 100644
index 2092f06cf..000000000
--- a/bm/sai_adapter/inc/spdlog/details/async_logger_impl.h
+++ /dev/null
@@ -1,89 +0,0 @@
-//
-// Copyright(c) 2015 Gabi Melman.
-// Distributed under the MIT License (http://opensource.org/licenses/MIT)
-//
-
-#pragma once
-
-// Async Logger implementation
-// Use an async_sink (queue per logger) to perform the logging in a worker thread
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-template
-inline spdlog::async_logger::async_logger(const std::string& logger_name,
- const It& begin,
- const It& end,
- size_t queue_size,
- const async_overflow_policy overflow_policy,
- const std::function& worker_warmup_cb,
- const std::chrono::milliseconds& flush_interval_ms,
- const std::function& worker_teardown_cb) :
- logger(logger_name, begin, end),
- _async_log_helper(new details::async_log_helper(_formatter, _sinks, queue_size, _err_handler, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb))
-{
-}
-
-inline spdlog::async_logger::async_logger(const std::string& logger_name,
- sinks_init_list sinks_list,
- size_t queue_size,
- const async_overflow_policy overflow_policy,
- const std::function& worker_warmup_cb,
- const std::chrono::milliseconds& flush_interval_ms,
- const std::function& worker_teardown_cb) :
- async_logger(logger_name, sinks_list.begin(), sinks_list.end(), queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb) {}
-
-inline spdlog::async_logger::async_logger(const std::string& logger_name,
- sink_ptr single_sink,
- size_t queue_size,
- const async_overflow_policy overflow_policy,
- const std::function& worker_warmup_cb,
- const std::chrono::milliseconds& flush_interval_ms,
- const std::function& worker_teardown_cb) :
- async_logger(logger_name,
-{
- single_sink
-}, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb) {}
-
-
-inline void spdlog::async_logger::flush()
-{
- _async_log_helper->flush(true);
-}
-
-inline void spdlog::async_logger::_set_formatter(spdlog::formatter_ptr msg_formatter)
-{
- _formatter = msg_formatter;
- _async_log_helper->set_formatter(_formatter);
-}
-
-inline void spdlog::async_logger::_set_pattern(const std::string& pattern)
-{
- _formatter = std::make_shared(pattern);
- _async_log_helper->set_formatter(_formatter);
-}
-
-
-inline void spdlog::async_logger::_sink_it(details::log_msg& msg)
-{
- try
- {
- _async_log_helper->log(msg);
- if (_should_flush_on(msg))
- _async_log_helper->flush(false); // do async flush
- }
- catch (const std::exception &ex)
- {
- _err_handler(ex.what());
- }
- catch (...)
- {
- _err_handler("Unknown exception");
- }
-}
diff --git a/bm/sai_adapter/inc/spdlog/details/file_helper.h b/bm/sai_adapter/inc/spdlog/details/file_helper.h
deleted file mode 100644
index 074d9b835..000000000
--- a/bm/sai_adapter/inc/spdlog/details/file_helper.h
+++ /dev/null
@@ -1,118 +0,0 @@
-//
-// Copyright(c) 2015 Gabi Melman.
-// Distributed under the MIT License (http://opensource.org/licenses/MIT)
-//
-
-#pragma once
-
-// Helper class for file sink
-// When failing to open a file, retry several times(5) with small delay between the tries(10 ms)
-// Can be set to auto flush on every line
-// Throw spdlog_ex exception on errors
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-namespace spdlog
-{
-namespace details
-{
-
-class file_helper
-{
-
-public:
- const int open_tries = 5;
- const int open_interval = 10;
-
- explicit file_helper() :
- _fd(nullptr)
- {}
-
- file_helper(const file_helper&) = delete;
- file_helper& operator=(const file_helper&) = delete;
-
- ~file_helper()
- {
- close();
- }
-
-
- void open(const filename_t& fname, bool truncate = false)
- {
-
- close();
- auto *mode = truncate ? SPDLOG_FILENAME_T("wb") : SPDLOG_FILENAME_T("ab");
- _filename = fname;
- for (int tries = 0; tries < open_tries; ++tries)
- {
- if (!os::fopen_s(&_fd, fname, mode))
- return;
-
- std::this_thread::sleep_for(std::chrono::milliseconds(open_interval));
- }
-
- throw spdlog_ex("Failed opening file " + os::filename_to_str(_filename) + " for writing", errno);
- }
-
- void reopen(bool truncate)
- {
- if (_filename.empty())
- throw spdlog_ex("Failed re opening file - was not opened before");
- open(_filename, truncate);
-
- }
-
- void flush()
- {
- std::fflush(_fd);
- }
-
- void close()
- {
- if (_fd)
- {
- std::fclose(_fd);
- _fd = nullptr;
- }
- }
-
- void write(const log_msg& msg)
- {
-
- size_t msg_size = msg.formatted.size();
- auto data = msg.formatted.data();
- if (std::fwrite(data, 1, msg_size, _fd) != msg_size)
- throw spdlog_ex("Failed writing to file " + os::filename_to_str(_filename), errno);
- }
-
- size_t size()
- {
- if (!_fd)
- throw spdlog_ex("Cannot use size() on closed file " + os::filename_to_str(_filename));
- return os::filesize(_fd);
- }
-
- const filename_t& filename() const
- {
- return _filename;
- }
-
- static bool file_exists(const filename_t& name)
- {
-
- return os::file_exists(name);
- }
-
-private:
- FILE* _fd;
- filename_t _filename;
-};
-}
-}
diff --git a/bm/sai_adapter/inc/spdlog/details/log_msg.h b/bm/sai_adapter/inc/spdlog/details/log_msg.h
deleted file mode 100644
index ecdc73d7c..000000000
--- a/bm/sai_adapter/inc/spdlog/details/log_msg.h
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// Copyright(c) 2015 Gabi Melman.
-// Distributed under the MIT License (http://opensource.org/licenses/MIT)
-//
-
-#pragma once
-
-#include
-#include
-
-
-#include
-#include