int dhd_pno_clean(dhd_pub_t *dhd) { char iovbuf[128]; int pfn_enabled = 0; int iov_len = 0; int ret; /* Disable pfn */ iov_len = bcm_mkiovar("pfn", (char *)&pfn_enabled, 4, iovbuf, sizeof(iovbuf)); ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); if (ret >= 0) { /* clear pfn */ iov_len = bcm_mkiovar("pfnclear", 0, 0, iovbuf, sizeof(iovbuf)); if (iov_len) { ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, iov_len); if (ret < 0) { DHD_ERROR(("%s failed code %d\n", __func__, ret)); } } else { ret = -1; DHD_ERROR(("%s failed code %d\n", __func__, iov_len)); } } else DHD_ERROR(("%s failed code %d\n", __func__, ret)); return ret; }
int dhd_deepsleep(struct net_device *dev, int flag) { char iovbuf[20]; uint powervar = 0; dhd_pub_t *dhdp = dhd_get_pub(dev); int cnt = 0; int ret = 0; switch (flag) { case 1 : /* Deepsleep on */ DHD_ERROR(("[WiFi] Deepsleep On\n")); /* Disable MPC */ powervar = 0; bcm_mkiovar("mpc", (char *)&powervar, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhdp, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* Enable Deepsleep*/ powervar = 1; bcm_mkiovar("deepsleep", (char *)&powervar, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhdp, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); break; case 0: /* Deepsleep Off */ DHD_ERROR(("[WiFi] Deepsleep Off\n")); /* Disable Deepsleep */ for( cnt = 0 ; cnt < MAX_TRY_CNT ; cnt++ ) { powervar = 0; bcm_mkiovar("deepsleep", (char *)&powervar, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhdp, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); memset(iovbuf,0,sizeof(iovbuf)); strcpy(iovbuf, "deepsleep"); if ((ret = dhdcdc_query_ioctl(dhdp, 0, WLC_GET_VAR, iovbuf, sizeof(iovbuf))) < 0 ) { DHD_ERROR(("the error of dhd deepsleep status ret value : %d\n",ret)); }else { if(!(*(int *)iovbuf )) { DHD_ERROR(("deepsleep mode is 0, ok , count : %d\n",cnt)); break; } } } /* Enable MPC */ powervar = 1; memset(iovbuf,0,sizeof(iovbuf)); bcm_mkiovar("mpc", (char *)&powervar, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhdp, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); break; } return 0; }
int dhd_pno_enable(dhd_pub_t *dhd, int pfn_enabled) { char iovbuf[128]; int ret = -1; if ((!dhd) && ((pfn_enabled != 0) || (pfn_enabled != 1))) { DHD_ERROR(("%s error exit\n", __func__)); return ret; } /* Enable/disable PNO */ ret = bcm_mkiovar("pfn", (char *)&pfn_enabled, 4, iovbuf, sizeof(iovbuf)); if (ret > 0) { ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); if (ret < 0) { DHD_ERROR(("%s failed for error=%d\n", __func__, ret)); return ret; } else { dhd->pno_enable = pfn_enabled; DHD_TRACE(("%s set pno as %d\n", __func__, dhd->pno_enable)); } } else DHD_ERROR(("%s failed err=%d\n", __func__, ret)); return ret; }
void dhd_arp_cleanup(dhd_pub_t *dhd) { #ifdef ARP_OFFLOAD_SUPPORT int ret = 0; int iov_len = 0; char iovbuf[128]; if (dhd == NULL) return; dhd_os_proto_block(dhd); iov_len = bcm_mkiovar("arp_hostip_clear", 0, 0, iovbuf, sizeof(iovbuf)); if ((ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, iov_len)) < 0) DHD_ERROR(("%s failed code %d\n", __FUNCTION__, ret)); iov_len = bcm_mkiovar("arp_table_clear", 0, 0, iovbuf, sizeof(iovbuf)); if ((ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, iov_len)) < 0) DHD_ERROR(("%s failed code %d\n", __FUNCTION__, ret)); dhd_os_proto_unblock(dhd); #endif /* ARP_OFFLOAD_SUPPORT */ }
void dhd_arp_offload_enable(dhd_pub_t *dhd, int arp_enable) { char iovbuf[32]; int retcode; bcm_mkiovar("arpoe", (char *)&arp_enable, 4, iovbuf, sizeof(iovbuf)); retcode = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); retcode = retcode >= 0 ? 0 : retcode; if (retcode) DHD_TRACE(("%s: failed to enabe ARP offload to %d, " "retcode = %d\n", __func__, arp_enable, retcode)); else DHD_TRACE(("%s: successfully enabed ARP offload to %d\n", __func__, arp_enable)); }
void dhd_arp_offload_set(dhd_pub_t *dhd, int arp_mode) { char iovbuf[32]; int retcode; bcm_mkiovar("arp_ol", (char *)&arp_mode, 4, iovbuf, sizeof(iovbuf)); retcode = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); retcode = retcode >= 0 ? 0 : retcode; if (retcode) DHD_TRACE(("%s: failed to set ARP offload mode to 0x%x, " "retcode = %d\n", __func__, arp_mode, retcode)); else DHD_TRACE(("%s: successfully set ARP offload mode to 0x%x\n", __func__, arp_mode)); }
void dhd_arp_offload_add_ip(dhd_pub_t *dhd, u32 ipaddr) { #ifdef ARP_OFFLOAD_SUPPORT int iov_len = 0; char iovbuf[32]; int retcode; dhd_os_proto_block(dhd); iov_len = bcm_mkiovar("arp_hostip", (char *)&ipaddr, 4, iovbuf, sizeof(iovbuf)); retcode = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, iov_len); dhd_os_proto_unblock(dhd); if (retcode) DHD_TRACE(("%s: ARP ip addr add failed, retcode = %d\n", __FUNCTION__, retcode)); else DHD_TRACE(("%s: ARP ipaddr entry added\n", __FUNCTION__)); #endif /* ARP_OFFLOAD_SUPPORT */ }
void sec_dhd_config_pm(dhd_pub_t *dhd, uint power_mode) { struct file *fp = NULL; char* filepath = "/data/.psm.info"; char iovbuf[WL_EVENTING_MASK_LEN + 12]; /* Set PowerSave mode */ fp = filp_open(filepath, O_RDONLY, 0); if(IS_ERR(fp))// the file is not exist { /* Set PowerSave mode */ dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode, sizeof(power_mode)); fp = filp_open(filepath, O_RDWR | O_CREAT, 0666); if(IS_ERR(fp)||(fp==NULL)) { DHD_ERROR(("[WIFI] %s: File open error\n", filepath)); } else { char buffer[2] = {1}; if(fp->f_mode & FMODE_WRITE) { sprintf(buffer,"1\n"); fp->f_op->write(fp, (const char *)buffer, sizeof(buffer), &fp->f_pos); } } } else { char buffer[1] = {0}; kernel_read(fp, fp->f_pos, buffer, 1); if(strncmp(buffer, "1",1)==0) { /* Set PowerSave mode */ dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode, sizeof(power_mode)); } else { /*Disable Power save features for CERTIFICATION*/ power_mode = 0; /* Set PowerSave mode */ dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode, sizeof(power_mode)); /* Disable MPC */ bcm_mkiovar("mpc", (char *)&power_mode, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); //original end fp = filp_open(filepath, O_RDWR | O_CREAT, 0666); if(IS_ERR(fp)||(fp==NULL)) { DHD_ERROR(("[WIFI] %s: File open error\n", filepath)); } else { char buffer[2] = {1}; if(fp->f_mode & FMODE_WRITE) { sprintf(buffer,"1\n"); fp->f_op->write(fp, (const char *)buffer, sizeof(buffer), &fp->f_pos); } } } } if(fp) filp_close(fp, NULL); }
int dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t * ioc, void * buf, int len) { dhd_prot_t *prot = dhd->prot; int ret = -1; if (dhd->busstate == DHD_BUS_DOWN) { DHD_ERROR(("%s : bus is down. we have nothing to do\n", __FUNCTION__)); return ret; } dhd_os_proto_block(dhd); DHD_TRACE(("%s: Enter\n", __FUNCTION__)); ASSERT(len <= WLC_IOCTL_MAXLEN); if (len > WLC_IOCTL_MAXLEN) goto done; if (prot->pending == TRUE) { DHD_TRACE(("CDC packet is pending!!!! cmd=0x%x (%lu) lastcmd=0x%x (%lu)\n", ioc->cmd, (unsigned long)ioc->cmd, prot->lastcmd, (unsigned long)prot->lastcmd)); if ((ioc->cmd == WLC_SET_VAR) || (ioc->cmd == WLC_GET_VAR)) { DHD_TRACE(("iovar cmd=%s\n", (char*)buf)); } goto done; } prot->pending = TRUE; prot->lastcmd = ioc->cmd; if (ioc->set) ret = dhdcdc_set_ioctl(dhd, ifidx, ioc->cmd, buf, len); else { ret = dhdcdc_query_ioctl(dhd, ifidx, ioc->cmd, buf, len); if (ret > 0) ioc->used = ret - sizeof(cdc_ioctl_t); } /* Too many programs assume ioctl() returns 0 on success */ if (ret >= 0) ret = 0; else { cdc_ioctl_t *msg = &prot->msg; ioc->needed = ltoh32(msg->len); /* len == needed when set/query fails from dongle */ } /* Intercept the wme_dp ioctl here */ if ((!ret) && (ioc->cmd == WLC_SET_VAR) && (!strcmp(buf, "wme_dp"))) { int slen, val = 0; slen = strlen("wme_dp") + 1; if (len >= (int)(slen + sizeof(int))) bcopy(((char *)buf + slen), &val, sizeof(int)); dhd->wme_dp = (uint8) ltoh32(val); } prot->pending = FALSE; done: dhd_os_proto_unblock(dhd); return ret; }
void dhd_pktfilter_offload_enable(dhd_pub_t * dhd, char *arg, int enable, int master_mode) { char *argv[8]; int i = 0; const char *str; int buf_len; int str_len; char *arg_save = 0, *arg_org = 0; int rc; char buf[128]; wl_pkt_filter_enable_t enable_parm; wl_pkt_filter_enable_t * pkt_filterp; if (!(arg_save = MALLOC(dhd->osh, strlen(arg) + 1))) { DHD_ERROR(("%s: kmalloc failed\n", __FUNCTION__)); goto fail; } arg_org = arg_save; memcpy(arg_save, arg, strlen(arg) + 1); argv[i] = bcmstrtok(&arg_save, " ", 0); i = 0; if (NULL == argv[i]) { DHD_ERROR(("No args provided\n")); goto fail; } str = "pkt_filter_enable"; str_len = strlen(str); strncpy(buf, str, str_len); buf[str_len] = '\0'; buf_len = str_len + 1; pkt_filterp = (wl_pkt_filter_enable_t *)(buf + str_len + 1); /* Parse packet filter id. */ enable_parm.id = htod32(strtoul(argv[i], NULL, 0)); /* Parse enable/disable value. */ enable_parm.enable = htod32(enable); buf_len += sizeof(enable_parm); memcpy((char *)pkt_filterp, &enable_parm, sizeof(enable_parm)); /* Enable/disable the specified filter. */ rc = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, buf_len); rc = rc >= 0 ? 0 : rc; if (rc) DHD_TRACE(("%s: failed to add pktfilter %s, retcode = %d\n", __FUNCTION__, arg, rc)); else DHD_TRACE(("%s: successfully added pktfilter %s\n", __FUNCTION__, arg)); /* Contorl the master mode */ bcm_mkiovar("pkt_filter_mode", (char *)&master_mode, 4, buf, sizeof(buf)); rc = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, sizeof(buf)); rc = rc >= 0 ? 0 : rc; if (rc) DHD_TRACE(("%s: failed to add pktfilter %s, retcode = %d\n", __FUNCTION__, arg, rc)); fail: if (arg_org) MFREE(dhd->osh, arg_org, strlen(arg) + 1); }
/* Keep-alive attributes are set in local variable (keep_alive_pkt), and ** then memcpy'ed into buffer (keep_alive_pktp) since there is no ** guarantee that the buffer is properly aligned. */ memcpy((char *)pkt_filterp, &pkt_filter, WL_PKT_FILTER_FIXED_LEN + WL_PKT_FILTER_PATTERN_FIXED_LEN); rc = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, buf_len); rc = rc >= 0 ? 0 : rc; if (rc) DHD_TRACE(("%s: failed to add pktfilter %s, retcode = %d\n", __FUNCTION__, arg, rc)); else DHD_TRACE(("%s: successfully added pktfilter %s\n", __FUNCTION__, arg)); fail: if (arg_org) MFREE(dhd->osh, arg_org, strlen(arg) + 1); if (buf) MFREE(dhd->osh, buf, BUF_SIZE); } void dhd_arp_offload_set(dhd_pub_t * dhd, int arp_mode) { char iovbuf[32]; int retcode; bcm_mkiovar("arp_ol", (char *)&arp_mode, 4, iovbuf, sizeof(iovbuf)); retcode = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); retcode = retcode >= 0 ? 0 : retcode; if (retcode) DHD_TRACE(("%s: failed to set ARP offload mode to 0x%x, retcode = %d\n", __FUNCTION__, arp_mode, retcode)); else DHD_TRACE(("%s: successfully set ARP offload mode to 0x%x\n", __FUNCTION__, arp_mode)); } void dhd_arp_offload_enable(dhd_pub_t * dhd, int arp_enable) { char iovbuf[32]; int retcode; bcm_mkiovar("arpoe", (char *)&arp_enable, 4, iovbuf, sizeof(iovbuf)); retcode = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); retcode = retcode >= 0 ? 0 : retcode; if (retcode) DHD_TRACE(("%s: failed to enabe ARP offload to %d, retcode = %d\n", __FUNCTION__, arp_enable, retcode)); else DHD_TRACE(("%s: successfully enabed ARP offload to %d\n", __FUNCTION__, arp_enable)); } #if defined(CONFIG_TARGET_LOCALE_KOR) uint g_pm = PM_OFF; #endif /* CONFIG_TARGET_LOCALE_KOR */ int dhd_preinit_ioctls(dhd_pub_t *dhd) { char iovbuf[WL_EVENTING_MASK_LEN + 12]; /* Room for "event_msgs" + '\0' + bitvec */ uint up = 0; char buf[128], *ptr; uint power_mode = PM_FAST; uint32 dongle_align = DHD_SDALIGN; uint32 glom = 0; uint bcn_timeout = 3; int scan_assoc_time = 40; int scan_unassoc_time = 80; #ifdef CONFIG_TARGET_LOCALE_KOR struct file *fp = NULL; char* filepath = "/data/.psm.info"; char* lcdfilepath = "/data/.lcdmode.info"; #endif /* CONFIG_TARGET_LOCALE_KOR */ #ifdef SCAN_5G_HOMECHANNEL_TIME int scan_home_time = 60; #endif #ifdef FCC_CERT uint spect = 0; #endif #ifdef SOFTAP if(!ap_fw_loaded) { #endif /* SOFTAP */ /* Set Country code */ if (dhd->country_code[0] != 0) { if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_COUNTRY, dhd->country_code, sizeof(dhd->country_code)) < 0) { DHD_ERROR(("%s: country code setting failed\n", __FUNCTION__)); } } #ifdef SOFTAP } #endif /* SOFTAP */ /* query for 'ver' to get version info from firmware */ memset(buf, 0, sizeof(buf)); ptr = buf; bcm_mkiovar("ver", 0, 0, buf, sizeof(buf)); dhdcdc_query_ioctl(dhd, 0, WLC_GET_VAR, buf, sizeof(buf)); bcmstrtok(&ptr, "\n", 0); /* Print fw version info */ DHD_ERROR(("Firmware version = %s\n", buf)); #ifdef BCMDISABLE_PM /*Disable Power save features for CERTIFICATION*/ power_mode = PM_OFF; /* Set PowerSave mode */ dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode, sizeof(power_mode)); #ifdef CONFIG_TARGET_LOCALE_KOR DHD_TRACE(("[BCM4329] Power Save Mode disabled\n")); #endif /* CONFIG_TARGET_LOCALE_KOR */ /* Disable MPC */ bcm_mkiovar("mpc", (char *)&power_mode, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); #else /* BCMDISABLE_PM */ #ifdef CONFIG_TARGET_LOCALE_KOR /* Set PowerSave mode */ fp = filp_open(filepath, O_RDONLY, 0); if(IS_ERR(fp))// the file is not exist { DHD_ERROR(("[BCM4329] /data/.psm.info not found\n")); /* Enable Power save features for CERTIFICATION*/ power_mode = PM_MAX; g_pm = PM_MAX; /* Set PowerSave mode */ dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode, sizeof(power_mode)); DHD_ERROR(("[BCM4329] PM Enabled\n")); fp = filp_open(filepath, O_RDWR | O_CREAT, 0666); if(IS_ERR(fp)||(fp==NULL)) { DHD_TRACE(("[WIFI] %s: File open error\n", filepath)); } else { char buffer[2] = {0}; if(fp->f_mode & FMODE_WRITE) { sprintf(buffer,"1\n"); fp->f_op->write(fp, (const char *)buffer, sizeof(buffer), &fp->f_pos); DHD_TRACE(("[BCM4329] Write /data/.psm.info -> 1\n")); } } } else { char buffer; DHD_TRACE(("[BCM4329] /data/.psm.info found!!\n")); kernel_read(fp, fp->f_pos, &buffer, 1); if(buffer==0x31) { /* Set PowerSave mode */ power_mode = PM_MAX; g_pm = PM_MAX; dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode, sizeof(power_mode)); DHD_TRACE(("[BCM4329] PM enabled\n")); } else { /*Disable Power save features for WAPI CERTIFICATION*/ power_mode = PM_OFF; g_pm = PM_OFF; /* Set PowerSave mode */ dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode, sizeof(power_mode)); DHD_TRACE(("[BCM4329] PM disabled\n")); /* Disable MPC */ bcm_mkiovar("mpc", (char *)&power_mode, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); } } if(fp) { filp_close(fp, NULL); } /* Set LCD mode */ fp = filp_open(lcdfilepath, O_RDONLY, 0); if(IS_ERR(fp))// the file is not exist { DHD_TRACE(("[BCM4329] /data/.lcdmode.info not found\n")); fp = filp_open(lcdfilepath, O_RDWR | O_CREAT, 0666); if(IS_ERR(fp)||(fp==NULL)) { DHD_TRACE(("[WIFI] %s: LCD mode file open error\n", filepath)); } else { char buffer[2] = {0}; if(fp->f_mode & FMODE_WRITE) { sprintf(buffer,"0\n"); fp->f_op->write(fp, (const char *)buffer, sizeof(buffer), &fp->f_pos); DHD_TRACE(("[BCM4329] Write /data/.lcdmode.info -> 0\n")); } } if(fp) { filp_close(fp, NULL); } } #else /* CONFIG_TARGET_LOCALE_KOR */ /* Set PowerSave mode */ power_mode = PM_MAX; #if defined(CONFIG_TARGET_LOCALE_KOR) g_pm = PM_MAX; #endif /* CONFIG_TARGET_LOCALE_KOR */ dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode, sizeof(power_mode)); #endif /* CONFIG_TARGET_LOCALE_KOR */ #endif //BCMDISABLE_PM #ifdef SOFTAP if(!ap_fw_loaded) { #endif /* SOFTAP */ #ifdef FCC_CERT dhdcdc_set_ioctl(dhd, 0, WLC_DOWN, (char *)&up, sizeof(up)); /* Disable TPC to get qualification of FCC */ dhdcdc_set_ioctl(dhd, 0, WLC_SET_SPECT_MANAGMENT, (char *)&spect, sizeof(spect)); #endif /* FCC_CERT */ #ifdef SOFTAP } #endif /* SOFTAP */ /* Match Host and Dongle rx alignment */ bcm_mkiovar("bus:txglomalign", (char *)&dongle_align, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* disable glom option per default */ bcm_mkiovar("bus:txglom", (char *)&glom, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* Setup timeout if Beacons are lost and roam is off to report link down */ bcm_mkiovar("bcn_timeout", (char *)&bcn_timeout, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* Enable/Disable build-in roaming to allowed ext supplicant to take of romaing */ bcm_mkiovar("roam_off", (char *)&dhd_roam, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* Force STA UP */ if (dhd_radio_up) dhdcdc_set_ioctl(dhd, 0, WLC_UP, (char *)&up, sizeof(up)); /* Setup event_msgs */ bcm_mkiovar("event_msgs", dhd->eventmask, WL_EVENTING_MASK_LEN, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_SCAN_CHANNEL_TIME, (char *)&scan_assoc_time, sizeof(scan_assoc_time)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_SCAN_UNASSOC_TIME, (char *)&scan_unassoc_time, sizeof(scan_unassoc_time)); #ifdef SCAN_5G_HOMECHANNEL_TIME DHD_INFO(("Scan Channel Home Time Set : 80 ms \r\n")); dhdcdc_set_ioctl(dhd, 0, WLC_SET_SCAN_HOME_TIME, (char *)&scan_home_time, sizeof(scan_home_time)); #endif #ifdef ARP_OFFLOAD_SUPPORT /* Set and enable ARP offload feature */ if (dhd_arp_enable) dhd_arp_offload_set(dhd, dhd_arp_mode); dhd_arp_offload_enable(dhd, dhd_arp_enable); #endif /* ARP_OFFLOAD_SUPPORT */ #ifdef PKT_FILTER_SUPPORT { int i; /* Set up pkt filter */ if (dhd_pkt_filter_enable) { for (i = 0; i < dhd->pktfilter_count; i++) { dhd_pktfilter_offload_set(dhd, dhd->pktfilter[i]); dhd_pktfilter_offload_enable(dhd, dhd->pktfilter[i], 0, dhd_master_mode); } } } #endif /* PKT_FILTER_SUPPORT */ return 0; }
void dhd_pktfilter_offload_set(dhd_pub_t * dhd, char *arg) { const char *str; wl_pkt_filter_t pkt_filter; wl_pkt_filter_t *pkt_filterp; int buf_len; int str_len; int rc; uint32 mask_size; uint32 pattern_size; char *argv[8], * buf = 0; int i = 0; char *arg_save = 0, *arg_org = 0; #define BUF_SIZE 2048 if (!(arg_save = MALLOC(dhd->osh, strlen(arg) + 1))) { DHD_ERROR(("%s: kmalloc failed\n", __FUNCTION__)); goto fail; } arg_org = arg_save; if (!(buf = MALLOC(dhd->osh, BUF_SIZE))) { DHD_ERROR(("%s: kmalloc failed\n", __FUNCTION__)); goto fail; } memcpy(arg_save, arg, strlen(arg) + 1); if (strlen(arg) > BUF_SIZE) { DHD_ERROR(("Not enough buffer %d < %d\n", (int)strlen(arg), (int)sizeof(buf))); goto fail; } argv[i] = bcmstrtok(&arg_save, " ", 0); while (argv[i++]) argv[i] = bcmstrtok(&arg_save, " ", 0); i = 0; if (NULL == argv[i]) { DHD_ERROR(("No args provided\n")); goto fail; } str = "pkt_filter_add"; str_len = strlen(str); strncpy(buf, str, str_len); buf[ str_len ] = '\0'; buf_len = str_len + 1; pkt_filterp = (wl_pkt_filter_t *) (buf + str_len + 1); /* Parse packet filter id. */ pkt_filter.id = htod32(strtoul(argv[i], NULL, 0)); if (NULL == argv[++i]) { DHD_ERROR(("Polarity not provided\n")); goto fail; } /* Parse filter polarity. */ pkt_filter.negate_match = htod32(strtoul(argv[i], NULL, 0)); if (NULL == argv[++i]) { DHD_ERROR(("Filter type not provided\n")); goto fail; } /* Parse filter type. */ pkt_filter.type = htod32(strtoul(argv[i], NULL, 0)); if (NULL == argv[++i]) { DHD_ERROR(("Offset not provided\n")); goto fail; } /* Parse pattern filter offset. */ pkt_filter.u.pattern.offset = htod32(strtoul(argv[i], NULL, 0)); if (NULL == argv[++i]) { DHD_ERROR(("Bitmask not provided\n")); goto fail; } /* Parse pattern filter mask. */ mask_size = htod32(wl_pattern_atoh(argv[i], (char *) pkt_filterp->u.pattern.mask_and_pattern)); if (NULL == argv[++i]) { DHD_ERROR(("Pattern not provided\n")); goto fail; } /* Parse pattern filter pattern. */ pattern_size = htod32(wl_pattern_atoh(argv[i], (char *) &pkt_filterp->u.pattern.mask_and_pattern[mask_size])); if (mask_size != pattern_size) { DHD_ERROR(("Mask and pattern not the same size\n")); goto fail; } pkt_filter.u.pattern.size_bytes = mask_size; buf_len += WL_PKT_FILTER_FIXED_LEN; buf_len += (WL_PKT_FILTER_PATTERN_FIXED_LEN + 2 * mask_size); /* Keep-alive attributes are set in local variable (keep_alive_pkt), and ** then memcpy'ed into buffer (keep_alive_pktp) since there is no ** guarantee that the buffer is properly aligned. */ memcpy((char *)pkt_filterp, &pkt_filter, WL_PKT_FILTER_FIXED_LEN + WL_PKT_FILTER_PATTERN_FIXED_LEN); rc = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, buf_len); rc = rc >= 0 ? 0 : rc; if (rc) DHD_TRACE(("%s: failed to add pktfilter %s, retcode = %d\n", __FUNCTION__, arg, rc)); else DHD_TRACE(("%s: successfully added pktfilter %s\n", __FUNCTION__, arg)); fail: if (arg_org) MFREE(dhd->osh, arg_org, strlen(arg) + 1); if (buf) MFREE(dhd->osh, buf, BUF_SIZE); }
/* Function to execute combined scan */ int dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t *ssids_local, int nssid, unsigned char scan_fr) { int err = -1; char iovbuf[128]; int k, i; wl_pfn_param_t pfn_param; wl_pfn_t pfn_element; DHD_TRACE(("%s nssid=%d nchan=%d\n", __func__, nssid, scan_fr)); if ((!dhd) && (!ssids_local)) { DHD_ERROR(("%s error exit\n", __func__)); err = -1; } /* Check for broadcast ssid */ for (k = 0; k < nssid; k++) { if (!ssids_local[k].SSID_len) { DHD_ERROR(("%d: Broadcast SSID is ilegal for PNO " "setting\n", k)); return err; } } /* #define PNO_DUMP 1 */ #ifdef PNO_DUMP { int j; for (j = 0; j < nssid; j++) { DHD_ERROR(("%d: scan for %s size =%d\n", j, ssids_local[j].SSID, ssids_local[j].SSID_len)); } } #endif /* PNO_DUMP */ /* clean up everything */ err = dhd_pno_clean(dhd); if (err < 0) { DHD_ERROR(("%s failed error=%d\n", __func__, err)); return err; } memset(&pfn_param, 0, sizeof(pfn_param)); memset(&pfn_element, 0, sizeof(pfn_element)); /* set pfn parameters */ pfn_param.version = PFN_VERSION; pfn_param.flags = (PFN_LIST_ORDER << SORT_CRITERIA_BIT); /* set up pno scan fr */ if (scan_fr != 0) pfn_param.scan_freq = scan_fr; bcm_mkiovar("pfn_set", (char *)&pfn_param, sizeof(pfn_param), iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* set all pfn ssid */ for (i = 0; i < nssid; i++) { pfn_element.bss_type = DOT11_BSSTYPE_INFRASTRUCTURE; pfn_element.auth = WLAN_AUTH_OPEN; pfn_element.wpa_auth = WPA_AUTH_PFN_ANY; pfn_element.wsec = 0; pfn_element.infra = 1; memcpy((char *)pfn_element.ssid.SSID, ssids_local[i].SSID, ssids_local[i].SSID_len); pfn_element.ssid.SSID_len = ssids_local[i].SSID_len; err = bcm_mkiovar("pfn_add", (char *)&pfn_element, sizeof(pfn_element), iovbuf, sizeof(iovbuf)); if (err > 0) { err = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); if (err < 0) { DHD_ERROR(("%s failed for i=%d error=%d\n", __func__, i, err)); return err; } } else DHD_ERROR(("%s failed err=%d\n", __func__, err)); } /* Enable PNO */ /* dhd_pno_enable(dhd, 1); */ return err; }
int dhd_preinit_ioctls(dhd_pub_t *dhd) { char iovbuf[WL_EVENTING_MASK_LEN + 12]; /* Room for "event_msgs" + '\0' + bitvec */ uint up = 0; char buf[128], *ptr; uint power_mode = PM_FAST; u32 dongle_align = DHD_SDALIGN; u32 glom = 0; uint bcn_timeout = 3; int scan_assoc_time = 40; int scan_unassoc_time = 40; #ifdef GET_CUSTOM_MAC_ENABLE int ret = 0; u8 ea_addr[ETH_ALEN]; #endif /* GET_CUSTOM_MAC_ENABLE */ dhd_os_proto_block(dhd); #ifdef GET_CUSTOM_MAC_ENABLE /* Read MAC address from external customer place ** NOTE that default mac address has to be present in ** otp or nvram file to bring up ** firmware but unique per board mac address maybe provided by ** customer code */ ret = dhd_custom_get_mac_address(ea_addr); if (!ret) { bcm_mkiovar("cur_etheraddr", (void *)ea_addr, ETH_ALEN, buf, sizeof(buf)); ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, sizeof(buf)); if (ret < 0) { DHD_ERROR(("%s: can't set MAC address , error=%d\n", __func__, ret)); } else memcpy(dhd->mac.octet, (void *)&ea_addr, ETH_ALEN); } #endif /* GET_CUSTOM_MAC_ENABLE */ /* Set Country code */ if (dhd->country_code[0] != 0) { if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_COUNTRY, dhd->country_code, sizeof(dhd->country_code)) < 0) { DHD_ERROR(("%s: country code setting failed\n", __func__)); } } /* query for 'ver' to get version info from firmware */ memset(buf, 0, sizeof(buf)); ptr = buf; bcm_mkiovar("ver", 0, 0, buf, sizeof(buf)); dhdcdc_query_ioctl(dhd, 0, WLC_GET_VAR, buf, sizeof(buf)); strsep(&ptr, "\n"); /* Print fw version info */ DHD_ERROR(("Firmware version = %s\n", buf)); /* Set PowerSave mode */ dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode, sizeof(power_mode)); /* Match Host and Dongle rx alignment */ bcm_mkiovar("bus:txglomalign", (char *)&dongle_align, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* disable glom option per default */ bcm_mkiovar("bus:txglom", (char *)&glom, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* Setup timeout if Beacons are lost and roam is off to report link down */ bcm_mkiovar("bcn_timeout", (char *)&bcn_timeout, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* Enable/Disable build-in roaming to allowed ext supplicant to take of romaing */ bcm_mkiovar("roam_off", (char *)&dhd_roam, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* Force STA UP */ if (dhd_radio_up) dhdcdc_set_ioctl(dhd, 0, WLC_UP, (char *)&up, sizeof(up)); /* Setup event_msgs */ bcm_mkiovar("event_msgs", dhd->eventmask, WL_EVENTING_MASK_LEN, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_SCAN_CHANNEL_TIME, (char *)&scan_assoc_time, sizeof(scan_assoc_time)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_SCAN_UNASSOC_TIME, (char *)&scan_unassoc_time, sizeof(scan_unassoc_time)); #ifdef ARP_OFFLOAD_SUPPORT /* Set and enable ARP offload feature */ if (dhd_arp_enable) dhd_arp_offload_set(dhd, dhd_arp_mode); dhd_arp_offload_enable(dhd, dhd_arp_enable); #endif /* ARP_OFFLOAD_SUPPORT */ #ifdef PKT_FILTER_SUPPORT { int i; /* Set up pkt filter */ if (dhd_pkt_filter_enable) { for (i = 0; i < dhd->pktfilter_count; i++) { dhd_pktfilter_offload_set(dhd, dhd->pktfilter[i]); dhd_pktfilter_offload_enable(dhd, dhd->pktfilter[i], dhd_pkt_filter_init, dhd_master_mode); } } } #endif /* PKT_FILTER_SUPPORT */ dhd_os_proto_unblock(dhd); return 0; }
int dhd_preinit_ioctls(dhd_pub_t *dhd) { char iovbuf[WL_EVENTING_MASK_LEN + 12]; /* Room for "event_msgs" + '\0' + bitvec */ uint up = 0; char buf[128], *ptr; uint power_mode = PM_FAST; uint32 dongle_align = DHD_SDALIGN; uint32 glom = 0; uint bcn_timeout = 3; int scan_assoc_time = 40; int scan_unassoc_time = 80; int roam_delta[2]; int roam_scan_period = 2; #ifdef SCAN_5G_HOMECHANNEL_TIME int scan_home_time = 60; #endif #ifdef FCC_CERT uint spect = 0; #endif struct file *fp = NULL; char* filepath = "/data/.psm.info"; int qosinfo = 1; /* enable VO AC */ #ifdef SOFTAP if(!ap_fw_loaded) { #endif /* SOFTAP */ /* Set Country code */ if (dhd->country_code[0] != 0) { if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_COUNTRY, dhd->country_code, sizeof(dhd->country_code)) < 0) { DHD_ERROR(("%s: country code setting failed\n", __FUNCTION__)); } } #ifdef SOFTAP } #endif /* SOFTAP */ /* query for 'ver' to get version info from firmware */ memset(buf, 0, sizeof(buf)); ptr = buf; bcm_mkiovar("ver", 0, 0, buf, sizeof(buf)); dhdcdc_query_ioctl(dhd, 0, WLC_GET_VAR, buf, sizeof(buf)); bcmstrtok(&ptr, "\n", 0); /* Print fw version info */ DHD_ERROR(("Firmware version = %s\n", buf)); ///////////////////////// /* Set PowerSave mode */ fp = filp_open(filepath, O_RDONLY, 0); if(IS_ERR(fp))// the file is not exist { /* Set PowerSave mode */ dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode, sizeof(power_mode)); fp = filp_open(filepath, O_RDWR | O_CREAT, 0666); if(IS_ERR(fp)||(fp==NULL)) { DHD_ERROR(("[WIFI] %s: File open error\n", filepath)); } else { char buffer[2] = {1}; if(fp->f_mode & FMODE_WRITE) { sprintf(buffer,"1\n"); fp->f_op->write(fp, (const char *)buffer, sizeof(buffer), &fp->f_pos); } } } else { char buffer[1] = {0}; kernel_read(fp, fp->f_pos, buffer, 1); if(strncmp(buffer, "1",1)==0) { /* Set PowerSave mode */ dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode, sizeof(power_mode)); } else { /*Disable Power save features for CERTIFICATION*/ power_mode = 0; /* Set PowerSave mode */ dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode, sizeof(power_mode)); /* Disable MPC */ bcm_mkiovar("mpc", (char *)&power_mode, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); fp = filp_open(filepath, O_RDWR | O_CREAT, 0666); if(IS_ERR(fp)||(fp==NULL)) { DHD_ERROR(("[WIFI] %s: File open error\n", filepath)); } else { char buffer[2] = {1}; if(fp->f_mode & FMODE_WRITE) { sprintf(buffer,"1\n"); fp->f_op->write(fp, (const char *)buffer, sizeof(buffer), &fp->f_pos); } } } } if(fp) filp_close(fp, NULL); #ifdef SOFTAP if(!ap_fw_loaded) { #endif /* SOFTAP */ #ifdef FCC_CERT dhdcdc_set_ioctl(dhd, 0, WLC_DOWN, (char *)&up, sizeof(up)); /* Disable TPC to get qualification of FCC */ dhdcdc_set_ioctl(dhd, 0, WLC_SET_SPECT_MANAGMENT, (char *)&spect, sizeof(spect)); #endif /* FCC_CERT */ #ifdef SOFTAP } #endif /* SOFTAP */ /* Match Host and Dongle rx alignment */ bcm_mkiovar("bus:txglomalign", (char *)&dongle_align, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* disable glom option per default */ bcm_mkiovar("bus:txglom", (char *)&glom, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* Setup timeout if Beacons are lost and roam is off to report link down */ bcm_mkiovar("bcn_timeout", (char *)&bcn_timeout, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* Enable/Disable build-in roaming to allowed ext supplicant to take of romaing */ bcm_mkiovar("roam_off", (char *)&dhd_roam, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* Enable UAPSD for voice packet AC=VO */ bcm_mkiovar("wme_qosinfo", (char *)&qosinfo, 4, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); /* Force STA UP */ if (dhd_radio_up) dhdcdc_set_ioctl(dhd, 0, WLC_UP, (char *)&up, sizeof(up)); /* Setup event_msgs */ bcm_mkiovar("event_msgs", dhd->eventmask, WL_EVENTING_MASK_LEN, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_SCAN_CHANNEL_TIME, (char *)&scan_assoc_time, sizeof(scan_assoc_time)); dhdcdc_set_ioctl(dhd, 0, WLC_SET_SCAN_UNASSOC_TIME, (char *)&scan_unassoc_time, sizeof(scan_unassoc_time)); /* roaming delta = 10 dBm */ roam_delta[0] = 10; roam_delta[1] = WLC_BAND_AUTO; dhdcdc_set_ioctl(dhd, 0, WLC_SET_ROAM_DELTA, (char *)roam_delta, sizeof(roam_delta)); /* roaming scan period = 2 seconds */ dhdcdc_set_ioctl(dhd, 0, WLC_SET_ROAM_SCAN_PERIOD, (char *)&roam_scan_period, sizeof(roam_scan_period)); #ifdef SCAN_5G_HOMECHANNEL_TIME DHD_INFO(("Scan Channel Home Time Set : 80 ms \r\n")); dhdcdc_set_ioctl(dhd, 0, WLC_SET_SCAN_HOME_TIME, (char *)&scan_home_time, sizeof(scan_home_time)); #endif #ifdef ARP_OFFLOAD_SUPPORT /* Set and enable ARP offload feature */ if (dhd_arp_enable) dhd_arp_offload_set(dhd, dhd_arp_mode); dhd_arp_offload_enable(dhd, dhd_arp_enable); #endif /* ARP_OFFLOAD_SUPPORT */ #ifdef PKT_FILTER_SUPPORT { int i; /* Set up pkt filter */ if (dhd_pkt_filter_enable) { for (i = 0; i < dhd->pktfilter_count; i++) { dhd_pktfilter_offload_set(dhd, dhd->pktfilter[i]); dhd_pktfilter_offload_enable(dhd, dhd->pktfilter[i], 0, dhd_master_mode); } } } #endif /* PKT_FILTER_SUPPORT */ return 0; }