1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

tests/dma: update to current progress

This commit is contained in:
Daniel Krebs 2018-05-15 17:54:37 +02:00
parent 7dcdfaccd9
commit 24db7ea1c0

View file

@ -26,38 +26,52 @@ Test(fpga, dma, .description = "DMA")
auto dma = reinterpret_cast<villas::fpga::ip::Dma&>(*ip);
if(not dma.connectLoopback()) {
if(not dma.loopbackPossible()) {
logger->info("Loopback test not possible for {}", *ip);
continue;
}
count++;
if(not dma.loopbackPossible()) {
logger->info("Loopback test not possible for {}", *ip);
continue;
}
// Simple DMA can only transfer up to 4 kb due to PCIe page size burst
// limitation
size_t len = 4 * (1 << 10);
// find a block RAM IP to write to
auto bramIp = state.cards.front()->lookupIp(villas::fpga::Vlnv("xilinx.com:ip:axi_bram_ctrl:"));
auto bram = reinterpret_cast<villas::fpga::ip::Bram*>(bramIp);
cr_assert_not_null(bram, "Couldn't find BRAM");
// Simple DMA can only transfer up to 4 kb due to PCIe page size burst
// limitation
size_t len = 4 * (1 << 10);
/* Allocate memory to use with DMA */
auto src = villas::HostRam::getAllocator().allocate<char>(len);
auto dst = bram->getAllocator().allocate<char>(len);
auto src = villas::HostDmaRam::getAllocator().allocate<char>(len);
auto dst = villas::HostDmaRam::getAllocator().allocate<char>(len);
/* ... only works with IOMMU enabled currently */
// auto src = bram->getAllocator().allocate<char>(len);
// auto dst = bram->getAllocator().allocate<char>(len);
/* ... only works with IOMMU enabled currently */
// auto src = villas::HostRam::getAllocator().allocate<char>(len);
// auto dst = villas::HostRam::getAllocator().allocate<char>(len);
/* Make sure memory is accessible for DMA */
cr_assert(dma.makeAccesibleFromVA(src.getMemoryBlock()),
"Source memory not accessible for DMA");
cr_assert(dma.makeAccesibleFromVA(dst.getMemoryBlock()),
"Destination memory not accessible for DMA");
/* Get new random data */
const size_t lenRandom = read_random(&src, len);
cr_assert(len == lenRandom, "Failed to get random data");
/* Start transfer */
cr_assert(dma.memcpy(src.getMemoryBlock(), dst.getMemoryBlock(), len),
"DMA ping pong failed");
/* Compare data */
cr_assert(memcmp(&src, &dst, len) == 0, "Data not equal");