mirror of
https://github.com/EttusResearch/uhd.git
synced 2026-10-25 17:36:10 +00:00
uhd: remove liberio
This commit is contained in:
parent
46f61951e8
commit
1d3866bef4
@ -1,35 +0,0 @@
|
||||
#
|
||||
# Copyright 2017 Ettus Research
|
||||
# Copyright 2018 Ettus Research, a National Instruments Company
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# - Find liberio
|
||||
# Find the liberio includes and client library
|
||||
# This module defines
|
||||
# LIBERIO_INCLUDE_DIR, where to find liberio/dma.h
|
||||
# LIBERIO_LIBRARIES, the libraries needed by a liberio client.
|
||||
# LIBERIO_FOUND, If false, do not try to use liberio.
|
||||
# also defined, but not for general use are
|
||||
# LIBERIO_LIBRARY, where to find the liberio library.
|
||||
|
||||
find_package(PkgConfig)
|
||||
PKG_CHECK_MODULES(PC_LIBERIO QUIET liberio >= 0.3)
|
||||
|
||||
find_path(LIBERIO_INCLUDE_DIR liberio/liberio.h
|
||||
HINTS $ENV{LIBERIO_DIR}/include ${PC_LIBERIO_INCLUDE_DIR}
|
||||
PATH_SUFFIXES liberio
|
||||
)
|
||||
|
||||
find_library(LIBERIO_LIBRARY
|
||||
NAMES erio liberio
|
||||
HINTS $ENV{LIBERIO_DIR}/lib ${PC_LIBERIO_LIBDIR} ${PC_LIBERIO_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBERIO DEFAULT_MSG LIBERIO_LIBRARY LIBERIO_INCLUDE_DIR)
|
||||
mark_as_advanced(LIBERIO_INCLUDE_DIR LIBERIO_LIBRARY)
|
||||
|
||||
set(LIBERIO_LIBRARIES ${LIBERIO_LIBRARY})
|
||||
set(LIBERIO_INCLUDE_DIRS ${LIBERIO_INCLUDE_DIR})
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
#define UHD_VERSION_ABI ${UHD_VERSION_ABI}
|
||||
#define UHD_VERSION_PATCH ${UHD_VERSION_PATCH}
|
||||
#cmakedefine ENABLE_USB
|
||||
#cmakedefine ENABLE_LIBERIO
|
||||
#ifndef UHD_VERSION
|
||||
#cmakedefine UHD_VERSION @UHD_VERSION_ADDED@
|
||||
#endif
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
@ -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.
|
||||
|
||||
@ -18,7 +18,6 @@ set(USRP_MPM_TOP_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/e31x_legacy_eeprom.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ethdispatch.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gpsd_iface.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/liberiotable.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mpmlog.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mpmtypes.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mpmutils.py
|
||||
|
||||
@ -1,60 +0,0 @@
|
||||
#
|
||||
# Copyright 2017 Ettus Research, a National Instruments Company
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
"""
|
||||
Liberio DMA dispatcher table control
|
||||
"""
|
||||
|
||||
from builtins import str
|
||||
from builtins import object
|
||||
from usrp_mpm.mpmlog import get_logger
|
||||
from usrp_mpm.sys_utils.uio import UIO
|
||||
|
||||
class LiberioDispatcherTable(object):
|
||||
"""
|
||||
Controls a Liberio DMA dispatcher table.
|
||||
|
||||
label -- A label that can be used by udev to find a UIO device
|
||||
"""
|
||||
|
||||
def __init__(self, label):
|
||||
self.log = get_logger(label)
|
||||
self._regs = UIO(label=label, read_only=False)
|
||||
self.poke32 = self._regs.poke32
|
||||
self.peek32 = self._regs.peek32
|
||||
|
||||
def set_route(self, sid, dma_channel):
|
||||
"""
|
||||
Sets up routing in the Liberio dispatcher. From sid, only the
|
||||
destination part is important. After this call, any CHDR packet with the
|
||||
appropriate destination address will get routed to `dma_channel`.
|
||||
|
||||
sid -- Full SID, but only destination part matters.
|
||||
dma_channel -- The DMA channel to which these packets should get routed.
|
||||
"""
|
||||
self.log.debug(
|
||||
"Routing SID `{sid}' to DMA channel `{chan}'.".format(
|
||||
sid=str(sid), chan=dma_channel
|
||||
)
|
||||
)
|
||||
def poke_and_trace(addr, data):
|
||||
" Do a poke32() and log.trace() "
|
||||
self.log.trace("Writing to address 0x{:04X}: 0x{:04X}".format(
|
||||
addr, data
|
||||
))
|
||||
self.poke32(addr, data)
|
||||
# Poke reg for destination channel
|
||||
try:
|
||||
with self._regs:
|
||||
poke_and_trace(
|
||||
0 + 4 * sid.dst_ep,
|
||||
dma_channel,
|
||||
)
|
||||
except Exception as ex:
|
||||
self.log.error(
|
||||
"Unexpected exception while setting route: %s",
|
||||
str(ex),
|
||||
)
|
||||
raise
|
||||
@ -845,11 +845,9 @@ class PeriphManagerBase(object):
|
||||
The return value is a list of strings. Every string is a key for a
|
||||
transport type. Values include:
|
||||
- "udp": Means this device can be reached via UDP
|
||||
- "liberio": Means this device can be reached via Liberio (local DMA)
|
||||
|
||||
The list is filtered based on what the device knows about where the UHD
|
||||
session is. For example, on an N310, it will only either return "UDP"
|
||||
or "Liberio", depending on if we're remotely launching UHD, or locally.
|
||||
session is. For example, on an N310, it will only return "UDP".
|
||||
|
||||
In order to get further information about how to connect to the device,
|
||||
the keys returned from this function can be used with
|
||||
@ -870,9 +868,6 @@ class PeriphManagerBase(object):
|
||||
- port (UDP port)
|
||||
- link_rate (bps of the link, e.g. 10e9 for 10GigE)
|
||||
|
||||
For Liberio, every entry has the following keys:
|
||||
- tx_dev: TX device (/dev/tx-dma*)
|
||||
- rx_dev: RX device (/dev/rx-dma*)
|
||||
"""
|
||||
raise NotImplementedError("get_chdr_link_options() not implemented.")
|
||||
|
||||
|
||||
@ -394,9 +394,6 @@ class e320(ZynqComponents, PeriphManagerBase):
|
||||
- port (UDP port)
|
||||
- link_rate (bps of the link, e.g. 10e9 for 10GigE)
|
||||
|
||||
For Liberio, every entry has the following keys:
|
||||
- tx_dev: TX device (/dev/tx-dma*)
|
||||
- rx_dev: RX device (/dev/rx-dma*)
|
||||
"""
|
||||
if xport_type not in self._xport_mgrs:
|
||||
self.log.warning("Can't get link options for unknown link type: `{}'."
|
||||
|
||||
@ -8,7 +8,6 @@ set(USRP_MPM_FILES ${USRP_MPM_FILES})
|
||||
set(USRP_MPM_XPORT_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/__init__.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/xportmgr_udp.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/xportmgr_liberio.py
|
||||
)
|
||||
list(APPEND USRP_MPM_FILES ${USRP_MPM_XPORT_FILES})
|
||||
set(USRP_MPM_FILES ${USRP_MPM_FILES} PARENT_SCOPE)
|
||||
|
||||
@ -8,4 +8,3 @@ Transport managers
|
||||
"""
|
||||
|
||||
from .xportmgr_udp import XportMgrUDP
|
||||
from .xportmgr_liberio import XportMgrLiberio
|
||||
|
||||
@ -1,74 +0,0 @@
|
||||
#
|
||||
# Copyright 2017 Ettus Research, a National Instruments Company
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
"""
|
||||
Liberio Transport manager
|
||||
"""
|
||||
|
||||
from builtins import object
|
||||
import pyudev
|
||||
|
||||
class XportMgrLiberio(object):
|
||||
"""
|
||||
Transport manager for Liberio connections
|
||||
"""
|
||||
# udev label for the UIO device that controls the DMA engine
|
||||
liberio_label = 'liberio'
|
||||
# Number of available DMA channels
|
||||
max_chan = 4
|
||||
|
||||
def __init__(self, log, max_chan=-1):
|
||||
self.log = log.getChild('Liberio')
|
||||
if max_chan < 0:
|
||||
context = pyudev.Context()
|
||||
rx_of_nodes = list(context.list_devices(subsystem="platform",
|
||||
OF_COMPATIBLE_0="ettus,usrp-rx-dma"))
|
||||
tx_of_nodes = list(context.list_devices(subsystem="platform",
|
||||
OF_COMPATIBLE_0="ettus,usrp-tx-dma"))
|
||||
self.max_chan = min(len(rx_of_nodes), len(tx_of_nodes))
|
||||
self.log.debug("Found {} channels".format(self.max_chan))
|
||||
else:
|
||||
self.max_chan = max_chan
|
||||
self.log.debug("Reporting {} channels".format(self.max_chan))
|
||||
|
||||
def init(self, args):
|
||||
"""
|
||||
Call this when the user calls 'init' on the periph manager
|
||||
"""
|
||||
pass
|
||||
|
||||
def deinit(self):
|
||||
" Clean up after a session terminates "
|
||||
pass
|
||||
|
||||
def get_xport_info(self):
|
||||
"""
|
||||
Returns a dictionary of useful information, e.g. for appending into the
|
||||
device info.
|
||||
|
||||
Note: This can be run by callers not owning a claim, even when the
|
||||
device has been claimed by someone else.
|
||||
|
||||
In this case, returns an empty dict.
|
||||
"""
|
||||
assert hasattr(self, 'log')
|
||||
return {}
|
||||
|
||||
def get_chdr_link_options(self):
|
||||
"""
|
||||
Returns a list of dictionaries for returning by
|
||||
PeriphManagerBase.get_chdr_link_options().
|
||||
|
||||
Note: This requires a claim, which means that init() was called, and
|
||||
deinit() was not yet called.
|
||||
"""
|
||||
return [
|
||||
{
|
||||
'tx_dev': "/dev/tx-dma{}".format(chan),
|
||||
'rx_dev': "/dev/rx-dma{}".format(chan),
|
||||
'dma_chan': str(chan),
|
||||
}
|
||||
for chan in range(self.max_chan)
|
||||
]
|
||||
Loading…
Reference in New Issue
Block a user