int icm_get_channel_loading(ICM_INFO_T* picm) { u_int32_t status = SUCCESS; struct ifreq ifr; ICM_SPECTRAL_INFO_T* psinfo = &picm->sinfo; ICM_DEV_INFO_T* pdev = get_pdev(); ICM_NLSOCK_T *pnlinfo = ICM_GET_ADDR_OF_NLSOCK_INFO(pdev); psinfo->atd.ad_id = IOCTL_SPECTRAL_GET_CHANINFO | ATH_DIAG_DYN; psinfo->atd.ad_in_data = NULL; psinfo->atd.ad_in_size = 0; psinfo->atd.ad_out_data = (void*)&picm->slist.chan_properties[0]; psinfo->atd.ad_out_size = sizeof(CHANNEL_PROPERTIES_T) * MAX_NUM_CHANNELS; strcpy(ifr.ifr_name, psinfo->atd.ad_name); ifr.ifr_data = (caddr_t)&psinfo->atd.ad_name; if (ioctl(pnlinfo->sock_fd, SIOCGATHPHYERR, &ifr) < 0) { status = FAILURE; perror("ioctl fail"); } return status; }
/* The backend is now connected so complete the connection process on our side */ static int pcifront_connect(struct pcifront_device *pdev) { device_t nexus; devclass_t nexus_devclass; /* We will add our device as a child of the nexus0 device */ if (!(nexus_devclass = devclass_find("nexus")) || !(nexus = devclass_get_device(nexus_devclass, 0))) { WPRINTF("could not find nexus0!\n"); return -1; } /* Create a newbus device representing this frontend instance */ pdev->ndev = BUS_ADD_CHILD(nexus, 0, "xpcife", pdev->unit); if (!pdev->ndev) { WPRINTF("could not create xpcife%d!\n", pdev->unit); return -EFAULT; } get_pdev(pdev); device_set_ivars(pdev->ndev, pdev); /* Good to go connected now */ xenbus_switch_state(pdev->xdev, NULL, XenbusStateConnected); printf("pcifront: connected to %s\n", pdev->xdev->nodename); mtx_lock(&Giant); device_probe_and_attach(pdev->ndev); mtx_unlock(&Giant); return 0; }
int icm_test_clear_chan_properties(ICM_INFO_T* picm) { ICM_DEV_INFO_T* pdev = get_pdev(); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "TEST : Clear recorded channel characteristics"); icm_clear_spectral_chan_properties(picm); return 0; }
/* * Function : set_spectral_debug * Description : set the spectral module debug level * Input params : pointer to icm info structrue * Return : success/failure * */ int set_spectral_debug(ICM_INFO_T* picm, int dbglevel) { u_int32_t status = SUCCESS; struct ifreq ifr; ICM_SPECTRAL_INFO_T* psinfo = &picm->sinfo; ICM_DEV_INFO_T* pdev = get_pdev(); ICM_NLSOCK_T *pnlinfo = ICM_GET_ADDR_OF_NLSOCK_INFO(pdev); /* XXX : We should set priority to 0 */ psinfo->atd.ad_id = IOCTL_SPECTRAL_SET_DEBUG_LEVEL | ATH_DIAG_DYN; psinfo->atd.ad_in_data = NULL; psinfo->atd.ad_in_size = 0; psinfo->atd.ad_out_size = sizeof(u_int32_t); strcpy(ifr.ifr_name, psinfo->atd.ad_name); ifr.ifr_data = (caddr_t)&psinfo->atd.ad_name; if (ioctl(pnlinfo->sock_fd, SIOCGATHPHYERR, &ifr) < 0) { status = FAILURE; perror("ioctl fail"); } return status; }
int icm_set_icm_active(ICM_INFO_T *picm, u_int32_t val) { u_int32_t status = SUCCESS; struct ifreq ifr; ICM_DEV_INFO_T* pdev = get_pdev(); ICM_SPECTRAL_INFO_T* psinfo = &picm->sinfo; ICM_NLSOCK_T *pnlinfo = ICM_GET_ADDR_OF_NLSOCK_INFO(pdev); /* XXX : We should set priority to 0 */ psinfo->atd.ad_id = IOCTL_SPECTRAL_SET_ICM_ACTIVE | ATH_DIAG_IN; psinfo->atd.ad_in_data = (void *)&val; psinfo->atd.ad_in_size = sizeof(u_int32_t); psinfo->atd.ad_out_size = 0; psinfo->atd.ad_out_data = NULL; strcpy(ifr.ifr_name, psinfo->atd.ad_name); ifr.ifr_data = (caddr_t)&psinfo->atd.ad_name; if (ioctl(pnlinfo->sock_fd, SIOCGATHPHYERR, &ifr) < 0) { status = FAILURE; perror("ioctl fail"); } return status; }
/* * Function : icm_get_channel_width * Description : Get current channel width from driver * Input params : pointer to icm info structure * Return : Channel width on success * IEEE80211_CWM_WIDTHINVALID on failure */ enum ieee80211_cwm_width icm_get_channel_width(ICM_INFO_T* picm) { enum ieee80211_cwm_width ch_width = 0; struct ifreq ifr; ICM_DEV_INFO_T* pdev = get_pdev(); ICM_NLSOCK_T *pnlinfo = ICM_GET_ADDR_OF_NLSOCK_INFO(pdev); ICM_SPECTRAL_INFO_T *psinfo = NULL; if (picm == NULL) { err("icm: ICM Information structure is invalid"); return IEEE80211_CWM_WIDTHINVALID; } psinfo = &picm->sinfo; psinfo->atd.ad_id = SPECTRAL_GET_CHAN_WIDTH | ATH_DIAG_DYN; psinfo->atd.ad_in_data = NULL; psinfo->atd.ad_in_size = 0; psinfo->atd.ad_out_data = (void*)&ch_width; psinfo->atd.ad_out_size = sizeof(u_int32_t); strncpy(ifr.ifr_name, psinfo->atd.ad_name, IFNAMSIZ); ifr.ifr_name[IFNAMSIZ - 1] = '\0'; ifr.ifr_data = (caddr_t)&psinfo->atd.ad_name; if (ioctl(pnlinfo->sock_fd, SIOCGATHPHYERR, &ifr) < 0) { ch_width = IEEE80211_CWM_WIDTHINVALID; perror("icm: SIOCGATHPHYERR ioctl fail (SPECTRAL_GET_CHAN_WIDTH)"); } return ch_width; }
/* * Function : start_spectral_scan * Description : start the spectrla scan on current channel * Input params : pointer to icm info structrue * Return : success/failure * */ int start_spectral_scan(ICM_INFO_T* picm) { u_int32_t status = SUCCESS; struct ifreq ifr; ICM_DEV_INFO_T* pdev = get_pdev(); ICM_NLSOCK_T *pnlinfo = ICM_GET_ADDR_OF_NLSOCK_INFO(pdev); ICM_SPECTRAL_INFO_T* psinfo = &picm->sinfo; picm->substate = ICM_STATE_SPECTRAL_SCAN; psinfo->atd.ad_id = IOCTL_SPECTRAL_ACTIVATE_SCAN | ATH_DIAG_DYN; psinfo->atd.ad_in_data = NULL; psinfo->atd.ad_in_size = 0; psinfo->atd.ad_out_data = (void*)&status; psinfo->atd.ad_out_size = sizeof(u_int32_t); strcpy(ifr.ifr_name, psinfo->atd.ad_name); ifr.ifr_data = (caddr_t)&psinfo->atd.ad_name; if (ioctl(pnlinfo->sock_fd, SIOCGATHPHYERR, &ifr) < 0) { status = FAILURE; perror("ioctl fail"); } return status; }
int icm_clear_spectral_chan_properties(ICM_INFO_T* picm) { u_int32_t status = SUCCESS; struct ifreq ifr; ICM_SPECTRAL_INFO_T* psinfo = &picm->sinfo; ICM_DEV_INFO_T* pdev = get_pdev(); ICM_NLSOCK_T *pnlinfo = ICM_GET_ADDR_OF_NLSOCK_INFO(pdev); /* XXX : We should set priority to 0 */ psinfo->atd.ad_id = IOCTL_SPECTRAL_CLEAR_CHANINFO | ATH_DIAG_DYN; psinfo->atd.ad_in_data = NULL; psinfo->atd.ad_in_size = 0; psinfo->atd.ad_out_data = (void*)&status; psinfo->atd.ad_out_size = sizeof(u_int32_t); strcpy(ifr.ifr_name, psinfo->atd.ad_name); ifr.ifr_data = (caddr_t)&psinfo->atd.ad_name; if (ioctl(pnlinfo->sock_fd, SIOCGATHPHYERR, &ifr) < 0) { status = FAILURE; perror("ioctl fail"); } return status; }
int icm_test_scan(ICM_INFO_T* picm) { ICM_DEV_INFO_T* pdev = get_pdev(); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "TEST : Generic Scan"); icm_do_80211_scan(picm); icm_display_scan_db(picm); return 0; }
int icm_test_get_chan_properties(ICM_INFO_T* picm) { ICM_DEV_INFO_T* pdev = get_pdev(); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "TEST : Channel characteristics"); icm_get_channel_loading(picm); icm_display_chan_properties(picm); return 0; }
int icm_test_list_channels(ICM_INFO_T* picm) { ICM_DEV_INFO_T* pdev = get_pdev(); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "TEST : Listing detail channel info"); icm_get_supported_channels(picm); icm_get_ieee_chaninfo(picm); icm_display_channels(picm); return 0; }
int icm_trim_spectral_scan_ch_list(ICM_INFO_T* picm) { ICM_DEV_INFO_T* pdev = get_pdev(); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_UTIL, "Trimming 11BG Channels for Spectral Scan"); picm->chlist_bg.count = 3; picm->chlist_bg.ch[0].channel = 1; picm->chlist_bg.ch[1].channel = 6; picm->chlist_bg.ch[2].channel = 11; return 0; }
int icm_test_channel(ICM_INFO_T* picm) { ICM_DEV_INFO_T* pdev = get_pdev(); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "TEST : GET CHANNELS"); if (icm_get_supported_channels(picm) == SUCCESS) { icm_display_channels(picm); } else { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "GET CHANNELS failed"); } return 0; }
/* * Function : icm_do_spectral_scan * Description : carry out spectral scans on required channels. Note * that we currently carry out spectral scans only for * ICM_BAND_11BG * Input params : pointer to icm info structrue, bool specifying whether * to restore original channel after scan. * Return : success/failure */ int icm_do_spectral_scan(ICM_INFO_T* picm, bool restore_channel) { int chan_before_spectral; int temp_chan; char cmd[CMD_BUF_SIZE] = {'\0'}; ICM_DEV_INFO_T *pdev = get_pdev(); if (picm->band != ICM_BAND_11BG) { /* Not currently supported */ err("Only 11BG Band currently supported for Spectral scan."); return FAILURE; } if (restore_channel) { if ((chan_before_spectral = icm_get_currchan(picm)) < 0) { err("Unable to get current channel."); return FAILURE; } } info("Starting spectral scan..."); if (icm_start_spectral_scan(picm) != SUCCESS) { err("Cannot start spectral scan..."); return FAILURE; } icm_send_event(pdev, ICM_EVENT_RECIPIENT_MAIN, ICM_EVENT_SPECTRAL_SWEEP_STARTED); /* Receive spectral scan till we complete all the channels */ if (icm_recv_spectral_data(picm) != SUCCESS) { err("Failure while receiving spectral data..."); return FAILURE; } if (restore_channel) { if ((temp_chan = icm_get_currchan(picm)) < 0) { err("Unable to get current channel."); return FAILURE; } if (chan_before_spectral != temp_chan) { info("Configuring back operating channel %d\n", chan_before_spectral); snprintf(cmd, sizeof(cmd), "%s %s %s %1d", "iwconfig", picm->dev_ifname, "channel", chan_before_spectral); system(cmd); } } return SUCCESS; }
int icm_test_spectral_active(ICM_INFO_T* picm) { ICM_DEV_INFO_T* pdev = get_pdev(); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "TEST : Spectral Active"); if (icm_is_spectral_active(picm)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "Spectral Active\n"); } else { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "Spectral Inactive\n"); } return 0; }
int icm_test_spectral_enab(ICM_INFO_T *picm) { ICM_DEV_INFO_T* pdev = get_pdev(); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "TEST : Spectral Enable"); if (icm_is_spectral_enab(picm)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "Spectral enabled\n"); } else { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "Spectral disabled\n"); } return 0; }
/* * Function : set_spectral_param * Description : set spectral param * Input params : pointer to icm info structrue * Return : success/failure * */ int icm_set_spectral_param(ICM_INFO_T* picm, int command, int value) { SPECTRAL_PARAMS_T sparam; struct ifreq ifr; ICM_SPECTRAL_INFO_T* psinfo = &picm->sinfo; ICM_DEV_INFO_T* pdev = get_pdev(); ICM_NLSOCK_T *pnlinfo = ICM_GET_ADDR_OF_NLSOCK_INFO(pdev); int status = SUCCESS; sparam.fft_period = HAL_PHYERR_PARAM_NOVAL; sparam.scan_period = HAL_PHYERR_PARAM_NOVAL; sparam.count = HAL_PHYERR_PARAM_NOVAL; sparam.short_report = HAL_PHYERR_PARAM_NOVAL; sparam.priority = HAL_PHYERR_PARAM_NOVAL; switch (command) { case IOCTL_SPECTRAL_SET_FFT_PEROID: sparam.fft_period = value; break; case IOCTL_SPECTRAL_SET_SCAN_PEROID: sparam.scan_period = value; break; case IOCTL_SPECTRAL_SET_SHORT_RPT: sparam.short_report = (value)?1:0; break; case IOCTL_SPECTRAL_SET_SCAN_COUNT: sparam.count = value; break; case IOCTL_SPECTRAL_SET_SPECTRAL_PRI: sparam.priority = (value)?1:0; break; default: break; } psinfo->atd.ad_id = IOCTL_SPECTRAL_SET_CONFIG | ATH_DIAG_DYN; psinfo->atd.ad_in_data = NULL; psinfo->atd.ad_in_size = 0; psinfo->atd.ad_out_data = (void*)&sparam; psinfo->atd.ad_out_size = sizeof(SPECTRAL_PARAMS_T); strcpy(ifr.ifr_name, psinfo->atd.ad_name); ifr.ifr_data = (caddr_t)&psinfo->atd.ad_name; if (ioctl(pnlinfo->sock_fd, SIOCGATHPHYERR, &ifr) < 0) { status = FAILURE; perror("ioctl fail"); } return status; }
int icm_do_test(ICM_INFO_T* picm) { ICM_DEV_INFO_T* pdev = get_pdev(); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "TEST : icm features"); icm_test_clear_chan_properties(picm); icm_test_get_chan_properties(picm); icm_test_list_channels(picm); icm_test_scan(picm); icm_test_nw_count(picm); icm_test_sweeping_spectral_scan(picm); icm_display_channels(picm); return 0; }
int icm_display_chan_properties(ICM_INFO_T* picm) { int i; ICM_DEV_INFO_T* pdev = get_pdev(); for (i = 0; i < MAX_NUM_CHANNELS; i++) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "%d %d : %d : %d : %d\n", i, picm->slist.chan_properties[i].cycle_count, picm->slist.chan_properties[i].channel_load, picm->slist.chan_properties[i].per, picm->slist.chan_properties[i].noisefloor); } return 0; }
int icm_start_spectral_scan(ICM_INFO_T* picm) { ICM_DEV_INFO_T* pdev = get_pdev(); /* Re-initialize */ if (icm_init_spectral(picm) != SUCCESS) { return FAILURE; } icm_switch_channel(picm); start_spectral_scan(picm); pdev->active_device = picm->dev_index; alarm(picm->sinfo.dwell_interval); return SUCCESS; }
void icm_display_channel_flags(ICM_CHANNEL_T* pch) { ICM_DEV_INFO_T* pdev = get_pdev(); if (IEEE80211_IS_CHAN_FHSS(pch)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tFHSS\n"); } if (IEEE80211_IS_CHAN_11NA(pch)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t11na\n"); } else if (IEEE80211_IS_CHAN_A(pch)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t11a\n"); } else if (IEEE80211_IS_CHAN_11NG(pch)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t11ng\n"); } else if (IEEE80211_IS_CHAN_G(pch) || IEEE80211_IS_CHAN_PUREG(pch)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t11g\n"); } else if (IEEE80211_IS_CHAN_B(pch)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t11b\n"); } if (IEEE80211_IS_CHAN_TURBO(pch)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tTurbo\n"); } if(IEEE80211_IS_CHAN_11N_CTL_CAPABLE(pch)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tControl capable\n"); } if(IEEE80211_IS_CHAN_11N_CTL_U_CAPABLE(pch)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tControl capable upper\n"); } if(IEEE80211_IS_CHAN_11N_CTL_L_CAPABLE(pch)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tControl capable lower\n"); } if (IEEE80211_IS_CHAN_DFSFLAG(pch)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tDFS\n"); } if (IEEE80211_IS_CHAN_HALF(pch)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tHalf\n"); } if (IEEE80211_IS_CHAN_PASSIVE(pch)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tPassive\n"); } if (IEEE80211_IS_CHAN_QUARTER(pch)) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tQuarter\n"); } }
void icm_print_chaninfo(ICM_INFO_T* picm, ICM_BAND_T band) { int i = 0; int wnw_found = 0; ICM_CHANNEL_LIST_T *pchlist = NULL; ICM_DEV_INFO_T* pdev = get_pdev(); if (band == ICM_BAND_2_4G) { pchlist = &picm->chlist_bg; ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\nSupported 11BG Channels\n"); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NO_PREFIX, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, LINESTR); } else { pchlist = &picm->chlist_a; ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\nSupported 11A Channels\n"); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NO_PREFIX, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, LINESTR); } ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_UTIL, "total number of channels = %d\n", pchlist->count); for (i = 0; i < pchlist->count; i++) { wnw_found = icm_get_wireless_nw_in_channel(picm, pchlist->ch[i].channel); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\nchannel : %d : Freq = %d MHz\n", pchlist->ch[i].channel, (int)pchlist->ch[i].freq); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t- Is extension channel 20 MHz : %s\n", (pchlist->ch[i].used_as_secondary_20)?"Yes":"No" ); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t- Is extension channel 40 MHz : %s\n", (pchlist->ch[i].used_as_secondary_40)?"Yes":"No" ); if (wnw_found) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t- Number of WNW %d\n", wnw_found); } icm_display_interference(pchlist->ch[i].flags); icm_display_channel_flags(&pchlist->ch[i]); } ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\n"); }
int icm_get_currchan(ICM_INFO_T* picm) { struct iwreq wrq; ICM_DEV_INFO_T* pdev = get_pdev(); ICM_NLSOCK_T *pnlinfo = ICM_GET_ADDR_OF_NLSOCK_INFO(pdev); if (picm == NULL) { return -1; } memset(&wrq, 0, sizeof(wrq)); strncpy(wrq.ifr_name, picm->dev_ifname, IFNAMSIZ); wrq.ifr_name[IFNAMSIZ - 1] = '\0'; if (ioctl(pnlinfo->sock_fd, SIOCGIWFREQ, &wrq) < 0) { fprintf(stderr, "%-8.16s Could not get channel info.\n\n", picm->dev_ifname); return -1; } return icm_convert_mhz2channel((u_int32_t)wrq.u.freq.m/100000); }
int icm_get_reg_domain(ICM_INFO_T* picm) { u_int32_t status = SUCCESS; struct ifreq ifr; ICM_SPECTRAL_INFO_T* psinfo = &picm->sinfo; ICM_DEV_INFO_T* pdev = get_pdev(); ICM_NLSOCK_T *pnlinfo = ICM_GET_ADDR_OF_NLSOCK_INFO(pdev); psinfo->atd.ad_id = IOCTL_SPECTRAL_GET_REG_MODE | ATH_DIAG_DYN; psinfo->atd.ad_in_data = NULL; psinfo->atd.ad_in_size = 0; psinfo->atd.ad_out_data = (void *)(&picm->dfs_domain); psinfo->atd.ad_out_size = sizeof(u_int32_t); strcpy(ifr.ifr_name, psinfo->atd.ad_name); ifr.ifr_data = (caddr_t)&psinfo->atd.ad_name; if (ioctl(pnlinfo->sock_fd, SIOCGATHPHYERR, &ifr) < 0) { status = FAILURE; perror("ioctl fail"); } return status; }
int icm_test_nw_count(ICM_INFO_T* picm) { int i; int ap_count = 0; ICM_DEV_INFO_T* pdev = get_pdev(); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NO_PREFIX, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_TEST, LINESTR); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_TEST, "Channel\t\tNum of Wireless nw\n"); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_TEST, "-------\t\t------------------\n"); for (i = 0; i < 14; i++) { ap_count = icm_get_wireless_nw_in_channel(picm, i); if (ap_count) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_TEST, " %d \t\t %d\n", i, ap_count); } } return 0; }
int icm_test_sweeping_spectral_scan(ICM_INFO_T* picm) { ICM_DEV_INFO_T* pdev = get_pdev(); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "TEST : Spectral Scan over the band"); icm_init_channel_params(picm); if (icm_get_supported_channels(picm) == FAILURE) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_MAJOR, ICM_MODULE_ID_TEST, "GET CHANNELS failed"); return -1; } //icm_disable_dcs(picm); if (icm_configure_spectral_params(picm) != SUCCESS) { err("Cannot configure required Spectral Scan parameters..."); return -1; } icm_start_spectral_scan(picm); icm_recv_spectral_data(picm); icm_display_channels(picm); return 0; }
/* * Function : icm_display_channels * Description : prints supported channels * Input params : pointer to ICM * Return : void * */ void icm_display_interference(int flags) { ICM_DEV_INFO_T* pdev = get_pdev(); if (flags & SPECT_CLASS_DETECT_MWO) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t- MWO Interfernce detected\n"); } if (flags & SPECT_CLASS_DETECT_CW) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t- CW Interfernce detected\n"); } if (flags & SPECT_CLASS_DETECT_WiFi) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t- WiFi Interfernce detected\n"); } if (flags & SPECT_CLASS_DETECT_CORDLESS_24) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t- CORDLESS 2.4GHz Interfernce detected\n"); } if (flags & SPECT_CLASS_DETECT_CORDLESS_5) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t- CORDLESS 5GHz Interfernce detected\n"); } if (flags & SPECT_CLASS_DETECT_BT) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t- BT Interfernce detected\n"); } if (flags & SPECT_CLASS_DETECT_FHSS) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\t- FHSS Interfernce detected\n"); } }
/* * Function : display_scan_db * Description : Displays the contents of Scan results * Input params : pointer to icm * Return : void * */ void icm_display_scan_db(ICM_INFO_T* picm) { int i = 0; ICM_DEV_INFO_T* pdev = get_pdev(); /* * XXX : 5GHz frequencies are not correctly decoded */ for (i = 0; i < MAX_SCAN_ENTRIES; i++) { if (picm->slist.elem[i].valid) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "Entry No : %d\n", i); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NO_PREFIX, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, LINESTR); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tBSSID : %s\n", icm_ether_sprintf(picm->slist.elem[i].bssid)); /* XXX - SSIDs need not necessarily be NULL terminated, as per standard. Handle this */ ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tSSID : %s\n", picm->slist.elem[i].ssid); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tChannel : %d %s\n", picm->slist.elem[i].channel,((picm->slist.elem[i].channel == (-2))?"Invalid":"Valid")); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tFrequency : %g\n", picm->slist.elem[i].freq); if (picm->slist.elem[i].htinfo.is_valid) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "HT Operation Info\n"); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tExtension Channel Offset : %d\n", picm->slist.elem[i].htinfo.ext_channel_offset); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tTx Channel Width : %d\n", picm->slist.elem[i].htinfo.tx_channel_width); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tOBSS NoHT Present : %d\n", picm->slist.elem[i].htinfo.obss_nonht_present); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tTx Burst Limit : %d\n", picm->slist.elem[i].htinfo.tx_burst_limit); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tNon GF Present : %d\n", picm->slist.elem[i].htinfo.non_gf_present); } if (picm->slist.elem[i].vhtop.is_valid) { ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "VHT Operation Info\n"); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tChannel Width : %d\n", picm->slist.elem[i].vhtop.channel_width); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tChannel CF Seg1 : %d\n", picm->slist.elem[i].vhtop.channel_cf_seg1); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\tChannel CF Seg2 : %d\n", picm->slist.elem[i].vhtop.channel_cf_seg2); } ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NO_PREFIX, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, LINESTR); ICM_DPRINTF(pdev, ICM_PRCTRL_FLAG_NONE, ICM_DEBUG_LEVEL_DEFAULT, ICM_MODULE_ID_UTIL, "\n"); } } }
/* * Function : is_11ac_offload * Description : Return whether the radio referred to in picm * is an 11ac offload radio. * Input params : Pointer to icm data structure * Return : On success: 1 (Offload) or 0 (Direct Attach) * On error : -1 */ int is_11ac_offload(ICM_INFO_T* picm) { return get_radio_priv_int_param(get_pdev(), picm->radio_ifname, OL_ATH_PARAM_GET_IF_ID); }
/* * Function : icm_recv_spectral_data * Description : receive spectral data from driver * Input params : pointer to icm info structrue * Return : success/failure * */ int icm_recv_spectral_data(ICM_INFO_T* picm) { int fdmax; int fd = 0; fd_set master; fd_set read_fds; struct timeval tv; /* range */ int ret; int evret; ICM_EVENT_T event = ICM_EVENT_INVALID; int spectraldone = 0; int eventfd = -1; ICM_DEV_INFO_T* pdev = get_pdev(); ICM_CONFIG_T* conf = &pdev->conf; ICM_NLSOCK_T* pnlinfo = NULL; ICM_INET_T* pinet = NULL; FD_ZERO(&master); FD_ZERO(&read_fds); pinet = ICM_GET_ADDR_OF_INETINFO(pdev); pnlinfo = ICM_GET_ADDR_OF_NLSOCK_INFO(pdev); eventfd = icm_register_event_recipient(pdev, ICM_EVENT_RECIPIENT_SPECTRAL_LOOP); FD_SET(pnlinfo->sock_fd, &master); FD_SET(eventfd, &master); if (conf->server_mode == TRUE) { FD_SET(pinet->listener, &master); } fdmax = (eventfd > pnlinfo->sock_fd) ? \ eventfd : pnlinfo->sock_fd; if (conf->server_mode == TRUE && fdmax < pinet->listener) { fdmax = pinet->listener; } tv.tv_sec = (CHANNEL_DWELL_INTERVAL * 4); tv.tv_usec = 0; while(1) { read_fds = master; /* Wait until some thing happens */ ret = select(fdmax + 1, &read_fds, NULL, NULL, &tv); if (ret == 0) { info("socket timeout"); break; } if (ret < 0) { if (errno == EAGAIN || errno == EINTR) { continue; } else { perror("select"); return FAILURE; } } for (fd = 0; fd <= fdmax; fd++) { if (FD_ISSET(fd, &read_fds)) { if (fd == pnlinfo->sock_fd) { if (icm_handle_spectral_data(pdev, picm) == FAILURE) { icm_cleanup(pdev); return FAILURE; } } else if (fd == eventfd) { evret = icm_get_event(pdev, ICM_EVENT_RECIPIENT_SPECTRAL_LOOP, &event); if (evret < 0) { err("Error retrieving event"); return FAILURE; } if (event == ICM_EVENT_SPECTRAL_SWEEP_DONE) { info("Received Spectral Scan Done event"); spectraldone = 1; break; } else { err("Unexpected event\n"); return FAILURE; } } } } if (spectraldone) { break; } } icm_deregister_event_recipient(pdev, ICM_EVENT_RECIPIENT_SPECTRAL_LOOP); icm_send_event(pdev, ICM_EVENT_RECIPIENT_MAIN, ICM_EVENT_SPECTRAL_SWEEP_DONE); picm->substate = ICM_STATE_INVALID; return SUCCESS; }