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