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.
36 /** Determines the format of FD */
39 RTE_QDMA_ULTRASHORT_FORMAT,
43 * If user has configured a Virtual Queue mode, but for some particular VQ
44 * user needs an exclusive H/W queue associated (for better performance
45 * on that particular VQ), then user can pass this flag while creating the
46 * Virtual Queue. A H/W queue will be allocated corresponding to
47 * VQ which uses this flag.
49 #define RTE_QDMA_VQ_EXCLUSIVE_PQ (1ULL)
51 /** States if the source addresses is physical. */
52 #define RTE_QDMA_JOB_SRC_PHY (1ULL)
54 /** States if the destination addresses is physical. */
55 #define RTE_QDMA_JOB_DEST_PHY (1ULL << 1)
57 /** Provides QDMA device attributes */
58 struct rte_qdma_attr {
59 /** total number of hw QDMA queues present */
60 uint16_t num_hw_queues;
63 /** QDMA device configuration structure */
64 struct rte_qdma_config {
65 /** Number of maximum hw queues to allocate per core. */
66 uint16_t max_hw_queues_per_core;
67 /** Maximum number of VQ's to be used. */
69 /** mode of operation - physical(h/w) or virtual */
74 * User provides this as input to the driver as a size of the FLE pool.
75 * FLE's (and corresponding source/destination descriptors) are
76 * allocated by the driver at enqueue time to store src/dest and
77 * other data and are freed at the dequeue time. This determines the
78 * maximum number of inflight jobs on the QDMA device. This should
85 uint32_t use_ultrashort:1;
99 /*using route by port for destination */
113 /* using route by port for source */
118 /** Provides QDMA device statistics */
119 struct rte_qdma_vq_stats {
120 /** States if this vq has exclusively associated hw queue */
121 uint8_t exclusive_hw_queue;
122 /** Associated lcore id */
124 /* Total number of enqueues on this VQ */
125 uint64_t num_enqueues;
126 /* Total number of dequeues from this VQ */
127 uint64_t num_dequeues;
128 /* total number of pending jobs in this VQ */
129 uint64_t num_pending_jobs;
132 /** Determines a QDMA job */
133 struct rte_qdma_job {
134 /** Source Address from where DMA is (to be) performed */
136 /** Destination Address where DMA is (to be) done */
138 /** Length of the DMA operation in bytes. */
140 /** See RTE_QDMA_JOB_ flags */
143 * User can specify a context which will be maintained
144 * on the dequeue operation.
148 * Status of the transaction.
149 * This is filled in the dequeue operation by the driver.
150 * upper 8bits acc_err for route by port.
151 * lower 8bits fd error
158 * Initialize the QDMA device.
168 * Get the QDMA attributes.
171 * QDMA attributes providing total number of hw queues etc.
174 rte_qdma_attr_get(struct rte_qdma_attr *qdma_attr);
177 * Reset the QDMA device. This API will completely reset the QDMA
178 * device, bringing it to original state as if only rte_qdma_init() API
186 rte_qdma_reset(void);
189 * Configure the QDMA device.
196 rte_qdma_configure(struct rte_qdma_config *qdma_config);
199 * Start the QDMA device.
206 rte_qdma_start(void);
209 * Create a Virtual Queue on a particular lcore id.
210 * This API can be called from any thread/core. User can create/destroy
214 * LCORE ID on which this particular queue would be associated with.
216 * RTE_QDMA_VQ_ flags. See macro definitions.
219 * - >= 0: Virtual queue ID.
223 rte_qdma_vq_create(uint32_t lcore_id, uint32_t flags);
225 /*create vq for route-by-port*/
227 rte_qdma_vq_create_rbp(uint32_t lcore_id, uint32_t flags,
228 struct rte_qdma_rbp *rbp);
231 * Enqueue multiple jobs to a Virtual Queue.
232 * If the enqueue is successful, the H/W will perform DMA operations
233 * on the basis of the QDMA jobs provided.
238 * List of QDMA Jobs containing relevant information related to DMA.
240 * Number of QDMA jobs provided by the user.
243 * - >=0: Number of jobs successfully submitted
247 rte_qdma_vq_enqueue_multi(uint16_t vq_id,
248 struct rte_qdma_job **job,
252 * Enqueue a single job to a Virtual Queue.
253 * If the enqueue is successful, the H/W will perform DMA operations
254 * on the basis of the QDMA job provided.
259 * A QDMA Job containing relevant information related to DMA.
262 * - >=0: Number of jobs successfully submitted
266 rte_qdma_vq_enqueue(uint16_t vq_id,
267 struct rte_qdma_job *job);
270 * Dequeue multiple completed jobs from a Virtual Queue.
271 * Provides the list of completed jobs capped by nb_jobs.
276 * List of QDMA Jobs returned from the API.
278 * Number of QDMA jobs requested for dequeue by the user.
281 * - >=0: Number of jobs successfully received
285 rte_qdma_vq_dequeue_multi(uint16_t vq_id,
286 struct rte_qdma_job **job,
290 * Dequeue a single completed jobs from a Virtual Queue.
296 * - A completed job or NULL if no job is there.
298 struct rte_qdma_job *
299 rte_qdma_vq_dequeue(uint16_t vq_id);
302 * Get a Virtual Queue statistics.
307 * VQ statistics structure which will be filled in by the driver.
310 rte_qdma_vq_stats(uint16_t vq_id,
311 struct rte_qdma_vq_stats *vq_stats);
314 * Destroy the Virtual Queue specified by vq_id.
315 * This API can be called from any thread/core. User can create/destroy
319 * Virtual Queue ID which needs to be uninitialized.
326 rte_qdma_vq_destroy(uint16_t vq_id);
329 * Destroy the RBP specific Virtual Queue specified by vq_id.
330 * This API can be called from any thread/core. User can create/destroy
334 * RBP based Virtual Queue ID which needs to be uninitialized.
342 rte_qdma_vq_destroy_rbp(uint16_t vq_id);
350 * Destroy the QDMA device.
353 rte_qdma_destroy(void);
355 #endif /* __RTE_PMD_DPAA2_QDMA_H__*/