From 40b563387b0af059a2d565d4cba958cf5e0772fb Mon Sep 17 00:00:00 2001 From: Alex Williams Date: Tue, 22 Oct 2019 11:51:00 -0500 Subject: mpm: Detect number of liberio channels Instead of using hard-coded values, detect the number of liberio channels, and only offer liberio links if they exist. --- mpm/python/usrp_mpm/periph_manager/e320.py | 9 +++++---- mpm/python/usrp_mpm/xports/xportmgr_liberio.py | 14 +++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'mpm') diff --git a/mpm/python/usrp_mpm/periph_manager/e320.py b/mpm/python/usrp_mpm/periph_manager/e320.py index 82185e51c..0343f7755 100644 --- a/mpm/python/usrp_mpm/periph_manager/e320.py +++ b/mpm/python/usrp_mpm/periph_manager/e320.py @@ -54,8 +54,7 @@ class E320XportMgrUDP(XportMgrUDP): } class E320XportMgrLiberio(XportMgrLiberio): - " E320-specific Liberio configuration " - max_chan = 6 + "E320-specific liberio configuration" # pylint: enable=too-few-public-methods ############################################################################### @@ -375,8 +374,10 @@ class e320(ZynqComponents, PeriphManagerBase): assert self.mboard_info['rpc_connection'] in ('remote', 'local') if self.mboard_info['rpc_connection'] == 'remote': return ["udp"] - # else: - return ["liberio"] + elif self._xport_mgrs["liberio"].max_chan > 0: + return ["liberio"] + else: + return ["udp"] def get_chdr_link_options(self, xport_type): """ diff --git a/mpm/python/usrp_mpm/xports/xportmgr_liberio.py b/mpm/python/usrp_mpm/xports/xportmgr_liberio.py index f7c1861af..1b4f87fbf 100644 --- a/mpm/python/usrp_mpm/xports/xportmgr_liberio.py +++ b/mpm/python/usrp_mpm/xports/xportmgr_liberio.py @@ -8,6 +8,7 @@ Liberio Transport manager """ from builtins import object +import pyudev class XportMgrLiberio(object): """ @@ -18,8 +19,19 @@ class XportMgrLiberio(object): # Number of available DMA channels max_chan = 4 - def __init__(self, log): + 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): """ -- cgit v1.2.3