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: Tim Lambrix
Subject: RE: [lwip-users] tcp_write() errors on snd_queuelen
Date: Wed, 16 Mar 2011 17:28:27 +0000

The lwIPTimer() function is called from the system tick interrupt timer.  This 
only increments the global variable g_ulLocalTimer.

It appears that the rest of the lwIP processing is all done in the Ethernet 
interrupt.  The interrupt function looks like the following:

  lwIPEthernetIntHandler(void)
  {
      // Read and Clear the interrupt.
      ulStatus = EthernetIntStatus(ETH_BASE, false);
      EthernetIntClear(ETH_BASE, ulStatus);
  
      // The handling of the interrupt is different based on the use of a RTOS.
  
      // No RTOS is being used.  If a transmit/receive interrupt was active,
      // run the low-level interrupt handler.
      if(ulStatus)
      {
          stellarisif_interrupt(&g_sNetIF);
      }
  
      // Service the lwIP timers.
      lwIPServiceTimers();
  }

It looks like all the work of the lwip processing, transmitting, and receiving 
occurs in the function stellarisif_interrupt() which I included below:

  stellarisif_interrupt(struct netif *netif)
  {
    struct stellarisif *stellarisif;
    struct pbuf *p;
  
    /* setup pointer to the if state data */
    stellarisif = netif->state;
  
    /**
     * Process the transmit and receive queues as long as there is receive
     * data available
     *
     */
    p = stellarisif_receive(netif);
    
    while(p != NULL) {
      /* process the packet */

      if(ethernet_input(p, netif)!=ERR_OK) {

        /* drop the packet */
        LWIP_DEBUGF(NETIF_DEBUG, ("stellarisif_input: input error\n"));
        pbuf_free(p);
  
        /* Adjust the link statistics */
        LINK_STATS_INC(link.memerr);
        LINK_STATS_INC(link.drop);
      }
  
      /* Check if TX fifo is empty and packet available */
      if((HWREG(ETH_BASE + MAC_O_TR) & MAC_TR_NEWTX) == 0) {
        p = dequeue_packet(&stellarisif->txq);
        if(p != NULL) {
          stellarisif_transmit(netif, p);
        }
      }
  
      /* Read another packet from the RX fifo */
      p = stellarisif_receive(netif);
    }
  
    /* One more check of the transmit queue/fifo */
    if((HWREG(ETH_BASE + MAC_O_TR) & MAC_TR_NEWTX) == 0) {
      p = dequeue_packet(&stellarisif->txq);
      if(p != NULL) {
        stellarisif_transmit(netif, p);
      }
    }
  }

-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Simon Goldschmidt
Sent: Wednesday, March 16, 2011 12:16 PM
To: Mailing list for lwIP users
Subject: RE: [lwip-users] tcp_write() errors on snd_queuelen

If you try to protect tcp_write() against the ETH interrupt by disabling 
interrupts, that would mean you would have to *always* disable the ETH 
interrupt while calling into lwIP. That's pretty unperformant, I think.

As I already said before, the lwIP way is to prevent the driver calling into 
lwIP from interrupt context.

_______________________________________________
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]