Hi :
I found it maybe enthernet driver problem. Cortex m3 use DMA channel to receive
and send data. And also, it link
Receive and send buffer as chain to speed up. The default ETH_TXBUFNB value is
5, when I change it to 1. The lwip
Performance is stable,but not fast as same as ETH_TXBUFNB == 5.
In enthernet interrupt handler, it will check input frame and give semaphore
and force task witch, then, ethernetif_input take the semaphore
To handle the receive packet.
Why lWIP performance goes down when ETH_TXBUFNB is 5 ?
static void low_level_init(struct netif *netif)
{
uint32_t i;
uint8_t mac_buffer[8];
/* set netif MAC hardware address length */
netif->hwaddr_len = ETHARP_HWADDR_LEN;
/* set netif MAC hardware address */
pdu_mac_init(mac_buffer);
netif->hwaddr[0] = mac_buffer[0];
netif->hwaddr[1] = mac_buffer[1];
netif->hwaddr[2] = mac_buffer[2];
netif->hwaddr[3] = mac_buffer[3];
netif->hwaddr[4] = mac_buffer[4];
netif->hwaddr[5] = mac_buffer[5];
/* set netif maximum transfer unit */
netif->mtu = 1500;
/* Accept broadcast address and ARP traffic */
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
s_pxNetIf =netif;
/* create binary semaphore used for informing ethernetif of frame reception */
if (s_xSemaphore == NULL)
{
s_xSemaphore= xSemaphoreCreateCounting(32,0);
}
/* initialize MAC address in ethernet MAC */
ETH_MACAddressConfig(ETH_MAC_Address0, netif->hwaddr);
/* Initialize Tx Descriptors list: Chain Mode */
ETH_DMATxDescChainInit(DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB);
/* Initialize Rx Descriptors list: Chain Mode */
ETH_DMARxDescChainInit(DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);
/* Enable Ethernet Rx interrrupt */
{
for(i=0; i<ETH_RXBUFNB; i++)
{
ETH_DMARxDescReceiveITConfig(&DMARxDscrTab[i], ENABLE);
}
}
#ifdef CHECKSUM_GEN_ICMP
/* Enable the checksum insertion for the Tx frames */
{
for(i=0; i<ETH_TXBUFNB; i++)
{
ETH_DMATxDescChecksumInsertionConfig(&DMATxDscrTab[i],
ETH_DMATxDesc_ChecksumTCPUDPICMPFull);
}
}
#endif
/* create the task that handles the ETH_MAC */
xTaskCreate(ethernetif_input, (signed char*) "Eth_if",
netifINTERFACE_TASK_STACK_SIZE, NULL,
netifINTERFACE_TASK_PRIORITY,NULL);
/* Enable MAC and DMA transmission and reception */
ETH_Start();
}
void ETH_IRQHandler(void)
{
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
/* Frame received */
if ( ETH_GetDMAFlagStatus(ETH_DMA_FLAG_R) == SET)
{
/* Give the semaphore to wakeup LwIP task */
xSemaphoreGiveFromISR( s_xSemaphore, &xHigherPriorityTaskWoken );
}
/* Clear the interrupt flags. */
/* Clear the Eth DMA Rx IT pending bits */
ETH_DMAClearITPendingBit(ETH_DMA_IT_R);
ETH_DMAClearITPendingBit(ETH_DMA_IT_NIS);
/* Switch tasks if necessary. */
if( xHigherPriorityTaskWoken != pdFALSE )
{
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
}
}
void ethernetif_input( void * pvParameters )
{
struct pbuf *p;
for( ;; )
{
if (xSemaphoreTake( s_xSemaphore, emacBLOCK_TIME_WAITING_FOR_INPUT)==pdTRUE)
{
p = low_level_input( s_pxNetIf );
if (ERR_OK != s_pxNetIf->input( p, s_pxNetIf))
{
pbuf_free(p);
p=NULL;
}
}
}
}
From: [email protected]
[mailto:[email protected]] On Behalf Of
vincent cui
Sent: 2012年5月11日 8:20
To: Mailing list for lwIP users
Subject: Re: [lwip-users] lwip performance goes down if running with FreeRTOS
Hi :
When lwIP performance goes to down, I capture the TCP packet as attached files.
I also extend PBUF_POOL_BUFSIZE to enough size. It seems no use.
Anyone can give any help ?
Vincent
From: [email protected]
[mailto:[email protected]] On Behalf Of
vincent cui
Sent: 2012年5月10日 21:01
To: Mailing list for lwIP users
Subject: [lwip-users] lwip performance goes down if running with FreeRTOS
Hi:
I found a odd strange in Cortex M3, running LWIP1.4.0 + FreeRTOS.
I write a TCP server to accept large file, the code works well if running in
LWIP standalone. The performance is high and stable.
But when I create the task in FreeRTOS, the whole LWIP performance goes to down
after the task accept file for a while
It seems that switch task in FreeRTOS cause it down, but I don’t know how to
bypass. I even try to “define LWIP_TCP_CORE_LOCKING’
To disable TCP task switch, but still got same result .
Anyone can give help ?
vincent
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users