xref: /dpdk/drivers/bus/dpaa/dpaa_bus.c (revision 089e5ed727a15da2729cfee9b63533dd120bd04c)
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 <rte_dpaa_bus.h>
36 #include <rte_dpaa_logs.h>
37 #include <dpaax_iova_table.h>
38 
39 #include <fsl_usd.h>
40 #include <fsl_qman.h>
41 #include <fsl_bman.h>
42 #include <of.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);
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 	pthread_t id;
254 	unsigned int cpu, lcore = rte_lcore_id();
255 	int ret;
256 	struct dpaa_portal *dpaa_io_portal;
257 	rte_cpuset_t cpuset;
258 
259 	BUS_INIT_FUNC_TRACE();
260 
261 	if ((size_t)arg == 1 || lcore == LCORE_ID_ANY)
262 		lcore = rte_get_master_lcore();
263 	else
264 		if (lcore >= RTE_MAX_LCORE)
265 			return -1;
266 
267 	cpu = rte_lcore_to_cpu_id(lcore);
268 
269 	/* Set CPU affinity for this thread.*/
270 	id = pthread_self();
271 	cpuset = rte_lcore_cpuset(lcore);
272 	ret = pthread_setaffinity_np(id, sizeof(cpu_set_t),
273 				     &cpuset);
274 	if (ret) {
275 		DPAA_BUS_LOG(ERR, "pthread_setaffinity_np failed on core :%u"
276 			     " (lcore=%u) with ret: %d", cpu, lcore, ret);
277 		return ret;
278 	}
279 
280 	/* Initialise bman thread portals */
281 	ret = bman_thread_init();
282 	if (ret) {
283 		DPAA_BUS_LOG(ERR, "bman_thread_init failed on core %u"
284 			     " (lcore=%u) with ret: %d", cpu, lcore, ret);
285 		return ret;
286 	}
287 
288 	DPAA_BUS_LOG(DEBUG, "BMAN thread initialized - CPU=%d lcore=%d",
289 		     cpu, lcore);
290 
291 	/* Initialise qman thread portals */
292 	ret = qman_thread_init();
293 	if (ret) {
294 		DPAA_BUS_LOG(ERR, "qman_thread_init failed on core %u"
295 			    " (lcore=%u) with ret: %d", cpu, lcore, ret);
296 		bman_thread_finish();
297 		return ret;
298 	}
299 
300 	DPAA_BUS_LOG(DEBUG, "QMAN thread initialized - CPU=%d lcore=%d",
301 		     cpu, lcore);
302 
303 	dpaa_io_portal = rte_malloc(NULL, sizeof(struct dpaa_portal),
304 				    RTE_CACHE_LINE_SIZE);
305 	if (!dpaa_io_portal) {
306 		DPAA_BUS_LOG(ERR, "Unable to allocate memory");
307 		bman_thread_finish();
308 		qman_thread_finish();
309 		return -ENOMEM;
310 	}
311 
312 	dpaa_io_portal->qman_idx = qman_get_portal_index();
313 	dpaa_io_portal->bman_idx = bman_get_portal_index();
314 	dpaa_io_portal->tid = syscall(SYS_gettid);
315 
316 	ret = pthread_setspecific(dpaa_portal_key, (void *)dpaa_io_portal);
317 	if (ret) {
318 		DPAA_BUS_LOG(ERR, "pthread_setspecific failed on core %u"
319 			     " (lcore=%u) with ret: %d", cpu, lcore, ret);
320 		dpaa_portal_finish(NULL);
321 
322 		return ret;
323 	}
324 
325 	RTE_PER_LCORE(dpaa_io) = true;
326 
327 	DPAA_BUS_LOG(DEBUG, "QMAN thread initialized");
328 
329 	return 0;
330 }
331 
332 int
333 rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq)
334 {
335 	/* Affine above created portal with channel*/
336 	u32 sdqcr;
337 	struct qman_portal *qp;
338 	int ret;
339 
340 	if (unlikely(!RTE_PER_LCORE(dpaa_io))) {
341 		ret = rte_dpaa_portal_init(arg);
342 		if (ret < 0) {
343 			DPAA_BUS_LOG(ERR, "portal initialization failure");
344 			return ret;
345 		}
346 	}
347 
348 	/* Initialise qman specific portals */
349 	qp = fsl_qman_portal_create();
350 	if (!qp) {
351 		DPAA_BUS_LOG(ERR, "Unable to alloc fq portal");
352 		return -1;
353 	}
354 	fq->qp = qp;
355 	sdqcr = QM_SDQCR_CHANNELS_POOL_CONV(fq->ch_id);
356 	qman_static_dequeue_add(sdqcr, qp);
357 
358 	return 0;
359 }
360 
361 int rte_dpaa_portal_fq_close(struct qman_fq *fq)
362 {
363 	return fsl_qman_portal_destroy(fq->qp);
364 }
365 
366 void
367 dpaa_portal_finish(void *arg)
368 {
369 	struct dpaa_portal *dpaa_io_portal = (struct dpaa_portal *)arg;
370 
371 	if (!dpaa_io_portal) {
372 		DPAA_BUS_LOG(DEBUG, "Portal already cleaned");
373 		return;
374 	}
375 
376 	bman_thread_finish();
377 	qman_thread_finish();
378 
379 	pthread_setspecific(dpaa_portal_key, NULL);
380 
381 	rte_free(dpaa_io_portal);
382 	dpaa_io_portal = NULL;
383 
384 	RTE_PER_LCORE(dpaa_io) = false;
385 }
386 
387 static int
388 rte_dpaa_bus_parse(const char *name, void *out_name)
389 {
390 	int i, j;
391 	int max_fman = 2, max_macs = 16;
392 	char *dup_name;
393 	char *sep = NULL;
394 
395 	/* There are two ways of passing device name, with and without
396 	 * separator. "dpaa_bus:fm1-mac3" with separator, and "fm1-mac3"
397 	 * without separator. Both need to be handled.
398 	 * It is also possible that "name=fm1-mac3" is passed along.
399 	 */
400 	DPAA_BUS_DEBUG("Parse device name (%s)\n", name);
401 
402 	/* Check for dpaa_bus:fm1-mac3 style */
403 	dup_name = strdup(name);
404 	sep = strchr(dup_name, ':');
405 	if (!sep)
406 		/* If not, check for name=fm1-mac3 style */
407 		sep = strchr(dup_name, '=');
408 
409 	if (sep)
410 		/* jump over the seprator */
411 		sep = (char *) (sep + 1);
412 	else
413 		sep = dup_name;
414 
415 	for (i = 0; i < max_fman; i++) {
416 		for (j = 0; j < max_macs; j++) {
417 			char fm_name[16];
418 			snprintf(fm_name, 16, "fm%d-mac%d", i, j);
419 			if (strcmp(fm_name, sep) == 0) {
420 				if (out_name)
421 					strcpy(out_name, sep);
422 				free(dup_name);
423 				return 0;
424 			}
425 		}
426 	}
427 
428 	for (i = 0; i < RTE_LIBRTE_DPAA_MAX_CRYPTODEV; i++) {
429 		char sec_name[16];
430 
431 		snprintf(sec_name, 16, "dpaa-sec%d", i);
432 		if (strcmp(sec_name, sep) == 0) {
433 			if (out_name)
434 				strcpy(out_name, sep);
435 			free(dup_name);
436 			return 0;
437 		}
438 	}
439 
440 	free(dup_name);
441 	return -EINVAL;
442 }
443 
444 #define DPAA_DEV_PATH1 "/sys/devices/platform/soc/soc:fsl,dpaa"
445 #define DPAA_DEV_PATH2 "/sys/devices/platform/fsl,dpaa"
446 
447 static int
448 rte_dpaa_bus_scan(void)
449 {
450 	int ret;
451 
452 	BUS_INIT_FUNC_TRACE();
453 
454 	if ((access(DPAA_DEV_PATH1, F_OK) != 0) &&
455 	    (access(DPAA_DEV_PATH2, F_OK) != 0)) {
456 		RTE_LOG(DEBUG, EAL, "DPAA Bus not present. Skipping.\n");
457 		return 0;
458 	}
459 
460 	if (rte_dpaa_bus.detected)
461 		return 0;
462 
463 	rte_dpaa_bus.detected = 1;
464 
465 	/* create the key, supplying a function that'll be invoked
466 	 * when a portal affined thread will be deleted.
467 	 */
468 	ret = pthread_key_create(&dpaa_portal_key, dpaa_portal_finish);
469 	if (ret) {
470 		DPAA_BUS_LOG(DEBUG, "Unable to create pthread key. (%d)", ret);
471 		dpaa_clean_device_list();
472 		return ret;
473 	}
474 
475 	return 0;
476 }
477 
478 /* register a dpaa bus based dpaa driver */
479 void
480 rte_dpaa_driver_register(struct rte_dpaa_driver *driver)
481 {
482 	RTE_VERIFY(driver);
483 
484 	BUS_INIT_FUNC_TRACE();
485 
486 	TAILQ_INSERT_TAIL(&rte_dpaa_bus.driver_list, driver, next);
487 	/* Update Bus references */
488 	driver->dpaa_bus = &rte_dpaa_bus;
489 }
490 
491 /* un-register a dpaa bus based dpaa driver */
492 void
493 rte_dpaa_driver_unregister(struct rte_dpaa_driver *driver)
494 {
495 	struct rte_dpaa_bus *dpaa_bus;
496 
497 	BUS_INIT_FUNC_TRACE();
498 
499 	dpaa_bus = driver->dpaa_bus;
500 
501 	TAILQ_REMOVE(&dpaa_bus->driver_list, driver, next);
502 	/* Update Bus references */
503 	driver->dpaa_bus = NULL;
504 }
505 
506 static int
507 rte_dpaa_device_match(struct rte_dpaa_driver *drv,
508 		      struct rte_dpaa_device *dev)
509 {
510 	if (!drv || !dev) {
511 		DPAA_BUS_DEBUG("Invalid drv or dev received.");
512 		return -1;
513 	}
514 
515 	if (drv->drv_type == dev->device_type)
516 		return 0;
517 
518 	return -1;
519 }
520 
521 static int
522 rte_dpaa_bus_dev_build(void)
523 {
524 	int ret;
525 
526 	/* Load the device-tree driver */
527 	ret = of_init();
528 	if (ret) {
529 		DPAA_BUS_LOG(ERR, "of_init failed with ret: %d", ret);
530 		return -1;
531 	}
532 
533 	/* Get the interface configurations from device-tree */
534 	dpaa_netcfg = netcfg_acquire();
535 	if (!dpaa_netcfg) {
536 		DPAA_BUS_LOG(ERR, "netcfg_acquire failed");
537 		return -EINVAL;
538 	}
539 
540 	RTE_LOG(NOTICE, EAL, "DPAA Bus Detected\n");
541 
542 	if (!dpaa_netcfg->num_ethports) {
543 		DPAA_BUS_LOG(INFO, "no network interfaces available");
544 		/* This is not an error */
545 		return 0;
546 	}
547 
548 #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
549 	dump_netcfg(dpaa_netcfg);
550 #endif
551 
552 	DPAA_BUS_LOG(DEBUG, "Number of ethernet devices = %d",
553 		     dpaa_netcfg->num_ethports);
554 	ret = dpaa_create_device_list();
555 	if (ret) {
556 		DPAA_BUS_LOG(ERR, "Unable to create device list. (%d)", ret);
557 		return ret;
558 	}
559 	return 0;
560 }
561 
562 static int
563 rte_dpaa_bus_probe(void)
564 {
565 	int ret = -1;
566 	struct rte_dpaa_device *dev;
567 	struct rte_dpaa_driver *drv;
568 	FILE *svr_file = NULL;
569 	unsigned int svr_ver;
570 	int probe_all = rte_dpaa_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST;
571 	static int process_once;
572 
573 	/* If DPAA bus is not present nothing needs to be done */
574 	if (!rte_dpaa_bus.detected)
575 		return 0;
576 
577 	/* Device list creation is only done once */
578 	if (!process_once)
579 		rte_dpaa_bus_dev_build();
580 	process_once = 1;
581 
582 	/* If no device present on DPAA bus nothing needs to be done */
583 	if (TAILQ_EMPTY(&rte_dpaa_bus.device_list))
584 		return 0;
585 
586 	svr_file = fopen(DPAA_SOC_ID_FILE, "r");
587 	if (svr_file) {
588 		if (fscanf(svr_file, "svr:%x", &svr_ver) > 0)
589 			dpaa_svr_family = svr_ver & SVR_MASK;
590 		fclose(svr_file);
591 	}
592 
593 	/* And initialize the PA->VA translation table */
594 	dpaax_iova_table_populate();
595 
596 	/* For each registered driver, and device, call the driver->probe */
597 	TAILQ_FOREACH(dev, &rte_dpaa_bus.device_list, next) {
598 		TAILQ_FOREACH(drv, &rte_dpaa_bus.driver_list, next) {
599 			ret = rte_dpaa_device_match(drv, dev);
600 			if (ret)
601 				continue;
602 
603 			if (rte_dev_is_probed(&dev->device))
604 				continue;
605 
606 			if (!drv->probe ||
607 			    (dev->device.devargs &&
608 			    dev->device.devargs->policy == RTE_DEV_BLACKLISTED))
609 				continue;
610 
611 			if (probe_all ||
612 			    (dev->device.devargs &&
613 			    dev->device.devargs->policy ==
614 			    RTE_DEV_WHITELISTED)) {
615 				ret = drv->probe(drv, dev);
616 				if (ret) {
617 					DPAA_BUS_ERR("Unable to probe.\n");
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 	/* Expectation is that device would be name=device_name */
701 	if (strncmp(str, "name=", 5) != 0) {
702 		DPAA_BUS_DEBUG("Invalid device string (%s)\n", str);
703 		return NULL;
704 	}
705 
706 	/* Now that name=device_name format is available, split */
707 	dup = strdup(str);
708 	dev_name = dup + strlen("name=");
709 
710 	if (start != NULL) {
711 		dstart = RTE_DEV_TO_DPAA_CONST(start);
712 		dev = TAILQ_NEXT(dstart, next);
713 	} else {
714 		dev = TAILQ_FIRST(&rte_dpaa_bus.device_list);
715 	}
716 
717 	while (dev != NULL) {
718 		if (strcmp(dev->device.name, dev_name) == 0) {
719 			free(dup);
720 			return &dev->device;
721 		}
722 		dev = TAILQ_NEXT(dev, next);
723 	}
724 
725 	free(dup);
726 	return NULL;
727 }
728 
729 static struct rte_dpaa_bus rte_dpaa_bus = {
730 	.bus = {
731 		.scan = rte_dpaa_bus_scan,
732 		.probe = rte_dpaa_bus_probe,
733 		.parse = rte_dpaa_bus_parse,
734 		.find_device = rte_dpaa_find_device,
735 		.get_iommu_class = rte_dpaa_get_iommu_class,
736 		.plug = dpaa_bus_plug,
737 		.unplug = dpaa_bus_unplug,
738 		.dev_iterate = dpaa_bus_dev_iterate,
739 	},
740 	.device_list = TAILQ_HEAD_INITIALIZER(rte_dpaa_bus.device_list),
741 	.driver_list = TAILQ_HEAD_INITIALIZER(rte_dpaa_bus.driver_list),
742 	.device_count = 0,
743 };
744 
745 RTE_REGISTER_BUS(FSL_DPAA_BUS_NAME, rte_dpaa_bus.bus);
746 
747 RTE_INIT(dpaa_init_log)
748 {
749 	dpaa_logtype_bus = rte_log_register("bus.dpaa");
750 	if (dpaa_logtype_bus >= 0)
751 		rte_log_set_level(dpaa_logtype_bus, RTE_LOG_NOTICE);
752 
753 	dpaa_logtype_mempool = rte_log_register("mempool.dpaa");
754 	if (dpaa_logtype_mempool >= 0)
755 		rte_log_set_level(dpaa_logtype_mempool, RTE_LOG_NOTICE);
756 
757 	dpaa_logtype_pmd = rte_log_register("pmd.net.dpaa");
758 	if (dpaa_logtype_pmd >= 0)
759 		rte_log_set_level(dpaa_logtype_pmd, RTE_LOG_NOTICE);
760 
761 	dpaa_logtype_eventdev = rte_log_register("pmd.event.dpaa");
762 	if (dpaa_logtype_eventdev >= 0)
763 		rte_log_set_level(dpaa_logtype_eventdev, RTE_LOG_NOTICE);
764 }
765