cdp_txrx_peer_ops.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2023 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. *
  202. * Get local peer state
  203. *
  204. * Return: peer status
  205. */
  206. static inline int
  207. cdp_peer_state_get(ol_txrx_soc_handle soc, uint8_t vdev_id, uint8_t *peer_mac)
  208. {
  209. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  210. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  211. "%s invalid instance", __func__);
  212. return 0;
  213. }
  214. if (soc->ops->peer_ops->get_peer_state)
  215. return soc->ops->peer_ops->get_peer_state(soc, vdev_id,
  216. peer_mac);
  217. return 0;
  218. }
  219. /**
  220. * cdp_peer_get_vdevid() - Get virtual interface id which peer registered
  221. * @soc: data path soc handle
  222. * @peer_mac: peer mac address
  223. * @vdev_id: virtual interface id which peer registered
  224. *
  225. * Get virtual interface id which peer registered
  226. *
  227. * Return: QDF_STATUS_SUCCESS registration success
  228. * QDF_STATUS_E_NOSUPPORT not support this feature
  229. */
  230. static inline QDF_STATUS
  231. cdp_peer_get_vdevid(ol_txrx_soc_handle soc,
  232. uint8_t *peer_mac, uint8_t *vdev_id)
  233. {
  234. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  235. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  236. "%s invalid instance", __func__);
  237. return QDF_STATUS_E_INVAL;
  238. }
  239. if (soc->ops->peer_ops->get_vdevid)
  240. return soc->ops->peer_ops->get_vdevid(soc, peer_mac, vdev_id);
  241. return QDF_STATUS_E_NOSUPPORT;
  242. }
  243. /**
  244. * cdp_peer_get_vdev_by_peer_addr() - Get vdev instance by local peer address
  245. * @soc: data path soc handle
  246. * @pdev: data path device instance
  247. * @peer_addr: peer mac address
  248. *
  249. * Get virtual interface id by local peer id
  250. *
  251. * Return: Virtual interface instance
  252. * NULL in case cannot find
  253. */
  254. static inline struct cdp_vdev
  255. *cdp_peer_get_vdev_by_peer_addr(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  256. struct qdf_mac_addr peer_addr)
  257. {
  258. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  259. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  260. "%s invalid instance", __func__);
  261. return NULL;
  262. }
  263. if (soc->ops->peer_ops->get_vdev_by_peer_addr)
  264. return soc->ops->peer_ops->get_vdev_by_peer_addr(pdev,
  265. peer_addr);
  266. return NULL;
  267. }
  268. /**
  269. * cdp_peer_get_peer_mac_addr() - Get peer mac address
  270. * @soc: data path soc handle
  271. * @peer: peer instance
  272. *
  273. * Get peer mac address
  274. *
  275. * Return: peer mac address pointer
  276. * NULL in case cannot find
  277. */
  278. static inline uint8_t
  279. *cdp_peer_get_peer_mac_addr(ol_txrx_soc_handle soc, void *peer)
  280. {
  281. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  282. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  283. "%s invalid instance", __func__);
  284. return NULL;
  285. }
  286. if (soc->ops->peer_ops->peer_get_peer_mac_addr)
  287. return soc->ops->peer_ops->peer_get_peer_mac_addr(peer);
  288. return NULL;
  289. }
  290. /**
  291. * cdp_peer_update_ibss_add_peer_num_of_vdev() - update number of peer
  292. * @soc: data path soc handle
  293. * @vdev_id: virtual interface instance id
  294. * @peer_num_delta: number of peer should be updated
  295. *
  296. * update number of peer
  297. *
  298. * Return: updated number of peer
  299. * 0 fail
  300. */
  301. static inline int16_t
  302. cdp_peer_update_ibss_add_peer_num_of_vdev(ol_txrx_soc_handle soc,
  303. uint8_t vdev_id,
  304. int16_t peer_num_delta)
  305. {
  306. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  307. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  308. "%s invalid instance", __func__);
  309. return 0;
  310. }
  311. if (soc->ops->peer_ops->update_ibss_add_peer_num_of_vdev)
  312. return soc->ops->peer_ops->update_ibss_add_peer_num_of_vdev(
  313. soc, vdev_id,
  314. peer_num_delta);
  315. return 0;
  316. }
  317. /**
  318. * cdp_peer_copy_mac_addr_raw() - copy peer mac address
  319. * @soc: data path soc handle
  320. * @vdev_id: virtual interface instance id
  321. * @bss_addr: mac address should be copied
  322. *
  323. * copy peer mac address
  324. *
  325. * Return: none
  326. */
  327. static inline void
  328. cdp_peer_copy_mac_addr_raw(ol_txrx_soc_handle soc,
  329. uint8_t vdev_id, uint8_t *bss_addr)
  330. {
  331. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  332. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  333. "%s invalid instance", __func__);
  334. return;
  335. }
  336. if (soc->ops->peer_ops->copy_mac_addr_raw)
  337. return soc->ops->peer_ops->copy_mac_addr_raw(soc, vdev_id,
  338. bss_addr);
  339. return;
  340. }
  341. /**
  342. * cdp_peer_add_last_real_peer() - Add peer with last peer marking
  343. * @soc: data path soc handle
  344. * @pdev_id: data path device instance id
  345. * @vdev_id: virtual interface instance id
  346. *
  347. * copy peer mac address
  348. *
  349. * Return: none
  350. */
  351. static inline void
  352. cdp_peer_add_last_real_peer(ol_txrx_soc_handle soc, uint8_t pdev_id,
  353. uint8_t vdev_id)
  354. {
  355. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  356. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  357. "%s invalid instance", __func__);
  358. return;
  359. }
  360. if (soc->ops->peer_ops->add_last_real_peer)
  361. return soc->ops->peer_ops->add_last_real_peer(soc, pdev_id,
  362. vdev_id);
  363. return;
  364. }
  365. /**
  366. * cdp_peer_is_vdev_restore_last_peer() - restore last peer
  367. * @soc: data path soc handle
  368. * @vdev_id: virtual interface id
  369. * @peer_mac: peer mac address
  370. *
  371. * restore last peer
  372. *
  373. * Return: true, restore success
  374. * false, restore fail
  375. */
  376. static inline bool
  377. cdp_peer_is_vdev_restore_last_peer(ol_txrx_soc_handle soc, uint8_t vdev_id,
  378. uint8_t *peer_mac)
  379. {
  380. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  381. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  382. "%s invalid instance", __func__);
  383. return false;
  384. }
  385. if (soc->ops->peer_ops->is_vdev_restore_last_peer)
  386. return soc->ops->peer_ops->is_vdev_restore_last_peer(soc,
  387. vdev_id,
  388. peer_mac);
  389. return false;
  390. }
  391. /**
  392. * cdp_peer_update_last_real_peer() - update last real peer
  393. * @soc: data path soc handle
  394. * @pdev_id: data path device instance id
  395. * @vdev_id: virtual interface id
  396. * @restore_last_peer: restore last peer or not
  397. *
  398. * update last real peer
  399. *
  400. * Return: none
  401. */
  402. static inline void
  403. cdp_peer_update_last_real_peer(ol_txrx_soc_handle soc, uint8_t pdev_id,
  404. uint8_t vdev_id, bool restore_last_peer)
  405. {
  406. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  407. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  408. "%s invalid instance", __func__);
  409. return;
  410. }
  411. if (soc->ops->peer_ops->update_last_real_peer)
  412. return soc->ops->peer_ops->update_last_real_peer(
  413. soc, pdev_id, vdev_id,
  414. restore_last_peer);
  415. return;
  416. }
  417. /**
  418. * cdp_peer_detach_force_delete() - Detach and delete a peer's data object
  419. * @soc: data path soc handle
  420. * @vdev_id: data path virtual interface id
  421. * @peer_mac: peer mac address
  422. *
  423. * Detach a peer and force the peer object to be removed. It is called during
  424. * roaming scenario when the firmware has already deleted a peer.
  425. * Peer object is freed immediately to avoid duplicate peers during roam sync
  426. * indication processing.
  427. *
  428. * Return: None
  429. */
  430. static inline void cdp_peer_detach_force_delete(ol_txrx_soc_handle soc,
  431. uint8_t vdev_id,
  432. uint8_t *peer_mac)
  433. {
  434. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  435. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  436. "%s invalid instance", __func__);
  437. return;
  438. }
  439. if (soc->ops->peer_ops->peer_detach_force_delete)
  440. return soc->ops->peer_ops->peer_detach_force_delete(soc,
  441. vdev_id,
  442. peer_mac);
  443. return;
  444. }
  445. /**
  446. * is_cdp_peer_detach_force_delete_supported() - To check if force delete
  447. * operation is supported
  448. * @soc: pointer to SOC handle
  449. *
  450. * Some of the platforms support force delete operation and some of them
  451. * don't. This API returns true if API which handles force delete operation
  452. * is registered and false otherwise.
  453. *
  454. * Return: true if API which handles force delete operation is registered
  455. * false in all other cases
  456. */
  457. static inline bool
  458. is_cdp_peer_detach_force_delete_supported(ol_txrx_soc_handle soc)
  459. {
  460. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  461. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  462. "%s invalid instance", __func__);
  463. return false;
  464. }
  465. if (soc->ops->peer_ops->peer_detach_force_delete)
  466. return true;
  467. return false;
  468. }
  469. /**
  470. * cdp_peer_set_peer_as_tdls() - To set peer as tdls peer
  471. * @soc: pointer to SOC handle
  472. * @vdev_id: virtual interface id
  473. * @peer_mac: peer mac address
  474. * @val: true or false
  475. *
  476. * Return: void
  477. */
  478. static inline void
  479. cdp_peer_set_peer_as_tdls(ol_txrx_soc_handle soc, uint8_t vdev_id,
  480. uint8_t *peer_mac, bool val)
  481. {
  482. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  483. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  484. "%s invalid instance", __func__);
  485. return;
  486. }
  487. if (soc->ops->peer_ops->set_peer_as_tdls_peer)
  488. soc->ops->peer_ops->set_peer_as_tdls_peer(soc, vdev_id,
  489. peer_mac, val);
  490. }
  491. /**
  492. * cdp_peer_set_tdls_offchan_enabled() - Set tdls offchan operation as enabled
  493. * @soc: pointer to SOC handle
  494. * @vdev_id: virtual interface id
  495. * @peer_mac: peer mac address
  496. * @val: true or false
  497. *
  498. * update tdls_offchan_enabled
  499. *
  500. * Return: none
  501. */
  502. static inline void
  503. cdp_peer_set_tdls_offchan_enabled(ol_txrx_soc_handle soc, uint8_t vdev_id,
  504. uint8_t *peer_mac, bool val)
  505. {
  506. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  507. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  508. "%s invalid instance", __func__);
  509. return;
  510. }
  511. if (soc->ops->peer_ops->set_tdls_offchan_enabled)
  512. soc->ops->peer_ops->set_tdls_offchan_enabled(soc, vdev_id,
  513. peer_mac, val);
  514. }
  515. /**
  516. * cdp_peer_flush_frags() - Flush frags on peer
  517. * @soc: data path soc handle
  518. * @vdev_id: virtual interface id
  519. * @peer_mac: peer mac addr
  520. *
  521. * Return: None
  522. */
  523. static inline void
  524. cdp_peer_flush_frags(ol_txrx_soc_handle soc, uint8_t vdev_id, uint8_t *peer_mac)
  525. {
  526. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  527. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  528. "%s invalid instance", __func__);
  529. return;
  530. }
  531. if (soc->ops->peer_ops->peer_flush_frags)
  532. soc->ops->peer_ops->peer_flush_frags(soc, vdev_id, peer_mac);
  533. }
  534. #endif /* _CDP_TXRX_PEER_H_ */