Bug 209328

Summary: ifconfig wlan0 country JP cannot work on iwn(N-6300)
Product: Base System Reporter: Masachika ISHIZUKA <ish>
Component: wirelessAssignee: Andriy Voskoboinyk <avos>
Status: Closed FIXED    
Severity: Affects Only Me CC: avos, ish
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=180682
Attachments:
Description Flags
messages
none
Patch for ifconfig none

Description Masachika ISHIZUKA 2016-05-06 12:05:25 UTC
My PC (dell studio 1558) has N-6300 (iwn driver with iwn6000g2bfw.ko).

'ifconfig wlan0 country JP' is working on 10.3-RELEASE, but isn't working on 11-current (r298976) with message 'iwn0: iwn_setregdomain: invalid channel 8 freq 2447/0x20480'.
Other country (for example, us, de, etc.) is working on 11-current.

N-6300 has 112 nchan when country JP,iwn_setregdomain in if_iwn.c failed iwn_find_eeprom_channel(sc, c) with only 4 nchan. (invalid channel 8 freq 2447/0x20480, invalid channel 9 freq 2452/0x20480, invalid channel 12 freq 2467/0x40480, invalid channel 13 freq 2472/0x40480).

I don't know cause.
Comment 1 Andriy Voskoboinyk freebsd_committer 2016-05-06 12:20:03 UTC
> 'ifconfig wlan0 country JP' is working on 10.3-RELEASE
it's (almost) noop; needed call (ic_getradiocaps) was added only in r293716.
Comment 2 Andriy Voskoboinyk freebsd_committer 2016-05-06 12:25:50 UTC
(In reply to Andriy Voskoboinyk from comment #1)
a bit wrong here; by default, all channels are seen, so this should not change anything (r293716 has another intention).
Comment 3 Andriy Voskoboinyk freebsd_committer 2016-05-06 12:35:15 UTC
> channel 8 freq 2447/0x20480
> channel 9 freq 2452/0x20480
HT40U

> channel 12 freq 2467/0x40480
> channel 13 freq 2472/0x40480
HT40D

looks like a bug in add_channel_ht40(); it shouldn't add them.
Comment 4 Masachika ISHIZUKA 2016-05-06 13:23:13 UTC
(In reply to Andriy Voskoboinyk from comment #3)
Thank you for reply.

I found that 'ifconfig -v wlan0 list chan' on 10.3R and 11-current are defferent.
There are 109 nchans on 10.3R and 113 nchans (109 nchans are identical on 10.3R and 4 are ch8 HT40U, ch9 HT40U, ch12 HT40D, ch13 HT 40D) on 11-current. (N-6300 has 112 nchan was miscount.)

> looks like a bug in add_channel_ht40(); it shouldn't add them.

I'm not check yet, perhaps you are right.  Thank you very much!!!
Comment 5 Andriy Voskoboinyk freebsd_committer 2016-05-06 17:18:57 UTC
Can you execute:
kenv hint.iwn.0.debug=0x40000010
reload the driver and attach dmesg output? (I have no idea where 8 and 9 were picked up (iwn_bands[5] = { 1, 2, 3, 4, 5, 6, 7 }).
Comment 6 Masachika ISHIZUKA 2016-05-07 00:19:26 UTC
(In reply to Andriy Voskoboinyk from comment #5)
Thank you for reply.

But important message didn't appear.
cucumber# kenv hint.iwn.0.debug=0x40000010
hint.iwn.0.debug="0x40000010"
cucumber# kldunload if_iwn
cucumber# kldload if_iwn
cucumber# tail -20 /var/log/messages | sed 's/\(hash=\).*$/\1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/'
May  7 09:02:17 cucumber kernel: iwn0: detached
May  7 09:02:17 cucumber kernel: pci3: <network> at device 0.0 (no driver attached)
May  7 09:02:17 cucumber root: /etc/rc.d/netif: WARNING: wlan0 does not exist.  Skipped.
May  7 09:02:24 cucumber kernel: iwn0: <Intel Centrino Ultimate-N 6300> mem 0xf0500000-0xf0501fff irq 17 at device 0.0 on pci3
May  7 09:02:25 cucumber wpa_supplicant[3227]: Successfully initialized wpa_supplicant
May  7 09:02:25 cucumber kernel: wlan0: Ethernet address: 00:24:d7:06:dc:08
May  7 09:02:25 cucumber kernel: iwn0: iwn_setregdomain: invalid channel 8 freq 2447/0x20480
May  7 09:02:25 cucumber kernel: iwn0: iwn_read_firmware: ucode rev=0x09dd0401
May  7 09:02:25 cucumber kernel: iwn0: iwn_read_firmware: ucode rev=0x09dd0401
May  7 09:02:26 cucumber wpa_supplicant[3228]: wlan0: Trying to associate with dc:fb:02:2b:d9:90 (SSID='ishorg-iNEi4Udw-a' freq=5220 MHz)
May  7 09:02:27 cucumber wpa_supplicant[3228]: wlan0: Associated with dc:fb:02:2b:d9:90
May  7 09:02:27 cucumber kernel: wlan0: link state changed to UP
May  7 09:02:27 cucumber wpa_supplicant[3228]: wlan0: CTRL-EVENT-EAP-STARTED EAP authentication started
May  7 09:02:27 cucumber wpa_supplicant[3228]: wlan0: CTRL-EVENT-EAP-PROPOSED-METHOD vendor=0 method=13
May  7 09:02:27 cucumber wpa_supplicant[3228]: wlan0: CTRL-EVENT-EAP-METHOD EAP vendor 0 method 13 (TLS) selected
May  7 09:02:27 cucumber wpa_supplicant[3228]: wlan0: CTRL-EVENT-EAP-PEER-CERT depth=1 subject='/C=JP/ST=Tokyo/O=ish/CN=cucumber.ish.org/emailAddress=ishizuka@ish.org' hash=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
May  7 09:02:27 cucumber wpa_supplicant[3228]: wlan0: CTRL-EVENT-EAP-PEER-CERT depth=0 subject='/C=JP/ST=Tokyo/L=Suginami/O=ish/CN=gw3.ish.org/emailAddress=ishizuka@ish.org' hash=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
May  7 09:02:27 cucumber wpa_supplicant[3228]: wlan0: CTRL-EVENT-EAP-SUCCESS EAP authentication completed successfully
May  7 09:02:27 cucumber wpa_supplicant[3228]: wlan0: WPA: Key negotiation completed with dc:fb:02:2b:d9:90 [PTK=CCMP GTK=CCMP]
May  7 09:02:27 cucumber wpa_supplicant[3228]: wlan0: CTRL-EVENT-CONNECTED - Connection to dc:fb:02:2b:d9:90 completed [id=0 id_str=]
Comment 7 Andriy Voskoboinyk freebsd_committer 2016-05-07 00:27:00 UTC
(In reply to Masachika ISHIZUKA from comment #6)
Ok, I forget about debug options. Try to add 'options IWN_DEBUG' to the kernel config and rebuild/reinstall it.
Comment 8 Masachika ISHIZUKA 2016-05-07 01:46:34 UTC
Created attachment 170075 [details]
messages

This is messages.
Comment 9 Andriy Voskoboinyk freebsd_committer 2016-05-07 07:06:11 UTC
Ok; as I can see, there are (overall) 123 channels + country JP should filter out
the highest band (149, 153, 157, 161, 165) (-10 channels) and two pairs of ht40
channels (149+/153- and 157+/161- - they are also present in the list) (-> should
be 109 channels). There is no channel 8+/9+/12-/13- in the logfile; so, the
problem is not in the driver (probably, ifconfig/lib80211?) + also:

> Other country (for example, us, de, etc.) is working on 11-current.

There are only two regdomains, which allow 12 and 13 HT40 channels: NONE and JAPAN.
Comment 10 Andriy Voskoboinyk freebsd_committer 2016-05-07 07:47:20 UTC
here (ifieee80211.c):

> /* NB: we use an HT40 channel center that matches HT20 */
> flags = (flags &~ IEEE80211_CHAN_HT40) | IEEE80211_CHAN_HT20;
Comment 11 Andriy Voskoboinyk freebsd_committer 2016-05-07 08:05:23 UTC
Created attachment 170081 [details]
Patch for ifconfig

Try to apply it to the src tree and rebuild/reinstall ifconfig.
Comment 12 Masachika ISHIZUKA 2016-05-07 11:32:05 UTC
(In reply to Andriy Voskoboinyk from comment #11)
Thank you!!!

This patch works fine.  I can set country JP with no errors.
'ifconfig -v wlan0 list chan' shows 109 nchans correctly.
Comment 13 commit-hook freebsd_committer 2016-05-09 16:16:15 UTC
A commit references this bug:

Author: avos
Date: Mon May  9 16:15:52 UTC 2016
New revision: 299264
URL: https://svnweb.freebsd.org/changeset/base/299264

Log:
  ifconfig: fix check for 40 MHz channels while applying country/regdomain.

  Do not use 20 MHz channel list while checking 40 MHz channels;
  it may be different. Just use the corresponding list instead.

  Tested by:	Masachika ISHIZUKA <ish@amail.plala.or.jp>

  PR:		209328

Changes:
  head/sbin/ifconfig/ifieee80211.c
Comment 14 Masachika ISHIZUKA 2016-05-10 01:37:19 UTC
(In reply to commit-hook from comment #13)
Thank you for updating HEAD.

It works well on r299288.