pci: use address struct in function arguments
[dpdk.git] / lib / librte_eal / linuxapp / eal / eal_pci.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #include <string.h>
35 #include <dirent.h>
36
37 #include <rte_log.h>
38 #include <rte_pci.h>
39 #include <rte_eal_memconfig.h>
40 #include <rte_malloc.h>
41 #include <rte_devargs.h>
42 #include <rte_memcpy.h>
43
44 #include "eal_filesystem.h"
45 #include "eal_private.h"
46 #include "eal_pci_init.h"
47
48 /**
49  * @file
50  * PCI probing under linux
51  *
52  * This code is used to simulate a PCI probe by parsing information in sysfs.
53  * When a registered device matches a driver, it is then initialized with
54  * IGB_UIO driver (or doesn't initialize, if the device wasn't bound to it).
55  */
56
57 static int
58 pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
59 {
60         int count;
61         char path[PATH_MAX];
62         char *name;
63
64         if (!filename || !dri_name)
65                 return -1;
66
67         count = readlink(filename, path, PATH_MAX);
68         if (count >= PATH_MAX)
69                 return -1;
70
71         /* For device does not have a driver */
72         if (count < 0)
73                 return 1;
74
75         path[count] = '\0';
76
77         name = strrchr(path, '/');
78         if (name) {
79                 strncpy(dri_name, name + 1, strlen(name + 1) + 1);
80                 return 0;
81         }
82
83         return -1;
84 }
85
86 /* Map pci device */
87 int
88 rte_eal_pci_map_device(struct rte_pci_device *dev)
89 {
90         int ret = -1;
91
92         /* try mapping the NIC resources using VFIO if it exists */
93         switch (dev->kdrv) {
94         case RTE_KDRV_VFIO:
95 #ifdef VFIO_PRESENT
96                 if (pci_vfio_is_enabled())
97                         ret = pci_vfio_map_resource(dev);
98 #endif
99                 break;
100         case RTE_KDRV_IGB_UIO:
101         case RTE_KDRV_UIO_GENERIC:
102                 /* map resources for devices that use uio */
103                 ret = pci_uio_map_resource(dev);
104                 break;
105         default:
106                 RTE_LOG(DEBUG, EAL,
107                         "  Not managed by a supported kernel driver, skipped\n");
108                 ret = 1;
109                 break;
110         }
111
112         return ret;
113 }
114
115 /* Unmap pci device */
116 void
117 rte_eal_pci_unmap_device(struct rte_pci_device *dev)
118 {
119         /* try unmapping the NIC resources using VFIO if it exists */
120         switch (dev->kdrv) {
121         case RTE_KDRV_VFIO:
122                 RTE_LOG(ERR, EAL, "Hotplug doesn't support vfio yet\n");
123                 break;
124         case RTE_KDRV_IGB_UIO:
125         case RTE_KDRV_UIO_GENERIC:
126                 /* unmap resources for devices that use uio */
127                 pci_uio_unmap_resource(dev);
128                 break;
129         default:
130                 RTE_LOG(DEBUG, EAL,
131                         "  Not managed by a supported kernel driver, skipped\n");
132                 break;
133         }
134 }
135
136 void *
137 pci_find_max_end_va(void)
138 {
139         const struct rte_memseg *seg = rte_eal_get_physmem_layout();
140         const struct rte_memseg *last = seg;
141         unsigned i = 0;
142
143         for (i = 0; i < RTE_MAX_MEMSEG; i++, seg++) {
144                 if (seg->addr == NULL)
145                         break;
146
147                 if (seg->addr > last->addr)
148                         last = seg;
149
150         }
151         return RTE_PTR_ADD(last->addr, last->len);
152 }
153
154 /* parse one line of the "resource" sysfs file (note that the 'line'
155  * string is modified)
156  */
157 int
158 pci_parse_one_sysfs_resource(char *line, size_t len, uint64_t *phys_addr,
159         uint64_t *end_addr, uint64_t *flags)
160 {
161         union pci_resource_info {
162                 struct {
163                         char *phys_addr;
164                         char *end_addr;
165                         char *flags;
166                 };
167                 char *ptrs[PCI_RESOURCE_FMT_NVAL];
168         } res_info;
169
170         if (rte_strsplit(line, len, res_info.ptrs, 3, ' ') != 3) {
171                 RTE_LOG(ERR, EAL,
172                         "%s(): bad resource format\n", __func__);
173                 return -1;
174         }
175         errno = 0;
176         *phys_addr = strtoull(res_info.phys_addr, NULL, 16);
177         *end_addr = strtoull(res_info.end_addr, NULL, 16);
178         *flags = strtoull(res_info.flags, NULL, 16);
179         if (errno != 0) {
180                 RTE_LOG(ERR, EAL,
181                         "%s(): bad resource format\n", __func__);
182                 return -1;
183         }
184
185         return 0;
186 }
187
188 /* parse the "resource" sysfs file */
189 static int
190 pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev)
191 {
192         FILE *f;
193         char buf[BUFSIZ];
194         int i;
195         uint64_t phys_addr, end_addr, flags;
196
197         f = fopen(filename, "r");
198         if (f == NULL) {
199                 RTE_LOG(ERR, EAL, "Cannot open sysfs resource\n");
200                 return -1;
201         }
202
203         for (i = 0; i<PCI_MAX_RESOURCE; i++) {
204
205                 if (fgets(buf, sizeof(buf), f) == NULL) {
206                         RTE_LOG(ERR, EAL,
207                                 "%s(): cannot read resource\n", __func__);
208                         goto error;
209                 }
210                 if (pci_parse_one_sysfs_resource(buf, sizeof(buf), &phys_addr,
211                                 &end_addr, &flags) < 0)
212                         goto error;
213
214                 if (flags & IORESOURCE_MEM) {
215                         dev->mem_resource[i].phys_addr = phys_addr;
216                         dev->mem_resource[i].len = end_addr - phys_addr + 1;
217                         /* not mapped for now */
218                         dev->mem_resource[i].addr = NULL;
219                 }
220         }
221         fclose(f);
222         return 0;
223
224 error:
225         fclose(f);
226         return -1;
227 }
228
229 /* Scan one pci sysfs entry, and fill the devices list from it. */
230 static int
231 pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
232 {
233         char filename[PATH_MAX];
234         unsigned long tmp;
235         struct rte_pci_device *dev;
236         char driver[PATH_MAX];
237         int ret;
238
239         dev = malloc(sizeof(*dev));
240         if (dev == NULL)
241                 return -1;
242
243         memset(dev, 0, sizeof(*dev));
244         dev->addr = *addr;
245
246         /* get vendor id */
247         snprintf(filename, sizeof(filename), "%s/vendor", dirname);
248         if (eal_parse_sysfs_value(filename, &tmp) < 0) {
249                 free(dev);
250                 return -1;
251         }
252         dev->id.vendor_id = (uint16_t)tmp;
253
254         /* get device id */
255         snprintf(filename, sizeof(filename), "%s/device", dirname);
256         if (eal_parse_sysfs_value(filename, &tmp) < 0) {
257                 free(dev);
258                 return -1;
259         }
260         dev->id.device_id = (uint16_t)tmp;
261
262         /* get subsystem_vendor id */
263         snprintf(filename, sizeof(filename), "%s/subsystem_vendor",
264                  dirname);
265         if (eal_parse_sysfs_value(filename, &tmp) < 0) {
266                 free(dev);
267                 return -1;
268         }
269         dev->id.subsystem_vendor_id = (uint16_t)tmp;
270
271         /* get subsystem_device id */
272         snprintf(filename, sizeof(filename), "%s/subsystem_device",
273                  dirname);
274         if (eal_parse_sysfs_value(filename, &tmp) < 0) {
275                 free(dev);
276                 return -1;
277         }
278         dev->id.subsystem_device_id = (uint16_t)tmp;
279
280         /* get class_id */
281         snprintf(filename, sizeof(filename), "%s/class",
282                  dirname);
283         if (eal_parse_sysfs_value(filename, &tmp) < 0) {
284                 free(dev);
285                 return -1;
286         }
287         /* the least 24 bits are valid: class, subclass, program interface */
288         dev->id.class_id = (uint32_t)tmp & RTE_CLASS_ANY_ID;
289
290         /* get max_vfs */
291         dev->max_vfs = 0;
292         snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
293         if (!access(filename, F_OK) &&
294             eal_parse_sysfs_value(filename, &tmp) == 0)
295                 dev->max_vfs = (uint16_t)tmp;
296         else {
297                 /* for non igb_uio driver, need kernel version >= 3.8 */
298                 snprintf(filename, sizeof(filename),
299                          "%s/sriov_numvfs", dirname);
300                 if (!access(filename, F_OK) &&
301                     eal_parse_sysfs_value(filename, &tmp) == 0)
302                         dev->max_vfs = (uint16_t)tmp;
303         }
304
305         /* get numa node */
306         snprintf(filename, sizeof(filename), "%s/numa_node",
307                  dirname);
308         if (access(filename, R_OK) != 0) {
309                 /* if no NUMA support, set default to 0 */
310                 dev->device.numa_node = 0;
311         } else {
312                 if (eal_parse_sysfs_value(filename, &tmp) < 0) {
313                         free(dev);
314                         return -1;
315                 }
316                 dev->device.numa_node = tmp;
317         }
318
319         /* parse resources */
320         snprintf(filename, sizeof(filename), "%s/resource", dirname);
321         if (pci_parse_sysfs_resource(filename, dev) < 0) {
322                 RTE_LOG(ERR, EAL, "%s(): cannot parse resource\n", __func__);
323                 free(dev);
324                 return -1;
325         }
326
327         /* parse driver */
328         snprintf(filename, sizeof(filename), "%s/driver", dirname);
329         ret = pci_get_kernel_driver_by_path(filename, driver);
330         if (ret < 0) {
331                 RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
332                 free(dev);
333                 return -1;
334         }
335
336         if (!ret) {
337                 if (!strcmp(driver, "vfio-pci"))
338                         dev->kdrv = RTE_KDRV_VFIO;
339                 else if (!strcmp(driver, "igb_uio"))
340                         dev->kdrv = RTE_KDRV_IGB_UIO;
341                 else if (!strcmp(driver, "uio_pci_generic"))
342                         dev->kdrv = RTE_KDRV_UIO_GENERIC;
343                 else
344                         dev->kdrv = RTE_KDRV_UNKNOWN;
345         } else
346                 dev->kdrv = RTE_KDRV_NONE;
347
348         /* device is valid, add in list (sorted) */
349         if (TAILQ_EMPTY(&pci_device_list)) {
350                 rte_eal_device_insert(&dev->device);
351                 TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
352         } else {
353                 struct rte_pci_device *dev2;
354                 int ret;
355
356                 TAILQ_FOREACH(dev2, &pci_device_list, next) {
357                         ret = rte_eal_compare_pci_addr(&dev->addr, &dev2->addr);
358                         if (ret > 0)
359                                 continue;
360
361                         if (ret < 0) {
362                                 TAILQ_INSERT_BEFORE(dev2, dev, next);
363                                 rte_eal_device_insert(&dev->device);
364                         } else { /* already registered */
365                                 dev2->kdrv = dev->kdrv;
366                                 dev2->max_vfs = dev->max_vfs;
367                                 memmove(dev2->mem_resource, dev->mem_resource,
368                                         sizeof(dev->mem_resource));
369                                 free(dev);
370                         }
371                         return 0;
372                 }
373                 rte_eal_device_insert(&dev->device);
374                 TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
375         }
376
377         return 0;
378 }
379
380 int
381 pci_update_device(const struct rte_pci_addr *addr)
382 {
383         char filename[PATH_MAX];
384
385         snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT,
386                  pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid,
387                  addr->function);
388
389         return pci_scan_one(filename, addr);
390 }
391
392 /*
393  * split up a pci address into its constituent parts.
394  */
395 static int
396 parse_pci_addr_format(const char *buf, int bufsize, struct rte_pci_addr *addr)
397 {
398         /* first split on ':' */
399         union splitaddr {
400                 struct {
401                         char *domain;
402                         char *bus;
403                         char *devid;
404                         char *function;
405                 };
406                 char *str[PCI_FMT_NVAL]; /* last element-separator is "." not ":" */
407         } splitaddr;
408
409         char *buf_copy = strndup(buf, bufsize);
410         if (buf_copy == NULL)
411                 return -1;
412
413         if (rte_strsplit(buf_copy, bufsize, splitaddr.str, PCI_FMT_NVAL, ':')
414                         != PCI_FMT_NVAL - 1)
415                 goto error;
416         /* final split is on '.' between devid and function */
417         splitaddr.function = strchr(splitaddr.devid,'.');
418         if (splitaddr.function == NULL)
419                 goto error;
420         *splitaddr.function++ = '\0';
421
422         /* now convert to int values */
423         errno = 0;
424         addr->domain = (uint16_t)strtoul(splitaddr.domain, NULL, 16);
425         addr->bus = (uint8_t)strtoul(splitaddr.bus, NULL, 16);
426         addr->devid = (uint8_t)strtoul(splitaddr.devid, NULL, 16);
427         addr->function = (uint8_t)strtoul(splitaddr.function, NULL, 10);
428         if (errno != 0)
429                 goto error;
430
431         free(buf_copy); /* free the copy made with strdup */
432         return 0;
433 error:
434         free(buf_copy);
435         return -1;
436 }
437
438 /*
439  * Scan the content of the PCI bus, and the devices in the devices
440  * list
441  */
442 int
443 rte_eal_pci_scan(void)
444 {
445         struct dirent *e;
446         DIR *dir;
447         char dirname[PATH_MAX];
448         struct rte_pci_addr addr;
449
450         dir = opendir(pci_get_sysfs_path());
451         if (dir == NULL) {
452                 RTE_LOG(ERR, EAL, "%s(): opendir failed: %s\n",
453                         __func__, strerror(errno));
454                 return -1;
455         }
456
457         while ((e = readdir(dir)) != NULL) {
458                 if (e->d_name[0] == '.')
459                         continue;
460
461                 if (parse_pci_addr_format(e->d_name, sizeof(e->d_name), &addr) != 0)
462                         continue;
463
464                 snprintf(dirname, sizeof(dirname), "%s/%s",
465                                 pci_get_sysfs_path(), e->d_name);
466                 if (pci_scan_one(dirname, &addr) < 0)
467                         goto error;
468         }
469         closedir(dir);
470         return 0;
471
472 error:
473         closedir(dir);
474         return -1;
475 }
476
477 /* Read PCI config space. */
478 int rte_eal_pci_read_config(const struct rte_pci_device *device,
479                             void *buf, size_t len, off_t offset)
480 {
481         const struct rte_intr_handle *intr_handle = &device->intr_handle;
482
483         switch (intr_handle->type) {
484         case RTE_INTR_HANDLE_UIO:
485         case RTE_INTR_HANDLE_UIO_INTX:
486                 return pci_uio_read_config(intr_handle, buf, len, offset);
487
488 #ifdef VFIO_PRESENT
489         case RTE_INTR_HANDLE_VFIO_MSIX:
490         case RTE_INTR_HANDLE_VFIO_MSI:
491         case RTE_INTR_HANDLE_VFIO_LEGACY:
492                 return pci_vfio_read_config(intr_handle, buf, len, offset);
493 #endif
494         default:
495                 RTE_LOG(ERR, EAL,
496                         "Unknown handle type of fd %d\n",
497                                         intr_handle->fd);
498                 return -1;
499         }
500 }
501
502 /* Write PCI config space. */
503 int rte_eal_pci_write_config(const struct rte_pci_device *device,
504                              const void *buf, size_t len, off_t offset)
505 {
506         const struct rte_intr_handle *intr_handle = &device->intr_handle;
507
508         switch (intr_handle->type) {
509         case RTE_INTR_HANDLE_UIO:
510         case RTE_INTR_HANDLE_UIO_INTX:
511                 return pci_uio_write_config(intr_handle, buf, len, offset);
512
513 #ifdef VFIO_PRESENT
514         case RTE_INTR_HANDLE_VFIO_MSIX:
515         case RTE_INTR_HANDLE_VFIO_MSI:
516         case RTE_INTR_HANDLE_VFIO_LEGACY:
517                 return pci_vfio_write_config(intr_handle, buf, len, offset);
518 #endif
519         default:
520                 RTE_LOG(ERR, EAL,
521                         "Unknown handle type of fd %d\n",
522                                         intr_handle->fd);
523                 return -1;
524         }
525 }
526
527 #if defined(RTE_ARCH_X86)
528 static int
529 pci_ioport_map(struct rte_pci_device *dev, int bar __rte_unused,
530                struct rte_pci_ioport *p)
531 {
532         uint16_t start, end;
533         FILE *fp;
534         char *line = NULL;
535         char pci_id[16];
536         int found = 0;
537         size_t linesz;
538
539         snprintf(pci_id, sizeof(pci_id), PCI_PRI_FMT,
540                  dev->addr.domain, dev->addr.bus,
541                  dev->addr.devid, dev->addr.function);
542
543         fp = fopen("/proc/ioports", "r");
544         if (fp == NULL) {
545                 RTE_LOG(ERR, EAL, "%s(): can't open ioports\n", __func__);
546                 return -1;
547         }
548
549         while (getdelim(&line, &linesz, '\n', fp) > 0) {
550                 char *ptr = line;
551                 char *left;
552                 int n;
553
554                 n = strcspn(ptr, ":");
555                 ptr[n] = 0;
556                 left = &ptr[n + 1];
557
558                 while (*left && isspace(*left))
559                         left++;
560
561                 if (!strncmp(left, pci_id, strlen(pci_id))) {
562                         found = 1;
563
564                         while (*ptr && isspace(*ptr))
565                                 ptr++;
566
567                         sscanf(ptr, "%04hx-%04hx", &start, &end);
568
569                         break;
570                 }
571         }
572
573         free(line);
574         fclose(fp);
575
576         if (!found)
577                 return -1;
578
579         dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
580         p->base = start;
581         RTE_LOG(DEBUG, EAL, "PCI Port IO found start=0x%x\n", start);
582
583         return 0;
584 }
585 #endif
586
587 int
588 rte_eal_pci_ioport_map(struct rte_pci_device *dev, int bar,
589                        struct rte_pci_ioport *p)
590 {
591         int ret = -1;
592
593         switch (dev->kdrv) {
594 #ifdef VFIO_PRESENT
595         case RTE_KDRV_VFIO:
596                 if (pci_vfio_is_enabled())
597                         ret = pci_vfio_ioport_map(dev, bar, p);
598                 break;
599 #endif
600         case RTE_KDRV_IGB_UIO:
601                 ret = pci_uio_ioport_map(dev, bar, p);
602                 break;
603         case RTE_KDRV_UIO_GENERIC:
604 #if defined(RTE_ARCH_X86)
605                 ret = pci_ioport_map(dev, bar, p);
606 #else
607                 ret = pci_uio_ioport_map(dev, bar, p);
608 #endif
609                 break;
610         case RTE_KDRV_NONE:
611 #if defined(RTE_ARCH_X86)
612                 ret = pci_ioport_map(dev, bar, p);
613 #endif
614                 break;
615         default:
616                 break;
617         }
618
619         if (!ret)
620                 p->dev = dev;
621
622         return ret;
623 }
624
625 void
626 rte_eal_pci_ioport_read(struct rte_pci_ioport *p,
627                         void *data, size_t len, off_t offset)
628 {
629         switch (p->dev->kdrv) {
630 #ifdef VFIO_PRESENT
631         case RTE_KDRV_VFIO:
632                 pci_vfio_ioport_read(p, data, len, offset);
633                 break;
634 #endif
635         case RTE_KDRV_IGB_UIO:
636                 pci_uio_ioport_read(p, data, len, offset);
637                 break;
638         case RTE_KDRV_UIO_GENERIC:
639                 pci_uio_ioport_read(p, data, len, offset);
640                 break;
641         case RTE_KDRV_NONE:
642 #if defined(RTE_ARCH_X86)
643                 pci_uio_ioport_read(p, data, len, offset);
644 #endif
645                 break;
646         default:
647                 break;
648         }
649 }
650
651 void
652 rte_eal_pci_ioport_write(struct rte_pci_ioport *p,
653                          const void *data, size_t len, off_t offset)
654 {
655         switch (p->dev->kdrv) {
656 #ifdef VFIO_PRESENT
657         case RTE_KDRV_VFIO:
658                 pci_vfio_ioport_write(p, data, len, offset);
659                 break;
660 #endif
661         case RTE_KDRV_IGB_UIO:
662                 pci_uio_ioport_write(p, data, len, offset);
663                 break;
664         case RTE_KDRV_UIO_GENERIC:
665                 pci_uio_ioport_write(p, data, len, offset);
666                 break;
667         case RTE_KDRV_NONE:
668 #if defined(RTE_ARCH_X86)
669                 pci_uio_ioport_write(p, data, len, offset);
670 #endif
671                 break;
672         default:
673                 break;
674         }
675 }
676
677 int
678 rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
679 {
680         int ret = -1;
681
682         switch (p->dev->kdrv) {
683 #ifdef VFIO_PRESENT
684         case RTE_KDRV_VFIO:
685                 if (pci_vfio_is_enabled())
686                         ret = pci_vfio_ioport_unmap(p);
687                 break;
688 #endif
689         case RTE_KDRV_IGB_UIO:
690                 ret = pci_uio_ioport_unmap(p);
691                 break;
692         case RTE_KDRV_UIO_GENERIC:
693 #if defined(RTE_ARCH_X86)
694                 ret = 0;
695 #else
696                 ret = pci_uio_ioport_unmap(p);
697 #endif
698                 break;
699         case RTE_KDRV_NONE:
700 #if defined(RTE_ARCH_X86)
701                 ret = 0;
702 #endif
703                 break;
704         default:
705                 break;
706         }
707
708         return ret;
709 }
710
711 /* Init the PCI EAL subsystem */
712 int
713 rte_eal_pci_init(void)
714 {
715         /* for debug purposes, PCI can be disabled */
716         if (internal_config.no_pci)
717                 return 0;
718
719         if (rte_eal_pci_scan() < 0) {
720                 RTE_LOG(ERR, EAL, "%s(): Cannot scan PCI bus\n", __func__);
721                 return -1;
722         }
723
724         return 0;
725 }