cdp_txrx_misc.h 12 KB

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