@@ -761,6 +761,68 @@ static ssize_t mwl_debugfs_txpwrlmt_read(struct file *file,
761
761
priv -> txpwrlmt_data .len );
762
762
}
763
763
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
+
764
826
static ssize_t mwl_debugfs_tx_amsdu_read (struct file * file ,
765
827
char __user * ubuf ,
766
828
size_t count , loff_t * ppos )
@@ -2139,6 +2201,7 @@ MWLWIFI_DEBUGFS_FILE_READ_OPS(ampdu);
2139
2201
MWLWIFI_DEBUGFS_FILE_READ_OPS (stnid );
2140
2202
MWLWIFI_DEBUGFS_FILE_READ_OPS (device_pwrtbl );
2141
2203
MWLWIFI_DEBUGFS_FILE_READ_OPS (txpwrlmt );
2204
+ MWLWIFI_DEBUGFS_FILE_READ_OPS (txpwrlmt_file );
2142
2205
MWLWIFI_DEBUGFS_FILE_OPS (tx_amsdu );
2143
2206
MWLWIFI_DEBUGFS_FILE_OPS (dump_hostcmd );
2144
2207
MWLWIFI_DEBUGFS_FILE_OPS (dump_probe );
@@ -2177,6 +2240,7 @@ void mwl_debugfs_init(struct ieee80211_hw *hw)
2177
2240
MWLWIFI_DEBUGFS_ADD_FILE (stnid );
2178
2241
MWLWIFI_DEBUGFS_ADD_FILE (device_pwrtbl );
2179
2242
MWLWIFI_DEBUGFS_ADD_FILE (txpwrlmt );
2243
+ MWLWIFI_DEBUGFS_ADD_FILE (txpwrlmt_file );
2180
2244
MWLWIFI_DEBUGFS_ADD_FILE (tx_amsdu );
2181
2245
MWLWIFI_DEBUGFS_ADD_FILE (dump_hostcmd );
2182
2246
MWLWIFI_DEBUGFS_ADD_FILE (dump_probe );
0 commit comments