Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Add infra for 2 p4 stack support #32

Open
wants to merge 3 commits into
base: azure-buildimage
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"chip_list": [
{
"id": "asic-0",
"chip_family": "Tofino",
"instance": 0,
"pcie_sysfs_prefix": "/sys/devices/pci0000:00/0000:00:03.0/0000:05:00.0",
"pcie_domain": 0,
"pcie_bus": 5,
"pcie_fn": 0,
"pcie_dev": 0,
"pcie_int_mode": 1,
"sds_fw_path": "share/tofino_sds_fw/avago/firmware"
}
],
"instance": 0,
"p4_program_list": [
{
"id": "pgm-0",
"instance": 0,
"path": "switch",
"program-name": "switch",
"table-config": "share/tofinopd/switch/pipe/context.json",
"tofino-bin": "share/tofinopd/switch/pipe/tofino.bin",
"switchsai": "lib/libswitchsai.so",
"agent0": "lib/platform/x86_64-accton_wedge100bf_32x-r0/libpltfm_mgr.so",
"bfrt-config" : "share/tofinopd/switch/bf-rt.json",
"model_json_path" : "share/switch/aug_model.json"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add comma EOL

"switchapi_port_add": false,
"non_default_port_ppgs": 5
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"chip_list": [
{
"id": "asic-0",
"chip_family": "Tofino",
"instance": 0,
"pcie_sysfs_prefix": "/sys/devices/pci0000:00/0000:00:03.0/0000:05:00.0",
"pcie_domain": 0,
"pcie_bus": 5,
"pcie_fn": 0,
"pcie_dev": 0,
"pcie_int_mode": 1,
"sds_fw_path": "share/tofino_sds_fw/avago/firmware"
}
],
"instance": 0,
"p4_program_list": [
{
"id": "pgm-0",
"instance": 0,
"path": "switch",
"program-name": "switch",
"table-config": "share/tofinopd/switch/pipe/context.json",
"tofino-bin": "share/tofinopd/switch/pipe/tofino.bin",
"switchsai": "lib/libswitchsai.so",
"agent0": "lib/platform/x86_64-accton_wedge100bf_65x-r0/libpltfm_mgr.so",
"bfrt-config" : "share/tofinopd/switch/bf-rt.json",
"model_json_path" : "share/switch/aug_model.json"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add comma EOL

"switchapi_port_add": false,
"non_default_port_ppgs": 5
}
]
}
4 changes: 4 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ sudo LANG=C chroot $FILESYSTEM_ROOT fuser -km /sys || true
sudo LANG=C chroot $FILESYSTEM_ROOT umount -lf /sys
{% endif %}

{% if sonic_asic_platform == "barefoot" %}
sudo cp p4stack.service $FILESYSTEM_ROOT/etc/systemd/system/
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable p4stack.service
{% endif %}
# Copy swss and syncd service script
sudo LANG=C cp $SCRIPTS_DIR/swss.sh $FILESYSTEM_ROOT/usr/local/bin/swss.sh
sudo LANG=C cp $SCRIPTS_DIR/syncd.sh $FILESYSTEM_ROOT/usr/local/bin/syncd.sh
Expand Down
4 changes: 4 additions & 0 deletions files/build_templates/syncd.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ Requires=database.service updategraph.service
Requires=opennsl-modules-4.9.0-7-amd64.service
{% elif sonic_asic_platform == 'nephos' %}
Requires=nps-modules-4.9.0-7-amd64.service
{% elif sonic_asic_platform == 'barefoot' %}
Requires=p4stack.service
{% endif %}
After=database.service updategraph.service
After=interfaces-config.service
{% if sonic_asic_platform == 'broadcom' %}
After=opennsl-modules-4.9.0-7-amd64.service
{% elif sonic_asic_platform == 'nephos' %}
After=nps-modules-4.9.0-7-amd64.service
{% elif sonic_asic_platform == 'barefoot' %}
After=p4stack.service
{% endif %}

[Service]
Expand Down
8 changes: 7 additions & 1 deletion platform/barefoot/bfn-platform.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
BFN_PLATFORM = bfnplatform_1.0.0_amd64.deb
$(BFN_PLATFORM)_URL = "https://github.com/barefootnetworks/sonic-release-pkgs/raw/sde-sai1.3.3/bfnplatform_1.0.0_amd64.deb"

ifeq ($(CONFIGURED_P4_STACK),p4_16)
$(BFN_PLATFORM)_PATH = /sonic # use local path, should be changed as soon as we released p4-16 and make pub available
SONIC_COPY_DEBS +=$(BFN_PLATFORM)
else
$(BFN_PLATFORM)_URL = "https://github.com/barefootnetworks/sonic-release-pkgs/raw/sde-sai1.3.3/bfnplatform_1.0.0_amd64.deb"
SONIC_ONLINE_DEBS += $(BFN_PLATFORM) # $(BFN_SAI_DEV)
endif

$(BFN_SAI_DEV)_DEPENDS += $(BFN_PLATFORM)
8 changes: 7 additions & 1 deletion platform/barefoot/bfn-sai.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
BFN_SAI = bfnsdk_1.0.0_amd64.deb
$(BFN_SAI)_URL = "https://github.com/barefootnetworks/sonic-release-pkgs/raw/sde-sai1.3.3/bfnsdk_1.0.0_amd64.deb"

ifeq ($(CONFIGURED_P4_STACK),p4_16)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we do not plan to merge to the upstream p4_16/p4_14 stack selection infrastructure at this moment, probably we can use the same approach but without mentioning p4_16, just to expose the approach itself. Also, we can use this methodology to either build from public DEB package or from the sources $(BFN_SAI)_PATH. Again, without mentioning p4_16.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it will have to be transparent. For same switch.p4 profile, we dont need to maintain both p4-14 and p4-16 versions.

$(BFN_SAI)_PATH = /sonic # use local path, should be changed to URL as soon as we released p4-16 and make pub available
SONIC_COPY_DEBS +=$(BFN_SAI)
else
$(BFN_SAI)_URL = "https://github.com/barefootnetworks/sonic-release-pkgs/raw/sde-sai1.3.3/bfnsdk_1.0.0_amd64.deb"
SONIC_ONLINE_DEBS += $(BFN_SAI) # $(BFN_SAI_DEV)
endif

$(BFN_SAI_DEV)_DEPENDS += $(BFN_SAI)
2 changes: 1 addition & 1 deletion platform/barefoot/docker-syncd-bfn/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ debs/{{ deb }}{{' '}}
{%- endfor -%}
debs/

RUN apt-get install -y libxml2 libpcap-dev libusb-1.0-0-dev libcurl3 libcurl4-gnutls-dev libunwind8-dev libpython3.4
RUN apt-get install -y libxml2 libpcap-dev libusb-1.0-0-dev libcurl3 libcurl4-gnutls-dev libunwind8-dev libpython3.4 libc-ares2 libgoogle-perftools4

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we aren't making it a dependency of our .deb package?


RUN dpkg -i \
{% for deb in docker_syncd_bfn_debs.split(' ') -%}
Expand Down
23 changes: 23 additions & 0 deletions platform/barefoot/systemd/p4stack.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Unit]

Description=Barefoot P4 stack cofiguration service
Before=syncd.service
After=database.service
[Service]

Type=oneshot
{% if CONFIGURED_P4_STACK is not defined %}
{% set CONFIGURED_P4_STACK= 'p4_14' %}
{% endif %}
Environment=P4_STACK={{ CONFIGURED_P4_STACK }}

ExecStart=/bin/bash -c ' \
PLATFORM=$(/usr/local/bin/sonic-cfggen -H -v 'DEVICE_METADATA.localhost.platform'); \
HWSKU=$(/usr/local/bin/sonic-cfggen -d -v 'DEVICE_METADATA.localhost.hwsku'); \
cd /usr/share/sonic/device/$PLATFORM/$HWSKU; \
[[ "$P4_STACK" == "p4_16" ]] && \
ln -s switch-sai.p416.conf switch-sai.conf || \
ln -s switch-sai.p414.conf switch-sai.conf'

[Install]
WantedBy=multi-user.target
5 changes: 3 additions & 2 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ PLATFORM_PATH = platform/$(CONFIGURED_PLATFORM)
export BUILD_NUMBER
export BUILD_TIMESTAMP
export CONFIGURED_PLATFORM

###############################################################################
## Utility rules
## Define configuration, help etc.
Expand Down Expand Up @@ -520,7 +519,9 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
j2 -f env files/initramfs-tools/arista-convertfs.j2 onie-image.conf > files/initramfs-tools/arista-convertfs

j2 files/build_templates/updategraph.service.j2 > updategraph.service

ifeq ($(CONFIGURED_PLATFORM),barefoot)
j2 $(PLATFORM_PATH)/systemd/p4stack.service.j2 > p4stack.service
endif
$(if $($*_DOCKERS),
j2 files/build_templates/sonic_debian_extension.j2 > sonic_debian_extension.sh
chmod +x sonic_debian_extension.sh,
Expand Down
2 changes: 2 additions & 0 deletions sonic-slave/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ RUN apt-get update && apt-get install -y \
libcurl3-nss-dev \
libunwind8-dev \
telnet \
libc-ares2 \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we aren't making this the dependencies of our .deb package? (Install them with our .dev)

libgoogle-perftools4 \
# For build image
cpio \
squashfs-tools \
Expand Down