]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
wil6210: add debugfs to show PMC ring content
authorDedy Lansky <dlansky@codeaurora.org>
Tue, 10 Sep 2019 13:46:24 +0000 (16:46 +0300)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 12 Sep 2019 15:06:32 +0000 (18:06 +0300)
PMC is a hardware debug mechanism which allows capturing real time
debug data and stream it to host memory. The driver allocates memory
buffers and set them inside PMC ring of descriptors.
Add pmcring debugfs that application can use to read the binary
content of descriptors inside the PMC ring (cat pmcring).

Signed-off-by: Dedy Lansky <dlansky@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/wil6210/debugfs.c
drivers/net/wireless/ath/wil6210/pmc.c
drivers/net/wireless/ath/wil6210/pmc.h

index fd3b2b3d1b5c6d5ca802d36e74a7da4645ab6993..50dc30e5bb7985ca3cfa5eae68246e7356bc5cdf 100644 (file)
@@ -959,6 +959,18 @@ static const struct file_operations fops_pmcdata = {
        .llseek         = wil_pmc_llseek,
 };
 
+static int wil_pmcring_seq_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, wil_pmcring_read, inode->i_private);
+}
+
+static const struct file_operations fops_pmcring = {
+       .open           = wil_pmcring_seq_open,
+       .release        = single_release,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+};
+
 /*---tx_mgmt---*/
 /* Write mgmt frame to this file to send it */
 static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
@@ -2371,6 +2383,7 @@ static const struct {
        {"back",        0644,           &fops_back},
        {"pmccfg",      0644,           &fops_pmccfg},
        {"pmcdata",     0444,           &fops_pmcdata},
+       {"pmcring",     0444,           &fops_pmcring},
        {"temp",        0444,           &temp_fops},
        {"freq",        0444,           &freq_fops},
        {"link",        0444,           &link_fops},
index c49f7988369ebaa980bc96529a33154103a8b445..4b7ac14fc2a7ffd2c220cd8aa923387a267533f1 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
+#include <linux/seq_file.h>
 #include "wmi.h"
 #include "wil6210.h"
 #include "txrx.h"
@@ -431,3 +432,28 @@ loff_t wil_pmc_llseek(struct file *filp, loff_t off, int whence)
 
        return newpos;
 }
+
+int wil_pmcring_read(struct seq_file *s, void *data)
+{
+       struct wil6210_priv *wil = s->private;
+       struct pmc_ctx *pmc = &wil->pmc;
+       size_t pmc_ring_size =
+               sizeof(struct vring_rx_desc) * pmc->num_descriptors;
+
+       mutex_lock(&pmc->lock);
+
+       if (!wil_is_pmc_allocated(pmc)) {
+               wil_err(wil, "error, pmc is not allocated!\n");
+               pmc->last_cmd_status = -EPERM;
+               mutex_unlock(&pmc->lock);
+               return -EPERM;
+       }
+
+       wil_dbg_misc(wil, "pmcring_read: size %zu\n", pmc_ring_size);
+
+       seq_write(s, pmc->pring_va, pmc_ring_size);
+
+       mutex_unlock(&pmc->lock);
+
+       return 0;
+}
index bebc8d52e1e610f5f8129aa30ab6f65a13af6483..92b8c4d84a6af653a2e4e5e5efcbb92ee1df6c28 100644 (file)
@@ -25,3 +25,4 @@ void wil_pmc_free(struct wil6210_priv *wil, int send_pmc_cmd);
 int wil_pmc_last_cmd_status(struct wil6210_priv *wil);
 ssize_t wil_pmc_read(struct file *, char __user *, size_t, loff_t *);
 loff_t wil_pmc_llseek(struct file *filp, loff_t off, int whence);
+int wil_pmcring_read(struct seq_file *s, void *data);