From 59e1c80701b64ad83bf1d6cf022efc17b8e4601f Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Fri, 19 Jan 2024 02:05:18 +0000 Subject: [PATCH] Add VPP date-plane app TARGETS --- dash-pipeline/Makefile | 82 +++++++++++++++++++- dash-pipeline/dockerfiles/DOCKER_VPP_IMG.env | 5 ++ dash-pipeline/dockerfiles/Dockerfile.vpp | 59 ++++++++++++++ 3 files changed, 143 insertions(+), 3 deletions(-) create mode 100644 dash-pipeline/dockerfiles/DOCKER_VPP_IMG.env create mode 100644 dash-pipeline/dockerfiles/Dockerfile.vpp diff --git a/dash-pipeline/Makefile b/dash-pipeline/Makefile index 6b4c8cd40..4f8e59eef 100644 --- a/dash-pipeline/Makefile +++ b/dash-pipeline/Makefile @@ -4,17 +4,17 @@ mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) mkfile_dir := $(dir $(mkfile_path)) # "All" type targets for convenience -all:p4 sai saithrift-server docker-saithrift-client docker-saichallenger-client test +all:p4 sai saithrift-server docker-saithrift-client docker-saichallenger-client vpp test run-all-tests:run-libsai-test run-saithrift-client-tests run-saichallenger-tests run-saithrift-client-tests: run-saithrift-ptftests run-saithrift-pytests run-saithrift-client-dev-tests: run-saithrift-dev-ptftests run-saithrift-dev-pytests .PHONY:clean -clean: kill-all p4-clean sai-clean test-clean network-clean saithrift-server-clean +clean: kill-all p4-clean sai-clean test-clean network-clean saithrift-server-clean vpp-clean rm -rf $(P4_OUTDIR) -kill-all: kill-saithrift-server kill-switch undeploy-ixiac kill-saichallenger-client +kill-all: kill-saithrift-server kill-switch undeploy-ixiac kill-saichallenger-client kill-vpp PWD := $(realpath $(mkfile_dir)) DASH_USER ?=dashuser @@ -64,6 +64,10 @@ include dockerfiles/DOCKER_SAI_CHALLENGER_CLIENT_BLDR_IMG.env # SAIChallenger Client image built locally with saithrift client libs + PTF & Pytest frameworks DOCKER_SAI_CHALLENGER_CLIENT_IMG ?= local/dash-saichallenger-client:latest +# Run/compile vpp +# include file defines DOCKER_VPP_IMG +include dockerfiles/DOCKER_VPP_IMG.env + # Set differently in CI scripts as needed, e.g. run switch container in -d mode DOCKER_FLAGS ?=-it @@ -251,6 +255,49 @@ run-saithrift-bldr-bash: $(DOCKER_RUN_SAITHRIFT_BLDR) \ /bin/bash +###################################### +# VPP date-plane app TARGETS +###################################### +DOCKER_RUN_VPP = docker run\ + $(DOCKER_FLAGS) \ + -v $(PWD)/bmv2:/bmv2 \ + -v $(PWD)/tests:/tests \ + -v $(PWD)/../:/dash \ + --network=host \ + -u $(HOST_USER):$(HOST_GROUP) \ + --rm \ + +.PHONY:vpp vpp-clean +vpp-clean: + $(DOCKER_RUN_VPP) \ + --name dash-vpp-$(USER) \ + -w /dash/dash-pipeline/vpp-plugin $(DOCKER_VPP_IMG) \ + make clean + +vpp: + @echo "Compile vpp for date-plane app ..." + $(DOCKER_RUN_VPP) \ + --name dash-vpp-$(USER) \ + -w /dash/dash-pipeline/vpp-plugin $(DOCKER_VPP_IMG) \ + make + +run-vpp-bash: + $(DOCKER_RUN_VPP) \ + --name dash-vpp-$(USER) \ + -w /dash/dash-pipeline/vpp-plugin $(DOCKER_VPP_IMG) \ + /bin/bash + +run-vpp: + $(DOCKER_RUN_VPP) \ + --privileged \ + -u root \ + --name dash-vpp-$(USER) \ + -w /dash/dash-pipeline/vpp-plugin $(DOCKER_VPP_IMG) \ + ./vpp.sh + +kill-vpp: + -docker kill dash-vpp-$(USER) + ###################################### # P4 Behavioral-model (switch) TARGETS ###################################### @@ -621,6 +668,35 @@ docker-publish-dash-grpc: docker push $(DOCKER_GRPC_IMG) [ -n $(DOCKER_GRPC_IMG_CTAG) ] && docker push $(DOCKER_GRPC_IMG_NAME):$(DOCKER_GRPC_IMG_CTAG) +############################### + +DOCKER_VPP_IMG_TAG = $(shell cat dockerfiles/Dockerfile.vpp | $(SHA1SUM)) +DOCKER_VPP_IMG = $(DOCKER_VPP_IMG_NAME):$(DOCKER_VPP_IMG_TAG) + +docker-dash-vpp: + { [ x$(ENABLE_DOCKER_PULL) == xy ] && docker pull $(DOCKER_VPP_IMG); } || \ + docker build \ + -f dockerfiles/Dockerfile.vpp \ + -t $(DOCKER_VPP_IMG) \ + --build-arg user=$(DASH_USER) \ + --build-arg group=$(DASH_GROUP) \ + --build-arg uid=$(DASH_UID) \ + --build-arg guid=$(DASH_GUID) \ + --build-arg hostname=$(DASH_HOST) \ + --build-arg available_processors=$(shell nproc) \ + dockerfiles + [ -n $(DOCKER_VPP_IMG_CTAG) ] && \ + docker tag $(DOCKER_VPP_IMG) $(DOCKER_VPP_IMG_NAME):$(DOCKER_VPP_IMG_CTAG) + +docker-pull-dash-vpp: + docker pull $(DOCKER_VPP_IMG) + +docker-publish-dash-vpp: + @echo "Publish $(DOCKER_VPP_IMG) - requires credentials, can only do from DASH repo, not a fork" + docker push $(DOCKER_VPP_IMG) + [ -n $(DOCKER_VPP_IMG_CTAG) ] && \ + docker push $(DOCKER_VPP_IMG_NAME):$(DOCKER_VPP_IMG_CTAG) + ############################### # BMV2-PKTGEN NETWORKING TARGETS ############################### diff --git a/dash-pipeline/dockerfiles/DOCKER_VPP_IMG.env b/dash-pipeline/dockerfiles/DOCKER_VPP_IMG.env new file mode 100644 index 000000000..c41c6f902 --- /dev/null +++ b/dash-pipeline/dockerfiles/DOCKER_VPP_IMG.env @@ -0,0 +1,5 @@ +# Define docker image repo/name:tag +# Changing this will cause build/publish to occur in CI actions +export DASH_ACR_REGISTRY=sonicdash.azurecr.io +export DOCKER_VPP_IMG_NAME?=${DASH_ACR_REGISTRY}/dash-vpp-bldr +export DOCKER_VPP_IMG_CTAG?=240118 diff --git a/dash-pipeline/dockerfiles/Dockerfile.vpp b/dash-pipeline/dockerfiles/Dockerfile.vpp new file mode 100644 index 000000000..27dcb3662 --- /dev/null +++ b/dash-pipeline/dockerfiles/Dockerfile.vpp @@ -0,0 +1,59 @@ +# This Dockerfile builds an image used to compile vpp for dash date-plane app. +FROM amd64/ubuntu:20.04 +LABEL maintainer="SONIC-DASH Community" +LABEL description="DASH date-plane app using vpp" + +# Configure make to run as many parallel jobs as cores available +ARG available_processors +ARG MAKEFLAGS=-j$available_processors + +ARG CC=gcc +ARG CXX=g++ +# Set TZ to avoid interactive installer +ENV TZ=America/Los_Angeles +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +ENV GIT_SSL_NO_VERIFY=true + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + git \ + build-essential \ + autoconf \ + libtool \ + pkg-config \ + sudo \ + iproute2 net-tools iputils-ping \ + make + +## Install vpp +RUN apt-get install -y curl +RUN curl -s https://packagecloud.io/install/repositories/fdio/release/script.deb.sh | bash -x +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + vpp vpp-plugin-core vpp-plugin-dpdk vpp-dbg vpp-dev + +# vpp development environment +RUN echo "wireshark-common wireshark-common/install-setuid boolean true" | debconf-set-selections +WORKDIR /var +RUN (git clone https://gerrit.fd.io/r/vpp && \ + cd vpp && UNATTENDED=y make install-dep) + + +WORKDIR / + +ARG user +ARG uid +ARG group +ARG guid +ARG hostname + +ENV BUILD_HOSTNAME $hostname +ENV USER $user + +RUN groupadd -f -r -g $guid $group +RUN useradd $user -l -u $uid -g $guid -d /var/$user -m -s /bin/bash +RUN echo "$user ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers + +USER $user + +CMD /bin/bash