aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h
blob: 17fffcb74c60e0b9aa58dba5c12e3026022ecd19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright 2018 NXP
 */

#ifndef __RTE_PMD_DPAA2_QDMA_H__
#define __RTE_PMD_DPAA2_QDMA_H__

/**
 * @file
 *
 * NXP dpaa2 QDMA specific structures.
 *
 */

/** Determines the mode of operation */
enum {
	/**
	 * Allocate a H/W queue per VQ i.e. Exclusive hardware queue for a VQ.
	 * This mode will have best performance.
	 */
	RTE_QDMA_MODE_HW,
	/**
	 * A VQ shall not have an exclusive associated H/W queue.
	 * Rather a H/W Queue will be shared by multiple Virtual Queues.
	 * This mode will have intermediate data structures to support
	 * multi VQ to PQ mappings thus having some performance implications.
	 * Note: Even in this mode there is an option to allocate a H/W
	 * queue for a VQ. Please see 'RTE_QDMA_VQ_EXCLUSIVE_PQ' flag.
	 */
	RTE_QDMA_MODE_VIRTUAL
};

/**
 * If user has configued a Virtual Queue mode, but for some particular VQ
 * user needs an exclusive H/W queue associated (for better performance
 * on that particular VQ), then user can pass this flag while creating the
 * Virtual Queue. A H/W queue will be allocated corresponding to
 * VQ which uses this flag.
 */
#define RTE_QDMA_VQ_EXCLUSIVE_PQ	(1ULL)

/** States if the source addresses is physical. */
#define RTE_QDMA_JOB_SRC_PHY		(1ULL)

/** States if the destination addresses is physical. */
#define RTE_QDMA_JOB_DEST_PHY		(1ULL << 1)

/** Provides QDMA device attributes */
struct rte_qdma_attr {
	/** total number of hw QDMA queues present */
	uint16_t num_hw_queues;
};

/** QDMA device configuration structure */
struct rte_qdma_config {
	/** Number of maximum hw queues to allocate per core. */
	uint16_t max_hw_queues_per_core;
	/** Maximum number of VQ's to be used. */
	uint16_t max_vqs;
	/** mode of operation - physical(h/w) or virtual */
	uint8_t mode;
	/**
	 * User provides this as input to the driver as a size of the FLE pool.
	 * FLE's (and corresponding source/destination descriptors) are
	 * allocated by the driver at enqueue time to store src/dest and
	 * other data and are freed at the dequeue time. This determines the
	 * maximum number of inflight jobs on the QDMA device. This should
	 * be power of 2.
	 */
	int fle_pool_count;
};

/** Provides QDMA device statistics */
struct rte_qdma_vq_stats {
	/** States if this vq has exclusively associated hw queue */
	uint8_t exclusive_hw_queue;
	/** Associated lcore id */
	uint32_t lcore_id;
	/* Total number of enqueues on this VQ */
	uint64_t num_enqueues;
	/* Total number of dequeues from this VQ */
	uint64_t num_dequeues;
	/* total number of pending jobs in this VQ */
	uint64_t num_pending_jobs;
};

/** Determines a QDMA job */
struct rte_qdma_job {
	/** Source Address from where DMA is (to be) performed */
	uint64_t src;
	/** Destination Address where DMA is (to be) done */
	uint64_t dest;
	/** Length of the DMA operation in bytes. */
	uint32_t len;
	/** See RTE_QDMA_JOB_ flags */
	uint32_t flags;
	/**
	 * User can specify a context which will be maintained
	 * on the dequeue operation.
	 */
	uint64_t cnxt;
	/**
	 * Status of the transaction.
	 * This is filled in the dequeue operation by the driver.
	 */
	uint8_t status;
};

/**
 * Initialize the QDMA device.
 *
 * @returns
 *   - 0: Success.
 *   - <0: Error code.
 */
int __rte_experimental
rte_qdma_init(void);

/**
 * Get the QDMA attributes.
 *
 * @param qdma_attr
 *   QDMA attributes providing total number of hw queues etc.
 */
void __rte_experimental
rte_qdma_attr_get(struct rte_qdma_attr *qdma_attr);

/**
 * Reset the QDMA device. This API will completely reset the QDMA
 * device, bringing it to original state as if only rte_qdma_init() API
 * has been called.
 *
 * @returns
 *   - 0: Success.
 *   - <0: Error code.
 */
int __rte_experimental
rte_qdma_reset(void);

/**
 * Configure the QDMA device.
 *
 * @returns
 *   - 0: Success.
 *   - <0: Error code.
 */
int __rte_experimental
rte_qdma_configure(struct rte_qdma_config *qdma_config);

/**
 * Start the QDMA device.
 *
 * @returns
 *   - 0: Success.
 *   - <0: Error code.
 */
int __rte_experimental
rte_qdma_start(void);

/**
 * Create a Virtual Queue on a particular lcore id.
 * This API can be called from any thread/core. User can create/destroy
 * VQ's at runtime.
 *
 * @param lcore_id
 *   LCORE ID on which this particular queue would be associated with.
 * @param flags
 *  RTE_QDMA_VQ_ flags. See macro definitions.
 *
 * @returns
 *   - >= 0: Virtual queue ID.
 *   - <0: Error code.
 */
int __rte_experimental
rte_qdma_vq_create(uint32_t lcore_id, uint32_t flags);

/**
 * Enqueue multiple jobs to a Virtual Queue.
 * If the enqueue is successful, the H/W will perform DMA operations
 * on the basis of the QDMA jobs provided.
 *
 * @param vq_id
 *   Virtual Queue ID.
 * @param job
 *   List of QDMA Jobs containing relevant information related to DMA.
 * @param nb_jobs
 *   Number of QDMA jobs provided by the user.
 *
 * @returns
 *   - >=0: Number of jobs successfully submitted
 *   - <0: Error code.
 */
int __rte_experimental
rte_qdma_vq_enqueue_multi(uint16_t vq_id,
			  struct rte_qdma_job **job,
			  uint16_t nb_jobs);

/**
 * Enqueue a single job to a Virtual Queue.
 * If the enqueue is successful, the H/W will perform DMA operations
 * on the basis of the QDMA job provided.
 *
 * @param vq_id
 *   Virtual Queue ID.
 * @param job
 *   A QDMA Job containing relevant information related to DMA.
 *
 * @returns
 *   - >=0: Number of jobs successfully submitted
 *   - <0: Error code.
 */
int __rte_experimental
rte_qdma_vq_enqueue(uint16_t vq_id,
		    struct rte_qdma_job *job);

/**
 * Dequeue multiple completed jobs from a Virtual Queue.
 * Provides the list of completed jobs capped by nb_jobs.
 *
 * @param vq_id
 *   Virtual Queue ID.
 * @param job
 *   List of QDMA Jobs returned from the API.
 * @param nb_jobs
 *   Number of QDMA jobs requested for dequeue by the user.
 *
 * @returns
 *   Number of jobs actually dequeued.
 */
int __rte_experimental
rte_qdma_vq_dequeue_multi(uint16_t vq_id,
			  struct rte_qdma_job **job,
			  uint16_t nb_jobs);

/**
 * Dequeue a single completed jobs from a Virtual Queue.
 *
 * @param vq_id
 *   Virtual Queue ID.
 *
 * @returns
 *   - A completed job or NULL if no job is there.
 */
struct rte_qdma_job * __rte_experimental
rte_qdma_vq_dequeue(uint16_t vq_id);

/**
 * Get a Virtual Queue statistics.
 *
 * @param vq_id
 *   Virtual Queue ID.
 * @param vq_stats
 *   VQ statistics structure which will be filled in by the driver.
 */
void __rte_experimental
rte_qdma_vq_stats(uint16_t vq_id,
		  struct rte_qdma_vq_stats *vq_stats);

/**
 * Destroy the Virtual Queue specified by vq_id.
 * This API can be called from any thread/core. User can create/destroy
 * VQ's at runtime.
 *
 * @param vq_id
 *   Virtual Queue ID which needs to be deinialized.
 *
 * @returns
 *   - 0: Success.
 *   - <0: Error code.
 */
int __rte_experimental
rte_qdma_vq_destroy(uint16_t vq_id);

/**
 * Stop QDMA device.
 */
void __rte_experimental
rte_qdma_stop(void);

/**
 * Destroy the QDMA device.
 */
void __rte_experimental
rte_qdma_destroy(void);

#endif /* __RTE_PMD_DPAA2_QDMA_H__*/