aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/rfnoc/node.cpp
Commit message (Collapse)AuthorAgeFilesLines
* graph: Restore default resolver callback at node removalAaron Rossetto2020-11-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The default resolve callback behavior for a newly-instantiated `node_t` object resolves all dirty properties associated with the node, then marks the properties as clean. When the node is added to a graph, its resolver callback is updated to use the graph property propagation algorithm in `graph_t::resolve_all_properties()`, which is considerably more sophisticated and relies on the graph topology to do its work. When a connection between two nodes is broken via the `graph::disconnect()` method, nodes which no longer have incoming or outgoing edges (connections) are removed from the graph. Prior to this change, the removed node's resolver callback was left pointing at the graph property propagation algorithm. In certain use cases, this could result in unexpected client-facing behavior. Consider, for example, this code (incomplete and for illustrative purposes only) which creates a streamer on one transmit chain of a multi-channel device, destroys that streamer, then creates a stream on the other transmit chain. Attempting to set the TX rate on the first chain after destroying the streamer does not result in the expected rate change, despite the same code working correctly before creating the streamer: constexpr size_t CH0 = ..., CH1 = ...; uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(...); // Set a TX rate on both chains; this succeeds usrp->set_tx_rate(initial_rate, CH0); usrp->set_tx_rate(initial_rate, CH1); assert(initial_rate == usrp->get_tx_rate(CH0)); assert(initial_rate == usrp->get_tx_rate(CH1)); // Create a TX streamer for channel 0 std::vector<size_t> chain0_chans{CH0}; stream_args_t sa; sa.channels = chain0_chans; sa.otw_format = ...; sa.cpu_format = ...; uhd::tx_streamer::sptr txs = usrp->get_tx_stream(sa); // Destroy the first streamer (disconnecting the graph) and // create a streamer for channel 1 txs.reset(); std::vector<size_t> chain1_chans{CH1}; sa.channels = chain1_chans; txs = usrp->get_tx_stream(sa); // Now try to set a new TX rate on both chains usrp->set_tx_rate(updated_rate, CH0); usrp->set_tx_rate(updated_rate, CH1); assert(updated_rate == usrp->get_tx_rate(CH0)); // <--- FAILS assert(updated_rate == usrp->get_tx_rate(CH1)); The reason this fails is because the second call to `set_tx_rate()` on channel 0 internally sets the 'interp' (interpolation ratio) property on the DUC node via the call to the DUC block controller's `set_input_rate()` function. As the DUC node is no longer part of the graph, having been removed from it when the first streamer instance was destroyed, the graph property propagation algorithm doesn't 'see' the node with the dirty property, and the 'interp' property resolver callback is never invoked. As a result, the DUC's input rate property, which depends on the interpolation ratio value, is never updated, and thus calling the `get_tx_rate()` function to query the new rate of the TX chain results in an unexpected value. In fact, in this particular case, `set_tx_rate()` actually raises a warning that the TX rate couldn't be set, and a message is printed to the console. This commit remedies the situation by restoring the default resolve callback behavior for a node when it is removed from the graph. This allows the framework to be able to invoke the property resolver callback on that node when a property is updated, the expected behavior of a newly instantiated node.
* rfnoc: Support instance overrides in set_properties()Aaron Rossetto2020-07-241-2/+19
| | | | | | | | | | | | | | | | | | | | | | | This commit adds an enhancement to node_t::set_properties() in which the instance argument provided to the function (which normally applies to all properties in the key/value list) can be overridden on a per-property basis using a special syntax. If the key consists of the property name followed by a colon (':') and then a number, the number following the colon is used to determine which instance of the property this set pertains to, and the value passed via the instance parameter is ignored for that property. For example, in the following call: node->set_properties("dog=10,cat:2=5,bird:0=0.5", 1) instance 1 of node's 'dog' property is set to 10, the 1 coming from the instance parameter, instance 2 of the node's 'cat' property is set to 5 due to the override syntax provided in the string, and instance 0 of the node's 'bird' property is set to 0.5 due to its override. If the name/instance pair is malformed, e.g. 'value:=10' or 'value:foobar=10', a runtime error is thrown.
* rfnoc: Add USE_MAP prop/action forwarding policyAaron Rossetto2020-05-281-17/+61
| | | | | | | | | | | | This commit adds a new forwarding policy for properties and actions, USE_MAP. This forwarding policy causes the node to consult a user-provided map to determine how to forward the property or action. The map's key is the source edge of the incoming property or action, while the value is a list of destination edges to which the property should be propagated or action should be forwarded. It allows clients to construct sophisticated forwarding behaviors for specialized blocks, such as a split stream block that needs to forward properties and actions only to specific output edges based on the incoming edge.
* rfnoc: Fix _has_port() port existence checkAaron Rossetto2020-05-281-2/+2
| | | | | | This commit fixes a bug in node_t::_has_port(), which was using the wrong comparison operator to determine if the instance value in the incoming res_source_info parameter is within a valid range.
* uhd: Apply clang-format against all .cpp and .hpp files in host/Martin Braun2020-03-031-28/+23
| | | | | Note: template_lvbitx.{cpp,hpp} need to be excluded from the list of files that clang-format gets applied against.
* rfnoc: Add DMA FIFO block controllerMartin Braun2019-11-261-1/+1
|
* rfnoc: node: Add set_properties()Martin Braun2019-11-261-0/+19
| | | | | node_t::set_properties() is a convenience function that lets you set multiple properties at once from a device_addr_t.
* rfnoc: actions: Allow sending actions to selfMartin Braun2019-11-261-0/+6
| | | | | | | | Sending actions to self is useful because calling post_action() from within an action handler will not actually trigger the action. Instead, it will defer delivery of the action. Allowing sending actions to self will allow to add another action, in deterministic order, and the execution of another action handler.
* rfnoc: node: Make register_property() unlock RW accessMartin Braun2019-11-261-1/+4
|
* rfnoc: Add tracking of 'valid' bit to propertiesAlex Williams2019-11-261-0/+9
| | | | | | The valid bit helps prevent placeholder defaults from being propagated through the graph. Values that are not valid will not be forwarded.
* rfnoc: Add shutdown feature to blocksMartin Braun2019-11-261-0/+5
| | | | | | | | On destruction, the rfnoc_graph will call shutdown() on all blocks. This allows a safe de-initialization of blocks independent of the lifetime of the noc_block_base::sptr. Also adds the shutdown feature to null_block_control.
* rfnoc: Add check_topology() API to nodesMartin Braun2019-11-261-0/+17
| | | | | This API lets blocks decide if their current topology is OK for them, and make decisions based on their topology.
* rfnoc: node: Fix resolution of properties with circular dependenciesMartin Braun2019-11-261-41/+51
| | | | | | | When a node has multiple properties that depend on each other (and possible have circular dependencies), the previous version of property propagation would not correctly resolve properties that got flagged dirty during the execution of other resolvers.
* rfnoc: node: Add default command time APIMartin Braun2019-11-261-0/+23
|
* rfnoc: Add action APIMartin Braun2019-11-261-0/+87
| | | | | | | | - Added action_info class - Allow to send actions from node to node - Allow to post actions into nodes - Allow to set default forwarding policies - Added unit tests
* rfnoc: Add property propagation, Boost.Graph storageMartin Braun2019-11-261-9/+303
| | | | | | | | | | | | - Adds a detail::graph_t class, which handles the propagation - Adds methods to node_t to aid with propagation - Adds unit tests - Adds dynamic property forwarding: Nodes are now able to forward properties they don't know about by providing a forwarding policy. A good example is the FIFO block which simply forwards most properties verbatim. - node: Temporarily disabling consistency check at init
* rfnoc: Add properties, nodes, and accessorsMartin Braun2019-11-261-0/+119
Adds the following classes: - uhd::rfnoc::node_t, the base class for RFNoC nodes - uhd::rfnoc::node_accessor_t, a class to access private properties - uhd::rfnoc::res_source_info, a struct that identifies where properties come from - uhd::rfnoc::property_t, and property_base_t (its parent) - uhd::rfnoc::prop_accessor_t, a class to access properties Add always dirty property (dirtifier). Also adds unit tests for properties.