Commit 8cab7581 authored by Alina Friedrichsen's avatar Alina Friedrichsen Committed by John W. Linville

ath5k: Read and write the TSF via debugfs

This patch updates the ath5k specific entry in the debugfs to read and reset the TSF value, to allowing write it, too. This makes debugging the IBSS handling of wifi drivers _much_ easier.
Signed-off-by: default avatarAlina Friedrichsen <x-alina@gmx.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent ae54c985
...@@ -1206,6 +1206,7 @@ extern void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter); ...@@ -1206,6 +1206,7 @@ extern void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter);
/* Beacon control functions */ /* Beacon control functions */
extern u32 ath5k_hw_get_tsf32(struct ath5k_hw *ah); extern u32 ath5k_hw_get_tsf32(struct ath5k_hw *ah);
extern u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah); extern u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah);
extern void ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64);
extern void ath5k_hw_reset_tsf(struct ath5k_hw *ah); extern void ath5k_hw_reset_tsf(struct ath5k_hw *ah);
extern void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval); extern void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval);
#if 0 #if 0
......
...@@ -210,15 +210,22 @@ static ssize_t write_file_tsf(struct file *file, ...@@ -210,15 +210,22 @@ static ssize_t write_file_tsf(struct file *file,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct ath5k_softc *sc = file->private_data; struct ath5k_softc *sc = file->private_data;
char buf[20]; char buf[21];
unsigned long long tsf;
if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) if (copy_from_user(buf, userbuf, min(count, sizeof(buf) - 1)))
return -EFAULT; return -EFAULT;
buf[sizeof(buf) - 1] = '\0';
if (strncmp(buf, "reset", 5) == 0) { if (strncmp(buf, "reset", 5) == 0) {
ath5k_hw_reset_tsf(sc->ah); ath5k_hw_reset_tsf(sc->ah);
printk(KERN_INFO "debugfs reset TSF\n"); printk(KERN_INFO "debugfs reset TSF\n");
} else {
tsf = simple_strtoul(buf, NULL, 0);
ath5k_hw_set_tsf64(sc->ah, tsf);
printk(KERN_INFO "debugfs set TSF to %#018llx\n", tsf);
} }
return count; return count;
} }
......
...@@ -645,6 +645,23 @@ u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah) ...@@ -645,6 +645,23 @@ u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah)
return ath5k_hw_reg_read(ah, AR5K_TSF_L32) | (tsf << 32); return ath5k_hw_reg_read(ah, AR5K_TSF_L32) | (tsf << 32);
} }
/**
* ath5k_hw_set_tsf64 - Set a new 64bit TSF
*
* @ah: The &struct ath5k_hw
* @tsf64: The new 64bit TSF
*
* Sets the new TSF
*/
void ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64)
{
ATH5K_TRACE(ah->ah_sc);
ath5k_hw_reg_write(ah, 0x00000000, AR5K_TSF_L32);
ath5k_hw_reg_write(ah, (tsf64 >> 32) & 0xffffffff, AR5K_TSF_U32);
ath5k_hw_reg_write(ah, tsf64 & 0xffffffff, AR5K_TSF_L32);
}
/** /**
* ath5k_hw_reset_tsf - Force a TSF reset * ath5k_hw_reset_tsf - Force a TSF reset
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment