1 /* 2 * Copyright (c) 2021, The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2022 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 24 #define DP_RX_MON_PACKET_OFFSET 8 25 #define DP_RX_MON_RX_HDR_OFFSET 8 26 #define DP_GET_NUM_QWORDS(num) ((num) >> 3) 27 28 #define DP_RX_MON_TLV_HDR_MARKER 0xFEED 29 #define DP_RX_MON_TLV_HDR_MARKER_LEN 2 30 #define DP_RX_MON_TLV_HDR_LEN 3 /* TLV ID field sz + TLV len field sz */ 31 #define DP_RX_MON_TLV_TOTAL_LEN 2 32 33 #define DP_RX_MON_TLV_PF_ID 1 34 #define DP_RX_MON_TLV_PPDU_ID 2 35 36 #define DP_RX_MON_TLV_MSDU_CNT 2 37 #define DP_RX_MON_MAX_MSDU 16 38 #define DP_RX_MON_MAX_TLVS 1 39 #define DP_RX_MON_PF_TLV_LEN (((DP_RX_MON_PF_TAG_LEN_PER_FRAG)\ 40 * (DP_RX_MON_MAX_MSDU) * 2)\ 41 + (DP_RX_MON_TLV_MSDU_CNT)) 42 43 #define DP_RX_MON_PPDU_ID_LEN 4 44 45 #define DP_RX_MON_INDIV_TLV_LEN ((DP_RX_MON_PF_TLV_LEN)\ 46 + (DP_RX_MON_PPDU_ID_LEN)) 47 #define DP_RX_MON_TLV_ROOM ((DP_RX_MON_INDIV_TLV_LEN)\ 48 + ((DP_RX_MON_TLV_HDR_LEN) * (DP_RX_MON_MAX_TLVS))\ 49 + (DP_RX_MON_TLV_HDR_MARKER_LEN)\ 50 + (DP_RX_MON_TLV_TOTAL_LEN)) 51 52 #define DP_RX_MON_WQ_THRESHOLD 128 53 /* 54 * dp_rx_mon_buffers_alloc() - allocate rx monitor buffers 55 * @soc: DP soc handle 56 * 57 * Return: QDF_STATUS_SUCCESS: Success 58 * QDF_STATUS_E_FAILURE: Error 59 */ 60 QDF_STATUS 61 dp_rx_mon_buffers_alloc(struct dp_soc *soc, uint32_t size); 62 63 /* 64 * dp_rx_mon_buffers_free() - free rx monitor buffers 65 * @soc: dp soc handle 66 * 67 */ 68 void 69 dp_rx_mon_buffers_free(struct dp_soc *soc); 70 71 /* 72 * dp_rx_mon_desc_pool_deinit() - deinit rx monitor descriptor pool 73 * @soc: dp soc handle 74 * 75 */ 76 void 77 dp_rx_mon_buf_desc_pool_deinit(struct dp_soc *soc); 78 79 /* 80 * dp_rx_mon_desc_pool_deinit() - deinit rx monitor descriptor pool 81 * @soc: dp soc handle 82 * 83 * Return: QDF_STATUS_SUCCESS: Success 84 * QDF_STATUS_E_FAILURE: Error 85 */ 86 QDF_STATUS 87 dp_rx_mon_buf_desc_pool_init(struct dp_soc *soc); 88 89 /* 90 * dp_rx_mon_buf_desc_pool_free() - free rx monitor descriptor pool 91 * @soc: dp soc handle 92 * 93 */ 94 void dp_rx_mon_buf_desc_pool_free(struct dp_soc *soc); 95 96 /* 97 * dp_rx_mon_buf_desc_pool_alloc() - allocate rx monitor descriptor pool 98 * @soc: DP soc handle 99 * 100 * Return: QDF_STATUS_SUCCESS: Success 101 * QDF_STATUS_E_FAILURE: Error 102 */ 103 QDF_STATUS 104 dp_rx_mon_buf_desc_pool_alloc(struct dp_soc *soc); 105 106 /** 107 * dp_rx_mon_stats_update_2_0 () - update rx stats 108 * 109 * @peer: monitor peer handle 110 * @ppdu: Rx PPDU status metadata object 111 * @ppdu_user: Rx PPDU user status metadata object 112 * 113 * Return: Void 114 */ 115 void dp_rx_mon_stats_update_2_0(struct dp_mon_peer *mon_peer, 116 struct cdp_rx_indication_ppdu *ppdu, 117 struct cdp_rx_stats_ppdu_user *ppdu_user); 118 119 /** 120 * dp_rx_mon_populate_ppdu_usr_info_2_0 () - Populate ppdu user info 121 * 122 * @rx_user_status: Rx user status 123 * @ppdu_user: ppdu user metadata 124 * 125 * Return: void 126 */ 127 void 128 dp_rx_mon_populate_ppdu_usr_info_2_0(struct mon_rx_user_status *rx_user_status, 129 struct cdp_rx_stats_ppdu_user *ppdu_user); 130 131 /** 132 * dp_rx_mon_populate_ppdu_info_2_0 () -- Populate ppdu info 133 * 134 * @hal_ppdu_info: HAL PPDU info 135 * @ppdu: Rx PPDU status metadata object 136 * 137 * Return: void 138 */ 139 void 140 dp_rx_mon_populate_ppdu_info_2_0(struct hal_rx_ppdu_info *hal_ppdu_info, 141 struct cdp_rx_indication_ppdu *ppdu); 142 143 /* 144 * dp_rx_process_pktlog_be() - process pktlog 145 * @soc: dp soc handle 146 * @pdev: dp pdev handle 147 * @ppdu_info: HAL PPDU info 148 * @status_frag: frag pointer which needs to be added to nbuf 149 * @end_offset: Offset in frag to be added to nbuf_frags 150 * 151 * Return: SUCCESS or Failure 152 */ 153 QDF_STATUS dp_rx_process_pktlog_be(struct dp_soc *soc, struct dp_pdev *pdev, 154 struct hal_rx_ppdu_info *ppdu_info, 155 void *status_frag, uint32_t end_offset); 156 157 #if !defined(DISABLE_MON_CONFIG) 158 /* 159 * dp_rx_mon_process_2_0 () - Process Rx monitor interrupt 160 * 161 * @soc: DP soc handle 162 * @int_ctx: Interrupt context 163 * @mac_id: LMAC id 164 * @quota: quota to reap 165 */ 166 uint32_t 167 dp_rx_mon_process_2_0(struct dp_soc *soc, struct dp_intr *int_ctx, 168 uint32_t mac_id, uint32_t quota); 169 170 /** 171 * dp_rx_mon_process_ppdu () - RxMON Workqueue processing API 172 * 173 * @context: workqueue context 174 */ 175 void dp_rx_mon_process_ppdu(void *context); 176 #else 177 static uint32_t 178 dp_rx_mon_process_2_0(struct dp_soc *soc, struct dp_intr *int_ctx, 179 uint32_t mac_id, uint32_t quota) 180 { 181 return 0; 182 } 183 184 static inline void dp_rx_mon_process_ppdu(void *context) 185 { 186 } 187 #endif /* DISABLE_MON_CONFIG */ 188 189 /** 190 * dp_rx_mon_handle_full_mon() - Handle full monitor MPDU restitch 191 * 192 * @pdev: DP pdev 193 * @ppdu_info: PPDU info 194 * @mpdu: mpdu buf 195 * 196 * Return: SUCCESS or Failure 197 */ 198 QDF_STATUS 199 dp_rx_mon_handle_full_mon(struct dp_pdev *pdev, 200 struct hal_rx_ppdu_info *ppdu_info, 201 qdf_nbuf_t mpdu); 202 203 /** 204 * dp_rx_mon_drain_wq() - Drain monitor buffers from rxmon workqueue 205 * 206 * @pdev: DP pdev handle 207 * 208 * Return: Void 209 */ 210 void dp_rx_mon_drain_wq(struct dp_pdev *pdev); 211 212 /** 213 * dp_mon_free_parent_nbuf() - Free parent SKB 214 * 215 * @mon_pdev: monitor pdev 216 * @nbuf: SKB to be freed 217 * 218 * @Return: void 219 */ 220 void 221 dp_mon_free_parent_nbuf(struct dp_mon_pdev *mon_pdev, 222 qdf_nbuf_t nbuf); 223 #if !defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG) &&\ 224 !defined(WLAN_SUPPORT_RX_FLOW_TAG) 225 void 226 dp_rx_mon_pf_tag_to_buf_headroom_2_0(void *nbuf, 227 struct hal_rx_ppdu_info *ppdu_info, 228 struct dp_pdev *pdev, struct dp_soc *soc) 229 { 230 } 231 232 void dp_rx_mon_shift_pf_tag_in_headroom(qdf_nbuf_t nbuf, struct dp_soc *soc) 233 { 234 } 235 #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */ 236 /** 237 * dp_mon_rx_print_advanced_stats_2_0 () - print advanced monitor statistics 238 * 239 * @soc: DP soc handle 240 * @pdev: DP pdev handle 241 * 242 * Return: void 243 */ 244 void dp_mon_rx_print_advanced_stats_2_0(struct dp_soc *soc, 245 struct dp_pdev *pdev); 246 #endif /* _DP_RX_MON_2_0_H_ */ 247