Пример #1
0
    def net_config(self,
                   data_ip=None,
                   data_port=None,
                   dest_ip=None,
                   dest_port=None):
        """
        net_config(self, data_i = None, data_port = None, dest_ip = None, dest_port = None)

        This function overrides the base class Backend net_config for a
        CoDD backend. If the CoDD backend is master, it will program the
        roach for output on 8 adapters, as configured in the config
        file.
        """
        # Only the master will have self.roach != None
        if self.roach:

            def tap_data(ips, gigbit_name):
                rvals = []

                for i in range(0, len(ips)):
                    tap = "tap%i" % i
                    gbe = gigbit_name + '%i' % i
                    bank = "BANK" + chr(65 + i)
                    ip = self._ip_string_to_int(ips[bank])
                    mac = self.bank.mac_base + ip
                    port = self.bank.dataport
                    rvals.append((tap, gbe, mac, ip, port))
                return rvals

            gigbit_name = self.mode.gigabit_interface_name
            dest_ip_register_name = self.mode.dest_ip_register_name
            dest_port_register_name = self.mode.dest_port_register_name

            taps = tap_data(self.mode.cdd_roach_ips, gigbit_name)

            for tap in taps:
                self.roach.tap_start(*tap)

            hpcs = self.mode.cdd_hpcs

            for i in range(0, len(hpcs)):
                ip_reg = dest_ip_register_name + '%i' % i
                pt_reg = dest_port_register_name + '%i' % i
                dest_ip = self.mode.cdd_hpc_ip_info[i][0]
                dest_port = self.mode.cdd_hpc_ip_info[i][1]
                self.roach.write_int(ip_reg, dest_ip)
                self.roach.write_int(pt_reg, dest_port)

            # now set up the arp tables:
            regs = [
                gigbit_name + '%i' % i
                for i in range(len(self.mode.cdd_roach_ips))
            ]
            set_arp(self.roach, regs, self.hpc_macs)

        return 'ok'
    def net_config(self, data_ip=None, data_port=None, dest_ip=None, dest_port=None):
        """
        net_config(self, data_i = None, data_port = None, dest_ip = None, dest_port = None)

        This function overrides the base class Backend net_config for a
        CoDD backend. If the CoDD backend is master, it will program the
        roach for output on 8 adapters, as configured in the config
        file.
        """
        # Only the master will have self.roach != None
        if self.roach:

            def tap_data(ips, gigbit_name):
                rvals = []

                for i in range(0, len(ips)):
                    tap = "tap%i" % i
                    gbe = gigbit_name + "%i" % i
                    bank = "BANK" + chr(65 + i)
                    ip = self._ip_string_to_int(ips[bank])
                    mac = self.bank.mac_base + ip
                    port = self.bank.dataport
                    rvals.append((tap, gbe, mac, ip, port))
                return rvals

            gigbit_name = self.mode.gigabit_interface_name
            dest_ip_register_name = self.mode.dest_ip_register_name
            dest_port_register_name = self.mode.dest_port_register_name

            taps = tap_data(self.mode.cdd_roach_ips, gigbit_name)

            for tap in taps:
                self.roach.tap_start(*tap)

            hpcs = self.mode.cdd_hpcs

            for i in range(0, len(hpcs)):
                ip_reg = dest_ip_register_name + "%i" % i
                pt_reg = dest_port_register_name + "%i" % i
                dest_ip = self.mode.cdd_hpc_ip_info[i][0]
                dest_port = self.mode.cdd_hpc_ip_info[i][1]
                self.roach.write_int(ip_reg, dest_ip)
                self.roach.write_int(pt_reg, dest_port)

            # now set up the arp tables:
            regs = [gigbit_name + "%i" % i for i in range(len(self.mode.cdd_roach_ips))]
            set_arp(self.roach, regs, self.hpc_macs)

        return "ok"
Пример #3
0
    def net_config(self, data_ip = None, data_port = None, dest_ip = None, dest_port = None):
        """net_config(self, roach_ip = None, port = None)

        Configures the 10Gb/s interface on the roach.  This consists of
        sending the tap-start katcp command to initialize the FPGA's
        10Gb/s interface, and updating a couple of registers on the
        ROACH2 with the destination IP address and port of the HPC
        computer.

        All the parameters to this function have 'None' as default
        values; if any is ommitted from the call the function will use
        the corresponding value loaded from the configuration file.

        *data_ip:*
          The IP address. Can be a string (ie '10.17.0.71'), or
          an integer of the same value (for that IP, it would be
          168886343) If given as a string, is converted to the integer
          representation.

        *data_port:*
          The ROACH 10Gb/s port number. An integer with a
          16-bit value; that is, not to exceed 65535.

        *dest_ip:*
          the IP address to send packets to; this is the 10Gb/s
          IP address of the HPC computer. Same format as 'data_ip'.

        *dest_port:*
          The 10Gb/s port on the HPC machine to send data
          to.

        """

        # don't do this if unit testing.
        if self.test_mode:
            return
        # don't do this if we don't control a roach, as can happen in
        # GUPPI CODD modes.
        if not self.roach:
            return

        if data_ip == None:
            data_ip = self._ip_string_to_int(self.bank.datahost)
        else:
            data_ip = self._ip_string_to_int(data_ip)

        if data_port == None:
            data_port = self.bank.dataport

        if dest_ip == None:
            dest_ip = self._ip_string_to_int(self.bank.dest_ip)
        else:
            dest_ip = self._ip_string_to_int(dest_ip)

        if dest_port == None:
            dest_port = self.bank.dest_port

        if type(data_ip) != int or type(data_port) != int \
                or type (dest_ip) != int or type (dest_port) != int \
                or data_port > 65535 or dest_port > 65535:
            raise Exception("Improperly formatted IP addresses and/or ports. "
                            "IP must be integer values or dotted quad strings. "
                            "Ports must be integer values < 65535.")

        gigbit_name = self.mode.gigabit_interface_name
        dest_ip_register_name = self.mode.dest_ip_register_name
        dest_port_register_name = self.mode.dest_port_register_name

        self.roach.tap_start("tap0", gigbit_name,
                             self.bank.mac_base + data_ip, data_ip, data_port)
        self.roach.write_int(dest_ip_register_name, dest_ip)
        self.roach.write_int(dest_port_register_name, dest_port)
        regs = [gigbit_name]
        time.sleep(1)
        set_arp(self.roach, regs, self.hpc_macs)

        return 'ok'
Пример #4
0
    def net_config(self, data_ip = None, data_port = None, dest_ip = None, dest_port = None):
        """net_config(self, roach_ip = None, port = None)

        Configures the 10Gb/s interface on the roach.  This consists of
        sending the tap-start katcp command to initialize the FPGA's
        10Gb/s interface, and updating a couple of registers on the
        ROACH2 with the destination IP address and port of the HPC
        computer.

        All the parameters to this function have 'None' as default
        values; if any is ommitted from the call the function will use
        the corresponding value loaded from the configuration file.

        *data_ip:*
          The IP address. Can be a string (ie '10.17.0.71'), or
          an integer of the same value (for that IP, it would be
          168886343) If given as a string, is converted to the integer
          representation.

        *data_port:*
          The ROACH 10Gb/s port number. An integer with a
          16-bit value; that is, not to exceed 65535.

        *dest_ip:*
          the IP address to send packets to; this is the 10Gb/s
          IP address of the HPC computer. Same format as 'data_ip'.

        *dest_port:*
          The 10Gb/s port on the HPC machine to send data
          to.

        """

        # don't do this if unit testing.
        if self.test_mode:
            return
        # don't do this if we don't control a roach, as can happen in
        # GUPPI CODD modes.
        if not self.roach:
            return

        if data_ip == None:
            data_ip = self._ip_string_to_int(self.bank.datahost)
        else:
            data_ip = self._ip_string_to_int(data_ip)

        if data_port == None:
            data_port = self.bank.dataport

        if dest_ip == None:
            dest_ip = self._ip_string_to_int(self.bank.dest_ip)
        else:
            dest_ip = self._ip_string_to_int(dest_ip)

        if dest_port == None:
            dest_port = self.bank.dest_port

        if type(data_ip) != int or type(data_port) != int \
                or type (dest_ip) != int or type (dest_port) != int \
                or data_port > 65535 or dest_port > 65535:
            raise Exception("Improperly formatted IP addresses and/or ports. "
                            "IP must be integer values or dotted quad strings. "
                            "Ports must be integer values < 65535.")

        gigbit_name = self.mode.gigabit_interface_name
        dest_ip_register_name = self.mode.dest_ip_register_name
        dest_port_register_name = self.mode.dest_port_register_name

        self.roach.tap_start("tap0", gigbit_name,
                             self.bank.mac_base + data_ip, data_ip, data_port)
        self.roach.write_int(dest_ip_register_name, dest_ip)
        self.roach.write_int(dest_port_register_name, dest_port)
        regs = [gigbit_name]
        time.sleep(1)
        set_arp(self.roach, regs, self.hpc_macs)

        return 'ok'