void wldev_del_vendr_ie(struct net_device *dev) { int buflen; char smbuf[WLC_IOCTL_SMLEN]; if (!ie_setbuf) return; /* Copy the vndr_ie SET command ("add"/"del") to the buffer */ strcpy (ie_setbuf->cmd, "del"); buflen = ie_setbuf->vndr_ie_buffer.vndr_ie_list[0].vndr_ie_data.len - VNDR_IE_MIN_LEN + sizeof(vndr_ie_setbuf_t) ; // dev_wlc_bufvar_set(dev, "vndr_ie", (char *)ie_setbuf, buflen); wldev_iovar_setbuf(dev, "vndr_ie", (char *)ie_setbuf, buflen, smbuf, sizeof(smbuf), NULL); kfree(ie_setbuf); ie_setbuf = NULL; return; }
int wl_android_set_country_rev( struct net_device *dev, char* command, int total_len) { int error = 0; wl_country_t cspec = {{0}, 0, {0} }; char country_code[WLC_CNTRY_BUF_SZ]; char smbuf[WLC_IOCTL_SMLEN]; int rev = 0; memset(country_code, 0, sizeof(country_code)); sscanf(command+sizeof("SETCOUNTRYREV"), "%10s %10d", country_code, &rev); WL_TRACE(("%s: country_code = %s, rev = %d\n", __FUNCTION__, country_code, rev)); memcpy(cspec.country_abbrev, country_code, sizeof(country_code)); memcpy(cspec.ccode, country_code, sizeof(country_code)); cspec.rev = rev; error = wldev_iovar_setbuf(dev, "country", (char *)&cspec, sizeof(cspec), smbuf, sizeof(smbuf), NULL); if (error) { DHD_ERROR(("%s: set country '%s/%d' failed code %d\n", __FUNCTION__, cspec.ccode, cspec.rev, error)); } else { dhd_bus_country_set(dev, &cspec); DHD_INFO(("%s: set country '%s/%d'\n", __FUNCTION__, cspec.ccode, cspec.rev)); } return error; }
static int wl_android_set_pmk(struct net_device *dev, char *command, int total_len) { uchar pmk[33]; int error = 0; char smbuf[WLC_IOCTL_SMLEN]; #ifdef OKC_DEBUG int i = 0; #endif bzero(pmk, sizeof(pmk)); memcpy((char *)pmk, command + strlen("SET_PMK "), 32); error = wldev_iovar_setbuf(dev, "okc_info_pmk", pmk, 32, smbuf, sizeof(smbuf), NULL); if (error) { DHD_ERROR(("Failed to set PMK for OKC, error = %d\n", error)); } #ifdef OKC_DEBUG DHD_ERROR(("PMK is ")); for (i = 0; i < 32; i++) DHD_ERROR(("%02X ", pmk[i])); DHD_ERROR(("\n")); #endif return error; }
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 set_roamscan_channel_list(struct net_device *dev, unsigned char n, unsigned char channels[], int ioctl_ver) { int i; int error; struct { int n; chanspec_t channels[20]; } channel_list; char iobuf[200]; uint band, band2G, band5G, bw; roamscan_mode = 1; if (n > 20) n = 20; #ifdef D11AC_IOTYPES if (ioctl_ver == 1) { /* legacy chanspec */ band2G = WL_LCHANSPEC_BAND_2G; band5G = WL_LCHANSPEC_BAND_5G; bw = WL_LCHANSPEC_BW_20 | WL_LCHANSPEC_CTL_SB_NONE; } else { band2G = WL_CHANSPEC_BAND_2G; band5G = WL_CHANSPEC_BAND_5G; bw = WL_CHANSPEC_BW_20; } #else band2G = WL_CHANSPEC_BAND_2G; band5G = WL_CHANSPEC_BAND_5G; bw = WL_CHANSPEC_BW_20 | WL_CHANSPEC_CTL_SB_NONE; #endif /* D11AC_IOTYPES */ for (i = 0; i < n; i++) { chanspec_t chanspec; if (channels[i] <= 14) { chanspec = band2G | bw | channels[i]; } else { chanspec = band5G | bw | channels[i]; } roam_cache[i].chanspec = chanspec; channel_list.channels[i] = chanspec; WL_DBG(("%s: channel[%d] - [%02d] \n", __FUNCTION__, i, channels[i])); } n_roam_cache = n; channel_list.n = n; error = wldev_iovar_setbuf(dev, "roamscan_channels", &channel_list, sizeof(channel_list), iobuf, sizeof(iobuf), NULL); if (error) { WL_ERROR(("Failed to set roamscan channels, error = %d\n", error)); } return error; }
s32 wldev_iovar_setint( struct net_device *dev, s8 *iovar, s32 val) { s8 iovar_buf[WLC_IOCTL_SMLEN]; val = htod32(val); memset(iovar_buf, 0, sizeof(iovar_buf)); return wldev_iovar_setbuf(dev, iovar, &val, sizeof(val), iovar_buf, sizeof(iovar_buf), NULL); }
void wldev_set_scanabort(struct net_device *dev) { s8 iovar_buf[WLC_IOCTL_SMLEN]; int ret = 0; memset(iovar_buf, 0, sizeof(iovar_buf)); ret = wldev_iovar_setbuf(dev, "scanabort", NULL, 0, iovar_buf, sizeof(iovar_buf), NULL); if (ret) printf("%s failed ret = %d\n", __func__, ret); }
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 wl_android_set_full_roam_scan_period( struct net_device *dev, char* command, int total_len) { int error = 0; int full_roam_scan_period = 0; char smbuf[WLC_IOCTL_SMLEN]; sscanf(command+sizeof("SETFULLROAMSCANPERIOD"), "%d", &full_roam_scan_period); WL_TRACE(("%s: fullroamperiod = %d\n", __func__, full_roam_scan_period)); error = wldev_iovar_setbuf(dev, "fullroamperiod", &full_roam_scan_period, sizeof(full_roam_scan_period), smbuf, sizeof(smbuf), NULL); if (error) { DHD_ERROR(("Failed to set full roam scan period, error = %d\n", error)); } return error; }
void wldev_add_vendr_ie(struct net_device *dev) { int buflen; char smbuf[WLC_IOCTL_SMLEN]; strcpy (ie_setbuf->cmd, "add"); buflen = ie_setbuf->vndr_ie_buffer.vndr_ie_list[0].vndr_ie_data.len - VNDR_IE_MIN_LEN + sizeof(vndr_ie_setbuf_t) ; // dev_wlc_bufvar_set(dev, "vndr_ie", (char *)ie_setbuf, buflen); wldev_iovar_setbuf(dev, "vndr_ie", (char *)ie_setbuf, buflen, smbuf, sizeof(smbuf), NULL); return; }
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; }
int set_roamscan_channel_list(struct net_device *dev, unsigned char n, unsigned char channels[], int ioctl_ver) { int i; int error; channel_list_t channel_list; char iobuf[WLC_IOCTL_SMLEN]; roamscan_mode = ROAMSCAN_MODE_WES; if (n > MAX_CHANNEL_LIST) n = MAX_CHANNEL_LIST; for (i = 0; i < n; i++) { chanspec_t chanspec; if (channels[i] <= CH_MAX_2G_CHANNEL) { chanspec = band2G | band_bw | channels[i]; } else { chanspec = band5G | band_bw | channels[i]; } roam_cache[i].chanspec = chanspec; channel_list.channels[i] = chanspec; WL_DBG(("channel[%d] - [%02d] \n", i, channels[i])); } n_roam_cache = n; channel_list.n = n; /* need to set ROAMSCAN_MODE_NORMAL to update roamscan_channels, * otherwise, it won't be updated */ wldev_iovar_setint(dev, "roamscan_mode", ROAMSCAN_MODE_NORMAL); error = wldev_iovar_setbuf(dev, "roamscan_channels", &channel_list, sizeof(channel_list), iobuf, sizeof(iobuf), NULL); if (error) { WL_DBG(("Failed to set roamscan channels, error = %d\n", error)); } wldev_iovar_setint(dev, "roamscan_mode", ROAMSCAN_MODE_WES); 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]; if (!country_code) return error; error = wldev_iovar_getbuf(dev, "country", &cspec, sizeof(cspec), smbuf, sizeof(smbuf), NULL); if (error < 0) AP6210_ERR("%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), true); if (error < 0) { AP6210_ERR("%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) { AP6210_ERR("%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); AP6210_ERR("%s: set country for %s as %s rev %d\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev); } return 0; }
static int wl_android_set_cckm_krk(struct net_device *dev, char *command) { int error; unsigned char key[16]; static char iovar_buf[WLC_IOCTL_MEDLEN]; WL_TRACE(("%s: wl_iw_set_cckm_krk\n", dev->name)); memset(iovar_buf, 0, sizeof(iovar_buf)); memcpy(key, command+strlen("set cckm_krk")+1, 16); error = wldev_iovar_setbuf(dev, "cckm_krk", key, sizeof(key), iovar_buf, WLC_IOCTL_MEDLEN, NULL); if (unlikely(error)) { WL_ERR((" cckm_krk set error (%d)\n", error)); return -1; } return 0; }
int wl_cfgnan_rtt_config_handler(struct net_device *ndev, struct bcm_cfg80211 *cfg, char *cmd, nan_cmd_data_t *cmd_data) { wl_nan_ranging_config_t rtt_config; s32 ret = BCME_OK; /* proceed only if mandatory argument is present - channel */ if (!cmd_data->chanspec) { WL_ERR((" mandatory argument is not present \n")); return -EINVAL; } /* * command to test * * wl: wl proxd_nancfg 44/80 128 32 ff:ff:ff:ff:ff:ff 1 * * wpa_cli: DRIVER NAN_RTT_CONFIG CHAN=44/80 */ memset(&rtt_config, 0, sizeof(wl_nan_ranging_config_t)); rtt_config.chanspec = cmd_data->chanspec; rtt_config.timeslot = 128; rtt_config.duration = 32; memcpy(&rtt_config.allow_mac, ðer_bcast, ETHER_ADDR_LEN); rtt_config.flags = 1; ret = wldev_iovar_setbuf(ndev, "proxd_nancfg", &rtt_config, sizeof(wl_nan_ranging_config_t), cfg->ioctl_buf, WLC_IOCTL_MEDLEN, NULL); if (unlikely(ret)) { WL_ERR((" nan rtt config failed, error = %d \n", ret)); } else { WL_DBG((" nan rtt config successful \n")); } return ret; }
int wl_cfgnan_transmit_handler(struct net_device *ndev, struct bcm_cfg80211 *cfg, char *cmd, nan_cmd_data_t *cmd_data) { wl_nan_ioc_t *nanioc = NULL; void *pxtlv; s32 ret = BCME_OK; u16 start, end; u16 kflags = in_atomic() ? GFP_ATOMIC : GFP_KERNEL; uint16 nanioc_size = sizeof(wl_nan_ioc_t) + NAN_IOCTL_BUF_SIZE; /* * proceed only if mandatory arguments are present - subscriber id, * publisher id, mac address */ if ((!cmd_data->sub_id) || (!cmd_data->pub_id) || ETHER_ISNULLADDR(&cmd_data->mac_addr.octet)) { WL_ERR((" mandatory arguments are not present \n")); return -EINVAL; } nanioc = kzalloc(nanioc_size, kflags); if (!nanioc) { WL_ERR((" memory allocation failed \n")); return -ENOMEM; } /* * command to test * * wl: wl nan trasnmit <sub_id> <pub_id> <mac_addr> -info <hex_string> * * wpa_cli: DRIVER NAN_TRANSMIT SUB_ID=<sub_id> PUB_ID=<pub_id> * MAC_ADDR=<mac_addr> SVC_INFO=<hex_string> */ /* nan transmit */ start = end = NAN_IOCTL_BUF_SIZE; nanioc->version = htod16(WL_NAN_IOCTL_VERSION); nanioc->id = htod16(WL_NAN_CMD_TRANSMIT); pxtlv = nanioc->data; ret = bcm_pack_xtlv_entry(&pxtlv, &end, WL_NAN_XTLV_INSTANCE_ID, sizeof(wl_nan_instance_id_t), &cmd_data->sub_id); if (unlikely(ret)) { goto fail; } ret = bcm_pack_xtlv_entry(&pxtlv, &end, WL_NAN_XTLV_REQUESTOR_ID, sizeof(wl_nan_instance_id_t), &cmd_data->pub_id); if (unlikely(ret)) { goto fail; } ret = bcm_pack_xtlv_entry(&pxtlv, &end, WL_NAN_XTLV_MAC_ADDR, ETHER_ADDR_LEN, &cmd_data->mac_addr.octet); if (unlikely(ret)) { goto fail; } if (cmd_data->svc_info.data && cmd_data->svc_info.dlen) { WL_DBG((" optional svc_info present, pack it \n")); ret = bcm_pack_xtlv_entry_from_hex_string(&pxtlv, &end, WL_NAN_XTLV_SVC_INFO, cmd_data->svc_info.data); if (unlikely(ret)) { goto fail; } } nanioc->len = start - end; nanioc_size = sizeof(wl_nan_ioc_t) + nanioc->len; ret = wldev_iovar_setbuf(ndev, "nan", nanioc, nanioc_size, cfg->ioctl_buf, WLC_IOCTL_MEDLEN, NULL); if (unlikely(ret)) { WL_ERR((" nan transmit failed, error = %d \n", ret)); goto fail; } else { WL_DBG((" nan transmit successful \n")); } fail: if (nanioc) { kfree(nanioc); } return ret; }
int wl_cfgnan_cancel_sub_handler(struct net_device *ndev, struct bcm_cfg80211 *cfg, char *cmd, nan_cmd_data_t *cmd_data) { wl_nan_ioc_t *nanioc = NULL; struct bcm_tlvbuf *tbuf = NULL; wl_nan_disc_params_t params; s32 ret = BCME_OK; u16 kflags = in_atomic() ? GFP_ATOMIC : GFP_KERNEL; uint16 nanioc_size = sizeof(wl_nan_ioc_t) + NAN_IOCTL_BUF_SIZE; /* proceed only if mandatory argument is present - subscriber id */ if (!cmd_data->sub_id) { WL_ERR((" mandatory argument is not present \n")); return -EINVAL; } nanioc = kzalloc(nanioc_size, kflags); if (!nanioc) { WL_ERR((" memory allocation failed \n")); return -ENOMEM; } tbuf = bcm_xtlv_buf_alloc(NULL, BCM_XTLV_HDR_SIZE + sizeof(params)); if (!tbuf) { WL_ERR((" memory allocation failed \n")); ret = -ENOMEM; goto fail; } /* * command to test * * wl: wl nan cancel_subscribe 10 * * wpa_cli: DRIVER NAN_CANCEL_SUBSCRIBE PUB_ID=10 */ bcm_xtlv_put_data(tbuf, WL_NAN_XTLV_INSTANCE_ID, &cmd_data->sub_id, sizeof(wl_nan_instance_id_t)); /* nan cancel subscribe */ nanioc->version = htod16(WL_NAN_IOCTL_VERSION); nanioc->id = htod16(WL_NAN_CMD_CANCEL_SUBSCRIBE); nanioc->len = htod16(bcm_xtlv_buf_len(tbuf)); bcopy(bcm_xtlv_head(tbuf), nanioc->data, bcm_xtlv_buf_len(tbuf)); nanioc_size = sizeof(wl_nan_ioc_t) + bcm_xtlv_buf_len(tbuf); ret = wldev_iovar_setbuf(ndev, "nan", nanioc, nanioc_size, cfg->ioctl_buf, WLC_IOCTL_MEDLEN, NULL); if (unlikely(ret)) { WL_ERR((" nan cancel subscribe failed, error = %d \n", ret)); goto fail; } else { WL_DBG((" nan cancel subscribe successful \n")); } fail: if (tbuf) { bcm_xtlv_buf_free(NULL, tbuf); } if (nanioc) { kfree(nanioc); } return ret; }
int wl_cfgnan_sub_handler(struct net_device *ndev, struct bcm_cfg80211 *cfg, char *cmd, nan_cmd_data_t *cmd_data) { wl_nan_ioc_t *nanioc = NULL; struct bcm_tlvbuf *tbuf = NULL; wl_nan_disc_params_t params; s32 ret = BCME_OK; u16 kflags = in_atomic() ? GFP_ATOMIC : GFP_KERNEL; uint16 nanioc_size = sizeof(wl_nan_ioc_t) + NAN_IOCTL_BUF_SIZE; /* * proceed only if mandatory arguments are present - subscriber id, * service hash */ if ((!cmd_data->sub_id) || (!cmd_data->svc_hash.data) || (!cmd_data->svc_hash.dlen)) { WL_ERR((" mandatory arguments are not present \n")); return -EINVAL; } nanioc = kzalloc(nanioc_size, kflags); if (!nanioc) { WL_ERR((" memory allocation failed \n")); return -ENOMEM; } tbuf = bcm_xtlv_buf_alloc(NULL, BCM_XTLV_HDR_SIZE + sizeof(params)); if (!tbuf) { WL_ERR((" memory allocation failed \n")); ret = -ENOMEM; goto fail; } /* * command to test * * wl: wl nan subscribe 10 NAN123 * * wpa_cli: DRIVER NAN_SUBSCRIBE SUB_ID=10 SVC_HASH=NAN123 */ /* nan subscribe */ params.period = 1; params.ttl = WL_NAN_TTL_UNTIL_CANCEL; params.flags = 0; params.instance_id = (wl_nan_instance_id_t)cmd_data->sub_id; memcpy((char *)params.svc_hash, cmd_data->svc_hash.data, cmd_data->svc_hash.dlen); bcm_xtlv_put_data(tbuf, WL_NAN_XTLV_SVC_PARAMS, ¶ms, sizeof(params)); nanioc->version = htod16(WL_NAN_IOCTL_VERSION); nanioc->id = htod16(WL_NAN_CMD_SUBSCRIBE); nanioc->len = htod16(bcm_xtlv_buf_len(tbuf)); bcopy(bcm_xtlv_head(tbuf), nanioc->data, bcm_xtlv_buf_len(tbuf)); nanioc_size = sizeof(wl_nan_ioc_t) + bcm_xtlv_buf_len(tbuf); ret = wldev_iovar_setbuf(ndev, "nan", nanioc, nanioc_size, cfg->ioctl_buf, WLC_IOCTL_MEDLEN, NULL); if (unlikely(ret)) { WL_ERR((" nan subscribe failed, error = %d \n", ret)); goto fail; } else { WL_DBG((" nan subscribe successful \n")); } fail: if (tbuf) { bcm_xtlv_buf_free(NULL, tbuf); } if (nanioc) { kfree(nanioc); } return ret; }
int wl_cfgnan_pub_handler(struct net_device *ndev, struct bcm_cfg80211 *cfg, char *cmd, nan_cmd_data_t *cmd_data) { wl_nan_ioc_t *nanioc = NULL; struct bcm_tlvbuf *tbuf = NULL; wl_nan_disc_params_t params; s32 ret = BCME_OK; u16 kflags = in_atomic() ? GFP_ATOMIC : GFP_KERNEL; uint16 tbuf_size = BCM_XTLV_HDR_SIZE + sizeof(params); uint16 nanioc_size = sizeof(wl_nan_ioc_t) + NAN_IOCTL_BUF_SIZE; void *pxtlv; u16 start, end; /* * proceed only if mandatory arguments are present - publisher id, * service hash */ if ((!cmd_data->pub_id) || (!cmd_data->svc_hash.data) || (!cmd_data->svc_hash.dlen)) { WL_ERR((" mandatory arguments are not present \n")); return -EINVAL; } nanioc = kzalloc(nanioc_size, kflags); if (!nanioc) { WL_ERR((" memory allocation failed \n")); return -ENOMEM; } tbuf = bcm_xtlv_buf_alloc(NULL, tbuf_size); if (!tbuf) { WL_ERR((" memory allocation failed \n")); ret = -ENOMEM; goto fail; } /* * command to test * * wl: wl nan publish 10 NAN123 -info <hex_string * wl nan publish 10 NAN123 -info <hex_string -period 1 -ttl 0xffffffff * * wpa_cli: DRIVER NAN_PUBLISH PUB_ID=10 SVC_HASH=NAN123 * SVC_INFO=<hex_string> * DRIVER NAN_PUBLISH PUB_ID=10 SVC_HASH=NAN123 * SVC_INFO=<hex_string> PUB_PR=1 PUB_INT=0xffffffff */ /* nan publish */ start = end = NAN_IOCTL_BUF_SIZE; nanioc->version = htod16(WL_NAN_IOCTL_VERSION); nanioc->id = htod16(WL_NAN_CMD_PUBLISH); pxtlv = nanioc->data; /* disovery parameters */ if (cmd_data->pub_pr) { params.period = cmd_data->pub_pr; } else { params.period = 1; } if (cmd_data->pub_int) { params.ttl = cmd_data->pub_int; } else { params.ttl = WL_NAN_TTL_UNTIL_CANCEL; } params.flags = WL_NAN_PUB_BOTH; params.instance_id = (wl_nan_instance_id_t)cmd_data->pub_id; memcpy((char *)params.svc_hash, cmd_data->svc_hash.data, cmd_data->svc_hash.dlen); ret = bcm_pack_xtlv_entry(&pxtlv, &end, WL_NAN_XTLV_SVC_PARAMS, sizeof(wl_nan_disc_params_t), ¶ms); if (unlikely(ret)) { goto fail; } if (cmd_data->svc_info.data && cmd_data->svc_info.dlen) { WL_DBG((" optional svc_info present, pack it \n")); ret = bcm_pack_xtlv_entry_from_hex_string(&pxtlv, &end, WL_NAN_XTLV_SVC_INFO, cmd_data->svc_info.data); if (unlikely(ret)) { goto fail; } } nanioc->len = start - end; nanioc_size = sizeof(wl_nan_ioc_t) + nanioc->len; ret = wldev_iovar_setbuf(ndev, "nan", nanioc, nanioc_size, cfg->ioctl_buf, WLC_IOCTL_MEDLEN, NULL); if (unlikely(ret)) { WL_ERR((" nan publish failed, error = %d \n", ret)); goto fail; } else { WL_DBG((" nan publish successful \n")); } fail: if (tbuf) { bcm_xtlv_buf_free(NULL, tbuf); } if (nanioc) { kfree(nanioc); } return ret; }
int wl_cfgnan_stop_handler(struct net_device *ndev, struct bcm_cfg80211 *cfg, char *cmd, nan_cmd_data_t *cmd_data) { wl_nan_ioc_t *nanioc = NULL; struct ether_addr cluster_id = ether_null; void *pxtlv; s32 ret = BCME_OK; u16 start, end; u16 kflags = in_atomic() ? GFP_ATOMIC : GFP_KERNEL; uint16 nanioc_size = sizeof(wl_nan_ioc_t) + NAN_IOCTL_BUF_SIZE; uint8 nan_enable = FALSE; if (cfg->nan_running == false) { WL_DBG((" nan not running, do nothing \n")); return BCME_OK; } nanioc = kzalloc(nanioc_size, kflags); if (!nanioc) { WL_ERR((" memory allocation failed \n")); return -ENOMEM; } /* * command to test * * wl: wl nan stop * wl nan 0 * * wpa_cli: DRIVER NAN_STOP */ /* nan stop */ start = end = NAN_IOCTL_BUF_SIZE; nanioc->version = htod16(WL_NAN_IOCTL_VERSION); nanioc->id = htod16(WL_NAN_CMD_STOP); pxtlv = nanioc->data; ret = bcm_pack_xtlv_entry(&pxtlv, &end, WL_NAN_XTLV_CLUSTER_ID, ETHER_ADDR_LEN, &cluster_id); if (unlikely(ret)) { goto fail; } nanioc->len = start - end; nanioc_size = sizeof(wl_nan_ioc_t) + nanioc->len; ret = wldev_iovar_setbuf(ndev, "nan", nanioc, nanioc_size, cfg->ioctl_buf, WLC_IOCTL_MEDLEN, NULL); if (unlikely(ret)) { WL_ERR((" nan stop failed, error = %d \n", ret)); goto fail; } else { WL_DBG((" nan stop successful \n")); } /* nan disable */ memset(nanioc, 0, nanioc_size); start = end = NAN_IOCTL_BUF_SIZE; nanioc->version = htod16(WL_NAN_IOCTL_VERSION); nanioc->id = htod16(WL_NAN_CMD_ENABLE); pxtlv = nanioc->data; ret = bcm_pack_xtlv_entry(&pxtlv, &end, WL_NAN_XTLV_ENABLE, sizeof(uint8), &nan_enable); if (unlikely(ret)) { goto fail; } nanioc->len = start - end; nanioc_size = sizeof(wl_nan_ioc_t) + nanioc->len; ret = wldev_iovar_setbuf(ndev, "nan", nanioc, nanioc_size, cfg->ioctl_buf, WLC_IOCTL_MEDLEN, NULL); if (unlikely(ret)) { WL_ERR((" nan disable failed, error = %d \n", ret)); goto fail; } else { WL_DBG((" nan disable successful \n")); } fail: if (nanioc) { kfree(nanioc); } return ret; }
int wl_cfgnan_enable_events(struct net_device *ndev, struct bcm_cfg80211 *cfg) { wl_nan_ioc_t *nanioc = NULL; void *pxtlv; u32 event_mask = 0; s32 ret = BCME_OK; u16 start, end; u16 kflags = in_atomic() ? GFP_ATOMIC : GFP_KERNEL; uint16 nanioc_size = sizeof(wl_nan_ioc_t) + NAN_IOCTL_BUF_SIZE; nanioc = kzalloc(nanioc_size, kflags); if (!nanioc) { WL_ERR((" memory allocation failed \n")); return -ENOMEM; } ret = wl_add_remove_eventmsg(ndev, WLC_E_NAN, true); if (unlikely(ret)) { WL_ERR((" nan event enable failed, error = %d \n", ret)); goto fail; } if (g_nan_debug) { /* enable all nan events */ event_mask = NAN_EVENT_MASK_ALL; } else { /* enable only selected nan events to avoid unnecessary host wake up */ event_mask |= NAN_EVENT_BIT(WL_NAN_EVENT_START); event_mask |= NAN_EVENT_BIT(WL_NAN_EVENT_JOIN); event_mask |= NAN_EVENT_BIT(WL_NAN_EVENT_DISCOVERY_RESULT); event_mask |= NAN_EVENT_BIT(WL_NAN_EVENT_RECEIVE); event_mask |= NAN_EVENT_BIT(WL_NAN_EVENT_TERMINATED); event_mask |= NAN_EVENT_BIT(WL_NAN_EVENT_STOP); event_mask |= NAN_EVENT_BIT(WL_NAN_EVENT_CLEAR_BIT); event_mask = htod32(event_mask); } start = end = NAN_IOCTL_BUF_SIZE; nanioc->version = htod16(WL_NAN_IOCTL_VERSION); nanioc->id = htod16(WL_NAN_CMD_EVENT_MASK); pxtlv = nanioc->data; ret = bcm_pack_xtlv_entry(&pxtlv, &end, WL_NAN_XTLV_EVENT_MASK, sizeof(uint32), &event_mask); if (unlikely(ret)) { goto fail; } nanioc->len = start - end; nanioc_size = sizeof(wl_nan_ioc_t) + nanioc->len; ret = wldev_iovar_setbuf(ndev, "nan", nanioc, nanioc_size, cfg->ioctl_buf, WLC_IOCTL_MEDLEN, NULL); if (unlikely(ret)) { WL_ERR((" nan event selective enable failed, error = %d \n", ret)); goto fail; } else { WL_DBG((" nan event selective enable successful \n")); } ret = wl_add_remove_eventmsg(ndev, WLC_E_PROXD, true); if (unlikely(ret)) { WL_ERR((" proxd event enable failed, error = %d \n", ret)); goto fail; } fail: if (nanioc) { kfree(nanioc); } return ret; }
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; }
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; }
int wl_cfgnan_rtt_find_handler(struct net_device *ndev, struct bcm_cfg80211 *cfg, char *cmd, nan_cmd_data_t *cmd_data) { void *iovbuf; wl_nan_ranging_list_t *rtt_list; s32 iovbuf_size = NAN_RTT_IOVAR_BUF_SIZE; s32 ret = BCME_OK; u16 kflags = in_atomic() ? GFP_ATOMIC : GFP_KERNEL; /* * proceed only if mandatory arguments are present - channel, bitmap, * mac address */ if ((!cmd_data->chanspec) || (!cmd_data->bmap) || ETHER_ISNULLADDR(&cmd_data->mac_addr.octet)) { WL_ERR((" mandatory arguments are not present \n")); return -EINVAL; } iovbuf = kzalloc(iovbuf_size, kflags); if (!iovbuf) { WL_ERR((" memory allocation failed \n")); return -ENOMEM; } /* * command to test * * wl: wl proxd_nanfind 1 44/80 <mac_addr> 0x300 5 6 1 * * wpa_cli: DRIVER NAN_RTT_FIND MAC_ADDR=<mac_addr> CHAN=44/80 BMAP=0x300 * */ rtt_list = (wl_nan_ranging_list_t *)iovbuf; rtt_list->count = 1; rtt_list->num_peers_done = 0; rtt_list->num_dws = 1; rtt_list->rp[0].chanspec = cmd_data->chanspec; memcpy(&rtt_list->rp[0].ea, &cmd_data->mac_addr, sizeof(struct ether_addr)); rtt_list->rp[0].abitmap = cmd_data->bmap; rtt_list->rp[0].frmcnt = 5; rtt_list->rp[0].retrycnt = 6; rtt_list->rp[0].flags = 1; iovbuf_size = sizeof(wl_nan_ranging_list_t) + sizeof(wl_nan_ranging_peer_t); ret = wldev_iovar_setbuf(ndev, "proxd_nanfind", iovbuf, iovbuf_size, cfg->ioctl_buf, WLC_IOCTL_MEDLEN, NULL); if (unlikely(ret)) { WL_ERR((" nan rtt find failed, error = %d \n", ret)); } else { WL_DBG((" nan rtt find successful \n")); } if (iovbuf) { kfree(iovbuf); } return ret; }
int wl_android_set_ibss_beacon_ouidata(struct net_device *dev, char *command, int total_len) { char ie_buf[VNDR_IE_MAX_LEN]; char *ioctl_buf = NULL; char hex[] = "XX"; char *pcmd = NULL; int ielen = 0, datalen = 0, idx = 0, tot_len = 0; vndr_ie_setbuf_t *vndr_ie = NULL; s32 iecount; uint32 pktflag; u16 kflags = in_atomic() ? GFP_ATOMIC : GFP_KERNEL; s32 err = BCME_OK; /* Check the VSIE (Vendor Specific IE) which was added. * If exist then send IOVAR to delete it */ if (wl_cfg80211_ibss_vsie_delete(dev) != BCME_OK) { return -EINVAL; } pcmd = command + strlen(CMD_SETIBSSBEACONOUIDATA) + 1; for (idx = 0; idx < DOT11_OUI_LEN; idx++) { hex[0] = *pcmd++; hex[1] = *pcmd++; ie_buf[idx] = (uint8)simple_strtoul(hex, NULL, 16); } pcmd++; while ((*pcmd != '\0') && (idx < VNDR_IE_MAX_LEN)) { hex[0] = *pcmd++; hex[1] = *pcmd++; ie_buf[idx++] = (uint8)simple_strtoul(hex, NULL, 16); datalen++; } tot_len = sizeof(vndr_ie_setbuf_t) + (datalen - 1); vndr_ie = (vndr_ie_setbuf_t *) kzalloc(tot_len, kflags); if (!vndr_ie) { WL_ERR(("IE memory alloc failed\n")); return -ENOMEM; } /* Copy the vndr_ie SET command ("add"/"del") to the buffer */ strncpy(vndr_ie->cmd, "add", VNDR_IE_CMD_LEN - 1); vndr_ie->cmd[VNDR_IE_CMD_LEN - 1] = '\0'; /* Set the IE count - the buffer contains only 1 IE */ iecount = htod32(1); memcpy((void *)&vndr_ie->vndr_ie_buffer.iecount, &iecount, sizeof(s32)); /* Set packet flag to indicate that BEACON's will contain this IE */ pktflag = htod32(VNDR_IE_BEACON_FLAG | VNDR_IE_PRBRSP_FLAG); memcpy((void *)&vndr_ie->vndr_ie_buffer.vndr_ie_list[0].pktflag, &pktflag, sizeof(u32)); /* Set the IE ID */ vndr_ie->vndr_ie_buffer.vndr_ie_list[0].vndr_ie_data.id = (uchar) DOT11_MNG_PROPR_ID; memcpy(&vndr_ie->vndr_ie_buffer.vndr_ie_list[0].vndr_ie_data.oui, &ie_buf, DOT11_OUI_LEN); memcpy(&vndr_ie->vndr_ie_buffer.vndr_ie_list[0].vndr_ie_data.data, &ie_buf[DOT11_OUI_LEN], datalen); ielen = DOT11_OUI_LEN + datalen; vndr_ie->vndr_ie_buffer.vndr_ie_list[0].vndr_ie_data.len = (uchar) ielen; ioctl_buf = kmalloc(WLC_IOCTL_MEDLEN, GFP_KERNEL); if (!ioctl_buf) { WL_ERR(("ioctl memory alloc failed\n")); if (vndr_ie) { kfree(vndr_ie); } return -ENOMEM; } memset(ioctl_buf, 0, WLC_IOCTL_MEDLEN); /* init the buffer */ err = wldev_iovar_setbuf(dev, "ie", vndr_ie, tot_len, ioctl_buf, WLC_IOCTL_MEDLEN, NULL); if (err != BCME_OK) { err = -EINVAL; if (vndr_ie) { kfree(vndr_ie); } } else { /* do NOT free 'vndr_ie' for the next process */ wl_cfg80211_ibss_vsie_set_buffer(vndr_ie, tot_len); } if (ioctl_buf) { kfree(ioctl_buf); } return err; }
int wl_cfgnan_set_config_handler(struct net_device *ndev, struct bcm_cfg80211 *cfg, char *cmd, nan_cmd_data_t *cmd_data) { wl_nan_ioc_t *nanioc = NULL; void *pxtlv; s32 ret = BCME_OK; u16 start, end; u16 kflags = in_atomic() ? GFP_ATOMIC : GFP_KERNEL; uint16 nanioc_size = sizeof(wl_nan_ioc_t) + NAN_IOCTL_BUF_SIZE; nanioc = kzalloc(nanioc_size, kflags); if (!nanioc) { WL_ERR((" memory allocation failed \n")); return -ENOMEM; } /* * command to test * * wl: wl nan <attr> <value> (wl nan role 1) * * wpa_cli: DRIVER NAN_CONFIG_SET ATTR=<attr> <value>...<value> * * wpa_cli: DRIVER NAN_SET_CONFIG ATTR=ATTR_ROLE ROLE=1 */ /* nan set config */ start = end = NAN_IOCTL_BUF_SIZE; nanioc->version = htod16(WL_NAN_IOCTL_VERSION); nanioc->id = htod16(WL_NAN_CMD_ATTR); pxtlv = nanioc->data; switch (cmd_data->attr.type) { case WL_NAN_XTLV_ROLE: ret = bcm_pack_xtlv_entry(&pxtlv, &end, WL_NAN_XTLV_ROLE, sizeof(u32), &cmd_data->role); break; case WL_NAN_XTLV_MASTER_PREF: ret = bcm_pack_xtlv_entry(&pxtlv, &end, WL_NAN_XTLV_MASTER_PREF, sizeof(u16), &cmd_data->master_pref); break; case WL_NAN_XTLV_DW_LEN: ret = bcm_pack_xtlv_entry(&pxtlv, &end, WL_NAN_XTLV_DW_LEN, sizeof(u16), &cmd_data->dw_len); break; case WL_NAN_XTLV_CLUSTER_ID: case WL_NAN_XTLV_IF_ADDR: case WL_NAN_XTLV_BCN_INTERVAL: case WL_NAN_XTLV_MAC_CHANSPEC: case WL_NAN_XTLV_MAC_TXRATE: default: ret = -EINVAL; break; } if (unlikely(ret)) { WL_ERR((" unsupported attribute, attr = %s (%d) \n", cmd_data->attr.name, cmd_data->attr.type)); goto fail; } nanioc->len = start - end; nanioc_size = sizeof(wl_nan_ioc_t) + nanioc->len; ret = wldev_iovar_setbuf(ndev, "nan", nanioc, nanioc_size, cfg->ioctl_buf, WLC_IOCTL_MEDLEN, NULL); if (unlikely(ret)) { WL_ERR((" nan set config failed, error = %d \n", ret)); goto fail; } else { WL_DBG((" nan set config successful \n")); } fail: if (nanioc) { kfree(nanioc); } return ret; }
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]; 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; } } cspec.rev = -1; //[email protected] - Country Code and rev from framework //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); { char *revstr; char *endptr = NULL; revstr = strchr(country_code, '/'); if (revstr) { cspec.rev = bcm_strtoul(revstr + 1, &endptr, 10); memcpy(cspec.country_abbrev,country_code,WLC_CNTRY_BUF_SZ); cspec.country_abbrev[2] = '\0'; memcpy(cspec.ccode,cspec.country_abbrev,WLC_CNTRY_BUF_SZ); } else { #if defined (CONFIG_PRODUCT_I_ATNT) || defined(CONFIG_PRODUCT_I_BELL) || defined(CONFIG_PRODUCT_J_TLS) 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); #else cspec.rev = 0; memcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ); memcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ); #endif } } WLDEV_ERROR(("%s: set country for %s as %s rev %d\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); //[email protected] - Country Code and rev from framework 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); WLDEV_ERROR(("%s: set country for %s as %s rev %d\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); return 0; }