277
277
val = ring_pa + info->head * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
278
278
nwl_write_register(val, ctx, info->base_addr, REG_SW_NEXT_BD);
279
// nwl_read_register(val, ctx, info->base_addr, 0x18);
283
// nwl_read_register(val, ctx, info->base_addr, REG_DMA_ENG_LAST_BD);
284
// printf("Last BD(Write): %lx %lx\n", ring, val);
293
286
struct timeval start, cur;
294
287
uint32_t status_size, status, control;
298
289
unsigned char *ring = pcilib_kmem_get_ua(ctx->pcilib, info->ring);
300
// status_size = NWL_RING_GET(ring, DMA_BD_BUFL_STATUS_OFFSET);
301
// printf("Status0: %lx\n", status_size);
303
291
ring += info->tail * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
305
293
gettimeofday(&start, NULL);
307
// printf("Waiting %li\n", info->tail);
308
// nwl_read_register(val, ctx, info->base_addr, REG_DMA_ENG_LAST_BD);
309
// printf("Last BD(Read): %lx %lx\n", ring, val);
312
296
status_size = NWL_RING_GET(ring, DMA_BD_BUFL_STATUS_OFFSET);
313
297
status = status_size & DMA_BD_STATUS_MASK;
315
// printf("%i: %lx\n", info->tail, status_size);
317
299
if (status & DMA_BD_ERROR_MASK) {
318
300
pcilib_error("NWL DMA Engine reported error in ring descriptor");
319
301
return (size_t)-1;
322
304
if (status & DMA_BD_COMP_MASK) {
323
305
if (status & DMA_BD_EOP_MASK) *eop = 1;
326
308
*size = status_size & DMA_BD_BUFL_MASK;
312
if ((info->tail + 1) == info->ring_size) ring -= info->tail * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
313
else ring += PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
314
*mrd = NWL_RING_GET(ring, DMA_BD_BUFL_STATUS_OFFSET)&DMA_BD_COMP_MASK;
328
// printf("Status: %lx\n", status_size);
329
318
return info->tail;
333
322
gettimeofday(&cur, NULL);
334
323
} while ((timeout == PCILIB_TIMEOUT_INFINITE)||(((cur.tv_sec - start.tv_sec)*1000000 + (cur.tv_usec - start.tv_usec)) < timeout));
336
// printf("Final status: %lx\n", status_size);
338
325
return (size_t)-1;
328
static int dma_nwl_is_overflown(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *info) {
330
unsigned char *ring = pcilib_kmem_get_ua(ctx->pcilib, info->ring);
331
if (info->tail > 0) ring += (info->tail - 1) * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
332
else ring += (info->ring_size - 1) * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
334
status = NWL_RING_GET(ring, DMA_BD_BUFL_STATUS_OFFSET);
335
return status&DMA_BD_COMP_MASK?1:0;
341
338
static int dma_nwl_return_buffer(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *info) {
346
343
size_t bufsz = pcilib_kmem_get_block_size(ctx->pcilib, info->pages, info->tail);
348
345
ring += info->tail * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
349
// printf("Returning: %i\n", info->tail);
351
347
#ifdef NWL_GENERATE_DMA_IRQ
352
348
NWL_RING_SET(ring, DMA_BD_BUFL_CTRL_OFFSET, bufsz | DMA_BD_INT_ERROR_MASK | DMA_BD_INT_COMP_MASK);
359
355
val = ring_pa + info->tail * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
360
356
nwl_write_register(val, ctx, info->base_addr, REG_SW_NEXT_BD);
361
// nwl_read_register(val, ctx, info->base_addr, 0x18);
364
359
if (info->tail == info->ring_size) info->tail = 0;
367
int dma_nwl_get_status(pcilib_t *vctx, pcilib_dma_engine_t dma, pcilib_dma_engine_status_t *status, size_t n_buffers, pcilib_dma_buffer_status_t *buffers) {
362
int dma_nwl_get_status(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, pcilib_dma_engine_status_t *status, size_t n_buffers, pcilib_dma_buffer_status_t *buffers) {
369
364
uint32_t bstatus;
370
365
nwl_dma_t *ctx = (nwl_dma_t*)vctx;
415
unsigned char *ring = pcilib_kmem_get_ua(ctx->pcilib, info->ring);
417
// status_size = NWL_RING_GET(ring, DMA_BD_BUFL_STATUS_OFFSET);
418
// printf("Status0: %lx\n", status_size);
420
ring += info->tail * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
422
gettimeofday(&start, NULL);
424
// printf("Waiting %li\n", info->tail);
425
// nwl_read_register(val, ctx, info->base_addr, REG_DMA_ENG_LAST_BD);
426
// printf("Last BD(Read): %lx %lx\n", ring, val);
429
status_size = NWL_RING_GET(ring, DMA_BD_BUFL_STATUS_OFFSET);
430
status = status_size & DMA_BD_STATUS_MASK;
432
// printf("%i: %lx\n", info->tail, status_size);
434
if (status & DMA_BD_ERROR_MASK) {
435
pcilib_error("NWL DMA Engine reported error in ring descriptor");
439
if (status & DMA_BD_COMP_MASK) {
440
if (status & DMA_BD_EOP_MASK) *eop = 1;
443
*size = status_size & DMA_BD_BUFL_MASK;
445
// printf("Status: %lx\n", status_size);
450
gettimeofday(&cur, NULL);
451
} while ((timeout == PCILIB_TIMEOUT_INFINITE)||(((cur.tv_sec - start.tv_sec)*1000000 + (cur.tv_usec - start.tv_usec)) < timeout));
b'\\ No newline at end of file'