target_if_tdls.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * Copyright (c) 2017-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. /**
  19. * DOC: offload lmac interface APIs for tdls
  20. *
  21. */
  22. #include <qdf_mem.h>
  23. #include <target_if.h>
  24. #include <qdf_status.h>
  25. #include <wmi_unified_api.h>
  26. #include <wmi_unified_priv.h>
  27. #include <wmi_unified_param.h>
  28. #include <wlan_objmgr_psoc_obj.h>
  29. #include <wlan_tdls_tgt_api.h>
  30. #include <target_if_tdls.h>
  31. #include <cdp_txrx_peer_ops.h>
  32. #include <wlan_utility.h>
  33. static inline struct wlan_lmac_if_tdls_rx_ops *
  34. target_if_tdls_get_rx_ops(struct wlan_objmgr_psoc *psoc)
  35. {
  36. return &psoc->soc_cb.rx_ops.tdls_rx_ops;
  37. }
  38. static int
  39. target_if_tdls_event_handler(ol_scn_t scn, uint8_t *data, uint32_t datalen)
  40. {
  41. struct wlan_objmgr_psoc *psoc;
  42. struct wmi_unified *wmi_handle;
  43. struct wlan_lmac_if_tdls_rx_ops *tdls_rx_ops;
  44. struct tdls_event_info info;
  45. QDF_STATUS status;
  46. if (!scn || !data) {
  47. target_if_err("scn: 0x%pK, data: 0x%pK", scn, data);
  48. return -EINVAL;
  49. }
  50. psoc = target_if_get_psoc_from_scn_hdl(scn);
  51. if (!psoc) {
  52. target_if_err("null psoc");
  53. return -EINVAL;
  54. }
  55. wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc);
  56. if (wmi_extract_vdev_tdls_ev_param(wmi_handle, data, &info)) {
  57. target_if_err("Failed to extract wmi tdls event");
  58. return -EINVAL;
  59. }
  60. tdls_rx_ops = target_if_tdls_get_rx_ops(psoc);
  61. if (tdls_rx_ops && tdls_rx_ops->tdls_ev_handler) {
  62. status = tdls_rx_ops->tdls_ev_handler(psoc, &info);
  63. if (QDF_IS_STATUS_ERROR(status)) {
  64. target_if_err("fail to handle tdls event");
  65. return -EINVAL;
  66. }
  67. }
  68. return 0;
  69. }
  70. QDF_STATUS
  71. target_if_tdls_update_fw_state(struct wlan_objmgr_psoc *psoc,
  72. struct tdls_info *param)
  73. {
  74. QDF_STATUS status;
  75. uint8_t tdls_state;
  76. if (TDLS_SUPPORT_EXP_TRIG_ONLY == param->tdls_state)
  77. tdls_state = WMI_TDLS_ENABLE_PASSIVE;
  78. else if (TDLS_SUPPORT_IMP_MODE == param->tdls_state ||
  79. TDLS_SUPPORT_EXT_CONTROL == param->tdls_state)
  80. tdls_state = WMI_TDLS_ENABLE_CONNECTION_TRACKER_IN_HOST;
  81. else
  82. tdls_state = WMI_TDLS_DISABLE;
  83. status = wmi_unified_update_fw_tdls_state_cmd(GET_WMI_HDL_FROM_PSOC(psoc),
  84. param, tdls_state);
  85. target_if_debug("vdev_id %d", param->vdev_id);
  86. return status;
  87. }
  88. QDF_STATUS
  89. target_if_tdls_update_peer_state(struct wlan_objmgr_psoc *psoc,
  90. struct tdls_peer_update_state *peer_params)
  91. {
  92. return QDF_STATUS_SUCCESS;
  93. }
  94. QDF_STATUS
  95. target_if_tdls_set_offchan_mode(struct wlan_objmgr_psoc *psoc,
  96. struct tdls_channel_switch_params *params)
  97. {
  98. QDF_STATUS status;
  99. status = wmi_unified_set_tdls_offchan_mode_cmd(GET_WMI_HDL_FROM_PSOC(psoc),
  100. params);
  101. return status;
  102. }
  103. QDF_STATUS
  104. target_if_tdls_set_uapsd(struct wlan_objmgr_psoc *psoc,
  105. struct sta_uapsd_trig_params *params)
  106. {
  107. QDF_STATUS ret;
  108. wmi_unified_t wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc);
  109. if (!wmi_service_enabled(wmi_handle,
  110. wmi_sta_uapsd_basic_auto_trig) ||
  111. !wmi_service_enabled(wmi_handle,
  112. wmi_sta_uapsd_var_auto_trig)) {
  113. target_if_debug("Trigger uapsd is not supported vdev id %d",
  114. params->vdevid);
  115. return QDF_STATUS_SUCCESS;
  116. }
  117. ret = wmi_unified_set_sta_uapsd_auto_trig_cmd(GET_WMI_HDL_FROM_PSOC(psoc),
  118. params);
  119. if (QDF_IS_STATUS_ERROR(ret))
  120. target_if_err("Failed to send set uapsd param ret = %d", ret);
  121. return ret;
  122. }
  123. QDF_STATUS
  124. target_if_tdls_register_event_handler(struct wlan_objmgr_psoc *psoc,
  125. void *arg)
  126. {
  127. return wmi_unified_register_event(GET_WMI_HDL_FROM_PSOC(psoc),
  128. wmi_tdls_peer_event_id,
  129. target_if_tdls_event_handler);
  130. }
  131. QDF_STATUS
  132. target_if_tdls_unregister_event_handler(struct wlan_objmgr_psoc *psoc,
  133. void *arg)
  134. {
  135. return wmi_unified_unregister_event(GET_WMI_HDL_FROM_PSOC(psoc),
  136. wmi_tdls_peer_event_id);
  137. }
  138. QDF_STATUS
  139. target_if_tdls_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
  140. {
  141. struct wlan_lmac_if_tdls_tx_ops *tdls_txops;
  142. tdls_txops = &tx_ops->tdls_tx_ops;
  143. tdls_txops->update_fw_state = target_if_tdls_update_fw_state;
  144. tdls_txops->update_peer_state = target_if_tdls_update_peer_state;
  145. tdls_txops->set_offchan_mode = target_if_tdls_set_offchan_mode;
  146. tdls_txops->tdls_reg_ev_handler = target_if_tdls_register_event_handler;
  147. tdls_txops->tdls_unreg_ev_handler =
  148. target_if_tdls_unregister_event_handler;
  149. tdls_txops->tdls_set_uapsd = target_if_tdls_set_uapsd;
  150. return QDF_STATUS_SUCCESS;
  151. }