cdp_txrx_peer_ops.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /*
  2. * Copyright (c) 2016-2021 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. /**
  19. * @file cdp_txrx_peer.h
  20. * @brief Define the host data path peer API functions
  21. * called by the host control SW and the OS interface module
  22. */
  23. #ifndef _CDP_TXRX_PEER_H_
  24. #define _CDP_TXRX_PEER_H_
  25. #include <cdp_txrx_ops.h>
  26. #include "cdp_txrx_handle.h"
  27. /**
  28. * cdp_peer_register() - Register peer into physical device
  29. * @soc - data path soc handle
  30. * @pdev_id - data path device instance id
  31. * @sta_desc - peer description
  32. *
  33. * Register peer into physical device
  34. *
  35. * Return: QDF_STATUS_SUCCESS registration success
  36. * QDF_STATUS_E_NOSUPPORT not support this feature
  37. */
  38. static inline QDF_STATUS
  39. cdp_peer_register(ol_txrx_soc_handle soc, uint8_t pdev_id,
  40. struct ol_txrx_desc_type *sta_desc)
  41. {
  42. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  43. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  44. "%s invalid instance", __func__);
  45. return QDF_STATUS_E_INVAL;
  46. }
  47. if (soc->ops->peer_ops->register_peer)
  48. return soc->ops->peer_ops->register_peer(soc, pdev_id,
  49. sta_desc);
  50. return QDF_STATUS_E_NOSUPPORT;
  51. }
  52. /**
  53. * cdp_clear_peer() - remove peer from physical device
  54. * @soc - data path soc handle
  55. * @pdev_id - data path device instance id
  56. * @peer_addr - peer mac address
  57. *
  58. * remove peer from physical device
  59. *
  60. * Return: QDF_STATUS_SUCCESS registration success
  61. * QDF_STATUS_E_NOSUPPORT not support this feature
  62. */
  63. static inline QDF_STATUS
  64. cdp_clear_peer(ol_txrx_soc_handle soc, uint8_t pdev_id,
  65. struct qdf_mac_addr peer_addr)
  66. {
  67. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  68. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  69. "%s invalid instance", __func__);
  70. return QDF_STATUS_E_INVAL;
  71. }
  72. if (soc->ops->peer_ops->clear_peer)
  73. return soc->ops->peer_ops->clear_peer(soc, pdev_id, peer_addr);
  74. return QDF_STATUS_E_NOSUPPORT;
  75. }
  76. /**
  77. * cdp_peer_register_ocb_peer() - register ocb peer from physical device
  78. * @soc - data path soc handle
  79. * @cds_ctx - cds void context
  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_sta_id() - Get vdev instance by local peer id
  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. * fasle, 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. * ol_txrx_peer_detach_force_delete() - Detach and delete a peer's data object
  419. * @peer - the object to detach
  420. *
  421. * Detach a peer and force the peer object to be removed. It is called during
  422. * roaming scenario when the firmware has already deleted a peer.
  423. * Peer object is freed immediately to avoid duplicate peers during roam sync
  424. * indication processing.
  425. *
  426. * Return: None
  427. */
  428. static inline void cdp_peer_detach_force_delete(ol_txrx_soc_handle soc,
  429. uint8_t vdev_id,
  430. uint8_t *peer_mac)
  431. {
  432. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  433. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  434. "%s invalid instance", __func__);
  435. return;
  436. }
  437. if (soc->ops->peer_ops->peer_detach_force_delete)
  438. return soc->ops->peer_ops->peer_detach_force_delete(soc,
  439. vdev_id,
  440. peer_mac);
  441. return;
  442. }
  443. /**
  444. * is_cdp_peer_detach_force_delete_supported() - To check if force delete
  445. * operation is supported
  446. * @soc: pointer to SOC handle
  447. *
  448. * Some of the platforms support force delete operation and some of them
  449. * don't. This API returns true if API which handles force delete operation
  450. * is registered and false otherwise.
  451. *
  452. * Return: true if API which handles force delete operation is registered
  453. * false in all other cases
  454. */
  455. static inline bool
  456. is_cdp_peer_detach_force_delete_supported(ol_txrx_soc_handle soc)
  457. {
  458. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  459. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  460. "%s invalid instance", __func__);
  461. return false;
  462. }
  463. if (soc->ops->peer_ops->peer_detach_force_delete)
  464. return true;
  465. return false;
  466. }
  467. /*
  468. * cdp_peer_set_peer_as_tdls() - To set peer as tdls peer
  469. * @soc: pointer to SOC handle
  470. * @vdev_id: virtual interface id
  471. * @peer_mac: peer mac address
  472. * @var: true or false
  473. *
  474. * Return: void
  475. */
  476. static inline void
  477. cdp_peer_set_peer_as_tdls(ol_txrx_soc_handle soc, uint8_t vdev_id,
  478. uint8_t *peer_mac, bool val)
  479. {
  480. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  481. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  482. "%s invalid instance", __func__);
  483. return;
  484. }
  485. if (soc->ops->peer_ops->set_peer_as_tdls_peer)
  486. soc->ops->peer_ops->set_peer_as_tdls_peer(soc, vdev_id,
  487. peer_mac, val);
  488. }
  489. /**
  490. * cdp_peer_set_tdls_offchan_enabled() - Set tdls offchan operation as enabled
  491. * @soc: pointer to SOC handle
  492. * @vdev_id: virtual interface id
  493. * @peer_mac: peer mac address
  494. * @val: true or false
  495. *
  496. * update tdls_offchan_enabled
  497. *
  498. * Return: none
  499. */
  500. static inline void
  501. cdp_peer_set_tdls_offchan_enabled(ol_txrx_soc_handle soc, uint8_t vdev_id,
  502. uint8_t *peer_mac, bool val)
  503. {
  504. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  505. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  506. "%s invalid instance", __func__);
  507. return;
  508. }
  509. if (soc->ops->peer_ops->set_tdls_offchan_enabled)
  510. soc->ops->peer_ops->set_tdls_offchan_enabled(soc, vdev_id,
  511. peer_mac, val);
  512. }
  513. /**
  514. * cdp_peer_flush_frags() - Flush frags on peer
  515. * @soc - data path soc handle
  516. * @vdev_id - virtual interface id
  517. * @peer_mac - peer mac addr
  518. *
  519. * Return: None
  520. */
  521. static inline void
  522. cdp_peer_flush_frags(ol_txrx_soc_handle soc, uint8_t vdev_id, uint8_t *peer_mac)
  523. {
  524. if (!soc || !soc->ops || !soc->ops->peer_ops) {
  525. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  526. "%s invalid instance", __func__);
  527. return;
  528. }
  529. if (soc->ops->peer_ops->peer_flush_frags)
  530. soc->ops->peer_ops->peer_flush_frags(soc, vdev_id, peer_mac);
  531. }
  532. #endif /* _CDP_TXRX_PEER_H_ */