cancel
Showing results for 
Search instead for 
Did you mean: 

Multiplue ENET Transmit descriptors

mark10
Associate II
Posted on September 27, 2007 at 15:23

Multiplue ENET Transmit descriptors

6 REPLIES 6
mark10
Associate II
Posted on May 17, 2011 at 09:45

Hi all,

STR912F device

I'm trying to get the ENET transmitter to work with more than one descriptor. Have got two descriptors linked together in a ring and I'm setting the NXT_EN bit within the ENET_TXCR register for both packets.

I have loaded the data and length etc. into the descriptors and buffers then I start the DMA.

1st packet comes out but the DMA always stop's no errors and for no reason so the 2nd packet never gets sent.

Has anyone hade a similar problem or a workaround.

It all works OK with just one descriptor.

Comments Welcomes

Mark

alandras
Associate II
Posted on May 17, 2011 at 09:45

Hi,

how did you set NPOL_EN: Next Descriptor Polling Enable from ENET_TXNDAR?

Are both desriptors valid when you start the DMA? How you tested that only one packet is sent? DMA should stop on the first descriptor if you linked them in a ring.

I'm using mulptiple descriptors and link then on the fly but have no problem.

Andras

sarao
Associate II
Posted on May 17, 2011 at 09:45

I'm just curious, but what are you doing that the descriptor needs to change?

I'm working on a ethernet heavy application and I'm trying to be proactive in learning about any issues that may come up and create a library that handles these conditions appropriately.

sarao
Associate II
Posted on May 17, 2011 at 09:45

I merged code from the Keil ''Easyweb'' example:

#define NUM_TX_BUFFERS 20 // allow up to 4 buffers.

static ENET_DMADSCRBase dmaTxDscrBase[ NUM_TX_BUFFERS ];

static u8 TxBuff[ EMAC_MAX_PACKET_SIZE * NUM_TX_BUFFERS ];

static u32 TxDscrIndex;

void ENET_TxDscrInit(void)

{

u32 currIndex; // index to the current descriptor

u32 nextIndex = 0; // index to the start of the next descriptor in the

// chain

u8 * pNextBuffer; // pointer to the RX next buffer in memeory

ENET_DMADSCRBase * pCurrentDescr;

ENET_DMADSCRBase * pNextDescr;

for ( currIndex = 0; currIndex < NUM_TX_BUFFERS; ++currIndex )

{

if ( (++nextIndex) == NUM_TX_BUFFERS ) // for the last descriptor

nextIndex = 0; // loop back to the first buffer.

pCurrentDescr = &dmaTxDscrBase[ currIndex ];

pNextDescr = &dmaTxDscrBase[ nextIndex ];

pNextBuffer = (u8*)(TxBuff + (currIndex * EMAC_MAX_PACKET_SIZE));

/* Initialize ENET status and control */

pCurrentDescr->dmaStatCntl = 0;

/* ENET Start Address */

pCurrentDescr->dmaAddr = (u32)pNextBuffer;

/* Next Descriptor Address */

pCurrentDescr->dmaNext = (u32)pNextDescr | DMA_DSCR_NXT_NPOL_EN;

/* Setting the VALID bit */

pCurrentDescr->dmaPackStatus = 0;//DMA_DSCR_TX_STATUS_VALID_MSK;

}

TxDscrIndex = 0;

/* Tx next set to Tx decriptor base */

ENET_DMA->TXNDAR = (u32)&(dmaTxDscrBase);

/* Enable next enable */

ENET_DMA->TXNDAR |= DMA_DSCR_NXT_NPOL_EN;

}

[ This message was edited by: jsarao on 27-09-2007 18:56 ]

sarao
Associate II
Posted on May 17, 2011 at 09:45

And here is my Transmit Packet code.

void ENET_TxPkt( void * ppkt, u16 size )

{

ENET_DMADSCRBase * pDescr = &dmaTxDscrBase[ TxDscrIndex ];

u8 * pTxBuffer = (u8*)(pDescr->dmaAddr & ~3);

if ( ++TxDscrIndex == NUM_TX_BUFFERS )

TxDscrIndex = 0;

MEMCOPY_L2S_BY4( pTxBuffer, (u8*)ppkt, size );

/* Setting the Frame Length & enable for next descriptor */

pDescr->dmaStatCntl = ( size | DMA_DSCR_CNTL_NXTEN );

/* Start the ENET by setting the VALID bit in dmaPackStatus of current

descr*/

pDescr->dmaPackStatus = DMA_DSCR_TX_STATUS_VALID_MSK;

/* Start the receive operation */

ENET_DMA->TXSTR |= DMA_TX_START_FETCH;

}

[ This message was edited by: jsarao on 27-09-2007 18:58 ]

sarao
Associate II
Posted on May 17, 2011 at 09:45

[I must have been exceeding some max character count or something. Anyway...]

The above code is a merge of the Keil ''easyweb'' example with the ENET library from ST.

I have the same thing implemented for the Receive (RX) as well.

The transmit works and seems to work well.

If anyone can see any problems, or can suggest any improvements, it would be much appreciated.

-Jeremy

[ This message was edited by: jsarao on 27-09-2007 19:00 ]