6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of NXP nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 #include <sys/types.h>
41 #include <sys/syscall.h>
43 #include <rte_config.h>
44 #include <rte_byteorder.h>
45 #include <rte_common.h>
46 #include <rte_interrupts.h>
48 #include <rte_debug.h>
50 #include <rte_atomic.h>
51 #include <rte_branch_prediction.h>
52 #include <rte_memory.h>
53 #include <rte_memzone.h>
54 #include <rte_tailq.h>
56 #include <rte_alarm.h>
57 #include <rte_ether.h>
58 #include <rte_ethdev.h>
59 #include <rte_malloc.h>
63 #include <rte_dpaa_bus.h>
64 #include <rte_dpaa_logs.h>
68 struct rte_dpaa_bus rte_dpaa_bus;
71 dpaa_add_to_device_list(struct rte_dpaa_device *dev)
73 TAILQ_INSERT_TAIL(&rte_dpaa_bus.device_list, dev, next);
77 dpaa_remove_from_device_list(struct rte_dpaa_device *dev)
79 TAILQ_INSERT_TAIL(&rte_dpaa_bus.device_list, dev, next);
83 rte_dpaa_bus_scan(void)
85 BUS_INIT_FUNC_TRACE();
90 /* register a dpaa bus based dpaa driver */
92 rte_dpaa_driver_register(struct rte_dpaa_driver *driver)
96 BUS_INIT_FUNC_TRACE();
98 TAILQ_INSERT_TAIL(&rte_dpaa_bus.driver_list, driver, next);
99 /* Update Bus references */
100 driver->dpaa_bus = &rte_dpaa_bus;
103 /* un-register a dpaa bus based dpaa driver */
105 rte_dpaa_driver_unregister(struct rte_dpaa_driver *driver)
107 struct rte_dpaa_bus *dpaa_bus;
109 BUS_INIT_FUNC_TRACE();
111 dpaa_bus = driver->dpaa_bus;
113 TAILQ_REMOVE(&dpaa_bus->driver_list, driver, next);
114 /* Update Bus references */
115 driver->dpaa_bus = NULL;
119 rte_dpaa_device_match(struct rte_dpaa_driver *drv,
120 struct rte_dpaa_device *dev)
124 BUS_INIT_FUNC_TRACE();
127 DPAA_BUS_DEBUG("Invalid drv or dev received.");
131 if (drv->drv_type == dev->device_type) {
132 DPAA_BUS_INFO("Device: %s matches for driver: %s",
133 dev->name, drv->driver.name);
134 ret = 0; /* Found a match */
141 rte_dpaa_bus_probe(void)
144 struct rte_dpaa_device *dev;
145 struct rte_dpaa_driver *drv;
147 BUS_INIT_FUNC_TRACE();
149 /* For each registered driver, and device, call the driver->probe */
150 TAILQ_FOREACH(dev, &rte_dpaa_bus.device_list, next) {
151 TAILQ_FOREACH(drv, &rte_dpaa_bus.driver_list, next) {
152 ret = rte_dpaa_device_match(drv, dev);
159 ret = drv->probe(drv, dev);
161 DPAA_BUS_ERR("Unable to probe.\n");
168 static struct rte_device *
169 rte_dpaa_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
172 struct rte_dpaa_device *dev;
174 TAILQ_FOREACH(dev, &rte_dpaa_bus.device_list, next) {
175 if (start && &dev->device == start) {
176 start = NULL; /* starting point found */
180 if (cmp(&dev->device, data) == 0)
187 struct rte_dpaa_bus rte_dpaa_bus = {
189 .scan = rte_dpaa_bus_scan,
190 .probe = rte_dpaa_bus_probe,
191 .find_device = rte_dpaa_find_device,
193 .device_list = TAILQ_HEAD_INITIALIZER(rte_dpaa_bus.device_list),
194 .driver_list = TAILQ_HEAD_INITIALIZER(rte_dpaa_bus.driver_list),
198 RTE_REGISTER_BUS(FSL_DPAA_BUS_NAME, rte_dpaa_bus.bus);
200 RTE_INIT(dpaa_init_log);
204 dpaa_logtype_bus = rte_log_register("bus.dpaa");
205 if (dpaa_logtype_bus >= 0)
206 rte_log_set_level(dpaa_logtype_bus, RTE_LOG_NOTICE);