drivers/dpaa: optimize thread local storage
[dpdk.git] / drivers / bus / dpaa / dpaa_bus.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  *   Copyright 2017-2019 NXP
4  *
5  */
6 /* System headers */
7 #include <stdio.h>
8 #include <inttypes.h>
9 #include <unistd.h>
10 #include <limits.h>
11 #include <sched.h>
12 #include <signal.h>
13 #include <pthread.h>
14 #include <sys/types.h>
15 #include <sys/syscall.h>
16
17 #include <rte_byteorder.h>
18 #include <rte_common.h>
19 #include <rte_interrupts.h>
20 #include <rte_log.h>
21 #include <rte_debug.h>
22 #include <rte_atomic.h>
23 #include <rte_branch_prediction.h>
24 #include <rte_memory.h>
25 #include <rte_tailq.h>
26 #include <rte_eal.h>
27 #include <rte_alarm.h>
28 #include <rte_ether.h>
29 #include <rte_ethdev_driver.h>
30 #include <rte_malloc.h>
31 #include <rte_ring.h>
32 #include <rte_bus.h>
33 #include <rte_mbuf_pool_ops.h>
34
35 #include <dpaa_of.h>
36 #include <rte_dpaa_bus.h>
37 #include <rte_dpaa_logs.h>
38 #include <dpaax_iova_table.h>
39
40 #include <fsl_usd.h>
41 #include <fsl_qman.h>
42 #include <fsl_bman.h>
43 #include <netcfg.h>
44
45 static struct rte_dpaa_bus rte_dpaa_bus;
46 struct netcfg_info *dpaa_netcfg;
47
48 /* define a variable to hold the portal_key, once created.*/
49 static pthread_key_t dpaa_portal_key;
50
51 unsigned int dpaa_svr_family;
52
53 #define FSL_DPAA_BUS_NAME       dpaa_bus
54
55 RTE_DEFINE_PER_LCORE(struct dpaa_portal *, dpaa_io);
56
57 struct fm_eth_port_cfg *
58 dpaa_get_eth_port_cfg(int dev_id)
59 {
60         return &dpaa_netcfg->port_cfg[dev_id];
61 }
62
63 static int
64 compare_dpaa_devices(struct rte_dpaa_device *dev1,
65                      struct rte_dpaa_device *dev2)
66 {
67         int comp = 0;
68
69         /* Segragating ETH from SEC devices */
70         if (dev1->device_type > dev2->device_type)
71                 comp = 1;
72         else if (dev1->device_type < dev2->device_type)
73                 comp = -1;
74         else
75                 comp = 0;
76
77         if ((comp != 0) || (dev1->device_type != FSL_DPAA_ETH))
78                 return comp;
79
80         if (dev1->id.fman_id > dev2->id.fman_id) {
81                 comp = 1;
82         } else if (dev1->id.fman_id < dev2->id.fman_id) {
83                 comp = -1;
84         } else {
85                 /* FMAN ids match, check for mac_id */
86                 if (dev1->id.mac_id > dev2->id.mac_id)
87                         comp = 1;
88                 else if (dev1->id.mac_id < dev2->id.mac_id)
89                         comp = -1;
90                 else
91                         comp = 0;
92         }
93
94         return comp;
95 }
96
97 static inline void
98 dpaa_add_to_device_list(struct rte_dpaa_device *newdev)
99 {
100         int comp, inserted = 0;
101         struct rte_dpaa_device *dev = NULL;
102         struct rte_dpaa_device *tdev = NULL;
103
104         TAILQ_FOREACH_SAFE(dev, &rte_dpaa_bus.device_list, next, tdev) {
105                 comp = compare_dpaa_devices(newdev, dev);
106                 if (comp < 0) {
107                         TAILQ_INSERT_BEFORE(dev, newdev, next);
108                         inserted = 1;
109                         break;
110                 }
111         }
112
113         if (!inserted)
114                 TAILQ_INSERT_TAIL(&rte_dpaa_bus.device_list, newdev, next);
115 }
116
117 /*
118  * Reads the SEC device from DTS
119  * Returns -1 if SEC devices not available, 0 otherwise
120  */
121 static inline int
122 dpaa_sec_available(void)
123 {
124         const struct device_node *caam_node;
125
126         for_each_compatible_node(caam_node, NULL, "fsl,sec-v4.0") {
127                 return 0;
128         }
129
130         return -1;
131 }
132
133 static void dpaa_clean_device_list(void);
134
135 static struct rte_devargs *
136 dpaa_devargs_lookup(struct rte_dpaa_device *dev)
137 {
138         struct rte_devargs *devargs;
139         char dev_name[32];
140
141         RTE_EAL_DEVARGS_FOREACH("dpaa_bus", devargs) {
142                 devargs->bus->parse(devargs->name, &dev_name);
143                 if (strcmp(dev_name, dev->device.name) == 0) {
144                         DPAA_BUS_INFO("**Devargs matched %s", dev_name);
145                         return devargs;
146                 }
147         }
148         return NULL;
149 }
150
151 static int
152 dpaa_create_device_list(void)
153 {
154         int i;
155         int ret;
156         struct rte_dpaa_device *dev;
157         struct fm_eth_port_cfg *cfg;
158         struct fman_if *fman_intf;
159
160         /* Creating Ethernet Devices */
161         for (i = 0; i < dpaa_netcfg->num_ethports; i++) {
162                 dev = calloc(1, sizeof(struct rte_dpaa_device));
163                 if (!dev) {
164                         DPAA_BUS_LOG(ERR, "Failed to allocate ETH devices");
165                         ret = -ENOMEM;
166                         goto cleanup;
167                 }
168
169                 dev->device.bus = &rte_dpaa_bus.bus;
170
171                 cfg = &dpaa_netcfg->port_cfg[i];
172                 fman_intf = cfg->fman_if;
173
174                 /* Device identifiers */
175                 dev->id.fman_id = fman_intf->fman_idx + 1;
176                 dev->id.mac_id = fman_intf->mac_idx;
177                 dev->device_type = FSL_DPAA_ETH;
178                 dev->id.dev_id = i;
179
180                 /* Create device name */
181                 memset(dev->name, 0, RTE_ETH_NAME_MAX_LEN);
182                 sprintf(dev->name, "fm%d-mac%d", (fman_intf->fman_idx + 1),
183                         fman_intf->mac_idx);
184                 DPAA_BUS_LOG(INFO, "%s netdev added", dev->name);
185                 dev->device.name = dev->name;
186                 dev->device.devargs = dpaa_devargs_lookup(dev);
187
188                 dpaa_add_to_device_list(dev);
189         }
190
191         rte_dpaa_bus.device_count = i;
192
193         /* Unlike case of ETH, RTE_LIBRTE_DPAA_MAX_CRYPTODEV SEC devices are
194          * constantly created only if "sec" property is found in the device
195          * tree. Logically there is no limit for number of devices (QI
196          * interfaces) that can be created.
197          */
198
199         if (dpaa_sec_available()) {
200                 DPAA_BUS_LOG(INFO, "DPAA SEC devices are not available");
201                 return 0;
202         }
203
204         /* Creating SEC Devices */
205         for (i = 0; i < RTE_LIBRTE_DPAA_MAX_CRYPTODEV; i++) {
206                 dev = calloc(1, sizeof(struct rte_dpaa_device));
207                 if (!dev) {
208                         DPAA_BUS_LOG(ERR, "Failed to allocate SEC devices");
209                         ret = -1;
210                         goto cleanup;
211                 }
212
213                 dev->device_type = FSL_DPAA_CRYPTO;
214                 dev->id.dev_id = rte_dpaa_bus.device_count + i;
215
216                 /* Even though RTE_CRYPTODEV_NAME_MAX_LEN is valid length of
217                  * crypto PMD, using RTE_ETH_NAME_MAX_LEN as that is the size
218                  * allocated for dev->name/
219                  */
220                 memset(dev->name, 0, RTE_ETH_NAME_MAX_LEN);
221                 sprintf(dev->name, "dpaa_sec-%d", i+1);
222                 DPAA_BUS_LOG(INFO, "%s cryptodev added", dev->name);
223                 dev->device.name = dev->name;
224                 dev->device.devargs = dpaa_devargs_lookup(dev);
225
226                 dpaa_add_to_device_list(dev);
227         }
228
229         rte_dpaa_bus.device_count += i;
230
231         return 0;
232
233 cleanup:
234         dpaa_clean_device_list();
235         return ret;
236 }
237
238 static void
239 dpaa_clean_device_list(void)
240 {
241         struct rte_dpaa_device *dev = NULL;
242         struct rte_dpaa_device *tdev = NULL;
243
244         TAILQ_FOREACH_SAFE(dev, &rte_dpaa_bus.device_list, next, tdev) {
245                 TAILQ_REMOVE(&rte_dpaa_bus.device_list, dev, next);
246                 free(dev);
247                 dev = NULL;
248         }
249 }
250
251 int rte_dpaa_portal_init(void *arg)
252 {
253         unsigned int cpu, lcore = rte_lcore_id();
254         int ret;
255
256         BUS_INIT_FUNC_TRACE();
257
258         if ((size_t)arg == 1 || lcore == LCORE_ID_ANY)
259                 lcore = rte_get_master_lcore();
260         else
261                 if (lcore >= RTE_MAX_LCORE)
262                         return -1;
263
264         cpu = rte_lcore_to_cpu_id(lcore);
265
266         /* Initialise bman thread portals */
267         ret = bman_thread_init();
268         if (ret) {
269                 DPAA_BUS_LOG(ERR, "bman_thread_init failed on core %u"
270                              " (lcore=%u) with ret: %d", cpu, lcore, ret);
271                 return ret;
272         }
273
274         DPAA_BUS_LOG(DEBUG, "BMAN thread initialized - CPU=%d lcore=%d",
275                      cpu, lcore);
276
277         /* Initialise qman thread portals */
278         ret = qman_thread_init();
279         if (ret) {
280                 DPAA_BUS_LOG(ERR, "qman_thread_init failed on core %u"
281                             " (lcore=%u) with ret: %d", cpu, lcore, ret);
282                 bman_thread_finish();
283                 return ret;
284         }
285
286         DPAA_BUS_LOG(DEBUG, "QMAN thread initialized - CPU=%d lcore=%d",
287                      cpu, lcore);
288
289         DPAA_PER_LCORE_PORTAL = rte_malloc(NULL, sizeof(struct dpaa_portal),
290                                     RTE_CACHE_LINE_SIZE);
291         if (!DPAA_PER_LCORE_PORTAL) {
292                 DPAA_BUS_LOG(ERR, "Unable to allocate memory");
293                 bman_thread_finish();
294                 qman_thread_finish();
295                 return -ENOMEM;
296         }
297
298         DPAA_PER_LCORE_PORTAL->qman_idx = qman_get_portal_index();
299         DPAA_PER_LCORE_PORTAL->bman_idx = bman_get_portal_index();
300         DPAA_PER_LCORE_PORTAL->tid = syscall(SYS_gettid);
301
302         ret = pthread_setspecific(dpaa_portal_key,
303                                   (void *)DPAA_PER_LCORE_PORTAL);
304         if (ret) {
305                 DPAA_BUS_LOG(ERR, "pthread_setspecific failed on core %u"
306                              " (lcore=%u) with ret: %d", cpu, lcore, ret);
307                 dpaa_portal_finish(NULL);
308
309                 return ret;
310         }
311
312         DPAA_BUS_LOG(DEBUG, "QMAN thread initialized");
313
314         return 0;
315 }
316
317 int
318 rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq)
319 {
320         /* Affine above created portal with channel*/
321         u32 sdqcr;
322         int ret;
323
324         if (unlikely(!DPAA_PER_LCORE_PORTAL)) {
325                 ret = rte_dpaa_portal_init(arg);
326                 if (ret < 0) {
327                         DPAA_BUS_LOG(ERR, "portal initialization failure");
328                         return ret;
329                 }
330         }
331
332         /* Initialise qman specific portals */
333         ret = fsl_qman_fq_portal_init(fq->qp);
334         if (ret) {
335                 DPAA_BUS_LOG(ERR, "Unable to init fq portal");
336                 return -1;
337         }
338
339         sdqcr = QM_SDQCR_CHANNELS_POOL_CONV(fq->ch_id);
340         qman_static_dequeue_add(sdqcr, fq->qp);
341
342         return 0;
343 }
344
345 int rte_dpaa_portal_fq_close(struct qman_fq *fq)
346 {
347         return fsl_qman_fq_portal_destroy(fq->qp);
348 }
349
350 void
351 dpaa_portal_finish(void *arg)
352 {
353         struct dpaa_portal *dpaa_io_portal = (struct dpaa_portal *)arg;
354
355         if (!dpaa_io_portal) {
356                 DPAA_BUS_LOG(DEBUG, "Portal already cleaned");
357                 return;
358         }
359
360         bman_thread_finish();
361         qman_thread_finish();
362
363         pthread_setspecific(dpaa_portal_key, NULL);
364
365         rte_free(dpaa_io_portal);
366         dpaa_io_portal = NULL;
367         DPAA_PER_LCORE_PORTAL = NULL;
368 }
369
370 static int
371 rte_dpaa_bus_parse(const char *name, void *out_name)
372 {
373         int i, j;
374         int max_fman = 2, max_macs = 16;
375         char *dup_name;
376         char *sep = NULL;
377
378         /* There are two ways of passing device name, with and without
379          * separator. "dpaa_bus:fm1-mac3" with separator, and "fm1-mac3"
380          * without separator. Both need to be handled.
381          * It is also possible that "name=fm1-mac3" is passed along.
382          */
383         DPAA_BUS_DEBUG("Parse device name (%s)", name);
384
385         /* Check for dpaa_bus:fm1-mac3 style */
386         dup_name = strdup(name);
387         sep = strchr(dup_name, ':');
388         if (!sep)
389                 /* If not, check for name=fm1-mac3 style */
390                 sep = strchr(dup_name, '=');
391
392         if (sep)
393                 /* jump over the seprator */
394                 sep = (char *) (sep + 1);
395         else
396                 sep = dup_name;
397
398         for (i = 0; i < max_fman; i++) {
399                 for (j = 0; j < max_macs; j++) {
400                         char fm_name[16];
401                         snprintf(fm_name, 16, "fm%d-mac%d", i, j);
402                         if (strcmp(fm_name, sep) == 0) {
403                                 if (out_name)
404                                         strcpy(out_name, sep);
405                                 free(dup_name);
406                                 return 0;
407                         }
408                 }
409         }
410
411         for (i = 0; i < RTE_LIBRTE_DPAA_MAX_CRYPTODEV; i++) {
412                 char sec_name[16];
413
414                 snprintf(sec_name, 16, "dpaa_sec-%d", i+1);
415                 if (strcmp(sec_name, sep) == 0) {
416                         if (out_name)
417                                 strcpy(out_name, sep);
418                         free(dup_name);
419                         return 0;
420                 }
421         }
422
423         free(dup_name);
424         return -EINVAL;
425 }
426
427 #define DPAA_DEV_PATH1 "/sys/devices/platform/soc/soc:fsl,dpaa"
428 #define DPAA_DEV_PATH2 "/sys/devices/platform/fsl,dpaa"
429
430 static int
431 rte_dpaa_bus_scan(void)
432 {
433         int ret;
434
435         BUS_INIT_FUNC_TRACE();
436
437         if ((access(DPAA_DEV_PATH1, F_OK) != 0) &&
438             (access(DPAA_DEV_PATH2, F_OK) != 0)) {
439                 RTE_LOG(DEBUG, EAL, "DPAA Bus not present. Skipping.\n");
440                 return 0;
441         }
442
443         if (rte_dpaa_bus.detected)
444                 return 0;
445
446         rte_dpaa_bus.detected = 1;
447
448         /* create the key, supplying a function that'll be invoked
449          * when a portal affined thread will be deleted.
450          */
451         ret = pthread_key_create(&dpaa_portal_key, dpaa_portal_finish);
452         if (ret) {
453                 DPAA_BUS_LOG(DEBUG, "Unable to create pthread key. (%d)", ret);
454                 dpaa_clean_device_list();
455                 return ret;
456         }
457
458         return 0;
459 }
460
461 /* register a dpaa bus based dpaa driver */
462 void
463 rte_dpaa_driver_register(struct rte_dpaa_driver *driver)
464 {
465         RTE_VERIFY(driver);
466
467         BUS_INIT_FUNC_TRACE();
468
469         TAILQ_INSERT_TAIL(&rte_dpaa_bus.driver_list, driver, next);
470         /* Update Bus references */
471         driver->dpaa_bus = &rte_dpaa_bus;
472 }
473
474 /* un-register a dpaa bus based dpaa driver */
475 void
476 rte_dpaa_driver_unregister(struct rte_dpaa_driver *driver)
477 {
478         struct rte_dpaa_bus *dpaa_bus;
479
480         BUS_INIT_FUNC_TRACE();
481
482         dpaa_bus = driver->dpaa_bus;
483
484         TAILQ_REMOVE(&dpaa_bus->driver_list, driver, next);
485         /* Update Bus references */
486         driver->dpaa_bus = NULL;
487 }
488
489 static int
490 rte_dpaa_device_match(struct rte_dpaa_driver *drv,
491                       struct rte_dpaa_device *dev)
492 {
493         if (!drv || !dev) {
494                 DPAA_BUS_DEBUG("Invalid drv or dev received.");
495                 return -1;
496         }
497
498         if (drv->drv_type == dev->device_type)
499                 return 0;
500
501         return -1;
502 }
503
504 static int
505 rte_dpaa_bus_dev_build(void)
506 {
507         int ret;
508
509         /* Load the device-tree driver */
510         ret = of_init();
511         if (ret) {
512                 DPAA_BUS_LOG(ERR, "of_init failed with ret: %d", ret);
513                 return -1;
514         }
515
516         /* Get the interface configurations from device-tree */
517         dpaa_netcfg = netcfg_acquire();
518         if (!dpaa_netcfg) {
519                 DPAA_BUS_LOG(ERR, "netcfg_acquire failed");
520                 return -EINVAL;
521         }
522
523         RTE_LOG(NOTICE, EAL, "DPAA Bus Detected\n");
524
525         if (!dpaa_netcfg->num_ethports) {
526                 DPAA_BUS_LOG(INFO, "no network interfaces available");
527                 /* This is not an error */
528                 return 0;
529         }
530
531 #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
532         dump_netcfg(dpaa_netcfg);
533 #endif
534
535         DPAA_BUS_LOG(DEBUG, "Number of ethernet devices = %d",
536                      dpaa_netcfg->num_ethports);
537         ret = dpaa_create_device_list();
538         if (ret) {
539                 DPAA_BUS_LOG(ERR, "Unable to create device list. (%d)", ret);
540                 return ret;
541         }
542         return 0;
543 }
544
545 static int
546 rte_dpaa_bus_probe(void)
547 {
548         int ret = -1;
549         struct rte_dpaa_device *dev;
550         struct rte_dpaa_driver *drv;
551         FILE *svr_file = NULL;
552         unsigned int svr_ver;
553         int probe_all = rte_dpaa_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST;
554         static int process_once;
555
556         /* If DPAA bus is not present nothing needs to be done */
557         if (!rte_dpaa_bus.detected)
558                 return 0;
559
560         /* Device list creation is only done once */
561         if (!process_once) {
562                 rte_dpaa_bus_dev_build();
563                 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
564                         /* One time load of Qman/Bman drivers */
565                         ret = qman_global_init();
566                         if (ret) {
567                                 DPAA_BUS_ERR("QMAN initialization failed: %d",
568                                              ret);
569                                 return ret;
570                         }
571                         ret = bman_global_init();
572                         if (ret) {
573                                 DPAA_BUS_ERR("BMAN initialization failed: %d",
574                                              ret);
575                                 return ret;
576                         }
577                 }
578         }
579         process_once = 1;
580
581         /* If no device present on DPAA bus nothing needs to be done */
582         if (TAILQ_EMPTY(&rte_dpaa_bus.device_list))
583                 return 0;
584
585         svr_file = fopen(DPAA_SOC_ID_FILE, "r");
586         if (svr_file) {
587                 if (fscanf(svr_file, "svr:%x", &svr_ver) > 0)
588                         dpaa_svr_family = svr_ver & SVR_MASK;
589                 fclose(svr_file);
590         }
591
592         /* And initialize the PA->VA translation table */
593         dpaax_iova_table_populate();
594
595         /* For each registered driver, and device, call the driver->probe */
596         TAILQ_FOREACH(dev, &rte_dpaa_bus.device_list, next) {
597                 TAILQ_FOREACH(drv, &rte_dpaa_bus.driver_list, next) {
598                         ret = rte_dpaa_device_match(drv, dev);
599                         if (ret)
600                                 continue;
601
602                         if (rte_dev_is_probed(&dev->device))
603                                 continue;
604
605                         if (!drv->probe ||
606                             (dev->device.devargs &&
607                             dev->device.devargs->policy == RTE_DEV_BLACKLISTED))
608                                 continue;
609
610                         if (probe_all ||
611                             (dev->device.devargs &&
612                             dev->device.devargs->policy ==
613                             RTE_DEV_WHITELISTED)) {
614                                 ret = drv->probe(drv, dev);
615                                 if (ret) {
616                                         DPAA_BUS_ERR("unable to probe:%s",
617                                                      dev->name);
618                                 } else {
619                                         dev->driver = drv;
620                                         dev->device.driver = &drv->driver;
621                                 }
622                         }
623                         break;
624                 }
625         }
626
627         /* Register DPAA mempool ops only if any DPAA device has
628          * been detected.
629          */
630         rte_mbuf_set_platform_mempool_ops(DPAA_MEMPOOL_OPS_NAME);
631
632         return 0;
633 }
634
635 static struct rte_device *
636 rte_dpaa_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
637                      const void *data)
638 {
639         struct rte_dpaa_device *dev;
640         const struct rte_dpaa_device *dstart;
641
642         /* find_device is called with 'data' as an opaque object - just call
643          * cmp with this and each device object on bus.
644          */
645
646         if (start != NULL) {
647                 dstart = RTE_DEV_TO_DPAA_CONST(start);
648                 dev = TAILQ_NEXT(dstart, next);
649         } else {
650                 dev = TAILQ_FIRST(&rte_dpaa_bus.device_list);
651         }
652
653         while (dev != NULL) {
654                 if (cmp(&dev->device, data) == 0) {
655                         DPAA_BUS_DEBUG("Found dev=(%s)\n", dev->device.name);
656                         return &dev->device;
657                 }
658                 dev = TAILQ_NEXT(dev, next);
659         }
660
661         DPAA_BUS_DEBUG("Unable to find any device\n");
662         return NULL;
663 }
664
665 /*
666  * Get iommu class of DPAA2 devices on the bus.
667  */
668 static enum rte_iova_mode
669 rte_dpaa_get_iommu_class(void)
670 {
671         if ((access(DPAA_DEV_PATH1, F_OK) != 0) &&
672             (access(DPAA_DEV_PATH2, F_OK) != 0)) {
673                 return RTE_IOVA_DC;
674         }
675         return RTE_IOVA_PA;
676 }
677
678 static int
679 dpaa_bus_plug(struct rte_device *dev __rte_unused)
680 {
681         /* No operation is performed while plugging the device */
682         return 0;
683 }
684
685 static int
686 dpaa_bus_unplug(struct rte_device *dev __rte_unused)
687 {
688         /* No operation is performed while unplugging the device */
689         return 0;
690 }
691
692 static void *
693 dpaa_bus_dev_iterate(const void *start, const char *str,
694                      const struct rte_dev_iterator *it __rte_unused)
695 {
696         const struct rte_dpaa_device *dstart;
697         struct rte_dpaa_device *dev;
698         char *dup, *dev_name = NULL;
699
700         if (str == NULL) {
701                 DPAA_BUS_DEBUG("No device string");
702                 return NULL;
703         }
704
705         /* Expectation is that device would be name=device_name */
706         if (strncmp(str, "name=", 5) != 0) {
707                 DPAA_BUS_DEBUG("Invalid device string (%s)\n", str);
708                 return NULL;
709         }
710
711         /* Now that name=device_name format is available, split */
712         dup = strdup(str);
713         dev_name = dup + strlen("name=");
714
715         if (start != NULL) {
716                 dstart = RTE_DEV_TO_DPAA_CONST(start);
717                 dev = TAILQ_NEXT(dstart, next);
718         } else {
719                 dev = TAILQ_FIRST(&rte_dpaa_bus.device_list);
720         }
721
722         while (dev != NULL) {
723                 if (strcmp(dev->device.name, dev_name) == 0) {
724                         free(dup);
725                         return &dev->device;
726                 }
727                 dev = TAILQ_NEXT(dev, next);
728         }
729
730         free(dup);
731         return NULL;
732 }
733
734 static struct rte_dpaa_bus rte_dpaa_bus = {
735         .bus = {
736                 .scan = rte_dpaa_bus_scan,
737                 .probe = rte_dpaa_bus_probe,
738                 .parse = rte_dpaa_bus_parse,
739                 .find_device = rte_dpaa_find_device,
740                 .get_iommu_class = rte_dpaa_get_iommu_class,
741                 .plug = dpaa_bus_plug,
742                 .unplug = dpaa_bus_unplug,
743                 .dev_iterate = dpaa_bus_dev_iterate,
744         },
745         .device_list = TAILQ_HEAD_INITIALIZER(rte_dpaa_bus.device_list),
746         .driver_list = TAILQ_HEAD_INITIALIZER(rte_dpaa_bus.driver_list),
747         .device_count = 0,
748 };
749
750 RTE_REGISTER_BUS(FSL_DPAA_BUS_NAME, rte_dpaa_bus.bus);
751 RTE_LOG_REGISTER(dpaa_logtype_bus, bus.dpaa, NOTICE);