Commit 3911bc34 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

scripts/rpc: option to format framework_get_pci_devices for use with lspci



Added an option, `--format-lspci` that produces output that can be
consumed by `lspci -F`.  Additionally, added a simple convenience script
that executes lspci with the the output of the RPC.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I41a0f846f32506c28cf6ca3a299ed264f64db1a4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10653


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 9647fd4e
Loading
Loading
Loading
Loading

scripts/lspci

0 → 100755
+6 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

set -e

scriptdir=$(dirname $0)
lspci -F <($scriptdir/rpc.py framework_get_pci_devices --format-lspci) "$@"
+14 −1
Original line number Diff line number Diff line
@@ -2691,9 +2691,22 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
    p.set_defaults(func=sock_set_default_impl)

    def framework_get_pci_devices(args):
        print_json(rpc.subsystem.framework_get_pci_devices(args.client))
        def splitbuf(buf, step):
            return [buf[i:i+step] for i in range(0, len(buf), step)]

        devices = rpc.subsystem.framework_get_pci_devices(args.client)
        if not args.format_lspci:
            print_json(devices)
        else:
            for devid, dev in enumerate(devices):
                print('{} device #{}'.format(dev['address'], devid))
                for lineid, line in enumerate(splitbuf(dev['config_space'], 32)):
                    print('{:02x}: {}'.format(lineid * 16, ' '.join(splitbuf(line.lower(), 2))))
                print()

    p = subparsers.add_parser('framework_get_pci_devices', help='''Get a list of attached PCI devices''')
    p.add_argument('--format-lspci', help='Format the output in a way to be consumed by lspci -F',
                   action='store_true')
    p.set_defaults(func=framework_get_pci_devices)

    def check_called_name(name):