summaryrefslogtreecommitdiffstats
path: root/dma
diff options
context:
space:
mode:
Diffstat (limited to 'dma')
-rw-r--r--dma/nwl.c6
-rw-r--r--dma/nwl.h4
-rw-r--r--dma/nwl_dma.h2
-rw-r--r--dma/nwl_engine.c45
-rw-r--r--dma/nwl_engine.h2
-rw-r--r--dma/nwl_engine_buffers.h85
-rw-r--r--dma/nwl_irq.c2
-rw-r--r--dma/nwl_loopback.c132
-rw-r--r--dma/nwl_register.c6
-rw-r--r--dma/nwl_register.h8
10 files changed, 139 insertions, 153 deletions
diff --git a/dma/nwl.c b/dma/nwl.c
index 7d2c964..cc03687 100644
--- a/dma/nwl.c
+++ b/dma/nwl.c
@@ -88,6 +88,10 @@ pcilib_dma_context_t *dma_nwl_init(pcilib_t *pcilib, pcilib_dma_modification_t t
ctx->pcilib = pcilib;
ctx->type = type;
+ if (type == PCILIB_NWL_MODIFICATION_IPECAMERA) {
+ ctx->dmactx.ignore_eop = 1;
+ }
+
pcilib_register_bank_t dma_bank = pcilib_find_bank_by_addr(pcilib, PCILIB_REGISTER_BANK_DMA);
if (dma_bank == PCILIB_REGISTER_BANK_INVALID) {
free(ctx);
@@ -132,7 +136,7 @@ void dma_nwl_free(pcilib_dma_context_t *vctx) {
if (ctx) {
if (ctx->type == PCILIB_DMA_MODIFICATION_DEFAULT) dma_nwl_stop_loopback(ctx);
dma_nwl_free_irq(ctx);
- dma_nwl_stop(ctx, PCILIB_DMA_ENGINE_ALL, PCILIB_DMA_FLAGS_DEFAULT);
+ dma_nwl_stop(vctx, PCILIB_DMA_ENGINE_ALL, PCILIB_DMA_FLAGS_DEFAULT);
free(ctx);
}
diff --git a/dma/nwl.h b/dma/nwl.h
index db48fdc..0e4b5ae 100644
--- a/dma/nwl.h
+++ b/dma/nwl.h
@@ -8,7 +8,7 @@ typedef struct pcilib_nwl_engine_description_s pcilib_nwl_engine_description_t;
#define NWL_XAUI_ENGINE 0
#define NWL_XRAWDATA_ENGINE 1
-#define NWL_FIX_EOP_FOR_BIG_PACKETS // requires precise sizes in read requests
+#define NWL_MAX_PACKET_SIZE 4096 //16384
//#define NWL_GENERATE_DMA_IRQ
#define PCILIB_NWL_ALIGNMENT 64 // in bytes
@@ -44,6 +44,8 @@ struct pcilib_nwl_engine_description_s {
struct nwl_dma_s {
+ struct pcilib_dma_context_s dmactx;
+
pcilib_t *pcilib;
pcilib_dma_modification_t type;
diff --git a/dma/nwl_dma.h b/dma/nwl_dma.h
index f87c68f..f9873f7 100644
--- a/dma/nwl_dma.h
+++ b/dma/nwl_dma.h
@@ -9,7 +9,7 @@
pcilib_dma_context_t *dma_nwl_init(pcilib_t *ctx, pcilib_dma_modification_t type, void *arg);
void dma_nwl_free(pcilib_dma_context_t *vctx);
-int dma_nwl_get_status(pcilib_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_engine_status_t *status, size_t n_buffers, pcilib_dma_buffer_status_t *buffers);
+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);
int dma_nwl_enable_irq(pcilib_dma_context_t *vctx, pcilib_irq_type_t type, pcilib_dma_flags_t flags);
int dma_nwl_disable_irq(pcilib_dma_context_t *vctx, pcilib_dma_flags_t flags);
diff --git a/dma/nwl_engine.c b/dma/nwl_engine.c
index 037ab02..806173d 100644
--- a/dma/nwl_engine.c
+++ b/dma/nwl_engine.c
@@ -77,7 +77,7 @@ int dma_nwl_start_engine(nwl_dma_t *ctx, pcilib_dma_engine_t dma) {
if (info->reused) {
info->preserve = 1;
- dma_nwl_acknowledge_irq(ctx, PCILIB_DMA_IRQ, dma);
+ dma_nwl_acknowledge_irq((pcilib_dma_context_t*)ctx, PCILIB_DMA_IRQ, dma);
#ifdef NWL_GENERATE_DMA_IRQ
dma_nwl_enable_engine_irq(ctx, dma);
@@ -126,7 +126,7 @@ int dma_nwl_start_engine(nwl_dma_t *ctx, pcilib_dma_engine_t dma) {
return PCILIB_ERROR_TIMEOUT;
}
- dma_nwl_acknowledge_irq(ctx, PCILIB_DMA_IRQ, dma);
+ dma_nwl_acknowledge_irq((pcilib_dma_context_t*)ctx, PCILIB_DMA_IRQ, dma);
ring_pa = pcilib_kmem_get_pa(ctx->pcilib, info->ring);
nwl_write_register(ring_pa, ctx, info->base_addr, REG_DMA_ENG_NEXT_BD);
@@ -198,7 +198,7 @@ int dma_nwl_stop_engine(nwl_dma_t *ctx, pcilib_dma_engine_t dma) {
}
}
- dma_nwl_acknowledge_irq(ctx, PCILIB_DMA_IRQ, dma);
+ dma_nwl_acknowledge_irq((pcilib_dma_context_t*)ctx, PCILIB_DMA_IRQ, dma);
if (info->preserve) {
flags = PCILIB_KMEM_FLAG_REUSE;
@@ -228,7 +228,7 @@ int dma_nwl_write_fragment(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma,
pcilib_nwl_engine_description_t *info = ctx->engines + dma;
- err = dma_nwl_start(ctx, dma, PCILIB_DMA_FLAGS_DEFAULT);
+ err = dma_nwl_start(vctx, dma, PCILIB_DMA_FLAGS_DEFAULT);
if (err) return err;
if (data) {
@@ -266,7 +266,7 @@ int dma_nwl_write_fragment(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma,
}
int dma_nwl_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, pcilib_timeout_t timeout, pcilib_dma_callback_t cb, void *cbattr) {
- int err, ret;
+ int err, ret = 1;
size_t res = 0;
size_t bufnum;
size_t bufsize;
@@ -277,28 +277,31 @@ int dma_nwl_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uin
pcilib_nwl_engine_description_t *info = ctx->engines + dma;
- err = dma_nwl_start(ctx, dma, PCILIB_DMA_FLAGS_DEFAULT);
+ err = dma_nwl_start(vctx, dma, PCILIB_DMA_FLAGS_DEFAULT);
if (err) return err;
-
+
do {
- bufnum = dma_nwl_wait_buffer(ctx, info, &bufsize, &eop, timeout);
- if (bufnum == PCILIB_DMA_BUFFER_INVALID) return PCILIB_ERROR_TIMEOUT;
-
-#ifdef NWL_FIX_EOP_FOR_BIG_PACKETS
- if (size > 65536) {
-// printf("%i %i\n", res + bufsize, size);
- if ((res+bufsize) < size) eop = 0;
- else if ((res+bufsize) == size) eop = 1;
+ if (ret > 2) {
+ bufnum = dma_nwl_wait_buffer(ctx, info, &bufsize, &eop, 0);
+ if (bufnum == PCILIB_DMA_BUFFER_INVALID) return 0;
+ } else {
+ bufnum = dma_nwl_wait_buffer(ctx, info, &bufsize, &eop, timeout);
+ if (bufnum == PCILIB_DMA_BUFFER_INVALID) {
+ if (ret == 1) return PCILIB_ERROR_TIMEOUT;
+ return 0;
+ }
}
-#endif /* NWL_FIX_EOP_FOR_BIG_PACKETS */
+
+ // EOP is not respected in IPE Camera
+ if (ctx->dmactx.ignore_eop) eop = 1;
pcilib_kmem_sync_block(ctx->pcilib, info->pages, PCILIB_KMEM_SYNC_FROMDEVICE, bufnum);
void *buf = pcilib_kmem_get_block_ua(ctx->pcilib, info->pages, bufnum);
- ret = cb(cbattr, eop?PCILIB_DMA_FLAG_EOP:0, bufsize, buf);
+ ret = cb(cbattr, (eop?PCILIB_DMA_FLAG_EOP:0), bufsize, buf);
// DS: Fixme, it looks like we can avoid calling this for the sake of performance
// pcilib_kmem_sync_block(ctx->pcilib, info->pages, PCILIB_KMEM_SYNC_TODEVICE, bufnum);
+ if (ret < 0) return -ret;
dma_nwl_return_buffer(ctx, info);
-
res += bufsize;
@@ -306,3 +309,9 @@ int dma_nwl_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uin
return 0;
}
+
+int dma_nwl_wait_completion(nwl_dma_t * ctx, pcilib_dma_engine_t dma, pcilib_timeout_t timeout) {
+ if (dma_nwl_get_next_buffer(ctx, ctx->engines + dma, PCILIB_NWL_DMA_PAGES - 1, PCILIB_DMA_TIMEOUT) == (PCILIB_NWL_DMA_PAGES - 1)) return 0;
+ else return PCILIB_ERROR_TIMEOUT;
+}
+
diff --git a/dma/nwl_engine.h b/dma/nwl_engine.h
index 176eaeb..f9f3f60 100644
--- a/dma/nwl_engine.h
+++ b/dma/nwl_engine.h
@@ -5,6 +5,8 @@ int dma_nwl_read_engine_config(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *
int dma_nwl_start_engine(nwl_dma_t *ctx, pcilib_dma_engine_t dma);
int dma_nwl_stop_engine(nwl_dma_t *ctx, pcilib_dma_engine_t dma);
+int dma_nwl_wait_completion(nwl_dma_t * ctx, pcilib_dma_engine_t dma, pcilib_timeout_t timeout);
+
#endif /* _PCILIB_DMA_NWL_ENGINE_H */
diff --git a/dma/nwl_engine_buffers.h b/dma/nwl_engine_buffers.h
index 8f31bb6..b97e469 100644
--- a/dma/nwl_engine_buffers.h
+++ b/dma/nwl_engine_buffers.h
@@ -276,13 +276,6 @@ static int dma_nwl_push_buffer(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *
val = ring_pa + info->head * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
nwl_write_register(val, ctx, info->base_addr, REG_SW_NEXT_BD);
-// nwl_read_register(val, ctx, info->base_addr, 0x18);
-
-// usleep(10000);
-
-// nwl_read_register(val, ctx, info->base_addr, REG_DMA_ENG_LAST_BD);
-// printf("Last BD(Write): %lx %lx\n", ring, val);
-
return 0;
}
@@ -293,27 +286,16 @@ static size_t dma_nwl_wait_buffer(nwl_dma_t *ctx, pcilib_nwl_engine_description_
struct timeval start, cur;
uint32_t status_size, status, control;
-// usleep(10000);
-
unsigned char *ring = pcilib_kmem_get_ua(ctx->pcilib, info->ring);
-// status_size = NWL_RING_GET(ring, DMA_BD_BUFL_STATUS_OFFSET);
-// printf("Status0: %lx\n", status_size);
-
ring += info->tail * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
gettimeofday(&start, NULL);
-// printf("Waiting %li\n", info->tail);
-// nwl_read_register(val, ctx, info->base_addr, REG_DMA_ENG_LAST_BD);
-// printf("Last BD(Read): %lx %lx\n", ring, val);
-
do {
status_size = NWL_RING_GET(ring, DMA_BD_BUFL_STATUS_OFFSET);
status = status_size & DMA_BD_STATUS_MASK;
-// printf("%i: %lx\n", info->tail, status_size);
-
if (status & DMA_BD_ERROR_MASK) {
pcilib_error("NWL DMA Engine reported error in ring descriptor");
return (size_t)-1;
@@ -322,10 +304,17 @@ static size_t dma_nwl_wait_buffer(nwl_dma_t *ctx, pcilib_nwl_engine_description_
if (status & DMA_BD_COMP_MASK) {
if (status & DMA_BD_EOP_MASK) *eop = 1;
else *eop = 0;
-
+
*size = status_size & DMA_BD_BUFL_MASK;
+
+/*
+ if (mrd) {
+ if ((info->tail + 1) == info->ring_size) ring -= info->tail * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
+ else ring += PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
+ *mrd = NWL_RING_GET(ring, DMA_BD_BUFL_STATUS_OFFSET)&DMA_BD_COMP_MASK;
+ }
+*/
-// printf("Status: %lx\n", status_size);
return info->tail;
}
@@ -333,11 +322,19 @@ static size_t dma_nwl_wait_buffer(nwl_dma_t *ctx, pcilib_nwl_engine_description_
gettimeofday(&cur, NULL);
} while ((timeout == PCILIB_TIMEOUT_INFINITE)||(((cur.tv_sec - start.tv_sec)*1000000 + (cur.tv_usec - start.tv_usec)) < timeout));
-// printf("Final status: %lx\n", status_size);
-
return (size_t)-1;
}
+static int dma_nwl_is_overflown(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *info) {
+ uint32_t status;
+ unsigned char *ring = pcilib_kmem_get_ua(ctx->pcilib, info->ring);
+ if (info->tail > 0) ring += (info->tail - 1) * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
+ else ring += (info->ring_size - 1) * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
+
+ status = NWL_RING_GET(ring, DMA_BD_BUFL_STATUS_OFFSET);
+ return status&DMA_BD_COMP_MASK?1:0;
+}
+
static int dma_nwl_return_buffer(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *info) {
uint32_t val;
@@ -346,7 +343,6 @@ static int dma_nwl_return_buffer(nwl_dma_t *ctx, pcilib_nwl_engine_description_t
size_t bufsz = pcilib_kmem_get_block_size(ctx->pcilib, info->pages, info->tail);
ring += info->tail * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
-// printf("Returning: %i\n", info->tail);
#ifdef NWL_GENERATE_DMA_IRQ
NWL_RING_SET(ring, DMA_BD_BUFL_CTRL_OFFSET, bufsz | DMA_BD_INT_ERROR_MASK | DMA_BD_INT_COMP_MASK);
@@ -358,13 +354,12 @@ static int dma_nwl_return_buffer(nwl_dma_t *ctx, pcilib_nwl_engine_description_t
val = ring_pa + info->tail * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
nwl_write_register(val, ctx, info->base_addr, REG_SW_NEXT_BD);
-// nwl_read_register(val, ctx, info->base_addr, 0x18);
info->tail++;
if (info->tail == info->ring_size) info->tail = 0;
}
-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) {
+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) {
size_t i;
uint32_t bstatus;
nwl_dma_t *ctx = (nwl_dma_t*)vctx;
@@ -410,43 +405,3 @@ int dma_nwl_get_status(pcilib_t *vctx, pcilib_dma_engine_t dma, pcilib_dma_engin
return 0;
}
-
-/*
- unsigned char *ring = pcilib_kmem_get_ua(ctx->pcilib, info->ring);
-
-// status_size = NWL_RING_GET(ring, DMA_BD_BUFL_STATUS_OFFSET);
-// printf("Status0: %lx\n", status_size);
-
- ring += info->tail * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
-
- gettimeofday(&start, NULL);
-
-// printf("Waiting %li\n", info->tail);
-// nwl_read_register(val, ctx, info->base_addr, REG_DMA_ENG_LAST_BD);
-// printf("Last BD(Read): %lx %lx\n", ring, val);
-
- do {
- status_size = NWL_RING_GET(ring, DMA_BD_BUFL_STATUS_OFFSET);
- status = status_size & DMA_BD_STATUS_MASK;
-
-// printf("%i: %lx\n", info->tail, status_size);
-
- if (status & DMA_BD_ERROR_MASK) {
- pcilib_error("NWL DMA Engine reported error in ring descriptor");
- return (size_t)-1;
- }
-
- if (status & DMA_BD_COMP_MASK) {
- if (status & DMA_BD_EOP_MASK) *eop = 1;
- else *eop = 0;
-
- *size = status_size & DMA_BD_BUFL_MASK;
-
-// printf("Status: %lx\n", status_size);
- return info->tail;
- }
-
- usleep(10);
- gettimeofday(&cur, NULL);
- } while ((timeout == PCILIB_TIMEOUT_INFINITE)||(((cur.tv_sec - start.tv_sec)*1000000 + (cur.tv_usec - start.tv_usec)) < timeout));
-*/ \ No newline at end of file
diff --git a/dma/nwl_irq.c b/dma/nwl_irq.c
index ae4aacc..ee5f520 100644
--- a/dma/nwl_irq.c
+++ b/dma/nwl_irq.c
@@ -81,7 +81,7 @@ int dma_nwl_disable_irq(pcilib_dma_context_t *vctx, pcilib_dma_flags_t flags) {
int dma_nwl_enable_engine_irq(nwl_dma_t *ctx, pcilib_dma_engine_t dma) {
uint32_t val;
- dma_nwl_enable_irq(ctx, PCILIB_DMA_IRQ, 0);
+ dma_nwl_enable_irq((pcilib_dma_context_t*)ctx, PCILIB_DMA_IRQ, 0);
nwl_read_register(val, ctx, ctx->engines[dma].base_addr, REG_DMA_ENG_CTRL_STATUS);
val |= (DMA_ENG_INT_ENABLE);
diff --git a/dma/nwl_loopback.c b/dma/nwl_loopback.c
index a87c109..11f7f34 100644
--- a/dma/nwl_loopback.c
+++ b/dma/nwl_loopback.c
@@ -13,6 +13,8 @@
#include "nwl_defines.h"
+#define NWL_BUG_EXTRA_DATA
+
int dma_nwl_start_loopback(nwl_dma_t *ctx, pcilib_dma_direction_t direction, size_t packet_size) {
uint32_t val;
@@ -66,11 +68,12 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
int iter, i;
int res;
int err;
- size_t bytes;
+ size_t bytes, rbytes;
uint32_t val;
uint32_t *buf, *cmp;
const char *error = NULL;
pcilib_register_value_t regval;
+ size_t packet_size, blocks;
size_t us = 0;
struct timeval start, cur;
@@ -87,8 +90,10 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
else size /= sizeof(uint32_t);
// Not supported
- if (direction == PCILIB_DMA_TO_DEVICE) return -1.;
- else if ((direction == PCILIB_DMA_FROM_DEVICE)&&(ctx->type != PCILIB_DMA_MODIFICATION_DEFAULT)) return -1.;
+ if (ctx->type == PCILIB_DMA_MODIFICATION_DEFAULT) {
+ if (direction == PCILIB_DMA_TO_DEVICE) return -1.;
+ }
+// else if ((direction == PCILIB_DMA_FROM_DEVICE)&&(ctx->type != PCILIB_DMA_MODIFICATION_DEFAULT)) return -1.;
// Stop Generators and drain old data
if (ctx->type == PCILIB_DMA_MODIFICATION_DEFAULT) dma_nwl_stop_loopback(ctx);
@@ -107,63 +112,107 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
dma_nwl_enable_engine_irq(ctx, writeid);
#endif /* NWL_GENERATE_DMA_IRQ */
- dma_nwl_start_loopback(ctx, direction, size * sizeof(uint32_t));
+ if (size * sizeof(uint32_t) > NWL_MAX_PACKET_SIZE) {
+ packet_size = NWL_MAX_PACKET_SIZE;
+ blocks = (size * sizeof(uint32_t)) / packet_size + (((size*sizeof(uint32_t))%packet_size)?1:0);
+ } else {
+ packet_size = size * sizeof(uint32_t);
+ blocks = 1;
+ }
+
+ dma_nwl_start_loopback(ctx, direction, packet_size);
// Allocate memory and prepare data
- buf = malloc(size * sizeof(uint32_t));
- cmp = malloc(size * sizeof(uint32_t));
+ buf = malloc(blocks * packet_size * sizeof(uint32_t));
+ cmp = malloc(blocks * packet_size * sizeof(uint32_t));
if ((!buf)||(!cmp)) {
if (buf) free(buf);
if (cmp) free(cmp);
return -1;
}
-//#ifdef DEBUG_HARDWARE
if (ctx->type == PCILIB_NWL_MODIFICATION_IPECAMERA) {
pcilib_write_register(ctx->pcilib, NULL, "control", 0x1e5);
usleep(100000);
pcilib_write_register(ctx->pcilib, NULL, "control", 0x1e1);
+
+ // This way causes more problems with garbage
+ //pcilib_write_register(ctx->pcilib, NULL, "control", 0x3e1);
}
-//#endif /* DEBUG_HARDWARE */
// Benchmark
for (iter = 0; iter < iterations; iter++) {
memset(cmp, 0x13 + iter, size * sizeof(uint32_t));
-//#ifdef DEBUG_HARDWARE
if (ctx->type == PCILIB_NWL_MODIFICATION_IPECAMERA) {
pcilib_write_register(ctx->pcilib, NULL, "control", 0x1e1);
}
-//#endif /* DEBUG_HARDWARE */
- gettimeofday(&start, NULL);
- if (direction&PCILIB_DMA_TO_DEVICE) {
+ if ((direction&PCILIB_DMA_TO_DEVICE)||(ctx->type != PCILIB_DMA_MODIFICATION_DEFAULT)) {
memcpy(buf, cmp, size * sizeof(uint32_t));
+ if (direction&PCILIB_DMA_TO_DEVICE) {
+ gettimeofday(&start, NULL);
+ }
+
err = pcilib_write_dma(ctx->pcilib, writeid, addr, size * sizeof(uint32_t), buf, &bytes);
if ((err)||(bytes != size * sizeof(uint32_t))) {
error = "Write failed";
- break;
+ break;
+ }
+
+ if (direction&PCILIB_DMA_TO_DEVICE) {
+ // wait written
+ if (direction == PCILIB_DMA_TO_DEVICE) {
+ dma_nwl_wait_completion(ctx, writeid, PCILIB_DMA_TIMEOUT);
+ }
+ gettimeofday(&cur, NULL);
+ us += ((cur.tv_sec - start.tv_sec)*1000000 + (cur.tv_usec - start.tv_usec));
}
}
-//#ifdef DEBUG_HARDWARE
if (ctx->type == PCILIB_NWL_MODIFICATION_IPECAMERA) {
pcilib_write_register(ctx->pcilib, NULL, "control", 0x3e1);
}
-//#endif /* DEBUG_HARDWARE */
memset(buf, 0, size * sizeof(uint32_t));
-
- err = pcilib_read_dma(ctx->pcilib, readid, addr, size * sizeof(uint32_t), buf, &bytes);
- gettimeofday(&cur, NULL);
- us += ((cur.tv_sec - start.tv_sec)*1000000 + (cur.tv_usec - start.tv_usec));
+ if (direction&PCILIB_DMA_FROM_DEVICE) {
+ gettimeofday(&start, NULL);
+ }
+
+ for (i = 0, bytes = 0; i < blocks; i++) {
+#ifdef NWL_BUG_EXTRA_DATA
+ retry:
+#endif
+
+ err = pcilib_read_dma(ctx->pcilib, readid, addr, packet_size * sizeof(uint32_t), buf + (bytes>>2), &rbytes);
+ if ((err)||(rbytes%sizeof(uint32_t))) {
+ break;
+ }
+#ifdef NWL_BUG_EXTRA_DATA
+ else if (rbytes == 8) {
+ goto retry;
+ }
+#endif
+ bytes += rbytes;
+ }
+
+ if (direction&PCILIB_DMA_FROM_DEVICE) {
+ gettimeofday(&cur, NULL);
+ us += ((cur.tv_sec - start.tv_sec)*1000000 + (cur.tv_usec - start.tv_usec));
+ }
+#ifdef NWL_BUG_EXTRA_DATA
+ if ((err)||((bytes != size * sizeof(uint32_t))&&((bytes - 8) != size * sizeof(uint32_t)))) {
+#else
if ((err)||(bytes != size * sizeof(uint32_t))) {
- error = "Read failed";
- break;
+#endif
+ printf("Expected: %zu bytes, but %zu read, error: %i\n", size * sizeof(uint32_t), bytes, err);
+ error = "Read failed";
+ break;
}
+#ifndef NWL_BUG_EXTRA_DATA
if (direction == PCILIB_DMA_BIDIRECTIONAL) {
res = memcmp(buf, cmp, size * sizeof(uint32_t));
if (res) {
@@ -171,7 +220,7 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
if (buf[i] != cmp[i]) break;
bytes = i;
- printf("Expected: *%lx, Written at position %lu:", 0x13 + iter, bytes);
+ printf("Expected: *0x%lx, Written at dword %lu:", 0x13 + iter, bytes);
for (; (i < size)&&(i < (bytes + 16)); i++) {
if (((i - bytes)%8)==0) printf("\n");
printf("% 10lx", buf[i]);
@@ -182,41 +231,12 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
break;
}
}
-
-#ifdef DEBUG_HARDWARE
- puts("====================================");
-
- err = pcilib_read_register(ctx->pcilib, NULL, "reg9050", &regval);
- printf("Status1: %i 0x%lx\n", err, regval);
- err = pcilib_read_register(ctx->pcilib, NULL, "reg9080", &regval);
- printf("Start address: %i 0x%lx\n", err, regval);
- err = pcilib_read_register(ctx->pcilib, NULL, "reg9090", &regval);
- printf("End address: %i 0x%lx\n", err, regval);
- err = pcilib_read_register(ctx->pcilib, NULL, "reg9100", &regval);
- printf("Status2: %i 0x%lx\n", err, regval);
- err = pcilib_read_register(ctx->pcilib, NULL, "reg9110", &regval);
- printf("Status3: %i 0x%lx\n", err, regval);
- err = pcilib_read_register(ctx->pcilib, NULL, "reg9160", &regval);
- printf("Add_rd_ddr: %i 0x%lx\n", err, regval);
-#endif /* DEBUG_HARDWARE */
-
+#endif
}
-#ifdef DEBUG_HARDWARE
- puts("------------------------------------------------");
- err = pcilib_read_register(ctx->pcilib, NULL, "reg9050", &regval);
- printf("Status1: %i 0x%lx\n", err, regval);
- err = pcilib_read_register(ctx->pcilib, NULL, "reg9080", &regval);
- printf("Start address: %i 0x%lx\n", err, regval);
- err = pcilib_read_register(ctx->pcilib, NULL, "reg9090", &regval);
- printf("End address: %i 0x%lx\n", err, regval);
- err = pcilib_read_register(ctx->pcilib, NULL, "reg9100", &regval);
- printf("Status2: %i 0x%lx\n", err, regval);
- err = pcilib_read_register(ctx->pcilib, NULL, "reg9110", &regval);
- printf("Status3: %i 0x%lx\n", err, regval);
- err = pcilib_read_register(ctx->pcilib, NULL, "reg9160", &regval);
- printf("Add_rd_ddr: %i 0x%lx\n", err, regval);
-#endif /* DEBUG_HARDWARE */
+ if (ctx->type == PCILIB_NWL_MODIFICATION_IPECAMERA) {
+ pcilib_write_register(ctx->pcilib, NULL, "control", 0x1e1);
+ }
if (error) {
pcilib_warning("%s at iteration %i, error: %i, bytes: %zu", error, iter, err, bytes);
@@ -238,5 +258,5 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
free(cmp);
free(buf);
- return error?-1:(1. * size * sizeof(uint32_t) * iterations * 1000000) / (1024. * 1024. * us);
+ return /*error?-1:*/(1. * size * sizeof(uint32_t) * iterations * 1000000) / (1024. * 1024. * us);
}
diff --git a/dma/nwl_register.c b/dma/nwl_register.c
index 5bb6e16..95b981a 100644
--- a/dma/nwl_register.c
+++ b/dma/nwl_register.c
@@ -26,8 +26,10 @@ int nwl_add_registers(nwl_dma_t *ctx) {
err = pcilib_add_registers(ctx->pcilib, 0, nwl_dma_registers);
if (err) return err;
- err = pcilib_add_registers(ctx->pcilib, 0, nwl_xrawdata_registers);
- if (err) return err;
+ if (ctx->type == PCILIB_DMA_MODIFICATION_DEFAULT) {
+ err = pcilib_add_registers(ctx->pcilib, 0, nwl_xrawdata_registers);
+ if (err) return err;
+ }
for (n = 0; nwl_dma_engine_registers[n].bits; n++) {
diff --git a/dma/nwl_register.h b/dma/nwl_register.h
index 89a8632..2f465bd 100644
--- a/dma/nwl_register.h
+++ b/dma/nwl_register.h
@@ -86,14 +86,6 @@ static pcilib_register_description_t nwl_xrawdata_registers[] = {
{0x9108, 0, 1, 0, 0x00000003, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK_DMA, "xrawdata_enable_checker", ""},
{0x9108, 1, 1, 0, 0x00000003, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK_DMA, "xrawdata_enable_loopback", ""},
{0x910C, 0, 1, 0, 0x00000000, PCILIB_REGISTER_R , PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK_DMA, "xrawdata_data_mistmatch", ""},
-#ifdef DEBUG_HARDWARE
- {0x9050, 0, 32, 0, 0x00000000, PCILIB_REGISTER_R , PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK_DMA, "reg9050", ""},
- {0x9080, 0, 32, 0, 0x00000000, PCILIB_REGISTER_R , PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK_DMA, "reg9080", ""},
- {0x9090, 0, 32, 0, 0x00000000, PCILIB_REGISTER_R , PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK_DMA, "reg9090", ""},
- {0x9100, 0, 32, 0, 0x00000000, PCILIB_REGISTER_R , PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK_DMA, "reg9100", ""},
- {0x9110, 0, 32, 0, 0x00000000, PCILIB_REGISTER_R , PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK_DMA, "reg9110", ""},
- {0x9160, 0, 32, 0, 0x00000000, PCILIB_REGISTER_R , PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK_DMA, "reg9160", ""},
-#endif /* DEBUG_HARDWARE */
{0, 0, 0, 0, 0x00000000, 0, 0, 0, NULL, NULL}
};