Lines Matching +full:touch +full:- +full:timeout +full:- +full:ms
3 /*-
23 * o tx a-mpdu
25 * o power-save operation
79 device_printf((_sc)->sc_dev, __VA_ARGS__); \
290 /* XXX hard-coded */
316 .timeout = RSU_TX_TIMEOUT
329 .timeout = RSU_TX_TIMEOUT
342 .timeout = RSU_TX_TIMEOUT
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.
383 struct rsu_softc *sc = ni->ni_ic->ic_softc; in rsu_ampdu_enable()
393 req.tid = htole32(tap->txa_tid); in rsu_ampdu_enable()
396 if (ieee80211_ampdu_tx_request_ext(ni, tap->txa_tid) != 1) in rsu_ampdu_enable()
402 tap->txa_tid); in rsu_ampdu_enable()
408 (void) ieee80211_ampdu_tx_request_active_ext(ni, tap->txa_tid, 0); in rsu_ampdu_enable()
414 (void) ieee80211_ampdu_tx_request_active_ext(ni, tap->txa_tid, 1); in rsu_ampdu_enable()
433 struct ieee80211com *ic = &sc->sc_ic; in rsu_attach()
440 sc->sc_udev = uaa->device; in rsu_attach()
441 sc->sc_dev = self; in rsu_attach()
442 sc->sc_rx_checksum_enable = 1; in rsu_attach()
444 sc->sc_ht = !! (USB_GET_DRIVER_INFO(uaa) & RSU_HT_SUPPORTED); in rsu_attach()
447 iface = usbd_get_iface(sc->sc_udev, 0); in rsu_attach()
448 sc->sc_nendpoints = iface->idesc->bNumEndpoints; in rsu_attach()
450 /* Endpoints are hard-coded for now, so enforce 4-endpoint only */ in rsu_attach()
451 if (sc->sc_nendpoints != 4) { in rsu_attach()
452 device_printf(sc->sc_dev, in rsu_attach()
453 "the driver currently only supports 4-endpoint devices\n"); in rsu_attach()
457 mtx_init(&sc->sc_mtx, device_get_nameunit(self), MTX_NETWORK_LOCK, in rsu_attach()
460 TIMEOUT_TASK_INIT(taskqueue_thread, &sc->calib_task, 0, in rsu_attach()
462 TASK_INIT(&sc->del_key_task, 0, rsu_delete_key_pair_cb, sc); in rsu_attach()
463 TASK_INIT(&sc->tx_task, 0, rsu_tx_task, sc); in rsu_attach()
464 mbufq_init(&sc->sc_snd, ifqmaxlen); in rsu_attach()
469 device_printf(sc->sc_dev, "could not allocate Rx buffers\n"); in rsu_attach()
475 device_printf(sc->sc_dev, "could not allocate Tx buffers\n"); in rsu_attach()
481 error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_xfer, in rsu_attach()
482 rsu_config, RSU_N_TRANSFER, sc, &sc->sc_mtx); in rsu_attach()
484 device_printf(sc->sc_dev, in rsu_attach()
491 sc->cut = MS(rsu_read_4(sc, R92S_PMC_FSM), R92S_PMC_FSM_CUT); in rsu_attach()
492 if (sc->cut != 3) in rsu_attach()
493 sc->cut = (sc->cut >> 1) + 1; in rsu_attach()
502 switch (sc->rom[84]) { in rsu_attach()
504 sc->sc_rftype = RTL8712_RFCONFIG_1T1R; in rsu_attach()
505 sc->sc_nrxstream = 1; in rsu_attach()
506 sc->sc_ntxstream = 1; in rsu_attach()
510 sc->sc_rftype = RTL8712_RFCONFIG_1T2R; in rsu_attach()
511 sc->sc_nrxstream = 2; in rsu_attach()
512 sc->sc_ntxstream = 1; in rsu_attach()
516 sc->sc_rftype = RTL8712_RFCONFIG_2T2R; in rsu_attach()
517 sc->sc_nrxstream = 2; in rsu_attach()
518 sc->sc_ntxstream = 2; in rsu_attach()
522 sc->sc_rftype = RTL8712_RFCONFIG_1T2R; in rsu_attach()
523 sc->sc_nrxstream = 2; in rsu_attach()
524 sc->sc_ntxstream = 1; in rsu_attach()
528 device_printf(sc->sc_dev, in rsu_attach()
531 sc->rom[84]); in rsu_attach()
535 IEEE80211_ADDR_COPY(ic->ic_macaddr, &sc->rom[0x12]); in rsu_attach()
536 device_printf(self, "MAC/BB RTL8712 cut %d %s\n", sc->cut, rft); in rsu_attach()
538 ic->ic_softc = sc; in rsu_attach()
539 ic->ic_name = device_get_nameunit(self); in rsu_attach()
540 ic->ic_phytype = IEEE80211_T_OFDM; /* Not only, but not used. */ in rsu_attach()
541 ic->ic_opmode = IEEE80211_M_STA; /* Default to BSS mode. */ in rsu_attach()
544 ic->ic_caps = in rsu_attach()
555 ic->ic_cryptocaps = in rsu_attach()
561 if (sc->sc_ht) { in rsu_attach()
562 device_printf(sc->sc_dev, "%s: enabling 11n\n", __func__); in rsu_attach()
565 ic->ic_htcaps = IEEE80211_HTC_HT | in rsu_attach()
572 ic->ic_htcaps |= IEEE80211_HTCAP_CHWIDTH40; in rsu_attach()
575 ic->ic_txstream = sc->sc_ntxstream; in rsu_attach()
576 ic->ic_rxstream = sc->sc_nrxstream; in rsu_attach()
578 ic->ic_flags_ext |= IEEE80211_FEXT_SCAN_OFFLOAD; in rsu_attach()
580 rsu_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, in rsu_attach()
581 ic->ic_channels); in rsu_attach()
584 ic->ic_raw_xmit = rsu_raw_xmit; in rsu_attach()
585 ic->ic_scan_start = rsu_scan_start; in rsu_attach()
586 ic->ic_scan_end = rsu_scan_end; in rsu_attach()
587 ic->ic_getradiocaps = rsu_getradiocaps; in rsu_attach()
588 ic->ic_set_channel = rsu_set_channel; in rsu_attach()
589 ic->ic_scan_curchan = rsu_scan_curchan; in rsu_attach()
590 ic->ic_scan_mindwell = rsu_scan_mindwell; in rsu_attach()
591 ic->ic_vap_create = rsu_vap_create; in rsu_attach()
592 ic->ic_vap_delete = rsu_vap_delete; in rsu_attach()
593 ic->ic_update_promisc = rsu_update_promisc; in rsu_attach()
594 ic->ic_update_mcast = rsu_update_mcast; in rsu_attach()
595 ic->ic_ioctl = rsu_ioctl_net; in rsu_attach()
596 ic->ic_parent = rsu_parent; in rsu_attach()
597 ic->ic_transmit = rsu_transmit; in rsu_attach()
598 ic->ic_send_mgmt = rsu_send_mgmt; in rsu_attach()
599 ic->ic_update_chw = rsu_update_chw; in rsu_attach()
600 ic->ic_ampdu_enable = rsu_ampdu_enable; in rsu_attach()
601 ic->ic_wme.wme_update = rsu_wme_update; in rsu_attach()
603 ieee80211_radiotap_attach(ic, &sc->sc_txtap.wt_ihdr, in rsu_attach()
604 sizeof(sc->sc_txtap), RSU_TX_RADIOTAP_PRESENT, in rsu_attach()
605 &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap), in rsu_attach()
614 usbd_transfer_unsetup(sc->sc_xfer, RSU_N_TRANSFER); in rsu_attach()
616 mtx_destroy(&sc->sc_mtx); in rsu_attach()
624 struct ieee80211com *ic = &sc->sc_ic; in rsu_detach()
628 usbd_transfer_unsetup(sc->sc_xfer, RSU_N_TRANSFER); in rsu_detach()
643 taskqueue_drain_timeout(taskqueue_thread, &sc->calib_task); in rsu_detach()
644 taskqueue_drain(taskqueue_thread, &sc->del_key_task); in rsu_detach()
645 taskqueue_drain(taskqueue_thread, &sc->tx_task); in rsu_detach()
648 mtx_destroy(&sc->sc_mtx); in rsu_detach()
662 while (ntries--) { in rsu_do_request()
663 err = usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx, in rsu_do_request()
664 req, data, 0, NULL, 250 /* ms */); in rsu_do_request()
682 struct rsu_softc *sc = ic->ic_softc; in rsu_vap_create()
687 if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */ in rsu_vap_create()
691 vap = &uvp->vap; in rsu_vap_create()
700 ifp = vap->iv_ifp; in rsu_vap_create()
703 if (sc->sc_rx_checksum_enable) in rsu_vap_create()
708 uvp->newstate = vap->iv_newstate; in rsu_vap_create()
710 vap->iv_newstate = rsu_monitor_newstate; in rsu_vap_create()
712 vap->iv_newstate = rsu_newstate; in rsu_vap_create()
713 vap->iv_key_alloc = rsu_key_alloc; in rsu_vap_create()
714 vap->iv_key_set = rsu_key_set; in rsu_vap_create()
715 vap->iv_key_delete = rsu_key_delete; in rsu_vap_create()
718 vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_16; in rsu_vap_create()
719 vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_32K; in rsu_vap_create()
724 ic->ic_opmode = opmode; in rsu_vap_create()
741 struct rsu_softc *sc = ic->ic_softc; in rsu_scan_start()
742 struct ieee80211_scan_state *ss = ic->ic_scan; in rsu_scan_start()
743 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in rsu_scan_start()
748 sc->sc_active_scan = !!(ss->ss_flags & IEEE80211_SCAN_ACTIVE); in rsu_scan_start()
749 /* XXX TODO: force awake if in network-sleep? */ in rsu_scan_start()
750 error = rsu_site_survey(sc, ss->ss_nssid > 0 ? &ss->ss_ssid[0] : NULL); in rsu_scan_start()
753 device_printf(sc->sc_dev, in rsu_scan_start()
769 struct rsu_softc *sc = ic->ic_softc; in rsu_getradiocaps()
776 if (sc->sc_ht) in rsu_getradiocaps()
779 bands, (ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40) ? in rsu_getradiocaps()
786 struct rsu_softc *sc = ic->ic_softc; in rsu_set_channel()
792 if (ic->ic_opmode == IEEE80211_M_MONITOR) { in rsu_set_channel()
796 cmd.channel = IEEE80211_CHAN2IEEE(ic->ic_curchan); in rsu_set_channel()
802 device_printf(sc->sc_dev, in rsu_set_channel()
831 struct rsu_softc *sc = ic->ic_softc; in rsu_update_promisc()
834 if (sc->sc_running) in rsu_update_promisc()
852 pos ^= (mask >> (i * 8 + j - 1)); in rsu_get_multi_pos()
874 struct ieee80211com *ic = &sc->sc_ic; in rsu_set_multi()
880 if (ic->ic_allmulti == 0) { in rsu_set_multi()
887 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) in rsu_set_multi()
888 if_foreach_llmaddr(vap->iv_ifp, rsu_hash_maddr, &mfilt); in rsu_set_multi()
902 struct rsu_softc *sc = ic->ic_softc; in rsu_update_mcast()
905 if (sc->sc_running) in rsu_update_mcast()
918 dp->sc = sc; in rsu_alloc_list()
919 dp->m = NULL; in rsu_alloc_list()
920 dp->buf = malloc(maxsz, M_USBDEV, M_NOWAIT); in rsu_alloc_list()
921 if (dp->buf == NULL) { in rsu_alloc_list()
922 device_printf(sc->sc_dev, in rsu_alloc_list()
927 dp->ni = NULL; in rsu_alloc_list()
941 error = rsu_alloc_list(sc, sc->sc_rx, RSU_RX_LIST_COUNT, in rsu_alloc_rx_list()
946 STAILQ_INIT(&sc->sc_rx_active); in rsu_alloc_rx_list()
947 STAILQ_INIT(&sc->sc_rx_inactive); in rsu_alloc_rx_list()
950 STAILQ_INSERT_HEAD(&sc->sc_rx_inactive, &sc->sc_rx[i], next); in rsu_alloc_rx_list()
960 error = rsu_alloc_list(sc, sc->sc_tx, RSU_TX_LIST_COUNT, in rsu_alloc_tx_list()
965 STAILQ_INIT(&sc->sc_tx_inactive); in rsu_alloc_tx_list()
968 STAILQ_INIT(&sc->sc_tx_active[i]); in rsu_alloc_tx_list()
969 STAILQ_INIT(&sc->sc_tx_pending[i]); in rsu_alloc_tx_list()
973 STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, &sc->sc_tx[i], next); in rsu_alloc_tx_list()
985 STAILQ_INIT(&sc->sc_tx_inactive); in rsu_free_tx_list()
988 STAILQ_INIT(&sc->sc_tx_active[i]); in rsu_free_tx_list()
989 STAILQ_INIT(&sc->sc_tx_pending[i]); in rsu_free_tx_list()
992 rsu_free_list(sc, sc->sc_tx, RSU_TX_LIST_COUNT); in rsu_free_tx_list()
999 STAILQ_INIT(&sc->sc_rx_inactive); in rsu_free_rx_list()
1000 STAILQ_INIT(&sc->sc_rx_active); in rsu_free_rx_list()
1002 rsu_free_list(sc, sc->sc_rx, RSU_RX_LIST_COUNT); in rsu_free_rx_list()
1013 if (dp->buf != NULL) { in rsu_free_list()
1014 free(dp->buf, M_USBDEV); in rsu_free_list()
1015 dp->buf = NULL; in rsu_free_list()
1017 if (dp->ni != NULL) { in rsu_free_list()
1018 ieee80211_free_node(dp->ni); in rsu_free_list()
1019 dp->ni = NULL; in rsu_free_list()
1029 bf = STAILQ_FIRST(&sc->sc_tx_inactive); in _rsu_getbuf()
1031 STAILQ_REMOVE_HEAD(&sc->sc_tx_inactive, next); in _rsu_getbuf()
1056 STAILQ_INSERT_TAIL(&sc->sc_tx_inactive, bf, next); in rsu_freebuf()
1168 return (MS(reg, R92S_EFUSE_CTRL_DATA)); in rsu_efuse_read_1()
1171 device_printf(sc->sc_dev, in rsu_efuse_read_1()
1179 uint8_t *rom = sc->rom; in rsu_read_rom()
1197 memset(&sc->rom, 0xff, sizeof(sc->rom)); in rsu_read_rom()
1220 for (i = 0; i < sizeof(sc->rom); i++) in rsu_read_rom()
1245 memset(data->buf, '\0', RSU_TXBUFSZ); in rsu_fw_cmd()
1247 /* Round-up command length to a multiple of 8 bytes. */ in rsu_fw_cmd()
1253 memset(data->buf, 0, xferlen); in rsu_fw_cmd()
1256 txd = (struct r92s_tx_desc *)data->buf; in rsu_fw_cmd()
1257 txd->txdw0 = htole32( in rsu_fw_cmd()
1261 txd->txdw1 = htole32(SM(R92S_TXDW1_QSEL, R92S_TXDW1_QSEL_H2C)); in rsu_fw_cmd()
1265 cmd->len = htole16(cmdsz); in rsu_fw_cmd()
1266 cmd->code = code; in rsu_fw_cmd()
1267 cmd->seq = sc->cmd_seq; in rsu_fw_cmd()
1268 sc->cmd_seq = (sc->cmd_seq + 1) & 0x7f; in rsu_fw_cmd()
1276 data->buflen = xferlen; in rsu_fw_cmd()
1277 STAILQ_INSERT_TAIL(&sc->sc_tx_pending[which], data, next); in rsu_fw_cmd()
1278 usbd_transfer_start(sc->sc_xfer[which]); in rsu_fw_cmd()
1308 sc->sc_currssi = rsu_read_4(sc, R92S_IOCMD_DATA); in rsu_calib_task()
1310 __func__, sc->sc_currssi, in rsu_calib_task()
1311 rsu_hwrssi_to_rssi(sc, sc->sc_currssi)); in rsu_calib_task()
1313 if (sc->sc_calibrating) in rsu_calib_task()
1314 taskqueue_enqueue_timeout(taskqueue_thread, &sc->calib_task, hz); in rsu_calib_task()
1340 * For now - it's on in all states except RUN, and
1360 if (sc->sc_curpwrstate == state) in rsu_set_fw_power_state()
1375 cmd.bcn_pass_time = 5; /* in 100mS usb.c, linux/rtlwifi */ in rsu_set_fw_power_state()
1381 device_printf(sc->sc_dev, "%s: unknown ps mode (%d)\n", in rsu_set_fw_power_state()
1392 sc->sc_curpwrstate = state; in rsu_set_fw_power_state()
1408 struct ieee80211com *ic = vap->iv_ic; in rsu_monitor_newstate()
1409 struct rsu_softc *sc = ic->ic_softc; in rsu_monitor_newstate()
1412 if (vap->iv_state != nstate) { in rsu_monitor_newstate()
1418 sc->sc_vap_is_running = 0; in rsu_monitor_newstate()
1422 sc->sc_vap_is_running = 1; in rsu_monitor_newstate()
1435 return (uvp->newstate(vap, nstate, arg)); in rsu_monitor_newstate()
1442 struct ieee80211com *ic = vap->iv_ic; in rsu_newstate()
1443 struct rsu_softc *sc = ic->ic_softc; in rsu_newstate()
1449 ostate = vap->iv_state; in rsu_newstate()
1450 RSU_DPRINTF(sc, RSU_DEBUG_STATE, "%s: %s -> %s\n", in rsu_newstate()
1459 sc->sc_calibrating = 0; in rsu_newstate()
1463 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(10)); in rsu_newstate()
1466 taskqueue_drain_timeout(taskqueue_thread, &sc->calib_task); in rsu_newstate()
1467 taskqueue_drain(taskqueue_thread, &sc->tx_task); in rsu_newstate()
1471 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(10)); in rsu_newstate()
1474 sc->sc_vap_is_running = 0; in rsu_newstate()
1478 if (sc->sc_running) in rsu_newstate()
1487 ni = ieee80211_ref_node(vap->iv_bss); in rsu_newstate()
1492 device_printf(sc->sc_dev, in rsu_newstate()
1500 ni = ieee80211_ref_node(vap->iv_bss); in rsu_newstate()
1501 rs = &ni->ni_rates; in rsu_newstate()
1503 ni->ni_txrate = rs->rs_rates[rs->rs_nrates - 1]; in rsu_newstate()
1512 sc->sc_calibrating = 1; in rsu_newstate()
1514 taskqueue_enqueue_timeout(taskqueue_thread, &sc->calib_task, in rsu_newstate()
1519 return (uvp->newstate(vap, nstate, arg)); in rsu_newstate()
1526 struct rsu_softc *sc = vap->iv_ic->ic_softc; in rsu_key_alloc()
1533 if (vap->iv_opmode != IEEE80211_M_STA) { in rsu_key_alloc()
1537 k->wk_flags |= IEEE80211_KEY_SWCRYPT; in rsu_key_alloc()
1544 if (isset(sc->keys_bmap, *keyix)) { in rsu_key_alloc()
1545 device_printf(sc->sc_dev, in rsu_key_alloc()
1551 setbit(sc->keys_bmap, *keyix); in rsu_key_alloc()
1564 struct rsu_softc *sc = vap->iv_ic->ic_softc; in rsu_process_key()
1567 if (k->wk_flags & IEEE80211_KEY_SWCRYPT) { in rsu_process_key()
1574 KASSERT(k->wk_keyix < nitems(sc->group_keys), in rsu_process_key()
1575 ("keyix %u > %zu\n", k->wk_keyix, nitems(sc->group_keys))); in rsu_process_key()
1578 sc->group_keys[k->wk_keyix] = (set ? k : NULL); in rsu_process_key()
1579 if (!sc->sc_running) { in rsu_process_key()
1588 ret = rsu_delete_key(sc, k->wk_keyix); in rsu_process_key()
1596 taskqueue_drain(taskqueue_thread, &sc->del_key_task); in rsu_process_key()
1603 setbit(sc->free_keys_bmap, k->wk_keyix); in rsu_process_key()
1607 taskqueue_enqueue(taskqueue_thread, &sc->del_key_task); in rsu_process_key()
1637 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(1)); in rsu_cam_read()
1640 device_printf(sc->sc_dev, in rsu_cam_read()
1668 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(1)); in rsu_key_check()
1672 device_printf(sc->sc_dev, in rsu_key_check()
1680 device_printf(sc->sc_dev, in rsu_key_check()
1703 device_printf(sc->sc_dev, "unknown cipher %d\n", cipher); in rsu_crypto_mode()
1718 algo = rsu_crypto_mode(sc, k->wk_cipher->ic_cipher, k->wk_keylen); in rsu_set_key_group()
1724 key.cam_id = k->wk_keyix; in rsu_set_key_group()
1725 key.grpkey = (k->wk_flags & IEEE80211_KEY_GROUP) != 0; in rsu_set_key_group()
1726 memcpy(key.key, k->wk_key, MIN(k->wk_keylen, sizeof(key.key))); in rsu_set_key_group()
1731 k->wk_cipher->ic_cipher, key.algo, k->wk_flags, k->wk_keylen, in rsu_set_key_group()
1732 ether_sprintf(k->wk_macaddr)); in rsu_set_key_group()
1736 device_printf(sc->sc_dev, in rsu_set_key_group()
1742 return (rsu_key_check(sc, k->wk_keyix, 1)); in rsu_set_key_group()
1754 if (!sc->sc_running) in rsu_set_key_pair()
1758 algo = rsu_crypto_mode(sc, k->wk_cipher->ic_cipher, k->wk_keylen); in rsu_set_key_pair()
1764 memcpy(key.macaddr, k->wk_macaddr, sizeof(key.macaddr)); in rsu_set_key_pair()
1765 memcpy(key.key, k->wk_key, MIN(k->wk_keylen, sizeof(key.key))); in rsu_set_key_pair()
1769 __func__, k->wk_keyix, k->wk_cipher->ic_cipher, key.algo, in rsu_set_key_pair()
1770 k->wk_flags, k->wk_keylen, ether_sprintf(key.macaddr)); in rsu_set_key_pair()
1774 device_printf(sc->sc_dev, in rsu_set_key_pair()
1780 return (rsu_key_check(sc, k->wk_keyix, 1)); in rsu_set_key_pair()
1788 for (i = 0; i < nitems(sc->group_keys); i++) { in rsu_reinit_static_keys()
1789 if (sc->group_keys[i] != NULL) { in rsu_reinit_static_keys()
1790 error = rsu_set_key_group(sc, sc->group_keys[i]); in rsu_reinit_static_keys()
1792 device_printf(sc->sc_dev, in rsu_reinit_static_keys()
1812 if (!sc->sc_running) in rsu_delete_key()
1820 clrbit(sc->keys_bmap, keyix); in rsu_delete_key()
1832 device_printf(sc->sc_dev, in rsu_delete_key()
1838 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(5)); in rsu_delete_key()
1847 clrbit(sc->keys_bmap, keyix); in rsu_delete_key()
1860 if (isset(sc->free_keys_bmap, i)) { in rsu_delete_key_pair_cb()
1871 clrbit(sc->free_keys_bmap, i); in rsu_delete_key_pair_cb()
1874 i = IEEE80211_WEP_NKID - 1; in rsu_delete_key_pair_cb()
1890 if (sc->sc_active_scan) in rsu_site_survey()
1895 sc->sc_extra_scan = 1; in rsu_site_survey()
1896 cmd.ssidlen = htole32(ssid->len); in rsu_site_survey()
1897 memcpy(cmd.ssid, ssid->ssid, ssid->len); in rsu_site_survey()
1901 device_printf(sc->sc_dev, in rsu_site_survey()
1917 struct ieee80211com *ic = &sc->sc_ic; in rsu_join_bss()
1918 struct ieee80211vap *vap = ni->ni_vap; in rsu_join_bss()
1939 if (vap->iv_flags & IEEE80211_F_WPA) { in rsu_join_bss()
1941 auth.dot1x = (ni->ni_authmode == IEEE80211_AUTH_8021X); in rsu_join_bss()
1953 IEEE80211_ADDR_COPY(bss->macaddr, ni->ni_bssid); in rsu_join_bss()
1954 bss->ssid.ssidlen = htole32(ni->ni_esslen); in rsu_join_bss()
1955 memcpy(bss->ssid.ssid, ni->ni_essid, ni->ni_esslen); in rsu_join_bss()
1956 if (vap->iv_flags & (IEEE80211_F_PRIVACY | IEEE80211_F_WPA)) in rsu_join_bss()
1957 bss->privacy = htole32(1); in rsu_join_bss()
1958 bss->rssi = htole32(ni->ni_avgrssi); in rsu_join_bss()
1959 if (ic->ic_curmode == IEEE80211_MODE_11B) in rsu_join_bss()
1960 bss->networktype = htole32(NDIS802_11DS); in rsu_join_bss()
1962 bss->networktype = htole32(NDIS802_11OFDM24); in rsu_join_bss()
1963 bss->config.len = htole32(sizeof(bss->config)); in rsu_join_bss()
1964 bss->config.bintval = htole32(ni->ni_intval); in rsu_join_bss()
1965 bss->config.dsconfig = htole32(ieee80211_chan2ieee(ic, ni->ni_chan)); in rsu_join_bss()
1966 bss->inframode = htole32(NDIS802_11INFRASTRUCTURE); in rsu_join_bss()
1968 memcpy(bss->supprates, ni->ni_rates.rs_rates, in rsu_join_bss()
1969 ni->ni_rates.rs_nrates); in rsu_join_bss()
1972 memcpy(&fixed->tstamp, ni->ni_tstamp.data, 8); in rsu_join_bss()
1973 fixed->bintval = htole16(ni->ni_intval); in rsu_join_bss()
1974 fixed->capabilities = htole16(ni->ni_capinfo); in rsu_join_bss()
1980 if ((ic->ic_flags & IEEE80211_F_WME) && in rsu_join_bss()
1981 (ni->ni_ies.wme_ie != NULL)) in rsu_join_bss()
1982 frm = ieee80211_add_wme_info(frm, &ic->ic_wme, ni); in rsu_join_bss()
1983 if (ni->ni_flags & IEEE80211_NODE_HT) { in rsu_join_bss()
1987 bss->ieslen = htole32(frm - (uint8_t *)fixed); in rsu_join_bss()
1988 bss->len = htole32(((frm - buf) + 3) & ~3); in rsu_join_bss()
1992 ether_sprintf(bss->macaddr), le32toh(bss->config.dsconfig)); in rsu_join_bss()
1999 uint32_t zero = 0; /* :-) */ in rsu_disconnect()
2030 struct ieee80211com *ic = &sc->sc_ic; in rsu_event_survey()
2041 ieslen = le32toh(bss->ieslen); in rsu_event_survey()
2043 if (__predict_false(ieslen > (uint32_t)(len - sizeof(*bss)))) in rsu_event_survey()
2050 ether_sprintf(bss->macaddr), ieslen, in rsu_event_survey()
2051 le32toh(bss->config.dsconfig), le32toh(bss->inframode), in rsu_event_survey()
2052 le32toh(bss->networktype), le32toh(bss->privacy), in rsu_event_survey()
2053 le32toh(bss->rssi)); in rsu_event_survey()
2057 if (__predict_false(ieslen > (size_t)(MCLBYTES - sizeof(*wh)))) in rsu_event_survey()
2064 wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT | in rsu_event_survey()
2066 wh->i_fc[1] = IEEE80211_FC1_DIR_NODS; in rsu_event_survey()
2067 USETW(wh->i_dur, 0); in rsu_event_survey()
2068 IEEE80211_ADDR_COPY(wh->i_addr1, ieee80211broadcastaddr); in rsu_event_survey()
2069 IEEE80211_ADDR_COPY(wh->i_addr2, bss->macaddr); in rsu_event_survey()
2070 IEEE80211_ADDR_COPY(wh->i_addr3, bss->macaddr); in rsu_event_survey()
2071 *(uint16_t *)wh->i_seq = 0; in rsu_event_survey()
2075 m->m_pkthdr.len = m->m_len = pktlen; in rsu_event_survey()
2082 rxs.c_ieee = le32toh(bss->config.dsconfig); in rsu_event_survey()
2086 rxs.c_rssi = le32toh(bss->rssi) / 2; in rsu_event_survey()
2087 rxs.c_nf = -96; in rsu_event_survey()
2100 struct ieee80211com *ic = &sc->sc_ic; in rsu_event_join_bss()
2101 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in rsu_event_join_bss()
2102 struct ieee80211_node *ni = vap->iv_bss; in rsu_event_join_bss()
2110 res = (int)le32toh(rsp->join_res); in rsu_event_join_bss()
2122 ieee80211_new_state(vap, IEEE80211_S_SCAN, -1); in rsu_event_join_bss()
2127 tmp = le32toh(rsp->associd); in rsu_event_join_bss()
2128 if (tmp >= vap->iv_max_aid) { in rsu_event_join_bss()
2134 __func__, ether_sprintf(rsp->bss.macaddr), tmp); in rsu_event_join_bss()
2136 ni->ni_associd = tmp | 0xc000; in rsu_event_join_bss()
2139 sc->sc_vap_is_running = 1; in rsu_event_join_bss()
2151 struct ieee80211com *ic = &sc->sc_ic; in rsu_event_addba_req_report()
2152 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in rsu_event_addba_req_report()
2157 device_printf(sc->sc_dev, "%s: short read (%d)\n", __func__, len); in rsu_event_addba_req_report()
2166 ether_sprintf(ba->mac_addr), in rsu_event_addba_req_report()
2167 (int) ba->tid, in rsu_event_addba_req_report()
2168 (int) le16toh(ba->ssn)); in rsu_event_addba_req_report()
2172 ni = ieee80211_ref_node(vap->iv_bss); in rsu_event_addba_req_report()
2173 ieee80211_ampdu_rx_start_ext(ni, ba->tid, le16toh(ba->ssn) >> 4, 32); in rsu_event_addba_req_report()
2180 struct ieee80211com *ic = &sc->sc_ic; in rsu_rx_event()
2181 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in rsu_rx_event()
2192 __func__, sc->sc_extra_scan ? "direct" : "broadcast", in rsu_rx_event()
2194 if (sc->sc_extra_scan == 1) { in rsu_rx_event()
2196 sc->sc_extra_scan = 0; in rsu_rx_event()
2211 if (vap->iv_state == IEEE80211_S_AUTH) in rsu_rx_event()
2218 if (vap->iv_state == IEEE80211_S_RUN && in rsu_rx_event()
2219 IEEE80211_ADDR_EQ(vap->iv_bss->ni_bssid, buf)) { in rsu_rx_event()
2221 ieee80211_new_state(vap, IEEE80211_S_SCAN, -1); in rsu_rx_event()
2237 device_printf(sc->sc_dev, "%s: unhandled code (%d)\n", __func__, code); in rsu_rx_event()
2252 len -= sizeof(struct r92s_rx_stat); in rsu_rx_multi_event()
2261 cmdsz = le16toh(cmd->len); in rsu_rx_multi_event()
2266 rsu_rx_event(sc, cmd->code, (uint8_t *)&cmd[1], cmdsz); in rsu_rx_multi_event()
2268 if (!(cmd->seq & R92S_FW_CMD_MORE)) in rsu_rx_multi_event()
2271 len -= sizeof(*cmd) + cmdsz; in rsu_rx_multi_event()
2278 static const int8_t cckoff[] = { 14, -2, -20, -40 }; in rsu_get_rssi()
2286 rpt = (cck->agc_rpt >> 6) & 0x3; in rsu_get_rssi()
2287 rssi = cck->agc_rpt & 0x3e; in rsu_get_rssi()
2288 rssi = cckoff[rpt] - rssi; in rsu_get_rssi()
2291 rssi = ((le32toh(phy->phydw1) >> 1) & 0x7f) - 106; in rsu_get_rssi()
2300 struct ieee80211com *ic = &sc->sc_ic; in rsu_rx_copy_to_mbuf()
2305 rxdw0 = le32toh(stat->rxdw0); in rsu_rx_copy_to_mbuf()
2313 pktlen = MS(rxdw0, R92S_RXDW0_PKTLEN); in rsu_rx_copy_to_mbuf()
2322 device_printf(sc->sc_dev, in rsu_rx_copy_to_mbuf()
2330 m->m_pkthdr.len = m->m_len = totlen; in rsu_rx_copy_to_mbuf()
2334 counter_u64_add(ic->ic_ierrors, 1); in rsu_rx_copy_to_mbuf()
2353 struct ieee80211com *ic = &sc->sc_ic; in rsu_rx_frame()
2363 rxdw0 = le32toh(stat->rxdw0); in rsu_rx_frame()
2364 rxdw3 = le32toh(stat->rxdw3); in rsu_rx_frame()
2366 rate = MS(rxdw3, R92S_RXDW3_RATE); in rsu_rx_frame()
2367 cipher = MS(rxdw0, R92S_RXDW0_CIPHER); in rsu_rx_frame()
2368 infosz = MS(rxdw0, R92S_RXDW0_INFOSZ) * 8; in rsu_rx_frame()
2375 rssi = rsu_hwrssi_to_rssi(sc, sc->sc_currssi); in rsu_rx_frame()
2398 m->m_pkthdr.csum_flags = CSUM_IP_CHECKED; in rsu_rx_frame()
2399 m->m_pkthdr.csum_flags |= CSUM_IP_VALID; in rsu_rx_frame()
2406 m->m_pkthdr.csum_flags |= CSUM_DATA_VALID; in rsu_rx_frame()
2407 m->m_pkthdr.csum_flags |= CSUM_PSEUDO_HDR; in rsu_rx_frame()
2408 m->m_pkthdr.csum_data = 0xffff; in rsu_rx_frame()
2420 rxs.c_nf = -96; in rsu_rx_frame()
2430 rxs.c_rate = IEEE80211_RATE_MCS | (rate - 12); in rsu_rx_frame()
2435 struct rsu_rx_radiotap_header *tap = &sc->sc_rxtap; in rsu_rx_frame()
2438 tap->wr_flags = 0; /* TODO */ in rsu_rx_frame()
2439 tap->wr_tsft = rsu_get_tsf_high(sc); in rsu_rx_frame()
2440 if (le32toh(stat->tsf_low) > rsu_get_tsf_low(sc)) in rsu_rx_frame()
2441 tap->wr_tsft--; in rsu_rx_frame()
2442 tap->wr_tsft = (uint64_t)htole32(tap->wr_tsft) << 32; in rsu_rx_frame()
2443 tap->wr_tsft += stat->tsf_low; in rsu_rx_frame()
2445 tap->wr_rate = rxs.c_rate; in rsu_rx_frame()
2446 tap->wr_dbm_antsignal = rssi; in rsu_rx_frame()
2454 if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED) && in rsu_rx_frame()
2456 m->m_flags |= M_WEP; in rsu_rx_frame()
2461 __func__, m->m_len, rate, infosz); in rsu_rx_frame()
2463 if (m->m_len >= sizeof(*wh)) in rsu_rx_frame()
2481 if (!sc->sc_running) in rsu_rx_multi_frame()
2486 npkts = MS(le32toh(stat->rxdw2), R92S_RXDW2_PKTCNT); in rsu_rx_multi_frame()
2491 while (npkts-- > 0) { in rsu_rx_multi_frame()
2495 rxdw0 = le32toh(stat->rxdw0); in rsu_rx_multi_frame()
2497 pktlen = MS(rxdw0, R92S_RXDW0_PKTLEN); in rsu_rx_multi_frame()
2501 infosz = MS(rxdw0, R92S_RXDW0_INFOSZ) * 8; in rsu_rx_multi_frame()
2515 prevm->m_next = m; in rsu_rx_multi_frame()
2518 /* Next chunk is 128-byte aligned. */ in rsu_rx_multi_frame()
2521 len -= totlen; in rsu_rx_multi_frame()
2530 struct rsu_softc *sc = data->sc; in rsu_rxeof()
2531 struct ieee80211com *ic = &sc->sc_ic; in rsu_rxeof()
2539 counter_u64_add(ic->ic_ierrors, 1); in rsu_rxeof()
2543 stat = (struct r92s_rx_stat *)data->buf; in rsu_rxeof()
2544 if ((le32toh(stat->rxdw1) & 0x1ff) == 0x1ff) { in rsu_rxeof()
2545 rsu_rx_multi_event(sc, data->buf, len); in rsu_rxeof()
2549 return (rsu_rx_multi_frame(sc, data->buf, len)); in rsu_rxeof()
2556 struct ieee80211com *ic = &sc->sc_ic; in rsu_bulk_rx_callback()
2565 data = STAILQ_FIRST(&sc->sc_rx_active); in rsu_bulk_rx_callback()
2568 STAILQ_REMOVE_HEAD(&sc->sc_rx_active, next); in rsu_bulk_rx_callback()
2570 STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next); in rsu_bulk_rx_callback()
2574 data = STAILQ_FIRST(&sc->sc_rx_inactive); in rsu_bulk_rx_callback()
2579 STAILQ_REMOVE_HEAD(&sc->sc_rx_inactive, next); in rsu_bulk_rx_callback()
2580 STAILQ_INSERT_TAIL(&sc->sc_rx_active, data, next); in rsu_bulk_rx_callback()
2581 usbd_xfer_set_frame_data(xfer, 0, data->buf, in rsu_bulk_rx_callback()
2590 next = m->m_next; in rsu_bulk_rx_callback()
2591 m->m_next = NULL; in rsu_bulk_rx_callback()
2597 if (ni->ni_flags & IEEE80211_NODE_HT) in rsu_bulk_rx_callback()
2598 m->m_flags |= M_AMPDU; in rsu_bulk_rx_callback()
2610 data = STAILQ_FIRST(&sc->sc_rx_active); in rsu_bulk_rx_callback()
2612 STAILQ_REMOVE_HEAD(&sc->sc_rx_active, next); in rsu_bulk_rx_callback()
2613 STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next); in rsu_bulk_rx_callback()
2617 counter_u64_add(ic->ic_ierrors, 1); in rsu_bulk_rx_callback()
2636 if (data->m) { in rsu_txeof()
2638 ieee80211_tx_complete(data->ni, data->m, 0); in rsu_txeof()
2639 data->m = NULL; in rsu_txeof()
2640 data->ni = NULL; in rsu_txeof()
2649 struct ieee80211com *ic = &sc->sc_ic; in rsu_bulk_tx_callback_sub()
2656 data = STAILQ_FIRST(&sc->sc_tx_active[which]); in rsu_bulk_tx_callback_sub()
2661 STAILQ_REMOVE_HEAD(&sc->sc_tx_active[which], next); in rsu_bulk_tx_callback_sub()
2667 data = STAILQ_FIRST(&sc->sc_tx_pending[which]); in rsu_bulk_tx_callback_sub()
2673 STAILQ_REMOVE_HEAD(&sc->sc_tx_pending[which], next); in rsu_bulk_tx_callback_sub()
2674 STAILQ_INSERT_TAIL(&sc->sc_tx_active[which], data, next); in rsu_bulk_tx_callback_sub()
2675 usbd_xfer_set_frame_data(xfer, 0, data->buf, data->buflen); in rsu_bulk_tx_callback_sub()
2683 data = STAILQ_FIRST(&sc->sc_tx_active[which]); in rsu_bulk_tx_callback_sub()
2685 STAILQ_REMOVE_HEAD(&sc->sc_tx_active[which], next); in rsu_bulk_tx_callback_sub()
2689 counter_u64_add(ic->ic_oerrors, 1); in rsu_bulk_tx_callback_sub()
2747 const struct ieee80211_txparam *tp = ni->ni_txparms; in rsu_tx_start()
2748 struct ieee80211vap *vap = ni->ni_vap; in rsu_tx_start()
2763 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; in rsu_tx_start()
2764 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); in rsu_tx_start()
2772 (m0->m_flags & M_EAPOL) != 0) in rsu_tx_start()
2773 rate = tp->mgmtrate; in rsu_tx_start()
2775 rate = tp->mcastrate; in rsu_tx_start()
2776 else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) in rsu_tx_start()
2777 rate = tp->ucastrate; in rsu_tx_start()
2784 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { in rsu_tx_start()
2787 device_printf(sc->sc_dev, in rsu_tx_start()
2801 qos = ((const struct ieee80211_qosframe *)wh)->i_qos[0]; in rsu_tx_start()
2803 /* Non-QoS TID */ in rsu_tx_start()
2804 /* XXX TODO: tid=0 for non-qos TID? */ in rsu_tx_start()
2832 txd = (struct r92s_tx_desc *)data->buf; in rsu_tx_start()
2835 txd->txdw0 |= htole32( in rsu_tx_start()
2836 SM(R92S_TXDW0_PKTLEN, m0->m_pkthdr.len) | in rsu_tx_start()
2840 txd->txdw1 |= htole32( in rsu_tx_start()
2843 txd->txdw1 |= htole32(R92S_TXDW1_NONQOS); in rsu_tx_start()
2844 if (k != NULL && !(k->wk_flags & IEEE80211_KEY_SWENCRYPT)) { in rsu_tx_start()
2845 switch (k->wk_cipher->ic_cipher) { in rsu_tx_start()
2858 txd->txdw1 |= htole32( in rsu_tx_start()
2860 SM(R92S_TXDW1_KEYIDX, k->wk_keyix)); in rsu_tx_start()
2863 txd->txdw2 |= htole32(R92S_TXDW2_BK); in rsu_tx_start()
2865 txd->txdw2 |= htole32(R92S_TXDW2_BMCAST); in rsu_tx_start()
2869 txd->txdw2 |= htole32(R92S_TXDW2_RTY_LMT_ENA); in rsu_tx_start()
2870 txd->txdw2 |= htole32(SM(R92S_TXDW2_RTY_LMT, tp->maxretry)); in rsu_tx_start()
2876 txd->txdw5 |= htole32(SM(R92S_TXDW5_DATARATE_FB_LMT, 0x1f)); in rsu_tx_start()
2877 txd->txdw5 |= htole32(SM(R92S_TXDW5_DATARATE, ridx)); in rsu_tx_start()
2878 txd->txdw4 |= htole32(R92S_TXDW4_DRVRATE); in rsu_tx_start()
2885 txd->txdw3 |= htole32(SM(R92S_TXDW3_SEQ, prio)); in rsu_tx_start()
2888 struct rsu_tx_radiotap_header *tap = &sc->sc_txtap; in rsu_tx_start()
2890 tap->wt_flags = 0; in rsu_tx_start()
2894 xferlen = sizeof(*txd) + m0->m_pkthdr.len; in rsu_tx_start()
2896 m_copydata(m0, 0, m0->m_pkthdr.len, (caddr_t)&txd[1]); in rsu_tx_start()
2898 data->buflen = xferlen; in rsu_tx_start()
2899 data->ni = ni; in rsu_tx_start()
2900 data->m = m0; in rsu_tx_start()
2901 STAILQ_INSERT_TAIL(&sc->sc_tx_pending[which], data, next); in rsu_tx_start()
2904 usbd_transfer_start(sc->sc_xfer[which]); in rsu_tx_start()
2911 struct rsu_softc *sc = ic->ic_softc; in rsu_transmit()
2915 if (!sc->sc_running) { in rsu_transmit()
2924 error = mbufq_enqueue(&sc->sc_snd, m); in rsu_transmit()
2948 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in rsu_drain_mbufq()
2949 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in rsu_drain_mbufq()
2950 m->m_pkthdr.rcvif = NULL; in rsu_drain_mbufq()
2965 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in _rsu_start()
2970 mbufq_prepend(&sc->sc_snd, m); in _rsu_start()
2974 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in _rsu_start()
2975 m->m_pkthdr.rcvif = NULL; in _rsu_start()
2980 if_inc_counter(ni->ni_vap->iv_ifp, in _rsu_start()
2994 taskqueue_enqueue(taskqueue_thread, &sc->tx_task); in rsu_start()
3000 struct rsu_softc *sc = ic->ic_softc; in rsu_ioctl_net()
3011 rxmask = ifr->ifr_reqcap & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6); in rsu_ioctl_net()
3015 if (sc->sc_rx_checksum_enable && in rsu_ioctl_net()
3018 sc->sc_rx_checksum_enable = 0; in rsu_ioctl_net()
3020 } else if (!sc->sc_rx_checksum_enable && rxmask != 0) { in rsu_ioctl_net()
3022 sc->sc_rx_checksum_enable = 1; in rsu_ioctl_net()
3032 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { in rsu_ioctl_net()
3033 if_t ifp = vap->iv_ifp; in rsu_ioctl_net()
3053 struct rsu_softc *sc = ic->ic_softc; in rsu_parent()
3055 if (ic->ic_nrunning > 0) { in rsu_parent()
3059 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in rsu_parent()
3068 * Power on sequence for A-cut adapters.
3150 * Power on sequence for B-cut and C-cut adapters.
3298 /* Firmware - tell it to switch things off */ in rsu_power_off()
3314 txd = (struct r92s_tx_desc *)data->buf; in rsu_fw_loadsection()
3316 if (len <= RSU_TXBUFSZ - sizeof(*txd)) { in rsu_fw_loadsection()
3318 txd->txdw0 |= htole32(R92S_TXDW0_LINIP); in rsu_fw_loadsection()
3321 mlen = RSU_TXBUFSZ - sizeof(*txd); in rsu_fw_loadsection()
3322 txd->txdw0 |= htole32(SM(R92S_TXDW0_PKTLEN, mlen)); in rsu_fw_loadsection()
3324 data->buflen = sizeof(*txd) + mlen; in rsu_fw_loadsection()
3328 STAILQ_INSERT_TAIL(&sc->sc_tx_pending[which], data, next); in rsu_fw_loadsection()
3330 len -= mlen; in rsu_fw_loadsection()
3332 usbd_transfer_start(sc->sc_xfer[which]); in rsu_fw_loadsection()
3343 struct ieee80211com *ic = &sc->sc_ic; in rsu_load_firmware()
3360 if ((fw = firmware_get("rsu-rtl8712fw")) == NULL) { in rsu_load_firmware()
3361 device_printf(sc->sc_dev, in rsu_load_firmware()
3362 "%s: failed load firmware of file rsu-rtl8712fw\n", in rsu_load_firmware()
3368 size = fw->datasize; in rsu_load_firmware()
3370 device_printf(sc->sc_dev, "firmware too short\n"); in rsu_load_firmware()
3374 hdr = (const struct r92s_fw_hdr *)fw->data; in rsu_load_firmware()
3375 if (hdr->signature != htole16(0x8712) && in rsu_load_firmware()
3376 hdr->signature != htole16(0x8192)) { in rsu_load_firmware()
3377 device_printf(sc->sc_dev, in rsu_load_firmware()
3379 le16toh(hdr->signature)); in rsu_load_firmware()
3383 RSU_DPRINTF(sc, RSU_DEBUG_FW, "FW V%d %02x-%02x %02x:%02x\n", in rsu_load_firmware()
3384 le16toh(hdr->version), hdr->month, hdr->day, hdr->hour, in rsu_load_firmware()
3385 hdr->minute); in rsu_load_firmware()
3388 if (hdr->privsz != htole32(sizeof(dmem))) { in rsu_load_firmware()
3389 device_printf(sc->sc_dev, "unsupported firmware image\n"); in rsu_load_firmware()
3394 imemsz = le32toh(hdr->imemsz); in rsu_load_firmware()
3395 ememsz = le32toh(hdr->sramsz); in rsu_load_firmware()
3397 if (imemsz > (size_t)(size - sizeof(*hdr)) || in rsu_load_firmware()
3398 ememsz > (size_t)(size - sizeof(*hdr) - imemsz)) { in rsu_load_firmware()
3399 device_printf(sc->sc_dev, "firmware too short\n"); in rsu_load_firmware()
3409 device_printf(sc->sc_dev, in rsu_load_firmware()
3421 device_printf(sc->sc_dev, "timeout waiting for IMEM transfer\n"); in rsu_load_firmware()
3428 device_printf(sc->sc_dev, in rsu_load_firmware()
3440 device_printf(sc->sc_dev, "timeout waiting for EMEM transfer\n"); in rsu_load_firmware()
3448 device_printf(sc->sc_dev, "could not enable system clock\n"); in rsu_load_firmware()
3455 device_printf(sc->sc_dev, in rsu_load_firmware()
3467 device_printf(sc->sc_dev, in rsu_load_firmware()
3468 "timeout waiting for microcontroller\n"); in rsu_load_firmware()
3476 dmem.nendpoints = sc->sc_nendpoints; in rsu_load_firmware()
3477 dmem.chip_version = sc->cut; in rsu_load_firmware()
3478 dmem.rf_config = sc->sc_rftype; in rsu_load_firmware()
3482 dmem.bw40_en = !! (ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40); in rsu_load_firmware()
3483 dmem.amsdu2ampdu_en = !! (sc->sc_ht); in rsu_load_firmware()
3484 dmem.ampdu_en = !! (sc->sc_ht); in rsu_load_firmware()
3485 dmem.agg_offload = !! (sc->sc_ht); in rsu_load_firmware()
3492 device_printf(sc->sc_dev, in rsu_load_firmware()
3503 device_printf(sc->sc_dev, "timeout waiting for %s transfer\n", in rsu_load_firmware()
3515 device_printf(sc->sc_dev, in rsu_load_firmware()
3516 "timeout waiting for firmware readiness\n"); in rsu_load_firmware()
3529 struct ieee80211com *ic = ni->ni_ic; in rsu_raw_xmit()
3530 struct rsu_softc *sc = ic->ic_softc; in rsu_raw_xmit()
3534 if (!sc->sc_running) { in rsu_raw_xmit()
3570 if (sc->sc_rx_checksum_enable) in rsu_rxfilter_init()
3581 /* NB: firmware can touch this register too. */ in rsu_rxfilter_set()
3589 struct ieee80211com *ic = &sc->sc_ic; in rsu_rxfilter_refresh()
3597 if (sc->sc_vap_is_running) in rsu_rxfilter_refresh()
3602 if (ic->ic_opmode == IEEE80211_M_MONITOR) { in rsu_rxfilter_refresh()
3604 if (sc->sc_vap_is_running) in rsu_rxfilter_refresh()
3611 if (ic->ic_promisc == 0 && ic->ic_opmode != IEEE80211_M_MONITOR) in rsu_rxfilter_refresh()
3620 struct ieee80211com *ic = &sc->sc_ic; in rsu_init()
3621 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in rsu_init()
3628 if (sc->sc_running) { in rsu_init()
3640 if (sc->cut == 1) in rsu_init()
3661 /* Set USB Rx aggregation timeout (1.7ms/4). */ in rsu_init()
3668 IEEE80211_ADDR_COPY(macaddr, vap ? vap->iv_myaddr : ic->ic_macaddr); in rsu_init()
3672 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(2000)); in rsu_init()
3680 device_printf(sc->sc_dev, "could not set MAC address\n"); in rsu_init()
3690 device_printf(sc->sc_dev, "could not set PS mode\n"); in rsu_init()
3699 sc->sc_extra_scan = 0; in rsu_init()
3700 usbd_transfer_start(sc->sc_xfer[RSU_BULK_RX]); in rsu_init()
3703 sc->sc_running = 1; in rsu_init()
3710 usbd_transfer_stop(sc->sc_xfer[i]); in rsu_init()
3722 if (!sc->sc_running) { in rsu_stop()
3727 sc->sc_running = 0; in rsu_stop()
3728 sc->sc_vap_is_running = 0; in rsu_stop()
3729 sc->sc_calibrating = 0; in rsu_stop()
3730 taskqueue_cancel_timeout(taskqueue_thread, &sc->calib_task, NULL); in rsu_stop()
3731 taskqueue_cancel(taskqueue_thread, &sc->tx_task, NULL); in rsu_stop()
3740 memset(sc->free_keys_bmap, 0, sizeof(sc->free_keys_bmap)); in rsu_stop()
3741 memset(sc->keys_bmap, 0, sizeof(sc->keys_bmap)); in rsu_stop()
3744 usbd_transfer_stop(sc->sc_xfer[i]); in rsu_stop()
3756 rsu_ms_delay(struct rsu_softc *sc, int ms) in rsu_ms_delay() argument
3759 //usb_pause_mtx(&sc->sc_mtx, hz / 1000); in rsu_ms_delay()
3760 DELAY(ms * 1000); in rsu_ms_delay()