recv_linux.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. #define _RECV_OSDEP_C_
  21. #include <drv_types.h>
  22. int rtw_os_alloc_recvframe(_adapter *padapter, union recv_frame *precvframe, u8 *pdata, _pkt *pskb)
  23. {
  24. int res = _SUCCESS;
  25. u8 shift_sz = 0;
  26. u32 skb_len, alloc_sz;
  27. _pkt *pkt_copy = NULL;
  28. struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib;
  29. if(pdata == NULL)
  30. {
  31. precvframe->u.hdr.pkt = NULL;
  32. res = _FAIL;
  33. return res;
  34. }
  35. // Modified by Albert 20101213
  36. // For 8 bytes IP header alignment.
  37. shift_sz = pattrib->qos ? 6:0;// Qos data, wireless lan header length is 26
  38. skb_len = pattrib->pkt_len;
  39. // for first fragment packet, driver need allocate 1536+drvinfo_sz+RXDESC_SIZE to defrag packet.
  40. // modify alloc_sz for recvive crc error packet by thomas 2011-06-02
  41. if((pattrib->mfrag == 1)&&(pattrib->frag_num == 0))
  42. {
  43. //alloc_sz = 1664; //1664 is 128 alignment.
  44. alloc_sz = (skb_len <= 1650) ? 1664:(skb_len + 14);
  45. }
  46. else
  47. {
  48. alloc_sz = skb_len;
  49. // 6 is for IP header 8 bytes alignment in QoS packet case.
  50. // 8 is for skb->data 4 bytes alignment.
  51. alloc_sz += 14;
  52. }
  53. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) // http://www.mail-archive.com/netdev@vger.kernel.org/msg17214.html
  54. pkt_copy = dev_alloc_skb(alloc_sz);
  55. #else
  56. pkt_copy = netdev_alloc_skb(padapter->pnetdev, alloc_sz);
  57. #endif
  58. if(pkt_copy)
  59. {
  60. pkt_copy->dev = padapter->pnetdev;
  61. precvframe->u.hdr.pkt = pkt_copy;
  62. precvframe->u.hdr.rx_head = pkt_copy->data;
  63. precvframe->u.hdr.rx_end = pkt_copy->data + alloc_sz;
  64. skb_reserve(pkt_copy, 8 - ((SIZE_PTR)( pkt_copy->data) & 7 ));//force pkt_copy->data at 8-byte alignment address
  65. skb_reserve(pkt_copy, shift_sz);//force ip_hdr at 8-byte alignment address according to shift_sz.
  66. _rtw_memcpy(pkt_copy->data, pdata, skb_len);
  67. precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail = pkt_copy->data;
  68. }
  69. else
  70. {
  71. #ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX
  72. DBG_871X("%s:can not allocate memory for skb copy\n", __FUNCTION__);
  73. precvframe->u.hdr.pkt = NULL;
  74. //rtw_free_recvframe(precvframe, pfree_recv_queue);
  75. //goto _exit_recvbuf2recvframe;
  76. res = _FAIL;
  77. #else
  78. if((pattrib->mfrag == 1)&&(pattrib->frag_num == 0))
  79. {
  80. DBG_871X("%s: alloc_skb fail , drop frag frame \n", __FUNCTION__);
  81. //rtw_free_recvframe(precvframe, pfree_recv_queue);
  82. res = _FAIL;
  83. goto exit_rtw_os_recv_resource_alloc;
  84. }
  85. if(pskb == NULL)
  86. {
  87. res = _FAIL;
  88. goto exit_rtw_os_recv_resource_alloc;
  89. }
  90. precvframe->u.hdr.pkt = skb_clone(pskb, GFP_ATOMIC);
  91. if(precvframe->u.hdr.pkt)
  92. {
  93. precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail = pdata;
  94. precvframe->u.hdr.rx_end = pdata + alloc_sz;
  95. }
  96. else
  97. {
  98. DBG_871X("%s: skb_clone fail\n", __FUNCTION__);
  99. //rtw_free_recvframe(precvframe, pfree_recv_queue);
  100. //goto _exit_recvbuf2recvframe;
  101. res = _FAIL;
  102. }
  103. #endif
  104. }
  105. exit_rtw_os_recv_resource_alloc:
  106. return res;
  107. }
  108. void rtw_os_free_recvframe(union recv_frame *precvframe)
  109. {
  110. if(precvframe->u.hdr.pkt)
  111. {
  112. dev_kfree_skb_any(precvframe->u.hdr.pkt);//free skb by driver
  113. precvframe->u.hdr.pkt = NULL;
  114. }
  115. }
  116. //init os related resource in struct recv_priv
  117. int rtw_os_recv_resource_init(struct recv_priv *precvpriv, _adapter *padapter)
  118. {
  119. int res=_SUCCESS;
  120. return res;
  121. }
  122. //alloc os related resource in union recv_frame
  123. int rtw_os_recv_resource_alloc(_adapter *padapter, union recv_frame *precvframe)
  124. {
  125. int res=_SUCCESS;
  126. precvframe->u.hdr.pkt_newalloc = precvframe->u.hdr.pkt = NULL;
  127. return res;
  128. }
  129. //free os related resource in union recv_frame
  130. void rtw_os_recv_resource_free(struct recv_priv *precvpriv)
  131. {
  132. }
  133. //alloc os related resource in struct recv_buf
  134. int rtw_os_recvbuf_resource_alloc(_adapter *padapter, struct recv_buf *precvbuf)
  135. {
  136. int res=_SUCCESS;
  137. #ifdef CONFIG_USB_HCI
  138. struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
  139. struct usb_device *pusbd = pdvobjpriv->pusbdev;
  140. precvbuf->irp_pending = _FALSE;
  141. precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL);
  142. if(precvbuf->purb == NULL){
  143. res = _FAIL;
  144. }
  145. precvbuf->pskb = NULL;
  146. precvbuf->reuse = _FALSE;
  147. precvbuf->pallocated_buf = precvbuf->pbuf = NULL;
  148. precvbuf->pdata = precvbuf->phead = precvbuf->ptail = precvbuf->pend = NULL;
  149. precvbuf->transfer_len = 0;
  150. precvbuf->len = 0;
  151. #ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX
  152. precvbuf->pallocated_buf = rtw_usb_buffer_alloc(pusbd, (size_t)precvbuf->alloc_sz, &precvbuf->dma_transfer_addr);
  153. precvbuf->pbuf = precvbuf->pallocated_buf;
  154. if(precvbuf->pallocated_buf == NULL)
  155. return _FAIL;
  156. #endif //CONFIG_USE_USB_BUFFER_ALLOC_RX
  157. #endif //CONFIG_USB_HCI
  158. return res;
  159. }
  160. //free os related resource in struct recv_buf
  161. int rtw_os_recvbuf_resource_free(_adapter *padapter, struct recv_buf *precvbuf)
  162. {
  163. int ret = _SUCCESS;
  164. #ifdef CONFIG_USB_HCI
  165. #ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX
  166. struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
  167. struct usb_device *pusbd = pdvobjpriv->pusbdev;
  168. rtw_usb_buffer_free(pusbd, (size_t)precvbuf->alloc_sz, precvbuf->pallocated_buf, precvbuf->dma_transfer_addr);
  169. precvbuf->pallocated_buf = NULL;
  170. precvbuf->dma_transfer_addr = 0;
  171. #endif //CONFIG_USE_USB_BUFFER_ALLOC_RX
  172. if(precvbuf->purb)
  173. {
  174. //usb_kill_urb(precvbuf->purb);
  175. usb_free_urb(precvbuf->purb);
  176. }
  177. #endif //CONFIG_USB_HCI
  178. if(precvbuf->pskb)
  179. dev_kfree_skb_any(precvbuf->pskb);
  180. return ret;
  181. }
  182. _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 *pdata)
  183. {
  184. u16 eth_type;
  185. u8 *data_ptr;
  186. _pkt *sub_skb;
  187. struct rx_pkt_attrib *pattrib;
  188. pattrib = &prframe->u.hdr.attrib;
  189. #ifdef CONFIG_SKB_COPY
  190. sub_skb = dev_alloc_skb(nSubframe_Length + 12);
  191. if(sub_skb)
  192. {
  193. skb_reserve(sub_skb, 12);
  194. data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length);
  195. _rtw_memcpy(data_ptr, (pdata + ETH_HLEN), nSubframe_Length);
  196. }
  197. else
  198. #endif // CONFIG_SKB_COPY
  199. {
  200. sub_skb = skb_clone(prframe->u.hdr.pkt, GFP_ATOMIC);
  201. if(sub_skb)
  202. {
  203. sub_skb->data = pdata + ETH_HLEN;
  204. sub_skb->len = nSubframe_Length;
  205. skb_set_tail_pointer(sub_skb, nSubframe_Length);
  206. }
  207. else
  208. {
  209. DBG_871X("%s(): skb_clone() Fail!!!\n",__FUNCTION__);
  210. return NULL;
  211. }
  212. }
  213. eth_type = RTW_GET_BE16(&sub_skb->data[6]);
  214. if (sub_skb->len >= 8 &&
  215. ((_rtw_memcmp(sub_skb->data, rtw_rfc1042_header, SNAP_SIZE) &&
  216. eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) ||
  217. _rtw_memcmp(sub_skb->data, rtw_bridge_tunnel_header, SNAP_SIZE) )) {
  218. /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */
  219. skb_pull(sub_skb, SNAP_SIZE);
  220. _rtw_memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN);
  221. _rtw_memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, ETH_ALEN);
  222. } else {
  223. u16 len;
  224. /* Leave Ethernet header part of hdr and full payload */
  225. len = htons(sub_skb->len);
  226. _rtw_memcpy(skb_push(sub_skb, 2), &len, 2);
  227. _rtw_memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN);
  228. _rtw_memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, ETH_ALEN);
  229. }
  230. return sub_skb;
  231. }
  232. void rtw_os_recv_indicate_pkt(_adapter *padapter, _pkt *pkt, struct rx_pkt_attrib *pattrib)
  233. {
  234. struct mlme_priv*pmlmepriv = &padapter->mlmepriv;
  235. #ifdef CONFIG_BR_EXT
  236. void *br_port = NULL;
  237. #endif
  238. /* Indicat the packets to upper layer */
  239. if (pkt) {
  240. if(check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE)
  241. {
  242. _pkt *pskb2=NULL;
  243. struct sta_info *psta = NULL;
  244. struct sta_priv *pstapriv = &padapter->stapriv;
  245. int bmcast = IS_MCAST(pattrib->dst);
  246. //DBG_871X("bmcast=%d\n", bmcast);
  247. if(_rtw_memcmp(pattrib->dst, myid(&padapter->eeprompriv), ETH_ALEN)==_FALSE)
  248. {
  249. //DBG_871X("not ap psta=%p, addr=%pM\n", psta, pattrib->dst);
  250. if(bmcast)
  251. {
  252. psta = rtw_get_bcmc_stainfo(padapter);
  253. pskb2 = skb_clone(pkt, GFP_ATOMIC);
  254. } else {
  255. psta = rtw_get_stainfo(pstapriv, pattrib->dst);
  256. }
  257. if(psta)
  258. {
  259. struct net_device *pnetdev= (struct net_device*)padapter->pnetdev;
  260. //DBG_871X("directly forwarding to the rtw_xmit_entry\n");
  261. //skb->ip_summed = CHECKSUM_NONE;
  262. pkt->dev = pnetdev;
  263. #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,35))
  264. skb_set_queue_mapping(pkt, rtw_recv_select_queue(pkt));
  265. #endif //LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,35)
  266. rtw_xmit_entry(pkt, pnetdev);
  267. if(bmcast && (pskb2 != NULL) ) {
  268. pkt = pskb2;
  269. } else {
  270. return;
  271. }
  272. }
  273. }
  274. else// to APself
  275. {
  276. //DBG_871X("to APSelf\n");
  277. }
  278. }
  279. #ifdef CONFIG_BR_EXT
  280. // Insert NAT2.5 RX here!
  281. #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))
  282. br_port = padapter->pnetdev->br_port;
  283. #else // (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))
  284. rcu_read_lock();
  285. br_port = rcu_dereference(padapter->pnetdev->rx_handler_data);
  286. rcu_read_unlock();
  287. #endif // (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))
  288. if( br_port && (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) == _TRUE) )
  289. {
  290. int nat25_handle_frame(_adapter *priv, struct sk_buff *skb);
  291. if (nat25_handle_frame(padapter, pkt) == -1) {
  292. //priv->ext_stats.rx_data_drops++;
  293. //DEBUG_ERR("RX DROP: nat25_handle_frame fail!\n");
  294. //return FAIL;
  295. #if 1
  296. // bypass this frame to upper layer!!
  297. #else
  298. dev_kfree_skb_any(sub_skb);
  299. continue;
  300. #endif
  301. }
  302. }
  303. #endif // CONFIG_BR_EXT
  304. pkt->protocol = eth_type_trans(pkt, padapter->pnetdev);
  305. pkt->dev = padapter->pnetdev;
  306. #ifdef CONFIG_TCP_CSUM_OFFLOAD_RX
  307. if ( (pattrib->tcpchk_valid == 1) && (pattrib->tcp_chkrpt == 1) ) {
  308. pkt->ip_summed = CHECKSUM_UNNECESSARY;
  309. } else {
  310. pkt->ip_summed = CHECKSUM_NONE;
  311. }
  312. #else /* !CONFIG_TCP_CSUM_OFFLOAD_RX */
  313. pkt->ip_summed = CHECKSUM_NONE;
  314. #endif //CONFIG_TCP_CSUM_OFFLOAD_RX
  315. netif_rx(pkt);
  316. }
  317. }
  318. void rtw_handle_tkip_mic_err(_adapter *padapter,u8 bgroup)
  319. {
  320. #ifdef CONFIG_IOCTL_CFG80211
  321. enum nl80211_key_type key_type;
  322. #endif
  323. union iwreq_data wrqu;
  324. struct iw_michaelmicfailure ev;
  325. struct mlme_priv* pmlmepriv = &padapter->mlmepriv;
  326. struct security_priv *psecuritypriv = &padapter->securitypriv;
  327. u32 cur_time = 0;
  328. if( psecuritypriv->last_mic_err_time == 0 )
  329. {
  330. psecuritypriv->last_mic_err_time = rtw_get_current_time();
  331. }
  332. else
  333. {
  334. cur_time = rtw_get_current_time();
  335. if( cur_time - psecuritypriv->last_mic_err_time < 60*HZ )
  336. {
  337. psecuritypriv->btkip_countermeasure = _TRUE;
  338. psecuritypriv->last_mic_err_time = 0;
  339. psecuritypriv->btkip_countermeasure_time = cur_time;
  340. }
  341. else
  342. {
  343. psecuritypriv->last_mic_err_time = rtw_get_current_time();
  344. }
  345. }
  346. #ifdef CONFIG_IOCTL_CFG80211
  347. if ( bgroup )
  348. {
  349. key_type |= NL80211_KEYTYPE_GROUP;
  350. }
  351. else
  352. {
  353. key_type |= NL80211_KEYTYPE_PAIRWISE;
  354. }
  355. cfg80211_michael_mic_failure(padapter->pnetdev, (u8 *)&pmlmepriv->assoc_bssid[ 0 ], key_type, -1,
  356. NULL, GFP_ATOMIC);
  357. #endif
  358. _rtw_memset( &ev, 0x00, sizeof( ev ) );
  359. if ( bgroup )
  360. {
  361. ev.flags |= IW_MICFAILURE_GROUP;
  362. }
  363. else
  364. {
  365. ev.flags |= IW_MICFAILURE_PAIRWISE;
  366. }
  367. ev.src_addr.sa_family = ARPHRD_ETHER;
  368. _rtw_memcpy( ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN );
  369. _rtw_memset( &wrqu, 0x00, sizeof( wrqu ) );
  370. wrqu.data.length = sizeof( ev );
  371. #ifndef CONFIG_IOCTL_CFG80211
  372. wireless_send_event( padapter->pnetdev, IWEVMICHAELMICFAILURE, &wrqu, (char*) &ev );
  373. #endif
  374. }
  375. void rtw_hostapd_mlme_rx(_adapter *padapter, union recv_frame *precv_frame)
  376. {
  377. #ifdef CONFIG_HOSTAPD_MLME
  378. _pkt *skb;
  379. struct hostapd_priv *phostapdpriv = padapter->phostapdpriv;
  380. struct net_device *pmgnt_netdev = phostapdpriv->pmgnt_netdev;
  381. RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("+rtw_hostapd_mlme_rx\n"));
  382. skb = precv_frame->u.hdr.pkt;
  383. if (skb == NULL)
  384. return;
  385. skb->data = precv_frame->u.hdr.rx_data;
  386. skb->tail = precv_frame->u.hdr.rx_tail;
  387. skb->len = precv_frame->u.hdr.len;
  388. //pskb_copy = skb_copy(skb, GFP_ATOMIC);
  389. // if(skb == NULL) goto _exit;
  390. skb->dev = pmgnt_netdev;
  391. skb->ip_summed = CHECKSUM_NONE;
  392. skb->pkt_type = PACKET_OTHERHOST;
  393. //skb->protocol = __constant_htons(0x0019); /*ETH_P_80211_RAW*/
  394. skb->protocol = __constant_htons(0x0003); /*ETH_P_80211_RAW*/
  395. //DBG_871X("(1)data=0x%x, head=0x%x, tail=0x%x, mac_header=0x%x, len=%d\n", skb->data, skb->head, skb->tail, skb->mac_header, skb->len);
  396. //skb->mac.raw = skb->data;
  397. skb_reset_mac_header(skb);
  398. //skb_pull(skb, 24);
  399. _rtw_memset(skb->cb, 0, sizeof(skb->cb));
  400. netif_rx(skb);
  401. precv_frame->u.hdr.pkt = NULL; // set pointer to NULL before rtw_free_recvframe() if call netif_rx()
  402. #endif
  403. }
  404. #ifdef CONFIG_AUTO_AP_MODE
  405. static void rtw_os_ksocket_send(_adapter *padapter, union recv_frame *precv_frame)
  406. {
  407. _pkt *skb = precv_frame->u.hdr.pkt;
  408. struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
  409. struct sta_info *psta = precv_frame->u.hdr.psta;
  410. DBG_871X("eth rx: got eth_type=0x%x\n", pattrib->eth_type);
  411. if (psta && psta->isrc && psta->pid>0)
  412. {
  413. u16 rx_pid;
  414. rx_pid = *(u16*)(skb->data+ETH_HLEN);
  415. DBG_871X("eth rx(pid=0x%x): sta("MAC_FMT") pid=0x%x\n",
  416. rx_pid, MAC_ARG(psta->hwaddr), psta->pid);
  417. if(rx_pid == psta->pid)
  418. {
  419. int i;
  420. u16 len = *(u16*)(skb->data+ETH_HLEN+2);
  421. //u16 ctrl_type = *(u16*)(skb->data+ETH_HLEN+4);
  422. //DBG_871X("eth, RC: len=0x%x, ctrl_type=0x%x\n", len, ctrl_type);
  423. DBG_871X("eth, RC: len=0x%x\n", len);
  424. for(i=0;i<len;i++)
  425. DBG_871X("0x%x\n", *(skb->data+ETH_HLEN+4+i));
  426. //DBG_871X("0x%x\n", *(skb->data+ETH_HLEN+6+i));
  427. DBG_871X("eth, RC-end\n");
  428. #if 0
  429. //send_sz = ksocket_send(padapter->ksock_send, &padapter->kaddr_send, (skb->data+ETH_HLEN+2), len);
  430. rtw_recv_ksocket_send_cmd(padapter, (skb->data+ETH_HLEN+2), len);
  431. //DBG_871X("ksocket_send size=%d\n", send_sz);
  432. #endif
  433. }
  434. }
  435. }
  436. #endif //CONFIG_AUTO_AP_MODE
  437. int rtw_recv_indicatepkt(_adapter *padapter, union recv_frame *precv_frame)
  438. {
  439. struct recv_priv *precvpriv;
  440. _queue *pfree_recv_queue;
  441. _pkt *skb;
  442. struct mlme_priv*pmlmepriv = &padapter->mlmepriv;
  443. struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
  444. _func_enter_;
  445. precvpriv = &(padapter->recvpriv);
  446. pfree_recv_queue = &(precvpriv->free_recv_queue);
  447. #ifdef CONFIG_DRVEXT_MODULE
  448. if (drvext_rx_handler(padapter, precv_frame->u.hdr.rx_data, precv_frame->u.hdr.len) == _SUCCESS)
  449. {
  450. goto _recv_indicatepkt_drop;
  451. }
  452. #endif
  453. #ifdef CONFIG_WAPI_SUPPORT
  454. if (rtw_wapi_check_for_drop(padapter,precv_frame))
  455. {
  456. WAPI_TRACE(WAPI_ERR, "%s(): Rx Reorder Drop case!!\n", __FUNCTION__);
  457. goto _recv_indicatepkt_drop;
  458. }
  459. #endif
  460. skb = precv_frame->u.hdr.pkt;
  461. if(skb == NULL)
  462. {
  463. RT_TRACE(_module_recv_osdep_c_,_drv_err_,("rtw_recv_indicatepkt():skb==NULL something wrong!!!!\n"));
  464. goto _recv_indicatepkt_drop;
  465. }
  466. RT_TRACE(_module_recv_osdep_c_,_drv_info_,("rtw_recv_indicatepkt():skb != NULL !!!\n"));
  467. 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));
  468. 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));
  469. skb->data = precv_frame->u.hdr.rx_data;
  470. skb_set_tail_pointer(skb, precv_frame->u.hdr.len);
  471. skb->len = precv_frame->u.hdr.len;
  472. 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, skb->end, skb->len));
  473. #ifdef CONFIG_AUTO_AP_MODE
  474. #if 1 //for testing
  475. #if 1
  476. if (0x8899 == pattrib->eth_type)
  477. {
  478. rtw_os_ksocket_send(padapter, precv_frame);
  479. //goto _recv_indicatepkt_drop;
  480. }
  481. #else
  482. if (0x8899 == pattrib->eth_type)
  483. {
  484. rtw_auto_ap_mode_rx(padapter, precv_frame);
  485. goto _recv_indicatepkt_end;
  486. }
  487. #endif
  488. #endif
  489. #endif //CONFIG_AUTO_AP_MODE
  490. rtw_os_recv_indicate_pkt(padapter, skb, pattrib);
  491. _recv_indicatepkt_end:
  492. precv_frame->u.hdr.pkt = NULL; // pointers to NULL before rtw_free_recvframe()
  493. rtw_free_recvframe(precv_frame, pfree_recv_queue);
  494. RT_TRACE(_module_recv_osdep_c_,_drv_info_,("\n rtw_recv_indicatepkt :after netif_rx!!!!\n"));
  495. _func_exit_;
  496. return _SUCCESS;
  497. _recv_indicatepkt_drop:
  498. //enqueue back to free_recv_queue
  499. if(precv_frame)
  500. rtw_free_recvframe(precv_frame, pfree_recv_queue);
  501. return _FAIL;
  502. _func_exit_;
  503. }
  504. void rtw_os_read_port(_adapter *padapter, struct recv_buf *precvbuf)
  505. {
  506. struct recv_priv *precvpriv = &padapter->recvpriv;
  507. #ifdef CONFIG_USB_HCI
  508. precvbuf->ref_cnt--;
  509. //free skb in recv_buf
  510. dev_kfree_skb_any(precvbuf->pskb);
  511. precvbuf->pskb = NULL;
  512. precvbuf->reuse = _FALSE;
  513. if(precvbuf->irp_pending == _FALSE)
  514. {
  515. rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf);
  516. }
  517. #endif
  518. #if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
  519. precvbuf->pskb = NULL;
  520. #endif
  521. }
  522. void _rtw_reordering_ctrl_timeout_handler (void *FunctionContext);
  523. void _rtw_reordering_ctrl_timeout_handler (void *FunctionContext)
  524. {
  525. struct recv_reorder_ctrl *preorder_ctrl = (struct recv_reorder_ctrl *)FunctionContext;
  526. rtw_reordering_ctrl_timeout_handler(preorder_ctrl);
  527. }
  528. void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
  529. {
  530. _adapter *padapter = preorder_ctrl->padapter;
  531. _init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev, _rtw_reordering_ctrl_timeout_handler, preorder_ctrl);
  532. }