cdp_txrx_cmn.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  1. /*
  2. * Copyright (c) 2011-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_cmn.h
  28. * @brief Define the host data path converged API functions
  29. * called by the host control SW and the OS interface module
  30. */
  31. #ifndef _CDP_TXRX_CMN_H_
  32. #define _CDP_TXRX_CMN_H_
  33. #include "qdf_types.h"
  34. #include "qdf_nbuf.h"
  35. #include "cdp_txrx_ops.h"
  36. #include "cdp_txrx_handle.h"
  37. #include "cdp_txrx_cmn_struct.h"
  38. /******************************************************************************
  39. *
  40. * Common Data Path Header File
  41. *
  42. *****************************************************************************/
  43. static inline int
  44. cdp_soc_attach_target(ol_txrx_soc_handle soc)
  45. {
  46. if (!soc || !soc->ops) {
  47. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  48. "%s: Invalid Instance:", __func__);
  49. QDF_BUG(0);
  50. return 0;
  51. }
  52. if (!soc->ops->cmn_drv_ops ||
  53. !soc->ops->cmn_drv_ops->txrx_soc_attach_target)
  54. return 0;
  55. return soc->ops->cmn_drv_ops->txrx_soc_attach_target(soc);
  56. }
  57. static inline int
  58. cdp_soc_get_nss_cfg(ol_txrx_soc_handle soc)
  59. {
  60. if (!soc || !soc->ops) {
  61. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  62. "%s: Invalid Instance:", __func__);
  63. QDF_BUG(0);
  64. return 0;
  65. }
  66. if (!soc->ops->cmn_drv_ops ||
  67. !soc->ops->cmn_drv_ops->txrx_soc_get_nss_cfg)
  68. return 0;
  69. return soc->ops->cmn_drv_ops->txrx_soc_get_nss_cfg(soc);
  70. }
  71. static inline void
  72. cdp_soc_set_nss_cfg(ol_txrx_soc_handle soc, uint32_t config)
  73. {
  74. if (!soc || !soc->ops) {
  75. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  76. "%s: Invalid Instance:", __func__);
  77. QDF_BUG(0);
  78. return;
  79. }
  80. if (!soc->ops->cmn_drv_ops ||
  81. !soc->ops->cmn_drv_ops->txrx_soc_set_nss_cfg)
  82. return;
  83. soc->ops->cmn_drv_ops->txrx_soc_set_nss_cfg(soc, config);
  84. }
  85. static inline struct cdp_vdev *
  86. cdp_vdev_attach(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  87. uint8_t *vdev_mac_addr, uint8_t vdev_id, enum wlan_op_mode op_mode)
  88. {
  89. if (!soc || !soc->ops) {
  90. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  91. "%s: Invalid Instance:", __func__);
  92. QDF_BUG(0);
  93. return NULL;
  94. }
  95. if (!soc->ops->cmn_drv_ops ||
  96. !soc->ops->cmn_drv_ops->txrx_vdev_attach)
  97. return NULL;
  98. return soc->ops->cmn_drv_ops->txrx_vdev_attach(pdev,
  99. vdev_mac_addr, vdev_id, op_mode);
  100. }
  101. static inline void
  102. cdp_vdev_detach(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  103. ol_txrx_vdev_delete_cb callback, void *cb_context)
  104. {
  105. if (!soc || !soc->ops) {
  106. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  107. "%s: Invalid Instance:", __func__);
  108. QDF_BUG(0);
  109. return;
  110. }
  111. if (!soc->ops->cmn_drv_ops ||
  112. !soc->ops->cmn_drv_ops->txrx_vdev_detach)
  113. return;
  114. soc->ops->cmn_drv_ops->txrx_vdev_detach(vdev,
  115. callback, cb_context);
  116. }
  117. static inline int
  118. cdp_pdev_attach_target(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  119. {
  120. if (!soc || !soc->ops) {
  121. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  122. "%s: Invalid Instance:", __func__);
  123. QDF_BUG(0);
  124. return 0;
  125. }
  126. if (!soc->ops->cmn_drv_ops ||
  127. !soc->ops->cmn_drv_ops->txrx_pdev_attach_target)
  128. return 0;
  129. return soc->ops->cmn_drv_ops->txrx_pdev_attach_target(pdev);
  130. }
  131. static inline struct cdp_pdev *cdp_pdev_attach
  132. (ol_txrx_soc_handle soc, struct cdp_cfg *ctrl_pdev,
  133. HTC_HANDLE htc_pdev, qdf_device_t osdev, uint8_t pdev_id)
  134. {
  135. if (!soc || !soc->ops) {
  136. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  137. "%s: Invalid Instance:", __func__);
  138. QDF_BUG(0);
  139. return NULL;
  140. }
  141. if (!soc->ops->cmn_drv_ops ||
  142. !soc->ops->cmn_drv_ops->txrx_pdev_attach)
  143. return NULL;
  144. return soc->ops->cmn_drv_ops->txrx_pdev_attach(soc, ctrl_pdev,
  145. htc_pdev, osdev, pdev_id);
  146. }
  147. static inline int cdp_pdev_post_attach(ol_txrx_soc_handle soc,
  148. struct cdp_pdev *pdev)
  149. {
  150. if (!soc || !soc->ops) {
  151. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  152. "%s: Invalid Instance:", __func__);
  153. QDF_BUG(0);
  154. return 0;
  155. }
  156. if (!soc->ops->cmn_drv_ops ||
  157. !soc->ops->cmn_drv_ops->txrx_pdev_post_attach)
  158. return 0;
  159. return soc->ops->cmn_drv_ops->txrx_pdev_post_attach(pdev);
  160. }
  161. static inline void
  162. cdp_pdev_pre_detach(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, int force)
  163. {
  164. if (!soc || !soc->ops) {
  165. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  166. "%s: Invalid Instance:", __func__);
  167. QDF_BUG(0);
  168. return;
  169. }
  170. if (!soc->ops->cmn_drv_ops ||
  171. !soc->ops->cmn_drv_ops->txrx_pdev_pre_detach)
  172. return;
  173. soc->ops->cmn_drv_ops->txrx_pdev_pre_detach(pdev, force);
  174. }
  175. static inline void
  176. cdp_pdev_detach(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, int force)
  177. {
  178. if (!soc || !soc->ops) {
  179. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  180. "%s: Invalid Instance:", __func__);
  181. QDF_BUG(0);
  182. return;
  183. }
  184. if (!soc->ops->cmn_drv_ops ||
  185. !soc->ops->cmn_drv_ops->txrx_pdev_detach)
  186. return;
  187. soc->ops->cmn_drv_ops->txrx_pdev_detach(pdev, force);
  188. }
  189. static inline void *cdp_peer_create
  190. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  191. uint8_t *peer_mac_addr)
  192. {
  193. if (!soc || !soc->ops) {
  194. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  195. "%s: Invalid Instance:", __func__);
  196. QDF_BUG(0);
  197. return NULL;
  198. }
  199. if (!soc->ops->cmn_drv_ops ||
  200. !soc->ops->cmn_drv_ops->txrx_peer_create)
  201. return NULL;
  202. return soc->ops->cmn_drv_ops->txrx_peer_create(vdev,
  203. peer_mac_addr);
  204. }
  205. static inline void cdp_peer_setup
  206. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev, void *peer)
  207. {
  208. if (!soc || !soc->ops) {
  209. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  210. "%s: Invalid Instance:", __func__);
  211. QDF_BUG(0);
  212. return;
  213. }
  214. if (!soc->ops->cmn_drv_ops ||
  215. !soc->ops->cmn_drv_ops->txrx_peer_setup)
  216. return;
  217. soc->ops->cmn_drv_ops->txrx_peer_setup(vdev,
  218. peer);
  219. }
  220. static inline void cdp_peer_teardown
  221. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev, void *peer)
  222. {
  223. if (!soc || !soc->ops) {
  224. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  225. "%s: Invalid Instance:", __func__);
  226. QDF_BUG(0);
  227. return;
  228. }
  229. if (!soc->ops->cmn_drv_ops ||
  230. !soc->ops->cmn_drv_ops->txrx_peer_teardown)
  231. return;
  232. soc->ops->cmn_drv_ops->txrx_peer_teardown(vdev, peer);
  233. }
  234. static inline void
  235. cdp_peer_delete(ol_txrx_soc_handle soc, void *peer, uint32_t bitmap)
  236. {
  237. if (!soc || !soc->ops) {
  238. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  239. "%s: Invalid Instance:", __func__);
  240. QDF_BUG(0);
  241. return;
  242. }
  243. if (!soc->ops->cmn_drv_ops ||
  244. !soc->ops->cmn_drv_ops->txrx_peer_delete)
  245. return;
  246. soc->ops->cmn_drv_ops->txrx_peer_delete(peer, bitmap);
  247. }
  248. static inline int
  249. cdp_set_monitor_mode(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  250. uint8_t smart_monitor)
  251. {
  252. if (!soc || !soc->ops) {
  253. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  254. "%s: Invalid Instance:", __func__);
  255. QDF_BUG(0);
  256. return 0;
  257. }
  258. if (!soc->ops->cmn_drv_ops ||
  259. !soc->ops->cmn_drv_ops->txrx_set_monitor_mode)
  260. return 0;
  261. return soc->ops->cmn_drv_ops->txrx_set_monitor_mode(vdev,
  262. smart_monitor);
  263. }
  264. static inline void
  265. cdp_set_curchan(ol_txrx_soc_handle soc,
  266. struct cdp_pdev *pdev,
  267. uint32_t chan_mhz)
  268. {
  269. if (!soc || !soc->ops) {
  270. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  271. "%s: Invalid Instance:", __func__);
  272. QDF_BUG(0);
  273. return;
  274. }
  275. if (!soc->ops->cmn_drv_ops ||
  276. !soc->ops->cmn_drv_ops->txrx_set_curchan)
  277. return;
  278. soc->ops->cmn_drv_ops->txrx_set_curchan(pdev, chan_mhz);
  279. }
  280. static inline void
  281. cdp_set_privacy_filters(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  282. void *filter, uint32_t num)
  283. {
  284. if (!soc || !soc->ops) {
  285. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  286. "%s: Invalid Instance:", __func__);
  287. QDF_BUG(0);
  288. return;
  289. }
  290. if (!soc->ops->cmn_drv_ops ||
  291. !soc->ops->cmn_drv_ops->txrx_set_privacy_filters)
  292. return;
  293. soc->ops->cmn_drv_ops->txrx_set_privacy_filters(vdev,
  294. filter, num);
  295. }
  296. /******************************************************************************
  297. * Data Interface (B Interface)
  298. *****************************************************************************/
  299. static inline void
  300. cdp_vdev_register(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  301. void *osif_vdev, struct ol_txrx_ops *txrx_ops)
  302. {
  303. if (!soc || !soc->ops) {
  304. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  305. "%s: Invalid Instance:", __func__);
  306. QDF_BUG(0);
  307. return;
  308. }
  309. if (!soc->ops->cmn_drv_ops ||
  310. !soc->ops->cmn_drv_ops->txrx_vdev_register)
  311. return;
  312. soc->ops->cmn_drv_ops->txrx_vdev_register(vdev,
  313. osif_vdev, txrx_ops);
  314. }
  315. static inline int
  316. cdp_mgmt_send(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  317. qdf_nbuf_t tx_mgmt_frm, uint8_t type)
  318. {
  319. if (!soc || !soc->ops) {
  320. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  321. "%s: Invalid Instance:", __func__);
  322. QDF_BUG(0);
  323. return 0;
  324. }
  325. if (!soc->ops->cmn_drv_ops ||
  326. !soc->ops->cmn_drv_ops->txrx_mgmt_send)
  327. return 0;
  328. return soc->ops->cmn_drv_ops->txrx_mgmt_send(vdev,
  329. tx_mgmt_frm, type);
  330. }
  331. static inline int
  332. cdp_mgmt_send_ext(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  333. qdf_nbuf_t tx_mgmt_frm, uint8_t type,
  334. uint8_t use_6mbps, uint16_t chanfreq)
  335. {
  336. if (!soc || !soc->ops) {
  337. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  338. "%s: Invalid Instance:", __func__);
  339. QDF_BUG(0);
  340. return 0;
  341. }
  342. if (!soc->ops->cmn_drv_ops ||
  343. !soc->ops->cmn_drv_ops->txrx_mgmt_send_ext)
  344. return 0;
  345. return soc->ops->cmn_drv_ops->txrx_mgmt_send_ext
  346. (vdev, tx_mgmt_frm, type, use_6mbps, chanfreq);
  347. }
  348. static inline void
  349. cdp_mgmt_tx_cb_set(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  350. uint8_t type, ol_txrx_mgmt_tx_cb download_cb,
  351. ol_txrx_mgmt_tx_cb ota_ack_cb, void *ctxt)
  352. {
  353. if (!soc || !soc->ops) {
  354. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  355. "%s: Invalid Instance:", __func__);
  356. QDF_BUG(0);
  357. return;
  358. }
  359. if (!soc->ops->cmn_drv_ops ||
  360. !soc->ops->cmn_drv_ops->txrx_mgmt_tx_cb_set)
  361. return;
  362. soc->ops->cmn_drv_ops->txrx_mgmt_tx_cb_set
  363. (pdev, type, download_cb, ota_ack_cb, ctxt);
  364. }
  365. static inline int cdp_get_tx_pending(ol_txrx_soc_handle soc,
  366. struct cdp_pdev *pdev)
  367. {
  368. if (!soc || !soc->ops) {
  369. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  370. "%s: Invalid Instance:", __func__);
  371. QDF_BUG(0);
  372. return 0;
  373. }
  374. if (!soc->ops->cmn_drv_ops ||
  375. !soc->ops->cmn_drv_ops->txrx_get_tx_pending)
  376. return 0;
  377. return soc->ops->cmn_drv_ops->txrx_get_tx_pending(pdev);
  378. }
  379. static inline void
  380. cdp_data_tx_cb_set(ol_txrx_soc_handle soc, struct cdp_vdev *data_vdev,
  381. ol_txrx_data_tx_cb callback, void *ctxt)
  382. {
  383. if (!soc || !soc->ops) {
  384. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  385. "%s: Invalid Instance:", __func__);
  386. QDF_BUG(0);
  387. return;
  388. }
  389. if (!soc->ops->cmn_drv_ops ||
  390. !soc->ops->cmn_drv_ops->txrx_data_tx_cb_set)
  391. return;
  392. soc->ops->cmn_drv_ops->txrx_data_tx_cb_set(data_vdev,
  393. callback, ctxt);
  394. }
  395. /******************************************************************************
  396. * Statistics and Debugging Interface (C Inteface)
  397. *****************************************************************************/
  398. /**
  399. * External Device physical address types
  400. *
  401. * Currently, both MAC and IPA uController use the same size addresses
  402. * and descriptors are exchanged between these two depending on the mode.
  403. *
  404. * Rationale: qdf_dma_addr_t is the type used internally on the host for DMA
  405. * operations. However, external device physical address sizes
  406. * may be different from host-specific physical address sizes.
  407. * This calls for the following definitions for target devices
  408. * (MAC, IPA uc).
  409. */
  410. #if HTT_PADDR64
  411. typedef uint64_t target_paddr_t;
  412. #else
  413. typedef uint32_t target_paddr_t;
  414. #endif /*HTT_PADDR64 */
  415. static inline int
  416. cdp_aggr_cfg(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  417. int max_subfrms_ampdu,
  418. int max_subfrms_amsdu)
  419. {
  420. if (!soc || !soc->ops) {
  421. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  422. "%s: Invalid Instance:", __func__);
  423. QDF_BUG(0);
  424. return 0;
  425. }
  426. if (!soc->ops->cmn_drv_ops ||
  427. !soc->ops->cmn_drv_ops->txrx_aggr_cfg)
  428. return 0;
  429. return soc->ops->cmn_drv_ops->txrx_aggr_cfg(vdev,
  430. max_subfrms_ampdu, max_subfrms_amsdu);
  431. }
  432. static inline int
  433. cdp_fw_stats_get(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  434. struct ol_txrx_stats_req *req, bool per_vdev,
  435. bool response_expected)
  436. {
  437. if (!soc || !soc->ops) {
  438. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  439. "%s: Invalid Instance:", __func__);
  440. QDF_BUG(0);
  441. return 0;
  442. }
  443. if (!soc->ops->cmn_drv_ops ||
  444. !soc->ops->cmn_drv_ops->txrx_fw_stats_get)
  445. return 0;
  446. return soc->ops->cmn_drv_ops->txrx_fw_stats_get(vdev, req,
  447. per_vdev, response_expected);
  448. }
  449. static inline int
  450. cdp_debug(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, int debug_specs)
  451. {
  452. if (!soc || !soc->ops) {
  453. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  454. "%s: Invalid Instance:", __func__);
  455. QDF_BUG(0);
  456. return 0;
  457. }
  458. if (!soc->ops->cmn_drv_ops ||
  459. !soc->ops->cmn_drv_ops->txrx_debug)
  460. return 0;
  461. return soc->ops->cmn_drv_ops->txrx_debug(vdev, debug_specs);
  462. }
  463. static inline void cdp_fw_stats_cfg(ol_txrx_soc_handle soc,
  464. struct cdp_vdev *vdev, uint8_t cfg_stats_type, uint32_t cfg_val)
  465. {
  466. if (!soc || !soc->ops) {
  467. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  468. "%s: Invalid Instance:", __func__);
  469. QDF_BUG(0);
  470. return;
  471. }
  472. if (!soc->ops->cmn_drv_ops ||
  473. !soc->ops->cmn_drv_ops->txrx_fw_stats_cfg)
  474. return;
  475. soc->ops->cmn_drv_ops->txrx_fw_stats_cfg(vdev,
  476. cfg_stats_type, cfg_val);
  477. }
  478. static inline void cdp_print_level_set(ol_txrx_soc_handle soc, unsigned level)
  479. {
  480. if (!soc || !soc->ops) {
  481. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  482. "%s: Invalid Instance:", __func__);
  483. QDF_BUG(0);
  484. return;
  485. }
  486. if (!soc->ops->cmn_drv_ops ||
  487. !soc->ops->cmn_drv_ops->txrx_print_level_set)
  488. return;
  489. soc->ops->cmn_drv_ops->txrx_print_level_set(level);
  490. }
  491. static inline uint8_t *
  492. cdp_get_vdev_mac_addr(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  493. {
  494. if (!soc || !soc->ops) {
  495. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  496. "%s: Invalid Instance:", __func__);
  497. QDF_BUG(0);
  498. return NULL;
  499. }
  500. if (!soc->ops->cmn_drv_ops ||
  501. !soc->ops->cmn_drv_ops->txrx_get_vdev_mac_addr)
  502. return NULL;
  503. return soc->ops->cmn_drv_ops->txrx_get_vdev_mac_addr(vdev);
  504. }
  505. /**
  506. * cdp_get_vdev_struct_mac_addr() - Return handle to struct qdf_mac_addr of
  507. * vdev
  508. * @vdev: vdev handle
  509. *
  510. * Return: Handle to struct qdf_mac_addr
  511. */
  512. static inline struct qdf_mac_addr *cdp_get_vdev_struct_mac_addr
  513. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  514. {
  515. if (!soc || !soc->ops) {
  516. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  517. "%s: Invalid Instance:", __func__);
  518. QDF_BUG(0);
  519. return NULL;
  520. }
  521. if (!soc->ops->cmn_drv_ops ||
  522. !soc->ops->cmn_drv_ops->txrx_get_vdev_struct_mac_addr)
  523. return NULL;
  524. return soc->ops->cmn_drv_ops->txrx_get_vdev_struct_mac_addr
  525. (vdev);
  526. }
  527. /**
  528. * cdp_get_pdev_from_vdev() - Return handle to pdev of vdev
  529. * @vdev: vdev handle
  530. *
  531. * Return: Handle to pdev
  532. */
  533. static inline struct cdp_pdev *cdp_get_pdev_from_vdev
  534. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  535. {
  536. if (!soc || !soc->ops) {
  537. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  538. "%s: Invalid Instance:", __func__);
  539. QDF_BUG(0);
  540. return NULL;
  541. }
  542. if (!soc->ops->cmn_drv_ops ||
  543. !soc->ops->cmn_drv_ops->txrx_get_pdev_from_vdev)
  544. return NULL;
  545. return soc->ops->cmn_drv_ops->txrx_get_pdev_from_vdev(vdev);
  546. }
  547. /**
  548. * cdp_get_ctrl_pdev_from_vdev() - Return control pdev of vdev
  549. * @vdev: vdev handle
  550. *
  551. * Return: Handle to control pdev
  552. */
  553. static inline struct cdp_cfg *
  554. cdp_get_ctrl_pdev_from_vdev(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  555. {
  556. if (!soc || !soc->ops) {
  557. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  558. "%s: Invalid Instance:", __func__);
  559. QDF_BUG(0);
  560. return NULL;
  561. }
  562. if (!soc->ops->cmn_drv_ops ||
  563. !soc->ops->cmn_drv_ops->txrx_get_ctrl_pdev_from_vdev)
  564. return NULL;
  565. return soc->ops->cmn_drv_ops->txrx_get_ctrl_pdev_from_vdev
  566. (vdev);
  567. }
  568. static inline struct cdp_vdev *
  569. cdp_get_vdev_from_vdev_id(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  570. uint8_t vdev_id)
  571. {
  572. if (!soc || !soc->ops) {
  573. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  574. "%s: Invalid Instance:", __func__);
  575. QDF_BUG(0);
  576. return NULL;
  577. }
  578. if (!soc->ops->cmn_drv_ops ||
  579. !soc->ops->cmn_drv_ops->txrx_get_vdev_from_vdev_id)
  580. return NULL;
  581. return soc->ops->cmn_drv_ops->txrx_get_vdev_from_vdev_id
  582. (pdev, vdev_id);
  583. }
  584. static inline void
  585. cdp_soc_detach(ol_txrx_soc_handle soc)
  586. {
  587. if (!soc || !soc->ops) {
  588. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  589. "%s: Invalid Instance:", __func__);
  590. QDF_BUG(0);
  591. return;
  592. }
  593. if (!soc->ops->cmn_drv_ops ||
  594. !soc->ops->cmn_drv_ops->txrx_soc_detach)
  595. return;
  596. soc->ops->cmn_drv_ops->txrx_soc_detach((void *)soc);
  597. }
  598. static inline int cdp_addba_requestprocess(ol_txrx_soc_handle soc,
  599. void *peer_handle, uint8_t dialogtoken, uint16_t tid,
  600. uint16_t batimeout, uint16_t buffersize, uint16_t startseqnum)
  601. {
  602. if (!soc || !soc->ops) {
  603. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  604. "%s: Invalid Instance:", __func__);
  605. QDF_BUG(0);
  606. return 0;
  607. }
  608. if (!soc->ops->cmn_drv_ops ||
  609. !soc->ops->cmn_drv_ops->addba_requestprocess)
  610. return 0;
  611. return soc->ops->cmn_drv_ops->addba_requestprocess(peer_handle,
  612. dialogtoken, tid, batimeout, buffersize, startseqnum);
  613. }
  614. static inline void cdp_addba_responsesetup(ol_txrx_soc_handle soc,
  615. void *peer_handle, uint8_t tid, uint8_t *dialogtoken,
  616. uint16_t *statuscode, uint16_t *buffersize, uint16_t *batimeout)
  617. {
  618. if (!soc || !soc->ops) {
  619. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  620. "%s: Invalid Instance:", __func__);
  621. QDF_BUG(0);
  622. return;
  623. }
  624. if (!soc->ops->cmn_drv_ops ||
  625. !soc->ops->cmn_drv_ops->addba_responsesetup)
  626. return;
  627. soc->ops->cmn_drv_ops->addba_responsesetup(peer_handle, tid,
  628. dialogtoken, statuscode, buffersize, batimeout);
  629. }
  630. static inline int cdp_delba_process(ol_txrx_soc_handle soc,
  631. void *peer_handle, int tid, uint16_t reasoncode)
  632. {
  633. if (!soc || !soc->ops) {
  634. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  635. "%s: Invalid Instance:", __func__);
  636. QDF_BUG(0);
  637. return 0;
  638. }
  639. if (!soc->ops->cmn_drv_ops ||
  640. !soc->ops->cmn_drv_ops->delba_process)
  641. return 0;
  642. return soc->ops->cmn_drv_ops->delba_process(peer_handle,
  643. tid, reasoncode);
  644. }
  645. /**
  646. * cdp_get_peer_mac_addr_frm_id: function to return vdev id and and peer
  647. * mac address
  648. * @soc: SOC handle
  649. * @peer_id: peer id of the peer for which mac_address is required
  650. * @mac_addr: reference to mac address
  651. *
  652. * reutm: vdev_id of the vap
  653. */
  654. static inline uint8_t
  655. cdp_get_peer_mac_addr_frm_id(ol_txrx_soc_handle soc, uint16_t peer_id,
  656. uint8_t *mac_addr)
  657. {
  658. if (!soc || !soc->ops) {
  659. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  660. "%s: Invalid Instance:", __func__);
  661. QDF_BUG(0);
  662. return CDP_INVALID_VDEV_ID;
  663. }
  664. if (!soc->ops->cmn_drv_ops ||
  665. !soc->ops->cmn_drv_ops->get_peer_mac_addr_frm_id)
  666. return CDP_INVALID_VDEV_ID;
  667. return soc->ops->cmn_drv_ops->get_peer_mac_addr_frm_id(soc,
  668. peer_id, mac_addr);
  669. }
  670. /**
  671. * cdp_set_vdev_dscp_tid_map(): function to set DSCP-tid map in the vap
  672. * @vdev: vdev handle
  673. * @map_id: id of the tid map
  674. *
  675. * Return: void
  676. */
  677. static inline void cdp_set_vdev_dscp_tid_map(ol_txrx_soc_handle soc,
  678. struct cdp_vdev *vdev, uint8_t map_id)
  679. {
  680. if (!soc || !soc->ops) {
  681. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  682. "%s: Invalid Instance:", __func__);
  683. QDF_BUG(0);
  684. return;
  685. }
  686. if (!soc->ops->cmn_drv_ops ||
  687. !soc->ops->cmn_drv_ops->set_vdev_dscp_tid_map)
  688. return;
  689. soc->ops->cmn_drv_ops->set_vdev_dscp_tid_map(vdev,
  690. map_id);
  691. }
  692. /**
  693. * cdp_set_pdev_dscp_tid_map(): function to change tid values in DSCP-tid map
  694. * @pdev: pdev handle
  695. * @map_id: id of the tid map
  696. * @tos: index value in map that needs to be changed
  697. * @tid: tid value passed by user
  698. *
  699. * Return: void
  700. */
  701. static inline void cdp_set_pdev_dscp_tid_map(ol_txrx_soc_handle soc,
  702. struct cdp_pdev *pdev, uint8_t map_id, uint8_t tos, uint8_t tid)
  703. {
  704. if (!soc || !soc->ops) {
  705. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  706. "%s: Invalid Instance:", __func__);
  707. QDF_BUG(0);
  708. return;
  709. }
  710. if (!soc->ops->cmn_drv_ops ||
  711. !soc->ops->cmn_drv_ops->set_pdev_dscp_tid_map)
  712. return;
  713. soc->ops->cmn_drv_ops->set_pdev_dscp_tid_map(pdev,
  714. map_id, tos, tid);
  715. }
  716. /**
  717. * cdp_flush_cache_rx_queue() - flush cache rx queue frame
  718. *
  719. * Return: None
  720. */
  721. static inline void cdp_flush_cache_rx_queue(ol_txrx_soc_handle soc)
  722. {
  723. if (!soc || !soc->ops) {
  724. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  725. "%s: Invalid Instance:", __func__);
  726. QDF_BUG(0);
  727. return;
  728. }
  729. if (!soc->ops->cmn_drv_ops ||
  730. !soc->ops->cmn_drv_ops->flush_cache_rx_queue)
  731. return;
  732. soc->ops->cmn_drv_ops->flush_cache_rx_queue();
  733. }
  734. /**
  735. * cdp_txrx_stats(): function to map to host and firmware statistics
  736. * Deprecated, use cdp_txrx_stats_request() instead.
  737. * @soc: soc handle
  738. * @vdev: virtual device
  739. * @stats: statistics option
  740. *
  741. * return: status
  742. */
  743. static inline
  744. int cdp_txrx_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  745. enum cdp_stats stats)
  746. {
  747. if (!soc || !soc->ops) {
  748. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  749. "%s: Invalid Instance:", __func__);
  750. QDF_BUG(0);
  751. return 0;
  752. }
  753. if (!soc->ops->cmn_drv_ops ||
  754. !soc->ops->cmn_drv_ops->txrx_stats)
  755. return 0;
  756. return soc->ops->cmn_drv_ops->txrx_stats(vdev, stats);
  757. }
  758. /**
  759. * cdp_txrx_stats_request(): function to map to host and firmware statistics
  760. * @soc: soc handle
  761. * @vdev: virtual device
  762. * @req: stats request container
  763. *
  764. * return: status
  765. */
  766. static inline
  767. int cdp_txrx_stats_request(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  768. struct cdp_txrx_stats_req *req)
  769. {
  770. if (!soc || !soc->ops || !soc->ops->cmn_drv_ops || !req) {
  771. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  772. "%s: Invalid Instance:", __func__);
  773. QDF_ASSERT(0);
  774. return 0;
  775. }
  776. if (soc->ops->cmn_drv_ops->txrx_stats_request)
  777. return soc->ops->cmn_drv_ops->txrx_stats_request(vdev, req);
  778. return 0;
  779. }
  780. /**
  781. * cdp_txrx_intr_attach(): function to attach and configure interrupt
  782. * @soc: soc handle
  783. */
  784. static inline QDF_STATUS cdp_txrx_intr_attach(ol_txrx_soc_handle soc)
  785. {
  786. if (!soc || !soc->ops) {
  787. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  788. "%s: Invalid Instance:", __func__);
  789. QDF_BUG(0);
  790. return 0;
  791. }
  792. if (!soc->ops->cmn_drv_ops ||
  793. !soc->ops->cmn_drv_ops->txrx_intr_attach)
  794. return 0;
  795. return soc->ops->cmn_drv_ops->txrx_intr_attach(soc);
  796. }
  797. /**
  798. * cdp_txrx_intr_detach(): function to detach interrupt
  799. * @soc: soc handle
  800. */
  801. static inline void cdp_txrx_intr_detach(ol_txrx_soc_handle soc)
  802. {
  803. if (!soc || !soc->ops) {
  804. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  805. "%s: Invalid Instance:", __func__);
  806. QDF_BUG(0);
  807. return;
  808. }
  809. if (!soc->ops->cmn_drv_ops ||
  810. !soc->ops->cmn_drv_ops->txrx_intr_detach)
  811. return;
  812. soc->ops->cmn_drv_ops->txrx_intr_detach(soc);
  813. }
  814. /**
  815. * cdp_display_stats(): function to map to dump stats
  816. * @soc: soc handle
  817. * @value: statistics option
  818. */
  819. static inline QDF_STATUS
  820. cdp_display_stats(ol_txrx_soc_handle soc, uint16_t value,
  821. enum qdf_stats_verbosity_level level)
  822. {
  823. if (!soc || !soc->ops) {
  824. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  825. "%s: Invalid Instance:", __func__);
  826. QDF_BUG(0);
  827. return 0;
  828. }
  829. if (!soc->ops->cmn_drv_ops ||
  830. !soc->ops->cmn_drv_ops->display_stats)
  831. return 0;
  832. return soc->ops->cmn_drv_ops->display_stats(soc, value, level);
  833. }
  834. /**
  835. * cdp_set_pn_check(): function to set pn check
  836. * @soc: soc handle
  837. * @sec_type: security type
  838. * #rx_pn: receive pn
  839. */
  840. static inline int cdp_set_pn_check(ol_txrx_soc_handle soc,
  841. struct cdp_vdev *vdev, struct cdp_peer *peer_handle, enum cdp_sec_type sec_type, uint32_t *rx_pn)
  842. {
  843. if (!soc || !soc->ops) {
  844. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  845. "%s: Invalid Instance:", __func__);
  846. QDF_BUG(0);
  847. return 0;
  848. }
  849. if (!soc->ops->cmn_drv_ops ||
  850. !soc->ops->cmn_drv_ops->set_pn_check)
  851. return 0;
  852. soc->ops->cmn_drv_ops->set_pn_check(vdev, peer_handle,
  853. sec_type, rx_pn);
  854. return 0;
  855. }
  856. /**
  857. * cdp_update_config_parameters(): function to propagate configuration
  858. * parameters to datapath
  859. * @soc: opaque soc handle
  860. * @cfg: configuration handle
  861. *
  862. * Return: status: 0 - Success, non-zero: Failure
  863. */
  864. static inline
  865. QDF_STATUS cdp_update_config_parameters(ol_txrx_soc_handle soc,
  866. struct cdp_config_params *cfg)
  867. {
  868. struct cdp_soc *psoc = (struct cdp_soc *)soc;
  869. if (!soc || !soc->ops) {
  870. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  871. "%s: Invalid Instance:", __func__);
  872. QDF_BUG(0);
  873. return 0;
  874. }
  875. if (!soc->ops->cmn_drv_ops ||
  876. !soc->ops->cmn_drv_ops->update_config_parameters)
  877. return QDF_STATUS_SUCCESS;
  878. return soc->ops->cmn_drv_ops->update_config_parameters(psoc,
  879. cfg);
  880. }
  881. #endif /* _CDP_TXRX_CMN_H_ */