NetBSD Problem Report #50187

From www@NetBSD.org  Tue Sep  1 22:54:55 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 36D62A5B2E
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  1 Sep 2015 22:54:55 +0000 (UTC)
Message-Id: <20150901225453.DAF96A6554@mollari.NetBSD.org>
Date: Tue,  1 Sep 2015 22:54:53 +0000 (UTC)
From: ottavio2006-netbsd@yahoo.com
Reply-To: ottavio2006-netbsd@yahoo.com
To: gnats-bugs@NetBSD.org
Subject: iwn0: frequency and channel mismatch
X-Send-Pr-Version: www-1.0

>Number:         50187
>Category:       kern
>Synopsis:       iwn0: frequency and channel mismatch
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 01 22:55:00 +0000 2015
>Closed-Date:    Mon Nov 16 06:57:47 +0000 2015
>Last-Modified:  Mon Nov 16 06:57:47 +0000 2015
>Originator:     Ottavio Caruso
>Release:        NetBSD 7.0_RC3
>Organization:
>Environment:
NetBSD X61 7.0_RC3 NetBSD 7.0_RC3 (GENERIC.201508110747Z) amd64
>Description:
Thinkpad X61 with a 4965AGN wireless Intel card. I can connect to
a 5Ghz fine with Linux or Windows 7, but not NetBSD.

The latter sees the access point as a normal 2.4 Ghz host on channel 11:

#wlanctl iwn0
iwn0: mac e0:3f:49:6a:87:ec bss e0:3f:49:6a:87:ec
        node flags 0004<scan>
        ess <5Ghz-access-point>
        chan 11 freq 2462MHz flags 04e0<cck,ofdm,2.4GHz,dynamic cck-ofdm>
        capabilities 0111<ess,privacy>
        beacon-interval 100 TU tsft 337491046458 us
        rates *6.0 9.0 *12.0 18.0 *24.0 36.0 48.0 [54.0]
        assoc-id 0 assoc-failed 0 inactivity 300s
        rssi 194 txseq 0 rxseq 62496

The interface tries to connect to the AP but fails.

The channel and the frequency reported are wrong.

This his how Linux (System Rescue CD) sees it

root@sysresccd /root % iwlist wls3 scan
wls3      Scan completed :
          Cell 01 - Address: E0:3F:49:6A:87:EC
                    Channel:48
                    Frequency:5.24 GHz (Channel 48)
                    Quality=45/70  Signal level=-65 dBm
                    Encryption key:on
                    ESSID:"5Ghz-access-point"
                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s
                              36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=0000004e0f09fba8
                    Extra: Last beacon: 54ms ago
                    IE: Unknown:
00204269726D696E6768616D43656E7472616C4261636B7061636B6572733547687A
                    IE: Unknown: 01088C129824B048606C
                    IE: Unknown:
073C4742202401172801172C01173001173401173801173C011740011764011E68011E6C011E70011E74011E78011E7C011E80011E84011E88011E8C011E
                    IE: Unknown: 200100
                    IE: Unknown: 23021000
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : CCMP TKIP
                        Authentication Suites (1) : PSK
                    IE: Unknown:
2D1AED091BFFFFFF0000000000000000000000000000000000000000
                    IE: Unknown:
3D1630080400000000000000000000000000000000000000
                    IE: Unknown: DD090010180205F03C0000
                    IE: WPA Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : CCMP TKIP
                        Authentication Suites (1) : PSK
                    IE: Unknown:
DD180050F2020101800003A4000027A4000042435E0062322F00

No problem accessing this access point under Linux.

Both Linux and NetBSD use /lib/firmware/iwlwifi-4965-2.ucode.


>How-To-Repeat:
1) wpa_gui &
2) Press "scan"
3) Analyse scan result
4) View Event history

Alternatively:
1) wlanctl iwn0 
2) Compare results with Linux iwlist wls3 scan
>Fix:

>Release-Note:

>Audit-Trail:
From: NONAKA Kimihiro <nonakap@gmail.com>
To: "gnats-bugs@netbsd.org" <gnats-bugs@netbsd.org>
Cc: kern-bug-people@netbsd.org, 
	"gnats-admin@netbsd.org" <gnats-admin@netbsd.org>, "netbsd-bugs@netbsd.org" <netbsd-bugs@netbsd.org>
Subject: Re: kern/50187: iwn0: frequency and channel mismatch
Date: Tue, 22 Sep 2015 20:05:47 +0900

 Hi,

 iwn(4) can handle 5GHz channel by this patch.
 However, channel probably needs to be set manually.

 Please try it.
 probably
 diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c
 index 7f5ca3d..04a4b06 100644
 --- a/sys/dev/pci/if_iwn.c
 +++ b/sys/dev/pci/if_iwn.cprobably
 @@ -330,7 +330,8 @@ static u_int8_t    *ieee80211_add_rates(u_int8_t *,
  static u_int8_t    *ieee80211_add_xrates(u_int8_t *,
      const struct ieee80211_rateset *);

 -static void    iwn_fix_channel(struct ieee80211com *, struct mbuf *);
 +static void    iwn_fix_channel(struct ieee80211com *, struct mbuf *,
 +            struct iwn_rx_stat *);

  #ifdef IWN_DEBUG
  #define DPRINTF(x)    do { if (iwn_debug > 0) printf x; } while (0)
 @@ -1866,7 +1867,7 @@ iwn_newstate(struct ieee80211com *ic, enum
 ieee80211_state nstate, int arg)
          /* XXX Not sure if call and flags are needed. */
          ieee80211_node_table_reset(&ic->ic_scan);
          ic->ic_flags |= IEEE80211_F_SCAN | IEEE80211_F_ASCAN;
 -        sc->sc_flags |= IWN_FLAG_SCANNING;
 +        sc->sc_flags |= IWN_FLAG_SCANNING_2GHZ;

          /* Make the link LED blink while we're scanning. */
          iwn_set_led(sc, IWN_LED_LINK, 10, 10);
 @@ -2089,7 +2090,7 @@ iwn_rx_done(struct iwn_softc *sc, struct
 iwn_rx_desc *desc,

      /* XXX Added for NetBSD: scans never stop without it */
      if (ic->ic_state == IEEE80211_S_SCAN)
 -        iwn_fix_channel(ic, m);
 +        iwn_fix_channel(ic, m, stat);

      if (sc->sc_drvbpf != NULL) {
          struct iwn_rx_radiotap_header *tap = &sc->sc_rxtap;
 @@ -2520,6 +2521,8 @@ iwn_notif_intr(struct iwn_softc *sc)
                   * We just finished scanning 2GHz channels,
                   * start scanning 5GHz ones.
                   */
 +                sc->sc_flags &= ~IWN_FLAG_SCANNING_2GHZ;
 +                sc->sc_flags |= IWN_FLAG_SCANNING_5GHZ;
                  if (iwn_scan(sc, IEEE80211_CHAN_5GHZ) == 0)
                      break;
              }
 @@ -6506,8 +6512,10 @@ ieee80211_add_xrates(u_int8_t *frm, const
 struct ieee80211_rateset *rs)
   * XXX: Duplicated from if_iwi.c
   */
  static void
 -iwn_fix_channel(struct ieee80211com *ic, struct mbuf *m)
 +iwn_fix_channel(struct ieee80211com *ic, struct mbuf *m,
 +    struct iwn_rx_stat *stat)
  {
 +    struct iwn_softc *sc = ic->ic_ifp->if_softc;
      struct ieee80211_frame *wh;
      uint8_t subtype;
      uint8_t *frm, *efrm;
 @@ -6523,6 +6531,13 @@ iwn_fix_channel(struct ieee80211com *ic, struct mbuf *m)
          subtype != IEEE80211_FC0_SUBTYPE_PROBE_RESP)
          return;

 +    if (sc->sc_flags & IWN_FLAG_SCANNING_5GHZ) {
 +        int chan = le16toh(stat->chan);
 +        if (chan < __arraycount(ic->ic_channels))
 +            ic->ic_curchan = &ic->ic_channels[chan];
 +        return;
 +    }
 +
      frm = (uint8_t *)(wh + 1);
      efrm = mtod(m, uint8_t *) + m->m_len;

 diff --git a/sys/dev/pci/if_iwnvar.h b/sys/dev/pci/if_iwnvar.h
 index d104c62..05989bb 100644
 --- a/sys/dev/pci/if_iwnvar.h
 +++ b/sys/dev/pci/if_iwnvar.h
 @@ -221,8 +221,10 @@ struct iwn_softc {
  #define IWN_FLAG_HAS_11N    (1 << 6)
  #define IWN_FLAG_ENH_SENS    (1 << 7)probably
  /* Added for NetBSD */
 -#define IWN_FLAG_SCANNING    (1 << 8)
 -#define IWN_FLAG_HW_INITED    (1 << 9)
 +#define IWN_FLAG_HW_INITED    (1 << 8)
 +#define IWN_FLAG_SCANNING_2GHZ    (1 << 9)
 +#define IWN_FLAG_SCANNING_5GHZ    (1 << 10)
 +#define IWN_FLAG_SCANNING    (IWN_FLAG_SCANNING_2GHZ|IWN_FLAG_SCANNING_5GHZ)

      uint8_t         hw_type;

From: Ottavio Caruso <ottavio2006-netbsd@yahoo.com>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, 
	tech-net@netbsd.org, netbsd-users@netbsd.org
Subject: Re: kern/50187: iwn0: frequency and channel mismatch
Date: Tue, 22 Sep 2015 21:32:19 +0000

 On 22 September 2015 at 11:10, NONAKA Kimihiro <nonakap@gmail.com> wrote:

 >
 >  Hi,
 >
 >  iwn(4) can handle 5GHz channel by this patch.
 >  However, channel probably needs to be set manually.
 >
 >  Please try it.
 >  probably
 >  diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c
 <--snip-->

 Using precompiled kernel with this patch as provided by NONAKA Kimihiro at:
 http://ftp.netbsd.org/pub/NetBSD/misc/nonaka/tmp/20150922-iwn-netbsd-GENERIC-nb7.xz

 The issue seems solved.

 I can now see the 5Ghz access point with the correct frequency and channel:

 bash-4.3$ sudo ifconfig iwn0 list scan
 SSID                              BSSID              CHAN RATE  S:N     INT CAPS

 *******5Ghz  e0:3f:49:6a:87:ec   40   54M 149:0    100 EP   WPA WME

 I can connect to the access point fine with wpa_gui and I don't even
 need to set the channel to 40.

 I haven't stress-tested but I think this can be marked as a success. Well done
 Nonaka!

 Is this patch going to be incorporated into upstream kernel any soon?

 -- 
 Ottavio

From: "NONAKA Kimihiro" <nonaka@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/50187 CVS commit: src/sys/dev/pci
Date: Tue, 22 Sep 2015 23:23:06 +0000

 Module Name:	src
 Committed By:	nonaka
 Date:		Tue Sep 22 23:23:06 UTC 2015

 Modified Files:
 	src/sys/dev/pci: if_iwn.c if_iwnvar.h

 Log Message:
 PR/50187: Don't use DS parameter set when 5GHz channel is scanning.

 XXX: pullup-7


 To generate a diff of this commit:
 cvs rdiff -u -r1.75 -r1.76 src/sys/dev/pci/if_iwn.c
 cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pci/if_iwnvar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/50187 CVS commit: [netbsd-7] src/sys/dev/pci
Date: Fri, 6 Nov 2015 00:50:52 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Fri Nov  6 00:50:52 UTC 2015

 Modified Files:
 	src/sys/dev/pci [netbsd-7]: if_iwn.c if_iwnvar.h

 Log Message:
 Pull up following revision(s) (requested by nonaka in ticket #987):
 	sys/dev/pci/if_iwnvar.h: revision 1.17
 	sys/dev/pci/if_iwn.c: revision 1.76
 PR/50187: Don't use DS parameter set when 5GHz channel is scanning.
 XXX: pullup-7


 To generate a diff of this commit:
 cvs rdiff -u -r1.71.4.1 -r1.71.4.2 src/sys/dev/pci/if_iwn.c
 cvs rdiff -u -r1.15.4.1 -r1.15.4.2 src/sys/dev/pci/if_iwnvar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Manuel Bouyer" <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/50187 CVS commit: [netbsd-6] src/sys/dev/pci
Date: Sun, 15 Nov 2015 20:27:35 +0000

 Module Name:	src
 Committed By:	bouyer
 Date:		Sun Nov 15 20:27:35 UTC 2015

 Modified Files:
 	src/sys/dev/pci [netbsd-6]: if_iwn.c if_iwnvar.h

 Log Message:
 Pull up following revision(s) (requested by nonaka in ticket #1330):
 	sys/dev/pci/if_iwnvar.h: revision 1.17
 	sys/dev/pci/if_iwn.c: revision 1.76
 PR/50187: Don't use DS parameter set when 5GHz channel is scanning.
 XXX: pullup-7


 To generate a diff of this commit:
 cvs rdiff -u -r1.62 -r1.62.2.1 src/sys/dev/pci/if_iwn.c
 cvs rdiff -u -r1.13 -r1.13.10.1 src/sys/dev/pci/if_iwnvar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: msaitoh@NetBSD.org
State-Changed-When: Mon, 16 Nov 2015 06:57:47 +0000
State-Changed-Why:
Pulled up.
Thanks.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.