Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rtl8712_recv.c
Go to the documentation of this file.
1 /******************************************************************************
2  * rtl8712_recv.c
3  *
4  * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
5  * Linux device driver for RTL8192SU
6  *
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.
10  *
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
14  * more details.
15  *
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
19  *
20  * Modifications for inclusion into the Linux staging tree are
21  * Copyright(c) 2010 Larry Finger. All rights reserved.
22  *
23  * Contact information:
24  * WLAN FAE <[email protected]>
25  * Larry Finger <[email protected]>
26  *
27  ******************************************************************************/
28 
29 #define _RTL8712_RECV_C_
30 
31 #include <linux/if_ether.h>
32 #include <linux/ip.h>
33 
34 #include "osdep_service.h"
35 #include "drv_types.h"
36 #include "recv_osdep.h"
37 #include "mlme_osdep.h"
38 #include "ethernet.h"
39 #include "usb_ops.h"
40 #include "wifi.h"
41 
42 /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
43 static u8 bridge_tunnel_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8};
44 
45 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
46 static u8 rfc1042_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
47 
48 static void recv_tasklet(void *priv);
49 
50 int r8712_init_recv_priv(struct recv_priv *precvpriv, struct _adapter *padapter)
51 {
52  int i;
53  struct recv_buf *precvbuf;
54  int res = _SUCCESS;
55  addr_t tmpaddr = 0;
56  int alignment = 0;
57  struct sk_buff *pskb = NULL;
58 
59  /*init recv_buf*/
60  _init_queue(&precvpriv->free_recv_buf_queue);
61  precvpriv->pallocated_recv_buf = _malloc(NR_RECVBUFF *
62  sizeof(struct recv_buf) + 4);
63  if (precvpriv->pallocated_recv_buf == NULL)
64  return _FAIL;
65  memset(precvpriv->pallocated_recv_buf, 0, NR_RECVBUFF *
66  sizeof(struct recv_buf) + 4);
67  precvpriv->precv_buf = precvpriv->pallocated_recv_buf + 4 -
68  ((addr_t) (precvpriv->pallocated_recv_buf) & 3);
69  precvbuf = (struct recv_buf *)precvpriv->precv_buf;
70  for (i = 0; i < NR_RECVBUFF; i++) {
71  _init_listhead(&precvbuf->list);
72  spin_lock_init(&precvbuf->recvbuf_lock);
73  res = r8712_os_recvbuf_resource_alloc(padapter, precvbuf);
74  if (res == _FAIL)
75  break;
76  precvbuf->ref_cnt = 0;
77  precvbuf->adapter = padapter;
78  list_insert_tail(&precvbuf->list,
79  &(precvpriv->free_recv_buf_queue.queue));
80  precvbuf++;
81  }
83  tasklet_init(&precvpriv->recv_tasklet,
84  (void(*)(unsigned long))recv_tasklet,
85  (unsigned long)padapter);
86  skb_queue_head_init(&precvpriv->rx_skb_queue);
87 
88  skb_queue_head_init(&precvpriv->free_recv_skb_queue);
89  for (i = 0; i < NR_PREALLOC_RECV_SKB; i++) {
90  pskb = netdev_alloc_skb(padapter->pnetdev, MAX_RECVBUF_SZ +
92  if (pskb) {
93  pskb->dev = padapter->pnetdev;
94  tmpaddr = (addr_t)pskb->data;
95  alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1);
96  skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment));
97  skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb);
98  }
99  pskb = NULL;
100  }
101  return res;
102 }
103 
104 void r8712_free_recv_priv(struct recv_priv *precvpriv)
105 {
106  int i;
107  struct recv_buf *precvbuf;
108  struct _adapter *padapter = precvpriv->adapter;
109 
110  precvbuf = (struct recv_buf *)precvpriv->precv_buf;
111  for (i = 0; i < NR_RECVBUFF ; i++) {
112  r8712_os_recvbuf_resource_free(padapter, precvbuf);
113  precvbuf++;
114  }
115  kfree(precvpriv->pallocated_recv_buf);
116  skb_queue_purge(&precvpriv->rx_skb_queue);
117  if (skb_queue_len(&precvpriv->rx_skb_queue))
118  printk(KERN_WARNING "r8712u: rx_skb_queue not empty\n");
120  if (skb_queue_len(&precvpriv->free_recv_skb_queue))
121  printk(KERN_WARNING "r8712u: free_recv_skb_queue not empty "
122  "%d\n", skb_queue_len(&precvpriv->free_recv_skb_queue));
123 }
124 
125 int r8712_init_recvbuf(struct _adapter *padapter, struct recv_buf *precvbuf)
126 {
127  int res = _SUCCESS;
128 
129  precvbuf->transfer_len = 0;
130  precvbuf->len = 0;
131  precvbuf->ref_cnt = 0;
132  if (precvbuf->pbuf) {
133  precvbuf->pdata = precvbuf->pbuf;
134  precvbuf->phead = precvbuf->pbuf;
135  precvbuf->ptail = precvbuf->pbuf;
136  precvbuf->pend = precvbuf->pdata + MAX_RECVBUF_SZ;
137  }
138  return res;
139 }
140 
141 int r8712_free_recvframe(union recv_frame *precvframe,
142  struct __queue *pfree_recv_queue)
143 {
144  unsigned long irqL;
145  struct _adapter *padapter = precvframe->u.hdr.adapter;
146  struct recv_priv *precvpriv = &padapter->recvpriv;
147 
148  if (precvframe->u.hdr.pkt) {
149  dev_kfree_skb_any(precvframe->u.hdr.pkt);/*free skb by driver*/
150  precvframe->u.hdr.pkt = NULL;
151  }
152  spin_lock_irqsave(&pfree_recv_queue->lock, irqL);
153  list_delete(&(precvframe->u.hdr.list));
154  list_insert_tail(&(precvframe->u.hdr.list),
155  get_list_head(pfree_recv_queue));
156  if (padapter != NULL) {
157  if (pfree_recv_queue == &precvpriv->free_recv_queue)
158  precvpriv->free_recvframe_cnt++;
159  }
160  spin_unlock_irqrestore(&pfree_recv_queue->lock, irqL);
161  return _SUCCESS;
162 }
163 
164 static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib,
165  struct recv_stat *prxstat)
166 {
167  u32 *pphy_info;
168  struct phy_stat *pphy_stat;
169  u16 drvinfo_sz = 0;
170 
171  drvinfo_sz = (le32_to_cpu(prxstat->rxdw0)&0x000f0000)>>16;
172  drvinfo_sz = drvinfo_sz<<3;
173  /*TODO:
174  * Offset 0 */
175  pattrib->bdecrypted = ((le32_to_cpu(prxstat->rxdw0) & BIT(27)) >> 27)
176  ? 0 : 1;
177  pattrib->crc_err = ((le32_to_cpu(prxstat->rxdw0) & BIT(14)) >> 14);
178  /*Offset 4*/
179  /*Offset 8*/
180  /*Offset 12*/
181  if (le32_to_cpu(prxstat->rxdw3) & BIT(13)) {
182  pattrib->tcpchk_valid = 1; /* valid */
183  if (le32_to_cpu(prxstat->rxdw3) & BIT(11))
184  pattrib->tcp_chkrpt = 1; /* correct */
185  else
186  pattrib->tcp_chkrpt = 0; /* incorrect */
187  if (le32_to_cpu(prxstat->rxdw3) & BIT(12))
188  pattrib->ip_chkrpt = 1; /* correct */
189  else
190  pattrib->ip_chkrpt = 0; /* incorrect */
191  } else
192  pattrib->tcpchk_valid = 0; /* invalid */
193  pattrib->mcs_rate = (u8)((le32_to_cpu(prxstat->rxdw3)) & 0x3f);
194  pattrib->htc = (u8)((le32_to_cpu(prxstat->rxdw3) >> 14) & 0x1);
195  /*Offset 16*/
196  /*Offset 20*/
197  /*phy_info*/
198  if (drvinfo_sz) {
199  pphy_stat = (struct phy_stat *)(prxstat+1);
200  pphy_info = (u32 *)prxstat+1;
201  }
202 }
203 
204 /*perform defrag*/
205 static union recv_frame *recvframe_defrag(struct _adapter *adapter,
206  struct __queue *defrag_q)
207 {
208  struct list_head *plist, *phead;
209  u8 *data, wlanhdr_offset;
210  u8 curfragnum;
211  struct recv_frame_hdr *pfhdr, *pnfhdr;
212  union recv_frame *prframe, *pnextrframe;
213  struct __queue *pfree_recv_queue;
214 
215  pfree_recv_queue = &adapter->recvpriv.free_recv_queue;
216  phead = get_list_head(defrag_q);
217  plist = get_next(phead);
218  prframe = LIST_CONTAINOR(plist, union recv_frame, u);
219  list_delete(&prframe->u.list);
220  pfhdr = &prframe->u.hdr;
221  curfragnum = 0;
222  if (curfragnum != pfhdr->attrib.frag_num) {
223  /*the first fragment number must be 0
224  *free the whole queue*/
225  r8712_free_recvframe(prframe, pfree_recv_queue);
226  r8712_free_recvframe_queue(defrag_q, pfree_recv_queue);
227  return NULL;
228  }
229  curfragnum++;
230  plist = get_list_head(defrag_q);
231  plist = get_next(plist);
232  data = get_recvframe_data(prframe);
233  while (end_of_queue_search(phead, plist) == false) {
234  pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u);
235  pnfhdr = &pnextrframe->u.hdr;
236  /*check the fragment sequence (2nd ~n fragment frame) */
237  if (curfragnum != pnfhdr->attrib.frag_num) {
238  /* the fragment number must increase (after decache)
239  * release the defrag_q & prframe */
240  r8712_free_recvframe(prframe, pfree_recv_queue);
241  r8712_free_recvframe_queue(defrag_q, pfree_recv_queue);
242  return NULL;
243  }
244  curfragnum++;
245  /* copy the 2nd~n fragment frame's payload to the first fragment
246  * get the 2nd~last fragment frame's payload */
247  wlanhdr_offset = pnfhdr->attrib.hdrlen + pnfhdr->attrib.iv_len;
248  recvframe_pull(pnextrframe, wlanhdr_offset);
249  /* append to first fragment frame's tail (if privacy frame,
250  * pull the ICV) */
251  recvframe_pull_tail(prframe, pfhdr->attrib.icv_len);
252  memcpy(pfhdr->rx_tail, pnfhdr->rx_data, pnfhdr->len);
253  recvframe_put(prframe, pnfhdr->len);
254  pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len;
255  plist = get_next(plist);
256  }
257  /* free the defrag_q queue and return the prframe */
258  r8712_free_recvframe_queue(defrag_q, pfree_recv_queue);
259  return prframe;
260 }
261 
262 /* check if need to defrag, if needed queue the frame to defrag_q */
264  union recv_frame *precv_frame)
265 {
266  u8 ismfrag;
267  u8 fragnum;
268  u8 *psta_addr;
269  struct recv_frame_hdr *pfhdr;
270  struct sta_info *psta;
271  struct sta_priv *pstapriv ;
272  struct list_head *phead;
273  union recv_frame *prtnframe = NULL;
274  struct __queue *pfree_recv_queue, *pdefrag_q;
275 
276  pstapriv = &padapter->stapriv;
277  pfhdr = &precv_frame->u.hdr;
278  pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
279  /* need to define struct of wlan header frame ctrl */
280  ismfrag = pfhdr->attrib.mfrag;
281  fragnum = pfhdr->attrib.frag_num;
282  psta_addr = pfhdr->attrib.ta;
283  psta = r8712_get_stainfo(pstapriv, psta_addr);
284  if (psta == NULL)
285  pdefrag_q = NULL;
286  else
287  pdefrag_q = &psta->sta_recvpriv.defrag_q;
288 
289  if ((ismfrag == 0) && (fragnum == 0))
290  prtnframe = precv_frame;/*isn't a fragment frame*/
291  if (ismfrag == 1) {
292  /* 0~(n-1) fragment frame
293  * enqueue to defraf_g */
294  if (pdefrag_q != NULL) {
295  if (fragnum == 0) {
296  /*the first fragment*/
297  if (_queue_empty(pdefrag_q) == false) {
298  /*free current defrag_q */
299  r8712_free_recvframe_queue(pdefrag_q,
300  pfree_recv_queue);
301  }
302  }
303  /* Then enqueue the 0~(n-1) fragment to the defrag_q */
304  phead = get_list_head(pdefrag_q);
305  list_insert_tail(&pfhdr->list, phead);
306  prtnframe = NULL;
307  } else {
308  /* can't find this ta's defrag_queue, so free this
309  * recv_frame */
310  r8712_free_recvframe(precv_frame, pfree_recv_queue);
311  prtnframe = NULL;
312  }
313 
314  }
315  if ((ismfrag == 0) && (fragnum != 0)) {
316  /* the last fragment frame
317  * enqueue the last fragment */
318  if (pdefrag_q != NULL) {
319  phead = get_list_head(pdefrag_q);
320  list_insert_tail(&pfhdr->list, phead);
321  /*call recvframe_defrag to defrag*/
322  precv_frame = recvframe_defrag(padapter, pdefrag_q);
323  prtnframe = precv_frame;
324  } else {
325  /* can't find this ta's defrag_queue, so free this
326  * recv_frame */
327  r8712_free_recvframe(precv_frame, pfree_recv_queue);
328  prtnframe = NULL;
329  }
330  }
331  if ((prtnframe != NULL) && (prtnframe->u.hdr.attrib.privacy)) {
332  /* after defrag we must check tkip mic code */
333  if (r8712_recvframe_chkmic(padapter, prtnframe) == _FAIL) {
334  r8712_free_recvframe(prtnframe, pfree_recv_queue);
335  prtnframe = NULL;
336  }
337  }
338  return prtnframe;
339 }
340 
341 static int amsdu_to_msdu(struct _adapter *padapter, union recv_frame *prframe)
342 {
343  int a_len, padding_len;
344  u16 eth_type, nSubframe_Length;
345  u8 nr_subframes, i;
346  unsigned char *data_ptr, *pdata;
347  struct rx_pkt_attrib *pattrib;
348  _pkt *sub_skb, *subframes[MAX_SUBFRAME_COUNT];
349  struct recv_priv *precvpriv = &padapter->recvpriv;
350  struct __queue *pfree_recv_queue = &(precvpriv->free_recv_queue);
351  int ret = _SUCCESS;
352 
353  nr_subframes = 0;
354  pattrib = &prframe->u.hdr.attrib;
355  recvframe_pull(prframe, prframe->u.hdr.attrib.hdrlen);
356  if (prframe->u.hdr.attrib.iv_len > 0)
357  recvframe_pull(prframe, prframe->u.hdr.attrib.iv_len);
358  a_len = prframe->u.hdr.len;
359  pdata = prframe->u.hdr.rx_data;
360  while (a_len > ETH_HLEN) {
361  /* Offset 12 denote 2 mac address */
362  nSubframe_Length = *((u16 *)(pdata + 12));
363  /*==m==>change the length order*/
364  nSubframe_Length = (nSubframe_Length >> 8) +
365  (nSubframe_Length << 8);
366  if (a_len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) {
367  printk(KERN_WARNING "r8712u: nRemain_Length is %d and"
368  " nSubframe_Length is: %d\n",
369  a_len, nSubframe_Length);
370  goto exit;
371  }
372  /* move the data point to data content */
373  pdata += ETH_HLEN;
374  a_len -= ETH_HLEN;
375  /* Allocate new skb for releasing to upper layer */
376  sub_skb = dev_alloc_skb(nSubframe_Length + 12);
377  if (!sub_skb)
378  break;
379  skb_reserve(sub_skb, 12);
380  data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length);
381  memcpy(data_ptr, pdata, nSubframe_Length);
382  subframes[nr_subframes++] = sub_skb;
383  if (nr_subframes >= MAX_SUBFRAME_COUNT) {
384  printk(KERN_WARNING "r8712u: ParseSubframe(): Too"
385  " many Subframes! Packets dropped!\n");
386  break;
387  }
388  pdata += nSubframe_Length;
389  a_len -= nSubframe_Length;
390  if (a_len != 0) {
391  padding_len = 4 - ((nSubframe_Length + ETH_HLEN) & 3);
392  if (padding_len == 4)
393  padding_len = 0;
394  if (a_len < padding_len)
395  goto exit;
396  pdata += padding_len;
397  a_len -= padding_len;
398  }
399  }
400  for (i = 0; i < nr_subframes; i++) {
401  sub_skb = subframes[i];
402  /* convert hdr + possible LLC headers into Ethernet header */
403  eth_type = (sub_skb->data[6] << 8) | sub_skb->data[7];
404  if (sub_skb->len >= 8 &&
405  ((!memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) &&
406  eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) ||
407  !memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE))) {
408  /* remove RFC1042 or Bridge-Tunnel encapsulation and
409  * replace EtherType */
410  skb_pull(sub_skb, SNAP_SIZE);
411  memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src,
412  ETH_ALEN);
413  memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst,
414  ETH_ALEN);
415  } else {
416  u16 len;
417  /* Leave Ethernet header part of hdr and full payload */
418  len = htons(sub_skb->len);
419  memcpy(skb_push(sub_skb, 2), &len, 2);
420  memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src,
421  ETH_ALEN);
422  memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst,
423  ETH_ALEN);
424  }
425  /* Indicate the packets to upper layer */
426  if (sub_skb) {
427  sub_skb->protocol =
428  eth_type_trans(sub_skb, padapter->pnetdev);
429  sub_skb->dev = padapter->pnetdev;
430  if ((pattrib->tcpchk_valid == 1) &&
431  (pattrib->tcp_chkrpt == 1)) {
432  sub_skb->ip_summed = CHECKSUM_UNNECESSARY;
433  } else
434  sub_skb->ip_summed = CHECKSUM_NONE;
435  netif_rx(sub_skb);
436  }
437  }
438 exit:
439  prframe->u.hdr.len = 0;
440  r8712_free_recvframe(prframe, pfree_recv_queue);
441  return ret;
442 }
443 
444 void r8712_rxcmd_event_hdl(struct _adapter *padapter, void *prxcmdbuf)
445 {
446  uint voffset;
447  u8 *poffset;
448  u16 pkt_len, cmd_len, drvinfo_sz;
449  u8 eid, cmd_seq;
450  struct recv_stat *prxstat;
451 
452  poffset = (u8 *)prxcmdbuf;
453  voffset = *(uint *)poffset;
454  pkt_len = le32_to_cpu(voffset) & 0x00003fff;
455  prxstat = (struct recv_stat *)prxcmdbuf;
456  drvinfo_sz = ((le32_to_cpu(prxstat->rxdw0) & 0x000f0000) >> 16);
457  drvinfo_sz = drvinfo_sz << 3;
458  poffset += RXDESC_SIZE + drvinfo_sz;
459  do {
460  voffset = *(uint *)poffset;
461  cmd_len = (u16)(le32_to_cpu(voffset) & 0xffff);
462  cmd_seq = (u8)((le32_to_cpu(voffset) >> 24) & 0x7f);
463  eid = (u8)((le32_to_cpu(voffset) >> 16) & 0xff);
464  r8712_event_handle(padapter, (uint *)poffset);
465  poffset += (cmd_len + 8);/*8 bytes alignment*/
466  } while (le32_to_cpu(voffset) & BIT(31));
467 
468 }
469 
470 static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl,
471  u16 seq_num)
472 {
473  u8 wsize = preorder_ctrl->wsize_b;
474  u16 wend = (preorder_ctrl->indicate_seq + wsize - 1) % 4096;
475 
476  /* Rx Reorder initialize condition.*/
477  if (preorder_ctrl->indicate_seq == 0xffff)
478  preorder_ctrl->indicate_seq = seq_num;
479  /* Drop out the packet which SeqNum is smaller than WinStart */
480  if (SN_LESS(seq_num, preorder_ctrl->indicate_seq))
481  return false;
482  /*
483  * Sliding window manipulation. Conditions includes:
484  * 1. Incoming SeqNum is equal to WinStart =>Window shift 1
485  * 2. Incoming SeqNum is larger than the WinEnd => Window shift N
486  */
487  if (SN_EQUAL(seq_num, preorder_ctrl->indicate_seq))
488  preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq +
489  1) % 4096;
490  else if (SN_LESS(wend, seq_num)) {
491  if (seq_num >= (wsize - 1))
492  preorder_ctrl->indicate_seq = seq_num + 1 - wsize;
493  else
494  preorder_ctrl->indicate_seq = 4095 - (wsize -
495  (seq_num + 1)) + 1;
496  }
497  return true;
498 }
499 
500 static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl,
501  union recv_frame *prframe)
502 {
503  struct list_head *phead, *plist;
504  union recv_frame *pnextrframe;
505  struct rx_pkt_attrib *pnextattrib;
506  struct __queue *ppending_recvframe_queue =
507  &preorder_ctrl->pending_recvframe_queue;
508  struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;
509 
510  phead = get_list_head(ppending_recvframe_queue);
511  plist = get_next(phead);
512  while (end_of_queue_search(phead, plist) == false) {
513  pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u);
514  pnextattrib = &pnextrframe->u.hdr.attrib;
515  if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
516  plist = get_next(plist);
517  else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num))
518  return false;
519  else
520  break;
521  }
522  list_delete(&(prframe->u.hdr.list));
523  list_insert_tail(&(prframe->u.hdr.list), plist);
524  return true;
525 }
526 
528  struct recv_reorder_ctrl *preorder_ctrl,
529  int bforced)
530 {
531  struct list_head *phead, *plist;
532  union recv_frame *prframe;
533  struct rx_pkt_attrib *pattrib;
534  int bPktInBuf = false;
535  struct recv_priv *precvpriv = &padapter->recvpriv;
536  struct __queue *ppending_recvframe_queue =
537  &preorder_ctrl->pending_recvframe_queue;
538 
539  phead = get_list_head(ppending_recvframe_queue);
540  plist = get_next(phead);
541  /* Handling some condition for forced indicate case.*/
542  if (bforced == true) {
543  if (is_list_empty(phead))
544  return true;
545  else {
546  prframe = LIST_CONTAINOR(plist, union recv_frame, u);
547  pattrib = &prframe->u.hdr.attrib;
548  preorder_ctrl->indicate_seq = pattrib->seq_num;
549  }
550  }
551  /* Prepare indication list and indication.
552  * Check if there is any packet need indicate. */
553  while (!is_list_empty(phead)) {
554  prframe = LIST_CONTAINOR(plist, union recv_frame, u);
555  pattrib = &prframe->u.hdr.attrib;
556  if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) {
557  plist = get_next(plist);
558  list_delete(&(prframe->u.hdr.list));
559  if (SN_EQUAL(preorder_ctrl->indicate_seq,
560  pattrib->seq_num))
561  preorder_ctrl->indicate_seq =
562  (preorder_ctrl->indicate_seq + 1) % 4096;
563  /*indicate this recv_frame*/
564  if (!pattrib->amsdu) {
565  if ((padapter->bDriverStopped == false) &&
566  (padapter->bSurpriseRemoved == false)) {
567  /* indicate this recv_frame */
568  r8712_recv_indicatepkt(padapter,
569  prframe);
570  }
571  } else if (pattrib->amsdu == 1) {
572  if (amsdu_to_msdu(padapter, prframe) !=
573  _SUCCESS)
574  r8712_free_recvframe(prframe,
575  &precvpriv->free_recv_queue);
576  }
577  /* Update local variables. */
578  bPktInBuf = false;
579  } else {
580  bPktInBuf = true;
581  break;
582  }
583  }
584  return bPktInBuf;
585 }
586 
587 static int recv_indicatepkt_reorder(struct _adapter *padapter,
588  union recv_frame *prframe)
589 {
590  unsigned long irql;
591  struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;
592  struct recv_reorder_ctrl *preorder_ctrl = prframe->u.hdr.preorder_ctrl;
593  struct __queue *ppending_recvframe_queue =
594  &preorder_ctrl->pending_recvframe_queue;
595 
596  if (!pattrib->amsdu) {
597  /* s1. */
598  r8712_wlanhdr_to_ethhdr(prframe);
599  if (pattrib->qos != 1) {
600  if ((padapter->bDriverStopped == false) &&
601  (padapter->bSurpriseRemoved == false)) {
602  r8712_recv_indicatepkt(padapter, prframe);
603  return _SUCCESS;
604  } else
605  return _FAIL;
606  }
607  }
608  spin_lock_irqsave(&ppending_recvframe_queue->lock, irql);
609  /*s2. check if winstart_b(indicate_seq) needs to be updated*/
610  if (!check_indicate_seq(preorder_ctrl, pattrib->seq_num))
611  goto _err_exit;
612  /*s3. Insert all packet into Reorder Queue to maintain its ordering.*/
613  if (!enqueue_reorder_recvframe(preorder_ctrl, prframe))
614  goto _err_exit;
615  /*s4.
616  * Indication process.
617  * After Packet dropping and Sliding Window shifting as above, we can
618  * now just indicate the packets with the SeqNum smaller than latest
619  * WinStart and buffer other packets.
620  *
621  * For Rx Reorder condition:
622  * 1. All packets with SeqNum smaller than WinStart => Indicate
623  * 2. All packets with SeqNum larger than or equal to
624  * WinStart => Buffer it.
625  */
626  if (r8712_recv_indicatepkts_in_order(padapter, preorder_ctrl, false) ==
627  true) {
628  _set_timer(&preorder_ctrl->reordering_ctrl_timer,
630  spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql);
631  } else {
632  spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql);
633  _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer);
634  }
635  return _SUCCESS;
636 _err_exit:
637  spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql);
638  return _FAIL;
639 }
640 
642 {
643  unsigned long irql;
644  struct recv_reorder_ctrl *preorder_ctrl =
645  (struct recv_reorder_ctrl *)pcontext;
646  struct _adapter *padapter = preorder_ctrl->padapter;
647  struct __queue *ppending_recvframe_queue =
648  &preorder_ctrl->pending_recvframe_queue;
649 
650  if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
651  return;
652  spin_lock_irqsave(&ppending_recvframe_queue->lock, irql);
653  r8712_recv_indicatepkts_in_order(padapter, preorder_ctrl, true);
654  spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql);
655 }
656 
657 static int r8712_process_recv_indicatepkts(struct _adapter *padapter,
658  union recv_frame *prframe)
659 {
660  int retval = _SUCCESS;
661  struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
662  struct ht_priv *phtpriv = &pmlmepriv->htpriv;
663 
664  if (phtpriv->ht_option == 1) { /*B/G/N Mode*/
665  if (recv_indicatepkt_reorder(padapter, prframe) != _SUCCESS) {
666  /* including perform A-MPDU Rx Ordering Buffer Control*/
667  if ((padapter->bDriverStopped == false) &&
668  (padapter->bSurpriseRemoved == false))
669  return _FAIL;
670  }
671  } else { /*B/G mode*/
672  retval = r8712_wlanhdr_to_ethhdr(prframe);
673  if (retval != _SUCCESS)
674  return retval;
675  if ((padapter->bDriverStopped == false) &&
676  (padapter->bSurpriseRemoved == false)) {
677  /* indicate this recv_frame */
678  r8712_recv_indicatepkt(padapter, prframe);
679  } else
680  return _FAIL;
681  }
682  return retval;
683 }
684 
685 static u8 query_rx_pwr_percentage(s8 antpower)
686 {
687  if ((antpower <= -100) || (antpower >= 20))
688  return 0;
689  else if (antpower >= 0)
690  return 100;
691  else
692  return 100 + antpower;
693 }
694 
695 static u8 evm_db2percentage(s8 value)
696 {
697  /*
698  * -33dB~0dB to 0%~99%
699  */
700  s8 ret_val;
701 
702  ret_val = value;
703  if (ret_val >= 0)
704  ret_val = 0;
705  if (ret_val <= -33)
706  ret_val = -33;
707  ret_val = -ret_val;
708  ret_val *= 3;
709  if (ret_val == 99)
710  ret_val = 100;
711  return ret_val;
712 }
713 
715 {
716  s32 ret_sig;
717 
718  if (cur_sig >= 51 && cur_sig <= 100)
719  ret_sig = 100;
720  else if (cur_sig >= 41 && cur_sig <= 50)
721  ret_sig = 80 + ((cur_sig - 40) * 2);
722  else if (cur_sig >= 31 && cur_sig <= 40)
723  ret_sig = 66 + (cur_sig - 30);
724  else if (cur_sig >= 21 && cur_sig <= 30)
725  ret_sig = 54 + (cur_sig - 20);
726  else if (cur_sig >= 10 && cur_sig <= 20)
727  ret_sig = 42 + (((cur_sig - 10) * 2) / 3);
728  else if (cur_sig >= 5 && cur_sig <= 9)
729  ret_sig = 22 + (((cur_sig - 5) * 3) / 2);
730  else if (cur_sig >= 1 && cur_sig <= 4)
731  ret_sig = 6 + (((cur_sig - 1) * 3) / 2);
732  else
733  ret_sig = cur_sig;
734  return ret_sig;
735 }
736 
737 static s32 translate2dbm(struct _adapter *padapter, u8 signal_strength_idx)
738 {
739  s32 signal_power; /* in dBm.*/
740  /* Translate to dBm (x=0.5y-95).*/
741  signal_power = (s32)((signal_strength_idx + 1) >> 1);
742  signal_power -= 95;
743  return signal_power;
744 }
745 
746 static void query_rx_phy_status(struct _adapter *padapter,
747  union recv_frame *prframe)
748 {
749  u8 i, max_spatial_stream, evm;
750  struct recv_stat *prxstat = (struct recv_stat *)prframe->u.hdr.rx_head;
751  struct phy_stat *pphy_stat = (struct phy_stat *)(prxstat + 1);
752  u8 *pphy_head = (u8 *)(prxstat + 1);
753  s8 rx_pwr[4], rx_pwr_all;
754  u8 pwdb_all;
755  u32 rssi, total_rssi = 0;
756  u8 bcck_rate = 0, rf_rx_num = 0, cck_highpwr = 0;
757  struct phy_cck_rx_status *pcck_buf;
758  u8 sq;
759 
760  /* Record it for next packet processing*/
761  bcck_rate = (prframe->u.hdr.attrib.mcs_rate <= 3 ? 1 : 0);
762  if (bcck_rate) {
763  u8 report;
764 
765  /* CCK Driver info Structure is not the same as OFDM packet.*/
766  pcck_buf = (struct phy_cck_rx_status *)pphy_stat;
767  /* (1)Hardware does not provide RSSI for CCK
768  * (2)PWDB, Average PWDB cacluated by hardware
769  * (for rate adaptive)
770  */
771  if (!cck_highpwr) {
772  report = pcck_buf->cck_agc_rpt & 0xc0;
773  report = report >> 6;
774  switch (report) {
775  /* Modify the RF RNA gain value to -40, -20,
776  * -2, 14 by Jenyu's suggestion
777  * Note: different RF with the different
778  * RNA gain. */
779  case 0x3:
780  rx_pwr_all = -40 - (pcck_buf->cck_agc_rpt &
781  0x3e);
782  break;
783  case 0x2:
784  rx_pwr_all = -20 - (pcck_buf->cck_agc_rpt &
785  0x3e);
786  break;
787  case 0x1:
788  rx_pwr_all = -2 - (pcck_buf->cck_agc_rpt &
789  0x3e);
790  break;
791  case 0x0:
792  rx_pwr_all = 14 - (pcck_buf->cck_agc_rpt &
793  0x3e);
794  break;
795  }
796  } else {
797  report = ((u8)(le32_to_cpu(pphy_stat->phydw1) >> 8)) &
798  0x60;
799  report = report >> 5;
800  switch (report) {
801  case 0x3:
802  rx_pwr_all = -40 - ((pcck_buf->cck_agc_rpt &
803  0x1f) << 1);
804  break;
805  case 0x2:
806  rx_pwr_all = -20 - ((pcck_buf->cck_agc_rpt &
807  0x1f) << 1);
808  break;
809  case 0x1:
810  rx_pwr_all = -2 - ((pcck_buf->cck_agc_rpt &
811  0x1f) << 1);
812  break;
813  case 0x0:
814  rx_pwr_all = 14 - ((pcck_buf->cck_agc_rpt &
815  0x1f) << 1);
816  break;
817  }
818  }
819  pwdb_all = query_rx_pwr_percentage(rx_pwr_all);
820  /* CCK gain is smaller than OFDM/MCS gain,*/
821  /* so we add gain diff by experiences, the val is 6 */
822  pwdb_all += 6;
823  if (pwdb_all > 100)
824  pwdb_all = 100;
825  /* modify the offset to make the same gain index with OFDM.*/
826  if (pwdb_all > 34 && pwdb_all <= 42)
827  pwdb_all -= 2;
828  else if (pwdb_all > 26 && pwdb_all <= 34)
829  pwdb_all -= 6;
830  else if (pwdb_all > 14 && pwdb_all <= 26)
831  pwdb_all -= 8;
832  else if (pwdb_all > 4 && pwdb_all <= 14)
833  pwdb_all -= 4;
834  /*
835  * (3) Get Signal Quality (EVM)
836  */
837  if (pwdb_all > 40)
838  sq = 100;
839  else {
840  sq = pcck_buf->sq_rpt;
841  if (pcck_buf->sq_rpt > 64)
842  sq = 0;
843  else if (pcck_buf->sq_rpt < 20)
844  sq = 100;
845  else
846  sq = ((64-sq) * 100) / 44;
847  }
848  prframe->u.hdr.attrib.signal_qual = sq;
849  prframe->u.hdr.attrib.rx_mimo_signal_qual[0] = sq;
850  prframe->u.hdr.attrib.rx_mimo_signal_qual[1] = -1;
851  } else {
852  /* (1)Get RSSI for HT rate */
853  for (i = 0; i < ((padapter->registrypriv.rf_config) &
854  0x0f) ; i++) {
855  rf_rx_num++;
856  rx_pwr[i] = ((pphy_head[PHY_STAT_GAIN_TRSW_SHT + i]
857  & 0x3F) * 2) - 110;
858  /* Translate DBM to percentage. */
859  rssi = query_rx_pwr_percentage(rx_pwr[i]);
860  total_rssi += rssi;
861  }
862  /* (2)PWDB, Average PWDB cacluated by hardware (for
863  * rate adaptive) */
864  rx_pwr_all = (((pphy_head[PHY_STAT_PWDB_ALL_SHT]) >> 1) & 0x7f)
865  - 106;
866  pwdb_all = query_rx_pwr_percentage(rx_pwr_all);
867 
868  {
869  /* (3)EVM of HT rate */
870  if (prframe->u.hdr.attrib.htc &&
871  prframe->u.hdr.attrib.mcs_rate >= 20 &&
872  prframe->u.hdr.attrib.mcs_rate <= 27) {
873  /* both spatial stream make sense */
874  max_spatial_stream = 2;
875  } else {
876  /* only spatial stream 1 makes sense */
877  max_spatial_stream = 1;
878  }
879  for (i = 0; i < max_spatial_stream; i++) {
880  evm = evm_db2percentage((pphy_head
881  [PHY_STAT_RXEVM_SHT + i]));/*dbm*/
882  prframe->u.hdr.attrib.signal_qual =
883  (u8)(evm & 0xff);
884  prframe->u.hdr.attrib.rx_mimo_signal_qual[i] =
885  (u8)(evm & 0xff);
886  }
887  }
888  }
889  /* UI BSS List signal strength(in percentage), make it good looking,
890  * from 0~100. It is assigned to the BSS List in
891  * GetValueFromBeaconOrProbeRsp(). */
892  if (bcck_rate)
893  prframe->u.hdr.attrib.signal_strength =
894  (u8)r8712_signal_scale_mapping(pwdb_all);
895  else {
896  if (rf_rx_num != 0)
897  prframe->u.hdr.attrib.signal_strength =
898  (u8)(r8712_signal_scale_mapping(total_rssi /=
899  rf_rx_num));
900  }
901 }
902 
903 static void process_link_qual(struct _adapter *padapter,
904  union recv_frame *prframe)
905 {
906  u32 last_evm = 0, tmpVal;
907  struct rx_pkt_attrib *pattrib;
908 
909  if (prframe == NULL || padapter == NULL)
910  return;
911  pattrib = &prframe->u.hdr.attrib;
912  if (pattrib->signal_qual != 0) {
913  /*
914  * 1. Record the general EVM to the sliding window.
915  */
916  if (padapter->recvpriv.signal_qual_data.total_num++ >=
918  padapter->recvpriv.signal_qual_data.total_num =
920  last_evm = padapter->recvpriv.signal_qual_data.elements
921  [padapter->recvpriv.signal_qual_data.index];
922  padapter->recvpriv.signal_qual_data.total_val -=
923  last_evm;
924  }
925  padapter->recvpriv.signal_qual_data.total_val +=
926  pattrib->signal_qual;
927  padapter->recvpriv.signal_qual_data.elements[padapter->
928  recvpriv.signal_qual_data.index++] =
929  pattrib->signal_qual;
930  if (padapter->recvpriv.signal_qual_data.index >=
932  padapter->recvpriv.signal_qual_data.index = 0;
933 
934  /* <1> Showed on UI for user, in percentage. */
935  tmpVal = padapter->recvpriv.signal_qual_data.total_val /
936  padapter->recvpriv.signal_qual_data.total_num;
937  padapter->recvpriv.signal = (u8)tmpVal;
938  }
939 }
940 
941 static void process_rssi(struct _adapter *padapter, union recv_frame *prframe)
942 {
943  u32 last_rssi, tmp_val;
944  struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;
945 
946  if (padapter->recvpriv.signal_strength_data.total_num++ >=
948  padapter->recvpriv.signal_strength_data.total_num =
950  last_rssi = padapter->recvpriv.signal_strength_data.elements
951  [padapter->recvpriv.signal_strength_data.index];
952  padapter->recvpriv.signal_strength_data.total_val -= last_rssi;
953  }
954  padapter->recvpriv.signal_strength_data.total_val +=
955  pattrib->signal_strength;
956  padapter->recvpriv.signal_strength_data.elements[padapter->recvpriv.
957  signal_strength_data.index++] =
958  pattrib->signal_strength;
959  if (padapter->recvpriv.signal_strength_data.index >=
961  padapter->recvpriv.signal_strength_data.index = 0;
962  tmp_val = padapter->recvpriv.signal_strength_data.total_val /
963  padapter->recvpriv.signal_strength_data.total_num;
964  padapter->recvpriv.rssi = (s8)translate2dbm(padapter, (u8)tmp_val);
965 }
966 
967 static void process_phy_info(struct _adapter *padapter,
968  union recv_frame *prframe)
969 {
970  query_rx_phy_status(padapter, prframe);
971  process_rssi(padapter, prframe);
972  process_link_qual(padapter, prframe);
973 }
974 
975 int recv_func(struct _adapter *padapter, void *pcontext)
976 {
977  struct rx_pkt_attrib *pattrib;
978  union recv_frame *prframe, *orig_prframe;
979  int retval = _SUCCESS;
980  struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
981  struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
982 
983  prframe = (union recv_frame *)pcontext;
984  orig_prframe = prframe;
985  pattrib = &prframe->u.hdr.attrib;
986  if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)) {
987  if (pattrib->crc_err == 1)
988  padapter->mppriv.rx_crcerrpktcount++;
989  else
990  padapter->mppriv.rx_pktcount++;
991  if (check_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE) == false) {
992  /* free this recv_frame */
993  r8712_free_recvframe(orig_prframe, pfree_recv_queue);
994  goto _exit_recv_func;
995  }
996  }
997  /* check the frame crtl field and decache */
998  retval = r8712_validate_recv_frame(padapter, prframe);
999  if (retval != _SUCCESS) {
1000  /* free this recv_frame */
1001  r8712_free_recvframe(orig_prframe, pfree_recv_queue);
1002  goto _exit_recv_func;
1003  }
1004  process_phy_info(padapter, prframe);
1005  prframe = r8712_decryptor(padapter, prframe);
1006  if (prframe == NULL) {
1007  retval = _FAIL;
1008  goto _exit_recv_func;
1009  }
1010  prframe = r8712_recvframe_chk_defrag(padapter, prframe);
1011  if (prframe == NULL)
1012  goto _exit_recv_func;
1013  prframe = r8712_portctrl(padapter, prframe);
1014  if (prframe == NULL) {
1015  retval = _FAIL;
1016  goto _exit_recv_func;
1017  }
1018  retval = r8712_process_recv_indicatepkts(padapter, prframe);
1019  if (retval != _SUCCESS) {
1020  r8712_free_recvframe(orig_prframe, pfree_recv_queue);
1021  goto _exit_recv_func;
1022  }
1023 _exit_recv_func:
1024  return retval;
1025 }
1026 
1027 static int recvbuf2recvframe(struct _adapter *padapter, struct sk_buff *pskb)
1028 {
1029  u8 *pbuf, shift_sz = 0;
1030  u8 frag, mf;
1031  uint pkt_len;
1032  u32 transfer_len;
1033  struct recv_stat *prxstat;
1034  u16 pkt_cnt, drvinfo_sz, pkt_offset, tmp_len, alloc_sz;
1035  struct __queue *pfree_recv_queue;
1036  _pkt *pkt_copy = NULL;
1037  union recv_frame *precvframe = NULL;
1038  struct recv_priv *precvpriv = &padapter->recvpriv;
1039 
1040  pfree_recv_queue = &(precvpriv->free_recv_queue);
1041  pbuf = pskb->data;
1042  prxstat = (struct recv_stat *)pbuf;
1043  pkt_cnt = (le32_to_cpu(prxstat->rxdw2)>>16)&0xff;
1044  pkt_len = le32_to_cpu(prxstat->rxdw0)&0x00003fff;
1045  transfer_len = pskb->len;
1046  /* Test throughput with Netgear 3700 (No security) with Chariot 3T3R
1047  * pairs. The packet count will be a big number so that the containing
1048  * packet will effect the Rx reordering. */
1049  if (transfer_len < pkt_len) {
1050  /* In this case, it means the MAX_RECVBUF_SZ is too small to
1051  * get the data from 8712u. */
1052  return _FAIL;
1053  }
1054  do {
1055  prxstat = (struct recv_stat *)pbuf;
1056  pkt_len = le32_to_cpu(prxstat->rxdw0)&0x00003fff;
1057  /* more fragment bit */
1058  mf = (le32_to_cpu(prxstat->rxdw1) >> 27) & 0x1;
1059  /* ragmentation number */
1060  frag = (le32_to_cpu(prxstat->rxdw2) >> 12) & 0xf;
1061  /* uint 2^3 = 8 bytes */
1062  drvinfo_sz = (le32_to_cpu(prxstat->rxdw0) & 0x000f0000) >> 16;
1063  drvinfo_sz = drvinfo_sz<<3;
1064  if (pkt_len <= 0)
1065  goto _exit_recvbuf2recvframe;
1066  /* Qos data, wireless lan header length is 26 */
1067  if ((le32_to_cpu(prxstat->rxdw0) >> 23) & 0x01)
1068  shift_sz = 2;
1069  precvframe = r8712_alloc_recvframe(pfree_recv_queue);
1070  if (precvframe == NULL)
1071  goto _exit_recvbuf2recvframe;
1072  _init_listhead(&precvframe->u.hdr.list);
1073  precvframe->u.hdr.precvbuf = NULL; /*can't access the precvbuf*/
1074  precvframe->u.hdr.len = 0;
1075  tmp_len = pkt_len + drvinfo_sz + RXDESC_SIZE;
1076  pkt_offset = (u16)_RND128(tmp_len);
1077  /* for first fragment packet, driver need allocate 1536 +
1078  * drvinfo_sz + RXDESC_SIZE to defrag packet. */
1079  if ((mf == 1) && (frag == 0))
1080  alloc_sz = 1658;/*1658+6=1664, 1664 is 128 alignment.*/
1081  else
1082  alloc_sz = tmp_len;
1083  /* 2 is for IP header 4 bytes alignment in QoS packet case.
1084  * 4 is for skb->data 4 bytes alignment. */
1085  alloc_sz += 6;
1086  pkt_copy = netdev_alloc_skb(padapter->pnetdev, alloc_sz);
1087  if (pkt_copy) {
1088  pkt_copy->dev = padapter->pnetdev;
1089  precvframe->u.hdr.pkt = pkt_copy;
1090  skb_reserve(pkt_copy, 4 - ((addr_t)(pkt_copy->data)
1091  % 4));
1092  skb_reserve(pkt_copy, shift_sz);
1093  memcpy(pkt_copy->data, pbuf, tmp_len);
1094  precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_data =
1095  precvframe->u.hdr.rx_tail = pkt_copy->data;
1096  precvframe->u.hdr.rx_end = pkt_copy->data + alloc_sz;
1097  } else {
1098  precvframe->u.hdr.pkt = skb_clone(pskb, GFP_ATOMIC);
1099  if (!precvframe->u.hdr.pkt)
1100  return _FAIL;
1101  precvframe->u.hdr.rx_head = pbuf;
1102  precvframe->u.hdr.rx_data = pbuf;
1103  precvframe->u.hdr.rx_tail = pbuf;
1104  precvframe->u.hdr.rx_end = pbuf + alloc_sz;
1105  }
1106  recvframe_put(precvframe, tmp_len);
1107  recvframe_pull(precvframe, drvinfo_sz + RXDESC_SIZE);
1108  /* because the endian issue, driver avoid reference to the
1109  * rxstat after calling update_recvframe_attrib_from_recvstat();
1110  */
1111  update_recvframe_attrib_from_recvstat(&precvframe->u.hdr.attrib,
1112  prxstat);
1113  r8712_recv_entry(precvframe);
1114  transfer_len -= pkt_offset;
1115  pbuf += pkt_offset;
1116  pkt_cnt--;
1117  precvframe = NULL;
1118  pkt_copy = NULL;
1119  } while ((transfer_len > 0) && pkt_cnt > 0);
1120 _exit_recvbuf2recvframe:
1121  return _SUCCESS;
1122 }
1123 
1124 static void recv_tasklet(void *priv)
1125 {
1126  struct sk_buff *pskb;
1127  struct _adapter *padapter = (struct _adapter *)priv;
1128  struct recv_priv *precvpriv = &padapter->recvpriv;
1129 
1130  while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) {
1131  recvbuf2recvframe(padapter, pskb);
1132  skb_reset_tail_pointer(pskb);
1133  pskb->len = 0;
1134  if (!skb_cloned(pskb))
1135  skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb);
1136  else
1137  consume_skb(pskb);
1138  }
1139 }