Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'mac80211-next-for-net-next-2021-02-12' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next

Johannes Berg says:

====================
Last set of updates:
* more minstrel work from Felix to reduce the
probing overhead
* QoS for nl80211 control port frames
* STBC injection support
* and a couple of small fixes
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+488 -429
+2
include/net/cfg80211.h
··· 2583 2583 * authentication capability. Drivers can offload authentication to 2584 2584 * userspace if this flag is set. Only applicable for cfg80211_connect() 2585 2585 * request (connect callback). 2586 + * @ASSOC_REQ_DISABLE_HE: Disable HE 2586 2587 */ 2587 2588 enum cfg80211_assoc_req_flags { 2588 2589 ASSOC_REQ_DISABLE_HT = BIT(0), 2589 2590 ASSOC_REQ_DISABLE_VHT = BIT(1), 2590 2591 ASSOC_REQ_USE_RRM = BIT(2), 2591 2592 CONNECT_REQ_EXTERNAL_AUTH_SUPPORT = BIT(3), 2593 + ASSOC_REQ_DISABLE_HE = BIT(4), 2592 2594 }; 2593 2595 2594 2596 /**
+11 -2
include/uapi/linux/nl80211.h
··· 1963 1963 * @NL80211_ATTR_PROBE_RESP: Probe Response template data. Contains the entire 1964 1964 * probe-response frame. The DA field in the 802.11 header is zero-ed out, 1965 1965 * to be filled by the FW. 1966 - * @NL80211_ATTR_DISABLE_HT: Force HT capable interfaces to disable 1967 - * this feature. Currently, only supported in mac80211 drivers. 1966 + * @NL80211_ATTR_DISABLE_HT: Force HT capable interfaces to disable 1967 + * this feature during association. This is a flag attribute. 1968 + * Currently only supported in mac80211 drivers. 1969 + * @NL80211_ATTR_DISABLE_VHT: Force VHT capable interfaces to disable 1970 + * this feature during association. This is a flag attribute. 1971 + * Currently only supported in mac80211 drivers. 1972 + * @NL80211_ATTR_DISABLE_HE: Force HE capable interfaces to disable 1973 + * this feature during association. This is a flag attribute. 1974 + * Currently only supported in mac80211 drivers. 1968 1975 * @NL80211_ATTR_HT_CAPABILITY_MASK: Specify which bits of the 1969 1976 * ATTR_HT_CAPABILITY to which attention should be paid. 1970 1977 * Currently, only mac80211 NICs support this feature. ··· 3051 3044 NL80211_ATTR_RECONNECT_REQUESTED, 3052 3045 3053 3046 NL80211_ATTR_SAR_SPEC, 3047 + 3048 + NL80211_ATTR_DISABLE_HE, 3054 3049 3055 3050 /* add attributes here, update the policy in nl80211.c */ 3056 3051
+1 -1
net/mac80211/mesh_hwmp.c
··· 356 356 */ 357 357 tx_time = (device_constant + 10 * test_frame_len / rate); 358 358 estimated_retx = ((1 << (2 * ARITH_SHIFT)) / (s_unit - err)); 359 - result = (tx_time * estimated_retx) >> (2 * ARITH_SHIFT); 359 + result = ((u64)tx_time * estimated_retx) >> (2 * ARITH_SHIFT); 360 360 return (u32)result; 361 361 } 362 362
+3
net/mac80211/mlme.c
··· 5754 5754 if (req->flags & ASSOC_REQ_DISABLE_VHT) 5755 5755 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; 5756 5756 5757 + if (req->flags & ASSOC_REQ_DISABLE_HE) 5758 + ifmgd->flags |= IEEE80211_STA_DISABLE_HE; 5759 + 5757 5760 err = ieee80211_prep_connection(sdata, req->bss, true, override); 5758 5761 if (err) 5759 5762 goto err_clear;
+385 -385
net/mac80211/rc80211_minstrel_ht.c
··· 266 266 const s16 minstrel_cck_bitrates[4] = { 10, 20, 55, 110 }; 267 267 const s16 minstrel_ofdm_bitrates[8] = { 60, 90, 120, 180, 240, 360, 480, 540 }; 268 268 static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES] __read_mostly; 269 + static const u8 minstrel_sample_seq[] = { 270 + MINSTREL_SAMPLE_TYPE_INC, 271 + MINSTREL_SAMPLE_TYPE_JUMP, 272 + MINSTREL_SAMPLE_TYPE_INC, 273 + MINSTREL_SAMPLE_TYPE_JUMP, 274 + MINSTREL_SAMPLE_TYPE_INC, 275 + MINSTREL_SAMPLE_TYPE_SLOW, 276 + }; 269 277 270 278 static void 271 279 minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi); ··· 387 379 static inline struct minstrel_rate_stats * 388 380 minstrel_get_ratestats(struct minstrel_ht_sta *mi, int index) 389 381 { 390 - return &mi->groups[index / MCS_GROUP_RATES].rates[index % MCS_GROUP_RATES]; 382 + return &mi->groups[MI_RATE_GROUP(index)].rates[MI_RATE_IDX(index)]; 391 383 } 392 384 393 385 static inline int minstrel_get_duration(int index) 394 386 { 395 - const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; 396 - unsigned int duration = group->duration[index % MCS_GROUP_RATES]; 387 + const struct mcs_group *group = &minstrel_mcs_groups[MI_RATE_GROUP(index)]; 388 + unsigned int duration = group->duration[MI_RATE_IDX(index)]; 397 389 398 390 return duration << group->shift; 399 391 } ··· 406 398 if (mi->avg_ampdu_len) 407 399 return MINSTREL_TRUNC(mi->avg_ampdu_len); 408 400 409 - if (minstrel_ht_is_legacy_group(mi->max_tp_rate[0] / MCS_GROUP_RATES)) 401 + if (minstrel_ht_is_legacy_group(MI_RATE_GROUP(mi->max_tp_rate[0]))) 410 402 return 1; 411 403 412 404 duration = minstrel_get_duration(mi->max_tp_rate[0]); ··· 473 465 int tmp_group, tmp_idx, tmp_tp_avg, tmp_prob; 474 466 int j = MAX_THR_RATES; 475 467 476 - cur_group = index / MCS_GROUP_RATES; 477 - cur_idx = index % MCS_GROUP_RATES; 468 + cur_group = MI_RATE_GROUP(index); 469 + cur_idx = MI_RATE_IDX(index); 478 470 cur_prob = mi->groups[cur_group].rates[cur_idx].prob_avg; 479 471 cur_tp_avg = minstrel_ht_get_tp_avg(mi, cur_group, cur_idx, cur_prob); 480 472 481 473 do { 482 - tmp_group = tp_list[j - 1] / MCS_GROUP_RATES; 483 - tmp_idx = tp_list[j - 1] % MCS_GROUP_RATES; 474 + tmp_group = MI_RATE_GROUP(tp_list[j - 1]); 475 + tmp_idx = MI_RATE_IDX(tp_list[j - 1]); 484 476 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg; 485 477 tmp_tp_avg = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, 486 478 tmp_prob); ··· 512 504 int max_gpr_group, max_gpr_idx; 513 505 int max_gpr_tp_avg, max_gpr_prob; 514 506 515 - cur_group = index / MCS_GROUP_RATES; 516 - cur_idx = index % MCS_GROUP_RATES; 517 - mg = &mi->groups[index / MCS_GROUP_RATES]; 518 - mrs = &mg->rates[index % MCS_GROUP_RATES]; 507 + cur_group = MI_RATE_GROUP(index); 508 + cur_idx = MI_RATE_IDX(index); 509 + mg = &mi->groups[cur_group]; 510 + mrs = &mg->rates[cur_idx]; 519 511 520 - tmp_group = *dest / MCS_GROUP_RATES; 521 - tmp_idx = *dest % MCS_GROUP_RATES; 512 + tmp_group = MI_RATE_GROUP(*dest); 513 + tmp_idx = MI_RATE_IDX(*dest); 522 514 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg; 523 515 tmp_tp_avg = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob); 524 516 525 517 /* if max_tp_rate[0] is from MCS_GROUP max_prob_rate get selected from 526 518 * MCS_GROUP as well as CCK_GROUP rates do not allow aggregation */ 527 - max_tp_group = mi->max_tp_rate[0] / MCS_GROUP_RATES; 528 - max_tp_idx = mi->max_tp_rate[0] % MCS_GROUP_RATES; 519 + max_tp_group = MI_RATE_GROUP(mi->max_tp_rate[0]); 520 + max_tp_idx = MI_RATE_IDX(mi->max_tp_rate[0]); 529 521 max_tp_prob = mi->groups[max_tp_group].rates[max_tp_idx].prob_avg; 530 522 531 - if (minstrel_ht_is_legacy_group(index / MCS_GROUP_RATES) && 523 + if (minstrel_ht_is_legacy_group(MI_RATE_GROUP(index)) && 532 524 !minstrel_ht_is_legacy_group(max_tp_group)) 533 525 return; 534 526 ··· 537 529 mrs->prob_avg < max_tp_prob) 538 530 return; 539 531 540 - max_gpr_group = mg->max_group_prob_rate / MCS_GROUP_RATES; 541 - max_gpr_idx = mg->max_group_prob_rate % MCS_GROUP_RATES; 532 + max_gpr_group = MI_RATE_GROUP(mg->max_group_prob_rate); 533 + max_gpr_idx = MI_RATE_IDX(mg->max_group_prob_rate); 542 534 max_gpr_prob = mi->groups[max_gpr_group].rates[max_gpr_idx].prob_avg; 543 535 544 536 if (mrs->prob_avg > MINSTREL_FRAC(75, 100)) { ··· 575 567 unsigned int tmp_group, tmp_idx, tmp_cck_tp, tmp_mcs_tp, tmp_prob; 576 568 int i; 577 569 578 - tmp_group = tmp_legacy_tp_rate[0] / MCS_GROUP_RATES; 579 - tmp_idx = tmp_legacy_tp_rate[0] % MCS_GROUP_RATES; 570 + tmp_group = MI_RATE_GROUP(tmp_legacy_tp_rate[0]); 571 + tmp_idx = MI_RATE_IDX(tmp_legacy_tp_rate[0]); 580 572 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg; 581 573 tmp_cck_tp = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob); 582 574 583 - tmp_group = tmp_mcs_tp_rate[0] / MCS_GROUP_RATES; 584 - tmp_idx = tmp_mcs_tp_rate[0] % MCS_GROUP_RATES; 575 + tmp_group = MI_RATE_GROUP(tmp_mcs_tp_rate[0]); 576 + tmp_idx = MI_RATE_IDX(tmp_mcs_tp_rate[0]); 585 577 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg; 586 578 tmp_mcs_tp = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob); 587 579 ··· 608 600 if (!mi->sta->ht_cap.ht_supported) 609 601 return; 610 602 611 - tmp_max_streams = minstrel_mcs_groups[mi->max_tp_rate[0] / 612 - MCS_GROUP_RATES].streams; 603 + group = MI_RATE_GROUP(mi->max_tp_rate[0]); 604 + tmp_max_streams = minstrel_mcs_groups[group].streams; 613 605 for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { 614 606 mg = &mi->groups[group]; 615 607 if (!mi->supported[group] || group == MINSTREL_CCK_GROUP) 616 608 continue; 617 609 618 - tmp_idx = mg->max_group_prob_rate % MCS_GROUP_RATES; 610 + tmp_idx = MI_RATE_IDX(mg->max_group_prob_rate); 619 611 tmp_prob = mi->groups[group].rates[tmp_idx].prob_avg; 620 612 621 613 if (tmp_tp < minstrel_ht_get_tp_avg(mi, group, tmp_idx, tmp_prob) && ··· 628 620 } 629 621 } 630 622 631 - static bool 632 - minstrel_ht_probe_group(struct minstrel_ht_sta *mi, const struct mcs_group *tp_group, 633 - int tp_idx, const struct mcs_group *group) 623 + static u16 624 + __minstrel_ht_get_sample_rate(struct minstrel_ht_sta *mi, 625 + enum minstrel_sample_type type) 634 626 { 635 - if (group->bw < tp_group->bw) 636 - return false; 637 - 638 - if (group->streams == tp_group->streams) 639 - return true; 640 - 641 - if (tp_idx < 4 && group->streams == tp_group->streams - 1) 642 - return true; 643 - 644 - return group->streams == tp_group->streams + 1; 645 - } 646 - 647 - static void 648 - minstrel_ht_find_probe_rates(struct minstrel_ht_sta *mi, u16 *rates, int *n_rates, 649 - bool faster_rate) 650 - { 651 - const struct mcs_group *group, *tp_group; 652 - int i, g, max_dur; 653 - int tp_idx; 654 - 655 - tp_group = &minstrel_mcs_groups[mi->max_tp_rate[0] / MCS_GROUP_RATES]; 656 - tp_idx = mi->max_tp_rate[0] % MCS_GROUP_RATES; 657 - 658 - max_dur = minstrel_get_duration(mi->max_tp_rate[0]); 659 - if (faster_rate) 660 - max_dur -= max_dur / 16; 661 - 662 - for (g = 0; g < MINSTREL_GROUPS_NB; g++) { 663 - u16 supported = mi->supported[g]; 664 - 665 - if (!supported) 666 - continue; 667 - 668 - group = &minstrel_mcs_groups[g]; 669 - if (!minstrel_ht_probe_group(mi, tp_group, tp_idx, group)) 670 - continue; 671 - 672 - for (i = 0; supported; supported >>= 1, i++) { 673 - int idx; 674 - 675 - if (!(supported & 1)) 676 - continue; 677 - 678 - if ((group->duration[i] << group->shift) > max_dur) 679 - continue; 680 - 681 - idx = g * MCS_GROUP_RATES + i; 682 - if (idx == mi->max_tp_rate[0]) 683 - continue; 684 - 685 - rates[(*n_rates)++] = idx; 686 - break; 687 - } 688 - } 689 - } 690 - 691 - static void 692 - minstrel_ht_rate_sample_switch(struct minstrel_priv *mp, 693 - struct minstrel_ht_sta *mi) 694 - { 695 - struct minstrel_rate_stats *mrs; 696 - u16 rates[MINSTREL_GROUPS_NB]; 697 - int n_rates = 0; 698 - int probe_rate = 0; 699 - bool faster_rate; 627 + u16 *rates = mi->sample[type].sample_rates; 628 + u16 cur; 700 629 int i; 701 - u8 random; 702 630 703 - /* 704 - * Use rate switching instead of probing packets for devices with 705 - * little control over retry fallback behavior 706 - */ 707 - if (mp->hw->max_rates > 1) 708 - return; 631 + for (i = 0; i < MINSTREL_SAMPLE_RATES; i++) { 632 + if (!rates[i]) 633 + continue; 709 634 710 - /* 711 - * If the current EWMA prob is >75%, look for a rate that's 6.25% 712 - * faster than the max tp rate. 713 - * If that fails, look again for a rate that is at least as fast 714 - */ 715 - mrs = minstrel_get_ratestats(mi, mi->max_tp_rate[0]); 716 - faster_rate = mrs->prob_avg > MINSTREL_FRAC(75, 100); 717 - minstrel_ht_find_probe_rates(mi, rates, &n_rates, faster_rate); 718 - if (!n_rates && faster_rate) 719 - minstrel_ht_find_probe_rates(mi, rates, &n_rates, false); 720 - 721 - /* If no suitable rate was found, try to pick the next one in the group */ 722 - if (!n_rates) { 723 - int g_idx = mi->max_tp_rate[0] / MCS_GROUP_RATES; 724 - u16 supported = mi->supported[g_idx]; 725 - 726 - supported >>= mi->max_tp_rate[0] % MCS_GROUP_RATES; 727 - for (i = 0; supported; supported >>= 1, i++) { 728 - if (!(supported & 1)) 729 - continue; 730 - 731 - probe_rate = mi->max_tp_rate[0] + i; 732 - goto out; 733 - } 734 - 735 - return; 635 + cur = rates[i]; 636 + rates[i] = 0; 637 + return cur; 736 638 } 737 639 738 - i = 0; 739 - if (n_rates > 1) { 740 - random = prandom_u32(); 741 - i = random % n_rates; 742 - } 743 - probe_rate = rates[i]; 744 - 745 - out: 746 - mi->sample_rate = probe_rate; 747 - mi->sample_mode = MINSTREL_SAMPLE_ACTIVE; 640 + return 0; 748 641 } 749 642 750 643 static inline int ··· 700 791 unsigned int cur_prob; 701 792 702 793 if (unlikely(mrs->attempts > 0)) { 703 - mrs->sample_skipped = 0; 704 794 cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts); 705 795 minstrel_filter_avg_add(&mrs->prob_avg, 706 796 &mrs->prob_avg_1, cur_prob); 707 797 mrs->att_hist += mrs->attempts; 708 798 mrs->succ_hist += mrs->success; 709 - } else { 710 - mrs->sample_skipped++; 711 799 } 712 800 713 801 mrs->last_success = mrs->success; ··· 712 806 mrs->success = 0; 713 807 mrs->attempts = 0; 714 808 } 809 + 810 + static bool 811 + minstrel_ht_find_sample_rate(struct minstrel_ht_sta *mi, int type, int idx) 812 + { 813 + int i; 814 + 815 + for (i = 0; i < MINSTREL_SAMPLE_RATES; i++) { 816 + u16 cur = mi->sample[type].sample_rates[i]; 817 + 818 + if (cur == idx) 819 + return true; 820 + 821 + if (!cur) 822 + break; 823 + } 824 + 825 + return false; 826 + } 827 + 828 + static int 829 + minstrel_ht_move_sample_rates(struct minstrel_ht_sta *mi, int type, 830 + u32 fast_rate_dur, u32 slow_rate_dur) 831 + { 832 + u16 *rates = mi->sample[type].sample_rates; 833 + int i, j; 834 + 835 + for (i = 0, j = 0; i < MINSTREL_SAMPLE_RATES; i++) { 836 + u32 duration; 837 + bool valid = false; 838 + u16 cur; 839 + 840 + cur = rates[i]; 841 + if (!cur) 842 + continue; 843 + 844 + duration = minstrel_get_duration(cur); 845 + switch (type) { 846 + case MINSTREL_SAMPLE_TYPE_SLOW: 847 + valid = duration > fast_rate_dur && 848 + duration < slow_rate_dur; 849 + break; 850 + case MINSTREL_SAMPLE_TYPE_INC: 851 + case MINSTREL_SAMPLE_TYPE_JUMP: 852 + valid = duration < fast_rate_dur; 853 + break; 854 + default: 855 + valid = false; 856 + break; 857 + } 858 + 859 + if (!valid) { 860 + rates[i] = 0; 861 + continue; 862 + } 863 + 864 + if (i == j) 865 + continue; 866 + 867 + rates[j++] = cur; 868 + rates[i] = 0; 869 + } 870 + 871 + return j; 872 + } 873 + 874 + static int 875 + minstrel_ht_group_min_rate_offset(struct minstrel_ht_sta *mi, int group, 876 + u32 max_duration) 877 + { 878 + u16 supported = mi->supported[group]; 879 + int i; 880 + 881 + for (i = 0; i < MCS_GROUP_RATES && supported; i++, supported >>= 1) { 882 + if (!(supported & BIT(0))) 883 + continue; 884 + 885 + if (minstrel_get_duration(MI_RATE(group, i)) >= max_duration) 886 + continue; 887 + 888 + return i; 889 + } 890 + 891 + return -1; 892 + } 893 + 894 + /* 895 + * Incremental update rates: 896 + * Flip through groups and pick the first group rate that is faster than the 897 + * highest currently selected rate 898 + */ 899 + static u16 900 + minstrel_ht_next_inc_rate(struct minstrel_ht_sta *mi, u32 fast_rate_dur) 901 + { 902 + struct minstrel_mcs_group_data *mg; 903 + u8 type = MINSTREL_SAMPLE_TYPE_INC; 904 + int i, index = 0; 905 + u8 group; 906 + 907 + group = mi->sample[type].sample_group; 908 + for (i = 0; i < ARRAY_SIZE(minstrel_mcs_groups); i++) { 909 + group = (group + 1) % ARRAY_SIZE(minstrel_mcs_groups); 910 + mg = &mi->groups[group]; 911 + 912 + index = minstrel_ht_group_min_rate_offset(mi, group, 913 + fast_rate_dur); 914 + if (index < 0) 915 + continue; 916 + 917 + index = MI_RATE(group, index & 0xf); 918 + if (!minstrel_ht_find_sample_rate(mi, type, index)) 919 + goto out; 920 + } 921 + index = 0; 922 + 923 + out: 924 + mi->sample[type].sample_group = group; 925 + 926 + return index; 927 + } 928 + 929 + static int 930 + minstrel_ht_next_group_sample_rate(struct minstrel_ht_sta *mi, int group, 931 + u16 supported, int offset) 932 + { 933 + struct minstrel_mcs_group_data *mg = &mi->groups[group]; 934 + u16 idx; 935 + int i; 936 + 937 + for (i = 0; i < MCS_GROUP_RATES; i++) { 938 + idx = sample_table[mg->column][mg->index]; 939 + if (++mg->index >= MCS_GROUP_RATES) { 940 + mg->index = 0; 941 + if (++mg->column >= ARRAY_SIZE(sample_table)) 942 + mg->column = 0; 943 + } 944 + 945 + if (idx < offset) 946 + continue; 947 + 948 + if (!(supported & BIT(idx))) 949 + continue; 950 + 951 + return MI_RATE(group, idx); 952 + } 953 + 954 + return -1; 955 + } 956 + 957 + /* 958 + * Jump rates: 959 + * Sample random rates, use those that are faster than the highest 960 + * currently selected rate. Rates between the fastest and the slowest 961 + * get sorted into the slow sample bucket, but only if it has room 962 + */ 963 + static u16 964 + minstrel_ht_next_jump_rate(struct minstrel_ht_sta *mi, u32 fast_rate_dur, 965 + u32 slow_rate_dur, int *slow_rate_ofs) 966 + { 967 + struct minstrel_mcs_group_data *mg; 968 + struct minstrel_rate_stats *mrs; 969 + u32 max_duration = slow_rate_dur; 970 + int i, index, offset; 971 + u16 *slow_rates; 972 + u16 supported; 973 + u32 duration; 974 + u8 group; 975 + 976 + if (*slow_rate_ofs >= MINSTREL_SAMPLE_RATES) 977 + max_duration = fast_rate_dur; 978 + 979 + slow_rates = mi->sample[MINSTREL_SAMPLE_TYPE_SLOW].sample_rates; 980 + group = mi->sample[MINSTREL_SAMPLE_TYPE_JUMP].sample_group; 981 + for (i = 0; i < ARRAY_SIZE(minstrel_mcs_groups); i++) { 982 + u8 type; 983 + 984 + group = (group + 1) % ARRAY_SIZE(minstrel_mcs_groups); 985 + mg = &mi->groups[group]; 986 + 987 + supported = mi->supported[group]; 988 + if (!supported) 989 + continue; 990 + 991 + offset = minstrel_ht_group_min_rate_offset(mi, group, 992 + max_duration); 993 + if (offset < 0) 994 + continue; 995 + 996 + index = minstrel_ht_next_group_sample_rate(mi, group, supported, 997 + offset); 998 + if (index < 0) 999 + continue; 1000 + 1001 + duration = minstrel_get_duration(index); 1002 + if (duration < fast_rate_dur) 1003 + type = MINSTREL_SAMPLE_TYPE_JUMP; 1004 + else 1005 + type = MINSTREL_SAMPLE_TYPE_SLOW; 1006 + 1007 + if (minstrel_ht_find_sample_rate(mi, type, index)) 1008 + continue; 1009 + 1010 + if (type == MINSTREL_SAMPLE_TYPE_JUMP) 1011 + goto found; 1012 + 1013 + if (*slow_rate_ofs >= MINSTREL_SAMPLE_RATES) 1014 + continue; 1015 + 1016 + if (duration >= slow_rate_dur) 1017 + continue; 1018 + 1019 + /* skip slow rates with high success probability */ 1020 + mrs = minstrel_get_ratestats(mi, index); 1021 + if (mrs->prob_avg > MINSTREL_FRAC(95, 100)) 1022 + continue; 1023 + 1024 + slow_rates[(*slow_rate_ofs)++] = index; 1025 + if (*slow_rate_ofs >= MINSTREL_SAMPLE_RATES) 1026 + max_duration = fast_rate_dur; 1027 + } 1028 + index = 0; 1029 + 1030 + found: 1031 + mi->sample[MINSTREL_SAMPLE_TYPE_JUMP].sample_group = group; 1032 + 1033 + return index; 1034 + } 1035 + 1036 + static void 1037 + minstrel_ht_refill_sample_rates(struct minstrel_ht_sta *mi) 1038 + { 1039 + u32 prob_dur = minstrel_get_duration(mi->max_prob_rate); 1040 + u32 tp_dur = minstrel_get_duration(mi->max_tp_rate[0]); 1041 + u32 tp2_dur = minstrel_get_duration(mi->max_tp_rate[1]); 1042 + u32 fast_rate_dur = min(min(tp_dur, tp2_dur), prob_dur); 1043 + u32 slow_rate_dur = max(max(tp_dur, tp2_dur), prob_dur); 1044 + u16 *rates; 1045 + int i, j; 1046 + 1047 + rates = mi->sample[MINSTREL_SAMPLE_TYPE_INC].sample_rates; 1048 + i = minstrel_ht_move_sample_rates(mi, MINSTREL_SAMPLE_TYPE_INC, 1049 + fast_rate_dur, slow_rate_dur); 1050 + while (i < MINSTREL_SAMPLE_RATES) { 1051 + rates[i] = minstrel_ht_next_inc_rate(mi, tp_dur); 1052 + if (!rates[i]) 1053 + break; 1054 + 1055 + i++; 1056 + } 1057 + 1058 + rates = mi->sample[MINSTREL_SAMPLE_TYPE_JUMP].sample_rates; 1059 + i = minstrel_ht_move_sample_rates(mi, MINSTREL_SAMPLE_TYPE_JUMP, 1060 + fast_rate_dur, slow_rate_dur); 1061 + j = minstrel_ht_move_sample_rates(mi, MINSTREL_SAMPLE_TYPE_SLOW, 1062 + fast_rate_dur, slow_rate_dur); 1063 + while (i < MINSTREL_SAMPLE_RATES) { 1064 + rates[i] = minstrel_ht_next_jump_rate(mi, fast_rate_dur, 1065 + slow_rate_dur, &j); 1066 + if (!rates[i]) 1067 + break; 1068 + 1069 + i++; 1070 + } 1071 + 1072 + for (i = 0; i < ARRAY_SIZE(mi->sample); i++) 1073 + memcpy(mi->sample[i].cur_sample_rates, mi->sample[i].sample_rates, 1074 + sizeof(mi->sample[i].cur_sample_rates)); 1075 + } 1076 + 715 1077 716 1078 /* 717 1079 * Update rate statistics and select new primary rates ··· 991 817 * higher throughput rates, even if the probablity is a bit lower 992 818 */ 993 819 static void 994 - minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, 995 - bool sample) 820 + minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) 996 821 { 997 822 struct minstrel_mcs_group_data *mg; 998 823 struct minstrel_rate_stats *mrs; ··· 1000 827 u16 tmp_legacy_tp_rate[MAX_THR_RATES], tmp_max_prob_rate; 1001 828 u16 index; 1002 829 bool ht_supported = mi->sta->ht_cap.ht_supported; 1003 - 1004 - mi->sample_mode = MINSTREL_SAMPLE_IDLE; 1005 - 1006 - if (sample) { 1007 - mi->total_packets_cur = mi->total_packets - 1008 - mi->total_packets_last; 1009 - mi->total_packets_last = mi->total_packets; 1010 - } 1011 - if (!mp->sample_switch) 1012 - sample = false; 1013 - if (mi->total_packets_cur < SAMPLE_SWITCH_THR && mp->sample_switch != 1) 1014 - sample = false; 1015 830 1016 831 if (mi->ampdu_packets > 0) { 1017 832 if (!ieee80211_hw_check(mp->hw, TX_STATUS_NO_AMPDU_LEN)) ··· 1012 851 mi->ampdu_packets = 0; 1013 852 } 1014 853 1015 - mi->sample_slow = 0; 1016 - mi->sample_count = 0; 1017 - 1018 - memset(tmp_mcs_tp_rate, 0, sizeof(tmp_mcs_tp_rate)); 1019 - memset(tmp_legacy_tp_rate, 0, sizeof(tmp_legacy_tp_rate)); 1020 854 if (mi->supported[MINSTREL_CCK_GROUP]) 1021 - for (j = 0; j < ARRAY_SIZE(tmp_legacy_tp_rate); j++) 1022 - tmp_legacy_tp_rate[j] = MINSTREL_CCK_GROUP * MCS_GROUP_RATES; 855 + group = MINSTREL_CCK_GROUP; 1023 856 else if (mi->supported[MINSTREL_OFDM_GROUP]) 1024 - for (j = 0; j < ARRAY_SIZE(tmp_legacy_tp_rate); j++) 1025 - tmp_legacy_tp_rate[j] = MINSTREL_OFDM_GROUP * MCS_GROUP_RATES; 857 + group = MINSTREL_OFDM_GROUP; 858 + else 859 + group = 0; 860 + 861 + index = MI_RATE(group, 0); 862 + for (j = 0; j < ARRAY_SIZE(tmp_legacy_tp_rate); j++) 863 + tmp_legacy_tp_rate[j] = index; 1026 864 1027 865 if (mi->supported[MINSTREL_VHT_GROUP_0]) 1028 - index = MINSTREL_VHT_GROUP_0 * MCS_GROUP_RATES; 866 + group = MINSTREL_VHT_GROUP_0; 1029 867 else if (ht_supported) 1030 - index = MINSTREL_HT_GROUP_0 * MCS_GROUP_RATES; 868 + group = MINSTREL_HT_GROUP_0; 1031 869 else if (mi->supported[MINSTREL_CCK_GROUP]) 1032 - index = MINSTREL_CCK_GROUP * MCS_GROUP_RATES; 870 + group = MINSTREL_CCK_GROUP; 1033 871 else 1034 - index = MINSTREL_OFDM_GROUP * MCS_GROUP_RATES; 872 + group = MINSTREL_OFDM_GROUP; 1035 873 874 + index = MI_RATE(group, 0); 1036 875 tmp_max_prob_rate = index; 1037 876 for (j = 0; j < ARRAY_SIZE(tmp_mcs_tp_rate); j++) 1038 877 tmp_mcs_tp_rate[j] = index; ··· 1040 879 /* Find best rate sets within all MCS groups*/ 1041 880 for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { 1042 881 u16 *tp_rate = tmp_mcs_tp_rate; 882 + u16 last_prob = 0; 1043 883 1044 884 mg = &mi->groups[group]; 1045 885 if (!mi->supported[group]) 1046 886 continue; 1047 887 1048 - mi->sample_count++; 1049 - 1050 888 /* (re)Initialize group rate indexes */ 1051 889 for(j = 0; j < MAX_THR_RATES; j++) 1052 - tmp_group_tp_rate[j] = MCS_GROUP_RATES * group; 890 + tmp_group_tp_rate[j] = MI_RATE(group, 0); 1053 891 1054 892 if (group == MINSTREL_CCK_GROUP && ht_supported) 1055 893 tp_rate = tmp_legacy_tp_rate; 1056 894 1057 - for (i = 0; i < MCS_GROUP_RATES; i++) { 895 + for (i = MCS_GROUP_RATES - 1; i >= 0; i--) { 1058 896 if (!(mi->supported[group] & BIT(i))) 1059 897 continue; 1060 898 1061 - index = MCS_GROUP_RATES * group + i; 899 + index = MI_RATE(group, i); 1062 900 1063 901 mrs = &mg->rates[i]; 1064 902 mrs->retry_updated = false; 1065 903 minstrel_ht_calc_rate_stats(mp, mrs); 904 + 905 + if (mrs->att_hist) 906 + last_prob = max(last_prob, mrs->prob_avg); 907 + else 908 + mrs->prob_avg = max(last_prob, mrs->prob_avg); 1066 909 cur_prob = mrs->prob_avg; 1067 910 1068 911 if (minstrel_ht_get_tp_avg(mi, group, i, cur_prob) == 0) ··· 1094 929 continue; 1095 930 1096 931 mg = &mi->groups[group]; 1097 - mg->max_group_prob_rate = MCS_GROUP_RATES * group; 932 + mg->max_group_prob_rate = MI_RATE(group, 0); 1098 933 1099 934 for (i = 0; i < MCS_GROUP_RATES; i++) { 1100 935 if (!(mi->supported[group] & BIT(i))) 1101 936 continue; 1102 937 1103 - index = MCS_GROUP_RATES * group + i; 938 + index = MI_RATE(group, i); 1104 939 1105 940 /* Find max probability rate per group and global */ 1106 941 minstrel_ht_set_best_prob_rate(mi, &tmp_max_prob_rate, ··· 1112 947 1113 948 /* Try to increase robustness of max_prob_rate*/ 1114 949 minstrel_ht_prob_rate_reduce_streams(mi); 1115 - 1116 - /* try to sample half of all available rates during each interval */ 1117 - mi->sample_count *= 4; 1118 - 1119 - if (sample) 1120 - minstrel_ht_rate_sample_switch(mp, mi); 950 + minstrel_ht_refill_sample_rates(mi); 1121 951 1122 952 #ifdef CONFIG_MAC80211_DEBUGFS 1123 953 /* use fixed index if set */ ··· 1120 960 for (i = 0; i < 4; i++) 1121 961 mi->max_tp_rate[i] = mp->fixed_rate_idx; 1122 962 mi->max_prob_rate = mp->fixed_rate_idx; 1123 - mi->sample_mode = MINSTREL_SAMPLE_IDLE; 1124 963 } 1125 964 #endif 1126 965 1127 966 /* Reset update timer */ 1128 967 mi->last_stats_update = jiffies; 968 + mi->sample_time = jiffies; 1129 969 } 1130 970 1131 971 static bool ··· 1156 996 } 1157 997 1158 998 static void 1159 - minstrel_set_next_sample_idx(struct minstrel_ht_sta *mi) 1160 - { 1161 - struct minstrel_mcs_group_data *mg; 1162 - 1163 - for (;;) { 1164 - mi->sample_group++; 1165 - mi->sample_group %= ARRAY_SIZE(minstrel_mcs_groups); 1166 - mg = &mi->groups[mi->sample_group]; 1167 - 1168 - if (!mi->supported[mi->sample_group]) 1169 - continue; 1170 - 1171 - if (++mg->index >= MCS_GROUP_RATES) { 1172 - mg->index = 0; 1173 - if (++mg->column >= ARRAY_SIZE(sample_table)) 1174 - mg->column = 0; 1175 - } 1176 - break; 1177 - } 1178 - } 1179 - 1180 - static void 1181 999 minstrel_downgrade_rate(struct minstrel_ht_sta *mi, u16 *idx, bool primary) 1182 1000 { 1183 1001 int group, orig_group; 1184 1002 1185 - orig_group = group = *idx / MCS_GROUP_RATES; 1003 + orig_group = group = MI_RATE_GROUP(*idx); 1186 1004 while (group > 0) { 1187 1005 group--; 1188 1006 ··· 1209 1071 struct ieee80211_tx_info *info = st->info; 1210 1072 struct minstrel_ht_sta *mi = priv_sta; 1211 1073 struct ieee80211_tx_rate *ar = info->status.rates; 1212 - struct minstrel_rate_stats *rate, *rate2, *rate_sample = NULL; 1074 + struct minstrel_rate_stats *rate, *rate2; 1213 1075 struct minstrel_priv *mp = priv; 1214 1076 u32 update_interval = mp->update_interval; 1215 1077 bool last, update = false; 1216 - bool sample_status = false; 1217 1078 int i; 1218 1079 1219 1080 /* This packet was aggregated but doesn't carry status info */ ··· 1226 1089 info->status.ampdu_len = 1; 1227 1090 } 1228 1091 1229 - mi->ampdu_packets++; 1230 - mi->ampdu_len += info->status.ampdu_len; 1231 - 1232 - if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) { 1233 - int avg_ampdu_len = minstrel_ht_avg_ampdu_len(mi); 1234 - 1235 - mi->sample_wait = 16 + 2 * avg_ampdu_len; 1236 - mi->sample_tries = 1; 1237 - mi->sample_count--; 1092 + /* wraparound */ 1093 + if (mi->total_packets >= ~0 - info->status.ampdu_len) { 1094 + mi->total_packets = 0; 1095 + mi->sample_packets = 0; 1238 1096 } 1239 1097 1098 + mi->total_packets += info->status.ampdu_len; 1240 1099 if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) 1241 1100 mi->sample_packets += info->status.ampdu_len; 1242 1101 1243 - if (mi->sample_mode != MINSTREL_SAMPLE_IDLE) 1244 - rate_sample = minstrel_get_ratestats(mi, mi->sample_rate); 1102 + mi->ampdu_packets++; 1103 + mi->ampdu_len += info->status.ampdu_len; 1245 1104 1246 1105 last = !minstrel_ht_txstat_valid(mp, mi, &ar[0]); 1247 1106 for (i = 0; !last; i++) { ··· 1245 1112 !minstrel_ht_txstat_valid(mp, mi, &ar[i + 1]); 1246 1113 1247 1114 rate = minstrel_ht_get_stats(mp, mi, &ar[i]); 1248 - if (rate == rate_sample) 1249 - sample_status = true; 1250 - 1251 1115 if (last) 1252 1116 rate->success += info->status.ampdu_ack_len; 1253 1117 1254 1118 rate->attempts += ar[i].count * info->status.ampdu_len; 1255 1119 } 1256 - 1257 - switch (mi->sample_mode) { 1258 - case MINSTREL_SAMPLE_IDLE: 1259 - if (mp->hw->max_rates > 1 || 1260 - mi->total_packets_cur < SAMPLE_SWITCH_THR) 1261 - update_interval /= 2; 1262 - break; 1263 - 1264 - case MINSTREL_SAMPLE_ACTIVE: 1265 - if (!sample_status) 1266 - break; 1267 - 1268 - mi->sample_mode = MINSTREL_SAMPLE_PENDING; 1269 - update = true; 1270 - break; 1271 - 1272 - case MINSTREL_SAMPLE_PENDING: 1273 - if (sample_status) 1274 - break; 1275 - 1276 - update = true; 1277 - minstrel_ht_update_stats(mp, mi, false); 1278 - break; 1279 - } 1280 - 1281 1120 1282 1121 if (mp->hw->max_rates > 1) { 1283 1122 /* ··· 1273 1168 1274 1169 if (time_after(jiffies, mi->last_stats_update + update_interval)) { 1275 1170 update = true; 1276 - minstrel_ht_update_stats(mp, mi, true); 1171 + minstrel_ht_update_stats(mp, mi); 1277 1172 } 1278 1173 1279 1174 if (update) ··· 1311 1206 ctime += (t_slot * cw) >> 1; 1312 1207 cw = min((cw << 1) | 1, mp->cw_max); 1313 1208 1314 - if (minstrel_ht_is_legacy_group(index / MCS_GROUP_RATES)) { 1209 + if (minstrel_ht_is_legacy_group(MI_RATE_GROUP(index))) { 1315 1210 overhead = mi->overhead_legacy; 1316 1211 overhead_rtscts = mi->overhead_legacy_rtscts; 1317 1212 } else { ··· 1344 1239 minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, 1345 1240 struct ieee80211_sta_rates *ratetbl, int offset, int index) 1346 1241 { 1347 - int group_idx = index / MCS_GROUP_RATES; 1242 + int group_idx = MI_RATE_GROUP(index); 1348 1243 const struct mcs_group *group = &minstrel_mcs_groups[group_idx]; 1349 1244 struct minstrel_rate_stats *mrs; 1350 1245 u8 idx; ··· 1364 1259 ratetbl->rate[offset].count_rts = mrs->retry_count_rtscts; 1365 1260 } 1366 1261 1367 - index %= MCS_GROUP_RATES; 1262 + index = MI_RATE_IDX(index); 1368 1263 if (group_idx == MINSTREL_CCK_GROUP) 1369 1264 idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)]; 1370 1265 else if (group_idx == MINSTREL_OFDM_GROUP) ··· 1394 1289 static inline int 1395 1290 minstrel_ht_get_prob_avg(struct minstrel_ht_sta *mi, int rate) 1396 1291 { 1397 - int group = rate / MCS_GROUP_RATES; 1398 - rate %= MCS_GROUP_RATES; 1292 + int group = MI_RATE_GROUP(rate); 1293 + rate = MI_RATE_IDX(rate); 1399 1294 return mi->groups[group].rates[rate].prob_avg; 1400 1295 } 1401 1296 1402 1297 static int 1403 1298 minstrel_ht_get_max_amsdu_len(struct minstrel_ht_sta *mi) 1404 1299 { 1405 - int group = mi->max_prob_rate / MCS_GROUP_RATES; 1300 + int group = MI_RATE_GROUP(mi->max_prob_rate); 1406 1301 const struct mcs_group *g = &minstrel_mcs_groups[group]; 1407 - int rate = mi->max_prob_rate % MCS_GROUP_RATES; 1302 + int rate = MI_RATE_IDX(mi->max_prob_rate); 1408 1303 unsigned int duration; 1409 1304 1410 1305 /* Disable A-MSDU if max_prob_rate is bad */ ··· 1452 1347 minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) 1453 1348 { 1454 1349 struct ieee80211_sta_rates *rates; 1455 - u16 first_rate = mi->max_tp_rate[0]; 1456 1350 int i = 0; 1457 - 1458 - if (mi->sample_mode == MINSTREL_SAMPLE_ACTIVE) 1459 - first_rate = mi->sample_rate; 1460 1351 1461 1352 rates = kzalloc(sizeof(*rates), GFP_ATOMIC); 1462 1353 if (!rates) 1463 1354 return; 1464 1355 1465 1356 /* Start with max_tp_rate[0] */ 1466 - minstrel_ht_set_rate(mp, mi, rates, i++, first_rate); 1357 + minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate[0]); 1467 1358 1468 1359 if (mp->hw->max_rates >= 3) { 1469 1360 /* At least 3 tx rates supported, use max_tp_rate[1] next */ ··· 1475 1374 rate_control_set_rates(mp->hw, mi->sta, rates); 1476 1375 } 1477 1376 1478 - static int 1479 - minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) 1377 + static u16 1378 + minstrel_ht_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) 1480 1379 { 1481 - struct minstrel_rate_stats *mrs; 1482 - struct minstrel_mcs_group_data *mg; 1483 - unsigned int sample_dur, sample_group, cur_max_tp_streams; 1484 - int tp_rate1, tp_rate2; 1485 - int sample_idx = 0; 1380 + u8 seq; 1486 1381 1487 - if (mp->hw->max_rates == 1 && mp->sample_switch && 1488 - (mi->total_packets_cur >= SAMPLE_SWITCH_THR || 1489 - mp->sample_switch == 1)) 1490 - return -1; 1491 - 1492 - if (mi->sample_wait > 0) { 1493 - mi->sample_wait--; 1494 - return -1; 1495 - } 1496 - 1497 - if (!mi->sample_tries) 1498 - return -1; 1499 - 1500 - sample_group = mi->sample_group; 1501 - mg = &mi->groups[sample_group]; 1502 - sample_idx = sample_table[mg->column][mg->index]; 1503 - minstrel_set_next_sample_idx(mi); 1504 - 1505 - if (!(mi->supported[sample_group] & BIT(sample_idx))) 1506 - return -1; 1507 - 1508 - mrs = &mg->rates[sample_idx]; 1509 - sample_idx += sample_group * MCS_GROUP_RATES; 1510 - 1511 - tp_rate1 = mi->max_tp_rate[0]; 1512 - 1513 - /* Set tp_rate2 to the second highest max_tp_rate */ 1514 - if (minstrel_get_duration(mi->max_tp_rate[0]) > 1515 - minstrel_get_duration(mi->max_tp_rate[1])) { 1516 - tp_rate2 = mi->max_tp_rate[0]; 1382 + if (mp->hw->max_rates > 1) { 1383 + seq = mi->sample_seq; 1384 + mi->sample_seq = (seq + 1) % ARRAY_SIZE(minstrel_sample_seq); 1385 + seq = minstrel_sample_seq[seq]; 1517 1386 } else { 1518 - tp_rate2 = mi->max_tp_rate[1]; 1387 + seq = MINSTREL_SAMPLE_TYPE_INC; 1519 1388 } 1520 1389 1521 - /* 1522 - * Sampling might add some overhead (RTS, no aggregation) 1523 - * to the frame. Hence, don't use sampling for the highest currently 1524 - * used highest throughput or probability rate. 1525 - */ 1526 - if (sample_idx == mi->max_tp_rate[0] || sample_idx == mi->max_prob_rate) 1527 - return -1; 1528 - 1529 - /* 1530 - * Do not sample if the probability is already higher than 95%, 1531 - * or if the rate is 3 times slower than the current max probability 1532 - * rate, to avoid wasting airtime. 1533 - */ 1534 - sample_dur = minstrel_get_duration(sample_idx); 1535 - if (mrs->prob_avg > MINSTREL_FRAC(95, 100) || 1536 - minstrel_get_duration(mi->max_prob_rate) * 3 < sample_dur) 1537 - return -1; 1538 - 1539 - 1540 - /* 1541 - * For devices with no configurable multi-rate retry, skip sampling 1542 - * below the per-group max throughput rate, and only use one sampling 1543 - * attempt per rate 1544 - */ 1545 - if (mp->hw->max_rates == 1 && 1546 - (minstrel_get_duration(mg->max_group_tp_rate[0]) < sample_dur || 1547 - mrs->attempts)) 1548 - return -1; 1549 - 1550 - /* Skip already sampled slow rates */ 1551 - if (sample_dur >= minstrel_get_duration(tp_rate1) && mrs->attempts) 1552 - return -1; 1553 - 1554 - /* 1555 - * Make sure that lower rates get sampled only occasionally, 1556 - * if the link is working perfectly. 1557 - */ 1558 - 1559 - cur_max_tp_streams = minstrel_mcs_groups[tp_rate1 / 1560 - MCS_GROUP_RATES].streams; 1561 - if (sample_dur >= minstrel_get_duration(tp_rate2) && 1562 - (cur_max_tp_streams - 1 < 1563 - minstrel_mcs_groups[sample_group].streams || 1564 - sample_dur >= minstrel_get_duration(mi->max_prob_rate))) { 1565 - if (mrs->sample_skipped < 20) 1566 - return -1; 1567 - 1568 - if (mi->sample_slow++ > 2) 1569 - return -1; 1570 - } 1571 - mi->sample_tries--; 1572 - 1573 - return sample_idx; 1390 + return __minstrel_ht_get_sample_rate(mi, seq); 1574 1391 } 1575 1392 1576 1393 static void ··· 1500 1481 struct ieee80211_tx_rate *rate = &info->status.rates[0]; 1501 1482 struct minstrel_ht_sta *mi = priv_sta; 1502 1483 struct minstrel_priv *mp = priv; 1503 - int sample_idx; 1484 + u16 sample_idx; 1504 1485 1505 1486 if (!(info->flags & IEEE80211_TX_CTL_AMPDU) && 1506 - !minstrel_ht_is_legacy_group(mi->max_prob_rate / MCS_GROUP_RATES)) 1487 + !minstrel_ht_is_legacy_group(MI_RATE_GROUP(mi->max_prob_rate))) 1507 1488 minstrel_aggr_check(sta, txrc->skb); 1508 1489 1509 1490 info->flags |= mi->tx_flags; ··· 1516 1497 /* Don't use EAPOL frames for sampling on non-mrr hw */ 1517 1498 if (mp->hw->max_rates == 1 && 1518 1499 (info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO)) 1519 - sample_idx = -1; 1520 - else 1521 - sample_idx = minstrel_get_sample_rate(mp, mi); 1522 - 1523 - mi->total_packets++; 1524 - 1525 - /* wraparound */ 1526 - if (mi->total_packets == ~0) { 1527 - mi->total_packets = 0; 1528 - mi->sample_packets = 0; 1529 - } 1530 - 1531 - if (sample_idx < 0) 1532 1500 return; 1533 1501 1534 - sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES]; 1535 - sample_idx %= MCS_GROUP_RATES; 1502 + if (time_is_before_jiffies(mi->sample_time)) 1503 + return; 1504 + 1505 + mi->sample_time = jiffies + MINSTREL_SAMPLE_INTERVAL; 1506 + sample_idx = minstrel_ht_get_sample_rate(mp, mi); 1507 + if (!sample_idx) 1508 + return; 1509 + 1510 + sample_group = &minstrel_mcs_groups[MI_RATE_GROUP(sample_idx)]; 1511 + sample_idx = MI_RATE_IDX(sample_idx); 1536 1512 1537 1513 if (sample_group == &minstrel_mcs_groups[MINSTREL_CCK_GROUP] && 1538 1514 (sample_idx >= 4) != txrc->short_preamble) ··· 1543 1529 int idx = sample_idx % ARRAY_SIZE(mp->ofdm_rates[0]); 1544 1530 rate->idx = mp->ofdm_rates[mi->band][idx]; 1545 1531 } else if (sample_group->flags & IEEE80211_TX_RC_VHT_MCS) { 1546 - ieee80211_rate_set_vht(rate, sample_idx % MCS_GROUP_RATES, 1532 + ieee80211_rate_set_vht(rate, MI_RATE_IDX(sample_idx), 1547 1533 sample_group->streams); 1548 1534 } else { 1549 1535 rate->idx = sample_idx + (sample_group->streams - 1) * 8; ··· 1644 1630 1645 1631 mi->avg_ampdu_len = MINSTREL_FRAC(1, 1); 1646 1632 1647 - /* When using MRR, sample more on the first attempt, without delay */ 1648 - if (mp->has_mrr) { 1649 - mi->sample_count = 16; 1650 - mi->sample_wait = 0; 1651 - } else { 1652 - mi->sample_count = 8; 1653 - mi->sample_wait = 8; 1654 - } 1655 - mi->sample_tries = 4; 1656 - 1657 1633 if (!use_vht) { 1658 1634 stbc = (ht_cap & IEEE80211_HT_CAP_RX_STBC) >> 1659 1635 IEEE80211_HT_CAP_RX_STBC_SHIFT; ··· 1731 1727 minstrel_ht_update_ofdm(mp, mi, sband, sta); 1732 1728 1733 1729 /* create an initial rate table with the lowest supported rates */ 1734 - minstrel_ht_update_stats(mp, mi, true); 1730 + minstrel_ht_update_stats(mp, mi); 1735 1731 minstrel_ht_update_rates(mp, mi); 1736 1732 } 1737 1733 ··· 1847 1843 if (!mp) 1848 1844 return NULL; 1849 1845 1850 - mp->sample_switch = -1; 1851 - 1852 1846 /* contention window settings 1853 1847 * Just an approximation. Using the per-queue values would complicate 1854 1848 * the calculations and is probably unnecessary */ ··· 1866 1864 mp->has_mrr = true; 1867 1865 1868 1866 mp->hw = hw; 1869 - mp->update_interval = HZ / 10; 1867 + mp->update_interval = HZ / 20; 1870 1868 1871 1869 minstrel_ht_init_cck_rates(mp); 1872 1870 for (i = 0; i < ARRAY_SIZE(mp->hw->wiphy->bands); i++) ··· 1884 1882 mp->fixed_rate_idx = (u32) -1; 1885 1883 debugfs_create_u32("fixed_rate_idx", S_IRUGO | S_IWUGO, debugfsdir, 1886 1884 &mp->fixed_rate_idx); 1887 - debugfs_create_u32("sample_switch", S_IRUGO | S_IWUSR, debugfsdir, 1888 - &mp->sample_switch); 1889 1885 } 1890 1886 #endif 1891 1887 ··· 1898 1898 struct minstrel_ht_sta *mi = priv_sta; 1899 1899 int i, j, prob, tp_avg; 1900 1900 1901 - i = mi->max_tp_rate[0] / MCS_GROUP_RATES; 1902 - j = mi->max_tp_rate[0] % MCS_GROUP_RATES; 1901 + i = MI_RATE_GROUP(mi->max_tp_rate[0]); 1902 + j = MI_RATE_IDX(mi->max_tp_rate[0]); 1903 1903 prob = mi->groups[i].rates[j].prob_avg; 1904 1904 1905 1905 /* convert tp_avg from pkt per second in kbps */
+30 -17
net/mac80211/rc80211_minstrel_ht.h
··· 6 6 #ifndef __RC_MINSTREL_HT_H 7 7 #define __RC_MINSTREL_HT_H 8 8 9 + #include <linux/bitfield.h> 10 + 9 11 /* number of highest throughput rates to consider*/ 10 12 #define MAX_THR_RATES 4 11 13 #define SAMPLE_COLUMNS 10 /* number of columns in sample table */ ··· 59 57 60 58 #define MCS_GROUP_RATES 10 61 59 60 + #define MI_RATE_IDX_MASK GENMASK(3, 0) 61 + #define MI_RATE_GROUP_MASK GENMASK(15, 4) 62 + 63 + #define MI_RATE(_group, _idx) \ 64 + (FIELD_PREP(MI_RATE_GROUP_MASK, _group) | \ 65 + FIELD_PREP(MI_RATE_IDX_MASK, _idx)) 66 + 67 + #define MI_RATE_IDX(_rate) FIELD_GET(MI_RATE_IDX_MASK, _rate) 68 + #define MI_RATE_GROUP(_rate) FIELD_GET(MI_RATE_GROUP_MASK, _rate) 69 + 70 + #define MINSTREL_SAMPLE_RATES 5 /* rates per sample type */ 71 + #define MINSTREL_SAMPLE_INTERVAL (HZ / 50) 72 + 62 73 struct minstrel_priv { 63 74 struct ieee80211_hw *hw; 64 75 bool has_mrr; 65 - u32 sample_switch; 66 76 unsigned int cw_min; 67 77 unsigned int cw_max; 68 78 unsigned int max_retry; ··· 124 110 u8 retry_count; 125 111 u8 retry_count_rtscts; 126 112 127 - u8 sample_skipped; 128 113 bool retry_updated; 114 + }; 115 + 116 + enum minstrel_sample_type { 117 + MINSTREL_SAMPLE_TYPE_INC, 118 + MINSTREL_SAMPLE_TYPE_JUMP, 119 + MINSTREL_SAMPLE_TYPE_SLOW, 120 + __MINSTREL_SAMPLE_TYPE_MAX 129 121 }; 130 122 131 123 struct minstrel_mcs_group_data { ··· 146 126 struct minstrel_rate_stats rates[MCS_GROUP_RATES]; 147 127 }; 148 128 149 - enum minstrel_sample_mode { 150 - MINSTREL_SAMPLE_IDLE, 151 - MINSTREL_SAMPLE_ACTIVE, 152 - MINSTREL_SAMPLE_PENDING, 129 + struct minstrel_sample_category { 130 + u8 sample_group; 131 + u16 sample_rates[MINSTREL_SAMPLE_RATES]; 132 + u16 cur_sample_rates[MINSTREL_SAMPLE_RATES]; 153 133 }; 154 134 155 135 struct minstrel_ht_sta { ··· 175 155 unsigned int overhead_legacy; 176 156 unsigned int overhead_legacy_rtscts; 177 157 178 - unsigned int total_packets_last; 179 - unsigned int total_packets_cur; 180 158 unsigned int total_packets; 181 159 unsigned int sample_packets; 182 160 183 161 /* tx flags to add for frames for this sta */ 184 162 u32 tx_flags; 185 163 186 - u8 sample_wait; 187 - u8 sample_tries; 188 - u8 sample_count; 189 - u8 sample_slow; 164 + u8 band; 190 165 191 - enum minstrel_sample_mode sample_mode; 166 + u8 sample_seq; 192 167 u16 sample_rate; 193 168 194 - /* current MCS group to be sampled */ 195 - u8 sample_group; 196 - 197 - u8 band; 169 + unsigned long sample_time; 170 + struct minstrel_sample_category sample[__MINSTREL_SAMPLE_TYPE_MAX]; 198 171 199 172 /* Bitfield of supported MCS rates of all groups */ 200 173 u16 supported[MINSTREL_GROUPS_NB];
+18 -4
net/mac80211/rc80211_minstrel_ht_debugfs.c
··· 32 32 return 0; 33 33 } 34 34 35 + static bool 36 + minstrel_ht_is_sample_rate(struct minstrel_ht_sta *mi, int idx) 37 + { 38 + int type, i; 39 + 40 + for (type = 0; type < ARRAY_SIZE(mi->sample); type++) 41 + for (i = 0; i < MINSTREL_SAMPLE_RATES; i++) 42 + if (mi->sample[type].cur_sample_rates[i] == idx) 43 + return true; 44 + return false; 45 + } 46 + 35 47 static char * 36 48 minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) 37 49 { ··· 68 56 69 57 for (j = 0; j < MCS_GROUP_RATES; j++) { 70 58 struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j]; 71 - int idx = i * MCS_GROUP_RATES + j; 59 + int idx = MI_RATE(i, j); 72 60 unsigned int duration; 73 61 74 62 if (!(mi->supported[i] & BIT(j))) ··· 96 84 *(p++) = (idx == mi->max_tp_rate[2]) ? 'C' : ' '; 97 85 *(p++) = (idx == mi->max_tp_rate[3]) ? 'D' : ' '; 98 86 *(p++) = (idx == mi->max_prob_rate) ? 'P' : ' '; 87 + *(p++) = minstrel_ht_is_sample_rate(mi, idx) ? 'S' : ' '; 99 88 100 89 if (gflags & IEEE80211_TX_RC_MCS) { 101 90 p += sprintf(p, " MCS%-2u", (mg->streams - 1) * 8 + j); ··· 158 145 159 146 p += sprintf(p, "\n"); 160 147 p += sprintf(p, 161 - " best ____________rate__________ ____statistics___ _____last____ ______sum-of________\n"); 148 + " best ____________rate__________ ____statistics___ _____last____ ______sum-of________\n"); 162 149 p += sprintf(p, 163 - "mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]\n"); 150 + "mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]\n"); 164 151 165 152 p = minstrel_ht_stats_dump(mi, MINSTREL_CCK_GROUP, p); 166 153 for (i = 0; i < MINSTREL_CCK_GROUP; i++) ··· 214 201 215 202 for (j = 0; j < MCS_GROUP_RATES; j++) { 216 203 struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j]; 217 - int idx = i * MCS_GROUP_RATES + j; 204 + int idx = MI_RATE(i, j); 218 205 unsigned int duration; 219 206 220 207 if (!(mi->supported[i] & BIT(j))) ··· 241 228 p += sprintf(p, "%s" ,((idx == mi->max_tp_rate[2]) ? "C" : "")); 242 229 p += sprintf(p, "%s" ,((idx == mi->max_tp_rate[3]) ? "D" : "")); 243 230 p += sprintf(p, "%s" ,((idx == mi->max_prob_rate) ? "P" : "")); 231 + p += sprintf(p, "%s", (minstrel_ht_is_sample_rate(mi, idx) ? "S" : "")); 244 232 245 233 if (gflags & IEEE80211_TX_RC_MCS) { 246 234 p += sprintf(p, ",MCS%-2u,", (mg->streams - 1) * 8 + j);
+2 -6
net/mac80211/status.c
··· 628 628 u64 cookie = IEEE80211_SKB_CB(skb)->ack.cookie; 629 629 struct ieee80211_sub_if_data *sdata; 630 630 struct ieee80211_hdr *hdr = (void *)skb->data; 631 - __be16 ethertype = 0; 632 - 633 - if (skb->len >= ETH_HLEN && skb->protocol == cpu_to_be16(ETH_P_802_3)) 634 - skb_copy_bits(skb, 2 * ETH_ALEN, &ethertype, ETH_TLEN); 635 631 636 632 rcu_read_lock(); 637 633 sdata = ieee80211_sdata_from_skb(local, skb); 638 634 if (sdata) { 639 - if (ethertype == sdata->control_port_protocol || 640 - ethertype == cpu_to_be16(ETH_P_PREAUTH)) 635 + if (skb->protocol == sdata->control_port_protocol || 636 + skb->protocol == cpu_to_be16(ETH_P_PREAUTH)) 641 637 cfg80211_control_port_tx_status(&sdata->wdev, 642 638 cookie, 643 639 skb->data,
+28 -6
net/mac80211/tx.c
··· 1182 1182 tx->sta = rcu_dereference(sdata->u.vlan.sta); 1183 1183 if (!tx->sta && sdata->wdev.use_4addr) 1184 1184 return TX_DROP; 1185 - } else if (info->flags & (IEEE80211_TX_INTFL_NL80211_FRAME_TX | 1186 - IEEE80211_TX_CTL_INJECTED) || 1187 - tx->sdata->control_port_protocol == tx->skb->protocol) { 1185 + } else if (tx->sdata->control_port_protocol == tx->skb->protocol) { 1188 1186 tx->sta = sta_info_get_bss(sdata, hdr->addr1); 1189 1187 } 1190 1188 if (!tx->sta && !is_multicast_ether_addr(hdr->addr1)) ··· 2122 2124 if (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_FEC && 2123 2125 mcs_flags & IEEE80211_RADIOTAP_MCS_FEC_LDPC) 2124 2126 info->flags |= IEEE80211_TX_CTL_LDPC; 2127 + 2128 + if (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_STBC) { 2129 + u8 stbc = u8_get_bits(mcs_flags, 2130 + IEEE80211_RADIOTAP_MCS_STBC_MASK); 2131 + 2132 + info->flags |= 2133 + u32_encode_bits(stbc, 2134 + IEEE80211_TX_CTL_STBC); 2135 + } 2125 2136 break; 2126 2137 2127 2138 case IEEE80211_RADIOTAP_VHT: ··· 5411 5404 { 5412 5405 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 5413 5406 struct ieee80211_local *local = sdata->local; 5407 + struct sta_info *sta; 5414 5408 struct sk_buff *skb; 5415 5409 struct ethhdr *ehdr; 5416 5410 u32 ctrl_flags = 0; ··· 5434 5426 if (cookie) 5435 5427 ctrl_flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; 5436 5428 5437 - flags |= IEEE80211_TX_INTFL_NL80211_FRAME_TX | 5438 - IEEE80211_TX_CTL_INJECTED; 5429 + flags |= IEEE80211_TX_INTFL_NL80211_FRAME_TX; 5439 5430 5440 5431 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 5441 5432 sizeof(struct ethhdr) + len); ··· 5451 5444 ehdr->h_proto = proto; 5452 5445 5453 5446 skb->dev = dev; 5454 - skb->protocol = htons(ETH_P_802_3); 5447 + skb->protocol = proto; 5455 5448 skb_reset_network_header(skb); 5456 5449 skb_reset_mac_header(skb); 5450 + 5451 + /* update QoS header to prioritize control port frames if possible, 5452 + * priorization also happens for control port frames send over 5453 + * AF_PACKET 5454 + */ 5455 + rcu_read_lock(); 5456 + 5457 + if (ieee80211_lookup_ra_sta(sdata, skb, &sta) == 0 && !IS_ERR(sta)) { 5458 + u16 queue = __ieee80211_select_queue(sdata, sta, skb); 5459 + 5460 + skb_set_queue_mapping(skb, queue); 5461 + skb_get_hash(skb); 5462 + } 5463 + 5464 + rcu_read_unlock(); 5457 5465 5458 5466 /* mutex lock is only needed for incrementing the cookie counter */ 5459 5467 mutex_lock(&local->mtx);
+7
net/wireless/nl80211.c
··· 752 752 NL80211_SAE_PWE_BOTH), 753 753 [NL80211_ATTR_RECONNECT_REQUESTED] = { .type = NLA_REJECT }, 754 754 [NL80211_ATTR_SAR_SPEC] = NLA_POLICY_NESTED(sar_policy), 755 + [NL80211_ATTR_DISABLE_HE] = { .type = NLA_FLAG }, 755 756 }; 756 757 757 758 /* policy for the key attributes */ ··· 10020 10019 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_VHT])) 10021 10020 req.flags |= ASSOC_REQ_DISABLE_VHT; 10022 10021 10022 + if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HE])) 10023 + req.flags |= ASSOC_REQ_DISABLE_HE; 10024 + 10023 10025 if (info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]) 10024 10026 memcpy(&req.vht_capa_mask, 10025 10027 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]), ··· 10805 10801 10806 10802 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_VHT])) 10807 10803 connect.flags |= ASSOC_REQ_DISABLE_VHT; 10804 + 10805 + if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HE])) 10806 + connect.flags |= ASSOC_REQ_DISABLE_HE; 10808 10807 10809 10808 if (info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]) 10810 10809 memcpy(&connect.vht_capa_mask,
+1 -1
net/wireless/reg.c
··· 1629 1629 { 1630 1630 const struct ieee80211_regdomain *regd = reg_get_regdomain(wiphy); 1631 1631 static const u32 bws[] = {0, 1, 2, 4, 5, 8, 10, 16, 20}; 1632 - const struct ieee80211_reg_rule *reg_rule; 1632 + const struct ieee80211_reg_rule *reg_rule = ERR_PTR(-ERANGE); 1633 1633 int i = ARRAY_SIZE(bws) - 1; 1634 1634 u32 bw; 1635 1635
-7
net/wireless/sysfs.c
··· 82 82 cfg80211_dev_free(rdev); 83 83 } 84 84 85 - static int wiphy_uevent(struct device *dev, struct kobj_uevent_env *env) 86 - { 87 - /* TODO, we probably need stuff here */ 88 - return 0; 89 - } 90 - 91 85 #ifdef CONFIG_PM_SLEEP 92 86 static void cfg80211_leave_all(struct cfg80211_registered_device *rdev) 93 87 { ··· 156 162 .owner = THIS_MODULE, 157 163 .dev_release = wiphy_dev_release, 158 164 .dev_groups = ieee80211_groups, 159 - .dev_uevent = wiphy_uevent, 160 165 .pm = WIPHY_PM_OPS, 161 166 .ns_type = &net_ns_type_operations, 162 167 .namespace = wiphy_namespace,