Lines Matching +full:rsu +full:- +full:rtl8712fw

3 /*-
22 * o tx a-mpdu
24 * o power-save operation
71 SYSCTL_NODE(_hw_usb, OID_AUTO, rsu, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
72 "USB rsu");
78 device_printf((_sc)->sc_dev, __VA_ARGS__); \
85 TUNABLE_INT("hw.usb.rsu.enable_11n", &rsu_enable_11n);
271 .name = "rsu",
276 DRIVER_MODULE(rsu, uhub, rsu_driver, NULL, NULL);
277 MODULE_DEPEND(rsu, wlan, 1, 1, 1);
278 MODULE_DEPEND(rsu, usb, 1, 1, 1);
279 MODULE_DEPEND(rsu, firmware, 1, 1, 1);
280 MODULE_VERSION(rsu, 1);
290 /* XXX hard-coded */
351 if (uaa->usb_mode != USB_MODE_HOST || in rsu_match()
352 uaa->info.bIfaceIndex != 0 || in rsu_match()
353 uaa->info.bConfigIndex != 0) in rsu_match()
373 * notification from net80211 that it'd like to do A-MPDU on the given TID.
378 struct rsu_softc *sc = ni->ni_ic->ic_softc; in rsu_ampdu_enable()
382 __func__, tap->txa_tid); in rsu_ampdu_enable()
391 req.tid = htole32(tap->txa_tid); in rsu_ampdu_enable()
394 if (ieee80211_ampdu_tx_request_ext(ni, tap->txa_tid) != 1) in rsu_ampdu_enable()
401 tap->txa_tid); in rsu_ampdu_enable()
409 ieee80211_ampdu_tx_request_active_ext(ni, tap->txa_tid, 0); in rsu_ampdu_enable()
419 ieee80211_ampdu_tx_request_active_ext(ni, tap->txa_tid, 1); in rsu_ampdu_enable()
438 struct ieee80211com *ic = &sc->sc_ic; in rsu_attach()
445 sc->sc_udev = uaa->device; in rsu_attach()
446 sc->sc_dev = self; in rsu_attach()
447 sc->sc_rx_checksum_enable = 1; in rsu_attach()
449 sc->sc_ht = !! (USB_GET_DRIVER_INFO(uaa) & RSU_HT_SUPPORTED); in rsu_attach()
452 iface = usbd_get_iface(sc->sc_udev, 0); in rsu_attach()
453 sc->sc_nendpoints = iface->idesc->bNumEndpoints; in rsu_attach()
455 /* Endpoints are hard-coded for now, so enforce 4-endpoint only */ in rsu_attach()
456 if (sc->sc_nendpoints != 4) { in rsu_attach()
457 device_printf(sc->sc_dev, in rsu_attach()
458 "the driver currently only supports 4-endpoint devices\n"); in rsu_attach()
462 mtx_init(&sc->sc_mtx, device_get_nameunit(self), MTX_NETWORK_LOCK, in rsu_attach()
465 TIMEOUT_TASK_INIT(taskqueue_thread, &sc->calib_task, 0, in rsu_attach()
467 TASK_INIT(&sc->del_key_task, 0, rsu_delete_key_pair_cb, sc); in rsu_attach()
468 TASK_INIT(&sc->tx_task, 0, rsu_tx_task, sc); in rsu_attach()
469 mbufq_init(&sc->sc_snd, ifqmaxlen); in rsu_attach()
474 device_printf(sc->sc_dev, "could not allocate Rx buffers\n"); in rsu_attach()
480 device_printf(sc->sc_dev, "could not allocate Tx buffers\n"); in rsu_attach()
486 error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_xfer, in rsu_attach()
487 rsu_config, RSU_N_TRANSFER, sc, &sc->sc_mtx); in rsu_attach()
489 device_printf(sc->sc_dev, in rsu_attach()
496 sc->cut = MS(rsu_read_4(sc, R92S_PMC_FSM), R92S_PMC_FSM_CUT); in rsu_attach()
497 if (sc->cut != 3) in rsu_attach()
498 sc->cut = (sc->cut >> 1) + 1; in rsu_attach()
507 switch (sc->rom[84]) { in rsu_attach()
509 sc->sc_rftype = RTL8712_RFCONFIG_1T1R; in rsu_attach()
510 sc->sc_nrxstream = 1; in rsu_attach()
511 sc->sc_ntxstream = 1; in rsu_attach()
515 sc->sc_rftype = RTL8712_RFCONFIG_1T2R; in rsu_attach()
516 sc->sc_nrxstream = 2; in rsu_attach()
517 sc->sc_ntxstream = 1; in rsu_attach()
521 sc->sc_rftype = RTL8712_RFCONFIG_2T2R; in rsu_attach()
522 sc->sc_nrxstream = 2; in rsu_attach()
523 sc->sc_ntxstream = 2; in rsu_attach()
527 sc->sc_rftype = RTL8712_RFCONFIG_1T2R; in rsu_attach()
528 sc->sc_nrxstream = 2; in rsu_attach()
529 sc->sc_ntxstream = 1; in rsu_attach()
533 device_printf(sc->sc_dev, in rsu_attach()
536 sc->rom[84]); in rsu_attach()
540 IEEE80211_ADDR_COPY(ic->ic_macaddr, &sc->rom[0x12]); in rsu_attach()
541 device_printf(self, "MAC/BB RTL8712 cut %d %s\n", sc->cut, rft); in rsu_attach()
543 ic->ic_softc = sc; in rsu_attach()
544 ic->ic_name = device_get_nameunit(self); in rsu_attach()
545 ic->ic_phytype = IEEE80211_T_OFDM; /* Not only, but not used. */ in rsu_attach()
546 ic->ic_opmode = IEEE80211_M_STA; /* Default to BSS mode. */ in rsu_attach()
549 ic->ic_caps = in rsu_attach()
560 ic->ic_cryptocaps = in rsu_attach()
566 if (sc->sc_ht) { in rsu_attach()
567 device_printf(sc->sc_dev, "%s: enabling 11n\n", __func__); in rsu_attach()
570 ic->ic_htcaps = IEEE80211_HTC_HT | in rsu_attach()
575 ic->ic_htcaps |= IEEE80211_HTCAP_CHWIDTH40; in rsu_attach()
578 ic->ic_txstream = sc->sc_ntxstream; in rsu_attach()
579 ic->ic_rxstream = sc->sc_nrxstream; in rsu_attach()
581 ic->ic_flags_ext |= IEEE80211_FEXT_SCAN_OFFLOAD; in rsu_attach()
582 ic->ic_flags_ext |= IEEE80211_FEXT_SEQNO_OFFLOAD; in rsu_attach()
584 rsu_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, in rsu_attach()
585 ic->ic_channels); in rsu_attach()
588 ic->ic_raw_xmit = rsu_raw_xmit; in rsu_attach()
589 ic->ic_scan_start = rsu_scan_start; in rsu_attach()
590 ic->ic_scan_end = rsu_scan_end; in rsu_attach()
591 ic->ic_getradiocaps = rsu_getradiocaps; in rsu_attach()
592 ic->ic_set_channel = rsu_set_channel; in rsu_attach()
593 ic->ic_scan_curchan = rsu_scan_curchan; in rsu_attach()
594 ic->ic_scan_mindwell = rsu_scan_mindwell; in rsu_attach()
595 ic->ic_vap_create = rsu_vap_create; in rsu_attach()
596 ic->ic_vap_delete = rsu_vap_delete; in rsu_attach()
597 ic->ic_update_promisc = rsu_update_promisc; in rsu_attach()
598 ic->ic_update_mcast = rsu_update_mcast; in rsu_attach()
599 ic->ic_ioctl = rsu_ioctl_net; in rsu_attach()
600 ic->ic_parent = rsu_parent; in rsu_attach()
601 ic->ic_transmit = rsu_transmit; in rsu_attach()
602 ic->ic_send_mgmt = rsu_send_mgmt; in rsu_attach()
603 ic->ic_update_chw = rsu_update_chw; in rsu_attach()
604 ic->ic_ampdu_enable = rsu_ampdu_enable; in rsu_attach()
605 ic->ic_wme.wme_update = rsu_wme_update; in rsu_attach()
607 ieee80211_radiotap_attach(ic, &sc->sc_txtap.wt_ihdr, in rsu_attach()
608 sizeof(sc->sc_txtap), RSU_TX_RADIOTAP_PRESENT, in rsu_attach()
609 &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap), in rsu_attach()
618 usbd_transfer_unsetup(sc->sc_xfer, RSU_N_TRANSFER); in rsu_attach()
620 mtx_destroy(&sc->sc_mtx); in rsu_attach()
628 struct ieee80211com *ic = &sc->sc_ic; in rsu_detach()
632 usbd_transfer_unsetup(sc->sc_xfer, RSU_N_TRANSFER); in rsu_detach()
647 taskqueue_drain_timeout(taskqueue_thread, &sc->calib_task); in rsu_detach()
648 taskqueue_drain(taskqueue_thread, &sc->del_key_task); in rsu_detach()
649 taskqueue_drain(taskqueue_thread, &sc->tx_task); in rsu_detach()
652 mtx_destroy(&sc->sc_mtx); in rsu_detach()
666 while (ntries--) { in rsu_do_request()
667 err = usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx, in rsu_do_request()
686 struct rsu_softc *sc = ic->ic_softc; in rsu_vap_create()
691 if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */ in rsu_vap_create()
695 vap = &uvp->vap; in rsu_vap_create()
704 ifp = vap->iv_ifp; in rsu_vap_create()
707 if (sc->sc_rx_checksum_enable) in rsu_vap_create()
712 uvp->newstate = vap->iv_newstate; in rsu_vap_create()
714 vap->iv_newstate = rsu_monitor_newstate; in rsu_vap_create()
716 vap->iv_newstate = rsu_newstate; in rsu_vap_create()
717 vap->iv_key_alloc = rsu_key_alloc; in rsu_vap_create()
718 vap->iv_key_set = rsu_key_set; in rsu_vap_create()
719 vap->iv_key_delete = rsu_key_delete; in rsu_vap_create()
722 vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_16; in rsu_vap_create()
723 vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_32K; in rsu_vap_create()
728 ic->ic_opmode = opmode; in rsu_vap_create()
745 struct rsu_softc *sc = ic->ic_softc; in rsu_scan_start()
746 struct ieee80211_scan_state *ss = ic->ic_scan; in rsu_scan_start()
747 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in rsu_scan_start()
752 sc->sc_active_scan = !!(ss->ss_flags & IEEE80211_SCAN_ACTIVE); in rsu_scan_start()
753 /* XXX TODO: force awake if in network-sleep? */ in rsu_scan_start()
754 error = rsu_site_survey(sc, ss->ss_nssid > 0 ? &ss->ss_ssid[0] : NULL); in rsu_scan_start()
757 device_printf(sc->sc_dev, in rsu_scan_start()
773 struct rsu_softc *sc = ic->ic_softc; in rsu_getradiocaps()
780 if (sc->sc_ht) in rsu_getradiocaps()
783 bands, (ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40) ? in rsu_getradiocaps()
790 struct rsu_softc *sc = ic->ic_softc; in rsu_set_channel()
796 if (ic->ic_opmode == IEEE80211_M_MONITOR) { in rsu_set_channel()
800 cmd.channel = IEEE80211_CHAN2IEEE(ic->ic_curchan); in rsu_set_channel()
806 device_printf(sc->sc_dev, in rsu_set_channel()
835 struct rsu_softc *sc = ic->ic_softc; in rsu_update_promisc()
838 if (sc->sc_running) in rsu_update_promisc()
856 pos ^= (mask >> (i * 8 + j - 1)); in rsu_get_multi_pos()
878 struct ieee80211com *ic = &sc->sc_ic; in rsu_set_multi()
884 if (ic->ic_allmulti == 0) { in rsu_set_multi()
891 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) in rsu_set_multi()
892 if_foreach_llmaddr(vap->iv_ifp, rsu_hash_maddr, &mfilt); in rsu_set_multi()
906 struct rsu_softc *sc = ic->ic_softc; in rsu_update_mcast()
909 if (sc->sc_running) in rsu_update_mcast()
922 dp->sc = sc; in rsu_alloc_list()
923 dp->m = NULL; in rsu_alloc_list()
924 dp->buf = malloc(maxsz, M_USBDEV, M_NOWAIT); in rsu_alloc_list()
925 if (dp->buf == NULL) { in rsu_alloc_list()
926 device_printf(sc->sc_dev, in rsu_alloc_list()
931 dp->ni = NULL; in rsu_alloc_list()
945 error = rsu_alloc_list(sc, sc->sc_rx, RSU_RX_LIST_COUNT, in rsu_alloc_rx_list()
950 STAILQ_INIT(&sc->sc_rx_active); in rsu_alloc_rx_list()
951 STAILQ_INIT(&sc->sc_rx_inactive); in rsu_alloc_rx_list()
954 STAILQ_INSERT_HEAD(&sc->sc_rx_inactive, &sc->sc_rx[i], next); in rsu_alloc_rx_list()
964 error = rsu_alloc_list(sc, sc->sc_tx, RSU_TX_LIST_COUNT, in rsu_alloc_tx_list()
969 STAILQ_INIT(&sc->sc_tx_inactive); in rsu_alloc_tx_list()
972 STAILQ_INIT(&sc->sc_tx_active[i]); in rsu_alloc_tx_list()
973 STAILQ_INIT(&sc->sc_tx_pending[i]); in rsu_alloc_tx_list()
977 STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, &sc->sc_tx[i], next); in rsu_alloc_tx_list()
989 STAILQ_INIT(&sc->sc_tx_inactive); in rsu_free_tx_list()
992 STAILQ_INIT(&sc->sc_tx_active[i]); in rsu_free_tx_list()
993 STAILQ_INIT(&sc->sc_tx_pending[i]); in rsu_free_tx_list()
996 rsu_free_list(sc, sc->sc_tx, RSU_TX_LIST_COUNT); in rsu_free_tx_list()
1003 STAILQ_INIT(&sc->sc_rx_inactive); in rsu_free_rx_list()
1004 STAILQ_INIT(&sc->sc_rx_active); in rsu_free_rx_list()
1006 rsu_free_list(sc, sc->sc_rx, RSU_RX_LIST_COUNT); in rsu_free_rx_list()
1017 if (dp->buf != NULL) { in rsu_free_list()
1018 free(dp->buf, M_USBDEV); in rsu_free_list()
1019 dp->buf = NULL; in rsu_free_list()
1021 if (dp->ni != NULL) { in rsu_free_list()
1022 ieee80211_free_node(dp->ni); in rsu_free_list()
1023 dp->ni = NULL; in rsu_free_list()
1033 bf = STAILQ_FIRST(&sc->sc_tx_inactive); in _rsu_getbuf()
1035 STAILQ_REMOVE_HEAD(&sc->sc_tx_inactive, next); in _rsu_getbuf()
1060 STAILQ_INSERT_TAIL(&sc->sc_tx_inactive, bf, next); in rsu_freebuf()
1175 device_printf(sc->sc_dev, in rsu_efuse_read_1()
1183 uint8_t *rom = sc->rom; in rsu_read_rom()
1201 memset(&sc->rom, 0xff, sizeof(sc->rom)); in rsu_read_rom()
1224 for (i = 0; i < sizeof(sc->rom); i++) in rsu_read_rom()
1249 memset(data->buf, '\0', RSU_TXBUFSZ); in rsu_fw_cmd()
1251 /* Round-up command length to a multiple of 8 bytes. */ in rsu_fw_cmd()
1257 memset(data->buf, 0, xferlen); in rsu_fw_cmd()
1260 txd = (struct r92s_tx_desc *)data->buf; in rsu_fw_cmd()
1261 txd->txdw0 = htole32( in rsu_fw_cmd()
1265 txd->txdw1 = htole32(SM(R92S_TXDW1_QSEL, R92S_TXDW1_QSEL_H2C)); in rsu_fw_cmd()
1269 cmd->len = htole16(cmdsz); in rsu_fw_cmd()
1270 cmd->code = code; in rsu_fw_cmd()
1271 cmd->seq = sc->cmd_seq; in rsu_fw_cmd()
1272 sc->cmd_seq = (sc->cmd_seq + 1) & 0x7f; in rsu_fw_cmd()
1280 data->buflen = xferlen; in rsu_fw_cmd()
1281 STAILQ_INSERT_TAIL(&sc->sc_tx_pending[which], data, next); in rsu_fw_cmd()
1282 usbd_transfer_start(sc->sc_xfer[which]); in rsu_fw_cmd()
1312 sc->sc_currssi = rsu_read_4(sc, R92S_IOCMD_DATA); in rsu_calib_task()
1314 __func__, sc->sc_currssi, in rsu_calib_task()
1315 rsu_hwrssi_to_rssi(sc, sc->sc_currssi)); in rsu_calib_task()
1317 if (sc->sc_calibrating) in rsu_calib_task()
1318 taskqueue_enqueue_timeout(taskqueue_thread, &sc->calib_task, hz); in rsu_calib_task()
1344 * For now - it's on in all states except RUN, and
1364 if (sc->sc_curpwrstate == state) in rsu_set_fw_power_state()
1385 device_printf(sc->sc_dev, "%s: unknown ps mode (%d)\n", in rsu_set_fw_power_state()
1396 sc->sc_curpwrstate = state; in rsu_set_fw_power_state()
1412 struct ieee80211com *ic = vap->iv_ic; in rsu_monitor_newstate()
1413 struct rsu_softc *sc = ic->ic_softc; in rsu_monitor_newstate()
1416 if (vap->iv_state != nstate) { in rsu_monitor_newstate()
1422 sc->sc_vap_is_running = 0; in rsu_monitor_newstate()
1426 sc->sc_vap_is_running = 1; in rsu_monitor_newstate()
1439 return (uvp->newstate(vap, nstate, arg)); in rsu_monitor_newstate()
1446 struct ieee80211com *ic = vap->iv_ic; in rsu_newstate()
1447 struct rsu_softc *sc = ic->ic_softc; in rsu_newstate()
1453 ostate = vap->iv_state; in rsu_newstate()
1454 RSU_DPRINTF(sc, RSU_DEBUG_STATE, "%s: %s -> %s\n", in rsu_newstate()
1463 sc->sc_calibrating = 0; in rsu_newstate()
1467 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(10)); in rsu_newstate()
1470 taskqueue_drain_timeout(taskqueue_thread, &sc->calib_task); in rsu_newstate()
1471 taskqueue_drain(taskqueue_thread, &sc->tx_task); in rsu_newstate()
1475 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(10)); in rsu_newstate()
1478 sc->sc_vap_is_running = 0; in rsu_newstate()
1482 if (sc->sc_running) in rsu_newstate()
1491 ni = ieee80211_ref_node(vap->iv_bss); in rsu_newstate()
1496 device_printf(sc->sc_dev, in rsu_newstate()
1504 ni = ieee80211_ref_node(vap->iv_bss); in rsu_newstate()
1505 rs = &ni->ni_rates; in rsu_newstate()
1508 rs->rs_rates[rs->rs_nrates - 1]); in rsu_newstate()
1517 sc->sc_calibrating = 1; in rsu_newstate()
1519 taskqueue_enqueue_timeout(taskqueue_thread, &sc->calib_task, in rsu_newstate()
1524 return (uvp->newstate(vap, nstate, arg)); in rsu_newstate()
1531 struct rsu_softc *sc = vap->iv_ic->ic_softc; in rsu_key_alloc()
1538 if (vap->iv_opmode != IEEE80211_M_STA) { in rsu_key_alloc()
1542 k->wk_flags |= IEEE80211_KEY_SWCRYPT; in rsu_key_alloc()
1553 if (isset(sc->keys_bmap, *keyix)) { in rsu_key_alloc()
1554 device_printf(sc->sc_dev, in rsu_key_alloc()
1560 setbit(sc->keys_bmap, *keyix); in rsu_key_alloc()
1573 struct rsu_softc *sc = vap->iv_ic->ic_softc; in rsu_process_key()
1576 if (k->wk_flags & IEEE80211_KEY_SWCRYPT) { in rsu_process_key()
1583 KASSERT(k->wk_keyix < nitems(sc->group_keys), in rsu_process_key()
1584 ("keyix %u > %zu\n", k->wk_keyix, nitems(sc->group_keys))); in rsu_process_key()
1587 sc->group_keys[k->wk_keyix] = (set ? k : NULL); in rsu_process_key()
1588 if (!sc->sc_running) { in rsu_process_key()
1597 ret = rsu_delete_key(sc, k->wk_keyix); in rsu_process_key()
1605 taskqueue_drain(taskqueue_thread, &sc->del_key_task); in rsu_process_key()
1612 setbit(sc->free_keys_bmap, k->wk_keyix); in rsu_process_key()
1616 taskqueue_enqueue(taskqueue_thread, &sc->del_key_task); in rsu_process_key()
1646 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(1)); in rsu_cam_read()
1649 device_printf(sc->sc_dev, in rsu_cam_read()
1677 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(1)); in rsu_key_check()
1681 device_printf(sc->sc_dev, in rsu_key_check()
1689 device_printf(sc->sc_dev, in rsu_key_check()
1712 device_printf(sc->sc_dev, "unknown cipher %d\n", cipher); in rsu_crypto_mode()
1727 algo = rsu_crypto_mode(sc, k->wk_cipher->ic_cipher, k->wk_keylen); in rsu_set_key_group()
1733 key.cam_id = k->wk_keyix; in rsu_set_key_group()
1734 key.grpkey = (k->wk_flags & IEEE80211_KEY_GROUP) != 0; in rsu_set_key_group()
1735 memcpy(key.key, k->wk_key, MIN(k->wk_keylen, sizeof(key.key))); in rsu_set_key_group()
1740 k->wk_cipher->ic_cipher, key.algo, k->wk_flags, k->wk_keylen, in rsu_set_key_group()
1741 ether_sprintf(k->wk_macaddr)); in rsu_set_key_group()
1745 device_printf(sc->sc_dev, in rsu_set_key_group()
1751 return (rsu_key_check(sc, k->wk_keyix, 1)); in rsu_set_key_group()
1763 if (!sc->sc_running) in rsu_set_key_pair()
1767 algo = rsu_crypto_mode(sc, k->wk_cipher->ic_cipher, k->wk_keylen); in rsu_set_key_pair()
1773 memcpy(key.macaddr, k->wk_macaddr, sizeof(key.macaddr)); in rsu_set_key_pair()
1774 memcpy(key.key, k->wk_key, MIN(k->wk_keylen, sizeof(key.key))); in rsu_set_key_pair()
1778 __func__, k->wk_keyix, k->wk_cipher->ic_cipher, key.algo, in rsu_set_key_pair()
1779 k->wk_flags, k->wk_keylen, ether_sprintf(key.macaddr)); in rsu_set_key_pair()
1783 device_printf(sc->sc_dev, in rsu_set_key_pair()
1789 return (rsu_key_check(sc, k->wk_keyix, 1)); in rsu_set_key_pair()
1797 for (i = 0; i < nitems(sc->group_keys); i++) { in rsu_reinit_static_keys()
1798 if (sc->group_keys[i] != NULL) { in rsu_reinit_static_keys()
1799 error = rsu_set_key_group(sc, sc->group_keys[i]); in rsu_reinit_static_keys()
1801 device_printf(sc->sc_dev, in rsu_reinit_static_keys()
1821 if (!sc->sc_running) in rsu_delete_key()
1829 clrbit(sc->keys_bmap, keyix); in rsu_delete_key()
1841 device_printf(sc->sc_dev, in rsu_delete_key()
1847 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(5)); in rsu_delete_key()
1856 clrbit(sc->keys_bmap, keyix); in rsu_delete_key()
1869 if (isset(sc->free_keys_bmap, i)) { in rsu_delete_key_pair_cb()
1880 clrbit(sc->free_keys_bmap, i); in rsu_delete_key_pair_cb()
1883 i = IEEE80211_WEP_NKID - 1; in rsu_delete_key_pair_cb()
1899 if (sc->sc_active_scan) in rsu_site_survey()
1904 sc->sc_extra_scan = 1; in rsu_site_survey()
1905 cmd.ssidlen = htole32(ssid->len); in rsu_site_survey()
1906 memcpy(cmd.ssid, ssid->ssid, ssid->len); in rsu_site_survey()
1910 device_printf(sc->sc_dev, in rsu_site_survey()
1926 struct ieee80211com *ic = &sc->sc_ic; in rsu_join_bss()
1927 struct ieee80211vap *vap = ni->ni_vap; in rsu_join_bss()
1948 if (vap->iv_flags & IEEE80211_F_WPA) { in rsu_join_bss()
1950 auth.dot1x = (ni->ni_authmode == IEEE80211_AUTH_8021X); in rsu_join_bss()
1962 IEEE80211_ADDR_COPY(bss->macaddr, ni->ni_bssid); in rsu_join_bss()
1963 bss->ssid.ssidlen = htole32(ni->ni_esslen); in rsu_join_bss()
1964 memcpy(bss->ssid.ssid, ni->ni_essid, ni->ni_esslen); in rsu_join_bss()
1965 if (vap->iv_flags & (IEEE80211_F_PRIVACY | IEEE80211_F_WPA)) in rsu_join_bss()
1966 bss->privacy = htole32(1); in rsu_join_bss()
1967 bss->rssi = htole32(ni->ni_avgrssi); in rsu_join_bss()
1968 if (ic->ic_curmode == IEEE80211_MODE_11B) in rsu_join_bss()
1969 bss->networktype = htole32(NDIS802_11DS); in rsu_join_bss()
1971 bss->networktype = htole32(NDIS802_11OFDM24); in rsu_join_bss()
1972 bss->config.len = htole32(sizeof(bss->config)); in rsu_join_bss()
1973 bss->config.bintval = htole32(ni->ni_intval); in rsu_join_bss()
1974 bss->config.dsconfig = htole32(ieee80211_chan2ieee(ic, ni->ni_chan)); in rsu_join_bss()
1975 bss->inframode = htole32(NDIS802_11INFRASTRUCTURE); in rsu_join_bss()
1977 memcpy(bss->supprates, ni->ni_rates.rs_rates, in rsu_join_bss()
1978 ni->ni_rates.rs_nrates); in rsu_join_bss()
1981 memcpy(&fixed->tstamp, ni->ni_tstamp.data, 8); in rsu_join_bss()
1982 fixed->bintval = htole16(ni->ni_intval); in rsu_join_bss()
1983 fixed->capabilities = htole16(ni->ni_capinfo); in rsu_join_bss()
1989 if ((ic->ic_flags & IEEE80211_F_WME) && in rsu_join_bss()
1990 (ni->ni_ies.wme_ie != NULL)) in rsu_join_bss()
1991 frm = ieee80211_add_wme_info(frm, &ic->ic_wme, ni); in rsu_join_bss()
1992 if (ni->ni_flags & IEEE80211_NODE_HT) { in rsu_join_bss()
1996 bss->ieslen = htole32(frm - (uint8_t *)fixed); in rsu_join_bss()
1997 bss->len = htole32(((frm - buf) + 3) & ~3); in rsu_join_bss()
2001 ether_sprintf(bss->macaddr), le32toh(bss->config.dsconfig)); in rsu_join_bss()
2008 uint32_t zero = 0; /* :-) */ in rsu_disconnect()
2039 struct ieee80211com *ic = &sc->sc_ic; in rsu_event_survey()
2050 ieslen = le32toh(bss->ieslen); in rsu_event_survey()
2052 if (__predict_false(ieslen > (uint32_t)(len - sizeof(*bss)))) in rsu_event_survey()
2059 ether_sprintf(bss->macaddr), ieslen, in rsu_event_survey()
2060 le32toh(bss->config.dsconfig), le32toh(bss->inframode), in rsu_event_survey()
2061 le32toh(bss->networktype), le32toh(bss->privacy), in rsu_event_survey()
2062 le32toh(bss->rssi)); in rsu_event_survey()
2066 if (__predict_false(ieslen > (size_t)(MCLBYTES - sizeof(*wh)))) in rsu_event_survey()
2073 wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT | in rsu_event_survey()
2075 wh->i_fc[1] = IEEE80211_FC1_DIR_NODS; in rsu_event_survey()
2076 USETW(wh->i_dur, 0); in rsu_event_survey()
2077 IEEE80211_ADDR_COPY(wh->i_addr1, ieee80211broadcastaddr); in rsu_event_survey()
2078 IEEE80211_ADDR_COPY(wh->i_addr2, bss->macaddr); in rsu_event_survey()
2079 IEEE80211_ADDR_COPY(wh->i_addr3, bss->macaddr); in rsu_event_survey()
2080 *(uint16_t *)wh->i_seq = 0; in rsu_event_survey()
2084 m->m_pkthdr.len = m->m_len = pktlen; in rsu_event_survey()
2091 rxs.c_ieee = le32toh(bss->config.dsconfig); in rsu_event_survey()
2095 rxs.c_rssi = le32toh(bss->rssi) / 2; in rsu_event_survey()
2096 rxs.c_nf = -96; in rsu_event_survey()
2109 struct ieee80211com *ic = &sc->sc_ic; in rsu_event_join_bss()
2110 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in rsu_event_join_bss()
2111 struct ieee80211_node *ni = vap->iv_bss; in rsu_event_join_bss()
2119 res = (int)le32toh(rsp->join_res); in rsu_event_join_bss()
2131 ieee80211_new_state(vap, IEEE80211_S_SCAN, -1); in rsu_event_join_bss()
2136 tmp = le32toh(rsp->associd); in rsu_event_join_bss()
2137 if (tmp >= vap->iv_max_aid) { in rsu_event_join_bss()
2143 __func__, ether_sprintf(rsp->bss.macaddr), tmp); in rsu_event_join_bss()
2145 ni->ni_associd = tmp | 0xc000; in rsu_event_join_bss()
2148 sc->sc_vap_is_running = 1; in rsu_event_join_bss()
2160 struct ieee80211com *ic = &sc->sc_ic; in rsu_event_addba_req_report()
2161 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in rsu_event_addba_req_report()
2166 device_printf(sc->sc_dev, "%s: short read (%d)\n", __func__, len); in rsu_event_addba_req_report()
2175 ether_sprintf(ba->mac_addr), in rsu_event_addba_req_report()
2176 (int) ba->tid, in rsu_event_addba_req_report()
2177 (int) le16toh(ba->ssn) >> 4); in rsu_event_addba_req_report()
2181 ni = ieee80211_ref_node(vap->iv_bss); in rsu_event_addba_req_report()
2182 ieee80211_ampdu_rx_start_ext(ni, ba->tid, le16toh(ba->ssn) >> 4, 32); in rsu_event_addba_req_report()
2189 struct ieee80211com *ic = &sc->sc_ic; in rsu_rx_event()
2190 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in rsu_rx_event()
2201 __func__, sc->sc_extra_scan ? "direct" : "broadcast", in rsu_rx_event()
2203 if (sc->sc_extra_scan == 1) { in rsu_rx_event()
2205 sc->sc_extra_scan = 0; in rsu_rx_event()
2220 if (vap->iv_state == IEEE80211_S_AUTH) in rsu_rx_event()
2232 if (vap->iv_state == IEEE80211_S_RUN && in rsu_rx_event()
2233 IEEE80211_ADDR_EQ(vap->iv_bss->ni_bssid, buf)) { in rsu_rx_event()
2235 ieee80211_new_state(vap, IEEE80211_S_SCAN, -1); in rsu_rx_event()
2252 device_printf(sc->sc_dev, "%s: unhandled code (%d)\n", __func__, code); in rsu_rx_event()
2267 len -= sizeof(struct r92s_rx_stat); in rsu_rx_multi_event()
2276 cmdsz = le16toh(cmd->len); in rsu_rx_multi_event()
2281 rsu_rx_event(sc, cmd->code, (uint8_t *)&cmd[1], cmdsz); in rsu_rx_multi_event()
2283 if (!(cmd->seq & R92S_FW_CMD_MORE)) in rsu_rx_multi_event()
2286 len -= sizeof(*cmd) + cmdsz; in rsu_rx_multi_event()
2293 static const int8_t cckoff[] = { 14, -2, -20, -40 }; in rsu_get_rssi()
2301 rpt = (cck->agc_rpt >> 6) & 0x3; in rsu_get_rssi()
2302 rssi = cck->agc_rpt & 0x3e; in rsu_get_rssi()
2303 rssi = cckoff[rpt] - rssi; in rsu_get_rssi()
2306 rssi = ((le32toh(phy->phydw1) >> 1) & 0x7f) - 106; in rsu_get_rssi()
2315 struct ieee80211com *ic = &sc->sc_ic; in rsu_rx_copy_to_mbuf()
2320 rxdw0 = le32toh(stat->rxdw0); in rsu_rx_copy_to_mbuf()
2337 device_printf(sc->sc_dev, in rsu_rx_copy_to_mbuf()
2345 m->m_pkthdr.len = m->m_len = totlen; in rsu_rx_copy_to_mbuf()
2349 counter_u64_add(ic->ic_ierrors, 1); in rsu_rx_copy_to_mbuf()
2368 struct ieee80211com *ic = &sc->sc_ic; in rsu_rx_frame()
2378 rxdw0 = le32toh(stat->rxdw0); in rsu_rx_frame()
2379 rxdw3 = le32toh(stat->rxdw3); in rsu_rx_frame()
2390 rssi = rsu_hwrssi_to_rssi(sc, sc->sc_currssi); in rsu_rx_frame()
2413 m->m_pkthdr.csum_flags = CSUM_IP_CHECKED; in rsu_rx_frame()
2414 m->m_pkthdr.csum_flags |= CSUM_IP_VALID; in rsu_rx_frame()
2421 m->m_pkthdr.csum_flags |= CSUM_DATA_VALID; in rsu_rx_frame()
2422 m->m_pkthdr.csum_flags |= CSUM_PSEUDO_HDR; in rsu_rx_frame()
2423 m->m_pkthdr.csum_data = 0xffff; in rsu_rx_frame()
2435 rxs.c_nf = -96; in rsu_rx_frame()
2445 rxs.c_rate = IEEE80211_RATE_MCS | (rate - 12); in rsu_rx_frame()
2450 struct rsu_rx_radiotap_header *tap = &sc->sc_rxtap; in rsu_rx_frame()
2453 tap->wr_flags = 0; /* TODO */ in rsu_rx_frame()
2454 tap->wr_tsft = rsu_get_tsf_high(sc); in rsu_rx_frame()
2455 if (le32toh(stat->tsf_low) > rsu_get_tsf_low(sc)) in rsu_rx_frame()
2456 tap->wr_tsft--; in rsu_rx_frame()
2457 tap->wr_tsft = (uint64_t)htole32(tap->wr_tsft) << 32; in rsu_rx_frame()
2458 tap->wr_tsft += stat->tsf_low; in rsu_rx_frame()
2460 tap->wr_rate = rxs.c_rate; in rsu_rx_frame()
2461 tap->wr_dbm_antsignal = rssi; in rsu_rx_frame()
2469 if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED) && in rsu_rx_frame()
2471 m->m_flags |= M_WEP; in rsu_rx_frame()
2476 __func__, m->m_len, rate, infosz); in rsu_rx_frame()
2478 if (m->m_len >= sizeof(*wh)) in rsu_rx_frame()
2496 if (!sc->sc_running) in rsu_rx_multi_frame()
2501 npkts = MS(le32toh(stat->rxdw2), R92S_RXDW2_PKTCNT); in rsu_rx_multi_frame()
2506 while (npkts-- > 0) { in rsu_rx_multi_frame()
2510 rxdw0 = le32toh(stat->rxdw0); in rsu_rx_multi_frame()
2530 prevm->m_next = m; in rsu_rx_multi_frame()
2533 /* Next chunk is 128-byte aligned. */ in rsu_rx_multi_frame()
2536 len -= totlen; in rsu_rx_multi_frame()
2545 struct rsu_softc *sc = data->sc; in rsu_rxeof()
2546 struct ieee80211com *ic = &sc->sc_ic; in rsu_rxeof()
2554 counter_u64_add(ic->ic_ierrors, 1); in rsu_rxeof()
2558 stat = (struct r92s_rx_stat *)data->buf; in rsu_rxeof()
2559 if ((le32toh(stat->rxdw1) & 0x1ff) == 0x1ff) { in rsu_rxeof()
2560 rsu_rx_multi_event(sc, data->buf, len); in rsu_rxeof()
2564 return (rsu_rx_multi_frame(sc, data->buf, len)); in rsu_rxeof()
2571 struct ieee80211com *ic = &sc->sc_ic; in rsu_bulk_rx_callback()
2580 data = STAILQ_FIRST(&sc->sc_rx_active); in rsu_bulk_rx_callback()
2583 STAILQ_REMOVE_HEAD(&sc->sc_rx_active, next); in rsu_bulk_rx_callback()
2585 STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next); in rsu_bulk_rx_callback()
2589 data = STAILQ_FIRST(&sc->sc_rx_inactive); in rsu_bulk_rx_callback()
2594 STAILQ_REMOVE_HEAD(&sc->sc_rx_inactive, next); in rsu_bulk_rx_callback()
2595 STAILQ_INSERT_TAIL(&sc->sc_rx_active, data, next); in rsu_bulk_rx_callback()
2596 usbd_xfer_set_frame_data(xfer, 0, data->buf, in rsu_bulk_rx_callback()
2605 next = m->m_next; in rsu_bulk_rx_callback()
2606 m->m_next = NULL; in rsu_bulk_rx_callback()
2612 if (ni->ni_flags & IEEE80211_NODE_HT) in rsu_bulk_rx_callback()
2613 m->m_flags |= M_AMPDU; in rsu_bulk_rx_callback()
2625 data = STAILQ_FIRST(&sc->sc_rx_active); in rsu_bulk_rx_callback()
2627 STAILQ_REMOVE_HEAD(&sc->sc_rx_active, next); in rsu_bulk_rx_callback()
2628 STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next); in rsu_bulk_rx_callback()
2632 counter_u64_add(ic->ic_ierrors, 1); in rsu_bulk_rx_callback()
2651 if (data->m) { in rsu_txeof()
2653 ieee80211_tx_complete(data->ni, data->m, 0); in rsu_txeof()
2654 data->m = NULL; in rsu_txeof()
2655 data->ni = NULL; in rsu_txeof()
2664 struct ieee80211com *ic = &sc->sc_ic; in rsu_bulk_tx_callback_sub()
2671 data = STAILQ_FIRST(&sc->sc_tx_active[which]); in rsu_bulk_tx_callback_sub()
2676 STAILQ_REMOVE_HEAD(&sc->sc_tx_active[which], next); in rsu_bulk_tx_callback_sub()
2682 data = STAILQ_FIRST(&sc->sc_tx_pending[which]); in rsu_bulk_tx_callback_sub()
2688 STAILQ_REMOVE_HEAD(&sc->sc_tx_pending[which], next); in rsu_bulk_tx_callback_sub()
2689 STAILQ_INSERT_TAIL(&sc->sc_tx_active[which], data, next); in rsu_bulk_tx_callback_sub()
2690 usbd_xfer_set_frame_data(xfer, 0, data->buf, data->buflen); in rsu_bulk_tx_callback_sub()
2698 data = STAILQ_FIRST(&sc->sc_tx_active[which]); in rsu_bulk_tx_callback_sub()
2700 STAILQ_REMOVE_HEAD(&sc->sc_tx_active[which], next); in rsu_bulk_tx_callback_sub()
2704 counter_u64_add(ic->ic_oerrors, 1); in rsu_bulk_tx_callback_sub()
2762 const struct ieee80211_txparam *tp = ni->ni_txparms; in rsu_tx_start()
2763 struct ieee80211vap *vap = ni->ni_vap; in rsu_tx_start()
2778 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; in rsu_tx_start()
2779 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); in rsu_tx_start()
2787 (m0->m_flags & M_EAPOL) != 0) in rsu_tx_start()
2788 rate = tp->mgmtrate; in rsu_tx_start()
2790 rate = tp->mcastrate; in rsu_tx_start()
2791 else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) in rsu_tx_start()
2792 rate = tp->ucastrate; in rsu_tx_start()
2799 /* Assign sequence number, A-MPDU or otherwise */ in rsu_tx_start()
2800 ieee80211_output_seqno_assign(ni, -1, m0); in rsu_tx_start()
2802 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { in rsu_tx_start()
2805 device_printf(sc->sc_dev, in rsu_tx_start()
2819 qos = ((const struct ieee80211_qosframe *)wh)->i_qos[0]; in rsu_tx_start()
2821 /* Non-QoS TID */ in rsu_tx_start()
2822 /* XXX TODO: tid=0 for non-qos TID? */ in rsu_tx_start()
2850 txd = (struct r92s_tx_desc *)data->buf; in rsu_tx_start()
2853 txd->txdw0 |= htole32( in rsu_tx_start()
2854 SM(R92S_TXDW0_PKTLEN, m0->m_pkthdr.len) | in rsu_tx_start()
2859 txd->txdw1 |= htole32( in rsu_tx_start()
2863 txd->txdw1 |= htole32(R92S_TXDW1_NONQOS); in rsu_tx_start()
2864 if (k != NULL && !(k->wk_flags & IEEE80211_KEY_SWENCRYPT)) { in rsu_tx_start()
2865 switch (k->wk_cipher->ic_cipher) { in rsu_tx_start()
2878 txd->txdw1 |= htole32( in rsu_tx_start()
2880 SM(R92S_TXDW1_KEYIDX, k->wk_keyix)); in rsu_tx_start()
2885 * A-MPDU and non-AMPDU candidates; the firmware will in rsu_tx_start()
2890 txd->txdw2 |= htole32(R92S_TXDW2_BMCAST); in rsu_tx_start()
2894 txd->txdw2 |= htole32(R92S_TXDW2_RTY_LMT_ENA); in rsu_tx_start()
2895 txd->txdw2 |= htole32(SM(R92S_TXDW2_RTY_LMT, tp->maxretry)); in rsu_tx_start()
2901 txd->txdw5 |= htole32(SM(R92S_TXDW5_DATARATE_FB_LMT, 0x1f)); in rsu_tx_start()
2902 txd->txdw5 |= htole32(SM(R92S_TXDW5_DATARATE, ridx)); in rsu_tx_start()
2903 txd->txdw4 |= htole32(R92S_TXDW4_DRVRATE); in rsu_tx_start()
2913 txd->txdw3 |= htole32(SM(R92S_TXDW3_SEQ, prio)); in rsu_tx_start()
2916 struct rsu_tx_radiotap_header *tap = &sc->sc_txtap; in rsu_tx_start()
2918 tap->wt_flags = 0; in rsu_tx_start()
2922 xferlen = sizeof(*txd) + m0->m_pkthdr.len; in rsu_tx_start()
2924 m_copydata(m0, 0, m0->m_pkthdr.len, (caddr_t)&txd[1]); in rsu_tx_start()
2926 data->buflen = xferlen; in rsu_tx_start()
2927 data->ni = ni; in rsu_tx_start()
2928 data->m = m0; in rsu_tx_start()
2929 STAILQ_INSERT_TAIL(&sc->sc_tx_pending[which], data, next); in rsu_tx_start()
2932 usbd_transfer_start(sc->sc_xfer[which]); in rsu_tx_start()
2939 struct rsu_softc *sc = ic->ic_softc; in rsu_transmit()
2943 if (!sc->sc_running) { in rsu_transmit()
2952 error = mbufq_enqueue(&sc->sc_snd, m); in rsu_transmit()
2976 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in rsu_drain_mbufq()
2977 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in rsu_drain_mbufq()
2978 m->m_pkthdr.rcvif = NULL; in rsu_drain_mbufq()
2993 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in _rsu_start()
2998 mbufq_prepend(&sc->sc_snd, m); in _rsu_start()
3002 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in _rsu_start()
3003 m->m_pkthdr.rcvif = NULL; in _rsu_start()
3008 if_inc_counter(ni->ni_vap->iv_ifp, in _rsu_start()
3022 taskqueue_enqueue(taskqueue_thread, &sc->tx_task); in rsu_start()
3028 struct rsu_softc *sc = ic->ic_softc; in rsu_ioctl_net()
3039 rxmask = ifr->ifr_reqcap & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6); in rsu_ioctl_net()
3043 if (sc->sc_rx_checksum_enable && in rsu_ioctl_net()
3046 sc->sc_rx_checksum_enable = 0; in rsu_ioctl_net()
3048 } else if (!sc->sc_rx_checksum_enable && rxmask != 0) { in rsu_ioctl_net()
3050 sc->sc_rx_checksum_enable = 1; in rsu_ioctl_net()
3060 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { in rsu_ioctl_net()
3061 if_t ifp = vap->iv_ifp; in rsu_ioctl_net()
3081 struct rsu_softc *sc = ic->ic_softc; in rsu_parent()
3083 if (ic->ic_nrunning > 0) { in rsu_parent()
3087 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in rsu_parent()
3096 * Power on sequence for A-cut adapters.
3178 * Power on sequence for B-cut and C-cut adapters.
3326 /* Firmware - tell it to switch things off */ in rsu_power_off()
3342 txd = (struct r92s_tx_desc *)data->buf; in rsu_fw_loadsection()
3344 if (len <= RSU_TXBUFSZ - sizeof(*txd)) { in rsu_fw_loadsection()
3346 txd->txdw0 |= htole32(R92S_TXDW0_LINIP); in rsu_fw_loadsection()
3349 mlen = RSU_TXBUFSZ - sizeof(*txd); in rsu_fw_loadsection()
3350 txd->txdw0 |= htole32(SM(R92S_TXDW0_PKTLEN, mlen)); in rsu_fw_loadsection()
3352 data->buflen = sizeof(*txd) + mlen; in rsu_fw_loadsection()
3356 STAILQ_INSERT_TAIL(&sc->sc_tx_pending[which], data, next); in rsu_fw_loadsection()
3358 len -= mlen; in rsu_fw_loadsection()
3360 usbd_transfer_start(sc->sc_xfer[which]); in rsu_fw_loadsection()
3371 struct ieee80211com *ic = &sc->sc_ic; in rsu_load_firmware()
3388 if ((fw = firmware_get("rsu-rtl8712fw")) == NULL) { in rsu_load_firmware()
3389 device_printf(sc->sc_dev, in rsu_load_firmware()
3390 "%s: failed load firmware of file rsu-rtl8712fw\n", in rsu_load_firmware()
3396 size = fw->datasize; in rsu_load_firmware()
3398 device_printf(sc->sc_dev, "firmware too short\n"); in rsu_load_firmware()
3402 hdr = (const struct r92s_fw_hdr *)fw->data; in rsu_load_firmware()
3403 if (hdr->signature != htole16(0x8712) && in rsu_load_firmware()
3404 hdr->signature != htole16(0x8192)) { in rsu_load_firmware()
3405 device_printf(sc->sc_dev, in rsu_load_firmware()
3407 le16toh(hdr->signature)); in rsu_load_firmware()
3411 RSU_DPRINTF(sc, RSU_DEBUG_FW, "FW V%d %02x-%02x %02x:%02x\n", in rsu_load_firmware()
3412 le16toh(hdr->version), hdr->month, hdr->day, hdr->hour, in rsu_load_firmware()
3413 hdr->minute); in rsu_load_firmware()
3416 if (hdr->privsz != htole32(sizeof(dmem))) { in rsu_load_firmware()
3417 device_printf(sc->sc_dev, "unsupported firmware image\n"); in rsu_load_firmware()
3422 imemsz = le32toh(hdr->imemsz); in rsu_load_firmware()
3423 ememsz = le32toh(hdr->sramsz); in rsu_load_firmware()
3425 if (imemsz > (size_t)(size - sizeof(*hdr)) || in rsu_load_firmware()
3426 ememsz > (size_t)(size - sizeof(*hdr) - imemsz)) { in rsu_load_firmware()
3427 device_printf(sc->sc_dev, "firmware too short\n"); in rsu_load_firmware()
3437 device_printf(sc->sc_dev, in rsu_load_firmware()
3449 device_printf(sc->sc_dev, "timeout waiting for IMEM transfer\n"); in rsu_load_firmware()
3456 device_printf(sc->sc_dev, in rsu_load_firmware()
3468 device_printf(sc->sc_dev, "timeout waiting for EMEM transfer\n"); in rsu_load_firmware()
3476 device_printf(sc->sc_dev, "could not enable system clock\n"); in rsu_load_firmware()
3483 device_printf(sc->sc_dev, in rsu_load_firmware()
3495 device_printf(sc->sc_dev, in rsu_load_firmware()
3504 dmem.nendpoints = sc->sc_nendpoints; in rsu_load_firmware()
3505 dmem.chip_version = sc->cut; in rsu_load_firmware()
3506 dmem.rf_config = sc->sc_rftype; in rsu_load_firmware()
3510 dmem.bw40_en = !! (ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40); in rsu_load_firmware()
3513 dmem.ampdu_en = !! (sc->sc_ht); in rsu_load_firmware()
3514 dmem.agg_offload = !! (sc->sc_ht); in rsu_load_firmware()
3521 device_printf(sc->sc_dev, in rsu_load_firmware()
3532 device_printf(sc->sc_dev, "timeout waiting for %s transfer\n", in rsu_load_firmware()
3544 device_printf(sc->sc_dev, in rsu_load_firmware()
3558 struct ieee80211com *ic = ni->ni_ic; in rsu_raw_xmit()
3559 struct rsu_softc *sc = ic->ic_softc; in rsu_raw_xmit()
3563 if (!sc->sc_running) { in rsu_raw_xmit()
3599 if (sc->sc_rx_checksum_enable) in rsu_rxfilter_init()
3618 struct ieee80211com *ic = &sc->sc_ic; in rsu_rxfilter_refresh()
3626 if (sc->sc_vap_is_running) in rsu_rxfilter_refresh()
3631 if (ic->ic_opmode == IEEE80211_M_MONITOR) { in rsu_rxfilter_refresh()
3633 if (sc->sc_vap_is_running) in rsu_rxfilter_refresh()
3640 if (ic->ic_promisc == 0 && ic->ic_opmode != IEEE80211_M_MONITOR) in rsu_rxfilter_refresh()
3649 struct ieee80211com *ic = &sc->sc_ic; in rsu_init()
3650 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in rsu_init()
3657 if (sc->sc_running) { in rsu_init()
3669 if (sc->cut == 1) in rsu_init()
3697 IEEE80211_ADDR_COPY(macaddr, vap ? vap->iv_myaddr : ic->ic_macaddr); in rsu_init()
3701 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(2000)); in rsu_init()
3709 device_printf(sc->sc_dev, "could not set MAC address\n"); in rsu_init()
3719 device_printf(sc->sc_dev, "could not set PS mode\n"); in rsu_init()
3728 sc->sc_extra_scan = 0; in rsu_init()
3729 usbd_transfer_start(sc->sc_xfer[RSU_BULK_RX]); in rsu_init()
3732 sc->sc_running = 1; in rsu_init()
3739 usbd_transfer_stop(sc->sc_xfer[i]); in rsu_init()
3751 if (!sc->sc_running) { in rsu_stop()
3756 sc->sc_running = 0; in rsu_stop()
3757 sc->sc_vap_is_running = 0; in rsu_stop()
3758 sc->sc_calibrating = 0; in rsu_stop()
3759 taskqueue_cancel_timeout(taskqueue_thread, &sc->calib_task, NULL); in rsu_stop()
3760 taskqueue_cancel(taskqueue_thread, &sc->tx_task, NULL); in rsu_stop()
3769 memset(sc->free_keys_bmap, 0, sizeof(sc->free_keys_bmap)); in rsu_stop()
3770 memset(sc->keys_bmap, 0, sizeof(sc->keys_bmap)); in rsu_stop()
3773 usbd_transfer_stop(sc->sc_xfer[i]); in rsu_stop()
3788 //usb_pause_mtx(&sc->sc_mtx, hz / 1000); in rsu_ms_delay()