usb.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009-2012 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. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * wlanfae <wlanfae@realtek.com>
  23. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  24. * Hsinchu 300, Taiwan.
  25. *
  26. *****************************************************************************/
  27. #include "wifi.h"
  28. #include "core.h"
  29. #include "usb.h"
  30. #include "base.h"
  31. #include "ps.h"
  32. #include "rtl8192c/fw_common.h"
  33. #include <linux/export.h>
  34. #define REALTEK_USB_VENQT_READ 0xC0
  35. #define REALTEK_USB_VENQT_WRITE 0x40
  36. #define REALTEK_USB_VENQT_CMD_REQ 0x05
  37. #define REALTEK_USB_VENQT_CMD_IDX 0x00
  38. #define MAX_USBCTRL_VENDORREQ_TIMES 10
  39. static void usbctrl_async_callback(struct urb *urb)
  40. {
  41. if (urb) {
  42. /* free dr */
  43. kfree(urb->setup_packet);
  44. /* free databuf */
  45. kfree(urb->transfer_buffer);
  46. }
  47. }
  48. static int _usbctrl_vendorreq_async_write(struct usb_device *udev, u8 request,
  49. u16 value, u16 index, void *pdata,
  50. u16 len)
  51. {
  52. int rc;
  53. unsigned int pipe;
  54. u8 reqtype;
  55. struct usb_ctrlrequest *dr;
  56. struct urb *urb;
  57. const u16 databuf_maxlen = REALTEK_USB_VENQT_MAX_BUF_SIZE;
  58. u8 *databuf;
  59. if (WARN_ON_ONCE(len > databuf_maxlen))
  60. len = databuf_maxlen;
  61. pipe = usb_sndctrlpipe(udev, 0); /* write_out */
  62. reqtype = REALTEK_USB_VENQT_WRITE;
  63. dr = kmalloc(sizeof(*dr), GFP_ATOMIC);
  64. if (!dr)
  65. return -ENOMEM;
  66. databuf = kmalloc(databuf_maxlen, GFP_ATOMIC);
  67. if (!databuf) {
  68. kfree(dr);
  69. return -ENOMEM;
  70. }
  71. urb = usb_alloc_urb(0, GFP_ATOMIC);
  72. if (!urb) {
  73. kfree(databuf);
  74. kfree(dr);
  75. return -ENOMEM;
  76. }
  77. dr->bRequestType = reqtype;
  78. dr->bRequest = request;
  79. dr->wValue = cpu_to_le16(value);
  80. dr->wIndex = cpu_to_le16(index);
  81. dr->wLength = cpu_to_le16(len);
  82. /* data are already in little-endian order */
  83. memcpy(databuf, pdata, len);
  84. usb_fill_control_urb(urb, udev, pipe,
  85. (unsigned char *)dr, databuf, len,
  86. usbctrl_async_callback, NULL);
  87. rc = usb_submit_urb(urb, GFP_ATOMIC);
  88. if (rc < 0) {
  89. kfree(databuf);
  90. kfree(dr);
  91. }
  92. usb_free_urb(urb);
  93. return rc;
  94. }
  95. static int _usbctrl_vendorreq_sync_read(struct usb_device *udev, u8 request,
  96. u16 value, u16 index, void *pdata,
  97. u16 len)
  98. {
  99. unsigned int pipe;
  100. int status;
  101. u8 reqtype;
  102. int vendorreq_times = 0;
  103. static int count;
  104. pipe = usb_rcvctrlpipe(udev, 0); /* read_in */
  105. reqtype = REALTEK_USB_VENQT_READ;
  106. do {
  107. status = usb_control_msg(udev, pipe, request, reqtype, value,
  108. index, pdata, len, 0); /*max. timeout*/
  109. if (status < 0) {
  110. /* firmware download is checksumed, don't retry */
  111. if ((value >= FW_8192C_START_ADDRESS &&
  112. value <= FW_8192C_END_ADDRESS))
  113. break;
  114. } else {
  115. break;
  116. }
  117. } while (++vendorreq_times < MAX_USBCTRL_VENDORREQ_TIMES);
  118. if (status < 0 && count++ < 4)
  119. pr_err("reg 0x%x, usbctrl_vendorreq TimeOut! status:0x%x value=0x%x\n",
  120. value, status, *(u32 *)pdata);
  121. return status;
  122. }
  123. static u32 _usb_read_sync(struct rtl_priv *rtlpriv, u32 addr, u16 len)
  124. {
  125. struct device *dev = rtlpriv->io.dev;
  126. struct usb_device *udev = to_usb_device(dev);
  127. u8 request;
  128. u16 wvalue;
  129. u16 index;
  130. __le32 *data;
  131. unsigned long flags;
  132. spin_lock_irqsave(&rtlpriv->locks.usb_lock, flags);
  133. if (++rtlpriv->usb_data_index >= RTL_USB_MAX_RX_COUNT)
  134. rtlpriv->usb_data_index = 0;
  135. data = &rtlpriv->usb_data[rtlpriv->usb_data_index];
  136. spin_unlock_irqrestore(&rtlpriv->locks.usb_lock, flags);
  137. request = REALTEK_USB_VENQT_CMD_REQ;
  138. index = REALTEK_USB_VENQT_CMD_IDX; /* n/a */
  139. wvalue = (u16)addr;
  140. _usbctrl_vendorreq_sync_read(udev, request, wvalue, index, data, len);
  141. return le32_to_cpu(*data);
  142. }
  143. static u8 _usb_read8_sync(struct rtl_priv *rtlpriv, u32 addr)
  144. {
  145. return (u8)_usb_read_sync(rtlpriv, addr, 1);
  146. }
  147. static u16 _usb_read16_sync(struct rtl_priv *rtlpriv, u32 addr)
  148. {
  149. return (u16)_usb_read_sync(rtlpriv, addr, 2);
  150. }
  151. static u32 _usb_read32_sync(struct rtl_priv *rtlpriv, u32 addr)
  152. {
  153. return _usb_read_sync(rtlpriv, addr, 4);
  154. }
  155. static void _usb_write_async(struct usb_device *udev, u32 addr, u32 val,
  156. u16 len)
  157. {
  158. u8 request;
  159. u16 wvalue;
  160. u16 index;
  161. __le32 data;
  162. request = REALTEK_USB_VENQT_CMD_REQ;
  163. index = REALTEK_USB_VENQT_CMD_IDX; /* n/a */
  164. wvalue = (u16)(addr&0x0000ffff);
  165. data = cpu_to_le32(val);
  166. _usbctrl_vendorreq_async_write(udev, request, wvalue, index, &data,
  167. len);
  168. }
  169. static void _usb_write8_async(struct rtl_priv *rtlpriv, u32 addr, u8 val)
  170. {
  171. struct device *dev = rtlpriv->io.dev;
  172. _usb_write_async(to_usb_device(dev), addr, val, 1);
  173. }
  174. static void _usb_write16_async(struct rtl_priv *rtlpriv, u32 addr, u16 val)
  175. {
  176. struct device *dev = rtlpriv->io.dev;
  177. _usb_write_async(to_usb_device(dev), addr, val, 2);
  178. }
  179. static void _usb_write32_async(struct rtl_priv *rtlpriv, u32 addr, u32 val)
  180. {
  181. struct device *dev = rtlpriv->io.dev;
  182. _usb_write_async(to_usb_device(dev), addr, val, 4);
  183. }
  184. static void _usb_writeN_sync(struct rtl_priv *rtlpriv, u32 addr, void *data,
  185. u16 len)
  186. {
  187. struct device *dev = rtlpriv->io.dev;
  188. struct usb_device *udev = to_usb_device(dev);
  189. u8 request = REALTEK_USB_VENQT_CMD_REQ;
  190. u8 reqtype = REALTEK_USB_VENQT_WRITE;
  191. u16 wvalue;
  192. u16 index = REALTEK_USB_VENQT_CMD_IDX;
  193. int pipe = usb_sndctrlpipe(udev, 0); /* write_out */
  194. u8 *buffer;
  195. wvalue = (u16)(addr & 0x0000ffff);
  196. buffer = kmemdup(data, len, GFP_ATOMIC);
  197. if (!buffer)
  198. return;
  199. usb_control_msg(udev, pipe, request, reqtype, wvalue,
  200. index, buffer, len, 50);
  201. kfree(buffer);
  202. }
  203. static void _rtl_usb_io_handler_init(struct device *dev,
  204. struct ieee80211_hw *hw)
  205. {
  206. struct rtl_priv *rtlpriv = rtl_priv(hw);
  207. rtlpriv->io.dev = dev;
  208. mutex_init(&rtlpriv->io.bb_mutex);
  209. rtlpriv->io.write8_async = _usb_write8_async;
  210. rtlpriv->io.write16_async = _usb_write16_async;
  211. rtlpriv->io.write32_async = _usb_write32_async;
  212. rtlpriv->io.read8_sync = _usb_read8_sync;
  213. rtlpriv->io.read16_sync = _usb_read16_sync;
  214. rtlpriv->io.read32_sync = _usb_read32_sync;
  215. rtlpriv->io.writeN_sync = _usb_writeN_sync;
  216. }
  217. static void _rtl_usb_io_handler_release(struct ieee80211_hw *hw)
  218. {
  219. struct rtl_priv __maybe_unused *rtlpriv = rtl_priv(hw);
  220. mutex_destroy(&rtlpriv->io.bb_mutex);
  221. }
  222. /**
  223. *
  224. * Default aggregation handler. Do nothing and just return the oldest skb.
  225. */
  226. static struct sk_buff *_none_usb_tx_aggregate_hdl(struct ieee80211_hw *hw,
  227. struct sk_buff_head *list)
  228. {
  229. return skb_dequeue(list);
  230. }
  231. #define IS_HIGH_SPEED_USB(udev) \
  232. ((USB_SPEED_HIGH == (udev)->speed) ? true : false)
  233. static int _rtl_usb_init_tx(struct ieee80211_hw *hw)
  234. {
  235. u32 i;
  236. struct rtl_priv *rtlpriv = rtl_priv(hw);
  237. struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
  238. rtlusb->max_bulk_out_size = IS_HIGH_SPEED_USB(rtlusb->udev)
  239. ? USB_HIGH_SPEED_BULK_SIZE
  240. : USB_FULL_SPEED_BULK_SIZE;
  241. RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "USB Max Bulk-out Size=%d\n",
  242. rtlusb->max_bulk_out_size);
  243. for (i = 0; i < __RTL_TXQ_NUM; i++) {
  244. u32 ep_num = rtlusb->ep_map.ep_mapping[i];
  245. if (!ep_num) {
  246. RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
  247. "Invalid endpoint map setting!\n");
  248. return -EINVAL;
  249. }
  250. }
  251. rtlusb->usb_tx_post_hdl =
  252. rtlpriv->cfg->usb_interface_cfg->usb_tx_post_hdl;
  253. rtlusb->usb_tx_cleanup =
  254. rtlpriv->cfg->usb_interface_cfg->usb_tx_cleanup;
  255. rtlusb->usb_tx_aggregate_hdl =
  256. (rtlpriv->cfg->usb_interface_cfg->usb_tx_aggregate_hdl)
  257. ? rtlpriv->cfg->usb_interface_cfg->usb_tx_aggregate_hdl
  258. : &_none_usb_tx_aggregate_hdl;
  259. init_usb_anchor(&rtlusb->tx_submitted);
  260. for (i = 0; i < RTL_USB_MAX_EP_NUM; i++) {
  261. skb_queue_head_init(&rtlusb->tx_skb_queue[i]);
  262. init_usb_anchor(&rtlusb->tx_pending[i]);
  263. }
  264. return 0;
  265. }
  266. static void _rtl_rx_work(unsigned long param);
  267. static int _rtl_usb_init_rx(struct ieee80211_hw *hw)
  268. {
  269. struct rtl_priv *rtlpriv = rtl_priv(hw);
  270. struct rtl_usb_priv *usb_priv = rtl_usbpriv(hw);
  271. struct rtl_usb *rtlusb = rtl_usbdev(usb_priv);
  272. rtlusb->rx_max_size = rtlpriv->cfg->usb_interface_cfg->rx_max_size;
  273. rtlusb->rx_urb_num = rtlpriv->cfg->usb_interface_cfg->rx_urb_num;
  274. rtlusb->in_ep = rtlpriv->cfg->usb_interface_cfg->in_ep_num;
  275. rtlusb->usb_rx_hdl = rtlpriv->cfg->usb_interface_cfg->usb_rx_hdl;
  276. rtlusb->usb_rx_segregate_hdl =
  277. rtlpriv->cfg->usb_interface_cfg->usb_rx_segregate_hdl;
  278. pr_info("rx_max_size %d, rx_urb_num %d, in_ep %d\n",
  279. rtlusb->rx_max_size, rtlusb->rx_urb_num, rtlusb->in_ep);
  280. init_usb_anchor(&rtlusb->rx_submitted);
  281. init_usb_anchor(&rtlusb->rx_cleanup_urbs);
  282. skb_queue_head_init(&rtlusb->rx_queue);
  283. rtlusb->rx_work_tasklet.func = _rtl_rx_work;
  284. rtlusb->rx_work_tasklet.data = (unsigned long)rtlusb;
  285. return 0;
  286. }
  287. static int _rtl_usb_init(struct ieee80211_hw *hw)
  288. {
  289. struct rtl_priv *rtlpriv = rtl_priv(hw);
  290. struct rtl_usb_priv *usb_priv = rtl_usbpriv(hw);
  291. struct rtl_usb *rtlusb = rtl_usbdev(usb_priv);
  292. int err;
  293. u8 epidx;
  294. struct usb_interface *usb_intf = rtlusb->intf;
  295. u8 epnums = usb_intf->cur_altsetting->desc.bNumEndpoints;
  296. rtlusb->out_ep_nums = rtlusb->in_ep_nums = 0;
  297. for (epidx = 0; epidx < epnums; epidx++) {
  298. struct usb_endpoint_descriptor *pep_desc;
  299. pep_desc = &usb_intf->cur_altsetting->endpoint[epidx].desc;
  300. if (usb_endpoint_dir_in(pep_desc))
  301. rtlusb->in_ep_nums++;
  302. else if (usb_endpoint_dir_out(pep_desc))
  303. rtlusb->out_ep_nums++;
  304. RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
  305. "USB EP(0x%02x), MaxPacketSize=%d, Interval=%d\n",
  306. pep_desc->bEndpointAddress, pep_desc->wMaxPacketSize,
  307. pep_desc->bInterval);
  308. }
  309. if (rtlusb->in_ep_nums < rtlpriv->cfg->usb_interface_cfg->in_ep_num) {
  310. pr_err("Too few input end points found\n");
  311. return -EINVAL;
  312. }
  313. if (rtlusb->out_ep_nums == 0) {
  314. pr_err("No output end points found\n");
  315. return -EINVAL;
  316. }
  317. /* usb endpoint mapping */
  318. err = rtlpriv->cfg->usb_interface_cfg->usb_endpoint_mapping(hw);
  319. rtlusb->usb_mq_to_hwq = rtlpriv->cfg->usb_interface_cfg->usb_mq_to_hwq;
  320. _rtl_usb_init_tx(hw);
  321. _rtl_usb_init_rx(hw);
  322. return err;
  323. }
  324. static void rtl_usb_init_sw(struct ieee80211_hw *hw)
  325. {
  326. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  327. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  328. struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  329. struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
  330. rtlhal->hw = hw;
  331. ppsc->inactiveps = false;
  332. ppsc->leisure_ps = false;
  333. ppsc->fwctrl_lps = false;
  334. ppsc->reg_fwctrl_lps = 3;
  335. ppsc->reg_max_lps_awakeintvl = 5;
  336. ppsc->fwctrl_psmode = FW_PS_DTIM_MODE;
  337. /* IBSS */
  338. mac->beacon_interval = 100;
  339. /* AMPDU */
  340. mac->min_space_cfg = 0;
  341. mac->max_mss_density = 0;
  342. /* set sane AMPDU defaults */
  343. mac->current_ampdu_density = 7;
  344. mac->current_ampdu_factor = 3;
  345. /* QOS */
  346. rtlusb->acm_method = eAcmWay2_SW;
  347. /* IRQ */
  348. /* HIMR - turn all on */
  349. rtlusb->irq_mask[0] = 0xFFFFFFFF;
  350. /* HIMR_EX - turn all on */
  351. rtlusb->irq_mask[1] = 0xFFFFFFFF;
  352. rtlusb->disableHWSM = true;
  353. }
  354. static void _rtl_rx_completed(struct urb *urb);
  355. static int _rtl_prep_rx_urb(struct ieee80211_hw *hw, struct rtl_usb *rtlusb,
  356. struct urb *urb, gfp_t gfp_mask)
  357. {
  358. struct rtl_priv *rtlpriv = rtl_priv(hw);
  359. void *buf;
  360. buf = usb_alloc_coherent(rtlusb->udev, rtlusb->rx_max_size, gfp_mask,
  361. &urb->transfer_dma);
  362. if (!buf) {
  363. RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
  364. "Failed to usb_alloc_coherent!!\n");
  365. return -ENOMEM;
  366. }
  367. usb_fill_bulk_urb(urb, rtlusb->udev,
  368. usb_rcvbulkpipe(rtlusb->udev, rtlusb->in_ep),
  369. buf, rtlusb->rx_max_size, _rtl_rx_completed, rtlusb);
  370. urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
  371. return 0;
  372. }
  373. static void _rtl_usb_rx_process_agg(struct ieee80211_hw *hw,
  374. struct sk_buff *skb)
  375. {
  376. struct rtl_priv *rtlpriv = rtl_priv(hw);
  377. u8 *rxdesc = skb->data;
  378. struct ieee80211_hdr *hdr;
  379. bool unicast = false;
  380. __le16 fc;
  381. struct ieee80211_rx_status rx_status = {0};
  382. struct rtl_stats stats = {
  383. .signal = 0,
  384. .noise = -98,
  385. .rate = 0,
  386. };
  387. skb_pull(skb, RTL_RX_DESC_SIZE);
  388. rtlpriv->cfg->ops->query_rx_desc(hw, &stats, &rx_status, rxdesc, skb);
  389. skb_pull(skb, (stats.rx_drvinfo_size + stats.rx_bufshift));
  390. hdr = (struct ieee80211_hdr *)(skb->data);
  391. fc = hdr->frame_control;
  392. if (!stats.crc) {
  393. memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status));
  394. if (is_broadcast_ether_addr(hdr->addr1)) {
  395. /*TODO*/;
  396. } else if (is_multicast_ether_addr(hdr->addr1)) {
  397. /*TODO*/
  398. } else {
  399. unicast = true;
  400. rtlpriv->stats.rxbytesunicast += skb->len;
  401. }
  402. rtl_is_special_data(hw, skb, false);
  403. if (ieee80211_is_data(fc)) {
  404. rtlpriv->cfg->ops->led_control(hw, LED_CTL_RX);
  405. if (unicast)
  406. rtlpriv->link_info.num_rx_inperiod++;
  407. }
  408. }
  409. }
  410. static void _rtl_usb_rx_process_noagg(struct ieee80211_hw *hw,
  411. struct sk_buff *skb)
  412. {
  413. struct rtl_priv *rtlpriv = rtl_priv(hw);
  414. u8 *rxdesc = skb->data;
  415. struct ieee80211_hdr *hdr;
  416. bool unicast = false;
  417. __le16 fc;
  418. struct ieee80211_rx_status rx_status = {0};
  419. struct rtl_stats stats = {
  420. .signal = 0,
  421. .noise = -98,
  422. .rate = 0,
  423. };
  424. skb_pull(skb, RTL_RX_DESC_SIZE);
  425. rtlpriv->cfg->ops->query_rx_desc(hw, &stats, &rx_status, rxdesc, skb);
  426. skb_pull(skb, (stats.rx_drvinfo_size + stats.rx_bufshift));
  427. hdr = (struct ieee80211_hdr *)(skb->data);
  428. fc = hdr->frame_control;
  429. if (!stats.crc) {
  430. memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status));
  431. if (is_broadcast_ether_addr(hdr->addr1)) {
  432. /*TODO*/;
  433. } else if (is_multicast_ether_addr(hdr->addr1)) {
  434. /*TODO*/
  435. } else {
  436. unicast = true;
  437. rtlpriv->stats.rxbytesunicast += skb->len;
  438. }
  439. rtl_is_special_data(hw, skb, false);
  440. if (ieee80211_is_data(fc)) {
  441. rtlpriv->cfg->ops->led_control(hw, LED_CTL_RX);
  442. if (unicast)
  443. rtlpriv->link_info.num_rx_inperiod++;
  444. }
  445. if (likely(rtl_action_proc(hw, skb, false)))
  446. ieee80211_rx(hw, skb);
  447. else
  448. dev_kfree_skb_any(skb);
  449. }
  450. }
  451. static void _rtl_rx_pre_process(struct ieee80211_hw *hw, struct sk_buff *skb)
  452. {
  453. struct sk_buff *_skb;
  454. struct sk_buff_head rx_queue;
  455. struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
  456. skb_queue_head_init(&rx_queue);
  457. if (rtlusb->usb_rx_segregate_hdl)
  458. rtlusb->usb_rx_segregate_hdl(hw, skb, &rx_queue);
  459. WARN_ON(skb_queue_empty(&rx_queue));
  460. while (!skb_queue_empty(&rx_queue)) {
  461. _skb = skb_dequeue(&rx_queue);
  462. _rtl_usb_rx_process_agg(hw, _skb);
  463. ieee80211_rx(hw, _skb);
  464. }
  465. }
  466. #define __RX_SKB_MAX_QUEUED 32
  467. static void _rtl_rx_work(unsigned long param)
  468. {
  469. struct rtl_usb *rtlusb = (struct rtl_usb *)param;
  470. struct ieee80211_hw *hw = usb_get_intfdata(rtlusb->intf);
  471. struct sk_buff *skb;
  472. while ((skb = skb_dequeue(&rtlusb->rx_queue))) {
  473. if (unlikely(IS_USB_STOP(rtlusb))) {
  474. dev_kfree_skb_any(skb);
  475. continue;
  476. }
  477. if (likely(!rtlusb->usb_rx_segregate_hdl)) {
  478. _rtl_usb_rx_process_noagg(hw, skb);
  479. } else {
  480. /* TO DO */
  481. _rtl_rx_pre_process(hw, skb);
  482. pr_err("rx agg not supported\n");
  483. }
  484. }
  485. }
  486. #define __RADIO_TAP_SIZE_RSV 32
  487. static void _rtl_rx_completed(struct urb *_urb)
  488. {
  489. struct rtl_usb *rtlusb = (struct rtl_usb *)_urb->context;
  490. struct ieee80211_hw *hw = usb_get_intfdata(rtlusb->intf);
  491. struct rtl_priv *rtlpriv = rtl_priv(hw);
  492. int err = 0;
  493. if (unlikely(IS_USB_STOP(rtlusb)))
  494. goto free;
  495. if (likely(0 == _urb->status)) {
  496. struct sk_buff *skb;
  497. unsigned int qlen;
  498. unsigned int size = _urb->actual_length;
  499. if (size < RTL_RX_DESC_SIZE + sizeof(struct ieee80211_hdr)) {
  500. RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
  501. "Too short packet from bulk IN! (len: %d)\n",
  502. size);
  503. goto resubmit;
  504. }
  505. qlen = skb_queue_len(&rtlusb->rx_queue);
  506. if (qlen >= __RX_SKB_MAX_QUEUED) {
  507. RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
  508. "Pending RX skbuff queue full! (qlen: %d)\n",
  509. qlen);
  510. goto resubmit;
  511. }
  512. skb = dev_alloc_skb(size + __RADIO_TAP_SIZE_RSV);
  513. if (!skb) {
  514. RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
  515. "Can't allocate skb for bulk IN!\n");
  516. goto resubmit;
  517. }
  518. _rtl_install_trx_info(rtlusb, skb, rtlusb->in_ep);
  519. /* reserve some space for mac80211's radiotap */
  520. skb_reserve(skb, __RADIO_TAP_SIZE_RSV);
  521. memcpy(skb_put(skb, size), _urb->transfer_buffer, size);
  522. skb_queue_tail(&rtlusb->rx_queue, skb);
  523. tasklet_schedule(&rtlusb->rx_work_tasklet);
  524. goto resubmit;
  525. }
  526. switch (_urb->status) {
  527. /* disconnect */
  528. case -ENOENT:
  529. case -ECONNRESET:
  530. case -ENODEV:
  531. case -ESHUTDOWN:
  532. goto free;
  533. default:
  534. break;
  535. }
  536. resubmit:
  537. usb_anchor_urb(_urb, &rtlusb->rx_submitted);
  538. err = usb_submit_urb(_urb, GFP_ATOMIC);
  539. if (unlikely(err)) {
  540. usb_unanchor_urb(_urb);
  541. goto free;
  542. }
  543. return;
  544. free:
  545. /* On some architectures, usb_free_coherent must not be called from
  546. * hardirq context. Queue urb to cleanup list.
  547. */
  548. usb_anchor_urb(_urb, &rtlusb->rx_cleanup_urbs);
  549. }
  550. #undef __RADIO_TAP_SIZE_RSV
  551. static void _rtl_usb_cleanup_rx(struct ieee80211_hw *hw)
  552. {
  553. struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
  554. struct urb *urb;
  555. usb_kill_anchored_urbs(&rtlusb->rx_submitted);
  556. tasklet_kill(&rtlusb->rx_work_tasklet);
  557. skb_queue_purge(&rtlusb->rx_queue);
  558. while ((urb = usb_get_from_anchor(&rtlusb->rx_cleanup_urbs))) {
  559. usb_free_coherent(urb->dev, urb->transfer_buffer_length,
  560. urb->transfer_buffer, urb->transfer_dma);
  561. usb_free_urb(urb);
  562. }
  563. }
  564. static int _rtl_usb_receive(struct ieee80211_hw *hw)
  565. {
  566. struct urb *urb;
  567. int err;
  568. int i;
  569. struct rtl_priv *rtlpriv = rtl_priv(hw);
  570. struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
  571. WARN_ON(0 == rtlusb->rx_urb_num);
  572. /* 1600 == 1514 + max WLAN header + rtk info */
  573. WARN_ON(rtlusb->rx_max_size < 1600);
  574. for (i = 0; i < rtlusb->rx_urb_num; i++) {
  575. err = -ENOMEM;
  576. urb = usb_alloc_urb(0, GFP_KERNEL);
  577. if (!urb) {
  578. RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
  579. "Failed to alloc URB!!\n");
  580. goto err_out;
  581. }
  582. err = _rtl_prep_rx_urb(hw, rtlusb, urb, GFP_KERNEL);
  583. if (err < 0) {
  584. RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
  585. "Failed to prep_rx_urb!!\n");
  586. usb_free_urb(urb);
  587. goto err_out;
  588. }
  589. usb_anchor_urb(urb, &rtlusb->rx_submitted);
  590. err = usb_submit_urb(urb, GFP_KERNEL);
  591. if (err)
  592. goto err_out;
  593. usb_free_urb(urb);
  594. }
  595. return 0;
  596. err_out:
  597. usb_kill_anchored_urbs(&rtlusb->rx_submitted);
  598. _rtl_usb_cleanup_rx(hw);
  599. return err;
  600. }
  601. static int rtl_usb_start(struct ieee80211_hw *hw)
  602. {
  603. int err;
  604. struct rtl_priv *rtlpriv = rtl_priv(hw);
  605. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  606. struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
  607. err = rtlpriv->cfg->ops->hw_init(hw);
  608. if (!err) {
  609. rtl_init_rx_config(hw);
  610. /* Enable software */
  611. SET_USB_START(rtlusb);
  612. /* should after adapter start and interrupt enable. */
  613. set_hal_start(rtlhal);
  614. /* Start bulk IN */
  615. err = _rtl_usb_receive(hw);
  616. }
  617. return err;
  618. }
  619. /**
  620. *
  621. *
  622. */
  623. /*======================= tx =========================================*/
  624. static void rtl_usb_cleanup(struct ieee80211_hw *hw)
  625. {
  626. u32 i;
  627. struct sk_buff *_skb;
  628. struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
  629. struct ieee80211_tx_info *txinfo;
  630. SET_USB_STOP(rtlusb);
  631. /* clean up rx stuff. */
  632. _rtl_usb_cleanup_rx(hw);
  633. /* clean up tx stuff */
  634. for (i = 0; i < RTL_USB_MAX_EP_NUM; i++) {
  635. while ((_skb = skb_dequeue(&rtlusb->tx_skb_queue[i]))) {
  636. rtlusb->usb_tx_cleanup(hw, _skb);
  637. txinfo = IEEE80211_SKB_CB(_skb);
  638. ieee80211_tx_info_clear_status(txinfo);
  639. txinfo->flags |= IEEE80211_TX_STAT_ACK;
  640. ieee80211_tx_status_irqsafe(hw, _skb);
  641. }
  642. usb_kill_anchored_urbs(&rtlusb->tx_pending[i]);
  643. }
  644. usb_kill_anchored_urbs(&rtlusb->tx_submitted);
  645. }
  646. /**
  647. *
  648. * We may add some struct into struct rtl_usb later. Do deinit here.
  649. *
  650. */
  651. static void rtl_usb_deinit(struct ieee80211_hw *hw)
  652. {
  653. rtl_usb_cleanup(hw);
  654. }
  655. static void rtl_usb_stop(struct ieee80211_hw *hw)
  656. {
  657. struct rtl_priv *rtlpriv = rtl_priv(hw);
  658. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  659. struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
  660. /* should after adapter start and interrupt enable. */
  661. set_hal_stop(rtlhal);
  662. /* Enable software */
  663. SET_USB_STOP(rtlusb);
  664. rtl_usb_deinit(hw);
  665. rtlpriv->cfg->ops->hw_disable(hw);
  666. }
  667. static void _rtl_submit_tx_urb(struct ieee80211_hw *hw, struct urb *_urb)
  668. {
  669. int err;
  670. struct rtl_priv *rtlpriv = rtl_priv(hw);
  671. struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
  672. usb_anchor_urb(_urb, &rtlusb->tx_submitted);
  673. err = usb_submit_urb(_urb, GFP_ATOMIC);
  674. if (err < 0) {
  675. struct sk_buff *skb;
  676. RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
  677. "Failed to submit urb\n");
  678. usb_unanchor_urb(_urb);
  679. skb = (struct sk_buff *)_urb->context;
  680. kfree_skb(skb);
  681. }
  682. usb_free_urb(_urb);
  683. }
  684. static int _usb_tx_post(struct ieee80211_hw *hw, struct urb *urb,
  685. struct sk_buff *skb)
  686. {
  687. struct rtl_priv *rtlpriv = rtl_priv(hw);
  688. struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
  689. struct ieee80211_tx_info *txinfo;
  690. rtlusb->usb_tx_post_hdl(hw, urb, skb);
  691. skb_pull(skb, RTL_TX_HEADER_SIZE);
  692. txinfo = IEEE80211_SKB_CB(skb);
  693. ieee80211_tx_info_clear_status(txinfo);
  694. txinfo->flags |= IEEE80211_TX_STAT_ACK;
  695. if (urb->status) {
  696. RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
  697. "Urb has error status 0x%X\n", urb->status);
  698. goto out;
  699. }
  700. /* TODO: statistics */
  701. out:
  702. ieee80211_tx_status_irqsafe(hw, skb);
  703. return urb->status;
  704. }
  705. static void _rtl_tx_complete(struct urb *urb)
  706. {
  707. struct sk_buff *skb = (struct sk_buff *)urb->context;
  708. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  709. struct rtl_usb *rtlusb = (struct rtl_usb *)info->rate_driver_data[0];
  710. struct ieee80211_hw *hw = usb_get_intfdata(rtlusb->intf);
  711. int err;
  712. if (unlikely(IS_USB_STOP(rtlusb)))
  713. return;
  714. err = _usb_tx_post(hw, urb, skb);
  715. if (err) {
  716. /* Ignore error and keep issuiing other urbs */
  717. return;
  718. }
  719. }
  720. static struct urb *_rtl_usb_tx_urb_setup(struct ieee80211_hw *hw,
  721. struct sk_buff *skb, u32 ep_num)
  722. {
  723. struct rtl_priv *rtlpriv = rtl_priv(hw);
  724. struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
  725. struct urb *_urb;
  726. WARN_ON(NULL == skb);
  727. _urb = usb_alloc_urb(0, GFP_ATOMIC);
  728. if (!_urb) {
  729. RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
  730. "Can't allocate URB for bulk out!\n");
  731. kfree_skb(skb);
  732. return NULL;
  733. }
  734. _rtl_install_trx_info(rtlusb, skb, ep_num);
  735. usb_fill_bulk_urb(_urb, rtlusb->udev, usb_sndbulkpipe(rtlusb->udev,
  736. ep_num), skb->data, skb->len, _rtl_tx_complete, skb);
  737. _urb->transfer_flags |= URB_ZERO_PACKET;
  738. return _urb;
  739. }
  740. static void _rtl_usb_transmit(struct ieee80211_hw *hw, struct sk_buff *skb,
  741. enum rtl_txq qnum)
  742. {
  743. struct rtl_priv *rtlpriv = rtl_priv(hw);
  744. struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
  745. u32 ep_num;
  746. struct urb *_urb = NULL;
  747. struct sk_buff *_skb = NULL;
  748. WARN_ON(NULL == rtlusb->usb_tx_aggregate_hdl);
  749. if (unlikely(IS_USB_STOP(rtlusb))) {
  750. RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
  751. "USB device is stopping...\n");
  752. kfree_skb(skb);
  753. return;
  754. }
  755. ep_num = rtlusb->ep_map.ep_mapping[qnum];
  756. _skb = skb;
  757. _urb = _rtl_usb_tx_urb_setup(hw, _skb, ep_num);
  758. if (unlikely(!_urb)) {
  759. RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
  760. "Can't allocate urb. Drop skb!\n");
  761. return;
  762. }
  763. _rtl_submit_tx_urb(hw, _urb);
  764. }
  765. static void _rtl_usb_tx_preprocess(struct ieee80211_hw *hw,
  766. struct ieee80211_sta *sta,
  767. struct sk_buff *skb,
  768. u16 hw_queue)
  769. {
  770. struct rtl_priv *rtlpriv = rtl_priv(hw);
  771. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  772. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  773. struct rtl_tx_desc *pdesc = NULL;
  774. struct rtl_tcb_desc tcb_desc;
  775. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data);
  776. __le16 fc = hdr->frame_control;
  777. u8 *pda_addr = hdr->addr1;
  778. /* ssn */
  779. u8 *qc = NULL;
  780. u8 tid = 0;
  781. u16 seq_number = 0;
  782. memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
  783. if (ieee80211_is_auth(fc)) {
  784. RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "MAC80211_LINKING\n");
  785. rtl_ips_nic_on(hw);
  786. }
  787. if (rtlpriv->psc.sw_ps_enabled) {
  788. if (ieee80211_is_data(fc) && !ieee80211_is_nullfunc(fc) &&
  789. !ieee80211_has_pm(fc))
  790. hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
  791. }
  792. rtl_action_proc(hw, skb, true);
  793. if (is_multicast_ether_addr(pda_addr))
  794. rtlpriv->stats.txbytesmulticast += skb->len;
  795. else if (is_broadcast_ether_addr(pda_addr))
  796. rtlpriv->stats.txbytesbroadcast += skb->len;
  797. else
  798. rtlpriv->stats.txbytesunicast += skb->len;
  799. if (ieee80211_is_data_qos(fc)) {
  800. qc = ieee80211_get_qos_ctl(hdr);
  801. tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
  802. seq_number = (le16_to_cpu(hdr->seq_ctrl) &
  803. IEEE80211_SCTL_SEQ) >> 4;
  804. seq_number += 1;
  805. seq_number <<= 4;
  806. }
  807. rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *)pdesc, info, sta, skb,
  808. hw_queue, &tcb_desc);
  809. if (!ieee80211_has_morefrags(hdr->frame_control)) {
  810. if (qc)
  811. mac->tids[tid].seq_number = seq_number;
  812. }
  813. if (ieee80211_is_data(fc))
  814. rtlpriv->cfg->ops->led_control(hw, LED_CTL_TX);
  815. }
  816. static int rtl_usb_tx(struct ieee80211_hw *hw,
  817. struct ieee80211_sta *sta,
  818. struct sk_buff *skb,
  819. struct rtl_tcb_desc *dummy)
  820. {
  821. struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
  822. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  823. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data);
  824. __le16 fc = hdr->frame_control;
  825. u16 hw_queue;
  826. if (unlikely(is_hal_stop(rtlhal)))
  827. goto err_free;
  828. hw_queue = rtlusb->usb_mq_to_hwq(fc, skb_get_queue_mapping(skb));
  829. _rtl_usb_tx_preprocess(hw, sta, skb, hw_queue);
  830. _rtl_usb_transmit(hw, skb, hw_queue);
  831. return NETDEV_TX_OK;
  832. err_free:
  833. dev_kfree_skb_any(skb);
  834. return NETDEV_TX_OK;
  835. }
  836. static bool rtl_usb_tx_chk_waitq_insert(struct ieee80211_hw *hw,
  837. struct ieee80211_sta *sta,
  838. struct sk_buff *skb)
  839. {
  840. return false;
  841. }
  842. static struct rtl_intf_ops rtl_usb_ops = {
  843. .adapter_start = rtl_usb_start,
  844. .adapter_stop = rtl_usb_stop,
  845. .adapter_tx = rtl_usb_tx,
  846. .waitq_insert = rtl_usb_tx_chk_waitq_insert,
  847. };
  848. int rtl_usb_probe(struct usb_interface *intf,
  849. const struct usb_device_id *id,
  850. struct rtl_hal_cfg *rtl_hal_cfg)
  851. {
  852. int err;
  853. struct ieee80211_hw *hw = NULL;
  854. struct rtl_priv *rtlpriv = NULL;
  855. struct usb_device *udev;
  856. struct rtl_usb_priv *usb_priv;
  857. hw = ieee80211_alloc_hw(sizeof(struct rtl_priv) +
  858. sizeof(struct rtl_usb_priv), &rtl_ops);
  859. if (!hw) {
  860. RT_ASSERT(false, "ieee80211 alloc failed\n");
  861. return -ENOMEM;
  862. }
  863. rtlpriv = hw->priv;
  864. rtlpriv->usb_data = kzalloc(RTL_USB_MAX_RX_COUNT * sizeof(u32),
  865. GFP_KERNEL);
  866. if (!rtlpriv->usb_data)
  867. return -ENOMEM;
  868. /* this spin lock must be initialized early */
  869. spin_lock_init(&rtlpriv->locks.usb_lock);
  870. rtlpriv->usb_data_index = 0;
  871. init_completion(&rtlpriv->firmware_loading_complete);
  872. SET_IEEE80211_DEV(hw, &intf->dev);
  873. udev = interface_to_usbdev(intf);
  874. usb_get_dev(udev);
  875. usb_priv = rtl_usbpriv(hw);
  876. memset(usb_priv, 0, sizeof(*usb_priv));
  877. usb_priv->dev.intf = intf;
  878. usb_priv->dev.udev = udev;
  879. usb_set_intfdata(intf, hw);
  880. /* init cfg & intf_ops */
  881. rtlpriv->rtlhal.interface = INTF_USB;
  882. rtlpriv->cfg = rtl_hal_cfg;
  883. rtlpriv->intf_ops = &rtl_usb_ops;
  884. rtl_dbgp_flag_init(hw);
  885. /* Init IO handler */
  886. _rtl_usb_io_handler_init(&udev->dev, hw);
  887. rtlpriv->cfg->ops->read_chip_version(hw);
  888. /*like read eeprom and so on */
  889. rtlpriv->cfg->ops->read_eeprom_info(hw);
  890. err = _rtl_usb_init(hw);
  891. if (err)
  892. goto error_out;
  893. rtl_usb_init_sw(hw);
  894. /* Init mac80211 sw */
  895. err = rtl_init_core(hw);
  896. if (err) {
  897. RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
  898. "Can't allocate sw for mac80211\n");
  899. goto error_out;
  900. }
  901. if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
  902. RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Can't init_sw_vars\n");
  903. goto error_out;
  904. }
  905. rtlpriv->cfg->ops->init_sw_leds(hw);
  906. return 0;
  907. error_out:
  908. rtl_deinit_core(hw);
  909. _rtl_usb_io_handler_release(hw);
  910. usb_put_dev(udev);
  911. complete(&rtlpriv->firmware_loading_complete);
  912. return -ENODEV;
  913. }
  914. EXPORT_SYMBOL(rtl_usb_probe);
  915. void rtl_usb_disconnect(struct usb_interface *intf)
  916. {
  917. struct ieee80211_hw *hw = usb_get_intfdata(intf);
  918. struct rtl_priv *rtlpriv = rtl_priv(hw);
  919. struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw));
  920. struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
  921. if (unlikely(!rtlpriv))
  922. return;
  923. /* just in case driver is removed before firmware callback */
  924. wait_for_completion(&rtlpriv->firmware_loading_complete);
  925. /*ieee80211_unregister_hw will call ops_stop */
  926. if (rtlmac->mac80211_registered == 1) {
  927. ieee80211_unregister_hw(hw);
  928. rtlmac->mac80211_registered = 0;
  929. } else {
  930. rtl_deinit_deferred_work(hw);
  931. rtlpriv->intf_ops->adapter_stop(hw);
  932. }
  933. /*deinit rfkill */
  934. /* rtl_deinit_rfkill(hw); */
  935. rtl_usb_deinit(hw);
  936. rtl_deinit_core(hw);
  937. kfree(rtlpriv->usb_data);
  938. rtlpriv->cfg->ops->deinit_sw_leds(hw);
  939. rtlpriv->cfg->ops->deinit_sw_vars(hw);
  940. _rtl_usb_io_handler_release(hw);
  941. usb_put_dev(rtlusb->udev);
  942. usb_set_intfdata(intf, NULL);
  943. ieee80211_free_hw(hw);
  944. }
  945. EXPORT_SYMBOL(rtl_usb_disconnect);
  946. int rtl_usb_suspend(struct usb_interface *pusb_intf, pm_message_t message)
  947. {
  948. return 0;
  949. }
  950. EXPORT_SYMBOL(rtl_usb_suspend);
  951. int rtl_usb_resume(struct usb_interface *pusb_intf)
  952. {
  953. return 0;
  954. }
  955. EXPORT_SYMBOL(rtl_usb_resume);