Altera_Forum
Honored Contributor
13 years agoTSE and scatter-gather dma problem
hi, everyone
I am recently trying to connect nios II to computor through ethernet , I separately connected a memory to stream scatter gather DMA to TSE's transmit and a stream to memory scatter gather DMA to TSE's receive . But when I sent a packet through scatter gather DMA, the output of TSE was nothing , also ,when I send packet from computor to NIOS, the receiving DMA got nothing. I had tried connect the memory to stream DMA to stream to memory DMA, it worked OK. Please give me some advice ,thanks. https://www.alteraforum.com/forum/attachment.php?attachmentid=5665 when I runned the code below , I checked ouput signals of TSE through signaltap II,but nothing happened# include "sys/alt_stdio.h"# include "altera_avalon_sgdma_regs.h"# include "altera_avalon_sgdma.h"# include "altera_avalon_sgdma_descriptor.h"
/* These will gate the data checking near the end of main */
volatile alt_u8 tx_done = 0;
volatile alt_u8 rx_done = 0;
void tx_callback_function(void * context)
{
tx_done++; /* main will be polling for this value being 1 */
}
void rx_callback_function(void * context)
{
rx_done++; /* main will be polling for this value being 1 */
}
unsigned int * mac_rev = (unsigned int *)TRIPLE_SPEED_ETHERNET_BASE;
unsigned int * mac_phy_addr = (unsigned int *)(TRIPLE_SPEED_ETHERNET_BASE+0x3C);
unsigned int * mac_phy_reg_addr_base = (unsigned int *)(TRIPLE_SPEED_ETHERNET_BASE+0x200);
unsigned int * mac_phy_reg_17 = (unsigned int *)(TRIPLE_SPEED_ETHERNET_BASE+0x200+ 17*4);
char rx_buf;
char tx_buf;
int i;
void init_phy()
{
* mac_phy_addr = 1;
* mac_phy_reg_addr_base = * mac_phy_reg_addr_base | 0x8000;
//*mac_phy_reg_addr_base = *mac_phy_reg_addr_base | 0x1000;
}
int main()
{
init_phy();
alt_printf("control register is %x\n", *mac_phy_reg_17);
alt_sgdma_dev * pSink = alt_avalon_sgdma_open(HITIC_SINK_NAME);
if(pSink == NULL)
{
alt_putstr("open sink error!\n");
}
alt_sgdma_dev * pSource = alt_avalon_sgdma_open(HITIC_SOURCE_NAME);
if(pSource == NULL)
{
alt_putstr("open source error!\n");
}
/**************************************************************
* Register the ISRs that will get called when each (full) *
* transfer completes *
************************************************************/
alt_avalon_sgdma_register_callback(pSource, &tx_callback_function,
(ALTERA_AVALON_SGDMA_CONTROL_IE_GLOBAL_MSK | ALTERA_AVALON_SGDMA_CONTROL_IE_CHAIN_COMPLETED_MSK),
NULL);
alt_avalon_sgdma_register_callback(pSink, &rx_callback_function,
(ALTERA_AVALON_SGDMA_CONTROL_IE_GLOBAL_MSK | ALTERA_AVALON_SGDMA_CONTROL_IE_CHAIN_COMPLETED_MSK),
NULL);
/**************************************************************/
alt_sgdma_descriptor sinkDesc, sourceDesc;
alt_sgdma_descriptor nextSinkDesc, nextSourceDesc;
nextSinkDesc.control = 0;
nextSinkDesc.control = 0;
alt_avalon_sgdma_construct_stream_to_mem_desc(&sinkDesc, &nextSinkDesc,
(alt_u32 *)rx_buf, 100, 0);
alt_avalon_sgdma_construct_mem_to_stream_desc(&sourceDesc, &nextSourceDesc,
(alt_u32 *)tx_buf, 100, 0, 0, 0, 0);
for(i = 0; i < 6; i ++)
{
tx_buf=0xff;
}
for(i = 6; i < 12; i ++)
{
tx_buf=0x11;
}
tx_buf = 0;
tx_buf = 100;
// while(1)
// {
// alt_avalon_sgdma_do_async_transfer(pSource, &sourceDesc);
// while(tx_done == 0) {}
// alt_putstr("The transmit SGDMA has completed\n");
// tx_done = 0;
// for(i = 0; i < 10000000; i++);
// }
while(1)
{
alt_avalon_sgdma_do_async_transfer(pSink, &sinkDesc);
while(rx_done == 0) {}
alt_putstr("The receive SGDMA has completed\n");
rx_done = 0;
}