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 DPAA_MEMPOOL_OPS_NAME "dpaa"
22 #define DEV_TO_DPAA_DEVICE(ptr) \
23 container_of(ptr, struct rte_dpaa_device, device)
25 /* DPAA SoC identifier; If this is not available, it can be concluded
26 * that board is non-DPAA. Single slot is currently supported.
28 #define DPAA_SOC_ID_FILE "/sys/devices/soc0/soc_id"
30 #define SVR_LS1043A_FAMILY 0x87920000
31 #define SVR_LS1046A_FAMILY 0x87070000
32 #define SVR_MASK 0xffff0000
34 extern unsigned int dpaa_svr_family;
36 struct rte_dpaa_device;
37 struct rte_dpaa_driver;
39 /* DPAA Device and Driver lists for DPAA bus */
40 TAILQ_HEAD(rte_dpaa_device_list, rte_dpaa_device);
41 TAILQ_HEAD(rte_dpaa_driver_list, rte_dpaa_driver);
43 /* Configuration variables exported from DPAA bus */
44 extern struct netcfg_info *dpaa_netcfg;
53 struct rte_dpaa_device_list device_list;
54 struct rte_dpaa_driver_list driver_list;
58 struct dpaa_device_id {
59 uint8_t fman_id; /**< Fman interface ID, for ETH type device */
60 uint8_t mac_id; /**< Fman MAC interface ID, for ETH type device */
61 uint16_t dev_id; /**< Device Identifier from DPDK */
64 struct rte_dpaa_device {
65 TAILQ_ENTRY(rte_dpaa_device) next;
66 struct rte_device device;
68 struct rte_eth_dev *eth_dev;
69 struct rte_cryptodev *crypto_dev;
71 struct rte_dpaa_driver *driver;
72 struct dpaa_device_id id;
73 enum rte_dpaa_type device_type; /**< Ethernet or crypto type device */
74 char name[RTE_ETH_NAME_MAX_LEN];
77 typedef int (*rte_dpaa_probe_t)(struct rte_dpaa_driver *dpaa_drv,
78 struct rte_dpaa_device *dpaa_dev);
79 typedef int (*rte_dpaa_remove_t)(struct rte_dpaa_device *dpaa_dev);
81 struct rte_dpaa_driver {
82 TAILQ_ENTRY(rte_dpaa_driver) next;
83 struct rte_driver driver;
84 struct rte_dpaa_bus *dpaa_bus;
85 enum rte_dpaa_type drv_type;
86 rte_dpaa_probe_t probe;
87 rte_dpaa_remove_t remove;
91 uint32_t bman_idx; /**< BMAN Portal ID*/
92 uint32_t qman_idx; /**< QMAN Portal ID*/
93 uint64_t tid;/**< Parent Thread id for this portal */
96 /* TODO - this is costly, need to write a fast coversion routine */
97 static inline void *rte_dpaa_mem_ptov(phys_addr_t paddr)
99 const struct rte_memseg *memseg = rte_eal_get_physmem_layout();
102 for (i = 0; i < RTE_MAX_MEMSEG && memseg[i].addr != NULL; i++) {
103 if (paddr >= memseg[i].iova && paddr <
104 memseg[i].iova + memseg[i].len)
105 return (uint8_t *)(memseg[i].addr) +
106 (paddr - memseg[i].iova);
113 * Register a DPAA driver.
116 * A pointer to a rte_dpaa_driver structure describing the driver
119 void rte_dpaa_driver_register(struct rte_dpaa_driver *driver);
122 * Unregister a DPAA driver.
125 * A pointer to a rte_dpaa_driver structure describing the driver
126 * to be unregistered.
128 void rte_dpaa_driver_unregister(struct rte_dpaa_driver *driver);
131 * Initialize a DPAA portal
137 * 0 in case of success, error otherwise
139 int rte_dpaa_portal_init(void *arg);
141 int rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq);
143 int rte_dpaa_portal_fq_close(struct qman_fq *fq);
146 * Cleanup a DPAA Portal
148 void dpaa_portal_finish(void *arg);
150 /** Helper for DPAA device registration from driver (eth, crypto) instance */
151 #define RTE_PMD_REGISTER_DPAA(nm, dpaa_drv) \
152 RTE_INIT(dpaainitfn_ ##nm); \
153 static void dpaainitfn_ ##nm(void) \
155 (dpaa_drv).driver.name = RTE_STR(nm);\
156 rte_dpaa_driver_register(&dpaa_drv); \
158 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
160 /* Create storage for dqrr entries per lcore */
161 #define DPAA_PORTAL_DEQUEUE_DEPTH 16
162 struct dpaa_portal_dqrr {
163 void *mbuf[DPAA_PORTAL_DEQUEUE_DEPTH];
168 RTE_DECLARE_PER_LCORE(struct dpaa_portal_dqrr, held_bufs);
170 #define DPAA_PER_LCORE_DQRR_SIZE RTE_PER_LCORE(held_bufs).dqrr_size
171 #define DPAA_PER_LCORE_DQRR_HELD RTE_PER_LCORE(held_bufs).dqrr_held
172 #define DPAA_PER_LCORE_DQRR_MBUF(i) RTE_PER_LCORE(held_bufs).mbuf[i]
178 #endif /* __RTE_DPAA_BUS_H__ */