if_wpi.c (175872) | if_wpi.c (177043) |
---|---|
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 175872 2008-02-01 19:36:27Z phk $"); | 22__FBSDID("$FreeBSD: head/sys/dev/wpi/if_wpi.c 177043 2008-03-10 23:16:48Z thompsa $"); |
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. --- 39 unchanged lines hidden (view full) --- 70#include <sys/queue.h> 71#include <sys/taskqueue.h> 72#include <sys/module.h> 73#include <sys/bus.h> 74#include <sys/endian.h> 75#include <sys/linker.h> 76#include <sys/firmware.h> 77 | 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. --- 39 unchanged lines hidden (view full) --- 70#include <sys/queue.h> 71#include <sys/taskqueue.h> 72#include <sys/module.h> 73#include <sys/bus.h> 74#include <sys/endian.h> 75#include <sys/linker.h> 76#include <sys/firmware.h> 77 |
78#if (__FreeBSD_version > 700000) 79#define WPI_CURRENT 80#endif 81 | |
82#include <machine/bus.h> 83#include <machine/resource.h> | 78#include <machine/bus.h> 79#include <machine/resource.h> |
84#ifndef WPI_CURRENT 85#include <machine/clock.h> 86#endif | |
87#include <sys/rman.h> 88 89#include <dev/pci/pcireg.h> 90#include <dev/pci/pcivar.h> 91 92#include <net/bpf.h> 93#include <net/if.h> 94#include <net/if_arp.h> --- 65 unchanged lines hidden (view full) --- 160}; 161 162static int wpi_dma_contig_alloc(struct wpi_softc *, struct wpi_dma_info *, 163 void **, bus_size_t, bus_size_t, int); 164static void wpi_dma_contig_free(struct wpi_dma_info *); 165static void wpi_dma_map_addr(void *, bus_dma_segment_t *, int, int); 166static int wpi_alloc_shared(struct wpi_softc *); 167static void wpi_free_shared(struct wpi_softc *); | 80#include <sys/rman.h> 81 82#include <dev/pci/pcireg.h> 83#include <dev/pci/pcivar.h> 84 85#include <net/bpf.h> 86#include <net/if.h> 87#include <net/if_arp.h> --- 65 unchanged lines hidden (view full) --- 153}; 154 155static int wpi_dma_contig_alloc(struct wpi_softc *, struct wpi_dma_info *, 156 void **, bus_size_t, bus_size_t, int); 157static void wpi_dma_contig_free(struct wpi_dma_info *); 158static void wpi_dma_map_addr(void *, bus_dma_segment_t *, int, int); 159static int wpi_alloc_shared(struct wpi_softc *); 160static void wpi_free_shared(struct wpi_softc *); |
168static struct wpi_rbuf *wpi_alloc_rbuf(struct wpi_softc *); 169static void wpi_free_rbuf(void *, void *); 170static int wpi_alloc_rpool(struct wpi_softc *); 171static void wpi_free_rpool(struct wpi_softc *); | |
172static int wpi_alloc_rx_ring(struct wpi_softc *, struct wpi_rx_ring *); 173static void wpi_reset_rx_ring(struct wpi_softc *, struct wpi_rx_ring *); 174static void wpi_free_rx_ring(struct wpi_softc *, struct wpi_rx_ring *); 175static int wpi_alloc_tx_ring(struct wpi_softc *, struct wpi_tx_ring *, 176 int, int); 177static void wpi_reset_tx_ring(struct wpi_softc *, struct wpi_tx_ring *); 178static void wpi_free_tx_ring(struct wpi_softc *, struct wpi_tx_ring *); 179static struct ieee80211_node *wpi_node_alloc(struct ieee80211_node_table *); --- 14 unchanged lines hidden (view full) --- 194static void wpi_rx_intr(struct wpi_softc *, struct wpi_rx_desc *, 195 struct wpi_rx_data *); 196static void wpi_tx_intr(struct wpi_softc *, struct wpi_rx_desc *); 197static void wpi_cmd_intr(struct wpi_softc *, struct wpi_rx_desc *); 198static void wpi_notif_intr(struct wpi_softc *); 199static void wpi_intr(void *); 200static void wpi_ops(void *, int); 201static uint8_t wpi_plcp_signal(int); | 161static int wpi_alloc_rx_ring(struct wpi_softc *, struct wpi_rx_ring *); 162static void wpi_reset_rx_ring(struct wpi_softc *, struct wpi_rx_ring *); 163static void wpi_free_rx_ring(struct wpi_softc *, struct wpi_rx_ring *); 164static int wpi_alloc_tx_ring(struct wpi_softc *, struct wpi_tx_ring *, 165 int, int); 166static void wpi_reset_tx_ring(struct wpi_softc *, struct wpi_tx_ring *); 167static void wpi_free_tx_ring(struct wpi_softc *, struct wpi_tx_ring *); 168static struct ieee80211_node *wpi_node_alloc(struct ieee80211_node_table *); --- 14 unchanged lines hidden (view full) --- 183static void wpi_rx_intr(struct wpi_softc *, struct wpi_rx_desc *, 184 struct wpi_rx_data *); 185static void wpi_tx_intr(struct wpi_softc *, struct wpi_rx_desc *); 186static void wpi_cmd_intr(struct wpi_softc *, struct wpi_rx_desc *); 187static void wpi_notif_intr(struct wpi_softc *); 188static void wpi_intr(void *); 189static void wpi_ops(void *, int); 190static uint8_t wpi_plcp_signal(int); |
202static int wpi_queue_cmd(struct wpi_softc *, int); 203static void wpi_tick(void *); 204#if 0 205static void wpi_radio_on(void *, int); 206static void wpi_radio_off(void *, int); 207#endif | 191static int wpi_queue_cmd(struct wpi_softc *, int, int, int); 192static void wpi_watchdog(void *); |
208static int wpi_tx_data(struct wpi_softc *, struct mbuf *, 209 struct ieee80211_node *, int); 210static void wpi_start(struct ifnet *); 211static void wpi_scan_start(struct ieee80211com *); 212static void wpi_scan_end(struct ieee80211com *); 213static void wpi_set_channel(struct ieee80211com *); 214static void wpi_scan_curchan(struct ieee80211com *, unsigned long); 215static void wpi_scan_mindwell(struct ieee80211com *); | 193static int wpi_tx_data(struct wpi_softc *, struct mbuf *, 194 struct ieee80211_node *, int); 195static void wpi_start(struct ifnet *); 196static void wpi_scan_start(struct ieee80211com *); 197static void wpi_scan_end(struct ieee80211com *); 198static void wpi_set_channel(struct ieee80211com *); 199static void wpi_scan_curchan(struct ieee80211com *, unsigned long); 200static void wpi_scan_mindwell(struct ieee80211com *); |
216static void wpi_watchdog(struct ifnet *); | |
217static int wpi_ioctl(struct ifnet *, u_long, caddr_t); | 201static int wpi_ioctl(struct ifnet *, u_long, caddr_t); |
218static void wpi_restart(void *, int); | |
219static void wpi_read_eeprom(struct wpi_softc *); 220static void wpi_read_eeprom_channels(struct wpi_softc *, int); 221static void wpi_read_eeprom_group(struct wpi_softc *, int); 222static int wpi_cmd(struct wpi_softc *, int, const void *, int, int); 223static int wpi_wme_update(struct ieee80211com *); 224static int wpi_mrr_setup(struct wpi_softc *); 225static void wpi_set_led(struct wpi_softc *, uint8_t, uint8_t, uint8_t); 226static void wpi_enable_tsf(struct wpi_softc *, struct ieee80211_node *); 227#if 0 228static int wpi_setup_beacon(struct wpi_softc *, struct ieee80211_node *); 229#endif 230static int wpi_auth(struct wpi_softc *); | 202static void wpi_read_eeprom(struct wpi_softc *); 203static void wpi_read_eeprom_channels(struct wpi_softc *, int); 204static void wpi_read_eeprom_group(struct wpi_softc *, int); 205static int wpi_cmd(struct wpi_softc *, int, const void *, int, int); 206static int wpi_wme_update(struct ieee80211com *); 207static int wpi_mrr_setup(struct wpi_softc *); 208static void wpi_set_led(struct wpi_softc *, uint8_t, uint8_t, uint8_t); 209static void wpi_enable_tsf(struct wpi_softc *, struct ieee80211_node *); 210#if 0 211static int wpi_setup_beacon(struct wpi_softc *, struct ieee80211_node *); 212#endif 213static int wpi_auth(struct wpi_softc *); |
214static int wpi_run(struct wpi_softc *); |
|
231static int wpi_scan(struct wpi_softc *); 232static int wpi_config(struct wpi_softc *); 233static void wpi_stop_master(struct wpi_softc *); 234static int wpi_power_up(struct wpi_softc *); 235static int wpi_reset(struct wpi_softc *); 236static void wpi_hw_config(struct wpi_softc *); 237static void wpi_init(void *); | 215static int wpi_scan(struct wpi_softc *); 216static int wpi_config(struct wpi_softc *); 217static void wpi_stop_master(struct wpi_softc *); 218static int wpi_power_up(struct wpi_softc *); 219static int wpi_reset(struct wpi_softc *); 220static void wpi_hw_config(struct wpi_softc *); 221static void wpi_init(void *); |
222static void wpi_init_locked(struct wpi_softc *, int); |
|
238static void wpi_stop(struct wpi_softc *); 239static void wpi_stop_locked(struct wpi_softc *); 240static void wpi_iter_func(void *, struct ieee80211_node *); 241 242static void wpi_newassoc(struct ieee80211_node *, int); 243static int wpi_set_txpower(struct wpi_softc *, struct ieee80211_channel *, 244 int); 245static void wpi_calib_timeout(void *); --- 65 unchanged lines hidden (view full) --- 311 * is times where we may need to reload the firmware but we are not 312 * in a context that can access the filesystem (ie taskq cause by restart) 313 * 314 * @return 0 on success, an errno on failure 315 */ 316static int 317wpi_load_firmware(struct wpi_softc *sc) 318{ | 223static void wpi_stop(struct wpi_softc *); 224static void wpi_stop_locked(struct wpi_softc *); 225static void wpi_iter_func(void *, struct ieee80211_node *); 226 227static void wpi_newassoc(struct ieee80211_node *, int); 228static int wpi_set_txpower(struct wpi_softc *, struct ieee80211_channel *, 229 int); 230static void wpi_calib_timeout(void *); --- 65 unchanged lines hidden (view full) --- 296 * is times where we may need to reload the firmware but we are not 297 * in a context that can access the filesystem (ie taskq cause by restart) 298 * 299 * @return 0 on success, an errno on failure 300 */ 301static int 302wpi_load_firmware(struct wpi_softc *sc) 303{ |
319#ifdef WPI_CURRENT | |
320 const struct firmware *fp ; | 304 const struct firmware *fp ; |
321#else 322 struct firmware *fp; 323#endif | |
324 struct wpi_dma_info *dma = &sc->fw_dma; 325 const struct wpi_firmware_hdr *hdr; 326 const uint8_t *itext, *idata, *rtext, *rdata, *btext; 327 uint32_t itextsz, idatasz, rtextsz, rdatasz, btextsz; 328 int error; | 305 struct wpi_dma_info *dma = &sc->fw_dma; 306 const struct wpi_firmware_hdr *hdr; 307 const uint8_t *itext, *idata, *rtext, *rdata, *btext; 308 uint32_t itextsz, idatasz, rtextsz, rdatasz, btextsz; 309 int error; |
329 WPI_LOCK_DECL; | |
330 331 DPRINTFN(WPI_DEBUG_FIRMWARE, 332 ("Attempting Loading Firmware from wpi_fw module\n")); 333 334 WPI_UNLOCK(sc); 335 336 if (sc->fw_fp == NULL && (sc->fw_fp = firmware_get("wpifw")) == NULL) { 337 device_printf(sc->sc_dev, --- 139 unchanged lines hidden (view full) --- 477} 478 479/** 480 * Free the referenced firmware image 481 */ 482static void 483wpi_unload_firmware(struct wpi_softc *sc) 484{ | 310 311 DPRINTFN(WPI_DEBUG_FIRMWARE, 312 ("Attempting Loading Firmware from wpi_fw module\n")); 313 314 WPI_UNLOCK(sc); 315 316 if (sc->fw_fp == NULL && (sc->fw_fp = firmware_get("wpifw")) == NULL) { 317 device_printf(sc->sc_dev, --- 139 unchanged lines hidden (view full) --- 457} 458 459/** 460 * Free the referenced firmware image 461 */ 462static void 463wpi_unload_firmware(struct wpi_softc *sc) 464{ |
485 WPI_LOCK_DECL; | |
486 487 if (sc->fw_fp) { 488 WPI_UNLOCK(sc); 489 firmware_put(sc->fw_fp, FIRMWARE_UNLOAD); 490 WPI_LOCK(sc); 491 sc->fw_fp = NULL; 492 } 493} --- 30 unchanged lines hidden (view full) --- 524 /* 525 * Create the taskqueues used by the driver. Primarily 526 * sc_tq handles most the task 527 */ 528 sc->sc_tq = taskqueue_create("wpi_taskq", M_NOWAIT | M_ZERO, 529 taskqueue_thread_enqueue, &sc->sc_tq); 530 taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, "%s taskq", 531 device_get_nameunit(dev)); | 465 466 if (sc->fw_fp) { 467 WPI_UNLOCK(sc); 468 firmware_put(sc->fw_fp, FIRMWARE_UNLOAD); 469 WPI_LOCK(sc); 470 sc->fw_fp = NULL; 471 } 472} --- 30 unchanged lines hidden (view full) --- 503 /* 504 * Create the taskqueues used by the driver. Primarily 505 * sc_tq handles most the task 506 */ 507 sc->sc_tq = taskqueue_create("wpi_taskq", M_NOWAIT | M_ZERO, 508 taskqueue_thread_enqueue, &sc->sc_tq); 509 taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, "%s taskq", 510 device_get_nameunit(dev)); |
532 533 sc->sc_tq2 = taskqueue_create("wpi_taskq2", M_NOWAIT | M_ZERO, 534 taskqueue_thread_enqueue, &sc->sc_tq2); 535 taskqueue_start_threads(&sc->sc_tq2, 1, PI_NET, "%s taskq2", 536 device_get_nameunit(dev)); | |
537#else 538#error "Sorry, this driver is not yet ready for FreeBSD < 7.0" 539#endif 540 541 /* Create the tasks that can be queued */ | 511#else 512#error "Sorry, this driver is not yet ready for FreeBSD < 7.0" 513#endif 514 515 /* Create the tasks that can be queued */ |
542#if 0 543 TASK_INIT(&sc->sc_radioontask, 0, wpi_radio_on, sc); 544 TASK_INIT(&sc->sc_radioofftask, 0, wpi_radio_off, sc); 545#endif | |
546 TASK_INIT(&sc->sc_opstask, 0, wpi_ops, sc); | 516 TASK_INIT(&sc->sc_opstask, 0, wpi_ops, sc); |
547 TASK_INIT(&sc->sc_restarttask, 0, wpi_restart, sc); | |
548 549 WPI_LOCK_INIT(sc); 550 WPI_CMD_LOCK_INIT(sc); 551 552 callout_init_mtx(&sc->calib_to, &sc->sc_mtx, 0); 553 callout_init_mtx(&sc->watchdog_to, &sc->sc_mtx, 0); 554 555 if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) { --- 54 unchanged lines hidden (view full) --- 610 wpi_mem_unlock(sc); 611 612 /* Allocate shared page */ 613 if ((error = wpi_alloc_shared(sc)) != 0) { 614 device_printf(dev, "could not allocate shared page\n"); 615 goto fail; 616 } 617 | 517 518 WPI_LOCK_INIT(sc); 519 WPI_CMD_LOCK_INIT(sc); 520 521 callout_init_mtx(&sc->calib_to, &sc->sc_mtx, 0); 522 callout_init_mtx(&sc->watchdog_to, &sc->sc_mtx, 0); 523 524 if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) { --- 54 unchanged lines hidden (view full) --- 579 wpi_mem_unlock(sc); 580 581 /* Allocate shared page */ 582 if ((error = wpi_alloc_shared(sc)) != 0) { 583 device_printf(dev, "could not allocate shared page\n"); 584 goto fail; 585 } 586 |
618 /* 619 * Allocate the receive buffer pool. The recieve buffers are 620 * WPI_RBUF_SIZE in length (3k) this is bigger than MCLBYTES 621 * hence we can't simply use a cluster and used mapped dma memory 622 * instead. 623 */ 624 if ((error = wpi_alloc_rpool(sc)) != 0) { 625 device_printf(dev, "could not allocate Rx buffers\n"); 626 goto fail; 627 } 628 | |
629 /* tx data queues - 4 for QoS purposes */ 630 for (ac = 0; ac < WME_NUM_AC; ac++) { 631 error = wpi_alloc_tx_ring(sc, &sc->txq[ac], WPI_TX_RING_COUNT, ac); 632 if (error != 0) { 633 device_printf(dev, "could not allocate Tx ring %d\n",ac); 634 goto fail; 635 } 636 } --- 102 unchanged lines hidden (view full) --- 739 740 sc->sc_txtap_len = sizeof sc->sc_txtap; 741 sc->sc_txtap.wt_ihdr.it_len = htole16(sc->sc_txtap_len); 742 sc->sc_txtap.wt_ihdr.it_present = htole32(WPI_TX_RADIOTAP_PRESENT); 743 744 /* 745 * Hook our interrupt after all initialization is complete. 746 */ | 587 /* tx data queues - 4 for QoS purposes */ 588 for (ac = 0; ac < WME_NUM_AC; ac++) { 589 error = wpi_alloc_tx_ring(sc, &sc->txq[ac], WPI_TX_RING_COUNT, ac); 590 if (error != 0) { 591 device_printf(dev, "could not allocate Tx ring %d\n",ac); 592 goto fail; 593 } 594 } --- 102 unchanged lines hidden (view full) --- 697 698 sc->sc_txtap_len = sizeof sc->sc_txtap; 699 sc->sc_txtap.wt_ihdr.it_len = htole16(sc->sc_txtap_len); 700 sc->sc_txtap.wt_ihdr.it_present = htole32(WPI_TX_RADIOTAP_PRESENT); 701 702 /* 703 * Hook our interrupt after all initialization is complete. 704 */ |
747 error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET |INTR_MPSAFE , 748#ifdef WPI_CURRENT 749 NULL, 750#endif 751 wpi_intr, sc, &sc->sc_ih); | 705 error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET |INTR_MPSAFE, 706 NULL, wpi_intr, sc, &sc->sc_ih); |
752 if (error != 0) { 753 device_printf(dev, "could not set up interrupt\n"); 754 goto fail; 755 } 756 | 707 if (error != 0) { 708 device_printf(dev, "could not set up interrupt\n"); 709 goto fail; 710 } 711 |
757 ieee80211_announce(ic); | 712 if (bootverbose) 713 ieee80211_announce(ic); |
758#ifdef XXX_DEBUG 759 ieee80211_announce_channels(ic); 760#endif 761 762 return 0; 763 764fail: wpi_detach(dev); 765 return ENXIO; 766} 767 768static int 769wpi_detach(device_t dev) 770{ 771 struct wpi_softc *sc = device_get_softc(dev); 772 struct ieee80211com *ic = &sc->sc_ic; 773 struct ifnet *ifp = ic->ic_ifp; 774 int ac; | 714#ifdef XXX_DEBUG 715 ieee80211_announce_channels(ic); 716#endif 717 718 return 0; 719 720fail: wpi_detach(dev); 721 return ENXIO; 722} 723 724static int 725wpi_detach(device_t dev) 726{ 727 struct wpi_softc *sc = device_get_softc(dev); 728 struct ieee80211com *ic = &sc->sc_ic; 729 struct ifnet *ifp = ic->ic_ifp; 730 int ac; |
775 WPI_LOCK_DECL; | |
776 777 if (ifp != NULL) { 778 wpi_stop(sc); 779 callout_drain(&sc->watchdog_to); 780 callout_drain(&sc->calib_to); 781 bpfdetach(ifp); 782 ieee80211_ifdetach(ic); 783 } 784 785 WPI_LOCK(sc); 786 if (sc->txq[0].data_dmat) { 787 for (ac = 0; ac < WME_NUM_AC; ac++) 788 wpi_free_tx_ring(sc, &sc->txq[ac]); 789 790 wpi_free_tx_ring(sc, &sc->cmdq); 791 wpi_free_rx_ring(sc, &sc->rxq); | 731 732 if (ifp != NULL) { 733 wpi_stop(sc); 734 callout_drain(&sc->watchdog_to); 735 callout_drain(&sc->calib_to); 736 bpfdetach(ifp); 737 ieee80211_ifdetach(ic); 738 } 739 740 WPI_LOCK(sc); 741 if (sc->txq[0].data_dmat) { 742 for (ac = 0; ac < WME_NUM_AC; ac++) 743 wpi_free_tx_ring(sc, &sc->txq[ac]); 744 745 wpi_free_tx_ring(sc, &sc->cmdq); 746 wpi_free_rx_ring(sc, &sc->rxq); |
792 wpi_free_rpool(sc); | |
793 wpi_free_shared(sc); 794 } 795 796 if (sc->fw_fp != NULL) { 797 wpi_unload_firmware(sc); 798 } 799 800 if (sc->fw_dma.tag) --- 7 unchanged lines hidden (view full) --- 808 809 if (sc->mem != NULL) 810 bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem); 811 812 if (ifp != NULL) 813 if_free(ifp); 814 815 taskqueue_free(sc->sc_tq); | 747 wpi_free_shared(sc); 748 } 749 750 if (sc->fw_fp != NULL) { 751 wpi_unload_firmware(sc); 752 } 753 754 if (sc->fw_dma.tag) --- 7 unchanged lines hidden (view full) --- 762 763 if (sc->mem != NULL) 764 bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem); 765 766 if (ifp != NULL) 767 if_free(ifp); 768 769 taskqueue_free(sc->sc_tq); |
816 taskqueue_free(sc->sc_tq2); | |
817 818 WPI_LOCK_DESTROY(sc); 819 WPI_CMD_LOCK_DESTROY(sc); 820 821 return 0; 822} 823 824static void 825wpi_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nsegs, int error) 826{ 827 if (error != 0) 828 return; 829 830 KASSERT(nsegs == 1, ("too many DMA segments, %d should be 1", nsegs)); 831 832 *(bus_addr_t *)arg = segs[0].ds_addr; 833} 834 | 770 771 WPI_LOCK_DESTROY(sc); 772 WPI_CMD_LOCK_DESTROY(sc); 773 774 return 0; 775} 776 777static void 778wpi_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nsegs, int error) 779{ 780 if (error != 0) 781 return; 782 783 KASSERT(nsegs == 1, ("too many DMA segments, %d should be 1", nsegs)); 784 785 *(bus_addr_t *)arg = segs[0].ds_addr; 786} 787 |
788/* 789 * Allocates a contiguous block of dma memory of the requested size and 790 * alignment. Due to limitations of the FreeBSD dma subsystem as of 20071217, 791 * allocations greater than 4096 may fail. Hence if the requested alignment is 792 * greater we allocate 'alignment' size extra memory and shift the vaddr and 793 * paddr after the dma load. This bypasses the problem at the cost of a little 794 * more memory. 795 */ |
|
835static int 836wpi_dma_contig_alloc(struct wpi_softc *sc, struct wpi_dma_info *dma, 837 void **kvap, bus_size_t size, bus_size_t alignment, int flags) 838{ 839 int error; | 796static int 797wpi_dma_contig_alloc(struct wpi_softc *sc, struct wpi_dma_info *dma, 798 void **kvap, bus_size_t size, bus_size_t alignment, int flags) 799{ 800 int error; |
840 int count = 0; | 801 bus_size_t align; 802 bus_size_t reqsize; |
841 842 DPRINTFN(WPI_DEBUG_DMA, | 803 804 DPRINTFN(WPI_DEBUG_DMA, |
843 ("Size: %zd - alignement %zd\n", size, alignment)); | 805 ("Size: %zd - alignment %zd\n", size, alignment)); |
844 845 dma->size = size; 846 dma->tag = NULL; 847 | 806 807 dma->size = size; 808 dma->tag = NULL; 809 |
848again: 849 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), alignment, | 810 if (alignment > 4096) { 811 align = PAGE_SIZE; 812 reqsize = size + alignment; 813 } else { 814 align = alignment; 815 reqsize = size; 816 } 817 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), align, |
850 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, | 818 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, |
851 NULL, NULL, size, 852 1, size, flags, | 819 NULL, NULL, reqsize, 820 1, reqsize, flags, |
853 NULL, NULL, &dma->tag); 854 if (error != 0) { 855 device_printf(sc->sc_dev, 856 "could not create shared page DMA tag\n"); 857 goto fail; 858 } | 821 NULL, NULL, &dma->tag); 822 if (error != 0) { 823 device_printf(sc->sc_dev, 824 "could not create shared page DMA tag\n"); 825 goto fail; 826 } |
859 error = bus_dmamem_alloc(dma->tag, (void **)&dma->vaddr, | 827 error = bus_dmamem_alloc(dma->tag, (void **)&dma->vaddr_start, |
860 flags | BUS_DMA_ZERO, &dma->map); 861 if (error != 0) { 862 device_printf(sc->sc_dev, 863 "could not allocate shared page DMA memory\n"); 864 goto fail; 865 } 866 | 828 flags | BUS_DMA_ZERO, &dma->map); 829 if (error != 0) { 830 device_printf(sc->sc_dev, 831 "could not allocate shared page DMA memory\n"); 832 goto fail; 833 } 834 |
867 /** 868 * Sadly FreeBSD can't always align on a 16k boundary, hence we give it 869 * 10 attempts increasing the size of the allocation by 4k each time. 870 * This should eventually align us on a 16k boundary at the cost 871 * of chewing up dma memory | 835 error = bus_dmamap_load(dma->tag, dma->map, dma->vaddr_start, 836 reqsize, wpi_dma_map_addr, &dma->paddr_start, flags); 837 838 /* Save the original pointers so we can free all the memory */ 839 dma->paddr = dma->paddr_start; 840 dma->vaddr = dma->vaddr_start; 841 842 /* 843 * Check the alignment and increment by 4096 until we get the 844 * requested alignment. Fail if can't obtain the alignment 845 * we requested. |
872 */ | 846 */ |
873 if ((((uintptr_t)dma->vaddr) & (alignment-1)) && count < 10) { 874 DPRINTFN(WPI_DEBUG_DMA, 875 ("Memory Unaligned, trying again: %d\n", count++)); 876 wpi_dma_contig_free(dma); 877 size += 4096; 878 goto again; 879 } | 847 if ((dma->paddr & (alignment -1 )) != 0) { 848 int i; |
880 | 849 |
881 DPRINTFN(WPI_DEBUG_DMA,("Memory, allocated & %s Aligned!\n", 882 count == 10 ? "FAILED" : "")); 883 if (count == 10) { 884 device_printf(sc->sc_dev, "Unable to align memory\n"); 885 error = ENOMEM; 886 goto fail; | 850 for (i = 0; i < alignment / 4096; i++) { 851 if ((dma->paddr & (alignment - 1 )) == 0) 852 break; 853 dma->paddr += 4096; 854 dma->vaddr += 4096; 855 } 856 if (i == alignment / 4096) { 857 device_printf(sc->sc_dev, 858 "alignment requirement was not satisfied\n"); 859 goto fail; 860 } |
887 } 888 | 861 } 862 |
889 error = bus_dmamap_load(dma->tag, dma->map, dma->vaddr, 890 size, wpi_dma_map_addr, &dma->paddr, flags); 891 | |
892 if (error != 0) { 893 device_printf(sc->sc_dev, 894 "could not load shared page DMA map\n"); 895 goto fail; 896 } 897 898 if (kvap != NULL) 899 *kvap = dma->vaddr; --- 5 unchanged lines hidden (view full) --- 905 return error; 906} 907 908static void 909wpi_dma_contig_free(struct wpi_dma_info *dma) 910{ 911 if (dma->tag) { 912 if (dma->map != NULL) { | 863 if (error != 0) { 864 device_printf(sc->sc_dev, 865 "could not load shared page DMA map\n"); 866 goto fail; 867 } 868 869 if (kvap != NULL) 870 *kvap = dma->vaddr; --- 5 unchanged lines hidden (view full) --- 876 return error; 877} 878 879static void 880wpi_dma_contig_free(struct wpi_dma_info *dma) 881{ 882 if (dma->tag) { 883 if (dma->map != NULL) { |
913 if (dma->paddr == 0) { | 884 if (dma->paddr_start != 0) { |
914 bus_dmamap_sync(dma->tag, dma->map, 915 BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); 916 bus_dmamap_unload(dma->tag, dma->map); 917 } | 885 bus_dmamap_sync(dma->tag, dma->map, 886 BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); 887 bus_dmamap_unload(dma->tag, dma->map); 888 } |
918 bus_dmamem_free(dma->tag, &dma->vaddr, dma->map); | 889 bus_dmamem_free(dma->tag, &dma->vaddr_start, dma->map); |
919 } 920 bus_dma_tag_destroy(dma->tag); 921 } 922} 923 924/* 925 * Allocate a shared page between host and NIC. 926 */ --- 16 unchanged lines hidden (view full) --- 943} 944 945static void 946wpi_free_shared(struct wpi_softc *sc) 947{ 948 wpi_dma_contig_free(&sc->shared_dma); 949} 950 | 890 } 891 bus_dma_tag_destroy(dma->tag); 892 } 893} 894 895/* 896 * Allocate a shared page between host and NIC. 897 */ --- 16 unchanged lines hidden (view full) --- 914} 915 916static void 917wpi_free_shared(struct wpi_softc *sc) 918{ 919 wpi_dma_contig_free(&sc->shared_dma); 920} 921 |
951struct wpi_rbuf * 952wpi_alloc_rbuf(struct wpi_softc *sc) 953{ 954 struct wpi_rbuf *rbuf; 955 956 rbuf = SLIST_FIRST(&sc->rxq.freelist); 957 if (rbuf == NULL) 958 return NULL; 959 SLIST_REMOVE_HEAD(&sc->rxq.freelist, next); 960 return rbuf; 961} 962 963/* 964 * This is called automatically by the network stack when the mbuf to which our 965 * Rx buffer is attached is freed. 966 */ 967static void 968wpi_free_rbuf(void *buf, void *arg) 969{ 970 struct wpi_rbuf *rbuf = arg; 971 struct wpi_softc *sc = rbuf->sc; 972 WPI_LOCK_DECL; 973 974 WPI_LOCK(sc); 975 976 /* put the buffer back in the free list */ 977 SLIST_INSERT_HEAD(&sc->rxq.freelist, rbuf, next); 978 979 WPI_UNLOCK(sc); 980} 981 | |
982static int | 922static int |
983wpi_alloc_rpool(struct wpi_softc *sc) 984{ 985 struct wpi_rx_ring *ring = &sc->rxq; 986 struct wpi_rbuf *rbuf; 987 int i, error; 988 989 /* allocate a big chunk of DMA'able memory.. */ 990 error = wpi_dma_contig_alloc(sc, &ring->buf_dma, NULL, 991 WPI_RBUF_COUNT * WPI_RBUF_SIZE, PAGE_SIZE, BUS_DMA_NOWAIT); 992 if (error != 0) { 993 device_printf(sc->sc_dev, 994 "could not allocate Rx buffers DMA memory\n"); 995 return error; 996 } 997 998 /* ..and split it into 3KB chunks */ 999 SLIST_INIT(&ring->freelist); 1000 for (i = 0; i < WPI_RBUF_COUNT; i++) { 1001 rbuf = &ring->rbuf[i]; 1002 1003 rbuf->sc = sc; /* backpointer for callbacks */ 1004 rbuf->vaddr = ring->buf_dma.vaddr + i * WPI_RBUF_SIZE; 1005 rbuf->paddr = ring->buf_dma.paddr + i * WPI_RBUF_SIZE; 1006 1007 SLIST_INSERT_HEAD(&ring->freelist, rbuf, next); 1008 } 1009 return 0; 1010} 1011 1012static void 1013wpi_free_rpool(struct wpi_softc *sc) 1014{ 1015 wpi_dma_contig_free(&sc->rxq.buf_dma); 1016} 1017 1018static int | |
1019wpi_alloc_rx_ring(struct wpi_softc *sc, struct wpi_rx_ring *ring) 1020{ 1021 | 923wpi_alloc_rx_ring(struct wpi_softc *sc, struct wpi_rx_ring *ring) 924{ 925 |
1022 struct wpi_rx_data *data; 1023 struct wpi_rbuf *rbuf; | |
1024 int i, error; 1025 1026 ring->cur = 0; 1027 1028 error = wpi_dma_contig_alloc(sc, &ring->desc_dma, | 926 int i, error; 927 928 ring->cur = 0; 929 930 error = wpi_dma_contig_alloc(sc, &ring->desc_dma, |
1029 (void **)&ring->desc, WPI_RX_RING_COUNT * sizeof (uint32_t), 1030 WPI_RING_DMA_ALIGN, BUS_DMA_NOWAIT); | 931 (void **)&ring->desc, WPI_RX_RING_COUNT * sizeof (uint32_t), 932 WPI_RING_DMA_ALIGN, BUS_DMA_NOWAIT); |
1031 1032 if (error != 0) { | 933 934 if (error != 0) { |
1033 device_printf(sc->sc_dev, 1034 "could not allocate rx ring DMA memory\n"); 1035 goto fail; | 935 device_printf(sc->sc_dev, 936 "%s: could not allocate rx ring DMA memory, error %d\n", 937 __func__, error); 938 goto fail; |
1036 } 1037 | 939 } 940 |
941 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, 942 BUS_SPACE_MAXADDR_32BIT, 943 BUS_SPACE_MAXADDR, NULL, NULL, MJUMPAGESIZE, 1, 944 MJUMPAGESIZE, BUS_DMA_NOWAIT, NULL, NULL, &ring->data_dmat); 945 if (error != 0) { 946 device_printf(sc->sc_dev, 947 "%s: bus_dma_tag_create_failed, error %d\n", 948 __func__, error); 949 goto fail; 950 } 951 |
|
1038 /* | 952 /* |
1039 * Allocate Rx buffers. | 953 * Setup Rx buffers. |
1040 */ 1041 for (i = 0; i < WPI_RX_RING_COUNT; i++) { | 954 */ 955 for (i = 0; i < WPI_RX_RING_COUNT; i++) { |
1042 data = &ring->data[i]; | 956 struct wpi_rx_data *data = &ring->data[i]; 957 struct mbuf *m; 958 bus_addr_t paddr; |
1043 | 959 |
1044 data->m = m_gethdr(M_DONTWAIT, MT_DATA); 1045 if (data->m == NULL) { | 960 error = bus_dmamap_create(ring->data_dmat, 0, &data->map); 961 if (error != 0) { |
1046 device_printf(sc->sc_dev, | 962 device_printf(sc->sc_dev, |
1047 "could not allocate rx mbuf\n"); 1048 error = ENOBUFS; | 963 "%s: bus_dmamap_create failed, error %d\n", 964 __func__, error); |
1049 goto fail; 1050 } | 965 goto fail; 966 } |
1051 1052 if ((rbuf = wpi_alloc_rbuf(sc)) == NULL) { 1053 m_freem(data->m); 1054 data->m = NULL; | 967 m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUMPAGESIZE); 968 if (m == NULL) { |
1055 device_printf(sc->sc_dev, | 969 device_printf(sc->sc_dev, |
1056 "could not allocate rx buffer\n"); 1057 error = ENOBUFS; | 970 "%s: could not allocate rx mbuf\n", __func__); 971 error = ENOMEM; |
1058 goto fail; 1059 } | 972 goto fail; 973 } |
1060 1061 /* attach RxBuffer to mbuf */ 1062 MEXTADD(data->m, rbuf->vaddr, WPI_RBUF_SIZE,wpi_free_rbuf, 1063 rbuf->vaddr, rbuf, 0, EXT_NET_DRV); 1064 1065 if ((data->m->m_flags & M_EXT) == 0) { 1066 m_freem(data->m); 1067 data->m = NULL; 1068 error = ENOBUFS; | 974 /* map page */ 975 error = bus_dmamap_load(ring->data_dmat, data->map, 976 mtod(m, caddr_t), MJUMPAGESIZE, 977 wpi_dma_map_addr, &paddr, BUS_DMA_NOWAIT); 978 if (error != 0 && error != EFBIG) { 979 device_printf(sc->sc_dev, 980 "%s: bus_dmamap_load failed, error %d\n", 981 __func__, error); 982 m_freem(m); 983 error = ENOMEM; /* XXX unique code */ |
1069 goto fail; 1070 } | 984 goto fail; 985 } |
1071 ring->desc[i] = htole32(rbuf->paddr); 1072 } | 986 bus_dmamap_sync(ring->data_dmat, data->map, 987 BUS_DMASYNC_PREWRITE); |
1073 | 988 |
989 data->m = m; 990 ring->desc[i] = htole32(paddr); 991 } |
|
1074 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, 1075 BUS_DMASYNC_PREWRITE); | 992 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, 993 BUS_DMASYNC_PREWRITE); |
1076 | |
1077 return 0; | 994 return 0; |
1078 | |
1079fail: 1080 wpi_free_rx_ring(sc, ring); 1081 return error; 1082} 1083 1084static void 1085wpi_reset_rx_ring(struct wpi_softc *sc, struct wpi_rx_ring *ring) 1086{ --- 7 unchanged lines hidden (view full) --- 1094 if (WPI_READ(sc, WPI_RX_STATUS) & WPI_RX_IDLE) 1095 break; 1096 DELAY(10); 1097 } 1098 1099 wpi_mem_unlock(sc); 1100 1101#ifdef WPI_DEBUG | 995fail: 996 wpi_free_rx_ring(sc, ring); 997 return error; 998} 999 1000static void 1001wpi_reset_rx_ring(struct wpi_softc *sc, struct wpi_rx_ring *ring) 1002{ --- 7 unchanged lines hidden (view full) --- 1010 if (WPI_READ(sc, WPI_RX_STATUS) & WPI_RX_IDLE) 1011 break; 1012 DELAY(10); 1013 } 1014 1015 wpi_mem_unlock(sc); 1016 1017#ifdef WPI_DEBUG |
1102 if (ntries == 100 && wpi_debug > 0) | 1018 if (ntries == 100) |
1103 device_printf(sc->sc_dev, "timeout resetting Rx ring\n"); 1104#endif 1105 1106 ring->cur = 0; 1107} 1108 1109static void 1110wpi_free_rx_ring(struct wpi_softc *sc, struct wpi_rx_ring *ring) 1111{ 1112 int i; 1113 1114 wpi_dma_contig_free(&ring->desc_dma); 1115 | 1019 device_printf(sc->sc_dev, "timeout resetting Rx ring\n"); 1020#endif 1021 1022 ring->cur = 0; 1023} 1024 1025static void 1026wpi_free_rx_ring(struct wpi_softc *sc, struct wpi_rx_ring *ring) 1027{ 1028 int i; 1029 1030 wpi_dma_contig_free(&ring->desc_dma); 1031 |
1116 for (i = 0; i < WPI_RX_RING_COUNT; i++) { 1117 if (ring->data[i].m != NULL) { | 1032 for (i = 0; i < WPI_RX_RING_COUNT; i++) 1033 if (ring->data[i].m != NULL) |
1118 m_freem(ring->data[i].m); | 1034 m_freem(ring->data[i].m); |
1119 ring->data[i].m = NULL; 1120 } 1121 } | |
1122} 1123 1124static int 1125wpi_alloc_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring, int count, 1126 int qid) 1127{ 1128 struct wpi_tx_data *data; 1129 int i, error; --- 53 unchanged lines hidden (view full) --- 1183 goto fail; 1184 } 1185 bus_dmamap_sync(ring->data_dmat, data->map, 1186 BUS_DMASYNC_PREWRITE); 1187 } 1188 1189 return 0; 1190 | 1035} 1036 1037static int 1038wpi_alloc_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring, int count, 1039 int qid) 1040{ 1041 struct wpi_tx_data *data; 1042 int i, error; --- 53 unchanged lines hidden (view full) --- 1096 goto fail; 1097 } 1098 bus_dmamap_sync(ring->data_dmat, data->map, 1099 BUS_DMASYNC_PREWRITE); 1100 } 1101 1102 return 0; 1103 |
1191fail: wpi_free_tx_ring(sc, ring); | 1104fail: 1105 wpi_free_tx_ring(sc, ring); |
1192 return error; 1193} 1194 1195static void 1196wpi_reset_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring) 1197{ 1198 struct wpi_tx_data *data; 1199 int i, ntries; 1200 1201 wpi_mem_lock(sc); 1202 1203 WPI_WRITE(sc, WPI_TX_CONFIG(ring->qid), 0); 1204 for (ntries = 0; ntries < 100; ntries++) { 1205 if (WPI_READ(sc, WPI_TX_STATUS) & WPI_TX_IDLE(ring->qid)) 1206 break; 1207 DELAY(10); 1208 } 1209#ifdef WPI_DEBUG | 1106 return error; 1107} 1108 1109static void 1110wpi_reset_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring) 1111{ 1112 struct wpi_tx_data *data; 1113 int i, ntries; 1114 1115 wpi_mem_lock(sc); 1116 1117 WPI_WRITE(sc, WPI_TX_CONFIG(ring->qid), 0); 1118 for (ntries = 0; ntries < 100; ntries++) { 1119 if (WPI_READ(sc, WPI_TX_STATUS) & WPI_TX_IDLE(ring->qid)) 1120 break; 1121 DELAY(10); 1122 } 1123#ifdef WPI_DEBUG |
1210 if (ntries == 100 && wpi_debug > 0) { | 1124 if (ntries == 100) |
1211 device_printf(sc->sc_dev, "timeout resetting Tx ring %d\n", 1212 ring->qid); | 1125 device_printf(sc->sc_dev, "timeout resetting Tx ring %d\n", 1126 ring->qid); |
1213 } | |
1214#endif 1215 wpi_mem_unlock(sc); 1216 1217 for (i = 0; i < ring->count; i++) { 1218 data = &ring->data[i]; 1219 1220 if (data->m != NULL) { 1221 bus_dmamap_unload(ring->data_dmat, data->map); --- 33 unchanged lines hidden (view full) --- 1255 if (ring->data_dmat != NULL) 1256 bus_dma_tag_destroy(ring->data_dmat); 1257} 1258 1259static int 1260wpi_shutdown(device_t dev) 1261{ 1262 struct wpi_softc *sc = device_get_softc(dev); | 1127#endif 1128 wpi_mem_unlock(sc); 1129 1130 for (i = 0; i < ring->count; i++) { 1131 data = &ring->data[i]; 1132 1133 if (data->m != NULL) { 1134 bus_dmamap_unload(ring->data_dmat, data->map); --- 33 unchanged lines hidden (view full) --- 1168 if (ring->data_dmat != NULL) 1169 bus_dma_tag_destroy(ring->data_dmat); 1170} 1171 1172static int 1173wpi_shutdown(device_t dev) 1174{ 1175 struct wpi_softc *sc = device_get_softc(dev); |
1263 WPI_LOCK_DECL; | |
1264 1265 WPI_LOCK(sc); 1266 wpi_stop_locked(sc); 1267 wpi_unload_firmware(sc); 1268 WPI_UNLOCK(sc); 1269 1270 return 0; 1271} --- 52 unchanged lines hidden (view full) --- 1324/** 1325 * Called by net80211 when ever there is a change to 80211 state machine 1326 */ 1327static int 1328wpi_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) 1329{ 1330 struct ifnet *ifp = ic->ic_ifp; 1331 struct wpi_softc *sc = ifp->if_softc; | 1176 1177 WPI_LOCK(sc); 1178 wpi_stop_locked(sc); 1179 wpi_unload_firmware(sc); 1180 WPI_UNLOCK(sc); 1181 1182 return 0; 1183} --- 52 unchanged lines hidden (view full) --- 1236/** 1237 * Called by net80211 when ever there is a change to 80211 state machine 1238 */ 1239static int 1240wpi_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) 1241{ 1242 struct ifnet *ifp = ic->ic_ifp; 1243 struct wpi_softc *sc = ifp->if_softc; |
1332 struct ieee80211_node *ni; 1333 int error; 1334 WPI_LOCK_DECL; | |
1335 | 1244 |
1336 WPI_LOCK(sc); 1337 callout_stop(&sc->calib_to); 1338 WPI_UNLOCK(sc); | 1245 DPRINTF(("%s: %s -> %s\n", __func__, 1246 ieee80211_state_name[ic->ic_state], 1247 ieee80211_state_name[nstate])); |
1339 1340 switch (nstate) { 1341 case IEEE80211_S_SCAN: | 1248 1249 switch (nstate) { 1250 case IEEE80211_S_SCAN: |
1342 DPRINTF(("NEWSTATE:SCAN\n")); 1343 /* Scanning is handled in net80211 via the scan_start, | 1251 /* 1252 * Scanning is handled in net80211 via the scan_start, |
1344 * scan_end, scan_curchan functions. Hence all we do when 1345 * changing to the SCAN state is update the leds 1346 */ 1347 1348 /* make the link LED blink while we're scanning */ 1349 wpi_set_led(sc, WPI_LED_LINK, 20, 2); 1350 break; 1351 | 1253 * scan_end, scan_curchan functions. Hence all we do when 1254 * changing to the SCAN state is update the leds 1255 */ 1256 1257 /* make the link LED blink while we're scanning */ 1258 wpi_set_led(sc, WPI_LED_LINK, 20, 2); 1259 break; 1260 |
1352 case IEEE80211_S_ASSOC: 1353 DPRINTF(("NEWSTATE:ASSOC\n")); 1354 if (ic->ic_state != IEEE80211_S_RUN) 1355 break; 1356 /* FALLTHROUGH */ 1357 | |
1358 case IEEE80211_S_AUTH: | 1261 case IEEE80211_S_AUTH: |
1359 DPRINTF(("NEWSTATE:AUTH\n")); 1360 sc->flags |= WPI_FLAG_AUTH; 1361 sc->config.associd = 0; 1362 sc->config.filter &= ~htole32(WPI_FILTER_BSS); 1363 wpi_queue_cmd(sc,WPI_AUTH); 1364 DPRINTF(("END AUTH\n")); 1365 break; | 1262 /* Delay the auth transition until we can update the firmware */ 1263 return wpi_queue_cmd(sc, WPI_AUTH, arg, WPI_QUEUE_NORMAL); |
1366 1367 case IEEE80211_S_RUN: | 1264 1265 case IEEE80211_S_RUN: |
1368 DPRINTF(("NEWSTATE:RUN\n")); | |
1369 if (ic->ic_opmode == IEEE80211_M_MONITOR) { 1370 /* link LED blinks while monitoring */ 1371 wpi_set_led(sc, WPI_LED_LINK, 5, 5); 1372 break; 1373 } | 1266 if (ic->ic_opmode == IEEE80211_M_MONITOR) { 1267 /* link LED blinks while monitoring */ 1268 wpi_set_led(sc, WPI_LED_LINK, 5, 5); 1269 break; 1270 } |
1374 1375#if 0 1376 if (ic->ic_opmode != IEEE80211_M_STA) { 1377 (void) wpi_auth(sc); /* XXX */ 1378 wpi_setup_beacon(sc, ic->ic_bss); 1379 } 1380#endif 1381 1382 ni = ic->ic_bss; 1383 wpi_enable_tsf(sc, ni); 1384 1385 /* update adapter's configuration */ 1386 sc->config.associd = htole16(ni->ni_associd & ~0xc000); 1387 /* short preamble/slot time are negotiated when associating */ 1388 sc->config.flags &= ~htole32(WPI_CONFIG_SHPREAMBLE | 1389 WPI_CONFIG_SHSLOT); 1390 if (ic->ic_flags & IEEE80211_F_SHSLOT) 1391 sc->config.flags |= htole32(WPI_CONFIG_SHSLOT); 1392 if (ic->ic_flags & IEEE80211_F_SHPREAMBLE) 1393 sc->config.flags |= htole32(WPI_CONFIG_SHPREAMBLE); 1394 sc->config.filter |= htole32(WPI_FILTER_BSS); 1395#if 0 1396 if (ic->ic_opmode != IEEE80211_M_STA) 1397 sc->config.filter |= htole32(WPI_FILTER_BEACON); 1398#endif 1399 1400/* XXX put somewhere HC_QOS_SUPPORT_ASSOC + HC_IBSS_START */ 1401 1402 DPRINTF(("config chan %d flags %x\n", sc->config.chan, 1403 sc->config.flags)); 1404 error = wpi_cmd(sc, WPI_CMD_CONFIGURE, &sc->config, 1405 sizeof (struct wpi_config), 1); 1406 if (error != 0) { 1407 device_printf(sc->sc_dev, 1408 "could not update configuration\n"); 1409 return error; 1410 } 1411 1412 if ((error = wpi_set_txpower(sc, ic->ic_bss->ni_chan, 1)) != 0) { 1413 device_printf(sc->sc_dev, 1414 "could set txpower\n"); 1415 return error; 1416 } 1417 1418 if (ic->ic_opmode == IEEE80211_M_STA) { 1419 /* fake a join to init the tx rate */ 1420 wpi_newassoc(ic->ic_bss, 1); 1421 } 1422 1423 /* start automatic rate control timer */ 1424 callout_reset(&sc->calib_to, hz/2, wpi_calib_timeout, sc); 1425 1426 /* link LED always on while associated */ 1427 wpi_set_led(sc, WPI_LED_LINK, 0, 1); | 1271 if (ic->ic_state != IEEE80211_S_RUN) 1272 /* set the association id first */ 1273 return wpi_queue_cmd(sc, WPI_RUN, arg, 1274 WPI_QUEUE_NORMAL); |
1428 break; 1429 | 1275 break; 1276 |
1430 case IEEE80211_S_INIT: 1431 DPRINTF(("NEWSTATE:INIT\n")); 1432 break; 1433 | |
1434 default: 1435 break; 1436 } 1437 | 1277 default: 1278 break; 1279 } 1280 |
1438 return (*sc->sc_newstate)(ic, nstate, arg); | 1281 return sc->sc_newstate(ic, nstate, arg); |
1439} 1440 1441/* 1442 * Grab exclusive access to NIC memory. 1443 */ 1444static void 1445wpi_mem_lock(struct wpi_softc *sc) 1446{ --- 142 unchanged lines hidden (view full) --- 1589 struct wpi_rx_data *data) 1590{ 1591 struct ieee80211com *ic = &sc->sc_ic; 1592 struct ifnet *ifp = ic->ic_ifp; 1593 struct wpi_rx_ring *ring = &sc->rxq; 1594 struct wpi_rx_stat *stat; 1595 struct wpi_rx_head *head; 1596 struct wpi_rx_tail *tail; | 1282} 1283 1284/* 1285 * Grab exclusive access to NIC memory. 1286 */ 1287static void 1288wpi_mem_lock(struct wpi_softc *sc) 1289{ --- 142 unchanged lines hidden (view full) --- 1432 struct wpi_rx_data *data) 1433{ 1434 struct ieee80211com *ic = &sc->sc_ic; 1435 struct ifnet *ifp = ic->ic_ifp; 1436 struct wpi_rx_ring *ring = &sc->rxq; 1437 struct wpi_rx_stat *stat; 1438 struct wpi_rx_head *head; 1439 struct wpi_rx_tail *tail; |
1597 struct wpi_rbuf *rbuf; 1598 struct ieee80211_frame *wh; | |
1599 struct ieee80211_node *ni; 1600 struct mbuf *m, *mnew; | 1440 struct ieee80211_node *ni; 1441 struct mbuf *m, *mnew; |
1601 WPI_LOCK_DECL; | 1442 bus_addr_t paddr; 1443 int error; |
1602 1603 stat = (struct wpi_rx_stat *)(desc + 1); 1604 1605 if (stat->len > WPI_STAT_MAXLEN) { 1606 device_printf(sc->sc_dev, "invalid rx statistic header\n"); 1607 ifp->if_ierrors++; 1608 return; 1609 } 1610 1611 head = (struct wpi_rx_head *)((caddr_t)(stat + 1) + stat->len); 1612 tail = (struct wpi_rx_tail *)((caddr_t)(head + 1) + le16toh(head->len)); 1613 1614 DPRINTFN(WPI_DEBUG_RX, ("rx intr: idx=%d len=%d stat len=%d rssi=%d " 1615 "rate=%x chan=%d tstamp=%ju\n", ring->cur, le32toh(desc->len), 1616 le16toh(head->len), (int8_t)stat->rssi, head->rate, head->chan, 1617 (uintmax_t)le64toh(tail->tstamp))); 1618 | 1444 1445 stat = (struct wpi_rx_stat *)(desc + 1); 1446 1447 if (stat->len > WPI_STAT_MAXLEN) { 1448 device_printf(sc->sc_dev, "invalid rx statistic header\n"); 1449 ifp->if_ierrors++; 1450 return; 1451 } 1452 1453 head = (struct wpi_rx_head *)((caddr_t)(stat + 1) + stat->len); 1454 tail = (struct wpi_rx_tail *)((caddr_t)(head + 1) + le16toh(head->len)); 1455 1456 DPRINTFN(WPI_DEBUG_RX, ("rx intr: idx=%d len=%d stat len=%d rssi=%d " 1457 "rate=%x chan=%d tstamp=%ju\n", ring->cur, le32toh(desc->len), 1458 le16toh(head->len), (int8_t)stat->rssi, head->rate, head->chan, 1459 (uintmax_t)le64toh(tail->tstamp))); 1460 |
1619 m = data->m; | 1461 /* XXX don't need mbuf, just dma buffer */ 1462 mnew = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUMPAGESIZE); 1463 if (mnew == NULL) { 1464 DPRINTFN(WPI_DEBUG_RX, ("%s: no mbuf to restock ring\n", 1465 __func__)); 1466 ic->ic_stats.is_rx_nobuf++; 1467 ifp->if_ierrors++; 1468 return; 1469 } 1470 error = bus_dmamap_load(ring->data_dmat, data->map, 1471 mtod(mnew, caddr_t), MJUMPAGESIZE, 1472 wpi_dma_map_addr, &paddr, BUS_DMA_NOWAIT); 1473 if (error != 0 && error != EFBIG) { 1474 device_printf(sc->sc_dev, 1475 "%s: bus_dmamap_load failed, error %d\n", __func__, error); 1476 m_freem(mnew); 1477 ic->ic_stats.is_rx_nobuf++; /* XXX need stat */ 1478 ifp->if_ierrors++; 1479 return; 1480 } 1481 bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE); |
1620 | 1482 |
1621 /* finalize mbuf */ | 1483 /* finalize mbuf and swap in new one */ 1484 m = data->m; |
1622 m->m_pkthdr.rcvif = ifp; 1623 m->m_data = (caddr_t)(head + 1); 1624 m->m_pkthdr.len = m->m_len = le16toh(head->len); 1625 | 1485 m->m_pkthdr.rcvif = ifp; 1486 m->m_data = (caddr_t)(head + 1); 1487 m->m_pkthdr.len = m->m_len = le16toh(head->len); 1488 |
1626 if ((rbuf = SLIST_FIRST(&sc->rxq.freelist)) != NULL) { 1627 mnew = m_gethdr(M_DONTWAIT,MT_DATA); 1628 if (mnew == NULL) { 1629 ifp->if_ierrors++; 1630 return; 1631 } | 1489 data->m = mnew; 1490 /* update Rx descriptor */ 1491 ring->desc[ring->cur] = htole32(paddr); |
1632 | 1492 |
1633 /* attach Rx buffer to mbuf */ 1634 MEXTADD(mnew, rbuf->vaddr, WPI_RBUF_SIZE, wpi_free_rbuf, 1635 rbuf->vaddr, rbuf, 0, EXT_NET_DRV); 1636 SLIST_REMOVE_HEAD(&sc->rxq.freelist, next); 1637 data->m = mnew; 1638 1639 /* update Rx descriptor */ 1640 ring->desc[ring->cur] = htole32(rbuf->paddr); 1641 } else { 1642 /* no free rbufs, copy frame */ 1643 m = m_dup(m, M_DONTWAIT); 1644 if (m == NULL) { 1645 /* no free mbufs either, drop frame */ 1646 ifp->if_ierrors++; 1647 return; 1648 } 1649 } 1650 1651#ifndef WPI_CURRENT 1652 if (sc->sc_drvbpf != NULL) { 1653#else | |
1654 if (bpf_peers_present(sc->sc_drvbpf)) { | 1493 if (bpf_peers_present(sc->sc_drvbpf)) { |
1655#endif | |
1656 struct wpi_rx_radiotap_header *tap = &sc->sc_rxtap; 1657 1658 tap->wr_flags = 0; 1659 tap->wr_chan_freq = 1660 htole16(ic->ic_channels[head->chan].ic_freq); 1661 tap->wr_chan_flags = 1662 htole16(ic->ic_channels[head->chan].ic_flags); 1663 tap->wr_dbm_antsignal = (int8_t)(stat->rssi - WPI_RSSI_OFFSET); --- 19 unchanged lines hidden (view full) --- 1683 default: tap->wr_rate = 0; 1684 } 1685 if (le16toh(head->flags) & 0x4) 1686 tap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; 1687 1688 bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_rxtap_len, m); 1689 } 1690 | 1494 struct wpi_rx_radiotap_header *tap = &sc->sc_rxtap; 1495 1496 tap->wr_flags = 0; 1497 tap->wr_chan_freq = 1498 htole16(ic->ic_channels[head->chan].ic_freq); 1499 tap->wr_chan_flags = 1500 htole16(ic->ic_channels[head->chan].ic_flags); 1501 tap->wr_dbm_antsignal = (int8_t)(stat->rssi - WPI_RSSI_OFFSET); --- 19 unchanged lines hidden (view full) --- 1521 default: tap->wr_rate = 0; 1522 } 1523 if (le16toh(head->flags) & 0x4) 1524 tap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; 1525 1526 bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_rxtap_len, m); 1527 } 1528 |
1691 wh = mtod(m, struct ieee80211_frame *); | |
1692 WPI_UNLOCK(sc); 1693 1694 /* XXX frame length > sizeof(struct ieee80211_frame_min)? */ 1695 /* grab a reference to the source node */ | 1529 WPI_UNLOCK(sc); 1530 1531 /* XXX frame length > sizeof(struct ieee80211_frame_min)? */ 1532 /* grab a reference to the source node */ |
1696 ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh); | 1533 ni = ieee80211_find_rxnode(ic, mtod(m, struct ieee80211_frame_min *)); |
1697 1698 /* send the frame to the 802.11 layer */ 1699 ieee80211_input(ic, m, ni, stat->rssi, 0, 0); 1700 1701 /* release node reference */ 1702 ieee80211_free_node(ni); 1703 WPI_LOCK(sc); 1704} --- 36 unchanged lines hidden (view full) --- 1741 m_freem(txdata->m); 1742 txdata->m = NULL; 1743 ieee80211_free_node(txdata->ni); 1744 txdata->ni = NULL; 1745 1746 ring->queued--; 1747 1748 sc->sc_tx_timer = 0; | 1534 1535 /* send the frame to the 802.11 layer */ 1536 ieee80211_input(ic, m, ni, stat->rssi, 0, 0); 1537 1538 /* release node reference */ 1539 ieee80211_free_node(ni); 1540 WPI_LOCK(sc); 1541} --- 36 unchanged lines hidden (view full) --- 1578 m_freem(txdata->m); 1579 txdata->m = NULL; 1580 ieee80211_free_node(txdata->ni); 1581 txdata->ni = NULL; 1582 1583 ring->queued--; 1584 1585 sc->sc_tx_timer = 0; |
1749 sc->watchdog_cnt = 0; 1750 callout_stop(&sc->watchdog_to); | |
1751 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 1752 wpi_start(ifp); 1753} 1754 1755static void 1756wpi_cmd_intr(struct wpi_softc *sc, struct wpi_rx_desc *desc) 1757{ 1758 struct wpi_tx_ring *ring = &sc->cmdq; --- 19 unchanged lines hidden (view full) --- 1778 sc->flags &= ~WPI_FLAG_BUSY; 1779 wakeup(&ring->cmd[desc->idx]); 1780} 1781 1782static void 1783wpi_notif_intr(struct wpi_softc *sc) 1784{ 1785 struct ieee80211com *ic = &sc->sc_ic; | 1586 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 1587 wpi_start(ifp); 1588} 1589 1590static void 1591wpi_cmd_intr(struct wpi_softc *sc, struct wpi_rx_desc *desc) 1592{ 1593 struct wpi_tx_ring *ring = &sc->cmdq; --- 19 unchanged lines hidden (view full) --- 1613 sc->flags &= ~WPI_FLAG_BUSY; 1614 wakeup(&ring->cmd[desc->idx]); 1615} 1616 1617static void 1618wpi_notif_intr(struct wpi_softc *sc) 1619{ 1620 struct ieee80211com *ic = &sc->sc_ic; |
1621 struct ifnet *ifp = ic->ic_ifp; |
|
1786 struct wpi_rx_desc *desc; 1787 struct wpi_rx_data *data; 1788 uint32_t hw; 1789 1790 hw = le32toh(sc->shared->next); 1791 while (sc->rxq.cur != hw) { 1792 data = &sc->rxq.data[sc->rxq.cur]; 1793 desc = (void *)data->m->m_ext.ext_buf; --- 43 unchanged lines hidden (view full) --- 1837 1838 /* enabled/disabled notification */ 1839 DPRINTF(("state changed to %x\n", le32toh(*status))); 1840 1841 if (le32toh(*status) & 1) { 1842 device_printf(sc->sc_dev, 1843 "Radio transmitter is switched off\n"); 1844 sc->flags |= WPI_FLAG_HW_RADIO_OFF; | 1622 struct wpi_rx_desc *desc; 1623 struct wpi_rx_data *data; 1624 uint32_t hw; 1625 1626 hw = le32toh(sc->shared->next); 1627 while (sc->rxq.cur != hw) { 1628 data = &sc->rxq.data[sc->rxq.cur]; 1629 desc = (void *)data->m->m_ext.ext_buf; --- 43 unchanged lines hidden (view full) --- 1673 1674 /* enabled/disabled notification */ 1675 DPRINTF(("state changed to %x\n", le32toh(*status))); 1676 1677 if (le32toh(*status) & 1) { 1678 device_printf(sc->sc_dev, 1679 "Radio transmitter is switched off\n"); 1680 sc->flags |= WPI_FLAG_HW_RADIO_OFF; |
1845 break; | 1681 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; 1682 /* Disable firmware commands */ 1683 WPI_WRITE(sc, WPI_UCODE_SET, WPI_DISABLE_CMD); |
1846 } | 1684 } |
1847 sc->flags &= ~WPI_FLAG_HW_RADIO_OFF; | |
1848 break; 1849 } 1850 case WPI_START_SCAN: 1851 { 1852 struct wpi_start_scan *scan = 1853 (struct wpi_start_scan *)(desc + 1); 1854 1855 DPRINTFN(WPI_DEBUG_SCANNING, 1856 ("scanning channel %d status %x\n", 1857 scan->chan, le32toh(scan->status))); | 1685 break; 1686 } 1687 case WPI_START_SCAN: 1688 { 1689 struct wpi_start_scan *scan = 1690 (struct wpi_start_scan *)(desc + 1); 1691 1692 DPRINTFN(WPI_DEBUG_SCANNING, 1693 ("scanning channel %d status %x\n", 1694 scan->chan, le32toh(scan->status))); |
1858 1859 /* fix current channel */ 1860 ic->ic_bss->ni_chan = &ic->ic_channels[scan->chan]; | |
1861 break; 1862 } 1863 case WPI_STOP_SCAN: 1864 { 1865 struct wpi_stop_scan *scan = 1866 (struct wpi_stop_scan *)(desc + 1); 1867 1868 DPRINTFN(WPI_DEBUG_SCANNING, 1869 ("scan finished nchan=%d status=%d chan=%d\n", 1870 scan->nchan, scan->status, scan->chan)); 1871 | 1695 break; 1696 } 1697 case WPI_STOP_SCAN: 1698 { 1699 struct wpi_stop_scan *scan = 1700 (struct wpi_stop_scan *)(desc + 1); 1701 1702 DPRINTFN(WPI_DEBUG_SCANNING, 1703 ("scan finished nchan=%d status=%d chan=%d\n", 1704 scan->nchan, scan->status, scan->chan)); 1705 |
1872 wpi_queue_cmd(sc, WPI_SCAN_NEXT); | 1706 sc->sc_scan_timer = 0; 1707 ieee80211_scan_next(ic); |
1873 break; 1874 } 1875 case WPI_MISSED_BEACON: 1876 { 1877 struct wpi_missed_beacon *beacon = 1878 (struct wpi_missed_beacon *)(desc + 1); 1879 | 1708 break; 1709 } 1710 case WPI_MISSED_BEACON: 1711 { 1712 struct wpi_missed_beacon *beacon = 1713 (struct wpi_missed_beacon *)(desc + 1); 1714 |
1880 if (le32toh(beacon->consecutive) >= ic->ic_bmissthreshold) { | 1715 if (le32toh(beacon->consecutive) >= 1716 ic->ic_bmissthreshold) { |
1881 DPRINTF(("Beacon miss: %u >= %u\n", 1882 le32toh(beacon->consecutive), 1883 ic->ic_bmissthreshold)); 1884 ieee80211_beacon_miss(ic); 1885 } | 1717 DPRINTF(("Beacon miss: %u >= %u\n", 1718 le32toh(beacon->consecutive), 1719 ic->ic_bmissthreshold)); 1720 ieee80211_beacon_miss(ic); 1721 } |
1722 break; |
|
1886 } 1887 } 1888 1889 sc->rxq.cur = (sc->rxq.cur + 1) % WPI_RX_RING_COUNT; 1890 } 1891 1892 /* tell the firmware what we have processed */ 1893 hw = (hw == 0) ? WPI_RX_RING_COUNT - 1 : hw - 1; 1894 WPI_WRITE(sc, WPI_RX_WIDX, hw & ~7); | 1723 } 1724 } 1725 1726 sc->rxq.cur = (sc->rxq.cur + 1) % WPI_RX_RING_COUNT; 1727 } 1728 1729 /* tell the firmware what we have processed */ 1730 hw = (hw == 0) ? WPI_RX_RING_COUNT - 1 : hw - 1; 1731 WPI_WRITE(sc, WPI_RX_WIDX, hw & ~7); |
1895 | |
1896} 1897 1898static void 1899wpi_intr(void *arg) 1900{ 1901 struct wpi_softc *sc = arg; 1902 uint32_t r; | 1732} 1733 1734static void 1735wpi_intr(void *arg) 1736{ 1737 struct wpi_softc *sc = arg; 1738 uint32_t r; |
1903 WPI_LOCK_DECL; | |
1904 1905 WPI_LOCK(sc); 1906 1907 r = WPI_READ(sc, WPI_INTR); 1908 if (r == 0 || r == 0xffffffff) { 1909 WPI_UNLOCK(sc); 1910 return; 1911 } 1912 1913 /* disable interrupts */ 1914 WPI_WRITE(sc, WPI_MASK, 0); 1915 /* ack interrupts */ 1916 WPI_WRITE(sc, WPI_INTR, r); 1917 1918 if (r & (WPI_SW_ERROR | WPI_HW_ERROR)) { 1919 device_printf(sc->sc_dev, "fatal firmware error\n"); 1920 DPRINTFN(6,("(%s)\n", (r & WPI_SW_ERROR) ? "(Software Error)" : 1921 "(Hardware Error)")); | 1739 1740 WPI_LOCK(sc); 1741 1742 r = WPI_READ(sc, WPI_INTR); 1743 if (r == 0 || r == 0xffffffff) { 1744 WPI_UNLOCK(sc); 1745 return; 1746 } 1747 1748 /* disable interrupts */ 1749 WPI_WRITE(sc, WPI_MASK, 0); 1750 /* ack interrupts */ 1751 WPI_WRITE(sc, WPI_INTR, r); 1752 1753 if (r & (WPI_SW_ERROR | WPI_HW_ERROR)) { 1754 device_printf(sc->sc_dev, "fatal firmware error\n"); 1755 DPRINTFN(6,("(%s)\n", (r & WPI_SW_ERROR) ? "(Software Error)" : 1756 "(Hardware Error)")); |
1922 taskqueue_enqueue(sc->sc_tq2, &sc->sc_restarttask); | 1757 wpi_queue_cmd(sc, WPI_RESTART, 0, WPI_QUEUE_CLEAR); |
1923 sc->flags &= ~WPI_FLAG_BUSY; 1924 WPI_UNLOCK(sc); 1925 return; 1926 } 1927 1928 if (r & WPI_RX_INTR) 1929 wpi_notif_intr(sc); 1930 --- 41 unchanged lines hidden (view full) --- 1972 * the buffer onto the transmit ring, kicking the card to process the 1973 * the buffer. 1974 */ 1975static int 1976wpi_tx_data(struct wpi_softc *sc, struct mbuf *m0, struct ieee80211_node *ni, 1977 int ac) 1978{ 1979 struct ieee80211com *ic = &sc->sc_ic; | 1758 sc->flags &= ~WPI_FLAG_BUSY; 1759 WPI_UNLOCK(sc); 1760 return; 1761 } 1762 1763 if (r & WPI_RX_INTR) 1764 wpi_notif_intr(sc); 1765 --- 41 unchanged lines hidden (view full) --- 1807 * the buffer onto the transmit ring, kicking the card to process the 1808 * the buffer. 1809 */ 1810static int 1811wpi_tx_data(struct wpi_softc *sc, struct mbuf *m0, struct ieee80211_node *ni, 1812 int ac) 1813{ 1814 struct ieee80211com *ic = &sc->sc_ic; |
1815 const struct chanAccParams *cap = &ic->ic_wme.wme_chanParams; |
|
1980 struct wpi_tx_ring *ring = &sc->txq[ac]; 1981 struct wpi_tx_desc *desc; 1982 struct wpi_tx_data *data; 1983 struct wpi_tx_cmd *cmd; 1984 struct wpi_cmd_data *tx; 1985 struct ieee80211_frame *wh; 1986 struct ieee80211_key *k; | 1816 struct wpi_tx_ring *ring = &sc->txq[ac]; 1817 struct wpi_tx_desc *desc; 1818 struct wpi_tx_data *data; 1819 struct wpi_tx_cmd *cmd; 1820 struct wpi_cmd_data *tx; 1821 struct ieee80211_frame *wh; 1822 struct ieee80211_key *k; |
1987 const struct chanAccParams *cap; | |
1988 struct mbuf *mnew; | 1823 struct mbuf *mnew; |
1989 int i, error, nsegs, rate, hdrlen, noack = 0; | 1824 int i, error, nsegs, rate, hdrlen, ismcast; |
1990 bus_dma_segment_t segs[WPI_MAX_SCATTER]; 1991 1992 desc = &ring->desc[ring->cur]; 1993 data = &ring->data[ring->cur]; 1994 1995 wh = mtod(m0, struct ieee80211_frame *); 1996 | 1825 bus_dma_segment_t segs[WPI_MAX_SCATTER]; 1826 1827 desc = &ring->desc[ring->cur]; 1828 data = &ring->data[ring->cur]; 1829 1830 wh = mtod(m0, struct ieee80211_frame *); 1831 |
1997 if (IEEE80211_QOS_HAS_SEQ(wh)) { 1998 hdrlen = sizeof (struct ieee80211_qosframe); 1999 cap = &ic->ic_wme.wme_chanParams; 2000 noack = cap->cap_wmeParams[ac].wmep_noackPolicy; 2001 } else 2002 hdrlen = sizeof (struct ieee80211_frame); | 1832 hdrlen = ieee80211_hdrsize(wh); 1833 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); |
2003 2004 if (wh->i_fc[1] & IEEE80211_FC1_WEP) { | 1834 1835 if (wh->i_fc[1] & IEEE80211_FC1_WEP) { |
2005 if ((k = ieee80211_crypto_encap(ic, ni, m0)) == NULL) { | 1836 k = ieee80211_crypto_encap(ic, ni, m0); 1837 if (k == NULL) { |
2006 m_freem(m0); 2007 return ENOBUFS; 2008 } | 1838 m_freem(m0); 1839 return ENOBUFS; 1840 } |
2009 | |
2010 /* packet header may have moved, reset our local pointer */ 2011 wh = mtod(m0, struct ieee80211_frame *); 2012 } 2013 | 1841 /* packet header may have moved, reset our local pointer */ 1842 wh = mtod(m0, struct ieee80211_frame *); 1843 } 1844 |
2014 /* pickup a rate */ 2015 if (IEEE80211_IS_MULTICAST(wh->i_addr1)|| 2016 ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == 2017 IEEE80211_FC0_TYPE_MGT)) { 2018 /* 2019 * mgmt/multicast frames are sent at the lowest available 2020 * bit-rate 2021 */ 2022 rate = ni->ni_rates.rs_rates[0]; 2023 } else { 2024 if (ic->ic_fixed_rate != -1) { 2025 rate = ic->ic_sup_rates[ic->ic_curmode]. 2026 rs_rates[ic->ic_fixed_rate]; 2027 } else 2028 rate = ni->ni_rates.rs_rates[ni->ni_txrate]; 2029 } 2030 rate &= IEEE80211_RATE_VAL; 2031 2032#ifndef WPI_CURRENT 2033 if (sc->sc_drvbpf != NULL) { 2034#else 2035 if (bpf_peers_present(sc->sc_drvbpf)) { 2036#endif 2037 2038 struct wpi_tx_radiotap_header *tap = &sc->sc_txtap; 2039 2040 tap->wt_flags = 0; 2041 tap->wt_chan_freq = htole16(ni->ni_chan->ic_freq); 2042 tap->wt_chan_flags = htole16(ni->ni_chan->ic_flags); 2043 tap->wt_rate = rate; 2044 tap->wt_hwqueue = ac; 2045 if (wh->i_fc[1] & IEEE80211_FC1_WEP) 2046 tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP; 2047 2048 bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m0); 2049 } 2050 | |
2051 cmd = &ring->cmd[ring->cur]; 2052 cmd->code = WPI_CMD_TX_DATA; 2053 cmd->flags = 0; 2054 cmd->qid = ring->qid; 2055 cmd->idx = ring->cur; 2056 2057 tx = (struct wpi_cmd_data *)cmd->data; | 1845 cmd = &ring->cmd[ring->cur]; 1846 cmd->code = WPI_CMD_TX_DATA; 1847 cmd->flags = 0; 1848 cmd->qid = ring->qid; 1849 cmd->idx = ring->cur; 1850 1851 tx = (struct wpi_cmd_data *)cmd->data; |
2058 tx->flags = 0; | 1852 tx->flags = htole32(WPI_TX_AUTO_SEQ); 1853 tx->timeout= htole16(0); 1854 tx->ofdm_mask = 0xff; 1855 tx->cck_mask = 0x0f; 1856 tx->lifetime = htole32(WPI_LIFETIME_INFINITE); 1857 tx->id = ismcast ? WPI_ID_BROADCAST : WPI_ID_BSS; 1858 tx->len = htole16(m0->m_pkthdr.len); |
2059 | 1859 |
2060 if (!noack && !IEEE80211_IS_MULTICAST(wh->i_addr1)) { 2061 tx->flags |= htole32(WPI_TX_NEED_ACK); 2062 } else if (m0->m_pkthdr.len + IEEE80211_CRC_LEN > ic->ic_rtsthreshold) { 2063 tx->flags |= htole32(WPI_TX_NEED_RTS | WPI_TX_FULL_TXOP); | 1860 if (ismcast) { 1861 if ((ni->ni_flags & IEEE80211_NODE_QOS) == 0 || 1862 !cap->cap_wmeParams[ac].wmep_noackPolicy) 1863 tx->flags |= htole32(WPI_TX_NEED_ACK); 1864 if (m0->m_pkthdr.len + IEEE80211_CRC_LEN > ic->ic_rtsthreshold) { 1865 tx->flags |= htole32(WPI_TX_NEED_RTS|WPI_TX_FULL_TXOP); 1866 tx->rts_ntries = 7; 1867 } |
2064 } 2065 | 1868 } 1869 |
2066 tx->flags |= htole32(WPI_TX_AUTO_SEQ); 2067 2068 tx->id = IEEE80211_IS_MULTICAST(wh->i_addr1) ? WPI_ID_BROADCAST : 2069 WPI_ID_BSS; 2070 2071 if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == 2072 IEEE80211_FC0_TYPE_MGT) { | 1870 /* pick a rate */ 1871 if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_MASK) { |
2073 uint8_t subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; 2074 /* tell h/w to set timestamp in probe responses */ 2075 if (subtype == IEEE80211_FC0_SUBTYPE_PROBE_RESP) | 1872 uint8_t subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; 1873 /* tell h/w to set timestamp in probe responses */ 1874 if (subtype == IEEE80211_FC0_SUBTYPE_PROBE_RESP) |
2076 tx->flags |= htole32(WPI_TX_INSERT_TSTAMP); | 1875 tx->flags |= htole32(WPI_TX_INSERT_TSTAMP); |
2077 2078 if (subtype == IEEE80211_FC0_SUBTYPE_ASSOC_REQ || | 1876 1877 if (subtype == IEEE80211_FC0_SUBTYPE_ASSOC_REQ || |
2079 subtype == IEEE80211_FC0_SUBTYPE_REASSOC_REQ) | 1878 subtype == IEEE80211_FC0_SUBTYPE_REASSOC_REQ) |
2080 tx->timeout = htole16(3); 2081 else 2082 tx->timeout = htole16(2); | 1879 tx->timeout = htole16(3); 1880 else 1881 tx->timeout = htole16(2); |
2083 } else 2084 tx->timeout = htole16(0); | |
2085 | 1882 |
1883 rate = ni->ni_rates.rs_rates[0] & IEEE80211_RATE_VAL; 1884 } else if (ismcast) { 1885 rate = ic->ic_mcast_rate; 1886 } else if (ic->ic_fixed_rate != IEEE80211_FIXED_RATE_NONE) { 1887 rate = ic->ic_fixed_rate; 1888 } else { 1889 rate = ni->ni_rates.rs_rates[ni->ni_txrate]; 1890 rate &= IEEE80211_RATE_VAL; 1891 } |
|
2086 tx->rate = wpi_plcp_signal(rate); 2087 2088 /* be very persistant at sending frames out */ | 1892 tx->rate = wpi_plcp_signal(rate); 1893 1894 /* be very persistant at sending frames out */ |
2089 tx->rts_ntries = 7; 2090 tx->data_ntries = 15; | 1895 tx->data_ntries = 15; /* XXX Way too high */ |
2091 | 1896 |
2092 tx->ofdm_mask = 0xff; 2093 tx->cck_mask = 0x0f; 2094 tx->lifetime = htole32(WPI_LIFETIME_INFINITE); | 1897 if (bpf_peers_present(sc->sc_drvbpf)) { 1898 struct wpi_tx_radiotap_header *tap = &sc->sc_txtap; 1899 tap->wt_flags = 0; 1900 tap->wt_chan_freq = htole16(ni->ni_chan->ic_freq); 1901 tap->wt_chan_flags = htole16(ni->ni_chan->ic_flags); 1902 tap->wt_rate = rate; 1903 tap->wt_hwqueue = ac; 1904 if (wh->i_fc[1] & IEEE80211_FC1_WEP) 1905 tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP; 1906 bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m0); 1907 } |
2095 | 1908 |
2096 tx->len = htole16(m0->m_pkthdr.len); 2097 | |
2098 /* save and trim IEEE802.11 header */ 2099 m_copydata(m0, 0, hdrlen, (caddr_t)&tx->wh); 2100 m_adj(m0, hdrlen); 2101 2102 error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, m0, segs, 2103 &nsegs, BUS_DMA_NOWAIT); 2104 if (error != 0 && error != EFBIG) { 2105 device_printf(sc->sc_dev, "could not map mbuf (error %d)\n", --- 58 unchanged lines hidden (view full) --- 2164static void 2165wpi_start(struct ifnet *ifp) 2166{ 2167 struct wpi_softc *sc = ifp->if_softc; 2168 struct ieee80211com *ic = &sc->sc_ic; 2169 struct ieee80211_node *ni; 2170 struct ether_header *eh; 2171 struct mbuf *m0; | 1909 /* save and trim IEEE802.11 header */ 1910 m_copydata(m0, 0, hdrlen, (caddr_t)&tx->wh); 1911 m_adj(m0, hdrlen); 1912 1913 error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, m0, segs, 1914 &nsegs, BUS_DMA_NOWAIT); 1915 if (error != 0 && error != EFBIG) { 1916 device_printf(sc->sc_dev, "could not map mbuf (error %d)\n", --- 58 unchanged lines hidden (view full) --- 1975static void 1976wpi_start(struct ifnet *ifp) 1977{ 1978 struct wpi_softc *sc = ifp->if_softc; 1979 struct ieee80211com *ic = &sc->sc_ic; 1980 struct ieee80211_node *ni; 1981 struct ether_header *eh; 1982 struct mbuf *m0; |
2172 int ac; 2173 WPI_LOCK_DECL; | 1983 int ac, waslocked; |
2174 | 1984 |
2175 WPI_LOCK(sc); | 1985 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) 1986 return; |
2176 | 1987 |
1988 waslocked = WPI_LOCK_OWNED(sc); 1989 if (!waslocked) 1990 WPI_LOCK(sc); 1991 |
|
2177 for (;;) { | 1992 for (;;) { |
2178 IF_POLL(&ic->ic_mgtq, m0); | 1993 IF_DEQUEUE(&ic->ic_mgtq, m0); |
2179 if (m0 != NULL) { | 1994 if (m0 != NULL) { |
2180 IF_DEQUEUE(&ic->ic_mgtq, m0); 2181 | |
2182 ni = (struct ieee80211_node *)m0->m_pkthdr.rcvif; 2183 m0->m_pkthdr.rcvif = NULL; 2184 2185 /* management frames go into ring 0 */ 2186 if (sc->txq[0].queued > sc->txq[0].count - 8) { 2187 ifp->if_oerrors++; 2188 continue; 2189 } 2190 2191 if (wpi_tx_data(sc, m0, ni, 0) != 0) { 2192 ifp->if_oerrors++; 2193 break; 2194 } 2195 } else { 2196 if (ic->ic_state != IEEE80211_S_RUN) 2197 break; 2198 | 1995 ni = (struct ieee80211_node *)m0->m_pkthdr.rcvif; 1996 m0->m_pkthdr.rcvif = NULL; 1997 1998 /* management frames go into ring 0 */ 1999 if (sc->txq[0].queued > sc->txq[0].count - 8) { 2000 ifp->if_oerrors++; 2001 continue; 2002 } 2003 2004 if (wpi_tx_data(sc, m0, ni, 0) != 0) { 2005 ifp->if_oerrors++; 2006 break; 2007 } 2008 } else { 2009 if (ic->ic_state != IEEE80211_S_RUN) 2010 break; 2011 |
2199 IFQ_POLL(&ifp->if_snd, m0); | 2012 IFQ_DRV_DEQUEUE(&ifp->if_snd, m0); |
2200 if (m0 == NULL) 2201 break; 2202 2203 /* 2204 * Cancel any background scan. 2205 */ 2206 if (ic->ic_flags & IEEE80211_F_SCAN) 2207 ieee80211_cancel_scan(ic); --- 14 unchanged lines hidden (view full) --- 2222 /* classify mbuf so we can find which tx ring to use */ 2223 if (ieee80211_classify(ic, m0, ni) != 0) { 2224 m_freem(m0); 2225 ieee80211_free_node(ni); 2226 ifp->if_oerrors++; 2227 continue; 2228 } 2229 | 2013 if (m0 == NULL) 2014 break; 2015 2016 /* 2017 * Cancel any background scan. 2018 */ 2019 if (ic->ic_flags & IEEE80211_F_SCAN) 2020 ieee80211_cancel_scan(ic); --- 14 unchanged lines hidden (view full) --- 2035 /* classify mbuf so we can find which tx ring to use */ 2036 if (ieee80211_classify(ic, m0, ni) != 0) { 2037 m_freem(m0); 2038 ieee80211_free_node(ni); 2039 ifp->if_oerrors++; 2040 continue; 2041 } 2042 |
2230 /* no QoS encapsulation for EAPOL frames */ 2231 ac = (eh->ether_type != htons(ETHERTYPE_PAE)) ? 2232 M_WME_GETAC(m0) : WME_AC_BE; 2233 | 2043 ac = M_WME_GETAC(m0); |
2234 if (sc->txq[ac].queued > sc->txq[ac].count - 8) { 2235 /* there is no place left in this ring */ 2236 IFQ_DRV_PREPEND(&ifp->if_snd, m0); 2237 ifp->if_drv_flags |= IFF_DRV_OACTIVE; 2238 break; 2239 } 2240 | 2044 if (sc->txq[ac].queued > sc->txq[ac].count - 8) { 2045 /* there is no place left in this ring */ 2046 IFQ_DRV_PREPEND(&ifp->if_snd, m0); 2047 ifp->if_drv_flags |= IFF_DRV_OACTIVE; 2048 break; 2049 } 2050 |
2241 IFQ_DRV_DEQUEUE(&ifp->if_snd, m0); | |
2242 BPF_MTAP(ifp, m0); 2243 2244 m0 = ieee80211_encap(ic, m0, ni); 2245 if (m0 == NULL) { 2246 ieee80211_free_node(ni); 2247 ifp->if_oerrors++; 2248 continue; 2249 } 2250 | 2051 BPF_MTAP(ifp, m0); 2052 2053 m0 = ieee80211_encap(ic, m0, ni); 2054 if (m0 == NULL) { 2055 ieee80211_free_node(ni); 2056 ifp->if_oerrors++; 2057 continue; 2058 } 2059 |
2251#ifndef WPI_CURRENT 2252 if (ic->ic_rawbpf != NULL) 2253#else | |
2254 if (bpf_peers_present(ic->ic_rawbpf)) | 2060 if (bpf_peers_present(ic->ic_rawbpf)) |
2255#endif | |
2256 bpf_mtap(ic->ic_rawbpf, m0); 2257 2258 if (wpi_tx_data(sc, m0, ni, ac) != 0) { 2259 ieee80211_free_node(ni); 2260 ifp->if_oerrors++; 2261 break; 2262 } 2263 } 2264 2265 sc->sc_tx_timer = 5; | 2061 bpf_mtap(ic->ic_rawbpf, m0); 2062 2063 if (wpi_tx_data(sc, m0, ni, ac) != 0) { 2064 ieee80211_free_node(ni); 2065 ifp->if_oerrors++; 2066 break; 2067 } 2068 } 2069 2070 sc->sc_tx_timer = 5; |
2266 sc->watchdog_cnt = 5; | |
2267 ic->ic_lastdata = ticks; 2268 } 2269 | 2071 ic->ic_lastdata = ticks; 2072 } 2073 |
2270 WPI_UNLOCK(sc); | 2074 if (!waslocked) 2075 WPI_UNLOCK(sc); |
2271} 2272 | 2076} 2077 |
2273static void 2274wpi_watchdog(struct ifnet *ifp) 2275{ 2276 struct wpi_softc *sc = ifp->if_softc; 2277 WPI_LOCK_DECL; 2278 2279 WPI_LOCK(sc); 2280 2281 DPRINTFN(WPI_DEBUG_WATCHDOG, ("watchdog_cnt: %d\n", sc->watchdog_cnt)); 2282 2283 if (sc->watchdog_cnt == 0 || --sc->watchdog_cnt) 2284 goto done; 2285 2286 if (--sc->sc_tx_timer != 0) { 2287 device_printf(sc->sc_dev,"device timeout\n"); 2288 ifp->if_oerrors++; 2289 taskqueue_enqueue(sc->sc_tq2, &sc->sc_restarttask); 2290 } 2291done: 2292 WPI_UNLOCK(sc); 2293} 2294 | |
2295static int 2296wpi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 2297{ 2298 struct wpi_softc *sc = ifp->if_softc; 2299 struct ieee80211com *ic = &sc->sc_ic; 2300 int error = 0; | 2078static int 2079wpi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 2080{ 2081 struct wpi_softc *sc = ifp->if_softc; 2082 struct ieee80211com *ic = &sc->sc_ic; 2083 int error = 0; |
2301 WPI_LOCK_DECL; | |
2302 2303 WPI_LOCK(sc); 2304 2305 switch (cmd) { 2306 case SIOCSIFFLAGS: 2307 if ((ifp->if_flags & IFF_UP)) { 2308 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) | 2084 2085 WPI_LOCK(sc); 2086 2087 switch (cmd) { 2088 case SIOCSIFFLAGS: 2089 if ((ifp->if_flags & IFF_UP)) { 2090 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) |
2309 wpi_init(sc); 2310 } else if (ifp->if_drv_flags & IFF_DRV_RUNNING) | 2091 wpi_init_locked(sc, 0); 2092 } else if ((ifp->if_drv_flags & IFF_DRV_RUNNING) || 2093 (sc->flags & WPI_FLAG_HW_RADIO_OFF)) |
2311 wpi_stop_locked(sc); 2312 break; 2313 default: 2314 WPI_UNLOCK(sc); 2315 error = ieee80211_ioctl(ic, cmd, data); 2316 WPI_LOCK(sc); 2317 } 2318 2319 if (error == ENETRESET) { 2320 if ((ifp->if_flags & IFF_UP) && 2321 (ifp->if_drv_flags & IFF_DRV_RUNNING) && 2322 ic->ic_roaming != IEEE80211_ROAMING_MANUAL) | 2094 wpi_stop_locked(sc); 2095 break; 2096 default: 2097 WPI_UNLOCK(sc); 2098 error = ieee80211_ioctl(ic, cmd, data); 2099 WPI_LOCK(sc); 2100 } 2101 2102 if (error == ENETRESET) { 2103 if ((ifp->if_flags & IFF_UP) && 2104 (ifp->if_drv_flags & IFF_DRV_RUNNING) && 2105 ic->ic_roaming != IEEE80211_ROAMING_MANUAL) |
2323 wpi_init(sc); | 2106 wpi_init_locked(sc, 0); |
2324 error = 0; 2325 } 2326 2327 WPI_UNLOCK(sc); 2328 2329 return error; 2330} 2331 --- 282 unchanged lines hidden (view full) --- 2614static int 2615wpi_auth(struct wpi_softc *sc) 2616{ 2617 struct ieee80211com *ic = &sc->sc_ic; 2618 struct ieee80211_node *ni = ic->ic_bss; 2619 struct wpi_node_info node; 2620 int error; 2621 | 2107 error = 0; 2108 } 2109 2110 WPI_UNLOCK(sc); 2111 2112 return error; 2113} 2114 --- 282 unchanged lines hidden (view full) --- 2397static int 2398wpi_auth(struct wpi_softc *sc) 2399{ 2400 struct ieee80211com *ic = &sc->sc_ic; 2401 struct ieee80211_node *ni = ic->ic_bss; 2402 struct wpi_node_info node; 2403 int error; 2404 |
2405 |
|
2622 /* update adapter's configuration */ | 2406 /* update adapter's configuration */ |
2407 sc->config.associd = 0; 2408 sc->config.filter &= ~htole32(WPI_FILTER_BSS); |
|
2623 IEEE80211_ADDR_COPY(sc->config.bssid, ni->ni_bssid); 2624 sc->config.chan = ieee80211_chan2ieee(ic, ni->ni_chan); 2625 if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan)) { 2626 sc->config.flags |= htole32(WPI_CONFIG_AUTO | 2627 WPI_CONFIG_24GHZ); 2628 } 2629 switch (ic->ic_curmode) { 2630 case IEEE80211_MODE_11A: --- 28 unchanged lines hidden (view full) --- 2659 memset(&node, 0, sizeof node); 2660 IEEE80211_ADDR_COPY(node.bssid, ni->ni_bssid); 2661 node.id = WPI_ID_BSS; 2662 node.rate = (ic->ic_curmode == IEEE80211_MODE_11A) ? 2663 wpi_plcp_signal(12) : wpi_plcp_signal(2); 2664 node.action = htole32(WPI_ACTION_SET_RATE); 2665 node.antenna = WPI_ANTENNA_BOTH; 2666 error = wpi_cmd(sc, WPI_CMD_ADD_NODE, &node, sizeof node, 1); | 2409 IEEE80211_ADDR_COPY(sc->config.bssid, ni->ni_bssid); 2410 sc->config.chan = ieee80211_chan2ieee(ic, ni->ni_chan); 2411 if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan)) { 2412 sc->config.flags |= htole32(WPI_CONFIG_AUTO | 2413 WPI_CONFIG_24GHZ); 2414 } 2415 switch (ic->ic_curmode) { 2416 case IEEE80211_MODE_11A: --- 28 unchanged lines hidden (view full) --- 2445 memset(&node, 0, sizeof node); 2446 IEEE80211_ADDR_COPY(node.bssid, ni->ni_bssid); 2447 node.id = WPI_ID_BSS; 2448 node.rate = (ic->ic_curmode == IEEE80211_MODE_11A) ? 2449 wpi_plcp_signal(12) : wpi_plcp_signal(2); 2450 node.action = htole32(WPI_ACTION_SET_RATE); 2451 node.antenna = WPI_ANTENNA_BOTH; 2452 error = wpi_cmd(sc, WPI_CMD_ADD_NODE, &node, sizeof node, 1); |
2667 if (error != 0) { | 2453 if (error != 0) |
2668 device_printf(sc->sc_dev, "could not add BSS node\n"); | 2454 device_printf(sc->sc_dev, "could not add BSS node\n"); |
2455 2456 return (error); 2457} 2458 2459static int 2460wpi_run(struct wpi_softc *sc) 2461{ 2462 struct ieee80211com *ic = &sc->sc_ic; 2463 struct ieee80211_node *ni = ic->ic_bss; 2464 int error; 2465 2466 ni = ic->ic_bss; 2467 wpi_enable_tsf(sc, ni); 2468 2469 /* update adapter's configuration */ 2470 sc->config.associd = htole16(ni->ni_associd & ~0xc000); 2471 /* short preamble/slot time are negotiated when associating */ 2472 sc->config.flags &= ~htole32(WPI_CONFIG_SHPREAMBLE | 2473 WPI_CONFIG_SHSLOT); 2474 if (ic->ic_flags & IEEE80211_F_SHSLOT) 2475 sc->config.flags |= htole32(WPI_CONFIG_SHSLOT); 2476 if (ic->ic_flags & IEEE80211_F_SHPREAMBLE) 2477 sc->config.flags |= htole32(WPI_CONFIG_SHPREAMBLE); 2478 sc->config.filter |= htole32(WPI_FILTER_BSS); 2479 2480 /* XXX put somewhere HC_QOS_SUPPORT_ASSOC + HC_IBSS_START */ 2481 2482 DPRINTF(("config chan %d flags %x\n", sc->config.chan, 2483 sc->config.flags)); 2484 error = wpi_cmd(sc, WPI_CMD_CONFIGURE, &sc->config, sizeof (struct 2485 wpi_config), 1); 2486 if (error != 0) { 2487 device_printf(sc->sc_dev, "could not update configuration\n"); |
|
2669 return error; 2670 } 2671 | 2488 return error; 2489 } 2490 |
2672 sc->flags &= ~WPI_FLAG_AUTH; | 2491 error = wpi_set_txpower(sc, ic->ic_bsschan, 1); 2492 if (error != 0) { 2493 device_printf(sc->sc_dev, "could set txpower\n"); 2494 return error; 2495 } |
2673 | 2496 |
2674 return 0; | 2497 if (ic->ic_opmode == IEEE80211_M_STA) { 2498 /* fake a join to init the tx rate */ 2499 wpi_newassoc(ic->ic_bss, 1); 2500 } 2501 2502 /* link LED always on while associated */ 2503 wpi_set_led(sc, WPI_LED_LINK, 0, 1); 2504 2505 /* start automatic rate control timer */ 2506 callout_reset(&sc->calib_to, hz/2, wpi_calib_timeout, sc); 2507 2508 return (error); |
2675} 2676 2677/* 2678 * Send a scan request to the firmware. Since this command is huge, we map it 2679 * into a mbufcluster instead of using the pre-allocated set of commands. Note, 2680 * much of this code is similar to that in wpi_cmd but because we must manually 2681 * construct the probe & channels, we duplicate what's needed here. XXX In the 2682 * future, this function should be modified to use wpi_cmd to help cleanup the 2683 * code base. 2684 */ 2685static int 2686wpi_scan(struct wpi_softc *sc) 2687{ 2688 struct ieee80211com *ic = &sc->sc_ic; | 2509} 2510 2511/* 2512 * Send a scan request to the firmware. Since this command is huge, we map it 2513 * into a mbufcluster instead of using the pre-allocated set of commands. Note, 2514 * much of this code is similar to that in wpi_cmd but because we must manually 2515 * construct the probe & channels, we duplicate what's needed here. XXX In the 2516 * future, this function should be modified to use wpi_cmd to help cleanup the 2517 * code base. 2518 */ 2519static int 2520wpi_scan(struct wpi_softc *sc) 2521{ 2522 struct ieee80211com *ic = &sc->sc_ic; |
2523 struct ieee80211_scan_state *ss = ic->ic_scan; |
|
2689 struct wpi_tx_ring *ring = &sc->cmdq; 2690 struct wpi_tx_desc *desc; 2691 struct wpi_tx_data *data; 2692 struct wpi_tx_cmd *cmd; 2693 struct wpi_scan_hdr *hdr; 2694 struct wpi_scan_chan *chan; 2695 struct ieee80211_frame *wh; 2696 struct ieee80211_rateset *rs; 2697 struct ieee80211_channel *c; 2698 enum ieee80211_phymode mode; 2699 uint8_t *frm; | 2524 struct wpi_tx_ring *ring = &sc->cmdq; 2525 struct wpi_tx_desc *desc; 2526 struct wpi_tx_data *data; 2527 struct wpi_tx_cmd *cmd; 2528 struct wpi_scan_hdr *hdr; 2529 struct wpi_scan_chan *chan; 2530 struct ieee80211_frame *wh; 2531 struct ieee80211_rateset *rs; 2532 struct ieee80211_channel *c; 2533 enum ieee80211_phymode mode; 2534 uint8_t *frm; |
2700 int nrates, pktlen, error; | 2535 int nrates, pktlen, error, i, nssid; |
2701 bus_addr_t physaddr; 2702 struct ifnet *ifp = ic->ic_ifp; 2703 2704 desc = &ring->desc[ring->cur]; 2705 data = &ring->data[ring->cur]; 2706 2707 data->m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); 2708 if (data->m == NULL) { --- 30 unchanged lines hidden (view full) --- 2739 /* send probe requests at 1Mbps */ 2740 hdr->tx.rate = wpi_ridx_to_plcp[WPI_CCK1]; 2741 } 2742 hdr->tx.id = WPI_ID_BROADCAST; 2743 hdr->tx.lifetime = htole32(WPI_LIFETIME_INFINITE); 2744 hdr->tx.flags = htole32(WPI_TX_AUTO_SEQ); 2745 2746 /*XXX Need to cater for multiple essids */ | 2536 bus_addr_t physaddr; 2537 struct ifnet *ifp = ic->ic_ifp; 2538 2539 desc = &ring->desc[ring->cur]; 2540 data = &ring->data[ring->cur]; 2541 2542 data->m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); 2543 if (data->m == NULL) { --- 30 unchanged lines hidden (view full) --- 2574 /* send probe requests at 1Mbps */ 2575 hdr->tx.rate = wpi_ridx_to_plcp[WPI_CCK1]; 2576 } 2577 hdr->tx.id = WPI_ID_BROADCAST; 2578 hdr->tx.lifetime = htole32(WPI_LIFETIME_INFINITE); 2579 hdr->tx.flags = htole32(WPI_TX_AUTO_SEQ); 2580 2581 /*XXX Need to cater for multiple essids */ |
2747 memset(&hdr->scan_essids[0], 0, 4 * sizeof(hdr->scan_essids[0])); 2748 hdr->scan_essids[0].id = IEEE80211_ELEMID_SSID; 2749 hdr->scan_essids[0].esslen = ic->ic_des_ssid[0].len; 2750 memcpy(hdr->scan_essids[0].essid, ic->ic_des_ssid[0].ssid, 2751 ic->ic_des_ssid[0].len); 2752 2753 if (wpi_debug & WPI_DEBUG_SCANNING) { 2754 printf("Scanning Essid: "); 2755 ieee80211_print_essid(ic->ic_des_ssid[0].ssid, 2756 ic->ic_des_ssid[0].len); 2757 printf("\n"); | 2582 memset(&hdr->scan_essids, 0, sizeof(hdr->scan_essids)); 2583 nssid = MIN(ss->ss_nssid, WPI_SCAN_MAX_ESSIDS); 2584 for (i = 0; i < nssid; i++ ){ 2585 hdr->scan_essids[i].id = IEEE80211_ELEMID_SSID; 2586 hdr->scan_essids[i].esslen = MIN(ss->ss_ssid[i].len, 32); 2587 memcpy(hdr->scan_essids[i].essid, ss->ss_ssid[i].ssid, 2588 hdr->scan_essids[i].esslen); 2589#ifdef WPI_DEBUG 2590 if (wpi_debug & WPI_DEBUG_SCANNING) { 2591 printf("Scanning Essid: "); 2592 ieee80211_print_essid(ic->ic_des_ssid[i].ssid, 2593 ic->ic_des_ssid[i].len); 2594 printf("\n"); 2595 } 2596#endif |
2758 } 2759 2760 /* 2761 * Build a probe request frame. Most of the following code is a 2762 * copy & paste of what is done in net80211. 2763 */ 2764 wh = (struct ieee80211_frame *)&hdr->scan_essids[4]; 2765 wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT | --- 125 unchanged lines hidden (view full) --- 2891 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, 2892 BUS_DMASYNC_PREWRITE); 2893 bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE); 2894 2895 /* kick cmd ring */ 2896 ring->cur = (ring->cur + 1) % WPI_CMD_RING_COUNT; 2897 WPI_WRITE(sc, WPI_TX_WIDX, ring->qid << 8 | ring->cur); 2898 | 2597 } 2598 2599 /* 2600 * Build a probe request frame. Most of the following code is a 2601 * copy & paste of what is done in net80211. 2602 */ 2603 wh = (struct ieee80211_frame *)&hdr->scan_essids[4]; 2604 wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT | --- 125 unchanged lines hidden (view full) --- 2730 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, 2731 BUS_DMASYNC_PREWRITE); 2732 bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE); 2733 2734 /* kick cmd ring */ 2735 ring->cur = (ring->cur + 1) % WPI_CMD_RING_COUNT; 2736 WPI_WRITE(sc, WPI_TX_WIDX, ring->qid << 8 | ring->cur); 2737 |
2738 sc->sc_scan_timer = 5; |
|
2899 return 0; /* will be notified async. of failure/success */ 2900} 2901 2902/** 2903 * Configure the card to listen to a particular channel, this transisions the 2904 * card in to being able to receive frames from remote devices. 2905 */ 2906static int --- 65 unchanged lines hidden (view full) --- 2972 error = wpi_cmd(sc, WPI_CMD_CONFIGURE, &sc->config, 2973 sizeof (struct wpi_config), 0); 2974 if (error != 0) { 2975 device_printf(sc->sc_dev, "configure command failed\n"); 2976 return error; 2977 } 2978 2979 /* configuration has changed, set Tx power accordingly */ | 2739 return 0; /* will be notified async. of failure/success */ 2740} 2741 2742/** 2743 * Configure the card to listen to a particular channel, this transisions the 2744 * card in to being able to receive frames from remote devices. 2745 */ 2746static int --- 65 unchanged lines hidden (view full) --- 2812 error = wpi_cmd(sc, WPI_CMD_CONFIGURE, &sc->config, 2813 sizeof (struct wpi_config), 0); 2814 if (error != 0) { 2815 device_printf(sc->sc_dev, "configure command failed\n"); 2816 return error; 2817 } 2818 2819 /* configuration has changed, set Tx power accordingly */ |
2980 if ((error = wpi_set_txpower(sc, ic->ic_curchan,0)) != 0) { | 2820 if ((error = wpi_set_txpower(sc, ic->ic_curchan, 0)) != 0) { |
2981 device_printf(sc->sc_dev, "could not set Tx power\n"); 2982 return error; 2983 } 2984 2985 /* add broadcast node */ 2986 memset(&node, 0, sizeof node); 2987 IEEE80211_ADDR_COPY(node.bssid, ifp->if_broadcastaddr); 2988 node.id = WPI_ID_BROADCAST; --- 131 unchanged lines hidden (view full) --- 3120 3121 if (sc->type > 1) 3122 hw |= WPI_HW_TYPE_B; 3123 3124 WPI_WRITE(sc, WPI_HWCONFIG, hw); 3125} 3126 3127static void | 2821 device_printf(sc->sc_dev, "could not set Tx power\n"); 2822 return error; 2823 } 2824 2825 /* add broadcast node */ 2826 memset(&node, 0, sizeof node); 2827 IEEE80211_ADDR_COPY(node.bssid, ifp->if_broadcastaddr); 2828 node.id = WPI_ID_BROADCAST; --- 131 unchanged lines hidden (view full) --- 2960 2961 if (sc->type > 1) 2962 hw |= WPI_HW_TYPE_B; 2963 2964 WPI_WRITE(sc, WPI_HWCONFIG, hw); 2965} 2966 2967static void |
2968wpi_rfkill_resume(struct wpi_softc *sc) 2969{ 2970 struct ifnet *ifp = sc->sc_ifp; 2971 struct ieee80211com *ic = &sc->sc_ic; 2972 int ntries; 2973 2974 /* enable firmware again */ 2975 WPI_WRITE(sc, WPI_UCODE_CLR, WPI_RADIO_OFF); 2976 WPI_WRITE(sc, WPI_UCODE_CLR, WPI_DISABLE_CMD); 2977 2978 /* wait for thermal sensors to calibrate */ 2979 for (ntries = 0; ntries < 1000; ntries++) { 2980 if ((sc->temp = (int)WPI_READ(sc, WPI_TEMPERATURE)) != 0) 2981 break; 2982 DELAY(10); 2983 } 2984 2985 if (ntries == 1000) { 2986 device_printf(sc->sc_dev, 2987 "timeout waiting for thermal calibration\n"); 2988 WPI_UNLOCK(sc); 2989 return; 2990 } 2991 DPRINTFN(WPI_DEBUG_TEMP,("temperature %d\n", sc->temp)); 2992 2993 if (wpi_config(sc) != 0) { 2994 device_printf(sc->sc_dev, "device config failed\n"); 2995 WPI_UNLOCK(sc); 2996 return; 2997 } 2998 2999 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 3000 ifp->if_drv_flags |= IFF_DRV_RUNNING; 3001 sc->flags &= ~WPI_FLAG_HW_RADIO_OFF; 3002 3003 if (ic->ic_flags & IEEE80211_F_SCAN) 3004 ieee80211_scan_next(ic); 3005 3006 ieee80211_beacon_miss(ic); 3007 3008 /* reset the led sequence */ 3009 switch (ic->ic_state) { 3010 case IEEE80211_S_SCAN: 3011 wpi_set_led(sc, WPI_LED_LINK, 20, 2); 3012 break; 3013 3014 case IEEE80211_S_RUN: 3015 if (ic->ic_opmode == IEEE80211_M_MONITOR) 3016 wpi_set_led(sc, WPI_LED_LINK, 5, 5); 3017 else 3018 wpi_set_led(sc, WPI_LED_LINK, 0, 1); 3019 break; 3020 3021 default: 3022 break; /* please compiler */ 3023 } 3024 3025 callout_reset(&sc->watchdog_to, hz, wpi_watchdog, sc); 3026} 3027 3028static void |
|
3128wpi_init(void *arg) 3129{ 3130 struct wpi_softc *sc = arg; | 3029wpi_init(void *arg) 3030{ 3031 struct wpi_softc *sc = arg; |
3032 3033 WPI_LOCK(sc); 3034 wpi_init_locked(sc, 0); 3035 WPI_UNLOCK(sc); 3036} 3037 3038static void 3039wpi_init_locked(struct wpi_softc *sc, int force) 3040{ |
|
3131 struct ieee80211com *ic = &sc->sc_ic; 3132 struct ifnet *ifp = ic->ic_ifp; 3133 uint32_t tmp; | 3041 struct ieee80211com *ic = &sc->sc_ic; 3042 struct ifnet *ifp = ic->ic_ifp; 3043 uint32_t tmp; |
3134 int ntries, error, qid; 3135 WPI_LOCK_DECL; | 3044 int ntries, qid; |
3136 | 3045 |
3137 WPI_LOCK(sc); 3138 | |
3139 wpi_stop_locked(sc); 3140 (void)wpi_reset(sc); 3141 3142 wpi_mem_lock(sc); 3143 wpi_mem_write(sc, WPI_MEM_CLOCK1, 0xa00); 3144 DELAY(20); 3145 tmp = wpi_mem_read(sc, WPI_MEM_PCIDEV); 3146 wpi_mem_write(sc, WPI_MEM_PCIDEV, tmp | 0x800); --- 40 unchanged lines hidden (view full) --- 3187 WPI_WRITE(sc, WPI_INTR, 0xffffffff); 3188 3189 /* enable interrupts */ 3190 WPI_WRITE(sc, WPI_MASK, WPI_INTR_MASK); 3191 3192 WPI_WRITE(sc, WPI_UCODE_CLR, WPI_RADIO_OFF); 3193 WPI_WRITE(sc, WPI_UCODE_CLR, WPI_RADIO_OFF); 3194 | 3046 wpi_stop_locked(sc); 3047 (void)wpi_reset(sc); 3048 3049 wpi_mem_lock(sc); 3050 wpi_mem_write(sc, WPI_MEM_CLOCK1, 0xa00); 3051 DELAY(20); 3052 tmp = wpi_mem_read(sc, WPI_MEM_PCIDEV); 3053 wpi_mem_write(sc, WPI_MEM_PCIDEV, tmp | 0x800); --- 40 unchanged lines hidden (view full) --- 3094 WPI_WRITE(sc, WPI_INTR, 0xffffffff); 3095 3096 /* enable interrupts */ 3097 WPI_WRITE(sc, WPI_MASK, WPI_INTR_MASK); 3098 3099 WPI_WRITE(sc, WPI_UCODE_CLR, WPI_RADIO_OFF); 3100 WPI_WRITE(sc, WPI_UCODE_CLR, WPI_RADIO_OFF); 3101 |
3195 if ((error = wpi_load_firmware(sc)) != 0) { | 3102 if ((wpi_load_firmware(sc)) != 0) { |
3196 device_printf(sc->sc_dev, 3197 "A problem occurred loading the firmware to the driver\n"); 3198 return; 3199 } 3200 3201 /* At this point the firmware is up and running. If the hardware 3202 * RF switch is turned off thermal calibration will fail, though 3203 * the card is still happy to continue to accept commands, catch | 3103 device_printf(sc->sc_dev, 3104 "A problem occurred loading the firmware to the driver\n"); 3105 return; 3106 } 3107 3108 /* At this point the firmware is up and running. If the hardware 3109 * RF switch is turned off thermal calibration will fail, though 3110 * the card is still happy to continue to accept commands, catch |
3204 * this case and record the hw is disabled. | 3111 * this case and schedule a task to watch for it to be turned on. |
3205 */ 3206 wpi_mem_lock(sc); 3207 tmp = wpi_mem_read(sc, WPI_MEM_HW_RADIO_OFF); 3208 wpi_mem_unlock(sc); 3209 3210 if (!(tmp & 0x1)) { 3211 sc->flags |= WPI_FLAG_HW_RADIO_OFF; | 3112 */ 3113 wpi_mem_lock(sc); 3114 tmp = wpi_mem_read(sc, WPI_MEM_HW_RADIO_OFF); 3115 wpi_mem_unlock(sc); 3116 3117 if (!(tmp & 0x1)) { 3118 sc->flags |= WPI_FLAG_HW_RADIO_OFF; |
3212 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 3213 ifp->if_drv_flags |= IFF_DRV_RUNNING; | |
3214 device_printf(sc->sc_dev,"Radio Transmitter is switched off\n"); | 3119 device_printf(sc->sc_dev,"Radio Transmitter is switched off\n"); |
3215 return; | 3120 goto out; |
3216 } 3217 3218 /* wait for thermal sensors to calibrate */ 3219 for (ntries = 0; ntries < 1000; ntries++) { 3220 if ((sc->temp = (int)WPI_READ(sc, WPI_TEMPERATURE)) != 0) 3221 break; 3222 DELAY(10); 3223 } 3224 3225 if (ntries == 1000) { 3226 device_printf(sc->sc_dev, 3227 "timeout waiting for thermal sensors calibration\n"); | 3121 } 3122 3123 /* wait for thermal sensors to calibrate */ 3124 for (ntries = 0; ntries < 1000; ntries++) { 3125 if ((sc->temp = (int)WPI_READ(sc, WPI_TEMPERATURE)) != 0) 3126 break; 3127 DELAY(10); 3128 } 3129 3130 if (ntries == 1000) { 3131 device_printf(sc->sc_dev, 3132 "timeout waiting for thermal sensors calibration\n"); |
3228 error = ETIMEDOUT; | |
3229 return; 3230 } 3231 DPRINTFN(WPI_DEBUG_TEMP,("temperature %d\n", sc->temp)); 3232 | 3133 return; 3134 } 3135 DPRINTFN(WPI_DEBUG_TEMP,("temperature %d\n", sc->temp)); 3136 |
3137 if (wpi_config(sc) != 0) { 3138 device_printf(sc->sc_dev, "device config failed\n"); 3139 return; 3140 } 3141 |
|
3233 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 3234 ifp->if_drv_flags |= IFF_DRV_RUNNING; | 3142 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 3143 ifp->if_drv_flags |= IFF_DRV_RUNNING; |
3235 callout_reset(&sc->watchdog_to, hz, wpi_tick, sc); 3236 WPI_UNLOCK(sc); | 3144out: 3145 callout_reset(&sc->watchdog_to, hz, wpi_watchdog, sc); |
3237 3238 if (ic->ic_opmode == IEEE80211_M_MONITOR) 3239 ieee80211_new_state(ic, IEEE80211_S_RUN, -1); 3240 else if (ic->ic_roaming != IEEE80211_ROAMING_MANUAL) 3241 ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); | 3146 3147 if (ic->ic_opmode == IEEE80211_M_MONITOR) 3148 ieee80211_new_state(ic, IEEE80211_S_RUN, -1); 3149 else if (ic->ic_roaming != IEEE80211_ROAMING_MANUAL) 3150 ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); |
3151 return; |
|
3242} 3243 3244static void 3245wpi_stop(struct wpi_softc *sc) 3246{ | 3152} 3153 3154static void 3155wpi_stop(struct wpi_softc *sc) 3156{ |
3247 WPI_LOCK_DECL; | |
3248 3249 WPI_LOCK(sc); 3250 wpi_stop_locked(sc); 3251 WPI_UNLOCK(sc); 3252 3253} 3254static void 3255wpi_stop_locked(struct wpi_softc *sc) 3256 3257{ 3258 struct ieee80211com *ic = &sc->sc_ic; 3259 struct ifnet *ifp = ic->ic_ifp; 3260 uint32_t tmp; 3261 int ac; 3262 | 3157 3158 WPI_LOCK(sc); 3159 wpi_stop_locked(sc); 3160 WPI_UNLOCK(sc); 3161 3162} 3163static void 3164wpi_stop_locked(struct wpi_softc *sc) 3165 3166{ 3167 struct ieee80211com *ic = &sc->sc_ic; 3168 struct ifnet *ifp = ic->ic_ifp; 3169 uint32_t tmp; 3170 int ac; 3171 |
3263 sc->watchdog_cnt = sc->sc_tx_timer = 0; | 3172 sc->sc_tx_timer = 0; 3173 sc->sc_scan_timer = 0; |
3264 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); | 3174 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); |
3175 sc->flags &= ~WPI_FLAG_HW_RADIO_OFF; 3176 callout_stop(&sc->watchdog_to); 3177 callout_stop(&sc->calib_to); |
|
3265 | 3178 |
3179 |
|
3266 /* disable interrupts */ 3267 WPI_WRITE(sc, WPI_MASK, 0); 3268 WPI_WRITE(sc, WPI_INTR, WPI_INTR_MASK); 3269 WPI_WRITE(sc, WPI_INTR_STATUS, 0xff); 3270 WPI_WRITE(sc, WPI_INTR_STATUS, 0x00070000); 3271 3272 /* Clear any commands left in the command buffer */ 3273 memset(sc->sc_cmd, 0, sizeof(sc->sc_cmd)); | 3180 /* disable interrupts */ 3181 WPI_WRITE(sc, WPI_MASK, 0); 3182 WPI_WRITE(sc, WPI_INTR, WPI_INTR_MASK); 3183 WPI_WRITE(sc, WPI_INTR_STATUS, 0xff); 3184 WPI_WRITE(sc, WPI_INTR_STATUS, 0x00070000); 3185 3186 /* Clear any commands left in the command buffer */ 3187 memset(sc->sc_cmd, 0, sizeof(sc->sc_cmd)); |
3188 memset(sc->sc_cmd_arg, 0, sizeof(sc->sc_cmd_arg)); 3189 sc->sc_cmd_cur = 0; 3190 sc->sc_cmd_next = 0; |
|
3274 3275 wpi_mem_lock(sc); 3276 wpi_mem_write(sc, WPI_MEM_MODE, 0); 3277 wpi_mem_unlock(sc); 3278 3279 /* reset all Tx rings */ 3280 for (ac = 0; ac < 4; ac++) 3281 wpi_reset_tx_ring(sc, &sc->txq[ac]); --- 41 unchanged lines hidden (view full) --- 3323} 3324 3325static void 3326wpi_calib_timeout(void *arg) 3327{ 3328 struct wpi_softc *sc = arg; 3329 struct ieee80211com *ic = &sc->sc_ic; 3330 int temp; | 3191 3192 wpi_mem_lock(sc); 3193 wpi_mem_write(sc, WPI_MEM_MODE, 0); 3194 wpi_mem_unlock(sc); 3195 3196 /* reset all Tx rings */ 3197 for (ac = 0; ac < 4; ac++) 3198 wpi_reset_tx_ring(sc, &sc->txq[ac]); --- 41 unchanged lines hidden (view full) --- 3240} 3241 3242static void 3243wpi_calib_timeout(void *arg) 3244{ 3245 struct wpi_softc *sc = arg; 3246 struct ieee80211com *ic = &sc->sc_ic; 3247 int temp; |
3331 WPI_LOCK_DECL; | |
3332 | 3248 |
3249 if (ic->ic_state != IEEE80211_S_RUN) 3250 return; 3251 |
|
3333 /* automatic rate control triggered every 500ms */ 3334 if (ic->ic_fixed_rate == IEEE80211_FIXED_RATE_NONE) { | 3252 /* automatic rate control triggered every 500ms */ 3253 if (ic->ic_fixed_rate == IEEE80211_FIXED_RATE_NONE) { |
3335 WPI_LOCK(sc); | |
3336 if (ic->ic_opmode == IEEE80211_M_STA) 3337 wpi_iter_func(sc, ic->ic_bss); 3338 else 3339 ieee80211_iterate_nodes(&ic->ic_sta, wpi_iter_func, sc); | 3254 if (ic->ic_opmode == IEEE80211_M_STA) 3255 wpi_iter_func(sc, ic->ic_bss); 3256 else 3257 ieee80211_iterate_nodes(&ic->ic_sta, wpi_iter_func, sc); |
3340 WPI_UNLOCK(sc); | |
3341 } 3342 3343 /* update sensor data */ 3344 temp = (int)WPI_READ(sc, WPI_TEMPERATURE); 3345 DPRINTFN(WPI_DEBUG_TEMP,("Temp in calibration is: %d\n", temp)); 3346#if 0 3347 //XXX Used by OpenBSD Sensor Framework 3348 sc->sensor.value = temp + 260; --- 262 unchanged lines hidden (view full) --- 3611 if (idx > WPI_MAX_PWR_INDEX) 3612 return WPI_MAX_PWR_INDEX; 3613 return idx; 3614 3615#undef interpolate 3616#undef fdivround 3617} 3618 | 3258 } 3259 3260 /* update sensor data */ 3261 temp = (int)WPI_READ(sc, WPI_TEMPERATURE); 3262 DPRINTFN(WPI_DEBUG_TEMP,("Temp in calibration is: %d\n", temp)); 3263#if 0 3264 //XXX Used by OpenBSD Sensor Framework 3265 sc->sensor.value = temp + 260; --- 262 unchanged lines hidden (view full) --- 3528 if (idx > WPI_MAX_PWR_INDEX) 3529 return WPI_MAX_PWR_INDEX; 3530 return idx; 3531 3532#undef interpolate 3533#undef fdivround 3534} 3535 |
3619#if 0 3620static void 3621wpi_radio_on(void *arg, int pending) 3622{ 3623 struct wpi_softc *sc = arg; 3624 3625 device_printf(sc->sc_dev, "radio turned on\n"); 3626} 3627 3628static void 3629wpi_radio_off(void *arg, int pending) 3630{ 3631 struct wpi_softc *sc = arg; 3632 3633 device_printf(sc->sc_dev, "radio turned off\n"); 3634} 3635#endif 3636 | |
3637/** 3638 * Called by net80211 framework to indicate that a scan 3639 * is starting. This function doesn't actually do the scan, 3640 * wpi_scan_curchan starts things off. This function is more 3641 * of an early warning from the framework we should get ready 3642 * for the scan. 3643 */ 3644static void 3645wpi_scan_start(struct ieee80211com *ic) 3646{ 3647 struct ifnet *ifp = ic->ic_ifp; 3648 struct wpi_softc *sc = ifp->if_softc; 3649 | 3536/** 3537 * Called by net80211 framework to indicate that a scan 3538 * is starting. This function doesn't actually do the scan, 3539 * wpi_scan_curchan starts things off. This function is more 3540 * of an early warning from the framework we should get ready 3541 * for the scan. 3542 */ 3543static void 3544wpi_scan_start(struct ieee80211com *ic) 3545{ 3546 struct ifnet *ifp = ic->ic_ifp; 3547 struct wpi_softc *sc = ifp->if_softc; 3548 |
3650 wpi_queue_cmd(sc, WPI_SCAN_START); | 3549 wpi_queue_cmd(sc, WPI_SCAN_START, 0, WPI_QUEUE_NORMAL); |
3651} 3652 3653/** 3654 * Called by the net80211 framework, indicates that the 3655 * scan has ended. If there is a scan in progress on the card 3656 * then it should be aborted. 3657 */ 3658static void 3659wpi_scan_end(struct ieee80211com *ic) 3660{ 3661 struct ifnet *ifp = ic->ic_ifp; 3662 struct wpi_softc *sc = ifp->if_softc; 3663 | 3550} 3551 3552/** 3553 * Called by the net80211 framework, indicates that the 3554 * scan has ended. If there is a scan in progress on the card 3555 * then it should be aborted. 3556 */ 3557static void 3558wpi_scan_end(struct ieee80211com *ic) 3559{ 3560 struct ifnet *ifp = ic->ic_ifp; 3561 struct wpi_softc *sc = ifp->if_softc; 3562 |
3664 wpi_queue_cmd(sc, WPI_SCAN_STOP); | 3563 wpi_queue_cmd(sc, WPI_SCAN_STOP, 0, WPI_QUEUE_NORMAL); |
3665} 3666 3667/** 3668 * Called by the net80211 framework to indicate to the driver 3669 * that the channel should be changed 3670 */ 3671static void 3672wpi_set_channel(struct ieee80211com *ic) 3673{ 3674 struct ifnet *ifp = ic->ic_ifp; 3675 struct wpi_softc *sc = ifp->if_softc; 3676 | 3564} 3565 3566/** 3567 * Called by the net80211 framework to indicate to the driver 3568 * that the channel should be changed 3569 */ 3570static void 3571wpi_set_channel(struct ieee80211com *ic) 3572{ 3573 struct ifnet *ifp = ic->ic_ifp; 3574 struct wpi_softc *sc = ifp->if_softc; 3575 |
3677 wpi_queue_cmd(sc, WPI_SET_CHAN); | 3576 /* 3577 * Only need to set the channel in Monitor mode. AP scanning and auth 3578 * are already taken care of by their respective firmware commands. 3579 */ 3580 if (ic->ic_opmode == IEEE80211_M_MONITOR) 3581 wpi_queue_cmd(sc, WPI_SET_CHAN, 0, WPI_QUEUE_NORMAL); |
3678} 3679 3680/** 3681 * Called by net80211 to indicate that we need to scan the current 3682 * channel. The channel is previously be set via the wpi_set_channel 3683 * callback. 3684 */ 3685static void 3686wpi_scan_curchan(struct ieee80211com *ic, unsigned long maxdwell) 3687{ 3688 struct ifnet *ifp = ic->ic_ifp; 3689 struct wpi_softc *sc = ifp->if_softc; 3690 3691 sc->maxdwell = maxdwell; 3692 | 3582} 3583 3584/** 3585 * Called by net80211 to indicate that we need to scan the current 3586 * channel. The channel is previously be set via the wpi_set_channel 3587 * callback. 3588 */ 3589static void 3590wpi_scan_curchan(struct ieee80211com *ic, unsigned long maxdwell) 3591{ 3592 struct ifnet *ifp = ic->ic_ifp; 3593 struct wpi_softc *sc = ifp->if_softc; 3594 3595 sc->maxdwell = maxdwell; 3596 |
3693 wpi_queue_cmd(sc, WPI_SCAN_CURCHAN); | 3597 wpi_queue_cmd(sc, WPI_SCAN_CURCHAN, 0, WPI_QUEUE_NORMAL); |
3694} 3695 3696/** 3697 * Called by the net80211 framework to indicate 3698 * the minimum dwell time has been met, terminate the scan. 3699 * We don't actually terminate the scan as the firmware will notify 3700 * us when it's finished and we have no way to interrupt it. 3701 */ --- 5 unchanged lines hidden (view full) --- 3707 3708/** 3709 * The ops function is called to perform some actual work. 3710 * because we can't sleep from any of the ic callbacks, we queue an 3711 * op task with wpi_queue_cmd and have the taskqueue process that task. 3712 * The task that gets cued is a op task, which ends up calling this function. 3713 */ 3714static void | 3598} 3599 3600/** 3601 * Called by the net80211 framework to indicate 3602 * the minimum dwell time has been met, terminate the scan. 3603 * We don't actually terminate the scan as the firmware will notify 3604 * us when it's finished and we have no way to interrupt it. 3605 */ --- 5 unchanged lines hidden (view full) --- 3611 3612/** 3613 * The ops function is called to perform some actual work. 3614 * because we can't sleep from any of the ic callbacks, we queue an 3615 * op task with wpi_queue_cmd and have the taskqueue process that task. 3616 * The task that gets cued is a op task, which ends up calling this function. 3617 */ 3618static void |
3715wpi_ops(void *arg, int pending) | 3619wpi_ops(void *arg0, int pending) |
3716{ | 3620{ |
3717 struct wpi_softc *sc = arg; | 3621 struct wpi_softc *sc = arg0; |
3718 struct ieee80211com *ic = &sc->sc_ic; | 3622 struct ieee80211com *ic = &sc->sc_ic; |
3719 WPI_LOCK_DECL; 3720 int cmd; | 3623 int cmd, arg, error; |
3721 3722again: 3723 WPI_CMD_LOCK(sc); 3724 cmd = sc->sc_cmd[sc->sc_cmd_cur]; | 3624 3625again: 3626 WPI_CMD_LOCK(sc); 3627 cmd = sc->sc_cmd[sc->sc_cmd_cur]; |
3628 arg = sc->sc_cmd_arg[sc->sc_cmd_cur]; |
|
3725 3726 if (cmd == 0) { 3727 /* No more commands to process */ 3728 WPI_CMD_UNLOCK(sc); 3729 return; 3730 } 3731 sc->sc_cmd[sc->sc_cmd_cur] = 0; /* free the slot */ | 3629 3630 if (cmd == 0) { 3631 /* No more commands to process */ 3632 WPI_CMD_UNLOCK(sc); 3633 return; 3634 } 3635 sc->sc_cmd[sc->sc_cmd_cur] = 0; /* free the slot */ |
3636 sc->sc_cmd_arg[sc->sc_cmd_cur] = 0; /* free the slot */ |
|
3732 sc->sc_cmd_cur = (sc->sc_cmd_cur + 1) % WPI_CMD_MAXOPS; 3733 WPI_CMD_UNLOCK(sc); 3734 WPI_LOCK(sc); 3735 | 3637 sc->sc_cmd_cur = (sc->sc_cmd_cur + 1) % WPI_CMD_MAXOPS; 3638 WPI_CMD_UNLOCK(sc); 3639 WPI_LOCK(sc); 3640 |
3736 if (!(sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING)) { | 3641 DPRINTFN(WPI_DEBUG_OPS,("wpi_ops: command: %d\n", cmd)); 3642 3643 switch (cmd) { 3644 case WPI_RESTART: 3645 wpi_init_locked(sc, 0); |
3737 WPI_UNLOCK(sc); 3738 return; | 3646 WPI_UNLOCK(sc); 3647 return; |
3648 3649 case WPI_RF_RESTART: 3650 wpi_rfkill_resume(sc); 3651 WPI_UNLOCK(sc); 3652 return; |
|
3739 } 3740 | 3653 } 3654 |
3741 { 3742 const char *name[]={"SCAN_START", "SCAN_CURCHAN",0,"STOP",0,0,0,"CHAN", 3743 0,0,0,0,0,0,"AUTH",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"NEXT"}; 3744 DPRINTFN(WPI_DEBUG_OPS,("wpi_ops: command: %d %s\n", cmd, name[cmd-1])); | 3655 if (!(sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING)) { 3656 WPI_UNLOCK(sc); 3657 return; |
3745 } 3746 3747 switch (cmd) { 3748 case WPI_SCAN_START: | 3658 } 3659 3660 switch (cmd) { 3661 case WPI_SCAN_START: |
3749 if (sc->flags & WPI_FLAG_HW_RADIO_OFF) { 3750 DPRINTF(("HERER\n")); 3751 ieee80211_cancel_scan(ic); 3752 } else 3753 sc->flags |= WPI_FLAG_SCANNING; | 3662 sc->flags |= WPI_FLAG_SCANNING; |
3754 break; 3755 3756 case WPI_SCAN_STOP: 3757 sc->flags &= ~WPI_FLAG_SCANNING; 3758 break; 3759 | 3663 break; 3664 3665 case WPI_SCAN_STOP: 3666 sc->flags &= ~WPI_FLAG_SCANNING; 3667 break; 3668 |
3760 case WPI_SCAN_NEXT: 3761 DPRINTF(("NEXT\n")); 3762 WPI_UNLOCK(sc); 3763 ieee80211_scan_next(ic); 3764 WPI_LOCK(sc); 3765 break; 3766 | |
3767 case WPI_SCAN_CURCHAN: 3768 if (wpi_scan(sc)) 3769 ieee80211_cancel_scan(ic); 3770 break; 3771 3772 case WPI_SET_CHAN: | 3669 case WPI_SCAN_CURCHAN: 3670 if (wpi_scan(sc)) 3671 ieee80211_cancel_scan(ic); 3672 break; 3673 3674 case WPI_SET_CHAN: |
3773 if (sc->flags&WPI_FLAG_AUTH) { 3774 DPRINTF(("Authenticating, not changing channel\n")); 3775 break; 3776 } 3777 if (wpi_config(sc)) { 3778 DPRINTF(("Scan cancelled\n")); | 3675 error = wpi_config(sc); 3676 if (error != 0) 3677 device_printf(sc->sc_dev, 3678 "error %d settting channel\n", error); 3679 break; 3680 3681 case WPI_AUTH: 3682 /* The node must be registered in the firmware before auth */ 3683 error = wpi_auth(sc); 3684 if (error != 0) { 3685 device_printf(sc->sc_dev, 3686 "%s: could not move to auth state, error %d\n", 3687 __func__, error); |
3779 WPI_UNLOCK(sc); | 3688 WPI_UNLOCK(sc); |
3780 ieee80211_cancel_scan(ic); 3781 WPI_LOCK(sc); 3782 sc->flags &= ~WPI_FLAG_SCANNING; 3783 wpi_restart(sc,0); 3784 WPI_UNLOCK(sc); | |
3785 return; 3786 } | 3689 return; 3690 } |
3691 /* Send the auth frame now */ 3692 sc->sc_newstate(ic, IEEE80211_S_AUTH, arg); |
|
3787 break; 3788 | 3693 break; 3694 |
3789 case WPI_AUTH: 3790 if (wpi_auth(sc) != 0) { | 3695 case WPI_RUN: 3696 error = wpi_run(sc); 3697 if (error != 0) { |
3791 device_printf(sc->sc_dev, | 3698 device_printf(sc->sc_dev, |
3792 "could not send authentication request\n"); 3793 wpi_stop_locked(sc); | 3699 "%s: could not move to run state, error %d\n", 3700 __func__, error); |
3794 WPI_UNLOCK(sc); 3795 return; 3796 } | 3701 WPI_UNLOCK(sc); 3702 return; 3703 } |
3797 WPI_UNLOCK(sc); 3798 ieee80211_node_authorize(ic->ic_bss); 3799 ieee80211_new_state(ic, IEEE80211_S_ASSOC, -1); 3800 WPI_LOCK(sc); | 3704 sc->sc_newstate(ic, IEEE80211_S_RUN, arg); |
3801 break; 3802 } 3803 WPI_UNLOCK(sc); 3804 3805 /* Take another pass */ 3806 goto again; 3807} 3808 3809/** 3810 * queue a command for later execution in a different thread. 3811 * This is needed as the net80211 callbacks do not allow 3812 * sleeping, since we need to sleep to confirm commands have 3813 * been processed by the firmware, we must defer execution to 3814 * a sleep enabled thread. 3815 */ 3816static int | 3705 break; 3706 } 3707 WPI_UNLOCK(sc); 3708 3709 /* Take another pass */ 3710 goto again; 3711} 3712 3713/** 3714 * queue a command for later execution in a different thread. 3715 * This is needed as the net80211 callbacks do not allow 3716 * sleeping, since we need to sleep to confirm commands have 3717 * been processed by the firmware, we must defer execution to 3718 * a sleep enabled thread. 3719 */ 3720static int |
3817wpi_queue_cmd(struct wpi_softc *sc, int cmd) | 3721wpi_queue_cmd(struct wpi_softc *sc, int cmd, int arg, int flush) |
3818{ 3819 WPI_CMD_LOCK(sc); 3820 | 3722{ 3723 WPI_CMD_LOCK(sc); 3724 |
3725 if (flush) { 3726 memset(sc->sc_cmd, 0, sizeof (sc->sc_cmd)); 3727 memset(sc->sc_cmd_arg, 0, sizeof (sc->sc_cmd_arg)); 3728 sc->sc_cmd_cur = 0; 3729 sc->sc_cmd_next = 0; 3730 } 3731 |
|
3821 if (sc->sc_cmd[sc->sc_cmd_next] != 0) { 3822 WPI_CMD_UNLOCK(sc); 3823 DPRINTF(("%s: command %d dropped\n", __func__, cmd)); 3824 return (EBUSY); 3825 } 3826 3827 sc->sc_cmd[sc->sc_cmd_next] = cmd; | 3732 if (sc->sc_cmd[sc->sc_cmd_next] != 0) { 3733 WPI_CMD_UNLOCK(sc); 3734 DPRINTF(("%s: command %d dropped\n", __func__, cmd)); 3735 return (EBUSY); 3736 } 3737 3738 sc->sc_cmd[sc->sc_cmd_next] = cmd; |
3739 sc->sc_cmd_arg[sc->sc_cmd_next] = arg; |
|
3828 sc->sc_cmd_next = (sc->sc_cmd_next + 1) % WPI_CMD_MAXOPS; 3829 3830 taskqueue_enqueue(sc->sc_tq, &sc->sc_opstask); 3831 3832 WPI_CMD_UNLOCK(sc); 3833 3834 return 0; 3835} 3836 | 3740 sc->sc_cmd_next = (sc->sc_cmd_next + 1) % WPI_CMD_MAXOPS; 3741 3742 taskqueue_enqueue(sc->sc_tq, &sc->sc_opstask); 3743 3744 WPI_CMD_UNLOCK(sc); 3745 3746 return 0; 3747} 3748 |
3837static void 3838wpi_restart(void * arg, int pending) 3839{ 3840#if 0 3841 struct wpi_softc *sc = arg; 3842 struct ieee80211com *ic = &sc->sc_ic; 3843 WPI_LOCK_DECL; 3844 3845 DPRINTF(("Device failed, restarting device\n")); 3846 WPI_LOCK(sc); 3847 wpi_stop(sc); 3848 wpi_init(sc); 3849 WPI_UNLOCK(sc); 3850 ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); 3851#endif 3852} 3853 | |
3854/* 3855 * Allocate DMA-safe memory for firmware transfer. 3856 */ 3857static int 3858wpi_alloc_fwmem(struct wpi_softc *sc) 3859{ 3860 /* allocate enough contiguous space to store text and data */ 3861 return wpi_dma_contig_alloc(sc, &sc->fw_dma, NULL, 3862 WPI_FW_MAIN_TEXT_MAXSZ + WPI_FW_MAIN_DATA_MAXSZ, 1, 3863 BUS_DMA_NOWAIT); 3864} 3865 3866static void 3867wpi_free_fwmem(struct wpi_softc *sc) 3868{ 3869 wpi_dma_contig_free(&sc->fw_dma); 3870} 3871 3872/** | 3749/* 3750 * Allocate DMA-safe memory for firmware transfer. 3751 */ 3752static int 3753wpi_alloc_fwmem(struct wpi_softc *sc) 3754{ 3755 /* allocate enough contiguous space to store text and data */ 3756 return wpi_dma_contig_alloc(sc, &sc->fw_dma, NULL, 3757 WPI_FW_MAIN_TEXT_MAXSZ + WPI_FW_MAIN_DATA_MAXSZ, 1, 3758 BUS_DMA_NOWAIT); 3759} 3760 3761static void 3762wpi_free_fwmem(struct wpi_softc *sc) 3763{ 3764 wpi_dma_contig_free(&sc->fw_dma); 3765} 3766 3767/** |
3873 * Called every second, wpi_tick used by the watch dog timer | 3768 * Called every second, wpi_watchdog used by the watch dog timer |
3874 * to check that the card is still alive 3875 */ 3876static void | 3769 * to check that the card is still alive 3770 */ 3771static void |
3877wpi_tick(void *arg) | 3772wpi_watchdog(void *arg) |
3878{ 3879 struct wpi_softc *sc = arg; | 3773{ 3774 struct wpi_softc *sc = arg; |
3775 struct ifnet *ifp = sc->sc_ifp; 3776 uint32_t tmp; |
|
3880 3881 DPRINTFN(WPI_DEBUG_WATCHDOG,("Watchdog: tick\n")); 3882 | 3777 3778 DPRINTFN(WPI_DEBUG_WATCHDOG,("Watchdog: tick\n")); 3779 |
3883 wpi_watchdog(sc->sc_ifp); 3884 callout_reset(&sc->watchdog_to, hz, wpi_tick, sc); | 3780 if (sc->flags & WPI_FLAG_HW_RADIO_OFF) { 3781 /* No need to lock firmware memory */ 3782 tmp = wpi_mem_read(sc, WPI_MEM_HW_RADIO_OFF); 3783 3784 if ((tmp & 0x1) == 0) { 3785 /* Radio kill switch is still off */ 3786 callout_reset(&sc->watchdog_to, hz, wpi_watchdog, sc); 3787 return; 3788 } 3789 3790 device_printf(sc->sc_dev, "Hardware Switch Enabled\n"); 3791 wpi_queue_cmd(sc, WPI_RF_RESTART, 0, WPI_QUEUE_CLEAR); 3792 return; 3793 } 3794 3795 if (sc->sc_tx_timer > 0) { 3796 if (--sc->sc_tx_timer == 0) { 3797 device_printf(sc->sc_dev,"device timeout\n"); 3798 ifp->if_oerrors++; 3799 wpi_queue_cmd(sc, WPI_RESTART, 0, WPI_QUEUE_CLEAR); 3800 } 3801 } 3802 if (sc->sc_scan_timer > 0) { 3803 if (--sc->sc_scan_timer == 0) { 3804 device_printf(sc->sc_dev,"scan timeout\n"); 3805 ieee80211_cancel_scan(&sc->sc_ic); 3806 wpi_queue_cmd(sc, WPI_RESTART, 0, WPI_QUEUE_CLEAR); 3807 } 3808 } 3809 3810 if (ifp->if_drv_flags & IFF_DRV_RUNNING) 3811 callout_reset(&sc->watchdog_to, hz, wpi_watchdog, sc); |
3885} 3886 3887#ifdef WPI_DEBUG 3888static const char *wpi_cmd_str(int cmd) 3889{ 3890 switch(cmd) { 3891 case WPI_DISABLE_CMD: return "WPI_DISABLE_CMD"; 3892 case WPI_CMD_CONFIGURE: return "WPI_CMD_CONFIGURE"; --- 24 unchanged lines hidden --- | 3812} 3813 3814#ifdef WPI_DEBUG 3815static const char *wpi_cmd_str(int cmd) 3816{ 3817 switch(cmd) { 3818 case WPI_DISABLE_CMD: return "WPI_DISABLE_CMD"; 3819 case WPI_CMD_CONFIGURE: return "WPI_CMD_CONFIGURE"; --- 24 unchanged lines hidden --- |