ipe_private.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _PCILIB_DMA_IPE_PRIVATE_H
  2. #define _PCILIB_DMA_IPE_PRIVATE_H
  3. #include "dma.h"
  4. #define IPEDMA_64BIT_MODE 1 /**< 64-bit mode addressing is required to support PCIe gen3 */
  5. #define IPEDMA_CORES 1
  6. #define IPEDMA_MAX_TLP_SIZE 256 /**< Defines maximum TLP in bytes supported by device */
  7. //#define IPEDMA_TLP_SIZE 128 /**< If set, enforces the specified TLP size */
  8. #define IPEDMA_STREAMING_MODE /**< Enables streaming DMA operation mode instead of ring-buffer, the page is written once and forgotten and need to be pushed in queue again */
  9. #define IPEDMA_STREAMING_CHECKS /**< Enables status checks in streaming mode (it will cause performance penalty) */
  10. #define IPEDMA_PAGE_SIZE 4096
  11. #define IPEDMA_DMA_PAGES 1024 /**< number of DMA pages in the ring buffer to allocate */
  12. #define IPEDMA_DMA_PROGRESS_THRESHOLD 1 /**< how many pages the DMA engine should fill before reporting progress */
  13. #define IPEDMA_DESCRIPTOR_SIZE 128
  14. #define IPEDMA_DESCRIPTOR_ALIGNMENT 64
  15. //#define IPEDMA_BUG_DMARD /**< No register read during DMA transfer */
  16. //#define IPEDMA_BUG_LAST_READ /**< We should forbid writting the second last available DMA buffer (the last is forbidden by design) */
  17. //#define IPEDMA_DETECT_PACKETS /**< Using empty_deceted flag */
  18. #define IPEDMA_SUPPORT_EMPTY_DETECTED /**< Avoid waiting for data when empty_detected flag is set in hardware */
  19. #define IPEDMA_DMA_TIMEOUT 100000 /**< us, overrides PCILIB_DMA_TIMEOUT (actual hardware timeout is 50ms according to Lorenzo) */
  20. #define IPEDMA_RESET_DELAY 100000 /**< Sleep between accessing DMA control and reset registers */
  21. #define IPEDMA_ADD_PAGE_DELAY 1000 /**< Delay between submitting successive DMA pages into IPEDMA_REG_PAGE_ADDR register */
  22. #define IPEDMA_NODATA_SLEEP 10 /**< To keep CPU free */
  23. #define IPEDMA_REG_RESET 0x00
  24. #define IPEDMA_REG_CONTROL 0x04
  25. #define IPEDMA_REG_TLP_SIZE 0x0C
  26. #define IPEDMA_REG_TLP_COUNT 0x10
  27. #define IPEDMA_REG_PAGE_ADDR 0x50
  28. #define IPEDMA_REG_UPDATE_ADDR 0x54
  29. #define IPEDMA_REG_LAST_READ 0x58 /**< In streaming mode, we can use it freely to track current status */
  30. #define IPEDMA_REG_PAGE_COUNT 0x5C
  31. #define IPEDMA_REG_UPDATE_THRESHOLD 0x60
  32. #define IPEDMA_REG_STREAMING_STATUS 0x68
  33. #define WR(addr, value) { *(uint32_t*)(ctx->base_addr + addr) = value; }
  34. #define RD(addr, value) { value = *(uint32_t*)(ctx->base_addr + addr); }
  35. typedef struct ipe_dma_s ipe_dma_t;
  36. struct ipe_dma_s {
  37. pcilib_dma_context_t dmactx;
  38. //pcilib_dma_engine_description_t engine[2];
  39. const pcilib_register_bank_description_t *dma_bank;
  40. char *base_addr;
  41. pcilib_irq_type_t irq_enabled; /**< indicates that IRQs are enabled */
  42. pcilib_irq_type_t irq_preserve; /**< indicates that IRQs should not be disabled during clean-up */
  43. int irq_started; /**< indicates that IRQ subsystem is initialized (detecting which types should be preserverd) */
  44. int started; /**< indicates that DMA buffers are initialized and reading is allowed */
  45. int writting; /**< indicates that we are in middle of writting packet */
  46. int reused; /**< indicates that DMA was found intialized, buffers were reused, and no additional initialization is needed */
  47. int preserve; /**< indicates that DMA should not be stopped during clean-up */
  48. int mode64; /**< indicates 64-bit operation mode */
  49. pcilib_kmem_handle_t *desc; /**< in-memory status descriptor written by DMA engine upon operation progess */
  50. pcilib_kmem_handle_t *pages; /**< collection of memory-locked pages for DMA operation */
  51. size_t ring_size, page_size;
  52. size_t last_read, last_read_addr, last_written;
  53. };
  54. #endif /* _PCILIB_DMA_IPE_PRIVATE_H */