cdp_txrx_ctrl.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. static inline int
  50. cdp_set_filter_neighbour_peers(ol_txrx_soc_handle soc,
  51. struct cdp_pdev *pdev, u_int32_t val)
  52. {
  53. if (soc->ops->ctrl_ops->txrx_set_filter_neighbour_peers)
  54. return soc->ops->ctrl_ops->txrx_set_filter_neighbour_peers
  55. (pdev, val);
  56. return 0;
  57. }
  58. /**
  59. * @brief set the safemode of the device
  60. * @details
  61. * This flag is used to bypass the encrypt and decrypt processes when send and
  62. * receive packets. It works like open AUTH mode, HW will treate all packets
  63. * as non-encrypt frames because no key installed. For rx fragmented frames,
  64. * it bypasses all the rx defragmentaion.
  65. *
  66. * @param vdev - the data virtual device object
  67. * @param val - the safemode state
  68. * @return - void
  69. */
  70. static inline void
  71. cdp_set_safemode(ol_txrx_soc_handle soc,
  72. struct cdp_vdev *vdev, u_int32_t val)
  73. {
  74. if (soc->ops->ctrl_ops->txrx_set_safemode)
  75. return soc->ops->ctrl_ops->txrx_set_safemode(vdev, val);
  76. return;
  77. }
  78. /**
  79. * @brief configure the drop unencrypted frame flag
  80. * @details
  81. * Rx related. When set this flag, all the unencrypted frames
  82. * received over a secure connection will be discarded
  83. *
  84. * @param vdev - the data virtual device object
  85. * @param val - flag
  86. * @return - void
  87. */
  88. static inline void
  89. cdp_set_drop_unenc(ol_txrx_soc_handle soc,
  90. struct cdp_vdev *vdev, u_int32_t val)
  91. {
  92. if (soc->ops->ctrl_ops->txrx_set_drop_unenc)
  93. return soc->ops->ctrl_ops->txrx_set_drop_unenc(vdev, val);
  94. return;
  95. }
  96. /**
  97. * @brief set the Tx encapsulation type of the VDEV
  98. * @details
  99. * This will be used to populate the HTT desc packet type field during Tx
  100. *
  101. * @param vdev - the data virtual device object
  102. * @param val - the Tx encap type (htt_cmn_pkt_type)
  103. * @return - void
  104. */
  105. static inline void
  106. cdp_set_tx_encap_type(ol_txrx_soc_handle soc,
  107. struct cdp_vdev *vdev, enum htt_cmn_pkt_type val)
  108. {
  109. if (soc->ops->ctrl_ops->txrx_set_tx_encap_type)
  110. return soc->ops->ctrl_ops->txrx_set_tx_encap_type(vdev, val);
  111. return;
  112. }
  113. /**
  114. * @brief set the Rx decapsulation type of the VDEV
  115. * @details
  116. * This will be used to configure into firmware and hardware which format to
  117. * decap all Rx packets into, for all peers under the VDEV.
  118. *
  119. * @param vdev - the data virtual device object
  120. * @param val - the Rx decap mode (htt_cmn_pkt_type)
  121. * @return - void
  122. */
  123. static inline void
  124. cdp_set_vdev_rx_decap_type(ol_txrx_soc_handle soc,
  125. struct cdp_vdev *vdev, enum htt_cmn_pkt_type val)
  126. {
  127. if (soc->ops->ctrl_ops->txrx_set_vdev_rx_decap_type)
  128. return soc->ops->ctrl_ops->txrx_set_vdev_rx_decap_type
  129. (vdev, val);
  130. return;
  131. }
  132. /**
  133. * @brief get the Rx decapsulation type of the VDEV
  134. *
  135. * @param vdev - the data virtual device object
  136. * @return - the Rx decap type (htt_cmn_pkt_type)
  137. */
  138. static inline enum htt_cmn_pkt_type
  139. cdp_get_vdev_rx_decap_type(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  140. {
  141. if (soc->ops->ctrl_ops->txrx_get_vdev_rx_decap_type)
  142. return soc->ops->ctrl_ops->txrx_get_vdev_rx_decap_type(vdev);
  143. return 0;
  144. }
  145. /* Is this similar to ol_txrx_peer_state_update() in MCL */
  146. /**
  147. * @brief Update the authorize peer object at association time
  148. * @details
  149. * For the host-based implementation of rate-control, it
  150. * updates the peer/node-related parameters within rate-control
  151. * context of the peer at association.
  152. *
  153. * @param peer - pointer to the node's object
  154. * @authorize - either to authorize or unauthorize peer
  155. *
  156. * @return none
  157. */
  158. static inline void
  159. cdp_peer_authorize(ol_txrx_soc_handle soc,
  160. struct ol_txrx_peer_t *peer, u_int32_t authorize)
  161. {
  162. if (soc->ops->ctrl_ops->txrx_peer_authorize)
  163. return soc->ops->ctrl_ops->txrx_peer_authorize
  164. (peer, authorize);
  165. return;
  166. }
  167. static inline bool
  168. cdp_set_inact_params(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  169. u_int16_t inact_check_interval,
  170. u_int16_t inact_normal,
  171. u_int16_t inact_overload)
  172. {
  173. if (soc->ops->ctrl_ops->txrx_set_inact_params)
  174. return soc->ops->ctrl_ops->txrx_set_inact_params
  175. (pdev, inact_check_interval, inact_normal,
  176. inact_overload);
  177. return false;
  178. }
  179. static inline bool
  180. cdp_start_inact_timer(ol_txrx_soc_handle soc,
  181. struct cdp_pdev *pdev,
  182. bool enable)
  183. {
  184. if (soc->ops->ctrl_ops->txrx_start_inact_timer)
  185. return soc->ops->ctrl_ops->txrx_start_inact_timer
  186. (pdev, enable);
  187. return false;
  188. }
  189. /**
  190. * @brief Set the overload status of the radio
  191. * @details
  192. * Set the overload status of the radio, updating the inactivity
  193. * threshold and inactivity count for each node.
  194. *
  195. * @param pdev - the data physical device object
  196. * @param overload - whether the radio is overloaded or not
  197. */
  198. static inline void
  199. cdp_set_overload(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  200. bool overload)
  201. {
  202. if (soc->ops->ctrl_ops->txrx_set_overload)
  203. return soc->ops->ctrl_ops->txrx_set_overload(pdev, overload);
  204. return;
  205. }
  206. /**
  207. * @brief Check the inactivity status of the peer/node
  208. *
  209. * @param peer - pointer to the node's object
  210. * @return true if the node is inactive; otherwise return false
  211. */
  212. static inline bool
  213. cdp_peer_is_inact(ol_txrx_soc_handle soc, void *peer)
  214. {
  215. if (soc->ops->ctrl_ops->txrx_peer_is_inact)
  216. return soc->ops->ctrl_ops->txrx_peer_is_inact(peer);
  217. return false;
  218. }
  219. /**
  220. * @brief Mark inactivity status of the peer/node
  221. * @details
  222. * If it becomes active, reset inactivity count to reload value;
  223. * if the inactivity status changed, notify umac band steering.
  224. *
  225. * @param peer - pointer to the node's object
  226. * @param inactive - whether the node is inactive or not
  227. */
  228. static inline void
  229. cdp_mark_peer_inact(ol_txrx_soc_handle soc,
  230. void *peer,
  231. bool inactive)
  232. {
  233. if (soc->ops->ctrl_ops->txrx_mark_peer_inact)
  234. return soc->ops->ctrl_ops->txrx_mark_peer_inact
  235. (peer, inactive);
  236. return;
  237. }
  238. /* Should be ol_txrx_ctrl_api.h */
  239. static inline void cdp_set_mesh_mode
  240. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev, u_int32_t val)
  241. {
  242. if (soc->ops->ctrl_ops->txrx_set_mesh_mode)
  243. return soc->ops->ctrl_ops->txrx_set_mesh_mode(vdev, val);
  244. return;
  245. }
  246. static inline void cdp_tx_flush_buffers
  247. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  248. {
  249. if (soc->ops->ctrl_ops->tx_flush_buffers)
  250. return soc->ops->ctrl_ops->tx_flush_buffers(vdev);
  251. return;
  252. }
  253. #endif