Beispiel #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()
Beispiel #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')
    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()