wlan_mlo_epcs.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. /**
  17. * DOC: contains EPCS APIs
  18. */
  19. #include <wlan_objmgr_pdev_obj.h>
  20. #include <wlan_objmgr_vdev_obj.h>
  21. #include <wlan_objmgr_peer_obj.h>
  22. #include <wlan_mlo_mgr_public_structs.h>
  23. #include <wlan_mlo_mgr_cmn.h>
  24. #include <qdf_util.h>
  25. #include <wlan_cm_api.h>
  26. #include <utils_mlo.h>
  27. #include <wlan_mlo_epcs.h>
  28. /**
  29. * wlan_mlo_parse_epcs_request_action_frame() - API to parse EPCS request action
  30. * frame.
  31. * @epcs: Pointer to EPCS structure
  32. * @action_frm: Pointer to action frame
  33. * @frm_len: frame length
  34. *
  35. * Return: QDF_STATUS
  36. */
  37. static QDF_STATUS
  38. wlan_mlo_parse_epcs_request_action_frame(struct wlan_epcs_info *epcs,
  39. struct wlan_action_frame *action_frm,
  40. uint32_t frm_len)
  41. {
  42. struct epcs_frm *epcs_action_frm;
  43. /*
  44. * EPCS request action frame
  45. *
  46. * 1-byte 1-byte 1-byte variable
  47. *--------------------------------------------
  48. * | | | | |
  49. * | Category| Protected | Dialog | PA ML IE |
  50. * | | EHT | token | |
  51. * | | Action | | |
  52. *--------------------------------------------
  53. */
  54. epcs_action_frm = (struct epcs_frm *)action_frm;
  55. epcs->cat = epcs_action_frm->protected_eht_action;
  56. epcs->dialog_token = epcs_action_frm->dialog_token;
  57. epcs_info("EPCS frame rcv : category:%d action:%d dialog_token:%d frmlen %d",
  58. epcs_action_frm->category,
  59. epcs_action_frm->protected_eht_action,
  60. epcs_action_frm->dialog_token, frm_len);
  61. return QDF_STATUS_SUCCESS;
  62. }
  63. /**
  64. * wlan_mlo_parse_epcs_response_action_frame() - API to parse EPCS response
  65. * action frame.
  66. * @epcs: Pointer to EPCS structure
  67. * @action_frm: Pointer to action frame
  68. * @frm_len: frame length
  69. *
  70. * Return: QDF_STATUS
  71. */
  72. static QDF_STATUS
  73. wlan_mlo_parse_epcs_response_action_frame(struct wlan_epcs_info *epcs,
  74. struct wlan_action_frame *action_frm,
  75. uint32_t frm_len)
  76. {
  77. struct epcs_frm *epcs_action_frm;
  78. /*
  79. * EPCS response action frame
  80. *
  81. * 1-byte 1-byte 1-byte 1-byte variable
  82. *----------------------------------------------------
  83. * | | | | | |
  84. * | Category| Protected | Dialog | Status | PA IE |
  85. * | | EHT | token | code | |
  86. * | | Action | | | |
  87. *----------------------------------------------------
  88. */
  89. epcs_action_frm = (struct epcs_frm *)action_frm;
  90. epcs->cat = epcs_action_frm->protected_eht_action;
  91. epcs->dialog_token = epcs_action_frm->dialog_token;
  92. QDF_SET_BITS(epcs->status, 0, 8, epcs_action_frm->resp.status_code[0]);
  93. QDF_SET_BITS(epcs->status, 8, 8, epcs_action_frm->resp.status_code[1]);
  94. epcs_info("EPCS frame rcv : category:%d action:%d dialog_token:%d status %x %x frmlen %d",
  95. epcs_action_frm->category,
  96. epcs_action_frm->protected_eht_action,
  97. epcs_action_frm->dialog_token,
  98. epcs_action_frm->resp.status_code[0],
  99. epcs_action_frm->resp.status_code[1], frm_len);
  100. return QDF_STATUS_SUCCESS;
  101. }
  102. /**
  103. * wlan_mlo_parse_epcs_teardown_action_frame() - API to parse EPCS teardown
  104. * action frame.
  105. * @epcs: Pointer to EPCS structure
  106. * @action_frm: Pointer to action frame
  107. * @frm_len: frame length
  108. *
  109. * Return: QDF_STATUS
  110. */
  111. static QDF_STATUS
  112. wlan_mlo_parse_epcs_teardown_action_frame(struct wlan_epcs_info *epcs,
  113. struct wlan_action_frame *action_frm,
  114. uint32_t frm_len)
  115. {
  116. struct epcs_frm *epcs_action_frm;
  117. /*
  118. * EPCS teardown action frame
  119. *
  120. * 1-byte 1-byte
  121. *------------------------
  122. * | | |
  123. * | Category| Protected |
  124. * | | EHT |
  125. * | | Action |
  126. *------------------------
  127. */
  128. epcs_action_frm = (struct epcs_frm *)action_frm;
  129. epcs->cat = epcs_action_frm->protected_eht_action;
  130. epcs_info("EPCS frame rcv : category:%d action:%d frmlen %d",
  131. epcs_action_frm->category,
  132. epcs_action_frm->protected_eht_action, frm_len);
  133. return QDF_STATUS_SUCCESS;
  134. }
  135. QDF_STATUS
  136. wlan_mlo_parse_epcs_action_frame(struct wlan_epcs_info *epcs,
  137. struct wlan_action_frame *action_frm,
  138. uint32_t frm_len)
  139. {
  140. QDF_STATUS ret_val = QDF_STATUS_SUCCESS;
  141. switch (action_frm->action) {
  142. case WLAN_EPCS_CATEGORY_REQUEST:
  143. return wlan_mlo_parse_epcs_request_action_frame(
  144. epcs, action_frm, frm_len);
  145. case WLAN_EPCS_CATEGORY_RESPONSE:
  146. return wlan_mlo_parse_epcs_response_action_frame(
  147. epcs, action_frm, frm_len);
  148. case WLAN_EPCS_CATEGORY_TEARDOWN:
  149. return wlan_mlo_parse_epcs_teardown_action_frame(
  150. epcs, action_frm, frm_len);
  151. default:
  152. ret_val = QDF_STATUS_E_INVAL;
  153. epcs_err("Invalid action :%d", action_frm->action);
  154. }
  155. return ret_val;
  156. }
  157. static uint8_t *
  158. wlan_mlo_add_epcs_request_action_frame(uint8_t *frm,
  159. struct wlan_action_frame_args *args,
  160. uint8_t *buf)
  161. {
  162. *frm++ = args->category;
  163. *frm++ = args->action;
  164. /* Dialog token*/
  165. *frm++ = args->arg1;
  166. epcs_info("EPCS frame: category:%d action:%d dialog_token:%d",
  167. args->category, args->action, args->arg1);
  168. /* Add priority access ml ie in caller for AP mode */
  169. return frm;
  170. }
  171. static uint8_t *
  172. wlan_mlo_add_epcs_response_action_frame(uint8_t *frm,
  173. struct wlan_action_frame_args *args,
  174. uint8_t *buf)
  175. {
  176. *frm++ = args->category;
  177. *frm++ = args->action;
  178. /* Dialog token*/
  179. *frm++ = args->arg1;
  180. /* Status code (2 bytes) */
  181. *frm++ = QDF_GET_BITS(args->arg2, 0, 8);
  182. *frm++ = QDF_GET_BITS(args->arg2, 8, 8);
  183. epcs_info("EPCS response frame: category:%d action:%d dialog_token:%d status_code:%d",
  184. args->category, args->action, args->arg1, args->arg2);
  185. /* Add priority access ml ie for AP mode */
  186. return frm;
  187. }
  188. uint8_t *
  189. wlan_mlo_add_epcs_action_frame(uint8_t *frm,
  190. struct wlan_action_frame_args *args,
  191. uint8_t *buf)
  192. {
  193. switch (args->action) {
  194. case WLAN_EPCS_CATEGORY_REQUEST:
  195. return wlan_mlo_add_epcs_request_action_frame(frm, args,
  196. buf);
  197. case WLAN_EPCS_CATEGORY_RESPONSE:
  198. return wlan_mlo_add_epcs_response_action_frame(frm, args,
  199. buf);
  200. case WLAN_EPCS_CATEGORY_TEARDOWN:
  201. *frm++ = args->category;
  202. *frm++ = args->action;
  203. return frm;
  204. default:
  205. epcs_err("Invalid category:%d", args->category);
  206. }
  207. return frm;
  208. }