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 = RX_BUF_LEN;
  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. /* TODO align */
  186. struct sk_buff *skb = dev_alloc_skb(sz + headroom);
  187. if (unlikely(!skb))
  188. return -ENOMEM;
  189. skb_reserve(skb, headroom);
  190. skb_put(skb, sz);
  191. pa = dma_map_single(dev, skb->data, skb->len, DMA_FROM_DEVICE);
  192. if (unlikely(dma_mapping_error(dev, pa))) {
  193. kfree_skb(skb);
  194. return -ENOMEM;
  195. }
  196. d->dma.d0 = BIT(9) | RX_DMA_D0_CMD_DMA_IT;
  197. wil_desc_addr_set(&d->dma.addr, pa);
  198. /* ip_length don't care */
  199. /* b11 don't care */
  200. /* error don't care */
  201. d->dma.status = 0; /* BIT(0) should be 0 for HW_OWNED */
  202. d->dma.length = cpu_to_le16(sz);
  203. *_d = *d;
  204. vring->ctx[i].skb = skb;
  205. return 0;
  206. }
  207. /**
  208. * Adds radiotap header
  209. *
  210. * Any error indicated as "Bad FCS"
  211. *
  212. * Vendor data for 04:ce:14-1 (Wilocity-1) consists of:
  213. * - Rx descriptor: 32 bytes
  214. * - Phy info
  215. */
  216. static void wil_rx_add_radiotap_header(struct wil6210_priv *wil,
  217. struct sk_buff *skb)
  218. {
  219. struct wireless_dev *wdev = wil->wdev;
  220. struct wil6210_rtap {
  221. struct ieee80211_radiotap_header rthdr;
  222. /* fields should be in the order of bits in rthdr.it_present */
  223. /* flags */
  224. u8 flags;
  225. /* channel */
  226. __le16 chnl_freq __aligned(2);
  227. __le16 chnl_flags;
  228. /* MCS */
  229. u8 mcs_present;
  230. u8 mcs_flags;
  231. u8 mcs_index;
  232. } __packed;
  233. struct wil6210_rtap_vendor {
  234. struct wil6210_rtap rtap;
  235. /* vendor */
  236. u8 vendor_oui[3] __aligned(2);
  237. u8 vendor_ns;
  238. __le16 vendor_skip;
  239. u8 vendor_data[0];
  240. } __packed;
  241. struct vring_rx_desc *d = wil_skb_rxdesc(skb);
  242. struct wil6210_rtap_vendor *rtap_vendor;
  243. int rtap_len = sizeof(struct wil6210_rtap);
  244. int phy_length = 0; /* phy info header size, bytes */
  245. static char phy_data[128];
  246. struct ieee80211_channel *ch = wdev->preset_chandef.chan;
  247. if (rtap_include_phy_info) {
  248. rtap_len = sizeof(*rtap_vendor) + sizeof(*d);
  249. /* calculate additional length */
  250. if (d->dma.status & RX_DMA_STATUS_PHY_INFO) {
  251. /**
  252. * PHY info starts from 8-byte boundary
  253. * there are 8-byte lines, last line may be partially
  254. * written (HW bug), thus FW configures for last line
  255. * to be excessive. Driver skips this last line.
  256. */
  257. int len = min_t(int, 8 + sizeof(phy_data),
  258. wil_rxdesc_phy_length(d));
  259. if (len > 8) {
  260. void *p = skb_tail_pointer(skb);
  261. void *pa = PTR_ALIGN(p, 8);
  262. if (skb_tailroom(skb) >= len + (pa - p)) {
  263. phy_length = len - 8;
  264. memcpy(phy_data, pa, phy_length);
  265. }
  266. }
  267. }
  268. rtap_len += phy_length;
  269. }
  270. if (skb_headroom(skb) < rtap_len &&
  271. pskb_expand_head(skb, rtap_len, 0, GFP_ATOMIC)) {
  272. wil_err(wil, "Unable to expand headrom to %d\n", rtap_len);
  273. return;
  274. }
  275. rtap_vendor = (void *)skb_push(skb, rtap_len);
  276. memset(rtap_vendor, 0, rtap_len);
  277. rtap_vendor->rtap.rthdr.it_version = PKTHDR_RADIOTAP_VERSION;
  278. rtap_vendor->rtap.rthdr.it_len = cpu_to_le16(rtap_len);
  279. rtap_vendor->rtap.rthdr.it_present = cpu_to_le32(
  280. (1 << IEEE80211_RADIOTAP_FLAGS) |
  281. (1 << IEEE80211_RADIOTAP_CHANNEL) |
  282. (1 << IEEE80211_RADIOTAP_MCS));
  283. if (d->dma.status & RX_DMA_STATUS_ERROR)
  284. rtap_vendor->rtap.flags |= IEEE80211_RADIOTAP_F_BADFCS;
  285. rtap_vendor->rtap.chnl_freq = cpu_to_le16(ch ? ch->center_freq : 58320);
  286. rtap_vendor->rtap.chnl_flags = cpu_to_le16(0);
  287. rtap_vendor->rtap.mcs_present = IEEE80211_RADIOTAP_MCS_HAVE_MCS;
  288. rtap_vendor->rtap.mcs_flags = 0;
  289. rtap_vendor->rtap.mcs_index = wil_rxdesc_mcs(d);
  290. if (rtap_include_phy_info) {
  291. rtap_vendor->rtap.rthdr.it_present |= cpu_to_le32(1 <<
  292. IEEE80211_RADIOTAP_VENDOR_NAMESPACE);
  293. /* OUI for Wilocity 04:ce:14 */
  294. rtap_vendor->vendor_oui[0] = 0x04;
  295. rtap_vendor->vendor_oui[1] = 0xce;
  296. rtap_vendor->vendor_oui[2] = 0x14;
  297. rtap_vendor->vendor_ns = 1;
  298. /* Rx descriptor + PHY data */
  299. rtap_vendor->vendor_skip = cpu_to_le16(sizeof(*d) +
  300. phy_length);
  301. memcpy(rtap_vendor->vendor_data, (void *)d, sizeof(*d));
  302. memcpy(rtap_vendor->vendor_data + sizeof(*d), phy_data,
  303. phy_length);
  304. }
  305. }
  306. /*
  307. * Fast swap in place between 2 registers
  308. */
  309. static void wil_swap_u16(u16 *a, u16 *b)
  310. {
  311. *a ^= *b;
  312. *b ^= *a;
  313. *a ^= *b;
  314. }
  315. static void wil_swap_ethaddr(void *data)
  316. {
  317. struct ethhdr *eth = data;
  318. u16 *s = (u16 *)eth->h_source;
  319. u16 *d = (u16 *)eth->h_dest;
  320. wil_swap_u16(s++, d++);
  321. wil_swap_u16(s++, d++);
  322. wil_swap_u16(s, d);
  323. }
  324. /**
  325. * reap 1 frame from @swhead
  326. *
  327. * Rx descriptor copied to skb->cb
  328. *
  329. * Safe to call from IRQ
  330. */
  331. static struct sk_buff *wil_vring_reap_rx(struct wil6210_priv *wil,
  332. struct vring *vring)
  333. {
  334. struct device *dev = wil_to_dev(wil);
  335. struct net_device *ndev = wil_to_ndev(wil);
  336. volatile struct vring_rx_desc *_d;
  337. struct vring_rx_desc *d;
  338. struct sk_buff *skb;
  339. dma_addr_t pa;
  340. unsigned int sz = RX_BUF_LEN;
  341. u16 dmalen;
  342. u8 ftype;
  343. u8 ds_bits;
  344. int cid;
  345. struct wil_net_stats *stats;
  346. BUILD_BUG_ON(sizeof(struct vring_rx_desc) > sizeof(skb->cb));
  347. if (wil_vring_is_empty(vring))
  348. return NULL;
  349. _d = &vring->va[vring->swhead].rx;
  350. if (!(_d->dma.status & RX_DMA_STATUS_DU)) {
  351. /* it is not error, we just reached end of Rx done area */
  352. return NULL;
  353. }
  354. skb = vring->ctx[vring->swhead].skb;
  355. d = wil_skb_rxdesc(skb);
  356. *d = *_d;
  357. pa = wil_desc_addr(&d->dma.addr);
  358. vring->ctx[vring->swhead].skb = NULL;
  359. wil_vring_advance_head(vring, 1);
  360. dma_unmap_single(dev, pa, sz, DMA_FROM_DEVICE);
  361. dmalen = le16_to_cpu(d->dma.length);
  362. trace_wil6210_rx(vring->swhead, d);
  363. wil_dbg_txrx(wil, "Rx[%3d] : %d bytes\n", vring->swhead, dmalen);
  364. wil_hex_dump_txrx("Rx ", DUMP_PREFIX_NONE, 32, 4,
  365. (const void *)d, sizeof(*d), false);
  366. if (dmalen > sz) {
  367. wil_err(wil, "Rx size too large: %d bytes!\n", dmalen);
  368. kfree_skb(skb);
  369. return NULL;
  370. }
  371. skb_trim(skb, dmalen);
  372. prefetch(skb->data);
  373. wil_hex_dump_txrx("Rx ", DUMP_PREFIX_OFFSET, 16, 1,
  374. skb->data, skb_headlen(skb), false);
  375. cid = wil_rxdesc_cid(d);
  376. stats = &wil->sta[cid].stats;
  377. stats->last_mcs_rx = wil_rxdesc_mcs(d);
  378. /* use radiotap header only if required */
  379. if (ndev->type == ARPHRD_IEEE80211_RADIOTAP)
  380. wil_rx_add_radiotap_header(wil, skb);
  381. /* no extra checks if in sniffer mode */
  382. if (ndev->type != ARPHRD_ETHER)
  383. return skb;
  384. /*
  385. * Non-data frames may be delivered through Rx DMA channel (ex: BAR)
  386. * Driver should recognize it by frame type, that is found
  387. * in Rx descriptor. If type is not data, it is 802.11 frame as is
  388. */
  389. ftype = wil_rxdesc_ftype(d) << 2;
  390. if (ftype != IEEE80211_FTYPE_DATA) {
  391. wil_dbg_txrx(wil, "Non-data frame ftype 0x%08x\n", ftype);
  392. /* TODO: process it */
  393. kfree_skb(skb);
  394. return NULL;
  395. }
  396. if (skb->len < ETH_HLEN) {
  397. wil_err(wil, "Short frame, len = %d\n", skb->len);
  398. /* TODO: process it (i.e. BAR) */
  399. kfree_skb(skb);
  400. return NULL;
  401. }
  402. /* L4 IDENT is on when HW calculated checksum, check status
  403. * and in case of error drop the packet
  404. * higher stack layers will handle retransmission (if required)
  405. */
  406. if (d->dma.status & RX_DMA_STATUS_L4_IDENT) {
  407. /* L4 protocol identified, csum calculated */
  408. if ((d->dma.error & RX_DMA_ERROR_L4_ERR) == 0)
  409. skb->ip_summed = CHECKSUM_UNNECESSARY;
  410. /* If HW reports bad checksum, let IP stack re-check it
  411. * For example, HW don't understand Microsoft IP stack that
  412. * mis-calculates TCP checksum - if it should be 0x0,
  413. * it writes 0xffff in violation of RFC 1624
  414. */
  415. }
  416. ds_bits = wil_rxdesc_ds_bits(d);
  417. if (ds_bits == 1) {
  418. /*
  419. * HW bug - in ToDS mode, i.e. Rx on AP side,
  420. * addresses get swapped
  421. */
  422. wil_swap_ethaddr(skb->data);
  423. }
  424. return skb;
  425. }
  426. /**
  427. * allocate and fill up to @count buffers in rx ring
  428. * buffers posted at @swtail
  429. */
  430. static int wil_rx_refill(struct wil6210_priv *wil, int count)
  431. {
  432. struct net_device *ndev = wil_to_ndev(wil);
  433. struct vring *v = &wil->vring_rx;
  434. u32 next_tail;
  435. int rc = 0;
  436. int headroom = ndev->type == ARPHRD_IEEE80211_RADIOTAP ?
  437. WIL6210_RTAP_SIZE : 0;
  438. for (; next_tail = wil_vring_next_tail(v),
  439. (next_tail != v->swhead) && (count-- > 0);
  440. v->swtail = next_tail) {
  441. rc = wil_vring_alloc_skb(wil, v, v->swtail, headroom);
  442. if (rc) {
  443. wil_err(wil, "Error %d in wil_rx_refill[%d]\n",
  444. rc, v->swtail);
  445. break;
  446. }
  447. }
  448. iowrite32(v->swtail, wil->csr + HOSTADDR(v->hwtail));
  449. return rc;
  450. }
  451. /*
  452. * Pass Rx packet to the netif. Update statistics.
  453. * Called in softirq context (NAPI poll).
  454. */
  455. void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev)
  456. {
  457. gro_result_t rc;
  458. struct wil6210_priv *wil = ndev_to_wil(ndev);
  459. unsigned int len = skb->len;
  460. struct vring_rx_desc *d = wil_skb_rxdesc(skb);
  461. int cid = wil_rxdesc_cid(d);
  462. struct wil_net_stats *stats = &wil->sta[cid].stats;
  463. skb_orphan(skb);
  464. rc = napi_gro_receive(&wil->napi_rx, skb);
  465. if (unlikely(rc == GRO_DROP)) {
  466. ndev->stats.rx_dropped++;
  467. stats->rx_dropped++;
  468. wil_dbg_txrx(wil, "Rx drop %d bytes\n", len);
  469. } else {
  470. ndev->stats.rx_packets++;
  471. stats->rx_packets++;
  472. ndev->stats.rx_bytes += len;
  473. stats->rx_bytes += len;
  474. }
  475. {
  476. static const char * const gro_res_str[] = {
  477. [GRO_MERGED] = "GRO_MERGED",
  478. [GRO_MERGED_FREE] = "GRO_MERGED_FREE",
  479. [GRO_HELD] = "GRO_HELD",
  480. [GRO_NORMAL] = "GRO_NORMAL",
  481. [GRO_DROP] = "GRO_DROP",
  482. };
  483. wil_dbg_txrx(wil, "Rx complete %d bytes => %s\n",
  484. len, gro_res_str[rc]);
  485. }
  486. }
  487. /**
  488. * Proceed all completed skb's from Rx VRING
  489. *
  490. * Safe to call from NAPI poll, i.e. softirq with interrupts enabled
  491. */
  492. void wil_rx_handle(struct wil6210_priv *wil, int *quota)
  493. {
  494. struct net_device *ndev = wil_to_ndev(wil);
  495. struct vring *v = &wil->vring_rx;
  496. struct sk_buff *skb;
  497. if (!v->va) {
  498. wil_err(wil, "Rx IRQ while Rx not yet initialized\n");
  499. return;
  500. }
  501. wil_dbg_txrx(wil, "%s()\n", __func__);
  502. while ((*quota > 0) && (NULL != (skb = wil_vring_reap_rx(wil, v)))) {
  503. (*quota)--;
  504. if (wil->wdev->iftype == NL80211_IFTYPE_MONITOR) {
  505. skb->dev = ndev;
  506. skb_reset_mac_header(skb);
  507. skb->ip_summed = CHECKSUM_UNNECESSARY;
  508. skb->pkt_type = PACKET_OTHERHOST;
  509. skb->protocol = htons(ETH_P_802_2);
  510. wil_netif_rx_any(skb, ndev);
  511. } else {
  512. struct ethhdr *eth = (void *)skb->data;
  513. skb->protocol = eth_type_trans(skb, ndev);
  514. if (is_unicast_ether_addr(eth->h_dest))
  515. wil_rx_reorder(wil, skb);
  516. else
  517. wil_netif_rx_any(skb, ndev);
  518. }
  519. }
  520. wil_rx_refill(wil, v->size);
  521. }
  522. int wil_rx_init(struct wil6210_priv *wil)
  523. {
  524. struct vring *vring = &wil->vring_rx;
  525. int rc;
  526. wil_dbg_misc(wil, "%s()\n", __func__);
  527. if (vring->va) {
  528. wil_err(wil, "Rx ring already allocated\n");
  529. return -EINVAL;
  530. }
  531. vring->size = WIL6210_RX_RING_SIZE;
  532. rc = wil_vring_alloc(wil, vring);
  533. if (rc)
  534. return rc;
  535. rc = wmi_rx_chain_add(wil, vring);
  536. if (rc)
  537. goto err_free;
  538. rc = wil_rx_refill(wil, vring->size);
  539. if (rc)
  540. goto err_free;
  541. return 0;
  542. err_free:
  543. wil_vring_free(wil, vring, 0);
  544. return rc;
  545. }
  546. void wil_rx_fini(struct wil6210_priv *wil)
  547. {
  548. struct vring *vring = &wil->vring_rx;
  549. wil_dbg_misc(wil, "%s()\n", __func__);
  550. if (vring->va)
  551. wil_vring_free(wil, vring, 0);
  552. }
  553. int wil_vring_init_tx(struct wil6210_priv *wil, int id, int size,
  554. int cid, int tid)
  555. {
  556. int rc;
  557. struct wmi_vring_cfg_cmd cmd = {
  558. .action = cpu_to_le32(WMI_VRING_CMD_ADD),
  559. .vring_cfg = {
  560. .tx_sw_ring = {
  561. .max_mpdu_size = cpu_to_le16(TX_BUF_LEN),
  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(wil, "Tx ring full. No space for %d fragments\n",
  796. 1 + nr_frags);
  797. return -ENOMEM;
  798. }
  799. _d = &vring->va[i].tx;
  800. pa = dma_map_single(dev, skb->data, skb_headlen(skb), DMA_TO_DEVICE);
  801. wil_dbg_txrx(wil, "Tx skb %d bytes 0x%p -> %pad\n", skb_headlen(skb),
  802. skb->data, &pa);
  803. wil_hex_dump_txrx("Tx ", DUMP_PREFIX_OFFSET, 16, 1,
  804. skb->data, skb_headlen(skb), false);
  805. if (unlikely(dma_mapping_error(dev, pa)))
  806. return -EINVAL;
  807. vring->ctx[i].mapped_as = wil_mapped_as_single;
  808. /* 1-st segment */
  809. wil_tx_desc_map(d, pa, skb_headlen(skb), vring_index);
  810. /* Process TCP/UDP checksum offloading */
  811. if (wil_tx_desc_offload_cksum_set(wil, d, skb)) {
  812. wil_err(wil, "VRING #%d Failed to set cksum, drop packet\n",
  813. vring_index);
  814. goto dma_error;
  815. }
  816. vring->ctx[i].nr_frags = nr_frags;
  817. wil_tx_desc_set_nr_frags(d, nr_frags);
  818. if (nr_frags)
  819. *_d = *d;
  820. /* middle segments */
  821. for (; f < nr_frags; f++) {
  822. const struct skb_frag_struct *frag =
  823. &skb_shinfo(skb)->frags[f];
  824. int len = skb_frag_size(frag);
  825. i = (swhead + f + 1) % vring->size;
  826. _d = &vring->va[i].tx;
  827. pa = skb_frag_dma_map(dev, frag, 0, skb_frag_size(frag),
  828. DMA_TO_DEVICE);
  829. if (unlikely(dma_mapping_error(dev, pa)))
  830. goto dma_error;
  831. vring->ctx[i].mapped_as = wil_mapped_as_page;
  832. wil_tx_desc_map(d, pa, len, vring_index);
  833. /* no need to check return code -
  834. * if it succeeded for 1-st descriptor,
  835. * it will succeed here too
  836. */
  837. wil_tx_desc_offload_cksum_set(wil, d, skb);
  838. *_d = *d;
  839. }
  840. /* for the last seg only */
  841. d->dma.d0 |= BIT(DMA_CFG_DESC_TX_0_CMD_EOP_POS);
  842. d->dma.d0 |= BIT(DMA_CFG_DESC_TX_0_CMD_MARK_WB_POS);
  843. d->dma.d0 |= BIT(DMA_CFG_DESC_TX_0_CMD_DMA_IT_POS);
  844. *_d = *d;
  845. /* hold reference to skb
  846. * to prevent skb release before accounting
  847. * in case of immediate "tx done"
  848. */
  849. vring->ctx[i].skb = skb_get(skb);
  850. wil_hex_dump_txrx("Tx ", DUMP_PREFIX_NONE, 32, 4,
  851. (const void *)d, sizeof(*d), false);
  852. if (wil_vring_is_empty(vring)) /* performance monitoring */
  853. txdata->idle += get_cycles() - txdata->last_idle;
  854. /* advance swhead */
  855. wil_vring_advance_head(vring, nr_frags + 1);
  856. wil_dbg_txrx(wil, "Tx swhead %d -> %d\n", swhead, vring->swhead);
  857. trace_wil6210_tx(vring_index, swhead, skb->len, nr_frags);
  858. iowrite32(vring->swhead, wil->csr + HOSTADDR(vring->hwtail));
  859. return 0;
  860. dma_error:
  861. /* unmap what we have mapped */
  862. nr_frags = f + 1; /* frags mapped + one for skb head */
  863. for (f = 0; f < nr_frags; f++) {
  864. struct wil_ctx *ctx;
  865. i = (swhead + f) % vring->size;
  866. ctx = &vring->ctx[i];
  867. _d = &vring->va[i].tx;
  868. *d = *_d;
  869. _d->dma.status = TX_DMA_STATUS_DU;
  870. wil_txdesc_unmap(dev, d, ctx);
  871. if (ctx->skb)
  872. dev_kfree_skb_any(ctx->skb);
  873. memset(ctx, 0, sizeof(*ctx));
  874. }
  875. return -EINVAL;
  876. }
  877. netdev_tx_t wil_start_xmit(struct sk_buff *skb, struct net_device *ndev)
  878. {
  879. struct wil6210_priv *wil = ndev_to_wil(ndev);
  880. struct ethhdr *eth = (void *)skb->data;
  881. struct vring *vring;
  882. static bool pr_once_fw;
  883. int rc;
  884. wil_dbg_txrx(wil, "%s()\n", __func__);
  885. if (!test_bit(wil_status_fwready, &wil->status)) {
  886. if (!pr_once_fw) {
  887. wil_err(wil, "FW not ready\n");
  888. pr_once_fw = true;
  889. }
  890. goto drop;
  891. }
  892. if (!test_bit(wil_status_fwconnected, &wil->status)) {
  893. wil_err(wil, "FW not connected\n");
  894. goto drop;
  895. }
  896. if (wil->wdev->iftype == NL80211_IFTYPE_MONITOR) {
  897. wil_err(wil, "Xmit in monitor mode not supported\n");
  898. goto drop;
  899. }
  900. pr_once_fw = false;
  901. /* find vring */
  902. if (is_unicast_ether_addr(eth->h_dest))
  903. vring = wil_find_tx_vring(wil, skb);
  904. else
  905. vring = wil_tx_bcast(wil, skb);
  906. if (!vring) {
  907. wil_dbg_txrx(wil, "No Tx VRING found for %pM\n", eth->h_dest);
  908. goto drop;
  909. }
  910. /* set up vring entry */
  911. rc = wil_tx_vring(wil, vring, skb);
  912. /* do we still have enough room in the vring? */
  913. if (wil_vring_avail_tx(vring) < wil_vring_wmark_low(vring)) {
  914. netif_tx_stop_all_queues(wil_to_ndev(wil));
  915. wil_dbg_txrx(wil, "netif_tx_stop : ring full\n");
  916. }
  917. switch (rc) {
  918. case 0:
  919. /* statistics will be updated on the tx_complete */
  920. dev_kfree_skb_any(skb);
  921. return NETDEV_TX_OK;
  922. case -ENOMEM:
  923. return NETDEV_TX_BUSY;
  924. default:
  925. break; /* goto drop; */
  926. }
  927. drop:
  928. ndev->stats.tx_dropped++;
  929. dev_kfree_skb_any(skb);
  930. return NET_XMIT_DROP;
  931. }
  932. /**
  933. * Clean up transmitted skb's from the Tx VRING
  934. *
  935. * Return number of descriptors cleared
  936. *
  937. * Safe to call from IRQ
  938. */
  939. int wil_tx_complete(struct wil6210_priv *wil, int ringid)
  940. {
  941. struct net_device *ndev = wil_to_ndev(wil);
  942. struct device *dev = wil_to_dev(wil);
  943. struct vring *vring = &wil->vring_tx[ringid];
  944. struct vring_tx_data *txdata = &wil->vring_tx_data[ringid];
  945. int done = 0;
  946. int cid = wil->vring2cid_tid[ringid][0];
  947. struct wil_net_stats *stats = &wil->sta[cid].stats;
  948. volatile struct vring_tx_desc *_d;
  949. if (!vring->va) {
  950. wil_err(wil, "Tx irq[%d]: vring not initialized\n", ringid);
  951. return 0;
  952. }
  953. if (!txdata->enabled) {
  954. wil_info(wil, "Tx irq[%d]: vring disabled\n", ringid);
  955. return 0;
  956. }
  957. wil_dbg_txrx(wil, "%s(%d)\n", __func__, ringid);
  958. while (!wil_vring_is_empty(vring)) {
  959. int new_swtail;
  960. struct wil_ctx *ctx = &vring->ctx[vring->swtail];
  961. /**
  962. * For the fragmented skb, HW will set DU bit only for the
  963. * last fragment. look for it
  964. */
  965. int lf = (vring->swtail + ctx->nr_frags) % vring->size;
  966. /* TODO: check we are not past head */
  967. _d = &vring->va[lf].tx;
  968. if (!(_d->dma.status & TX_DMA_STATUS_DU))
  969. break;
  970. new_swtail = (lf + 1) % vring->size;
  971. while (vring->swtail != new_swtail) {
  972. struct vring_tx_desc dd, *d = &dd;
  973. u16 dmalen;
  974. struct sk_buff *skb;
  975. ctx = &vring->ctx[vring->swtail];
  976. skb = ctx->skb;
  977. _d = &vring->va[vring->swtail].tx;
  978. *d = *_d;
  979. dmalen = le16_to_cpu(d->dma.length);
  980. trace_wil6210_tx_done(ringid, vring->swtail, dmalen,
  981. d->dma.error);
  982. wil_dbg_txrx(wil,
  983. "Tx[%3d] : %d bytes, status 0x%02x err 0x%02x\n",
  984. vring->swtail, dmalen, d->dma.status,
  985. d->dma.error);
  986. wil_hex_dump_txrx("TxC ", DUMP_PREFIX_NONE, 32, 4,
  987. (const void *)d, sizeof(*d), false);
  988. wil_txdesc_unmap(dev, d, ctx);
  989. if (skb) {
  990. if (d->dma.error == 0) {
  991. ndev->stats.tx_packets++;
  992. stats->tx_packets++;
  993. ndev->stats.tx_bytes += skb->len;
  994. stats->tx_bytes += skb->len;
  995. } else {
  996. ndev->stats.tx_errors++;
  997. stats->tx_errors++;
  998. }
  999. dev_kfree_skb_any(skb);
  1000. }
  1001. memset(ctx, 0, sizeof(*ctx));
  1002. /* There is no need to touch HW descriptor:
  1003. * - ststus bit TX_DMA_STATUS_DU is set by design,
  1004. * so hardware will not try to process this desc.,
  1005. * - rest of descriptor will be initialized on Tx.
  1006. */
  1007. vring->swtail = wil_vring_next_tail(vring);
  1008. done++;
  1009. }
  1010. }
  1011. if (wil_vring_is_empty(vring)) { /* performance monitoring */
  1012. wil_dbg_txrx(wil, "Ring[%2d] empty\n", ringid);
  1013. txdata->last_idle = get_cycles();
  1014. }
  1015. if (wil_vring_avail_tx(vring) > wil_vring_wmark_high(vring)) {
  1016. wil_dbg_txrx(wil, "netif_tx_wake : ring not full\n");
  1017. netif_tx_wake_all_queues(wil_to_ndev(wil));
  1018. }
  1019. return done;
  1020. }