Skip to content

Commit 07706cb

Browse files
authored
Add swadm subcommands for enabling / disabling a link (#39)
* Add `swadm` subcommands for enabling / disabling a link * Clippy
1 parent aa212ae commit 07706cb

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

swadm/src/link.rs

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,12 @@ pub enum Link {
349349
filter: Option<String>,
350350
},
351351

352+
/// Enable a link.
353+
Enable { link: LinkPath },
354+
355+
/// Disable a link.
356+
Disable { link: LinkPath },
357+
352358
/// Set a property of a link.
353359
SetProp {
354360
/// The link to set the property on.
@@ -833,11 +839,11 @@ async fn link_rmon_counters(
833839
#[macro_export]
834840
macro_rules! print_speedenc_fields {
835841
($label:expr, $all:ident, $($field_path:ident).+) => {
836-
print!("{:10}", $label);
842+
print!("{:10}", $label);
837843
for lane in & $all {
838844
print!(" {:>6}", lane.$($field_path).+.to_string());
839-
}
840-
println!();
845+
}
846+
println!();
841847
}
842848
}
843849

@@ -865,11 +871,11 @@ async fn link_serdes_enc_speed(
865871
#[macro_export]
866872
macro_rules! print_anlt_fields {
867873
($label:expr, $all:ident, $($field_path:ident).+) => {
868-
print!("{:20}", $label);
874+
print!("{:20}", $label);
869875
for lane in & $all {
870876
print!(" {:>6}", lane.$($field_path).+.to_string());
871-
}
872-
println!();
877+
}
878+
println!();
873879
}
874880
}
875881

@@ -1005,11 +1011,11 @@ async fn link_serdes_eye(
10051011
#[macro_export]
10061012
macro_rules! print_rx_adapt_fields {
10071013
($label:expr, $all:ident, $($field_path:ident).+) => {
1008-
print!("{:14}", $label);
1014+
print!("{:14}", $label);
10091015
for lane in & $all {
10101016
print!(" {:>6}", lane.$($field_path).+.to_string());
1011-
}
1012-
println!();
1017+
}
1018+
println!();
10131019
}
10141020
}
10151021

@@ -1038,13 +1044,13 @@ async fn link_serdes_rx_adapt(
10381044
#[macro_export]
10391045
macro_rules! print_txeq_fields {
10401046
($label:expr, $all:ident, $($field_path:ident).+) => {
1041-
print!("{:6}", $label);
1047+
print!("{:6}", $label);
10421048
for lane in & $all {
10431049
let sw = lane.sw.$($field_path).+.unwrap_or(0);
10441050
let hw = lane.hw.$($field_path).+.unwrap_or(0);
1045-
print!(" {:>3} ({:>3})", sw.to_string(), hw.to_string());
1046-
}
1047-
println!();
1051+
print!(" {:>3} ({:>3})", sw.to_string(), hw.to_string());
1052+
}
1053+
println!();
10481054
}
10491055
}
10501056

@@ -1103,11 +1109,11 @@ async fn link_serdes_tx_eq_set(
11031109
#[macro_export]
11041110
macro_rules! print_rx_sig_fields {
11051111
($label:expr, $all:ident, $($field_path:ident).+) => {
1106-
print!("{:12}", $label);
1112+
print!("{:12}", $label);
11071113
for lane in & $all {
11081114
print!(" {:>6}", lane.$($field_path).+.to_string());
1109-
}
1110-
println!();
1115+
}
1116+
println!();
11111117
}
11121118
}
11131119

@@ -1798,6 +1804,18 @@ pub async fn link_cmd(client: &Client, link: Link) -> anyhow::Result<()> {
17981804
.context("failed to set KR mode")?;
17991805
}
18001806
},
1807+
Link::Enable { link } => {
1808+
client
1809+
.link_enabled_set(&link.port_id, &link.link_id, true)
1810+
.await
1811+
.with_context(|| "failed to enable link")?;
1812+
}
1813+
Link::Disable { link } => {
1814+
client
1815+
.link_enabled_set(&link.port_id, &link.link_id, false)
1816+
.await
1817+
.with_context(|| "failed to disable link")?;
1818+
}
18011819
Link::History {
18021820
link,
18031821
raw,

0 commit comments

Comments
 (0)