From 9c2d90292b9a613fb290c5a04e99014d1a9118ab Mon Sep 17 00:00:00 2001 From: Ciro Nishiguchi Date: Mon, 25 Mar 2019 12:41:34 -0500 Subject: uhd: add new transport interface and base class implementation New interface aimed to replace zero_copy_if for new code, including new RFNoC development and redesign of streamer objects. Generic implementation of send and receive transport interfaces to allow reuse by various transport types. Derived classes implement transport-specific functions that are invoked by the base classes through CRTP. --- host/include/uhd/transport/CMakeLists.txt | 1 + host/include/uhd/transport/frame_buff.hpp | 69 +++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 host/include/uhd/transport/frame_buff.hpp (limited to 'host/include') diff --git a/host/include/uhd/transport/CMakeLists.txt b/host/include/uhd/transport/CMakeLists.txt index d0810e502..400b3db0b 100644 --- a/host/include/uhd/transport/CMakeLists.txt +++ b/host/include/uhd/transport/CMakeLists.txt @@ -10,6 +10,7 @@ UHD_INSTALL(FILES bounded_buffer.ipp buffer_pool.hpp chdr.hpp + frame_buff.hpp if_addrs.hpp udp_constants.hpp udp_simple.hpp diff --git a/host/include/uhd/transport/frame_buff.hpp b/host/include/uhd/transport/frame_buff.hpp new file mode 100644 index 000000000..c335f0c4b --- /dev/null +++ b/host/include/uhd/transport/frame_buff.hpp @@ -0,0 +1,69 @@ +// +// Copyright 2019 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_UHD_TRANSPORT_FRAME_BUFF_HPP +#define INCLUDED_UHD_TRANSPORT_FRAME_BUFF_HPP + +#include + +namespace uhd { namespace transport { + +/*! + * Contains a reference to a frame buffer managed by a link. + */ +class frame_buff +{ +public: + /*! + * No-op deleter to prevent unique_ptr from deleting the buffer if the + * pointer goes out of scope. The lifetime of the buffers is controlled + * by the links. + */ + struct deleter + { + void operator()(frame_buff*) {} + }; + + using uptr = std::unique_ptr; + + /*! + * Get the raw data buffer contained within the frame buffer + * \return a pointer to the buffer memory. + */ + void* data() const + { + return _data; + } + + /*! + * Returns the size of the packet + * \return the size of the packet contained in the frame buffer, in bytes. + */ + size_t packet_size() const + { + return _packet_size; + } + + /*! + * Sets the size of the packet contained in the frame buffer, in bytes. + * \param size Number of bytes occupied in the buffer + */ + void set_packet_size(size_t size) + { + _packet_size = size; + } + +protected: + /*! Pointer to data of current frame */ + void* _data = nullptr; + + /*! Size of packet in current frame */ + size_t _packet_size = 0; +}; + +}} // namespace uhd::transport + +#endif /* INCLUDED_UHD_TRANSPORT_FRAME_BUFF_HPP */ -- cgit v1.2.3