Deleted Added
full compact
if_wpi.c (190462) if_wpi.c (190526)
1/*-
2 * Copyright (c) 2006,2007
3 * Damien Bergamini <damien.bergamini@free.fr>
4 * Benjamin Close <Benjamin.Close@clearchain.com>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.

--- 5 unchanged lines hidden (view full) ---

14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#define VERSION "20071127"
20
21#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2006,2007
3 * Damien Bergamini <damien.bergamini@free.fr>
4 * Benjamin Close <Benjamin.Close@clearchain.com>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.

--- 5 unchanged lines hidden (view full) ---

14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#define VERSION "20071127"
20
21#include <sys/cdefs.h>
22__FBSDID("$FreeBSD: head/sys/dev/wpi/if_wpi.c 190462 2009-03-27 05:44:53Z jmallett $");
22__FBSDID("$FreeBSD: head/sys/dev/wpi/if_wpi.c 190526 2009-03-29 17:59:14Z sam $");
23
24/*
25 * Driver for Intel PRO/Wireless 3945ABG 802.11 network adapters.
26 *
27 * The 3945ABG network adapter doesn't use traditional hardware as
28 * many other adaptors do. Instead at run time the eeprom is set into a known
29 * state and told to load boot firmware. The boot firmware loads an init and a
30 * main binary firmware image into SRAM on the card via DMA.

--- 175 unchanged lines hidden (view full) ---

206static int wpi_raw_xmit(struct ieee80211_node *, struct mbuf *,
207 const struct ieee80211_bpf_params *);
208static void wpi_scan_start(struct ieee80211com *);
209static void wpi_scan_end(struct ieee80211com *);
210static void wpi_set_channel(struct ieee80211com *);
211static void wpi_scan_curchan(struct ieee80211_scan_state *, unsigned long);
212static void wpi_scan_mindwell(struct ieee80211_scan_state *);
213static int wpi_ioctl(struct ifnet *, u_long, caddr_t);
23
24/*
25 * Driver for Intel PRO/Wireless 3945ABG 802.11 network adapters.
26 *
27 * The 3945ABG network adapter doesn't use traditional hardware as
28 * many other adaptors do. Instead at run time the eeprom is set into a known
29 * state and told to load boot firmware. The boot firmware loads an init and a
30 * main binary firmware image into SRAM on the card via DMA.

--- 175 unchanged lines hidden (view full) ---

206static int wpi_raw_xmit(struct ieee80211_node *, struct mbuf *,
207 const struct ieee80211_bpf_params *);
208static void wpi_scan_start(struct ieee80211com *);
209static void wpi_scan_end(struct ieee80211com *);
210static void wpi_set_channel(struct ieee80211com *);
211static void wpi_scan_curchan(struct ieee80211_scan_state *, unsigned long);
212static void wpi_scan_mindwell(struct ieee80211_scan_state *);
213static int wpi_ioctl(struct ifnet *, u_long, caddr_t);
214static void wpi_read_eeprom(struct wpi_softc *);
214static void wpi_read_eeprom(struct wpi_softc *,
215 uint8_t macaddr[IEEE80211_ADDR_LEN]);
215static void wpi_read_eeprom_channels(struct wpi_softc *, int);
216static void wpi_read_eeprom_group(struct wpi_softc *, int);
217static int wpi_cmd(struct wpi_softc *, int, const void *, int, int);
218static int wpi_wme_update(struct ieee80211com *);
219static int wpi_mrr_setup(struct wpi_softc *);
220static void wpi_set_led(struct wpi_softc *, uint8_t, uint8_t, uint8_t);
221static void wpi_enable_tsf(struct wpi_softc *, struct ieee80211_node *);
222#if 0

--- 265 unchanged lines hidden (view full) ---

488wpi_attach(device_t dev)
489{
490 struct wpi_softc *sc = device_get_softc(dev);
491 struct ifnet *ifp;
492 struct ieee80211com *ic;
493 int ac, error, supportsa = 1;
494 uint32_t tmp;
495 const struct wpi_ident *ident;
216static void wpi_read_eeprom_channels(struct wpi_softc *, int);
217static void wpi_read_eeprom_group(struct wpi_softc *, int);
218static int wpi_cmd(struct wpi_softc *, int, const void *, int, int);
219static int wpi_wme_update(struct ieee80211com *);
220static int wpi_mrr_setup(struct wpi_softc *);
221static void wpi_set_led(struct wpi_softc *, uint8_t, uint8_t, uint8_t);
222static void wpi_enable_tsf(struct wpi_softc *, struct ieee80211_node *);
223#if 0

--- 265 unchanged lines hidden (view full) ---

489wpi_attach(device_t dev)
490{
491 struct wpi_softc *sc = device_get_softc(dev);
492 struct ifnet *ifp;
493 struct ieee80211com *ic;
494 int ac, error, supportsa = 1;
495 uint32_t tmp;
496 const struct wpi_ident *ident;
497 uint8_t macaddr[IEEE80211_ADDR_LEN];
496
497 sc->sc_dev = dev;
498
499 if (bootverbose || WPI_DEBUG_SET)
500 device_printf(sc->sc_dev,"Driver Revision %s\n", VERSION);
501
502 /*
503 * Some card's only support 802.11b/g not a, check to see if

--- 141 unchanged lines hidden (view full) ---

645 | IEEE80211_C_HOSTAP /* Host access point mode */
646#endif
647 ;
648
649 /*
650 * Read in the eeprom and also setup the channels for
651 * net80211. We don't set the rates as net80211 does this for us
652 */
498
499 sc->sc_dev = dev;
500
501 if (bootverbose || WPI_DEBUG_SET)
502 device_printf(sc->sc_dev,"Driver Revision %s\n", VERSION);
503
504 /*
505 * Some card's only support 802.11b/g not a, check to see if

--- 141 unchanged lines hidden (view full) ---

647 | IEEE80211_C_HOSTAP /* Host access point mode */
648#endif
649 ;
650
651 /*
652 * Read in the eeprom and also setup the channels for
653 * net80211. We don't set the rates as net80211 does this for us
654 */
653 wpi_read_eeprom(sc);
655 wpi_read_eeprom(sc, macaddr);
654
655 if (bootverbose || WPI_DEBUG_SET) {
656 device_printf(sc->sc_dev, "Regulatory Domain: %.4s\n", sc->domain);
657 device_printf(sc->sc_dev, "Hardware Type: %c\n",
658 sc->type > 1 ? 'B': '?');
659 device_printf(sc->sc_dev, "Hardware Revision: %c\n",
660 ((le16toh(sc->rev) & 0xf0) == 0xd0) ? 'D': '?');
661 device_printf(sc->sc_dev, "SKU %s support 802.11a\n",

--- 8 unchanged lines hidden (view full) ---

670 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
671 ifp->if_init = wpi_init;
672 ifp->if_ioctl = wpi_ioctl;
673 ifp->if_start = wpi_start;
674 IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
675 ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
676 IFQ_SET_READY(&ifp->if_snd);
677
656
657 if (bootverbose || WPI_DEBUG_SET) {
658 device_printf(sc->sc_dev, "Regulatory Domain: %.4s\n", sc->domain);
659 device_printf(sc->sc_dev, "Hardware Type: %c\n",
660 sc->type > 1 ? 'B': '?');
661 device_printf(sc->sc_dev, "Hardware Revision: %c\n",
662 ((le16toh(sc->rev) & 0xf0) == 0xd0) ? 'D': '?');
663 device_printf(sc->sc_dev, "SKU %s support 802.11a\n",

--- 8 unchanged lines hidden (view full) ---

672 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
673 ifp->if_init = wpi_init;
674 ifp->if_ioctl = wpi_ioctl;
675 ifp->if_start = wpi_start;
676 IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
677 ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
678 IFQ_SET_READY(&ifp->if_snd);
679
678 ieee80211_ifattach(ic);
680 ieee80211_ifattach(ic, macaddr);
679 /* override default methods */
680 ic->ic_node_alloc = wpi_node_alloc;
681 ic->ic_newassoc = wpi_newassoc;
682 ic->ic_raw_xmit = wpi_raw_xmit;
683 ic->ic_wme.wme_update = wpi_wme_update;
684 ic->ic_scan_start = wpi_scan_start;
685 ic->ic_scan_end = wpi_scan_end;
686 ic->ic_set_channel = wpi_set_channel;

--- 1458 unchanged lines hidden (view full) ---

2145 }
2146 return error;
2147}
2148
2149/*
2150 * Extract various information from EEPROM.
2151 */
2152static void
681 /* override default methods */
682 ic->ic_node_alloc = wpi_node_alloc;
683 ic->ic_newassoc = wpi_newassoc;
684 ic->ic_raw_xmit = wpi_raw_xmit;
685 ic->ic_wme.wme_update = wpi_wme_update;
686 ic->ic_scan_start = wpi_scan_start;
687 ic->ic_scan_end = wpi_scan_end;
688 ic->ic_set_channel = wpi_set_channel;

--- 1458 unchanged lines hidden (view full) ---

2147 }
2148 return error;
2149}
2150
2151/*
2152 * Extract various information from EEPROM.
2153 */
2154static void
2153wpi_read_eeprom(struct wpi_softc *sc)
2155wpi_read_eeprom(struct wpi_softc *sc, uint8_t macaddr[IEEE80211_ADDR_LEN])
2154{
2156{
2155 struct ifnet *ifp = sc->sc_ifp;
2156 struct ieee80211com *ic = ifp->if_l2com;
2157 int i;
2158
2159 /* read the hardware capabilities, revision and SKU type */
2160 wpi_read_prom_data(sc, WPI_EEPROM_CAPABILITIES, &sc->cap,1);
2161 wpi_read_prom_data(sc, WPI_EEPROM_REVISION, &sc->rev,2);
2162 wpi_read_prom_data(sc, WPI_EEPROM_TYPE, &sc->type, 1);
2163
2164 /* read the regulatory domain */
2165 wpi_read_prom_data(sc, WPI_EEPROM_DOMAIN, sc->domain, 4);
2166
2167 /* read in the hw MAC address */
2157 int i;
2158
2159 /* read the hardware capabilities, revision and SKU type */
2160 wpi_read_prom_data(sc, WPI_EEPROM_CAPABILITIES, &sc->cap,1);
2161 wpi_read_prom_data(sc, WPI_EEPROM_REVISION, &sc->rev,2);
2162 wpi_read_prom_data(sc, WPI_EEPROM_TYPE, &sc->type, 1);
2163
2164 /* read the regulatory domain */
2165 wpi_read_prom_data(sc, WPI_EEPROM_DOMAIN, sc->domain, 4);
2166
2167 /* read in the hw MAC address */
2168 wpi_read_prom_data(sc, WPI_EEPROM_MAC, ic->ic_myaddr, 6);
2168 wpi_read_prom_data(sc, WPI_EEPROM_MAC, macaddr, 6);
2169
2170 /* read the list of authorized channels */
2171 for (i = 0; i < WPI_CHAN_BANDS_COUNT; i++)
2172 wpi_read_eeprom_channels(sc,i);
2173
2174 /* read the power level calibration info for each group */
2175 for (i = 0; i < WPI_POWER_GROUPS_COUNT; i++)
2176 wpi_read_eeprom_group(sc,i);

--- 456 unchanged lines hidden (view full) ---

2633 * Build a probe request frame. Most of the following code is a
2634 * copy & paste of what is done in net80211.
2635 */
2636 wh = (struct ieee80211_frame *)&hdr->scan_essids[4];
2637 wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT |
2638 IEEE80211_FC0_SUBTYPE_PROBE_REQ;
2639 wh->i_fc[1] = IEEE80211_FC1_DIR_NODS;
2640 IEEE80211_ADDR_COPY(wh->i_addr1, ifp->if_broadcastaddr);
2169
2170 /* read the list of authorized channels */
2171 for (i = 0; i < WPI_CHAN_BANDS_COUNT; i++)
2172 wpi_read_eeprom_channels(sc,i);
2173
2174 /* read the power level calibration info for each group */
2175 for (i = 0; i < WPI_POWER_GROUPS_COUNT; i++)
2176 wpi_read_eeprom_group(sc,i);

--- 456 unchanged lines hidden (view full) ---

2633 * Build a probe request frame. Most of the following code is a
2634 * copy & paste of what is done in net80211.
2635 */
2636 wh = (struct ieee80211_frame *)&hdr->scan_essids[4];
2637 wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT |
2638 IEEE80211_FC0_SUBTYPE_PROBE_REQ;
2639 wh->i_fc[1] = IEEE80211_FC1_DIR_NODS;
2640 IEEE80211_ADDR_COPY(wh->i_addr1, ifp->if_broadcastaddr);
2641 IEEE80211_ADDR_COPY(wh->i_addr2, ic->ic_myaddr);
2641 IEEE80211_ADDR_COPY(wh->i_addr2, IF_LLADDR(ifp));
2642 IEEE80211_ADDR_COPY(wh->i_addr3, ifp->if_broadcastaddr);
2643 *(u_int16_t *)&wh->i_dur[0] = 0; /* filled by h/w */
2644 *(u_int16_t *)&wh->i_seq[0] = 0; /* filled by h/w */
2645
2646 frm = (uint8_t *)(wh + 1);
2647
2648 /* add essid IE, the hardware will fill this in for us */
2649 *frm++ = IEEE80211_ELEMID_SSID;

--- 155 unchanged lines hidden (view full) ---

2805 if (error != 0) {
2806 device_printf(sc->sc_dev,
2807 "could not configure bluetooth coexistence\n");
2808 return error;
2809 }
2810
2811 /* configure adapter */
2812 memset(&sc->config, 0, sizeof (struct wpi_config));
2642 IEEE80211_ADDR_COPY(wh->i_addr3, ifp->if_broadcastaddr);
2643 *(u_int16_t *)&wh->i_dur[0] = 0; /* filled by h/w */
2644 *(u_int16_t *)&wh->i_seq[0] = 0; /* filled by h/w */
2645
2646 frm = (uint8_t *)(wh + 1);
2647
2648 /* add essid IE, the hardware will fill this in for us */
2649 *frm++ = IEEE80211_ELEMID_SSID;

--- 155 unchanged lines hidden (view full) ---

2805 if (error != 0) {
2806 device_printf(sc->sc_dev,
2807 "could not configure bluetooth coexistence\n");
2808 return error;
2809 }
2810
2811 /* configure adapter */
2812 memset(&sc->config, 0, sizeof (struct wpi_config));
2813 IEEE80211_ADDR_COPY(sc->config.myaddr, ic->ic_myaddr);
2813 IEEE80211_ADDR_COPY(sc->config.myaddr, IF_LLADDR(ifp));
2814 /*set default channel*/
2815 sc->config.chan = htole16(ieee80211_chan2ieee(ic, ic->ic_curchan));
2816 sc->config.flags = htole32(WPI_CONFIG_TSF);
2817 if (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan)) {
2818 sc->config.flags |= htole32(WPI_CONFIG_AUTO |
2819 WPI_CONFIG_24GHZ);
2820 }
2821 sc->config.filter = 0;

--- 1034 unchanged lines hidden ---
2814 /*set default channel*/
2815 sc->config.chan = htole16(ieee80211_chan2ieee(ic, ic->ic_curchan));
2816 sc->config.flags = htole32(WPI_CONFIG_TSF);
2817 if (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan)) {
2818 sc->config.flags |= htole32(WPI_CONFIG_AUTO |
2819 WPI_CONFIG_24GHZ);
2820 }
2821 sc->config.filter = 0;

--- 1034 unchanged lines hidden ---