developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 1 | From dc6f151a8420ce5569b1db103525543600b2f9b5 Mon Sep 17 00:00:00 2001 |
| 2 | From: Sujuan Chen <sujuan.chen@mediatek.com> |
| 3 | Date: Fri, 6 Jan 2023 18:18:50 +0800 |
| 4 | Subject: [PATCH 3011/3014] mt76: mt7915: wed: add rxwi for further in chip rro |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 5 | |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 6 | Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com> |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 7 | --- |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 8 | dma.c | 107 ++++++++++++++++++++++++------------------------ |
| 9 | mac80211.c | 2 +- |
| 10 | mt76.h | 24 +++++++---- |
| 11 | mt7915/dma.c | 2 - |
| 12 | mt7915/mmio.c | 21 +++++----- |
| 13 | mt7915/mt7915.h | 1 + |
| 14 | tx.c | 16 ++++---- |
| 15 | 7 files changed, 90 insertions(+), 83 deletions(-) |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 16 | |
| 17 | diff --git a/dma.c b/dma.c |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 18 | index 98d2a29a..21f26df7 100644 |
developer | 780b915 | 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) |
| 121 | - skb_free_frag(t->ptr); |
| 122 | - kfree(t); |
| 123 | + while ((r = __mt76_get_rxwi(dev)) != NULL) { |
| 124 | + if (r->ptr) |
| 125 | + skb_free_frag(r->ptr); |
| 126 | + kfree(r); |
| 127 | } |
| 128 | local_bh_enable(); |
| 129 | } |
| 130 | @@ -209,7 +209,7 @@ mt76_dma_queue_reset(struct mt76_dev *dev, struct mt76_queue *q) |
| 131 | static int |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 132 | mt76_dma_add_rx_buf(struct mt76_dev *dev, struct mt76_queue *q, |
| 133 | struct mt76_queue_buf *buf, void *data, |
| 134 | - struct mt76_txwi_cache *txwi) |
| 135 | + struct mt76_rxwi_cache *rxwi) |
| 136 | { |
| 137 | struct mt76_desc *desc = &q->desc[q->head]; |
| 138 | struct mt76_queue_entry *entry = &q->entry[q->head]; |
| 139 | @@ -221,15 +221,15 @@ mt76_dma_add_rx_buf(struct mt76_dev *dev, struct mt76_queue *q, |
| 140 | |
| 141 | if ((q->flags & MT_QFLAG_WED) && |
| 142 | FIELD_GET(MT_QFLAG_WED_TYPE, q->flags) == MT76_WED_Q_RX) { |
| 143 | - if(!txwi) { |
| 144 | - txwi = mt76_get_rxwi(dev); |
| 145 | - if (!txwi) |
| 146 | + if(!rxwi) { |
| 147 | + rxwi = mt76_get_rxwi(dev); |
| 148 | + if (!rxwi) |
| 149 | return -ENOMEM; |
| 150 | } |
| 151 | |
| 152 | - rx_token = mt76_rx_token_consume(dev, data, txwi, buf->addr); |
| 153 | + rx_token = mt76_rx_token_consume(dev, data, rxwi, buf->addr); |
| 154 | if (rx_token < 0) { |
| 155 | - mt76_put_rxwi(dev, txwi); |
| 156 | + mt76_put_rxwi(dev, rxwi); |
| 157 | return -ENOMEM; |
| 158 | } |
| 159 | |
| 160 | @@ -244,7 +244,7 @@ mt76_dma_add_rx_buf(struct mt76_dev *dev, struct mt76_queue *q, |
| 161 | |
| 162 | entry->dma_addr[0] = buf->addr; |
| 163 | entry->dma_len[0] = buf->len; |
| 164 | - entry->txwi = txwi; |
| 165 | + entry->rxwi = rxwi; |
| 166 | entry->buf = data; |
| 167 | entry->wcid = 0xffff; |
| 168 | entry->skip_buf1 = true; |
| 169 | @@ -257,7 +257,7 @@ mt76_dma_add_rx_buf(struct mt76_dev *dev, struct mt76_queue *q, |
| 170 | static int |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 171 | mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q, |
| 172 | struct mt76_queue_buf *buf, int nbufs, u32 info, |
| 173 | - struct sk_buff *skb, void *txwi) |
| 174 | + struct sk_buff *skb, void *txwi, void *rxwi) |
| 175 | { |
| 176 | struct mt76_queue_entry *entry; |
| 177 | struct mt76_desc *desc; |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 178 | @@ -310,6 +310,7 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | q->entry[idx].txwi = txwi; |
| 182 | + q->entry[idx].rxwi = rxwi; |
| 183 | q->entry[idx].skb = skb; |
| 184 | q->entry[idx].wcid = 0xffff; |
| 185 | |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 186 | @@ -409,14 +410,14 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 187 | u32 id, find = 0; |
| 188 | u32 token = FIELD_GET(MT_DMA_CTL_TOKEN, |
| 189 | le32_to_cpu(desc->buf1)); |
| 190 | - struct mt76_txwi_cache *t; |
| 191 | + struct mt76_rxwi_cache *r; |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 192 | struct mt76_queue_buf qbuf; |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 193 | |
| 194 | if (*more) { |
| 195 | spin_lock_bh(&dev->rx_token_lock); |
| 196 | |
| 197 | - idr_for_each_entry(&dev->rx_token, t, id) { |
| 198 | - if (t->dma_addr == le32_to_cpu(desc->buf0)) { |
| 199 | + idr_for_each_entry(&dev->rx_token, r, id) { |
| 200 | + if (r->dma_addr == le32_to_cpu(desc->buf0)) { |
| 201 | find = 1; |
| 202 | desc->buf1 = FIELD_PREP(MT_DMA_CTL_TOKEN, id); |
| 203 | token = id; |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 204 | @@ -429,11 +430,11 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 205 | return NULL; |
| 206 | } |
| 207 | |
| 208 | - t = mt76_rx_token_release(dev, token); |
| 209 | - if (!t) |
| 210 | + r = mt76_rx_token_release(dev, token); |
| 211 | + if (!r) |
| 212 | return NULL; |
| 213 | |
| 214 | - dma_unmap_single(dev->dma_dev, t->dma_addr, |
| 215 | + dma_unmap_single(dev->dma_dev, r->dma_addr, |
| 216 | SKB_WITH_OVERHEAD(q->buf_size), |
| 217 | DMA_FROM_DEVICE); |
| 218 | |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 219 | @@ -441,27 +442,27 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 220 | if (!buf) |
| 221 | return NULL; |
| 222 | |
| 223 | - memcpy(buf, t->ptr, SKB_WITH_OVERHEAD(q->buf_size)); |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 224 | + memcpy(buf, r->ptr, SKB_WITH_OVERHEAD(q->buf_size)); |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 225 | |
| 226 | - t->dma_addr = dma_map_single(dev->dma_dev, t->ptr, |
| 227 | + r->dma_addr = dma_map_single(dev->dma_dev, r->ptr, |
| 228 | SKB_WITH_OVERHEAD(q->buf_size), |
| 229 | DMA_FROM_DEVICE); |
| 230 | - if (unlikely(dma_mapping_error(dev->dma_dev, t->dma_addr))) { |
| 231 | - skb_free_frag(t->ptr); |
| 232 | - mt76_put_rxwi(dev, t); |
| 233 | + if (unlikely(dma_mapping_error(dev->dma_dev, r->dma_addr))) { |
| 234 | + skb_free_frag(r->ptr); |
| 235 | + mt76_put_rxwi(dev, r); |
| 236 | return NULL; |
| 237 | } |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 238 | |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 239 | - qbuf.addr = t->dma_addr; |
| 240 | + qbuf.addr = r->dma_addr; |
| 241 | qbuf.len = SKB_WITH_OVERHEAD(q->buf_size); |
| 242 | qbuf.skip_unmap = false; |
| 243 | |
| 244 | - if (mt76_dma_add_rx_buf(dev, q, &qbuf, t->ptr, t) < 0) { |
| 245 | - dma_unmap_single(dev->dma_dev, t->dma_addr, |
| 246 | + if (mt76_dma_add_rx_buf(dev, q, &qbuf, r->ptr, r) < 0) { |
| 247 | + dma_unmap_single(dev->dma_dev, r->dma_addr, |
| 248 | SKB_WITH_OVERHEAD(q->buf_size), |
| 249 | DMA_FROM_DEVICE); |
| 250 | - skb_free_frag(t->ptr); |
| 251 | - mt76_put_rxwi(dev, t); |
| 252 | + skb_free_frag(r->ptr); |
| 253 | + mt76_put_rxwi(dev, r); |
| 254 | return NULL; |
| 255 | } |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 256 | |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 257 | @@ -531,7 +532,7 @@ mt76_dma_tx_queue_skb_raw(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 258 | buf.len = skb->len; |
| 259 | |
| 260 | spin_lock_bh(&q->lock); |
| 261 | - mt76_dma_add_buf(dev, q, &buf, 1, tx_info, skb, NULL); |
| 262 | + mt76_dma_add_buf(dev, q, &buf, 1, tx_info, skb, NULL, NULL); |
| 263 | mt76_dma_kick_queue(dev, q); |
| 264 | spin_unlock_bh(&q->lock); |
| 265 | |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 266 | @@ -608,7 +609,7 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 267 | goto unmap; |
| 268 | |
| 269 | return mt76_dma_add_buf(dev, q, tx_info.buf, tx_info.nbuf, |
| 270 | - tx_info.info, tx_info.skb, t); |
| 271 | + tx_info.info, tx_info.skb, t, NULL); |
| 272 | |
| 273 | unmap: |
| 274 | for (n--; n > 0; n--) |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 275 | diff --git a/mac80211.c b/mac80211.c |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 276 | index de9ef237..818f4f0c 100644 |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 277 | --- a/mac80211.c |
| 278 | +++ b/mac80211.c |
| 279 | @@ -597,7 +597,6 @@ mt76_alloc_device(struct device *pdev, unsigned int size, |
| 280 | spin_lock_init(&dev->lock); |
| 281 | spin_lock_init(&dev->cc_lock); |
| 282 | spin_lock_init(&dev->status_lock); |
| 283 | - spin_lock_init(&dev->wed_lock); |
| 284 | mutex_init(&dev->mutex); |
| 285 | init_waitqueue_head(&dev->tx_wait); |
| 286 | |
| 287 | @@ -628,6 +627,7 @@ mt76_alloc_device(struct device *pdev, unsigned int size, |
| 288 | INIT_LIST_HEAD(&dev->txwi_cache); |
| 289 | INIT_LIST_HEAD(&dev->rxwi_cache); |
| 290 | dev->token_size = dev->drv->token_size; |
| 291 | + dev->rx_token_size = dev->drv->rx_token_size; |
| 292 | |
| 293 | for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++) |
| 294 | skb_queue_head_init(&dev->rx_skb[i]); |
| 295 | diff --git a/mt76.h b/mt76.h |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 296 | index b10a16f8..631c4ccd 100644 |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 297 | --- a/mt76.h |
| 298 | +++ b/mt76.h |
| 299 | @@ -166,6 +166,7 @@ struct mt76_queue_entry { |
| 300 | }; |
| 301 | union { |
| 302 | struct mt76_txwi_cache *txwi; |
| 303 | + struct mt76_rxwi_cache *rxwi; |
| 304 | struct urb *urb; |
| 305 | int buf_sz; |
| 306 | }; |
| 307 | @@ -354,10 +355,15 @@ struct mt76_txwi_cache { |
| 308 | struct list_head list; |
| 309 | dma_addr_t dma_addr; |
| 310 | |
| 311 | - union { |
| 312 | - struct sk_buff *skb; |
| 313 | - void *ptr; |
| 314 | - }; |
| 315 | + struct sk_buff *skb; |
| 316 | +}; |
| 317 | + |
| 318 | +struct mt76_rxwi_cache { |
| 319 | + struct list_head list; |
| 320 | + dma_addr_t dma_addr; |
| 321 | + |
| 322 | + void *ptr; |
| 323 | + u32 token; |
| 324 | }; |
| 325 | |
| 326 | struct mt76_rx_tid { |
| 327 | @@ -441,6 +447,7 @@ struct mt76_driver_ops { |
| 328 | u16 txwi_size; |
| 329 | u16 token_size; |
| 330 | u8 mcs_rates; |
| 331 | + u16 rx_token_size; |
| 332 | |
| 333 | void (*update_survey)(struct mt76_phy *phy); |
| 334 | |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 335 | @@ -809,7 +816,6 @@ struct mt76_dev { |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 336 | |
| 337 | struct ieee80211_hw *hw; |
| 338 | |
| 339 | - spinlock_t wed_lock; |
| 340 | spinlock_t lock; |
| 341 | spinlock_t cc_lock; |
| 342 | |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 343 | @@ -1400,8 +1406,8 @@ mt76_tx_status_get_hw(struct mt76_dev *dev, struct sk_buff *skb) |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | void mt76_put_txwi(struct mt76_dev *dev, struct mt76_txwi_cache *t); |
| 347 | -void mt76_put_rxwi(struct mt76_dev *dev, struct mt76_txwi_cache *t); |
| 348 | -struct mt76_txwi_cache *mt76_get_rxwi(struct mt76_dev *dev); |
| 349 | +void mt76_put_rxwi(struct mt76_dev *dev, struct mt76_rxwi_cache *r); |
| 350 | +struct mt76_rxwi_cache *mt76_get_rxwi(struct mt76_dev *dev); |
| 351 | void mt76_free_pending_rxwi(struct mt76_dev *dev); |
| 352 | void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames, |
| 353 | struct napi_struct *napi); |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 354 | @@ -1547,9 +1553,9 @@ struct mt76_txwi_cache * |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 355 | mt76_token_release(struct mt76_dev *dev, int token, bool *wake); |
| 356 | int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi); |
| 357 | void __mt76_set_tx_blocked(struct mt76_dev *dev, bool blocked); |
| 358 | -struct mt76_txwi_cache *mt76_rx_token_release(struct mt76_dev *dev, int token); |
| 359 | +struct mt76_rxwi_cache *mt76_rx_token_release(struct mt76_dev *dev, int token); |
| 360 | int mt76_rx_token_consume(struct mt76_dev *dev, void *ptr, |
| 361 | - struct mt76_txwi_cache *r, dma_addr_t phys); |
| 362 | + struct mt76_rxwi_cache *r, dma_addr_t phys); |
| 363 | |
| 364 | static inline void mt76_set_tx_blocked(struct mt76_dev *dev, bool blocked) |
| 365 | { |
| 366 | diff --git a/mt7915/dma.c b/mt7915/dma.c |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 367 | index 36260085..9cbd3625 100644 |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 368 | --- a/mt7915/dma.c |
| 369 | +++ b/mt7915/dma.c |
| 370 | @@ -492,7 +492,6 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2) |
| 371 | mtk_wed_get_rx_capa(&mdev->mmio.wed)) { |
| 372 | dev->mt76.q_rx[MT_RXQ_MAIN].flags = |
| 373 | MT_WED_Q_RX(MT7915_RXQ_BAND0); |
| 374 | - dev->mt76.rx_token_size += MT7915_RX_RING_SIZE; |
| 375 | } |
| 376 | |
| 377 | ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MAIN], |
| 378 | @@ -529,7 +528,6 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2) |
| 379 | mtk_wed_get_rx_capa(&mdev->mmio.wed)) { |
| 380 | dev->mt76.q_rx[MT_RXQ_BAND1].flags = |
| 381 | MT_WED_Q_RX(MT7915_RXQ_BAND1); |
| 382 | - dev->mt76.rx_token_size += MT7915_RX_RING_SIZE; |
| 383 | } |
| 384 | |
| 385 | /* rx data queue for band1 */ |
| 386 | diff --git a/mt7915/mmio.c b/mt7915/mmio.c |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 387 | index 4bc8e8cd..09b39730 100644 |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 388 | --- a/mt7915/mmio.c |
| 389 | +++ b/mt7915/mmio.c |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 390 | @@ -605,18 +605,18 @@ static void mt7915_mmio_wed_release_rx_buf(struct mtk_wed_device *wed) |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 391 | |
| 392 | dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed); |
| 393 | for (i = 0; i < dev->mt76.rx_token_size; i++) { |
| 394 | - struct mt76_txwi_cache *t; |
| 395 | + struct mt76_rxwi_cache *r; |
| 396 | |
| 397 | - t = mt76_rx_token_release(&dev->mt76, i); |
| 398 | - if (!t || !t->ptr) |
| 399 | + r = mt76_rx_token_release(&dev->mt76, i); |
| 400 | + if (!r || !r->ptr) |
| 401 | continue; |
| 402 | |
| 403 | - dma_unmap_single(dev->mt76.dma_dev, t->dma_addr, |
| 404 | + dma_unmap_single(dev->mt76.dma_dev, r->dma_addr, |
| 405 | wed->wlan.rx_size, DMA_FROM_DEVICE); |
| 406 | - skb_free_frag(t->ptr); |
| 407 | - t->ptr = NULL; |
| 408 | + skb_free_frag(r->ptr); |
| 409 | + r->ptr = NULL; |
| 410 | |
| 411 | - mt76_put_rxwi(&dev->mt76, t); |
| 412 | + mt76_put_rxwi(&dev->mt76, r); |
| 413 | } |
| 414 | |
| 415 | mt76_free_pending_rxwi(&dev->mt76); |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 416 | @@ -641,7 +641,7 @@ static u32 mt7915_mmio_wed_init_rx_buf(struct mtk_wed_device *wed, int size) |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 417 | sizeof(struct skb_shared_info)); |
| 418 | |
| 419 | for (i = 0; i < size; i++) { |
| 420 | - struct mt76_txwi_cache *t = mt76_get_rxwi(&dev->mt76); |
| 421 | + struct mt76_rxwi_cache *r = mt76_get_rxwi(&dev->mt76); |
| 422 | dma_addr_t phy_addr; |
| 423 | int token; |
| 424 | void *ptr; |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 425 | @@ -660,7 +660,7 @@ static u32 mt7915_mmio_wed_init_rx_buf(struct mtk_wed_device *wed, int size) |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | desc->buf0 = cpu_to_le32(phy_addr); |
| 429 | - token = mt76_rx_token_consume(&dev->mt76, ptr, t, phy_addr); |
| 430 | + token = mt76_rx_token_consume(&dev->mt76, ptr, r, phy_addr); |
| 431 | if (token < 0) { |
| 432 | dma_unmap_single(dev->mt76.dma_dev, phy_addr, |
| 433 | wed->wlan.rx_size, DMA_TO_DEVICE); |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 434 | @@ -788,7 +788,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 435 | wed->wlan.update_wo_rx_stats = mt7915_mmio_wed_update_rx_stats; |
| 436 | wed->wlan.ser_trigger = mt7915_wed_trigger_ser; |
| 437 | |
| 438 | - dev->mt76.rx_token_size = wed->wlan.rx_npkt; |
| 439 | + dev->mt76.rx_token_size += wed->wlan.rx_npkt; |
| 440 | |
| 441 | if (mtk_wed_device_attach(wed)) |
| 442 | return 0; |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 443 | @@ -994,6 +994,7 @@ struct mt7915_dev *mt7915_mmio_probe(struct device *pdev, |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 444 | SURVEY_INFO_TIME_RX | |
| 445 | SURVEY_INFO_TIME_BSS_RX, |
| 446 | .token_size = MT7915_TOKEN_SIZE, |
| 447 | + .rx_token_size = MT7915_RX_TOKEN_SIZE, |
| 448 | .tx_prepare_skb = mt7915_tx_prepare_skb, |
| 449 | .tx_complete_skb = mt76_connac_tx_complete_skb, |
| 450 | .rx_skb = mt7915_queue_rx_skb, |
| 451 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 452 | index c3a0b326..91b98ede 100644 |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 453 | --- a/mt7915/mt7915.h |
| 454 | +++ b/mt7915/mt7915.h |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 455 | @@ -57,6 +57,7 @@ |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 456 | #define MT7915_EEPROM_BLOCK_SIZE 16 |
| 457 | #define MT7915_TOKEN_SIZE 8192 |
developer | efb40c1 | 2022-12-21 18:05:47 +0800 | [diff] [blame] | 458 | #define MT7915_HW_TOKEN_SIZE 7168 |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 459 | +#define MT7915_RX_TOKEN_SIZE 4096 |
| 460 | |
| 461 | #define MT7915_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */ |
| 462 | #define MT7915_CFEND_RATE_11B 0x03 /* 11B LP, 11M */ |
| 463 | diff --git a/tx.c b/tx.c |
developer | b9a9660 | 2023-01-10 19:53:25 +0800 | [diff] [blame^] | 464 | index 6d55566f..a72b7779 100644 |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 465 | --- a/tx.c |
| 466 | +++ b/tx.c |
| 467 | @@ -756,16 +756,16 @@ int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi) |
| 468 | EXPORT_SYMBOL_GPL(mt76_token_consume); |
| 469 | |
| 470 | int mt76_rx_token_consume(struct mt76_dev *dev, void *ptr, |
| 471 | - struct mt76_txwi_cache *t, dma_addr_t phys) |
| 472 | + struct mt76_rxwi_cache *r, dma_addr_t phys) |
| 473 | { |
| 474 | int token; |
| 475 | |
| 476 | spin_lock_bh(&dev->rx_token_lock); |
| 477 | - token = idr_alloc(&dev->rx_token, t, 0, dev->rx_token_size, |
| 478 | + token = idr_alloc(&dev->rx_token, r, 0, dev->rx_token_size, |
| 479 | GFP_ATOMIC); |
| 480 | if (token >= 0) { |
| 481 | - t->ptr = ptr; |
| 482 | - t->dma_addr = phys; |
| 483 | + r->ptr = ptr; |
| 484 | + r->dma_addr = phys; |
| 485 | } |
| 486 | spin_unlock_bh(&dev->rx_token_lock); |
| 487 | |
| 488 | @@ -802,15 +802,15 @@ mt76_token_release(struct mt76_dev *dev, int token, bool *wake) |
| 489 | } |
| 490 | EXPORT_SYMBOL_GPL(mt76_token_release); |
| 491 | |
| 492 | -struct mt76_txwi_cache * |
| 493 | +struct mt76_rxwi_cache * |
| 494 | mt76_rx_token_release(struct mt76_dev *dev, int token) |
| 495 | { |
| 496 | - struct mt76_txwi_cache *t; |
| 497 | + struct mt76_rxwi_cache *r; |
| 498 | |
| 499 | spin_lock_bh(&dev->rx_token_lock); |
| 500 | - t = idr_remove(&dev->rx_token, token); |
| 501 | + r = idr_remove(&dev->rx_token, token); |
| 502 | spin_unlock_bh(&dev->rx_token_lock); |
| 503 | |
| 504 | - return t; |
| 505 | + return r; |
| 506 | } |
| 507 | EXPORT_SYMBOL_GPL(mt76_rx_token_release); |
| 508 | -- |
developer | 79a21a2 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 509 | 2.18.0 |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 510 | |