debugfs.c (b3e5ced63e051e8f911b795ac5b06229a5328f7b) debugfs.c (dc16427bbe65aeec416f490df73cdeeef5ab62c0)
1/*
2 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES

--- 10 unchanged lines hidden (view full) ---

19#include <linux/seq_file.h>
20#include <linux/pci.h>
21#include <linux/rtnetlink.h>
22#include <linux/power_supply.h>
23
24#include "wil6210.h"
25#include "wmi.h"
26#include "txrx.h"
1/*
2 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES

--- 10 unchanged lines hidden (view full) ---

19#include <linux/seq_file.h>
20#include <linux/pci.h>
21#include <linux/rtnetlink.h>
22#include <linux/power_supply.h>
23
24#include "wil6210.h"
25#include "wmi.h"
26#include "txrx.h"
27#include "pmc.h"
27
28/* Nasty hack. Better have per device instances */
29static u32 mem_addr;
30static u32 dbg_txdesc_index;
31static u32 dbg_vring_index; /* 24+ for Rx, 0..23 for Tx */
32u32 vring_idle_trsh = 16; /* HW fetches up to 16 descriptors at once */
33
34enum dbg_off_type {

--- 662 unchanged lines hidden (view full) ---

697}
698
699static const struct file_operations fops_back = {
700 .read = wil_read_back,
701 .write = wil_write_back,
702 .open = simple_open,
703};
704
28
29/* Nasty hack. Better have per device instances */
30static u32 mem_addr;
31static u32 dbg_txdesc_index;
32static u32 dbg_vring_index; /* 24+ for Rx, 0..23 for Tx */
33u32 vring_idle_trsh = 16; /* HW fetches up to 16 descriptors at once */
34
35enum dbg_off_type {

--- 662 unchanged lines hidden (view full) ---

698}
699
700static const struct file_operations fops_back = {
701 .read = wil_read_back,
702 .write = wil_write_back,
703 .open = simple_open,
704};
705
706/* pmc control, write:
707 * - "alloc <num descriptors> <descriptor_size>" to allocate PMC
708 * - "free" to release memory allocated for PMC
709 */
710static ssize_t wil_write_pmccfg(struct file *file, const char __user *buf,
711 size_t len, loff_t *ppos)
712{
713 struct wil6210_priv *wil = file->private_data;
714 int rc;
715 char *kbuf = kmalloc(len + 1, GFP_KERNEL);
716 char cmd[9];
717 int num_descs, desc_size;
718
719 if (!kbuf)
720 return -ENOMEM;
721
722 rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
723 if (rc != len) {
724 kfree(kbuf);
725 return rc >= 0 ? -EIO : rc;
726 }
727
728 kbuf[len] = '\0';
729 rc = sscanf(kbuf, "%8s %d %d", cmd, &num_descs, &desc_size);
730 kfree(kbuf);
731
732 if (rc < 0)
733 return rc;
734
735 if (rc < 1) {
736 wil_err(wil, "pmccfg: no params given\n");
737 return -EINVAL;
738 }
739
740 if (0 == strcmp(cmd, "alloc")) {
741 if (rc != 3) {
742 wil_err(wil, "pmccfg: alloc requires 2 params\n");
743 return -EINVAL;
744 }
745 wil_pmc_alloc(wil, num_descs, desc_size);
746 } else if (0 == strcmp(cmd, "free")) {
747 if (rc != 1) {
748 wil_err(wil, "pmccfg: free does not have any params\n");
749 return -EINVAL;
750 }
751 wil_pmc_free(wil, true);
752 } else {
753 wil_err(wil, "pmccfg: Unrecognized command \"%s\"\n", cmd);
754 return -EINVAL;
755 }
756
757 return len;
758}
759
760static ssize_t wil_read_pmccfg(struct file *file, char __user *user_buf,
761 size_t count, loff_t *ppos)
762{
763 struct wil6210_priv *wil = file->private_data;
764 char text[256];
765 char help[] = "pmc control, write:\n"
766 " - \"alloc <num descriptors> <descriptor_size>\" to allocate pmc\n"
767 " - \"free\" to free memory allocated for pmc\n";
768
769 sprintf(text, "Last command status: %d\n\n%s",
770 wil_pmc_last_cmd_status(wil),
771 help);
772
773 return simple_read_from_buffer(user_buf, count, ppos, text,
774 strlen(text) + 1);
775}
776
777static const struct file_operations fops_pmccfg = {
778 .read = wil_read_pmccfg,
779 .write = wil_write_pmccfg,
780 .open = simple_open,
781};
782
783static const struct file_operations fops_pmcdata = {
784 .open = simple_open,
785 .read = wil_pmc_read,
786 .llseek = wil_pmc_llseek,
787};
788
705/*---tx_mgmt---*/
706/* Write mgmt frame to this file to send it */
707static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
708 size_t len, loff_t *ppos)
709{
710 struct wil6210_priv *wil = file->private_data;
711 struct wiphy *wiphy = wil_to_wiphy(wil);
712 struct wireless_dev *wdev = wil_to_wdev(wil);

--- 645 unchanged lines hidden (view full) ---

1358 {"bf", S_IRUGO, &fops_bf},
1359 {"ssid", S_IRUGO | S_IWUSR, &fops_ssid},
1360 {"mem_val", S_IRUGO, &fops_memread},
1361 {"reset", S_IWUSR, &fops_reset},
1362 {"rxon", S_IWUSR, &fops_rxon},
1363 {"tx_mgmt", S_IWUSR, &fops_txmgmt},
1364 {"wmi_send", S_IWUSR, &fops_wmi},
1365 {"back", S_IRUGO | S_IWUSR, &fops_back},
789/*---tx_mgmt---*/
790/* Write mgmt frame to this file to send it */
791static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
792 size_t len, loff_t *ppos)
793{
794 struct wil6210_priv *wil = file->private_data;
795 struct wiphy *wiphy = wil_to_wiphy(wil);
796 struct wireless_dev *wdev = wil_to_wdev(wil);

--- 645 unchanged lines hidden (view full) ---

1442 {"bf", S_IRUGO, &fops_bf},
1443 {"ssid", S_IRUGO | S_IWUSR, &fops_ssid},
1444 {"mem_val", S_IRUGO, &fops_memread},
1445 {"reset", S_IWUSR, &fops_reset},
1446 {"rxon", S_IWUSR, &fops_rxon},
1447 {"tx_mgmt", S_IWUSR, &fops_txmgmt},
1448 {"wmi_send", S_IWUSR, &fops_wmi},
1449 {"back", S_IRUGO | S_IWUSR, &fops_back},
1450 {"pmccfg", S_IRUGO | S_IWUSR, &fops_pmccfg},
1451 {"pmcdata", S_IRUGO, &fops_pmcdata},
1366 {"temp", S_IRUGO, &fops_temp},
1367 {"freq", S_IRUGO, &fops_freq},
1368 {"link", S_IRUGO, &fops_link},
1369 {"info", S_IRUGO, &fops_info},
1370 {"recovery", S_IRUGO | S_IWUSR, &fops_recovery},
1371};
1372
1373static void wil6210_debugfs_init_files(struct wil6210_priv *wil,

--- 61 unchanged lines hidden (view full) ---

1435int wil6210_debugfs_init(struct wil6210_priv *wil)
1436{
1437 struct dentry *dbg = wil->debug = debugfs_create_dir(WIL_NAME,
1438 wil_to_wiphy(wil)->debugfsdir);
1439
1440 if (IS_ERR_OR_NULL(dbg))
1441 return -ENODEV;
1442
1452 {"temp", S_IRUGO, &fops_temp},
1453 {"freq", S_IRUGO, &fops_freq},
1454 {"link", S_IRUGO, &fops_link},
1455 {"info", S_IRUGO, &fops_info},
1456 {"recovery", S_IRUGO | S_IWUSR, &fops_recovery},
1457};
1458
1459static void wil6210_debugfs_init_files(struct wil6210_priv *wil,

--- 61 unchanged lines hidden (view full) ---

1521int wil6210_debugfs_init(struct wil6210_priv *wil)
1522{
1523 struct dentry *dbg = wil->debug = debugfs_create_dir(WIL_NAME,
1524 wil_to_wiphy(wil)->debugfsdir);
1525
1526 if (IS_ERR_OR_NULL(dbg))
1527 return -ENODEV;
1528
1529 wil_pmc_init(wil);
1530
1443 wil6210_debugfs_init_files(wil, dbg);
1444 wil6210_debugfs_init_isr(wil, dbg);
1445 wil6210_debugfs_init_blobs(wil, dbg);
1446 wil6210_debugfs_init_offset(wil, dbg, wil, dbg_wil_off);
1447 wil6210_debugfs_init_offset(wil, dbg, (void * __force)wil->csr,
1448 dbg_wil_regs);
1449 wil6210_debugfs_init_offset(wil, dbg, NULL, dbg_statics);
1450
1451 wil6210_debugfs_create_pseudo_ISR(wil, dbg);
1452
1453 wil6210_debugfs_create_ITR_CNT(wil, dbg);
1454
1455 return 0;
1456}
1457
1458void wil6210_debugfs_remove(struct wil6210_priv *wil)
1459{
1460 debugfs_remove_recursive(wil->debug);
1461 wil->debug = NULL;
1531 wil6210_debugfs_init_files(wil, dbg);
1532 wil6210_debugfs_init_isr(wil, dbg);
1533 wil6210_debugfs_init_blobs(wil, dbg);
1534 wil6210_debugfs_init_offset(wil, dbg, wil, dbg_wil_off);
1535 wil6210_debugfs_init_offset(wil, dbg, (void * __force)wil->csr,
1536 dbg_wil_regs);
1537 wil6210_debugfs_init_offset(wil, dbg, NULL, dbg_statics);
1538
1539 wil6210_debugfs_create_pseudo_ISR(wil, dbg);
1540
1541 wil6210_debugfs_create_ITR_CNT(wil, dbg);
1542
1543 return 0;
1544}
1545
1546void wil6210_debugfs_remove(struct wil6210_priv *wil)
1547{
1548 debugfs_remove_recursive(wil->debug);
1549 wil->debug = NULL;
1550
1551 /* free pmc memory without sending command to fw, as it will
1552 * be reset on the way down anyway
1553 */
1554 wil_pmc_free(wil, false);
1462}
1555}