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
2,502 changes: 1,259 additions & 1,243 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ camino = { version = "1.1", features = ["serde1"] }
cfg-if = "1"
chrono = "0.4"
colored = "2"
clap = { version = "4.5.8", features = [ "derive" ] }
csv = "1.3"
curl = "0.4"
display-error-chain = "0.2"
Expand Down Expand Up @@ -96,7 +97,6 @@ slog-async = "2.8"
slog-bunyan = "2.5"
slog-term = "2.9"
socket2 = { version = "0.6", features = ["all"] }
structopt = "0.3"
strum = { version = "0.26.3", features = [ "derive" ] }
syn = { version = "2.0", features = ["extra-traits"]}
tabwriter = { version = "1", features = ["ansi_formatting"] }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ Configuring a nat entry using `swadm`:
``` sh
$ ./target/release/swadm nat add \
-e 10.85.0.211 \
-h 65535 \
-H 65535 \
-m A8:40:25:F6:F9:94 \
-i fd00:1122:3344:101::1 \
-l 1024 \
Expand Down
2 changes: 1 addition & 1 deletion aal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "aal"
version = "0.1.0"
edition = "2021"
edition = "2024"

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

Expand Down
16 changes: 8 additions & 8 deletions aal/src/match_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,10 @@ impl TryFrom<&ValueTypes> for u32 {
fn try_from(v: &ValueTypes) -> Result<Self, Self::Error> {
let mask = (1u64 << 32) - 1;

if let ValueTypes::U64(v) = v {
if v & mask == *v {
return Ok((v & mask) as u32);
}
if let ValueTypes::U64(v) = v
&& v & mask == *v
{
return Ok((v & mask) as u32);
}

Err("value not 32 bits")
Expand All @@ -400,10 +400,10 @@ impl TryFrom<&ValueTypes> for u8 {
fn try_from(v: &ValueTypes) -> Result<Self, Self::Error> {
let mask = (1u64 << 8) - 1;

if let ValueTypes::U64(v) = v {
if v & mask == *v {
return Ok((v & mask) as u8);
}
if let ValueTypes::U64(v) = v
&& v & mask == *v
{
return Ok((v & mask) as u8);
}

Err("value not 8 bits")
Expand Down
2 changes: 1 addition & 1 deletion aal_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
version = "0.0.1"
name = "aal_macros"
edition = "2021"
edition = "2024"

[lib]
proc-macro = true
Expand Down
4 changes: 2 additions & 2 deletions aal_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ fn get_fields<'a>(
return Err(Error::new(
f.span(),
format!("unrecognized key type: {x}"),
))
));
}
},
};
Expand All @@ -391,7 +391,7 @@ fn get_fields<'a>(
}

// Parse all of the arguments to an action
fn get_action_args(variant: &Variant) -> Result<Vec<ActionArg>> {
fn get_action_args(variant: &Variant) -> Result<Vec<ActionArg<'_>>> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is weird. I guess it's because ActionArg contains Ident<'a>? I wonder why Ident has a lifetime. Hmm. Not for today.

let mut args = Vec::new();

let named = match variant.fields {
Expand Down
2 changes: 1 addition & 1 deletion asic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "asic"
version = "0.1.0"
edition = "2021"
edition = "2024"

[features]
tofino_asic = [
Expand Down
4 changes: 2 additions & 2 deletions asic/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn sde_prep() -> Result<()> {
let sde_dir =
env::var("SDE").with_context(|| "failed to get SDE env var")?;

env::set_var("CFLAGS", format!("-I{sde_dir}/include"));
unsafe { env::set_var("CFLAGS", format!("-I{sde_dir}/include")) };

println!("cargo:rerun-if-changed={TOFINO_DIR}/{FN_FILE}");
println!("cargo:rerun-if-changed={TOFINO_DIR}/{TYPE_FILE}");
Expand All @@ -121,7 +121,7 @@ fn sde_prep() -> Result<()> {

fn main() -> Result<()> {
#[cfg(target_os = "illumos")]
{
unsafe {
env::set_var("AR", "/usr/bin/gar");
env::set_var("LIBCLANG_PATH", "/opt/ooce/llvm/lib");
}
Expand Down
12 changes: 6 additions & 6 deletions asic/src/chaos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ use aal::{
};
use common::ports::{PortFec, PortId, PortMedia, PortPrbsMode, PortSpeed};

use crate::Identifiers;
pub use crate::faux_fsm::FsmState;
pub use crate::faux_fsm::PortFsmState;
use crate::Identifiers;

pub mod table;

Expand Down Expand Up @@ -117,11 +117,11 @@ impl TableChaos {
id: &str,
message: &str,
) -> AsicResult<()> {
if let Some(value) = self.values.get(id) {
if *value >= random() {
slog::error!(log, "chaos table error: {}", message);
return Err(AsicError::Synthetic(message.into()));
}
if let Some(value) = self.values.get(id)
&& *value >= random()
{
slog::error!(log, "chaos table error: {}", message);
return Err(AsicError::Synthetic(message.into()));
}
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions asic/src/chaos/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
//
// Copyright 2025 Oxide Computer Company

use std::collections::hash_map::DefaultHasher;
use std::collections::HashSet;
use std::collections::hash_map::DefaultHasher;
use std::hash::Hash;
use std::hash::Hasher;
use std::sync::Mutex;

use crate::chaos::{table_unfurl, Handle};
use crate::chaos::{Handle, table_unfurl};
use aal::{
ActionParse, AsicError, AsicResult, CounterData, MatchParse, TableOps,
};
Expand Down
10 changes: 5 additions & 5 deletions asic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,44 +127,44 @@ pub mod tofino_asic;

#[cfg(feature = "tofino_asic")]
mod plat {
pub use super::tofino_asic::stats::AsicLinkStats;
pub use super::tofino_asic::table::Table;
pub use super::tofino_asic::FsmState;
pub use super::tofino_asic::Handle;
pub use super::tofino_asic::PortFsmState;
pub use super::tofino_asic::stats::AsicLinkStats;
pub use super::tofino_asic::table::Table;
}

#[cfg(feature = "tofino_stub")]
pub mod tofino_stub;
#[cfg(feature = "tofino_stub")]
mod plat {
pub use super::tofino_stub::table::Table;
pub use super::tofino_stub::AsicLinkStats;
pub use super::tofino_stub::FsmState;
pub use super::tofino_stub::PortFsmState;
pub use super::tofino_stub::StubHandle as Handle;
pub use super::tofino_stub::table::Table;
}

#[cfg(feature = "softnpu")]
pub mod softnpu;
#[cfg(feature = "softnpu")]
mod plat {
pub use super::softnpu::table::Table;
pub use super::softnpu::AsicLinkStats;
pub use super::softnpu::FsmState;
pub use super::softnpu::Handle;
pub use super::softnpu::PortFsmState;
pub use super::softnpu::table::Table;
}

#[cfg(feature = "chaos")]
pub mod chaos;
#[cfg(feature = "chaos")]
mod plat {
pub use super::chaos::table::Table;
pub use super::chaos::AsicLinkStats;
pub use super::chaos::FsmState;
pub use super::chaos::Handle;
pub use super::chaos::PortFsmState;
pub use super::chaos::table::Table;
}

pub use plat::AsicLinkStats;
Expand Down
18 changes: 9 additions & 9 deletions asic/src/softnpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
use std::collections::HashMap;
use std::sync::Mutex;

use slog::{o, Logger};
use slog::{Logger, o};
use tokio::sync::mpsc;
use uuid::Uuid;

use crate::Identifiers;
pub use crate::faux_fsm::FsmState;
pub use crate::faux_fsm::FsmType;
pub use crate::faux_fsm::PortFsmState;
use crate::Identifiers;

use aal::{
AsicError, AsicId, AsicOps, AsicResult, Connector, PortHdl, PortUpdate,
Expand Down Expand Up @@ -118,7 +118,7 @@ impl Handle {
None => {
return Err(AsicError::InvalidArg(
"softnpu unix domain socket missing".to_string(),
))
));
}
},
};
Expand Down Expand Up @@ -279,12 +279,12 @@ impl AsicOps for Handle {
_speed: PortSpeed,
_fec: PortFec,
) -> AsicResult<(PortHdl, u16)> {
if let Some(link_id) = lane {
if link_id > 0 {
return Err(AsicError::InvalidArg(
"softnpu only supports lane 0".into(),
));
}
if let Some(link_id) = lane
&& link_id > 0
{
return Err(AsicError::InvalidArg(
"softnpu only supports lane 0".into(),
));
}
let mut ports = self.ports.lock().unwrap();
// Each switch port / connector only supports a single channel, and so a
Expand Down
30 changes: 24 additions & 6 deletions asic/src/softnpu/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ impl TableOps<Handle> for Table {
params.extend_from_slice(&v.to_le_bytes());
}
x => {
error!(hdl.log, "unexpected parameter: {dpd_table}::index {x}")
error!(
hdl.log,
"unexpected parameter: {dpd_table}::index {x}"
)
}
}
}
Expand Down Expand Up @@ -185,7 +188,10 @@ impl TableOps<Handle> for Table {
);
}
x => {
error!(hdl.log, "unexpected parameter: {dpd_table}::forward {x}")
error!(
hdl.log,
"unexpected parameter: {dpd_table}::forward {x}"
)
}
}
}
Expand Down Expand Up @@ -221,7 +227,10 @@ impl TableOps<Handle> for Table {
);
}
x => {
error!(hdl.log, "unexpected parameter: {dpd_table}::forward_vlan {x}")
error!(
hdl.log,
"unexpected parameter: {dpd_table}::forward_vlan {x}"
)
}
}
}
Expand Down Expand Up @@ -249,7 +258,10 @@ impl TableOps<Handle> for Table {
params.extend_from_slice(&v.to_le_bytes());
}
x => {
error!(hdl.log, "unexpected parameter: {dpd_table}::index {x}")
error!(
hdl.log,
"unexpected parameter: {dpd_table}::index {x}"
)
}
}
}
Expand All @@ -273,7 +285,10 @@ impl TableOps<Handle> for Table {
);
}
x => {
error!(hdl.log, "unexpected parameter: {dpd_table}::forward {x}")
error!(
hdl.log,
"unexpected parameter: {dpd_table}::forward {x}"
)
}
}
}
Expand Down Expand Up @@ -305,7 +320,10 @@ impl TableOps<Handle> for Table {
);
}
x => {
error!(hdl.log, "unexpected parameter: {dpd_table}::forward_vlan {x}")
error!(
hdl.log,
"unexpected parameter: {dpd_table}::forward_vlan {x}"
)
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions asic/src/tofino_asic/bf_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use tokio::sync::mpsc;
use aal::{AsicError, AsicResult, PortUpdate};

use crate::tofino_asic::genpd::*;
use crate::tofino_asic::{bf_status_t, CheckError, TofinoFamily};
use crate::tofino_asic::{CheckError, TofinoFamily, bf_status_t};

// State needed to allow callbacks from the SDE to communicate with the
// mainline dpd code.
Expand Down Expand Up @@ -190,7 +190,7 @@ pub(crate) fn send_port_update(callback: &str, update: PortUpdate) {
// callback will generally be a no-op. The only exception would be if somebody
// were using the bf cli to manipulate ports, at which point all bets are off as
// to what's happening with the port.
Copy link
Collaborator

Choose a reason for hiding this comment

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

really? Huh.

#[no_mangle]
#[unsafe(no_mangle)]
extern "C" fn port_admin_state_cb(
dev_id: bf_dev_id_t,
port: bf_dev_port_t,
Expand All @@ -214,7 +214,7 @@ extern "C" fn port_admin_state_cb(
}

// Called whenever a port's link state changes between up and down.
#[no_mangle]
#[unsafe(no_mangle)]
extern "C" fn port_status_int_cb(
dev_id: bf_dev_id_t,
port: bf_dev_port_t,
Expand All @@ -238,7 +238,7 @@ extern "C" fn port_status_int_cb(
}

// Called whenever a port's presence-detect bit changes
#[no_mangle]
#[unsafe(no_mangle)]
extern "C" fn port_presence_cb(
dev_id: bf_dev_id_t,
port: bf_dev_port_t,
Expand Down Expand Up @@ -270,7 +270,7 @@ static mut TOFINO_FAMILY: Option<TofinoFamily> = None;
// This gets called when a tofino device is added to the bf_switchd
// infrastructure in the SDE. This should happen exactly once, when we call
// bf_drv_init() below. We take this opportunity to do some basic sanity tests.
#[no_mangle]
#[unsafe(no_mangle)]
extern "C" fn device_add_cb(
dev_id: bf_dev_id_t,
dev_family: bf_dev_family_t,
Expand Down Expand Up @@ -329,7 +329,7 @@ pub fn register_handler(
None => Err(AsicError::Uninitialized(
"register_handler() called with no callback state".into(),
)),
Some(ref mut cb) => {
Some(cb) => {
cb.update_tx = Some(update_tx);
Ok(())
}
Expand Down Expand Up @@ -406,7 +406,7 @@ pub fn bf_init(
return Err(crate::tofino_asic::sde_error(
"initializing bf context",
rval,
))
));
}
}
};
Expand Down
Loading