|
From: | Baptiste Chaboud-crousaz |
Subject: | [lwip-users] Pbuf starvation |
Date: | Fri, 19 Jun 2009 08:38:06 +0200 |
User-agent: | Internet Messaging Program (IMP) H3 (4.1.6) |
Hi all,
I use the lwIP stack without OS on a STM32F107 processor (ST micro). The processor Ethernet module is configured to assert an interrupt when a complete Ethernet Frame is received. Upon interrupt I call "ethernetif_input(struct netif *netif)" which the code is given below:
void
ethernetif_input(struct netif *netif)
{
struct ethernetif
*ethernetif;
struct eth_hdr *ethhdr;
struct pbuf *p = NULL;
ethernetif = netif->state;
/* move received packet
into a new pbuf */
while((p = low_level_input(netif)) != NULL)
{
/* points to packet payload, which starts with an Ethernet header
*/
ethhdr = p->payload;
switch
(htons(ethhdr->type))
{
case ETHTYPE_ARP: /* ARP
packet */
etharp_arp_input(netif, ethernetif->ethaddr,
p);
break;
case ETHTYPE_IP: /* IP packet
*/
/* Update the ARP table */
etharp_ip_input(netif, p);
/* Skip the Ethernet header
*/
pbuf_header(p, -((s16_t)sizeof(struct eth_hdr)));
/* Pass the packet to the network layer.*/
netif->input(p, netif);
break;
default:
pbuf_free(p);
p = NULL;
break;
}
}
}
The function "struct pbuf * low_level_input(struct netif *netif)" is called until no more data is available. This function allocates a pbuf buffer to store the received data: pbuf_alloc(PBUF_RAW, len, PBUF_POOL);.
Between each call to the "struct pbuf * low_level_input(struct netif *netif)", the received data are processed according to their type: ARP or IP packet (for IP packet netif->input is "err_t ip_input(struct pbuf *p, struct netif *inp)").
As I can see once the packet is processed (except if it is a reassembled packet), the allocated pbuf ,in which the data are stored , is freed by a call to pbuf_free.
Nevertheless after a short period without error, the pbuf allocation failed because no more free space is available for a new allocation. I don't understand why!!! Is someone can help me to understand why the previously allocated pbuf are not correctly freed?
I must underline the fact that this problem doesn't occur when the network traffic is very low loaded. But when the network has to support a heavy loaded traffic, the problem appears rapidely.
Thanks for your help.
Best regards.
Baptiste
[Prev in Thread] | Current Thread | [Next in Thread] |