diff options
Diffstat (limited to 'host/lib/include/uhdlib/transport/link_if.hpp')
-rw-r--r-- | host/lib/include/uhdlib/transport/link_if.hpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/host/lib/include/uhdlib/transport/link_if.hpp b/host/lib/include/uhdlib/transport/link_if.hpp new file mode 100644 index 000000000..60376e571 --- /dev/null +++ b/host/lib/include/uhdlib/transport/link_if.hpp @@ -0,0 +1,101 @@ +// +// Copyright 2019 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#include <uhd/transport/frame_buff.hpp> +#include <memory> + +#ifndef INCLUDED_UHDLIB_TRANSPORT_LINK_IF_HPP +# define INCLUDED_UHDLIB_TRANSPORT_LINK_IF_HPP + +namespace uhd { namespace transport { + +/*! + * Link interface for transmitting packets. + */ +class send_link_if +{ +public: + using sptr = std::shared_ptr<send_link_if>; + + /*! + * Get the number of frame buffers that can be queued by this link. + */ + virtual size_t get_num_send_frames() const = 0; + + /*! + * Get the maximum capacity of a frame buffer. + */ + virtual size_t get_send_frame_size() const = 0; + + /*! + * Get an empty frame buffer in which to write packet contents. + * + * \param timeout_ms a positive timeout value specifies the maximum number + of ms to wait, a negative value specifies to block + until successful, and a value of 0 specifies no wait. + * \return a frame buffer, or null uptr if timeout occurs + */ + virtual frame_buff::uptr get_send_buff(int32_t timeout_ms) = 0; + + /*! + * Send a packet with the contents of the frame buffer and release the + * buffer, allowing the link driver to reuse it. If the size of the frame + * buffer is 0, the buffer is released with no packet being sent. + * + * \param buffer frame buffer containing packet data + * + * Throws an exception if an I/O error occurs while sending + */ + virtual void release_send_buff(frame_buff::uptr buff) = 0; + + send_link_if() = default; + send_link_if(const send_link_if&) = delete; + send_link_if& operator=(const send_link_if&) = delete; +}; + +/*! + * Link interface for receiving packets. + */ +class recv_link_if +{ +public: + using sptr = std::shared_ptr<recv_link_if>; + + /*! + * Get the number of frame buffers that can be queued by this link. + */ + virtual size_t get_num_recv_frames() const = 0; + + /*! + * Get the maximum capacity of a frame buffer. + */ + virtual size_t get_recv_frame_size() const = 0; + + /*! + * Receive a packet and return a frame buffer containing the packet data. + * + * \param timeout_ms a positive timeout value specifies the maximum number + of ms to wait, a negative value specifies to block + until successful, and a value of 0 specifies no wait. + * \return a frame buffer, or null uptr if timeout occurs + */ + virtual frame_buff::uptr get_recv_buff(int32_t timeout_ms) = 0; + + /*! + * Release a frame buffer, allowing the link driver to reuse it. + * + * \param buffer frame buffer to release for reuse by the link + */ + virtual void release_recv_buff(frame_buff::uptr buff) = 0; + + recv_link_if() = default; + recv_link_if(const recv_link_if&) = delete; + recv_link_if& operator=(const recv_link_if&) = delete; +}; + +}} // namespace uhd::transport + +#endif /* INCLUDED_UHDLIB_TRANSPORT_LINK_IF_HPP */ |