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.
39 * RTE FSLMC Bus Interface
50 #include <sys/queue.h>
54 #include <rte_debug.h>
55 #include <rte_interrupts.h>
59 #define FSLMC_OBJECT_MAX_LEN 32 /**< Length of each device on bus */
61 struct rte_dpaa2_driver;
63 /* DPAA2 Device and Driver lists for FSLMC bus */
64 TAILQ_HEAD(rte_fslmc_device_list, rte_dpaa2_device);
65 TAILQ_HEAD(rte_fslmc_driver_list, rte_dpaa2_driver);
67 extern struct rte_fslmc_bus rte_fslmc_bus;
69 enum rte_dpaa2_dev_type {
70 /* Devices backed by DPDK driver */
71 DPAA2_ETH, /**< DPNI type device*/
72 DPAA2_CRYPTO, /**< DPSECI type device */
73 DPAA2_CON, /**< DPCONC type device */
74 /* Devices not backed by a DPDK driver: DPIO, DPBP, DPCI, DPMCP */
75 DPAA2_BPOOL, /**< DPBP type device */
76 DPAA2_IO, /**< DPIO type device */
77 DPAA2_CI, /**< DPCI type device */
78 DPAA2_MPORTAL, /**< DPMCP type device */
79 /* Unknown device placeholder */
84 * A structure describing a DPAA2 device.
86 struct rte_dpaa2_device {
87 TAILQ_ENTRY(rte_dpaa2_device) next; /**< Next probed DPAA2 device. */
88 struct rte_device device; /**< Inherit core device */
90 struct rte_eth_dev *eth_dev; /**< ethernet device */
91 struct rte_cryptodev *cryptodev; /**< Crypto Device */
93 enum rte_dpaa2_dev_type dev_type; /**< Device Type */
94 uint16_t object_id; /**< DPAA2 Object ID */
95 struct rte_intr_handle intr_handle; /**< Interrupt handle */
96 struct rte_dpaa2_driver *driver; /**< Associated driver */
97 char name[FSLMC_OBJECT_MAX_LEN]; /**< DPAA2 Object name*/
100 typedef int (*rte_dpaa2_probe_t)(struct rte_dpaa2_driver *dpaa2_drv,
101 struct rte_dpaa2_device *dpaa2_dev);
102 typedef int (*rte_dpaa2_remove_t)(struct rte_dpaa2_device *dpaa2_dev);
105 * A structure describing a DPAA2 driver.
107 struct rte_dpaa2_driver {
108 TAILQ_ENTRY(rte_dpaa2_driver) next; /**< Next in list. */
109 struct rte_driver driver; /**< Inherit core driver. */
110 struct rte_fslmc_bus *fslmc_bus; /**< FSLMC bus reference */
111 uint32_t drv_flags; /**< Flags for controlling device.*/
112 enum rte_dpaa2_dev_type drv_type; /**< Driver Type */
113 rte_dpaa2_probe_t probe;
114 rte_dpaa2_remove_t remove;
120 struct rte_fslmc_bus {
121 struct rte_bus bus; /**< Generic Bus object */
122 struct rte_fslmc_device_list device_list;
123 /**< FSLMC DPAA2 Device list */
124 struct rte_fslmc_driver_list driver_list;
125 /**< FSLMC DPAA2 Driver list */
127 /**< Optional: Count of devices on bus */
131 * Register a DPAA2 driver.
134 * A pointer to a rte_dpaa2_driver structure describing the driver
137 void rte_fslmc_driver_register(struct rte_dpaa2_driver *driver);
140 * Unregister a DPAA2 driver.
143 * A pointer to a rte_dpaa2_driver structure describing the driver
144 * to be unregistered.
146 void rte_fslmc_driver_unregister(struct rte_dpaa2_driver *driver);
148 /** Helper for DPAA2 device registration from driver (eth, crypto) instance */
149 #define RTE_PMD_REGISTER_DPAA2(nm, dpaa2_drv) \
150 RTE_INIT(dpaa2initfn_ ##nm); \
151 static void dpaa2initfn_ ##nm(void) \
153 (dpaa2_drv).driver.name = RTE_STR(nm);\
154 rte_fslmc_driver_register(&dpaa2_drv); \
156 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
162 #endif /* _RTE_FSLMC_H_ */