@@ -121,6 +121,91 @@ static const struct file_operations fops_debug = {
121
121
122
122
#endif
123
123
124
+ static ssize_t read_file_dirtyts (struct file * file , char __user * user_buf , size_t count , loff_t * ppos ) {
125
+ struct ath_softc * sc = file -> private_data ;
126
+ u8 buf [sizeof (u64 )];
127
+
128
+ memcpy (buf , & sc -> ptp_dirtyts , sizeof buf );
129
+ return simple_read_from_buffer (user_buf , count , ppos , buf , sizeof buf );
130
+ }
131
+
132
+ static ssize_t write_file_dirtyts (struct file * file , const char __user * user_buf ,
133
+ size_t count , loff_t * ppos ) {
134
+ struct ath_softc * sc = file -> private_data ;
135
+ u8 buf [sizeof (u64 )];
136
+ ssize_t len ;
137
+ u64 dirty_cycle ;
138
+ u32 raw_tsf ;
139
+ s64 delta ;
140
+ s64 dirty_ns ;
141
+ unsigned long flags ;
142
+ u32 remain ;
143
+
144
+ len = simple_write_to_buffer (buf , sizeof buf , ppos , user_buf , count );
145
+ if (len < 0 ) {
146
+ return len ;
147
+ }
148
+ if (len < sizeof buf ) {
149
+ return - EINVAL ;
150
+ }
151
+
152
+ memcpy (& dirty_cycle , buf , sizeof buf );
153
+ raw_tsf = (dirty_cycle >> 32 );
154
+ remain = dirty_cycle & 0xffffffffU ;
155
+
156
+ spin_lock_irqsave (& sc -> systim_lock , flags );
157
+ dirty_ns = timecounter_cyc2time (& sc -> tc , raw_tsf );
158
+ delta = 0 ;
159
+ if (remain ) {
160
+ u64 frac = 0 ;
161
+ delta = cyclecounter_cyc2ns (& sc -> cc , 1 , sc -> cc .mask , & frac );
162
+ delta = delta * remain / 1000 ;
163
+ }
164
+ spin_unlock_irqrestore (& sc -> systim_lock , flags );
165
+
166
+ dirty_ns += delta ;
167
+ sc -> ptp_dirtyts = dirty_ns ;
168
+
169
+ return len ;
170
+ }
171
+
172
+ static const struct file_operations fops_dirtyts = {
173
+ .read = read_file_dirtyts ,
174
+ .write = write_file_dirtyts ,
175
+ .open = simple_open ,
176
+ .owner = THIS_MODULE ,
177
+ .llseek = default_llseek ,
178
+ };
179
+
180
+ static ssize_t read_file_trigger_cbr (struct file * file , char __user * user_buf , size_t count , loff_t * ppos ) {
181
+ return - EINVAL ;
182
+ }
183
+
184
+ static ssize_t write_file_trigger_cbr (struct file * file , const char __user * user_buf ,
185
+ size_t count , loff_t * ppos ) {
186
+ struct ath_softc * sc = file -> private_data ;
187
+ struct ath_hw * ah = sc -> sc_ah ;
188
+
189
+ if (count & 1 ) {
190
+ printk ("ath9k: cbr open\n" );
191
+ // REG_RMW(ah, AR_QMISC(ATH_TXQ_AC_VI), AR_Q_MISC_FSP_CBR, AR_Q_MISC_FSP);
192
+ REG_WRITE (ah , AR_QCBRCFG (ATH_TXQ_AC_VI ), 0xc350 );
193
+ } else {
194
+ printk ("ath9k: cbr gated\n" );
195
+ // REG_RMW(ah, AR_QMISC(ATH_TXQ_AC_VI), 0x4, AR_Q_MISC_FSP);
196
+ }
197
+
198
+ return count ;
199
+ }
200
+
201
+ static const struct file_operations fops_trigger_cbr = {
202
+ .read = read_file_trigger_cbr ,
203
+ .write = write_file_trigger_cbr ,
204
+ .open = simple_open ,
205
+ .owner = THIS_MODULE ,
206
+ .llseek = default_llseek ,
207
+ };
208
+
124
209
#define DMA_BUF_LEN 1024
125
210
126
211
@@ -1427,6 +1512,12 @@ int ath9k_init_debug(struct ath_hw *ah)
1427
1512
sc -> debug .debugfs_phy ,
1428
1513
read_file_dump_nfcal );
1429
1514
1515
+ debugfs_create_file ("dirtyts" , 0600 , sc -> debug .debugfs_phy ,
1516
+ sc , & fops_dirtyts );
1517
+
1518
+ debugfs_create_file ("trigger_cbr" , 0600 , sc -> debug .debugfs_phy ,
1519
+ sc , & fops_trigger_cbr );
1520
+
1430
1521
ath9k_cmn_debug_base_eeprom (sc -> debug .debugfs_phy , sc -> sc_ah );
1431
1522
ath9k_cmn_debug_modal_eeprom (sc -> debug .debugfs_phy , sc -> sc_ah );
1432
1523
0 commit comments