raw/dpaa2_qdma: support configuration APIs
[dpdk.git] / drivers / raw / dpaa2_qdma / rte_pmd_dpaa2_qdma.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2018 NXP
3  */
4
5 #ifndef __RTE_PMD_DPAA2_QDMA_H__
6 #define __RTE_PMD_DPAA2_QDMA_H__
7
8 /**
9  * @file
10  *
11  * NXP dpaa2 QDMA specific structures.
12  *
13  */
14
15 /** Determines the mode of operation */
16 enum {
17         /**
18          * Allocate a H/W queue per VQ i.e. Exclusive hardware queue for a VQ.
19          * This mode will have best performance.
20          */
21         RTE_QDMA_MODE_HW,
22         /**
23          * A VQ shall not have an exclusive associated H/W queue.
24          * Rather a H/W Queue will be shared by multiple Virtual Queues.
25          * This mode will have intermediate data structures to support
26          * multi VQ to PQ mappings thus having some performance implications.
27          * Note: Even in this mode there is an option to allocate a H/W
28          * queue for a VQ. Please see 'RTE_QDMA_VQ_EXCLUSIVE_PQ' flag.
29          */
30         RTE_QDMA_MODE_VIRTUAL
31 };
32
33 /**
34  * If user has configued a Virtual Queue mode, but for some particular VQ
35  * user needs an exclusive H/W queue associated (for better performance
36  * on that particular VQ), then user can pass this flag while creating the
37  * Virtual Queue. A H/W queue will be allocated corresponding to
38  * VQ which uses this flag.
39  */
40 #define RTE_QDMA_VQ_EXCLUSIVE_PQ        (1ULL)
41
42 /** States if the source addresses is physical. */
43 #define RTE_QDMA_JOB_SRC_PHY            (1ULL)
44
45 /** States if the destination addresses is physical. */
46 #define RTE_QDMA_JOB_DEST_PHY           (1ULL << 1)
47
48 /** Provides QDMA device attributes */
49 struct rte_qdma_attr {
50         /** total number of hw QDMA queues present */
51         uint16_t num_hw_queues;
52 };
53
54 /** QDMA device configuration structure */
55 struct rte_qdma_config {
56         /** Number of maximum hw queues to allocate per core. */
57         uint16_t max_hw_queues_per_core;
58         /** Maximum number of VQ's to be used. */
59         uint16_t max_vqs;
60         /** mode of operation - physical(h/w) or virtual */
61         uint8_t mode;
62         /**
63          * User provides this as input to the driver as a size of the FLE pool.
64          * FLE's (and corresponding source/destination descriptors) are
65          * allocated by the driver at enqueue time to store src/dest and
66          * other data and are freed at the dequeue time. This determines the
67          * maximum number of inflight jobs on the QDMA device. This should
68          * be power of 2.
69          */
70         int fle_pool_count;
71 };
72
73 /** Provides QDMA device statistics */
74 struct rte_qdma_vq_stats {
75         /** States if this vq has exclusively associated hw queue */
76         uint8_t exclusive_hw_queue;
77         /** Associated lcore id */
78         uint32_t lcore_id;
79         /* Total number of enqueues on this VQ */
80         uint64_t num_enqueues;
81         /* Total number of dequeues from this VQ */
82         uint64_t num_dequeues;
83         /* total number of pending jobs in this VQ */
84         uint64_t num_pending_jobs;
85 };
86
87 /** Determines a QDMA job */
88 struct rte_qdma_job {
89         /** Source Address from where DMA is (to be) performed */
90         uint64_t src;
91         /** Destination Address where DMA is (to be) done */
92         uint64_t dest;
93         /** Length of the DMA operation in bytes. */
94         uint32_t len;
95         /** See RTE_QDMA_JOB_ flags */
96         uint32_t flags;
97         /**
98          * User can specify a context which will be maintained
99          * on the dequeue operation.
100          */
101         uint64_t cnxt;
102         /**
103          * Status of the transaction.
104          * This is filled in the dequeue operation by the driver.
105          */
106         uint8_t status;
107 };
108
109 /**
110  * Initialize the QDMA device.
111  *
112  * @returns
113  *   - 0: Success.
114  *   - <0: Error code.
115  */
116 int __rte_experimental
117 rte_qdma_init(void);
118
119 /**
120  * Get the QDMA attributes.
121  *
122  * @param qdma_attr
123  *   QDMA attributes providing total number of hw queues etc.
124  */
125 void __rte_experimental
126 rte_qdma_attr_get(struct rte_qdma_attr *qdma_attr);
127
128 /**
129  * Reset the QDMA device. This API will completely reset the QDMA
130  * device, bringing it to original state as if only rte_qdma_init() API
131  * has been called.
132  *
133  * @returns
134  *   - 0: Success.
135  *   - <0: Error code.
136  */
137 int __rte_experimental
138 rte_qdma_reset(void);
139
140 /**
141  * Configure the QDMA device.
142  *
143  * @returns
144  *   - 0: Success.
145  *   - <0: Error code.
146  */
147 int __rte_experimental
148 rte_qdma_configure(struct rte_qdma_config *qdma_config);
149
150 /**
151  * Start the QDMA device.
152  *
153  * @returns
154  *   - 0: Success.
155  *   - <0: Error code.
156  */
157 int __rte_experimental
158 rte_qdma_start(void);
159
160 /**
161  * Create a Virtual Queue on a particular lcore id.
162  * This API can be called from any thread/core. User can create/destroy
163  * VQ's at runtime.
164  *
165  * @param lcore_id
166  *   LCORE ID on which this particular queue would be associated with.
167  * @param flags
168  *  RTE_QDMA_VQ_ flags. See macro definitions.
169  *
170  * @returns
171  *   - >= 0: Virtual queue ID.
172  *   - <0: Error code.
173  */
174 int __rte_experimental
175 rte_qdma_vq_create(uint32_t lcore_id, uint32_t flags);
176
177 /**
178  * Get a Virtual Queue statistics.
179  *
180  * @param vq_id
181  *   Virtual Queue ID.
182  * @param vq_stats
183  *   VQ statistics structure which will be filled in by the driver.
184  */
185 void __rte_experimental
186 rte_qdma_vq_stats(uint16_t vq_id,
187                   struct rte_qdma_vq_stats *vq_stats);
188
189 /**
190  * Destroy the Virtual Queue specified by vq_id.
191  * This API can be called from any thread/core. User can create/destroy
192  * VQ's at runtime.
193  *
194  * @param vq_id
195  *   Virtual Queue ID which needs to be deinialized.
196  *
197  * @returns
198  *   - 0: Success.
199  *   - <0: Error code.
200  */
201 int __rte_experimental
202 rte_qdma_vq_destroy(uint16_t vq_id);
203
204 /**
205  * Stop QDMA device.
206  */
207 void __rte_experimental
208 rte_qdma_stop(void);
209
210 /**
211  * Destroy the QDMA device.
212  */
213 void __rte_experimental
214 rte_qdma_destroy(void);
215
216 #endif /* __RTE_PMD_DPAA2_QDMA_H__*/