ath5k: debug level improvements
PATCH 1/2 ath5k: debug level improvements
* use only one debug level for beacon debugging: unify ATH5K_DEBUG_BEACON and ATH5K_DEBUG_BEACON_PROC.
* remove debug level ATH5K_DEBUG_FATAL. doesn't make sense as a debug level - if it's fatal it should be logged as an error.
* fancier printing of debug levels. cat /debugfs/ath5k/phy0/debug.
* allow debug levels to be changed by echoing their name into /debugfs/ath5k/phy0/debug. this will toggle the state, when it was off it will be turned on and vice versa.
* use copy_from_user() when reading from the debug files. use unsigned int for better optimization.
drivers/net/wireless/ath5k/base.c: Changes-licensed-under: 3-Clause-BSD drivers/net/wireless/ath5k/debug.c: Changes-licensed-under: GPL drivers/net/wireless/ath5k/debug.h: Changes-licensed-under: GPL
---
drivers/net/wireless/ath5k/base.c | 10 ++- drivers/net/wireless/ath5k/debug.c | 120 ++++++++++++++++++++++++++++++------ drivers/net/wireless/ath5k/debug.h | 18 ++--- 3 files changed, 113 insertions(+), 35 deletions(-)
drivers/net/wireless/ath5k/base.c +5 -5
@@ -1919,7 +1919,7 @@ ath5k_beacon_send(struct ath5k_softc *sc)struct ath5k_buf *bf = sc->bbuf;struct ath5k_hw *ah = sc->ah; -ATH5K_DBG (sc,ATH5K_DEBUG_BEACON_PROC ,"in beacon_send\n" ); +ATH5K_DBG_UNLIMIT (sc,ATH5K_DEBUG_BEACON ,"in beacon_send\n" );if (unlikely (bf->skb ==NULL || sc->opmode ==IEEE80211_IF_TYPE_STA || sc->opmode ==IEEE80211_IF_TYPE_MNTR )) {
@@ -1935,10 +1935,10 @@ ath5k_beacon_send(struct ath5k_softc *sc)*/ if (unlikely (ath5k_hw_num_tx_pending (ah, sc->bhalq) !=0 )) { sc->bmisscount++; -ATH5K_DBG (sc,ATH5K_DEBUG_BEACON_PROC , +ATH5K_DBG (sc,ATH5K_DEBUG_BEACON ,"missed %u consecutive beacons\n" , sc->bmisscount);if (sc->bmisscount >3 ) {/* NB: 3 is a guess */ -ATH5K_DBG (sc,ATH5K_DEBUG_BEACON_PROC , +ATH5K_DBG (sc,ATH5K_DEBUG_BEACON ,"stuck beacon time (%u missed)\n" , sc->bmisscount);tasklet_schedule (&sc->restq);
@@ -1946,7 +1946,7 @@ ath5k_beacon_send(struct ath5k_softc *sc)return ; }if (unlikely (sc->bmisscount !=0 )) { -ATH5K_DBG (sc,ATH5K_DEBUG_BEACON_PROC , +ATH5K_DBG (sc,ATH5K_DEBUG_BEACON ,"resume beacon xmit after %u misses\n" , sc->bmisscount); sc->bmisscount =0 ;
@@ -1966,7 +1966,7 @@ ath5k_beacon_send(struct ath5k_softc *sc)ath5k_hw_put_tx_buf (ah, sc->bhalq, bf->daddr);ath5k_hw_tx_start (ah, sc->bhalq); -ATH5K_DBG (sc,ATH5K_DEBUG_BEACON_PROC ,"TXDP[%u] = %llx (%p)\n" , +ATH5K_DBG (sc,ATH5K_DEBUG_BEACON ,"TXDP[%u] = %llx (%p)\n" , sc->bhalq, (unsigned long long )bf->daddr, bf->desc); sc->bsent++;
drivers/net/wireless/ath5k/debug.c +101 -19
178 lines not on this page · raw message
drivers/net/wireless/ath5k/debug.h +7 -11
@@ -91,7 +91,6 @@ struct ath5k_dbg_info {* @ATH5K_DEBUG_MODE: mode init/setup * @ATH5K_DEBUG_XMIT: basic xmit operation * @ATH5K_DEBUG_BEACON: beacon handling -* @ATH5K_DEBUG_BEACON_PROC: beacon ISR proc * @ATH5K_DEBUG_CALIBRATE: periodic calibration * @ATH5K_DEBUG_TXPOWER: transmit power setting * @ATH5K_DEBUG_LED: led management
@@ -99,7 +98,6 @@ struct ath5k_dbg_info {* @ATH5K_DEBUG_DUMP_TX: print transmit skb content * @ATH5K_DEBUG_DUMPMODES: dump modes * @ATH5K_DEBUG_TRACE: trace function calls -* @ATH5K_DEBUG_FATAL: fatal errors * @ATH5K_DEBUG_ANY: show at any debug level * * The debug level is used to control the amount and type of debugging output
@@ -115,15 +113,13 @@ enum ath5k_debug_level {ATH5K_DEBUG_MODE =0x00000004 ,ATH5K_DEBUG_XMIT =0x00000008 ,ATH5K_DEBUG_BEACON =0x00000010 , -ATH5K_DEBUG_BEACON_PROC =0x00000020 , -ATH5K_DEBUG_CALIBRATE =0x00000100 , -ATH5K_DEBUG_TXPOWER =0x00000200 , -ATH5K_DEBUG_LED =0x00000400 , -ATH5K_DEBUG_DUMP_RX =0x00001000 , -ATH5K_DEBUG_DUMP_TX =0x00002000 , -ATH5K_DEBUG_DUMPMODES =0x00004000 , -ATH5K_DEBUG_TRACE =0x00010000 , -ATH5K_DEBUG_FATAL =0x80000000 , +ATH5K_DEBUG_CALIBRATE =0x00000020 , +ATH5K_DEBUG_TXPOWER =0x00000040 , +ATH5K_DEBUG_LED =0x00000080 , +ATH5K_DEBUG_DUMP_RX =0x00000100 , +ATH5K_DEBUG_DUMP_TX =0x00000200 , +ATH5K_DEBUG_DUMPMODES =0x00000400 , +ATH5K_DEBUG_TRACE =0x00001000 ,ATH5K_DEBUG_ANY =0xffffffff };
PATCH 2/2 ath5k: always extend rx timestamp with tsf
always extend the rx timestamp with the local TSF, since this information is also needed for proper IBSS merging. this is done in the tasklet for now, maybe has to be moved to the interrupt handler like in madwifi.
drivers/net/wireless/ath5k/base.c: Changes-licensed-under: 3-Clause-BSD
---
drivers/net/wireless/ath5k/base.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-)
drivers/net/wireless/ath5k/base.c +12 -5
@@ -1725,11 +1725,18 @@ accept:skb_pull (skb, pad); } -if (sc->opmode ==IEEE80211_IF_TYPE_MNTR ) - rxs.mactime =ath5k_extend_tsf (sc->ah, - ds->ds_rxstat.rs_tstamp); -else - rxs.mactime = ds->ds_rxstat.rs_tstamp; +/* +* always extend the mac timestamp, since this information is +* also needed for proper IBSS merging. +* +* XXX: it might be too late to do it here, since rs_tstamp is +* 15bit only. that means TSF extension has to be done within +* 32768usec (about 32ms). it might be necessary to move this to +* the interrupt handler, like it is done in madwifi. +*/ + rxs.mactime =ath5k_extend_tsf (sc->ah, ds->ds_rxstat.rs_tstamp); + rxs.flag |=RX_FLAG_TSFT ; + rxs.freq = sc->curchan->freq; rxs.channel = sc->curchan->chan; rxs.phymode = sc->curmode;
Re: [PATCH 2/2] ath5k: always extend rx timestamp with tsf
Quoted 7 lines · Bruno Randolf
always extend the rx timestamp with the local TSF, since this information is also needed for proper IBSS merging. this is done in the tasklet for now, maybe has to be moved to the interrupt handler like in madwifi.
drivers/net/wireless/ath5k/base.c: Changes-licensed-under: 3-Clause-BSDSigned-off-by Bruno Randolf <[email protected]>
Luis
Re: [PATCH 2/2] ath5k: always extend rx timestamp with tsf
In reply to Bruno Randolf2008/1/21, Bruno Randolf <[email protected]>:
Quoted 33 lines
always extend the rx timestamp with the local TSF, since this information is also needed for proper IBSS merging. this is done in the tasklet for now, maybe has to be moved to the interrupt handler like in madwifi.
drivers/net/wireless/ath5k/base.c: Changes-licensed-under: 3-Clause-BSDSigned-off-by Bruno Randolf <[email protected]>---
drivers/net/wireless/ath5k/base.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-)drivers/net/wireless/ath5k/base.c +5
-5@@ -1725,11 +1725,18 @@ accept:skb_pull (skb, pad); } -if (sc->opmode ==IEEE80211_IF_TYPE_MNTR ) - rxs.mactime =ath5k_extend_tsf (sc->ah, - ds->ds_rxstat.rs_tstamp); -else - rxs.mactime = ds->ds_rxstat.rs_tstamp; +/* +* always extend the mac timestamp, since this information is +* also needed for proper IBSS merging. +* +* XXX: it might be too late to do it here, since rs_tstamp is
drivers/net/wireless/ath5k/base.c accept: · line 1742
Quoted 10 lines
drivers/net/wireless/ath5k/base.c +7
-0+* 15bit only. that means TSF extension has to be done within +* 32768usec (about 32ms). it might be necessary to move this to +* the interrupt handler, like it is done in madwifi. +*/ + rxs.mactime =ath5k_extend_tsf (sc->ah, ds->ds_rxstat.rs_tstamp); + rxs.flag |=RX_FLAG_TSFT ; + rxs.freq = sc->curchan->freq; rxs.channel = sc->curchan->chan; rxs.phymode = sc->curmode;
Signature · 3 lines
GPG ID: 0xD21DB2DB As you read this post global entropy rises. Have Fun ;-) Nick
drivers/net/wireless/ath5k/debug.c static ssize_t write_file_tsf(struct file *file, · line 215
Quoted 9 lines · Bruno Randolf
drivers/net/wireless/ath5k/debug.c +4
-1@@ -209,7 +209,12 @@ static ssize_t write_file_tsf(struct file *file, size_t count, loff_t *ppos) { struct ath5k_softc *sc = file->private_data; -if (strncmp (userbuf,"reset" ,5 ) ==0 ) { +char buf[20 ]; + +if (copy_from_user (buf, userbuf,min_t (size_t, count,20 ))) +return -EFAULT ;
How about let the compiler count the size of buf? Like this:
if (copy_from_user(buf, userbuf, min_t(size_t, count, sizeof(buf))))
That way the size of buf is only in one place, and we might avoid a bug whenever someone changes the size of buf.
drivers/net/wireless/ath5k/debug.c static const struct file_operations fops_reset = { · line 352
Quoted 5 lines
drivers/net/wireless/ath5k/debug.c +5
-0+static ssize_t read_file_debug (struct file *file,char __user *user_buf, +size_t count,loff_t *ppos) +{ +struct ath5k_softc *sc = file->private_data; +char buf[1000 ];
To my eyes allocating 1000 bytes from stack is too large.
Signature · 1 line
Kalle Valo
Quoted 11 lines · On Monday 21 January 2008 15:44:46 Kalle Valo wrote:
drivers/net/wireless/ath5k/debug.c static ssize_t write_file_tsf(struct file *file, · line 215
Quoted 4 lines
drivers/net/wireless/ath5k/debug.c +4
-0+char buf[20 ]; + +if (copy_from_user (buf, userbuf,min_t (size_t, count,20 ))) +return -EFAULT ;How about let the compiler count the size of buf? Like this:
if (
copy_from_user(buf, userbuf, min_t(size_t, count, sizeof(buf))))That way the size of buf is only in one place, and we might avoid a bug whenever someone changes the size of buf.
good idea. that way i can also get rid of min_t(size_t,...) and use min().
Quoted 7 lines
drivers/net/wireless/ath5k/debug.c static const struct file_operations fops_reset = { · line 352
Quoted 5 lines
drivers/net/wireless/ath5k/debug.c +5
-0+static ssize_t read_file_debug (struct file *file,char __user *user_buf, +size_t count,loff_t *ppos) +{ +struct ath5k_softc *sc = file->private_data; +char buf[1000 ];To my eyes allocating 1000 bytes from stack is too large.
what about 700? ;)
the output currently is 626 byte.
thanks,
bruno
Quoted 8 lines · bruno randolf
Quoted 7 lines · On Monday 21 January 2008 15:44:46 Kalle Valo wrote:
drivers/net/wireless/ath5k/debug.c static ssize_t write_file_tsf(struct file *file, · line 215
Quoted 4 lines
drivers/net/wireless/ath5k/debug.c +4
-0+char buf[20 ]; + +if (copy_from_user (buf, userbuf,min_t (size_t, count,20 ))) +return -EFAULT ;How about let the compiler count the size of buf? Like this:
Quoted 6 lines
Quoted 4 lines
if (
copy_from_user(buf, userbuf, min_t(size_t, count, sizeof(buf))))That way the size of buf is only in one place, and we might avoid a bug whenever someone changes the size of buf.
good idea. that way i can also get rid of
min_t(size_t,...)and usemin().
Even better.
Quoted 10 lines
Quoted 7 lines
drivers/net/wireless/ath5k/debug.c static const struct file_operations fops_reset = { · line 352
Quoted 5 lines
drivers/net/wireless/ath5k/debug.c +5
-0+static ssize_t read_file_debug (struct file *file,char __user *user_buf, +size_t count,loff_t *ppos) +{ +struct ath5k_softc *sc = file->private_data; +char buf[1000 ];To my eyes allocating 1000 bytes from stack is too large.
what about 700? ;)
the output currently is 626 byte.
Hehe :) I have no idea what's the preferred limit here, so I cannot you give a definitive answer. But I would guess that 700 byte allocation is still sensible with 4k stacks.
But this is for a debug interface so most likely this doesn't matter that much.
Signature · 1 line
Kalle Valo