Esempio n. 1
0
def runtest():
    # Check if the test is running in an environment where
    # it can access the machine with the slice kit attached
    args = xmostest.getargs()
    if not args.remote_resourcer:
        # Abort the test
        print 'Remote resourcer not avaliable'
        return

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), 'smoke'):
        packets = 1000
    elif xmostest.testlevel_is_at_least(xmostest.get_testlevel(), 'nightly'):
        packets = 10000
    else:  # weekend
        packets = 100000

    tests = [  # device     ip               processes ports mii    protocol
        ['EXPLORER', '192.168.1.198', 1, 1, 'ETH', 'UDP', 'UIP'],
        ['EXPLORER', '192.168.1.198', 1, 1, 'ETH', 'TCP', 'UIP'],
        ['EXPLORER', '192.168.1.198', 2, 2, 'ETH', 'UDP', 'UIP'],
        ['EXPLORER', '192.168.1.198', 2, 2, 'ETH', 'TCP', 'UIP'],
        ['MICARRAY', '192.168.1.197', 1, 1, 'RAW', 'UDP', 'UIP'],
        ['MICARRAY', '192.168.1.197', 1, 1, 'RAW', 'TCP', 'UIP'],
        ['MICARRAY', '192.168.1.197', 2, 2, 'RAW', 'UDP', 'UIP'],
        ['MICARRAY', '192.168.1.197', 2, 2, 'RAW', 'TCP', 'UIP'],
        ['MICARRAY', '192.168.1.197', 1, 1, 'ETH', 'UDP', 'UIP'],
        ['MICARRAY', '192.168.1.197', 1, 1, 'ETH', 'TCP', 'UIP'],
        ['MICARRAY', '192.168.1.197', 2, 2, 'ETH', 'UDP', 'UIP'],
        ['MICARRAY', '192.168.1.197', 2, 2, 'ETH', 'TCP', 'UIP'],
        ['SLICEKIT', '192.168.1.196', 1, 1, 'RAW', 'UDP', 'UIP'],
        ['SLICEKIT', '192.168.1.196', 1, 1, 'RAW', 'TCP', 'UIP'],
        ['SLICEKIT', '192.168.1.196', 2, 2, 'RAW', 'UDP', 'UIP'],
        ['SLICEKIT', '192.168.1.196', 2, 2, 'RAW', 'TCP', 'UIP'],
        ['SLICEKIT', '192.168.1.196', 1, 1, 'ETH', 'UDP', 'UIP'],
        ['SLICEKIT', '192.168.1.196', 1, 1, 'ETH', 'TCP', 'UIP'],
        ['SLICEKIT', '192.168.1.196', 2, 2, 'ETH', 'UDP', 'UIP'],
        ['SLICEKIT', '192.168.1.196', 2, 2, 'ETH', 'TCP', 'UIP'],
        ['EXPLORER', '192.168.1.198', 1, 1, 'ETH', 'UDP', 'LWIP'],
        ['EXPLORER', '192.168.1.198', 1, 1, 'ETH', 'TCP', 'LWIP'],
        ['EXPLORER', '192.168.1.198', 2, 2, 'ETH', 'UDP', 'LWIP'],
        ['EXPLORER', '192.168.1.198', 2, 2, 'ETH', 'TCP', 'LWIP'],
        ['MICARRAY', '192.168.1.197', 1, 1, 'RAW', 'UDP', 'LWIP'],
        ['MICARRAY', '192.168.1.197', 1, 1, 'RAW', 'TCP', 'LWIP'],
        ['MICARRAY', '192.168.1.197', 2, 2, 'RAW', 'UDP', 'LWIP'],
        ['MICARRAY', '192.168.1.197', 2, 2, 'RAW', 'TCP', 'LWIP'],
        ['MICARRAY', '192.168.1.197', 1, 1, 'ETH', 'UDP', 'LWIP'],
        ['MICARRAY', '192.168.1.197', 1, 1, 'ETH', 'TCP', 'LWIP'],
        ['MICARRAY', '192.168.1.197', 2, 2, 'ETH', 'UDP', 'LWIP'],
        ['MICARRAY', '192.168.1.197', 2, 2, 'ETH', 'TCP', 'LWIP'],
    ]

    for conf in tests:
        test(packets, 0.002, *conf)
Esempio n. 2
0
def do_test(mac, rx_clk, rx_phy, tx_clk, tx_phy):
    start_test(rx_phy)

    resources = xmostest.request_resource("xsim")

    testname = 'test_time_tx'
    level = 'nightly'

    binary = '{test}/bin/{mac}_{phy}/{test}_{mac}_{phy}.xe'.format(
        test=testname, mac=mac, phy=rx_phy.get_name())

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {test}: {mac} {phy} phy at {clk}".format(
            test=testname, mac=mac, phy=rx_phy.get_name(), clk=rx_clk.get_name())

    expect_folder = create_if_needed("expect")
    expect_filename = '{folder}/{test}_{mac}_{phy}_{clk}.expect'.format(
        folder=expect_folder, test=testname, mac=mac, phy=rx_phy.get_name(), clk=rx_clk.get_name())
    create_expect(expect_filename)

    tester = xmostest.ComparisonTester(open(expect_filename),
                                     'lib_ethernet', 'basic_tests', testname,
                                     {'mac':mac, 'phy':rx_phy.get_name(), 'clk':rx_clk.get_name()},
                                     regexp=True)

    tester.set_min_testlevel('nightly')

    simargs = get_sim_args(testname, mac, rx_clk, rx_phy)
    xmostest.run_on_simulator(resources['xsim'], binary,
                              simthreads=[rx_clk, rx_phy, tx_clk, tx_phy],
                              tester=tester,
                              simargs=simargs)
Esempio n. 3
0
def do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, test_file, seed,
               level='nightly', extra_tasks=[]):

    testname,extension = os.path.splitext(os.path.basename(test_file))

    resources = xmostest.request_resource("xsim")

    binary = 'test_rx_backpressure/bin/{mac}_{phy}_{arch}/test_rx_backpressure_{mac}_{phy}_{arch}.xe'.format(
        mac=mac, phy=tx_phy.get_name(), arch=arch)

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {test}: {mac} mac, {phy} phy, {arch} arch sending {n} packets at {clk} (seed {seed})".format(
            test=testname, n=len(packets), mac=mac,
            phy=tx_phy.get_name(), arch=arch, clk=tx_clk.get_name(), seed=seed)

    tx_phy.set_packets(packets)

    tester = OutputChecker('lib_ethernet', 'basic_tests', testname,
                           {'mac':mac, 'phy':tx_phy.get_name(), 'clk':tx_clk.get_name(), 'arch':arch})

    tester.set_min_testlevel(level)

    simargs = get_sim_args(testname, mac, tx_clk, tx_phy, arch)
    xmostest.run_on_simulator(resources['xsim'], binary,
                              simthreads=[rx_clk, rx_phy, tx_clk, tx_phy] + extra_tasks,
                              tester=tester,
                              simargs=simargs)
Esempio n. 4
0
def do_rx_test(mac,
               arch,
               rx_clk,
               rx_phy,
               tx_clk,
               tx_phy,
               packets,
               test_file,
               seed,
               level='nightly',
               extra_tasks=[]):
    """ Shared test code for all RX tests using the test_rx application.
    """
    testname, extension = os.path.splitext(os.path.basename(test_file))

    resources = xmostest.request_resource("xsim")

    binary = 'test_rx/bin/{mac}_{phy}_{arch}/test_rx_{mac}_{phy}_{arch}.xe'.format(
        mac=mac, phy=tx_phy.get_name(), arch=arch)

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {test}: {mac} mac, {phy} phy, {arch} arch sending {n} packets at {clk} (seed {seed})".format(
            test=testname,
            n=len(packets),
            mac=mac,
            phy=tx_phy.get_name(),
            arch=arch,
            clk=tx_clk.get_name(),
            seed=seed)

    tx_phy.set_packets(packets)
    rx_phy.set_expected_packets(packets)

    expect_folder = create_if_needed("expect")
    expect_filename = '{folder}/{test}_{mac}_{phy}_{clk}_{arch}.expect'.format(
        folder=expect_folder,
        test=testname,
        mac=mac,
        phy=tx_phy.get_name(),
        clk=tx_clk.get_name(),
        arch=arch)
    create_expect(packets, expect_filename)

    tester = xmostest.ComparisonTester(
        open(expect_filename), 'lib_ethernet', 'basic_tests', testname, {
            'mac': mac,
            'phy': tx_phy.get_name(),
            'clk': tx_clk.get_name(),
            'arch': arch
        })

    tester.set_min_testlevel(level)

    simargs = get_sim_args(testname, mac, tx_clk, tx_phy, arch)
    xmostest.run_on_simulator(resources['xsim'],
                              binary,
                              simthreads=[rx_clk, rx_phy, tx_clk, tx_phy] +
                              extra_tasks,
                              tester=tester,
                              simargs=simargs)
Esempio n. 5
0
def do_test(mac, rx_clk, rx_phy, tx_clk, tx_phy):
    resources = xmostest.request_resource("xsim")

    testname = 'test_shaper'

    level = 'nightly'
    binary = '{test}/bin/{phy}_{clk}/{test}_{phy}_{clk}.xe'.format(
        test=testname, phy=rx_phy.get_name(), clk=rx_clk.get_name())

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {test}: {phy} phy at {clk}".format(
            test=testname, phy=rx_phy.get_name(), clk=rx_clk.get_name())

    # MAC request 1MB/s
    slope = 5 * 1024 * 1024

    bit_time = tx_phy.get_clock().get_bit_time()
    data_bytes = 100
    ifg_bytes = 96/8
    preamble_bytes = 8
    crc_bytes = 4
    packet_bytes = ifg_bytes + preamble_bytes + data_bytes + crc_bytes
    packets_per_second = slope / (packet_bytes * 8)
    packet_period = 1000000000 / packets_per_second

    print "Running with {n} byte packets, {b} bps requested, packet preiod {p} ns".format(
        n=data_bytes, b=slope, p=packet_period)
    num_expected_packets = 30
    timeout_monitor = TimeoutMonitor(20000, packet_period, num_expected_packets, args.verbose)
    rx_phy.timeout_monitor = timeout_monitor
    rx_phy.n_hp_packets = 0
    rx_phy.n_lp_packets = 0
   
    expect_folder = create_if_needed("expect")
    expect_filename = '{folder}/{test}_{phy}_{clk}.expect'.format(
        folder=expect_folder, test=testname, phy=tx_phy.get_name(), clk=tx_clk.get_name())
    create_expect(expect_filename, num_expected_packets)
    tester = xmostest.ComparisonTester(open(expect_filename),
                                       'lib_ethernet', 'basic_tests', testname,
                                       {'phy':rx_phy.get_name(), 'clk':rx_clk.get_name()},
                                       regexp=True)

    tester.set_min_testlevel(level)

    simargs = get_sim_args(testname, mac, rx_clk, rx_phy)
    if rx_phy.get_name() == 'rgmii' and rx_clk.get_name() == '125Mhz':
        xmostest.run_on_simulator(resources['xsim'], binary,
                                  simthreads=[rx_clk, rx_phy, tx_clk, tx_phy, timeout_monitor],
                                  tester=tester,
                                  simargs=simargs,
                                  timeout=1200)
    else:
        xmostest.run_on_simulator(resources['xsim'], binary,
                                  simthreads=[rx_clk, rx_phy, tx_clk, tx_phy, timeout_monitor],
                                  tester=tester,
                                  simargs=simargs)
def do_test(mac, rx_clk, rx_phy, tx_clk, tx_phy):
    start_test(rx_phy)

    resources = xmostest.request_resource("xsim")

    testname = 'test_time_tx'
    level = 'nightly'

    binary = '{test}/bin/{mac}_{phy}/{test}_{mac}_{phy}.xe'.format(
        test=testname, mac=mac, phy=rx_phy.get_name())

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {test}: {mac} {phy} phy at {clk}".format(
            test=testname,
            mac=mac,
            phy=rx_phy.get_name(),
            clk=rx_clk.get_name())

    expect_folder = create_if_needed("expect")
    expect_filename = '{folder}/{test}_{mac}_{phy}_{clk}.expect'.format(
        folder=expect_folder,
        test=testname,
        mac=mac,
        phy=rx_phy.get_name(),
        clk=rx_clk.get_name())
    create_expect(expect_filename)

    tester = xmostest.ComparisonTester(open(expect_filename),
                                       'lib_ethernet',
                                       'basic_tests',
                                       testname, {
                                           'mac': mac,
                                           'phy': rx_phy.get_name(),
                                           'clk': rx_clk.get_name()
                                       },
                                       regexp=True)

    tester.set_min_testlevel('nightly')

    simargs = get_sim_args(testname, mac, rx_clk, rx_phy)
    xmostest.run_on_simulator(resources['xsim'],
                              binary,
                              simthreads=[rx_clk, rx_phy, tx_clk, tx_phy],
                              tester=tester,
                              simargs=simargs)
Esempio n. 7
0
def do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, test_file, seed,
               level='nightly', extra_tasks=[]):

    """ Shared test code for all RX tests using the test_rx application.
    """
    testname,extension = os.path.splitext(os.path.basename(test_file))

    resources = xmostest.request_resource("xsim")

    binary = 'test_rx/bin/{mac}_{phy}_{arch}/test_rx_{mac}_{phy}_{arch}.xe'.format(
        mac=mac, phy=tx_phy.get_name(), arch=arch)

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {test}: {mac} mac, {phy} phy, {arch} arch sending {n} packets at {clk} (seed {seed})".format(
            test=testname, n=len(packets), mac=mac,
            phy=tx_phy.get_name(), arch=arch, clk=tx_clk.get_name(), seed=seed)

    tx_phy.set_packets(packets)
    rx_phy.set_expected_packets(packets)

    expect_folder = create_if_needed("expect")
    expect_filename = '{folder}/{test}_{mac}_{phy}_{clk}_{arch}.expect'.format(
        folder=expect_folder, test=testname, mac=mac, phy=tx_phy.get_name(), clk=tx_clk.get_name(), arch=arch)
    create_expect(packets, expect_filename)

    tester = xmostest.ComparisonTester(open(expect_filename),
                                      'lib_ethernet', 'basic_tests', testname,
                                     {'mac':mac, 'phy':tx_phy.get_name(), 'clk':tx_clk.get_name(), 'arch':arch})

    tester.set_min_testlevel(level)

    simargs = get_sim_args(testname, mac, tx_clk, tx_phy, arch)
    xmostest.run_on_simulator(resources['xsim'], binary,
                              simthreads=[rx_clk, rx_phy, tx_clk, tx_phy] + extra_tasks,
                              tester=tester,
                              simargs=simargs)
Esempio n. 8
0
def do_test(mac, rx_clk, rx_phy, tx_clk, tx_phy, seed):
    start_test(rx_phy)

    rand = random.Random()
    rand.seed(seed)

    # Generate an include file to define the seed
    with open(os.path.join("include", "seed.h"), "w") as f:
        f.write("#define SEED {}".format(seed))

    resources = xmostest.request_resource("xsim")
    testname = 'test_time_rx_tx'
    level = 'nightly'

    binary = '{test}/bin/{mac}_{phy}/{test}_{mac}_{phy}.xe'.format(
        test=testname, mac=mac, phy=tx_phy.get_name())

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {test}: {phy} phy at {clk} (seed {seed})".format(
            test=testname, phy=tx_phy.get_name(), clk=tx_clk.get_name(), seed=seed)

    dut_mac_address = get_dut_mac_address()
    ifg = tx_clk.get_min_ifg()

    packets = []
    done = False
    num_data_bytes = 0
    while not done:
        do_small_packet = rand.randint(0, 100) > 30
        if do_small_packet:
            length = rand.randint(46, 100)
        else:
            length = rand.randint(46, 1500)

        burst_len = 1
        do_burst = rand.randint(0, 100) > 80
        if do_burst:
            burst_len = rand.randint(1, 16)

        for i in range(burst_len):
            packets.append(MiiPacket(rand,
                dst_mac_addr=dut_mac_address, inter_frame_gap=ifg, num_data_bytes=length
              ))

            # Add on the overhead of the packet header
            num_data_bytes += length + 14

            if len(packets) == num_test_packets:
                done = True
                break

    tx_phy.set_packets(packets)

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Sending {n} packets with {b} bytes at the DUT".format(n=len(packets), b=num_data_bytes)

    expect_folder = create_if_needed("expect")
    expect_filename = '{folder}/{test}_{mac}.expect'.format(
        folder=expect_folder, test=testname, mac=mac)
    create_expect(packets, expect_filename)
    tester = xmostest.ComparisonTester(open(expect_filename),
                                     'lib_ethernet', 'basic_tests', testname,
                                      {'mac':mac, 'phy':tx_phy.get_name(), 'clk':tx_clk.get_name()},
                                      regexp=True)

    tester.set_min_testlevel('nightly')

    simargs = get_sim_args(testname, mac, tx_clk, tx_phy)
    xmostest.run_on_simulator(resources['xsim'], binary,
                              simthreads=[rx_clk, rx_phy, tx_clk, tx_phy],
                              tester=tester,
                              simargs=simargs)
Esempio n. 9
0
def do_test(mac, rx_clk, rx_phy, tx_clk, tx_phy):
    resources = xmostest.request_resource("xsim")

    testname = 'test_shaper'

    level = 'nightly'
    binary = '{test}/bin/{phy}_{clk}/{test}_{phy}_{clk}.xe'.format(
        test=testname, phy=rx_phy.get_name(), clk=rx_clk.get_name())

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {test}: {phy} phy at {clk}".format(
            test=testname, phy=rx_phy.get_name(), clk=rx_clk.get_name())

    # MAC request 1MB/s
    slope = 5 * 1024 * 1024

    bit_time = tx_phy.get_clock().get_bit_time()
    data_bytes = 100
    ifg_bytes = 96 / 8
    preamble_bytes = 8
    crc_bytes = 4
    packet_bytes = ifg_bytes + preamble_bytes + data_bytes + crc_bytes
    packets_per_second = slope / (packet_bytes * 8)
    packet_period = 1000000000 / packets_per_second

    print "Running with {n} byte packets, {b} bps requested, packet preiod {p} ns".format(
        n=data_bytes, b=slope, p=packet_period)
    num_expected_packets = 30
    timeout_monitor = TimeoutMonitor(20000, packet_period,
                                     num_expected_packets, args.verbose)
    rx_phy.timeout_monitor = timeout_monitor
    rx_phy.n_hp_packets = 0
    rx_phy.n_lp_packets = 0

    expect_folder = create_if_needed("expect")
    expect_filename = '{folder}/{test}_{phy}_{clk}.expect'.format(
        folder=expect_folder,
        test=testname,
        phy=tx_phy.get_name(),
        clk=tx_clk.get_name())
    create_expect(expect_filename, num_expected_packets)
    tester = xmostest.ComparisonTester(open(expect_filename),
                                       'lib_ethernet',
                                       'basic_tests',
                                       testname, {
                                           'phy': rx_phy.get_name(),
                                           'clk': rx_clk.get_name()
                                       },
                                       regexp=True)

    tester.set_min_testlevel(level)

    simargs = get_sim_args(testname, mac, rx_clk, rx_phy)
    if rx_phy.get_name() == 'rgmii' and rx_clk.get_name() == '125Mhz':
        xmostest.run_on_simulator(
            resources['xsim'],
            binary,
            simthreads=[rx_clk, rx_phy, tx_clk, tx_phy, timeout_monitor],
            tester=tester,
            simargs=simargs,
            timeout=1200)
    else:
        xmostest.run_on_simulator(
            resources['xsim'],
            binary,
            simthreads=[rx_clk, rx_phy, tx_clk, tx_phy, timeout_monitor],
            tester=tester,
            simargs=simargs)
Esempio n. 10
0
def do_test(mac, rx_clk, rx_phy, tx_clk, tx_phy, seed):
    start_test(rx_phy)

    rand = random.Random()
    rand.seed(seed)

    # Generate an include file to define the seed
    with open(os.path.join("include", "seed.inc"), "w") as f:
        f.write("#define SEED {}".format(seed))

    resources = xmostest.request_resource("xsim")
    testname = 'test_time_rx_tx'
    level = 'nightly'

    binary = '{test}/bin/{mac}_{phy}/{test}_{mac}_{phy}.xe'.format(
        test=testname, mac=mac, phy=tx_phy.get_name())

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {test}: {phy} phy at {clk} (seed {seed})".format(
            test=testname, phy=tx_phy.get_name(), clk=tx_clk.get_name(), seed=seed)

    dut_mac_address = get_dut_mac_address()
    ifg = tx_clk.get_min_ifg()

    packets = []
    done = False
    num_data_bytes = 0
    while not done:
        do_small_packet = rand.randint(0, 100) > 30
        if do_small_packet:
            length = rand.randint(46, 100)
        else:
            length = rand.randint(46, 1500)

        burst_len = 1
        do_burst = rand.randint(0, 100) > 80
        if do_burst:
            burst_len = rand.randint(1, 16)

        for i in range(burst_len):
            packets.append(MiiPacket(rand,
                dst_mac_addr=dut_mac_address, inter_frame_gap=ifg, num_data_bytes=length
              ))

            # Add on the overhead of the packet header
            num_data_bytes += length + 14

            if len(packets) == num_test_packets:
                done = True
                break

    tx_phy.set_packets(packets)

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Sending {n} packets with {b} bytes at the DUT".format(n=len(packets), b=num_data_bytes)

    expect_folder = create_if_needed("expect")
    expect_filename = '{folder}/{test}_{mac}.expect'.format(
        folder=expect_folder, test=testname, mac=mac)
    create_expect(packets, expect_filename)
    tester = xmostest.ComparisonTester(open(expect_filename),
                                     'lib_ethernet', 'basic_tests', testname,
                                      {'mac':mac, 'phy':tx_phy.get_name(), 'clk':tx_clk.get_name()},
                                      regexp=True)

    tester.set_min_testlevel('nightly')

    simargs = get_sim_args(testname, mac, tx_clk, tx_phy)
    xmostest.run_on_simulator(resources['xsim'], binary,
                              simthreads=[rx_clk, rx_phy, tx_clk, tx_phy],
                              tester=tester,
                              simargs=simargs)
def do_test(mac,
            tx_clk,
            tx_phy,
            seed,
            num_windows=10,
            num_avb_streams=12,
            num_avb_data_bytes=400,
            weight_none=50,
            weight_lp=50,
            weight_other=50,
            data_len_min=46,
            data_len_max=500,
            weight_tagged=50,
            weight_untagged=50):

    rand = random.Random()
    rand.seed(seed)

    bit_time = tx_phy.get_clock().get_bit_time()
    rxLpControl = RxLpControl('tile[0]:XS1_PORT_1D', bit_time, 0, True,
                              rand.randint(0, sys.maxint))

    resources = xmostest.request_resource("xsim")
    testname = 'test_avb_traffic'
    level = 'nightly'

    binary = '{test}/bin/{mac}_{phy}/{test}_{mac}_{phy}.xe'.format(
        test=testname, mac=mac, phy=tx_phy.get_name())

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {test}: {phy} phy at {clk} (seed {seed})".format(
            test=testname,
            phy=tx_phy.get_name(),
            clk=tx_clk.get_name(),
            seed=seed)

    stream_mac_addresses = {}
    stream_seq_id = {}
    stream_ids = [x for x in range(num_avb_streams)]
    for i in stream_ids:
        stream_mac_addresses[i] = [i, 1, 2, 3, 4, 5]
        stream_seq_id[i] = 0

    packets = []
    filler = PacketFiller(weight_none, weight_lp, weight_other, weight_tagged,
                          weight_untagged, data_len_min, data_len_max,
                          bit_time)

    window_size = 125000

    min_ifg = 96 * bit_time
    last_packet_end = 0
    ifg = 0
    for window in range(num_windows):
        # Randomly place the streams in the 125us window
        packet_start_times = sorted(
            [rand.randint(0, window_size) for x in range(num_avb_streams)])

        if debug_fill:
            print "Window {} - times {}".format(window, packet_start_times)

        rand.shuffle(stream_ids)
        for (i, stream) in enumerate(stream_ids):
            packet_start_time = packet_start_times[i]

            gap_size = packet_start_time - last_packet_end

            (last_packet_end, ifg) = filler.fill_gap(rand, packets, gap_size,
                                                     last_packet_end, ifg)
            start_ifg = min_ifg

            avb_packet = MiiPacket(rand,
                                   dst_mac_addr=stream_mac_addresses[stream],
                                   create_data_args=[
                                       'same',
                                       (stream_seq_id[stream],
                                        num_avb_data_bytes)
                                   ],
                                   vlan_prio_tag=[0x81, 0x00, 0x00, 0x00],
                                   inter_frame_gap=ifg)
            stream_seq_id[stream] += 1
            packets.append(avb_packet)
            ifg = rand.randint(min_ifg, 2 * min_ifg)

            packet_time = avb_packet.get_packet_time(bit_time)

            if debug_fill:
                print "PACKET {} -> {}".format(last_packet_end,
                                               last_packet_end + packet_time)
            last_packet_end += packet_time

        # Fill the window after the last packet
        gap_size = window_size - last_packet_end
        (last_packet_end, ifg) = filler.fill_gap(rand, packets, gap_size,
                                                 last_packet_end, ifg)

        # Compute where in the next window the last packet has finished
        last_packet_end = last_packet_end - window_size

    tx_phy.set_packets(packets)

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {w} windows of {s} AVB streams with {b} data bytes each".format(
            w=num_windows, s=num_avb_streams, b=num_avb_data_bytes)
        print "Sending {n} lp packets with {b} bytes hp data".format(
            n=filler.lp_seq_id, b=filler.lp_data_bytes)
        print "Sending {n} other packets with {b} bytes hp data".format(
            n=filler.other_seq_id, b=filler.other_data_bytes)

    expect_folder = create_if_needed("expect")
    expect_filename = '{folder}/{test}_{mac}_{phy}.expect'.format(
        folder=expect_folder, test=testname, mac=mac, phy=tx_phy.get_name())
    create_expect(packets, expect_filename, num_windows, num_avb_streams,
                  num_avb_data_bytes)
    tester = xmostest.ComparisonTester(open(expect_filename),
                                       'lib_ethernet',
                                       'basic_tests',
                                       testname, {
                                           'mac': mac,
                                           'phy': tx_phy.get_name(),
                                           'clk': tx_clk.get_name(),
                                           'n_stream': num_avb_streams,
                                           'b_p_stream': num_avb_data_bytes,
                                           'len_min': data_len_min,
                                           'len_max': data_len_max,
                                           'w_none': weight_none,
                                           'w_lp': weight_lp,
                                           'w_other': weight_other,
                                           'n_windows': num_windows
                                       },
                                       regexp=True)

    tester.set_min_testlevel(level)

    simargs = get_sim_args(testname, mac, tx_clk, tx_phy)
    xmostest.run_on_simulator(resources['xsim'],
                              binary,
                              simthreads=[tx_clk, tx_phy, rxLpControl],
                              tester=tester,
                              simargs=simargs)
Esempio n. 12
0
def do_test(mac, tx_clk, tx_phy, seed,
            num_windows=10, num_avb_streams=12, num_avb_data_bytes=400,
            weight_none=50, weight_lp=50, weight_other=50,
            data_len_min=46, data_len_max=500,
            weight_tagged=50, weight_untagged=50):

    rand = random.Random()
    rand.seed(seed)

    bit_time = tx_phy.get_clock().get_bit_time()
    rxLpControl = RxLpControl('tile[0]:XS1_PORT_1D', bit_time, 0, True, rand.randint(0, sys.maxint))

    resources = xmostest.request_resource("xsim")
    testname = 'test_avb_traffic'
    level = 'nightly'

    binary = '{test}/bin/{mac}_{phy}/{test}_{mac}_{phy}.xe'.format(
        test=testname, mac=mac, phy=tx_phy.get_name())

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {test}: {phy} phy at {clk} (seed {seed})".format(
            test=testname, phy=tx_phy.get_name(), clk=tx_clk.get_name(), seed=seed)

    stream_mac_addresses = {}
    stream_seq_id = {}
    stream_ids = [x for x in range(num_avb_streams)]
    for i in stream_ids:
        stream_mac_addresses[i] = [i, 1, 2, 3, 4, 5]
        stream_seq_id[i] = 0
        
    packets = []
    filler = PacketFiller(weight_none, weight_lp, weight_other, weight_tagged, weight_untagged,
                          data_len_min, data_len_max, bit_time)

    window_size = 125000
    
    min_ifg = 96 * bit_time
    last_packet_end = 0
    ifg = 0
    for window in range(num_windows):
        # Randomly place the streams in the 125us window
        packet_start_times = sorted([rand.randint(0, window_size) for x in range(num_avb_streams)])

        if debug_fill:
            print "Window {} - times {}".format(window, packet_start_times)

        rand.shuffle(stream_ids)
        for (i, stream) in enumerate(stream_ids):
            packet_start_time = packet_start_times[i]

            gap_size = packet_start_time - last_packet_end

            (last_packet_end, ifg) = filler.fill_gap(rand, packets, gap_size, last_packet_end, ifg)
            start_ifg = min_ifg

            avb_packet= MiiPacket(rand,
                dst_mac_addr=stream_mac_addresses[stream],
                create_data_args=['same', (stream_seq_id[stream], num_avb_data_bytes)],
                vlan_prio_tag=[0x81, 0x00, 0x00, 0x00],
                inter_frame_gap=ifg)
            stream_seq_id[stream] += 1
            packets.append(avb_packet)
            ifg = rand.randint(min_ifg, 2 * min_ifg)

            packet_time = avb_packet.get_packet_time(bit_time)

            if debug_fill:
                print "PACKET {} -> {}".format(last_packet_end, last_packet_end + packet_time)
            last_packet_end += packet_time

        # Fill the window after the last packet
        gap_size = window_size - last_packet_end
        (last_packet_end, ifg) = filler.fill_gap(rand, packets, gap_size, last_packet_end, ifg)

        # Compute where in the next window the last packet has finished
        last_packet_end = last_packet_end - window_size
        
    tx_phy.set_packets(packets)

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {w} windows of {s} AVB streams with {b} data bytes each".format(
            w=num_windows, s=num_avb_streams, b=num_avb_data_bytes)
        print "Sending {n} lp packets with {b} bytes hp data".format(
            n=filler.lp_seq_id, b=filler.lp_data_bytes)
        print "Sending {n} other packets with {b} bytes hp data".format(
            n=filler.other_seq_id, b=filler.other_data_bytes)

    expect_folder = create_if_needed("expect")
    expect_filename = '{folder}/{test}_{mac}_{phy}.expect'.format(
        folder=expect_folder, test=testname, mac=mac, phy=tx_phy.get_name())
    create_expect(packets, expect_filename, num_windows, num_avb_streams, num_avb_data_bytes)
    tester = xmostest.ComparisonTester(open(expect_filename),
                                     'lib_ethernet', 'basic_tests', testname,
                                      {'mac':mac, 'phy':tx_phy.get_name(), 'clk':tx_clk.get_name(),
                                       'n_stream':num_avb_streams, 'b_p_stream':num_avb_data_bytes,
                                       'len_min':data_len_min, 'len_max':data_len_max,
                                       'w_none':weight_none, 'w_lp':weight_lp, 'w_other':weight_other,
                                       'n_windows':num_windows},
                                      regexp=True)

    tester.set_min_testlevel(level)

    simargs = get_sim_args(testname, mac, tx_clk, tx_phy)
    xmostest.run_on_simulator(resources['xsim'], binary,
                              simthreads=[tx_clk, tx_phy, rxLpControl],
                              tester=tester,
                              simargs=simargs)
Esempio n. 13
0
def do_test(mac, tx_clk, tx_phy, seed,
            num_packets=200,
            weight_hp=50, weight_lp=50, weight_other=50,
            data_len_min=46, data_len_max=500,
            weight_tagged=50, weight_untagged=50,
            max_hp_mbps=1000):

    rand = random.Random()
    rand.seed(seed)

    bit_time = tx_phy.get_clock().get_bit_time()
    rxLpControl = RxLpControl('tile[0]:XS1_PORT_1D', bit_time, 0, True, rand.randint(0, sys.maxint))

    resources = xmostest.request_resource("xsim")
    testname = 'test_rx_queues'
    level = 'nightly'

    binary = '{test}/bin/{mac}_{phy}/{test}_{mac}_{phy}.xe'.format(
        test=testname, mac=mac, phy=tx_phy.get_name())

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {test}: {phy} phy at {clk} (seed {seed})".format(
            test=testname, phy=tx_phy.get_name(), clk=tx_clk.get_name(), seed=seed)

    hp_mac_address = [0,1,2,3,4,5]
    hp_seq_id = 0
    hp_data_bytes = 0
    lp_mac_address = [1,2,3,4,5,6]
    lp_seq_id = 0
    lp_data_bytes = 0
    other_mac_address = [2,3,4,5,6,7]
    other_seq_id = 0
    other_data_bytes = 0

    packets = []
    done = False

    limiter = DataLimiter(max_hp_mbps, bit_time)
    total_weight_tag = weight_tagged + weight_untagged
    total_weight_tc = weight_hp + weight_lp + weight_other
    while not done:
        if (rand.randint(0, total_weight_tag) < weight_tagged):
            tag = [0x81, 0x00, rand.randint(0,0xff), rand.randint(0, 0xff)]
        else:
            tag = None

        mac_choice = rand.randint(0, total_weight_tc - 1)
        if (mac_choice < weight_lp):
            dst_mac_addr = lp_mac_address
        elif (mac_choice < weight_hp + weight_lp):
            dst_mac_addr = hp_mac_address
        else:
            dst_mac_addr = other_mac_address

        frame_size = choose_data_size(rand, data_len_min, data_len_max)
            
        if (rand.randint(0,100) > 30):
            burst_len = rand.randint(1,20)
        else:
            burst_len = 1

        for j in range(burst_len):
            # The seq_ids are effectively packet counts
            if (hp_seq_id + lp_seq_id + other_seq_id) == num_packets:
                done = True
                break
        
            if dst_mac_addr == lp_mac_address:
                packet_type = DataLimiter.LP_PACKET
                seq_id = lp_seq_id
                lp_seq_id += 1
                lp_data_bytes += frame_size + 14
                if tag:
                    lp_data_bytes += 4
            elif dst_mac_addr == hp_mac_address:
                packet_type = DataLimiter.HP_PACKET
                seq_id = hp_seq_id
                hp_seq_id += 1
                hp_data_bytes += frame_size + 14
                if tag:
                    hp_data_bytes += 4
            else:
                packet_type = DataLimiter.OTHER_PACKET
                seq_id = other_seq_id
                other_seq_id += 1
                other_data_bytes += frame_size + 14
                if tag:
                    other_data_bytes += 4

            ifg = limiter.get_ifg(packet_type, frame_size, tag)
                
            packets.append(MiiPacket(rand,
                dst_mac_addr=dst_mac_addr,
                create_data_args=['same', (seq_id, frame_size)],
                vlan_prio_tag=tag,
                inter_frame_gap=ifg
            ))


    tx_phy.set_packets(packets)

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Sending {n} hp packets with {b} bytes data".format(n=hp_seq_id, b=hp_data_bytes)
        print "Sending {n} lp packets with {b} bytes hp data".format(n=lp_seq_id, b=lp_data_bytes)
        print "Sending {n} other packets with {b} bytes hp data".format(n=other_seq_id, b=other_data_bytes)

    expect_folder = create_if_needed("expect")
    expect_filename = '{folder}/{test}_{mac}_{phy}.expect'.format(
        folder=expect_folder, test=testname, mac=mac, phy=tx_phy.get_name())
    create_expect(packets, expect_filename, hp_mac_address, lp_mac_address)
    tester = xmostest.ComparisonTester(open(expect_filename),
                                     'lib_ethernet', 'basic_tests', testname,
                                      {'mac':mac, 'phy':tx_phy.get_name(), 'clk':tx_clk.get_name(),
                                       'max_hp_mbps':max_hp_mbps,
                                       'len_min':data_len_min, 'len_max':data_len_max,
                                       'w_hp':weight_hp, 'w_lp':weight_lp, 'w_other':weight_other,
                                       'n_packets':num_packets},
                                      regexp=True)

    tester.set_min_testlevel(level)

    simargs = get_sim_args(testname, mac, tx_clk, tx_phy)
    xmostest.run_on_simulator(resources['xsim'], binary,
                              simthreads=[tx_clk, tx_phy, rxLpControl],
                              tester=tester,
                              simargs=simargs)
Esempio n. 14
0
def do_test(mac,
            tx_clk,
            tx_phy,
            seed,
            num_packets=200,
            weight_hp=50,
            weight_lp=50,
            weight_other=50,
            data_len_min=46,
            data_len_max=500,
            weight_tagged=50,
            weight_untagged=50,
            max_hp_mbps=1000):

    rand = random.Random()
    rand.seed(seed)

    bit_time = tx_phy.get_clock().get_bit_time()
    rxLpControl = RxLpControl('tile[0]:XS1_PORT_1D', bit_time, 0, True,
                              rand.randint(0, sys.maxint))

    resources = xmostest.request_resource("xsim")
    testname = 'test_rx_queues'
    level = 'nightly'

    binary = '{test}/bin/{mac}_{phy}/{test}_{mac}_{phy}.xe'.format(
        test=testname, mac=mac, phy=tx_phy.get_name())

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Running {test}: {phy} phy at {clk} (seed {seed})".format(
            test=testname,
            phy=tx_phy.get_name(),
            clk=tx_clk.get_name(),
            seed=seed)

    hp_mac_address = [0, 1, 2, 3, 4, 5]
    hp_seq_id = 0
    hp_data_bytes = 0
    lp_mac_address = [1, 2, 3, 4, 5, 6]
    lp_seq_id = 0
    lp_data_bytes = 0
    other_mac_address = [2, 3, 4, 5, 6, 7]
    other_seq_id = 0
    other_data_bytes = 0

    packets = []
    done = False

    limiter = DataLimiter(max_hp_mbps, bit_time)
    total_weight_tag = weight_tagged + weight_untagged
    total_weight_tc = weight_hp + weight_lp + weight_other
    while not done:
        if (rand.randint(0, total_weight_tag) < weight_tagged):
            tag = [0x81, 0x00, rand.randint(0, 0xff), rand.randint(0, 0xff)]
        else:
            tag = None

        mac_choice = rand.randint(0, total_weight_tc - 1)
        if (mac_choice < weight_lp):
            dst_mac_addr = lp_mac_address
        elif (mac_choice < weight_hp + weight_lp):
            dst_mac_addr = hp_mac_address
        else:
            dst_mac_addr = other_mac_address

        frame_size = choose_data_size(rand, data_len_min, data_len_max)

        if (rand.randint(0, 100) > 30):
            burst_len = rand.randint(1, 20)
        else:
            burst_len = 1

        for j in range(burst_len):
            # The seq_ids are effectively packet counts
            if (hp_seq_id + lp_seq_id + other_seq_id) == num_packets:
                done = True
                break

            if dst_mac_addr == lp_mac_address:
                packet_type = DataLimiter.LP_PACKET
                seq_id = lp_seq_id
                lp_seq_id += 1
                lp_data_bytes += frame_size + 14
                if tag:
                    lp_data_bytes += 4
            elif dst_mac_addr == hp_mac_address:
                packet_type = DataLimiter.HP_PACKET
                seq_id = hp_seq_id
                hp_seq_id += 1
                hp_data_bytes += frame_size + 14
                if tag:
                    hp_data_bytes += 4
            else:
                packet_type = DataLimiter.OTHER_PACKET
                seq_id = other_seq_id
                other_seq_id += 1
                other_data_bytes += frame_size + 14
                if tag:
                    other_data_bytes += 4

            ifg = limiter.get_ifg(packet_type, frame_size, tag)

            packets.append(
                MiiPacket(rand,
                          dst_mac_addr=dst_mac_addr,
                          create_data_args=['same', (seq_id, frame_size)],
                          vlan_prio_tag=tag,
                          inter_frame_gap=ifg))

    tx_phy.set_packets(packets)

    if xmostest.testlevel_is_at_least(xmostest.get_testlevel(), level):
        print "Sending {n} hp packets with {b} bytes data".format(
            n=hp_seq_id, b=hp_data_bytes)
        print "Sending {n} lp packets with {b} bytes hp data".format(
            n=lp_seq_id, b=lp_data_bytes)
        print "Sending {n} other packets with {b} bytes hp data".format(
            n=other_seq_id, b=other_data_bytes)

    expect_folder = create_if_needed("expect")
    expect_filename = '{folder}/{test}_{mac}_{phy}.expect'.format(
        folder=expect_folder, test=testname, mac=mac, phy=tx_phy.get_name())
    create_expect(packets, expect_filename, hp_mac_address, lp_mac_address)
    tester = xmostest.ComparisonTester(open(expect_filename),
                                       'lib_ethernet',
                                       'basic_tests',
                                       testname, {
                                           'mac': mac,
                                           'phy': tx_phy.get_name(),
                                           'clk': tx_clk.get_name(),
                                           'max_hp_mbps': max_hp_mbps,
                                           'len_min': data_len_min,
                                           'len_max': data_len_max,
                                           'w_hp': weight_hp,
                                           'w_lp': weight_lp,
                                           'w_other': weight_other,
                                           'n_packets': num_packets
                                       },
                                       regexp=True)

    tester.set_min_testlevel(level)

    simargs = get_sim_args(testname, mac, tx_clk, tx_phy)
    xmostest.run_on_simulator(resources['xsim'],
                              binary,
                              simthreads=[tx_clk, tx_phy, rxLpControl],
                              tester=tester,
                              simargs=simargs)