@@ -761,6 +761,76 @@ 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
+ 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
+
764
834
static ssize_t mwl_debugfs_tx_amsdu_read (struct file * file ,
765
835
char __user * ubuf ,
766
836
size_t count , loff_t * ppos )
@@ -2139,6 +2209,7 @@ MWLWIFI_DEBUGFS_FILE_READ_OPS(ampdu);
2139
2209
MWLWIFI_DEBUGFS_FILE_READ_OPS (stnid );
2140
2210
MWLWIFI_DEBUGFS_FILE_READ_OPS (device_pwrtbl );
2141
2211
MWLWIFI_DEBUGFS_FILE_READ_OPS (txpwrlmt );
2212
+ MWLWIFI_DEBUGFS_FILE_READ_OPS (txpwrlmt_file );
2142
2213
MWLWIFI_DEBUGFS_FILE_OPS (tx_amsdu );
2143
2214
MWLWIFI_DEBUGFS_FILE_OPS (dump_hostcmd );
2144
2215
MWLWIFI_DEBUGFS_FILE_OPS (dump_probe );
@@ -2177,6 +2248,7 @@ void mwl_debugfs_init(struct ieee80211_hw *hw)
2177
2248
MWLWIFI_DEBUGFS_ADD_FILE (stnid );
2178
2249
MWLWIFI_DEBUGFS_ADD_FILE (device_pwrtbl );
2179
2250
MWLWIFI_DEBUGFS_ADD_FILE (txpwrlmt );
2251
+ MWLWIFI_DEBUGFS_ADD_FILE (txpwrlmt_file );
2180
2252
MWLWIFI_DEBUGFS_ADD_FILE (tx_amsdu );
2181
2253
MWLWIFI_DEBUGFS_ADD_FILE (dump_hostcmd );
2182
2254
MWLWIFI_DEBUGFS_ADD_FILE (dump_probe );
0 commit comments