1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#
# 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)
]
|