928c93b2078f42abbe7b8dae02532204381b8b8f
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 306-mac80211-Deinline-rate_control_rate_init-rate_contro.patch
1 From: Denys Vlasenko <dvlasenk@redhat.com>
2 Date: Wed, 15 Jul 2015 14:56:06 +0200
3 Subject: [PATCH] mac80211: Deinline rate_control_rate_init,
4 rate_control_rate_update
5
6 With this .config: http://busybox.net/~vda/kernel_config,
7 after deinlining these functions have sizes and callsite counts
8 as follows:
9
10 rate_control_rate_init: 554 bytes, 8 calls
11 rate_control_rate_update: 1596 bytes, 5 calls
12
13 Total size reduction: about 11 kbytes.
14
15 Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
16 CC: John Linville <linville@tuxdriver.com>
17 CC: Michal Kazior <michal.kazior@tieto.com>
18 CC: Johannes Berg <johannes.berg@intel.com>
19 Cc: linux-wireless@vger.kernel.org
20 Cc: netdev@vger.kernel.org
21 CC: linux-kernel@vger.kernel.org
22 ---
23
24 --- a/net/mac80211/rate.c
25 +++ b/net/mac80211/rate.c
26 @@ -29,6 +29,65 @@ module_param(ieee80211_default_rc_algo,
27 MODULE_PARM_DESC(ieee80211_default_rc_algo,
28 "Default rate control algorithm for mac80211 to use");
29
30 +void rate_control_rate_init(struct sta_info *sta)
31 +{
32 + struct ieee80211_local *local = sta->sdata->local;
33 + struct rate_control_ref *ref = sta->rate_ctrl;
34 + struct ieee80211_sta *ista = &sta->sta;
35 + void *priv_sta = sta->rate_ctrl_priv;
36 + struct ieee80211_supported_band *sband;
37 + struct ieee80211_chanctx_conf *chanctx_conf;
38 +
39 + ieee80211_sta_set_rx_nss(sta);
40 +
41 + if (!ref)
42 + return;
43 +
44 + rcu_read_lock();
45 +
46 + chanctx_conf = rcu_dereference(sta->sdata->vif.chanctx_conf);
47 + if (WARN_ON(!chanctx_conf)) {
48 + rcu_read_unlock();
49 + return;
50 + }
51 +
52 + sband = local->hw.wiphy->bands[chanctx_conf->def.chan->band];
53 +
54 + spin_lock_bh(&sta->rate_ctrl_lock);
55 + ref->ops->rate_init(ref->priv, sband, &chanctx_conf->def, ista,
56 + priv_sta);
57 + spin_unlock_bh(&sta->rate_ctrl_lock);
58 + rcu_read_unlock();
59 + set_sta_flag(sta, WLAN_STA_RATE_CONTROL);
60 +}
61 +
62 +void rate_control_rate_update(struct ieee80211_local *local,
63 + struct ieee80211_supported_band *sband,
64 + struct sta_info *sta, u32 changed)
65 +{
66 + struct rate_control_ref *ref = local->rate_ctrl;
67 + struct ieee80211_sta *ista = &sta->sta;
68 + void *priv_sta = sta->rate_ctrl_priv;
69 + struct ieee80211_chanctx_conf *chanctx_conf;
70 +
71 + if (ref && ref->ops->rate_update) {
72 + rcu_read_lock();
73 +
74 + chanctx_conf = rcu_dereference(sta->sdata->vif.chanctx_conf);
75 + if (WARN_ON(!chanctx_conf)) {
76 + rcu_read_unlock();
77 + return;
78 + }
79 +
80 + spin_lock_bh(&sta->rate_ctrl_lock);
81 + ref->ops->rate_update(ref->priv, sband, &chanctx_conf->def,
82 + ista, priv_sta, changed);
83 + spin_unlock_bh(&sta->rate_ctrl_lock);
84 + rcu_read_unlock();
85 + }
86 + drv_sta_rc_update(local, sta->sdata, &sta->sta, changed);
87 +}
88 +
89 int ieee80211_rate_control_register(const struct rate_control_ops *ops)
90 {
91 struct rate_control_alg *alg;
92 --- a/net/mac80211/rate.h
93 +++ b/net/mac80211/rate.h
94 @@ -71,64 +71,10 @@ rate_control_tx_status_noskb(struct ieee
95 spin_unlock_bh(&sta->rate_ctrl_lock);
96 }
97
98 -static inline void rate_control_rate_init(struct sta_info *sta)
99 -{
100 - struct ieee80211_local *local = sta->sdata->local;
101 - struct rate_control_ref *ref = sta->rate_ctrl;
102 - struct ieee80211_sta *ista = &sta->sta;
103 - void *priv_sta = sta->rate_ctrl_priv;
104 - struct ieee80211_supported_band *sband;
105 - struct ieee80211_chanctx_conf *chanctx_conf;
106 -
107 - ieee80211_sta_set_rx_nss(sta);
108 -
109 - if (!ref)
110 - return;
111 -
112 - rcu_read_lock();
113 -
114 - chanctx_conf = rcu_dereference(sta->sdata->vif.chanctx_conf);
115 - if (WARN_ON(!chanctx_conf)) {
116 - rcu_read_unlock();
117 - return;
118 - }
119 -
120 - sband = local->hw.wiphy->bands[chanctx_conf->def.chan->band];
121 -
122 - spin_lock_bh(&sta->rate_ctrl_lock);
123 - ref->ops->rate_init(ref->priv, sband, &chanctx_conf->def, ista,
124 - priv_sta);
125 - spin_unlock_bh(&sta->rate_ctrl_lock);
126 - rcu_read_unlock();
127 - set_sta_flag(sta, WLAN_STA_RATE_CONTROL);
128 -}
129 -
130 -static inline void rate_control_rate_update(struct ieee80211_local *local,
131 +void rate_control_rate_init(struct sta_info *sta);
132 +void rate_control_rate_update(struct ieee80211_local *local,
133 struct ieee80211_supported_band *sband,
134 - struct sta_info *sta, u32 changed)
135 -{
136 - struct rate_control_ref *ref = local->rate_ctrl;
137 - struct ieee80211_sta *ista = &sta->sta;
138 - void *priv_sta = sta->rate_ctrl_priv;
139 - struct ieee80211_chanctx_conf *chanctx_conf;
140 -
141 - if (ref && ref->ops->rate_update) {
142 - rcu_read_lock();
143 -
144 - chanctx_conf = rcu_dereference(sta->sdata->vif.chanctx_conf);
145 - if (WARN_ON(!chanctx_conf)) {
146 - rcu_read_unlock();
147 - return;
148 - }
149 -
150 - spin_lock_bh(&sta->rate_ctrl_lock);
151 - ref->ops->rate_update(ref->priv, sband, &chanctx_conf->def,
152 - ista, priv_sta, changed);
153 - spin_unlock_bh(&sta->rate_ctrl_lock);
154 - rcu_read_unlock();
155 - }
156 - drv_sta_rc_update(local, sta->sdata, &sta->sta, changed);
157 -}
158 + struct sta_info *sta, u32 changed);
159
160 static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
161 struct sta_info *sta, gfp_t gfp)