aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/include/uhd/rfnoc/noc_block_base.hpp7
-rw-r--r--host/lib/rfnoc/noc_block_base.cpp9
2 files changed, 15 insertions, 1 deletions
diff --git a/host/include/uhd/rfnoc/noc_block_base.hpp b/host/include/uhd/rfnoc/noc_block_base.hpp
index 0514849c4..dbb20b8d2 100644
--- a/host/include/uhd/rfnoc/noc_block_base.hpp
+++ b/host/include/uhd/rfnoc/noc_block_base.hpp
@@ -204,7 +204,9 @@ protected:
* noc_block_base. If an RFNoC block subclassing noc_block_base wants to
* modify the MTU forwarding policy, it would typically call this function
* in its constructor. Once set, however, the MTU forwarding policy cannot
- * be changed.
+ * be changed. This represents a change in behaviour from UHD 4.0.
+ * Violations of this restriction will result in a uhd::runtime_error being
+ * thrown.
*/
void set_mtu_forwarding_policy(const forwarding_policy_t policy);
@@ -294,6 +296,9 @@ private:
//! Forwarding policy for the MTU properties
forwarding_policy_t _mtu_fwd_policy = forwarding_policy_t::DROP;
+ //! Flag indicating if MTU forwarding property has been set yet
+ bool _mtu_fwd_policy_set = false;
+
//! Container for the 'mtu' property. This will hold one edge property
// for all in- and output edges.
std::vector<property_t<size_t>> _mtu_props;
diff --git a/host/lib/rfnoc/noc_block_base.cpp b/host/lib/rfnoc/noc_block_base.cpp
index b4a15509f..4245ea5db 100644
--- a/host/lib/rfnoc/noc_block_base.cpp
+++ b/host/lib/rfnoc/noc_block_base.cpp
@@ -159,6 +159,15 @@ void noc_block_base::_set_tick_rate(const double tick_rate)
void noc_block_base::set_mtu_forwarding_policy(const forwarding_policy_t policy)
{
+ // Error if the MTU forwarding policy has already been set--it can only be
+ // set once per instance of the block
+ if (_mtu_fwd_policy_set) {
+ RFNOC_LOG_ERROR("Attempt to re-set MTU forwarding policy");
+ throw uhd::runtime_error("MTU forwarding policy can only be set once per "
+ "NoC block instance");
+ }
+ _mtu_fwd_policy_set = true;
+
if (policy == forwarding_policy_t::DROP || policy == forwarding_policy_t::ONE_TO_ONE
|| policy == forwarding_policy_t::ONE_TO_ALL
|| policy == forwarding_policy_t::ONE_TO_FAN) {