.. | .. |
---|
| 1 | +// SPDX-License-Identifier: ISC |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2012-2015,2017 Qualcomm Atheros, Inc. |
---|
3 | 4 | * 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. |
---|
16 | 5 | */ |
---|
17 | 6 | |
---|
18 | 7 | #include <linux/types.h> |
---|
19 | 8 | #include <linux/errno.h> |
---|
20 | 9 | #include <linux/fs.h> |
---|
| 10 | +#include <linux/seq_file.h> |
---|
21 | 11 | #include "wmi.h" |
---|
22 | 12 | #include "wil6210.h" |
---|
23 | 13 | #include "txrx.h" |
---|
.. | .. |
---|
39 | 29 | mutex_init(&wil->pmc.lock); |
---|
40 | 30 | } |
---|
41 | 31 | |
---|
42 | | -/** |
---|
43 | | - * Allocate the physical ring (p-ring) and the required |
---|
| 32 | +/* Allocate the physical ring (p-ring) and the required |
---|
44 | 33 | * number of descriptors of required size. |
---|
45 | 34 | * Initialize the descriptors as required by pmc dma. |
---|
46 | 35 | * The descriptors' buffers dwords are initialized to hold |
---|
.. | .. |
---|
231 | 220 | mutex_unlock(&pmc->lock); |
---|
232 | 221 | } |
---|
233 | 222 | |
---|
234 | | -/** |
---|
235 | | - * Traverse the p-ring and release all buffers. |
---|
| 223 | +/* Traverse the p-ring and release all buffers. |
---|
236 | 224 | * At the end release the p-ring memory |
---|
237 | 225 | */ |
---|
238 | 226 | void wil_pmc_free(struct wil6210_priv *wil, int send_pmc_cmd) |
---|
.. | .. |
---|
309 | 297 | mutex_unlock(&pmc->lock); |
---|
310 | 298 | } |
---|
311 | 299 | |
---|
312 | | -/** |
---|
313 | | - * Status of the last operation requested via debugfs: alloc/free/read. |
---|
| 300 | +/* Status of the last operation requested via debugfs: alloc/free/read. |
---|
314 | 301 | * 0 - success or negative errno |
---|
315 | 302 | */ |
---|
316 | 303 | int wil_pmc_last_cmd_status(struct wil6210_priv *wil) |
---|
.. | .. |
---|
321 | 308 | return wil->pmc.last_cmd_status; |
---|
322 | 309 | } |
---|
323 | 310 | |
---|
324 | | -/** |
---|
325 | | - * Read from required position up to the end of current descriptor, |
---|
| 311 | +/* Read from required position up to the end of current descriptor, |
---|
326 | 312 | * depends on descriptor size configured during alloc request. |
---|
327 | 313 | */ |
---|
328 | 314 | ssize_t wil_pmc_read(struct file *filp, char __user *buf, size_t count, |
---|
.. | .. |
---|
431 | 417 | |
---|
432 | 418 | return newpos; |
---|
433 | 419 | } |
---|
| 420 | + |
---|
| 421 | +int wil_pmcring_read(struct seq_file *s, void *data) |
---|
| 422 | +{ |
---|
| 423 | + struct wil6210_priv *wil = s->private; |
---|
| 424 | + struct pmc_ctx *pmc = &wil->pmc; |
---|
| 425 | + size_t pmc_ring_size = |
---|
| 426 | + sizeof(struct vring_rx_desc) * pmc->num_descriptors; |
---|
| 427 | + |
---|
| 428 | + mutex_lock(&pmc->lock); |
---|
| 429 | + |
---|
| 430 | + if (!wil_is_pmc_allocated(pmc)) { |
---|
| 431 | + wil_err(wil, "error, pmc is not allocated!\n"); |
---|
| 432 | + pmc->last_cmd_status = -EPERM; |
---|
| 433 | + mutex_unlock(&pmc->lock); |
---|
| 434 | + return -EPERM; |
---|
| 435 | + } |
---|
| 436 | + |
---|
| 437 | + wil_dbg_misc(wil, "pmcring_read: size %zu\n", pmc_ring_size); |
---|
| 438 | + |
---|
| 439 | + seq_write(s, pmc->pring_va, pmc_ring_size); |
---|
| 440 | + |
---|
| 441 | + mutex_unlock(&pmc->lock); |
---|
| 442 | + |
---|
| 443 | + return 0; |
---|
| 444 | +} |
---|