acx.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. /*
  2. * This file is part of wl18xx
  3. *
  4. * Copyright (C) 2011 Texas Instruments Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  18. * 02110-1301 USA
  19. *
  20. */
  21. #include "../wlcore/cmd.h"
  22. #include "../wlcore/debug.h"
  23. #include "../wlcore/acx.h"
  24. #include "acx.h"
  25. #include "wl18xx.h"
  26. int wl18xx_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap,
  27. u32 sdio_blk_size, u32 extra_mem_blks,
  28. u32 len_field_size)
  29. {
  30. struct wl18xx_acx_host_config_bitmap *bitmap_conf;
  31. int ret;
  32. wl1271_debug(DEBUG_ACX, "acx cfg bitmap %d blk %d spare %d field %d",
  33. host_cfg_bitmap, sdio_blk_size, extra_mem_blks,
  34. len_field_size);
  35. bitmap_conf = kzalloc(sizeof(*bitmap_conf), GFP_KERNEL);
  36. if (!bitmap_conf) {
  37. ret = -ENOMEM;
  38. goto out;
  39. }
  40. bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap);
  41. bitmap_conf->host_sdio_block_size = cpu_to_le32(sdio_blk_size);
  42. bitmap_conf->extra_mem_blocks = cpu_to_le32(extra_mem_blks);
  43. bitmap_conf->length_field_size = cpu_to_le32(len_field_size);
  44. ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP,
  45. bitmap_conf, sizeof(*bitmap_conf));
  46. if (ret < 0) {
  47. wl1271_warning("wl1271 bitmap config opt failed: %d", ret);
  48. goto out;
  49. }
  50. out:
  51. kfree(bitmap_conf);
  52. return ret;
  53. }
  54. int wl18xx_acx_set_checksum_state(struct wl1271 *wl)
  55. {
  56. struct wl18xx_acx_checksum_state *acx;
  57. int ret;
  58. wl1271_debug(DEBUG_ACX, "acx checksum state");
  59. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  60. if (!acx) {
  61. ret = -ENOMEM;
  62. goto out;
  63. }
  64. acx->checksum_state = CHECKSUM_OFFLOAD_ENABLED;
  65. ret = wl1271_cmd_configure(wl, ACX_CSUM_CONFIG, acx, sizeof(*acx));
  66. if (ret < 0) {
  67. wl1271_warning("failed to set Tx checksum state: %d", ret);
  68. goto out;
  69. }
  70. out:
  71. kfree(acx);
  72. return ret;
  73. }
  74. int wl18xx_acx_clear_statistics(struct wl1271 *wl)
  75. {
  76. struct wl18xx_acx_clear_statistics *acx;
  77. int ret = 0;
  78. wl1271_debug(DEBUG_ACX, "acx clear statistics");
  79. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  80. if (!acx) {
  81. ret = -ENOMEM;
  82. goto out;
  83. }
  84. ret = wl1271_cmd_configure(wl, ACX_CLEAR_STATISTICS, acx, sizeof(*acx));
  85. if (ret < 0) {
  86. wl1271_warning("failed to clear firmware statistics: %d", ret);
  87. goto out;
  88. }
  89. out:
  90. kfree(acx);
  91. return ret;
  92. }
  93. int wl18xx_acx_peer_ht_operation_mode(struct wl1271 *wl, u8 hlid, bool wide)
  94. {
  95. struct wlcore_peer_ht_operation_mode *acx;
  96. int ret;
  97. wl1271_debug(DEBUG_ACX, "acx peer ht operation mode hlid %d bw %d",
  98. hlid, wide);
  99. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  100. if (!acx) {
  101. ret = -ENOMEM;
  102. goto out;
  103. }
  104. acx->hlid = hlid;
  105. acx->bandwidth = wide ? WLCORE_BANDWIDTH_40MHZ : WLCORE_BANDWIDTH_20MHZ;
  106. ret = wl1271_cmd_configure(wl, ACX_PEER_HT_OPERATION_MODE_CFG, acx,
  107. sizeof(*acx));
  108. if (ret < 0) {
  109. wl1271_warning("acx peer ht operation mode failed: %d", ret);
  110. goto out;
  111. }
  112. out:
  113. kfree(acx);
  114. return ret;
  115. }
  116. /*
  117. * this command is basically the same as wl1271_acx_ht_capabilities,
  118. * with the addition of supported rates. they should be unified in
  119. * the next fw api change
  120. */
  121. int wl18xx_acx_set_peer_cap(struct wl1271 *wl,
  122. struct ieee80211_sta_ht_cap *ht_cap,
  123. bool allow_ht_operation,
  124. u32 rate_set, u8 hlid)
  125. {
  126. struct wlcore_acx_peer_cap *acx;
  127. int ret = 0;
  128. u32 ht_capabilites = 0;
  129. wl1271_debug(DEBUG_ACX,
  130. "acx set cap ht_supp: %d ht_cap: %d rates: 0x%x",
  131. ht_cap->ht_supported, ht_cap->cap, rate_set);
  132. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  133. if (!acx) {
  134. ret = -ENOMEM;
  135. goto out;
  136. }
  137. if (allow_ht_operation && ht_cap->ht_supported) {
  138. /* no need to translate capabilities - use the spec values */
  139. ht_capabilites = ht_cap->cap;
  140. /*
  141. * this bit is not employed by the spec but only by FW to
  142. * indicate peer HT support
  143. */
  144. ht_capabilites |= WL12XX_HT_CAP_HT_OPERATION;
  145. /* get data from A-MPDU parameters field */
  146. acx->ampdu_max_length = ht_cap->ampdu_factor;
  147. acx->ampdu_min_spacing = ht_cap->ampdu_density;
  148. }
  149. acx->hlid = hlid;
  150. acx->ht_capabilites = cpu_to_le32(ht_capabilites);
  151. acx->supported_rates = cpu_to_le32(rate_set);
  152. ret = wl1271_cmd_configure(wl, ACX_PEER_CAP, acx, sizeof(*acx));
  153. if (ret < 0) {
  154. wl1271_warning("acx ht capabilities setting failed: %d", ret);
  155. goto out;
  156. }
  157. out:
  158. kfree(acx);
  159. return ret;
  160. }
  161. /*
  162. * When the host is suspended, we don't want to get any fast-link/PSM
  163. * notifications
  164. */
  165. int wl18xx_acx_interrupt_notify_config(struct wl1271 *wl,
  166. bool action)
  167. {
  168. struct wl18xx_acx_interrupt_notify *acx;
  169. int ret = 0;
  170. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  171. if (!acx) {
  172. ret = -ENOMEM;
  173. goto out;
  174. }
  175. acx->enable = action;
  176. ret = wl1271_cmd_configure(wl, ACX_INTERRUPT_NOTIFY, acx, sizeof(*acx));
  177. if (ret < 0) {
  178. wl1271_warning("acx interrupt notify setting failed: %d", ret);
  179. goto out;
  180. }
  181. out:
  182. kfree(acx);
  183. return ret;
  184. }
  185. /*
  186. * When the host is suspended, we can configure the FW to disable RX BA
  187. * notifications.
  188. */
  189. int wl18xx_acx_rx_ba_filter(struct wl1271 *wl, bool action)
  190. {
  191. struct wl18xx_acx_rx_ba_filter *acx;
  192. int ret = 0;
  193. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  194. if (!acx) {
  195. ret = -ENOMEM;
  196. goto out;
  197. }
  198. acx->enable = (u32)action;
  199. ret = wl1271_cmd_configure(wl, ACX_RX_BA_FILTER, acx, sizeof(*acx));
  200. if (ret < 0) {
  201. wl1271_warning("acx rx ba activity filter setting failed: %d",
  202. ret);
  203. goto out;
  204. }
  205. out:
  206. kfree(acx);
  207. return ret;
  208. }
  209. int wl18xx_acx_ap_sleep(struct wl1271 *wl)
  210. {
  211. struct wl18xx_priv *priv = wl->priv;
  212. struct acx_ap_sleep_cfg *acx;
  213. struct conf_ap_sleep_settings *conf = &priv->conf.ap_sleep;
  214. int ret;
  215. wl1271_debug(DEBUG_ACX, "acx config ap sleep");
  216. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  217. if (!acx) {
  218. ret = -ENOMEM;
  219. goto out;
  220. }
  221. acx->idle_duty_cycle = conf->idle_duty_cycle;
  222. acx->connected_duty_cycle = conf->connected_duty_cycle;
  223. acx->max_stations_thresh = conf->max_stations_thresh;
  224. acx->idle_conn_thresh = conf->idle_conn_thresh;
  225. ret = wl1271_cmd_configure(wl, ACX_AP_SLEEP_CFG, acx, sizeof(*acx));
  226. if (ret < 0) {
  227. wl1271_warning("acx config ap-sleep failed: %d", ret);
  228. goto out;
  229. }
  230. out:
  231. kfree(acx);
  232. return ret;
  233. }
  234. int wl18xx_acx_dynamic_fw_traces(struct wl1271 *wl)
  235. {
  236. struct acx_dynamic_fw_traces_cfg *acx;
  237. int ret;
  238. wl1271_debug(DEBUG_ACX, "acx dynamic fw traces config %d",
  239. wl->dynamic_fw_traces);
  240. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  241. if (!acx) {
  242. ret = -ENOMEM;
  243. goto out;
  244. }
  245. acx->dynamic_fw_traces = cpu_to_le32(wl->dynamic_fw_traces);
  246. ret = wl1271_cmd_configure(wl, ACX_DYNAMIC_TRACES_CFG,
  247. acx, sizeof(*acx));
  248. if (ret < 0) {
  249. wl1271_warning("acx config dynamic fw traces failed: %d", ret);
  250. goto out;
  251. }
  252. out:
  253. kfree(acx);
  254. return ret;
  255. }