Skip to content

Commit a91cca3

Browse files
Nieuwejaarbnaeckerinternet-diglettrcgoodfellowzeeshanlakhani
committed
initial open source release
Co-authored-by: Benjamin Naecker <ben@oxide.computer> Co-authored-by: Levon Tarver <levon@oxide.computer> Co-authored-by: Ryan Goodfellow <ryan.goodfellow@oxide.computer> Co-authored-by: Zeeshan Lakhani <zeeshan@oxidecomputer.com>
0 parents  commit a91cca3

File tree

213 files changed

+82322
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+82322
-0
lines changed

.cargo/config.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[alias]
2+
xtask = "run --package xtask --"
3+
4+
[net]
5+
git-fetch-with-cli = true
6+
7+
[profile.dev]
8+
panic = "abort"
9+
10+
[profile.release]
11+
panic = "abort"
12+
13+
# We'd like to set this only if the `tokio-console` feature is enabled, but it
14+
# is not recommended to match on a `cfg` directive that includes features.
15+
# See https://doc.rust-lang.org/cargo/reference/config.html#target.
16+
[build]
17+
rustflags = ["--cfg", "tokio_unstable"]
18+
19+
# https://github.com/rust-lang/cargo/issues/3946#issuecomment-973132993
20+
[env]
21+
CARGO_WORKSPACE_DIR = { value = "", relative = true }

.github/buildomat/common.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# These describe which version of the SDE to download and where to find it
4+
SDE_COMMIT=0e4cfe10c92db223a953923d77f09a299b82157b
5+
SDE_PKG_SHA256=89795e536cfc9713a892904480c6c1d7bff99ca8b9e16ba8c3955fb548e037fe
6+
SDE_DEB_SHA256=deb3015f8f8a46a16de8d7ddfa549d353a658105a0dcb963e5bd65587f3d0758
7+
8+
[ `uname -s` == "SunOS" ] && SERIES=illumos
9+
[ `uname -s` == "SunOS" ] || SERIES=linux
10+
SDE_DIR=https://buildomat.eng.oxide.computer/public/file/oxidecomputer/tofino-sde/$SERIES/$SDE_COMMIT
11+
12+
# Install the active Rust toolchain from rust-toolchain.toml. We need this
13+
# because `rustup` version 1.28 made it where the toolchain is not installed by
14+
# default.
15+
rustup show active-toolchain || rustup toolchain install

.github/buildomat/config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#
2+
# This file, with this flag, must be present in the default branch in order for
3+
# the buildomat integration to create check suites.
4+
#
5+
enable = true

.github/buildomat/illumos.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Download the SDE from CI, verify its integrity, and install it
2+
banner "sde setup"
3+
4+
export PKG=tofino_sde.p5p
5+
curl -OL $SDE_DIR/$PKG
6+
SDE_CALC=`digest -a sha256 $PKG`
7+
if [ $SDE_CALC != $SDE_PKG_SHA256 ]; then
8+
echo "downloaded tofino_sde has a bad checksum"
9+
exit 1
10+
fi
11+
pfexec pkg install -g $PKG tofino_sde
12+
13+
export SDE=/opt/oxide/tofino_sde
14+
export LD_LIBRARY_PATH="$SDE/lib:$LD_LIBRARY_PATH"
15+
16+
# Install a couple of non-standard packages needed to build dendrite
17+
banner "packages"
18+
pfexec pkg install clang-15 pcap
19+
pfexec pkg set-mediator -V 15 clang llvm
20+
21+
cargo --version
22+
rustc --version

.github/buildomat/jobs/dpd_openapi.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
#:
3+
#: name = "dpd_openapi"
4+
#: variety = "basic"
5+
#: target = "helios-2.0"
6+
#: output_rules = [
7+
#: "/out/*",
8+
#: ]
9+
#:
10+
#: [[publish]]
11+
#: series = "openapi"
12+
#: name = "dpd.json"
13+
#: from_output = "/out/dpd.json"
14+
#:
15+
#: [[publish]]
16+
#: series = "openapi"
17+
#: name = "dpd.json.sha256.txt"
18+
#: from_output = "/out/dpd.json.sha256.txt"
19+
20+
set -o errexit
21+
set -o pipefail
22+
set -o xtrace
23+
24+
banner copy
25+
pfexec mkdir -p /out
26+
pfexec chown "$UID" /out
27+
cp openapi/dpd.json /out/dpd.json
28+
digest -a sha256 /out/dpd.json > /out/dpd.json.sha256.txt

.github/buildomat/jobs/image.sh

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
#!/bin/bash
2+
#:
3+
#: name = "image"
4+
#: variety = "basic"
5+
#: target = "helios-2.0"
6+
#: rust_toolchain = true
7+
#: output_rules = [
8+
#: "/out/*",
9+
#: "/out/p4c-diags/logs/*",
10+
#: "/out/p4c-diags/graphs/*"
11+
#: ]
12+
#:
13+
#: [[publish]]
14+
#: series = "image"
15+
#: name = "dendrite-stub.tar.gz"
16+
#: from_output = "/out/dendrite-stub.tar.gz"
17+
#:
18+
#: [[publish]]
19+
#: series = "image"
20+
#: name = "dendrite-stub.sha256.txt"
21+
#: from_output = "/out/dendrite-stub.sha256.txt"
22+
#:
23+
#: [[publish]]
24+
#: series = "image"
25+
#: name = "dendrite-asic.tar.gz"
26+
#: from_output = "/out/dendrite-asic.tar.gz"
27+
#:
28+
#: [[publish]]
29+
#: series = "image"
30+
#: name = "dendrite-asic.sha256.txt"
31+
#: from_output = "/out/dendrite-asic.sha256.txt"
32+
#:
33+
#: [[publish]]
34+
#: series = "image"
35+
#: name = "dendrite-asic-console.tar.gz"
36+
#: from_output = "/out/dendrite-asic-console.tar.gz"
37+
#:
38+
#: [[publish]]
39+
#: series = "image"
40+
#: name = "dendrite-asic-console.sha256.txt"
41+
#: from_output = "/out/dendrite-asic-console.sha256.txt"
42+
#:
43+
#: [[publish]]
44+
#: series = "image"
45+
#: name = "dendrite-softnpu.tar.gz"
46+
#: from_output = "/out/dendrite-softnpu.tar.gz"
47+
#:
48+
#: [[publish]]
49+
#: series = "image"
50+
#: name = "dendrite-softnpu.sha256.txt"
51+
#: from_output = "/out/dendrite-softnpu.sha256.txt"
52+
#:
53+
#: [[publish]]
54+
#: series = "image"
55+
#: name = "dendrite-global.tar.gz"
56+
#: from_output = "/out/dendrite-global.tar.gz"
57+
#:
58+
#: [[publish]]
59+
#: series = "image"
60+
#: name = "dendrite-global.sha256.txt"
61+
#: from_output = "/out/dendrite-global.sha256.txt"
62+
#:
63+
#: [[publish]]
64+
#: series = "image"
65+
#: name = "dendrite-global-console.tar.gz"
66+
#: from_output = "/out/dendrite-global-console.tar.gz"
67+
#:
68+
#: [[publish]]
69+
#: series = "image"
70+
#: name = "dendrite-global-console.sha256.txt"
71+
#: from_output = "/out/dendrite-global-console.sha256.txt"
72+
#:
73+
#: [[publish]]
74+
#: series = "bin"
75+
#: name = "swadm"
76+
#: from_output = "/out/swadm"
77+
#:
78+
#: [[publish]]
79+
#: series = "bin"
80+
#: name = "swadm.sha256.txt"
81+
#: from_output = "/out/swadm.sha256.txt"
82+
#:
83+
84+
set -o errexit
85+
set -o pipefail
86+
set -o xtrace
87+
88+
source .github/buildomat/common.sh
89+
source .github/buildomat/illumos.sh
90+
91+
# Copy file from our local working directory into the /out directory, where
92+
# buildomat can retrieve for archiving.
93+
# usage: archive <source stem> <dest stem> <suffix>
94+
function archive {
95+
mv out/$1$3 /out/$2$3
96+
digest -a sha256 /out/$2$3 > /out/$2.sha256.txt
97+
}
98+
99+
pfexec mkdir -p /out
100+
pfexec chown "$UID" /out
101+
102+
banner "P4 Codegen"
103+
# Add gcc-12 so the p4 compiler can find cpp
104+
# The tofino2 has 20 stages, but the current sidecar.p4 will fit into 14. We
105+
# add the "--stages 14" here to detect if/when the program grows beyond that
106+
# limit. It's not necessarily a problem if we grow, but given the limited space
107+
# on the ASIC, we want to grow deliberatately and thoughtfully.
108+
PATH=/opt/gcc-12/bin:$PATH cargo xtask codegen --stages 14
109+
110+
# Preserve all the diagnostics spit out by the compiler
111+
mkdir -p /out/p4c-diags
112+
cp -r target/proto/opt/oxide/dendrite/sidecar/pipe/logs /out/p4c-diags/
113+
cp -r target/proto/opt/oxide/dendrite/sidecar/pipe/graphs /out/p4c-diags/
114+
115+
# Build the binaries that are common across all asic varieties
116+
banner build common
117+
export SDE=/opt/oxide/tofino_sde
118+
ptime -m cargo build --release --verbose --bin swadm --bin tfportd --bin uplinkd
119+
cp target/release/swadm /out
120+
digest -a sha256 /out/swadm > /out/swadm.sha256.txt
121+
122+
cp target/release/swadm /out
123+
digest -a sha256 /out/swadm > /out/swadm.sha256.txt
124+
125+
# Build the `dpd` binary, and package / archive the result.
126+
#
127+
# Arguments:
128+
# 1. The feature name for the provided package name, e.g., `tofino_asic`
129+
# 2. An optional `--with-console` flag, to enable the `tokio-console` feature
130+
# of `dpd`.
131+
function build() {
132+
local FEATURE="$1"
133+
NAME="$(echo $FEATURE | sed "s/tofino_//")"
134+
if [ "$2" = "--with-console" ]; then
135+
echo "building with tokio-console feature"
136+
DPD_FEATURES="$FEATURE tokio-console"
137+
LOCAL_ARCHIVE_SUFFIX="$NAME-console"
138+
GLOBAL_ARCHIVE_SUFFIX="global-console"
139+
else
140+
DPD_FEATURES="$FEATURE"
141+
LOCAL_ARCHIVE_SUFFIX="$NAME"
142+
GLOBAL_ARCHIVE_SUFFIX="global"
143+
fi
144+
banner build "$NAME"
145+
ptime -m cargo build --release --verbose --features "$DPD_FEATURES" --bin dpd
146+
147+
banner package "$NAME"
148+
ptime -m cargo xtask dist --format omicron --release --features "$FEATURE"
149+
150+
if [ "$NAME" = "asic" ]; then
151+
echo "building helios tarball"
152+
ptime -m cargo xtask dist --format global --release
153+
mv dendrite-global.tar.gz "out/dendrite-$GLOBAL_ARCHIVE_SUFFIX.tar.gz"
154+
archive "dendrite-$GLOBAL_ARCHIVE_SUFFIX" "dendrite-$GLOBAL_ARCHIVE_SUFFIX" .tar.gz
155+
fi
156+
157+
banner archive "$NAME"
158+
archive dendrite "dendrite-$LOCAL_ARCHIVE_SUFFIX" .tar.gz
159+
}
160+
161+
for FEATURE in tofino_stub tofino_asic softnpu
162+
do
163+
build "$FEATURE"
164+
if [ "$FEATURE" = "tofino_asic" ]; then
165+
build "$FEATURE" --with-console
166+
fi
167+
done
168+
169+
ls -lR /out/

.github/buildomat/jobs/linux.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
#:
3+
#: name = "linux"
4+
#: variety = "basic"
5+
#: target = "ubuntu-22.04"
6+
#: rust_toolchain = true
7+
#: output_rules = [
8+
#: "/out/*",
9+
#: "/work/swadm",
10+
#: "/work/swadm.sha256.txt",
11+
#: "/work/dpd",
12+
#: "/work/dpd.sha256.txt",
13+
#: ]
14+
#:
15+
#: [[publish]]
16+
#: series = "linux-bin"
17+
#: name = "swadm"
18+
#: from_output = "/work/swadm"
19+
#:
20+
#: [[publish]]
21+
#: series = "linux-bin"
22+
#: name = "swadm.sha256.txt"
23+
#: from_output = "/work/swadm.sha256.txt"
24+
#:
25+
#: [[publish]]
26+
#: series = "linux-bin"
27+
#: name = "dpd"
28+
#: from_output = "/work/dpd"
29+
#
30+
#: [[publish]]
31+
#: series = "linux-bin"
32+
#: name = "dpd.sha256.txt"
33+
#: from_output = "/work/dpd.sha256.txt"
34+
#:
35+
36+
set -o errexit
37+
set -o pipefail
38+
set -o xtrace
39+
40+
source .github/buildomat/common.sh
41+
source .github/buildomat/linux.sh
42+
43+
banner "Packages"
44+
sudo apt update -y
45+
sudo apt install -y libpcap-dev libclang-dev libssl-dev
46+
47+
export SDE=/opt/oxide/tofino_sde
48+
49+
banner "Build"
50+
cargo build --features=tofino_asic --bin dpd
51+
cargo build --release --features=tofino_stub --bin dpd --bin swadm
52+
53+
cp target/release/dpd /work
54+
digest /work/dpd > /work/dpd.sha256.txt
55+
56+
cp target/release/swadm /work
57+
digest /work/swadm > /work/swadm.sha256.txt
58+
59+
banner "Artifacts"
60+
sudo mkdir -p /out
61+
sudo chown "$UID" /out

0 commit comments

Comments
 (0)