Merge branch 'for-4.6' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq
[deliverable/linux.git] / drivers / staging / rtl8712 / recv_linux.c
CommitLineData
2865d42c
LF
1/******************************************************************************
2 * recv_linux.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 <wlanfae@realtek.com>.
25 * Larry Finger <Larry.Finger@lwfinger.net>
26 *
27 ******************************************************************************/
28
29#define _RECV_OSDEP_C_
30
359140aa
AB
31#include <linux/usb.h>
32
2865d42c
LF
33#include "osdep_service.h"
34#include "drv_types.h"
35#include "wifi.h"
36#include "recv_osdep.h"
37#include "osdep_intf.h"
359140aa
AB
38#include "ethernet.h"
39#include <linux/if_arp.h>
2865d42c
LF
40#include "usb_ops.h"
41
42/*init os related resource in struct recv_priv*/
43/*alloc os related resource in union recv_frame*/
44int r8712_os_recv_resource_alloc(struct _adapter *padapter,
45 union recv_frame *precvframe)
46{
8558ace8
SB
47 precvframe->u.hdr.pkt_newalloc = NULL;
48 precvframe->u.hdr.pkt = NULL;
2865d42c
LF
49 return _SUCCESS;
50}
51
52/*alloc os related resource in struct recv_buf*/
53int r8712_os_recvbuf_resource_alloc(struct _adapter *padapter,
54 struct recv_buf *precvbuf)
55{
56 int res = _SUCCESS;
57
58 precvbuf->irp_pending = false;
68e9b249 59 precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL);
9155c924 60 if (!precvbuf->purb)
2865d42c
LF
61 res = _FAIL;
62 precvbuf->pskb = NULL;
63 precvbuf->reuse = false;
64 precvbuf->pallocated_buf = NULL;
65 precvbuf->pbuf = NULL;
66 precvbuf->pdata = NULL;
67 precvbuf->phead = NULL;
68 precvbuf->ptail = NULL;
69 precvbuf->pend = NULL;
70 precvbuf->transfer_len = 0;
71 precvbuf->len = 0;
72 return res;
73}
74
75/*free os related resource in struct recv_buf*/
76int r8712_os_recvbuf_resource_free(struct _adapter *padapter,
77 struct recv_buf *precvbuf)
78{
79 if (precvbuf->pskb)
80 dev_kfree_skb_any(precvbuf->pskb);
81 if (precvbuf->purb) {
82 usb_kill_urb(precvbuf->purb);
83 usb_free_urb(precvbuf->purb);
84 }
85 return _SUCCESS;
86}
87
88void r8712_handle_tkip_mic_err(struct _adapter *padapter, u8 bgroup)
89{
90 union iwreq_data wrqu;
91 struct iw_michaelmicfailure ev;
92 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
93
94 memset(&ev, 0x00, sizeof(ev));
95 if (bgroup)
96 ev.flags |= IW_MICFAILURE_GROUP;
97 else
98 ev.flags |= IW_MICFAILURE_PAIRWISE;
99 ev.src_addr.sa_family = ARPHRD_ETHER;
c7c42826 100 ether_addr_copy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0]);
2865d42c
LF
101 memset(&wrqu, 0x00, sizeof(wrqu));
102 wrqu.data.length = sizeof(ev);
103 wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, &wrqu,
104 (char *)&ev);
105}
106
107void r8712_recv_indicatepkt(struct _adapter *padapter,
108 union recv_frame *precv_frame)
109{
110 struct recv_priv *precvpriv;
111 struct __queue *pfree_recv_queue;
112 _pkt *skb;
113 struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
114
115 precvpriv = &(padapter->recvpriv);
116 pfree_recv_queue = &(precvpriv->free_recv_queue);
117 skb = precv_frame->u.hdr.pkt;
6806be31 118 if (!skb)
2865d42c
LF
119 goto _recv_indicatepkt_drop;
120 skb->data = precv_frame->u.hdr.rx_data;
2865d42c 121 skb->len = precv_frame->u.hdr.len;
abf02cfc 122 skb_set_tail_pointer(skb, skb->len);
2865d42c
LF
123 if ((pattrib->tcpchk_valid == 1) && (pattrib->tcp_chkrpt == 1))
124 skb->ip_summed = CHECKSUM_UNNECESSARY;
125 else
126 skb->ip_summed = CHECKSUM_NONE;
127 skb->dev = padapter->pnetdev;
128 skb->protocol = eth_type_trans(skb, padapter->pnetdev);
129 netif_rx(skb);
130 precv_frame->u.hdr.pkt = NULL; /* pointers to NULL before
61172e0c
PV
131 * r8712_free_recvframe()
132 */
2865d42c
LF
133 r8712_free_recvframe(precv_frame, pfree_recv_queue);
134 return;
135_recv_indicatepkt_drop:
136 /*enqueue back to free_recv_queue*/
7eea766a 137 if (precv_frame)
2865d42c 138 r8712_free_recvframe(precv_frame, pfree_recv_queue);
7eea766a 139 precvpriv->rx_drop++;
2865d42c
LF
140}
141
e922df7d 142static void _r8712_reordering_ctrl_timeout_handler (unsigned long data)
2865d42c
LF
143{
144 struct recv_reorder_ctrl *preorder_ctrl =
e922df7d 145 (struct recv_reorder_ctrl *)data;
2865d42c
LF
146
147 r8712_reordering_ctrl_timeout_handler(preorder_ctrl);
148}
149
150void r8712_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
151{
e922df7d
VT
152 setup_timer(&preorder_ctrl->reordering_ctrl_timer,
153 _r8712_reordering_ctrl_timeout_handler,
154 (unsigned long)preorder_ctrl);
2865d42c 155}
This page took 0.483748 seconds and 5 git commands to generate.