Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2021-2026 NXP
3 : : */
4 : :
5 : : #include <bus_dpaa_driver.h>
6 : : #include <rte_dmadev_pmd.h>
7 : : #include <rte_kvargs.h>
8 : :
9 : : #include "dpaa_qdma.h"
10 : : #include "dpaa_qdma_logs.h"
11 : :
12 : : static uint32_t s_sg_max_entry_sz = 2000;
13 : : static bool s_hw_err_check;
14 : : static bool s_data_validation;
15 : : static bool s_sg_enable = true;
16 : : #ifdef RTE_DMA_DPAA_ERRATA_ERR050757
17 : : static bool s_pci_read = true;
18 : : #endif
19 : :
20 : : #define DPAA_DMA_ERROR_CHECK "dpaa_dma_err_check"
21 : : #define DPAA_DMA_SG_DISABLE "dpaa_dma_sg_disable"
22 : : #define DPAA_DMA_DATA_VALID "dpaa_dma_data_validation"
23 : : #ifdef RTE_DMA_DPAA_ERRATA_ERR050757
24 : : #define DPAA_DMA_PCI_READ_DISABLE "dpaa_dma_pci_read_disable"
25 : : #define DPAA_DMA_ERRATA_PARAMS DPAA_DMA_PCI_READ_DISABLE "=<int>"
26 : : #else
27 : : #define DPAA_DMA_ERRATA_PARAMS ""
28 : : #endif
29 : :
30 : : static inline void
31 : : qdma_desc_addr_set64(struct fsl_qdma_comp_cmd_desc *ccdf, u64 addr)
32 : : {
33 : 0 : ccdf->addr_hi = upper_32_bits(addr);
34 : 0 : ccdf->addr_lo = rte_cpu_to_le_32(lower_32_bits(addr));
35 : : }
36 : :
37 : : static inline void
38 : : qdma_desc_sge_addr_set64(struct fsl_qdma_comp_sg_desc *sge, u64 addr)
39 : : {
40 : 0 : sge->addr_hi = upper_32_bits(addr);
41 : 0 : sge->addr_lo = rte_cpu_to_le_32(lower_32_bits(addr));
42 : : }
43 : :
44 : : static inline int
45 : : qdma_ccdf_get_queue(struct fsl_qdma_comp_cmd_desc *ccdf,
46 : : uint8_t *queue_idx)
47 : : {
48 : 0 : uint64_t addr = ((uint64_t)ccdf->addr_hi) << 32 | ccdf->addr_lo;
49 : :
50 : 0 : if (addr && queue_idx)
51 : 0 : *queue_idx = ccdf->queue;
52 [ # # ]: 0 : if (addr) {
53 : 0 : ccdf->addr_hi = 0;
54 : 0 : ccdf->addr_lo = 0;
55 : : return true;
56 : : }
57 : :
58 : : return false;
59 : : }
60 : :
61 : : static inline int
62 : : ilog2(int x)
63 : : {
64 : : int log = 0;
65 : :
66 : 0 : x >>= 1;
67 : :
68 [ # # # # : 0 : while (x) {
# # # # #
# # # ]
69 : 0 : log++;
70 : 0 : x >>= 1;
71 : : }
72 : : return log;
73 : : }
74 : :
75 : : static inline int
76 : : ilog2_qsize(uint32_t q_size)
77 : : {
78 : 0 : return (ilog2(q_size) - ilog2(64));
79 : : }
80 : :
81 : : static inline int
82 : : ilog2_qthld(uint32_t q_thld)
83 : : {
84 : 0 : return (ilog2(q_thld) - ilog2(16));
85 : : }
86 : :
87 : : static inline int
88 : : fsl_qdma_queue_bd_in_hw(struct fsl_qdma_queue *fsl_queue)
89 : : {
90 : : struct rte_dma_stats *stats = &fsl_queue->stats;
91 : :
92 : 0 : return (stats->submitted - stats->completed);
93 : : }
94 : :
95 : : static u32
96 : : qdma_readl(void *addr)
97 : : {
98 : : return QDMA_IN(addr);
99 : : }
100 : :
101 : : static void
102 : : qdma_writel(u32 val, void *addr)
103 : : {
104 : 0 : QDMA_OUT(addr, val);
105 : : }
106 : :
107 : : static u32
108 : : qdma_readl_be(void *addr)
109 : : {
110 : : return QDMA_IN_BE(addr);
111 : : }
112 : :
113 : : static void
114 : : qdma_writel_be(u32 val, void *addr)
115 : : {
116 : : QDMA_OUT_BE(addr, val);
117 : : }
118 : :
119 : : static void *
120 : 0 : dma_pool_alloc(char *nm, int size, int aligned, dma_addr_t *phy_addr)
121 : : {
122 : : void *virt_addr;
123 : :
124 : 0 : virt_addr = rte_zmalloc(nm, size, aligned);
125 [ # # ]: 0 : if (!virt_addr)
126 : : return NULL;
127 : :
128 : 0 : *phy_addr = rte_mem_virt2iova(virt_addr);
129 : :
130 : 0 : return virt_addr;
131 : : }
132 : :
133 : : /*
134 : : * Pre-request command descriptor and compound S/G for enqueue.
135 : : */
136 : : static int
137 : 0 : fsl_qdma_pre_comp_sd_desc(struct fsl_qdma_queue *queue)
138 : : {
139 : 0 : struct fsl_qdma_engine *fsl_qdma = queue->engine;
140 : : struct fsl_qdma_sdf *sdf;
141 : : struct fsl_qdma_ddf *ddf;
142 : : struct fsl_qdma_comp_cmd_desc *ccdf;
143 : : uint16_t i, j;
144 : : struct fsl_qdma_cmpd_ft *ft;
145 : :
146 [ # # ]: 0 : for (i = 0; i < queue->n_cq; i++) {
147 : 0 : dma_addr_t phy_ft = 0;
148 : :
149 : 0 : queue->ft[i] = dma_pool_alloc(NULL,
150 : : sizeof(struct fsl_qdma_cmpd_ft),
151 : : RTE_CACHE_LINE_SIZE, &phy_ft);
152 [ # # ]: 0 : if (!queue->ft[i])
153 : 0 : goto fail;
154 [ # # ]: 0 : if (((uint64_t)queue->ft[i]) &
155 : : (RTE_CACHE_LINE_SIZE - 1)) {
156 : 0 : DPAA_QDMA_ERR("FD[%d] addr(%p) not cache aligned",
157 : : i, queue->ft[i]);
158 : 0 : rte_free(queue->ft[i]);
159 : 0 : queue->ft[i] = NULL;
160 : 0 : goto fail;
161 : : }
162 [ # # ]: 0 : if (((uint64_t)(&queue->ft[i]->desc_ssge[0])) &
163 : : (RTE_CACHE_LINE_SIZE - 1)) {
164 : 0 : DPAA_QDMA_ERR("FD[%d] SGE addr(%p) not cache aligned",
165 : : i, &queue->ft[i]->desc_ssge[0]);
166 : 0 : rte_free(queue->ft[i]);
167 : 0 : queue->ft[i] = NULL;
168 : 0 : goto fail;
169 : : }
170 : 0 : queue->ft[i]->phy_ssge = phy_ft +
171 : : offsetof(struct fsl_qdma_cmpd_ft, desc_ssge);
172 : 0 : queue->ft[i]->phy_dsge = phy_ft +
173 : : offsetof(struct fsl_qdma_cmpd_ft, desc_dsge);
174 : 0 : queue->ft[i]->phy_df = phy_ft +
175 : : offsetof(struct fsl_qdma_cmpd_ft, df);
176 : :
177 : : ft = queue->ft[i];
178 : : sdf = &ft->df.sdf;
179 : : ddf = &ft->df.ddf;
180 : : /* Compound Command Descriptor(Frame List Table) */
181 : : qdma_desc_sge_addr_set64(&ft->desc_buf, ft->phy_df);
182 : : /* It must be 32 as Compound S/G Descriptor */
183 : 0 : ft->desc_buf.length = sizeof(struct fsl_qdma_df);
184 : :
185 : : /* Descriptor Buffer */
186 : 0 : sdf->srttype = FSL_QDMA_CMD_RWTTYPE;
187 : : #ifdef RTE_DMA_DPAA_ERRATA_ERR050265
188 : : sdf->prefetch = 1;
189 : : #endif
190 : 0 : ddf->dwttype = FSL_QDMA_CMD_RWTTYPE;
191 : 0 : ddf->lwc = FSL_QDMA_CMD_LWC;
192 : :
193 : 0 : ccdf = &queue->cq[i];
194 : : qdma_desc_addr_set64(ccdf, phy_ft);
195 : 0 : ccdf->format = FSL_QDMA_COMP_SG_FORMAT;
196 [ # # ]: 0 : if (!fsl_qdma->is_silent)
197 : 0 : ccdf->ser = 1;
198 : 0 : ccdf->queue = queue->queue_id;
199 : : }
200 : 0 : queue->ci = 0;
201 : :
202 : 0 : return 0;
203 : :
204 : : fail:
205 [ # # ]: 0 : for (j = 0; j < i; j++)
206 : 0 : rte_free(queue->ft[j]);
207 : :
208 : : return -ENOMEM;
209 : : }
210 : :
211 : : static int
212 : 0 : fsl_qdma_alloc_queue_resources(struct fsl_qdma_engine *fsl_qdma,
213 : : int queue_id, int block_id)
214 : : {
215 : : struct fsl_qdma_queue *cmd_queue;
216 : : uint32_t queue_size;
217 : : char nm[RTE_MEMZONE_NAMESIZE];
218 : :
219 : : cmd_queue = &fsl_qdma->cmd_queues[block_id][queue_id];
220 : 0 : cmd_queue->engine = fsl_qdma;
221 : :
222 : : queue_size = sizeof(struct fsl_qdma_comp_cmd_desc) *
223 : : QDMA_QUEUE_SIZE;
224 : :
225 : : sprintf(nm, "Command queue_%d_%d",
226 : : block_id, queue_id);
227 : 0 : cmd_queue->cq = dma_pool_alloc(nm, queue_size,
228 : : queue_size, &cmd_queue->bus_addr);
229 [ # # ]: 0 : if (!cmd_queue->cq) {
230 : 0 : DPAA_QDMA_ERR("%s alloc failed!", nm);
231 : 0 : return -ENOMEM;
232 : : }
233 : :
234 : 0 : cmd_queue->block_vir = fsl_qdma->block_base +
235 : 0 : FSL_QDMA_BLOCK_BASE_OFFSET(fsl_qdma, block_id);
236 : 0 : cmd_queue->n_cq = QDMA_QUEUE_SIZE;
237 : 0 : cmd_queue->queue_id = queue_id;
238 : 0 : cmd_queue->block_id = block_id;
239 : 0 : cmd_queue->pending_start = 0;
240 : 0 : cmd_queue->pending_num = 0;
241 : 0 : cmd_queue->complete_start = 0;
242 : :
243 : : sprintf(nm, "Compound Table_%d_%d",
244 : : block_id, queue_id);
245 : 0 : cmd_queue->ft = rte_zmalloc(nm,
246 : : sizeof(void *) * QDMA_QUEUE_SIZE, 0);
247 [ # # ]: 0 : if (!cmd_queue->ft) {
248 : 0 : DPAA_QDMA_ERR("%s zmalloc failed!", nm);
249 : 0 : rte_free(cmd_queue->cq);
250 : 0 : return -ENOMEM;
251 : : }
252 : : sprintf(nm, "Pending_desc_%d_%d",
253 : : block_id, queue_id);
254 : 0 : cmd_queue->pending_desc = rte_zmalloc(nm,
255 : : sizeof(struct fsl_qdma_desc) * FSL_QDMA_MAX_DESC_NUM, 0);
256 [ # # ]: 0 : if (!cmd_queue->pending_desc) {
257 : 0 : DPAA_QDMA_ERR("%s zmalloc failed!", nm);
258 : 0 : rte_free(cmd_queue->ft);
259 : 0 : rte_free(cmd_queue->cq);
260 : 0 : return -ENOMEM;
261 : : }
262 : : sprintf(nm, "complete-burst_ring_%d_%d",
263 : : block_id, queue_id);
264 : 0 : cmd_queue->complete_burst = rte_ring_create(nm,
265 : : QDMA_QUEUE_SIZE * 2, 0,
266 : : RING_F_SP_ENQ | RING_F_SC_DEQ);
267 [ # # ]: 0 : if (!cmd_queue->complete_burst) {
268 : 0 : DPAA_QDMA_ERR("%s create failed!", nm);
269 : 0 : rte_free(cmd_queue->pending_desc);
270 : 0 : rte_free(cmd_queue->ft);
271 : 0 : rte_free(cmd_queue->cq);
272 : 0 : return -ENOMEM;
273 : : }
274 : : sprintf(nm, "complete-desc_ring_%d_%d",
275 : : block_id, queue_id);
276 : 0 : cmd_queue->complete_desc = rte_ring_create(nm,
277 : : FSL_QDMA_MAX_DESC_NUM * 2, 0,
278 : : RING_F_SP_ENQ | RING_F_SC_DEQ);
279 [ # # ]: 0 : if (!cmd_queue->complete_desc) {
280 : 0 : DPAA_QDMA_ERR("%s create failed!", nm);
281 : 0 : rte_ring_free(cmd_queue->complete_burst);
282 : 0 : rte_free(cmd_queue->pending_desc);
283 : 0 : rte_free(cmd_queue->ft);
284 : 0 : rte_free(cmd_queue->cq);
285 : 0 : return -ENOMEM;
286 : : }
287 : : sprintf(nm, "complete-pool-desc_ring_%d_%d",
288 : : block_id, queue_id);
289 : 0 : cmd_queue->complete_pool = rte_ring_create(nm,
290 : : FSL_QDMA_MAX_DESC_NUM * 2, 0,
291 : : RING_F_SP_ENQ | RING_F_SC_DEQ);
292 [ # # ]: 0 : if (!cmd_queue->complete_pool) {
293 : 0 : DPAA_QDMA_ERR("%s create failed!", nm);
294 : 0 : rte_ring_free(cmd_queue->complete_desc);
295 : 0 : rte_ring_free(cmd_queue->complete_burst);
296 : 0 : rte_free(cmd_queue->pending_desc);
297 : 0 : rte_free(cmd_queue->ft);
298 : 0 : rte_free(cmd_queue->cq);
299 : 0 : return -ENOMEM;
300 : : }
301 : :
302 : 0 : memset(&cmd_queue->stats, 0, sizeof(struct rte_dma_stats));
303 : 0 : cmd_queue->pending_max = FSL_QDMA_MAX_DESC_NUM;
304 : :
305 : 0 : return 0;
306 : : }
307 : :
308 : : static void
309 : 0 : fsl_qdma_free_cmdq_res(struct fsl_qdma_queue *queue)
310 : : {
311 : 0 : rte_free(queue->ft);
312 : 0 : rte_free(queue->cq);
313 : 0 : rte_free(queue->pending_desc);
314 : 0 : rte_ring_free(queue->complete_burst);
315 : 0 : rte_ring_free(queue->complete_desc);
316 : 0 : rte_ring_free(queue->complete_pool);
317 : 0 : }
318 : :
319 : : static void
320 : : fsl_qdma_free_stq_res(struct fsl_qdma_status_queue *queue)
321 : : {
322 : 0 : rte_free(queue->cq);
323 : : }
324 : :
325 : : static int
326 : 0 : fsl_qdma_prep_status_queue(struct fsl_qdma_engine *fsl_qdma,
327 : : uint32_t block_id)
328 : : {
329 : : struct fsl_qdma_status_queue *status;
330 : : uint32_t status_size;
331 : :
332 : : status = &fsl_qdma->stat_queues[block_id];
333 : 0 : status->engine = fsl_qdma;
334 : :
335 : : status_size = QDMA_STATUS_SIZE *
336 : : sizeof(struct fsl_qdma_comp_cmd_desc);
337 : :
338 : 0 : status->cq = dma_pool_alloc(NULL, status_size,
339 : : status_size, &status->bus_addr);
340 : :
341 [ # # ]: 0 : if (!status->cq)
342 : : return -ENOMEM;
343 : :
344 : : memset(status->cq, 0x0, status_size);
345 : 0 : status->n_cq = QDMA_STATUS_SIZE;
346 : 0 : status->complete = 0;
347 : 0 : status->block_id = block_id;
348 : 0 : status->block_vir = fsl_qdma->block_base +
349 : 0 : FSL_QDMA_BLOCK_BASE_OFFSET(fsl_qdma, block_id);
350 : :
351 : 0 : return 0;
352 : : }
353 : :
354 : : static int
355 : 0 : fsl_qdma_halt(struct fsl_qdma_engine *fsl_qdma)
356 : : {
357 : 0 : void *ctrl = fsl_qdma->ctrl_base;
358 : : void *block;
359 : : int i, count = RETRIES;
360 : : unsigned int j;
361 : : u32 reg;
362 : :
363 : : /* Disable the command queue and wait for idle state. */
364 : : reg = qdma_readl(ctrl + FSL_QDMA_DMR);
365 [ # # ]: 0 : reg |= FSL_QDMA_DMR_DQD;
366 : : qdma_writel(reg, ctrl + FSL_QDMA_DMR);
367 [ # # ]: 0 : for (j = 0; j < fsl_qdma->num_blocks; j++) {
368 : 0 : block = fsl_qdma->block_base +
369 : 0 : FSL_QDMA_BLOCK_BASE_OFFSET(fsl_qdma, j);
370 [ # # ]: 0 : for (i = 0; i < FSL_QDMA_QUEUE_NUM_MAX; i++)
371 : 0 : qdma_writel(0, block + FSL_QDMA_BCQMR(i));
372 : : }
373 : : while (true) {
374 : 0 : reg = qdma_readl(ctrl + FSL_QDMA_DSR);
375 [ # # ]: 0 : if (!(reg & FSL_QDMA_DSR_DB))
376 : : break;
377 [ # # ]: 0 : if (count-- < 0)
378 : : return -EBUSY;
379 : 0 : rte_delay_us(100);
380 : : }
381 : :
382 [ # # ]: 0 : for (j = 0; j < fsl_qdma->num_blocks; j++) {
383 : 0 : block = fsl_qdma->block_base +
384 : 0 : FSL_QDMA_BLOCK_BASE_OFFSET(fsl_qdma, j);
385 : :
386 : : /* Disable status queue. */
387 : : qdma_writel(0, block + FSL_QDMA_BSQMR);
388 : :
389 : : /*
390 : : * clear the command queue interrupt detect register for
391 : : * all queues.
392 : : */
393 : : qdma_writel(0xffffffff, block + FSL_QDMA_BCQIDR(0));
394 : : }
395 : :
396 : : return 0;
397 : : }
398 : :
399 : : static void
400 : 0 : fsl_qdma_data_validation(struct fsl_qdma_desc *desc[],
401 : : uint8_t num, struct fsl_qdma_queue *fsl_queue)
402 : : {
403 : : uint32_t i, j;
404 : : uint8_t *v_src, *v_dst;
405 : : char err_msg[512];
406 : : int offset;
407 : :
408 [ # # ]: 0 : if (likely(!s_data_validation))
409 : 0 : return;
410 : :
411 : 0 : offset = sprintf(err_msg, "Fatal TC%d/queue%d: ",
412 : 0 : fsl_queue->block_id,
413 : 0 : fsl_queue->queue_id);
414 [ # # ]: 0 : for (i = 0; i < num; i++) {
415 : 0 : v_src = rte_mem_iova2virt(desc[i]->src);
416 : 0 : v_dst = rte_mem_iova2virt(desc[i]->dst);
417 [ # # ]: 0 : for (j = 0; j < desc[i]->len; j++) {
418 [ # # ]: 0 : if (v_src[j] != v_dst[j]) {
419 : 0 : sprintf(&err_msg[offset],
420 : : "job[%"PRIu64"]:src(%p)[%d](%d)!=dst(%p)[%d](%d)",
421 : : desc[i]->flag, v_src, j, v_src[j],
422 : : v_dst, j, v_dst[j]);
423 : 0 : DPAA_QDMA_ERR("%s, stop validating!",
424 : : err_msg);
425 : 0 : return;
426 : : }
427 : : }
428 : : }
429 : : }
430 : :
431 : : static int
432 : 0 : fsl_qdma_reg_init(struct fsl_qdma_engine *fsl_qdma)
433 : : {
434 : : struct fsl_qdma_queue *temp;
435 : : struct fsl_qdma_status_queue *temp_stat;
436 : 0 : void *ctrl = fsl_qdma->ctrl_base;
437 : : void *block;
438 : : u32 i, j;
439 : : u32 reg;
440 : : int ret, val;
441 : :
442 : : /* Try to halt the qDMA engine first. */
443 : 0 : ret = fsl_qdma_halt(fsl_qdma);
444 [ # # ]: 0 : if (ret) {
445 : 0 : DPAA_QDMA_ERR("DMA halt failed!");
446 : 0 : return ret;
447 : : }
448 : :
449 [ # # ]: 0 : for (j = 0; j < fsl_qdma->num_blocks; j++) {
450 : 0 : block = fsl_qdma->block_base +
451 : 0 : FSL_QDMA_BLOCK_BASE_OFFSET(fsl_qdma, j);
452 [ # # ]: 0 : for (i = 0; i < QDMA_QUEUES; i++) {
453 : : temp = &fsl_qdma->cmd_queues[j][i];
454 : : /*
455 : : * Initialize Command Queue registers to
456 : : * point to the first
457 : : * command descriptor in memory.
458 : : * Dequeue Pointer Address Registers
459 : : * Enqueue Pointer Address Registers
460 : : */
461 : :
462 : 0 : qdma_writel(lower_32_bits(temp->bus_addr),
463 [ # # ]: 0 : block + FSL_QDMA_BCQDPA_SADDR(i));
464 : 0 : qdma_writel(upper_32_bits(temp->bus_addr),
465 [ # # ]: 0 : block + FSL_QDMA_BCQEDPA_SADDR(i));
466 : 0 : qdma_writel(lower_32_bits(temp->bus_addr),
467 [ # # ]: 0 : block + FSL_QDMA_BCQEPA_SADDR(i));
468 : 0 : qdma_writel(upper_32_bits(temp->bus_addr),
469 [ # # ]: 0 : block + FSL_QDMA_BCQEEPA_SADDR(i));
470 : :
471 : : /* Initialize the queue mode. */
472 : : reg = FSL_QDMA_BCQMR_EN;
473 : 0 : reg |= FSL_QDMA_BCQMR_CD_THLD(ilog2_qthld(temp->n_cq));
474 : 0 : reg |= FSL_QDMA_BCQMR_CQ_SIZE(ilog2_qsize(temp->n_cq));
475 : 0 : temp->le_cqmr = reg;
476 [ # # ]: 0 : qdma_writel(reg, block + FSL_QDMA_BCQMR(i));
477 : : }
478 : :
479 : : /*
480 : : * Workaround for erratum: ERR010812.
481 : : * We must enable XOFF to avoid the enqueue rejection occurs.
482 : : * Setting SQCCMR ENTER_WM to 0x20.
483 : : */
484 : :
485 : : qdma_writel(FSL_QDMA_SQCCMR_ENTER_WM,
486 : : block + FSL_QDMA_SQCCMR);
487 : :
488 : : /*
489 : : * Initialize status queue registers to point to the first
490 : : * command descriptor in memory.
491 : : * Dequeue Pointer Address Registers
492 : : * Enqueue Pointer Address Registers
493 : : */
494 : :
495 : : temp_stat = &fsl_qdma->stat_queues[j];
496 [ # # ]: 0 : qdma_writel(upper_32_bits(temp_stat->bus_addr),
497 : : block + FSL_QDMA_SQEEPAR);
498 [ # # ]: 0 : qdma_writel(lower_32_bits(temp_stat->bus_addr),
499 : : block + FSL_QDMA_SQEPAR);
500 [ # # ]: 0 : qdma_writel(upper_32_bits(temp_stat->bus_addr),
501 : : block + FSL_QDMA_SQEDPAR);
502 [ # # ]: 0 : qdma_writel(lower_32_bits(temp_stat->bus_addr),
503 : : block + FSL_QDMA_SQDPAR);
504 : : /* Desiable status queue interrupt. */
505 : :
506 : : qdma_writel(0x0, block + FSL_QDMA_BCQIER(0));
507 : : qdma_writel(0x0, block + FSL_QDMA_BSQICR);
508 : : qdma_writel(0x0, block + FSL_QDMA_CQIER);
509 : :
510 : : /* Initialize the status queue mode. */
511 : : reg = FSL_QDMA_BSQMR_EN;
512 : 0 : val = ilog2_qsize(temp_stat->n_cq);
513 [ # # ]: 0 : reg |= FSL_QDMA_BSQMR_CQ_SIZE(val);
514 : : qdma_writel(reg, block + FSL_QDMA_BSQMR);
515 : : }
516 : :
517 : : reg = qdma_readl(ctrl + FSL_QDMA_DMR);
518 [ # # ]: 0 : reg &= ~FSL_QDMA_DMR_DQD;
519 : : qdma_writel(reg, ctrl + FSL_QDMA_DMR);
520 : :
521 : 0 : return 0;
522 : : }
523 : :
524 : : static uint16_t
525 : 0 : dpaa_qdma_block_dequeue(struct fsl_qdma_engine *fsl_qdma,
526 : : uint8_t block_id)
527 : : {
528 : : struct fsl_qdma_status_queue *stat_queue;
529 : : struct fsl_qdma_queue *cmd_queue;
530 : : struct fsl_qdma_comp_cmd_desc *cq;
531 : : uint16_t start, count = 0;
532 : : uint8_t qid = 0;
533 : : uint32_t reg;
534 : : int ret;
535 : : uint8_t *block;
536 : : uint16_t *dq_complete;
537 : : struct fsl_qdma_desc *desc[FSL_QDMA_SG_MAX_ENTRY];
538 : :
539 : 0 : stat_queue = &fsl_qdma->stat_queues[block_id];
540 : 0 : cq = stat_queue->cq;
541 : 0 : start = stat_queue->complete;
542 : :
543 : 0 : block = fsl_qdma->block_base +
544 : 0 : FSL_QDMA_BLOCK_BASE_OFFSET(fsl_qdma, block_id);
545 : :
546 : : do {
547 : 0 : reg = qdma_readl_be(block + FSL_QDMA_BSQSR);
548 [ # # ]: 0 : if (reg & FSL_QDMA_BSQSR_QE_BE)
549 : : break;
550 : :
551 : : qdma_writel_be(FSL_QDMA_BSQMR_DI, block + FSL_QDMA_BSQMR);
552 [ # # ]: 0 : ret = qdma_ccdf_get_queue(&cq[start], &qid);
553 : : if (ret == true) {
554 : 0 : cmd_queue = &fsl_qdma->cmd_queues[block_id][qid];
555 : :
556 [ # # # # : 0 : ret = rte_ring_dequeue(cmd_queue->complete_burst,
# ]
557 : : (void **)&dq_complete);
558 : : if (ret) {
559 : 0 : DPAA_QDMA_ERR("DQ desc number failed!");
560 : 0 : break;
561 : : }
562 : :
563 : 0 : ret = rte_ring_dequeue_bulk(cmd_queue->complete_desc,
564 [ # # # # : 0 : (void **)desc, *dq_complete, NULL);
# ]
565 [ # # ]: 0 : if (ret != (*dq_complete)) {
566 : 0 : DPAA_QDMA_ERR("DQ %d descs failed!(%d)",
567 : : *dq_complete, ret);
568 : 0 : break;
569 : : }
570 : :
571 : 0 : fsl_qdma_data_validation(desc, *dq_complete, cmd_queue);
572 : :
573 : 0 : ret = rte_ring_enqueue_bulk(cmd_queue->complete_pool,
574 [ # # # # : 0 : (void **)desc, (*dq_complete), NULL);
# ]
575 [ # # ]: 0 : if (ret != (*dq_complete)) {
576 : 0 : DPAA_QDMA_ERR("Failed desc eq %d!=%d to %s",
577 : : ret, *dq_complete,
578 : : cmd_queue->complete_pool->name);
579 : 0 : break;
580 : : }
581 : :
582 : 0 : cmd_queue->complete_start =
583 : 0 : (cmd_queue->complete_start + (*dq_complete)) &
584 : 0 : (cmd_queue->pending_max - 1);
585 : 0 : cmd_queue->stats.completed++;
586 : :
587 : 0 : start++;
588 [ # # ]: 0 : if (unlikely(start == stat_queue->n_cq))
589 : : start = 0;
590 : 0 : count++;
591 : : } else {
592 : 0 : DPAA_QDMA_ERR("Block%d not empty but dq-queue failed!",
593 : : block_id);
594 : 0 : break;
595 : : }
596 : : } while (1);
597 : 0 : stat_queue->complete = start;
598 : :
599 : 0 : return count;
600 : : }
601 : :
602 : : static int
603 : 0 : fsl_qdma_enqueue_desc_to_ring(struct fsl_qdma_queue *fsl_queue,
604 : : uint16_t num)
605 : : {
606 : 0 : struct fsl_qdma_engine *fsl_qdma = fsl_queue->engine;
607 : : uint16_t i, idx, start, dq;
608 : : int ret, dq_cnt;
609 : :
610 [ # # ]: 0 : if (fsl_qdma->is_silent)
611 : : return 0;
612 : :
613 : 0 : fsl_queue->desc_in_hw[fsl_queue->ci] = num;
614 : 0 : eq_again:
615 : 0 : ret = rte_ring_enqueue(fsl_queue->complete_burst,
616 [ # # # # : 0 : &fsl_queue->desc_in_hw[fsl_queue->ci]);
# ]
617 : : if (ret) {
618 : : DPAA_QDMA_DP_DEBUG("%s: Queue is full, try dequeue first",
619 : : __func__);
620 : : DPAA_QDMA_DP_DEBUG("%s: submitted:%"PRIu64", completed:%"PRIu64"",
621 : : __func__, fsl_queue->stats.submitted,
622 : : fsl_queue->stats.completed);
623 : : dq_cnt = 0;
624 : : dq_again:
625 : 0 : dq = dpaa_qdma_block_dequeue(fsl_queue->engine,
626 : 0 : fsl_queue->block_id);
627 : 0 : dq_cnt++;
628 [ # # ]: 0 : if (dq > 0) {
629 : 0 : goto eq_again;
630 : : } else {
631 [ # # ]: 0 : if (dq_cnt < 100)
632 : 0 : goto dq_again;
633 : 0 : DPAA_QDMA_ERR("%s: Dq block%d failed!",
634 : : __func__, fsl_queue->block_id);
635 : : }
636 : 0 : return ret;
637 : : }
638 : 0 : start = fsl_queue->pending_start;
639 [ # # ]: 0 : for (i = 0; i < num; i++) {
640 : 0 : idx = (start + i) & (fsl_queue->pending_max - 1);
641 : 0 : ret = rte_ring_enqueue(fsl_queue->complete_desc,
642 [ # # # # : 0 : &fsl_queue->pending_desc[idx]);
# ]
643 : : if (ret) {
644 : 0 : DPAA_QDMA_ERR("Descriptors eq failed!");
645 : 0 : return ret;
646 : : }
647 : : }
648 : :
649 : : return 0;
650 : : }
651 : :
652 : : static int
653 : 0 : fsl_qdma_enqueue_overflow(struct fsl_qdma_queue *fsl_queue)
654 : : {
655 : : int overflow = 0;
656 : : uint32_t reg;
657 : : uint16_t blk_drain, check_num, drain_num;
658 : 0 : uint8_t *block = fsl_queue->block_vir;
659 : : const struct rte_dma_stats *st = &fsl_queue->stats;
660 : 0 : struct fsl_qdma_engine *fsl_qdma = fsl_queue->engine;
661 : :
662 : : check_num = 0;
663 : : overflow_check:
664 [ # # # # ]: 0 : if (fsl_qdma->is_silent || unlikely(s_hw_err_check)) {
665 : 0 : reg = qdma_readl_be(block +
666 : 0 : FSL_QDMA_BCQSR(fsl_queue->queue_id));
667 : 0 : overflow = (reg & FSL_QDMA_BCQSR_QF_XOFF_BE) ?
668 : 0 : 1 : 0;
669 : : } else {
670 : 0 : overflow = (fsl_qdma_queue_bd_in_hw(fsl_queue) >=
671 : 0 : QDMA_QUEUE_CR_WM) ? 1 : 0;
672 : : }
673 : :
674 [ # # ]: 0 : if (likely(!overflow)) {
675 : : return 0;
676 [ # # ]: 0 : } else if (fsl_qdma->is_silent) {
677 : 0 : check_num++;
678 [ # # ]: 0 : if (check_num >= 10000) {
679 : 0 : DPAA_QDMA_WARN("Waiting for HW complete in silent mode");
680 : : check_num = 0;
681 : : }
682 : 0 : goto overflow_check;
683 : : }
684 : :
685 : : DPAA_QDMA_DP_DEBUG("TC%d/Q%d submitted(%"PRIu64")-completed(%"PRIu64") >= %d",
686 : : fsl_queue->block_id, fsl_queue->queue_id,
687 : : st->submitted, st->completed, QDMA_QUEUE_CR_WM);
688 : : drain_num = 0;
689 : :
690 : 0 : drain_again:
691 : 0 : blk_drain = dpaa_qdma_block_dequeue(fsl_qdma,
692 : 0 : fsl_queue->block_id);
693 [ # # ]: 0 : if (!blk_drain) {
694 : 0 : drain_num++;
695 [ # # ]: 0 : if (drain_num >= 10000) {
696 : 0 : DPAA_QDMA_WARN("TC%d failed drain, Q%d's %"PRIu64" bd in HW.",
697 : : fsl_queue->block_id, fsl_queue->queue_id,
698 : : st->submitted - st->completed);
699 : : drain_num = 0;
700 : : }
701 : 0 : goto drain_again;
702 : : }
703 : 0 : check_num++;
704 [ # # ]: 0 : if (check_num >= 1000) {
705 : 0 : DPAA_QDMA_WARN("TC%d failed check, Q%d's %"PRIu64" bd in HW.",
706 : : fsl_queue->block_id, fsl_queue->queue_id,
707 : : st->submitted - st->completed);
708 : : check_num = 0;
709 : : }
710 : 0 : goto overflow_check;
711 : :
712 : : return 0;
713 : : }
714 : :
715 : : static int
716 : 0 : fsl_qdma_enqueue_desc_single(struct fsl_qdma_queue *fsl_queue,
717 : : dma_addr_t dst, dma_addr_t src, size_t len)
718 : : {
719 : 0 : uint8_t *block = fsl_queue->block_vir;
720 : : struct fsl_qdma_comp_sg_desc *csgf_src, *csgf_dest;
721 : : struct fsl_qdma_cmpd_ft *ft;
722 : : int ret;
723 : : #ifdef RTE_DMA_DPAA_ERRATA_ERR050757
724 : : struct fsl_qdma_sdf *sdf;
725 : : #endif
726 : :
727 : 0 : ret = fsl_qdma_enqueue_overflow(fsl_queue);
728 [ # # ]: 0 : if (unlikely(ret))
729 : : return ret;
730 : :
731 : 0 : ft = fsl_queue->ft[fsl_queue->ci];
732 : :
733 : : #ifdef RTE_DMA_DPAA_ERRATA_ERR050757
734 : : if (s_pci_read) {
735 : : sdf = &ft->df.sdf;
736 : : sdf->srttype = FSL_QDMA_CMD_RWTTYPE;
737 : : #ifdef RTE_DMA_DPAA_ERRATA_ERR050265
738 : : sdf->prefetch = 1;
739 : : #endif
740 : : if (len > FSL_QDMA_CMD_SS_ERR050757_LEN) {
741 : : sdf->ssen = 1;
742 : : sdf->sss = FSL_QDMA_CMD_SS_ERR050757_LEN;
743 : : sdf->ssd = FSL_QDMA_CMD_SS_ERR050757_LEN;
744 : : } else {
745 : : sdf->ssen = 0;
746 : : sdf->sss = 0;
747 : : sdf->ssd = 0;
748 : : }
749 : : }
750 : : #endif
751 : : csgf_src = &ft->desc_sbuf;
752 : : csgf_dest = &ft->desc_dbuf;
753 : : qdma_desc_sge_addr_set64(csgf_src, src);
754 : 0 : csgf_src->length = len;
755 : 0 : csgf_src->extion = 0;
756 : : qdma_desc_sge_addr_set64(csgf_dest, dst);
757 : 0 : csgf_dest->length = len;
758 : 0 : csgf_dest->extion = 0;
759 : : /* This entry is the last entry. */
760 : 0 : csgf_dest->final = 1;
761 : :
762 : 0 : ret = fsl_qdma_enqueue_desc_to_ring(fsl_queue, 1);
763 [ # # ]: 0 : if (ret)
764 : : return ret;
765 : 0 : fsl_queue->ci = (fsl_queue->ci + 1) & (fsl_queue->n_cq - 1);
766 : :
767 : 0 : qdma_writel(fsl_queue->le_cqmr | FSL_QDMA_BCQMR_EI,
768 [ # # ]: 0 : block + FSL_QDMA_BCQMR(fsl_queue->queue_id));
769 : 0 : fsl_queue->stats.submitted++;
770 : :
771 : 0 : return 0;
772 : : }
773 : :
774 : : static int
775 : 0 : fsl_qdma_enqueue_desc_sg(struct fsl_qdma_queue *fsl_queue)
776 : : {
777 : 0 : uint8_t *block = fsl_queue->block_vir;
778 : : struct fsl_qdma_comp_sg_desc *csgf_src, *csgf_dest;
779 : : struct fsl_qdma_cmpd_ft *ft;
780 : : uint32_t total_len;
781 : : uint16_t start, idx, num, i, next_idx;
782 : : int ret;
783 : : #ifdef RTE_DMA_DPAA_ERRATA_ERR050757
784 : : struct fsl_qdma_sdf *sdf;
785 : : #endif
786 : :
787 : : eq_sg:
788 : : total_len = 0;
789 : 0 : start = fsl_queue->pending_start;
790 [ # # ]: 0 : if (fsl_queue->pending_desc[start].len > s_sg_max_entry_sz ||
791 [ # # ]: 0 : fsl_queue->pending_num == 1) {
792 : 0 : ret = fsl_qdma_enqueue_desc_single(fsl_queue,
793 : : fsl_queue->pending_desc[start].dst,
794 : : fsl_queue->pending_desc[start].src,
795 : : fsl_queue->pending_desc[start].len);
796 [ # # ]: 0 : if (!ret) {
797 : 0 : fsl_queue->pending_start =
798 : 0 : (start + 1) & (fsl_queue->pending_max - 1);
799 : 0 : fsl_queue->pending_num--;
800 : : }
801 [ # # ]: 0 : if (fsl_queue->pending_num > 0)
802 : 0 : goto eq_sg;
803 : :
804 : 0 : return ret;
805 : : }
806 : :
807 : 0 : ret = fsl_qdma_enqueue_overflow(fsl_queue);
808 [ # # ]: 0 : if (unlikely(ret))
809 : 0 : return ret;
810 : :
811 : 0 : if (fsl_queue->pending_num > FSL_QDMA_SG_MAX_ENTRY)
812 : : num = FSL_QDMA_SG_MAX_ENTRY;
813 : : else
814 : : num = fsl_queue->pending_num;
815 : :
816 : 0 : ft = fsl_queue->ft[fsl_queue->ci];
817 : : csgf_src = &ft->desc_sbuf;
818 : : csgf_dest = &ft->desc_dbuf;
819 : :
820 : 0 : qdma_desc_sge_addr_set64(csgf_src, ft->phy_ssge);
821 : 0 : csgf_src->extion = 1;
822 : 0 : qdma_desc_sge_addr_set64(csgf_dest, ft->phy_dsge);
823 : 0 : csgf_dest->extion = 1;
824 : : /* This entry is the last entry. */
825 : 0 : csgf_dest->final = 1;
826 [ # # ]: 0 : for (i = 0; i < num; i++) {
827 : 0 : idx = (start + i) & (fsl_queue->pending_max - 1);
828 : 0 : qdma_desc_sge_addr_set64(&ft->desc_ssge[i],
829 : 0 : fsl_queue->pending_desc[idx].src);
830 : 0 : ft->desc_ssge[i].length = fsl_queue->pending_desc[idx].len;
831 : 0 : ft->desc_ssge[i].final = 0;
832 : 0 : qdma_desc_sge_addr_set64(&ft->desc_dsge[i],
833 : : fsl_queue->pending_desc[idx].dst);
834 : 0 : ft->desc_dsge[i].length = fsl_queue->pending_desc[idx].len;
835 : 0 : ft->desc_dsge[i].final = 0;
836 : 0 : total_len += fsl_queue->pending_desc[idx].len;
837 [ # # ]: 0 : if ((i + 1) != num) {
838 : 0 : next_idx = (idx + 1) & (fsl_queue->pending_max - 1);
839 [ # # ]: 0 : if (fsl_queue->pending_desc[next_idx].len >
840 : : s_sg_max_entry_sz) {
841 : 0 : num = i + 1;
842 : 0 : break;
843 : : }
844 : : }
845 : : }
846 : :
847 [ # # ]: 0 : if (num == 0 || num > FSL_QDMA_SG_MAX_ENTRY) {
848 : 0 : DPAA_QDMA_ERR("Invalid scatter-gather entry count: num=%u", num);
849 : 0 : return -EINVAL;
850 : : }
851 : :
852 : 0 : ft->desc_ssge[num - 1].final = 1;
853 : 0 : ft->desc_dsge[num - 1].final = 1;
854 : 0 : csgf_src->length = total_len;
855 : 0 : csgf_dest->length = total_len;
856 : : #ifdef RTE_DMA_DPAA_ERRATA_ERR050757
857 : : if (s_pci_read) {
858 : : sdf = &ft->df.sdf;
859 : : sdf->srttype = FSL_QDMA_CMD_RWTTYPE;
860 : : #ifdef RTE_DMA_DPAA_ERRATA_ERR050265
861 : : sdf->prefetch = 1;
862 : : #endif
863 : : if (total_len > FSL_QDMA_CMD_SS_ERR050757_LEN) {
864 : : sdf->ssen = 1;
865 : : sdf->sss = FSL_QDMA_CMD_SS_ERR050757_LEN;
866 : : sdf->ssd = FSL_QDMA_CMD_SS_ERR050757_LEN;
867 : : } else {
868 : : sdf->ssen = 0;
869 : : sdf->sss = 0;
870 : : sdf->ssd = 0;
871 : : }
872 : : }
873 : : #endif
874 : 0 : ret = fsl_qdma_enqueue_desc_to_ring(fsl_queue, num);
875 [ # # ]: 0 : if (ret)
876 : 0 : return ret;
877 : :
878 : 0 : fsl_queue->ci = (fsl_queue->ci + 1) & (fsl_queue->n_cq - 1);
879 : :
880 : 0 : qdma_writel(fsl_queue->le_cqmr | FSL_QDMA_BCQMR_EI,
881 [ # # ]: 0 : block + FSL_QDMA_BCQMR(fsl_queue->queue_id));
882 : 0 : fsl_queue->stats.submitted++;
883 : :
884 : 0 : fsl_queue->pending_start =
885 : 0 : (start + num) & (fsl_queue->pending_max - 1);
886 : 0 : fsl_queue->pending_num -= num;
887 [ # # ]: 0 : if (fsl_queue->pending_num > 0)
888 : 0 : goto eq_sg;
889 : :
890 : : return 0;
891 : : }
892 : :
893 : : static int
894 : 0 : fsl_qdma_enqueue_desc(struct fsl_qdma_queue *fsl_queue)
895 : : {
896 : 0 : uint16_t start = fsl_queue->pending_start;
897 : : int ret;
898 : :
899 [ # # ]: 0 : if (fsl_queue->pending_num == 1) {
900 : 0 : ret = fsl_qdma_enqueue_desc_single(fsl_queue,
901 : : fsl_queue->pending_desc[start].dst,
902 : : fsl_queue->pending_desc[start].src,
903 : 0 : fsl_queue->pending_desc[start].len);
904 [ # # ]: 0 : if (!ret) {
905 : 0 : fsl_queue->pending_start =
906 : 0 : (start + 1) & (fsl_queue->pending_max - 1);
907 : 0 : fsl_queue->pending_num = 0;
908 : : }
909 : 0 : return ret;
910 [ # # ]: 0 : } else if (!s_sg_enable) {
911 [ # # ]: 0 : while (fsl_queue->pending_num > 0) {
912 : 0 : ret = fsl_qdma_enqueue_desc_single(fsl_queue,
913 : : fsl_queue->pending_desc[start].dst,
914 : : fsl_queue->pending_desc[start].src,
915 : 0 : fsl_queue->pending_desc[start].len);
916 [ # # ]: 0 : if (!ret) {
917 : 0 : start = (start + 1) &
918 : 0 : (fsl_queue->pending_max - 1);
919 : 0 : fsl_queue->pending_start = start;
920 : 0 : fsl_queue->pending_num--;
921 : : } else {
922 : : /* Transient on a full ring; caller retries. */
923 : 0 : return ret;
924 : : }
925 : : }
926 : :
927 : : return 0;
928 : : }
929 : :
930 : 0 : return fsl_qdma_enqueue_desc_sg(fsl_queue);
931 : : }
932 : :
933 : : static int
934 : 0 : dpaa_qdma_info_get(const struct rte_dma_dev *dev,
935 : : struct rte_dma_info *dev_info, __rte_unused uint32_t info_sz)
936 : : {
937 : 0 : struct fsl_qdma_engine *fsl_qdma = dev->data->dev_private;
938 : :
939 : : dev_info->dev_capa = RTE_DMA_CAPA_MEM_TO_MEM |
940 : : RTE_DMA_CAPA_SILENT | RTE_DMA_CAPA_OPS_COPY |
941 : : RTE_DMA_CAPA_OPS_COPY_SG;
942 : 0 : dev_info->dev_capa |= DPAA_QDMA_FLAGS_INDEX;
943 : 0 : dev_info->max_vchans = fsl_qdma->n_queues;
944 : 0 : dev_info->max_desc = FSL_QDMA_MAX_DESC_NUM;
945 : 0 : dev_info->min_desc = QDMA_QUEUE_SIZE;
946 : 0 : dev_info->max_sges = FSL_QDMA_SG_MAX_ENTRY;
947 : :
948 : 0 : return 0;
949 : : }
950 : :
951 : : static int
952 : 0 : dpaa_get_channel(struct fsl_qdma_engine *fsl_qdma,
953 : : uint16_t vchan)
954 : : {
955 : : int ret, i, j, found = 0;
956 : 0 : struct fsl_qdma_queue *fsl_queue = fsl_qdma->chan[vchan];
957 : :
958 [ # # ]: 0 : if (fsl_queue) {
959 : : found = 1;
960 : 0 : goto queue_found;
961 : : }
962 : :
963 [ # # ]: 0 : for (i = 0; i < QDMA_BLOCKS; i++) {
964 [ # # ]: 0 : for (j = 0; j < QDMA_QUEUES; j++) {
965 : 0 : fsl_queue = &fsl_qdma->cmd_queues[i][j];
966 : :
967 [ # # ]: 0 : if (fsl_queue->channel_id == vchan) {
968 : : found = 1;
969 : 0 : fsl_qdma->chan[vchan] = fsl_queue;
970 : 0 : goto queue_found;
971 : : }
972 : : }
973 : : }
974 : :
975 : 0 : queue_found:
976 : : if (!found)
977 : : return -ENXIO;
978 : :
979 [ # # ]: 0 : if (fsl_queue->used)
980 : : return 0;
981 : :
982 : 0 : ret = fsl_qdma_pre_comp_sd_desc(fsl_queue);
983 [ # # ]: 0 : if (ret)
984 : : return ret;
985 : :
986 : 0 : fsl_queue->used = 1;
987 : 0 : fsl_qdma->block_queues[fsl_queue->block_id]++;
988 : :
989 : 0 : return 0;
990 : : }
991 : :
992 : : static int
993 : 0 : dpaa_qdma_configure(struct rte_dma_dev *dmadev,
994 : : const struct rte_dma_conf *dev_conf,
995 : : __rte_unused uint32_t conf_sz)
996 : : {
997 : 0 : struct fsl_qdma_engine *fsl_qdma = dmadev->data->dev_private;
998 : :
999 : 0 : fsl_qdma->is_silent = dev_conf->flags & RTE_DMA_CFG_FLAG_SILENT;
1000 : 0 : return 0;
1001 : : }
1002 : :
1003 : : static int
1004 : 0 : dpaa_qdma_start(__rte_unused struct rte_dma_dev *dev)
1005 : : {
1006 : 0 : return 0;
1007 : : }
1008 : :
1009 : : static int
1010 : 0 : dpaa_qdma_close(struct rte_dma_dev *dmadev)
1011 : : {
1012 : 0 : struct fsl_qdma_engine *fsl_qdma = dmadev->data->dev_private;
1013 : : uint32_t i, j, regs_size;
1014 : :
1015 : 0 : regs_size = fsl_qdma->block_offset * fsl_qdma->num_blocks;
1016 : 0 : regs_size += (QDMA_CTRL_REGION_SIZE + QDMA_STATUS_REGION_SIZE);
1017 : :
1018 [ # # ]: 0 : for (i = 0; i < QDMA_BLOCKS; i++)
1019 : : fsl_qdma_free_stq_res(&fsl_qdma->stat_queues[i]);
1020 : :
1021 [ # # ]: 0 : for (i = 0; i < QDMA_BLOCKS; i++) {
1022 [ # # ]: 0 : for (j = 0; j < QDMA_QUEUES; j++)
1023 : 0 : fsl_qdma_free_cmdq_res(&fsl_qdma->cmd_queues[i][j]);
1024 : : }
1025 : :
1026 : 0 : munmap(fsl_qdma->ctrl_base, regs_size);
1027 : :
1028 : 0 : return 0;
1029 : : }
1030 : :
1031 : : static int
1032 : 0 : dpaa_qdma_queue_setup(struct rte_dma_dev *dmadev,
1033 : : uint16_t vchan,
1034 : : __rte_unused const struct rte_dma_vchan_conf *conf,
1035 : : __rte_unused uint32_t conf_sz)
1036 : : {
1037 : 0 : struct fsl_qdma_engine *fsl_qdma = dmadev->data->dev_private;
1038 : :
1039 : 0 : return dpaa_get_channel(fsl_qdma, vchan);
1040 : : }
1041 : :
1042 : : static int
1043 : 0 : dpaa_qdma_submit(void *dev_private, uint16_t vchan)
1044 : : {
1045 : : struct fsl_qdma_engine *fsl_qdma = dev_private;
1046 : 0 : struct fsl_qdma_queue *fsl_queue = fsl_qdma->chan[vchan];
1047 : :
1048 [ # # ]: 0 : if (!fsl_queue->pending_num)
1049 : : return 0;
1050 : :
1051 : 0 : return fsl_qdma_enqueue_desc(fsl_queue);
1052 : : }
1053 : :
1054 : : static int
1055 : 0 : dpaa_qdma_enqueue(void *dev_private, uint16_t vchan,
1056 : : rte_iova_t src, rte_iova_t dst,
1057 : : uint32_t length, uint64_t flags)
1058 : : {
1059 : : struct fsl_qdma_engine *fsl_qdma = dev_private;
1060 : 0 : struct fsl_qdma_queue *fsl_queue = fsl_qdma->chan[vchan];
1061 : 0 : uint16_t start = fsl_queue->pending_start;
1062 : 0 : uint8_t pending = fsl_queue->pending_num;
1063 : : uint16_t idx;
1064 : : int ret;
1065 : :
1066 [ # # ]: 0 : if (pending >= fsl_queue->pending_max) {
1067 : 0 : DPAA_QDMA_ERR("Too many pending jobs(%d) on queue%d",
1068 : : pending, vchan);
1069 : 0 : return -ENOSPC;
1070 : : }
1071 : 0 : idx = (start + pending) & (fsl_queue->pending_max - 1);
1072 : :
1073 : 0 : fsl_queue->pending_desc[idx].src = src;
1074 : 0 : fsl_queue->pending_desc[idx].dst = dst;
1075 : 0 : fsl_queue->pending_desc[idx].flag =
1076 : 0 : DPAA_QDMA_IDX_FROM_FLAG(flags);
1077 : 0 : fsl_queue->pending_desc[idx].len = length;
1078 : 0 : fsl_queue->pending_num++;
1079 : :
1080 [ # # ]: 0 : if (!(flags & RTE_DMA_OP_FLAG_SUBMIT))
1081 : 0 : return idx;
1082 : :
1083 : 0 : ret = fsl_qdma_enqueue_desc(fsl_queue);
1084 [ # # ]: 0 : if (!ret)
1085 : 0 : return fsl_queue->pending_start;
1086 : :
1087 : : return ret;
1088 : : }
1089 : :
1090 : : static int
1091 : 0 : dpaa_qdma_copy_sg(void *dev_private,
1092 : : uint16_t vchan,
1093 : : const struct rte_dma_sge *src,
1094 : : const struct rte_dma_sge *dst,
1095 : : uint16_t nb_src, uint16_t nb_dst,
1096 : : uint64_t flags)
1097 : : {
1098 : : int ret;
1099 : : uint16_t i, start, idx;
1100 : : struct fsl_qdma_engine *fsl_qdma = dev_private;
1101 : 0 : struct fsl_qdma_queue *fsl_queue = fsl_qdma->chan[vchan];
1102 : : const uint16_t *idx_addr = NULL;
1103 : :
1104 [ # # ]: 0 : if (unlikely(nb_src != nb_dst)) {
1105 : 0 : DPAA_QDMA_ERR("%s: nb_src(%d) != nb_dst(%d) on queue%d",
1106 : : __func__, nb_src, nb_dst, vchan);
1107 : 0 : return -EINVAL;
1108 : : }
1109 : :
1110 [ # # ]: 0 : if ((fsl_queue->pending_num + nb_src) > FSL_QDMA_SG_MAX_ENTRY) {
1111 : 0 : DPAA_QDMA_ERR("Too many pending jobs on queue%d",
1112 : : vchan);
1113 : 0 : return -ENOSPC;
1114 : : }
1115 : 0 : start = fsl_queue->pending_start + fsl_queue->pending_num;
1116 : 0 : start = start & (fsl_queue->pending_max - 1);
1117 : : idx = start;
1118 : :
1119 : 0 : idx_addr = DPAA_QDMA_IDXADDR_FROM_SG_FLAG(flags);
1120 : :
1121 [ # # ]: 0 : for (i = 0; i < nb_src; i++) {
1122 [ # # ]: 0 : if (unlikely(src[i].length != dst[i].length)) {
1123 : 0 : DPAA_QDMA_ERR("src.len(%d) != dst.len(%d)",
1124 : : src[i].length, dst[i].length);
1125 : 0 : return -EINVAL;
1126 : : }
1127 : 0 : idx = (start + i) & (fsl_queue->pending_max - 1);
1128 : 0 : fsl_queue->pending_desc[idx].src = src[i].addr;
1129 : 0 : fsl_queue->pending_desc[idx].dst = dst[i].addr;
1130 : 0 : fsl_queue->pending_desc[idx].len = dst[i].length;
1131 : 0 : fsl_queue->pending_desc[idx].flag = idx_addr[i];
1132 : : }
1133 : 0 : fsl_queue->pending_num += nb_src;
1134 : :
1135 [ # # ]: 0 : if (!(flags & RTE_DMA_OP_FLAG_SUBMIT))
1136 : 0 : return idx;
1137 : :
1138 : 0 : ret = fsl_qdma_enqueue_desc(fsl_queue);
1139 [ # # ]: 0 : if (!ret)
1140 : 0 : return fsl_queue->pending_start;
1141 : :
1142 : : return ret;
1143 : : }
1144 : :
1145 : : static int
1146 : 0 : dpaa_qdma_err_handle(struct fsl_qdma_err_reg *reg)
1147 : : {
1148 : : struct fsl_qdma_err_reg local;
1149 : : size_t i, offset = 0;
1150 : : char err_msg[512];
1151 : :
1152 : : local.dedr_be = rte_read32(®->dedr_be);
1153 [ # # ]: 0 : if (!local.dedr_be)
1154 : : return 0;
1155 : 0 : offset = sprintf(err_msg, "ERR detected:");
1156 [ # # ]: 0 : if (local.dedr.ere) {
1157 : 0 : offset += sprintf(&err_msg[offset],
1158 : : " ere(Enqueue rejection error)");
1159 : : }
1160 [ # # ]: 0 : if (local.dedr.dde) {
1161 : 0 : offset += sprintf(&err_msg[offset],
1162 : : " dde(Destination descriptor error)");
1163 : : }
1164 [ # # ]: 0 : if (local.dedr.sde) {
1165 : 0 : offset += sprintf(&err_msg[offset],
1166 : : " sde(Source descriptor error)");
1167 : : }
1168 [ # # ]: 0 : if (local.dedr.cde) {
1169 : 0 : offset += sprintf(&err_msg[offset],
1170 : : " cde(Command descriptor error)");
1171 : : }
1172 [ # # ]: 0 : if (local.dedr.wte) {
1173 : 0 : offset += sprintf(&err_msg[offset],
1174 : : " wte(Write transaction error)");
1175 : : }
1176 [ # # ]: 0 : if (local.dedr.rte) {
1177 : 0 : offset += sprintf(&err_msg[offset],
1178 : : " rte(Read transaction error)");
1179 : : }
1180 [ # # ]: 0 : if (local.dedr.me) {
1181 : 0 : offset += sprintf(&err_msg[offset],
1182 : : " me(Multiple errors of the same type)");
1183 : : }
1184 : 0 : DPAA_QDMA_ERR("%s", err_msg);
1185 [ # # ]: 0 : for (i = 0; i < FSL_QDMA_DECCD_ERR_NUM; i++) {
1186 : 0 : local.deccd_le[FSL_QDMA_DECCD_ERR_NUM - 1 - i] =
1187 : : QDMA_IN(®->deccd_le[i]);
1188 : : }
1189 : 0 : local.deccqidr_be = rte_read32(®->deccqidr_be);
1190 : : local.decbr = rte_read32(®->decbr);
1191 : :
1192 : 0 : offset = sprintf(err_msg, "ERR command:");
1193 : 0 : offset += sprintf(&err_msg[offset],
1194 : : " status: %02x, ser: %d, offset:%d, fmt: %02x",
1195 : 0 : local.err_cmd.status, local.err_cmd.ser,
1196 : 0 : local.err_cmd.offset, local.err_cmd.format);
1197 : 0 : offset += sprintf(&err_msg[offset],
1198 : : " address: 0x%"PRIx64", queue: %d, dd: %02x",
1199 : 0 : (uint64_t)local.err_cmd.addr_hi << 32 |
1200 : 0 : local.err_cmd.addr_lo,
1201 : 0 : local.err_cmd.queue, local.err_cmd.dd);
1202 : 0 : DPAA_QDMA_ERR("%s", err_msg);
1203 : 0 : DPAA_QDMA_ERR("ERR command block: %d, queue: %d",
1204 : : local.deccqidr.block, local.deccqidr.queue);
1205 : :
1206 : : rte_write32(local.dedr_be, ®->dedr_be);
1207 : :
1208 : 0 : return -EIO;
1209 : : }
1210 : :
1211 : : static uint16_t
1212 : 0 : dpaa_qdma_dequeue_status(void *dev_private, uint16_t vchan,
1213 : : const uint16_t nb_cpls, uint16_t *last_idx,
1214 : : enum rte_dma_status_code *st)
1215 : 0 : {
1216 : : struct fsl_qdma_engine *fsl_qdma = dev_private;
1217 : : int err;
1218 : 0 : struct fsl_qdma_queue *fsl_queue = fsl_qdma->chan[vchan];
1219 : 0 : void *status = fsl_qdma->status_base;
1220 : 0 : struct fsl_qdma_desc *desc_complete[nb_cpls];
1221 : : uint16_t i, dq_num;
1222 : :
1223 [ # # ]: 0 : if (unlikely(fsl_qdma->is_silent)) {
1224 : 0 : DPAA_QDMA_WARN("Can't dq in silent mode");
1225 : :
1226 : 0 : return 0;
1227 : : }
1228 : :
1229 : 0 : dq_num = dpaa_qdma_block_dequeue(fsl_qdma,
1230 : 0 : fsl_queue->block_id);
1231 : : DPAA_QDMA_DP_DEBUG("%s: block dq(%d)",
1232 : : __func__, dq_num);
1233 : :
1234 [ # # # # : 0 : dq_num = rte_ring_dequeue_burst(fsl_queue->complete_pool,
# ]
1235 : : (void **)desc_complete, nb_cpls, NULL);
1236 [ # # ]: 0 : for (i = 0; i < dq_num; i++)
1237 : 0 : last_idx[i] = desc_complete[i]->flag;
1238 : :
1239 [ # # ]: 0 : if (st) {
1240 [ # # ]: 0 : for (i = 0; i < dq_num; i++)
1241 : 0 : st[i] = RTE_DMA_STATUS_SUCCESSFUL;
1242 : : }
1243 : :
1244 [ # # ]: 0 : if (s_hw_err_check) {
1245 : 0 : err = dpaa_qdma_err_handle(status +
1246 : : FSL_QDMA_ERR_REG_STATUS_OFFSET);
1247 [ # # ]: 0 : if (err)
1248 : 0 : fsl_queue->stats.errors++;
1249 : : }
1250 : :
1251 : : return dq_num;
1252 : : }
1253 : :
1254 : : static uint16_t
1255 : 0 : dpaa_qdma_dequeue(void *dev_private,
1256 : : uint16_t vchan, const uint16_t nb_cpls,
1257 : : uint16_t *last_idx, bool *has_error)
1258 : 0 : {
1259 : : struct fsl_qdma_engine *fsl_qdma = dev_private;
1260 : : int err;
1261 : 0 : struct fsl_qdma_queue *fsl_queue = fsl_qdma->chan[vchan];
1262 : 0 : void *status = fsl_qdma->status_base;
1263 : 0 : struct fsl_qdma_desc *desc_complete[nb_cpls];
1264 : : uint16_t i, dq_num;
1265 : :
1266 [ # # ]: 0 : if (unlikely(fsl_qdma->is_silent)) {
1267 : 0 : DPAA_QDMA_WARN("Can't dq in silent mode");
1268 : :
1269 : 0 : return 0;
1270 : : }
1271 : :
1272 : 0 : *has_error = false;
1273 : 0 : dq_num = dpaa_qdma_block_dequeue(fsl_qdma,
1274 : 0 : fsl_queue->block_id);
1275 : : DPAA_QDMA_DP_DEBUG("%s: block dq(%d)",
1276 : : __func__, dq_num);
1277 : :
1278 [ # # # # : 0 : dq_num = rte_ring_dequeue_burst(fsl_queue->complete_pool,
# ]
1279 : : (void **)desc_complete, nb_cpls, NULL);
1280 [ # # ]: 0 : for (i = 0; i < dq_num; i++)
1281 : 0 : last_idx[i] = desc_complete[i]->flag;
1282 : :
1283 [ # # ]: 0 : if (s_hw_err_check) {
1284 : 0 : err = dpaa_qdma_err_handle(status +
1285 : : FSL_QDMA_ERR_REG_STATUS_OFFSET);
1286 [ # # ]: 0 : if (err) {
1287 : : if (has_error)
1288 : 0 : *has_error = true;
1289 : 0 : fsl_queue->stats.errors++;
1290 : : }
1291 : : }
1292 : :
1293 : : return dq_num;
1294 : : }
1295 : :
1296 : : static int
1297 : 0 : dpaa_qdma_stats_get(const struct rte_dma_dev *dmadev,
1298 : : uint16_t vchan, struct rte_dma_stats *rte_stats, uint32_t size)
1299 : : {
1300 : 0 : struct fsl_qdma_engine *fsl_qdma = dmadev->data->dev_private;
1301 : 0 : struct fsl_qdma_queue *fsl_queue = fsl_qdma->chan[vchan];
1302 : : struct rte_dma_stats *stats = &fsl_queue->stats;
1303 : :
1304 [ # # ]: 0 : if (size < sizeof(rte_stats))
1305 : : return -EINVAL;
1306 [ # # ]: 0 : if (rte_stats == NULL)
1307 : : return -EINVAL;
1308 : :
1309 : 0 : *rte_stats = *stats;
1310 : :
1311 : 0 : return 0;
1312 : : }
1313 : :
1314 : : static int
1315 : 0 : dpaa_qdma_stats_reset(struct rte_dma_dev *dmadev, uint16_t vchan)
1316 : : {
1317 : 0 : struct fsl_qdma_engine *fsl_qdma = dmadev->data->dev_private;
1318 : 0 : struct fsl_qdma_queue *fsl_queue = fsl_qdma->chan[vchan];
1319 : :
1320 : 0 : memset(&fsl_queue->stats, 0, sizeof(struct rte_dma_stats));
1321 : :
1322 : 0 : return 0;
1323 : : }
1324 : :
1325 : : static uint16_t
1326 : 0 : dpaa_qdma_burst_capacity(const void *dev_private, uint16_t vchan)
1327 : : {
1328 : : const struct fsl_qdma_engine *fsl_qdma = dev_private;
1329 : 0 : struct fsl_qdma_queue *fsl_queue = fsl_qdma->chan[vchan];
1330 : :
1331 : 0 : return fsl_queue->pending_max - fsl_queue->pending_num;
1332 : : }
1333 : :
1334 : : static struct rte_dma_dev_ops dpaa_qdma_ops = {
1335 : : .dev_info_get = dpaa_qdma_info_get,
1336 : : .dev_configure = dpaa_qdma_configure,
1337 : : .dev_start = dpaa_qdma_start,
1338 : : .dev_close = dpaa_qdma_close,
1339 : : .vchan_setup = dpaa_qdma_queue_setup,
1340 : : .stats_get = dpaa_qdma_stats_get,
1341 : : .stats_reset = dpaa_qdma_stats_reset,
1342 : : };
1343 : :
1344 : : static int
1345 : 0 : check_devargs_handler(__rte_unused const char *key, const char *value,
1346 : : __rte_unused void *opaque)
1347 : : {
1348 [ # # ]: 0 : if (strcmp(value, "1"))
1349 : 0 : return -1;
1350 : :
1351 : : return 0;
1352 : : }
1353 : :
1354 : : static int
1355 : 0 : dpaa_get_devargs(struct rte_devargs *devargs, const char *key)
1356 : : {
1357 : : struct rte_kvargs *kvlist;
1358 : :
1359 [ # # ]: 0 : if (!devargs)
1360 : : return 0;
1361 : :
1362 : 0 : kvlist = rte_kvargs_parse(devargs->args, NULL);
1363 [ # # ]: 0 : if (!kvlist)
1364 : : return 0;
1365 : :
1366 [ # # ]: 0 : if (!rte_kvargs_count(kvlist, key)) {
1367 : 0 : rte_kvargs_free(kvlist);
1368 : 0 : return 0;
1369 : : }
1370 : :
1371 [ # # ]: 0 : if (rte_kvargs_process(kvlist, key,
1372 : : check_devargs_handler, NULL) < 0) {
1373 : 0 : rte_kvargs_free(kvlist);
1374 : 0 : return 0;
1375 : : }
1376 : 0 : rte_kvargs_free(kvlist);
1377 : :
1378 : 0 : return 1;
1379 : : }
1380 : :
1381 : : static int
1382 : 0 : dpaa_qdma_init(struct rte_dma_dev *dmadev)
1383 : : {
1384 : 0 : struct fsl_qdma_engine *fsl_qdma = dmadev->data->dev_private;
1385 : : uint64_t phys_addr;
1386 : : int ccsr_qdma_fd;
1387 : : int regs_size;
1388 : : int ret;
1389 : : uint32_t i, j, k;
1390 : :
1391 [ # # ]: 0 : if (dpaa_get_devargs(dmadev->device->devargs, DPAA_DMA_ERROR_CHECK)) {
1392 : 0 : s_hw_err_check = true;
1393 : 0 : DPAA_QDMA_INFO("Enable DMA error checks");
1394 : : }
1395 [ # # ]: 0 : if (dpaa_get_devargs(dmadev->device->devargs, DPAA_DMA_SG_DISABLE)) {
1396 : 0 : s_sg_enable = false;
1397 : 0 : DPAA_QDMA_INFO("SG mode disabled via devarg");
1398 : : }
1399 [ # # ]: 0 : if (dpaa_get_devargs(dmadev->device->devargs, DPAA_DMA_DATA_VALID)) {
1400 : 0 : s_data_validation = true;
1401 : 0 : DPAA_QDMA_INFO("Data validation enabled via devarg");
1402 : : }
1403 : : #ifdef RTE_DMA_DPAA_ERRATA_ERR050757
1404 : : if (dpaa_get_devargs(dmadev->device->devargs, DPAA_DMA_PCI_READ_DISABLE)) {
1405 : : s_pci_read = false;
1406 : : DPAA_QDMA_INFO("ERR050757 PCI read workaround disabled via devarg");
1407 : : }
1408 : : #endif
1409 : :
1410 : 0 : fsl_qdma->n_queues = QDMA_QUEUES * QDMA_BLOCKS;
1411 : 0 : fsl_qdma->num_blocks = QDMA_BLOCKS;
1412 : 0 : fsl_qdma->block_offset = QDMA_BLOCK_OFFSET;
1413 : :
1414 : : ccsr_qdma_fd = open("/dev/mem", O_RDWR);
1415 [ # # ]: 0 : if (unlikely(ccsr_qdma_fd < 0)) {
1416 : 0 : DPAA_QDMA_ERR("Can not open /dev/mem for qdma CCSR map");
1417 : 0 : return ccsr_qdma_fd;
1418 : : }
1419 : :
1420 : 0 : regs_size = fsl_qdma->block_offset * fsl_qdma->num_blocks;
1421 : 0 : regs_size += (QDMA_CTRL_REGION_SIZE + QDMA_STATUS_REGION_SIZE);
1422 : : phys_addr = QDMA_CCSR_BASE;
1423 : 0 : fsl_qdma->reg_base = mmap(NULL, regs_size,
1424 : : PROT_READ | PROT_WRITE, MAP_SHARED,
1425 : : ccsr_qdma_fd, phys_addr);
1426 : :
1427 : 0 : close(ccsr_qdma_fd);
1428 [ # # ]: 0 : if (fsl_qdma->reg_base == MAP_FAILED) {
1429 : 0 : DPAA_QDMA_ERR("Map qdma reg: Phys(0x%"PRIx64"), size(%d)",
1430 : : phys_addr, regs_size);
1431 : 0 : return -ENOMEM;
1432 : : }
1433 : :
1434 : 0 : fsl_qdma->ctrl_base =
1435 : : fsl_qdma->reg_base + QDMA_CTRL_REGION_OFFSET;
1436 : 0 : fsl_qdma->status_base =
1437 : 0 : fsl_qdma->reg_base + QDMA_STATUS_REGION_OFFSET;
1438 : 0 : fsl_qdma->block_base =
1439 : 0 : fsl_qdma->status_base + QDMA_STATUS_REGION_SIZE;
1440 : :
1441 [ # # ]: 0 : for (i = 0; i < QDMA_BLOCKS; i++) {
1442 : 0 : ret = fsl_qdma_prep_status_queue(fsl_qdma, i);
1443 [ # # ]: 0 : if (ret)
1444 : 0 : goto mem_free;
1445 : : }
1446 : :
1447 : : k = 0;
1448 [ # # ]: 0 : for (i = 0; i < QDMA_QUEUES; i++) {
1449 [ # # ]: 0 : for (j = 0; j < QDMA_BLOCKS; j++) {
1450 : 0 : ret = fsl_qdma_alloc_queue_resources(fsl_qdma, i, j);
1451 [ # # ]: 0 : if (ret)
1452 : 0 : goto mem_free;
1453 : 0 : fsl_qdma->cmd_queues[j][i].channel_id = k;
1454 : 0 : k++;
1455 : : }
1456 : : }
1457 : :
1458 : 0 : ret = fsl_qdma_reg_init(fsl_qdma);
1459 [ # # ]: 0 : if (ret) {
1460 : 0 : DPAA_QDMA_ERR("Can't Initialize the qDMA engine.");
1461 : 0 : goto mem_free;
1462 : : }
1463 : :
1464 : : return 0;
1465 : :
1466 : 0 : mem_free:
1467 [ # # ]: 0 : for (i = 0; i < fsl_qdma->num_blocks; i++)
1468 : : fsl_qdma_free_stq_res(&fsl_qdma->stat_queues[i]);
1469 : :
1470 [ # # ]: 0 : for (i = 0; i < fsl_qdma->num_blocks; i++) {
1471 [ # # ]: 0 : for (j = 0; j < QDMA_QUEUES; j++)
1472 : 0 : fsl_qdma_free_cmdq_res(&fsl_qdma->cmd_queues[i][j]);
1473 : : }
1474 : :
1475 : 0 : munmap(fsl_qdma->ctrl_base, regs_size);
1476 : :
1477 : 0 : return ret;
1478 : : }
1479 : :
1480 : : static int
1481 : 0 : dpaa_qdma_probe(__rte_unused struct rte_dpaa_driver *dpaa_drv,
1482 : : struct rte_dpaa_device *dpaa_dev)
1483 : : {
1484 : : struct rte_dma_dev *dmadev;
1485 : : int ret;
1486 : :
1487 : : /*
1488 : : * struct fsl_qdma_engine lives in memory shared with the primary, and
1489 : : * reg_base in it is a process-private mmap of the QDMA CCSR region that
1490 : : * is only valid in the primary. Until a secondary can establish its own
1491 : : * mapping, do not advertise the device here: registering it would hand
1492 : : * out a usable dmadev whose MMIO pointers are not mapped in this
1493 : : * process.
1494 : : */
1495 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1496 : 0 : DPAA_QDMA_DEBUG("%s: skipped in secondary process",
1497 : : dpaa_dev->device.name);
1498 : : /* Positive: leave unclaimed, not a probe failure. */
1499 : 0 : return 1;
1500 : : }
1501 : :
1502 : 0 : dmadev = rte_dma_pmd_allocate(dpaa_dev->device.name,
1503 : 0 : rte_socket_id(),
1504 : : sizeof(struct fsl_qdma_engine));
1505 [ # # ]: 0 : if (!dmadev) {
1506 : 0 : DPAA_QDMA_ERR("Unable to allocate dmadevice");
1507 : 0 : return -EINVAL;
1508 : : }
1509 : :
1510 : 0 : dmadev->dev_ops = &dpaa_qdma_ops;
1511 : 0 : dmadev->device = &dpaa_dev->device;
1512 : 0 : dmadev->fp_obj->dev_private = dmadev->data->dev_private;
1513 : 0 : dmadev->fp_obj->copy = dpaa_qdma_enqueue;
1514 : 0 : dmadev->fp_obj->copy_sg = dpaa_qdma_copy_sg;
1515 : 0 : dmadev->fp_obj->submit = dpaa_qdma_submit;
1516 : 0 : dmadev->fp_obj->completed = dpaa_qdma_dequeue;
1517 : 0 : dmadev->fp_obj->completed_status = dpaa_qdma_dequeue_status;
1518 : 0 : dmadev->fp_obj->burst_capacity = dpaa_qdma_burst_capacity;
1519 : :
1520 : : /* Invoke PMD device initialization function */
1521 : 0 : ret = dpaa_qdma_init(dmadev);
1522 [ # # ]: 0 : if (ret) {
1523 : 0 : (void)rte_dma_pmd_release(dpaa_dev->device.name);
1524 : 0 : return ret;
1525 : : }
1526 : :
1527 : 0 : dmadev->state = RTE_DMA_DEV_READY;
1528 : 0 : return 0;
1529 : : }
1530 : :
1531 : : static int
1532 : 0 : dpaa_qdma_remove(struct rte_dpaa_device *dpaa_dev)
1533 : : {
1534 [ # # ]: 0 : if (rte_dma_pmd_release(dpaa_dev->device.name))
1535 : 0 : DPAA_QDMA_ERR("Device cleanup failed");
1536 : :
1537 : 0 : return 0;
1538 : : }
1539 : :
1540 : : static struct rte_dpaa_driver rte_dpaa_qdma_pmd = {
1541 : : .drv_type = FSL_DPAA_QDMA,
1542 : : .probe = dpaa_qdma_probe,
1543 : : .remove = dpaa_qdma_remove,
1544 : : };
1545 : :
1546 : 306 : RTE_PMD_REGISTER_DPAA(dpaa_qdma, rte_dpaa_qdma_pmd);
1547 : : RTE_PMD_REGISTER_PARAM_STRING(dpaa_qdma,
1548 : : DPAA_DMA_ERROR_CHECK "=<int> "
1549 : : DPAA_DMA_SG_DISABLE "=<int> "
1550 : : DPAA_DMA_DATA_VALID "=<int> "
1551 : : DPAA_DMA_ERRATA_PARAMS);
1552 [ - + ]: 306 : RTE_LOG_REGISTER_DEFAULT(dpaa_qdma_logtype, INFO);
|