Lines Matching refs:rsc
414 rtw_txdac_enable(rtw_softc_t *rsc, int enable) in rtw_txdac_enable() argument
417 struct rtw_regs *regs = &rsc->sc_regs; in rtw_txdac_enable()
491 rtw_continuous_tx_enable(rtw_softc_t *rsc, int enable) in rtw_continuous_tx_enable() argument
493 struct rtw_regs *regs = &rsc->sc_regs; in rtw_continuous_tx_enable()
505 rtw_txdac_enable(rsc, !enable); in rtw_continuous_tx_enable()
551 rtw_enable_interrupts(rtw_softc_t *rsc) in rtw_enable_interrupts() argument
553 struct rtw_regs *regs = &rsc->sc_regs; in rtw_enable_interrupts()
555 rsc->sc_inten = RTW_INTR_RX | RTW_INTR_TX | RTW_INTR_IOERROR; in rtw_enable_interrupts()
557 RTW_WRITE16(regs, RTW_IMR, rsc->sc_inten); in rtw_enable_interrupts()
561 if (rsc->sc_intr_ack != NULL) in rtw_enable_interrupts()
562 (*rsc->sc_intr_ack)(regs); in rtw_enable_interrupts()
593 rtw_reset(rtw_softc_t *rsc) in rtw_reset() argument
597 rc = rtw_chip_reset(&rsc->sc_regs, "rtw"); in rtw_reset()
601 (void) rtw_recall_eeprom(&rsc->sc_regs, "rtw"); in rtw_reset()
651 rtw_io_enable(rtw_softc_t *rsc, uint8_t flags, int enable);
654 rtw_rtx_disable(rtw_softc_t *rsc) in rtw_rtx_disable() argument
656 struct rtw_regs *regs = &rsc->sc_regs; in rtw_rtx_disable()
658 rtw_io_enable(rsc, RTW_CR_RE|RTW_CR_TE, 0); in rtw_rtx_disable()
1027 rtw_rxdesc_init(rtw_softc_t *rsc, struct rtw_rxbuf *rbf, int idx, int is_last) in rtw_rxdesc_init() argument
1046 RTW_DMA_SYNC_DESC(rsc->sc_desc_dma, in rtw_rxdesc_init()
1067 rtw_io_enable(rtw_softc_t *rsc, uint8_t flags, int enable) in rtw_io_enable() argument
1070 struct rtw_regs *regs = &rsc->sc_regs; in rtw_io_enable()
1079 RTW_DMA_SYNC_DESC(rsc->sc_desc_dma, in rtw_io_enable()
1083 rsc->rx_next = 0; in rtw_io_enable()
1084 rtw_rxdesc_init(rsc, rsc->rxbuf_h, 0, 0); in rtw_io_enable()
1157 rtw_dma_free(rtw_softc_t *rsc) in rtw_dma_free() argument
1165 txbf = list_head(&rsc->sc_txq[i].tx_free_list); in rtw_dma_free()
1168 list_remove(&rsc->sc_txq[i].tx_free_list, txbf); in rtw_dma_free()
1169 txbf = list_head(&rsc->sc_txq[i].tx_free_list); in rtw_dma_free()
1171 list_destroy(&rsc->sc_txq[i].tx_free_list); in rtw_dma_free()
1172 txbf = list_head(&rsc->sc_txq[i].tx_dirty_list); in rtw_dma_free()
1175 list_remove(&rsc->sc_txq[i].tx_dirty_list, txbf); in rtw_dma_free()
1176 txbf = list_head(&rsc->sc_txq[i].tx_dirty_list); in rtw_dma_free()
1178 list_destroy(&rsc->sc_txq[i].tx_dirty_list); in rtw_dma_free()
1180 if (rsc->sc_txq[i].txbuf_h != NULL) { in rtw_dma_free()
1181 kmem_free(rsc->sc_txq[i].txbuf_h, in rtw_dma_free()
1183 rsc->sc_txq[i].txbuf_h = NULL; in rtw_dma_free()
1188 rxbf = rsc->rxbuf_h; in rtw_dma_free()
1194 if (rsc->rxbuf_h != NULL) { in rtw_dma_free()
1195 kmem_free(rsc->rxbuf_h, in rtw_dma_free()
1197 rsc->rxbuf_h = NULL; in rtw_dma_free()
1200 rtw_free_dma_mem(&rsc->sc_desc_dma); in rtw_dma_free()
1204 rtw_dma_init(dev_info_t *devinfo, rtw_softc_t *rsc) in rtw_dma_init() argument
1217 rsc->sc_dmabuf_size = roundup(sizeof (struct ieee80211_frame) + 0x100 + in rtw_dma_init()
1220 IEEE80211_WEP_CRCLEN), rsc->sc_cachelsz); in rtw_dma_init()
1225 &rsc->sc_desc_dma); in rtw_dma_init()
1228 phybaseaddr = rsc->sc_desc_dma.cookie.dmac_address; in rtw_dma_init()
1229 virbaseaddr = rsc->sc_desc_dma.mem_va; in rtw_dma_init()
1242 list_create(&rsc->sc_txq[i].tx_free_list, in rtw_dma_init()
1245 list_create(&rsc->sc_txq[i].tx_dirty_list, in rtw_dma_init()
1249 rsc->sc_txq[i].txdesc_h = in rtw_dma_init()
1252 txds = rsc->sc_txq[i].txdesc_h; in rtw_dma_init()
1256 rsc->sc_txq[i].txbuf_h = txbf; in rtw_dma_init()
1260 (uintptr_t)rsc->sc_txq[i].txdesc_h); in rtw_dma_init()
1261 list_insert_tail(&rsc->sc_txq[i].tx_free_list, txbf); in rtw_dma_init()
1265 rsc->sc_dmabuf_size, in rtw_dma_init()
1279 rsc->rxdesc_h = (struct rtw_rxdesc *)(uintptr_t)vrx; in rtw_dma_init()
1280 rxds = rsc->rxdesc_h; in rtw_dma_init()
1285 rsc->rxbuf_h = rxbf; in rtw_dma_init()
1290 prx + ((uintptr_t)rxds - (uintptr_t)rsc->rxdesc_h); in rtw_dma_init()
1294 rsc->sc_dmabuf_size, in rtw_dma_init()
1308 rtw_hwring_setup(rtw_softc_t *rsc) in rtw_hwring_setup() argument
1310 struct rtw_regs *regs = &rsc->sc_regs; in rtw_hwring_setup()
1313 phybaseaddr = rsc->sc_desc_dma.cookie.dmac_address; in rtw_hwring_setup()
1320 rsc->hw_start = RTW_READ(regs, RTW_TNPDA); in rtw_hwring_setup()
1321 rsc->hw_go = RTW_READ(regs, RTW_TNPDA); in rtw_hwring_setup()
1325 rtw_swring_setup(rtw_softc_t *rsc, int flag) in rtw_swring_setup() argument
1333 phybaseaddr = rsc->sc_desc_dma.cookie.dmac_address; in rtw_swring_setup()
1338 RTW_DMA_SYNC(rsc->sc_desc_dma, DDI_DMA_SYNC_FORDEV); in rtw_swring_setup()
1341 rsc->sc_txq[i].tx_prod = rsc->sc_txq[i].tx_cons = 0; in rtw_swring_setup()
1342 rsc->sc_txq[i].tx_nfree = rtw_qlen[i]; in rtw_swring_setup()
1343 txbf = list_head(&rsc->sc_txq[i].tx_free_list); in rtw_swring_setup()
1345 list_remove(&rsc->sc_txq[i].tx_free_list, txbf); in rtw_swring_setup()
1346 txbf = list_head(&rsc->sc_txq[i].tx_free_list); in rtw_swring_setup()
1348 txbf = list_head(&rsc->sc_txq[i].tx_dirty_list); in rtw_swring_setup()
1350 list_remove(&rsc->sc_txq[i].tx_dirty_list, txbf); in rtw_swring_setup()
1351 txbf = list_head(&rsc->sc_txq[i].tx_dirty_list); in rtw_swring_setup()
1353 txbf = rsc->sc_txq[i].txbuf_h; in rtw_swring_setup()
1357 list_insert_tail(&rsc->sc_txq[i].tx_free_list, txbf); in rtw_swring_setup()
1380 rsc->rx_next = 0; in rtw_swring_setup()
1381 rxbf = rsc->rxbuf_h; in rtw_swring_setup()
1388 rtw_rxdesc_init(rsc, rxbf, j, is_last); in rtw_swring_setup()
1394 rtw_resume_ticks(rtw_softc_t *rsc) in rtw_resume_ticks() argument
1396 RTW_WRITE(&rsc->sc_regs, RTW_TINT, 0xffffffff); in rtw_resume_ticks()
1542 rtw_pwrstate0(rtw_softc_t *rsc, enum rtw_pwrstate power, int before_rf, in rtw_pwrstate0() argument
1545 struct rtw_regs *regs = &rsc->sc_regs; in rtw_pwrstate0()
1549 (*rsc->sc_pwrstate_cb)(regs, power, before_rf, digphy); in rtw_pwrstate0()
1567 rtw_pwrstate(rtw_softc_t *rsc, enum rtw_pwrstate power) in rtw_pwrstate() argument
1573 rtw_pwrstate_string(rsc->sc_pwrstate), rtw_pwrstate_string(power)); in rtw_pwrstate()
1575 if (rsc->sc_pwrstate == power) in rtw_pwrstate()
1578 rtw_pwrstate0(rsc, power, 1, rsc->sc_flags & RTW_F_DIGPHY); in rtw_pwrstate()
1579 rc = rtw_rf_pwrstate(rsc->sc_rf, power); in rtw_pwrstate()
1580 rtw_pwrstate0(rsc, power, 0, rsc->sc_flags & RTW_F_DIGPHY); in rtw_pwrstate()
1594 rsc->sc_pwrstate = power; in rtw_pwrstate()
1596 rsc->sc_pwrstate = RTW_OFF; in rtw_pwrstate()
1601 rtw_disable(rtw_softc_t *rsc) in rtw_disable() argument
1605 if ((rsc->sc_flags & RTW_F_ENABLED) == 0) in rtw_disable()
1609 if ((rsc->sc_flags & RTW_F_INVALID) == 0 && in rtw_disable()
1610 (rc = rtw_pwrstate(rsc, RTW_OFF)) != 0) { in rtw_disable()
1614 if (rsc->sc_disable != NULL) in rtw_disable()
1615 (*rsc->sc_disable)(rsc); in rtw_disable()
1617 rsc->sc_flags &= ~RTW_F_ENABLED; in rtw_disable()
1621 rtw_enable(rtw_softc_t *rsc) in rtw_enable() argument
1623 if ((rsc->sc_flags & RTW_F_ENABLED) == 0) { in rtw_enable()
1624 if (rsc->sc_enable != NULL && (*rsc->sc_enable)(rsc) != 0) { in rtw_enable()
1628 rsc->sc_flags |= RTW_F_ENABLED; in rtw_enable()
1629 if (rtw_pwrstate(rsc, RTW_ON) != 0) in rtw_enable()
1636 rtw_set_nettype(rtw_softc_t *rsc, enum ieee80211_opmode opmode) in rtw_set_nettype() argument
1641 rtw_set_access(&rsc->sc_regs, RTW_ACCESS_CONFIG); in rtw_set_nettype()
1643 msr = RTW_READ8(&rsc->sc_regs, RTW_MSR) & ~RTW_MSR_NETYPE_MASK; in rtw_set_nettype()
1657 RTW_WRITE8(&rsc->sc_regs, RTW_MSR, msr); in rtw_set_nettype()
1659 rtw_set_access(&rsc->sc_regs, RTW_ACCESS_NONE); in rtw_set_nettype()
1663 rtw_pktfilt_load(rtw_softc_t *rsc) in rtw_pktfilt_load() argument
1665 struct rtw_regs *regs = &rsc->sc_regs; in rtw_pktfilt_load()
1666 struct ieee80211com *ic = &rsc->sc_ic; in rtw_pktfilt_load()
1669 rsc->sc_rcr &= ~RTW_RCR_PKTFILTER_MASK; in rtw_pktfilt_load()
1670 rsc->sc_rcr &= ~(RTW_RCR_MXDMA_MASK | RTW_RCR_RXFTH_MASK); in rtw_pktfilt_load()
1672 rsc->sc_rcr |= RTW_RCR_PKTFILTER_DEFAULT; in rtw_pktfilt_load()
1674 rsc->sc_rcr |= RTW_RCR_ENMARP; in rtw_pktfilt_load()
1676 rsc->sc_rcr |= RTW_RCR_RXFTH_WHOLE |RTW_RCR_MXDMA_1024; in rtw_pktfilt_load()
1682 rsc->sc_rcr |= RTW_RCR_ADD3; in rtw_pktfilt_load()
1689 rsc->sc_rcr |= RTW_RCR_AB; /* accept all broadcast */ in rtw_pktfilt_load()
1693 rsc->sc_rcr |= RTW_RCR_AM; in rtw_pktfilt_load()
1694 RTW_WRITE(regs, RTW_RCR, rsc->sc_rcr); in rtw_pktfilt_load()
1701 RTW_WRITE(regs, RTW_RCR, rsc->sc_rcr); in rtw_pktfilt_load()
1728 rtw_refine_setting(rtw_softc_t *rsc) in rtw_refine_setting() argument
1733 regs = &rsc->sc_regs; in rtw_refine_setting()
1734 rc = rtw_reset(rsc); in rtw_refine_setting()
1739 rtw_io_enable(rsc, RTW_CR_RE|RTW_CR_TE, 1); in rtw_refine_setting()
1743 rtw_pktfilt_load(rsc); in rtw_refine_setting()
1753 rtw_set_rfprog(regs, rsc->sc_rfchipid, "rtw"); in rtw_refine_setting()
1755 RTW_WRITE8(regs, RTW_PHYDELAY, rsc->sc_phydelay); in rtw_refine_setting()
1762 rtw_tune(rtw_softc_t *rsc) in rtw_tune() argument
1764 struct ieee80211com *ic = &rsc->sc_ic; in rtw_tune()
1767 int antdiv = rsc->sc_flags & RTW_F_ANTDIV, in rtw_tune()
1768 dflantb = rsc->sc_flags & RTW_F_DFLANTB; in rtw_tune()
1780 if (chan == rsc->sc_cur_chan) { in rtw_tune()
1785 rtw_idle(&rsc->sc_regs); in rtw_tune()
1786 rtw_io_enable(rsc, RTW_CR_RE | RTW_CR_TE, 0); in rtw_tune()
1787 ASSERT((rsc->sc_flags & RTW_F_ENABLED) != 0); in rtw_tune()
1789 if ((rc = rtw_phy_init(&rsc->sc_regs, rsc->sc_rf, in rtw_tune()
1790 rtw_chan2txpower(&rsc->sc_srom, ic, ic->ic_curchan), in rtw_tune()
1791 rsc->sc_csthr, ic->ic_curchan->ich_freq, antdiv, in rtw_tune()
1796 rtw_io_enable(rsc, RTW_CR_RE | RTW_CR_TE, 1); in rtw_tune()
1797 rtw_resume_ticks(rsc); in rtw_tune()
1798 rsc->sc_cur_chan = chan; in rtw_tune()
1803 rtw_init(rtw_softc_t *rsc) in rtw_init() argument
1805 struct ieee80211com *ic = &rsc->sc_ic; in rtw_init()
1808 rtw_stop(rsc); in rtw_init()
1809 mutex_enter(&rsc->sc_genlock); in rtw_init()
1810 if ((rc = rtw_enable(rsc)) != 0) in rtw_init()
1812 rc = rtw_refine_setting(rsc); in rtw_init()
1814 mutex_exit(&rsc->sc_genlock); in rtw_init()
1817 rtw_swring_setup(rsc, 1); in rtw_init()
1818 rtw_hwring_setup(rsc); in rtw_init()
1819 RTW_WRITE16(&rsc->sc_regs, RTW_BSSID16, 0x0); in rtw_init()
1820 RTW_WRITE(&rsc->sc_regs, RTW_BSSID32, 0x0); in rtw_init()
1821 rtw_enable_interrupts(rsc); in rtw_init()
1828 rsc->sc_invalid = 0; in rtw_init()
1830 mutex_exit(&rsc->sc_genlock); in rtw_init()
1835 rtw_rf_attach(rtw_softc_t *rsc, enum rtw_rfchipid rfchipid, int digphy) in rtw_rf_attach() argument
1856 rf = rtw_max2820_create(&rsc->sc_regs, rf_write, 0); in rtw_rf_attach()
1857 rsc->sc_pwrstate_cb = rtw_maxim_pwrstate; in rtw_rf_attach()
1860 rf = rtw_sa2400_create(&rsc->sc_regs, rf_write, digphy); in rtw_rf_attach()
1861 rsc->sc_pwrstate_cb = rtw_philips_pwrstate; in rtw_rf_attach()
1865 rsc->sc_pwrstate_cb = rtw_rfmd_pwrstate; in rtw_rf_attach()
1873 rf->rf_continuous_tx_arg = (void *)rsc; in rtw_rf_attach()
1905 static void rtw_intr_rx(rtw_softc_t *rsc);
1906 static void rtw_ring_recycling(rtw_softc_t *rsc, uint16_t isr, uint32_t pri);
2088 rtw_assembly_80211(rtw_softc_t *rsc, struct rtw_txbuf *bf, in rtw_assembly_80211() argument
2101 ic = &rsc->sc_ic; in rtw_assembly_80211()
2231 RTW_DMA_SYNC_DESC(rsc->sc_desc_dma, in rtw_assembly_80211()
2241 rsc->sc_pktxmt64++; in rtw_assembly_80211()
2242 rsc->sc_bytexmt64 += pktlen; in rtw_assembly_80211()
2251 rtw_softc_t *rsc = (rtw_softc_t *)ic; in rtw_send() local
2256 mutex_enter(&rsc->sc_txlock); in rtw_send()
2257 mutex_enter(&rsc->sc_txq[i].txbuf_lock); in rtw_send()
2258 bf = list_head(&rsc->sc_txq[i].tx_free_list); in rtw_send()
2260 if ((bf == NULL) || (rsc->sc_txq[i].tx_nfree <= 4)) { in rtw_send()
2262 rsc->sc_noxmtbuf++; in rtw_send()
2267 rsc->sc_need_reschedule = 1; in rtw_send()
2271 mutex_exit(&rsc->sc_txq[i].txbuf_lock); in rtw_send()
2272 mutex_exit(&rsc->sc_txlock); in rtw_send()
2275 list_remove(&rsc->sc_txq[i].tx_free_list, bf); in rtw_send()
2276 rsc->sc_txq[i].tx_nfree--; in rtw_send()
2279 ret = rtw_assembly_80211(rsc, bf, mp); in rtw_send()
2282 mutex_exit(&rsc->sc_txq[i].txbuf_lock); in rtw_send()
2283 mutex_exit(&rsc->sc_txlock); in rtw_send()
2290 list_insert_tail(&rsc->sc_txq[i].tx_dirty_list, bf); in rtw_send()
2292 rtw_dma_start(&rsc->sc_regs, i); in rtw_send()
2294 mutex_exit(&rsc->sc_txq[i].txbuf_lock); in rtw_send()
2295 mutex_exit(&rsc->sc_txlock); in rtw_send()
2304 rtw_softc_t *rsc = arg; in rtw_m_tx() local
2305 ieee80211com_t *ic = (ieee80211com_t *)rsc; in rtw_m_tx()
2332 rtw_softc_t *rsc = (rtw_softc_t *)arg; in rtw_next_scan() local
2334 rsc->sc_scan_id = 0; in rtw_next_scan()
2343 rtw_join_bss(rtw_softc_t *rsc, uint8_t *bssid, uint16_t intval0) in rtw_join_bss() argument
2347 struct rtw_regs *regs = &rsc->sc_regs; in rtw_join_bss()
2369 rtw_io_enable(rsc, RTW_CR_RE | RTW_CR_TE, 1); in rtw_join_bss()
2376 rtw_rate_ctl_start(rtw_softc_t *rsc, struct ieee80211_node *in) in rtw_rate_ctl_start() argument
2378 ieee80211com_t *ic = (ieee80211com_t *)rsc; in rtw_rate_ctl_start()
2418 rtw_rate_ctl_reset(rtw_softc_t *rsc, enum ieee80211_state state) in rtw_rate_ctl_reset() argument
2420 ieee80211com_t *ic = &rsc->sc_ic; in rtw_rate_ctl_reset()
2431 rtw_rate_ctl_start(rsc, in); in rtw_rate_ctl_reset()
2445 rtw_softc_t *rsc = (rtw_softc_t *)ic; in rtw_rate_ctl() local
2450 mutex_enter(&rsc->sc_genlock); in rtw_rate_ctl()
2451 enough = (rsc->sc_tx_ok + rsc->sc_tx_err) >= 600? 1 : 0; in rtw_rate_ctl()
2454 if (enough && rsc->sc_tx_ok < rsc->sc_tx_err) in rtw_rate_ctl()
2473 rsc->sc_tx_ok = rsc->sc_tx_err = rsc->sc_tx_retr = 0; in rtw_rate_ctl()
2474 mutex_exit(&rsc->sc_genlock); in rtw_rate_ctl()
2476 rsc->sc_ratectl_id = timeout(rtw_rate_ctl, ic, in rtw_rate_ctl()
2483 rtw_softc_t *rsc = (rtw_softc_t *)ic; in rtw_new_state() local
2494 mutex_enter(&rsc->sc_genlock); in rtw_new_state()
2495 if (rsc->sc_scan_id != 0) { in rtw_new_state()
2496 (void) untimeout(rsc->sc_scan_id); in rtw_new_state()
2497 rsc->sc_scan_id = 0; in rtw_new_state()
2499 if (rsc->sc_ratectl_id != 0) { in rtw_new_state()
2500 (void) untimeout(rsc->sc_ratectl_id); in rtw_new_state()
2501 rsc->sc_ratectl_id = 0; in rtw_new_state()
2503 rtw_rate_ctl_reset(rsc, nstate); in rtw_new_state()
2505 (void) rtw_pwrstate(rsc, RTW_ON); in rtw_new_state()
2507 if ((error = rtw_tune(rsc)) != 0) { in rtw_new_state()
2508 mutex_exit(&rsc->sc_genlock); in rtw_new_state()
2518 rsc->sc_scan_id = timeout(rtw_next_scan, ic, in rtw_new_state()
2520 rtw_set_nettype(rsc, IEEE80211_M_MONITOR); in rtw_new_state()
2527 rtw_set_nettype(rsc, IEEE80211_M_MONITOR); in rtw_new_state()
2534 rtw_join_bss(rsc, ic->ic_bss->in_bssid, 0); in rtw_new_state()
2535 rsc->sc_ratectl_id = timeout(rtw_rate_ctl, ic, in rtw_new_state()
2541 rtw_set_nettype(rsc, ic->ic_opmode); in rtw_new_state()
2548 mutex_exit(&rsc->sc_genlock); in rtw_new_state()
2552 error = rsc->sc_newstate(ic, nstate, arg); in rtw_new_state()
2558 rtw_intr_rx(rtw_softc_t *rsc) in rtw_intr_rx() argument
2572 ieee80211com_t *ic = (ieee80211com_t *)rsc; in rtw_intr_rx()
2576 __func__, rsc->sc_ic.ic_state); in rtw_intr_rx()
2577 mutex_enter(&rsc->rxbuf_lock); in rtw_intr_rx()
2578 next = rsc->rx_next; in rtw_intr_rx()
2579 mutex_exit(&rsc->rxbuf_lock); in rtw_intr_rx()
2581 RTW_DMA_SYNC_DESC(rsc->sc_desc_dma, in rtw_intr_rx()
2586 bf = rsc->rxbuf_h + next; in rtw_intr_rx()
2600 RTW_DMA_SYNC_DESC(rsc->sc_desc_dma, in rtw_intr_rx()
2604 bf = rsc->rxbuf_h; in rtw_intr_rx()
2613 rsc->sc_pktrcv64++; in rtw_intr_rx()
2623 rsc->sc_bytercv64 += len; in rtw_intr_rx()
2634 rsc->sc_ic.ic_opmode != IEEE80211_M_MONITOR) { in rtw_intr_rx()
2645 if (rsc->sc_rfchipid == RTW_RFCHIPID_PHILIPS) in rtw_intr_rx()
2660 mp = allocb(rsc->sc_dmabuf_size, BPRI_MED); in rtw_intr_rx()
2663 rsc->sc_norcvbuf++; in rtw_intr_rx()
2683 rtw_rxdesc_init(rsc, bf, next, is_last); in rtw_intr_rx()
2688 mutex_enter(&rsc->rxbuf_lock); in rtw_intr_rx()
2689 rsc->rx_next = next; in rtw_intr_rx()
2690 mutex_exit(&rsc->rxbuf_lock); in rtw_intr_rx()
2694 rtw_ring_recycling(rtw_softc_t *rsc, uint16_t isr, uint32_t pri) in rtw_ring_recycling() argument
2702 mutex_enter(&rsc->sc_txq[pri].txbuf_lock); in rtw_ring_recycling()
2703 head = RTW_READ(&rsc->sc_regs, RTW_TNPDA); in rtw_ring_recycling()
2704 if (head == rsc->hw_go) { in rtw_ring_recycling()
2705 mutex_exit(&rsc->sc_txq[pri].txbuf_lock); in rtw_ring_recycling()
2709 rsc->sc_ic.ic_state); in rtw_ring_recycling()
2711 bf = list_head(&rsc->sc_txq[pri].tx_dirty_list); in rtw_ring_recycling()
2715 mutex_exit(&rsc->sc_txq[pri].txbuf_lock); in rtw_ring_recycling()
2719 while ((bf != NULL) && (rsc->hw_go != head)) { in rtw_ring_recycling()
2721 idx = (rsc->hw_go - rsc->hw_start) / sizeof (struct rtw_txdesc); in rtw_ring_recycling()
2723 rsc->hw_go = rsc->hw_start; in rtw_ring_recycling()
2725 rsc->hw_go += sizeof (struct rtw_txdesc); in rtw_ring_recycling()
2726 RTW_DMA_SYNC_DESC(rsc->sc_desc_dma, in rtw_ring_recycling()
2739 rsc->sc_tx_ok++; in rtw_ring_recycling()
2746 rsc->sc_tx_ok++; in rtw_ring_recycling()
2748 rsc->sc_tx_err++; in rtw_ring_recycling()
2751 rsc->sc_tx_retr += in rtw_ring_recycling()
2753 rsc->sc_xmtretry += in rtw_ring_recycling()
2755 list_remove(&rsc->sc_txq[pri].tx_dirty_list, bf); in rtw_ring_recycling()
2756 list_insert_tail(&rsc->sc_txq[pri].tx_free_list, in rtw_ring_recycling()
2758 (rsc->sc_txq[pri].tx_nfree)++; in rtw_ring_recycling()
2759 if (rsc->sc_need_reschedule == 1) { in rtw_ring_recycling()
2760 mac_tx_update(rsc->sc_ic.ic_mach); in rtw_ring_recycling()
2761 rsc->sc_need_reschedule = 0; in rtw_ring_recycling()
2765 pri, rsc->sc_txq[pri].tx_nfree); in rtw_ring_recycling()
2767 RTW_DMA_SYNC_DESC(rsc->sc_desc_dma, in rtw_ring_recycling()
2771 bf = list_head(&rsc->sc_txq[pri].tx_dirty_list); in rtw_ring_recycling()
2773 mutex_exit(&rsc->sc_txq[pri].txbuf_lock); in rtw_ring_recycling()
2777 rtw_intr_timeout(rtw_softc_t *rsc) in rtw_intr_timeout() argument
2779 rtw_resume_ticks(rsc); in rtw_intr_timeout()
2786 rtw_softc_t *rsc = (rtw_softc_t *)arg; in rtw_intr() local
2787 struct rtw_regs *regs = &rsc->sc_regs; in rtw_intr()
2790 mutex_enter(&rsc->sc_genlock); in rtw_intr()
2795 mutex_exit(&rsc->sc_genlock); in rtw_intr()
2830 rsc->sc_intr++; in rtw_intr()
2833 mutex_exit(&rsc->sc_genlock); in rtw_intr()
2834 rtw_intr_rx(rsc); in rtw_intr()
2835 mutex_enter(&rsc->sc_genlock); in rtw_intr()
2838 rtw_intr_timeout(rsc); in rtw_intr()
2841 rtw_ring_recycling(rsc, isr, 1); in rtw_intr()
2842 mutex_exit(&rsc->sc_genlock); in rtw_intr()
2849 rtw_softc_t *rsc = (rtw_softc_t *)arg; in rtw_stop() local
2850 struct rtw_regs *regs = &rsc->sc_regs; in rtw_stop()
2852 mutex_enter(&rsc->sc_genlock); in rtw_stop()
2854 rtw_io_enable(rsc, RTW_CR_RE | RTW_CR_TE, 0); in rtw_stop()
2856 rsc->sc_invalid = 1; in rtw_stop()
2857 mutex_exit(&rsc->sc_genlock); in rtw_stop()
2863 rtw_softc_t *rsc = (rtw_softc_t *)arg; in rtw_m_stop() local
2865 (void) ieee80211_new_state(&rsc->sc_ic, IEEE80211_S_INIT, -1); in rtw_m_stop()
2866 rtw_stop(rsc); in rtw_m_stop()
2882 rtw_softc_t *rsc = NULL; in rtw_quiesce() local
2885 rsc = ddi_get_soft_state(rtw_soft_state_p, ddi_get_instance(dip)); in rtw_quiesce()
2886 ASSERT(rsc != NULL); in rtw_quiesce()
2887 regs = &rsc->sc_regs; in rtw_quiesce()
2891 rtw_io_enable(rsc, RTW_CR_RE | RTW_CR_TE, 0); in rtw_quiesce()
2904 rtw_softc_t *rsc = (rtw_softc_t *)arg; in rtw_m_setprop() local
2905 struct ieee80211com *ic = &rsc->sc_ic; in rtw_m_setprop()
2911 if (ic->ic_des_esslen && (rsc->sc_invalid == 0)) { in rtw_m_setprop()
2912 (void) rtw_init(rsc); in rtw_m_setprop()
2924 rtw_softc_t *rsc = arg; in rtw_m_getprop() local
2927 err = ieee80211_getprop(&rsc->sc_ic, pr_name, wldp_pr_num, in rtw_m_getprop()
2937 rtw_softc_t *rsc = arg; in rtw_m_propinfo() local
2939 ieee80211_propinfo(&rsc->sc_ic, pr_name, wldp_pr_num, prh); in rtw_m_propinfo()
2945 rtw_softc_t *rsc = (rtw_softc_t *)arg; in rtw_m_start() local
2946 ieee80211com_t *ic = (ieee80211com_t *)rsc; in rtw_m_start()
2949 rtw_print_regs(&rsc->sc_regs, "rtw", "rtw_start"); in rtw_m_start()
2952 ret = rtw_init(rsc); in rtw_m_start()
2965 rtw_softc_t *rsc = (rtw_softc_t *)arg; in rtw_m_unicst() local
2966 ieee80211com_t *ic = (ieee80211com_t *)rsc; in rtw_m_unicst()
2967 struct rtw_regs *regs = &rsc->sc_regs; in rtw_m_unicst()
2970 mutex_enter(&rsc->sc_genlock); in rtw_m_unicst()
2977 mutex_exit(&rsc->sc_genlock); in rtw_m_unicst()
2984 rtw_softc_t *rsc = (rtw_softc_t *)arg; in rtw_m_promisc() local
2985 struct rtw_regs *regs = &rsc->sc_regs; in rtw_m_promisc()
2987 mutex_enter(&rsc->sc_genlock); in rtw_m_promisc()
2990 rsc->sc_rcr |= RTW_RCR_PROMIC; in rtw_m_promisc()
2992 rsc->sc_rcr &= ~RTW_RCR_PROMIC; in rtw_m_promisc()
2994 RTW_WRITE(regs, RTW_RCR, rsc->sc_rcr); in rtw_m_promisc()
2996 mutex_exit(&rsc->sc_genlock); in rtw_m_promisc()
3003 rtw_softc_t *rsc = (rtw_softc_t *)arg; in rtw_m_multicst() local
3004 struct rtw_regs *regs = &rsc->sc_regs; in rtw_m_multicst()
3007 mutex_enter(&rsc->sc_genlock); in rtw_m_multicst()
3009 rsc->sc_rcr |= RTW_RCR_AM; in rtw_m_multicst()
3015 RTW_WRITE(regs, RTW_RCR, rsc->sc_rcr); in rtw_m_multicst()
3018 rsc->sc_rcr &= ~RTW_RCR_AM; in rtw_m_multicst()
3021 RTW_WRITE(regs, RTW_RCR, rsc->sc_rcr); in rtw_m_multicst()
3024 mutex_exit(&rsc->sc_genlock); in rtw_m_multicst()
3031 rtw_softc_t *rsc = arg; in rtw_m_ioctl() local
3032 struct ieee80211com *ic = &rsc->sc_ic; in rtw_m_ioctl()
3037 if (ic->ic_des_esslen && (rsc->sc_invalid == 0)) { in rtw_m_ioctl()
3038 (void) rtw_init(rsc); in rtw_m_ioctl()
3048 rtw_softc_t *rsc = (rtw_softc_t *)arg; in rtw_m_stat() local
3049 ieee80211com_t *ic = &rsc->sc_ic; in rtw_m_stat()
3053 mutex_enter(&rsc->sc_genlock); in rtw_m_stat()
3063 *val = rsc->sc_noxmtbuf; in rtw_m_stat()
3066 *val = rsc->sc_norcvbuf; in rtw_m_stat()
3069 *val = rsc->sc_bytercv64; in rtw_m_stat()
3072 *val = rsc->sc_pktrcv64; in rtw_m_stat()
3075 *val = rsc->sc_bytexmt64; in rtw_m_stat()
3078 *val = rsc->sc_pktxmt64; in rtw_m_stat()
3081 *val = rsc->sc_xmtretry; in rtw_m_stat()
3091 mutex_exit(&rsc->sc_genlock); in rtw_m_stat()
3097 mutex_exit(&rsc->sc_genlock); in rtw_m_stat()
3104 rtw_mutex_destroy(rtw_softc_t *rsc) in rtw_mutex_destroy() argument
3108 mutex_destroy(&rsc->rxbuf_lock); in rtw_mutex_destroy()
3109 mutex_destroy(&rsc->sc_txlock); in rtw_mutex_destroy()
3111 mutex_destroy(&rsc->sc_txq[RTW_NTXPRI - 1 - i].txbuf_lock); in rtw_mutex_destroy()
3113 mutex_destroy(&rsc->sc_genlock); in rtw_mutex_destroy()
3119 rtw_softc_t *rsc; in rtw_attach() local
3134 rsc = ddi_get_soft_state(rtw_soft_state_p, in rtw_attach()
3136 ASSERT(rsc != NULL); in rtw_attach()
3137 mutex_enter(&rsc->sc_genlock); in rtw_attach()
3138 rsc->sc_flags &= ~RTW_F_SUSPEND; in rtw_attach()
3139 mutex_exit(&rsc->sc_genlock); in rtw_attach()
3140 if ((rsc->sc_flags & RTW_F_PLUMBED)) { in rtw_attach()
3141 err = rtw_init(rsc); in rtw_attach()
3143 mutex_enter(&rsc->sc_genlock); in rtw_attach()
3144 rsc->sc_flags &= ~RTW_F_PLUMBED; in rtw_attach()
3145 mutex_exit(&rsc->sc_genlock); in rtw_attach()
3160 rsc = ddi_get_soft_state(rtw_soft_state_p, ddi_get_instance(devinfo)); in rtw_attach()
3161 ic = &rsc->sc_ic; in rtw_attach()
3162 rsc->sc_dev = devinfo; in rtw_attach()
3164 err = ddi_regs_map_setup(devinfo, 0, (caddr_t *)&rsc->sc_cfg_base, 0, 0, in rtw_attach()
3165 &rtw_reg_accattr, &rsc->sc_cfg_handle); in rtw_attach()
3171 csz = ddi_get8(rsc->sc_cfg_handle, in rtw_attach()
3172 (uint8_t *)(rsc->sc_cfg_base + PCI_CONF_CACHE_LINESZ)); in rtw_attach()
3175 rsc->sc_cachelsz = csz << 2; in rtw_attach()
3176 vendor_id = ddi_get16(rsc->sc_cfg_handle, in rtw_attach()
3177 (uint16_t *)((uintptr_t)rsc->sc_cfg_base + PCI_CONF_VENID)); in rtw_attach()
3178 device_id = ddi_get16(rsc->sc_cfg_handle, in rtw_attach()
3179 (uint16_t *)((uintptr_t)rsc->sc_cfg_base + PCI_CONF_DEVID)); in rtw_attach()
3188 ddi_put16(rsc->sc_cfg_handle, in rtw_attach()
3189 (uint16_t *)((uintptr_t)rsc->sc_cfg_base + PCI_CONF_COMM), command); in rtw_attach()
3193 ddi_put8(rsc->sc_cfg_handle, in rtw_attach()
3194 (uint8_t *)(rsc->sc_cfg_base + PCI_CONF_LATENCY_TIMER), 0xa8); in rtw_attach()
3196 ddi_regs_map_free(&rsc->sc_cfg_handle); in rtw_attach()
3198 err = ddi_regs_map_setup(devinfo, 2, (caddr_t *)&rsc->sc_regs.r_base, in rtw_attach()
3199 0, 0, &rtw_reg_accattr, &rsc->sc_regs.r_handle); in rtw_attach()
3206 rsc->sc_regs.r_base, rsc->sc_regs.r_handle); in rtw_attach()
3208 err = rtw_dma_init(devinfo, rsc); in rtw_attach()
3219 RTW_WRITE8(&rsc->sc_regs, RTW_TPPOLL, RTW_TPPOLL_SALL); in rtw_attach()
3220 rtw_io_enable(rsc, RTW_CR_RE | RTW_CR_TE, 0); in rtw_attach()
3223 if (rtw_reset(rsc) != 0) { in rtw_attach()
3228 rsc->sc_rcr = RTW_READ(&rsc->sc_regs, RTW_RCR); in rtw_attach()
3230 if ((rsc->sc_rcr & RTW_RCR_9356SEL) != 0) in rtw_attach()
3231 rsc->sc_flags |= RTW_F_9356SROM; in rtw_attach()
3233 if (rtw_srom_read(&rsc->sc_regs, rsc->sc_flags, &rsc->sc_srom, in rtw_attach()
3240 if (rtw_srom_parse(&rsc->sc_srom, &rsc->sc_flags, &rsc->sc_csthr, in rtw_attach()
3241 &rsc->sc_rfchipid, &rsc->sc_rcr, &rsc->sc_locale, in rtw_attach()
3249 ((rsc->sc_flags & RTW_F_DIGPHY) != 0) ? "digital" : "analog"); in rtw_attach()
3252 rsc->sc_rf = rtw_rf_attach(rsc, rsc->sc_rfchipid, in rtw_attach()
3253 rsc->sc_flags & RTW_F_DIGPHY); in rtw_attach()
3255 if (rsc->sc_rf == NULL) { in rtw_attach()
3259 rsc->sc_phydelay = rtw_check_phydelay(&rsc->sc_regs, rsc->sc_rcr); in rtw_attach()
3262 "rtw: PHY delay %d\n", rsc->sc_phydelay); in rtw_attach()
3264 if (rsc->sc_locale == RTW_LOCALE_UNKNOWN) in rtw_attach()
3265 rtw_identify_country(&rsc->sc_regs, &rsc->sc_locale, in rtw_attach()
3268 rtw_init_channels(rsc->sc_locale, &rsc->sc_ic.ic_sup_channels, in rtw_attach()
3273 if (rtw_identify_sta(&rsc->sc_regs, ic->ic_macaddr, in rtw_attach()
3280 rsc->sc_newstate = ic->ic_newstate; in rtw_attach()
3285 if (ddi_get_iblock_cookie(devinfo, 0, &(rsc->sc_iblock)) in rtw_attach()
3292 mutex_init(&rsc->sc_genlock, NULL, MUTEX_DRIVER, rsc->sc_iblock); in rtw_attach()
3294 mutex_init(&rsc->sc_txq[i].txbuf_lock, NULL, MUTEX_DRIVER, in rtw_attach()
3295 rsc->sc_iblock); in rtw_attach()
3297 mutex_init(&rsc->rxbuf_lock, NULL, MUTEX_DRIVER, rsc->sc_iblock); in rtw_attach()
3298 mutex_init(&rsc->sc_txlock, NULL, MUTEX_DRIVER, rsc->sc_iblock); in rtw_attach()
3300 if (ddi_add_intr(devinfo, 0, &rsc->sc_iblock, NULL, rtw_intr, in rtw_attach()
3301 (caddr_t)(rsc)) != DDI_SUCCESS) { in rtw_attach()
3322 macp->m_driver = rsc; in rtw_attach()
3350 rsc->sc_flags |= RTW_F_ATTACHED; in rtw_attach()
3351 rsc->sc_need_reschedule = 0; in rtw_attach()
3352 rsc->sc_invalid = 1; in rtw_attach()
3358 ddi_remove_intr(devinfo, 0, rsc->sc_iblock); in rtw_attach()
3361 rtw_mutex_destroy(rsc); in rtw_attach()
3365 rtw_rf_destroy(rsc->sc_rf); in rtw_attach()
3367 rtw_srom_free(&rsc->sc_srom); in rtw_attach()
3369 rtw_dma_free(rsc); in rtw_attach()
3371 ddi_regs_map_free(&rsc->sc_regs.r_handle); in rtw_attach()
3380 rtw_softc_t *rsc; in rtw_detach() local
3382 rsc = ddi_get_soft_state(rtw_soft_state_p, ddi_get_instance(devinfo)); in rtw_detach()
3383 ASSERT(rsc != NULL); in rtw_detach()
3389 ieee80211_new_state(&rsc->sc_ic, IEEE80211_S_INIT, -1); in rtw_detach()
3390 mutex_enter(&rsc->sc_genlock); in rtw_detach()
3391 rsc->sc_flags |= RTW_F_SUSPEND; in rtw_detach()
3392 mutex_exit(&rsc->sc_genlock); in rtw_detach()
3393 if (rsc->sc_invalid == 0) { in rtw_detach()
3394 rtw_stop(rsc); in rtw_detach()
3395 mutex_enter(&rsc->sc_genlock); in rtw_detach()
3396 rsc->sc_flags |= RTW_F_PLUMBED; in rtw_detach()
3397 mutex_exit(&rsc->sc_genlock); in rtw_detach()
3403 if (!(rsc->sc_flags & RTW_F_ATTACHED)) in rtw_detach()
3406 if (mac_disable(rsc->sc_ic.ic_mach) != 0) in rtw_detach()
3410 ddi_remove_intr(devinfo, 0, rsc->sc_iblock); in rtw_detach()
3412 rtw_mutex_destroy(rsc); in rtw_detach()
3413 ieee80211_detach((ieee80211com_t *)rsc); in rtw_detach()
3417 (void) mac_unregister(rsc->sc_ic.ic_mach); in rtw_detach()
3419 rtw_rf_destroy(rsc->sc_rf); in rtw_detach()
3420 rtw_srom_free(&rsc->sc_srom); in rtw_detach()
3421 rtw_dma_free(rsc); in rtw_detach()
3423 ddi_regs_map_free(&rsc->sc_regs.r_handle); in rtw_detach()