1 /* 2 * Copyright (c) 2021, The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 #ifndef _DP_RX_MON_2_0_H_ 19 #define _DP_RX_MON_2_0_H_ 20 21 #include <qdf_nbuf_frag.h> 22 #include <hal_be_api_mon.h> 23 #include <dp_mon_2.0.h> 24 25 #define DP_RX_MON_PACKET_OFFSET 8 26 #define DP_RX_MON_RX_HDR_OFFSET 8 27 #define DP_GET_NUM_QWORDS(num) ((num) >> 3) 28 29 #define DP_RX_MON_TLV_HDR_MARKER 0xFEED 30 #define DP_RX_MON_TLV_HDR_MARKER_LEN 2 31 #define DP_RX_MON_TLV_HDR_LEN 3 /* TLV ID field sz + TLV len field sz */ 32 #define DP_RX_MON_TLV_TOTAL_LEN 2 33 34 #define DP_RX_MON_TLV_PF_ID 1 35 #define DP_RX_MON_TLV_PPDU_ID 2 36 #define DP_RX_MON_MAX_TLVS 2 37 38 #define DP_RX_MON_TLV_MSDU_CNT 2 39 #define DP_RX_MON_MAX_MSDU 16 40 #define DP_RX_MON_PF_TLV_LEN (((DP_RX_MON_PF_TAG_LEN_PER_FRAG)\ 41 * (DP_RX_MON_MAX_MSDU) * 2)\ 42 + (DP_RX_MON_TLV_MSDU_CNT)) 43 44 #define DP_RX_MON_PPDU_ID_LEN 4 45 46 #define DP_RX_MON_INDIV_TLV_LEN ((DP_RX_MON_PF_TLV_LEN)\ 47 + (DP_RX_MON_PPDU_ID_LEN)) 48 #define DP_RX_MON_TLV_ROOM ((DP_RX_MON_INDIV_TLV_LEN)\ 49 + ((DP_RX_MON_TLV_HDR_LEN) * (DP_RX_MON_MAX_TLVS))\ 50 + (DP_RX_MON_TLV_HDR_MARKER_LEN)\ 51 + (DP_RX_MON_TLV_TOTAL_LEN)) 52 53 #define DP_RX_MON_WQ_THRESHOLD 128 54 55 #define DP_RX_MON_MAX_RX_HEADER_LEN 128 56 57 #ifdef WLAN_PKT_CAPTURE_RX_2_0 58 QDF_STATUS dp_mon_pdev_ext_init_2_0(struct dp_pdev *pdev); 59 QDF_STATUS dp_mon_pdev_ext_deinit_2_0(struct dp_pdev *pdev); 60 61 #ifdef QCA_KMEM_CACHE_SUPPORT 62 QDF_STATUS dp_rx_mon_ppdu_info_cache_create(struct dp_pdev *pdev); 63 void dp_rx_mon_ppdu_info_cache_destroy(struct dp_pdev *pdev); 64 struct hal_rx_ppdu_info* 65 dp_rx_mon_get_ppdu_info(struct dp_mon_pdev *mon_pdev); 66 void 67 dp_rx_mon_free_ppdu_info(struct dp_pdev *pdev, 68 struct hal_rx_ppdu_info *ppdu_info); 69 void 70 __dp_rx_mon_free_ppdu_info(struct dp_mon_pdev *mon_pdev, 71 struct hal_rx_ppdu_info *ppdu_info); 72 #else 73 static inline QDF_STATUS dp_rx_mon_ppdu_info_cache_create(struct dp_pdev *pdev) 74 { 75 return QDF_STATUS_SUCCESS; 76 } 77 78 static inline void dp_rx_mon_ppdu_info_cache_destroy(struct dp_pdev *pdev) 79 { 80 } 81 82 static inline struct hal_rx_ppdu_info* 83 dp_rx_mon_get_ppdu_info(struct dp_mon_pdev *mon_pdev) 84 { 85 qdf_mem_zero(&mon_pdev->ppdu_info, sizeof(struct hal_rx_ppdu_info)); 86 return &mon_pdev->ppdu_info; 87 } 88 89 static inline void 90 dp_rx_mon_free_ppdu_info(struct dp_pdev *pdev, 91 struct hal_rx_ppdu_info *ppdu_info) 92 { 93 } 94 95 static inline void 96 __dp_rx_mon_free_ppdu_info(struct dp_mon_pdev *mon_pdev, 97 struct hal_rx_ppdu_info *ppdu_info) 98 { 99 } 100 #endif 101 102 QDF_STATUS dp_rx_mon_pdev_htt_srng_setup_2_0(struct dp_soc *soc, 103 struct dp_pdev *pdev, 104 int mac_id, 105 int mac_for_pdev); 106 QDF_STATUS dp_rx_mon_soc_htt_srng_setup_2_0(struct dp_soc *soc, 107 int mac_id); 108 QDF_STATUS dp_rx_mon_pdev_rings_alloc_2_0(struct dp_pdev *pdev, int lmac_id); 109 void dp_rx_mon_pdev_rings_free_2_0(struct dp_pdev *pdev, int lmac_id); 110 QDF_STATUS dp_rx_mon_pdev_rings_init_2_0(struct dp_pdev *pdev, int lmac_id); 111 void dp_rx_mon_pdev_rings_deinit_2_0(struct dp_pdev *pdev, int lmac_id); 112 QDF_STATUS dp_rx_mon_soc_init_2_0(struct dp_soc *soc); 113 114 /* 115 * dp_rx_mon_buffers_alloc() - allocate rx monitor buffers 116 * @soc: DP soc handle 117 * 118 * Return: QDF_STATUS_SUCCESS: Success 119 * QDF_STATUS_E_FAILURE: Error 120 */ 121 QDF_STATUS 122 dp_rx_mon_buffers_alloc(struct dp_soc *soc, uint32_t size); 123 124 /* 125 * dp_rx_mon_buffers_free() - free rx monitor buffers 126 * @soc: dp soc handle 127 * 128 */ 129 void 130 dp_rx_mon_buffers_free(struct dp_soc *soc); 131 132 /* 133 * dp_rx_mon_desc_pool_deinit() - deinit rx monitor descriptor pool 134 * @soc: dp soc handle 135 * 136 */ 137 void 138 dp_rx_mon_buf_desc_pool_deinit(struct dp_soc *soc); 139 140 /* 141 * dp_rx_mon_desc_pool_deinit() - deinit rx monitor descriptor pool 142 * @soc: dp soc handle 143 * 144 * Return: QDF_STATUS_SUCCESS: Success 145 * QDF_STATUS_E_FAILURE: Error 146 */ 147 QDF_STATUS 148 dp_rx_mon_buf_desc_pool_init(struct dp_soc *soc); 149 150 /* 151 * dp_rx_mon_buf_desc_pool_free() - free rx monitor descriptor pool 152 * @soc: dp soc handle 153 * 154 */ 155 void dp_rx_mon_buf_desc_pool_free(struct dp_soc *soc); 156 157 /* 158 * dp_rx_mon_buf_desc_pool_alloc() - allocate rx monitor descriptor pool 159 * @soc: DP soc handle 160 * 161 * Return: QDF_STATUS_SUCCESS: Success 162 * QDF_STATUS_E_FAILURE: Error 163 */ 164 QDF_STATUS 165 dp_rx_mon_buf_desc_pool_alloc(struct dp_soc *soc); 166 167 /** 168 * dp_rx_mon_stats_update_2_0() - update rx stats 169 * 170 * @mon_peer: monitor peer handle 171 * @ppdu: Rx PPDU status metadata object 172 * @ppdu_user: Rx PPDU user status metadata object 173 * 174 * Return: Void 175 */ 176 void dp_rx_mon_stats_update_2_0(struct dp_mon_peer *mon_peer, 177 struct cdp_rx_indication_ppdu *ppdu, 178 struct cdp_rx_stats_ppdu_user *ppdu_user); 179 180 /** 181 * dp_rx_mon_populate_ppdu_usr_info_2_0() - Populate ppdu user info 182 * 183 * @rx_user_status: Rx user status 184 * @ppdu_user: ppdu user metadata 185 * 186 * Return: void 187 */ 188 void 189 dp_rx_mon_populate_ppdu_usr_info_2_0(struct mon_rx_user_status *rx_user_status, 190 struct cdp_rx_stats_ppdu_user *ppdu_user); 191 192 /** 193 * dp_rx_mon_populate_ppdu_info_2_0() -- Populate ppdu info 194 * 195 * @hal_ppdu_info: HAL PPDU info 196 * @ppdu: Rx PPDU status metadata object 197 * 198 * Return: void 199 */ 200 void 201 dp_rx_mon_populate_ppdu_info_2_0(struct hal_rx_ppdu_info *hal_ppdu_info, 202 struct cdp_rx_indication_ppdu *ppdu); 203 204 QDF_STATUS dp_rx_mon_soc_attach_2_0(struct dp_soc *soc, int lmac_id); 205 void dp_rx_mon_soc_detach_2_0(struct dp_soc *soc, int lmac_id); 206 void dp_rx_mon_soc_deinit_2_0(struct dp_soc *soc, uint32_t lmac_id); 207 208 #ifndef QCA_MONITOR_2_0_PKT_SUPPORT 209 static inline QDF_STATUS dp_rx_mon_init_wq_sm(struct dp_pdev *pdev) 210 { 211 return QDF_STATUS_SUCCESS; 212 } 213 214 static inline QDF_STATUS dp_rx_mon_deinit_wq_sm(struct dp_pdev *pdev) 215 { 216 return QDF_STATUS_SUCCESS; 217 } 218 219 static inline QDF_STATUS 220 dp_rx_mon_add_ppdu_info_to_wq(struct dp_pdev *pdev, 221 struct hal_rx_ppdu_info *ppdu_info) 222 { 223 return QDF_STATUS_SUCCESS; 224 } 225 226 static inline int 227 dp_rx_mon_flush_packet_tlv(struct dp_pdev *pdev, void *buf, uint16_t end_offset, 228 union dp_mon_desc_list_elem_t **desc_list, 229 union dp_mon_desc_list_elem_t **tail) 230 { 231 return 0; 232 } 233 234 static inline void 235 dp_rx_mon_handle_rx_hdr(struct dp_pdev *pdev, 236 struct hal_rx_ppdu_info *ppdu_info, 237 void *status_frag) 238 { 239 } 240 241 static inline uint16_t 242 dp_rx_mon_handle_mon_buf_addr(struct dp_pdev *pdev, 243 struct hal_rx_ppdu_info *ppdu_info, 244 union dp_mon_desc_list_elem_t **desc_list, 245 union dp_mon_desc_list_elem_t **tail) 246 { 247 return 0; 248 } 249 250 static inline void 251 dp_rx_mon_handle_msdu_end(struct dp_pdev *pdev, 252 struct hal_rx_ppdu_info *ppdu_info) 253 { 254 } 255 256 static inline void 257 dp_rx_mon_reset_mpdu_q(struct hal_rx_ppdu_info *ppdu_info) 258 { 259 } 260 261 static inline void 262 dp_rx_mon_handle_mpdu_start(struct hal_rx_ppdu_info *ppdu_info) 263 { 264 } 265 266 static inline void 267 dp_rx_mon_handle_mpdu_end(struct hal_rx_ppdu_info *ppdu_info) 268 { 269 } 270 271 static inline QDF_STATUS 272 dp_rx_mon_nbuf_add_rx_frag(qdf_nbuf_t nbuf, qdf_frag_t *frag, 273 uint16_t frag_len, uint16_t offset, 274 uint16_t buf_size, bool frag_ref) 275 { 276 return 0; 277 } 278 279 static inline void 280 dp_rx_mon_pf_tag_to_buf_headroom_2_0(void *nbuf, 281 struct hal_rx_ppdu_info *ppdu_info, 282 struct dp_pdev *pdev, struct dp_soc *soc) 283 { 284 } 285 #endif 286 #else 287 static inline QDF_STATUS dp_mon_pdev_ext_init_2_0(struct dp_pdev *pdev) 288 { 289 return QDF_STATUS_SUCCESS; 290 } 291 292 static inline QDF_STATUS dp_mon_pdev_ext_deinit_2_0(struct dp_pdev *pdev) 293 { 294 return QDF_STATUS_SUCCESS; 295 } 296 297 static inline QDF_STATUS dp_rx_mon_ppdu_info_cache_create(struct dp_pdev *pdev) 298 { 299 return QDF_STATUS_SUCCESS; 300 } 301 302 static inline void dp_rx_mon_ppdu_info_cache_destroy(struct dp_pdev *pdev) 303 { 304 } 305 306 static inline struct hal_rx_ppdu_info* 307 dp_rx_mon_get_ppdu_info(struct dp_mon_pdev *mon_pdev) 308 { 309 return NULL; 310 } 311 312 static inline void 313 dp_rx_mon_free_ppdu_info(struct dp_pdev *pdev, 314 struct hal_rx_ppdu_info *ppdu_info) 315 { 316 } 317 318 static inline QDF_STATUS 319 dp_rx_mon_buffers_alloc(struct dp_soc *soc, uint32_t size) 320 { 321 return QDF_STATUS_SUCCESS; 322 } 323 324 static inline 325 QDF_STATUS dp_rx_mon_soc_init_2_0(struct dp_soc *soc) 326 { 327 return QDF_STATUS_SUCCESS; 328 } 329 330 static inline void 331 dp_rx_mon_buffers_free(struct dp_soc *soc) 332 333 { 334 } 335 336 static inline void 337 dp_rx_mon_buf_desc_pool_deinit(struct dp_soc *soc) 338 { 339 } 340 341 static inline QDF_STATUS 342 dp_rx_mon_buf_desc_pool_init(struct dp_soc *soc) 343 { 344 return QDF_STATUS_SUCCESS; 345 } 346 347 static inline void dp_rx_mon_buf_desc_pool_free(struct dp_soc *soc) 348 { 349 } 350 351 static inline QDF_STATUS 352 dp_rx_mon_buf_desc_pool_alloc(struct dp_soc *soc) 353 { 354 return QDF_STATUS_SUCCESS; 355 } 356 357 static inline 358 void dp_rx_mon_stats_update_2_0(struct dp_mon_peer *mon_peer, 359 struct cdp_rx_indication_ppdu *ppdu, 360 struct cdp_rx_stats_ppdu_user *ppdu_user) 361 { 362 } 363 364 static inline void 365 dp_rx_mon_populate_ppdu_usr_info_2_0(struct mon_rx_user_status *rx_user_status, 366 struct cdp_rx_stats_ppdu_user *ppdu_user) 367 { 368 } 369 370 static inline void 371 dp_rx_mon_populate_ppdu_info_2_0(struct hal_rx_ppdu_info *hal_ppdu_info, 372 struct cdp_rx_indication_ppdu *ppdu) 373 { 374 } 375 376 static inline 377 QDF_STATUS dp_rx_mon_pdev_htt_srng_setup_2_0(struct dp_soc *soc, 378 struct dp_pdev *pdev, 379 int mac_id, 380 int mac_for_pdev) 381 { 382 return QDF_STATUS_SUCCESS; 383 } 384 385 static inline 386 QDF_STATUS dp_rx_mon_soc_htt_srng_setup_2_0(struct dp_soc *soc, 387 int mac_id) 388 { 389 return QDF_STATUS_SUCCESS; 390 } 391 392 static inline 393 QDF_STATUS dp_rx_mon_pdev_rings_alloc_2_0(struct dp_pdev *pdev, int lmac_id) 394 { 395 return QDF_STATUS_SUCCESS; 396 } 397 398 static inline 399 void dp_rx_mon_pdev_rings_free_2_0(struct dp_pdev *pdev, int lmac_id) 400 { 401 } 402 403 static inline 404 QDF_STATUS dp_rx_mon_pdev_rings_init_2_0(struct dp_pdev *pdev, int lmac_id) 405 { 406 return QDF_STATUS_SUCCESS; 407 } 408 409 static inline 410 void dp_rx_mon_pdev_rings_deinit_2_0(struct dp_pdev *pdev, int lmac_id) 411 { 412 } 413 414 static inline 415 QDF_STATUS dp_rx_mon_soc_attach_2_0(struct dp_soc *soc, int lmac_id) 416 { 417 return QDF_STATUS_SUCCESS; 418 } 419 420 static inline 421 void dp_rx_mon_soc_detach_2_0(struct dp_soc *soc, int lmac_id) 422 { 423 } 424 425 static inline 426 void dp_rx_mon_soc_deinit_2_0(struct dp_soc *soc, uint32_t lmac_id) 427 { 428 } 429 #endif 430 431 #if !defined(DISABLE_MON_CONFIG) && defined(WLAN_PKT_CAPTURE_RX_2_0) 432 /* 433 * dp_rx_mon_process_2_0() - Process Rx monitor interrupt 434 * 435 * @soc: DP soc handle 436 * @int_ctx: Interrupt context 437 * @mac_id: LMAC id 438 * @quota: quota to reap 439 */ 440 uint32_t 441 dp_rx_mon_process_2_0(struct dp_soc *soc, struct dp_intr *int_ctx, 442 uint32_t mac_id, uint32_t quota); 443 444 /** 445 * dp_rx_mon_process_ppdu() - RxMON Workqueue processing API 446 * 447 * @context: workqueue context 448 */ 449 void dp_rx_mon_process_ppdu(void *context); 450 #else 451 static inline uint32_t 452 dp_rx_mon_process_2_0(struct dp_soc *soc, struct dp_intr *int_ctx, 453 uint32_t mac_id, uint32_t quota) 454 { 455 return 0; 456 } 457 458 static inline void dp_rx_mon_process_ppdu(void *context) 459 { 460 } 461 #endif /* DISABLE_MON_CONFIG */ 462 463 /** 464 * dp_rx_mon_handle_full_mon() - Handle full monitor MPDU restitch 465 * 466 * @pdev: DP pdev 467 * @ppdu_info: PPDU info 468 * @mpdu: mpdu buf 469 * 470 * Return: SUCCESS or Failure 471 */ 472 QDF_STATUS 473 dp_rx_mon_handle_full_mon(struct dp_pdev *pdev, 474 struct hal_rx_ppdu_info *ppdu_info, 475 qdf_nbuf_t mpdu); 476 477 /** 478 * dp_rx_mon_drain_wq() - Drain monitor buffers from rxmon workqueue 479 * 480 * @pdev: DP pdev handle 481 * 482 * Return: Void 483 */ 484 void dp_rx_mon_drain_wq(struct dp_pdev *pdev); 485 486 /** 487 * dp_mon_free_parent_nbuf() - Free parent SKB 488 * 489 * @mon_pdev: monitor pdev 490 * @nbuf: SKB to be freed 491 * 492 * Return: void 493 */ 494 void dp_mon_free_parent_nbuf(struct dp_mon_pdev *mon_pdev, 495 qdf_nbuf_t nbuf); 496 497 #ifdef QCA_ENHANCED_STATS_SUPPORT 498 /** 499 * dp_mon_rx_print_advanced_stats_2_0() - print advanced monitor statistics 500 * 501 * @soc: DP soc handle 502 * @pdev: DP pdev handle 503 * 504 * Return: void 505 */ 506 void dp_mon_rx_print_advanced_stats_2_0(struct dp_soc *soc, 507 struct dp_pdev *pdev); 508 #else 509 static inline 510 void dp_mon_rx_print_advanced_stats_2_0(struct dp_soc *soc, 511 struct dp_pdev *pdev) 512 { 513 } 514 #endif 515 516 #ifdef BE_PKTLOG_SUPPORT 517 /** 518 * dp_rx_process_pktlog_be() - process pktlog 519 * @soc: dp soc handle 520 * @pdev: dp pdev handle 521 * @ppdu_info: HAL PPDU info 522 * @status_frag: frag pointer which needs to be added to nbuf 523 * @end_offset: Offset in frag to be added to nbuf_frags 524 * 525 * Return: QDF_STATUS_SUCCESS or Failure 526 */ 527 QDF_STATUS 528 dp_rx_process_pktlog_be(struct dp_soc *soc, struct dp_pdev *pdev, 529 struct hal_rx_ppdu_info *ppdu_info, 530 void *status_frag, uint32_t end_offset); 531 #else 532 static inline QDF_STATUS 533 dp_rx_process_pktlog_be(struct dp_soc *soc, struct dp_pdev *pdev, 534 struct hal_rx_ppdu_info *ppdu_info, 535 void *status_frag, uint32_t end_offset) 536 { 537 return QDF_STATUS_SUCCESS; 538 } 539 #endif 540 541 /** 542 * dp_rx_mon_append_nbuf() - Append nbuf to parent nbuf 543 * @nbuf: Parent nbuf 544 * @tmp_nbuf: nbuf to be attached to parent 545 * 546 * Return: void 547 */ 548 void dp_rx_mon_append_nbuf(qdf_nbuf_t nbuf, qdf_nbuf_t tmp_nbuf); 549 #endif /* _DP_RX_MON_2_0_H_ */ 550