Skip to content

Commit 2cbc0c2

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 0474b2f commit 2cbc0c2

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

debugfs.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,76 @@ 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+
const u32 txpwr_cfg_sig = cpu_to_le32(TXPWRLMT_CFG_SIGNATURE);
771+
const u32 txpwr_cfg_ver = 0;
772+
// The binary bytes take 2 chars and one space/nl plus some
773+
// for the header.
774+
int size = (SYSADPT_TXPWRLMT_CFG_BUF_SIZE * 3) + 40;
775+
char *buf = kzalloc(size, GFP_KERNEL);
776+
char *p = buf;
777+
int len = 0;
778+
int remain = priv->txpwrlmt_data.len;
779+
const char *tblp = priv->txpwrlmt_data.buf;
780+
781+
ssize_t ret = 0;
782+
783+
if (!p)
784+
return -ENOMEM;
785+
786+
len += scnprintf(p + len, size - len, "%*ph\n",
787+
TXPWRLMT_CFG_SIG_LEN, &txpwr_cfg_sig);
788+
len += scnprintf(p + len, size - len, "%*ph\n",
789+
TXPWRLMT_CFG_VERSION_INFO_LEN, &txpwr_cfg_ver);
790+
791+
while (remain > sizeof(struct mwl_txpwrlmt_cfg_entry_hdr)) {
792+
struct mwl_txpwrlmt_cfg_entry_hdr* subband_hdr =
793+
(struct mwl_txpwrlmt_cfg_entry_hdr*)tblp;
794+
u16 subband_len = le16_to_cpu(subband_hdr->len);
795+
len += scnprintf(p + len, size - len, "\n%*ph\n",
796+
sizeof(struct mwl_txpwrlmt_cfg_entry_hdr),
797+
tblp);
798+
tblp += sizeof(struct mwl_txpwrlmt_cfg_entry_hdr);
799+
remain -= sizeof(struct mwl_txpwrlmt_cfg_entry_hdr);
800+
801+
// TODO(nhed): maybe add more sanity checks?
802+
while (subband_len > 0) {
803+
u16 hexd_line_cnt = min(subband_len, (u16)32);
804+
len += scnprintf(p + len, size - len, "%*ph\n",
805+
hexd_line_cnt, tblp);
806+
tblp += hexd_line_cnt;
807+
remain -= hexd_line_cnt;
808+
subband_len -= hexd_line_cnt;
809+
}
810+
811+
// Not sure why `\n` delimiters are added between subbands
812+
// into the binary data buffer txpwrlmt_data.buf by
813+
// mwl_fwcmd_get_txpwrlmt_cfg_data() but since we need to skip
814+
// them we may as well test for them.
815+
if (*tblp != '\n') {
816+
printk("Unexpected lack of subband delimiter(s)\n");
817+
ret = -EIO;
818+
goto cleanup;
819+
}
820+
tblp++;
821+
remain--;
822+
}
823+
len += scnprintf(p + len, size - len, "\n");
824+
ret = simple_read_from_buffer(ubuf, count, ppos, p, len);
825+
826+
cleanup:
827+
if (buf) {
828+
kfree(buf);
829+
}
830+
831+
return ret;
832+
}
833+
764834
static ssize_t mwl_debugfs_tx_amsdu_read(struct file *file,
765835
char __user *ubuf,
766836
size_t count, loff_t *ppos)
@@ -2139,6 +2209,7 @@ MWLWIFI_DEBUGFS_FILE_READ_OPS(ampdu);
21392209
MWLWIFI_DEBUGFS_FILE_READ_OPS(stnid);
21402210
MWLWIFI_DEBUGFS_FILE_READ_OPS(device_pwrtbl);
21412211
MWLWIFI_DEBUGFS_FILE_READ_OPS(txpwrlmt);
2212+
MWLWIFI_DEBUGFS_FILE_READ_OPS(txpwrlmt_file);
21422213
MWLWIFI_DEBUGFS_FILE_OPS(tx_amsdu);
21432214
MWLWIFI_DEBUGFS_FILE_OPS(dump_hostcmd);
21442215
MWLWIFI_DEBUGFS_FILE_OPS(dump_probe);
@@ -2177,6 +2248,7 @@ void mwl_debugfs_init(struct ieee80211_hw *hw)
21772248
MWLWIFI_DEBUGFS_ADD_FILE(stnid);
21782249
MWLWIFI_DEBUGFS_ADD_FILE(device_pwrtbl);
21792250
MWLWIFI_DEBUGFS_ADD_FILE(txpwrlmt);
2251+
MWLWIFI_DEBUGFS_ADD_FILE(txpwrlmt_file);
21802252
MWLWIFI_DEBUGFS_ADD_FILE(tx_amsdu);
21812253
MWLWIFI_DEBUGFS_ADD_FILE(dump_hostcmd);
21822254
MWLWIFI_DEBUGFS_ADD_FILE(dump_probe);

0 commit comments

Comments
 (0)