Skip to content

Commit

Permalink
Merge branch 'main' into range-requests
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed Nov 1, 2024
2 parents 6f1773e + 75fa3c9 commit 9588978
Show file tree
Hide file tree
Showing 45 changed files with 856 additions and 147 deletions.
14 changes: 7 additions & 7 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 @@ -342,7 +342,7 @@ crucible-common = { git = "https://github.com/oxidecomputer/crucible", rev = "b7
csv = "1.3.0"
curve25519-dalek = "4"
datatest-stable = "0.2.9"
display-error-chain = "0.2.1"
display-error-chain = "0.2.2"
omicron-ddm-admin-client = { path = "clients/ddm-admin-client" }
db-macros = { path = "nexus/db-macros" }
debug-ignore = "1.0.5"
Expand Down
18 changes: 1 addition & 17 deletions clients/dpd-client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use anyhow::Context;
use anyhow::Result;
use omicron_zone_package::config::Config;
use omicron_zone_package::package::PackageSource;
use progenitor::TypePatch;
use quote::quote;
use std::env;
use std::fs;
Expand Down Expand Up @@ -89,22 +88,7 @@ fn main() -> Result<()> {
slog::debug!(state.log, "client response"; "result" => ?result);
}
})
.with_patch("LinkId", &TypePatch::default()
.with_derive("Eq")
.with_derive("PartialEq")
)
.with_patch("LinkCreate", &TypePatch::default()
.with_derive("Eq")
.with_derive("PartialEq")
)
.with_patch("LinkSettings", &TypePatch::default()
.with_derive("Eq")
.with_derive("PartialEq")
)
.with_patch("PortSettings", &TypePatch::default()
.with_derive("Eq")
.with_derive("PartialEq")
)
.with_derive("PartialEq")
)
.generate_tokens(&spec)
.with_context(|| {
Expand Down
1 change: 1 addition & 0 deletions clients/sled-agent-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ progenitor::generate_api!(
BgpConfig = { derives = [Eq, Hash] },
BgpPeerConfig = { derives = [Eq, Hash] },
LldpPortConfig = { derives = [Eq, Hash, PartialOrd, Ord] },
TxEqConfig = { derives = [Eq, Hash] },
OmicronPhysicalDiskConfig = { derives = [Eq, Hash, PartialOrd, Ord] },
PortConfigV2 = { derives = [Eq, Hash] },
RouteConfig = { derives = [Eq, Hash] },
Expand Down
35 changes: 35 additions & 0 deletions common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2358,6 +2358,10 @@ pub struct SwitchPortSettingsView {
/// Link-layer discovery protocol (LLDP) settings.
pub link_lldp: Vec<LldpLinkConfig>,

/// TX equalization settings. These are optional, and most links will not
/// need them.
pub tx_eq: Vec<Option<TxEqConfig>>,

/// Layer 3 interface settings.
pub interfaces: Vec<SwitchInterfaceConfig>,

Expand Down Expand Up @@ -2500,6 +2504,9 @@ pub struct SwitchPortLinkConfig {
/// link.
pub lldp_link_config_id: Option<Uuid>,

/// The tx_eq configuration id for this link.
pub tx_eq_config_id: Option<Uuid>,

/// The name of this link.
pub link_name: String,

Expand Down Expand Up @@ -2544,6 +2551,34 @@ pub struct LldpLinkConfig {
pub management_ip: Option<oxnet::IpNet>,
}

/// Per-port tx-eq overrides. This can be used to fine-tune the transceiver
/// equalization settings to improve signal integrity.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
pub struct TxEqConfig {
/// Pre-cursor tap1
pub pre1: Option<i32>,
/// Pre-cursor tap2
pub pre2: Option<i32>,
/// Main tap
pub main: Option<i32>,
/// Post-cursor tap2
pub post2: Option<i32>,
/// Post-cursor tap1
pub post1: Option<i32>,
}

impl From<crate::api::internal::shared::TxEqConfig> for TxEqConfig {
fn from(x: crate::api::internal::shared::TxEqConfig) -> TxEqConfig {
TxEqConfig {
pre1: x.pre1,
pre2: x.pre2,
main: x.main,
post2: x.post2,
post1: x.post1,
}
}
}

/// Describes the kind of an switch interface.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
#[serde(rename_all = "snake_case")]
Expand Down
28 changes: 27 additions & 1 deletion common/src/api/internal/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,24 @@ pub struct LldpPortConfig {
pub management_addrs: Option<Vec<IpAddr>>,
}

/// Per-port tx-eq overrides. This can be used to fine-tune the transceiver
/// equalization settings to improve signal integrity.
#[derive(
Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema,
)]
pub struct TxEqConfig {
/// Pre-cursor tap1
pub pre1: Option<i32>,
/// Pre-cursor tap2
pub pre2: Option<i32>,
/// Main tap
pub main: Option<i32>,
/// Post-cursor tap2
pub post2: Option<i32>,
/// Post-cursor tap1
pub post1: Option<i32>,
}

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
pub struct PortConfigV2 {
/// The set of routes associated with this port.
Expand All @@ -479,6 +497,8 @@ pub struct PortConfigV2 {
pub autoneg: bool,
/// LLDP configuration for this port
pub lldp: Option<LldpPortConfig>,
/// TX-EQ configuration for this port
pub tx_eq: Option<TxEqConfig>,
}

/// A set of switch uplinks.
Expand All @@ -497,11 +517,17 @@ pub struct HostPortConfig {
pub addrs: Vec<UplinkAddressConfig>,

pub lldp: Option<LldpPortConfig>,
pub tx_eq: Option<TxEqConfig>,
}

impl From<PortConfigV2> for HostPortConfig {
fn from(x: PortConfigV2) -> Self {
Self { port: x.port, addrs: x.addresses, lldp: x.lldp.clone() }
Self {
port: x.port,
addrs: x.addresses,
lldp: x.lldp.clone(),
tx_eq: x.tx_eq,
}
}
}

Expand Down
12 changes: 6 additions & 6 deletions flake.lock

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

12 changes: 12 additions & 0 deletions nexus/db-model/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ table! {
speed -> crate::SwitchLinkSpeedEnum,
autoneg -> Bool,
lldp_link_config_id -> Nullable<Uuid>,
tx_eq_config_id -> Nullable<Uuid>,
}
}

Expand All @@ -164,6 +165,17 @@ table! {
}
}

table! {
tx_eq_config (id) {
id -> Uuid,
pre1 -> Nullable<Int4>,
pre2 -> Nullable<Int4>,
main -> Nullable<Int4>,
post2 -> Nullable<Int4>,
post1 -> Nullable<Int4>,
}
}

table! {
switch_port_settings_interface_config (id) {
port_settings_id -> Uuid,
Expand Down
3 changes: 2 additions & 1 deletion nexus/db-model/src/schema_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::collections::BTreeMap;
///
/// This must be updated when you change the database schema. Refer to
/// schema/crdb/README.adoc in the root of this repository for details.
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(112, 0, 0);
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(113, 0, 0);

/// List of all past database schema versions, in *reverse* order
///
Expand All @@ -29,6 +29,7 @@ static KNOWN_VERSIONS: Lazy<Vec<KnownVersion>> = Lazy::new(|| {
// | leaving the first copy as an example for the next person.
// v
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
KnownVersion::new(113, "add-tx-eq"),
KnownVersion::new(112, "blueprint-dataset"),
KnownVersion::new(111, "drop-omicron-zone-underlay-address"),
KnownVersion::new(110, "clickhouse-policy"),
Expand Down
52 changes: 52 additions & 0 deletions nexus/db-model/src/switch_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::schema::{
switch_port_settings_group, switch_port_settings_groups,
switch_port_settings_interface_config, switch_port_settings_link_config,
switch_port_settings_port_config, switch_port_settings_route_config,
tx_eq_config,
};
use crate::{impl_enum_type, SqlU32};
use crate::{SqlU16, SqlU8};
Expand Down Expand Up @@ -387,9 +388,11 @@ pub struct SwitchPortLinkConfig {
pub fec: SwitchLinkFec,
pub speed: SwitchLinkSpeed,
pub autoneg: bool,
pub tx_eq_config_id: Option<Uuid>,
}

impl SwitchPortLinkConfig {
#[allow(clippy::too_many_arguments)]
pub fn new(
port_settings_id: Uuid,
lldp_link_config_id: Uuid,
Expand All @@ -398,6 +401,7 @@ impl SwitchPortLinkConfig {
fec: SwitchLinkFec,
speed: SwitchLinkSpeed,
autoneg: bool,
tx_eq_config_id: Option<Uuid>,
) -> Self {
Self {
port_settings_id,
Expand All @@ -407,6 +411,7 @@ impl SwitchPortLinkConfig {
speed,
autoneg,
mtu: mtu.into(),
tx_eq_config_id,
}
}
}
Expand All @@ -416,6 +421,7 @@ impl Into<external::SwitchPortLinkConfig> for SwitchPortLinkConfig {
external::SwitchPortLinkConfig {
port_settings_id: self.port_settings_id,
lldp_link_config_id: self.lldp_link_config_id,
tx_eq_config_id: self.tx_eq_config_id,
link_name: self.link_name.clone(),
mtu: self.mtu.into(),
fec: self.fec.into(),
Expand Down Expand Up @@ -494,6 +500,52 @@ impl Into<external::LldpLinkConfig> for LldpLinkConfig {
}
}

#[derive(
Queryable,
Insertable,
Selectable,
Clone,
Debug,
Serialize,
Deserialize,
AsChangeset,
)]
#[diesel(table_name = tx_eq_config)]
pub struct TxEqConfig {
pub id: Uuid,
pub pre1: Option<i32>,
pub pre2: Option<i32>,
pub main: Option<i32>,
pub post2: Option<i32>,
pub post1: Option<i32>,
}

impl TxEqConfig {
pub fn new(
pre1: Option<i32>,
pre2: Option<i32>,
main: Option<i32>,
post2: Option<i32>,
post1: Option<i32>,
) -> Self {
Self { id: Uuid::new_v4(), pre1, pre2, main, post2, post1 }
}
}

// This converts the internal database version of the config into the
// user-facing version.
impl Into<external::TxEqConfig> for TxEqConfig {
fn into(self) -> external::TxEqConfig {
external::TxEqConfig {
pre1: self.pre1,
pre2: self.pre2,
main: self.main,
post2: self.post2,
post1: self.post1,
}
}
}

#[derive(
Queryable,
Insertable,
Expand Down
Loading

0 comments on commit 9588978

Please sign in to comment.