Exemplo n.º 1
0
void wlan_btamp_conn_sm_delete(wlan_btamp_conn_sm_t handle)
{
    wlan_btamp_conn_sm_t     smhandle = (wlan_btamp_conn_sm_t)handle;
    struct ieee80211vap      *vap = NULL;
    struct ieee80211_node    *ni = NULL;

    if (!smhandle)
        return;

    vap = smhandle->vap_handle;

    if (smhandle->is_running) {
        IEEE80211_DPRINTF(smhandle->vap_handle, IEEE80211_MSG_STATE,
                          "%s: Deleting state machine while it is still runing \n", __func__); 
    }
    ASSERT(! smhandle->is_running);
    
    OS_CANCEL_TIMER(&(smhandle->sm_timer));
    OS_FREE_TIMER(&(smhandle->sm_timer));

    ieee80211_sm_delete(smhandle->hsm_handle);

    /* Delete node for the peer mac address */
    ni = ieee80211_vap_find_node(vap, smhandle->peer);
    if (ni) {
        IEEE80211_NODE_LEAVE(ni);
        ieee80211_free_node(ni); /* Decrement the extra ref count from find */
    }

    OS_FREE(smhandle);
}
Exemplo n.º 2
0
/*
 * stop handling the events.
 */
int wlan_btamp_conn_sm_stop(wlan_btamp_conn_sm_t handle, wlan_btamp_conn_sm_event_reason reason)
{
    wlan_btamp_conn_sm_t    smhandle = (wlan_btamp_conn_sm_t)handle;

    if (!smhandle)
        return -EINVAL;

    /*
     * return an error if it is already stopped (or)
     * there is a stop request is pending.
     */
    if (!smhandle->is_running ) {
        IEEE80211_DPRINTF(smhandle->vap_handle, IEEE80211_MSG_STATE,
                          "%s: BTAMP Connection SM is already stopped\n",__func__);
        return -EALREADY;
    }
    if (smhandle->is_stop_requested) {
        IEEE80211_DPRINTF(smhandle->vap_handle, IEEE80211_MSG_STATE,
                          "%s: BTAMP Connection SM is already being stopped\n",__func__);
        return -EALREADY;
    }
    smhandle->is_stop_requested = 1;

    OS_CANCEL_TIMER(&(smhandle->sm_timer));

    ieee80211_sm_dispatch(smhandle->hsm_handle,
                          IEEE80211_BTAMP_CONN_EVENT_DISCONNECT_REQUEST,
                          sizeof(u_int32_t),
                          &reason);
                          
    return EOK;
}
Exemplo n.º 3
0
int wlan_mlme_auth_request(wlan_if_t vaphandle, u_int32_t timeout)
{
    struct ieee80211vap           *vap = vaphandle;
    struct ieee80211_mlme_priv    *mlme_priv = vap->iv_mlme_priv;
    struct ieee80211_node         *ni = vap->iv_bss; /* bss node */
    int                           error = 0;

    IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s\n", __func__);

    /* wait for auth seq number 2 (open response or shared challenge) */
    ASSERT(mlme_priv->im_request_type == MLME_REQ_NONE);
    mlme_priv->im_request_type = MLME_REQ_AUTH;
    mlme_priv->im_expected_auth_seq_number = IEEE80211_AUTH_OPEN_RESPONSE;

    /* Set the timeout timer for authenticate failure case */
    OS_SET_TIMER(&mlme_priv->im_timeout_timer, timeout);

    /*  Send the authentication packet */
    error = ieee80211_send_auth(ni, IEEE80211_AUTH_SHARED_REQUEST, 0, NULL, 0);
    if (error) {
        goto err;
    }

    return error;

err:
    mlme_priv->im_request_type = MLME_REQ_NONE;
    OS_CANCEL_TIMER(&mlme_priv->im_timeout_timer);
    return error;
}
Exemplo n.º 4
0
static void ieee80211_btamp_conn_state_assoc_exit(void *ctx) 
{
    wlan_btamp_conn_sm_t    sm = (wlan_btamp_conn_sm_t) ctx;
    
    wlan_mlme_cancel(sm->vap_handle); /* cancel any pending mlme assoc req */
    OS_CANCEL_TIMER(&sm->sm_timer);
}
Exemplo n.º 5
0
/* Send association or reassociation request */
static int mlme_assoc_reassoc_request(wlan_if_t vaphandle, int reassoc, u_int8_t *prev_bssid, u_int32_t timeout)
{
    struct ieee80211vap           *vap = vaphandle;
    struct ieee80211_mlme_priv    *mlme_priv = vap->iv_mlme_priv;
    struct ieee80211_node         *ni = vap->iv_bss; /* bss node */
    int                           error = 0;

    IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s\n", __func__);

    ASSERT(mlme_priv->im_request_type == MLME_REQ_NONE);
    mlme_priv->im_request_type = reassoc ? MLME_REQ_REASSOC : MLME_REQ_ASSOC;

    /* Set the timeout timer for association failure case */
    OS_SET_TIMER(&mlme_priv->im_timeout_timer, timeout);

    /* Transmit frame */
    error = ieee80211_send_assoc(ni, reassoc, prev_bssid);
    if (error) {
        IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: ieee80211_send_assoc error %d (0x%08X)\n", 
            __func__, error, error);
        goto err;
    }

    return error;

err:
    mlme_priv->im_request_type = MLME_REQ_NONE;
    OS_CANCEL_TIMER(&mlme_priv->im_timeout_timer);
    return error;
}
Exemplo n.º 6
0
/* Confirmations */
void ieee80211_mlme_join_complete_infra(struct ieee80211_node *ni)
{
    struct ieee80211vap           *vap = ni->ni_vap;
    struct ieee80211_mlme_priv    *mlme_priv = vap->iv_mlme_priv;

    if ((mlme_priv->im_request_type == MLME_REQ_JOIN_INFRA) && (MLME_STOP_WAITING_FOR_JOIN(mlme_priv) == 1)) 
    {
        IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s\n", __func__);

        /* Request complete */
        mlme_priv->im_request_type = MLME_REQ_NONE;

        /*
         * We have received the beacon that synchronises us with the BSS.
         * We don't care whether the Timer got cancelled or not. The macro
         * HW_STOP_WAITING_FOR_JOIN synchronizes us with the cancel operation
         */
        OS_CANCEL_TIMER(&mlme_priv->im_timeout_timer);

        /* Call MLME confirmation handler */
        IEEE80211_DELIVER_EVENT_MLME_JOIN_COMPLETE_INFRA(vap, IEEE80211_STATUS_SUCCESS);
    }
    else 
    {
        if (mlme_priv->im_request_type != MLME_REQ_NONE) {
            IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: Failed: im_request_type=%d\n", 
                __func__,
                mlme_priv->im_request_type);
        }        
    }
    
    /* start SW bmiss. will be here for every beacon received from our AP  */
    mlme_sta_swbmiss_timer_start(vap);
}
Exemplo n.º 7
0
/*
 * Delete Resource manager.
 */
void ieee80211_resmgr_delete(ieee80211_resmgr_t resmgr)
{
    struct ieee80211com    *ic;
    
    if (!resmgr)
        return ;

    ic = resmgr->ic;

    /* No vaps should exist at this time */
    ASSERT(TAILQ_FIRST(&ic->ic_vaps) == NULL);

    OS_CANCEL_TIMER(&(resmgr->scandata.canpause_timer));
    OS_FREE_TIMER(&(resmgr->scandata.canpause_timer));
    IEEE80211_RESMGR_LOCK_DESTROY(resmgr);

    /* Stop and delete the Off-Channel Scheduler */
    if (ic->ic_caps_ext & IEEE80211_CEXT_MULTICHAN) {
        ieee80211_resmgr_oc_scheduler_delete(resmgr);
    }
    
    /* Stop and delete state machine */
    ieee80211_resmgr_sm_delete(resmgr);

    /* Free ResMgr data structures */
    OS_FREE(resmgr);
    ic->ic_resmgr = NULL;
}
Exemplo n.º 8
0
static OS_TIMER_FUNC(dfs_task)
{
    struct ieee80211com *ic;
    struct ath_dfs *dfs = NULL;

    OS_GET_TIMER_ARG(ic, struct ieee80211com *);
    dfs = (struct ath_dfs *)ic->ic_dfs;
    /*
     * XXX no locking?!
     */
    if (dfs_process_radarevent(dfs, ic->ic_curchan)) {
#ifndef ATH_DFS_RADAR_DETECTION_ONLY

        /*
         * This marks the channel (and the extension channel, if HT40) as
         * having seen a radar event.  It marks CHAN_INTERFERENCE and
         * will add it to the local NOL implementation.
         *
         * This is only done for 'usenol=1', as the other two modes
         * don't do radar notification or CAC/CSA/NOL; it just notes
         * there was a radar.
         */
        if (dfs->dfs_rinfo.rn_use_nol == 1) {
            dfs_channel_mark_radar(dfs, ic->ic_curchan);
        }
#endif /* ATH_DFS_RADAR_DETECTION_ONLY */

        /*
         * This calls into the umac DFS code, which sets the umac related
         * radar flags and begins the channel change machinery.
         *
         * XXX TODO: the umac NOL code isn't used, but IEEE80211_CHAN_RADAR
         * still gets set.  Since the umac NOL code isn't used, that flag
         * is never cleared.  This needs to be fixed. See EV 105776.
         */
        if (dfs->dfs_rinfo.rn_use_nol == 1)  {
            ic->ic_dfs_notify_radar(ic, ic->ic_curchan);
            /* 
                EV 129487 : 
                we have detected radar in the channel, stop processing
                PHY error data as this can cause false detect in the new 
                channel while channel change is in progress 
            */

            dfs_radar_disable(ic);
        } else if (dfs->dfs_rinfo.rn_use_nol == 0) {
            /*
             * For the test mode, don't do a CSA here; but setup the
             * test timer so we get a CSA _back_ to the original channel.
             */
            OS_CANCEL_TIMER(&dfs->ath_dfstesttimer);
            dfs->ath_dfstest = 1;
            dfs->ath_dfstest_ieeechan = ic->ic_curchan->ic_ieee;
            dfs->ath_dfstesttime = 1;   /* 1ms */
            OS_SET_TIMER(&dfs->ath_dfstesttimer, dfs->ath_dfstesttime);
        }
    }
    dfs->ath_radar_tasksched = 0;
}
Exemplo n.º 9
0
Arquivo: gpio.c Projeto: jhbsz/102
static int gpio_simple_config_led_write(struct file *file, const char *buf,
					unsigned long count, void *data)
{
	u_int32_t val;

	if (sscanf(buf, "%d", &val) != 1)
		return -EINVAL;
    
    if(val == SIMPLE_CONFIG_BLINK){
        if( ath_gpio_in_val(WPS_LED_GPIO) == 0 ){
            initial_led_state = WPS_LED_ON;
        }else{ 
            initial_led_state = WPS_LED_OFF;
        }
    }

	if ((val == SIMPLE_CONFIG_BLINK) && !wps_led_blinking) { /* wps LED blinking */
		wps_led_blinking = 1;
		simple_config_led_state = SIMPLE_CONFIG_BLINK;
		ath_gpio_out_val(WPS_LED_GPIO, WPS_LED_ON);
		OS_CANCEL_TIMER(&os_timer_t);
		OS_INIT_TIMER(NULL, &os_timer_t, wps_led_blink, &os_timer_t);
		OS_SET_TIMER(&os_timer_t, 1000);
	} else if (val == SIMPLE_CONFIG_FAIL) {	/* WPS failed */
		wps_led_blinking = 0;
		simple_config_led_state = SIMPLE_CONFIG_FAIL;
		ath_gpio_out_val(WPS_LED_GPIO, WPS_LED_ON);
		OS_CANCEL_TIMER(&os_timer_t);
		OS_INIT_TIMER(NULL, &os_timer_t, wps_led_fail, &os_timer_t);
		OS_SET_TIMER(&os_timer_t, 200);
	} else if (val == SIMPLE_CONFIG_ON) {	/* WPS Success */
		wps_led_blinking = 0;
		simple_config_led_state = SIMPLE_CONFIG_ON;
		OS_CANCEL_TIMER(&os_timer_t);
		ath_gpio_out_val(WPS_LED_GPIO, WPS_LED_ON);
		OS_INIT_TIMER(NULL, &os_timer_t, wps_led_success, &os_timer_t);
		OS_SET_TIMER(&os_timer_t, 120000);
	} else if (val == SIMPLE_CONFIG_OFF) {	/* wps LED off */
		wps_led_blinking = 0;
		simple_config_led_state = SIMPLE_CONFIG_OFF;
		OS_CANCEL_TIMER(&os_timer_t);
		ath_gpio_out_val(WPS_LED_GPIO, initial_led_state);
	}

	return count;
}
Exemplo n.º 10
0
int ieee80211_mlme_vdetach(struct ieee80211vap *vap)
{
    ieee80211_mlme_priv_t    mlme_priv = vap->iv_mlme_priv;
    int                      ftype;

    if (mlme_priv == NULL) {
        ASSERT(mlme_priv);
        return -1; /* already detached ? */
    }

    OS_CANCEL_TIMER(&mlme_priv->im_timeout_timer);
    OS_FREE_TIMER(&mlme_priv->im_timeout_timer);
	
    switch(vap->iv_opmode) {
    case IEEE80211_M_IBSS:
        mlme_adhoc_vdetach(vap);
        break;
    case IEEE80211_M_STA:
        mlme_sta_vdetach(vap);
        break;
    default:
        break;
    } 
    OS_FREE(mlme_priv);
    vap->iv_mlme_priv = NULL;

    /* Free app ie buffers */
    for (ftype = 0; ftype < IEEE80211_FRAME_TYPE_MAX; ftype++) {
        if (vap->iv_app_ie[ftype].ie) {
            OS_FREE(vap->iv_app_ie[ftype].ie);
            vap->iv_app_ie[ftype].ie = NULL;
            vap->iv_app_ie[ftype].length = 0;
        }
    }
    /* Make sure we have release all the App IE */
    for (ftype = 0; ftype < IEEE80211_FRAME_TYPE_MAX; ftype++) {
        ASSERT(LIST_EMPTY(&vap->iv_app_ie_list[ftype]));
    }

    /* Free opt ie buffer */
    if (vap->iv_opt_ie.ie) {
        OS_FREE(vap->iv_opt_ie.ie);
        vap->iv_opt_ie.ie = NULL;
        vap->iv_opt_ie.length = 0;
    }

    if (vap->iv_beacon_copy_buf) {
        void *pTmp = vap->iv_beacon_copy_buf;
        vap->iv_beacon_copy_buf = NULL;
        vap->iv_beacon_copy_len = 0;
        OS_FREE(pTmp);
    }

    return 0;
}
Exemplo n.º 11
0
Arquivo: gpio.c Projeto: jhbsz/102
static OS_TIMER_FUNC(wps_led_fail)
{
	static int WPSled = WPS_LED_ON, sec = 0;
	ath_gpio_out_val(WPS_LED_GPIO, WPSled);
	WPSled = !WPSled;
	sec++;
	if (sec < 250 * 5) {//Keep blinking for 250 seconds & timer callback kicks in every 200 ms
		OS_SET_TIMER(&os_timer_t, 200);
	} else {
		sec = 0;
		wps_led_blinking = 0;
		OS_CANCEL_TIMER(&os_timer_t);
		ath_gpio_out_val(WPS_LED_GPIO, initial_led_state);
	}
}
Exemplo n.º 12
0
void stop_current_scan(struct ath_softc *sc)
{
    struct ath_spectral *spectral = sc->sc_spectral;

    if (spectral == NULL) {
		SPECTRAL_DPRINTK(sc, ATH_DEBUG_SPECTRAL1, "%s: sc_spectral is NULL, HW may not be spectral capable\n",
			__func__);
		return;
    }

    ath_hal_stop_spectral_scan(sc->sc_ah);
#ifdef SPECTRAL_CLASSIFIER_IN_KERNEL
    OS_CANCEL_TIMER(&spectral->classify_timer);
#endif
#ifdef SPECTRAL_DEBUG_TIMER
    OS_CANCEL_TIMER(&spectral->debug_timer);
#endif
    if( spectral->classify_scan) {
        printk("%s - control chan detects=%d extension channel detects=%d above_dc_detects=%d below_dc_detects=%d\n", __func__,spectral->detects_control_channel, spectral->detects_extension_channel, spectral->detects_above_dc, spectral->detects_below_dc);
        spectral->detects_control_channel=0;
        spectral->detects_extension_channel=0;
        spectral->detects_above_dc=0;
        spectral->detects_below_dc=0;
        spectral->classify_scan = 0;
        print_detection(sc);
    }
    
    spectral->this_scan_phy_err = sc->sc_phy_stats[sc->sc_curmode].ast_rx_phyerr - spectral->cached_phy_err;
    spectral->send_single_packet = 0;

    spectral->ctl_eacs_avg_rssi=SPECTRAL_EACS_RSSI_THRESH;
    spectral->ext_eacs_avg_rssi=SPECTRAL_EACS_RSSI_THRESH;

    spectral->ctl_eacs_spectral_reports=0;
    spectral->ext_eacs_spectral_reports=0;
}
Exemplo n.º 13
0
Arquivo: gpio.c Projeto: jhbsz/102
static OS_TIMER_FUNC(wps_led_blink)
{
	static int WPSled = WPS_LED_ON, sec = 0;
	ath_gpio_out_val(WPS_LED_GPIO, WPSled);
	WPSled = !WPSled;
	sec++;
	if (sec < WPS_TIME_OUT) {
		OS_SET_TIMER(&os_timer_t, 1000);
	} else {
		sec = 0;
		wps_led_blinking = 0;
		OS_CANCEL_TIMER(&os_timer_t);
		ath_gpio_out_val(WPS_LED_GPIO, initial_led_state);
	}
}
/* END ADD: c00217102 2012-8-12 FOR WS323 */
static OS_TIMER_FUNC(wps_led_blink)
{
	gpio_wps_other_led_off();
	
	ath_gpio_out_val(wps_led_gpio, WPSled);
	WPSled = !WPSled;
	sec++;
	if (sec < 130) {        
		OS_SET_TIMER(&os_timer_t, 1000);
	} else {
		sec = 0;
		OS_CANCEL_TIMER(&os_timer_t);
		WPSled=WPS_LED_OFF;
		ath_gpio_out_val(wps_led_gpio, WPSled);
		simple_config_led_state = SIMPLE_CONFIG_OFF;
	}
}
Exemplo n.º 15
0
void dfs_nol_timer_cleanup(struct ath_dfs *dfs)
{
    struct dfs_nolelem *nol = dfs->dfs_nol, *prev;

    /* First Cancel timer */
    while (nol) {
        OS_CANCEL_TIMER(&nol->nol_timer);
        nol = nol->nol_next;
    }
    /* Free NOL elem, don't mix this while loop with above loop */
    nol = dfs->dfs_nol;
    while (nol) {
        prev = nol;
        nol = nol->nol_next;
        OS_FREE(prev);
    }
    return;
}
Exemplo n.º 16
0
/* Cancel any pending MLME request */
int wlan_mlme_cancel(wlan_if_t vaphandle)
{
    struct ieee80211vap           *vap = vaphandle;
    struct ieee80211_mlme_priv    *mlme_priv = vap->iv_mlme_priv;

    IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s\n", __func__);

    /* Cancel pending timer */
    if (OS_CANCEL_TIMER(&mlme_priv->im_timeout_timer) && 
        (mlme_priv->im_request_type != MLME_REQ_NONE)) 
    {
        /* Invoke the timeout routine */
        IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME,"%s", "Trigger early timeout\n");
        mlme_timeout_callback(vap, IEEE80211_STATUS_CANCEL);

    }

    return 0;
}
Exemplo n.º 17
0
/*
 * Delete the given frequency/chwidth from the NOL.
 */
static void
dfs_nol_delete(struct ath_dfs *dfs, u_int16_t delfreq, u_int16_t delchwidth)
{
    struct dfs_nolelem *nol,**prev_next;

    if (dfs == NULL) {
        DFS_DPRINTK(dfs, ATH_DEBUG_DFS, "%s: sc_dfs is NULL\n", __func__);
        return;
    }

    DFS_DPRINTK(dfs, ATH_DEBUG_DFS_NOL,
      "%s: remove channel=%d/%d MHz from NOL\n",
      __func__,
      delfreq, delchwidth);
    prev_next = &(dfs->dfs_nol);
    nol = dfs->dfs_nol;
    while (nol != NULL) {
        if (nol->nol_freq == delfreq && nol->nol_chwidth == delchwidth) {
            *prev_next = nol->nol_next;
            DFS_DPRINTK(dfs, ATH_DEBUG_DFS_NOL,
              "%s removing channel %d/%dMHz from NOL tstamp=%d\n",
                __func__, nol->nol_freq, nol->nol_chwidth,
                (adf_os_ticks_to_msecs(adf_os_ticks()) / 1000));
            OS_CANCEL_TIMER(&nol->nol_timer);
            OS_FREE(nol);
            nol = NULL;
            nol = *prev_next;

            /* Update the NOL counter */
            dfs->dfs_nol_count--;

            /* Be paranoid! */
            if (dfs->dfs_nol_count < 0) {
                DFS_PRINTK("%s: dfs_nol_count < 0; eek!\n", __func__);
                dfs->dfs_nol_count = 0;
            }

        } else {
            prev_next = &(nol->nol_next);
            nol = nol->nol_next;
        }
    }
}
Exemplo n.º 18
0
Arquivo: gpio.c Projeto: jhbsz/102
static OS_TIMER_FUNC(power_led_blink)
{
	static int power_led_status = POWER_LED_OFF, power_on_timeout = 0;

    OS_CANCEL_TIMER(&power_on_timer);

    if (power_on_finish) {
		ath_gpio_out_val(POWER_ON_GLED_GPIO, POWER_LED_ON);
    } else if (++power_on_timeout >= POWER_ON_TIMEOUT) {
        ath_gpio_out_val(POWER_ON_GLED_GPIO, POWER_LED_OFF);  
        ath_gpio_config_input(POWER_ON_GLED_GPIO);
        ath_gpio_config_output(POWER_ON_RLED_GPIO);
        ath_gpio_out_val(POWER_ON_RLED_GPIO, POWER_LED_ON);  
    } else {
		ath_gpio_out_val(POWER_ON_GLED_GPIO, power_led_status);
	    power_led_status = !power_led_status;
		OS_SET_TIMER(&power_on_timer, POWER_LED_BLINK_INTERVAL);
    }
}
/* START ADD: c00217102 2012-8-12 FOR WS323 */
static OS_TIMER_FUNC(wps_led_on)
{
	static int WPSled = WPS_LED_ON, secd = 0;
	gpio_wps_other_led_off();
	ath_gpio_out_val(wps_led_gpio, WPSled);
	
	if (secd < 100) 
    {        
        secd++;
        OS_SET_TIMER(&os_timer_t, 100);
	} 
    else 
    {
		secd = 0;
		OS_CANCEL_TIMER(&os_timer_t);
		ath_gpio_out_val(wps_led_gpio, WPS_LED_OFF);        
		simple_config_led_state = SIMPLE_CONFIG_OFF;
        printk("OS_TIMER_FUNC(wps_led_on) over\n");
	}
}
Exemplo n.º 20
0
static void ieee80211_pwrsave_smps_vap_event_handler (ieee80211_vap_t vap, ieee80211_vap_event *event, void *arg)
{
    ieee80211_pwrsave_smps_t smps = (ieee80211_pwrsave_smps_t) arg;

    switch(event->type) {
    case IEEE80211_VAP_UP:
        if (!smps->ips_connected ) {
            smps->ips_connected=TRUE;
            OS_SET_TIMER(&smps->ips_timer,IEEE80211_PWRSAVE_TIMER_INTERVAL);
        }
        break;
    case IEEE80211_VAP_FULL_SLEEP:
    case IEEE80211_VAP_DOWN:
        OS_CANCEL_TIMER(&smps->ips_timer);
        smps->ips_connected = FALSE;
        break;
    default:
        break;
    }
}
Exemplo n.º 21
0
int ieee80211_mlme_auth_request_btamp(wlan_if_t vaphandle, u_int8_t *peer_addr, u_int32_t timeout)
{
    struct ieee80211vap           *vap = vaphandle;
    struct ieee80211_mlme_priv    *mlme_priv = vap->iv_mlme_priv;
    struct ieee80211_node         *ni = NULL;
    int                           error = 0;

    IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s\n", __func__);
    
    ni = ieee80211_find_txnode(vap, peer_addr);
    //ni = ieee80211_find_node(&vap->iv_ic->ic_sta, peer_addr);

    if (ni == NULL) {
        return EINVAL;
    }

    /* Wait for auth seq number 2 (open response) */
    ASSERT(mlme_priv->im_request_type == MLME_REQ_NONE);
    mlme_priv->im_request_type = MLME_REQ_AUTH;
    mlme_priv->im_expected_auth_seq_number = IEEE80211_AUTH_OPEN_RESPONSE;

    /* Set the timeout timer for authenticate failure case */
    OS_SET_TIMER(&mlme_priv->im_timeout_timer, timeout);

    /*  Send the authentication packet */
    error = ieee80211_send_auth(ni, IEEE80211_AUTH_OPEN_REQUEST, 0, NULL, 0);
    ieee80211_free_node(ni);
    if (error) {
        goto err;
    }

    return error;

err:
    mlme_priv->im_request_type = MLME_REQ_NONE;
    OS_CANCEL_TIMER(&mlme_priv->im_timeout_timer);
    return error;
}
Exemplo n.º 22
0
static int mlme_assoc_reassoc_request_btamp(wlan_if_t vaphandle, u_int8_t *mac_addr,
                                            int reassoc, u_int8_t *prev_bssid, u_int32_t timeout)
{
    struct ieee80211vap           *vap = vaphandle;
    struct ieee80211_mlme_priv    *mlme_priv = vap->iv_mlme_priv;
    struct ieee80211_node         *ni = NULL;
    int                           error = 0;

    IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s\n", __func__);

    ni = ieee80211_find_txnode(vap, mac_addr);
    //ni = ieee80211_find_node(&vap->iv_ic->ic_sta, mac_addr);

    if (ni == NULL) {
        return EINVAL;
    }

    ASSERT(mlme_priv->im_request_type == MLME_REQ_NONE);
    mlme_priv->im_request_type = reassoc ? MLME_REQ_REASSOC : MLME_REQ_ASSOC;

    /* Set the timeout timer for association failure case */
    OS_SET_TIMER(&mlme_priv->im_timeout_timer, timeout);

    /* Transmit frame */
    error = ieee80211_send_assoc(ni, reassoc, prev_bssid);
    ieee80211_free_node(ni);
    if (error) {
        goto err;
    }

    return error;

err:
    mlme_priv->im_request_type = MLME_REQ_NONE;
    OS_CANCEL_TIMER(&mlme_priv->im_timeout_timer);
    return error;
}
Exemplo n.º 23
0
void ieee80211_prdperfstats_stop(struct ieee80211com *ic)
{
    OS_CANCEL_TIMER(&(ic->ic_prdperfstats_timer));
}
Exemplo n.º 24
0
void mlme_recv_auth_sta(struct ieee80211_node *ni,
                        u_int16_t             algo, 
                        u_int16_t             seq, 
                        u_int16_t             status_code,
                        u_int8_t              *challenge, 
                        u_int8_t              challenge_length, 
                        wbuf_t                wbuf)
{
    struct ieee80211vap           *vap = ni->ni_vap;
    struct ieee80211_mlme_priv    *mlme_priv = vap->iv_mlme_priv;

    IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s\n", __func__);

    if (mlme_priv->im_request_type != MLME_REQ_AUTH) {
        IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: invalid request type\n", 
            __func__,
            mlme_priv->im_request_type);

        return;
    }
    /* Validate algo */
    if (algo == IEEE80211_AUTH_ALG_SHARED) {
        if (!RSN_AUTH_IS_SHARED_KEY(&vap->iv_rsn)) {
            IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: Received a shared auth response in open mode.\n", 
                __func__);
        }
        else {
            /* Mark node as shared key authentication */
            RSN_RESET_AUTHMODE(&ni->ni_rsn);
            RSN_SET_AUTHMODE(&ni->ni_rsn, IEEE80211_AUTH_SHARED);
        }
    }

    /* Validate seq */
    if (seq != mlme_priv->im_expected_auth_seq_number) {
        IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: Invalid seq %d,%d\n", 
            __func__,
            seq, mlme_priv->im_expected_auth_seq_number);
        return;
    }

    if (RSN_AUTH_IS_SHARED_KEY(&vap->iv_rsn) && 
        (seq == IEEE80211_AUTH_SHARED_CHALLENGE) &&
        (status_code == IEEE80211_STATUS_SUCCESS)) 
    {
        /* Send the challenge response authentication packet. 
         * We don't care if the send fails. If it does, the timeout routine will do
         * the necessary cleanup.
         */
        ieee80211_send_auth(ni, seq + 1, 0, challenge, challenge_length);
        mlme_priv->im_expected_auth_seq_number = IEEE80211_AUTH_SHARED_PASS;
        return;
    }

    if (!OS_CANCEL_TIMER(&mlme_priv->im_timeout_timer)) {
        IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: Timed-out already\n", __func__);
        return;
    }

    IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: mlme_auth_complete\n", __func__);

    /* Request complete */
    mlme_priv->im_request_type = MLME_REQ_NONE;

    /* Authentication complete (success or failure) */
    IEEE80211_DELIVER_EVENT_MLME_AUTH_COMPLETE(vap, status_code);
}
Exemplo n.º 25
0
/* Receive assoc/reassoc response 
 * - the caller of this routine validates the frame and ensures that the opmode == STA
 */
void ieee80211_mlme_recv_assoc_response(struct ieee80211_node *ni, 
                                        int                   subtype,
                                        u_int16_t             capability, 
                                        u_int16_t             status_code, 
                                        u_int16_t             aid,
                                        u_int8_t              *ie_data, 
                                        u_int32_t             ie_length, 
                                        wbuf_t                wbuf)
{
    struct ieee80211vap           *vap = ni->ni_vap;
    struct ieee80211_mlme_priv    *mlme_priv = vap->iv_mlme_priv;
    struct ieee80211com           *ic = ni->ni_ic;    
    int                           mlme_request_type = mlme_priv->im_request_type;
    int                           error;
    u_int32_t                     rxlinkspeed, txlinkspeed; /* bits/sec */

    IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s im_request_type=%d status=%d (0x%08X)\n", 
        __func__,
        mlme_priv->im_request_type,
        status_code, status_code);

    /* Ignore if no request in progress */
    if ((mlme_priv->im_request_type != MLME_REQ_ASSOC) &&
        (mlme_priv->im_request_type != MLME_REQ_REASSOC))
    {
        IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: Incorrect request type %d\n", 
            __func__, mlme_priv->im_request_type);
        return;
    }

    if (!OS_CANCEL_TIMER(&mlme_priv->im_timeout_timer)) {
        IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: Timed-out already\n", __func__);
        return;
    }

    if (status_code != IEEE80211_STATUS_SUCCESS) {
        goto complete;
    }

    /* Validate AID */
    aid  &= ~IEEE80211_FIELD_TYPE_AID;
    if ((aid > 2007) || (aid == 0))
    {
        IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: Association response contains invalid AID=%d\n", __func__, aid);
        status_code = IEEE80211_STATUS_UNSPECIFIED;
        goto complete;
    }

    error = mlme_process_asresp_elements(ni, ie_data, ie_length);
    if (error) {
        IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: mlme_process_asresp_elements failed\n", __func__);
        status_code = IEEE80211_STATUS_UNSPECIFIED;
        goto complete;
    }

    /* Association successful */

complete:
    switch (mlme_priv->im_request_type) {
    case MLME_REQ_ASSOC:
        IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: mlme_assoc_complete status %d\n", __func__, status_code);
        if (subtype != IEEE80211_FC0_SUBTYPE_ASSOC_RESP) {
			IEEE80211_DPRINTF(vap, IEEE80211_MSG_ANY, "%s: mlme_assoc_complete status type mismatched %d\n", __func__, subtype);
			return;
        }
        break;

    case MLME_REQ_REASSOC:
        IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: mlme_reassoc_complete status %d\n", __func__, status_code);
        if (subtype != IEEE80211_FC0_SUBTYPE_REASSOC_RESP) {
			IEEE80211_DPRINTF(vap, IEEE80211_MSG_ANY, "%s: mlme_assoc_complete status type mismatched %d\n", __func__, subtype);
			return;
        }
        break;

    default:
        IEEE80211_DPRINTF(vap, IEEE80211_MSG_ANY, "%s: mlme_reassoc_complete status %d unexpected request type %d\n", 
            __func__, status_code, mlme_priv->im_request_type);
        return;
    }

    /* Request complete */
    mlme_priv->im_request_type = MLME_REQ_NONE;

    if (status_code == IEEE80211_STATUS_SUCCESS) {
        ASSERT(aid != 0);
        ni->ni_associd = aid;
        ni->ni_assoctime = OS_GET_TICKS() - ni->ni_assocstarttime;
#if ATH_SUPPORT_HTC
        ieee80211_update_node_target(ni, ni->ni_vap);
#endif            

        /* Association successful, put underlying H/W into ready state */
        ieee80211_vap_start(vap);
		/*AUTELAN-Added-Begin:Deleted by duanmingzhe for RIFS+LDPC issue*/
        //if (ni->ni_htcap & IEEE80211_HTCAP_C_ADVCODING)
        //    ic->ic_enable_rifs_ldpcwar(ni, 0);
        //else
        //    ic->ic_enable_rifs_ldpcwar(ni, 1);  
		/*AUTELAN-Added-End:Deleted by duanmingzhe for RIFS+LDPC issue*/      
    }

    /* indicate linkspeed */
     mlme_get_linkrate(ni, &rxlinkspeed, &txlinkspeed);
     IEEE80211_DELIVER_EVENT_LINK_SPEED(vap, rxlinkspeed, txlinkspeed);

    /* Association complete (success or failure) */
    switch (mlme_request_type) {
    case MLME_REQ_ASSOC:
        IEEE80211_DELIVER_EVENT_MLME_ASSOC_COMPLETE(vap, status_code, aid, wbuf);
        break;

    case MLME_REQ_REASSOC:
        IEEE80211_DELIVER_EVENT_MLME_REASSOC_COMPLETE(vap, status_code, aid, wbuf);
        break;

    default:
        break;
    }
}
Exemplo n.º 26
0
void mlme_recv_auth_btamp(struct ieee80211_node *ni,
                          u_int16_t algo, u_int16_t seq, u_int16_t status_code,
                          u_int8_t *challenge, u_int8_t challenge_length, wbuf_t wbuf)
{

    struct ieee80211vap           *vap = ni->ni_vap;
    struct ieee80211_mlme_priv    *mlme_priv = vap->iv_mlme_priv;
    struct ieee80211_frame        *wh;
    u_int16_t                     indication_status = IEEE80211_STATUS_SUCCESS,response_status = IEEE80211_STATUS_SUCCESS ;
    bool                          send_auth_response=true, indicate=true;

    wh = (struct ieee80211_frame *) wbuf_header(wbuf);
    /* AP must be up and running */
    if (!mlme_priv->im_connection_up || ieee80211_vap_ready_is_clear(vap)) {
        return;
    }

    IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_AUTH, wh->i_addr2,
                       "recv auth frame with algorithm %d seq %d \n", algo, seq);

    do {

        /* Check node existance for the peer */
        if (ni == vap->iv_bss) {
            return;
        } else {
            ieee80211_ref_node(ni);
        }

        /* Validate algo */
        if (algo == IEEE80211_AUTH_ALG_OPEN) {
            if (mlme_priv->im_expected_auth_seq_number) {
                send_auth_response = false;
                indicate = false;
                if (seq == mlme_priv->im_expected_auth_seq_number) {
                    if (!OS_CANCEL_TIMER(&mlme_priv->im_timeout_timer)) {
                        IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: Timed-out already\n", __func__);
                        break;
                    }

                    IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s: mlme_auth_complete\n", __func__);

                    /* Request complete */
                    mlme_priv->im_request_type = MLME_REQ_NONE;

                    /* Authentication complete (success or failure) */
                    IEEE80211_DELIVER_EVENT_MLME_AUTH_COMPLETE(vap, status_code);
                    vap->iv_mlme_priv->im_expected_auth_seq_number = 0;
                } else {
                    break;
                }
            } else {
                if (seq != IEEE80211_AUTH_OPEN_REQUEST) {
                    response_status = IEEE80211_STATUS_SEQUENCE;
                    indication_status = IEEE80211_STATUS_SEQUENCE;
                    break;
                } else {
                    indicate = true;
                    send_auth_response = true;
                }
            }
        } else if (algo == IEEE80211_AUTH_ALG_SHARED) {
            response_status = IEEE80211_STATUS_ALG;
            indication_status = IEEE80211_STATUS_ALG;
            break;
        } else {
            IEEE80211_DPRINTF(vap, IEEE80211_MSG_AUTH | IEEE80211_MSG_CRYPTO,
                              "[%s] auth: unsupported algorithm %d \n",ether_sprintf(wh->i_addr2),algo);
            vap->iv_stats.is_rx_auth_unsupported++;
            response_status = IEEE80211_STATUS_ALG;
            indication_status = IEEE80211_STATUS_ALG;
            break;
        }
    } while (FALSE);

    IEEE80211_DELIVER_EVENT_MLME_AUTH_INDICATION(vap, ni->ni_macaddr, indication_status);

    if (send_auth_response) {
        ieee80211_send_auth(ni, seq + 1, response_status, NULL, 0);
    }

    if (ni) {
        if (indication_status != IEEE80211_STATUS_SUCCESS ){
            /* auth is not success, remove the node from node table*/
            ieee80211_node_leave(ni);
        }
        /*
         * release the reference created at the begining of the case above
         * either by alloc_node or ref_node.
         */ 
        ieee80211_free_node(ni);
    }
}
Exemplo n.º 27
0
void
ath_process_spectraldata(struct ath_spectral *spectral, struct ath_buf *bf, struct ath_rx_status *rxs, u_int64_t fulltsf)
{
#define EXT_CH_RADAR_FOUND          0x02
#define PRI_CH_RADAR_FOUND          0x01
#define EXT_CH_RADAR_EARLY_FOUND    0x04
#define SPECTRAL_SCAN_DATA          0x10
#define DEFAULT_CHAN_NOISE_FLOOR    -110

    int i = 0;
    struct samp_msg_params params;

    u_int8_t rssi             = 0;
    u_int8_t control_rssi     = 0;
    u_int8_t extension_rssi   = 0;
    u_int8_t combined_rssi    = 0;
    u_int8_t max_exp          = 0;
    u_int8_t max_scale        = 0;
    u_int8_t dc_index         = 0;
    u_int8_t lower_dc         = 0;
    u_int8_t upper_dc         = 0;
    u_int8_t ext_rssi         = 0;

    int8_t inv_control_rssi     = 0;
    int8_t inv_combined_rssi    = 0;
    int8_t inv_extension_rssi   = 0;
    int8_t temp_nf              = 0;


    u_int8_t pulse_bw_info      = 0;
    u_int8_t pulse_length_ext   = 0;
    u_int8_t pulse_length_pri   = 0;

    u_int32_t tstamp            = 0;

    u_int16_t datalen           = 0;
    u_int16_t max_mag           = 0;
    u_int16_t newdatalen        = 0;
    u_int16_t already_copied    = 0;
    u_int16_t maxmag_upper      = 0;

    u_int8_t maxindex_upper     = 0;
    u_int8_t max_index          = 0;
    
    int bin_pwr_count   = 0;

    u_int32_t *last_word_ptr        = NULL;
    u_int32_t *secondlast_word_ptr  = NULL;

    u_int8_t *byte_ptr          = NULL;
    u_int8_t *fft_data_end_ptr  = NULL;

    u_int8_t last_byte_0 = 0;
    u_int8_t last_byte_1 = 0;
    u_int8_t last_byte_2 = 0;
    u_int8_t last_byte_3 = 0;

    u_int8_t secondlast_byte_0 = 0;
    u_int8_t secondlast_byte_1 = 0;
    u_int8_t secondlast_byte_2 = 0;
    u_int8_t secondlast_byte_3 = 0;

    HT20_FFT_PACKET fft_20;
    HT40_FFT_PACKET fft_40;

    u_int8_t *fft_data_ptr  = NULL;
    u_int8_t *fft_src_ptr   = NULL;
    u_int8_t *data_ptr      = NULL;

    int8_t cmp_rssi = -110;
    int8_t rssi_up  = 0;
    int8_t rssi_low = 0;

    static u_int64_t last_tsf       = 0;
    static u_int64_t send_tstamp    = 0;

    int8_t nfc_control_rssi     = 0;
    int8_t nfc_extension_rssi   = 0;

    int peak_freq   = 0;
    int nb_lower    = 0;
    int nb_upper    = 0;

    int8_t ctl_chan_noise_floor = DEFAULT_CHAN_NOISE_FLOOR;
    int8_t ext_chan_noise_floor = DEFAULT_CHAN_NOISE_FLOOR;
    struct ath_softc* sc        = NULL;
    SPECTRAL_OPS* p_sops        = NULL;

    if (((rxs->rs_phyerr != HAL_PHYERR_RADAR)) &&
        ((rxs->rs_phyerr != HAL_PHYERR_FALSE_RADAR_EXT)) &&
        ((rxs->rs_phyerr != HAL_PHYERR_SPECTRAL))) {
        printk("%s : Unknown PHY error (0x%x)\n", __func__, rxs->rs_phyerr);
        return;
    }

    if (spectral == NULL) {
        printk("Spectral Module not attached\n");
        return;
    }

    sc     = GET_SPECTRAL_ATHSOFTC(spectral);
    p_sops = GET_SPECTRAL_OPS(spectral);

    spectral->ath_spectral_stats.total_phy_errors++;

    /* Get pointer to data & timestamp*/
    datalen = rxs->rs_datalen;
    tstamp  = (rxs->rs_tstamp & SPECTRAL_TSMASK);

    /* check for valid data length */
    if ((!datalen) || (datalen < spectral->spectral_data_len - 1))  {
        spectral->ath_spectral_stats.datalen_discards++;
        return;
    }


    /* WAR: Never trust combined RSSI on radar pulses for <=
     * OWL2.0. For short pulses only the chain 0 rssi is present
     * and remaining descriptor data is all 0x80, for longer
     * pulses the descriptor is present, but the combined value is
     * inaccurate. This HW capability is queried in spectral_attach and stored in
     * the sc_spectral_combined_rssi_ok flag.*/

    if (spectral->sc_spectral_combined_rssi_ok) {
        rssi = (u_int8_t) rxs->rs_rssi;
    } else {
        rssi = (u_int8_t) rxs->rs_rssi_ctl0;
    }

    /* get rssi values */
    combined_rssi   = rssi;
    control_rssi    = (u_int8_t) rxs->rs_rssi_ctl0;
    extension_rssi  = (u_int8_t) rxs->rs_rssi_ext0;
    ext_rssi        = (u_int8_t) rxs->rs_rssi_ext0;

    /*
     * If the combined RSSI is less than a particular threshold, this pulse is of no
     * interest to the classifier, so discard it here itself
     * except when noise power cal is required (then we want all rssi values)
     */
    inv_combined_rssi = fix_rssi_inv_only(combined_rssi);

    if (inv_combined_rssi < 5 && !spectral->sc_spectral_noise_pwr_cal) {
        return;
    }

    last_word_ptr       = (u_int32_t *)(((u_int8_t*)bf->bf_vdata) + datalen - (datalen%4));
    secondlast_word_ptr = last_word_ptr-1;

    byte_ptr    =   (u_int8_t*)last_word_ptr;
    last_byte_0 =   (*(byte_ptr)   & 0xff);
    last_byte_1 =   (*(byte_ptr+1) & 0xff);
    last_byte_2 =   (*(byte_ptr+2) & 0xff);
    last_byte_3 =   (*(byte_ptr+3) & 0xff);

    byte_ptr            =   (u_int8_t*)secondlast_word_ptr;
    secondlast_byte_0   =   (*(byte_ptr)   & 0xff);
    secondlast_byte_1   =   (*(byte_ptr+1) & 0xff);
    secondlast_byte_2   =   (*(byte_ptr+2) & 0xff);
    secondlast_byte_3   =   (*(byte_ptr+3) & 0xff);


    switch((datalen & 0x3)) {
        case 0:
            pulse_bw_info       = secondlast_byte_3;
            pulse_length_ext    = secondlast_byte_2;
            pulse_length_pri    = secondlast_byte_1;
            byte_ptr            = (u_int8_t*)secondlast_word_ptr;
            fft_data_end_ptr    = (byte_ptr);
            break;
        case 1:
            pulse_bw_info       = last_byte_0;
            pulse_length_ext    = secondlast_byte_3;
            pulse_length_pri    = secondlast_byte_2;
            byte_ptr            = (u_int8_t*)secondlast_word_ptr;
            fft_data_end_ptr    = (byte_ptr+2);
            break;
        case 2:
            pulse_bw_info       = last_byte_1;
            pulse_length_ext    = last_byte_0;
            pulse_length_pri    = secondlast_byte_3;
            byte_ptr            = (u_int8_t*)secondlast_word_ptr;
            fft_data_end_ptr    = (byte_ptr+3);
            break;
        case 3:
            pulse_bw_info       = last_byte_2;
            pulse_length_ext    = last_byte_1;
            pulse_length_pri    = last_byte_0;
            byte_ptr            = (u_int8_t*)last_word_ptr;
            fft_data_end_ptr    = (byte_ptr);
            break;
        default:
             printk(  "datalen mod4=%d spectral_data_len=%d\n", (datalen%4), spectral->spectral_data_len);
    }

    /*
     * Only the last 3 bits of the BW info are relevant, 
     * they indicate which channel the radar was detected in.
     */
    pulse_bw_info &= 0x17;

    if (pulse_bw_info & SPECTRAL_SCAN_DATA) {

        if (datalen > spectral->spectral_data_len + 2) {
            //printk("Invalid spectral scan datalen = %d\n", datalen);
            return;
        }

        if (spectral->num_spectral_data == 0) {
            spectral->first_tstamp = tstamp;
            spectral->max_rssi = -110;
            //printk( "First FFT data tstamp = %u rssi=%d\n", tstamp, fix_rssi_inv_only(combined_rssi));
        }

        spectral->num_spectral_data++;

        OS_MEMZERO(&fft_40, sizeof (fft_40));
        OS_MEMZERO(&fft_20, sizeof (fft_20));

        if (spectral->sc_spectral_20_40_mode) {
            fft_data_ptr = (u_int8_t*)&fft_40.lower_bins.bin_magnitude[0];
        } else {
            fft_data_ptr = (u_int8_t*)&fft_20.lower_bins.bin_magnitude[0];
        }

        byte_ptr = fft_data_ptr;

        if (datalen == spectral->spectral_data_len) {

            if (spectral->sc_spectral_20_40_mode) {
                // HT40 packet, correct length
                OS_MEMCPY(&fft_40, (u_int8_t*)(bf->bf_vdata), datalen);
            } else {
                // HT20 packet, correct length
                OS_MEMCPY(&fft_20, (u_int8_t*)(bf->bf_vdata), datalen);
            }

        }

      /* This happens when there is a missing byte because CCK is enabled.
       * This may happen with or without the second bug of the MAC inserting
       * 2 bytes
       */
      if ((datalen == (spectral->spectral_data_len - 1)) ||
          (datalen == (spectral->spectral_data_len + 1))) {

          printk(  "%s %d missing 1 byte datalen=%d expected=%d\n", __func__, __LINE__, datalen, spectral->spectral_data_len);

          already_copied++;

          if (spectral->sc_spectral_20_40_mode) {
              // HT40 packet, missing 1 byte
              // Use the beginning byte as byte 0 and byte 1
              fft_40.lower_bins.bin_magnitude[0]=*(u_int8_t*)(bf->bf_vdata);
              // Now copy over the rest
              fft_data_ptr = (u_int8_t*)&fft_40.lower_bins.bin_magnitude[1];
              OS_MEMCPY(fft_data_ptr, (u_int8_t*)(bf->bf_vdata), datalen);
          } else {
              // HT20 packet, missing 1 byte
              // Use the beginning byte as byte 0 and byte 1
              fft_20.lower_bins.bin_magnitude[0]=*(u_int8_t*)(bf->bf_vdata);
              // Now copy over the rest
              fft_data_ptr = (u_int8_t*)&fft_20.lower_bins.bin_magnitude[1];
              OS_MEMCPY(fft_data_ptr, (u_int8_t*)(bf->bf_vdata), datalen);
          }
      }

      if ((datalen == (spectral->spectral_data_len + 1)) ||
          (datalen == (spectral->spectral_data_len + 2))) {

          //printk(  "%s %d extra bytes datalen=%d expected=%d\n", __func__, __LINE__, datalen, spectral->spectral_data_len);

          if (spectral->sc_spectral_20_40_mode) {// HT40 packet, MAC added 2 extra bytes
              fft_src_ptr = (u_int8_t*)(bf->bf_vdata);

              fft_data_ptr = (u_int8_t*)&fft_40.lower_bins.bin_magnitude[already_copied];

              for( i = 0, newdatalen=0; newdatalen < (SPECTRAL_HT40_DATA_LEN - already_copied); i++) {
                if (i == 30 || i == 32) {
                  continue;
                }

                *(fft_data_ptr+newdatalen)=*(fft_src_ptr+i);
                newdatalen++;
              }
          } else { //HT20 packet, MAC added 2 extra bytes
              fft_src_ptr = (u_int8_t*)(bf->bf_vdata);
              fft_data_ptr = (u_int8_t*)&fft_20.lower_bins.bin_magnitude[already_copied];

              for(i=0, newdatalen=0; newdatalen < (SPECTRAL_HT20_DATA_LEN - already_copied); i++) {
                if (i == 30 || i == 32)
                  continue;

                *(fft_data_ptr+newdatalen)=*(fft_src_ptr+i);
                newdatalen++;
              }
          }
      }

      spectral->total_spectral_data++;

      dc_index = spectral->spectral_dc_index;

      if (spectral->sc_spectral_20_40_mode) {
            max_exp     = (fft_40.max_exp & 0x07);
            byte_ptr    = (u_int8_t*)&fft_40.lower_bins.bin_magnitude[0];

             /* Correct the DC bin value */
            lower_dc = *(byte_ptr+dc_index-1);
            upper_dc = *(byte_ptr+dc_index+1);
            *(byte_ptr+dc_index)=((upper_dc + lower_dc)/2);

       } else {
             max_exp    = (fft_20.max_exp & 0x07);
             byte_ptr   = (u_int8_t*)&fft_20.lower_bins.bin_magnitude[0];

            /* Correct the DC bin value */
            lower_dc = *(byte_ptr+dc_index-1);
            upper_dc = *(byte_ptr+dc_index+1);
            *(byte_ptr+dc_index)=((upper_dc + lower_dc)/2);

       }

        if (p_sops->get_ent_spectral_mask(spectral)) {
            *(byte_ptr+dc_index) &=
                ~((1 << p_sops->get_ent_spectral_mask(spectral)) - 1);
        }

        if (max_exp < 1) {
            max_scale = 1;
        } else {
            max_scale = (2) << (max_exp - 1);
        }

        bin_pwr_count = spectral->spectral_numbins;

        if ((last_tsf  > fulltsf) && (!spectral->classify_scan)) {
            spectral->send_single_packet = 1;
            last_tsf = fulltsf;
        }

        inv_combined_rssi   = fix_rssi_inv_only(combined_rssi);
        inv_control_rssi    = fix_rssi_inv_only(control_rssi);
        inv_extension_rssi  = fix_rssi_inv_only(extension_rssi);

        {
            if (spectral->upper_is_control)
              rssi_up = control_rssi;
            else
              rssi_up = extension_rssi;

            if (spectral->lower_is_control)
              rssi_low = control_rssi;
            else
              rssi_low = extension_rssi;

            nfc_control_rssi = get_nfc_ctl_rssi(spectral, inv_control_rssi, &temp_nf);
            ctl_chan_noise_floor = temp_nf;
            rssi_low = fix_rssi_for_classifier(spectral, rssi_low, spectral->lower_is_control, spectral->lower_is_extension);

            if (spectral->sc_spectral_20_40_mode) {
              rssi_up = fix_rssi_for_classifier(spectral, rssi_up,spectral->upper_is_control,spectral->upper_is_extension);
              nfc_extension_rssi = get_nfc_ext_rssi(spectral, inv_extension_rssi, &temp_nf);
              ext_chan_noise_floor = temp_nf;
            }
        }
        if(sc->sc_ieee_ops->spectral_eacs_update) {
            sc->sc_ieee_ops->spectral_eacs_update(sc->sc_ieee, nfc_control_rssi,
                                                  nfc_extension_rssi, ctl_chan_noise_floor, 
                                                                       ext_chan_noise_floor);
        }

        if (!spectral->sc_spectral_20_40_mode) {
            rssi_up             = 0;
            extension_rssi      = 0;
            inv_extension_rssi  = 0;
            nb_upper            = 0;
            maxindex_upper      = 0;
            maxmag_upper        = 0;
        }

        params.rssi         = inv_combined_rssi;
        params.lower_rssi   = rssi_low;
        params.upper_rssi   = rssi_up;

        if (spectral->sc_spectral_noise_pwr_cal) {
            params.chain_ctl_rssi[0] = fix_rssi_inv_only(rxs->rs_rssi_ctl0);
            params.chain_ctl_rssi[1] = fix_rssi_inv_only(rxs->rs_rssi_ctl1);
            params.chain_ctl_rssi[2] = fix_rssi_inv_only(rxs->rs_rssi_ctl2);
            params.chain_ext_rssi[0] = fix_rssi_inv_only(rxs->rs_rssi_ext0);
            params.chain_ext_rssi[1] = fix_rssi_inv_only(rxs->rs_rssi_ext1);
            params.chain_ext_rssi[2] = fix_rssi_inv_only(rxs->rs_rssi_ext2);
        }

        params.bwinfo       = pulse_bw_info;
        params.tstamp       = tstamp;
        params.max_mag      = max_mag;
        params.max_index    = max_index;
        params.max_exp      = max_scale;
        params.peak         = peak_freq;
        params.pwr_count    = bin_pwr_count;
        params.bin_pwr_data = &byte_ptr;
        params.freq         = p_sops->get_current_channel(spectral);
        if(sc->sc_ieee_ops->spectral_get_freq_loading) {
            params.freq_loading = sc->sc_ieee_ops->spectral_get_freq_loading(sc->sc_ieee);
        }
        else {
            params.freq_loading = 0;
        }
        params.interf_list.count = 0;
        params.max_lower_index   = 0;//maxindex_lower;
        params.max_upper_index   = 0;//maxindex_upper;
        params.nb_lower          = nb_lower;
        params.nb_upper          = nb_upper;
        params.last_tstamp       = spectral->last_tstamp;

        get_nfc_ctl_rssi(spectral, inv_control_rssi, &temp_nf);

        params.noise_floor = (int16_t)temp_nf;

        OS_MEMCPY(&params.classifier_params, &spectral->classifier_params, sizeof(SPECTRAL_CLASSIFIER_PARAMS));

        cmp_rssi = fix_rssi_inv_only (combined_rssi);
        spectral->send_single_packet = 0;

#ifdef SPECTRAL_DEBUG_TIMER
        OS_CANCEL_TIMER(&spectral->debug_timer);
#endif
        spectral->spectral_sent_msg++;
        params.datalen = datalen;

        if (spectral->sc_spectral_20_40_mode) {
            data_ptr = (u_int8_t*)&fft_40.lower_bins.bin_magnitude;
        } else {
            data_ptr = (u_int8_t*)&fft_20.lower_bins.bin_magnitude;
        }

        byte_ptr = (u_int8_t*)data_ptr;
        params.bin_pwr_data = &byte_ptr;

        send_tstamp = p_sops->get_tsf64(spectral);
        spectral_create_samp_msg(spectral, &params);

#ifdef SPECTRAL_CLASSIFIER_IN_KERNEL

        if (spectral->classify_scan && maxindex_lower != (SPECTRAL_HT20_DC_INDEX + 1)) {

            classifier(&spectral->bd_lower, tstamp, spectral->last_tstamp, rssi_low, nb_lower, maxindex_lower);

            if (spectral->sc_spectral_20_40_mode && maxindex_upper != (SPECTRAL_HT40_DC_INDEX)) {
                classifier(&spectral->bd_upper, tstamp, spectral->last_tstamp, rssi_up, nb_upper, maxindex_upper);
            }

            print_detection(sc);
        }

#endif /* SPECTRAL_CLASSIFIER_IN_KERNEL */

        spectral->last_tstamp=tstamp;

        return;
  } else {

      /*
       *  Add a HAL capability that tests if chip is capable of spectral scan.
       *  Probably just a check if its a Merlin and above.
       */
      printk("Non Spectral error\n");
      spectral->ath_spectral_stats.owl_phy_errors++;
  }
#undef EXT_CH_RADAR_FOUND
#undef PRI_CH_RADAR_FOUND
#undef EXT_CH_RADAR_EARLY_FOUND
#undef SPECTRAL_SCAN_DATA
}
static int gpio_simple_config_led_write(struct file *file, const char *buf,
					unsigned long count, void *data)
{
	u_int32_t val;

	if (sscanf(buf, "%d", &val) != 1)
	{
        printk("\n val wrong %d\n", val);
		return -EINVAL;
    }
    printk("\n config_led_write %d \n", val);

	if (val == SIMPLE_CONFIG_ON) {
		printk("\nWPS SIMPLE_CONFIG_ON\n");
	/* WPS Success */		
		simple_config_led_state = SIMPLE_CONFIG_ON;
		OS_CANCEL_TIMER(&os_timer_t);
		WPSled=WPS_LED_ON;
		gpio_wps_other_led_off();
		ath_gpio_out_val(wps_led_gpio, WPSled);
        wps_success_func();
		OS_INIT_TIMER(NULL, &os_timer_t, wps_led_on, &os_timer_t);
		OS_SET_TIMER(&os_timer_t, 100);        
	} else if (val == SIMPLE_CONFIG_OFF) {	/* WPS failed */
		simple_config_led_state = SIMPLE_CONFIG_OFF;
		OS_CANCEL_TIMER(&os_timer_t);
		WPSled=WPS_LED_OFF;
		gpio_wps_other_led_off();
		printk("\nWPS SIMPLE_CONFIG_OFF\n");
		ath_gpio_out_val(wps_led_gpio, WPSled);
	}
    /* START ADD: c00217102 2012-8-12 FOR WS323 */
    else if (val == SIMPLE_CONFIG_OVERLAP)
    {
        
		printk("\nWPS SIMPLE_CONFIG_OVERLAP\n");
		simple_config_led_state = SIMPLE_CONFIG_OVERLAP;
        OS_CANCEL_TIMER(&os_timer_t);
		WPSled=WPS_LED_ON;
		gpio_wps_other_led_off();
		ath_gpio_out_val(wps_led_gpio, WPSled);
		OS_INIT_TIMER(NULL, &os_timer_t, wps_led_overlap, &os_timer_t);
		OS_SET_TIMER(&os_timer_t, 100);
    }else if (val == SIMPLE_CONFIG_INGRESS_ERROR)
    {
		simple_config_led_state = SIMPLE_CONFIG_INGRESS_ERROR;
        OS_CANCEL_TIMER(&os_timer_t);
		WPSled=WPS_LED_ON;
		gpio_wps_other_led_off();
		ath_gpio_out_val(wps_led_gpio, WPSled);
		printk("\nWPS SIMPLE_CONFIG_INGRESS_ERROR\n");
		OS_INIT_TIMER(NULL, &os_timer_t, wps_led_error, &os_timer_t);
		OS_SET_TIMER(&os_timer_t, 100);
    }
	else if (val == SIMPLE_CONFIG_INGRESS)
    {		
		simple_config_led_state = SIMPLE_CONFIG_INGRESS;
        OS_CANCEL_TIMER(&os_timer_t);
		WPSled=WPS_LED_ON;
		gpio_wps_other_led_off();
		ath_gpio_out_val(wps_led_gpio, WPSled);
		printk("\nWPS SIMPLE_CONFIG_INGRESS\n");
		OS_INIT_TIMER(NULL, &os_timer_t, wps_led_ingress, &os_timer_t);
		OS_SET_TIMER(&os_timer_t, 100);
    }

    /* END ADD: c00217102 2012-8-12 FOR WS323 */
    
	return count;
}
Exemplo n.º 29
0
void
dfs_detach(struct ieee80211com *ic)
{
	struct ath_dfs *dfs = (struct ath_dfs *)ic->ic_dfs;
	int n, empty;

	if (dfs == NULL) {
	        DFS_DPRINTK(dfs, ATH_DEBUG_DFS1, "%s: ic_dfs is NULL\n", __func__);
		return;
	}
  
        /* Bug 29099 make sure all outstanding timers are cancelled*/

        if (dfs->ath_radar_tasksched) {
            OS_CANCEL_TIMER(&dfs->ath_dfs_task_timer);
            dfs->ath_radar_tasksched = 0;
        }

	if (dfs->ath_dfstest) {
		OS_CANCEL_TIMER(&dfs->ath_dfstesttimer);
		dfs->ath_dfstest = 0;
	}

#if 0        
#ifndef ATH_DFS_RADAR_DETECTION_ONLY
        if (dfs->ic_dfswait) {
            OS_CANCEL_TIMER(&dfs->ic_dfswaittimer);
            dfs->ath_dfswait = 0;
        }

 		OS_CANCEL_TIMER(&dfs->sc_dfs_war_timer);
	if (dfs->dfs_nol != NULL) {
	    struct dfs_nolelem *nol, *next;
	    nol = dfs->dfs_nol;
                /* Bug 29099 - each NOL element has its own timer, cancel it and 
                   free the element*/
		while (nol != NULL) {
                       OS_CANCEL_TIMER(&nol->nol_timer);
		       next = nol->nol_next;
		       OS_FREE(nol);
		       nol = next;
		}
		dfs->dfs_nol = NULL;
	}
#endif
#endif
        /* Return radar events to free q*/
        dfs_reset_radarq(dfs);
	dfs_reset_alldelaylines(dfs);

        /* Free up pulse log*/
        if (dfs->pulses != NULL) {
                OS_FREE(dfs->pulses);
                dfs->pulses = NULL;
        }

	for (n=0; n<DFS_MAX_RADAR_TYPES;n++) {
		if (dfs->dfs_radarf[n] != NULL) {
			OS_FREE(dfs->dfs_radarf[n]);
			dfs->dfs_radarf[n] = NULL;
		}
	}


	if (dfs->dfs_radartable != NULL) {
		for (n=0; n<256; n++) {
			if (dfs->dfs_radartable[n] != NULL) {
				OS_FREE(dfs->dfs_radartable[n]);
				dfs->dfs_radartable[n] = NULL;
			}
		}
		OS_FREE(dfs->dfs_radartable);
		dfs->dfs_radartable = NULL;
#ifndef ATH_DFS_RADAR_DETECTION_ONLY
		dfs->ath_dfs_isdfsregdomain = 0;
#endif
	}
        
	if (dfs->dfs_b5radars != NULL) {
		OS_FREE(dfs->dfs_b5radars);
		dfs->dfs_b5radars=NULL;
	}

	dfs_reset_ar(dfs);

	ATH_ARQ_LOCK(dfs);
	empty = STAILQ_EMPTY(&(dfs->dfs_arq));
	ATH_ARQ_UNLOCK(dfs);
	if (!empty) {
		dfs_reset_arq(dfs);
	}
        if (dfs->events != NULL) {
                OS_FREE(dfs->events);
                dfs->events = NULL;
        }
       dfs_nol_timer_cleanup(dfs);
	OS_FREE(dfs);

	/* XXX? */
        ic->ic_dfs = NULL;
}
Exemplo n.º 30
0
void
dfs_nol_addchan(struct ath_dfs *dfs, struct ieee80211_channel *chan,
    u_int32_t dfs_nol_timeout)
{
#define TIME_IN_MS 1000
#define TIME_IN_US (TIME_IN_MS * 1000)
    struct dfs_nolelem *nol, *elem, *prev;
    struct dfs_nol_timer_arg *dfs_nol_arg;
    /* XXX for now, assume all events are 20MHz wide */
    int ch_width = 20;

    if (dfs == NULL) {
        DFS_DPRINTK(dfs, ATH_DEBUG_DFS_NOL, "%s: sc_dfs is NULL\n", __func__);
        return;
    }
    nol = dfs->dfs_nol;
    prev = dfs->dfs_nol;
    elem = NULL;
    while (nol != NULL) {
        if ((nol->nol_freq == chan->ic_freq) &&
            (nol->nol_chwidth == ch_width)) {
                nol->nol_start_ticks = adf_os_ticks();
                nol->nol_timeout_ms = dfs_nol_timeout*TIME_IN_MS;
                DFS_DPRINTK(dfs, ATH_DEBUG_DFS_NOL, 
                    "%s: Update OS Ticks for NOL %d MHz / %d MHz\n",
                    __func__, nol->nol_freq, nol->nol_chwidth);
                OS_CANCEL_TIMER(&nol->nol_timer);
                OS_SET_TIMER(&nol->nol_timer, dfs_nol_timeout*TIME_IN_MS);
                return;
        }
        prev = nol;
        nol = nol->nol_next;
    }
    /* Add a new element to the NOL*/
    elem = (struct dfs_nolelem *)OS_MALLOC(dfs->ic->ic_osdev, sizeof(struct dfs_nolelem),GFP_ATOMIC);
    if (elem == NULL) {
        goto bad;
    }
    dfs_nol_arg = (struct dfs_nol_timer_arg *)OS_MALLOC(dfs->ic->ic_osdev, 
                      sizeof(struct dfs_nol_timer_arg), GFP_ATOMIC);
    if (dfs_nol_arg == NULL) {
        OS_FREE(elem);
        goto bad;
    }
    elem->nol_freq = chan->ic_freq;
    elem->nol_chwidth = ch_width;
    elem->nol_start_ticks = adf_os_ticks();
    elem->nol_timeout_ms = dfs_nol_timeout*TIME_IN_MS;
    elem->nol_next = NULL;
    if (prev) {
        prev->nol_next = elem;
    } else {
        /* This is the first element in the NOL */
        dfs->dfs_nol = elem;
    }
    dfs_nol_arg->dfs = dfs;
    dfs_nol_arg->delfreq = elem->nol_freq;
    dfs_nol_arg->delchwidth = elem->nol_chwidth;

    OS_INIT_TIMER(dfs->ic->ic_osdev, &elem->nol_timer, dfs_remove_from_nol,
      dfs_nol_arg);
    OS_SET_TIMER(&elem->nol_timer, dfs_nol_timeout*TIME_IN_MS);

    /* Update the NOL counter */
    dfs->dfs_nol_count++;

    DFS_DPRINTK(dfs, ATH_DEBUG_DFS_NOL,
      "%s: new NOL channel %d MHz / %d MHz\n",
      __func__,
      elem->nol_freq,
      elem->nol_chwidth);
    return;

bad:
    DFS_DPRINTK(dfs, ATH_DEBUG_DFS_NOL | ATH_DEBUG_DFS,
                "%s: failed to allocate memory for nol entry\n", __func__);

#undef TIME_IN_MS
#undef TIME_IN_US
}