summaryrefslogtreecommitdiffstats
path: root/host/lib/transport
diff options
context:
space:
mode:
authorBen Hilburn <ben.hilburn@ettus.com>2014-03-27 17:42:28 -0700
committerBen Hilburn <ben.hilburn@ettus.com>2014-03-27 17:42:28 -0700
commitb1073740a95f3ba9d62f83956430386448e1b528 (patch)
tree28793534170198cf49620f8b08922288f6c21077 /host/lib/transport
parentf8753a3d7f3616a49f6c0a1ae661f286a4f20c66 (diff)
parenta8d4649c4e95a5d8ccfe3c52fdbfc05c984f3acc (diff)
downloaduhd-b1073740a95f3ba9d62f83956430386448e1b528.tar.gz
uhd-b1073740a95f3ba9d62f83956430386448e1b528.tar.bz2
uhd-b1073740a95f3ba9d62f83956430386448e1b528.zip
Merge branch 'origin/x300/bug386' for flushing buffers smarter.
Diffstat (limited to 'host/lib/transport')
-rw-r--r--host/lib/transport/nirio_zero_copy.cpp35
1 files changed, 21 insertions, 14 deletions
diff --git a/host/lib/transport/nirio_zero_copy.cpp b/host/lib/transport/nirio_zero_copy.cpp
index 7b1e32fe0..c3c8a9368 100644
--- a/host/lib/transport/nirio_zero_copy.cpp
+++ b/host/lib/transport/nirio_zero_copy.cpp
@@ -18,7 +18,6 @@
#include <uhd/transport/nirio_zero_copy.hpp>
#include <stdio.h>
#include <uhd/transport/nirio/nirio_fifo.h>
-#include <uhd/transport/nirio/nirio_fifo.h>
#include <uhd/transport/buffer_pool.hpp>
#include <uhd/utils/msg.hpp>
#include <uhd/utils/log.hpp>
@@ -261,19 +260,27 @@ private:
UHD_INLINE void _flush_rx_buff()
{
- nirio_status flush_status = 0;
- while (nirio_status_not_fatal(flush_status)) {
- static const size_t NUM_ELEMS_TO_FLUSH = 1;
- static const uint32_t FLUSH_TIMEOUT_IN_MS = 0;
-
- fifo_data_t* flush_data_ptr = NULL;
- size_t flush_elems_acquired = 0, flush_elems_remaining = 0;
- flush_status = _recv_fifo->acquire(
- flush_data_ptr, NUM_ELEMS_TO_FLUSH, FLUSH_TIMEOUT_IN_MS,
- flush_elems_acquired, flush_elems_remaining);
- if (nirio_status_not_fatal(flush_status)) {
- _recv_fifo->release(flush_elems_acquired);
- }
+ // acquire is called with 0 elements requested first to
+ // get the number of elements in the buffer and then
+ // repeatedly with the number of remaining elements
+ // until the buffer is empty
+ fifo_data_t* elems_buffer;
+ for (size_t num_elems_requested = 0,
+ num_elems_acquired = 0,
+ num_elems_remaining = 1;
+ num_elems_remaining;
+ num_elems_requested = num_elems_remaining)
+ {
+ nirio_status status = _recv_fifo->acquire(
+ elems_buffer,
+ num_elems_requested,
+ 0, // timeout
+ num_elems_acquired,
+ num_elems_remaining);
+ // throw excetption if status is fatal
+ nirio_status_to_exception(status,
+ "NI-RIO PCIe data transfer failed during flush.");
+ _recv_fifo->release(num_elems_acquired);
}
}