From 10bb0f7661d181e5f69ecb75bc810984aa35488d Mon Sep 17 00:00:00 2001 From: Anirudha Sarangi Date: Mon, 9 Feb 2015 17:11:43 +0530 Subject: [PATCH] lwip: Fix issue on Rx path in hadling packets with Xilkernel This patch fixes rx packet handling issue with Xilkernel. The issue was processing a single packet from the input queue everytime the semaphore is released in the ISR. Now, we iterate till the queue is completely emptied. After the ISR releases the semaphore and before the queue is read, there could be new packets in the queue and hence can lead to situations where there could be considerable delay in processing a particular packet. This patch also ensures that the ISR releases the semaphore once for an entry into Rx ISR instead of each received packet. This enhances performance. Signed-off-by: Anirudha Sarangi --- .../contrib/ports/xilinx/netif/xaxiemacif.c | 60 ++++++++++--------- .../ports/xilinx/netif/xaxiemacif_dma.c | 7 +-- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/ThirdParty/sw_services/lwip141/src/contrib/ports/xilinx/netif/xaxiemacif.c b/ThirdParty/sw_services/lwip141/src/contrib/ports/xilinx/netif/xaxiemacif.c index 2583ff58..272cb90a 100755 --- a/ThirdParty/sw_services/lwip141/src/contrib/ports/xilinx/netif/xaxiemacif.c +++ b/ThirdParty/sw_services/lwip141/src/contrib/ports/xilinx/netif/xaxiemacif.c @@ -242,45 +242,49 @@ int xaxiemacif_input(struct netif *netif) struct pbuf *p; SYS_ARCH_DECL_PROTECT(lev); - /* move received packet into a new pbuf */ - SYS_ARCH_PROTECT(lev); - p = low_level_input(netif); - SYS_ARCH_UNPROTECT(lev); +#if !NO_SYS + while (1) +#endif + { + /* move received packet into a new pbuf */ + SYS_ARCH_PROTECT(lev); + p = low_level_input(netif); + SYS_ARCH_UNPROTECT(lev); - /* no packet could be read, silently ignore this */ - if (p == NULL) - return 0; + /* no packet could be read, silently ignore this */ + if (p == NULL) + return 0; - /* points to packet payload, which starts with an Ethernet header */ - ethhdr = p->payload; + /* points to packet payload, which starts with an Ethernet header */ + ethhdr = p->payload; #if LINK_STATS - lwip_stats.link.recv++; + lwip_stats.link.recv++; #endif /* LINK_STATS */ - switch (htons(ethhdr->type)) { - /* IP or ARP packet? */ - case ETHTYPE_IP: - case ETHTYPE_ARP: + switch (htons(ethhdr->type)) { + /* IP or ARP packet? */ + case ETHTYPE_IP: + case ETHTYPE_ARP: #if PPPOE_SUPPORT - /* PPPoE packet? */ - case ETHTYPE_PPPOEDISC: - case ETHTYPE_PPPOE: + /* PPPoE packet? */ + case ETHTYPE_PPPOEDISC: + case ETHTYPE_PPPOE: #endif /* PPPOE_SUPPORT */ - /* full packet send to tcpip_thread to process */ - if (netif->input(p, netif) != ERR_OK) { - LWIP_DEBUGF(NETIF_DEBUG, ("xaxiemacif_input: IP input error\r\n")); + /* full packet send to tcpip_thread to process */ + if (netif->input(p, netif) != ERR_OK) { + LWIP_DEBUGF(NETIF_DEBUG, ("xaxiemacif_input: IP input error\r\n")); + pbuf_free(p); + p = NULL; + } + break; + + default: pbuf_free(p); p = NULL; - } - break; - - default: - pbuf_free(p); - p = NULL; - break; + break; + } } - return 1; } diff --git a/ThirdParty/sw_services/lwip141/src/contrib/ports/xilinx/netif/xaxiemacif_dma.c b/ThirdParty/sw_services/lwip141/src/contrib/ports/xilinx/netif/xaxiemacif_dma.c index d4be1ba9..e3097c6e 100755 --- a/ThirdParty/sw_services/lwip141/src/contrib/ports/xilinx/netif/xaxiemacif_dma.c +++ b/ThirdParty/sw_services/lwip141/src/contrib/ports/xilinx/netif/xaxiemacif_dma.c @@ -418,10 +418,6 @@ static void axidma_recv_handler(void *arg) lwip_stats.link.drop++; #endif pbuf_free(p); - } else { -#if !NO_SYS - sys_sem_signal(&xemac->sem_rx_data_available); -#endif } rxbd = XAxiDma_BdRingNext(rxring, rxbd); } @@ -430,6 +426,9 @@ static void axidma_recv_handler(void *arg) /* return all the processed bd's back to the stack */ /* setup_rx_bds -> use XAxiDma_BdRingGetFreeCnt */ setup_rx_bds(rxring); +#if !NO_SYS + sys_sem_signal(&xemac->sem_rx_data_available); +#endif } XAxiDma_BdRingIntEnable(rxring, XAXIDMA_IRQ_ALL_MASK); }