nwl_private.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef _PCILIB_DMA_NWL_PRIVATE_H
  2. #define _PCILIB_DMA_NWL_PRIVATE_H
  3. typedef struct nwl_dma_s nwl_dma_t;
  4. typedef struct pcilib_nwl_engine_context_s pcilib_nwl_engine_context_t;
  5. #define NWL_DMA_IRQ_SOURCE 0
  6. #define NWL_XAUI_ENGINE 0
  7. #define NWL_XRAWDATA_ENGINE 1
  8. #define NWL_MAX_PACKET_SIZE 4096 //16384
  9. //#define NWL_GENERATE_DMA_IRQ
  10. #define PCILIB_NWL_ALIGNMENT 64 // in bytes
  11. #define PCILIB_NWL_DMA_DESCRIPTOR_SIZE 64 // in bytes
  12. #define PCILIB_NWL_DMA_PAGES 256 // 1024
  13. #define PCILIB_NWL_REGISTER_TIMEOUT 10000 /**< us */
  14. #include "datacpy.h"
  15. #include "nwl.h"
  16. #include "nwl_irq.h"
  17. #include "nwl_engine.h"
  18. #include "nwl_loopback.h"
  19. #define nwl_read_register(var, ctx, base, reg) pcilib_datacpy(&var, base + reg, 4, 1, ctx->dma_bank->raw_endianess)
  20. #define nwl_write_register(var, ctx, base, reg) pcilib_datacpy(base + reg, &var, 4, 1, ctx->dma_bank->raw_endianess)
  21. struct pcilib_nwl_engine_context_s {
  22. const pcilib_dma_engine_description_t *desc;
  23. char *base_addr;
  24. size_t ring_size, page_size;
  25. size_t head, tail;
  26. pcilib_kmem_handle_t *ring;
  27. pcilib_kmem_handle_t *pages;
  28. int started; /**< indicates that DMA buffers are initialized and reading is allowed */
  29. int writting; /**< indicates that we are in middle of writting packet */
  30. int reused; /**< indicates that DMA was found intialized, buffers were reused, and no additional initialization is needed */
  31. int preserve; /**< indicates that DMA should not be stopped during clean-up */
  32. };
  33. typedef enum {
  34. NWL_MODIFICATION_DEFAULT,
  35. NWL_MODIFICATION_IPECAMERA
  36. } nwl_modification_t;
  37. struct nwl_dma_s {
  38. pcilib_dma_context_t dmactx;
  39. nwl_modification_t type;
  40. int ignore_eop; /**< always set end-of-packet */
  41. const pcilib_register_bank_description_t *dma_bank;
  42. char *base_addr;
  43. pcilib_irq_type_t irq_enabled; /**< indicates that IRQs are enabled */
  44. pcilib_irq_type_t irq_preserve; /**< indicates that IRQs should not be disabled during clean-up */
  45. int started; /**< indicates that DMA subsystem is initialized and DMA engine can start */
  46. int irq_started; /**< indicates that IRQ subsystem is initialized (detecting which types should be preserverd) */
  47. int loopback_started; /**< indicates that benchmarking subsystem is initialized */
  48. // pcilib_dma_engine_t n_engines;
  49. pcilib_nwl_engine_context_t engines[PCILIB_MAX_DMA_ENGINES + 1];
  50. };
  51. int nwl_add_registers(nwl_dma_t *ctx);
  52. #endif /* _PCILIB_DMA_NWL_PRIVATE_H */