Skip to content
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
121 changes: 104 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ omicron-common = { git = "https://github.com/oxidecomputer/omicron", branch= "ma
oximeter = { git = "https://github.com/oxidecomputer/omicron", branch = "main" }
oximeter-producer = { git = "https://github.com/oxidecomputer/omicron", branch = "main" }
oximeter-instruments = { git = "https://github.com/oxidecomputer/omicron", branch = "main", default-features = false, features = ["kstat"] }
oxnet = { version = "0.1.6", default-features = false, features = ["schemars", "serde"] }
oxnet = { version = "0.1.7", default-features = false, features = ["schemars", "serde"] }
propolis = { git = "https://github.com/oxidecomputer/propolis" }
smf = { git = "https://github.com/illumos/smf-rs" }
slog-error-chain = { git = "https://github.com/oxidecomputer/slog-error-chain", branch = "main" }
Expand Down
24 changes: 23 additions & 1 deletion asic/src/chaos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize};
use slog::Logger;
use std::collections::HashMap;
use std::sync::Mutex;
use std::sync::OnceLock;
use tokio::sync::mpsc;

#[cfg(feature = "multicast")]
Expand Down Expand Up @@ -344,6 +345,7 @@ pub struct Handle {
ports: Mutex<HashMap<PortHdl, Port>>,
config: AsicConfig,
log: Logger,
updates: OnceLock<mpsc::UnboundedSender<PortUpdate>>,
}

impl Handle {
Expand All @@ -353,6 +355,7 @@ impl Handle {
ports: Mutex::new(HashMap::new()),
config: config.clone(),
log: log.clone(),
updates: OnceLock::new(),
})
}
/// Chaos ASICs always report as a model.
Expand Down Expand Up @@ -494,6 +497,22 @@ impl AsicOps for Handle {
unfurl!(self, port_enable_set);
let mut ports = self.ports.lock().unwrap();
get_port_mut(&mut ports, port_hdl)?.enabled = val;

let Some(chan) = self.updates.get() else {
return Ok(());
};

let asic_port_id = self.port_to_asic_id(port_hdl)?;
let r1 = chan.send(PortUpdate::Enable { asic_port_id, enabled: val });
let r2 = chan.send(PortUpdate::LinkUp { asic_port_id, linkup: val });

if r1.is_err() || r2.is_err() {
return Err(AsicError::Internal(
"PortUpdate tx failed. That rx chan should never be dropped."
.to_string(),
));
}

Ok(())
}

Expand Down Expand Up @@ -579,9 +598,12 @@ impl AsicOps for Handle {

fn register_port_update_handler(
&self,
_tx_channel: mpsc::UnboundedSender<PortUpdate>,
tx_channel: mpsc::UnboundedSender<PortUpdate>,
) -> AsicResult<()> {
unfurl!(self, register_port_update_handler);
if self.updates.set(tx_channel).is_err() {
return Err(AsicError::Exists);
}
Ok(())
}

Expand Down
1 change: 1 addition & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2024"

[features]
multicast = []
test-utils = []

[dependencies]
anyhow.workspace = true
Expand Down
Loading
Loading