Lines Matching refs:priv
612 static int at76_get_hw_config(struct at76_priv *priv) in at76_get_hw_config() argument
620 if (at76_is_intersil(priv->board_type)) { in at76_get_hw_config()
621 ret = at76_get_hw_cfg_intersil(priv->udev, hwcfg, in at76_get_hw_config()
625 memcpy(priv->mac_addr, hwcfg->i.mac_addr, ETH_ALEN); in at76_get_hw_config()
626 priv->regulatory_domain = hwcfg->i.regulatory_domain; in at76_get_hw_config()
627 } else if (at76_is_503rfmd(priv->board_type)) { in at76_get_hw_config()
628 ret = at76_get_hw_cfg(priv->udev, hwcfg, sizeof(hwcfg->r3)); in at76_get_hw_config()
631 memcpy(priv->mac_addr, hwcfg->r3.mac_addr, ETH_ALEN); in at76_get_hw_config()
632 priv->regulatory_domain = hwcfg->r3.regulatory_domain; in at76_get_hw_config()
634 ret = at76_get_hw_cfg(priv->udev, hwcfg, sizeof(hwcfg->r5)); in at76_get_hw_config()
637 memcpy(priv->mac_addr, hwcfg->r5.mac_addr, ETH_ALEN); in at76_get_hw_config()
638 priv->regulatory_domain = hwcfg->r5.regulatory_domain; in at76_get_hw_config()
644 wiphy_err(priv->hw->wiphy, "cannot get HW Config (error %d)\n", in at76_get_hw_config()
772 static int at76_wait_completion(struct at76_priv *priv, int cmd) in at76_wait_completion() argument
778 status = at76_get_cmd_status(priv->udev, cmd); in at76_wait_completion()
780 wiphy_err(priv->hw->wiphy, in at76_wait_completion()
788 wiphy_name(priv->hw->wiphy), cmd, status, in at76_wait_completion()
797 wiphy_err(priv->hw->wiphy, in at76_wait_completion()
807 static int at76_set_mib(struct at76_priv *priv, struct set_mib_buffer *buf) in at76_set_mib() argument
811 ret = at76_set_card_command(priv->udev, CMD_SET_MIB, buf, in at76_set_mib()
817 ret = at76_wait_completion(priv, CMD_SET_MIB); in at76_set_mib()
819 wiphy_info(priv->hw->wiphy, in at76_set_mib()
829 static int at76_set_radio(struct at76_priv *priv, int enable) in at76_set_radio() argument
834 if (priv->radio_on == enable) in at76_set_radio()
839 ret = at76_set_card_command(priv->udev, cmd, NULL, 0); in at76_set_radio()
841 wiphy_err(priv->hw->wiphy, in at76_set_radio()
846 priv->radio_on = enable; in at76_set_radio()
851 static int at76_set_pm_mode(struct at76_priv *priv) in at76_set_pm_mode() argument
855 priv->mib_buf.type = MIB_MAC_MGMT; in at76_set_pm_mode()
856 priv->mib_buf.size = 1; in at76_set_pm_mode()
857 priv->mib_buf.index = offsetof(struct mib_mac_mgmt, power_mgmt_mode); in at76_set_pm_mode()
858 priv->mib_buf.data.byte = priv->pm_mode; in at76_set_pm_mode()
860 ret = at76_set_mib(priv, &priv->mib_buf); in at76_set_pm_mode()
862 wiphy_err(priv->hw->wiphy, "set_mib (pm_mode) failed: %d\n", in at76_set_pm_mode()
868 static int at76_set_preamble(struct at76_priv *priv, u8 type) in at76_set_preamble() argument
872 priv->mib_buf.type = MIB_LOCAL; in at76_set_preamble()
873 priv->mib_buf.size = 1; in at76_set_preamble()
874 priv->mib_buf.index = offsetof(struct mib_local, preamble_type); in at76_set_preamble()
875 priv->mib_buf.data.byte = type; in at76_set_preamble()
877 ret = at76_set_mib(priv, &priv->mib_buf); in at76_set_preamble()
879 wiphy_err(priv->hw->wiphy, "set_mib (preamble) failed: %d\n", in at76_set_preamble()
885 static int at76_set_frag(struct at76_priv *priv, u16 size) in at76_set_frag() argument
889 priv->mib_buf.type = MIB_MAC; in at76_set_frag()
890 priv->mib_buf.size = 2; in at76_set_frag()
891 priv->mib_buf.index = offsetof(struct mib_mac, frag_threshold); in at76_set_frag()
892 priv->mib_buf.data.word = cpu_to_le16(size); in at76_set_frag()
894 ret = at76_set_mib(priv, &priv->mib_buf); in at76_set_frag()
896 wiphy_err(priv->hw->wiphy, in at76_set_frag()
902 static int at76_set_rts(struct at76_priv *priv, u16 size) in at76_set_rts() argument
906 priv->mib_buf.type = MIB_MAC; in at76_set_rts()
907 priv->mib_buf.size = 2; in at76_set_rts()
908 priv->mib_buf.index = offsetof(struct mib_mac, rts_threshold); in at76_set_rts()
909 priv->mib_buf.data.word = cpu_to_le16(size); in at76_set_rts()
911 ret = at76_set_mib(priv, &priv->mib_buf); in at76_set_rts()
913 wiphy_err(priv->hw->wiphy, "set_mib (rts) failed: %d\n", ret); in at76_set_rts()
918 static int at76_set_autorate_fallback(struct at76_priv *priv, int onoff) in at76_set_autorate_fallback() argument
922 priv->mib_buf.type = MIB_LOCAL; in at76_set_autorate_fallback()
923 priv->mib_buf.size = 1; in at76_set_autorate_fallback()
924 priv->mib_buf.index = offsetof(struct mib_local, txautorate_fallback); in at76_set_autorate_fallback()
925 priv->mib_buf.data.byte = onoff; in at76_set_autorate_fallback()
927 ret = at76_set_mib(priv, &priv->mib_buf); in at76_set_autorate_fallback()
929 wiphy_err(priv->hw->wiphy, in at76_set_autorate_fallback()
935 static void at76_dump_mib_mac_addr(struct at76_priv *priv) in at76_dump_mib_mac_addr() argument
945 ret = at76_get_mib(priv->udev, MIB_MAC_ADDR, m, in at76_dump_mib_mac_addr()
948 wiphy_err(priv->hw->wiphy, in at76_dump_mib_mac_addr()
954 wiphy_name(priv->hw->wiphy), in at76_dump_mib_mac_addr()
958 "status %d", wiphy_name(priv->hw->wiphy), i, in at76_dump_mib_mac_addr()
964 static void at76_dump_mib_mac_wep(struct at76_priv *priv) in at76_dump_mib_mac_wep() argument
974 ret = at76_get_mib(priv->udev, MIB_MAC_WEP, m, in at76_dump_mib_mac_wep()
977 wiphy_err(priv->hw->wiphy, in at76_dump_mib_mac_wep()
984 "encr_level %u key %d", wiphy_name(priv->hw->wiphy), in at76_dump_mib_mac_wep()
996 wiphy_name(priv->hw->wiphy), i, in at76_dump_mib_mac_wep()
1002 static void at76_dump_mib_mac_mgmt(struct at76_priv *priv) in at76_dump_mib_mac_mgmt() argument
1011 ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, m, in at76_dump_mib_mac_mgmt()
1014 wiphy_err(priv->hw->wiphy, in at76_dump_mib_mac_mgmt()
1026 wiphy_name(priv->hw->wiphy), le16_to_cpu(m->beacon_period), in at76_dump_mib_mac_mgmt()
1040 static void at76_dump_mib_mac(struct at76_priv *priv) in at76_dump_mib_mac() argument
1048 ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(struct mib_mac)); in at76_dump_mib_mac()
1050 wiphy_err(priv->hw->wiphy, in at76_dump_mib_mac()
1061 wiphy_name(priv->hw->wiphy), in at76_dump_mib_mac()
1077 static void at76_dump_mib_phy(struct at76_priv *priv) in at76_dump_mib_phy() argument
1085 ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(struct mib_phy)); in at76_dump_mib_phy()
1087 wiphy_err(priv->hw->wiphy, in at76_dump_mib_phy()
1097 wiphy_name(priv->hw->wiphy), le32_to_cpu(m->ed_threshold), in at76_dump_mib_phy()
1110 static void at76_dump_mib_local(struct at76_priv *priv) in at76_dump_mib_local() argument
1118 ret = at76_get_mib(priv->udev, MIB_LOCAL, m, sizeof(*m)); in at76_dump_mib_local()
1120 wiphy_err(priv->hw->wiphy, in at76_dump_mib_local()
1127 "preamble_type %d", wiphy_name(priv->hw->wiphy), in at76_dump_mib_local()
1135 static void at76_dump_mib_mdomain(struct at76_priv *priv) in at76_dump_mib_mdomain() argument
1143 ret = at76_get_mib(priv->udev, MIB_MDOMAIN, m, in at76_dump_mib_mdomain()
1146 wiphy_err(priv->hw->wiphy, in at76_dump_mib_mdomain()
1152 wiphy_name(priv->hw->wiphy), in at76_dump_mib_mdomain()
1156 wiphy_name(priv->hw->wiphy), in at76_dump_mib_mdomain()
1163 static int at76_start_monitor(struct at76_priv *priv) in at76_start_monitor() argument
1171 scan.channel = priv->channel; in at76_start_monitor()
1174 scan.min_channel_time = cpu_to_le16(priv->scan_min_time); in at76_start_monitor()
1175 scan.max_channel_time = cpu_to_le16(priv->scan_max_time); in at76_start_monitor()
1178 ret = at76_set_card_command(priv->udev, CMD_SCAN, &scan, sizeof(scan)); in at76_start_monitor()
1180 ret = at76_get_cmd_status(priv->udev, CMD_SCAN); in at76_start_monitor()
1205 struct at76_priv *priv = urb->context; in at76_rx_callback() local
1207 priv->rx_tasklet.data = (unsigned long)urb; in at76_rx_callback()
1208 tasklet_schedule(&priv->rx_tasklet); in at76_rx_callback()
1211 static int at76_submit_rx_urb(struct at76_priv *priv) in at76_submit_rx_urb() argument
1215 struct sk_buff *skb = priv->rx_skb; in at76_submit_rx_urb()
1217 if (!priv->rx_urb) { in at76_submit_rx_urb()
1218 wiphy_err(priv->hw->wiphy, "%s: priv->rx_urb is NULL\n", in at76_submit_rx_urb()
1226 wiphy_err(priv->hw->wiphy, in at76_submit_rx_urb()
1231 priv->rx_skb = skb; in at76_submit_rx_urb()
1238 usb_fill_bulk_urb(priv->rx_urb, priv->udev, priv->rx_pipe, in at76_submit_rx_urb()
1239 skb_put(skb, size), size, at76_rx_callback, priv); in at76_submit_rx_urb()
1240 ret = usb_submit_urb(priv->rx_urb, GFP_ATOMIC); in at76_submit_rx_urb()
1246 wiphy_err(priv->hw->wiphy, in at76_submit_rx_urb()
1252 wiphy_err(priv->hw->wiphy, in at76_submit_rx_urb()
1354 static int at76_startup_device(struct at76_priv *priv) in at76_startup_device() argument
1356 struct at76_card_config *ccfg = &priv->card_config; in at76_startup_device()
1361 "keylen %d", wiphy_name(priv->hw->wiphy), priv->essid_size, in at76_startup_device()
1362 priv->essid, IW_ESSID_MAX_SIZE, priv->essid, in at76_startup_device()
1363 priv->iw_mode == IW_MODE_ADHOC ? "adhoc" : "infra", in at76_startup_device()
1364 priv->channel, priv->wep_enabled ? "enabled" : "disabled", in at76_startup_device()
1365 priv->wep_key_id, priv->wep_keys_len[priv->wep_key_id]); in at76_startup_device()
1368 "txrate %s auth_mode %d", wiphy_name(priv->hw->wiphy), in at76_startup_device()
1369 preambles[priv->preamble_type], priv->rts_threshold, in at76_startup_device()
1370 priv->short_retry_limit, priv->frag_threshold, in at76_startup_device()
1371 priv->txrate == TX_RATE_1MBIT ? "1MBit" : priv->txrate == in at76_startup_device()
1372 TX_RATE_2MBIT ? "2MBit" : priv->txrate == in at76_startup_device()
1373 TX_RATE_5_5MBIT ? "5.5MBit" : priv->txrate == in at76_startup_device()
1374 TX_RATE_11MBIT ? "11MBit" : priv->txrate == in at76_startup_device()
1375 TX_RATE_AUTO ? "auto" : "<invalid>", priv->auth_mode); in at76_startup_device()
1379 wiphy_name(priv->hw->wiphy), priv->pm_mode, priv->pm_period, in at76_startup_device()
1380 priv->auth_mode == WLAN_AUTH_OPEN ? "open" : "shared_secret", in at76_startup_device()
1381 priv->scan_min_time, priv->scan_max_time, in at76_startup_device()
1382 priv->scan_mode == SCAN_TYPE_ACTIVE ? "active" : "passive"); in at76_startup_device()
1386 ccfg->short_retry_limit = priv->short_retry_limit; in at76_startup_device()
1388 if (priv->wep_enabled) { in at76_startup_device()
1389 if (priv->wep_keys_len[priv->wep_key_id] > WEP_SMALL_KEY_LEN) in at76_startup_device()
1401 ccfg->rts_threshold = cpu_to_le16(priv->rts_threshold); in at76_startup_device()
1402 ccfg->fragmentation_threshold = cpu_to_le16(priv->frag_threshold); in at76_startup_device()
1406 ccfg->auto_rate_fallback = (priv->txrate == TX_RATE_AUTO ? 1 : 0); in at76_startup_device()
1407 ccfg->channel = priv->channel; in at76_startup_device()
1408 ccfg->privacy_invoked = priv->wep_enabled; in at76_startup_device()
1409 memcpy(ccfg->current_ssid, priv->essid, IW_ESSID_MAX_SIZE); in at76_startup_device()
1410 ccfg->ssid_len = priv->essid_size; in at76_startup_device()
1412 ccfg->wep_default_key_id = priv->wep_key_id; in at76_startup_device()
1413 memcpy(ccfg->wep_default_key_value, priv->wep_keys, in at76_startup_device()
1414 sizeof(priv->wep_keys)); in at76_startup_device()
1416 ccfg->short_preamble = priv->preamble_type; in at76_startup_device()
1417 ccfg->beacon_period = cpu_to_le16(priv->beacon_period); in at76_startup_device()
1419 ret = at76_set_card_command(priv->udev, CMD_STARTUP, &priv->card_config, in at76_startup_device()
1422 wiphy_err(priv->hw->wiphy, "at76_set_card_command failed: %d\n", in at76_startup_device()
1427 at76_wait_completion(priv, CMD_STARTUP); in at76_startup_device()
1430 eth_zero_addr(priv->bssid); in at76_startup_device()
1432 priv->scanning = false; in at76_startup_device()
1434 if (at76_set_radio(priv, 1) == 1) in at76_startup_device()
1435 at76_wait_completion(priv, CMD_RADIO_ON); in at76_startup_device()
1437 ret = at76_set_preamble(priv, priv->preamble_type); in at76_startup_device()
1441 ret = at76_set_frag(priv, priv->frag_threshold); in at76_startup_device()
1445 ret = at76_set_rts(priv, priv->rts_threshold); in at76_startup_device()
1449 ret = at76_set_autorate_fallback(priv, in at76_startup_device()
1450 priv->txrate == TX_RATE_AUTO ? 1 : 0); in at76_startup_device()
1454 ret = at76_set_pm_mode(priv); in at76_startup_device()
1459 at76_dump_mib_mac(priv); in at76_startup_device()
1460 at76_dump_mib_mac_addr(priv); in at76_startup_device()
1461 at76_dump_mib_mac_mgmt(priv); in at76_startup_device()
1462 at76_dump_mib_mac_wep(priv); in at76_startup_device()
1463 at76_dump_mib_mdomain(priv); in at76_startup_device()
1464 at76_dump_mib_phy(priv); in at76_startup_device()
1465 at76_dump_mib_local(priv); in at76_startup_device()
1474 struct at76_priv *priv = container_of(work, struct at76_priv, in at76_work_set_promisc() local
1478 if (priv->device_unplugged) in at76_work_set_promisc()
1481 mutex_lock(&priv->mtx); in at76_work_set_promisc()
1483 priv->mib_buf.type = MIB_LOCAL; in at76_work_set_promisc()
1484 priv->mib_buf.size = 1; in at76_work_set_promisc()
1485 priv->mib_buf.index = offsetof(struct mib_local, promiscuous_mode); in at76_work_set_promisc()
1486 priv->mib_buf.data.byte = priv->promisc ? 1 : 0; in at76_work_set_promisc()
1488 ret = at76_set_mib(priv, &priv->mib_buf); in at76_work_set_promisc()
1490 wiphy_err(priv->hw->wiphy, in at76_work_set_promisc()
1493 mutex_unlock(&priv->mtx); in at76_work_set_promisc()
1499 struct at76_priv *priv = container_of(work, struct at76_priv, in at76_work_submit_rx() local
1502 mutex_lock(&priv->mtx); in at76_work_submit_rx()
1503 at76_submit_rx_urb(priv); in at76_work_submit_rx()
1504 mutex_unlock(&priv->mtx); in at76_work_submit_rx()
1520 static inline int at76_guess_freq(struct at76_priv *priv) in at76_guess_freq() argument
1524 int channel = priv->channel; in at76_guess_freq()
1525 int len = priv->rx_skb->len; in at76_guess_freq()
1526 struct ieee80211_hdr *hdr = (void *)priv->rx_skb->data; in at76_guess_freq()
1528 if (!priv->scanning) in at76_guess_freq()
1556 struct at76_priv *priv = urb->context; in at76_rx_tasklet() local
1560 if (priv->device_unplugged) { in at76_rx_tasklet()
1566 if (!priv->rx_skb || !priv->rx_skb->data) in at76_rx_tasklet()
1569 buf = (struct at76_rx_buffer *)priv->rx_skb->data; in at76_rx_tasklet()
1575 __func__, wiphy_name(priv->hw->wiphy), in at76_rx_tasklet()
1582 wiphy_name(priv->hw->wiphy), buf->rx_rate, buf->rssi, in at76_rx_tasklet()
1585 skb_pull(priv->rx_skb, AT76_RX_HDRLEN); in at76_rx_tasklet()
1586 skb_trim(priv->rx_skb, le16_to_cpu(buf->wlength)); in at76_rx_tasklet()
1587 at76_dbg_dump(DBG_RX_DATA, priv->rx_skb->data, in at76_rx_tasklet()
1588 priv->rx_skb->len, "RX: len=%d", priv->rx_skb->len); in at76_rx_tasklet()
1594 rx_status.freq = at76_guess_freq(priv); in at76_rx_tasklet()
1597 priv->rx_skb->len, priv->rx_skb->data_len); in at76_rx_tasklet()
1598 memcpy(IEEE80211_SKB_RXCB(priv->rx_skb), &rx_status, sizeof(rx_status)); in at76_rx_tasklet()
1599 ieee80211_rx_irqsafe(priv->hw, priv->rx_skb); in at76_rx_tasklet()
1602 priv->rx_skb = NULL; in at76_rx_tasklet()
1604 at76_submit_rx_urb(priv); in at76_rx_tasklet()
1682 static int at76_join(struct at76_priv *priv) in at76_join() argument
1688 memcpy(join.essid, priv->essid, priv->essid_size); in at76_join()
1689 join.essid_size = priv->essid_size; in at76_join()
1690 memcpy(join.bssid, priv->bssid, ETH_ALEN); in at76_join()
1692 join.channel = priv->channel; in at76_join()
1696 ret = at76_set_card_command(priv->udev, CMD_JOIN, &join, in at76_join()
1700 wiphy_err(priv->hw->wiphy, "at76_set_card_command failed: %d\n", in at76_join()
1705 ret = at76_wait_completion(priv, CMD_JOIN); in at76_join()
1708 wiphy_err(priv->hw->wiphy, "at76_wait_completion failed: %d\n", in at76_join()
1713 at76_set_pm_mode(priv); in at76_join()
1720 struct at76_priv *priv = container_of(work, struct at76_priv, in at76_work_join_bssid() local
1723 if (priv->device_unplugged) in at76_work_join_bssid()
1726 mutex_lock(&priv->mtx); in at76_work_join_bssid()
1728 if (is_valid_ether_addr(priv->bssid)) in at76_work_join_bssid()
1729 at76_join(priv); in at76_work_join_bssid()
1731 mutex_unlock(&priv->mtx); in at76_work_join_bssid()
1736 struct at76_priv *priv = urb->context; in at76_mac80211_tx_callback() local
1737 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(priv->tx_skb); in at76_mac80211_tx_callback()
1759 ieee80211_tx_status_irqsafe(priv->hw, priv->tx_skb); in at76_mac80211_tx_callback()
1761 priv->tx_skb = NULL; in at76_mac80211_tx_callback()
1763 ieee80211_wake_queues(priv->hw); in at76_mac80211_tx_callback()
1770 struct at76_priv *priv = hw->priv; in at76_mac80211_tx() local
1771 struct at76_tx_buffer *tx_buffer = priv->bulk_out_buffer; in at76_mac80211_tx()
1778 if (priv->tx_urb->status == -EINPROGRESS) { in at76_mac80211_tx()
1779 wiphy_err(priv->hw->wiphy, in at76_mac80211_tx()
1793 if (!ether_addr_equal_64bits(priv->bssid, mgmt->bssid)) { in at76_mac80211_tx()
1794 memcpy(priv->bssid, mgmt->bssid, ETH_ALEN); in at76_mac80211_tx()
1795 ieee80211_queue_work(hw, &priv->work_join_bssid); in at76_mac80211_tx()
1805 WARN_ON(priv->tx_skb != NULL); in at76_mac80211_tx()
1807 priv->tx_skb = skb; in at76_mac80211_tx()
1820 wiphy_name(priv->hw->wiphy), le16_to_cpu(tx_buffer->wlength), in at76_mac80211_tx()
1826 usb_fill_bulk_urb(priv->tx_urb, priv->udev, priv->tx_pipe, tx_buffer, in at76_mac80211_tx()
1827 submit_len, at76_mac80211_tx_callback, priv); in at76_mac80211_tx()
1828 ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC); in at76_mac80211_tx()
1830 wiphy_err(priv->hw->wiphy, "error in tx submit urb: %d\n", ret); in at76_mac80211_tx()
1832 wiphy_err(priv->hw->wiphy, in at76_mac80211_tx()
1834 priv->tx_urb, in at76_mac80211_tx()
1835 priv->tx_urb->hcpriv, priv->tx_urb->complete); in at76_mac80211_tx()
1841 struct at76_priv *priv = hw->priv; in at76_mac80211_start() local
1846 mutex_lock(&priv->mtx); in at76_mac80211_start()
1848 ret = at76_submit_rx_urb(priv); in at76_mac80211_start()
1850 wiphy_err(priv->hw->wiphy, "open: submit_rx_urb failed: %d\n", in at76_mac80211_start()
1855 at76_startup_device(priv); in at76_mac80211_start()
1857 at76_start_monitor(priv); in at76_mac80211_start()
1860 mutex_unlock(&priv->mtx); in at76_mac80211_start()
1867 struct at76_priv *priv = hw->priv; in at76_mac80211_stop() local
1871 cancel_delayed_work(&priv->dwork_hw_scan); in at76_mac80211_stop()
1872 cancel_work_sync(&priv->work_join_bssid); in at76_mac80211_stop()
1873 cancel_work_sync(&priv->work_set_promisc); in at76_mac80211_stop()
1875 mutex_lock(&priv->mtx); in at76_mac80211_stop()
1877 if (!priv->device_unplugged) { in at76_mac80211_stop()
1880 at76_set_radio(priv, 0); in at76_mac80211_stop()
1884 usb_kill_urb(priv->rx_urb); in at76_mac80211_stop()
1887 mutex_unlock(&priv->mtx); in at76_mac80211_stop()
1893 struct at76_priv *priv = hw->priv; in at76_add_interface() local
1898 mutex_lock(&priv->mtx); in at76_add_interface()
1902 priv->iw_mode = IW_MODE_INFRA; in at76_add_interface()
1910 mutex_unlock(&priv->mtx); in at76_add_interface()
1923 struct at76_priv *priv = container_of(work, struct at76_priv, in at76_dwork_hw_scan() local
1927 if (priv->device_unplugged) in at76_dwork_hw_scan()
1930 mutex_lock(&priv->mtx); in at76_dwork_hw_scan()
1932 ret = at76_get_cmd_status(priv->udev, CMD_SCAN); in at76_dwork_hw_scan()
1938 ieee80211_queue_delayed_work(priv->hw, &priv->dwork_hw_scan, in at76_dwork_hw_scan()
1940 mutex_unlock(&priv->mtx); in at76_dwork_hw_scan()
1944 if (is_valid_ether_addr(priv->bssid)) in at76_dwork_hw_scan()
1945 at76_join(priv); in at76_dwork_hw_scan()
1947 priv->scanning = false; in at76_dwork_hw_scan()
1949 mutex_unlock(&priv->mtx); in at76_dwork_hw_scan()
1951 ieee80211_scan_completed(priv->hw, false); in at76_dwork_hw_scan()
1953 ieee80211_wake_queues(priv->hw); in at76_dwork_hw_scan()
1961 struct at76_priv *priv = hw->priv; in at76_hw_scan() local
1968 if (priv->device_unplugged) in at76_hw_scan()
1971 mutex_lock(&priv->mtx); in at76_hw_scan()
1991 scan.min_channel_time = cpu_to_le16(priv->scan_min_time); in at76_hw_scan()
1992 scan.max_channel_time = cpu_to_le16(priv->scan_max_time); in at76_hw_scan()
1993 scan.probe_delay = cpu_to_le16(priv->scan_min_time * 1000); in at76_hw_scan()
1997 ret = at76_set_card_command(priv->udev, CMD_SCAN, &scan, sizeof(scan)); in at76_hw_scan()
2000 wiphy_err(priv->hw->wiphy, "CMD_SCAN failed: %d\n", ret); in at76_hw_scan()
2004 priv->scanning = true; in at76_hw_scan()
2005 ieee80211_queue_delayed_work(priv->hw, &priv->dwork_hw_scan, in at76_hw_scan()
2009 mutex_unlock(&priv->mtx); in at76_hw_scan()
2016 struct at76_priv *priv = hw->priv; in at76_config() local
2020 at76_dbg_dump(DBG_MAC80211, priv->bssid, ETH_ALEN, "bssid:"); in at76_config()
2022 mutex_lock(&priv->mtx); in at76_config()
2024 priv->channel = hw->conf.chandef.chan->hw_value; in at76_config()
2026 if (is_valid_ether_addr(priv->bssid)) in at76_config()
2027 at76_join(priv); in at76_config()
2029 at76_start_monitor(priv); in at76_config()
2031 mutex_unlock(&priv->mtx); in at76_config()
2041 struct at76_priv *priv = hw->priv; in at76_bss_info_changed() local
2050 mutex_lock(&priv->mtx); in at76_bss_info_changed()
2052 memcpy(priv->bssid, conf->bssid, ETH_ALEN); in at76_bss_info_changed()
2054 if (is_valid_ether_addr(priv->bssid)) in at76_bss_info_changed()
2056 at76_join(priv); in at76_bss_info_changed()
2058 mutex_unlock(&priv->mtx); in at76_bss_info_changed()
2066 struct at76_priv *priv = hw->priv; in at76_configure_filter() local
2077 if (priv->device_unplugged) in at76_configure_filter()
2084 if (flags && !priv->promisc) { in at76_configure_filter()
2086 priv->promisc = 1; in at76_configure_filter()
2087 } else if (!flags && priv->promisc) { in at76_configure_filter()
2089 priv->promisc = 0; in at76_configure_filter()
2093 ieee80211_queue_work(hw, &priv->work_set_promisc); in at76_configure_filter()
2096 static int at76_set_wep(struct at76_priv *priv) in at76_set_wep() argument
2099 struct mib_mac_wep *mib_data = &priv->mib_buf.data.wep_mib; in at76_set_wep()
2101 priv->mib_buf.type = MIB_MAC_WEP; in at76_set_wep()
2102 priv->mib_buf.size = sizeof(struct mib_mac_wep); in at76_set_wep()
2103 priv->mib_buf.index = 0; in at76_set_wep()
2107 if (priv->wep_enabled) { in at76_set_wep()
2108 if (priv->wep_keys_len[priv->wep_key_id] > WEP_SMALL_KEY_LEN) in at76_set_wep()
2120 mib_data->privacy_invoked = priv->wep_enabled; in at76_set_wep()
2121 mib_data->wep_default_key_id = priv->wep_key_id; in at76_set_wep()
2122 memcpy(mib_data->wep_default_keyvalue, priv->wep_keys, in at76_set_wep()
2123 sizeof(priv->wep_keys)); in at76_set_wep()
2125 ret = at76_set_mib(priv, &priv->mib_buf); in at76_set_wep()
2128 wiphy_err(priv->hw->wiphy, in at76_set_wep()
2138 struct at76_priv *priv = hw->priv; in at76_set_key() local
2152 mutex_lock(&priv->mtx); in at76_set_key()
2156 memcpy(priv->wep_keys[key->keyidx], key->key, key->keylen); in at76_set_key()
2157 priv->wep_keys_len[key->keyidx] = key->keylen; in at76_set_key()
2160 priv->wep_key_id = key->keyidx; in at76_set_key()
2165 priv->wep_keys_len[key->keyidx] = 0; in at76_set_key()
2169 priv->wep_enabled = 0; in at76_set_key()
2172 if (priv->wep_keys_len[i] != 0) in at76_set_key()
2173 priv->wep_enabled = 1; in at76_set_key()
2176 at76_set_wep(priv); in at76_set_key()
2178 mutex_unlock(&priv->mtx); in at76_set_key()
2200 struct at76_priv *priv; in at76_alloc_new_device() local
2209 priv = hw->priv; in at76_alloc_new_device()
2210 priv->hw = hw; in at76_alloc_new_device()
2212 priv->udev = udev; in at76_alloc_new_device()
2214 mutex_init(&priv->mtx); in at76_alloc_new_device()
2215 INIT_WORK(&priv->work_set_promisc, at76_work_set_promisc); in at76_alloc_new_device()
2216 INIT_WORK(&priv->work_submit_rx, at76_work_submit_rx); in at76_alloc_new_device()
2217 INIT_WORK(&priv->work_join_bssid, at76_work_join_bssid); in at76_alloc_new_device()
2218 INIT_DELAYED_WORK(&priv->dwork_hw_scan, at76_dwork_hw_scan); in at76_alloc_new_device()
2220 tasklet_init(&priv->rx_tasklet, at76_rx_tasklet, 0); in at76_alloc_new_device()
2222 priv->pm_mode = AT76_PM_OFF; in at76_alloc_new_device()
2223 priv->pm_period = 0; in at76_alloc_new_device()
2227 return priv; in at76_alloc_new_device()
2230 static int at76_alloc_urbs(struct at76_priv *priv, in at76_alloc_urbs() argument
2265 priv->rx_pipe = usb_rcvbulkpipe(priv->udev, ep_in->bEndpointAddress); in at76_alloc_urbs()
2266 priv->tx_pipe = usb_sndbulkpipe(priv->udev, ep_out->bEndpointAddress); in at76_alloc_urbs()
2268 priv->rx_urb = usb_alloc_urb(0, GFP_KERNEL); in at76_alloc_urbs()
2269 priv->tx_urb = usb_alloc_urb(0, GFP_KERNEL); in at76_alloc_urbs()
2270 if (!priv->rx_urb || !priv->tx_urb) { in at76_alloc_urbs()
2276 priv->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL); in at76_alloc_urbs()
2277 if (!priv->bulk_out_buffer) in at76_alloc_urbs()
2317 static int at76_init_new_device(struct at76_priv *priv, in at76_init_new_device() argument
2330 ret = at76_alloc_urbs(priv, interface); in at76_init_new_device()
2335 ret = at76_get_hw_config(priv); in at76_init_new_device()
2341 priv->domain = at76_get_reg_domain(priv->regulatory_domain); in at76_init_new_device()
2343 priv->channel = DEF_CHANNEL; in at76_init_new_device()
2344 priv->iw_mode = IW_MODE_INFRA; in at76_init_new_device()
2345 priv->rts_threshold = DEF_RTS_THRESHOLD; in at76_init_new_device()
2346 priv->frag_threshold = DEF_FRAG_THRESHOLD; in at76_init_new_device()
2347 priv->short_retry_limit = DEF_SHORT_RETRY_LIMIT; in at76_init_new_device()
2348 priv->txrate = TX_RATE_AUTO; in at76_init_new_device()
2349 priv->preamble_type = PREAMBLE_TYPE_LONG; in at76_init_new_device()
2350 priv->beacon_period = 100; in at76_init_new_device()
2351 priv->auth_mode = WLAN_AUTH_OPEN; in at76_init_new_device()
2352 priv->scan_min_time = DEF_SCAN_MIN_TIME; in at76_init_new_device()
2353 priv->scan_max_time = DEF_SCAN_MAX_TIME; in at76_init_new_device()
2354 priv->scan_mode = SCAN_TYPE_ACTIVE; in at76_init_new_device()
2355 priv->device_unplugged = 0; in at76_init_new_device()
2358 wiphy = priv->hw->wiphy; in at76_init_new_device()
2359 priv->hw->wiphy->max_scan_ssids = 1; in at76_init_new_device()
2360 priv->hw->wiphy->max_scan_ie_len = 0; in at76_init_new_device()
2361 priv->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); in at76_init_new_device()
2362 priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &at76_supported_band; in at76_init_new_device()
2363 ieee80211_hw_set(priv->hw, RX_INCLUDES_FCS); in at76_init_new_device()
2364 ieee80211_hw_set(priv->hw, SIGNAL_UNSPEC); in at76_init_new_device()
2365 priv->hw->max_signal = 100; in at76_init_new_device()
2367 SET_IEEE80211_DEV(priv->hw, &interface->dev); in at76_init_new_device()
2368 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); in at76_init_new_device()
2372 priv->fw_version.major, priv->fw_version.minor, in at76_init_new_device()
2373 priv->fw_version.patch, priv->fw_version.build); in at76_init_new_device()
2375 wiphy->hw_version = priv->board_type; in at76_init_new_device()
2377 ret = ieee80211_register_hw(priv->hw); in at76_init_new_device()
2384 priv->mac80211_registered = 1; in at76_init_new_device()
2386 wiphy_info(priv->hw->wiphy, "USB %s, MAC %pM, firmware %d.%d.%d-%d\n", in at76_init_new_device()
2387 dev_name(&interface->dev), priv->mac_addr, in at76_init_new_device()
2388 priv->fw_version.major, priv->fw_version.minor, in at76_init_new_device()
2389 priv->fw_version.patch, priv->fw_version.build); in at76_init_new_device()
2390 wiphy_info(priv->hw->wiphy, "regulatory domain 0x%02x: %s\n", in at76_init_new_device()
2391 priv->regulatory_domain, priv->domain->name); in at76_init_new_device()
2397 static void at76_delete_device(struct at76_priv *priv) in at76_delete_device() argument
2402 priv->device_unplugged = 1; in at76_delete_device()
2404 tasklet_kill(&priv->rx_tasklet); in at76_delete_device()
2406 if (priv->mac80211_registered) in at76_delete_device()
2407 ieee80211_unregister_hw(priv->hw); in at76_delete_device()
2409 if (priv->tx_urb) { in at76_delete_device()
2410 usb_kill_urb(priv->tx_urb); in at76_delete_device()
2411 usb_free_urb(priv->tx_urb); in at76_delete_device()
2413 if (priv->rx_urb) { in at76_delete_device()
2414 usb_kill_urb(priv->rx_urb); in at76_delete_device()
2415 usb_free_urb(priv->rx_urb); in at76_delete_device()
2420 kfree(priv->bulk_out_buffer); in at76_delete_device()
2424 kfree_skb(priv->rx_skb); in at76_delete_device()
2428 ieee80211_free_hw(priv->hw); in at76_delete_device()
2437 struct at76_priv *priv; in at76_probe() local
2524 priv = at76_alloc_new_device(udev); in at76_probe()
2525 if (!priv) { in at76_probe()
2530 usb_set_intfdata(interface, priv); in at76_probe()
2532 memcpy(&priv->fw_version, fwv, sizeof(struct mib_fw_version)); in at76_probe()
2533 priv->board_type = board_type; in at76_probe()
2535 ret = at76_init_new_device(priv, interface); in at76_probe()
2537 at76_delete_device(priv); in at76_probe()
2548 struct at76_priv *priv; in at76_disconnect() local
2550 priv = usb_get_intfdata(interface); in at76_disconnect()
2554 if (!priv) in at76_disconnect()
2557 wiphy_info(priv->hw->wiphy, "disconnecting\n"); in at76_disconnect()
2558 at76_delete_device(priv); in at76_disconnect()
2559 usb_put_dev(priv->udev); in at76_disconnect()