linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: greearb@candelatech.com
To: ath11k@lists.infradead.org
Cc: linux-wireless@vger.kernel.org, Ben Greear <greearb@candelatech.com>
Subject: [PATCH 2/2] ath11k:  Add firmware_info file to debugfs
Date: Thu, 27 Aug 2020 16:30:02 -0700	[thread overview]
Message-ID: <20200827233002.21483-2-greearb@candelatech.com> (raw)
In-Reply-To: <20200827233002.21483-1-greearb@candelatech.com>

From: Ben Greear <greearb@candelatech.com>

This shows the fwcfg file name so that users don't have to guess,
as well as some other info about the firmware and radio.

directory: QCA6390/hw2.0
fwcfg:     fwcfg-pci-0000:14:00.0.txt
bus:       0000:14:00.0
version:   0x101c06cc
hw_rev:    6390-hw2
board:     board.bin

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 drivers/net/wireless/ath/ath11k/debug.c | 56 +++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/drivers/net/wireless/ath/ath11k/debug.c b/drivers/net/wireless/ath/ath11k/debug.c
index 2ac0df8aee26..38ffcae67ab5 100644
--- a/drivers/net/wireless/ath/ath11k/debug.c
+++ b/drivers/net/wireless/ath/ath11k/debug.c
@@ -398,6 +398,59 @@ static const struct file_operations fops_pdev_stats = {
 	.llseek = default_llseek,
 };
 
+static ssize_t ath11k_read_fwinfo(struct file *file,
+				  char __user *user_buf,
+				  size_t count, loff_t *ppos)
+{
+	struct ath11k_base *ab = file->private_data;
+	char *buf;
+	unsigned int len = 0, buf_len = 1000;
+	ssize_t ret_cnt;
+
+	buf = kzalloc(buf_len, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+
+	/* TODO:  Locking? */
+
+	len = snprintf(buf, buf_len, "directory: %s\nfwcfg:     fwcfg-%s-%s.txt\nbus:       %s",
+		       ab->hw_params.fw.dir,
+		       ath11k_bus_str(ab->hif.bus), dev_name(ab->dev), dev_name(ab->dev));
+
+	/* Just to be safe */
+	buf[buf_len - 1] = 0;
+	len = strlen(buf);
+
+	len += snprintf(buf + len, buf_len - len, "\nversion:   0x%0x\nhw_rev:    ",
+			ab->qmi.target.fw_version);
+	switch (ab->hw_rev) {
+	case ATH11K_HW_QCA6390_HW11:
+		len += snprintf(buf + len, buf_len - len, "6390-hw1\n");
+		break;
+	case ATH11K_HW_QCA6390_HW20:
+		len += snprintf(buf + len, buf_len - len, "6390-hw2\n");
+		break;
+	case ATH11K_HW_IPQ8074:
+		len += snprintf(buf + len, buf_len - len, "8074\n");
+		break;
+	}
+
+	len += snprintf(buf + len, buf_len - len, "board:     %s\n",
+			ab->fw_board_name);
+
+	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+
+	kfree(buf);
+	return ret_cnt;
+}
+
+static const struct file_operations fops_fwinfo_services = {
+	.read = ath11k_read_fwinfo,
+	.open = simple_open,
+	.owner = THIS_MODULE,
+	.llseek = default_llseek,
+};
+
 static int ath11k_open_vdev_stats(struct inode *inode, struct file *file)
 {
 	struct ath11k *ar = inode->i_private;
@@ -1201,6 +1254,9 @@ int ath11k_debug_register(struct ath11k *ar)
 				    &ar->dfs_block_radar_events);
 	}
 
+	debugfs_create_file("firmware_info", 0400, ar->debug.debugfs_pdev, ab,
+			    &fops_fwinfo_services);
+
 	return 0;
 }
 
-- 
2.26.2


  reply	other threads:[~2020-08-27 23:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-27 23:30 [PATCH 1/2] ath11k: Support reading fwcfg file for driver options greearb
2020-08-27 23:30 ` greearb [this message]
2020-08-28  1:42   ` [PATCH 2/2] ath11k: Add firmware_info file to debugfs kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200827233002.21483-2-greearb@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=ath11k@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).