summaryrefslogtreecommitdiffstats
path: root/dma_private.h
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2023-05-25 22:41:04 +0200
committerSuren A. Chilingaryan <csa@suren.me>2023-05-25 22:41:04 +0200
commit6f4af841f6fdd099b97d071ae64c8be60f809456 (patch)
treed4f9a18b38e1ce3cfc0a5336215d5ce3afe830d2 /dma_private.h
downloadpcidev-6f4af841f6fdd099b97d071ae64c8be60f809456.tar.gz
pcidev-6f4af841f6fdd099b97d071ae64c8be60f809456.tar.bz2
pcidev-6f4af841f6fdd099b97d071ae64c8be60f809456.tar.xz
pcidev-6f4af841f6fdd099b97d071ae64c8be60f809456.zip
A sample event engine for pcitool (not requiring any PCIe hardware). Initial (barely tested and intended only as an example) release
Diffstat (limited to 'dma_private.h')
-rw-r--r--dma_private.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/dma_private.h b/dma_private.h
new file mode 100644
index 0000000..53e951b
--- /dev/null
+++ b/dma_private.h
@@ -0,0 +1,46 @@
+#ifndef _PCIDEV_DMA_PRIVATE_H
+#define _PCIDEV_DMA_PRIVATE_H
+
+#include <pcilib/dma.h>
+
+#define PCIDEV_DMA_DESCRIPTOR_SIZE 128
+#define PCIDEV_DMA_DESCRIPTOR_ALIGNMENT 64
+
+#define PCIDEV_DMA_FLAG_NOSYNC 0x01 /**< Do not call kernel space for page synchronization */
+#define PCIDEV_DMA_FLAG_NOSLEEP 0x02 /**< Do not sleep in the loop while waiting for the data */
+#define PCIDEV_DMA_NODATA_SLEEP 100 /**< To keep CPU free, in nanoseconds */
+
+typedef uint32_t reg_t;
+typedef struct pcidev_dma_s pcidev_dma_t;
+typedef struct pcidev_dma_desc_s pcidev_dma_desc_t;
+
+struct pcidev_dma_desc_s {
+ uint32_t page_count;
+ volatile uintptr_t last_write_addr;
+ volatile uintptr_t last_read_addr;
+};
+
+struct pcidev_dma_s {
+ pcilib_dma_context_t dmactx;
+
+ pcilib_kmem_handle_t *desc; /**< in-memory status descriptor written by DMA engine upon operation progess */
+ pcilib_kmem_handle_t *pages; /**< collection of memory-locked pages for DMA operation */
+
+ pcilib_dma_engine_t rdma;
+
+ uint32_t version; /**< hardware revision */
+
+ int started; /**< indicates that DMA buffers are initialized and reading is allowed */
+ int writting; /**< indicates that we are in middle of writting packet */
+ int reused; /**< indicates that DMA was found intialized, buffers were reused, and no additional initialization is needed */
+ int preserve; /**< indicates that DMA should not be stopped during clean-up */
+
+ uint32_t dma_flags; /**< Various operation flags, see PCIDEV_DMA_FLAG_* */
+ size_t dma_timeout; /**< DMA timeout, PCIDEV_DMA_TIMEOUT is used by default */
+ size_t dma_pages; /**< Number of DMA pages in ring buffer to allocate */
+
+ size_t ring_size, page_size; /**< Number of pages in ring buffer and the size of a single DMA page */
+ size_t last_read;
+};
+
+#endif /* _PCIDEV_DMA_PRIVATE_H */