From 2970aa27ce45d51cefe5c1d35eb8bf8a1e928245 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Mon, 30 Apr 2018 16:18:10 -0700 Subject: mpm: xportmgr_udp: Assign xports to previously used SFPs This changes the sorting algorithm for the xport<->SFP mapping. When multiple SFPs are used, this sorting will avoid a criss-cross mapping (e.g., mapping ports 0 and 1 of 0/Radio_0 to different SFPs). --- mpm/python/usrp_mpm/xports/xportmgr_udp.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'mpm') diff --git a/mpm/python/usrp_mpm/xports/xportmgr_udp.py b/mpm/python/usrp_mpm/xports/xportmgr_udp.py index c7d36af29..74b3bccfc 100644 --- a/mpm/python/usrp_mpm/xports/xportmgr_udp.py +++ b/mpm/python/usrp_mpm/xports/xportmgr_udp.py @@ -48,6 +48,7 @@ class XportMgrUDP(object): self._init_interfaces(self._possible_chdr_ifaces) self._eth_dispatchers = {} self._allocations = {} + self._previous_block_ep = {} def _init_interfaces(self, possible_ifaces): """ @@ -196,6 +197,30 @@ class XportMgrUDP(object): if sid.src_addr <= self.max_ctrl_addr: sid.src_addr = self.iface_config[iface_name]['ctrl_src_addr'] return sid + + def sort_xport_info(xport): + """ + We sort xport_info (which is a list of xport) as follows: + 1. Look at current allocation of xport src_addr (which is the addr + of host). If the allocation too large, in this case larger or + equal to 2 (since 2*125 = 250MS/s = max bandwidth of SFP+ port), + we will use the allocation for sorting. + 2. Else, we need to look at the destination block. The priority will + yield to the xport that has the previous destination block + that is the same as this coming destination block. + Note: smaller number return is the higher chance to be picked + """ + sid = SID(xport['send_sid']) + src_addr = sid.src_addr + prev_block = -1 + if src_addr in self._previous_block_ep: + prev_block = self._previous_block_ep[src_addr] + allocation = int(xport['allocation']) + if allocation >= 2: + return allocation + else: + return allocation if prev_block != sid.get_dst_block() else -1; + assert xport_type in ('CTRL', 'ASYNC_MSG', 'TX_DATA', 'RX_DATA') allocation_getter = lambda iface: { 'CTRL': 0, @@ -213,7 +238,9 @@ class XportMgrUDP(object): 'xport_type': xport_type, } for iface_name, iface_info in iteritems(self._chdr_ifaces) - ], key=lambda x: int(x['allocation']), reverse=False) + ] + , key=lambda x: sort_xport_info(x) + , reverse=False) return xport_info def commit_xport(self, sid, xport_info): @@ -247,6 +274,7 @@ class XportMgrUDP(object): self._eth_dispatchers[eth_iface].set_route( sid.reversed(), sender_addr, sender_port) self.log.trace("UDP transport successfully committed!") + self._previous_block_ep[sid.src_addr] = sid.get_dst_block() if xport_info.get('xport_type') == 'TX_DATA': self._allocations[eth_iface] = \ {'tx': self._allocations.get(eth_iface, {}).get('tx', 0) + 1} -- cgit v1.2.3