User Manual
BCM1250/BCM1125/BCM1125H
10/21/02
B r o a d c o m C o r p o r a t i o n
Document
1250_1125-UM100CB-R
Section 4: System Control and Debug Unit
Page
85
T
RACE
E
XAMPLE
2: N
ETWORK
P
ACKET
H
EADERS
This example uses the trace buffer as a non-obtrusive record of the most recent network packet headers that
were received from one of the MACs. It could be used, for example, when there is a bug that is thought to be
caused by the processing of some rare sequence of network packets.
The trick is to notice that the DMA controller will always write the receive DMA status back into the DMA
descriptor at the end of packet reception. This is used to prime collection of the first two transfers of the next
packet.
The first address trap is set up to detect the range of addresses that cover the receive DMA descriptor ring.
trace0
detects a write to this space from the I/O bridge that connects the MACs. This write is done at the end
of a packet reception to put the status flags into the descriptor (the requester ID is needed here because the
CPU will also be writing the ring to update the descriptors).
seq0
uses this to start the trace collection. When
a packet arrives the DMA will write it to memory in 32 byte cache line chunks. The address associated with the
write request triggers
trace1
, and
seq1
filters it to be recorded (this may not be needed in this example, and
will be fairly costly because it will unalign the trace buffer pointer from the entry boundary).
The
trace2
is used to detect a write data transfer from the MAC to the buffer memory. It does this by detecting
a transfer on the data bus where the data source (in the resp_id field) and the initiator of the transaction (in the
data_id field) are the same. This is enough to detect that some write data is in flight from the I/O bridge. The
seq2
sequence will first need
trace1
to detect the write request to the buffer addresses before looking at
trace2
to detect the data transfer part of the transaction. When the sequence is triggered the data sample is
taken and written to the trace buffer.
Since the network packet header is in the first 64 bytes of the packet only the first two DMA transfers should
be recorded.
seq2
will trigger on both, causing data to be written to the trace buffer.
seq3
has to see both
transfers before it triggers and stops collection.
This process repeats, using the trace memory as a circular buffer, until the Freeze command is given (by
software writing the
trace_cfg
register). At this point the trace buffer can be read out, showing the last 64
packet headers. (Two lines in the buffer are used up for each DMA transfer recorded -- the first has the
seq1
address sample and two empty slots, and the second the
seq2
address/data sample. Since the first two
transfers of each packet are recorded there are 4 trace buffer lines per packet).
Addr0 = range of receive DMA descriptors for the MAC
Addr1 = range of receive buffers
trace0 = reqid=iobr1 & Addrmatch0 & write (A phase of descr write)
trace1 = reqid=iobr1 & Addrmatch1 & write (A phase of write)
trace2 = rspid=iobr1 & dataid=iobr1 (write data from iobridge)
seq0 = trace0, ignore, ignore, ignore -> Start
seq1 = trace1, ignore, ignore, ignore -> A-sample
seq2 = trace1, trace2, ignore, ignore -> D-sample
seq3 = trace1, trace2, trace1, trace2 -> Stop