Example #1
0
static int
ath_sysctl_tpc(SYSCTL_HANDLER_ARGS)
{
	struct ath_softc *sc = arg1;
	u_int tpc = ath_hal_gettpc(sc->sc_ah);
	int error;

	error = sysctl_handle_int(oidp, &tpc, 0, req);
	if (error || !req->newptr)
		return error;
	return !ath_hal_settpc(sc->sc_ah, tpc) ? EINVAL : 0;
}
Example #2
0
/*
 * Start continuous transmit operation.
 */
static int
tx99_start(struct ath_softc *sc)
{
    static struct ath_tx99_tgt tx99_tgt;
    struct ath_tx99 *tx99 = sc->sc_tx99;
    struct ath_hal *ah = sc->sc_ah;
    int is2GHz = 0;
    adf_nbuf_t 	skb;
    HAL_CHANNEL *c = NULL;
    if(tx99->recv)
    {
        ath_hal_phydisable(ah);
        //adf_os_print("%s: device %s tx99 continuous receive mode\n", __FUNCTION__, adf_net_ifname(sc->sc_ic->ic_dev));
        return 0;
    }
    /* check tx99 running state */
    if(tx99->tx99_state){		/* already active */
        adf_os_print("%s: already running\n", __FUNCTION__);
        return 0;
    }
    /* set tx99 state active */
    tx99->tx99_state = 1;
    /* allocate diag packet buffer */
    tx99->skb = ath_alloc_skb_tx99(sc->sc_osdev, 2000, 32);
    if (tx99->skb == NULL) {
        adf_os_print("%s: unable to allocate skb\n", __FUNCTION__);
        tx99->tx99_state = 0;
        return -ENOMEM;
    }
    skb = tx99->skb;
    /* drain all tx queue */
    ath_drain_txq(sc);
    /*
     * Setup channel using configured frequency+flags.
     */
    if (tx99_channel_setup(sc) != EOK) {
        adf_os_print("%s: unable to setup operation\n", __FUNCTION__);
        tx99->tx99_state = 0;
        adf_nbuf_free(skb);
        return -EIO;
    }
    /*disable desc tpc */
    ath_hal_settpc(ah,0);
    /*
     * Setup tx power limit
     */ 
    c = &sc->sc_curchan; 
    is2GHz = TX99_IS_CHAN_2GHZ(c);
    ath_hal_settxpowlimit(ah,tx99->txpower,0,is2GHz);
    /* set tx99 enable */
    tx99_tgt.txrate = adf_os_htonl(tx99->txrate);
    tx99_tgt.txpower = adf_os_htonl(tx99->txpower);
    tx99_tgt.txchain = adf_os_htonl(tx99->chanmask);
    tx99_tgt.htmode = adf_os_htonl(tx99->htmode);
    tx99_tgt.type = adf_os_htonl(tx99->type);
    tx99_tgt.chtype = adf_os_htonl(TX99_IS_CHAN_5GHZ(c));
    tx99_tgt.txantenna = adf_os_htonl(0);
    if( tx99->txpower < 60 ) /* only update channel pwr if not default MAX power */
        ath_hal_tx99_channel_pwr_update(ah, c, tx99->txpower);
#ifdef ATH_SUPPORT_HTC
    ah_tx99_start(ah, (u_int8_t *)&tx99_tgt);
    /* send diag packet */
    {
        struct  ath_txep *txep;
        adf_nbuf_t 	skb;

        A_STATUS ret;
        adf_nbuf_put_tail(skb, 1500);
        txep = sc->sc_ac2ep[WME_AC_VO];
        /* send packet to target */
        ret = HTCSendPkt(sc->sc_host_htc_handle, NULL ,skb, sc->sc_data_VO_ep);
        if(ret)
        {
            adf_os_print("%s: tx99 fail \n", __FUNCTION__);
            tx99_stop(sc, 0);
        }   
    }
#else
    adf_nbuf_put_tail(skb, 1500);
    if (ath_tx99_tgt_start(sc, tx99_tgt.chtype) != EOK) {
        adf_os_print("%s: tx99 fail \n", __FUNCTION__);
        tx99_stop(sc, 0);
    }
#endif
    /* wait a while to make sure target setting ready */
    adf_os_mdelay(50);
    adf_os_print("%s: continuous transmit started\n", __FUNCTION__);
    return 0;
}