cdp_txrx_ctrl.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. /*
  2. * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. /**
  27. * @file cdp_txrx_ctrl.h
  28. * @brief Define the host data path control API functions
  29. * called by the host control SW and the OS interface module
  30. */
  31. #ifndef _CDP_TXRX_CTRL_H_
  32. #define _CDP_TXRX_CTRL_H_
  33. #include "cdp_txrx_handle.h"
  34. static inline int cdp_is_target_ar900b
  35. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  36. {
  37. if (soc->ops->ctrl_ops->txrx_is_target_ar900b)
  38. return soc->ops->ctrl_ops->txrx_is_target_ar900b(vdev);
  39. return 0;
  40. }
  41. /* WIN */
  42. static inline int
  43. cdp_mempools_attach(ol_txrx_soc_handle soc, void *ctrl_pdev)
  44. {
  45. if (soc->ops->ctrl_ops->txrx_mempools_attach)
  46. return soc->ops->ctrl_ops->txrx_mempools_attach(ctrl_pdev);
  47. return 0;
  48. }
  49. /**
  50. * @brief set filter neighbour peers
  51. * @details
  52. * This defines interface function to set neighbour peer filtering.
  53. *
  54. * @param soc - the pointer to soc object
  55. * @param pdev - the pointer physical device object
  56. * @param val - the enable/disable value
  57. * @return - int
  58. */
  59. static inline int
  60. cdp_set_filter_neighbour_peers(ol_txrx_soc_handle soc,
  61. struct cdp_pdev *pdev, u_int32_t val)
  62. {
  63. if (soc->ops->ctrl_ops->txrx_set_filter_neighbour_peers)
  64. return soc->ops->ctrl_ops->txrx_set_filter_neighbour_peers
  65. (pdev, val);
  66. return 0;
  67. }
  68. /**
  69. * @brief update the neighbour peer addresses
  70. * @details
  71. * This defines interface function to update neighbour peers addresses
  72. * which needs to be filtered
  73. *
  74. * @param soc - the pointer to soc object
  75. * @param pdev - the pointer to physical device object
  76. * @param cmd - add/del entry into peer table
  77. * @param macaddr - the address of neighbour peer
  78. * @return - int
  79. */
  80. static inline int
  81. cdp_update_filter_neighbour_peers(ol_txrx_soc_handle soc,
  82. struct cdp_pdev *pdev, uint32_t cmd, uint8_t *macaddr)
  83. {
  84. if (soc->ops->ctrl_ops->txrx_update_filter_neighbour_peers)
  85. return soc->ops->ctrl_ops->txrx_update_filter_neighbour_peers
  86. (pdev, cmd, macaddr);
  87. return 0;
  88. }
  89. /**
  90. * @brief set the safemode of the device
  91. * @details
  92. * This flag is used to bypass the encrypt and decrypt processes when send and
  93. * receive packets. It works like open AUTH mode, HW will treate all packets
  94. * as non-encrypt frames because no key installed. For rx fragmented frames,
  95. * it bypasses all the rx defragmentaion.
  96. *
  97. * @param vdev - the data virtual device object
  98. * @param val - the safemode state
  99. * @return - void
  100. */
  101. static inline void
  102. cdp_set_safemode(ol_txrx_soc_handle soc,
  103. struct cdp_vdev *vdev, u_int32_t val)
  104. {
  105. if (soc->ops->ctrl_ops->txrx_set_safemode)
  106. return soc->ops->ctrl_ops->txrx_set_safemode(vdev, val);
  107. return;
  108. }
  109. /**
  110. * @brief configure the drop unencrypted frame flag
  111. * @details
  112. * Rx related. When set this flag, all the unencrypted frames
  113. * received over a secure connection will be discarded
  114. *
  115. * @param vdev - the data virtual device object
  116. * @param val - flag
  117. * @return - void
  118. */
  119. static inline void
  120. cdp_set_drop_unenc(ol_txrx_soc_handle soc,
  121. struct cdp_vdev *vdev, u_int32_t val)
  122. {
  123. if (soc->ops->ctrl_ops->txrx_set_drop_unenc)
  124. return soc->ops->ctrl_ops->txrx_set_drop_unenc(vdev, val);
  125. return;
  126. }
  127. /**
  128. * @brief set the Tx encapsulation type of the VDEV
  129. * @details
  130. * This will be used to populate the HTT desc packet type field during Tx
  131. *
  132. * @param vdev - the data virtual device object
  133. * @param val - the Tx encap type (htt_cmn_pkt_type)
  134. * @return - void
  135. */
  136. static inline void
  137. cdp_set_tx_encap_type(ol_txrx_soc_handle soc,
  138. struct cdp_vdev *vdev, enum htt_cmn_pkt_type val)
  139. {
  140. if (soc->ops->ctrl_ops->txrx_set_tx_encap_type)
  141. return soc->ops->ctrl_ops->txrx_set_tx_encap_type(vdev, val);
  142. return;
  143. }
  144. /**
  145. * @brief set the Rx decapsulation type of the VDEV
  146. * @details
  147. * This will be used to configure into firmware and hardware which format to
  148. * decap all Rx packets into, for all peers under the VDEV.
  149. *
  150. * @param vdev - the data virtual device object
  151. * @param val - the Rx decap mode (htt_cmn_pkt_type)
  152. * @return - void
  153. */
  154. static inline void
  155. cdp_set_vdev_rx_decap_type(ol_txrx_soc_handle soc,
  156. struct cdp_vdev *vdev, enum htt_cmn_pkt_type val)
  157. {
  158. if (soc->ops->ctrl_ops->txrx_set_vdev_rx_decap_type)
  159. return soc->ops->ctrl_ops->txrx_set_vdev_rx_decap_type
  160. (vdev, val);
  161. return;
  162. }
  163. /**
  164. * @brief get the Rx decapsulation type of the VDEV
  165. *
  166. * @param vdev - the data virtual device object
  167. * @return - the Rx decap type (htt_cmn_pkt_type)
  168. */
  169. static inline enum htt_cmn_pkt_type
  170. cdp_get_vdev_rx_decap_type(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  171. {
  172. if (soc->ops->ctrl_ops->txrx_get_vdev_rx_decap_type)
  173. return soc->ops->ctrl_ops->txrx_get_vdev_rx_decap_type(vdev);
  174. return 0;
  175. }
  176. /**
  177. * @brief set the Reo Destination ring for the pdev
  178. * @details
  179. * This will be used to configure the Reo Destination ring for this pdev.
  180. *
  181. * @param soc - pointer to the soc
  182. * @param pdev - the data physical device object
  183. * @param val - the Reo destination ring index (1 to 4)
  184. * @return - void
  185. */
  186. static inline void
  187. cdp_set_pdev_reo_dest(ol_txrx_soc_handle soc,
  188. struct cdp_pdev *pdev, enum cdp_host_reo_dest_ring val)
  189. {
  190. if (soc->ops->ctrl_ops->txrx_set_pdev_reo_dest)
  191. return soc->ops->ctrl_ops->txrx_set_pdev_reo_dest
  192. (pdev, val);
  193. return;
  194. }
  195. /**
  196. * @brief get the Reo Destination ring for the pdev
  197. *
  198. * @param soc - pointer to the soc
  199. * @param pdev - the data physical device object
  200. * @return - the Reo destination ring index (1 to 4), 0 if not supported.
  201. */
  202. static inline enum cdp_host_reo_dest_ring
  203. cdp_get_pdev_reo_dest(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  204. {
  205. if (soc->ops->ctrl_ops->txrx_get_pdev_reo_dest)
  206. return soc->ops->ctrl_ops->txrx_get_pdev_reo_dest(pdev);
  207. return cdp_host_reo_dest_ring_unknown;
  208. }
  209. /* Is this similar to ol_txrx_peer_state_update() in MCL */
  210. /**
  211. * @brief Update the authorize peer object at association time
  212. * @details
  213. * For the host-based implementation of rate-control, it
  214. * updates the peer/node-related parameters within rate-control
  215. * context of the peer at association.
  216. *
  217. * @param peer - pointer to the node's object
  218. * @authorize - either to authorize or unauthorize peer
  219. *
  220. * @return none
  221. */
  222. static inline void
  223. cdp_peer_authorize(ol_txrx_soc_handle soc,
  224. struct ol_txrx_peer_t *peer, u_int32_t authorize)
  225. {
  226. if (soc->ops->ctrl_ops->txrx_peer_authorize)
  227. return soc->ops->ctrl_ops->txrx_peer_authorize
  228. (peer, authorize);
  229. return;
  230. }
  231. static inline bool
  232. cdp_set_inact_params(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  233. u_int16_t inact_check_interval,
  234. u_int16_t inact_normal,
  235. u_int16_t inact_overload)
  236. {
  237. if (!soc || !pdev)
  238. return false;
  239. if (soc->ops->ctrl_ops->txrx_set_inact_params)
  240. return soc->ops->ctrl_ops->txrx_set_inact_params
  241. (pdev, inact_check_interval, inact_normal,
  242. inact_overload);
  243. return false;
  244. }
  245. static inline bool
  246. cdp_start_inact_timer(ol_txrx_soc_handle soc,
  247. struct cdp_pdev *pdev,
  248. bool enable)
  249. {
  250. if (!soc || !pdev)
  251. return false;
  252. if (soc->ops->ctrl_ops->txrx_start_inact_timer)
  253. return soc->ops->ctrl_ops->txrx_start_inact_timer
  254. (pdev, enable);
  255. return false;
  256. }
  257. /**
  258. * @brief Set the overload status of the radio
  259. * @details
  260. * Set the overload status of the radio, updating the inactivity
  261. * threshold and inactivity count for each node.
  262. *
  263. * @param pdev - the data physical device object
  264. * @param overload - whether the radio is overloaded or not
  265. */
  266. static inline void
  267. cdp_set_overload(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  268. bool overload)
  269. {
  270. if (!soc || !pdev)
  271. return;
  272. if (soc->ops->ctrl_ops->txrx_set_overload)
  273. return soc->ops->ctrl_ops->txrx_set_overload(pdev, overload);
  274. return;
  275. }
  276. /**
  277. * @brief Check the inactivity status of the peer/node
  278. *
  279. * @param peer - pointer to the node's object
  280. * @return true if the node is inactive; otherwise return false
  281. */
  282. static inline bool
  283. cdp_peer_is_inact(ol_txrx_soc_handle soc, void *peer)
  284. {
  285. if (!soc || !peer)
  286. return false;
  287. if (soc->ops->ctrl_ops->txrx_peer_is_inact)
  288. return soc->ops->ctrl_ops->txrx_peer_is_inact(peer);
  289. return false;
  290. }
  291. /**
  292. * @brief Mark inactivity status of the peer/node
  293. * @details
  294. * If it becomes active, reset inactivity count to reload value;
  295. * if the inactivity status changed, notify umac band steering.
  296. *
  297. * @param peer - pointer to the node's object
  298. * @param inactive - whether the node is inactive or not
  299. */
  300. static inline void
  301. cdp_mark_peer_inact(ol_txrx_soc_handle soc,
  302. void *peer,
  303. bool inactive)
  304. {
  305. if (soc->ops->ctrl_ops->txrx_mark_peer_inact)
  306. return soc->ops->ctrl_ops->txrx_mark_peer_inact
  307. (peer, inactive);
  308. return;
  309. }
  310. /* Should be ol_txrx_ctrl_api.h */
  311. static inline void cdp_set_mesh_mode
  312. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev, u_int32_t val)
  313. {
  314. if (soc->ops->ctrl_ops->txrx_set_mesh_mode)
  315. return soc->ops->ctrl_ops->txrx_set_mesh_mode(vdev, val);
  316. return;
  317. }
  318. /**
  319. * @brief set mesh rx filter
  320. * @details based on the bits enabled in the filter packets has to be dropped.
  321. *
  322. * @param soc - pointer to the soc
  323. * @param vdev - the data virtual device object
  324. * @param val - value to be set
  325. * @return - void
  326. */
  327. static inline
  328. void cdp_set_mesh_rx_filter(ol_txrx_soc_handle soc,
  329. struct cdp_vdev *vdev, uint32_t val)
  330. {
  331. if (soc->ops->ctrl_ops->txrx_set_mesh_rx_filter)
  332. return soc->ops->ctrl_ops->txrx_set_mesh_rx_filter(vdev, val);
  333. return;
  334. }
  335. static inline void cdp_tx_flush_buffers
  336. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  337. {
  338. if (soc->ops->ctrl_ops->tx_flush_buffers)
  339. return soc->ops->ctrl_ops->tx_flush_buffers(vdev);
  340. return;
  341. }
  342. static inline void cdp_txrx_set_vdev_param(ol_txrx_soc_handle soc,
  343. struct cdp_vdev *vdev, enum cdp_vdev_param_type type,
  344. uint32_t val)
  345. {
  346. if (soc->ops->ctrl_ops->txrx_set_vdev_param)
  347. return soc->ops->ctrl_ops->txrx_set_vdev_param(vdev, type, val);
  348. return;
  349. }
  350. static inline void
  351. cdp_peer_set_nawds(ol_txrx_soc_handle soc,
  352. struct ol_txrx_peer_t *peer, uint8_t value)
  353. {
  354. if (soc->ops->ctrl_ops->txrx_peer_set_nawds)
  355. return soc->ops->ctrl_ops->txrx_peer_set_nawds
  356. (peer, value);
  357. return;
  358. }
  359. /**
  360. * @brief Subscribe to a specified WDI event.
  361. * @details
  362. * This function adds the provided wdi_event_subscribe object to a list of
  363. * subscribers for the specified WDI event.
  364. * When the event in question happens, each subscriber for the event will
  365. * have their callback function invoked.
  366. * The order in which callback functions from multiple subscribers are
  367. * invoked is unspecified.
  368. *
  369. * @param soc - pointer to the soc
  370. * @param pdev - the data physical device object
  371. * @param event_cb_sub - the callback and context for the event subscriber
  372. * @param event - which event's notifications are being subscribed to
  373. * @return - int
  374. */
  375. static inline int
  376. cdp_wdi_event_sub(ol_txrx_soc_handle soc,
  377. struct cdp_pdev *pdev, void *event_cb_sub, uint32_t event)
  378. {
  379. if (!soc || !soc->ops || !soc->ops->ctrl_ops) {
  380. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  381. "%s invalid instance", __func__);
  382. return 0;
  383. }
  384. if (soc->ops->ctrl_ops->txrx_wdi_event_sub)
  385. return soc->ops->ctrl_ops->txrx_wdi_event_sub
  386. (pdev, event_cb_sub, event);
  387. return 0;
  388. }
  389. /**
  390. * @brief Unsubscribe from a specified WDI event.
  391. * @details
  392. * This function removes the provided event subscription object from the
  393. * list of subscribers for its event.
  394. * This function shall only be called if there was a successful prior call
  395. * to event_sub() on the same wdi_event_subscribe object.
  396. *
  397. * @param soc - pointer to the soc
  398. * @param pdev - the data physical device object
  399. * @param event_cb_sub - the callback and context for the event subscriber
  400. * @param event - which event's notifications are being subscribed to
  401. * @return - int
  402. */
  403. static inline int
  404. cdp_wdi_event_unsub(ol_txrx_soc_handle soc,
  405. struct cdp_pdev *pdev, void *event_cb_sub, uint32_t event)
  406. {
  407. if (!soc || !soc->ops || !soc->ops->ctrl_ops) {
  408. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  409. "%s invalid instance", __func__);
  410. return 0;
  411. }
  412. if (soc->ops->ctrl_ops->txrx_wdi_event_unsub)
  413. return soc->ops->ctrl_ops->txrx_wdi_event_unsub
  414. (pdev, event_cb_sub, event);
  415. return 0;
  416. }
  417. #endif