Example #1
0
static HAL_STATUS
v9287EepromGet(struct ath_hal *ah, int param, void *val)
{
#define	CHAN_A_IDX	0
#define	CHAN_B_IDX	1
#define	IS_VERS(op, v)	((pBase->version & AR5416_EEP_VER_MINOR_MASK) op (v))
	HAL_EEPROM_9287 *ee = AH_PRIVATE(ah)->ah_eeprom;
	const MODAL_EEP_9287_HEADER *pModal = &ee->ee_base.modalHeader;
	const BASE_EEP_9287_HEADER *pBase = &ee->ee_base.baseEepHeader;
	uint32_t sum;
	uint8_t *macaddr;
	int i;

	switch (param) {
        case AR_EEP_NFTHRESH_2:
		*(int16_t *)val = pModal->noiseFloorThreshCh[0];
		return HAL_OK;
        case AR_EEP_MACADDR:		/* Get MAC Address */
		sum = 0;
		macaddr = val;
		for (i = 0; i < 6; i++) {
			macaddr[i] = pBase->macAddr[i];
			sum += pBase->macAddr[i];
		}
		if (sum == 0 || sum == 0xffff*3) {
			HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad mac address %s\n",
			    __func__, ath_hal_ether_sprintf(macaddr));
			return HAL_EEBADMAC;
		}
		return HAL_OK;
        case AR_EEP_REGDMN_0:
		return pBase->regDmn[0];
        case AR_EEP_REGDMN_1:
		return pBase->regDmn[1];
        case AR_EEP_OPCAP:
		return pBase->deviceCap;
        case AR_EEP_OPMODE:
		return pBase->opCapFlags;
        case AR_EEP_RFSILENT:
		return pBase->rfSilent;
	case AR_EEP_TXMASK:
		return pBase->txMask;
	case AR_EEP_RXMASK:
		return pBase->rxMask;
	case AR_EEP_OL_PWRCTRL:
		HALASSERT(val == AH_NULL);
		return pBase->openLoopPwrCntl ?  HAL_OK : HAL_EIO;
	case AR_EEP_AMODE:
		return HAL_EIO;		/* no 5GHz for Kiwi */
	case AR_EEP_BMODE:
	case AR_EEP_GMODE:
		HALASSERT(val == AH_NULL);
		return pBase->opCapFlags & AR5416_OPFLAGS_11G ?
		    HAL_OK : HAL_EIO;
	case AR_EEP_32KHZCRYSTAL:
	case AR_EEP_COMPRESS:
	case AR_EEP_FASTFRAME:		/* XXX policy decision, h/w can do it */
	case AR_EEP_WRITEPROTECT:	/* NB: no write protect bit */
		HALASSERT(val == AH_NULL);
		/* fall thru... */
	case AR_EEP_MAXQCU:		/* NB: not in opCapFlags */
	case AR_EEP_KCENTRIES:		/* NB: not in opCapFlags */
		return HAL_EIO;
	case AR_EEP_AES:
	case AR_EEP_BURST:
        case AR_EEP_RFKILL:
	case AR_EEP_TURBO5DISABLE:
	case AR_EEP_TURBO2DISABLE:
		HALASSERT(val == AH_NULL);
		return HAL_OK;
	case AR_EEP_ANTGAINMAX_2:
		*(int8_t *) val = ee->ee_antennaGainMax[1];
		return HAL_OK;
	case AR_EEP_PWR_TABLE_OFFSET:
		*(int8_t *) val = pBase->pwrTableOffset;
		return HAL_OK;
	case AR_EEP_TEMPSENSE_SLOPE:
		if (IS_VERS(>=,  AR9287_EEP_MINOR_VER_2))
			*(int8_t *)val = pBase->tempSensSlope;
		else
			*(int8_t *)val = 0;
		return HAL_OK;
	case AR_EEP_TEMPSENSE_SLOPE_PAL_ON:
		if (IS_VERS(>=,  AR9287_EEP_MINOR_VER_3))
			*(int8_t *)val = pBase->tempSensSlopePalOn;
		else
Example #2
0
static HAL_STATUS
v4kEepromGet(struct ath_hal *ah, int param, void *val)
{
#define	CHAN_A_IDX	0
#define	CHAN_B_IDX	1
#define	IS_VERS(op, v)	((pBase->version & AR5416_EEP_VER_MINOR_MASK) op (v))
    HAL_EEPROM_v4k *ee = AH_PRIVATE(ah)->ah_eeprom;
    const MODAL_EEP4K_HEADER *pModal = &ee->ee_base.modalHeader;
    const BASE_EEP4K_HEADER  *pBase  = &ee->ee_base.baseEepHeader;
    uint32_t sum;
    uint8_t *macaddr;
    int i;

    switch (param) {
    case AR_EEP_NFTHRESH_2:
        *(int16_t *)val = pModal->noiseFloorThreshCh[0];
        return HAL_OK;
    case AR_EEP_MACADDR:		/* Get MAC Address */
        sum = 0;
        macaddr = val;
        for (i = 0; i < 6; i++) {
            macaddr[i] = pBase->macAddr[i];
            sum += pBase->macAddr[i];
        }
        if (sum == 0 || sum == 0xffff*3) {
            HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad mac address %s\n",
                     __func__, ath_hal_ether_sprintf(macaddr));
            return HAL_EEBADMAC;
        }
        return HAL_OK;
    case AR_EEP_REGDMN_0:
        return pBase->regDmn[0];
    case AR_EEP_REGDMN_1:
        return pBase->regDmn[1];
    case AR_EEP_OPCAP:
        return pBase->deviceCap;
    case AR_EEP_OPMODE:
        return pBase->opCapFlags;
    case AR_EEP_RFSILENT:
        return pBase->rfSilent;
    case AR_EEP_OB_2:
        return pModal->ob_0;
    case AR_EEP_DB_2:
        return pModal->db1_1;
    case AR_EEP_TXMASK:
        return pBase->txMask;
    case AR_EEP_RXMASK:
        return pBase->rxMask;
    case AR_EEP_RXGAIN_TYPE:
        return AR5416_EEP_RXGAIN_ORIG;
    case AR_EEP_TXGAIN_TYPE:
        return pBase->txGainType;
    case AR_EEP_OL_PWRCTRL:
        HALASSERT(val == AH_NULL);
        return HAL_EIO;
    case AR_EEP_AMODE:
        HALASSERT(val == AH_NULL);
        return pBase->opCapFlags & AR5416_OPFLAGS_11A ?
               HAL_OK : HAL_EIO;
    case AR_EEP_BMODE:
    case AR_EEP_GMODE:
        HALASSERT(val == AH_NULL);
        return pBase->opCapFlags & AR5416_OPFLAGS_11G ?
               HAL_OK : HAL_EIO;
    case AR_EEP_32KHZCRYSTAL:
    case AR_EEP_COMPRESS:
    case AR_EEP_FASTFRAME:		/* XXX policy decision, h/w can do it */
    case AR_EEP_WRITEPROTECT:	/* NB: no write protect bit */
        HALASSERT(val == AH_NULL);
    /* fall thru... */
    case AR_EEP_MAXQCU:		/* NB: not in opCapFlags */
    case AR_EEP_KCENTRIES:		/* NB: not in opCapFlags */
        return HAL_EIO;
    case AR_EEP_AES:
    case AR_EEP_BURST:
    case AR_EEP_RFKILL:
    case AR_EEP_TURBO2DISABLE:
        HALASSERT(val == AH_NULL);
        return HAL_OK;
    case AR_EEP_ANTGAINMAX_2:
        *(int8_t *) val = ee->ee_antennaGainMax;
        return HAL_OK;
    default:
        HALASSERT(0);
        return HAL_EINVAL;
    }
#undef IS_VERS
#undef CHAN_A_IDX
#undef CHAN_B_IDX
}
Example #3
0
static HAL_STATUS
v14EepromGet(struct ath_hal *ah, int param, void *val)
{
#define	CHAN_A_IDX	0
#define	CHAN_B_IDX	1
#define	IS_VERS(op, v)	((pBase->version & AR5416_EEP_VER_MINOR_MASK) op (v))
	HAL_EEPROM_v14 *ee = AH_PRIVATE(ah)->ah_eeprom;
	const MODAL_EEP_HEADER *pModal = ee->ee_base.modalHeader;
	const BASE_EEP_HEADER  *pBase  = &ee->ee_base.baseEepHeader;
	uint32_t sum;
	uint8_t *macaddr;
	int i;

	switch (param) {
        case AR_EEP_NFTHRESH_5:
		*(int16_t *)val = pModal[0].noiseFloorThreshCh[0];
		return HAL_OK;
        case AR_EEP_NFTHRESH_2:
		*(int16_t *)val = pModal[1].noiseFloorThreshCh[0];
		return HAL_OK;
        case AR_EEP_MACADDR:		/* Get MAC Address */
		sum = 0;
		macaddr = val;
		for (i = 0; i < 6; i++) {
			macaddr[i] = pBase->macAddr[i];
			sum += pBase->macAddr[i];
		}
		if (sum == 0 || sum == 0xffff*3) {
			HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad mac address %s\n",
			    __func__, ath_hal_ether_sprintf(macaddr));
			return HAL_EEBADMAC;
		}
		return HAL_OK;
        case AR_EEP_REGDMN_0:
		return pBase->regDmn[0];
        case AR_EEP_REGDMN_1:
		return pBase->regDmn[1];
        case AR_EEP_OPCAP:
		return pBase->deviceCap;
        case AR_EEP_OPMODE:
		return pBase->opCapFlags;
        case AR_EEP_RFSILENT:
		return pBase->rfSilent;
	case AR_EEP_OB_5:
		return pModal[CHAN_A_IDX].ob;
    	case AR_EEP_DB_5:
		return pModal[CHAN_A_IDX].db;
    	case AR_EEP_OB_2:
		return pModal[CHAN_B_IDX].ob;
    	case AR_EEP_DB_2:
		return pModal[CHAN_B_IDX].db;
	case AR_EEP_TXMASK:
		return pBase->txMask;
	case AR_EEP_RXMASK:
		return pBase->rxMask;
	case AR_EEP_RXGAIN_TYPE:
		return IS_VERS(>=, AR5416_EEP_MINOR_VER_17) ?
		    pBase->rxGainType : AR5416_EEP_RXGAIN_ORIG;
	case AR_EEP_TXGAIN_TYPE:
		return IS_VERS(>=, AR5416_EEP_MINOR_VER_19) ?
		    pBase->txGainType : AR5416_EEP_TXGAIN_ORIG;
	case AR_EEP_FSTCLK_5G:
		/* 5ghz fastclock is always enabled for Merlin minor <= 16 */
		if (IS_VERS(<=, AR5416_EEP_MINOR_VER_16))
			return HAL_OK;
		return pBase->fastClk5g ? HAL_OK : HAL_EIO;
	case AR_EEP_OL_PWRCTRL:
		HALASSERT(val == AH_NULL);
		return pBase->openLoopPwrCntl ?  HAL_OK : HAL_EIO;
	case AR_EEP_DAC_HPWR_5G:
		if (IS_VERS(>=, AR5416_EEP_MINOR_VER_20)) {
			*(uint8_t *) val = pBase->dacHiPwrMode_5G;
			return HAL_OK;
		} else
			return HAL_EIO;
	case AR_EEP_FRAC_N_5G:
		if (IS_VERS(>=, AR5416_EEP_MINOR_VER_22)) {
			*(uint8_t *) val = pBase->frac_n_5g;
		} else
Example #4
0
/*
 * Initialize the tables for a node.
 */
static void
ath_rate_ctl_reset(struct ath_softc *sc, struct ieee80211_node *ni)
{
#define	RATE(_ix)	(ni->ni_rates.rs_rates[(_ix)] & IEEE80211_RATE_VAL)
#define	DOT11RATE(_ix)	(rt->info[(_ix)].dot11Rate & IEEE80211_RATE_VAL)
#define	MCS(_ix)	(ni->ni_htrates.rs_rates[_ix] | IEEE80211_RATE_MCS)
	struct ath_node *an = ATH_NODE(ni);
	struct sample_node *sn = ATH_NODE_SAMPLE(an);
	const HAL_RATE_TABLE *rt = sc->sc_currates;
	int x, y, rix;

	KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));

	KASSERT(sc->sc_curmode < IEEE80211_MODE_MAX+2,
	    ("curmode %u", sc->sc_curmode));

	sn->sched = mrr_schedules[sc->sc_curmode];
	KASSERT(sn->sched != NULL,
	    ("no mrr schedule for mode %u", sc->sc_curmode));

        sn->static_rix = -1;
	ath_rate_update_static_rix(sc, ni);

	sn->currates = sc->sc_currates;

	/*
	 * Construct a bitmask of usable rates.  This has all
	 * negotiated rates minus those marked by the hal as
	 * to be ignored for doing rate control.
	 */
	sn->ratemask = 0;
	/* MCS rates */
	if (ni->ni_flags & IEEE80211_NODE_HT) {
		for (x = 0; x < ni->ni_htrates.rs_nrates; x++) {
			rix = sc->sc_rixmap[MCS(x)];
			if (rix == 0xff)
				continue;
			/* skip rates marked broken by hal */
			if (!rt->info[rix].valid)
				continue;
			KASSERT(rix < SAMPLE_MAXRATES,
			    ("mcs %u has rix %d", MCS(x), rix));
			sn->ratemask |= (uint64_t) 1<<rix;
		}
	}

	/* Legacy rates */
	for (x = 0; x < ni->ni_rates.rs_nrates; x++) {
		rix = sc->sc_rixmap[RATE(x)];
		if (rix == 0xff)
			continue;
		/* skip rates marked broken by hal */
		if (!rt->info[rix].valid)
			continue;
		KASSERT(rix < SAMPLE_MAXRATES,
		    ("rate %u has rix %d", RATE(x), rix));
		sn->ratemask |= (uint64_t) 1<<rix;
	}
#ifdef IEEE80211_DEBUG
	if (ieee80211_msg(ni->ni_vap, IEEE80211_MSG_RATECTL)) {
		uint64_t mask;

		ieee80211_note(ni->ni_vap, "[%s] %s: size 1600 rate/tt",
		    ath_hal_ether_sprintf(ni->ni_macaddr), __func__);
		for (mask = sn->ratemask, rix = 0; mask != 0; mask >>= 1, rix++) {
			if ((mask & 1) == 0)
				continue;
			kprintf(" %d %s/%d", dot11rate(rt, rix), dot11rate_label(rt, rix),
			    calc_usecs_unicast_packet(sc, 1600, rix, 0,0,
			        (ni->ni_chw == 40)));
		}
		kprintf("\n");
	}