dp_internal.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. /*
  2. * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _DP_INTERNAL_H_
  19. #define _DP_INTERNAL_H_
  20. #include "dp_types.h"
  21. #define RX_BUFFER_SIZE_PKTLOG_LITE 1024
  22. #if DP_PRINT_ENABLE
  23. #include <stdarg.h> /* va_list */
  24. #include <qdf_types.h> /* qdf_vprint */
  25. #include <cdp_txrx_handle.h>
  26. enum {
  27. /* FATAL_ERR - print only irrecoverable error messages */
  28. DP_PRINT_LEVEL_FATAL_ERR,
  29. /* ERR - include non-fatal err messages */
  30. DP_PRINT_LEVEL_ERR,
  31. /* WARN - include warnings */
  32. DP_PRINT_LEVEL_WARN,
  33. /* INFO1 - include fundamental, infrequent events */
  34. DP_PRINT_LEVEL_INFO1,
  35. /* INFO2 - include non-fundamental but infrequent events */
  36. DP_PRINT_LEVEL_INFO2,
  37. };
  38. #define dp_print(level, fmt, ...) do { \
  39. if (level <= g_txrx_print_level) \
  40. qdf_print(fmt, ## __VA_ARGS__); \
  41. while (0)
  42. #define DP_PRINT(level, fmt, ...) do { \
  43. dp_print(level, "DP: " fmt, ## __VA_ARGS__); \
  44. while (0)
  45. #else
  46. #define DP_PRINT(level, fmt, ...)
  47. #endif /* DP_PRINT_ENABLE */
  48. #define DP_TRACE(LVL, fmt, args ...) \
  49. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_##LVL, \
  50. fmt, ## args)
  51. #define DP_TRACE_STATS(LVL, fmt, args ...) \
  52. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_##LVL, \
  53. fmt, ## args)
  54. #define DP_PRINT_STATS(fmt, args ...) \
  55. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, \
  56. fmt, ## args)
  57. #define DP_STATS_INIT(_handle) \
  58. qdf_mem_set(&((_handle)->stats), sizeof((_handle)->stats), 0x0)
  59. #define DP_STATS_CLR(_handle) \
  60. qdf_mem_set(&((_handle)->stats), sizeof((_handle)->stats), 0x0)
  61. #ifndef DISABLE_DP_STATS
  62. #define DP_STATS_INC(_handle, _field, _delta) \
  63. { \
  64. if (likely(_handle)) \
  65. _handle->stats._field += _delta; \
  66. }
  67. #define DP_STATS_INCC(_handle, _field, _delta, _cond) \
  68. { \
  69. if (_cond && likely(_handle)) \
  70. _handle->stats._field += _delta; \
  71. }
  72. #define DP_STATS_DEC(_handle, _field, _delta) \
  73. { \
  74. if (likely(_handle)) \
  75. _handle->stats._field -= _delta; \
  76. }
  77. #define DP_STATS_UPD(_handle, _field, _delta) \
  78. { \
  79. if (likely(_handle)) \
  80. _handle->stats._field = _delta; \
  81. }
  82. #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes) \
  83. { \
  84. DP_STATS_INC(_handle, _field.num, _count); \
  85. DP_STATS_INC(_handle, _field.bytes, _bytes) \
  86. }
  87. #define DP_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond) \
  88. { \
  89. DP_STATS_INCC(_handle, _field.num, _count, _cond); \
  90. DP_STATS_INCC(_handle, _field.bytes, _bytes, _cond) \
  91. }
  92. #define DP_STATS_AGGR(_handle_a, _handle_b, _field) \
  93. { \
  94. _handle_a->stats._field += _handle_b->stats._field; \
  95. }
  96. #define DP_STATS_AGGR_PKT(_handle_a, _handle_b, _field) \
  97. { \
  98. DP_STATS_AGGR(_handle_a, _handle_b, _field.num); \
  99. DP_STATS_AGGR(_handle_a, _handle_b, _field.bytes);\
  100. }
  101. #define DP_HIST_INIT() \
  102. uint32_t num_of_packets[MAX_PDEV_CNT] = {0};
  103. #define DP_HIST_PACKET_COUNT_INC(_pdev_id) \
  104. { \
  105. ++num_of_packets[_pdev_id]; \
  106. }
  107. #define DP_TX_HISTOGRAM_UPDATE(_pdev, _p_cntrs) \
  108. do { \
  109. if (_p_cntrs == 1) { \
  110. DP_STATS_INC(_pdev, \
  111. tx_comp_histogram.pkts_1, 1); \
  112. } else if (_p_cntrs > 1 && _p_cntrs <= 20) { \
  113. DP_STATS_INC(_pdev, \
  114. tx_comp_histogram.pkts_2_20, 1); \
  115. } else if (_p_cntrs > 20 && _p_cntrs <= 40) { \
  116. DP_STATS_INC(_pdev, \
  117. tx_comp_histogram.pkts_21_40, 1); \
  118. } else if (_p_cntrs > 40 && _p_cntrs <= 60) { \
  119. DP_STATS_INC(_pdev, \
  120. tx_comp_histogram.pkts_41_60, 1); \
  121. } else if (_p_cntrs > 60 && _p_cntrs <= 80) { \
  122. DP_STATS_INC(_pdev, \
  123. tx_comp_histogram.pkts_61_80, 1); \
  124. } else if (_p_cntrs > 80 && _p_cntrs <= 100) { \
  125. DP_STATS_INC(_pdev, \
  126. tx_comp_histogram.pkts_81_100, 1); \
  127. } else if (_p_cntrs > 100 && _p_cntrs <= 200) { \
  128. DP_STATS_INC(_pdev, \
  129. tx_comp_histogram.pkts_101_200, 1); \
  130. } else if (_p_cntrs > 200) { \
  131. DP_STATS_INC(_pdev, \
  132. tx_comp_histogram.pkts_201_plus, 1); \
  133. } \
  134. } while (0)
  135. #define DP_RX_HISTOGRAM_UPDATE(_pdev, _p_cntrs) \
  136. do { \
  137. if (_p_cntrs == 1) { \
  138. DP_STATS_INC(_pdev, \
  139. rx_ind_histogram.pkts_1, 1); \
  140. } else if (_p_cntrs > 1 && _p_cntrs <= 20) { \
  141. DP_STATS_INC(_pdev, \
  142. rx_ind_histogram.pkts_2_20, 1); \
  143. } else if (_p_cntrs > 20 && _p_cntrs <= 40) { \
  144. DP_STATS_INC(_pdev, \
  145. rx_ind_histogram.pkts_21_40, 1); \
  146. } else if (_p_cntrs > 40 && _p_cntrs <= 60) { \
  147. DP_STATS_INC(_pdev, \
  148. rx_ind_histogram.pkts_41_60, 1); \
  149. } else if (_p_cntrs > 60 && _p_cntrs <= 80) { \
  150. DP_STATS_INC(_pdev, \
  151. rx_ind_histogram.pkts_61_80, 1); \
  152. } else if (_p_cntrs > 80 && _p_cntrs <= 100) { \
  153. DP_STATS_INC(_pdev, \
  154. rx_ind_histogram.pkts_81_100, 1); \
  155. } else if (_p_cntrs > 100 && _p_cntrs <= 200) { \
  156. DP_STATS_INC(_pdev, \
  157. rx_ind_histogram.pkts_101_200, 1); \
  158. } else if (_p_cntrs > 200) { \
  159. DP_STATS_INC(_pdev, \
  160. rx_ind_histogram.pkts_201_plus, 1); \
  161. } \
  162. } while (0)
  163. #define DP_TX_HIST_STATS_PER_PDEV() \
  164. do { \
  165. uint8_t hist_stats = 0; \
  166. for (hist_stats = 0; hist_stats < soc->pdev_count; \
  167. hist_stats++) { \
  168. DP_TX_HISTOGRAM_UPDATE(soc->pdev_list[hist_stats], \
  169. num_of_packets[hist_stats]); \
  170. } \
  171. } while (0)
  172. #define DP_RX_HIST_STATS_PER_PDEV() \
  173. do { \
  174. uint8_t hist_stats = 0; \
  175. for (hist_stats = 0; hist_stats < soc->pdev_count; \
  176. hist_stats++) { \
  177. DP_RX_HISTOGRAM_UPDATE(soc->pdev_list[hist_stats], \
  178. num_of_packets[hist_stats]); \
  179. } \
  180. } while (0)
  181. #else
  182. #define DP_STATS_INC(_handle, _field, _delta)
  183. #define DP_STATS_INCC(_handle, _field, _delta, _cond)
  184. #define DP_STATS_DEC(_handle, _field, _delta)
  185. #define DP_STATS_UPD(_handle, _field, _delta)
  186. #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes)
  187. #define DP_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond)
  188. #define DP_STATS_AGGR(_handle_a, _handle_b, _field)
  189. #define DP_STATS_AGGR_PKT(_handle_a, _handle_b, _field)
  190. #define DP_HIST_INIT()
  191. #define DP_HIST_PACKET_COUNT_INC(_pdev_id)
  192. #define DP_TX_HISTOGRAM_UPDATE(_pdev, _p_cntrs)
  193. #define DP_RX_HISTOGRAM_UPDATE(_pdev, _p_cntrs)
  194. #define DP_RX_HIST_STATS_PER_PDEV()
  195. #define DP_TX_HIST_STATS_PER_PDEV()
  196. #endif
  197. #define DP_HTT_T2H_HP_PIPE 5
  198. extern int dp_peer_find_attach(struct dp_soc *soc);
  199. extern void dp_peer_find_detach(struct dp_soc *soc);
  200. extern void dp_peer_find_hash_add(struct dp_soc *soc, struct dp_peer *peer);
  201. extern void dp_peer_find_hash_remove(struct dp_soc *soc, struct dp_peer *peer);
  202. extern void dp_peer_find_hash_erase(struct dp_soc *soc);
  203. extern void dp_peer_rx_init(struct dp_pdev *pdev, struct dp_peer *peer);
  204. extern void dp_peer_cleanup(struct dp_vdev *vdev, struct dp_peer *peer);
  205. extern void dp_peer_rx_cleanup(struct dp_vdev *vdev, struct dp_peer *peer);
  206. extern void dp_peer_unref_delete(void *peer_handle);
  207. extern void dp_rx_discard(struct dp_vdev *vdev, struct dp_peer *peer,
  208. unsigned tid, qdf_nbuf_t msdu_list);
  209. extern void *dp_find_peer_by_addr(struct cdp_pdev *dev,
  210. uint8_t *peer_mac_addr, uint8_t *peer_id);
  211. #ifndef CONFIG_WIN
  212. QDF_STATUS dp_register_peer(struct cdp_pdev *pdev_handle,
  213. struct ol_txrx_desc_type *sta_desc);
  214. QDF_STATUS dp_clear_peer(struct cdp_pdev *pdev_handle, uint8_t local_id);
  215. void *dp_find_peer_by_addr_and_vdev(struct cdp_pdev *pdev_handle,
  216. struct cdp_vdev *vdev,
  217. uint8_t *peer_addr, uint8_t *local_id);
  218. uint16_t dp_local_peer_id(void *peer);
  219. void *dp_peer_find_by_local_id(struct cdp_pdev *pdev_handle, uint8_t local_id);
  220. QDF_STATUS dp_peer_state_update(struct cdp_pdev *pdev_handle, uint8_t *peer_mac,
  221. enum ol_txrx_peer_state state);
  222. QDF_STATUS dp_get_vdevid(void *peer_handle, uint8_t *vdev_id);
  223. struct cdp_vdev *dp_get_vdev_by_sta_id(struct cdp_pdev *pdev_handle,
  224. uint8_t sta_id);
  225. struct cdp_vdev *dp_get_vdev_for_peer(void *peer);
  226. uint8_t *dp_peer_get_peer_mac_addr(void *peer);
  227. int dp_get_peer_state(void *peer_handle);
  228. void dp_local_peer_id_pool_init(struct dp_pdev *pdev);
  229. void dp_local_peer_id_alloc(struct dp_pdev *pdev, struct dp_peer *peer);
  230. void dp_local_peer_id_free(struct dp_pdev *pdev, struct dp_peer *peer);
  231. qdf_time_t *dp_get_last_assoc_received(void *peer_handle);
  232. qdf_time_t *dp_get_last_disassoc_received(void *peer_handle);
  233. qdf_time_t *dp_get_last_deauth_received(void *peer_handle);
  234. #endif
  235. extern int dp_addba_requestprocess_wifi3(void *peer_handle,
  236. uint8_t dialogtoken, uint16_t tid, uint16_t batimeout,
  237. uint16_t buffersize, uint16_t startseqnum);
  238. extern void dp_addba_responsesetup_wifi3(void *peer_handle, uint8_t tid,
  239. uint8_t *dialogtoken, uint16_t *statuscode,
  240. uint16_t *buffersize, uint16_t *batimeout);
  241. extern int dp_delba_process_wifi3(void *peer_handle,
  242. int tid, uint16_t reasoncode);
  243. extern int dp_rx_tid_setup_wifi3(struct dp_peer *peer, int tid,
  244. uint32_t ba_window_size, uint32_t start_seq);
  245. extern QDF_STATUS dp_reo_send_cmd(struct dp_soc *soc,
  246. enum hal_reo_cmd_type type, struct hal_reo_cmd_params *params,
  247. void (*callback_fn), void *data);
  248. extern void dp_reo_cmdlist_destroy(struct dp_soc *soc);
  249. extern void dp_reo_status_ring_handler(struct dp_soc *soc);
  250. void dp_aggregate_vdev_stats(struct dp_vdev *vdev);
  251. void dp_rx_tid_stats_cb(struct dp_soc *soc, void *cb_ctxt,
  252. union hal_reo_status *reo_status);
  253. void dp_rx_bar_stats_cb(struct dp_soc *soc, void *cb_ctxt,
  254. union hal_reo_status *reo_status);
  255. uint16_t dp_tx_me_send_convert_ucast(struct cdp_vdev *vdev_handle,
  256. qdf_nbuf_t nbuf, uint8_t newmac[][DP_MAC_ADDR_LEN],
  257. uint8_t new_mac_cnt);
  258. void dp_tx_me_alloc_descriptor(struct cdp_pdev *pdev);
  259. void dp_tx_me_free_descriptor(struct cdp_pdev *pdev);
  260. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  261. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  262. uint32_t config_param_1, uint32_t config_param_2,
  263. uint32_t config_param_3);
  264. void dp_htt_stats_print_tag(uint8_t tag_type, uint32_t *tag_buf);
  265. void dp_peer_rxtid_stats(struct dp_peer *peer, void (*callback_fn),
  266. void *cb_ctxt);
  267. void dp_set_pn_check_wifi3(struct cdp_vdev *vdev_handle,
  268. struct cdp_peer *peer_handle, enum cdp_sec_type sec_type,
  269. uint32_t *rx_pn);
  270. #if defined(CONFIG_WIN) && WDI_EVENT_ENABLE
  271. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  272. uint32_t stats_type_upload_mask);
  273. int dp_wdi_event_unsub(struct cdp_pdev *txrx_pdev_handle,
  274. void *event_cb_sub_handle,
  275. uint32_t event);
  276. int dp_wdi_event_sub(struct cdp_pdev *txrx_pdev_handle,
  277. void *event_cb_sub_handle,
  278. uint32_t event);
  279. void dp_wdi_event_handler(enum WDI_EVENT event, void *soc,
  280. void *data, u_int16_t peer_id,
  281. int status, u_int8_t pdev_id);
  282. int dp_wdi_event_attach(struct dp_pdev *txrx_pdev);
  283. int dp_wdi_event_detach(struct dp_pdev *txrx_pdev);
  284. int dp_set_pktlog_wifi3(struct dp_pdev *pdev, uint32_t event,
  285. bool enable);
  286. static inline void dp_hif_update_pipe_callback(void *soc, void *cb_context,
  287. QDF_STATUS (*callback)(void *, qdf_nbuf_t, uint8_t), uint8_t pipe_id)
  288. {
  289. struct hif_msg_callbacks hif_pipe_callbacks;
  290. struct dp_soc *dp_soc = (struct dp_soc *)soc;
  291. /* TODO: Temporary change to bypass HTC connection for this new
  292. * HIF pipe, which will be used for packet log and other high-
  293. * priority HTT messsages. Proper HTC connection to be added
  294. * later once required FW changes are available
  295. */
  296. hif_pipe_callbacks.rxCompletionHandler = callback;
  297. hif_pipe_callbacks.Context = cb_context;
  298. hif_update_pipe_callback(dp_soc->hif_handle,
  299. DP_HTT_T2H_HP_PIPE, &hif_pipe_callbacks);
  300. }
  301. #else
  302. static inline int dp_wdi_event_unsub(struct cdp_pdev *txrx_pdev_handle,
  303. void *event_cb_sub_handle,
  304. uint32_t event)
  305. {
  306. return 0;
  307. }
  308. static inline int dp_wdi_event_sub(struct cdp_pdev *txrx_pdev_handle,
  309. void *event_cb_sub_handle,
  310. uint32_t event)
  311. {
  312. return 0;
  313. }
  314. static inline void dp_wdi_event_handler(enum WDI_EVENT event, void *soc,
  315. void *data, u_int16_t peer_id,
  316. int status, u_int8_t pdev_id)
  317. {
  318. }
  319. static inline int dp_wdi_event_attach(struct dp_pdev *txrx_pdev)
  320. {
  321. return 0;
  322. }
  323. static inline int dp_wdi_event_detach(struct dp_pdev *txrx_pdev)
  324. {
  325. return 0;
  326. }
  327. static inline int dp_set_pktlog_wifi3(struct dp_pdev *pdev, uint32_t event,
  328. bool enable)
  329. {
  330. return 0;
  331. }
  332. static inline QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  333. uint32_t stats_type_upload_mask)
  334. {
  335. return 0;
  336. }
  337. static inline void dp_hif_update_pipe_callback(void *soc, void *cb_context,
  338. QDF_STATUS (*callback)(void *, qdf_nbuf_t, uint8_t), uint8_t pipe_id)
  339. {
  340. }
  341. #endif /* CONFIG_WIN */
  342. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  343. void dp_tx_dump_flow_pool_info(void *soc);
  344. int dp_tx_delete_flow_pool(struct dp_soc *soc, struct dp_tx_desc_pool_s *pool,
  345. bool force);
  346. #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */
  347. #endif /* #ifndef _DP_INTERNAL_H_ */