aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests/common
diff options
context:
space:
mode:
authorCiro Nishiguchi <ciro.nishiguchi@ni.com>2019-10-28 14:28:33 -0500
committerMartin Braun <martin.braun@ettus.com>2019-11-26 12:21:33 -0800
commita8e286b106f19c37d6cf20de886c65f3c04da162 (patch)
tree5c1baf4310abc0e4e082c960dffabd18a9fb6a3e /host/tests/common
parent10b9d2688b5bcb150eec786a9ef7473f1c1c28ac (diff)
downloaduhd-a8e286b106f19c37d6cf20de886c65f3c04da162.tar.gz
uhd-a8e286b106f19c37d6cf20de886c65f3c04da162.tar.bz2
uhd-a8e286b106f19c37d6cf20de886c65f3c04da162.zip
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.
Diffstat (limited to 'host/tests/common')
-rw-r--r--host/tests/common/mock_transport.hpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/host/tests/common/mock_transport.hpp b/host/tests/common/mock_transport.hpp
index 321f22830..a8dc761f1 100644
--- a/host/tests/common/mock_transport.hpp
+++ b/host/tests/common/mock_transport.hpp
@@ -40,12 +40,13 @@ public:
uint16_t src_addr,
uint32_t credits)
: _credits(credits)
+ , _frame_size(send_link->get_send_frame_size())
{
_send_addr = (dst_addr << 16) | (src_addr << 0);
_recv_addr = (src_addr << 16) | (dst_addr << 0);
/* Make message client for sending side-band messages */
- send_io_if::send_callback_t msg_send_cb = [this](frame_buff::uptr& buff,
+ send_io_if::send_callback_t msg_send_cb = [this](frame_buff::uptr buff,
send_link_if* link) {
uint32_t* data = (uint32_t*)buff->data();
data[ADDR_OFFSET] = this->_send_addr;
@@ -53,21 +54,25 @@ public:
link->release_send_buff(std::move(buff));
};
_msg_if = io_srv->make_send_client(
- send_link, MSG_BUFFS, msg_send_cb, recv_link_if::sptr(), 0, nullptr);
+ send_link, MSG_BUFFS, msg_send_cb, recv_link_if::sptr(), 0, nullptr, nullptr);
/* Make client for sending streaming data */
- send_io_if::send_callback_t send_cb = [this](frame_buff::uptr& buff,
+ send_io_if::send_callback_t send_cb = [this](frame_buff::uptr buff,
send_link_if* link) {
- this->send_buff(buff, link);
+ this->send_buff(std::move(buff), link);
};
recv_callback_t recv_cb = [this](frame_buff::uptr& buff,
recv_link_if* link,
send_link_if* /*send_link*/) {
return this->recv_buff(buff, link);
};
+ send_io_if::fc_callback_t fc_cb = [this](size_t) {
+ return this->_seqno < this->_ackno + this->_credits;
+ };
+
/* Pretend get 1 flow control message per sent packet */
_send_if = io_srv->make_send_client(
- send_link, credits, send_cb, recv_link, credits, recv_cb);
+ send_link, credits, send_cb, recv_link, credits, recv_cb, fc_cb);
}
~mock_send_transport() {}
@@ -99,6 +104,10 @@ public:
*/
frame_buff::uptr get_data_buff(int32_t timeout_ms)
{
+ if (!_send_if->wait_for_dest_ready(_frame_size, timeout_ms)) {
+ return frame_buff::uptr();
+ }
+
frame_buff::uptr buff = _send_if->get_send_buff(timeout_ms);
if (!buff) {
return frame_buff::uptr();
@@ -138,11 +147,8 @@ public:
* Callbacks execute on the I/O thread! Be careful about what state is
* touched. In addition, this callback should NOT sleep.
*/
- void send_buff(frame_buff::uptr& buff, send_link_if* send_link)
+ void send_buff(frame_buff::uptr buff, send_link_if* send_link)
{
- if (_seqno >= _ackno + _credits) {
- return;
- }
uint32_t* data = (uint32_t*)buff->data();
data[ADDR_OFFSET] = _send_addr;
data[SEQNO_OFFSET] = _seqno;
@@ -202,6 +208,7 @@ private:
send_io_if::sptr _send_if;
uint32_t _seqno = 0;
uint32_t _ackno = 0;
+ size_t _frame_size;
};
/*!