Skip to content

Commit 3c5b13e

Browse files
committed
Add /sys/kernel/debug/ieee80211/phyX/mwlwifi/txpwrlmt_file
This presents the same data as mwlwifi/txpwrlmt but it is formatted as hex for consumption as the firmware file mwlwifi/txpwrlmt_cfg.conf. With this you can: 1. Save the current eeprom stored values when mwlwifi/txpwrlmt_cfg.conf is not present for manual editing (to lower values). 2. Compare (diff) against mwlwifi/txpwrlmt_cfg.conf (when it is present) to confirm that it is properly processed.
1 parent eab22c2 commit 3c5b13e

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

debugfs.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,68 @@ static ssize_t mwl_debugfs_txpwrlmt_read(struct file *file,
761761
priv->txpwrlmt_data.len);
762762
}
763763

764+
static ssize_t mwl_debugfs_txpwrlmt_file_read(struct file *file,
765+
char __user *ubuf,
766+
size_t count, loff_t *ppos)
767+
{
768+
struct mwl_priv *priv = (struct mwl_priv *)file->private_data;
769+
770+
// The binary bytes take 2 chars and one space/nl plus some
771+
// for the header.
772+
int size = (SYSADPT_TXPWRLMT_CFG_BUF_SIZE * 3)+40;
773+
char *buf = kmalloc(size, GFP_KERNEL);
774+
char *p = buf;
775+
int len = 0;
776+
int remain = priv->txpwrlmt_data.len;
777+
const char *tblp = priv->txpwrlmt_data.buf;
778+
ssize_t ret = 0;
779+
780+
if (!p)
781+
return -ENOMEM;
782+
783+
len += scnprintf(p + len, size - len, "01 0E 24 A1\n");
784+
len += scnprintf(p + len, size - len, "00 00 00 00\n");
785+
786+
while (remain > sizeof(struct mwl_txpwrlmt_cfg_entry_hdr)) {
787+
struct mwl_txpwrlmt_cfg_entry_hdr* subband_hdr =
788+
(struct mwl_txpwrlmt_cfg_entry_hdr*)tblp;
789+
__le16 subband_len = le16_to_cpu(subband_hdr->len);
790+
len += scnprintf(p + len, size - len, "\n%*ph\n",
791+
sizeof(struct mwl_txpwrlmt_cfg_entry_hdr),
792+
tblp);
793+
tblp += sizeof(struct mwl_txpwrlmt_cfg_entry_hdr);
794+
remain -= sizeof(struct mwl_txpwrlmt_cfg_entry_hdr);
795+
796+
// TODO(nhed): maybe add more sanity checks?
797+
while (subband_len > 0) {
798+
__le16 hexd_line_cnt = min(subband_len, (__le16)32);
799+
len += scnprintf(p + len, size - len, "%*ph\n",
800+
hexd_line_cnt, tblp);
801+
tblp += hexd_line_cnt;
802+
remain -= hexd_line_cnt;
803+
subband_len -= hexd_line_cnt;
804+
}
805+
806+
// Not sure why `\n` delimiters are added between subbands
807+
// into the binary data buffer txpwrlmt_data.buf by
808+
// mwl_fwcmd_get_txpwrlmt_cfg_data() but since we need to skip
809+
// them we may as well test for them.
810+
if (*tblp != '\n') {
811+
printk("Unexpected lack of subband delimiter(s)\n");
812+
kfree(buf);
813+
return EIO;
814+
}
815+
tblp++;
816+
remain--;
817+
}
818+
len += scnprintf(p + len, size - len, "\n");
819+
820+
ret = simple_read_from_buffer(ubuf, count, ppos, p, len);
821+
kfree(buf);
822+
823+
return ret;
824+
}
825+
764826
static ssize_t mwl_debugfs_tx_amsdu_read(struct file *file,
765827
char __user *ubuf,
766828
size_t count, loff_t *ppos)
@@ -2139,6 +2201,7 @@ MWLWIFI_DEBUGFS_FILE_READ_OPS(ampdu);
21392201
MWLWIFI_DEBUGFS_FILE_READ_OPS(stnid);
21402202
MWLWIFI_DEBUGFS_FILE_READ_OPS(device_pwrtbl);
21412203
MWLWIFI_DEBUGFS_FILE_READ_OPS(txpwrlmt);
2204+
MWLWIFI_DEBUGFS_FILE_READ_OPS(txpwrlmt_file);
21422205
MWLWIFI_DEBUGFS_FILE_OPS(tx_amsdu);
21432206
MWLWIFI_DEBUGFS_FILE_OPS(dump_hostcmd);
21442207
MWLWIFI_DEBUGFS_FILE_OPS(dump_probe);
@@ -2177,6 +2240,7 @@ void mwl_debugfs_init(struct ieee80211_hw *hw)
21772240
MWLWIFI_DEBUGFS_ADD_FILE(stnid);
21782241
MWLWIFI_DEBUGFS_ADD_FILE(device_pwrtbl);
21792242
MWLWIFI_DEBUGFS_ADD_FILE(txpwrlmt);
2243+
MWLWIFI_DEBUGFS_ADD_FILE(txpwrlmt_file);
21802244
MWLWIFI_DEBUGFS_ADD_FILE(tx_amsdu);
21812245
MWLWIFI_DEBUGFS_ADD_FILE(dump_hostcmd);
21822246
MWLWIFI_DEBUGFS_ADD_FILE(dump_probe);

0 commit comments

Comments
 (0)