dp_internal.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. #if DP_PRINT_ENABLE
  21. #include <stdarg.h> /* va_list */
  22. #include <qdf_types.h> /* qdf_vprint */
  23. #include <cdp_txrx_handle.h>
  24. enum {
  25. /* FATAL_ERR - print only irrecoverable error messages */
  26. DP_PRINT_LEVEL_FATAL_ERR,
  27. /* ERR - include non-fatal err messages */
  28. DP_PRINT_LEVEL_ERR,
  29. /* WARN - include warnings */
  30. DP_PRINT_LEVEL_WARN,
  31. /* INFO1 - include fundamental, infrequent events */
  32. DP_PRINT_LEVEL_INFO1,
  33. /* INFO2 - include non-fundamental but infrequent events */
  34. DP_PRINT_LEVEL_INFO2,
  35. };
  36. #define dp_print(level, fmt, ...) do { \
  37. if (level <= g_txrx_print_level) \
  38. qdf_print(fmt, ## __VA_ARGS__); \
  39. while (0)
  40. #define DP_PRINT(level, fmt, ...) do { \
  41. dp_print(level, "DP: " fmt, ## __VA_ARGS__); \
  42. while (0)
  43. #else
  44. #define DP_PRINT(level, fmt, ...)
  45. #endif /* DP_PRINT_ENABLE */
  46. #define DP_TRACE(LVL, fmt, args ...) \
  47. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_##LVL, \
  48. fmt, ## args)
  49. #define DP_TRACE_STATS(LVL, fmt, args ...) \
  50. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_##LVL, \
  51. fmt, ## args)
  52. #define DP_STATS_INIT(_handle) \
  53. qdf_mem_set(&((_handle)->stats), sizeof((_handle)->stats), 0x0)
  54. #define DP_STATS_CLR(_handle) \
  55. qdf_mem_set(&((_handle)->stats), sizeof((_handle)->stats), 0x0)
  56. #ifndef DISABLE_DP_STATS
  57. #define DP_STATS_INC(_handle, _field, _delta) \
  58. { \
  59. _handle->stats._field += _delta; \
  60. }
  61. #define DP_STATS_INCC(_handle, _field, _delta, _cond) \
  62. { \
  63. if (_cond) { \
  64. _handle->stats._field += _delta; \
  65. } \
  66. }
  67. #define DP_STATS_DEC(_handle, _field, _delta) \
  68. { \
  69. _handle->stats._field -= _delta; \
  70. }
  71. #define DP_STATS_UPD(_handle, _field, _delta) \
  72. { \
  73. _handle->stats._field = _delta; \
  74. }
  75. #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes) \
  76. { \
  77. DP_STATS_INC(_handle, _field.num, _count); \
  78. DP_STATS_INC(_handle, _field.bytes, _bytes) \
  79. }
  80. #define DP_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond) \
  81. { \
  82. DP_STATS_INCC(_handle, _field.num, _count, _cond); \
  83. DP_STATS_INCC(_handle, _field.bytes, _bytes, _cond) \
  84. }
  85. #define DP_STATS_AGGR(_handle_a, _handle_b, _field) \
  86. { \
  87. _handle_a->stats._field += _handle_b->stats._field; \
  88. }
  89. #define DP_STATS_AGGR_PKT(_handle_a, _handle_b, _field) \
  90. { \
  91. DP_STATS_AGGR(_handle_a, _handle_b, _field.num); \
  92. DP_STATS_AGGR(_handle_a, _handle_b, _field.bytes);\
  93. }
  94. #define DP_HIST_INIT() \
  95. uint32_t num_of_packets[MAX_PDEV_CNT] = {0};
  96. #define DP_HIST_PACKET_COUNT_INC(_pdev_id) \
  97. { \
  98. ++num_of_packets[_pdev_id]; \
  99. }
  100. #define DP_TX_HISTOGRAM_UPDATE(_pdev, _p_cntrs) \
  101. do { \
  102. if (_p_cntrs == 1) { \
  103. DP_STATS_INC(_pdev, \
  104. tx_comp_histogram.pkts_1, 1); \
  105. } else if (_p_cntrs > 1 && _p_cntrs <= 20) { \
  106. DP_STATS_INC(_pdev, \
  107. tx_comp_histogram.pkts_2_20, 1); \
  108. } else if (_p_cntrs > 20 && _p_cntrs <= 40) { \
  109. DP_STATS_INC(_pdev, \
  110. tx_comp_histogram.pkts_21_40, 1); \
  111. } else if (_p_cntrs > 40 && _p_cntrs <= 60) { \
  112. DP_STATS_INC(_pdev, \
  113. tx_comp_histogram.pkts_41_60, 1); \
  114. } else if (_p_cntrs > 60 && _p_cntrs <= 80) { \
  115. DP_STATS_INC(_pdev, \
  116. tx_comp_histogram.pkts_61_80, 1); \
  117. } else if (_p_cntrs > 80 && _p_cntrs <= 100) { \
  118. DP_STATS_INC(_pdev, \
  119. tx_comp_histogram.pkts_81_100, 1); \
  120. } else if (_p_cntrs > 100 && _p_cntrs <= 200) { \
  121. DP_STATS_INC(_pdev, \
  122. tx_comp_histogram.pkts_101_200, 1); \
  123. } else if (_p_cntrs > 200) { \
  124. DP_STATS_INC(_pdev, \
  125. tx_comp_histogram.pkts_201_plus, 1); \
  126. } \
  127. } while (0)
  128. #define DP_RX_HISTOGRAM_UPDATE(_pdev, _p_cntrs) \
  129. do { \
  130. if (_p_cntrs == 1) { \
  131. DP_STATS_INC(_pdev, \
  132. rx_ind_histogram.pkts_1, 1); \
  133. } else if (_p_cntrs > 1 && _p_cntrs <= 20) { \
  134. DP_STATS_INC(_pdev, \
  135. rx_ind_histogram.pkts_2_20, 1); \
  136. } else if (_p_cntrs > 20 && _p_cntrs <= 40) { \
  137. DP_STATS_INC(_pdev, \
  138. rx_ind_histogram.pkts_21_40, 1); \
  139. } else if (_p_cntrs > 40 && _p_cntrs <= 60) { \
  140. DP_STATS_INC(_pdev, \
  141. rx_ind_histogram.pkts_41_60, 1); \
  142. } else if (_p_cntrs > 60 && _p_cntrs <= 80) { \
  143. DP_STATS_INC(_pdev, \
  144. rx_ind_histogram.pkts_61_80, 1); \
  145. } else if (_p_cntrs > 80 && _p_cntrs <= 100) { \
  146. DP_STATS_INC(_pdev, \
  147. rx_ind_histogram.pkts_81_100, 1); \
  148. } else if (_p_cntrs > 100 && _p_cntrs <= 200) { \
  149. DP_STATS_INC(_pdev, \
  150. rx_ind_histogram.pkts_101_200, 1); \
  151. } else if (_p_cntrs > 200) { \
  152. DP_STATS_INC(_pdev, \
  153. rx_ind_histogram.pkts_201_plus, 1); \
  154. } \
  155. } while (0)
  156. #define DP_TX_HIST_STATS_PER_PDEV() \
  157. do { \
  158. uint8_t hist_stats = 0; \
  159. for (hist_stats = 0; hist_stats < soc->pdev_count; \
  160. hist_stats++) { \
  161. DP_TX_HISTOGRAM_UPDATE(soc->pdev_list[hist_stats], \
  162. num_of_packets[hist_stats]); \
  163. } \
  164. } while (0)
  165. #define DP_RX_HIST_STATS_PER_PDEV() \
  166. do { \
  167. uint8_t hist_stats = 0; \
  168. for (hist_stats = 0; hist_stats < soc->pdev_count; \
  169. hist_stats++) { \
  170. DP_RX_HISTOGRAM_UPDATE(soc->pdev_list[hist_stats], \
  171. num_of_packets[hist_stats]); \
  172. } \
  173. } while (0)
  174. #else
  175. #define DP_STATS_INC(_handle, _field, _delta)
  176. #define DP_STATS_INCC(_handle, _field, _delta, _cond)
  177. #define DP_STATS_DEC(_handle, _field, _delta)
  178. #define DP_STATS_UPD(_handle, _field, _delta)
  179. #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes)
  180. #define DP_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond)
  181. #define DP_STATS_AGGR(_handle_a, _handle_b, _field)
  182. #define DP_STATS_AGGR_PKT(_handle_a, _handle_b, _field)
  183. #define DP_HIST_INIT()
  184. #define DP_HIST_PACKET_COUNT_INC(_pdev_id)
  185. #define DP_TX_HISTOGRAM_UPDATE(_pdev, _p_cntrs)
  186. #define DP_RX_HISTOGRAM_UPDATE(_pdev, _p_cntrs)
  187. #define DP_RX_HIST_STATS_PER_PDEV()
  188. #define DP_TX_HIST_STATS_PER_PDEV()
  189. #endif
  190. extern int dp_peer_find_attach(struct dp_soc *soc);
  191. extern void dp_peer_find_detach(struct dp_soc *soc);
  192. extern void dp_peer_find_hash_add(struct dp_soc *soc, struct dp_peer *peer);
  193. extern void dp_peer_find_hash_remove(struct dp_soc *soc, struct dp_peer *peer);
  194. extern void dp_peer_find_hash_erase(struct dp_soc *soc);
  195. extern void dp_peer_rx_init(struct dp_pdev *pdev, struct dp_peer *peer);
  196. extern void dp_peer_cleanup(struct dp_vdev *vdev, struct dp_peer *peer);
  197. extern void dp_peer_rx_cleanup(struct dp_vdev *vdev, struct dp_peer *peer);
  198. extern void dp_peer_unref_delete(void *peer_handle);
  199. extern void dp_rx_discard(struct dp_vdev *vdev, struct dp_peer *peer,
  200. unsigned tid, qdf_nbuf_t msdu_list);
  201. extern void *dp_find_peer_by_addr(struct cdp_pdev *dev,
  202. uint8_t *peer_mac_addr, uint8_t *peer_id);
  203. #ifndef CONFIG_WIN
  204. QDF_STATUS dp_register_peer(struct cdp_pdev *pdev_handle,
  205. struct ol_txrx_desc_type *sta_desc);
  206. QDF_STATUS dp_clear_peer(struct cdp_pdev *pdev_handle, uint8_t local_id);
  207. void *dp_find_peer_by_addr_and_vdev(struct cdp_pdev *pdev_handle,
  208. struct cdp_vdev *vdev,
  209. uint8_t *peer_addr, uint8_t *local_id);
  210. uint16_t dp_local_peer_id(void *peer);
  211. void *dp_peer_find_by_local_id(struct cdp_pdev *pdev_handle, uint8_t local_id);
  212. QDF_STATUS dp_peer_state_update(struct cdp_pdev *pdev_handle, uint8_t *peer_mac,
  213. enum ol_txrx_peer_state state);
  214. QDF_STATUS dp_get_vdevid(void *peer_handle, uint8_t *vdev_id);
  215. struct cdp_vdev *dp_get_vdev_for_peer(void *peer);
  216. uint8_t *dp_peer_get_peer_mac_addr(void *peer);
  217. int dp_get_peer_state(void *peer_handle);
  218. void dp_local_peer_id_pool_init(struct dp_pdev *pdev);
  219. void dp_local_peer_id_alloc(struct dp_pdev *pdev, struct dp_peer *peer);
  220. void dp_local_peer_id_free(struct dp_pdev *pdev, struct dp_peer *peer);
  221. qdf_time_t *dp_get_last_assoc_received(void *peer_handle);
  222. qdf_time_t *dp_get_last_disassoc_received(void *peer_handle);
  223. qdf_time_t *dp_get_last_deauth_received(void *peer_handle);
  224. #endif
  225. extern int dp_addba_requestprocess_wifi3(void *peer_handle,
  226. uint8_t dialogtoken, uint16_t tid, uint16_t batimeout,
  227. uint16_t buffersize, uint16_t startseqnum);
  228. extern void dp_addba_responsesetup_wifi3(void *peer_handle, uint8_t tid,
  229. uint8_t *dialogtoken, uint16_t *statuscode,
  230. uint16_t *buffersize, uint16_t *batimeout);
  231. extern int dp_delba_process_wifi3(void *peer_handle,
  232. int tid, uint16_t reasoncode);
  233. extern int dp_rx_tid_setup_wifi3(struct dp_peer *peer, int tid,
  234. uint32_t ba_window_size, uint32_t start_seq);
  235. extern QDF_STATUS dp_reo_send_cmd(struct dp_soc *soc,
  236. enum hal_reo_cmd_type type, struct hal_reo_cmd_params *params,
  237. void (*callback_fn), void *data);
  238. extern void dp_reo_status_ring_handler(struct dp_soc *soc);
  239. void dp_aggregate_vdev_stats(struct dp_vdev *vdev);
  240. uint16_t dp_tx_me_send_convert_ucast(struct cdp_vdev *vdev_handle,
  241. qdf_nbuf_t nbuf, uint8_t newmac[][DP_MAC_ADDR_LEN],
  242. uint8_t new_mac_cnt);
  243. void dp_tx_me_alloc_descriptor(struct cdp_pdev *pdev);
  244. void dp_tx_me_free_descriptor(struct cdp_pdev *pdev);
  245. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  246. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  247. uint32_t config_param_1, uint32_t config_param_2,
  248. uint32_t config_param_3);
  249. void dp_htt_stats_print_tag(uint8_t tag_type, uint32_t *tag_buf);
  250. #endif /* #ifndef _DP_INTERNAL_H_ */