I can see a few problems in tse_mac_raw_sendM.
First you don't bypass the cache when writing the packet contents.
Second, in the "recopy to buf2" loop, you are reading the contents back using IORD_8DIRECT, whereas you filled it the [] operator. The second method uses the cache, but the first one bypasses it, so you may read back completely different data.
Third, you don't use the ActualData pointer in the SGDMA descriptor.
I would first create two uncached pointers:
char *uncached_pkt = alt_remap_uncached ((volatile void*) pkt, 256);
char *uncached_buf2 = alt_remap_uncached ((volatile void*) buf2, 1560);
Then use the uncached versions to access the data:
uncached_pkt=0xCC;
uncached_pkt=0xCC;
for(k=2;k<254;k++){
uncached_pkt=0xA5;
}
uncached_pkt=0xEE;
uncached_pkt=0xEE;
for(i=0;i<length;i++) {
uncached_buf2 = uncached_pkt;
}
ActualData = (unsigned int*)buf2;
(by the way, I'm not sure buf2 will be properly 32-bit aligned this way...)
Then to remove bit 31 before building the descriptor, you need to call remap_cached, not remap_uncached:
ActualData = (unsigned int*)alt_remap_cached ((volatile void*) ActualData, 256);
And finally build the descriptor with ActualData:
alt_avalon_sgdma_construct_mem_to_stream_desc(
(alt_sgdma_descriptor *) desc, // descriptor I want to work with
(alt_sgdma_descriptor *) desc,// pointer to "next"
(alt_u32 *)ActualData, // starting read address
(length), //# bytes
1, // don't read from constant address
1, // generate sop
1, // generate endofpacket signal
0); // atlantic channel (don't know/don't care: set to 0)
I hope this helps