Skip to content

Commit 28eb62f

Browse files
YonatanPitzlguohan
YonatanPitz
authored andcommitted
[saip4]: New p4 platform based on SAI behavioral model software switch (#1117)
* merged new p4 platform from 1.0.3 * reverted SAI-P4-BM to SAI1.0 * changed port_config.ini from alias to name. changed tenjin makefile to https * updated SAI-P4-BM commit
1 parent 7540893 commit 28eb62f

18 files changed

+100
-57
lines changed

.gitmodules

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
[submodule "sonic-swss"]
1111
path = src/sonic-swss
1212
url = https://github.com/Azure/sonic-swss
13-
[submodule "src/p4-switch/switch"]
14-
path = platform/p4/p4-switch/switch
15-
url = https://github.com/krambn/switch
16-
[submodule "src/p4-bmv2/behavioral-model"]
17-
path = platform/p4/p4-bmv/behavioral-model
18-
url = https://github.com/krambn/behavioral-model
1913
[submodule "src/p4c-bm/p4c-bm"]
2014
path = platform/p4/p4c-bm/p4c-bm
2115
url = https://github.com/krambn/p4c-bm
@@ -68,3 +62,9 @@
6862
[submodule "src/sonic-frr/frr"]
6963
path = src/sonic-frr/frr
7064
url = https://github.com/FRRouting/frr.git
65+
[submodule "platform/p4/p4-hlir/p4-hlir-v1.1"]
66+
path = platform/p4/p4-hlir/p4-hlir-v1.1
67+
url = https://github.com/p4lang/p4-hlir.git
68+
[submodule "platform/p4/SAI-P4-BM"]
69+
path = platform/p4/SAI-P4-BM
70+
url = https://github.com/Mellanox/SAI-P4-BM.git

platform/p4/SAI-P4-BM

Submodule SAI-P4-BM added at c25b5ae

platform/p4/docker-sonic-p4.mk

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ DOCKER_SONIC_P4 = docker-sonic-p4.gz
44
$(DOCKER_SONIC_P4)_PATH = $(PLATFORM_PATH)/docker-sonic-p4
55
$(DOCKER_SONIC_P4)_DEPENDS += $(SWSS) $(SYNCD) $(P4_SWITCH) $(REDIS_SERVER) $(REDIS_TOOLS) $(LIBTEAMDCT) $(LIBTEAM_UTILS)
66

7-
ifeq ($(ROUTING_STACK), quagga)
7+
# ifeq ($(ROUTING_STACK), quagga)
88
$(DOCKER_SONIC_P4)_DEPENDS += $(QUAGGA)
9-
else ifeq ($(ROUTING_STACK), frr)
10-
$(DOCKER_SONIC_P4)_DEPENDS += $(FRR)
11-
else
12-
$(DOCKER_SONIC_P4)_DEPENDS += $(GOBGP)
13-
endif
9+
# else ifeq ($(ROUTING_STACK), frr)
10+
# $(DOCKER_SONIC_P4)_DEPENDS += $(FRR)
11+
# else
12+
# $(DOCKER_SONIC_P4)_DEPENDS += $(GOBGP)
13+
# endif
1414

1515
$(DOCKER_SONIC_P4)_LOAD_DOCKERS += $(DOCKER_BASE)
1616
SONIC_DOCKER_IMAGES += $(DOCKER_SONIC_P4)

platform/p4/docker-sonic-p4/Dockerfile.j2

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ debs/{{ deb }}{{' '}}
2020

2121
ADD port_config.ini /port_config.ini
2222
ADD startup.sh /scripts/startup.sh
23+
ADD run_bm.sh /scripts/run_bm.sh
2324

2425
ADD rsyslog.conf /etc/rsyslog.conf
2526

+33-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
1-
# alias lanes
2-
Ethernet0 1
3-
Ethernet1 2
4-
Ethernet2 3
5-
Ethernet3 4
1+
# name lanes
2+
Ethernet0 0
3+
Ethernet1 1
4+
Ethernet2 2
5+
Ethernet3 3
6+
Ethernet4 4
7+
Ethernet5 5
8+
Ethernet6 6
9+
Ethernet7 7
10+
Ethernet8 8
11+
Ethernet9 9
12+
Ethernet10 10
13+
Ethernet11 11
14+
Ethernet12 12
15+
Ethernet13 13
16+
Ethernet14 14
17+
Ethernet15 15
18+
Ethernet16 16
19+
Ethernet17 17
20+
Ethernet18 18
21+
Ethernet19 19
22+
Ethernet20 20
23+
Ethernet21 21
24+
Ethernet22 22
25+
Ethernet23 23
26+
Ethernet24 24
27+
Ethernet25 25
28+
Ethernet26 26
29+
Ethernet27 27
30+
Ethernet28 28
31+
Ethernet29 29
32+
Ethernet30 30
33+
Ethernet31 31

platform/p4/docker-sonic-p4/rsyslog.conf

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ $ModLoad imuxsock # provides support for local system logging
3131
###########################
3232
#Set remote syslog server
3333
*.* @172.17.0.1:514
34+
#Set local syslog
35+
#*.* /var/log/messages
3436

3537
#
3638
# Use traditional timestamp format.

platform/p4/docker-sonic-p4/run_bm.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
# handler()
3+
# {
4+
# kill -s INT $ROUTER_PID
5+
# kill -s INT $BRIDGE_PID
6+
# }
7+
8+
set -m
9+
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 &
10+
export ROUTER_PID=$!
11+
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 &
12+
export BRIDGE_PID=$!
13+
sleep 10
14+
simple_switch_CLI --pre SimplePreLAG < /usr/share/p4-sai-bm/bridge_default_config.txt
15+
simple_switch_CLI < /usr/share/p4-sai-bm/bridge_default_config_mirror.txt
16+
simple_switch_CLI --pre SimplePreLAG --thrift-port 9091 < /usr/share/p4-sai-bm/router_default_config.txt
17+
simple_switch_CLI --thrift-port 9091 < /usr/share/p4-sai-bm/router_default_config_mirror.txt
18+
19+
# echo "router and bridge are running send SIGINT to close"
20+
21+
# trap handler INT
22+
# sleep inf
23+
# sudo kill -s SIGINT 3319

platform/p4/docker-sonic-p4/startup.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ rm -f /var/run/rsyslogd.pid
88
service rsyslog start
99

1010
echo "Start redis server"
11-
service redis-server start
11+
service redis-server start &
12+
sleep 3
1213

13-
echo "Veth setup"
14-
/usr/share/bmpd/tools/veth_setup.sh > /tmp/veth_setup.log 2>&1
14+
redis-cli flushall
1515

16-
echo "Disable IPv6"
17-
/usr/share/bmpd/tools/veth_disable_ipv6.sh > /tmp/veth_disable.log 2>&1
16+
echo "Veth setup"
17+
veth_setup.sh > /tmp/veth_setup.log 2>&1
1818

1919
echo "Start BMV2"
20-
/run_bm.sh > /tmp/run_bm.log 2>&1 &
20+
/scripts/run_bm.sh > /tmp/run_bm.log 2>&1 &
2121
sleep 15
2222

2323
redis-cli -n 1 set LOGLEVEL DEBUG

platform/p4/p4-bmv.mk

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# p4 bmv package
22

3-
P4_BMV = p4-bmv2_1.0.0_amd64.deb
4-
$(P4_BMV)_DEPENDS += $(LIBTHRIFT_DEV) $(PYTHON_THRIFT) $(THRIFT_COMPILER)
3+
P4_BMV = sai-p4-bm_1.0.0_amd64.deb
4+
$(P4_BMV)_DEPENDS += $(LIBTHRIFT_DEV) $(PYTHON_THRIFT) $(THRIFT_COMPILER) $(P4C_BM)
55
$(P4_BMV)_RDEPENDS += $(LIBTHRIFT) $(PYTHON_THRIFT) $(THRIFT_COMPILER)
6-
$(P4_BMV)_SRC_PATH = $(PLATFORM_PATH)/p4-bmv/behavioral-model
6+
$(P4_BMV)_SRC_PATH = $(PLATFORM_PATH)/SAI-P4-BM/p4-switch
77
SONIC_DPKG_DEBS += $(P4_BMV)

platform/p4/p4-bmv/behavioral-model

-1
This file was deleted.

platform/p4/p4-hlir.mk

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# p4 bmv package
22

3+
P4_HLIR_V1_1 = python-p4-hlir-v1-1_1.1.7-1_all.deb
4+
$(P4_HLIR_V1_1)_SRC_PATH = $(PLATFORM_PATH)/p4-hlir/p4-hlir-v1.1
5+
SONIC_PYTHON_STDEB_DEBS += $(P4_HLIR_V1_1)
6+
37
P4_HLIR = python-p4-hlir_0.9.36-1_all.deb
48
$(P4_HLIR)_SRC_PATH = $(PLATFORM_PATH)/p4-hlir/p4-hlir
59
SONIC_PYTHON_STDEB_DEBS += $(P4_HLIR)

platform/p4/p4-hlir/p4-hlir-v1.1

Submodule p4-hlir-v1.1 added at fdee55e

platform/p4/p4-switch.mk

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# p4 switch package
1+
# p4 sai adapter package
22

3-
P4_SWITCH = p4-switch_1.0.0_amd64.deb
4-
$(P4_SWITCH)_DEPENDS += $(P4C_BM) $(P4_BMV)
5-
$(P4_SWITCH)_RDEPENDS += $(P4C_BM) $(P4_BMV)
6-
$(P4_SWITCH)_SRC_PATH = $(PLATFORM_PATH)/p4-switch
7-
SONIC_MAKE_DEBS += $(P4_SWITCH)
3+
P4_SWITCH = p4-sai-adapter_0.1-0_amd64.deb
4+
$(P4_SWITCH)_DEPENDS += $(LIBTHRIFT_DEV) $(PYTHON_THRIFT) $(THRIFT_COMPILER) $(P4_BMV)
5+
$(P4_SWITCH)_RDEPENDS += $(LIBTHRIFT) $(PYTHON_THRIFT) $(THRIFT_COMPILER) $(P4_BMV)
6+
$(P4_SWITCH)_SRC_PATH = $(PLATFORM_PATH)/SAI-P4-BM/sai_adapter
7+
SONIC_DPKG_DEBS += $(P4_SWITCH)

platform/p4/p4-switch/Makefile

-17
This file was deleted.

platform/p4/p4-switch/switch

-1
This file was deleted.

platform/p4/p4c-bm.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
P4C_BM = python-p4c-bm_1.0.0-5415c416-1_all.deb
44
$(P4C_BM)_SRC_PATH = $(PLATFORM_PATH)/p4c-bm/p4c-bm
5-
$(P4C_BM)_DEPENDS += $(TENJIN) $(P4_HLIR)
6-
$(P4C_BM)_RDEPENDS += $(TENJIN) $(P4_HLIR)
5+
$(P4C_BM)_DEPENDS += $(TENJIN) $(P4_HLIR) $(P4_HLIR_V1_1)
6+
$(P4C_BM)_RDEPENDS += $(TENJIN) $(P4_HLIR) $(P4_HLIR_V1_1)
77
SONIC_PYTHON_STDEB_DEBS += $(P4C_BM)

platform/p4/rules.mk

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
include $(PLATFORM_PATH)/p4-switch.mk
2-
include $(PLATFORM_PATH)/p4-bmv.mk
1+
# include $(PLATFORM_PATH)/p4-softswitch.mk
2+
include $(PLATFORM_PATH)/tenjin.mk
33
include $(PLATFORM_PATH)/p4-hlir.mk
44
include $(PLATFORM_PATH)/p4c-bm.mk
5-
include $(PLATFORM_PATH)/tenjin.mk
5+
# include $(PLATFORM_PATH)/p4-sai-bm.mk
6+
include $(PLATFORM_PATH)/p4-bmv.mk
7+
include $(PLATFORM_PATH)/p4-switch.mk
68
include $(PLATFORM_PATH)/docker-sonic-p4.mk
79

810
SONIC_ALL += $(DOCKER_SONIC_P4)

platform/p4/tenjin/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ MAIN_TARGET = python-tenjin_$(TENJIN_VERSION_FULL)_all.deb
99
$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
1010
rm -rf Tenjin-$(TENJIN_VERSION)
1111

12-
wget -nc http://pypi.python.org/packages/source/T/Tenjin/Tenjin-$(TENJIN_VERSION).tar.gz
12+
wget -nc https://pypi.python.org/packages/source/T/Tenjin/Tenjin-$(TENJIN_VERSION).tar.gz
1313
tar xzf Tenjin-$(TENJIN_VERSION).tar.gz
1414

1515
pushd Tenjin-$(TENJIN_VERSION)

0 commit comments

Comments
 (0)