utils_mlo.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /*
  2. * Copyright (c) 2021, The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. /*
  18. * DOC: contains MLO manager containing util public api's
  19. */
  20. #ifndef _WLAN_UTILS_MLO_H_
  21. #define _WLAN_UTILS_MLO_H_
  22. #include <wlan_cmn_ieee80211.h>
  23. #include "wlan_mlo_mgr_public_structs.h"
  24. #include <wlan_cm_ucfg_api.h>
  25. #include <wlan_objmgr_vdev_obj.h>
  26. #ifdef WLAN_FEATURE_11BE_MLO
  27. /**
  28. * util_gen_link_assoc_req() - Generate link specific assoc request
  29. * @frame: Pointer to original association request. This should not contain the
  30. * 802.11 header, and must start from the fixed fields in the association
  31. * request. This is required due to some caller semantics built into the end to
  32. * end design.
  33. * @frame_len: Length of original association request
  34. * @isreassoc: Whether this is a re-association request
  35. * @link_addr: Secondary link's MAC address
  36. * @link_frame: Generated secondary link specific association request. Note that
  37. * this will start from the 802.11 header (unlike the original association
  38. * request). This should be ignored in the case of failure.
  39. * @link_frame_maxsize: Maximum size of generated secondary link specific
  40. * association request
  41. * @link_frame_len: Pointer to location where populated length of generated
  42. * secondary link specific association request should be written. This should be
  43. * ignored in the case of failure.
  44. *
  45. * Generate a link specific logically equivalent association request for the
  46. * secondary link from the original association request containing a Multi-Link
  47. * element. This applies to both association and re-association requests.
  48. * Currently, only two link MLO is supported.
  49. *
  50. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  51. * the reason for error in the case of failure.
  52. */
  53. QDF_STATUS
  54. util_gen_link_assoc_req(uint8_t *frame, qdf_size_t frame_len, bool isreassoc,
  55. struct qdf_mac_addr link_addr,
  56. uint8_t *link_frame,
  57. qdf_size_t link_frame_maxsize,
  58. qdf_size_t *link_frame_len);
  59. /**
  60. * util_gen_link_assoc_rsp() - Generate link specific assoc response
  61. * @frame: Pointer to original association response. This should not contain the
  62. * 802.11 header, and must start from the fixed fields in the association
  63. * response. This is required due to some caller semantics built into the end to
  64. * end design.
  65. * @frame_len: Length of original association response
  66. * @isreassoc: Whether this is a re-association response
  67. * @link_addr: Secondary link's MAC address
  68. * @link_frame: Generated secondary link specific association response. Note
  69. * that this will start from the 802.11 header (unlike the original association
  70. * response). This should be ignored in the case of failure.
  71. * @link_frame_maxsize: Maximum size of generated secondary link specific
  72. * association response
  73. * @link_frame_len: Pointer to location where populated length of generated
  74. * secondary link specific association response should be written. This should
  75. * be ignored in the case of failure.
  76. *
  77. * Generate a link specific logically equivalent association response for the
  78. * secondary link from the original association response containing a Multi-Link
  79. * element. This applies to both association and re-association responses.
  80. * Currently, only two link MLO is supported.
  81. *
  82. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  83. * the reason for error in the case of failure.
  84. */
  85. QDF_STATUS
  86. util_gen_link_assoc_rsp(uint8_t *frame, qdf_size_t frame_len, bool isreassoc,
  87. struct qdf_mac_addr link_addr,
  88. uint8_t *link_frame,
  89. qdf_size_t link_frame_maxsize,
  90. qdf_size_t *link_frame_len);
  91. /**
  92. * util_find_mlie - Find the first Multi-Link element or the start of the first
  93. * Multi-Link element fragment sequence in a given buffer containing elements,
  94. * if a Multi-Link element or element fragment sequence exists in the given
  95. * buffer.
  96. *
  97. * @buf: Buffer to be searched for the Multi-Link element or the start of the
  98. * Multi-Link element fragment sequence
  99. * @buflen: Length of the buffer
  100. * @mlieseq: Pointer to location where the starting address of the Multi-Link
  101. * element or Multi-Link element fragment sequence should be updated if found
  102. * in the given buffer. The value NULL will be updated to this location if the
  103. * element or element fragment sequence is not found. This should be ignored by
  104. * the caller if the function returns error.
  105. * @mlieseqlen: Pointer to location where the total length of the Multi-Link
  106. * element or Multi-Link element fragment sequence should be updated if found
  107. * in the given buffer. This should be ignored by the caller if the function
  108. * returns error, or if the function indicates that the element or element
  109. * fragment sequence was not found by providing a starting address of NULL.
  110. *
  111. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  112. * the reason for error in the case of failure
  113. */
  114. QDF_STATUS
  115. util_find_mlie(uint8_t *buf, qdf_size_t buflen, uint8_t **mlieseq,
  116. qdf_size_t *mlieseqlen);
  117. /**
  118. * util_get_mlie_variant - Get the variant of the given Multi-Link element or
  119. * element fragment sequence.
  120. *
  121. * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
  122. * fragment sequence
  123. * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  124. * fragment sequence
  125. * @variant: Pointer to the location where the value of the variant should be
  126. * updated. On success, the value should be interpreted by the caller as a
  127. * member of enum wlan_ml_variant. (This enum is not directly used as an
  128. * argument, so that non-MLO code that happens to call this function does not
  129. * need to be aware of the definition of the enum, though such a call would
  130. * ultimately result in an error). The value should be ignored by the caller if
  131. * the function returns error.
  132. *
  133. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  134. * the reason for error in the case of failure
  135. */
  136. QDF_STATUS
  137. util_get_mlie_variant(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  138. int *variant);
  139. /**
  140. * util_get_bvmlie_mldmacaddr - Get the MLD MAC address from a given Basic
  141. * variant Multi-Link element or element fragment sequence.
  142. *
  143. * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
  144. * fragment sequence
  145. * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  146. * fragment sequence
  147. * @mldmacaddrfound: Pointer to the location where a boolean status should be
  148. * updated indicating whether the MLD MAC address was found or not. This should
  149. * be ignored by the caller if the function returns error.
  150. * @linkid: Pointer to the location where the MLD MAC address should be updated.
  151. * This should be ignored by the caller if the function returns error, or if the
  152. * function indicates that the MLD MAC address was not found.
  153. *
  154. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  155. * the reason for error in the case of failure
  156. */
  157. QDF_STATUS
  158. util_get_bvmlie_mldmacaddr(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  159. bool *mldmacaddrfound,
  160. struct qdf_mac_addr *mldmacaddr);
  161. /**
  162. * util_get_bvmlie_primary_linkid - Get the link identifier from a given Basic
  163. * variant Multi-Link element or element fragment sequence, of the AP that
  164. * transmits the Multi-Link element/element fragment sequence or the
  165. * nontransmitted BSSID in the same multiple BSSID set as the AP that transmits
  166. * the Multi-Link element/element fragment sequence and that is affiliated with
  167. * the MLD that is described in the Multi-Link element.
  168. *
  169. * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
  170. * fragment sequence
  171. * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  172. * fragment sequence
  173. * @linkidfound: Pointer to the location where a boolean status should be
  174. * updated indicating whether the link identifier was found or not. This should
  175. * be ignored by the caller if the function returns error.
  176. * @linkid: Pointer to the location where the value of the link identifier
  177. * should be updated. This should be ignored by the caller if the function
  178. * returns error, or if the function indicates that the link identifier was not
  179. * found.
  180. *
  181. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  182. * the reason for error in the case of failure
  183. */
  184. QDF_STATUS
  185. util_get_bvmlie_primary_linkid(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  186. bool *linkidfound, uint8_t *linkid);
  187. /**
  188. * util_get_bvmlie_mldcap - Get the MLD capabilities from a given Basic
  189. * variant Multi-Link element or element fragment sequence, of the AP that
  190. * transmits the Multi-Link element/element fragment sequence or the
  191. * nontransmitted BSSID in the same multiple BSSID set as the AP that transmits
  192. * the Multi-Link element/element fragment sequence and that is affiliated with
  193. * the MLD that is described in the Multi-Link element.
  194. *
  195. * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
  196. * fragment sequence
  197. * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  198. * fragment sequence
  199. * @mldcapfound: Pointer to the location where a boolean status should be
  200. * updated indicating whether the MLD capabilities was found or not. This should
  201. * be ignored by the caller if the function returns error.
  202. * @mldcap: Pointer to the location where the value of the MLD capabilities
  203. * should be updated. This should be ignored by the caller if the function
  204. * returns error, or if the function indicates that the MLD capabilities was not
  205. * found.
  206. *
  207. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  208. * the reason for error in the case of failure
  209. */
  210. QDF_STATUS
  211. util_get_bvmlie_mldcap(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  212. bool *mldcapfound, uint16_t *mldcap);
  213. /**
  214. * util_get_bvmlie_persta_partner_info() - Get per-STA partner link information
  215. *
  216. * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
  217. * fragment sequence
  218. * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  219. * fragment sequence
  220. * @partner_info: Pointer to the location where the partner link information
  221. * should be updated. This should be ignored by the caller if the function
  222. * returns error. Note that success will be returned and the number of links in
  223. * this structure will be reported as 0, if no Link Info is found, or no per-STA
  224. * profile is found, or if none of the per-STA profiles includes a MAC address
  225. * in the STA Info field (assuming no errors are encountered).
  226. *
  227. * Get partner link information in the per-STA profiles present in a Basic
  228. * variant Multi-Link element. The partner link information is returned only for
  229. * those per-STA profiles which have a MAC address in the STA Info field.
  230. *
  231. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  232. * the reason for error in the case of failure
  233. */
  234. QDF_STATUS
  235. util_get_bvmlie_persta_partner_info(uint8_t *mlieseq,
  236. qdf_size_t mlieseqlen,
  237. struct mlo_partner_info *partner_info);
  238. #else
  239. static inline QDF_STATUS
  240. util_gen_link_assoc_req(uint8_t *frame, qdf_size_t frame_len, bool isreassoc,
  241. struct qdf_mac_addr link_addr,
  242. uint8_t *link_frame,
  243. qdf_size_t link_frame_maxsize,
  244. qdf_size_t *link_frame_len)
  245. {
  246. return QDF_STATUS_E_NOSUPPORT;
  247. }
  248. static inline QDF_STATUS
  249. util_gen_link_assoc_rsp(uint8_t *frame, qdf_size_t frame_len, bool isreassoc,
  250. struct qdf_mac_addr link_addr,
  251. uint8_t *link_frame,
  252. qdf_size_t link_frame_maxsize,
  253. qdf_size_t *link_frame_len)
  254. {
  255. return QDF_STATUS_E_NOSUPPORT;
  256. }
  257. static inline QDF_STATUS
  258. util_find_mlie(uint8_t *buf, qdf_size_t buflen, uint8_t **mlieseq,
  259. qdf_size_t *mlieseqlen)
  260. {
  261. return QDF_STATUS_E_NOSUPPORT;
  262. }
  263. static inline QDF_STATUS
  264. util_get_mlie_variant(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  265. int *variant)
  266. {
  267. return QDF_STATUS_E_NOSUPPORT;
  268. }
  269. static inline QDF_STATUS
  270. util_get_bvmlie_mldmacaddr(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  271. bool *mldmacaddrfound,
  272. struct qdf_mac_addr *mldmacaddr)
  273. {
  274. return QDF_STATUS_E_NOSUPPORT;
  275. }
  276. static inline QDF_STATUS
  277. util_get_bvmlie_primary_linkid(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  278. bool *linkidfound, uint8_t *linkid)
  279. {
  280. return QDF_STATUS_E_NOSUPPORT;
  281. }
  282. static inline QDF_STATUS
  283. util_get_bvmlie_persta_partner_info(uint8_t *mlieseq,
  284. qdf_size_t mlieseqlen,
  285. struct mlo_partner_info *partner_info)
  286. {
  287. return QDF_STATUS_E_NOSUPPORT;
  288. }
  289. #endif /* WLAN_FEATURE_11BE_MLO */
  290. #endif /* _WLAN_UTILS_MLO_H_ */