if_bwi.c (286410) | if_bwi.c (286437) |
---|---|
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 --- 21 unchanged lines hidden (view full) --- 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * $DragonFly: src/sys/dev/netif/bwi/if_bwi.c,v 1.19 2008/02/15 11:15:38 sephe Exp $ 35 */ 36 37#include <sys/cdefs.h> | 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 --- 21 unchanged lines hidden (view full) --- 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * $DragonFly: src/sys/dev/netif/bwi/if_bwi.c,v 1.19 2008/02/15 11:15:38 sephe Exp $ 35 */ 36 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/sys/dev/bwi/if_bwi.c 286410 2015-08-07 11:43:14Z glebius $"); | 38__FBSDID("$FreeBSD: head/sys/dev/bwi/if_bwi.c 286437 2015-08-08 01:10:17Z adrian $"); |
39 40#include "opt_inet.h" 41#include "opt_bwi.h" 42#include "opt_wlan.h" 43 44#include <sys/param.h> 45#include <sys/endian.h> 46#include <sys/kernel.h> --- 50 unchanged lines hidden (view full) --- 97 uint8_t bssid[IEEE80211_ADDR_LEN]; 98} __packed; 99 100static struct ieee80211vap *bwi_vap_create(struct ieee80211com *, 101 const char [IFNAMSIZ], int, enum ieee80211_opmode, int, 102 const uint8_t [IEEE80211_ADDR_LEN], 103 const uint8_t [IEEE80211_ADDR_LEN]); 104static void bwi_vap_delete(struct ieee80211vap *); | 39 40#include "opt_inet.h" 41#include "opt_bwi.h" 42#include "opt_wlan.h" 43 44#include <sys/param.h> 45#include <sys/endian.h> 46#include <sys/kernel.h> --- 50 unchanged lines hidden (view full) --- 97 uint8_t bssid[IEEE80211_ADDR_LEN]; 98} __packed; 99 100static struct ieee80211vap *bwi_vap_create(struct ieee80211com *, 101 const char [IFNAMSIZ], int, enum ieee80211_opmode, int, 102 const uint8_t [IEEE80211_ADDR_LEN], 103 const uint8_t [IEEE80211_ADDR_LEN]); 104static void bwi_vap_delete(struct ieee80211vap *); |
105static void bwi_init(struct bwi_softc *); 106static void bwi_parent(struct ieee80211com *); 107static int bwi_transmit(struct ieee80211com *, struct mbuf *); 108static void bwi_start_locked(struct bwi_softc *); | 105static void bwi_init(void *); 106static int bwi_ioctl(struct ifnet *, u_long, caddr_t); 107static void bwi_start(struct ifnet *); 108static void bwi_start_locked(struct ifnet *); |
109static int bwi_raw_xmit(struct ieee80211_node *, struct mbuf *, 110 const struct ieee80211_bpf_params *); 111static void bwi_watchdog(void *); 112static void bwi_scan_start(struct ieee80211com *); 113static void bwi_set_channel(struct ieee80211com *); 114static void bwi_scan_end(struct ieee80211com *); 115static int bwi_newstate(struct ieee80211vap *, enum ieee80211_state, int); 116static void bwi_updateslot(struct ieee80211com *); --- 230 unchanged lines hidden (view full) --- 347 348 desc->addr = htole32(addr); 349 desc->ctrl = htole32(ctrl); 350} 351 352int 353bwi_attach(struct bwi_softc *sc) 354{ | 109static int bwi_raw_xmit(struct ieee80211_node *, struct mbuf *, 110 const struct ieee80211_bpf_params *); 111static void bwi_watchdog(void *); 112static void bwi_scan_start(struct ieee80211com *); 113static void bwi_set_channel(struct ieee80211com *); 114static void bwi_scan_end(struct ieee80211com *); 115static int bwi_newstate(struct ieee80211vap *, enum ieee80211_state, int); 116static void bwi_updateslot(struct ieee80211com *); --- 230 unchanged lines hidden (view full) --- 347 348 desc->addr = htole32(addr); 349 desc->ctrl = htole32(ctrl); 350} 351 352int 353bwi_attach(struct bwi_softc *sc) 354{ |
355 struct ieee80211com *ic = &sc->sc_ic; | 355 struct ieee80211com *ic; |
356 device_t dev = sc->sc_dev; | 356 device_t dev = sc->sc_dev; |
357 struct ifnet *ifp; |
|
357 struct bwi_mac *mac; 358 struct bwi_phy *phy; 359 int i, error; 360 uint8_t bands; | 358 struct bwi_mac *mac; 359 struct bwi_phy *phy; 360 int i, error; 361 uint8_t bands; |
362 uint8_t macaddr[IEEE80211_ADDR_LEN]; |
|
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); 369 taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, "%s taskq", 370 device_get_nameunit(dev)); 371 TASK_INIT(&sc->sc_restart_task, 0, bwi_restart, sc); | 363 364 BWI_LOCK_INIT(sc); 365 366 /* 367 * Initialize taskq and various tasks 368 */ 369 sc->sc_tq = taskqueue_create("bwi_taskq", M_NOWAIT | M_ZERO, 370 taskqueue_thread_enqueue, &sc->sc_tq); 371 taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, "%s taskq", 372 device_get_nameunit(dev)); 373 TASK_INIT(&sc->sc_restart_task, 0, bwi_restart, sc); |
374 |
|
372 callout_init_mtx(&sc->sc_calib_ch, &sc->sc_mtx, 0); | 375 callout_init_mtx(&sc->sc_calib_ch, &sc->sc_mtx, 0); |
373 mbufq_init(&sc->sc_snd, ifqmaxlen); | |
374 375 /* 376 * Initialize sysctl variables 377 */ 378 sc->sc_fw_version = BWI_FW_VERSION3; 379 sc->sc_led_idle = (2350 * hz) / 1000; 380 sc->sc_led_blink = 1; 381 sc->sc_txpwr_calib = 1; --- 61 unchanged lines hidden (view full) --- 443 error = bwi_dma_alloc(sc); 444 if (error) 445 goto fail; 446 447 error = bwi_mac_fw_alloc(mac); 448 if (error) 449 goto fail; 450 | 376 377 /* 378 * Initialize sysctl variables 379 */ 380 sc->sc_fw_version = BWI_FW_VERSION3; 381 sc->sc_led_idle = (2350 * hz) / 1000; 382 sc->sc_led_blink = 1; 383 sc->sc_txpwr_calib = 1; --- 61 unchanged lines hidden (view full) --- 445 error = bwi_dma_alloc(sc); 446 if (error) 447 goto fail; 448 449 error = bwi_mac_fw_alloc(mac); 450 if (error) 451 goto fail; 452 |
453 ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211); 454 if (ifp == NULL) { 455 device_printf(dev, "can not if_alloc()\n"); 456 error = ENOSPC; 457 goto fail; 458 } 459 ic = ifp->if_l2com; 460 461 /* set these up early for if_printf use */ 462 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 463 464 ifp->if_softc = sc; 465 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; 466 ifp->if_init = bwi_init; 467 ifp->if_ioctl = bwi_ioctl; 468 ifp->if_start = bwi_start; 469 IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); 470 ifp->if_snd.ifq_drv_maxlen = ifqmaxlen; 471 IFQ_SET_READY(&ifp->if_snd); |
|
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; 457 if (phy->phy_mode == IEEE80211_MODE_11B || 458 phy->phy_mode == IEEE80211_MODE_11G) { 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; 464 setbit(&bands, IEEE80211_MODE_11G); 465 } 466 | 472 callout_init_mtx(&sc->sc_watchdog_timer, &sc->sc_mtx, 0); 473 474 /* 475 * Setup ratesets, phytype, channels and get MAC address 476 */ 477 bands = 0; 478 if (phy->phy_mode == IEEE80211_MODE_11B || 479 phy->phy_mode == IEEE80211_MODE_11G) { 480 setbit(&bands, IEEE80211_MODE_11B); 481 if (phy->phy_mode == IEEE80211_MODE_11B) { 482 ic->ic_phytype = IEEE80211_T_DS; 483 } else { 484 ic->ic_phytype = IEEE80211_T_OFDM; 485 setbit(&bands, IEEE80211_MODE_11G); 486 } 487 |
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)) { | 488 bwi_get_eaddr(sc, BWI_SPROM_11BG_EADDR, macaddr); 489 if (IEEE80211_IS_MULTICAST(macaddr)) { 490 bwi_get_eaddr(sc, BWI_SPROM_11A_EADDR, macaddr); 491 if (IEEE80211_IS_MULTICAST(macaddr)) { |
471 device_printf(dev, 472 "invalid MAC address: %6D\n", | 492 device_printf(dev, 493 "invalid MAC address: %6D\n", |
473 ic->ic_macaddr, ":"); | 494 macaddr, ":"); |
474 } 475 } 476 } else if (phy->phy_mode == IEEE80211_MODE_11A) { 477 /* TODO: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 */ 490 ieee80211_init_channels(ic, NULL, &bands); 491 | 495 } 496 } 497 } else if (phy->phy_mode == IEEE80211_MODE_11A) { 498 /* TODO:11A */ 499 setbit(&bands, IEEE80211_MODE_11A); 500 error = ENXIO; 501 goto fail; 502 } else { 503 panic("unknown phymode %d\n", phy->phy_mode); 504 } 505 506 /* Get locale */ 507 sc->sc_locale = __SHIFTOUT(bwi_read_sprom(sc, BWI_SPROM_CARD_INFO), 508 BWI_SPROM_CARD_INFO_LOCALE); 509 DPRINTF(sc, BWI_DBG_ATTACH, "locale: %d\n", sc->sc_locale); 510 /* XXX use locale */ 511 ieee80211_init_channels(ic, NULL, &bands); 512 |
513 ic->ic_ifp = ifp; |
|
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 | 499 IEEE80211_C_MONITOR; 500 ic->ic_opmode = IEEE80211_M_STA; | 514 ic->ic_softc = sc; 515 ic->ic_name = device_get_nameunit(dev); 516 ic->ic_caps = IEEE80211_C_STA | 517 IEEE80211_C_SHSLOT | 518 IEEE80211_C_SHPREAMBLE | 519 IEEE80211_C_WPA | 520 IEEE80211_C_BGSCAN | 521 IEEE80211_C_MONITOR; 522 ic->ic_opmode = IEEE80211_M_STA; |
501 ieee80211_ifattach(ic); | 523 ieee80211_ifattach(ic, macaddr); |
502 503 ic->ic_headroom = sizeof(struct bwi_txbuf_hdr); 504 505 /* override default methods */ 506 ic->ic_vap_create = bwi_vap_create; 507 ic->ic_vap_delete = bwi_vap_delete; 508 ic->ic_raw_xmit = bwi_raw_xmit; 509 ic->ic_updateslot = bwi_updateslot; 510 ic->ic_scan_start = bwi_scan_start; 511 ic->ic_scan_end = bwi_scan_end; 512 ic->ic_set_channel = bwi_set_channel; | 524 525 ic->ic_headroom = sizeof(struct bwi_txbuf_hdr); 526 527 /* override default methods */ 528 ic->ic_vap_create = bwi_vap_create; 529 ic->ic_vap_delete = bwi_vap_delete; 530 ic->ic_raw_xmit = bwi_raw_xmit; 531 ic->ic_updateslot = bwi_updateslot; 532 ic->ic_scan_start = bwi_scan_start; 533 ic->ic_scan_end = bwi_scan_end; 534 ic->ic_set_channel = bwi_set_channel; |
513 ic->ic_transmit = bwi_transmit; 514 ic->ic_parent = bwi_parent; | |
515 516 sc->sc_rates = ieee80211_get_ratetable(ic->ic_curchan); 517 518 ieee80211_radiotap_attach(ic, 519 &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th), 520 BWI_TX_RADIOTAP_PRESENT, 521 &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th), 522 BWI_RX_RADIOTAP_PRESENT); --- 29 unchanged lines hidden (view full) --- 552fail: 553 BWI_LOCK_DESTROY(sc); 554 return (error); 555} 556 557int 558bwi_detach(struct bwi_softc *sc) 559{ | 535 536 sc->sc_rates = ieee80211_get_ratetable(ic->ic_curchan); 537 538 ieee80211_radiotap_attach(ic, 539 &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th), 540 BWI_TX_RADIOTAP_PRESENT, 541 &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th), 542 BWI_RX_RADIOTAP_PRESENT); --- 29 unchanged lines hidden (view full) --- 572fail: 573 BWI_LOCK_DESTROY(sc); 574 return (error); 575} 576 577int 578bwi_detach(struct bwi_softc *sc) 579{ |
560 struct ieee80211com *ic = &sc->sc_ic; | 580 struct ifnet *ifp = sc->sc_ifp; 581 struct ieee80211com *ic = ifp->if_l2com; |
561 int i; 562 563 bwi_stop(sc, 1); 564 callout_drain(&sc->sc_led_blink_ch); 565 callout_drain(&sc->sc_calib_ch); 566 callout_drain(&sc->sc_watchdog_timer); 567 ieee80211_ifdetach(ic); 568 569 for (i = 0; i < sc->sc_nmac; ++i) 570 bwi_mac_detach(&sc->sc_mac[i]); 571 bwi_dma_free(sc); | 582 int i; 583 584 bwi_stop(sc, 1); 585 callout_drain(&sc->sc_led_blink_ch); 586 callout_drain(&sc->sc_calib_ch); 587 callout_drain(&sc->sc_watchdog_timer); 588 ieee80211_ifdetach(ic); 589 590 for (i = 0; i < sc->sc_nmac; ++i) 591 bwi_mac_detach(&sc->sc_mac[i]); 592 bwi_dma_free(sc); |
593 if_free(ifp); |
|
572 taskqueue_free(sc->sc_tq); | 594 taskqueue_free(sc->sc_tq); |
573 mbufq_drain(&sc->sc_snd); | |
574 575 BWI_LOCK_DESTROY(sc); 576 577 return (0); 578} 579 580static struct ieee80211vap * 581bwi_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit, 582 enum ieee80211_opmode opmode, int flags, 583 const uint8_t bssid[IEEE80211_ADDR_LEN], 584 const uint8_t mac[IEEE80211_ADDR_LEN]) 585{ 586 struct bwi_vap *bvp; 587 struct ieee80211vap *vap; 588 589 if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */ 590 return NULL; | 595 596 BWI_LOCK_DESTROY(sc); 597 598 return (0); 599} 600 601static struct ieee80211vap * 602bwi_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit, 603 enum ieee80211_opmode opmode, int flags, 604 const uint8_t bssid[IEEE80211_ADDR_LEN], 605 const uint8_t mac[IEEE80211_ADDR_LEN]) 606{ 607 struct bwi_vap *bvp; 608 struct ieee80211vap *vap; 609 610 if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */ 611 return NULL; |
591 bvp = malloc(sizeof(struct bwi_vap), M_80211_VAP, M_WAITOK | M_ZERO); | 612 bvp = (struct bwi_vap *) malloc(sizeof(struct bwi_vap), 613 M_80211_VAP, M_WAITOK | M_ZERO); 614 if (bvp == NULL) 615 return NULL; |
592 vap = &bvp->bv_vap; 593 /* enable s/w bmiss handling for sta mode */ 594 ieee80211_vap_setup(ic, vap, name, unit, opmode, | 616 vap = &bvp->bv_vap; 617 /* enable s/w bmiss handling for sta mode */ 618 ieee80211_vap_setup(ic, vap, name, unit, opmode, |
595 flags | IEEE80211_CLONE_NOBEACONS, bssid); | 619 flags | IEEE80211_CLONE_NOBEACONS, bssid, mac); |
596 597 /* override default methods */ 598 bvp->bv_newstate = vap->iv_newstate; 599 vap->iv_newstate = bwi_newstate; 600#if 0 601 vap->iv_update_beacon = bwi_beacon_update; 602#endif 603 ieee80211_ratectl_init(vap); 604 605 /* complete setup */ | 620 621 /* override default methods */ 622 bvp->bv_newstate = vap->iv_newstate; 623 vap->iv_newstate = bwi_newstate; 624#if 0 625 vap->iv_update_beacon = bwi_beacon_update; 626#endif 627 ieee80211_ratectl_init(vap); 628 629 /* complete setup */ |
606 ieee80211_vap_attach(vap, bwi_media_change, ieee80211_media_status, 607 mac); | 630 ieee80211_vap_attach(vap, bwi_media_change, ieee80211_media_status); |
608 ic->ic_opmode = opmode; 609 return vap; 610} 611 612static void 613bwi_vap_delete(struct ieee80211vap *vap) 614{ 615 struct bwi_vap *bvp = BWI_VAP(vap); --- 7 unchanged lines hidden (view full) --- 623bwi_suspend(struct bwi_softc *sc) 624{ 625 bwi_stop(sc, 1); 626} 627 628void 629bwi_resume(struct bwi_softc *sc) 630{ | 631 ic->ic_opmode = opmode; 632 return vap; 633} 634 635static void 636bwi_vap_delete(struct ieee80211vap *vap) 637{ 638 struct bwi_vap *bvp = BWI_VAP(vap); --- 7 unchanged lines hidden (view full) --- 646bwi_suspend(struct bwi_softc *sc) 647{ 648 bwi_stop(sc, 1); 649} 650 651void 652bwi_resume(struct bwi_softc *sc) 653{ |
654 struct ifnet *ifp = sc->sc_ifp; |
|
631 | 655 |
632 if (sc->sc_ic.ic_nrunning > 0) | 656 if (ifp->if_flags & IFF_UP) |
633 bwi_init(sc); 634} 635 636int 637bwi_shutdown(struct bwi_softc *sc) 638{ 639 bwi_stop(sc, 1); 640 return 0; --- 547 unchanged lines hidden (view full) --- 1188 howmany(freq.clkfreq_max * 15, 1000000)); 1189 } 1190 } 1191 1192 return bwi_regwin_switch(sc, old, NULL); 1193} 1194 1195static void | 657 bwi_init(sc); 658} 659 660int 661bwi_shutdown(struct bwi_softc *sc) 662{ 663 bwi_stop(sc, 1); 664 return 0; --- 547 unchanged lines hidden (view full) --- 1212 howmany(freq.clkfreq_max * 15, 1000000)); 1213 } 1214 } 1215 1216 return bwi_regwin_switch(sc, old, NULL); 1217} 1218 1219static void |
1196bwi_init(struct bwi_softc *sc) | 1220bwi_init(void *xsc) |
1197{ | 1221{ |
1198 struct ieee80211com *ic = &sc->sc_ic; | 1222 struct bwi_softc *sc = xsc; 1223 struct ifnet *ifp = sc->sc_ifp; 1224 struct ieee80211com *ic = ifp->if_l2com; |
1199 1200 BWI_LOCK(sc); 1201 bwi_init_statechg(sc, 1); 1202 BWI_UNLOCK(sc); 1203 | 1225 1226 BWI_LOCK(sc); 1227 bwi_init_statechg(sc, 1); 1228 BWI_UNLOCK(sc); 1229 |
1204 if (sc->sc_flags & BWI_F_RUNNING) | 1230 if (ifp->if_drv_flags & IFF_DRV_RUNNING) |
1205 ieee80211_start_all(ic); /* start all vap's */ 1206} 1207 1208static void 1209bwi_init_statechg(struct bwi_softc *sc, int statechg) 1210{ | 1231 ieee80211_start_all(ic); /* start all vap's */ 1232} 1233 1234static void 1235bwi_init_statechg(struct bwi_softc *sc, int statechg) 1236{ |
1237 struct ifnet *ifp = sc->sc_ifp; |
|
1211 struct bwi_mac *mac; 1212 int error; 1213 | 1238 struct bwi_mac *mac; 1239 int error; 1240 |
1214 BWI_ASSERT_LOCKED(sc); 1215 | |
1216 bwi_stop_locked(sc, statechg); 1217 1218 bwi_bbp_power_on(sc, BWI_CLOCK_MODE_FAST); 1219 1220 /* TODO: 2 MAC */ 1221 1222 mac = &sc->sc_mac[0]; 1223 error = bwi_regwin_switch(sc, &mac->mac_regwin, NULL); 1224 if (error) { | 1241 bwi_stop_locked(sc, statechg); 1242 1243 bwi_bbp_power_on(sc, BWI_CLOCK_MODE_FAST); 1244 1245 /* TODO: 2 MAC */ 1246 1247 mac = &sc->sc_mac[0]; 1248 error = bwi_regwin_switch(sc, &mac->mac_regwin, NULL); 1249 if (error) { |
1225 device_printf(sc->sc_dev, "%s: error %d on regwin switch\n", | 1250 if_printf(ifp, "%s: error %d on regwin switch\n", |
1226 __func__, error); 1227 goto bad; 1228 } 1229 error = bwi_mac_init(mac); 1230 if (error) { | 1251 __func__, error); 1252 goto bad; 1253 } 1254 error = bwi_mac_init(mac); 1255 if (error) { |
1231 device_printf(sc->sc_dev, "%s: error %d on MAC init\n", 1232 __func__, error); | 1256 if_printf(ifp, "%s: error %d on MAC init\n", __func__, error); |
1233 goto bad; 1234 } 1235 1236 bwi_bbp_power_on(sc, BWI_CLOCK_MODE_DYN); 1237 1238 bwi_set_bssid(sc, bwi_zero_addr); /* Clear BSSID */ | 1257 goto bad; 1258 } 1259 1260 bwi_bbp_power_on(sc, BWI_CLOCK_MODE_DYN); 1261 1262 bwi_set_bssid(sc, bwi_zero_addr); /* Clear BSSID */ |
1239 bwi_set_addr_filter(sc, BWI_ADDR_FILTER_MYADDR, sc->sc_ic.ic_macaddr); | 1263 bwi_set_addr_filter(sc, BWI_ADDR_FILTER_MYADDR, IF_LLADDR(ifp)); |
1240 1241 bwi_mac_reset_hwkeys(mac); 1242 1243 if ((mac->mac_flags & BWI_MAC_F_HAS_TXSTATS) == 0) { 1244 int i; 1245 1246#define NRETRY 1000 1247 /* 1248 * Drain any possible pending TX status 1249 */ 1250 for (i = 0; i < NRETRY; ++i) { 1251 if ((CSR_READ_4(sc, BWI_TXSTATUS0) & 1252 BWI_TXSTATUS0_VALID) == 0) 1253 break; 1254 CSR_READ_4(sc, BWI_TXSTATUS1); 1255 } 1256 if (i == NRETRY) | 1264 1265 bwi_mac_reset_hwkeys(mac); 1266 1267 if ((mac->mac_flags & BWI_MAC_F_HAS_TXSTATS) == 0) { 1268 int i; 1269 1270#define NRETRY 1000 1271 /* 1272 * Drain any possible pending TX status 1273 */ 1274 for (i = 0; i < NRETRY; ++i) { 1275 if ((CSR_READ_4(sc, BWI_TXSTATUS0) & 1276 BWI_TXSTATUS0_VALID) == 0) 1277 break; 1278 CSR_READ_4(sc, BWI_TXSTATUS1); 1279 } 1280 if (i == NRETRY) |
1257 device_printf(sc->sc_dev, 1258 "%s: can't drain TX status\n", __func__); | 1281 if_printf(ifp, "%s: can't drain TX status\n", __func__); |
1259#undef NRETRY 1260 } 1261 1262 if (mac->mac_phy.phy_mode == IEEE80211_MODE_11G) 1263 bwi_mac_updateslot(mac, 1); 1264 1265 /* Start MAC */ 1266 error = bwi_mac_start(mac); 1267 if (error) { | 1282#undef NRETRY 1283 } 1284 1285 if (mac->mac_phy.phy_mode == IEEE80211_MODE_11G) 1286 bwi_mac_updateslot(mac, 1); 1287 1288 /* Start MAC */ 1289 error = bwi_mac_start(mac); 1290 if (error) { |
1268 device_printf(sc->sc_dev, "%s: error %d starting MAC\n", 1269 __func__, error); | 1291 if_printf(ifp, "%s: error %d starting MAC\n", __func__, error); |
1270 goto bad; 1271 } 1272 1273 /* Clear stop flag before enabling interrupt */ 1274 sc->sc_flags &= ~BWI_F_STOP; | 1292 goto bad; 1293 } 1294 1295 /* Clear stop flag before enabling interrupt */ 1296 sc->sc_flags &= ~BWI_F_STOP; |
1275 sc->sc_flags |= BWI_F_RUNNING; | 1297 1298 ifp->if_drv_flags |= IFF_DRV_RUNNING; |
1276 callout_reset(&sc->sc_watchdog_timer, hz, bwi_watchdog, sc); 1277 1278 /* Enable intrs */ 1279 bwi_enable_intrs(sc, BWI_INIT_INTRS); 1280 return; 1281bad: 1282 bwi_stop_locked(sc, 1); 1283} 1284 | 1299 callout_reset(&sc->sc_watchdog_timer, hz, bwi_watchdog, sc); 1300 1301 /* Enable intrs */ 1302 bwi_enable_intrs(sc, BWI_INIT_INTRS); 1303 return; 1304bad: 1305 bwi_stop_locked(sc, 1); 1306} 1307 |
1285static void 1286bwi_parent(struct ieee80211com *ic) | 1308static int 1309bwi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) |
1287{ | 1310{ |
1288 struct bwi_softc *sc = ic->ic_softc; 1289 int startall = 0; | 1311#define IS_RUNNING(ifp) \ 1312 ((ifp->if_flags & IFF_UP) && (ifp->if_drv_flags & IFF_DRV_RUNNING)) 1313 struct bwi_softc *sc = ifp->if_softc; 1314 struct ieee80211com *ic = ifp->if_l2com; 1315 struct ifreq *ifr = (struct ifreq *) data; 1316 int error = 0, startall = 0; |
1290 | 1317 |
1291 BWI_LOCK(sc); 1292 if (ic->ic_nrunning > 0) { 1293 struct bwi_mac *mac; 1294 int promisc = -1; | 1318 switch (cmd) { 1319 case SIOCSIFFLAGS: 1320 BWI_LOCK(sc); 1321 if (IS_RUNNING(ifp)) { 1322 struct bwi_mac *mac; 1323 int promisc = -1; |
1295 | 1324 |
1296 KASSERT(sc->sc_cur_regwin->rw_type == BWI_REGWIN_T_MAC, 1297 ("current regwin type %d", 1298 sc->sc_cur_regwin->rw_type)); 1299 mac = (struct bwi_mac *)sc->sc_cur_regwin; | 1325 KASSERT(sc->sc_cur_regwin->rw_type == BWI_REGWIN_T_MAC, 1326 ("current regwin type %d", 1327 sc->sc_cur_regwin->rw_type)); 1328 mac = (struct bwi_mac *)sc->sc_cur_regwin; |
1300 | 1329 |
1301 if (ic->ic_promisc > 0 && (sc->sc_flags & BWI_F_PROMISC) == 0) { 1302 promisc = 1; 1303 sc->sc_flags |= BWI_F_PROMISC; 1304 } else if (ic->ic_promisc == 0 && 1305 (sc->sc_flags & BWI_F_PROMISC) != 0) { 1306 promisc = 0; 1307 sc->sc_flags &= ~BWI_F_PROMISC; | 1330 if ((ifp->if_flags & IFF_PROMISC) && 1331 (sc->sc_flags & BWI_F_PROMISC) == 0) { 1332 promisc = 1; 1333 sc->sc_flags |= BWI_F_PROMISC; 1334 } else if ((ifp->if_flags & IFF_PROMISC) == 0 && 1335 (sc->sc_flags & BWI_F_PROMISC)) { 1336 promisc = 0; 1337 sc->sc_flags &= ~BWI_F_PROMISC; 1338 } 1339 1340 if (promisc >= 0) 1341 bwi_mac_set_promisc(mac, promisc); |
1308 } 1309 | 1342 } 1343 |
1310 if (promisc >= 0) 1311 bwi_mac_set_promisc(mac, promisc); 1312 } 1313 if (ic->ic_nrunning > 0) { 1314 if ((sc->sc_flags & BWI_F_RUNNING) == 0) { 1315 bwi_init_statechg(sc, 1); 1316 startall = 1; | 1344 if (ifp->if_flags & IFF_UP) { 1345 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { 1346 bwi_init_statechg(sc, 1); 1347 startall = 1; 1348 } 1349 } else { 1350 if (ifp->if_drv_flags & IFF_DRV_RUNNING) 1351 bwi_stop_locked(sc, 1); |
1317 } | 1352 } |
1318 } else if (sc->sc_flags & BWI_F_RUNNING) 1319 bwi_stop_locked(sc, 1); 1320 BWI_UNLOCK(sc); 1321 if (startall) 1322 ieee80211_start_all(ic); | 1353 BWI_UNLOCK(sc); 1354 if (startall) 1355 ieee80211_start_all(ic); 1356 break; 1357 case SIOCGIFMEDIA: 1358 error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd); 1359 break; 1360 case SIOCGIFADDR: 1361 error = ether_ioctl(ifp, cmd, data); 1362 break; 1363 default: 1364 error = EINVAL; 1365 break; 1366 } 1367 return error; 1368#undef IS_RUNNING |
1323} 1324 | 1369} 1370 |
1325static int 1326bwi_transmit(struct ieee80211com *ic, struct mbuf *m) | 1371static void 1372bwi_start(struct ifnet *ifp) |
1327{ | 1373{ |
1328 struct bwi_softc *sc = ic->ic_softc; 1329 int error; | 1374 struct bwi_softc *sc = ifp->if_softc; |
1330 1331 BWI_LOCK(sc); | 1375 1376 BWI_LOCK(sc); |
1332 if ((sc->sc_flags & BWI_F_RUNNING) == 0) { 1333 BWI_UNLOCK(sc); 1334 return (ENXIO); 1335 } 1336 error = mbufq_enqueue(&sc->sc_snd, m); 1337 if (error) { 1338 BWI_UNLOCK(sc); 1339 return (error); 1340 } 1341 bwi_start_locked(sc); | 1377 bwi_start_locked(ifp); |
1342 BWI_UNLOCK(sc); | 1378 BWI_UNLOCK(sc); |
1343 return (0); | |
1344} 1345 1346static void | 1379} 1380 1381static void |
1347bwi_start_locked(struct bwi_softc *sc) | 1382bwi_start_locked(struct ifnet *ifp) |
1348{ | 1383{ |
1384 struct bwi_softc *sc = ifp->if_softc; |
|
1349 struct bwi_txbuf_data *tbd = &sc->sc_tx_bdata[BWI_TX_DATA_RING]; 1350 struct ieee80211_frame *wh; 1351 struct ieee80211_node *ni; | 1385 struct bwi_txbuf_data *tbd = &sc->sc_tx_bdata[BWI_TX_DATA_RING]; 1386 struct ieee80211_frame *wh; 1387 struct ieee80211_node *ni; |
1388 struct ieee80211_key *k; |
|
1352 struct mbuf *m; 1353 int trans, idx; 1354 | 1389 struct mbuf *m; 1390 int trans, idx; 1391 |
1355 BWI_ASSERT_LOCKED(sc); | 1392 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) 1393 return; |
1356 1357 trans = 0; 1358 idx = tbd->tbd_idx; 1359 | 1394 1395 trans = 0; 1396 idx = tbd->tbd_idx; 1397 |
1360 while (tbd->tbd_buf[idx].tb_mbuf == NULL && 1361 tbd->tbd_used + BWI_TX_NSPRDESC < BWI_TX_NDESC && 1362 (m = mbufq_dequeue(&sc->sc_snd)) != NULL) { | 1398 while (tbd->tbd_buf[idx].tb_mbuf == NULL) { 1399 IFQ_DRV_DEQUEUE(&ifp->if_snd, m); /* XXX: LOCK */ 1400 if (m == NULL) 1401 break; 1402 |
1363 ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; 1364 wh = mtod(m, struct ieee80211_frame *); | 1403 ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; 1404 wh = mtod(m, struct ieee80211_frame *); |
1365 if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED) != 0 && 1366 ieee80211_crypto_encap(ni, m) == NULL) { 1367 if_inc_counter(ni->ni_vap->iv_ifp, 1368 IFCOUNTER_OERRORS, 1); 1369 ieee80211_free_node(ni); 1370 m_freem(m); 1371 continue; | 1405 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { 1406 k = ieee80211_crypto_encap(ni, m); 1407 if (k == NULL) { 1408 ieee80211_free_node(ni); 1409 m_freem(m); 1410 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); 1411 continue; 1412 } |
1372 } | 1413 } |
1414 wh = NULL; /* Catch any invalid use */ 1415 |
|
1373 if (bwi_encap(sc, idx, m, ni) != 0) { 1374 /* 'm' is freed in bwi_encap() if we reach here */ | 1416 if (bwi_encap(sc, idx, m, ni) != 0) { 1417 /* 'm' is freed in bwi_encap() if we reach here */ |
1375 if (ni != NULL) { 1376 if_inc_counter(ni->ni_vap->iv_ifp, 1377 IFCOUNTER_OERRORS, 1); | 1418 if (ni != NULL) |
1378 ieee80211_free_node(ni); | 1419 ieee80211_free_node(ni); |
1379 } else 1380 counter_u64_add(sc->sc_ic.ic_oerrors, 1); | 1420 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
1381 continue; 1382 } | 1421 continue; 1422 } |
1423 |
|
1383 trans = 1; 1384 tbd->tbd_used++; 1385 idx = (idx + 1) % BWI_TX_NDESC; | 1424 trans = 1; 1425 tbd->tbd_used++; 1426 idx = (idx + 1) % BWI_TX_NDESC; |
1386 } | |
1387 | 1427 |
1428 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); 1429 1430 if (tbd->tbd_used + BWI_TX_NSPRDESC >= BWI_TX_NDESC) { 1431 ifp->if_drv_flags |= IFF_DRV_OACTIVE; 1432 break; 1433 } 1434 } |
|
1388 tbd->tbd_idx = idx; | 1435 tbd->tbd_idx = idx; |
1436 |
|
1389 if (trans) 1390 sc->sc_tx_timer = 5; 1391} 1392 1393static int 1394bwi_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, 1395 const struct ieee80211_bpf_params *params) 1396{ 1397 struct ieee80211com *ic = ni->ni_ic; | 1437 if (trans) 1438 sc->sc_tx_timer = 5; 1439} 1440 1441static int 1442bwi_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, 1443 const struct ieee80211_bpf_params *params) 1444{ 1445 struct ieee80211com *ic = ni->ni_ic; |
1398 struct bwi_softc *sc = ic->ic_softc; | 1446 struct ifnet *ifp = ic->ic_ifp; 1447 struct bwi_softc *sc = ifp->if_softc; |
1399 /* XXX wme? */ 1400 struct bwi_txbuf_data *tbd = &sc->sc_tx_bdata[BWI_TX_DATA_RING]; 1401 int idx, error; 1402 | 1448 /* XXX wme? */ 1449 struct bwi_txbuf_data *tbd = &sc->sc_tx_bdata[BWI_TX_DATA_RING]; 1450 int idx, error; 1451 |
1403 if ((sc->sc_flags & BWI_F_RUNNING) == 0) { | 1452 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { |
1404 ieee80211_free_node(ni); 1405 m_freem(m); 1406 return ENETDOWN; 1407 } 1408 1409 BWI_LOCK(sc); 1410 idx = tbd->tbd_idx; 1411 KASSERT(tbd->tbd_buf[idx].tb_mbuf == NULL, ("slot %d not empty", idx)); --- 6 unchanged lines hidden (view full) --- 1418 } else { 1419 /* 1420 * Caller supplied explicit parameters to use in 1421 * sending the frame. 1422 */ 1423 error = bwi_encap_raw(sc, idx, m, ni, params); 1424 } 1425 if (error == 0) { | 1453 ieee80211_free_node(ni); 1454 m_freem(m); 1455 return ENETDOWN; 1456 } 1457 1458 BWI_LOCK(sc); 1459 idx = tbd->tbd_idx; 1460 KASSERT(tbd->tbd_buf[idx].tb_mbuf == NULL, ("slot %d not empty", idx)); --- 6 unchanged lines hidden (view full) --- 1467 } else { 1468 /* 1469 * Caller supplied explicit parameters to use in 1470 * sending the frame. 1471 */ 1472 error = bwi_encap_raw(sc, idx, m, ni, params); 1473 } 1474 if (error == 0) { |
1426 tbd->tbd_used++; | 1475 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); 1476 if (++tbd->tbd_used + BWI_TX_NSPRDESC >= BWI_TX_NDESC) 1477 ifp->if_drv_flags |= IFF_DRV_OACTIVE; |
1427 tbd->tbd_idx = (idx + 1) % BWI_TX_NDESC; 1428 sc->sc_tx_timer = 5; | 1478 tbd->tbd_idx = (idx + 1) % BWI_TX_NDESC; 1479 sc->sc_tx_timer = 5; |
1429 } else | 1480 } else { |
1430 /* NB: m is reclaimed on encap failure */ 1431 ieee80211_free_node(ni); | 1481 /* NB: m is reclaimed on encap failure */ 1482 ieee80211_free_node(ni); |
1483 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); 1484 } |
|
1432 BWI_UNLOCK(sc); 1433 return error; 1434} 1435 1436static void 1437bwi_watchdog(void *arg) 1438{ 1439 struct bwi_softc *sc; | 1485 BWI_UNLOCK(sc); 1486 return error; 1487} 1488 1489static void 1490bwi_watchdog(void *arg) 1491{ 1492 struct bwi_softc *sc; |
1493 struct ifnet *ifp; |
|
1440 1441 sc = arg; | 1494 1495 sc = arg; |
1496 ifp = sc->sc_ifp; |
|
1442 BWI_ASSERT_LOCKED(sc); 1443 if (sc->sc_tx_timer != 0 && --sc->sc_tx_timer == 0) { | 1497 BWI_ASSERT_LOCKED(sc); 1498 if (sc->sc_tx_timer != 0 && --sc->sc_tx_timer == 0) { |
1444 device_printf(sc->sc_dev, "watchdog timeout\n"); 1445 counter_u64_add(sc->sc_ic.ic_oerrors, 1); | 1499 if_printf(ifp, "watchdog timeout\n"); 1500 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
1446 taskqueue_enqueue(sc->sc_tq, &sc->sc_restart_task); 1447 } 1448 callout_reset(&sc->sc_watchdog_timer, hz, bwi_watchdog, sc); 1449} 1450 1451static void 1452bwi_stop(struct bwi_softc *sc, int statechg) 1453{ 1454 BWI_LOCK(sc); 1455 bwi_stop_locked(sc, statechg); 1456 BWI_UNLOCK(sc); 1457} 1458 1459static void 1460bwi_stop_locked(struct bwi_softc *sc, int statechg) 1461{ | 1501 taskqueue_enqueue(sc->sc_tq, &sc->sc_restart_task); 1502 } 1503 callout_reset(&sc->sc_watchdog_timer, hz, bwi_watchdog, sc); 1504} 1505 1506static void 1507bwi_stop(struct bwi_softc *sc, int statechg) 1508{ 1509 BWI_LOCK(sc); 1510 bwi_stop_locked(sc, statechg); 1511 BWI_UNLOCK(sc); 1512} 1513 1514static void 1515bwi_stop_locked(struct bwi_softc *sc, int statechg) 1516{ |
1517 struct ifnet *ifp = sc->sc_ifp; |
|
1462 struct bwi_mac *mac; 1463 int i, error, pwr_off = 0; 1464 1465 BWI_ASSERT_LOCKED(sc); 1466 1467 callout_stop(&sc->sc_calib_ch); 1468 callout_stop(&sc->sc_led_blink_ch); 1469 sc->sc_led_blinking = 0; 1470 sc->sc_flags |= BWI_F_STOP; 1471 | 1518 struct bwi_mac *mac; 1519 int i, error, pwr_off = 0; 1520 1521 BWI_ASSERT_LOCKED(sc); 1522 1523 callout_stop(&sc->sc_calib_ch); 1524 callout_stop(&sc->sc_led_blink_ch); 1525 sc->sc_led_blinking = 0; 1526 sc->sc_flags |= BWI_F_STOP; 1527 |
1472 if (sc->sc_flags & BWI_F_RUNNING) { | 1528 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { |
1473 KASSERT(sc->sc_cur_regwin->rw_type == BWI_REGWIN_T_MAC, 1474 ("current regwin type %d", sc->sc_cur_regwin->rw_type)); 1475 mac = (struct bwi_mac *)sc->sc_cur_regwin; 1476 1477 bwi_disable_intrs(sc, BWI_ALL_INTRS); 1478 CSR_READ_4(sc, BWI_MAC_INTR_MASK); 1479 bwi_mac_stop(mac); 1480 } --- 15 unchanged lines hidden (view full) --- 1496 bwi_regwin_switch(sc, old_rw, NULL); 1497 } 1498 1499 if (pwr_off) 1500 bwi_bbp_power_off(sc); 1501 1502 sc->sc_tx_timer = 0; 1503 callout_stop(&sc->sc_watchdog_timer); | 1529 KASSERT(sc->sc_cur_regwin->rw_type == BWI_REGWIN_T_MAC, 1530 ("current regwin type %d", sc->sc_cur_regwin->rw_type)); 1531 mac = (struct bwi_mac *)sc->sc_cur_regwin; 1532 1533 bwi_disable_intrs(sc, BWI_ALL_INTRS); 1534 CSR_READ_4(sc, BWI_MAC_INTR_MASK); 1535 bwi_mac_stop(mac); 1536 } --- 15 unchanged lines hidden (view full) --- 1552 bwi_regwin_switch(sc, old_rw, NULL); 1553 } 1554 1555 if (pwr_off) 1556 bwi_bbp_power_off(sc); 1557 1558 sc->sc_tx_timer = 0; 1559 callout_stop(&sc->sc_watchdog_timer); |
1504 sc->sc_flags &= ~BWI_F_RUNNING; | 1560 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); |
1505} 1506 1507void 1508bwi_intr(void *xsc) 1509{ 1510 struct bwi_softc *sc = xsc; | 1561} 1562 1563void 1564bwi_intr(void *xsc) 1565{ 1566 struct bwi_softc *sc = xsc; |
1567 struct ifnet *ifp = sc->sc_ifp; |
|
1511 struct bwi_mac *mac; 1512 uint32_t intr_status; 1513 uint32_t txrx_intr_status[BWI_TXRX_NRING]; 1514 int i, txrx_error, tx = 0, rx_data = -1; 1515 1516 BWI_LOCK(sc); 1517 | 1568 struct bwi_mac *mac; 1569 uint32_t intr_status; 1570 uint32_t txrx_intr_status[BWI_TXRX_NRING]; 1571 int i, txrx_error, tx = 0, rx_data = -1; 1572 1573 BWI_LOCK(sc); 1574 |
1518 if ((sc->sc_flags & BWI_F_RUNNING) == 0 || | 1575 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || |
1519 (sc->sc_flags & BWI_F_STOP)) { 1520 BWI_UNLOCK(sc); 1521 return; 1522 } 1523 /* 1524 * Get interrupt status 1525 */ 1526 intr_status = CSR_READ_4(sc, BWI_MAC_INTR_STATUS); --- 26 unchanged lines hidden (view full) --- 1553 1554 txrx_intr_status[i] = 1555 CSR_READ_4(sc, BWI_TXRX_INTR_STATUS(i)) & mask; 1556 1557 _DPRINTF(sc, BWI_DBG_INTR, ", %d 0x%08x", 1558 i, txrx_intr_status[i]); 1559 1560 if (txrx_intr_status[i] & BWI_TXRX_INTR_ERROR) { | 1576 (sc->sc_flags & BWI_F_STOP)) { 1577 BWI_UNLOCK(sc); 1578 return; 1579 } 1580 /* 1581 * Get interrupt status 1582 */ 1583 intr_status = CSR_READ_4(sc, BWI_MAC_INTR_STATUS); --- 26 unchanged lines hidden (view full) --- 1610 1611 txrx_intr_status[i] = 1612 CSR_READ_4(sc, BWI_TXRX_INTR_STATUS(i)) & mask; 1613 1614 _DPRINTF(sc, BWI_DBG_INTR, ", %d 0x%08x", 1615 i, txrx_intr_status[i]); 1616 1617 if (txrx_intr_status[i] & BWI_TXRX_INTR_ERROR) { |
1561 device_printf(sc->sc_dev, | 1618 if_printf(ifp, |
1562 "%s: intr fatal TX/RX (%d) error 0x%08x\n", 1563 __func__, i, txrx_intr_status[i]); 1564 txrx_error = 1; 1565 } 1566 } 1567 _DPRINTF(sc, BWI_DBG_INTR, "%s\n", ""); 1568 1569 /* --- 21 unchanged lines hidden (view full) --- 1591 * Suggesting that we should never get it and if we do we're not 1592 * feeding TX packets into the MAC correctly if we do... Apparently, 1593 * it is valid only on mac version 5 and higher, but I couldn't 1594 * find a reference for that... Since I see them from time to time 1595 * on my card, this suggests an error in the tx path still... 1596 */ 1597 if (intr_status & BWI_INTR_PHY_TXERR) { 1598 if (mac->mac_flags & BWI_MAC_F_PHYE_RESET) { | 1619 "%s: intr fatal TX/RX (%d) error 0x%08x\n", 1620 __func__, i, txrx_intr_status[i]); 1621 txrx_error = 1; 1622 } 1623 } 1624 _DPRINTF(sc, BWI_DBG_INTR, "%s\n", ""); 1625 1626 /* --- 21 unchanged lines hidden (view full) --- 1648 * Suggesting that we should never get it and if we do we're not 1649 * feeding TX packets into the MAC correctly if we do... Apparently, 1650 * it is valid only on mac version 5 and higher, but I couldn't 1651 * find a reference for that... Since I see them from time to time 1652 * on my card, this suggests an error in the tx path still... 1653 */ 1654 if (intr_status & BWI_INTR_PHY_TXERR) { 1655 if (mac->mac_flags & BWI_MAC_F_PHYE_RESET) { |
1599 device_printf(sc->sc_dev, "%s: intr PHY TX error\n", 1600 __func__); | 1656 if_printf(ifp, "%s: intr PHY TX error\n", __func__); |
1601 taskqueue_enqueue(sc->sc_tq, &sc->sc_restart_task); 1602 BWI_UNLOCK(sc); 1603 return; 1604 } 1605 } 1606 1607 if (txrx_error) { 1608 /* TODO: reset device */ 1609 } 1610 1611 if (intr_status & BWI_INTR_TBTT) 1612 bwi_mac_config_ps(mac); 1613 1614 if (intr_status & BWI_INTR_EO_ATIM) | 1657 taskqueue_enqueue(sc->sc_tq, &sc->sc_restart_task); 1658 BWI_UNLOCK(sc); 1659 return; 1660 } 1661 } 1662 1663 if (txrx_error) { 1664 /* TODO: reset device */ 1665 } 1666 1667 if (intr_status & BWI_INTR_TBTT) 1668 bwi_mac_config_ps(mac); 1669 1670 if (intr_status & BWI_INTR_EO_ATIM) |
1615 device_printf(sc->sc_dev, "EO_ATIM\n"); | 1671 if_printf(ifp, "EO_ATIM\n"); |
1616 1617 if (intr_status & BWI_INTR_PMQ) { 1618 for (;;) { 1619 if ((CSR_READ_4(sc, BWI_MAC_PS_STATUS) & 0x8) == 0) 1620 break; 1621 } 1622 CSR_WRITE_2(sc, BWI_MAC_PS_STATUS, 0x2); 1623 } 1624 1625 if (intr_status & BWI_INTR_NOISE) | 1672 1673 if (intr_status & BWI_INTR_PMQ) { 1674 for (;;) { 1675 if ((CSR_READ_4(sc, BWI_MAC_PS_STATUS) & 0x8) == 0) 1676 break; 1677 } 1678 CSR_WRITE_2(sc, BWI_MAC_PS_STATUS, 0x2); 1679 } 1680 1681 if (intr_status & BWI_INTR_NOISE) |
1626 device_printf(sc->sc_dev, "intr noise\n"); | 1682 if_printf(ifp, "intr noise\n"); |
1627 1628 if (txrx_intr_status[0] & BWI_TXRX_INTR_RX) { 1629 rx_data = sc->sc_rxeof(sc); 1630 if (sc->sc_flags & BWI_F_STOP) { 1631 BWI_UNLOCK(sc); 1632 return; 1633 } 1634 } --- 32 unchanged lines hidden (view full) --- 1667 } 1668 1669 BWI_UNLOCK(sc); 1670} 1671 1672static void 1673bwi_scan_start(struct ieee80211com *ic) 1674{ | 1683 1684 if (txrx_intr_status[0] & BWI_TXRX_INTR_RX) { 1685 rx_data = sc->sc_rxeof(sc); 1686 if (sc->sc_flags & BWI_F_STOP) { 1687 BWI_UNLOCK(sc); 1688 return; 1689 } 1690 } --- 32 unchanged lines hidden (view full) --- 1723 } 1724 1725 BWI_UNLOCK(sc); 1726} 1727 1728static void 1729bwi_scan_start(struct ieee80211com *ic) 1730{ |
1675 struct bwi_softc *sc = ic->ic_softc; | 1731 struct bwi_softc *sc = ic->ic_ifp->if_softc; |
1676 1677 BWI_LOCK(sc); 1678 /* Enable MAC beacon promiscuity */ 1679 CSR_SETBITS_4(sc, BWI_MAC_STATUS, BWI_MAC_STATUS_PASS_BCN); 1680 BWI_UNLOCK(sc); 1681} 1682 1683static void 1684bwi_set_channel(struct ieee80211com *ic) 1685{ | 1732 1733 BWI_LOCK(sc); 1734 /* Enable MAC beacon promiscuity */ 1735 CSR_SETBITS_4(sc, BWI_MAC_STATUS, BWI_MAC_STATUS_PASS_BCN); 1736 BWI_UNLOCK(sc); 1737} 1738 1739static void 1740bwi_set_channel(struct ieee80211com *ic) 1741{ |
1686 struct bwi_softc *sc = ic->ic_softc; | 1742 struct bwi_softc *sc = ic->ic_ifp->if_softc; |
1687 struct ieee80211_channel *c = ic->ic_curchan; 1688 struct bwi_mac *mac; 1689 1690 BWI_LOCK(sc); 1691 KASSERT(sc->sc_cur_regwin->rw_type == BWI_REGWIN_T_MAC, 1692 ("current regwin type %d", sc->sc_cur_regwin->rw_type)); 1693 mac = (struct bwi_mac *)sc->sc_cur_regwin; 1694 bwi_rf_set_chan(mac, ieee80211_chan2ieee(ic, c), 0); --- 9 unchanged lines hidden (view full) --- 1704 htole16(c->ic_flags & 0xffff); 1705 1706 BWI_UNLOCK(sc); 1707} 1708 1709static void 1710bwi_scan_end(struct ieee80211com *ic) 1711{ | 1743 struct ieee80211_channel *c = ic->ic_curchan; 1744 struct bwi_mac *mac; 1745 1746 BWI_LOCK(sc); 1747 KASSERT(sc->sc_cur_regwin->rw_type == BWI_REGWIN_T_MAC, 1748 ("current regwin type %d", sc->sc_cur_regwin->rw_type)); 1749 mac = (struct bwi_mac *)sc->sc_cur_regwin; 1750 bwi_rf_set_chan(mac, ieee80211_chan2ieee(ic, c), 0); --- 9 unchanged lines hidden (view full) --- 1760 htole16(c->ic_flags & 0xffff); 1761 1762 BWI_UNLOCK(sc); 1763} 1764 1765static void 1766bwi_scan_end(struct ieee80211com *ic) 1767{ |
1712 struct bwi_softc *sc = ic->ic_softc; | 1768 struct bwi_softc *sc = ic->ic_ifp->if_softc; |
1713 1714 BWI_LOCK(sc); 1715 CSR_CLRBITS_4(sc, BWI_MAC_STATUS, BWI_MAC_STATUS_PASS_BCN); 1716 BWI_UNLOCK(sc); 1717} 1718 1719static int 1720bwi_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) 1721{ 1722 struct bwi_vap *bvp = BWI_VAP(vap); 1723 struct ieee80211com *ic= vap->iv_ic; | 1769 1770 BWI_LOCK(sc); 1771 CSR_CLRBITS_4(sc, BWI_MAC_STATUS, BWI_MAC_STATUS_PASS_BCN); 1772 BWI_UNLOCK(sc); 1773} 1774 1775static int 1776bwi_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) 1777{ 1778 struct bwi_vap *bvp = BWI_VAP(vap); 1779 struct ieee80211com *ic= vap->iv_ic; |
1724 struct bwi_softc *sc = ic->ic_softc; | 1780 struct ifnet *ifp = ic->ic_ifp; |
1725 enum ieee80211_state ostate = vap->iv_state; | 1781 enum ieee80211_state ostate = vap->iv_state; |
1782 struct bwi_softc *sc = ifp->if_softc; |
|
1726 struct bwi_mac *mac; 1727 int error; 1728 1729 BWI_LOCK(sc); 1730 1731 callout_stop(&sc->sc_calib_ch); 1732 1733 if (nstate == IEEE80211_S_INIT) --- 829 unchanged lines hidden (view full) --- 2563 } 2564} 2565 2566static int 2567bwi_rxeof(struct bwi_softc *sc, int end_idx) 2568{ 2569 struct bwi_ring_data *rd = &sc->sc_rx_rdata; 2570 struct bwi_rxbuf_data *rbd = &sc->sc_rx_bdata; | 1783 struct bwi_mac *mac; 1784 int error; 1785 1786 BWI_LOCK(sc); 1787 1788 callout_stop(&sc->sc_calib_ch); 1789 1790 if (nstate == IEEE80211_S_INIT) --- 829 unchanged lines hidden (view full) --- 2620 } 2621} 2622 2623static int 2624bwi_rxeof(struct bwi_softc *sc, int end_idx) 2625{ 2626 struct bwi_ring_data *rd = &sc->sc_rx_rdata; 2627 struct bwi_rxbuf_data *rbd = &sc->sc_rx_bdata; |
2571 struct ieee80211com *ic = &sc->sc_ic; | 2628 struct ifnet *ifp = sc->sc_ifp; 2629 struct ieee80211com *ic = ifp->if_l2com; |
2572 int idx, rx_data = 0; 2573 2574 idx = rbd->rbd_idx; 2575 while (idx != end_idx) { 2576 struct bwi_rxbuf *rb = &rbd->rbd_buf[idx]; 2577 struct bwi_rxbuf_hdr *hdr; 2578 struct ieee80211_frame_min *wh; 2579 struct ieee80211_node *ni; 2580 struct mbuf *m; 2581 uint32_t plcp; 2582 uint16_t flags2; 2583 int buflen, wh_ofs, hdr_extra, rssi, noise, type, rate; 2584 2585 m = rb->rb_mbuf; 2586 bus_dmamap_sync(sc->sc_buf_dtag, rb->rb_dmap, 2587 BUS_DMASYNC_POSTREAD); 2588 2589 if (bwi_newbuf(sc, idx, 0)) { | 2630 int idx, rx_data = 0; 2631 2632 idx = rbd->rbd_idx; 2633 while (idx != end_idx) { 2634 struct bwi_rxbuf *rb = &rbd->rbd_buf[idx]; 2635 struct bwi_rxbuf_hdr *hdr; 2636 struct ieee80211_frame_min *wh; 2637 struct ieee80211_node *ni; 2638 struct mbuf *m; 2639 uint32_t plcp; 2640 uint16_t flags2; 2641 int buflen, wh_ofs, hdr_extra, rssi, noise, type, rate; 2642 2643 m = rb->rb_mbuf; 2644 bus_dmamap_sync(sc->sc_buf_dtag, rb->rb_dmap, 2645 BUS_DMASYNC_POSTREAD); 2646 2647 if (bwi_newbuf(sc, idx, 0)) { |
2590 counter_u64_add(ic->ic_ierrors, 1); | 2648 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
2591 goto next; 2592 } 2593 2594 hdr = mtod(m, struct bwi_rxbuf_hdr *); 2595 flags2 = le16toh(hdr->rxh_flags2); 2596 2597 hdr_extra = 0; 2598 if (flags2 & BWI_RXH_F2_TYPE2FRAME) 2599 hdr_extra = 2; 2600 wh_ofs = hdr_extra + 6; /* XXX magic number */ 2601 2602 buflen = le16toh(hdr->rxh_buflen); 2603 if (buflen < BWI_FRAME_MIN_LEN(wh_ofs)) { | 2649 goto next; 2650 } 2651 2652 hdr = mtod(m, struct bwi_rxbuf_hdr *); 2653 flags2 = le16toh(hdr->rxh_flags2); 2654 2655 hdr_extra = 0; 2656 if (flags2 & BWI_RXH_F2_TYPE2FRAME) 2657 hdr_extra = 2; 2658 wh_ofs = hdr_extra + 6; /* XXX magic number */ 2659 2660 buflen = le16toh(hdr->rxh_buflen); 2661 if (buflen < BWI_FRAME_MIN_LEN(wh_ofs)) { |
2604 device_printf(sc->sc_dev, 2605 "%s: zero length data, hdr_extra %d\n", 2606 __func__, hdr_extra); 2607 counter_u64_add(ic->ic_ierrors, 1); | 2662 if_printf(ifp, "%s: zero length data, hdr_extra %d\n", 2663 __func__, hdr_extra); 2664 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
2608 m_freem(m); 2609 goto next; 2610 } 2611 2612 bcopy((uint8_t *)(hdr + 1) + hdr_extra, &plcp, sizeof(plcp)); 2613 rssi = bwi_calc_rssi(sc, hdr); 2614 noise = bwi_calc_noise(sc); 2615 | 2665 m_freem(m); 2666 goto next; 2667 } 2668 2669 bcopy((uint8_t *)(hdr + 1) + hdr_extra, &plcp, sizeof(plcp)); 2670 rssi = bwi_calc_rssi(sc, hdr); 2671 noise = bwi_calc_noise(sc); 2672 |
2673 m->m_pkthdr.rcvif = ifp; |
|
2616 m->m_len = m->m_pkthdr.len = buflen + sizeof(*hdr); 2617 m_adj(m, sizeof(*hdr) + wh_ofs); 2618 2619 if (htole16(hdr->rxh_flags1) & BWI_RXH_F1_OFDM) 2620 rate = bwi_plcp2rate(plcp, IEEE80211_T_OFDM); 2621 else 2622 rate = bwi_plcp2rate(plcp, IEEE80211_T_CCK); 2623 --- 117 unchanged lines hidden (view full) --- 2741 } 2742} 2743 2744static void 2745bwi_free_tx_ring32(struct bwi_softc *sc, int ring_idx) 2746{ 2747 struct bwi_ring_data *rd; 2748 struct bwi_txbuf_data *tbd; | 2674 m->m_len = m->m_pkthdr.len = buflen + sizeof(*hdr); 2675 m_adj(m, sizeof(*hdr) + wh_ofs); 2676 2677 if (htole16(hdr->rxh_flags1) & BWI_RXH_F1_OFDM) 2678 rate = bwi_plcp2rate(plcp, IEEE80211_T_OFDM); 2679 else 2680 rate = bwi_plcp2rate(plcp, IEEE80211_T_CCK); 2681 --- 117 unchanged lines hidden (view full) --- 2799 } 2800} 2801 2802static void 2803bwi_free_tx_ring32(struct bwi_softc *sc, int ring_idx) 2804{ 2805 struct bwi_ring_data *rd; 2806 struct bwi_txbuf_data *tbd; |
2807 struct ifnet *ifp = sc->sc_ifp; |
|
2749 uint32_t state, val; 2750 int i; 2751 2752 KASSERT(ring_idx < BWI_TX_NRING, ("ring_idx %d", ring_idx)); 2753 rd = &sc->sc_tx_rdata[ring_idx]; 2754 tbd = &sc->sc_tx_bdata[ring_idx]; 2755 2756#define NRETRY 10 --- 4 unchanged lines hidden (view full) --- 2761 if (state == BWI_TX32_STATUS_STATE_DISABLED || 2762 state == BWI_TX32_STATUS_STATE_IDLE || 2763 state == BWI_TX32_STATUS_STATE_STOPPED) 2764 break; 2765 2766 DELAY(1000); 2767 } 2768 if (i == NRETRY) { | 2808 uint32_t state, val; 2809 int i; 2810 2811 KASSERT(ring_idx < BWI_TX_NRING, ("ring_idx %d", ring_idx)); 2812 rd = &sc->sc_tx_rdata[ring_idx]; 2813 tbd = &sc->sc_tx_bdata[ring_idx]; 2814 2815#define NRETRY 10 --- 4 unchanged lines hidden (view full) --- 2820 if (state == BWI_TX32_STATUS_STATE_DISABLED || 2821 state == BWI_TX32_STATUS_STATE_IDLE || 2822 state == BWI_TX32_STATUS_STATE_STOPPED) 2823 break; 2824 2825 DELAY(1000); 2826 } 2827 if (i == NRETRY) { |
2769 device_printf(sc->sc_dev, 2770 "%s: wait for TX ring(%d) stable timed out\n", 2771 __func__, ring_idx); | 2828 if_printf(ifp, "%s: wait for TX ring(%d) stable timed out\n", 2829 __func__, ring_idx); |
2772 } 2773 2774 CSR_WRITE_4(sc, rd->rdata_txrx_ctrl + BWI_TX32_CTRL, 0); 2775 for (i = 0; i < NRETRY; ++i) { 2776 val = CSR_READ_4(sc, rd->rdata_txrx_ctrl + BWI_TX32_STATUS); 2777 state = __SHIFTOUT(val, BWI_TX32_STATUS_STATE_MASK); 2778 if (state == BWI_TX32_STATUS_STATE_DISABLED) 2779 break; 2780 2781 DELAY(1000); 2782 } 2783 if (i == NRETRY) | 2830 } 2831 2832 CSR_WRITE_4(sc, rd->rdata_txrx_ctrl + BWI_TX32_CTRL, 0); 2833 for (i = 0; i < NRETRY; ++i) { 2834 val = CSR_READ_4(sc, rd->rdata_txrx_ctrl + BWI_TX32_STATUS); 2835 state = __SHIFTOUT(val, BWI_TX32_STATUS_STATE_MASK); 2836 if (state == BWI_TX32_STATUS_STATE_DISABLED) 2837 break; 2838 2839 DELAY(1000); 2840 } 2841 if (i == NRETRY) |
2784 device_printf(sc->sc_dev, "%s: reset TX ring (%d) timed out\n", | 2842 if_printf(ifp, "%s: reset TX ring (%d) timed out\n", |
2785 __func__, ring_idx); 2786 2787#undef NRETRY 2788 2789 DELAY(1000); 2790 2791 CSR_WRITE_4(sc, rd->rdata_txrx_ctrl + BWI_TX32_RINGINFO, 0); 2792 --- 91 unchanged lines hidden (view full) --- 2884 panic("unsupport modulation type %u\n", modtype); 2885} 2886 2887static int 2888bwi_encap(struct bwi_softc *sc, int idx, struct mbuf *m, 2889 struct ieee80211_node *ni) 2890{ 2891 struct ieee80211vap *vap = ni->ni_vap; | 2843 __func__, ring_idx); 2844 2845#undef NRETRY 2846 2847 DELAY(1000); 2848 2849 CSR_WRITE_4(sc, rd->rdata_txrx_ctrl + BWI_TX32_RINGINFO, 0); 2850 --- 91 unchanged lines hidden (view full) --- 2942 panic("unsupport modulation type %u\n", modtype); 2943} 2944 2945static int 2946bwi_encap(struct bwi_softc *sc, int idx, struct mbuf *m, 2947 struct ieee80211_node *ni) 2948{ 2949 struct ieee80211vap *vap = ni->ni_vap; |
2892 struct ieee80211com *ic = &sc->sc_ic; | 2950 struct ifnet *ifp = sc->sc_ifp; 2951 struct ieee80211com *ic = ifp->if_l2com; |
2893 struct bwi_ring_data *rd = &sc->sc_tx_rdata[BWI_TX_DATA_RING]; 2894 struct bwi_txbuf_data *tbd = &sc->sc_tx_bdata[BWI_TX_DATA_RING]; 2895 struct bwi_txbuf *tb = &tbd->tbd_buf[idx]; 2896 struct bwi_mac *mac; 2897 struct bwi_txbuf_hdr *hdr; 2898 struct ieee80211_frame *wh; 2899 const struct ieee80211_txparam *tp; 2900 uint8_t rate, rate_fb; --- 59 unchanged lines hidden (view full) --- 2960 ieee80211_radiotap_tx(vap, m); 2961 } 2962 2963 /* 2964 * Setup the embedded TX header 2965 */ 2966 M_PREPEND(m, sizeof(*hdr), M_NOWAIT); 2967 if (m == NULL) { | 2952 struct bwi_ring_data *rd = &sc->sc_tx_rdata[BWI_TX_DATA_RING]; 2953 struct bwi_txbuf_data *tbd = &sc->sc_tx_bdata[BWI_TX_DATA_RING]; 2954 struct bwi_txbuf *tb = &tbd->tbd_buf[idx]; 2955 struct bwi_mac *mac; 2956 struct bwi_txbuf_hdr *hdr; 2957 struct ieee80211_frame *wh; 2958 const struct ieee80211_txparam *tp; 2959 uint8_t rate, rate_fb; --- 59 unchanged lines hidden (view full) --- 3019 ieee80211_radiotap_tx(vap, m); 3020 } 3021 3022 /* 3023 * Setup the embedded TX header 3024 */ 3025 M_PREPEND(m, sizeof(*hdr), M_NOWAIT); 3026 if (m == NULL) { |
2968 device_printf(sc->sc_dev, "%s: prepend TX header failed\n", 2969 __func__); | 3027 if_printf(ifp, "%s: prepend TX header failed\n", __func__); |
2970 return ENOBUFS; 2971 } 2972 hdr = mtod(m, struct bwi_txbuf_hdr *); 2973 2974 bzero(hdr, sizeof(*hdr)); 2975 2976 bcopy(wh->i_fc, hdr->txh_fc, sizeof(hdr->txh_fc)); 2977 bcopy(wh->i_addr1, hdr->txh_addr1, sizeof(hdr->txh_addr1)); --- 32 unchanged lines hidden (view full) --- 3010 /* Catch any further usage */ 3011 hdr = NULL; 3012 wh = NULL; 3013 3014 /* DMA load */ 3015 error = bus_dmamap_load_mbuf(sc->sc_buf_dtag, tb->tb_dmap, m, 3016 bwi_dma_buf_addr, &paddr, BUS_DMA_NOWAIT); 3017 if (error && error != EFBIG) { | 3028 return ENOBUFS; 3029 } 3030 hdr = mtod(m, struct bwi_txbuf_hdr *); 3031 3032 bzero(hdr, sizeof(*hdr)); 3033 3034 bcopy(wh->i_fc, hdr->txh_fc, sizeof(hdr->txh_fc)); 3035 bcopy(wh->i_addr1, hdr->txh_addr1, sizeof(hdr->txh_addr1)); --- 32 unchanged lines hidden (view full) --- 3068 /* Catch any further usage */ 3069 hdr = NULL; 3070 wh = NULL; 3071 3072 /* DMA load */ 3073 error = bus_dmamap_load_mbuf(sc->sc_buf_dtag, tb->tb_dmap, m, 3074 bwi_dma_buf_addr, &paddr, BUS_DMA_NOWAIT); 3075 if (error && error != EFBIG) { |
3018 device_printf(sc->sc_dev, "%s: can't load TX buffer (1) %d\n", | 3076 if_printf(ifp, "%s: can't load TX buffer (1) %d\n", |
3019 __func__, error); 3020 goto back; 3021 } 3022 3023 if (error) { /* error == EFBIG */ 3024 struct mbuf *m_new; 3025 3026 m_new = m_defrag(m, M_NOWAIT); 3027 if (m_new == NULL) { | 3077 __func__, error); 3078 goto back; 3079 } 3080 3081 if (error) { /* error == EFBIG */ 3082 struct mbuf *m_new; 3083 3084 m_new = m_defrag(m, M_NOWAIT); 3085 if (m_new == NULL) { |
3028 device_printf(sc->sc_dev, 3029 "%s: can't defrag TX buffer\n", __func__); | 3086 if_printf(ifp, "%s: can't defrag TX buffer\n", 3087 __func__); |
3030 error = ENOBUFS; 3031 goto back; 3032 } else { 3033 m = m_new; 3034 } 3035 3036 error = bus_dmamap_load_mbuf(sc->sc_buf_dtag, tb->tb_dmap, m, 3037 bwi_dma_buf_addr, &paddr, 3038 BUS_DMA_NOWAIT); 3039 if (error) { | 3088 error = ENOBUFS; 3089 goto back; 3090 } else { 3091 m = m_new; 3092 } 3093 3094 error = bus_dmamap_load_mbuf(sc->sc_buf_dtag, tb->tb_dmap, m, 3095 bwi_dma_buf_addr, &paddr, 3096 BUS_DMA_NOWAIT); 3097 if (error) { |
3040 device_printf(sc->sc_dev, 3041 "%s: can't load TX buffer (2) %d\n", | 3098 if_printf(ifp, "%s: can't load TX buffer (2) %d\n", |
3042 __func__, error); 3043 goto back; 3044 } 3045 } 3046 error = 0; 3047 3048 bus_dmamap_sync(sc->sc_buf_dtag, tb->tb_dmap, BUS_DMASYNC_PREWRITE); 3049 --- 25 unchanged lines hidden (view full) --- 3075 m_freem(m); 3076 return error; 3077} 3078 3079static int 3080bwi_encap_raw(struct bwi_softc *sc, int idx, struct mbuf *m, 3081 struct ieee80211_node *ni, const struct ieee80211_bpf_params *params) 3082{ | 3099 __func__, error); 3100 goto back; 3101 } 3102 } 3103 error = 0; 3104 3105 bus_dmamap_sync(sc->sc_buf_dtag, tb->tb_dmap, BUS_DMASYNC_PREWRITE); 3106 --- 25 unchanged lines hidden (view full) --- 3132 m_freem(m); 3133 return error; 3134} 3135 3136static int 3137bwi_encap_raw(struct bwi_softc *sc, int idx, struct mbuf *m, 3138 struct ieee80211_node *ni, const struct ieee80211_bpf_params *params) 3139{ |
3140 struct ifnet *ifp = sc->sc_ifp; |
|
3083 struct ieee80211vap *vap = ni->ni_vap; 3084 struct ieee80211com *ic = ni->ni_ic; 3085 struct bwi_ring_data *rd = &sc->sc_tx_rdata[BWI_TX_DATA_RING]; 3086 struct bwi_txbuf_data *tbd = &sc->sc_tx_bdata[BWI_TX_DATA_RING]; 3087 struct bwi_txbuf *tb = &tbd->tbd_buf[idx]; 3088 struct bwi_mac *mac; 3089 struct bwi_txbuf_hdr *hdr; 3090 struct ieee80211_frame *wh; --- 50 unchanged lines hidden (view full) --- 3141 ieee80211_radiotap_tx(vap, m); 3142 } 3143 3144 /* 3145 * Setup the embedded TX header 3146 */ 3147 M_PREPEND(m, sizeof(*hdr), M_NOWAIT); 3148 if (m == NULL) { | 3141 struct ieee80211vap *vap = ni->ni_vap; 3142 struct ieee80211com *ic = ni->ni_ic; 3143 struct bwi_ring_data *rd = &sc->sc_tx_rdata[BWI_TX_DATA_RING]; 3144 struct bwi_txbuf_data *tbd = &sc->sc_tx_bdata[BWI_TX_DATA_RING]; 3145 struct bwi_txbuf *tb = &tbd->tbd_buf[idx]; 3146 struct bwi_mac *mac; 3147 struct bwi_txbuf_hdr *hdr; 3148 struct ieee80211_frame *wh; --- 50 unchanged lines hidden (view full) --- 3199 ieee80211_radiotap_tx(vap, m); 3200 } 3201 3202 /* 3203 * Setup the embedded TX header 3204 */ 3205 M_PREPEND(m, sizeof(*hdr), M_NOWAIT); 3206 if (m == NULL) { |
3149 device_printf(sc->sc_dev, "%s: prepend TX header failed\n", 3150 __func__); | 3207 if_printf(ifp, "%s: prepend TX header failed\n", __func__); |
3151 return ENOBUFS; 3152 } 3153 hdr = mtod(m, struct bwi_txbuf_hdr *); 3154 3155 bzero(hdr, sizeof(*hdr)); 3156 3157 bcopy(wh->i_fc, hdr->txh_fc, sizeof(hdr->txh_fc)); 3158 bcopy(wh->i_addr1, hdr->txh_addr1, sizeof(hdr->txh_addr1)); --- 31 unchanged lines hidden (view full) --- 3190 3191 /* DMA load */ 3192 error = bus_dmamap_load_mbuf(sc->sc_buf_dtag, tb->tb_dmap, m, 3193 bwi_dma_buf_addr, &paddr, BUS_DMA_NOWAIT); 3194 if (error != 0) { 3195 struct mbuf *m_new; 3196 3197 if (error != EFBIG) { | 3208 return ENOBUFS; 3209 } 3210 hdr = mtod(m, struct bwi_txbuf_hdr *); 3211 3212 bzero(hdr, sizeof(*hdr)); 3213 3214 bcopy(wh->i_fc, hdr->txh_fc, sizeof(hdr->txh_fc)); 3215 bcopy(wh->i_addr1, hdr->txh_addr1, sizeof(hdr->txh_addr1)); --- 31 unchanged lines hidden (view full) --- 3247 3248 /* DMA load */ 3249 error = bus_dmamap_load_mbuf(sc->sc_buf_dtag, tb->tb_dmap, m, 3250 bwi_dma_buf_addr, &paddr, BUS_DMA_NOWAIT); 3251 if (error != 0) { 3252 struct mbuf *m_new; 3253 3254 if (error != EFBIG) { |
3198 device_printf(sc->sc_dev, 3199 "%s: can't load TX buffer (1) %d\n", | 3255 if_printf(ifp, "%s: can't load TX buffer (1) %d\n", |
3200 __func__, error); 3201 goto back; 3202 } 3203 m_new = m_defrag(m, M_NOWAIT); 3204 if (m_new == NULL) { | 3256 __func__, error); 3257 goto back; 3258 } 3259 m_new = m_defrag(m, M_NOWAIT); 3260 if (m_new == NULL) { |
3205 device_printf(sc->sc_dev, 3206 "%s: can't defrag TX buffer\n", __func__); | 3261 if_printf(ifp, "%s: can't defrag TX buffer\n", 3262 __func__); |
3207 error = ENOBUFS; 3208 goto back; 3209 } 3210 m = m_new; 3211 error = bus_dmamap_load_mbuf(sc->sc_buf_dtag, tb->tb_dmap, m, 3212 bwi_dma_buf_addr, &paddr, 3213 BUS_DMA_NOWAIT); 3214 if (error) { | 3263 error = ENOBUFS; 3264 goto back; 3265 } 3266 m = m_new; 3267 error = bus_dmamap_load_mbuf(sc->sc_buf_dtag, tb->tb_dmap, m, 3268 bwi_dma_buf_addr, &paddr, 3269 BUS_DMA_NOWAIT); 3270 if (error) { |
3215 device_printf(sc->sc_dev, 3216 "%s: can't load TX buffer (2) %d\n", | 3271 if_printf(ifp, "%s: can't load TX buffer (2) %d\n", |
3217 __func__, error); 3218 goto back; 3219 } 3220 } 3221 3222 bus_dmamap_sync(sc->sc_buf_dtag, tb->tb_dmap, BUS_DMASYNC_PREWRITE); 3223 3224 tb->tb_mbuf = m; --- 27 unchanged lines hidden (view full) --- 3252bwi_start_tx64(struct bwi_softc *sc, uint32_t tx_ctrl, int idx) 3253{ 3254 /* TODO:64 */ 3255} 3256 3257static void 3258bwi_txeof_status32(struct bwi_softc *sc) 3259{ | 3272 __func__, error); 3273 goto back; 3274 } 3275 } 3276 3277 bus_dmamap_sync(sc->sc_buf_dtag, tb->tb_dmap, BUS_DMASYNC_PREWRITE); 3278 3279 tb->tb_mbuf = m; --- 27 unchanged lines hidden (view full) --- 3307bwi_start_tx64(struct bwi_softc *sc, uint32_t tx_ctrl, int idx) 3308{ 3309 /* TODO:64 */ 3310} 3311 3312static void 3313bwi_txeof_status32(struct bwi_softc *sc) 3314{ |
3315 struct ifnet *ifp = sc->sc_ifp; |
|
3260 uint32_t val, ctrl_base; 3261 int end_idx; 3262 3263 ctrl_base = sc->sc_txstats->stats_ctrl_base; 3264 3265 val = CSR_READ_4(sc, ctrl_base + BWI_RX32_STATUS); 3266 end_idx = __SHIFTOUT(val, BWI_RX32_STATUS_INDEX_MASK) / 3267 sizeof(struct bwi_desc32); 3268 3269 bwi_txeof_status(sc, end_idx); 3270 3271 CSR_WRITE_4(sc, ctrl_base + BWI_RX32_INDEX, 3272 end_idx * sizeof(struct bwi_desc32)); 3273 | 3316 uint32_t val, ctrl_base; 3317 int end_idx; 3318 3319 ctrl_base = sc->sc_txstats->stats_ctrl_base; 3320 3321 val = CSR_READ_4(sc, ctrl_base + BWI_RX32_STATUS); 3322 end_idx = __SHIFTOUT(val, BWI_RX32_STATUS_INDEX_MASK) / 3323 sizeof(struct bwi_desc32); 3324 3325 bwi_txeof_status(sc, end_idx); 3326 3327 CSR_WRITE_4(sc, ctrl_base + BWI_RX32_INDEX, 3328 end_idx * sizeof(struct bwi_desc32)); 3329 |
3274 bwi_start_locked(sc); | 3330 if ((ifp->if_drv_flags & IFF_DRV_OACTIVE) == 0) 3331 ifp->if_start(ifp); |
3275} 3276 3277static void 3278bwi_txeof_status64(struct bwi_softc *sc) 3279{ 3280 /* TODO:64 */ 3281} 3282 3283static void 3284_bwi_txeof(struct bwi_softc *sc, uint16_t tx_id, int acked, int data_txcnt) 3285{ | 3332} 3333 3334static void 3335bwi_txeof_status64(struct bwi_softc *sc) 3336{ 3337 /* TODO:64 */ 3338} 3339 3340static void 3341_bwi_txeof(struct bwi_softc *sc, uint16_t tx_id, int acked, int data_txcnt) 3342{ |
3343 struct ifnet *ifp = sc->sc_ifp; |
|
3286 struct bwi_txbuf_data *tbd; 3287 struct bwi_txbuf *tb; 3288 int ring_idx, buf_idx; 3289 struct ieee80211_node *ni; 3290 struct ieee80211vap *vap; 3291 3292 if (tx_id == 0) { | 3344 struct bwi_txbuf_data *tbd; 3345 struct bwi_txbuf *tb; 3346 int ring_idx, buf_idx; 3347 struct ieee80211_node *ni; 3348 struct ieee80211vap *vap; 3349 3350 if (tx_id == 0) { |
3293 device_printf(sc->sc_dev, "%s: zero tx id\n", __func__); | 3351 if_printf(ifp, "%s: zero tx id\n", __func__); |
3294 return; 3295 } 3296 3297 ring_idx = __SHIFTOUT(tx_id, BWI_TXH_ID_RING_MASK); 3298 buf_idx = __SHIFTOUT(tx_id, BWI_TXH_ID_IDX_MASK); 3299 3300 KASSERT(ring_idx == BWI_TX_DATA_RING, ("ring_idx %d", ring_idx)); 3301 KASSERT(buf_idx < BWI_TX_NDESC, ("buf_idx %d", buf_idx)); --- 4 unchanged lines hidden (view full) --- 3306 3307 tb = &tbd->tbd_buf[buf_idx]; 3308 DPRINTF(sc, BWI_DBG_TXEOF, "txeof idx %d, " 3309 "acked %d, data_txcnt %d, ni %p\n", 3310 buf_idx, acked, data_txcnt, tb->tb_ni); 3311 3312 bus_dmamap_unload(sc->sc_buf_dtag, tb->tb_dmap); 3313 | 3352 return; 3353 } 3354 3355 ring_idx = __SHIFTOUT(tx_id, BWI_TXH_ID_RING_MASK); 3356 buf_idx = __SHIFTOUT(tx_id, BWI_TXH_ID_IDX_MASK); 3357 3358 KASSERT(ring_idx == BWI_TX_DATA_RING, ("ring_idx %d", ring_idx)); 3359 KASSERT(buf_idx < BWI_TX_NDESC, ("buf_idx %d", buf_idx)); --- 4 unchanged lines hidden (view full) --- 3364 3365 tb = &tbd->tbd_buf[buf_idx]; 3366 DPRINTF(sc, BWI_DBG_TXEOF, "txeof idx %d, " 3367 "acked %d, data_txcnt %d, ni %p\n", 3368 buf_idx, acked, data_txcnt, tb->tb_ni); 3369 3370 bus_dmamap_unload(sc->sc_buf_dtag, tb->tb_dmap); 3371 |
3314 if ((ni = tb->tb_ni) != NULL) { | 3372 ni = tb->tb_ni; 3373 if (tb->tb_ni != NULL) { |
3315 const struct bwi_txbuf_hdr *hdr = 3316 mtod(tb->tb_mbuf, const struct bwi_txbuf_hdr *); 3317 vap = ni->ni_vap; 3318 3319 /* NB: update rate control only for unicast frames */ 3320 if (hdr->txh_mac_ctrl & htole32(BWI_TXH_MAC_C_ACK)) { 3321 /* 3322 * Feed back 'acked and data_txcnt'. Note that the 3323 * generic AMRR code only understands one tx rate 3324 * and the estimator doesn't handle real retry counts 3325 * well so to avoid over-aggressive downshifting we 3326 * treat any number of retries as "1". 3327 */ 3328 ieee80211_ratectl_tx_complete(vap, ni, 3329 (data_txcnt > 1) ? IEEE80211_RATECTL_TX_SUCCESS : 3330 IEEE80211_RATECTL_TX_FAILURE, &acked, NULL); 3331 } | 3374 const struct bwi_txbuf_hdr *hdr = 3375 mtod(tb->tb_mbuf, const struct bwi_txbuf_hdr *); 3376 vap = ni->ni_vap; 3377 3378 /* NB: update rate control only for unicast frames */ 3379 if (hdr->txh_mac_ctrl & htole32(BWI_TXH_MAC_C_ACK)) { 3380 /* 3381 * Feed back 'acked and data_txcnt'. Note that the 3382 * generic AMRR code only understands one tx rate 3383 * and the estimator doesn't handle real retry counts 3384 * well so to avoid over-aggressive downshifting we 3385 * treat any number of retries as "1". 3386 */ 3387 ieee80211_ratectl_tx_complete(vap, ni, 3388 (data_txcnt > 1) ? IEEE80211_RATECTL_TX_SUCCESS : 3389 IEEE80211_RATECTL_TX_FAILURE, &acked, NULL); 3390 } |
3332 ieee80211_tx_complete(ni, tb->tb_mbuf, !acked); | 3391 3392 /* 3393 * Do any tx complete callback. Note this must 3394 * be done before releasing the node reference. 3395 */ 3396 if (tb->tb_mbuf->m_flags & M_TXCB) 3397 ieee80211_process_callback(ni, tb->tb_mbuf, !acked); 3398 3399 ieee80211_free_node(tb->tb_ni); |
3333 tb->tb_ni = NULL; | 3400 tb->tb_ni = NULL; |
3334 } else 3335 m_freem(tb->tb_mbuf); | 3401 } 3402 m_freem(tb->tb_mbuf); |
3336 tb->tb_mbuf = NULL; 3337 3338 if (tbd->tbd_used == 0) 3339 sc->sc_tx_timer = 0; | 3403 tb->tb_mbuf = NULL; 3404 3405 if (tbd->tbd_used == 0) 3406 sc->sc_tx_timer = 0; |
3407 3408 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; |
|
3340} 3341 3342static void 3343bwi_txeof_status(struct bwi_softc *sc, int end_idx) 3344{ 3345 struct bwi_txstats_data *st = sc->sc_txstats; 3346 int idx; 3347 --- 15 unchanged lines hidden (view full) --- 3363 idx = (idx + 1) % BWI_TXSTATS_NDESC; 3364 } 3365 st->stats_idx = idx; 3366} 3367 3368static void 3369bwi_txeof(struct bwi_softc *sc) 3370{ | 3409} 3410 3411static void 3412bwi_txeof_status(struct bwi_softc *sc, int end_idx) 3413{ 3414 struct bwi_txstats_data *st = sc->sc_txstats; 3415 int idx; 3416 --- 15 unchanged lines hidden (view full) --- 3432 idx = (idx + 1) % BWI_TXSTATS_NDESC; 3433 } 3434 st->stats_idx = idx; 3435} 3436 3437static void 3438bwi_txeof(struct bwi_softc *sc) 3439{ |
3440 struct ifnet *ifp = sc->sc_ifp; |
|
3371 3372 for (;;) { 3373 uint32_t tx_status0, tx_status1; 3374 uint16_t tx_id; 3375 int data_txcnt; 3376 3377 tx_status0 = CSR_READ_4(sc, BWI_TXSTATUS0); 3378 if ((tx_status0 & BWI_TXSTATUS0_VALID) == 0) --- 6 unchanged lines hidden (view full) --- 3385 3386 if (tx_status0 & (BWI_TXSTATUS0_AMPDU | BWI_TXSTATUS0_PENDING)) 3387 continue; 3388 3389 _bwi_txeof(sc, le16toh(tx_id), tx_status0 & BWI_TXSTATUS0_ACKED, 3390 data_txcnt); 3391 } 3392 | 3441 3442 for (;;) { 3443 uint32_t tx_status0, tx_status1; 3444 uint16_t tx_id; 3445 int data_txcnt; 3446 3447 tx_status0 = CSR_READ_4(sc, BWI_TXSTATUS0); 3448 if ((tx_status0 & BWI_TXSTATUS0_VALID) == 0) --- 6 unchanged lines hidden (view full) --- 3455 3456 if (tx_status0 & (BWI_TXSTATUS0_AMPDU | BWI_TXSTATUS0_PENDING)) 3457 continue; 3458 3459 _bwi_txeof(sc, le16toh(tx_id), tx_status0 & BWI_TXSTATUS0_ACKED, 3460 data_txcnt); 3461 } 3462 |
3393 bwi_start_locked(sc); | 3463 if ((ifp->if_drv_flags & IFF_DRV_OACTIVE) == 0) 3464 ifp->if_start(ifp); |
3394} 3395 3396static int 3397bwi_bbp_power_on(struct bwi_softc *sc, enum bwi_clock_mode clk_mode) 3398{ 3399 bwi_power_on(sc, 1); 3400 return bwi_set_clock_mode(sc, clk_mode); 3401} --- 231 unchanged lines hidden (view full) --- 3633 /* Flush pending bus write */ 3634 CSR_READ_4(sc, BWI_STATE_LO); 3635 DELAY(1); 3636} 3637 3638static void 3639bwi_set_bssid(struct bwi_softc *sc, const uint8_t *bssid) 3640{ | 3465} 3466 3467static int 3468bwi_bbp_power_on(struct bwi_softc *sc, enum bwi_clock_mode clk_mode) 3469{ 3470 bwi_power_on(sc, 1); 3471 return bwi_set_clock_mode(sc, clk_mode); 3472} --- 231 unchanged lines hidden (view full) --- 3704 /* Flush pending bus write */ 3705 CSR_READ_4(sc, BWI_STATE_LO); 3706 DELAY(1); 3707} 3708 3709static void 3710bwi_set_bssid(struct bwi_softc *sc, const uint8_t *bssid) 3711{ |
3712 struct ifnet *ifp = sc->sc_ifp; |
|
3641 struct bwi_mac *mac; 3642 struct bwi_myaddr_bssid buf; 3643 const uint8_t *p; 3644 uint32_t val; 3645 int n, i; 3646 3647 KASSERT(sc->sc_cur_regwin->rw_type == BWI_REGWIN_T_MAC, 3648 ("current regwin type %d", sc->sc_cur_regwin->rw_type)); 3649 mac = (struct bwi_mac *)sc->sc_cur_regwin; 3650 3651 bwi_set_addr_filter(sc, BWI_ADDR_FILTER_BSSID, bssid); 3652 | 3713 struct bwi_mac *mac; 3714 struct bwi_myaddr_bssid buf; 3715 const uint8_t *p; 3716 uint32_t val; 3717 int n, i; 3718 3719 KASSERT(sc->sc_cur_regwin->rw_type == BWI_REGWIN_T_MAC, 3720 ("current regwin type %d", sc->sc_cur_regwin->rw_type)); 3721 mac = (struct bwi_mac *)sc->sc_cur_regwin; 3722 3723 bwi_set_addr_filter(sc, BWI_ADDR_FILTER_BSSID, bssid); 3724 |
3653 bcopy(sc->sc_ic.ic_macaddr, buf.myaddr, sizeof(buf.myaddr)); | 3725 bcopy(IF_LLADDR(ifp), buf.myaddr, sizeof(buf.myaddr)); |
3654 bcopy(bssid, buf.bssid, sizeof(buf.bssid)); 3655 3656 n = sizeof(buf) / sizeof(val); 3657 p = (const uint8_t *)&buf; 3658 for (i = 0; i < n; ++i) { 3659 int j; 3660 3661 val = 0; --- 6 unchanged lines hidden (view full) --- 3668 3669static void 3670bwi_updateslot(struct ieee80211com *ic) 3671{ 3672 struct bwi_softc *sc = ic->ic_softc; 3673 struct bwi_mac *mac; 3674 3675 BWI_LOCK(sc); | 3726 bcopy(bssid, buf.bssid, sizeof(buf.bssid)); 3727 3728 n = sizeof(buf) / sizeof(val); 3729 p = (const uint8_t *)&buf; 3730 for (i = 0; i < n; ++i) { 3731 int j; 3732 3733 val = 0; --- 6 unchanged lines hidden (view full) --- 3740 3741static void 3742bwi_updateslot(struct ieee80211com *ic) 3743{ 3744 struct bwi_softc *sc = ic->ic_softc; 3745 struct bwi_mac *mac; 3746 3747 BWI_LOCK(sc); |
3676 if (sc->sc_flags & BWI_F_RUNNING) { | 3748 if (ic->ic_ifp->if_drv_flags & IFF_DRV_RUNNING) { |
3677 DPRINTF(sc, BWI_DBG_80211, "%s\n", __func__); 3678 3679 KASSERT(sc->sc_cur_regwin->rw_type == BWI_REGWIN_T_MAC, 3680 ("current regwin type %d", sc->sc_cur_regwin->rw_type)); 3681 mac = (struct bwi_mac *)sc->sc_cur_regwin; 3682 3683 bwi_mac_updateslot(mac, (ic->ic_flags & IEEE80211_F_SHSLOT)); 3684 } 3685 BWI_UNLOCK(sc); 3686} 3687 3688static void 3689bwi_calibrate(void *xsc) 3690{ 3691 struct bwi_softc *sc = xsc; | 3749 DPRINTF(sc, BWI_DBG_80211, "%s\n", __func__); 3750 3751 KASSERT(sc->sc_cur_regwin->rw_type == BWI_REGWIN_T_MAC, 3752 ("current regwin type %d", sc->sc_cur_regwin->rw_type)); 3753 mac = (struct bwi_mac *)sc->sc_cur_regwin; 3754 3755 bwi_mac_updateslot(mac, (ic->ic_flags & IEEE80211_F_SHSLOT)); 3756 } 3757 BWI_UNLOCK(sc); 3758} 3759 3760static void 3761bwi_calibrate(void *xsc) 3762{ 3763 struct bwi_softc *sc = xsc; |
3764#ifdef INVARIANTS 3765 struct ifnet *ifp = sc->sc_ifp; 3766 struct ieee80211com *ic = ifp->if_l2com; 3767#endif |
|
3692 struct bwi_mac *mac; 3693 3694 BWI_ASSERT_LOCKED(sc); 3695 | 3768 struct bwi_mac *mac; 3769 3770 BWI_ASSERT_LOCKED(sc); 3771 |
3696 KASSERT(sc->sc_ic.ic_opmode != IEEE80211_M_MONITOR, 3697 ("opmode %d", sc->sc_ic.ic_opmode)); | 3772 KASSERT(ic->ic_opmode != IEEE80211_M_MONITOR, 3773 ("opmode %d", ic->ic_opmode)); |
3698 3699 KASSERT(sc->sc_cur_regwin->rw_type == BWI_REGWIN_T_MAC, 3700 ("current regwin type %d", sc->sc_cur_regwin->rw_type)); 3701 mac = (struct bwi_mac *)sc->sc_cur_regwin; 3702 3703 bwi_mac_calibrate_txpower(mac, sc->sc_txpwrcb_type); 3704 sc->sc_txpwrcb_type = BWI_TXPWR_CALIB; 3705 --- 125 unchanged lines hidden (view full) --- 3831 else 3832 val &= ~led->l_mask; 3833 return val; 3834} 3835 3836static void 3837bwi_led_newstate(struct bwi_softc *sc, enum ieee80211_state nstate) 3838{ | 3774 3775 KASSERT(sc->sc_cur_regwin->rw_type == BWI_REGWIN_T_MAC, 3776 ("current regwin type %d", sc->sc_cur_regwin->rw_type)); 3777 mac = (struct bwi_mac *)sc->sc_cur_regwin; 3778 3779 bwi_mac_calibrate_txpower(mac, sc->sc_txpwrcb_type); 3780 sc->sc_txpwrcb_type = BWI_TXPWR_CALIB; 3781 --- 125 unchanged lines hidden (view full) --- 3907 else 3908 val &= ~led->l_mask; 3909 return val; 3910} 3911 3912static void 3913bwi_led_newstate(struct bwi_softc *sc, enum ieee80211_state nstate) 3914{ |
3839 struct ieee80211com *ic = &sc->sc_ic; | 3915 struct ifnet *ifp = sc->sc_ifp; 3916 struct ieee80211com *ic = ifp->if_l2com; |
3840 uint16_t val; 3841 int i; 3842 3843 if (nstate == IEEE80211_S_INIT) { 3844 callout_stop(&sc->sc_led_blink_ch); 3845 sc->sc_led_blinking = 0; 3846 } 3847 | 3917 uint16_t val; 3918 int i; 3919 3920 if (nstate == IEEE80211_S_INIT) { 3921 callout_stop(&sc->sc_led_blink_ch); 3922 sc->sc_led_blinking = 0; 3923 } 3924 |
3848 if ((sc->sc_flags & BWI_F_RUNNING) == 0) | 3925 if ((ic->ic_ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) |
3849 return; 3850 3851 val = CSR_READ_2(sc, BWI_MAC_GPIO_CTRL); 3852 for (i = 0; i < BWI_LED_MAX; ++i) { 3853 struct bwi_led *led = &sc->sc_leds[i]; 3854 int on; 3855 3856 if (led->l_act == BWI_LED_ACT_UNKN || --- 111 unchanged lines hidden (view full) --- 3968 struct bwi_softc *sc = xsc; 3969 sc->sc_led_blinking = 0; 3970} 3971 3972static void 3973bwi_restart(void *xsc, int pending) 3974{ 3975 struct bwi_softc *sc = xsc; | 3926 return; 3927 3928 val = CSR_READ_2(sc, BWI_MAC_GPIO_CTRL); 3929 for (i = 0; i < BWI_LED_MAX; ++i) { 3930 struct bwi_led *led = &sc->sc_leds[i]; 3931 int on; 3932 3933 if (led->l_act == BWI_LED_ACT_UNKN || --- 111 unchanged lines hidden (view full) --- 4045 struct bwi_softc *sc = xsc; 4046 sc->sc_led_blinking = 0; 4047} 4048 4049static void 4050bwi_restart(void *xsc, int pending) 4051{ 4052 struct bwi_softc *sc = xsc; |
4053 struct ifnet *ifp = sc->sc_ifp; |
|
3976 | 4054 |
3977 device_printf(sc->sc_dev, "%s begin, help!\n", __func__); | 4055 if_printf(ifp, "%s begin, help!\n", __func__); |
3978 BWI_LOCK(sc); | 4056 BWI_LOCK(sc); |
3979 bwi_init_statechg(sc, 0); | 4057 bwi_init_statechg(xsc, 0); |
3980#if 0 | 4058#if 0 |
3981 bwi_start_locked(sc); | 4059 bwi_start_locked(ifp); |
3982#endif 3983 BWI_UNLOCK(sc); 3984} | 4060#endif 4061 BWI_UNLOCK(sc); 4062} |