daily pastebin goal
77%
SHARE
TWEET

Untitled

a guest May 26th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. skb_put(skb, urb->actual_length);
  2.     if (!priv->is_rtl8187b) {
  3.         struct rtl8187_rx_hdr *hdr =
  4.             (typeof(hdr))(skb_tail_pointer(skb) - sizeof(*hdr));
  5.         flags = le32_to_cpu(hdr->flags);
  6.         signal = hdr->signal & 0x7f;
  7.         rx_status.antenna = (hdr->signal >> 7) & 1;
  8.         rx_status.noise = hdr->noise;
  9.         rx_status.mactime = le64_to_cpu(hdr->mac_time);
  10.         priv->quality = signal;
  11.         rx_status.qual = priv->quality;
  12.         priv->noise = hdr->noise;
  13.         rate = (flags >> 20) & 0xF;
  14.         if (rate > 3) { /* OFDM rate */
  15.             if (signal > 90)
  16.                 signal = 90;
  17.             else if (signal < 25)
  18.                 signal = 25;
  19.             signal = 90 - signal;
  20.         } else {    /* CCK rate */
  21.             if (signal > 95)
  22.                 signal = 95;
  23.             else if (signal < 30)
  24.                 signal = 30;
  25.             signal = 95 - signal;
  26.         }
  27.         rx_status.signal = signal;
  28.         priv->signal = signal;
  29.     } else {
  30.         struct rtl8187b_rx_hdr *hdr =
  31.             (typeof(hdr))(skb_tail_pointer(skb) - sizeof(*hdr));
  32.         /* The Realtek datasheet for the RTL8187B shows that the RX
  33.          * header contains the following quantities: signal quality,
  34.          * RSSI, AGC, the received power in dB, and the measured SNR.
  35.          * In testing, none of these quantities show qualitative
  36.          * agreement with AP signal strength, except for the AGC,
  37.          * which is inversely proportional to the strength of the
  38.          * signal. In the following, the quality and signal strength
  39.          * are derived from the AGC. The arbitrary scaling constants
  40.          * are chosen to make the results close to the values obtained
  41.          * for a BCM4312 using b43 as the driver. The noise is ignored
  42.          * for now.
  43.          */
  44.         flags = le32_to_cpu(hdr->flags);
  45.         quality = 170 - hdr->agc;
  46.         if (quality > 100)
  47.             quality = 100;
  48.         signal = 14 - hdr->agc / 2;
  49.         rx_status.qual = quality;
  50.         priv->quality = quality;
  51.         rx_status.signal = signal;
  52.         priv->signal = signal;
  53.         rx_status.antenna = (hdr->rssi >> 7) & 1;
  54.         rx_status.mactime = le64_to_cpu(hdr->mac_time);
  55.         rate = (flags >> 20) & 0xF;
  56.     }
  57.  
  58.     skb_trim(skb, flags & 0x0FFF);
  59.     rx_status.rate_idx = rate;
  60.     rx_status.freq = dev->conf.channel->center_freq;
  61.     rx_status.band = dev->conf.channel->band;
  62.     rx_status.flag |= RX_FLAG_TSFT;
  63.     if (flags & (1 << 13))
  64.         rx_status.flag |= RX_FLAG_FAILED_FCS_CRC;
  65.     ieee80211_rx_irqsafe(dev, skb, &rx_status);
  66.  
  67.     skb = dev_alloc_skb(RTL8187_MAX_RX);
  68.     if (unlikely(!skb)) {
  69.         usb_free_urb(urb);
  70.         /* TODO check rx queue length and refill *somewhere* */
  71.         return;
  72.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top