dynamic polling

This commit is contained in:
Carl-Benedikt Krger 2011-06-30 11:12:43 +02:00
parent 4674a140a0
commit d9de73381c

View file

@ -107,7 +107,6 @@ unsigned int mpb_size = NULL;
/* Start address of the local register bank */
static int local_crb = 0xF8000000;
static int crb = 0xE0000000;
/* just set and reset the irq */
static int pulse_irq = 0;
@ -204,9 +203,8 @@ typedef struct mmnif
uint8_t tx_queue;
uint8_t* tx_buff[MMNIF_TX_QUEUELEN];
mm_rx_buffer_t* rx_buff;
/* config register banks */
void* crb[MMNIF_CORES];
sem_t com_poll;
/* comunication mailbox
*/
@ -879,17 +877,17 @@ err_t mmnif_init(struct netif* netif)
*/
sem_init(&mmnif->rx_buff->lock,1);
/* init the sems for communication art
*/
sem_init(&mmnif->com_poll,1);
sem_wait(&mmnif->com_poll);
/* inform via interrupt should be the dafault
*/
if (!no_irq)
mmnif->rx_buff->iv_intr = TRUE;
for (i = 0; i < MMNIF_CORES;i+=2)
{
mmnif->crb[i] = crb + RCK_TILE_SIZE*(i/2);
mmnif->crb[i+1] = crb + RCK_TILE_SIZE*(i/2);
}
/* Alloc and clear internal memory for tx_buff
*/
#ifdef WIN32
@ -1085,14 +1083,29 @@ static int mmnif_wait(struct netif* netif, uint32_t poll, int budget)
else
{
quota = budget;
mmnif->stats.bdg_overflow++;
/* if (budget overflow too often)
* {
* enable polling and disable interrupts
* }
*/
}
mmnif->stats.bdg_overflow++;
if (mmnif->stats.bdg_overflow >= 0x10)
{
/* enable polling and disable interrupts
*
*/
mmnif_lock_rx_hdr(own_ip_address && 0xff);
mmnif->rx_buff->iv_intr = FALSE;
mmnif_unlock_rx_hdr(own_ip_address && 0xff);
DEBUGPRINTF("\nPOLLING ENABLED\n");
sem_post(&mmnif->com_poll);
mmnif->stats.bdg_overflow = 0;
}
/* process up to quota packets from the receive queue */
while (npackets <= quota)
{
@ -1164,6 +1177,12 @@ int mmnif_poll(void* e)
DEBUGPRINTF("Polling for work to do!!!! ONBBBB 0x%.8X BBBB\n\n",mmnif->rx_buff);
#endif
/* if (!no_irq)
{
sem_wait(&mmnif->com_poll);
sem_wait(&mmnif->com_poll);
}
*/
/*run while driver is up*/
while (active)
{
@ -1172,11 +1191,23 @@ int mmnif_poll(void* e)
tmp32 = mmnif_timestamp();
diff = diff - tmp32 > 0 ? diff - tmp32 : tmp32 - diff;
mmnif->stats.pll_empty++;
/* if (too many emtpy runs)
* {
* enable interrupts and suspend polling
* }
if (mmnif->stats.pll_empty >= 0x100000)
{
/* enable interrupts and suspend polling
*
*/
// sem_wait(&mmnif->com_poll);
mmnif_lock_rx_hdr(own_ip_address && 0xff);
mmnif->rx_buff->iv_intr = TRUE;
mmnif_unlock_rx_hdr(own_ip_address && 0xff);
DEBUGPRINTF("\nINTERRUPTS ENABLED\n");
sem_wait(&mmnif->com_poll);
mmnif->stats.pll_empty = 1;
}
}
mmnif->stats.pll_empty--;
// udelay(30000);
@ -1264,7 +1295,7 @@ int mmnif_open()
/* If interrupts are not used we immediately add the polling function
* to the queue which would otherwise be done through the IRQ handler.
*/
if (no_irq)
// if (no_irq)
mmnif_device_schedule();
/* Start the device worker thread wich actually processes the incoming