Lines Matching +full:sense +full:- +full:bitfield +full:- +full:width

1 // SPDX-License-Identifier: GPL-2.0-only
3 * This is the new netlink-based wireless configuration interface.
5 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
6 * Copyright 2013-2014 Intel Mobile Communications GmbH
7 * Copyright 2015-2017 Intel Deutschland GmbH
8 * Copyright (C) 2018-2022 Intel Corporation
32 #include "rdev-ops.h"
50 NL80211_MCGRP_TESTMODE /* keep last - ifdef! */
74 int wiphy_idx = -1; in __cfg80211_wdev_from_attrs()
75 int ifidx = -1; in __cfg80211_wdev_from_attrs()
78 return ERR_PTR(-EINVAL); in __cfg80211_wdev_from_attrs()
90 lockdep_assert_held(&rdev->wiphy.mtx); in __cfg80211_wdev_from_attrs()
92 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in __cfg80211_wdev_from_attrs()
93 if (have_ifidx && wdev->netdev && in __cfg80211_wdev_from_attrs()
94 wdev->netdev->ifindex == ifidx) { in __cfg80211_wdev_from_attrs()
98 if (have_wdev_id && wdev->identifier == (u32)wdev_id) { in __cfg80211_wdev_from_attrs()
104 return result ?: ERR_PTR(-ENODEV); in __cfg80211_wdev_from_attrs()
112 if (wiphy_net(&rdev->wiphy) != netns) in __cfg80211_wdev_from_attrs()
115 if (have_wdev_id && rdev->wiphy_idx != wiphy_idx) in __cfg80211_wdev_from_attrs()
118 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in __cfg80211_wdev_from_attrs()
119 if (have_ifidx && wdev->netdev && in __cfg80211_wdev_from_attrs()
120 wdev->netdev->ifindex == ifidx) { in __cfg80211_wdev_from_attrs()
124 if (have_wdev_id && wdev->identifier == (u32)wdev_id) { in __cfg80211_wdev_from_attrs()
136 return ERR_PTR(-ENODEV); in __cfg80211_wdev_from_attrs()
150 return ERR_PTR(-EINVAL); in __cfg80211_rdev_from_attrs()
164 list_for_each_entry(wdev, &tmp->wiphy.wdev_list, list) { in __cfg80211_rdev_from_attrs()
165 if (wdev->identifier != (u32)wdev_id) in __cfg80211_rdev_from_attrs()
175 return ERR_PTR(-EINVAL); in __cfg80211_rdev_from_attrs()
185 if (netdev->ieee80211_ptr) in __cfg80211_rdev_from_attrs()
187 netdev->ieee80211_ptr->wiphy); in __cfg80211_rdev_from_attrs()
191 /* not wireless device -- return error */ in __cfg80211_rdev_from_attrs()
193 return ERR_PTR(-EINVAL); in __cfg80211_rdev_from_attrs()
195 /* mismatch -- return error */ in __cfg80211_rdev_from_attrs()
197 return ERR_PTR(-EINVAL); in __cfg80211_rdev_from_attrs()
204 return ERR_PTR(-ENODEV); in __cfg80211_rdev_from_attrs()
206 if (netns != wiphy_net(&rdev->wiphy)) in __cfg80211_rdev_from_attrs()
207 return ERR_PTR(-ENODEV); in __cfg80211_rdev_from_attrs()
222 return __cfg80211_rdev_from_attrs(netns, info->attrs); in cfg80211_get_dev_from_info()
238 s1g_bcn = ieee80211_is_s1g_beacon(mgmt->frame_control); in validate_beacon_head()
252 if (ieee80211_hdrlen(mgmt->frame_control) != hdrlen) in validate_beacon_head()
256 len -= fixedlen; in validate_beacon_head()
267 return -EINVAL; in validate_beacon_head()
285 return -EINVAL; in validate_ie_attr()
292 return -EINVAL; in validate_he_capa()
469 .len = 20-1 },
495 [NL80211_ATTR_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ-1 },
525 NLA_POLICY_MAX(NLA_U8, NUM_NL80211_PLINK_ACTIONS - 1),
537 /* allow 3 for NUL-termination, we used to declare this NLA_STRING */
604 NLA_POLICY_MAX(NLA_U8, NUM_NL80211_PLINK_STATES - 1),
700 [NL80211_ATTR_TSID] = NLA_POLICY_MAX(NLA_U8, IEEE80211_NUM_TIDS - 1),
702 NLA_POLICY_MAX(NLA_U8, IEEE80211_NUM_UPS - 1),
714 NLA_POLICY_MAX(NLA_U8, NUM_NL80211_P2P_PS_STATUS - 1),
761 [NL80211_ATTR_VLAN_ID] = NLA_POLICY_RANGE(NLA_U16, 1, VLAN_N_VID - 2),
818 [NL80211_KEY_TYPE] = NLA_POLICY_MAX(NLA_U32, NUM_NL80211_KEYTYPES - 1),
975 if (!cb->args[0]) { in nl80211_prepare_wdev_dump()
982 return -ENOMEM; in nl80211_prepare_wdev_dump()
986 err = nlmsg_parse_deprecated(cb->nlh, in nl80211_prepare_wdev_dump()
996 *wdev = __cfg80211_wdev_from_attrs(NULL, sock_net(cb->skb->sk), in nl80211_prepare_wdev_dump()
1003 *rdev = wiphy_to_rdev((*wdev)->wiphy); in nl80211_prepare_wdev_dump()
1004 mutex_lock(&(*rdev)->wiphy.mtx); in nl80211_prepare_wdev_dump()
1006 /* 0 is the first index - add 1 to parse only once */ in nl80211_prepare_wdev_dump()
1007 cb->args[0] = (*rdev)->wiphy_idx + 1; in nl80211_prepare_wdev_dump()
1008 cb->args[1] = (*wdev)->identifier; in nl80211_prepare_wdev_dump()
1015 wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1); in nl80211_prepare_wdev_dump()
1018 return -ENODEV; in nl80211_prepare_wdev_dump()
1023 list_for_each_entry(tmp, &(*rdev)->wiphy.wdev_list, list) { in nl80211_prepare_wdev_dump()
1024 if (tmp->identifier == cb->args[1]) { in nl80211_prepare_wdev_dump()
1032 return -ENODEV; in nl80211_prepare_wdev_dump()
1034 mutex_lock(&(*rdev)->wiphy.mtx); in nl80211_prepare_wdev_dump()
1066 rule->wmm_rule.client[j].cw_min) || in nl80211_msg_put_wmm_rules()
1068 rule->wmm_rule.client[j].cw_max) || in nl80211_msg_put_wmm_rules()
1070 rule->wmm_rule.client[j].aifsn) || in nl80211_msg_put_wmm_rules()
1072 rule->wmm_rule.client[j].cot)) in nl80211_msg_put_wmm_rules()
1082 return -ENOBUFS; in nl80211_msg_put_wmm_rules()
1090 * list to protect old user-space tools from breaking in nl80211_msg_put_channel()
1092 if (!large && chan->flags & in nl80211_msg_put_channel()
1095 if (!large && chan->freq_offset) in nl80211_msg_put_channel()
1099 chan->center_freq)) in nl80211_msg_put_channel()
1102 if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_OFFSET, chan->freq_offset)) in nl80211_msg_put_channel()
1105 if ((chan->flags & IEEE80211_CHAN_DISABLED) && in nl80211_msg_put_channel()
1108 if (chan->flags & IEEE80211_CHAN_NO_IR) { in nl80211_msg_put_channel()
1114 if (chan->flags & IEEE80211_CHAN_RADAR) { in nl80211_msg_put_channel()
1120 time = elapsed_jiffies_msecs(chan->dfs_state_entered); in nl80211_msg_put_channel()
1123 chan->dfs_state)) in nl80211_msg_put_channel()
1130 chan->dfs_cac_ms)) in nl80211_msg_put_channel()
1136 if ((chan->flags & IEEE80211_CHAN_NO_HT40MINUS) && in nl80211_msg_put_channel()
1139 if ((chan->flags & IEEE80211_CHAN_NO_HT40PLUS) && in nl80211_msg_put_channel()
1142 if ((chan->flags & IEEE80211_CHAN_NO_80MHZ) && in nl80211_msg_put_channel()
1145 if ((chan->flags & IEEE80211_CHAN_NO_160MHZ) && in nl80211_msg_put_channel()
1148 if ((chan->flags & IEEE80211_CHAN_INDOOR_ONLY) && in nl80211_msg_put_channel()
1151 if ((chan->flags & IEEE80211_CHAN_IR_CONCURRENT) && in nl80211_msg_put_channel()
1154 if ((chan->flags & IEEE80211_CHAN_NO_20MHZ) && in nl80211_msg_put_channel()
1157 if ((chan->flags & IEEE80211_CHAN_NO_10MHZ) && in nl80211_msg_put_channel()
1160 if ((chan->flags & IEEE80211_CHAN_NO_HE) && in nl80211_msg_put_channel()
1163 if ((chan->flags & IEEE80211_CHAN_1MHZ) && in nl80211_msg_put_channel()
1166 if ((chan->flags & IEEE80211_CHAN_2MHZ) && in nl80211_msg_put_channel()
1169 if ((chan->flags & IEEE80211_CHAN_4MHZ) && in nl80211_msg_put_channel()
1172 if ((chan->flags & IEEE80211_CHAN_8MHZ) && in nl80211_msg_put_channel()
1175 if ((chan->flags & IEEE80211_CHAN_16MHZ) && in nl80211_msg_put_channel()
1178 if ((chan->flags & IEEE80211_CHAN_NO_320MHZ) && in nl80211_msg_put_channel()
1181 if ((chan->flags & IEEE80211_CHAN_NO_EHT) && in nl80211_msg_put_channel()
1187 DBM_TO_MBM(chan->max_power))) in nl80211_msg_put_channel()
1192 freq_reg_info(wiphy, MHZ_TO_KHZ(chan->center_freq)); in nl80211_msg_put_channel()
1194 if (!IS_ERR_OR_NULL(rule) && rule->has_wmm) { in nl80211_msg_put_channel()
1203 return -ENOBUFS; in nl80211_msg_put_channel()
1213 if (txqstats->filled & BIT(NL80211_TXQ_STATS_ ## attr) && \ in nl80211_put_txq_stats()
1214 nla_put_u32(msg, NL80211_TXQ_STATS_ ## attr, txqstats->memb)) \ in nl80211_put_txq_stats()
1242 * nl80211_link_id - return link ID
1267 return -1; in nl80211_link_id_or_invalid()
1286 info->extack); in nl80211_parse_key_new()
1290 k->def = !!tb[NL80211_KEY_DEFAULT]; in nl80211_parse_key_new()
1291 k->defmgmt = !!tb[NL80211_KEY_DEFAULT_MGMT]; in nl80211_parse_key_new()
1292 k->defbeacon = !!tb[NL80211_KEY_DEFAULT_BEACON]; in nl80211_parse_key_new()
1294 if (k->def) { in nl80211_parse_key_new()
1295 k->def_uni = true; in nl80211_parse_key_new()
1296 k->def_multi = true; in nl80211_parse_key_new()
1298 if (k->defmgmt || k->defbeacon) in nl80211_parse_key_new()
1299 k->def_multi = true; in nl80211_parse_key_new()
1302 k->idx = nla_get_u8(tb[NL80211_KEY_IDX]); in nl80211_parse_key_new()
1305 k->p.key = nla_data(tb[NL80211_KEY_DATA]); in nl80211_parse_key_new()
1306 k->p.key_len = nla_len(tb[NL80211_KEY_DATA]); in nl80211_parse_key_new()
1310 k->p.seq = nla_data(tb[NL80211_KEY_SEQ]); in nl80211_parse_key_new()
1311 k->p.seq_len = nla_len(tb[NL80211_KEY_SEQ]); in nl80211_parse_key_new()
1315 k->p.cipher = nla_get_u32(tb[NL80211_KEY_CIPHER]); in nl80211_parse_key_new()
1318 k->type = nla_get_u32(tb[NL80211_KEY_TYPE]); in nl80211_parse_key_new()
1324 NUM_NL80211_KEY_DEFAULT_TYPES - 1, in nl80211_parse_key_new()
1327 info->extack); in nl80211_parse_key_new()
1331 k->def_uni = kdt[NL80211_KEY_DEFAULT_TYPE_UNICAST]; in nl80211_parse_key_new()
1332 k->def_multi = kdt[NL80211_KEY_DEFAULT_TYPE_MULTICAST]; in nl80211_parse_key_new()
1336 k->p.mode = nla_get_u8(tb[NL80211_KEY_MODE]); in nl80211_parse_key_new()
1343 if (info->attrs[NL80211_ATTR_KEY_DATA]) { in nl80211_parse_key_old()
1344 k->p.key = nla_data(info->attrs[NL80211_ATTR_KEY_DATA]); in nl80211_parse_key_old()
1345 k->p.key_len = nla_len(info->attrs[NL80211_ATTR_KEY_DATA]); in nl80211_parse_key_old()
1348 if (info->attrs[NL80211_ATTR_KEY_SEQ]) { in nl80211_parse_key_old()
1349 k->p.seq = nla_data(info->attrs[NL80211_ATTR_KEY_SEQ]); in nl80211_parse_key_old()
1350 k->p.seq_len = nla_len(info->attrs[NL80211_ATTR_KEY_SEQ]); in nl80211_parse_key_old()
1353 if (info->attrs[NL80211_ATTR_KEY_IDX]) in nl80211_parse_key_old()
1354 k->idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]); in nl80211_parse_key_old()
1356 if (info->attrs[NL80211_ATTR_KEY_CIPHER]) in nl80211_parse_key_old()
1357 k->p.cipher = nla_get_u32(info->attrs[NL80211_ATTR_KEY_CIPHER]); in nl80211_parse_key_old()
1359 k->def = !!info->attrs[NL80211_ATTR_KEY_DEFAULT]; in nl80211_parse_key_old()
1360 k->defmgmt = !!info->attrs[NL80211_ATTR_KEY_DEFAULT_MGMT]; in nl80211_parse_key_old()
1362 if (k->def) { in nl80211_parse_key_old()
1363 k->def_uni = true; in nl80211_parse_key_old()
1364 k->def_multi = true; in nl80211_parse_key_old()
1366 if (k->defmgmt) in nl80211_parse_key_old()
1367 k->def_multi = true; in nl80211_parse_key_old()
1369 if (info->attrs[NL80211_ATTR_KEY_TYPE]) in nl80211_parse_key_old()
1370 k->type = nla_get_u32(info->attrs[NL80211_ATTR_KEY_TYPE]); in nl80211_parse_key_old()
1372 if (info->attrs[NL80211_ATTR_KEY_DEFAULT_TYPES]) { in nl80211_parse_key_old()
1375 NUM_NL80211_KEY_DEFAULT_TYPES - 1, in nl80211_parse_key_old()
1376 info->attrs[NL80211_ATTR_KEY_DEFAULT_TYPES], in nl80211_parse_key_old()
1378 info->extack); in nl80211_parse_key_old()
1382 k->def_uni = kdt[NL80211_KEY_DEFAULT_TYPE_UNICAST]; in nl80211_parse_key_old()
1383 k->def_multi = kdt[NL80211_KEY_DEFAULT_TYPE_MULTICAST]; in nl80211_parse_key_old()
1394 k->idx = -1; in nl80211_parse_key()
1395 k->type = -1; in nl80211_parse_key()
1397 if (info->attrs[NL80211_ATTR_KEY]) in nl80211_parse_key()
1398 err = nl80211_parse_key_new(info, info->attrs[NL80211_ATTR_KEY], k); in nl80211_parse_key()
1405 if ((k->def ? 1 : 0) + (k->defmgmt ? 1 : 0) + in nl80211_parse_key()
1406 (k->defbeacon ? 1 : 0) > 1) { in nl80211_parse_key()
1409 return -EINVAL; in nl80211_parse_key()
1412 if (k->defmgmt || k->defbeacon) { in nl80211_parse_key()
1413 if (k->def_uni || !k->def_multi) { in nl80211_parse_key()
1416 return -EINVAL; in nl80211_parse_key()
1420 if (k->idx != -1) { in nl80211_parse_key()
1421 if (k->defmgmt) { in nl80211_parse_key()
1422 if (k->idx < 4 || k->idx > 5) { in nl80211_parse_key()
1425 return -EINVAL; in nl80211_parse_key()
1427 } else if (k->defbeacon) { in nl80211_parse_key()
1428 if (k->idx < 6 || k->idx > 7) { in nl80211_parse_key()
1431 return -EINVAL; in nl80211_parse_key()
1433 } else if (k->def) { in nl80211_parse_key()
1434 if (k->idx < 0 || k->idx > 3) { in nl80211_parse_key()
1435 GENL_SET_ERR_MSG(info, "def key idx not 0-3"); in nl80211_parse_key()
1436 return -EINVAL; in nl80211_parse_key()
1439 if (k->idx < 0 || k->idx > 7) { in nl80211_parse_key()
1440 GENL_SET_ERR_MSG(info, "key idx not 0-7"); in nl80211_parse_key()
1441 return -EINVAL; in nl80211_parse_key()
1453 struct nlattr *keys = info->attrs[NL80211_ATTR_KEYS]; in nl80211_parse_connkeys()
1470 return ERR_PTR(-ENOMEM); in nl80211_parse_connkeys()
1472 result->def = -1; in nl80211_parse_connkeys()
1476 parse.idx = -1; in nl80211_parse_connkeys()
1481 err = -EINVAL; in nl80211_parse_connkeys()
1485 GENL_SET_ERR_MSG(info, "key index out of range [0-3]"); in nl80211_parse_connkeys()
1495 result->def = parse.idx; in nl80211_parse_connkeys()
1507 err = -EINVAL; in nl80211_parse_connkeys()
1510 result->params[parse.idx].cipher = parse.p.cipher; in nl80211_parse_connkeys()
1511 result->params[parse.idx].key_len = parse.p.key_len; in nl80211_parse_connkeys()
1512 result->params[parse.idx].key = result->data[parse.idx]; in nl80211_parse_connkeys()
1513 memcpy(result->data[parse.idx], parse.p.key, parse.p.key_len); in nl80211_parse_connkeys()
1520 if (result->def < 0) { in nl80211_parse_connkeys()
1521 err = -EINVAL; in nl80211_parse_connkeys()
1536 switch (wdev->iftype) { in nl80211_key_allowed()
1543 if (wdev->u.ibss.current_bss) in nl80211_key_allowed()
1545 return -ENOLINK; in nl80211_key_allowed()
1548 if (wdev->connected) in nl80211_key_allowed()
1550 return -ENOLINK; in nl80211_key_allowed()
1558 return -EINVAL; in nl80211_key_allowed()
1570 if (!chan || chan->flags & IEEE80211_CHAN_DISABLED) in nl80211_get_valid_chan()
1595 return -ENOBUFS; in nl80211_put_iftypes()
1610 for (i = 0; i < wiphy->n_iface_combinations; i++) { in nl80211_put_iface_combinations()
1614 c = &wiphy->iface_combinations[i]; in nl80211_put_iface_combinations()
1625 for (j = 0; j < c->n_limits; j++) { in nl80211_put_iface_combinations()
1632 c->limits[j].max)) in nl80211_put_iface_combinations()
1635 c->limits[j].types)) in nl80211_put_iface_combinations()
1642 if (c->beacon_int_infra_match && in nl80211_put_iface_combinations()
1646 c->num_different_channels) || in nl80211_put_iface_combinations()
1648 c->max_interfaces)) in nl80211_put_iface_combinations()
1652 c->radar_detect_widths) || in nl80211_put_iface_combinations()
1654 c->radar_detect_regions))) in nl80211_put_iface_combinations()
1656 if (c->beacon_int_min_gcd && in nl80211_put_iface_combinations()
1658 c->beacon_int_min_gcd)) in nl80211_put_iface_combinations()
1668 return -ENOBUFS; in nl80211_put_iface_combinations()
1675 const struct wiphy_wowlan_tcp_support *tcp = rdev->wiphy.wowlan->tcp; in nl80211_send_wowlan_tcp_caps()
1684 return -ENOBUFS; in nl80211_send_wowlan_tcp_caps()
1687 tcp->data_payload_max)) in nl80211_send_wowlan_tcp_caps()
1688 return -ENOBUFS; in nl80211_send_wowlan_tcp_caps()
1691 tcp->data_payload_max)) in nl80211_send_wowlan_tcp_caps()
1692 return -ENOBUFS; in nl80211_send_wowlan_tcp_caps()
1694 if (tcp->seq && nla_put_flag(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ)) in nl80211_send_wowlan_tcp_caps()
1695 return -ENOBUFS; in nl80211_send_wowlan_tcp_caps()
1697 if (tcp->tok && nla_put(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN, in nl80211_send_wowlan_tcp_caps()
1698 sizeof(*tcp->tok), tcp->tok)) in nl80211_send_wowlan_tcp_caps()
1699 return -ENOBUFS; in nl80211_send_wowlan_tcp_caps()
1702 tcp->data_interval_max)) in nl80211_send_wowlan_tcp_caps()
1703 return -ENOBUFS; in nl80211_send_wowlan_tcp_caps()
1706 tcp->wake_payload_max)) in nl80211_send_wowlan_tcp_caps()
1707 return -ENOBUFS; in nl80211_send_wowlan_tcp_caps()
1719 if (!rdev->wiphy.wowlan) in nl80211_send_wowlan()
1725 return -ENOBUFS; in nl80211_send_wowlan()
1727 if (((rdev->wiphy.wowlan->flags & WIPHY_WOWLAN_ANY) && in nl80211_send_wowlan()
1729 ((rdev->wiphy.wowlan->flags & WIPHY_WOWLAN_DISCONNECT) && in nl80211_send_wowlan()
1731 ((rdev->wiphy.wowlan->flags & WIPHY_WOWLAN_MAGIC_PKT) && in nl80211_send_wowlan()
1733 ((rdev->wiphy.wowlan->flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY) && in nl80211_send_wowlan()
1735 ((rdev->wiphy.wowlan->flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) && in nl80211_send_wowlan()
1737 ((rdev->wiphy.wowlan->flags & WIPHY_WOWLAN_EAP_IDENTITY_REQ) && in nl80211_send_wowlan()
1739 ((rdev->wiphy.wowlan->flags & WIPHY_WOWLAN_4WAY_HANDSHAKE) && in nl80211_send_wowlan()
1741 ((rdev->wiphy.wowlan->flags & WIPHY_WOWLAN_RFKILL_RELEASE) && in nl80211_send_wowlan()
1743 return -ENOBUFS; in nl80211_send_wowlan()
1745 if (rdev->wiphy.wowlan->n_patterns) { in nl80211_send_wowlan()
1747 .max_patterns = rdev->wiphy.wowlan->n_patterns, in nl80211_send_wowlan()
1748 .min_pattern_len = rdev->wiphy.wowlan->pattern_min_len, in nl80211_send_wowlan()
1749 .max_pattern_len = rdev->wiphy.wowlan->pattern_max_len, in nl80211_send_wowlan()
1750 .max_pkt_offset = rdev->wiphy.wowlan->max_pkt_offset, in nl80211_send_wowlan()
1755 return -ENOBUFS; in nl80211_send_wowlan()
1758 if ((rdev->wiphy.wowlan->flags & WIPHY_WOWLAN_NET_DETECT) && in nl80211_send_wowlan()
1760 rdev->wiphy.wowlan->max_nd_match_sets)) in nl80211_send_wowlan()
1761 return -ENOBUFS; in nl80211_send_wowlan()
1764 return -ENOBUFS; in nl80211_send_wowlan()
1777 if (!rdev->wiphy.coalesce) in nl80211_send_coalesce()
1780 rule.max_rules = rdev->wiphy.coalesce->n_rules; in nl80211_send_coalesce()
1781 rule.max_delay = rdev->wiphy.coalesce->max_delay; in nl80211_send_coalesce()
1782 rule.pat.max_patterns = rdev->wiphy.coalesce->n_patterns; in nl80211_send_coalesce()
1783 rule.pat.min_pattern_len = rdev->wiphy.coalesce->pattern_min_len; in nl80211_send_coalesce()
1784 rule.pat.max_pattern_len = rdev->wiphy.coalesce->pattern_max_len; in nl80211_send_coalesce()
1785 rule.pat.max_pkt_offset = rdev->wiphy.coalesce->max_pkt_offset; in nl80211_send_coalesce()
1788 return -ENOBUFS; in nl80211_send_coalesce()
1798 const struct ieee80211_sta_he_cap *he_cap = &iftdata->he_cap; in nl80211_send_iftype_data()
1799 const struct ieee80211_sta_eht_cap *eht_cap = &iftdata->eht_cap; in nl80211_send_iftype_data()
1802 iftdata->types_mask)) in nl80211_send_iftype_data()
1803 return -ENOBUFS; in nl80211_send_iftype_data()
1805 if (he_cap->has_he) { in nl80211_send_iftype_data()
1807 sizeof(he_cap->he_cap_elem.mac_cap_info), in nl80211_send_iftype_data()
1808 he_cap->he_cap_elem.mac_cap_info) || in nl80211_send_iftype_data()
1810 sizeof(he_cap->he_cap_elem.phy_cap_info), in nl80211_send_iftype_data()
1811 he_cap->he_cap_elem.phy_cap_info) || in nl80211_send_iftype_data()
1813 sizeof(he_cap->he_mcs_nss_supp), in nl80211_send_iftype_data()
1814 &he_cap->he_mcs_nss_supp) || in nl80211_send_iftype_data()
1816 sizeof(he_cap->ppe_thres), he_cap->ppe_thres)) in nl80211_send_iftype_data()
1817 return -ENOBUFS; in nl80211_send_iftype_data()
1820 if (eht_cap->has_eht && he_cap->has_he) { in nl80211_send_iftype_data()
1825 is_ap = iftdata->types_mask & BIT(NL80211_IFTYPE_AP) || in nl80211_send_iftype_data()
1826 iftdata->types_mask & BIT(NL80211_IFTYPE_P2P_GO); in nl80211_send_iftype_data()
1829 ieee80211_eht_mcs_nss_size(&he_cap->he_cap_elem, in nl80211_send_iftype_data()
1830 &eht_cap->eht_cap_elem, in nl80211_send_iftype_data()
1833 ppe_thres_hdr = get_unaligned_le16(&eht_cap->eht_ppe_thres[0]); in nl80211_send_iftype_data()
1836 eht_cap->eht_cap_elem.phy_cap_info); in nl80211_send_iftype_data()
1839 sizeof(eht_cap->eht_cap_elem.mac_cap_info), in nl80211_send_iftype_data()
1840 eht_cap->eht_cap_elem.mac_cap_info) || in nl80211_send_iftype_data()
1842 sizeof(eht_cap->eht_cap_elem.phy_cap_info), in nl80211_send_iftype_data()
1843 eht_cap->eht_cap_elem.phy_cap_info) || in nl80211_send_iftype_data()
1845 mcs_nss_size, &eht_cap->eht_mcs_nss_supp) || in nl80211_send_iftype_data()
1847 ppe_thresh_size, eht_cap->eht_ppe_thres)) in nl80211_send_iftype_data()
1848 return -ENOBUFS; in nl80211_send_iftype_data()
1851 if (sband->band == NL80211_BAND_6GHZ && in nl80211_send_iftype_data()
1853 sizeof(iftdata->he_6ghz_capa), in nl80211_send_iftype_data()
1854 &iftdata->he_6ghz_capa)) in nl80211_send_iftype_data()
1855 return -ENOBUFS; in nl80211_send_iftype_data()
1857 if (iftdata->vendor_elems.data && iftdata->vendor_elems.len && in nl80211_send_iftype_data()
1859 iftdata->vendor_elems.len, iftdata->vendor_elems.data)) in nl80211_send_iftype_data()
1860 return -ENOBUFS; in nl80211_send_iftype_data()
1874 if (sband->ht_cap.ht_supported && in nl80211_send_band_rateinfo()
1876 sizeof(sband->ht_cap.mcs), in nl80211_send_band_rateinfo()
1877 &sband->ht_cap.mcs) || in nl80211_send_band_rateinfo()
1879 sband->ht_cap.cap) || in nl80211_send_band_rateinfo()
1881 sband->ht_cap.ampdu_factor) || in nl80211_send_band_rateinfo()
1883 sband->ht_cap.ampdu_density))) in nl80211_send_band_rateinfo()
1884 return -ENOBUFS; in nl80211_send_band_rateinfo()
1887 if (sband->vht_cap.vht_supported && in nl80211_send_band_rateinfo()
1889 sizeof(sband->vht_cap.vht_mcs), in nl80211_send_band_rateinfo()
1890 &sband->vht_cap.vht_mcs) || in nl80211_send_band_rateinfo()
1892 sband->vht_cap.cap))) in nl80211_send_band_rateinfo()
1893 return -ENOBUFS; in nl80211_send_band_rateinfo()
1895 if (large && sband->n_iftype_data) { in nl80211_send_band_rateinfo()
1902 return -ENOBUFS; in nl80211_send_band_rateinfo()
1904 for (i = 0; i < sband->n_iftype_data; i++) { in nl80211_send_band_rateinfo()
1909 return -ENOBUFS; in nl80211_send_band_rateinfo()
1912 &sband->iftype_data[i]); in nl80211_send_band_rateinfo()
1923 if (large && sband->edmg_cap.channels && in nl80211_send_band_rateinfo()
1925 sband->edmg_cap.channels) || in nl80211_send_band_rateinfo()
1927 sband->edmg_cap.bw_config))) in nl80211_send_band_rateinfo()
1929 return -ENOBUFS; in nl80211_send_band_rateinfo()
1934 return -ENOBUFS; in nl80211_send_band_rateinfo()
1936 for (i = 0; i < sband->n_bitrates; i++) { in nl80211_send_band_rateinfo()
1939 return -ENOBUFS; in nl80211_send_band_rateinfo()
1941 rate = &sband->bitrates[i]; in nl80211_send_band_rateinfo()
1943 rate->bitrate)) in nl80211_send_band_rateinfo()
1944 return -ENOBUFS; in nl80211_send_band_rateinfo()
1945 if ((rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) && in nl80211_send_band_rateinfo()
1948 return -ENOBUFS; in nl80211_send_band_rateinfo()
1972 return -ENOBUFS; in nl80211_send_mgmt_stypes()
1977 return -ENOBUFS; in nl80211_send_mgmt_stypes()
1984 return -ENOBUFS; in nl80211_send_mgmt_stypes()
1995 return -ENOBUFS; in nl80211_send_mgmt_stypes()
2000 return -ENOBUFS; in nl80211_send_mgmt_stypes()
2007 return -ENOBUFS; in nl80211_send_mgmt_stypes()
2020 if (rdev->ops->op) { \
2054 if (rdev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL) in nl80211_add_commands_unsplit()
2059 if (rdev->wiphy.flags & WIPHY_FLAG_NETNS_OK) { in nl80211_add_commands_unsplit()
2064 if (rdev->ops->set_monitor_channel || rdev->ops->start_ap || in nl80211_add_commands_unsplit()
2065 rdev->ops->join_mesh) { in nl80211_add_commands_unsplit()
2070 if (rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) { in nl80211_add_commands_unsplit()
2074 if (rdev->wiphy.max_sched_scan_reqs) in nl80211_add_commands_unsplit()
2078 if (rdev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS) { in nl80211_add_commands_unsplit()
2089 if (rdev->ops->connect || rdev->ops->auth) { in nl80211_add_commands_unsplit()
2095 if (rdev->ops->disconnect || rdev->ops->deauth) { in nl80211_add_commands_unsplit()
2103 return -ENOBUFS; in nl80211_add_commands_unsplit()
2112 if (!cap->ftm.supported) in nl80211_send_pmsr_ftm_capa()
2117 return -ENOBUFS; in nl80211_send_pmsr_ftm_capa()
2119 if (cap->ftm.asap && nla_put_flag(msg, NL80211_PMSR_FTM_CAPA_ATTR_ASAP)) in nl80211_send_pmsr_ftm_capa()
2120 return -ENOBUFS; in nl80211_send_pmsr_ftm_capa()
2121 if (cap->ftm.non_asap && in nl80211_send_pmsr_ftm_capa()
2123 return -ENOBUFS; in nl80211_send_pmsr_ftm_capa()
2124 if (cap->ftm.request_lci && in nl80211_send_pmsr_ftm_capa()
2126 return -ENOBUFS; in nl80211_send_pmsr_ftm_capa()
2127 if (cap->ftm.request_civicloc && in nl80211_send_pmsr_ftm_capa()
2129 return -ENOBUFS; in nl80211_send_pmsr_ftm_capa()
2131 cap->ftm.preambles)) in nl80211_send_pmsr_ftm_capa()
2132 return -ENOBUFS; in nl80211_send_pmsr_ftm_capa()
2134 cap->ftm.bandwidths)) in nl80211_send_pmsr_ftm_capa()
2135 return -ENOBUFS; in nl80211_send_pmsr_ftm_capa()
2136 if (cap->ftm.max_bursts_exponent >= 0 && in nl80211_send_pmsr_ftm_capa()
2138 cap->ftm.max_bursts_exponent)) in nl80211_send_pmsr_ftm_capa()
2139 return -ENOBUFS; in nl80211_send_pmsr_ftm_capa()
2140 if (cap->ftm.max_ftms_per_burst && in nl80211_send_pmsr_ftm_capa()
2142 cap->ftm.max_ftms_per_burst)) in nl80211_send_pmsr_ftm_capa()
2143 return -ENOBUFS; in nl80211_send_pmsr_ftm_capa()
2144 if (cap->ftm.trigger_based && in nl80211_send_pmsr_ftm_capa()
2146 return -ENOBUFS; in nl80211_send_pmsr_ftm_capa()
2147 if (cap->ftm.non_trigger_based && in nl80211_send_pmsr_ftm_capa()
2149 return -ENOBUFS; in nl80211_send_pmsr_ftm_capa()
2158 const struct cfg80211_pmsr_capabilities *cap = rdev->wiphy.pmsr_capa; in nl80211_send_pmsr_capa()
2171 return -ENOBUFS; in nl80211_send_pmsr_capa()
2173 if (nla_put_u32(msg, NL80211_PMSR_ATTR_MAX_PEERS, cap->max_peers)) in nl80211_send_pmsr_capa()
2174 return -ENOBUFS; in nl80211_send_pmsr_capa()
2176 if (cap->report_ap_tsf && in nl80211_send_pmsr_capa()
2178 return -ENOBUFS; in nl80211_send_pmsr_capa()
2180 if (cap->randomize_mac_addr && in nl80211_send_pmsr_capa()
2182 return -ENOBUFS; in nl80211_send_pmsr_capa()
2186 return -ENOBUFS; in nl80211_send_pmsr_capa()
2189 return -ENOBUFS; in nl80211_send_pmsr_capa()
2205 if (!rdev->wiphy.num_iftype_akm_suites || in nl80211_put_iftype_akm_suites()
2206 !rdev->wiphy.iftype_akm_suites) in nl80211_put_iftype_akm_suites()
2211 return -ENOBUFS; in nl80211_put_iftype_akm_suites()
2213 for (i = 0; i < rdev->wiphy.num_iftype_akm_suites; i++) { in nl80211_put_iftype_akm_suites()
2216 return -ENOBUFS; in nl80211_put_iftype_akm_suites()
2218 iftype_akms = &rdev->wiphy.iftype_akm_suites[i]; in nl80211_put_iftype_akm_suites()
2221 iftype_akms->iftypes_mask)) in nl80211_put_iftype_akm_suites()
2222 return -ENOBUFS; in nl80211_put_iftype_akm_suites()
2225 sizeof(u32) * iftype_akms->n_akm_suites, in nl80211_put_iftype_akm_suites()
2226 iftype_akms->akm_suites)) { in nl80211_put_iftype_akm_suites()
2227 return -ENOBUFS; in nl80211_put_iftype_akm_suites()
2243 if (!rdev->wiphy.tid_config_support.vif && in nl80211_put_tid_config_support()
2244 !rdev->wiphy.tid_config_support.peer) in nl80211_put_tid_config_support()
2249 return -ENOSPC; in nl80211_put_tid_config_support()
2251 if (rdev->wiphy.tid_config_support.vif && in nl80211_put_tid_config_support()
2253 rdev->wiphy.tid_config_support.vif, in nl80211_put_tid_config_support()
2257 if (rdev->wiphy.tid_config_support.peer && in nl80211_put_tid_config_support()
2259 rdev->wiphy.tid_config_support.peer, in nl80211_put_tid_config_support()
2263 /* for now we just use the same value ... makes more sense */ in nl80211_put_tid_config_support()
2265 rdev->wiphy.tid_config_support.max_retry)) in nl80211_put_tid_config_support()
2268 rdev->wiphy.tid_config_support.max_retry)) in nl80211_put_tid_config_support()
2276 return -ENOBUFS; in nl80211_put_tid_config_support()
2287 if (!rdev->wiphy.sar_capa) in nl80211_put_sar_specs()
2290 num_freq_ranges = rdev->wiphy.sar_capa->num_freq_ranges; in nl80211_put_sar_specs()
2294 return -ENOSPC; in nl80211_put_sar_specs()
2296 if (nla_put_u32(msg, NL80211_SAR_ATTR_TYPE, rdev->wiphy.sar_capa->type)) in nl80211_put_sar_specs()
2310 rdev->wiphy.sar_capa->freq_ranges[i].start_freq)) in nl80211_put_sar_specs()
2314 rdev->wiphy.sar_capa->freq_ranges[i].end_freq)) in nl80211_put_sar_specs()
2326 return -ENOBUFS; in nl80211_put_sar_specs()
2333 if (!wiphy->mbssid_max_interfaces) in nl80211_put_mbssid_support()
2338 return -ENOBUFS; in nl80211_put_mbssid_support()
2341 wiphy->mbssid_max_interfaces)) in nl80211_put_mbssid_support()
2344 if (wiphy->ema_max_profile_periodicity && in nl80211_put_mbssid_support()
2347 wiphy->ema_max_profile_periodicity)) in nl80211_put_mbssid_support()
2355 return -ENOBUFS; in nl80211_put_mbssid_support()
2378 rdev->wiphy.mgmt_stypes; in nl80211_send_wiphy()
2383 return -ENOBUFS; in nl80211_send_wiphy()
2386 return -EINVAL; in nl80211_send_wiphy()
2388 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_send_wiphy()
2390 wiphy_name(&rdev->wiphy)) || in nl80211_send_wiphy()
2398 switch (state->split_start) { in nl80211_send_wiphy()
2401 rdev->wiphy.retry_short) || in nl80211_send_wiphy()
2403 rdev->wiphy.retry_long) || in nl80211_send_wiphy()
2405 rdev->wiphy.frag_threshold) || in nl80211_send_wiphy()
2407 rdev->wiphy.rts_threshold) || in nl80211_send_wiphy()
2409 rdev->wiphy.coverage_class) || in nl80211_send_wiphy()
2411 rdev->wiphy.max_scan_ssids) || in nl80211_send_wiphy()
2413 rdev->wiphy.max_sched_scan_ssids) || in nl80211_send_wiphy()
2415 rdev->wiphy.max_scan_ie_len) || in nl80211_send_wiphy()
2417 rdev->wiphy.max_sched_scan_ie_len) || in nl80211_send_wiphy()
2419 rdev->wiphy.max_match_sets)) in nl80211_send_wiphy()
2422 if ((rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN) && in nl80211_send_wiphy()
2425 if ((rdev->wiphy.flags & WIPHY_FLAG_MESH_AUTH) && in nl80211_send_wiphy()
2428 if ((rdev->wiphy.flags & WIPHY_FLAG_AP_UAPSD) && in nl80211_send_wiphy()
2431 if ((rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_FW_ROAM) && in nl80211_send_wiphy()
2434 if ((rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) && in nl80211_send_wiphy()
2437 if ((rdev->wiphy.flags & WIPHY_FLAG_TDLS_EXTERNAL_SETUP) && in nl80211_send_wiphy()
2440 state->split_start++; in nl80211_send_wiphy()
2441 if (state->split) in nl80211_send_wiphy()
2446 sizeof(u32) * rdev->wiphy.n_cipher_suites, in nl80211_send_wiphy()
2447 rdev->wiphy.cipher_suites)) in nl80211_send_wiphy()
2451 rdev->wiphy.max_num_pmkids)) in nl80211_send_wiphy()
2454 if ((rdev->wiphy.flags & WIPHY_FLAG_CONTROL_PORT_PROTOCOL) && in nl80211_send_wiphy()
2459 rdev->wiphy.available_antennas_tx) || in nl80211_send_wiphy()
2461 rdev->wiphy.available_antennas_rx)) in nl80211_send_wiphy()
2464 if ((rdev->wiphy.flags & WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD) && in nl80211_send_wiphy()
2466 rdev->wiphy.probe_resp_offload)) in nl80211_send_wiphy()
2469 if ((rdev->wiphy.available_antennas_tx || in nl80211_send_wiphy()
2470 rdev->wiphy.available_antennas_rx) && in nl80211_send_wiphy()
2471 rdev->ops->get_antenna) { in nl80211_send_wiphy()
2487 state->split_start++; in nl80211_send_wiphy()
2488 if (state->split) in nl80211_send_wiphy()
2493 rdev->wiphy.interface_modes)) in nl80211_send_wiphy()
2495 state->split_start++; in nl80211_send_wiphy()
2496 if (state->split) in nl80211_send_wiphy()
2505 for (band = state->band_start; in nl80211_send_wiphy()
2506 band < (state->split ? in nl80211_send_wiphy()
2513 if (band > NL80211_BAND_5GHZ && !state->split) in nl80211_send_wiphy()
2516 sband = rdev->wiphy.bands[band]; in nl80211_send_wiphy()
2525 switch (state->chan_start) { in nl80211_send_wiphy()
2528 state->split)) in nl80211_send_wiphy()
2530 state->chan_start++; in nl80211_send_wiphy()
2531 if (state->split) in nl80211_send_wiphy()
2541 for (i = state->chan_start - 1; in nl80211_send_wiphy()
2542 i < sband->n_channels; in nl80211_send_wiphy()
2549 chan = &sband->channels[i]; in nl80211_send_wiphy()
2552 msg, &rdev->wiphy, chan, in nl80211_send_wiphy()
2553 state->split)) in nl80211_send_wiphy()
2557 if (state->split) in nl80211_send_wiphy()
2560 if (i < sband->n_channels) in nl80211_send_wiphy()
2561 state->chan_start = i + 2; in nl80211_send_wiphy()
2563 state->chan_start = 0; in nl80211_send_wiphy()
2569 if (state->split) { in nl80211_send_wiphy()
2571 if (state->chan_start) in nl80211_send_wiphy()
2572 band--; in nl80211_send_wiphy()
2579 state->band_start = band + 1; in nl80211_send_wiphy()
2581 state->band_start = 0; in nl80211_send_wiphy()
2584 if (state->band_start == 0 && state->chan_start == 0) in nl80211_send_wiphy()
2585 state->split_start++; in nl80211_send_wiphy()
2586 if (state->split) in nl80211_send_wiphy()
2598 if (state->split) { in nl80211_send_wiphy()
2601 if (rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH) in nl80211_send_wiphy()
2604 if (rdev->wiphy.features & in nl80211_send_wiphy()
2610 if (rdev->wiphy.sar_capa) in nl80211_send_wiphy()
2616 state->split_start++; in nl80211_send_wiphy()
2617 if (state->split) in nl80211_send_wiphy()
2621 if (rdev->ops->remain_on_channel && in nl80211_send_wiphy()
2622 (rdev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL) && in nl80211_send_wiphy()
2625 rdev->wiphy.max_remain_on_channel_duration)) in nl80211_send_wiphy()
2628 if ((rdev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX) && in nl80211_send_wiphy()
2632 state->split_start++; in nl80211_send_wiphy()
2633 if (state->split) in nl80211_send_wiphy()
2638 if (nl80211_send_wowlan(msg, rdev, state->split)) in nl80211_send_wiphy()
2640 state->split_start++; in nl80211_send_wiphy()
2641 if (state->split) in nl80211_send_wiphy()
2644 state->split_start++; in nl80211_send_wiphy()
2649 rdev->wiphy.software_iftypes)) in nl80211_send_wiphy()
2652 if (nl80211_put_iface_combinations(&rdev->wiphy, msg, in nl80211_send_wiphy()
2653 state->split)) in nl80211_send_wiphy()
2656 state->split_start++; in nl80211_send_wiphy()
2657 if (state->split) in nl80211_send_wiphy()
2661 if ((rdev->wiphy.flags & WIPHY_FLAG_HAVE_AP_SME) && in nl80211_send_wiphy()
2663 rdev->wiphy.ap_sme_capa)) in nl80211_send_wiphy()
2666 features = rdev->wiphy.features; in nl80211_send_wiphy()
2668 * We can only add the per-channel limit information if the in nl80211_send_wiphy()
2672 if (state->split) in nl80211_send_wiphy()
2677 if (rdev->wiphy.ht_capa_mod_mask && in nl80211_send_wiphy()
2679 sizeof(*rdev->wiphy.ht_capa_mod_mask), in nl80211_send_wiphy()
2680 rdev->wiphy.ht_capa_mod_mask)) in nl80211_send_wiphy()
2683 if (rdev->wiphy.flags & WIPHY_FLAG_HAVE_AP_SME && in nl80211_send_wiphy()
2684 rdev->wiphy.max_acl_mac_addrs && in nl80211_send_wiphy()
2686 rdev->wiphy.max_acl_mac_addrs)) in nl80211_send_wiphy()
2699 if (state->split) in nl80211_send_wiphy()
2700 state->split_start++; in nl80211_send_wiphy()
2702 state->split_start = 0; in nl80211_send_wiphy()
2709 rdev->wiphy.max_sched_scan_plans) || in nl80211_send_wiphy()
2711 rdev->wiphy.max_sched_scan_plan_interval) || in nl80211_send_wiphy()
2713 rdev->wiphy.max_sched_scan_plan_iterations)) in nl80211_send_wiphy()
2716 if (rdev->wiphy.extended_capabilities && in nl80211_send_wiphy()
2718 rdev->wiphy.extended_capabilities_len, in nl80211_send_wiphy()
2719 rdev->wiphy.extended_capabilities) || in nl80211_send_wiphy()
2721 rdev->wiphy.extended_capabilities_len, in nl80211_send_wiphy()
2722 rdev->wiphy.extended_capabilities_mask))) in nl80211_send_wiphy()
2725 if (rdev->wiphy.vht_capa_mod_mask && in nl80211_send_wiphy()
2727 sizeof(*rdev->wiphy.vht_capa_mod_mask), in nl80211_send_wiphy()
2728 rdev->wiphy.vht_capa_mod_mask)) in nl80211_send_wiphy()
2732 rdev->wiphy.perm_addr)) in nl80211_send_wiphy()
2735 if (!is_zero_ether_addr(rdev->wiphy.addr_mask) && in nl80211_send_wiphy()
2737 rdev->wiphy.addr_mask)) in nl80211_send_wiphy()
2740 if (rdev->wiphy.n_addresses > 1) { in nl80211_send_wiphy()
2747 for (i = 0; i < rdev->wiphy.n_addresses; i++) in nl80211_send_wiphy()
2749 rdev->wiphy.addresses[i].addr)) in nl80211_send_wiphy()
2755 state->split_start++; in nl80211_send_wiphy()
2761 if ((rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_5_10_MHZ) && in nl80211_send_wiphy()
2766 if (rdev->wiphy.max_ap_assoc_sta && in nl80211_send_wiphy()
2768 rdev->wiphy.max_ap_assoc_sta)) in nl80211_send_wiphy()
2771 state->split_start++; in nl80211_send_wiphy()
2774 if (rdev->wiphy.n_vendor_commands) { in nl80211_send_wiphy()
2783 for (i = 0; i < rdev->wiphy.n_vendor_commands; i++) { in nl80211_send_wiphy()
2784 info = &rdev->wiphy.vendor_commands[i].info; in nl80211_send_wiphy()
2791 if (rdev->wiphy.n_vendor_events) { in nl80211_send_wiphy()
2800 for (i = 0; i < rdev->wiphy.n_vendor_events; i++) { in nl80211_send_wiphy()
2801 info = &rdev->wiphy.vendor_events[i]; in nl80211_send_wiphy()
2807 state->split_start++; in nl80211_send_wiphy()
2810 if (rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH && in nl80211_send_wiphy()
2812 rdev->wiphy.max_num_csa_counters)) in nl80211_send_wiphy()
2815 if (rdev->wiphy.regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED && in nl80211_send_wiphy()
2819 if (rdev->wiphy.max_sched_scan_reqs && in nl80211_send_wiphy()
2821 rdev->wiphy.max_sched_scan_reqs)) in nl80211_send_wiphy()
2825 sizeof(rdev->wiphy.ext_features), in nl80211_send_wiphy()
2826 rdev->wiphy.ext_features)) in nl80211_send_wiphy()
2829 if (rdev->wiphy.bss_select_support) { in nl80211_send_wiphy()
2831 u32 bss_select_support = rdev->wiphy.bss_select_support; in nl80211_send_wiphy()
2849 state->split_start++; in nl80211_send_wiphy()
2852 if (rdev->wiphy.num_iftype_ext_capab && in nl80211_send_wiphy()
2853 rdev->wiphy.iftype_ext_capab) { in nl80211_send_wiphy()
2861 for (i = state->capa_start; in nl80211_send_wiphy()
2862 i < rdev->wiphy.num_iftype_ext_capab; i++) { in nl80211_send_wiphy()
2865 capab = &rdev->wiphy.iftype_ext_capab[i]; in nl80211_send_wiphy()
2871 capab->iftype) || in nl80211_send_wiphy()
2873 capab->extended_capabilities_len, in nl80211_send_wiphy()
2874 capab->extended_capabilities) || in nl80211_send_wiphy()
2876 capab->extended_capabilities_len, in nl80211_send_wiphy()
2877 capab->extended_capabilities_mask)) in nl80211_send_wiphy()
2880 if (rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_MLO && in nl80211_send_wiphy()
2883 capab->eml_capabilities) || in nl80211_send_wiphy()
2886 capab->mld_capa_and_ops))) in nl80211_send_wiphy()
2890 if (state->split) in nl80211_send_wiphy()
2894 if (i < rdev->wiphy.num_iftype_ext_capab) { in nl80211_send_wiphy()
2895 state->capa_start = i + 1; in nl80211_send_wiphy()
2901 rdev->wiphy.nan_supported_bands)) in nl80211_send_wiphy()
2904 if (wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_send_wiphy()
2916 rdev->wiphy.txq_limit)) in nl80211_send_wiphy()
2919 rdev->wiphy.txq_memory_limit)) in nl80211_send_wiphy()
2922 rdev->wiphy.txq_quantum)) in nl80211_send_wiphy()
2926 state->split_start++; in nl80211_send_wiphy()
2932 state->split_start++; in nl80211_send_wiphy()
2935 if (rdev->wiphy.akm_suites && in nl80211_send_wiphy()
2937 sizeof(u32) * rdev->wiphy.n_akm_suites, in nl80211_send_wiphy()
2938 rdev->wiphy.akm_suites)) in nl80211_send_wiphy()
2946 state->split_start++; in nl80211_send_wiphy()
2952 if (nl80211_put_mbssid_support(&rdev->wiphy, msg)) in nl80211_send_wiphy()
2956 rdev->wiphy.max_num_akm_suites)) in nl80211_send_wiphy()
2959 if (rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_MLO) in nl80211_send_wiphy()
2963 state->split_start = 0; in nl80211_send_wiphy()
2972 return -EMSGSIZE; in nl80211_send_wiphy()
2983 return -ENOMEM; in nl80211_dump_wiphy_parse()
2985 ret = nlmsg_parse_deprecated(cb->nlh, in nl80211_dump_wiphy_parse()
2995 state->split = tb[NL80211_ATTR_SPLIT_WIPHY_DUMP]; in nl80211_dump_wiphy_parse()
2997 state->filter_wiphy = nla_get_u32(tb[NL80211_ATTR_WIPHY]); in nl80211_dump_wiphy_parse()
2999 state->filter_wiphy = nla_get_u64(tb[NL80211_ATTR_WDEV]) >> 32; in nl80211_dump_wiphy_parse()
3005 netdev = __dev_get_by_index(sock_net(skb->sk), ifidx); in nl80211_dump_wiphy_parse()
3007 ret = -ENODEV; in nl80211_dump_wiphy_parse()
3010 if (netdev->ieee80211_ptr) { in nl80211_dump_wiphy_parse()
3012 netdev->ieee80211_ptr->wiphy); in nl80211_dump_wiphy_parse()
3013 state->filter_wiphy = rdev->wiphy_idx; in nl80211_dump_wiphy_parse()
3026 struct nl80211_dump_wiphy_state *state = (void *)cb->args[0]; in nl80211_dump_wiphy()
3034 return -ENOMEM; in nl80211_dump_wiphy()
3036 state->filter_wiphy = -1; in nl80211_dump_wiphy()
3043 cb->args[0] = (long)state; in nl80211_dump_wiphy()
3047 if (!net_eq(wiphy_net(&rdev->wiphy), sock_net(skb->sk))) in nl80211_dump_wiphy()
3049 if (++idx <= state->start) in nl80211_dump_wiphy()
3051 if (state->filter_wiphy != -1 && in nl80211_dump_wiphy()
3052 state->filter_wiphy != rdev->wiphy_idx) in nl80211_dump_wiphy()
3058 NETLINK_CB(cb->skb).portid, in nl80211_dump_wiphy()
3059 cb->nlh->nlmsg_seq, in nl80211_dump_wiphy()
3075 if ((ret == -ENOBUFS || ret == -EMSGSIZE) && in nl80211_dump_wiphy()
3076 !skb->len && !state->split && in nl80211_dump_wiphy()
3077 cb->min_dump_alloc < 4096) { in nl80211_dump_wiphy()
3078 cb->min_dump_alloc = 4096; in nl80211_dump_wiphy()
3079 state->split_start = 0; in nl80211_dump_wiphy()
3083 idx--; in nl80211_dump_wiphy()
3086 } while (state->split_start > 0); in nl80211_dump_wiphy()
3091 state->start = idx; in nl80211_dump_wiphy()
3093 return skb->len; in nl80211_dump_wiphy()
3098 kfree((void *)cb->args[0]); in nl80211_dump_wiphy_done()
3105 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_get_wiphy()
3110 return -ENOMEM; in nl80211_get_wiphy()
3113 info->snd_portid, info->snd_seq, 0, in nl80211_get_wiphy()
3116 return -ENOBUFS; in nl80211_get_wiphy()
3138 return -EINVAL; in parse_txq_params()
3141 txq_params->txop = nla_get_u16(tb[NL80211_TXQ_ATTR_TXOP]); in parse_txq_params()
3142 txq_params->cwmin = nla_get_u16(tb[NL80211_TXQ_ATTR_CWMIN]); in parse_txq_params()
3143 txq_params->cwmax = nla_get_u16(tb[NL80211_TXQ_ATTR_CWMAX]); in parse_txq_params()
3144 txq_params->aifs = nla_get_u8(tb[NL80211_TXQ_ATTR_AIFS]); in parse_txq_params()
3147 return -EINVAL; in parse_txq_params()
3148 txq_params->ac = array_index_nospec(ac, NL80211_NUM_ACS); in parse_txq_params()
3161 * low-level driver when the AP starts or the mesh is joined. in nl80211_can_set_dev_channel()
3163 * the channel in the start-ap or join-mesh commands instead. in nl80211_can_set_dev_channel()
3170 wdev->iftype == NL80211_IFTYPE_AP || in nl80211_can_set_dev_channel()
3171 wdev->iftype == NL80211_IFTYPE_MESH_POINT || in nl80211_can_set_dev_channel()
3172 wdev->iftype == NL80211_IFTYPE_MONITOR || in nl80211_can_set_dev_channel()
3173 wdev->iftype == NL80211_IFTYPE_P2P_GO; in nl80211_can_set_dev_channel()
3180 struct netlink_ext_ack *extack = info->extack; in nl80211_parse_chandef()
3181 struct nlattr **attrs = info->attrs; in nl80211_parse_chandef()
3185 return -EINVAL; in nl80211_parse_chandef()
3188 nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ])); in nl80211_parse_chandef()
3189 if (info->attrs[NL80211_ATTR_WIPHY_FREQ_OFFSET]) in nl80211_parse_chandef()
3191 nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ_OFFSET]); in nl80211_parse_chandef()
3194 chandef->chan = ieee80211_get_channel_khz(&rdev->wiphy, control_freq); in nl80211_parse_chandef()
3195 chandef->width = NL80211_CHAN_WIDTH_20_NOHT; in nl80211_parse_chandef()
3196 chandef->center_freq1 = KHZ_TO_MHZ(control_freq); in nl80211_parse_chandef()
3197 chandef->freq1_offset = control_freq % 1000; in nl80211_parse_chandef()
3198 chandef->center_freq2 = 0; in nl80211_parse_chandef()
3201 if (!chandef->chan || chandef->chan->flags & IEEE80211_CHAN_DISABLED) { in nl80211_parse_chandef()
3204 return -EINVAL; in nl80211_parse_chandef()
3217 cfg80211_chandef_create(chandef, chandef->chan, in nl80211_parse_chandef()
3221 chandef->center_freq1 != nla_get_u32(attrs[NL80211_ATTR_CENTER_FREQ1])) { in nl80211_parse_chandef()
3225 return -EINVAL; in nl80211_parse_chandef()
3233 return -EINVAL; in nl80211_parse_chandef()
3240 return -EINVAL; in nl80211_parse_chandef()
3243 chandef->width = in nl80211_parse_chandef()
3245 if (chandef->chan->band == NL80211_BAND_S1GHZ) { in nl80211_parse_chandef()
3246 /* User input error for channel width doesn't match channel */ in nl80211_parse_chandef()
3247 if (chandef->width != ieee80211_s1g_channel_width(chandef->chan)) { in nl80211_parse_chandef()
3250 "bad channel width"); in nl80211_parse_chandef()
3251 return -EINVAL; in nl80211_parse_chandef()
3255 chandef->center_freq1 = in nl80211_parse_chandef()
3258 chandef->freq1_offset = nla_get_u32( in nl80211_parse_chandef()
3261 chandef->freq1_offset = 0; in nl80211_parse_chandef()
3264 chandef->center_freq2 = in nl80211_parse_chandef()
3268 if (info->attrs[NL80211_ATTR_WIPHY_EDMG_CHANNELS]) { in nl80211_parse_chandef()
3269 chandef->edmg.channels = in nl80211_parse_chandef()
3270 nla_get_u8(info->attrs[NL80211_ATTR_WIPHY_EDMG_CHANNELS]); in nl80211_parse_chandef()
3272 if (info->attrs[NL80211_ATTR_WIPHY_EDMG_BW_CONFIG]) in nl80211_parse_chandef()
3273 chandef->edmg.bw_config = in nl80211_parse_chandef()
3274 nla_get_u8(info->attrs[NL80211_ATTR_WIPHY_EDMG_BW_CONFIG]); in nl80211_parse_chandef()
3276 chandef->edmg.bw_config = 0; in nl80211_parse_chandef()
3277 chandef->edmg.channels = 0; in nl80211_parse_chandef()
3282 return -EINVAL; in nl80211_parse_chandef()
3285 if (!cfg80211_chandef_usable(&rdev->wiphy, chandef, in nl80211_parse_chandef()
3288 return -EINVAL; in nl80211_parse_chandef()
3291 if ((chandef->width == NL80211_CHAN_WIDTH_5 || in nl80211_parse_chandef()
3292 chandef->width == NL80211_CHAN_WIDTH_10) && in nl80211_parse_chandef()
3293 !(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_5_10_MHZ)) { in nl80211_parse_chandef()
3295 return -EINVAL; in nl80211_parse_chandef()
3313 wdev = dev->ieee80211_ptr; in __nl80211_set_channel()
3315 return -EOPNOTSUPP; in __nl80211_set_channel()
3317 iftype = wdev->iftype; in __nl80211_set_channel()
3320 if (wdev && wdev->valid_links) in __nl80211_set_channel()
3321 return -EINVAL; in __nl80211_set_channel()
3332 if (!cfg80211_reg_can_beacon_relax(&rdev->wiphy, &chandef, in __nl80211_set_channel()
3334 return -EINVAL; in __nl80211_set_channel()
3335 if (wdev->links[link_id].ap.beacon_interval) { in __nl80211_set_channel()
3338 if (!dev || !rdev->ops->set_ap_chanwidth || in __nl80211_set_channel()
3339 !(rdev->wiphy.features & in __nl80211_set_channel()
3341 return -EBUSY; in __nl80211_set_channel()
3343 /* Only allow dynamic channel width changes */ in __nl80211_set_channel()
3344 cur_chan = wdev->links[link_id].ap.chandef.chan; in __nl80211_set_channel()
3346 return -EBUSY; in __nl80211_set_channel()
3352 wdev->links[link_id].ap.chandef = chandef; in __nl80211_set_channel()
3354 wdev->u.ap.preset_chandef = chandef; in __nl80211_set_channel()
3365 return -EINVAL; in __nl80211_set_channel()
3370 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_channel()
3371 int link_id = nl80211_link_id_or_invalid(info->attrs); in nl80211_set_channel()
3372 struct net_device *netdev = info->user_ptr[1]; in nl80211_set_channel()
3375 wdev_lock(netdev->ieee80211_ptr); in nl80211_set_channel()
3377 wdev_unlock(netdev->ieee80211_ptr); in nl80211_set_channel()
3399 * done for backward compatibility -- previously in nl80211_set_wiphy()
3406 if (info->attrs[NL80211_ATTR_IFINDEX]) { in nl80211_set_wiphy()
3407 int ifindex = nla_get_u32(info->attrs[NL80211_ATTR_IFINDEX]); in nl80211_set_wiphy()
3410 if (netdev && netdev->ieee80211_ptr) in nl80211_set_wiphy()
3411 rdev = wiphy_to_rdev(netdev->ieee80211_ptr->wiphy); in nl80211_set_wiphy()
3418 info->attrs); in nl80211_set_wiphy()
3427 wdev = netdev->ieee80211_ptr; in nl80211_set_wiphy()
3429 wiphy_lock(&rdev->wiphy); in nl80211_set_wiphy()
3436 if (info->attrs[NL80211_ATTR_WIPHY_NAME]) in nl80211_set_wiphy()
3438 rdev, nla_data(info->attrs[NL80211_ATTR_WIPHY_NAME])); in nl80211_set_wiphy()
3444 if (info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS]) { in nl80211_set_wiphy()
3448 if (!rdev->ops->set_txq_params) { in nl80211_set_wiphy()
3449 result = -EOPNOTSUPP; in nl80211_set_wiphy()
3454 result = -EINVAL; in nl80211_set_wiphy()
3458 if (netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && in nl80211_set_wiphy()
3459 netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) { in nl80211_set_wiphy()
3460 result = -EINVAL; in nl80211_set_wiphy()
3465 result = -ENETDOWN; in nl80211_set_wiphy()
3470 info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS], in nl80211_set_wiphy()
3476 info->extack); in nl80211_set_wiphy()
3484 nl80211_link_id_or_invalid(info->attrs); in nl80211_set_wiphy()
3486 wdev_lock(netdev->ieee80211_ptr); in nl80211_set_wiphy()
3488 !(netdev->ieee80211_ptr->valid_links & in nl80211_set_wiphy()
3490 result = -ENOLINK; in nl80211_set_wiphy()
3492 !netdev->ieee80211_ptr->valid_links) in nl80211_set_wiphy()
3493 result = -EINVAL; in nl80211_set_wiphy()
3497 wdev_unlock(netdev->ieee80211_ptr); in nl80211_set_wiphy()
3503 if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { in nl80211_set_wiphy()
3504 int link_id = nl80211_link_id_or_invalid(info->attrs); in nl80211_set_wiphy()
3521 if (info->attrs[NL80211_ATTR_WIPHY_TX_POWER_SETTING]) { in nl80211_set_wiphy()
3526 if (!(rdev->wiphy.features & NL80211_FEATURE_VIF_TXPOWER)) in nl80211_set_wiphy()
3529 if (!rdev->ops->set_tx_power) { in nl80211_set_wiphy()
3530 result = -EOPNOTSUPP; in nl80211_set_wiphy()
3535 type = nla_get_u32(info->attrs[idx]); in nl80211_set_wiphy()
3537 if (!info->attrs[NL80211_ATTR_WIPHY_TX_POWER_LEVEL] && in nl80211_set_wiphy()
3539 result = -EINVAL; in nl80211_set_wiphy()
3545 mbm = nla_get_u32(info->attrs[idx]); in nl80211_set_wiphy()
3553 if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX] && in nl80211_set_wiphy()
3554 info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]) { in nl80211_set_wiphy()
3557 if ((!rdev->wiphy.available_antennas_tx && in nl80211_set_wiphy()
3558 !rdev->wiphy.available_antennas_rx) || in nl80211_set_wiphy()
3559 !rdev->ops->set_antenna) { in nl80211_set_wiphy()
3560 result = -EOPNOTSUPP; in nl80211_set_wiphy()
3564 tx_ant = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX]); in nl80211_set_wiphy()
3565 rx_ant = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]); in nl80211_set_wiphy()
3569 if ((~tx_ant && (tx_ant & ~rdev->wiphy.available_antennas_tx)) || in nl80211_set_wiphy()
3570 (~rx_ant && (rx_ant & ~rdev->wiphy.available_antennas_rx))) { in nl80211_set_wiphy()
3571 result = -EINVAL; in nl80211_set_wiphy()
3575 tx_ant = tx_ant & rdev->wiphy.available_antennas_tx; in nl80211_set_wiphy()
3576 rx_ant = rx_ant & rdev->wiphy.available_antennas_rx; in nl80211_set_wiphy()
3585 if (info->attrs[NL80211_ATTR_WIPHY_RETRY_SHORT]) { in nl80211_set_wiphy()
3587 info->attrs[NL80211_ATTR_WIPHY_RETRY_SHORT]); in nl80211_set_wiphy()
3592 if (info->attrs[NL80211_ATTR_WIPHY_RETRY_LONG]) { in nl80211_set_wiphy()
3594 info->attrs[NL80211_ATTR_WIPHY_RETRY_LONG]); in nl80211_set_wiphy()
3599 if (info->attrs[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]) { in nl80211_set_wiphy()
3601 info->attrs[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]); in nl80211_set_wiphy()
3603 result = -EINVAL; in nl80211_set_wiphy()
3607 if (frag_threshold != (u32) -1) { in nl80211_set_wiphy()
3619 if (info->attrs[NL80211_ATTR_WIPHY_RTS_THRESHOLD]) { in nl80211_set_wiphy()
3621 info->attrs[NL80211_ATTR_WIPHY_RTS_THRESHOLD]); in nl80211_set_wiphy()
3625 if (info->attrs[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) { in nl80211_set_wiphy()
3626 if (info->attrs[NL80211_ATTR_WIPHY_DYN_ACK]) { in nl80211_set_wiphy()
3627 result = -EINVAL; in nl80211_set_wiphy()
3632 info->attrs[NL80211_ATTR_WIPHY_COVERAGE_CLASS]); in nl80211_set_wiphy()
3636 if (info->attrs[NL80211_ATTR_WIPHY_DYN_ACK]) { in nl80211_set_wiphy()
3637 if (!(rdev->wiphy.features & NL80211_FEATURE_ACKTO_ESTIMATION)) { in nl80211_set_wiphy()
3638 result = -EOPNOTSUPP; in nl80211_set_wiphy()
3645 if (info->attrs[NL80211_ATTR_TXQ_LIMIT]) { in nl80211_set_wiphy()
3646 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_set_wiphy()
3648 result = -EOPNOTSUPP; in nl80211_set_wiphy()
3652 info->attrs[NL80211_ATTR_TXQ_LIMIT]); in nl80211_set_wiphy()
3656 if (info->attrs[NL80211_ATTR_TXQ_MEMORY_LIMIT]) { in nl80211_set_wiphy()
3657 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_set_wiphy()
3659 result = -EOPNOTSUPP; in nl80211_set_wiphy()
3663 info->attrs[NL80211_ATTR_TXQ_MEMORY_LIMIT]); in nl80211_set_wiphy()
3667 if (info->attrs[NL80211_ATTR_TXQ_QUANTUM]) { in nl80211_set_wiphy()
3668 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_set_wiphy()
3670 result = -EOPNOTSUPP; in nl80211_set_wiphy()
3674 info->attrs[NL80211_ATTR_TXQ_QUANTUM]); in nl80211_set_wiphy()
3684 if (!rdev->ops->set_wiphy_params) { in nl80211_set_wiphy()
3685 result = -EOPNOTSUPP; in nl80211_set_wiphy()
3689 old_retry_short = rdev->wiphy.retry_short; in nl80211_set_wiphy()
3690 old_retry_long = rdev->wiphy.retry_long; in nl80211_set_wiphy()
3691 old_frag_threshold = rdev->wiphy.frag_threshold; in nl80211_set_wiphy()
3692 old_rts_threshold = rdev->wiphy.rts_threshold; in nl80211_set_wiphy()
3693 old_coverage_class = rdev->wiphy.coverage_class; in nl80211_set_wiphy()
3694 old_txq_limit = rdev->wiphy.txq_limit; in nl80211_set_wiphy()
3695 old_txq_memory_limit = rdev->wiphy.txq_memory_limit; in nl80211_set_wiphy()
3696 old_txq_quantum = rdev->wiphy.txq_quantum; in nl80211_set_wiphy()
3699 rdev->wiphy.retry_short = retry_short; in nl80211_set_wiphy()
3701 rdev->wiphy.retry_long = retry_long; in nl80211_set_wiphy()
3703 rdev->wiphy.frag_threshold = frag_threshold; in nl80211_set_wiphy()
3705 rdev->wiphy.rts_threshold = rts_threshold; in nl80211_set_wiphy()
3707 rdev->wiphy.coverage_class = coverage_class; in nl80211_set_wiphy()
3709 rdev->wiphy.txq_limit = txq_limit; in nl80211_set_wiphy()
3711 rdev->wiphy.txq_memory_limit = txq_memory_limit; in nl80211_set_wiphy()
3713 rdev->wiphy.txq_quantum = txq_quantum; in nl80211_set_wiphy()
3717 rdev->wiphy.retry_short = old_retry_short; in nl80211_set_wiphy()
3718 rdev->wiphy.retry_long = old_retry_long; in nl80211_set_wiphy()
3719 rdev->wiphy.frag_threshold = old_frag_threshold; in nl80211_set_wiphy()
3720 rdev->wiphy.rts_threshold = old_rts_threshold; in nl80211_set_wiphy()
3721 rdev->wiphy.coverage_class = old_coverage_class; in nl80211_set_wiphy()
3722 rdev->wiphy.txq_limit = old_txq_limit; in nl80211_set_wiphy()
3723 rdev->wiphy.txq_memory_limit = old_txq_memory_limit; in nl80211_set_wiphy()
3724 rdev->wiphy.txq_quantum = old_txq_quantum; in nl80211_set_wiphy()
3732 wiphy_unlock(&rdev->wiphy); in nl80211_set_wiphy()
3740 return -EINVAL; in nl80211_send_chandef()
3743 chandef->chan->center_freq)) in nl80211_send_chandef()
3744 return -ENOBUFS; in nl80211_send_chandef()
3746 chandef->chan->freq_offset)) in nl80211_send_chandef()
3747 return -ENOBUFS; in nl80211_send_chandef()
3748 switch (chandef->width) { in nl80211_send_chandef()
3754 return -ENOBUFS; in nl80211_send_chandef()
3759 if (nla_put_u32(msg, NL80211_ATTR_CHANNEL_WIDTH, chandef->width)) in nl80211_send_chandef()
3760 return -ENOBUFS; in nl80211_send_chandef()
3761 if (nla_put_u32(msg, NL80211_ATTR_CENTER_FREQ1, chandef->center_freq1)) in nl80211_send_chandef()
3762 return -ENOBUFS; in nl80211_send_chandef()
3763 if (chandef->center_freq2 && in nl80211_send_chandef()
3764 nla_put_u32(msg, NL80211_ATTR_CENTER_FREQ2, chandef->center_freq2)) in nl80211_send_chandef()
3765 return -ENOBUFS; in nl80211_send_chandef()
3774 struct net_device *dev = wdev->netdev; in nl80211_send_iface()
3783 return -1; in nl80211_send_iface()
3786 (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || in nl80211_send_iface()
3787 nla_put_string(msg, NL80211_ATTR_IFNAME, dev->name))) in nl80211_send_iface()
3790 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_send_iface()
3791 nla_put_u32(msg, NL80211_ATTR_IFTYPE, wdev->iftype) || in nl80211_send_iface()
3796 rdev->devlist_generation ^ in nl80211_send_iface()
3798 nla_put_u8(msg, NL80211_ATTR_4ADDR, wdev->use_4addr)) in nl80211_send_iface()
3801 if (rdev->ops->get_channel && !wdev->valid_links) { in nl80211_send_iface()
3810 if (rdev->ops->get_tx_power) { in nl80211_send_iface()
3821 switch (wdev->iftype) { in nl80211_send_iface()
3824 if (wdev->u.ap.ssid_len && in nl80211_send_iface()
3825 nla_put(msg, NL80211_ATTR_SSID, wdev->u.ap.ssid_len, in nl80211_send_iface()
3826 wdev->u.ap.ssid)) in nl80211_send_iface()
3831 if (wdev->u.client.ssid_len && in nl80211_send_iface()
3832 nla_put(msg, NL80211_ATTR_SSID, wdev->u.client.ssid_len, in nl80211_send_iface()
3833 wdev->u.client.ssid)) in nl80211_send_iface()
3837 if (wdev->u.ibss.ssid_len && in nl80211_send_iface()
3838 nla_put(msg, NL80211_ATTR_SSID, wdev->u.ibss.ssid_len, in nl80211_send_iface()
3839 wdev->u.ibss.ssid)) in nl80211_send_iface()
3848 if (rdev->ops->get_txq_stats) { in nl80211_send_iface()
3858 if (wdev->valid_links) { in nl80211_send_iface()
3874 wdev->links[link_id].addr)) in nl80211_send_iface()
3894 return -EMSGSIZE; in nl80211_send_iface()
3901 int wp_start = cb->args[0]; in nl80211_dump_interface()
3902 int if_start = cb->args[1]; in nl80211_dump_interface()
3903 int filter_wiphy = -1; in nl80211_dump_interface()
3909 if (!cb->args[2]) { in nl80211_dump_interface()
3911 .filter_wiphy = -1, in nl80211_dump_interface()
3921 * if filtering, set cb->args[2] to +1 since 0 is the default in nl80211_dump_interface()
3925 cb->args[2] = filter_wiphy + 1; in nl80211_dump_interface()
3927 cb->args[2] = -1; in nl80211_dump_interface()
3928 } else if (cb->args[2] > 0) { in nl80211_dump_interface()
3929 filter_wiphy = cb->args[2] - 1; in nl80211_dump_interface()
3933 if (!net_eq(wiphy_net(&rdev->wiphy), sock_net(skb->sk))) in nl80211_dump_interface()
3940 if (filter_wiphy >= 0 && filter_wiphy != rdev->wiphy_idx) in nl80211_dump_interface()
3945 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in nl80211_dump_interface()
3950 if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).portid, in nl80211_dump_interface()
3951 cb->nlh->nlmsg_seq, NLM_F_MULTI, in nl80211_dump_interface()
3962 cb->args[0] = wp_idx; in nl80211_dump_interface()
3963 cb->args[1] = if_idx; in nl80211_dump_interface()
3965 ret = skb->len; in nl80211_dump_interface()
3975 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_get_interface()
3976 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_get_interface()
3980 return -ENOMEM; in nl80211_get_interface()
3982 if (nl80211_send_iface(msg, info->snd_portid, info->snd_seq, 0, in nl80211_get_interface()
3985 return -ENOBUFS; in nl80211_get_interface()
4008 return -EINVAL; in parse_monitor_flags()
4011 return -EINVAL; in parse_monitor_flags()
4030 if (info->attrs[NL80211_ATTR_MNTR_FLAGS]) { in nl80211_parse_mon_options()
4032 return -EINVAL; in nl80211_parse_mon_options()
4034 err = parse_monitor_flags(info->attrs[NL80211_ATTR_MNTR_FLAGS], in nl80211_parse_mon_options()
4035 &params->flags); in nl80211_parse_mon_options()
4042 if (params->flags & MONITOR_FLAG_ACTIVE && in nl80211_parse_mon_options()
4043 !(rdev->wiphy.features & NL80211_FEATURE_ACTIVE_MONITOR)) in nl80211_parse_mon_options()
4044 return -EOPNOTSUPP; in nl80211_parse_mon_options()
4046 if (info->attrs[NL80211_ATTR_MU_MIMO_GROUP_DATA]) { in nl80211_parse_mon_options()
4051 return -EINVAL; in nl80211_parse_mon_options()
4053 if (!wiphy_ext_feature_isset(&rdev->wiphy, cap_flag)) in nl80211_parse_mon_options()
4054 return -EOPNOTSUPP; in nl80211_parse_mon_options()
4057 nla_data(info->attrs[NL80211_ATTR_MU_MIMO_GROUP_DATA]); in nl80211_parse_mon_options()
4061 (mumimo_groups[VHT_MUMIMO_GROUPS_DATA_LEN - 1] & BIT(7))) in nl80211_parse_mon_options()
4062 return -EINVAL; in nl80211_parse_mon_options()
4064 params->vht_mumimo_groups = mumimo_groups; in nl80211_parse_mon_options()
4068 if (info->attrs[NL80211_ATTR_MU_MIMO_FOLLOW_MAC_ADDR]) { in nl80211_parse_mon_options()
4072 return -EINVAL; in nl80211_parse_mon_options()
4074 if (!wiphy_ext_feature_isset(&rdev->wiphy, cap_flag)) in nl80211_parse_mon_options()
4075 return -EOPNOTSUPP; in nl80211_parse_mon_options()
4077 params->vht_mumimo_follow_addr = in nl80211_parse_mon_options()
4078 nla_data(info->attrs[NL80211_ATTR_MU_MIMO_FOLLOW_MAC_ADDR]); in nl80211_parse_mon_options()
4091 return -EBUSY; in nl80211_valid_4addr()
4097 if (rdev->wiphy.flags & WIPHY_FLAG_4ADDR_AP) in nl80211_valid_4addr()
4101 if (rdev->wiphy.flags & WIPHY_FLAG_4ADDR_STATION) in nl80211_valid_4addr()
4108 return -EOPNOTSUPP; in nl80211_valid_4addr()
4113 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_interface()
4117 struct net_device *dev = info->user_ptr[1]; in nl80211_set_interface()
4122 otype = ntype = dev->ieee80211_ptr->iftype; in nl80211_set_interface()
4124 if (info->attrs[NL80211_ATTR_IFTYPE]) { in nl80211_set_interface()
4125 ntype = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]); in nl80211_set_interface()
4130 if (info->attrs[NL80211_ATTR_MESH_ID]) { in nl80211_set_interface()
4131 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_set_interface()
4134 return -EINVAL; in nl80211_set_interface()
4136 return -EBUSY; in nl80211_set_interface()
4141 wdev->u.mesh.id_up_len = in nl80211_set_interface()
4142 nla_len(info->attrs[NL80211_ATTR_MESH_ID]); in nl80211_set_interface()
4143 memcpy(wdev->u.mesh.id, in nl80211_set_interface()
4144 nla_data(info->attrs[NL80211_ATTR_MESH_ID]), in nl80211_set_interface()
4145 wdev->u.mesh.id_up_len); in nl80211_set_interface()
4149 if (info->attrs[NL80211_ATTR_4ADDR]) { in nl80211_set_interface()
4150 params.use_4addr = !!nla_get_u8(info->attrs[NL80211_ATTR_4ADDR]); in nl80211_set_interface()
4156 params.use_4addr = -1; in nl80211_set_interface()
4170 if (!err && params.use_4addr != -1) in nl80211_set_interface()
4171 dev->ieee80211_ptr->use_4addr = params.use_4addr; in nl80211_set_interface()
4174 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_set_interface()
4184 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in _nl80211_new_interface()
4193 if (!info->attrs[NL80211_ATTR_IFNAME]) in _nl80211_new_interface()
4194 return -EINVAL; in _nl80211_new_interface()
4196 if (info->attrs[NL80211_ATTR_IFTYPE]) in _nl80211_new_interface()
4197 type = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]); in _nl80211_new_interface()
4199 if (!rdev->ops->add_virtual_intf) in _nl80211_new_interface()
4200 return -EOPNOTSUPP; in _nl80211_new_interface()
4203 rdev->wiphy.features & NL80211_FEATURE_MAC_ON_CREATE) && in _nl80211_new_interface()
4204 info->attrs[NL80211_ATTR_MAC]) { in _nl80211_new_interface()
4205 nla_memcpy(params.macaddr, info->attrs[NL80211_ATTR_MAC], in _nl80211_new_interface()
4208 return -EADDRNOTAVAIL; in _nl80211_new_interface()
4211 if (info->attrs[NL80211_ATTR_4ADDR]) { in _nl80211_new_interface()
4212 params.use_4addr = !!nla_get_u8(info->attrs[NL80211_ATTR_4ADDR]); in _nl80211_new_interface()
4218 if (!cfg80211_iftype_allowed(&rdev->wiphy, type, params.use_4addr, 0)) in _nl80211_new_interface()
4219 return -EOPNOTSUPP; in _nl80211_new_interface()
4227 return -ENOMEM; in _nl80211_new_interface()
4230 nla_data(info->attrs[NL80211_ATTR_IFNAME]), in _nl80211_new_interface()
4234 return -EPROTO; in _nl80211_new_interface()
4240 if (info->attrs[NL80211_ATTR_SOCKET_OWNER]) in _nl80211_new_interface()
4241 wdev->owner_nlportid = info->snd_portid; in _nl80211_new_interface()
4245 if (!info->attrs[NL80211_ATTR_MESH_ID]) in _nl80211_new_interface()
4250 wdev->u.mesh.id_up_len = in _nl80211_new_interface()
4251 nla_len(info->attrs[NL80211_ATTR_MESH_ID]); in _nl80211_new_interface()
4252 memcpy(wdev->u.mesh.id, in _nl80211_new_interface()
4253 nla_data(info->attrs[NL80211_ATTR_MESH_ID]), in _nl80211_new_interface()
4254 wdev->u.mesh.id_up_len); in _nl80211_new_interface()
4270 if (nl80211_send_iface(msg, info->snd_portid, info->snd_seq, 0, in _nl80211_new_interface()
4273 return -ENOBUFS; in _nl80211_new_interface()
4281 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_new_interface()
4287 wiphy_lock(&rdev->wiphy); in nl80211_new_interface()
4289 wiphy_unlock(&rdev->wiphy); in nl80211_new_interface()
4296 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_del_interface()
4297 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_del_interface()
4299 if (!rdev->ops->del_virtual_intf) in nl80211_del_interface()
4300 return -EOPNOTSUPP; in nl80211_del_interface()
4311 mutex_unlock(&rdev->wiphy.mtx); in nl80211_del_interface()
4320 if (!wdev->netdev) in nl80211_del_interface()
4321 info->user_ptr[1] = NULL; in nl80211_del_interface()
4323 dev_close(wdev->netdev); in nl80211_del_interface()
4325 mutex_lock(&rdev->wiphy.mtx); in nl80211_del_interface()
4332 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_noack_map()
4333 struct net_device *dev = info->user_ptr[1]; in nl80211_set_noack_map()
4336 if (!info->attrs[NL80211_ATTR_NOACK_MAP]) in nl80211_set_noack_map()
4337 return -EINVAL; in nl80211_set_noack_map()
4339 if (!rdev->ops->set_noack_map) in nl80211_set_noack_map()
4340 return -EOPNOTSUPP; in nl80211_set_noack_map()
4342 noack_map = nla_get_u16(info->attrs[NL80211_ATTR_NOACK_MAP]); in nl80211_set_noack_map()
4352 if (link_id != -1) { in nl80211_validate_key_link_id()
4355 return -EINVAL; in nl80211_validate_key_link_id()
4361 if (wdev->valid_links) { in nl80211_validate_key_link_id()
4362 if (link_id == -1) { in nl80211_validate_key_link_id()
4365 return -EINVAL; in nl80211_validate_key_link_id()
4367 if (!(wdev->valid_links & BIT(link_id))) { in nl80211_validate_key_link_id()
4369 return -EINVAL; in nl80211_validate_key_link_id()
4371 } else if (link_id != -1) { in nl80211_validate_key_link_id()
4372 GENL_SET_ERR_MSG(info, "link ID not allowed for non-MLO group key"); in nl80211_validate_key_link_id()
4373 return -EINVAL; in nl80211_validate_key_link_id()
4390 if ((params->key && in get_key_callback()
4391 nla_put(cookie->msg, NL80211_ATTR_KEY_DATA, in get_key_callback()
4392 params->key_len, params->key)) || in get_key_callback()
4393 (params->seq && in get_key_callback()
4394 nla_put(cookie->msg, NL80211_ATTR_KEY_SEQ, in get_key_callback()
4395 params->seq_len, params->seq)) || in get_key_callback()
4396 (params->cipher && in get_key_callback()
4397 nla_put_u32(cookie->msg, NL80211_ATTR_KEY_CIPHER, in get_key_callback()
4398 params->cipher))) in get_key_callback()
4401 key = nla_nest_start_noflag(cookie->msg, NL80211_ATTR_KEY); in get_key_callback()
4405 if ((params->key && in get_key_callback()
4406 nla_put(cookie->msg, NL80211_KEY_DATA, in get_key_callback()
4407 params->key_len, params->key)) || in get_key_callback()
4408 (params->seq && in get_key_callback()
4409 nla_put(cookie->msg, NL80211_KEY_SEQ, in get_key_callback()
4410 params->seq_len, params->seq)) || in get_key_callback()
4411 (params->cipher && in get_key_callback()
4412 nla_put_u32(cookie->msg, NL80211_KEY_CIPHER, in get_key_callback()
4413 params->cipher))) in get_key_callback()
4416 if (nla_put_u8(cookie->msg, NL80211_KEY_IDX, cookie->idx)) in get_key_callback()
4419 nla_nest_end(cookie->msg, key); in get_key_callback()
4423 cookie->error = 1; in get_key_callback()
4428 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_get_key()
4430 struct net_device *dev = info->user_ptr[1]; in nl80211_get_key()
4440 int link_id = nl80211_link_id_or_invalid(info->attrs); in nl80211_get_key()
4441 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_get_key()
4443 if (wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_get_key()
4447 if ((wdev->iftype == NL80211_IFTYPE_STATION || in nl80211_get_key()
4448 wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) && in nl80211_get_key()
4449 wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_get_key()
4453 if (info->attrs[NL80211_ATTR_KEY_IDX]) { in nl80211_get_key()
4454 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]); in nl80211_get_key()
4458 return -EINVAL; in nl80211_get_key()
4462 if (info->attrs[NL80211_ATTR_MAC]) in nl80211_get_key()
4463 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_get_key()
4466 if (info->attrs[NL80211_ATTR_KEY_TYPE]) { in nl80211_get_key()
4467 u32 kt = nla_get_u32(info->attrs[NL80211_ATTR_KEY_TYPE]); in nl80211_get_key()
4471 return -EINVAL; in nl80211_get_key()
4475 if (!rdev->ops->get_key) in nl80211_get_key()
4476 return -EOPNOTSUPP; in nl80211_get_key()
4478 if (!pairwise && mac_addr && !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) in nl80211_get_key()
4479 return -ENOENT; in nl80211_get_key()
4483 return -ENOMEM; in nl80211_get_key()
4485 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, in nl80211_get_key()
4493 if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || in nl80211_get_key()
4517 err = -ENOBUFS; in nl80211_get_key()
4525 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_key()
4528 struct net_device *dev = info->user_ptr[1]; in nl80211_set_key()
4529 int link_id = nl80211_link_id_or_invalid(info->attrs); in nl80211_set_key()
4530 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_set_key()
4537 return -EINVAL; in nl80211_set_key()
4544 return -EINVAL; in nl80211_set_key()
4549 if (!rdev->ops->set_default_key) { in nl80211_set_key()
4550 err = -EOPNOTSUPP; in nl80211_set_key()
4569 wdev->wext.default_key = key.idx; in nl80211_set_key()
4573 err = -EINVAL; in nl80211_set_key()
4577 if (!rdev->ops->set_default_mgmt_key) { in nl80211_set_key()
4578 err = -EOPNOTSUPP; in nl80211_set_key()
4595 wdev->wext.default_mgmt_key = key.idx; in nl80211_set_key()
4599 err = -EINVAL; in nl80211_set_key()
4603 if (!rdev->ops->set_default_beacon_key) { in nl80211_set_key()
4604 err = -EOPNOTSUPP; in nl80211_set_key()
4620 wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_set_key()
4624 if (info->attrs[NL80211_ATTR_MAC]) in nl80211_set_key()
4625 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_set_key()
4628 err = -EINVAL; in nl80211_set_key()
4640 err = -EINVAL; in nl80211_set_key()
4650 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_new_key()
4652 struct net_device *dev = info->user_ptr[1]; in nl80211_new_key()
4655 int link_id = nl80211_link_id_or_invalid(info->attrs); in nl80211_new_key()
4656 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_new_key()
4664 return -EINVAL; in nl80211_new_key()
4667 if (info->attrs[NL80211_ATTR_MAC]) in nl80211_new_key()
4668 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_new_key()
4670 if (key.type == -1) { in nl80211_new_key()
4681 return -EINVAL; in nl80211_new_key()
4685 info->attrs[NL80211_ATTR_VLAN_ID]) in nl80211_new_key()
4686 key.p.vlan_id = nla_get_u16(info->attrs[NL80211_ATTR_VLAN_ID]); in nl80211_new_key()
4688 if (!rdev->ops->add_key) in nl80211_new_key()
4689 return -EOPNOTSUPP; in nl80211_new_key()
4695 return -EINVAL; in nl80211_new_key()
4721 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_del_key()
4723 struct net_device *dev = info->user_ptr[1]; in nl80211_del_key()
4726 int link_id = nl80211_link_id_or_invalid(info->attrs); in nl80211_del_key()
4727 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_del_key()
4733 if (info->attrs[NL80211_ATTR_MAC]) in nl80211_del_key()
4734 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_del_key()
4736 if (key.type == -1) { in nl80211_del_key()
4746 return -EINVAL; in nl80211_del_key()
4750 return -EINVAL; in nl80211_del_key()
4752 if (!rdev->ops->del_key) in nl80211_del_key()
4753 return -EOPNOTSUPP; in nl80211_del_key()
4759 !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) in nl80211_del_key()
4760 err = -ENOENT; in nl80211_del_key()
4773 if (key.idx == wdev->wext.default_key) in nl80211_del_key()
4774 wdev->wext.default_key = -1; in nl80211_del_key()
4775 else if (key.idx == wdev->wext.default_mgmt_key) in nl80211_del_key()
4776 wdev->wext.default_mgmt_key = -1; in nl80211_del_key()
4792 return -EINVAL; in validate_acl_mac_addrs()
4813 if (!wiphy->max_acl_mac_addrs) in parse_acl_data()
4814 return ERR_PTR(-EOPNOTSUPP); in parse_acl_data()
4816 if (!info->attrs[NL80211_ATTR_ACL_POLICY]) in parse_acl_data()
4817 return ERR_PTR(-EINVAL); in parse_acl_data()
4819 acl_policy = nla_get_u32(info->attrs[NL80211_ATTR_ACL_POLICY]); in parse_acl_data()
4822 return ERR_PTR(-EINVAL); in parse_acl_data()
4824 if (!info->attrs[NL80211_ATTR_MAC_ADDRS]) in parse_acl_data()
4825 return ERR_PTR(-EINVAL); in parse_acl_data()
4827 n_entries = validate_acl_mac_addrs(info->attrs[NL80211_ATTR_MAC_ADDRS]); in parse_acl_data()
4831 if (n_entries > wiphy->max_acl_mac_addrs) in parse_acl_data()
4832 return ERR_PTR(-ENOTSUPP); in parse_acl_data()
4836 return ERR_PTR(-ENOMEM); in parse_acl_data()
4838 nla_for_each_nested(attr, info->attrs[NL80211_ATTR_MAC_ADDRS], tmp) { in parse_acl_data()
4839 memcpy(acl->mac_addrs[i].addr, nla_data(attr), ETH_ALEN); in parse_acl_data()
4843 acl->n_acl_entries = n_entries; in parse_acl_data()
4844 acl->acl_policy = acl_policy; in parse_acl_data()
4851 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_mac_acl()
4852 struct net_device *dev = info->user_ptr[1]; in nl80211_set_mac_acl()
4856 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && in nl80211_set_mac_acl()
4857 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) in nl80211_set_mac_acl()
4858 return -EOPNOTSUPP; in nl80211_set_mac_acl()
4860 if (!dev->ieee80211_ptr->links[0].ap.beacon_interval) in nl80211_set_mac_acl()
4861 return -EINVAL; in nl80211_set_mac_acl()
4863 acl = parse_acl_data(&rdev->wiphy, info); in nl80211_set_mac_acl()
4884 for (ridx = 0; ridx < sband->n_bitrates; ridx++) { in rateset_to_mask()
4886 &sband->bitrates[ridx]; in rateset_to_mask()
4887 if (rate == srate->bitrate) { in rateset_to_mask()
4892 if (ridx == sband->n_bitrates) in rateset_to_mask()
4919 if (sband->ht_cap.mcs.rx_mask[ridx] & rbit) in ht_rateset_to_mask()
4966 u16 tx_mcs_map = le16_to_cpu(sband->vht_cap.vht_mcs.tx_mcs_map); in vht_set_mcs_mask()
4970 if (!sband->vht_cap.vht_supported) in vht_set_mcs_mask()
4979 if ((tx_mcs_mask[i] & txrate->mcs[i]) == txrate->mcs[i]) in vht_set_mcs_mask()
4980 mcs[i] = txrate->mcs[i]; in vht_set_mcs_mask()
5019 struct net_device *dev = info->user_ptr[1]; in he_get_txmcsmap()
5020 struct wireless_dev *wdev = dev->ieee80211_ptr; in he_get_txmcsmap()
5030 return le16_to_cpu(he_cap->he_mcs_nss_supp.tx_mcs_80); in he_get_txmcsmap()
5033 switch (chandef->width) { in he_get_txmcsmap()
5035 tx_mcs = he_cap->he_mcs_nss_supp.tx_mcs_80p80; in he_get_txmcsmap()
5038 tx_mcs = he_cap->he_mcs_nss_supp.tx_mcs_160; in he_get_txmcsmap()
5041 tx_mcs = he_cap->he_mcs_nss_supp.tx_mcs_80; in he_get_txmcsmap()
5060 he_cap = ieee80211_get_he_iftype_cap(sband, wdev->iftype); in he_set_mcs_mask()
5072 if ((tx_mcs_mask[i] & txrate->mcs[i]) == txrate->mcs[i]) in he_set_mcs_mask()
5073 mcs[i] = txrate->mcs[i]; in he_set_mcs_mask()
5090 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_parse_tx_bitrate_mask()
5091 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_parse_tx_bitrate_mask()
5105 sband = rdev->wiphy.bands[i]; in nl80211_parse_tx_bitrate_mask()
5110 mask->control[i].legacy = (1 << sband->n_bitrates) - 1; in nl80211_parse_tx_bitrate_mask()
5111 memcpy(mask->control[i].ht_mcs, in nl80211_parse_tx_bitrate_mask()
5112 sband->ht_cap.mcs.rx_mask, in nl80211_parse_tx_bitrate_mask()
5113 sizeof(mask->control[i].ht_mcs)); in nl80211_parse_tx_bitrate_mask()
5115 if (sband->vht_cap.vht_supported) { in nl80211_parse_tx_bitrate_mask()
5116 vht_tx_mcs_map = le16_to_cpu(sband->vht_cap.vht_mcs.tx_mcs_map); in nl80211_parse_tx_bitrate_mask()
5117 vht_build_mcs_mask(vht_tx_mcs_map, mask->control[i].vht_mcs); in nl80211_parse_tx_bitrate_mask()
5120 he_cap = ieee80211_get_he_iftype_cap(sband, wdev->iftype); in nl80211_parse_tx_bitrate_mask()
5125 he_build_mcs_mask(he_tx_mcs_map, mask->control[i].he_mcs); in nl80211_parse_tx_bitrate_mask()
5127 mask->control[i].he_gi = 0xFF; in nl80211_parse_tx_bitrate_mask()
5128 mask->control[i].he_ltf = 0xFF; in nl80211_parse_tx_bitrate_mask()
5144 return -EINVAL; in nl80211_parse_tx_bitrate_mask()
5145 sband = rdev->wiphy.bands[band]; in nl80211_parse_tx_bitrate_mask()
5147 return -EINVAL; in nl80211_parse_tx_bitrate_mask()
5151 info->extack); in nl80211_parse_tx_bitrate_mask()
5155 mask->control[band].legacy = rateset_to_mask( in nl80211_parse_tx_bitrate_mask()
5159 if ((mask->control[band].legacy == 0) && in nl80211_parse_tx_bitrate_mask()
5161 return -EINVAL; in nl80211_parse_tx_bitrate_mask()
5168 mask->control[band].ht_mcs)) in nl80211_parse_tx_bitrate_mask()
5169 return -EINVAL; in nl80211_parse_tx_bitrate_mask()
5176 mask->control[band].vht_mcs)) in nl80211_parse_tx_bitrate_mask()
5177 return -EINVAL; in nl80211_parse_tx_bitrate_mask()
5181 mask->control[band].gi = in nl80211_parse_tx_bitrate_mask()
5183 if (mask->control[band].gi > NL80211_TXRATE_FORCE_LGI) in nl80211_parse_tx_bitrate_mask()
5184 return -EINVAL; in nl80211_parse_tx_bitrate_mask()
5189 mask->control[band].he_mcs, in nl80211_parse_tx_bitrate_mask()
5191 return -EINVAL; in nl80211_parse_tx_bitrate_mask()
5194 mask->control[band].he_gi = in nl80211_parse_tx_bitrate_mask()
5197 mask->control[band].he_ltf = in nl80211_parse_tx_bitrate_mask()
5200 if (mask->control[band].legacy == 0) { in nl80211_parse_tx_bitrate_mask()
5204 if (!(rdev->wiphy.bands[band]->ht_cap.ht_supported || in nl80211_parse_tx_bitrate_mask()
5205 rdev->wiphy.bands[band]->vht_cap.vht_supported || in nl80211_parse_tx_bitrate_mask()
5206 ieee80211_get_he_iftype_cap(sband, wdev->iftype))) in nl80211_parse_tx_bitrate_mask()
5207 return -EINVAL; in nl80211_parse_tx_bitrate_mask()
5210 if (mask->control[band].ht_mcs[i]) in nl80211_parse_tx_bitrate_mask()
5214 if (mask->control[band].vht_mcs[i]) in nl80211_parse_tx_bitrate_mask()
5218 if (mask->control[band].he_mcs[i]) in nl80211_parse_tx_bitrate_mask()
5222 return -EINVAL; in nl80211_parse_tx_bitrate_mask()
5235 u32 rate = beacon_rate->control[band].legacy; in validate_beacon_tx_rate()
5239 return -EINVAL; in validate_beacon_tx_rate()
5243 if (hweight8(beacon_rate->control[band].ht_mcs[i]) > 1) { in validate_beacon_tx_rate()
5244 return -EINVAL; in validate_beacon_tx_rate()
5245 } else if (beacon_rate->control[band].ht_mcs[i]) { in validate_beacon_tx_rate()
5248 return -EINVAL; in validate_beacon_tx_rate()
5251 return -EINVAL; in validate_beacon_tx_rate()
5256 if (hweight16(beacon_rate->control[band].vht_mcs[i]) > 1) { in validate_beacon_tx_rate()
5257 return -EINVAL; in validate_beacon_tx_rate()
5258 } else if (beacon_rate->control[band].vht_mcs[i]) { in validate_beacon_tx_rate()
5261 return -EINVAL; in validate_beacon_tx_rate()
5264 return -EINVAL; in validate_beacon_tx_rate()
5269 if (hweight16(beacon_rate->control[band].he_mcs[i]) > 1) { in validate_beacon_tx_rate()
5270 return -EINVAL; in validate_beacon_tx_rate()
5271 } else if (beacon_rate->control[band].he_mcs[i]) { in validate_beacon_tx_rate()
5274 return -EINVAL; in validate_beacon_tx_rate()
5277 return -EINVAL; in validate_beacon_tx_rate()
5282 return -EINVAL; in validate_beacon_tx_rate()
5285 !wiphy_ext_feature_isset(&rdev->wiphy, in validate_beacon_tx_rate()
5287 return -EINVAL; in validate_beacon_tx_rate()
5289 !wiphy_ext_feature_isset(&rdev->wiphy, in validate_beacon_tx_rate()
5291 return -EINVAL; in validate_beacon_tx_rate()
5293 !wiphy_ext_feature_isset(&rdev->wiphy, in validate_beacon_tx_rate()
5295 return -EINVAL; in validate_beacon_tx_rate()
5297 !wiphy_ext_feature_isset(&rdev->wiphy, in validate_beacon_tx_rate()
5299 return -EINVAL; in validate_beacon_tx_rate()
5312 if (!wiphy->mbssid_max_interfaces) in nl80211_parse_mbssid_config()
5313 return -EOPNOTSUPP; in nl80211_parse_mbssid_config()
5318 return -EINVAL; in nl80211_parse_mbssid_config()
5320 config->ema = nla_get_flag(tb[NL80211_MBSSID_CONFIG_ATTR_EMA]); in nl80211_parse_mbssid_config()
5321 if (config->ema) { in nl80211_parse_mbssid_config()
5322 if (!wiphy->ema_max_profile_periodicity) in nl80211_parse_mbssid_config()
5323 return -EOPNOTSUPP; in nl80211_parse_mbssid_config()
5325 if (num_elems > wiphy->ema_max_profile_periodicity) in nl80211_parse_mbssid_config()
5326 return -EINVAL; in nl80211_parse_mbssid_config()
5329 config->index = nla_get_u8(tb[NL80211_MBSSID_CONFIG_ATTR_INDEX]); in nl80211_parse_mbssid_config()
5330 if (config->index >= wiphy->mbssid_max_interfaces || in nl80211_parse_mbssid_config()
5331 (!config->index && !num_elems)) in nl80211_parse_mbssid_config()
5332 return -EINVAL; in nl80211_parse_mbssid_config()
5338 if ((!config->index && tx_ifindex != dev->ifindex) || in nl80211_parse_mbssid_config()
5339 (config->index && tx_ifindex == dev->ifindex)) in nl80211_parse_mbssid_config()
5340 return -EINVAL; in nl80211_parse_mbssid_config()
5342 if (tx_ifindex != dev->ifindex) { in nl80211_parse_mbssid_config()
5346 if (!tx_netdev || !tx_netdev->ieee80211_ptr || in nl80211_parse_mbssid_config()
5347 tx_netdev->ieee80211_ptr->wiphy != wiphy || in nl80211_parse_mbssid_config()
5348 tx_netdev->ieee80211_ptr->iftype != in nl80211_parse_mbssid_config()
5351 return -EINVAL; in nl80211_parse_mbssid_config()
5354 config->tx_wdev = tx_netdev->ieee80211_ptr; in nl80211_parse_mbssid_config()
5356 config->tx_wdev = dev->ieee80211_ptr; in nl80211_parse_mbssid_config()
5358 } else if (!config->index) { in nl80211_parse_mbssid_config()
5359 config->tx_wdev = dev->ieee80211_ptr; in nl80211_parse_mbssid_config()
5361 return -EINVAL; in nl80211_parse_mbssid_config()
5375 if (!wiphy->mbssid_max_interfaces) in nl80211_parse_mbssid_elems()
5376 return ERR_PTR(-EINVAL); in nl80211_parse_mbssid_elems()
5383 return ERR_PTR(-ENOMEM); in nl80211_parse_mbssid_elems()
5386 elems->elem[i].data = nla_data(nl_elems); in nl80211_parse_mbssid_elems()
5387 elems->elem[i].len = nla_len(nl_elems); in nl80211_parse_mbssid_elems()
5390 elems->cnt = num_elems; in nl80211_parse_mbssid_elems()
5406 return -EINVAL; in nl80211_parse_he_bss_color()
5408 he_bss_color->color = in nl80211_parse_he_bss_color()
5410 he_bss_color->enabled = in nl80211_parse_he_bss_color()
5412 he_bss_color->partial = in nl80211_parse_he_bss_color()
5427 bcn->link_id = nl80211_link_id(attrs); in nl80211_parse_beacon()
5430 bcn->head = nla_data(attrs[NL80211_ATTR_BEACON_HEAD]); in nl80211_parse_beacon()
5431 bcn->head_len = nla_len(attrs[NL80211_ATTR_BEACON_HEAD]); in nl80211_parse_beacon()
5432 if (!bcn->head_len) in nl80211_parse_beacon()
5433 return -EINVAL; in nl80211_parse_beacon()
5438 bcn->tail = nla_data(attrs[NL80211_ATTR_BEACON_TAIL]); in nl80211_parse_beacon()
5439 bcn->tail_len = nla_len(attrs[NL80211_ATTR_BEACON_TAIL]); in nl80211_parse_beacon()
5444 return -EINVAL; in nl80211_parse_beacon()
5447 bcn->beacon_ies = nla_data(attrs[NL80211_ATTR_IE]); in nl80211_parse_beacon()
5448 bcn->beacon_ies_len = nla_len(attrs[NL80211_ATTR_IE]); in nl80211_parse_beacon()
5452 bcn->proberesp_ies = in nl80211_parse_beacon()
5454 bcn->proberesp_ies_len = in nl80211_parse_beacon()
5459 bcn->assocresp_ies = in nl80211_parse_beacon()
5461 bcn->assocresp_ies_len = in nl80211_parse_beacon()
5466 bcn->probe_resp = nla_data(attrs[NL80211_ATTR_PROBE_RESP]); in nl80211_parse_beacon()
5467 bcn->probe_resp_len = nla_len(attrs[NL80211_ATTR_PROBE_RESP]); in nl80211_parse_beacon()
5481 wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_parse_beacon()
5483 bcn->ftm_responder = 1; in nl80211_parse_beacon()
5485 return -EOPNOTSUPP; in nl80211_parse_beacon()
5488 bcn->lci = nla_data(tb[NL80211_FTM_RESP_ATTR_LCI]); in nl80211_parse_beacon()
5489 bcn->lci_len = nla_len(tb[NL80211_FTM_RESP_ATTR_LCI]); in nl80211_parse_beacon()
5493 bcn->civicloc = nla_data(tb[NL80211_FTM_RESP_ATTR_CIVICLOC]); in nl80211_parse_beacon()
5494 bcn->civicloc_len = nla_len(tb[NL80211_FTM_RESP_ATTR_CIVICLOC]); in nl80211_parse_beacon()
5497 bcn->ftm_responder = -1; in nl80211_parse_beacon()
5502 &bcn->he_bss_color); in nl80211_parse_beacon()
5505 bcn->he_bss_color_valid = true; in nl80211_parse_beacon()
5510 nl80211_parse_mbssid_elems(&rdev->wiphy, in nl80211_parse_beacon()
5516 bcn->mbssid_ies = mbssid; in nl80211_parse_beacon()
5534 return -EINVAL; in nl80211_parse_he_obss_pd()
5536 he_obss_pd->sr_ctrl = nla_get_u8(tb[NL80211_HE_OBSS_PD_ATTR_SR_CTRL]); in nl80211_parse_he_obss_pd()
5539 he_obss_pd->min_offset = in nl80211_parse_he_obss_pd()
5542 he_obss_pd->max_offset = in nl80211_parse_he_obss_pd()
5545 he_obss_pd->non_srg_max_offset = in nl80211_parse_he_obss_pd()
5548 if (he_obss_pd->min_offset > he_obss_pd->max_offset) in nl80211_parse_he_obss_pd()
5549 return -EINVAL; in nl80211_parse_he_obss_pd()
5552 memcpy(he_obss_pd->bss_color_bitmap, in nl80211_parse_he_obss_pd()
5554 sizeof(he_obss_pd->bss_color_bitmap)); in nl80211_parse_he_obss_pd()
5557 memcpy(he_obss_pd->partial_bssid_bitmap, in nl80211_parse_he_obss_pd()
5559 sizeof(he_obss_pd->partial_bssid_bitmap)); in nl80211_parse_he_obss_pd()
5561 he_obss_pd->enable = true; in nl80211_parse_he_obss_pd()
5572 struct cfg80211_fils_discovery *fd = &params->fils_discovery; in nl80211_parse_fils_discovery()
5574 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_parse_fils_discovery()
5576 return -EINVAL; in nl80211_parse_fils_discovery()
5586 return -EINVAL; in nl80211_parse_fils_discovery()
5588 fd->tmpl_len = nla_len(tb[NL80211_FILS_DISCOVERY_ATTR_TMPL]); in nl80211_parse_fils_discovery()
5589 fd->tmpl = nla_data(tb[NL80211_FILS_DISCOVERY_ATTR_TMPL]); in nl80211_parse_fils_discovery()
5590 fd->min_interval = nla_get_u32(tb[NL80211_FILS_DISCOVERY_ATTR_INT_MIN]); in nl80211_parse_fils_discovery()
5591 fd->max_interval = nla_get_u32(tb[NL80211_FILS_DISCOVERY_ATTR_INT_MAX]); in nl80211_parse_fils_discovery()
5604 &params->unsol_bcast_probe_resp; in nl80211_parse_unsol_bcast_probe_resp()
5606 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_parse_unsol_bcast_probe_resp()
5608 return -EINVAL; in nl80211_parse_unsol_bcast_probe_resp()
5617 return -EINVAL; in nl80211_parse_unsol_bcast_probe_resp()
5619 presp->tmpl = nla_data(tb[NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_TMPL]); in nl80211_parse_unsol_bcast_probe_resp()
5620 presp->tmpl_len = nla_len(tb[NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_TMPL]); in nl80211_parse_unsol_bcast_probe_resp()
5621 presp->interval = nla_get_u32(tb[NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INT]); in nl80211_parse_unsol_bcast_probe_resp()
5633 for (i = 0; i < rates->datalen; i++) { in nl80211_check_ap_rate_selectors()
5634 if (rates->data[i] == BSS_MEMBERSHIP_SELECTOR_HT_PHY) in nl80211_check_ap_rate_selectors()
5635 params->ht_required = true; in nl80211_check_ap_rate_selectors()
5636 if (rates->data[i] == BSS_MEMBERSHIP_SELECTOR_VHT_PHY) in nl80211_check_ap_rate_selectors()
5637 params->vht_required = true; in nl80211_check_ap_rate_selectors()
5638 if (rates->data[i] == BSS_MEMBERSHIP_SELECTOR_HE_PHY) in nl80211_check_ap_rate_selectors()
5639 params->he_required = true; in nl80211_check_ap_rate_selectors()
5640 if (rates->data[i] == BSS_MEMBERSHIP_SELECTOR_SAE_H2E) in nl80211_check_ap_rate_selectors()
5641 params->sae_h2e_required = true; in nl80211_check_ap_rate_selectors()
5652 const struct cfg80211_beacon_data *bcn = &params->beacon; in nl80211_calculate_ap_params()
5653 size_t ies_len = bcn->tail_len; in nl80211_calculate_ap_params()
5654 const u8 *ies = bcn->tail; in nl80211_calculate_ap_params()
5665 if (cap && cap->datalen >= sizeof(*params->ht_cap)) in nl80211_calculate_ap_params()
5666 params->ht_cap = (void *)cap->data; in nl80211_calculate_ap_params()
5668 if (cap && cap->datalen >= sizeof(*params->vht_cap)) in nl80211_calculate_ap_params()
5669 params->vht_cap = (void *)cap->data; in nl80211_calculate_ap_params()
5671 if (cap && cap->datalen >= sizeof(*params->he_cap) + 1) in nl80211_calculate_ap_params()
5672 params->he_cap = (void *)(cap->data + 1); in nl80211_calculate_ap_params()
5674 if (cap && cap->datalen >= sizeof(*params->he_oper) + 1) in nl80211_calculate_ap_params()
5675 params->he_oper = (void *)(cap->data + 1); in nl80211_calculate_ap_params()
5678 if (!cap->datalen) in nl80211_calculate_ap_params()
5679 return -EINVAL; in nl80211_calculate_ap_params()
5680 params->eht_cap = (void *)(cap->data + 1); in nl80211_calculate_ap_params()
5681 if (!ieee80211_eht_capa_size_ok((const u8 *)params->he_cap, in nl80211_calculate_ap_params()
5682 (const u8 *)params->eht_cap, in nl80211_calculate_ap_params()
5683 cap->datalen - 1, true)) in nl80211_calculate_ap_params()
5684 return -EINVAL; in nl80211_calculate_ap_params()
5688 if (!cap->datalen) in nl80211_calculate_ap_params()
5689 return -EINVAL; in nl80211_calculate_ap_params()
5690 params->eht_oper = (void *)(cap->data + 1); in nl80211_calculate_ap_params()
5691 if (!ieee80211_eht_oper_size_ok((const u8 *)params->eht_oper, in nl80211_calculate_ap_params()
5692 cap->datalen - 1)) in nl80211_calculate_ap_params()
5693 return -EINVAL; in nl80211_calculate_ap_params()
5703 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in nl80211_get_ap_channel()
5704 if (wdev->iftype != NL80211_IFTYPE_AP && in nl80211_get_ap_channel()
5705 wdev->iftype != NL80211_IFTYPE_P2P_GO) in nl80211_get_ap_channel()
5708 if (!wdev->u.ap.preset_chandef.chan) in nl80211_get_ap_channel()
5711 params->chandef = wdev->u.ap.preset_chandef; in nl80211_get_ap_channel()
5727 if (!(rdev->wiphy.features & NL80211_FEATURE_SAE) && in nl80211_valid_auth_type()
5730 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_valid_auth_type()
5738 if (!(rdev->wiphy.features & NL80211_FEATURE_SAE) && in nl80211_valid_auth_type()
5739 !wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_valid_auth_type()
5749 &rdev->wiphy, in nl80211_valid_auth_type()
5755 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_valid_auth_type()
5772 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_start_ap()
5773 unsigned int link_id = nl80211_link_id(info->attrs); in nl80211_start_ap()
5774 struct net_device *dev = info->user_ptr[1]; in nl80211_start_ap()
5775 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_start_ap()
5779 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && in nl80211_start_ap()
5780 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) in nl80211_start_ap()
5781 return -EOPNOTSUPP; in nl80211_start_ap()
5783 if (!rdev->ops->start_ap) in nl80211_start_ap()
5784 return -EOPNOTSUPP; in nl80211_start_ap()
5786 if (wdev->links[link_id].ap.beacon_interval) in nl80211_start_ap()
5787 return -EALREADY; in nl80211_start_ap()
5790 if (!info->attrs[NL80211_ATTR_BEACON_INTERVAL] || in nl80211_start_ap()
5791 !info->attrs[NL80211_ATTR_DTIM_PERIOD] || in nl80211_start_ap()
5792 !info->attrs[NL80211_ATTR_BEACON_HEAD]) in nl80211_start_ap()
5793 return -EINVAL; in nl80211_start_ap()
5797 return -ENOMEM; in nl80211_start_ap()
5799 err = nl80211_parse_beacon(rdev, info->attrs, &params->beacon); in nl80211_start_ap()
5803 params->beacon_interval = in nl80211_start_ap()
5804 nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]); in nl80211_start_ap()
5805 params->dtim_period = in nl80211_start_ap()
5806 nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]); in nl80211_start_ap()
5808 err = cfg80211_validate_beacon_int(rdev, dev->ieee80211_ptr->iftype, in nl80211_start_ap()
5809 params->beacon_interval); in nl80211_start_ap()
5818 * additional information -- drivers must check! in nl80211_start_ap()
5820 if (info->attrs[NL80211_ATTR_SSID]) { in nl80211_start_ap()
5821 params->ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); in nl80211_start_ap()
5822 params->ssid_len = in nl80211_start_ap()
5823 nla_len(info->attrs[NL80211_ATTR_SSID]); in nl80211_start_ap()
5824 if (params->ssid_len == 0) { in nl80211_start_ap()
5825 err = -EINVAL; in nl80211_start_ap()
5829 if (wdev->u.ap.ssid_len && in nl80211_start_ap()
5830 (wdev->u.ap.ssid_len != params->ssid_len || in nl80211_start_ap()
5831 memcmp(wdev->u.ap.ssid, params->ssid, params->ssid_len))) { in nl80211_start_ap()
5833 err = -EINVAL; in nl80211_start_ap()
5836 } else if (wdev->valid_links) { in nl80211_start_ap()
5838 err = -EINVAL; in nl80211_start_ap()
5842 if (info->attrs[NL80211_ATTR_HIDDEN_SSID]) in nl80211_start_ap()
5843 params->hidden_ssid = nla_get_u32( in nl80211_start_ap()
5844 info->attrs[NL80211_ATTR_HIDDEN_SSID]); in nl80211_start_ap()
5846 params->privacy = !!info->attrs[NL80211_ATTR_PRIVACY]; in nl80211_start_ap()
5848 if (info->attrs[NL80211_ATTR_AUTH_TYPE]) { in nl80211_start_ap()
5849 params->auth_type = nla_get_u32( in nl80211_start_ap()
5850 info->attrs[NL80211_ATTR_AUTH_TYPE]); in nl80211_start_ap()
5851 if (!nl80211_valid_auth_type(rdev, params->auth_type, in nl80211_start_ap()
5853 err = -EINVAL; in nl80211_start_ap()
5857 params->auth_type = NL80211_AUTHTYPE_AUTOMATIC; in nl80211_start_ap()
5859 err = nl80211_crypto_settings(rdev, info, &params->crypto, in nl80211_start_ap()
5864 if (info->attrs[NL80211_ATTR_INACTIVITY_TIMEOUT]) { in nl80211_start_ap()
5865 if (!(rdev->wiphy.features & NL80211_FEATURE_INACTIVITY_TIMER)) { in nl80211_start_ap()
5866 err = -EOPNOTSUPP; in nl80211_start_ap()
5869 params->inactivity_timeout = nla_get_u16( in nl80211_start_ap()
5870 info->attrs[NL80211_ATTR_INACTIVITY_TIMEOUT]); in nl80211_start_ap()
5873 if (info->attrs[NL80211_ATTR_P2P_CTWINDOW]) { in nl80211_start_ap()
5874 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) { in nl80211_start_ap()
5875 err = -EINVAL; in nl80211_start_ap()
5878 params->p2p_ctwindow = in nl80211_start_ap()
5879 nla_get_u8(info->attrs[NL80211_ATTR_P2P_CTWINDOW]); in nl80211_start_ap()
5880 if (params->p2p_ctwindow != 0 && in nl80211_start_ap()
5881 !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_CTWIN)) { in nl80211_start_ap()
5882 err = -EINVAL; in nl80211_start_ap()
5887 if (info->attrs[NL80211_ATTR_P2P_OPPPS]) { in nl80211_start_ap()
5890 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) { in nl80211_start_ap()
5891 err = -EINVAL; in nl80211_start_ap()
5894 tmp = nla_get_u8(info->attrs[NL80211_ATTR_P2P_OPPPS]); in nl80211_start_ap()
5895 params->p2p_opp_ps = tmp; in nl80211_start_ap()
5896 if (params->p2p_opp_ps != 0 && in nl80211_start_ap()
5897 !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_OPPPS)) { in nl80211_start_ap()
5898 err = -EINVAL; in nl80211_start_ap()
5903 if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { in nl80211_start_ap()
5904 err = nl80211_parse_chandef(rdev, info, &params->chandef); in nl80211_start_ap()
5907 } else if (wdev->valid_links) { in nl80211_start_ap()
5909 err = -EINVAL; in nl80211_start_ap()
5911 } else if (wdev->u.ap.preset_chandef.chan) { in nl80211_start_ap()
5912 params->chandef = wdev->u.ap.preset_chandef; in nl80211_start_ap()
5914 err = -EINVAL; in nl80211_start_ap()
5918 if (!cfg80211_reg_can_beacon_relax(&rdev->wiphy, &params->chandef, in nl80211_start_ap()
5919 wdev->iftype)) { in nl80211_start_ap()
5920 err = -EINVAL; in nl80211_start_ap()
5926 if (info->attrs[NL80211_ATTR_TX_RATES]) { in nl80211_start_ap()
5927 err = nl80211_parse_tx_bitrate_mask(info, info->attrs, in nl80211_start_ap()
5929 &params->beacon_rate, in nl80211_start_ap()
5934 err = validate_beacon_tx_rate(rdev, params->chandef.chan->band, in nl80211_start_ap()
5935 &params->beacon_rate); in nl80211_start_ap()
5940 if (info->attrs[NL80211_ATTR_SMPS_MODE]) { in nl80211_start_ap()
5941 params->smps_mode = in nl80211_start_ap()
5942 nla_get_u8(info->attrs[NL80211_ATTR_SMPS_MODE]); in nl80211_start_ap()
5943 switch (params->smps_mode) { in nl80211_start_ap()
5947 if (!(rdev->wiphy.features & in nl80211_start_ap()
5949 err = -EINVAL; in nl80211_start_ap()
5954 if (!(rdev->wiphy.features & in nl80211_start_ap()
5956 err = -EINVAL; in nl80211_start_ap()
5961 err = -EINVAL; in nl80211_start_ap()
5965 params->smps_mode = NL80211_SMPS_OFF; in nl80211_start_ap()
5968 params->pbss = nla_get_flag(info->attrs[NL80211_ATTR_PBSS]); in nl80211_start_ap()
5969 if (params->pbss && !rdev->wiphy.bands[NL80211_BAND_60GHZ]) { in nl80211_start_ap()
5970 err = -EOPNOTSUPP; in nl80211_start_ap()
5974 if (info->attrs[NL80211_ATTR_ACL_POLICY]) { in nl80211_start_ap()
5975 params->acl = parse_acl_data(&rdev->wiphy, info); in nl80211_start_ap()
5976 if (IS_ERR(params->acl)) { in nl80211_start_ap()
5977 err = PTR_ERR(params->acl); in nl80211_start_ap()
5978 params->acl = NULL; in nl80211_start_ap()
5983 params->twt_responder = in nl80211_start_ap()
5984 nla_get_flag(info->attrs[NL80211_ATTR_TWT_RESPONDER]); in nl80211_start_ap()
5986 if (info->attrs[NL80211_ATTR_HE_OBSS_PD]) { in nl80211_start_ap()
5988 info->attrs[NL80211_ATTR_HE_OBSS_PD], in nl80211_start_ap()
5989 &params->he_obss_pd); in nl80211_start_ap()
5994 if (info->attrs[NL80211_ATTR_FILS_DISCOVERY]) { in nl80211_start_ap()
5996 info->attrs[NL80211_ATTR_FILS_DISCOVERY], in nl80211_start_ap()
6002 if (info->attrs[NL80211_ATTR_UNSOL_BCAST_PROBE_RESP]) { in nl80211_start_ap()
6004 rdev, info->attrs[NL80211_ATTR_UNSOL_BCAST_PROBE_RESP], in nl80211_start_ap()
6010 if (info->attrs[NL80211_ATTR_MBSSID_CONFIG]) { in nl80211_start_ap()
6011 err = nl80211_parse_mbssid_config(&rdev->wiphy, dev, in nl80211_start_ap()
6012 info->attrs[NL80211_ATTR_MBSSID_CONFIG], in nl80211_start_ap()
6013 &params->mbssid_config, in nl80211_start_ap()
6014 params->beacon.mbssid_ies ? in nl80211_start_ap()
6015 params->beacon.mbssid_ies->cnt : in nl80211_start_ap()
6025 if (info->attrs[NL80211_ATTR_AP_SETTINGS_FLAGS]) in nl80211_start_ap()
6026 params->flags = nla_get_u32( in nl80211_start_ap()
6027 info->attrs[NL80211_ATTR_AP_SETTINGS_FLAGS]); in nl80211_start_ap()
6028 else if (info->attrs[NL80211_ATTR_EXTERNAL_AUTH_SUPPORT]) in nl80211_start_ap()
6029 params->flags |= NL80211_AP_SETTINGS_EXTERNAL_AUTH_SUPPORT; in nl80211_start_ap()
6031 if (wdev->conn_owner_nlportid && in nl80211_start_ap()
6032 info->attrs[NL80211_ATTR_SOCKET_OWNER] && in nl80211_start_ap()
6033 wdev->conn_owner_nlportid != info->snd_portid) { in nl80211_start_ap()
6034 err = -EINVAL; in nl80211_start_ap()
6038 /* FIXME: validate MLO/link-id against driver capabilities */ in nl80211_start_ap()
6042 wdev->links[link_id].ap.beacon_interval = params->beacon_interval; in nl80211_start_ap()
6043 wdev->links[link_id].ap.chandef = params->chandef; in nl80211_start_ap()
6044 wdev->u.ap.ssid_len = params->ssid_len; in nl80211_start_ap()
6045 memcpy(wdev->u.ap.ssid, params->ssid, in nl80211_start_ap()
6046 params->ssid_len); in nl80211_start_ap()
6048 if (info->attrs[NL80211_ATTR_SOCKET_OWNER]) in nl80211_start_ap()
6049 wdev->conn_owner_nlportid = info->snd_portid; in nl80211_start_ap()
6054 kfree(params->acl); in nl80211_start_ap()
6055 kfree(params->beacon.mbssid_ies); in nl80211_start_ap()
6056 if (params->mbssid_config.tx_wdev && in nl80211_start_ap()
6057 params->mbssid_config.tx_wdev->netdev && in nl80211_start_ap()
6058 params->mbssid_config.tx_wdev->netdev != dev) in nl80211_start_ap()
6059 dev_put(params->mbssid_config.tx_wdev->netdev); in nl80211_start_ap()
6067 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_beacon()
6068 unsigned int link_id = nl80211_link_id(info->attrs); in nl80211_set_beacon()
6069 struct net_device *dev = info->user_ptr[1]; in nl80211_set_beacon()
6070 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_set_beacon()
6074 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && in nl80211_set_beacon()
6075 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) in nl80211_set_beacon()
6076 return -EOPNOTSUPP; in nl80211_set_beacon()
6078 if (!rdev->ops->change_beacon) in nl80211_set_beacon()
6079 return -EOPNOTSUPP; in nl80211_set_beacon()
6081 if (!wdev->links[link_id].ap.beacon_interval) in nl80211_set_beacon()
6082 return -EINVAL; in nl80211_set_beacon()
6084 err = nl80211_parse_beacon(rdev, info->attrs, &params); in nl80211_set_beacon()
6099 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_stop_ap()
6100 unsigned int link_id = nl80211_link_id(info->attrs); in nl80211_stop_ap()
6101 struct net_device *dev = info->user_ptr[1]; in nl80211_stop_ap()
6127 nla = info->attrs[NL80211_ATTR_STA_FLAGS2]; in parse_station_flags()
6132 params->sta_flags_mask = sta_flags->mask; in parse_station_flags()
6133 params->sta_flags_set = sta_flags->set; in parse_station_flags()
6134 params->sta_flags_set &= params->sta_flags_mask; in parse_station_flags()
6135 if ((params->sta_flags_mask | in parse_station_flags()
6136 params->sta_flags_set) & BIT(__NL80211_STA_FLAG_INVALID)) in parse_station_flags()
6137 return -EINVAL; in parse_station_flags()
6143 nla = info->attrs[NL80211_ATTR_STA_FLAGS]; in parse_station_flags()
6147 if (nla_parse_nested_deprecated(flags, NL80211_STA_FLAG_MAX, nla, sta_flags_policy, info->extack)) in parse_station_flags()
6148 return -EINVAL; in parse_station_flags()
6160 params->sta_flags_mask = BIT(NL80211_STA_FLAG_AUTHORIZED) | in parse_station_flags()
6167 params->sta_flags_mask = BIT(NL80211_STA_FLAG_AUTHORIZED) | in parse_station_flags()
6171 params->sta_flags_mask = BIT(NL80211_STA_FLAG_AUTHENTICATED) | in parse_station_flags()
6176 return -EINVAL; in parse_station_flags()
6181 params->sta_flags_set |= (1<<flag); in parse_station_flags()
6185 return -EINVAL; in parse_station_flags()
6205 /* report 16-bit bitrate only if we can */ in nl80211_put_sta_rate()
6214 switch (info->bw) { in nl80211_put_sta_rate()
6238 WARN_ON(!(info->flags & RATE_INFO_FLAGS_HE_MCS)); in nl80211_put_sta_rate()
6245 WARN_ON(!(info->flags & RATE_INFO_FLAGS_EHT_MCS)); in nl80211_put_sta_rate()
6252 if (info->flags & RATE_INFO_FLAGS_MCS) { in nl80211_put_sta_rate()
6253 if (nla_put_u8(msg, NL80211_RATE_INFO_MCS, info->mcs)) in nl80211_put_sta_rate()
6255 if (info->flags & RATE_INFO_FLAGS_SHORT_GI && in nl80211_put_sta_rate()
6258 } else if (info->flags & RATE_INFO_FLAGS_VHT_MCS) { in nl80211_put_sta_rate()
6259 if (nla_put_u8(msg, NL80211_RATE_INFO_VHT_MCS, info->mcs)) in nl80211_put_sta_rate()
6261 if (nla_put_u8(msg, NL80211_RATE_INFO_VHT_NSS, info->nss)) in nl80211_put_sta_rate()
6263 if (info->flags & RATE_INFO_FLAGS_SHORT_GI && in nl80211_put_sta_rate()
6266 } else if (info->flags & RATE_INFO_FLAGS_HE_MCS) { in nl80211_put_sta_rate()
6267 if (nla_put_u8(msg, NL80211_RATE_INFO_HE_MCS, info->mcs)) in nl80211_put_sta_rate()
6269 if (nla_put_u8(msg, NL80211_RATE_INFO_HE_NSS, info->nss)) in nl80211_put_sta_rate()
6271 if (nla_put_u8(msg, NL80211_RATE_INFO_HE_GI, info->he_gi)) in nl80211_put_sta_rate()
6273 if (nla_put_u8(msg, NL80211_RATE_INFO_HE_DCM, info->he_dcm)) in nl80211_put_sta_rate()
6275 if (info->bw == RATE_INFO_BW_HE_RU && in nl80211_put_sta_rate()
6277 info->he_ru_alloc)) in nl80211_put_sta_rate()
6279 } else if (info->flags & RATE_INFO_FLAGS_EHT_MCS) { in nl80211_put_sta_rate()
6280 if (nla_put_u8(msg, NL80211_RATE_INFO_EHT_MCS, info->mcs)) in nl80211_put_sta_rate()
6282 if (nla_put_u8(msg, NL80211_RATE_INFO_EHT_NSS, info->nss)) in nl80211_put_sta_rate()
6284 if (nla_put_u8(msg, NL80211_RATE_INFO_EHT_GI, info->eht_gi)) in nl80211_put_sta_rate()
6286 if (info->bw == RATE_INFO_BW_EHT_RU && in nl80211_put_sta_rate()
6288 info->eht_ru_alloc)) in nl80211_put_sta_rate()
6334 return -1; in nl80211_send_station()
6337 if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || in nl80211_send_station()
6339 nla_put_u32(msg, NL80211_ATTR_GENERATION, sinfo->generation)) in nl80211_send_station()
6348 if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_ ## attr) && \ in nl80211_send_station()
6350 sinfo->memb)) \ in nl80211_send_station()
6354 if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_ ## attr) && \ in nl80211_send_station()
6356 sinfo->memb, NL80211_STA_INFO_PAD)) \ in nl80211_send_station()
6364 if (sinfo->filled & (BIT_ULL(NL80211_STA_INFO_RX_BYTES) | in nl80211_send_station()
6367 (u32)sinfo->rx_bytes)) in nl80211_send_station()
6370 if (sinfo->filled & (BIT_ULL(NL80211_STA_INFO_TX_BYTES) | in nl80211_send_station()
6373 (u32)sinfo->tx_bytes)) in nl80211_send_station()
6384 if (wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_send_station()
6388 switch (rdev->wiphy.signal_type) { in nl80211_send_station()
6396 if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL)) { in nl80211_send_station()
6397 if (!nl80211_put_signal(msg, sinfo->chains, in nl80211_send_station()
6398 sinfo->chain_signal, in nl80211_send_station()
6402 if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG)) { in nl80211_send_station()
6403 if (!nl80211_put_signal(msg, sinfo->chains, in nl80211_send_station()
6404 sinfo->chain_signal_avg, in nl80211_send_station()
6408 if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE)) { in nl80211_send_station()
6409 if (!nl80211_put_sta_rate(msg, &sinfo->txrate, in nl80211_send_station()
6413 if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_BITRATE)) { in nl80211_send_station()
6414 if (!nl80211_put_sta_rate(msg, &sinfo->rxrate, in nl80211_send_station()
6432 if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_BSS_PARAM)) { in nl80211_send_station()
6438 if (((sinfo->bss_param.flags & BSS_PARAM_FLAGS_CTS_PROT) && in nl80211_send_station()
6440 ((sinfo->bss_param.flags & BSS_PARAM_FLAGS_SHORT_PREAMBLE) && in nl80211_send_station()
6442 ((sinfo->bss_param.flags & BSS_PARAM_FLAGS_SHORT_SLOT_TIME) && in nl80211_send_station()
6445 sinfo->bss_param.dtim_period) || in nl80211_send_station()
6447 sinfo->bss_param.beacon_interval)) in nl80211_send_station()
6452 if ((sinfo->filled & BIT_ULL(NL80211_STA_INFO_STA_FLAGS)) && in nl80211_send_station()
6455 &sinfo->sta_flags)) in nl80211_send_station()
6464 if (wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_send_station()
6473 if (sinfo->pertid) { in nl80211_send_station()
6486 tidstats = &sinfo->pertid[tid]; in nl80211_send_station()
6488 if (!tidstats->filled) in nl80211_send_station()
6496 if (tidstats->filled & BIT(NL80211_TID_STATS_ ## attr) && \ in nl80211_send_station()
6498 tidstats->memb, NL80211_TID_STATS_PAD)) \ in nl80211_send_station()
6508 if ((tidstats->filled & in nl80211_send_station()
6510 !nl80211_put_txq_stats(msg, &tidstats->txq_stats, in nl80211_send_station()
6522 if (sinfo->assoc_req_ies_len && in nl80211_send_station()
6523 nla_put(msg, NL80211_ATTR_IE, sinfo->assoc_req_ies_len, in nl80211_send_station()
6524 sinfo->assoc_req_ies)) in nl80211_send_station()
6534 return -EMSGSIZE; in nl80211_send_station()
6544 int sta_idx = cb->args[2]; in nl80211_dump_station()
6551 __acquire(&rdev->wiphy.mtx); in nl80211_dump_station()
6553 if (!wdev->netdev) { in nl80211_dump_station()
6554 err = -EINVAL; in nl80211_dump_station()
6558 if (!rdev->ops->dump_station) { in nl80211_dump_station()
6559 err = -EOPNOTSUPP; in nl80211_dump_station()
6565 err = rdev_dump_station(rdev, wdev->netdev, sta_idx, in nl80211_dump_station()
6567 if (err == -ENOENT) in nl80211_dump_station()
6573 NETLINK_CB(cb->skb).portid, in nl80211_dump_station()
6574 cb->nlh->nlmsg_seq, NLM_F_MULTI, in nl80211_dump_station()
6575 rdev, wdev->netdev, mac_addr, in nl80211_dump_station()
6583 cb->args[2] = sta_idx; in nl80211_dump_station()
6584 err = skb->len; in nl80211_dump_station()
6586 wiphy_unlock(&rdev->wiphy); in nl80211_dump_station()
6593 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_get_station()
6594 struct net_device *dev = info->user_ptr[1]; in nl80211_get_station()
6602 if (!info->attrs[NL80211_ATTR_MAC]) in nl80211_get_station()
6603 return -EINVAL; in nl80211_get_station()
6605 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_get_station()
6607 if (!rdev->ops->get_station) in nl80211_get_station()
6608 return -EOPNOTSUPP; in nl80211_get_station()
6617 return -ENOMEM; in nl80211_get_station()
6621 info->snd_portid, info->snd_seq, 0, in nl80211_get_station()
6624 return -ENOBUFS; in nl80211_get_station()
6634 if (params->listen_interval != -1 && in cfg80211_check_station_change()
6636 return -EINVAL; in cfg80211_check_station_change()
6638 if (params->support_p2p_ps != -1 && in cfg80211_check_station_change()
6640 return -EINVAL; in cfg80211_check_station_change()
6642 if (params->aid && in cfg80211_check_station_change()
6643 !(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) && in cfg80211_check_station_change()
6645 return -EINVAL; in cfg80211_check_station_change()
6654 * No ignoring the TDLS flag here -- the userspace mesh in cfg80211_check_station_change()
6658 if (params->sta_flags_mask & in cfg80211_check_station_change()
6662 return -EINVAL; in cfg80211_check_station_change()
6666 if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))) in cfg80211_check_station_change()
6667 return -EINVAL; in cfg80211_check_station_change()
6669 params->sta_flags_mask &= ~BIT(NL80211_STA_FLAG_TDLS_PEER); in cfg80211_check_station_change()
6672 /* disallow mesh-specific things */ in cfg80211_check_station_change()
6673 if (params->plink_action != NL80211_PLINK_ACTION_NO_ACTION) in cfg80211_check_station_change()
6674 return -EINVAL; in cfg80211_check_station_change()
6675 if (params->local_pm) in cfg80211_check_station_change()
6676 return -EINVAL; in cfg80211_check_station_change()
6677 if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) in cfg80211_check_station_change()
6678 return -EINVAL; in cfg80211_check_station_change()
6684 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) in cfg80211_check_station_change()
6685 return -EINVAL; in cfg80211_check_station_change()
6688 * a hostapd/wpa_supplicant issue -- it always includes the in cfg80211_check_station_change()
6691 params->sta_flags_mask &= ~BIT(NL80211_STA_FLAG_TDLS_PEER); in cfg80211_check_station_change()
6697 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) in cfg80211_check_station_change()
6698 return -EINVAL; in cfg80211_check_station_change()
6699 if (params->sta_modify_mask & STATION_PARAM_APPLY_CAPABILITY) in cfg80211_check_station_change()
6700 return -EINVAL; in cfg80211_check_station_change()
6701 if (params->link_sta_params.supported_rates) in cfg80211_check_station_change()
6702 return -EINVAL; in cfg80211_check_station_change()
6703 if (params->ext_capab || params->link_sta_params.ht_capa || in cfg80211_check_station_change()
6704 params->link_sta_params.vht_capa || in cfg80211_check_station_change()
6705 params->link_sta_params.he_capa || in cfg80211_check_station_change()
6706 params->link_sta_params.eht_capa) in cfg80211_check_station_change()
6707 return -EINVAL; in cfg80211_check_station_change()
6712 if (params->vlan) in cfg80211_check_station_change()
6713 return -EINVAL; in cfg80211_check_station_change()
6719 if (!(params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED))) in cfg80211_check_station_change()
6720 return -EOPNOTSUPP; in cfg80211_check_station_change()
6725 if (params->sta_flags_mask & in cfg80211_check_station_change()
6732 return -EINVAL; in cfg80211_check_station_change()
6735 if (!(wiphy->features & NL80211_FEATURE_FULL_AP_CLIENT_STATE) && in cfg80211_check_station_change()
6736 params->sta_flags_mask & in cfg80211_check_station_change()
6739 return -EINVAL; in cfg80211_check_station_change()
6744 if (params->sta_flags_mask & ~BIT(NL80211_STA_FLAG_AUTHORIZED)) in cfg80211_check_station_change()
6745 return -EINVAL; in cfg80211_check_station_change()
6749 if (params->sta_flags_mask & ~(BIT(NL80211_STA_FLAG_AUTHORIZED) | in cfg80211_check_station_change()
6751 return -EINVAL; in cfg80211_check_station_change()
6753 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED) && in cfg80211_check_station_change()
6754 !params->link_sta_params.supported_rates) in cfg80211_check_station_change()
6755 return -EINVAL; in cfg80211_check_station_change()
6759 return -EINVAL; in cfg80211_check_station_change()
6761 if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) in cfg80211_check_station_change()
6762 return -EINVAL; in cfg80211_check_station_change()
6765 if (params->plink_action != NL80211_PLINK_ACTION_NO_ACTION && in cfg80211_check_station_change()
6766 params->plink_action != NL80211_PLINK_ACTION_BLOCK) in cfg80211_check_station_change()
6767 return -EINVAL; in cfg80211_check_station_change()
6778 params->link_sta_params.opmode_notif_used = false; in cfg80211_check_station_change()
6790 struct nlattr *vlanattr = info->attrs[NL80211_ATTR_STA_VLAN]; in get_vlan()
6799 return ERR_PTR(-ENODEV); in get_vlan()
6801 if (!v->ieee80211_ptr || v->ieee80211_ptr->wiphy != &rdev->wiphy) { in get_vlan()
6802 ret = -EINVAL; in get_vlan()
6806 if (v->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN && in get_vlan()
6807 v->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && in get_vlan()
6808 v->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) { in get_vlan()
6809 ret = -EINVAL; in get_vlan()
6814 ret = -ENETDOWN; in get_vlan()
6832 if (!info->attrs[NL80211_ATTR_STA_WME]) in nl80211_parse_sta_wme()
6835 nla = info->attrs[NL80211_ATTR_STA_WME]; in nl80211_parse_sta_wme()
6838 info->extack); in nl80211_parse_sta_wme()
6843 params->uapsd_queues = nla_get_u8( in nl80211_parse_sta_wme()
6845 if (params->uapsd_queues & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK) in nl80211_parse_sta_wme()
6846 return -EINVAL; in nl80211_parse_sta_wme()
6849 params->max_sp = nla_get_u8(tb[NL80211_STA_WME_MAX_SP]); in nl80211_parse_sta_wme()
6851 if (params->max_sp & ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK) in nl80211_parse_sta_wme()
6852 return -EINVAL; in nl80211_parse_sta_wme()
6854 params->sta_modify_mask |= STATION_PARAM_APPLY_UAPSD; in nl80211_parse_sta_wme()
6862 if (info->attrs[NL80211_ATTR_STA_SUPPORTED_CHANNELS]) { in nl80211_parse_sta_channel_info()
6863 params->supported_channels = in nl80211_parse_sta_channel_info()
6864 nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_CHANNELS]); in nl80211_parse_sta_channel_info()
6865 params->supported_channels_len = in nl80211_parse_sta_channel_info()
6866 nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_CHANNELS]); in nl80211_parse_sta_channel_info()
6872 if (params->supported_channels_len % 2) in nl80211_parse_sta_channel_info()
6873 return -EINVAL; in nl80211_parse_sta_channel_info()
6876 if (info->attrs[NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES]) { in nl80211_parse_sta_channel_info()
6877 params->supported_oper_classes = in nl80211_parse_sta_channel_info()
6878 nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES]); in nl80211_parse_sta_channel_info()
6879 params->supported_oper_classes_len = in nl80211_parse_sta_channel_info()
6880 nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES]); in nl80211_parse_sta_channel_info()
6890 if (info->attrs[NL80211_ATTR_PEER_AID]) in nl80211_set_station_tdls()
6891 params->aid = nla_get_u16(info->attrs[NL80211_ATTR_PEER_AID]); in nl80211_set_station_tdls()
6892 if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) in nl80211_set_station_tdls()
6893 params->link_sta_params.ht_capa = in nl80211_set_station_tdls()
6894 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); in nl80211_set_station_tdls()
6895 if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) in nl80211_set_station_tdls()
6896 params->link_sta_params.vht_capa = in nl80211_set_station_tdls()
6897 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]); in nl80211_set_station_tdls()
6898 if (info->attrs[NL80211_ATTR_HE_CAPABILITY]) { in nl80211_set_station_tdls()
6899 params->link_sta_params.he_capa = in nl80211_set_station_tdls()
6900 nla_data(info->attrs[NL80211_ATTR_HE_CAPABILITY]); in nl80211_set_station_tdls()
6901 params->link_sta_params.he_capa_len = in nl80211_set_station_tdls()
6902 nla_len(info->attrs[NL80211_ATTR_HE_CAPABILITY]); in nl80211_set_station_tdls()
6904 if (info->attrs[NL80211_ATTR_EHT_CAPABILITY]) { in nl80211_set_station_tdls()
6905 params->link_sta_params.eht_capa = in nl80211_set_station_tdls()
6906 nla_data(info->attrs[NL80211_ATTR_EHT_CAPABILITY]); in nl80211_set_station_tdls()
6907 params->link_sta_params.eht_capa_len = in nl80211_set_station_tdls()
6908 nla_len(info->attrs[NL80211_ATTR_EHT_CAPABILITY]); in nl80211_set_station_tdls()
6910 if (!ieee80211_eht_capa_size_ok((const u8 *)params->link_sta_params.he_capa, in nl80211_set_station_tdls()
6911 (const u8 *)params->link_sta_params.eht_capa, in nl80211_set_station_tdls()
6912 params->link_sta_params.eht_capa_len, in nl80211_set_station_tdls()
6914 return -EINVAL; in nl80211_set_station_tdls()
6929 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_parse_sta_txpower_setting()
6932 if (info->attrs[NL80211_ATTR_STA_TX_POWER_SETTING]) { in nl80211_parse_sta_txpower_setting()
6933 if (!rdev->ops->set_tx_power || in nl80211_parse_sta_txpower_setting()
6934 !wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_parse_sta_txpower_setting()
6936 return -EOPNOTSUPP; in nl80211_parse_sta_txpower_setting()
6939 txpwr->type = nla_get_u8(info->attrs[idx]); in nl80211_parse_sta_txpower_setting()
6941 if (txpwr->type == NL80211_TX_POWER_LIMITED) { in nl80211_parse_sta_txpower_setting()
6944 if (info->attrs[idx]) in nl80211_parse_sta_txpower_setting()
6945 txpwr->power = nla_get_s16(info->attrs[idx]); in nl80211_parse_sta_txpower_setting()
6947 return -EINVAL; in nl80211_parse_sta_txpower_setting()
6960 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_station()
6961 struct net_device *dev = info->user_ptr[1]; in nl80211_set_station()
6968 if (!rdev->ops->change_station) in nl80211_set_station()
6969 return -EOPNOTSUPP; in nl80211_set_station()
6976 if (info->attrs[NL80211_ATTR_STA_AID]) in nl80211_set_station()
6977 params.aid = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]); in nl80211_set_station()
6979 if (info->attrs[NL80211_ATTR_VLAN_ID]) in nl80211_set_station()
6980 params.vlan_id = nla_get_u16(info->attrs[NL80211_ATTR_VLAN_ID]); in nl80211_set_station()
6982 if (info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]) in nl80211_set_station()
6984 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]); in nl80211_set_station()
6986 params.listen_interval = -1; in nl80211_set_station()
6988 if (info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]) in nl80211_set_station()
6990 nla_get_u8(info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]); in nl80211_set_station()
6992 params.support_p2p_ps = -1; in nl80211_set_station()
6994 if (!info->attrs[NL80211_ATTR_MAC]) in nl80211_set_station()
6995 return -EINVAL; in nl80211_set_station()
6998 nl80211_link_id_or_invalid(info->attrs); in nl80211_set_station()
7000 if (info->attrs[NL80211_ATTR_MLD_ADDR]) { in nl80211_set_station()
7007 return -EINVAL; in nl80211_set_station()
7009 mac_addr = nla_data(info->attrs[NL80211_ATTR_MLD_ADDR]); in nl80211_set_station()
7012 nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_set_station()
7014 return -EINVAL; in nl80211_set_station()
7016 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_set_station()
7020 if (info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]) { in nl80211_set_station()
7022 nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]); in nl80211_set_station()
7024 nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]); in nl80211_set_station()
7027 if (info->attrs[NL80211_ATTR_STA_CAPABILITY]) { in nl80211_set_station()
7029 nla_get_u16(info->attrs[NL80211_ATTR_STA_CAPABILITY]); in nl80211_set_station()
7033 if (info->attrs[NL80211_ATTR_STA_EXT_CAPABILITY]) { in nl80211_set_station()
7035 nla_data(info->attrs[NL80211_ATTR_STA_EXT_CAPABILITY]); in nl80211_set_station()
7037 nla_len(info->attrs[NL80211_ATTR_STA_EXT_CAPABILITY]); in nl80211_set_station()
7040 if (parse_station_flags(info, dev->ieee80211_ptr->iftype, &params)) in nl80211_set_station()
7041 return -EINVAL; in nl80211_set_station()
7043 if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) in nl80211_set_station()
7045 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); in nl80211_set_station()
7047 if (info->attrs[NL80211_ATTR_STA_PLINK_STATE]) { in nl80211_set_station()
7049 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_STATE]); in nl80211_set_station()
7050 if (info->attrs[NL80211_ATTR_MESH_PEER_AID]) in nl80211_set_station()
7052 info->attrs[NL80211_ATTR_MESH_PEER_AID]); in nl80211_set_station()
7056 if (info->attrs[NL80211_ATTR_LOCAL_MESH_POWER_MODE]) in nl80211_set_station()
7058 info->attrs[NL80211_ATTR_LOCAL_MESH_POWER_MODE]); in nl80211_set_station()
7060 if (info->attrs[NL80211_ATTR_OPMODE_NOTIF]) { in nl80211_set_station()
7063 nla_get_u8(info->attrs[NL80211_ATTR_OPMODE_NOTIF]); in nl80211_set_station()
7066 if (info->attrs[NL80211_ATTR_HE_6GHZ_CAPABILITY]) in nl80211_set_station()
7068 nla_data(info->attrs[NL80211_ATTR_HE_6GHZ_CAPABILITY]); in nl80211_set_station()
7070 if (info->attrs[NL80211_ATTR_AIRTIME_WEIGHT]) in nl80211_set_station()
7072 nla_get_u16(info->attrs[NL80211_ATTR_AIRTIME_WEIGHT]); in nl80211_set_station()
7075 !wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_set_station()
7077 return -EOPNOTSUPP; in nl80211_set_station()
7094 switch (dev->ieee80211_ptr->iftype) { in nl80211_set_station()
7104 err = -EOPNOTSUPP; in nl80211_set_station()
7109 wdev_lock(dev->ieee80211_ptr); in nl80211_set_station()
7111 wdev_unlock(dev->ieee80211_ptr); in nl80211_set_station()
7121 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_new_station()
7123 struct net_device *dev = info->user_ptr[1]; in nl80211_new_station()
7124 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_new_station()
7132 if (!rdev->ops->add_station) in nl80211_new_station()
7133 return -EOPNOTSUPP; in nl80211_new_station()
7135 if (!info->attrs[NL80211_ATTR_MAC]) in nl80211_new_station()
7136 return -EINVAL; in nl80211_new_station()
7138 if (!info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]) in nl80211_new_station()
7139 return -EINVAL; in nl80211_new_station()
7141 if (!info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]) in nl80211_new_station()
7142 return -EINVAL; in nl80211_new_station()
7144 if (!info->attrs[NL80211_ATTR_STA_AID] && in nl80211_new_station()
7145 !info->attrs[NL80211_ATTR_PEER_AID]) in nl80211_new_station()
7146 return -EINVAL; in nl80211_new_station()
7149 nl80211_link_id_or_invalid(info->attrs); in nl80211_new_station()
7151 if (info->attrs[NL80211_ATTR_MLD_ADDR]) { in nl80211_new_station()
7152 mac_addr = nla_data(info->attrs[NL80211_ATTR_MLD_ADDR]); in nl80211_new_station()
7155 nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_new_station()
7157 return -EINVAL; in nl80211_new_station()
7159 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_new_station()
7163 nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]); in nl80211_new_station()
7165 nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]); in nl80211_new_station()
7167 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]); in nl80211_new_station()
7169 if (info->attrs[NL80211_ATTR_VLAN_ID]) in nl80211_new_station()
7170 params.vlan_id = nla_get_u16(info->attrs[NL80211_ATTR_VLAN_ID]); in nl80211_new_station()
7172 if (info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]) { in nl80211_new_station()
7174 nla_get_u8(info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]); in nl80211_new_station()
7181 dev->ieee80211_ptr->iftype == NL80211_IFTYPE_P2P_GO; in nl80211_new_station()
7184 if (info->attrs[NL80211_ATTR_PEER_AID]) in nl80211_new_station()
7185 params.aid = nla_get_u16(info->attrs[NL80211_ATTR_PEER_AID]); in nl80211_new_station()
7187 params.aid = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]); in nl80211_new_station()
7189 if (info->attrs[NL80211_ATTR_STA_CAPABILITY]) { in nl80211_new_station()
7191 nla_get_u16(info->attrs[NL80211_ATTR_STA_CAPABILITY]); in nl80211_new_station()
7195 if (info->attrs[NL80211_ATTR_STA_EXT_CAPABILITY]) { in nl80211_new_station()
7197 nla_data(info->attrs[NL80211_ATTR_STA_EXT_CAPABILITY]); in nl80211_new_station()
7199 nla_len(info->attrs[NL80211_ATTR_STA_EXT_CAPABILITY]); in nl80211_new_station()
7202 if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) in nl80211_new_station()
7204 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); in nl80211_new_station()
7206 if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) in nl80211_new_station()
7208 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]); in nl80211_new_station()
7210 if (info->attrs[NL80211_ATTR_HE_CAPABILITY]) { in nl80211_new_station()
7212 nla_data(info->attrs[NL80211_ATTR_HE_CAPABILITY]); in nl80211_new_station()
7214 nla_len(info->attrs[NL80211_ATTR_HE_CAPABILITY]); in nl80211_new_station()
7216 if (info->attrs[NL80211_ATTR_EHT_CAPABILITY]) { in nl80211_new_station()
7218 nla_data(info->attrs[NL80211_ATTR_EHT_CAPABILITY]); in nl80211_new_station()
7220 nla_len(info->attrs[NL80211_ATTR_EHT_CAPABILITY]); in nl80211_new_station()
7226 return -EINVAL; in nl80211_new_station()
7230 if (info->attrs[NL80211_ATTR_HE_6GHZ_CAPABILITY]) in nl80211_new_station()
7232 nla_data(info->attrs[NL80211_ATTR_HE_6GHZ_CAPABILITY]); in nl80211_new_station()
7234 if (info->attrs[NL80211_ATTR_OPMODE_NOTIF]) { in nl80211_new_station()
7237 nla_get_u8(info->attrs[NL80211_ATTR_OPMODE_NOTIF]); in nl80211_new_station()
7240 if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) in nl80211_new_station()
7242 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); in nl80211_new_station()
7244 if (info->attrs[NL80211_ATTR_AIRTIME_WEIGHT]) in nl80211_new_station()
7246 nla_get_u16(info->attrs[NL80211_ATTR_AIRTIME_WEIGHT]); in nl80211_new_station()
7249 !wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_new_station()
7251 return -EOPNOTSUPP; in nl80211_new_station()
7267 if (parse_station_flags(info, dev->ieee80211_ptr->iftype, &params)) in nl80211_new_station()
7268 return -EINVAL; in nl80211_new_station()
7283 return -EINVAL; in nl80211_new_station()
7289 return -EINVAL; in nl80211_new_station()
7294 switch (dev->ieee80211_ptr->iftype) { in nl80211_new_station()
7299 if (!(rdev->wiphy.flags & WIPHY_FLAG_AP_UAPSD) || in nl80211_new_station()
7305 info->attrs[NL80211_ATTR_PEER_AID]) in nl80211_new_station()
7306 return -EINVAL; in nl80211_new_station()
7311 if (!(rdev->wiphy.features & in nl80211_new_station()
7314 return -EINVAL; in nl80211_new_station()
7342 return -EINVAL; in nl80211_new_station()
7345 info->attrs[NL80211_ATTR_PEER_AID]) in nl80211_new_station()
7346 return -EINVAL; in nl80211_new_station()
7357 return -EINVAL; in nl80211_new_station()
7360 return -EINVAL; in nl80211_new_station()
7362 if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS)) in nl80211_new_station()
7363 return -EOPNOTSUPP; in nl80211_new_station()
7365 if (!(rdev->wiphy.flags & WIPHY_FLAG_TDLS_EXTERNAL_SETUP)) in nl80211_new_station()
7366 return -EOPNOTSUPP; in nl80211_new_station()
7374 return -EOPNOTSUPP; in nl80211_new_station()
7379 wdev_lock(dev->ieee80211_ptr); in nl80211_new_station()
7380 if (wdev->valid_links) { in nl80211_new_station()
7382 err = -EINVAL; in nl80211_new_station()
7385 if (!(wdev->valid_links & BIT(params.link_sta_params.link_id))) { in nl80211_new_station()
7386 err = -ENOLINK; in nl80211_new_station()
7391 err = -EINVAL; in nl80211_new_station()
7397 wdev_unlock(dev->ieee80211_ptr); in nl80211_new_station()
7404 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_del_station()
7405 struct net_device *dev = info->user_ptr[1]; in nl80211_del_station()
7411 if (info->attrs[NL80211_ATTR_MAC]) in nl80211_del_station()
7412 params.mac = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_del_station()
7414 switch (dev->ieee80211_ptr->iftype) { in nl80211_del_station()
7423 if (wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_del_station()
7426 return -EINVAL; in nl80211_del_station()
7428 return -EINVAL; in nl80211_del_station()
7431 if (!rdev->ops->del_station) in nl80211_del_station()
7432 return -EOPNOTSUPP; in nl80211_del_station()
7434 if (info->attrs[NL80211_ATTR_MGMT_SUBTYPE]) { in nl80211_del_station()
7436 nla_get_u8(info->attrs[NL80211_ATTR_MGMT_SUBTYPE]); in nl80211_del_station()
7439 return -EINVAL; in nl80211_del_station()
7445 if (info->attrs[NL80211_ATTR_REASON_CODE]) { in nl80211_del_station()
7447 nla_get_u16(info->attrs[NL80211_ATTR_REASON_CODE]); in nl80211_del_station()
7449 return -EINVAL; /* 0 is reserved */ in nl80211_del_station()
7455 wdev_lock(dev->ieee80211_ptr); in nl80211_del_station()
7457 wdev_unlock(dev->ieee80211_ptr); in nl80211_del_station()
7472 return -1; in nl80211_send_mpath()
7474 if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || in nl80211_send_mpath()
7477 nla_put_u32(msg, NL80211_ATTR_GENERATION, pinfo->generation)) in nl80211_send_mpath()
7483 if ((pinfo->filled & MPATH_INFO_FRAME_QLEN) && in nl80211_send_mpath()
7485 pinfo->frame_qlen)) in nl80211_send_mpath()
7487 if (((pinfo->filled & MPATH_INFO_SN) && in nl80211_send_mpath()
7488 nla_put_u32(msg, NL80211_MPATH_INFO_SN, pinfo->sn)) || in nl80211_send_mpath()
7489 ((pinfo->filled & MPATH_INFO_METRIC) && in nl80211_send_mpath()
7491 pinfo->metric)) || in nl80211_send_mpath()
7492 ((pinfo->filled & MPATH_INFO_EXPTIME) && in nl80211_send_mpath()
7494 pinfo->exptime)) || in nl80211_send_mpath()
7495 ((pinfo->filled & MPATH_INFO_FLAGS) && in nl80211_send_mpath()
7497 pinfo->flags)) || in nl80211_send_mpath()
7498 ((pinfo->filled & MPATH_INFO_DISCOVERY_TIMEOUT) && in nl80211_send_mpath()
7500 pinfo->discovery_timeout)) || in nl80211_send_mpath()
7501 ((pinfo->filled & MPATH_INFO_DISCOVERY_RETRIES) && in nl80211_send_mpath()
7503 pinfo->discovery_retries)) || in nl80211_send_mpath()
7504 ((pinfo->filled & MPATH_INFO_HOP_COUNT) && in nl80211_send_mpath()
7506 pinfo->hop_count)) || in nl80211_send_mpath()
7507 ((pinfo->filled & MPATH_INFO_PATH_CHANGE) && in nl80211_send_mpath()
7509 pinfo->path_change_count))) in nl80211_send_mpath()
7519 return -EMSGSIZE; in nl80211_send_mpath()
7530 int path_idx = cb->args[2]; in nl80211_dump_mpath()
7537 __acquire(&rdev->wiphy.mtx); in nl80211_dump_mpath()
7539 if (!rdev->ops->dump_mpath) { in nl80211_dump_mpath()
7540 err = -EOPNOTSUPP; in nl80211_dump_mpath()
7544 if (wdev->iftype != NL80211_IFTYPE_MESH_POINT) { in nl80211_dump_mpath()
7545 err = -EOPNOTSUPP; in nl80211_dump_mpath()
7550 err = rdev_dump_mpath(rdev, wdev->netdev, path_idx, dst, in nl80211_dump_mpath()
7552 if (err == -ENOENT) in nl80211_dump_mpath()
7557 if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).portid, in nl80211_dump_mpath()
7558 cb->nlh->nlmsg_seq, NLM_F_MULTI, in nl80211_dump_mpath()
7559 wdev->netdev, dst, next_hop, in nl80211_dump_mpath()
7567 cb->args[2] = path_idx; in nl80211_dump_mpath()
7568 err = skb->len; in nl80211_dump_mpath()
7570 wiphy_unlock(&rdev->wiphy); in nl80211_dump_mpath()
7576 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_get_mpath()
7578 struct net_device *dev = info->user_ptr[1]; in nl80211_get_mpath()
7586 if (!info->attrs[NL80211_ATTR_MAC]) in nl80211_get_mpath()
7587 return -EINVAL; in nl80211_get_mpath()
7589 dst = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_get_mpath()
7591 if (!rdev->ops->get_mpath) in nl80211_get_mpath()
7592 return -EOPNOTSUPP; in nl80211_get_mpath()
7594 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) in nl80211_get_mpath()
7595 return -EOPNOTSUPP; in nl80211_get_mpath()
7603 return -ENOMEM; in nl80211_get_mpath()
7605 if (nl80211_send_mpath(msg, info->snd_portid, info->snd_seq, 0, in nl80211_get_mpath()
7608 return -ENOBUFS; in nl80211_get_mpath()
7616 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_mpath()
7617 struct net_device *dev = info->user_ptr[1]; in nl80211_set_mpath()
7621 if (!info->attrs[NL80211_ATTR_MAC]) in nl80211_set_mpath()
7622 return -EINVAL; in nl80211_set_mpath()
7624 if (!info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]) in nl80211_set_mpath()
7625 return -EINVAL; in nl80211_set_mpath()
7627 dst = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_set_mpath()
7628 next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]); in nl80211_set_mpath()
7630 if (!rdev->ops->change_mpath) in nl80211_set_mpath()
7631 return -EOPNOTSUPP; in nl80211_set_mpath()
7633 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) in nl80211_set_mpath()
7634 return -EOPNOTSUPP; in nl80211_set_mpath()
7641 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_new_mpath()
7642 struct net_device *dev = info->user_ptr[1]; in nl80211_new_mpath()
7646 if (!info->attrs[NL80211_ATTR_MAC]) in nl80211_new_mpath()
7647 return -EINVAL; in nl80211_new_mpath()
7649 if (!info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]) in nl80211_new_mpath()
7650 return -EINVAL; in nl80211_new_mpath()
7652 dst = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_new_mpath()
7653 next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]); in nl80211_new_mpath()
7655 if (!rdev->ops->add_mpath) in nl80211_new_mpath()
7656 return -EOPNOTSUPP; in nl80211_new_mpath()
7658 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) in nl80211_new_mpath()
7659 return -EOPNOTSUPP; in nl80211_new_mpath()
7666 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_del_mpath()
7667 struct net_device *dev = info->user_ptr[1]; in nl80211_del_mpath()
7670 if (info->attrs[NL80211_ATTR_MAC]) in nl80211_del_mpath()
7671 dst = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_del_mpath()
7673 if (!rdev->ops->del_mpath) in nl80211_del_mpath()
7674 return -EOPNOTSUPP; in nl80211_del_mpath()
7676 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) in nl80211_del_mpath()
7677 return -EOPNOTSUPP; in nl80211_del_mpath()
7684 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_get_mpp()
7686 struct net_device *dev = info->user_ptr[1]; in nl80211_get_mpp()
7694 if (!info->attrs[NL80211_ATTR_MAC]) in nl80211_get_mpp()
7695 return -EINVAL; in nl80211_get_mpp()
7697 dst = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_get_mpp()
7699 if (!rdev->ops->get_mpp) in nl80211_get_mpp()
7700 return -EOPNOTSUPP; in nl80211_get_mpp()
7702 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) in nl80211_get_mpp()
7703 return -EOPNOTSUPP; in nl80211_get_mpp()
7711 return -ENOMEM; in nl80211_get_mpp()
7713 if (nl80211_send_mpath(msg, info->snd_portid, info->snd_seq, 0, in nl80211_get_mpp()
7716 return -ENOBUFS; in nl80211_get_mpp()
7730 int path_idx = cb->args[2]; in nl80211_dump_mpp()
7737 __acquire(&rdev->wiphy.mtx); in nl80211_dump_mpp()
7739 if (!rdev->ops->dump_mpp) { in nl80211_dump_mpp()
7740 err = -EOPNOTSUPP; in nl80211_dump_mpp()
7744 if (wdev->iftype != NL80211_IFTYPE_MESH_POINT) { in nl80211_dump_mpp()
7745 err = -EOPNOTSUPP; in nl80211_dump_mpp()
7750 err = rdev_dump_mpp(rdev, wdev->netdev, path_idx, dst, in nl80211_dump_mpp()
7752 if (err == -ENOENT) in nl80211_dump_mpp()
7757 if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).portid, in nl80211_dump_mpp()
7758 cb->nlh->nlmsg_seq, NLM_F_MULTI, in nl80211_dump_mpp()
7759 wdev->netdev, dst, mpp, in nl80211_dump_mpp()
7767 cb->args[2] = path_idx; in nl80211_dump_mpp()
7768 err = skb->len; in nl80211_dump_mpp()
7770 wiphy_unlock(&rdev->wiphy); in nl80211_dump_mpp()
7776 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_bss()
7777 struct net_device *dev = info->user_ptr[1]; in nl80211_set_bss()
7778 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_set_bss()
7784 params.use_cts_prot = -1; in nl80211_set_bss()
7785 params.use_short_preamble = -1; in nl80211_set_bss()
7786 params.use_short_slot_time = -1; in nl80211_set_bss()
7787 params.ap_isolate = -1; in nl80211_set_bss()
7788 params.ht_opmode = -1; in nl80211_set_bss()
7789 params.p2p_ctwindow = -1; in nl80211_set_bss()
7790 params.p2p_opp_ps = -1; in nl80211_set_bss()
7792 if (info->attrs[NL80211_ATTR_BSS_CTS_PROT]) in nl80211_set_bss()
7794 nla_get_u8(info->attrs[NL80211_ATTR_BSS_CTS_PROT]); in nl80211_set_bss()
7795 if (info->attrs[NL80211_ATTR_BSS_SHORT_PREAMBLE]) in nl80211_set_bss()
7797 nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_PREAMBLE]); in nl80211_set_bss()
7798 if (info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME]) in nl80211_set_bss()
7800 nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME]); in nl80211_set_bss()
7801 if (info->attrs[NL80211_ATTR_BSS_BASIC_RATES]) { in nl80211_set_bss()
7803 nla_data(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]); in nl80211_set_bss()
7805 nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]); in nl80211_set_bss()
7807 if (info->attrs[NL80211_ATTR_AP_ISOLATE]) in nl80211_set_bss()
7808 params.ap_isolate = !!nla_get_u8(info->attrs[NL80211_ATTR_AP_ISOLATE]); in nl80211_set_bss()
7809 if (info->attrs[NL80211_ATTR_BSS_HT_OPMODE]) in nl80211_set_bss()
7811 nla_get_u16(info->attrs[NL80211_ATTR_BSS_HT_OPMODE]); in nl80211_set_bss()
7813 if (info->attrs[NL80211_ATTR_P2P_CTWINDOW]) { in nl80211_set_bss()
7814 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) in nl80211_set_bss()
7815 return -EINVAL; in nl80211_set_bss()
7817 nla_get_u8(info->attrs[NL80211_ATTR_P2P_CTWINDOW]); in nl80211_set_bss()
7819 !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_CTWIN)) in nl80211_set_bss()
7820 return -EINVAL; in nl80211_set_bss()
7823 if (info->attrs[NL80211_ATTR_P2P_OPPPS]) { in nl80211_set_bss()
7826 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) in nl80211_set_bss()
7827 return -EINVAL; in nl80211_set_bss()
7828 tmp = nla_get_u8(info->attrs[NL80211_ATTR_P2P_OPPPS]); in nl80211_set_bss()
7831 !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_OPPPS)) in nl80211_set_bss()
7832 return -EINVAL; in nl80211_set_bss()
7835 if (!rdev->ops->change_bss) in nl80211_set_bss()
7836 return -EOPNOTSUPP; in nl80211_set_bss()
7838 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && in nl80211_set_bss()
7839 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) in nl80211_set_bss()
7840 return -EOPNOTSUPP; in nl80211_set_bss()
7858 * completely when built-in to the kernel right between the time in nl80211_req_set_reg()
7863 return -EINPROGRESS; in nl80211_req_set_reg()
7865 if (info->attrs[NL80211_ATTR_USER_REG_HINT_TYPE]) in nl80211_req_set_reg()
7867 nla_get_u32(info->attrs[NL80211_ATTR_USER_REG_HINT_TYPE]); in nl80211_req_set_reg()
7874 if (!info->attrs[NL80211_ATTR_REG_ALPHA2]) in nl80211_req_set_reg()
7875 return -EINVAL; in nl80211_req_set_reg()
7877 data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]); in nl80211_req_set_reg()
7880 if (info->attrs[NL80211_ATTR_SOCKET_OWNER]) { in nl80211_req_set_reg()
7881 owner_nlportid = info->snd_portid; in nl80211_req_set_reg()
7882 is_indoor = !!info->attrs[NL80211_ATTR_REG_INDOOR]; in nl80211_req_set_reg()
7890 return -EINVAL; in nl80211_req_set_reg()
7902 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_get_mesh_config()
7903 struct net_device *dev = info->user_ptr[1]; in nl80211_get_mesh_config()
7904 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_get_mesh_config()
7911 if (wdev->iftype != NL80211_IFTYPE_MESH_POINT) in nl80211_get_mesh_config()
7912 return -EOPNOTSUPP; in nl80211_get_mesh_config()
7914 if (!rdev->ops->get_mesh_config) in nl80211_get_mesh_config()
7915 return -EOPNOTSUPP; in nl80211_get_mesh_config()
7919 if (!wdev->u.mesh.id_len) in nl80211_get_mesh_config()
7931 return -ENOMEM; in nl80211_get_mesh_config()
7932 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, in nl80211_get_mesh_config()
7939 if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || in nl80211_get_mesh_config()
8010 return -ENOBUFS; in nl80211_get_mesh_config()
8045 NLA_POLICY_RANGE(NLA_S32, -255, 0),
8088 cfg->param = fn(tb[attr]); \ in nl80211_parse_mesh_config()
8089 mask |= BIT((attr) - 1); \ in nl80211_parse_mesh_config()
8093 if (!info->attrs[NL80211_ATTR_MESH_CONFIG]) in nl80211_parse_mesh_config()
8094 return -EINVAL; in nl80211_parse_mesh_config()
8095 …ated(tb, NL80211_MESHCONF_ATTR_MAX, info->attrs[NL80211_ATTR_MESH_CONFIG], nl80211_meshconf_params… in nl80211_parse_mesh_config()
8096 return -EINVAL; in nl80211_parse_mesh_config()
8099 * parameters (otherwise our bitfield scheme would not work.) */ in nl80211_parse_mesh_config()
8134 (cfg->path_refresh_time < 1 || cfg->path_refresh_time > 65535)) in nl80211_parse_mesh_config()
8135 return -EINVAL; in nl80211_parse_mesh_config()
8144 (cfg->dot11MeshHWMPactivePathTimeout < 1 || in nl80211_parse_mesh_config()
8145 cfg->dot11MeshHWMPactivePathTimeout > 65535)) in nl80211_parse_mesh_config()
8146 return -EINVAL; in nl80211_parse_mesh_config()
8178 * IEEE 802.11-2016 9.4.2.57 HT Operation element. in nl80211_parse_mesh_config()
8186 return -EINVAL; in nl80211_parse_mesh_config()
8191 cfg->ht_opmode = ht_opmode; in nl80211_parse_mesh_config()
8192 mask |= (1 << (NL80211_MESHCONF_HT_OPMODE - 1)); in nl80211_parse_mesh_config()
8199 (cfg->dot11MeshHWMPactivePathToRootTimeout < 1 || in nl80211_parse_mesh_config()
8200 cfg->dot11MeshHWMPactivePathToRootTimeout > 65535)) in nl80211_parse_mesh_config()
8201 return -EINVAL; in nl80211_parse_mesh_config()
8228 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_parse_mesh_setup()
8231 if (!info->attrs[NL80211_ATTR_MESH_SETUP]) in nl80211_parse_mesh_setup()
8232 return -EINVAL; in nl80211_parse_mesh_setup()
8233 …ed(tb, NL80211_MESH_SETUP_ATTR_MAX, info->attrs[NL80211_ATTR_MESH_SETUP], nl80211_mesh_setup_param… in nl80211_parse_mesh_setup()
8234 return -EINVAL; in nl80211_parse_mesh_setup()
8237 setup->sync_method = in nl80211_parse_mesh_setup()
8243 setup->path_sel_proto = in nl80211_parse_mesh_setup()
8249 setup->path_metric = in nl80211_parse_mesh_setup()
8257 setup->ie = nla_data(ieattr); in nl80211_parse_mesh_setup()
8258 setup->ie_len = nla_len(ieattr); in nl80211_parse_mesh_setup()
8261 !(rdev->wiphy.features & NL80211_FEATURE_USERSPACE_MPM)) in nl80211_parse_mesh_setup()
8262 return -EINVAL; in nl80211_parse_mesh_setup()
8263 setup->user_mpm = nla_get_flag(tb[NL80211_MESH_SETUP_USERSPACE_MPM]); in nl80211_parse_mesh_setup()
8264 setup->is_authenticated = nla_get_flag(tb[NL80211_MESH_SETUP_USERSPACE_AUTH]); in nl80211_parse_mesh_setup()
8265 setup->is_secure = nla_get_flag(tb[NL80211_MESH_SETUP_USERSPACE_AMPE]); in nl80211_parse_mesh_setup()
8266 if (setup->is_secure) in nl80211_parse_mesh_setup()
8267 setup->user_mpm = true; in nl80211_parse_mesh_setup()
8270 if (!setup->user_mpm) in nl80211_parse_mesh_setup()
8271 return -EINVAL; in nl80211_parse_mesh_setup()
8272 setup->auth_id = in nl80211_parse_mesh_setup()
8282 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_update_mesh_config()
8283 struct net_device *dev = info->user_ptr[1]; in nl80211_update_mesh_config()
8284 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_update_mesh_config()
8289 if (wdev->iftype != NL80211_IFTYPE_MESH_POINT) in nl80211_update_mesh_config()
8290 return -EOPNOTSUPP; in nl80211_update_mesh_config()
8292 if (!rdev->ops->update_mesh_config) in nl80211_update_mesh_config()
8293 return -EOPNOTSUPP; in nl80211_update_mesh_config()
8300 if (!wdev->u.mesh.id_len) in nl80211_update_mesh_config()
8301 err = -ENOLINK; in nl80211_update_mesh_config()
8317 if (nla_put_string(msg, NL80211_ATTR_REG_ALPHA2, regdom->alpha2) || in nl80211_put_regdom()
8318 (regdom->dfs_region && in nl80211_put_regdom()
8319 nla_put_u8(msg, NL80211_ATTR_DFS_REGION, regdom->dfs_region))) in nl80211_put_regdom()
8326 for (i = 0; i < regdom->n_reg_rules; i++) { in nl80211_put_regdom()
8333 reg_rule = &regdom->reg_rules[i]; in nl80211_put_regdom()
8334 freq_range = &reg_rule->freq_range; in nl80211_put_regdom()
8335 power_rule = &reg_rule->power_rule; in nl80211_put_regdom()
8341 max_bandwidth_khz = freq_range->max_bandwidth_khz; in nl80211_put_regdom()
8347 reg_rule->flags) || in nl80211_put_regdom()
8349 freq_range->start_freq_khz) || in nl80211_put_regdom()
8351 freq_range->end_freq_khz) || in nl80211_put_regdom()
8355 power_rule->max_antenna_gain) || in nl80211_put_regdom()
8357 power_rule->max_eirp) || in nl80211_put_regdom()
8359 reg_rule->dfs_cac_ms)) in nl80211_put_regdom()
8369 return -EMSGSIZE; in nl80211_put_regdom()
8378 int err = -EMSGSIZE; in nl80211_get_reg_do()
8383 return -ENOBUFS; in nl80211_get_reg_do()
8385 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, in nl80211_get_reg_do()
8392 if (info->attrs[NL80211_ATTR_WIPHY]) { in nl80211_get_reg_do()
8401 wiphy = &rdev->wiphy; in nl80211_get_reg_do()
8402 self_managed = wiphy->regulatory_flags & in nl80211_get_reg_do()
8409 /* a self-managed-reg device must have a private regdom */ in nl80211_get_reg_do()
8411 err = -EINVAL; in nl80211_get_reg_do()
8452 void *hdr = nl80211hdr_put(msg, NETLINK_CB(cb->skb).portid, seq, flags, in nl80211_send_regdom()
8456 return -1; in nl80211_send_regdom()
8472 if (wiphy && wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED && in nl80211_send_regdom()
8481 return -EMSGSIZE; in nl80211_send_regdom()
8489 int err, reg_idx, start = cb->args[2]; in nl80211_get_reg_dump()
8494 err = nl80211_send_regdom(skb, cb, cb->nlh->nlmsg_seq, in nl80211_get_reg_dump()
8504 regdom = get_wiphy_regdom(&rdev->wiphy); in nl80211_get_reg_dump()
8511 err = nl80211_send_regdom(skb, cb, cb->nlh->nlmsg_seq, in nl80211_get_reg_dump()
8512 NLM_F_MULTI, &rdev->wiphy, regdom); in nl80211_get_reg_dump()
8514 reg_idx--; in nl80211_get_reg_dump()
8519 cb->args[2] = reg_idx; in nl80211_get_reg_dump()
8520 err = skb->len; in nl80211_get_reg_dump()
8540 struct ieee80211_freq_range *freq_range = &reg_rule->freq_range; in parse_reg_rule()
8541 struct ieee80211_power_rule *power_rule = &reg_rule->power_rule; in parse_reg_rule()
8544 return -EINVAL; in parse_reg_rule()
8546 return -EINVAL; in parse_reg_rule()
8548 return -EINVAL; in parse_reg_rule()
8550 return -EINVAL; in parse_reg_rule()
8552 return -EINVAL; in parse_reg_rule()
8554 reg_rule->flags = nla_get_u32(tb[NL80211_ATTR_REG_RULE_FLAGS]); in parse_reg_rule()
8556 freq_range->start_freq_khz = in parse_reg_rule()
8558 freq_range->end_freq_khz = in parse_reg_rule()
8560 freq_range->max_bandwidth_khz = in parse_reg_rule()
8563 power_rule->max_eirp = in parse_reg_rule()
8567 power_rule->max_antenna_gain = in parse_reg_rule()
8571 reg_rule->dfs_cac_ms = in parse_reg_rule()
8587 if (!info->attrs[NL80211_ATTR_REG_ALPHA2]) in nl80211_set_reg()
8588 return -EINVAL; in nl80211_set_reg()
8590 if (!info->attrs[NL80211_ATTR_REG_RULES]) in nl80211_set_reg()
8591 return -EINVAL; in nl80211_set_reg()
8593 alpha2 = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]); in nl80211_set_reg()
8595 if (info->attrs[NL80211_ATTR_DFS_REGION]) in nl80211_set_reg()
8596 dfs_region = nla_get_u8(info->attrs[NL80211_ATTR_DFS_REGION]); in nl80211_set_reg()
8598 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES], in nl80211_set_reg()
8602 return -EINVAL; in nl80211_set_reg()
8607 r = -EINVAL; in nl80211_set_reg()
8613 r = -ENOMEM; in nl80211_set_reg()
8617 rd->n_reg_rules = num_rules; in nl80211_set_reg()
8618 rd->alpha2[0] = alpha2[0]; in nl80211_set_reg()
8619 rd->alpha2[1] = alpha2[1]; in nl80211_set_reg()
8626 rd->dfs_region = dfs_region; in nl80211_set_reg()
8628 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES], in nl80211_set_reg()
8632 info->extack); in nl80211_set_reg()
8635 r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]); in nl80211_set_reg()
8642 r = -EINVAL; in nl80211_set_reg()
8689 return b < NUM_NL80211_BANDS && wiphy->bands[b]; in is_band_valid()
8704 return -EINVAL; in parse_bss_select()
8716 return -EINVAL; in parse_bss_select()
8721 bss_select->behaviour = __NL80211_BSS_SELECT_ATTR_INVALID; in parse_bss_select()
8724 bss_select->behaviour = NL80211_BSS_SELECT_ATTR_RSSI; in parse_bss_select()
8727 bss_select->behaviour = NL80211_BSS_SELECT_ATTR_BAND_PREF; in parse_bss_select()
8728 bss_select->param.band_pref = in parse_bss_select()
8730 if (!is_band_valid(wiphy, bss_select->param.band_pref)) in parse_bss_select()
8731 return -EINVAL; in parse_bss_select()
8738 bss_select->behaviour = NL80211_BSS_SELECT_ATTR_RSSI_ADJUST; in parse_bss_select()
8739 bss_select->param.adjust.band = adj_param->band; in parse_bss_select()
8740 bss_select->param.adjust.delta = adj_param->delta; in parse_bss_select()
8741 if (!is_band_valid(wiphy, bss_select->param.adjust.band)) in parse_bss_select()
8742 return -EINVAL; in parse_bss_select()
8745 /* user-space did not provide behaviour attribute */ in parse_bss_select()
8746 if (bss_select->behaviour == __NL80211_BSS_SELECT_ATTR_INVALID) in parse_bss_select()
8747 return -EINVAL; in parse_bss_select()
8749 if (!(wiphy->bss_select_support & BIT(bss_select->behaviour))) in parse_bss_select()
8750 return -EINVAL; in parse_bss_select()
8771 return -EINVAL; in nl80211_parse_random_mac()
8779 return -EINVAL; in nl80211_parse_random_mac()
8822 * the off-channel operation. in cfg80211_off_channel_oper_allowed()
8825 if (chandef->chan->flags & IEEE80211_CHAN_RADAR) in cfg80211_off_channel_oper_allowed()
8832 return regulatory_pre_cac_allowed(wdev->wiphy); in cfg80211_off_channel_oper_allowed()
8863 flags = &req->flags; in nl80211_check_scan_flags()
8864 mac_addr = req->mac_addr; in nl80211_check_scan_flags()
8865 mac_addr_mask = req->mac_addr_mask; in nl80211_check_scan_flags()
8870 flags = &req->flags; in nl80211_check_scan_flags()
8871 mac_addr = req->mac_addr; in nl80211_check_scan_flags()
8872 mac_addr_mask = req->mac_addr_mask; in nl80211_check_scan_flags()
8878 !(wiphy->features & NL80211_FEATURE_LOW_PRIORITY_SCAN)) || in nl80211_check_scan_flags()
8906 return -EOPNOTSUPP; in nl80211_check_scan_flags()
8911 if (!(wiphy->features & randomness_flag) || in nl80211_check_scan_flags()
8912 (wdev && wdev->connected)) in nl80211_check_scan_flags()
8913 return -EOPNOTSUPP; in nl80211_check_scan_flags()
8925 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_trigger_scan()
8926 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_trigger_scan()
8935 wiphy = &rdev->wiphy; in nl80211_trigger_scan()
8937 if (wdev->iftype == NL80211_IFTYPE_NAN) in nl80211_trigger_scan()
8938 return -EOPNOTSUPP; in nl80211_trigger_scan()
8940 if (!rdev->ops->scan) in nl80211_trigger_scan()
8941 return -EOPNOTSUPP; in nl80211_trigger_scan()
8943 if (rdev->scan_req || rdev->scan_msg) in nl80211_trigger_scan()
8944 return -EBUSY; in nl80211_trigger_scan()
8946 if (info->attrs[NL80211_ATTR_SCAN_FREQ_KHZ]) { in nl80211_trigger_scan()
8949 return -EOPNOTSUPP; in nl80211_trigger_scan()
8950 scan_freqs = info->attrs[NL80211_ATTR_SCAN_FREQ_KHZ]; in nl80211_trigger_scan()
8952 } else if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) in nl80211_trigger_scan()
8953 scan_freqs = info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]; in nl80211_trigger_scan()
8958 return -EINVAL; in nl80211_trigger_scan()
8963 if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) in nl80211_trigger_scan()
8964 nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp) in nl80211_trigger_scan()
8967 if (n_ssids > wiphy->max_scan_ssids) in nl80211_trigger_scan()
8968 return -EINVAL; in nl80211_trigger_scan()
8970 if (info->attrs[NL80211_ATTR_IE]) in nl80211_trigger_scan()
8971 ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); in nl80211_trigger_scan()
8975 if (ie_len > wiphy->max_scan_ie_len) in nl80211_trigger_scan()
8976 return -EINVAL; in nl80211_trigger_scan()
8979 + sizeof(*request->ssids) * n_ssids in nl80211_trigger_scan()
8980 + sizeof(*request->channels) * n_channels in nl80211_trigger_scan()
8983 return -ENOMEM; in nl80211_trigger_scan()
8986 request->ssids = (void *)&request->channels[n_channels]; in nl80211_trigger_scan()
8987 request->n_ssids = n_ssids; in nl80211_trigger_scan()
8990 request->ie = (void *)(request->ssids + n_ssids); in nl80211_trigger_scan()
8992 request->ie = (void *)(request->channels + n_channels); in nl80211_trigger_scan()
9007 err = -EINVAL; in nl80211_trigger_scan()
9012 if (chan->flags & IEEE80211_CHAN_DISABLED) in nl80211_trigger_scan()
9015 request->channels[i] = chan; in nl80211_trigger_scan()
9025 if (!wiphy->bands[band]) in nl80211_trigger_scan()
9027 for (j = 0; j < wiphy->bands[band]->n_channels; j++) { in nl80211_trigger_scan()
9030 chan = &wiphy->bands[band]->channels[j]; in nl80211_trigger_scan()
9032 if (chan->flags & IEEE80211_CHAN_DISABLED) in nl80211_trigger_scan()
9035 request->channels[i] = chan; in nl80211_trigger_scan()
9042 err = -EINVAL; in nl80211_trigger_scan()
9046 request->n_channels = i; in nl80211_trigger_scan()
9049 for (i = 0; i < request->n_channels; i++) { in nl80211_trigger_scan()
9050 struct ieee80211_channel *chan = request->channels[i]; in nl80211_trigger_scan()
9052 /* if we can go off-channel to the target channel we're good */ in nl80211_trigger_scan()
9058 err = -EBUSY; in nl80211_trigger_scan()
9066 nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp) { in nl80211_trigger_scan()
9068 err = -EINVAL; in nl80211_trigger_scan()
9071 request->ssids[i].ssid_len = nla_len(attr); in nl80211_trigger_scan()
9072 memcpy(request->ssids[i].ssid, nla_data(attr), nla_len(attr)); in nl80211_trigger_scan()
9077 if (info->attrs[NL80211_ATTR_IE]) { in nl80211_trigger_scan()
9078 request->ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); in nl80211_trigger_scan()
9079 memcpy((void *)request->ie, in nl80211_trigger_scan()
9080 nla_data(info->attrs[NL80211_ATTR_IE]), in nl80211_trigger_scan()
9081 request->ie_len); in nl80211_trigger_scan()
9085 if (wiphy->bands[i]) in nl80211_trigger_scan()
9086 request->rates[i] = in nl80211_trigger_scan()
9087 (1 << wiphy->bands[i]->n_bitrates) - 1; in nl80211_trigger_scan()
9089 if (info->attrs[NL80211_ATTR_SCAN_SUPP_RATES]) { in nl80211_trigger_scan()
9091 info->attrs[NL80211_ATTR_SCAN_SUPP_RATES], in nl80211_trigger_scan()
9096 err = -EINVAL; in nl80211_trigger_scan()
9100 if (!wiphy->bands[band]) in nl80211_trigger_scan()
9103 err = ieee80211_get_ratemask(wiphy->bands[band], in nl80211_trigger_scan()
9106 &request->rates[band]); in nl80211_trigger_scan()
9112 if (info->attrs[NL80211_ATTR_MEASUREMENT_DURATION]) { in nl80211_trigger_scan()
9113 request->duration = in nl80211_trigger_scan()
9114 nla_get_u16(info->attrs[NL80211_ATTR_MEASUREMENT_DURATION]); in nl80211_trigger_scan()
9115 request->duration_mandatory = in nl80211_trigger_scan()
9116 nla_get_flag(info->attrs[NL80211_ATTR_MEASUREMENT_DURATION_MANDATORY]); in nl80211_trigger_scan()
9119 err = nl80211_check_scan_flags(wiphy, wdev, request, info->attrs, in nl80211_trigger_scan()
9124 request->no_cck = in nl80211_trigger_scan()
9125 nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]); in nl80211_trigger_scan()
9136 if (info->attrs[NL80211_ATTR_BSSID]) in nl80211_trigger_scan()
9137 memcpy(request->bssid, in nl80211_trigger_scan()
9138 nla_data(info->attrs[NL80211_ATTR_BSSID]), ETH_ALEN); in nl80211_trigger_scan()
9139 else if (!(request->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) && in nl80211_trigger_scan()
9140 info->attrs[NL80211_ATTR_MAC]) in nl80211_trigger_scan()
9141 memcpy(request->bssid, nla_data(info->attrs[NL80211_ATTR_MAC]), in nl80211_trigger_scan()
9144 eth_broadcast_addr(request->bssid); in nl80211_trigger_scan()
9146 request->wdev = wdev; in nl80211_trigger_scan()
9147 request->wiphy = &rdev->wiphy; in nl80211_trigger_scan()
9148 request->scan_start = jiffies; in nl80211_trigger_scan()
9150 rdev->scan_req = request; in nl80211_trigger_scan()
9157 dev_hold(wdev->netdev); in nl80211_trigger_scan()
9162 rdev->scan_req = NULL; in nl80211_trigger_scan()
9170 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_abort_scan()
9171 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_abort_scan()
9173 if (!rdev->ops->abort_scan) in nl80211_abort_scan()
9174 return -EOPNOTSUPP; in nl80211_abort_scan()
9176 if (rdev->scan_msg) in nl80211_abort_scan()
9179 if (!rdev->scan_req) in nl80211_abort_scan()
9180 return -ENOENT; in nl80211_abort_scan()
9205 return -EINVAL; in nl80211_parse_sched_scan_plans()
9207 request->scan_plans[0].interval = in nl80211_parse_sched_scan_plans()
9209 if (!request->scan_plans[0].interval) in nl80211_parse_sched_scan_plans()
9210 return -EINVAL; in nl80211_parse_sched_scan_plans()
9212 if (request->scan_plans[0].interval > in nl80211_parse_sched_scan_plans()
9213 wiphy->max_sched_scan_plan_interval) in nl80211_parse_sched_scan_plans()
9214 request->scan_plans[0].interval = in nl80211_parse_sched_scan_plans()
9215 wiphy->max_sched_scan_plan_interval; in nl80211_parse_sched_scan_plans()
9224 return -EINVAL; in nl80211_parse_sched_scan_plans()
9234 return -EINVAL; in nl80211_parse_sched_scan_plans()
9236 request->scan_plans[i].interval = in nl80211_parse_sched_scan_plans()
9238 if (!request->scan_plans[i].interval || in nl80211_parse_sched_scan_plans()
9239 request->scan_plans[i].interval > in nl80211_parse_sched_scan_plans()
9240 wiphy->max_sched_scan_plan_interval) in nl80211_parse_sched_scan_plans()
9241 return -EINVAL; in nl80211_parse_sched_scan_plans()
9244 request->scan_plans[i].iterations = in nl80211_parse_sched_scan_plans()
9246 if (!request->scan_plans[i].iterations || in nl80211_parse_sched_scan_plans()
9247 (request->scan_plans[i].iterations > in nl80211_parse_sched_scan_plans()
9248 wiphy->max_sched_scan_plan_iterations)) in nl80211_parse_sched_scan_plans()
9249 return -EINVAL; in nl80211_parse_sched_scan_plans()
9250 } else if (i < n_plans - 1) { in nl80211_parse_sched_scan_plans()
9255 return -EINVAL; in nl80211_parse_sched_scan_plans()
9265 if (request->scan_plans[n_plans - 1].iterations) in nl80211_parse_sched_scan_plans()
9266 return -EINVAL; in nl80211_parse_sched_scan_plans()
9283 ret = -EOPNOTSUPP; in nl80211_parse_sched_scan_per_band_rssi()
9286 match_sets->per_band_rssi_thold[i] = in nl80211_parse_sched_scan_per_band_rssi()
9292 match_sets->per_band_rssi_thold[i] = rssi_thold; in nl80211_parse_sched_scan_per_band_rssi()
9298 return -EINVAL; in nl80211_parse_sched_scan_per_band_rssi()
9300 match_sets->per_band_rssi_thold[band] = nla_get_s32(attr); in nl80211_parse_sched_scan_per_band_rssi()
9322 return ERR_PTR(-EINVAL); in nl80211_parse_sched_scan()
9332 if (n_ssids > wiphy->max_sched_scan_ssids) in nl80211_parse_sched_scan()
9333 return ERR_PTR(-EINVAL); in nl80211_parse_sched_scan()
9342 * global RSSI for all other matchsets - if there are other matchsets. in nl80211_parse_sched_scan()
9361 return ERR_PTR(-EINVAL); in nl80211_parse_sched_scan()
9380 return ERR_PTR(-EINVAL); in nl80211_parse_sched_scan()
9387 if (ie_len > wiphy->max_sched_scan_ie_len) in nl80211_parse_sched_scan()
9388 return ERR_PTR(-EINVAL); in nl80211_parse_sched_scan()
9396 return ERR_PTR(-EINVAL); in nl80211_parse_sched_scan()
9409 return ERR_PTR(-EINVAL); in nl80211_parse_sched_scan()
9414 if (!n_plans || n_plans > wiphy->max_sched_scan_plans) in nl80211_parse_sched_scan()
9415 return ERR_PTR(-EINVAL); in nl80211_parse_sched_scan()
9421 return ERR_PTR(-EINVAL); in nl80211_parse_sched_scan()
9424 + sizeof(*request->ssids) * n_ssids in nl80211_parse_sched_scan()
9425 + sizeof(*request->match_sets) * n_match_sets in nl80211_parse_sched_scan()
9426 + sizeof(*request->scan_plans) * n_plans in nl80211_parse_sched_scan()
9427 + sizeof(*request->channels) * n_channels in nl80211_parse_sched_scan()
9430 return ERR_PTR(-ENOMEM); in nl80211_parse_sched_scan()
9433 request->ssids = (void *)&request->channels[n_channels]; in nl80211_parse_sched_scan()
9434 request->n_ssids = n_ssids; in nl80211_parse_sched_scan()
9437 request->ie = (void *)(request->ssids + n_ssids); in nl80211_parse_sched_scan()
9439 request->ie = (void *)(request->channels + n_channels); in nl80211_parse_sched_scan()
9443 if (request->ie) in nl80211_parse_sched_scan()
9444 request->match_sets = (void *)(request->ie + ie_len); in nl80211_parse_sched_scan()
9446 request->match_sets = in nl80211_parse_sched_scan()
9447 (void *)(request->ssids + n_ssids); in nl80211_parse_sched_scan()
9449 request->match_sets = in nl80211_parse_sched_scan()
9450 (void *)(request->channels + n_channels); in nl80211_parse_sched_scan()
9452 request->n_match_sets = n_match_sets; in nl80211_parse_sched_scan()
9455 request->scan_plans = (void *)(request->match_sets + in nl80211_parse_sched_scan()
9457 else if (request->ie) in nl80211_parse_sched_scan()
9458 request->scan_plans = (void *)(request->ie + ie_len); in nl80211_parse_sched_scan()
9460 request->scan_plans = (void *)(request->ssids + n_ssids); in nl80211_parse_sched_scan()
9462 request->scan_plans = (void *)(request->channels + n_channels); in nl80211_parse_sched_scan()
9464 request->n_scan_plans = n_plans; in nl80211_parse_sched_scan()
9477 err = -EINVAL; in nl80211_parse_sched_scan()
9482 if (chan->flags & IEEE80211_CHAN_DISABLED) in nl80211_parse_sched_scan()
9485 request->channels[i] = chan; in nl80211_parse_sched_scan()
9493 if (!wiphy->bands[band]) in nl80211_parse_sched_scan()
9495 for (j = 0; j < wiphy->bands[band]->n_channels; j++) { in nl80211_parse_sched_scan()
9498 chan = &wiphy->bands[band]->channels[j]; in nl80211_parse_sched_scan()
9500 if (chan->flags & IEEE80211_CHAN_DISABLED) in nl80211_parse_sched_scan()
9503 request->channels[i] = chan; in nl80211_parse_sched_scan()
9510 err = -EINVAL; in nl80211_parse_sched_scan()
9514 request->n_channels = i; in nl80211_parse_sched_scan()
9521 err = -EINVAL; in nl80211_parse_sched_scan()
9524 request->ssids[i].ssid_len = nla_len(attr); in nl80211_parse_sched_scan()
9525 memcpy(request->ssids[i].ssid, nla_data(attr), in nl80211_parse_sched_scan()
9558 err = -EINVAL; in nl80211_parse_sched_scan()
9563 memcpy(request->match_sets[i].ssid.ssid, in nl80211_parse_sched_scan()
9565 request->match_sets[i].ssid.ssid_len = in nl80211_parse_sched_scan()
9569 memcpy(request->match_sets[i].bssid, in nl80211_parse_sched_scan()
9572 /* special attribute - old implementation w/a */ in nl80211_parse_sched_scan()
9573 request->match_sets[i].rssi_thold = default_match_rssi; in nl80211_parse_sched_scan()
9576 request->match_sets[i].rssi_thold = in nl80211_parse_sched_scan()
9581 &request->match_sets[i], in nl80211_parse_sched_scan()
9583 request->match_sets[i].rssi_thold); in nl80211_parse_sched_scan()
9592 request->match_sets[0].rssi_thold = default_match_rssi; in nl80211_parse_sched_scan()
9594 request->min_rssi_thold = INT_MAX; in nl80211_parse_sched_scan()
9596 request->min_rssi_thold = in nl80211_parse_sched_scan()
9597 min(request->match_sets[i].rssi_thold, in nl80211_parse_sched_scan()
9598 request->min_rssi_thold); in nl80211_parse_sched_scan()
9600 request->min_rssi_thold = NL80211_SCAN_RSSI_THOLD_OFF; in nl80211_parse_sched_scan()
9604 request->ie_len = ie_len; in nl80211_parse_sched_scan()
9605 memcpy((void *)request->ie, in nl80211_parse_sched_scan()
9607 request->ie_len); in nl80211_parse_sched_scan()
9615 request->delay = in nl80211_parse_sched_scan()
9619 request->relative_rssi = nla_get_s8( in nl80211_parse_sched_scan()
9621 request->relative_rssi_set = true; in nl80211_parse_sched_scan()
9624 if (request->relative_rssi_set && in nl80211_parse_sched_scan()
9630 request->rssi_adjust.band = rssi_adjust->band; in nl80211_parse_sched_scan()
9631 request->rssi_adjust.delta = rssi_adjust->delta; in nl80211_parse_sched_scan()
9632 if (!is_band_valid(wiphy, request->rssi_adjust.band)) { in nl80211_parse_sched_scan()
9633 err = -EINVAL; in nl80211_parse_sched_scan()
9642 request->scan_start = jiffies; in nl80211_parse_sched_scan()
9654 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_start_sched_scan()
9655 struct net_device *dev = info->user_ptr[1]; in nl80211_start_sched_scan()
9656 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_start_sched_scan()
9661 if (!rdev->wiphy.max_sched_scan_reqs || !rdev->ops->sched_scan_start) in nl80211_start_sched_scan()
9662 return -EOPNOTSUPP; in nl80211_start_sched_scan()
9664 want_multi = info->attrs[NL80211_ATTR_SCHED_SCAN_MULTI]; in nl80211_start_sched_scan()
9669 sched_scan_req = nl80211_parse_sched_scan(&rdev->wiphy, wdev, in nl80211_start_sched_scan()
9670 info->attrs, in nl80211_start_sched_scan()
9671 rdev->wiphy.max_match_sets); in nl80211_start_sched_scan()
9678 * or if driver does not support multi-scheduled scan in nl80211_start_sched_scan()
9680 if (want_multi && rdev->wiphy.max_sched_scan_reqs > 1) in nl80211_start_sched_scan()
9681 sched_scan_req->reqid = cfg80211_assign_cookie(rdev); in nl80211_start_sched_scan()
9687 sched_scan_req->dev = dev; in nl80211_start_sched_scan()
9688 sched_scan_req->wiphy = &rdev->wiphy; in nl80211_start_sched_scan()
9690 if (info->attrs[NL80211_ATTR_SOCKET_OWNER]) in nl80211_start_sched_scan()
9691 sched_scan_req->owner_nlportid = info->snd_portid; in nl80211_start_sched_scan()
9708 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_stop_sched_scan()
9711 if (!rdev->wiphy.max_sched_scan_reqs || !rdev->ops->sched_scan_stop) in nl80211_stop_sched_scan()
9712 return -EOPNOTSUPP; in nl80211_stop_sched_scan()
9714 if (info->attrs[NL80211_ATTR_COOKIE]) { in nl80211_stop_sched_scan()
9715 cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); in nl80211_stop_sched_scan()
9719 req = list_first_or_null_rcu(&rdev->sched_scan_req_list, in nl80211_stop_sched_scan()
9722 if (!req || req->reqid || in nl80211_stop_sched_scan()
9723 (req->owner_nlportid && in nl80211_stop_sched_scan()
9724 req->owner_nlportid != info->snd_portid)) in nl80211_stop_sched_scan()
9725 return -ENOENT; in nl80211_stop_sched_scan()
9733 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_start_radar_detection()
9734 struct net_device *dev = info->user_ptr[1]; in nl80211_start_radar_detection()
9735 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_start_radar_detection()
9736 struct wiphy *wiphy = wdev->wiphy; in nl80211_start_radar_detection()
9740 int err = -EINVAL; in nl80211_start_radar_detection()
9742 flush_delayed_work(&rdev->dfs_update_channels_wk); in nl80211_start_radar_detection()
9754 err = cfg80211_chandef_dfs_required(wiphy, &chandef, wdev->iftype); in nl80211_start_radar_detection()
9759 err = -EINVAL; in nl80211_start_radar_detection()
9764 err = -EINVAL; in nl80211_start_radar_detection()
9768 if (nla_get_flag(info->attrs[NL80211_ATTR_RADAR_BACKGROUND])) { in nl80211_start_radar_detection()
9775 err = -EBUSY; in nl80211_start_radar_detection()
9779 if (wdev->cac_started) { in nl80211_start_radar_detection()
9780 err = -EBUSY; in nl80211_start_radar_detection()
9786 err = -EOPNOTSUPP; in nl80211_start_radar_detection()
9790 if (!rdev->ops->start_radar_detection) { in nl80211_start_radar_detection()
9791 err = -EOPNOTSUPP; in nl80211_start_radar_detection()
9795 cac_time_ms = cfg80211_chandef_dfs_cac_time(&rdev->wiphy, &chandef); in nl80211_start_radar_detection()
9801 wdev->links[0].ap.chandef = chandef; in nl80211_start_radar_detection()
9802 wdev->cac_started = true; in nl80211_start_radar_detection()
9803 wdev->cac_start_time = jiffies; in nl80211_start_radar_detection()
9804 wdev->cac_time_ms = cac_time_ms; in nl80211_start_radar_detection()
9815 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_notify_radar_detection()
9816 struct net_device *dev = info->user_ptr[1]; in nl80211_notify_radar_detection()
9817 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_notify_radar_detection()
9818 struct wiphy *wiphy = wdev->wiphy; in nl80211_notify_radar_detection()
9827 return -EINVAL; in nl80211_notify_radar_detection()
9836 err = cfg80211_chandef_dfs_required(wiphy, &chandef, wdev->iftype); in nl80211_notify_radar_detection()
9845 return -EINVAL; in nl80211_notify_radar_detection()
9851 if (chandef.chan->dfs_state == NL80211_DFS_UNAVAILABLE) in nl80211_notify_radar_detection()
9858 rdev->radar_chandef = chandef; in nl80211_notify_radar_detection()
9861 queue_work(cfg80211_wq, &rdev->propagate_radar_detect_wk); in nl80211_notify_radar_detection()
9868 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_channel_switch()
9869 unsigned int link_id = nl80211_link_id(info->attrs); in nl80211_channel_switch()
9870 struct net_device *dev = info->user_ptr[1]; in nl80211_channel_switch()
9871 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_channel_switch()
9880 if (!rdev->ops->channel_switch || in nl80211_channel_switch()
9881 !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH)) in nl80211_channel_switch()
9882 return -EOPNOTSUPP; in nl80211_channel_switch()
9884 switch (dev->ieee80211_ptr->iftype) { in nl80211_channel_switch()
9896 if (!wdev->links[link_id].ap.beacon_interval) in nl80211_channel_switch()
9897 return -ENOTCONN; in nl80211_channel_switch()
9900 if (!wdev->u.ibss.ssid_len) in nl80211_channel_switch()
9901 return -ENOTCONN; in nl80211_channel_switch()
9904 if (!wdev->u.mesh.id_len) in nl80211_channel_switch()
9905 return -ENOTCONN; in nl80211_channel_switch()
9908 return -EOPNOTSUPP; in nl80211_channel_switch()
9912 params.beacon_csa.ftm_responder = -1; in nl80211_channel_switch()
9914 if (!info->attrs[NL80211_ATTR_WIPHY_FREQ] || in nl80211_channel_switch()
9915 !info->attrs[NL80211_ATTR_CH_SWITCH_COUNT]) in nl80211_channel_switch()
9916 return -EINVAL; in nl80211_channel_switch()
9919 if (need_new_beacon && !info->attrs[NL80211_ATTR_CSA_IES]) in nl80211_channel_switch()
9920 return -EINVAL; in nl80211_channel_switch()
9925 cs_count = nla_get_u32(info->attrs[NL80211_ATTR_CH_SWITCH_COUNT]); in nl80211_channel_switch()
9927 return -EINVAL; in nl80211_channel_switch()
9934 err = nl80211_parse_beacon(rdev, info->attrs, &params.beacon_after); in nl80211_channel_switch()
9941 err = -ENOMEM; in nl80211_channel_switch()
9946 info->attrs[NL80211_ATTR_CSA_IES], in nl80211_channel_switch()
9947 nl80211_policy, info->extack); in nl80211_channel_switch()
9956 err = -EINVAL; in nl80211_channel_switch()
9962 err = -EINVAL; in nl80211_channel_switch()
9967 if (rdev->wiphy.max_num_csa_counters && in nl80211_channel_switch()
9969 rdev->wiphy.max_num_csa_counters)) { in nl80211_channel_switch()
9970 err = -EINVAL; in nl80211_channel_switch()
9977 /* sanity checks - counters should fit and be the same */ in nl80211_channel_switch()
9982 err = -EINVAL; in nl80211_channel_switch()
9987 err = -EINVAL; in nl80211_channel_switch()
9995 err = -EINVAL; in nl80211_channel_switch()
10000 if (rdev->wiphy.max_num_csa_counters && in nl80211_channel_switch()
10002 rdev->wiphy.max_num_csa_counters)) { in nl80211_channel_switch()
10003 err = -EINVAL; in nl80211_channel_switch()
10010 /* sanity checks - counters should fit and be the same */ in nl80211_channel_switch()
10015 err = -EINVAL; in nl80211_channel_switch()
10021 err = -EINVAL; in nl80211_channel_switch()
10032 if (!cfg80211_reg_can_beacon_relax(&rdev->wiphy, &params.chandef, in nl80211_channel_switch()
10033 wdev->iftype)) { in nl80211_channel_switch()
10034 err = -EINVAL; in nl80211_channel_switch()
10038 err = cfg80211_chandef_dfs_required(wdev->wiphy, in nl80211_channel_switch()
10040 wdev->iftype); in nl80211_channel_switch()
10047 !nla_get_flag(info->attrs[NL80211_ATTR_HANDLE_DFS])) { in nl80211_channel_switch()
10048 err = -EINVAL; in nl80211_channel_switch()
10053 if (info->attrs[NL80211_ATTR_CH_SWITCH_BLOCK_TX]) in nl80211_channel_switch()
10073 struct cfg80211_bss *res = &intbss->pub; in nl80211_send_bss()
10081 hdr = nl80211hdr_put(msg, NETLINK_CB(cb->skb).portid, seq, flags, in nl80211_send_bss()
10084 return -1; in nl80211_send_bss()
10088 if (nla_put_u32(msg, NL80211_ATTR_GENERATION, rdev->bss_generation)) in nl80211_send_bss()
10090 if (wdev->netdev && in nl80211_send_bss()
10091 nla_put_u32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex)) in nl80211_send_bss()
10100 if ((!is_zero_ether_addr(res->bssid) && in nl80211_send_bss()
10101 nla_put(msg, NL80211_BSS_BSSID, ETH_ALEN, res->bssid))) in nl80211_send_bss()
10106 if (rcu_access_pointer(res->proberesp_ies) && in nl80211_send_bss()
10113 ies = rcu_dereference(res->ies); in nl80211_send_bss()
10115 if (nla_put_u64_64bit(msg, NL80211_BSS_TSF, ies->tsf, in nl80211_send_bss()
10118 if (ies->len && nla_put(msg, NL80211_BSS_INFORMATION_ELEMENTS, in nl80211_send_bss()
10119 ies->len, ies->data)) in nl80211_send_bss()
10124 ies = rcu_dereference(res->beacon_ies); in nl80211_send_bss()
10125 if (ies && ies->from_beacon) { in nl80211_send_bss()
10126 if (nla_put_u64_64bit(msg, NL80211_BSS_BEACON_TSF, ies->tsf, in nl80211_send_bss()
10129 if (ies->len && nla_put(msg, NL80211_BSS_BEACON_IES, in nl80211_send_bss()
10130 ies->len, ies->data)) in nl80211_send_bss()
10135 if (res->beacon_interval && in nl80211_send_bss()
10136 nla_put_u16(msg, NL80211_BSS_BEACON_INTERVAL, res->beacon_interval)) in nl80211_send_bss()
10138 if (nla_put_u16(msg, NL80211_BSS_CAPABILITY, res->capability) || in nl80211_send_bss()
10139 nla_put_u32(msg, NL80211_BSS_FREQUENCY, res->channel->center_freq) || in nl80211_send_bss()
10141 res->channel->freq_offset) || in nl80211_send_bss()
10142 nla_put_u32(msg, NL80211_BSS_CHAN_WIDTH, res->scan_width) || in nl80211_send_bss()
10144 jiffies_to_msecs(jiffies - intbss->ts))) in nl80211_send_bss()
10147 if (intbss->parent_tsf && in nl80211_send_bss()
10149 intbss->parent_tsf, NL80211_BSS_PAD) || in nl80211_send_bss()
10151 intbss->parent_bssid))) in nl80211_send_bss()
10154 if (intbss->ts_boottime && in nl80211_send_bss()
10156 intbss->ts_boottime, NL80211_BSS_PAD)) in nl80211_send_bss()
10159 if (!nl80211_put_signal(msg, intbss->pub.chains, in nl80211_send_bss()
10160 intbss->pub.chain_signal, in nl80211_send_bss()
10164 switch (rdev->wiphy.signal_type) { in nl80211_send_bss()
10166 if (nla_put_u32(msg, NL80211_BSS_SIGNAL_MBM, res->signal)) in nl80211_send_bss()
10170 if (nla_put_u8(msg, NL80211_BSS_SIGNAL_UNSPEC, res->signal)) in nl80211_send_bss()
10177 switch (wdev->iftype) { in nl80211_send_bss()
10181 if (intbss == wdev->links[link_id].client.current_bss && in nl80211_send_bss()
10184 (wdev->valid_links && in nl80211_send_bss()
10188 wdev->u.client.connected_addr))))) in nl80211_send_bss()
10193 if (intbss == wdev->u.ibss.current_bss && in nl80211_send_bss()
10211 return -EMSGSIZE; in nl80211_send_bss()
10219 int start = cb->args[2], idx = 0; in nl80211_dump_scan()
10226 __acquire(&rdev->wiphy.mtx); in nl80211_dump_scan()
10229 spin_lock_bh(&rdev->bss_lock); in nl80211_dump_scan()
10233 * into multiple messages. It is unlikely that any more bss-es will be in nl80211_dump_scan()
10240 cb->seq = rdev->bss_generation; in nl80211_dump_scan()
10242 list_for_each_entry(scan, &rdev->bss_list, list) { in nl80211_dump_scan()
10246 cb->nlh->nlmsg_seq, NLM_F_MULTI, in nl80211_dump_scan()
10248 idx--; in nl80211_dump_scan()
10253 spin_unlock_bh(&rdev->bss_lock); in nl80211_dump_scan()
10256 cb->args[2] = idx; in nl80211_dump_scan()
10257 wiphy_unlock(&rdev->wiphy); in nl80211_dump_scan()
10259 return skb->len; in nl80211_dump_scan()
10271 if (!survey->channel && !allow_radio_stats) in nl80211_send_survey()
10277 return -ENOMEM; in nl80211_send_survey()
10279 if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) in nl80211_send_survey()
10286 if (survey->channel && in nl80211_send_survey()
10288 survey->channel->center_freq)) in nl80211_send_survey()
10291 if (survey->channel && survey->channel->freq_offset && in nl80211_send_survey()
10293 survey->channel->freq_offset)) in nl80211_send_survey()
10296 if ((survey->filled & SURVEY_INFO_NOISE_DBM) && in nl80211_send_survey()
10297 nla_put_u8(msg, NL80211_SURVEY_INFO_NOISE, survey->noise)) in nl80211_send_survey()
10299 if ((survey->filled & SURVEY_INFO_IN_USE) && in nl80211_send_survey()
10302 if ((survey->filled & SURVEY_INFO_TIME) && in nl80211_send_survey()
10304 survey->time, NL80211_SURVEY_INFO_PAD)) in nl80211_send_survey()
10306 if ((survey->filled & SURVEY_INFO_TIME_BUSY) && in nl80211_send_survey()
10308 survey->time_busy, NL80211_SURVEY_INFO_PAD)) in nl80211_send_survey()
10310 if ((survey->filled & SURVEY_INFO_TIME_EXT_BUSY) && in nl80211_send_survey()
10312 survey->time_ext_busy, NL80211_SURVEY_INFO_PAD)) in nl80211_send_survey()
10314 if ((survey->filled & SURVEY_INFO_TIME_RX) && in nl80211_send_survey()
10316 survey->time_rx, NL80211_SURVEY_INFO_PAD)) in nl80211_send_survey()
10318 if ((survey->filled & SURVEY_INFO_TIME_TX) && in nl80211_send_survey()
10320 survey->time_tx, NL80211_SURVEY_INFO_PAD)) in nl80211_send_survey()
10322 if ((survey->filled & SURVEY_INFO_TIME_SCAN) && in nl80211_send_survey()
10324 survey->time_scan, NL80211_SURVEY_INFO_PAD)) in nl80211_send_survey()
10326 if ((survey->filled & SURVEY_INFO_TIME_BSS_RX) && in nl80211_send_survey()
10328 survey->time_bss_rx, NL80211_SURVEY_INFO_PAD)) in nl80211_send_survey()
10338 return -EMSGSIZE; in nl80211_send_survey()
10347 int survey_idx = cb->args[2]; in nl80211_dump_survey()
10353 return -ENOMEM; in nl80211_dump_survey()
10361 __acquire(&rdev->wiphy.mtx); in nl80211_dump_survey()
10366 if (!wdev->netdev) { in nl80211_dump_survey()
10367 res = -EINVAL; in nl80211_dump_survey()
10371 if (!rdev->ops->dump_survey) { in nl80211_dump_survey()
10372 res = -EOPNOTSUPP; in nl80211_dump_survey()
10378 res = rdev_dump_survey(rdev, wdev->netdev, survey_idx, &survey); in nl80211_dump_survey()
10380 if (res == -ENOENT) in nl80211_dump_survey()
10385 /* don't send disabled channels, but do send non-channel data */ in nl80211_dump_survey()
10387 survey.channel->flags & IEEE80211_CHAN_DISABLED) { in nl80211_dump_survey()
10393 NETLINK_CB(cb->skb).portid, in nl80211_dump_survey()
10394 cb->nlh->nlmsg_seq, NLM_F_MULTI, in nl80211_dump_survey()
10395 wdev->netdev, radio_stats, &survey) < 0) in nl80211_dump_survey()
10401 cb->args[2] = survey_idx; in nl80211_dump_survey()
10402 res = skb->len; in nl80211_dump_survey()
10405 wiphy_unlock(&rdev->wiphy); in nl80211_dump_survey()
10418 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_authenticate()
10419 struct net_device *dev = info->user_ptr[1]; in nl80211_authenticate()
10429 if (!info->attrs[NL80211_ATTR_MAC]) in nl80211_authenticate()
10430 return -EINVAL; in nl80211_authenticate()
10432 if (!info->attrs[NL80211_ATTR_AUTH_TYPE]) in nl80211_authenticate()
10433 return -EINVAL; in nl80211_authenticate()
10435 if (!info->attrs[NL80211_ATTR_SSID]) in nl80211_authenticate()
10436 return -EINVAL; in nl80211_authenticate()
10438 if (!info->attrs[NL80211_ATTR_WIPHY_FREQ]) in nl80211_authenticate()
10439 return -EINVAL; in nl80211_authenticate()
10446 if (key.type != -1 && key.type != NL80211_KEYTYPE_GROUP) in nl80211_authenticate()
10447 return -EINVAL; in nl80211_authenticate()
10449 return -EINVAL; in nl80211_authenticate()
10454 return -EINVAL; in nl80211_authenticate()
10456 return -EINVAL; in nl80211_authenticate()
10466 for (i = 0; i < rdev->wiphy.n_cipher_suites; i++) { in nl80211_authenticate()
10467 if (key.p.cipher == rdev->wiphy.cipher_suites[i]) { in nl80211_authenticate()
10473 return -EINVAL; in nl80211_authenticate()
10476 if (!rdev->ops->auth) in nl80211_authenticate()
10477 return -EOPNOTSUPP; in nl80211_authenticate()
10479 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && in nl80211_authenticate()
10480 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT) in nl80211_authenticate()
10481 return -EOPNOTSUPP; in nl80211_authenticate()
10483 bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_authenticate()
10484 freq = MHZ_TO_KHZ(nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ])); in nl80211_authenticate()
10485 if (info->attrs[NL80211_ATTR_WIPHY_FREQ_OFFSET]) in nl80211_authenticate()
10487 nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ_OFFSET]); in nl80211_authenticate()
10489 chan = nl80211_get_valid_chan(&rdev->wiphy, freq); in nl80211_authenticate()
10491 return -EINVAL; in nl80211_authenticate()
10493 ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); in nl80211_authenticate()
10494 ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]); in nl80211_authenticate()
10496 if (info->attrs[NL80211_ATTR_IE]) { in nl80211_authenticate()
10497 req.ie = nla_data(info->attrs[NL80211_ATTR_IE]); in nl80211_authenticate()
10498 req.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); in nl80211_authenticate()
10501 auth_type = nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]); in nl80211_authenticate()
10503 return -EINVAL; in nl80211_authenticate()
10509 !info->attrs[NL80211_ATTR_AUTH_DATA]) in nl80211_authenticate()
10510 return -EINVAL; in nl80211_authenticate()
10512 if (info->attrs[NL80211_ATTR_AUTH_DATA]) { in nl80211_authenticate()
10517 return -EINVAL; in nl80211_authenticate()
10518 req.auth_data = nla_data(info->attrs[NL80211_ATTR_AUTH_DATA]); in nl80211_authenticate()
10519 req.auth_data_len = nla_len(info->attrs[NL80211_ATTR_AUTH_DATA]); in nl80211_authenticate()
10522 local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; in nl80211_authenticate()
10535 req.link_id = nl80211_link_id_or_invalid(info->attrs); in nl80211_authenticate()
10537 if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_MLO)) in nl80211_authenticate()
10538 return -EINVAL; in nl80211_authenticate()
10539 if (!info->attrs[NL80211_ATTR_MLD_ADDR]) in nl80211_authenticate()
10540 return -EINVAL; in nl80211_authenticate()
10541 req.ap_mld_addr = nla_data(info->attrs[NL80211_ATTR_MLD_ADDR]); in nl80211_authenticate()
10544 req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, in nl80211_authenticate()
10548 return -ENOENT; in nl80211_authenticate()
10550 wdev_lock(dev->ieee80211_ptr); in nl80211_authenticate()
10552 wdev_unlock(dev->ieee80211_ptr); in nl80211_authenticate()
10554 cfg80211_put_bss(&rdev->wiphy, req.bss); in nl80211_authenticate()
10562 if (!info->attrs[NL80211_ATTR_SOCKET_OWNER]) { in validate_pae_over_nl80211()
10564 return -EINVAL; in validate_pae_over_nl80211()
10567 if (!rdev->ops->tx_control_port || in validate_pae_over_nl80211()
10568 !wiphy_ext_feature_isset(&rdev->wiphy, in validate_pae_over_nl80211()
10570 return -EOPNOTSUPP; in validate_pae_over_nl80211()
10582 settings->control_port = info->attrs[NL80211_ATTR_CONTROL_PORT]; in nl80211_crypto_settings()
10584 if (info->attrs[NL80211_ATTR_CONTROL_PORT_ETHERTYPE]) { in nl80211_crypto_settings()
10588 info->attrs[NL80211_ATTR_CONTROL_PORT_ETHERTYPE]); in nl80211_crypto_settings()
10589 settings->control_port_ethertype = cpu_to_be16(proto); in nl80211_crypto_settings()
10590 if (!(rdev->wiphy.flags & WIPHY_FLAG_CONTROL_PORT_PROTOCOL) && in nl80211_crypto_settings()
10592 return -EINVAL; in nl80211_crypto_settings()
10593 if (info->attrs[NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT]) in nl80211_crypto_settings()
10594 settings->control_port_no_encrypt = true; in nl80211_crypto_settings()
10596 settings->control_port_ethertype = cpu_to_be16(ETH_P_PAE); in nl80211_crypto_settings()
10598 if (info->attrs[NL80211_ATTR_CONTROL_PORT_OVER_NL80211]) { in nl80211_crypto_settings()
10604 settings->control_port_over_nl80211 = true; in nl80211_crypto_settings()
10606 if (info->attrs[NL80211_ATTR_CONTROL_PORT_NO_PREAUTH]) in nl80211_crypto_settings()
10607 settings->control_port_no_preauth = true; in nl80211_crypto_settings()
10610 if (info->attrs[NL80211_ATTR_CIPHER_SUITES_PAIRWISE]) { in nl80211_crypto_settings()
10614 data = nla_data(info->attrs[NL80211_ATTR_CIPHER_SUITES_PAIRWISE]); in nl80211_crypto_settings()
10615 len = nla_len(info->attrs[NL80211_ATTR_CIPHER_SUITES_PAIRWISE]); in nl80211_crypto_settings()
10616 settings->n_ciphers_pairwise = len / sizeof(u32); in nl80211_crypto_settings()
10619 return -EINVAL; in nl80211_crypto_settings()
10621 if (settings->n_ciphers_pairwise > cipher_limit) in nl80211_crypto_settings()
10622 return -EINVAL; in nl80211_crypto_settings()
10624 memcpy(settings->ciphers_pairwise, data, len); in nl80211_crypto_settings()
10626 for (i = 0; i < settings->n_ciphers_pairwise; i++) in nl80211_crypto_settings()
10628 &rdev->wiphy, in nl80211_crypto_settings()
10629 settings->ciphers_pairwise[i])) in nl80211_crypto_settings()
10630 return -EINVAL; in nl80211_crypto_settings()
10633 if (info->attrs[NL80211_ATTR_CIPHER_SUITE_GROUP]) { in nl80211_crypto_settings()
10634 settings->cipher_group = in nl80211_crypto_settings()
10635 nla_get_u32(info->attrs[NL80211_ATTR_CIPHER_SUITE_GROUP]); in nl80211_crypto_settings()
10636 if (!cfg80211_supported_cipher_suite(&rdev->wiphy, in nl80211_crypto_settings()
10637 settings->cipher_group)) in nl80211_crypto_settings()
10638 return -EINVAL; in nl80211_crypto_settings()
10641 if (info->attrs[NL80211_ATTR_WPA_VERSIONS]) { in nl80211_crypto_settings()
10642 settings->wpa_versions = in nl80211_crypto_settings()
10643 nla_get_u32(info->attrs[NL80211_ATTR_WPA_VERSIONS]); in nl80211_crypto_settings()
10644 if (!nl80211_valid_wpa_versions(settings->wpa_versions)) in nl80211_crypto_settings()
10645 return -EINVAL; in nl80211_crypto_settings()
10648 if (info->attrs[NL80211_ATTR_AKM_SUITES]) { in nl80211_crypto_settings()
10652 data = nla_data(info->attrs[NL80211_ATTR_AKM_SUITES]); in nl80211_crypto_settings()
10653 len = nla_len(info->attrs[NL80211_ATTR_AKM_SUITES]); in nl80211_crypto_settings()
10654 settings->n_akm_suites = len / sizeof(u32); in nl80211_crypto_settings()
10657 return -EINVAL; in nl80211_crypto_settings()
10659 if (settings->n_akm_suites > rdev->wiphy.max_num_akm_suites) in nl80211_crypto_settings()
10660 return -EINVAL; in nl80211_crypto_settings()
10662 memcpy(settings->akm_suites, data, len); in nl80211_crypto_settings()
10665 if (info->attrs[NL80211_ATTR_PMK]) { in nl80211_crypto_settings()
10666 if (nla_len(info->attrs[NL80211_ATTR_PMK]) != WLAN_PMK_LEN) in nl80211_crypto_settings()
10667 return -EINVAL; in nl80211_crypto_settings()
10668 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_crypto_settings()
10670 !wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_crypto_settings()
10672 return -EINVAL; in nl80211_crypto_settings()
10673 settings->psk = nla_data(info->attrs[NL80211_ATTR_PMK]); in nl80211_crypto_settings()
10676 if (info->attrs[NL80211_ATTR_SAE_PASSWORD]) { in nl80211_crypto_settings()
10677 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_crypto_settings()
10679 !wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_crypto_settings()
10681 return -EINVAL; in nl80211_crypto_settings()
10682 settings->sae_pwd = in nl80211_crypto_settings()
10683 nla_data(info->attrs[NL80211_ATTR_SAE_PASSWORD]); in nl80211_crypto_settings()
10684 settings->sae_pwd_len = in nl80211_crypto_settings()
10685 nla_len(info->attrs[NL80211_ATTR_SAE_PASSWORD]); in nl80211_crypto_settings()
10688 if (info->attrs[NL80211_ATTR_SAE_PWE]) in nl80211_crypto_settings()
10689 settings->sae_pwe = in nl80211_crypto_settings()
10690 nla_get_u8(info->attrs[NL80211_ATTR_SAE_PWE]); in nl80211_crypto_settings()
10692 settings->sae_pwe = NL80211_SAE_PWE_UNSPECIFIED; in nl80211_crypto_settings()
10708 return ERR_PTR(-EINVAL); in nl80211_assoc_bss()
10716 chan = nl80211_get_valid_chan(&rdev->wiphy, freq); in nl80211_assoc_bss()
10718 return ERR_PTR(-EINVAL); in nl80211_assoc_bss()
10720 bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, in nl80211_assoc_bss()
10725 return ERR_PTR(-ENOENT); in nl80211_assoc_bss()
10733 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_associate()
10734 struct net_device *dev = info->user_ptr[1]; in nl80211_associate()
10741 if (dev->ieee80211_ptr->conn_owner_nlportid && in nl80211_associate()
10742 dev->ieee80211_ptr->conn_owner_nlportid != info->snd_portid) in nl80211_associate()
10743 return -EPERM; in nl80211_associate()
10745 if (!info->attrs[NL80211_ATTR_SSID]) in nl80211_associate()
10746 return -EINVAL; in nl80211_associate()
10748 if (!rdev->ops->assoc) in nl80211_associate()
10749 return -EOPNOTSUPP; in nl80211_associate()
10751 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && in nl80211_associate()
10752 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT) in nl80211_associate()
10753 return -EOPNOTSUPP; in nl80211_associate()
10755 ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); in nl80211_associate()
10756 ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]); in nl80211_associate()
10758 if (info->attrs[NL80211_ATTR_IE]) { in nl80211_associate()
10759 req.ie = nla_data(info->attrs[NL80211_ATTR_IE]); in nl80211_associate()
10760 req.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); in nl80211_associate()
10765 "non-inheritance makes no sense"); in nl80211_associate()
10766 return -EINVAL; in nl80211_associate()
10770 if (info->attrs[NL80211_ATTR_USE_MFP]) { in nl80211_associate()
10772 nla_get_u32(info->attrs[NL80211_ATTR_USE_MFP]); in nl80211_associate()
10776 return -EINVAL; in nl80211_associate()
10779 if (info->attrs[NL80211_ATTR_PREV_BSSID]) in nl80211_associate()
10780 req.prev_bssid = nla_data(info->attrs[NL80211_ATTR_PREV_BSSID]); in nl80211_associate()
10782 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HT])) in nl80211_associate()
10785 if (info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) in nl80211_associate()
10787 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]), in nl80211_associate()
10790 if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) { in nl80211_associate()
10791 if (!info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) in nl80211_associate()
10792 return -EINVAL; in nl80211_associate()
10794 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]), in nl80211_associate()
10798 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_VHT])) in nl80211_associate()
10801 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HE])) in nl80211_associate()
10804 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_EHT])) in nl80211_associate()
10807 if (info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]) in nl80211_associate()
10809 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]), in nl80211_associate()
10812 if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) { in nl80211_associate()
10813 if (!info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]) in nl80211_associate()
10814 return -EINVAL; in nl80211_associate()
10816 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]), in nl80211_associate()
10820 if (nla_get_flag(info->attrs[NL80211_ATTR_USE_RRM])) { in nl80211_associate()
10821 if (!((rdev->wiphy.features & in nl80211_associate()
10823 (rdev->wiphy.features & NL80211_FEATURE_QUIET)) && in nl80211_associate()
10824 !wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_associate()
10826 return -EINVAL; in nl80211_associate()
10830 if (info->attrs[NL80211_ATTR_FILS_KEK]) { in nl80211_associate()
10831 req.fils_kek = nla_data(info->attrs[NL80211_ATTR_FILS_KEK]); in nl80211_associate()
10832 req.fils_kek_len = nla_len(info->attrs[NL80211_ATTR_FILS_KEK]); in nl80211_associate()
10833 if (!info->attrs[NL80211_ATTR_FILS_NONCES]) in nl80211_associate()
10834 return -EINVAL; in nl80211_associate()
10836 nla_data(info->attrs[NL80211_ATTR_FILS_NONCES]); in nl80211_associate()
10839 if (info->attrs[NL80211_ATTR_S1G_CAPABILITY_MASK]) { in nl80211_associate()
10840 if (!info->attrs[NL80211_ATTR_S1G_CAPABILITY]) in nl80211_associate()
10841 return -EINVAL; in nl80211_associate()
10843 nla_data(info->attrs[NL80211_ATTR_S1G_CAPABILITY_MASK]), in nl80211_associate()
10847 if (info->attrs[NL80211_ATTR_S1G_CAPABILITY]) { in nl80211_associate()
10848 if (!info->attrs[NL80211_ATTR_S1G_CAPABILITY_MASK]) in nl80211_associate()
10849 return -EINVAL; in nl80211_associate()
10851 nla_data(info->attrs[NL80211_ATTR_S1G_CAPABILITY]), in nl80211_associate()
10855 req.link_id = nl80211_link_id_or_invalid(info->attrs); in nl80211_associate()
10857 if (info->attrs[NL80211_ATTR_MLO_LINKS]) { in nl80211_associate()
10863 return -EINVAL; in nl80211_associate()
10865 if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_MLO)) in nl80211_associate()
10866 return -EINVAL; in nl80211_associate()
10868 if (info->attrs[NL80211_ATTR_MAC] || in nl80211_associate()
10869 info->attrs[NL80211_ATTR_WIPHY_FREQ] || in nl80211_associate()
10870 !info->attrs[NL80211_ATTR_MLD_ADDR]) in nl80211_associate()
10871 return -EINVAL; in nl80211_associate()
10873 req.ap_mld_addr = nla_data(info->attrs[NL80211_ATTR_MLD_ADDR]); in nl80211_associate()
10877 return -ENOMEM; in nl80211_associate()
10880 info->attrs[NL80211_ATTR_MLO_LINKS], in nl80211_associate()
10888 err = -EINVAL; in nl80211_associate()
10895 err = -EINVAL; in nl80211_associate()
10918 err = -EINVAL; in nl80211_associate()
10926 "cannot deal with non-inheritance"); in nl80211_associate()
10927 err = -EINVAL; in nl80211_associate()
10934 err = -EINVAL; in nl80211_associate()
10940 "cannot have per-link elems on assoc link"); in nl80211_associate()
10941 err = -EINVAL; in nl80211_associate()
10949 return -EINVAL; in nl80211_associate()
10951 req.bss = nl80211_assoc_bss(rdev, ssid, ssid_len, info->attrs, in nl80211_associate()
10959 wdev_lock(dev->ieee80211_ptr); in nl80211_associate()
10963 if (!err && info->attrs[NL80211_ATTR_SOCKET_OWNER]) { in nl80211_associate()
10964 dev->ieee80211_ptr->conn_owner_nlportid = in nl80211_associate()
10965 info->snd_portid; in nl80211_associate()
10966 memcpy(dev->ieee80211_ptr->disconnect_bssid, in nl80211_associate()
10970 wdev_unlock(dev->ieee80211_ptr); in nl80211_associate()
10975 cfg80211_put_bss(&rdev->wiphy, req.links[link_id].bss); in nl80211_associate()
10976 cfg80211_put_bss(&rdev->wiphy, req.bss); in nl80211_associate()
10984 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_deauthenticate()
10985 struct net_device *dev = info->user_ptr[1]; in nl80211_deauthenticate()
10991 if (dev->ieee80211_ptr->conn_owner_nlportid && in nl80211_deauthenticate()
10992 dev->ieee80211_ptr->conn_owner_nlportid != info->snd_portid) in nl80211_deauthenticate()
10993 return -EPERM; in nl80211_deauthenticate()
10995 if (!info->attrs[NL80211_ATTR_MAC]) in nl80211_deauthenticate()
10996 return -EINVAL; in nl80211_deauthenticate()
10998 if (!info->attrs[NL80211_ATTR_REASON_CODE]) in nl80211_deauthenticate()
10999 return -EINVAL; in nl80211_deauthenticate()
11001 if (!rdev->ops->deauth) in nl80211_deauthenticate()
11002 return -EOPNOTSUPP; in nl80211_deauthenticate()
11004 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && in nl80211_deauthenticate()
11005 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT) in nl80211_deauthenticate()
11006 return -EOPNOTSUPP; in nl80211_deauthenticate()
11008 bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_deauthenticate()
11010 reason_code = nla_get_u16(info->attrs[NL80211_ATTR_REASON_CODE]); in nl80211_deauthenticate()
11013 return -EINVAL; in nl80211_deauthenticate()
11016 if (info->attrs[NL80211_ATTR_IE]) { in nl80211_deauthenticate()
11017 ie = nla_data(info->attrs[NL80211_ATTR_IE]); in nl80211_deauthenticate()
11018 ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); in nl80211_deauthenticate()
11021 local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; in nl80211_deauthenticate()
11023 wdev_lock(dev->ieee80211_ptr); in nl80211_deauthenticate()
11026 wdev_unlock(dev->ieee80211_ptr); in nl80211_deauthenticate()
11032 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_disassociate()
11033 struct net_device *dev = info->user_ptr[1]; in nl80211_disassociate()
11039 if (dev->ieee80211_ptr->conn_owner_nlportid && in nl80211_disassociate()
11040 dev->ieee80211_ptr->conn_owner_nlportid != info->snd_portid) in nl80211_disassociate()
11041 return -EPERM; in nl80211_disassociate()
11043 if (!info->attrs[NL80211_ATTR_MAC]) in nl80211_disassociate()
11044 return -EINVAL; in nl80211_disassociate()
11046 if (!info->attrs[NL80211_ATTR_REASON_CODE]) in nl80211_disassociate()
11047 return -EINVAL; in nl80211_disassociate()
11049 if (!rdev->ops->disassoc) in nl80211_disassociate()
11050 return -EOPNOTSUPP; in nl80211_disassociate()
11052 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && in nl80211_disassociate()
11053 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT) in nl80211_disassociate()
11054 return -EOPNOTSUPP; in nl80211_disassociate()
11056 bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_disassociate()
11058 reason_code = nla_get_u16(info->attrs[NL80211_ATTR_REASON_CODE]); in nl80211_disassociate()
11061 return -EINVAL; in nl80211_disassociate()
11064 if (info->attrs[NL80211_ATTR_IE]) { in nl80211_disassociate()
11065 ie = nla_data(info->attrs[NL80211_ATTR_IE]); in nl80211_disassociate()
11066 ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); in nl80211_disassociate()
11069 local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; in nl80211_disassociate()
11071 wdev_lock(dev->ieee80211_ptr); in nl80211_disassociate()
11074 wdev_unlock(dev->ieee80211_ptr); in nl80211_disassociate()
11083 struct wiphy *wiphy = &rdev->wiphy; in nl80211_parse_mcast_rate()
11090 sband = wiphy->bands[band]; in nl80211_parse_mcast_rate()
11094 for (i = 0; i < sband->n_bitrates; i++) { in nl80211_parse_mcast_rate()
11095 if (sband->bitrates[i].bitrate == rateval) { in nl80211_parse_mcast_rate()
11108 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_join_ibss()
11109 struct net_device *dev = info->user_ptr[1]; in nl80211_join_ibss()
11117 if (!info->attrs[NL80211_ATTR_SSID] || in nl80211_join_ibss()
11118 !nla_len(info->attrs[NL80211_ATTR_SSID])) in nl80211_join_ibss()
11119 return -EINVAL; in nl80211_join_ibss()
11123 if (info->attrs[NL80211_ATTR_BEACON_INTERVAL]) in nl80211_join_ibss()
11125 nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]); in nl80211_join_ibss()
11132 if (!rdev->ops->join_ibss) in nl80211_join_ibss()
11133 return -EOPNOTSUPP; in nl80211_join_ibss()
11135 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC) in nl80211_join_ibss()
11136 return -EOPNOTSUPP; in nl80211_join_ibss()
11138 wiphy = &rdev->wiphy; in nl80211_join_ibss()
11140 if (info->attrs[NL80211_ATTR_MAC]) { in nl80211_join_ibss()
11141 ibss.bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_join_ibss()
11144 return -EINVAL; in nl80211_join_ibss()
11146 ibss.ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); in nl80211_join_ibss()
11147 ibss.ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]); in nl80211_join_ibss()
11149 if (info->attrs[NL80211_ATTR_IE]) { in nl80211_join_ibss()
11150 ibss.ie = nla_data(info->attrs[NL80211_ATTR_IE]); in nl80211_join_ibss()
11151 ibss.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); in nl80211_join_ibss()
11158 if (!cfg80211_reg_can_beacon(&rdev->wiphy, &ibss.chandef, in nl80211_join_ibss()
11160 return -EINVAL; in nl80211_join_ibss()
11162 switch (ibss.chandef.width) { in nl80211_join_ibss()
11169 if (!(rdev->wiphy.features & NL80211_FEATURE_HT_IBSS)) in nl80211_join_ibss()
11170 return -EINVAL; in nl80211_join_ibss()
11175 if (!(rdev->wiphy.features & NL80211_FEATURE_HT_IBSS)) in nl80211_join_ibss()
11176 return -EINVAL; in nl80211_join_ibss()
11177 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_join_ibss()
11179 return -EINVAL; in nl80211_join_ibss()
11182 return -EINVAL; in nl80211_join_ibss()
11184 return -EINVAL; in nl80211_join_ibss()
11187 ibss.channel_fixed = !!info->attrs[NL80211_ATTR_FREQ_FIXED]; in nl80211_join_ibss()
11188 ibss.privacy = !!info->attrs[NL80211_ATTR_PRIVACY]; in nl80211_join_ibss()
11190 if (info->attrs[NL80211_ATTR_BSS_BASIC_RATES]) { in nl80211_join_ibss()
11192 nla_data(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]); in nl80211_join_ibss()
11194 nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]); in nl80211_join_ibss()
11196 wiphy->bands[ibss.chandef.chan->band]; in nl80211_join_ibss()
11204 if (info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) in nl80211_join_ibss()
11206 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]), in nl80211_join_ibss()
11209 if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) { in nl80211_join_ibss()
11210 if (!info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) in nl80211_join_ibss()
11211 return -EINVAL; in nl80211_join_ibss()
11213 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]), in nl80211_join_ibss()
11217 if (info->attrs[NL80211_ATTR_MCAST_RATE] && in nl80211_join_ibss()
11219 nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE]))) in nl80211_join_ibss()
11220 return -EINVAL; in nl80211_join_ibss()
11222 if (ibss.privacy && info->attrs[NL80211_ATTR_KEYS]) { in nl80211_join_ibss()
11229 if ((ibss.chandef.width != NL80211_CHAN_WIDTH_20_NOHT) && in nl80211_join_ibss()
11232 return -EINVAL; in nl80211_join_ibss()
11237 nla_get_flag(info->attrs[NL80211_ATTR_CONTROL_PORT]); in nl80211_join_ibss()
11239 if (info->attrs[NL80211_ATTR_CONTROL_PORT_OVER_NL80211]) { in nl80211_join_ibss()
11251 nla_get_flag(info->attrs[NL80211_ATTR_HANDLE_DFS]); in nl80211_join_ibss()
11253 wdev_lock(dev->ieee80211_ptr); in nl80211_join_ibss()
11257 else if (info->attrs[NL80211_ATTR_SOCKET_OWNER]) in nl80211_join_ibss()
11258 dev->ieee80211_ptr->conn_owner_nlportid = info->snd_portid; in nl80211_join_ibss()
11259 wdev_unlock(dev->ieee80211_ptr); in nl80211_join_ibss()
11266 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_leave_ibss()
11267 struct net_device *dev = info->user_ptr[1]; in nl80211_leave_ibss()
11269 if (!rdev->ops->leave_ibss) in nl80211_leave_ibss()
11270 return -EOPNOTSUPP; in nl80211_leave_ibss()
11272 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC) in nl80211_leave_ibss()
11273 return -EOPNOTSUPP; in nl80211_leave_ibss()
11280 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_mcast_rate()
11281 struct net_device *dev = info->user_ptr[1]; in nl80211_set_mcast_rate()
11285 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC && in nl80211_set_mcast_rate()
11286 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT && in nl80211_set_mcast_rate()
11287 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_OCB) in nl80211_set_mcast_rate()
11288 return -EOPNOTSUPP; in nl80211_set_mcast_rate()
11290 if (!rdev->ops->set_mcast_rate) in nl80211_set_mcast_rate()
11291 return -EOPNOTSUPP; in nl80211_set_mcast_rate()
11295 if (!info->attrs[NL80211_ATTR_MCAST_RATE]) in nl80211_set_mcast_rate()
11296 return -EINVAL; in nl80211_set_mcast_rate()
11298 nla_rate = nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE]); in nl80211_set_mcast_rate()
11300 return -EINVAL; in nl80211_set_mcast_rate()
11327 if (nla_put_u32(skb, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) in __cfg80211_alloc_vendor_skb()
11332 info->vendor_id)) in __cfg80211_alloc_vendor_skb()
11335 info->subcmd)) in __cfg80211_alloc_vendor_skb()
11343 if (wdev->netdev && in __cfg80211_alloc_vendor_skb()
11345 wdev->netdev->ifindex)) in __cfg80211_alloc_vendor_skb()
11353 ((void **)skb->cb)[0] = rdev; in __cfg80211_alloc_vendor_skb()
11354 ((void **)skb->cb)[1] = hdr; in __cfg80211_alloc_vendor_skb()
11355 ((void **)skb->cb)[2] = data; in __cfg80211_alloc_vendor_skb()
11377 if (WARN_ON(vendor_event_idx != -1)) in __cfg80211_alloc_event_skb()
11383 vendor_event_idx >= wiphy->n_vendor_events)) in __cfg80211_alloc_event_skb()
11385 info = &wiphy->vendor_events[vendor_event_idx]; in __cfg80211_alloc_event_skb()
11399 struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0]; in __cfg80211_send_event_skb()
11400 void *hdr = ((void **)skb->cb)[1]; in __cfg80211_send_event_skb()
11402 struct nlattr *data = ((void **)skb->cb)[2]; in __cfg80211_send_event_skb()
11406 memset(skb->cb, 0, sizeof(skb->cb)); in __cfg80211_send_event_skb()
11411 if (nlhdr->nlmsg_pid) { in __cfg80211_send_event_skb()
11412 genlmsg_unicast(wiphy_net(&rdev->wiphy), skb, in __cfg80211_send_event_skb()
11413 nlhdr->nlmsg_pid); in __cfg80211_send_event_skb()
11415 if (data->nla_type == NL80211_ATTR_VENDOR_DATA) in __cfg80211_send_event_skb()
11418 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), in __cfg80211_send_event_skb()
11427 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_testmode_do()
11431 lockdep_assert_held(&rdev->wiphy.mtx); in nl80211_testmode_do()
11434 info->attrs); in nl80211_testmode_do()
11436 if (!rdev->ops->testmode_cmd) in nl80211_testmode_do()
11437 return -EOPNOTSUPP; in nl80211_testmode_do()
11441 if (err != -EINVAL) in nl80211_testmode_do()
11444 } else if (wdev->wiphy != &rdev->wiphy) { in nl80211_testmode_do()
11445 return -EINVAL; in nl80211_testmode_do()
11448 if (!info->attrs[NL80211_ATTR_TESTDATA]) in nl80211_testmode_do()
11449 return -EINVAL; in nl80211_testmode_do()
11451 rdev->cur_cmd_info = info; in nl80211_testmode_do()
11453 nla_data(info->attrs[NL80211_ATTR_TESTDATA]), in nl80211_testmode_do()
11454 nla_len(info->attrs[NL80211_ATTR_TESTDATA])); in nl80211_testmode_do()
11455 rdev->cur_cmd_info = NULL; in nl80211_testmode_do()
11472 if (cb->args[0]) { in nl80211_testmode_dump()
11477 phy_idx = cb->args[0] - 1; in nl80211_testmode_dump()
11481 err = -ENOENT; in nl80211_testmode_dump()
11488 err = -ENOMEM; in nl80211_testmode_dump()
11492 err = nlmsg_parse_deprecated(cb->nlh, in nl80211_testmode_dump()
11499 rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk), attrbuf); in nl80211_testmode_dump()
11504 phy_idx = rdev->wiphy_idx; in nl80211_testmode_dump()
11507 cb->args[1] = (long)attrbuf[NL80211_ATTR_TESTDATA]; in nl80211_testmode_dump()
11510 if (cb->args[1]) { in nl80211_testmode_dump()
11511 data = nla_data((void *)cb->args[1]); in nl80211_testmode_dump()
11512 data_len = nla_len((void *)cb->args[1]); in nl80211_testmode_dump()
11515 if (!rdev->ops->testmode_dump) { in nl80211_testmode_dump()
11516 err = -EOPNOTSUPP; in nl80211_testmode_dump()
11521 void *hdr = nl80211hdr_put(skb, NETLINK_CB(cb->skb).portid, in nl80211_testmode_dump()
11522 cb->nlh->nlmsg_seq, NLM_F_MULTI, in nl80211_testmode_dump()
11542 if (err == -ENOBUFS || err == -ENOENT) { in nl80211_testmode_dump()
11553 err = skb->len; in nl80211_testmode_dump()
11555 cb->args[0] = phy_idx + 1; in nl80211_testmode_dump()
11565 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_connect()
11566 struct net_device *dev = info->user_ptr[1]; in nl80211_connect()
11575 if (!info->attrs[NL80211_ATTR_SSID] || in nl80211_connect()
11576 !nla_len(info->attrs[NL80211_ATTR_SSID])) in nl80211_connect()
11577 return -EINVAL; in nl80211_connect()
11579 if (info->attrs[NL80211_ATTR_AUTH_TYPE]) { in nl80211_connect()
11581 nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]); in nl80211_connect()
11584 return -EINVAL; in nl80211_connect()
11588 connect.privacy = info->attrs[NL80211_ATTR_PRIVACY]; in nl80211_connect()
11590 if (info->attrs[NL80211_ATTR_WANT_1X_4WAY_HS] && in nl80211_connect()
11591 !wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_connect()
11593 return -EINVAL; in nl80211_connect()
11594 connect.want_1x = info->attrs[NL80211_ATTR_WANT_1X_4WAY_HS]; in nl80211_connect()
11601 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && in nl80211_connect()
11602 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT) in nl80211_connect()
11603 return -EOPNOTSUPP; in nl80211_connect()
11605 wiphy = &rdev->wiphy; in nl80211_connect()
11607 connect.bg_scan_period = -1; in nl80211_connect()
11608 if (info->attrs[NL80211_ATTR_BG_SCAN_PERIOD] && in nl80211_connect()
11609 (wiphy->flags & WIPHY_FLAG_SUPPORTS_FW_ROAM)) { in nl80211_connect()
11611 nla_get_u16(info->attrs[NL80211_ATTR_BG_SCAN_PERIOD]); in nl80211_connect()
11614 if (info->attrs[NL80211_ATTR_MAC]) in nl80211_connect()
11615 connect.bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_connect()
11616 else if (info->attrs[NL80211_ATTR_MAC_HINT]) in nl80211_connect()
11618 nla_data(info->attrs[NL80211_ATTR_MAC_HINT]); in nl80211_connect()
11619 connect.ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); in nl80211_connect()
11620 connect.ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]); in nl80211_connect()
11622 if (info->attrs[NL80211_ATTR_IE]) { in nl80211_connect()
11623 connect.ie = nla_data(info->attrs[NL80211_ATTR_IE]); in nl80211_connect()
11624 connect.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); in nl80211_connect()
11627 if (info->attrs[NL80211_ATTR_USE_MFP]) { in nl80211_connect()
11628 connect.mfp = nla_get_u32(info->attrs[NL80211_ATTR_USE_MFP]); in nl80211_connect()
11630 !wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_connect()
11632 return -EOPNOTSUPP; in nl80211_connect()
11637 if (info->attrs[NL80211_ATTR_PREV_BSSID]) in nl80211_connect()
11639 nla_data(info->attrs[NL80211_ATTR_PREV_BSSID]); in nl80211_connect()
11641 if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) in nl80211_connect()
11643 info->attrs[NL80211_ATTR_WIPHY_FREQ])); in nl80211_connect()
11644 if (info->attrs[NL80211_ATTR_WIPHY_FREQ_OFFSET]) in nl80211_connect()
11646 nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ_OFFSET]); in nl80211_connect()
11651 return -EINVAL; in nl80211_connect()
11652 } else if (info->attrs[NL80211_ATTR_WIPHY_FREQ_HINT]) { in nl80211_connect()
11653 freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ_HINT]); in nl80211_connect()
11657 return -EINVAL; in nl80211_connect()
11660 if (info->attrs[NL80211_ATTR_WIPHY_EDMG_CHANNELS]) { in nl80211_connect()
11662 nla_get_u8(info->attrs[NL80211_ATTR_WIPHY_EDMG_CHANNELS]); in nl80211_connect()
11664 if (info->attrs[NL80211_ATTR_WIPHY_EDMG_BW_CONFIG]) in nl80211_connect()
11666 nla_get_u8(info->attrs[NL80211_ATTR_WIPHY_EDMG_BW_CONFIG]); in nl80211_connect()
11669 if (connect.privacy && info->attrs[NL80211_ATTR_KEYS]) { in nl80211_connect()
11675 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HT])) in nl80211_connect()
11678 if (info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) in nl80211_connect()
11680 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]), in nl80211_connect()
11683 if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) { in nl80211_connect()
11684 if (!info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) { in nl80211_connect()
11686 return -EINVAL; in nl80211_connect()
11689 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]), in nl80211_connect()
11693 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_VHT])) in nl80211_connect()
11696 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HE])) in nl80211_connect()
11699 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_EHT])) in nl80211_connect()
11702 if (info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]) in nl80211_connect()
11704 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]), in nl80211_connect()
11707 if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) { in nl80211_connect()
11708 if (!info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]) { in nl80211_connect()
11710 return -EINVAL; in nl80211_connect()
11713 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]), in nl80211_connect()
11717 if (nla_get_flag(info->attrs[NL80211_ATTR_USE_RRM])) { in nl80211_connect()
11718 if (!((rdev->wiphy.features & in nl80211_connect()
11720 (rdev->wiphy.features & NL80211_FEATURE_QUIET)) && in nl80211_connect()
11721 !wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_connect()
11724 return -EINVAL; in nl80211_connect()
11729 connect.pbss = nla_get_flag(info->attrs[NL80211_ATTR_PBSS]); in nl80211_connect()
11730 if (connect.pbss && !rdev->wiphy.bands[NL80211_BAND_60GHZ]) { in nl80211_connect()
11732 return -EOPNOTSUPP; in nl80211_connect()
11735 if (info->attrs[NL80211_ATTR_BSS_SELECT]) { in nl80211_connect()
11736 /* bss selection makes no sense if bssid is set */ in nl80211_connect()
11739 return -EINVAL; in nl80211_connect()
11742 err = parse_bss_select(info->attrs[NL80211_ATTR_BSS_SELECT], in nl80211_connect()
11750 if (wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_connect()
11752 info->attrs[NL80211_ATTR_FILS_ERP_USERNAME] && in nl80211_connect()
11753 info->attrs[NL80211_ATTR_FILS_ERP_REALM] && in nl80211_connect()
11754 info->attrs[NL80211_ATTR_FILS_ERP_NEXT_SEQ_NUM] && in nl80211_connect()
11755 info->attrs[NL80211_ATTR_FILS_ERP_RRK]) { in nl80211_connect()
11757 nla_data(info->attrs[NL80211_ATTR_FILS_ERP_USERNAME]); in nl80211_connect()
11759 nla_len(info->attrs[NL80211_ATTR_FILS_ERP_USERNAME]); in nl80211_connect()
11761 nla_data(info->attrs[NL80211_ATTR_FILS_ERP_REALM]); in nl80211_connect()
11763 nla_len(info->attrs[NL80211_ATTR_FILS_ERP_REALM]); in nl80211_connect()
11766 info->attrs[NL80211_ATTR_FILS_ERP_NEXT_SEQ_NUM]); in nl80211_connect()
11768 nla_data(info->attrs[NL80211_ATTR_FILS_ERP_RRK]); in nl80211_connect()
11770 nla_len(info->attrs[NL80211_ATTR_FILS_ERP_RRK]); in nl80211_connect()
11771 } else if (info->attrs[NL80211_ATTR_FILS_ERP_USERNAME] || in nl80211_connect()
11772 info->attrs[NL80211_ATTR_FILS_ERP_REALM] || in nl80211_connect()
11773 info->attrs[NL80211_ATTR_FILS_ERP_NEXT_SEQ_NUM] || in nl80211_connect()
11774 info->attrs[NL80211_ATTR_FILS_ERP_RRK]) { in nl80211_connect()
11776 return -EINVAL; in nl80211_connect()
11779 if (nla_get_flag(info->attrs[NL80211_ATTR_EXTERNAL_AUTH_SUPPORT])) { in nl80211_connect()
11780 if (!info->attrs[NL80211_ATTR_SOCKET_OWNER]) { in nl80211_connect()
11784 return -EINVAL; in nl80211_connect()
11789 if (nla_get_flag(info->attrs[NL80211_ATTR_MLO_SUPPORT])) in nl80211_connect()
11792 wdev_lock(dev->ieee80211_ptr); in nl80211_connect()
11799 if (!err && info->attrs[NL80211_ATTR_SOCKET_OWNER]) { in nl80211_connect()
11800 dev->ieee80211_ptr->conn_owner_nlportid = info->snd_portid; in nl80211_connect()
11802 memcpy(dev->ieee80211_ptr->disconnect_bssid, in nl80211_connect()
11805 eth_zero_addr(dev->ieee80211_ptr->disconnect_bssid); in nl80211_connect()
11808 wdev_unlock(dev->ieee80211_ptr); in nl80211_connect()
11817 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_update_connect_params()
11818 struct net_device *dev = info->user_ptr[1]; in nl80211_update_connect_params()
11819 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_update_connect_params()
11825 if (!rdev->ops->update_connect_params) in nl80211_update_connect_params()
11826 return -EOPNOTSUPP; in nl80211_update_connect_params()
11828 if (info->attrs[NL80211_ATTR_IE]) { in nl80211_update_connect_params()
11829 connect.ie = nla_data(info->attrs[NL80211_ATTR_IE]); in nl80211_update_connect_params()
11830 connect.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); in nl80211_update_connect_params()
11834 fils_sk_offload = wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_update_connect_params()
11838 * when driver supports fils-sk offload all attributes must be in nl80211_update_connect_params()
11839 * provided. So the else covers "fils-sk-not-all" and in nl80211_update_connect_params()
11840 * "no-fils-sk-any". in nl80211_update_connect_params()
11843 info->attrs[NL80211_ATTR_FILS_ERP_USERNAME] && in nl80211_update_connect_params()
11844 info->attrs[NL80211_ATTR_FILS_ERP_REALM] && in nl80211_update_connect_params()
11845 info->attrs[NL80211_ATTR_FILS_ERP_NEXT_SEQ_NUM] && in nl80211_update_connect_params()
11846 info->attrs[NL80211_ATTR_FILS_ERP_RRK]) { in nl80211_update_connect_params()
11848 nla_data(info->attrs[NL80211_ATTR_FILS_ERP_USERNAME]); in nl80211_update_connect_params()
11850 nla_len(info->attrs[NL80211_ATTR_FILS_ERP_USERNAME]); in nl80211_update_connect_params()
11852 nla_data(info->attrs[NL80211_ATTR_FILS_ERP_REALM]); in nl80211_update_connect_params()
11854 nla_len(info->attrs[NL80211_ATTR_FILS_ERP_REALM]); in nl80211_update_connect_params()
11857 info->attrs[NL80211_ATTR_FILS_ERP_NEXT_SEQ_NUM]); in nl80211_update_connect_params()
11859 nla_data(info->attrs[NL80211_ATTR_FILS_ERP_RRK]); in nl80211_update_connect_params()
11861 nla_len(info->attrs[NL80211_ATTR_FILS_ERP_RRK]); in nl80211_update_connect_params()
11863 } else if (info->attrs[NL80211_ATTR_FILS_ERP_USERNAME] || in nl80211_update_connect_params()
11864 info->attrs[NL80211_ATTR_FILS_ERP_REALM] || in nl80211_update_connect_params()
11865 info->attrs[NL80211_ATTR_FILS_ERP_NEXT_SEQ_NUM] || in nl80211_update_connect_params()
11866 info->attrs[NL80211_ATTR_FILS_ERP_RRK]) { in nl80211_update_connect_params()
11867 return -EINVAL; in nl80211_update_connect_params()
11870 if (info->attrs[NL80211_ATTR_AUTH_TYPE]) { in nl80211_update_connect_params()
11871 auth_type = nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]); in nl80211_update_connect_params()
11874 return -EINVAL; in nl80211_update_connect_params()
11878 return -EINVAL; in nl80211_update_connect_params()
11884 wdev_lock(dev->ieee80211_ptr); in nl80211_update_connect_params()
11885 if (!wdev->connected) in nl80211_update_connect_params()
11886 ret = -ENOLINK; in nl80211_update_connect_params()
11889 wdev_unlock(dev->ieee80211_ptr); in nl80211_update_connect_params()
11896 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_disconnect()
11897 struct net_device *dev = info->user_ptr[1]; in nl80211_disconnect()
11901 if (dev->ieee80211_ptr->conn_owner_nlportid && in nl80211_disconnect()
11902 dev->ieee80211_ptr->conn_owner_nlportid != info->snd_portid) in nl80211_disconnect()
11903 return -EPERM; in nl80211_disconnect()
11905 if (!info->attrs[NL80211_ATTR_REASON_CODE]) in nl80211_disconnect()
11908 reason = nla_get_u16(info->attrs[NL80211_ATTR_REASON_CODE]); in nl80211_disconnect()
11911 return -EINVAL; in nl80211_disconnect()
11913 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && in nl80211_disconnect()
11914 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT) in nl80211_disconnect()
11915 return -EOPNOTSUPP; in nl80211_disconnect()
11917 wdev_lock(dev->ieee80211_ptr); in nl80211_disconnect()
11919 wdev_unlock(dev->ieee80211_ptr); in nl80211_disconnect()
11925 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_wiphy_netns()
11929 if (info->attrs[NL80211_ATTR_PID]) { in nl80211_wiphy_netns()
11930 u32 pid = nla_get_u32(info->attrs[NL80211_ATTR_PID]); in nl80211_wiphy_netns()
11933 } else if (info->attrs[NL80211_ATTR_NETNS_FD]) { in nl80211_wiphy_netns()
11934 u32 fd = nla_get_u32(info->attrs[NL80211_ATTR_NETNS_FD]); in nl80211_wiphy_netns()
11938 return -EINVAL; in nl80211_wiphy_netns()
11947 if (!net_eq(wiphy_net(&rdev->wiphy), net)) in nl80211_wiphy_netns()
11956 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_setdel_pmksa()
11959 struct net_device *dev = info->user_ptr[1]; in nl80211_setdel_pmksa()
11964 if (!info->attrs[NL80211_ATTR_PMKID]) in nl80211_setdel_pmksa()
11965 return -EINVAL; in nl80211_setdel_pmksa()
11967 pmksa.pmkid = nla_data(info->attrs[NL80211_ATTR_PMKID]); in nl80211_setdel_pmksa()
11969 if (info->attrs[NL80211_ATTR_MAC]) { in nl80211_setdel_pmksa()
11970 pmksa.bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_setdel_pmksa()
11971 } else if (info->attrs[NL80211_ATTR_SSID] && in nl80211_setdel_pmksa()
11972 info->attrs[NL80211_ATTR_FILS_CACHE_ID] && in nl80211_setdel_pmksa()
11973 (info->genlhdr->cmd == NL80211_CMD_DEL_PMKSA || in nl80211_setdel_pmksa()
11974 info->attrs[NL80211_ATTR_PMK])) { in nl80211_setdel_pmksa()
11975 pmksa.ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); in nl80211_setdel_pmksa()
11976 pmksa.ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]); in nl80211_setdel_pmksa()
11978 nla_data(info->attrs[NL80211_ATTR_FILS_CACHE_ID]); in nl80211_setdel_pmksa()
11980 return -EINVAL; in nl80211_setdel_pmksa()
11982 if (info->attrs[NL80211_ATTR_PMK]) { in nl80211_setdel_pmksa()
11983 pmksa.pmk = nla_data(info->attrs[NL80211_ATTR_PMK]); in nl80211_setdel_pmksa()
11984 pmksa.pmk_len = nla_len(info->attrs[NL80211_ATTR_PMK]); in nl80211_setdel_pmksa()
11987 if (info->attrs[NL80211_ATTR_PMK_LIFETIME]) in nl80211_setdel_pmksa()
11989 nla_get_u32(info->attrs[NL80211_ATTR_PMK_LIFETIME]); in nl80211_setdel_pmksa()
11991 if (info->attrs[NL80211_ATTR_PMK_REAUTH_THRESHOLD]) in nl80211_setdel_pmksa()
11994 info->attrs[NL80211_ATTR_PMK_REAUTH_THRESHOLD]); in nl80211_setdel_pmksa()
11996 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && in nl80211_setdel_pmksa()
11997 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT && in nl80211_setdel_pmksa()
11998 !(dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP && in nl80211_setdel_pmksa()
11999 wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_setdel_pmksa()
12001 return -EOPNOTSUPP; in nl80211_setdel_pmksa()
12003 switch (info->genlhdr->cmd) { in nl80211_setdel_pmksa()
12005 rdev_ops = rdev->ops->set_pmksa; in nl80211_setdel_pmksa()
12008 rdev_ops = rdev->ops->del_pmksa; in nl80211_setdel_pmksa()
12016 return -EOPNOTSUPP; in nl80211_setdel_pmksa()
12018 return rdev_ops(&rdev->wiphy, dev, &pmksa); in nl80211_setdel_pmksa()
12023 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_flush_pmksa()
12024 struct net_device *dev = info->user_ptr[1]; in nl80211_flush_pmksa()
12026 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && in nl80211_flush_pmksa()
12027 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT) in nl80211_flush_pmksa()
12028 return -EOPNOTSUPP; in nl80211_flush_pmksa()
12030 if (!rdev->ops->flush_pmksa) in nl80211_flush_pmksa()
12031 return -EOPNOTSUPP; in nl80211_flush_pmksa()
12038 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_tdls_mgmt()
12039 struct net_device *dev = info->user_ptr[1]; in nl80211_tdls_mgmt()
12046 if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) || in nl80211_tdls_mgmt()
12047 !rdev->ops->tdls_mgmt) in nl80211_tdls_mgmt()
12048 return -EOPNOTSUPP; in nl80211_tdls_mgmt()
12050 if (!info->attrs[NL80211_ATTR_TDLS_ACTION] || in nl80211_tdls_mgmt()
12051 !info->attrs[NL80211_ATTR_STATUS_CODE] || in nl80211_tdls_mgmt()
12052 !info->attrs[NL80211_ATTR_TDLS_DIALOG_TOKEN] || in nl80211_tdls_mgmt()
12053 !info->attrs[NL80211_ATTR_IE] || in nl80211_tdls_mgmt()
12054 !info->attrs[NL80211_ATTR_MAC]) in nl80211_tdls_mgmt()
12055 return -EINVAL; in nl80211_tdls_mgmt()
12057 peer = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_tdls_mgmt()
12058 action_code = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_ACTION]); in nl80211_tdls_mgmt()
12059 status_code = nla_get_u16(info->attrs[NL80211_ATTR_STATUS_CODE]); in nl80211_tdls_mgmt()
12060 dialog_token = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_DIALOG_TOKEN]); in nl80211_tdls_mgmt()
12061 initiator = nla_get_flag(info->attrs[NL80211_ATTR_TDLS_INITIATOR]); in nl80211_tdls_mgmt()
12062 if (info->attrs[NL80211_ATTR_TDLS_PEER_CAPABILITY]) in nl80211_tdls_mgmt()
12064 nla_get_u32(info->attrs[NL80211_ATTR_TDLS_PEER_CAPABILITY]); in nl80211_tdls_mgmt()
12069 nla_data(info->attrs[NL80211_ATTR_IE]), in nl80211_tdls_mgmt()
12070 nla_len(info->attrs[NL80211_ATTR_IE])); in nl80211_tdls_mgmt()
12075 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_tdls_oper()
12076 struct net_device *dev = info->user_ptr[1]; in nl80211_tdls_oper()
12080 if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) || in nl80211_tdls_oper()
12081 !rdev->ops->tdls_oper) in nl80211_tdls_oper()
12082 return -EOPNOTSUPP; in nl80211_tdls_oper()
12084 if (!info->attrs[NL80211_ATTR_TDLS_OPERATION] || in nl80211_tdls_oper()
12085 !info->attrs[NL80211_ATTR_MAC]) in nl80211_tdls_oper()
12086 return -EINVAL; in nl80211_tdls_oper()
12088 operation = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_OPERATION]); in nl80211_tdls_oper()
12089 peer = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_tdls_oper()
12097 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_remain_on_channel()
12098 unsigned int link_id = nl80211_link_id(info->attrs); in nl80211_remain_on_channel()
12099 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_remain_on_channel()
12107 if (!info->attrs[NL80211_ATTR_WIPHY_FREQ] || in nl80211_remain_on_channel()
12108 !info->attrs[NL80211_ATTR_DURATION]) in nl80211_remain_on_channel()
12109 return -EINVAL; in nl80211_remain_on_channel()
12111 duration = nla_get_u32(info->attrs[NL80211_ATTR_DURATION]); in nl80211_remain_on_channel()
12113 if (!rdev->ops->remain_on_channel || in nl80211_remain_on_channel()
12114 !(rdev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL)) in nl80211_remain_on_channel()
12115 return -EOPNOTSUPP; in nl80211_remain_on_channel()
12122 duration > rdev->wiphy.max_remain_on_channel_duration) in nl80211_remain_on_channel()
12123 return -EINVAL; in nl80211_remain_on_channel()
12139 return -EBUSY; in nl80211_remain_on_channel()
12148 return -EBUSY; in nl80211_remain_on_channel()
12155 return -ENOMEM; in nl80211_remain_on_channel()
12157 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, in nl80211_remain_on_channel()
12160 err = -ENOBUFS; in nl80211_remain_on_channel()
12179 err = -ENOBUFS; in nl80211_remain_on_channel()
12188 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_cancel_remain_on_channel()
12189 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_cancel_remain_on_channel()
12192 if (!info->attrs[NL80211_ATTR_COOKIE]) in nl80211_cancel_remain_on_channel()
12193 return -EINVAL; in nl80211_cancel_remain_on_channel()
12195 if (!rdev->ops->cancel_remain_on_channel) in nl80211_cancel_remain_on_channel()
12196 return -EOPNOTSUPP; in nl80211_cancel_remain_on_channel()
12198 cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); in nl80211_cancel_remain_on_channel()
12207 unsigned int link_id = nl80211_link_id(info->attrs); in nl80211_set_tx_bitrate_mask()
12208 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_tx_bitrate_mask()
12209 struct net_device *dev = info->user_ptr[1]; in nl80211_set_tx_bitrate_mask()
12210 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_set_tx_bitrate_mask()
12213 if (!rdev->ops->set_bitrate_mask) in nl80211_set_tx_bitrate_mask()
12214 return -EOPNOTSUPP; in nl80211_set_tx_bitrate_mask()
12217 err = nl80211_parse_tx_bitrate_mask(info, info->attrs, in nl80211_set_tx_bitrate_mask()
12231 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_register_mgmt()
12232 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_register_mgmt()
12235 if (!info->attrs[NL80211_ATTR_FRAME_MATCH]) in nl80211_register_mgmt()
12236 return -EINVAL; in nl80211_register_mgmt()
12238 if (info->attrs[NL80211_ATTR_FRAME_TYPE]) in nl80211_register_mgmt()
12239 frame_type = nla_get_u16(info->attrs[NL80211_ATTR_FRAME_TYPE]); in nl80211_register_mgmt()
12241 switch (wdev->iftype) { in nl80211_register_mgmt()
12253 return -EOPNOTSUPP; in nl80211_register_mgmt()
12257 if (!rdev->ops->mgmt_tx) in nl80211_register_mgmt()
12258 return -EOPNOTSUPP; in nl80211_register_mgmt()
12260 if (info->attrs[NL80211_ATTR_RECEIVE_MULTICAST] && in nl80211_register_mgmt()
12261 !wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_register_mgmt()
12265 return -EOPNOTSUPP; in nl80211_register_mgmt()
12268 return cfg80211_mlme_register_mgmt(wdev, info->snd_portid, frame_type, in nl80211_register_mgmt()
12269 nla_data(info->attrs[NL80211_ATTR_FRAME_MATCH]), in nl80211_register_mgmt()
12270 nla_len(info->attrs[NL80211_ATTR_FRAME_MATCH]), in nl80211_register_mgmt()
12271 info->attrs[NL80211_ATTR_RECEIVE_MULTICAST], in nl80211_register_mgmt()
12272 info->extack); in nl80211_register_mgmt()
12277 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_tx_mgmt()
12278 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_tx_mgmt()
12286 info->attrs[NL80211_ATTR_DONT_WAIT_FOR_ACK], in nl80211_tx_mgmt()
12289 if (!info->attrs[NL80211_ATTR_FRAME]) in nl80211_tx_mgmt()
12290 return -EINVAL; in nl80211_tx_mgmt()
12292 if (!rdev->ops->mgmt_tx) in nl80211_tx_mgmt()
12293 return -EOPNOTSUPP; in nl80211_tx_mgmt()
12295 switch (wdev->iftype) { in nl80211_tx_mgmt()
12297 if (!info->attrs[NL80211_ATTR_WIPHY_FREQ]) in nl80211_tx_mgmt()
12298 return -EINVAL; in nl80211_tx_mgmt()
12310 return -EOPNOTSUPP; in nl80211_tx_mgmt()
12313 if (info->attrs[NL80211_ATTR_DURATION]) { in nl80211_tx_mgmt()
12314 if (!(rdev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX)) in nl80211_tx_mgmt()
12315 return -EINVAL; in nl80211_tx_mgmt()
12316 params.wait = nla_get_u32(info->attrs[NL80211_ATTR_DURATION]); in nl80211_tx_mgmt()
12323 params.wait > rdev->wiphy.max_remain_on_channel_duration) in nl80211_tx_mgmt()
12324 return -EINVAL; in nl80211_tx_mgmt()
12327 params.offchan = info->attrs[NL80211_ATTR_OFFCHANNEL_TX_OK]; in nl80211_tx_mgmt()
12329 if (params.offchan && !(rdev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX)) in nl80211_tx_mgmt()
12330 return -EINVAL; in nl80211_tx_mgmt()
12332 params.no_cck = nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]); in nl80211_tx_mgmt()
12338 if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { in nl80211_tx_mgmt()
12345 return -EINVAL; in nl80211_tx_mgmt()
12351 return -EBUSY; in nl80211_tx_mgmt()
12354 params.link_id = nl80211_link_id_or_invalid(info->attrs); in nl80211_tx_mgmt()
12361 !(wdev->valid_links & BIT(params.link_id))) { in nl80211_tx_mgmt()
12363 return -EINVAL; in nl80211_tx_mgmt()
12367 params.buf = nla_data(info->attrs[NL80211_ATTR_FRAME]); in nl80211_tx_mgmt()
12368 params.len = nla_len(info->attrs[NL80211_ATTR_FRAME]); in nl80211_tx_mgmt()
12370 if (info->attrs[NL80211_ATTR_CSA_C_OFFSETS_TX]) { in nl80211_tx_mgmt()
12371 int len = nla_len(info->attrs[NL80211_ATTR_CSA_C_OFFSETS_TX]); in nl80211_tx_mgmt()
12375 return -EINVAL; in nl80211_tx_mgmt()
12379 nla_data(info->attrs[NL80211_ATTR_CSA_C_OFFSETS_TX]); in nl80211_tx_mgmt()
12384 return -EINVAL; in nl80211_tx_mgmt()
12391 return -ENOMEM; in nl80211_tx_mgmt()
12393 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, in nl80211_tx_mgmt()
12396 err = -ENOBUFS; in nl80211_tx_mgmt()
12418 err = -ENOBUFS; in nl80211_tx_mgmt()
12426 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_tx_mgmt_cancel_wait()
12427 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_tx_mgmt_cancel_wait()
12430 if (!info->attrs[NL80211_ATTR_COOKIE]) in nl80211_tx_mgmt_cancel_wait()
12431 return -EINVAL; in nl80211_tx_mgmt_cancel_wait()
12433 if (!rdev->ops->mgmt_tx_cancel_wait) in nl80211_tx_mgmt_cancel_wait()
12434 return -EOPNOTSUPP; in nl80211_tx_mgmt_cancel_wait()
12436 switch (wdev->iftype) { in nl80211_tx_mgmt_cancel_wait()
12447 return -EOPNOTSUPP; in nl80211_tx_mgmt_cancel_wait()
12450 cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); in nl80211_tx_mgmt_cancel_wait()
12457 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_power_save()
12459 struct net_device *dev = info->user_ptr[1]; in nl80211_set_power_save()
12464 if (!info->attrs[NL80211_ATTR_PS_STATE]) in nl80211_set_power_save()
12465 return -EINVAL; in nl80211_set_power_save()
12467 ps_state = nla_get_u32(info->attrs[NL80211_ATTR_PS_STATE]); in nl80211_set_power_save()
12469 wdev = dev->ieee80211_ptr; in nl80211_set_power_save()
12471 if (!rdev->ops->set_power_mgmt) in nl80211_set_power_save()
12472 return -EOPNOTSUPP; in nl80211_set_power_save()
12476 if (state == wdev->ps) in nl80211_set_power_save()
12479 err = rdev_set_power_mgmt(rdev, dev, state, wdev->ps_timeout); in nl80211_set_power_save()
12481 wdev->ps = state; in nl80211_set_power_save()
12487 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_get_power_save()
12490 struct net_device *dev = info->user_ptr[1]; in nl80211_get_power_save()
12495 wdev = dev->ieee80211_ptr; in nl80211_get_power_save()
12497 if (!rdev->ops->set_power_mgmt) in nl80211_get_power_save()
12498 return -EOPNOTSUPP; in nl80211_get_power_save()
12502 return -ENOMEM; in nl80211_get_power_save()
12504 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, in nl80211_get_power_save()
12507 err = -ENOBUFS; in nl80211_get_power_save()
12511 if (wdev->ps) in nl80211_get_power_save()
12523 err = -ENOBUFS; in nl80211_get_power_save()
12543 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_cqm_txe()
12544 struct net_device *dev = info->user_ptr[1]; in nl80211_set_cqm_txe()
12545 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_set_cqm_txe()
12548 return -EINVAL; in nl80211_set_cqm_txe()
12550 if (!rdev->ops->set_cqm_txe_config) in nl80211_set_cqm_txe()
12551 return -EOPNOTSUPP; in nl80211_set_cqm_txe()
12553 if (wdev->iftype != NL80211_IFTYPE_STATION && in nl80211_set_cqm_txe()
12554 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) in nl80211_set_cqm_txe()
12555 return -EOPNOTSUPP; in nl80211_set_cqm_txe()
12563 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_cqm_rssi_update()
12570 if (!wdev->cqm_config) in cfg80211_cqm_rssi_update()
12579 if (!wdev->cqm_config->last_rssi_event_value && in cfg80211_cqm_rssi_update()
12580 wdev->links[0].client.current_bss && in cfg80211_cqm_rssi_update()
12581 rdev->ops->get_station) { in cfg80211_cqm_rssi_update()
12585 mac_addr = wdev->links[0].client.current_bss->pub.bssid; in cfg80211_cqm_rssi_update()
12593 wdev->cqm_config->last_rssi_event_value = in cfg80211_cqm_rssi_update()
12597 last = wdev->cqm_config->last_rssi_event_value; in cfg80211_cqm_rssi_update()
12598 hyst = wdev->cqm_config->rssi_hyst; in cfg80211_cqm_rssi_update()
12599 n = wdev->cqm_config->n_rssi_thresholds; in cfg80211_cqm_rssi_update()
12603 if (last < wdev->cqm_config->rssi_thresholds[i]) in cfg80211_cqm_rssi_update()
12607 low_index = i - 1; in cfg80211_cqm_rssi_update()
12610 low = wdev->cqm_config->rssi_thresholds[low_index] - hyst; in cfg80211_cqm_rssi_update()
12616 high = wdev->cqm_config->rssi_thresholds[i] + hyst - 1; in cfg80211_cqm_rssi_update()
12628 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_cqm_rssi()
12629 struct net_device *dev = info->user_ptr[1]; in nl80211_set_cqm_rssi()
12630 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_set_cqm_rssi()
12637 return -EINVAL; in nl80211_set_cqm_rssi()
12642 if (wdev->iftype != NL80211_IFTYPE_STATION && in nl80211_set_cqm_rssi()
12643 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) in nl80211_set_cqm_rssi()
12644 return -EOPNOTSUPP; in nl80211_set_cqm_rssi()
12650 if (n_thresholds <= 1 && rdev->ops->set_cqm_rssi_config) { in nl80211_set_cqm_rssi()
12658 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_set_cqm_rssi()
12660 return -EOPNOTSUPP; in nl80211_set_cqm_rssi()
12673 err = -ENOMEM; in nl80211_set_cqm_rssi()
12677 cqm_config->rssi_hyst = hysteresis; in nl80211_set_cqm_rssi()
12678 cqm_config->n_rssi_thresholds = n_thresholds; in nl80211_set_cqm_rssi()
12679 memcpy(cqm_config->rssi_thresholds, thresholds, in nl80211_set_cqm_rssi()
12683 wdev->cqm_config = cqm_config; in nl80211_set_cqm_rssi()
12700 cqm = info->attrs[NL80211_ATTR_CQM]; in nl80211_set_cqm()
12702 return -EINVAL; in nl80211_set_cqm()
12706 info->extack); in nl80211_set_cqm()
12718 return -EINVAL; in nl80211_set_cqm()
12734 return -EINVAL; in nl80211_set_cqm()
12739 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_join_ocb()
12740 struct net_device *dev = info->user_ptr[1]; in nl80211_join_ocb()
12753 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_leave_ocb()
12754 struct net_device *dev = info->user_ptr[1]; in nl80211_leave_ocb()
12761 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_join_mesh()
12762 struct net_device *dev = info->user_ptr[1]; in nl80211_join_mesh()
12771 if (info->attrs[NL80211_ATTR_MESH_CONFIG]) { in nl80211_join_mesh()
12778 if (!info->attrs[NL80211_ATTR_MESH_ID] || in nl80211_join_mesh()
12779 !nla_len(info->attrs[NL80211_ATTR_MESH_ID])) in nl80211_join_mesh()
12780 return -EINVAL; in nl80211_join_mesh()
12782 setup.mesh_id = nla_data(info->attrs[NL80211_ATTR_MESH_ID]); in nl80211_join_mesh()
12783 setup.mesh_id_len = nla_len(info->attrs[NL80211_ATTR_MESH_ID]); in nl80211_join_mesh()
12785 if (info->attrs[NL80211_ATTR_MCAST_RATE] && in nl80211_join_mesh()
12787 nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE]))) in nl80211_join_mesh()
12788 return -EINVAL; in nl80211_join_mesh()
12790 if (info->attrs[NL80211_ATTR_BEACON_INTERVAL]) { in nl80211_join_mesh()
12792 nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]); in nl80211_join_mesh()
12801 if (info->attrs[NL80211_ATTR_DTIM_PERIOD]) { in nl80211_join_mesh()
12803 nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]); in nl80211_join_mesh()
12805 return -EINVAL; in nl80211_join_mesh()
12808 if (info->attrs[NL80211_ATTR_MESH_SETUP]) { in nl80211_join_mesh()
12818 if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { in nl80211_join_mesh()
12827 if (info->attrs[NL80211_ATTR_BSS_BASIC_RATES]) { in nl80211_join_mesh()
12828 u8 *rates = nla_data(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]); in nl80211_join_mesh()
12830 nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]); in nl80211_join_mesh()
12834 return -EINVAL; in nl80211_join_mesh()
12836 sband = rdev->wiphy.bands[setup.chandef.chan->band]; in nl80211_join_mesh()
12844 if (info->attrs[NL80211_ATTR_TX_RATES]) { in nl80211_join_mesh()
12845 err = nl80211_parse_tx_bitrate_mask(info, info->attrs, in nl80211_join_mesh()
12853 return -EINVAL; in nl80211_join_mesh()
12855 err = validate_beacon_tx_rate(rdev, setup.chandef.chan->band, in nl80211_join_mesh()
12862 nla_get_flag(info->attrs[NL80211_ATTR_HANDLE_DFS]); in nl80211_join_mesh()
12864 if (info->attrs[NL80211_ATTR_CONTROL_PORT_OVER_NL80211]) { in nl80211_join_mesh()
12873 wdev_lock(dev->ieee80211_ptr); in nl80211_join_mesh()
12875 if (!err && info->attrs[NL80211_ATTR_SOCKET_OWNER]) in nl80211_join_mesh()
12876 dev->ieee80211_ptr->conn_owner_nlportid = info->snd_portid; in nl80211_join_mesh()
12877 wdev_unlock(dev->ieee80211_ptr); in nl80211_join_mesh()
12884 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_leave_mesh()
12885 struct net_device *dev = info->user_ptr[1]; in nl80211_leave_mesh()
12894 struct cfg80211_wowlan *wowlan = rdev->wiphy.wowlan_config; in nl80211_send_wowlan_patterns()
12898 if (!wowlan->n_patterns) in nl80211_send_wowlan_patterns()
12903 return -ENOBUFS; in nl80211_send_wowlan_patterns()
12905 for (i = 0; i < wowlan->n_patterns; i++) { in nl80211_send_wowlan_patterns()
12908 return -ENOBUFS; in nl80211_send_wowlan_patterns()
12909 pat_len = wowlan->patterns[i].pattern_len; in nl80211_send_wowlan_patterns()
12911 wowlan->patterns[i].mask) || in nl80211_send_wowlan_patterns()
12913 wowlan->patterns[i].pattern) || in nl80211_send_wowlan_patterns()
12915 wowlan->patterns[i].pkt_offset)) in nl80211_send_wowlan_patterns()
12916 return -ENOBUFS; in nl80211_send_wowlan_patterns()
12935 return -ENOBUFS; in nl80211_send_wowlan_tcp()
12937 if (nla_put_in_addr(msg, NL80211_WOWLAN_TCP_SRC_IPV4, tcp->src) || in nl80211_send_wowlan_tcp()
12938 nla_put_in_addr(msg, NL80211_WOWLAN_TCP_DST_IPV4, tcp->dst) || in nl80211_send_wowlan_tcp()
12939 nla_put(msg, NL80211_WOWLAN_TCP_DST_MAC, ETH_ALEN, tcp->dst_mac) || in nl80211_send_wowlan_tcp()
12940 nla_put_u16(msg, NL80211_WOWLAN_TCP_SRC_PORT, tcp->src_port) || in nl80211_send_wowlan_tcp()
12941 nla_put_u16(msg, NL80211_WOWLAN_TCP_DST_PORT, tcp->dst_port) || in nl80211_send_wowlan_tcp()
12943 tcp->payload_len, tcp->payload) || in nl80211_send_wowlan_tcp()
12945 tcp->data_interval) || in nl80211_send_wowlan_tcp()
12947 tcp->wake_len, tcp->wake_data) || in nl80211_send_wowlan_tcp()
12949 DIV_ROUND_UP(tcp->wake_len, 8), tcp->wake_mask)) in nl80211_send_wowlan_tcp()
12950 return -ENOBUFS; in nl80211_send_wowlan_tcp()
12952 if (tcp->payload_seq.len && in nl80211_send_wowlan_tcp()
12954 sizeof(tcp->payload_seq), &tcp->payload_seq)) in nl80211_send_wowlan_tcp()
12955 return -ENOBUFS; in nl80211_send_wowlan_tcp()
12957 if (tcp->payload_tok.len && in nl80211_send_wowlan_tcp()
12959 sizeof(tcp->payload_tok) + tcp->tokens_size, in nl80211_send_wowlan_tcp()
12960 &tcp->payload_tok)) in nl80211_send_wowlan_tcp()
12961 return -ENOBUFS; in nl80211_send_wowlan_tcp()
12979 return -ENOBUFS; in nl80211_send_wowlan_nd()
12981 if (req->n_scan_plans == 1 && in nl80211_send_wowlan_nd()
12983 req->scan_plans[0].interval * 1000)) in nl80211_send_wowlan_nd()
12984 return -ENOBUFS; in nl80211_send_wowlan_nd()
12986 if (nla_put_u32(msg, NL80211_ATTR_SCHED_SCAN_DELAY, req->delay)) in nl80211_send_wowlan_nd()
12987 return -ENOBUFS; in nl80211_send_wowlan_nd()
12989 if (req->relative_rssi_set) { in nl80211_send_wowlan_nd()
12993 req->relative_rssi)) in nl80211_send_wowlan_nd()
12994 return -ENOBUFS; in nl80211_send_wowlan_nd()
12996 rssi_adjust.band = req->rssi_adjust.band; in nl80211_send_wowlan_nd()
12997 rssi_adjust.delta = req->rssi_adjust.delta; in nl80211_send_wowlan_nd()
13000 return -ENOBUFS; in nl80211_send_wowlan_nd()
13005 return -ENOBUFS; in nl80211_send_wowlan_nd()
13007 for (i = 0; i < req->n_channels; i++) { in nl80211_send_wowlan_nd()
13008 if (nla_put_u32(msg, i, req->channels[i]->center_freq)) in nl80211_send_wowlan_nd()
13009 return -ENOBUFS; in nl80211_send_wowlan_nd()
13014 if (req->n_match_sets) { in nl80211_send_wowlan_nd()
13018 return -ENOBUFS; in nl80211_send_wowlan_nd()
13020 for (i = 0; i < req->n_match_sets; i++) { in nl80211_send_wowlan_nd()
13023 return -ENOBUFS; in nl80211_send_wowlan_nd()
13026 req->match_sets[i].ssid.ssid_len, in nl80211_send_wowlan_nd()
13027 req->match_sets[i].ssid.ssid)) in nl80211_send_wowlan_nd()
13028 return -ENOBUFS; in nl80211_send_wowlan_nd()
13036 return -ENOBUFS; in nl80211_send_wowlan_nd()
13038 for (i = 0; i < req->n_scan_plans; i++) { in nl80211_send_wowlan_nd()
13041 return -ENOBUFS; in nl80211_send_wowlan_nd()
13044 req->scan_plans[i].interval) || in nl80211_send_wowlan_nd()
13045 (req->scan_plans[i].iterations && in nl80211_send_wowlan_nd()
13047 req->scan_plans[i].iterations))) in nl80211_send_wowlan_nd()
13048 return -ENOBUFS; in nl80211_send_wowlan_nd()
13060 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_get_wowlan()
13065 if (!rdev->wiphy.wowlan) in nl80211_get_wowlan()
13066 return -EOPNOTSUPP; in nl80211_get_wowlan()
13068 if (rdev->wiphy.wowlan_config && rdev->wiphy.wowlan_config->tcp) { in nl80211_get_wowlan()
13070 size += rdev->wiphy.wowlan_config->tcp->tokens_size + in nl80211_get_wowlan()
13071 rdev->wiphy.wowlan_config->tcp->payload_len + in nl80211_get_wowlan()
13072 rdev->wiphy.wowlan_config->tcp->wake_len + in nl80211_get_wowlan()
13073 rdev->wiphy.wowlan_config->tcp->wake_len / 8; in nl80211_get_wowlan()
13078 return -ENOMEM; in nl80211_get_wowlan()
13080 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, in nl80211_get_wowlan()
13085 if (rdev->wiphy.wowlan_config) { in nl80211_get_wowlan()
13093 if ((rdev->wiphy.wowlan_config->any && in nl80211_get_wowlan()
13095 (rdev->wiphy.wowlan_config->disconnect && in nl80211_get_wowlan()
13097 (rdev->wiphy.wowlan_config->magic_pkt && in nl80211_get_wowlan()
13099 (rdev->wiphy.wowlan_config->gtk_rekey_failure && in nl80211_get_wowlan()
13101 (rdev->wiphy.wowlan_config->eap_identity_req && in nl80211_get_wowlan()
13103 (rdev->wiphy.wowlan_config->four_way_handshake && in nl80211_get_wowlan()
13105 (rdev->wiphy.wowlan_config->rfkill_release && in nl80211_get_wowlan()
13113 rdev->wiphy.wowlan_config->tcp)) in nl80211_get_wowlan()
13118 rdev->wiphy.wowlan_config->nd_config)) in nl80211_get_wowlan()
13129 return -ENOBUFS; in nl80211_get_wowlan()
13144 if (!rdev->wiphy.wowlan->tcp) in nl80211_parse_wowlan_tcp()
13145 return -EINVAL; in nl80211_parse_wowlan_tcp()
13160 return -EINVAL; in nl80211_parse_wowlan_tcp()
13163 if (data_size > rdev->wiphy.wowlan->tcp->data_payload_max) in nl80211_parse_wowlan_tcp()
13164 return -EINVAL; in nl80211_parse_wowlan_tcp()
13167 rdev->wiphy.wowlan->tcp->data_interval_max || in nl80211_parse_wowlan_tcp()
13169 return -EINVAL; in nl80211_parse_wowlan_tcp()
13172 if (wake_size > rdev->wiphy.wowlan->tcp->wake_payload_max) in nl80211_parse_wowlan_tcp()
13173 return -EINVAL; in nl80211_parse_wowlan_tcp()
13177 return -EINVAL; in nl80211_parse_wowlan_tcp()
13183 tokens_size = tokln - sizeof(*tok); in nl80211_parse_wowlan_tcp()
13185 if (!tok->len || tokens_size % tok->len) in nl80211_parse_wowlan_tcp()
13186 return -EINVAL; in nl80211_parse_wowlan_tcp()
13187 if (!rdev->wiphy.wowlan->tcp->tok) in nl80211_parse_wowlan_tcp()
13188 return -EINVAL; in nl80211_parse_wowlan_tcp()
13189 if (tok->len > rdev->wiphy.wowlan->tcp->tok->max_len) in nl80211_parse_wowlan_tcp()
13190 return -EINVAL; in nl80211_parse_wowlan_tcp()
13191 if (tok->len < rdev->wiphy.wowlan->tcp->tok->min_len) in nl80211_parse_wowlan_tcp()
13192 return -EINVAL; in nl80211_parse_wowlan_tcp()
13193 if (tokens_size > rdev->wiphy.wowlan->tcp->tok->bufsize) in nl80211_parse_wowlan_tcp()
13194 return -EINVAL; in nl80211_parse_wowlan_tcp()
13195 if (tok->offset + tok->len > data_size) in nl80211_parse_wowlan_tcp()
13196 return -EINVAL; in nl80211_parse_wowlan_tcp()
13201 if (!rdev->wiphy.wowlan->tcp->seq) in nl80211_parse_wowlan_tcp()
13202 return -EINVAL; in nl80211_parse_wowlan_tcp()
13203 if (seq->len == 0 || seq->len > 4) in nl80211_parse_wowlan_tcp()
13204 return -EINVAL; in nl80211_parse_wowlan_tcp()
13205 if (seq->len + seq->offset > data_size) in nl80211_parse_wowlan_tcp()
13206 return -EINVAL; in nl80211_parse_wowlan_tcp()
13216 return -ENOMEM; in nl80211_parse_wowlan_tcp()
13217 cfg->src = nla_get_in_addr(tb[NL80211_WOWLAN_TCP_SRC_IPV4]); in nl80211_parse_wowlan_tcp()
13218 cfg->dst = nla_get_in_addr(tb[NL80211_WOWLAN_TCP_DST_IPV4]); in nl80211_parse_wowlan_tcp()
13219 memcpy(cfg->dst_mac, nla_data(tb[NL80211_WOWLAN_TCP_DST_MAC]), in nl80211_parse_wowlan_tcp()
13227 err = __sock_create(wiphy_net(&rdev->wiphy), PF_INET, SOCK_STREAM, in nl80211_parse_wowlan_tcp()
13228 IPPROTO_TCP, &cfg->sock, 1); in nl80211_parse_wowlan_tcp()
13233 if (inet_csk_get_port(cfg->sock->sk, port)) { in nl80211_parse_wowlan_tcp()
13234 sock_release(cfg->sock); in nl80211_parse_wowlan_tcp()
13236 return -EADDRINUSE; in nl80211_parse_wowlan_tcp()
13238 cfg->src_port = inet_sk(cfg->sock->sk)->inet_num; in nl80211_parse_wowlan_tcp()
13242 return -EINVAL; in nl80211_parse_wowlan_tcp()
13244 cfg->src_port = port; in nl80211_parse_wowlan_tcp()
13247 cfg->dst_port = nla_get_u16(tb[NL80211_WOWLAN_TCP_DST_PORT]); in nl80211_parse_wowlan_tcp()
13248 cfg->payload_len = data_size; in nl80211_parse_wowlan_tcp()
13249 cfg->payload = (u8 *)cfg + sizeof(*cfg) + tokens_size; in nl80211_parse_wowlan_tcp()
13250 memcpy((void *)cfg->payload, in nl80211_parse_wowlan_tcp()
13254 cfg->payload_seq = *seq; in nl80211_parse_wowlan_tcp()
13255 cfg->data_interval = nla_get_u32(tb[NL80211_WOWLAN_TCP_DATA_INTERVAL]); in nl80211_parse_wowlan_tcp()
13256 cfg->wake_len = wake_size; in nl80211_parse_wowlan_tcp()
13257 cfg->wake_data = (u8 *)cfg + sizeof(*cfg) + tokens_size + data_size; in nl80211_parse_wowlan_tcp()
13258 memcpy((void *)cfg->wake_data, in nl80211_parse_wowlan_tcp()
13261 cfg->wake_mask = (u8 *)cfg + sizeof(*cfg) + tokens_size + in nl80211_parse_wowlan_tcp()
13263 memcpy((void *)cfg->wake_mask, in nl80211_parse_wowlan_tcp()
13267 cfg->tokens_size = tokens_size; in nl80211_parse_wowlan_tcp()
13268 cfg->payload_tok = *tok; in nl80211_parse_wowlan_tcp()
13269 memcpy(cfg->payload_tok.token_stream, tok->token_stream, in nl80211_parse_wowlan_tcp()
13273 trig->tcp = cfg; in nl80211_parse_wowlan_tcp()
13288 return -ENOMEM; in nl80211_parse_wowlan_nd()
13290 if (!(wowlan->flags & WIPHY_WOWLAN_NET_DETECT)) { in nl80211_parse_wowlan_nd()
13291 err = -EOPNOTSUPP; in nl80211_parse_wowlan_nd()
13300 trig->nd_config = nl80211_parse_sched_scan(&rdev->wiphy, NULL, tb, in nl80211_parse_wowlan_nd()
13301 wowlan->max_nd_match_sets); in nl80211_parse_wowlan_nd()
13302 err = PTR_ERR_OR_ZERO(trig->nd_config); in nl80211_parse_wowlan_nd()
13304 trig->nd_config = NULL; in nl80211_parse_wowlan_nd()
13313 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_wowlan()
13317 const struct wiphy_wowlan_support *wowlan = rdev->wiphy.wowlan; in nl80211_set_wowlan()
13319 bool prev_enabled = rdev->wiphy.wowlan_config; in nl80211_set_wowlan()
13323 return -EOPNOTSUPP; in nl80211_set_wowlan()
13325 if (!info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]) { in nl80211_set_wowlan()
13327 rdev->wiphy.wowlan_config = NULL; in nl80211_set_wowlan()
13332 info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS], in nl80211_set_wowlan()
13333 nl80211_wowlan_policy, info->extack); in nl80211_set_wowlan()
13338 if (!(wowlan->flags & WIPHY_WOWLAN_ANY)) in nl80211_set_wowlan()
13339 return -EINVAL; in nl80211_set_wowlan()
13344 if (!(wowlan->flags & WIPHY_WOWLAN_DISCONNECT)) in nl80211_set_wowlan()
13345 return -EINVAL; in nl80211_set_wowlan()
13351 if (!(wowlan->flags & WIPHY_WOWLAN_MAGIC_PKT)) in nl80211_set_wowlan()
13352 return -EINVAL; in nl80211_set_wowlan()
13358 return -EINVAL; in nl80211_set_wowlan()
13361 if (!(wowlan->flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE)) in nl80211_set_wowlan()
13362 return -EINVAL; in nl80211_set_wowlan()
13368 if (!(wowlan->flags & WIPHY_WOWLAN_EAP_IDENTITY_REQ)) in nl80211_set_wowlan()
13369 return -EINVAL; in nl80211_set_wowlan()
13375 if (!(wowlan->flags & WIPHY_WOWLAN_4WAY_HANDSHAKE)) in nl80211_set_wowlan()
13376 return -EINVAL; in nl80211_set_wowlan()
13382 if (!(wowlan->flags & WIPHY_WOWLAN_RFKILL_RELEASE)) in nl80211_set_wowlan()
13383 return -EINVAL; in nl80211_set_wowlan()
13399 if (n_patterns > wowlan->n_patterns) in nl80211_set_wowlan()
13400 return -EINVAL; in nl80211_set_wowlan()
13406 return -ENOMEM; in nl80211_set_wowlan()
13419 info->extack); in nl80211_set_wowlan()
13423 err = -EINVAL; in nl80211_set_wowlan()
13431 if (pat_len > wowlan->pattern_max_len || in nl80211_set_wowlan()
13432 pat_len < wowlan->pattern_min_len) in nl80211_set_wowlan()
13440 if (pkt_offset > wowlan->max_pkt_offset) in nl80211_set_wowlan()
13446 err = -ENOMEM; in nl80211_set_wowlan()
13483 * It therefore makes little sense to combine with the more constrained in nl80211_set_wowlan()
13487 err = -EINVAL; in nl80211_set_wowlan()
13493 err = -ENOMEM; in nl80211_set_wowlan()
13497 rdev->wiphy.wowlan_config = ntrig; in nl80211_set_wowlan()
13500 if (rdev->ops->set_wakeup && in nl80211_set_wowlan()
13501 prev_enabled != !!rdev->wiphy.wowlan_config) in nl80211_set_wowlan()
13502 rdev_set_wakeup(rdev, rdev->wiphy.wowlan_config); in nl80211_set_wowlan()
13509 if (new_triggers.tcp && new_triggers.tcp->sock) in nl80211_set_wowlan()
13510 sock_release(new_triggers.tcp->sock); in nl80211_set_wowlan()
13524 if (!rdev->coalesce->n_rules) in nl80211_send_coalesce_rules()
13529 return -ENOBUFS; in nl80211_send_coalesce_rules()
13531 for (i = 0; i < rdev->coalesce->n_rules; i++) { in nl80211_send_coalesce_rules()
13534 return -ENOBUFS; in nl80211_send_coalesce_rules()
13536 rule = &rdev->coalesce->rules[i]; in nl80211_send_coalesce_rules()
13538 rule->delay)) in nl80211_send_coalesce_rules()
13539 return -ENOBUFS; in nl80211_send_coalesce_rules()
13542 rule->condition)) in nl80211_send_coalesce_rules()
13543 return -ENOBUFS; in nl80211_send_coalesce_rules()
13548 return -ENOBUFS; in nl80211_send_coalesce_rules()
13550 for (j = 0; j < rule->n_patterns; j++) { in nl80211_send_coalesce_rules()
13553 return -ENOBUFS; in nl80211_send_coalesce_rules()
13554 pat_len = rule->patterns[j].pattern_len; in nl80211_send_coalesce_rules()
13557 rule->patterns[j].mask) || in nl80211_send_coalesce_rules()
13559 rule->patterns[j].pattern) || in nl80211_send_coalesce_rules()
13561 rule->patterns[j].pkt_offset)) in nl80211_send_coalesce_rules()
13562 return -ENOBUFS; in nl80211_send_coalesce_rules()
13575 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_get_coalesce()
13579 if (!rdev->wiphy.coalesce) in nl80211_get_coalesce()
13580 return -EOPNOTSUPP; in nl80211_get_coalesce()
13584 return -ENOMEM; in nl80211_get_coalesce()
13586 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, in nl80211_get_coalesce()
13591 if (rdev->coalesce && nl80211_send_coalesce_rules(msg, rdev)) in nl80211_get_coalesce()
13599 return -ENOBUFS; in nl80211_get_coalesce()
13604 struct cfg80211_coalesce *coalesce = rdev->coalesce; in cfg80211_rdev_free_coalesce()
13611 for (i = 0; i < coalesce->n_rules; i++) { in cfg80211_rdev_free_coalesce()
13612 rule = &coalesce->rules[i]; in cfg80211_rdev_free_coalesce()
13613 for (j = 0; j < rule->n_patterns; j++) in cfg80211_rdev_free_coalesce()
13614 kfree(rule->patterns[j].mask); in cfg80211_rdev_free_coalesce()
13615 kfree(rule->patterns); in cfg80211_rdev_free_coalesce()
13617 kfree(coalesce->rules); in cfg80211_rdev_free_coalesce()
13619 rdev->coalesce = NULL; in cfg80211_rdev_free_coalesce()
13627 const struct wiphy_coalesce_support *coalesce = rdev->wiphy.coalesce; in nl80211_parse_coalesce_rule()
13638 new_rule->delay = in nl80211_parse_coalesce_rule()
13640 if (new_rule->delay > coalesce->max_delay) in nl80211_parse_coalesce_rule()
13641 return -EINVAL; in nl80211_parse_coalesce_rule()
13644 new_rule->condition = in nl80211_parse_coalesce_rule()
13648 return -EINVAL; in nl80211_parse_coalesce_rule()
13653 if (n_patterns > coalesce->n_patterns) in nl80211_parse_coalesce_rule()
13654 return -EINVAL; in nl80211_parse_coalesce_rule()
13656 new_rule->patterns = kcalloc(n_patterns, sizeof(new_rule->patterns[0]), in nl80211_parse_coalesce_rule()
13658 if (!new_rule->patterns) in nl80211_parse_coalesce_rule()
13659 return -ENOMEM; in nl80211_parse_coalesce_rule()
13661 new_rule->n_patterns = n_patterns; in nl80211_parse_coalesce_rule()
13677 return -EINVAL; in nl80211_parse_coalesce_rule()
13681 return -EINVAL; in nl80211_parse_coalesce_rule()
13682 if (pat_len > coalesce->pattern_max_len || in nl80211_parse_coalesce_rule()
13683 pat_len < coalesce->pattern_min_len) in nl80211_parse_coalesce_rule()
13684 return -EINVAL; in nl80211_parse_coalesce_rule()
13690 if (pkt_offset > coalesce->max_pkt_offset) in nl80211_parse_coalesce_rule()
13691 return -EINVAL; in nl80211_parse_coalesce_rule()
13692 new_rule->patterns[i].pkt_offset = pkt_offset; in nl80211_parse_coalesce_rule()
13696 return -ENOMEM; in nl80211_parse_coalesce_rule()
13698 new_rule->patterns[i].mask = mask_pat; in nl80211_parse_coalesce_rule()
13703 new_rule->patterns[i].pattern = mask_pat; in nl80211_parse_coalesce_rule()
13704 new_rule->patterns[i].pattern_len = pat_len; in nl80211_parse_coalesce_rule()
13715 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_coalesce()
13716 const struct wiphy_coalesce_support *coalesce = rdev->wiphy.coalesce; in nl80211_set_coalesce()
13723 if (!rdev->wiphy.coalesce || !rdev->ops->set_coalesce) in nl80211_set_coalesce()
13724 return -EOPNOTSUPP; in nl80211_set_coalesce()
13726 if (!info->attrs[NL80211_ATTR_COALESCE_RULE]) { in nl80211_set_coalesce()
13732 nla_for_each_nested(rule, info->attrs[NL80211_ATTR_COALESCE_RULE], in nl80211_set_coalesce()
13735 if (n_rules > coalesce->n_rules) in nl80211_set_coalesce()
13736 return -EINVAL; in nl80211_set_coalesce()
13741 return -ENOMEM; in nl80211_set_coalesce()
13746 nla_for_each_nested(rule, info->attrs[NL80211_ATTR_COALESCE_RULE], in nl80211_set_coalesce()
13762 err = -ENOMEM; in nl80211_set_coalesce()
13766 rdev->coalesce = n_coalesce; in nl80211_set_coalesce()
13772 for (j = 0; j < tmp_rule->n_patterns; j++) in nl80211_set_coalesce()
13773 kfree(tmp_rule->patterns[j].mask); in nl80211_set_coalesce()
13774 kfree(tmp_rule->patterns); in nl80211_set_coalesce()
13783 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_rekey_data()
13784 struct net_device *dev = info->user_ptr[1]; in nl80211_set_rekey_data()
13785 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_set_rekey_data()
13790 if (!info->attrs[NL80211_ATTR_REKEY_DATA]) in nl80211_set_rekey_data()
13791 return -EINVAL; in nl80211_set_rekey_data()
13794 info->attrs[NL80211_ATTR_REKEY_DATA], in nl80211_set_rekey_data()
13795 nl80211_rekey_policy, info->extack); in nl80211_set_rekey_data()
13801 return -EINVAL; in nl80211_set_rekey_data()
13803 !(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK && in nl80211_set_rekey_data()
13805 return -ERANGE; in nl80211_set_rekey_data()
13807 !(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK && in nl80211_set_rekey_data()
13809 return -ERANGE; in nl80211_set_rekey_data()
13820 if (!wdev->connected) { in nl80211_set_rekey_data()
13821 err = -ENOTCONN; in nl80211_set_rekey_data()
13825 if (!rdev->ops->set_rekey_data) { in nl80211_set_rekey_data()
13826 err = -EOPNOTSUPP; in nl80211_set_rekey_data()
13839 struct net_device *dev = info->user_ptr[1]; in nl80211_register_unexpected_frame()
13840 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_register_unexpected_frame()
13842 if (wdev->iftype != NL80211_IFTYPE_AP && in nl80211_register_unexpected_frame()
13843 wdev->iftype != NL80211_IFTYPE_P2P_GO) in nl80211_register_unexpected_frame()
13844 return -EINVAL; in nl80211_register_unexpected_frame()
13846 if (wdev->ap_unexpected_nlportid) in nl80211_register_unexpected_frame()
13847 return -EBUSY; in nl80211_register_unexpected_frame()
13849 wdev->ap_unexpected_nlportid = info->snd_portid; in nl80211_register_unexpected_frame()
13856 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_probe_client()
13857 struct net_device *dev = info->user_ptr[1]; in nl80211_probe_client()
13858 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_probe_client()
13865 if (wdev->iftype != NL80211_IFTYPE_AP && in nl80211_probe_client()
13866 wdev->iftype != NL80211_IFTYPE_P2P_GO) in nl80211_probe_client()
13867 return -EOPNOTSUPP; in nl80211_probe_client()
13869 if (!info->attrs[NL80211_ATTR_MAC]) in nl80211_probe_client()
13870 return -EINVAL; in nl80211_probe_client()
13872 if (!rdev->ops->probe_client) in nl80211_probe_client()
13873 return -EOPNOTSUPP; in nl80211_probe_client()
13877 return -ENOMEM; in nl80211_probe_client()
13879 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, in nl80211_probe_client()
13882 err = -ENOBUFS; in nl80211_probe_client()
13886 addr = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_probe_client()
13901 err = -ENOBUFS; in nl80211_probe_client()
13909 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_register_beacons()
13913 if (!(rdev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS)) in nl80211_register_beacons()
13914 return -EOPNOTSUPP; in nl80211_register_beacons()
13918 return -ENOMEM; in nl80211_register_beacons()
13921 spin_lock_bh(&rdev->beacon_registrations_lock); in nl80211_register_beacons()
13922 list_for_each_entry(reg, &rdev->beacon_registrations, list) { in nl80211_register_beacons()
13923 if (reg->nlportid == info->snd_portid) { in nl80211_register_beacons()
13924 rv = -EALREADY; in nl80211_register_beacons()
13929 nreg->nlportid = info->snd_portid; in nl80211_register_beacons()
13930 list_add(&nreg->list, &rdev->beacon_registrations); in nl80211_register_beacons()
13932 spin_unlock_bh(&rdev->beacon_registrations_lock); in nl80211_register_beacons()
13936 spin_unlock_bh(&rdev->beacon_registrations_lock); in nl80211_register_beacons()
13943 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_start_p2p_device()
13944 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_start_p2p_device()
13947 if (!rdev->ops->start_p2p_device) in nl80211_start_p2p_device()
13948 return -EOPNOTSUPP; in nl80211_start_p2p_device()
13950 if (wdev->iftype != NL80211_IFTYPE_P2P_DEVICE) in nl80211_start_p2p_device()
13951 return -EOPNOTSUPP; in nl80211_start_p2p_device()
13956 if (rfkill_blocked(rdev->wiphy.rfkill)) in nl80211_start_p2p_device()
13957 return -ERFKILL; in nl80211_start_p2p_device()
13963 wdev->is_running = true; in nl80211_start_p2p_device()
13964 rdev->opencount++; in nl80211_start_p2p_device()
13971 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_stop_p2p_device()
13972 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_stop_p2p_device()
13974 if (wdev->iftype != NL80211_IFTYPE_P2P_DEVICE) in nl80211_stop_p2p_device()
13975 return -EOPNOTSUPP; in nl80211_stop_p2p_device()
13977 if (!rdev->ops->stop_p2p_device) in nl80211_stop_p2p_device()
13978 return -EOPNOTSUPP; in nl80211_stop_p2p_device()
13987 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_start_nan()
13988 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_start_nan()
13992 if (wdev->iftype != NL80211_IFTYPE_NAN) in nl80211_start_nan()
13993 return -EOPNOTSUPP; in nl80211_start_nan()
13996 return -EEXIST; in nl80211_start_nan()
13998 if (rfkill_blocked(rdev->wiphy.rfkill)) in nl80211_start_nan()
13999 return -ERFKILL; in nl80211_start_nan()
14001 if (!info->attrs[NL80211_ATTR_NAN_MASTER_PREF]) in nl80211_start_nan()
14002 return -EINVAL; in nl80211_start_nan()
14005 nla_get_u8(info->attrs[NL80211_ATTR_NAN_MASTER_PREF]); in nl80211_start_nan()
14007 if (info->attrs[NL80211_ATTR_BANDS]) { in nl80211_start_nan()
14008 u32 bands = nla_get_u32(info->attrs[NL80211_ATTR_BANDS]); in nl80211_start_nan()
14010 if (bands & ~(u32)wdev->wiphy->nan_supported_bands) in nl80211_start_nan()
14011 return -EOPNOTSUPP; in nl80211_start_nan()
14014 return -EINVAL; in nl80211_start_nan()
14023 wdev->is_running = true; in nl80211_start_nan()
14024 rdev->opencount++; in nl80211_start_nan()
14031 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_stop_nan()
14032 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_stop_nan()
14034 if (wdev->iftype != NL80211_IFTYPE_NAN) in nl80211_stop_nan()
14035 return -EOPNOTSUPP; in nl80211_stop_nan()
14053 return -EINVAL; in validate_nan_filter()
14070 BUILD_BUG_ON(sizeof(*func->rx_filters) != sizeof(*func->tx_filters)); in handle_nan_filter()
14072 filter = kcalloc(n_entries, sizeof(*func->rx_filters), GFP_KERNEL); in handle_nan_filter()
14074 return -ENOMEM; in handle_nan_filter()
14086 func->num_tx_filters = n_entries; in handle_nan_filter()
14087 func->tx_filters = filter; in handle_nan_filter()
14089 func->num_rx_filters = n_entries; in handle_nan_filter()
14090 func->rx_filters = filter; in handle_nan_filter()
14102 return -ENOMEM; in handle_nan_filter()
14108 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_nan_add_func()
14109 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_nan_add_func()
14116 if (wdev->iftype != NL80211_IFTYPE_NAN) in nl80211_nan_add_func()
14117 return -EOPNOTSUPP; in nl80211_nan_add_func()
14120 return -ENOTCONN; in nl80211_nan_add_func()
14122 if (!info->attrs[NL80211_ATTR_NAN_FUNC]) in nl80211_nan_add_func()
14123 return -EINVAL; in nl80211_nan_add_func()
14126 info->attrs[NL80211_ATTR_NAN_FUNC], in nl80211_nan_add_func()
14128 info->extack); in nl80211_nan_add_func()
14134 return -ENOMEM; in nl80211_nan_add_func()
14136 func->cookie = cfg80211_assign_cookie(rdev); in nl80211_nan_add_func()
14139 err = -EINVAL; in nl80211_nan_add_func()
14144 func->type = nla_get_u8(tb[NL80211_NAN_FUNC_TYPE]); in nl80211_nan_add_func()
14147 err = -EINVAL; in nl80211_nan_add_func()
14151 memcpy(func->service_id, nla_data(tb[NL80211_NAN_FUNC_SERVICE_ID]), in nl80211_nan_add_func()
14152 sizeof(func->service_id)); in nl80211_nan_add_func()
14154 func->close_range = in nl80211_nan_add_func()
14158 func->serv_spec_info_len = in nl80211_nan_add_func()
14160 func->serv_spec_info = in nl80211_nan_add_func()
14162 func->serv_spec_info_len, in nl80211_nan_add_func()
14164 if (!func->serv_spec_info) { in nl80211_nan_add_func()
14165 err = -ENOMEM; in nl80211_nan_add_func()
14171 func->ttl = nla_get_u32(tb[NL80211_NAN_FUNC_TTL]); in nl80211_nan_add_func()
14173 switch (func->type) { in nl80211_nan_add_func()
14176 err = -EINVAL; in nl80211_nan_add_func()
14180 func->publish_type = in nl80211_nan_add_func()
14182 func->publish_bcast = in nl80211_nan_add_func()
14185 if ((!(func->publish_type & NL80211_NAN_SOLICITED_PUBLISH)) && in nl80211_nan_add_func()
14186 func->publish_bcast) { in nl80211_nan_add_func()
14187 err = -EINVAL; in nl80211_nan_add_func()
14192 func->subscribe_active = in nl80211_nan_add_func()
14199 err = -EINVAL; in nl80211_nan_add_func()
14203 func->followup_id = in nl80211_nan_add_func()
14205 func->followup_reqid = in nl80211_nan_add_func()
14207 memcpy(func->followup_dest.addr, in nl80211_nan_add_func()
14209 sizeof(func->followup_dest.addr)); in nl80211_nan_add_func()
14210 if (func->ttl) { in nl80211_nan_add_func()
14211 err = -EINVAL; in nl80211_nan_add_func()
14216 err = -EINVAL; in nl80211_nan_add_func()
14227 info->extack); in nl80211_nan_add_func()
14231 func->srf_include = in nl80211_nan_add_func()
14237 err = -EINVAL; in nl80211_nan_add_func()
14241 func->srf_bf_len = in nl80211_nan_add_func()
14243 func->srf_bf = in nl80211_nan_add_func()
14245 func->srf_bf_len, GFP_KERNEL); in nl80211_nan_add_func()
14246 if (!func->srf_bf) { in nl80211_nan_add_func()
14247 err = -ENOMEM; in nl80211_nan_add_func()
14251 func->srf_bf_idx = in nl80211_nan_add_func()
14259 err = -EINVAL; in nl80211_nan_add_func()
14265 err = -EINVAL; in nl80211_nan_add_func()
14269 func->srf_num_macs = n_entries; in nl80211_nan_add_func()
14270 func->srf_macs = in nl80211_nan_add_func()
14271 kcalloc(n_entries, sizeof(*func->srf_macs), in nl80211_nan_add_func()
14273 if (!func->srf_macs) { in nl80211_nan_add_func()
14274 err = -ENOMEM; in nl80211_nan_add_func()
14279 memcpy(func->srf_macs[i++].addr, nla_data(attr), in nl80211_nan_add_func()
14280 sizeof(*func->srf_macs)); in nl80211_nan_add_func()
14300 err = -ENOMEM; in nl80211_nan_add_func()
14304 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, in nl80211_nan_add_func()
14306 /* This can't really happen - we just allocated 4KB */ in nl80211_nan_add_func()
14308 err = -ENOMEM; in nl80211_nan_add_func()
14321 if (nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, func->cookie, in nl80211_nan_add_func()
14330 func->instance_id)) in nl80211_nan_add_func()
14340 return -ENOBUFS; in nl80211_nan_add_func()
14346 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_nan_del_func()
14347 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_nan_del_func()
14350 if (wdev->iftype != NL80211_IFTYPE_NAN) in nl80211_nan_del_func()
14351 return -EOPNOTSUPP; in nl80211_nan_del_func()
14354 return -ENOTCONN; in nl80211_nan_del_func()
14356 if (!info->attrs[NL80211_ATTR_COOKIE]) in nl80211_nan_del_func()
14357 return -EINVAL; in nl80211_nan_del_func()
14359 cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); in nl80211_nan_del_func()
14369 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_nan_change_config()
14370 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_nan_change_config()
14374 if (wdev->iftype != NL80211_IFTYPE_NAN) in nl80211_nan_change_config()
14375 return -EOPNOTSUPP; in nl80211_nan_change_config()
14378 return -ENOTCONN; in nl80211_nan_change_config()
14380 if (info->attrs[NL80211_ATTR_NAN_MASTER_PREF]) { in nl80211_nan_change_config()
14382 nla_get_u8(info->attrs[NL80211_ATTR_NAN_MASTER_PREF]); in nl80211_nan_change_config()
14384 return -EINVAL; in nl80211_nan_change_config()
14389 if (info->attrs[NL80211_ATTR_BANDS]) { in nl80211_nan_change_config()
14390 u32 bands = nla_get_u32(info->attrs[NL80211_ATTR_BANDS]); in nl80211_nan_change_config()
14392 if (bands & ~(u32)wdev->wiphy->nan_supported_bands) in nl80211_nan_change_config()
14393 return -EOPNOTSUPP; in nl80211_nan_change_config()
14396 return -EINVAL; in nl80211_nan_change_config()
14403 return -EINVAL; in nl80211_nan_change_config()
14411 struct wiphy *wiphy = wdev->wiphy; in cfg80211_nan_match()
14417 if (WARN_ON(!match->inst_id || !match->peer_inst_id || !match->addr)) in cfg80211_nan_match()
14430 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in cfg80211_nan_match()
14431 (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX, in cfg80211_nan_match()
14432 wdev->netdev->ifindex)) || in cfg80211_nan_match()
14437 if (nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, match->cookie, in cfg80211_nan_match()
14439 nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, match->addr)) in cfg80211_nan_match()
14451 if (nla_put_u8(msg, NL80211_NAN_FUNC_INSTANCE_ID, match->inst_id)) in cfg80211_nan_match()
14461 if (nla_put_u8(msg, NL80211_NAN_FUNC_TYPE, match->type) || in cfg80211_nan_match()
14462 nla_put_u8(msg, NL80211_NAN_FUNC_INSTANCE_ID, match->peer_inst_id)) in cfg80211_nan_match()
14465 if (match->info && match->info_len && in cfg80211_nan_match()
14466 nla_put(msg, NL80211_NAN_FUNC_SERVICE_INFO, match->info_len, in cfg80211_nan_match()
14467 match->info)) in cfg80211_nan_match()
14474 if (!wdev->owner_nlportid) in cfg80211_nan_match()
14475 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), in cfg80211_nan_match()
14478 genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, in cfg80211_nan_match()
14479 wdev->owner_nlportid); in cfg80211_nan_match()
14493 struct wiphy *wiphy = wdev->wiphy; in cfg80211_nan_func_terminated()
14512 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in cfg80211_nan_func_terminated()
14513 (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX, in cfg80211_nan_func_terminated()
14514 wdev->netdev->ifindex)) || in cfg80211_nan_func_terminated()
14534 if (!wdev->owner_nlportid) in cfg80211_nan_func_terminated()
14535 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), in cfg80211_nan_func_terminated()
14538 genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, in cfg80211_nan_func_terminated()
14539 wdev->owner_nlportid); in cfg80211_nan_func_terminated()
14556 return -ENOMEM; in nl80211_get_protocol_features()
14558 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, in nl80211_get_protocol_features()
14572 return -ENOBUFS; in nl80211_get_protocol_features()
14577 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_update_ft_ies()
14579 struct net_device *dev = info->user_ptr[1]; in nl80211_update_ft_ies()
14581 if (!rdev->ops->update_ft_ies) in nl80211_update_ft_ies()
14582 return -EOPNOTSUPP; in nl80211_update_ft_ies()
14584 if (!info->attrs[NL80211_ATTR_MDID] || in nl80211_update_ft_ies()
14585 !info->attrs[NL80211_ATTR_IE]) in nl80211_update_ft_ies()
14586 return -EINVAL; in nl80211_update_ft_ies()
14589 ft_params.md = nla_get_u16(info->attrs[NL80211_ATTR_MDID]); in nl80211_update_ft_ies()
14590 ft_params.ie = nla_data(info->attrs[NL80211_ATTR_IE]); in nl80211_update_ft_ies()
14591 ft_params.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); in nl80211_update_ft_ies()
14599 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_crit_protocol_start()
14600 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_crit_protocol_start()
14605 if (!rdev->ops->crit_proto_start) in nl80211_crit_protocol_start()
14606 return -EOPNOTSUPP; in nl80211_crit_protocol_start()
14608 if (WARN_ON(!rdev->ops->crit_proto_stop)) in nl80211_crit_protocol_start()
14609 return -EINVAL; in nl80211_crit_protocol_start()
14611 if (rdev->crit_proto_nlportid) in nl80211_crit_protocol_start()
14612 return -EBUSY; in nl80211_crit_protocol_start()
14615 if (info->attrs[NL80211_ATTR_CRIT_PROT_ID]) in nl80211_crit_protocol_start()
14616 proto = nla_get_u16(info->attrs[NL80211_ATTR_CRIT_PROT_ID]); in nl80211_crit_protocol_start()
14619 return -EINVAL; in nl80211_crit_protocol_start()
14622 if (!info->attrs[NL80211_ATTR_MAX_CRIT_PROT_DURATION]) in nl80211_crit_protocol_start()
14623 return -EINVAL; in nl80211_crit_protocol_start()
14626 nla_get_u16(info->attrs[NL80211_ATTR_MAX_CRIT_PROT_DURATION]); in nl80211_crit_protocol_start()
14630 rdev->crit_proto_nlportid = info->snd_portid; in nl80211_crit_protocol_start()
14638 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_crit_protocol_stop()
14639 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_crit_protocol_stop()
14641 if (!rdev->ops->crit_proto_stop) in nl80211_crit_protocol_stop()
14642 return -EOPNOTSUPP; in nl80211_crit_protocol_stop()
14644 if (rdev->crit_proto_nlportid) { in nl80211_crit_protocol_stop()
14645 rdev->crit_proto_nlportid = 0; in nl80211_crit_protocol_stop()
14655 if (vcmd->policy == VENDOR_CMD_RAW_DATA) { in nl80211_vendor_check_policy()
14656 if (attr->nla_type & NLA_F_NESTED) { in nl80211_vendor_check_policy()
14659 return -EINVAL; in nl80211_vendor_check_policy()
14665 if (!(attr->nla_type & NLA_F_NESTED)) { in nl80211_vendor_check_policy()
14667 return -EINVAL; in nl80211_vendor_check_policy()
14670 return nla_validate_nested(attr, vcmd->maxattr, vcmd->policy, extack); in nl80211_vendor_check_policy()
14675 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_vendor_cmd()
14678 info->attrs); in nl80211_vendor_cmd()
14682 if (!rdev->wiphy.vendor_commands) in nl80211_vendor_cmd()
14683 return -EOPNOTSUPP; in nl80211_vendor_cmd()
14687 if (err != -EINVAL) in nl80211_vendor_cmd()
14690 } else if (wdev->wiphy != &rdev->wiphy) { in nl80211_vendor_cmd()
14691 return -EINVAL; in nl80211_vendor_cmd()
14694 if (!info->attrs[NL80211_ATTR_VENDOR_ID] || in nl80211_vendor_cmd()
14695 !info->attrs[NL80211_ATTR_VENDOR_SUBCMD]) in nl80211_vendor_cmd()
14696 return -EINVAL; in nl80211_vendor_cmd()
14698 vid = nla_get_u32(info->attrs[NL80211_ATTR_VENDOR_ID]); in nl80211_vendor_cmd()
14699 subcmd = nla_get_u32(info->attrs[NL80211_ATTR_VENDOR_SUBCMD]); in nl80211_vendor_cmd()
14700 for (i = 0; i < rdev->wiphy.n_vendor_commands; i++) { in nl80211_vendor_cmd()
14705 vcmd = &rdev->wiphy.vendor_commands[i]; in nl80211_vendor_cmd()
14707 if (vcmd->info.vendor_id != vid || vcmd->info.subcmd != subcmd) in nl80211_vendor_cmd()
14710 if (vcmd->flags & (WIPHY_VENDOR_CMD_NEED_WDEV | in nl80211_vendor_cmd()
14713 return -EINVAL; in nl80211_vendor_cmd()
14714 if (vcmd->flags & WIPHY_VENDOR_CMD_NEED_NETDEV && in nl80211_vendor_cmd()
14715 !wdev->netdev) in nl80211_vendor_cmd()
14716 return -EINVAL; in nl80211_vendor_cmd()
14718 if (vcmd->flags & WIPHY_VENDOR_CMD_NEED_RUNNING) { in nl80211_vendor_cmd()
14720 return -ENETDOWN; in nl80211_vendor_cmd()
14726 if (!vcmd->doit) in nl80211_vendor_cmd()
14727 return -EOPNOTSUPP; in nl80211_vendor_cmd()
14729 if (info->attrs[NL80211_ATTR_VENDOR_DATA]) { in nl80211_vendor_cmd()
14730 data = nla_data(info->attrs[NL80211_ATTR_VENDOR_DATA]); in nl80211_vendor_cmd()
14731 len = nla_len(info->attrs[NL80211_ATTR_VENDOR_DATA]); in nl80211_vendor_cmd()
14734 info->attrs[NL80211_ATTR_VENDOR_DATA], in nl80211_vendor_cmd()
14735 info->extack); in nl80211_vendor_cmd()
14740 rdev->cur_cmd_info = info; in nl80211_vendor_cmd()
14741 err = vcmd->doit(&rdev->wiphy, wdev, data, len); in nl80211_vendor_cmd()
14742 rdev->cur_cmd_info = NULL; in nl80211_vendor_cmd()
14746 return -EOPNOTSUPP; in nl80211_vendor_cmd()
14757 int vcmd_idx = -1; in nl80211_prepare_vendor_dump()
14762 if (cb->args[0]) { in nl80211_prepare_vendor_dump()
14764 struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1); in nl80211_prepare_vendor_dump()
14768 return -ENODEV; in nl80211_prepare_vendor_dump()
14772 if (cb->args[1]) { in nl80211_prepare_vendor_dump()
14773 list_for_each_entry(tmp, &wiphy->wdev_list, list) { in nl80211_prepare_vendor_dump()
14774 if (tmp->identifier == cb->args[1] - 1) { in nl80211_prepare_vendor_dump()
14787 return -ENOMEM; in nl80211_prepare_vendor_dump()
14789 err = nlmsg_parse_deprecated(cb->nlh, in nl80211_prepare_vendor_dump()
14798 err = -EINVAL; in nl80211_prepare_vendor_dump()
14802 *wdev = __cfg80211_wdev_from_attrs(NULL, sock_net(skb->sk), attrbuf); in nl80211_prepare_vendor_dump()
14806 *rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk), attrbuf); in nl80211_prepare_vendor_dump()
14815 for (i = 0; i < (*rdev)->wiphy.n_vendor_commands; i++) { in nl80211_prepare_vendor_dump()
14818 vcmd = &(*rdev)->wiphy.vendor_commands[i]; in nl80211_prepare_vendor_dump()
14820 if (vcmd->info.vendor_id != vid || vcmd->info.subcmd != subcmd) in nl80211_prepare_vendor_dump()
14823 if (!vcmd->dumpit) { in nl80211_prepare_vendor_dump()
14824 err = -EOPNOTSUPP; in nl80211_prepare_vendor_dump()
14833 err = -EOPNOTSUPP; in nl80211_prepare_vendor_dump()
14842 &(*rdev)->wiphy.vendor_commands[vcmd_idx], in nl80211_prepare_vendor_dump()
14844 cb->extack); in nl80211_prepare_vendor_dump()
14849 /* 0 is the first index - add 1 to parse only once */ in nl80211_prepare_vendor_dump()
14850 cb->args[0] = (*rdev)->wiphy_idx + 1; in nl80211_prepare_vendor_dump()
14852 cb->args[1] = *wdev ? (*wdev)->identifier + 1 : 0; in nl80211_prepare_vendor_dump()
14853 cb->args[2] = vcmd_idx; in nl80211_prepare_vendor_dump()
14854 cb->args[3] = (unsigned long)data; in nl80211_prepare_vendor_dump()
14855 cb->args[4] = data_len; in nl80211_prepare_vendor_dump()
14881 vcmd_idx = cb->args[2]; in nl80211_vendor_cmd_dump()
14882 data = (void *)cb->args[3]; in nl80211_vendor_cmd_dump()
14883 data_len = cb->args[4]; in nl80211_vendor_cmd_dump()
14884 vcmd = &rdev->wiphy.vendor_commands[vcmd_idx]; in nl80211_vendor_cmd_dump()
14886 if (vcmd->flags & (WIPHY_VENDOR_CMD_NEED_WDEV | in nl80211_vendor_cmd_dump()
14889 err = -EINVAL; in nl80211_vendor_cmd_dump()
14892 if (vcmd->flags & WIPHY_VENDOR_CMD_NEED_NETDEV && in nl80211_vendor_cmd_dump()
14893 !wdev->netdev) { in nl80211_vendor_cmd_dump()
14894 err = -EINVAL; in nl80211_vendor_cmd_dump()
14898 if (vcmd->flags & WIPHY_VENDOR_CMD_NEED_RUNNING) { in nl80211_vendor_cmd_dump()
14900 err = -ENETDOWN; in nl80211_vendor_cmd_dump()
14907 void *hdr = nl80211hdr_put(skb, NETLINK_CB(cb->skb).portid, in nl80211_vendor_cmd_dump()
14908 cb->nlh->nlmsg_seq, NLM_F_MULTI, in nl80211_vendor_cmd_dump()
14913 if (nla_put_u32(skb, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_vendor_cmd_dump()
14928 err = vcmd->dumpit(&rdev->wiphy, wdev, skb, data, data_len, in nl80211_vendor_cmd_dump()
14929 (unsigned long *)&cb->args[5]); in nl80211_vendor_cmd_dump()
14932 if (err == -ENOBUFS || err == -ENOENT) { in nl80211_vendor_cmd_dump()
14943 err = skb->len; in nl80211_vendor_cmd_dump()
14956 if (WARN_ON(!rdev->cur_cmd_info)) in __cfg80211_alloc_reply_skb()
14960 rdev->cur_cmd_info->snd_portid, in __cfg80211_alloc_reply_skb()
14961 rdev->cur_cmd_info->snd_seq, in __cfg80211_alloc_reply_skb()
14968 struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0]; in cfg80211_vendor_cmd_reply()
14969 void *hdr = ((void **)skb->cb)[1]; in cfg80211_vendor_cmd_reply()
14970 struct nlattr *data = ((void **)skb->cb)[2]; in cfg80211_vendor_cmd_reply()
14973 memset(skb->cb, 0, sizeof(skb->cb)); in cfg80211_vendor_cmd_reply()
14975 if (WARN_ON(!rdev->cur_cmd_info)) { in cfg80211_vendor_cmd_reply()
14977 return -EINVAL; in cfg80211_vendor_cmd_reply()
14982 return genlmsg_reply(skb, rdev->cur_cmd_info); in cfg80211_vendor_cmd_reply()
14990 if (WARN_ON(!rdev->cur_cmd_info)) in cfg80211_vendor_cmd_get_sender()
14993 return rdev->cur_cmd_info->snd_portid; in cfg80211_vendor_cmd_get_sender()
15000 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_qos_map()
15002 struct net_device *dev = info->user_ptr[1]; in nl80211_set_qos_map()
15006 if (!rdev->ops->set_qos_map) in nl80211_set_qos_map()
15007 return -EOPNOTSUPP; in nl80211_set_qos_map()
15009 if (info->attrs[NL80211_ATTR_QOS_MAP]) { in nl80211_set_qos_map()
15010 pos = nla_data(info->attrs[NL80211_ATTR_QOS_MAP]); in nl80211_set_qos_map()
15011 len = nla_len(info->attrs[NL80211_ATTR_QOS_MAP]); in nl80211_set_qos_map()
15014 return -EINVAL; in nl80211_set_qos_map()
15018 return -ENOMEM; in nl80211_set_qos_map()
15020 num_des = (len - IEEE80211_QOS_MAP_LEN_MIN) >> 1; in nl80211_set_qos_map()
15024 memcpy(qos_map->dscp_exception, pos, des_len); in nl80211_set_qos_map()
15025 qos_map->num_des = num_des; in nl80211_set_qos_map()
15027 if (qos_map->dscp_exception[des].up > 7) { in nl80211_set_qos_map()
15029 return -EINVAL; in nl80211_set_qos_map()
15034 memcpy(qos_map->up, pos, IEEE80211_QOS_MAP_LEN_MIN); in nl80211_set_qos_map()
15037 wdev_lock(dev->ieee80211_ptr); in nl80211_set_qos_map()
15038 ret = nl80211_key_allowed(dev->ieee80211_ptr); in nl80211_set_qos_map()
15041 wdev_unlock(dev->ieee80211_ptr); in nl80211_set_qos_map()
15049 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_add_tx_ts()
15050 struct net_device *dev = info->user_ptr[1]; in nl80211_add_tx_ts()
15051 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_add_tx_ts()
15057 if (!(rdev->wiphy.features & NL80211_FEATURE_SUPPORTS_WMM_ADMISSION)) in nl80211_add_tx_ts()
15058 return -EOPNOTSUPP; in nl80211_add_tx_ts()
15060 if (!info->attrs[NL80211_ATTR_TSID] || !info->attrs[NL80211_ATTR_MAC] || in nl80211_add_tx_ts()
15061 !info->attrs[NL80211_ATTR_USER_PRIO]) in nl80211_add_tx_ts()
15062 return -EINVAL; in nl80211_add_tx_ts()
15064 tsid = nla_get_u8(info->attrs[NL80211_ATTR_TSID]); in nl80211_add_tx_ts()
15065 up = nla_get_u8(info->attrs[NL80211_ATTR_USER_PRIO]); in nl80211_add_tx_ts()
15067 /* WMM uses TIDs 0-7 even for TSPEC */ in nl80211_add_tx_ts()
15073 return -EINVAL; in nl80211_add_tx_ts()
15076 peer = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_add_tx_ts()
15078 if (info->attrs[NL80211_ATTR_ADMITTED_TIME]) { in nl80211_add_tx_ts()
15080 nla_get_u16(info->attrs[NL80211_ATTR_ADMITTED_TIME]); in nl80211_add_tx_ts()
15082 return -EINVAL; in nl80211_add_tx_ts()
15086 switch (wdev->iftype) { in nl80211_add_tx_ts()
15089 if (wdev->connected) in nl80211_add_tx_ts()
15091 err = -ENOTCONN; in nl80211_add_tx_ts()
15094 err = -EOPNOTSUPP; in nl80211_add_tx_ts()
15107 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_del_tx_ts()
15108 struct net_device *dev = info->user_ptr[1]; in nl80211_del_tx_ts()
15109 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_del_tx_ts()
15114 if (!info->attrs[NL80211_ATTR_TSID] || !info->attrs[NL80211_ATTR_MAC]) in nl80211_del_tx_ts()
15115 return -EINVAL; in nl80211_del_tx_ts()
15117 tsid = nla_get_u8(info->attrs[NL80211_ATTR_TSID]); in nl80211_del_tx_ts()
15118 peer = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_del_tx_ts()
15130 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_tdls_channel_switch()
15131 struct net_device *dev = info->user_ptr[1]; in nl80211_tdls_channel_switch()
15132 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_tdls_channel_switch()
15138 if (!rdev->ops->tdls_channel_switch || in nl80211_tdls_channel_switch()
15139 !(rdev->wiphy.features & NL80211_FEATURE_TDLS_CHANNEL_SWITCH)) in nl80211_tdls_channel_switch()
15140 return -EOPNOTSUPP; in nl80211_tdls_channel_switch()
15142 switch (dev->ieee80211_ptr->iftype) { in nl80211_tdls_channel_switch()
15147 return -EOPNOTSUPP; in nl80211_tdls_channel_switch()
15150 if (!info->attrs[NL80211_ATTR_MAC] || in nl80211_tdls_channel_switch()
15151 !info->attrs[NL80211_ATTR_OPER_CLASS]) in nl80211_tdls_channel_switch()
15152 return -EINVAL; in nl80211_tdls_channel_switch()
15159 * Don't allow wide channels on the 2.4Ghz band, as per IEEE802.11-2012 in nl80211_tdls_channel_switch()
15163 if (chandef.chan->band == NL80211_BAND_2GHZ && in nl80211_tdls_channel_switch()
15164 chandef.width != NL80211_CHAN_WIDTH_20_NOHT && in nl80211_tdls_channel_switch()
15165 chandef.width != NL80211_CHAN_WIDTH_20) in nl80211_tdls_channel_switch()
15166 return -EINVAL; in nl80211_tdls_channel_switch()
15169 if (!cfg80211_reg_can_beacon_relax(&rdev->wiphy, &chandef, in nl80211_tdls_channel_switch()
15170 wdev->iftype)) in nl80211_tdls_channel_switch()
15171 return -EINVAL; in nl80211_tdls_channel_switch()
15174 if (cfg80211_chandef_dfs_required(wdev->wiphy, &chandef, wdev->iftype)) in nl80211_tdls_channel_switch()
15175 return -EINVAL; in nl80211_tdls_channel_switch()
15177 addr = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_tdls_channel_switch()
15178 oper_class = nla_get_u8(info->attrs[NL80211_ATTR_OPER_CLASS]); in nl80211_tdls_channel_switch()
15190 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_tdls_cancel_channel_switch()
15191 struct net_device *dev = info->user_ptr[1]; in nl80211_tdls_cancel_channel_switch()
15192 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_tdls_cancel_channel_switch()
15195 if (!rdev->ops->tdls_channel_switch || in nl80211_tdls_cancel_channel_switch()
15196 !rdev->ops->tdls_cancel_channel_switch || in nl80211_tdls_cancel_channel_switch()
15197 !(rdev->wiphy.features & NL80211_FEATURE_TDLS_CHANNEL_SWITCH)) in nl80211_tdls_cancel_channel_switch()
15198 return -EOPNOTSUPP; in nl80211_tdls_cancel_channel_switch()
15200 switch (dev->ieee80211_ptr->iftype) { in nl80211_tdls_cancel_channel_switch()
15205 return -EOPNOTSUPP; in nl80211_tdls_cancel_channel_switch()
15208 if (!info->attrs[NL80211_ATTR_MAC]) in nl80211_tdls_cancel_channel_switch()
15209 return -EINVAL; in nl80211_tdls_cancel_channel_switch()
15211 addr = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_tdls_cancel_channel_switch()
15223 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_multicast_to_unicast()
15224 struct net_device *dev = info->user_ptr[1]; in nl80211_set_multicast_to_unicast()
15225 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_set_multicast_to_unicast()
15229 if (!rdev->ops->set_multicast_to_unicast) in nl80211_set_multicast_to_unicast()
15230 return -EOPNOTSUPP; in nl80211_set_multicast_to_unicast()
15232 if (wdev->iftype != NL80211_IFTYPE_AP && in nl80211_set_multicast_to_unicast()
15233 wdev->iftype != NL80211_IFTYPE_P2P_GO) in nl80211_set_multicast_to_unicast()
15234 return -EOPNOTSUPP; in nl80211_set_multicast_to_unicast()
15236 nla = info->attrs[NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED]; in nl80211_set_multicast_to_unicast()
15244 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_pmk()
15245 struct net_device *dev = info->user_ptr[1]; in nl80211_set_pmk()
15246 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_set_pmk()
15250 if (wdev->iftype != NL80211_IFTYPE_STATION && in nl80211_set_pmk()
15251 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) in nl80211_set_pmk()
15252 return -EOPNOTSUPP; in nl80211_set_pmk()
15254 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_set_pmk()
15256 return -EOPNOTSUPP; in nl80211_set_pmk()
15258 if (!info->attrs[NL80211_ATTR_MAC] || !info->attrs[NL80211_ATTR_PMK]) in nl80211_set_pmk()
15259 return -EINVAL; in nl80211_set_pmk()
15262 if (!wdev->connected) { in nl80211_set_pmk()
15263 ret = -ENOTCONN; in nl80211_set_pmk()
15267 pmk_conf.aa = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_set_pmk()
15268 if (memcmp(pmk_conf.aa, wdev->u.client.connected_addr, ETH_ALEN)) { in nl80211_set_pmk()
15269 ret = -EINVAL; in nl80211_set_pmk()
15273 pmk_conf.pmk = nla_data(info->attrs[NL80211_ATTR_PMK]); in nl80211_set_pmk()
15274 pmk_conf.pmk_len = nla_len(info->attrs[NL80211_ATTR_PMK]); in nl80211_set_pmk()
15277 ret = -EINVAL; in nl80211_set_pmk()
15281 if (info->attrs[NL80211_ATTR_PMKR0_NAME]) in nl80211_set_pmk()
15283 nla_data(info->attrs[NL80211_ATTR_PMKR0_NAME]); in nl80211_set_pmk()
15293 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_del_pmk()
15294 struct net_device *dev = info->user_ptr[1]; in nl80211_del_pmk()
15295 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_del_pmk()
15299 if (wdev->iftype != NL80211_IFTYPE_STATION && in nl80211_del_pmk()
15300 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) in nl80211_del_pmk()
15301 return -EOPNOTSUPP; in nl80211_del_pmk()
15303 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_del_pmk()
15305 return -EOPNOTSUPP; in nl80211_del_pmk()
15307 if (!info->attrs[NL80211_ATTR_MAC]) in nl80211_del_pmk()
15308 return -EINVAL; in nl80211_del_pmk()
15311 aa = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_del_pmk()
15320 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_external_auth()
15321 struct net_device *dev = info->user_ptr[1]; in nl80211_external_auth()
15324 if (!rdev->ops->external_auth) in nl80211_external_auth()
15325 return -EOPNOTSUPP; in nl80211_external_auth()
15327 if (!info->attrs[NL80211_ATTR_SSID] && in nl80211_external_auth()
15328 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && in nl80211_external_auth()
15329 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) in nl80211_external_auth()
15330 return -EINVAL; in nl80211_external_auth()
15332 if (!info->attrs[NL80211_ATTR_BSSID]) in nl80211_external_auth()
15333 return -EINVAL; in nl80211_external_auth()
15335 if (!info->attrs[NL80211_ATTR_STATUS_CODE]) in nl80211_external_auth()
15336 return -EINVAL; in nl80211_external_auth()
15340 if (info->attrs[NL80211_ATTR_SSID]) { in nl80211_external_auth()
15341 params.ssid.ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]); in nl80211_external_auth()
15343 return -EINVAL; in nl80211_external_auth()
15345 nla_data(info->attrs[NL80211_ATTR_SSID]), in nl80211_external_auth()
15349 memcpy(params.bssid, nla_data(info->attrs[NL80211_ATTR_BSSID]), in nl80211_external_auth()
15352 params.status = nla_get_u16(info->attrs[NL80211_ATTR_STATUS_CODE]); in nl80211_external_auth()
15354 if (info->attrs[NL80211_ATTR_PMKID]) in nl80211_external_auth()
15355 params.pmkid = nla_data(info->attrs[NL80211_ATTR_PMKID]); in nl80211_external_auth()
15362 bool dont_wait_for_ack = info->attrs[NL80211_ATTR_DONT_WAIT_FOR_ACK]; in nl80211_tx_control_port()
15363 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_tx_control_port()
15364 struct net_device *dev = info->user_ptr[1]; in nl80211_tx_control_port()
15365 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_tx_control_port()
15375 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_tx_control_port()
15377 return -EOPNOTSUPP; in nl80211_tx_control_port()
15379 if (!rdev->ops->tx_control_port) in nl80211_tx_control_port()
15380 return -EOPNOTSUPP; in nl80211_tx_control_port()
15382 if (!info->attrs[NL80211_ATTR_FRAME] || in nl80211_tx_control_port()
15383 !info->attrs[NL80211_ATTR_MAC] || in nl80211_tx_control_port()
15384 !info->attrs[NL80211_ATTR_CONTROL_PORT_ETHERTYPE]) { in nl80211_tx_control_port()
15386 return -EINVAL; in nl80211_tx_control_port()
15391 switch (wdev->iftype) { in nl80211_tx_control_port()
15397 if (wdev->u.ibss.current_bss) in nl80211_tx_control_port()
15399 err = -ENOTCONN; in nl80211_tx_control_port()
15403 if (wdev->connected) in nl80211_tx_control_port()
15405 err = -ENOTCONN; in nl80211_tx_control_port()
15408 err = -EOPNOTSUPP; in nl80211_tx_control_port()
15414 buf = nla_data(info->attrs[NL80211_ATTR_FRAME]); in nl80211_tx_control_port()
15415 len = nla_len(info->attrs[NL80211_ATTR_FRAME]); in nl80211_tx_control_port()
15416 dest = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_tx_control_port()
15417 proto = nla_get_u16(info->attrs[NL80211_ATTR_CONTROL_PORT_ETHERTYPE]); in nl80211_tx_control_port()
15419 nla_get_flag(info->attrs[NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT]); in nl80211_tx_control_port()
15421 link_id = nl80211_link_id_or_invalid(info->attrs); in nl80211_tx_control_port()
15427 nl_set_extack_cookie_u64(info->extack, cookie); in nl80211_tx_control_port()
15437 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_get_ftm_responder_stats()
15438 struct net_device *dev = info->user_ptr[1]; in nl80211_get_ftm_responder_stats()
15439 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_get_ftm_responder_stats()
15441 unsigned int link_id = nl80211_link_id(info->attrs); in nl80211_get_ftm_responder_stats()
15447 if (wdev->iftype != NL80211_IFTYPE_AP || in nl80211_get_ftm_responder_stats()
15448 !wdev->links[link_id].ap.beacon_interval) in nl80211_get_ftm_responder_stats()
15449 return -EOPNOTSUPP; in nl80211_get_ftm_responder_stats()
15456 return -ENODATA; in nl80211_get_ftm_responder_stats()
15460 return -ENOMEM; in nl80211_get_ftm_responder_stats()
15462 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, in nl80211_get_ftm_responder_stats()
15467 if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) in nl80211_get_ftm_responder_stats()
15504 return -ENOBUFS; in nl80211_get_ftm_responder_stats()
15509 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_update_owe_info()
15511 struct net_device *dev = info->user_ptr[1]; in nl80211_update_owe_info()
15513 if (!rdev->ops->update_owe_info) in nl80211_update_owe_info()
15514 return -EOPNOTSUPP; in nl80211_update_owe_info()
15516 if (!info->attrs[NL80211_ATTR_STATUS_CODE] || in nl80211_update_owe_info()
15517 !info->attrs[NL80211_ATTR_MAC]) in nl80211_update_owe_info()
15518 return -EINVAL; in nl80211_update_owe_info()
15521 owe_info.status = nla_get_u16(info->attrs[NL80211_ATTR_STATUS_CODE]); in nl80211_update_owe_info()
15522 nla_memcpy(owe_info.peer, info->attrs[NL80211_ATTR_MAC], ETH_ALEN); in nl80211_update_owe_info()
15524 if (info->attrs[NL80211_ATTR_IE]) { in nl80211_update_owe_info()
15525 owe_info.ie = nla_data(info->attrs[NL80211_ATTR_IE]); in nl80211_update_owe_info()
15526 owe_info.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); in nl80211_update_owe_info()
15534 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_probe_mesh_link()
15535 struct net_device *dev = info->user_ptr[1]; in nl80211_probe_mesh_link()
15536 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_probe_mesh_link()
15543 if (!rdev->ops->probe_mesh_link || !rdev->ops->get_station) in nl80211_probe_mesh_link()
15544 return -EOPNOTSUPP; in nl80211_probe_mesh_link()
15546 if (!info->attrs[NL80211_ATTR_MAC] || in nl80211_probe_mesh_link()
15547 !info->attrs[NL80211_ATTR_FRAME]) { in nl80211_probe_mesh_link()
15549 return -EINVAL; in nl80211_probe_mesh_link()
15552 if (wdev->iftype != NL80211_IFTYPE_MESH_POINT) in nl80211_probe_mesh_link()
15553 return -EOPNOTSUPP; in nl80211_probe_mesh_link()
15555 dest = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_probe_mesh_link()
15556 buf = nla_data(info->attrs[NL80211_ATTR_FRAME]); in nl80211_probe_mesh_link()
15557 len = nla_len(info->attrs[NL80211_ATTR_FRAME]); in nl80211_probe_mesh_link()
15560 return -EINVAL; in nl80211_probe_mesh_link()
15563 !ether_addr_equal(buf + ETH_ALEN, dev->dev_addr)) in nl80211_probe_mesh_link()
15564 return -EINVAL; in nl80211_probe_mesh_link()
15581 struct netlink_ext_ack *extack = info->extack; in parse_tid_conf()
15586 return -EINVAL; in parse_tid_conf()
15588 tid_conf->config_override = in parse_tid_conf()
15590 tid_conf->tids = nla_get_u16(attrs[NL80211_TID_CONFIG_ATTR_TIDS]); in parse_tid_conf()
15592 if (tid_conf->config_override) { in parse_tid_conf()
15593 if (rdev->ops->reset_tid_config) { in parse_tid_conf()
15595 tid_conf->tids); in parse_tid_conf()
15599 return -EINVAL; in parse_tid_conf()
15604 tid_conf->mask |= BIT(NL80211_TID_CONFIG_ATTR_NOACK); in parse_tid_conf()
15605 tid_conf->noack = in parse_tid_conf()
15610 tid_conf->mask |= BIT(NL80211_TID_CONFIG_ATTR_RETRY_SHORT); in parse_tid_conf()
15611 tid_conf->retry_short = in parse_tid_conf()
15614 if (tid_conf->retry_short > rdev->wiphy.max_data_retry_count) in parse_tid_conf()
15615 return -EINVAL; in parse_tid_conf()
15619 tid_conf->mask |= BIT(NL80211_TID_CONFIG_ATTR_RETRY_LONG); in parse_tid_conf()
15620 tid_conf->retry_long = in parse_tid_conf()
15623 if (tid_conf->retry_long > rdev->wiphy.max_data_retry_count) in parse_tid_conf()
15624 return -EINVAL; in parse_tid_conf()
15628 tid_conf->mask |= BIT(NL80211_TID_CONFIG_ATTR_AMPDU_CTRL); in parse_tid_conf()
15629 tid_conf->ampdu = in parse_tid_conf()
15634 tid_conf->mask |= BIT(NL80211_TID_CONFIG_ATTR_RTSCTS_CTRL); in parse_tid_conf()
15635 tid_conf->rtscts = in parse_tid_conf()
15640 tid_conf->mask |= BIT(NL80211_TID_CONFIG_ATTR_AMSDU_CTRL); in parse_tid_conf()
15641 tid_conf->amsdu = in parse_tid_conf()
15648 tid_conf->txrate_type = nla_get_u8(attrs[idx]); in parse_tid_conf()
15650 if (tid_conf->txrate_type != NL80211_TX_RATE_AUTOMATIC) { in parse_tid_conf()
15653 &tid_conf->txrate_mask, dev, in parse_tid_conf()
15658 tid_conf->mask |= BIT(NL80211_TID_CONFIG_ATTR_TX_RATE); in parse_tid_conf()
15660 tid_conf->mask |= BIT(NL80211_TID_CONFIG_ATTR_TX_RATE_TYPE); in parse_tid_conf()
15664 mask = rdev->wiphy.tid_config_support.peer; in parse_tid_conf()
15666 mask = rdev->wiphy.tid_config_support.vif; in parse_tid_conf()
15668 if (tid_conf->mask & ~mask) { in parse_tid_conf()
15670 return -ENOTSUPP; in parse_tid_conf()
15679 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_tid_config()
15681 unsigned int link_id = nl80211_link_id(info->attrs); in nl80211_set_tid_config()
15682 struct net_device *dev = info->user_ptr[1]; in nl80211_set_tid_config()
15686 int ret = -EINVAL; in nl80211_set_tid_config()
15689 if (!info->attrs[NL80211_ATTR_TID_CONFIG]) in nl80211_set_tid_config()
15690 return -EINVAL; in nl80211_set_tid_config()
15692 if (!rdev->ops->set_tid_config) in nl80211_set_tid_config()
15693 return -EOPNOTSUPP; in nl80211_set_tid_config()
15695 nla_for_each_nested(tid, info->attrs[NL80211_ATTR_TID_CONFIG], in nl80211_set_tid_config()
15702 return -ENOMEM; in nl80211_set_tid_config()
15704 tid_config->n_tid_conf = num_conf; in nl80211_set_tid_config()
15706 if (info->attrs[NL80211_ATTR_MAC]) in nl80211_set_tid_config()
15707 tid_config->peer = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_set_tid_config()
15709 wdev_lock(dev->ieee80211_ptr); in nl80211_set_tid_config()
15711 nla_for_each_nested(tid, info->attrs[NL80211_ATTR_TID_CONFIG], in nl80211_set_tid_config()
15720 &tid_config->tid_conf[conf_idx], in nl80211_set_tid_config()
15721 info, tid_config->peer, link_id); in nl80211_set_tid_config()
15732 wdev_unlock(dev->ieee80211_ptr); in nl80211_set_tid_config()
15738 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_color_change()
15740 struct net_device *dev = info->user_ptr[1]; in nl80211_color_change()
15741 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_color_change()
15746 if (!rdev->ops->color_change) in nl80211_color_change()
15747 return -EOPNOTSUPP; in nl80211_color_change()
15749 if (!wiphy_ext_feature_isset(&rdev->wiphy, in nl80211_color_change()
15751 return -EOPNOTSUPP; in nl80211_color_change()
15753 if (wdev->iftype != NL80211_IFTYPE_AP) in nl80211_color_change()
15754 return -EOPNOTSUPP; in nl80211_color_change()
15756 if (!info->attrs[NL80211_ATTR_COLOR_CHANGE_COUNT] || in nl80211_color_change()
15757 !info->attrs[NL80211_ATTR_COLOR_CHANGE_COLOR] || in nl80211_color_change()
15758 !info->attrs[NL80211_ATTR_COLOR_CHANGE_ELEMS]) in nl80211_color_change()
15759 return -EINVAL; in nl80211_color_change()
15761 params.count = nla_get_u8(info->attrs[NL80211_ATTR_COLOR_CHANGE_COUNT]); in nl80211_color_change()
15762 params.color = nla_get_u8(info->attrs[NL80211_ATTR_COLOR_CHANGE_COLOR]); in nl80211_color_change()
15764 err = nl80211_parse_beacon(rdev, info->attrs, &params.beacon_next); in nl80211_color_change()
15770 return -ENOMEM; in nl80211_color_change()
15773 info->attrs[NL80211_ATTR_COLOR_CHANGE_ELEMS], in nl80211_color_change()
15774 nl80211_policy, info->extack); in nl80211_color_change()
15783 err = -EINVAL; in nl80211_color_change()
15788 err = -EINVAL; in nl80211_color_change()
15794 err = -EINVAL; in nl80211_color_change()
15799 err = -EINVAL; in nl80211_color_change()
15808 err = -EINVAL; in nl80211_color_change()
15814 err = -EINVAL; in nl80211_color_change()
15820 err = -EINVAL; in nl80211_color_change()
15841 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_fils_aad()
15842 struct net_device *dev = info->user_ptr[1]; in nl80211_set_fils_aad()
15846 if (!info->attrs[NL80211_ATTR_MAC] || in nl80211_set_fils_aad()
15847 !info->attrs[NL80211_ATTR_FILS_KEK] || in nl80211_set_fils_aad()
15848 !info->attrs[NL80211_ATTR_FILS_NONCES]) in nl80211_set_fils_aad()
15849 return -EINVAL; in nl80211_set_fils_aad()
15851 fils_aad.macaddr = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_set_fils_aad()
15852 fils_aad.kek_len = nla_len(info->attrs[NL80211_ATTR_FILS_KEK]); in nl80211_set_fils_aad()
15853 fils_aad.kek = nla_data(info->attrs[NL80211_ATTR_FILS_KEK]); in nl80211_set_fils_aad()
15854 nonces = nla_data(info->attrs[NL80211_ATTR_FILS_NONCES]); in nl80211_set_fils_aad()
15863 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_add_link()
15864 unsigned int link_id = nl80211_link_id(info->attrs); in nl80211_add_link()
15865 struct net_device *dev = info->user_ptr[1]; in nl80211_add_link()
15866 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_add_link()
15869 if (!(wdev->wiphy->flags & WIPHY_FLAG_SUPPORTS_MLO)) in nl80211_add_link()
15870 return -EINVAL; in nl80211_add_link()
15872 switch (wdev->iftype) { in nl80211_add_link()
15876 return -EINVAL; in nl80211_add_link()
15879 if (!info->attrs[NL80211_ATTR_MAC] || in nl80211_add_link()
15880 !is_valid_ether_addr(nla_data(info->attrs[NL80211_ATTR_MAC]))) in nl80211_add_link()
15881 return -EINVAL; in nl80211_add_link()
15884 wdev->valid_links |= BIT(link_id); in nl80211_add_link()
15885 ether_addr_copy(wdev->links[link_id].addr, in nl80211_add_link()
15886 nla_data(info->attrs[NL80211_ATTR_MAC])); in nl80211_add_link()
15890 wdev->valid_links &= ~BIT(link_id); in nl80211_add_link()
15891 eth_zero_addr(wdev->links[link_id].addr); in nl80211_add_link()
15900 unsigned int link_id = nl80211_link_id(info->attrs); in nl80211_remove_link()
15901 struct net_device *dev = info->user_ptr[1]; in nl80211_remove_link()
15902 struct wireless_dev *wdev = dev->ieee80211_ptr; in nl80211_remove_link()
15905 if (!info->attrs[NL80211_ATTR_MLO_LINK_ID]) in nl80211_remove_link()
15906 return -EINVAL; in nl80211_remove_link()
15908 switch (wdev->iftype) { in nl80211_remove_link()
15912 return -EINVAL; in nl80211_remove_link()
15927 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_add_mod_link_station()
15928 struct net_device *dev = info->user_ptr[1]; in nl80211_add_mod_link_station()
15931 if ((add && !rdev->ops->add_link_station) || in nl80211_add_mod_link_station()
15932 (!add && !rdev->ops->mod_link_station)) in nl80211_add_mod_link_station()
15933 return -EOPNOTSUPP; in nl80211_add_mod_link_station()
15935 if (add && !info->attrs[NL80211_ATTR_MAC]) in nl80211_add_mod_link_station()
15936 return -EINVAL; in nl80211_add_mod_link_station()
15938 if (!info->attrs[NL80211_ATTR_MLD_ADDR]) in nl80211_add_mod_link_station()
15939 return -EINVAL; in nl80211_add_mod_link_station()
15941 if (add && !info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]) in nl80211_add_mod_link_station()
15942 return -EINVAL; in nl80211_add_mod_link_station()
15944 params.mld_mac = nla_data(info->attrs[NL80211_ATTR_MLD_ADDR]); in nl80211_add_mod_link_station()
15946 if (info->attrs[NL80211_ATTR_MAC]) { in nl80211_add_mod_link_station()
15947 params.link_mac = nla_data(info->attrs[NL80211_ATTR_MAC]); in nl80211_add_mod_link_station()
15949 return -EINVAL; in nl80211_add_mod_link_station()
15952 if (!info->attrs[NL80211_ATTR_MLO_LINK_ID]) in nl80211_add_mod_link_station()
15953 return -EINVAL; in nl80211_add_mod_link_station()
15955 params.link_id = nla_get_u8(info->attrs[NL80211_ATTR_MLO_LINK_ID]); in nl80211_add_mod_link_station()
15957 if (info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]) { in nl80211_add_mod_link_station()
15959 nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]); in nl80211_add_mod_link_station()
15961 nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]); in nl80211_add_mod_link_station()
15964 if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) in nl80211_add_mod_link_station()
15966 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); in nl80211_add_mod_link_station()
15968 if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) in nl80211_add_mod_link_station()
15970 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]); in nl80211_add_mod_link_station()
15972 if (info->attrs[NL80211_ATTR_HE_CAPABILITY]) { in nl80211_add_mod_link_station()
15974 nla_data(info->attrs[NL80211_ATTR_HE_CAPABILITY]); in nl80211_add_mod_link_station()
15976 nla_len(info->attrs[NL80211_ATTR_HE_CAPABILITY]); in nl80211_add_mod_link_station()
15978 if (info->attrs[NL80211_ATTR_EHT_CAPABILITY]) { in nl80211_add_mod_link_station()
15980 nla_data(info->attrs[NL80211_ATTR_EHT_CAPABILITY]); in nl80211_add_mod_link_station()
15982 nla_len(info->attrs[NL80211_ATTR_EHT_CAPABILITY]); in nl80211_add_mod_link_station()
15988 return -EINVAL; in nl80211_add_mod_link_station()
15992 if (info->attrs[NL80211_ATTR_HE_6GHZ_CAPABILITY]) in nl80211_add_mod_link_station()
15994 nla_data(info->attrs[NL80211_ATTR_HE_6GHZ_CAPABILITY]); in nl80211_add_mod_link_station()
15996 if (info->attrs[NL80211_ATTR_OPMODE_NOTIF]) { in nl80211_add_mod_link_station()
15999 nla_get_u8(info->attrs[NL80211_ATTR_OPMODE_NOTIF]); in nl80211_add_mod_link_station()
16007 wdev_lock(dev->ieee80211_ptr); in nl80211_add_mod_link_station()
16012 wdev_unlock(dev->ieee80211_ptr); in nl80211_add_mod_link_station()
16033 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_remove_link_station()
16034 struct net_device *dev = info->user_ptr[1]; in nl80211_remove_link_station()
16037 if (!rdev->ops->del_link_station) in nl80211_remove_link_station()
16038 return -EOPNOTSUPP; in nl80211_remove_link_station()
16040 if (!info->attrs[NL80211_ATTR_MLD_ADDR] || in nl80211_remove_link_station()
16041 !info->attrs[NL80211_ATTR_MLO_LINK_ID]) in nl80211_remove_link_station()
16042 return -EINVAL; in nl80211_remove_link_station()
16044 params.mld_mac = nla_data(info->attrs[NL80211_ATTR_MLD_ADDR]); in nl80211_remove_link_station()
16045 params.link_id = nla_get_u8(info->attrs[NL80211_ATTR_MLO_LINK_ID]); in nl80211_remove_link_station()
16047 wdev_lock(dev->ieee80211_ptr); in nl80211_remove_link_station()
16049 wdev_unlock(dev->ieee80211_ptr); in nl80211_remove_link_station()
16151 if (WARN_ON(ops->internal_flags >= ARRAY_SIZE(nl80211_internal_flags))) in nl80211_pre_doit()
16152 return -EINVAL; in nl80211_pre_doit()
16154 internal_flags = nl80211_internal_flags[ops->internal_flags]; in nl80211_pre_doit()
16163 info->user_ptr[0] = rdev; in nl80211_pre_doit()
16167 info->attrs); in nl80211_pre_doit()
16173 dev = wdev->netdev; in nl80211_pre_doit()
16175 rdev = wiphy_to_rdev(wdev->wiphy); in nl80211_pre_doit()
16179 err = -EINVAL; in nl80211_pre_doit()
16183 info->user_ptr[1] = dev; in nl80211_pre_doit()
16185 info->user_ptr[1] = wdev; in nl80211_pre_doit()
16190 err = -ENETDOWN; in nl80211_pre_doit()
16194 info->user_ptr[0] = rdev; in nl80211_pre_doit()
16198 struct nlattr *link_id = info->attrs[NL80211_ATTR_MLO_LINK_ID]; in nl80211_pre_doit()
16201 err = -EINVAL; in nl80211_pre_doit()
16205 /* MLO -> require valid link ID */ in nl80211_pre_doit()
16206 if (wdev->valid_links && in nl80211_pre_doit()
16208 !(wdev->valid_links & BIT(nla_get_u8(link_id))))) { in nl80211_pre_doit()
16209 err = -EINVAL; in nl80211_pre_doit()
16213 /* non-MLO -> no link ID attribute accepted */ in nl80211_pre_doit()
16214 if (!wdev->valid_links && link_id) { in nl80211_pre_doit()
16215 err = -EINVAL; in nl80211_pre_doit()
16221 if (info->attrs[NL80211_ATTR_MLO_LINK_ID] || in nl80211_pre_doit()
16222 (wdev && wdev->valid_links)) { in nl80211_pre_doit()
16223 err = -EINVAL; in nl80211_pre_doit()
16229 wiphy_lock(&rdev->wiphy); in nl80211_pre_doit()
16231 __release(&rdev->wiphy.mtx); in nl80211_pre_doit()
16246 u32 internal_flags = nl80211_internal_flags[ops->internal_flags]; in nl80211_post_doit()
16248 if (info->user_ptr[1]) { in nl80211_post_doit()
16250 struct wireless_dev *wdev = info->user_ptr[1]; in nl80211_post_doit()
16252 dev_put(wdev->netdev); in nl80211_post_doit()
16254 dev_put(info->user_ptr[1]); in nl80211_post_doit()
16258 if (info->user_ptr[0] && in nl80211_post_doit()
16260 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_post_doit()
16263 __acquire(&rdev->wiphy.mtx); in nl80211_post_doit()
16264 wiphy_unlock(&rdev->wiphy); in nl80211_post_doit()
16289 return -EINVAL; in nl80211_set_sar_sub_specs()
16293 return -EINVAL; in nl80211_set_sar_sub_specs()
16298 if (range_index >= rdev->wiphy.sar_capa->num_freq_ranges) in nl80211_set_sar_sub_specs()
16299 return -EINVAL; in nl80211_set_sar_sub_specs()
16303 if (sar_specs->sub_specs[i].freq_range_index == range_index) in nl80211_set_sar_sub_specs()
16304 return -EINVAL; in nl80211_set_sar_sub_specs()
16307 sar_specs->sub_specs[index].power = in nl80211_set_sar_sub_specs()
16310 sar_specs->sub_specs[index].freq_range_index = range_index; in nl80211_set_sar_sub_specs()
16317 struct cfg80211_registered_device *rdev = info->user_ptr[0]; in nl80211_set_sar_specs()
16326 if (!rdev->wiphy.sar_capa || !rdev->ops->set_sar_specs) in nl80211_set_sar_specs()
16327 return -EOPNOTSUPP; in nl80211_set_sar_specs()
16329 if (!info->attrs[NL80211_ATTR_SAR_SPEC]) in nl80211_set_sar_specs()
16330 return -EINVAL; in nl80211_set_sar_specs()
16333 info->attrs[NL80211_ATTR_SAR_SPEC], in nl80211_set_sar_specs()
16337 return -EINVAL; in nl80211_set_sar_specs()
16340 if (type != rdev->wiphy.sar_capa->type) in nl80211_set_sar_specs()
16341 return -EINVAL; in nl80211_set_sar_specs()
16347 if (specs > rdev->wiphy.sar_capa->num_freq_ranges) in nl80211_set_sar_specs()
16348 return -EINVAL; in nl80211_set_sar_specs()
16352 return -ENOMEM; in nl80211_set_sar_specs()
16354 sar_spec->type = type; in nl80211_set_sar_specs()
16364 err = -EINVAL; in nl80211_set_sar_specs()
16369 err = -EINVAL; in nl80211_set_sar_specs()
16375 sar_spec->num_sub_specs = specs; in nl80211_set_sar_specs()
16377 rdev->cur_cmd_info = info; in nl80211_set_sar_specs()
16379 rdev->cur_cmd_info = NULL; in nl80211_set_sar_specs()
17267 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_notify_wiphy()
17286 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_notify_iface()
17293 struct cfg80211_scan_request *req = rdev->scan_req; in nl80211_add_scan_req()
17304 for (i = 0; i < req->n_ssids; i++) { in nl80211_add_scan_req()
17305 if (nla_put(msg, i, req->ssids[i].ssid_len, req->ssids[i].ssid)) in nl80211_add_scan_req()
17310 if (req->flags & NL80211_SCAN_FLAG_FREQ_KHZ) { in nl80211_add_scan_req()
17314 for (i = 0; i < req->n_channels; i++) { in nl80211_add_scan_req()
17316 ieee80211_channel_to_khz(req->channels[i]))) in nl80211_add_scan_req()
17325 for (i = 0; i < req->n_channels; i++) { in nl80211_add_scan_req()
17326 if (nla_put_u32(msg, i, req->channels[i]->center_freq)) in nl80211_add_scan_req()
17332 if (req->ie && in nl80211_add_scan_req()
17333 nla_put(msg, NL80211_ATTR_IE, req->ie_len, req->ie)) in nl80211_add_scan_req()
17336 if (req->flags && in nl80211_add_scan_req()
17337 nla_put_u32(msg, NL80211_ATTR_SCAN_FLAGS, req->flags)) in nl80211_add_scan_req()
17340 info = rdev->int_scan_req ? &rdev->int_scan_req->info : in nl80211_add_scan_req()
17341 &rdev->scan_req->info; in nl80211_add_scan_req()
17342 if (info->scan_start_tsf && in nl80211_add_scan_req()
17344 info->scan_start_tsf, NL80211_BSS_PAD) || in nl80211_add_scan_req()
17346 info->tsf_bssid))) in nl80211_add_scan_req()
17351 return -ENOBUFS; in nl80211_add_scan_req()
17364 return -1; in nl80211_prep_scan_msg()
17366 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_prep_scan_msg()
17367 (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX, in nl80211_prep_scan_msg()
17368 wdev->netdev->ifindex)) || in nl80211_prep_scan_msg()
17381 return -EMSGSIZE; in nl80211_prep_scan_msg()
17392 return -1; in nl80211_prep_sched_scan_msg()
17395 wiphy_to_rdev(req->wiphy)->wiphy_idx) || in nl80211_prep_sched_scan_msg()
17396 nla_put_u32(msg, NL80211_ATTR_IFINDEX, req->dev->ifindex) || in nl80211_prep_sched_scan_msg()
17397 nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, req->reqid, in nl80211_prep_sched_scan_msg()
17406 return -EMSGSIZE; in nl80211_prep_sched_scan_msg()
17424 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_send_scan_start()
17454 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_send_scan_msg()
17471 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(req->wiphy), msg, 0, in nl80211_send_sched_scan()
17479 if (nla_put_u8(msg, NL80211_ATTR_REG_INITIATOR, request->initiator)) in nl80211_reg_change_event_fill()
17482 if (request->alpha2[0] == '0' && request->alpha2[1] == '0') { in nl80211_reg_change_event_fill()
17486 } else if (request->alpha2[0] == '9' && request->alpha2[1] == '9') { in nl80211_reg_change_event_fill()
17490 } else if ((request->alpha2[0] == '9' && request->alpha2[1] == '8') || in nl80211_reg_change_event_fill()
17491 request->intersect) { in nl80211_reg_change_event_fill()
17499 request->alpha2)) in nl80211_reg_change_event_fill()
17503 if (request->wiphy_idx != WIPHY_IDX_INVALID) { in nl80211_reg_change_event_fill()
17504 struct wiphy *wiphy = wiphy_idx_to_wiphy(request->wiphy_idx); in nl80211_reg_change_event_fill()
17507 nla_put_u32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx)) in nl80211_reg_change_event_fill()
17511 wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED && in nl80211_reg_change_event_fill()
17576 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_send_mlme_event()
17577 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || in nl80211_send_mlme_event()
17601 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_send_mlme_event()
17614 NL80211_CMD_AUTHENTICATE, gfp, -1, NULL, 0, in nl80211_send_rx_auth()
17622 nl80211_send_mlme_event(rdev, netdev, data->buf, data->len, in nl80211_send_rx_assoc()
17624 data->uapsd_queues, in nl80211_send_rx_assoc()
17625 data->req_ies, data->req_ies_len, false); in nl80211_send_rx_assoc()
17633 NL80211_CMD_DEAUTHENTICATE, gfp, -1, NULL, 0, in nl80211_send_deauth()
17642 NL80211_CMD_DISASSOCIATE, gfp, -1, NULL, 0, in nl80211_send_disassoc()
17649 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_rx_unprot_mlme_mgmt()
17650 struct wiphy *wiphy = wdev->wiphy; in cfg80211_rx_unprot_mlme_mgmt()
17658 if (ieee80211_is_deauth(mgmt->frame_control)) { in cfg80211_rx_unprot_mlme_mgmt()
17660 } else if (ieee80211_is_disassoc(mgmt->frame_control)) { in cfg80211_rx_unprot_mlme_mgmt()
17662 } else if (ieee80211_is_beacon(mgmt->frame_control)) { in cfg80211_rx_unprot_mlme_mgmt()
17663 if (wdev->unprot_beacon_reported && in cfg80211_rx_unprot_mlme_mgmt()
17664 elapsed_jiffies_msecs(wdev->unprot_beacon_reported) < 10000) in cfg80211_rx_unprot_mlme_mgmt()
17667 wdev->unprot_beacon_reported = jiffies; in cfg80211_rx_unprot_mlme_mgmt()
17673 nl80211_send_mlme_event(rdev, dev, buf, len, cmd, GFP_ATOMIC, -1, in cfg80211_rx_unprot_mlme_mgmt()
17695 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_send_mlme_timeout()
17696 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || in nl80211_send_mlme_timeout()
17703 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_send_mlme_timeout()
17736 const u8 *connected_addr = cr->valid_links ? in nl80211_send_connect_result()
17737 cr->ap_mld_addr : cr->links[0].bssid; in nl80211_send_connect_result()
17739 if (cr->valid_links) { in nl80211_send_connect_result()
17745 link_info_size += cr->links[link].addr ? in nl80211_send_connect_result()
17747 link_info_size += (cr->links[link].bssid || in nl80211_send_connect_result()
17748 cr->links[link].bss) ? in nl80211_send_connect_result()
17753 msg = nlmsg_new(100 + cr->req_ie_len + cr->resp_ie_len + in nl80211_send_connect_result()
17754 cr->fils.kek_len + cr->fils.pmk_len + in nl80211_send_connect_result()
17755 (cr->fils.pmkid ? WLAN_PMKID_LEN : 0) + link_info_size, in nl80211_send_connect_result()
17766 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_send_connect_result()
17767 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || in nl80211_send_connect_result()
17771 cr->status < 0 ? WLAN_STATUS_UNSPECIFIED_FAILURE : in nl80211_send_connect_result()
17772 cr->status) || in nl80211_send_connect_result()
17773 (cr->status < 0 && in nl80211_send_connect_result()
17776 cr->timeout_reason))) || in nl80211_send_connect_result()
17777 (cr->req_ie && in nl80211_send_connect_result()
17778 nla_put(msg, NL80211_ATTR_REQ_IE, cr->req_ie_len, cr->req_ie)) || in nl80211_send_connect_result()
17779 (cr->resp_ie && in nl80211_send_connect_result()
17780 nla_put(msg, NL80211_ATTR_RESP_IE, cr->resp_ie_len, in nl80211_send_connect_result()
17781 cr->resp_ie)) || in nl80211_send_connect_result()
17782 (cr->fils.update_erp_next_seq_num && in nl80211_send_connect_result()
17784 cr->fils.erp_next_seq_num)) || in nl80211_send_connect_result()
17785 (cr->status == WLAN_STATUS_SUCCESS && in nl80211_send_connect_result()
17786 ((cr->fils.kek && in nl80211_send_connect_result()
17787 nla_put(msg, NL80211_ATTR_FILS_KEK, cr->fils.kek_len, in nl80211_send_connect_result()
17788 cr->fils.kek)) || in nl80211_send_connect_result()
17789 (cr->fils.pmk && in nl80211_send_connect_result()
17790 nla_put(msg, NL80211_ATTR_PMK, cr->fils.pmk_len, cr->fils.pmk)) || in nl80211_send_connect_result()
17791 (cr->fils.pmkid && in nl80211_send_connect_result()
17792 nla_put(msg, NL80211_ATTR_PMKID, WLAN_PMKID_LEN, cr->fils.pmkid))))) in nl80211_send_connect_result()
17795 if (cr->valid_links) { in nl80211_send_connect_result()
17805 const u8 *bssid = cr->links[link].bss ? in nl80211_send_connect_result()
17806 cr->links[link].bss->bssid : in nl80211_send_connect_result()
17807 cr->links[link].bssid; in nl80211_send_connect_result()
17816 (cr->links[link].addr && in nl80211_send_connect_result()
17818 cr->links[link].addr))) in nl80211_send_connect_result()
17829 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_send_connect_result()
17845 const u8 *connected_addr = info->ap_mld_addr ? in nl80211_send_roamed()
17846 info->ap_mld_addr : in nl80211_send_roamed()
17847 (info->links[0].bss ? in nl80211_send_roamed()
17848 info->links[0].bss->bssid : in nl80211_send_roamed()
17849 info->links[0].bssid); in nl80211_send_roamed()
17851 if (info->valid_links) { in nl80211_send_roamed()
17857 link_info_size += info->links[link].addr ? in nl80211_send_roamed()
17859 link_info_size += (info->links[link].bssid || in nl80211_send_roamed()
17860 info->links[link].bss) ? in nl80211_send_roamed()
17865 msg = nlmsg_new(100 + info->req_ie_len + info->resp_ie_len + in nl80211_send_roamed()
17866 info->fils.kek_len + info->fils.pmk_len + in nl80211_send_roamed()
17867 (info->fils.pmkid ? WLAN_PMKID_LEN : 0) + in nl80211_send_roamed()
17878 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_send_roamed()
17879 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || in nl80211_send_roamed()
17881 (info->req_ie && in nl80211_send_roamed()
17882 nla_put(msg, NL80211_ATTR_REQ_IE, info->req_ie_len, in nl80211_send_roamed()
17883 info->req_ie)) || in nl80211_send_roamed()
17884 (info->resp_ie && in nl80211_send_roamed()
17885 nla_put(msg, NL80211_ATTR_RESP_IE, info->resp_ie_len, in nl80211_send_roamed()
17886 info->resp_ie)) || in nl80211_send_roamed()
17887 (info->fils.update_erp_next_seq_num && in nl80211_send_roamed()
17889 info->fils.erp_next_seq_num)) || in nl80211_send_roamed()
17890 (info->fils.kek && in nl80211_send_roamed()
17891 nla_put(msg, NL80211_ATTR_FILS_KEK, info->fils.kek_len, in nl80211_send_roamed()
17892 info->fils.kek)) || in nl80211_send_roamed()
17893 (info->fils.pmk && in nl80211_send_roamed()
17894 nla_put(msg, NL80211_ATTR_PMK, info->fils.pmk_len, info->fils.pmk)) || in nl80211_send_roamed()
17895 (info->fils.pmkid && in nl80211_send_roamed()
17896 nla_put(msg, NL80211_ATTR_PMKID, WLAN_PMKID_LEN, info->fils.pmkid))) in nl80211_send_roamed()
17899 if (info->valid_links) { in nl80211_send_roamed()
17909 const u8 *bssid = info->links[link].bss ? in nl80211_send_roamed()
17910 info->links[link].bss->bssid : in nl80211_send_roamed()
17911 info->links[link].bssid; in nl80211_send_roamed()
17920 (info->links[link].addr && in nl80211_send_roamed()
17922 info->links[link].addr))) in nl80211_send_roamed()
17933 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_send_roamed()
17957 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_send_port_authorized()
17958 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || in nl80211_send_port_authorized()
17964 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_send_port_authorized()
17989 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_send_disconnected()
17990 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || in nl80211_send_disconnected()
18000 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_send_disconnected()
18025 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_send_ibss_bssid()
18026 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || in nl80211_send_ibss_bssid()
18032 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_send_ibss_bssid()
18044 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_notify_new_peer_candidate()
18045 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_notify_new_peer_candidate()
18049 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_MESH_POINT)) in cfg80211_notify_new_peer_candidate()
18064 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in cfg80211_notify_new_peer_candidate()
18065 nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || in cfg80211_notify_new_peer_candidate()
18075 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in cfg80211_notify_new_peer_candidate()
18102 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_michael_mic_failure()
18103 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || in nl80211_michael_mic_failure()
18106 (key_id != -1 && in nl80211_michael_mic_failure()
18113 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_michael_mic_failure()
18196 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_send_remain_on_chan_event()
18197 (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX, in nl80211_send_remain_on_chan_event()
18198 wdev->netdev->ifindex)) || in nl80211_send_remain_on_chan_event()
18201 nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, chan->center_freq) || in nl80211_send_remain_on_chan_event()
18214 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_send_remain_on_chan_event()
18225 struct wireless_dev *wdev = netdev->ieee80211_ptr; in cfg80211_assoc_comeback()
18226 struct wiphy *wiphy = wdev->wiphy; in cfg80211_assoc_comeback()
18243 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in cfg80211_assoc_comeback()
18244 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || in cfg80211_assoc_comeback()
18251 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in cfg80211_assoc_comeback()
18264 struct wiphy *wiphy = wdev->wiphy; in cfg80211_ready_on_channel()
18278 struct wiphy *wiphy = wdev->wiphy; in cfg80211_remain_on_channel_expired()
18291 struct wiphy *wiphy = wdev->wiphy; in cfg80211_tx_mgmt_expired()
18303 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; in cfg80211_new_sta()
18319 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in cfg80211_new_sta()
18327 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; in cfg80211_del_sta_sinfo()
18349 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in cfg80211_del_sta_sinfo()
18358 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; in cfg80211_conn_failed()
18373 if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || in cfg80211_conn_failed()
18380 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in cfg80211_conn_failed()
18392 struct wireless_dev *wdev = dev->ieee80211_ptr; in __nl80211_unexpected_frame()
18393 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in __nl80211_unexpected_frame()
18396 u32 nlportid = READ_ONCE(wdev->ap_unexpected_nlportid); in __nl80211_unexpected_frame()
18411 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in __nl80211_unexpected_frame()
18412 nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || in __nl80211_unexpected_frame()
18417 genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid); in __nl80211_unexpected_frame()
18428 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_rx_spurious_frame()
18433 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && in cfg80211_rx_spurious_frame()
18434 wdev->iftype != NL80211_IFTYPE_P2P_GO)) { in cfg80211_rx_spurious_frame()
18448 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_rx_unexpected_4addr_frame()
18453 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && in cfg80211_rx_unexpected_4addr_frame()
18454 wdev->iftype != NL80211_IFTYPE_P2P_GO && in cfg80211_rx_unexpected_4addr_frame()
18455 wdev->iftype != NL80211_IFTYPE_AP_VLAN)) { in cfg80211_rx_unexpected_4addr_frame()
18471 struct net_device *netdev = wdev->netdev; in nl80211_send_mgmt()
18475 msg = nlmsg_new(100 + info->len, gfp); in nl80211_send_mgmt()
18477 return -ENOMEM; in nl80211_send_mgmt()
18482 return -ENOMEM; in nl80211_send_mgmt()
18485 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_send_mgmt()
18487 netdev->ifindex)) || in nl80211_send_mgmt()
18490 (info->have_link_id && in nl80211_send_mgmt()
18491 nla_put_u8(msg, NL80211_ATTR_MLO_LINK_ID, info->link_id)) || in nl80211_send_mgmt()
18492 nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, KHZ_TO_MHZ(info->freq)) || in nl80211_send_mgmt()
18493 nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ_OFFSET, info->freq % 1000) || in nl80211_send_mgmt()
18494 (info->sig_dbm && in nl80211_send_mgmt()
18495 nla_put_u32(msg, NL80211_ATTR_RX_SIGNAL_DBM, info->sig_dbm)) || in nl80211_send_mgmt()
18496 nla_put(msg, NL80211_ATTR_FRAME, info->len, info->buf) || in nl80211_send_mgmt()
18497 (info->flags && in nl80211_send_mgmt()
18498 nla_put_u32(msg, NL80211_ATTR_RXMGMT_FLAGS, info->flags)) || in nl80211_send_mgmt()
18499 (info->rx_tstamp && nla_put_u64_64bit(msg, in nl80211_send_mgmt()
18501 info->rx_tstamp, in nl80211_send_mgmt()
18503 (info->ack_tstamp && nla_put_u64_64bit(msg, in nl80211_send_mgmt()
18505 info->ack_tstamp, in nl80211_send_mgmt()
18511 return genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid); in nl80211_send_mgmt()
18515 return -ENOBUFS; in nl80211_send_mgmt()
18522 struct wiphy *wiphy = wdev->wiphy; in nl80211_frame_tx_status()
18524 struct net_device *netdev = wdev->netdev; in nl80211_frame_tx_status()
18529 trace_cfg80211_mgmt_tx_status(wdev, status->cookie, in nl80211_frame_tx_status()
18530 status->ack); in nl80211_frame_tx_status()
18532 trace_cfg80211_control_port_tx_status(wdev, status->cookie, in nl80211_frame_tx_status()
18533 status->ack); in nl80211_frame_tx_status()
18535 msg = nlmsg_new(100 + status->len, gfp); in nl80211_frame_tx_status()
18545 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_frame_tx_status()
18547 netdev->ifindex)) || in nl80211_frame_tx_status()
18550 nla_put(msg, NL80211_ATTR_FRAME, status->len, status->buf) || in nl80211_frame_tx_status()
18551 nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, status->cookie, in nl80211_frame_tx_status()
18553 (status->ack && nla_put_flag(msg, NL80211_ATTR_ACK)) || in nl80211_frame_tx_status()
18554 (status->tx_tstamp && in nl80211_frame_tx_status()
18556 status->tx_tstamp, NL80211_ATTR_PAD)) || in nl80211_frame_tx_status()
18557 (status->ack_tstamp && in nl80211_frame_tx_status()
18559 status->ack_tstamp, NL80211_ATTR_PAD))) in nl80211_frame_tx_status()
18564 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_frame_tx_status()
18599 struct wireless_dev *wdev = dev->ieee80211_ptr; in __nl80211_rx_control_port()
18600 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in __nl80211_rx_control_port()
18602 const u8 *addr = ehdr->h_source; in __nl80211_rx_control_port()
18603 u16 proto = be16_to_cpu(skb->protocol); in __nl80211_rx_control_port()
18608 u32 nlportid = READ_ONCE(wdev->conn_owner_nlportid); in __nl80211_rx_control_port()
18611 return -ENOENT; in __nl80211_rx_control_port()
18613 msg = nlmsg_new(100 + skb->len, gfp); in __nl80211_rx_control_port()
18615 return -ENOMEM; in __nl80211_rx_control_port()
18620 return -ENOBUFS; in __nl80211_rx_control_port()
18623 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in __nl80211_rx_control_port()
18624 nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || in __nl80211_rx_control_port()
18633 frame = nla_reserve(msg, NL80211_ATTR_FRAME, skb->len); in __nl80211_rx_control_port()
18637 skb_copy_bits(skb, 0, nla_data(frame), skb->len); in __nl80211_rx_control_port()
18640 return genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid); in __nl80211_rx_control_port()
18644 return -ENOBUFS; in __nl80211_rx_control_port()
18662 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_prepare_cqm()
18663 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_prepare_cqm()
18670 cb = (void **)msg->cb; in cfg80211_prepare_cqm()
18678 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in cfg80211_prepare_cqm()
18679 nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) in cfg80211_prepare_cqm()
18699 void **cb = (void **)msg->cb; in cfg80211_send_cqm()
18705 memset(msg->cb, 0, sizeof(msg->cb)); in cfg80211_send_cqm()
18707 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in cfg80211_send_cqm()
18716 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_cqm_rssi_notify()
18717 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_cqm_rssi_notify()
18725 if (wdev->cqm_config) { in cfg80211_cqm_rssi_notify()
18726 wdev->cqm_config->last_rssi_event_value = rssi_level; in cfg80211_cqm_rssi_notify()
18731 rssi_level = wdev->cqm_config->last_rssi_event_value; in cfg80211_cqm_rssi_notify()
18841 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_gtk_rekey_notify()
18842 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || in nl80211_gtk_rekey_notify()
18858 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_gtk_rekey_notify()
18869 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_gtk_rekey_notify()
18870 struct wiphy *wiphy = wdev->wiphy; in cfg80211_gtk_rekey_notify()
18897 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_pmksa_candidate_notify()
18898 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) in nl80211_pmksa_candidate_notify()
18915 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_pmksa_candidate_notify()
18926 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_pmksa_candidate_notify()
18927 struct wiphy *wiphy = wdev->wiphy; in cfg80211_pmksa_candidate_notify()
18943 struct wireless_dev *wdev = netdev->ieee80211_ptr; in nl80211_ch_switch_notify()
18957 if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) in nl80211_ch_switch_notify()
18960 if (wdev->valid_links && in nl80211_ch_switch_notify()
18977 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_ch_switch_notify()
18989 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_ch_switch_notify()
18990 struct wiphy *wiphy = wdev->wiphy; in cfg80211_ch_switch_notify()
18998 switch (wdev->iftype) { in cfg80211_ch_switch_notify()
19001 if (!WARN_ON(!wdev->links[link_id].client.current_bss)) in cfg80211_ch_switch_notify()
19003 chandef->chan); in cfg80211_ch_switch_notify()
19006 wdev->u.mesh.chandef = *chandef; in cfg80211_ch_switch_notify()
19007 wdev->u.mesh.preset_chandef = *chandef; in cfg80211_ch_switch_notify()
19011 wdev->links[link_id].ap.chandef = *chandef; in cfg80211_ch_switch_notify()
19014 wdev->u.ibss.chandef = *chandef; in cfg80211_ch_switch_notify()
19033 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_ch_switch_started_notify()
19034 struct wiphy *wiphy = wdev->wiphy; in cfg80211_ch_switch_started_notify()
19052 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_bss_color_notify()
19053 struct wiphy *wiphy = wdev->wiphy; in cfg80211_bss_color_notify()
19064 return -ENOMEM; in cfg80211_bss_color_notify()
19070 if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) in cfg80211_bss_color_notify()
19084 return genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), in cfg80211_bss_color_notify()
19089 return -EINVAL; in cfg80211_bss_color_notify()
19112 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) in nl80211_radar_notify()
19117 struct wireless_dev *wdev = netdev->ieee80211_ptr; in nl80211_radar_notify()
19119 if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || in nl80211_radar_notify()
19133 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in nl80211_radar_notify()
19146 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_sta_opmode_change_notify()
19147 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_sta_opmode_change_notify()
19163 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) in cfg80211_sta_opmode_change_notify()
19166 if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) in cfg80211_sta_opmode_change_notify()
19172 if ((sta_opmode->changed & STA_OPMODE_SMPS_MODE_CHANGED) && in cfg80211_sta_opmode_change_notify()
19173 nla_put_u8(msg, NL80211_ATTR_SMPS_MODE, sta_opmode->smps_mode)) in cfg80211_sta_opmode_change_notify()
19176 if ((sta_opmode->changed & STA_OPMODE_MAX_BW_CHANGED) && in cfg80211_sta_opmode_change_notify()
19177 nla_put_u32(msg, NL80211_ATTR_CHANNEL_WIDTH, sta_opmode->bw)) in cfg80211_sta_opmode_change_notify()
19180 if ((sta_opmode->changed & STA_OPMODE_N_SS_CHANGED) && in cfg80211_sta_opmode_change_notify()
19181 nla_put_u8(msg, NL80211_ATTR_NSS, sta_opmode->rx_nss)) in cfg80211_sta_opmode_change_notify()
19186 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in cfg80211_sta_opmode_change_notify()
19200 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_probe_status()
19201 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_probe_status()
19218 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in cfg80211_probe_status()
19219 nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || in cfg80211_probe_status()
19230 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in cfg80211_probe_status()
19249 spin_lock_bh(&rdev->beacon_registrations_lock); in cfg80211_report_obss_beacon_khz()
19250 list_for_each_entry(reg, &rdev->beacon_registrations, list) { in cfg80211_report_obss_beacon_khz()
19253 spin_unlock_bh(&rdev->beacon_registrations_lock); in cfg80211_report_obss_beacon_khz()
19261 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in cfg80211_report_obss_beacon_khz()
19274 genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, reg->nlportid); in cfg80211_report_obss_beacon_khz()
19276 spin_unlock_bh(&rdev->beacon_registrations_lock); in cfg80211_report_obss_beacon_khz()
19280 spin_unlock_bh(&rdev->beacon_registrations_lock); in cfg80211_report_obss_beacon_khz()
19289 struct cfg80211_wowlan_nd_info *nd = wakeup->net_detect; in cfg80211_net_detect_results()
19296 return -EMSGSIZE; in cfg80211_net_detect_results()
19298 for (i = 0; i < nd->n_matches; i++) { in cfg80211_net_detect_results()
19299 struct cfg80211_wowlan_nd_match *match = nd->matches[i]; in cfg80211_net_detect_results()
19312 if (nla_put(msg, NL80211_ATTR_SSID, match->ssid.ssid_len, in cfg80211_net_detect_results()
19313 match->ssid.ssid)) { in cfg80211_net_detect_results()
19318 if (match->n_channels) { in cfg80211_net_detect_results()
19326 for (j = 0; j < match->n_channels; j++) { in cfg80211_net_detect_results()
19327 if (nla_put_u32(msg, j, match->channels[j])) { in cfg80211_net_detect_results()
19349 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_report_wowlan_wakeup()
19354 trace_cfg80211_report_wowlan_wakeup(wdev->wiphy, wdev, wakeup); in cfg80211_report_wowlan_wakeup()
19357 size += wakeup->packet_present_len; in cfg80211_report_wowlan_wakeup()
19367 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in cfg80211_report_wowlan_wakeup()
19372 if (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX, in cfg80211_report_wowlan_wakeup()
19373 wdev->netdev->ifindex)) in cfg80211_report_wowlan_wakeup()
19384 if (wakeup->disconnect && in cfg80211_report_wowlan_wakeup()
19387 if (wakeup->magic_pkt && in cfg80211_report_wowlan_wakeup()
19390 if (wakeup->gtk_rekey_failure && in cfg80211_report_wowlan_wakeup()
19393 if (wakeup->eap_identity_req && in cfg80211_report_wowlan_wakeup()
19396 if (wakeup->four_way_handshake && in cfg80211_report_wowlan_wakeup()
19399 if (wakeup->rfkill_release && in cfg80211_report_wowlan_wakeup()
19403 if (wakeup->pattern_idx >= 0 && in cfg80211_report_wowlan_wakeup()
19405 wakeup->pattern_idx)) in cfg80211_report_wowlan_wakeup()
19408 if (wakeup->tcp_match && in cfg80211_report_wowlan_wakeup()
19412 if (wakeup->tcp_connlost && in cfg80211_report_wowlan_wakeup()
19416 if (wakeup->tcp_nomoretokens && in cfg80211_report_wowlan_wakeup()
19421 if (wakeup->packet) { in cfg80211_report_wowlan_wakeup()
19425 if (!wakeup->packet_80211) { in cfg80211_report_wowlan_wakeup()
19432 if (wakeup->packet_len && in cfg80211_report_wowlan_wakeup()
19433 nla_put_u32(msg, len_attr, wakeup->packet_len)) in cfg80211_report_wowlan_wakeup()
19436 if (nla_put(msg, pkt_attr, wakeup->packet_present_len, in cfg80211_report_wowlan_wakeup()
19437 wakeup->packet)) in cfg80211_report_wowlan_wakeup()
19441 if (wakeup->net_detect && in cfg80211_report_wowlan_wakeup()
19450 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in cfg80211_report_wowlan_wakeup()
19464 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_tdls_oper_request()
19465 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_tdls_oper_request()
19469 trace_cfg80211_tdls_oper_request(wdev->wiphy, dev, peer, oper, in cfg80211_tdls_oper_request()
19482 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in cfg80211_tdls_oper_request()
19483 nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || in cfg80211_tdls_oper_request()
19492 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in cfg80211_tdls_oper_request()
19510 if (state != NETLINK_URELEASE || notify->protocol != NETLINK_GENERIC) in nl80211_netlink_notify()
19519 &rdev->sched_scan_req_list, in nl80211_netlink_notify()
19521 if (sched_scan_req->owner_nlportid == notify->portid) { in nl80211_netlink_notify()
19522 sched_scan_req->nl_owner_dead = true; in nl80211_netlink_notify()
19523 schedule_work(&rdev->sched_scan_stop_wk); in nl80211_netlink_notify()
19527 list_for_each_entry_rcu(wdev, &rdev->wiphy.wdev_list, list) { in nl80211_netlink_notify()
19528 cfg80211_mlme_unregister_socket(wdev, notify->portid); in nl80211_netlink_notify()
19530 if (wdev->owner_nlportid == notify->portid) { in nl80211_netlink_notify()
19531 wdev->nl_owner_dead = true; in nl80211_netlink_notify()
19532 schedule_work(&rdev->destroy_work); in nl80211_netlink_notify()
19533 } else if (wdev->conn_owner_nlportid == notify->portid) { in nl80211_netlink_notify()
19534 schedule_work(&wdev->disconnect_wk); in nl80211_netlink_notify()
19537 cfg80211_release_pmsr(wdev, notify->portid); in nl80211_netlink_notify()
19540 spin_lock_bh(&rdev->beacon_registrations_lock); in nl80211_netlink_notify()
19541 list_for_each_entry_safe(reg, tmp, &rdev->beacon_registrations, in nl80211_netlink_notify()
19543 if (reg->nlportid == notify->portid) { in nl80211_netlink_notify()
19544 list_del(&reg->list); in nl80211_netlink_notify()
19549 spin_unlock_bh(&rdev->beacon_registrations_lock); in nl80211_netlink_notify()
19558 regulatory_netlink_notify(notify->portid); in nl80211_netlink_notify()
19569 struct wiphy *wiphy = netdev->ieee80211_ptr->wiphy; in cfg80211_ft_event()
19576 if (!ft_event->target_ap) in cfg80211_ft_event()
19579 msg = nlmsg_new(100 + ft_event->ies_len + ft_event->ric_ies_len, in cfg80211_ft_event()
19588 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in cfg80211_ft_event()
19589 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || in cfg80211_ft_event()
19590 nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, ft_event->target_ap)) in cfg80211_ft_event()
19593 if (ft_event->ies && in cfg80211_ft_event()
19594 nla_put(msg, NL80211_ATTR_IE, ft_event->ies_len, ft_event->ies)) in cfg80211_ft_event()
19596 if (ft_event->ric_ies && in cfg80211_ft_event()
19597 nla_put(msg, NL80211_ATTR_IE_RIC, ft_event->ric_ies_len, in cfg80211_ft_event()
19598 ft_event->ric_ies)) in cfg80211_ft_event()
19603 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in cfg80211_ft_event()
19618 rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_crit_proto_stopped()
19619 if (!rdev->crit_proto_nlportid) in cfg80211_crit_proto_stopped()
19622 nlportid = rdev->crit_proto_nlportid; in cfg80211_crit_proto_stopped()
19623 rdev->crit_proto_nlportid = 0; in cfg80211_crit_proto_stopped()
19633 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in cfg80211_crit_proto_stopped()
19640 genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid); in cfg80211_crit_proto_stopped()
19650 struct wiphy *wiphy = wdev->wiphy; in nl80211_send_ap_stopped()
19663 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in nl80211_send_ap_stopped()
19664 nla_put_u32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex) || in nl80211_send_ap_stopped()
19682 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_external_auth_request()
19683 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_external_auth_request()
19687 if (!wdev->conn_owner_nlportid) in cfg80211_external_auth_request()
19688 return -EINVAL; in cfg80211_external_auth_request()
19692 return -ENOMEM; in cfg80211_external_auth_request()
19698 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in cfg80211_external_auth_request()
19699 nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || in cfg80211_external_auth_request()
19700 nla_put_u32(msg, NL80211_ATTR_AKM_SUITES, params->key_mgmt_suite) || in cfg80211_external_auth_request()
19702 params->action) || in cfg80211_external_auth_request()
19703 nla_put(msg, NL80211_ATTR_BSSID, ETH_ALEN, params->bssid) || in cfg80211_external_auth_request()
19704 nla_put(msg, NL80211_ATTR_SSID, params->ssid.ssid_len, in cfg80211_external_auth_request()
19705 params->ssid.ssid)) in cfg80211_external_auth_request()
19709 genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, in cfg80211_external_auth_request()
19710 wdev->conn_owner_nlportid); in cfg80211_external_auth_request()
19715 return -ENOBUFS; in cfg80211_external_auth_request()
19723 struct wiphy *wiphy = netdev->ieee80211_ptr->wiphy; in cfg80211_update_owe_info_event()
19738 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || in cfg80211_update_owe_info_event()
19739 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || in cfg80211_update_owe_info_event()
19740 nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, owe_info->peer)) in cfg80211_update_owe_info_event()
19743 if (!owe_info->ie_len || in cfg80211_update_owe_info_event()
19744 nla_put(msg, NL80211_ATTR_IE, owe_info->ie_len, owe_info->ie)) in cfg80211_update_owe_info_event()
19749 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, in cfg80211_update_owe_info_event()