Пример #1
0
 def _preload_ethtables(self, eth_dispatchers, table_file):
     """
     Populates the ethernet tables from a JSON file
     """
     import json
     try:
         eth_table_data = json.load(open(table_file))
     except ValueError as ex:
         self.log.warning("Bad values in preloading table file: %s",
                          str(ex))
         return
     self.log.info(
         "Preloading Ethernet dispatch tables from JSON file `%s'.",
         table_file)
     for eth_iface, data in iteritems(eth_table_data):
         if eth_iface not in eth_dispatchers:
             self.log.warning("Request to preload eth dispatcher table for "
                              "iface `{}', but no such interface is "
                              "registered. Known interfaces: {}".format(
                                  str(eth_iface),
                                  ",".join(eth_dispatchers.keys())))
             continue
         eth_dispatcher = eth_dispatchers[eth_iface]
         self.log.debug("Preloading {} dispatch table".format(eth_iface))
         try:
             for dst_ep, udp_data in iteritems(data):
                 sid = SID()
                 sid.set_dst_ep(int(dst_ep))
                 eth_dispatcher.set_route(sid, udp_data['ip_addr'],
                                          udp_data['port'],
                                          udp_data.get('mac_addr', None))
         except ValueError as ex:
             self.log.warning("Bad values in preloading table file: %s",
                              str(ex))
Пример #2
0
 def request_xport(self, dst_address, suggested_src_address, xport_type):
     """
     See PeriphManagerBase.request_xport() for docs.
     """
     # Try suggested address first, then just pick the first available one:
     src_address = suggested_src_address
     if src_address not in self._available_endpoints:
         if len(self._available_endpoints) == 0:
             raise RuntimeError(
                 "Depleted pool of SID endpoints for this device!")
         else:
             src_address = self._available_endpoints[0]
     sid = SID(src_address << 16 | dst_address)
     # Note: This SID may change its source address!
     self.log.debug(
         "request_xport(dst=0x%04X, suggested_src_address=0x%04X, xport_type=%s): " \
         "operating on temporary SID: %s",
         dst_address, suggested_src_address, str(xport_type), str(sid))
     # FIXME token!
     assert self.mboard_info['rpc_connection'] in ('remote', 'local')
     if self.mboard_info['rpc_connection'] == 'remote':
         return self._xport_mgrs['udp'].request_xport(
             sid,
             xport_type,
         )
     elif self.mboard_info['rpc_connection'] == 'local':
         return self._xport_mgrs['liberio'].request_xport(
             sid,
             xport_type,
         )
Пример #3
0
 def _preload_ethtables(self, eth_dispatchers, table_file):
     """
     Populates the ethernet tables from a JSON file
     """
     import json
     try:
         eth_table_data = json.load(open(table_file))
     except ValueError as ex:
         self.log.warning(
             "Bad values in preloading table file: %s",
             str(ex)
         )
         return
     self.log.info(
         "Preloading Ethernet dispatch tables from JSON file `%s'.",
         table_file
     )
     for eth_iface, data in iteritems(eth_table_data):
         if eth_iface not in eth_dispatchers:
             self.log.warning(
                 "Request to preload eth dispatcher table for "
                 "iface `{}', but no such interface is "
                 "registered. Known interfaces: {}".format(
                     str(eth_iface),
                     ",".join(eth_dispatchers.keys())
                 )
             )
             continue
         eth_dispatcher = eth_dispatchers[eth_iface]
         self.log.debug("Preloading {} dispatch table".format(eth_iface))
         try:
             for dst_addr, udp_data in iteritems(data):
                 sid = SID()
                 sid.set_dst_addr(int(dst_addr))
                 eth_dispatcher.set_route(
                     sid,
                     udp_data['ip_addr'],
                     udp_data['port'],
                     udp_data.get('mac_addr', None)
                 )
         except ValueError as ex:
             self.log.warning(
                 "Bad values in preloading table file: %s",
                 str(ex)
             )
Пример #4
0
 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 >= alloc_limit:
         return allocation
     else:
         return allocation if prev_block != sid.get_dst_block() else -1;
Пример #5
0
 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
Пример #6
0
    def commit_xport(self, xport_info):
        """
        See PeriphManagerBase.commit_xport() for docs.

        Reminder: All connections are incoming, i.e. "send" or "TX" means
        remote device to local device, and "receive" or "RX" means this local
        device to remote device. "Remote device" can be, for example, a UHD
        session.
        """
        ## Go, go, go
        assert self.mboard_info['rpc_connection'] in ('local')
        sid = SID(xport_info['send_sid'])
        self._available_endpoints.remove(sid.src_ep)
        self.log.debug("Committing transport for SID %s, xport info: %s",
                       str(sid), str(xport_info))
        if self.mboard_info['rpc_connection'] == 'local':
            return self._xport_mgrs['liberio'].commit_xport(sid, xport_info)