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