txrx.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  1. /*
  2. * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <linux/etherdevice.h>
  17. #include <net/ieee80211_radiotap.h>
  18. #include <linux/if_arp.h>
  19. #include <linux/moduleparam.h>
  20. #include <linux/ip.h>
  21. #include <linux/ipv6.h>
  22. #include <net/ipv6.h>
  23. #include <linux/prefetch.h>
  24. #include "wil6210.h"
  25. #include "wmi.h"
  26. #include "txrx.h"
  27. #include "trace.h"
  28. static bool rtap_include_phy_info;
  29. module_param(rtap_include_phy_info, bool, S_IRUGO);
  30. MODULE_PARM_DESC(rtap_include_phy_info,
  31. " Include PHY info in the radiotap header, default - no");
  32. static inline int wil_vring_is_empty(struct vring *vring)
  33. {
  34. return vring->swhead == vring->swtail;
  35. }
  36. static inline u32 wil_vring_next_tail(struct vring *vring)
  37. {
  38. return (vring->swtail + 1) % vring->size;
  39. }
  40. static inline void wil_vring_advance_head(struct vring *vring, int n)
  41. {
  42. vring->swhead = (vring->swhead + n) % vring->size;
  43. }
  44. static inline int wil_vring_is_full(struct vring *vring)
  45. {
  46. return wil_vring_next_tail(vring) == vring->swhead;
  47. }
  48. /*
  49. * Available space in Tx Vring
  50. */
  51. static inline int wil_vring_avail_tx(struct vring *vring)
  52. {
  53. u32 swhead = vring->swhead;
  54. u32 swtail = vring->swtail;
  55. int used = (vring->size + swhead - swtail) % vring->size;
  56. return vring->size - used - 1;
  57. }
  58. /**
  59. * wil_vring_wmark_low - low watermark for available descriptor space
  60. */
  61. static inline int wil_vring_wmark_low(struct vring *vring)
  62. {
  63. return vring->size/8;
  64. }
  65. /**
  66. * wil_vring_wmark_high - high watermark for available descriptor space
  67. */
  68. static inline int wil_vring_wmark_high(struct vring *vring)
  69. {
  70. return vring->size/4;
  71. }
  72. static int wil_vring_alloc(struct wil6210_priv *wil, struct vring *vring)
  73. {
  74. struct device *dev = wil_to_dev(wil);
  75. size_t sz = vring->size * sizeof(vring->va[0]);
  76. uint i;
  77. wil_dbg_misc(wil, "%s()\n", __func__);
  78. BUILD_BUG_ON(sizeof(vring->va[0]) != 32);
  79. vring->swhead = 0;
  80. vring->swtail = 0;
  81. vring->ctx = kcalloc(vring->size, sizeof(vring->ctx[0]), GFP_KERNEL);
  82. if (!vring->ctx) {
  83. vring->va = NULL;
  84. return -ENOMEM;
  85. }
  86. /*
  87. * vring->va should be aligned on its size rounded up to power of 2
  88. * This is granted by the dma_alloc_coherent
  89. */
  90. vring->va = dma_alloc_coherent(dev, sz, &vring->pa, GFP_KERNEL);
  91. if (!vring->va) {
  92. kfree(vring->ctx);
  93. vring->ctx = NULL;
  94. return -ENOMEM;
  95. }
  96. /* initially, all descriptors are SW owned
  97. * For Tx and Rx, ownership bit is at the same location, thus
  98. * we can use any
  99. */
  100. for (i = 0; i < vring->size; i++) {
  101. volatile struct vring_tx_desc *_d = &vring->va[i].tx;
  102. _d->dma.status = TX_DMA_STATUS_DU;
  103. }
  104. wil_dbg_misc(wil, "vring[%d] 0x%p:%pad 0x%p\n", vring->size,
  105. vring->va, &vring->pa, vring->ctx);
  106. return 0;
  107. }
  108. static void wil_txdesc_unmap(struct device *dev, struct vring_tx_desc *d,
  109. struct wil_ctx *ctx)
  110. {
  111. dma_addr_t pa = wil_desc_addr(&d->dma.addr);
  112. u16 dmalen = le16_to_cpu(d->dma.length);
  113. switch (ctx->mapped_as) {
  114. case wil_mapped_as_single:
  115. dma_unmap_single(dev, pa, dmalen, DMA_TO_DEVICE);
  116. break;
  117. case wil_mapped_as_page:
  118. dma_unmap_page(dev, pa, dmalen, DMA_TO_DEVICE);
  119. break;
  120. default:
  121. break;
  122. }
  123. }
  124. static void wil_vring_free(struct wil6210_priv *wil, struct vring *vring,
  125. int tx)
  126. {
  127. struct device *dev = wil_to_dev(wil);
  128. size_t sz = vring->size * sizeof(vring->va[0]);
  129. if (tx) {
  130. int vring_index = vring - wil->vring_tx;
  131. wil_dbg_misc(wil, "free Tx vring %d [%d] 0x%p:%pad 0x%p\n",
  132. vring_index, vring->size, vring->va,
  133. &vring->pa, vring->ctx);
  134. } else {
  135. wil_dbg_misc(wil, "free Rx vring [%d] 0x%p:%pad 0x%p\n",
  136. vring->size, vring->va,
  137. &vring->pa, vring->ctx);
  138. }
  139. while (!wil_vring_is_empty(vring)) {
  140. dma_addr_t pa;
  141. u16 dmalen;
  142. struct wil_ctx *ctx;
  143. if (tx) {
  144. struct vring_tx_desc dd, *d = &dd;
  145. volatile struct vring_tx_desc *_d =
  146. &vring->va[vring->swtail].tx;
  147. ctx = &vring->ctx[vring->swtail];
  148. *d = *_d;
  149. wil_txdesc_unmap(dev, d, ctx);
  150. if (ctx->skb)
  151. dev_kfree_skb_any(ctx->skb);
  152. vring->swtail = wil_vring_next_tail(vring);
  153. } else { /* rx */
  154. struct vring_rx_desc dd, *d = &dd;
  155. volatile struct vring_rx_desc *_d =
  156. &vring->va[vring->swhead].rx;
  157. ctx = &vring->ctx[vring->swhead];
  158. *d = *_d;
  159. pa = wil_desc_addr(&d->dma.addr);
  160. dmalen = le16_to_cpu(d->dma.length);
  161. dma_unmap_single(dev, pa, dmalen, DMA_FROM_DEVICE);
  162. kfree_skb(ctx->skb);
  163. wil_vring_advance_head(vring, 1);
  164. }
  165. }
  166. dma_free_coherent(dev, sz, (void *)vring->va, vring->pa);
  167. kfree(vring->ctx);
  168. vring->pa = 0;
  169. vring->va = NULL;
  170. vring->ctx = NULL;
  171. }
  172. /**
  173. * Allocate one skb for Rx VRING
  174. *
  175. * Safe to call from IRQ
  176. */
  177. static int wil_vring_alloc_skb(struct wil6210_priv *wil, struct vring *vring,
  178. u32 i, int headroom)
  179. {
  180. struct device *dev = wil_to_dev(wil);
  181. unsigned int sz = mtu_max + ETH_HLEN;
  182. struct vring_rx_desc dd, *d = &dd;
  183. volatile struct vring_rx_desc *_d = &vring->va[i].rx;
  184. dma_addr_t pa;
  185. struct sk_buff *skb = dev_alloc_skb(sz + headroom);
  186. if (unlikely(!skb))
  187. return -ENOMEM;
  188. skb_reserve(skb, headroom);
  189. skb_put(skb, sz);
  190. pa = dma_map_single(dev, skb->data, skb->len, DMA_FROM_DEVICE);
  191. if (unlikely(dma_mapping_error(dev, pa))) {
  192. kfree_skb(skb);
  193. return -ENOMEM;
  194. }
  195. d->dma.d0 = BIT(9) | RX_DMA_D0_CMD_DMA_IT;
  196. wil_desc_addr_set(&d->dma.addr, pa);
  197. /* ip_length don't care */
  198. /* b11 don't care */
  199. /* error don't care */
  200. d->dma.status = 0; /* BIT(0) should be 0 for HW_OWNED */
  201. d->dma.length = cpu_to_le16(sz);
  202. *_d = *d;
  203. vring->ctx[i].skb = skb;
  204. return 0;
  205. }
  206. /**
  207. * Adds radiotap header
  208. *
  209. * Any error indicated as "Bad FCS"
  210. *
  211. * Vendor data for 04:ce:14-1 (Wilocity-1) consists of:
  212. * - Rx descriptor: 32 bytes
  213. * - Phy info
  214. */
  215. static void wil_rx_add_radiotap_header(struct wil6210_priv *wil,
  216. struct sk_buff *skb)
  217. {
  218. struct wireless_dev *wdev = wil->wdev;
  219. struct wil6210_rtap {
  220. struct ieee80211_radiotap_header rthdr;
  221. /* fields should be in the order of bits in rthdr.it_present */
  222. /* flags */
  223. u8 flags;
  224. /* channel */
  225. __le16 chnl_freq __aligned(2);
  226. __le16 chnl_flags;
  227. /* MCS */
  228. u8 mcs_present;
  229. u8 mcs_flags;
  230. u8 mcs_index;
  231. } __packed;
  232. struct wil6210_rtap_vendor {
  233. struct wil6210_rtap rtap;
  234. /* vendor */
  235. u8 vendor_oui[3] __aligned(2);
  236. u8 vendor_ns;
  237. __le16 vendor_skip;
  238. u8 vendor_data[0];
  239. } __packed;
  240. struct vring_rx_desc *d = wil_skb_rxdesc(skb);
  241. struct wil6210_rtap_vendor *rtap_vendor;
  242. int rtap_len = sizeof(struct wil6210_rtap);
  243. int phy_length = 0; /* phy info header size, bytes */
  244. static char phy_data[128];
  245. struct ieee80211_channel *ch = wdev->preset_chandef.chan;
  246. if (rtap_include_phy_info) {
  247. rtap_len = sizeof(*rtap_vendor) + sizeof(*d);
  248. /* calculate additional length */
  249. if (d->dma.status & RX_DMA_STATUS_PHY_INFO) {
  250. /**
  251. * PHY info starts from 8-byte boundary
  252. * there are 8-byte lines, last line may be partially
  253. * written (HW bug), thus FW configures for last line
  254. * to be excessive. Driver skips this last line.
  255. */
  256. int len = min_t(int, 8 + sizeof(phy_data),
  257. wil_rxdesc_phy_length(d));
  258. if (len > 8) {
  259. void *p = skb_tail_pointer(skb);
  260. void *pa = PTR_ALIGN(p, 8);
  261. if (skb_tailroom(skb) >= len + (pa - p)) {
  262. phy_length = len - 8;
  263. memcpy(phy_data, pa, phy_length);
  264. }
  265. }
  266. }
  267. rtap_len += phy_length;
  268. }
  269. if (skb_headroom(skb) < rtap_len &&
  270. pskb_expand_head(skb, rtap_len, 0, GFP_ATOMIC)) {
  271. wil_err(wil, "Unable to expand headrom to %d\n", rtap_len);
  272. return;
  273. }
  274. rtap_vendor = (void *)skb_push(skb, rtap_len);
  275. memset(rtap_vendor, 0, rtap_len);
  276. rtap_vendor->rtap.rthdr.it_version = PKTHDR_RADIOTAP_VERSION;
  277. rtap_vendor->rtap.rthdr.it_len = cpu_to_le16(rtap_len);
  278. rtap_vendor->rtap.rthdr.it_present = cpu_to_le32(
  279. (1 << IEEE80211_RADIOTAP_FLAGS) |
  280. (1 << IEEE80211_RADIOTAP_CHANNEL) |
  281. (1 << IEEE80211_RADIOTAP_MCS));
  282. if (d->dma.status & RX_DMA_STATUS_ERROR)
  283. rtap_vendor->rtap.flags |= IEEE80211_RADIOTAP_F_BADFCS;
  284. rtap_vendor->rtap.chnl_freq = cpu_to_le16(ch ? ch->center_freq : 58320);
  285. rtap_vendor->rtap.chnl_flags = cpu_to_le16(0);
  286. rtap_vendor->rtap.mcs_present = IEEE80211_RADIOTAP_MCS_HAVE_MCS;
  287. rtap_vendor->rtap.mcs_flags = 0;
  288. rtap_vendor->rtap.mcs_index = wil_rxdesc_mcs(d);
  289. if (rtap_include_phy_info) {
  290. rtap_vendor->rtap.rthdr.it_present |= cpu_to_le32(1 <<
  291. IEEE80211_RADIOTAP_VENDOR_NAMESPACE);
  292. /* OUI for Wilocity 04:ce:14 */
  293. rtap_vendor->vendor_oui[0] = 0x04;
  294. rtap_vendor->vendor_oui[1] = 0xce;
  295. rtap_vendor->vendor_oui[2] = 0x14;
  296. rtap_vendor->vendor_ns = 1;
  297. /* Rx descriptor + PHY data */
  298. rtap_vendor->vendor_skip = cpu_to_le16(sizeof(*d) +
  299. phy_length);
  300. memcpy(rtap_vendor->vendor_data, (void *)d, sizeof(*d));
  301. memcpy(rtap_vendor->vendor_data + sizeof(*d), phy_data,
  302. phy_length);
  303. }
  304. }
  305. /*
  306. * Fast swap in place between 2 registers
  307. */
  308. static void wil_swap_u16(u16 *a, u16 *b)
  309. {
  310. *a ^= *b;
  311. *b ^= *a;
  312. *a ^= *b;
  313. }
  314. static void wil_swap_ethaddr(void *data)
  315. {
  316. struct ethhdr *eth = data;
  317. u16 *s = (u16 *)eth->h_source;
  318. u16 *d = (u16 *)eth->h_dest;
  319. wil_swap_u16(s++, d++);
  320. wil_swap_u16(s++, d++);
  321. wil_swap_u16(s, d);
  322. }
  323. /**
  324. * reap 1 frame from @swhead
  325. *
  326. * Rx descriptor copied to skb->cb
  327. *
  328. * Safe to call from IRQ
  329. */
  330. static struct sk_buff *wil_vring_reap_rx(struct wil6210_priv *wil,
  331. struct vring *vring)
  332. {
  333. struct device *dev = wil_to_dev(wil);
  334. struct net_device *ndev = wil_to_ndev(wil);
  335. volatile struct vring_rx_desc *_d;
  336. struct vring_rx_desc *d;
  337. struct sk_buff *skb;
  338. dma_addr_t pa;
  339. unsigned int sz = mtu_max + ETH_HLEN;
  340. u16 dmalen;
  341. u8 ftype;
  342. u8 ds_bits;
  343. int cid;
  344. struct wil_net_stats *stats;
  345. BUILD_BUG_ON(sizeof(struct vring_rx_desc) > sizeof(skb->cb));
  346. if (wil_vring_is_empty(vring))
  347. return NULL;
  348. _d = &vring->va[vring->swhead].rx;
  349. if (!(_d->dma.status & RX_DMA_STATUS_DU)) {
  350. /* it is not error, we just reached end of Rx done area */
  351. return NULL;
  352. }
  353. skb = vring->ctx[vring->swhead].skb;
  354. d = wil_skb_rxdesc(skb);
  355. *d = *_d;
  356. pa = wil_desc_addr(&d->dma.addr);
  357. vring->ctx[vring->swhead].skb = NULL;
  358. wil_vring_advance_head(vring, 1);
  359. dma_unmap_single(dev, pa, sz, DMA_FROM_DEVICE);
  360. dmalen = le16_to_cpu(d->dma.length);
  361. trace_wil6210_rx(vring->swhead, d);
  362. wil_dbg_txrx(wil, "Rx[%3d] : %d bytes\n", vring->swhead, dmalen);
  363. wil_hex_dump_txrx("Rx ", DUMP_PREFIX_NONE, 32, 4,
  364. (const void *)d, sizeof(*d), false);
  365. if (dmalen > sz) {
  366. wil_err(wil, "Rx size too large: %d bytes!\n", dmalen);
  367. kfree_skb(skb);
  368. return NULL;
  369. }
  370. skb_trim(skb, dmalen);
  371. prefetch(skb->data);
  372. wil_hex_dump_txrx("Rx ", DUMP_PREFIX_OFFSET, 16, 1,
  373. skb->data, skb_headlen(skb), false);
  374. cid = wil_rxdesc_cid(d);
  375. stats = &wil->sta[cid].stats;
  376. stats->last_mcs_rx = wil_rxdesc_mcs(d);
  377. /* use radiotap header only if required */
  378. if (ndev->type == ARPHRD_IEEE80211_RADIOTAP)
  379. wil_rx_add_radiotap_header(wil, skb);
  380. /* no extra checks if in sniffer mode */
  381. if (ndev->type != ARPHRD_ETHER)
  382. return skb;
  383. /*
  384. * Non-data frames may be delivered through Rx DMA channel (ex: BAR)
  385. * Driver should recognize it by frame type, that is found
  386. * in Rx descriptor. If type is not data, it is 802.11 frame as is
  387. */
  388. ftype = wil_rxdesc_ftype(d) << 2;
  389. if (ftype != IEEE80211_FTYPE_DATA) {
  390. wil_dbg_txrx(wil, "Non-data frame ftype 0x%08x\n", ftype);
  391. /* TODO: process it */
  392. kfree_skb(skb);
  393. return NULL;
  394. }
  395. if (skb->len < ETH_HLEN) {
  396. wil_err(wil, "Short frame, len = %d\n", skb->len);
  397. /* TODO: process it (i.e. BAR) */
  398. kfree_skb(skb);
  399. return NULL;
  400. }
  401. /* L4 IDENT is on when HW calculated checksum, check status
  402. * and in case of error drop the packet
  403. * higher stack layers will handle retransmission (if required)
  404. */
  405. if (d->dma.status & RX_DMA_STATUS_L4_IDENT) {
  406. /* L4 protocol identified, csum calculated */
  407. if ((d->dma.error & RX_DMA_ERROR_L4_ERR) == 0)
  408. skb->ip_summed = CHECKSUM_UNNECESSARY;
  409. /* If HW reports bad checksum, let IP stack re-check it
  410. * For example, HW don't understand Microsoft IP stack that
  411. * mis-calculates TCP checksum - if it should be 0x0,
  412. * it writes 0xffff in violation of RFC 1624
  413. */
  414. }
  415. ds_bits = wil_rxdesc_ds_bits(d);
  416. if (ds_bits == 1) {
  417. /*
  418. * HW bug - in ToDS mode, i.e. Rx on AP side,
  419. * addresses get swapped
  420. */
  421. wil_swap_ethaddr(skb->data);
  422. }
  423. return skb;
  424. }
  425. /**
  426. * allocate and fill up to @count buffers in rx ring
  427. * buffers posted at @swtail
  428. */
  429. static int wil_rx_refill(struct wil6210_priv *wil, int count)
  430. {
  431. struct net_device *ndev = wil_to_ndev(wil);
  432. struct vring *v = &wil->vring_rx;
  433. u32 next_tail;
  434. int rc = 0;
  435. int headroom = ndev->type == ARPHRD_IEEE80211_RADIOTAP ?
  436. WIL6210_RTAP_SIZE : 0;
  437. for (; next_tail = wil_vring_next_tail(v),
  438. (next_tail != v->swhead) && (count-- > 0);
  439. v->swtail = next_tail) {
  440. rc = wil_vring_alloc_skb(wil, v, v->swtail, headroom);
  441. if (rc) {
  442. wil_err(wil, "Error %d in wil_rx_refill[%d]\n",
  443. rc, v->swtail);
  444. break;
  445. }
  446. }
  447. iowrite32(v->swtail, wil->csr + HOSTADDR(v->hwtail));
  448. return rc;
  449. }
  450. /*
  451. * Pass Rx packet to the netif. Update statistics.
  452. * Called in softirq context (NAPI poll).
  453. */
  454. void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev)
  455. {
  456. gro_result_t rc;
  457. struct wil6210_priv *wil = ndev_to_wil(ndev);
  458. unsigned int len = skb->len;
  459. struct vring_rx_desc *d = wil_skb_rxdesc(skb);
  460. int cid = wil_rxdesc_cid(d);
  461. struct wil_net_stats *stats = &wil->sta[cid].stats;
  462. skb_orphan(skb);
  463. rc = napi_gro_receive(&wil->napi_rx, skb);
  464. if (unlikely(rc == GRO_DROP)) {
  465. ndev->stats.rx_dropped++;
  466. stats->rx_dropped++;
  467. wil_dbg_txrx(wil, "Rx drop %d bytes\n", len);
  468. } else {
  469. ndev->stats.rx_packets++;
  470. stats->rx_packets++;
  471. ndev->stats.rx_bytes += len;
  472. stats->rx_bytes += len;
  473. }
  474. {
  475. static const char * const gro_res_str[] = {
  476. [GRO_MERGED] = "GRO_MERGED",
  477. [GRO_MERGED_FREE] = "GRO_MERGED_FREE",
  478. [GRO_HELD] = "GRO_HELD",
  479. [GRO_NORMAL] = "GRO_NORMAL",
  480. [GRO_DROP] = "GRO_DROP",
  481. };
  482. wil_dbg_txrx(wil, "Rx complete %d bytes => %s\n",
  483. len, gro_res_str[rc]);
  484. }
  485. }
  486. /**
  487. * Proceed all completed skb's from Rx VRING
  488. *
  489. * Safe to call from NAPI poll, i.e. softirq with interrupts enabled
  490. */
  491. void wil_rx_handle(struct wil6210_priv *wil, int *quota)
  492. {
  493. struct net_device *ndev = wil_to_ndev(wil);
  494. struct vring *v = &wil->vring_rx;
  495. struct sk_buff *skb;
  496. if (!v->va) {
  497. wil_err(wil, "Rx IRQ while Rx not yet initialized\n");
  498. return;
  499. }
  500. wil_dbg_txrx(wil, "%s()\n", __func__);
  501. while ((*quota > 0) && (NULL != (skb = wil_vring_reap_rx(wil, v)))) {
  502. (*quota)--;
  503. if (wil->wdev->iftype == NL80211_IFTYPE_MONITOR) {
  504. skb->dev = ndev;
  505. skb_reset_mac_header(skb);
  506. skb->ip_summed = CHECKSUM_UNNECESSARY;
  507. skb->pkt_type = PACKET_OTHERHOST;
  508. skb->protocol = htons(ETH_P_802_2);
  509. wil_netif_rx_any(skb, ndev);
  510. } else {
  511. struct ethhdr *eth = (void *)skb->data;
  512. skb->protocol = eth_type_trans(skb, ndev);
  513. if (is_unicast_ether_addr(eth->h_dest))
  514. wil_rx_reorder(wil, skb);
  515. else
  516. wil_netif_rx_any(skb, ndev);
  517. }
  518. }
  519. wil_rx_refill(wil, v->size);
  520. }
  521. int wil_rx_init(struct wil6210_priv *wil, u16 size)
  522. {
  523. struct vring *vring = &wil->vring_rx;
  524. int rc;
  525. wil_dbg_misc(wil, "%s()\n", __func__);
  526. if (vring->va) {
  527. wil_err(wil, "Rx ring already allocated\n");
  528. return -EINVAL;
  529. }
  530. vring->size = size;
  531. rc = wil_vring_alloc(wil, vring);
  532. if (rc)
  533. return rc;
  534. rc = wmi_rx_chain_add(wil, vring);
  535. if (rc)
  536. goto err_free;
  537. rc = wil_rx_refill(wil, vring->size);
  538. if (rc)
  539. goto err_free;
  540. return 0;
  541. err_free:
  542. wil_vring_free(wil, vring, 0);
  543. return rc;
  544. }
  545. void wil_rx_fini(struct wil6210_priv *wil)
  546. {
  547. struct vring *vring = &wil->vring_rx;
  548. wil_dbg_misc(wil, "%s()\n", __func__);
  549. if (vring->va)
  550. wil_vring_free(wil, vring, 0);
  551. }
  552. int wil_vring_init_tx(struct wil6210_priv *wil, int id, int size,
  553. int cid, int tid)
  554. {
  555. int rc;
  556. struct wmi_vring_cfg_cmd cmd = {
  557. .action = cpu_to_le32(WMI_VRING_CMD_ADD),
  558. .vring_cfg = {
  559. .tx_sw_ring = {
  560. .max_mpdu_size =
  561. cpu_to_le16(mtu_max + ETH_HLEN),
  562. .ring_size = cpu_to_le16(size),
  563. },
  564. .ringid = id,
  565. .cidxtid = mk_cidxtid(cid, tid),
  566. .encap_trans_type = WMI_VRING_ENC_TYPE_802_3,
  567. .mac_ctrl = 0,
  568. .to_resolution = 0,
  569. .agg_max_wsize = 16,
  570. .schd_params = {
  571. .priority = cpu_to_le16(0),
  572. .timeslot_us = cpu_to_le16(0xfff),
  573. },
  574. },
  575. };
  576. struct {
  577. struct wil6210_mbox_hdr_wmi wmi;
  578. struct wmi_vring_cfg_done_event cmd;
  579. } __packed reply;
  580. struct vring *vring = &wil->vring_tx[id];
  581. struct vring_tx_data *txdata = &wil->vring_tx_data[id];
  582. wil_dbg_misc(wil, "%s() max_mpdu_size %d\n", __func__,
  583. cmd.vring_cfg.tx_sw_ring.max_mpdu_size);
  584. if (vring->va) {
  585. wil_err(wil, "Tx ring [%d] already allocated\n", id);
  586. rc = -EINVAL;
  587. goto out;
  588. }
  589. memset(txdata, 0, sizeof(*txdata));
  590. vring->size = size;
  591. rc = wil_vring_alloc(wil, vring);
  592. if (rc)
  593. goto out;
  594. wil->vring2cid_tid[id][0] = cid;
  595. wil->vring2cid_tid[id][1] = tid;
  596. cmd.vring_cfg.tx_sw_ring.ring_mem_base = cpu_to_le64(vring->pa);
  597. rc = wmi_call(wil, WMI_VRING_CFG_CMDID, &cmd, sizeof(cmd),
  598. WMI_VRING_CFG_DONE_EVENTID, &reply, sizeof(reply), 100);
  599. if (rc)
  600. goto out_free;
  601. if (reply.cmd.status != WMI_FW_STATUS_SUCCESS) {
  602. wil_err(wil, "Tx config failed, status 0x%02x\n",
  603. reply.cmd.status);
  604. rc = -EINVAL;
  605. goto out_free;
  606. }
  607. vring->hwtail = le32_to_cpu(reply.cmd.tx_vring_tail_ptr);
  608. txdata->enabled = 1;
  609. return 0;
  610. out_free:
  611. wil_vring_free(wil, vring, 1);
  612. out:
  613. return rc;
  614. }
  615. void wil_vring_fini_tx(struct wil6210_priv *wil, int id)
  616. {
  617. struct vring *vring = &wil->vring_tx[id];
  618. WARN_ON(!mutex_is_locked(&wil->mutex));
  619. if (!vring->va)
  620. return;
  621. wil_dbg_misc(wil, "%s() id=%d\n", __func__, id);
  622. /* make sure NAPI won't touch this vring */
  623. wil->vring_tx_data[id].enabled = 0;
  624. if (test_bit(wil_status_napi_en, &wil->status))
  625. napi_synchronize(&wil->napi_tx);
  626. wil_vring_free(wil, vring, 1);
  627. }
  628. static struct vring *wil_find_tx_vring(struct wil6210_priv *wil,
  629. struct sk_buff *skb)
  630. {
  631. int i;
  632. struct ethhdr *eth = (void *)skb->data;
  633. int cid = wil_find_cid(wil, eth->h_dest);
  634. if (cid < 0)
  635. return NULL;
  636. if (!wil->sta[cid].data_port_open &&
  637. (skb->protocol != cpu_to_be16(ETH_P_PAE)))
  638. return NULL;
  639. /* TODO: fix for multiple TID */
  640. for (i = 0; i < ARRAY_SIZE(wil->vring2cid_tid); i++) {
  641. if (wil->vring2cid_tid[i][0] == cid) {
  642. struct vring *v = &wil->vring_tx[i];
  643. wil_dbg_txrx(wil, "%s(%pM) -> [%d]\n",
  644. __func__, eth->h_dest, i);
  645. if (v->va) {
  646. return v;
  647. } else {
  648. wil_dbg_txrx(wil, "vring[%d] not valid\n", i);
  649. return NULL;
  650. }
  651. }
  652. }
  653. return NULL;
  654. }
  655. static void wil_set_da_for_vring(struct wil6210_priv *wil,
  656. struct sk_buff *skb, int vring_index)
  657. {
  658. struct ethhdr *eth = (void *)skb->data;
  659. int cid = wil->vring2cid_tid[vring_index][0];
  660. memcpy(eth->h_dest, wil->sta[cid].addr, ETH_ALEN);
  661. }
  662. static int wil_tx_vring(struct wil6210_priv *wil, struct vring *vring,
  663. struct sk_buff *skb);
  664. /*
  665. * Find 1-st vring and return it; set dest address for this vring in skb
  666. * duplicate skb and send it to other active vrings
  667. */
  668. static struct vring *wil_tx_bcast(struct wil6210_priv *wil,
  669. struct sk_buff *skb)
  670. {
  671. struct vring *v, *v2;
  672. struct sk_buff *skb2;
  673. int i;
  674. u8 cid;
  675. /* find 1-st vring eligible for data */
  676. for (i = 0; i < WIL6210_MAX_TX_RINGS; i++) {
  677. v = &wil->vring_tx[i];
  678. if (!v->va)
  679. continue;
  680. cid = wil->vring2cid_tid[i][0];
  681. if (!wil->sta[cid].data_port_open)
  682. continue;
  683. goto found;
  684. }
  685. wil_dbg_txrx(wil, "Tx while no vrings active?\n");
  686. return NULL;
  687. found:
  688. wil_dbg_txrx(wil, "BCAST -> ring %d\n", i);
  689. wil_set_da_for_vring(wil, skb, i);
  690. /* find other active vrings and duplicate skb for each */
  691. for (i++; i < WIL6210_MAX_TX_RINGS; i++) {
  692. v2 = &wil->vring_tx[i];
  693. if (!v2->va)
  694. continue;
  695. cid = wil->vring2cid_tid[i][0];
  696. if (!wil->sta[cid].data_port_open)
  697. continue;
  698. skb2 = skb_copy(skb, GFP_ATOMIC);
  699. if (skb2) {
  700. wil_dbg_txrx(wil, "BCAST DUP -> ring %d\n", i);
  701. wil_set_da_for_vring(wil, skb2, i);
  702. wil_tx_vring(wil, v2, skb2);
  703. } else {
  704. wil_err(wil, "skb_copy failed\n");
  705. }
  706. }
  707. return v;
  708. }
  709. static int wil_tx_desc_map(struct vring_tx_desc *d, dma_addr_t pa, u32 len,
  710. int vring_index)
  711. {
  712. wil_desc_addr_set(&d->dma.addr, pa);
  713. d->dma.ip_length = 0;
  714. /* 0..6: mac_length; 7:ip_version 0-IP6 1-IP4*/
  715. d->dma.b11 = 0/*14 | BIT(7)*/;
  716. d->dma.error = 0;
  717. d->dma.status = 0; /* BIT(0) should be 0 for HW_OWNED */
  718. d->dma.length = cpu_to_le16((u16)len);
  719. d->dma.d0 = (vring_index << DMA_CFG_DESC_TX_0_QID_POS);
  720. d->mac.d[0] = 0;
  721. d->mac.d[1] = 0;
  722. d->mac.d[2] = 0;
  723. d->mac.ucode_cmd = 0;
  724. /* use dst index 0 */
  725. d->mac.d[1] |= BIT(MAC_CFG_DESC_TX_1_DST_INDEX_EN_POS) |
  726. (0 << MAC_CFG_DESC_TX_1_DST_INDEX_POS);
  727. /* translation type: 0 - bypass; 1 - 802.3; 2 - native wifi */
  728. d->mac.d[2] = BIT(MAC_CFG_DESC_TX_2_SNAP_HDR_INSERTION_EN_POS) |
  729. (1 << MAC_CFG_DESC_TX_2_L2_TRANSLATION_TYPE_POS);
  730. return 0;
  731. }
  732. static inline
  733. void wil_tx_desc_set_nr_frags(struct vring_tx_desc *d, int nr_frags)
  734. {
  735. d->mac.d[2] |= ((nr_frags + 1) <<
  736. MAC_CFG_DESC_TX_2_NUM_OF_DESCRIPTORS_POS);
  737. }
  738. static int wil_tx_desc_offload_cksum_set(struct wil6210_priv *wil,
  739. struct vring_tx_desc *d,
  740. struct sk_buff *skb)
  741. {
  742. int protocol;
  743. if (skb->ip_summed != CHECKSUM_PARTIAL)
  744. return 0;
  745. d->dma.b11 = ETH_HLEN; /* MAC header length */
  746. switch (skb->protocol) {
  747. case cpu_to_be16(ETH_P_IP):
  748. protocol = ip_hdr(skb)->protocol;
  749. d->dma.b11 |= BIT(DMA_CFG_DESC_TX_OFFLOAD_CFG_L3T_IPV4_POS);
  750. break;
  751. case cpu_to_be16(ETH_P_IPV6):
  752. protocol = ipv6_hdr(skb)->nexthdr;
  753. break;
  754. default:
  755. return -EINVAL;
  756. }
  757. switch (protocol) {
  758. case IPPROTO_TCP:
  759. d->dma.d0 |= (2 << DMA_CFG_DESC_TX_0_L4_TYPE_POS);
  760. /* L4 header len: TCP header length */
  761. d->dma.d0 |=
  762. (tcp_hdrlen(skb) & DMA_CFG_DESC_TX_0_L4_LENGTH_MSK);
  763. break;
  764. case IPPROTO_UDP:
  765. /* L4 header len: UDP header length */
  766. d->dma.d0 |=
  767. (sizeof(struct udphdr) & DMA_CFG_DESC_TX_0_L4_LENGTH_MSK);
  768. break;
  769. default:
  770. return -EINVAL;
  771. }
  772. d->dma.ip_length = skb_network_header_len(skb);
  773. /* Enable TCP/UDP checksum */
  774. d->dma.d0 |= BIT(DMA_CFG_DESC_TX_0_TCP_UDP_CHECKSUM_EN_POS);
  775. /* Calculate pseudo-header */
  776. d->dma.d0 |= BIT(DMA_CFG_DESC_TX_0_PSEUDO_HEADER_CALC_EN_POS);
  777. return 0;
  778. }
  779. static int wil_tx_vring(struct wil6210_priv *wil, struct vring *vring,
  780. struct sk_buff *skb)
  781. {
  782. struct device *dev = wil_to_dev(wil);
  783. struct vring_tx_desc dd, *d = &dd;
  784. volatile struct vring_tx_desc *_d;
  785. u32 swhead = vring->swhead;
  786. int avail = wil_vring_avail_tx(vring);
  787. int nr_frags = skb_shinfo(skb)->nr_frags;
  788. uint f = 0;
  789. int vring_index = vring - wil->vring_tx;
  790. struct vring_tx_data *txdata = &wil->vring_tx_data[vring_index];
  791. uint i = swhead;
  792. dma_addr_t pa;
  793. wil_dbg_txrx(wil, "%s()\n", __func__);
  794. if (avail < 1 + nr_frags) {
  795. wil_err_ratelimited(wil,
  796. "Tx ring full. No space for %d fragments\n",
  797. 1 + nr_frags);
  798. return -ENOMEM;
  799. }
  800. _d = &vring->va[i].tx;
  801. pa = dma_map_single(dev, skb->data, skb_headlen(skb), DMA_TO_DEVICE);
  802. wil_dbg_txrx(wil, "Tx skb %d bytes 0x%p -> %pad\n", skb_headlen(skb),
  803. skb->data, &pa);
  804. wil_hex_dump_txrx("Tx ", DUMP_PREFIX_OFFSET, 16, 1,
  805. skb->data, skb_headlen(skb), false);
  806. if (unlikely(dma_mapping_error(dev, pa)))
  807. return -EINVAL;
  808. vring->ctx[i].mapped_as = wil_mapped_as_single;
  809. /* 1-st segment */
  810. wil_tx_desc_map(d, pa, skb_headlen(skb), vring_index);
  811. /* Process TCP/UDP checksum offloading */
  812. if (wil_tx_desc_offload_cksum_set(wil, d, skb)) {
  813. wil_err(wil, "VRING #%d Failed to set cksum, drop packet\n",
  814. vring_index);
  815. goto dma_error;
  816. }
  817. vring->ctx[i].nr_frags = nr_frags;
  818. wil_tx_desc_set_nr_frags(d, nr_frags);
  819. if (nr_frags)
  820. *_d = *d;
  821. /* middle segments */
  822. for (; f < nr_frags; f++) {
  823. const struct skb_frag_struct *frag =
  824. &skb_shinfo(skb)->frags[f];
  825. int len = skb_frag_size(frag);
  826. i = (swhead + f + 1) % vring->size;
  827. _d = &vring->va[i].tx;
  828. pa = skb_frag_dma_map(dev, frag, 0, skb_frag_size(frag),
  829. DMA_TO_DEVICE);
  830. if (unlikely(dma_mapping_error(dev, pa)))
  831. goto dma_error;
  832. vring->ctx[i].mapped_as = wil_mapped_as_page;
  833. wil_tx_desc_map(d, pa, len, vring_index);
  834. /* no need to check return code -
  835. * if it succeeded for 1-st descriptor,
  836. * it will succeed here too
  837. */
  838. wil_tx_desc_offload_cksum_set(wil, d, skb);
  839. *_d = *d;
  840. }
  841. /* for the last seg only */
  842. d->dma.d0 |= BIT(DMA_CFG_DESC_TX_0_CMD_EOP_POS);
  843. d->dma.d0 |= BIT(DMA_CFG_DESC_TX_0_CMD_MARK_WB_POS);
  844. d->dma.d0 |= BIT(DMA_CFG_DESC_TX_0_CMD_DMA_IT_POS);
  845. *_d = *d;
  846. /* hold reference to skb
  847. * to prevent skb release before accounting
  848. * in case of immediate "tx done"
  849. */
  850. vring->ctx[i].skb = skb_get(skb);
  851. wil_hex_dump_txrx("Tx ", DUMP_PREFIX_NONE, 32, 4,
  852. (const void *)d, sizeof(*d), false);
  853. if (wil_vring_is_empty(vring)) /* performance monitoring */
  854. txdata->idle += get_cycles() - txdata->last_idle;
  855. /* advance swhead */
  856. wil_vring_advance_head(vring, nr_frags + 1);
  857. wil_dbg_txrx(wil, "Tx swhead %d -> %d\n", swhead, vring->swhead);
  858. trace_wil6210_tx(vring_index, swhead, skb->len, nr_frags);
  859. iowrite32(vring->swhead, wil->csr + HOSTADDR(vring->hwtail));
  860. return 0;
  861. dma_error:
  862. /* unmap what we have mapped */
  863. nr_frags = f + 1; /* frags mapped + one for skb head */
  864. for (f = 0; f < nr_frags; f++) {
  865. struct wil_ctx *ctx;
  866. i = (swhead + f) % vring->size;
  867. ctx = &vring->ctx[i];
  868. _d = &vring->va[i].tx;
  869. *d = *_d;
  870. _d->dma.status = TX_DMA_STATUS_DU;
  871. wil_txdesc_unmap(dev, d, ctx);
  872. if (ctx->skb)
  873. dev_kfree_skb_any(ctx->skb);
  874. memset(ctx, 0, sizeof(*ctx));
  875. }
  876. return -EINVAL;
  877. }
  878. netdev_tx_t wil_start_xmit(struct sk_buff *skb, struct net_device *ndev)
  879. {
  880. struct wil6210_priv *wil = ndev_to_wil(ndev);
  881. struct ethhdr *eth = (void *)skb->data;
  882. struct vring *vring;
  883. static bool pr_once_fw;
  884. int rc;
  885. wil_dbg_txrx(wil, "%s()\n", __func__);
  886. if (!test_bit(wil_status_fwready, &wil->status)) {
  887. if (!pr_once_fw) {
  888. wil_err(wil, "FW not ready\n");
  889. pr_once_fw = true;
  890. }
  891. goto drop;
  892. }
  893. if (!test_bit(wil_status_fwconnected, &wil->status)) {
  894. wil_err(wil, "FW not connected\n");
  895. goto drop;
  896. }
  897. if (wil->wdev->iftype == NL80211_IFTYPE_MONITOR) {
  898. wil_err(wil, "Xmit in monitor mode not supported\n");
  899. goto drop;
  900. }
  901. pr_once_fw = false;
  902. /* find vring */
  903. if (is_unicast_ether_addr(eth->h_dest))
  904. vring = wil_find_tx_vring(wil, skb);
  905. else
  906. vring = wil_tx_bcast(wil, skb);
  907. if (!vring) {
  908. wil_dbg_txrx(wil, "No Tx VRING found for %pM\n", eth->h_dest);
  909. goto drop;
  910. }
  911. /* set up vring entry */
  912. rc = wil_tx_vring(wil, vring, skb);
  913. /* do we still have enough room in the vring? */
  914. if (wil_vring_avail_tx(vring) < wil_vring_wmark_low(vring)) {
  915. netif_tx_stop_all_queues(wil_to_ndev(wil));
  916. wil_dbg_txrx(wil, "netif_tx_stop : ring full\n");
  917. }
  918. switch (rc) {
  919. case 0:
  920. /* statistics will be updated on the tx_complete */
  921. dev_kfree_skb_any(skb);
  922. return NETDEV_TX_OK;
  923. case -ENOMEM:
  924. return NETDEV_TX_BUSY;
  925. default:
  926. break; /* goto drop; */
  927. }
  928. drop:
  929. ndev->stats.tx_dropped++;
  930. dev_kfree_skb_any(skb);
  931. return NET_XMIT_DROP;
  932. }
  933. /**
  934. * Clean up transmitted skb's from the Tx VRING
  935. *
  936. * Return number of descriptors cleared
  937. *
  938. * Safe to call from IRQ
  939. */
  940. int wil_tx_complete(struct wil6210_priv *wil, int ringid)
  941. {
  942. struct net_device *ndev = wil_to_ndev(wil);
  943. struct device *dev = wil_to_dev(wil);
  944. struct vring *vring = &wil->vring_tx[ringid];
  945. struct vring_tx_data *txdata = &wil->vring_tx_data[ringid];
  946. int done = 0;
  947. int cid = wil->vring2cid_tid[ringid][0];
  948. struct wil_net_stats *stats = &wil->sta[cid].stats;
  949. volatile struct vring_tx_desc *_d;
  950. if (!vring->va) {
  951. wil_err(wil, "Tx irq[%d]: vring not initialized\n", ringid);
  952. return 0;
  953. }
  954. if (!txdata->enabled) {
  955. wil_info(wil, "Tx irq[%d]: vring disabled\n", ringid);
  956. return 0;
  957. }
  958. wil_dbg_txrx(wil, "%s(%d)\n", __func__, ringid);
  959. while (!wil_vring_is_empty(vring)) {
  960. int new_swtail;
  961. struct wil_ctx *ctx = &vring->ctx[vring->swtail];
  962. /**
  963. * For the fragmented skb, HW will set DU bit only for the
  964. * last fragment. look for it
  965. */
  966. int lf = (vring->swtail + ctx->nr_frags) % vring->size;
  967. /* TODO: check we are not past head */
  968. _d = &vring->va[lf].tx;
  969. if (!(_d->dma.status & TX_DMA_STATUS_DU))
  970. break;
  971. new_swtail = (lf + 1) % vring->size;
  972. while (vring->swtail != new_swtail) {
  973. struct vring_tx_desc dd, *d = &dd;
  974. u16 dmalen;
  975. struct sk_buff *skb;
  976. ctx = &vring->ctx[vring->swtail];
  977. skb = ctx->skb;
  978. _d = &vring->va[vring->swtail].tx;
  979. *d = *_d;
  980. dmalen = le16_to_cpu(d->dma.length);
  981. trace_wil6210_tx_done(ringid, vring->swtail, dmalen,
  982. d->dma.error);
  983. wil_dbg_txrx(wil,
  984. "Tx[%3d] : %d bytes, status 0x%02x err 0x%02x\n",
  985. vring->swtail, dmalen, d->dma.status,
  986. d->dma.error);
  987. wil_hex_dump_txrx("TxC ", DUMP_PREFIX_NONE, 32, 4,
  988. (const void *)d, sizeof(*d), false);
  989. wil_txdesc_unmap(dev, d, ctx);
  990. if (skb) {
  991. if (d->dma.error == 0) {
  992. ndev->stats.tx_packets++;
  993. stats->tx_packets++;
  994. ndev->stats.tx_bytes += skb->len;
  995. stats->tx_bytes += skb->len;
  996. } else {
  997. ndev->stats.tx_errors++;
  998. stats->tx_errors++;
  999. }
  1000. dev_kfree_skb_any(skb);
  1001. }
  1002. memset(ctx, 0, sizeof(*ctx));
  1003. /* There is no need to touch HW descriptor:
  1004. * - ststus bit TX_DMA_STATUS_DU is set by design,
  1005. * so hardware will not try to process this desc.,
  1006. * - rest of descriptor will be initialized on Tx.
  1007. */
  1008. vring->swtail = wil_vring_next_tail(vring);
  1009. done++;
  1010. }
  1011. }
  1012. if (wil_vring_is_empty(vring)) { /* performance monitoring */
  1013. wil_dbg_txrx(wil, "Ring[%2d] empty\n", ringid);
  1014. txdata->last_idle = get_cycles();
  1015. }
  1016. if (wil_vring_avail_tx(vring) > wil_vring_wmark_high(vring)) {
  1017. wil_dbg_txrx(wil, "netif_tx_wake : ring not full\n");
  1018. netif_tx_wake_all_queues(wil_to_ndev(wil));
  1019. }
  1020. return done;
  1021. }