This source file includes following definitions.
- rtw_os_free_recvframe
- rtw_os_recv_resource_alloc
- rtw_os_recv_resource_free
- rtw_os_recvbuf_resource_free
- rtw_os_alloc_msdu_pkt
- rtw_os_recv_indicate_pkt
- rtw_handle_tkip_mic_err
- rtw_os_ksocket_send
- rtw_recv_indicatepkt
- rtw_init_recv_timer
1
2
3
4
5
6
7 #define _RECV_OSDEP_C_
8
9 #include <drv_types.h>
10 #include <rtw_debug.h>
11 #include <linux/jiffies.h>
12
13 void rtw_os_free_recvframe(union recv_frame *precvframe)
14 {
15 if (precvframe->u.hdr.pkt) {
16 dev_kfree_skb_any(precvframe->u.hdr.pkt);
17
18 precvframe->u.hdr.pkt = NULL;
19 }
20 }
21
22
23 void rtw_os_recv_resource_alloc(struct adapter *padapter, union recv_frame *precvframe)
24 {
25 precvframe->u.hdr.pkt_newalloc = precvframe->u.hdr.pkt = NULL;
26 }
27
28
29 void rtw_os_recv_resource_free(struct recv_priv *precvpriv)
30 {
31 sint i;
32 union recv_frame *precvframe;
33
34 precvframe = (union recv_frame*) precvpriv->precv_frame_buf;
35
36 for (i = 0; i < NR_RECVFRAME; i++) {
37 if (precvframe->u.hdr.pkt) {
38 dev_kfree_skb_any(precvframe->u.hdr.pkt);
39 precvframe->u.hdr.pkt = NULL;
40 }
41 precvframe++;
42 }
43 }
44
45
46 void rtw_os_recvbuf_resource_free(struct adapter *padapter, struct recv_buf *precvbuf)
47 {
48 if (precvbuf->pskb) {
49 dev_kfree_skb_any(precvbuf->pskb);
50 }
51 }
52
53 _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 *pdata)
54 {
55 u16 eth_type;
56 _pkt *sub_skb;
57 struct rx_pkt_attrib *pattrib;
58
59 pattrib = &prframe->u.hdr.attrib;
60
61 sub_skb = rtw_skb_alloc(nSubframe_Length + 12);
62 if (sub_skb) {
63 skb_reserve(sub_skb, 12);
64 skb_put_data(sub_skb, (pdata + ETH_HLEN), nSubframe_Length);
65 } else {
66 sub_skb = rtw_skb_clone(prframe->u.hdr.pkt);
67 if (sub_skb) {
68 sub_skb->data = pdata + ETH_HLEN;
69 sub_skb->len = nSubframe_Length;
70 skb_set_tail_pointer(sub_skb, nSubframe_Length);
71 } else {
72 DBG_871X("%s(): rtw_skb_clone() Fail!!!\n", __func__);
73 return NULL;
74 }
75 }
76
77 eth_type = RTW_GET_BE16(&sub_skb->data[6]);
78
79 if (sub_skb->len >= 8 &&
80 ((!memcmp(sub_skb->data, rtw_rfc1042_header, SNAP_SIZE) &&
81 eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) ||
82 !memcmp(sub_skb->data, rtw_bridge_tunnel_header, SNAP_SIZE))) {
83
84 skb_pull(sub_skb, SNAP_SIZE);
85 memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN);
86 memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, ETH_ALEN);
87 } else {
88 __be16 len;
89
90 len = htons(sub_skb->len);
91 memcpy(skb_push(sub_skb, 2), &len, 2);
92 memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN);
93 memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, ETH_ALEN);
94 }
95
96 return sub_skb;
97 }
98
99 void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt_attrib *pattrib)
100 {
101 struct mlme_priv*pmlmepriv = &padapter->mlmepriv;
102 int ret;
103
104
105 if (pkt) {
106 if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
107 _pkt *pskb2 = NULL;
108 struct sta_info *psta = NULL;
109 struct sta_priv *pstapriv = &padapter->stapriv;
110 int bmcast = IS_MCAST(pattrib->dst);
111
112
113
114 if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), ETH_ALEN)) {
115
116
117 if (bmcast) {
118 psta = rtw_get_bcmc_stainfo(padapter);
119 pskb2 = rtw_skb_clone(pkt);
120 } else {
121 psta = rtw_get_stainfo(pstapriv, pattrib->dst);
122 }
123
124 if (psta) {
125 struct net_device *pnetdev = (struct net_device*)padapter->pnetdev;
126
127
128
129
130 pkt->dev = pnetdev;
131 skb_set_queue_mapping(pkt, rtw_recv_select_queue(pkt));
132
133 _rtw_xmit_entry(pkt, pnetdev);
134
135 if (bmcast && (pskb2 != NULL)) {
136 pkt = pskb2;
137 DBG_COUNTER(padapter->rx_logs.os_indicate_ap_mcast);
138 } else {
139 DBG_COUNTER(padapter->rx_logs.os_indicate_ap_forward);
140 return;
141 }
142 }
143 } else {
144
145
146 DBG_COUNTER(padapter->rx_logs.os_indicate_ap_self);
147 }
148 }
149
150 pkt->protocol = eth_type_trans(pkt, padapter->pnetdev);
151 pkt->dev = padapter->pnetdev;
152
153 #ifdef CONFIG_TCP_CSUM_OFFLOAD_RX
154 if ((pattrib->tcpchk_valid == 1) && (pattrib->tcp_chkrpt == 1))
155 pkt->ip_summed = CHECKSUM_UNNECESSARY;
156 else
157 pkt->ip_summed = CHECKSUM_NONE;
158
159 #else
160 pkt->ip_summed = CHECKSUM_NONE;
161 #endif
162
163 ret = rtw_netif_rx(padapter->pnetdev, pkt);
164 if (ret == NET_RX_SUCCESS)
165 DBG_COUNTER(padapter->rx_logs.os_netif_ok);
166 else
167 DBG_COUNTER(padapter->rx_logs.os_netif_err);
168 }
169 }
170
171 void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup)
172 {
173 enum nl80211_key_type key_type = 0;
174 union iwreq_data wrqu;
175 struct iw_michaelmicfailure ev;
176 struct mlme_priv* pmlmepriv = &padapter->mlmepriv;
177 struct security_priv *psecuritypriv = &padapter->securitypriv;
178 unsigned long cur_time = 0;
179
180 if (psecuritypriv->last_mic_err_time == 0) {
181 psecuritypriv->last_mic_err_time = jiffies;
182 } else {
183 cur_time = jiffies;
184
185 if (cur_time - psecuritypriv->last_mic_err_time < 60*HZ) {
186 psecuritypriv->btkip_countermeasure = true;
187 psecuritypriv->last_mic_err_time = 0;
188 psecuritypriv->btkip_countermeasure_time = cur_time;
189 } else {
190 psecuritypriv->last_mic_err_time = jiffies;
191 }
192 }
193
194 if (bgroup) {
195 key_type |= NL80211_KEYTYPE_GROUP;
196 } else {
197 key_type |= NL80211_KEYTYPE_PAIRWISE;
198 }
199
200 cfg80211_michael_mic_failure(padapter->pnetdev, (u8 *)&pmlmepriv->assoc_bssid[ 0 ], key_type, -1,
201 NULL, GFP_ATOMIC);
202
203 memset(&ev, 0x00, sizeof(ev));
204 if (bgroup) {
205 ev.flags |= IW_MICFAILURE_GROUP;
206 } else {
207 ev.flags |= IW_MICFAILURE_PAIRWISE;
208 }
209
210 ev.src_addr.sa_family = ARPHRD_ETHER;
211 memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN);
212
213 memset(&wrqu, 0x00, sizeof(wrqu));
214 wrqu.data.length = sizeof(ev);
215 }
216
217 #ifdef CONFIG_AUTO_AP_MODE
218 static void rtw_os_ksocket_send(struct adapter *padapter, union recv_frame *precv_frame)
219 {
220 _pkt *skb = precv_frame->u.hdr.pkt;
221 struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
222 struct sta_info *psta = precv_frame->u.hdr.psta;
223
224 DBG_871X("eth rx: got eth_type = 0x%x\n", pattrib->eth_type);
225
226 if (psta && psta->isrc && psta->pid>0) {
227 u16 rx_pid;
228
229 rx_pid = *(u16*)(skb->data+ETH_HLEN);
230
231 DBG_871X("eth rx(pid = 0x%x): sta("MAC_FMT") pid = 0x%x\n",
232 rx_pid, MAC_ARG(psta->hwaddr), psta->pid);
233
234 if (rx_pid == psta->pid) {
235 int i;
236 u16 len = *(u16*)(skb->data+ETH_HLEN+2);
237
238
239
240 DBG_871X("eth, RC: len = 0x%x\n", len);
241
242 for (i = 0;i<len;i++)
243 DBG_871X("0x%x\n", *(skb->data+ETH_HLEN+4+i));
244
245
246 DBG_871X("eth, RC-end\n");
247 }
248
249 }
250
251 }
252 #endif
253
254 int rtw_recv_indicatepkt(struct adapter *padapter, union recv_frame *precv_frame)
255 {
256 struct recv_priv *precvpriv;
257 struct __queue *pfree_recv_queue;
258 _pkt *skb;
259 struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
260
261 DBG_COUNTER(padapter->rx_logs.os_indicate);
262
263 precvpriv = &(padapter->recvpriv);
264 pfree_recv_queue = &(precvpriv->free_recv_queue);
265
266 skb = precv_frame->u.hdr.pkt;
267 if (skb == NULL) {
268 RT_TRACE(_module_recv_osdep_c_, _drv_err_, ("rtw_recv_indicatepkt():skb == NULL something wrong!!!!\n"));
269 goto _recv_indicatepkt_drop;
270 }
271
272 RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("rtw_recv_indicatepkt():skb != NULL !!!\n"));
273 RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("rtw_recv_indicatepkt():precv_frame->u.hdr.rx_head =%p precv_frame->hdr.rx_data =%p\n", precv_frame->u.hdr.rx_head, precv_frame->u.hdr.rx_data));
274 RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("precv_frame->hdr.rx_tail =%p precv_frame->u.hdr.rx_end =%p precv_frame->hdr.len =%d\n", precv_frame->u.hdr.rx_tail, precv_frame->u.hdr.rx_end, precv_frame->u.hdr.len));
275
276 skb->data = precv_frame->u.hdr.rx_data;
277
278 skb_set_tail_pointer(skb, precv_frame->u.hdr.len);
279
280 skb->len = precv_frame->u.hdr.len;
281
282 RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("\n skb->head =%p skb->data =%p skb->tail =%p skb->end =%p skb->len =%d\n", skb->head, skb->data, skb_tail_pointer(skb), skb_end_pointer(skb), skb->len));
283
284 #ifdef CONFIG_AUTO_AP_MODE
285 if (0x8899 == pattrib->eth_type) {
286 rtw_os_ksocket_send(padapter, precv_frame);
287
288
289 }
290 #endif
291
292 rtw_os_recv_indicate_pkt(padapter, skb, pattrib);
293
294 precv_frame->u.hdr.pkt = NULL;
295
296 rtw_free_recvframe(precv_frame, pfree_recv_queue);
297
298 RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("\n rtw_recv_indicatepkt :after rtw_os_recv_indicate_pkt!!!!\n"));
299
300 return _SUCCESS;
301
302 _recv_indicatepkt_drop:
303
304
305 rtw_free_recvframe(precv_frame, pfree_recv_queue);
306
307 DBG_COUNTER(padapter->rx_logs.os_indicate_err);
308 return _FAIL;
309 }
310
311 void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
312 {
313 timer_setup(&preorder_ctrl->reordering_ctrl_timer,
314 rtw_reordering_ctrl_timeout_handler, 0);
315
316 }