diff options
author | RobertWalstab <robert.walstab@gmail.com> | 2020-07-14 10:55:35 +0200 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-07-20 16:01:03 -0500 |
commit | 1d3866bef4e4677b95d3364b94880d7823d2530f (patch) | |
tree | 4ab0fe6879f60c4c8c3e007ae92acd11b82fbd2f /host/lib | |
parent | 46f61951e88d8936814095bf2f8db014b6ff67e6 (diff) | |
download | uhd-1d3866bef4e4677b95d3364b94880d7823d2530f.tar.gz uhd-1d3866bef4e4677b95d3364b94880d7823d2530f.tar.bz2 uhd-1d3866bef4e4677b95d3364b94880d7823d2530f.zip |
uhd: remove liberio
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/CMakeLists.txt | 2 | ||||
-rw-r--r-- | host/lib/include/uhdlib/transport/liberio_link.hpp | 178 | ||||
-rw-r--r-- | host/lib/transport/CMakeLists.txt | 7 | ||||
-rw-r--r-- | host/lib/transport/liberio_link.cpp | 154 | ||||
-rw-r--r-- | host/lib/usrp/mpmd/mpmd_link_if_mgr.hpp | 2 |
5 files changed, 1 insertions, 342 deletions
diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index c0b39faea..3335cfec9 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -60,9 +60,7 @@ endmacro(INCLUDE_SUBDIRECTORY) message(STATUS "") # Dependencies find_package(LIBUSB) -find_package(LIBERIO) find_package(DPDK 18.11 EXACT) -LIBUHD_REGISTER_COMPONENT("LIBERIO" ENABLE_LIBERIO ON "ENABLE_LIBUHD;LIBERIO_FOUND" OFF OFF) LIBUHD_REGISTER_COMPONENT("USB" ENABLE_USB ON "ENABLE_LIBUHD;LIBUSB_FOUND" OFF OFF) # Devices LIBUHD_REGISTER_COMPONENT("B100" ENABLE_B100 ON "ENABLE_LIBUHD;ENABLE_USB" OFF OFF) diff --git a/host/lib/include/uhdlib/transport/liberio_link.hpp b/host/lib/include/uhdlib/transport/liberio_link.hpp deleted file mode 100644 index e81a39393..000000000 --- a/host/lib/include/uhdlib/transport/liberio_link.hpp +++ /dev/null @@ -1,178 +0,0 @@ -// -// Copyright 2019 Ettus Research, a National Instruments brand -// -// SPDX-License-Identifier: GPL-3.0-or-later -// - -#pragma once - -#include <uhd/config.hpp> -#include <uhd/transport/buffer_pool.hpp> -#include <uhd/types/device_addr.hpp> -#include <uhdlib/transport/adapter_info.hpp> -#include <uhdlib/transport/link_base.hpp> -#include <liberio/liberio.h> -#include <cassert> -#include <string> -#include <vector> - -namespace uhd { namespace transport { - -class liberio_frame_buff : public frame_buff -{ -public: - liberio_frame_buff(struct liberio_chan* chan) : _chan(chan) - { - assert(_chan); - // Acquire channel reference - liberio_chan_get(_chan); - } - - ~liberio_frame_buff() - { - if (_buff) { - // Set payload size to signify "empty" - liberio_buf_set_payload(_buff, 0, 0); - - // Release buffer back to liberio - liberio_chan_buf_enqueue(_chan, _buff); - _buff = nullptr; - _data = nullptr; - } - // Release channel reference - liberio_chan_put(_chan); - } - - liberio_frame_buff(const liberio_frame_buff& src) : liberio_frame_buff(src._chan) {} - - UHD_FORCE_INLINE size_t get(int32_t timeout_ms) - { - // Dequeue timeout in microseconds - _buff = liberio_chan_buf_dequeue(_chan, timeout_ms * 1000); - if (!_buff) { - return 0; - } - _packet_size = liberio_buf_get_len(_buff, 0); - _data = liberio_buf_get_mem(_buff, 0); - return _packet_size; - } - - UHD_FORCE_INLINE void release() - { - assert(_buff); - liberio_buf_set_payload(_buff, 0, _packet_size); - liberio_chan_buf_enqueue(_chan, _buff); - _buff = nullptr; - _data = nullptr; - } - -private: - struct liberio_buf* _buff = nullptr; - struct liberio_chan* _chan; -}; - -class liberio_adapter_info : public adapter_info -{ -public: - liberio_adapter_info() = default; - ~liberio_adapter_info() = default; - - std::string to_string() - { - // Currently, there is only ever one liberio adapter - // If that changes, fix this! - return std::string("Liberio"); - } - - bool operator==(const liberio_adapter_info& /*rhs*/) const - { - // Currently, there is only ever one liberio adapter - // If that changes, fix this! - return true; - } -}; - -/*! - * A zero copy transport interface to the liberio DMA library. - */ -class liberio_link : public recv_link_base<liberio_link>, - public send_link_base<liberio_link> -{ -public: - using sptr = std::shared_ptr<liberio_link>; - - liberio_link(const std::string& tx_path, - const std::string& rx_path, - const link_params_t& params); - - ~liberio_link(); - - /*! - * Make a new liberio link. - * - * \param tx_path a path string to the TX DMA device - * \param rx_path a path string to the RX DMA device - * \param params Values for frame sizes, num frames, and buffer sizes - * \return a shared_ptr to a new liberio link - */ - static sptr make(const std::string& tx_path, - const std::string& rx_path, - const link_params_t& params); - - /*! - * Get the physical adapter ID used for this link - */ - adapter_id_t get_send_adapter_id() const - { - return _adapter_id; - } - - /*! - * Get the physical adapter ID used for this link - */ - adapter_id_t get_recv_adapter_id() const - { - return _adapter_id; - } - -private: - using recv_link_base_t = recv_link_base<liberio_link>; - using send_link_base_t = send_link_base<liberio_link>; - - // Friend declarations to allow base classes to call private methods - friend recv_link_base_t; - friend send_link_base_t; - - // Methods called by recv_link_base - size_t get_recv_buff_derived(frame_buff& buff, int32_t timeout_ms) - { - auto& buffer = static_cast<liberio_frame_buff&>(buff); - return buffer.get(timeout_ms); - } - - void release_recv_buff_derived(frame_buff& buff) - { - auto& buffer = static_cast<liberio_frame_buff&>(buff); - buffer.release(); - } - - bool get_send_buff_derived(frame_buff& buff, int32_t timeout_ms) - { - auto& buffer = static_cast<liberio_frame_buff&>(buff); - return buffer.get(timeout_ms); - } - - void release_send_buff_derived(frame_buff& buff) - { - auto& buffer = static_cast<liberio_frame_buff&>(buff); - buffer.release(); - } - - struct liberio_chan* _tx_chan; - struct liberio_chan* _rx_chan; - std::vector<liberio_frame_buff> _recv_buffs; - std::vector<liberio_frame_buff> _send_buffs; - adapter_id_t _adapter_id; -}; - -}} // namespace uhd::transport diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt index 2b1378978..3c60414e0 100644 --- a/host/lib/transport/CMakeLists.txt +++ b/host/lib/transport/CMakeLists.txt @@ -133,13 +133,6 @@ if(ENABLE_X300) ) endif(ENABLE_X300) -if(ENABLE_LIBERIO) - include_directories(${LIBERIO_INCLUDE_DIRS}) - LIBUHD_APPEND_LIBS(${LIBERIO_LIBRARIES}) - LIBUHD_APPEND_SOURCES( - ${CMAKE_CURRENT_SOURCE_DIR}/liberio_link.cpp - ) -endif(ENABLE_LIBERIO) if(ENABLE_DPDK) INCLUDE_SUBDIRECTORY(uhd-dpdk) diff --git a/host/lib/transport/liberio_link.cpp b/host/lib/transport/liberio_link.cpp deleted file mode 100644 index ec8abbca8..000000000 --- a/host/lib/transport/liberio_link.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// -// Copyright 2019 Ettus Research, a National Instruments brand -// -// SPDX-License-Identifier: GPL-3.0-or-later -// - -#include <uhd/config.hpp> -#include <uhd/utils/log.hpp> -#include <uhd/utils/static.hpp> -#include <uhdlib/transport/adapter.hpp> -#include <uhdlib/transport/liberio_link.hpp> -#include <sys/syslog.h> -#include <memory> - -namespace uhd { namespace transport { - -using liberio_ctx_sptr = std::shared_ptr<liberio_ctx>; - -static const uint64_t USEC = 1000000; - -static void liberio_log_cb(int severity, const char* msg, void*) -{ - switch (severity) { - case LOG_WARNING: - UHD_LOG_WARNING("LIBERIO", msg); - return; - case LOG_NOTICE: - case LOG_INFO: - UHD_LOG_INFO("LIBERIO", msg); - return; - default: - UHD_LOG_INFO("LIBERIO", msg); - }; -} - -class liberio_context_holder -{ -public: - UHD_SINGLETON_FCN(liberio_context_holder, get); - - inline struct liberio_chan* alloc_tx_chan(const std::string& path) - { - return liberio_ctx_alloc_chan(_ctx, path.c_str(), TX, USRP_MEMORY_MMAP); - } - - inline struct liberio_chan* alloc_rx_chan(const std::string& path) - { - return liberio_ctx_alloc_chan(_ctx, path.c_str(), RX, USRP_MEMORY_MMAP); - } - -private: - liberio_context_holder(void) - { - _ctx = liberio_ctx_new(); - liberio_ctx_register_logger(_ctx, &liberio_log_cb, nullptr); - } - - ~liberio_context_holder(void) - { - liberio_ctx_put(_ctx); - } - - liberio_ctx* _ctx; -}; - -liberio_link::liberio_link( - const std::string& tx_path, const std::string& rx_path, const link_params_t& params) - : recv_link_base_t(params.num_recv_frames, params.recv_frame_size) - , send_link_base_t(params.num_send_frames, params.send_frame_size) -{ - auto& ctx_holder = liberio_context_holder::get(); - - /* Allocate TX channel (begins with refcount of 1) - */ - _tx_chan = ctx_holder.alloc_tx_chan(tx_path); - UHD_ASSERT_THROW(_tx_chan); - - /* set the size, allocate */ - UHD_ASSERT_THROW(!liberio_chan_set_fixed_size(_tx_chan, 0, params.send_frame_size)); - UHD_ASSERT_THROW(!liberio_chan_request_buffers(_tx_chan, params.num_send_frames)); - - /* TODO: Check params in factory and adjust them there instead of throwing exception - * here? */ - UHD_ASSERT_THROW(params.num_send_frames == liberio_chan_get_num_bufs(_tx_chan)); - for (size_t i = 0; i < params.num_send_frames; i++) { - _send_buffs.push_back(liberio_frame_buff(_tx_chan)); - } - - /* Allocate RX channel (begins with refcount of 1) - */ - _rx_chan = ctx_holder.alloc_rx_chan(rx_path); - UHD_ASSERT_THROW(_rx_chan); - - /* set the size, allocate */ - UHD_ASSERT_THROW(!liberio_chan_set_fixed_size(_rx_chan, 0, params.recv_frame_size)); - UHD_ASSERT_THROW(!liberio_chan_request_buffers(_rx_chan, params.num_recv_frames)); - /* TODO: Check params in factory and adjust them there instead of throwing exception - * here? */ - UHD_ASSERT_THROW(params.num_recv_frames == liberio_chan_get_num_bufs(_rx_chan)); - - for (size_t i = 0; i < params.num_recv_frames; i++) { - _recv_buffs.push_back(liberio_frame_buff(_rx_chan)); - } - UHD_ASSERT_THROW(!liberio_chan_enqueue_all(_rx_chan)); - - /* Start streaming on the devices */ - liberio_chan_start_streaming(_rx_chan); - liberio_chan_start_streaming(_tx_chan); - - /* Finally, preload the buffer pools in parent class */ - for (auto& buff : _send_buffs) { - send_link_base_t::preload_free_buff(&buff); - } - for (auto& buff : _recv_buffs) { - recv_link_base_t::preload_free_buff(&buff); - } - - auto info = liberio_adapter_info(); - auto& adap_ctx = adapter_ctx::get(); - _adapter_id = adap_ctx.register_adapter(info); - - UHD_LOGGER_TRACE("LIBERIO") - << boost::format("Created liberio link (tx:%s, rx:%s)") % tx_path % rx_path; - UHD_LOGGER_TRACE("LIBERIO") - << boost::format("num_recv_frames=%d, recv_frame_size=%d, num_send_frames=%d, " - "send_frame_size=%d") - % params.num_recv_frames % params.recv_frame_size % params.num_send_frames - % params.send_frame_size; -} - -liberio_link::~liberio_link() -{ - /* stop the channel, free the buffers */ - liberio_chan_stop_streaming(_tx_chan); - liberio_chan_request_buffers(_tx_chan, 0); - liberio_chan_put(_tx_chan); - - liberio_chan_stop_streaming(_rx_chan); - liberio_chan_request_buffers(_rx_chan, 0); - liberio_chan_put(_rx_chan); -} - -liberio_link::sptr liberio_link::make( - const std::string& tx_path, const std::string& rx_path, const link_params_t& params) -{ - UHD_ASSERT_THROW(params.recv_frame_size > 0); - UHD_ASSERT_THROW(params.send_frame_size > 0); - UHD_ASSERT_THROW(params.num_send_frames > 0); - UHD_ASSERT_THROW(params.num_recv_frames > 0); - - return std::make_shared<liberio_link>(tx_path, rx_path, params); -} - -}} // namespace uhd::transport diff --git a/host/lib/usrp/mpmd/mpmd_link_if_mgr.hpp b/host/lib/usrp/mpmd/mpmd_link_if_mgr.hpp index 4bf893dd4..8f364c10f 100644 --- a/host/lib/usrp/mpmd/mpmd_link_if_mgr.hpp +++ b/host/lib/usrp/mpmd/mpmd_link_if_mgr.hpp @@ -75,7 +75,7 @@ public: * from mb_args in the \p xport_info. If yes, it will use that for * connections. * - * \param xport_type The type of xport ("udp", "liberio", ...) + * \param xport_type The type of xport ("udp") * \param xport_info The available information on this transport. For * example, if the xport_type is "udp", then this would * contain the available IP addresses. |