906-wlcore-wl12xx-wl18xx-configure-num_links-per-hw.patch 12 KB

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