Пример #1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--segment',
                        '-S',
                        type=hexint,
                        help='Segment number of PCIe device')
    parser.add_argument('--bus',
                        '-B',
                        type=hexint,
                        help='Bus number of PCIe device')
    parser.add_argument('--device',
                        '-D',
                        type=hexint,
                        help='Device number of PCIe device')
    parser.add_argument('--function',
                        '-F',
                        type=hexint,
                        help='Function number of PCIe device')
    parser.add_argument('--clear',
                        '-c',
                        action='store_true',
                        help='Clear statistics')
    parser.add_argument('--debug',
                        '-d',
                        action='store_true',
                        help='Output debug information')
    args, left = parser.parse_known_args()

    f = FpgaFinder(args.segment, args.bus, args.device, args.function)
    devs = f.find()
    for d in devs:
        if args.debug:
            s = 'bdf: {segment:04x}:{bus:02x}:{dev:02x}.{func:x}'.format(**d)
            print(s)
    if len(devs) > 1:
        exception_quit('{} FPGAs are found\nplease choose '
                       'one FPGA'.format(len(devs)))
    if not devs:
        exception_quit('no FPGA found')

    args.sbdf = '{segment:04x}:{bus:02x}:{dev:02x}.{func:x}'.format(**devs[0])
    bitstream_id_path = f.find_node(devs[0].get('path'),
                                    'intel-fpga-fme.*/bitstream_id',
                                    depth=1)
    with open(bitstream_id_path[0], 'r') as fd:
        bitstream_id = fd.read().strip()
    args.build_flags = (int(bitstream_id, 16) >> 24) & 0xff
    args.eth_grps = f.find_node(devs[0].get('path'), 'eth_group*/dev', depth=4)
    if not args.eth_grps:
        exception_quit('No ethernet group found')
    for g in args.eth_grps:
        if args.debug:
            print('ethernet group device: {}'.format(g))

    f = FPGASTATS(args)
    if args.clear:
        f.clear_stats()
    else:
        f.start()
Пример #2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--segment',
                        '-S',
                        type=hexint,
                        help='Segment number of PCIe device')
    parser.add_argument('--bus',
                        '-B',
                        type=hexint,
                        help='Bus number of PCIe device')
    parser.add_argument('--device',
                        '-D',
                        type=hexint,
                        help='Device number of PCIe device')
    parser.add_argument('--function',
                        '-F',
                        type=hexint,
                        help='Function number of PCIe device')
    parser.add_argument('--mtu',
                        nargs='?',
                        const='',
                        help='maximum allowable ethernet frame length')
    parser.add_argument('--port',
                        nargs='*',
                        default='all',
                        help='select specific port (default: %(default)s)')
    parser.add_argument('--direction',
                        choices=['tx', 'rx', 'both'],
                        default='both',
                        help='select direction of port (default: %(default)s)')
    parser.add_argument('--side',
                        choices=['line', 'host'],
                        default='host',
                        help='select mac on which side (default: %(default)s)')
    parser.add_argument('--debug',
                        '-d',
                        action='store_true',
                        help='Output debug information')
    args, left = parser.parse_known_args()

    f = FpgaFinder(args.segment, args.bus, args.device, args.function)
    devs = f.find()
    if args.debug:
        for d in devs:
            s = 'bdf: {segment:04x}:{bus:02x}:{dev:02x}.{func:x}'.format(**d)
            print(s)
    if len(devs) > 1:
        s = '{} FPGAs are found\nplease choose one FPGA'.format(len(devs))
        exception_quit(s, 1)
    if not devs:
        sys.exit(2)
    args.fpga_root = devs[0].get('path')
    args.eth_grps = f.find_eth_group(args.fpga_root)
    print("args.eth_grps", args.eth_grps)
    if len(args.eth_grps) == 0:
        exception_quit("Invalid Eth group MDEV")

    lp = FPGAMAC(args)
    lp.eth_group_start()
Пример #3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--segment',
                        '-S',
                        type=hexint,
                        help='Segment number of PCIe device')
    parser.add_argument('--bus',
                        '-B',
                        type=hexint,
                        help='Bus number of PCIe device')
    parser.add_argument('--device',
                        '-D',
                        type=hexint,
                        help='Device number of PCIe device')
    parser.add_argument('--function',
                        '-F',
                        type=hexint,
                        help='Function number of PCIe device')
    parser.add_argument('--offset',
                        default='0',
                        type=hexint,
                        help='read mac address from a offset address')
    args, left = parser.parse_known_args()

    f = FpgaFinder(args.segment, args.bus, args.device, args.function)
    devs = f.find()
    for d in devs:
        print('bdf: {segment:04x}:{bus:02x}:{dev:02x}.{func:x}'.format(**d))
    if len(devs) > 1:
        exception_quit('{} FPGAs are found\nplease choose '
                       'one FPGA to do mactest'.format(len(devs)))
    if not devs:
        exception_quit('no FPGA found')
    args.fpga_root = devs[0].get('path')
    nvmem_path = f.find_node(devs[0].get('path'), 'nvmem', depth=7)
    if not nvmem_path:
        nvmem_path = f.find_node(devs[0].get('path'), 'eeprom', depth=7)
    if not nvmem_path:
        exception_quit('No nvmem found at {}'.format(devs[0].get('path')))
    args.nvmem = nvmem_path[0]
    if len(nvmem_path) > 1:
        print('multi nvmem found, '
              'select {} to do mactest'.format(args.nvmem))
    args.eth_grps = f.find_node(devs[0].get('path'), 'eth_group*/dev', depth=3)
    if not args.eth_grps:
        exception_quit('No ethernet group found')
    for g in args.eth_grps:
        print('ethernet group device: {}'.format(g))

    m = MacromCompare(args)
    m.start()
Пример #4
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--segment',
                        '-S',
                        type=hexint,
                        help='Segment number of PCIe device')
    parser.add_argument('--bus',
                        '-B',
                        type=hexint,
                        help='Bus number of PCIe device')
    parser.add_argument('--device',
                        '-D',
                        type=hexint,
                        help='Device number of PCIe device')
    parser.add_argument('--function',
                        '-F',
                        type=hexint,
                        help='Function number of PCIe device')
    args, left = parser.parse_known_args()

    f = FpgaFinder(args.segment, args.bus, args.device, args.function)
    devs = f.find()
    for d in devs:
        print('bdf: {segment:04x}:{bus:02x}:{dev:02x}.{func:x}'.format(**d))
    if len(devs) > 1:
        exception_quit('{} FPGAs are found\nplease choose '
                       'one FPGA'.format(len(devs)))
    if not devs:
        exception_quit('no FPGA found')
    args.eth_grps = f.find_node(devs[0].get('path'), 'eth_group*/dev', depth=3)
    if not args.eth_grps:
        exception_quit('No ethernet group found')
    for g in args.eth_grps:
        print('ethernet group device: {}'.format(g))

    f = FPGASTATS(args)
    f.start()
Пример #5
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--segment', '-S',  type=hexint,
                        help='Segment number of PCIe device')
    parser.add_argument('--bus', '-B',  type=hexint,
                        help='Bus number of PCIe device')
    parser.add_argument('--device', '-D',  type=hexint,
                        help='Device number of PCIe device')
    parser.add_argument('--function', '-F',  type=hexint,
                        help='Function number of PCIe device')
    parser.add_argument('--offset',
                        default='0',  type=hexint,
                        help='read mac address from a offset address')
    parser.add_argument('--debug', '-d', action='store_true',
                        help='Output debug information')
    args, left = parser.parse_known_args()

    f = FpgaFinder(args.segment, args.bus, args.device, args.function)
    devs = f.find()
    for d in devs:
        if args.debug:
            s = 'bdf: {segment:04x}:{bus:02x}:{dev:02x}.{func:x}'.format(**d)
            print(s)
    if len(devs) > 1:
        exception_quit('{} FPGAs are found\nplease choose '
                       'one FPGA to do mactest'.format(len(devs)))
    if not devs:
        exception_quit('no FPGA found')
    args.fpga_root = devs[0].get('path')
    args.bitstream_id = f.find_node(devs[0].get('path'),
                                    'bitstream_id', depth=3)

    mac_addrs = glob.glob(os.path.join(devs[0].get('path'),
                                       'intel-fpga-fme.*', 'spi-altera*',
                                       'spi_master', 'spi*', 'spi*',
                                       'mac_address'))
    args.mac_addr = None
    if len(mac_addrs) > 0:
        args.mac_addr = mac_addrs[0]
    mac_cnts = glob.glob(os.path.join(devs[0].get('path'),
                                      'intel-fpga-fme.*', 'spi-altera*',
                                      'spi_master', 'spi*', 'spi*',
                                      'mac_count'))
    args.mac_cnt = None
    if len(mac_cnts) > 0:
        args.mac_cnt = mac_cnts[0]

    if args.mac_addr is None or args.mac_cnt is None:
        nvmem_path = f.find_node(devs[0].get('path'), 'nvmem', depth=7)
        if not nvmem_path:
            nvmem_path = f.find_node(devs[0].get('path'), 'eeprom', depth=7)
        if not nvmem_path:
            exception_quit('No nvmem found at {}'.format(devs[0].get('path')))
        args.nvmem = None
        if len(nvmem_path) > 0:
            args.nvmem = nvmem_path[0]
        if len(nvmem_path) > 1 and args.debug:
            s = 'multi nvmem found, select {} to do mactest'.format(args.nvmem)
            print(s)

    args.eth_grps = f.find_node(devs[0].get('path'), 'eth_group*/dev', depth=4)
    if not args.eth_grps:
        exception_quit('No ethernet group found')
    for g in args.eth_grps:
        if args.debug:
            print('ethernet group device: {}'.format(g))

    m = MacromCompare(args)
    m.start()
Пример #6
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--segment',
                        '-S',
                        type=hexint,
                        help='Segment number of PCIe device')
    parser.add_argument('--bus',
                        '-B',
                        type=hexint,
                        help='Bus number of PCIe device')
    parser.add_argument('--device',
                        '-D',
                        type=hexint,
                        help='Device number of PCIe device')
    parser.add_argument('--function',
                        '-F',
                        type=hexint,
                        help='Function number of PCIe device')
    parser.add_argument('--direction',
                        required=True,
                        choices=['local', 'remote'],
                        help='choose loopback direction from chip view')
    parser.add_argument('--enable',
                        action='store_const',
                        dest='en',
                        const=1,
                        help='loopback enable')
    parser.add_argument('--disable',
                        action='store_const',
                        dest='en',
                        const=0,
                        help='loopback disable')
    parser.add_argument('--type',
                        choices=['serial', 'precdr', 'postcdr'],
                        help='choose loopback type')
    parser.add_argument('--port',
                        nargs='*',
                        default='all',
                        help='enable/disable loopback on specific port')
    parser.add_argument('--side',
                        required=True,
                        choices=['line', 'host'],
                        help='choose loopback on which side')
    args, left = parser.parse_known_args()

    if args.en is None:
        exception_quit('please specify --enable/--disable loopback!')
    else:
        op = 'enable' if args.en else 'disable'
        print('{} fpga loopback'.format(op))

    if not args.type:
        if ((args.side == 'line' and args.direction == 'local')
                or (args.side == 'host' and args.direction == 'remote')):
            args.type = 'serial'
        else:
            exception_quit(
                'missing argument --type [serial | precdr | postcdr]')

    f = FpgaFinder(args.segment, args.bus, args.device, args.function)
    devs = f.find()
    for d in devs:
        print('bdf: {segment:04x}:{bus:02x}:{dev:02x}.{func:x}'.format(**d))
    if len(devs) > 1:
        exception_quit('{} FPGAs are found\nplease choose '
                       'one FPGA'.format(len(devs)))
    if not devs:
        exception_quit('no FPGA found')
    args.eth_grps = f.find_node(devs[0].get('path'), 'eth_group*/dev', depth=3)
    if not args.eth_grps:
        exception_quit('No ethernet group found')
    for g in args.eth_grps:
        print('ethernet group device: {}'.format(g))

    lp = FPGALPBK(args)
    lp.start()
    print('Done')
Пример #7
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--segment',
                        '-S',
                        type=hexint,
                        help='Segment number of PCIe device')
    parser.add_argument('--bus',
                        '-B',
                        type=hexint,
                        help='Bus number of PCIe device')
    parser.add_argument('--device',
                        '-D',
                        type=hexint,
                        help='Device number of PCIe device')
    parser.add_argument('--function',
                        '-F',
                        type=hexint,
                        help='Function number of PCIe device')
    parser.add_argument('mode',
                        choices=['no', 'kr', 'rs'],
                        nargs='?',
                        default=None,
                        help='Choose fec mode to configure')
    parser.add_argument('--rsu', '-r', action='store_true', help='Reboot card')
    parser.add_argument('--debug',
                        '-d',
                        action='store_true',
                        help='Output debug information')
    args, left = parser.parse_known_args()

    f = FpgaFinder(args.segment, args.bus, args.device, args.function)
    devs = f.find()
    for d in devs:
        sbdf = '{segment:04x}:{bus:02x}:{dev:02x}.{func:x}'.format(**d)
    if len(devs) > 1:
        exception_quit(
            '{} FPGAs are found\n'
            'please choose one FPGA'.format(len(devs)), 1)
    if not devs:
        exception_quit('no FPGA found', 2)

    if args.mode is None:
        if args.rsu:
            bdf = do_rsu(sbdf, args.debug)
            if bdf is None:
                ret = 1
            else:
                ret = 0
        else:
            ret = show_fec_mode(sbdf)
        sys.exit(ret)

    if fec_is_fixed(sbdf, args.debug):
        print('fec mode is not configurable in card {}'.format(sbdf))
        sys.exit(2)

    with open(CONF_FILE, 'w') as f:
        option_line = OPTION_LINE + '"{}"'.format(args.mode)
        if args.debug:
            print("write '{}' to file {}".format(option_line, CONF_FILE))
        f.write(option_line + '\n')

    ret = reload_driver(args.mode, args.debug)
    if ret == 0:
        bdf = do_rsu(sbdf, args.debug)
        if bdf is not None:
            if args.debug and bdf != sbdf:
                print("BDF of FPGA changed to {}".format(bdf))
            ret = check_fec_mode(bdf, args.mode, args.debug)
        else:
            ret = 1

    if ret == 0:
        print("done")
    else:
        print("please power cycle system or reboot card to make the fec mode "
              "effective")
    sys.exit(ret)
Пример #8
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--segment', '-S', type=hexint,
                        help='Segment number of PCIe device')
    parser.add_argument('--bus', '-B', type=hexint,
                        help='Bus number of PCIe device')
    parser.add_argument('--device', '-D', type=hexint,
                        help='Device number of PCIe device')
    parser.add_argument('--function', '-F', type=hexint,
                        help='Function number of PCIe device')
    parser.add_argument('--number', '-n', default=DEFAULT_TEST_PKT_NUM,
                        help='Number of the test packets to send per MAC')
    parser.add_argument('--length', '-s', default=DEFAULT_TEST_PKT_LEN,
                        help='Length of each test packet')
    parser.add_argument('--loopback', '-l', action='store_true',
                        help='Configure loopback automatically.'
                             'Loopback is not configured by default.')
    parser.add_argument('--clear', '-c', action='store_true',
                        help='Clear statistics automatically.'
                             'Statistics are not cleared by default.')
    parser.add_argument('--port', '-p', nargs='*', default='all',
                        help='Test on selected MACs')
    parser.add_argument('--debug', '-d', action='store_true',
                        help='Output debug information')
    args, left = parser.parse_known_args()

    setattr(args, 'number', int(getattr(args, 'number')))
    if args.number < MIN_TEST_PKT_NUM or args.number > MAX_TEST_PKT_NUM:
        setattr(args, 'number', DEFAULT_TEST_PKT_NUM)
        print(('The number of test packets is out of range ({}~{})'
              ', use {} instead'.format(MIN_TEST_PKT_NUM, MAX_TEST_PKT_NUM,
                                        DEFAULT_TEST_PKT_NUM)))
    setattr(args, 'length', int(getattr(args, 'length')))
    if args.length < MIN_TEST_PKT_LEN or args.length > MAX_TEST_PKT_LEN:
        setattr(args, 'length', DEFAULT_TEST_PKT_LEN)
        print(('The length of test packet is out of range ({}~{})'
              ', use {} instead'.format(MIN_TEST_PKT_LEN, MAX_TEST_PKT_LEN,
                                        DEFAULT_TEST_PKT_LEN)))

    f = FpgaFinder(args.segment, args.bus, args.device, args.function)
    devs = f.find()
    for d in devs:
        sbdf = '{segment:04x}:{bus:02x}:{dev:02x}.{func:x}'.format(**d)
        print('DUT: {}'.format(sbdf))
    if len(devs) > 1:
        exception_quit('{} FPGAs are found\n'
                       'please choose one FPGA'.format(len(devs)), 1)
    if not devs:
        exception_quit('no FPGA found', 2)

    args.fpga_root = devs[0].get('path')
    args.eth_grps = f.find_eth_group(args.fpga_root)
    print("args.eth_grps", args.eth_grps)
    if len(args.eth_grps) == 0:
        exception_quit("Invalid Eth group MDEV")

    get_sbdf_mode_mapping(sbdf, args)
    lock_file = '/tmp/DUT{}'.format(sbdf)
    if os.path.exists(lock_file):
        exception_quit("FPGA {} is already in test".format(sbdf), 0)

    try:
        with open(lock_file, 'w') as fd:
            fd.write(sbdf)
        enable_loopback(args)
        fvl_bypass_mode_test(sbdf, args)
    finally:
        disable_loopback(args)
        if os.path.exists(lock_file):
            os.remove(lock_file)
        print('Done')