diff options
author | Ciro Nishiguchi <ciro.nishiguchi@ni.com> | 2019-10-28 14:28:33 -0500 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 12:21:33 -0800 |
commit | a8e286b106f19c37d6cf20de886c65f3c04da162 (patch) | |
tree | 5c1baf4310abc0e4e082c960dffabd18a9fb6a3e /host/lib/include/uhdlib/transport/io_service.hpp | |
parent | 10b9d2688b5bcb150eec786a9ef7473f1c1c28ac (diff) | |
download | uhd-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/lib/include/uhdlib/transport/io_service.hpp')
-rw-r--r-- | host/lib/include/uhdlib/transport/io_service.hpp | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/host/lib/include/uhdlib/transport/io_service.hpp b/host/lib/include/uhdlib/transport/io_service.hpp index 399b693dc..87702ee2d 100644 --- a/host/lib/include/uhdlib/transport/io_service.hpp +++ b/host/lib/include/uhdlib/transport/io_service.hpp @@ -183,19 +183,25 @@ public: using sptr = std::shared_ptr<send_io_if>; /*! - * Callback for sending the packet. Callback is responsible for calling - * release_send_buff() if it wants to send the packet. This will require - * moving the uptr's reference. If the packet will NOT be sent, the - * callback must NOT release the uptr. + * Callback for sending the packet. Callback should call release_send_buff() + * and update any internal state needed. For example, flow control state + * could be updated here, and the header could be filled out as well, like + * the packet's sequence number and/or addresses. * - * Function should update any internal state needed. For example, flow - * control state could be updated here, and the header could be filled out - * as well, like the packet's sequence number and/or addresses. + * Callbacks execute on the I/O thread! Be careful about what state is + * touched. In addition, this callback should NOT sleep. + */ + using send_callback_t = std::function<void(frame_buff::uptr, send_link_if*)>; + + /*! + * Callback to check whether a packet can be sent. For flow controlled + * links, the callback should return whether the requested number of bytes + * can be received by the destination. * * Callbacks execute on the I/O thread! Be careful about what state is * touched. In addition, this callback should NOT sleep. */ - using send_callback_t = std::function<void(frame_buff::uptr&, send_link_if*)>; + using fc_callback_t = std::function<bool(const size_t)>; /* Transport client methods */ /*! @@ -209,6 +215,19 @@ public: virtual frame_buff::uptr get_send_buff(int32_t timeout_ms) = 0; /*! + * Wait until the destination is ready for a packet. For flow controlled + * transports, this method must be called prior to release_send_buff. If + * the transport is not flow controlled, you do not need to call this + * method. + * + * \param num_bytes the number of bytes to be sent in release_send_buff + * \param timeout_ms timeout in milliseconds to wait for destination to be + * ready + * \return whether the destination is ready for the requested bytes + */ + virtual bool wait_for_dest_ready(size_t num_bytes, int32_t timeout_ms) = 0; + + /*! * Release the send buffer to the send queue. * If the frame_buff's packet_size is zero, the link will free the buffer * without sending it. @@ -307,6 +326,7 @@ public: * \param recv_link the link used to observe flow control (can be empty) * \param num_recv_frames Number of buffers to reserve in recv_link * \param recv_cb callback function for receiving packets from recv_link + * \param fc_cb callback function to check if destination is ready for data * \return a send_io_if for interfacing with the link */ virtual send_io_if::sptr make_send_client(send_link_if::sptr send_link, @@ -314,7 +334,8 @@ public: send_io_if::send_callback_t cb, recv_link_if::sptr recv_link, size_t num_recv_frames, - recv_callback_t recv_cb) = 0; + recv_callback_t recv_cb, + send_io_if::fc_callback_t fc_cb) = 0; /*! * Create a recv_io_if and registers the transport's callbacks. |