diff options
author | Martin Braun <martin.braun@ettus.com> | 2022-01-26 09:57:43 +0100 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-02-01 14:40:41 -0600 |
commit | cba3c8351d39a67262114a0d419b5c708cdb2c2b (patch) | |
tree | 4146e86c4363b6fa5349e48e48b2645a0f67801f | |
parent | c3327801ca43f3fdeca669e3aff470ce05e439a0 (diff) | |
download | uhd-cba3c8351d39a67262114a0d419b5c708cdb2c2b.tar.gz uhd-cba3c8351d39a67262114a0d419b5c708cdb2c2b.tar.bz2 uhd-cba3c8351d39a67262114a0d419b5c708cdb2c2b.zip |
rfnoc: Set the default MTU forwarding policy to ONE_TO_ONE.
Previously, the default was DROP. For almost all RFNoC blocks, this is
not a good default. It is very easy to crash USRPs by not properly
propagating the MTU. For example, the following flow graph:
Radio -> DDC -> FIR -> Streamer
would crash an X310 when not manually setting an spp value. The reason
is: The Radio block has an output buffer of 8192 bytes, capable of
handling 2044 samples per packet. However, that's too big for the
Ethernet portion of the X310, which would cause the X310 to lose
connection between UHD and firmware. If the FIR were configured to
propagate MTU, the Host->USRP connection (which has an MTU of <= 8000)
would limit the MTU on all links, and the spp value would automatically
be reduced to 1996 (or less).
This commit uses the post_init() feature to check the user set an MTU in
the constructor, and sets it to the default if that didn't happen. This
doesn't solve all problems (the new default of ONE_TO_ONE) could also be
incorrect, but is a much more suitable default.
As a consequence, this has a minor change in how
set_mtu_forwarding_policy() can be used: It now must be called during
the constructor. Before, the rule was that it may only be called once,
but that could also have happened, e.g., during the first property
resolution. Now, the constructor is the last time block authors can
choose an MTU forwarding policy.
-rw-r--r-- | host/include/uhd/rfnoc/noc_block_base.hpp | 18 | ||||
-rw-r--r-- | host/lib/rfnoc/noc_block_base.cpp | 7 |
2 files changed, 15 insertions, 10 deletions
diff --git a/host/include/uhd/rfnoc/noc_block_base.hpp b/host/include/uhd/rfnoc/noc_block_base.hpp index b18de41fc..454fb288b 100644 --- a/host/include/uhd/rfnoc/noc_block_base.hpp +++ b/host/include/uhd/rfnoc/noc_block_base.hpp @@ -261,15 +261,15 @@ protected: * all opposite side ports. This is an appropriate policy for the * split-stream block. * - * The default policy is DROP. + * The default policy is ONE_TO_ONE. * - * Note: The MTU forwarding policy can only be set ONCE per instance of a - * 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. This represents a change in behaviour from UHD 4.0. - * Violations of this restriction will result in a uhd::runtime_error being - * thrown. + * Note: The MTU forwarding policy can only be set once, and only during + * construction of a noc_block_base. If an RFNoC block subclassing + * noc_block_base wants to modify the MTU forwarding policy, it must call + * this function in its constructor. Once set, however, the MTU forwarding + * policy cannot 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); @@ -358,7 +358,7 @@ private: std::vector<property_t<double>> _tick_rate_props; //! Forwarding policy for the MTU properties - forwarding_policy_t _mtu_fwd_policy = forwarding_policy_t::DROP; + forwarding_policy_t _mtu_fwd_policy = forwarding_policy_t::ONE_TO_ONE; //! Flag indicating if MTU forwarding property has been set yet bool _mtu_fwd_policy_set = false; diff --git a/host/lib/rfnoc/noc_block_base.cpp b/host/lib/rfnoc/noc_block_base.cpp index f854ca8d4..a43249e47 100644 --- a/host/lib/rfnoc/noc_block_base.cpp +++ b/host/lib/rfnoc/noc_block_base.cpp @@ -352,7 +352,12 @@ void noc_block_base::shutdown() void noc_block_base::post_init() { - // nop + // Verify the block set its MTU forwarding policy. If not, set it to the + // default value. + if (!_mtu_fwd_policy_set) { + RFNOC_LOG_INFO("Setting default MTU forward policy."); + set_mtu_forwarding_policy(_mtu_fwd_policy); + } } std::shared_ptr<mb_controller> noc_block_base::get_mb_controller() |