1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018-2020 NXP
5 #ifndef __DPAA2_QDMA_H__
6 #define __DPAA2_QDMA_H__
11 #define DPAA2_QDMA_MAX_FLE 3
12 #define DPAA2_QDMA_MAX_SDD 2
14 #define DPAA2_DPDMAI_MAX_QUEUES 8
16 /** FLE pool size: 3 Frame list + 2 source/destination descriptor */
17 #define QDMA_FLE_POOL_SIZE (sizeof(struct rte_qdma_job *) + \
18 sizeof(struct qbman_fle) * DPAA2_QDMA_MAX_FLE + \
19 sizeof(struct qdma_sdd) * DPAA2_QDMA_MAX_SDD)
20 /** FLE pool cache size */
21 #define QDMA_FLE_CACHE_SIZE(_num) (_num/(RTE_MAX_LCORE * 2))
23 /** Notification by FQD_CTX[fqid] */
24 #define QDMA_SER_CTX (1 << 8)
25 #define DPAA2_RBP_MEM_RW 0x0
27 * Source descriptor command read transaction type for RBP=0:
28 * coherent copy of cacheable memory
30 #define DPAA2_COHERENT_NO_ALLOCATE_CACHE 0xb
31 #define DPAA2_LX2_COHERENT_NO_ALLOCATE_CACHE 0x7
33 * Destination descriptor command write transaction type for RBP=0:
34 * coherent copy of cacheable memory
36 #define DPAA2_COHERENT_ALLOCATE_CACHE 0x6
37 #define DPAA2_LX2_COHERENT_ALLOCATE_CACHE 0xb
39 /** Maximum possible H/W Queues on each core */
40 #define MAX_HW_QUEUE_PER_CORE 64
42 #define QDMA_RBP_UPPER_ADDRESS_MASK (0xfff0000000000)
44 * Represents a QDMA device.
45 * A single QDMA device exists which is combination of multiple DPDMAI rawdev's.
48 /** total number of hw queues. */
49 uint16_t num_hw_queues;
51 * Maximum number of hw queues to be alocated per core.
52 * This is limited by MAX_HW_QUEUE_PER_CORE
54 uint16_t max_hw_queues_per_core;
56 /** VQ's of this device */
57 struct qdma_virt_queue *vqs;
58 /** Maximum number of VQ's */
60 /** Device state - started or stopped */
62 /** FLE pool for the device */
63 struct rte_mempool *fle_pool;
66 /** A lock to QDMA device whenever required */
70 /** Represents a QDMA H/W queue */
71 struct qdma_hw_queue {
72 /** Pointer to Next instance */
73 TAILQ_ENTRY(qdma_hw_queue) next;
74 /** DPDMAI device to communicate with HW */
75 struct dpaa2_dpdmai_dev *dpdmai_dev;
76 /** queue ID to communicate with HW */
78 /** Associated lcore id */
80 /** Number of users of this hw queue */
84 struct qdma_virt_queue;
86 typedef uint16_t (qdma_get_job_t)(struct qdma_virt_queue *qdma_vq,
87 const struct qbman_fd *fd,
88 struct rte_qdma_job **job);
89 typedef int (qdma_set_fd_t)(struct qdma_virt_queue *qdma_vq,
91 struct rte_qdma_job *job);
93 typedef int (qdma_dequeue_multijob_t)(
94 struct qdma_virt_queue *qdma_vq,
96 struct rte_qdma_job **job,
99 typedef int (qdma_enqueue_multijob_t)(
100 struct qdma_virt_queue *qdma_vq,
101 struct rte_qdma_job **job,
104 /** Represents a QDMA virtual queue */
105 struct qdma_virt_queue {
106 /** Status ring of the virtual queue */
107 struct rte_ring *status_ring;
108 /** Associated hw queue */
109 struct qdma_hw_queue *hw_queue;
111 struct rte_qdma_rbp rbp;
112 /** Associated lcore id */
114 /** States if this vq is in use or not */
116 /** States if this vq has exclusively associated hw queue */
117 uint8_t exclusive_hw_queue;
118 /* Total number of enqueues on this VQ */
119 uint64_t num_enqueues;
120 /* Total number of dequeues from this VQ */
121 uint64_t num_dequeues;
125 qdma_set_fd_t *set_fd;
126 qdma_get_job_t *get_job;
128 qdma_dequeue_multijob_t *dequeue_job;
129 qdma_enqueue_multijob_t *enqueue_job;
132 /** Represents a QDMA per core hw queues allocation in virtual mode */
133 struct qdma_per_core_info {
134 /** list for allocated hw queues */
135 struct qdma_hw_queue *hw_queues[MAX_HW_QUEUE_PER_CORE];
136 /* Number of hw queues allocated for this core */
137 uint16_t num_hw_queues;
140 /** Source/Destination Descriptor */
143 /** Stride configuration */
145 /** Route-by-port command */
189 /** Represents a DPDMAI raw device */
190 struct dpaa2_dpdmai_dev {
191 /** Pointer to Next device instance */
192 TAILQ_ENTRY(dpaa2_qdma_device) next;
193 /** handle to DPDMAI object */
194 struct fsl_mc_io dpdmai;
195 /** HW ID for DPDMAI object */
197 /** Tocken of this device */
199 /** Number of queue in this DPDMAI device */
202 struct dpaa2_queue rx_queue[DPAA2_DPDMAI_MAX_QUEUES];
204 struct dpaa2_queue tx_queue[DPAA2_DPDMAI_MAX_QUEUES];
205 struct qdma_device *qdma_dev;
208 static inline struct qdma_device *
209 QDMA_DEV_OF_VQ(struct qdma_virt_queue *vq)
211 return vq->hw_queue->dpdmai_dev->qdma_dev;
214 #endif /* __DPAA2_QDMA_H__ */