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
1 change: 1 addition & 0 deletions crates/bmc-mock/src/hw/bluefield3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ impl Bluefield3<'_> {
},
})),
storage: None,
processors: None,
secure_boot_available: true,
}],
}
Expand Down
1 change: 1 addition & 0 deletions crates/bmc-mock/src/hw/dell_poweredge_r750.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ impl DellPowerEdgeR750<'_> {
// there. So we provide empty collection to avoid 404
// failure.
storage: Some(vec![]),
processors: None,
secure_boot_available: true,
base_bios: Some(redfish::bios::builder(&redfish::bios::resource(system_id))
.attributes(json!({
Expand Down
2 changes: 2 additions & 0 deletions crates/bmc-mock/src/hw/dgx_gb300_nvl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ impl DgxGB300Nvl<'_> {
secure_boot_available: false,
serial_number: Some(self.hgx_serial_number.to_string().into()),
storage: None,
processors: None,
},
redfish::computer_system::SingleSystemConfig {
base_bios: Some(base_bios(system_id)),
Expand All @@ -190,6 +191,7 @@ impl DgxGB300Nvl<'_> {
secure_boot_available: true,
serial_number: Some(self.system_0_serial_number.to_string().into()),
storage: None,
processors: None,
},
],
}
Expand Down
1 change: 1 addition & 0 deletions crates/bmc-mock/src/hw/generic_ami.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl GenericAmi<'_> {
oem: redfish::computer_system::Oem::Generic,
log_services: None,
storage: None,
processors: None,
base_bios: Some(
redfish::bios::builder(&redfish::bios::resource(system_id))
.attributes(json!({"EndlessBoot":""}))
Expand Down
2 changes: 2 additions & 0 deletions crates/bmc-mock/src/hw/lenovo_gb300_nvl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ impl LenovoGB300Nvl<'_> {
secure_boot_available: false,
serial_number: Some(self.hgx_serial_number.to_string().into()),
storage: None,
processors: None,
},
redfish::computer_system::SingleSystemConfig {
base_bios: Some(base_bios(system_id)),
Expand All @@ -195,6 +196,7 @@ impl LenovoGB300Nvl<'_> {
secure_boot_available: true,
serial_number: Some(self.system_0_serial_number.to_string().into()),
storage: None,
processors: None,
},
],
}
Expand Down
1 change: 1 addition & 0 deletions crates/bmc-mock/src/hw/liteon_power_shelf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl LiteOnPowerShelf<'_> {
oem: redfish::computer_system::Oem::Generic,
log_services: None,
storage: None,
processors: None,
base_bios: Some(
redfish::bios::builder(&redfish::bios::resource(system_id)).build(),
),
Expand Down
2 changes: 2 additions & 0 deletions crates/bmc-mock/src/hw/nvidia_dgx_h100.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ impl NvidiaDgxH100<'_> {
base_bios: Some(base_bios(system_id)),
log_services: None,
storage: None,
processors: None,
secure_boot_available: true,
},
redfish::computer_system::SingleSystemConfig {
Expand All @@ -202,6 +203,7 @@ impl NvidiaDgxH100<'_> {
base_bios: None,
log_services: None,
storage: None,
processors: None,
secure_boot_available: false,
},
],
Expand Down
39 changes: 34 additions & 5 deletions crates/bmc-mock/src/hw/nvidia_gb200.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,40 @@ impl BiancaBoard<'_> {
}
}

pub fn hgx_gpu_chassis(
&self,
ids: [GpuChassisIds; 2],
) -> [redfish::chassis::SingleChassisConfig; 2] {
ids.map(|ids| {
fn gpu_base_index(&self) -> usize {
match self.index {
BoardIndex::Board0 => 0,
BoardIndex::Board1 => 2,
}
}

pub fn gpu_chassis_ids(&self) -> [GpuChassisIds; 2] {
let base = self.gpu_base_index();
[0, 1].map(|local| {
let n = base + local;
GpuChassisIds {
chassis_id: format!("HGX_GPU_{n}").into(),
pcie_device_id: format!("GPU_{n}").into(),
}
})
}

pub fn hgx_gpu_processors(&self, system_id: &str) -> [redfish::processor::Processor; 2] {
self.gpu_chassis_ids().map(|ids| {
let voltage_sensor_id =
redfish::sensor::sensor_id(redfish::sensor::SensorKind::Voltage, 1);
redfish::processor::gpu(
system_id,
&ids.pcie_device_id,
redfish::sensor::chassis_resource(&ids.chassis_id, &voltage_sensor_id)
.odata_id
.as_ref(),
)
})
}

pub fn hgx_gpu_chassis(&self) -> [redfish::chassis::SingleChassisConfig; 2] {
self.gpu_chassis_ids().map(|ids| {
let sensors = redfish::sensor::generate_chassis_sensors(
&ids.chassis_id,
redfish::sensor::Layout {
Expand Down
1 change: 1 addition & 0 deletions crates/bmc-mock/src/hw/nvidia_switch_nd5200_ld.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ impl NvidiaSwitchNd5200Ld<'_> {
oem: redfish::computer_system::Oem::Generic,
log_services: None,
storage: Some(vec![]),
processors: None,
base_bios: None,
secure_boot_available: false,
}],
Expand Down
2 changes: 2 additions & 0 deletions crates/bmc-mock/src/hw/supermicro_gb300_nvl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ impl SupermicroGB300Nvl<'_> {
secure_boot_available: false,
serial_number: Some(self.hgx_serial_number.to_string().into()),
storage: None,
processors: None,
},
redfish::computer_system::SingleSystemConfig {
base_bios: Some(base_bios(system_id)),
Expand All @@ -191,6 +192,7 @@ impl SupermicroGB300Nvl<'_> {
secure_boot_available: true,
serial_number: Some(self.system_0_serial_number.to_string().into()),
storage: None,
processors: None,
},
],
}
Expand Down
44 changes: 13 additions & 31 deletions crates/bmc-mock/src/hw/wiwynn_gb200_nvl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ impl WiwynnGB200Nvl<'_> {
.build()
})).collect();

let hgx_baseboard_id = "HGX_Baseboard_0";

redfish::computer_system::Config {
systems: vec![
redfish::computer_system::SingleSystemConfig {
Expand All @@ -117,10 +119,11 @@ impl WiwynnGB200Nvl<'_> {
),
log_services: None,
storage: None,
processors: None,
secure_boot_available: true,
},
redfish::computer_system::SingleSystemConfig {
id: "HGX_Baseboard_0".into(),
id: hgx_baseboard_id.into(),
manufacturer: Some("NVIDIA".into()),
model: Some("GB200 NVL".into()),
chassis: vec!["HGX_Chassis_0".into()],
Expand All @@ -134,6 +137,12 @@ impl WiwynnGB200Nvl<'_> {
base_bios: None,
log_services: None,
storage: None,
processors: Some(
self.compute_board
.iter()
.flat_map(|board| board.hgx_gpu_processors(hgx_baseboard_id))
.collect(),
),
secure_boot_available: false,
},
],
Expand Down Expand Up @@ -203,36 +212,9 @@ impl WiwynnGB200Nvl<'_> {
.map(|(index, id)| self.compute_board[index].hgx_cpu_chassis(id.into())),
)
.chain(
[
(
0,
[
hw::nvidia_gb200::GpuChassisIds {
chassis_id: "HGX_GPU_0".into(),
pcie_device_id: "GPU_0".into(),
},
hw::nvidia_gb200::GpuChassisIds {
chassis_id: "HGX_GPU_1".into(),
pcie_device_id: "GPU_1".into(),
},
],
),
(
1,
[
hw::nvidia_gb200::GpuChassisIds {
chassis_id: "HGX_GPU_2".into(),
pcie_device_id: "GPU_2".into(),
},
hw::nvidia_gb200::GpuChassisIds {
chassis_id: "HGX_GPU_3".into(),
pcie_device_id: "GPU_3".into(),
},
],
),
]
.into_iter()
.flat_map(|(index, ids)| self.compute_board[index].hgx_gpu_chassis(ids)),
self.compute_board
.iter()
.flat_map(|board| board.hgx_gpu_chassis()),
)
.chain(
self.io_board
Expand Down
78 changes: 78 additions & 0 deletions crates/bmc-mock/src/redfish/computer_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub fn add_routes(r: Router<BmcState>, bmc_vendor: redfish::oem::BmcVendor) -> R
const ETH_ID: &str = "{eth_id}";
const BOOT_OPTION_ID: &str = "{boot_option_id}";
const LOG_SERVICE_ID: &str = "{log_service_id}";
const PROCESSOR_ID: &str = "{processor_id}";
let bios = redfish::bios::resource(SYSTEM_ID);
r.route(&collection().odata_id, get(get_system_collection))
.route(
Expand Down Expand Up @@ -112,6 +113,18 @@ pub fn add_routes(r: Router<BmcState>, bmc_vendor: redfish::oem::BmcVendor) -> R
&redfish::storage::system_collection(SYSTEM_ID).odata_id,
get(get_storage_collection),
)
.route(
&redfish::processor::system_collection(SYSTEM_ID).odata_id,
get(get_processors_collection),
)
.route(
&redfish::processor::system_resource(SYSTEM_ID, PROCESSOR_ID).odata_id,
get(get_processor),
)
.route(
&redfish::processor::metrics_resource(SYSTEM_ID, PROCESSOR_ID).odata_id,
get(get_processor_metrics),
)
.route(
&bmc_vendor.make_settings_odata_id(&bios),
patch(patch_bios_settings),
Expand All @@ -136,6 +149,7 @@ pub struct SingleSystemConfig {
pub base_bios: Option<serde_json::Value>,
pub log_services: Option<Arc<dyn LogServices>>,
pub storage: Option<Vec<redfish::storage::Storage>>,
pub processors: Option<Vec<redfish::processor::Processor>>,
pub secure_boot_available: bool,
pub oem: Oem,
}
Expand Down Expand Up @@ -231,6 +245,14 @@ impl SingleSystemState {
}
}

fn find_processor(&self, processor_id: &str) -> Option<&redfish::processor::Processor> {
self.config
.processors
.iter()
.flatten()
.find(|processor| processor.id == processor_id)
}

pub fn find_boot_option(&self, option_id: &str) -> Option<&redfish::boot_option::BootOption> {
self.config
.boot_options
Expand Down Expand Up @@ -369,6 +391,11 @@ async fn get_system(State(state): State<BmcState>, Path(system_id): Path<String>
.is_some()
.then_some(redfish::storage::system_collection(&system_id));

let processors = config
.processors
.is_some()
.then_some(redfish::processor::system_collection(&system_id));

let secure_boot = config
.secure_boot_available
.then_some(redfish::secure_boot::resource(&system_id));
Expand All @@ -381,6 +408,7 @@ async fn get_system(State(state): State<BmcState>, Path(system_id): Path<String>
.maybe_with(SystemBuilder::ethernet_interfaces, &ethernet_interfaces)
.maybe_with(SystemBuilder::log_services, &log_services)
.maybe_with(SystemBuilder::storage, &storage)
.maybe_with(SystemBuilder::processors, &processors)
.maybe_with(SystemBuilder::secure_boot, &secure_boot)
.pcie_devices(&pcie_devices)
.build()
Expand Down Expand Up @@ -719,6 +747,52 @@ async fn get_storage_collection(
.unwrap_or_else(http::not_found)
}

async fn get_processors_collection(
State(state): State<BmcState>,
Path(system_id): Path<String>,
) -> Response {
state
.system_state
.find(&system_id)
.and_then(|system_state| system_state.config.processors.as_ref())
.map(|processors| {
let members = processors
.iter()
.map(|processor| {
redfish::processor::system_resource(&system_id, &processor.id).entity_ref()
})
.collect::<Vec<_>>();
redfish::processor::system_collection(&system_id)
.with_members(&members)
.into_ok_response()
})
.unwrap_or_else(http::not_found)
}

async fn get_processor(
State(state): State<BmcState>,
Path((system_id, processor_id)): Path<(String, String)>,
) -> Response {
state
.system_state
.find(&system_id)
.and_then(|system_state| system_state.find_processor(&processor_id))
.map(|processor| processor.to_json().into_ok_response())
.unwrap_or_else(http::not_found)
}

async fn get_processor_metrics(
State(state): State<BmcState>,
Path((system_id, processor_id)): Path<(String, String)>,
) -> Response {
state
.system_state
.find(&system_id)
.and_then(|system_state| system_state.find_processor(&processor_id))
.map(|processor| processor.metrics_json().into_ok_response())
.unwrap_or_else(http::not_found)
}

async fn get_bios(State(state): State<BmcState>, Path(system_id): Path<String>) -> Response {
state
.system_state
Expand Down Expand Up @@ -865,6 +939,10 @@ impl SystemBuilder {
self.apply_patch(storage.nav_property("Storage"))
}

pub fn processors(self, processors: &redfish::Collection<'_>) -> Self {
self.apply_patch(processors.nav_property("Processors"))
}

pub fn link_chassis(self, ids: &[Cow<'static, str>]) -> Self {
let chassis = ids
.iter()
Expand Down
1 change: 1 addition & 0 deletions crates/bmc-mock/src/redfish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub mod oem;
pub mod pcie_device;
pub mod power_subsystem;
pub mod power_supply;
pub mod processor;
pub mod resource;
pub mod secure_boot;
pub mod sensor;
Expand Down
Loading
Loading