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.
32 #ifndef __RTE_DPAA_BUS_H__
33 #define __RTE_DPAA_BUS_H__
36 #include <rte_mempool.h>
38 #define FSL_DPAA_BUS_NAME "FSL_DPAA_BUS"
40 #define DEV_TO_DPAA_DEVICE(ptr) \
41 container_of(ptr, struct rte_dpaa_device, device)
43 struct rte_dpaa_device;
44 struct rte_dpaa_driver;
46 /* DPAA Device and Driver lists for DPAA bus */
47 TAILQ_HEAD(rte_dpaa_device_list, rte_dpaa_device);
48 TAILQ_HEAD(rte_dpaa_driver_list, rte_dpaa_driver);
57 struct rte_dpaa_device_list device_list;
58 struct rte_dpaa_driver_list driver_list;
62 struct dpaa_device_id {
63 uint8_t fman_id; /**< Fman interface ID, for ETH type device */
64 uint8_t mac_id; /**< Fman MAC interface ID, for ETH type device */
65 uint16_t dev_id; /**< Device Identifier from DPDK */
68 struct rte_dpaa_device {
69 TAILQ_ENTRY(rte_dpaa_device) next;
70 struct rte_device device;
72 struct rte_eth_dev *eth_dev;
73 struct rte_cryptodev *crypto_dev;
75 struct rte_dpaa_driver *driver;
76 struct dpaa_device_id id;
77 enum rte_dpaa_type device_type; /**< Ethernet or crypto type device */
78 char name[RTE_ETH_NAME_MAX_LEN];
81 typedef int (*rte_dpaa_probe_t)(struct rte_dpaa_driver *dpaa_drv,
82 struct rte_dpaa_device *dpaa_dev);
83 typedef int (*rte_dpaa_remove_t)(struct rte_dpaa_device *dpaa_dev);
85 struct rte_dpaa_driver {
86 TAILQ_ENTRY(rte_dpaa_driver) next;
87 struct rte_driver driver;
88 struct rte_dpaa_bus *dpaa_bus;
89 enum rte_dpaa_type drv_type;
90 rte_dpaa_probe_t probe;
91 rte_dpaa_remove_t remove;
95 uint32_t bman_idx; /**< BMAN Portal ID*/
96 uint32_t qman_idx; /**< QMAN Portal ID*/
97 uint64_t tid;/**< Parent Thread id for this portal */
100 /* TODO - this is costly, need to write a fast coversion routine */
101 static inline void *rte_dpaa_mem_ptov(phys_addr_t paddr)
103 const struct rte_memseg *memseg = rte_eal_get_physmem_layout();
106 for (i = 0; i < RTE_MAX_MEMSEG && memseg[i].addr != NULL; i++) {
107 if (paddr >= memseg[i].phys_addr && paddr <
108 memseg[i].phys_addr + memseg[i].len)
109 return (uint8_t *)(memseg[i].addr) +
110 (paddr - memseg[i].phys_addr);
117 * Register a DPAA driver.
120 * A pointer to a rte_dpaa_driver structure describing the driver
123 void rte_dpaa_driver_register(struct rte_dpaa_driver *driver);
126 * Unregister a DPAA driver.
129 * A pointer to a rte_dpaa_driver structure describing the driver
130 * to be unregistered.
132 void rte_dpaa_driver_unregister(struct rte_dpaa_driver *driver);
134 /** Helper for DPAA device registration from driver (eth, crypto) instance */
135 #define RTE_PMD_REGISTER_DPAA(nm, dpaa_drv) \
136 RTE_INIT(dpaainitfn_ ##nm); \
137 static void dpaainitfn_ ##nm(void) \
139 (dpaa_drv).driver.name = RTE_STR(nm);\
140 rte_dpaa_driver_register(&dpaa_drv); \
142 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
148 #endif /* __RTE_DPAA_BUS_H__ */