dp_txrx_wds.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. /*
  2. * Copyright (c) 2016-2020 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. #ifdef QCA_PEER_MULTIQ_SUPPORT
  27. int dp_peer_find_ast_index_by_flowq_id(struct cdp_soc_t *soc,
  28. uint16_t vdev_id, uint8_t *peer_mac_addr,
  29. uint8_t flow_id, uint8_t tid);
  30. #endif
  31. void
  32. dp_rx_da_learn(struct dp_soc *soc,
  33. uint8_t *rx_tlv_hdr,
  34. struct dp_peer *ta_peer,
  35. qdf_nbuf_t nbuf);
  36. void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status);
  37. #ifdef FEATURE_WDS
  38. static inline bool dp_tx_da_search_override(struct dp_vdev *vdev)
  39. {
  40. struct dp_soc *soc = vdev->pdev->soc;
  41. /*
  42. * If AST index override support is available (HKv2 etc),
  43. * DA search flag be enabled always
  44. *
  45. * If AST index override support is not available (HKv1),
  46. * DA search flag should be used for all modes except QWRAP
  47. */
  48. if (soc->ast_override_support || !vdev->proxysta_vdev)
  49. return true;
  50. return false;
  51. }
  52. #endif
  53. #ifdef WDS_VENDOR_EXTENSION
  54. QDF_STATUS
  55. dp_txrx_peer_wds_tx_policy_update(struct cdp_soc_t *cdp_soc, uint8_t vdev_id,
  56. uint8_t *peer_mac, int wds_tx_ucast,
  57. int wds_tx_mcast);
  58. QDF_STATUS
  59. dp_txrx_set_wds_rx_policy(struct cdp_soc_t *cdp_soc, uint8_t vdev_id,
  60. u_int32_t val);
  61. #endif
  62. /**
  63. * dp_hmwds_ast_add_notify() - schedules hmwds ast add status work
  64. * @peer: DP peer
  65. * @mac_addr: ast mac addr
  66. * @type: ast type
  67. * @err: QDF_STATUS error code
  68. * @is_peer_map: notify is from peer map
  69. *
  70. * Return: void
  71. */
  72. void dp_hmwds_ast_add_notify(struct dp_peer *peer,
  73. uint8_t *mac_addr,
  74. enum cdp_txrx_ast_entry_type type,
  75. QDF_STATUS err,
  76. bool is_peer_map);
  77. #ifdef QCA_SUPPORT_WDS_EXTENDED
  78. /**
  79. * dp_wds_ext_peer_learn() - function to send event to control
  80. * path on receiving 1st 4-address frame from backhaul.
  81. * @soc: DP soc
  82. * @ta_peer: WDS repeater peer
  83. *
  84. * Return: void
  85. */
  86. static inline void dp_wds_ext_peer_learn(struct dp_soc *soc,
  87. struct dp_peer *ta_peer)
  88. {
  89. uint8_t wds_ext_src_mac[QDF_MAC_ADDR_SIZE];
  90. if (ta_peer->vdev->wds_ext_enabled &&
  91. !qdf_atomic_test_and_set_bit(WDS_EXT_PEER_INIT_BIT,
  92. &ta_peer->wds_ext.init)) {
  93. qdf_mem_copy(wds_ext_src_mac, &ta_peer->mac_addr.raw[0],
  94. QDF_MAC_ADDR_SIZE);
  95. soc->cdp_soc.ol_ops->rx_wds_ext_peer_learn(
  96. soc->ctrl_psoc,
  97. ta_peer->peer_id,
  98. ta_peer->vdev->vdev_id,
  99. wds_ext_src_mac);
  100. }
  101. }
  102. #else
  103. static inline void dp_wds_ext_peer_learn(struct dp_soc *soc,
  104. struct dp_peer *ta_peer)
  105. {
  106. }
  107. #endif
  108. /**
  109. * dp_rx_wds_add_or_update_ast() - Add or update the ast entry.
  110. *
  111. * @soc: core txrx main context
  112. * @ta_peer: WDS repeater peer
  113. * @mac_addr: mac address of the peer
  114. * @is_ad4_valid: 4-address valid flag
  115. * @is_sa_valid: source address valid flag
  116. * @is_chfrag_start: frag start flag
  117. * @sa_idx: source-address index for peer
  118. * @sa_sw_peer_id: software source-address peer-id
  119. *
  120. * Return: void:
  121. */
  122. static inline void
  123. dp_rx_wds_add_or_update_ast(struct dp_soc *soc, struct dp_peer *ta_peer,
  124. qdf_nbuf_t nbuf, uint8_t is_ad4_valid,
  125. uint8_t is_sa_valid, uint8_t is_chfrag_start,
  126. uint16_t sa_idx, uint16_t sa_sw_peer_id)
  127. {
  128. struct dp_peer *sa_peer;
  129. struct dp_ast_entry *ast;
  130. uint32_t flags = IEEE80211_NODE_F_WDS_HM;
  131. uint32_t ret = 0;
  132. struct dp_neighbour_peer *neighbour_peer = NULL;
  133. struct dp_pdev *pdev = ta_peer->vdev->pdev;
  134. uint8_t wds_src_mac[QDF_MAC_ADDR_SIZE];
  135. /* For AP mode : Do wds source port learning only if it is a
  136. * 4-address mpdu
  137. *
  138. * For STA mode : Frames from RootAP backend will be in 3-address mode,
  139. * till RootAP does the WDS source port learning; Hence in repeater/STA
  140. * mode, we enable learning even in 3-address mode , to avoid RootAP
  141. * backbone getting wrongly learnt as MEC on repeater
  142. */
  143. if (ta_peer->vdev->opmode != wlan_op_mode_sta) {
  144. if (!(is_chfrag_start && is_ad4_valid))
  145. return;
  146. } else {
  147. /* For HKv2 Source port learing is not needed in STA mode
  148. * as we have support in HW
  149. *
  150. * if sa_valid bit is set there is a AST entry added on AP VAP
  151. * and this peer has roamed behind ROOT AP in this case proceed
  152. * further to check for roaming
  153. */
  154. if (soc->ast_override_support && !is_sa_valid)
  155. return;
  156. }
  157. if (qdf_unlikely(!is_sa_valid)) {
  158. qdf_mem_copy(wds_src_mac,
  159. (qdf_nbuf_data(nbuf) + QDF_MAC_ADDR_SIZE),
  160. QDF_MAC_ADDR_SIZE);
  161. dp_wds_ext_peer_learn(soc, ta_peer);
  162. ret = dp_peer_add_ast(soc,
  163. ta_peer,
  164. wds_src_mac,
  165. CDP_TXRX_AST_TYPE_WDS,
  166. flags);
  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. ret = dp_peer_add_ast(soc,
  191. ta_peer,
  192. wds_src_mac,
  193. CDP_TXRX_AST_TYPE_WDS,
  194. flags);
  195. return;
  196. } else {
  197. /* In HKv2 smart monitor case, when NAC client is
  198. * added first and this client roams within BSS to
  199. * connect to RE, since we have an AST entry for
  200. * NAC we get sa_is_valid bit set. So we check if
  201. * smart monitor is enabled and send add_ast command
  202. * to FW.
  203. */
  204. if (pdev->neighbour_peers_added) {
  205. qdf_mem_copy(wds_src_mac,
  206. (qdf_nbuf_data(nbuf) +
  207. QDF_MAC_ADDR_SIZE),
  208. QDF_MAC_ADDR_SIZE);
  209. qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
  210. TAILQ_FOREACH(neighbour_peer,
  211. &pdev->neighbour_peers_list,
  212. neighbour_peer_list_elem) {
  213. if (!qdf_mem_cmp(&neighbour_peer->neighbour_peers_macaddr,
  214. wds_src_mac,
  215. QDF_MAC_ADDR_SIZE)) {
  216. ret = dp_peer_add_ast(soc,
  217. ta_peer,
  218. wds_src_mac,
  219. CDP_TXRX_AST_TYPE_WDS,
  220. flags);
  221. QDF_TRACE(QDF_MODULE_ID_DP,
  222. QDF_TRACE_LEVEL_INFO,
  223. "sa valid and nac roamed to wds");
  224. break;
  225. }
  226. }
  227. qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
  228. }
  229. return;
  230. }
  231. }
  232. if ((ast->type == CDP_TXRX_AST_TYPE_WDS_HM) ||
  233. (ast->type == CDP_TXRX_AST_TYPE_WDS_HM_SEC)) {
  234. qdf_spin_unlock_bh(&soc->ast_lock);
  235. return;
  236. }
  237. /*
  238. * Ensure we are updating the right AST entry by
  239. * validating ast_idx.
  240. * There is a possibility we might arrive here without
  241. * AST MAP event , so this check is mandatory
  242. */
  243. if (ast->is_mapped && (ast->ast_idx == sa_idx))
  244. ast->is_active = TRUE;
  245. if (sa_sw_peer_id != ta_peer->peer_id) {
  246. if ((ast->type != CDP_TXRX_AST_TYPE_STATIC) &&
  247. (ast->type != CDP_TXRX_AST_TYPE_SELF) &&
  248. (ast->type != CDP_TXRX_AST_TYPE_STA_BSS)) {
  249. if (ast->pdev_id != ta_peer->vdev->pdev->pdev_id) {
  250. /* This case is when a STA roams from one
  251. * repeater to another repeater, but these
  252. * repeaters are connected to root AP on
  253. * different radios.
  254. * Ex: rptr1 connected to ROOT AP over 5G
  255. * and rptr2 connected to ROOT AP over 2G
  256. * radio
  257. */
  258. dp_peer_del_ast(soc, ast);
  259. } else {
  260. /* this case is when a STA roams from one
  261. * reapter to another repeater, but inside
  262. * same radio.
  263. */
  264. /* For HKv2 do not update the AST entry if
  265. * new ta_peer is on STA vap as SRC port
  266. * learning is disable on STA vap
  267. */
  268. if (soc->ast_override_support &&
  269. (ta_peer->vdev->opmode == wlan_op_mode_sta)) {
  270. dp_peer_del_ast(soc, ast);
  271. } else {
  272. dp_wds_ext_peer_learn(soc, ta_peer);
  273. dp_peer_update_ast(soc, ta_peer, ast, flags);
  274. }
  275. qdf_spin_unlock_bh(&soc->ast_lock);
  276. return;
  277. }
  278. }
  279. /*
  280. * Do not kickout STA if it belongs to a different radio.
  281. * For DBDC repeater, it is possible to arrive here
  282. * for multicast loopback frames originated from connected
  283. * clients and looped back (intrabss) by Root AP
  284. */
  285. if (ast->pdev_id != ta_peer->vdev->pdev->pdev_id) {
  286. qdf_spin_unlock_bh(&soc->ast_lock);
  287. return;
  288. }
  289. qdf_spin_unlock_bh(&soc->ast_lock);
  290. /*
  291. * Kickout, when direct associated peer(SA) roams
  292. * to another AP and reachable via TA peer
  293. */
  294. sa_peer = dp_peer_get_ref_by_id(soc, ast->peer_id,
  295. DP_MOD_ID_RX);
  296. if (!sa_peer)
  297. return;
  298. if ((sa_peer->vdev->opmode == wlan_op_mode_ap) &&
  299. sa_peer->delete_in_progress) {
  300. qdf_mem_copy(wds_src_mac,
  301. (qdf_nbuf_data(nbuf) + QDF_MAC_ADDR_SIZE),
  302. QDF_MAC_ADDR_SIZE);
  303. sa_peer->delete_in_progress = true;
  304. if (soc->cdp_soc.ol_ops->peer_sta_kickout) {
  305. soc->cdp_soc.ol_ops->peer_sta_kickout(
  306. soc->ctrl_psoc,
  307. sa_peer->vdev->pdev->pdev_id,
  308. wds_src_mac);
  309. }
  310. }
  311. dp_peer_unref_delete(sa_peer, DP_MOD_ID_RX);
  312. return;
  313. }
  314. qdf_spin_unlock_bh(&soc->ast_lock);
  315. }
  316. /**
  317. * dp_rx_wds_srcport_learn() - Add or update the STA PEER which
  318. * is behind the WDS repeater.
  319. *
  320. * @soc: core txrx main context
  321. * @rx_tlv_hdr: base address of RX TLV header
  322. * @ta_peer: WDS repeater peer
  323. * @nbuf: rx pkt
  324. *
  325. * Return: void:
  326. */
  327. static inline void
  328. dp_rx_wds_srcport_learn(struct dp_soc *soc,
  329. uint8_t *rx_tlv_hdr,
  330. struct dp_peer *ta_peer,
  331. qdf_nbuf_t nbuf,
  332. struct hal_rx_msdu_metadata msdu_end_info)
  333. {
  334. uint8_t sa_is_valid = qdf_nbuf_is_sa_valid(nbuf);
  335. uint8_t is_chfrag_start = 0;
  336. uint8_t is_ad4_valid = 0;
  337. if (qdf_unlikely(!ta_peer))
  338. return;
  339. is_chfrag_start = qdf_nbuf_is_rx_chfrag_start(nbuf);
  340. if (is_chfrag_start)
  341. is_ad4_valid = hal_rx_get_mpdu_mac_ad4_valid(soc->hal_soc, rx_tlv_hdr);
  342. /*
  343. * Get the AST entry from HW SA index and mark it as active
  344. */
  345. dp_rx_wds_add_or_update_ast(soc, ta_peer, nbuf, is_ad4_valid,
  346. sa_is_valid, is_chfrag_start,
  347. msdu_end_info.sa_idx, msdu_end_info.sa_sw_peer_id);
  348. }
  349. /*
  350. * dp_rx_ast_set_active() - set the active flag of the astentry
  351. * corresponding to a hw index.
  352. * @soc: core txrx main context
  353. * @sa_idx: hw idx
  354. * @is_active: active flag
  355. *
  356. */
  357. static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc,
  358. uint16_t sa_idx, bool is_active)
  359. {
  360. struct dp_ast_entry *ast;
  361. qdf_spin_lock_bh(&soc->ast_lock);
  362. ast = soc->ast_table[sa_idx];
  363. /*
  364. * Ensure we are updating the right AST entry by
  365. * validating ast_idx.
  366. * There is a possibility we might arrive here without
  367. * AST MAP event , so this check is mandatory
  368. */
  369. if (ast && ast->is_mapped && (ast->ast_idx == sa_idx)) {
  370. ast->is_active = is_active;
  371. qdf_spin_unlock_bh(&soc->ast_lock);
  372. return QDF_STATUS_SUCCESS;
  373. }
  374. qdf_spin_unlock_bh(&soc->ast_lock);
  375. return QDF_STATUS_E_FAILURE;
  376. }
  377. #endif /* DP_TXRX_WDS*/