if_bwi.c (11d38a5764295585a2472d5e861fa8abe1a11eb2) if_bwi.c (0046e1868fb0f7704f0ba2fd9ec63321adbf0a8e)
1/*
2 * Copyright (c) 2007 The DragonFly Project. All rights reserved.
3 *
4 * This code is derived from software contributed to The DragonFly Project
5 * by Sepherosa Ziehau <sepherosa@gmail.com>
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

351
352int
353bwi_attach(struct bwi_softc *sc)
354{
355 struct ieee80211com *ic = &sc->sc_ic;
356 device_t dev = sc->sc_dev;
357 struct bwi_mac *mac;
358 struct bwi_phy *phy;
1/*
2 * Copyright (c) 2007 The DragonFly Project. All rights reserved.
3 *
4 * This code is derived from software contributed to The DragonFly Project
5 * by Sepherosa Ziehau <sepherosa@gmail.com>
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

351
352int
353bwi_attach(struct bwi_softc *sc)
354{
355 struct ieee80211com *ic = &sc->sc_ic;
356 device_t dev = sc->sc_dev;
357 struct bwi_mac *mac;
358 struct bwi_phy *phy;
359 uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)];
359 int i, error;
360 int i, error;
360 uint8_t bands;
361
362 BWI_LOCK_INIT(sc);
363
364 /*
365 * Initialize taskq and various tasks
366 */
367 sc->sc_tq = taskqueue_create("bwi_taskq", M_NOWAIT | M_ZERO,
368 taskqueue_thread_enqueue, &sc->sc_tq);

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

448 if (error)
449 goto fail;
450
451 callout_init_mtx(&sc->sc_watchdog_timer, &sc->sc_mtx, 0);
452
453 /*
454 * Setup ratesets, phytype, channels and get MAC address
455 */
361
362 BWI_LOCK_INIT(sc);
363
364 /*
365 * Initialize taskq and various tasks
366 */
367 sc->sc_tq = taskqueue_create("bwi_taskq", M_NOWAIT | M_ZERO,
368 taskqueue_thread_enqueue, &sc->sc_tq);

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

448 if (error)
449 goto fail;
450
451 callout_init_mtx(&sc->sc_watchdog_timer, &sc->sc_mtx, 0);
452
453 /*
454 * Setup ratesets, phytype, channels and get MAC address
455 */
456 bands = 0;
456 memset(bands, 0, sizeof(bands));
457 if (phy->phy_mode == IEEE80211_MODE_11B ||
458 phy->phy_mode == IEEE80211_MODE_11G) {
457 if (phy->phy_mode == IEEE80211_MODE_11B ||
458 phy->phy_mode == IEEE80211_MODE_11G) {
459 setbit(&bands, IEEE80211_MODE_11B);
459 setbit(bands, IEEE80211_MODE_11B);
460 if (phy->phy_mode == IEEE80211_MODE_11B) {
461 ic->ic_phytype = IEEE80211_T_DS;
462 } else {
463 ic->ic_phytype = IEEE80211_T_OFDM;
460 if (phy->phy_mode == IEEE80211_MODE_11B) {
461 ic->ic_phytype = IEEE80211_T_DS;
462 } else {
463 ic->ic_phytype = IEEE80211_T_OFDM;
464 setbit(&bands, IEEE80211_MODE_11G);
464 setbit(bands, IEEE80211_MODE_11G);
465 }
466
467 bwi_get_eaddr(sc, BWI_SPROM_11BG_EADDR, ic->ic_macaddr);
468 if (IEEE80211_IS_MULTICAST(ic->ic_macaddr)) {
469 bwi_get_eaddr(sc, BWI_SPROM_11A_EADDR, ic->ic_macaddr);
470 if (IEEE80211_IS_MULTICAST(ic->ic_macaddr)) {
471 device_printf(dev,
472 "invalid MAC address: %6D\n",
473 ic->ic_macaddr, ":");
474 }
475 }
476 } else if (phy->phy_mode == IEEE80211_MODE_11A) {
477 /* TODO:11A */
465 }
466
467 bwi_get_eaddr(sc, BWI_SPROM_11BG_EADDR, ic->ic_macaddr);
468 if (IEEE80211_IS_MULTICAST(ic->ic_macaddr)) {
469 bwi_get_eaddr(sc, BWI_SPROM_11A_EADDR, ic->ic_macaddr);
470 if (IEEE80211_IS_MULTICAST(ic->ic_macaddr)) {
471 device_printf(dev,
472 "invalid MAC address: %6D\n",
473 ic->ic_macaddr, ":");
474 }
475 }
476 } else if (phy->phy_mode == IEEE80211_MODE_11A) {
477 /* TODO:11A */
478 setbit(&bands, IEEE80211_MODE_11A);
478 setbit(bands, IEEE80211_MODE_11A);
479 error = ENXIO;
480 goto fail;
481 } else {
482 panic("unknown phymode %d\n", phy->phy_mode);
483 }
484
485 /* Get locale */
486 sc->sc_locale = __SHIFTOUT(bwi_read_sprom(sc, BWI_SPROM_CARD_INFO),
487 BWI_SPROM_CARD_INFO_LOCALE);
488 DPRINTF(sc, BWI_DBG_ATTACH, "locale: %d\n", sc->sc_locale);
489 /* XXX use locale */
479 error = ENXIO;
480 goto fail;
481 } else {
482 panic("unknown phymode %d\n", phy->phy_mode);
483 }
484
485 /* Get locale */
486 sc->sc_locale = __SHIFTOUT(bwi_read_sprom(sc, BWI_SPROM_CARD_INFO),
487 BWI_SPROM_CARD_INFO_LOCALE);
488 DPRINTF(sc, BWI_DBG_ATTACH, "locale: %d\n", sc->sc_locale);
489 /* XXX use locale */
490 ieee80211_init_channels(ic, NULL, &bands);
490 ieee80211_init_channels(ic, NULL, bands);
491
492 ic->ic_softc = sc;
493 ic->ic_name = device_get_nameunit(dev);
494 ic->ic_caps = IEEE80211_C_STA |
495 IEEE80211_C_SHSLOT |
496 IEEE80211_C_SHPREAMBLE |
497 IEEE80211_C_WPA |
498 IEEE80211_C_BGSCAN |

--- 3477 unchanged lines hidden ---
491
492 ic->ic_softc = sc;
493 ic->ic_name = device_get_nameunit(dev);
494 ic->ic_caps = IEEE80211_C_STA |
495 IEEE80211_C_SHSLOT |
496 IEEE80211_C_SHPREAMBLE |
497 IEEE80211_C_WPA |
498 IEEE80211_C_BGSCAN |

--- 3477 unchanged lines hidden ---