cdp_txrx_misc.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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_misc.h
  28. * @brief Define the host data path miscelleneous API functions
  29. * called by the host control SW and the OS interface module
  30. */
  31. #ifndef _CDP_TXRX_MISC_H_
  32. #define _CDP_TXRX_MISC_H_
  33. #include "cdp_txrx_handle.h"
  34. /**
  35. * cdp_tx_non_std() - Allow the control-path SW to send data frames
  36. *
  37. * @soc - data path soc handle
  38. * @data_vdev - which vdev should transmit the tx data frames
  39. * @tx_spec - what non-standard handling to apply to the tx data frames
  40. * @msdu_list - NULL-terminated list of tx MSDUs
  41. *
  42. * Generally, all tx data frames come from the OS shim into the txrx layer.
  43. * However, there are rare cases such as TDLS messaging where the UMAC
  44. * control-path SW creates tx data frames.
  45. * This UMAC SW can call this function to provide the tx data frames to
  46. * the txrx layer.
  47. * The UMAC SW can request a callback for these data frames after their
  48. * transmission completes, by using the ol_txrx_data_tx_cb_set function
  49. * to register a tx completion callback, and by specifying
  50. * ol_tx_spec_no_free as the tx_spec arg when giving the frames to
  51. * ol_tx_non_std.
  52. * The MSDUs need to have the appropriate L2 header type (802.3 vs. 802.11),
  53. * as specified by ol_cfg_frame_type().
  54. *
  55. * Return: null - success, skb - failure
  56. */
  57. static inline qdf_nbuf_t
  58. cdp_tx_non_std(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  59. enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list)
  60. {
  61. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  62. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  63. "%s invalid instance", __func__);
  64. return NULL;
  65. }
  66. if (soc->ops->misc_ops->tx_non_std)
  67. return soc->ops->misc_ops->tx_non_std(
  68. vdev, tx_spec, msdu_list);
  69. return NULL;
  70. }
  71. /**
  72. * cdp_set_ibss_vdev_heart_beat_timer() - Update ibss vdev heart
  73. * beat timer
  74. * @soc - data path soc handle
  75. * @vdev - vdev handle
  76. * @timer_value_sec - new heart beat timer value
  77. *
  78. * Return: Old timer value set in vdev.
  79. */
  80. static inline uint16_t
  81. cdp_set_ibss_vdev_heart_beat_timer(ol_txrx_soc_handle soc,
  82. struct cdp_vdev *vdev, uint16_t timer_value_sec)
  83. {
  84. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  85. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  86. "%s invalid instance", __func__);
  87. return 0;
  88. }
  89. if (soc->ops->misc_ops->set_ibss_vdev_heart_beat_timer)
  90. return soc->ops->misc_ops->set_ibss_vdev_heart_beat_timer(
  91. vdev, timer_value_sec);
  92. return 0;
  93. }
  94. /**
  95. * cdp_set_wisa_mode() - set wisa mode
  96. * @soc - data path soc handle
  97. * @vdev - vdev handle
  98. * @enable - enable or disable
  99. *
  100. * Return: QDF_STATUS_SUCCESS mode enable success
  101. */
  102. static inline QDF_STATUS
  103. cdp_set_wisa_mode(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, bool enable)
  104. {
  105. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  106. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  107. "%s invalid instance", __func__);
  108. return QDF_STATUS_E_INVAL;
  109. }
  110. if (soc->ops->misc_ops->set_wisa_mode)
  111. return soc->ops->misc_ops->set_wisa_mode(vdev, enable);
  112. return QDF_STATUS_SUCCESS;
  113. }
  114. /**
  115. * cdp_set_wmm_param() - set wmm parameter
  116. * @soc - data path soc handle
  117. * @pdev - device instance pointer
  118. * @wmm_param - wmm parameter
  119. *
  120. * Return: none
  121. */
  122. static inline void
  123. cdp_set_wmm_param(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  124. struct ol_tx_wmm_param_t wmm_param)
  125. {
  126. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  127. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  128. "%s invalid instance", __func__);
  129. return;
  130. }
  131. if (soc->ops->misc_ops->set_wmm_param)
  132. return soc->ops->misc_ops->set_wmm_param(
  133. pdev, wmm_param);
  134. return;
  135. }
  136. /**
  137. * cdp_runtime_suspend() - suspend
  138. * @soc - data path soc handle
  139. * @pdev - device instance pointer
  140. *
  141. * Return: QDF_STATUS_SUCCESS suspend success
  142. */
  143. static inline QDF_STATUS cdp_runtime_suspend(ol_txrx_soc_handle soc,
  144. struct cdp_pdev *pdev)
  145. {
  146. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  147. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  148. "%s invalid instance", __func__);
  149. return QDF_STATUS_E_INVAL;
  150. }
  151. if (soc->ops->misc_ops->runtime_suspend)
  152. return soc->ops->misc_ops->runtime_suspend(pdev);
  153. return QDF_STATUS_SUCCESS;
  154. }
  155. /**
  156. * cdp_runtime_resume() - resume
  157. * @soc - data path soc handle
  158. * @pdev - device instance pointer
  159. *
  160. * Return: QDF_STATUS_SUCCESS suspend success
  161. */
  162. static inline QDF_STATUS cdp_runtime_resume(ol_txrx_soc_handle soc,
  163. struct cdp_pdev *pdev)
  164. {
  165. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  166. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  167. "%s invalid instance", __func__);
  168. return QDF_STATUS_E_INVAL;
  169. }
  170. if (soc->ops->misc_ops->runtime_resume)
  171. return soc->ops->misc_ops->runtime_resume(pdev);
  172. return QDF_STATUS_SUCCESS;
  173. }
  174. /**
  175. * cdp_hl_tdls_flag_reset() - tdls flag reset
  176. * @soc - data path soc handle
  177. * @vdev - virtual interface handle pointer
  178. * @flag
  179. *
  180. * Return: none
  181. */
  182. static inline void
  183. cdp_hl_tdls_flag_reset(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, bool flag)
  184. {
  185. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  186. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  187. "%s invalid instance", __func__);
  188. return;
  189. }
  190. if (soc->ops->misc_ops->hl_tdls_flag_reset)
  191. return soc->ops->misc_ops->hl_tdls_flag_reset(vdev, flag);
  192. return;
  193. }
  194. /**
  195. * cdp_get_opmode() - get vdev operation mode
  196. * @soc - data path soc handle
  197. * @vdev - virtual interface instance
  198. *
  199. * Return virtual device operational mode
  200. * op_mode_ap,
  201. * op_mode_ibss,
  202. * op_mode_sta,
  203. * op_mode_monitor,
  204. * op_mode_ocb,
  205. *
  206. * return interface id
  207. * 0 unknown interface
  208. */
  209. static inline int
  210. cdp_get_opmode(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  211. {
  212. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  213. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  214. "%s invalid instance", __func__);
  215. return 0;
  216. }
  217. if (soc->ops->misc_ops->get_opmode)
  218. return soc->ops->misc_ops->get_opmode(vdev);
  219. return 0;
  220. }
  221. /**
  222. * cdp_get_vdev_id() - get vdev id
  223. * @soc - data path soc handle
  224. * @vdev - virtual interface instance
  225. *
  226. * get virtual interface id
  227. *
  228. * return interface id
  229. * 0 unknown interface
  230. */
  231. static inline uint16_t
  232. cdp_get_vdev_id(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  233. {
  234. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  235. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  236. "%s invalid instance", __func__);
  237. return 0;
  238. }
  239. if (soc->ops->misc_ops->get_vdev_id)
  240. return soc->ops->misc_ops->get_vdev_id(vdev);
  241. return 0;
  242. }
  243. /**
  244. * cdp_bad_peer_txctl_set_setting() - TBD
  245. * @soc - data path soc handle
  246. * @pdev - data path device instance
  247. * @enable -
  248. * @period -
  249. * @txq_limit -
  250. *
  251. * TBD
  252. *
  253. * Return: none
  254. */
  255. static inline void
  256. cdp_bad_peer_txctl_set_setting(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  257. int enable, int period, int txq_limit)
  258. {
  259. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  260. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  261. "%s invalid instance", __func__);
  262. return;
  263. }
  264. if (soc->ops->misc_ops->bad_peer_txctl_set_setting)
  265. return soc->ops->misc_ops->bad_peer_txctl_set_setting(pdev,
  266. enable, period, txq_limit);
  267. return;
  268. }
  269. /**
  270. * cdp_bad_peer_txctl_update_threshold() - TBD
  271. * @soc - data path soc handle
  272. * @pdev - data path device instance
  273. * @level -
  274. * @tput_thresh -
  275. * @tx_limit -
  276. *
  277. * TBD
  278. *
  279. * Return: none
  280. */
  281. static inline void
  282. cdp_bad_peer_txctl_update_threshold(ol_txrx_soc_handle soc,
  283. struct cdp_pdev *pdev,
  284. int level, int tput_thresh, int tx_limit)
  285. {
  286. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  287. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  288. "%s invalid instance", __func__);
  289. return;
  290. }
  291. if (soc->ops->misc_ops->bad_peer_txctl_update_threshold)
  292. return soc->ops->misc_ops->bad_peer_txctl_update_threshold(
  293. pdev, level, tput_thresh, tx_limit);
  294. return;
  295. }
  296. /**
  297. * cdp_mark_first_wakeup_packet() - set flag to indicate that
  298. * fw is compatible for marking first packet after wow wakeup
  299. * @soc - data path soc handle
  300. * @value: 1 for enabled/ 0 for disabled
  301. *
  302. * Return: None
  303. */
  304. static inline void cdp_mark_first_wakeup_packet(ol_txrx_soc_handle soc,
  305. uint8_t value)
  306. {
  307. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  308. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  309. "%s invalid instance", __func__);
  310. return;
  311. }
  312. if (soc->ops->misc_ops->mark_first_wakeup_packet)
  313. return soc->ops->misc_ops->mark_first_wakeup_packet(value);
  314. return;
  315. }
  316. /**
  317. * cds_update_mac_id() - update mac_id for vdev
  318. * @soc - data path soc handle
  319. * @vdev_id: vdev id
  320. * @mac_id: mac id
  321. *
  322. * Return: none
  323. */
  324. static inline void cdp_update_mac_id(void *psoc, uint8_t vdev_id,
  325. uint8_t mac_id)
  326. {
  327. ol_txrx_soc_handle soc = psoc;
  328. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  329. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  330. "%s invalid instance", __func__);
  331. return;
  332. }
  333. if (soc->ops->misc_ops->update_mac_id)
  334. return soc->ops->misc_ops->update_mac_id(vdev_id, mac_id);
  335. return;
  336. }
  337. /**
  338. * cdp_flush_rx_frames() - flush cached rx frames
  339. * @soc - data path soc handle
  340. * @peer: peer
  341. * @drop: set flag to drop frames
  342. *
  343. * Return: None
  344. */
  345. static inline void cdp_flush_rx_frames(ol_txrx_soc_handle soc, void *peer,
  346. bool drop)
  347. {
  348. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  349. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  350. "%s invalid instance", __func__);
  351. return;
  352. }
  353. if (soc->ops->misc_ops->flush_rx_frames)
  354. return soc->ops->misc_ops->flush_rx_frames(peer, drop);
  355. return;
  356. }
  357. /*
  358. * cdp_get_intra_bss_fwd_pkts_count() - to get the total tx and rx packets
  359. * that has been forwarded from txrx layer without going to upper layers.
  360. * @vdev_id: vdev id
  361. * @fwd_tx_packets: pointer to forwarded tx packets count parameter
  362. * @fwd_rx_packets: pointer to forwarded rx packets count parameter
  363. *
  364. * Return: status -> A_OK - success, A_ERROR - failure
  365. */
  366. static inline A_STATUS cdp_get_intra_bss_fwd_pkts_count(
  367. ol_txrx_soc_handle soc, uint8_t vdev_id,
  368. uint64_t *fwd_tx_packets, uint64_t *fwd_rx_packets)
  369. {
  370. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  371. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  372. "%s invalid instance", __func__);
  373. return 0;
  374. }
  375. if (soc->ops->misc_ops->get_intra_bss_fwd_pkts_count)
  376. return soc->ops->misc_ops->get_intra_bss_fwd_pkts_count(
  377. vdev_id, fwd_tx_packets, fwd_rx_packets);
  378. return 0;
  379. }
  380. /**
  381. * cdp_pkt_log_init() - API to initialize packet log
  382. * @handle: pdev handle
  383. * @scn: HIF context
  384. *
  385. * Return: void
  386. */
  387. static inline void cdp_pkt_log_init(ol_txrx_soc_handle soc,
  388. struct cdp_pdev *pdev, void *scn)
  389. {
  390. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  391. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  392. "%s invalid instance", __func__);
  393. return;
  394. }
  395. if (soc->ops->misc_ops->pkt_log_init)
  396. return soc->ops->misc_ops->pkt_log_init(pdev, scn);
  397. return;
  398. }
  399. /**
  400. * cdp_pkt_log_con_service() - API to connect packet log service
  401. * @handle: pdev handle
  402. * @scn: HIF context
  403. *
  404. * Return: void
  405. */
  406. static inline void cdp_pkt_log_con_service(ol_txrx_soc_handle soc,
  407. struct cdp_pdev *pdev, void *scn)
  408. {
  409. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  410. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  411. "%s invalid instance", __func__);
  412. return;
  413. }
  414. if (soc->ops->misc_ops->pkt_log_con_service)
  415. return soc->ops->misc_ops->pkt_log_con_service(pdev, scn);
  416. return;
  417. }
  418. #endif /* _CDP_TXRX_MISC_H_ */