dp_txrx_wds.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. /*
  2. * Copyright (c) 2016-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
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef _DP_TXRX_WDS_H_
  20. #define _DP_TXRX_WDS_H_
  21. #ifdef WIFI_MONITOR_SUPPORT
  22. #include "dp_htt.h"
  23. #include "dp_mon.h"
  24. #endif
  25. /* host managed flag */
  26. #define DP_AST_FLAGS_HM 0x0020
  27. /* WDS AST entry aging timer value */
  28. #define DP_WDS_AST_AGING_TIMER_DEFAULT_MS 120000
  29. #define DP_WDS_AST_AGING_TIMER_CNT \
  30. ((DP_WDS_AST_AGING_TIMER_DEFAULT_MS / DP_AST_AGING_TIMER_DEFAULT_MS) - 1)
  31. void dp_soc_wds_attach(struct dp_soc *soc);
  32. void dp_soc_wds_detach(struct dp_soc *soc);
  33. #ifdef QCA_PEER_MULTIQ_SUPPORT
  34. int dp_peer_find_ast_index_by_flowq_id(struct cdp_soc_t *soc,
  35. uint16_t vdev_id, uint8_t *peer_mac_addr,
  36. uint8_t flow_id, uint8_t tid);
  37. #endif
  38. void
  39. dp_rx_da_learn(struct dp_soc *soc,
  40. uint8_t *rx_tlv_hdr,
  41. struct dp_txrx_peer *ta_peer,
  42. qdf_nbuf_t nbuf);
  43. void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status);
  44. #ifdef FEATURE_WDS
  45. #ifdef FEATURE_MCL_REPEATER
  46. static inline bool dp_tx_da_search_override(struct dp_vdev *vdev)
  47. {
  48. if (vdev->mec_enabled)
  49. return true;
  50. return false;
  51. }
  52. #else
  53. static inline bool dp_tx_da_search_override(struct dp_vdev *vdev)
  54. {
  55. struct dp_soc *soc = vdev->pdev->soc;
  56. /*
  57. * If AST index override support is available (HKv2 etc),
  58. * DA search flag be enabled always
  59. *
  60. * If AST index override support is not available (HKv1),
  61. * DA search flag should be used for all modes except QWRAP
  62. */
  63. if (soc->ast_override_support || !vdev->proxysta_vdev)
  64. return true;
  65. return false;
  66. }
  67. #endif /* FEATURE_MCL_REPEATER */
  68. #endif /* FEATURE_WDS */
  69. #ifdef WDS_VENDOR_EXTENSION
  70. QDF_STATUS
  71. dp_txrx_peer_wds_tx_policy_update(struct cdp_soc_t *cdp_soc, uint8_t vdev_id,
  72. uint8_t *peer_mac, int wds_tx_ucast,
  73. int wds_tx_mcast);
  74. QDF_STATUS
  75. dp_txrx_set_wds_rx_policy(struct cdp_soc_t *cdp_soc, uint8_t vdev_id,
  76. u_int32_t val);
  77. #endif
  78. /**
  79. * dp_hmwds_ast_add_notify() - schedules hmwds ast add status work
  80. * @peer: DP peer
  81. * @mac_addr: ast mac addr
  82. * @type: ast type
  83. * @err: QDF_STATUS error code
  84. * @is_peer_map: notify is from peer map
  85. *
  86. * Return: void
  87. */
  88. void dp_hmwds_ast_add_notify(struct dp_peer *peer,
  89. uint8_t *mac_addr,
  90. enum cdp_txrx_ast_entry_type type,
  91. QDF_STATUS err,
  92. bool is_peer_map);
  93. #ifdef QCA_SUPPORT_WDS_EXTENDED
  94. /**
  95. * dp_wds_ext_peer_learn() - function to send event to control
  96. * path on receiving 1st 4-address frame from backhaul.
  97. * @soc: DP soc
  98. * @ta_peer: WDS repeater peer
  99. *
  100. * Return: void
  101. */
  102. static inline void dp_wds_ext_peer_learn(struct dp_soc *soc,
  103. struct dp_peer *ta_peer)
  104. {
  105. uint8_t wds_ext_src_mac[QDF_MAC_ADDR_SIZE];
  106. if (ta_peer->vdev->wds_ext_enabled &&
  107. !qdf_atomic_test_and_set_bit(WDS_EXT_PEER_INIT_BIT,
  108. &ta_peer->txrx_peer->wds_ext.init)) {
  109. qdf_mem_copy(wds_ext_src_mac, &ta_peer->mac_addr.raw[0],
  110. QDF_MAC_ADDR_SIZE);
  111. soc->cdp_soc.ol_ops->rx_wds_ext_peer_learn(
  112. soc->ctrl_psoc,
  113. ta_peer->peer_id,
  114. ta_peer->vdev->vdev_id,
  115. wds_ext_src_mac);
  116. }
  117. }
  118. #else
  119. static inline void dp_wds_ext_peer_learn(struct dp_soc *soc,
  120. struct dp_peer *ta_peer)
  121. {
  122. }
  123. #endif
  124. /**
  125. * dp_rx_wds_add_or_update_ast() - Add or update the ast entry.
  126. *
  127. * @soc: core txrx main context
  128. * @ta_txrx_peer: WDS repeater txrx peer
  129. * @mac_addr: mac address of the peer
  130. * @is_ad4_valid: 4-address valid flag
  131. * @is_sa_valid: source address valid flag
  132. * @is_chfrag_start: frag start flag
  133. * @sa_idx: source-address index for peer
  134. * @sa_sw_peer_id: software source-address peer-id
  135. *
  136. * Return: void:
  137. */
  138. static inline void
  139. dp_rx_wds_add_or_update_ast(struct dp_soc *soc,
  140. struct dp_txrx_peer *ta_peer,
  141. qdf_nbuf_t nbuf, uint8_t is_ad4_valid,
  142. uint8_t is_sa_valid, uint8_t is_chfrag_start,
  143. uint16_t sa_idx, uint16_t sa_sw_peer_id)
  144. {
  145. struct dp_peer *sa_peer;
  146. struct dp_ast_entry *ast;
  147. uint32_t flags = DP_AST_FLAGS_HM;
  148. uint32_t ret = 0;
  149. struct dp_pdev *pdev = ta_peer->vdev->pdev;
  150. uint8_t wds_src_mac[QDF_MAC_ADDR_SIZE];
  151. struct dp_peer *ta_base_peer;
  152. if (!(is_chfrag_start && is_ad4_valid))
  153. return;
  154. if (qdf_unlikely(!is_sa_valid)) {
  155. qdf_mem_copy(wds_src_mac,
  156. (qdf_nbuf_data(nbuf) + QDF_MAC_ADDR_SIZE),
  157. QDF_MAC_ADDR_SIZE);
  158. ta_base_peer = dp_peer_get_ref_by_id(soc, ta_peer->peer_id,
  159. DP_MOD_ID_RX);
  160. if (ta_base_peer) {
  161. if (ta_peer->vdev->opmode == wlan_op_mode_ap)
  162. dp_wds_ext_peer_learn(soc, ta_base_peer);
  163. ret = dp_peer_add_ast(soc, ta_base_peer, wds_src_mac,
  164. CDP_TXRX_AST_TYPE_WDS, flags);
  165. dp_peer_unref_delete(ta_base_peer, DP_MOD_ID_RX);
  166. }
  167. return;
  168. }
  169. qdf_spin_lock_bh(&soc->ast_lock);
  170. ast = soc->ast_table[sa_idx];
  171. if (!ast) {
  172. qdf_spin_unlock_bh(&soc->ast_lock);
  173. /*
  174. * In HKv1, it is possible that HW retains the AST entry in
  175. * GSE cache on 1 radio , even after the AST entry is deleted
  176. * (on another radio).
  177. *
  178. * Due to this, host might still get sa_is_valid indications
  179. * for frames with SA not really present in AST table.
  180. *
  181. * So we go ahead and send an add_ast command to FW in such
  182. * cases where sa is reported still as valid, so that FW will
  183. * invalidate this GSE cache entry and new AST entry gets
  184. * cached.
  185. */
  186. if (!soc->ast_override_support) {
  187. qdf_mem_copy(wds_src_mac,
  188. (qdf_nbuf_data(nbuf) + QDF_MAC_ADDR_SIZE),
  189. QDF_MAC_ADDR_SIZE);
  190. ta_base_peer = dp_peer_get_ref_by_id(soc,
  191. ta_peer->peer_id,
  192. DP_MOD_ID_RX);
  193. if (ta_base_peer) {
  194. ret = dp_peer_add_ast(soc, ta_base_peer,
  195. wds_src_mac,
  196. CDP_TXRX_AST_TYPE_WDS,
  197. flags);
  198. dp_peer_unref_delete(ta_base_peer,
  199. DP_MOD_ID_RX);
  200. }
  201. return;
  202. } else {
  203. /* In HKv2 smart monitor case, when NAC client is
  204. * added first and this client roams within BSS to
  205. * connect to RE, since we have an AST entry for
  206. * NAC we get sa_is_valid bit set. So we check if
  207. * smart monitor is enabled and send add_ast command
  208. * to FW.
  209. */
  210. ta_base_peer = dp_peer_get_ref_by_id(soc,
  211. ta_peer->peer_id,
  212. DP_MOD_ID_RX);
  213. if (ta_base_peer) {
  214. dp_monitor_neighbour_peer_add_ast(pdev,
  215. ta_base_peer,
  216. wds_src_mac,
  217. nbuf,
  218. flags);
  219. dp_peer_unref_delete(ta_base_peer,
  220. DP_MOD_ID_RX);
  221. }
  222. return;
  223. }
  224. }
  225. /*
  226. * Ensure we are updating the right AST entry by
  227. * validating ast_idx.
  228. * There is a possibility we might arrive here without
  229. * AST MAP event , so this check is mandatory
  230. */
  231. if (ast->is_mapped && (ast->ast_idx == sa_idx))
  232. ast->is_active = TRUE;
  233. if (ast->peer_id != ta_peer->peer_id) {
  234. if ((ast->type == CDP_TXRX_AST_TYPE_WDS_HM) ||
  235. (ast->type == CDP_TXRX_AST_TYPE_WDS_HM_SEC)) {
  236. qdf_spin_unlock_bh(&soc->ast_lock);
  237. return;
  238. }
  239. if ((ast->type != CDP_TXRX_AST_TYPE_STATIC) &&
  240. (ast->type != CDP_TXRX_AST_TYPE_SELF) &&
  241. (ast->type != CDP_TXRX_AST_TYPE_STA_BSS)) {
  242. if (ast->pdev_id != ta_peer->vdev->pdev->pdev_id) {
  243. /* This case is when a STA roams from one
  244. * repeater to another repeater, but these
  245. * repeaters are connected to root AP on
  246. * different radios.
  247. * Ex: rptr1 connected to ROOT AP over 5G
  248. * and rptr2 connected to ROOT AP over 2G
  249. * radio
  250. */
  251. dp_peer_del_ast(soc, ast);
  252. } else {
  253. /* this case is when a STA roams from one
  254. * reapter to another repeater, but inside
  255. * same radio.
  256. */
  257. /* For HKv2 do not update the AST entry if
  258. * new ta_peer is on STA vap as SRC port
  259. * learning is disable on STA vap
  260. */
  261. if (soc->ast_override_support &&
  262. (ta_peer->vdev->opmode == wlan_op_mode_sta)) {
  263. dp_peer_del_ast(soc, ast);
  264. } else {
  265. ta_base_peer =
  266. dp_peer_get_ref_by_id(soc,
  267. ta_peer->peer_id,
  268. DP_MOD_ID_RX);
  269. if (ta_base_peer) {
  270. dp_wds_ext_peer_learn(soc,
  271. ta_base_peer);
  272. dp_peer_update_ast(soc,
  273. ta_base_peer,
  274. ast, flags);
  275. dp_peer_unref_delete(ta_base_peer,
  276. DP_MOD_ID_RX);
  277. }
  278. }
  279. qdf_spin_unlock_bh(&soc->ast_lock);
  280. return;
  281. }
  282. }
  283. /*
  284. * Do not kickout STA if it belongs to a different radio.
  285. * For DBDC repeater, it is possible to arrive here
  286. * for multicast loopback frames originated from connected
  287. * clients and looped back (intrabss) by Root AP
  288. */
  289. if (ast->pdev_id != ta_peer->vdev->pdev->pdev_id) {
  290. qdf_spin_unlock_bh(&soc->ast_lock);
  291. return;
  292. }
  293. qdf_spin_unlock_bh(&soc->ast_lock);
  294. /*
  295. * Kickout, when direct associated peer(SA) roams
  296. * to another AP and reachable via TA peer
  297. */
  298. sa_peer = dp_peer_get_ref_by_id(soc, ast->peer_id,
  299. DP_MOD_ID_RX);
  300. if (!sa_peer)
  301. return;
  302. if ((sa_peer->vdev->opmode == wlan_op_mode_ap) &&
  303. !sa_peer->delete_in_progress) {
  304. qdf_mem_copy(wds_src_mac,
  305. (qdf_nbuf_data(nbuf) + QDF_MAC_ADDR_SIZE),
  306. QDF_MAC_ADDR_SIZE);
  307. sa_peer->delete_in_progress = true;
  308. if (soc->cdp_soc.ol_ops->peer_sta_kickout) {
  309. soc->cdp_soc.ol_ops->peer_sta_kickout(
  310. soc->ctrl_psoc,
  311. sa_peer->vdev->pdev->pdev_id,
  312. wds_src_mac);
  313. }
  314. }
  315. dp_peer_unref_delete(sa_peer, DP_MOD_ID_RX);
  316. return;
  317. }
  318. qdf_spin_unlock_bh(&soc->ast_lock);
  319. }
  320. /**
  321. * dp_rx_wds_srcport_learn() - Add or update the STA PEER which
  322. * is behind the WDS repeater.
  323. *
  324. * @soc: core txrx main context
  325. * @rx_tlv_hdr: base address of RX TLV header
  326. * @ta_peer: WDS repeater peer
  327. * @nbuf: rx pkt
  328. *
  329. * Return: void:
  330. */
  331. static inline void
  332. dp_rx_wds_srcport_learn(struct dp_soc *soc,
  333. uint8_t *rx_tlv_hdr,
  334. struct dp_txrx_peer *ta_peer,
  335. qdf_nbuf_t nbuf,
  336. struct hal_rx_msdu_metadata msdu_end_info)
  337. {
  338. uint8_t sa_is_valid = qdf_nbuf_is_sa_valid(nbuf);
  339. uint8_t is_chfrag_start = 0;
  340. uint8_t is_ad4_valid = 0;
  341. if (qdf_unlikely(!ta_peer))
  342. return;
  343. is_chfrag_start = qdf_nbuf_is_rx_chfrag_start(nbuf);
  344. if (is_chfrag_start)
  345. is_ad4_valid = hal_rx_get_mpdu_mac_ad4_valid(soc->hal_soc, rx_tlv_hdr);
  346. /*
  347. * Get the AST entry from HW SA index and mark it as active
  348. */
  349. dp_rx_wds_add_or_update_ast(soc, ta_peer, nbuf, is_ad4_valid,
  350. sa_is_valid, is_chfrag_start,
  351. msdu_end_info.sa_idx, msdu_end_info.sa_sw_peer_id);
  352. }
  353. #ifdef IPA_WDS_EASYMESH_FEATURE
  354. /**
  355. * dp_rx_ipa_wds_srcport_learn() - Add or update the STA PEER which
  356. * is behind the WDS repeater.
  357. *
  358. * @soc: core txrx main context
  359. * @ta_peer: WDS repeater peer
  360. * @nbuf: rx pkt
  361. * @msdu_end_info: msdu end info
  362. * @ad4_valid: address4 valid bit
  363. * @chfrag_start: Msdu start bit
  364. *
  365. * Return: void
  366. */
  367. static inline void
  368. dp_rx_ipa_wds_srcport_learn(struct dp_soc *soc,
  369. struct dp_peer *ta_peer, qdf_nbuf_t nbuf,
  370. struct hal_rx_msdu_metadata msdu_end_info,
  371. bool ad4_valid, bool chfrag_start)
  372. {
  373. uint8_t sa_is_valid = qdf_nbuf_is_sa_valid(nbuf);
  374. uint8_t is_chfrag_start = (uint8_t)chfrag_start;
  375. uint8_t is_ad4_valid = (uint8_t)ad4_valid;
  376. struct dp_txrx_peer *peer = (struct dp_txrx_peer *)ta_peer;
  377. if (qdf_unlikely(!ta_peer))
  378. return;
  379. /*
  380. * Get the AST entry from HW SA index and mark it as active
  381. */
  382. dp_rx_wds_add_or_update_ast(soc, peer, nbuf, is_ad4_valid,
  383. sa_is_valid, is_chfrag_start,
  384. msdu_end_info.sa_idx,
  385. msdu_end_info.sa_sw_peer_id);
  386. }
  387. #endif
  388. /*
  389. * dp_rx_ast_set_active() - set the active flag of the astentry
  390. * corresponding to a hw index.
  391. * @soc: core txrx main context
  392. * @sa_idx: hw idx
  393. * @is_active: active flag
  394. *
  395. */
  396. static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc,
  397. uint16_t sa_idx, bool is_active)
  398. {
  399. struct dp_ast_entry *ast;
  400. qdf_spin_lock_bh(&soc->ast_lock);
  401. ast = soc->ast_table[sa_idx];
  402. if (!ast) {
  403. qdf_spin_unlock_bh(&soc->ast_lock);
  404. return QDF_STATUS_E_NULL_VALUE;
  405. }
  406. if (!ast->is_mapped) {
  407. qdf_spin_unlock_bh(&soc->ast_lock);
  408. return QDF_STATUS_E_INVAL;
  409. }
  410. /*
  411. * Ensure we are updating the right AST entry by
  412. * validating ast_idx.
  413. * There is a possibility we might arrive here without
  414. * AST MAP event , so this check is mandatory
  415. */
  416. if (ast->ast_idx == sa_idx) {
  417. ast->is_active = is_active;
  418. qdf_spin_unlock_bh(&soc->ast_lock);
  419. return QDF_STATUS_SUCCESS;
  420. }
  421. qdf_spin_unlock_bh(&soc->ast_lock);
  422. return QDF_STATUS_E_FAILURE;
  423. }
  424. #endif /* DP_TXRX_WDS*/