wlan_mlo_epcs.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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. #ifndef _WLAN_MLO_EPCS_H_
  20. #define _WLAN_MLO_EPCS_H_
  21. #include <wlan_cmn_ieee80211.h>
  22. #include <wlan_mlo_mgr_public_structs.h>
  23. #ifdef WMI_AP_SUPPORT
  24. #include <wlan_cmn.h>
  25. #endif
  26. struct wlan_mlo_peer_context;
  27. /**
  28. * enum wlan_epcs_category - epcs category
  29. *
  30. * @WLAN_EPCS_CATEGORY_NONE: none
  31. * @WLAN_EPCS_CATEGORY_REQUEST: EPCS request
  32. * @WLAN_EPCS_CATEGORY_RESPONSE: EPCS response
  33. * @WLAN_EPCS_CATEGORY_TEARDOWN: EPCS teardown
  34. * @WLAN_EPCS_CATEGORY_INVALID: Invalid
  35. */
  36. enum wlan_epcs_category {
  37. WLAN_EPCS_CATEGORY_NONE = 0,
  38. WLAN_EPCS_CATEGORY_REQUEST = 3,
  39. WLAN_EPCS_CATEGORY_RESPONSE = 4,
  40. WLAN_EPCS_CATEGORY_TEARDOWN = 5,
  41. WLAN_EPCS_CATEGORY_INVALID,
  42. };
  43. /**
  44. * struct ml_pa_partner_link_info - Priority Access ML partner information
  45. * @link_id: Link ID
  46. * @edca_ie_present: EDCA IE present
  47. * @muedca_ie_present: MU EDCA IE present
  48. * @ven_wme_ie_present: WME IE present
  49. * @edca: EDCA IE
  50. * @muedca: MU EDCA IE
  51. * @ven_wme_ie_bytes: WME IE
  52. */
  53. struct ml_pa_partner_link_info {
  54. uint8_t link_id;
  55. uint8_t edca_ie_present:1,
  56. muedca_ie_present:1,
  57. ven_wme_ie_present:1;
  58. union {
  59. struct edca_ie edca;
  60. uint8_t ven_wme_ie_bytes[WLAN_VENDOR_WME_IE_LEN + 2];
  61. };
  62. struct muedca_ie muedca;
  63. };
  64. /**
  65. * struct ml_pa_info - priority access ML info
  66. * @mld_mac_addr: MLD mac address
  67. * @num_links: Number of Links
  68. * @link_info: Partner link information
  69. */
  70. struct ml_pa_info {
  71. struct qdf_mac_addr mld_mac_addr;
  72. uint8_t num_links;
  73. struct ml_pa_partner_link_info link_info[WLAN_UMAC_MLO_MAX_VDEVS];
  74. };
  75. /**
  76. * struct wlan_epcs_info - EPCS information of frame
  77. * @cat: frame category
  78. * @dialog_token: dialog token
  79. * @status: status
  80. * @pa_info: Priority access ML info
  81. */
  82. struct wlan_epcs_info {
  83. enum wlan_epcs_category cat;
  84. uint8_t dialog_token;
  85. uint16_t status;
  86. struct ml_pa_info pa_info;
  87. };
  88. /**
  89. * enum peer_epcs_state - epcs stat of peer
  90. * @EPCS_DOWN: EPCS state down
  91. * @EPCS_ENABLE: EPCS state enabled
  92. */
  93. enum peer_epcs_state {
  94. EPCS_DOWN,
  95. EPCS_ENABLE
  96. };
  97. /**
  98. * struct wlan_mlo_peer_epcs_info - Peer EPCS information
  99. * @state: EPCS state of peer
  100. * @self_gen_dialog_token: selfgenerated dialog token
  101. */
  102. struct wlan_mlo_peer_epcs_info {
  103. enum peer_epcs_state state;
  104. uint8_t self_gen_dialog_token;
  105. };
  106. #define EPCS_MAX_AUTHORIZE_MAC_ADDR 32
  107. /**
  108. * struct epcs_peer_authorize_info - EPCS authorized mac addresses
  109. * @valid: valid index if set t0 true
  110. * @peer_mld_mac: mld mac address
  111. */
  112. struct epcs_peer_authorize_info {
  113. bool valid;
  114. uint8_t peer_mld_mac[QDF_MAC_ADDR_SIZE];
  115. };
  116. /**
  117. * struct wlan_epcs_context - EPCS context if MLD
  118. * @epcs_dev_lock: epcs dev context lock
  119. * @authorize_info: Array of Authorization info containing peer mac address
  120. */
  121. struct wlan_epcs_context {
  122. #ifdef WLAN_MLO_USE_SPINLOCK
  123. qdf_spinlock_t epcs_dev_lock;
  124. #else
  125. qdf_mutex_t epcs_dev_lock;
  126. #endif
  127. struct epcs_peer_authorize_info
  128. authorize_info[EPCS_MAX_AUTHORIZE_MAC_ADDR];
  129. };
  130. /**
  131. * struct epcs_frm - EPCS action frame format
  132. * @category: category
  133. * @protected_eht_action: Protected EHT Action
  134. * @dialog_token: Dialog Token
  135. * @status_code: Status Code
  136. * @req: Request frame
  137. * @resp: Response frame
  138. * @bytes: Priority Access Multi-Link element bytes
  139. */
  140. struct epcs_frm {
  141. uint8_t category;
  142. uint8_t protected_eht_action;
  143. uint8_t dialog_token;
  144. union {
  145. struct {
  146. uint8_t bytes[0];
  147. } req;
  148. struct {
  149. uint8_t status_code[2];
  150. uint8_t bytes[0];
  151. } resp;
  152. };
  153. };
  154. /* MIN EPCS request frame length */
  155. #define EPCS_REQ_MIN_LENGTH 3
  156. /* MIN EPCS response frame length */
  157. #define EPCS_RESP_MIN_LENGTH 5
  158. #define epcs_alert(format, args...) \
  159. QDF_TRACE_FATAL(QDF_MODULE_ID_EPCS, format, ## args)
  160. #define epcs_err(format, args...) \
  161. QDF_TRACE_ERROR(QDF_MODULE_ID_EPCS, format, ## args)
  162. #define epcs_warn(format, args...) \
  163. QDF_TRACE_WARN(QDF_MODULE_ID_EPCS, format, ## args)
  164. #define epcs_info(format, args...) \
  165. QDF_TRACE_INFO(QDF_MODULE_ID_EPCS, format, ## args)
  166. #define epcs_debug(format, args...) \
  167. QDF_TRACE_DEBUG(QDF_MODULE_ID_EPCS, format, ## args)
  168. #define epcs_rl_debug(format, args...) \
  169. QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_EPCS, format, ## args)
  170. #ifdef WLAN_MLO_USE_SPINLOCK
  171. /**
  172. * epcs_dev_lock_create - Create EPCS device mutex/spinlock
  173. * @epcs_ctx: EPCS context
  174. *
  175. * Creates mutex/spinlock
  176. *
  177. * Return: void
  178. */
  179. static inline void
  180. epcs_dev_lock_create(struct wlan_epcs_context *epcs_ctx)
  181. {
  182. qdf_spinlock_create(&epcs_ctx->epcs_dev_lock);
  183. }
  184. /**
  185. * epcs_dev_lock_destroy - Destroy EPCS mutex/spinlock
  186. * @epcs_ctx: EPCS context
  187. *
  188. * Destroy mutex/spinlock
  189. *
  190. * Return: void
  191. */
  192. static inline void
  193. epcs_dev_lock_destroy(struct wlan_epcs_context *epcs_ctx)
  194. {
  195. qdf_spinlock_destroy(&epcs_ctx->epcs_dev_lock);
  196. }
  197. /**
  198. * epcs_dev_lock_acquire - acquire EPCS mutex/spinlock
  199. * @epcs_ctx: EPCS context
  200. *
  201. * acquire mutex/spinlock
  202. *
  203. * return: void
  204. */
  205. static inline
  206. void epcs_dev_lock_acquire(struct wlan_epcs_context *epcs_ctx)
  207. {
  208. qdf_spin_lock_bh(&epcs_ctx->epcs_dev_lock);
  209. }
  210. /**
  211. * epcs_dev_lock_release - release EPCS dev mutex/spinlock
  212. * @epcs_ctx: EPCS context
  213. *
  214. * release mutex/spinlock
  215. *
  216. * return: void
  217. */
  218. static inline
  219. void epcs_dev_lock_release(struct wlan_epcs_context *epcs_ctx)
  220. {
  221. qdf_spin_unlock_bh(&epcs_ctx->epcs_dev_lock);
  222. }
  223. #else /* WLAN_MLO_USE_SPINLOCK */
  224. static inline
  225. void epcs_dev_lock_create(struct wlan_epcs_context *epcs_ctx)
  226. {
  227. qdf_mutex_create(&epcs_ctx->epcs_dev_lock);
  228. }
  229. static inline
  230. void epcs_dev_lock_destroy(struct wlan_epcs_context *epcs_ctx)
  231. {
  232. qdf_mutex_destroy(&epcs_ctx->epcs_dev_lock);
  233. }
  234. static inline void epcs_dev_lock_acquire(struct wlan_epcs_context *epcs_ctx)
  235. {
  236. qdf_mutex_acquire(&epcs_ctx->epcs_dev_lock);
  237. }
  238. static inline void epcs_dev_lock_release(struct wlan_epcs_context *epcs_ctx)
  239. {
  240. qdf_mutex_release(&epcs_ctx->epcs_dev_lock);
  241. }
  242. #endif
  243. /**
  244. * wlan_mlo_add_epcs_action_frame() - API to add EPCS action frame
  245. * @frm: Pointer to a frame to add EPCS information
  246. * @args: EPCS action frame related info
  247. * @buf: Pointer to EPCS IE values
  248. *
  249. * Return: Pointer to the updated frame buffer
  250. */
  251. uint8_t *wlan_mlo_add_epcs_action_frame(uint8_t *frm,
  252. struct wlan_action_frame_args *args,
  253. uint8_t *buf);
  254. /**
  255. * wlan_mlo_parse_epcs_action_frame() - API to parse EPCS action frame
  256. * @epcs: Pointer to EPCS information
  257. * @action_frm: EPCS action frame
  258. * @frm_len: frame length
  259. *
  260. * Return: QDF_STATUS
  261. */
  262. QDF_STATUS
  263. wlan_mlo_parse_epcs_action_frame(struct wlan_epcs_info *epcs,
  264. struct wlan_action_frame *action_frm,
  265. uint32_t frm_len);
  266. /**
  267. * wlan_mlo_peer_rcv_cmd() - API to process EPCS command
  268. * @ml_peer: Pointer to ML peer received
  269. * @epcs: Pointer to EPCS information
  270. * @updparam: pointer to fill update parameters
  271. *
  272. * Return: QDF_STATUS
  273. */
  274. QDF_STATUS
  275. wlan_mlo_peer_rcv_cmd(struct wlan_mlo_peer_context *ml_peer,
  276. struct wlan_epcs_info *epcs,
  277. bool *updparam);
  278. /**
  279. * wlan_mlo_peer_rcv_action_frame() - API to process EPCS frame receive event
  280. * @ml_peer: Pointer to ML peer received
  281. * @epcs: Pointer to EPCS information
  282. * @respond: pointer to fill response required or not
  283. * @updparam: pointer to fill update parameters
  284. *
  285. * Return: QDF_STATUS
  286. */
  287. QDF_STATUS
  288. wlan_mlo_peer_rcv_action_frame(struct wlan_mlo_peer_context *ml_peer,
  289. struct wlan_epcs_info *epcs,
  290. bool *respond,
  291. bool *updparam);
  292. /**
  293. * wlan_mlo_update_authorize_epcs_mac_addr() - API to authorize mac addr
  294. * @vdev: pointer to vdev
  295. * @peer_mld_mac: mld mac address
  296. *
  297. * Return: QDF_STATUS
  298. */
  299. QDF_STATUS
  300. wlan_mlo_update_authorize_epcs_mac_addr(struct wlan_objmgr_vdev *vdev,
  301. uint8_t *peer_mld_mac);
  302. /**
  303. * wlan_mlo_update_deauthorize_epcs_mac_addr() - API to deauthorize mac addr
  304. * @vdev: pointer to vdev
  305. * @peer_mld_mac: mld mac address
  306. *
  307. * Return: QDF_STATUS
  308. */
  309. QDF_STATUS
  310. wlan_mlo_update_deauthorize_epcs_mac_addr(struct wlan_objmgr_vdev *vdev,
  311. uint8_t *peer_mld_mac);
  312. #endif /* _WLAN_MLO_EPCS_H_ */