xref: /dpdk/usertools/dpdk-devbind.py (revision d37f5f27)
1#! /usr/bin/env python
2# SPDX-License-Identifier: BSD-3-Clause
3# Copyright(c) 2010-2014 Intel Corporation
4#
5
6import sys
7import os
8import getopt
9import subprocess
10from os.path import exists, abspath, dirname, basename
11
12# The PCI base class for all devices
13network_class = {'Class': '02', 'Vendor': None, 'Device': None,
14                    'SVendor': None, 'SDevice': None}
15ifpga_class = {'Class': '12', 'Vendor': '8086', 'Device': '0b30',
16                    'SVendor': None, 'SDevice': None}
17encryption_class = {'Class': '10', 'Vendor': None, 'Device': None,
18                   'SVendor': None, 'SDevice': None}
19intel_processor_class = {'Class': '0b', 'Vendor': '8086', 'Device': None,
20                   'SVendor': None, 'SDevice': None}
21cavium_sso = {'Class': '08', 'Vendor': '177d', 'Device': 'a04b,a04d',
22              'SVendor': None, 'SDevice': None}
23cavium_fpa = {'Class': '08', 'Vendor': '177d', 'Device': 'a053',
24              'SVendor': None, 'SDevice': None}
25cavium_pkx = {'Class': '08', 'Vendor': '177d', 'Device': 'a0dd,a049',
26              'SVendor': None, 'SDevice': None}
27cavium_tim = {'Class': '08', 'Vendor': '177d', 'Device': 'a051',
28              'SVendor': None, 'SDevice': None}
29cavium_zip = {'Class': '12', 'Vendor': '177d', 'Device': 'a037',
30              'SVendor': None, 'SDevice': None}
31avp_vnic = {'Class': '05', 'Vendor': '1af4', 'Device': '1110',
32              'SVendor': None, 'SDevice': None}
33
34octeontx2_sso = {'Class': '08', 'Vendor': '177d', 'Device': 'a0f9,a0fa',
35              'SVendor': None, 'SDevice': None}
36octeontx2_npa = {'Class': '08', 'Vendor': '177d', 'Device': 'a0fb,a0fc',
37              'SVendor': None, 'SDevice': None}
38
39intel_ioat_bdw = {'Class': '08', 'Vendor': '8086', 'Device': '6f20,6f21,6f22,6f23,6f24,6f25,6f26,6f27,6f2e,6f2f',
40              'SVendor': None, 'SDevice': None}
41intel_ioat_skx = {'Class': '08', 'Vendor': '8086', 'Device': '2021',
42              'SVendor': None, 'SDevice': None}
43
44network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class]
45crypto_devices = [encryption_class, intel_processor_class]
46eventdev_devices = [cavium_sso, cavium_tim, octeontx2_sso]
47mempool_devices = [cavium_fpa, octeontx2_npa]
48compress_devices = [cavium_zip]
49misc_devices = [intel_ioat_bdw, intel_ioat_skx]
50
51# global dict ethernet devices present. Dictionary indexed by PCI address.
52# Each device within this is itself a dictionary of device properties
53devices = {}
54# list of supported DPDK drivers
55dpdk_drivers = ["igb_uio", "vfio-pci", "uio_pci_generic"]
56
57# command-line arg flags
58b_flag = None
59status_flag = False
60force_flag = False
61args = []
62
63
64def usage():
65    '''Print usage information for the program'''
66    argv0 = basename(sys.argv[0])
67    print("""
68Usage:
69------
70
71     %(argv0)s [options] DEVICE1 DEVICE2 ....
72
73where DEVICE1, DEVICE2 etc, are specified via PCI "domain:bus:slot.func" syntax
74or "bus:slot.func" syntax. For devices bound to Linux kernel drivers, they may
75also be referred to by Linux interface name e.g. eth0, eth1, em0, em1, etc.
76
77Options:
78    --help, --usage:
79        Display usage information and quit
80
81    -s, --status:
82        Print the current status of all known network, crypto, event
83        and mempool devices.
84        For each device, it displays the PCI domain, bus, slot and function,
85        along with a text description of the device. Depending upon whether the
86        device is being used by a kernel driver, the igb_uio driver, or no
87        driver, other relevant information will be displayed:
88        * the Linux interface name e.g. if=eth0
89        * the driver being used e.g. drv=igb_uio
90        * any suitable drivers not currently using that device
91            e.g. unused=igb_uio
92        NOTE: if this flag is passed along with a bind/unbind option, the
93        status display will always occur after the other operations have taken
94        place.
95
96    --status-dev:
97        Print the status of given device group. Supported device groups are:
98        "net", "crypto", "event", "mempool" and "compress"
99
100    -b driver, --bind=driver:
101        Select the driver to use or \"none\" to unbind the device
102
103    -u, --unbind:
104        Unbind a device (Equivalent to \"-b none\")
105
106    --force:
107        By default, network devices which are used by Linux - as indicated by
108        having routes in the routing table - cannot be modified. Using the
109        --force flag overrides this behavior, allowing active links to be
110        forcibly unbound.
111        WARNING: This can lead to loss of network connection and should be used
112        with caution.
113
114Examples:
115---------
116
117To display current device status:
118        %(argv0)s --status
119
120To display current network device status:
121        %(argv0)s --status-dev net
122
123To bind eth1 from the current driver and move to use igb_uio
124        %(argv0)s --bind=igb_uio eth1
125
126To unbind 0000:01:00.0 from using any driver
127        %(argv0)s -u 0000:01:00.0
128
129To bind 0000:02:00.0 and 0000:02:00.1 to the ixgbe kernel driver
130        %(argv0)s -b ixgbe 02:00.0 02:00.1
131
132    """ % locals())  # replace items from local variables
133
134
135# This is roughly compatible with check_output function in subprocess module
136# which is only available in python 2.7.
137def check_output(args, stderr=None):
138    '''Run a command and capture its output'''
139    return subprocess.Popen(args, stdout=subprocess.PIPE,
140                            stderr=stderr).communicate()[0]
141
142
143def check_modules():
144    '''Checks that igb_uio is loaded'''
145    global dpdk_drivers
146
147    # list of supported modules
148    mods = [{"Name": driver, "Found": False} for driver in dpdk_drivers]
149
150    # first check if module is loaded
151    try:
152        # Get list of sysfs modules (both built-in and dynamically loaded)
153        sysfs_path = '/sys/module/'
154
155        # Get the list of directories in sysfs_path
156        sysfs_mods = [os.path.join(sysfs_path, o) for o
157                      in os.listdir(sysfs_path)
158                      if os.path.isdir(os.path.join(sysfs_path, o))]
159
160        # Extract the last element of '/sys/module/abc' in the array
161        sysfs_mods = [a.split('/')[-1] for a in sysfs_mods]
162
163        # special case for vfio_pci (module is named vfio-pci,
164        # but its .ko is named vfio_pci)
165        sysfs_mods = [a if a != 'vfio_pci' else 'vfio-pci' for a in sysfs_mods]
166
167        for mod in mods:
168            if mod["Name"] in sysfs_mods:
169                mod["Found"] = True
170    except:
171        pass
172
173    # check if we have at least one loaded module
174    if True not in [mod["Found"] for mod in mods] and b_flag is not None:
175        if b_flag in dpdk_drivers:
176            print("Error - no supported modules(DPDK driver) are loaded")
177            sys.exit(1)
178        else:
179            print("Warning - no supported modules(DPDK driver) are loaded")
180
181    # change DPDK driver list to only contain drivers that are loaded
182    dpdk_drivers = [mod["Name"] for mod in mods if mod["Found"]]
183
184
185def has_driver(dev_id):
186    '''return true if a device is assigned to a driver. False otherwise'''
187    return "Driver_str" in devices[dev_id]
188
189
190def get_pci_device_details(dev_id, probe_lspci):
191    '''This function gets additional details for a PCI device'''
192    device = {}
193
194    if probe_lspci:
195        extra_info = check_output(["lspci", "-vmmks", dev_id]).splitlines()
196
197        # parse lspci details
198        for line in extra_info:
199            if len(line) == 0:
200                continue
201            name, value = line.decode().split("\t", 1)
202            name = name.strip(":") + "_str"
203            device[name] = value
204    # check for a unix interface name
205    device["Interface"] = ""
206    for base, dirs, _ in os.walk("/sys/bus/pci/devices/%s/" % dev_id):
207        if "net" in dirs:
208            device["Interface"] = \
209                ",".join(os.listdir(os.path.join(base, "net")))
210            break
211    # check if a port is used for ssh connection
212    device["Ssh_if"] = False
213    device["Active"] = ""
214
215    return device
216
217def clear_data():
218    '''This function clears any old data'''
219    devices = {}
220
221def get_device_details(devices_type):
222    '''This function populates the "devices" dictionary. The keys used are
223    the pci addresses (domain:bus:slot.func). The values are themselves
224    dictionaries - one for each NIC.'''
225    global devices
226    global dpdk_drivers
227
228    # first loop through and read details for all devices
229    # request machine readable format, with numeric IDs and String
230    dev = {}
231    dev_lines = check_output(["lspci", "-Dvmmnnk"]).splitlines()
232    for dev_line in dev_lines:
233        if len(dev_line) == 0:
234            if device_type_match(dev, devices_type):
235                # Replace "Driver" with "Driver_str" to have consistency of
236                # of dictionary key names
237                if "Driver" in dev.keys():
238                    dev["Driver_str"] = dev.pop("Driver")
239                if "Module" in dev.keys():
240                    dev["Module_str"] = dev.pop("Module")
241                # use dict to make copy of dev
242                devices[dev["Slot"]] = dict(dev)
243            # Clear previous device's data
244            dev = {}
245        else:
246            name, value = dev_line.decode().split("\t", 1)
247            value_list = value.rsplit(' ', 1)
248            if len(value_list) > 1:
249                # String stored in <name>_str
250                dev[name.rstrip(":") + '_str'] = value_list[0]
251            # Numeric IDs
252            dev[name.rstrip(":")] = value_list[len(value_list) - 1] \
253                .rstrip("]").lstrip("[")
254
255    if devices_type == network_devices:
256        # check what is the interface if any for an ssh connection if
257        # any to this host, so we can mark it later.
258        ssh_if = []
259        route = check_output(["ip", "-o", "route"])
260        # filter out all lines for 169.254 routes
261        route = "\n".join(filter(lambda ln: not ln.startswith("169.254"),
262                             route.decode().splitlines()))
263        rt_info = route.split()
264        for i in range(len(rt_info) - 1):
265            if rt_info[i] == "dev":
266                ssh_if.append(rt_info[i+1])
267
268    # based on the basic info, get extended text details
269    for d in devices.keys():
270        if not device_type_match(devices[d], devices_type):
271            continue
272
273        # get additional info and add it to existing data
274        devices[d] = devices[d].copy()
275        # No need to probe lspci
276        devices[d].update(get_pci_device_details(d, False).items())
277
278        if devices_type == network_devices:
279            for _if in ssh_if:
280                if _if in devices[d]["Interface"].split(","):
281                    devices[d]["Ssh_if"] = True
282                    devices[d]["Active"] = "*Active*"
283                    break
284
285        # add igb_uio to list of supporting modules if needed
286        if "Module_str" in devices[d]:
287            for driver in dpdk_drivers:
288                if driver not in devices[d]["Module_str"]:
289                    devices[d]["Module_str"] = \
290                        devices[d]["Module_str"] + ",%s" % driver
291        else:
292            devices[d]["Module_str"] = ",".join(dpdk_drivers)
293
294        # make sure the driver and module strings do not have any duplicates
295        if has_driver(d):
296            modules = devices[d]["Module_str"].split(",")
297            if devices[d]["Driver_str"] in modules:
298                modules.remove(devices[d]["Driver_str"])
299                devices[d]["Module_str"] = ",".join(modules)
300
301
302def device_type_match(dev, devices_type):
303    for i in range(len(devices_type)):
304        param_count = len(
305            [x for x in devices_type[i].values() if x is not None])
306        match_count = 0
307        if dev["Class"][0:2] == devices_type[i]["Class"]:
308            match_count = match_count + 1
309            for key in devices_type[i].keys():
310                if key != 'Class' and devices_type[i][key]:
311                    value_list = devices_type[i][key].split(',')
312                    for value in value_list:
313                        if value.strip(' ') == dev[key]:
314                            match_count = match_count + 1
315            # count must be the number of non None parameters to match
316            if match_count == param_count:
317                return True
318    return False
319
320def dev_id_from_dev_name(dev_name):
321    '''Take a device "name" - a string passed in by user to identify a NIC
322    device, and determine the device id - i.e. the domain:bus:slot.func - for
323    it, which can then be used to index into the devices array'''
324
325    # check if it's already a suitable index
326    if dev_name in devices:
327        return dev_name
328    # check if it's an index just missing the domain part
329    elif "0000:" + dev_name in devices:
330        return "0000:" + dev_name
331    else:
332        # check if it's an interface name, e.g. eth1
333        for d in devices.keys():
334            if dev_name in devices[d]["Interface"].split(","):
335                return devices[d]["Slot"]
336    # if nothing else matches - error
337    print("Unknown device: %s. "
338          "Please specify device in \"bus:slot.func\" format" % dev_name)
339    sys.exit(1)
340
341
342def unbind_one(dev_id, force):
343    '''Unbind the device identified by "dev_id" from its current driver'''
344    dev = devices[dev_id]
345    if not has_driver(dev_id):
346        print("%s %s %s is not currently managed by any driver\n" %
347              (dev["Slot"], dev["Device_str"], dev["Interface"]))
348        return
349
350    # prevent us disconnecting ourselves
351    if dev["Ssh_if"] and not force:
352        print("Routing table indicates that interface %s is active. "
353              "Skipping unbind" % (dev_id))
354        return
355
356    # write to /sys to unbind
357    filename = "/sys/bus/pci/drivers/%s/unbind" % dev["Driver_str"]
358    try:
359        f = open(filename, "a")
360    except:
361        print("Error: unbind failed for %s - Cannot open %s"
362              % (dev_id, filename))
363        sys.exit(1)
364    f.write(dev_id)
365    f.close()
366
367
368def bind_one(dev_id, driver, force):
369    '''Bind the device given by "dev_id" to the driver "driver". If the device
370    is already bound to a different driver, it will be unbound first'''
371    dev = devices[dev_id]
372    saved_driver = None  # used to rollback any unbind in case of failure
373
374    # prevent disconnection of our ssh session
375    if dev["Ssh_if"] and not force:
376        print("Routing table indicates that interface %s is active. "
377              "Not modifying" % (dev_id))
378        return
379
380    # unbind any existing drivers we don't want
381    if has_driver(dev_id):
382        if dev["Driver_str"] == driver:
383            print("%s already bound to driver %s, skipping\n"
384                  % (dev_id, driver))
385            return
386        else:
387            saved_driver = dev["Driver_str"]
388            unbind_one(dev_id, force)
389            dev["Driver_str"] = ""  # clear driver string
390
391    # For kernels >= 3.15 driver_override can be used to specify the driver
392    # for a device rather than relying on the driver to provide a positive
393    # match of the device.  The existing process of looking up
394    # the vendor and device ID, adding them to the driver new_id,
395    # will erroneously bind other devices too which has the additional burden
396    # of unbinding those devices
397    if driver in dpdk_drivers:
398        filename = "/sys/bus/pci/devices/%s/driver_override" % dev_id
399        if os.path.exists(filename):
400            try:
401                f = open(filename, "w")
402            except:
403                print("Error: bind failed for %s - Cannot open %s"
404                      % (dev_id, filename))
405                return
406            try:
407                f.write("%s" % driver)
408                f.close()
409            except:
410                print("Error: bind failed for %s - Cannot write driver %s to "
411                      "PCI ID " % (dev_id, driver))
412                return
413        # For kernels < 3.15 use new_id to add PCI id's to the driver
414        else:
415            filename = "/sys/bus/pci/drivers/%s/new_id" % driver
416            try:
417                f = open(filename, "w")
418            except:
419                print("Error: bind failed for %s - Cannot open %s"
420                      % (dev_id, filename))
421                return
422            try:
423                # Convert Device and Vendor Id to int to write to new_id
424                f.write("%04x %04x" % (int(dev["Vendor"],16),
425                        int(dev["Device"], 16)))
426                f.close()
427            except:
428                print("Error: bind failed for %s - Cannot write new PCI ID to "
429                      "driver %s" % (dev_id, driver))
430                return
431
432    # do the bind by writing to /sys
433    filename = "/sys/bus/pci/drivers/%s/bind" % driver
434    try:
435        f = open(filename, "a")
436    except:
437        print("Error: bind failed for %s - Cannot open %s"
438              % (dev_id, filename))
439        if saved_driver is not None:  # restore any previous driver
440            bind_one(dev_id, saved_driver, force)
441        return
442    try:
443        f.write(dev_id)
444        f.close()
445    except:
446        # for some reason, closing dev_id after adding a new PCI ID to new_id
447        # results in IOError. however, if the device was successfully bound,
448        # we don't care for any errors and can safely ignore IOError
449        tmp = get_pci_device_details(dev_id, True)
450        if "Driver_str" in tmp and tmp["Driver_str"] == driver:
451            return
452        print("Error: bind failed for %s - Cannot bind to driver %s"
453              % (dev_id, driver))
454        if saved_driver is not None:  # restore any previous driver
455            bind_one(dev_id, saved_driver, force)
456        return
457
458    # For kernels > 3.15 driver_override is used to bind a device to a driver.
459    # Before unbinding it, overwrite driver_override with empty string so that
460    # the device can be bound to any other driver
461    filename = "/sys/bus/pci/devices/%s/driver_override" % dev_id
462    if os.path.exists(filename):
463        try:
464            f = open(filename, "w")
465        except:
466            print("Error: unbind failed for %s - Cannot open %s"
467                  % (dev_id, filename))
468            sys.exit(1)
469        try:
470            f.write("\00")
471            f.close()
472        except:
473            print("Error: unbind failed for %s - Cannot open %s"
474                  % (dev_id, filename))
475            sys.exit(1)
476
477
478def unbind_all(dev_list, force=False):
479    """Unbind method, takes a list of device locations"""
480
481    if dev_list[0] == "dpdk":
482        for d in devices.keys():
483            if "Driver_str" in devices[d]:
484                if devices[d]["Driver_str"] in dpdk_drivers:
485                    unbind_one(devices[d]["Slot"], force)
486        return
487
488    dev_list = map(dev_id_from_dev_name, dev_list)
489    for d in dev_list:
490        unbind_one(d, force)
491
492
493def bind_all(dev_list, driver, force=False):
494    """Bind method, takes a list of device locations"""
495    global devices
496
497    dev_list = map(dev_id_from_dev_name, dev_list)
498
499    for d in dev_list:
500        bind_one(d, driver, force)
501
502    # For kernels < 3.15 when binding devices to a generic driver
503    # (i.e. one that doesn't have a PCI ID table) using new_id, some devices
504    # that are not bound to any other driver could be bound even if no one has
505    # asked them to. hence, we check the list of drivers again, and see if
506    # some of the previously-unbound devices were erroneously bound.
507    if not os.path.exists("/sys/bus/pci/devices/%s/driver_override" % d):
508        for d in devices.keys():
509            # skip devices that were already bound or that we know should be bound
510            if "Driver_str" in devices[d] or d in dev_list:
511                continue
512
513            # update information about this device
514            devices[d] = dict(devices[d].items() +
515                              get_pci_device_details(d, True).items())
516
517            # check if updated information indicates that the device was bound
518            if "Driver_str" in devices[d]:
519                unbind_one(d, force)
520
521
522def display_devices(title, dev_list, extra_params=None):
523    '''Displays to the user the details of a list of devices given in
524    "dev_list". The "extra_params" parameter, if given, should contain a string
525     with %()s fields in it for replacement by the named fields in each
526     device's dictionary.'''
527    strings = []  # this holds the strings to print. We sort before printing
528    print("\n%s" % title)
529    print("="*len(title))
530    if len(dev_list) == 0:
531        strings.append("<none>")
532    else:
533        for dev in dev_list:
534            if extra_params is not None:
535                strings.append("%s '%s %s' %s" % (dev["Slot"],
536                                               dev["Device_str"],
537                                               dev["Device"],
538                                               extra_params % dev))
539            else:
540                strings.append("%s '%s'" % (dev["Slot"], dev["Device_str"]))
541    # sort before printing, so that the entries appear in PCI order
542    strings.sort()
543    print("\n".join(strings))  # print one per line
544
545def show_device_status(devices_type, device_name):
546    global dpdk_drivers
547    kernel_drv = []
548    dpdk_drv = []
549    no_drv = []
550
551    # split our list of network devices into the three categories above
552    for d in devices.keys():
553        if device_type_match(devices[d], devices_type):
554            if not has_driver(d):
555                no_drv.append(devices[d])
556                continue
557            if devices[d]["Driver_str"] in dpdk_drivers:
558                dpdk_drv.append(devices[d])
559            else:
560                kernel_drv.append(devices[d])
561
562    n_devs = len(dpdk_drv) + len(kernel_drv) + len(no_drv)
563
564    # don't bother displaying anything if there are no devices
565    if n_devs == 0:
566        msg = "No '%s' devices detected" % device_name
567        print("")
568        print(msg)
569        print("".join('=' * len(msg)))
570        return
571
572    # print each category separately, so we can clearly see what's used by DPDK
573    if len(dpdk_drv) != 0:
574        display_devices("%s devices using DPDK-compatible driver" % device_name,
575                        dpdk_drv, "drv=%(Driver_str)s unused=%(Module_str)s")
576    if len(kernel_drv) != 0:
577        display_devices("%s devices using kernel driver" % device_name, kernel_drv,
578                        "if=%(Interface)s drv=%(Driver_str)s "
579                        "unused=%(Module_str)s %(Active)s")
580    if len(no_drv) != 0:
581        display_devices("Other %s devices" % device_name, no_drv,
582                        "unused=%(Module_str)s")
583
584def show_status():
585    '''Function called when the script is passed the "--status" option.
586    Displays to the user what devices are bound to the igb_uio driver, the
587    kernel driver or to no driver'''
588
589    if status_dev == "net" or status_dev == "all":
590        show_device_status(network_devices, "Network")
591
592    if status_dev == "crypto" or status_dev == "all":
593        show_device_status(crypto_devices, "Crypto")
594
595    if status_dev == "event" or status_dev == "all":
596        show_device_status(eventdev_devices, "Eventdev")
597
598    if status_dev == "mempool" or status_dev == "all":
599        show_device_status(mempool_devices, "Mempool")
600
601    if status_dev == "compress" or status_dev == "all":
602        show_device_status(compress_devices , "Compress")
603
604    if status_dev == "misc" or status_dev == "all":
605        show_device_status(misc_devices, "Misc (rawdev)")
606
607def parse_args():
608    '''Parses the command-line arguments given by the user and takes the
609    appropriate action for each'''
610    global b_flag
611    global status_flag
612    global status_dev
613    global force_flag
614    global args
615    if len(sys.argv) <= 1:
616        usage()
617        sys.exit(0)
618
619    try:
620        opts, args = getopt.getopt(sys.argv[1:], "b:us",
621                                   ["help", "usage", "status", "status-dev=",
622                                    "force", "bind=", "unbind", ])
623    except getopt.GetoptError as error:
624        print(str(error))
625        print("Run '%s --usage' for further information" % sys.argv[0])
626        sys.exit(1)
627
628    for opt, arg in opts:
629        if opt == "--help" or opt == "--usage":
630            usage()
631            sys.exit(0)
632        if opt == "--status-dev":
633            status_flag = True
634            status_dev = arg
635        if opt == "--status" or opt == "-s":
636            status_flag = True
637            status_dev = "all"
638        if opt == "--force":
639            force_flag = True
640        if opt == "-b" or opt == "-u" or opt == "--bind" or opt == "--unbind":
641            if b_flag is not None:
642                print("Error - Only one bind or unbind may be specified\n")
643                sys.exit(1)
644            if opt == "-u" or opt == "--unbind":
645                b_flag = "none"
646            else:
647                b_flag = arg
648
649
650def do_arg_actions():
651    '''do the actual action requested by the user'''
652    global b_flag
653    global status_flag
654    global force_flag
655    global args
656
657    if b_flag is None and not status_flag:
658        print("Error: No action specified for devices."
659              "Please give a -b or -u option")
660        print("Run '%s --usage' for further information" % sys.argv[0])
661        sys.exit(1)
662
663    if b_flag is not None and len(args) == 0:
664        print("Error: No devices specified.")
665        print("Run '%s --usage' for further information" % sys.argv[0])
666        sys.exit(1)
667
668    if b_flag == "none" or b_flag == "None":
669        unbind_all(args, force_flag)
670    elif b_flag is not None:
671        bind_all(args, b_flag, force_flag)
672    if status_flag:
673        if b_flag is not None:
674            clear_data()
675            # refresh if we have changed anything
676            get_device_details(network_devices)
677            get_device_details(crypto_devices)
678            get_device_details(eventdev_devices)
679            get_device_details(mempool_devices)
680            get_device_details(compress_devices)
681            get_device_details(misc_devices)
682        show_status()
683
684
685def main():
686    '''program main function'''
687    # check if lspci is installed, suppress any output
688    with open(os.devnull, 'w') as devnull:
689        ret = subprocess.call(['which', 'lspci'],
690                              stdout=devnull, stderr=devnull)
691        if ret != 0:
692            print("'lspci' not found - please install 'pciutils'")
693            sys.exit(1)
694    parse_args()
695    check_modules()
696    clear_data()
697    get_device_details(network_devices)
698    get_device_details(crypto_devices)
699    get_device_details(eventdev_devices)
700    get_device_details(mempool_devices)
701    get_device_details(compress_devices)
702    get_device_details(misc_devices)
703    do_arg_actions()
704
705if __name__ == "__main__":
706    main()
707