lantiq: remove unmaintained code
[openwrt/staging/yousong.git] / package / kernel / mac80211 / patches / 906-wlcore-wl12xx-wl18xx-configure-num_links-per-hw.patch
1 Upcoming fw versions will have different max links support
2 (according to the hw). Get ready for it by configuring
3 wl->num_links per-hw, instead of using the const WL12XX_MAX_LINKS.
4
5 However, continue using WLCORE_MAX_LINKS in order to simplify
6 structs declarations (we use it in multiple bitmaps, and converting
7 them to dynamic arrays is just cumbersome).
8
9 Signed-off-by: Eliad Peller <eliad@wizery.com>
10
11 ---
12 drivers/net/wireless/ti/wl12xx/main.c | 3 +++
13 drivers/net/wireless/ti/wl12xx/wl12xx.h | 2 ++
14 drivers/net/wireless/ti/wl18xx/main.c | 3 +++
15 drivers/net/wireless/ti/wl18xx/wl18xx.h | 4 +++-
16 drivers/net/wireless/ti/wlcore/cmd.c | 4 ++--
17 drivers/net/wireless/ti/wlcore/event.c | 4 ++--
18 drivers/net/wireless/ti/wlcore/main.c | 12 ++++++++----
19 drivers/net/wireless/ti/wlcore/rx.c | 8 ++++----
20 drivers/net/wireless/ti/wlcore/tx.c | 20 ++++++++++----------
21 drivers/net/wireless/ti/wlcore/wlcore.h | 8 +++++---
22 drivers/net/wireless/ti/wlcore/wlcore_i.h | 13 +++++++++----
23 11 files changed, 51 insertions(+), 30 deletions(-)
24
25 --- a/drivers/net/wireless/ti/wl12xx/main.c
26 +++ b/drivers/net/wireless/ti/wl12xx/main.c
27 @@ -1749,9 +1749,12 @@ static int wl12xx_setup(struct wl1271 *w
28 struct wlcore_platdev_data *pdev_data = dev_get_platdata(&wl->pdev->dev);
29 struct wl12xx_platform_data *pdata = pdev_data->pdata;
30
31 + BUILD_BUG_ON(WL12XX_MAX_LINKS > WLCORE_MAX_LINKS);
32 +
33 wl->rtable = wl12xx_rtable;
34 wl->num_tx_desc = WL12XX_NUM_TX_DESCRIPTORS;
35 wl->num_rx_desc = WL12XX_NUM_RX_DESCRIPTORS;
36 + wl->num_links = WL12XX_MAX_LINKS;
37 wl->num_channels = 1;
38 wl->num_mac_addr = WL12XX_NUM_MAC_ADDRESSES;
39 wl->band_rate_to_idx = wl12xx_band_rate_to_idx;
40 --- a/drivers/net/wireless/ti/wl12xx/wl12xx.h
41 +++ b/drivers/net/wireless/ti/wl12xx/wl12xx.h
42 @@ -65,6 +65,8 @@
43
44 #define WL12XX_RX_BA_MAX_SESSIONS 3
45
46 +#define WL12XX_MAX_LINKS 12
47 +
48 struct wl127x_rx_mem_pool_addr {
49 u32 addr;
50 u32 addr_extra;
51 --- a/drivers/net/wireless/ti/wl18xx/main.c
52 +++ b/drivers/net/wireless/ti/wl18xx/main.c
53 @@ -1752,9 +1752,12 @@ static int wl18xx_setup(struct wl1271 *w
54 struct wl18xx_priv *priv = wl->priv;
55 int ret;
56
57 + BUILD_BUG_ON(WL18XX_MAX_LINKS > WLCORE_MAX_LINKS);
58 +
59 wl->rtable = wl18xx_rtable;
60 wl->num_tx_desc = WL18XX_NUM_TX_DESCRIPTORS;
61 wl->num_rx_desc = WL18XX_NUM_RX_DESCRIPTORS;
62 + wl->num_links = WL18XX_MAX_LINKS;
63 wl->num_channels = 2;
64 wl->num_mac_addr = WL18XX_NUM_MAC_ADDRESSES;
65 wl->band_rate_to_idx = wl18xx_band_rate_to_idx;
66 --- a/drivers/net/wireless/ti/wl18xx/wl18xx.h
67 +++ b/drivers/net/wireless/ti/wl18xx/wl18xx.h
68 @@ -42,6 +42,8 @@
69
70 #define WL18XX_RX_BA_MAX_SESSIONS 5
71
72 +#define WL18XX_MAX_LINKS 12
73 +
74 struct wl18xx_priv {
75 /* buffer for sending commands to FW */
76 u8 cmd_buf[WL18XX_CMD_MAX_SIZE];
77 @@ -114,7 +116,7 @@ struct wl18xx_fw_packet_counters {
78 u8 tx_released_pkts[NUM_TX_QUEUES];
79
80 /* Cumulative counter of freed packets per HLID */
81 - u8 tx_lnk_free_pkts[WL12XX_MAX_LINKS];
82 + u8 tx_lnk_free_pkts[WL18XX_MAX_LINKS];
83
84 /* Cumulative counter of released Voice memory blocks */
85 u8 tx_voice_released_blks;
86 --- a/drivers/net/wireless/ti/wlcore/cmd.c
87 +++ b/drivers/net/wireless/ti/wlcore/cmd.c
88 @@ -312,8 +312,8 @@ static int wlcore_get_new_session_id(str
89 int wl12xx_allocate_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid)
90 {
91 unsigned long flags;
92 - u8 link = find_first_zero_bit(wl->links_map, WL12XX_MAX_LINKS);
93 - if (link >= WL12XX_MAX_LINKS)
94 + u8 link = find_first_zero_bit(wl->links_map, wl->num_links);
95 + if (link >= wl->num_links)
96 return -EBUSY;
97
98 wl->session_ids[link] = wlcore_get_new_session_id(wl, link);
99 --- a/drivers/net/wireless/ti/wlcore/event.c
100 +++ b/drivers/net/wireless/ti/wlcore/event.c
101 @@ -68,7 +68,7 @@ static void wl1271_stop_ba_event(struct
102 u8 hlid;
103 struct wl1271_link *lnk;
104 for_each_set_bit(hlid, wlvif->ap.sta_hlid_map,
105 - WL12XX_MAX_LINKS) {
106 + wl->num_links) {
107 lnk = &wl->links[hlid];
108 if (!lnk->ba_bitmap)
109 continue;
110 @@ -173,7 +173,7 @@ static void wlcore_disconnect_sta(struct
111 const u8 *addr;
112 int h;
113
114 - for_each_set_bit(h, &sta_bitmap, WL12XX_MAX_LINKS) {
115 + for_each_set_bit(h, &sta_bitmap, wl->num_links) {
116 bool found = false;
117 /* find the ap vif connected to this sta */
118 wl12xx_for_each_wlvif_ap(wl, wlvif) {
119 --- a/drivers/net/wireless/ti/wlcore/main.c
120 +++ b/drivers/net/wireless/ti/wlcore/main.c
121 @@ -372,7 +372,7 @@ static void wl12xx_irq_update_links_stat
122 wl->ap_fw_ps_map = cur_fw_ps_map;
123 }
124
125 - for_each_set_bit(hlid, wlvif->ap.sta_hlid_map, WL12XX_MAX_LINKS)
126 + for_each_set_bit(hlid, wlvif->ap.sta_hlid_map, wl->num_links)
127 wl12xx_irq_ps_regulate_link(wl, wlvif, hlid,
128 wl->links[hlid].allocated_pkts);
129 }
130 @@ -412,7 +412,7 @@ static int wlcore_fw_status(struct wl127
131 }
132
133
134 - for_each_set_bit(i, wl->links_map, WL12XX_MAX_LINKS) {
135 + for_each_set_bit(i, wl->links_map, wl->num_links) {
136 u8 diff;
137 lnk = &wl->links[i];
138
139 @@ -5888,7 +5888,7 @@ struct ieee80211_hw *wlcore_alloc_hw(siz
140 int i, j, ret;
141 unsigned int order;
142
143 - BUILD_BUG_ON(AP_MAX_STATIONS > WL12XX_MAX_LINKS);
144 + BUILD_BUG_ON(AP_MAX_STATIONS > WLCORE_MAX_LINKS);
145
146 hw = ieee80211_alloc_hw(sizeof(*wl), &wl1271_ops);
147 if (!hw) {
148 @@ -5911,8 +5911,12 @@ struct ieee80211_hw *wlcore_alloc_hw(siz
149
150 wl->hw = hw;
151
152 + /*
153 + * wl->num_links is not configured yet, so just use WLCORE_MAX_LINKS.
154 + * we don't allocate any additional resource here, so that's fine.
155 + */
156 for (i = 0; i < NUM_TX_QUEUES; i++)
157 - for (j = 0; j < WL12XX_MAX_LINKS; j++)
158 + for (j = 0; j < WLCORE_MAX_LINKS; j++)
159 skb_queue_head_init(&wl->links[j].tx_queue[i]);
160
161 skb_queue_head_init(&wl->deferred_rx_queue);
162 --- a/drivers/net/wireless/ti/wlcore/rx.c
163 +++ b/drivers/net/wireless/ti/wlcore/rx.c
164 @@ -205,7 +205,7 @@ static int wl1271_rx_handle_data(struct
165
166 int wlcore_rx(struct wl1271 *wl, struct wl_fw_status *status)
167 {
168 - unsigned long active_hlids[BITS_TO_LONGS(WL12XX_MAX_LINKS)] = {0};
169 + unsigned long active_hlids[BITS_TO_LONGS(WLCORE_MAX_LINKS)] = {0};
170 u32 buf_size;
171 u32 fw_rx_counter = status->fw_rx_counter % wl->num_rx_desc;
172 u32 drv_rx_counter = wl->rx_counter % wl->num_rx_desc;
173 @@ -263,12 +263,12 @@ int wlcore_rx(struct wl1271 *wl, struct
174 wl->aggr_buf + pkt_offset,
175 pkt_len, rx_align,
176 &hlid) == 1) {
177 - if (hlid < WL12XX_MAX_LINKS)
178 + if (hlid < wl->num_links)
179 __set_bit(hlid, active_hlids);
180 else
181 WARN(1,
182 - "hlid exceeded WL12XX_MAX_LINKS "
183 - "(%d)\n", hlid);
184 + "hlid (%d) exceeded MAX_LINKS\n",
185 + hlid);
186 }
187
188 wl->rx_counter++;
189 --- a/drivers/net/wireless/ti/wlcore/tx.c
190 +++ b/drivers/net/wireless/ti/wlcore/tx.c
191 @@ -565,11 +565,11 @@ static struct sk_buff *wlcore_vif_dequeu
192 int i, h, start_hlid;
193
194 /* start from the link after the last one */
195 - start_hlid = (wlvif->last_tx_hlid + 1) % WL12XX_MAX_LINKS;
196 + start_hlid = (wlvif->last_tx_hlid + 1) % wl->num_links;
197
198 /* dequeue according to AC, round robin on each link */
199 - for (i = 0; i < WL12XX_MAX_LINKS; i++) {
200 - h = (start_hlid + i) % WL12XX_MAX_LINKS;
201 + for (i = 0; i < wl->num_links; i++) {
202 + h = (start_hlid + i) % wl->num_links;
203
204 /* only consider connected stations */
205 if (!test_bit(h, wlvif->links_map))
206 @@ -693,8 +693,8 @@ static void wl1271_skb_queue_head(struct
207 skb_queue_head(&wl->links[hlid].tx_queue[q], skb);
208
209 /* make sure we dequeue the same packet next time */
210 - wlvif->last_tx_hlid = (hlid + WL12XX_MAX_LINKS - 1) %
211 - WL12XX_MAX_LINKS;
212 + wlvif->last_tx_hlid = (hlid + wl->num_links - 1) %
213 + wl->num_links;
214 }
215
216 spin_lock_irqsave(&wl->wl_lock, flags);
217 @@ -727,7 +727,7 @@ void wl12xx_rearm_rx_streaming(struct wl
218 timeout = wl->conf.rx_streaming.duration;
219 wl12xx_for_each_wlvif_sta(wl, wlvif) {
220 bool found = false;
221 - for_each_set_bit(hlid, active_hlids, WL12XX_MAX_LINKS) {
222 + for_each_set_bit(hlid, active_hlids, wl->num_links) {
223 if (test_bit(hlid, wlvif->links_map)) {
224 found = true;
225 break;
226 @@ -764,7 +764,7 @@ int wlcore_tx_work_locked(struct wl1271
227 struct wl1271_tx_hw_descr *desc;
228 u32 buf_offset = 0, last_len = 0;
229 bool sent_packets = false;
230 - unsigned long active_hlids[BITS_TO_LONGS(WL12XX_MAX_LINKS)] = {0};
231 + unsigned long active_hlids[BITS_TO_LONGS(WLCORE_MAX_LINKS)] = {0};
232 int ret = 0;
233 int bus_ret = 0;
234 u8 hlid;
235 @@ -1066,7 +1066,7 @@ void wl12xx_tx_reset_wlvif(struct wl1271
236 int i;
237
238 /* TX failure */
239 - for_each_set_bit(i, wlvif->links_map, WL12XX_MAX_LINKS) {
240 + for_each_set_bit(i, wlvif->links_map, wl->num_links) {
241 if (wlvif->bss_type == BSS_TYPE_AP_BSS &&
242 i != wlvif->ap.bcast_hlid && i != wlvif->ap.global_hlid) {
243 /* this calls wl12xx_free_link */
244 @@ -1090,7 +1090,7 @@ void wl12xx_tx_reset(struct wl1271 *wl)
245
246 /* only reset the queues if something bad happened */
247 if (wl1271_tx_total_queue_count(wl) != 0) {
248 - for (i = 0; i < WL12XX_MAX_LINKS; i++)
249 + for (i = 0; i < wl->num_links; i++)
250 wl1271_tx_reset_link_queues(wl, i);
251
252 for (i = 0; i < NUM_TX_QUEUES; i++)
253 @@ -1183,7 +1183,7 @@ void wl1271_tx_flush(struct wl1271 *wl)
254 WL1271_TX_FLUSH_TIMEOUT / 1000);
255
256 /* forcibly flush all Tx buffers on our queues */
257 - for (i = 0; i < WL12XX_MAX_LINKS; i++)
258 + for (i = 0; i < wl->num_links; i++)
259 wl1271_tx_reset_link_queues(wl, i);
260
261 out_wake:
262 --- a/drivers/net/wireless/ti/wlcore/wlcore.h
263 +++ b/drivers/net/wireless/ti/wlcore/wlcore.h
264 @@ -224,7 +224,7 @@ struct wl1271 {
265 int channel;
266 u8 system_hlid;
267
268 - unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)];
269 + unsigned long links_map[BITS_TO_LONGS(WLCORE_MAX_LINKS)];
270 unsigned long roles_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)];
271 unsigned long roc_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)];
272 unsigned long rate_policies_map[
273 @@ -232,7 +232,7 @@ struct wl1271 {
274 unsigned long klv_templates_map[
275 BITS_TO_LONGS(WLCORE_MAX_KLV_TEMPLATES)];
276
277 - u8 session_ids[WL12XX_MAX_LINKS];
278 + u8 session_ids[WLCORE_MAX_LINKS];
279
280 struct list_head wlvif_list;
281
282 @@ -380,7 +380,7 @@ struct wl1271 {
283 * AP-mode - links indexed by HLID. The global and broadcast links
284 * are always active.
285 */
286 - struct wl1271_link links[WL12XX_MAX_LINKS];
287 + struct wl1271_link links[WLCORE_MAX_LINKS];
288
289 /* number of currently active links */
290 int active_link_count;
291 @@ -438,6 +438,8 @@ struct wl1271 {
292 u32 num_tx_desc;
293 /* number of RX descriptors the HW supports. */
294 u32 num_rx_desc;
295 + /* number of links the HW supports */
296 + u8 num_links;
297
298 /* translate HW Tx rates to standard rate-indices */
299 const u8 **band_rate_to_idx;
300 --- a/drivers/net/wireless/ti/wlcore/wlcore_i.h
301 +++ b/drivers/net/wireless/ti/wlcore/wlcore_i.h
302 @@ -58,10 +58,15 @@
303 #define WL1271_DEFAULT_DTIM_PERIOD 1
304
305 #define WL12XX_MAX_ROLES 4
306 -#define WL12XX_MAX_LINKS 12
307 #define WL12XX_INVALID_ROLE_ID 0xff
308 #define WL12XX_INVALID_LINK_ID 0xff
309
310 +/*
311 + * max number of links allowed by all HWs.
312 + * this is NOT the actual max links supported by the current hw.
313 + */
314 +#define WLCORE_MAX_LINKS 12
315 +
316 /* the driver supports the 2.4Ghz and 5Ghz bands */
317 #define WLCORE_NUM_BANDS 2
318
319 @@ -156,7 +161,7 @@ struct wl_fw_status {
320
321 /*
322 * Cumulative counter of freed packets per HLID
323 - * (length of the array is WL12XX_MAX_LINKS)
324 + * (length of the array is wl->num_links)
325 */
326 u8 *tx_lnk_free_pkts;
327
328 @@ -357,7 +362,7 @@ struct wl12xx_vif {
329
330 /* HLIDs bitmap of associated stations */
331 unsigned long sta_hlid_map[BITS_TO_LONGS(
332 - WL12XX_MAX_LINKS)];
333 + WLCORE_MAX_LINKS)];
334
335 /* recoreded keys - set here before AP startup */
336 struct wl1271_ap_key *recorded_keys[MAX_NUM_KEYS];
337 @@ -374,7 +379,7 @@ struct wl12xx_vif {
338 /* counters of packets per AC, across all links in the vif */
339 int tx_queue_count[NUM_TX_QUEUES];
340
341 - unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)];
342 + unsigned long links_map[BITS_TO_LONGS(WLCORE_MAX_LINKS)];
343
344 u8 ssid[IEEE80211_MAX_SSID_LEN + 1];
345 u8 ssid_len;