lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] tcp_write() errors on snd_queuelen


From: Andrew Foster
Subject: Re: [lwip-users] tcp_write() errors on snd_queuelen
Date: Wed, 16 Mar 2011 12:05:15 -0400
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Thunderbird/3.1.7

Tim,

For the sake of our discussion I'm going to assume MAP_IntMasterDisable() does what it as advertised to do.

Moving forward, how does your project use lwIP?

More specifically:
Are you running an RTOS? If so which?

How does your application call tcp_write? I.e. from a thread or other context?

Can you include your lwipopts.h in this post?

Andrew

On 03/16/2011 11:56 AM, Tim Lambrix wrote:
Andrew,
Thanks for your help too. I will take all I can get right now.  It looks like 
SYS_ARCH_PROTECT is defined as follows and it does hit this line of code (only 
from the interrupt itself however):
        sys_prot_t
        sys_arch_protect(void)
        {
                return((sys_prot_t)MAP_IntMasterDisable());
        }
I think this is correct?  However, the stellarisif_transmit function you 
mention is called in three places and only one of them has the SYS_ARCH_PROTECT 
called before it.  I don't see the calls in the interrupt itself 
stellarisif_interrupt.

Maybe I am missing something here but the problem I seem to have is the Ethernet 
interrupt goes off while I am in the tcp_write->tcp_enqueue function and changes 
the values of pcb->snd_queuelen. I have modified the local variable in that 
function queuelen to not use the value read at line 195 from:

        queuelen = pcb->snd_queuelen;    to
        queuelen = 0;

and line 411 from:

        pcb->snd_queuelen = queuelen;    to
        pcb->snd_queuelen += queuelen;

This fixes the issue but I welcome your insight on why it should not happen in the 
first place.  I don't see any calls close to SYS_ARCH_PROTECT in the tcp_write 
function to prevent the interrupt from going off.  I also tried disabling the 
Ethernet ISR for both ETH_INT_RX and ETH_INT_TX (the only two enabled) before 
calling tcp_write and enabling both after the call.  That also works to prevent 
the corruption of pcb->  snd_queuelen.


 From what I have traced in code, the protection prevents the interrupt from 
going off again while in the interrupt.  I have been trying to find where lwIP 
gets processed outside of the interrupts if the interrupt is not suppose to 
mess with the pbufs.  It looks to me like they can.

My original post of findings is here:
http://lists.nongnu.org/archive/html/lwip-users/2011-03/msg00069.html

Tim



-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Andrew Foster
Sent: Wednesday, March 16, 2011 11:17 AM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] tcp_write() errors on snd_queuelen

Tim,

Sorry for jumping in on this late in the thread. I've used the TI
Port(1.3.2) a couple of times on different projects. Typically, I've
used it in conjunction with FreeRTOS. One thing to be mindful of is
making sure you have SYS_ARCH_PROTECT defined correctly.

stellarisif_output and stellarisif_transmit must be ran in critical
sections with both the PBUF structure and the ETH TX FIFO protected.
Otherwise, the stellarisif_interrupt can come in and modify the PBUF chain.

Again, I apologize if I'm stating the obvious here or things you've
already ruled out. I wasn't able to find the original post.

Andrew
_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users

_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users



reply via email to

[Prev in Thread] Current Thread [Next in Thread]