320-mac80211-notify-drivers-on-sta-rate-table-changes.patch 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. From: Johannes Berg <johannes.berg@intel.com>
  2. Date: Tue, 18 Nov 2014 23:26:40 +0100
  3. Subject: [PATCH] mac80211: notify drivers on sta rate table changes
  4. This allows drivers with a firmware or chip-based rate lookup table to
  5. use the most recent default rate selection without having to get it from
  6. per-packet data or explicit ieee80211_get_tx_rate calls
  7. Signed-off-by: Felix Fietkau <nbd@openwrt.org>
  8. ---
  9. --- a/include/net/mac80211.h
  10. +++ b/include/net/mac80211.h
  11. @@ -2631,6 +2631,9 @@ enum ieee80211_reconfig_type {
  12. * uses hardware rate control (%IEEE80211_HW_HAS_RATE_CONTROL) since
  13. * otherwise the rate control algorithm is notified directly.
  14. * Must be atomic.
  15. + * @sta_rate_tbl_update: Notifies the driver that the rate table changed. This
  16. + * is only used if the configured rate control algorithm actually uses
  17. + * the new rate table API, and is therefore optional. Must be atomic.
  18. *
  19. * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
  20. * bursting) for a hardware TX queue.
  21. @@ -2972,6 +2975,9 @@ struct ieee80211_ops {
  22. struct ieee80211_vif *vif,
  23. struct ieee80211_sta *sta,
  24. u32 changed);
  25. + void (*sta_rate_tbl_update)(struct ieee80211_hw *hw,
  26. + struct ieee80211_vif *vif,
  27. + struct ieee80211_sta *sta);
  28. int (*conf_tx)(struct ieee80211_hw *hw,
  29. struct ieee80211_vif *vif, u16 ac,
  30. const struct ieee80211_tx_queue_params *params);
  31. --- a/net/mac80211/driver-ops.h
  32. +++ b/net/mac80211/driver-ops.h
  33. @@ -621,6 +621,21 @@ static inline void drv_sta_rc_update(str
  34. trace_drv_return_void(local);
  35. }
  36. +static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
  37. + struct ieee80211_sub_if_data *sdata,
  38. + struct ieee80211_sta *sta)
  39. +{
  40. + sdata = get_bss_sdata(sdata);
  41. + if (!check_sdata_in_driver(sdata))
  42. + return;
  43. +
  44. + trace_drv_sta_rate_tbl_update(local, sdata, sta);
  45. + if (local->ops->sta_rate_tbl_update)
  46. + local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
  47. +
  48. + trace_drv_return_void(local);
  49. +}
  50. +
  51. static inline int drv_conf_tx(struct ieee80211_local *local,
  52. struct ieee80211_sub_if_data *sdata, u16 ac,
  53. const struct ieee80211_tx_queue_params *params)
  54. --- a/net/mac80211/rate.c
  55. +++ b/net/mac80211/rate.c
  56. @@ -696,6 +696,7 @@ int rate_control_set_rates(struct ieee80
  57. struct ieee80211_sta *pubsta,
  58. struct ieee80211_sta_rates *rates)
  59. {
  60. + struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
  61. struct ieee80211_sta_rates *old;
  62. /*
  63. @@ -709,6 +710,8 @@ int rate_control_set_rates(struct ieee80
  64. if (old)
  65. kfree_rcu(old, rcu_head);
  66. + drv_sta_rate_tbl_update(hw_to_local(hw), sta->sdata, pubsta);
  67. +
  68. return 0;
  69. }
  70. EXPORT_SYMBOL(rate_control_set_rates);
  71. --- a/net/mac80211/trace.h
  72. +++ b/net/mac80211/trace.h
  73. @@ -826,6 +826,13 @@ DEFINE_EVENT(sta_event, drv_sta_pre_rcu_
  74. TP_ARGS(local, sdata, sta)
  75. );
  76. +DEFINE_EVENT(sta_event, drv_sta_rate_tbl_update,
  77. + TP_PROTO(struct ieee80211_local *local,
  78. + struct ieee80211_sub_if_data *sdata,
  79. + struct ieee80211_sta *sta),
  80. + TP_ARGS(local, sdata, sta)
  81. +);
  82. +
  83. TRACE_EVENT(drv_conf_tx,
  84. TP_PROTO(struct ieee80211_local *local,
  85. struct ieee80211_sub_if_data *sdata,