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 19 #ifndef _DP_HTT_H_ 20 #define _DP_HTT_H_ 21 22 #include <qdf_types.h> 23 #include <qdf_lock.h> 24 #include <qdf_nbuf.h> 25 #include <htc_api.h> 26 27 #include "cdp_txrx_cmn_struct.h" 28 #include "dp_types.h" 29 30 #define HTT_TX_MUTEX_TYPE qdf_spinlock_t 31 32 #define HTT_TX_MUTEX_INIT(_mutex) \ 33 qdf_spinlock_create(_mutex) 34 35 #define HTT_TX_MUTEX_ACQUIRE(_mutex) \ 36 qdf_spin_lock_bh(_mutex) 37 38 #define HTT_TX_MUTEX_RELEASE(_mutex) \ 39 qdf_spin_unlock_bh(_mutex) 40 41 #define HTT_TX_MUTEX_DESTROY(_mutex) \ 42 qdf_spinlock_destroy(_mutex) 43 44 #define DP_HTT_MAX_SEND_QUEUE_DEPTH 64 45 46 #ifndef HTT_MAC_ADDR_LEN 47 #define HTT_MAC_ADDR_LEN 6 48 #endif 49 50 #define HTT_FRAMECTRL_TYPE_MASK 0x0C 51 #define HTT_GET_FRAME_CTRL_TYPE(_val) \ 52 (((_val) & HTT_FRAMECTRL_TYPE_MASK) >> 2) 53 #define FRAME_CTRL_TYPE_MGMT 0x0 54 #define FRAME_CTRL_TYPE_CTRL 0x1 55 #define FRAME_CTRL_TYPE_DATA 0x2 56 #define FRAME_CTRL_TYPE_RESV 0x3 57 58 #define HTT_FRAMECTRL_DATATYPE 0x08 59 #define HTT_PPDU_DESC_MAX_DEPTH 16 60 #define DP_SCAN_PEER_ID 0xFFFF 61 62 #define DP_HTT_HTC_PKT_MISCLIST_SIZE 256 63 64 #define HTT_T2H_EXT_STATS_TLV_START_OFFSET 3 65 66 struct dp_htt_htc_pkt { 67 void *soc_ctxt; 68 qdf_dma_addr_t nbuf_paddr; 69 HTC_PACKET htc_pkt; 70 }; 71 72 struct dp_htt_htc_pkt_union { 73 union { 74 struct dp_htt_htc_pkt pkt; 75 struct dp_htt_htc_pkt_union *next; 76 } u; 77 }; 78 79 struct htt_soc { 80 void *ctrl_psoc; 81 void *dp_soc; 82 void *hal_soc; 83 HTC_HANDLE htc_soc; 84 qdf_device_t osdev; 85 HTC_ENDPOINT_ID htc_endpoint; 86 struct dp_htt_htc_pkt_union *htt_htc_pkt_freelist; 87 struct dp_htt_htc_pkt_union *htt_htc_pkt_misclist; 88 struct { 89 u_int8_t major; 90 u_int8_t minor; 91 } tgt_ver; 92 struct { 93 u_int8_t major; 94 u_int8_t minor; 95 } wifi_ip_ver; 96 97 struct { 98 int htc_err_cnt; 99 int htc_pkt_free; 100 } stats; 101 102 HTT_TX_MUTEX_TYPE htt_tx_mutex; 103 }; 104 105 /** 106 * struct htt_rx_ring_tlv_filter - Rx ring TLV filter 107 * enable/disable. 108 * @mpdu_start: enable/disable MPDU start TLV 109 * @msdu_start: enable/disable MSDU start TLV 110 * @packet: enable/disable PACKET TLV 111 * @msdu_end: enable/disable MSDU end TLV 112 * @mpdu_end: enable/disable MPDU end TLV 113 * @packet_header: enable/disable PACKET header TLV 114 * @attention: enable/disable ATTENTION TLV 115 * @ppdu_start: enable/disable PPDU start TLV 116 * @ppdu_end: enable/disable PPDU end TLV 117 * @ppdu_end_user_stats: enable/disable PPDU user stats TLV 118 * @ppdu_end_user_stats_ext: enable/disable PPDU user stats ext TLV 119 * @ppdu_end_status_done: enable/disable PPDU end status done TLV 120 * @enable_fp: enable/disable FP packet 121 * @enable_md: enable/disable MD packet 122 * @enable_mo: enable/disable MO packet 123 * @enable_mgmt: enable/disable MGMT packet 124 * @enable_ctrl: enable/disable CTRL packet 125 * @enable_data: enable/disable DATA packet 126 * @offset_valid: Flag to indicate if below offsets are valid 127 * @rx_packet_offset: Offset of packet payload 128 * @rx_header_offset: Offset of rx_header tlv 129 * @rx_mpdu_end_offset: Offset of rx_mpdu_end tlv 130 * @rx_mpdu_start_offset: Offset of rx_mpdu_start tlv 131 * @rx_msdu_end_offset: Offset of rx_msdu_end tlv 132 * @rx_msdu_start_offset: Offset of rx_msdu_start tlv 133 * @rx_attn_offset: Offset of rx_attention tlv 134 */ 135 struct htt_rx_ring_tlv_filter { 136 u_int32_t mpdu_start:1, 137 msdu_start:1, 138 packet:1, 139 msdu_end:1, 140 mpdu_end:1, 141 packet_header:1, 142 attention:1, 143 ppdu_start:1, 144 ppdu_end:1, 145 ppdu_end_user_stats:1, 146 ppdu_end_user_stats_ext:1, 147 ppdu_end_status_done:1, 148 header_per_msdu:1, 149 enable_fp:1, 150 enable_md:1, 151 enable_mo:1; 152 u_int32_t fp_mgmt_filter:16, 153 mo_mgmt_filter:16; 154 u_int32_t fp_ctrl_filter:16, 155 mo_ctrl_filter:16; 156 u_int32_t fp_data_filter:16, 157 mo_data_filter:16; 158 u_int16_t md_data_filter; 159 u_int16_t md_mgmt_filter; 160 u_int16_t md_ctrl_filter; 161 bool offset_valid; 162 uint16_t rx_packet_offset; 163 uint16_t rx_header_offset; 164 uint16_t rx_mpdu_end_offset; 165 uint16_t rx_mpdu_start_offset; 166 uint16_t rx_msdu_end_offset; 167 uint16_t rx_msdu_start_offset; 168 uint16_t rx_attn_offset; 169 }; 170 171 /* 172 * htt_soc_initialize() - SOC level HTT initialization 173 * @htt_soc: Opaque htt SOC handle 174 * @ctrl_psoc: Opaque ctrl SOC handle 175 * @htc_soc: SOC level HTC handle 176 * @hal_soc: Opaque HAL SOC handle 177 * @osdev: QDF device 178 * 179 * Return: HTT handle on success; NULL on failure 180 */ 181 void * 182 htt_soc_initialize(void *htt_soc, void *ctrl_psoc, HTC_HANDLE htc_soc, 183 void *hal_soc, qdf_device_t osdev); 184 185 /* 186 * htt_soc_htc_dealloc() - HTC memory de-alloc 187 * @htt_soc: SOC level HTT handle 188 * 189 * Return: None 190 */ 191 void htt_soc_htc_dealloc(struct htt_soc *htt_handle); 192 193 /* 194 * htt_soc_htc_prealloc() - HTC memory prealloc 195 * @htt_soc: SOC level HTT handle 196 * 197 * Return: QDF_STATUS_SUCCESS on success or 198 * QDF_STATUS_E_NO_MEM on allocation failure 199 */ 200 QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *htt_soc); 201 202 void htt_soc_detach(void *soc); 203 204 int htt_srng_setup(void *htt_soc, int pdev_id, void *hal_srng, 205 int hal_ring_type); 206 207 int htt_soc_attach_target(void *htt_soc); 208 209 /* 210 * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter 211 * config message to target 212 * @htt_soc: HTT SOC handle 213 * @pdev_id: PDEV Id 214 * @hal_srng: Opaque HAL SRNG pointer 215 * @hal_ring_type: SRNG ring type 216 * @ring_buf_size: SRNG buffer size 217 * @htt_tlv_filter: Rx SRNG TLV and filter setting 218 * 219 * Return: 0 on success; error code on failure 220 */ 221 int htt_h2t_rx_ring_cfg(void *htt_soc, int pdev_id, void *hal_srng, 222 int hal_ring_type, int ring_buf_size, 223 struct htt_rx_ring_tlv_filter *htt_tlv_filter); 224 225 /* 226 * htt_t2h_stats_handler() - target to host stats work handler 227 * @context: context (dp soc context) 228 * 229 * Return: void 230 */ 231 void htt_t2h_stats_handler(void *context); 232 233 /** 234 * struct htt_stats_context - htt stats information 235 * @soc: Size of each descriptor in the pool 236 * @msg: T2H Ext stats message queue 237 * @msg_len: T2H Ext stats message length 238 */ 239 struct htt_stats_context { 240 struct dp_soc *soc; 241 qdf_nbuf_queue_t msg; 242 uint32_t msg_len; 243 }; 244 245 int 246 dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(uint32_t bitmap); 247 248 /** 249 * dp_ppdu_desc_user_stats_update(): Function to update TX user stats 250 * @pdev: DP pdev handle 251 * @ppdu_info: per PPDU TLV descriptor 252 * 253 * return: void 254 */ 255 void 256 dp_ppdu_desc_user_stats_update(struct dp_pdev *pdev, 257 struct ppdu_info *ppdu_info); 258 259 #endif /* _DP_HTT_H_ */ 260