Commit graph

189 commits

Author SHA1 Message Date
Virendra Kakade
a98da1dfd4 rfnoc: fix incorrect long fifo wait timeouts
This fixes behavior where we would get long 100 sec timeouts
on fifo waits instead of 100 ms timeouts.

Signed-off-by: Virendra Kakade <virendra.kakade@ni.com>
2019-11-26 12:21:35 -08:00
Alex Williams
911ca16adc lib: Add DPDK service queue
This is a data structure intended for use by the DPDK I/O service.
It uses DPDK's lockless ring in multi-producer, single-consumer mode
to allow clients to submit requests to the DPDK I/O service's worker
thread. Clients can specify a timeout for the requests to be fulfilled.
2019-11-26 12:21:34 -08:00
Ciro Nishiguchi
c730d7ba20 rfnoc: fix invalid access when sending packet with no samples 2019-11-26 12:21:34 -08:00
Martin Braun
920198556e mg/rh/rfnoc: Harmonize peripheral registers
- Move the SPI addresses out of radio_control_impl
- Fix the GPIO address spaces for N310/N300
2019-11-26 12:21:34 -08:00
Martin Braun
59fae330b0 detail::graph: Add shutdown capability
In the existing graph, when the shutdown was simply a release. However,
any outstanding actions would trigger warnings (because released graphs
aren't supposed to still have actions being passed around), which would
sometimes be visible at the end of an application.

This is a safer solution than simply releasing, because it explicitly
sets a shutdown flag that all graph-affecting functions (property
propagation and action handling) respect. Once the flag is set, the
graph can no longer be booted up again.
2019-11-26 12:21:33 -08:00
Ciro Nishiguchi
837b89e2ec rfnoc: Rename thread affinity args
Rename thread affinity args such that they do not end with an integer.
Arg names ending with an integer are interpreted as being targeted at a
specific motherboard index in device_addr methods.
2019-11-26 12:21:33 -08:00
Alex Williams
f5861562d9 transport: Add new base for DPDK links, based on 18.11
dpdk_ctx represents the central context and manager of all memory
and threads allocated via the DPDK EAL. In this commit, it parses
the user's arguments, configures all the ports, and brings them up.

dpdk_port represents each DPDK NIC port's configuration, and it
manages the allocation of individual queues and their flow rules.
It also would provide access to an ARP table and functions for
handling ARP requests and responses. The flow rules and ARP
functions are not yet implemented.
2019-11-26 12:21:33 -08:00
Ciro Nishiguchi
a8e286b106 rfnoc: Make polling I/O service not block on flow control
Add a new method to io_service::send_io to check whether the destination
is ready for data, to make it possible to poll send_io rather than block
waiting for flow control credits.
2019-11-26 12:21:33 -08:00
Ciro Nishiguchi
10b9d2688b rfnoc: Make I/O services relinquish CPU while waiting 2019-11-26 12:21:33 -08:00
Martin Braun
ea89fd0dd4 rfnoc: xports: Count FC bytes as multiples of CHDR width
SEPs on the FPGA can only occupy multiples of the CHDR width in their
FIFOs, unlike SW, where buffers are stored in RAM and can be aligned
anyhow. Therefore, we align the counting of bytes for FC purpose and
count multiples of CHDR width instead of the true number of bytes per
packet.
2019-11-26 12:21:32 -08:00
Ciro Nishiguchi
b4ef7ca804 rfnoc: Restrict to inline I/O service based on link restrictions
For links that do not support releasing buffers out of order, restrict
the I/O service manager to always select the inline I/O service.
2019-11-26 12:21:32 -08:00
Ciro Nishiguchi
7b95cbd7fd rfnoc: Merge I/O service device args with stream args
This makes it possible for users to put I/O service-related args in
either the device args or stream args.
2019-11-26 12:21:32 -08:00
Ciro Nishiguchi
1cd874911d rfnoc: Split up offload I/O service into multiple files 2019-11-26 12:21:32 -08:00
Martin Braun
d3a16b7022 uhd: Replace all occurrences of boost::bind with std::bind
Note: Replacing everything with a lambda would be even better, but that
can't be easily scripted so we'll do this as a first step to reduce the
Boost footprint.

This also removes occurences of #include <boost/bind.hpp>, and makes
sure all usages of std::bind have an #include <functional>. clang-format
wasn't always applied to minimize the changeset in this commit, however,
it was applied to the blocks of #includes.

Due to conflicts with other Boost libraries, the placeholders _1, _2,
etc. could not be directly used, but had to be explicitly called out
(as std::placeholders::_1, etc.). This makes the use of std::bind even
uglier, which serves as another reminder that using std::bind (and even
more so, boost::bind) should be avoided.

nirio/rpc/rpc_client.cpp still contains a reference to boost::bind. It
was not possible to remove it by simply doing a search and replace, so
it will be removed in a separate commit.
2019-11-26 12:21:32 -08:00
Aaron Rossetto
0bd233e642 uhd: Introduce I/O service manager
- Implement I/O service detach link methods
- The I/O service manager instantiates new I/O services or connects
  links to existing I/O services based on options provided by the user
  in stream_args.
- Add a streamer ID parameter to methods to create transports so that
  the I/O service manager can group transports appropriately when using
  offload threads.
- Change X300 and MPMD to use I/O service manager to connect links to
  I/O services.
- There is now a single I/O service manager per rfnoc_graph (and it is
  also stored in the graph)
- The I/O service manager now also knows the device args for the
  rfnoc_graph it was created with, and can make decisions based upon
  those (e.g, use a specific I/O service for DPDK, share cores between
  streamers, etc.)
- The I/O Service Manager does not get any decision logic with this
  commit, though
- The MB ifaces for mpmd and x300 now access this global I/O service
  manager
- Add configuration of link parameters with overrides

Co-Authored-By: Martin Braun <martin.braun@ettus.com>
Co-Authored-By: Aaron Rossetto <aaron.rossetto@ni.com>
2019-11-26 12:21:32 -08:00
Ciro Nishiguchi
912ed28b3d rfnoc: Make trasnport safe to use with offload threads
Make transports safe to use with an offload thread by ensuring that the
callbacks and the API methods can execute concurrently. Also, ensure
that the transports release their I/O service clients prior to allowing
their other member variables be destroyed.
2019-11-26 12:21:32 -08:00
Aaron Rossetto
2f97f8bd01 transport: Implement eov indications for Rx and Tx streams 2019-11-26 12:21:32 -08:00
Martin Braun
fcc2e9c602 uhd: Replace boost::function with std::function
This is mostly a search-and-replace operation, with few exceptions:
- boost::function has a clear() method. In C++11, this is achieved by
  assigning nullptr to the std::function object.
- The empty() method is replaced by std::function's bool() operator
2019-11-26 12:21:32 -08:00
Martin Braun
1fe98e8701 uhd: Replace usage of boost smart pointers with C++11 counterparts
This removes the following Boost constructs:
- boost::shared_ptr, boost::weak_ptr
- boost::enable_shared_from_this
- boost::static_pointer_cast, boost::dynamic_pointer_cast

The appropriate includes were also removed. All C++11 versions of these
require #include <memory>.
Note that the stdlib and Boost versions have the exact same syntax, they
only differ in the namespace (boost vs. std). The modifications were all
done using sed, with the exception of boost::scoped_ptr, which was
replaced by std::unique_ptr.

References to boost::smart_ptr were also removed.

boost::intrusive_ptr is not removed in this commit, since it does not
have a 1:1 mapping to a C++11 construct.
2019-11-26 12:21:32 -08:00
Ciro Nishiguchi
650c07cbcb transport: Implement an I/O service that uses an offload thread
The offload_io_service executes another I/O service instance within an
offload thread, and provides synchronization mechanisms to communicate
with clients. Frame buffers are passed from the offload thread to the
client and back via single-producer, single-consumer queues.
2019-11-26 12:21:31 -08:00
Martin Braun
f9f9cb0d2c rfnoc: Add DMA FIFO block controller 2019-11-26 12:16:25 -08:00
Martin Braun
7d69dcdcc3 Remove proto-RFNoC files
This commit removes all files and parts of files that are used by
proto-RFNoC only.

uhd: Fix include CMakeLists.txt, add missing files
2019-11-26 12:16:25 -08:00
Martin Braun
c256b9df65 x300/mpmd: Port all RFNoC devices to the new RFNoC framework
Co-Authored-By: Alex Williams <alex.williams@ni.com>
Co-Authored-By: Sugandha Gupta <sugandha.gupta@ettus.com>
Co-Authored-By: Brent Stapleton <brent.stapleton@ettus.com>
Co-Authored-By: Ciro Nishiguchi <ciro.nishiguchi@ni.com>
2019-11-26 12:16:25 -08:00
Martin Braun
67dbaa41f2 rfnoc: radio: Add API call to disable timestamps
By calling radio_control::enable_rx_timestamps(false, chan), the radio
will not add timestamps to outgoing packets.
2019-11-26 11:49:46 -08:00
Alex Williams
ebef8c3419 transport: Port liberio to link_if 2019-11-26 11:49:46 -08:00
Ciro Nishiguchi
f312d82760 rfnoc: Fix transport buffer reservations
Change transports to reserve the number of frame buffers they actually
need from the I/O service. Previously some I/O service clients reserved
0 buffers since they shared frame buffers with other clients, as we know
the two clients do not use the links simultaneously. This is possible
with the inline_io_service but not with a multithreaded I/O service
which queues buffer for clients before they are requested.
2019-11-26 11:49:45 -08:00
Ciro Nishiguchi
98209df92e streamer: Add option to ignore sequence errors
Add template parameter to ignore sequence errors, used for testing.
2019-11-26 11:49:45 -08:00
Ciro Nishiguchi
0e2464ad88 rfnoc: Move data xport sep configuration to static methods
Move the configuration logic for stream endpoints to static methods of
the chdr data transports. This separates those interactions from the
main transport code, simplifying both. It also makes it easier to use
the transports with mock link objects.
2019-11-26 11:49:43 -08:00
Brent Stapleton
23f4f8cf4e rfnoc: Add multi_usrp_rfnoc, modify multi_usrp
This adds a separate version of multi_usrp for RFNoC devices. It is
compatible with RFNoC devices only, and prefers C++ APIs over property
tree usage. The factory of multi_usrp is modified such that it picks the
correct version, users of multi_usrp don't care about this change.

This also introduces some API changes:
- Removing redundant GPIO functions. Now all GPIO control, setting, and
  readback is done with uint32_t's.
- Adding getter/setter for GPIO source. This was done to simplify the
  other GPIO settings, as the source for each pin is not always a
  binary. The CTRL mode, for example, can either be ATR or GPIO.
  However, the source can be controlled by various radios or "PS" or
  some other source.
- Removing the mask from the RFNoC radio controllers' set_gpio_attr().
- Adding state caching to gpio_atr_3000, and a getter for it. Whenever
  an attribute is set, that value is cached, and can now be retreieved.
- Remove low-level register API. Since UHD 3.10, there is no USRP that
  implements that API.
Modifying the filter API in the following ways:
- Splitting filter API getter/setter/list into separate RX and TX
  functions
- Adding channel numbers as an argument
- The filter name will no longer be a property tree path, but rather a
  filter name. For RFNoC devices, this will take the form
  `BLOCK_ID:FILTER_NAME`. For non-RFNoC devices, this will just be the
  filter name (e.g. `HB_1`)
- Removing search mask from listing function. Users can do their own
  searching

Co-Authored-By: Martin Braun <martin.braun@ettus.com>
2019-11-26 11:49:42 -08:00
Martin Braun
027cf1fe9b rfnoc: radio/streamer: Handle late commands and burst ACKs
- Burst ACKs are already handled by the TX streamer, but the radio now
  also sends an action upstream on reception of a burst ACK
- Late commands were only acquitted by an 'L', now an action gets sent
  downstream and is handled in the rx streamer
2019-11-26 11:49:42 -08:00
Ciro Nishiguchi
77a5358dd0 rfnoc: Add MTU property to RX streamer 2019-11-26 11:49:42 -08:00
Ciro Nishiguchi
f5e726b0ad rfnoc: Implement flushing on overrun
This modifies the overrun handling such that the RX streamer does not
restart the radios until the packets that were buffered prior to the
overrun are read by the user.

When an RX streamer receives an overrun, it will run the following
algorithm:
1. Stop all upstream producers.
2. Set an internal flag in the streamer that indicates that the
   producers have stopped due to an overrun.
3. Continue servicing calls to recv until it runs out of packets in the
   host buffer (packets that can be read from the transport using a 0
   timeout).
4. Once the packets are exhausted, return an overrun error from recv.

The radio, if it was in continuous streaming mode before the overrun,
includes a flag in its initial action whether or not to restart
streaming.

5. If the radio requested a restart, the streamer submits a restart
   request action upstream. This action will be received by the radio.
   The radio will then check the current time, and send a stream command
   action back downstream.
6. The RX streamer receives the stream command action, and uses it to
   send another stream command to all upstream producers. This way, all
   upstream producers receive a start command for the same time.
2019-11-26 11:49:41 -08:00
Martin Braun
4c6ee083ef rfnoc: Add nirio_link link object 2019-11-26 11:49:40 -08:00
Alex Williams
a4274c19eb rfnoc: Use adapter_id_t for balancing load across links
Since the mb_iface allocates local device IDs, also have it track
the associated adapter IDs and provide a facility to retrieve them.
Incorporate the adapter IDs in the user API to select the adapter
for streamers.
2019-11-26 11:49:40 -08:00
Brent Stapleton
81bd789694 rfnoc: ctrlport: Fixing timeouts for timed commands
When issuing a timed command, if there is no room in the command FIFO
and there is a timed command queue'd up, wait for a long time before
timing out.
2019-11-26 11:49:39 -08:00
Martin Braun
932ff0537b rfnoc: client_zero can track num SEPs and num ctrl EPs separately 2019-11-26 11:49:39 -08:00
Alex Williams
01284980b1 transport: Add modeling of physical adapters
Now link instances must have the ability to report the corresponding
physical adapter that is used for the local side of the link. This
information can be used to help identify when multiple links share
the same adapter.
2019-11-26 11:49:38 -08:00
Alex Williams
117af6f0b0 rfnoc: Add ability to select transport for streamers to user APIs
Now the user can choose which transport is used in connect() calls.
2019-11-26 11:49:36 -08:00
Ciro Nishiguchi
bffef674fb rfnoc: tx_streamer: add support for async messages
Add an async message queue that aggregates errors from multiple sources.
Errors can come from the strs packets originating from the stream
endpoint or from the radio block through control packets to the host.
2019-11-26 11:49:36 -08:00
Alex Williams
91e01c4844 rfnoc: Centralize initialization state of SEPs to epid_allocator
Because the initialization state of SEPs is a graph-wide property,
link_stream_managers and mgmt_portals cannot rely on their private
members to determine if they can reset an SEP. Move the call to
init SEPs into the epid_allocator, and have it call into a
mgmt_portal to gain access to the SEP.

Thus, link_stream_managers only request that an epid_allocator
ensure an SEP is numbered and initialized, and they provide a path
to communicate with the SEP. The epid_allocator will ensure init
only happens once, so a stream currently running on another
link_stream_manager does not get interrupted. This could happen,
for example, if the OSTRM went to one device, and the ISTRM came
from another. In general, EPIDs should only be assigned once.
2019-11-26 11:49:36 -08:00
Alex Williams
0fc57b99b9 rfnoc: Use link_stream_manager's mgmt_portal for all mgmt packets
Change data transports to use the mgmt_portal from the
link_stream_manager. The initialization state of a device's EPIDs
needs to be shared amongst all the SEP users. Otherwise, an RX
transport may attempt to do a full reset of the SEP while TX is
streaming (for example).

TODO: The code contained here is not sufficient to handle multiple
links that can access the same SEPs, as those would have different
link_stream_managers, and thus, different mgmt_portal instances and
views of the SEP state.
2019-11-26 11:49:36 -08:00
Martin Braun
7bac67af08 rfnoc: client0: Change flush-all-blocks to not throw on timeout
The convenience call that flushed all the blocks would throw during
timeout. Now, it returns a bool whether or not the flush was successful.
2019-11-26 11:49:36 -08:00
Martin Braun
bddaac5e26 rfnoc: graph: Optimize property propagation algorithm
This introduces the concept of a resolution context, because the
property propagation algorithm needs to behave differently when called
during an initialization step (e.g. when the graph is committed), or
when the user changes a property on one of the nodes after it was
committed.

The algorithm is modified as follows:

- When called during an initialization step, then all nodes get resolved
  at least once. If nodes added new properties, then all nodes get
  touched again until the max number of iterations is reached.
- When called because a node modified one of its properties, then that
  node is always resolved first. From there, all other nodes are
  resolved in topological order. However, the algorithm immediately
  terminates as soon as there are no more dirty nodes.
- When called because a node modified one of its properties, but the
  graph is currently not in a committed state, then that node will do
  a local property resolution.
2019-11-26 11:49:36 -08:00
Ciro Nishiguchi
35db8f741b rfnoc: Add MTU property to TX streamer 2019-11-26 11:49:35 -08:00
Martin Braun
ec991efc06 rfnoc: graph: Lock release/commit state
Property propagation and action handling depend on the release state,
but they are lengthy operations. It is therefore imperative to not
change the release/commit state during those methods.

This commit changes the following:
- Change the release state counter from an atomic to a non-atomic
  variable
- Instead, use a mutex to lock the release state counter, and use the
  same mutex for locking access to the property propagation and action
  handling

The rfnoc_graph now tries to release the graph before shutting down
blocks to make sure they don't get destroyed while those algorithms are
still running.
2019-11-26 11:49:34 -08:00
Martin Braun
1e51dd7774 rfnoc: radio: Add async message validation
This adds a method to the radio to check if an async message is valid,
which can be used to ack async messages immediately.
2019-11-26 11:49:34 -08:00
Martin Braun
d717feaf3d rfnoc: radio: Introduce coerce_rate() method
This is a helper method for property resolution, where set_rate() is not
appropriate.
2019-11-26 11:49:34 -08:00
Martin Braun
ab87597e9e rfnoc: Implement overrun handling using action API
In order to enable overrun handling through the action API, a few new
features are implemented:
- The RX streamer can now accept stream command actions. The streamer
  will interpret stream command actions as a request to send stream
  commands upstream to all producers.
- A new action type is defined ('restart request') which is understood
  by the radio and streamer, and is a handshake between producers and
  consumers. In this case, it will ask the radio to send a stream
  command itself.

When an RX streamer receives an overrun, it will now run the following
algorithm:
1. Stop all upstream producers (this was already in the code before this
   commit).
2. If no restart is required, Wait for the radios to have space in the
   downstream blocks.

The radio, if it was in continuous streaming mode before the overrun,
includes a flag in its initial action whether or not to restart the
streaming. Also, it will wait for the stop stream command from the
streamer. When it receives that, it will initiate a restart request
handshake.

3. The streamer submits a restart request action upstream. This action
   will be received by the radio.
   The radio will then check the current time, and send a stream command
   action back downstream.
4. The RX streamer receives the stream command action, and uses it to
   send another stream command to all upstream producers. This way, all
   upstream producers receive a start command for the same time.
2019-11-26 11:49:32 -08:00
Martin Braun
83abb81e61 rfnoc: actions: Allow sending actions to self
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.
2019-11-26 11:49:32 -08:00
Lars Amsel
2a66eb62d8 rfnoc: Introduce device-specific blocks
- Add device ID constants (e.g., E310 == 0xE310, X300 == 0xA300). These
  are stored in the device FPGA, and can be used for decisions later
- Blocks can be specific to a device. For example, x300_radio_control
  can only work on an X300 series device.
- Because blocks can be device-specific, all radio blocks can now share
  a common Noc-ID (0x12AD1000).
- The registry and factory functions are modified to acommodate for
  this.
  - The motherboard access is now also factored into the same registry
    macro.
2019-11-26 11:49:32 -08:00