1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018-2019 NXP
5 #ifndef __RTE_PMD_DPAA2_QDMA_H__
6 #define __RTE_PMD_DPAA2_QDMA_H__
11 * NXP dpaa2 QDMA specific structures.
15 /** Maximum qdma burst size */
16 #define RTE_QDMA_BURST_NB_MAX 256
18 /** Determines the mode of operation */
21 * Allocate a H/W queue per VQ i.e. Exclusive hardware queue for a VQ.
22 * This mode will have best performance.
26 * A VQ shall not have an exclusive associated H/W queue.
27 * Rather a H/W Queue will be shared by multiple Virtual Queues.
28 * This mode will have intermediate data structures to support
29 * multi VQ to PQ mappings thus having some performance implications.
30 * Note: Even in this mode there is an option to allocate a H/W
31 * queue for a VQ. Please see 'RTE_QDMA_VQ_EXCLUSIVE_PQ' flag.
37 * If user has configured a Virtual Queue mode, but for some particular VQ
38 * user needs an exclusive H/W queue associated (for better performance
39 * on that particular VQ), then user can pass this flag while creating the
40 * Virtual Queue. A H/W queue will be allocated corresponding to
41 * VQ which uses this flag.
43 #define RTE_QDMA_VQ_EXCLUSIVE_PQ (1ULL)
45 /** States if the source addresses is physical. */
46 #define RTE_QDMA_JOB_SRC_PHY (1ULL)
48 /** States if the destination addresses is physical. */
49 #define RTE_QDMA_JOB_DEST_PHY (1ULL << 1)
51 /** Provides QDMA device attributes */
52 struct rte_qdma_attr {
53 /** total number of hw QDMA queues present */
54 uint16_t num_hw_queues;
57 /** QDMA device configuration structure */
58 struct rte_qdma_config {
59 /** Number of maximum hw queues to allocate per core. */
60 uint16_t max_hw_queues_per_core;
61 /** Maximum number of VQ's to be used. */
63 /** mode of operation - physical(h/w) or virtual */
66 * User provides this as input to the driver as a size of the FLE pool.
67 * FLE's (and corresponding source/destination descriptors) are
68 * allocated by the driver at enqueue time to store src/dest and
69 * other data and are freed at the dequeue time. This determines the
70 * maximum number of inflight jobs on the QDMA device. This should
77 uint32_t use_ultrashort:1;
91 /*using route by port for destination */
105 /* using route by port for source */
110 /** Provides QDMA device statistics */
111 struct rte_qdma_vq_stats {
112 /** States if this vq has exclusively associated hw queue */
113 uint8_t exclusive_hw_queue;
114 /** Associated lcore id */
116 /* Total number of enqueues on this VQ */
117 uint64_t num_enqueues;
118 /* Total number of dequeues from this VQ */
119 uint64_t num_dequeues;
120 /* total number of pending jobs in this VQ */
121 uint64_t num_pending_jobs;
124 /** Determines a QDMA job */
125 struct rte_qdma_job {
126 /** Source Address from where DMA is (to be) performed */
128 /** Destination Address where DMA is (to be) done */
130 /** Length of the DMA operation in bytes. */
132 /** See RTE_QDMA_JOB_ flags */
135 * User can specify a context which will be maintained
136 * on the dequeue operation.
140 * Status of the transaction.
141 * This is filled in the dequeue operation by the driver.
142 * upper 8bits acc_err for route by port.
143 * lower 8bits fd error
149 * Initialize the QDMA device.
159 * Get the QDMA attributes.
162 * QDMA attributes providing total number of hw queues etc.
165 rte_qdma_attr_get(struct rte_qdma_attr *qdma_attr);
168 * Reset the QDMA device. This API will completely reset the QDMA
169 * device, bringing it to original state as if only rte_qdma_init() API
177 rte_qdma_reset(void);
180 * Configure the QDMA device.
187 rte_qdma_configure(struct rte_qdma_config *qdma_config);
190 * Start the QDMA device.
197 rte_qdma_start(void);
200 * Create a Virtual Queue on a particular lcore id.
201 * This API can be called from any thread/core. User can create/destroy
205 * LCORE ID on which this particular queue would be associated with.
207 * RTE_QDMA_VQ_ flags. See macro definitions.
210 * - >= 0: Virtual queue ID.
214 rte_qdma_vq_create(uint32_t lcore_id, uint32_t flags);
216 /*create vq for route-by-port*/
218 rte_qdma_vq_create_rbp(uint32_t lcore_id, uint32_t flags,
219 struct rte_qdma_rbp *rbp);
222 * Enqueue multiple jobs to a Virtual Queue.
223 * If the enqueue is successful, the H/W will perform DMA operations
224 * on the basis of the QDMA jobs provided.
229 * List of QDMA Jobs containing relevant information related to DMA.
231 * Number of QDMA jobs provided by the user.
234 * - >=0: Number of jobs successfully submitted
238 rte_qdma_vq_enqueue_multi(uint16_t vq_id,
239 struct rte_qdma_job **job,
243 * Enqueue a single job to a Virtual Queue.
244 * If the enqueue is successful, the H/W will perform DMA operations
245 * on the basis of the QDMA job provided.
250 * A QDMA Job containing relevant information related to DMA.
253 * - >=0: Number of jobs successfully submitted
257 rte_qdma_vq_enqueue(uint16_t vq_id,
258 struct rte_qdma_job *job);
261 * Dequeue multiple completed jobs from a Virtual Queue.
262 * Provides the list of completed jobs capped by nb_jobs.
267 * List of QDMA Jobs returned from the API.
269 * Number of QDMA jobs requested for dequeue by the user.
272 * - >=0: Number of jobs successfully received
276 rte_qdma_vq_dequeue_multi(uint16_t vq_id,
277 struct rte_qdma_job **job,
281 * Dequeue a single completed jobs from a Virtual Queue.
287 * - A completed job or NULL if no job is there.
289 struct rte_qdma_job * __rte_experimental
290 rte_qdma_vq_dequeue(uint16_t vq_id);
293 * Get a Virtual Queue statistics.
298 * VQ statistics structure which will be filled in by the driver.
301 rte_qdma_vq_stats(uint16_t vq_id,
302 struct rte_qdma_vq_stats *vq_stats);
305 * Destroy the Virtual Queue specified by vq_id.
306 * This API can be called from any thread/core. User can create/destroy
310 * Virtual Queue ID which needs to be uninitialized.
317 rte_qdma_vq_destroy(uint16_t vq_id);
320 * Destroy the RBP specific Virtual Queue specified by vq_id.
321 * This API can be called from any thread/core. User can create/destroy
325 * RBP based Virtual Queue ID which needs to be uninitialized.
333 rte_qdma_vq_destroy_rbp(uint16_t vq_id);
341 * Destroy the QDMA device.
344 rte_qdma_destroy(void);
346 #endif /* __RTE_PMD_DPAA2_QDMA_H__*/