hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/net/wireless/ath/wil6210/pmc.c
....@@ -1,23 +1,13 @@
1
+// SPDX-License-Identifier: ISC
12 /*
23 * Copyright (c) 2012-2015,2017 Qualcomm Atheros, Inc.
34 * 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.
165 */
176
187 #include <linux/types.h>
198 #include <linux/errno.h>
209 #include <linux/fs.h>
10
+#include <linux/seq_file.h>
2111 #include "wmi.h"
2212 #include "wil6210.h"
2313 #include "txrx.h"
....@@ -39,8 +29,7 @@
3929 mutex_init(&wil->pmc.lock);
4030 }
4131
42
-/**
43
- * Allocate the physical ring (p-ring) and the required
32
+/* Allocate the physical ring (p-ring) and the required
4433 * number of descriptors of required size.
4534 * Initialize the descriptors as required by pmc dma.
4635 * The descriptors' buffers dwords are initialized to hold
....@@ -231,8 +220,7 @@
231220 mutex_unlock(&pmc->lock);
232221 }
233222
234
-/**
235
- * Traverse the p-ring and release all buffers.
223
+/* Traverse the p-ring and release all buffers.
236224 * At the end release the p-ring memory
237225 */
238226 void wil_pmc_free(struct wil6210_priv *wil, int send_pmc_cmd)
....@@ -309,8 +297,7 @@
309297 mutex_unlock(&pmc->lock);
310298 }
311299
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.
314301 * 0 - success or negative errno
315302 */
316303 int wil_pmc_last_cmd_status(struct wil6210_priv *wil)
....@@ -321,8 +308,7 @@
321308 return wil->pmc.last_cmd_status;
322309 }
323310
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,
326312 * depends on descriptor size configured during alloc request.
327313 */
328314 ssize_t wil_pmc_read(struct file *filp, char __user *buf, size_t count,
....@@ -431,3 +417,28 @@
431417
432418 return newpos;
433419 }
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
+}