usb_ops_linux.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243
  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 _HCI_OPS_OS_C_
  21. //#include <drv_types.h>
  22. #include <rtl8812a_hal.h>
  23. static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr)
  24. {
  25. u8 request;
  26. u8 requesttype;
  27. u16 wvalue;
  28. u16 index;
  29. u16 len;
  30. u8 data=0;
  31. _func_enter_;
  32. request = 0x05;
  33. requesttype = 0x01;//read_in
  34. index = 0;//n/a
  35. wvalue = (u16)(addr&0x0000ffff);
  36. len = 1;
  37. usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype);
  38. _func_exit_;
  39. return data;
  40. }
  41. static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr)
  42. {
  43. u8 request;
  44. u8 requesttype;
  45. u16 wvalue;
  46. u16 index;
  47. u16 len;
  48. u16 data=0;
  49. _func_enter_;
  50. request = 0x05;
  51. requesttype = 0x01;//read_in
  52. index = 0;//n/a
  53. wvalue = (u16)(addr&0x0000ffff);
  54. len = 2;
  55. usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype);
  56. _func_exit_;
  57. return data;
  58. }
  59. static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr)
  60. {
  61. u8 request;
  62. u8 requesttype;
  63. u16 wvalue;
  64. u16 index;
  65. u16 len;
  66. u32 data=0;
  67. _func_enter_;
  68. request = 0x05;
  69. requesttype = 0x01;//read_in
  70. index = 0;//n/a
  71. wvalue = (u16)(addr&0x0000ffff);
  72. len = 4;
  73. usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype);
  74. _func_exit_;
  75. return data;
  76. }
  77. static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val)
  78. {
  79. u8 request;
  80. u8 requesttype;
  81. u16 wvalue;
  82. u16 index;
  83. u16 len;
  84. u8 data;
  85. int ret;
  86. _func_enter_;
  87. request = 0x05;
  88. requesttype = 0x00;//write_out
  89. index = 0;//n/a
  90. wvalue = (u16)(addr&0x0000ffff);
  91. len = 1;
  92. data = val;
  93. ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype);
  94. _func_exit_;
  95. return ret;
  96. }
  97. static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val)
  98. {
  99. u8 request;
  100. u8 requesttype;
  101. u16 wvalue;
  102. u16 index;
  103. u16 len;
  104. u16 data;
  105. int ret;
  106. _func_enter_;
  107. request = 0x05;
  108. requesttype = 0x00;//write_out
  109. index = 0;//n/a
  110. wvalue = (u16)(addr&0x0000ffff);
  111. len = 2;
  112. data = val;
  113. ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype);
  114. _func_exit_;
  115. return ret;
  116. }
  117. static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
  118. {
  119. u8 request;
  120. u8 requesttype;
  121. u16 wvalue;
  122. u16 index;
  123. u16 len;
  124. u32 data;
  125. int ret;
  126. _func_enter_;
  127. request = 0x05;
  128. requesttype = 0x00;//write_out
  129. index = 0;//n/a
  130. wvalue = (u16)(addr&0x0000ffff);
  131. len = 4;
  132. data =val;
  133. ret =usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype);
  134. _func_exit_;
  135. return ret;
  136. }
  137. static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata)
  138. {
  139. u8 request;
  140. u8 requesttype;
  141. u16 wvalue;
  142. u16 index;
  143. u16 len;
  144. u8 buf[VENDOR_CMD_MAX_DATA_LEN]={0};
  145. int ret;
  146. _func_enter_;
  147. request = 0x05;
  148. requesttype = 0x00;//write_out
  149. index = 0;//n/a
  150. wvalue = (u16)(addr&0x0000ffff);
  151. len = length;
  152. _rtw_memcpy(buf, pdata, len );
  153. ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, buf, len, requesttype);
  154. _func_exit_;
  155. return ret;
  156. }
  157. #ifdef CONFIG_SUPPORT_USB_INT
  158. void interrupt_handler_8812au(_adapter *padapter,u16 pkt_len,u8 *pbuf)
  159. {
  160. HAL_DATA_TYPE *pHalData=GET_HAL_DATA(padapter);
  161. struct reportpwrstate_parm pwr_rpt;
  162. if ( pkt_len != INTERRUPT_MSG_FORMAT_LEN )
  163. {
  164. DBG_8192C("%s Invalid interrupt content length (%d)!\n", __FUNCTION__, pkt_len);
  165. return ;
  166. }
  167. // HISR
  168. _rtw_memcpy(&(pHalData->IntArray[0]), &(pbuf[USB_INTR_CONTENT_HISR_OFFSET]), 4);
  169. _rtw_memcpy(&(pHalData->IntArray[1]), &(pbuf[USB_INTR_CONTENT_HISRE_OFFSET]), 4);
  170. #if 0 //DBG
  171. {
  172. u32 hisr=0 ,hisr_ex=0;
  173. _rtw_memcpy(&hisr,&(pHalData->IntArray[0]),4);
  174. hisr = le32_to_cpu(hisr);
  175. _rtw_memcpy(&hisr_ex,&(pHalData->IntArray[1]),4);
  176. hisr_ex = le32_to_cpu(hisr_ex);
  177. if((hisr != 0) || (hisr_ex!=0))
  178. DBG_871X("===> %s hisr:0x%08x ,hisr_ex:0x%08x \n",__FUNCTION__,hisr,hisr_ex);
  179. }
  180. #endif
  181. #ifdef CONFIG_LPS_LCLK
  182. if( pHalData->IntArray[0] & IMR_CPWM_88E )
  183. {
  184. _rtw_memcpy(&pwr_rpt.state, &(pbuf[USB_INTR_CONTENT_CPWM1_OFFSET]), 1);
  185. //_rtw_memcpy(&pwr_rpt.state2, &(pbuf[USB_INTR_CONTENT_CPWM2_OFFSET]), 1);
  186. //88e's cpwm value only change BIT0, so driver need to add PS_STATE_S2 for LPS flow.
  187. pwr_rpt.state |= PS_STATE_S2;
  188. _set_workitem(&padapter->pwrctrlpriv.cpwm_event);
  189. }
  190. #endif//CONFIG_LPS_LCLK
  191. #ifdef CONFIG_INTERRUPT_BASED_TXBCN
  192. #ifdef CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT
  193. if (pHalData->IntArray[0] & IMR_BCNDMAINT0_88E)
  194. #endif
  195. #ifdef CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR
  196. if (pHalData->IntArray[0] & (IMR_TBDER_88E|IMR_TBDOK_88E))
  197. #endif
  198. {
  199. struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
  200. #if 0
  201. if(pHalData->IntArray[0] & IMR_BCNDMAINT0_88E)
  202. DBG_8192C("%s: HISR_BCNERLY_INT\n", __func__);
  203. if(pHalData->IntArray[0] & IMR_TBDOK_88E)
  204. DBG_8192C("%s: HISR_TXBCNOK\n", __func__);
  205. if(pHalData->IntArray[0] & IMR_TBDER_88E)
  206. DBG_8192C("%s: HISR_TXBCNERR\n", __func__);
  207. #endif
  208. if(check_fwstate(pmlmepriv, WIFI_AP_STATE))
  209. {
  210. //send_beacon(padapter);
  211. if(pmlmepriv->update_bcn == _TRUE)
  212. {
  213. //tx_beacon_hdl(padapter, NULL);
  214. set_tx_beacon_cmd(padapter);
  215. }
  216. }
  217. #ifdef CONFIG_CONCURRENT_MODE
  218. if(check_buddy_fwstate(padapter, WIFI_AP_STATE))
  219. {
  220. //send_beacon(padapter);
  221. if(padapter->pbuddy_adapter->mlmepriv.update_bcn == _TRUE)
  222. {
  223. //tx_beacon_hdl(padapter, NULL);
  224. set_tx_beacon_cmd(padapter->pbuddy_adapter);
  225. }
  226. }
  227. #endif
  228. }
  229. #endif //CONFIG_INTERRUPT_BASED_TXBCN
  230. #ifdef DBG_CONFIG_ERROR_DETECT_INT
  231. if( pHalData->IntArray[1] & IMR_TXERR_88E )
  232. DBG_871X("===> %s Tx Error Flag Interrupt Status \n",__FUNCTION__);
  233. if( pHalData->IntArray[1] & IMR_RXERR_88E )
  234. DBG_871X("===> %s Rx Error Flag INT Status \n",__FUNCTION__);
  235. if( pHalData->IntArray[1] & IMR_TXFOVW_88E )
  236. DBG_871X("===> %s Transmit FIFO Overflow \n",__FUNCTION__);
  237. if( pHalData->IntArray[1] & IMR_RXFOVW_88E )
  238. DBG_871X("===> %s Receive FIFO Overflow \n",__FUNCTION__);
  239. #endif//DBG_CONFIG_ERROR_DETECT_INT
  240. // C2H Event
  241. if(pbuf[0]!= 0){
  242. _rtw_memcpy(&(pHalData->C2hArray[0]), &(pbuf[USB_INTR_CONTENT_C2H_OFFSET]), 16);
  243. //rtw_c2h_wk_cmd(padapter); to do..
  244. }
  245. }
  246. #endif
  247. #ifdef CONFIG_USB_INTERRUPT_IN_PIPE
  248. static void usb_read_interrupt_complete(struct urb *purb, struct pt_regs *regs)
  249. {
  250. int err;
  251. _adapter *padapter = (_adapter *)purb->context;
  252. if(padapter->bSurpriseRemoved || padapter->bDriverStopped||padapter->bReadPortCancel)
  253. {
  254. DBG_8192C("%s() RX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bReadPortCancel(%d)\n",
  255. __FUNCTION__,padapter->bDriverStopped, padapter->bSurpriseRemoved,padapter->bReadPortCancel);
  256. return;
  257. }
  258. if(purb->status==0)//SUCCESS
  259. {
  260. if (purb->actual_length > INTERRUPT_MSG_FORMAT_LEN)
  261. {
  262. DBG_8192C("usb_read_interrupt_complete: purb->actual_length > INTERRUPT_MSG_FORMAT_LEN(%d)\n",INTERRUPT_MSG_FORMAT_LEN);
  263. }
  264. interrupt_handler_8188eu(padapter, purb->actual_length,purb->transfer_buffer );
  265. err = usb_submit_urb(purb, GFP_ATOMIC);
  266. if((err) && (err != (-EPERM)))
  267. {
  268. DBG_8192C("cannot submit interrupt in-token(err = 0x%08x),urb_status = %d\n",err, purb->status);
  269. }
  270. }
  271. else
  272. {
  273. DBG_8192C("###=> usb_read_interrupt_complete => urb status(%d)\n", purb->status);
  274. switch(purb->status) {
  275. case -EINVAL:
  276. case -EPIPE:
  277. case -ENODEV:
  278. case -ESHUTDOWN:
  279. //padapter->bSurpriseRemoved=_TRUE;
  280. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete:bSurpriseRemoved=TRUE\n"));
  281. case -ENOENT:
  282. padapter->bDriverStopped=_TRUE;
  283. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete:bDriverStopped=TRUE\n"));
  284. break;
  285. case -EPROTO:
  286. break;
  287. case -EINPROGRESS:
  288. DBG_8192C("ERROR: URB IS IN PROGRESS!/n");
  289. break;
  290. default:
  291. break;
  292. }
  293. }
  294. }
  295. static u32 usb_read_interrupt(struct intf_hdl *pintfhdl, u32 addr)
  296. {
  297. int err;
  298. unsigned int pipe;
  299. u32 ret = _SUCCESS;
  300. _adapter *adapter = pintfhdl->padapter;
  301. struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter);
  302. struct recv_priv *precvpriv = &adapter->recvpriv;
  303. struct usb_device *pusbd = pdvobj->pusbdev;
  304. _func_enter_;
  305. //translate DMA FIFO addr to pipehandle
  306. pipe = ffaddr2pipehdl(pdvobj, addr);
  307. usb_fill_int_urb(precvpriv->int_in_urb, pusbd, pipe,
  308. precvpriv->int_in_buf,
  309. INTERRUPT_MSG_FORMAT_LEN,
  310. usb_read_interrupt_complete,
  311. adapter,
  312. 1);
  313. err = usb_submit_urb(precvpriv->int_in_urb, GFP_ATOMIC);
  314. if((err) && (err != (-EPERM)))
  315. {
  316. DBG_8192C("cannot submit interrupt in-token(err = 0x%08x),urb_status = %d\n",err, precvpriv->int_in_urb->status);
  317. ret = _FAIL;
  318. }
  319. _func_exit_;
  320. return ret;
  321. }
  322. #endif
  323. static s32 pre_recv_entry(union recv_frame *precvframe, u8 *pphy_status)
  324. {
  325. s32 ret=_SUCCESS;
  326. #ifdef CONFIG_CONCURRENT_MODE
  327. u8 *primary_myid, *secondary_myid, *paddr1;
  328. union recv_frame *precvframe_if2 = NULL;
  329. _adapter *primary_padapter = precvframe->u.hdr.adapter;
  330. _adapter *secondary_padapter = primary_padapter->pbuddy_adapter;
  331. struct recv_priv *precvpriv = &primary_padapter->recvpriv;
  332. _queue *pfree_recv_queue = &precvpriv->free_recv_queue;
  333. u8 *pbuf = precvframe->u.hdr.rx_data;
  334. if(!secondary_padapter)
  335. return ret;
  336. paddr1 = GetAddr1Ptr(pbuf);
  337. if(IS_MCAST(paddr1) == _FALSE)//unicast packets
  338. {
  339. //primary_myid = myid(&primary_padapter->eeprompriv);
  340. secondary_myid = myid(&secondary_padapter->eeprompriv);
  341. if(_rtw_memcmp(paddr1, secondary_myid, ETH_ALEN))
  342. {
  343. //change to secondary interface
  344. precvframe->u.hdr.adapter = secondary_padapter;
  345. }
  346. //ret = recv_entry(precvframe);
  347. }
  348. else // Handle BC/MC Packets
  349. {
  350. u8 clone = _TRUE;
  351. #if 0
  352. u8 type, subtype, *paddr2, *paddr3;
  353. type = GetFrameType(pbuf);
  354. subtype = GetFrameSubType(pbuf); //bit(7)~bit(2)
  355. switch (type)
  356. {
  357. case WIFI_MGT_TYPE: //Handle BC/MC mgnt Packets
  358. if(subtype == WIFI_BEACON)
  359. {
  360. paddr3 = GetAddr3Ptr(precvframe->u.hdr.rx_data);
  361. if (check_fwstate(&secondary_padapter->mlmepriv, _FW_LINKED) &&
  362. _rtw_memcmp(paddr3, get_bssid(&secondary_padapter->mlmepriv), ETH_ALEN))
  363. {
  364. //change to secondary interface
  365. precvframe->u.hdr.adapter = secondary_padapter;
  366. clone = _FALSE;
  367. }
  368. if(check_fwstate(&primary_padapter->mlmepriv, _FW_LINKED) &&
  369. _rtw_memcmp(paddr3, get_bssid(&primary_padapter->mlmepriv), ETH_ALEN))
  370. {
  371. if(clone==_FALSE)
  372. {
  373. clone = _TRUE;
  374. }
  375. else
  376. {
  377. clone = _FALSE;
  378. }
  379. precvframe->u.hdr.adapter = primary_padapter;
  380. }
  381. if(check_fwstate(&primary_padapter->mlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) ||
  382. check_fwstate(&secondary_padapter->mlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING))
  383. {
  384. clone = _TRUE;
  385. precvframe->u.hdr.adapter = primary_padapter;
  386. }
  387. }
  388. else if(subtype == WIFI_PROBEREQ)
  389. {
  390. //probe req frame is only for interface2
  391. //change to secondary interface
  392. precvframe->u.hdr.adapter = secondary_padapter;
  393. clone = _FALSE;
  394. }
  395. break;
  396. case WIFI_CTRL_TYPE: // Handle BC/MC ctrl Packets
  397. break;
  398. case WIFI_DATA_TYPE: //Handle BC/MC data Packets
  399. //Notes: AP MODE never rx BC/MC data packets
  400. paddr2 = GetAddr2Ptr(precvframe->u.hdr.rx_data);
  401. if(_rtw_memcmp(paddr2, get_bssid(&secondary_padapter->mlmepriv), ETH_ALEN))
  402. {
  403. //change to secondary interface
  404. precvframe->u.hdr.adapter = secondary_padapter;
  405. clone = _FALSE;
  406. }
  407. break;
  408. default:
  409. break;
  410. }
  411. #endif
  412. if(_TRUE == clone)
  413. {
  414. //clone/copy to if2
  415. struct rx_pkt_attrib *pattrib = NULL;
  416. precvframe_if2 = rtw_alloc_recvframe(pfree_recv_queue);
  417. if(precvframe_if2)
  418. {
  419. precvframe_if2->u.hdr.adapter = secondary_padapter;
  420. _rtw_init_listhead(&precvframe_if2->u.hdr.list);
  421. precvframe_if2->u.hdr.precvbuf = NULL; //can't access the precvbuf for new arch.
  422. precvframe_if2->u.hdr.len=0;
  423. _rtw_memcpy(&precvframe_if2->u.hdr.attrib, &precvframe->u.hdr.attrib, sizeof(struct rx_pkt_attrib));
  424. pattrib = &precvframe_if2->u.hdr.attrib;
  425. if(rtw_os_alloc_recvframe(secondary_padapter, precvframe_if2, pbuf, NULL) == _SUCCESS)
  426. {
  427. recvframe_put(precvframe_if2, pattrib->pkt_len);
  428. //recvframe_pull(precvframe_if2, drvinfo_sz + RXDESC_SIZE);
  429. if (pattrib->physt && pphy_status)
  430. rtl8812_query_rx_phy_status(precvframe_if2, pphy_status);
  431. ret = rtw_recv_entry(precvframe_if2);
  432. }
  433. else
  434. {
  435. rtw_free_recvframe(precvframe_if2, pfree_recv_queue);
  436. DBG_8192C("%s()-%d: alloc_skb() failed!\n", __FUNCTION__, __LINE__);
  437. }
  438. }
  439. }
  440. }
  441. //if (precvframe->u.hdr.attrib.physt)
  442. // rtl8812_query_rx_phy_status(precvframe, pphy_status);
  443. //ret = rtw_recv_entry(precvframe);
  444. #endif
  445. return ret;
  446. }
  447. static int recvbuf2recvframe(_adapter *padapter,
  448. #ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX
  449. struct recv_buf *precvbuf
  450. #else
  451. _pkt *pskb
  452. #endif
  453. )
  454. {
  455. u8 *pbuf;
  456. u8 pkt_cnt = 0;
  457. u32 pkt_offset;
  458. s32 transfer_len;
  459. u8 *pphy_status = NULL;
  460. union recv_frame *precvframe = NULL;
  461. struct rx_pkt_attrib *pattrib = NULL;
  462. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
  463. struct recv_priv *precvpriv = &padapter->recvpriv;
  464. _queue *pfree_recv_queue = &precvpriv->free_recv_queue;
  465. #ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX
  466. transfer_len = (s32)precvbuf->transfer_len;
  467. pbuf = precvbuf->pbuf;
  468. #else
  469. transfer_len = (s32)pskb->len;
  470. pbuf = pskb->data;
  471. #endif//CONFIG_USE_USB_BUFFER_ALLOC_RX
  472. #ifdef CONFIG_USB_RX_AGGREGATION
  473. pkt_cnt = GET_RX_STATUS_DESC_USB_AGG_PKTNUM_8812(pbuf);
  474. #endif
  475. do{
  476. precvframe = rtw_alloc_recvframe(pfree_recv_queue);
  477. if(precvframe==NULL)
  478. {
  479. RT_TRACE(_module_rtl871x_recv_c_,_drv_err_,("recvbuf2recvframe: precvframe==NULL\n"));
  480. DBG_8192C("%s()-%d: rtw_alloc_recvframe() failed! RX Drop!\n", __FUNCTION__, __LINE__);
  481. goto _exit_recvbuf2recvframe;
  482. }
  483. _rtw_init_listhead(&precvframe->u.hdr.list);
  484. precvframe->u.hdr.precvbuf = NULL; //can't access the precvbuf for new arch.
  485. precvframe->u.hdr.len=0;
  486. rtl8812_query_rx_desc_status(precvframe, pbuf);
  487. pattrib = &precvframe->u.hdr.attrib;
  488. if ((pattrib->crc_err) || (pattrib->icv_err))
  489. {
  490. DBG_8192C("%s: RX Warning! crc_err=%d icv_err=%d, skip!\n", __FUNCTION__, pattrib->crc_err, pattrib->icv_err);
  491. rtw_free_recvframe(precvframe, pfree_recv_queue);
  492. goto _exit_recvbuf2recvframe;
  493. }
  494. pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len;
  495. if((pattrib->pkt_len<=0) || (pkt_offset>transfer_len))
  496. {
  497. RT_TRACE(_module_rtl871x_recv_c_,_drv_info_,("recvbuf2recvframe: pkt_len<=0\n"));
  498. DBG_8192C("%s()-%d: RX Warning!,pkt_len<=0 or pkt_offset> transfer_len \n", __FUNCTION__, __LINE__);
  499. rtw_free_recvframe(precvframe, pfree_recv_queue);
  500. goto _exit_recvbuf2recvframe;
  501. }
  502. if(rtw_os_alloc_recvframe(padapter, precvframe,
  503. (pbuf+pattrib->shift_sz + pattrib->drvinfo_sz + RXDESC_SIZE),
  504. #ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX
  505. NULL
  506. #else
  507. pskb
  508. #endif
  509. ) == _FAIL)
  510. {
  511. rtw_free_recvframe(precvframe, pfree_recv_queue);
  512. goto _exit_recvbuf2recvframe;
  513. }
  514. recvframe_put(precvframe, pattrib->pkt_len);
  515. //recvframe_pull(precvframe, drvinfo_sz + RXDESC_SIZE);
  516. if(pattrib->pkt_rpt_type == NORMAL_RX)//Normal rx packet
  517. {
  518. if(pattrib->physt)
  519. pphy_status = (pbuf + RXDESC_OFFSET);
  520. #ifdef CONFIG_CONCURRENT_MODE
  521. if(rtw_buddy_adapter_up(padapter))
  522. {
  523. if(pre_recv_entry(precvframe, pphy_status) != _SUCCESS)
  524. {
  525. RT_TRACE(_module_rtl871x_recv_c_,_drv_err_,
  526. ("recvbuf2recvframe: recv_entry(precvframe) != _SUCCESS\n"));
  527. }
  528. }
  529. #endif //CONFIG_CONCURRENT_MODE
  530. if(pattrib->physt && pphy_status)
  531. rtl8812_query_rx_phy_status(precvframe, pphy_status);
  532. if(rtw_recv_entry(precvframe) != _SUCCESS)
  533. {
  534. RT_TRACE(_module_rtl871x_recv_c_,_drv_err_,
  535. ("recvbuf2recvframe: rtw_recv_entry(precvframe) != _SUCCESS\n"));
  536. }
  537. }
  538. else{ // pkt_rpt_type == TX_REPORT1-CCX, TX_REPORT2-TX RTP,HIS_REPORT-USB HISR RTP
  539. if (pattrib->pkt_rpt_type == C2H_PACKET) {
  540. //DBG_8192C("rx C2H_PACKET \n");
  541. //C2HPacketHandler_8812A(padapter,precvframe->u.hdr.rx_data,pattrib->pkt_len);
  542. }
  543. //enqueue recvframe to txrtp queue
  544. else if(pattrib->pkt_rpt_type == TX_REPORT1){
  545. DBG_8192C("rx CCX \n");
  546. }
  547. else if(pattrib->pkt_rpt_type == TX_REPORT2){
  548. //DBG_8192C("rx TX RPT \n");
  549. }
  550. /*else if(pattrib->pkt_rpt_type == HIS_REPORT)
  551. {
  552. //DBG_8192C("%s , rx USB HISR \n",__FUNCTION__);
  553. #ifdef CONFIG_SUPPORT_USB_INT
  554. interrupt_handler_8812au(padapter,pattrib->pkt_len,precvframe->u.hdr.rx_data);
  555. #endif
  556. }*/
  557. rtw_free_recvframe(precvframe, pfree_recv_queue);
  558. }
  559. #ifdef CONFIG_USB_RX_AGGREGATION
  560. // jaguar 8-byte alignment
  561. pkt_offset = (u16)_RND8(pkt_offset);
  562. pkt_cnt--;
  563. pbuf += pkt_offset;
  564. #endif
  565. transfer_len -= pkt_offset;
  566. precvframe = NULL;
  567. }while(transfer_len>0);
  568. _exit_recvbuf2recvframe:
  569. return _SUCCESS;
  570. }
  571. #ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX
  572. void rtl8812au_recv_tasklet(void *priv)
  573. {
  574. struct recv_buf *precvbuf = NULL;
  575. _adapter *padapter = (_adapter*)priv;
  576. struct recv_priv *precvpriv = &padapter->recvpriv;
  577. while (NULL != (precvbuf = rtw_dequeue_recvbuf(&precvpriv->recv_buf_pending_queue)))
  578. {
  579. if ((padapter->bDriverStopped == _TRUE)||(padapter->bSurpriseRemoved== _TRUE))
  580. {
  581. DBG_8192C("recv_tasklet => bDriverStopped or bSurpriseRemoved \n");
  582. break;
  583. }
  584. recvbuf2recvframe(padapter, precvbuf);
  585. rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf);
  586. }
  587. }
  588. static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs)
  589. {
  590. struct recv_buf *precvbuf = (struct recv_buf *)purb->context;
  591. _adapter *padapter =(_adapter *)precvbuf->adapter;
  592. struct recv_priv *precvpriv = &padapter->recvpriv;
  593. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete!!!\n"));
  594. precvpriv->rx_pending_cnt --;
  595. if(padapter->bSurpriseRemoved || padapter->bDriverStopped||padapter->bReadPortCancel)
  596. {
  597. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n", padapter->bDriverStopped, padapter->bSurpriseRemoved));
  598. goto exit;
  599. }
  600. if(purb->status==0)//SUCCESS
  601. {
  602. if ((purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE))
  603. {
  604. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete: (purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)\n"));
  605. rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf);
  606. }
  607. else
  608. {
  609. rtw_reset_continual_urb_error(adapter_to_dvobj(padapter));
  610. precvbuf->transfer_len = purb->actual_length;
  611. //rtw_enqueue_rx_transfer_buffer(precvpriv, rx_transfer_buf);
  612. rtw_enqueue_recvbuf(precvbuf, &precvpriv->recv_buf_pending_queue);
  613. tasklet_schedule(&precvpriv->recv_tasklet);
  614. }
  615. }
  616. else
  617. {
  618. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete : purb->status(%d) != 0 \n", purb->status));
  619. DBG_8192C("###=> usb_read_port_complete => urb status(%d)\n", purb->status);
  620. if(rtw_inc_and_chk_continual_urb_error(adapter_to_dvobj(padapter)) == _TRUE ){
  621. padapter->bSurpriseRemoved = _TRUE;
  622. }
  623. switch(purb->status) {
  624. case -EINVAL:
  625. case -EPIPE:
  626. case -ENODEV:
  627. case -ESHUTDOWN:
  628. //padapter->bSurpriseRemoved=_TRUE;
  629. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete:bSurpriseRemoved=TRUE\n"));
  630. case -ENOENT:
  631. padapter->bDriverStopped=_TRUE;
  632. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete:bDriverStopped=TRUE\n"));
  633. break;
  634. case -EPROTO:
  635. case -EILSEQ:
  636. case -ETIME:
  637. case -ECOMM:
  638. case -EOVERFLOW:
  639. #ifdef DBG_CONFIG_ERROR_DETECT
  640. {
  641. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
  642. pHalData->srestpriv.Wifi_Error_Status = USB_READ_PORT_FAIL;
  643. }
  644. #endif
  645. rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf);
  646. break;
  647. case -EINPROGRESS:
  648. DBG_8192C("ERROR: URB IS IN PROGRESS!/n");
  649. break;
  650. default:
  651. break;
  652. }
  653. }
  654. exit:
  655. _func_exit_;
  656. }
  657. static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem)
  658. {
  659. int err;
  660. unsigned int pipe;
  661. u32 ret = _SUCCESS;
  662. PURB purb = NULL;
  663. struct recv_buf *precvbuf = (struct recv_buf *)rmem;
  664. _adapter *adapter = pintfhdl->padapter;
  665. struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter);
  666. struct recv_priv *precvpriv = &adapter->recvpriv;
  667. struct usb_device *pusbd = pdvobj->pusbdev;
  668. _func_enter_;
  669. if(adapter->bDriverStopped || adapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)
  670. {
  671. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port:( padapter->bDriverStopped ||padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n"));
  672. return _FAIL;
  673. }
  674. if(precvbuf !=NULL)
  675. {
  676. rtl8812au_init_recvbuf(adapter, precvbuf);
  677. if(precvbuf->pbuf)
  678. {
  679. precvpriv->rx_pending_cnt++;
  680. purb = precvbuf->purb;
  681. //translate DMA FIFO addr to pipehandle
  682. pipe = ffaddr2pipehdl(pdvobj, addr);
  683. usb_fill_bulk_urb(purb, pusbd, pipe,
  684. precvbuf->pbuf,
  685. MAX_RECVBUF_SZ,
  686. usb_read_port_complete,
  687. precvbuf);//context is precvbuf
  688. purb->transfer_dma = precvbuf->dma_transfer_addr;
  689. purb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
  690. err = usb_submit_urb(purb, GFP_ATOMIC);
  691. if((err) && (err != (-EPERM)))
  692. {
  693. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("cannot submit rx in-token(err=0x%.8x), URB_STATUS =0x%.8x", err, purb->status));
  694. DBG_8192C("cannot submit rx in-token(err = 0x%08x),urb_status = %d\n",err,purb->status);
  695. ret = _FAIL;
  696. }
  697. }
  698. }
  699. else
  700. {
  701. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port:precvbuf ==NULL\n"));
  702. ret = _FAIL;
  703. }
  704. _func_exit_;
  705. return ret;
  706. }
  707. #else // CONFIG_USE_USB_BUFFER_ALLOC_RX
  708. void rtl8812au_recv_tasklet(void *priv)
  709. {
  710. _pkt *pskb;
  711. _adapter *padapter = (_adapter*)priv;
  712. struct recv_priv *precvpriv = &padapter->recvpriv;
  713. while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue)))
  714. {
  715. if ((padapter->bDriverStopped == _TRUE)||(padapter->bSurpriseRemoved== _TRUE))
  716. {
  717. DBG_8192C("recv_tasklet => bDriverStopped or bSurpriseRemoved \n");
  718. dev_kfree_skb_any(pskb);
  719. break;
  720. }
  721. recvbuf2recvframe(padapter, pskb);
  722. #ifdef CONFIG_PREALLOC_RECV_SKB
  723. skb_reset_tail_pointer(pskb);
  724. pskb->len = 0;
  725. skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb);
  726. #else
  727. dev_kfree_skb_any(pskb);
  728. #endif
  729. }
  730. }
  731. static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs)
  732. {
  733. _irqL irqL;
  734. uint isevt, *pbuf;
  735. struct recv_buf *precvbuf = (struct recv_buf *)purb->context;
  736. _adapter *padapter =(_adapter *)precvbuf->adapter;
  737. struct recv_priv *precvpriv = &padapter->recvpriv;
  738. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete!!!\n"));
  739. //_enter_critical(&precvpriv->lock, &irqL);
  740. //precvbuf->irp_pending=_FALSE;
  741. //precvpriv->rx_pending_cnt --;
  742. //_exit_critical(&precvpriv->lock, &irqL);
  743. precvpriv->rx_pending_cnt --;
  744. //if(precvpriv->rx_pending_cnt== 0)
  745. //{
  746. // RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete: rx_pending_cnt== 0, set allrxreturnevt!\n"));
  747. // _rtw_up_sema(&precvpriv->allrxreturnevt);
  748. //}
  749. if(padapter->bSurpriseRemoved || padapter->bDriverStopped||padapter->bReadPortCancel)
  750. {
  751. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n", padapter->bDriverStopped, padapter->bSurpriseRemoved));
  752. #ifdef CONFIG_PREALLOC_RECV_SKB
  753. precvbuf->reuse = _TRUE;
  754. #else
  755. if(precvbuf->pskb){
  756. DBG_8192C("==> free skb(%p)\n",precvbuf->pskb);
  757. dev_kfree_skb_any(precvbuf->pskb);
  758. }
  759. #endif
  760. DBG_8192C("%s() RX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bReadPortCancel(%d)\n",
  761. __FUNCTION__,padapter->bDriverStopped, padapter->bSurpriseRemoved,padapter->bReadPortCancel);
  762. goto exit;
  763. }
  764. if(purb->status==0)//SUCCESS
  765. {
  766. if ((purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE))
  767. {
  768. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete: (purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)\n"));
  769. precvbuf->reuse = _TRUE;
  770. rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf);
  771. DBG_8192C("%s()-%d: RX Warning!\n", __FUNCTION__, __LINE__);
  772. }
  773. else
  774. {
  775. rtw_reset_continual_urb_error(adapter_to_dvobj(padapter));
  776. precvbuf->transfer_len = purb->actual_length;
  777. skb_put(precvbuf->pskb, purb->actual_length);
  778. skb_queue_tail(&precvpriv->rx_skb_queue, precvbuf->pskb);
  779. if (skb_queue_len(&precvpriv->rx_skb_queue)<=1)
  780. tasklet_schedule(&precvpriv->recv_tasklet);
  781. precvbuf->pskb = NULL;
  782. precvbuf->reuse = _FALSE;
  783. rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf);
  784. }
  785. }
  786. else
  787. {
  788. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete : purb->status(%d) != 0 \n", purb->status));
  789. DBG_8192C("###=> usb_read_port_complete => urb status(%d)\n", purb->status);
  790. if(rtw_inc_and_chk_continual_urb_error(adapter_to_dvobj(padapter)) == _TRUE ){
  791. padapter->bSurpriseRemoved = _TRUE;
  792. }
  793. switch(purb->status) {
  794. case -EINVAL:
  795. case -EPIPE:
  796. case -ENODEV:
  797. case -ESHUTDOWN:
  798. //padapter->bSurpriseRemoved=_TRUE;
  799. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete:bSurpriseRemoved=TRUE\n"));
  800. case -ENOENT:
  801. padapter->bDriverStopped=_TRUE;
  802. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete:bDriverStopped=TRUE\n"));
  803. break;
  804. case -EPROTO:
  805. case -EILSEQ:
  806. case -ETIME:
  807. case -ECOMM:
  808. case -EOVERFLOW:
  809. #ifdef DBG_CONFIG_ERROR_DETECT
  810. {
  811. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
  812. pHalData->srestpriv.Wifi_Error_Status = USB_READ_PORT_FAIL;
  813. }
  814. #endif
  815. precvbuf->reuse = _TRUE;
  816. rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf);
  817. break;
  818. case -EINPROGRESS:
  819. DBG_8192C("ERROR: URB IS IN PROGRESS!/n");
  820. break;
  821. default:
  822. break;
  823. }
  824. }
  825. exit:
  826. _func_exit_;
  827. }
  828. static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem)
  829. {
  830. _irqL irqL;
  831. int err;
  832. unsigned int pipe;
  833. SIZE_PTR tmpaddr=0;
  834. SIZE_PTR alignment=0;
  835. u32 ret = _SUCCESS;
  836. PURB purb = NULL;
  837. struct recv_buf *precvbuf = (struct recv_buf *)rmem;
  838. _adapter *adapter = pintfhdl->padapter;
  839. struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter);
  840. struct recv_priv *precvpriv = &adapter->recvpriv;
  841. struct usb_device *pusbd = pdvobj->pusbdev;
  842. _func_enter_;
  843. if(adapter->bDriverStopped || adapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)
  844. {
  845. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port:( padapter->bDriverStopped ||padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n"));
  846. return _FAIL;
  847. }
  848. #ifdef CONFIG_PREALLOC_RECV_SKB
  849. if((precvbuf->reuse == _FALSE) || (precvbuf->pskb == NULL))
  850. {
  851. if (NULL != (precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue)))
  852. {
  853. precvbuf->reuse = _TRUE;
  854. }
  855. }
  856. #endif
  857. if(precvbuf !=NULL)
  858. {
  859. rtl8812au_init_recvbuf(adapter, precvbuf);
  860. //re-assign for linux based on skb
  861. if((precvbuf->reuse == _FALSE) || (precvbuf->pskb == NULL))
  862. {
  863. //precvbuf->pskb = alloc_skb(MAX_RECVBUF_SZ, GFP_ATOMIC);//don't use this after v2.6.25
  864. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) // http://www.mail-archive.com/netdev@vger.kernel.org/msg17214.html
  865. precvbuf->pskb = dev_alloc_skb(MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
  866. #else
  867. precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
  868. #endif
  869. if(precvbuf->pskb == NULL)
  870. {
  871. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("init_recvbuf(): alloc_skb fail!\n"));
  872. DBG_8192C("#### usb_read_port() alloc_skb fail!#####\n");
  873. return _FAIL;
  874. }
  875. tmpaddr = (SIZE_PTR)precvbuf->pskb->data;
  876. alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1);
  877. skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment));
  878. precvbuf->phead = precvbuf->pskb->head;
  879. precvbuf->pdata = precvbuf->pskb->data;
  880. precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
  881. precvbuf->pend = skb_end_pointer(precvbuf->pskb);
  882. precvbuf->pbuf = precvbuf->pskb->data;
  883. }
  884. else//reuse skb
  885. {
  886. precvbuf->phead = precvbuf->pskb->head;
  887. precvbuf->pdata = precvbuf->pskb->data;
  888. precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
  889. precvbuf->pend = skb_end_pointer(precvbuf->pskb);
  890. precvbuf->pbuf = precvbuf->pskb->data;
  891. precvbuf->reuse = _FALSE;
  892. }
  893. //_enter_critical(&precvpriv->lock, &irqL);
  894. //precvpriv->rx_pending_cnt++;
  895. //precvbuf->irp_pending = _TRUE;
  896. //_exit_critical(&precvpriv->lock, &irqL);
  897. precvpriv->rx_pending_cnt++;
  898. purb = precvbuf->purb;
  899. //translate DMA FIFO addr to pipehandle
  900. pipe = ffaddr2pipehdl(pdvobj, addr);
  901. usb_fill_bulk_urb(purb, pusbd, pipe,
  902. precvbuf->pbuf,
  903. MAX_RECVBUF_SZ,
  904. usb_read_port_complete,
  905. precvbuf);//context is precvbuf
  906. err = usb_submit_urb(purb, GFP_ATOMIC);
  907. if((err) && (err != (-EPERM)))
  908. {
  909. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("cannot submit rx in-token(err=0x%.8x), URB_STATUS =0x%.8x", err, purb->status));
  910. DBG_8192C("cannot submit rx in-token(err = 0x%08x),urb_status = %d\n",err,purb->status);
  911. ret = _FAIL;
  912. }
  913. }
  914. else
  915. {
  916. RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port:precvbuf ==NULL\n"));
  917. ret = _FAIL;
  918. }
  919. _func_exit_;
  920. return ret;
  921. }
  922. #endif // CONFIG_USE_USB_BUFFER_ALLOC_RX
  923. void rtl8812au_xmit_tasklet(void *priv)
  924. {
  925. int ret = _FALSE;
  926. _adapter *padapter = (_adapter*)priv;
  927. struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
  928. if(check_fwstate(&padapter->mlmepriv, _FW_UNDER_SURVEY) == _TRUE)
  929. return;
  930. while(1)
  931. {
  932. if ((padapter->bDriverStopped == _TRUE)||(padapter->bSurpriseRemoved== _TRUE) || (padapter->bWritePortCancel == _TRUE))
  933. {
  934. DBG_8192C("xmit_tasklet => bDriverStopped or bSurpriseRemoved or bWritePortCancel\n");
  935. break;
  936. }
  937. ret = rtl8812au_xmitframe_complete(padapter, pxmitpriv, NULL);
  938. if(ret==_FALSE)
  939. break;
  940. }
  941. }
  942. void rtl8812au_set_intf_ops(struct _io_ops *pops)
  943. {
  944. _func_enter_;
  945. _rtw_memset((u8 *)pops, 0, sizeof(struct _io_ops));
  946. pops->_read8 = &usb_read8;
  947. pops->_read16 = &usb_read16;
  948. pops->_read32 = &usb_read32;
  949. pops->_read_mem = &usb_read_mem;
  950. pops->_read_port = &usb_read_port;
  951. pops->_write8 = &usb_write8;
  952. pops->_write16 = &usb_write16;
  953. pops->_write32 = &usb_write32;
  954. pops->_writeN = &usb_writeN;
  955. #ifdef CONFIG_USB_SUPPORT_ASYNC_VDN_REQ
  956. pops->_write8_async= &usb_async_write8;
  957. pops->_write16_async = &usb_async_write16;
  958. pops->_write32_async = &usb_async_write32;
  959. #endif
  960. pops->_write_mem = &usb_write_mem;
  961. pops->_write_port = &usb_write_port;
  962. pops->_read_port_cancel = &usb_read_port_cancel;
  963. pops->_write_port_cancel = &usb_write_port_cancel;
  964. #ifdef CONFIG_USB_INTERRUPT_IN_PIPE
  965. pops->_read_interrupt = &usb_read_interrupt;
  966. #endif
  967. _func_exit_;
  968. }
  969. void rtl8812au_set_hw_type(_adapter *padapter)
  970. {
  971. if(padapter->chip_type == RTL8812)
  972. {
  973. padapter->HardwareType = HARDWARE_TYPE_RTL8812AU;
  974. DBG_871X("CHIP TYPE: RTL8812\n");
  975. }
  976. else if(padapter->chip_type == RTL8821)
  977. {
  978. //padapter->HardwareType = HARDWARE_TYPE_RTL8811AU;
  979. padapter->HardwareType = HARDWARE_TYPE_RTL8821U;
  980. DBG_871X("CHIP TYPE: RTL8811AU or RTL8821U\n");
  981. }
  982. }