Return immediately when using d_residual.
[debian/gnuradio] / usrp / doc / traffic-cop-dma
1 Matt,
2
3 Here's my idea on the interface to the traffic cop.  Basically I'm
4 thinking about treating it as 4 separate DMA channels, one for each of
5 the four possible "flows".  In the interest of simplicity, I think we can
6 assign buffers 0,1 to channel 0;  2,3 to channel 1, etc...
7
8 port assignments
9 -----------------
10   0   SERDES
11   1   DSP pipeline
12   2   Gigabit ethernet MAC
13   3   RAM
14
15
16 registers
17 ---------
18
19   MBZ == Must Be Zero
20
21      3                   2                   1
22    1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 
23
24
25 TC_DMA_SRC_{0,3} [WR] ("traffic cop DMA source, channel N")
26
27   (The {0,3} notation means there are four of these registers,
28    one for each channel, named TC_DMA_SRC_0, TC_DMA_SRC_1,
29    TC_DMA_SRC_2, TC_DMA_3.)
30
31   Specifies where the writing port adapter writes info the buffer, and
32   the maximum number of lines to write.
33
34        5             9                  9                9  
35   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36   |0|  src  |      start      |     end (max)   |       step      |
37   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38
39   src:   source port number.  E.g., 2 = ethernet MAC (the buffer writer)
40   start: starting line number for transfer (32-bit lines)
41   end:   index of last line to write.  I.e., start = 0, end = 0, xfers 1 line.
42   step:  normally 1.
43
44
45 TC_DMA_DST_{0,3} [WR]
46
47   Specifies the range of lines that the reading port adapter accesses.
48   The number of lines to be transferred is controlled by the source.
49
50        5             9                  9                9  
51   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52   |0|  dst  |      start      |    end (max)    |       step      |
53   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54
55   dst:   destination port number.  E.g., 1 = DSP pipeline (the buffer reader)
56   start: starting line number tranfer (32-bit lines)
57   end:   Must be zero, unless a TC_DMA_CMD_SEND_0 or TC_DMA_CMD_SEND_1
58          cmd is written to TC_DMA_CTRL_{0,3} in which case this
59          specifies the index of the last line to send to the destination.
60   step:  normally 1.
61
62
63 TC_DMA_CTRL_{0,3} [WR]
64
65                             27                           1    4
66   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
67   |                         MBZ                         |A|  cmd  |
68   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
69
70
71   A:    Set if "Host Approval" is required before beginning xfer to dst.
72         Used to allow processor to inspect packet for s/w dispatch.  If set,
73         traffic cop sets PENDING_APPROVAL bit (and causes interrupt?) after the
74         2nd line has been written into the buffer.   Reader is held off
75         until hosts APPROVES or DROPS the buffer.
76
77
78   cmd:  command
79
80     TC_DMA_CMD_RESET         0  // abort active tranfers now; reset to idle state
81     TC_DMA_CMD_START         1  // begin transfers according
82     TC_DMA_CMD_STOP          2  // stop transfers at completion of current buffer
83     TC_DMA_CMD_APPROVE_0     3  // host approves xfer on even buffer, continue
84     TC_DMA_CMD_APPROVE_1     4  // host approves xfer on odd buffer, continue
85     TC_DMA_CMD_DROP_0        5  // host naks xfer on even buffer, drop buffer and continue
86     TC_DMA_CMD_DROP_1        6  // host naks xfer on even buffer, drop buffer and continue
87     TC_DMA_CMD_SEND_0        7  // copy buffer 0 to destination (processor init'd buffer)
88     TC_DMA_CMD_SEND_1        8  // copy buffer 1 to destination (processor init'd buffer)
89
90
91 TC_DMA_STATUS_{0,3} [RD]
92
93            10                  10
94   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95   |    nwritten even  |   nwritten odd    |     state?    | flags |
96   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
97
98   nwritten even:  number of lines written into even buffer
99   nwritten odd:   number of lines written into odd buffer
100
101   flag bits:
102
103     bmTCDS_PENDING_APPROVAL_0   (1 << 0)   // pending host approval on even buffer
104     bmTCDS_PENDING_APPROVAL_1   (1 << 1)   // pending host approval on odd buffer
105     bmTCDS_WRITE_DONE_0         (1 << 2)   // the even buffer write is complete
106     bmTCDS_WRITE_DONE_1         (1 << 3)   // the odd buffer write is complete
107
108 I think the combination of the "host approval" and WRITE_DONE bits
109 will allow us to handle the cases where the host looks and doesn't
110 care, and the case where the host looks, cares, and needs to wait
111 until it sees the whole packet.
112
113 WRITE_DONE_* should be cleared when the corresponding buffer is
114 selected to be written into (e.g., when swapping buffers, and at init)
115 prior to writing the first line.  WRITE_DONE_* is set when the
116 requested number of lines have been written into the buffer.
117
118
119
120 I also want a "global status register" that pulls the N flag bits
121 from each of the 4 status registers into a single word.  This should
122 allow me to read a single word to figure out what to do.
123
124
125 TC_DMA_STATUS_GLOBAL [RD]
126
127   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
128   |     flags3    |     flags2    |     flags1    |     flags0    |
129   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
130
131
132
133 // some kind of registers to enable and ack interrupts
134
135 TC_DMA_INTR_EN  [WR]      // enable particular interrupts
136 TC_DMA_INTR_CLR [WR]      // clear particular pending interrupts
137