From owner-freebsd-mobile@FreeBSD.ORG Mon Dec 7 17:04:44 2009 Return-Path: Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C9451106566C for ; Mon, 7 Dec 2009 17:04:44 +0000 (UTC) (envelope-from Andre.Albsmeier@siemens.com) Received: from david.siemens.de (david.siemens.de [192.35.17.14]) by mx1.freebsd.org (Postfix) with ESMTP id 4A72F8FC16 for ; Mon, 7 Dec 2009 17:04:43 +0000 (UTC) Received: from mail3.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id nB7Ga7v2010044 for ; Mon, 7 Dec 2009 17:36:07 +0100 Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.40.130]) by mail3.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id nB7Ga7xn026856 for ; Mon, 7 Dec 2009 17:36:07 +0100 Received: (from localhost) by curry.mchp.siemens.de (8.14.3/8.14.3) id nB7Ga7lO073698 for freebsd-mobile@freebsd.org; Mon, 7 Dec 2009 17:36:07 +0100 (CET) Date: Mon, 7 Dec 2009 17:36:07 +0100 From: Andre Albsmeier To: freebsd-mobile@freebsd.org Message-ID: <20091207163607.GA15625@curry.mchp.siemens.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Echelon: X-Advice: Drop that crappy M$-Outlook, I'm tired of your viruses! User-Agent: Mutt/1.5.20 (2009-06-14) Subject: iwi: Possibly wrong interpretation of beacon->number in if_iwi.c? X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Dec 2009 17:04:45 -0000 I am currently using iwi in a rather difficult WLAN environment (multiple APs on the same channel and weak signals). While trying to find out why iwi0 reassociates every 10 to 60 seconds I used sysctl debug.iwi=5 and logged (among others) these messages: ... Beacon state (1, 18941446) Beacon miss: 18941446 >= 254 Beacon state (1, 18941703) Beacon miss: 18941703 >= 254 Beacon state (1, 18941446) ... Trying to understand what this means, I found the corresponding code in /sys/dev/iwi/if_iwi.c: if (le32toh(beacon->number) >= ic->ic_bmissthreshold) { DPRINTF(("Beacon miss: %u >= %u\n", le32toh(beacon->number), ic->ic_bmissthreshold)); ieee80211_beacon_miss(ic); } le32toh(beacon->number) seems to be the number of missed beacons. However, I have no idea how it can be that high after an uptime of only a few minutes. Could it be that only the LSB of this value is meaningful? I added some debug code to if_iwi.c: iwi0: Beacon miss: 19006982 1220606 iwi0: Beacon miss: 19006982 1220606 iwi0: Beacon miss: 19007239 1220707 iwi0: Beacon miss: 19007496 1220808 iwi0: Beacon miss: 19269126 1260606 iwi0: Beacon miss: 19269383 1260707 iwi0: Beacon miss: 19269640 1260808 iwi0: Beacon miss: 19269126 1260606 iwi0: Beacon miss: 19269383 1260707 iwi0: Beacon miss: 19269640 1260808 iwi0: Beacon miss: 19269897 1260909 iwi0: Beacon miss: 19270154 1260a0a iwi0: Beacon miss: 19270411 1260b0b iwi0: Beacon miss: 19269126 1260606 iwi0: Beacon miss: 19006982 1220606 iwi0: Beacon miss: 19006982 1220606 iwi0: Beacon miss: 19007239 1220707 iwi0: Beacon miss: 19006982 1220606 iwi0: Beacon miss: 19007239 1220707 iwi0: Beacon miss: 19007496 1220808 iwi0: Beacon miss: 19007753 1220909 iwi0: Beacon miss: 19008010 1220a0a iwi0: Beacon miss: 19006982 1220606 iwi0: Beacon miss: 19007239 1220707 iwi0: Beacon miss: 19007496 1220808 iwi0: Beacon miss: 19007753 1220909 The second value is le32toh(beacon->number) converted to hex and we see that the two least significant bytes are always the same. This, and the fact that bmissthreshold must be in the range 1 to 255, makes me assume that we possibly should ignore the upper 24 bits. I am now using this patch to if_iwi.c: --- if_iwi.c.ORI 2009-12-07 16:17:46.000000000 +0100 +++ if_iwi.c 2009-12-07 16:20:10.000000000 +0100 @@ -1497,7 +1497,7 @@ /* XXX check struct length */ beacon = (struct iwi_notif_beacon_state *)(notif + 1); - DPRINTFN(5, ("Beacon state (%u, %u)\n", + DPRINTFN(5, ("Beacon state (%u, 0x%x)\n", beacon->state, le32toh(beacon->number))); if (beacon->state == IWI_BEACON_MISS) { @@ -1508,9 +1508,9 @@ * 802.11 layer. * XXX try to roam, drop assoc only on much higher count */ - if (le32toh(beacon->number) >= ic->ic_bmissthreshold) { + if ((le32toh(beacon->number) & 0xFF) >= ic->ic_bmissthreshold) { DPRINTF(("Beacon miss: %u >= %u\n", - le32toh(beacon->number), + le32toh(beacon->number) & 0xFF, ic->ic_bmissthreshold)); ieee80211_beacon_miss(ic); } and things got a lot better. After rising bmissthreshold to 50, which would be perfectly acceptable here, I got no more problems. All this is on a fresh 7.2-STABLE, however, I have upgraded the fw in /sys/contrib/dev/iwi from V3.0 to V3.1 manually (this has no effect on the problem mentioned above). What do people think? Thanks, -Andre From owner-freebsd-mobile@FreeBSD.ORG Tue Dec 8 01:05:25 2009 Return-Path: Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 46EB110656AD for ; Tue, 8 Dec 2009 01:05:25 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.26]) by mx1.freebsd.org (Postfix) with ESMTP id C91C58FC1D for ; Tue, 8 Dec 2009 01:05:24 +0000 (UTC) Received: by ey-out-2122.google.com with SMTP id 22so1283097eye.9 for ; Mon, 07 Dec 2009 17:05:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:cc:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=np5iq4Jg7wPFsFDCaU6gGui1UqX3oiYKq4Vu7kqcO98=; b=RatjpIBaK5r3RtevAq+62iypf5WjfAsJ4c/dvaok/8OhnnuukdMmaWyItWsNIV1Ugn 8CNesWscpkCLQoTsyZPYWYyj/ZkRFgdU8+/cclncDgxw8gYX7mgdw3bo6EQvVRdHFFYH BaL9DlO9/FvL79rispLLd06IWsUbb5EVNmhvg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:cc:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=BYodl8C+oKtk/jMkAH0qof9LkL2OFtTrZ7En8r2axgzvMKJbFm/HbeTF3tXwvY8CVY zd1PzYbsioDyFvP4Jbt94BadBaTongA+0m5AmQO2ZCSFmIcK617I1NLug/pnVds1bLF6 gKN4Gqp3WWgnyTnnYj5mYDjM4xzvHVrgReqkU= Received: by 10.213.46.145 with SMTP id j17mr8117481ebf.8.1260234323818; Mon, 07 Dec 2009 17:05:23 -0800 (PST) Received: from rui-macbook.lan (bl6-157-203.dsl.telepac.pt [82.155.157.203]) by mx.google.com with ESMTPS id 7sm9993005eyb.10.2009.12.07.17.05.22 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 07 Dec 2009 17:05:22 -0800 (PST) Sender: Rui Paulo Message-Id: <9A2736AF-321C-4F39-9AE5-BD436F7C2808@FreeBSD.org> From: Rui Paulo To: Andre Albsmeier In-Reply-To: <20091207163607.GA15625@curry.mchp.siemens.de> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Date: Tue, 8 Dec 2009 01:05:21 +0000 References: <20091207163607.GA15625@curry.mchp.siemens.de> X-Mailer: Apple Mail (2.936) Cc: freebsd-mobile@freebsd.org Subject: Re: iwi: Possibly wrong interpretation of beacon->number in if_iwi.c? X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2009 01:05:25 -0000 On 7 Dec 2009, at 16:36, Andre Albsmeier wrote: > What do people think? This could be a new firmware interface. You might want to check out how the latest Linux driver does this. -- Rui Paulo From owner-freebsd-mobile@FreeBSD.ORG Tue Dec 8 10:42:48 2009 Return-Path: Delivered-To: freebsd-mobile@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 608E0106566C; Tue, 8 Dec 2009 10:42:48 +0000 (UTC) (envelope-from Andre.Albsmeier@siemens.com) Received: from goliath.siemens.de (goliath.siemens.de [192.35.17.28]) by mx1.freebsd.org (Postfix) with ESMTP id E860F8FC12; Tue, 8 Dec 2009 10:42:47 +0000 (UTC) Received: from mail3.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id nB8Agkxu011975; Tue, 8 Dec 2009 11:42:46 +0100 Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.40.130]) by mail3.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id nB8AgkcV014472; Tue, 8 Dec 2009 11:42:46 +0100 Received: (from localhost) by curry.mchp.siemens.de (8.14.3/8.14.3) id nB8Agk0E077549; Date: Tue, 8 Dec 2009 11:42:46 +0100 From: Andre Albsmeier To: Rui Paulo Message-ID: <20091208104246.GA18375@curry.mchp.siemens.de> References: <20091207163607.GA15625@curry.mchp.siemens.de> <9A2736AF-321C-4F39-9AE5-BD436F7C2808@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9A2736AF-321C-4F39-9AE5-BD436F7C2808@FreeBSD.org> X-Echelon: X-Advice: Drop that crappy M$-Outlook, I'm tired of your viruses! User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Andre Albsmeier , freebsd-mobile@FreeBSD.org Subject: Re: iwi: Possibly wrong interpretation of beacon->number in if_iwi.c? X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2009 10:42:48 -0000 On Tue, 08-Dec-2009 at 01:05:21 +0000, Rui Paulo wrote: > On 7 Dec 2009, at 16:36, Andre Albsmeier wrote: > > What do people think? > > > This could be a new firmware interface. You might want to check out > how the latest Linux driver does this. They do it the same way (comparing the whole 32bit ints). I don't know about the firmware interface (no docs). Originally, FreeBSD-6 and FreeBSD-7 use the same fw (V3.0). 8+ uses V3.1. Our code in FreeBSD-6 is the same as in 7. I didn't have problems with 6 in the very same environment, however, I remember I had to raise bmissthreshold a bit which means that I actually had missed beacons (the whole code in question is only triggered on a beacon miss). I don't have any problems at home where I am only 2m away from the AP (possibly no missed beacons there). I have also seen other people report similarly insane numbers. I have also found reports on the net where the values were reasonable. As I said, I use fw V3.1 and not the original V3.0. I did so in FreeBSD-6 as well. To summarise things, here are my observations of how beacon->number behaves with different software: fw3.0 fw3.1 FreeBSD-6 OK OK FreeBSD-7 insane insane "insane" means that in 99% of all cases beacon->number is something like 0xabcdXYXY (abcd can be 0000). Maybe someone who got the docs can jump in here. -Andre