From 18098228932f3e25e3ac1750599c5e531657f161 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 1 Jun 2017 18:39:04 -0700 Subject: mpm/mpmd: Further improvements on multi-device operations - Crossbar local addr is now written during initialization of UHD session - Support for multiple crossbars per device (at least on UHD side) - Crossbars are now sequentially given a unique address --- mpm/python/usrp_mpm/periph_manager/base.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'mpm/python/usrp_mpm/periph_manager/base.py') diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index 4e6d461d8..ef9e4b092 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -387,8 +387,12 @@ class PeriphManagerBase(object): xbar_index -- The index of the crossbar that's being queried. docstring for get_num_blocks""" - # FIXME - return int(open('/sys/class/rfnoc_crossbar/crossbar0/nports').read().strip()) - 3 + # FIXME udev lookup + xbar_sysfs_path = '/sys/class/rfnoc_crossbar/crossbar{}/nports'.format( + xbar_index + ) + return int(open(xbar_sysfs_path).read().strip()) - \ + self.get_base_port(xbar_index) @no_claim def get_base_port(self, xbar_index): @@ -401,5 +405,21 @@ class PeriphManagerBase(object): xbar_index -- The index of the crossbar that's being queried """ - return 3 # FIXME This is the same 3 as in get_num_blocks + return 3 # FIXME It's 3 because 0,1,2 are SFP,SFP,DMA + + def set_xbar_local_addr(self, xbar_index, local_addr): + """ + Program crossbar xbar_index to have the local address local_addr. + """ + # FIXME udev lookup + xbar_sysfs_path = '/sys/class/rfnoc_crossbar/crossbar{}/local_addr'.format( + xbar_index + ) + laddr_value = "0x{:X}".format(local_addr) + self.log.trace("Setting local address for xbar {} to {}.".format( + xbar_sysfs_path, laddr_value + )) + with open(xbar_sysfs_path, "w") as xbar_file: + xbar_file.write(laddr_value) + return True -- cgit v1.2.3