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 7: DMA Page
181
Examples
The following examples illustrate uses of the checksum and CRC engine. These are intended to illustrate use
of the data mover generators, in some cases it will be more efficient to do more processing of small buffers on
the CPU rather than expending more effort on managing descriptors.
Figure 33: Example 1 - TCP checksum a packet
Example 1 illustrated in
shows preparing a packet for transmission by computing its TCP checksum.
The example has a packet made up of a header buffer (with Ethernet, IP and TCP headers) and two data
buffers. Prior to passing the descriptors to the data mover software should compute the checksum of the
pseudo-header (the source and destination IP addresses, the protocol type and the TCP Length) and write this
(rather than zero) to the checksum field in the TCP header. The descriptors are set up so the first resets the
sum and adds the bytes in the TCP header. The pseudo-header sum is included (this takes advantage of the
fact that the order of the adds does not matter). The second descriptor adds the first data block, and the third
descriptor the second data block. Because the Prefetch flag is set the buffers are only read and no copy is
made. The third descriptor has the Append CS flag set so the destination address is used to write out the final
checksum. The destination points to the checksum field in the TCP header, so the final checksum is
automatically written into the packet. If the packet is going to be sent over the Ethernet interface after only a
short delay then consideration should be given to setting the l2ca_src flag in all the descriptors so the packets
are only read from memory once and staged in the L2 cache for transmission. In this example l2ca_src should
certainly be set in the first descriptor since the buffer will be at most two cache blocks and the data mover will
soon be doing a read-modify-write to update the two checksum bytes.
Eth
Data (1)
Src
Enable CS
Hdr
IP
Hdr
TCP
Hdr
Data (2)
Dst
Reset CS
Prefetch
Src
Enable CS
Dst
Prefetch
Src
Enable CS
Dst
Append CS
Prefetch
Len=TCPHdr
Len=Len(1)
Len=Len(2)