diff --git a/.gitmodules b/.gitmodules index 454019f9ebdd..d6e934cb5447 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,12 +10,6 @@ [submodule "sonic-swss"] path = src/sonic-swss url = https://github.com/Azure/sonic-swss -[submodule "src/p4-switch/switch"] - path = platform/p4/p4-switch/switch - url = https://github.com/krambn/switch -[submodule "src/p4-bmv2/behavioral-model"] - path = platform/p4/p4-bmv/behavioral-model - url = https://github.com/krambn/behavioral-model [submodule "src/p4c-bm/p4c-bm"] path = platform/p4/p4c-bm/p4c-bm url = https://github.com/krambn/p4c-bm @@ -66,3 +60,9 @@ [submodule "platform/broadcom/sonic-platform-modules-accton"] path = platform/broadcom/sonic-platform-modules-accton url = https://github.com/edge-core/sonic-platform-modules-accton.git +[submodule "platform/p4/SAI-P4-BM"] + path = platform/p4/SAI-P4-BM + url = https://github.com/Mellanox/SAI-P4-BM.git +[submodule "platform/p4/p4-hlir/p4-hlir-v1.1"] + path = platform/p4/p4-hlir/p4-hlir-v1.1 + url = https://github.com/p4lang/p4-hlir.git diff --git a/README.md b/README.md index c3d58ae1b538..75e6e2fe1103 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Any server can be a build image server. We are using a server with 1T hard disk. # Prerequisites ## SAI Version -SONiC V2 is using [SAI 0.9.4](https://github.com/opencomputeproject/SAI/tree/v0.9.4). +SONiC V2 is using [SAI 1.0.3](https://github.com/opencomputeproject/SAI/tree/v1.0.3). ## Clone or fetch the code repository with all git submodules To clone the code repository recursively, assuming git version 1.9 or newer: diff --git a/platform/p4/SAI-P4-BM b/platform/p4/SAI-P4-BM new file mode 160000 index 000000000000..d6fa7407bb17 --- /dev/null +++ b/platform/p4/SAI-P4-BM @@ -0,0 +1 @@ +Subproject commit d6fa7407bb172266c4db4f784433f4c944c808d2 diff --git a/platform/p4/docker-sonic-p4.mk b/platform/p4/docker-sonic-p4.mk index a23284e50374..b5a63773fbbe 100644 --- a/platform/p4/docker-sonic-p4.mk +++ b/platform/p4/docker-sonic-p4.mk @@ -4,13 +4,13 @@ DOCKER_SONIC_P4 = docker-sonic-p4.gz $(DOCKER_SONIC_P4)_PATH = $(PLATFORM_PATH)/docker-sonic-p4 $(DOCKER_SONIC_P4)_DEPENDS += $(SWSS) $(SYNCD) $(P4_SWITCH) $(REDIS_SERVER) $(REDIS_TOOLS) $(LIBTEAMDCT) $(LIBTEAM_UTILS) -ifeq ($(ROUTING_STACK), quagga) +# ifeq ($(ROUTING_STACK), quagga) $(DOCKER_SONIC_P4)_DEPENDS += $(QUAGGA) -else ifeq ($(ROUTING_STACK), frr) -$(DOCKER_SONIC_P4)_DEPENDS += $(FRR) -else -$(DOCKER_SONIC_P4)_DEPENDS += $(GOBGP) -endif +# else ifeq ($(ROUTING_STACK), frr) +# $(DOCKER_SONIC_P4)_DEPENDS += $(FRR) +# else +# $(DOCKER_SONIC_P4)_DEPENDS += $(GOBGP) +# endif $(DOCKER_SONIC_P4)_LOAD_DOCKERS += $(DOCKER_BASE) SONIC_DOCKER_IMAGES += $(DOCKER_SONIC_P4) diff --git a/platform/p4/docker-sonic-p4/Dockerfile.j2 b/platform/p4/docker-sonic-p4/Dockerfile.j2 index 1b8d1746b2bb..debb89de9c14 100644 --- a/platform/p4/docker-sonic-p4/Dockerfile.j2 +++ b/platform/p4/docker-sonic-p4/Dockerfile.j2 @@ -20,6 +20,7 @@ debs/{{ deb }}{{' '}} ADD port_config.ini /port_config.ini ADD startup.sh /scripts/startup.sh +ADD run_bm.sh /scripts/run_bm.sh ADD rsyslog.conf /etc/rsyslog.conf diff --git a/platform/p4/docker-sonic-p4/port_config.ini b/platform/p4/docker-sonic-p4/port_config.ini index 574f8f976ef9..94088ddb8c22 100644 --- a/platform/p4/docker-sonic-p4/port_config.ini +++ b/platform/p4/docker-sonic-p4/port_config.ini @@ -1,5 +1,33 @@ # alias lanes -Ethernet0 1 -Ethernet1 2 -Ethernet2 3 -Ethernet3 4 +Ethernet0 0 +Ethernet1 1 +Ethernet2 2 +Ethernet3 3 +Ethernet4 4 +Ethernet5 5 +Ethernet6 6 +Ethernet7 7 +Ethernet8 8 +Ethernet9 9 +Ethernet10 10 +Ethernet11 11 +Ethernet12 12 +Ethernet13 13 +Ethernet14 14 +Ethernet15 15 +Ethernet16 16 +Ethernet17 17 +Ethernet18 18 +Ethernet19 19 +Ethernet20 20 +Ethernet21 21 +Ethernet22 22 +Ethernet23 23 +Ethernet24 24 +Ethernet25 25 +Ethernet26 26 +Ethernet27 27 +Ethernet28 28 +Ethernet29 29 +Ethernet30 30 +Ethernet31 31 \ No newline at end of file diff --git a/platform/p4/docker-sonic-p4/rsyslog.conf b/platform/p4/docker-sonic-p4/rsyslog.conf index e8f42bdabe50..33c4a45b319e 100644 --- a/platform/p4/docker-sonic-p4/rsyslog.conf +++ b/platform/p4/docker-sonic-p4/rsyslog.conf @@ -31,6 +31,8 @@ $ModLoad imuxsock # provides support for local system logging ########################### #Set remote syslog server *.* @172.17.0.1:514 +#Set local syslog +#*.* /var/log/messages # # Use traditional timestamp format. diff --git a/platform/p4/docker-sonic-p4/run_bm.sh b/platform/p4/docker-sonic-p4/run_bm.sh new file mode 100755 index 000000000000..66cea4f5d5cf --- /dev/null +++ b/platform/p4/docker-sonic-p4/run_bm.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# handler() +# { + # kill -s INT $ROUTER_PID + # kill -s INT $BRIDGE_PID +# } + +set -m +ip netns exec sw_net simple_switch -i 0@router_port1 -i 250@router_cpu_port --thrift-port 9091 --log-file /tmp/router_log --log-flush --notifications-addr ipc:///tmp/bmv2-router-notifications.ipc /usr/share/p4-sai-bm/sai_router.json & +export ROUTER_PID=$! +ip netns exec sw_net 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 7@sw_port7 -i 8@sw_port8 -i 9@sw_port9 -i 10@sw_port10 -i 11@sw_port11 -i 12@sw_port12 -i 13@sw_port13 -i 14@sw_port14 -i 15@sw_port15 -i 16@sw_port16 -i 17@sw_port17 -i 18@sw_port18 -i 19@sw_port19 -i 20@sw_port20 -i 21@sw_port21 -i 22@sw_port22 -i 23@sw_port23 -i 24@sw_port24 -i 25@sw_port25 -i 26@sw_port26 -i 27@sw_port27 -i 28@sw_port28 -i 29@sw_port29 -i 30@sw_port30 -i 31@sw_port31 -i 250@cpu_port -i 251@router_port0 --log-file /tmp/bridge_log --log-flush /usr/share/p4-sai-bm/sai_bridge.json & +export BRIDGE_PID=$! +sleep 10 +simple_switch_CLI --pre SimplePreLAG < /usr/share/p4-sai-bm/bridge_default_config.txt +simple_switch_CLI < /usr/share/p4-sai-bm/bridge_default_config_mirror.txt +simple_switch_CLI --pre SimplePreLAG --thrift-port 9091 < /usr/share/p4-sai-bm/router_default_config.txt +simple_switch_CLI --thrift-port 9091 < /usr/share/p4-sai-bm/router_default_config_mirror.txt + +# echo "router and bridge are running send SIGINT to close" + +# trap handler INT +# sleep inf +# sudo kill -s SIGINT 3319 diff --git a/platform/p4/docker-sonic-p4/startup.sh b/platform/p4/docker-sonic-p4/startup.sh index 18cd4716580b..5880d431674c 100755 --- a/platform/p4/docker-sonic-p4/startup.sh +++ b/platform/p4/docker-sonic-p4/startup.sh @@ -8,16 +8,16 @@ rm -f /var/run/rsyslogd.pid service rsyslog start echo "Start redis server" -service redis-server start +service redis-server start & +sleep 3 -echo "Veth setup" -/usr/share/bmpd/tools/veth_setup.sh > /tmp/veth_setup.log 2>&1 +redis-cli flushall -echo "Disable IPv6" -/usr/share/bmpd/tools/veth_disable_ipv6.sh > /tmp/veth_disable.log 2>&1 +echo "Veth setup" +veth_setup.sh > /tmp/veth_setup.log 2>&1 echo "Start BMV2" -/run_bm.sh > /tmp/run_bm.log 2>&1 & +/scripts/run_bm.sh > /tmp/run_bm.log 2>&1 & sleep 15 redis-cli -n 1 set LOGLEVEL DEBUG diff --git a/platform/p4/p4-bmv.mk b/platform/p4/p4-bmv.mk index 6fe00d189eb7..affb0d5ac824 100644 --- a/platform/p4/p4-bmv.mk +++ b/platform/p4/p4-bmv.mk @@ -1,7 +1,7 @@ # p4 bmv package -P4_BMV = p4-bmv2_1.0.0_amd64.deb -$(P4_BMV)_DEPENDS += $(LIBTHRIFT_DEV) $(PYTHON_THRIFT) $(THRIFT_COMPILER) +P4_BMV = sai-p4-bm_1.0.0_amd64.deb +$(P4_BMV)_DEPENDS += $(LIBTHRIFT_DEV) $(PYTHON_THRIFT) $(THRIFT_COMPILER) $(P4C_BM) $(P4_BMV)_RDEPENDS += $(LIBTHRIFT) $(PYTHON_THRIFT) $(THRIFT_COMPILER) -$(P4_BMV)_SRC_PATH = $(PLATFORM_PATH)/p4-bmv/behavioral-model +$(P4_BMV)_SRC_PATH = $(PLATFORM_PATH)/SAI-P4-BM/p4-switch SONIC_DPKG_DEBS += $(P4_BMV) diff --git a/platform/p4/p4-bmv/behavioral-model b/platform/p4/p4-bmv/behavioral-model deleted file mode 160000 index a6ccf267bc9c..000000000000 --- a/platform/p4/p4-bmv/behavioral-model +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a6ccf267bc9c5c31fd40fe5841893e38e03abeb4 diff --git a/platform/p4/p4-hlir.mk b/platform/p4/p4-hlir.mk index 2873275983a9..61307c7ff79a 100644 --- a/platform/p4/p4-hlir.mk +++ b/platform/p4/p4-hlir.mk @@ -1,5 +1,9 @@ # p4 bmv package +P4_HLIR_V1_1 = python-p4-hlir-v1-1_1.1.7-1_all.deb +$(P4_HLIR_V1_1)_SRC_PATH = $(PLATFORM_PATH)/p4-hlir/p4-hlir-v1.1 +SONIC_PYTHON_STDEB_DEBS += $(P4_HLIR_V1_1) + P4_HLIR = python-p4-hlir_0.9.36-1_all.deb $(P4_HLIR)_SRC_PATH = $(PLATFORM_PATH)/p4-hlir/p4-hlir SONIC_PYTHON_STDEB_DEBS += $(P4_HLIR) diff --git a/platform/p4/p4-hlir/p4-hlir-v1.1 b/platform/p4/p4-hlir/p4-hlir-v1.1 new file mode 160000 index 000000000000..fdee55e2567f --- /dev/null +++ b/platform/p4/p4-hlir/p4-hlir-v1.1 @@ -0,0 +1 @@ +Subproject commit fdee55e2567fe65463f328d70558b5079894b420 diff --git a/platform/p4/p4-switch.mk b/platform/p4/p4-switch.mk index 6fc07f908779..fb092fa2c5f3 100644 --- a/platform/p4/p4-switch.mk +++ b/platform/p4/p4-switch.mk @@ -1,7 +1,7 @@ -# p4 switch package +# p4 sai adapter package -P4_SWITCH = p4-switch_1.0.0_amd64.deb -$(P4_SWITCH)_DEPENDS += $(P4C_BM) $(P4_BMV) -$(P4_SWITCH)_RDEPENDS += $(P4C_BM) $(P4_BMV) -$(P4_SWITCH)_SRC_PATH = $(PLATFORM_PATH)/p4-switch -SONIC_MAKE_DEBS += $(P4_SWITCH) +P4_SWITCH = p4-sai-adapter_0.1-0_amd64.deb +$(P4_SWITCH)_DEPENDS += $(LIBTHRIFT_DEV) $(PYTHON_THRIFT) $(THRIFT_COMPILER) $(P4_BMV) +$(P4_SWITCH)_RDEPENDS += $(LIBTHRIFT) $(PYTHON_THRIFT) $(THRIFT_COMPILER) $(P4_BMV) +$(P4_SWITCH)_SRC_PATH = $(PLATFORM_PATH)/SAI-P4-BM/sai_adapter +SONIC_DPKG_DEBS += $(P4_SWITCH) diff --git a/platform/p4/p4-switch/Makefile b/platform/p4/p4-switch/Makefile deleted file mode 100644 index 57f6a05999a1..000000000000 --- a/platform/p4/p4-switch/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -SHELL = /bin/bash -.ONESHELL: - -MAIN_TARGET = p4-switch_1.0.0_amd64.deb - -$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : - pushd switch - - mkdir -p p4-build/bmv2/switch - mkdir -p p4-build/bmv2/pd_thrift_gen - - ./autogen.sh - dpkg-buildpackage -us -uc -b -j4 - - popd - - mv $* $(DEST)/ diff --git a/platform/p4/p4-switch/switch b/platform/p4/p4-switch/switch deleted file mode 160000 index e934752f356d..000000000000 --- a/platform/p4/p4-switch/switch +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e934752f356d3ad48cbec99067f47c83795ddcec diff --git a/platform/p4/p4c-bm.mk b/platform/p4/p4c-bm.mk index f51595772c3a..1982ee359212 100644 --- a/platform/p4/p4c-bm.mk +++ b/platform/p4/p4c-bm.mk @@ -2,6 +2,6 @@ P4C_BM = python-p4c-bm_1.0.0-5415c416-1_all.deb $(P4C_BM)_SRC_PATH = $(PLATFORM_PATH)/p4c-bm/p4c-bm -$(P4C_BM)_DEPENDS += $(TENJIN) $(P4_HLIR) -$(P4C_BM)_RDEPENDS += $(TENJIN) $(P4_HLIR) +$(P4C_BM)_DEPENDS += $(TENJIN) $(P4_HLIR) $(P4_HLIR_V1_1) +$(P4C_BM)_RDEPENDS += $(TENJIN) $(P4_HLIR) $(P4_HLIR_V1_1) SONIC_PYTHON_STDEB_DEBS += $(P4C_BM) diff --git a/platform/p4/rules.mk b/platform/p4/rules.mk index 408a58041f56..20def91333c6 100644 --- a/platform/p4/rules.mk +++ b/platform/p4/rules.mk @@ -1,8 +1,10 @@ -include $(PLATFORM_PATH)/p4-switch.mk -include $(PLATFORM_PATH)/p4-bmv.mk +# include $(PLATFORM_PATH)/p4-softswitch.mk +include $(PLATFORM_PATH)/tenjin.mk include $(PLATFORM_PATH)/p4-hlir.mk include $(PLATFORM_PATH)/p4c-bm.mk -include $(PLATFORM_PATH)/tenjin.mk +# include $(PLATFORM_PATH)/p4-sai-bm.mk +include $(PLATFORM_PATH)/p4-bmv.mk +include $(PLATFORM_PATH)/p4-switch.mk include $(PLATFORM_PATH)/docker-sonic-p4.mk SONIC_ALL += $(DOCKER_SONIC_P4)