cdp_txrx_cmn.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. /*
  2. * Copyright (c) 2011-2016 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_api_common.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 "htc_api.h"
  34. #include "qdf_types.h"
  35. #include "qdf_nbuf.h"
  36. /******************************************************************************
  37. *
  38. * Common Data Path Header File
  39. *
  40. *****************************************************************************/
  41. /******************************************************************************
  42. *
  43. * Structure definitions
  44. *
  45. *****************************************************************************/
  46. /**
  47. * ol_txrx_pdev_handle - opaque handle for txrx physical device
  48. * object
  49. */
  50. struct ol_txrx_pdev_t;
  51. typedef struct ol_txrx_pdev_t *ol_txrx_pdev_handle;
  52. /**
  53. * ol_txrx_vdev_handle - opaque handle for txrx virtual device
  54. * object
  55. */
  56. struct ol_txrx_vdev_t;
  57. typedef struct ol_txrx_vdev_t *ol_txrx_vdev_handle;
  58. /**
  59. * ol_pdev_handle - opaque handle for the configuration
  60. * associated with the physical device
  61. */
  62. struct ol_pdev_t;
  63. typedef struct ol_pdev_t *ol_pdev_handle;
  64. /**
  65. * ol_txrx_peer_handle - opaque handle for txrx peer object
  66. */
  67. struct ol_txrx_peer_t;
  68. typedef struct ol_txrx_peer_t *ol_txrx_peer_handle;
  69. /**
  70. * ol_txrx_vdev_delete_cb - callback registered during vdev
  71. * detach
  72. */
  73. typedef void (*ol_txrx_vdev_delete_cb)(void *context);
  74. /**
  75. * ol_osif_vdev_handle - paque handle for OS shim virtual device
  76. * object
  77. */
  78. struct ol_osif_vdev_t;
  79. typedef struct ol_osif_vdev_t *ol_osif_vdev_handle;
  80. /**
  81. * wlan_op_mode - Virtual device operation mode
  82. * @wlan_op_mode_unknown: Unknown mode
  83. * @wlan_op_mode_ap: AP mode
  84. * @wlan_op_mode_ibss: IBSS mode
  85. * @wlan_op_mode_sta: STA (client) mode
  86. * @wlan_op_mode_monitor: Monitor mode
  87. * @wlan_op_mode_ocb: OCB mode
  88. * @wlan_op_mode_ndi: NAN datapath mode
  89. */
  90. enum wlan_op_mode {
  91. wlan_op_mode_unknown,
  92. wlan_op_mode_ap,
  93. wlan_op_mode_ibss,
  94. wlan_op_mode_sta,
  95. wlan_op_mode_monitor,
  96. wlan_op_mode_ocb,
  97. wlan_op_mode_ndi,
  98. };
  99. /**
  100. * ol_txrx_tx_fp - top-level transmit function
  101. * @data_vdev - handle to the virtual device object
  102. * @msdu_list - list of network buffers
  103. */
  104. typedef qdf_nbuf_t (*ol_txrx_tx_fp)(ol_txrx_vdev_handle data_vdev,
  105. qdf_nbuf_t msdu_list);
  106. /**
  107. * ol_txrx_tx_flow_control_fp - tx flow control notification
  108. * function from txrx to OS shim
  109. * @osif_dev - the virtual device's OS shim object
  110. * @tx_resume - tx os q should be resumed or not
  111. */
  112. typedef void (*ol_txrx_tx_flow_control_fp)(void *osif_dev,
  113. bool tx_resume);
  114. /**
  115. * ol_txrx_rx_fp - receive function to hand batches of data
  116. * frames from txrx to OS shim
  117. * @data_vdev - handle to the OSIF virtual device object
  118. * @msdu_list - list of network buffers
  119. */
  120. typedef QDF_STATUS (*ol_txrx_rx_fp)(void *osif_dev, qdf_nbuf_t msdu_list);
  121. /**
  122. * ol_txrx_rx_check_wai_fp - OSIF WAPI receive function
  123. */
  124. typedef bool (*ol_txrx_rx_check_wai_fp)(ol_osif_vdev_handle vdev,
  125. qdf_nbuf_t mpdu_head,
  126. qdf_nbuf_t mpdu_tail);
  127. /**
  128. * ol_txrx_rx_mon_fp - OSIF monitor mode receive function for single
  129. * MPDU (802.11 format)
  130. */
  131. typedef void (*ol_txrx_rx_mon_fp)(ol_osif_vdev_handle vdev,
  132. qdf_nbuf_t mpdu,
  133. void *rx_status);
  134. /**
  135. * ol_txrx_proxy_arp_fp - proxy arp function pointer
  136. */
  137. typedef int (*ol_txrx_proxy_arp_fp)(ol_osif_vdev_handle vdev,
  138. qdf_nbuf_t netbuf);
  139. /**
  140. * ol_txrx_stats_callback - statistics notify callback
  141. */
  142. typedef void (*ol_txrx_stats_callback)(void *ctxt,
  143. uint32_t type,
  144. uint8_t *buf, int bytes);
  145. /**
  146. * ol_txrx_ops - (pointers to) the functions used for tx and rx
  147. * data xfer
  148. *
  149. * There are two portions of these txrx operations.
  150. * The rx portion is filled in by OSIF SW before calling
  151. * ol_txrx_osif_vdev_register; inside the ol_txrx_osif_vdev_register
  152. * the txrx SW stores a copy of these rx function pointers, to use
  153. * as it delivers rx data frames to the OSIF SW.
  154. * The tx portion is filled in by the txrx SW inside
  155. * ol_txrx_osif_vdev_register; when the function call returns,
  156. * the OSIF SW stores a copy of these tx functions to use as it
  157. * delivers tx data frames to the txrx SW.
  158. *
  159. * @tx.std - the tx function pointer for standard data
  160. * frames This function pointer is set by the txrx SW
  161. * perform host-side transmit operations based on
  162. * whether a HL or LL host/target interface is in use.
  163. * @tx.flow_control_cb - the transmit flow control
  164. * function that is registered by the
  165. * OSIF which is called from txrx to
  166. * indicate whether the transmit OS
  167. * queues should be paused/resumed
  168. * @rx.std - the OS shim rx function to deliver rx data
  169. * frames to. This can have different values for
  170. * different virtual devices, e.g. so one virtual
  171. * device's OS shim directly hands rx frames to the OS,
  172. * but another virtual device's OS shim filters out P2P
  173. * messages before sending the rx frames to the OS. The
  174. * netbufs delivered to the osif_rx function are in the
  175. * format specified by the OS to use for tx and rx
  176. * frames (either 802.3 or native WiFi)
  177. * @rx.wai_check - the tx function pointer for WAPI frames
  178. * @rx.mon - the OS shim rx monitor function to deliver
  179. * monitor data to Though in practice, it is probable
  180. * that the same function will be used for delivering
  181. * rx monitor data for all virtual devices, in theory
  182. * each different virtual device can have a different
  183. * OS shim function for accepting rx monitor data. The
  184. * netbufs delivered to the osif_rx_mon function are in
  185. * 802.11 format. Each netbuf holds a 802.11 MPDU, not
  186. * an 802.11 MSDU. Depending on compile-time
  187. * configuration, each netbuf may also have a
  188. * monitor-mode encapsulation header such as a radiotap
  189. * header added before the MPDU contents.
  190. * @proxy_arp - proxy arp function pointer - specified by
  191. * OS shim, stored by txrx
  192. */
  193. struct ol_txrx_ops {
  194. /* tx function pointers - specified by txrx, stored by OS shim */
  195. struct {
  196. ol_txrx_tx_fp tx;
  197. } tx;
  198. /* rx function pointers - specified by OS shim, stored by txrx */
  199. struct {
  200. ol_txrx_rx_fp rx;
  201. ol_txrx_rx_check_wai_fp wai_check;
  202. ol_txrx_rx_mon_fp mon;
  203. } rx;
  204. /* proxy arp function pointer - specified by OS shim, stored by txrx */
  205. ol_txrx_proxy_arp_fp proxy_arp;
  206. };
  207. /**
  208. * ol_txrx_stats_req - specifications of the requested
  209. * statistics
  210. */
  211. struct ol_txrx_stats_req {
  212. uint32_t stats_type_upload_mask; /* which stats to upload */
  213. uint32_t stats_type_reset_mask; /* which stats to reset */
  214. /* stats will be printed if either print element is set */
  215. struct {
  216. int verbose; /* verbose stats printout */
  217. int concise; /* concise stats printout (takes precedence) */
  218. } print; /* print uploaded stats */
  219. /* stats notify callback will be invoked if fp is non-NULL */
  220. struct {
  221. ol_txrx_stats_callback fp;
  222. void *ctxt;
  223. } callback;
  224. /* stats will be copied into the specified buffer if buf is non-NULL */
  225. struct {
  226. uint8_t *buf;
  227. int byte_limit; /* don't copy more than this */
  228. } copy;
  229. /*
  230. * If blocking is true, the caller will take the specified semaphore
  231. * to wait for the stats to be uploaded, and the driver will release
  232. * the semaphore when the stats are done being uploaded.
  233. */
  234. struct {
  235. int blocking;
  236. /*Note: this needs to change to some qdf_* type */
  237. qdf_semaphore_t *sem_ptr;
  238. } wait;
  239. };
  240. /******************************************************************************
  241. *
  242. * Control Interface (A Interface)
  243. *
  244. *****************************************************************************/
  245. int
  246. ol_txrx_pdev_attach_target(ol_txrx_pdev_handle pdev);
  247. ol_txrx_vdev_handle
  248. ol_txrx_vdev_attach(ol_txrx_pdev_handle pdev, uint8_t *vdev_mac_addr,
  249. uint8_t vdev_id, enum wlan_op_mode op_mode);
  250. void
  251. ol_txrx_vdev_detach(ol_txrx_vdev_handle vdev,
  252. ol_txrx_vdev_delete_cb callback, void *cb_context);
  253. ol_txrx_pdev_handle
  254. ol_txrx_pdev_attach(
  255. ol_pdev_handle ctrl_pdev,
  256. HTC_HANDLE htc_pdev,
  257. qdf_device_t osdev);
  258. void
  259. ol_txrx_pdev_detach(ol_txrx_pdev_handle pdev, int force);
  260. ol_txrx_peer_handle
  261. ol_txrx_peer_attach(ol_txrx_vdev_handle vdev, uint8_t *peer_mac_addr);
  262. void
  263. ol_txrx_peer_detach(ol_txrx_peer_handle peer);
  264. int
  265. ol_txrx_set_monitor_mode(ol_txrx_vdev_handle vdev);
  266. void
  267. ol_txrx_set_curchan(
  268. ol_txrx_pdev_handle pdev,
  269. uint32_t chan_mhz);
  270. void
  271. ol_txrx_set_privacy_filters(ol_txrx_vdev_handle vdev,
  272. void *filter, uint32_t num);
  273. /******************************************************************************
  274. * Data Interface (B Interface)
  275. *****************************************************************************/
  276. void
  277. ol_txrx_vdev_register(ol_txrx_vdev_handle vdev,
  278. void *osif_vdev, struct ol_txrx_ops *txrx_ops);
  279. int
  280. ol_txrx_mgmt_send(
  281. ol_txrx_vdev_handle vdev,
  282. qdf_nbuf_t tx_mgmt_frm,
  283. uint8_t type);
  284. int
  285. ol_txrx_mgmt_send_ext(ol_txrx_vdev_handle vdev,
  286. qdf_nbuf_t tx_mgmt_frm,
  287. uint8_t type, uint8_t use_6mbps, uint16_t chanfreq);
  288. /**
  289. * ol_txrx_mgmt_tx_cb - tx management delivery notification
  290. * callback function
  291. */
  292. typedef void
  293. (*ol_txrx_mgmt_tx_cb)(void *ctxt, qdf_nbuf_t tx_mgmt_frm, int had_error);
  294. void
  295. ol_txrx_mgmt_tx_cb_set(ol_txrx_pdev_handle pdev,
  296. uint8_t type,
  297. ol_txrx_mgmt_tx_cb download_cb,
  298. ol_txrx_mgmt_tx_cb ota_ack_cb, void *ctxt);
  299. int ol_txrx_get_tx_pending(ol_txrx_pdev_handle pdev);
  300. /**
  301. * ol_txrx_data_tx_cb - Function registered with the data path
  302. * that is called when tx frames marked as "no free" are
  303. * done being transmitted
  304. */
  305. typedef void
  306. (*ol_txrx_data_tx_cb)(void *ctxt, qdf_nbuf_t tx_frm, int had_error);
  307. void
  308. ol_txrx_data_tx_cb_set(ol_txrx_vdev_handle data_vdev,
  309. ol_txrx_data_tx_cb callback, void *ctxt);
  310. /******************************************************************************
  311. * Statistics and Debugging Interface (C Inteface)
  312. *****************************************************************************/
  313. int
  314. ol_txrx_aggr_cfg(ol_txrx_vdev_handle vdev,
  315. int max_subfrms_ampdu,
  316. int max_subfrms_amsdu);
  317. int
  318. ol_txrx_fw_stats_get(
  319. ol_txrx_vdev_handle vdev,
  320. struct ol_txrx_stats_req *req,
  321. bool per_vdev,
  322. bool response_expected);
  323. int
  324. ol_txrx_debug(ol_txrx_vdev_handle vdev, int debug_specs);
  325. void ol_txrx_fw_stats_cfg(
  326. ol_txrx_vdev_handle vdev,
  327. uint8_t cfg_stats_type,
  328. uint32_t cfg_val);
  329. void ol_txrx_print_level_set(unsigned level);
  330. #define TXRX_FW_STATS_TXSTATS 1
  331. #define TXRX_FW_STATS_RXSTATS 2
  332. #define TXRX_FW_STATS_RX_RATE_INFO 3
  333. #define TXRX_FW_STATS_PHYSTATS 4
  334. #define TXRX_FW_STATS_PHYSTATS_CONCISE 5
  335. #define TXRX_FW_STATS_TX_RATE_INFO 6
  336. #define TXRX_FW_STATS_TID_STATE 7
  337. #define TXRX_FW_STATS_HOST_STATS 8
  338. #define TXRX_FW_STATS_CLEAR_HOST_STATS 9
  339. #define TXRX_FW_STATS_CE_STATS 10
  340. #define TXRX_FW_STATS_VOW_UMAC_COUNTER 11
  341. #define TXRX_FW_STATS_ME_STATS 12
  342. #define TXRX_FW_STATS_TXBF_INFO 13
  343. #define TXRX_FW_STATS_SND_INFO 14
  344. #define TXRX_FW_STATS_ERROR_INFO 15
  345. #define TXRX_FW_STATS_TX_SELFGEN_INFO 16
  346. #define TXRX_FW_STATS_TX_MU_INFO 17
  347. #define TXRX_FW_SIFS_RESP_INFO 18
  348. #define TXRX_FW_RESET_STATS 19
  349. #define TXRX_FW_MAC_WDOG_STATS 20
  350. #define TXRX_FW_MAC_DESC_STATS 21
  351. #define TXRX_FW_MAC_FETCH_MGR_STATS 22
  352. #define TXRX_FW_MAC_PREFETCH_MGR_STATS 23
  353. #define PER_RADIO_FW_STATS_REQUEST 0
  354. #define PER_VDEV_FW_STATS_REQUEST 1
  355. /**
  356. * ol_txrx_get_vdev_mac_addr() - Return mac addr of vdev
  357. * @vdev: vdev handle
  358. *
  359. * Return: vdev mac address
  360. */
  361. uint8_t *
  362. ol_txrx_get_vdev_mac_addr(ol_txrx_vdev_handle vdev);
  363. /**
  364. * ol_txrx_get_vdev_struct_mac_addr() - Return handle to struct qdf_mac_addr of
  365. * vdev
  366. * @vdev: vdev handle
  367. *
  368. * Return: Handle to struct qdf_mac_addr
  369. */
  370. struct qdf_mac_addr *
  371. ol_txrx_get_vdev_struct_mac_addr(ol_txrx_vdev_handle vdev);
  372. /**
  373. * ol_txrx_get_pdev_from_vdev() - Return handle to pdev of vdev
  374. * @vdev: vdev handle
  375. *
  376. * Return: Handle to pdev
  377. */
  378. ol_txrx_pdev_handle ol_txrx_get_pdev_from_vdev(ol_txrx_vdev_handle vdev);
  379. /**
  380. * ol_txrx_get_ctrl_pdev_from_vdev() - Return control pdev of vdev
  381. * @vdev: vdev handle
  382. *
  383. * Return: Handle to control pdev
  384. */
  385. ol_pdev_handle
  386. ol_txrx_get_ctrl_pdev_from_vdev(ol_txrx_vdev_handle vdev);
  387. #endif /* _CDP_TXRX_CMN_H_ */