Skip to content
Merged
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
34 changes: 34 additions & 0 deletions .github/buildomat/jobs/multicast-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
#:
#: name = "multicast-test"
#: variety = "basic"
#: target = "ubuntu-22.04"
#: rust_toolchain = true
#:
#: output_rules = [
#: "/work/simulator.log",
#: "/work/dpd.log",
#: ]
#:

#### >>>>>>>>>>>>>>>>>>>>>>>>>>>> Local Usage >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
####
#### The following environment variables are useful.
####
#### - JUST_TEST=1 Just runs the tests, skipping system prep.
#### - TESTNAME='$name' Will just run the specified test.
#### - STARTUP_TIMEOUT=n Seconds to wait for tofino-model/dpd to start.
#### Defaults to 15.
#### - NOBUILD=1 Don't build sidecar.p4 (in case you've already
#### built it)
####
#### <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

export RUST_BACKTRACE=1

set -o errexit
set -o pipefail
set -o xtrace

export MULTICAST=1
source .github/buildomat/packet-test-common.sh
102 changes: 1 addition & 101 deletions .github/buildomat/jobs/packet-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,104 +30,4 @@ set -o errexit
set -o pipefail
set -o xtrace

source .github/buildomat/common.sh
source .github/buildomat/linux.sh

wd=`pwd`
export WS=$wd
STARTUP_TIMEOUT=${STARTUP_TIMEOUT:=15}

function cleanup {
set +o errexit
set +o pipefail
cd $wd
sudo -E pkill -9 dpd
sudo -E pkill -9 tofino-model
sudo -E ./tools/veth_teardown.sh
stty sane
# wait for daemons to die, if log file sizes change this can fail CI
sleep 10
}
trap cleanup EXIT

if [[ $JUST_TEST -ne 1 ]]; then
# See what hugepages was before starting
sysctl vm.nr_hugepages
# Make sure huge pages is enabled. This is required for running the SDE on
# linux.
sudo -E sysctl -w vm.nr_hugepages=128
# Under some circumstances the sysctl may not completely work, so flush
# the vm caches and retry.
sudo -E sh -c 'echo 3 > /proc/sys/vm/drop_caches'
sudo -E sysctl -w vm.nr_hugepages=128
# See what hugepages is now. If this is zero and things go sideways later,
# you'll know why.
sysctl vm.nr_hugepages

banner "Packages"
sudo apt update -y
sudo apt install -y \
libpcap-dev \
libclang-dev \
libssl-dev \
pkg-config \
libcli-dev \
sysvbanner
fi

export SDE=/opt/oxide/tofino_sde

banner "Build"
if [[ $NOBUILD -ne 1 ]]; then
cargo build --features=tofino_asic --bin dpd --bin swadm
cargo xtask codegen --stages $TOFINO_STAGES
fi

banner "Test"
sudo -E ./tools/veth_setup.sh
id=`id -un`
gr=`id -gn`
sudo -E mkdir -p /work
sudo -E chown $id:$gr /work
sudo -E ./tools/run_tofino_model.sh &> /work/simulator.log &
sleep $STARTUP_TIMEOUT
sudo -E ./tools/run_dpd.sh -m 127.0.0.1 &> /work/dpd.log &
sleep $STARTUP_TIMEOUT

banner "Links"

./target/debug/swadm -h '[::1]' link ls || echo "failed to list links"

banner "swadm Checks"

pushd swadm

DENDRITE_TEST_HOST='[::1]' \
DENDRITE_TEST_VERBOSITY=3 \
cargo test \
--no-fail-fast \
--test \
counters \
-- \
--ignored

popd

banner "Packet Tests"

set +o errexit
set +o pipefail
stty sane
set -o errexit
set -o pipefail

pushd dpd-client

DENDRITE_TEST_HOST='[::1]' \
DENDRITE_TEST_VERBOSITY=3 \
cargo test \
--features tofino_asic \
--no-fail-fast \
$TESTNAME \
-- \
--ignored
source .github/buildomat/packet-test-common.sh
132 changes: 132 additions & 0 deletions .github/buildomat/packet-test-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
export RUST_BACKTRACE=1

source .github/buildomat/common.sh
source .github/buildomat/linux.sh

wd=`pwd`
export WS=$wd
MODEL_STARTUP_TIMEOUT=${MODEL_STARTUP_TIMEOUT:=5}
STARTUP_TIMEOUT=${STARTUP_TIMEOUT:=120}

if [ x$MULTICAST == x ]; then
BUILD_FEATURES=tofino_asic
CODEGEN_FEATURES=
SWADM_FEATURES=
else
BUILD_FEATURES=tofino_asic,multicast
CODEGEN_FEATURES=--multicast
SWADM_FEATURES=--features=multicast
fi

function cleanup {
set +o errexit
set +o pipefail
cd $wd
sudo -E pkill -9 dpd
sudo -E pkill -9 tofino-model
sudo -E ./tools/veth_teardown.sh
stty sane
# wait for daemons to die, if log file sizes change this can fail CI
sleep 10
}
trap cleanup EXIT

if [[ $JUST_TEST -ne 1 ]]; then
# See what hugepages was before starting
sysctl vm.nr_hugepages
# Make sure huge pages is enabled. This is required for running the SDE on
# linux.
sudo -E sysctl -w vm.nr_hugepages=128
# Under some circumstances the sysctl may not completely work, so flush
# the vm caches and retry.
sudo -E sh -c 'echo 3 > /proc/sys/vm/drop_caches'
sudo -E sysctl -w vm.nr_hugepages=128
# See what hugepages is now. If this is zero and things go sideways later,
# you'll know why.
sysctl vm.nr_hugepages

banner "Packages"
sudo apt update -y
sudo apt install -y \
libpcap-dev \
libclang-dev \
libssl-dev \
pkg-config \
libcli-dev \
sysvbanner
fi

export SDE=/opt/oxide/tofino_sde

banner "Build"
if [[ $NOBUILD -ne 1 ]]; then
cargo build --features=$BUILD_FEATURES --bin dpd --bin swadm
cargo xtask codegen --stages $TOFINO_STAGES $CODEGEN_FEATURES
fi

banner "Test"
sudo -E ./tools/veth_setup.sh
id=`id -un`
gr=`id -gn`
sudo -E mkdir -p /work
sudo -E chown $id:$gr /work
sudo -E ./tools/run_tofino_model.sh &> /work/simulator.log &
sleep $MODEL_STARTUP_TIMEOUT
sudo -E ./tools/run_dpd.sh -m 127.0.0.1 &> /work/dpd.log &
echo "waiting for dpd to come online"
set +o errexit

SLEEP_TIME=5
iters=$(( $STARTUP_TIMEOUT / $SLEEP_TIME ))
while [ 1 ] ; do
./target/debug/swadm --host '[::1]' build-info 2> /dev/null
if [ $? == 0 ]; then
break
fi
iters=$(($iters - 1))
if [ $iters = 0 ]; then
echo "dpd failed to come online in $STARTUP_TIMEOUT seconds"
exit 1
fi
sleep $SLEEP_TIME
done
set -o errexit

banner "Links"

./target/debug/swadm --host '[::1]' link ls || echo "failed to list links"

banner "swadm Checks"

pushd swadm

DENDRITE_TEST_HOST='[::1]' \
DENDRITE_TEST_VERBOSITY=3 \
cargo test \
--no-fail-fast \
$SWADM_FEATURES \
--test \
counters \
-- \
--ignored

popd

banner "Packet Tests"

set +o errexit
set +o pipefail
stty sane
set -o errexit
set -o pipefail

pushd dpd-client

DENDRITE_TEST_HOST='[::1]' \
DENDRITE_TEST_VERBOSITY=3 \
cargo test \
--features $BUILD_FEATURES \
--no-fail-fast \
$TESTNAME \
-- \
--ignored
3 changes: 2 additions & 1 deletion aal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "aal"
version = "0.1.0"
edition = "2024"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
multicast = []

[dependencies]
common.workspace = true
Expand Down
87 changes: 45 additions & 42 deletions aal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,52 @@ pub enum AsicError {
Missing(String),
}

/// The `AsicOps` trait contains all of the non-Table related ASIC operations
/// The `AsicMulticastOps` trait contains the multicast-related ASIC operations
/// that the dataplane daemon requires.
#[cfg(feature = "multicast")]
pub trait AsicMulticastOps {
/// Return a vector containing all of the defined multicast groups.
fn mc_domains(&self) -> Vec<u16>;

/// For a given multicast group, return the number of ports assigned to it.
fn mc_port_count(&self, group_id: u16) -> AsicResult<usize>;

/// Add a port to a multicast group. The port is identified using its ASIC
/// identifier.
fn mc_port_add(
&self,
group_id: u16,
port: AsicId,
rid: u16,
level_1_excl_id: u16,
) -> AsicResult<()>;

/// Remove a port from a multicast group. The port is identified using its ASIC
/// identifier.
fn mc_port_remove(&self, group_id: u16, port: AsicId) -> AsicResult<()>;

/// Create a new, unpopulated multicast group.
fn mc_group_create(&self, group_id: u16) -> AsicResult<()>;

/// Destroy a multicast group.
fn mc_group_destroy(&self, group_id: u16) -> AsicResult<()>;

/// Check if a multicast group exists.
fn mc_group_exists(&self, group_id: u16) -> bool {
self.mc_domains().contains(&group_id)
}

/// Get the total number of multicast groups.
fn mc_groups_count(&self) -> AsicResult<usize>;

/// Set the maximum number of multicast nodes.
fn mc_set_max_nodes(
&self,
max_nodes: u32,
max_link_aggregated_nodes: u32,
) -> AsicResult<()>;
}

pub trait AsicOps {
/// Reports the kind of media plugged into the port
// TODO-correctness: This should probably take a `PortId` or `Connector`.
Expand Down Expand Up @@ -196,47 +240,6 @@ pub trait AsicOps {
connector: Connector,
) -> AsicResult<Vec<u8>>;

/// Return a vector containing all of the defined multicast groups.
fn mc_domains(&self) -> Vec<u16>;

/// For a given multicast group, return the number of ports assigned to it.
fn mc_port_count(&self, group_id: u16) -> AsicResult<usize>;

/// Add a port to a multicast group. The port is identified using its ASIC
/// identifier.
fn mc_port_add(
&self,
group_id: u16,
port: AsicId,
rid: u16,
level_1_excl_id: u16,
) -> AsicResult<()>;

/// Remove a port from a multicast group. The port is identified using its ASIC
/// identifier.
fn mc_port_remove(&self, group_id: u16, port: AsicId) -> AsicResult<()>;

/// Create a new, unpopulated multicast group.
fn mc_group_create(&self, group_id: u16) -> AsicResult<()>;

/// Destroy a multicast group.
fn mc_group_destroy(&self, group_id: u16) -> AsicResult<()>;

/// Check if a multicast group exists.
fn mc_group_exists(&self, group_id: u16) -> bool {
self.mc_domains().contains(&group_id)
}

/// Get the total number of multicast groups.
fn mc_groups_count(&self) -> AsicResult<usize>;

/// Set the maximum number of multicast nodes.
fn mc_set_max_nodes(
&self,
max_nodes: u32,
max_link_aggregated_nodes: u32,
) -> AsicResult<()>;

/// Get sidecar identifiers of the device being managed.
fn get_sidecar_identifiers(&self) -> AsicResult<impl SidecarIdentifiers>;

Expand Down
1 change: 1 addition & 0 deletions asic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ tofino_asic = [
tofino_stub = []
softnpu = ["softnpu-lib", "dep:propolis"]
chaos = []
multicast = ["aal/multicast"]

[lib]
# The genpd.rs code generated by bindgen causes the doctest to fail
Expand Down
Loading