aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/rfnoc/radio_control_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/rfnoc/radio_control_impl.cpp')
-rw-r--r--host/lib/rfnoc/radio_control_impl.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/host/lib/rfnoc/radio_control_impl.cpp b/host/lib/rfnoc/radio_control_impl.cpp
index 3c4c28d11..697bb2549 100644
--- a/host/lib/rfnoc/radio_control_impl.cpp
+++ b/host/lib/rfnoc/radio_control_impl.cpp
@@ -139,8 +139,11 @@ radio_control_impl::radio_control_impl(make_args_ptr make_args)
_type_in.reserve(get_num_input_ports());
_type_out.reserve(get_num_output_ports());
for (size_t chan = 0; chan < get_num_output_ports(); ++chan) {
+ // Default SPP is the maximum value we can fit through the edge, given our MTU
+ const int default_spp =
+ get_max_spp(get_max_payload_size({res_source_info::OUTPUT_EDGE, chan}));
_spp_prop.push_back(
- property_t<int>(PROP_KEY_SPP, DEFAULT_SPP, {res_source_info::USER, chan}));
+ property_t<int>(PROP_KEY_SPP, default_spp, {res_source_info::USER, chan}));
_samp_rate_in.push_back(property_t<double>(
PROP_KEY_SAMP_RATE, get_tick_rate(), {res_source_info::INPUT_EDGE, chan}));
_samp_rate_out.push_back(property_t<double>(
@@ -166,17 +169,15 @@ radio_control_impl::radio_control_impl(make_args_ptr make_args)
{&_spp_prop.back()},
[this, chan, &spp = _spp_prop.back()]() {
RFNOC_LOG_TRACE("Calling resolver for spp@" << chan);
- // MTU is max payload size, header with timestamp is already
- // accounted for
- const int mtu =
- static_cast<int>(get_mtu({res_source_info::OUTPUT_EDGE, chan}));
- const int mtu_samps = mtu / (_samp_width / 8);
- const int max_spp_per_mtu = mtu_samps - (mtu_samps % _spc);
- if (spp.get() > max_spp_per_mtu) {
- RFNOC_LOG_DEBUG("spp value " << spp.get() << " exceeds MTU of "
- << mtu << "! Coercing to "
- << max_spp_per_mtu);
- spp = max_spp_per_mtu;
+ const size_t max_pyld =
+ get_max_payload_size({res_source_info::OUTPUT_EDGE, chan});
+ const int max_spp = get_max_spp(max_pyld);
+ if (spp.get() > max_spp) {
+ RFNOC_LOG_DEBUG("spp value "
+ << spp.get() << " exceeds MTU of "
+ << get_mtu({res_source_info::OUTPUT_EDGE, chan})
+ << "! Coercing to " << max_spp);
+ spp = max_spp;
}
if (spp.get() % _spc) {
spp = spp.get() - (spp.get() % _spc);
@@ -185,7 +186,7 @@ radio_control_impl::radio_control_impl(make_args_ptr make_args)
<< spp.get());
}
if (spp.get() <= 0) {
- spp = DEFAULT_SPP;
+ spp = max_spp;
RFNOC_LOG_WARNING(
"spp must be greater than zero! Coercing to " << spp.get());
}
@@ -198,7 +199,6 @@ radio_control_impl::radio_control_impl(make_args_ptr make_args)
chan,
&samp_rate_in = _samp_rate_in.at(chan),
&samp_rate_out = _samp_rate_out.at(chan)]() {
- const auto UHD_UNUSED(log_chan) = chan;
RFNOC_LOG_TRACE("Calling resolver for samp_rate@" << chan);
samp_rate_in = coerce_rate(samp_rate_in.get());
samp_rate_out = samp_rate_in.get();
@@ -1109,3 +1109,9 @@ void radio_control_impl::async_message_handler(
boost::format("Received async message to invalid addr 0x%08X!") % addr));
}
}
+
+int radio_control_impl::get_max_spp(const size_t bytes)
+{
+ const int packet_samps = bytes / (_samp_width / 8);
+ return packet_samps - (packet_samps % _spc);
+}