2 * Original code based Host AP (software wireless LAN access point) driver
3 * for Intersil Prism2/2.5/3 - hostap.o module, common routines
5 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
7 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
8 * Copyright (c) 2004, Intel Corporation
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation. See README and COPYING for
14 ******************************************************************************
16 Few modifications for Realtek's Wi-Fi drivers by
17 Andrea Merello <andrea.merello@gmail.com>
19 A special thanks goes to Realtek for their support !
21 ******************************************************************************/
24 #include <linux/compiler.h>
25 #include <linux/errno.h>
26 #include <linux/if_arp.h>
27 #include <linux/in6.h>
30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/netdevice.h>
33 #include <linux/pci.h>
34 #include <linux/proc_fs.h>
35 #include <linux/skbuff.h>
36 #include <linux/slab.h>
37 #include <linux/tcp.h>
38 #include <linux/types.h>
39 #include <linux/wireless.h>
40 #include <linux/etherdevice.h>
41 #include <linux/uaccess.h>
42 #include <linux/ctype.h>
47 static void rtllib_rx_mgt(struct rtllib_device *ieee, struct sk_buff *skb,
48 struct rtllib_rx_stats *stats);
50 static inline void rtllib_monitor_rx(struct rtllib_device *ieee,
52 struct rtllib_rx_stats *rx_status,
56 skb_reset_mac_header(skb);
57 skb_pull(skb, hdr_length);
58 skb->pkt_type = PACKET_OTHERHOST;
59 skb->protocol = htons(ETH_P_80211_RAW);
60 memset(skb->cb, 0, sizeof(skb->cb));
64 /* Called only as a tasklet (software IRQ) */
65 static struct rtllib_frag_entry *
66 rtllib_frag_cache_find(struct rtllib_device *ieee, unsigned int seq,
67 unsigned int frag, u8 tid, u8 *src, u8 *dst)
69 struct rtllib_frag_entry *entry;
72 for (i = 0; i < RTLLIB_FRAG_CACHE_LEN; i++) {
73 entry = &ieee->frag_cache[tid][i];
74 if (entry->skb != NULL &&
75 time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
77 "expiring fragment cache entry seq=%u last_frag=%u\n",
78 entry->seq, entry->last_frag);
79 dev_kfree_skb_any(entry->skb);
83 if (entry->skb != NULL && entry->seq == seq &&
84 (entry->last_frag + 1 == frag || frag == -1) &&
85 memcmp(entry->src_addr, src, ETH_ALEN) == 0 &&
86 memcmp(entry->dst_addr, dst, ETH_ALEN) == 0)
93 /* Called only as a tasklet (software IRQ) */
94 static struct sk_buff *
95 rtllib_frag_cache_get(struct rtllib_device *ieee,
96 struct rtllib_hdr_4addr *hdr)
98 struct sk_buff *skb = NULL;
99 u16 fc = le16_to_cpu(hdr->frame_ctl);
100 u16 sc = le16_to_cpu(hdr->seq_ctl);
101 unsigned int frag = WLAN_GET_SEQ_FRAG(sc);
102 unsigned int seq = WLAN_GET_SEQ_SEQ(sc);
103 struct rtllib_frag_entry *entry;
104 struct rtllib_hdr_3addrqos *hdr_3addrqos;
105 struct rtllib_hdr_4addrqos *hdr_4addrqos;
108 if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
109 RTLLIB_QOS_HAS_SEQ(fc)) {
110 hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr;
111 tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID;
114 } else if (RTLLIB_QOS_HAS_SEQ(fc)) {
115 hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr;
116 tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID;
124 /* Reserve enough space to fit maximum frame length */
125 skb = dev_alloc_skb(ieee->dev->mtu +
126 sizeof(struct rtllib_hdr_4addr) +
132 (RTLLIB_QOS_HAS_SEQ(fc) ? 2 : 0));
136 entry = &ieee->frag_cache[tid][ieee->frag_next_idx[tid]];
137 ieee->frag_next_idx[tid]++;
138 if (ieee->frag_next_idx[tid] >= RTLLIB_FRAG_CACHE_LEN)
139 ieee->frag_next_idx[tid] = 0;
141 if (entry->skb != NULL)
142 dev_kfree_skb_any(entry->skb);
144 entry->first_frag_time = jiffies;
146 entry->last_frag = frag;
148 ether_addr_copy(entry->src_addr, hdr->addr2);
149 ether_addr_copy(entry->dst_addr, hdr->addr1);
151 /* received a fragment of a frame for which the head fragment
152 * should have already been received
154 entry = rtllib_frag_cache_find(ieee, seq, frag, tid, hdr->addr2,
157 entry->last_frag = frag;
166 /* Called only as a tasklet (software IRQ) */
167 static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee,
168 struct rtllib_hdr_4addr *hdr)
170 u16 fc = le16_to_cpu(hdr->frame_ctl);
171 u16 sc = le16_to_cpu(hdr->seq_ctl);
172 unsigned int seq = WLAN_GET_SEQ_SEQ(sc);
173 struct rtllib_frag_entry *entry;
174 struct rtllib_hdr_3addrqos *hdr_3addrqos;
175 struct rtllib_hdr_4addrqos *hdr_4addrqos;
178 if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
179 RTLLIB_QOS_HAS_SEQ(fc)) {
180 hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr;
181 tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID;
184 } else if (RTLLIB_QOS_HAS_SEQ(fc)) {
185 hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr;
186 tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID;
193 entry = rtllib_frag_cache_find(ieee, seq, -1, tid, hdr->addr2,
197 netdev_dbg(ieee->dev,
198 "Couldn't invalidate fragment cache entry (seq=%u)\n",
207 /* rtllib_rx_frame_mgtmt
209 * Responsible for handling management control frames
211 * Called by rtllib_rx
214 rtllib_rx_frame_mgmt(struct rtllib_device *ieee, struct sk_buff *skb,
215 struct rtllib_rx_stats *rx_stats, u16 type,
218 /* On the struct stats definition there is written that
219 * this is not mandatory.... but seems that the probe
220 * response parser uses it
222 struct rtllib_hdr_3addr *hdr = (struct rtllib_hdr_3addr *)skb->data;
224 rx_stats->len = skb->len;
225 rtllib_rx_mgt(ieee, skb, rx_stats);
226 if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN))) {
227 dev_kfree_skb_any(skb);
230 rtllib_rx_frame_softmac(ieee, skb, rx_stats, type, stype);
232 dev_kfree_skb_any(skb);
237 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation
238 * Ethernet-II snap header (RFC1042 for most EtherTypes)
240 static unsigned char rfc1042_header[] = {
241 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00
243 /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
244 static unsigned char bridge_tunnel_header[] = {
245 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8
247 /* No encapsulation header if EtherType < 0x600 (=length) */
249 /* Called by rtllib_rx_frame_decrypt */
250 static int rtllib_is_eapol_frame(struct rtllib_device *ieee,
251 struct sk_buff *skb, size_t hdrlen)
253 struct net_device *dev = ieee->dev;
255 struct rtllib_hdr_4addr *hdr;
261 hdr = (struct rtllib_hdr_4addr *) skb->data;
262 fc = le16_to_cpu(hdr->frame_ctl);
264 /* check that the frame is unicast frame to us */
265 if ((fc & (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS)) ==
267 memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0 &&
268 memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) {
269 /* ToDS frame with own addr BSSID and DA */
270 } else if ((fc & (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS)) ==
271 RTLLIB_FCTL_FROMDS &&
272 memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) {
273 /* FromDS frame with own addr as DA */
277 if (skb->len < 24 + 8)
280 /* check for port access entity Ethernet type */
281 pos = skb->data + hdrlen;
282 ethertype = (pos[6] << 8) | pos[7];
283 if (ethertype == ETH_P_PAE)
289 /* Called only as a tasklet (software IRQ), by rtllib_rx */
291 rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
292 struct lib80211_crypt_data *crypt)
294 struct rtllib_hdr_4addr *hdr;
297 if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
300 if (ieee->hwsec_active) {
301 struct cb_desc *tcb_desc = (struct cb_desc *)
302 (skb->cb + MAX_DEV_ADDR_SIZE);
304 tcb_desc->bHwSec = 1;
306 if (ieee->need_sw_enc)
307 tcb_desc->bHwSec = 0;
310 hdr = (struct rtllib_hdr_4addr *) skb->data;
311 hdrlen = rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
313 atomic_inc(&crypt->refcnt);
314 res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
315 atomic_dec(&crypt->refcnt);
317 netdev_dbg(ieee->dev, "decryption failed (SA= %pM) res=%d\n",
320 netdev_dbg(ieee->dev,
321 "Decryption failed ICV mismatch (key %d)\n",
322 skb->data[hdrlen + 3] >> 6);
330 /* Called only as a tasklet (software IRQ), by rtllib_rx */
332 rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb,
333 int keyidx, struct lib80211_crypt_data *crypt)
335 struct rtllib_hdr_4addr *hdr;
338 if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
340 if (ieee->hwsec_active) {
341 struct cb_desc *tcb_desc = (struct cb_desc *)
342 (skb->cb + MAX_DEV_ADDR_SIZE);
344 tcb_desc->bHwSec = 1;
346 if (ieee->need_sw_enc)
347 tcb_desc->bHwSec = 0;
350 hdr = (struct rtllib_hdr_4addr *) skb->data;
351 hdrlen = rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
353 atomic_inc(&crypt->refcnt);
354 res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
355 atomic_dec(&crypt->refcnt);
357 netdev_dbg(ieee->dev,
358 "MSDU decryption/MIC verification failed (SA= %pM keyidx=%d)\n",
367 /* this function is stolen from ipw2200 driver*/
368 #define IEEE_PACKET_RETRY_TIME (5*HZ)
369 static int is_duplicate_packet(struct rtllib_device *ieee,
370 struct rtllib_hdr_4addr *header)
372 u16 fc = le16_to_cpu(header->frame_ctl);
373 u16 sc = le16_to_cpu(header->seq_ctl);
374 u16 seq = WLAN_GET_SEQ_SEQ(sc);
375 u16 frag = WLAN_GET_SEQ_FRAG(sc);
376 u16 *last_seq, *last_frag;
377 unsigned long *last_time;
378 struct rtllib_hdr_3addrqos *hdr_3addrqos;
379 struct rtllib_hdr_4addrqos *hdr_4addrqos;
382 if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
383 RTLLIB_QOS_HAS_SEQ(fc)) {
384 hdr_4addrqos = (struct rtllib_hdr_4addrqos *)header;
385 tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID;
388 } else if (RTLLIB_QOS_HAS_SEQ(fc)) {
389 hdr_3addrqos = (struct rtllib_hdr_3addrqos *)header;
390 tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID;
397 switch (ieee->iw_mode) {
401 struct ieee_ibss_seq *entry = NULL;
402 u8 *mac = header->addr2;
403 int index = mac[5] % IEEE_IBSS_MAC_HASH_SIZE;
405 list_for_each(p, &ieee->ibss_mac_hash[index]) {
406 entry = list_entry(p, struct ieee_ibss_seq, list);
407 if (!memcmp(entry->mac, mac, ETH_ALEN))
410 if (p == &ieee->ibss_mac_hash[index]) {
411 entry = kmalloc(sizeof(struct ieee_ibss_seq),
416 ether_addr_copy(entry->mac, mac);
417 entry->seq_num[tid] = seq;
418 entry->frag_num[tid] = frag;
419 entry->packet_time[tid] = jiffies;
420 list_add(&entry->list, &ieee->ibss_mac_hash[index]);
423 last_seq = &entry->seq_num[tid];
424 last_frag = &entry->frag_num[tid];
425 last_time = &entry->packet_time[tid];
430 last_seq = &ieee->last_rxseq_num[tid];
431 last_frag = &ieee->last_rxfrag_num[tid];
432 last_time = &ieee->last_packet_time[tid];
438 if ((*last_seq == seq) &&
439 time_after(*last_time + IEEE_PACKET_RETRY_TIME, jiffies)) {
440 if (*last_frag == frag)
442 if (*last_frag + 1 != frag)
443 /* out-of-order fragment */
449 *last_time = jiffies;
457 static bool AddReorderEntry(struct rx_ts_record *pTS,
458 struct rx_reorder_entry *pReorderEntry)
460 struct list_head *pList = &pTS->RxPendingPktList;
462 while (pList->next != &pTS->RxPendingPktList) {
463 if (SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)
464 list_entry(pList->next, struct rx_reorder_entry,
467 else if (SN_EQUAL(pReorderEntry->SeqNum,
468 ((struct rx_reorder_entry *)list_entry(pList->next,
469 struct rx_reorder_entry, List))->SeqNum))
474 pReorderEntry->List.next = pList->next;
475 pReorderEntry->List.next->prev = &pReorderEntry->List;
476 pReorderEntry->List.prev = pList;
477 pList->next = &pReorderEntry->List;
482 void rtllib_indicate_packets(struct rtllib_device *ieee,
483 struct rtllib_rxb **prxbIndicateArray, u8 index)
485 struct net_device_stats *stats = &ieee->stats;
489 for (j = 0; j < index; j++) {
490 struct rtllib_rxb *prxb = prxbIndicateArray[j];
492 for (i = 0; i < prxb->nr_subframes; i++) {
493 struct sk_buff *sub_skb = prxb->subframes[i];
495 /* convert hdr + possible LLC headers into Ethernet header */
496 ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7];
497 if (sub_skb->len >= 8 &&
498 ((memcmp(sub_skb->data, rfc1042_header,
500 ethertype != ETH_P_AARP &&
501 ethertype != ETH_P_IPX) ||
502 memcmp(sub_skb->data, bridge_tunnel_header,
504 /* remove RFC1042 or Bridge-Tunnel encapsulation
505 * and replace EtherType
507 skb_pull(sub_skb, SNAP_SIZE);
508 memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN);
509 memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN);
512 /* Leave Ethernet header part of hdr and full payload */
514 memcpy(skb_push(sub_skb, 2), &len, 2);
515 memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN);
516 memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN);
519 /* Indicate the packets to upper layer */
522 stats->rx_bytes += sub_skb->len;
524 memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
525 sub_skb->protocol = eth_type_trans(sub_skb,
527 sub_skb->dev = ieee->dev;
528 sub_skb->dev->stats.rx_packets++;
529 sub_skb->dev->stats.rx_bytes += sub_skb->len;
530 /* 802.11 crc not sufficient */
531 sub_skb->ip_summed = CHECKSUM_NONE;
532 ieee->last_rx_ps_time = jiffies;
541 void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,
542 struct rx_ts_record *pTS)
544 struct rx_reorder_entry *pRxReorderEntry;
547 del_timer_sync(&pTS->RxPktPendingTimer);
548 while (!list_empty(&pTS->RxPendingPktList)) {
549 if (RfdCnt >= REORDER_WIN_SIZE) {
550 netdev_info(ieee->dev,
551 "-------------->%s() error! RfdCnt >= REORDER_WIN_SIZE\n",
556 pRxReorderEntry = (struct rx_reorder_entry *)
557 list_entry(pTS->RxPendingPktList.prev,
558 struct rx_reorder_entry, List);
559 netdev_dbg(ieee->dev, "%s(): Indicate SeqNum %d!\n", __func__,
560 pRxReorderEntry->SeqNum);
561 list_del_init(&pRxReorderEntry->List);
563 ieee->RfdArray[RfdCnt] = pRxReorderEntry->prxb;
566 list_add_tail(&pRxReorderEntry->List,
567 &ieee->RxReorder_Unused_List);
569 rtllib_indicate_packets(ieee, ieee->RfdArray, RfdCnt);
571 pTS->RxIndicateSeq = 0xffff;
574 static void RxReorderIndicatePacket(struct rtllib_device *ieee,
575 struct rtllib_rxb *prxb,
576 struct rx_ts_record *pTS, u16 SeqNum)
578 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
579 struct rx_reorder_entry *pReorderEntry = NULL;
580 u8 WinSize = pHTInfo->RxReorderWinSize;
583 bool bMatchWinStart = false, bPktInBuf = false;
586 netdev_dbg(ieee->dev,
587 "%s(): Seq is %d, pTS->RxIndicateSeq is %d, WinSize is %d\n",
588 __func__, SeqNum, pTS->RxIndicateSeq, WinSize);
590 spin_lock_irqsave(&(ieee->reorder_spinlock), flags);
592 WinEnd = (pTS->RxIndicateSeq + WinSize - 1) % 4096;
593 /* Rx Reorder initialize condition.*/
594 if (pTS->RxIndicateSeq == 0xffff)
595 pTS->RxIndicateSeq = SeqNum;
597 /* Drop out the packet which SeqNum is smaller than WinStart */
598 if (SN_LESS(SeqNum, pTS->RxIndicateSeq)) {
599 netdev_dbg(ieee->dev,
600 "Packet Drop! IndicateSeq: %d, NewSeq: %d\n",
601 pTS->RxIndicateSeq, SeqNum);
602 pHTInfo->RxReorderDropCounter++;
606 for (i = 0; i < prxb->nr_subframes; i++)
607 dev_kfree_skb(prxb->subframes[i]);
611 spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
615 /* Sliding window manipulation. Conditions includes:
616 * 1. Incoming SeqNum is equal to WinStart =>Window shift 1
617 * 2. Incoming SeqNum is larger than the WinEnd => Window shift N
619 if (SN_EQUAL(SeqNum, pTS->RxIndicateSeq)) {
620 pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096;
621 bMatchWinStart = true;
622 } else if (SN_LESS(WinEnd, SeqNum)) {
623 if (SeqNum >= (WinSize - 1))
624 pTS->RxIndicateSeq = SeqNum + 1 - WinSize;
626 pTS->RxIndicateSeq = 4095 -
627 (WinSize - (SeqNum + 1)) + 1;
628 netdev_dbg(ieee->dev,
629 "Window Shift! IndicateSeq: %d, NewSeq: %d\n",
630 pTS->RxIndicateSeq, SeqNum);
633 /* Indication process.
634 * After Packet dropping and Sliding Window shifting as above, we can
635 * now just indicate the packets with the SeqNum smaller than latest
636 * WinStart and struct buffer other packets.
638 * For Rx Reorder condition:
639 * 1. All packets with SeqNum smaller than WinStart => Indicate
640 * 2. All packets with SeqNum larger than or equal to
641 * WinStart => Buffer it.
643 if (bMatchWinStart) {
644 /* Current packet is going to be indicated.*/
645 netdev_dbg(ieee->dev,
646 "Packets indication! IndicateSeq: %d, NewSeq: %d\n",
647 pTS->RxIndicateSeq, SeqNum);
648 ieee->prxbIndicateArray[0] = prxb;
651 /* Current packet is going to be inserted into pending list.*/
652 if (!list_empty(&ieee->RxReorder_Unused_List)) {
653 pReorderEntry = (struct rx_reorder_entry *)
654 list_entry(ieee->RxReorder_Unused_List.next,
655 struct rx_reorder_entry, List);
656 list_del_init(&pReorderEntry->List);
658 /* Make a reorder entry and insert
659 * into a the packet list.
661 pReorderEntry->SeqNum = SeqNum;
662 pReorderEntry->prxb = prxb;
664 if (!AddReorderEntry(pTS, pReorderEntry)) {
667 netdev_dbg(ieee->dev,
668 "%s(): Duplicate packet is dropped. IndicateSeq: %d, NewSeq: %d\n",
669 __func__, pTS->RxIndicateSeq,
671 list_add_tail(&pReorderEntry->List,
672 &ieee->RxReorder_Unused_List);
674 for (i = 0; i < prxb->nr_subframes; i++)
675 dev_kfree_skb(prxb->subframes[i]);
679 netdev_dbg(ieee->dev,
680 "Pkt insert into struct buffer. IndicateSeq: %d, NewSeq: %d\n",
681 pTS->RxIndicateSeq, SeqNum);
684 /* Packets are dropped if there are not enough reorder
685 * entries. This part should be modified!! We can just
686 * indicate all the packets in struct buffer and get
689 netdev_err(ieee->dev,
690 "%s(): There is no reorder entry! Packet is dropped!\n",
695 for (i = 0; i < prxb->nr_subframes; i++)
696 dev_kfree_skb(prxb->subframes[i]);
703 /* Check if there is any packet need indicate.*/
704 while (!list_empty(&pTS->RxPendingPktList)) {
705 netdev_dbg(ieee->dev, "%s(): start RREORDER indicate\n",
708 pReorderEntry = (struct rx_reorder_entry *)
709 list_entry(pTS->RxPendingPktList.prev,
710 struct rx_reorder_entry,
712 if (SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) ||
713 SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) {
714 /* This protect struct buffer from overflow. */
715 if (index >= REORDER_WIN_SIZE) {
716 netdev_err(ieee->dev,
717 "%s(): Buffer overflow!\n",
723 list_del_init(&pReorderEntry->List);
725 if (SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq))
726 pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) %
729 ieee->prxbIndicateArray[index] = pReorderEntry->prxb;
730 netdev_dbg(ieee->dev, "%s(): Indicate SeqNum %d!\n",
731 __func__, pReorderEntry->SeqNum);
734 list_add_tail(&pReorderEntry->List,
735 &ieee->RxReorder_Unused_List);
742 /* Handling pending timer. Set this timer to prevent from long time
746 if (timer_pending(&pTS->RxPktPendingTimer))
747 del_timer_sync(&pTS->RxPktPendingTimer);
748 pTS->RxTimeoutIndicateSeq = 0xffff;
750 if (index > REORDER_WIN_SIZE) {
751 netdev_err(ieee->dev,
752 "%s(): Rx Reorder struct buffer full!\n",
754 spin_unlock_irqrestore(&(ieee->reorder_spinlock),
758 rtllib_indicate_packets(ieee, ieee->prxbIndicateArray, index);
762 if (bPktInBuf && pTS->RxTimeoutIndicateSeq == 0xffff) {
763 netdev_dbg(ieee->dev, "%s(): SET rx timeout timer\n", __func__);
764 pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq;
765 mod_timer(&pTS->RxPktPendingTimer, jiffies +
766 msecs_to_jiffies(pHTInfo->RxReorderPendingTime));
768 spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
771 static u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb,
772 struct rtllib_rx_stats *rx_stats,
773 struct rtllib_rxb *rxb, u8 *src, u8 *dst)
775 struct rtllib_hdr_3addr *hdr = (struct rtllib_hdr_3addr *)skb->data;
776 u16 fc = le16_to_cpu(hdr->frame_ctl);
778 u16 LLCOffset = sizeof(struct rtllib_hdr_3addr);
780 bool bIsAggregateFrame = false;
781 u16 nSubframe_Length;
782 u8 nPadding_Length = 0;
784 struct sk_buff *sub_skb;
786 /* just for debug purpose */
787 SeqNum = WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr->seq_ctl));
788 if ((RTLLIB_QOS_HAS_SEQ(fc)) &&
789 (((union frameqos *)(skb->data + RTLLIB_3ADDR_LEN))->field.reserved))
790 bIsAggregateFrame = true;
792 if (RTLLIB_QOS_HAS_SEQ(fc))
794 if (rx_stats->bContainHTC)
795 LLCOffset += sHTCLng;
797 ChkLength = LLCOffset;
799 if (skb->len <= ChkLength)
802 skb_pull(skb, LLCOffset);
803 ieee->bIsAggregateFrame = bIsAggregateFrame;
804 if (!bIsAggregateFrame) {
805 rxb->nr_subframes = 1;
807 /* altered by clark 3/30/2010
808 * The struct buffer size of the skb indicated to upper layer
809 * must be less than 5000, or the defraged IP datagram
810 * in the IP layer will exceed "ipfrag_high_tresh" and be
811 * discarded. so there must not use the function
812 * "skb_copy" and "skb_clone" for "skb".
815 /* Allocate new skb for releasing to upper layer */
816 sub_skb = dev_alloc_skb(RTLLIB_SKBBUFFER_SIZE);
819 skb_reserve(sub_skb, 12);
820 data_ptr = (u8 *)skb_put(sub_skb, skb->len);
821 memcpy(data_ptr, skb->data, skb->len);
822 sub_skb->dev = ieee->dev;
824 rxb->subframes[0] = sub_skb;
826 memcpy(rxb->src, src, ETH_ALEN);
827 memcpy(rxb->dst, dst, ETH_ALEN);
828 rxb->subframes[0]->dev = ieee->dev;
832 rxb->nr_subframes = 0;
833 memcpy(rxb->src, src, ETH_ALEN);
834 memcpy(rxb->dst, dst, ETH_ALEN);
835 while (skb->len > ETHERNET_HEADER_SIZE) {
836 /* Offset 12 denote 2 mac address */
837 nSubframe_Length = *((u16 *)(skb->data + 12));
838 nSubframe_Length = (nSubframe_Length >> 8) +
839 (nSubframe_Length << 8);
841 if (skb->len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) {
842 netdev_info(ieee->dev,
843 "%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",
844 __func__, rxb->nr_subframes);
845 netdev_info(ieee->dev,
846 "%s: A-MSDU parse error!! Subframe Length: %d\n",
847 __func__, nSubframe_Length);
848 netdev_info(ieee->dev,
849 "nRemain_Length is %d and nSubframe_Length is : %d\n",
850 skb->len, nSubframe_Length);
851 netdev_info(ieee->dev,
852 "The Packet SeqNum is %d\n",
857 /* move the data point to data content */
858 skb_pull(skb, ETHERNET_HEADER_SIZE);
860 /* altered by clark 3/30/2010
861 * The struct buffer size of the skb indicated to upper layer
862 * must be less than 5000, or the defraged IP datagram
863 * in the IP layer will exceed "ipfrag_high_tresh" and be
864 * discarded. so there must not use the function
865 * "skb_copy" and "skb_clone" for "skb".
868 /* Allocate new skb for releasing to upper layer */
869 sub_skb = dev_alloc_skb(nSubframe_Length + 12);
872 skb_reserve(sub_skb, 12);
873 data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length);
874 memcpy(data_ptr, skb->data, nSubframe_Length);
876 sub_skb->dev = ieee->dev;
877 rxb->subframes[rxb->nr_subframes++] = sub_skb;
878 if (rxb->nr_subframes >= MAX_SUBFRAME_COUNT) {
879 netdev_dbg(ieee->dev,
880 "ParseSubframe(): Too many Subframes! Packets dropped!\n");
883 skb_pull(skb, nSubframe_Length);
886 nPadding_Length = 4 - ((nSubframe_Length +
887 ETHERNET_HEADER_SIZE) % 4);
888 if (nPadding_Length == 4)
891 if (skb->len < nPadding_Length)
894 skb_pull(skb, nPadding_Length);
898 return rxb->nr_subframes;
902 static size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee,
904 struct rtllib_rx_stats *rx_stats)
906 struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;
907 u16 fc = le16_to_cpu(hdr->frame_ctl);
910 hdrlen = rtllib_get_hdrlen(fc);
911 if (HTCCheck(ieee, skb->data)) {
913 netdev_info(ieee->dev, "%s: find HTCControl!\n",
916 rx_stats->bContainHTC = true;
919 if (RTLLIB_QOS_HAS_SEQ(fc))
920 rx_stats->bIsQosData = true;
925 static int rtllib_rx_check_duplicate(struct rtllib_device *ieee,
926 struct sk_buff *skb, u8 multicast)
928 struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;
930 u8 frag, type, stype;
932 fc = le16_to_cpu(hdr->frame_ctl);
933 type = WLAN_FC_GET_TYPE(fc);
934 stype = WLAN_FC_GET_STYPE(fc);
935 sc = le16_to_cpu(hdr->seq_ctl);
936 frag = WLAN_GET_SEQ_FRAG(sc);
938 if ((ieee->pHTInfo->bCurRxReorderEnable == false) ||
939 !ieee->current_network.qos_data.active ||
940 !IsDataFrame(skb->data) ||
941 IsLegacyDataFrame(skb->data)) {
942 if (!((type == RTLLIB_FTYPE_MGMT) &&
943 (stype == RTLLIB_STYPE_BEACON))) {
944 if (is_duplicate_packet(ieee, hdr))
948 struct rx_ts_record *pRxTS = NULL;
950 if (GetTs(ieee, (struct ts_common_info **) &pRxTS, hdr->addr2,
951 (u8)Frame_QoSTID((u8 *)(skb->data)), RX_DIR, true)) {
952 if ((fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) &&
953 (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum))
955 pRxTS->RxLastFragNum = frag;
956 pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc);
958 netdev_warn(ieee->dev, "%s(): No TS! Skip the check!\n",
967 static void rtllib_rx_extract_addr(struct rtllib_device *ieee,
968 struct rtllib_hdr_4addr *hdr, u8 *dst,
971 u16 fc = le16_to_cpu(hdr->frame_ctl);
973 switch (fc & (RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) {
974 case RTLLIB_FCTL_FROMDS:
975 ether_addr_copy(dst, hdr->addr1);
976 ether_addr_copy(src, hdr->addr3);
977 ether_addr_copy(bssid, hdr->addr2);
979 case RTLLIB_FCTL_TODS:
980 ether_addr_copy(dst, hdr->addr3);
981 ether_addr_copy(src, hdr->addr2);
982 ether_addr_copy(bssid, hdr->addr1);
984 case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS:
985 ether_addr_copy(dst, hdr->addr3);
986 ether_addr_copy(src, hdr->addr4);
987 ether_addr_copy(bssid, ieee->current_network.bssid);
990 ether_addr_copy(dst, hdr->addr1);
991 ether_addr_copy(src, hdr->addr2);
992 ether_addr_copy(bssid, hdr->addr3);
997 static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc,
998 u8 *dst, u8 *src, u8 *bssid, u8 *addr2)
1002 type = WLAN_FC_GET_TYPE(fc);
1003 stype = WLAN_FC_GET_STYPE(fc);
1005 /* Filter frames from different BSS */
1006 if (((fc & RTLLIB_FCTL_DSTODS) != RTLLIB_FCTL_DSTODS) &&
1007 !ether_addr_equal(ieee->current_network.bssid, bssid) &&
1008 !is_zero_ether_addr(ieee->current_network.bssid)) {
1012 /* Filter packets sent by an STA that will be forwarded by AP */
1013 if (ieee->IntelPromiscuousModeInfo.bPromiscuousOn &&
1014 ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame) {
1015 if ((fc & RTLLIB_FCTL_TODS) && !(fc & RTLLIB_FCTL_FROMDS) &&
1016 !ether_addr_equal(dst, ieee->current_network.bssid) &&
1017 ether_addr_equal(bssid, ieee->current_network.bssid)) {
1022 /* Nullfunc frames may have PS-bit set, so they must be passed to
1023 * hostap_handle_sta_rx() before being dropped here.
1025 if (!ieee->IntelPromiscuousModeInfo.bPromiscuousOn) {
1026 if (stype != RTLLIB_STYPE_DATA &&
1027 stype != RTLLIB_STYPE_DATA_CFACK &&
1028 stype != RTLLIB_STYPE_DATA_CFPOLL &&
1029 stype != RTLLIB_STYPE_DATA_CFACKPOLL &&
1030 stype != RTLLIB_STYPE_QOS_DATA) {
1031 if (stype != RTLLIB_STYPE_NULLFUNC)
1032 netdev_dbg(ieee->dev,
1033 "RX: dropped data frame with no data (type=0x%02x, subtype=0x%02x)\n",
1039 if (ieee->iw_mode != IW_MODE_MESH) {
1040 /* packets from our adapter are dropped (echo) */
1041 if (!memcmp(src, ieee->dev->dev_addr, ETH_ALEN))
1044 /* {broad,multi}cast packets to our BSS go through */
1045 if (is_multicast_ether_addr(dst)) {
1046 if (memcmp(bssid, ieee->current_network.bssid,
1054 static int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb,
1055 struct lib80211_crypt_data **crypt, size_t hdrlen)
1057 struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;
1058 u16 fc = le16_to_cpu(hdr->frame_ctl);
1061 if (ieee->host_decrypt) {
1062 if (skb->len >= hdrlen + 3)
1063 idx = skb->data[hdrlen + 3] >> 6;
1065 *crypt = ieee->crypt_info.crypt[idx];
1066 /* allow NULL decrypt to indicate an station specific override
1067 * for default encryption
1069 if (*crypt && ((*crypt)->ops == NULL ||
1070 (*crypt)->ops->decrypt_mpdu == NULL))
1073 if (!*crypt && (fc & RTLLIB_FCTL_WEP)) {
1074 /* This seems to be triggered by some (multicast?)
1075 * frames from other than current BSS, so just drop the
1076 * frames silently instead of filling system log with
1079 netdev_dbg(ieee->dev,
1080 "Decryption failed (not set) (SA= %pM)\n",
1089 static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
1090 struct rtllib_rx_stats *rx_stats,
1091 struct lib80211_crypt_data *crypt, size_t hdrlen)
1093 struct rtllib_hdr_4addr *hdr;
1098 hdr = (struct rtllib_hdr_4addr *)skb->data;
1099 fc = le16_to_cpu(hdr->frame_ctl);
1100 sc = le16_to_cpu(hdr->seq_ctl);
1101 frag = WLAN_GET_SEQ_FRAG(sc);
1103 if ((!rx_stats->Decrypted))
1104 ieee->need_sw_enc = 1;
1106 ieee->need_sw_enc = 0;
1108 keyidx = rtllib_rx_frame_decrypt(ieee, skb, crypt);
1109 if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && (keyidx < 0)) {
1110 netdev_info(ieee->dev, "%s: decrypt frame error\n", __func__);
1114 hdr = (struct rtllib_hdr_4addr *) skb->data;
1115 if ((frag != 0 || (fc & RTLLIB_FCTL_MOREFRAGS))) {
1117 struct sk_buff *frag_skb = rtllib_frag_cache_get(ieee, hdr);
1119 netdev_dbg(ieee->dev, "Rx Fragment received (%u)\n", frag);
1122 netdev_dbg(ieee->dev,
1123 "Rx cannot get skb from fragment cache (morefrag=%d seq=%u frag=%u)\n",
1124 (fc & RTLLIB_FCTL_MOREFRAGS) != 0,
1125 WLAN_GET_SEQ_SEQ(sc), frag);
1132 if (frag_skb->tail + flen > frag_skb->end) {
1133 netdev_warn(ieee->dev,
1134 "%s: host decrypted and reassembled frame did not fit skb\n",
1136 rtllib_frag_cache_invalidate(ieee, hdr);
1141 /* copy first fragment (including full headers) into
1142 * beginning of the fragment cache skb
1144 memcpy(skb_put(frag_skb, flen), skb->data, flen);
1146 /* append frame payload to the end of the fragment
1149 memcpy(skb_put(frag_skb, flen), skb->data + hdrlen,
1152 dev_kfree_skb_any(skb);
1155 if (fc & RTLLIB_FCTL_MOREFRAGS) {
1156 /* more fragments expected - leave the skb in fragment
1157 * cache for now; it will be delivered to upper layers
1158 * after all fragments have been received
1163 /* this was the last fragment and the frame will be
1164 * delivered, so remove skb from fragment cache
1167 hdr = (struct rtllib_hdr_4addr *) skb->data;
1168 rtllib_frag_cache_invalidate(ieee, hdr);
1171 /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
1172 * encrypted/authenticated
1174 if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) &&
1175 rtllib_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) {
1176 netdev_info(ieee->dev, "%s: ==>decrypt msdu error\n", __func__);
1180 hdr = (struct rtllib_hdr_4addr *) skb->data;
1181 if (crypt && !(fc & RTLLIB_FCTL_WEP) && !ieee->open_wep) {
1182 if (/*ieee->ieee802_1x &&*/
1183 rtllib_is_eapol_frame(ieee, skb, hdrlen)) {
1185 /* pass unencrypted EAPOL frames even if encryption is
1188 struct eapol *eap = (struct eapol *)(skb->data +
1190 netdev_dbg(ieee->dev,
1191 "RX: IEEE 802.1X EAPOL frame: %s\n",
1192 eap_get_type(eap->type));
1194 netdev_dbg(ieee->dev,
1195 "encryption configured, but RX frame not encrypted (SA= %pM)\n",
1201 if (crypt && !(fc & RTLLIB_FCTL_WEP) &&
1202 rtllib_is_eapol_frame(ieee, skb, hdrlen)) {
1203 struct eapol *eap = (struct eapol *)(skb->data + 24);
1205 netdev_dbg(ieee->dev, "RX: IEEE 802.1X EAPOL frame: %s\n",
1206 eap_get_type(eap->type));
1209 if (crypt && !(fc & RTLLIB_FCTL_WEP) && !ieee->open_wep &&
1210 !rtllib_is_eapol_frame(ieee, skb, hdrlen)) {
1211 netdev_dbg(ieee->dev,
1212 "dropped unencrypted RX data frame from %pM (drop_unencrypted=1)\n",
1217 if (rtllib_is_eapol_frame(ieee, skb, hdrlen))
1218 netdev_warn(ieee->dev, "RX: IEEE802.1X EAPOL frame!\n");
1223 static void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast,
1228 if (ieee->state == RTLLIB_LINKED) {
1229 if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod +
1230 ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) ||
1231 (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) {
1232 if (ieee->LeisurePSLeave)
1233 ieee->LeisurePSLeave(ieee->dev);
1237 ieee->last_rx_ps_time = jiffies;
1240 static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee,
1241 struct rtllib_rx_stats *rx_stats,
1242 struct rtllib_rxb *rxb,
1246 struct net_device *dev = ieee->dev;
1251 netdev_info(dev, "%s: rxb is NULL!!\n", __func__);
1255 for (i = 0; i < rxb->nr_subframes; i++) {
1256 struct sk_buff *sub_skb = rxb->subframes[i];
1259 /* convert hdr + possible LLC headers
1260 * into Ethernet header
1262 ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7];
1263 if (sub_skb->len >= 8 &&
1264 ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 &&
1265 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
1266 memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
1267 /* remove RFC1042 or Bridge-Tunnel encapsulation
1268 * and replace EtherType
1270 skb_pull(sub_skb, SNAP_SIZE);
1271 ether_addr_copy(skb_push(sub_skb, ETH_ALEN),
1273 ether_addr_copy(skb_push(sub_skb, ETH_ALEN),
1277 /* Leave Ethernet header part of hdr
1281 memcpy(skb_push(sub_skb, 2), &len, 2);
1282 ether_addr_copy(skb_push(sub_skb, ETH_ALEN),
1284 ether_addr_copy(skb_push(sub_skb, ETH_ALEN),
1288 ieee->stats.rx_packets++;
1289 ieee->stats.rx_bytes += sub_skb->len;
1291 if (is_multicast_ether_addr(dst))
1292 ieee->stats.multicast++;
1294 /* Indicate the packets to upper layer */
1295 memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
1296 sub_skb->protocol = eth_type_trans(sub_skb, dev);
1298 sub_skb->dev->stats.rx_packets++;
1299 sub_skb->dev->stats.rx_bytes += sub_skb->len;
1300 /* 802.11 crc not sufficient */
1301 sub_skb->ip_summed = CHECKSUM_NONE;
1308 static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
1309 struct rtllib_rx_stats *rx_stats)
1311 struct net_device *dev = ieee->dev;
1312 struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;
1313 struct lib80211_crypt_data *crypt = NULL;
1314 struct rtllib_rxb *rxb = NULL;
1315 struct rx_ts_record *pTS = NULL;
1316 u16 fc, sc, SeqNum = 0;
1317 u8 type, stype, multicast = 0, unicast = 0, nr_subframes = 0, TID = 0;
1321 u8 bssid[ETH_ALEN] = {0};
1324 bool bToOtherSTA = false;
1327 hdr = (struct rtllib_hdr_4addr *)skb->data;
1328 fc = le16_to_cpu(hdr->frame_ctl);
1329 type = WLAN_FC_GET_TYPE(fc);
1330 stype = WLAN_FC_GET_STYPE(fc);
1331 sc = le16_to_cpu(hdr->seq_ctl);
1333 /*Filter pkt not to me*/
1334 multicast = is_multicast_ether_addr(hdr->addr1);
1335 unicast = !multicast;
1336 if (unicast && !ether_addr_equal(dev->dev_addr, hdr->addr1)) {
1337 if (ieee->bNetPromiscuousMode)
1343 /*Filter pkt has too small length */
1344 hdrlen = rtllib_rx_get_hdrlen(ieee, skb, rx_stats);
1345 if (skb->len < hdrlen) {
1347 "%s():ERR!!! skb->len is smaller than hdrlen\n",
1352 /* Filter Duplicate pkt */
1353 ret = rtllib_rx_check_duplicate(ieee, skb, multicast);
1357 /* Filter CTRL Frame */
1358 if (type == RTLLIB_FTYPE_CTL)
1361 /* Filter MGNT Frame */
1362 if (type == RTLLIB_FTYPE_MGMT) {
1365 if (rtllib_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
1371 /* Filter WAPI DATA Frame */
1373 /* Update statstics for AP roaming */
1375 ieee->LinkDetectInfo.NumRecvDataInPeriod++;
1376 ieee->LinkDetectInfo.NumRxOkInPeriod++;
1378 dev->last_rx = jiffies;
1380 /* Data frame - extract src/dst addresses */
1381 rtllib_rx_extract_addr(ieee, hdr, dst, src, bssid);
1383 /* Filter Data frames */
1384 ret = rtllib_rx_data_filter(ieee, fc, dst, src, bssid, hdr->addr2);
1388 if (skb->len == hdrlen)
1391 /* Send pspoll based on moredata */
1392 if ((ieee->iw_mode == IW_MODE_INFRA) &&
1393 (ieee->sta_sleep == LPS_IS_SLEEP) &&
1394 (ieee->polling) && (!bToOtherSTA)) {
1395 if (WLAN_FC_MORE_DATA(fc)) {
1396 /* more data bit is set, let's request a new frame
1399 rtllib_sta_ps_send_pspoll_frame(ieee);
1401 ieee->polling = false;
1405 /* Get crypt if encrypted */
1406 ret = rtllib_rx_get_crypt(ieee, skb, &crypt, hdrlen);
1410 /* Decrypt data frame (including reassemble) */
1411 ret = rtllib_rx_decrypt(ieee, skb, rx_stats, crypt, hdrlen);
1417 /* Get TS for Rx Reorder */
1418 hdr = (struct rtllib_hdr_4addr *) skb->data;
1419 if (ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data)
1420 && !is_multicast_ether_addr(hdr->addr1)
1421 && (!bToOtherSTA)) {
1422 TID = Frame_QoSTID(skb->data);
1423 SeqNum = WLAN_GET_SEQ_SEQ(sc);
1424 GetTs(ieee, (struct ts_common_info **) &pTS, hdr->addr2, TID,
1426 if (TID != 0 && TID != 3)
1427 ieee->bis_any_nonbepkts = true;
1430 /* Parse rx data frame (For AMSDU) */
1431 /* skb: hdr + (possible reassembled) full plaintext payload */
1432 payload = skb->data + hdrlen;
1433 rxb = kmalloc(sizeof(struct rtllib_rxb), GFP_ATOMIC);
1437 /* to parse amsdu packets */
1438 /* qos data packets & reserved bit is 1 */
1439 if (parse_subframe(ieee, skb, rx_stats, rxb, src, dst) == 0) {
1440 /* only to free rxb, and not submit the packets
1443 for (i = 0; i < rxb->nr_subframes; i++)
1444 dev_kfree_skb(rxb->subframes[i]);
1450 /* Update WAPI PN */
1452 /* Check if leave LPS */
1454 if (ieee->bIsAggregateFrame)
1455 nr_subframes = rxb->nr_subframes;
1459 ieee->LinkDetectInfo.NumRxUnicastOkInPeriod += nr_subframes;
1460 rtllib_rx_check_leave_lps(ieee, unicast, nr_subframes);
1463 /* Indicate packets to upper layer or Rx Reorder */
1464 if (ieee->pHTInfo->bCurRxReorderEnable == false || pTS == NULL ||
1466 rtllib_rx_indicate_pkt_legacy(ieee, rx_stats, rxb, dst, src);
1468 RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum);
1476 ieee->stats.rx_dropped++;
1478 /* Returning 0 indicates to caller that we have not handled the SKB--
1479 * so it is still allocated and can be used again by underlying
1480 * hardware as a DMA target
1485 static int rtllib_rx_Master(struct rtllib_device *ieee, struct sk_buff *skb,
1486 struct rtllib_rx_stats *rx_stats)
1491 static int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb,
1492 struct rtllib_rx_stats *rx_stats)
1494 struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;
1495 u16 fc = le16_to_cpu(hdr->frame_ctl);
1496 size_t hdrlen = rtllib_get_hdrlen(fc);
1498 if (skb->len < hdrlen) {
1499 netdev_info(ieee->dev,
1500 "%s():ERR!!! skb->len is smaller than hdrlen\n",
1505 if (HTCCheck(ieee, skb->data)) {
1506 if (net_ratelimit())
1507 netdev_info(ieee->dev, "%s: Find HTCControl!\n",
1512 rtllib_monitor_rx(ieee, skb, rx_stats, hdrlen);
1513 ieee->stats.rx_packets++;
1514 ieee->stats.rx_bytes += skb->len;
1519 static int rtllib_rx_Mesh(struct rtllib_device *ieee, struct sk_buff *skb,
1520 struct rtllib_rx_stats *rx_stats)
1525 /* All received frames are sent to this function. @skb contains the frame in
1526 * IEEE 802.11 format, i.e., in the format it was sent over air.
1527 * This function is called only as a tasklet (software IRQ).
1529 int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
1530 struct rtllib_rx_stats *rx_stats)
1534 if (!ieee || !skb || !rx_stats) {
1535 pr_info("%s: Input parameters NULL!\n", __func__);
1538 if (skb->len < 10) {
1539 netdev_info(ieee->dev, "%s: SKB length < 10\n", __func__);
1543 switch (ieee->iw_mode) {
1546 ret = rtllib_rx_InfraAdhoc(ieee, skb, rx_stats);
1548 case IW_MODE_MASTER:
1549 case IW_MODE_REPEAT:
1550 ret = rtllib_rx_Master(ieee, skb, rx_stats);
1552 case IW_MODE_MONITOR:
1553 ret = rtllib_rx_Monitor(ieee, skb, rx_stats);
1556 ret = rtllib_rx_Mesh(ieee, skb, rx_stats);
1559 netdev_info(ieee->dev, "%s: ERR iw mode!!!\n", __func__);
1567 ieee->stats.rx_dropped++;
1570 EXPORT_SYMBOL(rtllib_rx);
1572 static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 };
1574 /* Make ther structure we read from the beacon packet has the right values */
1575 static int rtllib_verify_qos_info(struct rtllib_qos_information_element
1576 *info_element, int sub_type)
1579 if (info_element->qui_subtype != sub_type)
1581 if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN))
1583 if (info_element->qui_type != QOS_OUI_TYPE)
1585 if (info_element->version != QOS_VERSION_1)
1592 /* Parse a QoS parameter element */
1593 static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info
1595 struct rtllib_info_element
1599 u16 size = sizeof(struct rtllib_qos_parameter_info) - 2;
1601 if ((info_element == NULL) || (element_param == NULL))
1604 if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) {
1605 memcpy(element_param->info_element.qui, info_element->data,
1607 element_param->info_element.elementID = info_element->id;
1608 element_param->info_element.length = info_element->len;
1612 ret = rtllib_verify_qos_info(&element_param->info_element,
1613 QOS_OUI_PARAM_SUB_TYPE);
1617 /* Parse a QoS information element */
1618 static int rtllib_read_qos_info_element(struct rtllib_qos_information_element
1620 struct rtllib_info_element
1624 u16 size = sizeof(struct rtllib_qos_information_element) - 2;
1626 if (element_info == NULL)
1628 if (info_element == NULL)
1631 if ((info_element->id == QOS_ELEMENT_ID) &&
1632 (info_element->len == size)) {
1633 memcpy(element_info->qui, info_element->data,
1635 element_info->elementID = info_element->id;
1636 element_info->length = info_element->len;
1641 ret = rtllib_verify_qos_info(element_info,
1642 QOS_OUI_INFO_SUB_TYPE);
1647 /* Write QoS parameters from the ac parameters. */
1648 static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info *param_elm,
1649 struct rtllib_qos_data *qos_data)
1651 struct rtllib_qos_ac_parameter *ac_params;
1652 struct rtllib_qos_parameters *qos_param = &(qos_data->parameters);
1657 qos_data->wmm_acm = 0;
1658 for (i = 0; i < QOS_QUEUE_NUM; i++) {
1659 ac_params = &(param_elm->ac_params_record[i]);
1661 aci = (ac_params->aci_aifsn & 0x60) >> 5;
1662 acm = (ac_params->aci_aifsn & 0x10) >> 4;
1664 if (aci >= QOS_QUEUE_NUM)
1668 /* BIT(0) | BIT(3) */
1670 qos_data->wmm_acm |= (0x01<<0)|(0x01<<3);
1673 /* BIT(4) | BIT(5) */
1675 qos_data->wmm_acm |= (0x01<<4)|(0x01<<5);
1678 /* BIT(6) | BIT(7) */
1680 qos_data->wmm_acm |= (0x01<<6)|(0x01<<7);
1684 /* BIT(1) | BIT(2) */
1686 qos_data->wmm_acm |= (0x01<<1)|(0x01<<2);
1690 qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f;
1692 /* WMM spec P.11: The minimum value for AIFSN shall be 2 */
1693 qos_param->aifs[aci] = max_t(u8, qos_param->aifs[aci], 2);
1695 qos_param->cw_min[aci] = cpu_to_le16(ac_params->ecw_min_max &
1698 qos_param->cw_max[aci] = cpu_to_le16((ac_params->ecw_min_max &
1701 qos_param->flag[aci] =
1702 (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
1703 qos_param->tx_op_limit[aci] = ac_params->tx_op_limit;
1708 /* we have a generic data element which it may contain QoS information or
1709 * parameters element. check the information element length to decide
1710 * which type to read
1712 static int rtllib_parse_qos_info_param_IE(struct rtllib_device *ieee,
1713 struct rtllib_info_element
1715 struct rtllib_network *network)
1718 struct rtllib_qos_information_element qos_info_element;
1720 rc = rtllib_read_qos_info_element(&qos_info_element, info_element);
1723 network->qos_data.param_count = qos_info_element.ac_info & 0x0F;
1724 network->flags |= NETWORK_HAS_QOS_INFORMATION;
1726 struct rtllib_qos_parameter_info param_element;
1728 rc = rtllib_read_qos_param_element(¶m_element,
1731 rtllib_qos_convert_ac_to_parameters(¶m_element,
1732 &(network->qos_data));
1733 network->flags |= NETWORK_HAS_QOS_PARAMETERS;
1734 network->qos_data.param_count =
1735 param_element.info_element.ac_info & 0x0F;
1740 netdev_dbg(ieee->dev, "QoS is supported\n");
1741 network->qos_data.supported = 1;
1746 static const char *get_info_element_string(u16 id)
1749 case MFIE_TYPE_SSID:
1751 case MFIE_TYPE_RATES:
1753 case MFIE_TYPE_FH_SET:
1755 case MFIE_TYPE_DS_SET:
1757 case MFIE_TYPE_CF_SET:
1761 case MFIE_TYPE_IBSS_SET:
1763 case MFIE_TYPE_COUNTRY:
1765 case MFIE_TYPE_HOP_PARAMS:
1766 return "HOP_PARAMS";
1767 case MFIE_TYPE_HOP_TABLE:
1769 case MFIE_TYPE_REQUEST:
1771 case MFIE_TYPE_CHALLENGE:
1773 case MFIE_TYPE_POWER_CONSTRAINT:
1774 return "POWER_CONSTRAINT";
1775 case MFIE_TYPE_POWER_CAPABILITY:
1776 return "POWER_CAPABILITY";
1777 case MFIE_TYPE_TPC_REQUEST:
1778 return "TPC_REQUEST";
1779 case MFIE_TYPE_TPC_REPORT:
1780 return "TPC_REPORT";
1781 case MFIE_TYPE_SUPP_CHANNELS:
1782 return "SUPP_CHANNELS";
1785 case MFIE_TYPE_MEASURE_REQUEST:
1786 return "MEASURE_REQUEST";
1787 case MFIE_TYPE_MEASURE_REPORT:
1788 return "MEASURE_REPORT";
1789 case MFIE_TYPE_QUIET:
1791 case MFIE_TYPE_IBSS_DFS:
1795 case MFIE_TYPE_RATES_EX:
1797 case MFIE_TYPE_GENERIC:
1799 case MFIE_TYPE_QOS_PARAMETER:
1800 return "QOS_PARAMETER";
1806 static inline void rtllib_extract_country_ie(
1807 struct rtllib_device *ieee,
1808 struct rtllib_info_element *info_element,
1809 struct rtllib_network *network,
1812 if (IS_DOT11D_ENABLE(ieee)) {
1813 if (info_element->len != 0) {
1814 memcpy(network->CountryIeBuf, info_element->data,
1816 network->CountryIeLen = info_element->len;
1818 if (!IS_COUNTRY_IE_VALID(ieee)) {
1819 if (rtllib_act_scanning(ieee, false) &&
1820 ieee->FirstIe_InScan)
1821 netdev_info(ieee->dev,
1822 "Received beacon ContryIE, SSID: <%s>\n",
1824 Dot11d_UpdateCountryIe(ieee, addr2,
1826 info_element->data);
1830 if (IS_EQUAL_CIE_SRC(ieee, addr2))
1831 UPDATE_CIE_WATCHDOG(ieee);
1835 static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
1836 struct rtllib_info_element *info_element,
1837 struct rtllib_network *network,
1839 u16 *tmp_htinfo_len)
1841 u16 ht_realtek_agg_len = 0;
1842 u8 ht_realtek_agg_buf[MAX_IE_LEN];
1844 if (!rtllib_parse_qos_info_param_IE(ieee, info_element, network))
1846 if (info_element->len >= 4 &&
1847 info_element->data[0] == 0x00 &&
1848 info_element->data[1] == 0x50 &&
1849 info_element->data[2] == 0xf2 &&
1850 info_element->data[3] == 0x01) {
1851 network->wpa_ie_len = min(info_element->len + 2,
1853 memcpy(network->wpa_ie, info_element, network->wpa_ie_len);
1856 if (info_element->len == 7 &&
1857 info_element->data[0] == 0x00 &&
1858 info_element->data[1] == 0xe0 &&
1859 info_element->data[2] == 0x4c &&
1860 info_element->data[3] == 0x01 &&
1861 info_element->data[4] == 0x02)
1862 network->Turbo_Enable = 1;
1864 if (*tmp_htcap_len == 0) {
1865 if (info_element->len >= 4 &&
1866 info_element->data[0] == 0x00 &&
1867 info_element->data[1] == 0x90 &&
1868 info_element->data[2] == 0x4c &&
1869 info_element->data[3] == 0x033) {
1870 *tmp_htcap_len = min_t(u8, info_element->len,
1872 if (*tmp_htcap_len != 0) {
1873 network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
1874 network->bssht.bdHTCapLen = min_t(u16, *tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf));
1875 memcpy(network->bssht.bdHTCapBuf,
1877 network->bssht.bdHTCapLen);
1880 if (*tmp_htcap_len != 0) {
1881 network->bssht.bdSupportHT = true;
1882 network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
1884 network->bssht.bdSupportHT = false;
1885 network->bssht.bdHT1R = false;
1890 if (*tmp_htinfo_len == 0) {
1891 if (info_element->len >= 4 &&
1892 info_element->data[0] == 0x00 &&
1893 info_element->data[1] == 0x90 &&
1894 info_element->data[2] == 0x4c &&
1895 info_element->data[3] == 0x034) {
1896 *tmp_htinfo_len = min_t(u8, info_element->len,
1898 if (*tmp_htinfo_len != 0) {
1899 network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
1900 network->bssht.bdHTInfoLen = min_t(u16, *tmp_htinfo_len, sizeof(network->bssht.bdHTInfoBuf));
1901 memcpy(network->bssht.bdHTInfoBuf,
1903 network->bssht.bdHTInfoLen);
1908 if (network->bssht.bdSupportHT) {
1909 if (info_element->len >= 4 &&
1910 info_element->data[0] == 0x00 &&
1911 info_element->data[1] == 0xe0 &&
1912 info_element->data[2] == 0x4c &&
1913 info_element->data[3] == 0x02) {
1914 ht_realtek_agg_len = min_t(u8, info_element->len,
1916 memcpy(ht_realtek_agg_buf, info_element->data,
1919 if (ht_realtek_agg_len >= 5) {
1920 network->realtek_cap_exit = true;
1921 network->bssht.bdRT2RTAggregation = true;
1923 if ((ht_realtek_agg_buf[4] == 1) &&
1924 (ht_realtek_agg_buf[5] & 0x02))
1925 network->bssht.bdRT2RTLongSlotTime = true;
1927 if ((ht_realtek_agg_buf[4] == 1) &&
1928 (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE))
1929 network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE;
1932 if (ht_realtek_agg_len >= 5) {
1933 if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP))
1934 network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP;
1937 if ((info_element->len >= 3 &&
1938 info_element->data[0] == 0x00 &&
1939 info_element->data[1] == 0x05 &&
1940 info_element->data[2] == 0xb5) ||
1941 (info_element->len >= 3 &&
1942 info_element->data[0] == 0x00 &&
1943 info_element->data[1] == 0x0a &&
1944 info_element->data[2] == 0xf7) ||
1945 (info_element->len >= 3 &&
1946 info_element->data[0] == 0x00 &&
1947 info_element->data[1] == 0x10 &&
1948 info_element->data[2] == 0x18)) {
1949 network->broadcom_cap_exist = true;
1951 if (info_element->len >= 3 &&
1952 info_element->data[0] == 0x00 &&
1953 info_element->data[1] == 0x0c &&
1954 info_element->data[2] == 0x43)
1955 network->ralink_cap_exist = true;
1956 if ((info_element->len >= 3 &&
1957 info_element->data[0] == 0x00 &&
1958 info_element->data[1] == 0x03 &&
1959 info_element->data[2] == 0x7f) ||
1960 (info_element->len >= 3 &&
1961 info_element->data[0] == 0x00 &&
1962 info_element->data[1] == 0x13 &&
1963 info_element->data[2] == 0x74))
1964 network->atheros_cap_exist = true;
1966 if ((info_element->len >= 3 &&
1967 info_element->data[0] == 0x00 &&
1968 info_element->data[1] == 0x50 &&
1969 info_element->data[2] == 0x43))
1970 network->marvell_cap_exist = true;
1971 if (info_element->len >= 3 &&
1972 info_element->data[0] == 0x00 &&
1973 info_element->data[1] == 0x40 &&
1974 info_element->data[2] == 0x96)
1975 network->cisco_cap_exist = true;
1978 if (info_element->len >= 3 &&
1979 info_element->data[0] == 0x00 &&
1980 info_element->data[1] == 0x0a &&
1981 info_element->data[2] == 0xf5)
1982 network->airgo_cap_exist = true;
1984 if (info_element->len > 4 &&
1985 info_element->data[0] == 0x00 &&
1986 info_element->data[1] == 0x40 &&
1987 info_element->data[2] == 0x96 &&
1988 info_element->data[3] == 0x01) {
1989 if (info_element->len == 6) {
1990 memcpy(network->CcxRmState, &info_element[4], 2);
1991 if (network->CcxRmState[0] != 0)
1992 network->bCcxRmEnable = true;
1994 network->bCcxRmEnable = false;
1995 network->MBssidMask = network->CcxRmState[1] & 0x07;
1996 if (network->MBssidMask != 0) {
1997 network->bMBssidValid = true;
1998 network->MBssidMask = 0xff <<
1999 (network->MBssidMask);
2000 ether_addr_copy(network->MBssid,
2002 network->MBssid[5] &= network->MBssidMask;
2004 network->bMBssidValid = false;
2007 network->bCcxRmEnable = false;
2010 if (info_element->len > 4 &&
2011 info_element->data[0] == 0x00 &&
2012 info_element->data[1] == 0x40 &&
2013 info_element->data[2] == 0x96 &&
2014 info_element->data[3] == 0x03) {
2015 if (info_element->len == 5) {
2016 network->bWithCcxVerNum = true;
2017 network->BssCcxVerNumber = info_element->data[4];
2019 network->bWithCcxVerNum = false;
2020 network->BssCcxVerNumber = 0;
2023 if (info_element->len > 4 &&
2024 info_element->data[0] == 0x00 &&
2025 info_element->data[1] == 0x50 &&
2026 info_element->data[2] == 0xf2 &&
2027 info_element->data[3] == 0x04) {
2028 netdev_dbg(ieee->dev, "MFIE_TYPE_WZC: %d bytes\n",
2030 network->wzc_ie_len = min(info_element->len+2, MAX_WZC_IE_LEN);
2031 memcpy(network->wzc_ie, info_element, network->wzc_ie_len);
2035 static void rtllib_parse_mfie_ht_cap(struct rtllib_info_element *info_element,
2036 struct rtllib_network *network,
2039 struct bss_ht *ht = &network->bssht;
2041 *tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN);
2042 if (*tmp_htcap_len != 0) {
2043 ht->bdHTSpecVer = HT_SPEC_VER_EWC;
2044 ht->bdHTCapLen = min_t(u16, *tmp_htcap_len,
2045 sizeof(ht->bdHTCapBuf));
2046 memcpy(ht->bdHTCapBuf, info_element->data, ht->bdHTCapLen);
2048 ht->bdSupportHT = true;
2049 ht->bdHT1R = ((((struct ht_capab_ele *)
2050 ht->bdHTCapBuf))->MCS[1]) == 0;
2052 ht->bdBandWidth = (enum ht_channel_width)
2053 (((struct ht_capab_ele *)
2054 (ht->bdHTCapBuf))->ChlWidth);
2056 ht->bdSupportHT = false;
2058 ht->bdBandWidth = HT_CHANNEL_WIDTH_20;
2062 int rtllib_parse_info_param(struct rtllib_device *ieee,
2063 struct rtllib_info_element *info_element,
2065 struct rtllib_network *network,
2066 struct rtllib_rx_stats *stats)
2070 u16 tmp_htcap_len = 0;
2071 u16 tmp_htinfo_len = 0;
2075 while (length >= sizeof(*info_element)) {
2076 if (sizeof(*info_element) + info_element->len > length) {
2077 netdev_dbg(ieee->dev,
2078 "Info elem: parse failed: info_element->len + 2 > left : info_element->len+2=%zd left=%d, id=%d.\n",
2079 info_element->len + sizeof(*info_element),
2080 length, info_element->id);
2081 /* We stop processing but don't return an error here
2082 * because some misbehaviour APs break this rule. ie.
2088 switch (info_element->id) {
2089 case MFIE_TYPE_SSID:
2090 if (rtllib_is_empty_essid(info_element->data,
2091 info_element->len)) {
2092 network->flags |= NETWORK_EMPTY_ESSID;
2096 network->ssid_len = min(info_element->len,
2097 (u8) IW_ESSID_MAX_SIZE);
2098 memcpy(network->ssid, info_element->data,
2100 if (network->ssid_len < IW_ESSID_MAX_SIZE)
2101 memset(network->ssid + network->ssid_len, 0,
2102 IW_ESSID_MAX_SIZE - network->ssid_len);
2104 netdev_dbg(ieee->dev, "MFIE_TYPE_SSID: '%s' len=%d.\n",
2105 network->ssid, network->ssid_len);
2108 case MFIE_TYPE_RATES:
2110 network->rates_len = min(info_element->len,
2112 for (i = 0; i < network->rates_len; i++) {
2113 network->rates[i] = info_element->data[i];
2114 p += snprintf(p, sizeof(rates_str) -
2115 (p - rates_str), "%02X ",
2117 if (rtllib_is_ofdm_rate
2118 (info_element->data[i])) {
2119 network->flags |= NETWORK_HAS_OFDM;
2120 if (info_element->data[i] &
2121 RTLLIB_BASIC_RATE_MASK)
2126 if (rtllib_is_cck_rate
2127 (info_element->data[i])) {
2128 network->flags |= NETWORK_HAS_CCK;
2132 netdev_dbg(ieee->dev, "MFIE_TYPE_RATES: '%s' (%d)\n",
2133 rates_str, network->rates_len);
2136 case MFIE_TYPE_RATES_EX:
2138 network->rates_ex_len = min(info_element->len,
2139 MAX_RATES_EX_LENGTH);
2140 for (i = 0; i < network->rates_ex_len; i++) {
2141 network->rates_ex[i] = info_element->data[i];
2142 p += snprintf(p, sizeof(rates_str) -
2143 (p - rates_str), "%02X ",
2144 network->rates_ex[i]);
2145 if (rtllib_is_ofdm_rate
2146 (info_element->data[i])) {
2147 network->flags |= NETWORK_HAS_OFDM;
2148 if (info_element->data[i] &
2149 RTLLIB_BASIC_RATE_MASK)
2155 netdev_dbg(ieee->dev, "MFIE_TYPE_RATES_EX: '%s' (%d)\n",
2156 rates_str, network->rates_ex_len);
2159 case MFIE_TYPE_DS_SET:
2160 netdev_dbg(ieee->dev, "MFIE_TYPE_DS_SET: %d\n",
2161 info_element->data[0]);
2162 network->channel = info_element->data[0];
2165 case MFIE_TYPE_FH_SET:
2166 netdev_dbg(ieee->dev, "MFIE_TYPE_FH_SET: ignored\n");
2169 case MFIE_TYPE_CF_SET:
2170 netdev_dbg(ieee->dev, "MFIE_TYPE_CF_SET: ignored\n");
2174 if (info_element->len < 4)
2177 network->tim.tim_count = info_element->data[0];
2178 network->tim.tim_period = info_element->data[1];
2180 network->dtim_period = info_element->data[1];
2181 if (ieee->state != RTLLIB_LINKED)
2183 network->last_dtim_sta_time = jiffies;
2185 network->dtim_data = RTLLIB_DTIM_VALID;
2188 if (info_element->data[2] & 1)
2189 network->dtim_data |= RTLLIB_DTIM_MBCAST;
2191 offset = (info_element->data[2] >> 1)*2;
2194 if (ieee->assoc_id < 8*offset ||
2195 ieee->assoc_id > 8*(offset + info_element->len - 3))
2198 offset = (ieee->assoc_id / 8) - offset;
2199 if (info_element->data[3 + offset] &
2200 (1 << (ieee->assoc_id % 8)))
2201 network->dtim_data |= RTLLIB_DTIM_UCAST;
2203 network->listen_interval = network->dtim_period;
2207 network->erp_value = info_element->data[0];
2208 network->flags |= NETWORK_HAS_ERP_VALUE;
2209 netdev_dbg(ieee->dev, "MFIE_TYPE_ERP_SET: %d\n",
2210 network->erp_value);
2212 case MFIE_TYPE_IBSS_SET:
2213 network->atim_window = info_element->data[0];
2214 netdev_dbg(ieee->dev, "MFIE_TYPE_IBSS_SET: %d\n",
2215 network->atim_window);
2218 case MFIE_TYPE_CHALLENGE:
2219 netdev_dbg(ieee->dev, "MFIE_TYPE_CHALLENGE: ignored\n");
2222 case MFIE_TYPE_GENERIC:
2223 netdev_dbg(ieee->dev, "MFIE_TYPE_GENERIC: %d bytes\n",
2226 rtllib_parse_mife_generic(ieee, info_element, network,
2232 netdev_dbg(ieee->dev, "MFIE_TYPE_RSN: %d bytes\n",
2234 network->rsn_ie_len = min(info_element->len + 2,
2236 memcpy(network->rsn_ie, info_element,
2237 network->rsn_ie_len);
2240 case MFIE_TYPE_HT_CAP:
2241 netdev_dbg(ieee->dev, "MFIE_TYPE_HT_CAP: %d bytes\n",
2244 rtllib_parse_mfie_ht_cap(info_element, network,
2249 case MFIE_TYPE_HT_INFO:
2250 netdev_dbg(ieee->dev, "MFIE_TYPE_HT_INFO: %d bytes\n",
2252 tmp_htinfo_len = min_t(u8, info_element->len,
2254 if (tmp_htinfo_len) {
2255 network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE;
2256 network->bssht.bdHTInfoLen = tmp_htinfo_len >
2257 sizeof(network->bssht.bdHTInfoBuf) ?
2258 sizeof(network->bssht.bdHTInfoBuf) :
2260 memcpy(network->bssht.bdHTInfoBuf,
2262 network->bssht.bdHTInfoLen);
2266 case MFIE_TYPE_AIRONET:
2267 netdev_dbg(ieee->dev, "MFIE_TYPE_AIRONET: %d bytes\n",
2269 if (info_element->len > IE_CISCO_FLAG_POSITION) {
2270 network->bWithAironetIE = true;
2272 if ((info_element->data[IE_CISCO_FLAG_POSITION]
2273 & SUPPORT_CKIP_MIC) ||
2274 (info_element->data[IE_CISCO_FLAG_POSITION]
2276 network->bCkipSupported = true;
2278 network->bCkipSupported = false;
2280 network->bWithAironetIE = false;
2281 network->bCkipSupported = false;
2284 case MFIE_TYPE_QOS_PARAMETER:
2285 netdev_err(ieee->dev,
2286 "QoS Error need to parse QOS_PARAMETER IE\n");
2289 case MFIE_TYPE_COUNTRY:
2290 netdev_dbg(ieee->dev, "MFIE_TYPE_COUNTRY: %d bytes\n",
2292 rtllib_extract_country_ie(ieee, info_element, network,
2297 netdev_dbg(ieee->dev,
2298 "Unsupported info element: %s (%d)\n",
2299 get_info_element_string(info_element->id),
2304 length -= sizeof(*info_element) + info_element->len;
2306 (struct rtllib_info_element *)&info_element->
2307 data[info_element->len];
2310 if (!network->atheros_cap_exist && !network->broadcom_cap_exist &&
2311 !network->cisco_cap_exist && !network->ralink_cap_exist &&
2312 !network->bssht.bdRT2RTAggregation)
2313 network->unknown_cap_exist = true;
2315 network->unknown_cap_exist = false;
2319 static long rtllib_translate_todbm(u8 signal_strength_index)
2323 signal_power = (long)((signal_strength_index + 1) >> 1);
2326 return signal_power;
2329 static inline int rtllib_network_init(
2330 struct rtllib_device *ieee,
2331 struct rtllib_probe_response *beacon,
2332 struct rtllib_network *network,
2333 struct rtllib_rx_stats *stats)
2335 memset(&network->qos_data, 0, sizeof(struct rtllib_qos_data));
2337 /* Pull out fixed field data */
2338 ether_addr_copy(network->bssid, beacon->header.addr3);
2339 network->capability = le16_to_cpu(beacon->capability);
2340 network->last_scanned = jiffies;
2341 network->time_stamp[0] = beacon->time_stamp[0];
2342 network->time_stamp[1] = beacon->time_stamp[1];
2343 network->beacon_interval = le16_to_cpu(beacon->beacon_interval);
2344 /* Where to pull this? beacon->listen_interval;*/
2345 network->listen_interval = 0x0A;
2346 network->rates_len = network->rates_ex_len = 0;
2347 network->ssid_len = 0;
2348 network->hidden_ssid_len = 0;
2349 memset(network->hidden_ssid, 0, sizeof(network->hidden_ssid));
2351 network->atim_window = 0;
2352 network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ?
2354 network->berp_info_valid = false;
2355 network->broadcom_cap_exist = false;
2356 network->ralink_cap_exist = false;
2357 network->atheros_cap_exist = false;
2358 network->cisco_cap_exist = false;
2359 network->unknown_cap_exist = false;
2360 network->realtek_cap_exit = false;
2361 network->marvell_cap_exist = false;
2362 network->airgo_cap_exist = false;
2363 network->Turbo_Enable = 0;
2364 network->SignalStrength = stats->SignalStrength;
2365 network->RSSI = stats->SignalStrength;
2366 network->CountryIeLen = 0;
2367 memset(network->CountryIeBuf, 0, MAX_IE_LEN);
2368 HTInitializeBssDesc(&network->bssht);
2369 if (stats->freq == RTLLIB_52GHZ_BAND) {
2370 /* for A band (No DS info) */
2371 network->channel = stats->received_channel;
2373 network->flags |= NETWORK_HAS_CCK;
2375 network->wpa_ie_len = 0;
2376 network->rsn_ie_len = 0;
2377 network->wzc_ie_len = 0;
2379 if (rtllib_parse_info_param(ieee,
2380 beacon->info_element,
2381 (stats->len - sizeof(*beacon)),
2387 if (stats->freq == RTLLIB_52GHZ_BAND)
2388 network->mode = IEEE_A;
2390 if (network->flags & NETWORK_HAS_OFDM)
2391 network->mode |= IEEE_G;
2392 if (network->flags & NETWORK_HAS_CCK)
2393 network->mode |= IEEE_B;
2396 if (network->mode == 0) {
2397 netdev_dbg(ieee->dev, "Filtered out '%s (%pM)' network.\n",
2398 escape_essid(network->ssid, network->ssid_len),
2403 if (network->bssht.bdSupportHT) {
2404 if (network->mode == IEEE_A)
2405 network->mode = IEEE_N_5G;
2406 else if (network->mode & (IEEE_G | IEEE_B))
2407 network->mode = IEEE_N_24G;
2409 if (rtllib_is_empty_essid(network->ssid, network->ssid_len))
2410 network->flags |= NETWORK_EMPTY_ESSID;
2411 stats->signal = 30 + (stats->SignalStrength * 70) / 100;
2412 stats->noise = rtllib_translate_todbm((u8)(100-stats->signal)) - 25;
2414 memcpy(&network->stats, stats, sizeof(network->stats));
2419 static inline int is_same_network(struct rtllib_network *src,
2420 struct rtllib_network *dst, u8 ssidbroad)
2422 /* A network is only a duplicate if the channel, BSSID, ESSID
2423 * and the capability field (in particular IBSS and BSS) all match.
2424 * We treat all <hidden> with the same BSSID and channel
2427 return (((src->ssid_len == dst->ssid_len) || (!ssidbroad)) &&
2428 (src->channel == dst->channel) &&
2429 !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
2430 (!memcmp(src->ssid, dst->ssid, src->ssid_len) ||
2432 ((src->capability & WLAN_CAPABILITY_IBSS) ==
2433 (dst->capability & WLAN_CAPABILITY_IBSS)) &&
2434 ((src->capability & WLAN_CAPABILITY_ESS) ==
2435 (dst->capability & WLAN_CAPABILITY_ESS)));
2439 static inline void update_network(struct rtllib_device *ieee,
2440 struct rtllib_network *dst,
2441 struct rtllib_network *src)
2446 memcpy(&dst->stats, &src->stats, sizeof(struct rtllib_rx_stats));
2447 dst->capability = src->capability;
2448 memcpy(dst->rates, src->rates, src->rates_len);
2449 dst->rates_len = src->rates_len;
2450 memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len);
2451 dst->rates_ex_len = src->rates_ex_len;
2452 if (src->ssid_len > 0) {
2453 if (dst->ssid_len == 0) {
2454 memset(dst->hidden_ssid, 0, sizeof(dst->hidden_ssid));
2455 dst->hidden_ssid_len = src->ssid_len;
2456 memcpy(dst->hidden_ssid, src->ssid, src->ssid_len);
2458 memset(dst->ssid, 0, dst->ssid_len);
2459 dst->ssid_len = src->ssid_len;
2460 memcpy(dst->ssid, src->ssid, src->ssid_len);
2463 dst->mode = src->mode;
2464 dst->flags = src->flags;
2465 dst->time_stamp[0] = src->time_stamp[0];
2466 dst->time_stamp[1] = src->time_stamp[1];
2467 if (src->flags & NETWORK_HAS_ERP_VALUE) {
2468 dst->erp_value = src->erp_value;
2469 dst->berp_info_valid = src->berp_info_valid = true;
2471 dst->beacon_interval = src->beacon_interval;
2472 dst->listen_interval = src->listen_interval;
2473 dst->atim_window = src->atim_window;
2474 dst->dtim_period = src->dtim_period;
2475 dst->dtim_data = src->dtim_data;
2476 dst->last_dtim_sta_time = src->last_dtim_sta_time;
2477 memcpy(&dst->tim, &src->tim, sizeof(struct rtllib_tim_parameters));
2479 dst->bssht.bdSupportHT = src->bssht.bdSupportHT;
2480 dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation;
2481 dst->bssht.bdHTCapLen = src->bssht.bdHTCapLen;
2482 memcpy(dst->bssht.bdHTCapBuf, src->bssht.bdHTCapBuf,
2483 src->bssht.bdHTCapLen);
2484 dst->bssht.bdHTInfoLen = src->bssht.bdHTInfoLen;
2485 memcpy(dst->bssht.bdHTInfoBuf, src->bssht.bdHTInfoBuf,
2486 src->bssht.bdHTInfoLen);
2487 dst->bssht.bdHTSpecVer = src->bssht.bdHTSpecVer;
2488 dst->bssht.bdRT2RTLongSlotTime = src->bssht.bdRT2RTLongSlotTime;
2489 dst->broadcom_cap_exist = src->broadcom_cap_exist;
2490 dst->ralink_cap_exist = src->ralink_cap_exist;
2491 dst->atheros_cap_exist = src->atheros_cap_exist;
2492 dst->realtek_cap_exit = src->realtek_cap_exit;
2493 dst->marvell_cap_exist = src->marvell_cap_exist;
2494 dst->cisco_cap_exist = src->cisco_cap_exist;
2495 dst->airgo_cap_exist = src->airgo_cap_exist;
2496 dst->unknown_cap_exist = src->unknown_cap_exist;
2497 memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
2498 dst->wpa_ie_len = src->wpa_ie_len;
2499 memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
2500 dst->rsn_ie_len = src->rsn_ie_len;
2501 memcpy(dst->wzc_ie, src->wzc_ie, src->wzc_ie_len);
2502 dst->wzc_ie_len = src->wzc_ie_len;
2504 dst->last_scanned = jiffies;
2505 /* qos related parameters */
2506 qos_active = dst->qos_data.active;
2507 old_param = dst->qos_data.param_count;
2508 dst->qos_data.supported = src->qos_data.supported;
2509 if (dst->flags & NETWORK_HAS_QOS_PARAMETERS)
2510 memcpy(&dst->qos_data, &src->qos_data,
2511 sizeof(struct rtllib_qos_data));
2512 if (dst->qos_data.supported == 1) {
2514 netdev_dbg(ieee->dev,
2515 "QoS the network %s is QoS supported\n",
2518 netdev_dbg(ieee->dev,
2519 "QoS the network is QoS supported\n");
2521 dst->qos_data.active = qos_active;
2522 dst->qos_data.old_param_count = old_param;
2524 dst->wmm_info = src->wmm_info;
2525 if (src->wmm_param[0].ac_aci_acm_aifsn ||
2526 src->wmm_param[1].ac_aci_acm_aifsn ||
2527 src->wmm_param[2].ac_aci_acm_aifsn ||
2528 src->wmm_param[3].ac_aci_acm_aifsn)
2529 memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN);
2531 dst->SignalStrength = src->SignalStrength;
2532 dst->RSSI = src->RSSI;
2533 dst->Turbo_Enable = src->Turbo_Enable;
2535 dst->CountryIeLen = src->CountryIeLen;
2536 memcpy(dst->CountryIeBuf, src->CountryIeBuf, src->CountryIeLen);
2538 dst->bWithAironetIE = src->bWithAironetIE;
2539 dst->bCkipSupported = src->bCkipSupported;
2540 memcpy(dst->CcxRmState, src->CcxRmState, 2);
2541 dst->bCcxRmEnable = src->bCcxRmEnable;
2542 dst->MBssidMask = src->MBssidMask;
2543 dst->bMBssidValid = src->bMBssidValid;
2544 memcpy(dst->MBssid, src->MBssid, 6);
2545 dst->bWithCcxVerNum = src->bWithCcxVerNum;
2546 dst->BssCcxVerNumber = src->BssCcxVerNumber;
2549 static inline int is_beacon(u16 fc)
2551 return (WLAN_FC_GET_STYPE(fc) == RTLLIB_STYPE_BEACON);
2554 static int IsPassiveChannel(struct rtllib_device *rtllib, u8 channel)
2556 if (channel > MAX_CHANNEL_NUMBER) {
2557 netdev_info(rtllib->dev, "%s(): Invalid Channel\n", __func__);
2561 if (rtllib->active_channel_map[channel] == 2)
2567 int rtllib_legal_channel(struct rtllib_device *rtllib, u8 channel)
2569 if (channel > MAX_CHANNEL_NUMBER) {
2570 netdev_info(rtllib->dev, "%s(): Invalid Channel\n", __func__);
2573 if (rtllib->active_channel_map[channel] > 0)
2578 EXPORT_SYMBOL(rtllib_legal_channel);
2580 static inline void rtllib_process_probe_response(
2581 struct rtllib_device *ieee,
2582 struct rtllib_probe_response *beacon,
2583 struct rtllib_rx_stats *stats)
2585 struct rtllib_network *target;
2586 struct rtllib_network *oldest = NULL;
2587 struct rtllib_info_element *info_element = &beacon->info_element[0];
2588 unsigned long flags;
2590 struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network),
2592 u16 frame_ctl = le16_to_cpu(beacon->header.frame_ctl);
2597 netdev_dbg(ieee->dev,
2598 "'%s' ( %pM ): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
2599 escape_essid(info_element->data, info_element->len),
2600 beacon->header.addr3,
2601 (le16_to_cpu(beacon->capability) & (1<<0xf)) ? '1' : '0',
2602 (le16_to_cpu(beacon->capability) & (1<<0xe)) ? '1' : '0',
2603 (le16_to_cpu(beacon->capability) & (1<<0xd)) ? '1' : '0',
2604 (le16_to_cpu(beacon->capability) & (1<<0xc)) ? '1' : '0',
2605 (le16_to_cpu(beacon->capability) & (1<<0xb)) ? '1' : '0',
2606 (le16_to_cpu(beacon->capability) & (1<<0xa)) ? '1' : '0',
2607 (le16_to_cpu(beacon->capability) & (1<<0x9)) ? '1' : '0',
2608 (le16_to_cpu(beacon->capability) & (1<<0x8)) ? '1' : '0',
2609 (le16_to_cpu(beacon->capability) & (1<<0x7)) ? '1' : '0',
2610 (le16_to_cpu(beacon->capability) & (1<<0x6)) ? '1' : '0',
2611 (le16_to_cpu(beacon->capability) & (1<<0x5)) ? '1' : '0',
2612 (le16_to_cpu(beacon->capability) & (1<<0x4)) ? '1' : '0',
2613 (le16_to_cpu(beacon->capability) & (1<<0x3)) ? '1' : '0',
2614 (le16_to_cpu(beacon->capability) & (1<<0x2)) ? '1' : '0',
2615 (le16_to_cpu(beacon->capability) & (1<<0x1)) ? '1' : '0',
2616 (le16_to_cpu(beacon->capability) & (1<<0x0)) ? '1' : '0');
2618 if (rtllib_network_init(ieee, beacon, network, stats)) {
2619 netdev_dbg(ieee->dev, "Dropped '%s' ( %pM) via %s.\n",
2620 escape_essid(info_element->data, info_element->len),
2621 beacon->header.addr3,
2622 is_beacon(frame_ctl) ? "BEACON" : "PROBE RESPONSE");
2627 if (!rtllib_legal_channel(ieee, network->channel))
2630 if (WLAN_FC_GET_STYPE(frame_ctl) == RTLLIB_STYPE_PROBE_RESP) {
2631 if (IsPassiveChannel(ieee, network->channel)) {
2632 netdev_info(ieee->dev,
2633 "GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n",
2639 /* The network parsed correctly -- so now we scan our known networks
2640 * to see if we can find it in our list.
2642 * NOTE: This search is definitely not optimized. Once its doing
2643 * the "right thing" we'll optimize it for efficiency if
2647 /* Search for this entry in the list and update it if it is
2651 spin_lock_irqsave(&ieee->lock, flags);
2652 if (is_same_network(&ieee->current_network, network,
2653 (network->ssid_len ? 1 : 0))) {
2654 update_network(ieee, &ieee->current_network, network);
2655 if ((ieee->current_network.mode == IEEE_N_24G ||
2656 ieee->current_network.mode == IEEE_G)
2657 && ieee->current_network.berp_info_valid) {
2658 if (ieee->current_network.erp_value & ERP_UseProtection)
2659 ieee->current_network.buseprotection = true;
2661 ieee->current_network.buseprotection = false;
2663 if (is_beacon(frame_ctl)) {
2664 if (ieee->state >= RTLLIB_LINKED)
2665 ieee->LinkDetectInfo.NumRecvBcnInPeriod++;
2668 list_for_each_entry(target, &ieee->network_list, list) {
2669 if (is_same_network(target, network,
2670 (target->ssid_len ? 1 : 0)))
2672 if ((oldest == NULL) ||
2673 (target->last_scanned < oldest->last_scanned))
2677 /* If we didn't find a match, then get a new network slot to initialize
2678 * with this beacon's information
2680 if (&target->list == &ieee->network_list) {
2681 if (list_empty(&ieee->network_free_list)) {
2682 /* If there are no more slots, expire the oldest */
2683 list_del(&oldest->list);
2685 netdev_dbg(ieee->dev,
2686 "Expired '%s' ( %pM) from network list.\n",
2687 escape_essid(target->ssid, target->ssid_len),
2690 /* Otherwise just pull from the free list */
2691 target = list_entry(ieee->network_free_list.next,
2692 struct rtllib_network, list);
2693 list_del(ieee->network_free_list.next);
2696 netdev_dbg(ieee->dev, "Adding '%s' ( %pM) via %s.\n",
2697 escape_essid(network->ssid, network->ssid_len),
2699 is_beacon(frame_ctl) ? "BEACON" : "PROBE RESPONSE");
2701 memcpy(target, network, sizeof(*target));
2702 list_add_tail(&target->list, &ieee->network_list);
2703 if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
2704 rtllib_softmac_new_net(ieee, network);
2706 netdev_dbg(ieee->dev, "Updating '%s' ( %pM) via %s.\n",
2707 escape_essid(target->ssid, target->ssid_len),
2709 is_beacon(frame_ctl) ? "BEACON" : "PROBE RESPONSE");
2711 /* we have an entry and we are going to update it. But this
2712 * entry may be already expired. In this case we do the same
2713 * as we found a new net and call the new_net handler
2715 renew = !time_after(target->last_scanned + ieee->scan_age,
2717 if ((!target->ssid_len) &&
2718 (((network->ssid_len > 0) && (target->hidden_ssid_len == 0))
2719 || ((ieee->current_network.ssid_len == network->ssid_len) &&
2720 (strncmp(ieee->current_network.ssid, network->ssid,
2721 network->ssid_len) == 0) &&
2722 (ieee->state == RTLLIB_NOLINK))))
2724 update_network(ieee, target, network);
2725 if (renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE))
2726 rtllib_softmac_new_net(ieee, network);
2729 spin_unlock_irqrestore(&ieee->lock, flags);
2730 if (is_beacon(frame_ctl) &&
2731 is_same_network(&ieee->current_network, network,
2732 (network->ssid_len ? 1 : 0)) &&
2733 (ieee->state == RTLLIB_LINKED)) {
2734 if (ieee->handle_beacon != NULL)
2735 ieee->handle_beacon(ieee->dev, beacon,
2736 &ieee->current_network);
2742 static void rtllib_rx_mgt(struct rtllib_device *ieee,
2743 struct sk_buff *skb,
2744 struct rtllib_rx_stats *stats)
2746 struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data;
2748 if ((WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)) !=
2749 RTLLIB_STYPE_PROBE_RESP) &&
2750 (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)) !=
2751 RTLLIB_STYPE_BEACON))
2752 ieee->last_rx_ps_time = jiffies;
2754 switch (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))) {
2756 case RTLLIB_STYPE_BEACON:
2757 netdev_dbg(ieee->dev, "received BEACON (%d)\n",
2758 WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)));
2759 rtllib_process_probe_response(
2760 ieee, (struct rtllib_probe_response *)header,
2763 if (ieee->sta_sleep || (ieee->ps != RTLLIB_PS_DISABLED &&
2764 ieee->iw_mode == IW_MODE_INFRA &&
2765 ieee->state == RTLLIB_LINKED))
2766 tasklet_schedule(&ieee->ps_task);
2770 case RTLLIB_STYPE_PROBE_RESP:
2771 netdev_dbg(ieee->dev, "received PROBE RESPONSE (%d)\n",
2772 WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)));
2773 rtllib_process_probe_response(ieee,
2774 (struct rtllib_probe_response *)header, stats);
2776 case RTLLIB_STYPE_PROBE_REQ:
2777 netdev_dbg(ieee->dev, "received PROBE RESQUEST (%d)\n",
2778 WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)));
2779 if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
2780 ((ieee->iw_mode == IW_MODE_ADHOC ||
2781 ieee->iw_mode == IW_MODE_MASTER) &&
2782 ieee->state == RTLLIB_LINKED))
2783 rtllib_rx_probe_rq(ieee, skb);