developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 1 | From cc7a9202984360cdc476d3aa860bebd9fc248a16 Mon Sep 17 00:00:00 2001 |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 2 | From: Sujuan Chen <sujuan.chen@mediatek.com> |
| 3 | Date: Fri, 6 Jan 2023 18:18:50 +0800 |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 4 | Subject: [PATCH] wifi: mt76: mt7915: wed: add rxwi for further in chip rro |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 5 | |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 6 | Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com> |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 7 | --- |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 8 | dma.c | 93 +++++++++++++++++++++++++------------------------ |
| 9 | mac80211.c | 2 +- |
| 10 | mt76.h | 24 ++++++++----- |
| 11 | mt7915/dma.c | 2 -- |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 12 | mt7915/mmio.c | 29 +++++++-------- |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 13 | mt7915/mt7915.h | 1 + |
| 14 | tx.c | 16 ++++----- |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 15 | 7 files changed, 87 insertions(+), 80 deletions(-) |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 16 | |
| 17 | diff --git a/dma.c b/dma.c |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 18 | index 3047f8ba..b210e39c 100644 |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 19 | --- a/dma.c |
| 20 | +++ b/dma.c |
| 21 | @@ -59,17 +59,17 @@ mt76_alloc_txwi(struct mt76_dev *dev) |
| 22 | return t; |
| 23 | } |
| 24 | |
| 25 | -static struct mt76_txwi_cache * |
| 26 | +static struct mt76_rxwi_cache * |
| 27 | mt76_alloc_rxwi(struct mt76_dev *dev) |
| 28 | { |
| 29 | - struct mt76_txwi_cache *t; |
| 30 | + struct mt76_rxwi_cache *r; |
| 31 | |
| 32 | - t = kzalloc(L1_CACHE_ALIGN(sizeof(*t)), GFP_ATOMIC); |
| 33 | - if (!t) |
| 34 | + r = kzalloc(L1_CACHE_ALIGN(sizeof(*r)), GFP_ATOMIC); |
| 35 | + if (!r) |
| 36 | return NULL; |
| 37 | |
| 38 | - t->ptr = NULL; |
| 39 | - return t; |
| 40 | + r->ptr = NULL; |
| 41 | + return r; |
| 42 | } |
| 43 | |
| 44 | static struct mt76_txwi_cache * |
| 45 | @@ -88,20 +88,20 @@ __mt76_get_txwi(struct mt76_dev *dev) |
| 46 | return t; |
| 47 | } |
| 48 | |
| 49 | -static struct mt76_txwi_cache * |
| 50 | +static struct mt76_rxwi_cache * |
| 51 | __mt76_get_rxwi(struct mt76_dev *dev) |
| 52 | { |
| 53 | - struct mt76_txwi_cache *t = NULL; |
| 54 | + struct mt76_rxwi_cache *r = NULL; |
| 55 | |
| 56 | - spin_lock(&dev->wed_lock); |
| 57 | + spin_lock(&dev->lock); |
| 58 | if (!list_empty(&dev->rxwi_cache)) { |
| 59 | - t = list_first_entry(&dev->rxwi_cache, struct mt76_txwi_cache, |
| 60 | + r = list_first_entry(&dev->rxwi_cache, struct mt76_rxwi_cache, |
| 61 | list); |
| 62 | - list_del(&t->list); |
| 63 | + list_del(&r->list); |
| 64 | } |
| 65 | - spin_unlock(&dev->wed_lock); |
| 66 | + spin_unlock(&dev->lock); |
| 67 | |
| 68 | - return t; |
| 69 | + return r; |
| 70 | } |
| 71 | |
| 72 | static struct mt76_txwi_cache * |
| 73 | @@ -115,13 +115,13 @@ mt76_get_txwi(struct mt76_dev *dev) |
| 74 | return mt76_alloc_txwi(dev); |
| 75 | } |
| 76 | |
| 77 | -struct mt76_txwi_cache * |
| 78 | +struct mt76_rxwi_cache * |
| 79 | mt76_get_rxwi(struct mt76_dev *dev) |
| 80 | { |
| 81 | - struct mt76_txwi_cache *t = __mt76_get_rxwi(dev); |
| 82 | + struct mt76_rxwi_cache *r = __mt76_get_rxwi(dev); |
| 83 | |
| 84 | - if (t) |
| 85 | - return t; |
| 86 | + if (r) |
| 87 | + return r; |
| 88 | |
| 89 | return mt76_alloc_rxwi(dev); |
| 90 | } |
| 91 | @@ -140,14 +140,14 @@ mt76_put_txwi(struct mt76_dev *dev, struct mt76_txwi_cache *t) |
| 92 | EXPORT_SYMBOL_GPL(mt76_put_txwi); |
| 93 | |
| 94 | void |
| 95 | -mt76_put_rxwi(struct mt76_dev *dev, struct mt76_txwi_cache *t) |
| 96 | +mt76_put_rxwi(struct mt76_dev *dev, struct mt76_rxwi_cache *r) |
| 97 | { |
| 98 | - if (!t) |
| 99 | + if (!r) |
| 100 | return; |
| 101 | |
| 102 | - spin_lock(&dev->wed_lock); |
| 103 | - list_add(&t->list, &dev->rxwi_cache); |
| 104 | - spin_unlock(&dev->wed_lock); |
| 105 | + spin_lock(&dev->lock); |
| 106 | + list_add(&r->list, &dev->rxwi_cache); |
| 107 | + spin_unlock(&dev->lock); |
| 108 | } |
| 109 | EXPORT_SYMBOL_GPL(mt76_put_rxwi); |
| 110 | |
| 111 | @@ -168,13 +168,13 @@ mt76_free_pending_txwi(struct mt76_dev *dev) |
| 112 | void |
| 113 | mt76_free_pending_rxwi(struct mt76_dev *dev) |
| 114 | { |
| 115 | - struct mt76_txwi_cache *t; |
| 116 | + struct mt76_rxwi_cache *r; |
| 117 | |
| 118 | local_bh_disable(); |
| 119 | - while ((t = __mt76_get_rxwi(dev)) != NULL) { |
| 120 | - if (t->ptr) |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 121 | - skb_free_frag(t->ptr); |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 122 | - kfree(t); |
| 123 | + while ((r = __mt76_get_rxwi(dev)) != NULL) { |
| 124 | + if (r->ptr) |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 125 | + skb_free_frag(r->ptr); |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 126 | + kfree(r); |
| 127 | } |
| 128 | local_bh_enable(); |
| 129 | } |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 130 | @@ -212,7 +212,7 @@ mt76_dma_add_rx_buf(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 131 | { |
| 132 | struct mt76_desc *desc = &q->desc[q->head]; |
| 133 | struct mt76_queue_entry *entry = &q->entry[q->head]; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 134 | - struct mt76_txwi_cache *txwi = NULL; |
| 135 | + struct mt76_rxwi_cache *rxwi = NULL; |
| 136 | u32 buf1 = 0, ctrl; |
| 137 | int idx = q->head; |
| 138 | int rx_token; |
| 139 | @@ -220,13 +220,13 @@ mt76_dma_add_rx_buf(struct mt76_dev *dev, struct mt76_queue *q, |
| 140 | ctrl = FIELD_PREP(MT_DMA_CTL_SD_LEN0, buf[0].len); |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 141 | |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 142 | if (mt76_queue_is_wed_rx(q)) { |
| 143 | - txwi = mt76_get_rxwi(dev); |
| 144 | - if (!txwi) |
| 145 | + rxwi = mt76_get_rxwi(dev); |
| 146 | + if (!rxwi) |
| 147 | return -ENOMEM; |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 148 | |
| 149 | - rx_token = mt76_rx_token_consume(dev, data, txwi, buf->addr); |
| 150 | + rx_token = mt76_rx_token_consume(dev, data, rxwi, buf->addr); |
| 151 | if (rx_token < 0) { |
| 152 | - mt76_put_rxwi(dev, txwi); |
| 153 | + mt76_put_rxwi(dev, rxwi); |
| 154 | return -ENOMEM; |
| 155 | } |
| 156 | |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 157 | @@ -241,7 +241,7 @@ mt76_dma_add_rx_buf(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 158 | |
| 159 | entry->dma_addr[0] = buf->addr; |
| 160 | entry->dma_len[0] = buf->len; |
| 161 | - entry->txwi = txwi; |
| 162 | + entry->rxwi = rxwi; |
| 163 | entry->buf = data; |
| 164 | entry->wcid = 0xffff; |
| 165 | entry->skip_buf1 = true; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 166 | @@ -254,7 +254,7 @@ mt76_dma_add_rx_buf(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 167 | static int |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 168 | mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q, |
| 169 | struct mt76_queue_buf *buf, int nbufs, u32 info, |
| 170 | - struct sk_buff *skb, void *txwi) |
| 171 | + struct sk_buff *skb, void *txwi, void *rxwi) |
| 172 | { |
| 173 | struct mt76_queue_entry *entry; |
| 174 | struct mt76_desc *desc; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 175 | @@ -307,6 +307,7 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | q->entry[idx].txwi = txwi; |
| 179 | + q->entry[idx].rxwi = rxwi; |
| 180 | q->entry[idx].skb = skb; |
| 181 | q->entry[idx].wcid = 0xffff; |
| 182 | |
developer | bb6ddff | 2023-03-08 17:22:32 +0800 | [diff] [blame] | 183 | @@ -405,13 +406,13 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
| 184 | u32 buf1 = le32_to_cpu(desc->buf1); |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 185 | u32 id, find = 0; |
developer | bb6ddff | 2023-03-08 17:22:32 +0800 | [diff] [blame] | 186 | u32 token = FIELD_GET(MT_DMA_CTL_TOKEN, buf1); |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 187 | - struct mt76_txwi_cache *t; |
| 188 | + struct mt76_rxwi_cache *r; |
| 189 | |
| 190 | if (*more) { |
| 191 | spin_lock_bh(&dev->rx_token_lock); |
| 192 | |
| 193 | - idr_for_each_entry(&dev->rx_token, t, id) { |
| 194 | - if (t->dma_addr == le32_to_cpu(desc->buf0)) { |
| 195 | + idr_for_each_entry(&dev->rx_token, r, id) { |
| 196 | + if (r->dma_addr == le32_to_cpu(desc->buf0)) { |
| 197 | find = 1; |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 198 | token = id; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 199 | |
developer | bb6ddff | 2023-03-08 17:22:32 +0800 | [diff] [blame] | 200 | @@ -428,19 +429,19 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 201 | return NULL; |
| 202 | } |
| 203 | |
| 204 | - t = mt76_rx_token_release(dev, token); |
| 205 | - if (!t) |
| 206 | + r = mt76_rx_token_release(dev, token); |
| 207 | + if (!r) |
| 208 | return NULL; |
| 209 | |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 210 | - dma_unmap_single(dev->dma_dev, t->dma_addr, |
| 211 | + dma_unmap_single(dev->dma_dev, r->dma_addr, |
| 212 | SKB_WITH_OVERHEAD(q->buf_size), |
| 213 | DMA_FROM_DEVICE); |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 214 | |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 215 | - buf = t->ptr; |
| 216 | - t->dma_addr = 0; |
| 217 | - t->ptr = NULL; |
| 218 | + buf = r->ptr; |
| 219 | + r->dma_addr = 0; |
| 220 | + r->ptr = NULL; |
developer | 765f189 | 2023-01-30 14:02:51 +0800 | [diff] [blame] | 221 | |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 222 | - mt76_put_rxwi(dev, t); |
| 223 | + mt76_put_rxwi(dev, r); |
developer | 765f189 | 2023-01-30 14:02:51 +0800 | [diff] [blame] | 224 | |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 225 | if (drop) { |
| 226 | u32 ctrl = le32_to_cpu(READ_ONCE(desc->ctrl)); |
developer | 8effbd3 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 227 | @@ -504,7 +505,7 @@ mt76_dma_tx_queue_skb_raw(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 228 | buf.len = skb->len; |
| 229 | |
| 230 | spin_lock_bh(&q->lock); |
| 231 | - mt76_dma_add_buf(dev, q, &buf, 1, tx_info, skb, NULL); |
| 232 | + mt76_dma_add_buf(dev, q, &buf, 1, tx_info, skb, NULL, NULL); |
| 233 | mt76_dma_kick_queue(dev, q); |
| 234 | spin_unlock_bh(&q->lock); |
| 235 | |
developer | 8effbd3 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 236 | @@ -584,7 +585,7 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 237 | goto unmap; |
| 238 | |
| 239 | return mt76_dma_add_buf(dev, q, tx_info.buf, tx_info.nbuf, |
| 240 | - tx_info.info, tx_info.skb, t); |
| 241 | + tx_info.info, tx_info.skb, t, NULL); |
| 242 | |
| 243 | unmap: |
| 244 | for (n--; n > 0; n--) |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 245 | diff --git a/mac80211.c b/mac80211.c |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 246 | index 25ec4330..35cd297c 100644 |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 247 | --- a/mac80211.c |
| 248 | +++ b/mac80211.c |
developer | 7af0f76 | 2023-05-22 15:16:16 +0800 | [diff] [blame] | 249 | @@ -603,7 +603,6 @@ mt76_alloc_device(struct device *pdev, unsigned int size, |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 250 | spin_lock_init(&dev->lock); |
| 251 | spin_lock_init(&dev->cc_lock); |
| 252 | spin_lock_init(&dev->status_lock); |
| 253 | - spin_lock_init(&dev->wed_lock); |
| 254 | mutex_init(&dev->mutex); |
| 255 | init_waitqueue_head(&dev->tx_wait); |
| 256 | |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 257 | @@ -636,6 +635,7 @@ mt76_alloc_device(struct device *pdev, unsigned int size, |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 258 | INIT_LIST_HEAD(&dev->txwi_cache); |
| 259 | INIT_LIST_HEAD(&dev->rxwi_cache); |
| 260 | dev->token_size = dev->drv->token_size; |
| 261 | + dev->rx_token_size = dev->drv->rx_token_size; |
| 262 | |
| 263 | for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++) |
| 264 | skb_queue_head_init(&dev->rx_skb[i]); |
| 265 | diff --git a/mt76.h b/mt76.h |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 266 | index 70146064..828d3e8b 100644 |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 267 | --- a/mt76.h |
| 268 | +++ b/mt76.h |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 269 | @@ -173,6 +173,7 @@ struct mt76_queue_entry { |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 270 | }; |
| 271 | union { |
| 272 | struct mt76_txwi_cache *txwi; |
| 273 | + struct mt76_rxwi_cache *rxwi; |
| 274 | struct urb *urb; |
| 275 | int buf_sz; |
| 276 | }; |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 277 | @@ -373,10 +374,15 @@ struct mt76_txwi_cache { |
| 278 | |
| 279 | unsigned long jiffies; |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 280 | |
| 281 | - union { |
| 282 | - struct sk_buff *skb; |
| 283 | - void *ptr; |
| 284 | - }; |
| 285 | + struct sk_buff *skb; |
| 286 | +}; |
| 287 | + |
| 288 | +struct mt76_rxwi_cache { |
| 289 | + struct list_head list; |
| 290 | + dma_addr_t dma_addr; |
| 291 | + |
| 292 | + void *ptr; |
| 293 | + u32 token; |
| 294 | }; |
| 295 | |
| 296 | struct mt76_rx_tid { |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 297 | @@ -462,6 +468,7 @@ struct mt76_driver_ops { |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 298 | u16 txwi_size; |
| 299 | u16 token_size; |
| 300 | u8 mcs_rates; |
| 301 | + u16 rx_token_size; |
| 302 | |
| 303 | void (*update_survey)(struct mt76_phy *phy); |
| 304 | |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 305 | @@ -835,7 +842,6 @@ struct mt76_dev { |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 306 | |
| 307 | struct ieee80211_hw *hw; |
| 308 | |
| 309 | - spinlock_t wed_lock; |
| 310 | spinlock_t lock; |
| 311 | spinlock_t cc_lock; |
| 312 | |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 313 | @@ -1525,8 +1531,8 @@ mt76_tx_status_get_hw(struct mt76_dev *dev, struct sk_buff *skb) |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | void mt76_put_txwi(struct mt76_dev *dev, struct mt76_txwi_cache *t); |
| 317 | -void mt76_put_rxwi(struct mt76_dev *dev, struct mt76_txwi_cache *t); |
| 318 | -struct mt76_txwi_cache *mt76_get_rxwi(struct mt76_dev *dev); |
| 319 | +void mt76_put_rxwi(struct mt76_dev *dev, struct mt76_rxwi_cache *r); |
| 320 | +struct mt76_rxwi_cache *mt76_get_rxwi(struct mt76_dev *dev); |
| 321 | void mt76_free_pending_rxwi(struct mt76_dev *dev); |
| 322 | void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames, |
| 323 | struct napi_struct *napi); |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 324 | @@ -1681,9 +1687,9 @@ struct mt76_txwi_cache * |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 325 | mt76_token_release(struct mt76_dev *dev, int token, bool *wake); |
| 326 | int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi); |
| 327 | void __mt76_set_tx_blocked(struct mt76_dev *dev, bool blocked); |
| 328 | -struct mt76_txwi_cache *mt76_rx_token_release(struct mt76_dev *dev, int token); |
| 329 | +struct mt76_rxwi_cache *mt76_rx_token_release(struct mt76_dev *dev, int token); |
| 330 | int mt76_rx_token_consume(struct mt76_dev *dev, void *ptr, |
| 331 | - struct mt76_txwi_cache *r, dma_addr_t phys); |
| 332 | + struct mt76_rxwi_cache *r, dma_addr_t phys); |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 333 | |
| 334 | static inline void mt76_set_tx_blocked(struct mt76_dev *dev, bool blocked) |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 335 | { |
| 336 | diff --git a/mt7915/dma.c b/mt7915/dma.c |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 337 | index 59a44d79..326c8c8c 100644 |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 338 | --- a/mt7915/dma.c |
| 339 | +++ b/mt7915/dma.c |
developer | 8effbd3 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 340 | @@ -509,7 +509,6 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2) |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 341 | mtk_wed_get_rx_capa(&mdev->mmio.wed)) { |
| 342 | dev->mt76.q_rx[MT_RXQ_MAIN].flags = |
| 343 | MT_WED_Q_RX(MT7915_RXQ_BAND0); |
| 344 | - dev->mt76.rx_token_size += MT7915_RX_RING_SIZE; |
| 345 | } |
| 346 | |
| 347 | ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MAIN], |
developer | 8effbd3 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 348 | @@ -546,7 +545,6 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2) |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 349 | mtk_wed_get_rx_capa(&mdev->mmio.wed)) { |
| 350 | dev->mt76.q_rx[MT_RXQ_BAND1].flags = |
| 351 | MT_WED_Q_RX(MT7915_RXQ_BAND1); |
| 352 | - dev->mt76.rx_token_size += MT7915_RX_RING_SIZE; |
| 353 | } |
| 354 | |
| 355 | /* rx data queue for band1 */ |
| 356 | diff --git a/mt7915/mmio.c b/mt7915/mmio.c |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 357 | index cae8b810..d7393901 100644 |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 358 | --- a/mt7915/mmio.c |
| 359 | +++ b/mt7915/mmio.c |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 360 | @@ -622,18 +622,18 @@ static void mt7915_mmio_wed_release_rx_buf(struct mtk_wed_device *wed) |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 361 | sizeof(struct skb_shared_info)); |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 362 | |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 363 | for (i = 0; i < dev->mt76.rx_token_size; i++) { |
| 364 | - struct mt76_txwi_cache *t; |
| 365 | + struct mt76_rxwi_cache *r; |
| 366 | |
| 367 | - t = mt76_rx_token_release(&dev->mt76, i); |
| 368 | - if (!t || !t->ptr) |
| 369 | + r = mt76_rx_token_release(&dev->mt76, i); |
| 370 | + if (!r || !r->ptr) |
| 371 | continue; |
| 372 | |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 373 | - dma_unmap_single(dev->mt76.dma_dev, t->dma_addr, |
| 374 | + dma_unmap_single(dev->mt76.dma_dev, r->dma_addr, |
| 375 | wed->wlan.rx_size, DMA_FROM_DEVICE); |
| 376 | - __free_pages(virt_to_page(t->ptr), get_order(length)); |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 377 | - t->ptr = NULL; |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 378 | + __free_pages(virt_to_page(r->ptr), get_order(length)); |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 379 | + r->ptr = NULL; |
| 380 | |
| 381 | - mt76_put_rxwi(&dev->mt76, t); |
| 382 | + mt76_put_rxwi(&dev->mt76, r); |
| 383 | } |
| 384 | |
| 385 | mt76_free_pending_rxwi(&dev->mt76); |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 386 | @@ -651,18 +651,18 @@ static u32 mt7915_mmio_wed_init_rx_buf(struct mtk_wed_device *wed, int size) |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 387 | sizeof(struct skb_shared_info)); |
| 388 | |
| 389 | for (i = 0; i < size; i++) { |
| 390 | - struct mt76_txwi_cache *t = mt76_get_rxwi(&dev->mt76); |
| 391 | + struct mt76_rxwi_cache *r = mt76_get_rxwi(&dev->mt76); |
| 392 | dma_addr_t phy_addr; |
| 393 | struct page *page; |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 394 | int token; |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 395 | void *ptr; |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 396 | |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 397 | - if (!t) |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 398 | + if (!r) |
| 399 | goto unmap; |
| 400 | |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 401 | page = __dev_alloc_pages(GFP_KERNEL, get_order(length)); |
| 402 | if (!page) { |
| 403 | - mt76_put_rxwi(&dev->mt76, t); |
| 404 | + mt76_put_rxwi(&dev->mt76, r); |
| 405 | goto unmap; |
| 406 | } |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 407 | |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 408 | @@ -672,17 +672,17 @@ static u32 mt7915_mmio_wed_init_rx_buf(struct mtk_wed_device *wed, int size) |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 409 | DMA_TO_DEVICE); |
| 410 | if (unlikely(dma_mapping_error(dev->mt76.dev, phy_addr))) { |
| 411 | __free_pages(page, get_order(length)); |
| 412 | - mt76_put_rxwi(&dev->mt76, t); |
| 413 | + mt76_put_rxwi(&dev->mt76, r); |
| 414 | goto unmap; |
| 415 | } |
| 416 | |
| 417 | desc->buf0 = cpu_to_le32(phy_addr); |
| 418 | - token = mt76_rx_token_consume(&dev->mt76, ptr, t, phy_addr); |
| 419 | + token = mt76_rx_token_consume(&dev->mt76, ptr, r, phy_addr); |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 420 | if (token < 0) { |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 421 | dma_unmap_single(dev->mt76.dma_dev, phy_addr, |
| 422 | wed->wlan.rx_size, DMA_TO_DEVICE); |
| 423 | __free_pages(page, get_order(length)); |
| 424 | - mt76_put_rxwi(&dev->mt76, t); |
| 425 | + mt76_put_rxwi(&dev->mt76, r); |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 426 | goto unmap; |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 427 | } |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 428 | |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 429 | @@ -848,7 +848,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 430 | wed->wlan.reset = mt7915_mmio_wed_reset; |
| 431 | wed->wlan.reset_complete = mt7915_mmio_wed_reset_complete; |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 432 | |
| 433 | - dev->mt76.rx_token_size = wed->wlan.rx_npkt; |
| 434 | + dev->mt76.rx_token_size += wed->wlan.rx_npkt; |
| 435 | |
| 436 | if (mtk_wed_device_attach(wed)) |
| 437 | return 0; |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 438 | @@ -1056,6 +1056,7 @@ struct mt7915_dev *mt7915_mmio_probe(struct device *pdev, |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 439 | SURVEY_INFO_TIME_RX | |
| 440 | SURVEY_INFO_TIME_BSS_RX, |
| 441 | .token_size = MT7915_TOKEN_SIZE, |
| 442 | + .rx_token_size = MT7915_RX_TOKEN_SIZE, |
| 443 | .tx_prepare_skb = mt7915_tx_prepare_skb, |
| 444 | .tx_complete_skb = mt76_connac_tx_complete_skb, |
| 445 | .rx_skb = mt7915_queue_rx_skb, |
| 446 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 447 | index c60521b1..4d3ff13b 100644 |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 448 | --- a/mt7915/mt7915.h |
| 449 | +++ b/mt7915/mt7915.h |
developer | 7af0f76 | 2023-05-22 15:16:16 +0800 | [diff] [blame] | 450 | @@ -64,6 +64,7 @@ |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 451 | #define MT7915_EEPROM_BLOCK_SIZE 16 |
developer | 7a520b5 | 2023-03-14 14:09:34 +0800 | [diff] [blame] | 452 | #define MT7915_HW_TOKEN_SIZE 7168 |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 453 | #define MT7915_TOKEN_SIZE 8192 |
| 454 | +#define MT7915_RX_TOKEN_SIZE 4096 |
| 455 | |
| 456 | #define MT7915_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */ |
| 457 | #define MT7915_CFEND_RATE_11B 0x03 /* 11B LP, 11M */ |
| 458 | diff --git a/tx.c b/tx.c |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 459 | index 5d7bf340..2594a625 100644 |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 460 | --- a/tx.c |
| 461 | +++ b/tx.c |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 462 | @@ -774,16 +774,16 @@ int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi) |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 463 | EXPORT_SYMBOL_GPL(mt76_token_consume); |
| 464 | |
| 465 | int mt76_rx_token_consume(struct mt76_dev *dev, void *ptr, |
| 466 | - struct mt76_txwi_cache *t, dma_addr_t phys) |
| 467 | + struct mt76_rxwi_cache *r, dma_addr_t phys) |
| 468 | { |
| 469 | int token; |
| 470 | |
| 471 | spin_lock_bh(&dev->rx_token_lock); |
| 472 | - token = idr_alloc(&dev->rx_token, t, 0, dev->rx_token_size, |
| 473 | + token = idr_alloc(&dev->rx_token, r, 0, dev->rx_token_size, |
| 474 | GFP_ATOMIC); |
| 475 | if (token >= 0) { |
| 476 | - t->ptr = ptr; |
| 477 | - t->dma_addr = phys; |
| 478 | + r->ptr = ptr; |
| 479 | + r->dma_addr = phys; |
| 480 | } |
| 481 | spin_unlock_bh(&dev->rx_token_lock); |
| 482 | |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 483 | @@ -820,15 +820,15 @@ mt76_token_release(struct mt76_dev *dev, int token, bool *wake) |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 484 | } |
| 485 | EXPORT_SYMBOL_GPL(mt76_token_release); |
| 486 | |
| 487 | -struct mt76_txwi_cache * |
| 488 | +struct mt76_rxwi_cache * |
| 489 | mt76_rx_token_release(struct mt76_dev *dev, int token) |
| 490 | { |
| 491 | - struct mt76_txwi_cache *t; |
| 492 | + struct mt76_rxwi_cache *r; |
| 493 | |
| 494 | spin_lock_bh(&dev->rx_token_lock); |
| 495 | - t = idr_remove(&dev->rx_token, token); |
| 496 | + r = idr_remove(&dev->rx_token, token); |
| 497 | spin_unlock_bh(&dev->rx_token_lock); |
| 498 | |
| 499 | - return t; |
| 500 | + return r; |
| 501 | } |
| 502 | EXPORT_SYMBOL_GPL(mt76_rx_token_release); |
| 503 | -- |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 504 | 2.18.0 |
developer | 57c8f1a | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 505 | |