18 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22 #include <linux/export.h>
30 #define RATETAB_ENT(_rate, _rateid, _flags) { \
33 .hw_value = (_rateid), \
36 #define CHAN2G(_channel, _freq, _flags) { \
37 .band = IEEE80211_BAND_2GHZ, \
38 .hw_value = (_channel), \
39 .center_freq = (_freq), \
41 .max_antenna_gain = 0, \
45 #define CHAN5G(_channel, _flags) { \
46 .band = IEEE80211_BAND_5GHZ, \
47 .hw_value = (_channel), \
48 .center_freq = 5000 + (5 * (_channel)), \
50 .max_antenna_gain = 0, \
54 #define DEFAULT_BG_SCAN_PERIOD 60
76 #define ath6kl_a_rates (ath6kl_rates + 4)
77 #define ath6kl_a_rates_size 8
78 #define ath6kl_g_rates (ath6kl_rates + 0)
79 #define ath6kl_g_rates_size 12
81 #define ath6kl_g_htcap IEEE80211_HT_CAP_SGI_20
82 #define ath6kl_a_htcap (IEEE80211_HT_CAP_SUP_WIDTH_20_40 | \
83 IEEE80211_HT_CAP_SGI_20 | \
84 IEEE80211_HT_CAP_SGI_40)
126 .n_channels =
ARRAY_SIZE(ath6kl_2ghz_channels),
127 .channels = ath6kl_2ghz_channels,
131 .ht_cap.ht_supported =
true,
135 .n_channels =
ARRAY_SIZE(ath6kl_5ghz_a_channels),
136 .channels = ath6kl_5ghz_a_channels,
140 .ht_cap.ht_supported =
true,
143 #define CCKM_KRK_CIPHER_SUITE 0x004096ff
146 static bool __ath6kl_cfg80211_sscan_stop(
struct ath6kl_vif *vif)
163 static void ath6kl_cfg80211_sscan_disable(
struct ath6kl_vif *vif)
168 stopped = __ath6kl_cfg80211_sscan_stop(vif);
176 static int ath6kl_set_wpa_version(
struct ath6kl_vif *vif,
188 ath6kl_err(
"%s: %u not supported\n", __func__, wpa_version);
195 static int ath6kl_set_auth_type(
struct ath6kl_vif *vif,
216 ath6kl_err(
"%s: 0x%x not supported\n", __func__, auth_type);
230 __func__, cipher, ucast);
259 ath6kl_err(
"cipher 0x%x not supported\n", cipher);
266 static void ath6kl_set_key_mgmt(
struct ath6kl_vif *vif,
u32 key_mgmt)
275 }
else if (key_mgmt == 0x00409600) {
285 static bool ath6kl_cfg80211_ready(
struct ath6kl_vif *vif)
302 static bool ath6kl_is_wpa_ie(
const u8 *
pos)
305 pos[2] == 0x00 && pos[3] == 0x50 &&
306 pos[4] == 0xf2 && pos[5] == 0x01;
309 static bool ath6kl_is_rsn_ie(
const u8 *
pos)
314 static bool ath6kl_is_wps_ie(
const u8 *
pos)
318 pos[2] == 0x00 && pos[3] == 0x50 && pos[4] == 0xf2 &&
322 static int ath6kl_set_assoc_req_ies(
struct ath6kl_vif *vif,
const u8 *ies,
341 if (ies && ies_len) {
347 while (pos + 1 < ies + ies_len) {
348 if (pos + 2 + pos[1] > ies + ies_len)
350 if (!(ath6kl_is_wpa_ie(pos) || ath6kl_is_rsn_ie(pos))) {
351 memcpy(buf + len, pos, 2 + pos[1]);
355 if (ath6kl_is_wps_ie(pos))
387 ath6kl_err(
"invalid interface type %u\n", type);
395 u8 *if_idx,
u8 *nw_type)
399 if (ath6kl_nliftype_to_drv_iftype(type, nw_type))
408 for (i = 0; i < ar->
vif_max; i++) {
429 static bool ath6kl_is_tx_pending(
struct ath6kl *ar)
438 struct ath6kl *ar = ath6kl_priv(dev);
444 ath6kl_cfg80211_sscan_disable(vif);
448 if (!ath6kl_cfg80211_ready(vif))
458 (sme->
bssid && is_zero_ether_addr(sme->
bssid)))) {
459 ath6kl_err(
"SkipScan: channel or bssid invalid\n");
479 ath6kl_is_tx_pending(ar),
488 status = ath6kl_set_assoc_req_ies(vif, sme->
ie, sme->
ie_len);
524 if (sme->
bssid && !is_broadcast_ether_addr(sme->
bssid))
527 ath6kl_set_wpa_version(vif, sme->
crypto.wpa_versions);
529 status = ath6kl_set_auth_type(vif, sme->
auth_type);
535 if (sme->
crypto.n_ciphers_pairwise)
536 ath6kl_set_cipher(vif, sme->
crypto.ciphers_pairwise[0],
true);
538 ath6kl_set_cipher(vif, 0,
true);
540 ath6kl_set_cipher(vif, sme->
crypto.cipher_group,
false);
542 if (sme->
crypto.n_akm_suites)
543 ath6kl_set_key_mgmt(vif, sme->
crypto.akm_suites[0]);
591 "%s: connect called with authmode %d dot11 auth %d"
592 " PW crypto %d PW crypto len %d GRP crypto %d"
593 " GRP crypto len %d channel hint %u\n",
642 ath6kl_err(
"ath6kl_wmi_connect_cmd failed\n");
660 ath6kl_add_bss_if_needed(
struct ath6kl_vif *vif,
665 size_t beacon_ie_len)
669 u16 cap_mask, cap_val;
700 bssid, 0, cap_val, 100,
701 ie, 2 + vif->
ssid_len + beacon_ie_len,
705 "added bss %pM to cfg80211\n", bssid);
714 u8 *bssid,
u16 listen_intvl,
717 u8 beacon_ie_len,
u8 assoc_req_len,
718 u8 assoc_resp_len,
u8 *assoc_info)
725 u8 assoc_req_ie_offset =
sizeof(
u16) +
sizeof(
u16);
728 u8 assoc_resp_ie_offset =
sizeof(
u16) +
sizeof(
u16) +
sizeof(
u16);
730 u8 *assoc_req_ie = assoc_info + beacon_ie_len + assoc_req_ie_offset;
731 u8 *assoc_resp_ie = assoc_info + beacon_ie_len + assoc_req_len +
732 assoc_resp_ie_offset;
734 assoc_req_len -= assoc_req_ie_offset;
735 assoc_resp_len -= assoc_resp_ie_offset;
744 if (nw_type & ADHOC_NETWORK) {
747 "%s: ath6k not in ibss mode\n", __func__);
756 "%s: ath6k not in station mode\n", __func__);
761 chan = ieee80211_get_channel(ar->
wiphy, (
int) channel);
763 bss = ath6kl_add_bss_if_needed(vif, nw_type, bssid, chan,
764 assoc_info, beacon_ie_len);
766 ath6kl_err(
"could not add cfg80211 bss entry\n");
770 if (nw_type & ADHOC_NETWORK) {
782 assoc_req_ie, assoc_req_len,
783 assoc_resp_ie, assoc_resp_len,
793 static int ath6kl_cfg80211_disconnect(
struct wiphy *wiphy,
796 struct ath6kl *ar = ath6kl_priv(dev);
802 ath6kl_cfg80211_sscan_disable(vif);
804 if (!ath6kl_cfg80211_ready(vif))
833 u8 *bssid,
u8 assoc_resp_len,
834 u8 *assoc_info,
u16 proto_reason)
843 if (vif->
nw_type & ADHOC_NETWORK) {
846 "%s: ath6k not in ibss mode\n", __func__);
858 "%s: ath6k not in station mode\n", __func__);
890 static int ath6kl_set_probed_ssids(
struct ath6kl *ar,
896 u8 i,
j, index_to_add, ssid_found =
false;
899 memset(ssid_list, 0,
sizeof(ssid_list));
905 for (i = 0; i < n_ssids; i++) {
909 ssid_list[
i].ssid.ssid_len = ssids[
i].
ssid_len;
911 if (ssids[i].ssid_len)
916 if (n_match_ssid == 0)
922 for (i = 0; i < n_match_ssid; i++) {
925 for (j = 0; j < n_ssids; j++) {
926 if ((match_set[i].
ssid.ssid_len ==
927 ssid_list[j].ssid.ssid_len) &&
929 match_set[i].
ssid.ssid,
930 match_set[i].
ssid.ssid_len))) {
943 ssid_list[index_to_add].ssid.ssid_len =
944 match_set[
i].
ssid.ssid_len;
946 match_set[i].
ssid.ssid,
947 match_set[i].
ssid.ssid_len);
952 for (i = 0; i < index_to_add; i++) {
955 ssid_list[i].ssid.ssid_len,
956 ssid_list[i].ssid.ssid);
969 static int ath6kl_cfg80211_scan(
struct wiphy *wiphy,
977 u32 force_fg_scan = 0;
979 if (!ath6kl_cfg80211_ready(vif))
982 ath6kl_cfg80211_sscan_disable(vif);
994 ret = ath6kl_set_probed_ssids(ar, vif, request->
ssids,
1004 ath6kl_err(
"failed to set Probe Request appie for scan\n");
1020 if (channels ==
NULL) {
1021 ath6kl_warn(
"failed to set scan channels, scan all channels");
1025 for (i = 0; i < n_channels; i++)
1026 channels[i] = request->
channels[i]->center_freq;
1046 n_channels, channels,
1054 n_channels, channels);
1072 aborted ?
" aborted" :
"");
1081 for (i = 0; i < vif->
scan_req->n_ssids; i++) {
1099 "channel switch notify nw_type %d freq %d mode %d\n",
1107 static int ath6kl_cfg80211_add_key(
struct wiphy *wiphy,
struct net_device *
ndev,
1112 struct ath6kl *ar = ath6kl_priv(ndev);
1119 if (!ath6kl_cfg80211_ready(vif))
1131 "%s: key index %d out of bounds\n", __func__,
1151 seq_len >
sizeof(key->
seq))
1187 "%s: index %d, key_len %d, key_type 0x%x, key_usage 0x%x, seq_len %d\n",
1188 __func__, key_index, key->
key_len, key_type,
1201 "Delay initial group key configuration until AP mode has been started\n");
1218 "Delay WEP key configuration until AP mode has been started\n");
1226 key_type, key_usage, key->
key_len,
1232 static int ath6kl_cfg80211_del_key(
struct wiphy *wiphy,
struct net_device *ndev,
1233 u8 key_index,
bool pairwise,
1236 struct ath6kl *ar = ath6kl_priv(ndev);
1241 if (!ath6kl_cfg80211_ready(vif))
1246 "%s: key index %d out of bounds\n", __func__,
1251 if (!vif->
keys[key_index].key_len) {
1253 "%s: index %d is empty\n", __func__, key_index);
1262 static int ath6kl_cfg80211_get_key(
struct wiphy *wiphy,
struct net_device *ndev,
1263 u8 key_index,
bool pairwise,
1274 if (!ath6kl_cfg80211_ready(vif))
1279 "%s: key index %d out of bounds\n", __func__,
1285 memset(¶ms, 0,
sizeof(params));
1297 static int ath6kl_cfg80211_set_default_key(
struct wiphy *wiphy,
1299 u8 key_index,
bool unicast,
1302 struct ath6kl *ar = ath6kl_priv(ndev);
1310 if (!ath6kl_cfg80211_ready(vif))
1315 "%s: key index %d out of bounds\n",
1316 __func__, key_index);
1320 if (!vif->
keys[key_index].key_len) {
1322 __func__, key_index);
1341 key_type, key_usage,
1352 "%s: keyid %d, ismcast %d\n", __func__, keyid, ismcast);
1360 static int ath6kl_cfg80211_set_wiphy_params(
struct wiphy *wiphy,
u32 changed)
1362 struct ath6kl *ar = (
struct ath6kl *)wiphy_priv(wiphy);
1373 if (!ath6kl_cfg80211_ready(vif))
1379 ath6kl_err(
"ath6kl_wmi_set_rts_cmd failed\n");
1391 static int ath6kl_cfg80211_set_txpower(
struct wiphy *wiphy,
1395 struct ath6kl *ar = (
struct ath6kl *)wiphy_priv(wiphy);
1406 if (!ath6kl_cfg80211_ready(vif))
1426 static int ath6kl_cfg80211_get_txpower(
struct wiphy *wiphy,
int *dbm)
1428 struct ath6kl *ar = (
struct ath6kl *)wiphy_priv(wiphy);
1435 if (!ath6kl_cfg80211_ready(vif))
1442 ath6kl_err(
"ath6kl_wmi_get_tx_pwr_cmd failed\n");
1449 if (signal_pending(
current)) {
1459 static int ath6kl_cfg80211_set_power_mgmt(
struct wiphy *wiphy,
1461 bool pmgmt,
int timeout)
1463 struct ath6kl *ar = ath6kl_priv(dev);
1468 __func__, pmgmt, timeout);
1470 if (!ath6kl_cfg80211_ready(vif))
1482 mode.pwr_mode) != 0) {
1490 static struct wireless_dev *ath6kl_cfg80211_add_iface(
struct wiphy *wiphy,
1496 struct ath6kl *ar = wiphy_priv(wiphy);
1501 ath6kl_err(
"Reached maximum number of supported vif\n");
1505 if (!ath6kl_is_valid_iftype(ar, type, &if_idx, &nw_type)) {
1506 ath6kl_err(
"Not a supported interface type\n");
1519 static int ath6kl_cfg80211_del_iface(
struct wiphy *wiphy,
1522 struct ath6kl *ar = wiphy_priv(wiphy);
1536 static int ath6kl_cfg80211_change_iface(
struct wiphy *wiphy,
1552 vif->
ar->fw_capabilities) &&
1555 if (vif->
ar->vif_max == 1) {
1559 goto set_iface_type;
1562 for (i = vif->
ar->max_norm_iface; i < vif->ar->
vif_max; i++) {
1567 if (i == vif->
ar->vif_max) {
1568 ath6kl_err(
"Invalid interface to bring up P2P\n");
1594 ath6kl_err(
"invalid interface type %u\n", type);
1603 static int ath6kl_cfg80211_join_ibss(
struct wiphy *wiphy,
1607 struct ath6kl *ar = ath6kl_priv(dev);
1611 if (!ath6kl_cfg80211_ready(vif))
1631 if (ibss_param->
bssid && !is_broadcast_ether_addr(ibss_param->
bssid))
1635 ath6kl_set_wpa_version(vif, 0);
1645 ath6kl_set_cipher(vif, 0,
true);
1646 ath6kl_set_cipher(vif, 0,
false);
1652 "%s: connect called with authmode %d dot11 auth %d"
1653 " PW crypto %d PW crypto len %d GRP crypto %d"
1654 " GRP crypto len %d channel hint %u\n",
1673 static int ath6kl_cfg80211_leave_ibss(
struct wiphy *wiphy,
1678 if (!ath6kl_cfg80211_ready(vif))
1688 static const u32 cipher_suites[] = {
1697 static bool is_rate_legacy(
s32 rate)
1699 static const s32 legacy[] = { 1000, 2000, 5500, 11000,
1700 6000, 9000, 12000, 18000, 24000,
1706 if (rate == legacy[i])
1712 static bool is_rate_ht20(
s32 rate,
u8 *
mcs,
bool *sgi)
1714 static const s32 ht20[] = { 6500, 13000, 19500, 26000, 39000,
1715 52000, 58500, 65000, 72200
1720 if (rate == ht20[i]) {
1734 static bool is_rate_ht40(
s32 rate,
u8 *mcs,
bool *sgi)
1736 static const s32 ht40[] = { 13500, 27000, 40500, 54000,
1737 81000, 108000, 121500, 135000,
1743 if (rate == ht40[i]) {
1758 static int ath6kl_get_station(
struct wiphy *wiphy,
struct net_device *dev,
1761 struct ath6kl *ar = ath6kl_priv(dev);
1815 if (is_rate_legacy(rate)) {
1816 sinfo->
txrate.legacy = rate / 100;
1817 }
else if (is_rate_ht20(rate, &mcs, &sgi)) {
1820 sinfo->
txrate.mcs = mcs - 1;
1826 }
else if (is_rate_ht40(rate, &mcs, &sgi)) {
1829 sinfo->
txrate.mcs = mcs - 1;
1838 "invalid rate from stats: %d\n", rate);
1857 static int ath6kl_set_pmksa(
struct wiphy *wiphy,
struct net_device *netdev,
1860 struct ath6kl *ar = ath6kl_priv(netdev);
1861 struct ath6kl_vif *vif = netdev_priv(netdev);
1864 pmksa->
pmkid,
true);
1867 static int ath6kl_del_pmksa(
struct wiphy *wiphy,
struct net_device *netdev,
1870 struct ath6kl *ar = ath6kl_priv(netdev);
1871 struct ath6kl_vif *vif = netdev_priv(netdev);
1874 pmksa->
pmkid,
false);
1877 static int ath6kl_flush_pmksa(
struct wiphy *wiphy,
struct net_device *netdev)
1879 struct ath6kl *ar = ath6kl_priv(netdev);
1880 struct ath6kl_vif *vif = netdev_priv(netdev);
1906 memset(&mask, 0,
sizeof(mask));
1907 for (pos = 0; pos < wow->
patterns[
i].pattern_len; pos++) {
1908 if (wow->
patterns[i].mask[pos / 8] & (0x1 << (pos % 8)))
1946 static const u8 unicst_pattern[] = { 0x00, 0x00, 0x00,
1947 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1948 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1950 static const u8 unicst_mask[] = { 0x01, 0x00, 0x00,
1951 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1952 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1954 u8 unicst_offset = 0;
1955 static const u8 arp_pattern[] = { 0x08, 0x06 };
1956 static const u8 arp_mask[] = { 0xff, 0xff };
1958 static const u8 discvr_pattern[] = { 0xe0, 0x00, 0x00, 0xf8 };
1959 static const u8 discvr_mask[] = { 0xf0, 0x00, 0x00, 0xf8 };
1960 u8 discvr_offset = 38;
1961 static const u8 dhcp_pattern[] = { 0xff, 0xff, 0xff, 0xff,
1962 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1963 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
1964 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1965 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1966 0x00, 0x00, 0x00, 0x00, 0x00, 0x43 };
1967 static const u8 dhcp_mask[] = { 0xff, 0xff, 0xff, 0xff,
1968 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1969 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
1970 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1971 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1972 0x00, 0x00, 0x00, 0x00, 0xff, 0xff };
1979 sizeof(unicst_pattern), unicst_offset,
1980 unicst_pattern, unicst_mask);
1982 ath6kl_err(
"failed to add WOW unicast IP pattern\n");
1989 sizeof(arp_pattern), arp_offset,
1990 arp_pattern, arp_mask);
1992 ath6kl_err(
"failed to add WOW ARP pattern\n");
2002 sizeof(discvr_pattern), discvr_offset,
2003 discvr_pattern, discvr_mask);
2005 ath6kl_err(
"failed to add WOW mDNS/SSDP/LLMNR pattern\n");
2012 sizeof(dhcp_pattern), dhcp_offset,
2013 dhcp_pattern, dhcp_mask);
2015 ath6kl_err(
"failed to add WOW DHCP broadcast pattern\n");
2025 static const u8 discvr_pattern[] = { 0xe0, 0x00, 0x00, 0xf8 };
2026 static const u8 discvr_mask[] = { 0xf0, 0x00, 0x00, 0xf8 };
2027 u8 discvr_offset = 38;
2038 ath6kl_err(
"failed to add WOW unicast pattern\n");
2050 sizeof(discvr_pattern), discvr_offset,
2051 discvr_pattern, discvr_mask);
2053 ath6kl_err(
"failed to add WOW mDNS/SSDP/LLMNR pattern\n");
2061 static int is_hsleep_mode_procsed(
struct ath6kl_vif *vif)
2066 static bool is_ctrl_ep_empty(
struct ath6kl *ar)
2071 static int ath6kl_cfg80211_host_sleep(
struct ath6kl *ar,
struct ath6kl_vif *vif)
2083 is_hsleep_mode_procsed(vif),
2086 ath6kl_warn(
"timeout, didn't get host sleep cmd processed event\n");
2088 }
else if (left < 0) {
2089 ath6kl_warn(
"error while waiting for host sleep cmd processed event %d\n",
2096 is_ctrl_ep_empty(ar),
2101 }
else if (left < 0) {
2102 ath6kl_warn(
"clear wmi ctrl data failed: %d\n", left);
2112 struct in_device *in_dev;
2113 struct in_ifaddr *ifa;
2129 if (!ath6kl_cfg80211_ready(vif))
2158 ret = ath6kl_wow_usr(ar, vif, wow, &filter);
2160 ret = ath6kl_wow_ap(ar, vif);
2162 ret = ath6kl_wow_sta(ar, vif);
2167 netif_stop_queue(vif->
ndev);
2187 0xFFFF, 0, 0xFFFF, 0, 0, 0,
2196 in_dev = __in_dev_get_rtnl(vif->
ndev);
2200 ifa = in_dev->ifa_list;
2201 memset(&ips, 0,
sizeof(ips));
2205 ips[
index] = ifa->ifa_local;
2206 ifa = ifa->ifa_next;
2211 ath6kl_err(
"total IP addr count is exceeding fw limit\n");
2217 ath6kl_err(
"fail to setup ip for arp agent\n");
2229 ret = ath6kl_cfg80211_host_sleep(ar, vif);
2236 static int ath6kl_wow_resume(
struct ath6kl *ar)
2250 ath6kl_warn(
"Failed to configure host sleep mode for wow resume: %d\n",
2258 0, 0, 0, 0, 0, 0, 3, 0, 0, 0);
2284 netif_wake_queue(vif->
ndev);
2289 static int ath6kl_cfg80211_deepsleep_suspend(
struct ath6kl *ar)
2299 ath6kl_err(
"deepsleep failed as wmi is not ready\n");
2306 ar->
wmi->saved_pwr_mode = ar->
wmi->pwr_mode;
2322 ret = ath6kl_cfg80211_host_sleep(ar, vif);
2329 static int ath6kl_cfg80211_deepsleep_resume(
struct ath6kl *ar)
2339 if (ar->
wmi->pwr_mode != ar->
wmi->saved_pwr_mode) {
2341 ar->
wmi->saved_pwr_mode);
2355 0, 0, 0, 0, 0, 0, 3, 0, 0, 0);
2378 prev_state = ar->
state;
2380 ret = ath6kl_wow_suspend(ar, wow);
2393 ret = ath6kl_cfg80211_deepsleep_suspend(ar);
2395 ath6kl_err(
"deepsleep suspend failed: %d\n", ret);
2409 "suspend hw off, no action for cutpower\n");
2417 ath6kl_warn(
"failed to stop hw during suspend: %d\n",
2447 switch (ar->
state) {
2451 ret = ath6kl_wow_resume(ar);
2462 ret = ath6kl_cfg80211_deepsleep_resume(ar);
2464 ath6kl_warn(
"deep sleep resume failed: %d\n", ret);
2474 ath6kl_warn(
"Failed to boot hw in resume: %d\n", ret);
2493 static int __ath6kl_cfg80211_suspend(
struct wiphy *wiphy,
2496 struct ath6kl *ar = wiphy_priv(wiphy);
2498 return ath6kl_hif_suspend(ar, wow);
2501 static int __ath6kl_cfg80211_resume(
struct wiphy *wiphy)
2503 struct ath6kl *ar = wiphy_priv(wiphy);
2505 return ath6kl_hif_resume(ar);
2555 memset(htcap, 0,
sizeof(*htcap));
2561 static int ath6kl_restore_htcap(
struct ath6kl_vif *vif)
2563 struct wiphy *wiphy = vif->
ar->wiphy;
2567 if (!wiphy->
bands[band])
2570 ret = ath6kl_set_htcap(vif, band,
2571 wiphy->
bands[band]->ht_cap.ht_supported);
2579 static bool ath6kl_is_p2p_ie(
const u8 *pos)
2582 pos[2] == 0x50 && pos[3] == 0x6f &&
2583 pos[4] == 0x9a && pos[5] == 0x09;
2586 static int ath6kl_set_ap_probe_resp_ies(
struct ath6kl_vif *vif,
2587 const u8 *ies,
size_t ies_len)
2600 if (ies && ies_len) {
2605 while (pos + 1 < ies + ies_len) {
2606 if (pos + 2 + pos[1] > ies + ies_len)
2608 if (!ath6kl_is_p2p_ie(pos)) {
2609 memcpy(buf + len, pos, 2 + pos[1]);
2622 static int ath6kl_set_ies(
struct ath6kl_vif *vif,
2637 res = ath6kl_set_ap_probe_resp_ies(vif, info->
proberesp_ies,
2664 vif->
ar->fw_capabilities))
2668 enable ?
"enable" :
"disable");
2673 ath6kl_err(
"failed to %s enhanced bmiss detection: %d\n",
2674 enable ?
"enable" :
"disable", err);
2691 rsn_ie_len = *(rsn_ie + 1);
2710 cnt = get_unaligned_le16(rsn_ie);
2711 rsn_ie += (2 + cnt * 4);
2712 rsn_ie_len -= (2 + cnt * 4);
2717 cnt = get_unaligned_le16(rsn_ie);
2718 rsn_ie += (2 + cnt * 4);
2719 rsn_ie_len -= (2 + cnt * 4);
2724 memcpy(rsn_capab, rsn_ie, 2);
2729 static int ath6kl_start_ap(
struct wiphy *wiphy,
struct net_device *dev,
2732 struct ath6kl *ar = ath6kl_priv(dev);
2735 bool hidden =
false;
2745 if (!ath6kl_cfg80211_ready(vif))
2751 res = ath6kl_set_ies(vif, &info->
beacon);
2764 ath6kl_warn(
"Failed to set dtim_period in beacon: %d\n", ret);
2769 ies = mgmt->
u.beacon.variable;
2772 ies_len = info->
beacon.head + info->
beacon.head_len - ies;
2785 ret = ath6kl_set_auth_type(vif, info->
auth_type);
2791 for (i = 0; i < info->
crypto.n_akm_suites; i++) {
2792 switch (info->
crypto.akm_suites[i]) {
2796 if (info->
crypto.wpa_versions & NL80211_WPA_VERSION_2)
2802 if (info->
crypto.wpa_versions & NL80211_WPA_VERSION_2)
2807 if (
p.auth_mode == 0)
2811 for (i = 0; i < info->
crypto.n_ciphers_pairwise; i++) {
2812 switch (info->
crypto.ciphers_pairwise[i]) {
2828 if (
p.prwise_crypto_type == 0) {
2830 ath6kl_set_cipher(vif, 0,
true);
2831 }
else if (info->
crypto.n_ciphers_pairwise == 1)
2832 ath6kl_set_cipher(vif, info->
crypto.ciphers_pairwise[0],
true);
2834 switch (info->
crypto.cipher_group) {
2852 ath6kl_set_cipher(vif, info->
crypto.cipher_group,
false);
2884 if (ath6kl_set_htcap(vif, info->
channel->band,
2894 if (!ath6kl_get_rsn_capab(&info->
beacon, (
u8 *) &rsn_capab) &&
2899 (
const u8 *) &rsn_capab,
2913 static int ath6kl_change_beacon(
struct wiphy *wiphy,
struct net_device *dev,
2918 if (!ath6kl_cfg80211_ready(vif))
2924 return ath6kl_set_ies(vif, beacon);
2927 static int ath6kl_stop_ap(
struct wiphy *wiphy,
struct net_device *dev)
2929 struct ath6kl *ar = ath6kl_priv(dev);
2941 return ath6kl_restore_htcap(vif);
2944 static const u8 bcast_addr[
ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2946 static int ath6kl_del_station(
struct wiphy *wiphy,
struct net_device *dev,
2949 struct ath6kl *ar = ath6kl_priv(dev);
2951 const u8 *
addr = mac ? mac : bcast_addr;
2957 static int ath6kl_change_station(
struct wiphy *wiphy,
struct net_device *dev,
2960 struct ath6kl *ar = ath6kl_priv(dev);
2977 static int ath6kl_remain_on_channel(
struct wiphy *wiphy,
2984 struct ath6kl_vif *vif = ath6kl_vif_from_wdev(wdev);
3001 static int ath6kl_cancel_remain_on_channel(
struct wiphy *wiphy,
3005 struct ath6kl_vif *vif = ath6kl_vif_from_wdev(wdev);
3015 static int ath6kl_send_go_probe_resp(
struct ath6kl_vif *vif,
3016 const u8 *buf,
size_t len,
3035 pos = mgmt->
u.probe_resp.variable;
3036 while (pos + 1 < buf + len) {
3037 if (pos + 2 + pos[1] > buf + len)
3039 if (ath6kl_is_p2p_ie(pos)) {
3040 memcpy(p2p + p2p_len, pos, 2 + pos[1]);
3041 p2p_len += 2 + pos[1];
3047 mgmt->
da, p2p, p2p_len);
3052 static bool ath6kl_mgmt_powersave_ap(
struct ath6kl_vif *vif,
3063 bool is_psq_empty =
false;
3065 size_t mgmt_buf_size;
3069 if (is_multicast_ether_addr(mgmt->
da))
3084 INIT_LIST_HEAD(&mgmt_buf->list);
3086 mgmt_buf->freq =
freq;
3087 mgmt_buf->wait =
wait;
3088 mgmt_buf->len =
len;
3089 mgmt_buf->no_cck =
no_cck;
3090 memcpy(mgmt_buf->buf, buf, len);
3092 is_psq_empty = skb_queue_empty(&conn->
psq) &&
3123 static bool ath6kl_is_p2p_go_ssid(
const u8 *buf,
size_t len)
3129 if (buf + len >= &mgmt->
u.probe_resp.variable[1] &&
3137 static int ath6kl_mgmt_tx(
struct wiphy *wiphy,
struct wireless_dev *wdev,
3140 bool channel_type_valid,
unsigned int wait,
3141 const u8 *buf,
size_t len,
bool no_cck,
3142 bool dont_wait_for_ack,
u64 *cookie)
3144 struct ath6kl_vif *vif = ath6kl_vif_from_wdev(wdev);
3148 bool more_data, queued;
3153 ath6kl_is_p2p_go_ssid(buf, len)) {
3159 return ath6kl_send_go_probe_resp(vif, buf, len,
3176 queued = ath6kl_mgmt_powersave_ap(vif,
3179 len, &more_data, no_cck);
3189 static void ath6kl_mgmt_frame_register(
struct wiphy *wiphy,
3193 struct ath6kl_vif *vif = ath6kl_vif_from_wdev(wdev);
3196 __func__, frame_type, reg);
3207 static int ath6kl_cfg80211_sscan_start(
struct wiphy *wiphy,
3211 struct ath6kl *ar = ath6kl_priv(dev);
3228 ret = ath6kl_set_probed_ssids(ar, vif, request->
ssids,
3259 ath6kl_warn(
"Failed to enable wow with ssid filter: %d\n", ret);
3268 ath6kl_warn(
"Failed to set probe request IE for scheduled scan: %d\n",
3276 ath6kl_warn(
"Failed to enable host sleep mode for sched scan: %d\n",
3286 static int ath6kl_cfg80211_sscan_stop(
struct wiphy *wiphy,
3292 stopped = __ath6kl_cfg80211_sscan_stop(vif);
3300 static int ath6kl_cfg80211_set_bitrate(
struct wiphy *wiphy,
3305 struct ath6kl *ar = ath6kl_priv(dev);
3341 .add_virtual_intf = ath6kl_cfg80211_add_iface,
3342 .del_virtual_intf = ath6kl_cfg80211_del_iface,
3343 .change_virtual_intf = ath6kl_cfg80211_change_iface,
3344 .scan = ath6kl_cfg80211_scan,
3345 .connect = ath6kl_cfg80211_connect,
3346 .disconnect = ath6kl_cfg80211_disconnect,
3347 .add_key = ath6kl_cfg80211_add_key,
3348 .get_key = ath6kl_cfg80211_get_key,
3349 .del_key = ath6kl_cfg80211_del_key,
3350 .set_default_key = ath6kl_cfg80211_set_default_key,
3351 .set_wiphy_params = ath6kl_cfg80211_set_wiphy_params,
3352 .set_tx_power = ath6kl_cfg80211_set_txpower,
3353 .get_tx_power = ath6kl_cfg80211_get_txpower,
3354 .set_power_mgmt = ath6kl_cfg80211_set_power_mgmt,
3355 .join_ibss = ath6kl_cfg80211_join_ibss,
3356 .leave_ibss = ath6kl_cfg80211_leave_ibss,
3357 .get_station = ath6kl_get_station,
3358 .set_pmksa = ath6kl_set_pmksa,
3359 .del_pmksa = ath6kl_del_pmksa,
3360 .flush_pmksa = ath6kl_flush_pmksa,
3363 .suspend = __ath6kl_cfg80211_suspend,
3364 .resume = __ath6kl_cfg80211_resume,
3366 .start_ap = ath6kl_start_ap,
3367 .change_beacon = ath6kl_change_beacon,
3368 .stop_ap = ath6kl_stop_ap,
3369 .del_station = ath6kl_del_station,
3370 .change_station = ath6kl_change_station,
3371 .remain_on_channel = ath6kl_remain_on_channel,
3372 .cancel_remain_on_channel = ath6kl_cancel_remain_on_channel,
3373 .mgmt_tx = ath6kl_mgmt_tx,
3374 .mgmt_frame_register = ath6kl_mgmt_frame_register,
3375 .sched_scan_start = ath6kl_cfg80211_sscan_start,
3376 .sched_scan_stop = ath6kl_cfg80211_sscan_stop,
3377 .set_bitrate_mask = ath6kl_cfg80211_set_bitrate,
3382 ath6kl_cfg80211_sscan_disable(vif);
3408 0, 0, 0, 0, 0, 0, 0, 0, 0) != 0)
3409 ath6kl_warn(
"failed to disable scan during stop\n");
3421 ar->
wmi->saved_pwr_mode = ar->
wmi->pwr_mode;
3424 ath6kl_warn(
"ath6kl_deep_sleep_enable: wmi_powermode_cmd failed\n");
3437 static int ath6kl_cfg80211_vif_init(
struct ath6kl_vif *vif)
3446 (
unsigned long) vif->
ndev);
3448 (
unsigned long) vif);
3467 if (vif->
nw_type == ADHOC_NETWORK)
3475 unregister_netdevice(vif->
ndev);
3482 u8 fw_vif_idx,
u8 nw_type)
3491 vif = netdev_priv(ndev);
3509 if (fw_vif_idx != 0)
3517 if (ath6kl_cfg80211_vif_init(vif))
3546 struct wiphy *wiphy = ar->
wiphy;
3547 bool band_2gig =
false, band_5gig =
false, ht =
false;
3555 set_wiphy_dev(wiphy, ar->
dev);
3574 switch (ar->
hw.cap) {
3604 ath6kl_band_2ghz.
ht_cap.cap = 0;
3605 ath6kl_band_2ghz.
ht_cap.ht_supported =
false;
3606 ath6kl_band_5ghz.
ht_cap.cap = 0;
3607 ath6kl_band_5ghz.
ht_cap.ht_supported =
false;
3611 ath6kl_band_2ghz.
ht_cap.mcs.rx_mask[0] = 0xff;
3612 ath6kl_band_5ghz.
ht_cap.mcs.rx_mask[0] = 0xff;
3613 ath6kl_band_2ghz.
ht_cap.mcs.rx_mask[1] = 0xff;
3614 ath6kl_band_5ghz.
ht_cap.mcs.rx_mask[1] = 0xff;
3616 ath6kl_band_2ghz.
ht_cap.mcs.rx_mask[0] = 0xff;
3617 ath6kl_band_5ghz.
ht_cap.mcs.rx_mask[0] = 0xff;
3638 wiphy->wowlan.pattern_min_len = 1;
3656 ar->
wiphy->probe_resp_offload =
3663 ath6kl_err(
"couldn't register wiphy device\n");
3682 struct wiphy *wiphy;
3688 ath6kl_err(
"couldn't allocate wiphy device\n");
3692 ar = wiphy_priv(wiphy);