cdp_txrx_cmn.h 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046
  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. static inline int
  297. cdp_set_monitor_filter(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  298. struct cdp_monitor_filter *filter_val)
  299. {
  300. if (soc->ops->mon_ops->txrx_set_advance_monitor_filter)
  301. return soc->ops->mon_ops->txrx_set_advance_monitor_filter(pdev,
  302. filter_val);
  303. return 0;
  304. }
  305. /******************************************************************************
  306. * Data Interface (B Interface)
  307. *****************************************************************************/
  308. static inline void
  309. cdp_vdev_register(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  310. void *osif_vdev, struct ol_txrx_ops *txrx_ops)
  311. {
  312. if (!soc || !soc->ops) {
  313. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  314. "%s: Invalid Instance:", __func__);
  315. QDF_BUG(0);
  316. return;
  317. }
  318. if (!soc->ops->cmn_drv_ops ||
  319. !soc->ops->cmn_drv_ops->txrx_vdev_register)
  320. return;
  321. soc->ops->cmn_drv_ops->txrx_vdev_register(vdev,
  322. osif_vdev, txrx_ops);
  323. }
  324. static inline int
  325. cdp_mgmt_send(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  326. qdf_nbuf_t tx_mgmt_frm, uint8_t type)
  327. {
  328. if (!soc || !soc->ops) {
  329. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  330. "%s: Invalid Instance:", __func__);
  331. QDF_BUG(0);
  332. return 0;
  333. }
  334. if (!soc->ops->cmn_drv_ops ||
  335. !soc->ops->cmn_drv_ops->txrx_mgmt_send)
  336. return 0;
  337. return soc->ops->cmn_drv_ops->txrx_mgmt_send(vdev,
  338. tx_mgmt_frm, type);
  339. }
  340. static inline int
  341. cdp_mgmt_send_ext(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  342. qdf_nbuf_t tx_mgmt_frm, uint8_t type,
  343. uint8_t use_6mbps, uint16_t chanfreq)
  344. {
  345. if (!soc || !soc->ops) {
  346. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  347. "%s: Invalid Instance:", __func__);
  348. QDF_BUG(0);
  349. return 0;
  350. }
  351. if (!soc->ops->cmn_drv_ops ||
  352. !soc->ops->cmn_drv_ops->txrx_mgmt_send_ext)
  353. return 0;
  354. return soc->ops->cmn_drv_ops->txrx_mgmt_send_ext
  355. (vdev, tx_mgmt_frm, type, use_6mbps, chanfreq);
  356. }
  357. static inline void
  358. cdp_mgmt_tx_cb_set(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  359. uint8_t type, ol_txrx_mgmt_tx_cb download_cb,
  360. ol_txrx_mgmt_tx_cb ota_ack_cb, void *ctxt)
  361. {
  362. if (!soc || !soc->ops) {
  363. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  364. "%s: Invalid Instance:", __func__);
  365. QDF_BUG(0);
  366. return;
  367. }
  368. if (!soc->ops->cmn_drv_ops ||
  369. !soc->ops->cmn_drv_ops->txrx_mgmt_tx_cb_set)
  370. return;
  371. soc->ops->cmn_drv_ops->txrx_mgmt_tx_cb_set
  372. (pdev, type, download_cb, ota_ack_cb, ctxt);
  373. }
  374. static inline int cdp_get_tx_pending(ol_txrx_soc_handle soc,
  375. struct cdp_pdev *pdev)
  376. {
  377. if (!soc || !soc->ops) {
  378. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  379. "%s: Invalid Instance:", __func__);
  380. QDF_BUG(0);
  381. return 0;
  382. }
  383. if (!soc->ops->cmn_drv_ops ||
  384. !soc->ops->cmn_drv_ops->txrx_get_tx_pending)
  385. return 0;
  386. return soc->ops->cmn_drv_ops->txrx_get_tx_pending(pdev);
  387. }
  388. static inline void
  389. cdp_data_tx_cb_set(ol_txrx_soc_handle soc, struct cdp_vdev *data_vdev,
  390. ol_txrx_data_tx_cb callback, void *ctxt)
  391. {
  392. if (!soc || !soc->ops) {
  393. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  394. "%s: Invalid Instance:", __func__);
  395. QDF_BUG(0);
  396. return;
  397. }
  398. if (!soc->ops->cmn_drv_ops ||
  399. !soc->ops->cmn_drv_ops->txrx_data_tx_cb_set)
  400. return;
  401. soc->ops->cmn_drv_ops->txrx_data_tx_cb_set(data_vdev,
  402. callback, ctxt);
  403. }
  404. /******************************************************************************
  405. * Statistics and Debugging Interface (C Inteface)
  406. *****************************************************************************/
  407. /**
  408. * External Device physical address types
  409. *
  410. * Currently, both MAC and IPA uController use the same size addresses
  411. * and descriptors are exchanged between these two depending on the mode.
  412. *
  413. * Rationale: qdf_dma_addr_t is the type used internally on the host for DMA
  414. * operations. However, external device physical address sizes
  415. * may be different from host-specific physical address sizes.
  416. * This calls for the following definitions for target devices
  417. * (MAC, IPA uc).
  418. */
  419. #if HTT_PADDR64
  420. typedef uint64_t target_paddr_t;
  421. #else
  422. typedef uint32_t target_paddr_t;
  423. #endif /*HTT_PADDR64 */
  424. static inline int
  425. cdp_aggr_cfg(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  426. int max_subfrms_ampdu,
  427. int max_subfrms_amsdu)
  428. {
  429. if (!soc || !soc->ops) {
  430. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  431. "%s: Invalid Instance:", __func__);
  432. QDF_BUG(0);
  433. return 0;
  434. }
  435. if (!soc->ops->cmn_drv_ops ||
  436. !soc->ops->cmn_drv_ops->txrx_aggr_cfg)
  437. return 0;
  438. return soc->ops->cmn_drv_ops->txrx_aggr_cfg(vdev,
  439. max_subfrms_ampdu, max_subfrms_amsdu);
  440. }
  441. static inline int
  442. cdp_fw_stats_get(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  443. struct ol_txrx_stats_req *req, bool per_vdev,
  444. bool response_expected)
  445. {
  446. if (!soc || !soc->ops) {
  447. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  448. "%s: Invalid Instance:", __func__);
  449. QDF_BUG(0);
  450. return 0;
  451. }
  452. if (!soc->ops->cmn_drv_ops ||
  453. !soc->ops->cmn_drv_ops->txrx_fw_stats_get)
  454. return 0;
  455. return soc->ops->cmn_drv_ops->txrx_fw_stats_get(vdev, req,
  456. per_vdev, response_expected);
  457. }
  458. static inline int
  459. cdp_debug(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, int debug_specs)
  460. {
  461. if (!soc || !soc->ops) {
  462. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  463. "%s: Invalid Instance:", __func__);
  464. QDF_BUG(0);
  465. return 0;
  466. }
  467. if (!soc->ops->cmn_drv_ops ||
  468. !soc->ops->cmn_drv_ops->txrx_debug)
  469. return 0;
  470. return soc->ops->cmn_drv_ops->txrx_debug(vdev, debug_specs);
  471. }
  472. static inline void cdp_fw_stats_cfg(ol_txrx_soc_handle soc,
  473. struct cdp_vdev *vdev, uint8_t cfg_stats_type, uint32_t cfg_val)
  474. {
  475. if (!soc || !soc->ops) {
  476. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  477. "%s: Invalid Instance:", __func__);
  478. QDF_BUG(0);
  479. return;
  480. }
  481. if (!soc->ops->cmn_drv_ops ||
  482. !soc->ops->cmn_drv_ops->txrx_fw_stats_cfg)
  483. return;
  484. soc->ops->cmn_drv_ops->txrx_fw_stats_cfg(vdev,
  485. cfg_stats_type, cfg_val);
  486. }
  487. static inline void cdp_print_level_set(ol_txrx_soc_handle soc, unsigned level)
  488. {
  489. if (!soc || !soc->ops) {
  490. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  491. "%s: Invalid Instance:", __func__);
  492. QDF_BUG(0);
  493. return;
  494. }
  495. if (!soc->ops->cmn_drv_ops ||
  496. !soc->ops->cmn_drv_ops->txrx_print_level_set)
  497. return;
  498. soc->ops->cmn_drv_ops->txrx_print_level_set(level);
  499. }
  500. static inline uint8_t *
  501. cdp_get_vdev_mac_addr(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  502. {
  503. if (!soc || !soc->ops) {
  504. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  505. "%s: Invalid Instance:", __func__);
  506. QDF_BUG(0);
  507. return NULL;
  508. }
  509. if (!soc->ops->cmn_drv_ops ||
  510. !soc->ops->cmn_drv_ops->txrx_get_vdev_mac_addr)
  511. return NULL;
  512. return soc->ops->cmn_drv_ops->txrx_get_vdev_mac_addr(vdev);
  513. }
  514. /**
  515. * cdp_get_vdev_struct_mac_addr() - Return handle to struct qdf_mac_addr of
  516. * vdev
  517. * @vdev: vdev handle
  518. *
  519. * Return: Handle to struct qdf_mac_addr
  520. */
  521. static inline struct qdf_mac_addr *cdp_get_vdev_struct_mac_addr
  522. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  523. {
  524. if (!soc || !soc->ops) {
  525. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  526. "%s: Invalid Instance:", __func__);
  527. QDF_BUG(0);
  528. return NULL;
  529. }
  530. if (!soc->ops->cmn_drv_ops ||
  531. !soc->ops->cmn_drv_ops->txrx_get_vdev_struct_mac_addr)
  532. return NULL;
  533. return soc->ops->cmn_drv_ops->txrx_get_vdev_struct_mac_addr
  534. (vdev);
  535. }
  536. /**
  537. * cdp_get_pdev_from_vdev() - Return handle to pdev of vdev
  538. * @vdev: vdev handle
  539. *
  540. * Return: Handle to pdev
  541. */
  542. static inline struct cdp_pdev *cdp_get_pdev_from_vdev
  543. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  544. {
  545. if (!soc || !soc->ops) {
  546. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  547. "%s: Invalid Instance:", __func__);
  548. QDF_BUG(0);
  549. return NULL;
  550. }
  551. if (!soc->ops->cmn_drv_ops ||
  552. !soc->ops->cmn_drv_ops->txrx_get_pdev_from_vdev)
  553. return NULL;
  554. return soc->ops->cmn_drv_ops->txrx_get_pdev_from_vdev(vdev);
  555. }
  556. /**
  557. * cdp_get_ctrl_pdev_from_vdev() - Return control pdev of vdev
  558. * @vdev: vdev handle
  559. *
  560. * Return: Handle to control pdev
  561. */
  562. static inline struct cdp_cfg *
  563. cdp_get_ctrl_pdev_from_vdev(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  564. {
  565. if (!soc || !soc->ops) {
  566. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  567. "%s: Invalid Instance:", __func__);
  568. QDF_BUG(0);
  569. return NULL;
  570. }
  571. if (!soc->ops->cmn_drv_ops ||
  572. !soc->ops->cmn_drv_ops->txrx_get_ctrl_pdev_from_vdev)
  573. return NULL;
  574. return soc->ops->cmn_drv_ops->txrx_get_ctrl_pdev_from_vdev
  575. (vdev);
  576. }
  577. static inline struct cdp_vdev *
  578. cdp_get_vdev_from_vdev_id(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  579. uint8_t vdev_id)
  580. {
  581. if (!soc || !soc->ops) {
  582. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  583. "%s: Invalid Instance:", __func__);
  584. QDF_BUG(0);
  585. return NULL;
  586. }
  587. if (!soc->ops->cmn_drv_ops ||
  588. !soc->ops->cmn_drv_ops->txrx_get_vdev_from_vdev_id)
  589. return NULL;
  590. return soc->ops->cmn_drv_ops->txrx_get_vdev_from_vdev_id
  591. (pdev, vdev_id);
  592. }
  593. static inline void
  594. cdp_soc_detach(ol_txrx_soc_handle soc)
  595. {
  596. if (!soc || !soc->ops) {
  597. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  598. "%s: Invalid Instance:", __func__);
  599. QDF_BUG(0);
  600. return;
  601. }
  602. if (!soc->ops->cmn_drv_ops ||
  603. !soc->ops->cmn_drv_ops->txrx_soc_detach)
  604. return;
  605. soc->ops->cmn_drv_ops->txrx_soc_detach((void *)soc);
  606. }
  607. static inline int cdp_addba_requestprocess(ol_txrx_soc_handle soc,
  608. void *peer_handle, uint8_t dialogtoken, uint16_t tid,
  609. uint16_t batimeout, uint16_t buffersize, uint16_t startseqnum)
  610. {
  611. if (!soc || !soc->ops) {
  612. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  613. "%s: Invalid Instance:", __func__);
  614. QDF_BUG(0);
  615. return 0;
  616. }
  617. if (!soc->ops->cmn_drv_ops ||
  618. !soc->ops->cmn_drv_ops->addba_requestprocess)
  619. return 0;
  620. return soc->ops->cmn_drv_ops->addba_requestprocess(peer_handle,
  621. dialogtoken, tid, batimeout, buffersize, startseqnum);
  622. }
  623. static inline void cdp_addba_responsesetup(ol_txrx_soc_handle soc,
  624. void *peer_handle, uint8_t tid, uint8_t *dialogtoken,
  625. uint16_t *statuscode, uint16_t *buffersize, uint16_t *batimeout)
  626. {
  627. if (!soc || !soc->ops) {
  628. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  629. "%s: Invalid Instance:", __func__);
  630. QDF_BUG(0);
  631. return;
  632. }
  633. if (!soc->ops->cmn_drv_ops ||
  634. !soc->ops->cmn_drv_ops->addba_responsesetup)
  635. return;
  636. soc->ops->cmn_drv_ops->addba_responsesetup(peer_handle, tid,
  637. dialogtoken, statuscode, buffersize, batimeout);
  638. }
  639. static inline int cdp_delba_process(ol_txrx_soc_handle soc,
  640. void *peer_handle, int tid, uint16_t reasoncode)
  641. {
  642. if (!soc || !soc->ops) {
  643. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  644. "%s: Invalid Instance:", __func__);
  645. QDF_BUG(0);
  646. return 0;
  647. }
  648. if (!soc->ops->cmn_drv_ops ||
  649. !soc->ops->cmn_drv_ops->delba_process)
  650. return 0;
  651. return soc->ops->cmn_drv_ops->delba_process(peer_handle,
  652. tid, reasoncode);
  653. }
  654. /**
  655. * cdp_get_peer_mac_addr_frm_id: function to return vdev id and and peer
  656. * mac address
  657. * @soc: SOC handle
  658. * @peer_id: peer id of the peer for which mac_address is required
  659. * @mac_addr: reference to mac address
  660. *
  661. * reutm: vdev_id of the vap
  662. */
  663. static inline uint8_t
  664. cdp_get_peer_mac_addr_frm_id(ol_txrx_soc_handle soc, uint16_t peer_id,
  665. uint8_t *mac_addr)
  666. {
  667. if (!soc || !soc->ops) {
  668. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  669. "%s: Invalid Instance:", __func__);
  670. QDF_BUG(0);
  671. return CDP_INVALID_VDEV_ID;
  672. }
  673. if (!soc->ops->cmn_drv_ops ||
  674. !soc->ops->cmn_drv_ops->get_peer_mac_addr_frm_id)
  675. return CDP_INVALID_VDEV_ID;
  676. return soc->ops->cmn_drv_ops->get_peer_mac_addr_frm_id(soc,
  677. peer_id, mac_addr);
  678. }
  679. /**
  680. * cdp_set_vdev_dscp_tid_map(): function to set DSCP-tid map in the vap
  681. * @vdev: vdev handle
  682. * @map_id: id of the tid map
  683. *
  684. * Return: void
  685. */
  686. static inline void cdp_set_vdev_dscp_tid_map(ol_txrx_soc_handle soc,
  687. struct cdp_vdev *vdev, uint8_t map_id)
  688. {
  689. if (!soc || !soc->ops) {
  690. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  691. "%s: Invalid Instance:", __func__);
  692. QDF_BUG(0);
  693. return;
  694. }
  695. if (!soc->ops->cmn_drv_ops ||
  696. !soc->ops->cmn_drv_ops->set_vdev_dscp_tid_map)
  697. return;
  698. soc->ops->cmn_drv_ops->set_vdev_dscp_tid_map(vdev,
  699. map_id);
  700. }
  701. /**
  702. * cdp_set_pdev_dscp_tid_map(): function to change tid values in DSCP-tid map
  703. * @pdev: pdev handle
  704. * @map_id: id of the tid map
  705. * @tos: index value in map that needs to be changed
  706. * @tid: tid value passed by user
  707. *
  708. * Return: void
  709. */
  710. static inline void cdp_set_pdev_dscp_tid_map(ol_txrx_soc_handle soc,
  711. struct cdp_pdev *pdev, uint8_t map_id, uint8_t tos, uint8_t tid)
  712. {
  713. if (!soc || !soc->ops) {
  714. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  715. "%s: Invalid Instance:", __func__);
  716. QDF_BUG(0);
  717. return;
  718. }
  719. if (!soc->ops->cmn_drv_ops ||
  720. !soc->ops->cmn_drv_ops->set_pdev_dscp_tid_map)
  721. return;
  722. soc->ops->cmn_drv_ops->set_pdev_dscp_tid_map(pdev,
  723. map_id, tos, tid);
  724. }
  725. /**
  726. * cdp_flush_cache_rx_queue() - flush cache rx queue frame
  727. *
  728. * Return: None
  729. */
  730. static inline void cdp_flush_cache_rx_queue(ol_txrx_soc_handle soc)
  731. {
  732. if (!soc || !soc->ops) {
  733. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  734. "%s: Invalid Instance:", __func__);
  735. QDF_BUG(0);
  736. return;
  737. }
  738. if (!soc->ops->cmn_drv_ops ||
  739. !soc->ops->cmn_drv_ops->flush_cache_rx_queue)
  740. return;
  741. soc->ops->cmn_drv_ops->flush_cache_rx_queue();
  742. }
  743. /**
  744. * cdp_txrx_stats(): function to map to host and firmware statistics
  745. * Deprecated, use cdp_txrx_stats_request() instead.
  746. * @soc: soc handle
  747. * @vdev: virtual device
  748. * @stats: statistics option
  749. *
  750. * return: status
  751. */
  752. static inline
  753. int cdp_txrx_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  754. enum cdp_stats stats)
  755. {
  756. if (!soc || !soc->ops) {
  757. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  758. "%s: Invalid Instance:", __func__);
  759. QDF_BUG(0);
  760. return 0;
  761. }
  762. if (!soc->ops->cmn_drv_ops ||
  763. !soc->ops->cmn_drv_ops->txrx_stats)
  764. return 0;
  765. return soc->ops->cmn_drv_ops->txrx_stats(vdev, stats);
  766. }
  767. /**
  768. * cdp_txrx_stats_request(): function to map to host and firmware statistics
  769. * @soc: soc handle
  770. * @vdev: virtual device
  771. * @req: stats request container
  772. *
  773. * return: status
  774. */
  775. static inline
  776. int cdp_txrx_stats_request(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  777. struct cdp_txrx_stats_req *req)
  778. {
  779. if (!soc || !soc->ops || !soc->ops->cmn_drv_ops || !req) {
  780. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  781. "%s: Invalid Instance:", __func__);
  782. QDF_ASSERT(0);
  783. return 0;
  784. }
  785. if (soc->ops->cmn_drv_ops->txrx_stats_request)
  786. return soc->ops->cmn_drv_ops->txrx_stats_request(vdev, req);
  787. return 0;
  788. }
  789. /**
  790. * cdp_txrx_intr_attach(): function to attach and configure interrupt
  791. * @soc: soc handle
  792. */
  793. static inline QDF_STATUS cdp_txrx_intr_attach(ol_txrx_soc_handle soc)
  794. {
  795. if (!soc || !soc->ops) {
  796. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  797. "%s: Invalid Instance:", __func__);
  798. QDF_BUG(0);
  799. return 0;
  800. }
  801. if (!soc->ops->cmn_drv_ops ||
  802. !soc->ops->cmn_drv_ops->txrx_intr_attach)
  803. return 0;
  804. return soc->ops->cmn_drv_ops->txrx_intr_attach(soc);
  805. }
  806. /**
  807. * cdp_txrx_intr_detach(): function to detach interrupt
  808. * @soc: soc handle
  809. */
  810. static inline void cdp_txrx_intr_detach(ol_txrx_soc_handle soc)
  811. {
  812. if (!soc || !soc->ops) {
  813. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  814. "%s: Invalid Instance:", __func__);
  815. QDF_BUG(0);
  816. return;
  817. }
  818. if (!soc->ops->cmn_drv_ops ||
  819. !soc->ops->cmn_drv_ops->txrx_intr_detach)
  820. return;
  821. soc->ops->cmn_drv_ops->txrx_intr_detach(soc);
  822. }
  823. /**
  824. * cdp_display_stats(): function to map to dump stats
  825. * @soc: soc handle
  826. * @value: statistics option
  827. */
  828. static inline QDF_STATUS
  829. cdp_display_stats(ol_txrx_soc_handle soc, uint16_t value,
  830. enum qdf_stats_verbosity_level level)
  831. {
  832. if (!soc || !soc->ops) {
  833. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  834. "%s: Invalid Instance:", __func__);
  835. QDF_BUG(0);
  836. return 0;
  837. }
  838. if (!soc->ops->cmn_drv_ops ||
  839. !soc->ops->cmn_drv_ops->display_stats)
  840. return 0;
  841. return soc->ops->cmn_drv_ops->display_stats(soc, value, level);
  842. }
  843. /**
  844. * cdp_set_pn_check(): function to set pn check
  845. * @soc: soc handle
  846. * @sec_type: security type
  847. * #rx_pn: receive pn
  848. */
  849. static inline int cdp_set_pn_check(ol_txrx_soc_handle soc,
  850. struct cdp_vdev *vdev, struct cdp_peer *peer_handle, enum cdp_sec_type sec_type, uint32_t *rx_pn)
  851. {
  852. if (!soc || !soc->ops) {
  853. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  854. "%s: Invalid Instance:", __func__);
  855. QDF_BUG(0);
  856. return 0;
  857. }
  858. if (!soc->ops->cmn_drv_ops ||
  859. !soc->ops->cmn_drv_ops->set_pn_check)
  860. return 0;
  861. soc->ops->cmn_drv_ops->set_pn_check(vdev, peer_handle,
  862. sec_type, rx_pn);
  863. return 0;
  864. }
  865. /**
  866. * cdp_update_config_parameters(): function to propagate configuration
  867. * parameters to datapath
  868. * @soc: opaque soc handle
  869. * @cfg: configuration handle
  870. *
  871. * Return: status: 0 - Success, non-zero: Failure
  872. */
  873. static inline
  874. QDF_STATUS cdp_update_config_parameters(ol_txrx_soc_handle soc,
  875. struct cdp_config_params *cfg)
  876. {
  877. struct cdp_soc *psoc = (struct cdp_soc *)soc;
  878. if (!soc || !soc->ops) {
  879. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  880. "%s: Invalid Instance:", __func__);
  881. QDF_BUG(0);
  882. return 0;
  883. }
  884. if (!soc->ops->cmn_drv_ops ||
  885. !soc->ops->cmn_drv_ops->update_config_parameters)
  886. return QDF_STATUS_SUCCESS;
  887. return soc->ops->cmn_drv_ops->update_config_parameters(psoc,
  888. cfg);
  889. }
  890. #endif /* _CDP_TXRX_CMN_H_ */