//Hugh 2012-04-05 ++++ int wldev_set_scansuppress(struct net_device *dev,int enable) { int res = 0; printf("%s: enter\n", __FUNCTION__); if (!dev) { WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__)); return -1; } printf("wldev_set_scansuppress enable[%d]\n", enable); if(enable){ if ((res = wldev_ioctl(dev, WLC_SET_SCANSUPPRESS, &enable, sizeof(enable), 1))) { WLDEV_ERROR(("%s fail to get ap\n", __FUNCTION__)); } printf("Successful enable scan suppress!!\n"); }else{ if ((res = wldev_ioctl(dev, WLC_SET_SCANSUPPRESS, &enable, sizeof(enable), 1))) { WLDEV_ERROR(("%s fail to get ap\n", __FUNCTION__)); } printf("Successful disable scan suppress!!\n"); } return 0; }
int wldev_start_stop_scansuppress(struct net_device *dev) { int res = 0; int enable = 1; if (!dev) { WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__)); return (res = -1);; } printf("%s enable[%d]\n",__FUNCTION__ ,enable); if(scan_suppress_flag){ if ((res = wldev_ioctl(dev, WLC_SET_SCANSUPPRESS, &enable, sizeof(enable), 1))) { WLDEV_ERROR(("%s fail to SET_SCANSUPPRESS enable\n", __FUNCTION__)); return (res = -1); } printf("Successful Enable scan suppress!!\n"); return 0; }else printf("scan_suppress_flag not set do nothing!!\n"); return 0; }
int wldev_get_ap_status(struct net_device *dev) { int res = 0; int ap = 0; int apsta = 0; char smbuf[WLC_IOCTL_SMLEN]; printf("%s: enter\n", __FUNCTION__); if (!dev) { WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__)); return -1; } if ((res = wldev_ioctl(dev, WLC_GET_AP, &ap, sizeof(ap), 0))) { WLDEV_ERROR(("%s fail to get ap\n", __FUNCTION__)); ap = 0; } if ((res = wldev_iovar_getbuf(dev, "apsta", &apsta, sizeof(apsta), smbuf, sizeof(smbuf), NULL)) < 0 ){ WLDEV_ERROR(("%s fail to get apsta \n", __FUNCTION__)); } else { memcpy(&apsta, smbuf, sizeof(apsta)); apsta = dtoh32(apsta); } return (ap||apsta); }
int wldev_set_country( struct net_device *dev, char *country_code, bool notify, bool user_enforced) { #ifdef TEGRA_REGION_BASED_NVRAM if (nv_dhd_set_nvram_params(country_code, dev)) { WLDEV_ERROR(("nvram params changed for country code: %s: Reload f/w\n", country_code)); return 0; } else return -1; #else /* TEGRA_REGION_BASED_NVRAM */ int error = -1; wl_country_t cspec = {{0}, 0, {0}}; scb_val_t scbval; char smbuf[WLC_IOCTL_SMLEN]; if (!country_code) return error; bzero(&scbval, sizeof(scb_val_t)); error = wldev_iovar_getbuf(dev, "country", NULL, 0, &cspec, sizeof(cspec), NULL); if (error < 0) { WLDEV_ERROR(("%s: get country failed = %d\n", __FUNCTION__, error)); return error; } if ((error < 0) || (strncmp(country_code, cspec.ccode, WLC_CNTRY_BUF_SZ) != 0)) { if (user_enforced) { bzero(&scbval, sizeof(scb_val_t)); error = wldev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t), true); if (error < 0) { WLDEV_ERROR(("%s: set country failed due to Disassoc error %d\n", __FUNCTION__, error)); return error; } } cspec.rev = -1; memcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ); memcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ); get_customized_country_code((char *)&cspec.country_abbrev, &cspec); error = wldev_iovar_setbuf(dev, "country", &cspec, sizeof(cspec), smbuf, sizeof(smbuf), NULL); if (error < 0) { WLDEV_ERROR(("%s: set country for %s as %s rev %d failed\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); return error; } dhd_bus_country_set(dev, &cspec, notify); WLDEV_ERROR(("%s: set country for %s as %s rev %d\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); } return 0; #endif }
int wldev_get_rx_rate_stats( struct net_device *dev, char *command, int total_len) { wl_scb_rx_rate_stats_t *rstats; struct ether_addr ea; char smbuf[WLC_IOCTL_SMLEN]; char eabuf[18] = {0, }; int bytes_written = 0; int error; memcpy(eabuf, command+strlen("RXRATESTATS")+1, 17); if (!bcm_ether_atoe(eabuf, &ea)) { WLDEV_ERROR(("Invalid MAC Address\n")); return -1; } error = wldev_iovar_getbuf(dev, "rx_rate_stats", &ea, ETHER_ADDR_LEN, smbuf, sizeof(smbuf), NULL); if (error < 0) { WLDEV_ERROR(("get rx_rate_stats failed = %d\n", error)); return -1; } rstats = (wl_scb_rx_rate_stats_t *)smbuf; bytes_written = sprintf(command, "1/%d/%d,", dtoh32(rstats->rx1mbps[0]), dtoh32(rstats->rx1mbps[1])); bytes_written += sprintf(command+bytes_written, "2/%d/%d,", dtoh32(rstats->rx2mbps[0]), dtoh32(rstats->rx2mbps[1])); bytes_written += sprintf(command+bytes_written, "5.5/%d/%d,", dtoh32(rstats->rx5mbps5[0]), dtoh32(rstats->rx5mbps5[1])); bytes_written += sprintf(command+bytes_written, "6/%d/%d,", dtoh32(rstats->rx6mbps[0]), dtoh32(rstats->rx6mbps[1])); bytes_written += sprintf(command+bytes_written, "9/%d/%d,", dtoh32(rstats->rx9mbps[0]), dtoh32(rstats->rx9mbps[1])); bytes_written += sprintf(command+bytes_written, "11/%d/%d,", dtoh32(rstats->rx11mbps[0]), dtoh32(rstats->rx11mbps[1])); bytes_written += sprintf(command+bytes_written, "12/%d/%d,", dtoh32(rstats->rx12mbps[0]), dtoh32(rstats->rx12mbps[1])); bytes_written += sprintf(command+bytes_written, "18/%d/%d,", dtoh32(rstats->rx18mbps[0]), dtoh32(rstats->rx18mbps[1])); bytes_written += sprintf(command+bytes_written, "24/%d/%d,", dtoh32(rstats->rx24mbps[0]), dtoh32(rstats->rx24mbps[1])); bytes_written += sprintf(command+bytes_written, "36/%d/%d,", dtoh32(rstats->rx36mbps[0]), dtoh32(rstats->rx36mbps[1])); bytes_written += sprintf(command+bytes_written, "48/%d/%d,", dtoh32(rstats->rx48mbps[0]), dtoh32(rstats->rx48mbps[1])); bytes_written += sprintf(command+bytes_written, "54/%d/%d", dtoh32(rstats->rx54mbps[0]), dtoh32(rstats->rx54mbps[1])); return bytes_written; }
void wldev_san_check_channel(struct net_device *ndev,int *errcode) { int error = 0; channel_info_t ci; int consta_channel = 0; int conap_channel = 0; printf("Enter %s\n",__FUNCTION__); if (!ndev ){ printf("%s NULL ConSTA netdev[%p]",__FUNCTION__,ndev); *errcode = 1; } if (!ap_net_dev ){ printf("%s NULL ConAP netdev[%p]",__FUNCTION__,ap_net_dev); *errcode = 2; } if ((error = wldev_ioctl(ndev, WLC_GET_CHANNEL, &ci, sizeof(ci), 0))) { WLDEV_ERROR(("%s: get ConSTA channel fail!\n", __FUNCTION__)); *errcode = 3; } else{ printf("%s Got ConSTA TargetChannel[%d]\n",__FUNCTION__,ci.target_channel); consta_channel = ci.target_channel; } if ((error = wldev_ioctl(ap_net_dev, WLC_GET_CHANNEL, &ci, sizeof(ci), 0))) { WLDEV_ERROR(("%s: get ConAP channel fail!\n", __FUNCTION__)); *errcode = 4; } else{ printf("%s Got ConAP TargetChannel[%d]\n",__FUNCTION__,ci.target_channel); conap_channel = ci.target_channel; } if(consta_channel == conap_channel){ printf("ConSTA,ConAP Channel same \n"); *errcode = 0; } else{ printf("ConSTA,ConAP Channel NOT same!!! \n"); *errcode = consta_channel; } printf("Leave %s errcode[%d]",__FUNCTION__,*errcode); }
int wldev_set_country( struct net_device *dev, char *country_code, bool notify, bool user_enforced, int revinfo) { int error = -1; wl_country_t cspec = {{0}, 0, {0}}; scb_val_t scbval; char smbuf[WLC_IOCTL_SMLEN]; if (!country_code) return error; bzero(&scbval, sizeof(scb_val_t)); error = wldev_iovar_getbuf(dev, "country", NULL, 0, &cspec, sizeof(cspec), NULL); if (error < 0) { WLDEV_ERROR(("%s: get country failed = %d\n", __FUNCTION__, error)); return error; } if ((error < 0) || dhd_force_country_change(dev) || (strncmp(country_code, cspec.ccode, WLC_CNTRY_BUF_SZ) != 0)) { if (user_enforced) { bzero(&scbval, sizeof(scb_val_t)); error = wldev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t), true); if (error < 0) { WLDEV_ERROR(("%s: set country failed due to Disassoc error %d\n", __FUNCTION__, error)); return error; } } cspec.rev = revinfo; memcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ); memcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ); dhd_get_customized_country_code(dev, (char *)&cspec.country_abbrev, &cspec); error = wldev_iovar_setbuf(dev, "country", &cspec, sizeof(cspec), smbuf, sizeof(smbuf), NULL); if (error < 0) { WLDEV_ERROR(("%s: set country for %s as %s rev %d failed\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); return error; } dhd_bus_country_set(dev, &cspec, notify); WLDEV_ERROR(("%s: set country for %s as %s rev %d\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); } return 0; }
int wldev_get_mode( struct net_device *dev, uint8 *cap) { int error = 0; int chanspec = 0; uint16 band = 0; uint16 bandwidth = 0; wl_bss_info_t *bss = NULL; char* buf = kmalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL); if (!buf) return -1; *(u32*) buf = htod32(WL_EXTRA_BUF_MAX); error = wldev_ioctl(dev, WLC_GET_BSS_INFO, (void*)buf, WL_EXTRA_BUF_MAX, false); if (error) { WLDEV_ERROR(("%s:failed:%d\n", __FUNCTION__, error)); return -1; } bss = (struct wl_bss_info *)(buf + 4); chanspec = wl_chspec_driver_to_host(bss->chanspec); band = chanspec & WL_CHANSPEC_BAND_MASK; bandwidth = chanspec & WL_CHANSPEC_BW_MASK; if (band == WL_CHANSPEC_BAND_2G) { if (bss->n_cap) strcpy(cap, "n"); else strcpy(cap, "bg"); } else if (band == WL_CHANSPEC_BAND_5G) { if (bandwidth == WL_CHANSPEC_BW_80) strcpy(cap, "ac"); else if ((bandwidth == WL_CHANSPEC_BW_40) || (bandwidth == WL_CHANSPEC_BW_20)) { if ((bss->nbss_cap & 0xf00) && (bss->n_cap)) strcpy(cap, "n|ac"); else if (bss->n_cap) strcpy(cap, "n"); else if (bss->vht_cap) strcpy(cap, "ac"); else strcpy(cap, "a"); } else { WLDEV_ERROR(("%s:Mode get failed\n", __FUNCTION__)); return -1; } } return error; }
/* * softap channel autoselect */ int wldev_get_auto_channel(struct net_device *dev, int *chan) { int chosen = 0; wl_uint32_list_t request; int retry = 0; int updown = 0; int ret = 0; wlc_ssid_t null_ssid; memset(&null_ssid, 0, sizeof(wlc_ssid_t)); ret |= wldev_ioctl(dev, WLC_UP, &updown, sizeof(updown), true); ret |= wldev_ioctl(dev, WLC_SET_SSID, &null_ssid, sizeof(null_ssid), true); request.count = htod32(0); ret = wldev_ioctl(dev, WLC_START_CHANNEL_SEL, &request, sizeof(request), true); if (ret < 0) { WLDEV_ERROR(("can't start auto channel scan:%d\n", ret)); goto fail; } while (retry++ < 15) { bcm_mdelay(350); ret = wldev_ioctl(dev, WLC_GET_CHANNEL_SEL, &chosen, sizeof(chosen), false); if ((ret == 0) && (dtoh32(chosen) != 0)) { *chan = (uint16)chosen & 0x00FF; /* covert chanspec --> chan number */ printf("%s: Got channel = %d, attempt:%d\n", __FUNCTION__, *chan, retry); break; } } if ((ret = wldev_ioctl(dev, WLC_DOWN, &updown, sizeof(updown), true)) < 0) { WLDEV_ERROR(("%s fail to WLC_DOWN ioctl err =%d\n", __FUNCTION__, ret)); goto fail; } fail : if (ret < 0) { WLDEV_ERROR(("%s: return value %d\n", __FUNCTION__, ret)); } return ret; }
int wldev_set_scansuppress(struct net_device *dev,int enable) { int res = 0; int scan_unassoc_time ; printf("%s: enter\n", __FUNCTION__); if (!dev) { WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__)); return -1; } printf("wldev_set_scansuppress enable[%d]\n", enable); if(enable){ scan_unassoc_time = 20; if((res = wldev_ioctl(dev, WLC_SET_SCAN_UNASSOC_TIME, (char *)&scan_unassoc_time,sizeof(scan_unassoc_time), 1))) { WLDEV_ERROR(("%s fail to set WLC_SET_SCAN_UNASSOC_TIME\n", __FUNCTION__)); } if ((res = wldev_ioctl(dev, WLC_SET_SCANSUPPRESS, &enable, sizeof(enable), 1))) { WLDEV_ERROR(("%s fail to get ap\n", __FUNCTION__)); } scan_suppress_flag = 1; printf("Successful enable scan suppress!!\n"); }else{ scan_unassoc_time = 80; if ((res = wldev_ioctl(dev, WLC_SET_SCAN_UNASSOC_TIME, (char *)&scan_unassoc_time,sizeof(scan_unassoc_time), 1))) { WLDEV_ERROR(("%s fail to set WLC_SET_SCAN_UNASSOC_TIME\n", __FUNCTION__)); } if ((res = wldev_ioctl(dev, WLC_SET_SCANSUPPRESS, &enable, sizeof(enable), 1))) { WLDEV_ERROR(("%s fail to get ap\n", __FUNCTION__)); } scan_suppress_flag = 0; printf("Successful disable scan suppress!!\n"); } return 0; }
int wldev_set_apsta_cfg(struct net_device *dev, char *param_str) { int res = 0; printf("%s: enter\n", __FUNCTION__); if (!dev) { WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__)); return -1; } init_ap_profile_from_string(param_str, &ap_cfg); if ((res = set_apsta_cfg(dev, &ap_cfg)) < 0) WLDEV_ERROR(("%s failed to set_apsta_cfg %d\n", __FUNCTION__, res)); return res; }
int wldev_set_ap_sta_registra_wsec(struct net_device *dev, char *command, int total_len) { int bytes_written = 0; int wsec = 0; if ( !ap_net_dev ) return 0; wldev_iovar_getint(ap_net_dev, "wsec", &wsec); WLDEV_ERROR(("### %s devname[%s],got wsec(bset)=0x%x\n", __FUNCTION__, ap_net_dev->name, wsec)); wsec |= SES_OW_ENABLED; WLDEV_ERROR(("### %s devname[%s],wsec=0x%x\n", __FUNCTION__, ap_net_dev->name, wsec)); wldev_iovar_setint(ap_net_dev, "wsec", wsec); WLDEV_ERROR(("### %s devname[%s] seting\n", __FUNCTION__, ap_net_dev->name)); wldev_iovar_getint(ap_net_dev, "wsec", &wsec); WLDEV_ERROR(("### %s devname[%s],got(aset) wsec=0x%x\n", __FUNCTION__, ap_net_dev->name, wsec)); return bytes_written; }
/** Format a bsscfg indexed iovar buffer. The bsscfg index will be * taken care of in dhd_ioctl_entry. Internal use only, not exposed to * wl_iw, wl_cfg80211 and wl_cfgp2p */ s32 wldev_mkiovar_bsscfg( const s8 *iovar_name, s8 *param, s32 paramlen, s8 *iovar_buf, s32 buflen, s32 bssidx) { const s8 *prefix = "bsscfg:"; s8 *p; u32 prefixlen; u32 namelen; u32 iolen; if (bssidx == 0) { return wldev_mkiovar((s8*)iovar_name, (s8 *)param, paramlen, (s8 *) iovar_buf, buflen); } prefixlen = (u32) strlen(prefix); /* lengh of bsscfg prefix */ namelen = (u32) strlen(iovar_name) + 1; /* lengh of iovar name + null */ iolen = prefixlen + namelen + sizeof(u32) + paramlen; if (buflen < 0 || iolen > (u32)buflen) { WLDEV_ERROR(("%s: buffer is too short\n", __FUNCTION__)); return BCME_BUFTOOSHORT; } if (iovar_buf && buflen != 0) memset(iovar_buf, 0, buflen); else return BCME_BADARG; p = (s8 *)iovar_buf; /* copy prefix, no null */ memcpy(p, prefix, prefixlen); p += prefixlen; /* copy iovar name including null */ memcpy(p, iovar_name, namelen); p += namelen; /* bss config index as first param */ bssidx = htod32(bssidx); memcpy(p, &bssidx, sizeof(u32)); p += sizeof(u32); /* parameter buffer follows */ if (paramlen) memcpy(p, param, paramlen); return iolen; }
s32 wldev_mkiovar_bsscfg( const s8 *iovar_name, s8 *param, s32 paramlen, s8 *iovar_buf, s32 buflen, s32 bssidx) { const s8 *prefix = "bsscfg:"; s8 *p; u32 prefixlen; u32 namelen; u32 iolen; if (bssidx == 0) { return wldev_mkiovar((s8*)iovar_name, (s8 *)param, paramlen, (s8 *) iovar_buf, buflen); } prefixlen = (u32) strlen(prefix); namelen = (u32) strlen(iovar_name) + 1; iolen = prefixlen + namelen + sizeof(u32) + paramlen; if (buflen < 0 || iolen > (u32)buflen) { WLDEV_ERROR(("%s: buffer is too short\n", __FUNCTION__)); return BCME_BUFTOOSHORT; } p = (s8 *)iovar_buf; memcpy(p, prefix, prefixlen); p += prefixlen; memcpy(p, iovar_name, namelen); p += namelen; bssidx = htod32(bssidx); memcpy(p, &bssidx, sizeof(u32)); p += sizeof(u32); if (paramlen) memcpy(p, param, paramlen); return iolen; }
static int wldev_set_pktfilter_enable_by_id(struct net_device *dev, int pkt_id, int enable) { wl_pkt_filter_enable_t enable_parm; char smbuf[WLC_IOCTL_SMLEN]; int res; /* enable or disable pkt filter, enable:1, disable:0 */ enable_parm.id = htod32(pkt_id); enable_parm.enable = htod32(enable); res = wldev_iovar_setbuf(dev, "pkt_filter_enable", &enable_parm, sizeof(enable_parm), smbuf, sizeof(smbuf), NULL); if (res < 0) { WLDEV_ERROR(("%s: set pkt_filter_enable failed, error:%d\n", __FUNCTION__, res)); return res; } return 0; }
s32 wldev_ioctl( struct net_device *dev, u32 cmd, void *arg, u32 len, u32 set) { s32 ret = 0; struct wl_ioctl ioc; memset(&ioc, 0, sizeof(ioc)); ioc.cmd = cmd; ioc.buf = arg; ioc.len = len; ioc.set = set; if (arg != NULL) { WLDEV_ERROR(("iovar:%s ioc->len%d cmd->%d type->%s\n", (char *)arg, ioc.len, cmd, set ? "set": "get")); } ret = dhd_ioctl_entry_local(dev, &ioc, cmd); return ret; }
int wldev_set_apsta(struct net_device *dev, bool enable) { int res = 0; int mpc = 0; int concr_mode = 0; char smbuf[WLC_IOCTL_SMLEN]; bss_setbuf_t bss_setbuf; memset(smbuf, 0, sizeof(smbuf)); printf("%s: enter\n", __FUNCTION__); if (!dev) { WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__)); return -1; } if (enable){ /* wait for interface ready */ wait_for_ap_ready(1); //broacom 0405 if ( ap_net_dev == NULL ) { WLDEV_ERROR(("%s ap_net_dev == NULL\n", __FUNCTION__)); goto fail; } //2012-09-10 CT2 set Concr_mode ++++ concr_mode = 1; if ((res = wldev_iovar_setint(dev, "concr_mode_set", concr_mode))) { printf("%s fail to set concr_mode res[%d]\n", __FUNCTION__,res); } //2012-09-10 CT2 set Concr_mode ++++ mpc = 0; if ((res = wldev_iovar_setint(dev, "mpc", mpc))) { WLDEV_ERROR(("%s fail to set mpc\n", __FUNCTION__)); goto fail; } if ((res = wl_iw_set_ap_security(ap_net_dev, &ap_cfg)) != 0) { WLDEV_ERROR((" %s ERROR setting SOFTAP security in :%d\n", __FUNCTION__, res)); goto fail; } bss_setbuf.cfg = 1; bss_setbuf.val = 1; /* up the interface */ if ((res = wldev_iovar_setbuf_bsscfg(dev, "bss", &bss_setbuf, sizeof(bss_setbuf), smbuf, sizeof(smbuf), 1, NULL)) < 0){ WLDEV_ERROR(("%s: ERROR:%d, set bss up failed\n", __FUNCTION__, res)); goto fail; } bcm_mdelay(500); if ((res = wldev_iovar_setint(dev, "allmulti", 1))) { WLDEV_ERROR(("%s: ERROR:%d, set allmulti failed\n", __FUNCTION__, res)); goto fail; } //BRCM_APSTA_START set_ap_channel(dev,&ap_cfg); ap_net_dev->operstate = IF_OPER_UP; //BRCM_APSTA_END } else { if ((res = wl_softap_stop(ap_net_dev))){ WLDEV_ERROR(("%s: ERROR:%d, call wl_softap_stop failed\n", __FUNCTION__, res)); goto fail; } //2012-09-10 CT2 set Concr_mode ++++ concr_mode = 0; if ((res = wldev_iovar_setint(dev, "concr_mode_set", concr_mode))) { printf("%s fail to set concr_mode res[%d]\n", __FUNCTION__,res); } //2012-09-10 CT2 set Concr_mode ++++ mpc = 1; if ((res = wldev_iovar_setint(dev, "mpc", mpc))) { WLDEV_ERROR(("%s fail to set mpc\n", __FUNCTION__)); goto fail; } } fail: return res; }
int wldev_set_country( struct net_device *dev, char *country_code, bool notify, bool user_enforced) { int error = -1; wl_country_t cspec = {{0}, 0, {0}}; scb_val_t scbval; char smbuf[WLC_IOCTL_SMLEN]; //CY+ default country when set country fail char default_country[10] = "XY"; //CY- #ifdef CHIPNUM uint chipnum = 0; #endif if (!country_code) return error; bzero(&scbval, sizeof(scb_val_t)); error = wldev_iovar_getbuf(dev, "country", NULL, 0, &cspec, sizeof(cspec), NULL); if (error < 0) { WLDEV_ERROR(("%s: get country failed = %d\n", __FUNCTION__, error)); return error; } //CY+ always set country #if 0 if ((error < 0) || (strncmp(country_code, cspec.country_abbrev, WLC_CNTRY_BUF_SZ) != 0)) { #else if(true){ #endif //CY- always set country if (user_enforced) { bzero(&scbval, sizeof(scb_val_t)); error = wldev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t), true); if (error < 0) { WLDEV_ERROR(("%s: set country failed due to Disassoc error %d\n", __FUNCTION__, error)); return error; } } cspec.rev = -1; memcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ); memcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ); #ifdef CHIPNUM chipnum = dhd_get_chipnum(dev); printk("%s: chipnum:%d\n", __FUNCTION__, chipnum); dhd_get_customized_country_code(dev, (char *)&cspec.country_abbrev, &cspec, chipnum); //CY+ set default country //BCM43340: XY //BCM43362: XV //BCM4343s: XV if (chipnum == 43430){ sprintf(default_country, "XV"); }else if (chipnum == 43362){ sprintf(default_country, "XV"); }else { sprintf(default_country, "XY"); } WLDEV_ERROR(("%s: set default country to %s for CHIP %d\n", __FUNCTION__, default_country, chipnum)); //CY- #else dhd_get_customized_country_code(dev, (char *)&cspec.country_abbrev, &cspec); #endif error = wldev_iovar_setbuf(dev, "country", &cspec, sizeof(cspec), smbuf, sizeof(smbuf), NULL); if (error < 0) { WLDEV_ERROR(("%s: set country for %s as %s rev %d failed, try to use %s\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev, default_country)); //return error; //if set country error, use default_country cspec.rev = -1; memcpy(cspec.country_abbrev, default_country, WLC_CNTRY_BUF_SZ); memcpy(cspec.ccode, default_country, WLC_CNTRY_BUF_SZ); #ifdef CHIPNUM dhd_get_customized_country_code(dev, (char *)&cspec.country_abbrev, &cspec, chipnum); #else dhd_get_customized_country_code(dev, (char *)&cspec.country_abbrev, &cspec); #endif error = wldev_iovar_setbuf(dev, "country", &cspec, sizeof(cspec), smbuf, sizeof(smbuf), NULL); if (error < 0) { WLDEV_ERROR(("%s: set country for %s as %s rev %d failed\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); return error; } } dhd_bus_country_set(dev, &cspec, notify); WLDEV_ERROR(("%s: set country for %s as %s rev %d\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); } return 0; } #if defined(CUSTOM_PLATFORM_NV_TEGRA) /* tuning performance for miracast */ int wldev_miracast_tuning( struct net_device *dev, char *command, int total_len) { int error = 0; int mode = 0; int ampdu_mpdu; int roam_off; #ifdef VSDB_BW_ALLOCATE_ENABLE int mchan_algo; int mchan_bw; #endif /* VSDB_BW_ALLOCATE_ENABLE */ if (sscanf(command, "%*s %d", &mode) != 1) { WLDEV_ERROR(("Failed to get mode\n")); return -1; } WLDEV_ERROR(("mode: %d\n", mode)); if (mode == 0) { /* Normal mode: restore everything to default */ ampdu_mpdu = -1; /* FW default */ #if defined(ROAM_ENABLE) roam_off = 0; /* roam enable */ #elif defined(DISABLE_BUILTIN_ROAM) roam_off = 1; /* roam disable */ #endif #ifdef VSDB_BW_ALLOCATE_ENABLE mchan_algo = 0; /* Default */ mchan_bw = 50; /* 50:50 */ #endif /* VSDB_BW_ALLOCATE_ENABLE */ } else if (mode == 1) { /* Miracast source mode */ ampdu_mpdu = 8; /* for tx latency */ #if defined(ROAM_ENABLE) || defined(DISABLE_BUILTIN_ROAM) roam_off = 1; /* roam disable */ #endif #ifdef VSDB_BW_ALLOCATE_ENABLE mchan_algo = 1; /* BW based */ mchan_bw = 25; /* 25:75 */ #endif /* VSDB_BW_ALLOCATE_ENABLE */ } else if (mode == 2) { /* Miracast sink/PC Gaming mode */ ampdu_mpdu = -1; /* FW default */ #if defined(ROAM_ENABLE) || defined(DISABLE_BUILTIN_ROAM) roam_off = 1; /* roam disable */ #endif #ifdef VSDB_BW_ALLOCATE_ENABLE mchan_algo = 0; /* Default */ mchan_bw = 50; /* 50:50 */ #endif /* VSDB_BW_ALLOCATE_ENABLE */ } else { WLDEV_ERROR(("Unknown mode: %d\n", mode)); return -1; } /* Update ampdu_mpdu */ error = wldev_iovar_setint(dev, "ampdu_mpdu", ampdu_mpdu); if (error) { WLDEV_ERROR(("Failed to set ampdu_mpdu: mode:%d, error:%d\n", mode, error)); return -1; } #if defined(ROAM_ENABLE) || defined(DISABLE_BUILTIN_ROAM) error = wldev_iovar_setint(dev, "roam_off", roam_off); if (error) { WLDEV_ERROR(("Failed to set roam_off: mode:%d, error:%d\n", mode, error)); return -1; } #endif /* ROAM_ENABLE || DISABLE_BUILTIN_ROAM */ #ifdef VSDB_BW_ALLOCATE_ENABLE error = wldev_iovar_setint(dev, "mchan_algo", mchan_algo); if (error) { WLDEV_ERROR(("Failed to set mchan_algo: mode:%d, error:%d\n", mode, error)); return -1; } error = wldev_iovar_setint(dev, "mchan_bw", mchan_bw); if (error) { WLDEV_ERROR(("Failed to set mchan_bw: mode:%d, error:%d\n", mode, error)); return -1; } #endif /* VSDB_BW_ALLOCATE_ENABLE */ return error; }
int wldev_set_country( struct net_device *dev, char *country_code) { int error = -1; wl_country_t cspec = {{0}, 0, {0}}; scb_val_t scbval; char smbuf[WLC_IOCTL_SMLEN]; uint32 chan_buf[WL_NUMCHANNELS]; wl_uint32_list_t *list; channel_info_t ci; int retry = 0; int chan = 1; if (!country_code) return error; error = wldev_iovar_getbuf(dev, "country", &cspec, sizeof(cspec), smbuf, sizeof(smbuf), NULL); if (error < 0) WLDEV_ERROR(("%s: get country failed = %d\n", __FUNCTION__, error)); if ((error < 0) || (strncmp(country_code, smbuf, WLC_CNTRY_BUF_SZ) != 0)) { bzero(&scbval, sizeof(scb_val_t)); error = wldev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t), 1); if (error < 0) { WLDEV_ERROR(("%s: set country failed due to Disassoc error %d\n", __FUNCTION__, error)); return error; } error = wldev_ioctl(dev, WLC_SET_CHANNEL, &chan, sizeof(chan), 1); if (error < 0) { WLDEV_ERROR(("%s: set country failed due to channel 1 error %d\n", __FUNCTION__, error)); return error; } } get_channel_retry: if ((error = wldev_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci), 0))) { WLDEV_ERROR(("%s: get channel fail!\n", __FUNCTION__)); return error; } ci.scan_channel = dtoh32(ci.scan_channel); if (ci.scan_channel) { retry++; printf("%s: scan in progress, retry %d!\n", __FUNCTION__, retry); if (retry > 3) return -EBUSY; bcm_mdelay(1000); goto get_channel_retry; } cspec.rev = -1; memcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ); memcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ); get_customized_country_code((char *)&cspec.country_abbrev, &cspec); error = wldev_iovar_setbuf(dev, "country", &cspec, sizeof(cspec), smbuf, sizeof(smbuf), NULL); if (error < 0) { if (strcmp(cspec.country_abbrev, DEF_COUNTRY_CODE) != 0) { strcpy(country_code, DEF_COUNTRY_CODE); retry = 0; goto get_channel_retry; } else { WLDEV_ERROR(("%s: set country for %s as %s rev %d failed\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); return error; } } else { if (strcmp(country_code, DEF_COUNTRY_CODE) != 0) { list = (wl_uint32_list_t *)(void *)chan_buf; list->count = htod32(WL_NUMCHANNELS); if ((error = wldev_ioctl_no_memset(dev, WLC_GET_VALID_CHANNELS, &chan_buf, sizeof(chan_buf), 0))) { WLDEV_ERROR(("%s: get channel list fail! %d\n", __FUNCTION__, error)); return error; } printf("%s: channel_count = %d\n", __FUNCTION__, list->count); if (list->count == 0) { strcpy(country_code, DEF_COUNTRY_CODE); retry = 0; goto get_channel_retry; } } } dhd_bus_country_set(dev, &cspec); printk(KERN_INFO "[WLAN] %s: set country for %s as %s rev %d\n", __func__, country_code, cspec.ccode, cspec.rev); wl_cfg80211_abort_connecting(); return 0; }
/* tuning performance for miracast */ int wldev_miracast_tuning( struct net_device *dev, int mode) { int error = 0; int ampdu_mpdu; int roam_off; #ifdef VSDB_BW_ALLOCATE_ENABLE int mchan_algo; int mchan_bw; #endif /* VSDB_BW_ALLOCATE_ENABLE */ WLDEV_ERROR(("mode: %d\n", mode)); if (mode == 0) { /* Normal mode: restore everything to default */ ampdu_mpdu = -1; /* FW default */ #if defined(ROAM_ENABLE) roam_off = 0; /* roam enable */ #elif defined(DISABLE_BUILTIN_ROAM) roam_off = 1; /* roam disable */ #endif #ifdef VSDB_BW_ALLOCATE_ENABLE mchan_algo = 0; /* Default */ mchan_bw = 50; /* 50:50 */ #endif /* VSDB_BW_ALLOCATE_ENABLE */ } else if (mode == 1) { /* Miracast source mode */ ampdu_mpdu = 8; /* for tx latency */ #if defined(ROAM_ENABLE) || defined(DISABLE_BUILTIN_ROAM) roam_off = 1; /* roam disable */ #endif #ifdef VSDB_BW_ALLOCATE_ENABLE mchan_algo = 1; /* BW based */ mchan_bw = 35; /* 35:65 */ #endif /* VSDB_BW_ALLOCATE_ENABLE */ } else if (mode == 2) { /* Miracast sink/PC Gaming mode */ ampdu_mpdu = -1; /* FW default */ #if defined(ROAM_ENABLE) || defined(DISABLE_BUILTIN_ROAM) roam_off = 1; /* roam disable */ #endif #ifdef VSDB_BW_ALLOCATE_ENABLE mchan_algo = 0; /* Default */ mchan_bw = 50; /* 50:50 */ #endif /* VSDB_BW_ALLOCATE_ENABLE */ } else { WLDEV_ERROR(("Unknown mode: %d\n", mode)); return -1; } /* Update ampdu_mpdu */ error = wldev_iovar_setint(dev, "ampdu_mpdu", ampdu_mpdu); if (error) { WLDEV_ERROR(("Failed to set ampdu_mpdu: mode:%d, error:%d\n", mode, error)); return -1; } #if defined(ROAM_ENABLE) || defined(DISABLE_BUILTIN_ROAM) error = wldev_iovar_setint(dev, "roam_off", roam_off); if (error) { WLDEV_ERROR(("Failed to set roam_off: mode:%d, error:%d\n", mode, error)); return -1; } #endif /* ROAM_ENABLE || DISABLE_BUILTIN_ROAM */ #ifdef VSDB_BW_ALLOCATE_ENABLE error = wldev_iovar_setint(dev, "mchan_algo", mchan_algo); if (error) { WLDEV_ERROR(("Failed to set mchan_algo: mode:%d, error:%d\n", mode, error)); return -1; } error = wldev_iovar_setint(dev, "mchan_bw", mchan_bw); if (error) { WLDEV_ERROR(("Failed to set mchan_bw: mode:%d, error:%d\n", mode, error)); return -1; } #endif /* VSDB_BW_ALLOCATE_ENABLE */ return error; }
int wldev_set_country( struct net_device *dev, char *country_code, bool notify, bool user_enforced) { int error = -1; wl_country_t cspec = {{0}, 0, {0}}; scb_val_t scbval; char smbuf[WLC_IOCTL_SMLEN]; #ifdef CUSTOMER_HW_ONE uint32 chan_buf[WL_NUMCHANNELS]; wl_uint32_list_t *list; channel_info_t ci; int retry = 0; int chan = 1; #endif if (!country_code) return error; bzero(&scbval, sizeof(scb_val_t)); error = wldev_iovar_getbuf(dev, "country", NULL, 0, &cspec, sizeof(cspec), NULL); if (error < 0) { WLDEV_ERROR(("%s: get country failed = %d\n", __FUNCTION__, error)); return error; } if ((error < 0) || (strncmp(country_code, cspec.country_abbrev, WLC_CNTRY_BUF_SZ) != 0)) { if (user_enforced) { bzero(&scbval, sizeof(scb_val_t)); error = wldev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t), true); if (error < 0) { WLDEV_ERROR(("%s: set country failed due to Disassoc error %d\n", __FUNCTION__, error)); return error; } } #ifdef CUSTOMER_HW_ONE error = wldev_ioctl(dev, WLC_SET_CHANNEL, &chan, sizeof(chan), 1); if (error < 0) { WLDEV_ERROR(("%s: set country failed due to channel 1 error %d\n", __FUNCTION__, error)); return error; } } get_channel_retry: if ((error = wldev_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci), 0))) { WLDEV_ERROR(("%s: get channel fail!\n", __FUNCTION__)); return error; } ci.scan_channel = dtoh32(ci.scan_channel); if (ci.scan_channel) { retry++; printf("%s: scan in progress, retry %d!\n", __FUNCTION__, retry); if (retry > 3) return -EBUSY; bcm_mdelay(1000); goto get_channel_retry; } #endif cspec.rev = -1; memcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ); memcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ); get_customized_country_code((char *)&cspec.country_abbrev, &cspec); error = wldev_iovar_setbuf(dev, "country", &cspec, sizeof(cspec), smbuf, sizeof(smbuf), NULL); if (error < 0) { #ifdef CUSTOMER_HW_ONE if (strcmp(cspec.country_abbrev, DEF_COUNTRY_CODE) != 0) { strcpy(country_code, DEF_COUNTRY_CODE); retry = 0; goto get_channel_retry; } else { #endif WLDEV_ERROR(("%s: set country for %s as %s rev %d failed\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); return error; } #ifdef CUSTOMER_HW_ONE } /* check if there are available channels */ else { if (strcmp(country_code, DEF_COUNTRY_CODE) != 0) { list = (wl_uint32_list_t *)(void *)chan_buf; list->count = htod32(WL_NUMCHANNELS); if ((error = wldev_ioctl_no_memset(dev, WLC_GET_VALID_CHANNELS, &chan_buf, sizeof(chan_buf), 0))) { WLDEV_ERROR(("%s: get channel list fail! %d\n", __FUNCTION__, error)); return error; } /* if NULL, set default country code instead and set country code again */ printf("%s: channel_count = %d\n", __FUNCTION__, list->count); if (list->count == 0) { strcpy(country_code, DEF_COUNTRY_CODE); retry = 0; goto get_channel_retry; } } #endif dhd_bus_country_set(dev, &cspec, notify); WLDEV_ERROR(("%s: set country for %s as %s rev %d\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); } #ifdef CUSTOMER_HW_ONE wl_cfg80211_abort_connecting(); #endif return 0; }
void wldev_adj_apsta_scan_param(struct net_device *dev,int enable) { int res; if(enable){ int scan_home_time = APSTA_SCAN_HOME_TIME; int scan_assoc_time = APSTA_SCAN_ASSOC_TIME; int scan_passive_time = APSTA_SCAN_PASSIVE_TIME; int scan_nprobes = APSTA_SCAN_NPROBES; int srl = APSTA_SCAN_SRL; int lrl = APSTA_SCAN_LRL; if((res = wldev_ioctl(dev, WLC_SET_SCAN_HOME_TIME, (char *)&scan_home_time,sizeof(scan_home_time), 1))) WLDEV_ERROR(("%s fail to WLC_SET_SCAN_HOME_TIME\n", __FUNCTION__)); if((res = wldev_ioctl(dev, WLC_SET_SCAN_CHANNEL_TIME, (char *)&scan_assoc_time,sizeof(scan_assoc_time), 1))) WLDEV_ERROR(("%s fail to WLC_SET_SCAN_CHANNEL_TIME\n", __FUNCTION__)); if((res = wldev_ioctl(dev, WLC_SET_SCAN_PASSIVE_TIME, (char *)&scan_passive_time,sizeof(scan_passive_time), 1))) WLDEV_ERROR(("%s fail WLC_SET_SCAN_PASSIVE_TIME\n", __FUNCTION__)); if((res = wldev_ioctl(dev, WLC_SET_SCAN_NPROBES, (char *)&scan_nprobes,sizeof(scan_nprobes), 1))) WLDEV_ERROR(("%s fail to WLC_SET_SCAN_NPROBES\n", __FUNCTION__)); if((res = wldev_ioctl(dev, WLC_SET_SRL, (char *)&srl,sizeof(srl), 1))) WLDEV_ERROR(("%s fail to WLC_SET_SRL\n", __FUNCTION__)); if((res = wldev_ioctl(dev, WLC_SET_LRL, (char *)&lrl,sizeof(lrl), 1))) WLDEV_ERROR(("%s fail to WLC_SET_LRL\n", __FUNCTION__)); }else{ int scan_home_time = SCAN_HOME_TIME; int scan_assoc_time = SCAN_ASSOC_TIME; int scan_passive_time = SCAN_PASSIVE_TIME; int scan_nprobes = SCAN_NPROBES; int srl = SCAN_SRL; int lrl = SCAN_LRL; if((res = wldev_ioctl(dev, WLC_SET_SCAN_HOME_TIME, (char *)&scan_home_time,sizeof(scan_home_time), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_SCAN_HOME_TIME\n", __FUNCTION__)); } if((res = wldev_ioctl(dev, WLC_SET_SCAN_CHANNEL_TIME, (char *)&scan_assoc_time,sizeof(scan_assoc_time), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_SCAN_CHANNEL_TIME\n", __FUNCTION__)); } if((res = wldev_ioctl(dev, WLC_SET_SCAN_PASSIVE_TIME, (char *)&scan_passive_time,sizeof(scan_passive_time), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_SCAN_PASSIVE_TIME\n", __FUNCTION__)); } if((res = wldev_ioctl(dev, WLC_SET_SCAN_NPROBES, (char *)&scan_nprobes,sizeof(scan_nprobes), 1))) { WLDEV_ERROR(("%s fail WLC_SET_SCAN_NPROBES\n", __FUNCTION__)); } if((res = wldev_ioctl(dev, WLC_SET_SRL, (char *)&srl,sizeof(srl), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_SRL\n", __FUNCTION__)); } if((res = wldev_ioctl(dev, WLC_SET_LRL, (char *)&lrl,sizeof(lrl), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_LRL\n", __FUNCTION__)); } } }
int wldev_set_apsta(struct net_device *dev, bool enable) { int res = 0; int mpc = 0; int concr_mode = 0; int roam_off; char smbuf[WLC_IOCTL_SMLEN]; bss_setbuf_t bss_setbuf; int frameburst; memset(smbuf, 0, sizeof(smbuf)); printf("%s: enter\n", __FUNCTION__); if (!dev) { WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__)); return -1; } if (enable){ wait_for_ap_ready(1); if ( ap_net_dev == NULL ) { WLDEV_ERROR(("%s ap_net_dev == NULL\n", __FUNCTION__)); goto fail; } concr_mode = 1; if ((res = wldev_iovar_setint(dev, "concr_mode_set", concr_mode))) { printf("%s fail to set concr_mode res[%d]\n", __FUNCTION__,res); } roam_off = 1; if((res = wldev_iovar_setint(dev, "roam_off", roam_off))) printf("%s fail to set roam_off res[%d]\n", __FUNCTION__,res); mpc = 0; if ((res = wldev_iovar_setint(dev, "mpc", mpc))) { WLDEV_ERROR(("%s fail to set mpc\n", __FUNCTION__)); goto fail; } if ((res = wl_iw_set_ap_security(ap_net_dev, &ap_cfg)) != 0) { WLDEV_ERROR((" %s ERROR setting SOFTAP security in :%d\n", __FUNCTION__, res)); goto fail; } if(wl_get_drv_status(wlcfg_drv_priv,CONNECTED,dev)) { u32 chanspec = 0; int err; if(wldev_iovar_getint(dev, "chanspec", (s32 *)&chanspec) == BCME_OK) { printf("%s get Chanspec [%0x]\n",__func__ ,chanspec); if((err = wldev_iovar_setint(ap_net_dev, "chanspec", chanspec)) == BCME_BADCHAN) { printf("%s set Chanspec failed\n",__func__); } else printf("%s set Chanspec OK\n",__func__); } else printf("%s get Chanspec failed\n",__func__); } else printf("%s Sta is not connected with any AP\n",__func__); bss_setbuf.cfg = 1; bss_setbuf.val = 1; if ((res = wldev_iovar_setbuf_bsscfg(dev, "bss", &bss_setbuf, sizeof(bss_setbuf), smbuf, sizeof(smbuf), 1, NULL)) < 0){ WLDEV_ERROR(("%s: ERROR:%d, set bss up failed\n", __FUNCTION__, res)); goto fail; } printf("prepare set frameburst \n"); frameburst = 1; if ((res = wldev_ioctl(dev, WLC_SET_FAKEFRAG, &frameburst, sizeof(frameburst), 0))) { printf("%s fail to set frameburst !!\n", __FUNCTION__); } if ((res = wldev_iovar_setint(dev, "allmulti", 1))) { WLDEV_ERROR(("%s: ERROR:%d, set allmulti failed\n", __FUNCTION__, res)); goto fail; } set_ap_channel(dev,&ap_cfg); ap_net_dev->operstate = IF_OPER_UP; } else { if ((res = wl_softap_stop(ap_net_dev))){ WLDEV_ERROR(("%s: ERROR:%d, call wl_softap_stop failed\n", __FUNCTION__, res)); goto fail; } concr_mode = 0; if ((res = wldev_iovar_setint(dev, "concr_mode_set", concr_mode))) { printf("%s fail to set concr_mode res[%d]\n", __FUNCTION__,res); } roam_off = 0; if((res = wldev_iovar_setint(dev, "roam_off", roam_off))) printf("%s fail to set roam_off res[%d]\n", __FUNCTION__,res); mpc = 1; if ((res = wldev_iovar_setint(dev, "mpc", mpc))) { WLDEV_ERROR(("%s fail to set mpc\n", __FUNCTION__)); goto fail; } printf("prepare set frameburst \n"); frameburst = 0; if ((res = wldev_ioctl(dev, WLC_SET_FAKEFRAG, &frameburst, sizeof(frameburst), 0))) { printf("%s fail to set frameburst !!\n", __FUNCTION__); } } fail: return res; }
int wldev_get_max_linkspeed( struct net_device *dev, char *command, int total_len) { wl_assoc_info_t *assoc_info; char smbuf[WLC_IOCTL_SMLEN]; char bssid[6], null_bssid[6]; int resp_ies_len = 0; int bytes_written = 0; int error, i; bzero(bssid, 6); bzero(null_bssid, 6); /* Check Association */ error = wldev_ioctl(dev, WLC_GET_BSSID, &bssid, sizeof(bssid), 0); if (error == BCME_NOTASSOCIATED) { /* Not associated */ bytes_written += snprintf(&command[bytes_written], total_len, "-1"); goto done; } else if (error < 0) { WLDEV_ERROR(("WLC_GET_BSSID failed = %d\n", error)); return -1; } else if (memcmp(bssid, null_bssid, ETHER_ADDR_LEN) == 0) { /* Zero BSSID: Not associated */ bytes_written += snprintf(&command[bytes_written], total_len, "-1"); goto done; } /* Get assoc_info */ bzero(smbuf, sizeof(smbuf)); error = wldev_iovar_getbuf(dev, "assoc_info", NULL, 0, smbuf, sizeof(smbuf), NULL); if (error < 0) { WLDEV_ERROR(("get assoc_info failed = %d\n", error)); return -1; } assoc_info = (wl_assoc_info_t *)smbuf; resp_ies_len = dtoh32(assoc_info->resp_len) - sizeof(struct dot11_assoc_resp); /* Retrieve assoc resp IEs */ if (resp_ies_len) { error = wldev_iovar_getbuf(dev, "assoc_resp_ies", NULL, 0, smbuf, sizeof(smbuf), NULL); if (error < 0) { WLDEV_ERROR(("get assoc_resp_ies failed = %d\n", error)); return -1; } { int maxRate = 0; struct dot11IE { unsigned char ie; unsigned char len; unsigned char data[0]; } *dot11IE = (struct dot11IE *)smbuf; int remaining = resp_ies_len; while (1) { if (remaining < 2) break; if (remaining < dot11IE->len + 2) break; switch (dot11IE->ie) { case 0x01: /* supported rates */ case 0x32: /* extended supported rates */ for (i = 0; i < dot11IE->len; i++) { int rate = ((dot11IE->data[i] & 0x7f) / 2); if (rate > maxRate) maxRate = rate; } break; case 0x2d: /* HT capabilities */ case 0x3d: /* HT operation */ /* 11n supported */ maxRate = 150; /* Just return an 11n rate for now. Could implement detailed parser later. */ break; default: break; } /* next IE */ dot11IE = (struct dot11IE *) ((unsigned char *)dot11IE + dot11IE->len + 2); remaining -= (dot11IE->len + 2); } bytes_written += snprintf(&command[bytes_written], total_len, "MaxLinkSpeed %d", maxRate); goto done; } } else { WLDEV_ERROR(("Zero Length assoc resp ies = %d\n", resp_ies_len)); return -1; } done: return bytes_written; }
int wldev_get_assoc_resp_ie( struct net_device *dev, char *command, int total_len) { wl_assoc_info_t *assoc_info; char smbuf[WLC_IOCTL_SMLEN]; char bssid[6], null_bssid[6]; int resp_ies_len = 0; int bytes_written = 0; int error, i; bzero(bssid, 6); bzero(null_bssid, 6); /* Check Association */ error = wldev_ioctl(dev, WLC_GET_BSSID, &bssid, sizeof(bssid), 0); if (error == BCME_NOTASSOCIATED) { /* Not associated */ bytes_written += snprintf(&command[bytes_written], total_len, "NA"); goto done; } else if (error < 0) { WLDEV_ERROR(("WLC_GET_BSSID failed = %d\n", error)); return -1; } else if (memcmp(bssid, null_bssid, ETHER_ADDR_LEN) == 0) { /* Zero BSSID: Not associated */ bytes_written += snprintf(&command[bytes_written], total_len, "NA"); goto done; } /* Get assoc_info */ bzero(smbuf, sizeof(smbuf)); error = wldev_iovar_getbuf(dev, "assoc_info", NULL, 0, smbuf, sizeof(smbuf), NULL); if (error < 0) { WLDEV_ERROR(("get assoc_info failed = %d\n", error)); return -1; } assoc_info = (wl_assoc_info_t *)smbuf; resp_ies_len = dtoh32(assoc_info->resp_len) - sizeof(struct dot11_assoc_resp); /* Retrieve assoc resp IEs */ if (resp_ies_len) { error = wldev_iovar_getbuf(dev, "assoc_resp_ies", NULL, 0, smbuf, sizeof(smbuf), NULL); if (error < 0) { WLDEV_ERROR(("get assoc_resp_ies failed = %d\n", error)); return -1; } /* Length */ bytes_written += snprintf(&command[bytes_written], total_len, "%d,", resp_ies_len); /* IEs */ if ((total_len - bytes_written) > resp_ies_len) { for (i = 0; i < resp_ies_len; i++) { bytes_written += sprintf(&command[bytes_written], "%02x", smbuf[i]); } } else { WLDEV_ERROR(("Not enough buffer\n")); return -1; } } else { WLDEV_ERROR(("Zero Length assoc resp ies = %d\n", resp_ies_len)); return -1; } done: return bytes_written; }
/* tuning performance for miracast */ int wldev_miracast_tuning( struct net_device *dev, char *command, int total_len) { int error = 0; int mode = 0; int ampdu_mpdu; int ampdu_rx_tid = -1; int disable_interference_mitigation = 0; int auto_interference_mitigation = -1; #ifdef VSDB_BW_ALLOCATE_ENABLE int mchan_algo; int mchan_bw; #endif /* VSDB_BW_ALLOCATE_ENABLE */ if (sscanf(command, "%*s %d", &mode) != 1) { WLDEV_ERROR(("Failed to get mode\n")); return -1; } set_mode: WLDEV_ERROR(("mode: %d\n", mode)); if (mode == 0) { /* Normal mode: restore everything to default */ ampdu_mpdu = -1; /* FW default */ #ifdef VSDB_BW_ALLOCATE_ENABLE mchan_algo = 0; /* Default */ mchan_bw = 50; /* 50:50 */ #endif /* VSDB_BW_ALLOCATE_ENABLE */ } else if (mode == 1) { /* Miracast source mode */ ampdu_mpdu = 8; /* for tx latency */ #ifdef VSDB_BW_ALLOCATE_ENABLE mchan_algo = 1; /* BW based */ mchan_bw = 25; /* 25:75 */ #endif /* VSDB_BW_ALLOCATE_ENABLE */ } else if (mode == 2) { /* Miracast sink/PC Gaming mode */ ampdu_mpdu = 8; /* FW default */ #ifdef VSDB_BW_ALLOCATE_ENABLE mchan_algo = 0; /* Default */ mchan_bw = 50; /* 50:50 */ #endif /* VSDB_BW_ALLOCATE_ENABLE */ } else if (mode == 3) { ampdu_rx_tid = 0; mode = 2; goto set_mode; } else if (mode == 4) { ampdu_rx_tid = 0x5f; mode = 0; goto set_mode; } else if (mode == 5) { /* Blake connected mode, disable interference mitigation */ error = wldev_ioctl(dev, WLC_SET_INTERFERENCE_OVERRIDE_MODE, &disable_interference_mitigation, sizeof(int), true); if (error) { WLDEV_ERROR(( "Failed to set interference_override: mode:%d, error:%d\n", mode, error)); return -1; } return error; } else if (mode == 6) { /* No Blake connected, enable auto interference mitigation */ error = wldev_ioctl(dev, WLC_SET_INTERFERENCE_OVERRIDE_MODE, &auto_interference_mitigation, sizeof(int), true); if (error) { WLDEV_ERROR(( "Failed to set interference_override: mode:%d, error:%d\n", mode, error)); return -1; } return error; } else { WLDEV_ERROR(("Unknown mode: %d\n", mode)); return -1; } /* Update ampdu_mpdu */ error = wldev_iovar_setint(dev, "ampdu_mpdu", ampdu_mpdu); if (error) { WLDEV_ERROR(("Failed to set ampdu_mpdu: mode:%d, error:%d\n", mode, error)); return -1; } if (ampdu_rx_tid != -1) dhd_set_ampdu_rx_tid(dev, ampdu_rx_tid); #ifdef VSDB_BW_ALLOCATE_ENABLE error = wldev_iovar_setint(dev, "mchan_algo", mchan_algo); if (error) { WLDEV_ERROR(("Failed to set mchan_algo: mode:%d, error:%d\n", mode, error)); return -1; } error = wldev_iovar_setint(dev, "mchan_bw", mchan_bw); if (error) { WLDEV_ERROR(("Failed to set mchan_bw: mode:%d, error:%d\n", mode, error)); return -1; } #endif /* VSDB_BW_ALLOCATE_ENABLE */ return error; }
void wldev_adj_apsta_scan_param(struct net_device *dev,int enable) { int res; if(enable){ //adjust parameters int scan_home_time = APSTA_SCAN_HOME_TIME; int scan_assoc_time = APSTA_SCAN_ASSOC_TIME; int scan_passive_time = APSTA_SCAN_PASSIVE_TIME; int scan_nprobes = APSTA_SCAN_NPROBES; int srl = APSTA_SCAN_SRL; int lrl = APSTA_SCAN_LRL; /*set scan home time*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_HOME_TIME, (char *)&scan_home_time,sizeof(scan_home_time), 1))) WLDEV_ERROR(("%s fail to WLC_SET_SCAN_HOME_TIME\n", __FUNCTION__)); /*set scan assoc time*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_CHANNEL_TIME, (char *)&scan_assoc_time,sizeof(scan_assoc_time), 1))) WLDEV_ERROR(("%s fail to WLC_SET_SCAN_CHANNEL_TIME\n", __FUNCTION__)); /*set scan passive time*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_PASSIVE_TIME, (char *)&scan_passive_time,sizeof(scan_passive_time), 1))) WLDEV_ERROR(("%s fail WLC_SET_SCAN_PASSIVE_TIME\n", __FUNCTION__)); /*set scan nprobes*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_NPROBES, (char *)&scan_nprobes,sizeof(scan_nprobes), 1))) WLDEV_ERROR(("%s fail to WLC_SET_SCAN_NPROBES\n", __FUNCTION__)); /*set srl*/ if((res = wldev_ioctl(dev, WLC_SET_SRL, (char *)&srl,sizeof(srl), 1))) WLDEV_ERROR(("%s fail to WLC_SET_SRL\n", __FUNCTION__)); /*set lrl*/ if((res = wldev_ioctl(dev, WLC_SET_LRL, (char *)&lrl,sizeof(lrl), 1))) WLDEV_ERROR(("%s fail to WLC_SET_LRL\n", __FUNCTION__)); }else{ //revert to the original design int scan_home_time = SCAN_HOME_TIME; int scan_assoc_time = SCAN_ASSOC_TIME; int scan_passive_time = SCAN_PASSIVE_TIME; int scan_nprobes = SCAN_NPROBES; int srl = SCAN_SRL; int lrl = SCAN_LRL; /*set scan home time*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_HOME_TIME, (char *)&scan_home_time,sizeof(scan_home_time), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_SCAN_HOME_TIME\n", __FUNCTION__)); } /*store scan assoc time*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_CHANNEL_TIME, (char *)&scan_assoc_time,sizeof(scan_assoc_time), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_SCAN_CHANNEL_TIME\n", __FUNCTION__)); } /*store scan passive time*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_PASSIVE_TIME, (char *)&scan_passive_time,sizeof(scan_passive_time), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_SCAN_PASSIVE_TIME\n", __FUNCTION__)); } /*store scan nprobes*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_NPROBES, (char *)&scan_nprobes,sizeof(scan_nprobes), 1))) { WLDEV_ERROR(("%s fail WLC_SET_SCAN_NPROBES\n", __FUNCTION__)); } /*store srl*/ if((res = wldev_ioctl(dev, WLC_SET_SRL, (char *)&srl,sizeof(srl), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_SRL\n", __FUNCTION__)); } /*store srl*/ if((res = wldev_ioctl(dev, WLC_SET_LRL, (char *)&lrl,sizeof(lrl), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_LRL\n", __FUNCTION__)); } } }
int wldev_set_scansuppress(struct net_device *dev,int enable) { int res = 0; int scan_unassoc_time ; printf("%s: enter\n", __FUNCTION__); if (!dev) { WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__)); return -1; } printf("wldev_set_scansuppress enable[%d]\n", enable); if(enable){ #if 1 scan_unassoc_time = 20; if((res = wldev_ioctl(dev, WLC_SET_SCAN_UNASSOC_TIME, (char *)&scan_unassoc_time,sizeof(scan_unassoc_time), 1))) { WLDEV_ERROR(("%s fail to set WLC_SET_SCAN_UNASSOC_TIME\n", __FUNCTION__)); } if ((res = wldev_ioctl(dev, WLC_SET_SCANSUPPRESS, &enable, sizeof(enable), 1))) { WLDEV_ERROR(("%s fail to get ap\n", __FUNCTION__)); } scan_suppress_flag = 1; #else dhd_wl_ioctl_cmd(dhd, WLC_SET_SCAN_UNASSOC_TIME, (char *)&scan_unassoc_time, sizeof(scan_unassoc_time), TRUE, 0); roam_off = 1; if((res = wldev_iovar_setint(dev, "roam_off", roam_off))){ printf("%s fail to set roam_off[%d]\n", __FUNCTION__,roam_off); return -1; }else{ printf("Set roam_off 1 and enable scansuppress_flag!!\n"); scan_suppress_flag = 1; } #endif printf("Successful enable scan suppress!!\n"); }else{ #if 1 scan_unassoc_time = 80; if ((res = wldev_ioctl(dev, WLC_SET_SCAN_UNASSOC_TIME, (char *)&scan_unassoc_time,sizeof(scan_unassoc_time), 1))) { WLDEV_ERROR(("%s fail to set WLC_SET_SCAN_UNASSOC_TIME\n", __FUNCTION__)); } if ((res = wldev_ioctl(dev, WLC_SET_SCANSUPPRESS, &enable, sizeof(enable), 1))) { WLDEV_ERROR(("%s fail to get ap\n", __FUNCTION__)); } scan_suppress_flag = 0; #else roam_off = 0; if((res = wldev_iovar_setint(dev, "roam_off", roam_off))){ printf("%s fail to set roam_off[%d]\n", __FUNCTION__,roam_off); return -1; }else{ printf("set roam_off to zero and disable scansuppress_flag!!\n"); scan_suppress_flag = 0; } #endif printf("Successful disable scan suppress!!\n"); } return 0; }
int wldev_set_apsta(struct net_device *dev, bool enable) { int res = 0; int mpc = 0; int concr_mode = 0; int roam_off; char smbuf[WLC_IOCTL_SMLEN]; bss_setbuf_t bss_setbuf; int frameburst; memset(smbuf, 0, sizeof(smbuf)); printf("%s: enter\n", __FUNCTION__); if (!dev) { WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__)); return -1; } if (enable){ /* wait for interface ready */ wait_for_ap_ready(1); if ( ap_net_dev == NULL ) { WLDEV_ERROR(("%s ap_net_dev == NULL\n", __FUNCTION__)); goto fail; } concr_mode = 1; if ((res = wldev_iovar_setint(dev, "concr_mode_set", concr_mode))) { printf("%s fail to set concr_mode res[%d]\n", __FUNCTION__,res); } rxglom_fail_count = RXGLOM_CONCUR_MODE_FAIL_COUNT; max_cntl_timeout = MAX_CONCUR_MODE_CNTL_TIMEOUT; roam_off = 1; if((res = wldev_iovar_setint(dev, "roam_off", roam_off))) printf("%s fail to set roam_off res[%d]\n", __FUNCTION__,res); mpc = 0; if ((res = wldev_iovar_setint(dev, "mpc", mpc))) { WLDEV_ERROR(("%s fail to set mpc\n", __FUNCTION__)); goto fail; } if ((res = wl_iw_set_ap_security(ap_net_dev, &ap_cfg)) != 0) { WLDEV_ERROR((" %s ERROR setting SOFTAP security in :%d\n", __FUNCTION__, res)); goto fail; } if(wl_get_drv_status(wlcfg_drv_priv,CONNECTED,dev)) { u32 chanspec = 0; int err; if(wldev_iovar_getint(dev, "chanspec", (s32 *)&chanspec) == BCME_OK) { printf("%s get Chanspec [%0x]\n",__func__ ,chanspec); if((err = wldev_iovar_setint(ap_net_dev, "chanspec", chanspec)) == BCME_BADCHAN) { printf("%s set Chanspec failed\n",__func__); } else printf("%s set Chanspec OK\n",__func__); } else printf("%s get Chanspec failed\n",__func__); } else printf("%s Sta is not connected with any AP\n",__func__); bss_setbuf.cfg = 1; bss_setbuf.val = 1; /* up the interface */ if ((res = wldev_iovar_setbuf_bsscfg(dev, "bss", &bss_setbuf, sizeof(bss_setbuf), smbuf, sizeof(smbuf), 1, NULL)) < 0){ WLDEV_ERROR(("%s: ERROR:%d, set bss up failed\n", __FUNCTION__, res)); goto fail; } bcm_mdelay(500); printf("prepare set frameburst \n"); frameburst = 1; if ((res = wldev_ioctl(dev, WLC_SET_FAKEFRAG, &frameburst, sizeof(frameburst), 0))) { printf("%s fail to set frameburst !!\n", __FUNCTION__); } if ((res = wldev_iovar_setint(dev, "allmulti", 1))) { WLDEV_ERROR(("%s: ERROR:%d, set allmulti failed\n", __FUNCTION__, res)); goto fail; } #if !defined(WLCREDALL) if ((res = wldev_iovar_setint(dev, "bus:credall", 1))) { WLDEV_ERROR(("%s: ERROR:%d, set credall failed\n", __FUNCTION__, res)); goto fail; } #endif set_ap_channel(dev,&ap_cfg); ap_net_dev->operstate = IF_OPER_UP; } else { if ((res = wl_softap_stop(ap_net_dev))){ WLDEV_ERROR(("%s: ERROR:%d, call wl_softap_stop failed\n", __FUNCTION__, res)); goto fail; } concr_mode = 0; if ((res = wldev_iovar_setint(dev, "concr_mode_set", concr_mode))) { printf("%s fail to set concr_mode res[%d]\n", __FUNCTION__,res); } rxglom_fail_count = RXGLOM_FAIL_COUNT; max_cntl_timeout = MAX_CNTL_TIMEOUT; scan_suppress_flag = 0; /* 2012-09-21 Stop roam when start Concurrent ++++ */ roam_off = 0; if((res = wldev_iovar_setint(dev, "roam_off", roam_off))) printf("%s fail to set roam_off res[%d]\n", __FUNCTION__,res); mpc = 1; if ((res = wldev_iovar_setint(dev, "mpc", mpc))) { WLDEV_ERROR(("%s fail to set mpc\n", __FUNCTION__)); goto fail; } #if !defined(WLCREDALL) if ((res = wldev_iovar_setint(dev, "bus:credall", 0))) { WLDEV_ERROR(("%s fail to set credall\n", __FUNCTION__)); goto fail; } #endif printf("prepare set frameburst \n"); frameburst = 0; if ((res = wldev_ioctl(dev, WLC_SET_FAKEFRAG, &frameburst, sizeof(frameburst), 0))) { printf("%s fail to set frameburst !!\n", __FUNCTION__); } wlcfg_drv_priv->dongle_connected = 0; wldev_adj_apsta_scan_param(dev,wlcfg_drv_priv->dongle_connected); } fail: return res; }
int wldev_miracast_tuning( struct net_device *dev, int mode) { int error = 0; int ampdu_mpdu; int roam_off; #ifdef VSDB_BW_ALLOCATE_ENABLE int mchan_algo; int mchan_bw; #endif WLDEV_ERROR(("mode: %d\n", mode)); if (mode == 0) { ampdu_mpdu = -1; #if defined(ROAM_ENABLE) roam_off = 0; #elif defined(DISABLE_BUILTIN_ROAM) roam_off = 1; #endif #ifdef VSDB_BW_ALLOCATE_ENABLE mchan_algo = 0; mchan_bw = 50; #endif } else if (mode == 1) { ampdu_mpdu = 8; #if defined(ROAM_ENABLE) || defined(DISABLE_BUILTIN_ROAM) roam_off = 1; #endif #ifdef VSDB_BW_ALLOCATE_ENABLE mchan_algo = 1; mchan_bw = 35; #endif } else if (mode == 2) { ampdu_mpdu = -1; #if defined(ROAM_ENABLE) || defined(DISABLE_BUILTIN_ROAM) roam_off = 1; #endif #ifdef VSDB_BW_ALLOCATE_ENABLE mchan_algo = 0; mchan_bw = 50; #endif } else { WLDEV_ERROR(("Unknown mode: %d\n", mode)); return -1; } error = wldev_iovar_setint(dev, "ampdu_mpdu", ampdu_mpdu); if (error) { WLDEV_ERROR(("Failed to set ampdu_mpdu: mode:%d, error:%d\n", mode, error)); return -1; } #if defined(ROAM_ENABLE) || defined(DISABLE_BUILTIN_ROAM) error = wldev_iovar_setint(dev, "roam_off", roam_off); if (error) { WLDEV_ERROR(("Failed to set roam_off: mode:%d, error:%d\n", mode, error)); return -1; } #endif #ifdef VSDB_BW_ALLOCATE_ENABLE error = wldev_iovar_setint(dev, "mchan_algo", mchan_algo); if (error) { WLDEV_ERROR(("Failed to set mchan_algo: mode:%d, error:%d\n", mode, error)); return -1; } error = wldev_iovar_setint(dev, "mchan_bw", mchan_bw); if (error) { WLDEV_ERROR(("Failed to set mchan_bw: mode:%d, error:%d\n", mode, error)); return -1; } #endif return error; }