acx.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. int wl18xx_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap,
  26. u32 sdio_blk_size, u32 extra_mem_blks,
  27. u32 len_field_size)
  28. {
  29. struct wl18xx_acx_host_config_bitmap *bitmap_conf;
  30. int ret;
  31. wl1271_debug(DEBUG_ACX, "acx cfg bitmap %d blk %d spare %d field %d",
  32. host_cfg_bitmap, sdio_blk_size, extra_mem_blks,
  33. len_field_size);
  34. bitmap_conf = kzalloc(sizeof(*bitmap_conf), GFP_KERNEL);
  35. if (!bitmap_conf) {
  36. ret = -ENOMEM;
  37. goto out;
  38. }
  39. bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap);
  40. bitmap_conf->host_sdio_block_size = cpu_to_le32(sdio_blk_size);
  41. bitmap_conf->extra_mem_blocks = cpu_to_le32(extra_mem_blks);
  42. bitmap_conf->length_field_size = cpu_to_le32(len_field_size);
  43. ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP,
  44. bitmap_conf, sizeof(*bitmap_conf));
  45. if (ret < 0) {
  46. wl1271_warning("wl1271 bitmap config opt failed: %d", ret);
  47. goto out;
  48. }
  49. out:
  50. kfree(bitmap_conf);
  51. return ret;
  52. }
  53. int wl18xx_acx_set_checksum_state(struct wl1271 *wl)
  54. {
  55. struct wl18xx_acx_checksum_state *acx;
  56. int ret;
  57. wl1271_debug(DEBUG_ACX, "acx checksum state");
  58. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  59. if (!acx) {
  60. ret = -ENOMEM;
  61. goto out;
  62. }
  63. acx->checksum_state = CHECKSUM_OFFLOAD_ENABLED;
  64. ret = wl1271_cmd_configure(wl, ACX_CSUM_CONFIG, acx, sizeof(*acx));
  65. if (ret < 0) {
  66. wl1271_warning("failed to set Tx checksum state: %d", ret);
  67. goto out;
  68. }
  69. out:
  70. kfree(acx);
  71. return ret;
  72. }
  73. int wl18xx_acx_clear_statistics(struct wl1271 *wl)
  74. {
  75. struct wl18xx_acx_clear_statistics *acx;
  76. int ret = 0;
  77. wl1271_debug(DEBUG_ACX, "acx clear statistics");
  78. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  79. if (!acx) {
  80. ret = -ENOMEM;
  81. goto out;
  82. }
  83. ret = wl1271_cmd_configure(wl, ACX_CLEAR_STATISTICS, acx, sizeof(*acx));
  84. if (ret < 0) {
  85. wl1271_warning("failed to clear firmware statistics: %d", ret);
  86. goto out;
  87. }
  88. out:
  89. kfree(acx);
  90. return ret;
  91. }
  92. int wl18xx_acx_peer_ht_operation_mode(struct wl1271 *wl, u8 hlid, bool wide)
  93. {
  94. struct wlcore_peer_ht_operation_mode *acx;
  95. int ret;
  96. wl1271_debug(DEBUG_ACX, "acx peer ht operation mode hlid %d bw %d",
  97. hlid, wide);
  98. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  99. if (!acx) {
  100. ret = -ENOMEM;
  101. goto out;
  102. }
  103. acx->hlid = hlid;
  104. acx->bandwidth = wide ? WLCORE_BANDWIDTH_40MHZ : WLCORE_BANDWIDTH_20MHZ;
  105. ret = wl1271_cmd_configure(wl, ACX_PEER_HT_OPERATION_MODE_CFG, acx,
  106. sizeof(*acx));
  107. if (ret < 0) {
  108. wl1271_warning("acx peer ht operation mode failed: %d", ret);
  109. goto out;
  110. }
  111. out:
  112. kfree(acx);
  113. return ret;
  114. }
  115. /*
  116. * this command is basically the same as wl1271_acx_ht_capabilities,
  117. * with the addition of supported rates. they should be unified in
  118. * the next fw api change
  119. */
  120. int wl18xx_acx_set_peer_cap(struct wl1271 *wl,
  121. struct ieee80211_sta_ht_cap *ht_cap,
  122. bool allow_ht_operation,
  123. u32 rate_set, u8 hlid)
  124. {
  125. struct wlcore_acx_peer_cap *acx;
  126. int ret = 0;
  127. u32 ht_capabilites = 0;
  128. wl1271_debug(DEBUG_ACX,
  129. "acx set cap ht_supp: %d ht_cap: %d rates: 0x%x",
  130. ht_cap->ht_supported, ht_cap->cap, rate_set);
  131. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  132. if (!acx) {
  133. ret = -ENOMEM;
  134. goto out;
  135. }
  136. if (allow_ht_operation && ht_cap->ht_supported) {
  137. /* no need to translate capabilities - use the spec values */
  138. ht_capabilites = ht_cap->cap;
  139. /*
  140. * this bit is not employed by the spec but only by FW to
  141. * indicate peer HT support
  142. */
  143. ht_capabilites |= WL12XX_HT_CAP_HT_OPERATION;
  144. /* get data from A-MPDU parameters field */
  145. acx->ampdu_max_length = ht_cap->ampdu_factor;
  146. acx->ampdu_min_spacing = ht_cap->ampdu_density;
  147. }
  148. acx->hlid = hlid;
  149. acx->ht_capabilites = cpu_to_le32(ht_capabilites);
  150. acx->supported_rates = cpu_to_le32(rate_set);
  151. ret = wl1271_cmd_configure(wl, ACX_PEER_CAP, acx, sizeof(*acx));
  152. if (ret < 0) {
  153. wl1271_warning("acx ht capabilities setting failed: %d", ret);
  154. goto out;
  155. }
  156. out:
  157. kfree(acx);
  158. return ret;
  159. }