linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath9k: Read and write the TSF via debugfs
@ 2009-01-23  4:44 Alina Friedrichsen
  2009-01-23 22:14 ` Johannes Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Alina Friedrichsen @ 2009-01-23  4:44 UTC (permalink / raw)
  To: linux-wireless, linville, johannes

This patch adds an ath9k specific entry to read, write and reset the TS=
=46 into the debugfs, like in ath5k. This makes debugging the IBSS hand=
ling of wifi drivers _much_ easier.

Signed-off-by: Alina Friedrichsen <x-alina@gmx.net>
---
diff -urN compat-wireless-2009-01-19/drivers/net/wireless/ath9k/ath9k.h=
 compat-wireless-2009-01-19.orig/drivers/net/wireless/ath9k/ath9k.h
--- compat-wireless-2009-01-19.orig/drivers/net/wireless/ath9k/ath9k.h	=
2009-01-19 20:07:21.000000000 +0100
+++ compat-wireless-2009-01-19/drivers/net/wireless/ath9k/ath9k.h	2009-=
01-23 01:54:41.000000000 +0100
@@ -916,6 +916,7 @@
 bool ath9k_hw_setbssidmask(struct ath_hal *ah, const u8 *mask);
 void ath9k_hw_write_associd(struct ath_hal *ah, const u8 *bssid, u16 a=
ssocId);
 u64 ath9k_hw_gettsf64(struct ath_hal *ah);
+void ath9k_hw_settsf64(struct ath_hal *ah, u64 tsf64);
 void ath9k_hw_reset_tsf(struct ath_hal *ah);
 bool ath9k_hw_set_tsfadjust(struct ath_hal *ah, u32 setting);
 bool ath9k_hw_setslottime(struct ath_hal *ah, u32 us);
diff -urN compat-wireless-2009-01-19/drivers/net/wireless/ath9k/core.h =
compat-wireless-2009-01-19.orig/drivers/net/wireless/ath9k/core.h
--- compat-wireless-2009-01-19.orig/drivers/net/wireless/ath9k/core.h	2=
009-01-19 20:07:21.000000000 +0100
+++ compat-wireless-2009-01-19/drivers/net/wireless/ath9k/core.h	2009-0=
1-23 02:40:53.000000000 +0100
@@ -141,6 +141,7 @@
 	struct dentry *debugfs_phy;
 	struct dentry *debugfs_dma;
 	struct dentry *debugfs_interrupt;
+	struct dentry *debugfs_tsf;
 	struct ath_stats stats;
 };
=20
diff -urN compat-wireless-2009-01-19/drivers/net/wireless/ath9k/debug.c=
 compat-wireless-2009-01-19.orig/drivers/net/wireless/ath9k/debug.c
--- compat-wireless-2009-01-19.orig/drivers/net/wireless/ath9k/debug.c	=
2009-01-19 20:07:21.000000000 +0100
+++ compat-wireless-2009-01-19/drivers/net/wireless/ath9k/debug.c	2009-=
01-23 02:45:34.000000000 +0100
@@ -222,6 +222,49 @@
 	.owner =3D THIS_MODULE
 };
=20
+
+static ssize_t read_file_tsf(struct file *file, char __user *user_buf,
+			     size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc =3D file->private_data;
+	char buf[100];
+	snprintf(buf, sizeof(buf), "0x%016llx\n",
+		 (unsigned long long)ath9k_hw_gettsf64(sc->sc_ah));
+	return simple_read_from_buffer(user_buf, count, ppos, buf, 19);
+}
+
+static ssize_t write_file_tsf(struct file *file,
+                              const char __user *user_buf,
+                              size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc =3D file->private_data;
+	char buf[21];
+	unsigned long long tsf;
+
+	if (copy_from_user(buf, user_buf, min(count, sizeof(buf) - 1)))
+		return -EFAULT;
+	buf[sizeof(buf) - 1] =3D '\0';
+
+	if (strncmp(buf, "reset", 5) =3D=3D 0) {
+		ath9k_hw_reset_tsf(sc->sc_ah);
+		printk(KERN_INFO "debugfs reset TSF\n");
+	} else {
+		tsf =3D simple_strtoul(buf, NULL, 0);
+		ath9k_hw_settsf64(sc->sc_ah, tsf);
+		printk(KERN_INFO "debugfs set TSF to %#018llx\n", tsf);
+	}
+
+	return count;
+}
+
+static const struct file_operations fops_tsf =3D {
+	.read =3D read_file_tsf,
+	.write =3D write_file_tsf,
+	.open =3D ath9k_debugfs_open,
+	.owner =3D THIS_MODULE
+};
+
+
 int ath9k_init_debug(struct ath_softc *sc)
 {
 	sc->sc_debug.debug_mask =3D ath9k_debug;
@@ -247,6 +290,11 @@
 	if (!sc->sc_debug.debugfs_interrupt)
 		goto err;
=20
+	sc->sc_debug.debugfs_tsf =3D debugfs_create_file("tsf", S_IRUGO,
+				       sc->sc_debug.debugfs_phy, sc, &fops_tsf);
+	if (!sc->sc_debug.debugfs_tsf)
+		goto err;
+
 	return 0;
 err:
 	ath9k_exit_debug(sc);
@@ -255,6 +303,7 @@
=20
 void ath9k_exit_debug(struct ath_softc *sc)
 {
+	debugfs_remove(sc->sc_debug.debugfs_tsf);
 	debugfs_remove(sc->sc_debug.debugfs_interrupt);
 	debugfs_remove(sc->sc_debug.debugfs_dma);
 	debugfs_remove(sc->sc_debug.debugfs_phy);
diff -urN compat-wireless-2009-01-19/drivers/net/wireless/ath9k/hw.c co=
mpat-wireless-2009-01-19.orig/drivers/net/wireless/ath9k/hw.c
--- compat-wireless-2009-01-19.orig/drivers/net/wireless/ath9k/hw.c	200=
9-01-19 20:07:21.000000000 +0100
+++ compat-wireless-2009-01-19/drivers/net/wireless/ath9k/hw.c	2009-01-=
23 02:39:11.000000000 +0100
@@ -3810,6 +3810,13 @@
 	return tsf;
 }
=20
+void ath9k_hw_settsf64(struct ath_hal *ah, u64 tsf64)
+{
+	REG_WRITE(ah, AR_TSF_L32, 0x00000000);
+	REG_WRITE(ah, AR_TSF_U32, (tsf64 >> 32) & 0xffffffff);
+	REG_WRITE(ah, AR_TSF_L32, tsf64 & 0xffffffff);
+}
+
 void ath9k_hw_reset_tsf(struct ath_hal *ah)
 {
 	int count;

--=20
NUR NOCH BIS 31.01.! GMX FreeDSL - Telefonanschluss + DSL=20
f=FCr nur 16,37 EURO/mtl.!* http://dsl.gmx.de/?ac=3DOM.AD.PD003K11308T4=
569a
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles=
s" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ath9k: Read and write the TSF via debugfs
  2009-01-23  4:44 [PATCH] ath9k: Read and write the TSF via debugfs Alina Friedrichsen
@ 2009-01-23 22:14 ` Johannes Berg
  2009-01-23 22:29   ` Alina Friedrichsen
       [not found]   ` <20090123222602.50450@gmx.net>
  0 siblings, 2 replies; 4+ messages in thread
From: Johannes Berg @ 2009-01-23 22:14 UTC (permalink / raw)
  To: Alina Friedrichsen; +Cc: linux-wireless, linville

[-- Attachment #1: Type: text/plain, Size: 301 bytes --]

On Fri, 2009-01-23 at 05:44 +0100, Alina Friedrichsen wrote:
> This patch adds an ath9k specific entry to read, write and reset the
> TSF into the debugfs, like in ath5k. This makes debugging the IBSS
> handling of wifi drivers _much_ easier.

Ok, read I can understand, but write??

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ath9k: Read and write the TSF via debugfs
  2009-01-23 22:14 ` Johannes Berg
@ 2009-01-23 22:29   ` Alina Friedrichsen
       [not found]   ` <20090123222602.50450@gmx.net>
  1 sibling, 0 replies; 4+ messages in thread
From: Alina Friedrichsen @ 2009-01-23 22:29 UTC (permalink / raw)
  To: linux-wireless, linville

Hi Johannes!

> Ok, read I can understand, but write??

I need to write it to test if the BSSID merge to the older IBSS network=
 works correctly.=20

I don't want to run around the block to test it. ;)

Regards
Alina

--=20
NUR NOCH BIS 31.01.! GMX FreeDSL - Telefonanschluss + DSL=20
f=FCr nur 16,37 EURO/mtl.!* http://dsl.gmx.de/?ac=3DOM.AD.PD003K11308T4=
569a
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles=
s" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ath9k: Read and write the TSF via debugfs
       [not found]   ` <20090123222602.50450@gmx.net>
@ 2009-01-24 14:17     ` Johannes Berg
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2009-01-24 14:17 UTC (permalink / raw)
  To: Alina Friedrichsen; +Cc: linux-wireless

[-- Attachment #1: Type: text/plain, Size: 456 bytes --]

On Fri, 2009-01-23 at 23:26 +0100, Alina Friedrichsen wrote:
> Hi Johannes!
> 
> > Ok, read I can understand, but write??
> 
> I need to write it to test if the BSSID merge to the older IBSS
> network works correctly. 
> 
> I don't want to run around the block to test it. ;)

Fine, but that definitely doesn't need to have support in mac80211, I
don't really want to see debug-only hooks that people will be left
wondering about.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-24 14:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-23  4:44 [PATCH] ath9k: Read and write the TSF via debugfs Alina Friedrichsen
2009-01-23 22:14 ` Johannes Berg
2009-01-23 22:29   ` Alina Friedrichsen
     [not found]   ` <20090123222602.50450@gmx.net>
2009-01-24 14:17     ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).