Skip to main content
Visitor II
October 17, 2007
Question

ENET DMA overflow on receive

  • October 17, 2007
  • 13 replies
  • 2569 views
Posted on October 17, 2007 at 06:38

ENET DMA overflow on receive

    This topic has been closed for replies.

    13 replies

    jwester9Author
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:47

    Hi

    I use Keil ethernet driver with lwip and have problem to handle receive overflow on DMA.

    I have enabled the RX_NEXT interrupt (generated if no valid descr found) and I also got the interrupt and trying to drop the packet by setting the VALID bit, but it not works, I got a new interrupt directly. Has anyone an example how to handle it in right way, maybe I have to go throu all descr and set the VALID bit ?

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:47

    What are you trying to achieve? Counting the dropped packets?

    I don't now the KEIL driver, but the VALID bit should be set after you processed the packet. Until that packets are dropped automatically.

    Andras

    jwester9Author
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:47

    First of all I will get it running without stop and drop the overflow packets.

    To clearify, if I set the NPOL_EN it will drop the packet automatically

    and on RX_CURR_DONE I process the receive packet and set the VALID bit

    If all descr are occupied the packets is dropped, but do I still got RX_CURR_DONE for the queued descr so I can continue to process recive packets

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:47

    you should have NPOL_EN=1 loaded from descriptor (ENET_RXNDAR) but also

    NXT_EN=1 in ENET_RXCR loaded from DMA_CONTROL part of descripor (where DMA_XFERCOUNT = size is)

    NPOL_EN is for polling only, if you can guarantee that next buffer is always valid, or you restart fetching after an overflow NEXT_EN should be enough. This could save some cycles depending on DFETCH_DLY but is more complicated than just setting the VALID bit.

    Andras

    [ This message was edited by: alandras on 27-09-2007 13:51 ]

    jwester9Author
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:47

    It works now, and it was necessary with the loop.

    The driver use 4 descr for receive and 2 descr for send, maybe the performance is little slow, maybe the stack is the problem

    I have tested it with ping running and stop/run the board with debugger and the ping allways start again.

    Also tested with Netwox generating random IP block together with ping, and ping mostley timeout but still running.

    Thanks for all help

    jwester9Author
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:47

    I have NPOL_EN as you describe and now it never stop, I also put in a loop in interrupt on RX_CURR_DONE to see if it is more than one descr ready, maybe this is not necessary ?

    How can I counting dropped packets on easy way, shall I use RX_NEXT interrupt ?

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:47

    >>RX_CURR_DONE to see if it is more than one descr ready, maybe this is not necessary ?

    I think so.

    >>How can I counting dropped packets on easy way, shall I use RX_NEXT interrupt ?

    There is a ''PACKET_LOST_EN: PACKET_LOST interrupt enable''

    in the ''DMA Interrupt Enable Register'' and

    ''RX_TO_EN: RX_TO interrupt enable''

    but is not well documented.

    Andras

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:47

    Reference Manual

    http://www.st.com/stonline/products/literature/um/12126.pdf page 98

    Current Vector Address Register (VICx_VAR)

    ''– At the end of the ISR, write to the VIC0_VAR register (or VIC1_VAR if the interrupt source is from VIC1) to update the priority hardware.''

    Could be this?

    Andras

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:47

    JW,

    Do you have sample code of your Ethernet (ENET) Interrupt Handler routine that you can post?

    I think I'm having a similar problem:

    1. Ethernet interrupts occur (RX_CURR_DONE)

    2. Handle interrupt: copy data from descriptor, set valid bit

    3. At some point later, I no longer get any interrupts

    PROBLEM: I never see any of the error interrupts (PACKET_LOST_EN, RX_MERR_INT_EN, RX_TO_EN)

    PROBLEM: I no longer get any receive interrupts either

    Here is my current handler (trimmed down):

    Code:

    void ENET_IRQHandler(void)

    {

    while ( (ENET_DMA->ISR) & ENET_DMA->IER )

    {

    // 15: RX_CURR_DONE_EN: RX_CURR_DONE interrupt enable

    if ( ENET_DMA->ISR & 0x00008000 )

    {

    ENET_IRQ_COUNT[15]++;

    if ( ENET_HandleRxPkt( RCVR_BUFFER ) == 0 )

    {

    while ( 1 )

    {

    }

    }

    ENET_DMA->ISR |= 0x00008000;

    }

    }

    }

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:47

    Andras,

    Thanks for the tip. I got real excited and thought this might be it! But it looks like this is taken care of in the IRQ.s code.

    Code:

    LDR R1, =VectorAddrDaisy ; Write to the VectorAddressDaisy to

    STR R1, [R1] ; clear the respective Interrupt

    Good thought though!