.. | .. |
---|
| 1 | +// SPDX-License-Identifier: ISC |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2012-2017 Qualcomm Atheros, Inc. |
---|
3 | | - * Copyright (c) 2018, The Linux Foundation. All rights reserved. |
---|
4 | | - * |
---|
5 | | - * Permission to use, copy, modify, and/or distribute this software for any |
---|
6 | | - * purpose with or without fee is hereby granted, provided that the above |
---|
7 | | - * copyright notice and this permission notice appear in all copies. |
---|
8 | | - * |
---|
9 | | - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
---|
10 | | - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
---|
11 | | - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
---|
12 | | - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
---|
13 | | - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
---|
14 | | - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
---|
15 | | - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
---|
| 4 | + * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. |
---|
16 | 5 | */ |
---|
17 | 6 | |
---|
18 | 7 | #include <linux/module.h> |
---|
.. | .. |
---|
63 | 52 | &ring->va[idx].rx.enhanced; |
---|
64 | 53 | u16 buff_id = le16_to_cpu(rx_d->mac.buff_id); |
---|
65 | 54 | |
---|
66 | | - has_skb = wil->rx_buff_mgmt.buff_arr[buff_id].skb; |
---|
| 55 | + if (wil->rx_buff_mgmt.buff_arr && |
---|
| 56 | + wil_val_in_range(buff_id, 0, wil->rx_buff_mgmt.size)) |
---|
| 57 | + has_skb = wil->rx_buff_mgmt.buff_arr[buff_id].skb; |
---|
67 | 58 | seq_printf(s, "%c", (has_skb) ? _h : _s); |
---|
68 | 59 | } else { |
---|
69 | 60 | struct wil_tx_enhanced_desc *d = |
---|
.. | .. |
---|
71 | 62 | &ring->va[idx].tx.enhanced; |
---|
72 | 63 | |
---|
73 | 64 | num_of_descs = (u8)d->mac.d[2]; |
---|
74 | | - has_skb = ring->ctx[idx].skb; |
---|
| 65 | + has_skb = ring->ctx && ring->ctx[idx].skb; |
---|
75 | 66 | if (num_of_descs >= 1) |
---|
76 | | - seq_printf(s, "%c", ring->ctx[idx].skb ? _h : _s); |
---|
| 67 | + seq_printf(s, "%c", has_skb ? _h : _s); |
---|
77 | 68 | else |
---|
78 | 69 | /* num_of_descs == 0, it's a frag in a list of descs */ |
---|
79 | 70 | seq_printf(s, "%c", has_skb ? 'h' : _s); |
---|
.. | .. |
---|
84 | 75 | const char *name, struct wil_ring *ring, |
---|
85 | 76 | char _s, char _h) |
---|
86 | 77 | { |
---|
87 | | - void __iomem *x = wmi_addr(wil, ring->hwtail); |
---|
| 78 | + void __iomem *x; |
---|
88 | 79 | u32 v; |
---|
89 | 80 | |
---|
90 | 81 | seq_printf(s, "RING %s = {\n", name); |
---|
.. | .. |
---|
96 | 87 | else |
---|
97 | 88 | seq_printf(s, " swtail = %d\n", ring->swtail); |
---|
98 | 89 | seq_printf(s, " swhead = %d\n", ring->swhead); |
---|
| 90 | + if (wil->use_enhanced_dma_hw) { |
---|
| 91 | + int ring_id = ring->is_rx ? |
---|
| 92 | + WIL_RX_DESC_RING_ID : ring - wil->ring_tx; |
---|
| 93 | + /* SUBQ_CONS is a table of 32 entries, one for each Q pair. |
---|
| 94 | + * lower 16bits are for even ring_id and upper 16bits are for |
---|
| 95 | + * odd ring_id |
---|
| 96 | + */ |
---|
| 97 | + x = wmi_addr(wil, RGF_DMA_SCM_SUBQ_CONS + 4 * (ring_id / 2)); |
---|
| 98 | + v = readl_relaxed(x); |
---|
| 99 | + |
---|
| 100 | + v = (ring_id % 2 ? (v >> 16) : (v & 0xffff)); |
---|
| 101 | + seq_printf(s, " hwhead = %u\n", v); |
---|
| 102 | + } |
---|
99 | 103 | seq_printf(s, " hwtail = [0x%08x] -> ", ring->hwtail); |
---|
| 104 | + x = wmi_addr(wil, ring->hwtail); |
---|
100 | 105 | if (x) { |
---|
101 | 106 | v = readl(x); |
---|
102 | 107 | seq_printf(s, "0x%08x = %d\n", v, v); |
---|
.. | .. |
---|
124 | 129 | seq_puts(s, "}\n"); |
---|
125 | 130 | } |
---|
126 | 131 | |
---|
127 | | -static int wil_ring_debugfs_show(struct seq_file *s, void *data) |
---|
| 132 | +static int ring_show(struct seq_file *s, void *data) |
---|
128 | 133 | { |
---|
129 | 134 | uint i; |
---|
130 | 135 | struct wil6210_priv *wil = s->private; |
---|
.. | .. |
---|
162 | 167 | |
---|
163 | 168 | snprintf(name, sizeof(name), "tx_%2d", i); |
---|
164 | 169 | |
---|
165 | | - if (cid < WIL6210_MAX_CID) |
---|
| 170 | + if (cid < wil->max_assoc_sta) |
---|
166 | 171 | seq_printf(s, |
---|
167 | 172 | "\n%pM CID %d TID %d 1x%s BACK([%u] %u TU A%s) [%3d|%3d] idle %s\n", |
---|
168 | 173 | wil->sta[cid].addr, cid, tid, |
---|
.. | .. |
---|
183 | 188 | |
---|
184 | 189 | return 0; |
---|
185 | 190 | } |
---|
186 | | - |
---|
187 | | -static int wil_ring_seq_open(struct inode *inode, struct file *file) |
---|
188 | | -{ |
---|
189 | | - return single_open(file, wil_ring_debugfs_show, inode->i_private); |
---|
190 | | -} |
---|
191 | | - |
---|
192 | | -static const struct file_operations fops_ring = { |
---|
193 | | - .open = wil_ring_seq_open, |
---|
194 | | - .release = single_release, |
---|
195 | | - .read = seq_read, |
---|
196 | | - .llseek = seq_lseek, |
---|
197 | | -}; |
---|
| 191 | +DEFINE_SHOW_ATTRIBUTE(ring); |
---|
198 | 192 | |
---|
199 | 193 | static void wil_print_sring(struct seq_file *s, struct wil6210_priv *wil, |
---|
200 | 194 | struct wil_status_ring *sring) |
---|
201 | 195 | { |
---|
202 | | - void __iomem *x = wmi_addr(wil, sring->hwtail); |
---|
| 196 | + void __iomem *x; |
---|
203 | 197 | int sring_idx = sring - wil->srings; |
---|
204 | 198 | u32 v; |
---|
205 | 199 | |
---|
.. | .. |
---|
210 | 204 | seq_printf(s, " size = %d\n", sring->size); |
---|
211 | 205 | seq_printf(s, " elem_size = %zu\n", sring->elem_size); |
---|
212 | 206 | seq_printf(s, " swhead = %d\n", sring->swhead); |
---|
| 207 | + if (wil->use_enhanced_dma_hw) { |
---|
| 208 | + /* COMPQ_PROD is a table of 32 entries, one for each Q pair. |
---|
| 209 | + * lower 16bits are for even ring_id and upper 16bits are for |
---|
| 210 | + * odd ring_id |
---|
| 211 | + */ |
---|
| 212 | + x = wmi_addr(wil, RGF_DMA_SCM_COMPQ_PROD + 4 * (sring_idx / 2)); |
---|
| 213 | + v = readl_relaxed(x); |
---|
| 214 | + |
---|
| 215 | + v = (sring_idx % 2 ? (v >> 16) : (v & 0xffff)); |
---|
| 216 | + seq_printf(s, " hwhead = %u\n", v); |
---|
| 217 | + } |
---|
213 | 218 | seq_printf(s, " hwtail = [0x%08x] -> ", sring->hwtail); |
---|
| 219 | + x = wmi_addr(wil, sring->hwtail); |
---|
214 | 220 | if (x) { |
---|
215 | 221 | v = readl_relaxed(x); |
---|
216 | 222 | seq_printf(s, "0x%08x = %d\n", v, v); |
---|
.. | .. |
---|
218 | 224 | seq_puts(s, "???\n"); |
---|
219 | 225 | } |
---|
220 | 226 | seq_printf(s, " desc_rdy_pol = %d\n", sring->desc_rdy_pol); |
---|
| 227 | + seq_printf(s, " invalid_buff_id_cnt = %d\n", |
---|
| 228 | + sring->invalid_buff_id_cnt); |
---|
221 | 229 | |
---|
222 | 230 | if (sring->va && (sring->size <= (1 << WIL_RING_SIZE_ORDER_MAX))) { |
---|
223 | 231 | uint i; |
---|
.. | .. |
---|
240 | 248 | seq_puts(s, "}\n"); |
---|
241 | 249 | } |
---|
242 | 250 | |
---|
243 | | -static int wil_srings_debugfs_show(struct seq_file *s, void *data) |
---|
| 251 | +static int srings_show(struct seq_file *s, void *data) |
---|
244 | 252 | { |
---|
245 | 253 | struct wil6210_priv *wil = s->private; |
---|
246 | 254 | int i = 0; |
---|
.. | .. |
---|
251 | 259 | |
---|
252 | 260 | return 0; |
---|
253 | 261 | } |
---|
254 | | - |
---|
255 | | -static int wil_srings_seq_open(struct inode *inode, struct file *file) |
---|
256 | | -{ |
---|
257 | | - return single_open(file, wil_srings_debugfs_show, inode->i_private); |
---|
258 | | -} |
---|
259 | | - |
---|
260 | | -static const struct file_operations fops_srings = { |
---|
261 | | - .open = wil_srings_seq_open, |
---|
262 | | - .release = single_release, |
---|
263 | | - .read = seq_read, |
---|
264 | | - .llseek = seq_lseek, |
---|
265 | | -}; |
---|
| 262 | +DEFINE_SHOW_ATTRIBUTE(srings); |
---|
266 | 263 | |
---|
267 | 264 | static void wil_seq_hexdump(struct seq_file *s, void *p, int len, |
---|
268 | 265 | const char *prefix) |
---|
.. | .. |
---|
279 | 276 | uint i; |
---|
280 | 277 | |
---|
281 | 278 | wil_halp_vote(wil); |
---|
| 279 | + |
---|
| 280 | + if (wil_mem_access_lock(wil)) { |
---|
| 281 | + wil_halp_unvote(wil); |
---|
| 282 | + return; |
---|
| 283 | + } |
---|
282 | 284 | |
---|
283 | 285 | wil_memcpy_fromio_32(&r, off, sizeof(r)); |
---|
284 | 286 | wil_mbox_ring_le2cpus(&r); |
---|
.. | .. |
---|
345 | 347 | } |
---|
346 | 348 | out: |
---|
347 | 349 | seq_puts(s, "}\n"); |
---|
| 350 | + wil_mem_access_unlock(wil); |
---|
348 | 351 | wil_halp_unvote(wil); |
---|
349 | 352 | } |
---|
350 | 353 | |
---|
351 | | -static int wil_mbox_debugfs_show(struct seq_file *s, void *data) |
---|
| 354 | +static int mbox_show(struct seq_file *s, void *data) |
---|
352 | 355 | { |
---|
353 | 356 | struct wil6210_priv *wil = s->private; |
---|
354 | 357 | int ret; |
---|
.. | .. |
---|
366 | 369 | |
---|
367 | 370 | return 0; |
---|
368 | 371 | } |
---|
369 | | - |
---|
370 | | -static int wil_mbox_seq_open(struct inode *inode, struct file *file) |
---|
371 | | -{ |
---|
372 | | - return single_open(file, wil_mbox_debugfs_show, inode->i_private); |
---|
373 | | -} |
---|
374 | | - |
---|
375 | | -static const struct file_operations fops_mbox = { |
---|
376 | | - .open = wil_mbox_seq_open, |
---|
377 | | - .release = single_release, |
---|
378 | | - .read = seq_read, |
---|
379 | | - .llseek = seq_lseek, |
---|
380 | | -}; |
---|
| 372 | +DEFINE_SHOW_ATTRIBUTE(mbox); |
---|
381 | 373 | |
---|
382 | 374 | static int wil_debugfs_iomem_x32_set(void *data, u64 val) |
---|
383 | 375 | { |
---|
.. | .. |
---|
390 | 382 | if (ret < 0) |
---|
391 | 383 | return ret; |
---|
392 | 384 | |
---|
393 | | - writel(val, (void __iomem *)d->offset); |
---|
| 385 | + writel_relaxed(val, (void __iomem *)d->offset); |
---|
| 386 | + |
---|
394 | 387 | wmb(); /* make sure write propagated to HW */ |
---|
395 | 388 | |
---|
396 | 389 | wil_pm_runtime_put(wil); |
---|
.. | .. |
---|
416 | 409 | return 0; |
---|
417 | 410 | } |
---|
418 | 411 | |
---|
419 | | -DEFINE_SIMPLE_ATTRIBUTE(fops_iomem_x32, wil_debugfs_iomem_x32_get, |
---|
420 | | - wil_debugfs_iomem_x32_set, "0x%08llx\n"); |
---|
| 412 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_iomem_x32, wil_debugfs_iomem_x32_get, |
---|
| 413 | + wil_debugfs_iomem_x32_set, "0x%08llx\n"); |
---|
421 | 414 | |
---|
422 | | -static struct dentry *wil_debugfs_create_iomem_x32(const char *name, |
---|
423 | | - umode_t mode, |
---|
424 | | - struct dentry *parent, |
---|
425 | | - void *value, |
---|
426 | | - struct wil6210_priv *wil) |
---|
| 415 | +static void wil_debugfs_create_iomem_x32(const char *name, umode_t mode, |
---|
| 416 | + struct dentry *parent, void *value, |
---|
| 417 | + struct wil6210_priv *wil) |
---|
427 | 418 | { |
---|
428 | | - struct dentry *file; |
---|
429 | 419 | struct wil_debugfs_iomem_data *data = &wil->dbg_data.data_arr[ |
---|
430 | 420 | wil->dbg_data.iomem_data_count]; |
---|
431 | 421 | |
---|
432 | 422 | data->wil = wil; |
---|
433 | 423 | data->offset = value; |
---|
434 | 424 | |
---|
435 | | - file = debugfs_create_file(name, mode, parent, data, &fops_iomem_x32); |
---|
436 | | - if (!IS_ERR_OR_NULL(file)) |
---|
437 | | - wil->dbg_data.iomem_data_count++; |
---|
438 | | - |
---|
439 | | - return file; |
---|
| 425 | + debugfs_create_file_unsafe(name, mode, parent, data, &fops_iomem_x32); |
---|
| 426 | + wil->dbg_data.iomem_data_count++; |
---|
440 | 427 | } |
---|
441 | 428 | |
---|
442 | 429 | static int wil_debugfs_ulong_set(void *data, u64 val) |
---|
.. | .. |
---|
451 | 438 | return 0; |
---|
452 | 439 | } |
---|
453 | 440 | |
---|
454 | | -DEFINE_SIMPLE_ATTRIBUTE(wil_fops_ulong, wil_debugfs_ulong_get, |
---|
455 | | - wil_debugfs_ulong_set, "0x%llx\n"); |
---|
456 | | - |
---|
457 | | -static struct dentry *wil_debugfs_create_ulong(const char *name, umode_t mode, |
---|
458 | | - struct dentry *parent, |
---|
459 | | - ulong *value) |
---|
460 | | -{ |
---|
461 | | - return debugfs_create_file(name, mode, parent, value, &wil_fops_ulong); |
---|
462 | | -} |
---|
| 441 | +DEFINE_DEBUGFS_ATTRIBUTE(wil_fops_ulong, wil_debugfs_ulong_get, |
---|
| 442 | + wil_debugfs_ulong_set, "0x%llx\n"); |
---|
463 | 443 | |
---|
464 | 444 | /** |
---|
465 | 445 | * wil6210_debugfs_init_offset - create set of debugfs files |
---|
466 | | - * @wil - driver's context, used for printing |
---|
467 | | - * @dbg - directory on the debugfs, where files will be created |
---|
468 | | - * @base - base address used in address calculation |
---|
469 | | - * @tbl - table with file descriptions. Should be terminated with empty element. |
---|
| 446 | + * @wil: driver's context, used for printing |
---|
| 447 | + * @dbg: directory on the debugfs, where files will be created |
---|
| 448 | + * @base: base address used in address calculation |
---|
| 449 | + * @tbl: table with file descriptions. Should be terminated with empty element. |
---|
470 | 450 | * |
---|
471 | 451 | * Creates files accordingly to the @tbl. |
---|
472 | 452 | */ |
---|
.. | .. |
---|
477 | 457 | int i; |
---|
478 | 458 | |
---|
479 | 459 | for (i = 0; tbl[i].name; i++) { |
---|
480 | | - struct dentry *f; |
---|
481 | | - |
---|
482 | 460 | switch (tbl[i].type) { |
---|
483 | 461 | case doff_u32: |
---|
484 | | - f = debugfs_create_u32(tbl[i].name, tbl[i].mode, dbg, |
---|
485 | | - base + tbl[i].off); |
---|
| 462 | + debugfs_create_u32(tbl[i].name, tbl[i].mode, dbg, |
---|
| 463 | + base + tbl[i].off); |
---|
486 | 464 | break; |
---|
487 | 465 | case doff_x32: |
---|
488 | | - f = debugfs_create_x32(tbl[i].name, tbl[i].mode, dbg, |
---|
489 | | - base + tbl[i].off); |
---|
| 466 | + debugfs_create_x32(tbl[i].name, tbl[i].mode, dbg, |
---|
| 467 | + base + tbl[i].off); |
---|
490 | 468 | break; |
---|
491 | 469 | case doff_ulong: |
---|
492 | | - f = wil_debugfs_create_ulong(tbl[i].name, tbl[i].mode, |
---|
493 | | - dbg, base + tbl[i].off); |
---|
| 470 | + debugfs_create_file_unsafe(tbl[i].name, tbl[i].mode, |
---|
| 471 | + dbg, base + tbl[i].off, |
---|
| 472 | + &wil_fops_ulong); |
---|
494 | 473 | break; |
---|
495 | 474 | case doff_io32: |
---|
496 | | - f = wil_debugfs_create_iomem_x32(tbl[i].name, |
---|
497 | | - tbl[i].mode, dbg, |
---|
498 | | - base + tbl[i].off, |
---|
499 | | - wil); |
---|
| 475 | + wil_debugfs_create_iomem_x32(tbl[i].name, tbl[i].mode, |
---|
| 476 | + dbg, base + tbl[i].off, |
---|
| 477 | + wil); |
---|
500 | 478 | break; |
---|
501 | 479 | case doff_u8: |
---|
502 | | - f = debugfs_create_u8(tbl[i].name, tbl[i].mode, dbg, |
---|
503 | | - base + tbl[i].off); |
---|
| 480 | + debugfs_create_u8(tbl[i].name, tbl[i].mode, dbg, |
---|
| 481 | + base + tbl[i].off); |
---|
504 | 482 | break; |
---|
505 | | - default: |
---|
506 | | - f = ERR_PTR(-EINVAL); |
---|
507 | 483 | } |
---|
508 | | - if (IS_ERR_OR_NULL(f)) |
---|
509 | | - wil_err(wil, "Create file \"%s\": err %ld\n", |
---|
510 | | - tbl[i].name, PTR_ERR(f)); |
---|
511 | 484 | } |
---|
512 | 485 | } |
---|
513 | 486 | |
---|
.. | .. |
---|
522 | 495 | {}, |
---|
523 | 496 | }; |
---|
524 | 497 | |
---|
525 | | -static int wil6210_debugfs_create_ISR(struct wil6210_priv *wil, |
---|
526 | | - const char *name, |
---|
527 | | - struct dentry *parent, u32 off) |
---|
| 498 | +static void wil6210_debugfs_create_ISR(struct wil6210_priv *wil, |
---|
| 499 | + const char *name, struct dentry *parent, |
---|
| 500 | + u32 off) |
---|
528 | 501 | { |
---|
529 | 502 | struct dentry *d = debugfs_create_dir(name, parent); |
---|
530 | 503 | |
---|
531 | | - if (IS_ERR_OR_NULL(d)) |
---|
532 | | - return -ENODEV; |
---|
533 | | - |
---|
534 | 504 | wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr + off, |
---|
535 | 505 | isr_off); |
---|
536 | | - |
---|
537 | | - return 0; |
---|
538 | 506 | } |
---|
539 | 507 | |
---|
540 | 508 | static const struct dbg_off pseudo_isr_off[] = { |
---|
.. | .. |
---|
544 | 512 | {}, |
---|
545 | 513 | }; |
---|
546 | 514 | |
---|
547 | | -static int wil6210_debugfs_create_pseudo_ISR(struct wil6210_priv *wil, |
---|
548 | | - struct dentry *parent) |
---|
| 515 | +static void wil6210_debugfs_create_pseudo_ISR(struct wil6210_priv *wil, |
---|
| 516 | + struct dentry *parent) |
---|
549 | 517 | { |
---|
550 | 518 | struct dentry *d = debugfs_create_dir("PSEUDO_ISR", parent); |
---|
551 | 519 | |
---|
552 | | - if (IS_ERR_OR_NULL(d)) |
---|
553 | | - return -ENODEV; |
---|
554 | | - |
---|
555 | 520 | wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr, |
---|
556 | 521 | pseudo_isr_off); |
---|
557 | | - |
---|
558 | | - return 0; |
---|
559 | 522 | } |
---|
560 | 523 | |
---|
561 | 524 | static const struct dbg_off lgc_itr_cnt_off[] = { |
---|
.. | .. |
---|
603 | 566 | struct dentry *d, *dtx, *drx; |
---|
604 | 567 | |
---|
605 | 568 | d = debugfs_create_dir("ITR_CNT", parent); |
---|
606 | | - if (IS_ERR_OR_NULL(d)) |
---|
607 | | - return -ENODEV; |
---|
608 | 569 | |
---|
609 | 570 | dtx = debugfs_create_dir("TX", d); |
---|
610 | 571 | drx = debugfs_create_dir("RX", d); |
---|
611 | | - if (IS_ERR_OR_NULL(dtx) || IS_ERR_OR_NULL(drx)) |
---|
612 | | - return -ENODEV; |
---|
613 | 572 | |
---|
614 | 573 | wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr, |
---|
615 | 574 | lgc_itr_cnt_off); |
---|
.. | .. |
---|
622 | 581 | return 0; |
---|
623 | 582 | } |
---|
624 | 583 | |
---|
625 | | -static int wil_memread_debugfs_show(struct seq_file *s, void *data) |
---|
| 584 | +static int memread_show(struct seq_file *s, void *data) |
---|
626 | 585 | { |
---|
627 | 586 | struct wil6210_priv *wil = s->private; |
---|
628 | 587 | void __iomem *a; |
---|
.. | .. |
---|
632 | 591 | if (ret < 0) |
---|
633 | 592 | return ret; |
---|
634 | 593 | |
---|
| 594 | + ret = wil_mem_access_lock(wil); |
---|
| 595 | + if (ret) { |
---|
| 596 | + wil_pm_runtime_put(wil); |
---|
| 597 | + return ret; |
---|
| 598 | + } |
---|
| 599 | + |
---|
635 | 600 | a = wmi_buffer(wil, cpu_to_le32(mem_addr)); |
---|
636 | 601 | |
---|
637 | 602 | if (a) |
---|
.. | .. |
---|
639 | 604 | else |
---|
640 | 605 | seq_printf(s, "[0x%08x] = INVALID\n", mem_addr); |
---|
641 | 606 | |
---|
| 607 | + wil_mem_access_unlock(wil); |
---|
642 | 608 | wil_pm_runtime_put(wil); |
---|
643 | 609 | |
---|
644 | 610 | return 0; |
---|
645 | 611 | } |
---|
646 | | - |
---|
647 | | -static int wil_memread_seq_open(struct inode *inode, struct file *file) |
---|
648 | | -{ |
---|
649 | | - return single_open(file, wil_memread_debugfs_show, inode->i_private); |
---|
650 | | -} |
---|
651 | | - |
---|
652 | | -static const struct file_operations fops_memread = { |
---|
653 | | - .open = wil_memread_seq_open, |
---|
654 | | - .release = single_release, |
---|
655 | | - .read = seq_read, |
---|
656 | | - .llseek = seq_lseek, |
---|
657 | | -}; |
---|
| 612 | +DEFINE_SHOW_ATTRIBUTE(memread); |
---|
658 | 613 | |
---|
659 | 614 | static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf, |
---|
660 | 615 | size_t count, loff_t *ppos) |
---|
.. | .. |
---|
667 | 622 | void *buf; |
---|
668 | 623 | size_t unaligned_bytes, aligned_count, ret; |
---|
669 | 624 | int rc; |
---|
670 | | - |
---|
671 | | - if (test_bit(wil_status_suspending, wil_blob->wil->status) || |
---|
672 | | - test_bit(wil_status_suspended, wil_blob->wil->status)) |
---|
673 | | - return 0; |
---|
674 | 625 | |
---|
675 | 626 | if (pos < 0) |
---|
676 | 627 | return -EINVAL; |
---|
.. | .. |
---|
698 | 649 | return rc; |
---|
699 | 650 | } |
---|
700 | 651 | |
---|
| 652 | + rc = wil_mem_access_lock(wil); |
---|
| 653 | + if (rc) { |
---|
| 654 | + kfree(buf); |
---|
| 655 | + wil_pm_runtime_put(wil); |
---|
| 656 | + return rc; |
---|
| 657 | + } |
---|
| 658 | + |
---|
701 | 659 | wil_memcpy_fromio_32(buf, (const void __iomem *) |
---|
702 | 660 | wil_blob->blob.data + aligned_pos, aligned_count); |
---|
703 | 661 | |
---|
704 | 662 | ret = copy_to_user(user_buf, buf + unaligned_bytes, count); |
---|
705 | 663 | |
---|
| 664 | + wil_mem_access_unlock(wil); |
---|
706 | 665 | wil_pm_runtime_put(wil); |
---|
707 | 666 | |
---|
708 | 667 | kfree(buf); |
---|
.. | .. |
---|
772 | 731 | .open = simple_open, |
---|
773 | 732 | }; |
---|
774 | 733 | |
---|
| 734 | +static ssize_t wil_write_file_rbufcap(struct file *file, |
---|
| 735 | + const char __user *buf, |
---|
| 736 | + size_t count, loff_t *ppos) |
---|
| 737 | +{ |
---|
| 738 | + struct wil6210_priv *wil = file->private_data; |
---|
| 739 | + int val; |
---|
| 740 | + int rc; |
---|
| 741 | + |
---|
| 742 | + rc = kstrtoint_from_user(buf, count, 0, &val); |
---|
| 743 | + if (rc) { |
---|
| 744 | + wil_err(wil, "Invalid argument\n"); |
---|
| 745 | + return rc; |
---|
| 746 | + } |
---|
| 747 | + /* input value: negative to disable, 0 to use system default, |
---|
| 748 | + * 1..ring size to set descriptor threshold |
---|
| 749 | + */ |
---|
| 750 | + wil_info(wil, "%s RBUFCAP, descriptors threshold - %d\n", |
---|
| 751 | + val < 0 ? "Disabling" : "Enabling", val); |
---|
| 752 | + |
---|
| 753 | + if (!wil->ring_rx.va || val > wil->ring_rx.size) { |
---|
| 754 | + wil_err(wil, "Invalid descriptors threshold, %d\n", val); |
---|
| 755 | + return -EINVAL; |
---|
| 756 | + } |
---|
| 757 | + |
---|
| 758 | + rc = wmi_rbufcap_cfg(wil, val < 0 ? 0 : 1, val < 0 ? 0 : val); |
---|
| 759 | + if (rc) { |
---|
| 760 | + wil_err(wil, "RBUFCAP config failed: %d\n", rc); |
---|
| 761 | + return rc; |
---|
| 762 | + } |
---|
| 763 | + |
---|
| 764 | + return count; |
---|
| 765 | +} |
---|
| 766 | + |
---|
| 767 | +static const struct file_operations fops_rbufcap = { |
---|
| 768 | + .write = wil_write_file_rbufcap, |
---|
| 769 | + .open = simple_open, |
---|
| 770 | +}; |
---|
| 771 | + |
---|
775 | 772 | /* block ack control, write: |
---|
776 | 773 | * - "add <ringid> <agg_size> <timeout>" to trigger ADDBA |
---|
777 | 774 | * - "del_tx <ringid> <reason>" to trigger DELBA for Tx side |
---|
.. | .. |
---|
834 | 831 | "BACK: del_rx require at least 2 params\n"); |
---|
835 | 832 | return -EINVAL; |
---|
836 | 833 | } |
---|
837 | | - if (p1 < 0 || p1 >= WIL6210_MAX_CID) { |
---|
| 834 | + if (p1 < 0 || p1 >= wil->max_assoc_sta) { |
---|
838 | 835 | wil_err(wil, "BACK: invalid CID %d\n", p1); |
---|
839 | 836 | return -EINVAL; |
---|
840 | 837 | } |
---|
841 | 838 | if (rc < 4) |
---|
842 | 839 | p3 = WLAN_REASON_QSTA_LEAVE_QBSS; |
---|
843 | 840 | sta = &wil->sta[p1]; |
---|
844 | | - wmi_delba_rx(wil, sta->mid, mk_cidxtid(p1, p2), p3); |
---|
| 841 | + wmi_delba_rx(wil, sta->mid, p1, p2, p3); |
---|
845 | 842 | } else { |
---|
846 | 843 | wil_err(wil, "BACK: Unrecognized command \"%s\"\n", cmd); |
---|
847 | 844 | return -EINVAL; |
---|
.. | .. |
---|
933 | 930 | " - \"alloc <num descriptors> <descriptor_size>\" to allocate pmc\n" |
---|
934 | 931 | " - \"free\" to free memory allocated for pmc\n"; |
---|
935 | 932 | |
---|
936 | | - sprintf(text, "Last command status: %d\n\n%s", |
---|
937 | | - wil_pmc_last_cmd_status(wil), |
---|
938 | | - help); |
---|
| 933 | + snprintf(text, sizeof(text), "Last command status: %d\n\n%s", |
---|
| 934 | + wil_pmc_last_cmd_status(wil), help); |
---|
939 | 935 | |
---|
940 | 936 | return simple_read_from_buffer(user_buf, count, ppos, text, |
---|
941 | 937 | strlen(text) + 1); |
---|
.. | .. |
---|
951 | 947 | .open = simple_open, |
---|
952 | 948 | .read = wil_pmc_read, |
---|
953 | 949 | .llseek = wil_pmc_llseek, |
---|
| 950 | +}; |
---|
| 951 | + |
---|
| 952 | +static int wil_pmcring_seq_open(struct inode *inode, struct file *file) |
---|
| 953 | +{ |
---|
| 954 | + return single_open(file, wil_pmcring_read, inode->i_private); |
---|
| 955 | +} |
---|
| 956 | + |
---|
| 957 | +static const struct file_operations fops_pmcring = { |
---|
| 958 | + .open = wil_pmcring_seq_open, |
---|
| 959 | + .release = single_release, |
---|
| 960 | + .read = seq_read, |
---|
| 961 | + .llseek = seq_lseek, |
---|
954 | 962 | }; |
---|
955 | 963 | |
---|
956 | 964 | /*---tx_mgmt---*/ |
---|
.. | .. |
---|
1002 | 1010 | void *cmd; |
---|
1003 | 1011 | int cmdlen = len - sizeof(struct wmi_cmd_hdr); |
---|
1004 | 1012 | u16 cmdid; |
---|
1005 | | - int rc, rc1; |
---|
| 1013 | + int rc1; |
---|
1006 | 1014 | |
---|
1007 | | - if (cmdlen < 0) |
---|
| 1015 | + if (cmdlen < 0 || *ppos != 0) |
---|
1008 | 1016 | return -EINVAL; |
---|
1009 | 1017 | |
---|
1010 | | - wmi = kmalloc(len, GFP_KERNEL); |
---|
1011 | | - if (!wmi) |
---|
1012 | | - return -ENOMEM; |
---|
1013 | | - |
---|
1014 | | - rc = simple_write_to_buffer(wmi, len, ppos, buf, len); |
---|
1015 | | - if (rc < 0) { |
---|
1016 | | - kfree(wmi); |
---|
1017 | | - return rc; |
---|
1018 | | - } |
---|
| 1018 | + wmi = memdup_user(buf, len); |
---|
| 1019 | + if (IS_ERR(wmi)) |
---|
| 1020 | + return PTR_ERR(wmi); |
---|
1019 | 1021 | |
---|
1020 | 1022 | cmd = (cmdlen > 0) ? &wmi[1] : NULL; |
---|
1021 | 1023 | cmdid = le16_to_cpu(wmi->command_id); |
---|
.. | .. |
---|
1025 | 1027 | |
---|
1026 | 1028 | wil_info(wil, "0x%04x[%d] -> %d\n", cmdid, cmdlen, rc1); |
---|
1027 | 1029 | |
---|
1028 | | - return rc; |
---|
| 1030 | + return len; |
---|
1029 | 1031 | } |
---|
1030 | 1032 | |
---|
1031 | 1033 | static const struct file_operations fops_wmi = { |
---|
.. | .. |
---|
1046 | 1048 | if (nr_frags) { |
---|
1047 | 1049 | seq_printf(s, " nr_frags = %d\n", nr_frags); |
---|
1048 | 1050 | for (i = 0; i < nr_frags; i++) { |
---|
1049 | | - const struct skb_frag_struct *frag = |
---|
1050 | | - &skb_shinfo(skb)->frags[i]; |
---|
| 1051 | + const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
---|
1051 | 1052 | |
---|
1052 | 1053 | len = skb_frag_size(frag); |
---|
1053 | 1054 | p = skb_frag_address_safe(frag); |
---|
.. | .. |
---|
1058 | 1059 | } |
---|
1059 | 1060 | |
---|
1060 | 1061 | /*---------Tx/Rx descriptor------------*/ |
---|
1061 | | -static int wil_txdesc_debugfs_show(struct seq_file *s, void *data) |
---|
| 1062 | +static int txdesc_show(struct seq_file *s, void *data) |
---|
1062 | 1063 | { |
---|
1063 | 1064 | struct wil6210_priv *wil = s->private; |
---|
1064 | 1065 | struct wil_ring *ring; |
---|
.. | .. |
---|
1114 | 1115 | |
---|
1115 | 1116 | if (wil->use_enhanced_dma_hw) { |
---|
1116 | 1117 | if (tx) { |
---|
1117 | | - skb = ring->ctx[txdesc_idx].skb; |
---|
1118 | | - } else { |
---|
| 1118 | + skb = ring->ctx ? ring->ctx[txdesc_idx].skb : NULL; |
---|
| 1119 | + } else if (wil->rx_buff_mgmt.buff_arr) { |
---|
1119 | 1120 | struct wil_rx_enhanced_desc *rx_d = |
---|
1120 | 1121 | (struct wil_rx_enhanced_desc *) |
---|
1121 | 1122 | &ring->va[txdesc_idx].rx.enhanced; |
---|
1122 | 1123 | u16 buff_id = le16_to_cpu(rx_d->mac.buff_id); |
---|
1123 | 1124 | |
---|
1124 | 1125 | if (!wil_val_in_range(buff_id, 0, |
---|
1125 | | - wil->rx_buff_mgmt.size)) { |
---|
| 1126 | + wil->rx_buff_mgmt.size)) |
---|
1126 | 1127 | seq_printf(s, "invalid buff_id %d\n", buff_id); |
---|
1127 | | - return 0; |
---|
1128 | | - } |
---|
1129 | | - skb = wil->rx_buff_mgmt.buff_arr[buff_id].skb; |
---|
| 1128 | + else |
---|
| 1129 | + skb = wil->rx_buff_mgmt.buff_arr[buff_id].skb; |
---|
1130 | 1130 | } |
---|
1131 | 1131 | } else { |
---|
1132 | 1132 | skb = ring->ctx[txdesc_idx].skb; |
---|
.. | .. |
---|
1151 | 1151 | |
---|
1152 | 1152 | return 0; |
---|
1153 | 1153 | } |
---|
1154 | | - |
---|
1155 | | -static int wil_txdesc_seq_open(struct inode *inode, struct file *file) |
---|
1156 | | -{ |
---|
1157 | | - return single_open(file, wil_txdesc_debugfs_show, inode->i_private); |
---|
1158 | | -} |
---|
1159 | | - |
---|
1160 | | -static const struct file_operations fops_txdesc = { |
---|
1161 | | - .open = wil_txdesc_seq_open, |
---|
1162 | | - .release = single_release, |
---|
1163 | | - .read = seq_read, |
---|
1164 | | - .llseek = seq_lseek, |
---|
1165 | | -}; |
---|
| 1154 | +DEFINE_SHOW_ATTRIBUTE(txdesc); |
---|
1166 | 1155 | |
---|
1167 | 1156 | /*---------Tx/Rx status message------------*/ |
---|
1168 | | -static int wil_status_msg_debugfs_show(struct seq_file *s, void *data) |
---|
| 1157 | +static int status_msg_show(struct seq_file *s, void *data) |
---|
1169 | 1158 | { |
---|
1170 | 1159 | struct wil6210_priv *wil = s->private; |
---|
1171 | 1160 | int sring_idx = dbg_sring_index; |
---|
1172 | 1161 | struct wil_status_ring *sring; |
---|
1173 | | - bool tx = sring_idx == wil->tx_sring_idx ? 1 : 0; |
---|
| 1162 | + bool tx; |
---|
1174 | 1163 | u32 status_msg_idx = dbg_status_msg_index; |
---|
1175 | 1164 | u32 *u; |
---|
1176 | 1165 | |
---|
.. | .. |
---|
1180 | 1169 | } |
---|
1181 | 1170 | |
---|
1182 | 1171 | sring = &wil->srings[sring_idx]; |
---|
| 1172 | + tx = !sring->is_rx; |
---|
1183 | 1173 | |
---|
1184 | 1174 | if (!sring->va) { |
---|
1185 | 1175 | seq_printf(s, "No %cX status ring\n", tx ? 'T' : 'R'); |
---|
.. | .. |
---|
1207 | 1197 | |
---|
1208 | 1198 | return 0; |
---|
1209 | 1199 | } |
---|
1210 | | - |
---|
1211 | | -static int wil_status_msg_seq_open(struct inode *inode, struct file *file) |
---|
1212 | | -{ |
---|
1213 | | - return single_open(file, wil_status_msg_debugfs_show, |
---|
1214 | | - inode->i_private); |
---|
1215 | | -} |
---|
1216 | | - |
---|
1217 | | -static const struct file_operations fops_status_msg = { |
---|
1218 | | - .open = wil_status_msg_seq_open, |
---|
1219 | | - .release = single_release, |
---|
1220 | | - .read = seq_read, |
---|
1221 | | - .llseek = seq_lseek, |
---|
1222 | | -}; |
---|
| 1200 | +DEFINE_SHOW_ATTRIBUTE(status_msg); |
---|
1223 | 1201 | |
---|
1224 | 1202 | static int wil_print_rx_buff(struct seq_file *s, struct list_head *lh) |
---|
1225 | 1203 | { |
---|
.. | .. |
---|
1237 | 1215 | return i; |
---|
1238 | 1216 | } |
---|
1239 | 1217 | |
---|
1240 | | -static int wil_rx_buff_mgmt_debugfs_show(struct seq_file *s, void *data) |
---|
| 1218 | +static int rx_buff_mgmt_show(struct seq_file *s, void *data) |
---|
1241 | 1219 | { |
---|
1242 | 1220 | struct wil6210_priv *wil = s->private; |
---|
1243 | 1221 | struct wil_rx_buff_mgmt *rbm = &wil->rx_buff_mgmt; |
---|
.. | .. |
---|
1262 | 1240 | |
---|
1263 | 1241 | return 0; |
---|
1264 | 1242 | } |
---|
1265 | | - |
---|
1266 | | -static int wil_rx_buff_mgmt_seq_open(struct inode *inode, struct file *file) |
---|
1267 | | -{ |
---|
1268 | | - return single_open(file, wil_rx_buff_mgmt_debugfs_show, |
---|
1269 | | - inode->i_private); |
---|
1270 | | -} |
---|
1271 | | - |
---|
1272 | | -static const struct file_operations fops_rx_buff_mgmt = { |
---|
1273 | | - .open = wil_rx_buff_mgmt_seq_open, |
---|
1274 | | - .release = single_release, |
---|
1275 | | - .read = seq_read, |
---|
1276 | | - .llseek = seq_lseek, |
---|
1277 | | -}; |
---|
| 1243 | +DEFINE_SHOW_ATTRIBUTE(rx_buff_mgmt); |
---|
1278 | 1244 | |
---|
1279 | 1245 | /*---------beamforming------------*/ |
---|
1280 | 1246 | static char *wil_bfstatus_str(u32 status) |
---|
.. | .. |
---|
1304 | 1270 | return true; |
---|
1305 | 1271 | } |
---|
1306 | 1272 | |
---|
1307 | | -static int wil_bf_debugfs_show(struct seq_file *s, void *data) |
---|
| 1273 | +static int bf_show(struct seq_file *s, void *data) |
---|
1308 | 1274 | { |
---|
1309 | 1275 | int rc; |
---|
1310 | 1276 | int i; |
---|
.. | .. |
---|
1320 | 1286 | |
---|
1321 | 1287 | memset(&reply, 0, sizeof(reply)); |
---|
1322 | 1288 | |
---|
1323 | | - for (i = 0; i < ARRAY_SIZE(wil->sta); i++) { |
---|
| 1289 | + for (i = 0; i < wil->max_assoc_sta; i++) { |
---|
1324 | 1290 | u32 status; |
---|
1325 | 1291 | |
---|
1326 | 1292 | cmd.cid = i; |
---|
1327 | 1293 | rc = wmi_call(wil, WMI_NOTIFY_REQ_CMDID, vif->mid, |
---|
1328 | 1294 | &cmd, sizeof(cmd), |
---|
1329 | 1295 | WMI_NOTIFY_REQ_DONE_EVENTID, &reply, |
---|
1330 | | - sizeof(reply), 20); |
---|
| 1296 | + sizeof(reply), WIL_WMI_CALL_GENERAL_TO_MS); |
---|
1331 | 1297 | /* if reply is all-0, ignore this CID */ |
---|
1332 | 1298 | if (rc || is_all_zeros(&reply.evt, sizeof(reply.evt))) |
---|
1333 | 1299 | continue; |
---|
.. | .. |
---|
1358 | 1324 | } |
---|
1359 | 1325 | return 0; |
---|
1360 | 1326 | } |
---|
1361 | | - |
---|
1362 | | -static int wil_bf_seq_open(struct inode *inode, struct file *file) |
---|
1363 | | -{ |
---|
1364 | | - return single_open(file, wil_bf_debugfs_show, inode->i_private); |
---|
1365 | | -} |
---|
1366 | | - |
---|
1367 | | -static const struct file_operations fops_bf = { |
---|
1368 | | - .open = wil_bf_seq_open, |
---|
1369 | | - .release = single_release, |
---|
1370 | | - .read = seq_read, |
---|
1371 | | - .llseek = seq_lseek, |
---|
1372 | | -}; |
---|
| 1327 | +DEFINE_SHOW_ATTRIBUTE(bf); |
---|
1373 | 1328 | |
---|
1374 | 1329 | /*---------temp------------*/ |
---|
1375 | 1330 | static void print_temp(struct seq_file *s, const char *prefix, s32 t) |
---|
1376 | 1331 | { |
---|
1377 | 1332 | switch (t) { |
---|
1378 | 1333 | case 0: |
---|
1379 | | - case ~(u32)0: |
---|
| 1334 | + case WMI_INVALID_TEMPERATURE: |
---|
1380 | 1335 | seq_printf(s, "%s N/A\n", prefix); |
---|
1381 | 1336 | break; |
---|
1382 | 1337 | default: |
---|
.. | .. |
---|
1386 | 1341 | } |
---|
1387 | 1342 | } |
---|
1388 | 1343 | |
---|
1389 | | -static int wil_temp_debugfs_show(struct seq_file *s, void *data) |
---|
| 1344 | +static int temp_show(struct seq_file *s, void *data) |
---|
1390 | 1345 | { |
---|
1391 | 1346 | struct wil6210_priv *wil = s->private; |
---|
1392 | | - s32 t_m, t_r; |
---|
1393 | | - int rc = wmi_get_temperature(wil, &t_m, &t_r); |
---|
| 1347 | + int rc, i; |
---|
1394 | 1348 | |
---|
1395 | | - if (rc) { |
---|
1396 | | - seq_puts(s, "Failed\n"); |
---|
1397 | | - return 0; |
---|
| 1349 | + if (test_bit(WMI_FW_CAPABILITY_TEMPERATURE_ALL_RF, |
---|
| 1350 | + wil->fw_capabilities)) { |
---|
| 1351 | + struct wmi_temp_sense_all_done_event sense_all_evt; |
---|
| 1352 | + |
---|
| 1353 | + wil_dbg_misc(wil, |
---|
| 1354 | + "WMI_FW_CAPABILITY_TEMPERATURE_ALL_RF is supported"); |
---|
| 1355 | + rc = wmi_get_all_temperatures(wil, &sense_all_evt); |
---|
| 1356 | + if (rc) { |
---|
| 1357 | + seq_puts(s, "Failed\n"); |
---|
| 1358 | + return 0; |
---|
| 1359 | + } |
---|
| 1360 | + print_temp(s, "T_mac =", |
---|
| 1361 | + le32_to_cpu(sense_all_evt.baseband_t1000)); |
---|
| 1362 | + seq_printf(s, "Connected RFs [0x%08x]\n", |
---|
| 1363 | + sense_all_evt.rf_bitmap); |
---|
| 1364 | + for (i = 0; i < WMI_MAX_XIF_PORTS_NUM; i++) { |
---|
| 1365 | + seq_printf(s, "RF[%d] = ", i); |
---|
| 1366 | + print_temp(s, "", |
---|
| 1367 | + le32_to_cpu(sense_all_evt.rf_t1000[i])); |
---|
| 1368 | + } |
---|
| 1369 | + } else { |
---|
| 1370 | + s32 t_m, t_r; |
---|
| 1371 | + |
---|
| 1372 | + wil_dbg_misc(wil, |
---|
| 1373 | + "WMI_FW_CAPABILITY_TEMPERATURE_ALL_RF is not supported"); |
---|
| 1374 | + rc = wmi_get_temperature(wil, &t_m, &t_r); |
---|
| 1375 | + if (rc) { |
---|
| 1376 | + seq_puts(s, "Failed\n"); |
---|
| 1377 | + return 0; |
---|
| 1378 | + } |
---|
| 1379 | + print_temp(s, "T_mac =", t_m); |
---|
| 1380 | + print_temp(s, "T_radio =", t_r); |
---|
1398 | 1381 | } |
---|
1399 | | - |
---|
1400 | | - print_temp(s, "T_mac =", t_m); |
---|
1401 | | - print_temp(s, "T_radio =", t_r); |
---|
1402 | | - |
---|
1403 | 1382 | return 0; |
---|
1404 | 1383 | } |
---|
1405 | | - |
---|
1406 | | -static int wil_temp_seq_open(struct inode *inode, struct file *file) |
---|
1407 | | -{ |
---|
1408 | | - return single_open(file, wil_temp_debugfs_show, inode->i_private); |
---|
1409 | | -} |
---|
1410 | | - |
---|
1411 | | -static const struct file_operations fops_temp = { |
---|
1412 | | - .open = wil_temp_seq_open, |
---|
1413 | | - .release = single_release, |
---|
1414 | | - .read = seq_read, |
---|
1415 | | - .llseek = seq_lseek, |
---|
1416 | | -}; |
---|
| 1384 | +DEFINE_SHOW_ATTRIBUTE(temp); |
---|
1417 | 1385 | |
---|
1418 | 1386 | /*---------freq------------*/ |
---|
1419 | | -static int wil_freq_debugfs_show(struct seq_file *s, void *data) |
---|
| 1387 | +static int freq_show(struct seq_file *s, void *data) |
---|
1420 | 1388 | { |
---|
1421 | 1389 | struct wil6210_priv *wil = s->private; |
---|
1422 | 1390 | struct wireless_dev *wdev = wil->main_ndev->ieee80211_ptr; |
---|
1423 | | - u16 freq = wdev->chandef.chan ? wdev->chandef.chan->center_freq : 0; |
---|
| 1391 | + u32 freq = wdev->chandef.chan ? wdev->chandef.chan->center_freq : 0; |
---|
1424 | 1392 | |
---|
1425 | 1393 | seq_printf(s, "Freq = %d\n", freq); |
---|
1426 | 1394 | |
---|
1427 | 1395 | return 0; |
---|
1428 | 1396 | } |
---|
1429 | | - |
---|
1430 | | -static int wil_freq_seq_open(struct inode *inode, struct file *file) |
---|
1431 | | -{ |
---|
1432 | | - return single_open(file, wil_freq_debugfs_show, inode->i_private); |
---|
1433 | | -} |
---|
1434 | | - |
---|
1435 | | -static const struct file_operations fops_freq = { |
---|
1436 | | - .open = wil_freq_seq_open, |
---|
1437 | | - .release = single_release, |
---|
1438 | | - .read = seq_read, |
---|
1439 | | - .llseek = seq_lseek, |
---|
1440 | | -}; |
---|
| 1397 | +DEFINE_SHOW_ATTRIBUTE(freq); |
---|
1441 | 1398 | |
---|
1442 | 1399 | /*---------link------------*/ |
---|
1443 | | -static int wil_link_debugfs_show(struct seq_file *s, void *data) |
---|
| 1400 | +static int link_show(struct seq_file *s, void *data) |
---|
1444 | 1401 | { |
---|
1445 | 1402 | struct wil6210_priv *wil = s->private; |
---|
1446 | 1403 | struct station_info *sinfo; |
---|
.. | .. |
---|
1450 | 1407 | if (!sinfo) |
---|
1451 | 1408 | return -ENOMEM; |
---|
1452 | 1409 | |
---|
1453 | | - for (i = 0; i < ARRAY_SIZE(wil->sta); i++) { |
---|
| 1410 | + for (i = 0; i < wil->max_assoc_sta; i++) { |
---|
1454 | 1411 | struct wil_sta_info *p = &wil->sta[i]; |
---|
1455 | 1412 | char *status = "unknown"; |
---|
1456 | 1413 | struct wil6210_vif *vif; |
---|
.. | .. |
---|
1474 | 1431 | if (p->status != wil_sta_connected) |
---|
1475 | 1432 | continue; |
---|
1476 | 1433 | |
---|
1477 | | - vif = (mid < wil->max_vifs) ? wil->vifs[mid] : NULL; |
---|
| 1434 | + vif = (mid < GET_MAX_VIFS(wil)) ? wil->vifs[mid] : NULL; |
---|
1478 | 1435 | if (vif) { |
---|
1479 | 1436 | rc = wil_cid_fill_sinfo(vif, i, sinfo); |
---|
1480 | 1437 | if (rc) |
---|
.. | .. |
---|
1492 | 1449 | kfree(sinfo); |
---|
1493 | 1450 | return rc; |
---|
1494 | 1451 | } |
---|
1495 | | - |
---|
1496 | | -static int wil_link_seq_open(struct inode *inode, struct file *file) |
---|
1497 | | -{ |
---|
1498 | | - return single_open(file, wil_link_debugfs_show, inode->i_private); |
---|
1499 | | -} |
---|
1500 | | - |
---|
1501 | | -static const struct file_operations fops_link = { |
---|
1502 | | - .open = wil_link_seq_open, |
---|
1503 | | - .release = single_release, |
---|
1504 | | - .read = seq_read, |
---|
1505 | | - .llseek = seq_lseek, |
---|
1506 | | -}; |
---|
| 1452 | +DEFINE_SHOW_ATTRIBUTE(link); |
---|
1507 | 1453 | |
---|
1508 | 1454 | /*---------info------------*/ |
---|
1509 | | -static int wil_info_debugfs_show(struct seq_file *s, void *data) |
---|
| 1455 | +static int info_show(struct seq_file *s, void *data) |
---|
1510 | 1456 | { |
---|
1511 | 1457 | struct wil6210_priv *wil = s->private; |
---|
1512 | 1458 | struct net_device *ndev = wil->main_ndev; |
---|
.. | .. |
---|
1541 | 1487 | #undef CHECK_QSTATE |
---|
1542 | 1488 | return 0; |
---|
1543 | 1489 | } |
---|
1544 | | - |
---|
1545 | | -static int wil_info_seq_open(struct inode *inode, struct file *file) |
---|
1546 | | -{ |
---|
1547 | | - return single_open(file, wil_info_debugfs_show, inode->i_private); |
---|
1548 | | -} |
---|
1549 | | - |
---|
1550 | | -static const struct file_operations fops_info = { |
---|
1551 | | - .open = wil_info_seq_open, |
---|
1552 | | - .release = single_release, |
---|
1553 | | - .read = seq_read, |
---|
1554 | | - .llseek = seq_lseek, |
---|
1555 | | -}; |
---|
| 1490 | +DEFINE_SHOW_ATTRIBUTE(info); |
---|
1556 | 1491 | |
---|
1557 | 1492 | /*---------recovery------------*/ |
---|
1558 | 1493 | /* mode = [manual|auto] |
---|
.. | .. |
---|
1668 | 1603 | seq_puts(s, "\n"); |
---|
1669 | 1604 | } |
---|
1670 | 1605 | |
---|
1671 | | -static int wil_sta_debugfs_show(struct seq_file *s, void *data) |
---|
| 1606 | +static int sta_show(struct seq_file *s, void *data) |
---|
1672 | 1607 | __acquires(&p->tid_rx_lock) __releases(&p->tid_rx_lock) |
---|
1673 | 1608 | { |
---|
1674 | 1609 | struct wil6210_priv *wil = s->private; |
---|
1675 | 1610 | int i, tid, mcs; |
---|
1676 | 1611 | |
---|
1677 | | - for (i = 0; i < ARRAY_SIZE(wil->sta); i++) { |
---|
| 1612 | + for (i = 0; i < wil->max_assoc_sta; i++) { |
---|
1678 | 1613 | struct wil_sta_info *p = &wil->sta[i]; |
---|
1679 | 1614 | char *status = "unknown"; |
---|
1680 | 1615 | u8 aid = 0; |
---|
1681 | 1616 | u8 mid; |
---|
| 1617 | + bool sta_connected = false; |
---|
1682 | 1618 | |
---|
1683 | 1619 | switch (p->status) { |
---|
1684 | 1620 | case wil_sta_unused: |
---|
.. | .. |
---|
1693 | 1629 | break; |
---|
1694 | 1630 | } |
---|
1695 | 1631 | mid = (p->status != wil_sta_unused) ? p->mid : U8_MAX; |
---|
1696 | | - seq_printf(s, "[%d] %pM %s MID %d AID %d\n", i, p->addr, status, |
---|
1697 | | - mid, aid); |
---|
| 1632 | + if (mid < GET_MAX_VIFS(wil)) { |
---|
| 1633 | + struct wil6210_vif *vif = wil->vifs[mid]; |
---|
| 1634 | + |
---|
| 1635 | + if (vif->wdev.iftype == NL80211_IFTYPE_STATION && |
---|
| 1636 | + p->status == wil_sta_connected) |
---|
| 1637 | + sta_connected = true; |
---|
| 1638 | + } |
---|
| 1639 | + /* print roam counter only for connected stations */ |
---|
| 1640 | + if (sta_connected) |
---|
| 1641 | + seq_printf(s, "[%d] %pM connected (roam counter %d) MID %d AID %d\n", |
---|
| 1642 | + i, p->addr, p->stats.ft_roams, mid, aid); |
---|
| 1643 | + else |
---|
| 1644 | + seq_printf(s, "[%d] %pM %s MID %d AID %d\n", i, |
---|
| 1645 | + p->addr, status, mid, aid); |
---|
1698 | 1646 | |
---|
1699 | 1647 | if (p->status == wil_sta_connected) { |
---|
1700 | 1648 | spin_lock_bh(&p->tid_rx_lock); |
---|
.. | .. |
---|
1737 | 1685 | |
---|
1738 | 1686 | return 0; |
---|
1739 | 1687 | } |
---|
| 1688 | +DEFINE_SHOW_ATTRIBUTE(sta); |
---|
1740 | 1689 | |
---|
1741 | | -static int wil_sta_seq_open(struct inode *inode, struct file *file) |
---|
1742 | | -{ |
---|
1743 | | - return single_open(file, wil_sta_debugfs_show, inode->i_private); |
---|
1744 | | -} |
---|
1745 | | - |
---|
1746 | | -static const struct file_operations fops_sta = { |
---|
1747 | | - .open = wil_sta_seq_open, |
---|
1748 | | - .release = single_release, |
---|
1749 | | - .read = seq_read, |
---|
1750 | | - .llseek = seq_lseek, |
---|
1751 | | -}; |
---|
1752 | | - |
---|
1753 | | -static int wil_mids_debugfs_show(struct seq_file *s, void *data) |
---|
| 1690 | +static int mids_show(struct seq_file *s, void *data) |
---|
1754 | 1691 | { |
---|
1755 | 1692 | struct wil6210_priv *wil = s->private; |
---|
1756 | 1693 | struct wil6210_vif *vif; |
---|
.. | .. |
---|
1758 | 1695 | int i; |
---|
1759 | 1696 | |
---|
1760 | 1697 | mutex_lock(&wil->vif_mutex); |
---|
1761 | | - for (i = 0; i < wil->max_vifs; i++) { |
---|
| 1698 | + for (i = 0; i < GET_MAX_VIFS(wil); i++) { |
---|
1762 | 1699 | vif = wil->vifs[i]; |
---|
1763 | 1700 | |
---|
1764 | 1701 | if (vif) { |
---|
.. | .. |
---|
1773 | 1710 | |
---|
1774 | 1711 | return 0; |
---|
1775 | 1712 | } |
---|
1776 | | - |
---|
1777 | | -static int wil_mids_seq_open(struct inode *inode, struct file *file) |
---|
1778 | | -{ |
---|
1779 | | - return single_open(file, wil_mids_debugfs_show, inode->i_private); |
---|
1780 | | -} |
---|
1781 | | - |
---|
1782 | | -static const struct file_operations fops_mids = { |
---|
1783 | | - .open = wil_mids_seq_open, |
---|
1784 | | - .release = single_release, |
---|
1785 | | - .read = seq_read, |
---|
1786 | | - .llseek = seq_lseek, |
---|
1787 | | -}; |
---|
| 1713 | +DEFINE_SHOW_ATTRIBUTE(mids); |
---|
1788 | 1714 | |
---|
1789 | 1715 | static int wil_tx_latency_debugfs_show(struct seq_file *s, void *data) |
---|
1790 | 1716 | __acquires(&p->tid_rx_lock) __releases(&p->tid_rx_lock) |
---|
.. | .. |
---|
1792 | 1718 | struct wil6210_priv *wil = s->private; |
---|
1793 | 1719 | int i, bin; |
---|
1794 | 1720 | |
---|
1795 | | - for (i = 0; i < ARRAY_SIZE(wil->sta); i++) { |
---|
| 1721 | + for (i = 0; i < wil->max_assoc_sta; i++) { |
---|
1796 | 1722 | struct wil_sta_info *p = &wil->sta[i]; |
---|
1797 | 1723 | char *status = "unknown"; |
---|
1798 | 1724 | u8 aid = 0; |
---|
.. | .. |
---|
1881 | 1807 | size_t sz = sizeof(u64) * WIL_NUM_LATENCY_BINS; |
---|
1882 | 1808 | |
---|
1883 | 1809 | wil->tx_latency_res = val; |
---|
1884 | | - for (i = 0; i < ARRAY_SIZE(wil->sta); i++) { |
---|
| 1810 | + for (i = 0; i < wil->max_assoc_sta; i++) { |
---|
1885 | 1811 | struct wil_sta_info *sta = &wil->sta[i]; |
---|
1886 | 1812 | |
---|
1887 | 1813 | kfree(sta->tx_latency_bins); |
---|
.. | .. |
---|
1966 | 1892 | } |
---|
1967 | 1893 | |
---|
1968 | 1894 | seq_printf(s, "TSF %lld\n", vif->fw_stats_tsf); |
---|
1969 | | - for (i = 0; i < ARRAY_SIZE(wil->sta); i++) { |
---|
| 1895 | + for (i = 0; i < wil->max_assoc_sta; i++) { |
---|
1970 | 1896 | if (wil->sta[i].status == wil_sta_unused) |
---|
1971 | 1897 | continue; |
---|
1972 | 1898 | if (wil->sta[i].mid != vif->mid) |
---|
.. | .. |
---|
1990 | 1916 | /* iterate over all MIDs and show per-cid statistics. Then show the |
---|
1991 | 1917 | * global statistics |
---|
1992 | 1918 | */ |
---|
1993 | | - for (i = 0; i < wil->max_vifs; i++) { |
---|
| 1919 | + for (i = 0; i < GET_MAX_VIFS(wil); i++) { |
---|
1994 | 1920 | vif = wil->vifs[i]; |
---|
1995 | 1921 | |
---|
1996 | 1922 | seq_printf(s, "MID %d ", i); |
---|
.. | .. |
---|
2046 | 1972 | if (rc) |
---|
2047 | 1973 | return rc; |
---|
2048 | 1974 | |
---|
2049 | | - for (i = 0; i < wil->max_vifs; i++) { |
---|
| 1975 | + for (i = 0; i < GET_MAX_VIFS(wil); i++) { |
---|
2050 | 1976 | vif = wil->vifs[i]; |
---|
2051 | 1977 | if (!vif) |
---|
2052 | 1978 | continue; |
---|
.. | .. |
---|
2428 | 2354 | umode_t mode; |
---|
2429 | 2355 | const struct file_operations *fops; |
---|
2430 | 2356 | } dbg_files[] = { |
---|
2431 | | - {"mbox", 0444, &fops_mbox}, |
---|
2432 | | - {"rings", 0444, &fops_ring}, |
---|
2433 | | - {"stations", 0444, &fops_sta}, |
---|
2434 | | - {"mids", 0444, &fops_mids}, |
---|
2435 | | - {"desc", 0444, &fops_txdesc}, |
---|
2436 | | - {"bf", 0444, &fops_bf}, |
---|
2437 | | - {"mem_val", 0644, &fops_memread}, |
---|
| 2357 | + {"mbox", 0444, &mbox_fops}, |
---|
| 2358 | + {"rings", 0444, &ring_fops}, |
---|
| 2359 | + {"stations", 0444, &sta_fops}, |
---|
| 2360 | + {"mids", 0444, &mids_fops}, |
---|
| 2361 | + {"desc", 0444, &txdesc_fops}, |
---|
| 2362 | + {"bf", 0444, &bf_fops}, |
---|
| 2363 | + {"mem_val", 0644, &memread_fops}, |
---|
2438 | 2364 | {"rxon", 0244, &fops_rxon}, |
---|
2439 | 2365 | {"tx_mgmt", 0244, &fops_txmgmt}, |
---|
2440 | 2366 | {"wmi_send", 0244, &fops_wmi}, |
---|
2441 | 2367 | {"back", 0644, &fops_back}, |
---|
2442 | 2368 | {"pmccfg", 0644, &fops_pmccfg}, |
---|
2443 | 2369 | {"pmcdata", 0444, &fops_pmcdata}, |
---|
2444 | | - {"temp", 0444, &fops_temp}, |
---|
2445 | | - {"freq", 0444, &fops_freq}, |
---|
2446 | | - {"link", 0444, &fops_link}, |
---|
2447 | | - {"info", 0444, &fops_info}, |
---|
| 2370 | + {"pmcring", 0444, &fops_pmcring}, |
---|
| 2371 | + {"temp", 0444, &temp_fops}, |
---|
| 2372 | + {"freq", 0444, &freq_fops}, |
---|
| 2373 | + {"link", 0444, &link_fops}, |
---|
| 2374 | + {"info", 0444, &info_fops}, |
---|
2448 | 2375 | {"recovery", 0644, &fops_recovery}, |
---|
2449 | 2376 | {"led_cfg", 0644, &fops_led_cfg}, |
---|
2450 | 2377 | {"led_blink_time", 0644, &fops_led_blink_time}, |
---|
.. | .. |
---|
2452 | 2379 | {"fw_version", 0444, &fops_fw_version}, |
---|
2453 | 2380 | {"suspend_stats", 0644, &fops_suspend_stats}, |
---|
2454 | 2381 | {"compressed_rx_status", 0644, &fops_compressed_rx_status}, |
---|
2455 | | - {"srings", 0444, &fops_srings}, |
---|
2456 | | - {"status_msg", 0444, &fops_status_msg}, |
---|
2457 | | - {"rx_buff_mgmt", 0444, &fops_rx_buff_mgmt}, |
---|
| 2382 | + {"srings", 0444, &srings_fops}, |
---|
| 2383 | + {"status_msg", 0444, &status_msg_fops}, |
---|
| 2384 | + {"rx_buff_mgmt", 0444, &rx_buff_mgmt_fops}, |
---|
2458 | 2385 | {"tx_latency", 0644, &fops_tx_latency}, |
---|
2459 | 2386 | {"link_stats", 0644, &fops_link_stats}, |
---|
2460 | 2387 | {"link_stats_global", 0644, &fops_link_stats_global}, |
---|
| 2388 | + {"rbufcap", 0244, &fops_rbufcap}, |
---|
2461 | 2389 | }; |
---|
2462 | 2390 | |
---|
2463 | 2391 | static void wil6210_debugfs_init_files(struct wil6210_priv *wil, |
---|
.. | .. |
---|
2516 | 2444 | {"RGF_MAC_MTRL_COUNTER_0", 0444, HOSTADDR(RGF_MAC_MTRL_COUNTER_0), |
---|
2517 | 2445 | doff_io32}, |
---|
2518 | 2446 | {"RGF_USER_USAGE_1", 0444, HOSTADDR(RGF_USER_USAGE_1), doff_io32}, |
---|
| 2447 | + {"RGF_USER_USAGE_2", 0444, HOSTADDR(RGF_USER_USAGE_2), doff_io32}, |
---|
2519 | 2448 | {}, |
---|
2520 | 2449 | }; |
---|
2521 | 2450 | |
---|
.. | .. |
---|
2527 | 2456 | {"led_polarity", 0644, (ulong)&led_polarity, doff_u8}, |
---|
2528 | 2457 | {"status_index", 0644, (ulong)&dbg_status_msg_index, doff_u32}, |
---|
2529 | 2458 | {"sring_index", 0644, (ulong)&dbg_sring_index, doff_u32}, |
---|
| 2459 | + {"drop_if_ring_full", 0644, (ulong)&drop_if_ring_full, doff_u8}, |
---|
2530 | 2460 | {}, |
---|
2531 | 2461 | }; |
---|
2532 | 2462 | |
---|
.. | .. |
---|
2580 | 2510 | wil->debug = NULL; |
---|
2581 | 2511 | |
---|
2582 | 2512 | kfree(wil->dbg_data.data_arr); |
---|
2583 | | - for (i = 0; i < ARRAY_SIZE(wil->sta); i++) |
---|
| 2513 | + for (i = 0; i < wil->max_assoc_sta; i++) |
---|
2584 | 2514 | kfree(wil->sta[i].tx_latency_bins); |
---|
2585 | 2515 | |
---|
2586 | 2516 | /* free pmc memory without sending command to fw, as it will |
---|