hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/net/wireless/marvell/mwifiex/cfg80211.c
....@@ -1,10 +1,10 @@
11 /*
2
- * Marvell Wireless LAN device driver: CFG80211
2
+ * NXP Wireless LAN device driver: CFG80211
33 *
4
- * Copyright (C) 2011-2014, Marvell International Ltd.
4
+ * Copyright 2011-2020 NXP
55 *
6
- * This software file (the "File") is distributed by Marvell International
7
- * Ltd. under the terms of the GNU General Public License Version 2, June 1991
6
+ * This software file (the "File") is distributed by NXP
7
+ * under the terms of the GNU General Public License Version 2, June 1991
88 * (the "License"). You may use, redistribute and/or modify this File in
99 * accordance with the terms and conditions of the License, a copy of which
1010 * is available by writing to the Free Software Foundation, Inc.,
....@@ -27,7 +27,8 @@
2727
2828 static const struct ieee80211_iface_limit mwifiex_ap_sta_limits[] = {
2929 {
30
- .max = 3, .types = BIT(NL80211_IFTYPE_STATION) |
30
+ .max = MWIFIEX_MAX_BSS_NUM,
31
+ .types = BIT(NL80211_IFTYPE_STATION) |
3132 BIT(NL80211_IFTYPE_P2P_GO) |
3233 BIT(NL80211_IFTYPE_P2P_CLIENT) |
3334 BIT(NL80211_IFTYPE_AP),
....@@ -269,17 +270,12 @@
269270 * CFG802.11 operation handler to register a mgmt frame.
270271 */
271272 static void
272
-mwifiex_cfg80211_mgmt_frame_register(struct wiphy *wiphy,
273
- struct wireless_dev *wdev,
274
- u16 frame_type, bool reg)
273
+mwifiex_cfg80211_update_mgmt_frame_registrations(struct wiphy *wiphy,
274
+ struct wireless_dev *wdev,
275
+ struct mgmt_frame_regs *upd)
275276 {
276277 struct mwifiex_private *priv = mwifiex_netdev_get_priv(wdev->netdev);
277
- u32 mask;
278
-
279
- if (reg)
280
- mask = priv->mgmt_frame_mask | BIT(frame_type >> 4);
281
- else
282
- mask = priv->mgmt_frame_mask & ~BIT(frame_type >> 4);
278
+ u32 mask = upd->interface_stypes;
283279
284280 if (mask != priv->mgmt_frame_mask) {
285281 priv->mgmt_frame_mask = mask;
....@@ -876,13 +872,13 @@
876872 spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
877873 }
878874
879
- spin_lock_irqsave(&adapter->rx_proc_lock, flags);
875
+ spin_lock_bh(&adapter->rx_proc_lock);
880876 adapter->rx_locked = true;
881877 if (adapter->rx_processing) {
882
- spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);
878
+ spin_unlock_bh(&adapter->rx_proc_lock);
883879 flush_workqueue(adapter->rx_workqueue);
884880 } else {
885
- spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);
881
+ spin_unlock_bh(&adapter->rx_proc_lock);
886882 }
887883
888884 mwifiex_free_priv(priv);
....@@ -938,9 +934,9 @@
938934 adapter->main_locked = false;
939935 spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
940936
941
- spin_lock_irqsave(&adapter->rx_proc_lock, flags);
937
+ spin_lock_bh(&adapter->rx_proc_lock);
942938 adapter->rx_locked = false;
943
- spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);
939
+ spin_unlock_bh(&adapter->rx_proc_lock);
944940
945941 mwifiex_set_mac_address(priv, dev, false, NULL);
946942
....@@ -1171,7 +1167,7 @@
11711167 case NL80211_IFTYPE_UNSPECIFIED:
11721168 mwifiex_dbg(priv->adapter, INFO,
11731169 "%s: kept type as IBSS\n", dev->name);
1174
- /* fall through */
1170
+ fallthrough;
11751171 case NL80211_IFTYPE_ADHOC: /* This shouldn't happen */
11761172 return 0;
11771173 default:
....@@ -1202,7 +1198,7 @@
12021198 case NL80211_IFTYPE_UNSPECIFIED:
12031199 mwifiex_dbg(priv->adapter, INFO,
12041200 "%s: kept type as STA\n", dev->name);
1205
- /* fall through */
1201
+ fallthrough;
12061202 case NL80211_IFTYPE_STATION: /* This shouldn't happen */
12071203 return 0;
12081204 default:
....@@ -1225,7 +1221,7 @@
12251221 case NL80211_IFTYPE_UNSPECIFIED:
12261222 mwifiex_dbg(priv->adapter, INFO,
12271223 "%s: kept type as AP\n", dev->name);
1228
- /* fall through */
1224
+ fallthrough;
12291225 case NL80211_IFTYPE_AP: /* This shouldn't happen */
12301226 return 0;
12311227 default:
....@@ -1251,7 +1247,7 @@
12511247 case NL80211_IFTYPE_UNSPECIFIED:
12521248 mwifiex_dbg(priv->adapter, INFO,
12531249 "%s: kept type as P2P\n", dev->name);
1254
- /* fall through */
1250
+ fallthrough;
12551251 case NL80211_IFTYPE_P2P_CLIENT:
12561252 case NL80211_IFTYPE_P2P_GO:
12571253 return 0;
....@@ -1274,27 +1270,27 @@
12741270 }
12751271
12761272 static void
1277
-mwifiex_parse_htinfo(struct mwifiex_private *priv, u8 tx_htinfo,
1273
+mwifiex_parse_htinfo(struct mwifiex_private *priv, u8 rateinfo, u8 htinfo,
12781274 struct rate_info *rate)
12791275 {
12801276 struct mwifiex_adapter *adapter = priv->adapter;
12811277
12821278 if (adapter->is_hw_11ac_capable) {
12831279 /* bit[1-0]: 00=LG 01=HT 10=VHT */
1284
- if (tx_htinfo & BIT(0)) {
1280
+ if (htinfo & BIT(0)) {
12851281 /* HT */
1286
- rate->mcs = priv->tx_rate;
1282
+ rate->mcs = rateinfo;
12871283 rate->flags |= RATE_INFO_FLAGS_MCS;
12881284 }
1289
- if (tx_htinfo & BIT(1)) {
1285
+ if (htinfo & BIT(1)) {
12901286 /* VHT */
1291
- rate->mcs = priv->tx_rate & 0x0F;
1287
+ rate->mcs = rateinfo & 0x0F;
12921288 rate->flags |= RATE_INFO_FLAGS_VHT_MCS;
12931289 }
12941290
1295
- if (tx_htinfo & (BIT(1) | BIT(0))) {
1291
+ if (htinfo & (BIT(1) | BIT(0))) {
12961292 /* HT or VHT */
1297
- switch (tx_htinfo & (BIT(3) | BIT(2))) {
1293
+ switch (htinfo & (BIT(3) | BIT(2))) {
12981294 case 0:
12991295 rate->bw = RATE_INFO_BW_20;
13001296 break;
....@@ -1309,28 +1305,50 @@
13091305 break;
13101306 }
13111307
1312
- if (tx_htinfo & BIT(4))
1308
+ if (htinfo & BIT(4))
13131309 rate->flags |= RATE_INFO_FLAGS_SHORT_GI;
13141310
1315
- if ((priv->tx_rate >> 4) == 1)
1311
+ if ((rateinfo >> 4) == 1)
13161312 rate->nss = 2;
13171313 else
13181314 rate->nss = 1;
13191315 }
13201316 } else {
13211317 /*
1322
- * Bit 0 in tx_htinfo indicates that current Tx rate
1323
- * is 11n rate. Valid MCS index values for us are 0 to 15.
1318
+ * Bit 0 in htinfo indicates that current rate is 11n. Valid
1319
+ * MCS index values for us are 0 to 15.
13241320 */
1325
- if ((tx_htinfo & BIT(0)) && (priv->tx_rate < 16)) {
1326
- rate->mcs = priv->tx_rate;
1321
+ if ((htinfo & BIT(0)) && (rateinfo < 16)) {
1322
+ rate->mcs = rateinfo;
13271323 rate->flags |= RATE_INFO_FLAGS_MCS;
13281324 rate->bw = RATE_INFO_BW_20;
1329
- if (tx_htinfo & BIT(1))
1325
+ if (htinfo & BIT(1))
13301326 rate->bw = RATE_INFO_BW_40;
1331
- if (tx_htinfo & BIT(2))
1327
+ if (htinfo & BIT(2))
13321328 rate->flags |= RATE_INFO_FLAGS_SHORT_GI;
13331329 }
1330
+ }
1331
+
1332
+ /* Decode legacy rates for non-HT. */
1333
+ if (!(htinfo & (BIT(0) | BIT(1)))) {
1334
+ /* Bitrates in multiples of 100kb/s. */
1335
+ static const int legacy_rates[] = {
1336
+ [0] = 10,
1337
+ [1] = 20,
1338
+ [2] = 55,
1339
+ [3] = 110,
1340
+ [4] = 60, /* MWIFIEX_RATE_INDEX_OFDM0 */
1341
+ [5] = 60,
1342
+ [6] = 90,
1343
+ [7] = 120,
1344
+ [8] = 180,
1345
+ [9] = 240,
1346
+ [10] = 360,
1347
+ [11] = 480,
1348
+ [12] = 540,
1349
+ };
1350
+ if (rateinfo < ARRAY_SIZE(legacy_rates))
1351
+ rate->legacy = legacy_rates[rateinfo];
13341352 }
13351353 }
13361354
....@@ -1374,7 +1392,8 @@
13741392 sinfo->tx_packets = node->stats.tx_packets;
13751393 sinfo->tx_failed = node->stats.tx_failed;
13761394
1377
- mwifiex_parse_htinfo(priv, node->stats.last_tx_htinfo,
1395
+ mwifiex_parse_htinfo(priv, priv->tx_rate,
1396
+ node->stats.last_tx_htinfo,
13781397 &sinfo->txrate);
13791398 sinfo->txrate.legacy = node->stats.last_tx_rate * 5;
13801399
....@@ -1400,7 +1419,8 @@
14001419 HostCmd_ACT_GEN_GET, DTIM_PERIOD_I,
14011420 &priv->dtim_period, true);
14021421
1403
- mwifiex_parse_htinfo(priv, priv->tx_htinfo, &sinfo->txrate);
1422
+ mwifiex_parse_htinfo(priv, priv->tx_rate, priv->tx_htinfo,
1423
+ &sinfo->txrate);
14041424
14051425 sinfo->signal_avg = priv->bcn_rssi_avg;
14061426 sinfo->rx_bytes = priv->stats.rx_bytes;
....@@ -1410,6 +1430,10 @@
14101430 sinfo->signal = priv->bcn_rssi_avg;
14111431 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */
14121432 sinfo->txrate.legacy = rate * 5;
1433
+
1434
+ sinfo->filled |= BIT(NL80211_STA_INFO_RX_BITRATE);
1435
+ mwifiex_parse_htinfo(priv, priv->rxpd_rate, priv->rxpd_htinfo,
1436
+ &sinfo->rxrate);
14131437
14141438 if (priv->bss_mode == NL80211_IFTYPE_STATION) {
14151439 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BSS_PARAM);
....@@ -1787,7 +1811,6 @@
17871811 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
17881812 struct mwifiex_sta_node *sta_node;
17891813 u8 deauth_mac[ETH_ALEN];
1790
- unsigned long flags;
17911814
17921815 if (!priv->bss_started && priv->wdev.cac_started) {
17931816 mwifiex_dbg(priv->adapter, INFO, "%s: abort CAC!\n", __func__);
....@@ -1805,11 +1828,11 @@
18051828
18061829 eth_zero_addr(deauth_mac);
18071830
1808
- spin_lock_irqsave(&priv->sta_list_spinlock, flags);
1831
+ spin_lock_bh(&priv->sta_list_spinlock);
18091832 sta_node = mwifiex_get_sta_entry(priv, params->mac);
18101833 if (sta_node)
18111834 ether_addr_copy(deauth_mac, params->mac);
1812
- spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
1835
+ spin_unlock_bh(&priv->sta_list_spinlock);
18131836
18141837 if (is_valid_ether_addr(deauth_mac)) {
18151838 if (mwifiex_send_cmd(priv, HostCmd_CMD_UAP_STA_DEAUTH,
....@@ -3013,7 +3036,7 @@
30133036
30143037 dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
30153038 dev->watchdog_timeo = MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT;
3016
- dev->hard_header_len += MWIFIEX_MIN_DATA_HEADER_LEN;
3039
+ dev->needed_headroom = MWIFIEX_MIN_DATA_HEADER_LEN;
30173040 dev->ethtool_ops = &mwifiex_ethtool_ops;
30183041
30193042 mdev_priv = netdev_priv(dev);
....@@ -3228,7 +3251,7 @@
32283251 in_dev = __in_dev_get_rtnl(adapter->priv[i]->netdev);
32293252 if (!in_dev)
32303253 continue;
3231
- ifa = in_dev->ifa_list;
3254
+ ifa = rtnl_dereference(in_dev->ifa_list);
32323255 if (!ifa || !ifa->ifa_local)
32333256 continue;
32343257 ips[i] = ifa->ifa_local;
....@@ -3694,11 +3717,11 @@
36943717 int ret;
36953718
36963719 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
3697
- return -ENOTSUPP;
3720
+ return -EOPNOTSUPP;
36983721
36993722 /* make sure we are in station mode and connected */
37003723 if (!(priv->bss_type == MWIFIEX_BSS_TYPE_STA && priv->media_connected))
3701
- return -ENOTSUPP;
3724
+ return -EOPNOTSUPP;
37023725
37033726 switch (action_code) {
37043727 case WLAN_TDLS_SETUP_REQUEST:
....@@ -3766,11 +3789,11 @@
37663789
37673790 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) ||
37683791 !(wiphy->flags & WIPHY_FLAG_TDLS_EXTERNAL_SETUP))
3769
- return -ENOTSUPP;
3792
+ return -EOPNOTSUPP;
37703793
37713794 /* make sure we are in station mode and connected */
37723795 if (!(priv->bss_type == MWIFIEX_BSS_TYPE_STA && priv->media_connected))
3773
- return -ENOTSUPP;
3796
+ return -EOPNOTSUPP;
37743797
37753798 mwifiex_dbg(priv->adapter, MSG,
37763799 "TDLS peer=%pM, oper=%d\n", peer, action);
....@@ -3800,7 +3823,7 @@
38003823 default:
38013824 mwifiex_dbg(priv->adapter, ERROR,
38023825 "tdls_oper: operation not supported\n");
3803
- return -ENOTSUPP;
3826
+ return -EOPNOTSUPP;
38043827 }
38053828
38063829 return mwifiex_tdls_oper(priv, peer, action);
....@@ -3812,15 +3835,14 @@
38123835 struct cfg80211_chan_def *chandef)
38133836 {
38143837 struct mwifiex_sta_node *sta_ptr;
3815
- unsigned long flags;
38163838 u16 chan;
38173839 u8 second_chan_offset, band;
38183840 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
38193841
3820
- spin_lock_irqsave(&priv->sta_list_spinlock, flags);
3842
+ spin_lock_bh(&priv->sta_list_spinlock);
38213843 sta_ptr = mwifiex_get_sta_entry(priv, addr);
38223844 if (!sta_ptr) {
3823
- spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
3845
+ spin_unlock_bh(&priv->sta_list_spinlock);
38243846 wiphy_err(wiphy, "%s: Invalid TDLS peer %pM\n",
38253847 __func__, addr);
38263848 return -ENOENT;
....@@ -3828,18 +3850,18 @@
38283850
38293851 if (!(sta_ptr->tdls_cap.extcap.ext_capab[3] &
38303852 WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH)) {
3831
- spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
3853
+ spin_unlock_bh(&priv->sta_list_spinlock);
38323854 wiphy_err(wiphy, "%pM do not support tdls cs\n", addr);
38333855 return -ENOENT;
38343856 }
38353857
38363858 if (sta_ptr->tdls_status == TDLS_CHAN_SWITCHING ||
38373859 sta_ptr->tdls_status == TDLS_IN_OFF_CHAN) {
3838
- spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
3860
+ spin_unlock_bh(&priv->sta_list_spinlock);
38393861 wiphy_err(wiphy, "channel switch is running, abort request\n");
38403862 return -EALREADY;
38413863 }
3842
- spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
3864
+ spin_unlock_bh(&priv->sta_list_spinlock);
38433865
38443866 chan = chandef->chan->hw_value;
38453867 second_chan_offset = mwifiex_get_sec_chan_offset(chan);
....@@ -3855,23 +3877,22 @@
38553877 const u8 *addr)
38563878 {
38573879 struct mwifiex_sta_node *sta_ptr;
3858
- unsigned long flags;
38593880 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
38603881
3861
- spin_lock_irqsave(&priv->sta_list_spinlock, flags);
3882
+ spin_lock_bh(&priv->sta_list_spinlock);
38623883 sta_ptr = mwifiex_get_sta_entry(priv, addr);
38633884 if (!sta_ptr) {
3864
- spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
3885
+ spin_unlock_bh(&priv->sta_list_spinlock);
38653886 wiphy_err(wiphy, "%s: Invalid TDLS peer %pM\n",
38663887 __func__, addr);
38673888 } else if (!(sta_ptr->tdls_status == TDLS_CHAN_SWITCHING ||
38683889 sta_ptr->tdls_status == TDLS_IN_BASE_CHAN ||
38693890 sta_ptr->tdls_status == TDLS_IN_OFF_CHAN)) {
3870
- spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
3891
+ spin_unlock_bh(&priv->sta_list_spinlock);
38713892 wiphy_err(wiphy, "tdls chan switch not initialize by %pM\n",
38723893 addr);
38733894 } else {
3874
- spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
3895
+ spin_unlock_bh(&priv->sta_list_spinlock);
38753896 mwifiex_stop_tdls_cs(priv, addr);
38763897 }
38773898 }
....@@ -3883,11 +3904,11 @@
38833904 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
38843905
38853906 if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)))
3886
- return -ENOTSUPP;
3907
+ return -EOPNOTSUPP;
38873908
38883909 /* make sure we are in station mode and connected */
38893910 if ((priv->bss_type != MWIFIEX_BSS_TYPE_STA) || !priv->media_connected)
3890
- return -ENOTSUPP;
3911
+ return -EOPNOTSUPP;
38913912
38923913 return mwifiex_tdls_oper(priv, mac, MWIFIEX_TDLS_CREATE_LINK);
38933914 }
....@@ -4019,8 +4040,8 @@
40194040 if (!priv)
40204041 return -EINVAL;
40214042
4022
- err = nla_parse(tb, MWIFIEX_TM_ATTR_MAX, data, len, mwifiex_tm_policy,
4023
- NULL);
4043
+ err = nla_parse_deprecated(tb, MWIFIEX_TM_ATTR_MAX, data, len,
4044
+ mwifiex_tm_policy, NULL);
40244045 if (err)
40254046 return err;
40264047
....@@ -4120,11 +4141,11 @@
41204141
41214142 /* we support change_station handler only for TDLS peers*/
41224143 if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)))
4123
- return -ENOTSUPP;
4144
+ return -EOPNOTSUPP;
41244145
41254146 /* make sure we are in station mode and connected */
41264147 if ((priv->bss_type != MWIFIEX_BSS_TYPE_STA) || !priv->media_connected)
4127
- return -ENOTSUPP;
4148
+ return -EOPNOTSUPP;
41284149
41294150 priv->sta_params = params;
41304151
....@@ -4152,7 +4173,8 @@
41524173 .del_key = mwifiex_cfg80211_del_key,
41534174 .set_default_mgmt_key = mwifiex_cfg80211_set_default_mgmt_key,
41544175 .mgmt_tx = mwifiex_cfg80211_mgmt_tx,
4155
- .mgmt_frame_register = mwifiex_cfg80211_mgmt_frame_register,
4176
+ .update_mgmt_frame_registrations =
4177
+ mwifiex_cfg80211_update_mgmt_frame_registrations,
41564178 .remain_on_channel = mwifiex_cfg80211_remain_on_channel,
41574179 .cancel_remain_on_channel = mwifiex_cfg80211_cancel_remain_on_channel,
41584180 .set_default_key = mwifiex_cfg80211_set_default_key,
....@@ -4304,6 +4326,11 @@
43044326 wiphy->iface_combinations = &mwifiex_iface_comb_ap_sta;
43054327 wiphy->n_iface_combinations = 1;
43064328
4329
+ if (adapter->max_sta_conn > adapter->max_p2p_conn)
4330
+ wiphy->max_ap_assoc_sta = adapter->max_sta_conn;
4331
+ else
4332
+ wiphy->max_ap_assoc_sta = adapter->max_p2p_conn;
4333
+
43074334 /* Initialize cipher suits */
43084335 wiphy->cipher_suites = mwifiex_cipher_suites;
43094336 wiphy->n_cipher_suites = ARRAY_SIZE(mwifiex_cipher_suites);