developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1 | From 3516b23f9acad60c44a13119e42636f92ca9d9a2 Mon Sep 17 00:00:00 2001 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 2 | From: Sujuan Chen <sujuan.chen@mediatek.com> |
| 3 | Date: Tue, 5 Jul 2022 19:42:55 +0800 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 3002/3006] mt76 add wed rx support |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com> |
| 7 | --- |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 8 | dma.c | 250 ++++++++++++++++++++++++++++++++++++++-------- |
| 9 | dma.h | 10 ++ |
| 10 | mac80211.c | 8 +- |
| 11 | mt76.h | 25 ++++- |
| 12 | mt7603/dma.c | 2 +- |
| 13 | mt7603/mt7603.h | 2 +- |
| 14 | mt7615/mac.c | 2 +- |
| 15 | mt7615/mt7615.h | 2 +- |
| 16 | mt76_connac_mcu.c | 9 ++ |
| 17 | mt76x02.h | 2 +- |
| 18 | mt76x02_txrx.c | 2 +- |
| 19 | mt7915/dma.c | 25 +++-- |
| 20 | mt7915/init.c | 9 ++ |
| 21 | mt7915/mac.c | 103 ++++++++++++++++++- |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 22 | mt7915/main.c | 26 ++++- |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 23 | mt7915/mcu.c | 14 ++- |
| 24 | mt7915/mcu.h | 1 + |
| 25 | mt7915/mmio.c | 26 ++++- |
| 26 | mt7915/mt7915.h | 10 +- |
| 27 | mt7915/regs.h | 14 ++- |
| 28 | mt7921/mac.c | 2 +- |
| 29 | mt7921/mt7921.h | 4 +- |
| 30 | mt7921/pci_mac.c | 4 +- |
| 31 | tx.c | 34 +++++++ |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 32 | 24 files changed, 505 insertions(+), 81 deletions(-) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 33 | |
| 34 | diff --git a/dma.c b/dma.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 35 | index 8ea09e6..3317d2b 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 36 | --- a/dma.c |
| 37 | +++ b/dma.c |
| 38 | @@ -98,6 +98,63 @@ mt76_put_txwi(struct mt76_dev *dev, struct mt76_txwi_cache *t) |
| 39 | } |
| 40 | EXPORT_SYMBOL_GPL(mt76_put_txwi); |
| 41 | |
| 42 | +static struct mt76_txwi_cache * |
| 43 | +mt76_alloc_rxwi(struct mt76_dev *dev) |
| 44 | +{ |
| 45 | + struct mt76_txwi_cache *r; |
| 46 | + int size; |
| 47 | + |
| 48 | + size = L1_CACHE_ALIGN(sizeof(*r)); |
| 49 | + r = kzalloc(size, GFP_ATOMIC); |
| 50 | + if (!r) |
| 51 | + return NULL; |
| 52 | + |
| 53 | + r->buf = NULL; |
| 54 | + |
| 55 | + return r; |
| 56 | +} |
| 57 | + |
| 58 | +static struct mt76_txwi_cache * |
| 59 | +__mt76_get_rxwi(struct mt76_dev *dev) |
| 60 | +{ |
| 61 | + struct mt76_txwi_cache *r = NULL; |
| 62 | + |
| 63 | + spin_lock(&dev->wed_lock); |
| 64 | + if (!list_empty(&dev->rxwi_cache)) { |
| 65 | + r = list_first_entry(&dev->rxwi_cache, struct mt76_txwi_cache, |
| 66 | + list); |
| 67 | + if(r) |
| 68 | + list_del(&r->list); |
| 69 | + } |
| 70 | + spin_unlock(&dev->wed_lock); |
| 71 | + |
| 72 | + return r; |
| 73 | +} |
| 74 | + |
| 75 | +struct mt76_txwi_cache * |
| 76 | +mt76_get_rxwi(struct mt76_dev *dev) |
| 77 | +{ |
| 78 | + struct mt76_txwi_cache *r = __mt76_get_rxwi(dev); |
| 79 | + |
| 80 | + if (r) |
| 81 | + return r; |
| 82 | + |
| 83 | + return mt76_alloc_rxwi(dev); |
| 84 | +} |
| 85 | +EXPORT_SYMBOL_GPL(mt76_get_rxwi); |
| 86 | + |
| 87 | +void |
| 88 | +mt76_put_rxwi(struct mt76_dev *dev, struct mt76_txwi_cache *r) |
| 89 | +{ |
| 90 | + if (!r) |
| 91 | + return; |
| 92 | + |
| 93 | + spin_lock(&dev->wed_lock); |
| 94 | + list_add(&r->list, &dev->rxwi_cache); |
| 95 | + spin_unlock(&dev->wed_lock); |
| 96 | +} |
| 97 | +EXPORT_SYMBOL_GPL(mt76_put_rxwi); |
| 98 | + |
| 99 | static void |
| 100 | mt76_free_pending_txwi(struct mt76_dev *dev) |
| 101 | { |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 102 | @@ -112,6 +169,21 @@ mt76_free_pending_txwi(struct mt76_dev *dev) |
| 103 | local_bh_enable(); |
| 104 | } |
| 105 | |
| 106 | +static void |
| 107 | +mt76_free_pending_rxwi(struct mt76_dev *dev) |
| 108 | +{ |
| 109 | + struct mt76_txwi_cache *r; |
| 110 | + |
| 111 | + local_bh_disable(); |
| 112 | + while ((r = __mt76_get_rxwi(dev)) != NULL) { |
| 113 | + if (r->buf) |
| 114 | + skb_free_frag(r->buf); |
| 115 | + |
| 116 | + kfree(r); |
| 117 | + } |
| 118 | + local_bh_enable(); |
| 119 | +} |
| 120 | + |
| 121 | static void |
| 122 | mt76_dma_sync_idx(struct mt76_dev *dev, struct mt76_queue *q) |
| 123 | { |
| 124 | @@ -141,12 +213,15 @@ mt76_dma_queue_reset(struct mt76_dev *dev, struct mt76_queue *q) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 125 | static int |
| 126 | mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q, |
| 127 | struct mt76_queue_buf *buf, int nbufs, u32 info, |
| 128 | - struct sk_buff *skb, void *txwi) |
| 129 | + struct sk_buff *skb, void *txwi, void *rxwi) |
| 130 | { |
| 131 | + struct mtk_wed_device *wed = &dev->mmio.wed; |
| 132 | + |
| 133 | struct mt76_queue_entry *entry; |
| 134 | struct mt76_desc *desc; |
| 135 | u32 ctrl; |
| 136 | int i, idx = -1; |
| 137 | + int type; |
| 138 | |
| 139 | if (txwi) { |
| 140 | q->entry[q->head].txwi = DMA_DUMMY_DATA; |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 141 | @@ -162,28 +237,42 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 142 | desc = &q->desc[idx]; |
| 143 | entry = &q->entry[idx]; |
| 144 | |
| 145 | - if (buf[0].skip_unmap) |
| 146 | - entry->skip_buf0 = true; |
| 147 | - entry->skip_buf1 = i == nbufs - 1; |
| 148 | - |
| 149 | - entry->dma_addr[0] = buf[0].addr; |
| 150 | - entry->dma_len[0] = buf[0].len; |
| 151 | - |
| 152 | - ctrl = FIELD_PREP(MT_DMA_CTL_SD_LEN0, buf[0].len); |
| 153 | - if (i < nbufs - 1) { |
| 154 | - entry->dma_addr[1] = buf[1].addr; |
| 155 | - entry->dma_len[1] = buf[1].len; |
| 156 | - buf1 = buf[1].addr; |
| 157 | - ctrl |= FIELD_PREP(MT_DMA_CTL_SD_LEN1, buf[1].len); |
| 158 | - if (buf[1].skip_unmap) |
| 159 | - entry->skip_buf1 = true; |
| 160 | + type = FIELD_GET(MT_QFLAG_WED_TYPE, q->flags); |
| 161 | + if (mtk_wed_device_active(wed) && type == MT76_WED_Q_RX) { |
| 162 | + struct mt76_txwi_cache *r = rxwi; |
| 163 | + int rx_token; |
| 164 | + |
| 165 | + if (!r) |
| 166 | + return -ENOMEM; |
| 167 | + |
| 168 | + rx_token = mt76_rx_token_consume(dev, (void *)skb, r, buf[0].addr); |
| 169 | + |
| 170 | + buf1 |= FIELD_PREP(MT_DMA_CTL_TOKEN, rx_token); |
| 171 | + ctrl = FIELD_PREP(MT_DMA_CTL_SD_LEN0, MTK_WED_RX_PKT_SIZE); |
| 172 | + ctrl |= MT_DMA_CTL_TO_HOST; |
| 173 | + } else { |
| 174 | + if (buf[0].skip_unmap) |
| 175 | + entry->skip_buf0 = true; |
| 176 | + entry->skip_buf1 = i == nbufs - 1; |
| 177 | + |
| 178 | + entry->dma_addr[0] = buf[0].addr; |
| 179 | + entry->dma_len[0] = buf[0].len; |
| 180 | + |
| 181 | + ctrl = FIELD_PREP(MT_DMA_CTL_SD_LEN0, buf[0].len); |
| 182 | + if (i < nbufs - 1) { |
| 183 | + entry->dma_addr[1] = buf[1].addr; |
| 184 | + entry->dma_len[1] = buf[1].len; |
| 185 | + buf1 = buf[1].addr; |
| 186 | + ctrl |= FIELD_PREP(MT_DMA_CTL_SD_LEN1, buf[1].len); |
| 187 | + if (buf[1].skip_unmap) |
| 188 | + entry->skip_buf1 = true; |
| 189 | + } |
| 190 | + if (i == nbufs - 1) |
| 191 | + ctrl |= MT_DMA_CTL_LAST_SEC0; |
| 192 | + else if (i == nbufs - 2) |
| 193 | + ctrl |= MT_DMA_CTL_LAST_SEC1; |
| 194 | } |
| 195 | |
| 196 | - if (i == nbufs - 1) |
| 197 | - ctrl |= MT_DMA_CTL_LAST_SEC0; |
| 198 | - else if (i == nbufs - 2) |
| 199 | - ctrl |= MT_DMA_CTL_LAST_SEC1; |
| 200 | - |
| 201 | WRITE_ONCE(desc->buf0, cpu_to_le32(buf0)); |
| 202 | WRITE_ONCE(desc->buf1, cpu_to_le32(buf1)); |
| 203 | WRITE_ONCE(desc->info, cpu_to_le32(info)); |
developer | a15518e | 2022-07-25 19:03:42 +0800 | [diff] [blame] | 204 | @@ -272,33 +361,65 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, struct mt76_queue *q, bool flush) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 205 | |
| 206 | static void * |
| 207 | mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
| 208 | - int *len, u32 *info, bool *more) |
| 209 | + int *len, u32 *info, bool *more, bool *drop) |
| 210 | { |
| 211 | struct mt76_queue_entry *e = &q->entry[idx]; |
| 212 | struct mt76_desc *desc = &q->desc[idx]; |
| 213 | dma_addr_t buf_addr; |
developer | a15518e | 2022-07-25 19:03:42 +0800 | [diff] [blame] | 214 | - void *buf = e->buf; |
| 215 | + void *buf = e->buf, *copy = NULL; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 216 | int buf_len = SKB_WITH_OVERHEAD(q->buf_size); |
| 217 | + struct mtk_wed_device *wed = &dev->mmio.wed; |
| 218 | + int type; |
| 219 | |
| 220 | - buf_addr = e->dma_addr[0]; |
| 221 | if (len) { |
| 222 | u32 ctl = le32_to_cpu(READ_ONCE(desc->ctrl)); |
| 223 | *len = FIELD_GET(MT_DMA_CTL_SD_LEN0, ctl); |
| 224 | *more = !(ctl & MT_DMA_CTL_LAST_SEC0); |
| 225 | } |
| 226 | |
| 227 | - if (info) |
| 228 | - *info = le32_to_cpu(desc->info); |
| 229 | + type = FIELD_GET(MT_QFLAG_WED_TYPE, q->flags); |
| 230 | + if (mtk_wed_device_active(wed) && type == MT76_WED_Q_RX) { |
| 231 | + u32 token; |
| 232 | + struct mt76_txwi_cache *r; |
| 233 | + |
| 234 | + token = FIELD_GET(MT_DMA_CTL_TOKEN, desc->buf1); |
| 235 | + |
| 236 | + r = mt76_rx_token_release(dev, token); |
| 237 | + if (!r) |
| 238 | + return NULL; |
| 239 | + |
| 240 | + buf = page_frag_alloc(&q->rx_page, q->buf_size, GFP_ATOMIC); |
| 241 | + if (!buf) |
| 242 | + return NULL; |
| 243 | + |
developer | a15518e | 2022-07-25 19:03:42 +0800 | [diff] [blame] | 244 | + copy = r->buf; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 245 | + buf_addr = r->dma_addr; |
| 246 | + buf_len = MTK_WED_RX_PKT_SIZE; |
| 247 | + r->dma_addr = 0; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 248 | + |
| 249 | + mt76_put_rxwi(dev, r); |
| 250 | + |
| 251 | + if (desc->ctrl & (MT_DMA_CTL_TO_HOST_A | MT_DMA_CTL_DROP)) |
| 252 | + *drop = true; |
| 253 | + } else { |
| 254 | + buf_addr = e->dma_addr[0]; |
| 255 | + e->buf = NULL; |
| 256 | + } |
| 257 | |
| 258 | dma_unmap_single(dev->dma_dev, buf_addr, buf_len, DMA_FROM_DEVICE); |
| 259 | - e->buf = NULL; |
| 260 | + |
developer | a15518e | 2022-07-25 19:03:42 +0800 | [diff] [blame] | 261 | + if (copy) |
| 262 | + memcpy(buf, copy, MTK_WED_RX_PKT_SIZE); |
| 263 | + |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 264 | + if (info) |
| 265 | + *info = le32_to_cpu(desc->info); |
| 266 | |
| 267 | return buf; |
| 268 | } |
| 269 | |
| 270 | static void * |
| 271 | mt76_dma_dequeue(struct mt76_dev *dev, struct mt76_queue *q, bool flush, |
| 272 | - int *len, u32 *info, bool *more) |
| 273 | + int *len, u32 *info, bool *more, bool *drop) |
| 274 | { |
| 275 | int idx = q->tail; |
| 276 | |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 277 | @@ -314,7 +435,7 @@ mt76_dma_dequeue(struct mt76_dev *dev, struct mt76_queue *q, bool flush, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 278 | q->tail = (q->tail + 1) % q->ndesc; |
| 279 | q->queued--; |
| 280 | |
| 281 | - return mt76_dma_get_buf(dev, q, idx, len, info, more); |
| 282 | + return mt76_dma_get_buf(dev, q, idx, len, info, more, drop); |
| 283 | } |
| 284 | |
| 285 | static int |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 286 | @@ -336,7 +457,7 @@ mt76_dma_tx_queue_skb_raw(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 287 | buf.len = skb->len; |
| 288 | |
| 289 | spin_lock_bh(&q->lock); |
| 290 | - mt76_dma_add_buf(dev, q, &buf, 1, tx_info, skb, NULL); |
| 291 | + mt76_dma_add_buf(dev, q, &buf, 1, tx_info, skb, NULL, NULL); |
| 292 | mt76_dma_kick_queue(dev, q); |
| 293 | spin_unlock_bh(&q->lock); |
| 294 | |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 295 | @@ -413,7 +534,7 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 296 | goto unmap; |
| 297 | |
| 298 | return mt76_dma_add_buf(dev, q, tx_info.buf, tx_info.nbuf, |
| 299 | - tx_info.info, tx_info.skb, t); |
| 300 | + tx_info.info, tx_info.skb, t, NULL); |
| 301 | |
| 302 | unmap: |
| 303 | for (n--; n > 0; n--) |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 304 | @@ -448,6 +569,8 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 305 | int frames = 0; |
| 306 | int len = SKB_WITH_OVERHEAD(q->buf_size); |
| 307 | int offset = q->buf_offset; |
| 308 | + struct mtk_wed_device *wed = &dev->mmio.wed; |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 309 | + struct page_frag_cache *rx_page; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 310 | |
| 311 | if (!q->ndesc) |
| 312 | return 0; |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 313 | @@ -456,10 +579,29 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 314 | |
| 315 | while (q->queued < q->ndesc - 1) { |
| 316 | struct mt76_queue_buf qbuf; |
| 317 | + int type = FIELD_GET(MT_QFLAG_WED_TYPE, q->flags); |
| 318 | + bool skip_alloc = false; |
| 319 | + struct mt76_txwi_cache *r = NULL; |
| 320 | + |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 321 | + rx_page = &q->rx_page; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 322 | + if (mtk_wed_device_active(wed) && type == MT76_WED_Q_RX) { |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 323 | + rx_page = &wed->rx_page; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 324 | + r = mt76_get_rxwi(dev); |
| 325 | + if (!r) |
| 326 | + return -ENOMEM; |
| 327 | + |
| 328 | + if (r->buf) { |
| 329 | + skip_alloc = true; |
| 330 | + len = MTK_WED_RX_PKT_SIZE; |
| 331 | + buf = r->buf; |
| 332 | + } |
| 333 | + } |
| 334 | |
| 335 | - buf = page_frag_alloc(&q->rx_page, q->buf_size, GFP_ATOMIC); |
| 336 | - if (!buf) |
| 337 | - break; |
| 338 | + if (!skip_alloc) { |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 339 | + buf = page_frag_alloc(rx_page, q->buf_size, GFP_ATOMIC); |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 340 | + if (!buf) |
| 341 | + break; |
| 342 | + } |
| 343 | |
| 344 | addr = dma_map_single(dev->dma_dev, buf, len, DMA_FROM_DEVICE); |
| 345 | if (unlikely(dma_mapping_error(dev->dma_dev, addr))) { |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 346 | @@ -470,7 +612,7 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 347 | qbuf.addr = addr + offset; |
| 348 | qbuf.len = len - offset; |
| 349 | qbuf.skip_unmap = false; |
| 350 | - mt76_dma_add_buf(dev, q, &qbuf, 1, 0, buf, NULL); |
| 351 | + mt76_dma_add_buf(dev, q, &qbuf, 1, 0, buf, NULL, r); |
| 352 | frames++; |
| 353 | } |
| 354 | |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 355 | @@ -516,6 +658,11 @@ mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 356 | if (!ret) |
| 357 | q->wed_regs = wed->txfree_ring.reg_base; |
| 358 | break; |
| 359 | + case MT76_WED_Q_RX: |
| 360 | + ret = mtk_wed_device_rx_ring_setup(wed, ring, q->regs); |
| 361 | + if (!ret) |
| 362 | + q->wed_regs = wed->rx_ring[ring].reg_base; |
| 363 | + break; |
| 364 | default: |
| 365 | ret = -EINVAL; |
| 366 | } |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 367 | @@ -531,7 +678,8 @@ mt76_dma_alloc_queue(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 368 | int idx, int n_desc, int bufsize, |
| 369 | u32 ring_base) |
| 370 | { |
| 371 | - int ret, size; |
| 372 | + int ret, size, type; |
| 373 | + struct mtk_wed_device *wed = &dev->mmio.wed; |
| 374 | |
| 375 | spin_lock_init(&q->lock); |
| 376 | spin_lock_init(&q->cleanup_lock); |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 377 | @@ -541,6 +689,11 @@ mt76_dma_alloc_queue(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 378 | q->buf_size = bufsize; |
| 379 | q->hw_idx = idx; |
| 380 | |
| 381 | + type = FIELD_GET(MT_QFLAG_WED_TYPE, q->flags); |
| 382 | + if (mtk_wed_device_active(wed) && type == MT76_WED_Q_RX) |
| 383 | + q->buf_size = SKB_DATA_ALIGN(NET_SKB_PAD + MTK_WED_RX_PKT_SIZE) + |
| 384 | + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); |
| 385 | + |
| 386 | size = q->ndesc * sizeof(struct mt76_desc); |
| 387 | q->desc = dmam_alloc_coherent(dev->dma_dev, size, &q->desc_dma, GFP_KERNEL); |
| 388 | if (!q->desc) |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 389 | @@ -573,7 +726,7 @@ mt76_dma_rx_cleanup(struct mt76_dev *dev, struct mt76_queue *q) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 390 | |
| 391 | spin_lock_bh(&q->lock); |
| 392 | do { |
| 393 | - buf = mt76_dma_dequeue(dev, q, true, NULL, NULL, &more); |
| 394 | + buf = mt76_dma_dequeue(dev, q, true, NULL, NULL, &more, NULL); |
| 395 | if (!buf) |
| 396 | break; |
| 397 | |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 398 | @@ -614,7 +767,7 @@ mt76_dma_rx_reset(struct mt76_dev *dev, enum mt76_rxq_id qid) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 399 | |
| 400 | static void |
| 401 | mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data, |
| 402 | - int len, bool more) |
| 403 | + int len, bool more, u32 info) |
| 404 | { |
| 405 | struct sk_buff *skb = q->rx_head; |
| 406 | struct skb_shared_info *shinfo = skb_shinfo(skb); |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 407 | @@ -634,7 +787,7 @@ mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 408 | |
| 409 | q->rx_head = NULL; |
| 410 | if (nr_frags < ARRAY_SIZE(shinfo->frags)) |
| 411 | - dev->drv->rx_skb(dev, q - dev->q_rx, skb); |
| 412 | + dev->drv->rx_skb(dev, q - dev->q_rx, skb, info); |
| 413 | else |
| 414 | dev_kfree_skb(skb); |
| 415 | } |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 416 | @@ -655,6 +808,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | while (done < budget) { |
| 420 | + bool drop = false; |
| 421 | u32 info; |
| 422 | |
| 423 | if (check_ddone) { |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 424 | @@ -665,10 +819,13 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 425 | break; |
| 426 | } |
| 427 | |
| 428 | - data = mt76_dma_dequeue(dev, q, false, &len, &info, &more); |
| 429 | + data = mt76_dma_dequeue(dev, q, false, &len, &info, &more, &drop); |
| 430 | if (!data) |
| 431 | break; |
| 432 | |
| 433 | + if (drop) |
| 434 | + goto free_frag; |
| 435 | + |
| 436 | if (q->rx_head) |
| 437 | data_len = q->buf_size; |
| 438 | else |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 439 | @@ -681,7 +838,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | if (q->rx_head) { |
| 443 | - mt76_add_fragment(dev, q, data, len, more); |
| 444 | + mt76_add_fragment(dev, q, data, len, more, info); |
| 445 | continue; |
| 446 | } |
| 447 | |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 448 | @@ -708,7 +865,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 449 | continue; |
| 450 | } |
| 451 | |
| 452 | - dev->drv->rx_skb(dev, q - dev->q_rx, skb); |
| 453 | + dev->drv->rx_skb(dev, q - dev->q_rx, skb, info); |
| 454 | continue; |
| 455 | |
| 456 | free_frag: |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 457 | @@ -785,7 +942,7 @@ EXPORT_SYMBOL_GPL(mt76_dma_attach); |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 458 | |
| 459 | void mt76_dma_cleanup(struct mt76_dev *dev) |
| 460 | { |
| 461 | - int i; |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 462 | + int i, type; |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 463 | |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 464 | mt76_worker_disable(&dev->tx_worker); |
| 465 | netif_napi_del(&dev->tx_napi); |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 466 | @@ -806,12 +963,17 @@ void mt76_dma_cleanup(struct mt76_dev *dev) |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 467 | |
| 468 | mt76_for_each_q_rx(dev, i) { |
| 469 | netif_napi_del(&dev->napi[i]); |
| 470 | - mt76_dma_rx_cleanup(dev, &dev->q_rx[i]); |
| 471 | + type = FIELD_GET(MT_QFLAG_WED_TYPE, dev->q_rx[i].flags); |
| 472 | + if (type != MT76_WED_Q_RX) |
| 473 | + mt76_dma_rx_cleanup(dev, &dev->q_rx[i]); |
| 474 | } |
| 475 | |
| 476 | mt76_free_pending_txwi(dev); |
| 477 | + mt76_free_pending_rxwi(dev); |
| 478 | |
| 479 | if (mtk_wed_device_active(&dev->mmio.wed)) |
| 480 | mtk_wed_device_detach(&dev->mmio.wed); |
| 481 | + |
| 482 | + mt76_free_pending_rxwi(dev); |
| 483 | } |
| 484 | EXPORT_SYMBOL_GPL(mt76_dma_cleanup); |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 485 | diff --git a/dma.h b/dma.h |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 486 | index fdf786f..90370d1 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 487 | --- a/dma.h |
| 488 | +++ b/dma.h |
| 489 | @@ -16,6 +16,16 @@ |
| 490 | #define MT_DMA_CTL_LAST_SEC0 BIT(30) |
| 491 | #define MT_DMA_CTL_DMA_DONE BIT(31) |
| 492 | |
| 493 | +#define MT_DMA_CTL_TO_HOST BIT(8) |
| 494 | +#define MT_DMA_CTL_TO_HOST_A BIT(12) |
| 495 | +#define MT_DMA_CTL_DROP BIT(14) |
| 496 | + |
| 497 | +#define MT_DMA_CTL_TOKEN GENMASK(31, 16) |
| 498 | + |
| 499 | +#define MT_DMA_PPE_CPU_REASON GENMASK(15, 11) |
| 500 | +#define MT_DMA_PPE_ENTRY GENMASK(30, 16) |
| 501 | +#define MT_DMA_INFO_PPE_VLD BIT(31) |
| 502 | + |
| 503 | #define MT_DMA_HDR_LEN 4 |
| 504 | #define MT_RX_INFO_LEN 4 |
| 505 | #define MT_FCE_INFO_LEN 4 |
| 506 | diff --git a/mac80211.c b/mac80211.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 507 | index 2f0605d..a2bd8ca 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 508 | --- a/mac80211.c |
| 509 | +++ b/mac80211.c |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 510 | @@ -598,11 +598,14 @@ mt76_alloc_device(struct device *pdev, unsigned int size, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 511 | BIT(NL80211_IFTYPE_ADHOC); |
| 512 | |
| 513 | spin_lock_init(&dev->token_lock); |
| 514 | + spin_lock_init(&dev->rx_token_lock); |
| 515 | idr_init(&dev->token); |
| 516 | + idr_init(&dev->rx_token); |
| 517 | |
| 518 | INIT_LIST_HEAD(&dev->wcid_list); |
| 519 | |
| 520 | INIT_LIST_HEAD(&dev->txwi_cache); |
| 521 | + INIT_LIST_HEAD(&dev->rxwi_cache); |
| 522 | dev->token_size = dev->drv->token_size; |
| 523 | |
| 524 | for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++) |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 525 | @@ -1300,7 +1303,10 @@ void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 526 | |
| 527 | while ((skb = __skb_dequeue(&dev->rx_skb[q])) != NULL) { |
| 528 | mt76_check_sta(dev, skb); |
| 529 | - mt76_rx_aggr_reorder(skb, &frames); |
| 530 | + if (mtk_wed_device_active(&dev->mmio.wed)) |
| 531 | + __skb_queue_tail(&frames, skb); |
| 532 | + else |
| 533 | + mt76_rx_aggr_reorder(skb, &frames); |
| 534 | } |
| 535 | |
| 536 | mt76_rx_complete(dev, &frames, napi); |
| 537 | diff --git a/mt76.h b/mt76.h |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 538 | index 4a41949..fb3ae86 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 539 | --- a/mt76.h |
| 540 | +++ b/mt76.h |
| 541 | @@ -20,6 +20,8 @@ |
| 542 | |
| 543 | #define MT_MCU_RING_SIZE 32 |
| 544 | #define MT_RX_BUF_SIZE 2048 |
| 545 | +#define MTK_WED_RX_PKT_SIZE 1700 |
| 546 | + |
| 547 | #define MT_SKB_HEAD_LEN 256 |
| 548 | |
| 549 | #define MT_MAX_NON_AQL_PKT 16 |
| 550 | @@ -35,6 +37,7 @@ |
| 551 | FIELD_PREP(MT_QFLAG_WED_TYPE, _type) | \ |
| 552 | FIELD_PREP(MT_QFLAG_WED_RING, _n)) |
| 553 | #define MT_WED_Q_TX(_n) __MT_WED_Q(MT76_WED_Q_TX, _n) |
| 554 | +#define MT_WED_Q_RX(_n) __MT_WED_Q(MT76_WED_Q_RX, _n) |
| 555 | #define MT_WED_Q_TXFREE __MT_WED_Q(MT76_WED_Q_TXFREE, 0) |
| 556 | |
| 557 | struct mt76_dev; |
| 558 | @@ -56,6 +59,7 @@ enum mt76_bus_type { |
| 559 | enum mt76_wed_type { |
| 560 | MT76_WED_Q_TX, |
| 561 | MT76_WED_Q_TXFREE, |
| 562 | + MT76_WED_Q_RX, |
| 563 | }; |
| 564 | |
| 565 | struct mt76_bus_ops { |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 566 | @@ -313,7 +317,10 @@ struct mt76_txwi_cache { |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 567 | struct list_head list; |
| 568 | dma_addr_t dma_addr; |
| 569 | |
| 570 | - struct sk_buff *skb; |
| 571 | + union { |
| 572 | + void *buf; |
| 573 | + struct sk_buff *skb; |
| 574 | + }; |
| 575 | }; |
| 576 | |
| 577 | struct mt76_rx_tid { |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 578 | @@ -411,7 +418,7 @@ struct mt76_driver_ops { |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 579 | bool (*rx_check)(struct mt76_dev *dev, void *data, int len); |
| 580 | |
| 581 | void (*rx_skb)(struct mt76_dev *dev, enum mt76_rxq_id q, |
| 582 | - struct sk_buff *skb); |
| 583 | + struct sk_buff *skb, u32 info); |
| 584 | |
| 585 | void (*rx_poll_complete)(struct mt76_dev *dev, enum mt76_rxq_id q); |
| 586 | |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 587 | @@ -756,6 +763,7 @@ struct mt76_dev { |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 588 | struct ieee80211_hw *hw; |
| 589 | |
| 590 | spinlock_t lock; |
| 591 | + spinlock_t wed_lock; |
| 592 | spinlock_t cc_lock; |
| 593 | |
| 594 | u32 cur_cc_bss_rx; |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 595 | @@ -781,6 +789,7 @@ struct mt76_dev { |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 596 | struct sk_buff_head rx_skb[__MT_RXQ_MAX]; |
| 597 | |
| 598 | struct list_head txwi_cache; |
| 599 | + struct list_head rxwi_cache; |
| 600 | struct mt76_queue *q_mcu[__MT_MCUQ_MAX]; |
| 601 | struct mt76_queue q_rx[__MT_RXQ_MAX]; |
| 602 | const struct mt76_queue_ops *queue_ops; |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 603 | @@ -794,12 +803,16 @@ struct mt76_dev { |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 604 | u16 wed_token_count; |
| 605 | u16 token_count; |
| 606 | u16 token_size; |
| 607 | + u16 rx_token_size; |
| 608 | + spinlock_t rx_token_lock; |
| 609 | + struct idr rx_token; |
| 610 | |
| 611 | wait_queue_head_t tx_wait; |
| 612 | /* spinclock used to protect wcid pktid linked list */ |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 613 | spinlock_t status_lock; |
| 614 | |
| 615 | u32 wcid_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)]; |
| 616 | + u32 wcid_wds_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)]; |
| 617 | u32 wcid_phy_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)]; |
| 618 | |
| 619 | u64 vif_mask; |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 620 | @@ -1357,6 +1370,8 @@ mt76_tx_status_get_hw(struct mt76_dev *dev, struct sk_buff *skb) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | void mt76_put_txwi(struct mt76_dev *dev, struct mt76_txwi_cache *t); |
| 624 | +void mt76_put_rxwi(struct mt76_dev *dev, struct mt76_txwi_cache *t); |
| 625 | +struct mt76_txwi_cache *mt76_get_rxwi(struct mt76_dev *dev); |
| 626 | void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames, |
| 627 | struct napi_struct *napi); |
| 628 | void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q, |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 629 | @@ -1501,6 +1516,12 @@ struct mt76_txwi_cache * |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 630 | mt76_token_release(struct mt76_dev *dev, int token, bool *wake); |
| 631 | int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi); |
| 632 | void __mt76_set_tx_blocked(struct mt76_dev *dev, bool blocked); |
| 633 | +int mt76_rx_token_consume(struct mt76_dev *dev, void *ptr, |
| 634 | + struct mt76_txwi_cache *r, dma_addr_t phys); |
| 635 | +void skb_trace(const struct sk_buff *skb, bool full_pkt); |
| 636 | + |
| 637 | +struct mt76_txwi_cache * |
| 638 | +mt76_rx_token_release(struct mt76_dev *dev, int token); |
| 639 | |
| 640 | static inline void mt76_set_tx_blocked(struct mt76_dev *dev, bool blocked) |
| 641 | { |
| 642 | diff --git a/mt7603/dma.c b/mt7603/dma.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 643 | index 590cff9..2ff71c5 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 644 | --- a/mt7603/dma.c |
| 645 | +++ b/mt7603/dma.c |
| 646 | @@ -69,7 +69,7 @@ free: |
| 647 | } |
| 648 | |
| 649 | void mt7603_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 650 | - struct sk_buff *skb) |
| 651 | + struct sk_buff *skb, u32 info) |
| 652 | { |
| 653 | struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76); |
| 654 | __le32 *rxd = (__le32 *)skb->data; |
| 655 | diff --git a/mt7603/mt7603.h b/mt7603/mt7603.h |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 656 | index 0fd46d9..f2ce22a 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 657 | --- a/mt7603/mt7603.h |
| 658 | +++ b/mt7603/mt7603.h |
| 659 | @@ -244,7 +244,7 @@ int mt7603_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, |
| 660 | void mt7603_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e); |
| 661 | |
| 662 | void mt7603_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 663 | - struct sk_buff *skb); |
| 664 | + struct sk_buff *skb, u32 info); |
| 665 | void mt7603_rx_poll_complete(struct mt76_dev *mdev, enum mt76_rxq_id q); |
| 666 | void mt7603_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps); |
| 667 | int mt7603_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
| 668 | diff --git a/mt7615/mac.c b/mt7615/mac.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 669 | index d6aae60..4774eaa 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 670 | --- a/mt7615/mac.c |
| 671 | +++ b/mt7615/mac.c |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 672 | @@ -1651,7 +1651,7 @@ bool mt7615_rx_check(struct mt76_dev *mdev, void *data, int len) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 673 | EXPORT_SYMBOL_GPL(mt7615_rx_check); |
| 674 | |
| 675 | void mt7615_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 676 | - struct sk_buff *skb) |
| 677 | + struct sk_buff *skb, u32 info) |
| 678 | { |
| 679 | struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76); |
| 680 | __le32 *rxd = (__le32 *)skb->data; |
| 681 | diff --git a/mt7615/mt7615.h b/mt7615/mt7615.h |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 682 | index 060d52c..232b0f2 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 683 | --- a/mt7615/mt7615.h |
| 684 | +++ b/mt7615/mt7615.h |
| 685 | @@ -511,7 +511,7 @@ void mt7615_tx_worker(struct mt76_worker *w); |
| 686 | void mt7615_tx_token_put(struct mt7615_dev *dev); |
| 687 | bool mt7615_rx_check(struct mt76_dev *mdev, void *data, int len); |
| 688 | void mt7615_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 689 | - struct sk_buff *skb); |
| 690 | + struct sk_buff *skb, u32 info); |
| 691 | void mt7615_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps); |
| 692 | int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
| 693 | struct ieee80211_sta *sta); |
| 694 | diff --git a/mt76_connac_mcu.c b/mt76_connac_mcu.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 695 | index e701db8..6ae1159 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 696 | --- a/mt76_connac_mcu.c |
| 697 | +++ b/mt76_connac_mcu.c |
| 698 | @@ -1190,6 +1190,7 @@ int mt76_connac_mcu_sta_ba(struct mt76_dev *dev, struct mt76_vif *mvif, |
| 699 | int cmd, bool enable, bool tx) |
| 700 | { |
| 701 | struct mt76_wcid *wcid = (struct mt76_wcid *)params->sta->drv_priv; |
| 702 | + struct mtk_wed_device *wed = &dev->mmio.wed; |
| 703 | struct wtbl_req_hdr *wtbl_hdr; |
| 704 | struct tlv *sta_wtbl; |
| 705 | struct sk_buff *skb; |
| 706 | @@ -1210,6 +1211,8 @@ int mt76_connac_mcu_sta_ba(struct mt76_dev *dev, struct mt76_vif *mvif, |
| 707 | mt76_connac_mcu_wtbl_ba_tlv(dev, skb, params, enable, tx, sta_wtbl, |
| 708 | wtbl_hdr); |
| 709 | |
| 710 | + if (mtk_wed_device_active(wed) && wed->ver > MTK_WED_V1) |
| 711 | + mtk_wed_device_update_msg(wed, WED_WO_STA_REC, skb->data, skb->len); |
| 712 | ret = mt76_mcu_skb_send_msg(dev, skb, cmd, true); |
| 713 | if (ret) |
| 714 | return ret; |
| 715 | @@ -1220,6 +1223,8 @@ int mt76_connac_mcu_sta_ba(struct mt76_dev *dev, struct mt76_vif *mvif, |
| 716 | |
| 717 | mt76_connac_mcu_sta_ba_tlv(skb, params, enable, tx); |
| 718 | |
| 719 | + if (mtk_wed_device_active(wed) && wed->ver > MTK_WED_V1) |
| 720 | + mtk_wed_device_update_msg(wed, WED_WO_STA_REC, skb->data, skb->len); |
| 721 | return mt76_mcu_skb_send_msg(dev, skb, cmd, true); |
| 722 | } |
| 723 | EXPORT_SYMBOL_GPL(mt76_connac_mcu_sta_ba); |
| 724 | @@ -2634,6 +2639,7 @@ int mt76_connac_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif, |
| 725 | struct mt76_wcid *wcid, enum set_key_cmd cmd) |
| 726 | { |
| 727 | struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; |
| 728 | + struct mtk_wed_device *wed = &dev->mmio.wed; |
| 729 | struct sk_buff *skb; |
| 730 | int ret; |
| 731 | |
| 732 | @@ -2645,6 +2651,9 @@ int mt76_connac_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif, |
| 733 | if (ret) |
| 734 | return ret; |
| 735 | |
| 736 | + if (mtk_wed_device_active(wed) && wed->ver > MTK_WED_V1) |
| 737 | + mtk_wed_device_update_msg(wed, WED_WO_STA_REC, skb->data, skb->len); |
| 738 | + |
| 739 | return mt76_mcu_skb_send_msg(dev, skb, mcu_cmd, true); |
| 740 | } |
| 741 | EXPORT_SYMBOL_GPL(mt76_connac_mcu_add_key); |
| 742 | diff --git a/mt76x02.h b/mt76x02.h |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 743 | index f76fd22..0b872af 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 744 | --- a/mt76x02.h |
| 745 | +++ b/mt76x02.h |
| 746 | @@ -173,7 +173,7 @@ int mt76x02_set_rts_threshold(struct ieee80211_hw *hw, u32 val); |
| 747 | void mt76x02_remove_hdr_pad(struct sk_buff *skb, int len); |
| 748 | bool mt76x02_tx_status_data(struct mt76_dev *mdev, u8 *update); |
| 749 | void mt76x02_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 750 | - struct sk_buff *skb); |
| 751 | + struct sk_buff *skb, u32 info); |
| 752 | void mt76x02_rx_poll_complete(struct mt76_dev *mdev, enum mt76_rxq_id q); |
| 753 | irqreturn_t mt76x02_irq_handler(int irq, void *dev_instance); |
| 754 | void mt76x02_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, |
| 755 | diff --git a/mt76x02_txrx.c b/mt76x02_txrx.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 756 | index 96fdf42..bf24d3e 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 757 | --- a/mt76x02_txrx.c |
| 758 | +++ b/mt76x02_txrx.c |
| 759 | @@ -33,7 +33,7 @@ void mt76x02_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, |
| 760 | EXPORT_SYMBOL_GPL(mt76x02_tx); |
| 761 | |
| 762 | void mt76x02_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 763 | - struct sk_buff *skb) |
| 764 | + struct sk_buff *skb, u32 info) |
| 765 | { |
| 766 | struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76); |
| 767 | void *rxwi = skb->data; |
| 768 | diff --git a/mt7915/dma.c b/mt7915/dma.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 769 | index ac30698..197a016 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 770 | --- a/mt7915/dma.c |
| 771 | +++ b/mt7915/dma.c |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 772 | @@ -349,6 +349,7 @@ static int mt7915_dma_enable(struct mt7915_dev *dev) |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 773 | int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2) |
| 774 | { |
| 775 | struct mt76_dev *mdev = &dev->mt76; |
| 776 | + struct mtk_wed_device *wed = &mdev->mmio.wed; |
| 777 | u32 wa_rx_base, wa_rx_idx; |
| 778 | u32 hif1_ofs = 0; |
| 779 | int ret; |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 780 | @@ -365,10 +366,12 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2) |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 781 | if (mtk_wed_device_active(&dev->mt76.mmio.wed) && !is_mt7986(mdev)) { |
| 782 | mt76_set(dev, MT_WFDMA_HOST_CONFIG, MT_WFDMA_HOST_CONFIG_WED); |
| 783 | if(is_mt7915(mdev)) { |
| 784 | - mt76_wr(dev, MT_WFDMA_WED_RING_CONTROL, |
| 785 | - FIELD_PREP(MT_WFDMA_WED_RING_CONTROL_TX0, 18) | |
| 786 | - FIELD_PREP(MT_WFDMA_WED_RING_CONTROL_TX1, 19) | |
| 787 | - FIELD_PREP(MT_WFDMA_WED_RING_CONTROL_RX1, 1)); |
| 788 | + mt76_wr(dev, MT_WFDMA_WED_RING_CONTROL, |
| 789 | + FIELD_PREP(MT_WFDMA_WED_RING_CONTROL_TX0, 18) | |
| 790 | + FIELD_PREP(MT_WFDMA_WED_RING_CONTROL_TX1, 19) | |
| 791 | + FIELD_PREP(MT_WFDMA_WED_RING_CONTROL_RX1, 1)); |
| 792 | + mt76_rmw(dev, MT_WFDMA0_EXT0_CFG, MT_WFDMA0_EXT0_RXWB_KEEP, |
| 793 | + MT_WFDMA0_EXT0_RXWB_KEEP); |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 794 | } else { |
| 795 | mt76_wr(dev, MT_WFDMA_WED_RING_CONTROL, |
| 796 | FIELD_PREP(MT_WFDMA_WED_RING_CONTROL_TX0, 18) | |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 797 | @@ -428,7 +431,7 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2) |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 798 | return ret; |
| 799 | |
| 800 | /* event from WA */ |
| 801 | - if (mtk_wed_device_active(&dev->mt76.mmio.wed) && is_mt7915(mdev)) { |
| 802 | + if (mtk_wed_device_active(wed) && is_mt7915(mdev)) { |
| 803 | wa_rx_base = MT_WED_RX_RING_BASE; |
| 804 | wa_rx_idx = MT7915_RXQ_MCU_WA; |
| 805 | dev->mt76.q_rx[MT_RXQ_MCU_WA].flags = MT_WED_Q_TXFREE; |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 806 | @@ -444,6 +447,11 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 807 | |
| 808 | /* rx data queue for band0 */ |
| 809 | if (!dev->phy.band_idx) { |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 810 | + if (mtk_wed_device_active(wed) && wed->ver > MTK_WED_V1) { |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 811 | + dev->mt76.q_rx[MT_RXQ_MAIN].flags = MT_WED_Q_RX(MT7915_RXQ_BAND0); |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 812 | + dev->mt76.rx_token_size += MT7915_RX_RING_SIZE; |
| 813 | + } |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 814 | + |
| 815 | ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MAIN], |
| 816 | MT_RXQ_ID(MT_RXQ_MAIN), |
| 817 | MT7915_RX_RING_SIZE, |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 818 | @@ -458,7 +466,7 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2) |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 819 | wa_rx_base = MT_RXQ_RING_BASE(MT_RXQ_MAIN_WA); |
| 820 | wa_rx_idx = MT_RXQ_ID(MT_RXQ_MAIN_WA); |
| 821 | |
| 822 | - if (mtk_wed_device_active(&dev->mt76.mmio.wed)) { |
| 823 | + if (mtk_wed_device_active(wed)) { |
| 824 | dev->mt76.q_rx[MT_RXQ_MAIN_WA].flags = MT_WED_Q_TXFREE; |
| 825 | if (is_mt7916(mdev)) { |
| 826 | wa_rx_base = MT_WED_RX_RING_BASE; |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 827 | @@ -474,6 +482,11 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2) |
| 828 | } |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 829 | |
| 830 | if (dev->dbdc_support || dev->phy.band_idx) { |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 831 | + if (mtk_wed_device_active(wed) && wed->ver > MTK_WED_V1) { |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 832 | + dev->mt76.q_rx[MT_RXQ_BAND1].flags = MT_WED_Q_RX(MT7915_RXQ_BAND1); |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 833 | + dev->mt76.rx_token_size += MT7915_RX_RING_SIZE; |
| 834 | + } |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 835 | + |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 836 | /* rx data queue for band1 */ |
| 837 | ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_BAND1], |
| 838 | MT_RXQ_ID(MT_RXQ_BAND1), |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 839 | diff --git a/mt7915/init.c b/mt7915/init.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 840 | index 538ff5c..cd9d846 100644 |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 841 | --- a/mt7915/init.c |
| 842 | +++ b/mt7915/init.c |
| 843 | @@ -695,6 +695,15 @@ mt7915_init_hardware(struct mt7915_dev *dev, struct mt7915_phy *phy2) |
| 844 | return ret; |
| 845 | } |
| 846 | |
| 847 | + /* wds workaround for mt7986 */ |
| 848 | + if (mtk_wed_device_active(&dev->mt76.mmio.wed) && is_mt7986(&dev->mt76)) { |
| 849 | + for(idx = MT7915_WTBL_WDS_START; idx < MT7915_WTBL_WDS_END; idx++) |
| 850 | + mt76_wcid_mask_set(dev->mt76.wcid_mask, idx); |
| 851 | + |
| 852 | + for (idx = 0; idx < DIV_ROUND_UP(MT7915_WTBL_STA, 32); idx++) |
| 853 | + dev->mt76.wcid_wds_mask[idx] = ~dev->mt76.wcid_mask[idx]; |
| 854 | + } |
| 855 | + |
| 856 | /* Beacon and mgmt frames should occupy wcid 0 */ |
| 857 | idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA); |
| 858 | if (idx) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 859 | diff --git a/mt7915/mac.c b/mt7915/mac.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 860 | index 0a13b7d..4e1dfc9 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 861 | --- a/mt7915/mac.c |
| 862 | +++ b/mt7915/mac.c |
| 863 | @@ -217,7 +217,7 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev) |
| 864 | } |
| 865 | |
| 866 | static int |
| 867 | -mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) |
| 868 | +mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb, enum mt76_rxq_id q, u32 info) |
| 869 | { |
| 870 | struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; |
| 871 | struct mt76_phy *mphy = &dev->mt76.phy; |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 872 | @@ -234,7 +234,7 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) |
| 873 | bool unicast, insert_ccmp_hdr = false; |
| 874 | u8 remove_pad, amsdu_info; |
| 875 | u8 mode = 0, qos_ctl = 0; |
| 876 | - struct mt7915_sta *msta; |
| 877 | + struct mt7915_sta *msta = NULL; |
| 878 | bool hdr_trans; |
| 879 | u16 hdr_gap; |
| 880 | u16 seq_ctrl = 0; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 881 | @@ -494,6 +494,27 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) |
| 882 | #endif |
| 883 | } else { |
| 884 | status->flag |= RX_FLAG_8023; |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 885 | + if (msta && msta->vif) { |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 886 | + struct mtk_wed_device *wed; |
| 887 | + int type; |
| 888 | + |
| 889 | + wed = &dev->mt76.mmio.wed; |
| 890 | + type = FIELD_GET(MT_QFLAG_WED_TYPE, dev->mt76.q_rx[q].flags); |
| 891 | + if ((mtk_wed_device_active(wed) && type == MT76_WED_Q_RX) && |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 892 | + (info & MT_DMA_INFO_PPE_VLD)) { |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 893 | + struct ieee80211_vif *vif; |
| 894 | + u32 hash, reason; |
| 895 | + |
| 896 | + vif = container_of((void *)msta->vif, struct ieee80211_vif, |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 897 | + drv_priv); |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 898 | + |
| 899 | + skb->dev = ieee80211_vif_to_netdev(vif); |
| 900 | + reason = FIELD_GET(MT_DMA_PPE_CPU_REASON, info); |
| 901 | + hash = FIELD_GET(MT_DMA_PPE_ENTRY, info); |
| 902 | + |
| 903 | + mtk_wed_device_ppe_check(wed, skb, reason, hash); |
| 904 | + } |
| 905 | + } |
| 906 | } |
| 907 | |
| 908 | if (rxv && mode >= MT_PHY_TYPE_HE_SU && !(status->flag & RX_FLAG_8023)) |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 909 | @@ -831,6 +852,80 @@ u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 910 | return MT_TXD_TXP_BUF_SIZE; |
| 911 | } |
| 912 | |
| 913 | +u32 |
| 914 | +mt7915_wed_init_rx_buf(struct mtk_wed_device *wed, int pkt_num) |
| 915 | +{ |
| 916 | + struct mtk_rxbm_desc *desc = wed->rx_buf_ring.desc; |
| 917 | + struct mt7915_dev *dev; |
| 918 | + dma_addr_t buf_phys; |
| 919 | + void *buf; |
| 920 | + int i, token, buf_size; |
| 921 | + |
| 922 | + buf_size = SKB_DATA_ALIGN(NET_SKB_PAD + wed->wlan.rx_pkt_size) + |
| 923 | + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); |
| 924 | + |
| 925 | + dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed); |
| 926 | + for (i = 0; i < pkt_num; i++) { |
| 927 | + struct mt76_txwi_cache *r = mt76_get_rxwi(&dev->mt76); |
| 928 | + |
| 929 | + buf = page_frag_alloc(&wed->rx_page, buf_size, GFP_ATOMIC); |
| 930 | + if (!buf) |
| 931 | + return -ENOMEM; |
| 932 | + |
| 933 | + buf_phys = dma_map_single(dev->mt76.dma_dev, buf, wed->wlan.rx_pkt_size, |
| 934 | + DMA_TO_DEVICE); |
| 935 | + |
| 936 | + if (unlikely(dma_mapping_error(dev->mt76.dev, buf_phys))) { |
| 937 | + skb_free_frag(buf); |
| 938 | + break; |
| 939 | + } |
| 940 | + |
| 941 | + desc->buf0 = buf_phys; |
| 942 | + |
| 943 | + token = mt76_rx_token_consume(&dev->mt76, buf, r, buf_phys); |
| 944 | + |
| 945 | + desc->token |= FIELD_PREP(MT_DMA_CTL_TOKEN, token); |
| 946 | + desc++; |
| 947 | + } |
| 948 | + |
| 949 | + return 0; |
| 950 | +} |
| 951 | + |
| 952 | +void mt7915_wed_release_rx_buf(struct mtk_wed_device *wed) |
| 953 | +{ |
| 954 | + struct mt76_txwi_cache *rxwi; |
| 955 | + struct mt7915_dev *dev; |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 956 | + struct page *page; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 957 | + int token; |
| 958 | + |
| 959 | + dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed); |
| 960 | + |
| 961 | + for(token = 0; token < dev->mt76.rx_token_size; token++) { |
| 962 | + rxwi = mt76_rx_token_release(&dev->mt76, token); |
| 963 | + if(!rxwi) |
| 964 | + continue; |
| 965 | + |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 966 | + if(!rxwi->buf) |
| 967 | + continue; |
| 968 | + |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 969 | + dma_unmap_single(dev->mt76.dma_dev, rxwi->dma_addr, |
| 970 | + wed->wlan.rx_pkt_size, DMA_FROM_DEVICE); |
| 971 | + skb_free_frag(rxwi->buf); |
| 972 | + rxwi->buf = NULL; |
| 973 | + |
| 974 | + mt76_put_rxwi(&dev->mt76, rxwi); |
| 975 | + } |
developer | 29f66b3 | 2022-07-12 15:23:20 +0800 | [diff] [blame] | 976 | + |
| 977 | + if (wed->rx_page.va) |
| 978 | + return; |
| 979 | + |
| 980 | + page = virt_to_page(wed->rx_page.va); |
| 981 | + __page_frag_cache_drain(page, wed->rx_page.pagecnt_bias); |
| 982 | + memset(&wed->rx_page, 0, sizeof(wed->rx_page)); |
| 983 | + |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 984 | + return; |
| 985 | +} |
| 986 | + |
| 987 | static void |
| 988 | mt7915_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi) |
| 989 | { |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 990 | @@ -1107,7 +1202,7 @@ bool mt7915_rx_check(struct mt76_dev *mdev, void *data, int len) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 991 | } |
| 992 | |
| 993 | void mt7915_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 994 | - struct sk_buff *skb) |
| 995 | + struct sk_buff *skb, u32 info) |
| 996 | { |
| 997 | struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); |
| 998 | __le32 *rxd = (__le32 *)skb->data; |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 999 | @@ -1141,7 +1236,7 @@ void mt7915_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1000 | dev_kfree_skb(skb); |
| 1001 | break; |
| 1002 | case PKT_TYPE_NORMAL: |
| 1003 | - if (!mt7915_mac_fill_rx(dev, skb)) { |
| 1004 | + if (!mt7915_mac_fill_rx(dev, skb, q, info)) { |
| 1005 | mt76_rx(&dev->mt76, q, skb); |
| 1006 | return; |
| 1007 | } |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 1008 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1009 | index b77b3be..29ee700 100644 |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 1010 | --- a/mt7915/main.c |
| 1011 | +++ b/mt7915/main.c |
| 1012 | @@ -670,8 +670,15 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
| 1013 | #endif |
| 1014 | int ret, idx; |
| 1015 | u32 addr; |
| 1016 | + bool wed_wds = false; |
| 1017 | |
| 1018 | - idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA); |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 1019 | + if (mtk_wed_device_active(&mdev->mmio.wed) && is_mt7986(mdev)) |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 1020 | + wed_wds = !!test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); |
| 1021 | + |
| 1022 | + if (wed_wds) |
| 1023 | + idx = mt76_wcid_alloc(mdev->wcid_wds_mask, MT7915_WTBL_STA); |
| 1024 | + else |
| 1025 | + idx = mt76_wcid_alloc(mdev->wcid_mask, MT7915_WTBL_STA); |
| 1026 | if (idx < 0) |
| 1027 | return -ENOSPC; |
| 1028 | |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 1029 | @@ -1107,6 +1114,14 @@ static void mt7915_sta_set_4addr(struct ieee80211_hw *hw, |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 1030 | else |
| 1031 | clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); |
| 1032 | |
| 1033 | + if (mtk_wed_device_active(&dev->mt76.mmio.wed) && |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 1034 | + is_mt7986(&dev->mt76) && |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 1035 | + (msta->wcid.idx < MT7915_WTBL_WDS_START || |
| 1036 | + msta->wcid.idx > MT7915_WTBL_WDS_END)) { |
| 1037 | + mt7915_sta_remove(hw, vif, sta); |
| 1038 | + mt7915_sta_add(hw, vif, sta); |
| 1039 | + } |
| 1040 | + |
| 1041 | mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta); |
| 1042 | } |
| 1043 | |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 1044 | @@ -1449,9 +1464,12 @@ mt7915_net_fill_forward_path(struct ieee80211_hw *hw, |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 1045 | /* fw will find the wcid by dest addr */ |
| 1046 | if(is_mt7915(&dev->mt76)) |
| 1047 | path->mtk_wdma.wcid = 0xff; |
| 1048 | - else |
| 1049 | - path->mtk_wdma.wcid = 0x3ff; |
| 1050 | - |
| 1051 | + else { |
| 1052 | + if (test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags)) |
| 1053 | + path->mtk_wdma.wcid = msta->wcid.idx; |
| 1054 | + else |
| 1055 | + path->mtk_wdma.wcid = 0x3ff; |
| 1056 | + } |
| 1057 | path->mtk_wdma.queue = phy != &dev->phy; |
| 1058 | |
| 1059 | ctx->dev = NULL; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1060 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1061 | index a041bb2..3d50b78 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1062 | --- a/mt7915/mcu.c |
| 1063 | +++ b/mt7915/mcu.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1064 | @@ -1722,6 +1722,7 @@ int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1065 | struct ieee80211_sta *sta, bool enable) |
| 1066 | { |
| 1067 | struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; |
| 1068 | + struct mtk_wed_device *wed = &dev->mt76.mmio.wed; |
| 1069 | struct mt7915_sta *msta; |
| 1070 | struct sk_buff *skb; |
| 1071 | int ret; |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1072 | @@ -1774,6 +1775,8 @@ int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1073 | return ret; |
| 1074 | } |
| 1075 | out: |
| 1076 | + if (mtk_wed_device_active(wed) && wed->ver > MTK_WED_V1) |
| 1077 | + mtk_wed_device_update_msg(wed, WED_WO_STA_REC, skb->data, skb->len); |
| 1078 | return mt76_mcu_skb_send_msg(&dev->mt76, skb, |
| 1079 | MCU_EXT_CMD(STA_REC_UPDATE), true); |
| 1080 | } |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1081 | @@ -2348,6 +2351,7 @@ mt7915_mcu_init_rx_airtime(struct mt7915_dev *dev) |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 1082 | int mt7915_run_firmware(struct mt7915_dev *dev) |
| 1083 | { |
| 1084 | int ret; |
| 1085 | + struct mtk_wed_device *wed = &dev->mt76.mmio.wed; |
| 1086 | |
| 1087 | /* force firmware operation mode into normal state, |
| 1088 | * which should be set before firmware download stage. |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1089 | @@ -2377,8 +2381,14 @@ int mt7915_run_firmware(struct mt7915_dev *dev) |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 1090 | if (ret) |
| 1091 | return ret; |
| 1092 | |
| 1093 | - if (mtk_wed_device_active(&dev->mt76.mmio.wed) && is_mt7915(&dev->mt76)) |
| 1094 | - mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY), 0, 0, 0); |
| 1095 | + if (mtk_wed_device_active(wed)) { |
| 1096 | + if (is_mt7915(&dev->mt76)) |
| 1097 | + mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY), |
| 1098 | + 0, 0, 0); |
| 1099 | + mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| 1100 | + MCU_WA_PARAM_WED_VERSION, |
| 1101 | + wed->rev_id, 0); |
| 1102 | + } |
| 1103 | |
| 1104 | ret = mt7915_mcu_set_mwds(dev, 1); |
| 1105 | if (ret) |
| 1106 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1107 | index 9d0fac4..1f56db6 100644 |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 1108 | --- a/mt7915/mcu.h |
| 1109 | +++ b/mt7915/mcu.h |
| 1110 | @@ -268,6 +268,7 @@ enum { |
| 1111 | MCU_WA_PARAM_RED_SHOW_STA = 0xf, |
| 1112 | MCU_WA_PARAM_RED_TARGET_DELAY = 0x10, |
| 1113 | #endif |
| 1114 | + MCU_WA_PARAM_WED_VERSION = 0x32, |
| 1115 | }; |
| 1116 | |
| 1117 | enum mcu_mmps_mode { |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1118 | diff --git a/mt7915/mmio.c b/mt7915/mmio.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1119 | index b0d8a61..111444d 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1120 | --- a/mt7915/mmio.c |
| 1121 | +++ b/mt7915/mmio.c |
| 1122 | @@ -28,6 +28,9 @@ static const u32 mt7915_reg[] = { |
| 1123 | [FW_EXCEPTION_ADDR] = 0x219848, |
| 1124 | [SWDEF_BASE_ADDR] = 0x41f200, |
| 1125 | [EXCEPTION_BASE_ADDR] = 0x219848, |
| 1126 | + [WED_TX_RING] = 0xd7300, |
| 1127 | + [WED_RX_RING] = 0xd7410, |
| 1128 | + [WED_RX_DATA_RING] = 0xd4500, |
| 1129 | }; |
| 1130 | |
| 1131 | static const u32 mt7916_reg[] = { |
| 1132 | @@ -45,6 +48,9 @@ static const u32 mt7916_reg[] = { |
| 1133 | [FW_EXCEPTION_ADDR] = 0x022050bc, |
| 1134 | [SWDEF_BASE_ADDR] = 0x411400, |
| 1135 | [EXCEPTION_BASE_ADDR] = 0x022050BC, |
| 1136 | + [WED_TX_RING] = 0xd7300, |
| 1137 | + [WED_RX_RING] = 0xd7410, |
| 1138 | + [WED_RX_DATA_RING] = 0xd4540, |
| 1139 | }; |
| 1140 | |
| 1141 | static const u32 mt7986_reg[] = { |
| 1142 | @@ -62,6 +68,9 @@ static const u32 mt7986_reg[] = { |
| 1143 | [FW_EXCEPTION_ADDR] = 0x02204ffc, |
| 1144 | [SWDEF_BASE_ADDR] = 0x411400, |
| 1145 | [EXCEPTION_BASE_ADDR] = 0x02204FFC, |
| 1146 | + [WED_TX_RING] = 0x24420, |
| 1147 | + [WED_RX_RING] = 0x24520, |
| 1148 | + [WED_RX_DATA_RING] = 0x24540, |
| 1149 | }; |
| 1150 | |
| 1151 | static const u32 mt7915_offs[] = { |
| 1152 | @@ -710,6 +719,7 @@ mt7915_pci_wed_init(struct mt7915_dev *dev, struct device *pdev, int *irq) |
| 1153 | wed->wlan.bus_type = MTK_BUS_TYPE_PCIE; |
| 1154 | wed->wlan.wpdma_int = base + MT_INT_WED_SOURCE_CSR; |
| 1155 | wed->wlan.wpdma_mask = base + MT_INT_WED_MASK_CSR; |
| 1156 | + wed->wlan.wpdma_phys = base + MT_WFDMA_EXT_CSR_BASE; |
| 1157 | } else { |
| 1158 | struct platform_device *plat_dev; |
| 1159 | struct resource *res; |
| 1160 | @@ -722,12 +732,19 @@ mt7915_pci_wed_init(struct mt7915_dev *dev, struct device *pdev, int *irq) |
| 1161 | wed->wlan.wpdma_int = base + MT_INT_SOURCE_CSR; |
| 1162 | wed->wlan.wpdma_mask = base + MT_INT_MASK_CSR; |
| 1163 | } |
| 1164 | + wed->wlan.rx_pkt = MT7915_WED_RX_TOKEN_SIZE; |
| 1165 | + wed->wlan.phy_base = base; |
| 1166 | wed->wlan.wpdma_tx = base + MT_TXQ_WED_RING_BASE; |
| 1167 | wed->wlan.wpdma_txfree = base + MT_RXQ_WED_RING_BASE; |
| 1168 | + wed->wlan.wpdma_rx_glo = base + MT_WPDMA_GLO_CFG; |
| 1169 | + wed->wlan.wpdma_rx = base + MT_RXQ_WED_DATA_RING_BASE; |
| 1170 | |
| 1171 | wed->wlan.tx_tbit[0] = MT_WED_TX_DONE_BAND0; |
| 1172 | wed->wlan.tx_tbit[1] = MT_WED_TX_DONE_BAND1; |
| 1173 | wed->wlan.txfree_tbit = MT_WED_TX_FREE_DONE; |
| 1174 | + wed->wlan.rx_tbit[0] = MT_WED_RX_DONE_BAND0; |
| 1175 | + wed->wlan.rx_tbit[1] = MT_WED_RX_DONE_BAND1; |
| 1176 | + |
| 1177 | wed->wlan.nbuf = 7168; |
| 1178 | wed->wlan.token_start = MT7915_TOKEN_SIZE - wed->wlan.nbuf; |
| 1179 | wed->wlan.init_buf = mt7915_wed_init_buf; |
| 1180 | @@ -735,12 +752,15 @@ mt7915_pci_wed_init(struct mt7915_dev *dev, struct device *pdev, int *irq) |
| 1181 | wed->wlan.offload_enable = mt7915_wed_offload_enable; |
| 1182 | wed->wlan.offload_disable = mt7915_wed_offload_disable; |
| 1183 | |
| 1184 | + wed->wlan.rx_nbuf = 65536; |
| 1185 | + wed->wlan.rx_pkt_size = MTK_WED_RX_PKT_SIZE; |
| 1186 | + wed->wlan.init_rx_buf = mt7915_wed_init_rx_buf; |
| 1187 | + wed->wlan.release_rx_buf = mt7915_wed_release_rx_buf; |
| 1188 | + |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 1189 | + dev->mt76.rx_token_size = wed->wlan.rx_pkt; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1190 | if (mtk_wed_device_attach(wed) != 0) |
| 1191 | return 0; |
| 1192 | |
| 1193 | - if (wed->ver == MTK_WED_V1) |
| 1194 | - wed->wlan.wpdma_phys = base + MT_WFDMA_EXT_CSR_BASE; |
| 1195 | - |
| 1196 | *irq = wed->irq; |
| 1197 | dev->mt76.dma_dev = wed->dev; |
| 1198 | mdev->token_size = wed->wlan.token_start; |
| 1199 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1200 | index e329f74..b10b90a 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1201 | --- a/mt7915/mt7915.h |
| 1202 | +++ b/mt7915/mt7915.h |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 1203 | @@ -18,6 +18,9 @@ |
| 1204 | #define MT7915_WTBL_STA (MT7915_WTBL_RESERVED - \ |
| 1205 | MT7915_MAX_INTERFACES) |
| 1206 | |
| 1207 | +#define MT7915_WTBL_WDS_START 256 |
| 1208 | +#define MT7915_WTBL_WDS_END 274 |
| 1209 | + |
| 1210 | #define MT7915_WATCHDOG_TIME (HZ / 10) |
| 1211 | #define MT7915_RESET_TIMEOUT (30 * HZ) |
| 1212 | |
| 1213 | @@ -78,6 +81,7 @@ |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1214 | #define MT7915_MAX_STA_TWT_AGRT 8 |
| 1215 | #define MT7915_MIN_TWT_DUR 64 |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 1216 | #define MT7915_MAX_QUEUE (MT_RXQ_BAND2 + __MT_MCUQ_MAX + 2) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1217 | +#define MT7915_WED_RX_TOKEN_SIZE 12288 |
| 1218 | |
| 1219 | struct mt7915_vif; |
| 1220 | struct mt7915_sta; |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1221 | @@ -544,7 +548,9 @@ void mt7915_wfsys_reset(struct mt7915_dev *dev); |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1222 | irqreturn_t mt7915_irq_handler(int irq, void *dev_instance); |
| 1223 | u64 __mt7915_get_tsf(struct ieee80211_hw *hw, struct mt7915_vif *mvif); |
| 1224 | u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id); |
| 1225 | - |
| 1226 | +u32 mt7915_wed_init_rx_buf(struct mtk_wed_device *wed, |
| 1227 | + int pkt_num); |
| 1228 | +void mt7915_wed_release_rx_buf(struct mtk_wed_device *wed); |
| 1229 | int mt7915_register_device(struct mt7915_dev *dev); |
| 1230 | void mt7915_unregister_device(struct mt7915_dev *dev); |
| 1231 | int mt7915_eeprom_init(struct mt7915_dev *dev); |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1232 | @@ -697,7 +703,7 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1233 | struct mt76_tx_info *tx_info); |
| 1234 | void mt7915_tx_token_put(struct mt7915_dev *dev); |
| 1235 | void mt7915_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 1236 | - struct sk_buff *skb); |
| 1237 | + struct sk_buff *skb, u32 info); |
| 1238 | bool mt7915_rx_check(struct mt76_dev *mdev, void *data, int len); |
| 1239 | void mt7915_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps); |
| 1240 | void mt7915_stats_work(struct work_struct *work); |
| 1241 | diff --git a/mt7915/regs.h b/mt7915/regs.h |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1242 | index 432ed30..36ef8a9 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1243 | --- a/mt7915/regs.h |
| 1244 | +++ b/mt7915/regs.h |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 1245 | @@ -27,6 +27,9 @@ enum reg_rev { |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1246 | FW_EXCEPTION_ADDR, |
| 1247 | SWDEF_BASE_ADDR, |
| 1248 | EXCEPTION_BASE_ADDR, |
| 1249 | + WED_TX_RING, |
| 1250 | + WED_RX_RING, |
| 1251 | + WED_RX_DATA_RING, |
| 1252 | __MT_REG_MAX, |
| 1253 | }; |
| 1254 | |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 1255 | @@ -564,9 +567,13 @@ enum offs_rev { |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1256 | #define MT_WFDMA0_GLO_CFG_OMIT_RX_INFO_PFET2 BIT(21) |
| 1257 | |
| 1258 | #define MT_WFDMA0_RST_DTX_PTR MT_WFDMA0(0x20c) |
| 1259 | +#define MT_WFDMA0_EXT0_CFG MT_WFDMA0(0x2b0) |
| 1260 | +#define MT_WFDMA0_EXT0_RXWB_KEEP BIT(10) |
| 1261 | + |
| 1262 | #define MT_WFDMA0_PRI_DLY_INT_CFG0 MT_WFDMA0(0x2f0) |
| 1263 | #define MT_WFDMA0_PRI_DLY_INT_CFG1 MT_WFDMA0(0x2f4) |
| 1264 | #define MT_WFDMA0_PRI_DLY_INT_CFG2 MT_WFDMA0(0x2f8) |
| 1265 | +#define MT_WPDMA_GLO_CFG MT_WFDMA0(0x208) |
| 1266 | |
| 1267 | #define MT_WFDMA0_MCU_HOST_INT_ENA MT_WFDMA0(0x1f4) |
| 1268 | #define MT_WFDMA0_MT_WA_WDT_INT BIT(31) |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 1269 | @@ -664,12 +671,15 @@ enum offs_rev { |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1270 | #define MT_TXQ_EXT_CTRL(q) (MT_Q_BASE(__TXQ(q)) + 0x600 + \ |
| 1271 | MT_TXQ_ID(q)* 0x4) |
| 1272 | |
| 1273 | -#define MT_TXQ_WED_RING_BASE (!is_mt7986(mdev)? 0xd7300 : 0x24420) |
| 1274 | -#define MT_RXQ_WED_RING_BASE (!is_mt7986(mdev)? 0xd7410 : 0x24520) |
| 1275 | +#define MT_TXQ_WED_RING_BASE __REG(WED_TX_RING) |
| 1276 | +#define MT_RXQ_WED_RING_BASE __REG(WED_RX_RING) |
| 1277 | +#define MT_RXQ_WED_DATA_RING_BASE __REG(WED_RX_DATA_RING) |
| 1278 | |
| 1279 | #define MT_WED_TX_DONE_BAND0 (is_mt7915(mdev)? 4 : 30) |
| 1280 | #define MT_WED_TX_DONE_BAND1 (is_mt7915(mdev)? 5 : 31) |
| 1281 | #define MT_WED_TX_FREE_DONE (is_mt7915(mdev)? 1 : 2) |
| 1282 | +#define MT_WED_RX_DONE_BAND0 (is_mt7915(mdev)? 16 : 22) |
| 1283 | +#define MT_WED_RX_DONE_BAND1 (is_mt7915(mdev)? 17 : 23) |
| 1284 | |
| 1285 | #define MT_INT_SOURCE_CSR __REG(INT_SOURCE_CSR) |
| 1286 | #define MT_INT_MASK_CSR __REG(INT_MASK_CSR) |
| 1287 | diff --git a/mt7921/mac.c b/mt7921/mac.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1288 | index 1374c15..275f367 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1289 | --- a/mt7921/mac.c |
| 1290 | +++ b/mt7921/mac.c |
| 1291 | @@ -555,7 +555,7 @@ out: |
| 1292 | EXPORT_SYMBOL_GPL(mt7921_mac_add_txs); |
| 1293 | |
| 1294 | void mt7921_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 1295 | - struct sk_buff *skb) |
| 1296 | + struct sk_buff *skb, u32 info) |
| 1297 | { |
| 1298 | struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); |
| 1299 | __le32 *rxd = (__le32 *)skb->data; |
| 1300 | diff --git a/mt7921/mt7921.h b/mt7921/mt7921.h |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1301 | index c161031..0a1f035 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1302 | --- a/mt7921/mt7921.h |
| 1303 | +++ b/mt7921/mt7921.h |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 1304 | @@ -381,7 +381,7 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1305 | void mt7921_tx_worker(struct mt76_worker *w); |
| 1306 | void mt7921_tx_token_put(struct mt7921_dev *dev); |
| 1307 | void mt7921_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 1308 | - struct sk_buff *skb); |
| 1309 | + struct sk_buff *skb, u32 info); |
| 1310 | void mt7921_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps); |
| 1311 | void mt7921_stats_work(struct work_struct *work); |
| 1312 | void mt7921_set_stream_he_caps(struct mt7921_phy *phy); |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 1313 | @@ -417,7 +417,7 @@ int mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1314 | |
| 1315 | bool mt7921e_rx_check(struct mt76_dev *mdev, void *data, int len); |
| 1316 | void mt7921e_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 1317 | - struct sk_buff *skb); |
| 1318 | + struct sk_buff *skb, u32 info); |
| 1319 | int mt7921e_driver_own(struct mt7921_dev *dev); |
| 1320 | int mt7921e_mac_reset(struct mt7921_dev *dev); |
| 1321 | int mt7921e_mcu_init(struct mt7921_dev *dev); |
| 1322 | diff --git a/mt7921/pci_mac.c b/mt7921/pci_mac.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1323 | index e180067..ca982eb 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1324 | --- a/mt7921/pci_mac.c |
| 1325 | +++ b/mt7921/pci_mac.c |
| 1326 | @@ -182,7 +182,7 @@ bool mt7921e_rx_check(struct mt76_dev *mdev, void *data, int len) |
| 1327 | } |
| 1328 | |
| 1329 | void mt7921e_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 1330 | - struct sk_buff *skb) |
| 1331 | + struct sk_buff *skb, u32 info) |
| 1332 | { |
| 1333 | struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); |
| 1334 | __le32 *rxd = (__le32 *)skb->data; |
| 1335 | @@ -196,7 +196,7 @@ void mt7921e_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 1336 | napi_consume_skb(skb, 1); |
| 1337 | break; |
| 1338 | default: |
| 1339 | - mt7921_queue_rx_skb(mdev, q, skb); |
| 1340 | + mt7921_queue_rx_skb(mdev, q, skb, info); |
| 1341 | break; |
| 1342 | } |
| 1343 | } |
| 1344 | diff --git a/tx.c b/tx.c |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame^] | 1345 | index 8b33186..b812d06 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1346 | --- a/tx.c |
| 1347 | +++ b/tx.c |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 1348 | @@ -778,3 +778,37 @@ mt76_token_release(struct mt76_dev *dev, int token, bool *wake) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1349 | return txwi; |
| 1350 | } |
| 1351 | EXPORT_SYMBOL_GPL(mt76_token_release); |
| 1352 | + |
| 1353 | +int mt76_rx_token_consume(struct mt76_dev *dev, void *ptr, |
| 1354 | + struct mt76_txwi_cache *r, dma_addr_t phys) |
| 1355 | +{ |
| 1356 | + int token; |
| 1357 | + |
| 1358 | + spin_lock_bh(&dev->rx_token_lock); |
| 1359 | + |
| 1360 | + token = idr_alloc(&dev->rx_token, r, 0, dev->rx_token_size, GFP_ATOMIC); |
| 1361 | + |
| 1362 | + spin_unlock_bh(&dev->rx_token_lock); |
| 1363 | + |
| 1364 | + r->buf = ptr; |
| 1365 | + r->dma_addr = phys; |
| 1366 | + |
| 1367 | + return token; |
| 1368 | +} |
| 1369 | +EXPORT_SYMBOL_GPL(mt76_rx_token_consume); |
| 1370 | + |
| 1371 | +struct mt76_txwi_cache * |
| 1372 | +mt76_rx_token_release(struct mt76_dev *dev, int token) |
| 1373 | +{ |
| 1374 | + |
| 1375 | + struct mt76_txwi_cache *rxwi; |
| 1376 | + |
| 1377 | + spin_lock_bh(&dev->rx_token_lock); |
| 1378 | + |
| 1379 | + rxwi = idr_remove(&dev->rx_token, token); |
| 1380 | + |
| 1381 | + spin_unlock_bh(&dev->rx_token_lock); |
| 1382 | + |
| 1383 | + return rxwi; |
| 1384 | +} |
| 1385 | +EXPORT_SYMBOL_GPL(mt76_rx_token_release); |
| 1386 | -- |
developer | c89c547 | 2022-08-02 13:00:04 +0800 | [diff] [blame] | 1387 | 2.18.0 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 1388 | |