hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/mac80211/rate.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright 2002-2005, Instant802 Networks, Inc.
34 * Copyright 2005-2006, Devicescape Software, Inc.
45 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
56 * Copyright 2017 Intel Deutschland GmbH
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 */
118
129 #include <linux/kernel.h>
....@@ -53,6 +50,13 @@
5350 }
5451
5552 sband = local->hw.wiphy->bands[chanctx_conf->def.chan->band];
53
+
54
+ /* TODO: check for minstrel_s1g ? */
55
+ if (sband->band == NL80211_BAND_S1GHZ) {
56
+ ieee80211_s1g_sta_rate_init(sta);
57
+ rcu_read_unlock();
58
+ return;
59
+ }
5660
5761 spin_lock_bh(&sta->rate_ctrl_lock);
5862 ref->ops->rate_init(ref->priv, sband, &chanctx_conf->def, ista,
....@@ -217,17 +221,16 @@
217221 ref->ops->name, len);
218222 }
219223
220
-static const struct file_operations rcname_ops = {
224
+const struct file_operations rcname_ops = {
221225 .read = rcname_read,
222226 .open = simple_open,
223227 .llseek = default_llseek,
224228 };
225229 #endif
226230
227
-static struct rate_control_ref *rate_control_alloc(const char *name,
228
- struct ieee80211_local *local)
231
+static struct rate_control_ref *
232
+rate_control_alloc(const char *name, struct ieee80211_local *local)
229233 {
230
- struct dentry *debugfsdir = NULL;
231234 struct rate_control_ref *ref;
232235
233236 ref = kmalloc(sizeof(struct rate_control_ref), GFP_KERNEL);
....@@ -237,13 +240,7 @@
237240 if (!ref->ops)
238241 goto free;
239242
240
-#ifdef CONFIG_MAC80211_DEBUGFS
241
- debugfsdir = debugfs_create_dir("rc", local->hw.wiphy->debugfsdir);
242
- local->debugfs.rcdir = debugfsdir;
243
- debugfs_create_file("name", 0400, debugfsdir, ref, &rcname_ops);
244
-#endif
245
-
246
- ref->priv = ref->ops->alloc(&local->hw, debugfsdir);
243
+ ref->priv = ref->ops->alloc(&local->hw);
247244 if (!ref->priv)
248245 goto free;
249246 return ref;
....@@ -276,10 +273,15 @@
276273 if (WARN_ON(!sdata->vif.bss_conf.chandef.chan))
277274 return;
278275
276
+ band = sdata->vif.bss_conf.chandef.chan->band;
277
+ if (band == NL80211_BAND_S1GHZ) {
278
+ /* TODO */
279
+ return;
280
+ }
281
+
279282 if (WARN_ON_ONCE(!basic_rates))
280283 return;
281284
282
- band = sdata->vif.bss_conf.chandef.chan->band;
283285 user_mask = sdata->rc_rateidx_mask[band];
284286 sband = local->hw.wiphy->bands[band];
285287
....@@ -306,21 +308,29 @@
306308 !ieee80211_is_data(fc);
307309 }
308310
309
-static void rc_send_low_basicrate(s8 *idx, u32 basic_rates,
311
+static void rc_send_low_basicrate(struct ieee80211_tx_rate *rate,
312
+ u32 basic_rates,
310313 struct ieee80211_supported_band *sband)
311314 {
312315 u8 i;
313316
317
+ if (sband->band == NL80211_BAND_S1GHZ) {
318
+ /* TODO */
319
+ rate->flags |= IEEE80211_TX_RC_S1G_MCS;
320
+ rate->idx = 0;
321
+ return;
322
+ }
323
+
314324 if (basic_rates == 0)
315325 return; /* assume basic rates unknown and accept rate */
316
- if (*idx < 0)
326
+ if (rate->idx < 0)
317327 return;
318
- if (basic_rates & (1 << *idx))
328
+ if (basic_rates & (1 << rate->idx))
319329 return; /* selected rate is a basic rate */
320330
321
- for (i = *idx + 1; i <= sband->n_bitrates; i++) {
331
+ for (i = rate->idx + 1; i <= sband->n_bitrates; i++) {
322332 if (basic_rates & (1 << i)) {
323
- *idx = i;
333
+ rate->idx = i;
324334 return;
325335 }
326336 }
....@@ -337,6 +347,12 @@
337347 int i;
338348 u32 rate_flags =
339349 ieee80211_chandef_rate_flags(&hw->conf.chandef);
350
+
351
+ if (sband->band == NL80211_BAND_S1GHZ) {
352
+ info->control.rates[0].flags |= IEEE80211_TX_RC_S1G_MCS;
353
+ info->control.rates[0].idx = 0;
354
+ return;
355
+ }
340356
341357 if ((sband->band == NL80211_BAND_2GHZ) &&
342358 (info->flags & IEEE80211_TX_CTL_NO_CCK_RATE))
....@@ -357,8 +373,10 @@
357373 break;
358374 }
359375 WARN_ONCE(i == sband->n_bitrates,
360
- "no supported rates (0x%x) in rate_mask 0x%x with flags 0x%x\n",
376
+ "no supported rates for sta %pM (0x%x, band %d) in rate_mask 0x%x with flags 0x%x\n",
377
+ sta ? sta->addr : NULL,
361378 sta ? sta->supp_rates[sband->band] : -1,
379
+ sband->band,
362380 rate_mask, rate_flags);
363381
364382 info->control.rates[0].count =
....@@ -369,9 +387,8 @@
369387 }
370388
371389
372
-bool rate_control_send_low(struct ieee80211_sta *pubsta,
373
- void *priv_sta,
374
- struct ieee80211_tx_rate_control *txrc)
390
+static bool rate_control_send_low(struct ieee80211_sta *pubsta,
391
+ struct ieee80211_tx_rate_control *txrc)
375392 {
376393 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
377394 struct ieee80211_supported_band *sband = txrc->sband;
....@@ -379,7 +396,7 @@
379396 int mcast_rate;
380397 bool use_basicrate = false;
381398
382
- if (!pubsta || !priv_sta || rc_no_data_or_no_ack_use_min(txrc)) {
399
+ if (!pubsta || rc_no_data_or_no_ack_use_min(txrc)) {
383400 __rate_control_send_low(txrc->hw, sband, pubsta, info,
384401 txrc->rate_idx_mask);
385402
....@@ -397,7 +414,7 @@
397414 }
398415
399416 if (use_basicrate)
400
- rc_send_low_basicrate(&info->control.rates[0].idx,
417
+ rc_send_low_basicrate(&info->control.rates[0],
401418 txrc->bss_conf->basic_rates,
402419 sband);
403420
....@@ -405,7 +422,6 @@
405422 }
406423 return false;
407424 }
408
-EXPORT_SYMBOL(rate_control_send_low);
409425
410426 static bool rate_idx_match_legacy_mask(s8 *rate_idx, int n_bitrates, u32 mask)
411427 {
....@@ -888,26 +904,29 @@
888904 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
889905 int i;
890906
891
- if (sta && test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) {
892
- ista = &sta->sta;
893
- priv_sta = sta->rate_ctrl_priv;
894
- }
895
-
896907 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
897908 info->control.rates[i].idx = -1;
898909 info->control.rates[i].flags = 0;
899910 info->control.rates[i].count = 0;
900911 }
901912
913
+ if (rate_control_send_low(sta ? &sta->sta : NULL, txrc))
914
+ return;
915
+
902916 if (ieee80211_hw_check(&sdata->local->hw, HAS_RATE_CONTROL))
903917 return;
918
+
919
+ if (sta && test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) {
920
+ ista = &sta->sta;
921
+ priv_sta = sta->rate_ctrl_priv;
922
+ }
904923
905924 if (ista) {
906925 spin_lock_bh(&sta->rate_ctrl_lock);
907926 ref->ops->get_rate(ref->priv, ista, priv_sta, txrc);
908927 spin_unlock_bh(&sta->rate_ctrl_lock);
909928 } else {
910
- ref->ops->get_rate(ref->priv, NULL, NULL, txrc);
929
+ rate_control_send_low(NULL, txrc);
911930 }
912931
913932 if (ieee80211_hw_check(&sdata->local->hw, SUPPORTS_RC_TABLE))