Skip to content

Commit

Permalink
first stab at sff-8636 complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron-Hartwig committed Nov 28, 2023
1 parent 987749d commit 92aaf7c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 26 deletions.
46 changes: 29 additions & 17 deletions controller/src/bin/xcvradm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ fn print_performance(performance_result: &PerformanceResult) {
print_array_of_option_property(
NAME_WIDTH,
"Rx amplitudes supported",
sff.rx_output_ampl_support,
sff.rx_output_ampl_support.as_slice(),
);
print_property(
NAME_WIDTH,
Expand All @@ -1462,7 +1462,7 @@ fn print_performance(performance_result: &PerformanceResult) {
let time = byte * 100;
print_property(NAME_WIDTH, "Max CTLE settling time (ms)", time);
} else {
print_property(NAME_WIDTH, "Max CTLE settling time (ms)", unsupported);
print_property(NAME_WIDTH, "Max CTLE settling time (ms)", &unsupported);
}
print_optional_property(NAME_WIDTH, "Host-side FEC enabled", sff.host_fec_enabled);
print_optional_property(
Expand All @@ -1473,43 +1473,47 @@ fn print_performance(performance_result: &PerformanceResult) {
print_optional_array_property(
NAME_WIDTH,
"Tx force squelched (lanes 0-3)",
sff.tx_force_squelches,
sff.tx_force_squelches.as_ref().map(|x| x.as_slice()),
);
print_optional_array_property(
NAME_WIDTH,
"Tx adaptive EQ frozen (lanes 0-3)",
sff.tx_ae_freezes,
sff.tx_ae_freezes.as_ref().map(|x| x.as_slice()),
);
print_array_property(
NAME_WIDTH,
"Tx EQ control (lanes 0-3)",
sff.tx_input_eqs.as_slice(),
);
print_array_property(NAME_WIDTH, "Tx EQ control (lanes 0-3)", sff.tx_input_eqs);
print_array_property(
NAME_WIDTH,
"Rx emphasis control (lanes 0-3)",
sff.rx_output_emphases,
sff.rx_output_emphases.as_slice(),
);
print_array_property(
NAME_WIDTH,
"Rx amplitude control (lanes 0-3)",
sff.rx_output_ampls,
sff.rx_output_ampls.as_slice(),
);
print_array_property(
NAME_WIDTH,
"Rx squelch disabled (lanes 0-3)",
sff.rx_squelch_disables,
sff.rx_squelch_disables.as_slice(),
);
print_array_property(
NAME_WIDTH,
"Tx squelch disabled (lanes 0-3)",
sff.tx_squelch_disables,
sff.tx_squelch_disables.as_slice(),
);
print_array_property(
NAME_WIDTH,
"Rx output disabled (lanes 0-3)",
sff.rx_output_disables,
sff.rx_output_disables.as_slice(),
);
print_optional_array_property(
NAME_WIDTH,
"Tx adaptive EQ enabled (lanes 0-3)",
sff.tx_adaptive_eq_enables,
sff.tx_adaptive_eq_enables.as_ref().map(|x| x.as_slice()),
);
}
None => (),
Expand All @@ -1533,8 +1537,8 @@ fn print_optional_property<T: Display>(name_width: usize, name: &str, value: Opt
}
}

fn print_array_property<T: Display>(name_width: usize, name: &str, values: [T]) {
print!(" {}: [", format!("{:>name_width$}", name));
fn print_array_property<T: Display + Sized>(name_width: usize, name: &str, values: &[T]) {
print!(" {}: [ ", format!("{:>name_width$}", name));
for (i, val) in values.into_iter().enumerate() {
print!("{}", val);
if i < values.len() - 1 {
Expand All @@ -1544,15 +1548,23 @@ fn print_array_property<T: Display>(name_width: usize, name: &str, values: [T])
println!(" ]");
}

fn print_optional_array_property<T: Display>(name_width: usize, name: &str, values: Option<&[T]>) {
fn print_optional_array_property<T: Display + Sized>(
name_width: usize,
name: &str,
values: Option<&[T]>,
) {
match values {
Some(array) => print_array_property(name_width, name, array),
None => println!("--"),
None => print_property(name_width, name, "--"),
}
}

fn print_array_of_option_property<T: Display>(name_width: usize, name: &str, values: [Option<T>]) {
print!(" {}: [", format!("{:>name_width$}", name));
fn print_array_of_option_property<T: Display + Sized>(
name_width: usize,
name: &str,
values: &[Option<T>],
) {
print!(" {}: [ ", format!("{:>name_width$}", name));
for (i, val) in values.into_iter().enumerate() {
match val {
Some(v) => {
Expand Down
17 changes: 8 additions & 9 deletions decode/src/performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct Performance {
// SFF-8636

#[derive(Clone, Debug, Default)]
pub struct SffPerformance<'a> {
pub struct SffPerformance {
pub max_tx_input_eq: TxInputEqualization,
pub max_rx_output_emphasis: RxOutputEmphasis,
pub rx_output_emphasis_type: RxOutputEmphasisType,
Expand All @@ -34,15 +34,15 @@ pub struct SffPerformance<'a> {
pub max_ctle_settle_time: Option<u8>,
pub host_fec_enabled: Option<bool>,
pub media_fec_enabled: Option<bool>,
pub tx_force_squelches: Option<&'a[bool; 4]>,
pub tx_ae_freezes: Option<&'a[bool; 4]>,
pub tx_force_squelches: Option<[bool; 4]>,
pub tx_ae_freezes: Option<[bool; 4]>,
pub tx_input_eqs: [TxInputEqualization; 4],
pub rx_output_emphases: [RxOutputEmphasis; 4],
pub rx_output_ampls: [RxOutputAmplitudeSupport; 4],
pub rx_squelch_disables: [bool; 4],
pub tx_squelch_disables: [bool; 4],
pub rx_output_disables: [bool; 4],
pub tx_adaptive_eq_enables: Option<&'a[bool; 4]>,
pub tx_adaptive_eq_enables: Option<[bool; 4]>,
}

#[derive(Clone, Copy, Debug, Default, PartialEq)]
Expand Down Expand Up @@ -417,6 +417,8 @@ impl ParseFromModule for Performance {
let mut media_fec_ctrl_support = false;
let mut tx_force_squelch_support = false;

let mut tx_force_squelches: [bool; 4] = [false; 4];

for idx in 0..18 {
let byte = bytes[idx];
match idx {
Expand All @@ -431,11 +433,8 @@ impl ParseFromModule for Performance {
for i in 0..4 {
let ampl = byte & i as u8;
let supported = ampl != 0;
perf.rx_output_ampl_support[i] = if supported {
Some(ampl.into())
} else {
None
}
perf.rx_output_ampl_support[i] =
if supported { Some(ampl.into()) } else { None }
}
}
// byte 227
Expand Down

0 comments on commit 92aaf7c

Please sign in to comment.