Lines Matching refs:sc

267 static int	uath_rx_data_xfer(struct uath_softc *sc);
425 uath_open_pipes(struct uath_softc *sc) in uath_open_pipes() argument
435 altif_data = uath_lookup_alt_if(sc->sc_udev, UATH_CONFIG_NO, in uath_open_pipes()
450 ep_node = uath_lookup_ep_data(sc->sc_dev, sc->sc_udev, in uath_open_pipes()
459 err = usb_pipe_open(sc->sc_dev, &ep_node->ep_descr, in uath_open_pipes()
460 &policy, USB_FLAGS_SLEEP, &sc->rx_cmd_pipe); in uath_open_pipes()
469 ep_node = uath_lookup_ep_data(sc->sc_dev, sc->sc_udev, in uath_open_pipes()
479 err = usb_pipe_open(sc->sc_dev, &ep_node->ep_descr, in uath_open_pipes()
480 &policy, USB_FLAGS_SLEEP, &sc->tx_cmd_pipe); in uath_open_pipes()
488 ep_node = uath_lookup_ep_data(sc->sc_dev, sc->sc_udev, in uath_open_pipes()
498 err = usb_pipe_open(sc->sc_dev, &ep_node->ep_descr, in uath_open_pipes()
499 &policy, USB_FLAGS_SLEEP, &sc->rx_data_pipe); in uath_open_pipes()
507 ep_node = uath_lookup_ep_data(sc->sc_dev, sc->sc_udev, in uath_open_pipes()
517 err = usb_pipe_open(sc->sc_dev, &ep_node->ep_descr, in uath_open_pipes()
518 &policy, USB_FLAGS_SLEEP, &sc->tx_data_pipe); in uath_open_pipes()
528 uath_close_pipes(sc); in uath_open_pipes()
533 uath_close_pipes(struct uath_softc *sc) in uath_close_pipes() argument
537 if (sc->rx_cmd_pipe != NULL) { in uath_close_pipes()
538 usb_pipe_reset(sc->sc_dev, sc->rx_cmd_pipe, flags, NULL, 0); in uath_close_pipes()
539 usb_pipe_close(sc->sc_dev, sc->rx_cmd_pipe, flags, NULL, 0); in uath_close_pipes()
540 sc->rx_cmd_pipe = NULL; in uath_close_pipes()
543 if (sc->tx_cmd_pipe != NULL) { in uath_close_pipes()
544 usb_pipe_reset(sc->sc_dev, sc->tx_cmd_pipe, flags, NULL, 0); in uath_close_pipes()
545 usb_pipe_close(sc->sc_dev, sc->tx_cmd_pipe, flags, NULL, 0); in uath_close_pipes()
546 sc->tx_cmd_pipe = NULL; in uath_close_pipes()
549 if (sc->rx_data_pipe != NULL) { in uath_close_pipes()
550 usb_pipe_reset(sc->sc_dev, sc->rx_data_pipe, flags, NULL, 0); in uath_close_pipes()
551 usb_pipe_close(sc->sc_dev, sc->rx_data_pipe, flags, NULL, 0); in uath_close_pipes()
552 sc->rx_data_pipe = NULL; in uath_close_pipes()
555 if (sc->tx_data_pipe != NULL) { in uath_close_pipes()
556 usb_pipe_reset(sc->sc_dev, sc->tx_data_pipe, flags, NULL, 0); in uath_close_pipes()
557 usb_pipe_close(sc->sc_dev, sc->tx_data_pipe, flags, NULL, 0); in uath_close_pipes()
558 sc->tx_data_pipe = NULL; in uath_close_pipes()
640 uath_fw_send(struct uath_softc *sc, usb_pipe_handle_t pipe, in uath_fw_send() argument
647 send_req = usb_alloc_bulk_req(sc->sc_dev, len, USB_FLAGS_SLEEP); in uath_fw_send()
669 uath_fw_ack(struct uath_softc *sc, int len) in uath_fw_ack() argument
676 req = usb_alloc_bulk_req(sc->sc_dev, len, USB_FLAGS_SLEEP); in uath_fw_ack()
685 req->bulk_client_private = (usb_opaque_t)sc; in uath_fw_ack()
690 err = usb_pipe_bulk_xfer(sc->rx_cmd_pipe, req, USB_FLAGS_SLEEP); in uath_fw_ack()
756 uath_loadfirmware(struct uath_softc *sc) in uath_loadfirmware() argument
808 err = uath_fw_send(sc, sc->tx_cmd_pipe, &txblock, in uath_loadfirmware()
817 err = uath_fw_send(sc, sc->tx_data_pipe, fw_index, mlen); in uath_loadfirmware()
825 err = uath_fw_ack(sc, sizeof (struct uath_fwblock)); in uath_loadfirmware()
846 uath_alloc_cmd_list(struct uath_softc *sc, struct uath_cmd cmds[], in uath_alloc_cmd_list() argument
854 cmd->sc = sc; /* backpointer for callbacks */ in uath_alloc_cmd_list()
872 uath_init_cmd_list(struct uath_softc *sc) in uath_init_cmd_list() argument
876 sc->sc_cmdid = sc->rx_cmd_queued = sc->tx_cmd_queued = 0; in uath_init_cmd_list()
878 if (uath_rx_cmd_xfer(sc) != UATH_SUCCESS) { in uath_init_cmd_list()
900 uath_host_available(struct uath_softc *sc) in uath_host_available() argument
909 return (uath_cmd_read(sc, WDCMSG_HOST_AVAILABLE, in uath_host_available()
914 uath_get_capability(struct uath_softc *sc, uint32_t cap, uint32_t *val) in uath_get_capability() argument
919 err = uath_cmd_read(sc, WDCMSG_TARGET_GET_CAPABILITY, &cap, in uath_get_capability()
929 uath_get_devcap(struct uath_softc *sc) in uath_get_devcap() argument
931 struct uath_devcap *cap = &sc->sc_devcap; in uath_get_devcap()
934 uath_get_capability(sc, CAP_TARGET_VERSION, in uath_get_devcap()
936 uath_get_capability(sc, CAP_TARGET_REVISION, in uath_get_devcap()
938 uath_get_capability(sc, CAP_MAC_VERSION, in uath_get_devcap()
940 uath_get_capability(sc, CAP_MAC_REVISION, in uath_get_devcap()
942 uath_get_capability(sc, CAP_PHY_REVISION, in uath_get_devcap()
944 uath_get_capability(sc, CAP_ANALOG_5GHz_REVISION, in uath_get_devcap()
946 uath_get_capability(sc, CAP_ANALOG_2GHz_REVISION, in uath_get_devcap()
948 uath_get_capability(sc, CAP_REG_DOMAIN, in uath_get_devcap()
950 uath_get_capability(sc, CAP_REG_CAP_BITS, in uath_get_devcap()
956 uath_get_capability(sc, CAP_WIRELESS_MODES, in uath_get_devcap()
958 uath_get_capability(sc, CAP_CHAN_SPREAD_SUPPORT, in uath_get_devcap()
960 uath_get_capability(sc, CAP_COMPRESS_SUPPORT, in uath_get_devcap()
962 uath_get_capability(sc, CAP_BURST_SUPPORT, in uath_get_devcap()
964 uath_get_capability(sc, CAP_FAST_FRAMES_SUPPORT, in uath_get_devcap()
966 uath_get_capability(sc, CAP_CHAP_TUNING_SUPPORT, in uath_get_devcap()
968 uath_get_capability(sc, CAP_TURBOG_SUPPORT, in uath_get_devcap()
970 uath_get_capability(sc, CAP_TURBO_PRIME_SUPPORT, in uath_get_devcap()
972 uath_get_capability(sc, CAP_DEVICE_TYPE, in uath_get_devcap()
974 uath_get_capability(sc, CAP_WME_SUPPORT, in uath_get_devcap()
976 uath_get_capability(sc, CAP_TOTAL_QUEUES, in uath_get_devcap()
978 uath_get_capability(sc, CAP_CONNECTION_ID_MAX, in uath_get_devcap()
981 uath_get_capability(sc, CAP_LOW_5GHZ_CHAN, in uath_get_devcap()
983 uath_get_capability(sc, CAP_HIGH_5GHZ_CHAN, in uath_get_devcap()
985 uath_get_capability(sc, CAP_LOW_2GHZ_CHAN, in uath_get_devcap()
987 uath_get_capability(sc, CAP_HIGH_2GHZ_CHAN, in uath_get_devcap()
989 uath_get_capability(sc, CAP_TWICE_ANTENNAGAIN_5G, in uath_get_devcap()
991 uath_get_capability(sc, CAP_TWICE_ANTENNAGAIN_2G, in uath_get_devcap()
994 uath_get_capability(sc, CAP_CIPHER_AES_CCM, in uath_get_devcap()
996 uath_get_capability(sc, CAP_CIPHER_TKIP, in uath_get_devcap()
998 uath_get_capability(sc, CAP_MIC_TKIP, in uath_get_devcap()
1006 uath_get_status(struct uath_softc *sc, uint32_t which, void *odata, int olen) in uath_get_status() argument
1011 err = uath_cmd_read(sc, WDCMSG_TARGET_GET_STATUS, in uath_get_status()
1020 uath_get_devstatus(struct uath_softc *sc, uint8_t macaddr[IEEE80211_ADDR_LEN]) in uath_get_devstatus() argument
1025 err = uath_get_status(sc, ST_MAC_ADDR, macaddr, IEEE80211_ADDR_LEN); in uath_get_devstatus()
1032 err = uath_get_status(sc, ST_SERIAL_NUMBER, in uath_get_devstatus()
1033 &sc->sc_serial[0], sizeof (sc->sc_serial)); in uath_get_devstatus()
1113 uath_cmd_read(struct uath_softc *sc, uint32_t code, const void *idata, in uath_cmd_read() argument
1117 return (uath_cmdsend(sc, code, idata, ilen, odata, olen, flags)); in uath_cmd_read()
1121 uath_cmd_write(struct uath_softc *sc, uint32_t code, const void *data, in uath_cmd_write() argument
1125 return (uath_cmdsend(sc, code, data, len, NULL, 0, flags)); in uath_cmd_write()
1132 uath_cmdsend(struct uath_softc *sc, uint32_t code, const void *idata, int ilen, in uath_cmdsend() argument
1140 cmd = &sc->sc_cmd[sc->sc_cmdid]; in uath_cmdsend()
1167 err = uath_tx_cmd_xfer(sc, sc->tx_cmd_pipe, cmd->buf, cmd->buflen); in uath_cmdsend()
1174 sc->sc_cmdid = (sc->sc_cmdid + 1) % UATH_CMD_LIST_COUNT; in uath_cmdsend()
1178 uath_cmd_lock_init(&sc->rlock); in uath_cmdsend()
1179 err = uath_cmd_lock_wait(&sc->rlock, 2000000); in uath_cmdsend()
1194 uath_cmd_lock_destroy(&sc->rlock); in uath_cmdsend()
1205 struct uath_softc *sc = (struct uath_softc *)req->bulk_client_private; in uath_cmd_txeof() local
1212 sc->tx_cmd_queued); in uath_cmd_txeof()
1215 sc->sc_tx_err++; in uath_cmd_txeof()
1217 mutex_enter(&sc->sc_txlock_cmd); in uath_cmd_txeof()
1218 sc->tx_cmd_queued--; in uath_cmd_txeof()
1219 mutex_exit(&sc->sc_txlock_cmd); in uath_cmd_txeof()
1224 uath_tx_cmd_xfer(struct uath_softc *sc, in uath_tx_cmd_xfer() argument
1231 send_req = usb_alloc_bulk_req(sc->sc_dev, len, USB_FLAGS_SLEEP); in uath_tx_cmd_xfer()
1233 send_req->bulk_client_private = (usb_opaque_t)sc; in uath_tx_cmd_xfer()
1253 mutex_enter(&sc->sc_txlock_cmd); in uath_tx_cmd_xfer()
1254 sc->tx_cmd_queued++; in uath_tx_cmd_xfer()
1255 mutex_exit(&sc->sc_txlock_cmd); in uath_tx_cmd_xfer()
1260 uath_cmdeof(struct uath_softc *sc, struct uath_cmd *cmd) in uath_cmdeof() argument
1349 uath_cmd_lock_signal(&sc->rlock); in uath_cmdeof()
1371 uath_cmd_lock_signal(&sc->rlock); in uath_cmdeof()
1391 struct uath_softc *sc = (struct uath_softc *)req->bulk_client_private; in uath_cmd_rxeof() local
1402 sc->rx_cmd_queued); in uath_cmd_rxeof()
1430 cmd = &sc->sc_cmd[0]; in uath_cmd_rxeof()
1432 cmd = &sc->sc_cmd[hdr->msgid]; in uath_cmd_rxeof()
1435 uath_cmdeof(sc, cmd); in uath_cmd_rxeof()
1436 (void) uath_rx_cmd_xfer(sc); in uath_cmd_rxeof()
1438 mutex_enter(&sc->sc_rxlock_cmd); in uath_cmd_rxeof()
1439 sc->rx_cmd_queued--; in uath_cmd_rxeof()
1440 mutex_exit(&sc->sc_rxlock_cmd); in uath_cmd_rxeof()
1446 uath_rx_cmd_xfer(struct uath_softc *sc) in uath_rx_cmd_xfer() argument
1451 req = usb_alloc_bulk_req(sc->sc_dev, UATH_MAX_CMDSZ, USB_FLAGS_SLEEP); in uath_rx_cmd_xfer()
1459 req->bulk_client_private = (usb_opaque_t)sc; in uath_rx_cmd_xfer()
1468 err = usb_pipe_bulk_xfer(sc->rx_cmd_pipe, req, USB_FLAGS_NOSLEEP); in uath_rx_cmd_xfer()
1476 mutex_enter(&sc->sc_rxlock_cmd); in uath_rx_cmd_xfer()
1477 sc->rx_cmd_queued++; in uath_rx_cmd_xfer()
1478 mutex_exit(&sc->sc_rxlock_cmd); in uath_rx_cmd_xfer()
1483 uath_init_data_queue(struct uath_softc *sc) in uath_init_data_queue() argument
1485 sc->tx_data_queued = sc->rx_data_queued = 0; in uath_init_data_queue()
1492 struct uath_softc *sc = (struct uath_softc *)req->bulk_client_private; in uath_data_txeof() local
1493 struct ieee80211com *ic = &sc->sc_ic; in uath_data_txeof()
1500 sc->tx_data_queued); in uath_data_txeof()
1503 sc->sc_tx_err++; in uath_data_txeof()
1505 mutex_enter(&sc->sc_txlock_data); in uath_data_txeof()
1506 sc->tx_data_queued--; in uath_data_txeof()
1508 if (sc->sc_need_sched) { in uath_data_txeof()
1509 sc->sc_need_sched = 0; in uath_data_txeof()
1513 mutex_exit(&sc->sc_txlock_data); in uath_data_txeof()
1518 uath_tx_data_xfer(struct uath_softc *sc, mblk_t *mp) in uath_tx_data_xfer() argument
1523 req = usb_alloc_bulk_req(sc->sc_dev, 0, USB_FLAGS_SLEEP); in uath_tx_data_xfer()
1533 req->bulk_client_private = (usb_opaque_t)sc; in uath_tx_data_xfer()
1541 if ((err = usb_pipe_bulk_xfer(sc->tx_data_pipe, req, 0)) != in uath_tx_data_xfer()
1550 sc->tx_data_queued++; in uath_tx_data_xfer()
1558 struct uath_softc *sc = (struct uath_softc *)req->bulk_client_private; in uath_data_rxeof() local
1559 struct ieee80211com *ic = &sc->sc_ic; in uath_data_rxeof()
1569 mutex_enter(&sc->sc_rxlock_data); in uath_data_rxeof()
1576 sc->rx_data_queued); in uath_data_rxeof()
1584 sc->sc_rx_err++; in uath_data_rxeof()
1593 sc->sc_rx_err++; in uath_data_rxeof()
1601 UATH_RESET_INTRX(sc); in uath_data_rxeof()
1602 sc->sc_rx_err++; in uath_data_rxeof()
1606 if (chunk->seqnum != sc->sc_intrx_nextnum) { in uath_data_rxeof()
1609 chunk->seqnum, sc->sc_intrx_nextnum); in uath_data_rxeof()
1610 UATH_STAT_INC(sc, st_badchunkseqnum); in uath_data_rxeof()
1611 UATH_RESET_INTRX(sc); in uath_data_rxeof()
1612 sc->sc_rx_err++; in uath_data_rxeof()
1624 UATH_STAT_INC(sc, st_multichunk); in uath_data_rxeof()
1630 sc->sc_intrx_nextnum++; in uath_data_rxeof()
1654 UATH_STAT_INC(sc, st_toobigrxpkt); in uath_data_rxeof()
1658 uath_update_rxstat(sc, BE_32(desc->status)); in uath_data_rxeof()
1665 sc->sc_rx_nobuf++; in uath_data_rxeof()
1680 sc->rx_data_queued--; in uath_data_rxeof()
1683 mutex_exit(&sc->sc_rxlock_data); in uath_data_rxeof()
1684 if (UATH_IS_RUNNING(sc) && !UATH_IS_SUSPEND(sc)) { in uath_data_rxeof()
1685 (void) uath_rx_data_xfer(sc); in uath_data_rxeof()
1690 uath_rx_data_xfer(struct uath_softc *sc) in uath_rx_data_xfer() argument
1695 req = usb_alloc_bulk_req(sc->sc_dev, in uath_rx_data_xfer()
1706 req->bulk_client_private = (usb_opaque_t)sc; in uath_rx_data_xfer()
1713 err = usb_pipe_bulk_xfer(sc->rx_data_pipe, req, 0); in uath_rx_data_xfer()
1721 mutex_enter(&sc->sc_rxlock_data); in uath_rx_data_xfer()
1722 sc->rx_data_queued++; in uath_rx_data_xfer()
1723 mutex_exit(&sc->sc_rxlock_data); in uath_rx_data_xfer()
1728 uath_update_rxstat(struct uath_softc *sc, uint32_t status) in uath_update_rxstat() argument
1733 UATH_STAT_INC(sc, st_stopinprogress); in uath_update_rxstat()
1736 UATH_STAT_INC(sc, st_crcerr); in uath_update_rxstat()
1739 UATH_STAT_INC(sc, st_phyerr); in uath_update_rxstat()
1742 UATH_STAT_INC(sc, st_decrypt_crcerr); in uath_update_rxstat()
1745 UATH_STAT_INC(sc, st_decrypt_micerr); in uath_update_rxstat()
1748 UATH_STAT_INC(sc, st_decomperr); in uath_update_rxstat()
1751 UATH_STAT_INC(sc, st_keyerr); in uath_update_rxstat()
1754 UATH_STAT_INC(sc, st_err); in uath_update_rxstat()
1764 struct uath_softc *sc = arg; in uath_next_scan() local
1765 struct ieee80211com *ic = &sc->sc_ic; in uath_next_scan()
1770 sc->sc_scan_id = 0; in uath_next_scan()
1774 uath_create_connection(struct uath_softc *sc, uint32_t connid) in uath_create_connection() argument
1777 struct ieee80211com *ic = &sc->sc_ic; in uath_create_connection()
1801 err = uath_cmd_write(sc, WDCMSG_CREATE_CONNECTION, &create, in uath_create_connection()
1807 uath_set_rates(struct uath_softc *sc, const struct ieee80211_rateset *rs) in uath_set_rates() argument
1821 err = uath_cmd_write(sc, WDCMSG_SET_BASIC_RATE, in uath_set_rates()
1827 uath_write_associd(struct uath_softc *sc) in uath_write_associd() argument
1829 struct ieee80211com *ic = &sc->sc_ic; in uath_write_associd()
1839 err = uath_cmd_write(sc, WDCMSG_WRITE_ASSOCID, &associd, in uath_write_associd()
1845 uath_set_ledsteady(struct uath_softc *sc, int lednum, int ledmode) in uath_set_ledsteady() argument
1857 err = uath_cmd_write(sc, WDCMSG_SET_LED_STEADY, &led, sizeof (led), 0); in uath_set_ledsteady()
1862 uath_set_ledblink(struct uath_softc *sc, int lednum, int ledmode, in uath_set_ledblink() argument
1878 err = uath_cmd_write(sc, WDCMSG_SET_LED_BLINK, in uath_set_ledblink()
1887 struct uath_softc *sc = (struct uath_softc *)ic; in uath_newstate() local
1896 if (sc->sc_scan_id != 0) { in uath_newstate()
1897 (void) untimeout(sc->sc_scan_id); in uath_newstate()
1898 sc->sc_scan_id = 0; in uath_newstate()
1901 UATH_LOCK(sc); in uath_newstate()
1903 if (UATH_IS_DISCONNECT(sc) && (nstate != IEEE80211_S_INIT)) { in uath_newstate()
1904 UATH_UNLOCK(sc); in uath_newstate()
1908 if (UATH_IS_SUSPEND(sc) && (nstate != IEEE80211_S_INIT)) { in uath_newstate()
1909 UATH_UNLOCK(sc); in uath_newstate()
1917 (void) uath_set_ledstate(sc, 0); in uath_newstate()
1921 if (uath_switch_channel(sc, ic->ic_curchan) != UATH_SUCCESS) { in uath_newstate()
1926 sc->sc_scan_id = timeout(uath_next_scan, (void *)sc, in uath_newstate()
1931 uath_config(sc, CFG_USER_RTS_THRESHOLD, ic->ic_rtsthreshold); in uath_newstate()
1933 if (uath_switch_channel(sc, ni->in_chan) != 0) { in uath_newstate()
1938 if (uath_create_connection(sc, UATH_ID_BSS) != 0) { in uath_newstate()
1945 if (uath_set_rates(sc, &ni->in_rates) != 0) { in uath_newstate()
1954 (void) uath_set_ledstate(sc, 1); in uath_newstate()
1964 if (uath_write_associd(sc) != 0) { in uath_newstate()
1970 (void) uath_set_ledsteady(sc, UATH_LED_LINK, UATH_LED_ON); in uath_newstate()
1972 (void) uath_set_ledblink(sc, UATH_LED_ACTIVITY, in uath_newstate()
1975 (void) uath_set_ledstate(sc, 1); in uath_newstate()
1979 UATH_UNLOCK(sc); in uath_newstate()
1981 err = sc->sc_newstate(ic, nstate, arg); in uath_newstate()
1988 struct uath_softc *sc = (struct uath_softc *)ic; in uath_send() local
2001 mutex_enter(&sc->sc_txlock_data); in uath_send()
2003 if (UATH_IS_SUSPEND(sc)) { in uath_send()
2008 if (sc->tx_data_queued > UATH_TX_DATA_LIST_COUNT) { in uath_send()
2013 sc->sc_need_sched = 1; in uath_send()
2015 sc->sc_tx_nobuf++; in uath_send()
2081 desc->msgid = sc->sc_msgid; /* don't care about endianness */ in uath_send()
2114 (void) uath_tx_data_xfer(sc, m); in uath_send()
2116 sc->sc_msgid = (sc->sc_msgid + 1) % UATH_TX_DATA_LIST_COUNT; in uath_send()
2129 mutex_exit(&sc->sc_txlock_data); in uath_send()
2136 struct uath_softc *sc; in uath_reconnect() local
2144 sc = ddi_get_soft_state(uath_soft_state_p, ddi_get_instance(devinfo)); in uath_reconnect()
2145 ASSERT(sc != NULL); in uath_reconnect()
2146 ic = (struct ieee80211com *)&sc->sc_ic; in uath_reconnect()
2148 if (!UATH_IS_RECONNECT(sc)) { in uath_reconnect()
2149 err = uath_open_pipes(sc); in uath_reconnect()
2156 err = uath_loadfirmware(sc); in uath_reconnect()
2163 uath_close_pipes(sc); in uath_reconnect()
2164 usb_client_detach(sc->sc_dev, sc->sc_udev); in uath_reconnect()
2167 err = usb_reset_device(sc->sc_dev, USB_RESET_LVL_DEFAULT); in uath_reconnect()
2179 err = usb_get_dev_data(devinfo, &sc->sc_udev, in uath_reconnect()
2182 sc->sc_udev = NULL; in uath_reconnect()
2187 vendor_id = sc->sc_udev->dev_descr->idVendor; in uath_reconnect()
2188 product_id = sc->sc_udev->dev_descr->idProduct; in uath_reconnect()
2189 sc->dev_flags = uath_lookup(vendor_id, product_id); in uath_reconnect()
2190 if (sc->dev_flags == UATH_FLAG_ERR) { in uath_reconnect()
2197 vendor_id, product_id, sc->dev_flags); in uath_reconnect()
2199 UATH_LOCK(sc); in uath_reconnect()
2200 sc->sc_flags |= UATH_FLAG_RECONNECT; in uath_reconnect()
2201 UATH_UNLOCK(sc); in uath_reconnect()
2204 err = uath_open_pipes(sc); in uath_reconnect()
2214 err = uath_alloc_cmd_list(sc, sc->sc_cmd, UATH_CMD_LIST_COUNT, in uath_reconnect()
2222 err = uath_init_cmd_list(sc); in uath_reconnect()
2232 err = uath_host_available(sc); in uath_reconnect()
2239 err = uath_get_devcap(sc); in uath_reconnect()
2246 err = uath_get_devstatus(sc, ic->ic_macaddr); in uath_reconnect()
2253 err = usb_check_same_device(sc->sc_dev, NULL, USB_LOG_L2, -1, in uath_reconnect()
2261 err = uath_init(sc); in uath_reconnect()
2268 UATH_LOCK(sc); in uath_reconnect()
2269 sc->sc_flags &= ~UATH_FLAG_RECONNECT; in uath_reconnect()
2270 sc->sc_flags &= ~UATH_FLAG_DISCONNECT; in uath_reconnect()
2271 sc->sc_flags |= UATH_FLAG_RUNNING; in uath_reconnect()
2272 UATH_UNLOCK(sc); in uath_reconnect()
2281 struct uath_softc *sc; in uath_disconnect() local
2288 sc = ddi_get_soft_state(uath_soft_state_p, ddi_get_instance(devinfo)); in uath_disconnect()
2289 ASSERT(sc != NULL); in uath_disconnect()
2291 if (sc->sc_flags & UATH_FLAG_RECONNECT) { in uath_disconnect()
2294 uath_close_pipes(sc); in uath_disconnect()
2298 UATH_LOCK(sc); in uath_disconnect()
2299 sc->sc_flags |= UATH_FLAG_DISCONNECT; in uath_disconnect()
2300 UATH_UNLOCK(sc); in uath_disconnect()
2302 ic = (struct ieee80211com *)&sc->sc_ic; in uath_disconnect()
2305 UATH_LOCK(sc); in uath_disconnect()
2306 sc->sc_flags &= ~UATH_FLAG_RUNNING; /* STOP */ in uath_disconnect()
2307 UATH_UNLOCK(sc); in uath_disconnect()
2310 uath_free_cmd_list(sc->sc_cmd, UATH_CMD_LIST_COUNT); in uath_disconnect()
2313 uath_close_pipes(sc); in uath_disconnect()
2322 uath_dataflush(struct uath_softc *sc) in uath_dataflush() argument
2346 desc->msgid = sc->sc_msgid; /* don't care about endianness */ in uath_dataflush()
2355 err = uath_fw_send(sc, sc->tx_data_pipe, buf, in uath_dataflush()
2364 sc->sc_msgid = (sc->sc_msgid + 1) % UATH_TX_DATA_LIST_COUNT; in uath_dataflush()
2370 uath_cmdflush(struct uath_softc *sc) in uath_cmdflush() argument
2372 return (uath_cmd_write(sc, WDCMSG_FLUSH, NULL, 0, 0)); in uath_cmdflush()
2376 uath_flush(struct uath_softc *sc) in uath_flush() argument
2380 err = uath_dataflush(sc); in uath_flush()
2384 err = uath_cmdflush(sc); in uath_flush()
2394 uath_set_ledstate(struct uath_softc *sc, int connected) in uath_set_ledstate() argument
2402 err = uath_cmd_write(sc, WDCMSG_SET_LED_STATE, in uath_set_ledstate()
2408 uath_config_multi(struct uath_softc *sc, uint32_t reg, const void *data, in uath_config_multi() argument
2419 err = uath_cmd_write(sc, WDCMSG_TARGET_SET_CONFIG, &write, in uath_config_multi()
2429 uath_config(struct uath_softc *sc, uint32_t reg, uint32_t val) in uath_config() argument
2438 err = uath_cmd_write(sc, WDCMSG_TARGET_SET_CONFIG, &write, in uath_config()
2448 uath_switch_channel(struct uath_softc *sc, struct ieee80211_channel *c) in uath_switch_channel() argument
2453 err = uath_set_chan(sc, c); in uath_switch_channel()
2461 err = uath_reset_tx_queues(sc); in uath_switch_channel()
2469 err = uath_wme_init(sc); in uath_switch_channel()
2476 err = uath_set_ledstate(sc, 0); in uath_switch_channel()
2483 err = uath_flush(sc); in uath_switch_channel()
2495 uath_set_rxfilter(struct uath_softc *sc, uint32_t bits, uint32_t op) in uath_set_rxfilter() argument
2505 return ((uath_cmd_write(sc, WDCMSG_RX_FILTER, &rxfilter, in uath_set_rxfilter()
2510 uath_set_chan(struct uath_softc *sc, struct ieee80211_channel *c) in uath_set_chan() argument
2512 struct ieee80211com *ic = &sc->sc_ic; in uath_set_chan()
2539 return (uath_cmd_write(sc, WDCMSG_RESET, &reset, sizeof (reset), 0)); in uath_set_chan()
2543 uath_reset_tx_queues(struct uath_softc *sc) in uath_reset_tx_queues() argument
2549 err = uath_cmd_write(sc, WDCMSG_RELEASE_TX_QUEUE, &qid, in uath_reset_tx_queues()
2558 uath_wme_init(struct uath_softc *sc) in uath_wme_init() argument
2583 err = uath_cmd_write(sc, WDCMSG_SETUP_TX_QUEUE, &qinfo, in uath_wme_init()
2594 struct uath_softc *sc = (struct uath_softc *)arg; in uath_stop_locked() local
2597 (void) uath_flush(sc); in uath_stop_locked()
2600 (void) uath_set_ledstate(sc, 0); in uath_stop_locked()
2603 (void) uath_cmd_write(sc, WDCMSG_TARGET_STOP, NULL, 0, 0); in uath_stop_locked()
2606 usb_pipe_reset(sc->sc_dev, sc->rx_data_pipe, USB_FLAGS_SLEEP, NULL, 0); in uath_stop_locked()
2607 usb_pipe_reset(sc->sc_dev, sc->tx_data_pipe, USB_FLAGS_SLEEP, NULL, 0); in uath_stop_locked()
2608 usb_pipe_reset(sc->sc_dev, sc->tx_cmd_pipe, USB_FLAGS_SLEEP, NULL, 0); in uath_stop_locked()
2614 struct uath_softc *sc = arg; in uath_init_locked() local
2615 struct ieee80211com *ic = &sc->sc_ic; in uath_init_locked()
2619 if (UATH_IS_RUNNING(sc)) in uath_init_locked()
2620 uath_stop_locked(sc); in uath_init_locked()
2622 uath_init_data_queue(sc); in uath_init_locked()
2625 sc->sc_intrx_nextnum = sc->sc_msgid = 0; in uath_init_locked()
2628 (void) uath_cmd_write(sc, WDCMSG_BIND, &val, sizeof (val), 0); in uath_init_locked()
2631 (void) uath_config_multi(sc, CFG_MAC_ADDR, in uath_init_locked()
2635 uath_config(sc, CFG_RATE_CONTROL_ENABLE, 0x00000001); in uath_init_locked()
2636 uath_config(sc, CFG_DIVERSITY_CTL, 0x00000001); in uath_init_locked()
2637 uath_config(sc, CFG_ABOLT, 0x0000003f); in uath_init_locked()
2638 uath_config(sc, CFG_WME_ENABLED, 0x00000001); in uath_init_locked()
2640 uath_config(sc, CFG_SERVICE_TYPE, 1); in uath_init_locked()
2641 uath_config(sc, CFG_TP_SCALE, 0x00000000); in uath_init_locked()
2642 uath_config(sc, CFG_TPC_HALF_DBM5, 0x0000003c); in uath_init_locked()
2643 uath_config(sc, CFG_TPC_HALF_DBM2, 0x0000003c); in uath_init_locked()
2644 uath_config(sc, CFG_OVERRD_TX_POWER, 0x00000000); in uath_init_locked()
2645 uath_config(sc, CFG_GMODE_PROTECTION, 0x00000000); in uath_init_locked()
2646 uath_config(sc, CFG_GMODE_PROTECT_RATE_INDEX, 0x00000003); in uath_init_locked()
2647 uath_config(sc, CFG_PROTECTION_TYPE, 0x00000000); in uath_init_locked()
2648 uath_config(sc, CFG_MODE_CTS, 0x00000002); in uath_init_locked()
2650 err = uath_cmd_read(sc, WDCMSG_TARGET_START, NULL, 0, in uath_init_locked()
2663 err = uath_switch_channel(sc, ic->ic_curchan); in uath_init_locked()
2671 (void) uath_cmd_write(sc, WDCMSG_SET_PWR_MODE, &val, sizeof (val), 0); in uath_init_locked()
2673 (void) uath_cmd_write(sc, WDCMSG_RESET_KEY_CACHE, NULL, 0, 0); in uath_init_locked()
2676 err = uath_rx_data_xfer(sc); in uath_init_locked()
2685 (void) uath_set_rxfilter(sc, 0x0, UATH_FILTER_OP_INIT); in uath_init_locked()
2686 (void) uath_set_rxfilter(sc, in uath_init_locked()
2694 uath_stop_locked(sc); in uath_init_locked()
2699 uath_init(struct uath_softc *sc) in uath_init() argument
2703 UATH_LOCK(sc); in uath_init()
2704 err = uath_init_locked(sc); in uath_init()
2708 UATH_UNLOCK(sc); in uath_init()
2711 UATH_UNLOCK(sc); in uath_init()
2716 uath_stop(struct uath_softc *sc) in uath_stop() argument
2721 UATH_LOCK(sc); in uath_stop()
2722 uath_stop_locked(sc); in uath_stop()
2723 UATH_UNLOCK(sc); in uath_stop()
2727 uath_resume(struct uath_softc *sc) in uath_resume() argument
2735 if (usb_check_same_device(sc->sc_dev, NULL, USB_LOG_L2, -1, in uath_resume()
2745 err = uath_init_cmd_list(sc); in uath_resume()
2752 err = uath_init(sc); in uath_resume()
2756 uath_stop(sc); in uath_resume()
2760 ieee80211_new_state(&sc->sc_ic, IEEE80211_S_INIT, -1); in uath_resume()
2761 UATH_LOCK(sc); in uath_resume()
2762 sc->sc_flags &= ~UATH_FLAG_SUSPEND; in uath_resume()
2763 sc->sc_flags |= UATH_FLAG_RUNNING; in uath_resume()
2764 UATH_UNLOCK(sc); in uath_resume()
2770 struct uath_softc *sc = (struct uath_softc *)arg; in uath_m_start() local
2771 struct ieee80211com *ic = &sc->sc_ic; in uath_m_start()
2777 err = uath_init(sc); in uath_m_start()
2781 uath_stop(sc); in uath_m_start()
2787 UATH_LOCK(sc); in uath_m_start()
2788 sc->sc_flags |= UATH_FLAG_RUNNING; in uath_m_start()
2789 UATH_UNLOCK(sc); in uath_m_start()
2796 struct uath_softc *sc = (struct uath_softc *)arg; in uath_m_stop() local
2797 struct ieee80211com *ic = &sc->sc_ic; in uath_m_stop()
2801 if (!UATH_IS_DISCONNECT(sc)) in uath_m_stop()
2802 uath_stop(sc); in uath_m_stop()
2804 UATH_LOCK(sc); in uath_m_stop()
2805 sc->sc_flags &= ~UATH_FLAG_RUNNING; in uath_m_stop()
2806 UATH_UNLOCK(sc); in uath_m_stop()
2812 struct uath_softc *sc = (struct uath_softc *)arg; in uath_m_ioctl() local
2813 struct ieee80211com *ic = &sc->sc_ic; in uath_m_ioctl()
2817 UATH_LOCK(sc); in uath_m_ioctl()
2820 if (UATH_IS_RUNNING(sc)) { in uath_m_ioctl()
2821 UATH_UNLOCK(sc); in uath_m_ioctl()
2822 (void) uath_init(sc); in uath_m_ioctl()
2825 UATH_LOCK(sc); in uath_m_ioctl()
2829 UATH_UNLOCK(sc); in uath_m_ioctl()
2860 struct uath_softc *sc = (struct uath_softc *)arg; in uath_m_setprop() local
2861 struct ieee80211com *ic = &sc->sc_ic; in uath_m_setprop()
2866 UATH_LOCK(sc); in uath_m_setprop()
2868 if (ic->ic_des_esslen && UATH_IS_RUNNING(sc)) { in uath_m_setprop()
2869 UATH_UNLOCK(sc); in uath_m_setprop()
2870 (void) uath_init(sc); in uath_m_setprop()
2872 UATH_LOCK(sc); in uath_m_setprop()
2876 UATH_UNLOCK(sc); in uath_m_setprop()
2884 struct uath_softc *sc = (struct uath_softc *)arg; in uath_m_getprop() local
2887 err = ieee80211_getprop(&sc->sc_ic, pr_name, wldp_pr_num, in uath_m_getprop()
2896 struct uath_softc *sc = (struct uath_softc *)arg; in uath_m_propinfo() local
2898 ieee80211_propinfo(&sc->sc_ic, pr_name, wldp_pr_num, prh); in uath_m_propinfo()
2904 struct uath_softc *sc = (struct uath_softc *)arg; in uath_m_stat() local
2905 struct ieee80211com *ic = &sc->sc_ic; in uath_m_stat()
2909 UATH_LOCK(sc); in uath_m_stat()
2919 *val = sc->sc_tx_nobuf; in uath_m_stat()
2922 *val = sc->sc_rx_nobuf; in uath_m_stat()
2925 *val = sc->sc_rx_err; in uath_m_stat()
2941 *val = sc->sc_tx_err; in uath_m_stat()
2944 *val = sc->sc_tx_retries; in uath_m_stat()
2956 UATH_UNLOCK(sc); in uath_m_stat()
2959 UATH_UNLOCK(sc); in uath_m_stat()
2962 UATH_UNLOCK(sc); in uath_m_stat()
2970 struct uath_softc *sc = (struct uath_softc *)arg; in uath_m_tx() local
2971 struct ieee80211com *ic = &sc->sc_ic; in uath_m_tx()
2980 UATH_IS_SUSPEND(sc)) { in uath_m_tx()
3002 struct uath_softc *sc; in uath_attach() local
3016 sc = ddi_get_soft_state(uath_soft_state_p, in uath_attach()
3018 ASSERT(sc != NULL); in uath_attach()
3019 uath_resume(sc); in uath_attach()
3033 sc = ddi_get_soft_state(uath_soft_state_p, instance); in uath_attach()
3034 ic = (ieee80211com_t *)&sc->sc_ic; in uath_attach()
3035 sc->sc_dev = devinfo; in uath_attach()
3044 err = usb_get_dev_data(devinfo, &sc->sc_udev, USB_PARSE_LVL_ALL, 0); in uath_attach()
3046 sc->sc_udev = NULL; in uath_attach()
3052 vendor_id = sc->sc_udev->dev_descr->idVendor; in uath_attach()
3053 product_id = sc->sc_udev->dev_descr->idProduct; in uath_attach()
3054 sc->dev_flags = uath_lookup(vendor_id, product_id); in uath_attach()
3055 if (sc->dev_flags == UATH_FLAG_ERR) { in uath_attach()
3063 vendor_id, product_id, sc->dev_flags); in uath_attach()
3069 err = uath_open_pipes(sc); in uath_attach()
3076 if (sc->dev_flags & UATH_FLAG_PRE_FIRMWARE) { in uath_attach()
3077 err = uath_loadfirmware(sc); in uath_attach()
3085 uath_close_pipes(sc); in uath_attach()
3086 usb_client_detach(sc->sc_dev, sc->sc_udev); in uath_attach()
3103 mutex_init(&sc->sc_genlock, NULL, MUTEX_DRIVER, NULL); in uath_attach()
3104 mutex_init(&sc->sc_rxlock_cmd, NULL, MUTEX_DRIVER, NULL); in uath_attach()
3105 mutex_init(&sc->sc_txlock_cmd, NULL, MUTEX_DRIVER, NULL); in uath_attach()
3106 mutex_init(&sc->sc_rxlock_data, NULL, MUTEX_DRIVER, NULL); in uath_attach()
3107 mutex_init(&sc->sc_txlock_data, NULL, MUTEX_DRIVER, NULL); in uath_attach()
3112 err = uath_alloc_cmd_list(sc, sc->sc_cmd, UATH_CMD_LIST_COUNT, in uath_attach()
3120 err = uath_init_cmd_list(sc); in uath_attach()
3130 err = uath_host_available(sc); in uath_attach()
3137 err = uath_get_devcap(sc); in uath_attach()
3144 err = uath_get_devstatus(sc, ic->ic_macaddr); in uath_attach()
3192 sc->sc_newstate = ic->ic_newstate; in uath_attach()
3197 sc->sc_flags = 0; in uath_attach()
3214 macp->m_driver = sc; in uath_attach()
3262 uath_free_cmd_list(sc->sc_cmd, UATH_CMD_LIST_COUNT); in uath_attach()
3264 mutex_destroy(&sc->sc_genlock); in uath_attach()
3265 mutex_destroy(&sc->sc_rxlock_cmd); in uath_attach()
3266 mutex_destroy(&sc->sc_rxlock_data); in uath_attach()
3267 mutex_destroy(&sc->sc_txlock_cmd); in uath_attach()
3268 mutex_destroy(&sc->sc_txlock_data); in uath_attach()
3270 uath_close_pipes(sc); in uath_attach()
3272 usb_client_detach(sc->sc_dev, sc->sc_udev); in uath_attach()
3281 struct uath_softc *sc; in uath_detach() local
3283 sc = ddi_get_soft_state(uath_soft_state_p, ddi_get_instance(devinfo)); in uath_detach()
3284 ASSERT(sc != NULL); in uath_detach()
3290 if (UATH_IS_RUNNING(sc)) { in uath_detach()
3291 ieee80211_new_state(&sc->sc_ic, IEEE80211_S_INIT, -1); in uath_detach()
3292 uath_stop(sc); in uath_detach()
3294 UATH_LOCK(sc); in uath_detach()
3295 sc->sc_flags &= ~UATH_FLAG_RUNNING; in uath_detach()
3296 sc->sc_flags |= UATH_FLAG_SUSPEND; in uath_detach()
3297 UATH_UNLOCK(sc); in uath_detach()
3303 if (sc->dev_flags & UATH_FLAG_PRE_FIRMWARE) { in uath_detach()
3309 if (!UATH_IS_DISCONNECT(sc) && UATH_IS_RUNNING(sc)) in uath_detach()
3310 uath_stop(sc); in uath_detach()
3312 uath_free_cmd_list(sc->sc_cmd, UATH_CMD_LIST_COUNT); in uath_detach()
3314 if (mac_disable(sc->sc_ic.ic_mach) != 0) in uath_detach()
3320 if (mac_unregister(sc->sc_ic.ic_mach) != 0) in uath_detach()
3326 ieee80211_detach(&sc->sc_ic); in uath_detach()
3329 uath_close_pipes(sc); in uath_detach()
3332 mutex_destroy(&sc->sc_genlock); in uath_detach()
3333 mutex_destroy(&sc->sc_rxlock_cmd); in uath_detach()
3334 mutex_destroy(&sc->sc_rxlock_data); in uath_detach()
3335 mutex_destroy(&sc->sc_txlock_cmd); in uath_detach()
3336 mutex_destroy(&sc->sc_txlock_data); in uath_detach()
3339 usb_client_detach(devinfo, sc->sc_udev); in uath_detach()
3340 sc->sc_udev = NULL; in uath_detach()