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_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 #define HTT_TX_MUTEX_TYPE qdf_spinlock_t 28 29 #define HTT_TX_MUTEX_INIT(_mutex) \ 30 qdf_spinlock_create(_mutex) 31 32 #define HTT_TX_MUTEX_ACQUIRE(_mutex) \ 33 qdf_spin_lock_bh(_mutex) 34 35 #define HTT_TX_MUTEX_RELEASE(_mutex) \ 36 qdf_spin_unlock_bh(_mutex) 37 38 #define HTT_TX_MUTEX_DESTROY(_mutex) \ 39 qdf_spinlock_destroy(_mutex) 40 41 #define DP_HTT_MAX_SEND_QUEUE_DEPTH 64 42 43 #ifndef HTT_MAC_ADDR_LEN 44 #define HTT_MAC_ADDR_LEN 6 45 #endif 46 47 #define DP_HTT_HTC_PKT_MISCLIST_SIZE 256 48 49 #define HTT_T2H_EXT_STATS_TLV_START_OFFSET 3 50 51 struct dp_htt_htc_pkt { 52 void *soc_ctxt; 53 qdf_dma_addr_t nbuf_paddr; 54 HTC_PACKET htc_pkt; 55 }; 56 57 struct dp_htt_htc_pkt_union { 58 union { 59 struct dp_htt_htc_pkt pkt; 60 struct dp_htt_htc_pkt_union *next; 61 } u; 62 }; 63 64 struct htt_soc { 65 void *ctrl_psoc; 66 void *dp_soc; 67 void *hal_soc; 68 HTC_HANDLE htc_soc; 69 qdf_device_t osdev; 70 HTC_ENDPOINT_ID htc_endpoint; 71 struct dp_htt_htc_pkt_union *htt_htc_pkt_freelist; 72 struct dp_htt_htc_pkt_union *htt_htc_pkt_misclist; 73 struct { 74 u_int8_t major; 75 u_int8_t minor; 76 } tgt_ver; 77 struct { 78 u_int8_t major; 79 u_int8_t minor; 80 } wifi_ip_ver; 81 82 struct { 83 int htc_err_cnt; 84 int htc_pkt_free; 85 } stats; 86 87 HTT_TX_MUTEX_TYPE htt_tx_mutex; 88 }; 89 90 /** 91 * struct htt_rx_ring_tlv_filter - Rx ring TLV filter 92 * enable/disable. 93 * @mpdu_start: enable/disable MPDU start TLV 94 * @msdu_start: enable/disable MSDU start TLV 95 * @packet: enable/disable PACKET TLV 96 * @msdu_end: enable/disable MSDU end TLV 97 * @mpdu_end: enable/disable MPDU end TLV 98 * @packet_header: enable/disable PACKET header TLV 99 * @attention: enable/disable ATTENTION TLV 100 * @ppdu_start: enable/disable PPDU start TLV 101 * @ppdu_end: enable/disable PPDU end TLV 102 * @ppdu_end_user_stats: enable/disable PPDU user stats TLV 103 * @ppdu_end_user_stats_ext: enable/disable PPDU user stats ext TLV 104 * @ppdu_end_status_done: enable/disable PPDU end status done TLV 105 * @enable_fp: enable/disable FP packet 106 * @enable_md: enable/disable MD packet 107 * @enable_mo: enable/disable MO packet 108 * @enable_mgmt: enable/disable MGMT packet 109 * @enable_ctrl: enable/disable CTRL packet 110 * @enable_data: enable/disable DATA packet 111 */ 112 struct htt_rx_ring_tlv_filter { 113 u_int32_t mpdu_start:1, 114 msdu_start:1, 115 packet:1, 116 msdu_end:1, 117 mpdu_end:1, 118 packet_header:1, 119 attention:1, 120 ppdu_start:1, 121 ppdu_end:1, 122 ppdu_end_user_stats:1, 123 ppdu_end_user_stats_ext:1, 124 ppdu_end_status_done:1, 125 header_per_msdu:1, 126 enable_fp:1, 127 enable_md:1, 128 enable_mo:1; 129 u_int32_t fp_mgmt_filter:16, 130 mo_mgmt_filter:16; 131 u_int32_t fp_ctrl_filter:16, 132 mo_ctrl_filter:16; 133 u_int32_t fp_data_filter:16, 134 mo_data_filter:16; 135 u_int16_t md_data_filter; 136 u_int16_t md_mgmt_filter; 137 u_int16_t md_ctrl_filter; 138 }; 139 140 /* 141 * htt_soc_initialize() - SOC level HTT initialization 142 * @htt_soc: Opaque htt SOC handle 143 * @ctrl_psoc: Opaque ctrl SOC handle 144 * @htc_soc: SOC level HTC handle 145 * @hal_soc: Opaque HAL SOC handle 146 * @osdev: QDF device 147 * 148 * Return: HTT handle on success; NULL on failure 149 */ 150 void * 151 htt_soc_initialize(void *htt_soc, void *ctrl_psoc, HTC_HANDLE htc_soc, 152 void *hal_soc, qdf_device_t osdev); 153 154 /* 155 * htt_soc_htc_dealloc() - HTC memory de-alloc 156 * @htt_soc: SOC level HTT handle 157 * 158 * Return: None 159 */ 160 void htt_soc_htc_dealloc(struct htt_soc *htt_handle); 161 162 /* 163 * htt_soc_htc_prealloc() - HTC memory prealloc 164 * @htt_soc: SOC level HTT handle 165 * 166 * Return: QDF_STATUS_SUCCESS on success or 167 * QDF_STATUS_E_NO_MEM on allocation failure 168 */ 169 QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *htt_soc); 170 171 void htt_soc_detach(void *soc); 172 173 int htt_srng_setup(void *htt_soc, int pdev_id, void *hal_srng, 174 int hal_ring_type); 175 176 int htt_soc_attach_target(void *htt_soc); 177 178 /* 179 * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter 180 * config message to target 181 * @htt_soc: HTT SOC handle 182 * @pdev_id: PDEV Id 183 * @hal_srng: Opaque HAL SRNG pointer 184 * @hal_ring_type: SRNG ring type 185 * @ring_buf_size: SRNG buffer size 186 * @htt_tlv_filter: Rx SRNG TLV and filter setting 187 * 188 * Return: 0 on success; error code on failure 189 */ 190 int htt_h2t_rx_ring_cfg(void *htt_soc, int pdev_id, void *hal_srng, 191 int hal_ring_type, int ring_buf_size, 192 struct htt_rx_ring_tlv_filter *htt_tlv_filter); 193 194 /* 195 * htt_t2h_stats_handler() - target to host stats work handler 196 * @context: context (dp soc context) 197 * 198 * Return: void 199 */ 200 void htt_t2h_stats_handler(void *context); 201 202 /** 203 * struct htt_stats_context - htt stats information 204 * @soc: Size of each descriptor in the pool 205 * @msg: T2H Ext stats message queue 206 * @msg_len: T2H Ext stats message length 207 */ 208 struct htt_stats_context { 209 struct dp_soc *soc; 210 qdf_nbuf_queue_t msg; 211 uint32_t msg_len; 212 }; 213 214 #endif /* _DP_HTT_H_ */ 215