From: Michael Buesch <hidden> Date: 2006-05-03 19:01:15
Measure the channel change time with the
bcm43xx tsf timer and remove the guesswork constant. ;)
Tests on my 4306 show that the time comes damn
close to reality.
Signed-off-by: Michael Buesch <redacted>
Index: wireless-dev/drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c
===================================================================
@@ -354,6 +354,33 @@bcm43xx_write32(bcm,BCM43xx_MMIO_STATUS_BITFIELD,status);}+staticvoidbcm43xx_measure_channel_change_time(structbcm43xx_private*bcm)+{+structbcm43xx_radioinfo*radio;+u64start,stop;+unsignedlongflags;+u8oldchan,testchan;++/* We (ab)use the bcm43xx TSF timer to measure the time needed+*toswitchchannels.Thisinformationishandedoverto+*theieee80211subsystem.+*Timeismeasuredinmicroseconds.+*/++bcm43xx_lock_mmio(bcm,flags);+radio=bcm43xx_current_radio(bcm);+oldchan=radio->channel;+testchan=(oldchan==6)?7:6;+bcm43xx_tsf_read(bcm,&start);+bcm43xx_radio_selectchannel(bcm,testchan,0);+bcm43xx_tsf_read(bcm,&stop);+bcm43xx_radio_selectchannel(bcm,oldchan,0);+bcm43xx_unlock_mmio(bcm,flags);++assert(stop>start);+bcm->ieee->channel_change_time=stop-start;+}+staticvoidbcm43xx_macfilter_set(structbcm43xx_private*bcm,u16offset,
On Wed, 3 May 2006 21:05:53 +0200, Michael Buesch wrote:
quoted hunk
@@ -354,6 +354,33 @@ bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD, status); }+static void bcm43xx_measure_channel_change_time(struct bcm43xx_private *bcm)+{+ struct bcm43xx_radioinfo *radio;+ u64 start, stop;+ unsigned long flags;+ u8 oldchan, testchan;++ /* We (ab)use the bcm43xx TSF timer to measure the time needed+ * to switch channels. This information is handed over to+ * the ieee80211 subsystem.+ * Time is measured in microseconds.+ */++ bcm43xx_lock_mmio(bcm, flags);+ radio = bcm43xx_current_radio(bcm);+ oldchan = radio->channel;+ testchan = (oldchan == 6) ? 7 : 6;+ bcm43xx_tsf_read(bcm, &start);+ bcm43xx_radio_selectchannel(bcm, testchan, 0);+ bcm43xx_tsf_read(bcm, &stop);+ bcm43xx_radio_selectchannel(bcm, oldchan, 0);+ bcm43xx_unlock_mmio(bcm, flags);++ assert(stop > start);
I think some safety fallback would be better. Like
if (stop - start < SOME_MIN_VALUE) channel_change_time = SOME_MIN_VALUE
(of course, this won't work because stop and start are unsigned, but you
probably got the idea).
And couldn't TSF counter overflow during the measurement?
From: Johannes Berg <johannes@sipsolutions.net> Date: 2006-05-04 12:22:41
On Thu, 2006-05-04 at 11:11 +0200, Jiri Benc wrote:
I think some safety fallback would be better. Like
if (stop - start < SOME_MIN_VALUE) channel_change_time = SOME_MIN_VALUE
(of course, this won't work because stop and start are unsigned, but you
probably got the idea).
Probably. And yes, it should still work since stop>start at all times.
And couldn't TSF counter overflow during the measurement?
Yes, if the card has been up for like 459148 years or has been reset to
an unbelievably high value. Remember, it's a 64 bit counter.
johannes
From: John W. Linville <hidden> Date: 2006-05-19 18:02:00
On Thu, May 04, 2006 at 02:36:56PM +0200, Johannes Berg wrote:
On Thu, 2006-05-04 at 14:33 +0200, Jiri Benc wrote:
quoted
TSF is set to a value sent by an AP. Is there anything that prevents
that AP to send you e.g. 0xfffffffffffff0?
Ah, good point, I didn't think of stupid APs. Yeah, it should handle it
I guess.
I'm going to apply this patch as it stands. Please follow-up with
a patch to handle the TSF overflow.
Thanks,
John
--
John W. Linville
linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org