Skip to content

Commit

Permalink
Initial SP inventory reporting to MGS (oxidecomputer#868)
Browse files Browse the repository at this point in the history
* Update sidecar/psc builds with `validate` task
  • Loading branch information
jgallagher authored Oct 25, 2022
1 parent 342a27d commit e4a3af0
Show file tree
Hide file tree
Showing 19 changed files with 506 additions and 26 deletions.
5 changes: 4 additions & 1 deletion Cargo.lock

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

10 changes: 9 additions & 1 deletion app/gimlet/rev-b.toml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,15 @@ uses = [
"usart1",
"system_flash", # TODO also used by `net`, both to read the stm32 uid
]
task-slots = ["jefe", "net", "update_server", "sys", "hf", "gimlet_seq"]
task-slots = [
"jefe",
"net",
"update_server",
"sys",
"hf",
"gimlet_seq",
"validate",
]
features = ["gimlet", "usart1", "vlan", "baud_rate_3M", "hardware_flow_control"]
interrupts = {"usart1.irq" = 0b10}

Expand Down
10 changes: 9 additions & 1 deletion app/gimlet/rev-c.toml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,15 @@ uses = [
"usart1",
"system_flash", # TODO also used by `net`, both to read the stm32 uid
]
task-slots = ["jefe", "net", "update_server", "sys", "hf", "gimlet_seq"]
task-slots = [
"jefe",
"net",
"update_server",
"sys",
"hf",
"gimlet_seq",
"validate",
]
features = ["gimlet", "usart1", "vlan", "baud_rate_3M", "hardware_flow_control"]
interrupts = {"usart1.irq" = 0b10}

Expand Down
10 changes: 9 additions & 1 deletion app/gimletlet/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,15 @@ uses = [
"usart1",
"system_flash", # TODO also used by `net`, both to read the stm32 uid
]
task-slots = ["jefe", "net", "update_server", "sys", "hf", "gimlet_seq"]
task-slots = [
"jefe",
"net",
"update_server",
"sys",
"hf",
"gimlet_seq",
"validate",
]
features = ["gimlet", "usart1", "vlan", "baud_rate_3M", "hardware_flow_control"]
interrupts = {"usart1.irq" = 0b10}

Expand Down
18 changes: 16 additions & 2 deletions app/psc/rev-a.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ stacksize = 896

[kernel]
name = "psc"
requires = {flash = 32768, ram = 4096}
requires = {flash = 32768, ram = 4176}
#
# For the kernel (and for any task that logs), we are required to enable
# either "itm" (denoting logging/panicking via ARM's Instrumentation Trace
Expand Down Expand Up @@ -103,6 +103,14 @@ stacksize = 1024
start = true
task-slots = ["sys", "i2c_driver"]

[tasks.validate]
name = "task-validate"
priority = 3
max-sizes = {flash = 16384, ram = 4096 }
stacksize = 1000
start = true
task-slots = ["i2c_driver"]

[tasks.net]
name = "task-net"
stacksize = 4640
Expand All @@ -124,7 +132,13 @@ start = true
uses = [
"system_flash", # TODO also used by `net`, both to read the stm32 uid
]
task-slots = ["jefe", "net", "update_server", "sys"]
task-slots = [
"jefe",
"net",
"update_server",
"sys",
"validate",
]
features = ["psc", "vlan"]

[tasks.udpecho]
Expand Down
18 changes: 16 additions & 2 deletions app/psc/rev-b.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ stacksize = 896

[kernel]
name = "psc"
requires = {flash = 32768, ram = 4096}
requires = {flash = 32768, ram = 4176}
#
# For the kernel (and for any task that logs), we are required to enable
# either "itm" (denoting logging/panicking via ARM's Instrumentation Trace
Expand Down Expand Up @@ -101,6 +101,14 @@ stacksize = 1024
start = true
task-slots = ["sys", "i2c_driver"]

[tasks.validate]
name = "task-validate"
priority = 3
max-sizes = {flash = 16384, ram = 4096 }
stacksize = 1000
start = true
task-slots = ["i2c_driver"]

[tasks.net]
name = "task-net"
stacksize = 4640
Expand All @@ -122,7 +130,13 @@ start = true
uses = [
"system_flash", # TODO also used by `net`, both to read the stm32 uid
]
task-slots = ["jefe", "net", "update_server", "sys"]
task-slots = [
"jefe",
"net",
"update_server",
"sys",
"validate",
]
features = ["psc", "vlan"]

[tasks.udpecho]
Expand Down
12 changes: 10 additions & 2 deletions app/sidecar/rev-a.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,21 @@ task-slots = ["sys",
[tasks.control_plane_agent]
name = "task-control-plane-agent"
priority = 6
max-sizes = {flash = 32768, ram = 8192}
max-sizes = {flash = 65536, ram = 8192}
stacksize = 2048
start = true
uses = [
"system_flash", # TODO also used by `net`, both to read the stm32 uid
]
task-slots = ["jefe", "net", "update_server", "sys", "sequencer", "auxflash"]
task-slots = [
"jefe",
"net",
"update_server",
"sys",
"sequencer",
"auxflash",
"validate",
]
features = ["sidecar", "vlan", "auxflash"]

[tasks.udpecho]
Expand Down
12 changes: 10 additions & 2 deletions app/sidecar/rev-b.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,21 @@ task-slots = ["sys",
[tasks.control_plane_agent]
name = "task-control-plane-agent"
priority = 6
max-sizes = {flash = 32768, ram = 8192}
max-sizes = {flash = 65536, ram = 8192}
stacksize = 2048
start = true
uses = [
"system_flash", # TODO also used by `net`, both to read the stm32 uid
]
task-slots = ["jefe", "net", "update_server", "sys", "sequencer", "auxflash"]
task-slots = [
"jefe",
"net",
"update_server",
"sys",
"sequencer",
"auxflash",
"validate",
]
features = ["sidecar", "vlan", "auxflash"]

[tasks.udpecho]
Expand Down
36 changes: 36 additions & 0 deletions build/i2c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ struct I2cSensors {
names: Option<Vec<String>>,
}

impl I2cSensors {
fn num_sensors(&self) -> usize {
self.temperature + self.power + self.current + self.voltage + self.speed
}
}

#[derive(Copy, Clone, Eq, PartialEq)]
pub enum Disposition {
/// controller is an initiator
Expand Down Expand Up @@ -871,6 +877,9 @@ impl ConfigGenerator {
match index {{"##
)?;

// The ordering / index values of this `match` must match the ordering
// returned by `device_descriptions()` below: if we change the ordering
// here, it must be updated there as well.
for (index, device) in self.devices.iter().enumerate() {
if drivers.get(&device.device).is_some() {
let driver = device.device.to_case(Case::UpperCamel);
Expand Down Expand Up @@ -1217,3 +1226,30 @@ pub fn codegen(disposition: Disposition) -> Result<()> {

Ok(())
}

pub struct I2cDeviceDescription {
pub device: String,
pub description: String,
pub num_measurement_channels: usize,
}

///
/// Returns a list of I2C device descriptions.
///
/// The order of device descriptions matches the indexing used in the generated
/// `validate()` command.
///
pub fn device_descriptions() -> impl Iterator<Item = I2cDeviceDescription> {
let g = ConfigGenerator::new(Disposition::Validation);

// Matches the ordering of the `match` produced by `generate_validation()`
// above; if we change the order here, it must change there as well.
g.devices.into_iter().map(|device| I2cDeviceDescription {
device: device.device,
description: device.description,
num_measurement_channels: device
.sensors
.as_ref()
.map_or(0, I2cSensors::num_sensors),
})
}
3 changes: 2 additions & 1 deletion task/control-plane-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ mutable-statics = {path = "../../lib/mutable-statics"}
ringbuf = {path = "../../lib/ringbuf"}
task-jefe-api = {path = "../jefe-api"}
task-net-api = {path = "../net-api", features = ["use-smoltcp"]}
task-validate-api = {path = "../validate-api"}
userlib = {path = "../../sys/userlib", features = ["panic-messages"]}
update-buffer = {path = "../../lib/update-buffer"}

gateway-messages = {git = "https://github.com/oxidecomputer/management-gateway-service", rev = "90a4a944d35b7250b4ab468b31ae88deaf34ff78"}
gateway-messages = {git = "https://github.com/oxidecomputer/management-gateway-service", rev = "c1484109c394f45e08018e0f35adc4a136cd207d"}

[features]
gimlet = ["drv-gimlet-hf-api", "drv-gimlet-seq-api", "drv-stm32h7-usart"]
Expand Down
Loading

0 comments on commit e4a3af0

Please sign in to comment.