cdp_txrx_cmn.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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->ops->cmn_drv_ops->txrx_soc_attach_target)
  47. return soc->ops->cmn_drv_ops->txrx_soc_attach_target(soc);
  48. return 0;
  49. }
  50. static inline struct cdp_vdev *
  51. cdp_vdev_attach(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  52. uint8_t *vdev_mac_addr, uint8_t vdev_id, enum wlan_op_mode op_mode)
  53. {
  54. if (soc->ops->cmn_drv_ops->txrx_vdev_attach)
  55. return soc->ops->cmn_drv_ops->txrx_vdev_attach(pdev,
  56. vdev_mac_addr, vdev_id, op_mode);
  57. return NULL;
  58. }
  59. static inline void
  60. cdp_vdev_detach(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  61. ol_txrx_vdev_delete_cb callback, void *cb_context)
  62. {
  63. if (soc->ops->cmn_drv_ops->txrx_vdev_detach)
  64. return soc->ops->cmn_drv_ops->txrx_vdev_detach(vdev,
  65. callback, cb_context);
  66. return;
  67. }
  68. static inline int
  69. cdp_pdev_attach_target(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  70. {
  71. if (soc->ops->cmn_drv_ops->txrx_pdev_attach_target)
  72. return soc->ops->cmn_drv_ops->txrx_pdev_attach_target(pdev);
  73. return 0;
  74. }
  75. static inline struct cdp_pdev *cdp_pdev_attach
  76. (ol_txrx_soc_handle soc, struct cdp_cfg *ctrl_pdev,
  77. HTC_HANDLE htc_pdev, qdf_device_t osdev, uint8_t pdev_id)
  78. {
  79. if (soc->ops->cmn_drv_ops->txrx_pdev_attach)
  80. return soc->ops->cmn_drv_ops->txrx_pdev_attach(soc, ctrl_pdev,
  81. htc_pdev, osdev, pdev_id);
  82. return NULL;
  83. }
  84. static inline int cdp_pdev_post_attach(ol_txrx_soc_handle soc,
  85. struct cdp_pdev *pdev)
  86. {
  87. if (soc->ops->cmn_drv_ops->txrx_pdev_post_attach)
  88. return soc->ops->cmn_drv_ops->txrx_pdev_post_attach(pdev);
  89. return 0;
  90. }
  91. static inline void
  92. cdp_pdev_pre_detach(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, int force)
  93. {
  94. if (soc->ops->cmn_drv_ops->txrx_pdev_pre_detach)
  95. return soc->ops->cmn_drv_ops->txrx_pdev_pre_detach(pdev, force);
  96. return;
  97. }
  98. static inline void
  99. cdp_pdev_detach(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, int force)
  100. {
  101. if (soc->ops->cmn_drv_ops->txrx_pdev_detach)
  102. return soc->ops->cmn_drv_ops->txrx_pdev_detach(pdev, force);
  103. return;
  104. }
  105. static inline void *cdp_peer_create
  106. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  107. uint8_t *peer_mac_addr)
  108. {
  109. if (soc->ops->cmn_drv_ops->txrx_peer_create)
  110. return soc->ops->cmn_drv_ops->txrx_peer_create(vdev,
  111. peer_mac_addr);
  112. return NULL;
  113. }
  114. static inline void cdp_peer_setup
  115. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev, void *peer)
  116. {
  117. if (soc->ops->cmn_drv_ops->txrx_peer_setup)
  118. return soc->ops->cmn_drv_ops->txrx_peer_setup(vdev,
  119. peer);
  120. return;
  121. }
  122. static inline void cdp_peer_teardown
  123. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev, void *peer)
  124. {
  125. if (soc->ops->cmn_drv_ops->txrx_peer_teardown)
  126. return soc->ops->cmn_drv_ops->txrx_peer_teardown(vdev,
  127. peer);
  128. return;
  129. }
  130. static inline void
  131. cdp_peer_delete(ol_txrx_soc_handle soc, void *peer)
  132. {
  133. if (soc->ops->cmn_drv_ops->txrx_peer_delete)
  134. return soc->ops->cmn_drv_ops->txrx_peer_delete(peer);
  135. return;
  136. }
  137. static inline int
  138. cdp_set_monitor_mode(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  139. {
  140. if (soc->ops->cmn_drv_ops->txrx_set_monitor_mode)
  141. return soc->ops->cmn_drv_ops->txrx_set_monitor_mode(vdev);
  142. return 0;
  143. }
  144. static inline void
  145. cdp_set_curchan(ol_txrx_soc_handle soc,
  146. struct cdp_pdev *pdev,
  147. uint32_t chan_mhz)
  148. {
  149. if (soc->ops->cmn_drv_ops->txrx_set_curchan)
  150. return soc->ops->cmn_drv_ops->txrx_set_curchan(pdev, chan_mhz);
  151. return;
  152. }
  153. static inline void
  154. cdp_set_privacy_filters(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  155. void *filter, uint32_t num)
  156. {
  157. if (soc->ops->cmn_drv_ops->txrx_set_privacy_filters)
  158. return soc->ops->cmn_drv_ops->txrx_set_privacy_filters(vdev,
  159. filter, num);
  160. return;
  161. }
  162. /******************************************************************************
  163. * Data Interface (B Interface)
  164. *****************************************************************************/
  165. static inline void
  166. cdp_vdev_register(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  167. void *osif_vdev, struct ol_txrx_ops *txrx_ops)
  168. {
  169. if (soc->ops->cmn_drv_ops->txrx_vdev_register)
  170. return soc->ops->cmn_drv_ops->txrx_vdev_register(vdev,
  171. osif_vdev, txrx_ops);
  172. return;
  173. }
  174. static inline int
  175. cdp_mgmt_send(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  176. qdf_nbuf_t tx_mgmt_frm, uint8_t type)
  177. {
  178. if (soc->ops->cmn_drv_ops->txrx_mgmt_send)
  179. return soc->ops->cmn_drv_ops->txrx_mgmt_send(vdev,
  180. tx_mgmt_frm, type);
  181. return 0;
  182. }
  183. static inline int
  184. cdp_mgmt_send_ext(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  185. qdf_nbuf_t tx_mgmt_frm, uint8_t type,
  186. uint8_t use_6mbps, uint16_t chanfreq)
  187. {
  188. if (soc->ops->cmn_drv_ops->txrx_mgmt_send_ext)
  189. return soc->ops->cmn_drv_ops->txrx_mgmt_send_ext
  190. (vdev, tx_mgmt_frm, type, use_6mbps, chanfreq);
  191. return 0;
  192. }
  193. static inline void
  194. cdp_mgmt_tx_cb_set(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  195. uint8_t type,
  196. ol_txrx_mgmt_tx_cb download_cb,
  197. ol_txrx_mgmt_tx_cb ota_ack_cb, void *ctxt)
  198. {
  199. if (soc->ops->cmn_drv_ops->txrx_mgmt_tx_cb_set)
  200. return soc->ops->cmn_drv_ops->txrx_mgmt_tx_cb_set
  201. (pdev, type, download_cb, ota_ack_cb, ctxt);
  202. return;
  203. }
  204. static inline int cdp_get_tx_pending(ol_txrx_soc_handle soc,
  205. struct cdp_pdev *pdev)
  206. {
  207. if (soc->ops->cmn_drv_ops->txrx_get_tx_pending)
  208. return soc->ops->cmn_drv_ops->txrx_get_tx_pending(pdev);
  209. return 0;
  210. }
  211. static inline void
  212. cdp_data_tx_cb_set(ol_txrx_soc_handle soc, struct cdp_vdev *data_vdev,
  213. ol_txrx_data_tx_cb callback, void *ctxt)
  214. {
  215. if (soc->ops->cmn_drv_ops->txrx_data_tx_cb_set)
  216. return soc->ops->cmn_drv_ops->txrx_data_tx_cb_set(data_vdev,
  217. callback, ctxt);
  218. return;
  219. }
  220. /******************************************************************************
  221. * Statistics and Debugging Interface (C Inteface)
  222. *****************************************************************************/
  223. static inline int
  224. cdp_aggr_cfg(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  225. int max_subfrms_ampdu,
  226. int max_subfrms_amsdu)
  227. {
  228. if (soc->ops->cmn_drv_ops->txrx_aggr_cfg)
  229. return soc->ops->cmn_drv_ops->txrx_aggr_cfg(vdev,
  230. max_subfrms_ampdu, max_subfrms_amsdu);
  231. return 0;
  232. }
  233. static inline int
  234. cdp_fw_stats_get(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  235. struct ol_txrx_stats_req *req, bool per_vdev,
  236. bool response_expected)
  237. {
  238. if (soc->ops->cmn_drv_ops->txrx_fw_stats_get)
  239. return soc->ops->cmn_drv_ops->txrx_fw_stats_get(vdev, req,
  240. per_vdev, response_expected);
  241. return 0;
  242. }
  243. static inline int
  244. cdp_debug(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, int debug_specs)
  245. {
  246. if (soc->ops->cmn_drv_ops->txrx_debug)
  247. return soc->ops->cmn_drv_ops->txrx_debug(vdev, debug_specs);
  248. return 0;
  249. }
  250. static inline void cdp_fw_stats_cfg(ol_txrx_soc_handle soc,
  251. struct cdp_vdev *vdev, uint8_t cfg_stats_type, uint32_t cfg_val)
  252. {
  253. if (soc->ops->cmn_drv_ops->txrx_fw_stats_cfg)
  254. return soc->ops->cmn_drv_ops->txrx_fw_stats_cfg(vdev,
  255. cfg_stats_type, cfg_val);
  256. return;
  257. }
  258. static inline void cdp_print_level_set(ol_txrx_soc_handle soc, unsigned level)
  259. {
  260. if (soc->ops->cmn_drv_ops->txrx_print_level_set)
  261. return soc->ops->cmn_drv_ops->txrx_print_level_set(level);
  262. return;
  263. }
  264. static inline uint8_t *
  265. cdp_get_vdev_mac_addr(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  266. {
  267. if (soc->ops->cmn_drv_ops->txrx_get_vdev_mac_addr)
  268. return soc->ops->cmn_drv_ops->txrx_get_vdev_mac_addr(vdev);
  269. return NULL;
  270. }
  271. /**
  272. * cdp_get_vdev_struct_mac_addr() - Return handle to struct qdf_mac_addr of
  273. * vdev
  274. * @vdev: vdev handle
  275. *
  276. * Return: Handle to struct qdf_mac_addr
  277. */
  278. static inline struct qdf_mac_addr *cdp_get_vdev_struct_mac_addr
  279. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  280. {
  281. if (soc->ops->cmn_drv_ops->txrx_get_vdev_struct_mac_addr)
  282. return soc->ops->cmn_drv_ops->txrx_get_vdev_struct_mac_addr
  283. (vdev);
  284. return NULL;
  285. }
  286. /**
  287. * cdp_get_pdev_from_vdev() - Return handle to pdev of vdev
  288. * @vdev: vdev handle
  289. *
  290. * Return: Handle to pdev
  291. */
  292. static inline struct cdp_pdev *cdp_get_pdev_from_vdev
  293. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  294. {
  295. if (soc->ops->cmn_drv_ops->txrx_get_pdev_from_vdev)
  296. return soc->ops->cmn_drv_ops->txrx_get_pdev_from_vdev(vdev);
  297. return NULL;
  298. }
  299. /**
  300. * cdp_get_ctrl_pdev_from_vdev() - Return control pdev of vdev
  301. * @vdev: vdev handle
  302. *
  303. * Return: Handle to control pdev
  304. */
  305. static inline struct cdp_cfg *
  306. cdp_get_ctrl_pdev_from_vdev(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  307. {
  308. if (soc->ops->cmn_drv_ops->txrx_get_ctrl_pdev_from_vdev)
  309. return soc->ops->cmn_drv_ops->txrx_get_ctrl_pdev_from_vdev
  310. (vdev);
  311. return NULL;
  312. }
  313. static inline struct cdp_vdev *
  314. cdp_get_vdev_from_vdev_id(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  315. uint8_t vdev_id)
  316. {
  317. if (soc->ops->cmn_drv_ops->txrx_get_vdev_from_vdev_id)
  318. return soc->ops->cmn_drv_ops->txrx_get_vdev_from_vdev_id
  319. (pdev, vdev_id);
  320. return NULL;
  321. }
  322. static inline void
  323. cdp_soc_detach(ol_txrx_soc_handle soc)
  324. {
  325. if (soc->ops->cmn_drv_ops->txrx_soc_detach)
  326. return soc->ops->cmn_drv_ops->txrx_soc_detach((void *)soc);
  327. return;
  328. }
  329. static inline int cdp_addba_requestprocess(ol_txrx_soc_handle soc,
  330. void *peer_handle, uint8_t dialogtoken, uint16_t tid,
  331. uint16_t batimeout, uint16_t buffersize, uint16_t startseqnum)
  332. {
  333. if (soc->ops->cmn_drv_ops->addba_requestprocess)
  334. return soc->ops->cmn_drv_ops->addba_requestprocess(peer_handle,
  335. dialogtoken, tid, batimeout, buffersize, startseqnum);
  336. return 0;
  337. }
  338. static inline void cdp_addba_responsesetup(ol_txrx_soc_handle soc,
  339. void *peer_handle, uint8_t tid, uint8_t *dialogtoken,
  340. uint16_t *statuscode, uint16_t *buffersize, uint16_t *batimeout)
  341. {
  342. if (soc->ops->cmn_drv_ops->addba_responsesetup)
  343. soc->ops->cmn_drv_ops->addba_responsesetup(peer_handle, tid,
  344. dialogtoken, statuscode, buffersize, batimeout);
  345. }
  346. static inline int cdp_delba_process(ol_txrx_soc_handle soc,
  347. void *peer_handle, int tid, uint16_t reasoncode)
  348. {
  349. if (soc->ops->cmn_drv_ops->delba_process)
  350. return soc->ops->cmn_drv_ops->delba_process(peer_handle,
  351. tid, reasoncode);
  352. return 0;
  353. }
  354. /**
  355. * cdp_get_peer_mac_addr_frm_id: function to return vdev id and and peer
  356. * mac address
  357. * @soc: SOC handle
  358. * @peer_id: peer id of the peer for which mac_address is required
  359. * @mac_addr: reference to mac address
  360. *
  361. * reutm: vdev_id of the vap
  362. */
  363. static inline uint8_t
  364. cdp_get_peer_mac_addr_frm_id(ol_txrx_soc_handle soc, uint16_t peer_id,
  365. uint8_t *mac_addr)
  366. {
  367. if (soc->ops->cmn_drv_ops->get_peer_mac_addr_frm_id)
  368. return soc->ops->cmn_drv_ops->get_peer_mac_addr_frm_id(soc,
  369. peer_id, mac_addr);
  370. return CDP_INVALID_VDEV_ID;
  371. }
  372. /**
  373. * cdp_set_vdev_dscp_tid_map(): function to set DSCP-tid map in the vap
  374. * @vdev: vdev handle
  375. * @map_id: id of the tid map
  376. *
  377. * Return: void
  378. */
  379. static inline void cdp_set_vdev_dscp_tid_map(ol_txrx_soc_handle soc,
  380. struct cdp_vdev *vdev, uint8_t map_id)
  381. {
  382. if (soc->ops->cmn_drv_ops->set_vdev_dscp_tid_map)
  383. return soc->ops->cmn_drv_ops->set_vdev_dscp_tid_map(vdev,
  384. map_id);
  385. return;
  386. }
  387. /**
  388. * cdp_set_pdev_dscp_tid_map(): function to change tid values in DSCP-tid map
  389. * @pdev: pdev handle
  390. * @map_id: id of the tid map
  391. * @tos: index value in map that needs to be changed
  392. * @tid: tid value passed by user
  393. *
  394. * Return: void
  395. */
  396. static inline void cdp_set_pdev_dscp_tid_map(ol_txrx_soc_handle soc,
  397. struct cdp_pdev *pdev, uint8_t map_id, uint8_t tos, uint8_t tid)
  398. {
  399. if (soc->ops->cmn_drv_ops->set_pdev_dscp_tid_map) {
  400. return soc->ops->cmn_drv_ops->set_pdev_dscp_tid_map(pdev,
  401. map_id, tos, tid);
  402. }
  403. return;
  404. }
  405. /**
  406. * cdp_flush_cache_rx_queue() - flush cache rx queue frame
  407. *
  408. * Return: None
  409. */
  410. static inline void cdp_flush_cache_rx_queue(ol_txrx_soc_handle soc)
  411. {
  412. if (soc->ops->cmn_drv_ops->flush_cache_rx_queue)
  413. soc->ops->cmn_drv_ops->flush_cache_rx_queue();
  414. }
  415. /**
  416. * cdp_txrx_stats(): function to map to host and firmware statistics
  417. * @soc: soc handle
  418. * @vdev: virtual device
  419. * @req: statistics request handle
  420. * @stats: statistics option
  421. *
  422. * return: status
  423. */
  424. static inline
  425. int cdp_txrx_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  426. struct ol_txrx_stats_req *req, enum cdp_stats stats)
  427. {
  428. if (soc->ops->cmn_drv_ops->txrx_stats)
  429. return soc->ops->cmn_drv_ops->txrx_stats(vdev, req, stats);
  430. return 0;
  431. }
  432. #endif /* _CDP_TXRX_CMN_H_ */