Skip to content

Commit

Permalink
driver: Support multiple DMA buffers
Browse files Browse the repository at this point in the history
driver: Change ioctl calls

Signed-off-by: João Silva <jgc3silva@gmail.com>
  • Loading branch information
vankxr committed Jun 1, 2024
1 parent 412defa commit 33e4dd4
Show file tree
Hide file tree
Showing 3 changed files with 302 additions and 72 deletions.
28 changes: 18 additions & 10 deletions software/driver/include/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@

typedef struct
{
uint64_t ullPhysAddr;
uint32_t ulBufSize;
} icyradio_ioctl_dma_buffer_query_t;
union
{
uint64_t ullPhysAddr; // For querying by physical address or to return the physical address
uint64_t ullIndex; // For querying by index
};
uint32_t ulSize; // Size of the buffer
} icyradio_ioctl_dma_buffer_t;

#define ICYRADIO_IOCTL_DMA_ALLOC _IOWR('B', 64, uint64_t *)
#define ICYRADIO_IOCTL_DMA_QUERY _IOR('B', 65, icyradio_ioctl_dma_buffer_query_t *)
#define ICYRADIO_IOCTL_DMA_FREE _IO('B', 66)
#define ICYRADIO_IOCTL_IRQ_QUERY _IOR('B', 67, uint8_t *)
#define ICYRADIO_IOCTL_IRQ_FLUSH _IO('B', 68)
#define ICYRADIO_IOCTL_IRQ_NOFLUSH _IO('B', 69)
#define ICYRADIO_IOCTL_DMA_ALLOC _IOWR('B', 64, icyradio_ioctl_dma_buffer_t *) // Allocate a DMA buffer
#define ICYRADIO_IOCTL_DMA_GET_COUNT _IOR('B', 65, uint64_t *) // Get the number of allocated DMA buffers
#define ICYRADIO_IOCTL_DMA_QUERY_BY_ADDR _IOR('B', 66, icyradio_ioctl_dma_buffer_t *) // Query a DMA buffer by physical address
#define ICYRADIO_IOCTL_DMA_QUERY_BY_INDEX _IOR('B', 67, icyradio_ioctl_dma_buffer_t *) // Query a DMA buffer by index
#define ICYRADIO_IOCTL_DMA_FREE _IOW('B', 68, icyradio_ioctl_dma_buffer_t *) // Free a DMA buffer
#define ICYRADIO_IOCTL_DMA_FREE_ALL _IO('B', 69) // Free all DMA buffers

#define ICYRADIO_IOCTL_SERIAL_QUERY _IOR('B', 96, uint64_t *)
#define ICYRADIO_IOCTL_IRQ_QUERY _IOR('B', 80, uint8_t *) // Query the number of allocated IRQ vectors
#define ICYRADIO_IOCTL_IRQ_FLUSH _IO('B', 81) // Flush the IRQ count (resets to zero and does not rise)
#define ICYRADIO_IOCTL_IRQ_NOFLUSH _IO('B', 82) // Do not flush the IRQ count (returns to normal operation)

#define ICYRADIO_IOCTL_SERIAL_QUERY _IOR('B', 96, uint64_t *) // Query the serial number of the device

#endif // __IOCTL_H__
18 changes: 13 additions & 5 deletions software/driver/include/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,30 @@
#include <linux/spinlock.h>
#include <linux/mutex.h>

typedef struct
typedef struct icyradio_dma_buffer_t icyradio_dma_buffer_t;
typedef struct icyradio_dev_t icyradio_dev_t;
struct icyradio_dma_buffer_t
{
void *pVirt;
dma_addr_t ulPhys;
uint32_t ulSize;
icyradio_dma_buffer_t *pNext;
};

struct icyradio_dev_t
{
struct mutex sMutex;
uint32_t ulDevID;
uint64_t ullSerialNumber;
struct pci_dev *pPCIDev;
struct file *pFile;
struct cdev sCharDev;
void *pDMAVirtAddr;
dma_addr_t ulDMAPhysAddr;
uint32_t ulDMABufSize;
icyradio_dma_buffer_t *pDMABuffers;
int iNumIRQs;
wait_queue_head_t sIRQWaitQueue;
spinlock_t sIRQLock;
uint64_t ullIRQCount;
uint8_t ubIRQFlush;
} icyradio_dev_t;
};

#endif // __STRUCTS_H__
Loading

0 comments on commit 33e4dd4

Please sign in to comment.