wmi_unified_atf_tlv.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #include <osdep.h>
  19. #include "wmi.h"
  20. #include "wmi_unified_priv.h"
  21. #include "wmi_unified_atf_param.h"
  22. #include "wmi_unified_atf_api.h"
  23. #ifdef WLAN_ATF_ENABLE
  24. /**
  25. * send_set_atf_cmd_tlv() - send set atf command to fw
  26. * @wmi_handle: wmi handle
  27. * @param: pointer to set atf param
  28. *
  29. * @return QDF_STATUS_SUCCESS on success and -ve on failure.
  30. */
  31. static QDF_STATUS
  32. send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
  33. struct set_atf_params *param)
  34. {
  35. wmi_atf_peer_info *peer_info;
  36. wmi_peer_atf_request_fixed_param *cmd;
  37. wmi_buf_t buf;
  38. uint8_t *buf_ptr;
  39. int i;
  40. int32_t len = 0;
  41. QDF_STATUS retval;
  42. len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
  43. len += param->num_peers * sizeof(wmi_atf_peer_info);
  44. buf = wmi_buf_alloc(wmi_handle, len);
  45. if (!buf) {
  46. WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
  47. return QDF_STATUS_E_FAILURE;
  48. }
  49. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  50. cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
  51. WMITLV_SET_HDR(&cmd->tlv_header,
  52. WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
  53. WMITLV_GET_STRUCT_TLVLEN(
  54. wmi_peer_atf_request_fixed_param));
  55. cmd->num_peers = param->num_peers;
  56. buf_ptr += sizeof(*cmd);
  57. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  58. sizeof(wmi_atf_peer_info) *
  59. cmd->num_peers);
  60. buf_ptr += WMI_TLV_HDR_SIZE;
  61. peer_info = (wmi_atf_peer_info *)buf_ptr;
  62. for (i = 0; i < cmd->num_peers; i++) {
  63. WMITLV_SET_HDR(&peer_info->tlv_header,
  64. WMITLV_TAG_STRUC_wmi_atf_peer_info,
  65. WMITLV_GET_STRUCT_TLVLEN(
  66. wmi_atf_peer_info));
  67. qdf_mem_copy(&(peer_info->peer_macaddr),
  68. &(param->peer_info[i].peer_macaddr),
  69. sizeof(wmi_mac_addr));
  70. peer_info->atf_units = param->peer_info[i].percentage_peer;
  71. peer_info->vdev_id = param->peer_info[i].vdev_id;
  72. peer_info->pdev_id =
  73. wmi_handle->ops->convert_pdev_id_host_to_target(
  74. param->peer_info[i].pdev_id);
  75. /*
  76. * TLV definition for peer atf request fixed param combines
  77. * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
  78. * stats and atf extension stats as two different
  79. * implementations.
  80. * Need to discuss with FW on this.
  81. *
  82. * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
  83. * peer_info->atf_units_reserved =
  84. * param->peer_ext_info[i].atf_index_reserved;
  85. */
  86. peer_info++;
  87. }
  88. wmi_mtrace(WMI_PEER_ATF_REQUEST_CMDID, NO_SESSION, 0);
  89. retval = wmi_unified_cmd_send(wmi_handle, buf, len,
  90. WMI_PEER_ATF_REQUEST_CMDID);
  91. if (retval != QDF_STATUS_SUCCESS) {
  92. WMI_LOGE("%s : WMI Failed", __func__);
  93. wmi_buf_free(buf);
  94. }
  95. return retval;
  96. }
  97. #endif
  98. /**
  99. * send_set_bwf_cmd_tlv() - send set bwf command to fw
  100. * @wmi_handle: wmi handle
  101. * @param: pointer to set bwf param
  102. *
  103. * Return: 0 for success or error code
  104. */
  105. static QDF_STATUS
  106. send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
  107. struct set_bwf_params *param)
  108. {
  109. wmi_bwf_peer_info *peer_info;
  110. wmi_peer_bwf_request_fixed_param *cmd;
  111. wmi_buf_t buf;
  112. QDF_STATUS retval;
  113. int32_t len;
  114. uint8_t *buf_ptr;
  115. int i;
  116. len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
  117. len += param->num_peers * sizeof(wmi_bwf_peer_info);
  118. buf = wmi_buf_alloc(wmi_handle, len);
  119. if (!buf) {
  120. WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
  121. return QDF_STATUS_E_FAILURE;
  122. }
  123. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  124. cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
  125. WMITLV_SET_HDR(&cmd->tlv_header,
  126. WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
  127. WMITLV_GET_STRUCT_TLVLEN(
  128. wmi_peer_bwf_request_fixed_param));
  129. cmd->num_peers = param->num_peers;
  130. buf_ptr += sizeof(*cmd);
  131. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  132. sizeof(wmi_bwf_peer_info) *
  133. cmd->num_peers);
  134. buf_ptr += WMI_TLV_HDR_SIZE;
  135. peer_info = (wmi_bwf_peer_info *)buf_ptr;
  136. for (i = 0; i < cmd->num_peers; i++) {
  137. WMITLV_SET_HDR(&peer_info->tlv_header,
  138. WMITLV_TAG_STRUC_wmi_bwf_peer_info,
  139. WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
  140. peer_info->bwf_guaranteed_bandwidth =
  141. param->peer_info[i].throughput;
  142. peer_info->bwf_max_airtime =
  143. param->peer_info[i].max_airtime;
  144. peer_info->bwf_peer_priority =
  145. param->peer_info[i].priority;
  146. qdf_mem_copy(&peer_info->peer_macaddr,
  147. &param->peer_info[i].peer_macaddr,
  148. sizeof(param->peer_info[i].peer_macaddr));
  149. peer_info->vdev_id =
  150. param->peer_info[i].vdev_id;
  151. peer_info->pdev_id =
  152. wmi_handle->ops->convert_pdev_id_host_to_target(
  153. param->peer_info[i].pdev_id);
  154. peer_info++;
  155. }
  156. wmi_mtrace(WMI_PEER_BWF_REQUEST_CMDID, NO_SESSION, 0);
  157. retval = wmi_unified_cmd_send(wmi_handle, buf, len,
  158. WMI_PEER_BWF_REQUEST_CMDID);
  159. if (retval != QDF_STATUS_SUCCESS) {
  160. WMI_LOGE("%s : WMI Failed", __func__);
  161. wmi_buf_free(buf);
  162. }
  163. return retval;
  164. }
  165. void wmi_atf_attach_tlv(wmi_unified_t wmi_handle)
  166. {
  167. struct wmi_ops *ops = wmi_handle->ops;
  168. #ifdef WLAN_ATF_ENABLE
  169. ops->send_set_atf_cmd = send_set_atf_cmd_tlv;
  170. #endif
  171. ops->send_set_bwf_cmd = send_set_bwf_cmd_tlv;
  172. }