示例#1
0
 def do_return_to_linux(self):
     if not self.m_devices:
         self.run_dpdk_lspci()
     dpdk_interfaces = []
     for device in self.m_devices.values():
         if device.get('Driver_str') in dpdk_nic_bind.dpdk_drivers:
             dpdk_interfaces.append(device['Slot'])
     if not dpdk_interfaces:
         print('No DPDK bound interfaces.')
         return
     if dpdk_nic_bind.get_igb_uio_usage():
         pid = dpdk_nic_bind.get_pid_using_pci(dpdk_interfaces)
         if pid:
             cmdline = dpdk_nic_bind.read_pid_cmdline(pid)
             print('DPDK interfaces are in use. Unbinding them might cause following process to hang:\npid: %s, cmd: %s' % (pid, cmdline))
             if not dpdk_nic_bind.confirm('Confirm (y/N):'):
                 return
     drivers_table = {
         'rte_ixgbe_pmd': 'ixgbe',
         'rte_igb_pmd': 'igb',
         'rte_i40e_pmd': 'i40e',
         'rte_em_pmd': 'e1000',
         'rte_vmxnet3_pmd': 'vmxnet3',
         'rte_virtio_pmd': 'virtio-pci',
         'rte_enic_pmd': 'enic',
     }
     for pci, info in dpdk_nic_bind.get_info_from_trex(dpdk_interfaces).items():
         if pci not in self.m_devices:
             raise DpdkSetup('Internal error: PCI %s is not found among devices' % pci)
         dev = self.m_devices[pci]
         if info['TRex_Driver'] not in drivers_table:
             print('Got unknown driver %s, description: %s' % (info['TRex_Driver'], dev['Device_str']))
         else:
             print('Returning to Linux %s' % pci)
             dpdk_nic_bind.bind_one(pci, drivers_table[info['TRex_Driver']], False)
示例#2
0
    def do_run (self):
        self.run_dpdk_lspci ()
        if map_driver.dump_interfaces is None or (map_driver.dump_interfaces == [] and map_driver.parent_cfg):
            self.load_config_file()
            if_list=self.m_cfg_dict[0]['interfaces']
        else:
            if_list = map_driver.dump_interfaces
            if not if_list:
                for dev in self.m_devices.values():
                    if dev.get('Driver_str') in dpdk_nic_bind.dpdk_drivers:
                        if_list.append(dev['Slot'])

        if_list = list(map(self.pci_name_to_full_name, if_list))
        for key in if_list:
            if key not in self.m_devices:
                err=" %s does not exist " %key;
                raise DpdkSetup(err)


            if 'Driver_str' in self.m_devices[key]:
                if self.m_devices[key]['Driver_str'] not in dpdk_nic_bind.dpdk_drivers :
                    self.do_bind_one (key)
            else:
                self.do_bind_one (key)

        if if_list and map_driver.args.parent and dpdk_nic_bind.get_igb_uio_usage():
            pid = dpdk_nic_bind.get_pid_using_pci(if_list)
            cmdline = dpdk_nic_bind.read_pid_cmdline(pid)
            print('Some or all of given interfaces are in use by following process:\npid: %s, cmd: %s' % (pid, cmdline))
            if not dpdk_nic_bind.confirm('Ignore and proceed (y/N):'):
                sys.exit(1)
示例#3
0
 def do_return_to_linux(self):
     if not self.m_devices:
         self.run_dpdk_lspci()
     dpdk_interfaces = []
     for device in self.m_devices.values():
         if device.get('Driver_str') in dpdk_nic_bind.dpdk_drivers:
             dpdk_interfaces.append(device['Slot'])
     if not dpdk_interfaces:
         print('No DPDK bound interfaces.')
         return
     if dpdk_nic_bind.get_igb_uio_usage():
         pid = dpdk_nic_bind.get_pid_using_pci(dpdk_interfaces)
         if pid:
             cmdline = dpdk_nic_bind.read_pid_cmdline(pid)
             print('DPDK interfaces are in use. Unbinding them might cause following process to hang:\n%s' % cmdline)
             if not dpdk_nic_bind.confirm('Confirm (y/N):'):
                 return
     drivers_table = {
         'rte_ixgbe_pmd': 'ixgbe',
         'rte_igb_pmd': 'igb',
         'rte_i40e_pmd': 'i40e',
         'rte_em_pmd': 'e1000',
         'rte_vmxnet3_pmd': 'vmxnet3',
         'rte_virtio_pmd': 'virtio',
         'rte_enic_pmd': 'enic',
     }
     for pci, info in dpdk_nic_bind.get_info_from_trex(dpdk_interfaces).items():
         if pci not in self.m_devices:
             raise DpdkSetup('Internal error: PCI %s is not found among devices' % pci)
         dev = self.m_devices[pci]
         if info['TRex_Driver'] not in drivers_table:
             print('Got unknown driver %s, description: %s' % (info['TRex_Driver'], dev['Device_str']))
         else:
             print('Returning to Linux %s' % pci)
             dpdk_nic_bind.bind_one(pci, drivers_table[info['TRex_Driver']], False)
示例#4
0
    def do_run (self):
        self.run_dpdk_lspci ()
        if map_driver.dump_interfaces is None or (map_driver.dump_interfaces == [] and map_driver.parent_cfg):
            self.load_config_file()
            if_list=self.m_cfg_dict[0]['interfaces']
        else:
            if_list = map_driver.dump_interfaces
            if not if_list:
                for dev in self.m_devices.values():
                    if dev.get('Driver_str') in dpdk_nic_bind.dpdk_drivers:
                        if_list.append(dev['Slot'])

        if_list = list(map(self.pci_name_to_full_name, if_list))
        for key in if_list:
            if key not in self.m_devices:
                err=" %s does not exist " %key;
                raise DpdkSetup(err)


            if 'Driver_str' in self.m_devices[key]:
                if self.m_devices[key]['Driver_str'] not in dpdk_nic_bind.dpdk_drivers :
                    self.do_bind_one (key)
            else:
                self.do_bind_one (key)

        if if_list and map_driver.args.parent and dpdk_nic_bind.get_igb_uio_usage():
            pid = dpdk_nic_bind.get_pid_using_pci(if_list)
            cmdline = dpdk_nic_bind.read_pid_cmdline(pid)
            print('Some or all of given interfaces are in use by following process:\n%s' % cmdline)
            if not dpdk_nic_bind.confirm('Ignore and proceed (y/N):'):
                sys.exit(1)
    def do_run (self,only_check_all_mlx=False):
        """ return the number of mellanox drivers"""

        self.run_dpdk_lspci ()
        if (map_driver.parent_args.dump_interfaces is None or
                    (map_driver.parent_args.dump_interfaces == [] and
                            map_driver.parent_args.cfg)):
            self.load_config_file()
            if_list=self.m_cfg_dict[0]['interfaces']
        else:
            if_list = map_driver.parent_args.dump_interfaces
            if not if_list:
                for dev in self.m_devices.values():
                    if dev.get('Driver_str') in dpdk_nic_bind.dpdk_drivers:
                        if_list.append(dev['Slot'])

        if_list = list(map(self.pci_name_to_full_name, if_list))


        # check how many mellanox cards we have
        Mellanox_cnt=0;
        for key in if_list:
            if key not in self.m_devices:
                err=" %s does not exist " %key;
                raise DpdkSetup(err)

            if 'Vendor_str' not in self.m_devices[key]:
                err=" %s does not have Vendor_str " %key;
                raise DpdkSetup(err)

            if self.m_devices[key]['Vendor_str'].find("Mellanox")>-1 :
                Mellanox_cnt=Mellanox_cnt+1


        if not map_driver.parent_args.dump_interfaces:
            if  ((Mellanox_cnt>0) and (Mellanox_cnt!= len(if_list))):
               err=" All driver should be from one vendor. you have at least one driver from Mellanox but not all "; 
               raise DpdkSetup(err)


        if not map_driver.parent_args.dump_interfaces:
            if  Mellanox_cnt>0 :
                self.set_only_mellanox_nics()

        if self.get_only_mellanox_nics():
            if not map_driver.parent_args.no_ofed_check:
                self.verify_ofed_os()
                self.check_ofed_version()

            for key in if_list:
                pci_id=self.m_devices[key]['Slot_str']
                self.tune_mlx5_device (pci_id)
                if 'Interface' in self.m_devices[key]:
                    dev_id=self.m_devices[key]['Interface']
                    self.disable_flow_control_mlx5_device (dev_id)
                    self.set_max_mtu_mlx5_device(dev_id)


        if only_check_all_mlx:
            if Mellanox_cnt >0:
                exit(1);
            else:
                exit(0);

        for key in if_list:
            if key not in self.m_devices:
                err=" %s does not exist " %key;
                raise DpdkSetup(err)

            if 'Driver_str' in self.m_devices[key]:
                if self.m_devices[key]['Driver_str'] not in (dpdk_nic_bind.dpdk_drivers+dpdk_nic_bind.dpdk_and_kernel) :
                    self.do_bind_one (key,(Mellanox_cnt>0))
                    pass;
            else:
                self.do_bind_one (key,(Mellanox_cnt>0))
                pass;

        if (Mellanox_cnt==0):
            # We are not in Mellanox case, we can do this check only in case of Intel (another process is running) 
            if if_list and map_driver.args.parent and (dpdk_nic_bind.get_igb_uio_usage()):
                pid = dpdk_nic_bind.get_pid_using_pci(if_list)
                if pid:
                    cmdline = dpdk_nic_bind.read_pid_cmdline(pid)
                    print('Some or all of given interfaces are in use by following process:\npid: %s, cmd: %s' % (pid, cmdline))
                    if not dpdk_nic_bind.confirm('Ignore and proceed (y/N):'):
                        sys.exit(-1)
                else:
                       print('WARNING: Some other program is using DPDK driver.\nIf it is TRex and you did not configure it for dual run, current command will fail.')
        if map_driver.parent_args.stl and not map_driver.parent_args.no_scapy_server:
            try:
                master_core = self.m_cfg_dict[0]['platform']['master_thread_id']
            except:
                master_core = 0
            ret = os.system('%s scapy_daemon_server restart -c %s' % (sys.executable, master_core))
            if ret:
                print("Could not start scapy_daemon_server, which is needed by GUI to create packets.\nIf you don't need it, use --no-scapy-server flag.")
                sys.exit(-1)

        if Mellanox_cnt:
            return 1
        else:
            return 0
    def do_run (self,only_check_all_mlx=False):
        self.run_dpdk_lspci ()
        if map_driver.dump_interfaces is None or (map_driver.dump_interfaces == [] and map_driver.parent_cfg):
            self.load_config_file()
            if_list=self.m_cfg_dict[0]['interfaces']
        else:
            if_list = map_driver.dump_interfaces
            if not if_list:
                for dev in self.m_devices.values():
                    if dev.get('Driver_str') in dpdk_nic_bind.dpdk_drivers:
                        if_list.append(dev['Slot'])

        if_list = list(map(self.pci_name_to_full_name, if_list))


        # check how many mellanox cards we have
        Mellanox_cnt=0;
        for key in if_list:
            if key not in self.m_devices:
                err=" %s does not exist " %key;
                raise DpdkSetup(err)

            if 'Vendor_str' not in self.m_devices[key]:
                err=" %s does not have Vendor_str " %key;
                raise DpdkSetup(err)

            if self.m_devices[key]['Vendor_str'].find("Mellanox")>-1 :
                Mellanox_cnt=Mellanox_cnt+1


        if not map_driver.dump_interfaces :
            if  ((Mellanox_cnt>0) and (Mellanox_cnt!= len(if_list))):
               err=" All driver should be from one vendor. you have at least one driver from Mellanox but not all "; 
               raise DpdkSetup(err)


        if not map_driver.dump_interfaces :
            if  Mellanox_cnt>0 :
                self.set_only_mellanox_nics()

        if self.get_only_mellanox_nics():
            self.check_ofe_version ()
            for key in if_list:
                pci_id=self.m_devices[key]['Slot_str']
                self.tune_mlx5_device (pci_id)
                if 'Interface' in self.m_devices[key]:
                    dev_id=self.m_devices[key]['Interface']
                    self.disable_flow_control_mlx5_device (dev_id)
                    self.set_max_mtu_mlx5_device(dev_id)


        if only_check_all_mlx:
            if Mellanox_cnt >0:
                exit(1);
            else:
                exit(0);

        for key in if_list:
            if key not in self.m_devices:
                err=" %s does not exist " %key;
                raise DpdkSetup(err)

            if 'Driver_str' in self.m_devices[key]:
                if self.m_devices[key]['Driver_str'] not in (dpdk_nic_bind.dpdk_drivers+dpdk_nic_bind.dpdk_and_kernel) :
                    self.do_bind_one (key,(Mellanox_cnt>0))
                    pass;
            else:
                self.do_bind_one (key,(Mellanox_cnt>0))
                pass;

        if (Mellanox_cnt==0):
            # We are not in Mellanox case, we can do this check only in case of Intel (another process is running) 
            if if_list and map_driver.args.parent and (dpdk_nic_bind.get_igb_uio_usage()):
                pid = dpdk_nic_bind.get_pid_using_pci(if_list)
                if pid:
                    cmdline = dpdk_nic_bind.read_pid_cmdline(pid)
                    print('Some or all of given interfaces are in use by following process:\npid: %s, cmd: %s' % (pid, cmdline))
                    if not dpdk_nic_bind.confirm('Ignore and proceed (y/N):'):
                        sys.exit(1)
                else:
                       print('WARNING: Some other program is using DPDK driver.\nIf it is TRex and you did not configure it for dual run, current command will fail.')