net/octeontx: cleanup redundant mbox structs
[dpdk.git] / drivers / raw / dpaa2_qdma / rte_pmd_dpaa2_qdma.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2018-2019 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 /** Maximum qdma burst size */
16 #define RTE_QDMA_BURST_NB_MAX 256
17
18 /** Determines the mode of operation */
19 enum {
20         /**
21          * Allocate a H/W queue per VQ i.e. Exclusive hardware queue for a VQ.
22          * This mode will have best performance.
23          */
24         RTE_QDMA_MODE_HW,
25         /**
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.
32          */
33         RTE_QDMA_MODE_VIRTUAL
34 };
35
36 /** Determines the format of FD */
37 enum {
38         RTE_QDMA_LONG_FORMAT,
39         RTE_QDMA_ULTRASHORT_FORMAT,
40 };
41
42 /**
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.
48  */
49 #define RTE_QDMA_VQ_EXCLUSIVE_PQ        (1ULL)
50
51 /** States if the source addresses is physical. */
52 #define RTE_QDMA_JOB_SRC_PHY            (1ULL)
53
54 /** States if the destination addresses is physical. */
55 #define RTE_QDMA_JOB_DEST_PHY           (1ULL << 1)
56
57 /** Provides QDMA device attributes */
58 struct rte_qdma_attr {
59         /** total number of hw QDMA queues present */
60         uint16_t num_hw_queues;
61 };
62
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. */
68         uint16_t max_vqs;
69         /** mode of operation - physical(h/w) or virtual */
70         uint8_t mode;
71         /** FD format */
72         uint8_t format;
73         /**
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
79          * be power of 2.
80          */
81         int fle_pool_count;
82 };
83
84 struct rte_qdma_rbp {
85         uint32_t use_ultrashort:1;
86         uint32_t enable:1;
87         /**
88          * dportid:
89          * 0000 PCI-Express 1
90          * 0001 PCI-Express 2
91          * 0010 PCI-Express 3
92          * 0011 PCI-Express 4
93          * 0100 PCI-Express 5
94          * 0101 PCI-Express 6
95          */
96         uint32_t dportid:4;
97         uint32_t dpfid:2;
98         uint32_t dvfid:6;
99         /*using route by port for destination */
100         uint32_t drbp:1;
101         /**
102          * sportid:
103          * 0000 PCI-Express 1
104          * 0001 PCI-Express 2
105          * 0010 PCI-Express 3
106          * 0011 PCI-Express 4
107          * 0100 PCI-Express 5
108          * 0101 PCI-Express 6
109          */
110         uint32_t sportid:4;
111         uint32_t spfid:2;
112         uint32_t svfid:6;
113         /* using route by port for source */
114         uint32_t srbp:1;
115         uint32_t rsv:4;
116 };
117
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 */
123         uint32_t 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;
130 };
131
132 /** Determines a QDMA job */
133 struct rte_qdma_job {
134         /** Source Address from where DMA is (to be) performed */
135         uint64_t src;
136         /** Destination Address where DMA is (to be) done */
137         uint64_t dest;
138         /** Length of the DMA operation in bytes. */
139         uint32_t len;
140         /** See RTE_QDMA_JOB_ flags */
141         uint32_t flags;
142         /**
143          * User can specify a context which will be maintained
144          * on the dequeue operation.
145          */
146         uint64_t cnxt;
147         /**
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
152          */
153         uint16_t status;
154         uint16_t vq_id;
155 };
156
157 /**
158  * Initialize the QDMA device.
159  *
160  * @returns
161  *   - 0: Success.
162  *   - <0: Error code.
163  */
164 int
165 rte_qdma_init(void);
166
167 /**
168  * Get the QDMA attributes.
169  *
170  * @param qdma_attr
171  *   QDMA attributes providing total number of hw queues etc.
172  */
173 void
174 rte_qdma_attr_get(struct rte_qdma_attr *qdma_attr);
175
176 /**
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
179  * has been called.
180  *
181  * @returns
182  *   - 0: Success.
183  *   - <0: Error code.
184  */
185 int
186 rte_qdma_reset(void);
187
188 /**
189  * Configure the QDMA device.
190  *
191  * @returns
192  *   - 0: Success.
193  *   - <0: Error code.
194  */
195 int
196 rte_qdma_configure(struct rte_qdma_config *qdma_config);
197
198 /**
199  * Start the QDMA device.
200  *
201  * @returns
202  *   - 0: Success.
203  *   - <0: Error code.
204  */
205 int
206 rte_qdma_start(void);
207
208 /**
209  * Create a Virtual Queue on a particular lcore id.
210  * This API can be called from any thread/core. User can create/destroy
211  * VQ's at runtime.
212  *
213  * @param lcore_id
214  *   LCORE ID on which this particular queue would be associated with.
215  * @param flags
216  *  RTE_QDMA_VQ_ flags. See macro definitions.
217  *
218  * @returns
219  *   - >= 0: Virtual queue ID.
220  *   - <0: Error code.
221  */
222 int
223 rte_qdma_vq_create(uint32_t lcore_id, uint32_t flags);
224
225 /*create vq for route-by-port*/
226 int
227 rte_qdma_vq_create_rbp(uint32_t lcore_id, uint32_t flags,
228                         struct rte_qdma_rbp *rbp);
229
230 /**
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.
234  *
235  * @param vq_id
236  *   Virtual Queue ID.
237  * @param job
238  *   List of QDMA Jobs containing relevant information related to DMA.
239  * @param nb_jobs
240  *   Number of QDMA jobs provided by the user.
241  *
242  * @returns
243  *   - >=0: Number of jobs successfully submitted
244  *   - <0: Error code.
245  */
246 int
247 rte_qdma_vq_enqueue_multi(uint16_t vq_id,
248                           struct rte_qdma_job **job,
249                           uint16_t nb_jobs);
250
251 /**
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.
255  *
256  * @param vq_id
257  *   Virtual Queue ID.
258  * @param job
259  *   A QDMA Job containing relevant information related to DMA.
260  *
261  * @returns
262  *   - >=0: Number of jobs successfully submitted
263  *   - <0: Error code.
264  */
265 int
266 rte_qdma_vq_enqueue(uint16_t vq_id,
267                     struct rte_qdma_job *job);
268
269 /**
270  * Dequeue multiple completed jobs from a Virtual Queue.
271  * Provides the list of completed jobs capped by nb_jobs.
272  *
273  * @param vq_id
274  *   Virtual Queue ID.
275  * @param job
276  *   List of QDMA Jobs returned from the API.
277  * @param nb_jobs
278  *   Number of QDMA jobs requested for dequeue by the user.
279  *
280  * @returns
281  *   - >=0: Number of jobs successfully received
282  *   - <0: Error code.
283  */
284 int
285 rte_qdma_vq_dequeue_multi(uint16_t vq_id,
286                           struct rte_qdma_job **job,
287                           uint16_t nb_jobs);
288
289 /**
290  * Dequeue a single completed jobs from a Virtual Queue.
291  *
292  * @param vq_id
293  *   Virtual Queue ID.
294  *
295  * @returns
296  *   - A completed job or NULL if no job is there.
297  */
298 struct rte_qdma_job *
299 rte_qdma_vq_dequeue(uint16_t vq_id);
300
301 /**
302  * Get a Virtual Queue statistics.
303  *
304  * @param vq_id
305  *   Virtual Queue ID.
306  * @param vq_stats
307  *   VQ statistics structure which will be filled in by the driver.
308  */
309 void
310 rte_qdma_vq_stats(uint16_t vq_id,
311                   struct rte_qdma_vq_stats *vq_stats);
312
313 /**
314  * Destroy the Virtual Queue specified by vq_id.
315  * This API can be called from any thread/core. User can create/destroy
316  * VQ's at runtime.
317  *
318  * @param vq_id
319  *   Virtual Queue ID which needs to be uninitialized.
320  *
321  * @returns
322  *   - 0: Success.
323  *   - <0: Error code.
324  */
325 int
326 rte_qdma_vq_destroy(uint16_t vq_id);
327
328 /**
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
331  * VQ's at runtime.
332  *
333  * @param vq_id
334  *   RBP based Virtual Queue ID which needs to be uninitialized.
335  *
336  * @returns
337  *   - 0: Success.
338  *   - <0: Error code.
339  */
340
341 int
342 rte_qdma_vq_destroy_rbp(uint16_t vq_id);
343 /**
344  * Stop QDMA device.
345  */
346 void
347 rte_qdma_stop(void);
348
349 /**
350  * Destroy the QDMA device.
351  */
352 void
353 rte_qdma_destroy(void);
354
355 #endif /* __RTE_PMD_DPAA2_QDMA_H__*/