From 3d2b53d4b15294241d98415211f1691c215d0029 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Wed, 24 Nov 2021 09:52:00 +0100 Subject: rfnoc: radio: Fix async message handling channel checks The async message handler and the async message validator would erroneously compare channel numbers for RX async messages with the number of valid TX channels. On TwinRX, where there are zero TX channels, this would always fail. Elsewhere in the code, the comparisons for TX and RX channels mixed up input and output ports. The second issue is that the comparison made was a "greater than" rather than "greater or equal". The effect of these two bugs was that potentially, we could have accepted async messages for an invalid port N, where N is the number of valid ports of this block, and that for TwinRX/X300 users, async messages on channel 1 would not get accepted (they would, however, get accepted for channel 0 because of the second issue). This includes overrun handling, which was broken for channel 1 and 3 on an X300. Another effect of the bug was that EPIDs for async messages weren't always programmed correctly. --- host/lib/rfnoc/radio_control_impl.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'host') diff --git a/host/lib/rfnoc/radio_control_impl.cpp b/host/lib/rfnoc/radio_control_impl.cpp index 5bc16f7cd..3c4c28d11 100644 --- a/host/lib/rfnoc/radio_control_impl.cpp +++ b/host/lib/rfnoc/radio_control_impl.cpp @@ -105,7 +105,7 @@ radio_control_impl::radio_control_impl(make_args_ptr make_args) return; } const size_t port = src.instance; - if (port > get_num_output_ports()) { + if (port >= get_num_output_ports()) { RFNOC_LOG_WARNING("Received stream command to invalid output port!"); return; } @@ -126,7 +126,7 @@ radio_control_impl::radio_control_impl(make_args_ptr make_args) get_mb_controller()->get_timekeeper(0)->get_time_now() + uhd::time_spec_t(OVERRUN_RESTART_DELAY); const size_t port = src.instance; - if (port > get_num_output_ports()) { + if (port >= get_num_output_ports()) { RFNOC_LOG_WARNING("Received stream command to invalid output port!"); return; } @@ -216,7 +216,7 @@ radio_control_impl::radio_control_impl(make_args_ptr make_args) RFNOC_LOG_TRACE("Sending async messages to EPID " << regs().get_src_epid() << ", remote port " << regs().get_port_num() << ", xbar port " << xbar_port); - for (size_t tx_chan = 0; tx_chan < get_num_output_ports(); tx_chan++) { + for (size_t tx_chan = 0; tx_chan < get_num_input_ports(); tx_chan++) { // Set the EPID and port of our regs() object (all async messages go to // the same location) _radio_reg_iface.poke32( @@ -230,7 +230,7 @@ radio_control_impl::radio_control_impl(make_args_ptr make_args) regmap::SWREG_TX_ERR + regmap::SWREG_CHAN_OFFSET * tx_chan, tx_chan); } - for (size_t rx_chan = 0; rx_chan < get_num_input_ports(); rx_chan++) { + for (size_t rx_chan = 0; rx_chan < get_num_output_ports(); rx_chan++) { // Set the EPID and port of our regs() object (all async messages go to // the same location) _radio_reg_iface.poke32( @@ -973,7 +973,7 @@ bool radio_control_impl::async_message_validator( return false; } if (addr_base == regmap::SWREG_RX_ERR) { - if (chan > get_num_output_ports()) { + if (chan >= get_num_output_ports()) { return false; } switch (code) { @@ -986,7 +986,7 @@ bool radio_control_impl::async_message_validator( } } if (addr_base == regmap::SWREG_TX_ERR) { - if (chan > get_num_input_ports()) { + if (chan >= get_num_input_ports()) { return false; } switch (code) { @@ -1039,7 +1039,7 @@ void radio_control_impl::async_message_handler( } switch (addr_base + addr_offset) { case regmap::SWREG_TX_ERR: { - if (chan > get_num_input_ports()) { + if (chan >= get_num_input_ports()) { RFNOC_LOG_WARNING( "Cannot process TX-related async message to invalid chan " << chan); return; @@ -1075,7 +1075,7 @@ void radio_control_impl::async_message_handler( break; } case regmap::SWREG_RX_ERR: { - if (chan > get_num_input_ports()) { + if (chan >= get_num_output_ports()) { RFNOC_LOG_WARNING( "Cannot process RX-related async message to invalid chan " << chan); return; -- cgit v1.2.3