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_
31 #include "osdep_service.h"
32 #include "drv_types.h"
33 #include "recv_osdep.h"
34 #include "mlme_osdep.h"
41 static const u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37};
43 /* Datagram Delivery Protocol */
44 static const u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3};
46 /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
47 static const u8 bridge_tunnel_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8};
49 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
50 static const u8 rfc1042_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
52 void _r8712_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv)
54 memset((u8 *)psta_recvpriv, 0, sizeof(struct sta_recv_priv));
55 spin_lock_init(&psta_recvpriv->lock);
56 _init_queue(&psta_recvpriv->defrag_q);
59 sint _r8712_init_recv_priv(struct recv_priv *precvpriv,
60 struct _adapter *padapter)
63 union recv_frame *precvframe;
65 memset((unsigned char *)precvpriv, 0, sizeof(struct recv_priv));
66 spin_lock_init(&precvpriv->lock);
67 _init_queue(&precvpriv->free_recv_queue);
68 _init_queue(&precvpriv->recv_pending_queue);
69 precvpriv->adapter = padapter;
70 precvpriv->free_recvframe_cnt = NR_RECVFRAME;
71 precvpriv->pallocated_frame_buf = _malloc(NR_RECVFRAME *
72 sizeof(union recv_frame) +
74 if (precvpriv->pallocated_frame_buf == NULL)
76 memset(precvpriv->pallocated_frame_buf, 0, NR_RECVFRAME *
77 sizeof(union recv_frame) + RXFRAME_ALIGN_SZ);
78 precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf +
80 ((addr_t)(precvpriv->pallocated_frame_buf) &
81 (RXFRAME_ALIGN_SZ-1));
82 precvframe = (union recv_frame *)precvpriv->precv_frame_buf;
83 for (i = 0; i < NR_RECVFRAME; i++) {
84 _init_listhead(&(precvframe->u.list));
85 list_insert_tail(&(precvframe->u.list),
86 &(precvpriv->free_recv_queue.queue));
87 r8712_os_recv_resource_alloc(padapter, precvframe);
88 precvframe->u.hdr.adapter = padapter;
91 precvpriv->rx_pending_cnt = 1;
92 sema_init(&precvpriv->allrxreturnevt, 0);
93 return r8712_init_recv_priv(precvpriv, padapter);
96 void _r8712_free_recv_priv(struct recv_priv *precvpriv)
98 kfree(precvpriv->pallocated_frame_buf);
99 r8712_free_recv_priv(precvpriv);
102 union recv_frame *r8712_alloc_recvframe(struct __queue *pfree_recv_queue)
105 union recv_frame *precvframe;
106 struct list_head *plist, *phead;
107 struct _adapter *padapter;
108 struct recv_priv *precvpriv;
110 spin_lock_irqsave(&pfree_recv_queue->lock, irqL);
111 if (_queue_empty(pfree_recv_queue) == true)
114 phead = get_list_head(pfree_recv_queue);
115 plist = get_next(phead);
116 precvframe = LIST_CONTAINOR(plist, union recv_frame, u);
117 list_delete(&precvframe->u.hdr.list);
118 padapter = precvframe->u.hdr.adapter;
119 if (padapter != NULL) {
120 precvpriv = &padapter->recvpriv;
121 if (pfree_recv_queue == &precvpriv->free_recv_queue)
122 precvpriv->free_recvframe_cnt--;
125 spin_unlock_irqrestore(&pfree_recv_queue->lock, irqL);
129 union recv_frame *dequeue_recvframe(struct __queue *queue)
131 return r8712_alloc_recvframe(queue);
134 sint enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
137 struct _adapter *padapter = precvframe->u.hdr.adapter;
138 struct recv_priv *precvpriv = &padapter->recvpriv;
140 spin_lock_irqsave(&queue->lock, irqL);
141 list_delete(&(precvframe->u.hdr.list));
142 list_insert_tail(&(precvframe->u.hdr.list), get_list_head(queue));
143 if (padapter != NULL) {
144 if (queue == &precvpriv->free_recv_queue)
145 precvpriv->free_recvframe_cnt++;
147 spin_unlock_irqrestore(&queue->lock, irqL);
152 caller : defrag; recvframe_chk_defrag in recv_thread (passive)
153 pframequeue: defrag_queue : will be accessed in recv_thread (passive)
155 using spin_lock to protect
159 void r8712_free_recvframe_queue(struct __queue *pframequeue,
160 struct __queue *pfree_recv_queue)
162 union recv_frame *precvframe;
163 struct list_head *plist, *phead;
165 spin_lock(&pframequeue->lock);
166 phead = get_list_head(pframequeue);
167 plist = get_next(phead);
168 while (end_of_queue_search(phead, plist) == false) {
169 precvframe = LIST_CONTAINOR(plist, union recv_frame, u);
170 plist = get_next(plist);
171 r8712_free_recvframe(precvframe, pfree_recv_queue);
173 spin_unlock(&pframequeue->lock);
176 sint r8712_recvframe_chkmic(struct _adapter *adapter,
177 union recv_frame *precvframe)
179 sint i, res = _SUCCESS;
183 u8 *pframe, *payload, *pframemic;
184 u8 *mickey, idx, *iv;
185 struct sta_info *stainfo;
186 struct rx_pkt_attrib *prxattrib = &precvframe->u.hdr.attrib;
187 struct security_priv *psecuritypriv = &adapter->securitypriv;
189 stainfo = r8712_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]);
190 if (prxattrib->encrypt == _TKIP_) {
191 /* calculate mic code */
192 if (stainfo != NULL) {
193 if (IS_MCAST(prxattrib->ra)) {
194 iv = precvframe->u.hdr.rx_data +
197 mickey = &psecuritypriv->XGrprxmickey[(((idx >>
198 6) & 0x3)) - 1].skey[0];
199 if (psecuritypriv->binstallGrpkey == false)
202 mickey = &stainfo->tkiprxmickey.skey[0];
203 /*icv_len included the mic code*/
204 datalen = precvframe->u.hdr.len - prxattrib->hdrlen -
205 prxattrib->iv_len - prxattrib->icv_len - 8;
206 pframe = precvframe->u.hdr.rx_data;
207 payload = pframe + prxattrib->hdrlen +
209 seccalctkipmic(mickey, pframe, payload, datalen,
211 (unsigned char)prxattrib->priority);
212 pframemic = payload + datalen;
214 for (i = 0; i < 8; i++) {
215 if (miccode[i] != *(pframemic + i))
218 if (bmic_err == true) {
219 if (prxattrib->bdecrypted == true)
220 r8712_handle_tkip_mic_err(adapter,
221 (u8)IS_MCAST(prxattrib->ra));
225 if ((psecuritypriv->bcheck_grpkey ==
226 false) && (IS_MCAST(prxattrib->ra) ==
228 psecuritypriv->bcheck_grpkey = true;
230 recvframe_pull_tail(precvframe, 8);
236 /* decrypt and set the ivlen,icvlen of the recv_frame */
237 union recv_frame *r8712_decryptor(struct _adapter *padapter,
238 union recv_frame *precv_frame)
240 struct rx_pkt_attrib *prxattrib = &precv_frame->u.hdr.attrib;
241 struct security_priv *psecuritypriv = &padapter->securitypriv;
242 union recv_frame *return_packet = precv_frame;
244 if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0) ||
245 (psecuritypriv->sw_decrypt == true))) {
246 psecuritypriv->hw_decrypted = false;
247 switch (prxattrib->encrypt) {
250 r8712_wep_decrypt(padapter, (u8 *)precv_frame);
253 r8712_tkip_decrypt(padapter, (u8 *)precv_frame);
256 r8712_aes_decrypt(padapter, (u8 *)precv_frame);
261 } else if (prxattrib->bdecrypted == 1)
262 psecuritypriv->hw_decrypted = true;
263 return return_packet;
265 /*###set the security information in the recv_frame */
266 union recv_frame *r8712_portctrl(struct _adapter *adapter,
267 union recv_frame *precv_frame)
271 struct recv_frame_hdr *pfhdr;
272 struct sta_info *psta;
273 struct sta_priv *pstapriv;
274 union recv_frame *prtnframe;
277 pstapriv = &adapter->stapriv;
278 ptr = get_recvframe_data(precv_frame);
279 pfhdr = &precv_frame->u.hdr;
280 psta_addr = pfhdr->attrib.ta;
281 psta = r8712_get_stainfo(pstapriv, psta_addr);
282 auth_alg = adapter->securitypriv.AuthAlgrthm;
284 if ((psta != NULL) && (psta->ieee8021x_blocked)) {
286 * only accept EAPOL frame */
287 prtnframe = precv_frame;
289 ptr = ptr + pfhdr->attrib.hdrlen +
290 pfhdr->attrib.iv_len + LLC_HEADER_SIZE;
291 memcpy(ðer_type, ptr, 2);
292 ether_type = ntohs((unsigned short)ether_type);
293 if (ether_type == 0x888e)
294 prtnframe = precv_frame;
297 r8712_free_recvframe(precv_frame,
298 &adapter->recvpriv.free_recv_queue);
303 * check decryption status, and decrypt the
305 prtnframe = precv_frame;
306 /* check is the EAPOL frame or not (Rekey) */
307 if (ether_type == 0x888e) {
309 prtnframe = precv_frame;
313 prtnframe = precv_frame;
317 sint recv_decache(union recv_frame *precv_frame, u8 bretry,
318 struct stainfo_rxcache *prxcache)
320 sint tid = precv_frame->u.hdr.attrib.priority;
321 u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num&0xffff) << 4) |
322 (precv_frame->u.hdr.attrib.frag_num & 0xf);
326 if (seq_ctrl == prxcache->tid_rxseq[tid])
328 prxcache->tid_rxseq[tid] = seq_ctrl;
332 sint sta2sta_data_frame(struct _adapter *adapter, union recv_frame *precv_frame,
333 struct sta_info **psta
336 u8 *ptr = precv_frame->u.hdr.rx_data;
338 struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
339 struct sta_priv *pstapriv = &adapter->stapriv;
340 struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
341 u8 *mybssid = get_bssid(pmlmepriv);
342 u8 *myhwaddr = myid(&adapter->eeprompriv);
344 sint bmcast = IS_MCAST(pattrib->dst);
346 if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) ||
347 (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) {
348 /* filter packets that SA is myself or multicast or broadcast */
349 if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN))
351 if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast))
353 if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
354 !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
355 (memcmp(pattrib->bssid, mybssid, ETH_ALEN)))
357 sta_addr = pattrib->src;
358 } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
359 /* For Station mode, sa and bssid should always be BSSID,
360 * and DA is my mac-address */
361 if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN))
363 sta_addr = pattrib->bssid;
364 } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
366 /* For AP mode, if DA == MCAST, then BSSID should
368 if (!IS_MCAST(pattrib->bssid))
370 } else { /* not mc-frame */
371 /* For AP mode, if DA is non-MCAST, then it must be
372 * BSSID, and bssid == BSSID */
373 if (memcmp(pattrib->bssid, pattrib->dst, ETH_ALEN))
375 sta_addr = pattrib->src;
377 } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) {
378 memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN);
379 memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN);
380 memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN);
381 memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
382 memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
387 *psta = r8712_get_bcmc_stainfo(adapter);
389 *psta = r8712_get_stainfo(pstapriv, sta_addr); /* get ap_info */
391 if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)
392 adapter->mppriv.rx_pktloss++;
398 sint ap2sta_data_frame(struct _adapter *adapter, union recv_frame *precv_frame,
399 struct sta_info **psta)
401 u8 *ptr = precv_frame->u.hdr.rx_data;
402 struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
403 struct sta_priv *pstapriv = &adapter->stapriv;
404 struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
405 u8 *mybssid = get_bssid(pmlmepriv);
406 u8 *myhwaddr = myid(&adapter->eeprompriv);
407 sint bmcast = IS_MCAST(pattrib->dst);
409 if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)
410 && (check_fwstate(pmlmepriv, _FW_LINKED) == true)) {
411 /* if NULL-frame, drop packet */
412 if ((GetFrameSubType(ptr)) == WIFI_DATA_NULL)
414 /* drop QoS-SubType Data, including QoS NULL,
415 * excluding QoS-Data */
416 if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) ==
417 WIFI_QOS_DATA_TYPE) {
418 if (GetFrameSubType(ptr) & (BIT(4) | BIT(5) | BIT(6)))
422 /* filter packets that SA is myself or multicast or broadcast */
423 if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN))
426 /* da should be for me */
427 if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast))
430 if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
431 !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
432 (memcmp(pattrib->bssid, mybssid, ETH_ALEN)))
435 *psta = r8712_get_bcmc_stainfo(adapter);
437 *psta = r8712_get_stainfo(pstapriv, pattrib->bssid);
440 } else if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) &&
441 (check_fwstate(pmlmepriv, _FW_LINKED) == true)) {
442 memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN);
443 memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN);
444 memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN);
445 memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
446 memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
447 memcpy(pattrib->bssid, mybssid, ETH_ALEN);
448 *psta = r8712_get_stainfo(pstapriv, pattrib->bssid);
456 sint sta2ap_data_frame(struct _adapter *adapter, union recv_frame *precv_frame,
457 struct sta_info **psta)
459 struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
460 struct sta_priv *pstapriv = &adapter->stapriv;
461 struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
462 unsigned char *mybssid = get_bssid(pmlmepriv);
464 if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
465 /* For AP mode, if DA is non-MCAST, then it must be BSSID,
467 * For AP mode, RA=BSSID, TX=STA(SRC_ADDR), A3=DST_ADDR */
468 if (memcmp(pattrib->bssid, mybssid, ETH_ALEN))
470 *psta = r8712_get_stainfo(pstapriv, pattrib->src);
477 sint validate_recv_ctrl_frame(struct _adapter *adapter,
478 union recv_frame *precv_frame)
483 sint validate_recv_mgnt_frame(struct _adapter *adapter,
484 union recv_frame *precv_frame)
490 sint validate_recv_data_frame(struct _adapter *adapter,
491 union recv_frame *precv_frame)
495 u8 *psa, *pda, *pbssid;
496 struct sta_info *psta = NULL;
497 u8 *ptr = precv_frame->u.hdr.rx_data;
498 struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
499 struct security_priv *psecuritypriv = &adapter->securitypriv;
501 bretry = GetRetry(ptr);
504 pbssid = get_hdr_bssid(ptr);
507 memcpy(pattrib->dst, pda, ETH_ALEN);
508 memcpy(pattrib->src, psa, ETH_ALEN);
509 memcpy(pattrib->bssid, pbssid, ETH_ALEN);
510 switch (pattrib->to_fr_ds) {
512 memcpy(pattrib->ra, pda, ETH_ALEN);
513 memcpy(pattrib->ta, psa, ETH_ALEN);
514 res = sta2sta_data_frame(adapter, precv_frame, &psta);
517 memcpy(pattrib->ra, pda, ETH_ALEN);
518 memcpy(pattrib->ta, pbssid, ETH_ALEN);
519 res = ap2sta_data_frame(adapter, precv_frame, &psta);
522 memcpy(pattrib->ra, pbssid, ETH_ALEN);
523 memcpy(pattrib->ta, psa, ETH_ALEN);
524 res = sta2ap_data_frame(adapter, precv_frame, &psta);
527 memcpy(pattrib->ra, GetAddr1Ptr(ptr), ETH_ALEN);
528 memcpy(pattrib->ta, GetAddr2Ptr(ptr), ETH_ALEN);
538 precv_frame->u.hdr.psta = psta;
540 /* parsing QC field */
541 if (pattrib->qos == 1) {
542 pattrib->priority = GetPriority((ptr + 24));
543 pattrib->ack_policy = GetAckpolicy((ptr + 24));
544 pattrib->amsdu = GetAMsdu((ptr + 24));
545 pattrib->hdrlen = pattrib->to_fr_ds == 3 ? 32 : 26;
547 pattrib->priority = 0;
548 pattrib->hdrlen = (pattrib->to_fr_ds == 3) ? 30 : 24;
551 if (pattrib->order)/*HT-CTRL 11n*/
552 pattrib->hdrlen += 4;
553 precv_frame->u.hdr.preorder_ctrl =
554 &psta->recvreorder_ctrl[pattrib->priority];
556 /* decache, drop duplicate recv packets */
557 if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) ==
561 if (pattrib->privacy) {
562 GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt,
563 IS_MCAST(pattrib->ra));
564 SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len,
567 pattrib->encrypt = 0;
568 pattrib->iv_len = pattrib->icv_len = 0;
573 sint r8712_validate_recv_frame(struct _adapter *adapter,
574 union recv_frame *precv_frame)
576 /*shall check frame subtype, to / from ds, da, bssid */
577 /*then call check if rx seq/frag. duplicated.*/
581 sint retval = _SUCCESS;
582 struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
584 u8 *ptr = precv_frame->u.hdr.rx_data;
585 u8 ver = (unsigned char)(*ptr) & 0x3;
590 type = GetFrameType(ptr);
591 subtype = GetFrameSubType(ptr); /*bit(7)~bit(2)*/
592 pattrib->to_fr_ds = get_tofr_ds(ptr);
593 pattrib->frag_num = GetFragNum(ptr);
594 pattrib->seq_num = GetSequence(ptr);
595 pattrib->pw_save = GetPwrMgt(ptr);
596 pattrib->mfrag = GetMFrag(ptr);
597 pattrib->mdata = GetMData(ptr);
598 pattrib->privacy = GetPrivacy(ptr);
599 pattrib->order = GetOrder(ptr);
601 case WIFI_MGT_TYPE: /*mgnt*/
602 retval = validate_recv_mgnt_frame(adapter, precv_frame);
604 case WIFI_CTRL_TYPE:/*ctrl*/
605 retval = validate_recv_ctrl_frame(adapter, precv_frame);
607 case WIFI_DATA_TYPE: /*data*/
608 pattrib->qos = (subtype & BIT(7)) ? 1 : 0;
609 retval = validate_recv_data_frame(adapter, precv_frame);
617 sint r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe)
619 /*remove the wlanhdr and add the eth_hdr*/
624 struct ieee80211_snap_hdr *psnap;
627 struct _adapter *adapter = precvframe->u.hdr.adapter;
628 struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
630 u8 *ptr = get_recvframe_data(precvframe); /*point to frame_ctrl field*/
631 struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib;
633 if (pattrib->encrypt)
634 recvframe_pull_tail(precvframe, pattrib->icv_len);
635 psnap = (struct ieee80211_snap_hdr *)(ptr + pattrib->hdrlen +
637 psnap_type = ptr + pattrib->hdrlen + pattrib->iv_len + SNAP_SIZE;
638 /* convert hdr + possible LLC headers into Ethernet header */
639 if ((!memcmp(psnap, (void *)rfc1042_header, SNAP_SIZE) &&
640 (memcmp(psnap_type, (void *)SNAP_ETH_TYPE_IPX, 2)) &&
641 (memcmp(psnap_type, (void *)SNAP_ETH_TYPE_APPLETALK_AARP, 2))) ||
642 !memcmp(psnap, (void *)bridge_tunnel_header, SNAP_SIZE)) {
643 /* remove RFC1042 or Bridge-Tunnel encapsulation and
644 * replace EtherType */
647 /* Leave Ethernet header part of hdr and full payload */
650 rmv_len = pattrib->hdrlen + pattrib->iv_len +
651 (bsnaphdr ? SNAP_SIZE : 0);
652 len = precvframe->u.hdr.len - rmv_len;
653 if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)) {
658 /* append rx status for mp test packets */
659 ptr = recvframe_pull(precvframe, (rmv_len -
660 sizeof(struct ethhdr) + 2) - 24);
661 memcpy(ptr, get_rxmem(precvframe), 24);
664 ptr = recvframe_pull(precvframe, (rmv_len -
665 sizeof(struct ethhdr) + (bsnaphdr ? 2 : 0)));
667 memcpy(ptr, pattrib->dst, ETH_ALEN);
668 memcpy(ptr+ETH_ALEN, pattrib->src, ETH_ALEN);
671 memcpy(ptr + 12, &len, 2);
676 s32 r8712_recv_entry(union recv_frame *precvframe)
678 struct _adapter *padapter;
679 struct recv_priv *precvpriv;
680 struct mlme_priv *pmlmepriv;
681 struct recv_stat *prxstat;
682 struct dvobj_priv *pdev;
683 u8 *phead, *pdata, *ptail, *pend;
685 struct __queue *pfree_recv_queue, *ppending_recv_queue;
687 struct intf_hdl *pintfhdl;
689 padapter = precvframe->u.hdr.adapter;
690 pintfhdl = &padapter->pio_queue->intf;
691 pmlmepriv = &padapter->mlmepriv;
692 precvpriv = &(padapter->recvpriv);
693 pdev = &padapter->dvobjpriv;
694 pfree_recv_queue = &(precvpriv->free_recv_queue);
695 ppending_recv_queue = &(precvpriv->recv_pending_queue);
696 phead = precvframe->u.hdr.rx_head;
697 pdata = precvframe->u.hdr.rx_data;
698 ptail = precvframe->u.hdr.rx_tail;
699 pend = precvframe->u.hdr.rx_end;
700 prxstat = (struct recv_stat *)phead;
702 padapter->ledpriv.LedControlHandler(padapter, LED_CTL_RX);
704 ret = recv_func(padapter, precvframe);
706 goto _recv_entry_drop;
707 precvpriv->rx_pkts++;
708 precvpriv->rx_bytes += (uint)(precvframe->u.hdr.rx_tail -
709 precvframe->u.hdr.rx_data);
712 precvpriv->rx_drop++;
713 padapter->mppriv.rx_pktloss = precvpriv->rx_drop;