From 1fabe449dd69df3642cd898c7f5cb96d54d629bd Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Tue, 20 Sep 2011 13:05:49 -0700 Subject: [PATCH] minor performance improvements => reducing the number of interrupts --- drivers/net/rckemac.c | 18 ++++++++++++++---- drivers/net/rckemac.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/rckemac.c b/drivers/net/rckemac.c index 6cb01ed3..07b538ad 100644 --- a/drivers/net/rckemac.c +++ b/drivers/net/rckemac.c @@ -349,7 +349,7 @@ static void rckemacif_input(struct netif* netif, struct pbuf* p) #endif /* PPPOE_SUPPORT */ /* * This function is called in the context of the tcpip thread. - * Therefore, we are able to call directly the input functions + * Therefore, we are able to call directly the input functions. */ err = ethernet_input(p, netif); if (err != ERR_OK) { @@ -501,6 +501,11 @@ rxDone: if (read_offset != write_offset) goto again; + + /* Enable eMAC interrupt */ + int tmp = *((volatile int*) (FPGA_BASE + IRQ_MASK + rckemacif->core * 2 * 4)); + *((volatile int*) (FPGA_BASE + IRQ_MASK + rckemacif->core * 2 * 4)) = tmp & ~(1 << rckemacif->num_emac); + rckemacif->polling = 0; } /* this function is called in the context of the tcpip thread */ @@ -528,8 +533,13 @@ static void rckemacif_handler(struct state* s) /* check for updated write offset */ write_offset = *((volatile unsigned int*) (rckemacif->rx_buffer)) & 0xFFFF; //write_offset = read_emac(rckemacif->num_emac, EMAC_RX_CONTROL + EMAC_RX_BUFFER_WRITE_OFFSET, rckemacif->core); - if ((write_offset != 0) && (rckemacif->rx_read_offset != write_offset)) { - if (tcpip_callback_with_block(rckemacif_poll, (void*) write_offset, 0) != ERR_OK) { + if ((write_offset != 0) && (rckemacif->rx_read_offset != write_offset) && !rckemacif->polling) { + if (tcpip_callback_with_block(rckemacif_poll, (void*) write_offset, 0) == ERR_OK) { + /* Maks eMAC interrupt */ + int tmp = *((volatile int*) (FPGA_BASE + IRQ_MASK + rckemacif->core * 2 * 4)); + *((volatile int*) (FPGA_BASE + IRQ_MASK + rckemacif->core * 2 * 4)) = tmp | (1 << rckemacif->num_emac); + rckemacif->polling = 1; + } else { LWIP_DEBUGF(NETIF_DEBUG, ("rckemacif_handler: unable to send a poll request to the tcpip thread\n")); } } @@ -572,7 +582,7 @@ err_t rckemacif_init(struct netif* netif) LWIP_DEBUGF(NETIF_DEBUG, ("rckemacif_init: out of memory\n")); return ERR_MEM; } - memset(rckemacif, 0, sizeof(rckemacif_t)); + memset(rckemacif, 0x00, sizeof(rckemacif_t)); rckemacif->core = core; /* allocate the receive buffer */ diff --git a/drivers/net/rckemac.h b/drivers/net/rckemac.h index 2796f14d..f6710594 100644 --- a/drivers/net/rckemac.h +++ b/drivers/net/rckemac.h @@ -39,6 +39,7 @@ typedef struct rckemacif { void* irq_address; uint32_t core; uint32_t num_emac; + volatile uint8_t polling; } rckemacif_t; /*