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 inline void rtllib_monitor_rx(struct rtllib_device *ieee,
48 struct sk_buff *skb, struct rtllib_rx_stats *rx_status,
52 skb_reset_mac_header(skb);
53 skb_pull(skb, hdr_length);
54 skb->pkt_type = PACKET_OTHERHOST;
55 skb->protocol = htons(ETH_P_80211_RAW);
56 memset(skb->cb, 0, sizeof(skb->cb));
60 /* Called only as a tasklet (software IRQ) */
61 static struct rtllib_frag_entry *
62 rtllib_frag_cache_find(struct rtllib_device *ieee, unsigned int seq,
63 unsigned int frag, u8 tid, u8 *src, u8 *dst)
65 struct rtllib_frag_entry *entry;
68 for (i = 0; i < RTLLIB_FRAG_CACHE_LEN; i++) {
69 entry = &ieee->frag_cache[tid][i];
70 if (entry->skb != NULL &&
71 time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
73 "expiring fragment cache entry seq=%u last_frag=%u\n",
74 entry->seq, entry->last_frag);
75 dev_kfree_skb_any(entry->skb);
79 if (entry->skb != NULL && entry->seq == seq &&
80 (entry->last_frag + 1 == frag || frag == -1) &&
81 memcmp(entry->src_addr, src, ETH_ALEN) == 0 &&
82 memcmp(entry->dst_addr, dst, ETH_ALEN) == 0)
89 /* Called only as a tasklet (software IRQ) */
90 static struct sk_buff *
91 rtllib_frag_cache_get(struct rtllib_device *ieee,
92 struct rtllib_hdr_4addr *hdr)
94 struct sk_buff *skb = NULL;
95 u16 fc = le16_to_cpu(hdr->frame_ctl);
96 u16 sc = le16_to_cpu(hdr->seq_ctl);
97 unsigned int frag = WLAN_GET_SEQ_FRAG(sc);
98 unsigned int seq = WLAN_GET_SEQ_SEQ(sc);
99 struct rtllib_frag_entry *entry;
100 struct rtllib_hdr_3addrqos *hdr_3addrqos;
101 struct rtllib_hdr_4addrqos *hdr_4addrqos;
104 if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) {
105 hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr;
106 tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID;
109 } else if (RTLLIB_QOS_HAS_SEQ(fc)) {
110 hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr;
111 tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID;
119 /* Reserve enough space to fit maximum frame length */
120 skb = dev_alloc_skb(ieee->dev->mtu +
121 sizeof(struct rtllib_hdr_4addr) +
126 (RTLLIB_QOS_HAS_SEQ(fc) ? 2 : 0) /* QOS Control */);
130 entry = &ieee->frag_cache[tid][ieee->frag_next_idx[tid]];
131 ieee->frag_next_idx[tid]++;
132 if (ieee->frag_next_idx[tid] >= RTLLIB_FRAG_CACHE_LEN)
133 ieee->frag_next_idx[tid] = 0;
135 if (entry->skb != NULL)
136 dev_kfree_skb_any(entry->skb);
138 entry->first_frag_time = jiffies;
140 entry->last_frag = frag;
142 ether_addr_copy(entry->src_addr, hdr->addr2);
143 ether_addr_copy(entry->dst_addr, hdr->addr1);
145 /* received a fragment of a frame for which the head fragment
146 * should have already been received
148 entry = rtllib_frag_cache_find(ieee, seq, frag, tid, hdr->addr2,
151 entry->last_frag = frag;
160 /* Called only as a tasklet (software IRQ) */
161 static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee,
162 struct rtllib_hdr_4addr *hdr)
164 u16 fc = le16_to_cpu(hdr->frame_ctl);
165 u16 sc = le16_to_cpu(hdr->seq_ctl);
166 unsigned int seq = WLAN_GET_SEQ_SEQ(sc);
167 struct rtllib_frag_entry *entry;
168 struct rtllib_hdr_3addrqos *hdr_3addrqos;
169 struct rtllib_hdr_4addrqos *hdr_4addrqos;
172 if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) {
173 hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr;
174 tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID;
177 } else if (RTLLIB_QOS_HAS_SEQ(fc)) {
178 hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr;
179 tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID;
186 entry = rtllib_frag_cache_find(ieee, seq, -1, tid, hdr->addr2,
190 netdev_dbg(ieee->dev,
191 "Couldn't invalidate fragment cache entry (seq=%u)\n",
200 /* rtllib_rx_frame_mgtmt
202 * Responsible for handling management control frames
204 * Called by rtllib_rx
207 rtllib_rx_frame_mgmt(struct rtllib_device *ieee, struct sk_buff *skb,
208 struct rtllib_rx_stats *rx_stats, u16 type,
211 /* On the struct stats definition there is written that
212 * this is not mandatory.... but seems that the probe
213 * response parser uses it
215 struct rtllib_hdr_3addr *hdr = (struct rtllib_hdr_3addr *)skb->data;
217 rx_stats->len = skb->len;
218 rtllib_rx_mgt(ieee, skb, rx_stats);
219 if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN))) {
220 dev_kfree_skb_any(skb);
223 rtllib_rx_frame_softmac(ieee, skb, rx_stats, type, stype);
225 dev_kfree_skb_any(skb);
230 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation
231 * Ethernet-II snap header (RFC1042 for most EtherTypes)
233 static unsigned char rfc1042_header[] = {
234 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00
236 /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
237 static unsigned char bridge_tunnel_header[] = {
238 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8
240 /* No encapsulation header if EtherType < 0x600 (=length) */
242 /* Called by rtllib_rx_frame_decrypt */
243 static int rtllib_is_eapol_frame(struct rtllib_device *ieee,
244 struct sk_buff *skb, size_t hdrlen)
246 struct net_device *dev = ieee->dev;
248 struct rtllib_hdr_4addr *hdr;
254 hdr = (struct rtllib_hdr_4addr *) skb->data;
255 fc = le16_to_cpu(hdr->frame_ctl);
257 /* check that the frame is unicast frame to us */
258 if ((fc & (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS)) ==
260 memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0 &&
261 memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) {
262 /* ToDS frame with own addr BSSID and DA */
263 } else if ((fc & (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS)) ==
264 RTLLIB_FCTL_FROMDS &&
265 memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) {
266 /* FromDS frame with own addr as DA */
270 if (skb->len < 24 + 8)
273 /* check for port access entity Ethernet type */
274 pos = skb->data + hdrlen;
275 ethertype = (pos[6] << 8) | pos[7];
276 if (ethertype == ETH_P_PAE)
282 /* Called only as a tasklet (software IRQ), by rtllib_rx */
284 rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
285 struct lib80211_crypt_data *crypt)
287 struct rtllib_hdr_4addr *hdr;
290 if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
293 if (ieee->hwsec_active) {
294 struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
296 tcb_desc->bHwSec = 1;
298 if (ieee->need_sw_enc)
299 tcb_desc->bHwSec = 0;
302 hdr = (struct rtllib_hdr_4addr *) skb->data;
303 hdrlen = rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
305 atomic_inc(&crypt->refcnt);
306 res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
307 atomic_dec(&crypt->refcnt);
309 netdev_dbg(ieee->dev, "decryption failed (SA= %pM) res=%d\n",
312 netdev_dbg(ieee->dev,
313 "Decryption failed ICV mismatch (key %d)\n",
314 skb->data[hdrlen + 3] >> 6);
315 ieee->ieee_stats.rx_discards_undecryptable++;
323 /* Called only as a tasklet (software IRQ), by rtllib_rx */
325 rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb,
326 int keyidx, struct lib80211_crypt_data *crypt)
328 struct rtllib_hdr_4addr *hdr;
331 if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
333 if (ieee->hwsec_active) {
334 struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
336 tcb_desc->bHwSec = 1;
338 if (ieee->need_sw_enc)
339 tcb_desc->bHwSec = 0;
342 hdr = (struct rtllib_hdr_4addr *) skb->data;
343 hdrlen = rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
345 atomic_inc(&crypt->refcnt);
346 res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
347 atomic_dec(&crypt->refcnt);
349 printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed (SA= %pM keyidx=%d)\n",
350 ieee->dev->name, hdr->addr2, keyidx);
358 /* this function is stolen from ipw2200 driver*/
359 #define IEEE_PACKET_RETRY_TIME (5*HZ)
360 static int is_duplicate_packet(struct rtllib_device *ieee,
361 struct rtllib_hdr_4addr *header)
363 u16 fc = le16_to_cpu(header->frame_ctl);
364 u16 sc = le16_to_cpu(header->seq_ctl);
365 u16 seq = WLAN_GET_SEQ_SEQ(sc);
366 u16 frag = WLAN_GET_SEQ_FRAG(sc);
367 u16 *last_seq, *last_frag;
368 unsigned long *last_time;
369 struct rtllib_hdr_3addrqos *hdr_3addrqos;
370 struct rtllib_hdr_4addrqos *hdr_4addrqos;
373 if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) {
374 hdr_4addrqos = (struct rtllib_hdr_4addrqos *)header;
375 tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID;
378 } else if (RTLLIB_QOS_HAS_SEQ(fc)) {
379 hdr_3addrqos = (struct rtllib_hdr_3addrqos *)header;
380 tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID;
387 switch (ieee->iw_mode) {
391 struct ieee_ibss_seq *entry = NULL;
392 u8 *mac = header->addr2;
393 int index = mac[5] % IEEE_IBSS_MAC_HASH_SIZE;
395 list_for_each(p, &ieee->ibss_mac_hash[index]) {
396 entry = list_entry(p, struct ieee_ibss_seq, list);
397 if (!memcmp(entry->mac, mac, ETH_ALEN))
400 if (p == &ieee->ibss_mac_hash[index]) {
401 entry = kmalloc(sizeof(struct ieee_ibss_seq), GFP_ATOMIC);
405 ether_addr_copy(entry->mac, mac);
406 entry->seq_num[tid] = seq;
407 entry->frag_num[tid] = frag;
408 entry->packet_time[tid] = jiffies;
409 list_add(&entry->list, &ieee->ibss_mac_hash[index]);
412 last_seq = &entry->seq_num[tid];
413 last_frag = &entry->frag_num[tid];
414 last_time = &entry->packet_time[tid];
419 last_seq = &ieee->last_rxseq_num[tid];
420 last_frag = &ieee->last_rxfrag_num[tid];
421 last_time = &ieee->last_packet_time[tid];
427 if ((*last_seq == seq) &&
428 time_after(*last_time + IEEE_PACKET_RETRY_TIME, jiffies)) {
429 if (*last_frag == frag)
431 if (*last_frag + 1 != frag)
432 /* out-of-order fragment */
438 *last_time = jiffies;
446 static bool AddReorderEntry(struct rx_ts_record *pTS,
447 struct rx_reorder_entry *pReorderEntry)
449 struct list_head *pList = &pTS->RxPendingPktList;
451 while (pList->next != &pTS->RxPendingPktList) {
452 if (SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)
453 list_entry(pList->next, struct rx_reorder_entry,
456 else if (SN_EQUAL(pReorderEntry->SeqNum,
457 ((struct rx_reorder_entry *)list_entry(pList->next,
458 struct rx_reorder_entry, List))->SeqNum))
463 pReorderEntry->List.next = pList->next;
464 pReorderEntry->List.next->prev = &pReorderEntry->List;
465 pReorderEntry->List.prev = pList;
466 pList->next = &pReorderEntry->List;
471 void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prxbIndicateArray, u8 index)
473 struct net_device_stats *stats = &ieee->stats;
477 for (j = 0; j < index; j++) {
478 struct rtllib_rxb *prxb = prxbIndicateArray[j];
480 for (i = 0; i < prxb->nr_subframes; i++) {
481 struct sk_buff *sub_skb = prxb->subframes[i];
483 /* convert hdr + possible LLC headers into Ethernet header */
484 ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7];
485 if (sub_skb->len >= 8 &&
486 ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 &&
487 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
488 memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
489 /* remove RFC1042 or Bridge-Tunnel encapsulation
490 * and replace EtherType
492 skb_pull(sub_skb, SNAP_SIZE);
493 memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN);
494 memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN);
497 /* Leave Ethernet header part of hdr and full payload */
499 memcpy(skb_push(sub_skb, 2), &len, 2);
500 memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN);
501 memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN);
504 /* Indicate the packets to upper layer */
507 stats->rx_bytes += sub_skb->len;
509 memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
510 sub_skb->protocol = eth_type_trans(sub_skb, ieee->dev);
511 sub_skb->dev = ieee->dev;
512 sub_skb->dev->stats.rx_packets++;
513 sub_skb->dev->stats.rx_bytes += sub_skb->len;
514 sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
515 ieee->last_rx_ps_time = jiffies;
524 void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS)
526 struct rx_reorder_entry *pRxReorderEntry;
529 del_timer_sync(&pTS->RxPktPendingTimer);
530 while (!list_empty(&pTS->RxPendingPktList)) {
531 if (RfdCnt >= REORDER_WIN_SIZE) {
532 netdev_info(ieee->dev,
533 "-------------->%s() error! RfdCnt >= REORDER_WIN_SIZE\n",
538 pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev, struct rx_reorder_entry, List);
539 RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate SeqNum %d!\n", __func__, pRxReorderEntry->SeqNum);
540 list_del_init(&pRxReorderEntry->List);
542 ieee->RfdArray[RfdCnt] = pRxReorderEntry->prxb;
545 list_add_tail(&pRxReorderEntry->List, &ieee->RxReorder_Unused_List);
547 rtllib_indicate_packets(ieee, ieee->RfdArray, RfdCnt);
549 pTS->RxIndicateSeq = 0xffff;
552 static void RxReorderIndicatePacket(struct rtllib_device *ieee,
553 struct rtllib_rxb *prxb,
554 struct rx_ts_record *pTS, u16 SeqNum)
556 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
557 struct rx_reorder_entry *pReorderEntry = NULL;
558 u8 WinSize = pHTInfo->RxReorderWinSize;
561 bool bMatchWinStart = false, bPktInBuf = false;
564 RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Seq is %d, pTS->RxIndicateSeq is %d, WinSize is %d\n", __func__, SeqNum,
565 pTS->RxIndicateSeq, WinSize);
567 spin_lock_irqsave(&(ieee->reorder_spinlock), flags);
569 WinEnd = (pTS->RxIndicateSeq + WinSize - 1) % 4096;
570 /* Rx Reorder initialize condition.*/
571 if (pTS->RxIndicateSeq == 0xffff)
572 pTS->RxIndicateSeq = SeqNum;
574 /* Drop out the packet which SeqNum is smaller than WinStart */
575 if (SN_LESS(SeqNum, pTS->RxIndicateSeq)) {
576 RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packet Drop! IndicateSeq: %d, NewSeq: %d\n",
577 pTS->RxIndicateSeq, SeqNum);
578 pHTInfo->RxReorderDropCounter++;
582 for (i = 0; i < prxb->nr_subframes; i++)
583 dev_kfree_skb(prxb->subframes[i]);
587 spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
591 /* Sliding window manipulation. Conditions includes:
592 * 1. Incoming SeqNum is equal to WinStart =>Window shift 1
593 * 2. Incoming SeqNum is larger than the WinEnd => Window shift N
595 if (SN_EQUAL(SeqNum, pTS->RxIndicateSeq)) {
596 pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096;
597 bMatchWinStart = true;
598 } else if (SN_LESS(WinEnd, SeqNum)) {
599 if (SeqNum >= (WinSize - 1))
600 pTS->RxIndicateSeq = SeqNum + 1 - WinSize;
602 pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum + 1)) + 1;
603 RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum);
606 /* Indication process.
607 * After Packet dropping and Sliding Window shifting as above, we can
608 * now just indicate the packets with the SeqNum smaller than latest
609 * WinStart and struct buffer other packets.
611 * For Rx Reorder condition:
612 * 1. All packets with SeqNum smaller than WinStart => Indicate
613 * 2. All packets with SeqNum larger than or equal to
614 * WinStart => Buffer it.
616 if (bMatchWinStart) {
617 /* Current packet is going to be indicated.*/
618 RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",
619 pTS->RxIndicateSeq, SeqNum);
620 ieee->prxbIndicateArray[0] = prxb;
623 /* Current packet is going to be inserted into pending list.*/
624 if (!list_empty(&ieee->RxReorder_Unused_List)) {
625 pReorderEntry = (struct rx_reorder_entry *)
626 list_entry(ieee->RxReorder_Unused_List.next,
627 struct rx_reorder_entry, List);
628 list_del_init(&pReorderEntry->List);
630 /* Make a reorder entry and insert into a the packet list.*/
631 pReorderEntry->SeqNum = SeqNum;
632 pReorderEntry->prxb = prxb;
634 if (!AddReorderEntry(pTS, pReorderEntry)) {
635 RTLLIB_DEBUG(RTLLIB_DL_REORDER,
636 "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n",
637 __func__, pTS->RxIndicateSeq,
639 list_add_tail(&pReorderEntry->List,
640 &ieee->RxReorder_Unused_List); {
643 for (i = 0; i < prxb->nr_subframes; i++)
644 dev_kfree_skb(prxb->subframes[i]);
649 RTLLIB_DEBUG(RTLLIB_DL_REORDER,
650 "Pkt insert into struct buffer!! IndicateSeq: %d, NewSeq: %d\n",
651 pTS->RxIndicateSeq, SeqNum);
654 /* Packets are dropped if there are not enough reorder
655 * entries. This part should be modified!! We can just
656 * indicate all the packets in struct buffer and get
659 netdev_err(ieee->dev,
660 "%s(): There is no reorder entry! Packet is dropped!\n",
665 for (i = 0; i < prxb->nr_subframes; i++)
666 dev_kfree_skb(prxb->subframes[i]);
673 /* Check if there is any packet need indicate.*/
674 while (!list_empty(&pTS->RxPendingPktList)) {
675 RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): start RREORDER indicate\n", __func__);
677 pReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev,
678 struct rx_reorder_entry, List);
679 if (SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) ||
680 SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) {
681 /* This protect struct buffer from overflow. */
682 if (index >= REORDER_WIN_SIZE) {
683 netdev_err(ieee->dev,
684 "%s(): Buffer overflow!\n",
690 list_del_init(&pReorderEntry->List);
692 if (SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq))
693 pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096;
695 ieee->prxbIndicateArray[index] = pReorderEntry->prxb;
696 RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate SeqNum %d!\n", __func__, pReorderEntry->SeqNum);
699 list_add_tail(&pReorderEntry->List,
700 &ieee->RxReorder_Unused_List);
707 /* Handling pending timer. Set this timer to prevent from long time
711 if (timer_pending(&pTS->RxPktPendingTimer))
712 del_timer_sync(&pTS->RxPktPendingTimer);
713 pTS->RxTimeoutIndicateSeq = 0xffff;
715 if (index > REORDER_WIN_SIZE) {
716 netdev_err(ieee->dev,
717 "%s(): Rx Reorder struct buffer full!\n",
719 spin_unlock_irqrestore(&(ieee->reorder_spinlock),
723 rtllib_indicate_packets(ieee, ieee->prxbIndicateArray, index);
727 if (bPktInBuf && pTS->RxTimeoutIndicateSeq == 0xffff) {
728 RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): SET rx timeout timer\n",
730 pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq;
731 mod_timer(&pTS->RxPktPendingTimer, jiffies +
732 msecs_to_jiffies(pHTInfo->RxReorderPendingTime));
734 spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
737 static u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb,
738 struct rtllib_rx_stats *rx_stats,
739 struct rtllib_rxb *rxb, u8 *src, u8 *dst)
741 struct rtllib_hdr_3addr *hdr = (struct rtllib_hdr_3addr *)skb->data;
742 u16 fc = le16_to_cpu(hdr->frame_ctl);
744 u16 LLCOffset = sizeof(struct rtllib_hdr_3addr);
746 bool bIsAggregateFrame = false;
747 u16 nSubframe_Length;
748 u8 nPadding_Length = 0;
750 struct sk_buff *sub_skb;
752 /* just for debug purpose */
753 SeqNum = WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr->seq_ctl));
754 if ((RTLLIB_QOS_HAS_SEQ(fc)) &&
755 (((union frameqos *)(skb->data + RTLLIB_3ADDR_LEN))->field.reserved))
756 bIsAggregateFrame = true;
758 if (RTLLIB_QOS_HAS_SEQ(fc))
760 if (rx_stats->bContainHTC)
761 LLCOffset += sHTCLng;
763 ChkLength = LLCOffset;
765 if (skb->len <= ChkLength)
768 skb_pull(skb, LLCOffset);
769 ieee->bIsAggregateFrame = bIsAggregateFrame;
770 if (!bIsAggregateFrame) {
771 rxb->nr_subframes = 1;
773 /* altered by clark 3/30/2010
774 * The struct buffer size of the skb indicated to upper layer
775 * must be less than 5000, or the defraged IP datagram
776 * in the IP layer will exceed "ipfrag_high_tresh" and be
777 * discarded. so there must not use the function
778 * "skb_copy" and "skb_clone" for "skb".
781 /* Allocate new skb for releasing to upper layer */
782 sub_skb = dev_alloc_skb(RTLLIB_SKBBUFFER_SIZE);
785 skb_reserve(sub_skb, 12);
786 data_ptr = (u8 *)skb_put(sub_skb, skb->len);
787 memcpy(data_ptr, skb->data, skb->len);
788 sub_skb->dev = ieee->dev;
790 rxb->subframes[0] = sub_skb;
792 memcpy(rxb->src, src, ETH_ALEN);
793 memcpy(rxb->dst, dst, ETH_ALEN);
794 rxb->subframes[0]->dev = ieee->dev;
798 rxb->nr_subframes = 0;
799 memcpy(rxb->src, src, ETH_ALEN);
800 memcpy(rxb->dst, dst, ETH_ALEN);
801 while (skb->len > ETHERNET_HEADER_SIZE) {
802 /* Offset 12 denote 2 mac address */
803 nSubframe_Length = *((u16 *)(skb->data + 12));
804 nSubframe_Length = (nSubframe_Length >> 8) +
805 (nSubframe_Length << 8);
807 if (skb->len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) {
808 netdev_info(ieee->dev,
809 "%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",
810 __func__, rxb->nr_subframes);
811 netdev_info(ieee->dev,
812 "%s: A-MSDU parse error!! Subframe Length: %d\n",
813 __func__, nSubframe_Length);
814 netdev_info(ieee->dev,
815 "nRemain_Length is %d and nSubframe_Length is : %d\n",
816 skb->len, nSubframe_Length);
817 netdev_info(ieee->dev,
818 "The Packet SeqNum is %d\n",
823 /* move the data point to data content */
824 skb_pull(skb, ETHERNET_HEADER_SIZE);
826 /* altered by clark 3/30/2010
827 * The struct buffer size of the skb indicated to upper layer
828 * must be less than 5000, or the defraged IP datagram
829 * in the IP layer will exceed "ipfrag_high_tresh" and be
830 * discarded. so there must not use the function
831 * "skb_copy" and "skb_clone" for "skb".
834 /* Allocate new skb for releasing to upper layer */
835 sub_skb = dev_alloc_skb(nSubframe_Length + 12);
838 skb_reserve(sub_skb, 12);
839 data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length);
840 memcpy(data_ptr, skb->data, nSubframe_Length);
842 sub_skb->dev = ieee->dev;
843 rxb->subframes[rxb->nr_subframes++] = sub_skb;
844 if (rxb->nr_subframes >= MAX_SUBFRAME_COUNT) {
845 netdev_dbg(ieee->dev,
846 "ParseSubframe(): Too many Subframes! Packets dropped!\n");
849 skb_pull(skb, nSubframe_Length);
852 nPadding_Length = 4 - ((nSubframe_Length +
853 ETHERNET_HEADER_SIZE) % 4);
854 if (nPadding_Length == 4)
857 if (skb->len < nPadding_Length)
860 skb_pull(skb, nPadding_Length);
864 return rxb->nr_subframes;
868 static size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee,
870 struct rtllib_rx_stats *rx_stats)
872 struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;
873 u16 fc = le16_to_cpu(hdr->frame_ctl);
876 hdrlen = rtllib_get_hdrlen(fc);
877 if (HTCCheck(ieee, skb->data)) {
879 netdev_info(ieee->dev, "%s: find HTCControl!\n",
882 rx_stats->bContainHTC = true;
885 if (RTLLIB_QOS_HAS_SEQ(fc))
886 rx_stats->bIsQosData = true;
891 static int rtllib_rx_check_duplicate(struct rtllib_device *ieee,
892 struct sk_buff *skb, u8 multicast)
894 struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;
896 u8 frag, type, stype;
898 fc = le16_to_cpu(hdr->frame_ctl);
899 type = WLAN_FC_GET_TYPE(fc);
900 stype = WLAN_FC_GET_STYPE(fc);
901 sc = le16_to_cpu(hdr->seq_ctl);
902 frag = WLAN_GET_SEQ_FRAG(sc);
904 if ((ieee->pHTInfo->bCurRxReorderEnable == false) ||
905 !ieee->current_network.qos_data.active ||
906 !IsDataFrame(skb->data) ||
907 IsLegacyDataFrame(skb->data)) {
908 if (!((type == RTLLIB_FTYPE_MGMT) && (stype == RTLLIB_STYPE_BEACON))) {
909 if (is_duplicate_packet(ieee, hdr))
913 struct rx_ts_record *pRxTS = NULL;
915 if (GetTs(ieee, (struct ts_common_info **) &pRxTS, hdr->addr2,
916 (u8)Frame_QoSTID((u8 *)(skb->data)), RX_DIR, true)) {
917 if ((fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) &&
918 (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum))
920 pRxTS->RxLastFragNum = frag;
921 pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc);
923 netdev_warn(ieee->dev, "%s(): No TS! Skip the check!\n",
932 static void rtllib_rx_extract_addr(struct rtllib_device *ieee,
933 struct rtllib_hdr_4addr *hdr, u8 *dst,
936 u16 fc = le16_to_cpu(hdr->frame_ctl);
938 switch (fc & (RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) {
939 case RTLLIB_FCTL_FROMDS:
940 ether_addr_copy(dst, hdr->addr1);
941 ether_addr_copy(src, hdr->addr3);
942 ether_addr_copy(bssid, hdr->addr2);
944 case RTLLIB_FCTL_TODS:
945 ether_addr_copy(dst, hdr->addr3);
946 ether_addr_copy(src, hdr->addr2);
947 ether_addr_copy(bssid, hdr->addr1);
949 case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS:
950 ether_addr_copy(dst, hdr->addr3);
951 ether_addr_copy(src, hdr->addr4);
952 ether_addr_copy(bssid, ieee->current_network.bssid);
955 ether_addr_copy(dst, hdr->addr1);
956 ether_addr_copy(src, hdr->addr2);
957 ether_addr_copy(bssid, hdr->addr3);
962 static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc,
963 u8 *dst, u8 *src, u8 *bssid, u8 *addr2)
967 type = WLAN_FC_GET_TYPE(fc);
968 stype = WLAN_FC_GET_STYPE(fc);
970 /* Filter frames from different BSS */
971 if (((fc & RTLLIB_FCTL_DSTODS) != RTLLIB_FCTL_DSTODS) &&
972 !ether_addr_equal(ieee->current_network.bssid, bssid) &&
973 !is_zero_ether_addr(ieee->current_network.bssid)) {
977 /* Filter packets sent by an STA that will be forwarded by AP */
978 if (ieee->IntelPromiscuousModeInfo.bPromiscuousOn &&
979 ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame) {
980 if ((fc & RTLLIB_FCTL_TODS) && !(fc & RTLLIB_FCTL_FROMDS) &&
981 !ether_addr_equal(dst, ieee->current_network.bssid) &&
982 ether_addr_equal(bssid, ieee->current_network.bssid)) {
987 /* Nullfunc frames may have PS-bit set, so they must be passed to
988 * hostap_handle_sta_rx() before being dropped here.
990 if (!ieee->IntelPromiscuousModeInfo.bPromiscuousOn) {
991 if (stype != RTLLIB_STYPE_DATA &&
992 stype != RTLLIB_STYPE_DATA_CFACK &&
993 stype != RTLLIB_STYPE_DATA_CFPOLL &&
994 stype != RTLLIB_STYPE_DATA_CFACKPOLL &&
995 stype != RTLLIB_STYPE_QOS_DATA) {
996 if (stype != RTLLIB_STYPE_NULLFUNC)
997 netdev_dbg(ieee->dev,
998 "RX: dropped data frame with no data (type=0x%02x, subtype=0x%02x)\n",
1004 if (ieee->iw_mode != IW_MODE_MESH) {
1005 /* packets from our adapter are dropped (echo) */
1006 if (!memcmp(src, ieee->dev->dev_addr, ETH_ALEN))
1009 /* {broad,multi}cast packets to our BSS go through */
1010 if (is_multicast_ether_addr(dst)) {
1011 if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN))
1018 static int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb,
1019 struct lib80211_crypt_data **crypt, size_t hdrlen)
1021 struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;
1022 u16 fc = le16_to_cpu(hdr->frame_ctl);
1025 if (ieee->host_decrypt) {
1026 if (skb->len >= hdrlen + 3)
1027 idx = skb->data[hdrlen + 3] >> 6;
1029 *crypt = ieee->crypt_info.crypt[idx];
1030 /* allow NULL decrypt to indicate an station specific override
1031 * for default encryption
1033 if (*crypt && ((*crypt)->ops == NULL ||
1034 (*crypt)->ops->decrypt_mpdu == NULL))
1037 if (!*crypt && (fc & RTLLIB_FCTL_WEP)) {
1038 /* This seems to be triggered by some (multicast?)
1039 * frames from other than current BSS, so just drop the
1040 * frames silently instead of filling system log with
1043 netdev_dbg(ieee->dev,
1044 "Decryption failed (not set) (SA= %pM)\n",
1046 ieee->ieee_stats.rx_discards_undecryptable++;
1054 static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
1055 struct rtllib_rx_stats *rx_stats,
1056 struct lib80211_crypt_data *crypt, size_t hdrlen)
1058 struct rtllib_hdr_4addr *hdr;
1063 hdr = (struct rtllib_hdr_4addr *)skb->data;
1064 fc = le16_to_cpu(hdr->frame_ctl);
1065 sc = le16_to_cpu(hdr->seq_ctl);
1066 frag = WLAN_GET_SEQ_FRAG(sc);
1068 if ((!rx_stats->Decrypted))
1069 ieee->need_sw_enc = 1;
1071 ieee->need_sw_enc = 0;
1073 keyidx = rtllib_rx_frame_decrypt(ieee, skb, crypt);
1074 if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && (keyidx < 0)) {
1075 netdev_info(ieee->dev, "%s: decrypt frame error\n", __func__);
1079 hdr = (struct rtllib_hdr_4addr *) skb->data;
1080 if ((frag != 0 || (fc & RTLLIB_FCTL_MOREFRAGS))) {
1082 struct sk_buff *frag_skb = rtllib_frag_cache_get(ieee, hdr);
1084 netdev_dbg(ieee->dev, "Rx Fragment received (%u)\n", frag);
1087 RTLLIB_DEBUG(RTLLIB_DL_RX | RTLLIB_DL_FRAG,
1088 "Rx cannot get skb from fragment cache (morefrag=%d seq=%u frag=%u)\n",
1089 (fc & RTLLIB_FCTL_MOREFRAGS) != 0,
1090 WLAN_GET_SEQ_SEQ(sc), frag);
1097 if (frag_skb->tail + flen > frag_skb->end) {
1098 netdev_warn(ieee->dev,
1099 "%s: host decrypted and reassembled frame did not fit skb\n",
1101 rtllib_frag_cache_invalidate(ieee, hdr);
1106 /* copy first fragment (including full headers) into
1107 * beginning of the fragment cache skb
1109 memcpy(skb_put(frag_skb, flen), skb->data, flen);
1111 /* append frame payload to the end of the fragment
1114 memcpy(skb_put(frag_skb, flen), skb->data + hdrlen,
1117 dev_kfree_skb_any(skb);
1120 if (fc & RTLLIB_FCTL_MOREFRAGS) {
1121 /* more fragments expected - leave the skb in fragment
1122 * cache for now; it will be delivered to upper layers
1123 * after all fragments have been received
1128 /* this was the last fragment and the frame will be
1129 * delivered, so remove skb from fragment cache
1132 hdr = (struct rtllib_hdr_4addr *) skb->data;
1133 rtllib_frag_cache_invalidate(ieee, hdr);
1136 /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
1137 * encrypted/authenticated
1139 if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) &&
1140 rtllib_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) {
1141 netdev_info(ieee->dev, "%s: ==>decrypt msdu error\n", __func__);
1145 hdr = (struct rtllib_hdr_4addr *) skb->data;
1146 if (crypt && !(fc & RTLLIB_FCTL_WEP) && !ieee->open_wep) {
1147 if (/*ieee->ieee802_1x &&*/
1148 rtllib_is_eapol_frame(ieee, skb, hdrlen)) {
1150 /* pass unencrypted EAPOL frames even if encryption is
1153 struct eapol *eap = (struct eapol *)(skb->data +
1155 netdev_dbg(ieee->dev,
1156 "RX: IEEE 802.1X EAPOL frame: %s\n",
1157 eap_get_type(eap->type));
1159 netdev_dbg(ieee->dev,
1160 "encryption configured, but RX frame not encrypted (SA= %pM)\n",
1166 if (crypt && !(fc & RTLLIB_FCTL_WEP) &&
1167 rtllib_is_eapol_frame(ieee, skb, hdrlen)) {
1168 struct eapol *eap = (struct eapol *)(skb->data +
1170 netdev_dbg(ieee->dev,
1171 "RX: IEEE 802.1X EAPOL frame: %s\n",
1172 eap_get_type(eap->type));
1175 if (crypt && !(fc & RTLLIB_FCTL_WEP) && !ieee->open_wep &&
1176 !rtllib_is_eapol_frame(ieee, skb, hdrlen)) {
1177 netdev_dbg(ieee->dev,
1178 "dropped unencrypted RX data frame from %pM (drop_unencrypted=1)\n",
1183 if (rtllib_is_eapol_frame(ieee, skb, hdrlen))
1184 netdev_warn(ieee->dev, "RX: IEEE802.1X EAPOL frame!\n");
1189 static void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes)
1193 if (ieee->state == RTLLIB_LINKED) {
1194 if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod +
1195 ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) ||
1196 (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) {
1197 if (ieee->LeisurePSLeave)
1198 ieee->LeisurePSLeave(ieee->dev);
1202 ieee->last_rx_ps_time = jiffies;
1205 static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee,
1206 struct rtllib_rx_stats *rx_stats,
1207 struct rtllib_rxb *rxb,
1211 struct net_device *dev = ieee->dev;
1216 netdev_info(dev, "%s: rxb is NULL!!\n", __func__);
1220 for (i = 0; i < rxb->nr_subframes; i++) {
1221 struct sk_buff *sub_skb = rxb->subframes[i];
1224 /* convert hdr + possible LLC headers into Ethernet header */
1225 ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7];
1226 if (sub_skb->len >= 8 &&
1227 ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 &&
1228 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
1229 memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
1230 /* remove RFC1042 or Bridge-Tunnel encapsulation and
1233 skb_pull(sub_skb, SNAP_SIZE);
1234 ether_addr_copy(skb_push(sub_skb, ETH_ALEN),
1236 ether_addr_copy(skb_push(sub_skb, ETH_ALEN),
1240 /* Leave Ethernet header part of hdr and full payload */
1242 memcpy(skb_push(sub_skb, 2), &len, 2);
1243 ether_addr_copy(skb_push(sub_skb, ETH_ALEN),
1245 ether_addr_copy(skb_push(sub_skb, ETH_ALEN),
1249 ieee->stats.rx_packets++;
1250 ieee->stats.rx_bytes += sub_skb->len;
1252 if (is_multicast_ether_addr(dst))
1253 ieee->stats.multicast++;
1255 /* Indicate the packets to upper layer */
1256 memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
1257 sub_skb->protocol = eth_type_trans(sub_skb, dev);
1259 sub_skb->dev->stats.rx_packets++;
1260 sub_skb->dev->stats.rx_bytes += sub_skb->len;
1261 sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
1268 static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
1269 struct rtllib_rx_stats *rx_stats)
1271 struct net_device *dev = ieee->dev;
1272 struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;
1273 struct lib80211_crypt_data *crypt = NULL;
1274 struct rtllib_rxb *rxb = NULL;
1275 struct rx_ts_record *pTS = NULL;
1276 u16 fc, sc, SeqNum = 0;
1277 u8 type, stype, multicast = 0, unicast = 0, nr_subframes = 0, TID = 0;
1281 u8 bssid[ETH_ALEN] = {0};
1284 bool bToOtherSTA = false;
1287 hdr = (struct rtllib_hdr_4addr *)skb->data;
1288 fc = le16_to_cpu(hdr->frame_ctl);
1289 type = WLAN_FC_GET_TYPE(fc);
1290 stype = WLAN_FC_GET_STYPE(fc);
1291 sc = le16_to_cpu(hdr->seq_ctl);
1293 /*Filter pkt not to me*/
1294 multicast = is_multicast_ether_addr(hdr->addr1);
1295 unicast = !multicast;
1296 if (unicast && !ether_addr_equal(dev->dev_addr, hdr->addr1)) {
1297 if (ieee->bNetPromiscuousMode)
1303 /*Filter pkt has too small length */
1304 hdrlen = rtllib_rx_get_hdrlen(ieee, skb, rx_stats);
1305 if (skb->len < hdrlen) {
1306 netdev_info(dev, "%s():ERR!!! skb->len is smaller than hdrlen\n",
1311 /* Filter Duplicate pkt */
1312 ret = rtllib_rx_check_duplicate(ieee, skb, multicast);
1316 /* Filter CTRL Frame */
1317 if (type == RTLLIB_FTYPE_CTL)
1320 /* Filter MGNT Frame */
1321 if (type == RTLLIB_FTYPE_MGMT) {
1324 if (rtllib_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
1330 /* Filter WAPI DATA Frame */
1332 /* Update statstics for AP roaming */
1334 ieee->LinkDetectInfo.NumRecvDataInPeriod++;
1335 ieee->LinkDetectInfo.NumRxOkInPeriod++;
1337 dev->last_rx = jiffies;
1339 /* Data frame - extract src/dst addresses */
1340 rtllib_rx_extract_addr(ieee, hdr, dst, src, bssid);
1342 /* Filter Data frames */
1343 ret = rtllib_rx_data_filter(ieee, fc, dst, src, bssid, hdr->addr2);
1347 if (skb->len == hdrlen)
1350 /* Send pspoll based on moredata */
1351 if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->sta_sleep == LPS_IS_SLEEP)
1352 && (ieee->polling) && (!bToOtherSTA)) {
1353 if (WLAN_FC_MORE_DATA(fc)) {
1354 /* more data bit is set, let's request a new frame from the AP */
1355 rtllib_sta_ps_send_pspoll_frame(ieee);
1357 ieee->polling = false;
1361 /* Get crypt if encrypted */
1362 ret = rtllib_rx_get_crypt(ieee, skb, &crypt, hdrlen);
1366 /* Decrypt data frame (including reassemble) */
1367 ret = rtllib_rx_decrypt(ieee, skb, rx_stats, crypt, hdrlen);
1373 /* Get TS for Rx Reorder */
1374 hdr = (struct rtllib_hdr_4addr *) skb->data;
1375 if (ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data)
1376 && !is_multicast_ether_addr(hdr->addr1)
1377 && (!bToOtherSTA)) {
1378 TID = Frame_QoSTID(skb->data);
1379 SeqNum = WLAN_GET_SEQ_SEQ(sc);
1380 GetTs(ieee, (struct ts_common_info **) &pTS, hdr->addr2, TID, RX_DIR, true);
1381 if (TID != 0 && TID != 3)
1382 ieee->bis_any_nonbepkts = true;
1385 /* Parse rx data frame (For AMSDU) */
1386 /* skb: hdr + (possible reassembled) full plaintext payload */
1387 payload = skb->data + hdrlen;
1388 rxb = kmalloc(sizeof(struct rtllib_rxb), GFP_ATOMIC);
1392 /* to parse amsdu packets */
1393 /* qos data packets & reserved bit is 1 */
1394 if (parse_subframe(ieee, skb, rx_stats, rxb, src, dst) == 0) {
1395 /* only to free rxb, and not submit the packets to upper layer */
1396 for (i = 0; i < rxb->nr_subframes; i++)
1397 dev_kfree_skb(rxb->subframes[i]);
1403 /* Update WAPI PN */
1405 /* Check if leave LPS */
1407 if (ieee->bIsAggregateFrame)
1408 nr_subframes = rxb->nr_subframes;
1412 ieee->LinkDetectInfo.NumRxUnicastOkInPeriod += nr_subframes;
1413 rtllib_rx_check_leave_lps(ieee, unicast, nr_subframes);
1416 /* Indicate packets to upper layer or Rx Reorder */
1417 if (ieee->pHTInfo->bCurRxReorderEnable == false || pTS == NULL || bToOtherSTA)
1418 rtllib_rx_indicate_pkt_legacy(ieee, rx_stats, rxb, dst, src);
1420 RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum);
1428 ieee->stats.rx_dropped++;
1430 /* Returning 0 indicates to caller that we have not handled the SKB--
1431 * so it is still allocated and can be used again by underlying
1432 * hardware as a DMA target
1437 static int rtllib_rx_Master(struct rtllib_device *ieee, struct sk_buff *skb,
1438 struct rtllib_rx_stats *rx_stats)
1443 static int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb,
1444 struct rtllib_rx_stats *rx_stats)
1446 struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;
1447 u16 fc = le16_to_cpu(hdr->frame_ctl);
1448 size_t hdrlen = rtllib_get_hdrlen(fc);
1450 if (skb->len < hdrlen) {
1451 netdev_info(ieee->dev,
1452 "%s():ERR!!! skb->len is smaller than hdrlen\n",
1457 if (HTCCheck(ieee, skb->data)) {
1458 if (net_ratelimit())
1459 netdev_info(ieee->dev, "%s: Find HTCControl!\n",
1464 rtllib_monitor_rx(ieee, skb, rx_stats, hdrlen);
1465 ieee->stats.rx_packets++;
1466 ieee->stats.rx_bytes += skb->len;
1471 static int rtllib_rx_Mesh(struct rtllib_device *ieee, struct sk_buff *skb,
1472 struct rtllib_rx_stats *rx_stats)
1477 /* All received frames are sent to this function. @skb contains the frame in
1478 * IEEE 802.11 format, i.e., in the format it was sent over air.
1479 * This function is called only as a tasklet (software IRQ).
1481 int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
1482 struct rtllib_rx_stats *rx_stats)
1486 if ((NULL == ieee) || (NULL == skb) || (NULL == rx_stats)) {
1487 pr_info("%s: Input parameters NULL!\n", __func__);
1490 if (skb->len < 10) {
1491 netdev_info(ieee->dev, "%s: SKB length < 10\n", __func__);
1495 switch (ieee->iw_mode) {
1498 ret = rtllib_rx_InfraAdhoc(ieee, skb, rx_stats);
1500 case IW_MODE_MASTER:
1501 case IW_MODE_REPEAT:
1502 ret = rtllib_rx_Master(ieee, skb, rx_stats);
1504 case IW_MODE_MONITOR:
1505 ret = rtllib_rx_Monitor(ieee, skb, rx_stats);
1508 ret = rtllib_rx_Mesh(ieee, skb, rx_stats);
1511 netdev_info(ieee->dev, "%s: ERR iw mode!!!\n", __func__);
1519 ieee->stats.rx_dropped++;
1522 EXPORT_SYMBOL(rtllib_rx);
1524 static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 };
1526 /* Make ther structure we read from the beacon packet has the right values */
1527 static int rtllib_verify_qos_info(struct rtllib_qos_information_element
1528 *info_element, int sub_type)
1531 if (info_element->qui_subtype != sub_type)
1533 if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN))
1535 if (info_element->qui_type != QOS_OUI_TYPE)
1537 if (info_element->version != QOS_VERSION_1)
1544 /* Parse a QoS parameter element */
1545 static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info
1546 *element_param, struct rtllib_info_element
1550 u16 size = sizeof(struct rtllib_qos_parameter_info) - 2;
1552 if ((info_element == NULL) || (element_param == NULL))
1555 if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) {
1556 memcpy(element_param->info_element.qui, info_element->data,
1558 element_param->info_element.elementID = info_element->id;
1559 element_param->info_element.length = info_element->len;
1563 ret = rtllib_verify_qos_info(&element_param->info_element,
1564 QOS_OUI_PARAM_SUB_TYPE);
1568 /* Parse a QoS information element */
1569 static int rtllib_read_qos_info_element(struct
1570 rtllib_qos_information_element
1571 *element_info, struct rtllib_info_element
1575 u16 size = sizeof(struct rtllib_qos_information_element) - 2;
1577 if (element_info == NULL)
1579 if (info_element == NULL)
1582 if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) {
1583 memcpy(element_info->qui, info_element->data,
1585 element_info->elementID = info_element->id;
1586 element_info->length = info_element->len;
1591 ret = rtllib_verify_qos_info(element_info,
1592 QOS_OUI_INFO_SUB_TYPE);
1597 /* Write QoS parameters from the ac parameters. */
1598 static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info *param_elm,
1599 struct rtllib_qos_data *qos_data)
1601 struct rtllib_qos_ac_parameter *ac_params;
1602 struct rtllib_qos_parameters *qos_param = &(qos_data->parameters);
1607 qos_data->wmm_acm = 0;
1608 for (i = 0; i < QOS_QUEUE_NUM; i++) {
1609 ac_params = &(param_elm->ac_params_record[i]);
1611 aci = (ac_params->aci_aifsn & 0x60) >> 5;
1612 acm = (ac_params->aci_aifsn & 0x10) >> 4;
1614 if (aci >= QOS_QUEUE_NUM)
1618 /* BIT(0) | BIT(3) */
1620 qos_data->wmm_acm |= (0x01<<0)|(0x01<<3);
1623 /* BIT(4) | BIT(5) */
1625 qos_data->wmm_acm |= (0x01<<4)|(0x01<<5);
1628 /* BIT(6) | BIT(7) */
1630 qos_data->wmm_acm |= (0x01<<6)|(0x01<<7);
1634 /* BIT(1) | BIT(2) */
1636 qos_data->wmm_acm |= (0x01<<1)|(0x01<<2);
1640 qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f;
1642 /* WMM spec P.11: The minimum value for AIFSN shall be 2 */
1643 qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2 : qos_param->aifs[aci];
1645 qos_param->cw_min[aci] = cpu_to_le16(ac_params->ecw_min_max & 0x0F);
1647 qos_param->cw_max[aci] = cpu_to_le16((ac_params->ecw_min_max & 0xF0) >> 4);
1649 qos_param->flag[aci] =
1650 (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
1651 qos_param->tx_op_limit[aci] = ac_params->tx_op_limit;
1656 /* we have a generic data element which it may contain QoS information or
1657 * parameters element. check the information element length to decide
1658 * which type to read
1660 static int rtllib_parse_qos_info_param_IE(struct rtllib_device *ieee,
1661 struct rtllib_info_element
1663 struct rtllib_network *network)
1666 struct rtllib_qos_information_element qos_info_element;
1668 rc = rtllib_read_qos_info_element(&qos_info_element, info_element);
1671 network->qos_data.param_count = qos_info_element.ac_info & 0x0F;
1672 network->flags |= NETWORK_HAS_QOS_INFORMATION;
1674 struct rtllib_qos_parameter_info param_element;
1676 rc = rtllib_read_qos_param_element(¶m_element,
1679 rtllib_qos_convert_ac_to_parameters(¶m_element,
1680 &(network->qos_data));
1681 network->flags |= NETWORK_HAS_QOS_PARAMETERS;
1682 network->qos_data.param_count =
1683 param_element.info_element.ac_info & 0x0F;
1688 netdev_dbg(ieee->dev, "QoS is supported\n");
1689 network->qos_data.supported = 1;
1694 #define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x
1696 static const char *get_info_element_string(u16 id)
1701 MFIE_STRING(FH_SET);
1702 MFIE_STRING(DS_SET);
1703 MFIE_STRING(CF_SET);
1705 MFIE_STRING(IBSS_SET);
1706 MFIE_STRING(COUNTRY);
1707 MFIE_STRING(HOP_PARAMS);
1708 MFIE_STRING(HOP_TABLE);
1709 MFIE_STRING(REQUEST);
1710 MFIE_STRING(CHALLENGE);
1711 MFIE_STRING(POWER_CONSTRAINT);
1712 MFIE_STRING(POWER_CAPABILITY);
1713 MFIE_STRING(TPC_REQUEST);
1714 MFIE_STRING(TPC_REPORT);
1715 MFIE_STRING(SUPP_CHANNELS);
1717 MFIE_STRING(MEASURE_REQUEST);
1718 MFIE_STRING(MEASURE_REPORT);
1720 MFIE_STRING(IBSS_DFS);
1722 MFIE_STRING(RATES_EX);
1723 MFIE_STRING(GENERIC);
1724 MFIE_STRING(QOS_PARAMETER);
1730 static inline void rtllib_extract_country_ie(
1731 struct rtllib_device *ieee,
1732 struct rtllib_info_element *info_element,
1733 struct rtllib_network *network,
1736 if (IS_DOT11D_ENABLE(ieee)) {
1737 if (info_element->len != 0) {
1738 memcpy(network->CountryIeBuf, info_element->data, info_element->len);
1739 network->CountryIeLen = info_element->len;
1741 if (!IS_COUNTRY_IE_VALID(ieee)) {
1742 if (rtllib_act_scanning(ieee, false) && ieee->FirstIe_InScan)
1743 netdev_info(ieee->dev,
1744 "Received beacon ContryIE, SSID: <%s>\n",
1746 Dot11d_UpdateCountryIe(ieee, addr2, info_element->len, info_element->data);
1750 if (IS_EQUAL_CIE_SRC(ieee, addr2))
1751 UPDATE_CIE_WATCHDOG(ieee);
1756 static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
1757 struct rtllib_info_element *info_element,
1758 struct rtllib_network *network,
1760 u16 *tmp_htinfo_len)
1762 u16 ht_realtek_agg_len = 0;
1763 u8 ht_realtek_agg_buf[MAX_IE_LEN];
1765 if (!rtllib_parse_qos_info_param_IE(ieee, info_element, network))
1767 if (info_element->len >= 4 &&
1768 info_element->data[0] == 0x00 &&
1769 info_element->data[1] == 0x50 &&
1770 info_element->data[2] == 0xf2 &&
1771 info_element->data[3] == 0x01) {
1772 network->wpa_ie_len = min(info_element->len + 2,
1774 memcpy(network->wpa_ie, info_element, network->wpa_ie_len);
1777 if (info_element->len == 7 &&
1778 info_element->data[0] == 0x00 &&
1779 info_element->data[1] == 0xe0 &&
1780 info_element->data[2] == 0x4c &&
1781 info_element->data[3] == 0x01 &&
1782 info_element->data[4] == 0x02)
1783 network->Turbo_Enable = 1;
1785 if (*tmp_htcap_len == 0) {
1786 if (info_element->len >= 4 &&
1787 info_element->data[0] == 0x00 &&
1788 info_element->data[1] == 0x90 &&
1789 info_element->data[2] == 0x4c &&
1790 info_element->data[3] == 0x033) {
1792 *tmp_htcap_len = min_t(u8, info_element->len,
1794 if (*tmp_htcap_len != 0) {
1795 network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
1796 network->bssht.bdHTCapLen = min_t(u16, *tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf));
1797 memcpy(network->bssht.bdHTCapBuf,
1799 network->bssht.bdHTCapLen);
1802 if (*tmp_htcap_len != 0) {
1803 network->bssht.bdSupportHT = true;
1804 network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
1806 network->bssht.bdSupportHT = false;
1807 network->bssht.bdHT1R = false;
1812 if (*tmp_htinfo_len == 0) {
1813 if (info_element->len >= 4 &&
1814 info_element->data[0] == 0x00 &&
1815 info_element->data[1] == 0x90 &&
1816 info_element->data[2] == 0x4c &&
1817 info_element->data[3] == 0x034) {
1818 *tmp_htinfo_len = min_t(u8, info_element->len,
1820 if (*tmp_htinfo_len != 0) {
1821 network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
1822 network->bssht.bdHTInfoLen = min_t(u16, *tmp_htinfo_len, sizeof(network->bssht.bdHTInfoBuf));
1823 memcpy(network->bssht.bdHTInfoBuf,
1825 network->bssht.bdHTInfoLen);
1831 if (ieee->aggregation) {
1832 if (network->bssht.bdSupportHT) {
1833 if (info_element->len >= 4 &&
1834 info_element->data[0] == 0x00 &&
1835 info_element->data[1] == 0xe0 &&
1836 info_element->data[2] == 0x4c &&
1837 info_element->data[3] == 0x02) {
1838 ht_realtek_agg_len = min_t(u8,
1841 memcpy(ht_realtek_agg_buf,
1845 if (ht_realtek_agg_len >= 5) {
1846 network->realtek_cap_exit = true;
1847 network->bssht.bdRT2RTAggregation = true;
1849 if ((ht_realtek_agg_buf[4] == 1) &&
1850 (ht_realtek_agg_buf[5] & 0x02))
1851 network->bssht.bdRT2RTLongSlotTime = true;
1853 if ((ht_realtek_agg_buf[4] == 1) &&
1854 (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE))
1855 network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE;
1858 if (ht_realtek_agg_len >= 5) {
1859 if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP))
1860 network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP;
1864 if ((info_element->len >= 3 &&
1865 info_element->data[0] == 0x00 &&
1866 info_element->data[1] == 0x05 &&
1867 info_element->data[2] == 0xb5) ||
1868 (info_element->len >= 3 &&
1869 info_element->data[0] == 0x00 &&
1870 info_element->data[1] == 0x0a &&
1871 info_element->data[2] == 0xf7) ||
1872 (info_element->len >= 3 &&
1873 info_element->data[0] == 0x00 &&
1874 info_element->data[1] == 0x10 &&
1875 info_element->data[2] == 0x18)) {
1876 network->broadcom_cap_exist = true;
1878 if (info_element->len >= 3 &&
1879 info_element->data[0] == 0x00 &&
1880 info_element->data[1] == 0x0c &&
1881 info_element->data[2] == 0x43)
1882 network->ralink_cap_exist = true;
1883 if ((info_element->len >= 3 &&
1884 info_element->data[0] == 0x00 &&
1885 info_element->data[1] == 0x03 &&
1886 info_element->data[2] == 0x7f) ||
1887 (info_element->len >= 3 &&
1888 info_element->data[0] == 0x00 &&
1889 info_element->data[1] == 0x13 &&
1890 info_element->data[2] == 0x74))
1891 network->atheros_cap_exist = true;
1893 if ((info_element->len >= 3 &&
1894 info_element->data[0] == 0x00 &&
1895 info_element->data[1] == 0x50 &&
1896 info_element->data[2] == 0x43))
1897 network->marvell_cap_exist = true;
1898 if (info_element->len >= 3 &&
1899 info_element->data[0] == 0x00 &&
1900 info_element->data[1] == 0x40 &&
1901 info_element->data[2] == 0x96)
1902 network->cisco_cap_exist = true;
1905 if (info_element->len >= 3 &&
1906 info_element->data[0] == 0x00 &&
1907 info_element->data[1] == 0x0a &&
1908 info_element->data[2] == 0xf5)
1909 network->airgo_cap_exist = true;
1911 if (info_element->len > 4 &&
1912 info_element->data[0] == 0x00 &&
1913 info_element->data[1] == 0x40 &&
1914 info_element->data[2] == 0x96 &&
1915 info_element->data[3] == 0x01) {
1916 if (info_element->len == 6) {
1917 memcpy(network->CcxRmState, &info_element[4], 2);
1918 if (network->CcxRmState[0] != 0)
1919 network->bCcxRmEnable = true;
1921 network->bCcxRmEnable = false;
1922 network->MBssidMask = network->CcxRmState[1] & 0x07;
1923 if (network->MBssidMask != 0) {
1924 network->bMBssidValid = true;
1925 network->MBssidMask = 0xff << (network->MBssidMask);
1926 ether_addr_copy(network->MBssid,
1928 network->MBssid[5] &= network->MBssidMask;
1930 network->bMBssidValid = false;
1933 network->bCcxRmEnable = false;
1936 if (info_element->len > 4 &&
1937 info_element->data[0] == 0x00 &&
1938 info_element->data[1] == 0x40 &&
1939 info_element->data[2] == 0x96 &&
1940 info_element->data[3] == 0x03) {
1941 if (info_element->len == 5) {
1942 network->bWithCcxVerNum = true;
1943 network->BssCcxVerNumber = info_element->data[4];
1945 network->bWithCcxVerNum = false;
1946 network->BssCcxVerNumber = 0;
1949 if (info_element->len > 4 &&
1950 info_element->data[0] == 0x00 &&
1951 info_element->data[1] == 0x50 &&
1952 info_element->data[2] == 0xf2 &&
1953 info_element->data[3] == 0x04) {
1954 RTLLIB_DEBUG_MGMT("MFIE_TYPE_WZC: %d bytes\n",
1956 network->wzc_ie_len = min(info_element->len+2,
1958 memcpy(network->wzc_ie, info_element,
1959 network->wzc_ie_len);
1963 int rtllib_parse_info_param(struct rtllib_device *ieee,
1964 struct rtllib_info_element *info_element,
1966 struct rtllib_network *network,
1967 struct rtllib_rx_stats *stats)
1971 u16 tmp_htcap_len = 0;
1972 u16 tmp_htinfo_len = 0;
1976 while (length >= sizeof(*info_element)) {
1977 if (sizeof(*info_element) + info_element->len > length) {
1978 RTLLIB_DEBUG_MGMT("Info elem: parse failed: info_element->len + 2 > left : info_element->len+2=%zd left=%d, id=%d.\n",
1980 sizeof(*info_element),
1981 length, info_element->id);
1982 /* We stop processing but don't return an error here
1983 * because some misbehaviour APs break this rule. ie.
1989 switch (info_element->id) {
1990 case MFIE_TYPE_SSID:
1991 if (rtllib_is_empty_essid(info_element->data,
1992 info_element->len)) {
1993 network->flags |= NETWORK_EMPTY_ESSID;
1997 network->ssid_len = min(info_element->len,
1998 (u8) IW_ESSID_MAX_SIZE);
1999 memcpy(network->ssid, info_element->data, network->ssid_len);
2000 if (network->ssid_len < IW_ESSID_MAX_SIZE)
2001 memset(network->ssid + network->ssid_len, 0,
2002 IW_ESSID_MAX_SIZE - network->ssid_len);
2004 RTLLIB_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
2005 network->ssid, network->ssid_len);
2008 case MFIE_TYPE_RATES:
2010 network->rates_len = min(info_element->len,
2012 for (i = 0; i < network->rates_len; i++) {
2013 network->rates[i] = info_element->data[i];
2014 p += snprintf(p, sizeof(rates_str) -
2015 (p - rates_str), "%02X ",
2017 if (rtllib_is_ofdm_rate
2018 (info_element->data[i])) {
2019 network->flags |= NETWORK_HAS_OFDM;
2020 if (info_element->data[i] &
2021 RTLLIB_BASIC_RATE_MASK)
2026 if (rtllib_is_cck_rate
2027 (info_element->data[i])) {
2028 network->flags |= NETWORK_HAS_CCK;
2032 RTLLIB_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n",
2033 rates_str, network->rates_len);
2036 case MFIE_TYPE_RATES_EX:
2038 network->rates_ex_len = min(info_element->len,
2039 MAX_RATES_EX_LENGTH);
2040 for (i = 0; i < network->rates_ex_len; i++) {
2041 network->rates_ex[i] = info_element->data[i];
2042 p += snprintf(p, sizeof(rates_str) -
2043 (p - rates_str), "%02X ",
2044 network->rates_ex[i]);
2045 if (rtllib_is_ofdm_rate
2046 (info_element->data[i])) {
2047 network->flags |= NETWORK_HAS_OFDM;
2048 if (info_element->data[i] &
2049 RTLLIB_BASIC_RATE_MASK)
2055 RTLLIB_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n",
2056 rates_str, network->rates_ex_len);
2059 case MFIE_TYPE_DS_SET:
2060 RTLLIB_DEBUG_MGMT("MFIE_TYPE_DS_SET: %d\n",
2061 info_element->data[0]);
2062 network->channel = info_element->data[0];
2065 case MFIE_TYPE_FH_SET:
2066 RTLLIB_DEBUG_MGMT("MFIE_TYPE_FH_SET: ignored\n");
2069 case MFIE_TYPE_CF_SET:
2070 RTLLIB_DEBUG_MGMT("MFIE_TYPE_CF_SET: ignored\n");
2074 if (info_element->len < 4)
2077 network->tim.tim_count = info_element->data[0];
2078 network->tim.tim_period = info_element->data[1];
2080 network->dtim_period = info_element->data[1];
2081 if (ieee->state != RTLLIB_LINKED)
2083 network->last_dtim_sta_time = jiffies;
2085 network->dtim_data = RTLLIB_DTIM_VALID;
2088 if (info_element->data[2] & 1)
2089 network->dtim_data |= RTLLIB_DTIM_MBCAST;
2091 offset = (info_element->data[2] >> 1)*2;
2094 if (ieee->assoc_id < 8*offset ||
2095 ieee->assoc_id > 8*(offset + info_element->len - 3))
2098 offset = (ieee->assoc_id / 8) - offset;
2099 if (info_element->data[3 + offset] &
2100 (1 << (ieee->assoc_id % 8)))
2101 network->dtim_data |= RTLLIB_DTIM_UCAST;
2103 network->listen_interval = network->dtim_period;
2107 network->erp_value = info_element->data[0];
2108 network->flags |= NETWORK_HAS_ERP_VALUE;
2109 RTLLIB_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n",
2110 network->erp_value);
2112 case MFIE_TYPE_IBSS_SET:
2113 network->atim_window = info_element->data[0];
2114 RTLLIB_DEBUG_MGMT("MFIE_TYPE_IBSS_SET: %d\n",
2115 network->atim_window);
2118 case MFIE_TYPE_CHALLENGE:
2119 RTLLIB_DEBUG_MGMT("MFIE_TYPE_CHALLENGE: ignored\n");
2122 case MFIE_TYPE_GENERIC:
2123 RTLLIB_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n",
2125 rtllib_parse_mife_generic(ieee, info_element, network,
2131 RTLLIB_DEBUG_MGMT("MFIE_TYPE_RSN: %d bytes\n",
2133 network->rsn_ie_len = min(info_element->len + 2,
2135 memcpy(network->rsn_ie, info_element,
2136 network->rsn_ie_len);
2139 case MFIE_TYPE_HT_CAP:
2140 netdev_dbg(ieee->dev, "MFIE_TYPE_HT_CAP: %d bytes\n",
2142 tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN);
2143 if (tmp_htcap_len != 0) {
2144 network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
2145 network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ?
2146 sizeof(network->bssht.bdHTCapBuf) : tmp_htcap_len;
2147 memcpy(network->bssht.bdHTCapBuf,
2149 network->bssht.bdHTCapLen);
2151 network->bssht.bdSupportHT = true;
2152 network->bssht.bdHT1R = ((((struct ht_capab_ele *)
2153 network->bssht.bdHTCapBuf))->MCS[1]) == 0;
2155 network->bssht.bdBandWidth = (enum ht_channel_width)
2156 (((struct ht_capab_ele *)
2157 (network->bssht.bdHTCapBuf))->ChlWidth);
2159 network->bssht.bdSupportHT = false;
2160 network->bssht.bdHT1R = false;
2161 network->bssht.bdBandWidth = HT_CHANNEL_WIDTH_20;
2166 case MFIE_TYPE_HT_INFO:
2167 netdev_dbg(ieee->dev, "MFIE_TYPE_HT_INFO: %d bytes\n",
2169 tmp_htinfo_len = min_t(u8, info_element->len, MAX_IE_LEN);
2170 if (tmp_htinfo_len) {
2171 network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE;
2172 network->bssht.bdHTInfoLen = tmp_htinfo_len >
2173 sizeof(network->bssht.bdHTInfoBuf) ?
2174 sizeof(network->bssht.bdHTInfoBuf) :
2176 memcpy(network->bssht.bdHTInfoBuf,
2178 network->bssht.bdHTInfoLen);
2182 case MFIE_TYPE_AIRONET:
2183 netdev_dbg(ieee->dev, "MFIE_TYPE_AIRONET: %d bytes\n",
2185 if (info_element->len > IE_CISCO_FLAG_POSITION) {
2186 network->bWithAironetIE = true;
2188 if ((info_element->data[IE_CISCO_FLAG_POSITION]
2189 & SUPPORT_CKIP_MIC) ||
2190 (info_element->data[IE_CISCO_FLAG_POSITION]
2192 network->bCkipSupported = true;
2194 network->bCkipSupported = false;
2196 network->bWithAironetIE = false;
2197 network->bCkipSupported = false;
2200 case MFIE_TYPE_QOS_PARAMETER:
2201 netdev_err(ieee->dev,
2202 "QoS Error need to parse QOS_PARAMETER IE\n");
2205 case MFIE_TYPE_COUNTRY:
2206 netdev_dbg(ieee->dev, "MFIE_TYPE_COUNTRY: %d bytes\n",
2208 rtllib_extract_country_ie(ieee, info_element, network,
2214 ("Unsupported info element: %s (%d)\n",
2215 get_info_element_string(info_element->id),
2220 length -= sizeof(*info_element) + info_element->len;
2222 (struct rtllib_info_element *)&info_element->
2223 data[info_element->len];
2226 if (!network->atheros_cap_exist && !network->broadcom_cap_exist &&
2227 !network->cisco_cap_exist && !network->ralink_cap_exist &&
2228 !network->bssht.bdRT2RTAggregation)
2229 network->unknown_cap_exist = true;
2231 network->unknown_cap_exist = false;
2235 static long rtllib_translate_todbm(u8 signal_strength_index)
2239 signal_power = (long)((signal_strength_index + 1) >> 1);
2242 return signal_power;
2245 static inline int rtllib_network_init(
2246 struct rtllib_device *ieee,
2247 struct rtllib_probe_response *beacon,
2248 struct rtllib_network *network,
2249 struct rtllib_rx_stats *stats)
2251 memset(&network->qos_data, 0, sizeof(struct rtllib_qos_data));
2253 /* Pull out fixed field data */
2254 ether_addr_copy(network->bssid, beacon->header.addr3);
2255 network->capability = le16_to_cpu(beacon->capability);
2256 network->last_scanned = jiffies;
2257 network->time_stamp[0] = beacon->time_stamp[0];
2258 network->time_stamp[1] = beacon->time_stamp[1];
2259 network->beacon_interval = le16_to_cpu(beacon->beacon_interval);
2260 /* Where to pull this? beacon->listen_interval;*/
2261 network->listen_interval = 0x0A;
2262 network->rates_len = network->rates_ex_len = 0;
2263 network->last_associate = 0;
2264 network->ssid_len = 0;
2265 network->hidden_ssid_len = 0;
2266 memset(network->hidden_ssid, 0, sizeof(network->hidden_ssid));
2268 network->atim_window = 0;
2269 network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ?
2271 network->berp_info_valid = false;
2272 network->broadcom_cap_exist = false;
2273 network->ralink_cap_exist = false;
2274 network->atheros_cap_exist = false;
2275 network->cisco_cap_exist = false;
2276 network->unknown_cap_exist = false;
2277 network->realtek_cap_exit = false;
2278 network->marvell_cap_exist = false;
2279 network->airgo_cap_exist = false;
2280 network->Turbo_Enable = 0;
2281 network->SignalStrength = stats->SignalStrength;
2282 network->RSSI = stats->SignalStrength;
2283 network->CountryIeLen = 0;
2284 memset(network->CountryIeBuf, 0, MAX_IE_LEN);
2285 HTInitializeBssDesc(&network->bssht);
2286 if (stats->freq == RTLLIB_52GHZ_BAND) {
2287 /* for A band (No DS info) */
2288 network->channel = stats->received_channel;
2290 network->flags |= NETWORK_HAS_CCK;
2292 network->wpa_ie_len = 0;
2293 network->rsn_ie_len = 0;
2294 network->wzc_ie_len = 0;
2296 if (rtllib_parse_info_param(ieee,
2297 beacon->info_element,
2298 (stats->len - sizeof(*beacon)),
2304 if (stats->freq == RTLLIB_52GHZ_BAND)
2305 network->mode = IEEE_A;
2307 if (network->flags & NETWORK_HAS_OFDM)
2308 network->mode |= IEEE_G;
2309 if (network->flags & NETWORK_HAS_CCK)
2310 network->mode |= IEEE_B;
2313 if (network->mode == 0) {
2314 netdev_dbg(ieee->dev, "Filtered out '%s (%pM)' network.\n",
2315 escape_essid(network->ssid, network->ssid_len),
2320 if (network->bssht.bdSupportHT) {
2321 if (network->mode == IEEE_A)
2322 network->mode = IEEE_N_5G;
2323 else if (network->mode & (IEEE_G | IEEE_B))
2324 network->mode = IEEE_N_24G;
2326 if (rtllib_is_empty_essid(network->ssid, network->ssid_len))
2327 network->flags |= NETWORK_EMPTY_ESSID;
2328 stats->signal = 30 + (stats->SignalStrength * 70) / 100;
2329 stats->noise = rtllib_translate_todbm((u8)(100-stats->signal)) - 25;
2331 memcpy(&network->stats, stats, sizeof(network->stats));
2336 static inline int is_same_network(struct rtllib_network *src,
2337 struct rtllib_network *dst, u8 ssidbroad)
2339 /* A network is only a duplicate if the channel, BSSID, ESSID
2340 * and the capability field (in particular IBSS and BSS) all match.
2341 * We treat all <hidden> with the same BSSID and channel
2344 return (((src->ssid_len == dst->ssid_len) || (!ssidbroad)) &&
2345 (src->channel == dst->channel) &&
2346 !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
2347 (!memcmp(src->ssid, dst->ssid, src->ssid_len) ||
2349 ((src->capability & WLAN_CAPABILITY_IBSS) ==
2350 (dst->capability & WLAN_CAPABILITY_IBSS)) &&
2351 ((src->capability & WLAN_CAPABILITY_ESS) ==
2352 (dst->capability & WLAN_CAPABILITY_ESS)));
2356 static inline void update_network(struct rtllib_device *ieee,
2357 struct rtllib_network *dst,
2358 struct rtllib_network *src)
2363 memcpy(&dst->stats, &src->stats, sizeof(struct rtllib_rx_stats));
2364 dst->capability = src->capability;
2365 memcpy(dst->rates, src->rates, src->rates_len);
2366 dst->rates_len = src->rates_len;
2367 memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len);
2368 dst->rates_ex_len = src->rates_ex_len;
2369 if (src->ssid_len > 0) {
2370 if (dst->ssid_len == 0) {
2371 memset(dst->hidden_ssid, 0, sizeof(dst->hidden_ssid));
2372 dst->hidden_ssid_len = src->ssid_len;
2373 memcpy(dst->hidden_ssid, src->ssid, src->ssid_len);
2375 memset(dst->ssid, 0, dst->ssid_len);
2376 dst->ssid_len = src->ssid_len;
2377 memcpy(dst->ssid, src->ssid, src->ssid_len);
2380 dst->mode = src->mode;
2381 dst->flags = src->flags;
2382 dst->time_stamp[0] = src->time_stamp[0];
2383 dst->time_stamp[1] = src->time_stamp[1];
2384 if (src->flags & NETWORK_HAS_ERP_VALUE) {
2385 dst->erp_value = src->erp_value;
2386 dst->berp_info_valid = src->berp_info_valid = true;
2388 dst->beacon_interval = src->beacon_interval;
2389 dst->listen_interval = src->listen_interval;
2390 dst->atim_window = src->atim_window;
2391 dst->dtim_period = src->dtim_period;
2392 dst->dtim_data = src->dtim_data;
2393 dst->last_dtim_sta_time = src->last_dtim_sta_time;
2394 memcpy(&dst->tim, &src->tim, sizeof(struct rtllib_tim_parameters));
2396 dst->bssht.bdSupportHT = src->bssht.bdSupportHT;
2397 dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation;
2398 dst->bssht.bdHTCapLen = src->bssht.bdHTCapLen;
2399 memcpy(dst->bssht.bdHTCapBuf, src->bssht.bdHTCapBuf,
2400 src->bssht.bdHTCapLen);
2401 dst->bssht.bdHTInfoLen = src->bssht.bdHTInfoLen;
2402 memcpy(dst->bssht.bdHTInfoBuf, src->bssht.bdHTInfoBuf,
2403 src->bssht.bdHTInfoLen);
2404 dst->bssht.bdHTSpecVer = src->bssht.bdHTSpecVer;
2405 dst->bssht.bdRT2RTLongSlotTime = src->bssht.bdRT2RTLongSlotTime;
2406 dst->broadcom_cap_exist = src->broadcom_cap_exist;
2407 dst->ralink_cap_exist = src->ralink_cap_exist;
2408 dst->atheros_cap_exist = src->atheros_cap_exist;
2409 dst->realtek_cap_exit = src->realtek_cap_exit;
2410 dst->marvell_cap_exist = src->marvell_cap_exist;
2411 dst->cisco_cap_exist = src->cisco_cap_exist;
2412 dst->airgo_cap_exist = src->airgo_cap_exist;
2413 dst->unknown_cap_exist = src->unknown_cap_exist;
2414 memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
2415 dst->wpa_ie_len = src->wpa_ie_len;
2416 memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
2417 dst->rsn_ie_len = src->rsn_ie_len;
2418 memcpy(dst->wzc_ie, src->wzc_ie, src->wzc_ie_len);
2419 dst->wzc_ie_len = src->wzc_ie_len;
2421 dst->last_scanned = jiffies;
2422 /* qos related parameters */
2423 qos_active = dst->qos_data.active;
2424 old_param = dst->qos_data.param_count;
2425 dst->qos_data.supported = src->qos_data.supported;
2426 if (dst->flags & NETWORK_HAS_QOS_PARAMETERS)
2427 memcpy(&dst->qos_data, &src->qos_data,
2428 sizeof(struct rtllib_qos_data));
2429 if (dst->qos_data.supported == 1) {
2431 netdev_dbg(ieee->dev,
2432 "QoS the network %s is QoS supported\n",
2435 netdev_dbg(ieee->dev,
2436 "QoS the network is QoS supported\n");
2438 dst->qos_data.active = qos_active;
2439 dst->qos_data.old_param_count = old_param;
2441 /* dst->last_associate is not overwritten */
2442 dst->wmm_info = src->wmm_info;
2443 if (src->wmm_param[0].ac_aci_acm_aifsn ||
2444 src->wmm_param[1].ac_aci_acm_aifsn ||
2445 src->wmm_param[2].ac_aci_acm_aifsn ||
2446 src->wmm_param[3].ac_aci_acm_aifsn)
2447 memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN);
2449 dst->SignalStrength = src->SignalStrength;
2450 dst->RSSI = src->RSSI;
2451 dst->Turbo_Enable = src->Turbo_Enable;
2453 dst->CountryIeLen = src->CountryIeLen;
2454 memcpy(dst->CountryIeBuf, src->CountryIeBuf, src->CountryIeLen);
2456 dst->bWithAironetIE = src->bWithAironetIE;
2457 dst->bCkipSupported = src->bCkipSupported;
2458 memcpy(dst->CcxRmState, src->CcxRmState, 2);
2459 dst->bCcxRmEnable = src->bCcxRmEnable;
2460 dst->MBssidMask = src->MBssidMask;
2461 dst->bMBssidValid = src->bMBssidValid;
2462 memcpy(dst->MBssid, src->MBssid, 6);
2463 dst->bWithCcxVerNum = src->bWithCcxVerNum;
2464 dst->BssCcxVerNumber = src->BssCcxVerNumber;
2467 static inline int is_beacon(u16 fc)
2469 return (WLAN_FC_GET_STYPE(fc) == RTLLIB_STYPE_BEACON);
2472 static int IsPassiveChannel(struct rtllib_device *rtllib, u8 channel)
2474 if (MAX_CHANNEL_NUMBER < channel) {
2475 netdev_info(rtllib->dev, "%s(): Invalid Channel\n", __func__);
2479 if (rtllib->active_channel_map[channel] == 2)
2485 int rtllib_legal_channel(struct rtllib_device *rtllib, u8 channel)
2487 if (MAX_CHANNEL_NUMBER < channel) {
2488 netdev_info(rtllib->dev, "%s(): Invalid Channel\n", __func__);
2491 if (rtllib->active_channel_map[channel] > 0)
2496 EXPORT_SYMBOL(rtllib_legal_channel);
2498 static inline void rtllib_process_probe_response(
2499 struct rtllib_device *ieee,
2500 struct rtllib_probe_response *beacon,
2501 struct rtllib_rx_stats *stats)
2503 struct rtllib_network *target;
2504 struct rtllib_network *oldest = NULL;
2505 struct rtllib_info_element *info_element = &beacon->info_element[0];
2506 unsigned long flags;
2508 struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network),
2510 u16 frame_ctl = le16_to_cpu(beacon->header.frame_ctl);
2515 netdev_dbg(ieee->dev,
2516 "'%s' ( %pM ): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
2517 escape_essid(info_element->data, info_element->len),
2518 beacon->header.addr3,
2519 (le16_to_cpu(beacon->capability) & (1<<0xf)) ? '1' : '0',
2520 (le16_to_cpu(beacon->capability) & (1<<0xe)) ? '1' : '0',
2521 (le16_to_cpu(beacon->capability) & (1<<0xd)) ? '1' : '0',
2522 (le16_to_cpu(beacon->capability) & (1<<0xc)) ? '1' : '0',
2523 (le16_to_cpu(beacon->capability) & (1<<0xb)) ? '1' : '0',
2524 (le16_to_cpu(beacon->capability) & (1<<0xa)) ? '1' : '0',
2525 (le16_to_cpu(beacon->capability) & (1<<0x9)) ? '1' : '0',
2526 (le16_to_cpu(beacon->capability) & (1<<0x8)) ? '1' : '0',
2527 (le16_to_cpu(beacon->capability) & (1<<0x7)) ? '1' : '0',
2528 (le16_to_cpu(beacon->capability) & (1<<0x6)) ? '1' : '0',
2529 (le16_to_cpu(beacon->capability) & (1<<0x5)) ? '1' : '0',
2530 (le16_to_cpu(beacon->capability) & (1<<0x4)) ? '1' : '0',
2531 (le16_to_cpu(beacon->capability) & (1<<0x3)) ? '1' : '0',
2532 (le16_to_cpu(beacon->capability) & (1<<0x2)) ? '1' : '0',
2533 (le16_to_cpu(beacon->capability) & (1<<0x1)) ? '1' : '0',
2534 (le16_to_cpu(beacon->capability) & (1<<0x0)) ? '1' : '0');
2536 if (rtllib_network_init(ieee, beacon, network, stats)) {
2537 netdev_dbg(ieee->dev, "Dropped '%s' ( %pM) via %s.\n",
2538 escape_essid(info_element->data, info_element->len),
2539 beacon->header.addr3,
2540 is_beacon(frame_ctl) ? "BEACON" : "PROBE RESPONSE");
2545 if (!rtllib_legal_channel(ieee, network->channel))
2548 if (WLAN_FC_GET_STYPE(frame_ctl) == RTLLIB_STYPE_PROBE_RESP) {
2549 if (IsPassiveChannel(ieee, network->channel)) {
2550 netdev_info(ieee->dev,
2551 "GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n",
2557 /* The network parsed correctly -- so now we scan our known networks
2558 * to see if we can find it in our list.
2560 * NOTE: This search is definitely not optimized. Once its doing
2561 * the "right thing" we'll optimize it for efficiency if
2565 /* Search for this entry in the list and update it if it is
2569 spin_lock_irqsave(&ieee->lock, flags);
2570 if (is_same_network(&ieee->current_network, network,
2571 (network->ssid_len ? 1 : 0))) {
2572 update_network(ieee, &ieee->current_network, network);
2573 if ((ieee->current_network.mode == IEEE_N_24G ||
2574 ieee->current_network.mode == IEEE_G)
2575 && ieee->current_network.berp_info_valid) {
2576 if (ieee->current_network.erp_value & ERP_UseProtection)
2577 ieee->current_network.buseprotection = true;
2579 ieee->current_network.buseprotection = false;
2581 if (is_beacon(frame_ctl)) {
2582 if (ieee->state >= RTLLIB_LINKED)
2583 ieee->LinkDetectInfo.NumRecvBcnInPeriod++;
2586 list_for_each_entry(target, &ieee->network_list, list) {
2587 if (is_same_network(target, network,
2588 (target->ssid_len ? 1 : 0)))
2590 if ((oldest == NULL) ||
2591 (target->last_scanned < oldest->last_scanned))
2595 /* If we didn't find a match, then get a new network slot to initialize
2596 * with this beacon's information
2598 if (&target->list == &ieee->network_list) {
2599 if (list_empty(&ieee->network_free_list)) {
2600 /* If there are no more slots, expire the oldest */
2601 list_del(&oldest->list);
2603 netdev_dbg(ieee->dev,
2604 "Expired '%s' ( %pM) from network list.\n",
2605 escape_essid(target->ssid, target->ssid_len),
2608 /* Otherwise just pull from the free list */
2609 target = list_entry(ieee->network_free_list.next,
2610 struct rtllib_network, list);
2611 list_del(ieee->network_free_list.next);
2614 netdev_dbg(ieee->dev, "Adding '%s' ( %pM) via %s.\n",
2615 escape_essid(network->ssid, network->ssid_len),
2617 is_beacon(frame_ctl) ? "BEACON" : "PROBE RESPONSE");
2619 memcpy(target, network, sizeof(*target));
2620 list_add_tail(&target->list, &ieee->network_list);
2621 if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
2622 rtllib_softmac_new_net(ieee, network);
2624 netdev_dbg(ieee->dev, "Updating '%s' ( %pM) via %s.\n",
2625 escape_essid(target->ssid, target->ssid_len),
2627 is_beacon(frame_ctl) ? "BEACON" : "PROBE RESPONSE");
2629 /* we have an entry and we are going to update it. But this
2630 * entry may be already expired. In this case we do the same
2631 * as we found a new net and call the new_net handler
2633 renew = !time_after(target->last_scanned + ieee->scan_age,
2635 if ((!target->ssid_len) &&
2636 (((network->ssid_len > 0) && (target->hidden_ssid_len == 0))
2637 || ((ieee->current_network.ssid_len == network->ssid_len) &&
2638 (strncmp(ieee->current_network.ssid, network->ssid,
2639 network->ssid_len) == 0) &&
2640 (ieee->state == RTLLIB_NOLINK))))
2642 update_network(ieee, target, network);
2643 if (renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE))
2644 rtllib_softmac_new_net(ieee, network);
2647 spin_unlock_irqrestore(&ieee->lock, flags);
2648 if (is_beacon(frame_ctl) &&
2649 is_same_network(&ieee->current_network, network,
2650 (network->ssid_len ? 1 : 0)) &&
2651 (ieee->state == RTLLIB_LINKED)) {
2652 if (ieee->handle_beacon != NULL)
2653 ieee->handle_beacon(ieee->dev, beacon,
2654 &ieee->current_network);
2660 void rtllib_rx_mgt(struct rtllib_device *ieee,
2661 struct sk_buff *skb,
2662 struct rtllib_rx_stats *stats)
2664 struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data;
2666 if ((WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)) !=
2667 RTLLIB_STYPE_PROBE_RESP) &&
2668 (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)) !=
2669 RTLLIB_STYPE_BEACON))
2670 ieee->last_rx_ps_time = jiffies;
2672 switch (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))) {
2674 case RTLLIB_STYPE_BEACON:
2675 RTLLIB_DEBUG_MGMT("received BEACON (%d)\n",
2676 WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)));
2677 rtllib_process_probe_response(
2678 ieee, (struct rtllib_probe_response *)header,
2681 if (ieee->sta_sleep || (ieee->ps != RTLLIB_PS_DISABLED &&
2682 ieee->iw_mode == IW_MODE_INFRA &&
2683 ieee->state == RTLLIB_LINKED))
2684 tasklet_schedule(&ieee->ps_task);
2688 case RTLLIB_STYPE_PROBE_RESP:
2689 RTLLIB_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
2690 WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)));
2691 rtllib_process_probe_response(ieee,
2692 (struct rtllib_probe_response *)header, stats);
2694 case RTLLIB_STYPE_PROBE_REQ:
2695 RTLLIB_DEBUG_MGMT("received PROBE RESQUEST (%d)\n",
2697 le16_to_cpu(header->frame_ctl)));
2698 if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
2699 ((ieee->iw_mode == IW_MODE_ADHOC ||
2700 ieee->iw_mode == IW_MODE_MASTER) &&
2701 ieee->state == RTLLIB_LINKED))
2702 rtllib_rx_probe_rq(ieee, skb);