BEST DMA device

1. Introduction

BEST DMA device is a subpart of BEST PCIe driver.
For each mSGDMA module in FPGA there is a char device.

2. Operation
2.1 Internal buffers
Driver at initialisation creates its internal buffers for DMA to write.
There are usually 4 or 8 buffers, size from 1MB to 4MB.

2.2 read()
Calling a read() function on dma device will copy to user space most recent
data. Driver will look at curent_buff_idx variable, which saves index of a
buffer currently beening writen to. Driver leaves that buffer and reads from
one buffer back, which has the most recent data.
Maximum read lengh is buf_len * (buf_nr-1);

                      curent_buff_idx
                             V
    +------------+    +------------+    +------------+
    |            |    |NNNNNOOOOOOO|    |            |
    +------------+    +------------+    +------------+
                            |
                           DMA writes here


2.2.1 Reading half buffer will get you (noted with numbers):

  Internal buffers:
                      curent_buff_idx
                             V
    +------------+    +------------+    +------------+
    |      123456|    |NNNNNOOOOOOO|    |            |
    +------------+    +------------+    +------------+
                            |
                           DMA writes here

  Read() buffer, returned to user:
    +------+
    |123456|
    +------+


2.2.2 Reading buffer and half will get you (noted with numbers):

  Internal buffers:
                      curent_buff_idx
                             V
    +------------+    +------------+    +------------+
    |789012345678|    |NNNNNOOOOOOO|    |      123456|
    +------------+    +------------+    +------------+
                            |
                           DMA writes here

  Read() buffer, returned to user:
    +-----------------+
    |12345678901234568|
    +-----------------+


