Skip to content
Merged
219 changes: 0 additions & 219 deletions common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2843,159 +2843,6 @@ pub struct AddressLotBlock {
pub last_address: IpAddr,
}

/// A switch port settings identity whose id may be used to view additional
/// details.
#[derive(
ObjectIdentity, Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq,
)]
pub struct SwitchPortSettingsIdentity {
#[serde(flatten)]
pub identity: IdentityMetadata,
}

/// This structure maps a port settings object to a port settings groups. Port
/// settings objects may inherit settings from groups. This mapping defines the
/// relationship between settings objects and the groups they reference.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
pub struct SwitchPortSettingsGroups {
/// The id of a port settings object referencing a port settings group.
pub port_settings_id: Uuid,

/// The id of a port settings group being referenced by a port settings
/// object.
pub port_settings_group_id: Uuid,
}

/// A port settings group is a named object that references a port settings
/// object.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
pub struct SwitchPortSettingsGroup {
#[serde(flatten)]
pub identity: IdentityMetadata,

/// The port settings that comprise this group.
pub port_settings_id: Uuid,
}

/// The link geometry associated with a switch port.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum SwitchPortGeometry {
/// The port contains a single QSFP28 link with four lanes.
Qsfp28x1,

/// The port contains two QSFP28 links each with two lanes.
Qsfp28x2,

/// The port contains four SFP28 links each with one lane.
Sfp28x4,
}

/// A physical port configuration for a port settings object.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
pub struct SwitchPortConfig {
/// The id of the port settings object this configuration belongs to.
pub port_settings_id: Uuid,

/// The physical link geometry of the port.
pub geometry: SwitchPortGeometry,
}

/// The speed of a link.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum LinkSpeed {
/// Zero gigabits per second.
Speed0G,
/// 1 gigabit per second.
Speed1G,
/// 10 gigabits per second.
Speed10G,
/// 25 gigabits per second.
Speed25G,
/// 40 gigabits per second.
Speed40G,
/// 50 gigabits per second.
Speed50G,
/// 100 gigabits per second.
Speed100G,
/// 200 gigabits per second.
Speed200G,
/// 400 gigabits per second.
Speed400G,
}

/// The forward error correction mode of a link.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum LinkFec {
/// Firecode forward error correction.
Firecode,
/// No forward error correction.
None,
/// Reed-Solomon forward error correction.
Rs,
}

/// A link configuration for a port settings object.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
pub struct SwitchPortLinkConfig {
/// The port settings this link configuration belongs to.
pub port_settings_id: Uuid,

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

/// The maximum transmission unit for this link.
pub mtu: u16,

/// The requested forward-error correction method. If this is not
/// specified, the standard FEC for the underlying media will be applied
/// if it can be determined.
pub fec: Option<LinkFec>,

/// The configured speed of the link.
pub speed: LinkSpeed,

/// Whether or not the link has autonegotiation enabled.
pub autoneg: bool,

/// The link-layer discovery protocol service configuration for this
/// link.
pub lldp_link_config: Option<LldpLinkConfig>,

/// The tx_eq configuration for this link.
pub tx_eq_config: Option<TxEqConfig>,
}

/// A link layer discovery protocol (LLDP) service configuration.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
pub struct LldpLinkConfig {
/// The id of this LLDP service instance.
pub id: Uuid,

/// Whether or not the LLDP service is enabled.
pub enabled: bool,

/// The LLDP link name TLV.
pub link_name: Option<String>,

/// The LLDP link description TLV.
pub link_description: Option<String>,

/// The LLDP chassis identifier TLV.
pub chassis_id: Option<String>,

/// The LLDP system name TLV.
pub system_name: Option<String>,

/// The LLDP system description TLV.
pub system_description: Option<String>,

/// The LLDP management IP TLV.
pub management_ip: Option<IpAddr>,
}

/// Information about LLDP advertisements from other network entities directly
/// connected to a switch port. This structure contains both metadata about
/// when and where the neighbor was seen, as well as the specific information
Expand Down Expand Up @@ -3040,72 +2887,6 @@ impl SimpleIdentity for LldpNeighbor {
}
}

/// 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>,
}

/// Describes the kind of an switch interface.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SwitchInterfaceKind {
/// Primary interfaces are associated with physical links. There is exactly
/// one primary interface per physical link.
Primary,

/// VLAN interfaces allow physical interfaces to be multiplexed onto
/// multiple logical links, each distinguished by a 12-bit 802.1Q Ethernet
/// tag.
Vlan,

/// Loopback interfaces are anchors for IP addresses that are not specific
/// to any particular port.
Loopback,
}

/// A switch port interface configuration for a port settings object.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
pub struct SwitchInterfaceConfig {
/// The port settings object this switch interface configuration belongs to.
pub port_settings_id: Uuid,

/// A unique identifier for this switch interface.
pub id: Uuid,

/// The name of this switch interface.
pub interface_name: Name,

/// Whether or not IPv6 is enabled on this interface.
pub v6_enabled: bool,

/// The switch interface kind.
pub kind: SwitchInterfaceKind,
}

/// A switch port VLAN interface configuration for a port settings object.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
pub struct SwitchVlanInterfaceConfig {
/// The switch interface configuration this VLAN interface configuration
/// belongs to.
pub interface_config_id: Uuid,

/// The virtual network id for this interface that is used for producing and
/// consuming 802.1Q Ethernet tags. This field has a maximum value of 4095
/// as 802.1Q tags are twelve bits.
pub vlan_id: u16,
}

/// A route configuration for a port settings object.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
pub struct SwitchPortRouteConfig {
Expand Down
23 changes: 5 additions & 18 deletions nexus/db-model/src/switch_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use ipnetwork::IpNetwork;
use nexus_db_schema::schema::{loopback_address, switch_vlan_interface_config};
use nexus_types::external_api::networking as networking_types;
use nexus_types::identity::Asset;
use omicron_common::api::external;
use omicron_uuid_kinds::LoopbackAddressKind;
use omicron_uuid_kinds::TypedUuid;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -53,20 +52,6 @@ impl From<networking_types::SwitchInterfaceKind> for DbSwitchInterfaceKind {
}
}

impl Into<external::SwitchInterfaceKind> for DbSwitchInterfaceKind {
fn into(self) -> external::SwitchInterfaceKind {
match self {
DbSwitchInterfaceKind::Primary => {
external::SwitchInterfaceKind::Primary
}
DbSwitchInterfaceKind::Vlan => external::SwitchInterfaceKind::Vlan,
DbSwitchInterfaceKind::Loopback => {
external::SwitchInterfaceKind::Loopback
}
}
}
}

#[derive(
Queryable,
Insertable,
Expand All @@ -89,9 +74,11 @@ impl SwitchVlanInterfaceConfig {
}
}

impl Into<external::SwitchVlanInterfaceConfig> for SwitchVlanInterfaceConfig {
fn into(self) -> external::SwitchVlanInterfaceConfig {
external::SwitchVlanInterfaceConfig {
impl Into<networking_types::SwitchVlanInterfaceConfig>
for SwitchVlanInterfaceConfig
{
fn into(self) -> networking_types::SwitchVlanInterfaceConfig {
networking_types::SwitchVlanInterfaceConfig {
interface_config_id: self.interface_config_id,
vlan_id: self.vid.into(),
}
Expand Down
Loading
Loading