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 32
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 configued 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
76 /** Provides QDMA device statistics */
77 struct rte_qdma_vq_stats {
78 /** States if this vq has exclusively associated hw queue */
79 uint8_t exclusive_hw_queue;
80 /** Associated lcore id */
82 /* Total number of enqueues on this VQ */
83 uint64_t num_enqueues;
84 /* Total number of dequeues from this VQ */
85 uint64_t num_dequeues;
86 /* total number of pending jobs in this VQ */
87 uint64_t num_pending_jobs;
90 /** Determines a QDMA job */
92 /** Source Address from where DMA is (to be) performed */
94 /** Destination Address where DMA is (to be) done */
96 /** Length of the DMA operation in bytes. */
98 /** See RTE_QDMA_JOB_ flags */
101 * User can specify a context which will be maintained
102 * on the dequeue operation.
106 * Status of the transaction.
107 * This is filled in the dequeue operation by the driver.
113 * Initialize the QDMA device.
123 * Get the QDMA attributes.
126 * QDMA attributes providing total number of hw queues etc.
129 rte_qdma_attr_get(struct rte_qdma_attr *qdma_attr);
132 * Reset the QDMA device. This API will completely reset the QDMA
133 * device, bringing it to original state as if only rte_qdma_init() API
141 rte_qdma_reset(void);
144 * Configure the QDMA device.
151 rte_qdma_configure(struct rte_qdma_config *qdma_config);
154 * Start the QDMA device.
161 rte_qdma_start(void);
164 * Create a Virtual Queue on a particular lcore id.
165 * This API can be called from any thread/core. User can create/destroy
169 * LCORE ID on which this particular queue would be associated with.
171 * RTE_QDMA_VQ_ flags. See macro definitions.
174 * - >= 0: Virtual queue ID.
178 rte_qdma_vq_create(uint32_t lcore_id, uint32_t flags);
181 * Enqueue multiple jobs to a Virtual Queue.
182 * If the enqueue is successful, the H/W will perform DMA operations
183 * on the basis of the QDMA jobs provided.
188 * List of QDMA Jobs containing relevant information related to DMA.
190 * Number of QDMA jobs provided by the user.
193 * - >=0: Number of jobs successfully submitted
197 rte_qdma_vq_enqueue_multi(uint16_t vq_id,
198 struct rte_qdma_job **job,
202 * Enqueue a single job to a Virtual Queue.
203 * If the enqueue is successful, the H/W will perform DMA operations
204 * on the basis of the QDMA job provided.
209 * A QDMA Job containing relevant information related to DMA.
212 * - >=0: Number of jobs successfully submitted
216 rte_qdma_vq_enqueue(uint16_t vq_id,
217 struct rte_qdma_job *job);
220 * Dequeue multiple completed jobs from a Virtual Queue.
221 * Provides the list of completed jobs capped by nb_jobs.
226 * List of QDMA Jobs returned from the API.
228 * Number of QDMA jobs requested for dequeue by the user.
231 * - >=0: Number of jobs successfully received
235 rte_qdma_vq_dequeue_multi(uint16_t vq_id,
236 struct rte_qdma_job **job,
240 * Dequeue a single completed jobs from a Virtual Queue.
246 * - A completed job or NULL if no job is there.
248 struct rte_qdma_job * __rte_experimental
249 rte_qdma_vq_dequeue(uint16_t vq_id);
252 * Get a Virtual Queue statistics.
257 * VQ statistics structure which will be filled in by the driver.
260 rte_qdma_vq_stats(uint16_t vq_id,
261 struct rte_qdma_vq_stats *vq_stats);
264 * Destroy the Virtual Queue specified by vq_id.
265 * This API can be called from any thread/core. User can create/destroy
269 * Virtual Queue ID which needs to be deinialized.
276 rte_qdma_vq_destroy(uint16_t vq_id);
285 * Destroy the QDMA device.
288 rte_qdma_destroy(void);
290 #endif /* __RTE_PMD_DPAA2_QDMA_H__*/