Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dash-pipeline/SAI/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sonic (1.0.0) stable; urgency=medium

* Initial release.

-- Ze Gan <zegan@microsoft.com> Tue, 10 Jan 2023 12:00:00 -0800
1 change: 1 addition & 0 deletions dash-pipeline/SAI/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
11 changes: 11 additions & 0 deletions dash-pipeline/SAI/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Source: sonic
Maintainer: Ze Gan <zegan@microsoft.com>
Section: net
Priority: optional
Build-Depends: dh-exec (>=0.3), debhelper (>= 9), autotools-dev, cmake, composer, patchelf
Standards-Version: 1.0.0

Package: sai-dash
Architecture: any
Depends: ${shlibs:Depends}
Description: This package contains SAI of dash.
34 changes: 34 additions & 0 deletions dash-pipeline/SAI/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


# main packaging script based on dh7 syntax
%:
dh $@

# dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 )
#override_dh_auto_configure:
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

override_dh_auto_make:
dh_auto_make -- libsai-dash.so

override_dh_auto_install:
dh_auto_install --destdir=debian/libsai-dash
3 changes: 3 additions & 0 deletions dash-pipeline/SAI/generate_dash_api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
/bmv2/dash_pipeline.bmv2/dash_pipeline_p4rt.json \
--ignore-tables=appliance,eni_meter,slb_decap \
dash
cp /bmv2/dash_pipeline.bmv2/dash_pipeline_p4rt.json ./lib
cp /bmv2/dash_pipeline.bmv2/dash_pipeline_p4rt.txt ./lib
cp -r debian/ ./lib
87 changes: 87 additions & 0 deletions dash-pipeline/SAI/templates/Makefile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# THIS MAKEFILE IS AUTO-GENERATED FROM templates/Makefile.j2
# DO NOT MODIFY

.ONESHELL:
SHELL = /bin/bash
.SHELLFLAGS += -e

# Sources from OCP SAI Repo:
SAI_DIR=../SAI/meta/
SAI_SRCS=saimetadatautils.c \
Expand Down Expand Up @@ -49,3 +53,86 @@ libsai.so: $(DASH_FIXED_SAI_SRCS) $(DASH_GEN_SAI_SRCS)
$(DASH_FIXED_SAI_OBJ) \
$(DASH_GEN_SAI_OBJ) \
$(SAI_OBJS)

libprotobuf:
git clone --depth=1 -b v3.18.1 https://github.com/google/protobuf.git
pushd ./protobuf
./autogen.sh
./configure
make -j
sudo make install
sudo ldconfig
popd

libgrpc:
git clone --depth=1 -b v1.43.2 https://github.com/google/grpc.git
pushd ./grpc
git submodule update --init --recursive
mkdir -p cmake/build
pushd ./cmake/build
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON ../..
make -j
sudo make install
sudo ldconfig
popd
popd

libbm:
git clone https://github.com/p4lang/behavioral-model.git
pushd ./behavioral-model
git checkout 9417f2d742cc9325c09e4a222a9b0702d0ce656a
apt install -y composer
bash ci/install-thrift.sh
bash ci/install-nanomsg.sh
sudo ldconfig
./autogen.sh
./configure
make -j
sudo make install
popd

libpi: libprotobuf libgrpc libbm
git clone https://github.com/p4lang/PI.git
pushd ./PI
git checkout 21592d61b314ba0c44a7409a733dbf9e46da6556
git submodule update --init --recursive
./autogen.sh
./configure --with-proto --with-bmv2
make -j
make check
sudo make install
popd

libsai-dash.so: libpi libgrpc $(DASH_FIXED_SAI_SRCS) $(DASH_GEN_SAI_SRCS)
g++ \
-fpermissive \
-c \
-I ../SAI/meta/ \
-I ../SAI/inc/ \
-I ../SAI/experimental/ \
-fPIC \
-g \
$(GXX_FLAGS) \
$(DASH_FIXED_SAI_SRCS) \
$(DASH_GEN_SAI_SRCS)

g++ \
-shared \
-g \
-o libsai-dash.so \
-lpiprotogrpc \
-lgrpc++ \
$(DASH_FIXED_SAI_OBJ) \
$(DASH_GEN_SAI_OBJ)

INSTALL_DIR:=/usr/lib/libsai-dash
CONF_DIR:=/etc/dash

install:
sudo mkdir -p $(DESTDIR)/$(INSTALL_DIR)
sudo cp libsai-dash.so $(DESTDIR)/$(INSTALL_DIR)
cp $(shell ldd libsai-dash.so | awk '{print $$3}' | grep /usr/local) $(DESTDIR)/$(INSTALL_DIR)
find $(DESTDIR)/$(INSTALL_DIR) -name '*.so*' -exec patchelf --set-rpath $(INSTALL_DIR) {} \;
sudo mkdir -p $(DESTDIR)/$(CONF_DIR)
sudo cp dash_pipeline_p4rt.txt $(DESTDIR)/$(CONF_DIR)
sudo cp dash_pipeline_p4rt.json $(DESTDIR)$(CONF_DIR)