Skip to content

Commit c82dae4

Browse files
committed
add port settings apply method to swadm
1 parent 661a8cb commit c82dae4

File tree

1 file changed

+71
-13
lines changed

1 file changed

+71
-13
lines changed

swadm/src/link.rs

Lines changed: 71 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//
55
// Copyright 2025 Oxide Computer Company
66

7+
use std::collections::HashMap;
78
use std::io::{Write, stdout};
89
use std::net::IpAddr;
910
use std::str::FromStr;
@@ -402,6 +403,10 @@ pub enum Link {
402403

403404
/// Use the mechanism omicron uses to set up a link
404405
Apply {
406+
/// The link path
407+
link: LinkPath,
408+
/// Dpd tag to use
409+
tag: String,
405410
/// The first lane of the port to use for the new link
406411
lane: Option<types::LinkId>,
407412
/// The requested speed of the link.
@@ -420,11 +425,24 @@ pub enum Link {
420425
///
421426
kr: bool,
422427

423-
/// Transceiver equalization adjustment parameters.
424-
tx_eq_pre2: Option<i32>,
428+
/// Transmit equalization precursor 1.
429+
#[clap(long)]
425430
tx_eq_pre1: Option<i32>,
431+
432+
/// Transmit equalization precursor 2.
433+
#[clap(long)]
434+
tx_eq_pre2: Option<i32>,
435+
436+
/// Transmit equalization main precursor.
437+
#[clap(long)]
426438
tx_eq_main: Option<i32>,
439+
440+
/// Transmit equalization postcursor 1.
441+
#[clap(long)]
427442
tx_eq_post1: Option<i32>,
443+
444+
/// Transmit equalization postcursor 2.
445+
#[clap(long)]
428446
tx_eq_post2: Option<i32>,
429447
},
430448
}
@@ -1953,18 +1971,58 @@ pub async fn link_cmd(client: &Client, link: Link) -> anyhow::Result<()> {
19531971
},
19541972

19551973
Link::Apply {
1956-
lane: _,
1957-
speed: _,
1958-
fec: _,
1959-
autoneg: _,
1960-
kr: _,
1961-
tx_eq_pre2: _,
1962-
tx_eq_pre1: _,
1963-
tx_eq_main: _,
1964-
tx_eq_post1: _,
1965-
tx_eq_post2: _,
1974+
link,
1975+
tag,
1976+
lane,
1977+
speed,
1978+
fec,
1979+
autoneg,
1980+
kr,
1981+
tx_eq_pre1,
1982+
tx_eq_pre2,
1983+
tx_eq_main,
1984+
tx_eq_post1,
1985+
tx_eq_post2,
19661986
} => {
1967-
todo!()
1987+
let port_id = &link.port_id;
1988+
let mut body = types::PortSettings {
1989+
links: HashMap::default(),
1990+
};
1991+
1992+
let tx_eq = if tx_eq_pre1.is_none()
1993+
&& tx_eq_pre2.is_none()
1994+
&& tx_eq_main.is_none()
1995+
&& tx_eq_post1.is_none()
1996+
&& tx_eq_post2.is_none()
1997+
{
1998+
None
1999+
} else {
2000+
Some(types::TxEq {
2001+
pre1: tx_eq_pre1,
2002+
pre2: tx_eq_pre2,
2003+
main: tx_eq_main,
2004+
post1: tx_eq_post1,
2005+
post2: tx_eq_post2,
2006+
})
2007+
};
2008+
body.links.insert(
2009+
String::from("0"),
2010+
types::LinkSettings {
2011+
addrs: Vec::default(),
2012+
params: types::LinkCreate {
2013+
autoneg,
2014+
fec: fec.map(|f| f.into()),
2015+
kr,
2016+
lane,
2017+
speed: speed.into(),
2018+
tx_eq,
2019+
},
2020+
},
2021+
);
2022+
client
2023+
.port_settings_apply(port_id, Some(tag.as_str()), &body)
2024+
.await
2025+
.context("port settings apply failed")?;
19682026
}
19692027
}
19702028
Ok(())

0 commit comments

Comments
 (0)