Just some code to play with the DMA bus.
src | ||
.gitignore | ||
LICENSE | ||
Makefile | ||
README.md |
dmatest
Just some code to buid a kernel module to play around with the DMA bus. The actual intent is to create an RDMA demo eventually.
-
Direct Piping Interface:
- Write to
/dev/dma_in
to send data - Read from
/dev/dma_out
to receive data
- Write to
-
DMA Buffer Management:
- Automatically allocates DMA buffers
- Handles buffer size limitations
-
Progress Reporting:
- Kernel logs show transfer progress
- Percentage and byte counts reported
-
IOCTL Commands:
DMA_GET_PHYS_ADDR
: Get physical DMA addressDMA_GET_BUFFER_SIZE
: Get buffer sizeDMA_TRANSFER_COMPLETE
: Signal transfer completion
-
Synchronization:
- Proper mutex protection for shared data
- Wait queues for blocking operations
Usage example:
# Load the module
sudo insmod dma_pipe.ko
# Send data to DMA input
cat input_file > /dev/dma_in
# Receive data from DMA output
cat /dev/dma_out > output_file
# Monitor progress
dmesg | tail
3. **Verification Steps**:
```bash
# Check kernel version
uname -r
# Clean rebuild
make clean && make
# Load module
sudo insmod dma_transfer.ko
# Verify
dmesg | tail
ls -l /dev/dma_transfer
This solution:
- Maintains all DMA functionality
- Works across different kernel versions
- Includes proper error handling and cleanup
- Provides clear debug output
The module creates /dev/dma_transfer
which can be used with standard file operations while utilizing DMA buffers for data transfer.
NOTE: You'll need a special NIC (InfiniBand or a RoCEv2-capable card to implement RDMA between hosts).