utils_mlo.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  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 Multi-Link element
  93. * @buf: Buffer to be searched for the Multi-Link element or the start of the
  94. * Multi-Link element fragment sequence
  95. * @buflen: Length of the buffer
  96. * @mlieseq: Pointer to location where the starting address of the Multi-Link
  97. * element or Multi-Link element fragment sequence should be updated if found
  98. * in the given buffer. The value NULL will be updated to this location if the
  99. * element or element fragment sequence is not found. This should be ignored by
  100. * the caller if the function returns error.
  101. * @mlieseqlen: Pointer to location where the total length of the Multi-Link
  102. * element or Multi-Link element fragment sequence should be updated if found
  103. * in the given buffer. This should be ignored by the caller if the function
  104. * returns error, or if the function indicates that the element or element
  105. * fragment sequence was not found by providing a starting address of NULL.
  106. *
  107. * Find the first Multi-Link element or the start of the first
  108. * Multi-Link element fragment sequence in a given buffer containing elements,
  109. * if a Multi-Link element or element fragment sequence exists in the given
  110. * buffer.
  111. *
  112. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  113. * the reason for error in the case of failure
  114. */
  115. QDF_STATUS
  116. util_find_mlie(uint8_t *buf, qdf_size_t buflen, uint8_t **mlieseq,
  117. qdf_size_t *mlieseqlen);
  118. /**
  119. * util_get_mlie_variant() - Get ML IE variant
  120. * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
  121. * fragment sequence
  122. * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  123. * fragment sequence
  124. * @variant: Pointer to the location where the value of the variant should be
  125. * updated. On success, the value should be interpreted by the caller as a
  126. * member of enum wlan_ml_variant. (This enum is not directly used as an
  127. * argument, so that non-MLO code that happens to call this function does not
  128. * need to be aware of the definition of the enum, though such a call would
  129. * ultimately result in an error). The value should be ignored by the caller if
  130. * the function returns error.
  131. *
  132. * Get the variant of the given Multi-Link element or element fragment sequence.
  133. *
  134. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  135. * the reason for error in the case of failure
  136. */
  137. QDF_STATUS
  138. util_get_mlie_variant(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  139. int *variant);
  140. /**
  141. * util_get_bvmlie_mldmacaddr() - Get the MLD MAC address
  142. * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
  143. * fragment sequence
  144. * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  145. * fragment sequence
  146. * @linkid: Pointer to the location where the MLD MAC address should be updated.
  147. * This should be ignored by the caller if the function returns error.
  148. *
  149. * Get the MLD MAC address from a given Basic variant Multi-Link element
  150. * or element fragment sequence.
  151. *
  152. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  153. * the reason for error in the case of failure
  154. */
  155. QDF_STATUS
  156. util_get_bvmlie_mldmacaddr(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  157. struct qdf_mac_addr *mldmacaddr);
  158. /**
  159. * util_get_bvmlie_eml_cap() - Get the EML capabilities
  160. * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
  161. * fragment sequence
  162. * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  163. * fragment sequence
  164. * @eml_cap_found: Pointer to the location where a boolean status should be
  165. * updated indicating whether the EML cabalility was found or not. This should
  166. * be ignored by the caller if the function returns error.
  167. * @eml_cap: Pointer to the location where the EML capabilities should be
  168. * updated. This should be ignored by the caller if the function indicates
  169. * that the EML capability was not found.
  170. *
  171. * Get the EML capabilities from a given Basic variant Multi-Link element or
  172. * element fragment sequence.
  173. *
  174. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  175. * the reason for error in the case of failure
  176. */
  177. QDF_STATUS
  178. util_get_bvmlie_eml_cap(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  179. bool *eml_cap_found,
  180. uint16_t *eml_cap);
  181. /**
  182. * util_get_bvmlie_primary_linkid() - Get the link identifier
  183. * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
  184. * fragment sequence
  185. * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  186. * fragment sequence
  187. * @linkidfound: Pointer to the location where a boolean status should be
  188. * updated indicating whether the link identifier was found or not. This should
  189. * be ignored by the caller if the function returns error.
  190. * @linkid: Pointer to the location where the value of the link identifier
  191. * should be updated. This should be ignored by the caller if the function
  192. * returns error, or if the function indicates that the link identifier was not
  193. * found.
  194. *
  195. * Get the link identifier from a given Basic variant Multi-Link element or
  196. * element fragment sequence, of the AP that transmits the Multi-Link
  197. * element/element fragment sequence or the nontransmitted BSSID in the same
  198. * multiple BSSID set as the AP that transmits the Multi-Link element/element
  199. * fragment sequence and that is affiliated with the MLD that is described in
  200. * the Multi-Link element.
  201. *
  202. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  203. * the reason for error in the case of failure
  204. */
  205. QDF_STATUS
  206. util_get_bvmlie_primary_linkid(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  207. bool *linkidfound, uint8_t *linkid);
  208. /**
  209. * util_get_mlie_common_info_len() - Get the MLD common info len
  210. * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
  211. * fragment sequence
  212. * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  213. * fragment sequence
  214. * @commoninfo_len: Pointer to the location where the value of the MLD common
  215. * info len should be updated. This should be ignored by the caller if the
  216. * function returns error.
  217. *
  218. * Get the MLD common info len from Multi-Link element transmitted by the AP.
  219. *
  220. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  221. * the reason for error in the case of failure
  222. */
  223. QDF_STATUS
  224. util_get_mlie_common_info_len(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  225. uint8_t *commoninfo_len);
  226. /**
  227. * util_get_bvmlie_bssparamchangecnt() - Get the MLD BSS PARAM Change Count
  228. * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
  229. * fragment sequence
  230. * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  231. * fragment sequence
  232. * @bssparamchangecntfound: Pointer to the location where a boolean status
  233. * should be updated indicating whether the MLD BSS PARAM Change Count was
  234. * found or not. This should be ignored by the caller if the function
  235. * returns error.
  236. * @bssparamchangecnt: Pointer to the location where the value of the MLD BSS
  237. * PARAM Change Count should be updated. This should be ignored by the caller
  238. * if the function returns error, or if the function indicates that the MLD
  239. * BSS PARAM Change Count was not found.
  240. *
  241. * Get the MLD BSS PARAM Change Count from Multi-Link element transmitted
  242. * by the AP.
  243. *
  244. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  245. * the reason for error in the case of failure
  246. */
  247. QDF_STATUS
  248. util_get_bvmlie_bssparamchangecnt(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  249. bool *bssparamchangecntfound,
  250. uint8_t *bssparamchangecnt);
  251. /**
  252. * util_get_bvmlie_mldcap() - Get the MLD capabilities
  253. * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
  254. * fragment sequence
  255. * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  256. * fragment sequence
  257. * @mldcapfound: Pointer to the location where a boolean status should be
  258. * updated indicating whether the MLD capabilities was found or not. This should
  259. * be ignored by the caller if the function returns error.
  260. * @mldcap: Pointer to the location where the value of the MLD capabilities
  261. * should be updated. This should be ignored by the caller if the function
  262. * returns error, or if the function indicates that the MLD capabilities was not
  263. * found.
  264. *
  265. * Get the MLD capabilities from a given Basic variant Multi-Link element or
  266. * element fragment sequence, of the AP that transmits the Multi-Link
  267. * element/element fragment sequence or the nontransmitted BSSID in the same
  268. * multiple BSSID set as the AP that transmits the Multi-Link element/element
  269. * fragment sequence and that is affiliated with the MLD that is described in
  270. * the Multi-Link element.
  271. *
  272. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  273. * the reason for error in the case of failure
  274. */
  275. QDF_STATUS
  276. util_get_bvmlie_mldcap(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  277. bool *mldcapfound, uint16_t *mldcap);
  278. /**
  279. * util_get_bvmlie_persta_partner_info() - Get per-STA partner link information
  280. * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
  281. * fragment sequence
  282. * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  283. * fragment sequence
  284. * @partner_info: Pointer to the location where the partner link information
  285. * should be updated. This should be ignored by the caller if the function
  286. * returns error. Note that success will be returned and the number of links in
  287. * this structure will be reported as 0, if no Link Info is found, or no per-STA
  288. * profile is found, or if none of the per-STA profiles includes a MAC address
  289. * in the STA Info field (assuming no errors are encountered).
  290. *
  291. * Get partner link information in the per-STA profiles present in a Basic
  292. * variant Multi-Link element. The partner link information is returned only for
  293. * those per-STA profiles which have a MAC address in the STA Info field.
  294. *
  295. * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
  296. * the reason for error in the case of failure
  297. */
  298. QDF_STATUS
  299. util_get_bvmlie_persta_partner_info(uint8_t *mlieseq,
  300. qdf_size_t mlieseqlen,
  301. struct mlo_partner_info *partner_info);
  302. #else
  303. static inline QDF_STATUS
  304. util_gen_link_assoc_req(uint8_t *frame, qdf_size_t frame_len, bool isreassoc,
  305. struct qdf_mac_addr link_addr,
  306. uint8_t *link_frame,
  307. qdf_size_t link_frame_maxsize,
  308. qdf_size_t *link_frame_len)
  309. {
  310. return QDF_STATUS_E_NOSUPPORT;
  311. }
  312. static inline QDF_STATUS
  313. util_gen_link_assoc_rsp(uint8_t *frame, qdf_size_t frame_len, bool isreassoc,
  314. struct qdf_mac_addr link_addr,
  315. uint8_t *link_frame,
  316. qdf_size_t link_frame_maxsize,
  317. qdf_size_t *link_frame_len)
  318. {
  319. return QDF_STATUS_E_NOSUPPORT;
  320. }
  321. static inline QDF_STATUS
  322. util_find_mlie(uint8_t *buf, qdf_size_t buflen, uint8_t **mlieseq,
  323. qdf_size_t *mlieseqlen)
  324. {
  325. return QDF_STATUS_E_NOSUPPORT;
  326. }
  327. static inline QDF_STATUS
  328. util_get_mlie_variant(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  329. int *variant)
  330. {
  331. return QDF_STATUS_E_NOSUPPORT;
  332. }
  333. static inline QDF_STATUS
  334. util_get_mlie_common_info_len(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  335. uint8_t *commoninfo_len)
  336. {
  337. return QDF_STATUS_E_NOSUPPORT;
  338. }
  339. static inline QDF_STATUS
  340. util_get_bvmlie_bssparamchangecnt(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  341. bool *bssparamchangecntfound,
  342. uint8_t *bssparamchangecnt)
  343. {
  344. return QDF_STATUS_E_NOSUPPORT;
  345. }
  346. static inline QDF_STATUS
  347. util_get_bvmlie_mldmacaddr(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  348. struct qdf_mac_addr *mldmacaddr)
  349. {
  350. return QDF_STATUS_E_NOSUPPORT;
  351. }
  352. static inline QDF_STATUS
  353. util_get_bvmlie_eml_cap(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  354. bool *eml_cap_found,
  355. uint16_t *eml_cap)
  356. {
  357. return QDF_STATUS_E_NOSUPPORT;
  358. }
  359. static inline QDF_STATUS
  360. util_get_bvmlie_primary_linkid(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  361. bool *linkidfound, uint8_t *linkid)
  362. {
  363. return QDF_STATUS_E_NOSUPPORT;
  364. }
  365. static inline QDF_STATUS
  366. util_get_bvmlie_persta_partner_info(uint8_t *mlieseq,
  367. qdf_size_t mlieseqlen,
  368. struct mlo_partner_info *partner_info)
  369. {
  370. return QDF_STATUS_E_NOSUPPORT;
  371. }
  372. #endif /* WLAN_FEATURE_11BE_MLO */
  373. #endif /* _WLAN_UTILS_MLO_H_ */