dp_txrx_wds.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. /*
  2. * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _DP_TXRX_WDS_H_
  19. #define _DP_TXRX_WDS_H_
  20. /* WDS AST entry aging timer value */
  21. #define DP_WDS_AST_AGING_TIMER_DEFAULT_MS 120000
  22. #define DP_WDS_AST_AGING_TIMER_CNT \
  23. ((DP_WDS_AST_AGING_TIMER_DEFAULT_MS / DP_AST_AGING_TIMER_DEFAULT_MS) - 1)
  24. void dp_soc_wds_attach(struct dp_soc *soc);
  25. void dp_soc_wds_detach(struct dp_soc *soc);
  26. void
  27. dp_rx_da_learn(struct dp_soc *soc,
  28. uint8_t *rx_tlv_hdr,
  29. struct dp_peer *ta_peer,
  30. qdf_nbuf_t nbuf);
  31. void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status);
  32. #ifdef FEATURE_WDS
  33. static inline bool dp_tx_da_search_override(struct dp_vdev *vdev)
  34. {
  35. struct dp_soc *soc = vdev->pdev->soc;
  36. /*
  37. * If AST index override support is available (HKv2 etc),
  38. * DA search flag be enabled always
  39. *
  40. * If AST index override support is not available (HKv1),
  41. * DA search flag should be used for all modes except QWRAP
  42. */
  43. if (soc->ast_override_support || !vdev->proxysta_vdev)
  44. return true;
  45. return false;
  46. }
  47. #endif
  48. #ifdef WDS_VENDOR_EXTENSION
  49. void
  50. dp_txrx_peer_wds_tx_policy_update(struct cdp_soc_t *cdp_soc, uint8_t vdev_id,
  51. uint8_t *peer_mac, int wds_tx_ucast,
  52. int wds_tx_mcast)
  53. void
  54. dp_txrx_set_wds_rx_policy(struct cdp_soc_t *cdp_soc, uint8_t vdev_id,
  55. u_int32_t val);
  56. #endif
  57. /**
  58. * dp_rx_wds_add_or_update_ast() - Add or update the ast entry.
  59. *
  60. * @soc: core txrx main context
  61. * @ta_peer: WDS repeater peer
  62. * @mac_addr: mac address of the peer
  63. * @is_ad4_valid: 4-address valid flag
  64. * @is_sa_valid: source address valid flag
  65. * @is_chfrag_start: frag start flag
  66. * @sa_idx: source-address index for peer
  67. * @sa_sw_peer_id: software source-address peer-id
  68. *
  69. * Return: void:
  70. */
  71. static inline void
  72. dp_rx_wds_add_or_update_ast(struct dp_soc *soc, struct dp_peer *ta_peer,
  73. qdf_nbuf_t nbuf, uint8_t is_ad4_valid,
  74. uint8_t is_sa_valid, uint8_t is_chfrag_start,
  75. uint16_t sa_idx, uint16_t sa_sw_peer_id)
  76. {
  77. struct dp_peer *sa_peer;
  78. struct dp_ast_entry *ast;
  79. uint32_t flags = IEEE80211_NODE_F_WDS_HM;
  80. uint32_t ret = 0;
  81. struct dp_neighbour_peer *neighbour_peer = NULL;
  82. struct dp_pdev *pdev = ta_peer->vdev->pdev;
  83. uint8_t wds_src_mac[QDF_MAC_ADDR_SIZE];
  84. /* For AP mode : Do wds source port learning only if it is a
  85. * 4-address mpdu
  86. *
  87. * For STA mode : Frames from RootAP backend will be in 3-address mode,
  88. * till RootAP does the WDS source port learning; Hence in repeater/STA
  89. * mode, we enable learning even in 3-address mode , to avoid RootAP
  90. * backbone getting wrongly learnt as MEC on repeater
  91. */
  92. if (ta_peer->vdev->opmode != wlan_op_mode_sta) {
  93. if (!(is_chfrag_start && is_ad4_valid))
  94. return;
  95. } else {
  96. /* For HKv2 Source port learing is not needed in STA mode
  97. * as we have support in HW
  98. *
  99. * if sa_valid bit is set there is a AST entry added on AP VAP
  100. * and this peer has roamed behind ROOT AP in this case proceed
  101. * further to check for roaming
  102. */
  103. if (soc->ast_override_support && !is_sa_valid)
  104. return;
  105. }
  106. if (qdf_unlikely(!is_sa_valid)) {
  107. qdf_mem_copy(wds_src_mac,
  108. (qdf_nbuf_data(nbuf) + QDF_MAC_ADDR_SIZE),
  109. QDF_MAC_ADDR_SIZE);
  110. ret = dp_peer_add_ast(soc,
  111. ta_peer,
  112. wds_src_mac,
  113. CDP_TXRX_AST_TYPE_WDS,
  114. flags);
  115. return;
  116. }
  117. qdf_spin_lock_bh(&soc->ast_lock);
  118. ast = soc->ast_table[sa_idx];
  119. qdf_spin_unlock_bh(&soc->ast_lock);
  120. if (!ast) {
  121. /*
  122. * In HKv1, it is possible that HW retains the AST entry in
  123. * GSE cache on 1 radio , even after the AST entry is deleted
  124. * (on another radio).
  125. *
  126. * Due to this, host might still get sa_is_valid indications
  127. * for frames with SA not really present in AST table.
  128. *
  129. * So we go ahead and send an add_ast command to FW in such
  130. * cases where sa is reported still as valid, so that FW will
  131. * invalidate this GSE cache entry and new AST entry gets
  132. * cached.
  133. */
  134. if (!soc->ast_override_support) {
  135. qdf_mem_copy(wds_src_mac,
  136. (qdf_nbuf_data(nbuf) + QDF_MAC_ADDR_SIZE),
  137. QDF_MAC_ADDR_SIZE);
  138. ret = dp_peer_add_ast(soc,
  139. ta_peer,
  140. wds_src_mac,
  141. CDP_TXRX_AST_TYPE_WDS,
  142. flags);
  143. return;
  144. } else {
  145. /* In HKv2 smart monitor case, when NAC client is
  146. * added first and this client roams within BSS to
  147. * connect to RE, since we have an AST entry for
  148. * NAC we get sa_is_valid bit set. So we check if
  149. * smart monitor is enabled and send add_ast command
  150. * to FW.
  151. */
  152. if (pdev->neighbour_peers_added) {
  153. qdf_mem_copy(wds_src_mac,
  154. (qdf_nbuf_data(nbuf) +
  155. QDF_MAC_ADDR_SIZE),
  156. QDF_MAC_ADDR_SIZE);
  157. qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
  158. TAILQ_FOREACH(neighbour_peer,
  159. &pdev->neighbour_peers_list,
  160. neighbour_peer_list_elem) {
  161. if (!qdf_mem_cmp(&neighbour_peer->neighbour_peers_macaddr,
  162. wds_src_mac,
  163. QDF_MAC_ADDR_SIZE)) {
  164. ret = dp_peer_add_ast(soc,
  165. ta_peer,
  166. wds_src_mac,
  167. CDP_TXRX_AST_TYPE_WDS,
  168. flags);
  169. QDF_TRACE(QDF_MODULE_ID_DP,
  170. QDF_TRACE_LEVEL_INFO,
  171. "sa valid and nac roamed to wds");
  172. break;
  173. }
  174. }
  175. qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
  176. }
  177. return;
  178. }
  179. }
  180. if ((ast->type == CDP_TXRX_AST_TYPE_WDS_HM) ||
  181. (ast->type == CDP_TXRX_AST_TYPE_WDS_HM_SEC))
  182. return;
  183. /*
  184. * Ensure we are updating the right AST entry by
  185. * validating ast_idx.
  186. * There is a possibility we might arrive here without
  187. * AST MAP event , so this check is mandatory
  188. */
  189. if (ast->is_mapped && (ast->ast_idx == sa_idx))
  190. ast->is_active = TRUE;
  191. if (sa_sw_peer_id != ta_peer->peer_ids[0]) {
  192. sa_peer = ast->peer;
  193. if ((ast->type != CDP_TXRX_AST_TYPE_STATIC) &&
  194. (ast->type != CDP_TXRX_AST_TYPE_SELF) &&
  195. (ast->type != CDP_TXRX_AST_TYPE_STA_BSS)) {
  196. if (ast->pdev_id != ta_peer->vdev->pdev->pdev_id) {
  197. /* This case is when a STA roams from one
  198. * repeater to another repeater, but these
  199. * repeaters are connected to root AP on
  200. * different radios.
  201. * Ex: rptr1 connected to ROOT AP over 5G
  202. * and rptr2 connected to ROOT AP over 2G
  203. * radio
  204. */
  205. qdf_spin_lock_bh(&soc->ast_lock);
  206. dp_peer_del_ast(soc, ast);
  207. qdf_spin_unlock_bh(&soc->ast_lock);
  208. } else {
  209. /* this case is when a STA roams from one
  210. * reapter to another repeater, but inside
  211. * same radio.
  212. */
  213. qdf_spin_lock_bh(&soc->ast_lock);
  214. /* For HKv2 do not update the AST entry if
  215. * new ta_peer is on STA vap as SRC port
  216. * learning is disable on STA vap
  217. */
  218. if (soc->ast_override_support &&
  219. (ta_peer->vdev->opmode == wlan_op_mode_sta))
  220. dp_peer_del_ast(soc, ast);
  221. else
  222. dp_peer_update_ast(soc, ta_peer, ast, flags);
  223. qdf_spin_unlock_bh(&soc->ast_lock);
  224. return;
  225. }
  226. }
  227. /*
  228. * Do not kickout STA if it belongs to a different radio.
  229. * For DBDC repeater, it is possible to arrive here
  230. * for multicast loopback frames originated from connected
  231. * clients and looped back (intrabss) by Root AP
  232. */
  233. if (ast->pdev_id != ta_peer->vdev->pdev->pdev_id) {
  234. return;
  235. }
  236. /*
  237. * Kickout, when direct associated peer(SA) roams
  238. * to another AP and reachable via TA peer
  239. */
  240. if ((sa_peer->vdev->opmode == wlan_op_mode_ap) &&
  241. !sa_peer->delete_in_progress) {
  242. sa_peer->delete_in_progress = true;
  243. if (soc->cdp_soc.ol_ops->peer_sta_kickout) {
  244. soc->cdp_soc.ol_ops->peer_sta_kickout(
  245. soc->ctrl_psoc,
  246. sa_peer->vdev->pdev->pdev_id,
  247. wds_src_mac);
  248. }
  249. }
  250. }
  251. }
  252. /**
  253. * dp_rx_wds_srcport_learn() - Add or update the STA PEER which
  254. * is behind the WDS repeater.
  255. *
  256. * @soc: core txrx main context
  257. * @rx_tlv_hdr: base address of RX TLV header
  258. * @ta_peer: WDS repeater peer
  259. * @nbuf: rx pkt
  260. *
  261. * Return: void:
  262. */
  263. static inline void
  264. dp_rx_wds_srcport_learn(struct dp_soc *soc,
  265. uint8_t *rx_tlv_hdr,
  266. struct dp_peer *ta_peer,
  267. qdf_nbuf_t nbuf)
  268. {
  269. uint16_t sa_sw_peer_id = hal_rx_msdu_end_sa_sw_peer_id_get(soc->hal_soc, rx_tlv_hdr);
  270. uint8_t sa_is_valid = hal_rx_msdu_end_sa_is_valid_get(soc->hal_soc, rx_tlv_hdr);
  271. uint16_t sa_idx;
  272. uint8_t is_chfrag_start = 0;
  273. uint8_t is_ad4_valid = 0;
  274. if (qdf_unlikely(!ta_peer))
  275. return;
  276. is_chfrag_start = qdf_nbuf_is_rx_chfrag_start(nbuf);
  277. if (is_chfrag_start)
  278. is_ad4_valid = hal_rx_get_mpdu_mac_ad4_valid(soc->hal_soc, rx_tlv_hdr);
  279. /*
  280. * Get the AST entry from HW SA index and mark it as active
  281. */
  282. sa_idx = hal_rx_msdu_end_sa_idx_get(soc->hal_soc, rx_tlv_hdr);
  283. dp_rx_wds_add_or_update_ast(soc, ta_peer, nbuf, is_ad4_valid,
  284. sa_is_valid, is_chfrag_start,
  285. sa_idx, sa_sw_peer_id);
  286. }
  287. /*
  288. * dp_rx_ast_set_active() - set the active flag of the astentry
  289. * corresponding to a hw index.
  290. * @soc: core txrx main context
  291. * @sa_idx: hw idx
  292. * @is_active: active flag
  293. *
  294. */
  295. static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc,
  296. uint16_t sa_idx, bool is_active)
  297. {
  298. struct dp_ast_entry *ast;
  299. qdf_spin_lock_bh(&soc->ast_lock);
  300. ast = soc->ast_table[sa_idx];
  301. /*
  302. * Ensure we are updating the right AST entry by
  303. * validating ast_idx.
  304. * There is a possibility we might arrive here without
  305. * AST MAP event , so this check is mandatory
  306. */
  307. if (ast && ast->is_mapped && (ast->ast_idx == sa_idx)) {
  308. ast->is_active = is_active;
  309. qdf_spin_unlock_bh(&soc->ast_lock);
  310. return QDF_STATUS_SUCCESS;
  311. }
  312. qdf_spin_unlock_bh(&soc->ast_lock);
  313. return QDF_STATUS_E_FAILURE;
  314. }
  315. #endif /* DP_TXRX_WDS*/