major changes

This commit is contained in:
Carl-Benedikt Krüger 2011-08-04 15:55:12 +02:00
parent da213b14af
commit e37c0c4ca7
2 changed files with 75 additions and 4 deletions

View file

@ -263,6 +263,22 @@ __inline int RCCE_ue(void){
#define __MEMCPY(x,y,z) memcpy(x,y,z)
#endif
/* mmnif_device_schedule() :
* if there is no interupt used to indicate new packets
* this creates a polling thread which looks for data
* itself
*/
__inline int mmnif_device_schedule()
{
#ifdef WIN32
bthread_create(&polling_thread,NULL,mmnif_poll,NULL);
return NULL;
#else
create_kernel_task(&polling_thread,mmnif_poll,NULL);
return NULL;
#endif
}
/* trigger an interrupt on the remote processor
* so he knows there is a packet to read
*/
@ -942,8 +958,9 @@ drop_packet:
#endif
return;
}
/* mmnif_irqhandler():
* handles the incomint interrupts
*/
void mmnif_irqhandler()
{
mmnif_t* mmnif;
@ -965,7 +982,61 @@ void mmnif_irqhandler()
// mmnif_wait(mmnif_dev,1,MMNIF_WORKER_BUDGET);
}
}
/*
* the poll function wich is used if no interrupt wake up our mmnif_rx functions
*/
int mmnif_poll(void* e)
{
mmnif_t* mmnif;
unsigned int diff = mmnif_timestamp();
if (!mmnif_dev)
{
DEBUGPRINTF("mmnif_poll(): the driver is not initialized yet\n");
return -1;
}
mmnif = (mmnif_t*) mmnif_dev->state;
#ifdef DEBUG_MMNIF
DEBUGPRINTF("mmnif_poll(): polling thread launched",mmnif->rx_buff);
#endif
if (!no_irq)
{
sem_wait(&mmnif->com_poll);
}
/*run while driver is up*/
while (active)
{
while (!mmnif->rx_buff->dcount == MMNIF_MAX_DESCRIPTORS)
{
mmnif->stats.pll_empty++;
if (mmnif->stats.pll_empty >= MMNIF_POLL_BUDGET)
{
/* enable interrupts and suspend polling
*
*/
mmnif->rx_buff->iv_intr = TRUE;
mmnif->stats.pll_empty = 0;
#ifdef DEBUG_MMNIF
DEBUGPRINTF("mmnif_poll(): heuristical interrupts enabled\n");
#endif
sem_wait(&mmnif->com_poll);
}
/* uncomment this to test only polling
*/
// mmnif->stats.pll_empty = 0;
}
mmnif->stats.pll_empty=0;
mmnif_rx(mmnif_dev);
}
return NULL;
}
/*
* Open the interface should be called by kernel to use this network interface
*/
@ -1021,7 +1092,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.
*/
// mmnif_device_schedule();
mmnif_device_schedule();
/* Start the device worker thread wich actually processes the incoming
* packet's this is not done in the "interrupt handler" to shorten them up

View file

@ -158,7 +158,7 @@ void srv_on_conn(ServerEventArgs* e)
{
int i = 0, err = 0;
int tmp1,tmp2;
char buff[1024];
char buff[2047];
SHELLDEBUGPRINTF("someone finally connected\n");