1 /* 2 * Copyright (c) 2016-2018 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 19 #ifndef _DP_INTERNAL_H_ 20 #define _DP_INTERNAL_H_ 21 22 #include "dp_types.h" 23 24 #define RX_BUFFER_SIZE_PKTLOG_LITE 1024 25 26 /* Macro For NYSM value received in VHT TLV */ 27 #define VHT_SGI_NYSM 3 28 29 #if DP_PRINT_ENABLE 30 #include <stdarg.h> /* va_list */ 31 #include <qdf_types.h> /* qdf_vprint */ 32 #include <cdp_txrx_handle.h> 33 34 enum { 35 /* FATAL_ERR - print only irrecoverable error messages */ 36 DP_PRINT_LEVEL_FATAL_ERR, 37 38 /* ERR - include non-fatal err messages */ 39 DP_PRINT_LEVEL_ERR, 40 41 /* WARN - include warnings */ 42 DP_PRINT_LEVEL_WARN, 43 44 /* INFO1 - include fundamental, infrequent events */ 45 DP_PRINT_LEVEL_INFO1, 46 47 /* INFO2 - include non-fundamental but infrequent events */ 48 DP_PRINT_LEVEL_INFO2, 49 }; 50 51 52 #define dp_print(level, fmt, ...) do { \ 53 if (level <= g_txrx_print_level) \ 54 qdf_print(fmt, ## __VA_ARGS__); \ 55 while (0) 56 #define DP_PRINT(level, fmt, ...) do { \ 57 dp_print(level, "DP: " fmt, ## __VA_ARGS__); \ 58 while (0) 59 #else 60 #define DP_PRINT(level, fmt, ...) 61 #endif /* DP_PRINT_ENABLE */ 62 63 #define DP_TRACE(LVL, fmt, args ...) \ 64 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_##LVL, \ 65 fmt, ## args) 66 67 #define DP_TRACE_STATS(LVL, fmt, args ...) \ 68 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_##LVL, \ 69 fmt, ## args) 70 71 #define DP_PRINT_STATS(fmt, args ...) \ 72 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, \ 73 fmt, ## args) 74 75 #define DP_STATS_INIT(_handle) \ 76 qdf_mem_set(&((_handle)->stats), sizeof((_handle)->stats), 0x0) 77 78 #define DP_STATS_CLR(_handle) \ 79 qdf_mem_set(&((_handle)->stats), sizeof((_handle)->stats), 0x0) 80 81 #ifndef DISABLE_DP_STATS 82 #define DP_STATS_INC(_handle, _field, _delta) \ 83 { \ 84 if (likely(_handle)) \ 85 _handle->stats._field += _delta; \ 86 } 87 88 #define DP_STATS_INCC(_handle, _field, _delta, _cond) \ 89 { \ 90 if (_cond && likely(_handle)) \ 91 _handle->stats._field += _delta; \ 92 } 93 94 #define DP_STATS_DEC(_handle, _field, _delta) \ 95 { \ 96 if (likely(_handle)) \ 97 _handle->stats._field -= _delta; \ 98 } 99 100 #define DP_STATS_UPD(_handle, _field, _delta) \ 101 { \ 102 if (likely(_handle)) \ 103 _handle->stats._field = _delta; \ 104 } 105 106 #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes) \ 107 { \ 108 DP_STATS_INC(_handle, _field.num, _count); \ 109 DP_STATS_INC(_handle, _field.bytes, _bytes) \ 110 } 111 112 #define DP_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond) \ 113 { \ 114 DP_STATS_INCC(_handle, _field.num, _count, _cond); \ 115 DP_STATS_INCC(_handle, _field.bytes, _bytes, _cond) \ 116 } 117 118 #define DP_STATS_AGGR(_handle_a, _handle_b, _field) \ 119 { \ 120 _handle_a->stats._field += _handle_b->stats._field; \ 121 } 122 123 #define DP_STATS_AGGR_PKT(_handle_a, _handle_b, _field) \ 124 { \ 125 DP_STATS_AGGR(_handle_a, _handle_b, _field.num); \ 126 DP_STATS_AGGR(_handle_a, _handle_b, _field.bytes);\ 127 } 128 129 #define DP_STATS_UPD_STRUCT(_handle_a, _handle_b, _field) \ 130 { \ 131 _handle_a->stats._field = _handle_b->stats._field; \ 132 } 133 134 #define DP_HIST_INIT() \ 135 uint32_t num_of_packets[MAX_PDEV_CNT] = {0}; 136 137 #define DP_HIST_PACKET_COUNT_INC(_pdev_id) \ 138 { \ 139 ++num_of_packets[_pdev_id]; \ 140 } 141 142 #define DP_TX_HISTOGRAM_UPDATE(_pdev, _p_cntrs) \ 143 do { \ 144 if (_p_cntrs == 1) { \ 145 DP_STATS_INC(_pdev, \ 146 tx_comp_histogram.pkts_1, 1); \ 147 } else if (_p_cntrs > 1 && _p_cntrs <= 20) { \ 148 DP_STATS_INC(_pdev, \ 149 tx_comp_histogram.pkts_2_20, 1); \ 150 } else if (_p_cntrs > 20 && _p_cntrs <= 40) { \ 151 DP_STATS_INC(_pdev, \ 152 tx_comp_histogram.pkts_21_40, 1); \ 153 } else if (_p_cntrs > 40 && _p_cntrs <= 60) { \ 154 DP_STATS_INC(_pdev, \ 155 tx_comp_histogram.pkts_41_60, 1); \ 156 } else if (_p_cntrs > 60 && _p_cntrs <= 80) { \ 157 DP_STATS_INC(_pdev, \ 158 tx_comp_histogram.pkts_61_80, 1); \ 159 } else if (_p_cntrs > 80 && _p_cntrs <= 100) { \ 160 DP_STATS_INC(_pdev, \ 161 tx_comp_histogram.pkts_81_100, 1); \ 162 } else if (_p_cntrs > 100 && _p_cntrs <= 200) { \ 163 DP_STATS_INC(_pdev, \ 164 tx_comp_histogram.pkts_101_200, 1); \ 165 } else if (_p_cntrs > 200) { \ 166 DP_STATS_INC(_pdev, \ 167 tx_comp_histogram.pkts_201_plus, 1); \ 168 } \ 169 } while (0) 170 171 #define DP_RX_HISTOGRAM_UPDATE(_pdev, _p_cntrs) \ 172 do { \ 173 if (_p_cntrs == 1) { \ 174 DP_STATS_INC(_pdev, \ 175 rx_ind_histogram.pkts_1, 1); \ 176 } else if (_p_cntrs > 1 && _p_cntrs <= 20) { \ 177 DP_STATS_INC(_pdev, \ 178 rx_ind_histogram.pkts_2_20, 1); \ 179 } else if (_p_cntrs > 20 && _p_cntrs <= 40) { \ 180 DP_STATS_INC(_pdev, \ 181 rx_ind_histogram.pkts_21_40, 1); \ 182 } else if (_p_cntrs > 40 && _p_cntrs <= 60) { \ 183 DP_STATS_INC(_pdev, \ 184 rx_ind_histogram.pkts_41_60, 1); \ 185 } else if (_p_cntrs > 60 && _p_cntrs <= 80) { \ 186 DP_STATS_INC(_pdev, \ 187 rx_ind_histogram.pkts_61_80, 1); \ 188 } else if (_p_cntrs > 80 && _p_cntrs <= 100) { \ 189 DP_STATS_INC(_pdev, \ 190 rx_ind_histogram.pkts_81_100, 1); \ 191 } else if (_p_cntrs > 100 && _p_cntrs <= 200) { \ 192 DP_STATS_INC(_pdev, \ 193 rx_ind_histogram.pkts_101_200, 1); \ 194 } else if (_p_cntrs > 200) { \ 195 DP_STATS_INC(_pdev, \ 196 rx_ind_histogram.pkts_201_plus, 1); \ 197 } \ 198 } while (0) 199 200 #define DP_TX_HIST_STATS_PER_PDEV() \ 201 do { \ 202 uint8_t hist_stats = 0; \ 203 for (hist_stats = 0; hist_stats < soc->pdev_count; \ 204 hist_stats++) { \ 205 DP_TX_HISTOGRAM_UPDATE(soc->pdev_list[hist_stats], \ 206 num_of_packets[hist_stats]); \ 207 } \ 208 } while (0) 209 210 211 #define DP_RX_HIST_STATS_PER_PDEV() \ 212 do { \ 213 uint8_t hist_stats = 0; \ 214 for (hist_stats = 0; hist_stats < soc->pdev_count; \ 215 hist_stats++) { \ 216 DP_RX_HISTOGRAM_UPDATE(soc->pdev_list[hist_stats], \ 217 num_of_packets[hist_stats]); \ 218 } \ 219 } while (0) 220 221 222 #else 223 #define DP_STATS_INC(_handle, _field, _delta) 224 #define DP_STATS_INCC(_handle, _field, _delta, _cond) 225 #define DP_STATS_DEC(_handle, _field, _delta) 226 #define DP_STATS_UPD(_handle, _field, _delta) 227 #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes) 228 #define DP_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond) 229 #define DP_STATS_AGGR(_handle_a, _handle_b, _field) 230 #define DP_STATS_AGGR_PKT(_handle_a, _handle_b, _field) 231 #define DP_HIST_INIT() 232 #define DP_HIST_PACKET_COUNT_INC(_pdev_id) 233 #define DP_TX_HISTOGRAM_UPDATE(_pdev, _p_cntrs) 234 #define DP_RX_HISTOGRAM_UPDATE(_pdev, _p_cntrs) 235 #define DP_RX_HIST_STATS_PER_PDEV() 236 #define DP_TX_HIST_STATS_PER_PDEV() 237 #endif 238 239 #define DP_HTT_T2H_HP_PIPE 5 240 static inline void dp_update_pdev_stats(struct dp_pdev *tgtobj, 241 struct cdp_vdev_stats *srcobj) 242 { 243 uint8_t i; 244 uint8_t pream_type; 245 246 for (pream_type = 0; pream_type < DOT11_MAX; pream_type++) { 247 for (i = 0; i < MAX_MCS; i++) { 248 tgtobj->stats.tx.pkt_type[pream_type]. 249 mcs_count[i] += 250 srcobj->tx.pkt_type[pream_type]. 251 mcs_count[i]; 252 tgtobj->stats.rx.pkt_type[pream_type]. 253 mcs_count[i] += 254 srcobj->rx.pkt_type[pream_type]. 255 mcs_count[i]; 256 } 257 } 258 259 for (i = 0; i < MAX_BW; i++) { 260 tgtobj->stats.tx.bw[i] += srcobj->tx.bw[i]; 261 tgtobj->stats.rx.bw[i] += srcobj->rx.bw[i]; 262 } 263 264 for (i = 0; i < SS_COUNT; i++) { 265 tgtobj->stats.tx.nss[i] += srcobj->tx.nss[i]; 266 tgtobj->stats.rx.nss[i] += srcobj->rx.nss[i]; 267 } 268 269 for (i = 0; i < WME_AC_MAX; i++) { 270 tgtobj->stats.tx.wme_ac_type[i] += 271 srcobj->tx.wme_ac_type[i]; 272 tgtobj->stats.rx.wme_ac_type[i] += 273 srcobj->rx.wme_ac_type[i]; 274 tgtobj->stats.tx.excess_retries_per_ac[i] += 275 srcobj->tx.excess_retries_per_ac[i]; 276 } 277 278 for (i = 0; i < MAX_GI; i++) { 279 tgtobj->stats.tx.sgi_count[i] += 280 srcobj->tx.sgi_count[i]; 281 tgtobj->stats.rx.sgi_count[i] += 282 srcobj->rx.sgi_count[i]; 283 } 284 285 for (i = 0; i < MAX_RECEPTION_TYPES; i++) 286 tgtobj->stats.rx.reception_type[i] += 287 srcobj->rx.reception_type[i]; 288 289 tgtobj->stats.tx.comp_pkt.bytes += srcobj->tx.comp_pkt.bytes; 290 tgtobj->stats.tx.comp_pkt.num += srcobj->tx.comp_pkt.num; 291 tgtobj->stats.tx.ucast.num += srcobj->tx.ucast.num; 292 tgtobj->stats.tx.ucast.bytes += srcobj->tx.ucast.bytes; 293 tgtobj->stats.tx.mcast.num += srcobj->tx.mcast.num; 294 tgtobj->stats.tx.mcast.bytes += srcobj->tx.mcast.bytes; 295 tgtobj->stats.tx.bcast.num += srcobj->tx.bcast.num; 296 tgtobj->stats.tx.bcast.bytes += srcobj->tx.bcast.bytes; 297 tgtobj->stats.tx.tx_success.num += srcobj->tx.tx_success.num; 298 tgtobj->stats.tx.tx_success.bytes += 299 srcobj->tx.tx_success.bytes; 300 tgtobj->stats.tx.nawds_mcast.num += 301 srcobj->tx.nawds_mcast.num; 302 tgtobj->stats.tx.nawds_mcast.bytes += 303 srcobj->tx.nawds_mcast.bytes; 304 tgtobj->stats.tx.tx_failed += srcobj->tx.tx_failed; 305 tgtobj->stats.tx.ofdma += srcobj->tx.ofdma; 306 tgtobj->stats.tx.stbc += srcobj->tx.stbc; 307 tgtobj->stats.tx.ldpc += srcobj->tx.ldpc; 308 tgtobj->stats.tx.retries += srcobj->tx.retries; 309 tgtobj->stats.tx.non_amsdu_cnt += srcobj->tx.non_amsdu_cnt; 310 tgtobj->stats.tx.amsdu_cnt += srcobj->tx.amsdu_cnt; 311 tgtobj->stats.tx.dropped.fw_rem += srcobj->tx.dropped.fw_rem; 312 tgtobj->stats.tx.dropped.fw_rem_tx += 313 srcobj->tx.dropped.fw_rem_tx; 314 tgtobj->stats.tx.dropped.fw_rem_notx += 315 srcobj->tx.dropped.fw_rem_notx; 316 tgtobj->stats.tx.dropped.fw_reason1 += 317 srcobj->tx.dropped.fw_reason1; 318 tgtobj->stats.tx.dropped.fw_reason2 += 319 srcobj->tx.dropped.fw_reason2; 320 tgtobj->stats.tx.dropped.fw_reason3 += 321 srcobj->tx.dropped.fw_reason3; 322 tgtobj->stats.tx.dropped.age_out += srcobj->tx.dropped.age_out; 323 tgtobj->stats.rx.err.mic_err += srcobj->rx.err.mic_err; 324 tgtobj->stats.rx.rssi = srcobj->rx.rssi; 325 tgtobj->stats.rx.rx_rate = srcobj->rx.rx_rate; 326 tgtobj->stats.rx.err.decrypt_err += srcobj->rx.err.decrypt_err; 327 tgtobj->stats.rx.non_ampdu_cnt += srcobj->rx.non_ampdu_cnt; 328 tgtobj->stats.rx.amsdu_cnt += srcobj->rx.ampdu_cnt; 329 tgtobj->stats.rx.non_amsdu_cnt += srcobj->rx.non_amsdu_cnt; 330 tgtobj->stats.rx.amsdu_cnt += srcobj->rx.amsdu_cnt; 331 tgtobj->stats.rx.to_stack.num += srcobj->rx.to_stack.num; 332 tgtobj->stats.rx.to_stack.bytes += srcobj->rx.to_stack.bytes; 333 334 for (i = 0; i < CDP_MAX_RX_RINGS; i++) { 335 tgtobj->stats.rx.rcvd_reo[i].num += 336 srcobj->rx.rcvd_reo[i].num; 337 tgtobj->stats.rx.rcvd_reo[i].bytes += 338 srcobj->rx.rcvd_reo[i].bytes; 339 } 340 341 srcobj->rx.unicast.num = 342 srcobj->rx.to_stack.num - 343 (srcobj->rx.multicast.num); 344 srcobj->rx.unicast.bytes = 345 srcobj->rx.to_stack.bytes - 346 (srcobj->rx.multicast.bytes); 347 348 tgtobj->stats.rx.unicast.num += srcobj->rx.unicast.num; 349 tgtobj->stats.rx.unicast.bytes += srcobj->rx.unicast.bytes; 350 tgtobj->stats.rx.multicast.num += srcobj->rx.multicast.num; 351 tgtobj->stats.rx.multicast.bytes += srcobj->rx.multicast.bytes; 352 tgtobj->stats.rx.bcast.num += srcobj->rx.bcast.num; 353 tgtobj->stats.rx.bcast.bytes += srcobj->rx.bcast.bytes; 354 tgtobj->stats.rx.raw.num += srcobj->rx.raw.num; 355 tgtobj->stats.rx.raw.bytes += srcobj->rx.raw.bytes; 356 tgtobj->stats.rx.intra_bss.pkts.num += 357 srcobj->rx.intra_bss.pkts.num; 358 tgtobj->stats.rx.intra_bss.pkts.bytes += 359 srcobj->rx.intra_bss.pkts.bytes; 360 tgtobj->stats.rx.intra_bss.fail.num += 361 srcobj->rx.intra_bss.fail.num; 362 tgtobj->stats.rx.intra_bss.fail.bytes += 363 srcobj->rx.intra_bss.fail.bytes; 364 365 tgtobj->stats.tx.last_ack_rssi = 366 srcobj->tx.last_ack_rssi; 367 tgtobj->stats.rx.mec_drop.num += srcobj->rx.mec_drop.num; 368 tgtobj->stats.rx.mec_drop.bytes += srcobj->rx.mec_drop.bytes; 369 } 370 371 static inline void dp_update_vdev_stats(struct cdp_vdev_stats *tgtobj, 372 struct dp_peer *srcobj) 373 { 374 uint8_t i; 375 uint8_t pream_type; 376 377 for (pream_type = 0; pream_type < DOT11_MAX; pream_type++) { 378 for (i = 0; i < MAX_MCS; i++) { 379 tgtobj->tx.pkt_type[pream_type]. 380 mcs_count[i] += 381 srcobj->stats.tx.pkt_type[pream_type]. 382 mcs_count[i]; 383 tgtobj->rx.pkt_type[pream_type]. 384 mcs_count[i] += 385 srcobj->stats.rx.pkt_type[pream_type]. 386 mcs_count[i]; 387 } 388 } 389 390 for (i = 0; i < MAX_BW; i++) { 391 tgtobj->tx.bw[i] += srcobj->stats.tx.bw[i]; 392 tgtobj->rx.bw[i] += srcobj->stats.rx.bw[i]; 393 } 394 395 for (i = 0; i < SS_COUNT; i++) { 396 tgtobj->tx.nss[i] += srcobj->stats.tx.nss[i]; 397 tgtobj->rx.nss[i] += srcobj->stats.rx.nss[i]; 398 } 399 400 for (i = 0; i < WME_AC_MAX; i++) { 401 tgtobj->tx.wme_ac_type[i] += 402 srcobj->stats.tx.wme_ac_type[i]; 403 tgtobj->rx.wme_ac_type[i] += 404 srcobj->stats.rx.wme_ac_type[i]; 405 tgtobj->tx.excess_retries_per_ac[i] += 406 srcobj->stats.tx.excess_retries_per_ac[i]; 407 } 408 409 for (i = 0; i < MAX_GI; i++) { 410 tgtobj->tx.sgi_count[i] += 411 srcobj->stats.tx.sgi_count[i]; 412 tgtobj->rx.sgi_count[i] += 413 srcobj->stats.rx.sgi_count[i]; 414 } 415 416 for (i = 0; i < MAX_RECEPTION_TYPES; i++) 417 tgtobj->rx.reception_type[i] += 418 srcobj->stats.rx.reception_type[i]; 419 420 tgtobj->tx.comp_pkt.bytes += srcobj->stats.tx.comp_pkt.bytes; 421 tgtobj->tx.comp_pkt.num += srcobj->stats.tx.comp_pkt.num; 422 tgtobj->tx.ucast.num += srcobj->stats.tx.ucast.num; 423 tgtobj->tx.ucast.bytes += srcobj->stats.tx.ucast.bytes; 424 tgtobj->tx.mcast.num += srcobj->stats.tx.mcast.num; 425 tgtobj->tx.mcast.bytes += srcobj->stats.tx.mcast.bytes; 426 tgtobj->tx.bcast.num += srcobj->stats.tx.bcast.num; 427 tgtobj->tx.bcast.bytes += srcobj->stats.tx.bcast.bytes; 428 tgtobj->tx.tx_success.num += srcobj->stats.tx.tx_success.num; 429 tgtobj->tx.tx_success.bytes += 430 srcobj->stats.tx.tx_success.bytes; 431 tgtobj->tx.nawds_mcast.num += 432 srcobj->stats.tx.nawds_mcast.num; 433 tgtobj->tx.nawds_mcast.bytes += 434 srcobj->stats.tx.nawds_mcast.bytes; 435 tgtobj->tx.tx_failed += srcobj->stats.tx.tx_failed; 436 tgtobj->tx.ofdma += srcobj->stats.tx.ofdma; 437 tgtobj->tx.stbc += srcobj->stats.tx.stbc; 438 tgtobj->tx.ldpc += srcobj->stats.tx.ldpc; 439 tgtobj->tx.retries += srcobj->stats.tx.retries; 440 tgtobj->tx.non_amsdu_cnt += srcobj->stats.tx.non_amsdu_cnt; 441 tgtobj->tx.amsdu_cnt += srcobj->stats.tx.amsdu_cnt; 442 tgtobj->tx.dropped.fw_rem += srcobj->stats.tx.dropped.fw_rem; 443 tgtobj->tx.dropped.fw_rem_tx += 444 srcobj->stats.tx.dropped.fw_rem_tx; 445 tgtobj->tx.dropped.fw_rem_notx += 446 srcobj->stats.tx.dropped.fw_rem_notx; 447 tgtobj->tx.dropped.fw_reason1 += 448 srcobj->stats.tx.dropped.fw_reason1; 449 tgtobj->tx.dropped.fw_reason2 += 450 srcobj->stats.tx.dropped.fw_reason2; 451 tgtobj->tx.dropped.fw_reason3 += 452 srcobj->stats.tx.dropped.fw_reason3; 453 tgtobj->tx.dropped.age_out += srcobj->stats.tx.dropped.age_out; 454 tgtobj->rx.err.mic_err += srcobj->stats.rx.err.mic_err; 455 tgtobj->rx.rssi = srcobj->stats.rx.rssi; 456 tgtobj->rx.rx_rate = srcobj->stats.rx.rx_rate; 457 tgtobj->rx.err.decrypt_err += srcobj->stats.rx.err.decrypt_err; 458 tgtobj->rx.non_ampdu_cnt += srcobj->stats.rx.non_ampdu_cnt; 459 tgtobj->rx.amsdu_cnt += srcobj->stats.rx.ampdu_cnt; 460 tgtobj->rx.non_amsdu_cnt += srcobj->stats.rx.non_amsdu_cnt; 461 tgtobj->rx.amsdu_cnt += srcobj->stats.rx.amsdu_cnt; 462 tgtobj->rx.to_stack.num += srcobj->stats.rx.to_stack.num; 463 tgtobj->rx.to_stack.bytes += srcobj->stats.rx.to_stack.bytes; 464 465 for (i = 0; i < CDP_MAX_RX_RINGS; i++) { 466 tgtobj->rx.rcvd_reo[i].num += 467 srcobj->stats.rx.rcvd_reo[i].num; 468 tgtobj->rx.rcvd_reo[i].bytes += 469 srcobj->stats.rx.rcvd_reo[i].bytes; 470 } 471 472 srcobj->stats.rx.unicast.num = 473 srcobj->stats.rx.to_stack.num - 474 srcobj->stats.rx.multicast.num; 475 srcobj->stats.rx.unicast.bytes = 476 srcobj->stats.rx.to_stack.bytes - 477 srcobj->stats.rx.multicast.bytes; 478 479 tgtobj->rx.unicast.num += srcobj->stats.rx.unicast.num; 480 tgtobj->rx.unicast.bytes += srcobj->stats.rx.unicast.bytes; 481 tgtobj->rx.multicast.num += srcobj->stats.rx.multicast.num; 482 tgtobj->rx.multicast.bytes += srcobj->stats.rx.multicast.bytes; 483 tgtobj->rx.bcast.num += srcobj->stats.rx.bcast.num; 484 tgtobj->rx.bcast.bytes += srcobj->stats.rx.bcast.bytes; 485 tgtobj->rx.raw.num += srcobj->stats.rx.raw.num; 486 tgtobj->rx.raw.bytes += srcobj->stats.rx.raw.bytes; 487 tgtobj->rx.intra_bss.pkts.num += 488 srcobj->stats.rx.intra_bss.pkts.num; 489 tgtobj->rx.intra_bss.pkts.bytes += 490 srcobj->stats.rx.intra_bss.pkts.bytes; 491 tgtobj->rx.intra_bss.fail.num += 492 srcobj->stats.rx.intra_bss.fail.num; 493 tgtobj->rx.intra_bss.fail.bytes += 494 srcobj->stats.rx.intra_bss.fail.bytes; 495 tgtobj->tx.last_ack_rssi = 496 srcobj->stats.tx.last_ack_rssi; 497 tgtobj->rx.mec_drop.num += srcobj->stats.rx.mec_drop.num; 498 tgtobj->rx.mec_drop.bytes += srcobj->stats.rx.mec_drop.bytes; 499 } 500 501 #define DP_UPDATE_STATS(_tgtobj, _srcobj) \ 502 do { \ 503 uint8_t i; \ 504 uint8_t pream_type; \ 505 for (pream_type = 0; pream_type < DOT11_MAX; pream_type++) { \ 506 for (i = 0; i < MAX_MCS; i++) { \ 507 DP_STATS_AGGR(_tgtobj, _srcobj, \ 508 tx.pkt_type[pream_type].mcs_count[i]); \ 509 DP_STATS_AGGR(_tgtobj, _srcobj, \ 510 rx.pkt_type[pream_type].mcs_count[i]); \ 511 } \ 512 } \ 513 \ 514 for (i = 0; i < MAX_BW; i++) { \ 515 DP_STATS_AGGR(_tgtobj, _srcobj, tx.bw[i]); \ 516 DP_STATS_AGGR(_tgtobj, _srcobj, rx.bw[i]); \ 517 } \ 518 \ 519 for (i = 0; i < SS_COUNT; i++) { \ 520 DP_STATS_AGGR(_tgtobj, _srcobj, rx.nss[i]); \ 521 DP_STATS_AGGR(_tgtobj, _srcobj, tx.nss[i]); \ 522 } \ 523 for (i = 0; i < WME_AC_MAX; i++) { \ 524 DP_STATS_AGGR(_tgtobj, _srcobj, tx.wme_ac_type[i]); \ 525 DP_STATS_AGGR(_tgtobj, _srcobj, rx.wme_ac_type[i]); \ 526 DP_STATS_AGGR(_tgtobj, _srcobj, tx.excess_retries_per_ac[i]); \ 527 \ 528 } \ 529 \ 530 for (i = 0; i < MAX_GI; i++) { \ 531 DP_STATS_AGGR(_tgtobj, _srcobj, tx.sgi_count[i]); \ 532 DP_STATS_AGGR(_tgtobj, _srcobj, rx.sgi_count[i]); \ 533 } \ 534 \ 535 for (i = 0; i < MAX_RECEPTION_TYPES; i++) \ 536 DP_STATS_AGGR(_tgtobj, _srcobj, rx.reception_type[i]); \ 537 \ 538 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.comp_pkt); \ 539 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.ucast); \ 540 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.mcast); \ 541 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.bcast); \ 542 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.tx_success); \ 543 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.nawds_mcast); \ 544 DP_STATS_AGGR(_tgtobj, _srcobj, tx.nawds_mcast_drop); \ 545 DP_STATS_AGGR(_tgtobj, _srcobj, tx.tx_failed); \ 546 DP_STATS_AGGR(_tgtobj, _srcobj, tx.ofdma); \ 547 DP_STATS_AGGR(_tgtobj, _srcobj, tx.stbc); \ 548 DP_STATS_AGGR(_tgtobj, _srcobj, tx.ldpc); \ 549 DP_STATS_AGGR(_tgtobj, _srcobj, tx.retries); \ 550 DP_STATS_AGGR(_tgtobj, _srcobj, tx.non_amsdu_cnt); \ 551 DP_STATS_AGGR(_tgtobj, _srcobj, tx.amsdu_cnt); \ 552 DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_rem); \ 553 DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_rem_tx); \ 554 DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_rem_notx); \ 555 DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason1); \ 556 DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason2); \ 557 DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason3); \ 558 DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.age_out); \ 559 \ 560 DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.mic_err); \ 561 DP_STATS_UPD_STRUCT(_tgtobj, _srcobj, rx.rssi); \ 562 DP_STATS_UPD_STRUCT(_tgtobj, _srcobj, rx.rx_rate); \ 563 DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.decrypt_err); \ 564 DP_STATS_AGGR(_tgtobj, _srcobj, rx.non_ampdu_cnt); \ 565 DP_STATS_AGGR(_tgtobj, _srcobj, rx.ampdu_cnt); \ 566 DP_STATS_AGGR(_tgtobj, _srcobj, rx.non_amsdu_cnt); \ 567 DP_STATS_AGGR(_tgtobj, _srcobj, rx.amsdu_cnt); \ 568 DP_STATS_AGGR(_tgtobj, _srcobj, rx.nawds_mcast_drop); \ 569 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.to_stack); \ 570 \ 571 for (i = 0; i < CDP_MAX_RX_RINGS; i++) \ 572 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.rcvd_reo[i]); \ 573 \ 574 _srcobj->stats.rx.unicast.num = \ 575 _srcobj->stats.rx.to_stack.num - \ 576 _srcobj->stats.rx.multicast.num; \ 577 _srcobj->stats.rx.unicast.bytes = \ 578 _srcobj->stats.rx.to_stack.bytes - \ 579 _srcobj->stats.rx.multicast.bytes; \ 580 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.unicast); \ 581 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.multicast); \ 582 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.bcast); \ 583 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.raw); \ 584 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.intra_bss.pkts); \ 585 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.intra_bss.fail); \ 586 DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.mec_drop); \ 587 \ 588 _tgtobj->stats.tx.last_ack_rssi = \ 589 _srcobj->stats.tx.last_ack_rssi; \ 590 } while (0) 591 592 extern int dp_peer_find_attach(struct dp_soc *soc); 593 extern void dp_peer_find_detach(struct dp_soc *soc); 594 extern void dp_peer_find_hash_add(struct dp_soc *soc, struct dp_peer *peer); 595 extern void dp_peer_find_hash_remove(struct dp_soc *soc, struct dp_peer *peer); 596 extern void dp_peer_find_hash_erase(struct dp_soc *soc); 597 extern void dp_peer_rx_init(struct dp_pdev *pdev, struct dp_peer *peer); 598 extern void dp_peer_cleanup(struct dp_vdev *vdev, struct dp_peer *peer); 599 extern void dp_peer_rx_cleanup(struct dp_vdev *vdev, struct dp_peer *peer); 600 extern void dp_peer_unref_delete(void *peer_handle); 601 extern void dp_rx_discard(struct dp_vdev *vdev, struct dp_peer *peer, 602 unsigned tid, qdf_nbuf_t msdu_list); 603 extern void *dp_find_peer_by_addr(struct cdp_pdev *dev, 604 uint8_t *peer_mac_addr, uint8_t *peer_id); 605 extern struct dp_peer *dp_peer_find_hash_find(struct dp_soc *soc, 606 uint8_t *peer_mac_addr, int mac_addr_is_aligned, uint8_t vdev_id); 607 608 #ifndef CONFIG_WIN 609 QDF_STATUS dp_register_peer(struct cdp_pdev *pdev_handle, 610 struct ol_txrx_desc_type *sta_desc); 611 QDF_STATUS dp_clear_peer(struct cdp_pdev *pdev_handle, uint8_t local_id); 612 void *dp_find_peer_by_addr_and_vdev(struct cdp_pdev *pdev_handle, 613 struct cdp_vdev *vdev, 614 uint8_t *peer_addr, uint8_t *local_id); 615 uint16_t dp_local_peer_id(void *peer); 616 void *dp_peer_find_by_local_id(struct cdp_pdev *pdev_handle, uint8_t local_id); 617 QDF_STATUS dp_peer_state_update(struct cdp_pdev *pdev_handle, uint8_t *peer_mac, 618 enum ol_txrx_peer_state state); 619 QDF_STATUS dp_get_vdevid(void *peer_handle, uint8_t *vdev_id); 620 struct cdp_vdev *dp_get_vdev_by_sta_id(struct cdp_pdev *pdev_handle, 621 uint8_t sta_id); 622 struct cdp_vdev *dp_get_vdev_for_peer(void *peer); 623 uint8_t *dp_peer_get_peer_mac_addr(void *peer); 624 int dp_get_peer_state(void *peer_handle); 625 void dp_local_peer_id_pool_init(struct dp_pdev *pdev); 626 void dp_local_peer_id_alloc(struct dp_pdev *pdev, struct dp_peer *peer); 627 void dp_local_peer_id_free(struct dp_pdev *pdev, struct dp_peer *peer); 628 #else 629 static inline void dp_local_peer_id_pool_init(struct dp_pdev *pdev) 630 { 631 } 632 633 static inline 634 void dp_local_peer_id_alloc(struct dp_pdev *pdev, struct dp_peer *peer) 635 { 636 } 637 638 static inline 639 void dp_local_peer_id_free(struct dp_pdev *pdev, struct dp_peer *peer) 640 { 641 } 642 #endif 643 int dp_addba_resp_tx_completion_wifi3(void *peer_handle, uint8_t tid, 644 int status); 645 extern int dp_addba_requestprocess_wifi3(void *peer_handle, 646 uint8_t dialogtoken, uint16_t tid, uint16_t batimeout, 647 uint16_t buffersize, uint16_t startseqnum); 648 extern void dp_addba_responsesetup_wifi3(void *peer_handle, uint8_t tid, 649 uint8_t *dialogtoken, uint16_t *statuscode, 650 uint16_t *buffersize, uint16_t *batimeout); 651 extern void dp_set_addba_response(void *peer_handle, uint8_t tid, 652 uint16_t statuscode); 653 extern int dp_delba_process_wifi3(void *peer_handle, 654 int tid, uint16_t reasoncode); 655 /* 656 * dp_delba_tx_completion_wifi3() - Handle delba tx completion 657 * 658 * @peer_handle: Peer handle 659 * @tid: Tid number 660 * @status: Tx completion status 661 * Indicate status of delba Tx to DP for stats update and retry 662 * delba if tx failed. 663 * 664 */ 665 int dp_delba_tx_completion_wifi3(void *peer_handle, uint8_t tid, 666 int status); 667 extern int dp_rx_tid_setup_wifi3(struct dp_peer *peer, int tid, 668 uint32_t ba_window_size, uint32_t start_seq); 669 670 extern QDF_STATUS dp_reo_send_cmd(struct dp_soc *soc, 671 enum hal_reo_cmd_type type, struct hal_reo_cmd_params *params, 672 void (*callback_fn), void *data); 673 674 extern void dp_reo_cmdlist_destroy(struct dp_soc *soc); 675 extern void dp_reo_status_ring_handler(struct dp_soc *soc); 676 void dp_aggregate_vdev_stats(struct dp_vdev *vdev, 677 struct cdp_vdev_stats *vdev_stats); 678 void dp_rx_tid_stats_cb(struct dp_soc *soc, void *cb_ctxt, 679 union hal_reo_status *reo_status); 680 void dp_rx_bar_stats_cb(struct dp_soc *soc, void *cb_ctxt, 681 union hal_reo_status *reo_status); 682 uint16_t dp_tx_me_send_convert_ucast(struct cdp_vdev *vdev_handle, 683 qdf_nbuf_t nbuf, uint8_t newmac[][DP_MAC_ADDR_LEN], 684 uint8_t new_mac_cnt); 685 void dp_tx_me_alloc_descriptor(struct cdp_pdev *pdev); 686 687 void dp_tx_me_free_descriptor(struct cdp_pdev *pdev); 688 QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev, 689 uint32_t stats_type_upload_mask, uint32_t config_param_0, 690 uint32_t config_param_1, uint32_t config_param_2, 691 uint32_t config_param_3, int cookie, int cookie_msb, 692 uint8_t mac_id); 693 void dp_htt_stats_print_tag(uint8_t tag_type, uint32_t *tag_buf); 694 void dp_htt_stats_copy_tag(struct dp_pdev *pdev, uint8_t tag_type, uint32_t *tag_buf); 695 void dp_peer_rxtid_stats(struct dp_peer *peer, void (*callback_fn), 696 void *cb_ctxt); 697 void dp_set_pn_check_wifi3(struct cdp_vdev *vdev_handle, 698 struct cdp_peer *peer_handle, enum cdp_sec_type sec_type, 699 uint32_t *rx_pn); 700 701 void *dp_get_pdev_for_mac_id(struct dp_soc *soc, uint32_t mac_id); 702 void dp_set_michael_key(struct cdp_peer *peer_handle, 703 bool is_unicast, uint32_t *key); 704 705 /* 706 * dp_get_mac_id_for_pdev() - Return mac corresponding to pdev for mac 707 * 708 * @mac_id: MAC id 709 * @pdev_id: pdev_id corresponding to pdev, 0 for MCL 710 * 711 * Single pdev using both MACs will operate on both MAC rings, 712 * which is the case for MCL. 713 * For WIN each PDEV will operate one ring, so index is zero. 714 * 715 */ 716 static inline int dp_get_mac_id_for_pdev(uint32_t mac_id, uint32_t pdev_id) 717 { 718 if (mac_id && pdev_id) { 719 qdf_print("Both mac_id and pdev_id cannot be non zero"); 720 QDF_BUG(0); 721 return 0; 722 } 723 return (mac_id + pdev_id); 724 } 725 726 /* 727 * dp_get_mac_id_for_mac() - Return mac corresponding WIN and MCL mac_ids 728 * 729 * @soc: handle to DP soc 730 * @mac_id: MAC id 731 * 732 * Single pdev using both MACs will operate on both MAC rings, 733 * which is the case for MCL. 734 * For WIN each PDEV will operate one ring, so index is zero. 735 * 736 */ 737 static inline int dp_get_mac_id_for_mac(struct dp_soc *soc, uint32_t mac_id) 738 { 739 /* 740 * Single pdev using both MACs will operate on both MAC rings, 741 * which is the case for MCL. 742 */ 743 if (!wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx)) 744 return mac_id; 745 746 /* For WIN each PDEV will operate one ring, so index is zero. */ 747 return 0; 748 } 749 750 #ifdef WDI_EVENT_ENABLE 751 QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev, 752 uint32_t stats_type_upload_mask, 753 uint8_t mac_id); 754 755 int dp_wdi_event_unsub(struct cdp_pdev *txrx_pdev_handle, 756 void *event_cb_sub_handle, 757 uint32_t event); 758 759 int dp_wdi_event_sub(struct cdp_pdev *txrx_pdev_handle, 760 void *event_cb_sub_handle, 761 uint32_t event); 762 763 void dp_wdi_event_handler(enum WDI_EVENT event, void *soc, 764 void *data, u_int16_t peer_id, 765 int status, u_int8_t pdev_id); 766 767 int dp_wdi_event_attach(struct dp_pdev *txrx_pdev); 768 int dp_wdi_event_detach(struct dp_pdev *txrx_pdev); 769 int dp_set_pktlog_wifi3(struct dp_pdev *pdev, uint32_t event, 770 bool enable); 771 void *dp_get_pldev(struct cdp_pdev *txrx_pdev); 772 void dp_pkt_log_init(struct cdp_pdev *ppdev, void *scn); 773 774 static inline void dp_hif_update_pipe_callback(void *soc, void *cb_context, 775 QDF_STATUS (*callback)(void *, qdf_nbuf_t, uint8_t), uint8_t pipe_id) 776 { 777 struct hif_msg_callbacks hif_pipe_callbacks; 778 struct dp_soc *dp_soc = (struct dp_soc *)soc; 779 780 /* TODO: Temporary change to bypass HTC connection for this new 781 * HIF pipe, which will be used for packet log and other high- 782 * priority HTT messages. Proper HTC connection to be added 783 * later once required FW changes are available 784 */ 785 hif_pipe_callbacks.rxCompletionHandler = callback; 786 hif_pipe_callbacks.Context = cb_context; 787 hif_update_pipe_callback(dp_soc->hif_handle, 788 DP_HTT_T2H_HP_PIPE, &hif_pipe_callbacks); 789 } 790 791 QDF_STATUS dp_peer_stats_notify(struct dp_peer *peer); 792 793 #else 794 static inline int dp_wdi_event_unsub(struct cdp_pdev *txrx_pdev_handle, 795 void *event_cb_sub_handle, 796 uint32_t event) 797 { 798 return 0; 799 } 800 801 static inline int dp_wdi_event_sub(struct cdp_pdev *txrx_pdev_handle, 802 void *event_cb_sub_handle, 803 uint32_t event) 804 { 805 return 0; 806 } 807 808 static inline void dp_wdi_event_handler(enum WDI_EVENT event, void *soc, 809 void *data, u_int16_t peer_id, 810 int status, u_int8_t pdev_id) 811 { 812 } 813 814 static inline int dp_wdi_event_attach(struct dp_pdev *txrx_pdev) 815 { 816 return 0; 817 } 818 819 static inline int dp_wdi_event_detach(struct dp_pdev *txrx_pdev) 820 { 821 return 0; 822 } 823 824 static inline int dp_set_pktlog_wifi3(struct dp_pdev *pdev, uint32_t event, 825 bool enable) 826 { 827 return 0; 828 } 829 static inline QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev, 830 uint32_t stats_type_upload_mask, uint8_t mac_id) 831 { 832 return 0; 833 } 834 static inline void dp_hif_update_pipe_callback(void *soc, void *cb_context, 835 QDF_STATUS (*callback)(void *, qdf_nbuf_t, uint8_t), uint8_t pipe_id) 836 { 837 } 838 839 static inline QDF_STATUS dp_peer_stats_notify(struct dp_peer *peer) 840 { 841 return QDF_STATUS_SUCCESS; 842 } 843 844 #endif /* CONFIG_WIN */ 845 #ifdef QCA_LL_TX_FLOW_CONTROL_V2 846 void dp_tx_dump_flow_pool_info(void *soc); 847 int dp_tx_delete_flow_pool(struct dp_soc *soc, struct dp_tx_desc_pool_s *pool, 848 bool force); 849 #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */ 850 851 #ifdef PEER_PROTECTED_ACCESS 852 /** 853 * dp_peer_unref_del_find_by_id() - dec ref and del peer if ref count is 854 * taken by dp_peer_find_by_id 855 * @peer: peer context 856 * 857 * Return: none 858 */ 859 static inline void dp_peer_unref_del_find_by_id(struct dp_peer *peer) 860 { 861 dp_peer_unref_delete(peer); 862 } 863 #else 864 static inline void dp_peer_unref_del_find_by_id(struct dp_peer *peer) 865 { 866 } 867 #endif 868 869 #endif /* #ifndef _DP_INTERNAL_H_ */ 870