Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- skb_put(skb, urb->actual_length);
- if (!priv->is_rtl8187b) {
- struct rtl8187_rx_hdr *hdr =
- (typeof(hdr))(skb_tail_pointer(skb) - sizeof(*hdr));
- flags = le32_to_cpu(hdr->flags);
- signal = hdr->signal & 0x7f;
- rx_status.antenna = (hdr->signal >> 7) & 1;
- rx_status.noise = hdr->noise;
- rx_status.mactime = le64_to_cpu(hdr->mac_time);
- priv->quality = signal;
- rx_status.qual = priv->quality;
- priv->noise = hdr->noise;
- rate = (flags >> 20) & 0xF;
- if (rate > 3) { /* OFDM rate */
- if (signal > 90)
- signal = 90;
- else if (signal < 25)
- signal = 25;
- signal = 90 - signal;
- } else { /* CCK rate */
- if (signal > 95)
- signal = 95;
- else if (signal < 30)
- signal = 30;
- signal = 95 - signal;
- }
- rx_status.signal = signal;
- priv->signal = signal;
- } else {
- struct rtl8187b_rx_hdr *hdr =
- (typeof(hdr))(skb_tail_pointer(skb) - sizeof(*hdr));
- /* The Realtek datasheet for the RTL8187B shows that the RX
- * header contains the following quantities: signal quality,
- * RSSI, AGC, the received power in dB, and the measured SNR.
- * In testing, none of these quantities show qualitative
- * agreement with AP signal strength, except for the AGC,
- * which is inversely proportional to the strength of the
- * signal. In the following, the quality and signal strength
- * are derived from the AGC. The arbitrary scaling constants
- * are chosen to make the results close to the values obtained
- * for a BCM4312 using b43 as the driver. The noise is ignored
- * for now.
- */
- flags = le32_to_cpu(hdr->flags);
- quality = 170 - hdr->agc;
- if (quality > 100)
- quality = 100;
- signal = 14 - hdr->agc / 2;
- rx_status.qual = quality;
- priv->quality = quality;
- rx_status.signal = signal;
- priv->signal = signal;
- rx_status.antenna = (hdr->rssi >> 7) & 1;
- rx_status.mactime = le64_to_cpu(hdr->mac_time);
- rate = (flags >> 20) & 0xF;
- }
- skb_trim(skb, flags & 0x0FFF);
- rx_status.rate_idx = rate;
- rx_status.freq = dev->conf.channel->center_freq;
- rx_status.band = dev->conf.channel->band;
- rx_status.flag |= RX_FLAG_TSFT;
- if (flags & (1 << 13))
- rx_status.flag |= RX_FLAG_FAILED_FCS_CRC;
- ieee80211_rx_irqsafe(dev, skb, &rx_status);
- skb = dev_alloc_skb(RTL8187_MAX_RX);
- if (unlikely(!skb)) {
- usb_free_urb(urb);
- /* TODO check rx queue length and refill *somewhere* */
- return;
- }
Add Comment
Please, Sign In to add comment