pcie-dma-trx: update to version 0x2

1. support buffer_size set by user
2. support assigned chn
3. support udma read
4. support buffer address set by userspace

Need to update test_pcie and test-pcie-ep-new.

New test command:

1. run ./test-pcie-ep-new 500 1024 chn_num buffer_address both on RC and EP first
   Release buffer use dma channel number = chn_num.

   if buffer_address = 0
	   pcie_dma_buffer_address get from DT reserved memory
   else
	   pcie_dma_buffer_address = buffer_address

2. run ./test-pcie 1 1000 1024 1 chn_num on RC
   The last "1" means enable PCIe udma read, "0" means write.
   RC read from EP use dma channel number = chn_num.

3. run ./test-pcie 2 1000 1024 1 chn_num on EP
   EP read from RC with offset = buffer count * buffer size.

4. check version by:
   cat /sys/kernel/debug/pcie/pcie_trx | grep version

5. 1024 means set buffer size to 1MB.

Change-Id: I7613037924659c75014d19b6c4845e096a56d295
Signed-off-by: Simon Xue <xxm@rock-chips.com>
This commit is contained in:
Simon Xue
2021-11-11 10:47:09 +08:00
committed by Jon Lin
parent b3bd9dfe5d
commit 1255dee7d3
4 changed files with 378 additions and 125 deletions

View File

@ -2,11 +2,14 @@
/*
* Copyright (C) 2018 Rockchip Electronics Co., Ltd.
*/
#ifndef _UAPI__PCIE_DMA_TRX_H__
#define _UAPI__PCIE_DMA_TRX_H__
enum transfer_type {
PCIE_DMA_DATA_SND,
PCIE_DMA_DATA_RCV_ACK,
PCIE_DMA_DATA_FREE_ACK,
PCIE_DMA_READ_REMOTE,
};
union pcie_dma_ioctl_param {
@ -16,6 +19,7 @@ union pcie_dma_ioctl_param {
u32 r_widx;
u32 size;
u32 type;
u32 chn;
} in;
struct {
u32 lwa;
@ -23,6 +27,9 @@ union pcie_dma_ioctl_param {
} out;
u32 lra;
u32 count;
u32 total_buffer_size;
phys_addr_t local_addr;
u32 buffer_size;
};
#define PCIE_BASE 'P'
@ -42,4 +49,13 @@ union pcie_dma_ioctl_param {
_IO(PCIE_BASE, 6)
#define PCIE_DMA_SET_LOOP_COUNT \
_IOW(PCIE_BASE, 7, union pcie_dma_ioctl_param)
#define PCIE_DMA_GET_TOTAL_BUFFER_SIZE \
_IOW(PCIE_BASE, 8, union pcie_dma_ioctl_param)
#define PCIE_DMA_SET_BUFFER_SIZE \
_IOW(PCIE_BASE, 9, union pcie_dma_ioctl_param)
#define PCIE_DMA_READ_FROM_REMOTE \
_IOW(PCIE_BASE, 0xa, union pcie_dma_ioctl_param)
#define PCIE_DMA_USER_SET_BUF_ADDR \
_IOW(PCIE_BASE, 0xb, union pcie_dma_ioctl_param)
#endif