1 /* SPDX-License-Identifier: BSD-3-Clause
6 #ifndef __RTE_DPAA_BUS_H__
7 #define __RTE_DPAA_BUS_H__
10 #include <rte_mempool.h>
18 #define FSL_DPAA_BUS_NAME "FSL_DPAA_BUS"
20 #define DEV_TO_DPAA_DEVICE(ptr) \
21 container_of(ptr, struct rte_dpaa_device, device)
23 struct rte_dpaa_device;
24 struct rte_dpaa_driver;
26 /* DPAA Device and Driver lists for DPAA bus */
27 TAILQ_HEAD(rte_dpaa_device_list, rte_dpaa_device);
28 TAILQ_HEAD(rte_dpaa_driver_list, rte_dpaa_driver);
30 /* Configuration variables exported from DPAA bus */
31 extern struct netcfg_info *dpaa_netcfg;
40 struct rte_dpaa_device_list device_list;
41 struct rte_dpaa_driver_list driver_list;
45 struct dpaa_device_id {
46 uint8_t fman_id; /**< Fman interface ID, for ETH type device */
47 uint8_t mac_id; /**< Fman MAC interface ID, for ETH type device */
48 uint16_t dev_id; /**< Device Identifier from DPDK */
51 struct rte_dpaa_device {
52 TAILQ_ENTRY(rte_dpaa_device) next;
53 struct rte_device device;
55 struct rte_eth_dev *eth_dev;
56 struct rte_cryptodev *crypto_dev;
58 struct rte_dpaa_driver *driver;
59 struct dpaa_device_id id;
60 enum rte_dpaa_type device_type; /**< Ethernet or crypto type device */
61 char name[RTE_ETH_NAME_MAX_LEN];
64 typedef int (*rte_dpaa_probe_t)(struct rte_dpaa_driver *dpaa_drv,
65 struct rte_dpaa_device *dpaa_dev);
66 typedef int (*rte_dpaa_remove_t)(struct rte_dpaa_device *dpaa_dev);
68 struct rte_dpaa_driver {
69 TAILQ_ENTRY(rte_dpaa_driver) next;
70 struct rte_driver driver;
71 struct rte_dpaa_bus *dpaa_bus;
72 enum rte_dpaa_type drv_type;
73 rte_dpaa_probe_t probe;
74 rte_dpaa_remove_t remove;
78 uint32_t bman_idx; /**< BMAN Portal ID*/
79 uint32_t qman_idx; /**< QMAN Portal ID*/
80 uint64_t tid;/**< Parent Thread id for this portal */
83 /* TODO - this is costly, need to write a fast coversion routine */
84 static inline void *rte_dpaa_mem_ptov(phys_addr_t paddr)
86 const struct rte_memseg *memseg = rte_eal_get_physmem_layout();
89 for (i = 0; i < RTE_MAX_MEMSEG && memseg[i].addr != NULL; i++) {
90 if (paddr >= memseg[i].iova && paddr <
91 memseg[i].iova + memseg[i].len)
92 return (uint8_t *)(memseg[i].addr) +
93 (paddr - memseg[i].iova);
100 * Register a DPAA driver.
103 * A pointer to a rte_dpaa_driver structure describing the driver
106 void rte_dpaa_driver_register(struct rte_dpaa_driver *driver);
109 * Unregister a DPAA driver.
112 * A pointer to a rte_dpaa_driver structure describing the driver
113 * to be unregistered.
115 void rte_dpaa_driver_unregister(struct rte_dpaa_driver *driver);
118 * Initialize a DPAA portal
124 * 0 in case of success, error otherwise
126 int rte_dpaa_portal_init(void *arg);
129 * Cleanup a DPAA Portal
131 void dpaa_portal_finish(void *arg);
133 /** Helper for DPAA device registration from driver (eth, crypto) instance */
134 #define RTE_PMD_REGISTER_DPAA(nm, dpaa_drv) \
135 RTE_INIT(dpaainitfn_ ##nm); \
136 static void dpaainitfn_ ##nm(void) \
138 (dpaa_drv).driver.name = RTE_STR(nm);\
139 rte_dpaa_driver_register(&dpaa_drv); \
141 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
147 #endif /* __RTE_DPAA_BUS_H__ */