cdp_txrx_peer_ops.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2023-2024 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. /**
  20. * DOC: cdp_txrx_peer_ops.h
  21. * Define the host data path peer API functions
  22. * called by the host control SW and the OS interface module
  23. */
  24. #ifndef _CDP_TXRX_PEER_H_
  25. #define _CDP_TXRX_PEER_H_
  26. #include <cdp_txrx_ops.h>
  27. #include "cdp_txrx_handle.h"
  28. /**
  29. * cdp_peer_register() - Register peer into physical device
  30. * @soc: data path soc handle
  31. * @pdev_id: data path device instance id
  32. * @sta_desc: peer description
  33. *
  34. * Register peer into physical device
  35. *
  36. * Return: QDF_STATUS_SUCCESS registration success
  37. * QDF_STATUS_E_NOSUPPORT not support this feature
  38. */
  39. static inline QDF_STATUS
  40. cdp_peer_register(ol_txrx_soc_handle soc, uint8_t pdev_id,
  41. struct ol_txrx_desc_type *sta_desc)
  42. {
  43. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  44. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  45. "%s invalid instance", __func__);
  46. return QDF_STATUS_E_INVAL;
  47. }
  48. if (soc->ops->peer_ops->register_peer)
  49. return soc->ops->peer_ops->register_peer(soc, pdev_id,
  50. sta_desc);
  51. return QDF_STATUS_E_NOSUPPORT;
  52. }
  53. /**
  54. * cdp_clear_peer() - remove peer from physical device
  55. * @soc: data path soc handle
  56. * @pdev_id: data path device instance id
  57. * @peer_addr: peer mac address
  58. *
  59. * remove peer from physical device
  60. *
  61. * Return: QDF_STATUS_SUCCESS registration success
  62. * QDF_STATUS_E_NOSUPPORT not support this feature
  63. */
  64. static inline QDF_STATUS
  65. cdp_clear_peer(ol_txrx_soc_handle soc, uint8_t pdev_id,
  66. struct qdf_mac_addr peer_addr)
  67. {
  68. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  69. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  70. "%s invalid instance", __func__);
  71. return QDF_STATUS_E_INVAL;
  72. }
  73. if (soc->ops->peer_ops->clear_peer)
  74. return soc->ops->peer_ops->clear_peer(soc, pdev_id, peer_addr);
  75. return QDF_STATUS_E_NOSUPPORT;
  76. }
  77. /**
  78. * cdp_peer_register_ocb_peer() - register ocb peer from physical device
  79. * @soc: data path soc handle
  80. * @mac_addr: mac address for ocb self peer
  81. *
  82. * register ocb peer from physical device
  83. *
  84. * Return: QDF_STATUS_SUCCESS registration success
  85. * QDF_STATUS_E_NOSUPPORT not support this feature
  86. */
  87. static inline QDF_STATUS
  88. cdp_peer_register_ocb_peer(ol_txrx_soc_handle soc,
  89. uint8_t *mac_addr)
  90. {
  91. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  92. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  93. "%s invalid instance", __func__);
  94. return QDF_STATUS_E_INVAL;
  95. }
  96. if (soc->ops->peer_ops->register_ocb_peer)
  97. return soc->ops->peer_ops->register_ocb_peer(mac_addr);
  98. return QDF_STATUS_E_NOSUPPORT;
  99. }
  100. /**
  101. * cdp_find_peer_exist - Find if peer already exists
  102. * @soc: data path soc handle
  103. * @pdev_id: data path device instance id
  104. * @peer_addr: peer mac address
  105. *
  106. * Return: true or false
  107. */
  108. static inline bool
  109. cdp_find_peer_exist(ol_txrx_soc_handle soc, uint8_t pdev_id,
  110. uint8_t *peer_addr)
  111. {
  112. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  113. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  114. "%s invalid instance", __func__);
  115. return false;
  116. }
  117. if (soc->ops->peer_ops->find_peer_exist)
  118. return soc->ops->peer_ops->find_peer_exist(soc, pdev_id,
  119. peer_addr);
  120. return false;
  121. }
  122. /**
  123. * cdp_find_peer_exist_on_vdev - Find if duplicate peer exists
  124. * on the given vdev
  125. * @soc: data path soc handle
  126. * @vdev_id: data path virtual interface id
  127. * @peer_addr: peer mac address
  128. *
  129. * Return: true or false
  130. */
  131. static inline bool
  132. cdp_find_peer_exist_on_vdev(ol_txrx_soc_handle soc, uint8_t vdev_id,
  133. uint8_t *peer_addr)
  134. {
  135. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  136. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  137. "%s invalid instance", __func__);
  138. return false;
  139. }
  140. if (soc->ops->peer_ops->find_peer_exist_on_vdev)
  141. return soc->ops->peer_ops->find_peer_exist_on_vdev(soc, vdev_id,
  142. peer_addr);
  143. return false;
  144. }
  145. /**
  146. * cdp_find_peer_exist_on_other_vdev - Find if duplicate peer exists
  147. * on other than the given vdev
  148. * @soc: data path soc handle
  149. * @vdev_id: data path virtual interface id
  150. * @peer_addr: peer mac address
  151. * @max_bssid: max number of bssids
  152. *
  153. * Return: true or false
  154. */
  155. static inline bool
  156. cdp_find_peer_exist_on_other_vdev(ol_txrx_soc_handle soc, uint8_t vdev_id,
  157. uint8_t *peer_addr, uint16_t max_bssid)
  158. {
  159. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  160. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  161. "%s invalid instance", __func__);
  162. return false;
  163. }
  164. if (soc->ops->peer_ops->find_peer_exist_on_other_vdev)
  165. return soc->ops->peer_ops->find_peer_exist_on_other_vdev(
  166. soc, vdev_id,
  167. peer_addr,
  168. max_bssid);
  169. return false;
  170. }
  171. /**
  172. * cdp_peer_state_update() - update peer local state
  173. * @soc: data path soc handle
  174. * @peer_addr: peer mac address
  175. * @state: new peer local state
  176. *
  177. * update peer local state
  178. *
  179. * Return: QDF_STATUS_SUCCESS registration success
  180. * QDF_STATUS_E_NOSUPPORT not support this feature
  181. */
  182. static inline QDF_STATUS
  183. cdp_peer_state_update(ol_txrx_soc_handle soc, uint8_t *peer_addr,
  184. enum ol_txrx_peer_state state)
  185. {
  186. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  187. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  188. "%s invalid instance", __func__);
  189. return QDF_STATUS_E_INVAL;
  190. }
  191. if (soc->ops->peer_ops->peer_state_update)
  192. return soc->ops->peer_ops->peer_state_update(soc, peer_addr,
  193. state);
  194. return QDF_STATUS_E_NOSUPPORT;
  195. }
  196. /**
  197. * cdp_peer_state_get() - Get local peer state
  198. * @soc: data path soc handle
  199. * @vdev_id: virtual interface id
  200. * @peer_mac: peer mac addr
  201. * @slowpath: call from slow path or not
  202. *
  203. * Get local peer state
  204. *
  205. * Return: peer status
  206. */
  207. static inline int
  208. cdp_peer_state_get(ol_txrx_soc_handle soc, uint8_t vdev_id, uint8_t *peer_mac, bool slowpath)
  209. {
  210. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  211. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  212. "%s invalid instance", __func__);
  213. return 0;
  214. }
  215. if (soc->ops->peer_ops->get_peer_state)
  216. return soc->ops->peer_ops->get_peer_state(soc, vdev_id,
  217. peer_mac,
  218. slowpath);
  219. return 0;
  220. }
  221. /**
  222. * cdp_peer_get_vdevid() - Get virtual interface id which peer registered
  223. * @soc: data path soc handle
  224. * @peer_mac: peer mac address
  225. * @vdev_id: virtual interface id which peer registered
  226. *
  227. * Get virtual interface id which peer registered
  228. *
  229. * Return: QDF_STATUS_SUCCESS registration success
  230. * QDF_STATUS_E_NOSUPPORT not support this feature
  231. */
  232. static inline QDF_STATUS
  233. cdp_peer_get_vdevid(ol_txrx_soc_handle soc,
  234. uint8_t *peer_mac, uint8_t *vdev_id)
  235. {
  236. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  237. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  238. "%s invalid instance", __func__);
  239. return QDF_STATUS_E_INVAL;
  240. }
  241. if (soc->ops->peer_ops->get_vdevid)
  242. return soc->ops->peer_ops->get_vdevid(soc, peer_mac, vdev_id);
  243. return QDF_STATUS_E_NOSUPPORT;
  244. }
  245. /**
  246. * cdp_peer_get_vdev_by_peer_addr() - Get vdev instance by local peer address
  247. * @soc: data path soc handle
  248. * @pdev: data path device instance
  249. * @peer_addr: peer mac address
  250. *
  251. * Get virtual interface id by local peer id
  252. *
  253. * Return: Virtual interface instance
  254. * NULL in case cannot find
  255. */
  256. static inline struct cdp_vdev
  257. *cdp_peer_get_vdev_by_peer_addr(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  258. struct qdf_mac_addr peer_addr)
  259. {
  260. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  261. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  262. "%s invalid instance", __func__);
  263. return NULL;
  264. }
  265. if (soc->ops->peer_ops->get_vdev_by_peer_addr)
  266. return soc->ops->peer_ops->get_vdev_by_peer_addr(pdev,
  267. peer_addr);
  268. return NULL;
  269. }
  270. /**
  271. * cdp_peer_get_peer_mac_addr() - Get peer mac address
  272. * @soc: data path soc handle
  273. * @peer: peer instance
  274. *
  275. * Get peer mac address
  276. *
  277. * Return: peer mac address pointer
  278. * NULL in case cannot find
  279. */
  280. static inline uint8_t
  281. *cdp_peer_get_peer_mac_addr(ol_txrx_soc_handle soc, void *peer)
  282. {
  283. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  284. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  285. "%s invalid instance", __func__);
  286. return NULL;
  287. }
  288. if (soc->ops->peer_ops->peer_get_peer_mac_addr)
  289. return soc->ops->peer_ops->peer_get_peer_mac_addr(peer);
  290. return NULL;
  291. }
  292. /**
  293. * cdp_peer_update_ibss_add_peer_num_of_vdev() - update number of peer
  294. * @soc: data path soc handle
  295. * @vdev_id: virtual interface instance id
  296. * @peer_num_delta: number of peer should be updated
  297. *
  298. * update number of peer
  299. *
  300. * Return: updated number of peer
  301. * 0 fail
  302. */
  303. static inline int16_t
  304. cdp_peer_update_ibss_add_peer_num_of_vdev(ol_txrx_soc_handle soc,
  305. uint8_t vdev_id,
  306. int16_t peer_num_delta)
  307. {
  308. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  309. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  310. "%s invalid instance", __func__);
  311. return 0;
  312. }
  313. if (soc->ops->peer_ops->update_ibss_add_peer_num_of_vdev)
  314. return soc->ops->peer_ops->update_ibss_add_peer_num_of_vdev(
  315. soc, vdev_id,
  316. peer_num_delta);
  317. return 0;
  318. }
  319. /**
  320. * cdp_peer_copy_mac_addr_raw() - copy peer mac address
  321. * @soc: data path soc handle
  322. * @vdev_id: virtual interface instance id
  323. * @bss_addr: mac address should be copied
  324. *
  325. * copy peer mac address
  326. *
  327. * Return: none
  328. */
  329. static inline void
  330. cdp_peer_copy_mac_addr_raw(ol_txrx_soc_handle soc,
  331. uint8_t vdev_id, uint8_t *bss_addr)
  332. {
  333. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  334. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  335. "%s invalid instance", __func__);
  336. return;
  337. }
  338. if (soc->ops->peer_ops->copy_mac_addr_raw)
  339. return soc->ops->peer_ops->copy_mac_addr_raw(soc, vdev_id,
  340. bss_addr);
  341. return;
  342. }
  343. /**
  344. * cdp_peer_add_last_real_peer() - Add peer with last peer marking
  345. * @soc: data path soc handle
  346. * @pdev_id: data path device instance id
  347. * @vdev_id: virtual interface instance id
  348. *
  349. * copy peer mac address
  350. *
  351. * Return: none
  352. */
  353. static inline void
  354. cdp_peer_add_last_real_peer(ol_txrx_soc_handle soc, uint8_t pdev_id,
  355. uint8_t vdev_id)
  356. {
  357. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  358. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  359. "%s invalid instance", __func__);
  360. return;
  361. }
  362. if (soc->ops->peer_ops->add_last_real_peer)
  363. return soc->ops->peer_ops->add_last_real_peer(soc, pdev_id,
  364. vdev_id);
  365. return;
  366. }
  367. /**
  368. * cdp_peer_is_vdev_restore_last_peer() - restore last peer
  369. * @soc: data path soc handle
  370. * @vdev_id: virtual interface id
  371. * @peer_mac: peer mac address
  372. *
  373. * restore last peer
  374. *
  375. * Return: true, restore success
  376. * false, restore fail
  377. */
  378. static inline bool
  379. cdp_peer_is_vdev_restore_last_peer(ol_txrx_soc_handle soc, uint8_t vdev_id,
  380. uint8_t *peer_mac)
  381. {
  382. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  383. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  384. "%s invalid instance", __func__);
  385. return false;
  386. }
  387. if (soc->ops->peer_ops->is_vdev_restore_last_peer)
  388. return soc->ops->peer_ops->is_vdev_restore_last_peer(soc,
  389. vdev_id,
  390. peer_mac);
  391. return false;
  392. }
  393. /**
  394. * cdp_peer_update_last_real_peer() - update last real peer
  395. * @soc: data path soc handle
  396. * @pdev_id: data path device instance id
  397. * @vdev_id: virtual interface id
  398. * @restore_last_peer: restore last peer or not
  399. *
  400. * update last real peer
  401. *
  402. * Return: none
  403. */
  404. static inline void
  405. cdp_peer_update_last_real_peer(ol_txrx_soc_handle soc, uint8_t pdev_id,
  406. uint8_t vdev_id, bool restore_last_peer)
  407. {
  408. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  409. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  410. "%s invalid instance", __func__);
  411. return;
  412. }
  413. if (soc->ops->peer_ops->update_last_real_peer)
  414. return soc->ops->peer_ops->update_last_real_peer(
  415. soc, pdev_id, vdev_id,
  416. restore_last_peer);
  417. return;
  418. }
  419. /**
  420. * cdp_peer_detach_force_delete() - Detach and delete a peer's data object
  421. * @soc: data path soc handle
  422. * @vdev_id: data path virtual interface id
  423. * @peer_mac: peer mac address
  424. *
  425. * Detach a peer and force the peer object to be removed. It is called during
  426. * roaming scenario when the firmware has already deleted a peer.
  427. * Peer object is freed immediately to avoid duplicate peers during roam sync
  428. * indication processing.
  429. *
  430. * Return: None
  431. */
  432. static inline void cdp_peer_detach_force_delete(ol_txrx_soc_handle soc,
  433. uint8_t vdev_id,
  434. uint8_t *peer_mac)
  435. {
  436. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  437. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  438. "%s invalid instance", __func__);
  439. return;
  440. }
  441. if (soc->ops->peer_ops->peer_detach_force_delete)
  442. return soc->ops->peer_ops->peer_detach_force_delete(soc,
  443. vdev_id,
  444. peer_mac);
  445. return;
  446. }
  447. /**
  448. * is_cdp_peer_detach_force_delete_supported() - To check if force delete
  449. * operation is supported
  450. * @soc: pointer to SOC handle
  451. *
  452. * Some of the platforms support force delete operation and some of them
  453. * don't. This API returns true if API which handles force delete operation
  454. * is registered and false otherwise.
  455. *
  456. * Return: true if API which handles force delete operation is registered
  457. * false in all other cases
  458. */
  459. static inline bool
  460. is_cdp_peer_detach_force_delete_supported(ol_txrx_soc_handle soc)
  461. {
  462. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  463. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  464. "%s invalid instance", __func__);
  465. return false;
  466. }
  467. if (soc->ops->peer_ops->peer_detach_force_delete)
  468. return true;
  469. return false;
  470. }
  471. /**
  472. * cdp_peer_set_peer_as_tdls() - To set peer as tdls peer
  473. * @soc: pointer to SOC handle
  474. * @vdev_id: virtual interface id
  475. * @peer_mac: peer mac address
  476. * @val: true or false
  477. *
  478. * Return: void
  479. */
  480. static inline void
  481. cdp_peer_set_peer_as_tdls(ol_txrx_soc_handle soc, uint8_t vdev_id,
  482. uint8_t *peer_mac, bool val)
  483. {
  484. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  485. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  486. "%s invalid instance", __func__);
  487. return;
  488. }
  489. if (soc->ops->peer_ops->set_peer_as_tdls_peer)
  490. soc->ops->peer_ops->set_peer_as_tdls_peer(soc, vdev_id,
  491. peer_mac, val);
  492. }
  493. /**
  494. * cdp_peer_set_tdls_offchan_enabled() - Set tdls offchan operation as enabled
  495. * @soc: pointer to SOC handle
  496. * @vdev_id: virtual interface id
  497. * @peer_mac: peer mac address
  498. * @val: true or false
  499. *
  500. * update tdls_offchan_enabled
  501. *
  502. * Return: none
  503. */
  504. static inline void
  505. cdp_peer_set_tdls_offchan_enabled(ol_txrx_soc_handle soc, uint8_t vdev_id,
  506. uint8_t *peer_mac, bool val)
  507. {
  508. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  509. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  510. "%s invalid instance", __func__);
  511. return;
  512. }
  513. if (soc->ops->peer_ops->set_tdls_offchan_enabled)
  514. soc->ops->peer_ops->set_tdls_offchan_enabled(soc, vdev_id,
  515. peer_mac, val);
  516. }
  517. /**
  518. * cdp_peer_flush_frags() - Flush frags on peer
  519. * @soc: data path soc handle
  520. * @vdev_id: virtual interface id
  521. * @peer_mac: peer mac addr
  522. *
  523. * Return: None
  524. */
  525. static inline void
  526. cdp_peer_flush_frags(ol_txrx_soc_handle soc, uint8_t vdev_id, uint8_t *peer_mac)
  527. {
  528. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  529. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  530. "%s invalid instance", __func__);
  531. return;
  532. }
  533. if (soc->ops->peer_ops->peer_flush_frags)
  534. soc->ops->peer_ops->peer_flush_frags(soc, vdev_id, peer_mac);
  535. }
  536. #endif /* _CDP_TXRX_PEER_H_ */