@@ -1480,6 +1480,19 @@ void ath10k_debug_tpc_stats_process(struct ath10k *ar,
14801480 spin_unlock_bh (& ar -> data_lock );
14811481}
14821482
1483+ void
1484+ ath10k_debug_tpc_stats_final_process (struct ath10k * ar ,
1485+ struct ath10k_tpc_stats_final * tpc_stats )
1486+ {
1487+ spin_lock_bh (& ar -> data_lock );
1488+
1489+ kfree (ar -> debug .tpc_stats_final );
1490+ ar -> debug .tpc_stats_final = tpc_stats ;
1491+ complete (& ar -> debug .tpc_complete );
1492+
1493+ spin_unlock_bh (& ar -> data_lock );
1494+ }
1495+
14831496static void ath10k_tpc_stats_print (struct ath10k_tpc_stats * tpc_stats ,
14841497 unsigned int j , char * buf , size_t * len )
14851498{
@@ -2143,6 +2156,137 @@ static const struct file_operations fops_fw_checksums = {
21432156 .llseek = default_llseek ,
21442157};
21452158
2159+ static ssize_t ath10k_sta_tid_stats_mask_read (struct file * file ,
2160+ char __user * user_buf ,
2161+ size_t count , loff_t * ppos )
2162+ {
2163+ struct ath10k * ar = file -> private_data ;
2164+ char buf [32 ];
2165+ size_t len ;
2166+
2167+ len = scnprintf (buf , sizeof (buf ), "0x%08x\n" , ar -> sta_tid_stats_mask );
2168+ return simple_read_from_buffer (user_buf , count , ppos , buf , len );
2169+ }
2170+
2171+ static ssize_t ath10k_sta_tid_stats_mask_write (struct file * file ,
2172+ const char __user * user_buf ,
2173+ size_t count , loff_t * ppos )
2174+ {
2175+ struct ath10k * ar = file -> private_data ;
2176+ char buf [32 ];
2177+ ssize_t len ;
2178+ u32 mask ;
2179+
2180+ len = min (count , sizeof (buf ) - 1 );
2181+ if (copy_from_user (buf , user_buf , len ))
2182+ return - EFAULT ;
2183+
2184+ buf [len ] = '\0' ;
2185+ if (kstrtoint (buf , 0 , & mask ))
2186+ return - EINVAL ;
2187+
2188+ ar -> sta_tid_stats_mask = mask ;
2189+
2190+ return len ;
2191+ }
2192+
2193+ static const struct file_operations fops_sta_tid_stats_mask = {
2194+ .read = ath10k_sta_tid_stats_mask_read ,
2195+ .write = ath10k_sta_tid_stats_mask_write ,
2196+ .open = simple_open ,
2197+ .owner = THIS_MODULE ,
2198+ .llseek = default_llseek ,
2199+ };
2200+
2201+ static int ath10k_debug_tpc_stats_final_request (struct ath10k * ar )
2202+ {
2203+ int ret ;
2204+ unsigned long time_left ;
2205+
2206+ lockdep_assert_held (& ar -> conf_mutex );
2207+
2208+ reinit_completion (& ar -> debug .tpc_complete );
2209+
2210+ ret = ath10k_wmi_pdev_get_tpc_table_cmdid (ar , WMI_TPC_CONFIG_PARAM );
2211+ if (ret ) {
2212+ ath10k_warn (ar , "failed to request tpc table cmdid: %d\n" , ret );
2213+ return ret ;
2214+ }
2215+
2216+ time_left = wait_for_completion_timeout (& ar -> debug .tpc_complete ,
2217+ 1 * HZ );
2218+ if (time_left == 0 )
2219+ return - ETIMEDOUT ;
2220+
2221+ return 0 ;
2222+ }
2223+
2224+ static int ath10k_tpc_stats_final_open (struct inode * inode , struct file * file )
2225+ {
2226+ struct ath10k * ar = inode -> i_private ;
2227+ void * buf ;
2228+ int ret ;
2229+
2230+ mutex_lock (& ar -> conf_mutex );
2231+
2232+ if (ar -> state != ATH10K_STATE_ON ) {
2233+ ret = - ENETDOWN ;
2234+ goto err_unlock ;
2235+ }
2236+
2237+ buf = vmalloc (ATH10K_TPC_CONFIG_BUF_SIZE );
2238+ if (!buf ) {
2239+ ret = - ENOMEM ;
2240+ goto err_unlock ;
2241+ }
2242+
2243+ ret = ath10k_debug_tpc_stats_final_request (ar );
2244+ if (ret ) {
2245+ ath10k_warn (ar , "failed to request tpc stats final: %d\n" ,
2246+ ret );
2247+ goto err_free ;
2248+ }
2249+
2250+ ath10k_tpc_stats_fill (ar , ar -> debug .tpc_stats , buf );
2251+ file -> private_data = buf ;
2252+
2253+ mutex_unlock (& ar -> conf_mutex );
2254+ return 0 ;
2255+
2256+ err_free :
2257+ vfree (buf );
2258+
2259+ err_unlock :
2260+ mutex_unlock (& ar -> conf_mutex );
2261+ return ret ;
2262+ }
2263+
2264+ static int ath10k_tpc_stats_final_release (struct inode * inode ,
2265+ struct file * file )
2266+ {
2267+ vfree (file -> private_data );
2268+
2269+ return 0 ;
2270+ }
2271+
2272+ static ssize_t ath10k_tpc_stats_final_read (struct file * file ,
2273+ char __user * user_buf ,
2274+ size_t count , loff_t * ppos )
2275+ {
2276+ const char * buf = file -> private_data ;
2277+ unsigned int len = strlen (buf );
2278+
2279+ return simple_read_from_buffer (user_buf , count , ppos , buf , len );
2280+ }
2281+
2282+ static const struct file_operations fops_tpc_stats_final = {
2283+ .open = ath10k_tpc_stats_final_open ,
2284+ .release = ath10k_tpc_stats_final_release ,
2285+ .read = ath10k_tpc_stats_final_read ,
2286+ .owner = THIS_MODULE ,
2287+ .llseek = default_llseek ,
2288+ };
2289+
21462290int ath10k_debug_create (struct ath10k * ar )
21472291{
21482292 ar -> debug .cal_data = vzalloc (ATH10K_DEBUG_CAL_DATA_LEN );
@@ -2258,6 +2402,16 @@ int ath10k_debug_register(struct ath10k *ar)
22582402 debugfs_create_file ("fw_checksums" , 0400 , ar -> debug .debugfs_phy , ar ,
22592403 & fops_fw_checksums );
22602404
2405+ if (IS_ENABLED (CONFIG_MAC80211_DEBUGFS ))
2406+ debugfs_create_file ("sta_tid_stats_mask" , 0600 ,
2407+ ar -> debug .debugfs_phy ,
2408+ ar , & fops_sta_tid_stats_mask );
2409+
2410+ if (test_bit (WMI_SERVICE_TPC_STATS_FINAL , ar -> wmi .svc_map ))
2411+ debugfs_create_file ("tpc_stats_final" , 0400 ,
2412+ ar -> debug .debugfs_phy , ar ,
2413+ & fops_tpc_stats_final );
2414+
22612415 return 0 ;
22622416}
22632417
0 commit comments