Beispiel #1
0
    def test_retrieve_eeprom(self):
        """
        Test ethtool app dump eeprom function
        """
        # require md5sum to check file
        out = self.dut.send_expect("whereis md5sum", "# ")
        self.verify("/usr/bin/md5sum" in out,
                    "This case required md5sum installed on DUT")

        self.dut.send_expect(self.cmd, "EthApp>", 60)

        portsinfo = []
        ori_drivers = []

        for portid in range(len(self.ports)):
            # dump eemprom by userspace ethtool
            self.dut.send_expect("eeprom %d eeprom_%d.bin" % (portid, portid),
                                 "EthApp>")
            portinfo = {
                'portid': portid,
                'eeprom_file': 'eeprom_%d.bin' % portid
            }
            portsinfo.append(portinfo)

        self.dut.send_expect("quit", "# ")

        for index in range(len(self.ports)):
            port = self.ports[index]
            netdev = self.dut.ports_info[port]['port']
            portinfo = portsinfo[index]
            # strip orignal driver
            portinfo['ori_driver'] = netdev.get_nic_driver()
            portinfo['net_dev'] = netdev
            # bind to default driver
            netdev.bind_driver()
            # get linux interface
            intf = netdev.get_interface_name()
            ethtool_eeprom = "ethtool_eeprom_%d.bin" % index
            # dump eemprom by linux ethtool
            self.dut.send_expect(
                "ethtool --eeprom-dump %s raw on > %s" %
                (intf, ethtool_eeprom), "# ")
            # wait for file ready
            time.sleep(2)
            portinfo['ethtool_eeprom'] = ethtool_eeprom
            # bind to original driver
            portinfo['net_dev'].bind_driver(portinfo['ori_driver'])

        for index in range(len(self.ports)):
            md5 = self.strip_md5(portsinfo[index]['eeprom_file'])
            md5_ref = self.strip_md5(portsinfo[index]['ethtool_eeprom'])
            print utils.GREEN("Reference eeprom md5 %s" % md5)
            print utils.GREEN("Reference eeprom md5_ref %s" % md5_ref)
            self.verify(md5 == md5_ref,
                        "Dumped eeprom not same as linux dumped")
Beispiel #2
0
 def check_packet_transmission(self, pkt_types, layer_configs=None):
     time.sleep(1)
     for pkt_type in pkt_types.keys():
         pkt_names = pkt_types[pkt_type]
         pkt = Packet(pkt_type=pkt_type)
         if layer_configs:
             for layer in layer_configs.keys():
                 pkt.config_layer(layer, layer_configs[layer])
         inst = self.tester.tcpdump_sniff_packets(self.tester_iface,
                                                  count=1,
                                                  timeout=8)
         pkt.send_pkt(tx_port=self.tester_iface)
         out = self.dut.get_session_output(timeout=2)
         time.sleep(1)
         self.tester.load_tcpdump_sniff_packets(inst)
         if self.printFlag:  # debug output
             print out
         for pkt_layer_name in pkt_names:
             if self.printFlag:  # debug output
                 print pkt_layer_name
             if pkt_layer_name not in out:
                 print utils.RED("Fail to detect %s" % pkt_layer_name)
                 if not self.printFlag:
                     raise VerifyFailure("Failed to detect %s" %
                                         pkt_layer_name)
         else:
             print utils.GREEN("Detected %s successfully" % pkt_type)
             time.sleep(1)
    def test_vm_power_managment_freqdown(self):
        """
        Check host cpu frequency can scale down in VM
        """
        guest_cmd = self.vm_power_dir + \
            "guest_cli/build/guest_vm_power_mgr -c 0xf -n 4 -- --vm-name=%s --vcpu-list=0,1,2,3" % self.vm_name
        out = self.vm_dut.send_expect(guest_cmd, "vmpower\(guest\)>", 120)

        for vcpu in range(self.core_num):
            self.vm_dut.send_expect("set_cpu_freq %d max" % vcpu,
                                    "vmpower\(guest\)>")

        for vcpu in range(self.core_num):
            # map between host cpu and guest cpu
            ori_freq = self.get_cpu_frequency(self.vcpu_map[vcpu])
            # get cpu frequencies range
            freqs = self.get_cpu_freqs(vcpu)

            for loop in range(len(freqs) - 1):
                # connect vm power host and guest
                self.vm_dut.send_expect("set_cpu_freq %d down" % vcpu,
                                        "vmpower\(guest\)>")
                cur_freq = self.get_cpu_frequency(self.vcpu_map[vcpu])
                print utils.GREEN("After freqency down, freq is %d\n" %
                                  cur_freq)
                self.verify(ori_freq > cur_freq,
                            "Cpu freqenecy can not scale down")
                ori_freq = cur_freq

        self.vm_dut.send_expect("quit", "# ")
Beispiel #4
0
    def test_vm_power_managment_frequp(self):
        """
        Check host cpu frequency can scale up in VM
        """
        guest_cmd = self.vm_power_dir + \
            "guest_cli/build/guest_vm_power_mgr -c 0xf -n 4 -- -i"
        out = self.vm_dut.send_expect(guest_cmd, "vmpower\(guest\)>", 120)

        for vcpu in range(self.core_num):
            self.vm_dut.send_expect(
                "set_cpu_freq %d min" % vcpu, "vmpower\(guest\)>")

        for vcpu in range(self.core_num):
            ori_freq = self.get_cpu_frequency(self.vcpu_map[vcpu])
            # get cpu frequencies range
            freqs = self.get_cpu_freqs(vcpu)
            for loop in range(len(freqs)-1):
                self.vm_dut.send_expect(
                    "set_cpu_freq %d up" % vcpu, "vmpower\(guest\)>")
                cur_freq = self.get_cpu_frequency(self.vcpu_map[vcpu])
                print utils.GREEN("After freqency up, freq is %d\n" % cur_freq)
                self.verify(
                    cur_freq > ori_freq, "Cpu freqenecy can not scale up")
                ori_freq = cur_freq

        self.vm_dut.send_expect("quit", "# ")
def send_email(sender, mailto, message, smtp_server):

    try:
        smtp = smtplib.SMTP(smtp_server)
        smtp.sendmail(sender, mailto, message.as_string())
        smtp.quit()
        print utils.GREEN("Email sent successfully.")
    except Exception, e:
        print utils.RED("Failed to send email " + str(e))
Beispiel #6
0
 def compare_checksum(self):
     chksums_ref =  self.get_chksums('/tmp/ref_pkt.pcap')
     chksums =  self.get_chksums('/tmp/sniff_{0}.pcap'.format(self.tester_iface))
     self.logger.info("chksums_ref :: %s"%chksums_ref)
     self.logger.info("chksums :: %s"%chksums)
     # verify saved pcap checksum same to expected checksum
     for key in chksums_ref:
         self.verify(int(chksums[key], 16) == int(chksums_ref[key], 16), "%s not matched to %s" % (key, chksums_ref[key]))
     print utils.GREEN("Checksum is ok")
Beispiel #7
0
    def handle_dev_destroy(self, **opts):
        if 'pf_idx' in opts.keys():
            port = int(opts['pf_idx'])

            try:
                print utils.GREEN("destroy vfs on port %d" % port)
                self.host_dut.destroy_sriov_vfs_by_port(port)
            except:
                print utils.RED("Failed to destroy vf as requested!!!")
Beispiel #8
0
    def check_packet_transmission(self, pkt_types):
        time.sleep(1)
        for pkt_type in pkt_types.keys():
            intf = self.src_intf
            pkt = Packet(pkt_type=pkt_type)
            # set packet every layer's input parameters
            if 'layer_configs' in pkt_types[pkt_type].keys():
                pkt_configs = pkt_types[pkt_type]['layer_configs']
                if pkt_configs:
                    for layer in pkt_configs.keys():
                        pkt.config_layer(layer, pkt_configs[layer])
            pkt.send_pkt(tx_port=self.src_intf)

            # check vm testpmd packet received information
            if 'vm' in pkt_types[pkt_type].keys():
                out = self.vm0_testpmd.get_output(timeout=2)
                if self.printFlag:  # debug output
                    print out
                for pkt_attribute in pkt_types[pkt_type]['vm']:
                    if self.printFlag:  # debug output
                        print pkt_attribute
                    if pkt_attribute not in out:
                        print utils.RED('Fail to detect %s' % pkt_attribute)
                        if not self.printFlag:  # print out all info in debug mode
                            raise VerifyFailure('Failed to detect %s' %
                                                pkt_attribute)
                print utils.GREEN('VM detected %s successfully' % pkt_type)

            # check dut testpmd packet received information
            if 'dut' in pkt_types[pkt_type].keys():
                out = self.host_testpmd.get_output(timeout=2)
                if self.printFlag:  # debug output
                    print out
                for pkt_attribute in pkt_types[pkt_type]['dut']:
                    if self.printFlag:  # debug output
                        print pkt_attribute
                    if pkt_attribute not in out:
                        print utils.RED('Fail to detect %s' % pkt_attribute)
                        if not self.printFlag:  # print out all info in debug mode
                            raise VerifyFailure('Failed to detect %s' %
                                                pkt_attribute)
                print utils.GREEN('DUT detected %s successfully' % pkt_type)
            time.sleep(1)
Beispiel #9
0
 def run_test(self, pkt_types):
     time.sleep(1)
     for pkt_type in pkt_types.keys():
         pkt_names = pkt_types[pkt_type]
         pkt = Packet(pkt_type=pkt_type)
         pkt.send_pkt(tx_port=self.tester_iface)
         out = self.dut.get_session_output(timeout=2)
         for pkt_layer_name in pkt_names:
             if pkt_layer_name not in out:
                 print utils.RED("Fail to detect %s" % pkt_layer_name)
                 raise VerifyFailure("Failed to detect %s" % pkt_layer_name)            
         print utils.GREEN("Detected %s successfully" % pkt_type)
Beispiel #10
0
    def test_rss_key_size(self):
        nic_rss_key_size = {
            "fortville_eagle": 52,
            "fortville_spirit": 52,
            "fortville_spirit_single": 52,
            "fortville_25g": 52,
            "niantic": 40,
            "e1000": 40,
            "redrockcanyou": 40,
            "atwood": 40,
            "boulderrapid": 40,
            "fortpark_TLV": 52
        }
        self.verify(self.nic in nic_rss_key_size.keys(),
                    "Not supporte rss key on %s" % self.nic)

        dutPorts = self.dut.get_ports(self.nic)
        localPort = self.tester.get_local_port(dutPorts[0])
        itf = self.tester.get_interface(localPort)
        self.dut.kill_all()
        self.dut.send_expect(
            "./%s/app/testpmd  -c fffff -n %d -- -i --coremask=0xffffe --rxq=2 --txq=2"
            % (self.target, self.dut.get_memory_channels()), "testpmd> ", 120)
        self.dut.send_expect("start", "testpmd> ", 120)
        out = self.dut.send_expect("show port info all", "testpmd> ", 120)
        self.dut.send_expect("quit", "# ", 30)

        pattern = re.compile("Hash key size in bytes:\s(\d+)")
        m = pattern.search(out)
        if m is not None:
            size = m.group(1)
            print utils.GREEN("******************")
            print utils.GREEN(
                "NIC %s hash size %d and expected %d" %
                (self.nic, int(size), nic_rss_key_size[self.nic]))
            if (nic_rss_key_size[self.nic] == int(size)):
                self.verify(True, "pass")
            else:
                self.verify(False, "fail")
Beispiel #11
0
 def run_nvgre_cope(self, pkt_nvgre):
     time.sleep(1)
     for pkts in pkt_nvgre:
         pkt = Packet()
         pkt.assign_layers(pkts[2])
         if 'inner_icmp' in pkts[2]:
             pkt.config_layers([('ipv6',{'nh':47}), ('inner_ipv6', {'nh': 58})])
         else:
             pkt.config_layers([('ipv6',{'nh':47}),('inner_ipv6', {'nh': 132})])
         pkt.send_pkt(tx_port=self.tester_iface)
         out = self.dut.get_session_output(timeout=2)
         for pkt_layer_name in pkts[1]:
             if pkt_layer_name not in out:
                 print utils.RED("Fail to detect %s" % pkt_layer_name)
                 raise VerifyFailure("Failed to detect %s" % pkt_layer_name)
         print utils.GREEN("Detected %s successfully" % pkts[0])
Beispiel #12
0
    def handle_dev_gen(self, **opts):
        if 'pf_idx' in opts.keys():
            port = int(opts['pf_idx'])
            if 'vf_num' in opts.keys():
                vf_num = int(opts['vf_num'])
            else:
                print utils.RED("No vf_num for port %d, assum one VF" % port)
                vf_num = 1
            if 'driver' in opts.keys():
                driver = opts['driver']

            try:
                print utils.GREEN("create vf %d %d %s" %
                                  (port, vf_num, driver))
                self.host_dut.generate_sriov_vfs_by_port(port, vf_num, driver)
                self.reset_pf_cmds(port)
            except:
                print utils.RED("Failed to create vf as requested!!!")
                raise VirtDeviceCreateException
Beispiel #13
0
    def test_nsh(self):
        """
        check if NSH packets can be normally detected by Fortpark and Fortville
        """
        self.verify(self.kdriver == 'i40e', "NSH packet detection only supported by i40e driver nic")

        nsh_packets = {'ether+nsh': 'Ether(type=0x894f)/NSH(Len=0x6,NextProto=0x0,NSP=0x000002,NSI=0xff)', \
                       'ether+nsh+ip': 'Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x1,NSP=0x000002,NSI=0xff)/IP()', \
                       'ether+nsh+ip+icmp': 'Ether(type=0x894f)/NSH(Len=0x6,NextProto=0x1,NSP=0x000002,NSI=0xff)/IP()/ICMP()', \
                       'ether+nsh+ip_frag': 'Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x1,NSP=0x000002,NSI=0xff)/IP(frag=1,flags="MF")', \
                       'ether+nsh+ip+tcp': 'Ether(type=0x894f)/NSH(Len=0x6,NextProto=0x1,NSP=0x000002,NSI=0xff)/IP()/TCP()', \
                       'ether+nsh+ip+udp': 'Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x1,NSP=0x000002,NSI=0xff)/IP()/UDP()', \
                       'ether+nsh+ip+sctp': 'Ether(type=0x894f)/NSH(Len=0x6,NextProto=0x1,NSP=0x000002,NSI=0xff)/IP()/SCTP(tag=1)/SCTPChunkData(data=\'X\' * 16)', \
                       'ether+nsh+ipv6': 'Ether(type=0x894f)/NSH(Len=0x6,NextProto=0x2,NSP=0x000002,NSI=0xff)/IPv6()', \
                       'ether+nsh+ipv6+icmp': 'Ether(type=0x894f)/NSH(Len=0x6,NextProto=0x2,NSP=0x000002,NSI=0xff)/IPv6(src="2001::1",dst="2003::2",nh=0x3A)/ICMP()',
                       'ether+nsh+ipv6_frag': 'Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x2,NSP=0x000002,NSI=0xff)/IPv6()/IPv6ExtHdrFragment()', \
                       'ether+nsh+ipv6+tcp': 'Ether(type=0x894f)/NSH(Len=0x6,NextProto=0x2,NSP=0x000002,NSI=0xff)/IPv6()/TCP()', \
                       'ether+nsh+ipv6+udp': 'Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x2,NSP=0x000002,NSI=0xff)/IPv6()/UDP()', \
                       'ether+nsh+ipv6+sctp': 'Ether(type=0x894f)/NSH(Len=0x6,NextProto=0x2,NSP=0x000002,NSI=0xff)/IPv6(nh=0x84)/SCTP(tag=1)/SCTPChunkData("x" * 16)'
                       }

        nsh_detect_message = {"ether+nsh": "L2_ETHER_NSH", \
                              "ether+nsh+ip": "L2_ETHER_NSH L3_IPV4_EXT_UNKNOWN L4_NONFRAG", \
                              "ether+nsh+ip+icmp": "L2_ETHER_NSH L3_IPV4_EXT_UNKNOWN L4_ICMP", \
                              "ether+nsh+ip_frag": "L2_ETHER_NSH L3_IPV4_EXT_UNKNOWN L4_FRAG", \
                              "ether+nsh+ip+tcp": "L2_ETHER_NSH L3_IPV4_EXT_UNKNOWN L4_TCP", \
                              "ether+nsh+ip+udp": "L2_ETHER_NSH L3_IPV4_EXT_UNKNOWN L4_UDP", \
                              "ether+nsh+ip+sctp": "L2_ETHER_NSH L3_IPV4_EXT_UNKNOWN L4_SCTP", \
                              "ether+nsh+ipv6": "L2_ETHER_NSH L3_IPV6_EXT_UNKNOWN L4_NONFRAG", \
                              "ether+nsh+ipv6+icmp": "L2_ETHER_NSH L3_IPV6_EXT_UNKNOWN L4_ICMP", \
                              "ether+nsh+ipv6_frag": "L2_ETHER_NSH L3_IPV6_EXT_UNKNOWN L4_FRAG", \
                              "ether+nsh+ipv6+tcp": "L2_ETHER_NSH L3_IPV6_EXT_UNKNOWN L4_TCP", \
                              "ether+nsh+ipv6+udp": "L2_ETHER_NSH L3_IPV6_EXT_UNKNOWN L4_UDP", \
                              "ether+nsh+ipv6+sctp": "L2_ETHER_NSH L3_IPV6_EXT_UNKNOWN L4_SCTP"
                             }

        for packet in nsh_packets:
            self.tester.scapy_foreground()
            self.tester.scapy_append("sendp([%s],iface='%s')" % (nsh_packets[packet], self.tester_iface))
            self.tester.scapy_execute()
            out = self.dut.get_session_output(timeout=2)
            self.verify(nsh_detect_message[packet] in out, "Packet Detection Error for : %s" % packet)
            print utils.GREEN("Detected packet %s Successfully" % packet)
Beispiel #14
0
 def run_test(self, sw_ptype, pkt_types, chk_types):
     """
     Generate and send packet according to packet type, detect each packet 
     layer.
     """
     for pkt_type in pkt_types.keys():
         if chk_types != None:
             pkt_names = chk_types[pkt_type]
         else:
             pkt_names = pkt_types[pkt_type]
         pkt = Packet(pkt_type=pkt_type)
         pkt.send_pkt(tx_port=self.tester_iface)
         out = self.dut.get_session_output(timeout=2)
         self.verify(sw_ptype in out,
                     "Failed to detect correct ptype value")
         for pkt_layer_name in pkt_names:
             if pkt_layer_name not in out:
                 print utils.RED("Fail to detect %s" % pkt_layer_name)
                 raise VerifyFailure("Failed to detect %s" % pkt_layer_name)
         print utils.GREEN("Detected %s successfully" % pkt_type)
Beispiel #15
0
    def test_l2pkt_detect(self):
        """
        Check whether L2 packet can be detected"
        """
        self.verify(("fortville" in self.nic or "fortpark_TLV" in self.nic),
                    "L2 packet detect only support by Fortville")
        self.L2_types = {
            "TIMESYNC": "L2_ETHER_TIMESYNC",
            "ARP": "L2_ETHER_ARP",
            "LLDP": "L2_ETHER_LLDP",
        }

        for l2_type in self.L2_types.keys():
            pkt_name = self.L2_types[l2_type]
            pkt = Packet(pkt_type=l2_type)
            pkt.send_pkt(tx_port=self.tester_iface)
            out = self.dut.get_session_output(timeout=2)
            if pkt_name in out:
                print utils.GREEN("Detected L2 %s successfully" % l2_type)
            else:
                raise VerifyFailure("Failed to detect L2 %s" % l2_type)
Beispiel #16
0
    def test_vm_power_managment_freqmin(self):
        """
        Check host cpu frequency can scale to min in VM
        """
        guest_cmd = self.vm_power_dir + \
            "guest_cli/build/guest_vm_power_mgr -c 0xf -n 4 -- -i"
        out = self.vm_dut.send_expect(guest_cmd, "vmpower\(guest\)>", 120)

        min_freq_path = "cat /sys/devices/system/cpu/cpu%s/cpufreq/" + \
                        "cpuinfo_min_freq"
        for vcpu in range(self.core_num):
            self.vm_dut.send_expect(
                "set_cpu_freq %d min" % vcpu, "vmpower\(guest\)>")
            freq = self.get_cpu_frequency(self.vcpu_map[vcpu])

            out = self.dut.alt_session.send_expect(
                min_freq_path % self.vcpu_map[vcpu], "# ")
            min_freq = int(out)

            self.verify(freq == min_freq, "Cpu min frequency not correct")
            print utils.GREEN("After freqency min, freq is %d\n" % min_freq)
        self.vm_dut.send_expect("quit", "# ")
Beispiel #17
0
 def count_packet(self, out, mac):
     """
     Count packet sum number.
     """
     lines = out.split("\r\n")
     cnt = 0
     count_pkt = 0
     # count the packet received from specified mac address.
     for line in lines:
         line = line.strip()
         if len(line) != 0 and line.startswith(("src=",)):
             for item in line.split(" "):
                 item = item.strip()
                 if(item == ("src=%s" % mac)):
                     cnt = cnt + 1
                 elif(item == "L4_UDP"):
                     cnt = cnt + 1
             if (cnt == 2):
                 count_pkt = count_pkt + 1
             cnt = 0
     print utils.GREEN("The number of UDP packets received by pf is %d." % count_pkt)
     return count_pkt
Beispiel #18
0
    def test_perf_vmdq_performance(self):
        """
        Try  different configuration and different packe size
        """

        self.tester.get_interface(self.tester.get_local_port(
            self.dut_ports[0]))

        frame_sizes = [64, 128, 256, 512, 1024, 1280, 1518]
        for config in self.core_configs:

            print utils.BLUE(config["cores"])
            self.dut.kill_all()

            core_config = config['cores']
            core_list = self.dut.get_core_list(core_config,
                                               socket=self.ports_socket)
            core_mask = utils.create_mask(core_list)
            portmask = utils.create_mask(self.dut.get_ports())
            if self.nic in ("niantic", "springfountain"):
                self.queues = 64
                self.dut.send_expect(
                    "examples/vmdq/build/vmdq_app -n %d -c %s -- -p %s --nb-pools 64&"
                    % (self.dut.get_memory_channels(), core_mask, portmask),
                    "reading queues", 30)
            elif self.nic in ("fortville_spirit", "fortville_spirit_single"):
                self.queues = 63
                self.dut.send_expect(
                    "examples/vmdq/build/vmdq_app -n %d -c %s -- -p %s --nb-pools 63&"
                    % (self.dut.get_memory_channels(), core_mask, portmask),
                    "reading queues", 30)
            elif self.nic in ("fortville_eagle"):
                self.queues = 34
                self.dut.send_expect(
                    "examples/vmdq/build/vmdq_app -n %d -c %s -- -p %s --nb-pools 34&"
                    % (self.dut.get_memory_channels(), core_mask, portmask),
                    "reading queues", 30)
            else:
                self.queues = 8
                self.dut.send_expect(
                    "examples/vmdq/build/vmdq_app -n %d -c %s -- -p %s --nb-pools 8&"
                    % (self.dut.get_memory_channels(), core_mask, portmask),
                    "reading queues", 30)

            tx_port = self.tester.get_local_port(self.dut_ports[0])
            rx_port = self.tester.get_local_port(self.dut_ports[1])

            print utils.GREEN("Waiting for application to initialize")
            sleep(5)

            for frame_size in frame_sizes:

                TestVmdq.current_frame_size = frame_size

                print utils.BLUE(str(frame_size))

                self.tester.scapy_append('dstmac="%s"' % self.destmac_port0)
                tx_mac = self.tester.get_mac(tx_port)
                self.tester.scapy_append('srcmac="%s"' % tx_mac)
                self.tester.scapy_append(
                    'flows = [Ether(src=srcmac,dst=dstmac)/Dot1Q(vlan=0)/("X"*%d)]'
                    % (frame_size - TestVmdq.ip_dot1q_header_size))
                self.tester.scapy_append('wrpcap("test1.pcap", flows)')
                self.tester.scapy_execute()

                self.tester.scapy_append('dstmac="%s"' % self.destmac_port1)
                tx_mac = self.tester.get_mac(rx_port)
                self.tester.scapy_append('srcmac="%s"' % tx_mac)
                self.tester.scapy_append(
                    'flows = [Ether(src=srcmac,dst=dstmac)/Dot1Q(vlan=0)/("X"*%d)]'
                    % (frame_size - TestVmdq.ip_dot1q_header_size))
                self.tester.scapy_append('wrpcap("test2.pcap", flows)')
                self.tester.scapy_execute()

                self.vlan_repeat = self.queues
                self.da_repeat = self.queues

                tgen_input = []
                tgen_input.append((tx_port, rx_port, "test1.pcap"))
                tgen_input.append((rx_port, tx_port, "test2.pcap"))
                _, pps = self.tester.traffic_generator_throughput(tgen_input)
                config['mpps'][frame_size] = pps / 1000000.0

        for n in range(len(self.core_configs)):
            for size in frame_sizes:
                self.verify(self.core_configs[n]['mpps'][size] is not 0,
                            "No traffic detected")

        # Print results
        self.result_table_create(['Frame size'] +
                                 [n['cores'] for n in self.core_configs])

        for size in frame_sizes:
            self.result_table_add([size] +
                                  [n['mpps'][size] for n in self.core_configs])

        self.result_table_print()
Beispiel #19
0
    def test_VEB_switching_inter_vfs_and_pf(self):
        """
        DPDK PF, then create 2VFs, PF in the host running dpdk testpmd, VFs
        running dpdk testpmd, VF1 send traffic to VF2, check if VF2 can receive
        the packets. send traffic from PF to VF1, ensure PF->VF1; send traffic
        from VF1 to PF, ensure VF1->PF can work.
        """
        # VF->PF
        self.setup_env(driver=self.drivername)
        self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" % (self.target, self.pf_pci), "testpmd>", 120)
        self.dut.send_expect("set fwd rxonly", "testpmd>")
        self.dut.send_expect("set verbose 1", "testpmd>")
        self.dut.send_expect("set promisc all off", "testpmd>")
        self.dut.send_expect("start", "testpmd>")
        time.sleep(2)
        self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --eth-peer=0,%s" % (self.target, self.sriov_vfs_port[0].pci, self.pf_mac_address), "testpmd>", 120)
        self.session_secondary.send_expect("mac_addr add 0 %s" % self.vf0_mac, "testpmd>")
        self.session_secondary.send_expect("set fwd txonly", "testpmd>")
        self.session_secondary.send_expect("set promisc all off", "testpmd>")
        self.session_secondary.send_expect("start", "testpmd>")
        time.sleep(2)
        # print the packets which received by pf, this caused most packets missed.
        out = self.dut.get_session_output(timeout=1)
        self.session_secondary.send_expect("stop", "testpmd>", 2)
        self.dut.send_expect("stop", "testpmd>", 2)

        count_pkt = self.count_packet(out, self.vf0_mac)
        vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
        pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
        self.verify(vf0_tx_stats[0] > 1000, "no packet was sent by VF0")
        self.verify(count_pkt > 100, "no packet was received by PF")
        self.session_secondary.send_expect("quit", "# ")
        time.sleep(2)
        self.dut.send_expect("quit", "# ")
        time.sleep(2)
 
        # PF->VF
        self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --eth-peer=0,%s" % (self.target, self.pf_pci, self.vf0_mac), "testpmd>", 120)
        self.dut.send_expect("set fwd txonly", "testpmd>")
        self.dut.send_expect("set promisc all off", "testpmd>")
        
        self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i" % (self.target, self.sriov_vfs_port[0].pci), "testpmd>", 120)
        self.session_secondary.send_expect("mac_addr add 0 %s" % self.vf0_mac, "testpmd>")
        self.session_secondary.send_expect("set fwd rxonly", "testpmd>")
        self.session_secondary.send_expect("set promisc all off", "testpmd>")
        self.session_secondary.send_expect("start", "testpmd>")
        time.sleep(2)
        self.dut.send_expect("start", "testpmd>")
        time.sleep(2)
        self.dut.send_expect("stop", "testpmd>", 2)
        self.session_secondary.send_expect("stop", "testpmd>", 2)

        vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
        print utils.GREEN("The number of UDP packets received by vf is %d." % vf0_rx_stats[0])
        self.verify(vf0_rx_stats[0] > 100, "no packet was received by VF0")
        self.session_secondary.send_expect("quit", "# ")
        time.sleep(2)
        self.dut.send_expect("quit", "# ")
        time.sleep(2)

        # tester->VF
        self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" % (self.target, self.pf_pci), "testpmd>", 120)
        self.dut.send_expect("set fwd mac", "testpmd>")
        self.dut.send_expect("set promisc all off", "testpmd>")
        self.dut.send_expect("start", "testpmd>")
        time.sleep(2)

        self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i" % (self.target, self.sriov_vfs_port[0].pci), "testpmd>", 120)
        self.session_secondary.send_expect("mac_addr add 0 %s" % self.vf0_mac, "testpmd>")
        self.session_secondary.send_expect("set fwd rxonly", "testpmd>")
        self.session_secondary.send_expect("set promisc all off", "testpmd>")
        self.session_secondary.send_expect("start", "testpmd>")
        time.sleep(2)

        vf0_start_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
        self.send_packet(self.vf0_mac, self.tester_itf)
        time.sleep(2)
        self.session_secondary.send_expect("stop", "testpmd>", 2)
        self.dut.send_expect("stop", "testpmd>", 2)
        vf0_end_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
        self.verify(vf0_end_rx_stats[0] - vf0_start_rx_stats[0] == 1, "no packet was received by VF0")
 
        self.dut.send_expect("start", "testpmd>")
        time.sleep(2)
        self.session_secondary.send_expect("start", "testpmd>")
        time.sleep(2)
        vf0_start_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
        pf_start_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
        pf_start_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
        self.send_packet(self.pf_mac_address, self.tester_itf)
        time.sleep(2)
        self.session_secondary.send_expect("stop", "testpmd>", 2)
        self.dut.send_expect("stop", "testpmd>", 2)
        vf0_end_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
        pf_end_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
        pf_end_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
        self.verify(pf_end_tx_stats[0] - pf_start_tx_stats[0] == 1, "no packet was sent by PF")
        self.verify(pf_end_rx_stats[0] - pf_start_rx_stats[0] == 1, "no packet was received by PF")
        self.verify(vf0_end_rx_stats[0] - vf0_start_rx_stats[0] == 0, "VF0 received unexpected packet")
        self.session_secondary.send_expect("quit", "# ")
        time.sleep(2)
        self.dut.send_expect("quit", "# ")
        time.sleep(2)

        # VF1->VF2
        self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" % (self.target, self.pf_pci), "testpmd>", 120)
        self.dut.send_expect("set promisc all off", "testpmd>")

        self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --eth-peer=0,%s" % (self.target, self.sriov_vfs_port[0].pci, self.vf1_mac), "testpmd>", 120)
        self.session_secondary.send_expect("set fwd txonly", "testpmd>")
        self.session_secondary.send_expect("set promisc all off", "testpmd>")
        time.sleep(2)

        self.session_third.send_expect("./%s/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test3 -- -i" % (self.target, self.sriov_vfs_port[1].pci), "testpmd>", 120)
        self.session_third.send_expect("mac_addr add 0 %s" % self.vf1_mac, "testpmd>")
        self.session_third.send_expect("set fwd rxonly", "testpmd>")
        self.session_third.send_expect("set promisc all off", "testpmd>")
        self.session_third.send_expect("start", "testpmd>")
        self.session_secondary.send_expect("start", "testpmd>")
        time.sleep(2)

        self.session_secondary.send_expect("stop", "testpmd>", 5)
        self.session_third.send_expect("stop", "testpmd>", 5)
        
        vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
        vf1_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
        self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
        self.verify(vf0_tx_stats[0] * 0.5 < vf1_rx_stats[0], "VF1 failed to receive packets from VF0")
Beispiel #20
0
 def get_freq_in_transmission(self):
     self.cur_freq = self.get_cpu_frequency(self.vcpu_map[1])
     print utils.GREEN("Current cpu frequency %d" % self.cur_freq)
Beispiel #21
0
    def send_and_verify(self, vm_id, vf_id, pkt_type):
        params = {}
        case_pass = True
        tester_recv_port = self.tester.get_local_port(self.pf)
        tester_iface = self.tester.get_interface(tester_recv_port)
        tester_smac = self.tester.get_mac(tester_recv_port)

        if pkt_type == "normal_udp":
            self.start_capture(tester_iface, pkt_smac=self.pf_mac)
            self.tester.scapy_append(
                'sendp([Ether(dst="%s",src="%s")/IP()/UDP()/Raw("X"*18)], iface="%s")'
                % (self.pf_mac, tester_smac, tester_iface))
            self.tester.scapy_execute()
            time.sleep(5)

            pkts = self.transfer_capture_file()
            self.verify(len(pkts) >= 1, "Failed to capture packets")
            self.verify(pkts[0].haslayer(Vxlan) == 1,
                        "Packet not encapsulated")
            try:
                payload = str(pkts[0][UDP][Vxlan][UDP].payload)
                for i in range(18):
                    self.verify(ord(payload[i]) == 88, "Check udp data failed")
            except:
                case_pass = False
                print utils.RED("Failure in checking packet payload")

            if case_pass:
                print utils.GREEN("Check normal udp packet forward pass on "
                                  "virtIO port %d" % vf_id)

        if pkt_type == "vxlan_udp_decap":
            # create vxlan packet pf mac + vni=1000 + inner virtIO port0 mac
            params['outer_mac_dst'] = self.pf_mac
            params['vni'] = 1000 + vm_id
            mac_incr = 2 * vm_id + vf_id
            params['inner_mac_dst'] = self.mac_address_add(mac_incr)

            # create vxlan pcap file and tranfer it to tester
            vxlan_pkt = VxlanTestConfig(self, **params)
            vxlan_pkt.create_pcap()

            # start capture
            self.start_capture(tester_iface, pkt_dmac=params['inner_mac_dst'])
            vxlan_pkt.send_pcap(tester_iface)
            time.sleep(5)

            # transfer capture pcap to server
            pkts = self.transfer_capture_file()
            # check packet number and payload
            self.verify(len(pkts) >= 1, "Failed to capture packets")
            self.verify(pkts[0].haslayer(Vxlan) == 0,
                        "Packet not de-encapsulated")

            try:
                payload = str(pkts[0][UDP].payload)
                for i in range(18):
                    self.verify(ord(payload[i]) == 88, "Check udp data failed")
            except:
                case_pass = False
                print utils.RED("Failure in checking packet payload")

            if case_pass:
                print utils.GREEN(
                    "Check vxlan packet decap pass on virtIO port"
                    " %d" % vf_id)

        if pkt_type == "vxlan_udp":
            # create vxlan packet pf mac + vni=1000 + inner virtIO port0 mac
            params['outer_mac_dst'] = self.pf_mac
            params['vni'] = 1000 + vm_id
            mac_incr = 2 * vm_id + vf_id
            params['inner_mac_dst'] = self.mac_address_add(mac_incr)

            # create vxlan pcap file and tranfer it to tester
            vxlan_pkt = VxlanTestConfig(self, **params)
            vxlan_pkt.create_pcap()

            # start capture
            self.start_capture(tester_iface, pkt_smac=self.pf_mac)
            vxlan_pkt.send_pcap(tester_iface)
            time.sleep(5)

            # transfer capture pcap to server
            pkts = self.transfer_capture_file()

            # check packet number and payload
            self.verify(len(pkts) >= 1, "Failed to capture packets")
            self.verify(pkts[0].haslayer(Vxlan) == 1,
                        "Packet not encapsulated")
            try:
                payload = str(pkts[0][UDP][Vxlan][UDP].payload)
                for i in range(18):
                    self.verify(ord(payload[i]) == 88, "Check udp data failed")
            except:
                case_pass = False
                print utils.RED("Failure in checking packet payload")

            if case_pass:
                print utils.GREEN("Check vxlan packet decap and encap pass on "
                                  "virtIO port %d" % vf_id)

        if pkt_type == "vxlan_udp_chksum":
            params['inner_l4_type'] = 'UDP'
        if pkt_type == "vxlan_tcp_chksum":
            params['inner_l4_type'] = 'TCP'
        if pkt_type == "vxlan_sctp_chksum":
            params['inner_l4_type'] = 'SCTP'

        if 'chksum' in pkt_type:
            # create vxlan packet pf mac + vni=1000 + inner virtIO port0 mac
            params['outer_mac_dst'] = self.pf_mac
            params['vni'] = 1000 + vm_id
            mac_incr = 2 * vm_id + vf_id
            params['inner_mac_dst'] = self.mac_address_add(mac_incr)
            # extract reference chksum value
            vxlan_pkt = VxlanTestConfig(self, **params)
            vxlan_pkt.create_pcap()
            chksums_ref = vxlan_pkt.get_chksums()
            print utils.GREEN("Checksum reference: %s" % chksums_ref)

            params['inner_ip_invalid'] = 1
            params['inner_l4_invalid'] = 1

            # create vxlan pcap file and tranfer it to tester
            vxlan_pkt = VxlanTestConfig(self, **params)
            vxlan_pkt.create_pcap()

            # start capture
            self.start_capture(tester_iface, pkt_smac=self.pf_mac)
            vxlan_pkt.send_pcap(tester_iface)
            time.sleep(5)
            # transfer capture pcap to server
            pkts = self.transfer_capture_file()
            # check packet number and payload
            self.verify(len(pkts) >= 1, "Failed to capture packets")
            self.verify(pkts[0].haslayer(Vxlan) == 1,
                        "Packet not encapsulated")
            chksums = vxlan_pkt.get_chksums(pcap='vxlan_cap.pcap')
            print utils.GREEN("Checksum : %s" % chksums)
            for key in chksums_ref:
                if 'inner' in key:  # only check inner packet chksum
                    self.verify(
                        chksums[key] == chksums_ref[key],
                        "%s not matched to %s" % (key, chksums_ref[key]))

            print utils.GREEN("%s checksum pass" % params['inner_l4_type'])

        if pkt_type == "vxlan_tcp_tso":
            # create vxlan packet pf mac + vni=1000 + inner virtIO port0 mac +
            # tcp
            params['inner_l4_type'] = 'TCP'
            params['outer_mac_dst'] = self.pf_mac
            params['vni'] = 1000 + vm_id
            mac_incr = 2 * vm_id + vf_id
            params['inner_mac_dst'] = self.mac_address_add(mac_incr)
            params['payload_size'] = 892  # 256 + 256 + 256 + 124

            # extract reference chksum value
            vxlan_pkt = VxlanTestConfig(self, **params)
            vxlan_pkt.create_pcap()

            # start capture
            self.start_capture(tester_iface, pkt_smac=self.pf_mac, count=4)
            vxlan_pkt.send_pcap(tester_iface)
            time.sleep(5)

            # transfer capture pcap to server
            pkts = self.transfer_capture_file()
            # check packet number and payload
            self.verify(len(pkts) == 4, "Failed to capture tso packets")

            # calculation  checksum, and checkt it
            for pkt in pkts:
                inner = pkt[Vxlan]
                inner_ip_chksum = inner[IP].chksum
                del inner.chksum
                inner[IP] = inner[IP].__class__(str(inner[IP]))
                inner_ip_chksum_ref = inner[IP].chksum
                print utils.GREEN("inner ip checksum reference: %x" %
                                  inner_ip_chksum_ref)
                print utils.GREEN("inner ip checksum: %x" % inner_ip_chksum)
                self.verify(inner_ip_chksum == inner_ip_chksum_ref,
                            "inner ip checksum error")
                inner_l4_chksum = inner[params['inner_l4_type']].chksum
                del inner[params['inner_l4_type']].chksum
                inner[params['inner_l4_type']] = inner[
                    params['inner_l4_type']].__class__(
                        str(inner[params['inner_l4_type']]))
                inner_l4_chksum_ref = inner[params['inner_l4_type']].chksum
                print utils.GREEN("inner l4 checksum reference: %x" %
                                  inner_l4_chksum_ref)
                print utils.GREEN("inner l4 checksum: %x" % inner_l4_chksum)
                self.verify(
                    inner_l4_chksum == inner_l4_chksum_ref,
                    "inner %s checksum error" % params['inner_l4_type'])

            length = 0
            for pkt in pkts:
                self.verify(
                    pkt.haslayer(Vxlan) == 1, "Packet not encapsulated")
                try:
                    payload = str(pkt[UDP][Vxlan][TCP].payload)
                    self.verify(
                        len(payload) <= self.def_mss, "TCP payload oversized")
                    length += len(payload)
                except:
                    case_pass = False
                    print utils.RED("Failure in checking tso payload")

            self.verify(length == 892, "Total tcp payload size not match")
            if case_pass:
                print utils.GREEN("Vxlan packet tso pass on virtIO port %d" %
                                  vf_id)