cdp_txrx_misc.h 15 KB

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