VOID unregister_client ( INT32 cli_id ) { p_atheros_dev dev; printk("DK::Unregsitering client %d \n",cli_id); dev = &dev_table[cli_id]; if (!VALID_CLIENT(dev)) { printk("DK::unregister_client:Invalid client \n"); return; } if (!BUSY_CLIENT(dev)) { printk("DK::unregister_client:Client not registered \n"); return; } reset_device(dev->cli_id); deleteEventQueue(&dev->isr_event_q); deleteEventQueue(&dev->trigered_event_q); #if defined(OWL_PB42) || defined(PYTHON_EMU) bus_dev_exit(dev->bus_dev); #endif dev->dev_busy = 0; return; }
/* * This is a pretty expensive routine -- it loops through all the fd's, * and finds the active clients (and servers and opers) and places them * on the "busy client" list */ void check_fdlists() { #ifdef CLIENT_SERVER #define BUSY_CLIENT(x) (((x)->priority < 55) || (!lifesux && ((x)->priority < 75))) #else #define BUSY_CLIENT(x) (((x)->priority < 40) || (!lifesux && ((x)->priority < 60))) #endif #define FDLISTCHKFREQ 2 aClient *cptr; int i, j; j = 0; for (i = highest_fd; i >= 0; i--) { if (!(cptr = local[i])) continue; if (IsServer(cptr) || IsListening(cptr) || IsOper(cptr)) { busycli_fdlist.entry[++j] = i; continue; } if (cptr->receiveM == cptr->lastrecvM) { cptr->priority += 2; /* lower a bit */ if (cptr->priority > 90) cptr->priority = 90; else if (BUSY_CLIENT(cptr)) busycli_fdlist.entry[++j] = i; continue; } else { cptr->lastrecvM = cptr->receiveM; cptr->priority -= 30; /* active client */ if (cptr->priority < 0) { cptr->priority = 0; busycli_fdlist.entry[++j] = i; } else if (BUSY_CLIENT(cptr)) busycli_fdlist.entry[++j] = i; } } busycli_fdlist.last_entry = j; /* rest of the fdlist is garbage */ /* return (now + FDLISTCHKFREQ + (lifesux + 1)); */ }
/* * This is a pretty expensive routine -- it loops through * all the fd's, and finds the active clients (and servers * and opers) and places them on the "busy client" list */ void fdlist_check(time_t now) { struct Client* cptr; int i; for (i = highest_fd; i >= 0; --i) { if (!(cptr = local[i])) continue; if (IsServer(cptr) || IsAnOper(cptr)) continue; GlobalFDList[i] &= ~FDL_BUSY; if (cptr->receiveM == cptr->lastrecvM) { cptr->priority += 2; /* lower a bit */ if (90 < cptr->priority) cptr->priority = 90; else if (BUSY_CLIENT(cptr)) { GlobalFDList[i] |= FDL_BUSY; } continue; } else { cptr->lastrecvM = cptr->receiveM; cptr->priority -= 30; /* active client */ if (cptr->priority < 0) { cptr->priority = 0; GlobalFDList[i] |= FDL_BUSY; } else if (BUSY_CLIENT(cptr)) { GlobalFDList[i] |= FDL_BUSY; } } } }
INT32 register_client ( INT32 major, INT32 minor ) { INT32 cli_id; p_atheros_dev dev; #if defined(OWL_PB42) || defined(PYTHON_EMU) UINT32 vendor_id; #endif /* get the client for this device */ cli_id = get_client_id(major, minor); if (cli_id == INVALID_CLIENT) { printk("DK::register_client:Device not found \n"); return -ENODEV; } printk("DK::Regsitering client %d \n",cli_id); dev = &dev_table[cli_id]; if (!VALID_CLIENT(dev)) { printk("DK::register_client:Invalid client \n"); return -ENODEV; } if (BUSY_CLIENT(dev)) { printk("DK::register_client:Client alreay in use \n"); return -EACCES; } #if !defined (P1020) // check whether the device is present // by reading the vendor id #if defined(OWL_PB42) || defined(PYTHON_EMU) #ifdef WASP_OSPREY if(cli_id!=0){ // For DBDC operation, Wasp radio's client ID is zero; #endif cli_cfg_read(cli_id,0,4,&vendor_id); if ((vendor_id & 0xffff) != ATHEROS_VENDOR_ID) { printk("DK::Device not present \n"); return -ENODEV; } #ifdef WASP_OSPREY } #endif #ifndef PYTHON_EMU if (bus_dev_init(dev->bus_dev) < 0) { printk("DK::register_client:Cannot initialize client \n"); return -EACCES; } #endif #endif #endif initEventQueue(&dev->isr_event_q); initEventQueue(&dev->trigered_event_q); reset_device(cli_id); dev->dev_busy = 1; return dev->cli_id; }