bus/dpaa: move QBMAN global init to bus
[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 int dpaa_logtype_bus;
46 int dpaa_logtype_mempool;
47 int dpaa_logtype_pmd;
48 int dpaa_logtype_eventdev;
49
50 static struct rte_dpaa_bus rte_dpaa_bus;
51 struct netcfg_info *dpaa_netcfg;
52
53 /* define a variable to hold the portal_key, once created.*/
54 static pthread_key_t dpaa_portal_key;
55
56 unsigned int dpaa_svr_family;
57
58 #define FSL_DPAA_BUS_NAME       dpaa_bus
59
60 RTE_DEFINE_PER_LCORE(bool, dpaa_io);
61 RTE_DEFINE_PER_LCORE(struct dpaa_portal_dqrr, held_bufs);
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         struct dpaa_portal *dpaa_io_portal;
256
257         BUS_INIT_FUNC_TRACE();
258
259         if ((size_t)arg == 1 || lcore == LCORE_ID_ANY)
260                 lcore = rte_get_master_lcore();
261         else
262                 if (lcore >= RTE_MAX_LCORE)
263                         return -1;
264
265         cpu = rte_lcore_to_cpu_id(lcore);
266
267         /* Initialise bman thread portals */
268         ret = bman_thread_init();
269         if (ret) {
270                 DPAA_BUS_LOG(ERR, "bman_thread_init failed on core %u"
271                              " (lcore=%u) with ret: %d", cpu, lcore, ret);
272                 return ret;
273         }
274
275         DPAA_BUS_LOG(DEBUG, "BMAN thread initialized - CPU=%d lcore=%d",
276                      cpu, lcore);
277
278         /* Initialise qman thread portals */
279         ret = qman_thread_init();
280         if (ret) {
281                 DPAA_BUS_LOG(ERR, "qman_thread_init failed on core %u"
282                             " (lcore=%u) with ret: %d", cpu, lcore, ret);
283                 bman_thread_finish();
284                 return ret;
285         }
286
287         DPAA_BUS_LOG(DEBUG, "QMAN thread initialized - CPU=%d lcore=%d",
288                      cpu, lcore);
289
290         dpaa_io_portal = rte_malloc(NULL, sizeof(struct dpaa_portal),
291                                     RTE_CACHE_LINE_SIZE);
292         if (!dpaa_io_portal) {
293                 DPAA_BUS_LOG(ERR, "Unable to allocate memory");
294                 bman_thread_finish();
295                 qman_thread_finish();
296                 return -ENOMEM;
297         }
298
299         dpaa_io_portal->qman_idx = qman_get_portal_index();
300         dpaa_io_portal->bman_idx = bman_get_portal_index();
301         dpaa_io_portal->tid = syscall(SYS_gettid);
302
303         ret = pthread_setspecific(dpaa_portal_key, (void *)dpaa_io_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         RTE_PER_LCORE(dpaa_io) = true;
313
314         DPAA_BUS_LOG(DEBUG, "QMAN thread initialized");
315
316         return 0;
317 }
318
319 int
320 rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq)
321 {
322         /* Affine above created portal with channel*/
323         u32 sdqcr;
324         int ret;
325
326         if (unlikely(!RTE_PER_LCORE(dpaa_io))) {
327                 ret = rte_dpaa_portal_init(arg);
328                 if (ret < 0) {
329                         DPAA_BUS_LOG(ERR, "portal initialization failure");
330                         return ret;
331                 }
332         }
333
334         /* Initialise qman specific portals */
335         ret = fsl_qman_fq_portal_init(fq->qp);
336         if (ret) {
337                 DPAA_BUS_LOG(ERR, "Unable to init fq portal");
338                 return -1;
339         }
340
341         sdqcr = QM_SDQCR_CHANNELS_POOL_CONV(fq->ch_id);
342         qman_static_dequeue_add(sdqcr, fq->qp);
343
344         return 0;
345 }
346
347 int rte_dpaa_portal_fq_close(struct qman_fq *fq)
348 {
349         return fsl_qman_fq_portal_destroy(fq->qp);
350 }
351
352 void
353 dpaa_portal_finish(void *arg)
354 {
355         struct dpaa_portal *dpaa_io_portal = (struct dpaa_portal *)arg;
356
357         if (!dpaa_io_portal) {
358                 DPAA_BUS_LOG(DEBUG, "Portal already cleaned");
359                 return;
360         }
361
362         bman_thread_finish();
363         qman_thread_finish();
364
365         pthread_setspecific(dpaa_portal_key, NULL);
366
367         rte_free(dpaa_io_portal);
368         dpaa_io_portal = NULL;
369
370         RTE_PER_LCORE(dpaa_io) = false;
371 }
372
373 static int
374 rte_dpaa_bus_parse(const char *name, void *out_name)
375 {
376         int i, j;
377         int max_fman = 2, max_macs = 16;
378         char *dup_name;
379         char *sep = NULL;
380
381         /* There are two ways of passing device name, with and without
382          * separator. "dpaa_bus:fm1-mac3" with separator, and "fm1-mac3"
383          * without separator. Both need to be handled.
384          * It is also possible that "name=fm1-mac3" is passed along.
385          */
386         DPAA_BUS_DEBUG("Parse device name (%s)", name);
387
388         /* Check for dpaa_bus:fm1-mac3 style */
389         dup_name = strdup(name);
390         sep = strchr(dup_name, ':');
391         if (!sep)
392                 /* If not, check for name=fm1-mac3 style */
393                 sep = strchr(dup_name, '=');
394
395         if (sep)
396                 /* jump over the seprator */
397                 sep = (char *) (sep + 1);
398         else
399                 sep = dup_name;
400
401         for (i = 0; i < max_fman; i++) {
402                 for (j = 0; j < max_macs; j++) {
403                         char fm_name[16];
404                         snprintf(fm_name, 16, "fm%d-mac%d", i, j);
405                         if (strcmp(fm_name, sep) == 0) {
406                                 if (out_name)
407                                         strcpy(out_name, sep);
408                                 free(dup_name);
409                                 return 0;
410                         }
411                 }
412         }
413
414         for (i = 0; i < RTE_LIBRTE_DPAA_MAX_CRYPTODEV; i++) {
415                 char sec_name[16];
416
417                 snprintf(sec_name, 16, "dpaa_sec-%d", i+1);
418                 if (strcmp(sec_name, sep) == 0) {
419                         if (out_name)
420                                 strcpy(out_name, sep);
421                         free(dup_name);
422                         return 0;
423                 }
424         }
425
426         free(dup_name);
427         return -EINVAL;
428 }
429
430 #define DPAA_DEV_PATH1 "/sys/devices/platform/soc/soc:fsl,dpaa"
431 #define DPAA_DEV_PATH2 "/sys/devices/platform/fsl,dpaa"
432
433 static int
434 rte_dpaa_bus_scan(void)
435 {
436         int ret;
437
438         BUS_INIT_FUNC_TRACE();
439
440         if ((access(DPAA_DEV_PATH1, F_OK) != 0) &&
441             (access(DPAA_DEV_PATH2, F_OK) != 0)) {
442                 RTE_LOG(DEBUG, EAL, "DPAA Bus not present. Skipping.\n");
443                 return 0;
444         }
445
446         if (rte_dpaa_bus.detected)
447                 return 0;
448
449         rte_dpaa_bus.detected = 1;
450
451         /* create the key, supplying a function that'll be invoked
452          * when a portal affined thread will be deleted.
453          */
454         ret = pthread_key_create(&dpaa_portal_key, dpaa_portal_finish);
455         if (ret) {
456                 DPAA_BUS_LOG(DEBUG, "Unable to create pthread key. (%d)", ret);
457                 dpaa_clean_device_list();
458                 return ret;
459         }
460
461         return 0;
462 }
463
464 /* register a dpaa bus based dpaa driver */
465 void
466 rte_dpaa_driver_register(struct rte_dpaa_driver *driver)
467 {
468         RTE_VERIFY(driver);
469
470         BUS_INIT_FUNC_TRACE();
471
472         TAILQ_INSERT_TAIL(&rte_dpaa_bus.driver_list, driver, next);
473         /* Update Bus references */
474         driver->dpaa_bus = &rte_dpaa_bus;
475 }
476
477 /* un-register a dpaa bus based dpaa driver */
478 void
479 rte_dpaa_driver_unregister(struct rte_dpaa_driver *driver)
480 {
481         struct rte_dpaa_bus *dpaa_bus;
482
483         BUS_INIT_FUNC_TRACE();
484
485         dpaa_bus = driver->dpaa_bus;
486
487         TAILQ_REMOVE(&dpaa_bus->driver_list, driver, next);
488         /* Update Bus references */
489         driver->dpaa_bus = NULL;
490 }
491
492 static int
493 rte_dpaa_device_match(struct rte_dpaa_driver *drv,
494                       struct rte_dpaa_device *dev)
495 {
496         if (!drv || !dev) {
497                 DPAA_BUS_DEBUG("Invalid drv or dev received.");
498                 return -1;
499         }
500
501         if (drv->drv_type == dev->device_type)
502                 return 0;
503
504         return -1;
505 }
506
507 static int
508 rte_dpaa_bus_dev_build(void)
509 {
510         int ret;
511
512         /* Load the device-tree driver */
513         ret = of_init();
514         if (ret) {
515                 DPAA_BUS_LOG(ERR, "of_init failed with ret: %d", ret);
516                 return -1;
517         }
518
519         /* Get the interface configurations from device-tree */
520         dpaa_netcfg = netcfg_acquire();
521         if (!dpaa_netcfg) {
522                 DPAA_BUS_LOG(ERR, "netcfg_acquire failed");
523                 return -EINVAL;
524         }
525
526         RTE_LOG(NOTICE, EAL, "DPAA Bus Detected\n");
527
528         if (!dpaa_netcfg->num_ethports) {
529                 DPAA_BUS_LOG(INFO, "no network interfaces available");
530                 /* This is not an error */
531                 return 0;
532         }
533
534 #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
535         dump_netcfg(dpaa_netcfg);
536 #endif
537
538         DPAA_BUS_LOG(DEBUG, "Number of ethernet devices = %d",
539                      dpaa_netcfg->num_ethports);
540         ret = dpaa_create_device_list();
541         if (ret) {
542                 DPAA_BUS_LOG(ERR, "Unable to create device list. (%d)", ret);
543                 return ret;
544         }
545         return 0;
546 }
547
548 static int
549 rte_dpaa_bus_probe(void)
550 {
551         int ret = -1;
552         struct rte_dpaa_device *dev;
553         struct rte_dpaa_driver *drv;
554         FILE *svr_file = NULL;
555         unsigned int svr_ver;
556         int probe_all = rte_dpaa_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST;
557         static int process_once;
558
559         /* If DPAA bus is not present nothing needs to be done */
560         if (!rte_dpaa_bus.detected)
561                 return 0;
562
563         /* Device list creation is only done once */
564         if (!process_once) {
565                 rte_dpaa_bus_dev_build();
566                 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
567                         /* One time load of Qman/Bman drivers */
568                         ret = qman_global_init();
569                         if (ret) {
570                                 DPAA_PMD_ERR("QMAN initialization failed: %d",
571                                              ret);
572                                 return ret;
573                         }
574                         ret = bman_global_init();
575                         if (ret) {
576                                 DPAA_PMD_ERR("BMAN initialization failed: %d",
577                                              ret);
578                                 return ret;
579                         }
580                 }
581         }
582         process_once = 1;
583
584         /* If no device present on DPAA bus nothing needs to be done */
585         if (TAILQ_EMPTY(&rte_dpaa_bus.device_list))
586                 return 0;
587
588         svr_file = fopen(DPAA_SOC_ID_FILE, "r");
589         if (svr_file) {
590                 if (fscanf(svr_file, "svr:%x", &svr_ver) > 0)
591                         dpaa_svr_family = svr_ver & SVR_MASK;
592                 fclose(svr_file);
593         }
594
595         /* And initialize the PA->VA translation table */
596         dpaax_iova_table_populate();
597
598         /* For each registered driver, and device, call the driver->probe */
599         TAILQ_FOREACH(dev, &rte_dpaa_bus.device_list, next) {
600                 TAILQ_FOREACH(drv, &rte_dpaa_bus.driver_list, next) {
601                         ret = rte_dpaa_device_match(drv, dev);
602                         if (ret)
603                                 continue;
604
605                         if (rte_dev_is_probed(&dev->device))
606                                 continue;
607
608                         if (!drv->probe ||
609                             (dev->device.devargs &&
610                             dev->device.devargs->policy == RTE_DEV_BLACKLISTED))
611                                 continue;
612
613                         if (probe_all ||
614                             (dev->device.devargs &&
615                             dev->device.devargs->policy ==
616                             RTE_DEV_WHITELISTED)) {
617                                 ret = drv->probe(drv, dev);
618                                 if (ret) {
619                                         DPAA_BUS_ERR("unable to probe:%s",
620                                                      dev->name);
621                                 } else {
622                                         dev->driver = drv;
623                                         dev->device.driver = &drv->driver;
624                                 }
625                         }
626                         break;
627                 }
628         }
629
630         /* Register DPAA mempool ops only if any DPAA device has
631          * been detected.
632          */
633         rte_mbuf_set_platform_mempool_ops(DPAA_MEMPOOL_OPS_NAME);
634
635         return 0;
636 }
637
638 static struct rte_device *
639 rte_dpaa_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
640                      const void *data)
641 {
642         struct rte_dpaa_device *dev;
643         const struct rte_dpaa_device *dstart;
644
645         /* find_device is called with 'data' as an opaque object - just call
646          * cmp with this and each device object on bus.
647          */
648
649         if (start != NULL) {
650                 dstart = RTE_DEV_TO_DPAA_CONST(start);
651                 dev = TAILQ_NEXT(dstart, next);
652         } else {
653                 dev = TAILQ_FIRST(&rte_dpaa_bus.device_list);
654         }
655
656         while (dev != NULL) {
657                 if (cmp(&dev->device, data) == 0) {
658                         DPAA_BUS_DEBUG("Found dev=(%s)\n", dev->device.name);
659                         return &dev->device;
660                 }
661                 dev = TAILQ_NEXT(dev, next);
662         }
663
664         DPAA_BUS_DEBUG("Unable to find any device\n");
665         return NULL;
666 }
667
668 /*
669  * Get iommu class of DPAA2 devices on the bus.
670  */
671 static enum rte_iova_mode
672 rte_dpaa_get_iommu_class(void)
673 {
674         if ((access(DPAA_DEV_PATH1, F_OK) != 0) &&
675             (access(DPAA_DEV_PATH2, F_OK) != 0)) {
676                 return RTE_IOVA_DC;
677         }
678         return RTE_IOVA_PA;
679 }
680
681 static int
682 dpaa_bus_plug(struct rte_device *dev __rte_unused)
683 {
684         /* No operation is performed while plugging the device */
685         return 0;
686 }
687
688 static int
689 dpaa_bus_unplug(struct rte_device *dev __rte_unused)
690 {
691         /* No operation is performed while unplugging the device */
692         return 0;
693 }
694
695 static void *
696 dpaa_bus_dev_iterate(const void *start, const char *str,
697                      const struct rte_dev_iterator *it __rte_unused)
698 {
699         const struct rte_dpaa_device *dstart;
700         struct rte_dpaa_device *dev;
701         char *dup, *dev_name = NULL;
702
703         /* Expectation is that device would be name=device_name */
704         if (strncmp(str, "name=", 5) != 0) {
705                 DPAA_BUS_DEBUG("Invalid device string (%s)\n", str);
706                 return NULL;
707         }
708
709         /* Now that name=device_name format is available, split */
710         dup = strdup(str);
711         dev_name = dup + strlen("name=");
712
713         if (start != NULL) {
714                 dstart = RTE_DEV_TO_DPAA_CONST(start);
715                 dev = TAILQ_NEXT(dstart, next);
716         } else {
717                 dev = TAILQ_FIRST(&rte_dpaa_bus.device_list);
718         }
719
720         while (dev != NULL) {
721                 if (strcmp(dev->device.name, dev_name) == 0) {
722                         free(dup);
723                         return &dev->device;
724                 }
725                 dev = TAILQ_NEXT(dev, next);
726         }
727
728         free(dup);
729         return NULL;
730 }
731
732 static struct rte_dpaa_bus rte_dpaa_bus = {
733         .bus = {
734                 .scan = rte_dpaa_bus_scan,
735                 .probe = rte_dpaa_bus_probe,
736                 .parse = rte_dpaa_bus_parse,
737                 .find_device = rte_dpaa_find_device,
738                 .get_iommu_class = rte_dpaa_get_iommu_class,
739                 .plug = dpaa_bus_plug,
740                 .unplug = dpaa_bus_unplug,
741                 .dev_iterate = dpaa_bus_dev_iterate,
742         },
743         .device_list = TAILQ_HEAD_INITIALIZER(rte_dpaa_bus.device_list),
744         .driver_list = TAILQ_HEAD_INITIALIZER(rte_dpaa_bus.driver_list),
745         .device_count = 0,
746 };
747
748 RTE_REGISTER_BUS(FSL_DPAA_BUS_NAME, rte_dpaa_bus.bus);
749
750 RTE_INIT(dpaa_init_log)
751 {
752         dpaa_logtype_bus = rte_log_register("bus.dpaa");
753         if (dpaa_logtype_bus >= 0)
754                 rte_log_set_level(dpaa_logtype_bus, RTE_LOG_NOTICE);
755
756         dpaa_logtype_mempool = rte_log_register("mempool.dpaa");
757         if (dpaa_logtype_mempool >= 0)
758                 rte_log_set_level(dpaa_logtype_mempool, RTE_LOG_NOTICE);
759
760         dpaa_logtype_pmd = rte_log_register("pmd.net.dpaa");
761         if (dpaa_logtype_pmd >= 0)
762                 rte_log_set_level(dpaa_logtype_pmd, RTE_LOG_NOTICE);
763
764         dpaa_logtype_eventdev = rte_log_register("pmd.event.dpaa");
765         if (dpaa_logtype_eventdev >= 0)
766                 rte_log_set_level(dpaa_logtype_eventdev, RTE_LOG_NOTICE);
767 }