1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright 2017-2019 NXP
6 #ifndef __RTE_DPAA_BUS_H__
7 #define __RTE_DPAA_BUS_H__
10 #include <rte_mempool.h>
11 #include <dpaax_iova_table.h>
19 #define DPAA_MEMPOOL_OPS_NAME "dpaa"
21 #define DEV_TO_DPAA_DEVICE(ptr) \
22 container_of(ptr, struct rte_dpaa_device, device)
24 /* DPAA SoC identifier; If this is not available, it can be concluded
25 * that board is non-DPAA. Single slot is currently supported.
27 #define DPAA_SOC_ID_FILE "/sys/devices/soc0/soc_id"
29 #define SVR_LS1043A_FAMILY 0x87920000
30 #define SVR_LS1046A_FAMILY 0x87070000
31 #define SVR_MASK 0xffff0000
33 #define RTE_DEV_TO_DPAA_CONST(ptr) \
34 container_of(ptr, const struct rte_dpaa_device, device)
36 extern unsigned int dpaa_svr_family;
38 extern RTE_DEFINE_PER_LCORE(bool, dpaa_io);
40 struct rte_dpaa_device;
41 struct rte_dpaa_driver;
43 /* DPAA Device and Driver lists for DPAA bus */
44 TAILQ_HEAD(rte_dpaa_device_list, rte_dpaa_device);
45 TAILQ_HEAD(rte_dpaa_driver_list, rte_dpaa_driver);
54 struct rte_dpaa_device_list device_list;
55 struct rte_dpaa_driver_list driver_list;
60 struct dpaa_device_id {
61 uint8_t fman_id; /**< Fman interface ID, for ETH type device */
62 uint8_t mac_id; /**< Fman MAC interface ID, for ETH type device */
63 uint16_t dev_id; /**< Device Identifier from DPDK */
66 struct rte_dpaa_device {
67 TAILQ_ENTRY(rte_dpaa_device) next;
68 struct rte_device device;
70 struct rte_eth_dev *eth_dev;
71 struct rte_cryptodev *crypto_dev;
73 struct rte_dpaa_driver *driver;
74 struct dpaa_device_id id;
75 struct rte_intr_handle intr_handle;
76 enum rte_dpaa_type device_type; /**< Ethernet or crypto type device */
77 char name[RTE_ETH_NAME_MAX_LEN];
80 typedef int (*rte_dpaa_probe_t)(struct rte_dpaa_driver *dpaa_drv,
81 struct rte_dpaa_device *dpaa_dev);
82 typedef int (*rte_dpaa_remove_t)(struct rte_dpaa_device *dpaa_dev);
84 struct rte_dpaa_driver {
85 TAILQ_ENTRY(rte_dpaa_driver) next;
86 struct rte_driver driver;
87 struct rte_dpaa_bus *dpaa_bus;
88 enum rte_dpaa_type drv_type;
89 rte_dpaa_probe_t probe;
90 rte_dpaa_remove_t remove;
94 uint32_t bman_idx; /**< BMAN Portal ID*/
95 uint32_t qman_idx; /**< QMAN Portal ID*/
96 uint64_t tid;/**< Parent Thread id for this portal */
99 /* Various structures representing contiguous memory maps */
101 TAILQ_ENTRY(dpaa_memseg) next;
107 TAILQ_HEAD(dpaa_memseg_list, dpaa_memseg);
108 extern struct dpaa_memseg_list rte_dpaa_memsegs;
110 /* Either iterate over the list of internal memseg references or fallback to
111 * EAL memseg based iova2virt.
113 static inline void *rte_dpaa_mem_ptov(phys_addr_t paddr)
115 struct dpaa_memseg *ms;
118 va = dpaax_iova_table_get_va(paddr);
119 if (likely(va != NULL))
122 /* Check if the address is already part of the memseg list internally
123 * maintained by the dpaa driver.
125 TAILQ_FOREACH(ms, &rte_dpaa_memsegs, next) {
126 if (paddr >= ms->iova && paddr <
128 return RTE_PTR_ADD(ms->vaddr, (uintptr_t)(paddr - ms->iova));
131 /* If not, Fallback to full memseg list searching */
132 va = rte_mem_iova2virt(paddr);
134 dpaax_iova_table_update(paddr, va, RTE_CACHE_LINE_SIZE);
139 static inline rte_iova_t
140 rte_dpaa_mem_vtop(void *vaddr)
142 const struct rte_memseg *ms;
144 ms = rte_mem_virt2memseg(vaddr, NULL);
146 return ms->iova + RTE_PTR_DIFF(vaddr, ms->addr);
152 * Register a DPAA driver.
155 * A pointer to a rte_dpaa_driver structure describing the driver
159 void rte_dpaa_driver_register(struct rte_dpaa_driver *driver);
162 * Unregister a DPAA driver.
165 * A pointer to a rte_dpaa_driver structure describing the driver
166 * to be unregistered.
169 void rte_dpaa_driver_unregister(struct rte_dpaa_driver *driver);
172 * Initialize a DPAA portal
178 * 0 in case of success, error otherwise
181 int rte_dpaa_portal_init(void *arg);
184 int rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq);
187 int rte_dpaa_portal_fq_close(struct qman_fq *fq);
190 * Cleanup a DPAA Portal
192 void dpaa_portal_finish(void *arg);
194 /** Helper for DPAA device registration from driver (eth, crypto) instance */
195 #define RTE_PMD_REGISTER_DPAA(nm, dpaa_drv) \
196 RTE_INIT(dpaainitfn_ ##nm) \
198 (dpaa_drv).driver.name = RTE_STR(nm);\
199 rte_dpaa_driver_register(&dpaa_drv); \
201 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
203 /* Create storage for dqrr entries per lcore */
204 #define DPAA_PORTAL_DEQUEUE_DEPTH 16
205 struct dpaa_portal_dqrr {
206 void *mbuf[DPAA_PORTAL_DEQUEUE_DEPTH];
211 RTE_DECLARE_PER_LCORE(struct dpaa_portal_dqrr, held_bufs);
213 #define DPAA_PER_LCORE_DQRR_SIZE RTE_PER_LCORE(held_bufs).dqrr_size
214 #define DPAA_PER_LCORE_DQRR_HELD RTE_PER_LCORE(held_bufs).dqrr_held
215 #define DPAA_PER_LCORE_DQRR_MBUF(i) RTE_PER_LCORE(held_bufs).mbuf[i]
218 struct fm_eth_port_cfg *dpaa_get_eth_port_cfg(int dev_id);
224 #endif /* __RTE_DPAA_BUS_H__ */