.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright 2002-2005, Instant802 Networks, Inc. |
---|
3 | 4 | * Copyright 2005-2006, Devicescape Software, Inc. |
---|
4 | 5 | * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz> |
---|
5 | 6 | * 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. |
---|
10 | 7 | */ |
---|
11 | 8 | |
---|
12 | 9 | #include <linux/kernel.h> |
---|
.. | .. |
---|
53 | 50 | } |
---|
54 | 51 | |
---|
55 | 52 | 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 | + } |
---|
56 | 60 | |
---|
57 | 61 | spin_lock_bh(&sta->rate_ctrl_lock); |
---|
58 | 62 | ref->ops->rate_init(ref->priv, sband, &chanctx_conf->def, ista, |
---|
.. | .. |
---|
217 | 221 | ref->ops->name, len); |
---|
218 | 222 | } |
---|
219 | 223 | |
---|
220 | | -static const struct file_operations rcname_ops = { |
---|
| 224 | +const struct file_operations rcname_ops = { |
---|
221 | 225 | .read = rcname_read, |
---|
222 | 226 | .open = simple_open, |
---|
223 | 227 | .llseek = default_llseek, |
---|
224 | 228 | }; |
---|
225 | 229 | #endif |
---|
226 | 230 | |
---|
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) |
---|
229 | 233 | { |
---|
230 | | - struct dentry *debugfsdir = NULL; |
---|
231 | 234 | struct rate_control_ref *ref; |
---|
232 | 235 | |
---|
233 | 236 | ref = kmalloc(sizeof(struct rate_control_ref), GFP_KERNEL); |
---|
.. | .. |
---|
237 | 240 | if (!ref->ops) |
---|
238 | 241 | goto free; |
---|
239 | 242 | |
---|
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); |
---|
247 | 244 | if (!ref->priv) |
---|
248 | 245 | goto free; |
---|
249 | 246 | return ref; |
---|
.. | .. |
---|
276 | 273 | if (WARN_ON(!sdata->vif.bss_conf.chandef.chan)) |
---|
277 | 274 | return; |
---|
278 | 275 | |
---|
| 276 | + band = sdata->vif.bss_conf.chandef.chan->band; |
---|
| 277 | + if (band == NL80211_BAND_S1GHZ) { |
---|
| 278 | + /* TODO */ |
---|
| 279 | + return; |
---|
| 280 | + } |
---|
| 281 | + |
---|
279 | 282 | if (WARN_ON_ONCE(!basic_rates)) |
---|
280 | 283 | return; |
---|
281 | 284 | |
---|
282 | | - band = sdata->vif.bss_conf.chandef.chan->band; |
---|
283 | 285 | user_mask = sdata->rc_rateidx_mask[band]; |
---|
284 | 286 | sband = local->hw.wiphy->bands[band]; |
---|
285 | 287 | |
---|
.. | .. |
---|
306 | 308 | !ieee80211_is_data(fc); |
---|
307 | 309 | } |
---|
308 | 310 | |
---|
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, |
---|
310 | 313 | struct ieee80211_supported_band *sband) |
---|
311 | 314 | { |
---|
312 | 315 | u8 i; |
---|
313 | 316 | |
---|
| 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 | + |
---|
314 | 324 | if (basic_rates == 0) |
---|
315 | 325 | return; /* assume basic rates unknown and accept rate */ |
---|
316 | | - if (*idx < 0) |
---|
| 326 | + if (rate->idx < 0) |
---|
317 | 327 | return; |
---|
318 | | - if (basic_rates & (1 << *idx)) |
---|
| 328 | + if (basic_rates & (1 << rate->idx)) |
---|
319 | 329 | return; /* selected rate is a basic rate */ |
---|
320 | 330 | |
---|
321 | | - for (i = *idx + 1; i <= sband->n_bitrates; i++) { |
---|
| 331 | + for (i = rate->idx + 1; i <= sband->n_bitrates; i++) { |
---|
322 | 332 | if (basic_rates & (1 << i)) { |
---|
323 | | - *idx = i; |
---|
| 333 | + rate->idx = i; |
---|
324 | 334 | return; |
---|
325 | 335 | } |
---|
326 | 336 | } |
---|
.. | .. |
---|
337 | 347 | int i; |
---|
338 | 348 | u32 rate_flags = |
---|
339 | 349 | 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 | + } |
---|
340 | 356 | |
---|
341 | 357 | if ((sband->band == NL80211_BAND_2GHZ) && |
---|
342 | 358 | (info->flags & IEEE80211_TX_CTL_NO_CCK_RATE)) |
---|
.. | .. |
---|
357 | 373 | break; |
---|
358 | 374 | } |
---|
359 | 375 | 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, |
---|
361 | 378 | sta ? sta->supp_rates[sband->band] : -1, |
---|
| 379 | + sband->band, |
---|
362 | 380 | rate_mask, rate_flags); |
---|
363 | 381 | |
---|
364 | 382 | info->control.rates[0].count = |
---|
.. | .. |
---|
369 | 387 | } |
---|
370 | 388 | |
---|
371 | 389 | |
---|
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) |
---|
375 | 392 | { |
---|
376 | 393 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); |
---|
377 | 394 | struct ieee80211_supported_band *sband = txrc->sband; |
---|
.. | .. |
---|
379 | 396 | int mcast_rate; |
---|
380 | 397 | bool use_basicrate = false; |
---|
381 | 398 | |
---|
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)) { |
---|
383 | 400 | __rate_control_send_low(txrc->hw, sband, pubsta, info, |
---|
384 | 401 | txrc->rate_idx_mask); |
---|
385 | 402 | |
---|
.. | .. |
---|
397 | 414 | } |
---|
398 | 415 | |
---|
399 | 416 | if (use_basicrate) |
---|
400 | | - rc_send_low_basicrate(&info->control.rates[0].idx, |
---|
| 417 | + rc_send_low_basicrate(&info->control.rates[0], |
---|
401 | 418 | txrc->bss_conf->basic_rates, |
---|
402 | 419 | sband); |
---|
403 | 420 | |
---|
.. | .. |
---|
405 | 422 | } |
---|
406 | 423 | return false; |
---|
407 | 424 | } |
---|
408 | | -EXPORT_SYMBOL(rate_control_send_low); |
---|
409 | 425 | |
---|
410 | 426 | static bool rate_idx_match_legacy_mask(s8 *rate_idx, int n_bitrates, u32 mask) |
---|
411 | 427 | { |
---|
.. | .. |
---|
888 | 904 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); |
---|
889 | 905 | int i; |
---|
890 | 906 | |
---|
891 | | - if (sta && test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) { |
---|
892 | | - ista = &sta->sta; |
---|
893 | | - priv_sta = sta->rate_ctrl_priv; |
---|
894 | | - } |
---|
895 | | - |
---|
896 | 907 | for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { |
---|
897 | 908 | info->control.rates[i].idx = -1; |
---|
898 | 909 | info->control.rates[i].flags = 0; |
---|
899 | 910 | info->control.rates[i].count = 0; |
---|
900 | 911 | } |
---|
901 | 912 | |
---|
| 913 | + if (rate_control_send_low(sta ? &sta->sta : NULL, txrc)) |
---|
| 914 | + return; |
---|
| 915 | + |
---|
902 | 916 | if (ieee80211_hw_check(&sdata->local->hw, HAS_RATE_CONTROL)) |
---|
903 | 917 | 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 | + } |
---|
904 | 923 | |
---|
905 | 924 | if (ista) { |
---|
906 | 925 | spin_lock_bh(&sta->rate_ctrl_lock); |
---|
907 | 926 | ref->ops->get_rate(ref->priv, ista, priv_sta, txrc); |
---|
908 | 927 | spin_unlock_bh(&sta->rate_ctrl_lock); |
---|
909 | 928 | } else { |
---|
910 | | - ref->ops->get_rate(ref->priv, NULL, NULL, txrc); |
---|
| 929 | + rate_control_send_low(NULL, txrc); |
---|
911 | 930 | } |
---|
912 | 931 | |
---|
913 | 932 | if (ieee80211_hw_check(&sdata->local->hw, SUPPORTS_RC_TABLE)) |
---|