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
= kmalloc(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 memset(precvpriv
->pallocated_frame_buf
, 0, NR_RECVFRAME
*
82 sizeof(union recv_frame
) + RXFRAME_ALIGN_SZ
);
83 precvpriv
->precv_frame_buf
= precvpriv
->pallocated_frame_buf
+
85 ((addr_t
)(precvpriv
->pallocated_frame_buf
) &
86 (RXFRAME_ALIGN_SZ
- 1));
87 precvframe
= (union recv_frame
*)precvpriv
->precv_frame_buf
;
88 for (i
= 0; i
< NR_RECVFRAME
; i
++) {
89 INIT_LIST_HEAD(&(precvframe
->u
.list
));
90 list_add_tail(&(precvframe
->u
.list
),
91 &(precvpriv
->free_recv_queue
.queue
));
92 r8712_os_recv_resource_alloc(padapter
, precvframe
);
93 precvframe
->u
.hdr
.adapter
= padapter
;
96 precvpriv
->rx_pending_cnt
= 1;
97 return r8712_init_recv_priv(precvpriv
, padapter
);
100 void _r8712_free_recv_priv(struct recv_priv
*precvpriv
)
102 kfree(precvpriv
->pallocated_frame_buf
);
103 r8712_free_recv_priv(precvpriv
);
106 union recv_frame
*r8712_alloc_recvframe(struct __queue
*pfree_recv_queue
)
109 union recv_frame
*precvframe
;
110 struct list_head
*plist
, *phead
;
111 struct _adapter
*padapter
;
112 struct recv_priv
*precvpriv
;
114 spin_lock_irqsave(&pfree_recv_queue
->lock
, irqL
);
115 if (list_empty(&pfree_recv_queue
->queue
)) {
118 phead
= &pfree_recv_queue
->queue
;
120 precvframe
= LIST_CONTAINOR(plist
, union recv_frame
, u
);
121 list_del_init(&precvframe
->u
.hdr
.list
);
122 padapter
= precvframe
->u
.hdr
.adapter
;
123 if (padapter
!= NULL
) {
124 precvpriv
= &padapter
->recvpriv
;
125 if (pfree_recv_queue
== &precvpriv
->free_recv_queue
)
126 precvpriv
->free_recvframe_cnt
--;
129 spin_unlock_irqrestore(&pfree_recv_queue
->lock
, irqL
);
134 caller : defrag; recvframe_chk_defrag in recv_thread (passive)
135 pframequeue: defrag_queue : will be accessed in recv_thread (passive)
137 using spin_lock to protect
141 void r8712_free_recvframe_queue(struct __queue
*pframequeue
,
142 struct __queue
*pfree_recv_queue
)
144 union recv_frame
*precvframe
;
145 struct list_head
*plist
, *phead
;
147 spin_lock(&pframequeue
->lock
);
148 phead
= &pframequeue
->queue
;
150 while (!end_of_queue_search(phead
, plist
)) {
151 precvframe
= LIST_CONTAINOR(plist
, union recv_frame
, u
);
153 r8712_free_recvframe(precvframe
, pfree_recv_queue
);
155 spin_unlock(&pframequeue
->lock
);
158 sint
r8712_recvframe_chkmic(struct _adapter
*adapter
,
159 union recv_frame
*precvframe
)
161 sint i
, res
= _SUCCESS
;
165 u8
*pframe
, *payload
, *pframemic
;
166 u8
*mickey
, idx
, *iv
;
167 struct sta_info
*stainfo
;
168 struct rx_pkt_attrib
*prxattrib
= &precvframe
->u
.hdr
.attrib
;
169 struct security_priv
*psecuritypriv
= &adapter
->securitypriv
;
171 stainfo
= r8712_get_stainfo(&adapter
->stapriv
, &prxattrib
->ta
[0]);
172 if (prxattrib
->encrypt
== _TKIP_
) {
173 /* calculate mic code */
174 if (stainfo
!= NULL
) {
175 if (IS_MCAST(prxattrib
->ra
)) {
176 iv
= precvframe
->u
.hdr
.rx_data
+
179 mickey
= &psecuritypriv
->XGrprxmickey
[(((idx
>>
180 6) & 0x3)) - 1].skey
[0];
181 if (!psecuritypriv
->binstallGrpkey
)
184 mickey
= &stainfo
->tkiprxmickey
.skey
[0];
186 /*icv_len included the mic code*/
187 datalen
= precvframe
->u
.hdr
.len
- prxattrib
->hdrlen
-
188 prxattrib
->iv_len
- prxattrib
->icv_len
- 8;
189 pframe
= precvframe
->u
.hdr
.rx_data
;
190 payload
= pframe
+ prxattrib
->hdrlen
+
192 seccalctkipmic(mickey
, pframe
, payload
, datalen
,
194 (unsigned char)prxattrib
->priority
);
195 pframemic
= payload
+ datalen
;
197 for (i
= 0; i
< 8; i
++) {
198 if (miccode
[i
] != *(pframemic
+ i
))
202 if (prxattrib
->bdecrypted
)
203 r8712_handle_tkip_mic_err(adapter
,
204 (u8
)IS_MCAST(prxattrib
->ra
));
208 if (!psecuritypriv
->bcheck_grpkey
&&
209 IS_MCAST(prxattrib
->ra
))
210 psecuritypriv
->bcheck_grpkey
= true;
212 recvframe_pull_tail(precvframe
, 8);
218 /* decrypt and set the ivlen,icvlen of the recv_frame */
219 union recv_frame
*r8712_decryptor(struct _adapter
*padapter
,
220 union recv_frame
*precv_frame
)
222 struct rx_pkt_attrib
*prxattrib
= &precv_frame
->u
.hdr
.attrib
;
223 struct security_priv
*psecuritypriv
= &padapter
->securitypriv
;
224 union recv_frame
*return_packet
= precv_frame
;
226 if ((prxattrib
->encrypt
> 0) && ((prxattrib
->bdecrypted
== 0) ||
227 psecuritypriv
->sw_decrypt
)) {
228 psecuritypriv
->hw_decrypted
= false;
229 switch (prxattrib
->encrypt
) {
232 r8712_wep_decrypt(padapter
, (u8
*)precv_frame
);
235 r8712_tkip_decrypt(padapter
, (u8
*)precv_frame
);
238 r8712_aes_decrypt(padapter
, (u8
*)precv_frame
);
243 } else if (prxattrib
->bdecrypted
== 1) {
244 psecuritypriv
->hw_decrypted
= true;
246 return return_packet
;
248 /*###set the security information in the recv_frame */
249 union recv_frame
*r8712_portctrl(struct _adapter
*adapter
,
250 union recv_frame
*precv_frame
)
254 struct recv_frame_hdr
*pfhdr
;
255 struct sta_info
*psta
;
256 struct sta_priv
*pstapriv
;
257 union recv_frame
*prtnframe
;
260 pstapriv
= &adapter
->stapriv
;
261 ptr
= get_recvframe_data(precv_frame
);
262 pfhdr
= &precv_frame
->u
.hdr
;
263 psta_addr
= pfhdr
->attrib
.ta
;
264 psta
= r8712_get_stainfo(pstapriv
, psta_addr
);
265 auth_alg
= adapter
->securitypriv
.AuthAlgrthm
;
268 ptr
= ptr
+ pfhdr
->attrib
.hdrlen
+ LLC_HEADER_SIZE
;
269 memcpy(ðer_type
, ptr
, 2);
270 ether_type
= ntohs((unsigned short)ether_type
);
272 if ((psta
!= NULL
) && (psta
->ieee8021x_blocked
)) {
274 * only accept EAPOL frame */
275 if (ether_type
== 0x888e) {
276 prtnframe
= precv_frame
;
279 r8712_free_recvframe(precv_frame
,
280 &adapter
->recvpriv
.free_recv_queue
);
285 * check decryption status, and decrypt the
287 prtnframe
= precv_frame
;
288 /* check is the EAPOL frame or not (Rekey) */
289 if (ether_type
== 0x888e) {
291 prtnframe
= precv_frame
;
295 prtnframe
= precv_frame
;
300 static sint
recv_decache(union recv_frame
*precv_frame
, u8 bretry
,
301 struct stainfo_rxcache
*prxcache
)
303 sint tid
= precv_frame
->u
.hdr
.attrib
.priority
;
304 u16 seq_ctrl
= ((precv_frame
->u
.hdr
.attrib
.seq_num
& 0xffff) << 4) |
305 (precv_frame
->u
.hdr
.attrib
.frag_num
& 0xf);
309 if (seq_ctrl
== prxcache
->tid_rxseq
[tid
])
311 prxcache
->tid_rxseq
[tid
] = seq_ctrl
;
315 static sint
sta2sta_data_frame(struct _adapter
*adapter
,
316 union recv_frame
*precv_frame
,
317 struct sta_info
**psta
)
319 u8
*ptr
= precv_frame
->u
.hdr
.rx_data
;
321 struct rx_pkt_attrib
*pattrib
= &precv_frame
->u
.hdr
.attrib
;
322 struct sta_priv
*pstapriv
= &adapter
->stapriv
;
323 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
324 u8
*mybssid
= get_bssid(pmlmepriv
);
325 u8
*myhwaddr
= myid(&adapter
->eeprompriv
);
327 sint bmcast
= IS_MCAST(pattrib
->dst
);
329 if (check_fwstate(pmlmepriv
, WIFI_ADHOC_STATE
) ||
330 check_fwstate(pmlmepriv
, WIFI_ADHOC_MASTER_STATE
)) {
331 /* filter packets that SA is myself or multicast or broadcast */
332 if (!memcmp(myhwaddr
, pattrib
->src
, ETH_ALEN
))
334 if ((memcmp(myhwaddr
, pattrib
->dst
, ETH_ALEN
)) && (!bmcast
))
336 if (is_zero_ether_addr(pattrib
->bssid
) ||
337 is_zero_ether_addr(mybssid
) ||
338 (memcmp(pattrib
->bssid
, mybssid
, ETH_ALEN
)))
340 sta_addr
= pattrib
->src
;
341 } else if (check_fwstate(pmlmepriv
, WIFI_STATION_STATE
)) {
342 /* For Station mode, sa and bssid should always be BSSID,
343 * and DA is my mac-address */
344 if (memcmp(pattrib
->bssid
, pattrib
->src
, ETH_ALEN
))
346 sta_addr
= pattrib
->bssid
;
347 } else if (check_fwstate(pmlmepriv
, WIFI_AP_STATE
)) {
349 /* For AP mode, if DA == MCAST, then BSSID should
351 if (!IS_MCAST(pattrib
->bssid
))
353 } else { /* not mc-frame */
354 /* For AP mode, if DA is non-MCAST, then it must be
355 * BSSID, and bssid == BSSID */
356 if (memcmp(pattrib
->bssid
, pattrib
->dst
, ETH_ALEN
))
358 sta_addr
= pattrib
->src
;
360 } else if (check_fwstate(pmlmepriv
, WIFI_MP_STATE
)) {
361 memcpy(pattrib
->dst
, GetAddr1Ptr(ptr
), ETH_ALEN
);
362 memcpy(pattrib
->src
, GetAddr2Ptr(ptr
), ETH_ALEN
);
363 memcpy(pattrib
->bssid
, GetAddr3Ptr(ptr
), ETH_ALEN
);
364 memcpy(pattrib
->ra
, pattrib
->dst
, ETH_ALEN
);
365 memcpy(pattrib
->ta
, pattrib
->src
, ETH_ALEN
);
371 *psta
= r8712_get_bcmc_stainfo(adapter
);
373 *psta
= r8712_get_stainfo(pstapriv
, sta_addr
); /* get ap_info */
375 if (check_fwstate(pmlmepriv
, WIFI_MP_STATE
))
376 adapter
->mppriv
.rx_pktloss
++;
382 static sint
ap2sta_data_frame(struct _adapter
*adapter
,
383 union recv_frame
*precv_frame
,
384 struct sta_info
**psta
)
386 u8
*ptr
= precv_frame
->u
.hdr
.rx_data
;
387 struct rx_pkt_attrib
*pattrib
= &precv_frame
->u
.hdr
.attrib
;
388 struct sta_priv
*pstapriv
= &adapter
->stapriv
;
389 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
390 u8
*mybssid
= get_bssid(pmlmepriv
);
391 u8
*myhwaddr
= myid(&adapter
->eeprompriv
);
392 sint bmcast
= IS_MCAST(pattrib
->dst
);
394 if (check_fwstate(pmlmepriv
, WIFI_STATION_STATE
) &&
395 check_fwstate(pmlmepriv
, _FW_LINKED
)) {
396 /* if NULL-frame, drop packet */
397 if ((GetFrameSubType(ptr
)) == WIFI_DATA_NULL
)
399 /* drop QoS-SubType Data, including QoS NULL,
400 * excluding QoS-Data */
401 if ((GetFrameSubType(ptr
) & WIFI_QOS_DATA_TYPE
) ==
402 WIFI_QOS_DATA_TYPE
) {
403 if (GetFrameSubType(ptr
) & (BIT(4) | BIT(5) | BIT(6)))
407 /* filter packets that SA is myself or multicast or broadcast */
408 if (!memcmp(myhwaddr
, pattrib
->src
, ETH_ALEN
))
411 /* da should be for me */
412 if ((memcmp(myhwaddr
, pattrib
->dst
, ETH_ALEN
)) && (!bmcast
))
415 if (is_zero_ether_addr(pattrib
->bssid
) ||
416 is_zero_ether_addr(mybssid
) ||
417 (memcmp(pattrib
->bssid
, mybssid
, ETH_ALEN
)))
420 *psta
= r8712_get_bcmc_stainfo(adapter
);
422 *psta
= r8712_get_stainfo(pstapriv
, pattrib
->bssid
);
425 } else if (check_fwstate(pmlmepriv
, WIFI_MP_STATE
) &&
426 check_fwstate(pmlmepriv
, _FW_LINKED
)) {
427 memcpy(pattrib
->dst
, GetAddr1Ptr(ptr
), ETH_ALEN
);
428 memcpy(pattrib
->src
, GetAddr2Ptr(ptr
), ETH_ALEN
);
429 memcpy(pattrib
->bssid
, GetAddr3Ptr(ptr
), ETH_ALEN
);
430 memcpy(pattrib
->ra
, pattrib
->dst
, ETH_ALEN
);
431 memcpy(pattrib
->ta
, pattrib
->src
, ETH_ALEN
);
432 memcpy(pattrib
->bssid
, mybssid
, ETH_ALEN
);
433 *psta
= r8712_get_stainfo(pstapriv
, pattrib
->bssid
);
442 static sint
sta2ap_data_frame(struct _adapter
*adapter
,
443 union recv_frame
*precv_frame
,
444 struct sta_info
**psta
)
446 struct rx_pkt_attrib
*pattrib
= &precv_frame
->u
.hdr
.attrib
;
447 struct sta_priv
*pstapriv
= &adapter
->stapriv
;
448 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
449 unsigned char *mybssid
= get_bssid(pmlmepriv
);
451 if (check_fwstate(pmlmepriv
, WIFI_AP_STATE
)) {
452 /* For AP mode, if DA is non-MCAST, then it must be BSSID,
454 * For AP mode, RA=BSSID, TX=STA(SRC_ADDR), A3=DST_ADDR */
455 if (memcmp(pattrib
->bssid
, mybssid
, ETH_ALEN
))
457 *psta
= r8712_get_stainfo(pstapriv
, pattrib
->src
);
464 static sint
validate_recv_ctrl_frame(struct _adapter
*adapter
,
465 union recv_frame
*precv_frame
)
470 static sint
validate_recv_mgnt_frame(struct _adapter
*adapter
,
471 union recv_frame
*precv_frame
)
477 static sint
validate_recv_data_frame(struct _adapter
*adapter
,
478 union recv_frame
*precv_frame
)
482 u8
*psa
, *pda
, *pbssid
;
483 struct sta_info
*psta
= NULL
;
484 u8
*ptr
= precv_frame
->u
.hdr
.rx_data
;
485 struct rx_pkt_attrib
*pattrib
= &precv_frame
->u
.hdr
.attrib
;
486 struct security_priv
*psecuritypriv
= &adapter
->securitypriv
;
488 bretry
= GetRetry(ptr
);
491 pbssid
= get_hdr_bssid(ptr
);
494 memcpy(pattrib
->dst
, pda
, ETH_ALEN
);
495 memcpy(pattrib
->src
, psa
, ETH_ALEN
);
496 memcpy(pattrib
->bssid
, pbssid
, ETH_ALEN
);
497 switch (pattrib
->to_fr_ds
) {
499 memcpy(pattrib
->ra
, pda
, ETH_ALEN
);
500 memcpy(pattrib
->ta
, psa
, ETH_ALEN
);
501 res
= sta2sta_data_frame(adapter
, precv_frame
, &psta
);
504 memcpy(pattrib
->ra
, pda
, ETH_ALEN
);
505 memcpy(pattrib
->ta
, pbssid
, ETH_ALEN
);
506 res
= ap2sta_data_frame(adapter
, precv_frame
, &psta
);
509 memcpy(pattrib
->ra
, pbssid
, ETH_ALEN
);
510 memcpy(pattrib
->ta
, psa
, ETH_ALEN
);
511 res
= sta2ap_data_frame(adapter
, precv_frame
, &psta
);
514 memcpy(pattrib
->ra
, GetAddr1Ptr(ptr
), ETH_ALEN
);
515 memcpy(pattrib
->ta
, GetAddr2Ptr(ptr
), ETH_ALEN
);
524 precv_frame
->u
.hdr
.psta
= psta
;
526 /* parsing QC field */
527 if (pattrib
->qos
== 1) {
528 pattrib
->priority
= GetPriority((ptr
+ 24));
529 pattrib
->ack_policy
= GetAckpolicy((ptr
+ 24));
530 pattrib
->amsdu
= GetAMsdu((ptr
+ 24));
531 pattrib
->hdrlen
= pattrib
->to_fr_ds
== 3 ? 32 : 26;
533 pattrib
->priority
= 0;
534 pattrib
->hdrlen
= (pattrib
->to_fr_ds
== 3) ? 30 : 24;
537 if (pattrib
->order
)/*HT-CTRL 11n*/
538 pattrib
->hdrlen
+= 4;
539 precv_frame
->u
.hdr
.preorder_ctrl
=
540 &psta
->recvreorder_ctrl
[pattrib
->priority
];
542 /* decache, drop duplicate recv packets */
543 if (recv_decache(precv_frame
, bretry
, &psta
->sta_recvpriv
.rxcache
) ==
547 if (pattrib
->privacy
) {
548 GET_ENCRY_ALGO(psecuritypriv
, psta
, pattrib
->encrypt
,
549 IS_MCAST(pattrib
->ra
));
550 SET_ICE_IV_LEN(pattrib
->iv_len
, pattrib
->icv_len
,
553 pattrib
->encrypt
= 0;
554 pattrib
->iv_len
= pattrib
->icv_len
= 0;
559 sint
r8712_validate_recv_frame(struct _adapter
*adapter
,
560 union recv_frame
*precv_frame
)
562 /*shall check frame subtype, to / from ds, da, bssid */
563 /*then call check if rx seq/frag. duplicated.*/
567 sint retval
= _SUCCESS
;
568 struct rx_pkt_attrib
*pattrib
= &precv_frame
->u
.hdr
.attrib
;
570 u8
*ptr
= precv_frame
->u
.hdr
.rx_data
;
571 u8 ver
= (unsigned char)(*ptr
) & 0x3;
576 type
= GetFrameType(ptr
);
577 subtype
= GetFrameSubType(ptr
); /*bit(7)~bit(2)*/
578 pattrib
->to_fr_ds
= get_tofr_ds(ptr
);
579 pattrib
->frag_num
= GetFragNum(ptr
);
580 pattrib
->seq_num
= GetSequence(ptr
);
581 pattrib
->pw_save
= GetPwrMgt(ptr
);
582 pattrib
->mfrag
= GetMFrag(ptr
);
583 pattrib
->mdata
= GetMData(ptr
);
584 pattrib
->privacy
= GetPrivacy(ptr
);
585 pattrib
->order
= GetOrder(ptr
);
587 case WIFI_MGT_TYPE
: /*mgnt*/
588 retval
= validate_recv_mgnt_frame(adapter
, precv_frame
);
590 case WIFI_CTRL_TYPE
:/*ctrl*/
591 retval
= validate_recv_ctrl_frame(adapter
, precv_frame
);
593 case WIFI_DATA_TYPE
: /*data*/
594 pattrib
->qos
= (subtype
& BIT(7)) ? 1 : 0;
595 retval
= validate_recv_data_frame(adapter
, precv_frame
);
603 sint
r8712_wlanhdr_to_ethhdr(union recv_frame
*precvframe
)
605 /*remove the wlanhdr and add the eth_hdr*/
610 struct ieee80211_snap_hdr
*psnap
;
611 struct _adapter
*adapter
= precvframe
->u
.hdr
.adapter
;
612 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
614 u8
*ptr
= get_recvframe_data(precvframe
); /*point to frame_ctrl field*/
615 struct rx_pkt_attrib
*pattrib
= &precvframe
->u
.hdr
.attrib
;
617 if (pattrib
->encrypt
)
618 recvframe_pull_tail(precvframe
, pattrib
->icv_len
);
619 psnap
= (struct ieee80211_snap_hdr
*)(ptr
+ pattrib
->hdrlen
+
621 psnap_type
= ptr
+ pattrib
->hdrlen
+ pattrib
->iv_len
+ SNAP_SIZE
;
622 /* convert hdr + possible LLC headers into Ethernet header */
623 if ((!memcmp(psnap
, (void *)rfc1042_header
, SNAP_SIZE
) &&
624 (memcmp(psnap_type
, (void *)SNAP_ETH_TYPE_IPX
, 2)) &&
625 (memcmp(psnap_type
, (void *)SNAP_ETH_TYPE_APPLETALK_AARP
, 2))) ||
626 !memcmp(psnap
, (void *)bridge_tunnel_header
, SNAP_SIZE
)) {
627 /* remove RFC1042 or Bridge-Tunnel encapsulation and
628 * replace EtherType */
631 /* Leave Ethernet header part of hdr and full payload */
634 rmv_len
= pattrib
->hdrlen
+ pattrib
->iv_len
+
635 (bsnaphdr
? SNAP_SIZE
: 0);
636 len
= precvframe
->u
.hdr
.len
- rmv_len
;
637 if (check_fwstate(pmlmepriv
, WIFI_MP_STATE
)) {
641 /* append rx status for mp test packets */
642 ptr
= recvframe_pull(precvframe
, (rmv_len
-
643 sizeof(struct ethhdr
) + 2) - 24);
646 memcpy(ptr
, get_rxmem(precvframe
), 24);
649 ptr
= recvframe_pull(precvframe
, (rmv_len
-
650 sizeof(struct ethhdr
) + (bsnaphdr
? 2 : 0)));
655 memcpy(ptr
, pattrib
->dst
, ETH_ALEN
);
656 memcpy(ptr
+ ETH_ALEN
, pattrib
->src
, ETH_ALEN
);
659 memcpy(ptr
+ 12, &len
, 2);
664 s32
r8712_recv_entry(union recv_frame
*precvframe
)
666 struct _adapter
*padapter
;
667 struct recv_priv
*precvpriv
;
671 padapter
= precvframe
->u
.hdr
.adapter
;
672 precvpriv
= &(padapter
->recvpriv
);
674 padapter
->ledpriv
.LedControlHandler(padapter
, LED_CTL_RX
);
676 ret
= recv_func(padapter
, precvframe
);
678 goto _recv_entry_drop
;
679 precvpriv
->rx_pkts
++;
680 precvpriv
->rx_bytes
+= (uint
)(precvframe
->u
.hdr
.rx_tail
-
681 precvframe
->u
.hdr
.rx_data
);
684 precvpriv
->rx_drop
++;
685 padapter
->mppriv
.rx_pktloss
= precvpriv
->rx_drop
;