1 /******************************************************************************
4 * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
5 * Linux device driver for RTL8192SU
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 * Modifications for inclusion into the Linux staging tree are
21 * Copyright(c) 2010 Larry Finger. All rights reserved.
23 * Contact information:
24 * WLAN FAE <wlanfae@realtek.com>
25 * Larry Finger <Larry.Finger@lwfinger.net>
27 ******************************************************************************/
29 #define _RTL871X_RECV_C_
32 #include <linux/slab.h>
33 #include <linux/if_ether.h>
34 #include <linux/kmemleak.h>
35 #include <linux/etherdevice.h>
37 #include "osdep_service.h"
38 #include "drv_types.h"
39 #include "recv_osdep.h"
40 #include "mlme_osdep.h"
45 static const u8 SNAP_ETH_TYPE_IPX
[2] = {0x81, 0x37};
47 /* Datagram Delivery Protocol */
48 static const u8 SNAP_ETH_TYPE_APPLETALK_AARP
[2] = {0x80, 0xf3};
50 /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
51 static const u8 bridge_tunnel_header
[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8};
53 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
54 static const u8 rfc1042_header
[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
56 void _r8712_init_sta_recv_priv(struct sta_recv_priv
*psta_recvpriv
)
58 memset((u8
*)psta_recvpriv
, 0, sizeof(struct sta_recv_priv
));
59 spin_lock_init(&psta_recvpriv
->lock
);
60 _init_queue(&psta_recvpriv
->defrag_q
);
63 sint
_r8712_init_recv_priv(struct recv_priv
*precvpriv
,
64 struct _adapter
*padapter
)
67 union recv_frame
*precvframe
;
69 memset((unsigned char *)precvpriv
, 0, sizeof(struct recv_priv
));
70 spin_lock_init(&precvpriv
->lock
);
71 _init_queue(&precvpriv
->free_recv_queue
);
72 _init_queue(&precvpriv
->recv_pending_queue
);
73 precvpriv
->adapter
= padapter
;
74 precvpriv
->free_recvframe_cnt
= NR_RECVFRAME
;
75 precvpriv
->pallocated_frame_buf
= kzalloc(NR_RECVFRAME
*
76 sizeof(union recv_frame
) + RXFRAME_ALIGN_SZ
,
78 if (precvpriv
->pallocated_frame_buf
== NULL
)
80 kmemleak_not_leak(precvpriv
->pallocated_frame_buf
);
81 precvpriv
->precv_frame_buf
= precvpriv
->pallocated_frame_buf
+
83 ((addr_t
)(precvpriv
->pallocated_frame_buf
) &
84 (RXFRAME_ALIGN_SZ
- 1));
85 precvframe
= (union recv_frame
*)precvpriv
->precv_frame_buf
;
86 for (i
= 0; i
< NR_RECVFRAME
; i
++) {
87 INIT_LIST_HEAD(&(precvframe
->u
.list
));
88 list_add_tail(&(precvframe
->u
.list
),
89 &(precvpriv
->free_recv_queue
.queue
));
90 r8712_os_recv_resource_alloc(padapter
, precvframe
);
91 precvframe
->u
.hdr
.adapter
= padapter
;
94 precvpriv
->rx_pending_cnt
= 1;
95 return r8712_init_recv_priv(precvpriv
, padapter
);
98 void _r8712_free_recv_priv(struct recv_priv
*precvpriv
)
100 kfree(precvpriv
->pallocated_frame_buf
);
101 r8712_free_recv_priv(precvpriv
);
104 union recv_frame
*r8712_alloc_recvframe(struct __queue
*pfree_recv_queue
)
107 union recv_frame
*precvframe
;
108 struct _adapter
*padapter
;
109 struct recv_priv
*precvpriv
;
111 spin_lock_irqsave(&pfree_recv_queue
->lock
, irqL
);
112 precvframe
= list_first_entry_or_null(&pfree_recv_queue
->queue
,
113 union recv_frame
, u
.hdr
.list
);
115 list_del_init(&precvframe
->u
.hdr
.list
);
116 padapter
= precvframe
->u
.hdr
.adapter
;
117 if (padapter
!= NULL
) {
118 precvpriv
= &padapter
->recvpriv
;
119 if (pfree_recv_queue
== &precvpriv
->free_recv_queue
)
120 precvpriv
->free_recvframe_cnt
--;
123 spin_unlock_irqrestore(&pfree_recv_queue
->lock
, irqL
);
128 caller : defrag; recvframe_chk_defrag in recv_thread (passive)
129 pframequeue: defrag_queue : will be accessed in recv_thread (passive)
131 using spin_lock to protect
135 void r8712_free_recvframe_queue(struct __queue
*pframequeue
,
136 struct __queue
*pfree_recv_queue
)
138 union recv_frame
*precvframe
;
139 struct list_head
*plist
, *phead
;
141 spin_lock(&pframequeue
->lock
);
142 phead
= &pframequeue
->queue
;
144 while (!end_of_queue_search(phead
, plist
)) {
145 precvframe
= LIST_CONTAINOR(plist
, union recv_frame
, u
);
147 r8712_free_recvframe(precvframe
, pfree_recv_queue
);
149 spin_unlock(&pframequeue
->lock
);
152 sint
r8712_recvframe_chkmic(struct _adapter
*adapter
,
153 union recv_frame
*precvframe
)
155 sint i
, res
= _SUCCESS
;
159 u8
*pframe
, *payload
, *pframemic
;
160 u8
*mickey
, idx
, *iv
;
161 struct sta_info
*stainfo
;
162 struct rx_pkt_attrib
*prxattrib
= &precvframe
->u
.hdr
.attrib
;
163 struct security_priv
*psecuritypriv
= &adapter
->securitypriv
;
165 stainfo
= r8712_get_stainfo(&adapter
->stapriv
, &prxattrib
->ta
[0]);
166 if (prxattrib
->encrypt
== _TKIP_
) {
167 /* calculate mic code */
168 if (stainfo
!= NULL
) {
169 if (IS_MCAST(prxattrib
->ra
)) {
170 iv
= precvframe
->u
.hdr
.rx_data
+
173 mickey
= &psecuritypriv
->XGrprxmickey
[(((idx
>>
174 6) & 0x3)) - 1].skey
[0];
175 if (!psecuritypriv
->binstallGrpkey
)
178 mickey
= &stainfo
->tkiprxmickey
.skey
[0];
180 /*icv_len included the mic code*/
181 datalen
= precvframe
->u
.hdr
.len
- prxattrib
->hdrlen
-
182 prxattrib
->iv_len
- prxattrib
->icv_len
- 8;
183 pframe
= precvframe
->u
.hdr
.rx_data
;
184 payload
= pframe
+ prxattrib
->hdrlen
+
186 seccalctkipmic(mickey
, pframe
, payload
, datalen
,
188 (unsigned char)prxattrib
->priority
);
189 pframemic
= payload
+ datalen
;
191 for (i
= 0; i
< 8; i
++) {
192 if (miccode
[i
] != *(pframemic
+ i
))
196 if (prxattrib
->bdecrypted
)
197 r8712_handle_tkip_mic_err(adapter
,
198 (u8
)IS_MCAST(prxattrib
->ra
));
202 if (!psecuritypriv
->bcheck_grpkey
&&
203 IS_MCAST(prxattrib
->ra
))
204 psecuritypriv
->bcheck_grpkey
= true;
206 recvframe_pull_tail(precvframe
, 8);
212 /* decrypt and set the ivlen,icvlen of the recv_frame */
213 union recv_frame
*r8712_decryptor(struct _adapter
*padapter
,
214 union recv_frame
*precv_frame
)
216 struct rx_pkt_attrib
*prxattrib
= &precv_frame
->u
.hdr
.attrib
;
217 struct security_priv
*psecuritypriv
= &padapter
->securitypriv
;
218 union recv_frame
*return_packet
= precv_frame
;
220 if ((prxattrib
->encrypt
> 0) && ((prxattrib
->bdecrypted
== 0) ||
221 psecuritypriv
->sw_decrypt
)) {
222 psecuritypriv
->hw_decrypted
= false;
223 switch (prxattrib
->encrypt
) {
226 r8712_wep_decrypt(padapter
, (u8
*)precv_frame
);
229 r8712_tkip_decrypt(padapter
, (u8
*)precv_frame
);
232 r8712_aes_decrypt(padapter
, (u8
*)precv_frame
);
237 } else if (prxattrib
->bdecrypted
== 1) {
238 psecuritypriv
->hw_decrypted
= true;
240 return return_packet
;
242 /*###set the security information in the recv_frame */
243 union recv_frame
*r8712_portctrl(struct _adapter
*adapter
,
244 union recv_frame
*precv_frame
)
248 struct recv_frame_hdr
*pfhdr
;
249 struct sta_info
*psta
;
250 struct sta_priv
*pstapriv
;
251 union recv_frame
*prtnframe
;
254 pstapriv
= &adapter
->stapriv
;
255 ptr
= get_recvframe_data(precv_frame
);
256 pfhdr
= &precv_frame
->u
.hdr
;
257 psta_addr
= pfhdr
->attrib
.ta
;
258 psta
= r8712_get_stainfo(pstapriv
, psta_addr
);
259 auth_alg
= adapter
->securitypriv
.AuthAlgrthm
;
262 ptr
= ptr
+ pfhdr
->attrib
.hdrlen
+ LLC_HEADER_SIZE
;
263 memcpy(ðer_type
, ptr
, 2);
264 ether_type
= ntohs((unsigned short)ether_type
);
266 if ((psta
!= NULL
) && (psta
->ieee8021x_blocked
)) {
268 * only accept EAPOL frame */
269 if (ether_type
== 0x888e) {
270 prtnframe
= precv_frame
;
273 r8712_free_recvframe(precv_frame
,
274 &adapter
->recvpriv
.free_recv_queue
);
279 * check decryption status, and decrypt the
281 prtnframe
= precv_frame
;
282 /* check is the EAPOL frame or not (Rekey) */
283 if (ether_type
== 0x888e) {
285 prtnframe
= precv_frame
;
289 prtnframe
= precv_frame
;
294 static sint
recv_decache(union recv_frame
*precv_frame
, u8 bretry
,
295 struct stainfo_rxcache
*prxcache
)
297 sint tid
= precv_frame
->u
.hdr
.attrib
.priority
;
298 u16 seq_ctrl
= ((precv_frame
->u
.hdr
.attrib
.seq_num
& 0xffff) << 4) |
299 (precv_frame
->u
.hdr
.attrib
.frag_num
& 0xf);
303 if (seq_ctrl
== prxcache
->tid_rxseq
[tid
])
305 prxcache
->tid_rxseq
[tid
] = seq_ctrl
;
309 static sint
sta2sta_data_frame(struct _adapter
*adapter
,
310 union recv_frame
*precv_frame
,
311 struct sta_info
**psta
)
313 u8
*ptr
= precv_frame
->u
.hdr
.rx_data
;
315 struct rx_pkt_attrib
*pattrib
= &precv_frame
->u
.hdr
.attrib
;
316 struct sta_priv
*pstapriv
= &adapter
->stapriv
;
317 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
318 u8
*mybssid
= get_bssid(pmlmepriv
);
319 u8
*myhwaddr
= myid(&adapter
->eeprompriv
);
321 sint bmcast
= IS_MCAST(pattrib
->dst
);
323 if (check_fwstate(pmlmepriv
, WIFI_ADHOC_STATE
) ||
324 check_fwstate(pmlmepriv
, WIFI_ADHOC_MASTER_STATE
)) {
325 /* filter packets that SA is myself or multicast or broadcast */
326 if (!memcmp(myhwaddr
, pattrib
->src
, ETH_ALEN
))
328 if ((memcmp(myhwaddr
, pattrib
->dst
, ETH_ALEN
)) && (!bmcast
))
330 if (is_zero_ether_addr(pattrib
->bssid
) ||
331 is_zero_ether_addr(mybssid
) ||
332 (memcmp(pattrib
->bssid
, mybssid
, ETH_ALEN
)))
334 sta_addr
= pattrib
->src
;
335 } else if (check_fwstate(pmlmepriv
, WIFI_STATION_STATE
)) {
336 /* For Station mode, sa and bssid should always be BSSID,
337 * and DA is my mac-address */
338 if (memcmp(pattrib
->bssid
, pattrib
->src
, ETH_ALEN
))
340 sta_addr
= pattrib
->bssid
;
341 } else if (check_fwstate(pmlmepriv
, WIFI_AP_STATE
)) {
343 /* For AP mode, if DA == MCAST, then BSSID should
345 if (!IS_MCAST(pattrib
->bssid
))
347 } else { /* not mc-frame */
348 /* For AP mode, if DA is non-MCAST, then it must be
349 * BSSID, and bssid == BSSID */
350 if (memcmp(pattrib
->bssid
, pattrib
->dst
, ETH_ALEN
))
352 sta_addr
= pattrib
->src
;
354 } else if (check_fwstate(pmlmepriv
, WIFI_MP_STATE
)) {
355 memcpy(pattrib
->dst
, GetAddr1Ptr(ptr
), ETH_ALEN
);
356 memcpy(pattrib
->src
, GetAddr2Ptr(ptr
), ETH_ALEN
);
357 memcpy(pattrib
->bssid
, GetAddr3Ptr(ptr
), ETH_ALEN
);
358 memcpy(pattrib
->ra
, pattrib
->dst
, ETH_ALEN
);
359 memcpy(pattrib
->ta
, pattrib
->src
, ETH_ALEN
);
365 *psta
= r8712_get_bcmc_stainfo(adapter
);
367 *psta
= r8712_get_stainfo(pstapriv
, sta_addr
); /* get ap_info */
369 if (check_fwstate(pmlmepriv
, WIFI_MP_STATE
))
370 adapter
->mppriv
.rx_pktloss
++;
376 static sint
ap2sta_data_frame(struct _adapter
*adapter
,
377 union recv_frame
*precv_frame
,
378 struct sta_info
**psta
)
380 u8
*ptr
= precv_frame
->u
.hdr
.rx_data
;
381 struct rx_pkt_attrib
*pattrib
= &precv_frame
->u
.hdr
.attrib
;
382 struct sta_priv
*pstapriv
= &adapter
->stapriv
;
383 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
384 u8
*mybssid
= get_bssid(pmlmepriv
);
385 u8
*myhwaddr
= myid(&adapter
->eeprompriv
);
386 sint bmcast
= IS_MCAST(pattrib
->dst
);
388 if (check_fwstate(pmlmepriv
, WIFI_STATION_STATE
) &&
389 check_fwstate(pmlmepriv
, _FW_LINKED
)) {
390 /* if NULL-frame, drop packet */
391 if ((GetFrameSubType(ptr
)) == WIFI_DATA_NULL
)
393 /* drop QoS-SubType Data, including QoS NULL,
394 * excluding QoS-Data */
395 if ((GetFrameSubType(ptr
) & WIFI_QOS_DATA_TYPE
) ==
396 WIFI_QOS_DATA_TYPE
) {
397 if (GetFrameSubType(ptr
) & (BIT(4) | BIT(5) | BIT(6)))
401 /* filter packets that SA is myself or multicast or broadcast */
402 if (!memcmp(myhwaddr
, pattrib
->src
, ETH_ALEN
))
405 /* da should be for me */
406 if ((memcmp(myhwaddr
, pattrib
->dst
, ETH_ALEN
)) && (!bmcast
))
409 if (is_zero_ether_addr(pattrib
->bssid
) ||
410 is_zero_ether_addr(mybssid
) ||
411 (memcmp(pattrib
->bssid
, mybssid
, ETH_ALEN
)))
414 *psta
= r8712_get_bcmc_stainfo(adapter
);
416 *psta
= r8712_get_stainfo(pstapriv
, pattrib
->bssid
);
419 } else if (check_fwstate(pmlmepriv
, WIFI_MP_STATE
) &&
420 check_fwstate(pmlmepriv
, _FW_LINKED
)) {
421 memcpy(pattrib
->dst
, GetAddr1Ptr(ptr
), ETH_ALEN
);
422 memcpy(pattrib
->src
, GetAddr2Ptr(ptr
), ETH_ALEN
);
423 memcpy(pattrib
->bssid
, GetAddr3Ptr(ptr
), ETH_ALEN
);
424 memcpy(pattrib
->ra
, pattrib
->dst
, ETH_ALEN
);
425 memcpy(pattrib
->ta
, pattrib
->src
, ETH_ALEN
);
426 memcpy(pattrib
->bssid
, mybssid
, ETH_ALEN
);
427 *psta
= r8712_get_stainfo(pstapriv
, pattrib
->bssid
);
436 static sint
sta2ap_data_frame(struct _adapter
*adapter
,
437 union recv_frame
*precv_frame
,
438 struct sta_info
**psta
)
440 struct rx_pkt_attrib
*pattrib
= &precv_frame
->u
.hdr
.attrib
;
441 struct sta_priv
*pstapriv
= &adapter
->stapriv
;
442 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
443 unsigned char *mybssid
= get_bssid(pmlmepriv
);
445 if (check_fwstate(pmlmepriv
, WIFI_AP_STATE
)) {
446 /* For AP mode, if DA is non-MCAST, then it must be BSSID,
448 * For AP mode, RA=BSSID, TX=STA(SRC_ADDR), A3=DST_ADDR */
449 if (memcmp(pattrib
->bssid
, mybssid
, ETH_ALEN
))
451 *psta
= r8712_get_stainfo(pstapriv
, pattrib
->src
);
458 static sint
validate_recv_ctrl_frame(struct _adapter
*adapter
,
459 union recv_frame
*precv_frame
)
464 static sint
validate_recv_mgnt_frame(struct _adapter
*adapter
,
465 union recv_frame
*precv_frame
)
471 static sint
validate_recv_data_frame(struct _adapter
*adapter
,
472 union recv_frame
*precv_frame
)
476 u8
*psa
, *pda
, *pbssid
;
477 struct sta_info
*psta
= NULL
;
478 u8
*ptr
= precv_frame
->u
.hdr
.rx_data
;
479 struct rx_pkt_attrib
*pattrib
= &precv_frame
->u
.hdr
.attrib
;
480 struct security_priv
*psecuritypriv
= &adapter
->securitypriv
;
482 bretry
= GetRetry(ptr
);
485 pbssid
= get_hdr_bssid(ptr
);
488 memcpy(pattrib
->dst
, pda
, ETH_ALEN
);
489 memcpy(pattrib
->src
, psa
, ETH_ALEN
);
490 memcpy(pattrib
->bssid
, pbssid
, ETH_ALEN
);
491 switch (pattrib
->to_fr_ds
) {
493 memcpy(pattrib
->ra
, pda
, ETH_ALEN
);
494 memcpy(pattrib
->ta
, psa
, ETH_ALEN
);
495 res
= sta2sta_data_frame(adapter
, precv_frame
, &psta
);
498 memcpy(pattrib
->ra
, pda
, ETH_ALEN
);
499 memcpy(pattrib
->ta
, pbssid
, ETH_ALEN
);
500 res
= ap2sta_data_frame(adapter
, precv_frame
, &psta
);
503 memcpy(pattrib
->ra
, pbssid
, ETH_ALEN
);
504 memcpy(pattrib
->ta
, psa
, ETH_ALEN
);
505 res
= sta2ap_data_frame(adapter
, precv_frame
, &psta
);
508 memcpy(pattrib
->ra
, GetAddr1Ptr(ptr
), ETH_ALEN
);
509 memcpy(pattrib
->ta
, GetAddr2Ptr(ptr
), ETH_ALEN
);
518 precv_frame
->u
.hdr
.psta
= psta
;
520 /* parsing QC field */
521 if (pattrib
->qos
== 1) {
522 pattrib
->priority
= GetPriority((ptr
+ 24));
523 pattrib
->ack_policy
= GetAckpolicy((ptr
+ 24));
524 pattrib
->amsdu
= GetAMsdu((ptr
+ 24));
525 pattrib
->hdrlen
= pattrib
->to_fr_ds
== 3 ? 32 : 26;
527 pattrib
->priority
= 0;
528 pattrib
->hdrlen
= (pattrib
->to_fr_ds
== 3) ? 30 : 24;
531 if (pattrib
->order
)/*HT-CTRL 11n*/
532 pattrib
->hdrlen
+= 4;
533 precv_frame
->u
.hdr
.preorder_ctrl
=
534 &psta
->recvreorder_ctrl
[pattrib
->priority
];
536 /* decache, drop duplicate recv packets */
537 if (recv_decache(precv_frame
, bretry
, &psta
->sta_recvpriv
.rxcache
) ==
541 if (pattrib
->privacy
) {
542 GET_ENCRY_ALGO(psecuritypriv
, psta
, pattrib
->encrypt
,
543 IS_MCAST(pattrib
->ra
));
544 SET_ICE_IV_LEN(pattrib
->iv_len
, pattrib
->icv_len
,
547 pattrib
->encrypt
= 0;
548 pattrib
->iv_len
= pattrib
->icv_len
= 0;
553 sint
r8712_validate_recv_frame(struct _adapter
*adapter
,
554 union recv_frame
*precv_frame
)
556 /*shall check frame subtype, to / from ds, da, bssid */
557 /*then call check if rx seq/frag. duplicated.*/
561 sint retval
= _SUCCESS
;
562 struct rx_pkt_attrib
*pattrib
= &precv_frame
->u
.hdr
.attrib
;
564 u8
*ptr
= precv_frame
->u
.hdr
.rx_data
;
565 u8 ver
= (unsigned char)(*ptr
) & 0x3;
570 type
= GetFrameType(ptr
);
571 subtype
= GetFrameSubType(ptr
); /*bit(7)~bit(2)*/
572 pattrib
->to_fr_ds
= get_tofr_ds(ptr
);
573 pattrib
->frag_num
= GetFragNum(ptr
);
574 pattrib
->seq_num
= GetSequence(ptr
);
575 pattrib
->pw_save
= GetPwrMgt(ptr
);
576 pattrib
->mfrag
= GetMFrag(ptr
);
577 pattrib
->mdata
= GetMData(ptr
);
578 pattrib
->privacy
= GetPrivacy(ptr
);
579 pattrib
->order
= GetOrder(ptr
);
581 case WIFI_MGT_TYPE
: /*mgnt*/
582 retval
= validate_recv_mgnt_frame(adapter
, precv_frame
);
584 case WIFI_CTRL_TYPE
:/*ctrl*/
585 retval
= validate_recv_ctrl_frame(adapter
, precv_frame
);
587 case WIFI_DATA_TYPE
: /*data*/
588 pattrib
->qos
= (subtype
& BIT(7)) ? 1 : 0;
589 retval
= validate_recv_data_frame(adapter
, precv_frame
);
597 sint
r8712_wlanhdr_to_ethhdr(union recv_frame
*precvframe
)
599 /*remove the wlanhdr and add the eth_hdr*/
604 struct ieee80211_snap_hdr
*psnap
;
605 struct _adapter
*adapter
= precvframe
->u
.hdr
.adapter
;
606 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
608 u8
*ptr
= get_recvframe_data(precvframe
); /*point to frame_ctrl field*/
609 struct rx_pkt_attrib
*pattrib
= &precvframe
->u
.hdr
.attrib
;
611 if (pattrib
->encrypt
)
612 recvframe_pull_tail(precvframe
, pattrib
->icv_len
);
613 psnap
= (struct ieee80211_snap_hdr
*)(ptr
+ pattrib
->hdrlen
+
615 psnap_type
= ptr
+ pattrib
->hdrlen
+ pattrib
->iv_len
+ SNAP_SIZE
;
616 /* convert hdr + possible LLC headers into Ethernet header */
617 if ((!memcmp(psnap
, (void *)rfc1042_header
, SNAP_SIZE
) &&
618 (memcmp(psnap_type
, (void *)SNAP_ETH_TYPE_IPX
, 2)) &&
619 (memcmp(psnap_type
, (void *)SNAP_ETH_TYPE_APPLETALK_AARP
, 2))) ||
620 !memcmp(psnap
, (void *)bridge_tunnel_header
, SNAP_SIZE
)) {
621 /* remove RFC1042 or Bridge-Tunnel encapsulation and
622 * replace EtherType */
625 /* Leave Ethernet header part of hdr and full payload */
628 rmv_len
= pattrib
->hdrlen
+ pattrib
->iv_len
+
629 (bsnaphdr
? SNAP_SIZE
: 0);
630 len
= precvframe
->u
.hdr
.len
- rmv_len
;
631 if (check_fwstate(pmlmepriv
, WIFI_MP_STATE
)) {
635 /* append rx status for mp test packets */
636 ptr
= recvframe_pull(precvframe
, (rmv_len
-
637 sizeof(struct ethhdr
) + 2) - 24);
638 memcpy(ptr
, get_rxmem(precvframe
), 24);
641 ptr
= recvframe_pull(precvframe
, (rmv_len
-
642 sizeof(struct ethhdr
) + (bsnaphdr
? 2 : 0)));
644 memcpy(ptr
, pattrib
->dst
, ETH_ALEN
);
645 memcpy(ptr
+ ETH_ALEN
, pattrib
->src
, ETH_ALEN
);
648 memcpy(ptr
+ 12, &len
, 2);
653 s32
r8712_recv_entry(union recv_frame
*precvframe
)
655 struct _adapter
*padapter
;
656 struct recv_priv
*precvpriv
;
660 padapter
= precvframe
->u
.hdr
.adapter
;
661 precvpriv
= &(padapter
->recvpriv
);
663 padapter
->ledpriv
.LedControlHandler(padapter
, LED_CTL_RX
);
665 ret
= recv_func(padapter
, precvframe
);
667 goto _recv_entry_drop
;
668 precvpriv
->rx_pkts
++;
669 precvpriv
->rx_bytes
+= (uint
)(precvframe
->u
.hdr
.rx_tail
-
670 precvframe
->u
.hdr
.rx_data
);
673 precvpriv
->rx_drop
++;
674 padapter
->mppriv
.rx_pktloss
= precvpriv
->rx_drop
;