From 10b9d2688b5bcb150eec786a9ef7473f1c1c28ac Mon Sep 17 00:00:00 2001 From: Ciro Nishiguchi Date: Sat, 26 Oct 2019 18:40:01 -0500 Subject: rfnoc: Make I/O services relinquish CPU while waiting --- .../include/uhdlib/transport/inline_io_service.hpp | 13 +++++++ .../uhdlib/transport/offload_io_service_client.hpp | 44 ++++++++++++++-------- 2 files changed, 41 insertions(+), 16 deletions(-) (limited to 'host/lib/include/uhdlib/transport') diff --git a/host/lib/include/uhdlib/transport/inline_io_service.hpp b/host/lib/include/uhdlib/transport/inline_io_service.hpp index fe41b96b6..d4a6dbbae 100644 --- a/host/lib/include/uhdlib/transport/inline_io_service.hpp +++ b/host/lib/include/uhdlib/transport/inline_io_service.hpp @@ -104,6 +104,19 @@ private: frame_buff::uptr recv( inline_recv_cb* recv_io_cb, recv_link_if* recv_link, int32_t timeout_ms); + /* + * Function to perform recv operations on a link, which is potentially + * muxed. This function is only called from send_io::release_send_buff, and + * always expects recv_io_cb to release its incoming buffer. Packets are + * forwarded to the appropriate mux or callback. + * + * \param recv_io_cb the callback+interface initiating the operation + * \param recv_link link to perform receive on + * \param timeout_ms timeout to wait for a buffer on the link + */ + void recv_flow_ctrl( + inline_recv_cb* recv_io_cb, recv_link_if* recv_link, int32_t timeout_ms); + /* Track whether link is muxed and the callback */ std::unordered_map> _recv_tbl; diff --git a/host/lib/include/uhdlib/transport/offload_io_service_client.hpp b/host/lib/include/uhdlib/transport/offload_io_service_client.hpp index 620e796ef..2f606878c 100644 --- a/host/lib/include/uhdlib/transport/offload_io_service_client.hpp +++ b/host/lib/include/uhdlib/transport/offload_io_service_client.hpp @@ -50,7 +50,7 @@ static frame_buff::uptr client_get_buff(pop_func_t pop, const int32_t timeout_ms /*! * Recv I/O client for offload I/O service */ -template +template class offload_recv_io : public recv_io_if { public: @@ -75,13 +75,19 @@ public: frame_buff::uptr get_recv_buff(int32_t timeout_ms) { - return detail::client_get_buff( - [this]() { - frame_buff* buff = _port->client_pop(); - _num_frames_in_use += buff ? 1 : 0; - return buff; - }, - timeout_ms); + if (polling) { + return detail::client_get_buff( + [this]() { + frame_buff* buff = _port->client_pop(); + _num_frames_in_use += buff ? 1 : 0; + return buff; + }, + timeout_ms); + } else { + frame_buff* buff = _port->client_pop(timeout_ms); + _num_frames_in_use += buff ? 1 : 0; + return frame_buff::uptr(buff); + } } void release_recv_buff(frame_buff::uptr buff) @@ -103,7 +109,7 @@ private: /*! * Send I/O client for offload I/O service */ -template +template class offload_send_io : public send_io_if { public: @@ -128,13 +134,19 @@ public: frame_buff::uptr get_send_buff(int32_t timeout_ms) { - return detail::client_get_buff( - [this]() { - frame_buff* buff = _port->client_pop(); - _num_frames_in_use += buff ? 1 : 0; - return buff; - }, - timeout_ms); + if (polling) { + return detail::client_get_buff( + [this]() { + frame_buff* buff = _port->client_pop(); + _num_frames_in_use += buff ? 1 : 0; + return buff; + }, + timeout_ms); + } else { + frame_buff* buff = _port->client_pop(timeout_ms); + _num_frames_in_use += buff ? 1 : 0; + return frame_buff::uptr(buff); + } } void release_send_buff(frame_buff::uptr buff) -- cgit v1.2.3