Exemple #1
0
static void wl1251_rx_status(struct wl1251 *wl,
                             struct wl1251_rx_descriptor *desc,
                             struct ieee80211_rx_status *status,
                             u8 beacon)
{
    u64 mactime;
    int ret;

    memset(status, 0, sizeof(struct ieee80211_rx_status));

    status->band = IEEE80211_BAND_2GHZ;
    status->mactime = desc->timestamp;

    /*
     * The rx status timestamp is a 32 bits value while the TSF is a
     * 64 bits one.
     * For IBSS merging, TSF is mandatory, so we have to get it
     * somehow, so we ask for ACX_TSF_INFO.
     * That could be moved to the get_tsf() hook, but unfortunately,
     * this one must be atomic, while our SPI routines can sleep.
     */
    if ((wl->bss_type == BSS_TYPE_IBSS) && beacon) {
        ret = wl1251_acx_tsf_info(wl, &mactime);
        if (ret == 0)
            status->mactime = mactime;
    }

    status->signal = desc->rssi;

    /*
     * FIXME: guessing that snr needs to be divided by two, otherwise
     * the values don't make any sense
     */
    wl->noise = desc->rssi - desc->snr / 2;

    status->freq = ieee80211_channel_to_frequency(desc->channel,
                   status->band);

    status->flag |= RX_FLAG_MACTIME_MPDU;

    if (desc->flags & RX_DESC_ENCRYPTION_MASK) {
        status->flag |= RX_FLAG_IV_STRIPPED | RX_FLAG_MMIC_STRIPPED;

        if (likely(!(desc->flags & RX_DESC_DECRYPT_FAIL)))
            status->flag |= RX_FLAG_DECRYPTED;

        if (unlikely(desc->flags & RX_DESC_MIC_FAIL))
            status->flag |= RX_FLAG_MMIC_ERROR;
    }

    if (unlikely(!(desc->flags & RX_DESC_VALID_FCS)))
        status->flag |= RX_FLAG_FAILED_FCS_CRC;


    /* FIXME: set status->rate_idx */
}
Exemple #2
0
static void wl1251_rx_status(struct wl1251 *wl,
			     struct wl1251_rx_descriptor *desc,
			     struct ieee80211_rx_status *status,
			     u8 beacon)
{
	u64 mactime;
	int ret;

	memset(status, 0, sizeof(struct ieee80211_rx_status));

	status->band = IEEE80211_BAND_2GHZ;
	status->mactime = desc->timestamp;

	/*
	 * The rx status timestamp is a 32 bits value while the TSF is a
	 * 64 bits one.
	 * For IBSS merging, TSF is mandatory, so we have to get it
	 * somehow, so we ask for ACX_TSF_INFO.
	 * That could be moved to the get_tsf() hook, but unfortunately,
	 * this one must be atomic, while our SPI routines can sleep.
	 */
	if ((wl->bss_type == BSS_TYPE_IBSS) && beacon) {
		ret = wl1251_acx_tsf_info(wl, &mactime);
		if (ret == 0)
			status->mactime = mactime;
	}

	status->signal = desc->rssi;

	/*
	 * FIXME: guessing that snr needs to be divided by two, otherwise
	 * the values don't make any sense
	 */
	wl->noise = desc->rssi - desc->snr / 2;

	status->freq = ieee80211_channel_to_frequency(desc->channel);

	status->flag |= RX_FLAG_TSFT;

	if (desc->flags & RX_DESC_ENCRYPTION_MASK) {
		status->flag |= RX_FLAG_IV_STRIPPED | RX_FLAG_MMIC_STRIPPED;

		if (likely(!(desc->flags & RX_DESC_DECRYPT_FAIL)))
			status->flag |= RX_FLAG_DECRYPTED;

		if (unlikely(desc->flags & RX_DESC_MIC_FAIL))
			status->flag |= RX_FLAG_MMIC_ERROR;
	}

	if (unlikely(!(desc->flags & RX_DESC_VALID_FCS)))
		status->flag |= RX_FLAG_FAILED_FCS_CRC;

	switch (desc->rate) {
		/* skip 1 and 12 Mbps because they have same value 0x0a */
	case RATE_2MBPS:
		status->rate_idx = 1;
		break;
	case RATE_5_5MBPS:
		status->rate_idx = 2;
		break;
	case RATE_11MBPS:
		status->rate_idx = 3;
		break;
	case RATE_6MBPS:
		status->rate_idx = 4;
		break;
	case RATE_9MBPS:
		status->rate_idx = 5;
		break;
	case RATE_18MBPS:
		status->rate_idx = 7;
		break;
	case RATE_24MBPS:
		status->rate_idx = 8;
		break;
	case RATE_36MBPS:
		status->rate_idx = 9;
		break;
	case RATE_48MBPS:
		status->rate_idx = 10;
		break;
	case RATE_54MBPS:
		status->rate_idx = 11;
		break;
	}

	/* for 1 and 12 Mbps we have to check the modulation */
	if (desc->rate == RATE_1MBPS) {
		if (!(desc->mod_pre & OFDM_RATE_BIT))
			/* CCK -> RATE_1MBPS */
			status->rate_idx = 0;
		else
			/* OFDM -> RATE_12MBPS */
			status->rate_idx = 6;
	}

	if (desc->mod_pre & SHORT_PREAMBLE_BIT)
		status->flag |= RX_FLAG_SHORTPRE;
}