1 /* SPDX-License-Identifier: BSD-3-Clause
13 * RTE FSLMC Bus Interface
24 #include <sys/queue.h>
27 #include <linux/vfio.h>
29 #include <rte_debug.h>
30 #include <rte_interrupts.h>
33 #include <rte_tailq.h>
35 #include <fslmc_vfio.h>
37 #define FSLMC_OBJECT_MAX_LEN 32 /**< Length of each device on bus */
39 /** Device driver supports IOVA as VA */
40 #define RTE_DPAA2_DRV_IOVA_AS_VA 0X0040
42 struct rte_dpaa2_driver;
44 /* DPAA2 Device and Driver lists for FSLMC bus */
45 TAILQ_HEAD(rte_fslmc_device_list, rte_dpaa2_device);
46 TAILQ_HEAD(rte_fslmc_driver_list, rte_dpaa2_driver);
48 extern struct rte_fslmc_bus rte_fslmc_bus;
50 enum rte_dpaa2_dev_type {
51 /* Devices backed by DPDK driver */
52 DPAA2_ETH, /**< DPNI type device*/
53 DPAA2_CRYPTO, /**< DPSECI type device */
54 DPAA2_CON, /**< DPCONC type device */
55 /* Devices not backed by a DPDK driver: DPIO, DPBP, DPCI, DPMCP */
56 DPAA2_BPOOL, /**< DPBP type device */
57 DPAA2_IO, /**< DPIO type device */
58 DPAA2_CI, /**< DPCI type device */
59 DPAA2_MPORTAL, /**< DPMCP type device */
60 /* Unknown device placeholder */
64 TAILQ_HEAD(rte_dpaa2_object_list, rte_dpaa2_object);
66 typedef int (*rte_dpaa2_obj_create_t)(int vdev_fd,
67 struct vfio_device_info *obj_info,
71 * A structure describing a DPAA2 object.
73 struct rte_dpaa2_object {
74 TAILQ_ENTRY(rte_dpaa2_object) next; /**< Next in list. */
75 const char *name; /**< Name of Object. */
76 enum rte_dpaa2_dev_type dev_type; /**< Type of device */
77 rte_dpaa2_obj_create_t create;
81 * A structure describing a DPAA2 device.
83 struct rte_dpaa2_device {
84 TAILQ_ENTRY(rte_dpaa2_device) next; /**< Next probed DPAA2 device. */
85 struct rte_device device; /**< Inherit core device */
87 struct rte_eth_dev *eth_dev; /**< ethernet device */
88 struct rte_cryptodev *cryptodev; /**< Crypto Device */
90 enum rte_dpaa2_dev_type dev_type; /**< Device Type */
91 uint16_t object_id; /**< DPAA2 Object ID */
92 struct rte_intr_handle intr_handle; /**< Interrupt handle */
93 struct rte_dpaa2_driver *driver; /**< Associated driver */
94 char name[FSLMC_OBJECT_MAX_LEN]; /**< DPAA2 Object name*/
97 typedef int (*rte_dpaa2_probe_t)(struct rte_dpaa2_driver *dpaa2_drv,
98 struct rte_dpaa2_device *dpaa2_dev);
99 typedef int (*rte_dpaa2_remove_t)(struct rte_dpaa2_device *dpaa2_dev);
102 * A structure describing a DPAA2 driver.
104 struct rte_dpaa2_driver {
105 TAILQ_ENTRY(rte_dpaa2_driver) next; /**< Next in list. */
106 struct rte_driver driver; /**< Inherit core driver. */
107 struct rte_fslmc_bus *fslmc_bus; /**< FSLMC bus reference */
108 uint32_t drv_flags; /**< Flags for controlling device.*/
109 enum rte_dpaa2_dev_type drv_type; /**< Driver Type */
110 rte_dpaa2_probe_t probe;
111 rte_dpaa2_remove_t remove;
117 struct rte_fslmc_bus {
118 struct rte_bus bus; /**< Generic Bus object */
119 struct rte_fslmc_device_list device_list;
120 /**< FSLMC DPAA2 Device list */
121 struct rte_fslmc_driver_list driver_list;
122 /**< FSLMC DPAA2 Driver list */
124 /**< Optional: Count of devices on bus */
128 * Register a DPAA2 driver.
131 * A pointer to a rte_dpaa2_driver structure describing the driver
134 void rte_fslmc_driver_register(struct rte_dpaa2_driver *driver);
137 * Unregister a DPAA2 driver.
140 * A pointer to a rte_dpaa2_driver structure describing the driver
141 * to be unregistered.
143 void rte_fslmc_driver_unregister(struct rte_dpaa2_driver *driver);
145 /** Helper for DPAA2 device registration from driver (eth, crypto) instance */
146 #define RTE_PMD_REGISTER_DPAA2(nm, dpaa2_drv) \
147 RTE_INIT(dpaa2initfn_ ##nm); \
148 static void dpaa2initfn_ ##nm(void) \
150 (dpaa2_drv).driver.name = RTE_STR(nm);\
151 rte_fslmc_driver_register(&dpaa2_drv); \
153 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
156 * Register a DPAA2 MC Object driver.
159 * A pointer to a rte_dpaa_object structure describing the mc object
162 void rte_fslmc_object_register(struct rte_dpaa2_object *object);
164 /** Helper for DPAA2 object registration */
165 #define RTE_PMD_REGISTER_DPAA2_OBJECT(nm, dpaa2_obj) \
166 RTE_INIT(dpaa2objinitfn_ ##nm); \
167 static void dpaa2objinitfn_ ##nm(void) \
169 (dpaa2_obj).name = RTE_STR(nm);\
170 rte_fslmc_object_register(&dpaa2_obj); \
172 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
178 #endif /* _RTE_FSLMC_H_ */