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
32 changes: 17 additions & 15 deletions Cargo.lock

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

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,10 @@ gateway-client = { path = "clients/gateway-client" }
# is "fine", because SP/MGS communication maintains forwards and backwards
# compatibility, but will mean that faux-mgs might be missing new
# functionality.)
gateway-ereport-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "01f06089a97bd084bec2595d4d62e0f91338cf57", default-features = false, features = ["debug-impls"] }
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "01f06089a97bd084bec2595d4d62e0f91338cf57", default-features = false, features = ["std"] }
gateway-sp-comms = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "01f06089a97bd084bec2595d4d62e0f91338cf57" }
#
gateway-ereport-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "438cd185666d5f164548885873f0f5df9a38eed1", default-features = false, features = ["debug-impls"] }
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "438cd185666d5f164548885873f0f5df9a38eed1", default-features = false, features = ["std"] }
gateway-sp-comms = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "438cd185666d5f164548885873f0f5df9a38eed1" }
gateway-test-utils = { path = "gateway-test-utils" }
gateway-types = { path = "gateway-types" }
gateway-types-versions = { path = "gateway-types/versions" }
Expand Down
7 changes: 7 additions & 0 deletions clients/gateway-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@ progenitor::generate_api!(
},

replace = {
Barcode = gateway_types::component_vpd::Barcode,
ComponentVpd = gateway_types::component_vpd::ComponentVpd,
Mpn1Barcode = gateway_types::component_vpd::Mpn1Barcode,
OxideBarcode = gateway_types::component_vpd::OxideBarcode,
PmbusDevice = gateway_types::component_vpd::PmbusDevice,
RotSlot = gateway_types::rot::RotSlot,
SledFanTray = gateway_types::component_vpd::SledFanTray,
Tmp11x = gateway_types::component_vpd::Tmp11x,
RotState = gateway_types::rot::RotState,
RotImageError = gateway_types::rot::RotImageError,
Ena = ereport_types::Ena,
Expand Down
16 changes: 16 additions & 0 deletions gateway-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ api_versions!([
// | example for the next person.
// v
// (next_int, IDENT),
(4, COMPONENT_VPD),
(3, NEWTYPE_UUID_BUMP),
(2, COSMO),
(1, INITIAL),
Expand Down Expand Up @@ -334,6 +335,21 @@ pub trait GatewayApi {
body: TypedBody<latest::update::UpdateAbortBody>,
) -> Result<HttpResponseUpdatedNoContent, HttpError>;

/// Get the vital product data (VPD) identity of a component.
///
/// Not all components have VPD. This endpoint will return an error if the
/// requested component does not advertise the `HAS_VPD` DeviceCapability
/// bit.
#[endpoint {
method = GET,
path = "/sp/{type}/{slot}/component/{component}/vpd",
versions = VERSION_COMPONENT_VPD..,
}]
async fn sp_component_vpd_get(
rqctx: RequestContext<Self::Context>,
path: Path<latest::component::PathSpComponent>,
) -> Result<HttpResponseOk<latest::component_vpd::ComponentVpd>, HttpError>;

/// Read the CMPA from a root of trust.
///
/// This endpoint is only valid for the `rot` component.
Expand Down
5 changes: 5 additions & 0 deletions gateway-types/src/component_vpd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

pub use gateway_types_versions::latest::component_vpd::*;
1 change: 1 addition & 0 deletions gateway-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
pub mod caboose;
pub mod component;
pub mod component_details;
pub mod component_vpd;
pub mod host;
pub mod ignition;
pub mod rot;
Expand Down
152 changes: 152 additions & 0 deletions gateway-types/versions/src/component_vpd/component_vpd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Deserialize,
Serialize,
JsonSchema,
)]
#[serde(tag = "type", rename_all = "snake_case")]
#[allow(clippy::large_enum_variant)]
pub enum ComponentVpd {
OxideBarcode(OxideBarcode),
Mpn1Barcode(Mpn1Barcode),
SledFanTray(SledFanTray),
Tmp11x(Tmp11x),
Pmbus(PmbusDevice),
}

#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Deserialize,
Serialize,
JsonSchema,
)]
pub struct OxideBarcode {
pub part_number: String,
pub revision: u32,
pub serial_number: String,
}

#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Deserialize,
Serialize,
JsonSchema,
)]
pub struct Mpn1Barcode {
pub manufacturer: String,
pub part_number: String,
pub revision: String,
pub serial_number: String,
}

#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Deserialize,
Serialize,
JsonSchema,
)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum Barcode {
Oxide(OxideBarcode),
Mpn1(Mpn1Barcode),
}

#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Deserialize,
Serialize,
JsonSchema,
)]
pub struct SledFanTray {
pub identity: OxideBarcode,
pub vpd_board_identity: OxideBarcode,
pub fan0: Barcode,
pub fan1: Barcode,
pub fan2: Barcode,
}

#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Deserialize,
Serialize,
JsonSchema,
)]
pub struct Tmp11x {
pub device_id: u16,
pub eeprom1: u16,
pub eeprom2: u16,
pub eeprom3: u16,
}

/// PMBus vital product data (VPD) read from a PMBus device.
///
/// If the device does not support a particular VPD command, the field in this
/// struct corresponding to that command will be `None`. Otherwise, the value
/// contains the exact bytes returned by the device, including an empty value or
/// any NUL bytes returned by the device.
#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Deserialize,
Serialize,
JsonSchema,
)]
pub struct PmbusDevice {
/// `MFR_ID` (PMBus command 0x99).
pub mfr_id: Option<Vec<u8>>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Entirely for my own curiosity - who/what is going to end up parsing the contents of these fields?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The problem with these is that their contents vary a lot based on the device. In the immediate future, my plans are mainly to use the PMBus VPD fields for the MWOCP68/MWOCP67 rectifiers in the gateway hardware-component metrics for the power shelf, and use them to start inventorying the PSUs (see #11047). The PSUs are currently the only field-replaceable units whose identity is determined via these PMBus commands, so I think we won't immediately be reading them for other devices, but we may eventually.

/// `MFR_MODEL` (PMBus command 0x9A).
pub mfr_model: Option<Vec<u8>>,
/// `MFR_REVISION` (PMBus command 0x9B).
pub mfr_revision: Option<Vec<u8>>,
/// `MFR_LOCATION` (PMBus command 0x9C).
pub mfr_location: Option<Vec<u8>>,
/// `MFR_DATE` (PMBus command 0x9D).
pub mfr_date: Option<Vec<u8>>,
/// `MFR_SERIAL` (PMBus command 0x9E).
pub mfr_serial: Option<Vec<u8>>,
/// `IC_DEVICE_ID` (PMBus command 0xAD).
pub ic_device_id: Option<Vec<u8>>,
/// `IC_DEVICE_REV` (PMBus command 0xAE).
pub ic_device_rev: Option<Vec<u8>>,
}
9 changes: 9 additions & 0 deletions gateway-types/versions/src/component_vpd/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! Version `COMPONENT_VPD` of the Gateway API.
//!
//! This version adds APIs for reading vital product data from an SP component.

pub mod component_vpd;
Loading
Loading