aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/usrp_mpm/periph_manager/base.py
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2022-07-04 14:33:51 +0200
committerskooNI <60897865+skooNI@users.noreply.github.com>2022-07-20 15:57:20 -0500
commit54990c55f8ca4568c3281325636f15d02bb31f3f (patch)
treee2b5d06fd327ba21ead9ebf5ae54094898c45b21 /mpm/python/usrp_mpm/periph_manager/base.py
parent807e19c107fcc316988b8f58a16a5b5613d3354f (diff)
downloaduhd-54990c55f8ca4568c3281325636f15d02bb31f3f.tar.gz
uhd-54990c55f8ca4568c3281325636f15d02bb31f3f.tar.bz2
uhd-54990c55f8ca4568c3281325636f15d02bb31f3f.zip
mpm: Factor out transport API into PeriphManagerBase
All MPM devices use identical implementations of the transport API. Minor differences between the actual lines of code in the various transport adapters are due to minor optimizations, such as hard-coding 'udp' as the only valid transport type for the N3xx series. This change moves the implementation of the transport API calls (get_chdr_link_options() and get_chdr_link_types()) into PeriphManagerBase. The class attributes _xport_adapter_mgrs is also declared in that class, but defining them is left up to the individual device implementations.
Diffstat (limited to 'mpm/python/usrp_mpm/periph_manager/base.py')
-rw-r--r--mpm/python/usrp_mpm/periph_manager/base.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py
index 729952c33..4bde831a0 100644
--- a/mpm/python/usrp_mpm/periph_manager/base.py
+++ b/mpm/python/usrp_mpm/periph_manager/base.py
@@ -8,14 +8,11 @@
Mboard implementation base class
"""
-from __future__ import print_function
import os
from enum import Enum
from hashlib import md5
from time import sleep
from concurrent import futures
-from builtins import str
-from builtins import object
from six import iteritems, itervalues
from usrp_mpm.mpmlog import get_logger
from usrp_mpm.sys_utils.filesystem_status import get_fs_version
@@ -51,7 +48,7 @@ def get_dboard_class_from_pid(pid):
# pylint: disable=no-self-use
# pylint: disable=too-many-public-methods
# pylint: disable=too-many-instance-attributes
-class PeriphManagerBase(object):
+class PeriphManagerBase:
""""
Base class for all motherboards. Common function and API calls should
be implemented here. Motherboard specific information can be stored in
@@ -243,6 +240,9 @@ class PeriphManagerBase(object):
assert self.mboard_eeprom_magic is not None
self.dboards = []
self._default_args = ""
+ # CHDR transport managers. These need to be instantiated by the child
+ # classes.
+ self._xport_mgrs = {}
# Set up logging
self.log = get_logger('PeriphManager')
self.claimed = False
@@ -730,6 +730,8 @@ class PeriphManagerBase(object):
self.log.error(
"Cannot run init(), device was never fully initialized!")
return False
+ for xport_mgr in self._xport_mgrs.values():
+ xport_mgr.init(args)
if not self.dboards:
return True
if args.get("serialize_init", False):
@@ -761,6 +763,8 @@ class PeriphManagerBase(object):
for slot, dboard in enumerate(self.dboards):
self.log.trace("call deinit() on dBoard in slot {}".format(slot))
dboard.deinit()
+ for xport_mgr in self._xport_mgrs.values():
+ xport_mgr.deinit()
def tear_down(self):
"""
@@ -1090,7 +1094,7 @@ class PeriphManagerBase(object):
the keys returned from this function can be used with
get_chdr_link_options().
"""
- raise NotImplementedError("get_chdr_link_types() not implemented.")
+ return list(self._xport_mgrs.keys())
def get_chdr_link_options(self, xport_type):
"""
@@ -1106,7 +1110,15 @@ class PeriphManagerBase(object):
- link_rate (bps of the link, e.g. 10e9 for 10GigE)
"""
- raise NotImplementedError("get_chdr_link_options() not implemented.")
+ if xport_type not in self._xport_mgrs:
+ self.log.warning(
+ f"Can't get link options for unknown link type: `{xport_type}'.")
+ return []
+ if xport_type == "udp":
+ return self._xport_mgrs[xport_type].get_chdr_link_options(
+ self.mboard_info['rpc_connection'])
+ # else:
+ return self._xport_mgrs[xport_type].get_chdr_link_options()
#######################################################################
# Claimer API