540-mac80211_optimize_mcs_rate_mask.patch 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. --- a/net/mac80211/ieee80211_i.h
  2. +++ b/net/mac80211/ieee80211_i.h
  3. @@ -739,6 +739,8 @@ struct ieee80211_sub_if_data {
  4. /* bitmap of allowed (non-MCS) rate indexes for rate control */
  5. u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
  6. +
  7. + bool rc_has_mcs_mask[IEEE80211_NUM_BANDS];
  8. u8 rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
  9. union {
  10. --- a/net/mac80211/cfg.c
  11. +++ b/net/mac80211/cfg.c
  12. @@ -2386,9 +2386,20 @@ static int ieee80211_set_bitrate_mask(st
  13. }
  14. for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
  15. + struct ieee80211_supported_band *sband = wiphy->bands[i];
  16. +
  17. sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
  18. memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs,
  19. sizeof(mask->control[i].mcs));
  20. +
  21. + sdata->rc_has_mcs_mask[i] = false;
  22. + if (!sband)
  23. + continue;
  24. +
  25. + if (memcmp(sdata->rc_rateidx_mcs_mask[i],
  26. + sband->ht_cap.mcs.rx_mask,
  27. + sizeof(sband->ht_cap.mcs.rx_mask)) != 0)
  28. + sdata->rc_has_mcs_mask[i] = true;
  29. }
  30. return 0;
  31. --- a/include/net/mac80211.h
  32. +++ b/include/net/mac80211.h
  33. @@ -4091,7 +4091,7 @@ void ieee80211_send_bar(struct ieee80211
  34. * (deprecated; this will be removed once drivers get updated to use
  35. * rate_idx_mask)
  36. * @rate_idx_mask: user-requested (legacy) rate mask
  37. - * @rate_idx_mcs_mask: user-requested MCS rate mask
  38. + * @rate_idx_mcs_mask: user-requested MCS rate mask (NULL if not in use)
  39. * @bss: whether this frame is sent out in AP or IBSS mode
  40. */
  41. struct ieee80211_tx_rate_control {
  42. @@ -4103,7 +4103,7 @@ struct ieee80211_tx_rate_control {
  43. bool rts, short_preamble;
  44. u8 max_rate_idx;
  45. u32 rate_idx_mask;
  46. - u8 rate_idx_mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
  47. + u8 *rate_idx_mcs_mask;
  48. bool bss;
  49. };
  50. --- a/net/mac80211/tx.c
  51. +++ b/net/mac80211/tx.c
  52. @@ -641,9 +641,11 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
  53. txrc.max_rate_idx = -1;
  54. else
  55. txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
  56. - memcpy(txrc.rate_idx_mcs_mask,
  57. - tx->sdata->rc_rateidx_mcs_mask[info->band],
  58. - sizeof(txrc.rate_idx_mcs_mask));
  59. +
  60. + if (tx->sdata->rc_has_mcs_mask[info->band])
  61. + txrc.rate_idx_mcs_mask =
  62. + tx->sdata->rc_rateidx_mcs_mask[info->band];
  63. +
  64. txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP ||
  65. tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
  66. tx->sdata->vif.type == NL80211_IFTYPE_ADHOC);
  67. @@ -2505,8 +2507,6 @@ struct sk_buff *ieee80211_beacon_get_tim
  68. txrc.max_rate_idx = -1;
  69. else
  70. txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
  71. - memcpy(txrc.rate_idx_mcs_mask, sdata->rc_rateidx_mcs_mask[band],
  72. - sizeof(txrc.rate_idx_mcs_mask));
  73. txrc.bss = true;
  74. rate_control_get_rate(sdata, NULL, &txrc);
  75. --- a/net/mac80211/rate.c
  76. +++ b/net/mac80211/rate.c
  77. @@ -460,9 +460,12 @@ void rate_control_get_rate(struct ieee80
  78. * the common case.
  79. */
  80. mask = sdata->rc_rateidx_mask[info->band];
  81. - memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band],
  82. - sizeof(mcs_mask));
  83. - if (mask != (1 << txrc->sband->n_bitrates) - 1) {
  84. + if (mask != (1 << txrc->sband->n_bitrates) - 1 || txrc->rate_idx_mcs_mask) {
  85. + if (txrc->rate_idx_mcs_mask)
  86. + memcpy(mcs_mask, txrc->rate_idx_mcs_mask, sizeof(mcs_mask));
  87. + else
  88. + memset(mcs_mask, 0xff, sizeof(mcs_mask));
  89. +
  90. if (sta) {
  91. /* Filter out rates that the STA does not support */
  92. mask &= sta->sta.supp_rates[info->band];