struct net_device *r8712_init_netdev(void) { struct _adapter *padapter; struct net_device *pnetdev; pnetdev = alloc_etherdev(sizeof(struct _adapter)); if (!pnetdev) return NULL; if (dev_alloc_name(pnetdev, ifname) < 0) { strcpy(ifname, "wlan%d"); dev_alloc_name(pnetdev, ifname); } padapter = (struct _adapter *) netdev_priv(pnetdev); padapter->pnetdev = pnetdev; printk(KERN_INFO "r8712u: register rtl8712_netdev_ops to" " netdev_ops\n"); pnetdev->netdev_ops = &rtl8712_netdev_ops; pnetdev->watchdog_timeo = HZ; /* 1 second timeout */ pnetdev->wireless_handlers = (struct iw_handler_def *) &r871x_handlers_def; /*step 2.*/ loadparam(padapter, pnetdev); netif_carrier_off(pnetdev); padapter->pid = 0; /* Initial the PID value used for HW PBC.*/ return pnetdev; }
struct net_device *rtw_init_netdev(struct adapter *old_padapter) { struct adapter *padapter; struct net_device *pnetdev = NULL; RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+init_net_dev\n")); if (old_padapter != NULL) pnetdev = rtw_alloc_etherdev_with_old_priv(sizeof(struct adapter), (void *)old_padapter); if (!pnetdev) return NULL; pnetdev->dev.type = &wlan_type; padapter = rtw_netdev_priv(pnetdev); padapter->pnetdev = pnetdev; DBG_88E("register rtw_netdev_ops to netdev_ops\n"); pnetdev->netdev_ops = &rtw_netdev_ops; pnetdev->watchdog_timeo = HZ*3; /* 3 second timeout */ pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def; /* step 2. */ loadparam(padapter, pnetdev); return pnetdev; }
struct net_device *rtw_init_netdev(void) { _adapter *padapter; struct net_device *pnetdev; RT_TRACE(_module_os_intfs_c_,_drv_info_,("+init_net_dev\n")); //pnetdev = alloc_netdev(sizeof(_adapter), "wlan%d", ether_setup); pnetdev = alloc_etherdev(sizeof(_adapter)); if (!pnetdev) return NULL; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) SET_MODULE_OWNER(pnetdev); #endif padapter = netdev_priv(pnetdev); _rtw_memset(padapter, 0,sizeof(_adapter)); padapter->pnetdev = pnetdev; //pnetdev->init = NULL; #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,29)) printk("register rtl8192_netdev_ops to netdev_ops\n"); pnetdev->netdev_ops = &rtw_netdev_ops; #else pnetdev->open = netdev_open; pnetdev->stop = netdev_close; pnetdev->hard_start_xmit = rtw_xmit_entry; pnetdev->set_mac_address = rtw_net_set_mac_address; pnetdev->get_stats = rtw_net_get_stats; pnetdev->do_ioctl = rtw_ioctl; #endif #ifdef CONFIG_RTL8712_TCP_CSUM_OFFLOAD_TX pnetdev->features |= NETIF_F_IP_CSUM; #endif //pnetdev->tx_timeout = NULL; pnetdev->watchdog_timeo = HZ; /* 1 second timeout */ pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def; #ifdef WIRELESS_SPY //priv->wireless_data.spy_data = &priv->spy_data; //pnetdev->wireless_data = &priv->wireless_data; #endif //step 2. loadparam(padapter, pnetdev); return pnetdev; }
struct net_device *rtw_init_netdev23a(struct rtw_adapter *old_padapter) { struct rtw_adapter *padapter; struct net_device *pnetdev; RT_TRACE(_module_os_intfs_c_, _drv_info_, "+init_net_dev\n"); pnetdev = alloc_etherdev_mq(sizeof(struct rtw_adapter), 4); if (!pnetdev) return NULL; pnetdev->dev.type = &wlan_type; padapter = netdev_priv(pnetdev); padapter->pnetdev = pnetdev; DBG_8723A("register rtw_netdev_ops to netdev_ops\n"); pnetdev->netdev_ops = &rtw_netdev_ops; pnetdev->watchdog_timeo = HZ*3; /* 3 second timeout */ loadparam(padapter, pnetdev); return pnetdev; }
static int r871xs_drv_init(struct sdio_func *func, const struct sdio_device_id *id) { _adapter *padapter = NULL; struct dvobj_priv *pdvobjpriv; struct net_device *pnetdev; RT_TRACE(_module_hci_intfs_c_,_drv_alert_,("+871x - drv_init:id=0x%p func->vendor=0x%x func->device=0x%x\n",id,func->vendor,func->device)); //step 1. pnetdev = rtw_init_netdev(); if (!pnetdev) goto error; padapter = netdev_priv(pnetdev); pdvobjpriv = &padapter->dvobjpriv; pdvobjpriv->padapter = padapter; pdvobjpriv->func = func; sdio_set_drvdata(func, pdvobjpriv); SET_NETDEV_DEV(pnetdev, &func->dev); //step 2. if (alloc_io_queue(padapter) == _FAIL) { RT_TRACE(_module_hci_intfs_c_,_drv_err_,("Can't init io_reqs\n")); goto error; } #if 0 //temp remove //step 3. if (loadparam(padapter, pnetdev) == _FAIL) { RT_TRACE(_module_hci_intfs_c_,_drv_err_,("Read Parameter Failed!\n")); goto error; } #endif //step 4. //dvobj_init(padapter); padapter->dvobj_init = &sd_dvobj_init; padapter->dvobj_deinit = &sd_dvobj_deinit; padapter->halpriv.hal_bus_init = &sd_hal_bus_init; padapter->halpriv.hal_bus_deinit = &sd_hal_bus_deinit; if (padapter->dvobj_init == NULL) { RT_TRACE(_module_hci_intfs_c_,_drv_err_,("\n Initialize dvobjpriv.dvobj_init error!!!\n")); goto error; } if (padapter->dvobj_init(padapter) == _FAIL) { RT_TRACE(_module_hci_intfs_c_,_drv_err_,("\n initialize device object priv Failed!\n")); goto error; } //step 6. if (rtw_init_drv_sw(padapter) == _FAIL) { RT_TRACE(_module_hci_intfs_c_,_drv_err_,("Initialize driver software resource Failed!\n")); goto error; } #if 1 { //step 7. u8 mac[6]; mac[0]=0x00; mac[1]=0xe0; mac[2]=0x4c; mac[3]=0x87; mac[4]=0x66; mac[5]=0x55; _rtw_memcpy(pnetdev->dev_addr, mac/*padapter->eeprompriv.mac_addr*/, ETH_ALEN); RT_TRACE(_module_hci_intfs_c_,_drv_info_,("pnetdev->dev_addr=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n",pnetdev->dev_addr[0],pnetdev->dev_addr[1],pnetdev->dev_addr[2],pnetdev->dev_addr[3],pnetdev->dev_addr[4],pnetdev->dev_addr[5])); } #endif //step 8. /* Tell the network stack we exist */ if (register_netdev(pnetdev) != 0) { RT_TRACE(_module_hci_intfs_c_,_drv_err_,("register_netdev() failed\n")); goto error; } RT_TRACE(_module_hci_intfs_c_,_drv_info_,("register_netdev() success\n")); RT_TRACE(_module_hci_intfs_c_,_drv_notice_,("-drv_init - Adapter->bDriverStopped=%d, Adapter->bSurpriseRemoved=%d\n",padapter->bDriverStopped, padapter->bSurpriseRemoved)); RT_TRACE(_module_hci_intfs_c_,_drv_info_,("-871xs_drv - drv_init, success!\n")); return 0; error: if (padapter->dvobj_deinit == NULL) { RT_TRACE(_module_hci_intfs_c_,_drv_err_,("\n Initialize dvobjpriv.dvobj_deinit error!!!\n")); } else { padapter->dvobj_deinit(padapter); } if (pnetdev) { unregister_netdev(pnetdev); free_netdev(pnetdev); } RT_TRACE(_module_hci_intfs_c_, _drv_emerg_, ("-871x_sdio - drv_init, fail!\n")); return -1; }
int main(int argc, char **arg) { clock_t start, endc, endt; double elapsedc, elapsedt; extmanager MyManager; DdNode *bdd; bddfileheader fileheader; int i, ivarcnt, code; gradientpair tvalue; double probability = -1.0; char *varpattern; varpattern = NULL; code = -1; params = loadparam(argc, arg); if (params.errorcnt > 0) { printhelp(argc, arg); for (i = 0; i < params.errorcnt; i++) { fprintf(stderr, "Error: not known or error at parameter %s.\n", arg[params.error[i]]); } return -1; } if (params.online == 0 && params.loadfile == -1) { printhelp(argc, arg); fprintf(stderr, "Error: you must specify a loading file.\n"); return -1; } if (params.method != 0 && arg[params.method][0] != 'g' && arg[params.method][0] != 'p' && arg[params.method][0] != 'o' && arg[params.method][0] != 'l') { printhelp(argc, arg); fprintf(stderr, "Error: you must choose a calculation method beetween " "[p]robability, [g]radient, [l]ine search, [o]nline.\n"); return -1; } if (params.debug) DEBUGON; RAPIDLOADON; SETMAXBUFSIZE(params.maxbufsize); #ifndef _WIN32 signal(SIGINT, termhandler); if (params.ppid != NULL) { signal(SIGALRM, pidhandler); alarm(5); } else { signal(SIGALRM, handler); alarm(params.timeout); } #endif if (params.online) { MyManager.manager = simpleBDDinit(0); MyManager.t = HIGH(MyManager.manager); MyManager.f = LOW(MyManager.manager); MyManager.varmap = InitNamedVars(1, 0); bdd = OnlineGenerateBDD(MyManager.manager, &MyManager.varmap); ivarcnt = GetVarCount(MyManager.manager); } else { fileheader = ReadFileHeader(arg[params.loadfile]); switch (fileheader.filetype) { case BDDFILE_SCRIPT: if (params.inputfile == -1) { printhelp(argc, arg); fprintf(stderr, "Error: an input file is necessary for this type of " "loading file.\n"); return -1; } MyManager.manager = simpleBDDinit(fileheader.varcnt); MyManager.t = HIGH(MyManager.manager); MyManager.f = LOW(MyManager.manager); MyManager.varmap = InitNamedMultiVars( fileheader.varcnt, fileheader.varstart, fileheader.bvarcnt); if (LoadMultiVariableData(MyManager.manager, MyManager.varmap, arg[params.inputfile]) == -1) return -1; start = clock(); bdd = FileGenerateBDD(MyManager.manager, MyManager.varmap, fileheader); endc = clock(); elapsedc = ((double)(endc - start)) / CLOCKS_PER_SEC; printf("elapsed_construction(%lf).\n", elapsedc); ivarcnt = fileheader.varcnt; break; case BDDFILE_NODEDUMP: if (params.inputfile == -1) { printhelp(argc, arg); fprintf(stderr, "Error: an input file is necessary for this type of " "loading file.\n"); return -1; } MyManager.manager = simpleBDDinit(fileheader.varcnt); MyManager.t = HIGH(MyManager.manager); MyManager.f = LOW(MyManager.manager); MyManager.varmap = InitNamedVars(fileheader.varcnt, fileheader.varstart); bdd = LoadNodeDump(MyManager.manager, MyManager.varmap, fileheader.inputfile); ivarcnt = fileheader.varcnt; break; default: fprintf(stderr, "Error: not a valid file format to load.\n"); return -1; break; } } #ifndef _WIN32 alarm(0); #endif // problem specifics if (bdd != NULL) { ivarcnt = RepairVarcnt(&MyManager.varmap); code = 0; /* if (params.inputfile != -1) { if (LoadVariableData(MyManager.varmap, arg[params.inputfile]) == -1) return -1; if (!all_loaded(MyManager.varmap, 1)) return -1; }*/ MyManager.his = InitHistory(ivarcnt); if (params.method != 0) { switch (arg[params.method][0]) { case 'g': for (i = 0; i < MyManager.varmap.varcnt; i++) { if (MyManager.varmap.vars[i] != NULL) { varpattern = extractpattern(MyManager.varmap.vars[i]); if ((varpattern == NULL) || (!patterncalculated(varpattern, MyManager, i))) { tvalue = CalcGradient(MyManager, bdd, i + MyManager.varmap.varstart, varpattern); probability = tvalue.probability; double factor = sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope) * (1 - sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope)) * params.sigmoid_slope; if (varpattern == NULL) { printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], MyManager.varmap.vars[i], tvalue.gradient * factor); } else { varpattern[strlen(varpattern) - 2] = '\0'; printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], varpattern, tvalue.gradient * factor); } ReInitHistory(MyManager.his, MyManager.varmap.varcnt); } if (varpattern != NULL) free(varpattern); } else { fprintf(stderr, "Error: no variable name given for parameter.\n"); } } if (probability < 0.0) { // no nodes, so we have to calculate probability ourself tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); probability = tvalue.probability; } printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); break; case 'l': tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); probability = tvalue.probability; printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); break; case 'p': printf("probability(%1.12f).\n", CalcProbability(MyManager, bdd)); break; case 'o': onlinetraverse(MyManager.manager, MyManager.varmap, MyManager.his, bdd); break; default: myexpand(MyManager, bdd); break; } } else { start = clock(); // simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, //"bdd.dot"); printf("probability(%1.12f).\n", ret_prob(MyManager, bdd)); endt = clock(); elapsedt = ((double)(endt - start)) / CLOCKS_PER_SEC; printf("elapsed_traversing(%lf).\n", elapsedt); // myexpand(MyManager, bdd); } if (params.savedfile > -1) SaveNodeDump(MyManager.manager, MyManager.varmap, bdd, arg[params.savedfile]); if (params.exportfile > -1) simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, arg[params.exportfile]); ReInitHistory(MyManager.his, MyManager.varmap.varcnt); free(MyManager.his); } if (MyManager.manager != NULL) { KillBDD(MyManager.manager); exit(code); free(MyManager.varmap.dvalue); free(MyManager.varmap.ivalue); free(MyManager.varmap.dynvalue); for (i = 0; i < MyManager.varmap.varcnt; i++) { free(MyManager.varmap.vars[i]); free(MyManager.varmap.mvars[i].probabilities); free(MyManager.varmap.mvars[i].booleanVars); } free(MyManager.varmap.vars); free(MyManager.varmap.mvars); free(MyManager.varmap.bVar2mVar); } if (params.error != NULL) free(params.error); return code; }