From owner-freebsd-current@FreeBSD.ORG Thu Dec 7 12:28:17 2006 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 497CE16A407 for ; Thu, 7 Dec 2006 12:28:17 +0000 (UTC) (envelope-from shigeru@iij.ad.jp) Received: from otm-mgo01.iij.ad.jp (otm-mgo01.iij.ad.jp [210.138.20.175]) by mx1.FreeBSD.org (Postfix) with ESMTP id 43C6E43E1B for ; Thu, 7 Dec 2006 12:22:36 +0000 (GMT) (envelope-from shigeru@iij.ad.jp) Received: OTM-MO(otm-mgo01) id kB7CNBBm038638; Thu, 7 Dec 2006 21:23:11 +0900 (JST) DKIM-Signature: a=rsa-sha1; c=relaxed/simple; d=iij.ad.jp; s=omgo0; t=1165494191; bh=dMn05j9KLcXZZG9SDM85HKaHKp8=; h=Received:Received: Date:Message-Id:To:Subject:From:In-Reply-To:References:X-Mailer: Mime-Version:Content-Type:Content-Transfer-Encoding; b=oB3/e5gYqXOa NYtiV++rFaabGH85+7iaQTFyfT3HocGMhuacYBIm7vVK7PxRhzKE2hzY3yExtt31JaZ cARyDWx9pspSiBMLrgxC/ZCAonGu0xOTzROb5VX6ZCatkmcswpWAKPQmtYb0r6+oj/0 IC8REWvy1dL966RzucAzAVRgU= Received: OTM-MIX(otm-mix00) id kB7CNBF9037771; Thu, 7 Dec 2006 21:23:11 +0900 (JST) Received: from localhost (mercury.iij.ad.jp [192.168.184.90]) by rsmtp.iij.ad.jp (OTM-MR/rsmtp01) id kB7CN8Op060972 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 7 Dec 2006 21:23:11 +0900 (JST) Date: Thu, 07 Dec 2006 21:23:08 +0900 (JST) Message-Id: <20061207.212308.32463430.shigeru@iij.ad.jp> To: freebsd-current@freebsd.org From: YAMAMOTO Shigeru In-Reply-To: <456271B3.4060701@errno.com> References: <20061121.100736.48665070.shigeru@iij.ad.jp> <456271B3.4060701@errno.com> X-Mailer: Mew version 5.1 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Thu_Dec__7_21_23_08_2006_784)--" Content-Transfer-Encoding: 7bit Subject: Re: how to get supported channels from iwi firmware X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Dec 2006 12:28:17 -0000 ----Next_Part(Thu_Dec__7_21_23_08_2006_784)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit >>>>> "Sam" == Sam Leffler writes: >> I'm using iwi(Intel(R) PRO/Wireless 2915ABG). iwi driver does not >> support 802.11j channels (34, 38, 42, 46) which channles are used in >> Japan. # a channel set, 34, 38, 42, 46 is called 'J52' in Japan. >> >> So, I fix iwi to support 802.11j channels. But it is no good fix. >> >> I think it is better to get supported channels list from iwi firmware. >> Does anybody know how to get supported channels list from iwi firmware? Sam> It's in the EEPROM. I don't recall if the linux driver even does that Sam> but maybe a recent version does so check there. I check Linux driver code at http://ipw2200.sourceforge.net/ I create new patch to get channel information from EEPROM. I test it at on my NotePC. Currently, I hove no trouble. But I don't to know my patch is right or not. Because, Linux driver does not use channel information. ;-( Linux driver only uses country code in EEPROM. So default setting in my patch is using only country code. If set 'USE_IWI_EEPROM_CHANNELS', my patch uses channel information in EEPROM. Please try my patch if you have interest my patch. Thanks, ------- YAMAMOTO Shigeru ----Next_Part(Thu_Dec__7_21_23_08_2006_784)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="iwi.eeprom.diff" Index: sys/dev/iwi/if_iwi.c =================================================================== RCS file: /share/cvsup/FreeBSD/current/usr/src/sys/dev/iwi/if_iwi.c,v retrieving revision 1.43 diff -u -r1.43 if_iwi.c --- sys/dev/iwi/if_iwi.c 6 Dec 2006 21:23:51 -0000 1.43 +++ sys/dev/iwi/if_iwi.c 7 Dec 2006 02:27:34 -0000 @@ -395,6 +395,32 @@ IEEE80211_C_WPA | /* 802.11i */ IEEE80211_C_WME; /* 802.11e */ + /* read EEPROM */ + for (i = 0; i < IWI_EEPROM_SIZE/2; i ++) { + sc->sc_eeprom.eeprom16[i] = iwi_read_prom_word(sc, i); + } + device_printf(dev, "IWI_EEPROM:\n"); + for (i = 0; i < IWI_EEPROM_SIZE/2; i ++) { + if (i % 16 == 0) { + printf("\n"); + } + printf(" %04x", sc->sc_eeprom.eeprom16[i]); + } + printf("\n"); + device_printf(dev, "IWI_EEPROM_VERSION: %d\n", sc->sc_eeprom.eeprom8[IWI_EEPROM_VERSION*2 + 1]); + device_printf(dev, "IWI_EEPROM_HW_VERSION: 0x%04x\n", sc->sc_eeprom.eeprom16[IWI_EEPROM_HW_VERSION]); + device_printf(dev, "IWI_EEPROM_COUNTRY_CODE: %c%c%c\n", sc->sc_eeprom.eeprom8[IWI_EEPROM_COUNTRY_CODE*2], sc->sc_eeprom.eeprom8[IWI_EEPROM_COUNTRY_CODE*2 + 1] , sc->sc_eeprom.eeprom8[IWI_EEPROM_COUNTRY_CODE*2 + 2]); + device_printf(dev, "IWI_EEPROM_BSS_CHANNELS_BG:"); + for (i = 0; i < 2; i ++) { + printf(" %02x", sc->sc_eeprom.eeprom8[IWI_EEPROM_BSS_CHANNELS_BG*2 + i]); + } + printf("\n"); + device_printf(dev, "IWI_EEPROM_BSS_CHANNELS_A:"); + for (i = 0; i < 5; i ++) { + printf(" %02x", sc->sc_eeprom.eeprom8[IWI_EEPROM_BSS_CHANNELS_A*2 + i]); + } + printf("\n"); + /* read MAC address from EEPROM */ val = iwi_read_prom_word(sc, IWI_EEPROM_MAC + 0); ic->ic_myaddr[0] = val & 0xff; @@ -410,12 +436,40 @@ /* set supported .11a rates (2915ABG only) */ ic->ic_sup_rates[IEEE80211_MODE_11A] = iwi_rateset_11a; +#if defined(USE_IWI_EEPROM_CHANNELS) + for (i = 0; i < 5*8; i ++) { + if ((sc->sc_eeprom.eeprom8[IWI_EEPROM_IBSS_CHANNELS_A*2 + i/8] >> (i % 8)) & 0x01) { + int ch = (i+1)*2; + + ic->ic_channels[ch].ic_freq = + ieee80211_ieee2mhz(ch, IEEE80211_CHAN_5GHZ); + ic->ic_channels[ch].ic_flags = IEEE80211_CHAN_A; + } + if ((sc->sc_eeprom.eeprom8[IWI_EEPROM_BSS_CHANNELS_A*2 + i/8] >> (i % 8)) & 0x01) { + int ch = (i+1)*2; + + ic->ic_channels[ch].ic_freq = + ieee80211_ieee2mhz(ch, IEEE80211_CHAN_5GHZ); + ic->ic_channels[ch].ic_flags = IEEE80211_CHAN_A; + } + } +#else + if (memcmp(&(sc->sc_eeprom.eeprom8[IWI_EEPROM_COUNTRY_CODE*2]), "ZZJ", 3) == 0) { + /* set supported .11a(802.11j) channels, which is used in Japan */ + for (i = 34; i <= 46; i += 4) { + ic->ic_channels[i].ic_freq = + ieee80211_ieee2mhz(i, IEEE80211_CHAN_5GHZ); + ic->ic_channels[i].ic_flags = IEEE80211_CHAN_A; + } + } + /* set supported .11a channels */ for (i = 36; i <= 64; i += 4) { ic->ic_channels[i].ic_freq = ieee80211_ieee2mhz(i, IEEE80211_CHAN_5GHZ); ic->ic_channels[i].ic_flags = IEEE80211_CHAN_A; } +#endif for (i = 149; i <= 165; i += 4) { ic->ic_channels[i].ic_freq = ieee80211_ieee2mhz(i, IEEE80211_CHAN_5GHZ); @@ -428,6 +482,28 @@ ic->ic_sup_rates[IEEE80211_MODE_11G] = iwi_rateset_11g; /* set supported .11b and .11g channels (1 through 14) */ +#if defined(USE_IWI_EEPROM_CHANNELS) + for (i = 0; i < 2*8 - 1; i ++) { + if ((sc->sc_eeprom.eeprom8[IWI_EEPROM_IBSS_CHANNELS_BG*2 + i/8] >> (i % 8)) & 0x01) { + int ch = (i+1); + + ic->ic_channels[ch].ic_freq = + ieee80211_ieee2mhz(ch, IEEE80211_CHAN_2GHZ); + ic->ic_channels[ch].ic_flags = + IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | + IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ; + } + if ((sc->sc_eeprom.eeprom8[IWI_EEPROM_BSS_CHANNELS_BG*2 + i/8] >> (i % 8)) & 0x01) { + int ch = (i+1); + + ic->ic_channels[ch].ic_freq = + ieee80211_ieee2mhz(ch, IEEE80211_CHAN_2GHZ); + ic->ic_channels[ch].ic_flags = + IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | + IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ; + } + } +#else for (i = 1; i <= 14; i++) { ic->ic_channels[i].ic_freq = ieee80211_ieee2mhz(i, IEEE80211_CHAN_2GHZ); @@ -435,6 +511,7 @@ IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ; } +#endif ieee80211_ifattach(ic); ic->ic_bmissthreshold = 10; /* override default */ Index: sys/dev/iwi/if_iwireg.h =================================================================== RCS file: /share/cvsup/FreeBSD/current/usr/src/sys/dev/iwi/if_iwireg.h,v retrieving revision 1.13 diff -u -r1.13 if_iwireg.h --- sys/dev/iwi/if_iwireg.h 23 Oct 2006 00:34:07 -0000 1.13 +++ sys/dev/iwi/if_iwireg.h 21 Nov 2006 08:31:51 -0000 @@ -476,9 +476,19 @@ #define IWI_MEM_EEPROM_EVENT 0x00300004 #define IWI_MEM_EEPROM_CTL 0x00300040 +#define IWI_EEPROM_SIZE (256) + +#define IWI_EEPROM_PME_CAPABILITY 0x09 /* 1 octet (msb) */ #define IWI_EEPROM_MAC 0x21 +#define IWI_EEPROM_VERSION 0x24 /* 1 octet (msb) */ #define IWI_EEPROM_NIC 0x25 /* nic type (lsb) */ #define IWI_EEPROM_SKU 0x25 /* nic type (msb) */ +#define IWI_EEPROM_COUNTRY_CODE 0x26 /* 3 octets (lsb) */ +#define IWI_EEPROM_IBSS_CHANNELS_BG 0x28 /* 2 octets (lsb) */ +#define IWI_EEPROM_IBSS_CHANNELS_A 0x29 /* 5 octets (msb) */ +#define IWI_EEPROM_BSS_CHANNELS_BG 0x2c /* 2 octets (lsb) */ +#define IWI_EEPROM_BSS_CHANNELS_A 0x2d /* 5 octets (msb) */ +#define IWI_EEPROM_HW_VERSION 0x72 /* 2 octets (lsb) */ #define IWI_EEPROM_DELAY 1 /* minimum hold time (microsecond) */ Index: sys/dev/iwi/if_iwivar.h =================================================================== RCS file: /share/cvsup/FreeBSD/current/usr/src/sys/dev/iwi/if_iwivar.h,v retrieving revision 1.11 diff -u -r1.11 if_iwivar.h --- sys/dev/iwi/if_iwivar.h 27 Apr 2006 21:43:37 -0000 1.11 +++ sys/dev/iwi/if_iwivar.h 21 Nov 2006 08:54:48 -0000 @@ -209,6 +209,11 @@ } sc_txtapu; #define sc_txtap sc_txtapu.th int sc_txtap_len; + + union { + uint8_t eeprom8[IWI_EEPROM_SIZE]; + uint16_t eeprom16[IWI_EEPROM_SIZE/2]; + } sc_eeprom; }; /* ----Next_Part(Thu_Dec__7_21_23_08_2006_784)----