cdp_txrx_cmn.h 12 KB

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