Skip to content

Commit

Permalink
sfp-tx-control
Browse files Browse the repository at this point in the history
  • Loading branch information
Stoyan Trilov committed Nov 22, 2024
1 parent 14739b3 commit cfa4cfd
Show file tree
Hide file tree
Showing 20 changed files with 216 additions and 107 deletions.

This file was deleted.

2 changes: 1 addition & 1 deletion include/timing/FIBIONode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class FIBIONode : public SFPMuxIONode {
/**
* @brief Switch on or off the SFP tx laser via the I2C IO expander controlling the sfp tx disable pin. aOn=1: laster transmitting, tx disable pin = 0; aOn=0: laster NOT transmitting, tx disable pin = 1.
*/
void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const; // NOLINT(build/unsigned)
void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const override; // NOLINT(build/unsigned)

// /**
// * @brief Fill hardware monitoring structure.
Expand Down
2 changes: 1 addition & 1 deletion include/timing/FIBV2IONode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class FIBV2IONode : public IONode {
/**
* @brief Switch on or off the SFP tx laser via the I2C IO expander controlling the sfp tx disable pin. aOn=1: laster transmitting, tx disable pin = 0; aOn=0: laster NOT transmitting, tx disable pin = 1.
*/
void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const; // NOLINT(build/unsigned)
void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const override; // NOLINT(build/unsigned)

/**
* @brief Print status of on-board PLL.
Expand Down
7 changes: 7 additions & 0 deletions include/timing/FMCIONode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ class FMCIONode : public IONode
*/
std::string get_clock_frequencies_table(bool print_out = false) const override;

/**
* @brief control tx laser of on-board SFP
*/
void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const override; // NOLINT(build/unsigned)

// /**
// * @brief Fill hardware monitoring structure.
// */
Expand All @@ -78,6 +83,8 @@ class FMCIONode : public IONode
// * @brief Give info to collector.
// */
// void get_info(opmonlib::InfoCollector& ci, int level) const override;
private:
void validate_sfp_id(uint32_t sfp_id) const; // NOLINT(build/unsigned)
};

} // namespace timing
Expand Down
5 changes: 5 additions & 0 deletions include/timing/GIBIONode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ class GIBIONode : public IONode
*/
void switch_sfp_soft_tx_control_bit(uint32_t sfp_id, bool turn_on) const override; // NOLINT(build/unsigned)

/**
* @brief control tx laser of on-board SFP softly (I2C command)
*/
void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const override; // NOLINT(build/unsigned)

/**
* @brief Fill hardware monitoring structure.
*/
Expand Down
5 changes: 5 additions & 0 deletions include/timing/IONode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ class IONode : public TimingNode
*/
virtual void switch_sfp_soft_tx_control_bit(uint32_t sfp_id, bool turn_on) const; // NOLINT(build/unsigned)

/**
* @brief control tx laser of on-board SFP
*/
virtual void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const = 0; // NOLINT(build/unsigned)

/**
* @brief Reset timing node.
*/
Expand Down
8 changes: 8 additions & 0 deletions include/timing/MIBIONode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ class MIBIONode : public IONode
*/
void switch_sfp_soft_tx_control_bit(uint32_t sfp_id, bool turn_on) const override; // NOLINT(build/unsigned)

/**
* @brief control tx laser of on-board SFP
*/
void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const override // NOLINT(build/unsigned)
{
TLOG() << "Not implemented in MIB v1 firmware";
}

// /**
// * @brief Fill hardware monitoring structure.
// */
Expand Down
5 changes: 5 additions & 0 deletions include/timing/MIBV2IONode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ class MIBV2IONode : public IONode
*/
void switch_sfp_soft_tx_control_bit(uint32_t sfp_id, bool turn_on) const override; // NOLINT(build/unsigned)

/**
* @brief control tx laser of on-board SFP
*/
void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const override; // NOLINT(build/unsigned)

/**
* @brief Fill hardware monitoring structure.
*/
Expand Down
7 changes: 7 additions & 0 deletions include/timing/PC059IONode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ class PC059IONode : public SFPMuxIONode
*/
void switch_sfp_soft_tx_control_bit(uint32_t sfp_id, bool turn_on) const override; // NOLINT(build/unsigned)

/**
* @brief control tx laser of on-board SFP softly (I2C command)
*/
void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const override; // NOLINT(build/unsigned)

// /**
// * @brief Fill hardware monitoring structure.
// */
Expand All @@ -94,6 +99,8 @@ class PC059IONode : public SFPMuxIONode
// * @brief Give info to collector.
// */
// void get_info(opmonlib::InfoCollector& ci, int level) const override;
private:
void validate_sfp_id(uint32_t sfp_id) const; // NOLINT(build/unsigned)
};

} // namespace timing
Expand Down
5 changes: 5 additions & 0 deletions include/timing/SIMIONode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ class SIMIONode : public IONode
* @brief Control tx laser of on-board SFP softly (I2C command)
*/
void switch_sfp_soft_tx_control_bit(uint32_t sfp_id, bool turn_on) const override; // NOLINT(build/unsigned)

/**
* @brief Control tx laser of on-board SFP softly (I2C command)
*/
void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const override; // NOLINT(build/unsigned)
};

} // namespace timing
Expand Down
7 changes: 7 additions & 0 deletions include/timing/TLUIONode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ class TLUIONode : public IONode
*/
void switch_sfp_soft_tx_control_bit(uint32_t, bool) const override; // NOLINT(build/unsigned)

/**
* @brief Control tx laser of on-board SFP softly (I2C command)
*/
void switch_sfp_tx(uint32_t, bool) const override; // NOLINT(build/unsigned)

// /**
// * @brief Fill hardware monitoring structure.
// */
Expand All @@ -87,6 +92,8 @@ class TLUIONode : public IONode

protected:
const std::vector<std::string> m_dac_devices;
private:
void validate_sfp_id(uint32_t sfp_id) const; // NOLINT(build/unsigned)
};

} // namespace timing
Expand Down
21 changes: 15 additions & 6 deletions pybindsrc/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ register_io(py::module& m)
.def("get_pll_status", &timing::FMCIONode::get_pll_status, py::arg("print_out") = false)
.def("get_hardware_info", &timing::FMCIONode::get_hardware_info, py::arg("print_out") = false)
.def("get_sfp_status", &timing::FMCIONode::get_sfp_status, py::arg("sfp_id"), py::arg("print_out") = false)
.def("switch_sfp_soft_tx_control_bit", &timing::FMCIONode::switch_sfp_soft_tx_control_bit);
.def("switch_sfp_soft_tx_control_bit", &timing::FMCIONode::switch_sfp_soft_tx_control_bit)
.def("switch_sfp_tx", &timing::FMCIONode::switch_sfp_tx);

py::class_<timing::PC059IONode, timing::IONode, uhal::Node>(m, "PC059IONode")
.def(py::init<const uhal::Node&>())
Expand All @@ -65,7 +66,8 @@ register_io(py::module& m)
.def("get_sfp_status", &timing::PC059IONode::get_sfp_status, py::arg("sfp_id"), py::arg("print_out") = false)
.def("switch_sfp_soft_tx_control_bit", &timing::PC059IONode::switch_sfp_soft_tx_control_bit)
.def("switch_sfp_mux_channel", &timing::PC059IONode::switch_sfp_mux_channel, py::arg("mux_channel"))
.def("read_active_sfp_mux_channel", &timing::PC059IONode::read_active_sfp_mux_channel);
.def("read_active_sfp_mux_channel", &timing::PC059IONode::read_active_sfp_mux_channel)
.def("switch_sfp_tx", &timing::PC059IONode::switch_sfp_tx);

py::class_<timing::FIBIONode, timing::IONode, uhal::Node>(m, "FIBIONode")
.def(py::init<const uhal::Node&>())
Expand All @@ -82,7 +84,8 @@ register_io(py::module& m)
.def("get_sfp_status", &timing::FIBIONode::get_sfp_status, py::arg("sfp_id"), py::arg("print_out") = false)
.def("switch_sfp_soft_tx_control_bit", &timing::FIBIONode::switch_sfp_soft_tx_control_bit)
.def("switch_sfp_mux_channel", &timing::FIBIONode::switch_sfp_mux_channel, py::arg("mux_channel"))
.def("read_active_sfp_mux_channel", &timing::FIBIONode::read_active_sfp_mux_channel);
.def("read_active_sfp_mux_channel", &timing::FIBIONode::read_active_sfp_mux_channel)
.def("switch_sfp_tx", &timing::FIBIONode::switch_sfp_tx);

py::class_<timing::FIBV2IONode, timing::IONode, uhal::Node>(m, "FIBV2IONode")
.def(py::init<const uhal::Node&>())
Expand All @@ -95,7 +98,8 @@ register_io(py::module& m)
.def("get_pll_status", &timing::FIBV2IONode::get_pll_status, py::arg("print_out") = false)
.def("get_hardware_info", &timing::FIBV2IONode::get_hardware_info, py::arg("print_out") = false)
.def("get_sfp_status", &timing::FIBV2IONode::get_sfp_status, py::arg("sfp_id"), py::arg("print_out") = false)
.def("switch_sfp_soft_tx_control_bit", &timing::FIBV2IONode::switch_sfp_soft_tx_control_bit);
.def("switch_sfp_soft_tx_control_bit", &timing::FIBV2IONode::switch_sfp_soft_tx_control_bit)
.def("switch_sfp_tx", &timing::FIBV2IONode::switch_sfp_tx);

py::class_<timing::TLUIONode, timing::IONode, uhal::Node>(m, "TLUIONode")
.def(py::init<const uhal::Node&>())
Expand All @@ -115,7 +119,8 @@ register_io(py::module& m)
&timing::TLUIONode::configure_dac,
py::arg("dac_id"),
py::arg("dac_value"),
py::arg("internal_ref") = false);
py::arg("internal_ref") = false)
.def("switch_sfp_tx", &timing::TLUIONode::switch_sfp_tx);

py::class_<timing::SIMIONode, timing::IONode, uhal::Node>(m, "SIMIONode")
.def(py::init<const uhal::Node&>())
Expand All @@ -130,7 +135,8 @@ register_io(py::module& m)
.def("get_pll_status", &timing::SIMIONode::get_pll_status, py::arg("print_out") = false)
.def("get_hardware_info", &timing::SIMIONode::get_hardware_info, py::arg("print_out") = false)
.def("get_sfp_status", &timing::SIMIONode::get_sfp_status, py::arg("sfp_id"), py::arg("print_out") = false)
.def("switch_sfp_soft_tx_control_bit", &timing::SIMIONode::switch_sfp_soft_tx_control_bit);
.def("switch_sfp_soft_tx_control_bit", &timing::SIMIONode::switch_sfp_soft_tx_control_bit)
.def("switch_sfp_tx", &timing::SIMIONode::switch_sfp_tx);

py::class_<timing::MIBIONode, timing::IONode, uhal::Node>(m, "MIBIONode")
.def(py::init<const uhal::Node&>())
Expand All @@ -147,6 +153,7 @@ register_io(py::module& m)
.def("get_hardware_info", &timing::MIBIONode::get_hardware_info, py::arg("print_out") = false)
.def("get_sfp_status", &timing::MIBIONode::get_sfp_status, py::arg("sfp_id"), py::arg("print_out") = false)
.def("switch_sfp_soft_tx_control_bit", &timing::MIBIONode::switch_sfp_soft_tx_control_bit)
.def("switch_sfp_tx", &timing::MIBIONode::switch_sfp_tx)
;

py::class_<timing::SwitchyardNode, uhal::Node>(m, "SwitchyardNode")
Expand All @@ -169,6 +176,7 @@ register_io(py::module& m)
.def("get_hardware_info", &timing::MIBV2IONode::get_hardware_info, py::arg("print_out") = false)
.def("get_sfp_status", &timing::MIBV2IONode::get_sfp_status, py::arg("sfp_id"), py::arg("print_out") = false)
.def("switch_sfp_soft_tx_control_bit", &timing::MIBV2IONode::switch_sfp_soft_tx_control_bit)
.def("switch_sfp_tx", &timing::MIBV2IONode::switch_sfp_tx)
;

py::class_<timing::GIBIONode, timing::IONode, uhal::Node>(m, "GIBIONode")
Expand All @@ -187,6 +195,7 @@ register_io(py::module& m)
.def("get_sfp_status", &timing::GIBIONode::get_sfp_status, py::arg("sfp_id"), py::arg("print_out") = false)
.def("switch_sfp_soft_tx_control_bit", &timing::GIBIONode::switch_sfp_soft_tx_control_bit)
.def("set_i2c_mux_channels", &timing::GIBIONode::set_i2c_mux_channels)
.def("switch_sfp_tx", &timing::GIBIONode::switch_sfp_tx)
;

} // NOLINT
Expand Down
21 changes: 7 additions & 14 deletions python/timing/cli/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ def clkstatus(ctx, obj, verbose):

ctx.invoke(status)

#if lBoardType in [kBoardPC059, kBoardFIB]:
# mux_fib = lIO.read_active_downstream_mux_channel()
# secho("Active sfp mux {} ".format(mux_fib))
if lBoardType == kBoardPC059: #TODO or lBoardRevision == kFIBRev1
mux_fib = lIO.read_active_downstream_mux_channel()
secho("Active sfp mux {} ".format(mux_fib))

echo()
ctx.invoke(freq)
Expand Down Expand Up @@ -282,17 +282,10 @@ def switchsfptx(ctx, obj, sfp_id, on):

if lBoardType in kLibrarySupportedBoards:
ctx.invoke(print_hardware_info)
if sfp_id is not None:
lIO.switch_sfp_soft_tx_control_bit(sfp_id, on)
echo(lIO.get_sfp_status(sfp_id))
else:
if lBoardType == kBoardFMC or lBoardType == kBoardTLU:
lIO.switch_sfp_soft_tx_control_bit(0, on)
echo(lIO.get_sfp_status(0))
elif ( lBoardType == kBoardPC059 ):
for i in range(9):
lIO.switch_sfp_soft_tx_control_bit(i, on)
echo(lIO.get_sfp_status(i))
lSFP=sfp_id
if sfp_id is None:
lSFP=0
lIO.switch_sfp_tx(lSFP, on)
else:
secho("Board {} not supported by timing library".format(lBoardType), fg='yellow')
# do sfp switch here
Expand Down
9 changes: 6 additions & 3 deletions src/FIBV2IONode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,15 @@ FIBV2IONode::switch_sfp_soft_tx_control_bit(uint32_t sfp_id, bool turn_on) const
//-----------------------------------------------------------------------------
void
FIBV2IONode::switch_sfp_tx(uint32_t sfp_id, bool turn_on) const { // NOLINT(build/unsigned)

validate_sfp_id(sfp_id);

uint8_t current_sfp_tx_control_flags = getNode("csr.ctrl.sfp_tx_disable").read(); // NOLINT(build/unsigned)
getClient().dispatch();

auto sfp_tx_control_flags = getNode("csr.ctrl.sfp_tx_disable").read(); // NOLINT(build/unsigned)
getClient().dispatch();

uint8_t current_sfp_tx_control_flags=sfp_tx_control_flags.value();
uint8_t new_sfp_tx_control_flags; // NOLINT(build/unsigned)

if (turn_on)
{
new_sfp_tx_control_flags = current_sfp_tx_control_flags & ~(1UL << sfp_id);
Expand Down
23 changes: 23 additions & 0 deletions src/FMCIONode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,28 @@ FMCIONode::get_clock_frequencies_table(bool print_out) const
// }
// }
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
void
FMCIONode::switch_sfp_tx(uint32_t sfp_id, bool turn_on) const // NOLINT(build/unsigned)
{
validate_sfp_id(sfp_id);

getNode("csr.ctrl.sfp_tx_dis").write(turn_on);
getClient().dispatch();
}
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
void
FMCIONode::validate_sfp_id(uint32_t sfp_id) const
{ // NOLINT(build/unsigned)
// on this board we have 3 upstream SFPs
if (sfp_id != 0)
{
throw InvalidSFPId(ERS_HERE, format_reg_value(sfp_id));
}
}
//-----------------------------------------------------------------------------
} // namespace timing
} // namespace dunedaq
Loading

0 comments on commit cfa4cfd

Please sign in to comment.