Lines Matching refs:sc
509 iwh_sc_t *sc; in iwh_attach() local
526 sc = ddi_get_soft_state(iwh_soft_state_p, in iwh_attach()
528 ASSERT(sc != NULL); in iwh_attach()
530 if (sc->sc_flags & IWH_F_RUNNING) { in iwh_attach()
531 (void) iwh_init(sc); in iwh_attach()
534 atomic_and_32(&sc->sc_flags, ~IWH_F_SUSPEND); in iwh_attach()
552 sc = ddi_get_soft_state(iwh_soft_state_p, instance); in iwh_attach()
553 ASSERT(sc != NULL); in iwh_attach()
555 sc->sc_dip = dip; in iwh_attach()
560 err = ddi_regs_map_setup(dip, 0, &sc->sc_cfg_base, 0, 0, in iwh_attach()
561 &iwh_reg_accattr, &sc->sc_cfg_handle); in iwh_attach()
568 sc->sc_dev_id = ddi_get16(sc->sc_cfg_handle, in iwh_attach()
569 (uint16_t *)(sc->sc_cfg_base + PCI_CONF_DEVID)); in iwh_attach()
570 if ((sc->sc_dev_id != 0x4232) && in iwh_attach()
571 (sc->sc_dev_id != 0x4235) && in iwh_attach()
572 (sc->sc_dev_id != 0x4236) && in iwh_attach()
573 (sc->sc_dev_id != 0x4237) && in iwh_attach()
574 (sc->sc_dev_id != 0x423a) && in iwh_attach()
575 (sc->sc_dev_id != 0x423b) && in iwh_attach()
576 (sc->sc_dev_id != 0x423c) && in iwh_attach()
577 (sc->sc_dev_id != 0x423d)) { in iwh_attach()
583 iwh_init_ht_conf(sc); in iwh_attach()
584 iwh_overwrite_11n_rateset(sc); in iwh_attach()
586 sc->sc_rev = ddi_get8(sc->sc_cfg_handle, in iwh_attach()
587 (uint8_t *)(sc->sc_cfg_base + PCI_CONF_REVID)); in iwh_attach()
592 ddi_put8(sc->sc_cfg_handle, (uint8_t *)(sc->sc_cfg_base + in iwh_attach()
598 sc->sc_clsz = ddi_get16(sc->sc_cfg_handle, in iwh_attach()
599 (uint16_t *)(sc->sc_cfg_base + PCI_CONF_CACHE_LINESZ)); in iwh_attach()
600 if (!sc->sc_clsz) { in iwh_attach()
601 sc->sc_clsz = 16; in iwh_attach()
603 sc->sc_clsz = (sc->sc_clsz << 2); in iwh_attach()
605 sc->sc_dmabuf_sz = roundup(0x2000 + sizeof (struct ieee80211_frame) + in iwh_attach()
608 IEEE80211_WEP_CRCLEN), sc->sc_clsz); in iwh_attach()
613 err = ddi_regs_map_setup(dip, 1, &sc->sc_base, in iwh_attach()
614 0, 0, &iwh_reg_accattr, &sc->sc_handle); in iwh_attach()
624 sc->sc_hw_rev = IWH_READ(sc, CSR_HW_REV); in iwh_attach()
640 sc->sc_intr_htable = kmem_zalloc(sizeof (ddi_intr_handle_t), KM_SLEEP); in iwh_attach()
642 err = ddi_intr_alloc(dip, sc->sc_intr_htable, DDI_INTR_TYPE_FIXED, 0, in iwh_attach()
650 err = ddi_intr_get_pri(sc->sc_intr_htable[0], &sc->sc_intr_pri); in iwh_attach()
657 mutex_init(&sc->sc_glock, NULL, MUTEX_DRIVER, in iwh_attach()
658 DDI_INTR_PRI(sc->sc_intr_pri)); in iwh_attach()
659 mutex_init(&sc->sc_tx_lock, NULL, MUTEX_DRIVER, in iwh_attach()
660 DDI_INTR_PRI(sc->sc_intr_pri)); in iwh_attach()
661 mutex_init(&sc->sc_mt_lock, NULL, MUTEX_DRIVER, in iwh_attach()
662 DDI_INTR_PRI(sc->sc_intr_pri)); in iwh_attach()
664 cv_init(&sc->sc_cmd_cv, NULL, CV_DRIVER, NULL); in iwh_attach()
665 cv_init(&sc->sc_put_seg_cv, NULL, CV_DRIVER, NULL); in iwh_attach()
666 cv_init(&sc->sc_ucode_cv, NULL, CV_DRIVER, NULL); in iwh_attach()
671 cv_init(&sc->sc_mt_cv, NULL, CV_DRIVER, NULL); in iwh_attach()
672 sc->sc_mf_thread = NULL; in iwh_attach()
673 sc->sc_mf_thread_switch = 0; in iwh_attach()
678 err = iwh_alloc_shared(sc); in iwh_attach()
685 (void) memset(sc->sc_shared, 0, sizeof (iwh_shared_t)); in iwh_attach()
690 err = iwh_alloc_kw(sc); in iwh_attach()
697 err = iwh_reset_hw(sc); in iwh_attach()
707 err = iwh_preinit(sc); in iwh_attach()
717 err = iwh_eep_load(sc); in iwh_attach()
724 if (IWH_READ_EEP_SHORT(sc, EEP_VERSION) < 0x011a) { in iwh_attach()
733 iwh_get_mac_from_eep(sc); in iwh_attach()
738 sc->sc_eep_calib = (struct iwh_eep_calibration *) in iwh_attach()
739 iwh_eep_addr_trans(sc, EEP_CALIBRATION); in iwh_attach()
744 err = iwh_ring_init(sc); in iwh_attach()
751 if ((0x423c == sc->sc_dev_id) || (0x423d == sc->sc_dev_id)) { in iwh_attach()
752 sc->sc_hdr = (iwh_firmware_hdr_t *)iwh_fw_5150_bin; in iwh_attach()
754 sc->sc_hdr = (iwh_firmware_hdr_t *)iwh_fw_5000_bin; in iwh_attach()
760 err = iwh_alloc_fw_dma(sc); in iwh_attach()
771 ic = &sc->sc_ic; in iwh_attach()
793 if (sc->sc_ht_conf.ht_support) { in iwh_attach()
816 if (sc->sc_ht_conf.cap & HT_CAP_SUP_WIDTH) { in iwh_attach()
843 iwh_overwrite_ic_default(sc); in iwh_attach()
855 err = ddi_intr_add_softint(dip, &sc->sc_soft_hdl, DDI_INTR_SOFTPRI_MAX, in iwh_attach()
856 iwh_rx_softintr, (caddr_t)sc); in iwh_attach()
863 err = ddi_intr_add_handler(sc->sc_intr_htable[0], iwh_intr, in iwh_attach()
864 (caddr_t)sc, NULL); in iwh_attach()
871 err = ddi_intr_enable(sc->sc_intr_htable[0]); in iwh_attach()
896 macp->m_driver = sc; in iwh_attach()
936 sc->sc_mf_thread_switch = 1; in iwh_attach()
937 if (NULL == sc->sc_mf_thread) { in iwh_attach()
938 sc->sc_mf_thread = thread_create((caddr_t)NULL, 0, in iwh_attach()
939 iwh_thread, sc, 0, &p0, TS_RUN, minclsyspri); in iwh_attach()
942 atomic_or_32(&sc->sc_flags, IWH_F_ATTACHED); in iwh_attach()
947 (void) ddi_intr_disable(sc->sc_intr_htable[0]); in iwh_attach()
950 (void) ddi_intr_remove_handler(sc->sc_intr_htable[0]); in iwh_attach()
953 (void) ddi_intr_remove_softint(sc->sc_soft_hdl); in iwh_attach()
954 sc->sc_soft_hdl = NULL; in iwh_attach()
960 iwh_free_fw_dma(sc); in iwh_attach()
963 iwh_ring_free(sc); in iwh_attach()
966 iwh_free_kw(sc); in iwh_attach()
969 iwh_free_shared(sc); in iwh_attach()
972 iwh_destroy_locks(sc); in iwh_attach()
975 (void) ddi_intr_free(sc->sc_intr_htable[0]); in iwh_attach()
978 kmem_free(sc->sc_intr_htable, sizeof (ddi_intr_handle_t)); in iwh_attach()
981 ddi_regs_map_free(&sc->sc_handle); in iwh_attach()
984 ddi_regs_map_free(&sc->sc_cfg_handle); in iwh_attach()
996 iwh_sc_t *sc; in iwh_detach() local
1000 sc = ddi_get_soft_state(iwh_soft_state_p, ddi_get_instance(dip)); in iwh_detach()
1001 ASSERT(sc != NULL); in iwh_detach()
1002 ic = &sc->sc_ic; in iwh_detach()
1009 atomic_and_32(&sc->sc_flags, ~IWH_F_HW_ERR_RECOVER); in iwh_detach()
1010 atomic_and_32(&sc->sc_flags, ~IWH_F_RATE_AUTO_CTL); in iwh_detach()
1012 atomic_or_32(&sc->sc_flags, IWH_F_SUSPEND); in iwh_detach()
1014 if (sc->sc_flags & IWH_F_RUNNING) { in iwh_detach()
1016 iwh_stop(sc); in iwh_detach()
1027 if (!(sc->sc_flags & IWH_F_ATTACHED)) { in iwh_detach()
1034 sc->sc_mf_thread_switch = 0; in iwh_detach()
1036 mutex_enter(&sc->sc_mt_lock); in iwh_detach()
1037 while (sc->sc_mf_thread != NULL) { in iwh_detach()
1038 if (cv_wait_sig(&sc->sc_mt_cv, &sc->sc_mt_lock) == 0) { in iwh_detach()
1042 mutex_exit(&sc->sc_mt_lock); in iwh_detach()
1044 err = mac_disable(sc->sc_ic.ic_mach); in iwh_detach()
1052 iwh_stop(sc); in iwh_detach()
1059 iwh_release_calib_buffer(sc); in iwh_detach()
1064 (void) mac_unregister(sc->sc_ic.ic_mach); in iwh_detach()
1066 mutex_enter(&sc->sc_glock); in iwh_detach()
1067 iwh_free_fw_dma(sc); in iwh_detach()
1068 iwh_ring_free(sc); in iwh_detach()
1069 iwh_free_kw(sc); in iwh_detach()
1070 iwh_free_shared(sc); in iwh_detach()
1071 mutex_exit(&sc->sc_glock); in iwh_detach()
1073 (void) ddi_intr_disable(sc->sc_intr_htable[0]); in iwh_detach()
1074 (void) ddi_intr_remove_handler(sc->sc_intr_htable[0]); in iwh_detach()
1075 (void) ddi_intr_free(sc->sc_intr_htable[0]); in iwh_detach()
1076 kmem_free(sc->sc_intr_htable, sizeof (ddi_intr_handle_t)); in iwh_detach()
1078 (void) ddi_intr_remove_softint(sc->sc_soft_hdl); in iwh_detach()
1079 sc->sc_soft_hdl = NULL; in iwh_detach()
1084 ieee80211_detach(&sc->sc_ic); in iwh_detach()
1086 iwh_destroy_locks(sc); in iwh_detach()
1088 ddi_regs_map_free(&sc->sc_handle); in iwh_detach()
1089 ddi_regs_map_free(&sc->sc_cfg_handle); in iwh_detach()
1100 iwh_destroy_locks(iwh_sc_t *sc) in iwh_destroy_locks() argument
1102 cv_destroy(&sc->sc_mt_cv); in iwh_destroy_locks()
1103 cv_destroy(&sc->sc_cmd_cv); in iwh_destroy_locks()
1104 cv_destroy(&sc->sc_put_seg_cv); in iwh_destroy_locks()
1105 cv_destroy(&sc->sc_ucode_cv); in iwh_destroy_locks()
1106 mutex_destroy(&sc->sc_mt_lock); in iwh_destroy_locks()
1107 mutex_destroy(&sc->sc_tx_lock); in iwh_destroy_locks()
1108 mutex_destroy(&sc->sc_glock); in iwh_destroy_locks()
1115 iwh_alloc_dma_mem(iwh_sc_t *sc, size_t memsize, in iwh_alloc_dma_mem() argument
1125 err = ddi_dma_alloc_handle(sc->sc_dip, dma_attr_p, in iwh_alloc_dma_mem()
1192 iwh_alloc_fw_dma(iwh_sc_t *sc) in iwh_alloc_fw_dma() argument
1206 t = (char *)(sc->sc_hdr + 1); in iwh_alloc_fw_dma()
1207 err = iwh_alloc_dma_mem(sc, LE_32(sc->sc_hdr->textsz), in iwh_alloc_fw_dma()
1210 &sc->sc_dma_fw_text); in iwh_alloc_fw_dma()
1217 dma_p = &sc->sc_dma_fw_text; in iwh_alloc_fw_dma()
1224 bcopy(t, dma_p->mem_va, LE_32(sc->sc_hdr->textsz)); in iwh_alloc_fw_dma()
1229 t += LE_32(sc->sc_hdr->textsz); in iwh_alloc_fw_dma()
1230 err = iwh_alloc_dma_mem(sc, LE_32(sc->sc_hdr->datasz), in iwh_alloc_fw_dma()
1233 &sc->sc_dma_fw_data); in iwh_alloc_fw_dma()
1240 dma_p = &sc->sc_dma_fw_data; in iwh_alloc_fw_dma()
1247 bcopy(t, dma_p->mem_va, LE_32(sc->sc_hdr->datasz)); in iwh_alloc_fw_dma()
1249 err = iwh_alloc_dma_mem(sc, LE_32(sc->sc_hdr->datasz), in iwh_alloc_fw_dma()
1252 &sc->sc_dma_fw_data_bak); in iwh_alloc_fw_dma()
1259 dma_p = &sc->sc_dma_fw_data_bak; in iwh_alloc_fw_dma()
1267 bcopy(t, dma_p->mem_va, LE_32(sc->sc_hdr->datasz)); in iwh_alloc_fw_dma()
1272 t += LE_32(sc->sc_hdr->datasz); in iwh_alloc_fw_dma()
1273 err = iwh_alloc_dma_mem(sc, LE_32(sc->sc_hdr->init_textsz), in iwh_alloc_fw_dma()
1276 &sc->sc_dma_fw_init_text); in iwh_alloc_fw_dma()
1283 dma_p = &sc->sc_dma_fw_init_text; in iwh_alloc_fw_dma()
1291 bcopy(t, dma_p->mem_va, LE_32(sc->sc_hdr->init_textsz)); in iwh_alloc_fw_dma()
1296 t += LE_32(sc->sc_hdr->init_textsz); in iwh_alloc_fw_dma()
1297 err = iwh_alloc_dma_mem(sc, LE_32(sc->sc_hdr->init_datasz), in iwh_alloc_fw_dma()
1300 &sc->sc_dma_fw_init_data); in iwh_alloc_fw_dma()
1307 dma_p = &sc->sc_dma_fw_init_data; in iwh_alloc_fw_dma()
1315 bcopy(t, dma_p->mem_va, LE_32(sc->sc_hdr->init_datasz)); in iwh_alloc_fw_dma()
1317 sc->sc_boot = t + LE_32(sc->sc_hdr->init_datasz); in iwh_alloc_fw_dma()
1324 iwh_free_fw_dma(iwh_sc_t *sc) in iwh_free_fw_dma() argument
1326 iwh_free_dma_mem(&sc->sc_dma_fw_text); in iwh_free_fw_dma()
1327 iwh_free_dma_mem(&sc->sc_dma_fw_data); in iwh_free_fw_dma()
1328 iwh_free_dma_mem(&sc->sc_dma_fw_data_bak); in iwh_free_fw_dma()
1329 iwh_free_dma_mem(&sc->sc_dma_fw_init_text); in iwh_free_fw_dma()
1330 iwh_free_dma_mem(&sc->sc_dma_fw_init_data); in iwh_free_fw_dma()
1337 iwh_alloc_shared(iwh_sc_t *sc) in iwh_alloc_shared() argument
1347 err = iwh_alloc_dma_mem(sc, sizeof (iwh_shared_t), in iwh_alloc_shared()
1350 &sc->sc_dma_sh); in iwh_alloc_shared()
1355 sc->sc_shared = (iwh_shared_t *)sc->sc_dma_sh.mem_va; in iwh_alloc_shared()
1358 dma_p = &sc->sc_dma_sh; in iwh_alloc_shared()
1368 iwh_free_shared(sc); in iwh_alloc_shared()
1373 iwh_free_shared(iwh_sc_t *sc) in iwh_free_shared() argument
1375 iwh_free_dma_mem(&sc->sc_dma_sh); in iwh_free_shared()
1382 iwh_alloc_kw(iwh_sc_t *sc) in iwh_alloc_kw() argument
1392 err = iwh_alloc_dma_mem(sc, IWH_KW_SIZE, in iwh_alloc_kw()
1395 &sc->sc_dma_kw); in iwh_alloc_kw()
1401 dma_p = &sc->sc_dma_kw; in iwh_alloc_kw()
1411 iwh_free_kw(sc); in iwh_alloc_kw()
1416 iwh_free_kw(iwh_sc_t *sc) in iwh_free_kw() argument
1418 iwh_free_dma_mem(&sc->sc_dma_kw); in iwh_free_kw()
1425 iwh_alloc_rx_ring(iwh_sc_t *sc) in iwh_alloc_rx_ring() argument
1434 ring = &sc->sc_rxq; in iwh_alloc_rx_ring()
1440 err = iwh_alloc_dma_mem(sc, RX_QUEUE_SIZE * sizeof (uint32_t), in iwh_alloc_rx_ring()
1465 err = iwh_alloc_dma_mem(sc, sc->sc_dmabuf_sz, in iwh_alloc_rx_ring()
1497 iwh_free_rx_ring(sc); in iwh_alloc_rx_ring()
1505 iwh_reset_rx_ring(iwh_sc_t *sc) in iwh_reset_rx_ring() argument
1509 iwh_mac_access_enter(sc); in iwh_reset_rx_ring()
1510 IWH_WRITE(sc, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); in iwh_reset_rx_ring()
1512 if (IWH_READ(sc, FH_MEM_RSSR_RX_STATUS_REG) & (1 << 24)) { in iwh_reset_rx_ring()
1523 iwh_mac_access_exit(sc); in iwh_reset_rx_ring()
1525 sc->sc_rxq.cur = 0; in iwh_reset_rx_ring()
1529 iwh_free_rx_ring(iwh_sc_t *sc) in iwh_free_rx_ring() argument
1534 if (sc->sc_rxq.data[i].dma_data.dma_hdl) { in iwh_free_rx_ring()
1535 IWH_DMA_SYNC(sc->sc_rxq.data[i].dma_data, in iwh_free_rx_ring()
1539 iwh_free_dma_mem(&sc->sc_rxq.data[i].dma_data); in iwh_free_rx_ring()
1542 if (sc->sc_rxq.dma_desc.dma_hdl) { in iwh_free_rx_ring()
1543 IWH_DMA_SYNC(sc->sc_rxq.dma_desc, DDI_DMA_SYNC_FORDEV); in iwh_free_rx_ring()
1546 iwh_free_dma_mem(&sc->sc_rxq.dma_desc); in iwh_free_rx_ring()
1553 iwh_alloc_tx_ring(iwh_sc_t *sc, iwh_tx_ring_t *ring, in iwh_alloc_tx_ring() argument
1576 err = iwh_alloc_dma_mem(sc, in iwh_alloc_tx_ring()
1602 err = iwh_alloc_dma_mem(sc, in iwh_alloc_tx_ring()
1639 err = iwh_alloc_dma_mem(sc, sc->sc_dmabuf_sz, in iwh_alloc_tx_ring()
1678 iwh_reset_tx_ring(iwh_sc_t *sc, iwh_tx_ring_t *ring) in iwh_reset_tx_ring() argument
1683 iwh_mac_access_enter(sc); in iwh_reset_tx_ring()
1685 IWH_WRITE(sc, IWH_FH_TCSR_CHNL_TX_CONFIG_REG(ring->qid), 0); in iwh_reset_tx_ring()
1687 if (IWH_READ(sc, IWH_FH_TSSR_TX_STATUS_REG) & in iwh_reset_tx_ring()
1702 iwh_mac_access_exit(sc); in iwh_reset_tx_ring()
1707 if (!(sc->sc_flags & IWH_F_QUIESCED)) { in iwh_reset_tx_ring()
1750 iwh_ring_init(iwh_sc_t *sc) in iwh_ring_init() argument
1759 err = iwh_alloc_tx_ring(sc, &sc->sc_txq[i], TFD_TX_CMD_SLOTS, in iwh_ring_init()
1769 err = iwh_alloc_tx_ring(sc, &sc->sc_txq[IWH_CMD_QUEUE_NUM], in iwh_ring_init()
1775 err = iwh_alloc_rx_ring(sc); in iwh_ring_init()
1785 iwh_ring_free(iwh_sc_t *sc) in iwh_ring_free() argument
1789 iwh_free_rx_ring(sc); in iwh_ring_free()
1791 iwh_free_tx_ring(&sc->sc_txq[i]); in iwh_ring_free()
1852 iwh_sc_t *sc; in iwh_newstate() local
1863 sc = (iwh_sc_t *)ic; in iwh_newstate()
1867 mutex_enter(&sc->sc_glock); in iwh_newstate()
1873 atomic_or_32(&sc->sc_flags, IWH_F_SCANNING); in iwh_newstate()
1874 iwh_set_led(sc, 2, 10, 2); in iwh_newstate()
1880 sc->sc_config.assoc_id = 0; in iwh_newstate()
1881 sc->sc_config.filter_flags &= in iwh_newstate()
1887 LE_16(sc->sc_config.chan), in iwh_newstate()
1888 LE_32(sc->sc_config.flags), in iwh_newstate()
1889 LE_32(sc->sc_config.filter_flags))); in iwh_newstate()
1891 err = iwh_cmd(sc, REPLY_RXON, &sc->sc_config, in iwh_newstate()
1896 atomic_and_32(&sc->sc_flags, ~IWH_F_SCANNING); in iwh_newstate()
1897 mutex_exit(&sc->sc_glock); in iwh_newstate()
1907 err = iwh_cmd(sc, REPLY_ADD_STA, &node, in iwh_newstate()
1912 atomic_and_32(&sc->sc_flags, ~IWH_F_SCANNING); in iwh_newstate()
1913 mutex_exit(&sc->sc_glock); in iwh_newstate()
1918 mutex_exit(&sc->sc_glock); in iwh_newstate()
1920 err = sc->sc_newstate(ic, nstate, arg); in iwh_newstate()
1921 mutex_enter(&sc->sc_glock); in iwh_newstate()
1922 if ((err != 0) || ((err = iwh_scan(sc)) != 0)) { in iwh_newstate()
1925 atomic_and_32(&sc->sc_flags, ~IWH_F_SCANNING); in iwh_newstate()
1928 mutex_exit(&sc->sc_glock); in iwh_newstate()
1933 sc->sc_clk = 0; in iwh_newstate()
1938 atomic_and_32(&sc->sc_flags, ~IWH_F_SCANNING); in iwh_newstate()
1944 sc->sc_config.assoc_id = 0; in iwh_newstate()
1945 sc->sc_config.filter_flags &= ~LE_32(RXON_FILTER_ASSOC_MSK); in iwh_newstate()
1952 if ((err = iwh_hw_set_before_auth(sc)) != 0) { in iwh_newstate()
1955 mutex_exit(&sc->sc_glock); in iwh_newstate()
1962 atomic_and_32(&sc->sc_flags, ~IWH_F_SCANNING); in iwh_newstate()
1969 iwh_set_led(sc, 2, 10, 10); in iwh_newstate()
1976 err = iwh_run_state_config(sc); in iwh_newstate()
1980 mutex_exit(&sc->sc_glock); in iwh_newstate()
1988 (sc->sc_ht_conf.ht_support) && in iwh_newstate()
1998 (sc->sc_ht_conf.tx_support_mcs[r/8] & in iwh_newstate()
2001 atomic_or_32(&sc->sc_flags, in iwh_newstate()
2008 atomic_or_32(&sc->sc_flags, in iwh_newstate()
2021 atomic_and_32(&sc->sc_flags, in iwh_newstate()
2029 iwh_set_led(sc, 2, 0, 1); in iwh_newstate()
2034 atomic_and_32(&sc->sc_flags, ~IWH_F_SCANNING); in iwh_newstate()
2039 iwh_set_led(sc, 2, 1, 0); in iwh_newstate()
2044 atomic_and_32(&sc->sc_flags, ~IWH_F_SCANNING); in iwh_newstate()
2049 mutex_exit(&sc->sc_glock); in iwh_newstate()
2051 return (sc->sc_newstate(ic, nstate, arg)); in iwh_newstate()
2058 iwh_mac_access_enter(iwh_sc_t *sc) in iwh_mac_access_enter() argument
2063 tmp = IWH_READ(sc, CSR_GP_CNTRL); in iwh_mac_access_enter()
2064 IWH_WRITE(sc, CSR_GP_CNTRL, in iwh_mac_access_enter()
2071 if ((IWH_READ(sc, CSR_GP_CNTRL) & in iwh_mac_access_enter()
2092 iwh_mac_access_exit(iwh_sc_t *sc) in iwh_mac_access_exit() argument
2094 uint32_t tmp = IWH_READ(sc, CSR_GP_CNTRL); in iwh_mac_access_exit()
2095 IWH_WRITE(sc, CSR_GP_CNTRL, in iwh_mac_access_exit()
2113 iwh_mem_write(iwh_sc_t *sc, uint32_t addr, uint32_t data) in iwh_mem_write() argument
2115 IWH_WRITE(sc, HBUS_TARG_MEM_WADDR, addr); in iwh_mem_write()
2116 IWH_WRITE(sc, HBUS_TARG_MEM_WDAT, data); in iwh_mem_write()
2123 iwh_reg_read(iwh_sc_t *sc, uint32_t addr) in iwh_reg_read() argument
2125 IWH_WRITE(sc, HBUS_TARG_PRPH_RADDR, addr | (3 << 24)); in iwh_reg_read()
2126 return (IWH_READ(sc, HBUS_TARG_PRPH_RDAT)); in iwh_reg_read()
2133 iwh_reg_write(iwh_sc_t *sc, uint32_t addr, uint32_t data) in iwh_reg_write() argument
2135 IWH_WRITE(sc, HBUS_TARG_PRPH_WADDR, addr | (3 << 24)); in iwh_reg_write()
2136 IWH_WRITE(sc, HBUS_TARG_PRPH_WDAT, data); in iwh_reg_write()
2148 iwh_load_init_firmware(iwh_sc_t *sc) in iwh_load_init_firmware() argument
2153 atomic_and_32(&sc->sc_flags, ~IWH_F_PUT_SEG); in iwh_load_init_firmware()
2158 err = iwh_put_seg_fw(sc, sc->sc_dma_fw_init_text.cookie.dmac_address, in iwh_load_init_firmware()
2159 RTC_INST_LOWER_BOUND, sc->sc_dma_fw_init_text.cookie.dmac_size); in iwh_load_init_firmware()
2171 while (!(sc->sc_flags & IWH_F_PUT_SEG)) { in iwh_load_init_firmware()
2172 if (cv_timedwait(&sc->sc_put_seg_cv, &sc->sc_glock, clk) < 0) { in iwh_load_init_firmware()
2177 if (!(sc->sc_flags & IWH_F_PUT_SEG)) { in iwh_load_init_firmware()
2183 atomic_and_32(&sc->sc_flags, ~IWH_F_PUT_SEG); in iwh_load_init_firmware()
2188 err = iwh_put_seg_fw(sc, sc->sc_dma_fw_init_data.cookie.dmac_address, in iwh_load_init_firmware()
2189 RTC_DATA_LOWER_BOUND, sc->sc_dma_fw_init_data.cookie.dmac_size); in iwh_load_init_firmware()
2201 while (!(sc->sc_flags & IWH_F_PUT_SEG)) { in iwh_load_init_firmware()
2202 if (cv_timedwait(&sc->sc_put_seg_cv, &sc->sc_glock, clk) < 0) { in iwh_load_init_firmware()
2207 if (!(sc->sc_flags & IWH_F_PUT_SEG)) { in iwh_load_init_firmware()
2213 atomic_and_32(&sc->sc_flags, ~IWH_F_PUT_SEG); in iwh_load_init_firmware()
2219 iwh_load_run_firmware(iwh_sc_t *sc) in iwh_load_run_firmware() argument
2224 atomic_and_32(&sc->sc_flags, ~IWH_F_PUT_SEG); in iwh_load_run_firmware()
2229 err = iwh_put_seg_fw(sc, sc->sc_dma_fw_text.cookie.dmac_address, in iwh_load_run_firmware()
2230 RTC_INST_LOWER_BOUND, sc->sc_dma_fw_text.cookie.dmac_size); in iwh_load_run_firmware()
2242 while (!(sc->sc_flags & IWH_F_PUT_SEG)) { in iwh_load_run_firmware()
2243 if (cv_timedwait(&sc->sc_put_seg_cv, &sc->sc_glock, clk) < 0) { in iwh_load_run_firmware()
2248 if (!(sc->sc_flags & IWH_F_PUT_SEG)) { in iwh_load_run_firmware()
2254 atomic_and_32(&sc->sc_flags, ~IWH_F_PUT_SEG); in iwh_load_run_firmware()
2259 err = iwh_put_seg_fw(sc, sc->sc_dma_fw_data_bak.cookie.dmac_address, in iwh_load_run_firmware()
2260 RTC_DATA_LOWER_BOUND, sc->sc_dma_fw_data.cookie.dmac_size); in iwh_load_run_firmware()
2272 while (!(sc->sc_flags & IWH_F_PUT_SEG)) { in iwh_load_run_firmware()
2273 if (cv_timedwait(&sc->sc_put_seg_cv, &sc->sc_glock, clk) < 0) { in iwh_load_run_firmware()
2278 if (!(sc->sc_flags & IWH_F_PUT_SEG)) { in iwh_load_run_firmware()
2284 atomic_and_32(&sc->sc_flags, ~IWH_F_PUT_SEG); in iwh_load_run_firmware()
2294 iwh_rx_phy_intr(iwh_sc_t *sc, iwh_rx_desc_t *desc) in iwh_rx_phy_intr() argument
2297 sc->sc_rx_phy_res.flag = 1; in iwh_rx_phy_intr()
2299 bcopy((uint8_t *)(desc + 1), sc->sc_rx_phy_res.buf, in iwh_rx_phy_intr()
2308 iwh_rx_mpdu_intr(iwh_sc_t *sc, iwh_rx_desc_t *desc) in iwh_rx_mpdu_intr() argument
2310 ieee80211com_t *ic = &sc->sc_ic; in iwh_rx_mpdu_intr()
2312 iwh_rx_ring_t *ring = &sc->sc_rxq; in iwh_rx_mpdu_intr()
2329 stat = (iwh_rx_phy_res_t *)sc->sc_rx_phy_res.buf; in iwh_rx_mpdu_intr()
2377 if ((len < 16) || (len > sc->sc_dmabuf_sz)) { in iwh_rx_mpdu_intr()
2392 sc->sc_rx_err++; in iwh_rx_mpdu_intr()
2400 sc->sc_assoc_id = *((uint16_t *)(wh + 1) + 2); in iwh_rx_mpdu_intr()
2403 sc->sc_assoc_id)); in iwh_rx_mpdu_intr()
2423 sc->sc_rx_nobuf++; in iwh_rx_mpdu_intr()
2438 iwh_tx_intr(iwh_sc_t *sc, iwh_rx_desc_t *desc) in iwh_tx_intr() argument
2440 ieee80211com_t *ic = &sc->sc_ic; in iwh_tx_intr()
2441 iwh_tx_ring_t *ring = &sc->sc_txq[desc->hdr.qid & 0x3]; in iwh_tx_intr()
2457 sc->sc_tx_retries++; in iwh_tx_intr()
2460 sc->sc_tx_retries)); in iwh_tx_intr()
2463 mutex_enter(&sc->sc_mt_lock); in iwh_tx_intr()
2464 sc->sc_tx_timer = 0; in iwh_tx_intr()
2465 mutex_exit(&sc->sc_mt_lock); in iwh_tx_intr()
2467 mutex_enter(&sc->sc_tx_lock); in iwh_tx_intr()
2474 if ((sc->sc_need_reschedule) && (ring->queued <= (ring->count >> 3))) { in iwh_tx_intr()
2475 sc->sc_need_reschedule = 0; in iwh_tx_intr()
2476 mutex_exit(&sc->sc_tx_lock); in iwh_tx_intr()
2478 mutex_enter(&sc->sc_tx_lock); in iwh_tx_intr()
2481 mutex_exit(&sc->sc_tx_lock); in iwh_tx_intr()
2488 iwh_cmd_intr(iwh_sc_t *sc, iwh_rx_desc_t *desc) in iwh_cmd_intr() argument
2494 if (sc->sc_cmd_accum > 0) { in iwh_cmd_intr()
2495 sc->sc_cmd_accum--; in iwh_cmd_intr()
2499 mutex_enter(&sc->sc_glock); in iwh_cmd_intr()
2501 sc->sc_cmd_flag = SC_CMD_FLG_DONE; in iwh_cmd_intr()
2503 cv_signal(&sc->sc_cmd_cv); in iwh_cmd_intr()
2505 mutex_exit(&sc->sc_glock); in iwh_cmd_intr()
2517 iwh_ucode_alive(iwh_sc_t *sc, iwh_rx_desc_t *desc) in iwh_ucode_alive() argument
2523 struct iwh_calib_results *res_p = &sc->sc_calib_results; in iwh_ucode_alive()
2547 bcopy(ar, &sc->sc_card_alive_init, in iwh_ucode_alive()
2553 mutex_enter(&sc->sc_glock); in iwh_ucode_alive()
2555 rv = iwh_alive_common(sc); in iwh_ucode_alive()
2559 mutex_exit(&sc->sc_glock); in iwh_ucode_alive()
2573 rv = iwh_cmd(sc, CALIBRATION_CFG_CMD, &cmd, sizeof (cmd), 1); in iwh_ucode_alive()
2577 mutex_exit(&sc->sc_glock); in iwh_ucode_alive()
2581 mutex_exit(&sc->sc_glock); in iwh_ucode_alive()
2588 bcopy(ar, &sc->sc_card_alive_run, in iwh_ucode_alive()
2591 mutex_enter(&sc->sc_glock); in iwh_ucode_alive()
2596 rv = iwh_alive_common(sc); in iwh_ucode_alive()
2600 mutex_exit(&sc->sc_glock); in iwh_ucode_alive()
2608 rv = iwh_cmd(sc, REPLY_PHY_CALIBRATION_CMD, in iwh_ucode_alive()
2614 mutex_exit(&sc->sc_glock); in iwh_ucode_alive()
2625 rv = iwh_cmd(sc, REPLY_PHY_CALIBRATION_CMD, in iwh_ucode_alive()
2631 mutex_exit(&sc->sc_glock); in iwh_ucode_alive()
2642 rv = iwh_cmd(sc, REPLY_PHY_CALIBRATION_CMD, in iwh_ucode_alive()
2649 mutex_exit(&sc->sc_glock); in iwh_ucode_alive()
2660 rv = iwh_cmd(sc, REPLY_PHY_CALIBRATION_CMD, in iwh_ucode_alive()
2667 mutex_exit(&sc->sc_glock); in iwh_ucode_alive()
2678 rv = iwh_cmd(sc, REPLY_PHY_CALIBRATION_CMD, in iwh_ucode_alive()
2685 mutex_exit(&sc->sc_glock); in iwh_ucode_alive()
2692 atomic_or_32(&sc->sc_flags, IWH_F_FW_INIT); in iwh_ucode_alive()
2693 cv_signal(&sc->sc_ucode_cv); in iwh_ucode_alive()
2695 mutex_exit(&sc->sc_glock); in iwh_ucode_alive()
2708 iwh_sc_t *sc; in iwh_rx_softintr() local
2717 sc = (iwh_sc_t *)arg; in iwh_rx_softintr()
2718 ic = &sc->sc_ic; in iwh_rx_softintr()
2724 index = (sc->sc_shared->val0) & 0xfff; in iwh_rx_softintr()
2726 while (sc->sc_rxq.cur != index) { in iwh_rx_softintr()
2727 data = &sc->sc_rxq.data[sc->sc_rxq.cur]; in iwh_rx_softintr()
2733 index, sc->sc_rxq.cur, desc->hdr.qid, desc->hdr.idx, in iwh_rx_softintr()
2742 iwh_cmd_intr(sc, desc); in iwh_rx_softintr()
2747 iwh_rx_phy_intr(sc, desc); in iwh_rx_softintr()
2751 iwh_rx_mpdu_intr(sc, desc); in iwh_rx_softintr()
2755 iwh_tx_intr(sc, desc); in iwh_rx_softintr()
2759 iwh_ucode_alive(sc, desc); in iwh_rx_softintr()
2779 sc->sc_ostate = sc->sc_ic.ic_state; in iwh_rx_softintr()
2780 ieee80211_new_state(&sc->sc_ic, in iwh_rx_softintr()
2782 atomic_or_32(&sc->sc_flags, in iwh_rx_softintr()
2813 sc->sc_scan_pending++; in iwh_rx_softintr()
2826 iwh_save_calib_result(sc, desc); in iwh_rx_softintr()
2830 mutex_enter(&sc->sc_glock); in iwh_rx_softintr()
2831 atomic_or_32(&sc->sc_flags, IWH_F_FW_INIT); in iwh_rx_softintr()
2832 cv_signal(&sc->sc_ucode_cv); in iwh_rx_softintr()
2833 mutex_exit(&sc->sc_glock); in iwh_rx_softintr()
2841 sc->sc_rxq.cur = (sc->sc_rxq.cur + 1) % RX_QUEUE_SIZE; in iwh_rx_softintr()
2849 IWH_WRITE(sc, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, index & (~7)); in iwh_rx_softintr()
2854 IWH_WRITE(sc, CSR_INT_MASK, CSR_INI_SET_MASK); in iwh_rx_softintr()
2866 iwh_sc_t *sc; in iwh_intr() local
2872 sc = (iwh_sc_t *)arg; in iwh_intr()
2874 r = IWH_READ(sc, CSR_INT); in iwh_intr()
2882 rfh = IWH_READ(sc, CSR_FH_INT_STATUS); in iwh_intr()
2890 IWH_WRITE(sc, CSR_INT_MASK, 0); in iwh_intr()
2895 IWH_WRITE(sc, CSR_INT, r); in iwh_intr()
2896 IWH_WRITE(sc, CSR_FH_INT_STATUS, rfh); in iwh_intr()
2901 iwh_stop(sc); in iwh_intr()
2902 sc->sc_ostate = sc->sc_ic.ic_state; in iwh_intr()
2907 if (!IWH_CHK_FAST_RECOVER(sc)) { in iwh_intr()
2908 ieee80211_new_state(&sc->sc_ic, IEEE80211_S_INIT, -1); in iwh_intr()
2911 atomic_or_32(&sc->sc_flags, IWH_F_HW_ERR_RECOVER); in iwh_intr()
2916 uint32_t tmp = IWH_READ(sc, CSR_GP_CNTRL); in iwh_intr()
2924 (void) ddi_intr_trigger_softint(sc->sc_soft_hdl, NULL); in iwh_intr()
2929 mutex_enter(&sc->sc_glock); in iwh_intr()
2930 atomic_or_32(&sc->sc_flags, IWH_F_PUT_SEG); in iwh_intr()
2931 cv_signal(&sc->sc_put_seg_cv); in iwh_intr()
2932 mutex_exit(&sc->sc_glock); in iwh_intr()
2945 IWH_WRITE(sc, CSR_INT_MASK, CSR_INI_SET_MASK); in iwh_intr()
3024 iwh_sc_t *sc; in iwh_m_tx() local
3031 sc = (iwh_sc_t *)arg; in iwh_m_tx()
3032 ic = &sc->sc_ic; in iwh_m_tx()
3034 if (sc->sc_flags & IWH_F_SUSPEND) { in iwh_m_tx()
3044 if ((sc->sc_flags & IWH_F_HW_ERR_RECOVER) && in iwh_m_tx()
3045 IWH_CHK_FAST_RECOVER(sc)) { in iwh_m_tx()
3070 iwh_sc_t *sc; in iwh_send() local
3092 sc = (iwh_sc_t *)ic; in iwh_send()
3094 if (sc->sc_flags & IWH_F_SUSPEND) { in iwh_send()
3117 sc->sc_tx_err++; in iwh_send()
3140 sc->sc_tx_err++; in iwh_send()
3160 mutex_enter(&sc->sc_tx_lock); in iwh_send()
3161 ring = &sc->sc_txq[txq_id]; in iwh_send()
3175 sc->sc_need_reschedule = 1; in iwh_send()
3176 mutex_exit(&sc->sc_tx_lock); in iwh_send()
3182 sc->sc_tx_nobuf++; in iwh_send()
3189 mutex_exit(&sc->sc_tx_lock); in iwh_send()
3199 mutex_enter(&sc->sc_tx_lock); in iwh_send()
3201 if ((sc->sc_need_reschedule) && (ring->queued <= 0)) { in iwh_send()
3202 sc->sc_need_reschedule = 0; in iwh_send()
3203 mutex_exit(&sc->sc_tx_lock); in iwh_send()
3205 mutex_enter(&sc->sc_tx_lock); in iwh_send()
3207 mutex_exit(&sc->sc_tx_lock); in iwh_send()
3251 sc->sc_tx_err++; in iwh_send()
3253 mutex_enter(&sc->sc_tx_lock); in iwh_send()
3255 if ((sc->sc_need_reschedule) && (ring->queued <= 0)) { in iwh_send()
3256 sc->sc_need_reschedule = 0; in iwh_send()
3257 mutex_exit(&sc->sc_tx_lock); in iwh_send()
3259 mutex_enter(&sc->sc_tx_lock); in iwh_send()
3261 mutex_exit(&sc->sc_tx_lock); in iwh_send()
3336 (sc->sc_ht_conf.ht_support)) { in iwh_send()
3378 (sc->sc_ht_conf.ht_support) && in iwh_send()
3427 mutex_enter(&sc->sc_tx_lock); in iwh_send()
3450 sc->sc_shared->queues_byte_cnt_tbls[ring->qid]. in iwh_send()
3454 sc->sc_shared->queues_byte_cnt_tbls[ring->qid]. in iwh_send()
3463 IWH_WRITE(sc, HBUS_TARG_WRPTR, ring->qid << 8 | ring->desc_cur); in iwh_send()
3465 mutex_exit(&sc->sc_tx_lock); in iwh_send()
3476 mutex_enter(&sc->sc_mt_lock); in iwh_send()
3477 if (0 == sc->sc_tx_timer) { in iwh_send()
3478 sc->sc_tx_timer = 4; in iwh_send()
3480 mutex_exit(&sc->sc_mt_lock); in iwh_send()
3492 iwh_sc_t *sc; in iwh_m_ioctl() local
3499 sc = (iwh_sc_t *)arg; in iwh_m_ioctl()
3500 ic = &sc->sc_ic; in iwh_m_ioctl()
3513 if (sc->sc_flags & IWH_F_RUNNING) { in iwh_m_ioctl()
3514 iwh_m_stop(sc); in iwh_m_ioctl()
3515 (void) iwh_m_start(sc); in iwh_m_ioctl()
3530 iwh_sc_t *sc; in iwh_m_getprop() local
3536 sc = (iwh_sc_t *)arg; in iwh_m_getprop()
3538 err = ieee80211_getprop(&sc->sc_ic, pr_name, wldp_pr_num, in iwh_m_getprop()
3548 iwh_sc_t *sc = (iwh_sc_t *)arg; in iwh_m_propinfo() local
3550 ieee80211_propinfo(&sc->sc_ic, pr_name, wldp_pr_num, mph); in iwh_m_propinfo()
3557 iwh_sc_t *sc; in iwh_m_setprop() local
3564 sc = (iwh_sc_t *)arg; in iwh_m_setprop()
3565 ic = &sc->sc_ic; in iwh_m_setprop()
3572 if (sc->sc_flags & IWH_F_RUNNING) { in iwh_m_setprop()
3573 iwh_m_stop(sc); in iwh_m_setprop()
3574 (void) iwh_m_start(sc); in iwh_m_setprop()
3590 iwh_sc_t *sc; in iwh_m_stat() local
3597 sc = (iwh_sc_t *)arg; in iwh_m_stat()
3598 ic = &sc->sc_ic; in iwh_m_stat()
3600 mutex_enter(&sc->sc_glock); in iwh_m_stat()
3611 *val = sc->sc_tx_nobuf; in iwh_m_stat()
3615 *val = sc->sc_rx_nobuf; in iwh_m_stat()
3619 *val = sc->sc_rx_err; in iwh_m_stat()
3640 *val = sc->sc_tx_err; in iwh_m_stat()
3644 *val = sc->sc_tx_retries; in iwh_m_stat()
3657 mutex_exit(&sc->sc_glock); in iwh_m_stat()
3661 mutex_exit(&sc->sc_glock); in iwh_m_stat()
3665 mutex_exit(&sc->sc_glock); in iwh_m_stat()
3676 iwh_sc_t *sc; in iwh_m_start() local
3683 sc = (iwh_sc_t *)arg; in iwh_m_start()
3684 ic = &sc->sc_ic; in iwh_m_start()
3686 err = iwh_init(sc); in iwh_m_start()
3693 atomic_or_32(&sc->sc_flags, IWH_F_HW_ERR_RECOVER); in iwh_m_start()
3699 atomic_or_32(&sc->sc_flags, IWH_F_RUNNING); in iwh_m_start()
3710 iwh_sc_t *sc; in iwh_m_stop() local
3716 sc = (iwh_sc_t *)arg; in iwh_m_stop()
3717 ic = &sc->sc_ic; in iwh_m_stop()
3719 iwh_stop(sc); in iwh_m_stop()
3724 iwh_release_calib_buffer(sc); in iwh_m_stop()
3728 atomic_and_32(&sc->sc_flags, ~IWH_F_HW_ERR_RECOVER); in iwh_m_stop()
3729 atomic_and_32(&sc->sc_flags, ~IWH_F_RATE_AUTO_CTL); in iwh_m_stop()
3731 atomic_and_32(&sc->sc_flags, ~IWH_F_RUNNING); in iwh_m_stop()
3732 atomic_and_32(&sc->sc_flags, ~IWH_F_SCANNING); in iwh_m_stop()
3741 iwh_sc_t *sc; in iwh_m_unicst() local
3748 sc = (iwh_sc_t *)arg; in iwh_m_unicst()
3749 ic = &sc->sc_ic; in iwh_m_unicst()
3753 mutex_enter(&sc->sc_glock); in iwh_m_unicst()
3754 err = iwh_config(sc); in iwh_m_unicst()
3755 mutex_exit(&sc->sc_glock); in iwh_m_unicst()
3785 iwh_thread(iwh_sc_t *sc) in iwh_thread() argument
3787 ieee80211com_t *ic = &sc->sc_ic; in iwh_thread()
3795 while (sc->sc_mf_thread_switch) { in iwh_thread()
3796 tmp = IWH_READ(sc, CSR_GP_CNTRL); in iwh_thread()
3798 atomic_and_32(&sc->sc_flags, ~IWH_F_RADIO_OFF); in iwh_thread()
3800 atomic_or_32(&sc->sc_flags, IWH_F_RADIO_OFF); in iwh_thread()
3806 if (sc->sc_flags & IWH_F_RADIO_OFF) { in iwh_thread()
3815 (sc->sc_flags & IWH_F_HW_ERR_RECOVER)) { in iwh_thread()
3820 iwh_stop(sc); in iwh_thread()
3822 if (IWH_CHK_FAST_RECOVER(sc)) { in iwh_thread()
3826 bcopy(&sc->sc_config, &sc->sc_config_save, in iwh_thread()
3827 sizeof (sc->sc_config)); in iwh_thread()
3833 err = iwh_init(sc); in iwh_thread()
3843 atomic_or_32(&sc->sc_flags, IWH_F_RUNNING); in iwh_thread()
3847 if (!IWH_CHK_FAST_RECOVER(sc) || in iwh_thread()
3848 iwh_fast_recover(sc) != IWH_SUCCESS) { in iwh_thread()
3849 atomic_and_32(&sc->sc_flags, in iwh_thread()
3853 if (sc->sc_ostate != IEEE80211_S_INIT) { in iwh_thread()
3861 (sc->sc_flags & IWH_F_SCANNING) && sc->sc_scan_pending) { in iwh_thread()
3865 sc->sc_scan_pending--; in iwh_thread()
3874 (sc->sc_flags & IWH_F_RATE_AUTO_CTL)) { in iwh_thread()
3876 if (clk > sc->sc_clk + drv_usectohz(1000000)) { in iwh_thread()
3877 iwh_amrr_timeout(sc); in iwh_thread()
3890 mutex_enter(&sc->sc_mt_lock); in iwh_thread()
3891 if (sc->sc_tx_timer) { in iwh_thread()
3894 sc->sc_tx_timer--; in iwh_thread()
3895 if (0 == sc->sc_tx_timer) { in iwh_thread()
3896 atomic_or_32(&sc->sc_flags, in iwh_thread()
3898 sc->sc_ostate = IEEE80211_S_RUN; in iwh_thread()
3906 mutex_exit(&sc->sc_mt_lock); in iwh_thread()
3909 mutex_enter(&sc->sc_mt_lock); in iwh_thread()
3910 sc->sc_mf_thread = NULL; in iwh_thread()
3911 cv_signal(&sc->sc_mt_cv); in iwh_thread()
3912 mutex_exit(&sc->sc_mt_lock); in iwh_thread()
3919 iwh_cmd(iwh_sc_t *sc, int code, const void *buf, int size, int async) in iwh_cmd() argument
3921 iwh_tx_ring_t *ring = &sc->sc_txq[IWH_CMD_QUEUE_NUM]; in iwh_cmd()
3926 ASSERT(mutex_owned(&sc->sc_glock)); in iwh_cmd()
3946 sc->sc_cmd_accum++; in iwh_cmd()
3952 sc->sc_shared->queues_byte_cnt_tbls[ring->qid]. in iwh_cmd()
3955 sc->sc_shared->queues_byte_cnt_tbls[ring->qid]. in iwh_cmd()
3959 IWH_WRITE(sc, HBUS_TARG_WRPTR, ring->qid << 8 | ring->cur); in iwh_cmd()
3967 while (sc->sc_cmd_flag != SC_CMD_FLG_DONE) { in iwh_cmd()
3968 if (cv_timedwait(&sc->sc_cmd_cv, in iwh_cmd()
3969 &sc->sc_glock, clk) < 0) { in iwh_cmd()
3974 if (SC_CMD_FLG_DONE == sc->sc_cmd_flag) { in iwh_cmd()
3975 sc->sc_cmd_flag = SC_CMD_FLG_NONE; in iwh_cmd()
3978 sc->sc_cmd_flag = SC_CMD_FLG_NONE; in iwh_cmd()
3988 iwh_set_led(iwh_sc_t *sc, uint8_t id, uint8_t off, uint8_t on) in iwh_set_led() argument
3997 (void) iwh_cmd(sc, REPLY_LEDS_CMD, &led, sizeof (led), 1); in iwh_set_led()
4004 iwh_hw_set_before_auth(iwh_sc_t *sc) in iwh_hw_set_before_auth() argument
4006 ieee80211com_t *ic = &sc->sc_ic; in iwh_hw_set_before_auth()
4014 IEEE80211_ADDR_COPY(sc->sc_config.bssid, in->in_bssid); in iwh_hw_set_before_auth()
4015 sc->sc_config.chan = LE_16(ieee80211_chan2ieee(ic, in->in_chan)); in iwh_hw_set_before_auth()
4019 sc->sc_config.ofdm_ht_triple_stream_basic_rates = 0; in iwh_hw_set_before_auth()
4020 sc->sc_config.ofdm_ht_dual_stream_basic_rates = 0; in iwh_hw_set_before_auth()
4021 sc->sc_config.ofdm_ht_single_stream_basic_rates = 0; in iwh_hw_set_before_auth()
4024 sc->sc_config.cck_basic_rates = 0x03; in iwh_hw_set_before_auth()
4025 sc->sc_config.ofdm_basic_rates = 0; in iwh_hw_set_before_auth()
4028 sc->sc_config.cck_basic_rates = 0; in iwh_hw_set_before_auth()
4029 sc->sc_config.ofdm_basic_rates = 0x15; in iwh_hw_set_before_auth()
4031 sc->sc_config.cck_basic_rates = 0x0f; in iwh_hw_set_before_auth()
4032 sc->sc_config.ofdm_basic_rates = 0xff; in iwh_hw_set_before_auth()
4036 sc->sc_config.flags &= ~LE_32(RXON_FLG_SHORT_PREAMBLE_MSK | in iwh_hw_set_before_auth()
4040 sc->sc_config.flags |= LE_32(RXON_FLG_SHORT_SLOT_MSK); in iwh_hw_set_before_auth()
4042 sc->sc_config.flags &= LE_32(~RXON_FLG_SHORT_SLOT_MSK); in iwh_hw_set_before_auth()
4046 sc->sc_config.flags |= LE_32(RXON_FLG_SHORT_PREAMBLE_MSK); in iwh_hw_set_before_auth()
4048 sc->sc_config.flags &= LE_32(~RXON_FLG_SHORT_PREAMBLE_MSK); in iwh_hw_set_before_auth()
4055 LE_16(sc->sc_config.chan), LE_32(sc->sc_config.flags), in iwh_hw_set_before_auth()
4056 LE_32(sc->sc_config.filter_flags), in iwh_hw_set_before_auth()
4057 sc->sc_config.cck_basic_rates, sc->sc_config.ofdm_basic_rates, in iwh_hw_set_before_auth()
4058 sc->sc_config.bssid[0], sc->sc_config.bssid[1], in iwh_hw_set_before_auth()
4059 sc->sc_config.bssid[2], sc->sc_config.bssid[3], in iwh_hw_set_before_auth()
4060 sc->sc_config.bssid[4], sc->sc_config.bssid[5])); in iwh_hw_set_before_auth()
4062 err = iwh_cmd(sc, REPLY_RXON, &sc->sc_config, in iwh_hw_set_before_auth()
4066 "failed to config chan%d\n", sc->sc_config.chan); in iwh_hw_set_before_auth()
4070 if ((sc->sc_dev_id != 0x423c) && in iwh_hw_set_before_auth()
4071 (sc->sc_dev_id != 0x423d)) { in iwh_hw_set_before_auth()
4072 err = iwh_tx_power_table(sc, 1); in iwh_hw_set_before_auth()
4081 err = iwh_add_ap_sta(sc); in iwh_hw_set_before_auth()
4086 if ((sc->sc_dev_id != 0x423c) && in iwh_hw_set_before_auth()
4087 (sc->sc_dev_id != 0x423d)) { in iwh_hw_set_before_auth()
4091 err = iwh_ap_lq(sc); in iwh_hw_set_before_auth()
4104 iwh_scan(iwh_sc_t *sc) in iwh_scan() argument
4106 ieee80211com_t *ic = &sc->sc_ic; in iwh_scan()
4107 iwh_tx_ring_t *ring = &sc->sc_txq[IWH_CMD_QUEUE_NUM]; in iwh_scan()
4270 sc->sc_shared->queues_byte_cnt_tbls[ring->qid] in iwh_scan()
4273 sc->sc_shared->queues_byte_cnt_tbls[ring->qid]. in iwh_scan()
4281 IWH_WRITE(sc, HBUS_TARG_WRPTR, ring->qid << 8 | ring->cur); in iwh_scan()
4290 iwh_config(iwh_sc_t *sc) in iwh_config() argument
4292 ieee80211com_t *ic = &sc->sc_ic; in iwh_config()
4307 err = iwh_cmd(sc, POWER_TABLE_CMD, &powertable, in iwh_config()
4322 err = iwh_cmd(sc, REPLY_BT_CONFIG, &bt, in iwh_config()
4333 (void) memset(&sc->sc_config, 0, sizeof (iwh_rxon_cmd_t)); in iwh_config()
4334 IEEE80211_ADDR_COPY(sc->sc_config.node_addr, ic->ic_macaddr); in iwh_config()
4335 IEEE80211_ADDR_COPY(sc->sc_config.wlap_bssid, ic->ic_macaddr); in iwh_config()
4336 sc->sc_config.chan = LE_16(ieee80211_chan2ieee(ic, ic->ic_curchan)); in iwh_config()
4337 sc->sc_config.flags = LE_32(RXON_FLG_BAND_24G_MSK); in iwh_config()
4338 sc->sc_config.flags &= LE_32(~(RXON_FLG_CHANNEL_MODE_MIXED_MSK | in iwh_config()
4343 sc->sc_config.dev_type = RXON_DEV_TYPE_ESS; in iwh_config()
4344 sc->sc_config.filter_flags |= LE_32(RXON_FILTER_ACCEPT_GRP_MSK | in iwh_config()
4351 sc->sc_config.dev_type = RXON_DEV_TYPE_IBSS; in iwh_config()
4353 sc->sc_config.flags |= LE_32(RXON_FLG_SHORT_PREAMBLE_MSK); in iwh_config()
4354 sc->sc_config.filter_flags = LE_32(RXON_FILTER_ACCEPT_GRP_MSK | in iwh_config()
4360 sc->sc_config.dev_type = RXON_DEV_TYPE_AP; in iwh_config()
4364 sc->sc_config.dev_type = RXON_DEV_TYPE_SNIFFER; in iwh_config()
4365 sc->sc_config.filter_flags |= LE_32(RXON_FILTER_ACCEPT_GRP_MSK | in iwh_config()
4373 sc->sc_config.cck_basic_rates = 0x0f; in iwh_config()
4378 sc->sc_config.ofdm_basic_rates = 0xff; in iwh_config()
4383 switch (sc->sc_ht_conf.rx_stream_count) { in iwh_config()
4385 sc->sc_config.ofdm_ht_triple_stream_basic_rates = 0xff; in iwh_config()
4386 sc->sc_config.ofdm_ht_dual_stream_basic_rates = 0xff; in iwh_config()
4387 sc->sc_config.ofdm_ht_single_stream_basic_rates = 0xff; in iwh_config()
4390 sc->sc_config.ofdm_ht_dual_stream_basic_rates = 0xff; in iwh_config()
4391 sc->sc_config.ofdm_ht_single_stream_basic_rates = 0xff; in iwh_config()
4394 sc->sc_config.ofdm_ht_single_stream_basic_rates = 0xff; in iwh_config()
4399 sc->sc_ht_conf.rx_stream_count); in iwh_config()
4406 iwh_config_rxon_chain(sc); in iwh_config()
4408 err = iwh_cmd(sc, REPLY_RXON, &sc->sc_config, in iwh_config()
4423 err = iwh_cmd(sc, REPLY_REMOVE_STA, &rm_sta, sizeof (iwh_rem_sta_t), 0); in iwh_config()
4430 if ((sc->sc_dev_id != 0x423c) && in iwh_config()
4431 (sc->sc_dev_id != 0x423d)) { in iwh_config()
4435 err = iwh_tx_power_table(sc, 0); in iwh_config()
4450 err = iwh_cmd(sc, REPLY_ADD_STA, &node, sizeof (node), 0); in iwh_config()
4457 if ((sc->sc_dev_id != 0x423c) && in iwh_config()
4458 (sc->sc_dev_id != 0x423d)) { in iwh_config()
4476 err = iwh_cmd(sc, REPLY_TX_LINK_QUALITY_CMD, &link_quality, in iwh_config()
4499 iwh_sc_t *sc; in iwh_quiesce() local
4501 sc = ddi_get_soft_state(iwh_soft_state_p, ddi_get_instance(dip)); in iwh_quiesce()
4502 if (sc == NULL) { in iwh_quiesce()
4517 atomic_or_32(&sc->sc_flags, IWH_F_QUIESCED); in iwh_quiesce()
4522 iwh_stop(sc); in iwh_quiesce()
4528 iwh_stop_master(iwh_sc_t *sc) in iwh_stop_master() argument
4533 tmp = IWH_READ(sc, CSR_RESET); in iwh_stop_master()
4534 IWH_WRITE(sc, CSR_RESET, tmp | CSR_RESET_REG_FLAG_STOP_MASTER); in iwh_stop_master()
4536 tmp = IWH_READ(sc, CSR_GP_CNTRL); in iwh_stop_master()
4543 if (IWH_READ(sc, CSR_RESET) & in iwh_stop_master()
4559 iwh_power_up(iwh_sc_t *sc) in iwh_power_up() argument
4563 iwh_mac_access_enter(sc); in iwh_power_up()
4564 tmp = iwh_reg_read(sc, ALM_APMG_PS_CTL); in iwh_power_up()
4567 iwh_reg_write(sc, ALM_APMG_PS_CTL, tmp); in iwh_power_up()
4568 iwh_mac_access_exit(sc); in iwh_power_up()
4578 iwh_preinit(iwh_sc_t *sc) in iwh_preinit() argument
4588 IWH_WRITE(sc, CSR_INT, 0xffffffff); in iwh_preinit()
4590 tmp = IWH_READ(sc, CSR_GIO_CHICKEN_BITS); in iwh_preinit()
4591 IWH_WRITE(sc, CSR_GIO_CHICKEN_BITS, in iwh_preinit()
4594 tmp = IWH_READ(sc, CSR_ANA_PLL_CFG); in iwh_preinit()
4595 IWH_WRITE(sc, CSR_ANA_PLL_CFG, tmp | IWH_CSR_ANA_PLL_CFG); in iwh_preinit()
4597 tmp = IWH_READ(sc, CSR_GP_CNTRL); in iwh_preinit()
4598 IWH_WRITE(sc, CSR_GP_CNTRL, tmp | CSR_GP_CNTRL_REG_FLAG_INIT_DONE); in iwh_preinit()
4604 if (IWH_READ(sc, CSR_GP_CNTRL) & in iwh_preinit()
4615 iwh_mac_access_enter(sc); in iwh_preinit()
4617 iwh_reg_write(sc, ALM_APMG_CLK_EN, APMG_CLK_REG_VAL_DMA_CLK_RQT); in iwh_preinit()
4620 tmp = iwh_reg_read(sc, ALM_APMG_PCIDEV_STT); in iwh_preinit()
4621 iwh_reg_write(sc, ALM_APMG_PCIDEV_STT, tmp | in iwh_preinit()
4623 iwh_mac_access_exit(sc); in iwh_preinit()
4625 radio_cfg = IWH_READ_EEP_SHORT(sc, EEP_SP_RADIO_CONFIGURATION); in iwh_preinit()
4627 tmp = IWH_READ(sc, CSR_HW_IF_CONFIG_REG); in iwh_preinit()
4628 IWH_WRITE(sc, CSR_HW_IF_CONFIG_REG, in iwh_preinit()
4639 IWH_WRITE(sc, CSR_INT_COALESCING, 512 / 32); in iwh_preinit()
4641 (void) iwh_power_up(sc); in iwh_preinit()
4643 if ((sc->sc_rev & 0x80) == 0x80 && (sc->sc_rev & 0x7f) < 8) { in iwh_preinit()
4644 tmp = ddi_get32(sc->sc_cfg_handle, in iwh_preinit()
4645 (uint32_t *)(sc->sc_cfg_base + 0xe8)); in iwh_preinit()
4646 ddi_put32(sc->sc_cfg_handle, in iwh_preinit()
4647 (uint32_t *)(sc->sc_cfg_base + 0xe8), in iwh_preinit()
4651 vlink = ddi_get8(sc->sc_cfg_handle, in iwh_preinit()
4652 (uint8_t *)(sc->sc_cfg_base + 0xf0)); in iwh_preinit()
4653 ddi_put8(sc->sc_cfg_handle, (uint8_t *)(sc->sc_cfg_base + 0xf0), in iwh_preinit()
4656 tmp = IWH_READ(sc, CSR_HW_IF_CONFIG_REG); in iwh_preinit()
4659 IWH_WRITE(sc, CSR_SW_VER, tmp); in iwh_preinit()
4664 iwh_mac_access_enter(sc); in iwh_preinit()
4665 tmp = iwh_reg_read(sc, ALM_APMG_PS_CTL); in iwh_preinit()
4667 iwh_reg_write(sc, ALM_APMG_PS_CTL, tmp); in iwh_preinit()
4670 tmp = iwh_reg_read(sc, ALM_APMG_PS_CTL); in iwh_preinit()
4672 iwh_reg_write(sc, ALM_APMG_PS_CTL, tmp); in iwh_preinit()
4673 iwh_mac_access_exit(sc); in iwh_preinit()
4682 iwh_eep_sem_down(iwh_sc_t *sc) in iwh_eep_sem_down() argument
4688 tmp = IWH_READ(sc, CSR_HW_IF_CONFIG_REG); in iwh_eep_sem_down()
4689 IWH_WRITE(sc, CSR_HW_IF_CONFIG_REG, in iwh_eep_sem_down()
4693 if (IWH_READ(sc, CSR_HW_IF_CONFIG_REG) & in iwh_eep_sem_down()
4708 iwh_eep_sem_up(iwh_sc_t *sc) in iwh_eep_sem_up() argument
4712 tmp = IWH_READ(sc, CSR_HW_IF_CONFIG_REG); in iwh_eep_sem_up()
4713 IWH_WRITE(sc, CSR_HW_IF_CONFIG_REG, in iwh_eep_sem_up()
4721 iwh_eep_load(iwh_sc_t *sc) in iwh_eep_load() argument
4725 uint16_t addr, eep_sz = sizeof (sc->sc_eep_map); in iwh_eep_load()
4726 uint16_t *eep_p = (uint16_t *)&sc->sc_eep_map; in iwh_eep_load()
4731 eep_gp = IWH_READ(sc, CSR_EEPROM_GP); in iwh_eep_load()
4739 rr = iwh_eep_sem_down(sc); in iwh_eep_load()
4747 IWH_WRITE(sc, CSR_EEPROM_REG, addr<<1); in iwh_eep_load()
4748 tmp = IWH_READ(sc, CSR_EEPROM_REG); in iwh_eep_load()
4749 IWH_WRITE(sc, CSR_EEPROM_REG, tmp & ~(0x2)); in iwh_eep_load()
4752 rv = IWH_READ(sc, CSR_EEPROM_REG); in iwh_eep_load()
4762 iwh_eep_sem_up(sc); in iwh_eep_load()
4769 iwh_eep_sem_up(sc); in iwh_eep_load()
4777 iwh_get_mac_from_eep(iwh_sc_t *sc) in iwh_get_mac_from_eep() argument
4779 ieee80211com_t *ic = &sc->sc_ic; in iwh_get_mac_from_eep()
4781 IEEE80211_ADDR_COPY(ic->ic_macaddr, &sc->sc_eep_map[EEP_MAC_ADDRESS]); in iwh_get_mac_from_eep()
4793 iwh_init(iwh_sc_t *sc) in iwh_init() argument
4801 iwh_release_calib_buffer(sc); in iwh_init()
4803 mutex_enter(&sc->sc_glock); in iwh_init()
4804 atomic_and_32(&sc->sc_flags, ~IWH_F_FW_INIT); in iwh_init()
4806 err = iwh_init_common(sc); in iwh_init()
4808 mutex_exit(&sc->sc_glock); in iwh_init()
4815 bcopy(sc->sc_dma_fw_data.mem_va, in iwh_init()
4816 sc->sc_dma_fw_data_bak.mem_va, in iwh_init()
4817 sc->sc_dma_fw_data.alength); in iwh_init()
4820 err = iwh_load_init_firmware(sc); in iwh_init()
4824 mutex_exit(&sc->sc_glock); in iwh_init()
4831 IWH_WRITE(sc, CSR_RESET, 0); in iwh_init()
4834 while (!(sc->sc_flags & IWH_F_FW_INIT)) { in iwh_init()
4835 if (cv_timedwait(&sc->sc_ucode_cv, in iwh_init()
4836 &sc->sc_glock, clk) < 0) { in iwh_init()
4841 if (!(sc->sc_flags & IWH_F_FW_INIT)) { in iwh_init()
4844 mutex_exit(&sc->sc_glock); in iwh_init()
4848 mutex_exit(&sc->sc_glock); in iwh_init()
4853 iwh_stop(sc); in iwh_init()
4855 mutex_enter(&sc->sc_glock); in iwh_init()
4856 atomic_and_32(&sc->sc_flags, ~IWH_F_FW_INIT); in iwh_init()
4858 err = iwh_init_common(sc); in iwh_init()
4860 mutex_exit(&sc->sc_glock); in iwh_init()
4867 err = iwh_load_run_firmware(sc); in iwh_init()
4871 mutex_exit(&sc->sc_glock); in iwh_init()
4878 IWH_WRITE(sc, CSR_RESET, 0); in iwh_init()
4881 while (!(sc->sc_flags & IWH_F_FW_INIT)) { in iwh_init()
4882 if (cv_timedwait(&sc->sc_ucode_cv, in iwh_init()
4883 &sc->sc_glock, clk) < 0) { in iwh_init()
4888 if (!(sc->sc_flags & IWH_F_FW_INIT)) { in iwh_init()
4891 mutex_exit(&sc->sc_glock); in iwh_init()
4895 mutex_exit(&sc->sc_glock); in iwh_init()
4899 mutex_enter(&sc->sc_glock); in iwh_init()
4900 atomic_and_32(&sc->sc_flags, ~IWH_F_FW_INIT); in iwh_init()
4906 err = iwh_config(sc); in iwh_init()
4910 mutex_exit(&sc->sc_glock); in iwh_init()
4917 mutex_exit(&sc->sc_glock); in iwh_init()
4925 iwh_stop(iwh_sc_t *sc) in iwh_stop() argument
4933 if (!(sc->sc_flags & IWH_F_QUIESCED)) { in iwh_stop()
4934 mutex_enter(&sc->sc_glock); in iwh_stop()
4937 IWH_WRITE(sc, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); in iwh_stop()
4941 IWH_WRITE(sc, CSR_INT_MASK, 0); in iwh_stop()
4942 IWH_WRITE(sc, CSR_INT, CSR_INI_SET_MASK); in iwh_stop()
4943 IWH_WRITE(sc, CSR_FH_INT_STATUS, 0xffffffff); in iwh_stop()
4949 iwh_reset_tx_ring(sc, &sc->sc_txq[i]); in iwh_stop()
4955 iwh_reset_rx_ring(sc); in iwh_stop()
4957 iwh_mac_access_enter(sc); in iwh_stop()
4958 iwh_reg_write(sc, ALM_APMG_CLK_DIS, APMG_CLK_REG_VAL_DMA_CLK_RQT); in iwh_stop()
4959 iwh_mac_access_exit(sc); in iwh_stop()
4963 iwh_stop_master(sc); in iwh_stop()
4965 mutex_enter(&sc->sc_mt_lock); in iwh_stop()
4966 sc->sc_tx_timer = 0; in iwh_stop()
4967 mutex_exit(&sc->sc_mt_lock); in iwh_stop()
4969 tmp = IWH_READ(sc, CSR_RESET); in iwh_stop()
4970 IWH_WRITE(sc, CSR_RESET, tmp | CSR_RESET_REG_FLAG_SW_RESET); in iwh_stop()
4975 if (!(sc->sc_flags & IWH_F_QUIESCED)) { in iwh_stop()
4976 mutex_exit(&sc->sc_glock); in iwh_stop()
5020 iwh_amrr_timeout(iwh_sc_t *sc) in iwh_amrr_timeout() argument
5022 ieee80211com_t *ic = &sc->sc_ic; in iwh_amrr_timeout()
5033 sc->sc_clk = ddi_get_lbolt(); in iwh_amrr_timeout()
5043 iwh_sc_t *sc = (iwh_sc_t *)ic; in iwh_is_max_rate() local
5049 if (sc->sc_ht_conf.tx_support_mcs[r/8] & in iwh_is_max_rate()
5068 iwh_sc_t *sc = (iwh_sc_t *)ic; in iwh_is_min_rate() local
5074 if (sc->sc_ht_conf.tx_support_mcs[r/8] & in iwh_is_min_rate()
5093 iwh_sc_t *sc = (iwh_sc_t *)ic; in iwh_increase_rate() local
5103 (sc->sc_ht_conf.tx_support_mcs[r/8] & in iwh_increase_rate()
5124 iwh_sc_t *sc = (iwh_sc_t *)ic; in iwh_decrease_rate() local
5134 (sc->sc_ht_conf.tx_support_mcs[r/8] & in iwh_decrease_rate()
5207 iwh_eep_addr_trans(iwh_sc_t *sc, uint32_t indi_addr) in iwh_eep_addr_trans() argument
5214 return (&sc->sc_eep_map[di_addr]); in iwh_eep_addr_trans()
5219 temp = IWH_READ_EEP_SHORT(sc, EEP_LINK_GENERAL); in iwh_eep_addr_trans()
5223 temp = IWH_READ_EEP_SHORT(sc, EEP_LINK_HOST); in iwh_eep_addr_trans()
5227 temp = IWH_READ_EEP_SHORT(sc, EEP_LINK_REGULATORY); in iwh_eep_addr_trans()
5231 temp = IWH_READ_EEP_SHORT(sc, EEP_LINK_CALIBRATION); in iwh_eep_addr_trans()
5235 temp = IWH_READ_EEP_SHORT(sc, EEP_LINK_PROCESS_ADJST); in iwh_eep_addr_trans()
5239 temp = IWH_READ_EEP_SHORT(sc, EEP_LINK_OTHERS); in iwh_eep_addr_trans()
5251 return (&sc->sc_eep_map[di_addr]); in iwh_eep_addr_trans()
5258 iwh_put_seg_fw(iwh_sc_t *sc, uint32_t addr_s, uint32_t addr_d, uint32_t len) in iwh_put_seg_fw() argument
5261 iwh_mac_access_enter(sc); in iwh_put_seg_fw()
5263 IWH_WRITE(sc, IWH_FH_TCSR_CHNL_TX_CONFIG_REG(IWH_FH_SRVC_CHNL), in iwh_put_seg_fw()
5266 IWH_WRITE(sc, IWH_FH_SRVC_CHNL_SRAM_ADDR_REG(IWH_FH_SRVC_CHNL), addr_d); in iwh_put_seg_fw()
5268 IWH_WRITE(sc, IWH_FH_TFDIB_CTRL0_REG(IWH_FH_SRVC_CHNL), in iwh_put_seg_fw()
5271 IWH_WRITE(sc, IWH_FH_TFDIB_CTRL1_REG(IWH_FH_SRVC_CHNL), len); in iwh_put_seg_fw()
5273 IWH_WRITE(sc, IWH_FH_TCSR_CHNL_TX_BUF_STS_REG(IWH_FH_SRVC_CHNL), in iwh_put_seg_fw()
5278 IWH_WRITE(sc, IWH_FH_TCSR_CHNL_TX_CONFIG_REG(IWH_FH_SRVC_CHNL), in iwh_put_seg_fw()
5283 iwh_mac_access_exit(sc); in iwh_put_seg_fw()
5292 iwh_alive_common(iwh_sc_t *sc) in iwh_alive_common() argument
5303 iwh_mac_access_enter(sc); in iwh_alive_common()
5308 sc->sc_scd_base = iwh_reg_read(sc, IWH_SCD_SRAM_BASE_ADDR); in iwh_alive_common()
5310 for (base = sc->sc_scd_base + IWH_SCD_CONTEXT_DATA_OFFSET; in iwh_alive_common()
5311 base < sc->sc_scd_base + IWH_SCD_TX_STTS_BITMAP_OFFSET; in iwh_alive_common()
5313 iwh_mem_write(sc, base, 0); in iwh_alive_common()
5316 for (; base < sc->sc_scd_base + IWH_SCD_TRANSLATE_TBL_OFFSET; in iwh_alive_common()
5318 iwh_mem_write(sc, base, 0); in iwh_alive_common()
5322 iwh_mem_write(sc, base + i, 0); in iwh_alive_common()
5325 iwh_reg_write(sc, IWH_SCD_DRAM_BASE_ADDR, in iwh_alive_common()
5326 sc->sc_dma_sh.cookie.dmac_address >> 10); in iwh_alive_common()
5328 iwh_reg_write(sc, IWH_SCD_QUEUECHAIN_SEL, in iwh_alive_common()
5331 iwh_reg_write(sc, IWH_SCD_AGGR_SEL, 0); in iwh_alive_common()
5334 iwh_reg_write(sc, IWH_SCD_QUEUE_RDPTR(i), 0); in iwh_alive_common()
5335 IWH_WRITE(sc, HBUS_TARG_WRPTR, 0 | (i << 8)); in iwh_alive_common()
5336 iwh_mem_write(sc, sc->sc_scd_base + in iwh_alive_common()
5338 iwh_mem_write(sc, sc->sc_scd_base + in iwh_alive_common()
5348 iwh_reg_write(sc, IWH_SCD_INTERRUPT_MASK, (1 << IWH_NUM_QUEUES) - 1); in iwh_alive_common()
5350 iwh_reg_write(sc, (IWH_SCD_BASE + 0x10), in iwh_alive_common()
5353 IWH_WRITE(sc, HBUS_TARG_WRPTR, (IWH_CMD_QUEUE_NUM << 8)); in iwh_alive_common()
5354 iwh_reg_write(sc, IWH_SCD_QUEUE_RDPTR(IWH_CMD_QUEUE_NUM), 0); in iwh_alive_common()
5361 iwh_reg_write(sc, IWH_SCD_QUEUE_STATUS_BITS(i), in iwh_alive_common()
5368 iwh_reg_write(sc, IWH_SCD_QUEUE_STATUS_BITS(IWH_CMD_QUEUE_NUM), in iwh_alive_common()
5375 iwh_reg_write(sc, IWH_SCD_QUEUE_STATUS_BITS(i), in iwh_alive_common()
5382 iwh_mac_access_exit(sc); in iwh_alive_common()
5386 rv = iwh_cmd(sc, COEX_PRIORITY_TABLE_CMD, &w_cmd, sizeof (w_cmd), 1); in iwh_alive_common()
5393 if ((sc->sc_dev_id != 0x423c) && in iwh_alive_common()
5394 (sc->sc_dev_id != 0x423d)) { in iwh_alive_common()
5398 c_cmd.data.cap_pin1 = LE_16(sc->sc_eep_calib->xtal_calib[0]); in iwh_alive_common()
5399 c_cmd.data.cap_pin2 = LE_16(sc->sc_eep_calib->xtal_calib[1]); in iwh_alive_common()
5401 rv = iwh_cmd(sc, REPLY_PHY_CALIBRATION_CMD, in iwh_alive_common()
5424 iwh_save_calib_result(iwh_sc_t *sc, iwh_rx_desc_t *desc) in iwh_save_calib_result() argument
5426 struct iwh_calib_results *res_p = &sc->sc_calib_results; in iwh_save_calib_result()
5523 iwh_tx_power_table(iwh_sc_t *sc, int async) in iwh_tx_power_table() argument
5531 txpower.channel = (uint8_t)LE_16(sc->sc_config.chan); in iwh_tx_power_table()
5553 err = iwh_cmd(sc, REPLY_TX_PWR_TABLE_CMD, &txpower, in iwh_tx_power_table()
5565 iwh_release_calib_buffer(iwh_sc_t *sc) in iwh_release_calib_buffer() argument
5567 if (sc->sc_calib_results.lo_res != NULL) { in iwh_release_calib_buffer()
5568 kmem_free(sc->sc_calib_results.lo_res, in iwh_release_calib_buffer()
5569 sc->sc_calib_results.lo_res_len); in iwh_release_calib_buffer()
5570 sc->sc_calib_results.lo_res = NULL; in iwh_release_calib_buffer()
5573 if (sc->sc_calib_results.tx_iq_res != NULL) { in iwh_release_calib_buffer()
5574 kmem_free(sc->sc_calib_results.tx_iq_res, in iwh_release_calib_buffer()
5575 sc->sc_calib_results.tx_iq_res_len); in iwh_release_calib_buffer()
5576 sc->sc_calib_results.tx_iq_res = NULL; in iwh_release_calib_buffer()
5579 if (sc->sc_calib_results.tx_iq_perd_res != NULL) { in iwh_release_calib_buffer()
5580 kmem_free(sc->sc_calib_results.tx_iq_perd_res, in iwh_release_calib_buffer()
5581 sc->sc_calib_results.tx_iq_perd_res_len); in iwh_release_calib_buffer()
5582 sc->sc_calib_results.tx_iq_perd_res = NULL; in iwh_release_calib_buffer()
5585 if (sc->sc_calib_results.dc_res != NULL) { in iwh_release_calib_buffer()
5586 kmem_free(sc->sc_calib_results.dc_res, in iwh_release_calib_buffer()
5587 sc->sc_calib_results.dc_res_len); in iwh_release_calib_buffer()
5588 sc->sc_calib_results.dc_res = NULL; in iwh_release_calib_buffer()
5591 if (sc->sc_calib_results.base_band_res != NULL) { in iwh_release_calib_buffer()
5592 kmem_free(sc->sc_calib_results.base_band_res, in iwh_release_calib_buffer()
5593 sc->sc_calib_results.base_band_res_len); in iwh_release_calib_buffer()
5594 sc->sc_calib_results.base_band_res = NULL; in iwh_release_calib_buffer()
5602 iwh_init_common(iwh_sc_t *sc) in iwh_init_common() argument
5607 if (iwh_reset_hw(sc) != IWH_SUCCESS) { in iwh_init_common()
5613 (void) iwh_preinit(sc); in iwh_init_common()
5615 tmp = IWH_READ(sc, CSR_GP_CNTRL); in iwh_init_common()
5625 iwh_mac_access_enter(sc); in iwh_init_common()
5626 IWH_WRITE(sc, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); in iwh_init_common()
5628 IWH_WRITE(sc, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); in iwh_init_common()
5629 IWH_WRITE(sc, FH_RSCSR_CHNL0_RBDCB_BASE_REG, in iwh_init_common()
5630 sc->sc_rxq.dma_desc.cookie.dmac_address >> 8); in iwh_init_common()
5632 IWH_WRITE(sc, FH_RSCSR_CHNL0_STTS_WPTR_REG, in iwh_init_common()
5633 ((uint32_t)(sc->sc_dma_sh.cookie.dmac_address + in iwh_init_common()
5636 IWH_WRITE(sc, FH_MEM_RCSR_CHNL0_CONFIG_REG, in iwh_init_common()
5642 iwh_mac_access_exit(sc); in iwh_init_common()
5643 IWH_WRITE(sc, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, in iwh_init_common()
5649 iwh_mac_access_enter(sc); in iwh_init_common()
5650 iwh_reg_write(sc, IWH_SCD_TXFACT, 0); in iwh_init_common()
5655 IWH_WRITE(sc, IWH_FH_KW_MEM_ADDR_REG, in iwh_init_common()
5656 sc->sc_dma_kw.cookie.dmac_address >> 4); in iwh_init_common()
5659 IWH_WRITE(sc, FH_MEM_CBBC_QUEUE(qid), in iwh_init_common()
5660 sc->sc_txq[qid].dma_desc.cookie.dmac_address >> 8); in iwh_init_common()
5661 IWH_WRITE(sc, IWH_FH_TCSR_CHNL_TX_CONFIG_REG(qid), in iwh_init_common()
5666 iwh_mac_access_exit(sc); in iwh_init_common()
5671 IWH_WRITE(sc, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); in iwh_init_common()
5672 IWH_WRITE(sc, CSR_UCODE_DRV_GP1_CLR, in iwh_init_common()
5678 IWH_WRITE(sc, CSR_INT, 0xffffffff); in iwh_init_common()
5683 IWH_WRITE(sc, CSR_INT_MASK, CSR_INI_SET_MASK); in iwh_init_common()
5685 IWH_WRITE(sc, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); in iwh_init_common()
5686 IWH_WRITE(sc, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); in iwh_init_common()
5692 iwh_fast_recover(iwh_sc_t *sc) in iwh_fast_recover() argument
5694 ieee80211com_t *ic = &sc->sc_ic; in iwh_fast_recover()
5697 mutex_enter(&sc->sc_glock); in iwh_fast_recover()
5702 bcopy(&sc->sc_config_save, &sc->sc_config, in iwh_fast_recover()
5703 sizeof (sc->sc_config)); in iwh_fast_recover()
5705 sc->sc_config.assoc_id = 0; in iwh_fast_recover()
5706 sc->sc_config.filter_flags &= ~LE_32(RXON_FILTER_ASSOC_MSK); in iwh_fast_recover()
5708 if ((err = iwh_hw_set_before_auth(sc)) != IWH_SUCCESS) { in iwh_fast_recover()
5711 mutex_exit(&sc->sc_glock); in iwh_fast_recover()
5715 bcopy(&sc->sc_config_save, &sc->sc_config, in iwh_fast_recover()
5716 sizeof (sc->sc_config)); in iwh_fast_recover()
5721 err = iwh_run_state_config(sc); in iwh_fast_recover()
5725 mutex_exit(&sc->sc_glock); in iwh_fast_recover()
5732 iwh_set_led(sc, 2, 0, 1); in iwh_fast_recover()
5734 mutex_exit(&sc->sc_glock); in iwh_fast_recover()
5736 atomic_and_32(&sc->sc_flags, ~IWH_F_HW_ERR_RECOVER); in iwh_fast_recover()
5749 iwh_run_state_config(iwh_sc_t *sc) in iwh_run_state_config() argument
5751 struct ieee80211com *ic = &sc->sc_ic; in iwh_run_state_config()
5759 sc->sc_config.assoc_id = in->in_associd & 0x3fff; in iwh_run_state_config()
5765 sc->sc_config.flags &= in iwh_run_state_config()
5770 sc->sc_config.flags |= in iwh_run_state_config()
5775 sc->sc_config.flags |= in iwh_run_state_config()
5786 ht_protec = sc->sc_ht_conf.ht_protection; in iwh_run_state_config()
5789 sc->sc_config.flags |= in iwh_run_state_config()
5796 iwh_config_rxon_chain(sc); in iwh_run_state_config()
5798 sc->sc_config.filter_flags |= in iwh_run_state_config()
5802 sc->sc_config.filter_flags |= in iwh_run_state_config()
5809 sc->sc_config.chan, sc->sc_config.flags, in iwh_run_state_config()
5810 sc->sc_config.filter_flags)); in iwh_run_state_config()
5812 err = iwh_cmd(sc, REPLY_RXON, &sc->sc_config, in iwh_run_state_config()
5820 if ((sc->sc_dev_id != 0x423c) && in iwh_run_state_config()
5821 (sc->sc_dev_id != 0x423d)) { in iwh_run_state_config()
5825 err = iwh_tx_power_table(sc, 1); in iwh_run_state_config()
5834 err = iwh_qosparam_to_hw(sc, 1); in iwh_run_state_config()
5928 iwh_qosparam_to_hw(iwh_sc_t *sc, int async) in iwh_qosparam_to_hw() argument
5930 ieee80211com_t *ic = &sc->sc_ic; in iwh_qosparam_to_hw()
5976 err = iwh_cmd(sc, REPLY_QOS_PARAM, &qosparam_cmd, in iwh_qosparam_to_hw()
6072 iwh_init_ht_conf(iwh_sc_t *sc) in iwh_init_ht_conf() argument
6074 (void) memset(&sc->sc_ht_conf, 0, sizeof (iwh_ht_conf_t)); in iwh_init_ht_conf()
6076 if ((0x4235 == sc->sc_dev_id) || in iwh_init_ht_conf()
6077 (0x4236 == sc->sc_dev_id) || in iwh_init_ht_conf()
6078 (0x423a == sc->sc_dev_id)) { in iwh_init_ht_conf()
6079 sc->sc_ht_conf.ht_support = 1; in iwh_init_ht_conf()
6081 sc->sc_ht_conf.valid_chains = 3; in iwh_init_ht_conf()
6082 sc->sc_ht_conf.tx_stream_count = 2; in iwh_init_ht_conf()
6083 sc->sc_ht_conf.rx_stream_count = 2; in iwh_init_ht_conf()
6085 sc->sc_ht_conf.tx_support_mcs[0] = 0xff; in iwh_init_ht_conf()
6086 sc->sc_ht_conf.tx_support_mcs[1] = 0xff; in iwh_init_ht_conf()
6087 sc->sc_ht_conf.rx_support_mcs[0] = 0xff; in iwh_init_ht_conf()
6088 sc->sc_ht_conf.rx_support_mcs[1] = 0xff; in iwh_init_ht_conf()
6090 sc->sc_ht_conf.ht_support = 1; in iwh_init_ht_conf()
6092 sc->sc_ht_conf.valid_chains = 2; in iwh_init_ht_conf()
6093 sc->sc_ht_conf.tx_stream_count = 1; in iwh_init_ht_conf()
6094 sc->sc_ht_conf.rx_stream_count = 2; in iwh_init_ht_conf()
6096 sc->sc_ht_conf.tx_support_mcs[0] = 0xff; in iwh_init_ht_conf()
6097 sc->sc_ht_conf.rx_support_mcs[0] = 0xff; in iwh_init_ht_conf()
6098 sc->sc_ht_conf.rx_support_mcs[1] = 0xff; in iwh_init_ht_conf()
6101 if (sc->sc_ht_conf.ht_support) { in iwh_init_ht_conf()
6102 sc->sc_ht_conf.cap |= HT_CAP_GRN_FLD; in iwh_init_ht_conf()
6103 sc->sc_ht_conf.cap |= HT_CAP_SGI_20; in iwh_init_ht_conf()
6104 sc->sc_ht_conf.cap |= HT_CAP_MAX_AMSDU; in iwh_init_ht_conf()
6106 sc->sc_ht_conf.cap |= HT_CAP_MIMO_PS; in iwh_init_ht_conf()
6108 sc->sc_ht_conf.ampdu_p.factor = HT_RX_AMPDU_FACTOR; in iwh_init_ht_conf()
6109 sc->sc_ht_conf.ampdu_p.density = HT_MPDU_DENSITY; in iwh_init_ht_conf()
6111 sc->sc_ht_conf.ht_protection = HT_PROT_CHAN_NON_HT; in iwh_init_ht_conf()
6119 iwh_overwrite_11n_rateset(iwh_sc_t *sc) in iwh_overwrite_11n_rateset() argument
6121 uint8_t *ht_rs = sc->sc_ht_conf.rx_support_mcs; in iwh_overwrite_11n_rateset()
6158 iwh_overwrite_ic_default(iwh_sc_t *sc) in iwh_overwrite_ic_default() argument
6160 ieee80211com_t *ic = &sc->sc_ic; in iwh_overwrite_ic_default()
6162 sc->sc_newstate = ic->ic_newstate; in iwh_overwrite_ic_default()
6167 if (sc->sc_ht_conf.ht_support) { in iwh_overwrite_ic_default()
6168 sc->sc_recv_action = ic->ic_recv_action; in iwh_overwrite_ic_default()
6170 sc->sc_send_action = ic->ic_send_action; in iwh_overwrite_ic_default()
6173 ic->ic_ampdu_rxmax = sc->sc_ht_conf.ampdu_p.factor; in iwh_overwrite_ic_default()
6174 ic->ic_ampdu_density = sc->sc_ht_conf.ampdu_p.density; in iwh_overwrite_ic_default()
6184 iwh_config_rxon_chain(iwh_sc_t *sc) in iwh_config_rxon_chain() argument
6186 ieee80211com_t *ic = &sc->sc_ic; in iwh_config_rxon_chain()
6189 if (3 == sc->sc_ht_conf.valid_chains) { in iwh_config_rxon_chain()
6190 sc->sc_config.rx_chain = LE_16((RXON_RX_CHAIN_A_MSK | in iwh_config_rxon_chain()
6194 sc->sc_config.rx_chain |= LE_16((RXON_RX_CHAIN_A_MSK | in iwh_config_rxon_chain()
6198 sc->sc_config.rx_chain |= LE_16((RXON_RX_CHAIN_A_MSK | in iwh_config_rxon_chain()
6202 sc->sc_config.rx_chain = LE_16((RXON_RX_CHAIN_A_MSK | in iwh_config_rxon_chain()
6205 sc->sc_config.rx_chain |= LE_16((RXON_RX_CHAIN_A_MSK | in iwh_config_rxon_chain()
6208 sc->sc_config.rx_chain |= LE_16((RXON_RX_CHAIN_A_MSK | in iwh_config_rxon_chain()
6213 sc->sc_config.rx_chain |= LE_16(RXON_RX_CHAIN_DRIVER_FORCE_MSK); in iwh_config_rxon_chain()
6217 sc->sc_ht_conf.ht_support) { in iwh_config_rxon_chain()
6218 if (3 == sc->sc_ht_conf.valid_chains) { in iwh_config_rxon_chain()
6219 sc->sc_config.rx_chain |= LE_16(3 << in iwh_config_rxon_chain()
6221 sc->sc_config.rx_chain |= LE_16(3 << in iwh_config_rxon_chain()
6224 sc->sc_config.rx_chain |= LE_16(2 << in iwh_config_rxon_chain()
6226 sc->sc_config.rx_chain |= LE_16(2 << in iwh_config_rxon_chain()
6230 sc->sc_config.rx_chain |= LE_16(1 << in iwh_config_rxon_chain()
6235 "rxon->rx_chain = %x\n", sc->sc_config.rx_chain)); in iwh_config_rxon_chain()
6242 iwh_add_ap_sta(iwh_sc_t *sc) in iwh_add_ap_sta() argument
6244 ieee80211com_t *ic = &sc->sc_ic; in iwh_add_ap_sta()
6258 if (sc->sc_ht_conf.ht_support && in iwh_add_ap_sta()
6283 err = iwh_cmd(sc, REPLY_ADD_STA, &node, sizeof (node), 1); in iwh_add_ap_sta()
6301 iwh_ap_lq(iwh_sc_t *sc) in iwh_ap_lq() argument
6303 ieee80211com_t *ic = &sc->sc_ic; in iwh_ap_lq()
6342 err = iwh_cmd(sc, REPLY_TX_LINK_QUALITY_CMD, &link_quality, in iwh_ap_lq()
6376 iwh_sc_t *sc; in iwh_recv_action() local
6392 sc = (iwh_sc_t *)ic; in iwh_recv_action()
6394 sc->sc_recv_action(in, frm, efrm); in iwh_recv_action()
6419 mutex_enter(&sc->sc_glock); in iwh_recv_action()
6420 err = iwh_cmd(sc, REPLY_ADD_STA, &node, sizeof (node), 1); in iwh_recv_action()
6424 mutex_exit(&sc->sc_glock); in iwh_recv_action()
6427 mutex_exit(&sc->sc_glock); in iwh_recv_action()
6453 mutex_enter(&sc->sc_glock); in iwh_recv_action()
6454 err = iwh_cmd(sc, REPLY_ADD_STA, &node, sizeof (node), 1); in iwh_recv_action()
6458 mutex_exit(&sc->sc_glock); in iwh_recv_action()
6461 mutex_exit(&sc->sc_glock); in iwh_recv_action()
6481 iwh_sc_t *sc; in iwh_send_action() local
6497 sc = (iwh_sc_t *)ic; in iwh_send_action()
6499 ret = sc->sc_send_action(in, category, action, args); in iwh_send_action()
6522 mutex_enter(&sc->sc_glock); in iwh_send_action()
6523 err = iwh_cmd(sc, REPLY_ADD_STA, &node, sizeof (node), 1); in iwh_send_action()
6527 mutex_exit(&sc->sc_glock); in iwh_send_action()
6530 mutex_exit(&sc->sc_glock); in iwh_send_action()
6543 iwh_reset_hw(iwh_sc_t *sc) in iwh_reset_hw() argument
6548 tmp = IWH_READ(sc, CSR_HW_IF_CONFIG_REG); in iwh_reset_hw()
6549 IWH_WRITE(sc, CSR_HW_IF_CONFIG_REG, in iwh_reset_hw()
6556 if (IWH_READ(sc, CSR_HW_IF_CONFIG_REG) & in iwh_reset_hw()
6567 tmp = IWH_READ(sc, CSR_HW_IF_CONFIG_REG); in iwh_reset_hw()
6568 IWH_WRITE(sc, CSR_HW_IF_CONFIG_REG, in iwh_reset_hw()
6572 if (0 == (IWH_READ(sc, CSR_HW_IF_CONFIG_REG) & in iwh_reset_hw()
6583 tmp = IWH_READ(sc, CSR_HW_IF_CONFIG_REG); in iwh_reset_hw()
6584 IWH_WRITE(sc, CSR_HW_IF_CONFIG_REG, in iwh_reset_hw()
6591 if (IWH_READ(sc, CSR_HW_IF_CONFIG_REG) & in iwh_reset_hw()