dp_internal.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  1. /*
  2. * Copyright (c) 2016-2019 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. #define DP_RSSI_AVG_WEIGHT 2
  23. /*
  24. * Formula to derive avg_rssi is taken from wifi2.o firmware
  25. */
  26. #define DP_GET_AVG_RSSI(avg_rssi, last_rssi) \
  27. (((avg_rssi) - (((uint8_t)(avg_rssi)) >> DP_RSSI_AVG_WEIGHT)) \
  28. + ((((uint8_t)(last_rssi)) >> DP_RSSI_AVG_WEIGHT)))
  29. /* Macro For NYSM value received in VHT TLV */
  30. #define VHT_SGI_NYSM 3
  31. /* PPDU STATS CFG */
  32. #define DP_PPDU_STATS_CFG_ALL 0xFFFF
  33. /* PPDU stats mask sent to FW to enable enhanced stats */
  34. #define DP_PPDU_STATS_CFG_ENH_STATS 0xE67
  35. /* PPDU stats mask sent to FW to support debug sniffer feature */
  36. #define DP_PPDU_STATS_CFG_SNIFFER 0x2FFF
  37. /* PPDU stats mask sent to FW to support BPR feature*/
  38. #define DP_PPDU_STATS_CFG_BPR 0x2000
  39. /* PPDU stats mask sent to FW to support BPR and enhanced stats feature */
  40. #define DP_PPDU_STATS_CFG_BPR_ENH (DP_PPDU_STATS_CFG_BPR | \
  41. DP_PPDU_STATS_CFG_ENH_STATS)
  42. /* PPDU stats mask sent to FW to support BPR and pcktlog stats feature */
  43. #define DP_PPDU_STATS_CFG_BPR_PKTLOG (DP_PPDU_STATS_CFG_BPR | \
  44. DP_PPDU_TXLITE_STATS_BITMASK_CFG)
  45. /**
  46. * Bitmap of HTT PPDU TLV types for Default mode
  47. */
  48. #define HTT_PPDU_DEFAULT_TLV_BITMAP \
  49. (1 << HTT_PPDU_STATS_COMMON_TLV) | \
  50. (1 << HTT_PPDU_STATS_USR_COMMON_TLV) | \
  51. (1 << HTT_PPDU_STATS_USR_RATE_TLV) | \
  52. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV) | \
  53. (1 << HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV) | \
  54. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV)
  55. /**
  56. * Bitmap of HTT PPDU TLV types for Sniffer mode bitmap 64
  57. */
  58. #define HTT_PPDU_SNIFFER_AMPDU_TLV_BITMAP_64 \
  59. ((1 << HTT_PPDU_STATS_COMMON_TLV) | \
  60. (1 << HTT_PPDU_STATS_USR_COMMON_TLV) | \
  61. (1 << HTT_PPDU_STATS_USR_RATE_TLV) | \
  62. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV) | \
  63. (1 << HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV) | \
  64. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) | \
  65. (1 << HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_64_TLV) | \
  66. (1 << HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_64_TLV))
  67. /**
  68. * Bitmap of HTT PPDU TLV types for Sniffer mode bitmap 256
  69. */
  70. #define HTT_PPDU_SNIFFER_AMPDU_TLV_BITMAP_256 \
  71. ((1 << HTT_PPDU_STATS_COMMON_TLV) | \
  72. (1 << HTT_PPDU_STATS_USR_COMMON_TLV) | \
  73. (1 << HTT_PPDU_STATS_USR_RATE_TLV) | \
  74. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV) | \
  75. (1 << HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV) | \
  76. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) | \
  77. (1 << HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV) | \
  78. (1 << HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_256_TLV))
  79. #ifdef WLAN_TX_PKT_CAPTURE_ENH
  80. extern uint8_t
  81. dp_cpu_ring_map[DP_NSS_CPU_RING_MAP_MAX][WLAN_CFG_INT_NUM_CONTEXTS];
  82. #endif
  83. #if DP_PRINT_ENABLE
  84. #include <stdarg.h> /* va_list */
  85. #include <qdf_types.h> /* qdf_vprint */
  86. #include <cdp_txrx_handle.h>
  87. enum {
  88. /* FATAL_ERR - print only irrecoverable error messages */
  89. DP_PRINT_LEVEL_FATAL_ERR,
  90. /* ERR - include non-fatal err messages */
  91. DP_PRINT_LEVEL_ERR,
  92. /* WARN - include warnings */
  93. DP_PRINT_LEVEL_WARN,
  94. /* INFO1 - include fundamental, infrequent events */
  95. DP_PRINT_LEVEL_INFO1,
  96. /* INFO2 - include non-fundamental but infrequent events */
  97. DP_PRINT_LEVEL_INFO2,
  98. };
  99. #define dp_print(level, fmt, ...) do { \
  100. if (level <= g_txrx_print_level) \
  101. qdf_print(fmt, ## __VA_ARGS__); \
  102. while (0)
  103. #define DP_PRINT(level, fmt, ...) do { \
  104. dp_print(level, "DP: " fmt, ## __VA_ARGS__); \
  105. while (0)
  106. #else
  107. #define DP_PRINT(level, fmt, ...)
  108. #endif /* DP_PRINT_ENABLE */
  109. #define DP_TRACE(LVL, fmt, args ...) \
  110. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_##LVL, \
  111. fmt, ## args)
  112. #ifdef CONFIG_MCL
  113. /* Stat prints should not go to console or kernel logs.*/
  114. #define DP_PRINT_STATS(fmt, args ...)\
  115. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH, \
  116. fmt, ## args)
  117. #else
  118. #define DP_PRINT_STATS(fmt, args ...)\
  119. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,\
  120. fmt, ## args)
  121. #endif
  122. #define DP_STATS_INIT(_handle) \
  123. qdf_mem_zero(&((_handle)->stats), sizeof((_handle)->stats))
  124. #define DP_STATS_CLR(_handle) \
  125. qdf_mem_zero(&((_handle)->stats), sizeof((_handle)->stats))
  126. #ifndef DISABLE_DP_STATS
  127. #define DP_STATS_INC(_handle, _field, _delta) \
  128. { \
  129. if (likely(_handle)) \
  130. _handle->stats._field += _delta; \
  131. }
  132. #define DP_STATS_INCC(_handle, _field, _delta, _cond) \
  133. { \
  134. if (_cond && likely(_handle)) \
  135. _handle->stats._field += _delta; \
  136. }
  137. #define DP_STATS_DEC(_handle, _field, _delta) \
  138. { \
  139. if (likely(_handle)) \
  140. _handle->stats._field -= _delta; \
  141. }
  142. #define DP_STATS_UPD(_handle, _field, _delta) \
  143. { \
  144. if (likely(_handle)) \
  145. _handle->stats._field = _delta; \
  146. }
  147. #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes) \
  148. { \
  149. DP_STATS_INC(_handle, _field.num, _count); \
  150. DP_STATS_INC(_handle, _field.bytes, _bytes) \
  151. }
  152. #define DP_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond) \
  153. { \
  154. DP_STATS_INCC(_handle, _field.num, _count, _cond); \
  155. DP_STATS_INCC(_handle, _field.bytes, _bytes, _cond) \
  156. }
  157. #define DP_STATS_AGGR(_handle_a, _handle_b, _field) \
  158. { \
  159. _handle_a->stats._field += _handle_b->stats._field; \
  160. }
  161. #define DP_STATS_AGGR_PKT(_handle_a, _handle_b, _field) \
  162. { \
  163. DP_STATS_AGGR(_handle_a, _handle_b, _field.num); \
  164. DP_STATS_AGGR(_handle_a, _handle_b, _field.bytes);\
  165. }
  166. #define DP_STATS_UPD_STRUCT(_handle_a, _handle_b, _field) \
  167. { \
  168. _handle_a->stats._field = _handle_b->stats._field; \
  169. }
  170. #else
  171. #define DP_STATS_INC(_handle, _field, _delta)
  172. #define DP_STATS_INCC(_handle, _field, _delta, _cond)
  173. #define DP_STATS_DEC(_handle, _field, _delta)
  174. #define DP_STATS_UPD(_handle, _field, _delta)
  175. #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes)
  176. #define DP_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond)
  177. #define DP_STATS_AGGR(_handle_a, _handle_b, _field)
  178. #define DP_STATS_AGGR_PKT(_handle_a, _handle_b, _field)
  179. #endif
  180. #ifdef ENABLE_DP_HIST_STATS
  181. #define DP_HIST_INIT() \
  182. uint32_t num_of_packets[MAX_PDEV_CNT] = {0};
  183. #define DP_HIST_PACKET_COUNT_INC(_pdev_id) \
  184. { \
  185. ++num_of_packets[_pdev_id]; \
  186. }
  187. #define DP_TX_HISTOGRAM_UPDATE(_pdev, _p_cntrs) \
  188. do { \
  189. if (_p_cntrs == 1) { \
  190. DP_STATS_INC(_pdev, \
  191. tx_comp_histogram.pkts_1, 1); \
  192. } else if (_p_cntrs > 1 && _p_cntrs <= 20) { \
  193. DP_STATS_INC(_pdev, \
  194. tx_comp_histogram.pkts_2_20, 1); \
  195. } else if (_p_cntrs > 20 && _p_cntrs <= 40) { \
  196. DP_STATS_INC(_pdev, \
  197. tx_comp_histogram.pkts_21_40, 1); \
  198. } else if (_p_cntrs > 40 && _p_cntrs <= 60) { \
  199. DP_STATS_INC(_pdev, \
  200. tx_comp_histogram.pkts_41_60, 1); \
  201. } else if (_p_cntrs > 60 && _p_cntrs <= 80) { \
  202. DP_STATS_INC(_pdev, \
  203. tx_comp_histogram.pkts_61_80, 1); \
  204. } else if (_p_cntrs > 80 && _p_cntrs <= 100) { \
  205. DP_STATS_INC(_pdev, \
  206. tx_comp_histogram.pkts_81_100, 1); \
  207. } else if (_p_cntrs > 100 && _p_cntrs <= 200) { \
  208. DP_STATS_INC(_pdev, \
  209. tx_comp_histogram.pkts_101_200, 1); \
  210. } else if (_p_cntrs > 200) { \
  211. DP_STATS_INC(_pdev, \
  212. tx_comp_histogram.pkts_201_plus, 1); \
  213. } \
  214. } while (0)
  215. #define DP_RX_HISTOGRAM_UPDATE(_pdev, _p_cntrs) \
  216. do { \
  217. if (_p_cntrs == 1) { \
  218. DP_STATS_INC(_pdev, \
  219. rx_ind_histogram.pkts_1, 1); \
  220. } else if (_p_cntrs > 1 && _p_cntrs <= 20) { \
  221. DP_STATS_INC(_pdev, \
  222. rx_ind_histogram.pkts_2_20, 1); \
  223. } else if (_p_cntrs > 20 && _p_cntrs <= 40) { \
  224. DP_STATS_INC(_pdev, \
  225. rx_ind_histogram.pkts_21_40, 1); \
  226. } else if (_p_cntrs > 40 && _p_cntrs <= 60) { \
  227. DP_STATS_INC(_pdev, \
  228. rx_ind_histogram.pkts_41_60, 1); \
  229. } else if (_p_cntrs > 60 && _p_cntrs <= 80) { \
  230. DP_STATS_INC(_pdev, \
  231. rx_ind_histogram.pkts_61_80, 1); \
  232. } else if (_p_cntrs > 80 && _p_cntrs <= 100) { \
  233. DP_STATS_INC(_pdev, \
  234. rx_ind_histogram.pkts_81_100, 1); \
  235. } else if (_p_cntrs > 100 && _p_cntrs <= 200) { \
  236. DP_STATS_INC(_pdev, \
  237. rx_ind_histogram.pkts_101_200, 1); \
  238. } else if (_p_cntrs > 200) { \
  239. DP_STATS_INC(_pdev, \
  240. rx_ind_histogram.pkts_201_plus, 1); \
  241. } \
  242. } while (0)
  243. #define DP_TX_HIST_STATS_PER_PDEV() \
  244. do { \
  245. uint8_t hist_stats = 0; \
  246. for (hist_stats = 0; hist_stats < soc->pdev_count; \
  247. hist_stats++) { \
  248. DP_TX_HISTOGRAM_UPDATE(soc->pdev_list[hist_stats], \
  249. num_of_packets[hist_stats]); \
  250. } \
  251. } while (0)
  252. #define DP_RX_HIST_STATS_PER_PDEV() \
  253. do { \
  254. uint8_t hist_stats = 0; \
  255. for (hist_stats = 0; hist_stats < soc->pdev_count; \
  256. hist_stats++) { \
  257. DP_RX_HISTOGRAM_UPDATE(soc->pdev_list[hist_stats], \
  258. num_of_packets[hist_stats]); \
  259. } \
  260. } while (0)
  261. #else
  262. #define DP_HIST_INIT()
  263. #define DP_HIST_PACKET_COUNT_INC(_pdev_id)
  264. #define DP_TX_HISTOGRAM_UPDATE(_pdev, _p_cntrs)
  265. #define DP_RX_HISTOGRAM_UPDATE(_pdev, _p_cntrs)
  266. #define DP_RX_HIST_STATS_PER_PDEV()
  267. #define DP_TX_HIST_STATS_PER_PDEV()
  268. #endif
  269. #define DP_HTT_T2H_HP_PIPE 5
  270. static inline void dp_update_pdev_stats(struct dp_pdev *tgtobj,
  271. struct cdp_vdev_stats *srcobj)
  272. {
  273. uint8_t i;
  274. uint8_t pream_type;
  275. for (pream_type = 0; pream_type < DOT11_MAX; pream_type++) {
  276. for (i = 0; i < MAX_MCS; i++) {
  277. tgtobj->stats.tx.pkt_type[pream_type].
  278. mcs_count[i] +=
  279. srcobj->tx.pkt_type[pream_type].
  280. mcs_count[i];
  281. tgtobj->stats.rx.pkt_type[pream_type].
  282. mcs_count[i] +=
  283. srcobj->rx.pkt_type[pream_type].
  284. mcs_count[i];
  285. }
  286. }
  287. for (i = 0; i < MAX_BW; i++) {
  288. tgtobj->stats.tx.bw[i] += srcobj->tx.bw[i];
  289. tgtobj->stats.rx.bw[i] += srcobj->rx.bw[i];
  290. }
  291. for (i = 0; i < SS_COUNT; i++) {
  292. tgtobj->stats.tx.nss[i] += srcobj->tx.nss[i];
  293. tgtobj->stats.rx.nss[i] += srcobj->rx.nss[i];
  294. }
  295. for (i = 0; i < WME_AC_MAX; i++) {
  296. tgtobj->stats.tx.wme_ac_type[i] +=
  297. srcobj->tx.wme_ac_type[i];
  298. tgtobj->stats.rx.wme_ac_type[i] +=
  299. srcobj->rx.wme_ac_type[i];
  300. tgtobj->stats.tx.excess_retries_per_ac[i] +=
  301. srcobj->tx.excess_retries_per_ac[i];
  302. }
  303. for (i = 0; i < MAX_GI; i++) {
  304. tgtobj->stats.tx.sgi_count[i] +=
  305. srcobj->tx.sgi_count[i];
  306. tgtobj->stats.rx.sgi_count[i] +=
  307. srcobj->rx.sgi_count[i];
  308. }
  309. for (i = 0; i < MAX_RECEPTION_TYPES; i++)
  310. tgtobj->stats.rx.reception_type[i] +=
  311. srcobj->rx.reception_type[i];
  312. tgtobj->stats.tx.comp_pkt.bytes += srcobj->tx.comp_pkt.bytes;
  313. tgtobj->stats.tx.comp_pkt.num += srcobj->tx.comp_pkt.num;
  314. tgtobj->stats.tx.ucast.num += srcobj->tx.ucast.num;
  315. tgtobj->stats.tx.ucast.bytes += srcobj->tx.ucast.bytes;
  316. tgtobj->stats.tx.mcast.num += srcobj->tx.mcast.num;
  317. tgtobj->stats.tx.mcast.bytes += srcobj->tx.mcast.bytes;
  318. tgtobj->stats.tx.bcast.num += srcobj->tx.bcast.num;
  319. tgtobj->stats.tx.bcast.bytes += srcobj->tx.bcast.bytes;
  320. tgtobj->stats.tx.tx_success.num += srcobj->tx.tx_success.num;
  321. tgtobj->stats.tx.tx_success.bytes +=
  322. srcobj->tx.tx_success.bytes;
  323. tgtobj->stats.tx.nawds_mcast.num +=
  324. srcobj->tx.nawds_mcast.num;
  325. tgtobj->stats.tx.nawds_mcast.bytes +=
  326. srcobj->tx.nawds_mcast.bytes;
  327. tgtobj->stats.tx.nawds_mcast_drop +=
  328. srcobj->tx.nawds_mcast_drop;
  329. tgtobj->stats.tx.tx_failed += srcobj->tx.tx_failed;
  330. tgtobj->stats.tx.ofdma += srcobj->tx.ofdma;
  331. tgtobj->stats.tx.stbc += srcobj->tx.stbc;
  332. tgtobj->stats.tx.ldpc += srcobj->tx.ldpc;
  333. tgtobj->stats.tx.retries += srcobj->tx.retries;
  334. tgtobj->stats.tx.non_amsdu_cnt += srcobj->tx.non_amsdu_cnt;
  335. tgtobj->stats.tx.amsdu_cnt += srcobj->tx.amsdu_cnt;
  336. tgtobj->stats.tx.non_ampdu_cnt += srcobj->tx.non_ampdu_cnt;
  337. tgtobj->stats.tx.ampdu_cnt += srcobj->tx.ampdu_cnt;
  338. tgtobj->stats.tx.dropped.fw_rem.num += srcobj->tx.dropped.fw_rem.num;
  339. tgtobj->stats.tx.dropped.fw_rem.bytes +=
  340. srcobj->tx.dropped.fw_rem.bytes;
  341. tgtobj->stats.tx.dropped.fw_rem_tx +=
  342. srcobj->tx.dropped.fw_rem_tx;
  343. tgtobj->stats.tx.dropped.fw_rem_notx +=
  344. srcobj->tx.dropped.fw_rem_notx;
  345. tgtobj->stats.tx.dropped.fw_reason1 +=
  346. srcobj->tx.dropped.fw_reason1;
  347. tgtobj->stats.tx.dropped.fw_reason2 +=
  348. srcobj->tx.dropped.fw_reason2;
  349. tgtobj->stats.tx.dropped.fw_reason3 +=
  350. srcobj->tx.dropped.fw_reason3;
  351. tgtobj->stats.tx.dropped.age_out += srcobj->tx.dropped.age_out;
  352. tgtobj->stats.rx.err.mic_err += srcobj->rx.err.mic_err;
  353. if (srcobj->rx.rssi != 0)
  354. tgtobj->stats.rx.rssi = srcobj->rx.rssi;
  355. tgtobj->stats.rx.rx_rate = srcobj->rx.rx_rate;
  356. tgtobj->stats.rx.err.decrypt_err += srcobj->rx.err.decrypt_err;
  357. tgtobj->stats.rx.non_ampdu_cnt += srcobj->rx.non_ampdu_cnt;
  358. tgtobj->stats.rx.amsdu_cnt += srcobj->rx.ampdu_cnt;
  359. tgtobj->stats.rx.non_amsdu_cnt += srcobj->rx.non_amsdu_cnt;
  360. tgtobj->stats.rx.amsdu_cnt += srcobj->rx.amsdu_cnt;
  361. tgtobj->stats.rx.nawds_mcast_drop += srcobj->rx.nawds_mcast_drop;
  362. tgtobj->stats.rx.to_stack.num += srcobj->rx.to_stack.num;
  363. tgtobj->stats.rx.to_stack.bytes += srcobj->rx.to_stack.bytes;
  364. for (i = 0; i < CDP_MAX_RX_RINGS; i++) {
  365. tgtobj->stats.rx.rcvd_reo[i].num +=
  366. srcobj->rx.rcvd_reo[i].num;
  367. tgtobj->stats.rx.rcvd_reo[i].bytes +=
  368. srcobj->rx.rcvd_reo[i].bytes;
  369. }
  370. srcobj->rx.unicast.num =
  371. srcobj->rx.to_stack.num -
  372. (srcobj->rx.multicast.num);
  373. srcobj->rx.unicast.bytes =
  374. srcobj->rx.to_stack.bytes -
  375. (srcobj->rx.multicast.bytes);
  376. tgtobj->stats.rx.unicast.num += srcobj->rx.unicast.num;
  377. tgtobj->stats.rx.unicast.bytes += srcobj->rx.unicast.bytes;
  378. tgtobj->stats.rx.multicast.num += srcobj->rx.multicast.num;
  379. tgtobj->stats.rx.multicast.bytes += srcobj->rx.multicast.bytes;
  380. tgtobj->stats.rx.bcast.num += srcobj->rx.bcast.num;
  381. tgtobj->stats.rx.bcast.bytes += srcobj->rx.bcast.bytes;
  382. tgtobj->stats.rx.raw.num += srcobj->rx.raw.num;
  383. tgtobj->stats.rx.raw.bytes += srcobj->rx.raw.bytes;
  384. tgtobj->stats.rx.intra_bss.pkts.num +=
  385. srcobj->rx.intra_bss.pkts.num;
  386. tgtobj->stats.rx.intra_bss.pkts.bytes +=
  387. srcobj->rx.intra_bss.pkts.bytes;
  388. tgtobj->stats.rx.intra_bss.fail.num +=
  389. srcobj->rx.intra_bss.fail.num;
  390. tgtobj->stats.rx.intra_bss.fail.bytes +=
  391. srcobj->rx.intra_bss.fail.bytes;
  392. tgtobj->stats.tx.last_ack_rssi =
  393. srcobj->tx.last_ack_rssi;
  394. tgtobj->stats.rx.mec_drop.num += srcobj->rx.mec_drop.num;
  395. tgtobj->stats.rx.mec_drop.bytes += srcobj->rx.mec_drop.bytes;
  396. }
  397. static inline void dp_update_pdev_ingress_stats(struct dp_pdev *tgtobj,
  398. struct dp_vdev *srcobj)
  399. {
  400. DP_STATS_AGGR_PKT(tgtobj, srcobj, tx_i.nawds_mcast);
  401. DP_STATS_AGGR_PKT(tgtobj, srcobj, tx_i.rcvd);
  402. DP_STATS_AGGR_PKT(tgtobj, srcobj, tx_i.processed);
  403. DP_STATS_AGGR_PKT(tgtobj, srcobj, tx_i.reinject_pkts);
  404. DP_STATS_AGGR_PKT(tgtobj, srcobj, tx_i.inspect_pkts);
  405. DP_STATS_AGGR_PKT(tgtobj, srcobj, tx_i.raw.raw_pkt);
  406. DP_STATS_AGGR(tgtobj, srcobj, tx_i.raw.dma_map_error);
  407. DP_STATS_AGGR_PKT(tgtobj, srcobj, tx_i.tso.tso_pkt);
  408. DP_STATS_AGGR(tgtobj, srcobj, tx_i.tso.dropped_host.num);
  409. DP_STATS_AGGR(tgtobj, srcobj, tx_i.tso.dropped_target);
  410. DP_STATS_AGGR(tgtobj, srcobj, tx_i.sg.dropped_host.num);
  411. DP_STATS_AGGR(tgtobj, srcobj, tx_i.sg.dropped_target);
  412. DP_STATS_AGGR_PKT(tgtobj, srcobj, tx_i.sg.sg_pkt);
  413. DP_STATS_AGGR_PKT(tgtobj, srcobj, tx_i.mcast_en.mcast_pkt);
  414. DP_STATS_AGGR(tgtobj, srcobj,
  415. tx_i.mcast_en.dropped_map_error);
  416. DP_STATS_AGGR(tgtobj, srcobj,
  417. tx_i.mcast_en.dropped_self_mac);
  418. DP_STATS_AGGR(tgtobj, srcobj,
  419. tx_i.mcast_en.dropped_send_fail);
  420. DP_STATS_AGGR(tgtobj, srcobj, tx_i.mcast_en.ucast);
  421. DP_STATS_AGGR(tgtobj, srcobj, tx_i.dropped.dma_error);
  422. DP_STATS_AGGR(tgtobj, srcobj, tx_i.dropped.ring_full);
  423. DP_STATS_AGGR(tgtobj, srcobj, tx_i.dropped.enqueue_fail);
  424. DP_STATS_AGGR(tgtobj, srcobj, tx_i.dropped.desc_na.num);
  425. DP_STATS_AGGR(tgtobj, srcobj, tx_i.dropped.res_full);
  426. DP_STATS_AGGR(tgtobj, srcobj, tx_i.dropped.headroom_insufficient);
  427. DP_STATS_AGGR(tgtobj, srcobj, tx_i.cce_classified);
  428. DP_STATS_AGGR(tgtobj, srcobj, tx_i.cce_classified_raw);
  429. DP_STATS_AGGR(tgtobj, srcobj, tx_i.mesh.exception_fw);
  430. DP_STATS_AGGR(tgtobj, srcobj, tx_i.mesh.completion_fw);
  431. tgtobj->stats.tx_i.dropped.dropped_pkt.num =
  432. tgtobj->stats.tx_i.dropped.dma_error +
  433. tgtobj->stats.tx_i.dropped.ring_full +
  434. tgtobj->stats.tx_i.dropped.enqueue_fail +
  435. tgtobj->stats.tx_i.dropped.desc_na.num +
  436. tgtobj->stats.tx_i.dropped.res_full;
  437. tgtobj->stats.tx_i.tso.num_seg =
  438. srcobj->stats.tx_i.tso.num_seg;
  439. }
  440. static inline void dp_update_vdev_stats(struct cdp_vdev_stats *tgtobj,
  441. struct dp_peer *srcobj)
  442. {
  443. uint8_t i;
  444. uint8_t pream_type;
  445. for (pream_type = 0; pream_type < DOT11_MAX; pream_type++) {
  446. for (i = 0; i < MAX_MCS; i++) {
  447. tgtobj->tx.pkt_type[pream_type].
  448. mcs_count[i] +=
  449. srcobj->stats.tx.pkt_type[pream_type].
  450. mcs_count[i];
  451. tgtobj->rx.pkt_type[pream_type].
  452. mcs_count[i] +=
  453. srcobj->stats.rx.pkt_type[pream_type].
  454. mcs_count[i];
  455. }
  456. }
  457. for (i = 0; i < MAX_BW; i++) {
  458. tgtobj->tx.bw[i] += srcobj->stats.tx.bw[i];
  459. tgtobj->rx.bw[i] += srcobj->stats.rx.bw[i];
  460. }
  461. for (i = 0; i < SS_COUNT; i++) {
  462. tgtobj->tx.nss[i] += srcobj->stats.tx.nss[i];
  463. tgtobj->rx.nss[i] += srcobj->stats.rx.nss[i];
  464. }
  465. for (i = 0; i < WME_AC_MAX; i++) {
  466. tgtobj->tx.wme_ac_type[i] +=
  467. srcobj->stats.tx.wme_ac_type[i];
  468. tgtobj->rx.wme_ac_type[i] +=
  469. srcobj->stats.rx.wme_ac_type[i];
  470. tgtobj->tx.excess_retries_per_ac[i] +=
  471. srcobj->stats.tx.excess_retries_per_ac[i];
  472. }
  473. for (i = 0; i < MAX_GI; i++) {
  474. tgtobj->tx.sgi_count[i] +=
  475. srcobj->stats.tx.sgi_count[i];
  476. tgtobj->rx.sgi_count[i] +=
  477. srcobj->stats.rx.sgi_count[i];
  478. }
  479. for (i = 0; i < MAX_RECEPTION_TYPES; i++)
  480. tgtobj->rx.reception_type[i] +=
  481. srcobj->stats.rx.reception_type[i];
  482. tgtobj->tx.comp_pkt.bytes += srcobj->stats.tx.comp_pkt.bytes;
  483. tgtobj->tx.comp_pkt.num += srcobj->stats.tx.comp_pkt.num;
  484. tgtobj->tx.ucast.num += srcobj->stats.tx.ucast.num;
  485. tgtobj->tx.ucast.bytes += srcobj->stats.tx.ucast.bytes;
  486. tgtobj->tx.mcast.num += srcobj->stats.tx.mcast.num;
  487. tgtobj->tx.mcast.bytes += srcobj->stats.tx.mcast.bytes;
  488. tgtobj->tx.bcast.num += srcobj->stats.tx.bcast.num;
  489. tgtobj->tx.bcast.bytes += srcobj->stats.tx.bcast.bytes;
  490. tgtobj->tx.tx_success.num += srcobj->stats.tx.tx_success.num;
  491. tgtobj->tx.tx_success.bytes +=
  492. srcobj->stats.tx.tx_success.bytes;
  493. tgtobj->tx.nawds_mcast.num +=
  494. srcobj->stats.tx.nawds_mcast.num;
  495. tgtobj->tx.nawds_mcast.bytes +=
  496. srcobj->stats.tx.nawds_mcast.bytes;
  497. tgtobj->tx.nawds_mcast_drop +=
  498. srcobj->stats.tx.nawds_mcast_drop;
  499. tgtobj->tx.tx_failed += srcobj->stats.tx.tx_failed;
  500. tgtobj->tx.ofdma += srcobj->stats.tx.ofdma;
  501. tgtobj->tx.stbc += srcobj->stats.tx.stbc;
  502. tgtobj->tx.ldpc += srcobj->stats.tx.ldpc;
  503. tgtobj->tx.retries += srcobj->stats.tx.retries;
  504. tgtobj->tx.non_amsdu_cnt += srcobj->stats.tx.non_amsdu_cnt;
  505. tgtobj->tx.amsdu_cnt += srcobj->stats.tx.amsdu_cnt;
  506. tgtobj->tx.non_ampdu_cnt += srcobj->stats.tx.non_ampdu_cnt;
  507. tgtobj->tx.ampdu_cnt += srcobj->stats.tx.ampdu_cnt;
  508. tgtobj->tx.dropped.fw_rem.num += srcobj->stats.tx.dropped.fw_rem.num;
  509. tgtobj->tx.dropped.fw_rem.bytes +=
  510. srcobj->stats.tx.dropped.fw_rem.bytes;
  511. tgtobj->tx.dropped.fw_rem_tx +=
  512. srcobj->stats.tx.dropped.fw_rem_tx;
  513. tgtobj->tx.dropped.fw_rem_notx +=
  514. srcobj->stats.tx.dropped.fw_rem_notx;
  515. tgtobj->tx.dropped.fw_reason1 +=
  516. srcobj->stats.tx.dropped.fw_reason1;
  517. tgtobj->tx.dropped.fw_reason2 +=
  518. srcobj->stats.tx.dropped.fw_reason2;
  519. tgtobj->tx.dropped.fw_reason3 +=
  520. srcobj->stats.tx.dropped.fw_reason3;
  521. tgtobj->tx.dropped.age_out += srcobj->stats.tx.dropped.age_out;
  522. tgtobj->rx.err.mic_err += srcobj->stats.rx.err.mic_err;
  523. if (srcobj->stats.rx.rssi != 0)
  524. tgtobj->rx.rssi = srcobj->stats.rx.rssi;
  525. tgtobj->rx.rx_rate = srcobj->stats.rx.rx_rate;
  526. tgtobj->rx.err.decrypt_err += srcobj->stats.rx.err.decrypt_err;
  527. tgtobj->rx.non_ampdu_cnt += srcobj->stats.rx.non_ampdu_cnt;
  528. tgtobj->rx.amsdu_cnt += srcobj->stats.rx.ampdu_cnt;
  529. tgtobj->rx.non_amsdu_cnt += srcobj->stats.rx.non_amsdu_cnt;
  530. tgtobj->rx.amsdu_cnt += srcobj->stats.rx.amsdu_cnt;
  531. tgtobj->rx.nawds_mcast_drop += srcobj->stats.rx.nawds_mcast_drop;
  532. tgtobj->rx.to_stack.num += srcobj->stats.rx.to_stack.num;
  533. tgtobj->rx.to_stack.bytes += srcobj->stats.rx.to_stack.bytes;
  534. for (i = 0; i < CDP_MAX_RX_RINGS; i++) {
  535. tgtobj->rx.rcvd_reo[i].num +=
  536. srcobj->stats.rx.rcvd_reo[i].num;
  537. tgtobj->rx.rcvd_reo[i].bytes +=
  538. srcobj->stats.rx.rcvd_reo[i].bytes;
  539. }
  540. srcobj->stats.rx.unicast.num =
  541. srcobj->stats.rx.to_stack.num -
  542. srcobj->stats.rx.multicast.num;
  543. srcobj->stats.rx.unicast.bytes =
  544. srcobj->stats.rx.to_stack.bytes -
  545. srcobj->stats.rx.multicast.bytes;
  546. tgtobj->rx.unicast.num += srcobj->stats.rx.unicast.num;
  547. tgtobj->rx.unicast.bytes += srcobj->stats.rx.unicast.bytes;
  548. tgtobj->rx.multicast.num += srcobj->stats.rx.multicast.num;
  549. tgtobj->rx.multicast.bytes += srcobj->stats.rx.multicast.bytes;
  550. tgtobj->rx.bcast.num += srcobj->stats.rx.bcast.num;
  551. tgtobj->rx.bcast.bytes += srcobj->stats.rx.bcast.bytes;
  552. tgtobj->rx.raw.num += srcobj->stats.rx.raw.num;
  553. tgtobj->rx.raw.bytes += srcobj->stats.rx.raw.bytes;
  554. tgtobj->rx.intra_bss.pkts.num +=
  555. srcobj->stats.rx.intra_bss.pkts.num;
  556. tgtobj->rx.intra_bss.pkts.bytes +=
  557. srcobj->stats.rx.intra_bss.pkts.bytes;
  558. tgtobj->rx.intra_bss.fail.num +=
  559. srcobj->stats.rx.intra_bss.fail.num;
  560. tgtobj->rx.intra_bss.fail.bytes +=
  561. srcobj->stats.rx.intra_bss.fail.bytes;
  562. tgtobj->tx.last_ack_rssi =
  563. srcobj->stats.tx.last_ack_rssi;
  564. tgtobj->rx.mec_drop.num += srcobj->stats.rx.mec_drop.num;
  565. tgtobj->rx.mec_drop.bytes += srcobj->stats.rx.mec_drop.bytes;
  566. }
  567. #define DP_UPDATE_STATS(_tgtobj, _srcobj) \
  568. do { \
  569. uint8_t i; \
  570. uint8_t pream_type; \
  571. for (pream_type = 0; pream_type < DOT11_MAX; pream_type++) { \
  572. for (i = 0; i < MAX_MCS; i++) { \
  573. DP_STATS_AGGR(_tgtobj, _srcobj, \
  574. tx.pkt_type[pream_type].mcs_count[i]); \
  575. DP_STATS_AGGR(_tgtobj, _srcobj, \
  576. rx.pkt_type[pream_type].mcs_count[i]); \
  577. } \
  578. } \
  579. \
  580. for (i = 0; i < MAX_BW; i++) { \
  581. DP_STATS_AGGR(_tgtobj, _srcobj, tx.bw[i]); \
  582. DP_STATS_AGGR(_tgtobj, _srcobj, rx.bw[i]); \
  583. } \
  584. \
  585. for (i = 0; i < SS_COUNT; i++) { \
  586. DP_STATS_AGGR(_tgtobj, _srcobj, rx.nss[i]); \
  587. DP_STATS_AGGR(_tgtobj, _srcobj, tx.nss[i]); \
  588. } \
  589. for (i = 0; i < WME_AC_MAX; i++) { \
  590. DP_STATS_AGGR(_tgtobj, _srcobj, tx.wme_ac_type[i]); \
  591. DP_STATS_AGGR(_tgtobj, _srcobj, rx.wme_ac_type[i]); \
  592. DP_STATS_AGGR(_tgtobj, _srcobj, tx.excess_retries_per_ac[i]); \
  593. \
  594. } \
  595. \
  596. for (i = 0; i < MAX_GI; i++) { \
  597. DP_STATS_AGGR(_tgtobj, _srcobj, tx.sgi_count[i]); \
  598. DP_STATS_AGGR(_tgtobj, _srcobj, rx.sgi_count[i]); \
  599. } \
  600. \
  601. for (i = 0; i < MAX_RECEPTION_TYPES; i++) \
  602. DP_STATS_AGGR(_tgtobj, _srcobj, rx.reception_type[i]); \
  603. \
  604. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.comp_pkt); \
  605. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.ucast); \
  606. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.mcast); \
  607. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.bcast); \
  608. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.tx_success); \
  609. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.nawds_mcast); \
  610. DP_STATS_AGGR(_tgtobj, _srcobj, tx.nawds_mcast_drop); \
  611. DP_STATS_AGGR(_tgtobj, _srcobj, tx.tx_failed); \
  612. DP_STATS_AGGR(_tgtobj, _srcobj, tx.ofdma); \
  613. DP_STATS_AGGR(_tgtobj, _srcobj, tx.stbc); \
  614. DP_STATS_AGGR(_tgtobj, _srcobj, tx.ldpc); \
  615. DP_STATS_AGGR(_tgtobj, _srcobj, tx.retries); \
  616. DP_STATS_AGGR(_tgtobj, _srcobj, tx.non_amsdu_cnt); \
  617. DP_STATS_AGGR(_tgtobj, _srcobj, tx.amsdu_cnt); \
  618. DP_STATS_AGGR(_tgtobj, _srcobj, tx.non_ampdu_cnt); \
  619. DP_STATS_AGGR(_tgtobj, _srcobj, tx.ampdu_cnt); \
  620. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.dropped.fw_rem); \
  621. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_rem_tx); \
  622. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_rem_notx); \
  623. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason1); \
  624. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason2); \
  625. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason3); \
  626. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.age_out); \
  627. \
  628. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.mic_err); \
  629. if (_srcobj->stats.rx.rssi != 0) \
  630. DP_STATS_UPD_STRUCT(_tgtobj, _srcobj, rx.rssi); \
  631. DP_STATS_UPD_STRUCT(_tgtobj, _srcobj, rx.rx_rate); \
  632. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.decrypt_err); \
  633. DP_STATS_AGGR(_tgtobj, _srcobj, rx.non_ampdu_cnt); \
  634. DP_STATS_AGGR(_tgtobj, _srcobj, rx.ampdu_cnt); \
  635. DP_STATS_AGGR(_tgtobj, _srcobj, rx.non_amsdu_cnt); \
  636. DP_STATS_AGGR(_tgtobj, _srcobj, rx.amsdu_cnt); \
  637. DP_STATS_AGGR(_tgtobj, _srcobj, rx.nawds_mcast_drop); \
  638. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.to_stack); \
  639. \
  640. for (i = 0; i < CDP_MAX_RX_RINGS; i++) \
  641. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.rcvd_reo[i]); \
  642. \
  643. _srcobj->stats.rx.unicast.num = \
  644. _srcobj->stats.rx.to_stack.num - \
  645. _srcobj->stats.rx.multicast.num; \
  646. _srcobj->stats.rx.unicast.bytes = \
  647. _srcobj->stats.rx.to_stack.bytes - \
  648. _srcobj->stats.rx.multicast.bytes; \
  649. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.unicast); \
  650. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.multicast); \
  651. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.bcast); \
  652. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.raw); \
  653. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.intra_bss.pkts); \
  654. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.intra_bss.fail); \
  655. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.mec_drop); \
  656. \
  657. _tgtobj->stats.tx.last_ack_rssi = \
  658. _srcobj->stats.tx.last_ack_rssi; \
  659. } while (0)
  660. extern int dp_peer_find_attach(struct dp_soc *soc);
  661. extern void dp_peer_find_detach(struct dp_soc *soc);
  662. extern void dp_peer_find_hash_add(struct dp_soc *soc, struct dp_peer *peer);
  663. extern void dp_peer_find_hash_remove(struct dp_soc *soc, struct dp_peer *peer);
  664. extern void dp_peer_find_hash_erase(struct dp_soc *soc);
  665. extern void dp_peer_rx_init(struct dp_pdev *pdev, struct dp_peer *peer);
  666. void dp_peer_tx_init(struct dp_pdev *pdev, struct dp_peer *peer);
  667. extern void dp_peer_cleanup(struct dp_vdev *vdev, struct dp_peer *peer);
  668. extern void dp_peer_rx_cleanup(struct dp_vdev *vdev, struct dp_peer *peer);
  669. extern void dp_peer_unref_delete(void *peer_handle);
  670. extern void dp_rx_discard(struct dp_vdev *vdev, struct dp_peer *peer,
  671. unsigned tid, qdf_nbuf_t msdu_list);
  672. extern void *dp_find_peer_by_addr(struct cdp_pdev *dev,
  673. uint8_t *peer_mac_addr, uint8_t *peer_id);
  674. extern struct dp_peer *dp_peer_find_hash_find(struct dp_soc *soc,
  675. uint8_t *peer_mac_addr, int mac_addr_is_aligned, uint8_t vdev_id);
  676. #ifndef CONFIG_WIN
  677. QDF_STATUS dp_register_peer(struct cdp_pdev *pdev_handle,
  678. struct ol_txrx_desc_type *sta_desc);
  679. QDF_STATUS dp_clear_peer(struct cdp_pdev *pdev_handle, uint8_t local_id);
  680. void *dp_find_peer_by_addr_and_vdev(struct cdp_pdev *pdev_handle,
  681. struct cdp_vdev *vdev,
  682. uint8_t *peer_addr, uint8_t *local_id);
  683. uint16_t dp_local_peer_id(void *peer);
  684. void *dp_peer_find_by_local_id(struct cdp_pdev *pdev_handle, uint8_t local_id);
  685. QDF_STATUS dp_peer_state_update(struct cdp_pdev *pdev_handle, uint8_t *peer_mac,
  686. enum ol_txrx_peer_state state);
  687. QDF_STATUS dp_get_vdevid(void *peer_handle, uint8_t *vdev_id);
  688. struct cdp_vdev *dp_get_vdev_by_sta_id(struct cdp_pdev *pdev_handle,
  689. uint8_t sta_id);
  690. struct cdp_vdev *dp_get_vdev_for_peer(void *peer);
  691. uint8_t *dp_peer_get_peer_mac_addr(void *peer);
  692. int dp_get_peer_state(void *peer_handle);
  693. void dp_local_peer_id_pool_init(struct dp_pdev *pdev);
  694. void dp_local_peer_id_alloc(struct dp_pdev *pdev, struct dp_peer *peer);
  695. void dp_local_peer_id_free(struct dp_pdev *pdev, struct dp_peer *peer);
  696. #else
  697. static inline void dp_local_peer_id_pool_init(struct dp_pdev *pdev)
  698. {
  699. }
  700. static inline
  701. void dp_local_peer_id_alloc(struct dp_pdev *pdev, struct dp_peer *peer)
  702. {
  703. }
  704. static inline
  705. void dp_local_peer_id_free(struct dp_pdev *pdev, struct dp_peer *peer)
  706. {
  707. }
  708. #endif
  709. int dp_addba_resp_tx_completion_wifi3(void *peer_handle, uint8_t tid,
  710. int status);
  711. extern int dp_addba_requestprocess_wifi3(void *peer_handle,
  712. uint8_t dialogtoken, uint16_t tid, uint16_t batimeout,
  713. uint16_t buffersize, uint16_t startseqnum);
  714. extern void dp_addba_responsesetup_wifi3(void *peer_handle, uint8_t tid,
  715. uint8_t *dialogtoken, uint16_t *statuscode,
  716. uint16_t *buffersize, uint16_t *batimeout);
  717. extern void dp_set_addba_response(void *peer_handle, uint8_t tid,
  718. uint16_t statuscode);
  719. extern int dp_delba_process_wifi3(void *peer_handle,
  720. int tid, uint16_t reasoncode);
  721. /*
  722. * dp_delba_tx_completion_wifi3() - Handle delba tx completion
  723. *
  724. * @peer_handle: Peer handle
  725. * @tid: Tid number
  726. * @status: Tx completion status
  727. * Indicate status of delba Tx to DP for stats update and retry
  728. * delba if tx failed.
  729. *
  730. */
  731. int dp_delba_tx_completion_wifi3(void *peer_handle, uint8_t tid,
  732. int status);
  733. extern int dp_rx_tid_setup_wifi3(struct dp_peer *peer, int tid,
  734. uint32_t ba_window_size, uint32_t start_seq);
  735. extern QDF_STATUS dp_reo_send_cmd(struct dp_soc *soc,
  736. enum hal_reo_cmd_type type, struct hal_reo_cmd_params *params,
  737. void (*callback_fn), void *data);
  738. extern void dp_reo_cmdlist_destroy(struct dp_soc *soc);
  739. /**
  740. * dp_reo_status_ring_handler - Handler for REO Status ring
  741. * @soc: DP Soc handle
  742. *
  743. * Returns: Number of descriptors reaped
  744. */
  745. uint32_t dp_reo_status_ring_handler(struct dp_soc *soc);
  746. void dp_aggregate_vdev_stats(struct dp_vdev *vdev,
  747. struct cdp_vdev_stats *vdev_stats);
  748. void dp_rx_tid_stats_cb(struct dp_soc *soc, void *cb_ctxt,
  749. union hal_reo_status *reo_status);
  750. void dp_rx_bar_stats_cb(struct dp_soc *soc, void *cb_ctxt,
  751. union hal_reo_status *reo_status);
  752. uint16_t dp_tx_me_send_convert_ucast(struct cdp_vdev *vdev_handle,
  753. qdf_nbuf_t nbuf, uint8_t newmac[][QDF_MAC_ADDR_SIZE],
  754. uint8_t new_mac_cnt);
  755. void dp_tx_me_alloc_descriptor(struct cdp_pdev *pdev);
  756. void dp_tx_me_free_descriptor(struct cdp_pdev *pdev);
  757. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  758. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  759. uint32_t config_param_1, uint32_t config_param_2,
  760. uint32_t config_param_3, int cookie, int cookie_msb,
  761. uint8_t mac_id);
  762. void dp_htt_stats_print_tag(uint8_t tag_type, uint32_t *tag_buf);
  763. void dp_htt_stats_copy_tag(struct dp_pdev *pdev, uint8_t tag_type, uint32_t *tag_buf);
  764. void dp_peer_rxtid_stats(struct dp_peer *peer, void (*callback_fn),
  765. void *cb_ctxt);
  766. void dp_set_pn_check_wifi3(struct cdp_vdev *vdev_handle,
  767. struct cdp_peer *peer_handle, enum cdp_sec_type sec_type,
  768. uint32_t *rx_pn);
  769. void *dp_get_pdev_for_mac_id(struct dp_soc *soc, uint32_t mac_id);
  770. void dp_set_michael_key(struct cdp_peer *peer_handle,
  771. bool is_unicast, uint32_t *key);
  772. #ifdef CONFIG_WIN
  773. uint32_t dp_pdev_tid_stats_display(void *pdev_handle,
  774. enum _ol_ath_param_t param, uint32_t value, void *buff);
  775. #endif
  776. void dp_update_delay_stats(struct dp_pdev *pdev, uint32_t delay,
  777. uint8_t tid, uint8_t mode);
  778. /**
  779. * dp_print_ring_stats(): Print tail and head pointer
  780. * @pdev: DP_PDEV handle
  781. *
  782. * Return:void
  783. */
  784. void dp_print_ring_stats(struct dp_pdev *pdev);
  785. /**
  786. * dp_print_pdev_cfg_params() - Print the pdev cfg parameters
  787. * @pdev_handle: DP pdev handle
  788. *
  789. * Return - void
  790. */
  791. void dp_print_pdev_cfg_params(struct dp_pdev *pdev);
  792. /**
  793. * dp_print_soc_cfg_params()- Dump soc wlan config parameters
  794. * @soc_handle: Soc handle
  795. *
  796. * Return: void
  797. */
  798. void dp_print_soc_cfg_params(struct dp_soc *soc);
  799. /**
  800. * dp_srng_get_str_from_ring_type() - Return string name for a ring
  801. * @ring_type: Ring
  802. *
  803. * Return: char const pointer
  804. */
  805. const
  806. char *dp_srng_get_str_from_hal_ring_type(enum hal_ring_type ring_type);
  807. /*
  808. * dp_txrx_path_stats() - Function to display dump stats
  809. * @soc - soc handle
  810. *
  811. * return: none
  812. */
  813. void dp_txrx_path_stats(struct dp_soc *soc);
  814. /*
  815. * dp_print_per_ring_stats(): Packet count per ring
  816. * @soc - soc handle
  817. *
  818. * Return - None
  819. */
  820. void dp_print_per_ring_stats(struct dp_soc *soc);
  821. /**
  822. * dp_aggregate_pdev_stats(): Consolidate stats at PDEV level
  823. * @pdev: DP PDEV handle
  824. *
  825. * return: void
  826. */
  827. void dp_aggregate_pdev_stats(struct dp_pdev *pdev);
  828. /**
  829. * dp_print_rx_rates(): Print Rx rate stats
  830. * @vdev: DP_VDEV handle
  831. *
  832. * Return:void
  833. */
  834. void dp_print_rx_rates(struct dp_vdev *vdev);
  835. /**
  836. * dp_print_tx_rates(): Print tx rates
  837. * @vdev: DP_VDEV handle
  838. *
  839. * Return:void
  840. */
  841. void dp_print_tx_rates(struct dp_vdev *vdev);
  842. /**
  843. * dp_print_peer_stats():print peer stats
  844. * @peer: DP_PEER handle
  845. *
  846. * return void
  847. */
  848. void dp_print_peer_stats(struct dp_peer *peer);
  849. /**
  850. * dp_print_pdev_tx_stats(): Print Pdev level TX stats
  851. * @pdev: DP_PDEV Handle
  852. *
  853. * Return:void
  854. */
  855. void
  856. dp_print_pdev_tx_stats(struct dp_pdev *pdev);
  857. /**
  858. * dp_print_pdev_rx_stats(): Print Pdev level RX stats
  859. * @pdev: DP_PDEV Handle
  860. *
  861. * Return: void
  862. */
  863. void
  864. dp_print_pdev_rx_stats(struct dp_pdev *pdev);
  865. /**
  866. * dp_print_pdev_rx_mon_stats(): Print Pdev level RX monitor stats
  867. * @pdev: DP_PDEV Handle
  868. *
  869. * Return: void
  870. */
  871. void
  872. dp_print_pdev_rx_mon_stats(struct dp_pdev *pdev);
  873. /**
  874. * dp_print_soc_tx_stats(): Print SOC level stats
  875. * @soc DP_SOC Handle
  876. *
  877. * Return: void
  878. */
  879. void dp_print_soc_tx_stats(struct dp_soc *soc);
  880. /**
  881. * dp_print_soc_interrupt_stats() - Print interrupt stats for the soc
  882. * @soc: dp_soc handle
  883. *
  884. * Return: None
  885. */
  886. void dp_print_soc_interrupt_stats(struct dp_soc *soc);
  887. /**
  888. * dp_print_soc_rx_stats: Print SOC level Rx stats
  889. * @soc: DP_SOC Handle
  890. *
  891. * Return:void
  892. */
  893. void dp_print_soc_rx_stats(struct dp_soc *soc);
  894. /**
  895. * dp_get_mac_id_for_pdev() - Return mac corresponding to pdev for mac
  896. *
  897. * @mac_id: MAC id
  898. * @pdev_id: pdev_id corresponding to pdev, 0 for MCL
  899. *
  900. * Single pdev using both MACs will operate on both MAC rings,
  901. * which is the case for MCL.
  902. * For WIN each PDEV will operate one ring, so index is zero.
  903. *
  904. */
  905. static inline int dp_get_mac_id_for_pdev(uint32_t mac_id, uint32_t pdev_id)
  906. {
  907. if (mac_id && pdev_id) {
  908. qdf_print("Both mac_id and pdev_id cannot be non zero");
  909. QDF_BUG(0);
  910. return 0;
  911. }
  912. return (mac_id + pdev_id);
  913. }
  914. /*
  915. * dp_get_mac_id_for_mac() - Return mac corresponding WIN and MCL mac_ids
  916. *
  917. * @soc: handle to DP soc
  918. * @mac_id: MAC id
  919. *
  920. * Single pdev using both MACs will operate on both MAC rings,
  921. * which is the case for MCL.
  922. * For WIN each PDEV will operate one ring, so index is zero.
  923. *
  924. */
  925. static inline int dp_get_mac_id_for_mac(struct dp_soc *soc, uint32_t mac_id)
  926. {
  927. /*
  928. * Single pdev using both MACs will operate on both MAC rings,
  929. * which is the case for MCL.
  930. */
  931. if (!wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx))
  932. return mac_id;
  933. /* For WIN each PDEV will operate one ring, so index is zero. */
  934. return 0;
  935. }
  936. bool dp_is_soc_reinit(struct dp_soc *soc);
  937. /*
  938. * dp_is_subtype_data() - check if the frame subtype is data
  939. *
  940. * @frame_ctrl: Frame control field
  941. *
  942. * check the frame control field and verify if the packet
  943. * is a data packet.
  944. *
  945. * Return: true or false
  946. */
  947. static inline bool dp_is_subtype_data(uint16_t frame_ctrl)
  948. {
  949. if (((qdf_cpu_to_le16(frame_ctrl) & QDF_IEEE80211_FC0_TYPE_MASK) ==
  950. QDF_IEEE80211_FC0_TYPE_DATA) &&
  951. (((qdf_cpu_to_le16(frame_ctrl) & QDF_IEEE80211_FC0_SUBTYPE_MASK) ==
  952. QDF_IEEE80211_FC0_SUBTYPE_DATA) ||
  953. ((qdf_cpu_to_le16(frame_ctrl) & QDF_IEEE80211_FC0_SUBTYPE_MASK) ==
  954. QDF_IEEE80211_FC0_SUBTYPE_QOS))) {
  955. return true;
  956. }
  957. return false;
  958. }
  959. #ifdef WDI_EVENT_ENABLE
  960. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  961. uint32_t stats_type_upload_mask,
  962. uint8_t mac_id);
  963. int dp_wdi_event_unsub(struct cdp_pdev *txrx_pdev_handle,
  964. void *event_cb_sub_handle,
  965. uint32_t event);
  966. int dp_wdi_event_sub(struct cdp_pdev *txrx_pdev_handle,
  967. void *event_cb_sub_handle,
  968. uint32_t event);
  969. void dp_wdi_event_handler(enum WDI_EVENT event, void *soc,
  970. void *data, u_int16_t peer_id,
  971. int status, u_int8_t pdev_id);
  972. int dp_wdi_event_attach(struct dp_pdev *txrx_pdev);
  973. int dp_wdi_event_detach(struct dp_pdev *txrx_pdev);
  974. int dp_set_pktlog_wifi3(struct dp_pdev *pdev, uint32_t event,
  975. bool enable);
  976. void *dp_get_pldev(struct cdp_pdev *txrx_pdev);
  977. void dp_pkt_log_init(struct cdp_pdev *ppdev, void *scn);
  978. static inline void dp_hif_update_pipe_callback(void *soc, void *cb_context,
  979. QDF_STATUS (*callback)(void *, qdf_nbuf_t, uint8_t), uint8_t pipe_id)
  980. {
  981. struct hif_msg_callbacks hif_pipe_callbacks;
  982. struct dp_soc *dp_soc = (struct dp_soc *)soc;
  983. /* TODO: Temporary change to bypass HTC connection for this new
  984. * HIF pipe, which will be used for packet log and other high-
  985. * priority HTT messages. Proper HTC connection to be added
  986. * later once required FW changes are available
  987. */
  988. hif_pipe_callbacks.rxCompletionHandler = callback;
  989. hif_pipe_callbacks.Context = cb_context;
  990. hif_update_pipe_callback(dp_soc->hif_handle,
  991. DP_HTT_T2H_HP_PIPE, &hif_pipe_callbacks);
  992. }
  993. QDF_STATUS dp_peer_stats_notify(struct dp_peer *peer);
  994. #else
  995. static inline int dp_wdi_event_unsub(struct cdp_pdev *txrx_pdev_handle,
  996. void *event_cb_sub_handle,
  997. uint32_t event)
  998. {
  999. return 0;
  1000. }
  1001. static inline int dp_wdi_event_sub(struct cdp_pdev *txrx_pdev_handle,
  1002. void *event_cb_sub_handle,
  1003. uint32_t event)
  1004. {
  1005. return 0;
  1006. }
  1007. static inline void dp_wdi_event_handler(enum WDI_EVENT event, void *soc,
  1008. void *data, u_int16_t peer_id,
  1009. int status, u_int8_t pdev_id)
  1010. {
  1011. }
  1012. static inline int dp_wdi_event_attach(struct dp_pdev *txrx_pdev)
  1013. {
  1014. return 0;
  1015. }
  1016. static inline int dp_wdi_event_detach(struct dp_pdev *txrx_pdev)
  1017. {
  1018. return 0;
  1019. }
  1020. static inline int dp_set_pktlog_wifi3(struct dp_pdev *pdev, uint32_t event,
  1021. bool enable)
  1022. {
  1023. return 0;
  1024. }
  1025. static inline QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  1026. uint32_t stats_type_upload_mask, uint8_t mac_id)
  1027. {
  1028. return 0;
  1029. }
  1030. static inline void dp_hif_update_pipe_callback(void *soc, void *cb_context,
  1031. QDF_STATUS (*callback)(void *, qdf_nbuf_t, uint8_t), uint8_t pipe_id)
  1032. {
  1033. }
  1034. static inline QDF_STATUS dp_peer_stats_notify(struct dp_peer *peer)
  1035. {
  1036. return QDF_STATUS_SUCCESS;
  1037. }
  1038. #endif /* CONFIG_WIN */
  1039. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  1040. void dp_tx_dump_flow_pool_info(void *soc);
  1041. int dp_tx_delete_flow_pool(struct dp_soc *soc, struct dp_tx_desc_pool_s *pool,
  1042. bool force);
  1043. #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */
  1044. #ifdef PEER_PROTECTED_ACCESS
  1045. /**
  1046. * dp_peer_unref_del_find_by_id() - dec ref and del peer if ref count is
  1047. * taken by dp_peer_find_by_id
  1048. * @peer: peer context
  1049. *
  1050. * Return: none
  1051. */
  1052. static inline void dp_peer_unref_del_find_by_id(struct dp_peer *peer)
  1053. {
  1054. dp_peer_unref_delete(peer);
  1055. }
  1056. #else
  1057. static inline void dp_peer_unref_del_find_by_id(struct dp_peer *peer)
  1058. {
  1059. }
  1060. #endif
  1061. #ifdef CONFIG_WIN
  1062. /**
  1063. * dp_pdev_print_delay_stats(): Print pdev level delay stats
  1064. * @pdev: DP_PDEV handle
  1065. *
  1066. * Return:void
  1067. */
  1068. void dp_pdev_print_delay_stats(struct dp_pdev *pdev);
  1069. /**
  1070. * dp_pdev_print_tid_stats(): Print pdev level tid stats
  1071. * @pdev: DP_PDEV handle
  1072. *
  1073. * Return:void
  1074. */
  1075. void dp_pdev_print_tid_stats(struct dp_pdev *pdev);
  1076. #endif /* CONFIG_WIN */
  1077. void dp_soc_set_txrx_ring_map(struct dp_soc *soc);
  1078. #ifndef WLAN_TX_PKT_CAPTURE_ENH
  1079. /**
  1080. * dp_tx_ppdu_stats_attach - Initialize Tx PPDU stats and enhanced capture
  1081. * @pdev: DP PDEV
  1082. *
  1083. * Return: none
  1084. */
  1085. static inline void dp_tx_ppdu_stats_attach(struct dp_pdev *pdev)
  1086. {
  1087. }
  1088. /**
  1089. * dp_tx_ppdu_stats_detach - Cleanup Tx PPDU stats and enhanced capture
  1090. * @pdev: DP PDEV
  1091. *
  1092. * Return: none
  1093. */
  1094. static inline void dp_tx_ppdu_stats_detach(struct dp_pdev *pdev)
  1095. {
  1096. }
  1097. /**
  1098. * dp_tx_ppdu_stats_process - Deferred PPDU stats handler
  1099. * @context: Opaque work context (PDEV)
  1100. *
  1101. * Return: none
  1102. */
  1103. static inline void dp_tx_ppdu_stats_process(void *context)
  1104. {
  1105. }
  1106. /**
  1107. * dp_tx_add_to_comp_queue() - add completion msdu to queue
  1108. * @soc: DP Soc handle
  1109. * @tx_desc: software Tx descriptor
  1110. * @ts : Tx completion status from HAL/HTT descriptor
  1111. * @peer: DP peer
  1112. *
  1113. * Return: none
  1114. */
  1115. static inline
  1116. QDF_STATUS dp_tx_add_to_comp_queue(struct dp_soc *soc,
  1117. struct dp_tx_desc_s *desc,
  1118. struct hal_tx_completion_status *ts,
  1119. struct dp_peer *peer)
  1120. {
  1121. return QDF_STATUS_E_FAILURE;
  1122. }
  1123. #endif
  1124. #endif /* #ifndef _DP_INTERNAL_H_ */