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

3 /*-
73 SYSCTL_NODE(_hw_usb, OID_AUTO, rsu, CTLFLAG_RW, 0, "USB rsu");
207 .name = "rsu",
214 DRIVER_MODULE(rsu, uhub, rsu_driver, rsu_devclass, NULL, 0);
215 MODULE_DEPEND(rsu, wlan, 1, 1, 1);
216 MODULE_DEPEND(rsu, usb, 1, 1, 1);
217 MODULE_DEPEND(rsu, firmware, 1, 1, 1);
218 MODULE_VERSION(rsu, 1);
291 if (uaa->usb_mode != USB_MODE_HOST ||
292 uaa->info.bIfaceIndex != 0 ||
293 uaa->info.bConfigIndex != 0)
310 sc->sc_udev = uaa->device;
311 sc->sc_dev = self;
313 mtx_init(&sc->sc_mtx, device_get_nameunit(self), MTX_NETWORK_LOCK,
315 TIMEOUT_TASK_INIT(taskqueue_thread, &sc->calib_task, 0,
317 callout_init(&sc->sc_watchdog_ch, 0);
320 error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_xfer,
321 rsu_config, RSU_N_TRANSFER, sc, &sc->sc_mtx);
323 device_printf(sc->sc_dev,
330 sc->cut = MS(rsu_read_4(sc, R92S_PMC_FSM), R92S_PMC_FSM_CUT);
331 if (sc->cut != 3)
332 sc->cut = (sc->cut >> 1) + 1;
339 IEEE80211_ADDR_COPY(sc->sc_bssid, &sc->rom[0x12]);
340 device_printf(self, "MAC/BB RTL8712 cut %d\n", sc->cut);
341 ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
346 ic = ifp->if_l2com;
347 ifp->if_softc = sc;
348 if_initname(ifp, "rsu", device_get_unit(self));
349 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
350 ifp->if_init = rsu_init;
351 ifp->if_ioctl = rsu_ioctl;
352 ifp->if_start = rsu_start;
353 IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
354 ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
355 IFQ_SET_READY(&ifp->if_snd);
356 ifp->if_capabilities |= IFCAP_RXCSUM;
357 ifp->if_capenable |= IFCAP_RXCSUM;
358 ifp->if_hwassist = CSUM_TCP;
360 ic->ic_ifp = ifp;
361 ic->ic_phytype = IEEE80211_T_OFDM; /* Not only, but not used. */
362 ic->ic_opmode = IEEE80211_M_STA; /* Default to BSS mode. */
365 ic->ic_caps =
374 if (usb_lookup(rsu_devs_noht, uaa->vendor, uaa->product) == NULL) {
376 ic->ic_htcaps =
381 ic->ic_sup_mcs[i] = 0xff;
391 ieee80211_ifattach(ic, sc->sc_bssid);
392 ic->ic_raw_xmit = rsu_raw_xmit;
393 ic->ic_scan_start = rsu_scan_start;
394 ic->ic_scan_end = rsu_scan_end;
395 ic->ic_set_channel = rsu_set_channel;
396 ic->ic_vap_create = rsu_vap_create;
397 ic->ic_vap_delete = rsu_vap_delete;
398 ic->ic_update_mcast = rsu_update_mcast;
400 ieee80211_radiotap_attach(ic, &sc->sc_txtap.wt_ihdr,
401 sizeof(sc->sc_txtap), RSU_TX_RADIOTAP_PRESENT,
402 &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap),
412 usbd_transfer_unsetup(sc->sc_xfer, RSU_N_TRANSFER);
414 mtx_destroy(&sc->sc_mtx);
422 struct ifnet *ifp = sc->sc_ifp;
423 struct ieee80211com *ic = ifp->if_l2com;
428 usbd_transfer_unsetup(sc->sc_xfer, RSU_N_TRANSFER);
431 callout_drain(&sc->sc_watchdog_ch);
432 taskqueue_drain_timeout(taskqueue_thread, &sc->calib_task);
439 mtx_destroy(&sc->sc_mtx);
453 while (ntries--) {
454 err = usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx,
456 if (err == 0 || !device_is_attached(sc->sc_dev))
460 usb_pause_mtx(&sc->sc_mtx, hz / 100);
475 if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */
482 vap = &uvp->vap;
487 uvp->newstate = vap->iv_newstate;
488 vap->iv_newstate = rsu_newstate;
493 ic->ic_opmode = opmode;
511 struct ifnet *ifp = ic->ic_ifp;
512 struct rsu_softc *sc = ifp->if_softc;
516 error = rsu_site_survey(sc, TAILQ_FIRST(&ic->ic_vaps));
519 device_printf(sc->sc_dev,
549 dp->sc = sc;
550 dp->m = NULL;
551 dp->buf = malloc(maxsz, M_USBDEV, M_NOWAIT);
552 if (dp->buf == NULL) {
553 device_printf(sc->sc_dev,
558 dp->ni = NULL;
572 error = rsu_alloc_list(sc, sc->sc_rx, RSU_RX_LIST_COUNT,
577 STAILQ_INIT(&sc->sc_rx_active);
578 STAILQ_INIT(&sc->sc_rx_inactive);
581 STAILQ_INSERT_HEAD(&sc->sc_rx_inactive, &sc->sc_rx[i], next);
591 error = rsu_alloc_list(sc, sc->sc_tx, RSU_TX_LIST_COUNT,
596 STAILQ_INIT(&sc->sc_tx_active);
597 STAILQ_INIT(&sc->sc_tx_inactive);
598 STAILQ_INIT(&sc->sc_tx_pending);
601 STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, &sc->sc_tx[i], next);
610 rsu_free_list(sc, sc->sc_tx, RSU_TX_LIST_COUNT);
616 rsu_free_list(sc, sc->sc_rx, RSU_RX_LIST_COUNT);
627 if (dp->buf != NULL) {
628 free(dp->buf, M_USBDEV);
629 dp->buf = NULL;
631 if (dp->ni != NULL) {
632 ieee80211_free_node(dp->ni);
633 dp->ni = NULL;
643 bf = STAILQ_FIRST(&sc->sc_tx_inactive);
645 STAILQ_REMOVE_HEAD(&sc->sc_tx_inactive, next);
662 struct ifnet *ifp = sc->sc_ifp;
664 ifp->if_drv_flags |= IFF_DRV_OACTIVE;
781 device_printf(sc->sc_dev,
789 uint8_t *rom = sc->rom;
807 memset(&sc->rom, 0xff, sizeof(sc->rom));
830 for (i = 0; i < sizeof(sc->rom); i++)
850 /* Round-up command length to a multiple of 8 bytes. */
855 memset(data->buf, 0, xferlen);
858 txd = (struct r92s_tx_desc *)data->buf;
859 txd->txdw0 = htole32(
863 txd->txdw1 = htole32(SM(R92S_TXDW1_QSEL, R92S_TXDW1_QSEL_H2C));
867 cmd->len = htole16(cmdsz);
868 cmd->code = code;
869 cmd->seq = sc->cmd_seq;
870 sc->cmd_seq = (sc->cmd_seq + 1) & 0x7f;
876 data->buflen = xferlen;
877 STAILQ_INSERT_TAIL(&sc->sc_tx_pending, data, next);
878 usbd_transfer_start(sc->sc_xfer[RSU_BULK_TX_VO]);
907 if (sc->sc_calibrating) {
909 taskqueue_enqueue_timeout(taskqueue_thread, &sc->calib_task,
919 struct ieee80211com *ic = vap->iv_ic;
920 struct rsu_softc *sc = ic->ic_ifp->if_softc;
926 ostate = vap->iv_state;
927 DPRINTF("%s -> %s\n", ieee80211_state_name[ostate],
934 sc->sc_calibrating = 0;
936 taskqueue_drain_timeout(taskqueue_thread, &sc->calib_task);
946 ni = ieee80211_ref_node(vap->iv_bss);
950 device_printf(sc->sc_dev,
955 ni = ieee80211_ref_node(vap->iv_bss);
956 rs = &ni->ni_rates;
958 ni->ni_txrate = rs->rs_rates[rs->rs_nrates - 1];
965 sc->sc_calibrating = 1;
969 taskqueue_enqueue_timeout(taskqueue_thread, &sc->calib_task, hz * 2);
971 return (uvp->newstate(vap, nstate, arg));
982 switch (k->wk_cipher->ic_cipher) {
984 if (k->wk_keylen < 8)
998 key.id = k->wk_keyix;
999 key.grpkey = (k->wk_flags & IEEE80211_KEY_GROUP) != 0;
1000 memcpy(key.key, k->wk_key, MIN(k->wk_keylen, sizeof(key.key)));
1010 key.id = k->wk_keyix;
1019 struct ifnet *ifp = sc->sc_ifp;
1020 struct ieee80211com *ic = ifp->if_l2com;
1023 if ((ic->ic_flags & IEEE80211_F_ASCAN) || sc->scan_pass == 1)
1026 if (sc->scan_pass == 1 && vap->iv_des_nssid > 0) {
1028 cmd.ssidlen = htole32(vap->iv_des_ssid[0].len);
1029 memcpy(cmd.ssid, vap->iv_des_ssid[0].ssid,
1030 vap->iv_des_ssid[0].len);
1033 DPRINTF("sending site survey command, pass=%d\n", sc->scan_pass);
1040 struct ifnet *ifp = sc->sc_ifp;
1041 struct ieee80211com *ic = ifp->if_l2com;
1042 struct ieee80211vap *vap = ni->ni_vap;
1058 if (vap->iv_flags & IEEE80211_F_WPA) {
1060 auth.dot1x = ni->ni_authmode == IEEE80211_AUTH_8021X;
1070 IEEE80211_ADDR_COPY(bss->macaddr, ni->ni_bssid);
1071 bss->ssid.ssidlen = htole32(ni->ni_esslen);
1072 memcpy(bss->ssid.ssid, ni->ni_essid, ni->ni_esslen);
1073 if (vap->iv_flags & (IEEE80211_F_PRIVACY | IEEE80211_F_WPA))
1074 bss->privacy = htole32(1);
1075 bss->rssi = htole32(ni->ni_avgrssi);
1076 if (ic->ic_curmode == IEEE80211_MODE_11B)
1077 bss->networktype = htole32(NDIS802_11DS);
1079 bss->networktype = htole32(NDIS802_11OFDM24);
1080 bss->config.len = htole32(sizeof(bss->config));
1081 bss->config.bintval = htole32(ni->ni_intval);
1082 bss->config.dsconfig = htole32(ieee80211_chan2ieee(ic, ni->ni_chan));
1083 bss->inframode = htole32(NDIS802_11INFRASTRUCTURE);
1084 memcpy(bss->supprates, ni->ni_rates.rs_rates,
1085 ni->ni_rates.rs_nrates);
1088 memcpy(&fixed->tstamp, ni->ni_tstamp.data, 8);
1089 fixed->bintval = htole16(ni->ni_intval);
1090 fixed->capabilities = htole16(ni->ni_capinfo);
1096 if (ni->ni_flags & IEEE80211_NODE_HT)
1098 bss->ieslen = htole32(frm - (uint8_t *)fixed);
1099 bss->len = htole32(((frm - buf) + 3) & ~3);
1101 ether_sprintf(bss->macaddr), le32toh(bss->config.dsconfig));
1108 uint32_t zero = 0; /* :-) */
1118 struct ifnet *ifp = sc->sc_ifp;
1119 struct ieee80211com *ic = ifp->if_l2com;
1129 if (__predict_false(len < sizeof(*bss) + le32toh(bss->ieslen)))
1134 ether_sprintf(bss->macaddr), le32toh(bss->len),
1135 le32toh(bss->config.dsconfig), le32toh(bss->inframode),
1136 le32toh(bss->networktype), le32toh(bss->privacy));
1139 pktlen = sizeof(*wh) + le32toh(bss->ieslen);
1147 if (!(m->m_flags & M_EXT)) {
1153 wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT |
1155 wh->i_fc[1] = IEEE80211_FC1_DIR_NODS;
1156 *(uint16_t *)wh->i_dur = 0;
1157 IEEE80211_ADDR_COPY(wh->i_addr1, ifp->if_broadcastaddr);
1158 IEEE80211_ADDR_COPY(wh->i_addr2, bss->macaddr);
1159 IEEE80211_ADDR_COPY(wh->i_addr3, bss->macaddr);
1160 *(uint16_t *)wh->i_seq = 0;
1161 memcpy(&wh[1], (uint8_t *)&bss[1], le32toh(bss->ieslen));
1164 m->m_pkthdr.len = m->m_len = pktlen;
1165 m->m_pkthdr.rcvif = ifp;
1168 le32toh(bss->config.dsconfig),
1171 ic->ic_curchan = c;
1176 ieee80211_input_all(ic, m, le32toh(bss->rssi), 0);
1183 struct ifnet *ifp = sc->sc_ifp;
1184 struct ieee80211com *ic = ifp->if_l2com;
1185 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
1186 struct ieee80211_node *ni = vap->iv_bss;
1193 res = (int)le32toh(rsp->join_res);
1198 ieee80211_new_state(vap, IEEE80211_S_SCAN, -1);
1203 ether_sprintf(rsp->bss.macaddr), le32toh(rsp->associd));
1204 ni->ni_associd = le32toh(rsp->associd) | 0xc000;
1214 struct ifnet *ifp = sc->sc_ifp;
1215 struct ieee80211com *ic = ifp->if_l2com;
1216 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
1221 if (vap->iv_state == IEEE80211_S_SCAN)
1226 sc->scan_pass, le32toh(*(uint32_t *)buf));
1227 if (vap->iv_state != IEEE80211_S_SCAN)
1229 if (sc->scan_pass == 0 && vap->iv_des_nssid != 0) {
1231 sc->scan_pass = 1;
1233 ieee80211_new_state(vap, IEEE80211_S_SCAN, -1);
1237 sc->scan_pass = 0;
1240 if (vap->iv_state == IEEE80211_S_AUTH)
1245 if (vap->iv_state == IEEE80211_S_RUN &&
1246 IEEE80211_ADDR_EQ(vap->iv_bss->ni_bssid, buf)) {
1248 ieee80211_new_state(vap, IEEE80211_S_SCAN, -1);
1256 if (ifp->if_flags & IFF_DEBUG) {
1274 len -= sizeof(struct r92s_rx_stat);
1283 cmdsz = le16toh(cmd->len);
1288 rsu_rx_event(sc, cmd->code, (uint8_t *)&cmd[1], cmdsz);
1290 if (!(cmd->seq & R92S_FW_CMD_MORE))
1293 len -= sizeof(*cmd) + cmdsz;
1300 static const int8_t cckoff[] = { 14, -2, -20, -40 };
1308 rpt = (cck->agc_rpt >> 6) & 0x3;
1309 rssi = cck->agc_rpt & 0x3e;
1310 rssi = cckoff[rpt] - rssi;
1313 rssi = ((le32toh(phy->phydw1) >> 1) & 0x7f) - 106;
1321 struct ifnet *ifp = sc->sc_ifp;
1322 struct ieee80211com *ic = ifp->if_l2com;
1331 rxdw0 = le32toh(stat->rxdw0);
1332 rxdw3 = le32toh(stat->rxdw3);
1335 ifp->if_ierrors++;
1339 ifp->if_ierrors++;
1357 ifp->if_ierrors++;
1362 if (__predict_false(!(m->m_flags & M_EXT))) {
1363 ifp->if_ierrors++;
1369 m->m_pkthdr.rcvif = ifp;
1373 m->m_pkthdr.csum_flags |= CSUM_DATA_VALID;
1377 m->m_pkthdr.len = m->m_len = pktlen;
1380 struct rsu_rx_radiotap_header *tap = &sc->sc_rxtap;
1383 tap->wr_flags = 2;
1387 case 0: tap->wr_rate = 2; break;
1388 case 1: tap->wr_rate = 4; break;
1389 case 2: tap->wr_rate = 11; break;
1390 case 3: tap->wr_rate = 22; break;
1392 case 4: tap->wr_rate = 12; break;
1393 case 5: tap->wr_rate = 18; break;
1394 case 6: tap->wr_rate = 24; break;
1395 case 7: tap->wr_rate = 36; break;
1396 case 8: tap->wr_rate = 48; break;
1397 case 9: tap->wr_rate = 72; break;
1398 case 10: tap->wr_rate = 96; break;
1399 case 11: tap->wr_rate = 108; break;
1403 tap->wr_rate = 0x80 | (rate - 12);
1405 tap->wr_dbm_antsignal = *rssi;
1406 tap->wr_chan_freq = htole16(ic->ic_curchan->ic_freq);
1407 tap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags);
1423 npkts = MS(le32toh(stat->rxdw2), R92S_RXDW2_PKTCNT);
1427 while (npkts-- > 0) {
1431 rxdw0 = le32toh(stat->rxdw0);
1451 prevm->m_next = m;
1454 /* Next chunk is 128-byte aligned. */
1457 len -= totlen;
1466 struct rsu_softc *sc = data->sc;
1474 sc->sc_ifp->if_ierrors++;
1478 stat = (struct r92s_rx_stat *)data->buf;
1479 if ((le32toh(stat->rxdw1) & 0x1ff) == 0x1ff) {
1480 rsu_rx_multi_event(sc, data->buf, len);
1484 return (rsu_rx_multi_frame(sc, data->buf, len, rssi));
1491 struct ifnet *ifp = sc->sc_ifp;
1492 struct ieee80211com *ic = ifp->if_l2com;
1503 data = STAILQ_FIRST(&sc->sc_rx_active);
1506 STAILQ_REMOVE_HEAD(&sc->sc_rx_active, next);
1508 STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next);
1512 data = STAILQ_FIRST(&sc->sc_rx_inactive);
1517 STAILQ_REMOVE_HEAD(&sc->sc_rx_inactive, next);
1518 STAILQ_INSERT_TAIL(&sc->sc_rx_active, data, next);
1519 usbd_xfer_set_frame_data(xfer, 0, data->buf,
1529 next = m->m_next;
1530 m->m_next = NULL;
1545 data = STAILQ_FIRST(&sc->sc_rx_active);
1547 STAILQ_REMOVE_HEAD(&sc->sc_rx_active, next);
1548 STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next);
1552 ifp->if_ierrors++;
1565 struct ifnet *ifp = sc->sc_ifp;
1574 if (data->m) {
1575 m = data->m;
1576 if (m->m_flags & M_TXCB) {
1578 ieee80211_process_callback(data->ni, m, 0);
1581 data->m = NULL;
1583 if (data->ni) {
1584 ieee80211_free_node(data->ni);
1585 data->ni = NULL;
1587 sc->sc_tx_timer = 0;
1588 ifp->if_opackets++;
1589 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1596 struct ifnet *ifp = sc->sc_ifp;
1603 data = STAILQ_FIRST(&sc->sc_tx_active);
1607 STAILQ_REMOVE_HEAD(&sc->sc_tx_active, next);
1609 STAILQ_INSERT_TAIL(&sc->sc_tx_inactive, data, next);
1613 data = STAILQ_FIRST(&sc->sc_tx_pending);
1618 STAILQ_REMOVE_HEAD(&sc->sc_tx_pending, next);
1619 STAILQ_INSERT_TAIL(&sc->sc_tx_active, data, next);
1620 usbd_xfer_set_frame_data(xfer, 0, data->buf, data->buflen);
1626 data = STAILQ_FIRST(&sc->sc_tx_active);
1629 if (data->ni != NULL) {
1630 ieee80211_free_node(data->ni);
1631 data->ni = NULL;
1632 ifp->if_oerrors++;
1646 struct ifnet *ifp = sc->sc_ifp;
1647 struct ieee80211com *ic = ifp->if_l2com;
1648 struct ieee80211vap *vap = ni->ni_vap;
1656 sc->sc_xfer[RSU_BULK_TX_BE],
1657 sc->sc_xfer[RSU_BULK_TX_BK],
1658 sc->sc_xfer[RSU_BULK_TX_VI],
1659 sc->sc_xfer[RSU_BULK_TX_VO]
1665 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
1667 if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
1670 device_printf(sc->sc_dev,
1681 xfer = sc->sc_xfer[RSU_BULK_TX_VO];
1692 txd = (struct r92s_tx_desc *)data->buf;
1695 txd->txdw0 |= htole32(
1696 SM(R92S_TXDW0_PKTLEN, m0->m_pkthdr.len) |
1700 txd->txdw1 |= htole32(
1704 txd->txdw1 |= htole32(R92S_TXDW1_NONQOS);
1707 switch (k->wk_cipher->ic_cipher) {
1720 txd->txdw1 |= htole32(
1722 SM(R92S_TXDW1_KEYIDX, k->k_id));
1725 txd->txdw2 |= htole32(R92S_TXDW2_BK);
1726 if (IEEE80211_IS_MULTICAST(wh->i_addr1))
1727 txd->txdw2 |= htole32(R92S_TXDW2_BMCAST);
1732 txd->txdw3 |= htole32(SM(R92S_TXDW3_SEQ, tid));
1735 struct rsu_tx_radiotap_header *tap = &sc->sc_txtap;
1737 tap->wt_flags = 0;
1738 tap->wt_chan_freq = htole16(ic->ic_curchan->ic_freq);
1739 tap->wt_chan_flags = htole16(ic->ic_curchan->ic_flags);
1742 xferlen = sizeof(*txd) + m0->m_pkthdr.len;
1743 m_copydata(m0, 0, m0->m_pkthdr.len, (caddr_t)&txd[1]);
1745 data->buflen = xferlen;
1746 data->ni = ni;
1747 data->m = m0;
1748 STAILQ_INSERT_TAIL(&sc->sc_tx_pending, data, next);
1757 struct rsu_softc *sc = ifp->if_softc;
1759 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
1770 struct rsu_softc *sc = ifp->if_softc;
1778 IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
1783 IFQ_DRV_PREPEND(&ifp->if_snd, m);
1786 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
1787 m->m_pkthdr.rcvif = NULL;
1790 ifp->if_oerrors++;
1791 STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next);
1795 sc->sc_tx_timer = 5;
1796 callout_reset(&sc->sc_watchdog_ch, hz, rsu_watchdog, sc);
1804 struct ifnet *ifp = sc->sc_ifp;
1806 if (sc->sc_tx_timer > 0) {
1807 if (--sc->sc_tx_timer == 0) {
1808 device_printf(sc->sc_dev, "device timeout\n");
1810 ifp->if_oerrors++;
1813 callout_reset(&sc->sc_watchdog_ch, hz, rsu_watchdog, sc);
1820 struct ieee80211com *ic = ifp->if_l2com;
1826 if (ifp->if_flags & IFF_UP) {
1827 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
1828 rsu_init(ifp->if_softc);
1832 if (ifp->if_drv_flags & IFF_DRV_RUNNING)
1839 error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);
1853 * Power on sequence for A-cut adapters.
1873 usb_pause_mtx(&sc->sc_mtx, 2 * hz);
1935 * Power on sequence for B-cut and C-cut adapters.
1945 usb_pause_mtx(&sc->sc_mtx, 10);
2057 usb_pause_mtx(&sc->sc_mtx, 5);
2093 txd = (struct r92s_tx_desc *)data->buf;
2095 if (len <= RSU_TXBUFSZ - sizeof(*txd)) {
2097 txd->txdw0 |= htole32(R92S_TXDW0_LINIP);
2100 mlen = RSU_TXBUFSZ - sizeof(*txd);
2101 txd->txdw0 |= htole32(SM(R92S_TXDW0_PKTLEN, mlen));
2103 data->buflen = sizeof(*txd) + mlen;
2105 STAILQ_INSERT_TAIL(&sc->sc_tx_pending, data, next);
2107 len -= mlen;
2109 usbd_transfer_start(sc->sc_xfer[RSU_BULK_TX_VO]);
2128 if ((fw = firmware_get("rsu-rtl8712fw")) == NULL) {
2129 device_printf(sc->sc_dev,
2130 "%s: failed load firmware of file rsu-rtl8712fw\n",
2136 size = fw->datasize;
2138 device_printf(sc->sc_dev, "firmware too short\n");
2142 hdr = (const struct r92s_fw_hdr *)fw->data;
2143 if (hdr->signature != htole16(0x8712) &&
2144 hdr->signature != htole16(0x8192)) {
2145 device_printf(sc->sc_dev,
2147 le16toh(hdr->signature));
2151 DPRINTF("FW V%d %02x-%02x %02x:%02x\n", le16toh(hdr->version),
2152 hdr->month, hdr->day, hdr->hour, hdr->minute);
2155 if (hdr->privsz != htole32(sizeof(*dmem))) {
2156 device_printf(sc->sc_dev, "unsupported firmware image\n");
2161 imemsz = le32toh(hdr->imemsz);
2162 ememsz = le32toh(hdr->sramsz);
2165 device_printf(sc->sc_dev, "firmware too short\n");
2175 device_printf(sc->sc_dev,
2181 usb_pause_mtx(&sc->sc_mtx, 10);
2187 device_printf(sc->sc_dev, "timeout waiting for %s transfer\n",
2196 device_printf(sc->sc_dev,
2202 usb_pause_mtx(&sc->sc_mtx, 10);
2208 device_printf(sc->sc_dev, "timeout waiting for %s transfer\n",
2218 device_printf(sc->sc_dev, "could not enable system clock\n");
2225 device_printf(sc->sc_dev,
2237 device_printf(sc->sc_dev,
2244 dmem = __DECONST(struct r92s_fw_priv *, &hdr->priv);
2246 dmem->hci_sel = R92S_HCI_SEL_USB | R92S_HCI_SEL_8172;
2247 dmem->nendpoints = sc->npipes;
2248 dmem->rf_config = 0x12; /* 1T2R */
2249 dmem->vcs_type = R92S_VCS_TYPE_AUTO;
2250 dmem->vcs_mode = R92S_VCS_MODE_RTS_CTS;
2252 dmem->bw40_en = (ic->ic_htcaps & IEEE80211_HTCAP_CBW20_40) != 0;
2254 dmem->turbo_mode = 1;
2258 device_printf(sc->sc_dev,
2269 device_printf(sc->sc_dev, "timeout waiting for %s transfer\n",
2281 device_printf(sc->sc_dev,
2296 struct ieee80211com *ic = ni->ni_ic;
2297 struct ifnet *ifp = ic->ic_ifp;
2298 struct rsu_softc *sc = ifp->if_softc;
2302 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
2315 ifp->if_opackets++;
2318 ifp->if_oerrors++;
2319 STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next);
2324 sc->sc_tx_timer = 5;
2342 struct ifnet *ifp = sc->sc_ifp;
2347 sc->cmdq.cur = sc->cmdq.next = sc->cmdq.queued = 0;
2352 device_printf(sc->sc_dev, "could not allocate Rx buffers\n");
2357 device_printf(sc->sc_dev, "could not allocate Tx buffers\n");
2362 if (sc->cut == 1)
2400 usb_pause_mtx(&sc->sc_mtx, 1500);
2406 device_printf(sc->sc_dev, "could not set MAC address\n");
2418 device_printf(sc->sc_dev, "could not set PS mode\n");
2423 if (ic->ic_htcaps & IEEE80211_HTCAP_CBW20_40) {
2430 device_printf(sc->sc_dev,
2437 ic->ic_bss->ni_chan = ic->ic_ibss_chan;
2439 sc->scan_pass = 0;
2440 usbd_transfer_start(sc->sc_xfer[RSU_BULK_RX]);
2443 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
2444 ifp->if_drv_flags |= IFF_DRV_RUNNING;
2446 callout_reset(&sc->sc_watchdog_ch, hz, rsu_watchdog, sc);
2458 struct rsu_softc *sc = ifp->if_softc;
2468 struct rsu_softc *sc = ifp->if_softc;
2471 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
2472 callout_stop(&sc->sc_watchdog_ch);
2473 sc->sc_calibrating = 0;
2474 taskqueue_cancel_timeout(taskqueue_thread, &sc->calib_task, NULL);
2480 usbd_transfer_stop(sc->sc_xfer[i]);