def config_output_gbe(self, src_ip, dest_ip, dest_mac, port): src_ip_int = helpers.ip_str2int(src_ip) dest_ip_int = helpers.ip_str2int(dest_ip) mac_int = src_ip_int + 0xc0000000 self.write_int('one_gbe_tx_port', port) self.write_int('one_gbe_tx_ip', dest_ip_int) self.roachhost.write('one_GbE', struct.pack('>Q', mac_int), offset=0) self.roachhost.write('one_GbE', struct.pack('>L', src_ip_int), offset=0x10) self.roachhost.write('one_GbE', struct.pack('>Q', dest_mac), offset=(0x3000 + 8 * (dest_ip_int & 0xff)))
def start_tge_taps(self): """ Start TGE taps on all the boards. Give each core an IP address dependent on the band which the associated X-engine will process. """ base_ip_int = helpers.ip_str2int( self.c_correlator['ten_gbe']['network']) for xn, xeng in enumerate(self.xengs): xeng.board_ip = base_ip_int + 4 * xn #board level IP. ports have this address + {0..3} for i in range(4): self._logger.info('Starting TGE tap core%d on %s' % (i, xeng.hostname)) ip = xeng.board_ip + i mac = 0x02000000 + ip port = 10000 self._logger.info('mac: 0x%x, ip: %s, port: %d' % (mac, helpers.ip_int2str(ip), port)) mac_table = [ 0x2000000 + (base_ip_int & 0xffffff00) + m for m in range(256) ] xeng.roachhost.config_10gbe_core( 'network_link%d_core' % (i + 1), mac, ip, port, mac_table) for n, ip in enumerate(self.band2ip): self._logger.info('band to ip mapping: band %d -> ip %s' % (n, helpers.ip_int2str(ip)))
def disable_debug_mac(self): for xn, xeng in enumerate(self.xengs): for i in range(4): mac_str = struct.pack( '>Q', 0x02000000 + helpers.ip_str2int( self.c_correlator['ten_gbe']['network']) + 1) xeng.roachhost.write('network_link%d_core' % (i + 1), mac_str, offset=(0x3000 + 8 * 1))
def tap_channel(self, channel, dest_ip, dest_mac): self._logger.info('Tapping Channel %d -> IP %s, mac 0x%8x' % (channel, dest_ip, dest_mac)) dest_ip_int = helpers.ip_str2int(dest_ip) base_ip_int = helpers.ip_str2int( self.c_correlator['ten_gbe']['network']) if (dest_ip_int & 0xffffff00) != (base_ip_int & 0xffffff00): self._logger.error( 'Debug ip %s and base ip %s are incompatible' % (dest_ip, self.c_correlator['ten_gbe']['network'])) # update the relevant mac address in the roach's arp table mac_str = struct.pack('>Q', dest_mac) ram_offset = 0x3000 + (8 * (dest_ip_int & 0xff)) for host, fpga in self.fpgas.iteritems(): for i in range(4): fpga.write('network_link%d_core' % (i + 1), mac_str, offset=ram_offset) # now change the destination address of the relevant channel for feng in self.fengs: ram = '' if (feng.band == 'low') and (channel < feng.n_chans): if channel & 1 == 0: ram = 'network_masker0_params' else: ram = 'network_masker1_params' if (feng.band == 'high') and (channel >= feng.n_chans): if channel & 1 == 0: ram = 'network_masker2_params' else: ram = 'network_masker3_params' if ram != '': ram_loc = channel // 2 prev_flags = feng.roachhost.read_int( ram, offset=ram_loc) #offset counts in 32bit words new_flags = (prev_flags & 0xffff0000) + (dest_ip_int & 0xff) feng.roachhost.write_int(ram, new_flags, offset=ram_loc)
def initialise_x_engines(self, passive=False): """ Instantiate an XEngine instance for each one specified in the correlator config file. Append the XEngine instances to the self.xengs list. """ self.xengs = [] for xn, xeng in enumerate(self.config['XEngine']['nodes']): xeng_attrs = {} for key in xeng.keys(): xeng_attrs[key] = xeng[key] for key in self.config['XEngine'].keys(): if (key != 'nodes') and (key not in xeng_attrs.keys()): xeng_attrs[key] = self.config['XEngine'][key] self._logger.info('Constructing X-engine %d (roach: %s)' % (xn, xeng['host'])) self.xengs.append( engines.XEngine(self.fpgas[xeng['host']], 'ctrl', connect_passively=passive, num=xn, **xeng_attrs)) self.n_xengs = len(self.xengs) self._logger.info('%d X-engines constructed' % self.n_xengs) self.band2ip = np.zeros(self.n_xengs, dtype=int) base_ip_int = helpers.ip_str2int( self.c_correlator['ten_gbe']['network']) mc_order = self.c_correlator['ten_gbe']['multicast_order'] for xn, xeng in enumerate(self.xengs): if mc_order != 0: xeng.rcvr_ip = (224 << 24) + (0 << 16) + ( 2 << 8) + 128 + 4 * mc_order * xn if not passive: xeng.subscribe_mc(xeng.rcvr_ip, mc_order) else: xeng.rcvr_ip = base_ip_int + 4 * xn #board level IP. ports have this address + {0..3} self.band2ip[xeng.band] = xeng.rcvr_ip