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 #ifdef HTT_LOGGER 30 #include "dp_htt_logger.h" 31 #else 32 struct htt_logger; 33 static inline 34 void htt_interface_logging_init(struct htt_logger **htt_logger_handle) 35 { 36 } 37 38 static inline 39 void htt_interface_logging_deinit(struct htt_logger *htt_logger_handle) 40 { 41 } 42 43 static inline 44 int htt_command_record(struct htt_logger *h, uint8_t msg_type, 45 uint8_t *msg_data) 46 { 47 return 0; 48 } 49 50 static inline 51 int htt_event_record(struct htt_logger *h, uint8_t msg_type, 52 uint8_t *msg_data) 53 { 54 return 0; 55 } 56 57 static inline 58 int htt_wbm_event_record(struct htt_logger *h, uint8_t tx_status, 59 uint8_t *msg_data) 60 { 61 return 0; 62 } 63 64 #endif 65 66 #define HTT_TX_MUTEX_TYPE qdf_spinlock_t 67 68 #define HTT_TX_MUTEX_INIT(_mutex) \ 69 qdf_spinlock_create(_mutex) 70 71 #define HTT_TX_MUTEX_ACQUIRE(_mutex) \ 72 qdf_spin_lock_bh(_mutex) 73 74 #define HTT_TX_MUTEX_RELEASE(_mutex) \ 75 qdf_spin_unlock_bh(_mutex) 76 77 #define HTT_TX_MUTEX_DESTROY(_mutex) \ 78 qdf_spinlock_destroy(_mutex) 79 80 #define DP_HTT_MAX_SEND_QUEUE_DEPTH 64 81 82 #ifndef HTT_MAC_ADDR_LEN 83 #define HTT_MAC_ADDR_LEN 6 84 #endif 85 86 #define HTT_FRAMECTRL_TYPE_MASK 0x0C 87 #define HTT_GET_FRAME_CTRL_TYPE(_val) \ 88 (((_val) & HTT_FRAMECTRL_TYPE_MASK) >> 2) 89 #define FRAME_CTRL_TYPE_MGMT 0x0 90 #define FRAME_CTRL_TYPE_CTRL 0x1 91 #define FRAME_CTRL_TYPE_DATA 0x2 92 #define FRAME_CTRL_TYPE_RESV 0x3 93 94 #define HTT_FRAMECTRL_DATATYPE 0x08 95 #define HTT_PPDU_DESC_MAX_DEPTH 16 96 #define DP_SCAN_PEER_ID 0xFFFF 97 98 #define DP_HTT_HTC_PKT_MISCLIST_SIZE 256 99 #define HTT_T2H_MAX_MSG_SIZE 2048 100 101 #define HTT_T2H_EXT_STATS_TLV_START_OFFSET 3 102 103 struct dp_htt_htc_pkt { 104 void *soc_ctxt; 105 qdf_dma_addr_t nbuf_paddr; 106 HTC_PACKET htc_pkt; 107 }; 108 109 struct dp_htt_htc_pkt_union { 110 union { 111 struct dp_htt_htc_pkt pkt; 112 struct dp_htt_htc_pkt_union *next; 113 } u; 114 }; 115 116 struct dp_htt_timestamp { 117 long *umac_ttt; 118 long *lmac_ttt; 119 }; 120 121 struct htt_soc { 122 struct cdp_ctrl_objmgr_psoc *ctrl_psoc; 123 struct dp_soc *dp_soc; 124 hal_soc_handle_t hal_soc; 125 struct dp_htt_timestamp pdevid_tt[MAX_PDEV_CNT]; 126 /* htt_logger handle */ 127 struct htt_logger *htt_logger_handle; 128 HTC_HANDLE htc_soc; 129 qdf_device_t osdev; 130 HTC_ENDPOINT_ID htc_endpoint; 131 struct dp_htt_htc_pkt_union *htt_htc_pkt_freelist; 132 struct dp_htt_htc_pkt_union *htt_htc_pkt_misclist; 133 struct { 134 u_int8_t major; 135 u_int8_t minor; 136 } tgt_ver; 137 struct { 138 u_int8_t major; 139 u_int8_t minor; 140 } wifi_ip_ver; 141 142 struct { 143 int htc_err_cnt; 144 int htc_pkt_free; 145 } stats; 146 147 HTT_TX_MUTEX_TYPE htt_tx_mutex; 148 }; 149 150 /** 151 * struct htt_rx_ring_tlv_filter - Rx ring TLV filter 152 * enable/disable. 153 * @mpdu_start: enable/disable MPDU start TLV 154 * @msdu_start: enable/disable MSDU start TLV 155 * @packet: enable/disable PACKET TLV 156 * @msdu_end: enable/disable MSDU end TLV 157 * @mpdu_end: enable/disable MPDU end TLV 158 * @packet_header: enable/disable PACKET header TLV 159 * @attention: enable/disable ATTENTION TLV 160 * @ppdu_start: enable/disable PPDU start TLV 161 * @ppdu_end: enable/disable PPDU end TLV 162 * @ppdu_end_user_stats: enable/disable PPDU user stats TLV 163 * @ppdu_end_user_stats_ext: enable/disable PPDU user stats ext TLV 164 * @ppdu_end_status_done: enable/disable PPDU end status done TLV 165 * @enable_fp: enable/disable FP packet 166 * @enable_md: enable/disable MD packet 167 * @enable_mo: enable/disable MO packet 168 * @enable_mgmt: enable/disable MGMT packet 169 * @enable_ctrl: enable/disable CTRL packet 170 * @enable_data: enable/disable DATA packet 171 * @offset_valid: Flag to indicate if below offsets are valid 172 * @rx_packet_offset: Offset of packet payload 173 * @rx_header_offset: Offset of rx_header tlv 174 * @rx_mpdu_end_offset: Offset of rx_mpdu_end tlv 175 * @rx_mpdu_start_offset: Offset of rx_mpdu_start tlv 176 * @rx_msdu_end_offset: Offset of rx_msdu_end tlv 177 * @rx_msdu_start_offset: Offset of rx_msdu_start tlv 178 * @rx_attn_offset: Offset of rx_attention tlv 179 */ 180 struct htt_rx_ring_tlv_filter { 181 u_int32_t mpdu_start:1, 182 msdu_start:1, 183 packet:1, 184 msdu_end:1, 185 mpdu_end:1, 186 packet_header:1, 187 attention:1, 188 ppdu_start:1, 189 ppdu_end:1, 190 ppdu_end_user_stats:1, 191 ppdu_end_user_stats_ext:1, 192 ppdu_end_status_done:1, 193 header_per_msdu:1, 194 enable_fp:1, 195 enable_md:1, 196 enable_mo:1; 197 u_int32_t fp_mgmt_filter:16, 198 mo_mgmt_filter:16; 199 u_int32_t fp_ctrl_filter:16, 200 mo_ctrl_filter:16; 201 u_int32_t fp_data_filter:16, 202 mo_data_filter:16; 203 u_int16_t md_data_filter; 204 u_int16_t md_mgmt_filter; 205 u_int16_t md_ctrl_filter; 206 bool offset_valid; 207 uint16_t rx_packet_offset; 208 uint16_t rx_header_offset; 209 uint16_t rx_mpdu_end_offset; 210 uint16_t rx_mpdu_start_offset; 211 uint16_t rx_msdu_end_offset; 212 uint16_t rx_msdu_start_offset; 213 uint16_t rx_attn_offset; 214 }; 215 216 /** 217 * struct dp_htt_rx_flow_fst_setup - Rx FST setup message 218 * @pdev_id: DP Pdev identifier 219 * @max_entries: Size of Rx FST in number of entries 220 * @max_search: Number of collisions allowed 221 * @base_addr_lo: lower 32-bit physical address 222 * @base_addr_hi: upper 32-bit physical address 223 * @ip_da_sa_prefix: IPv4 prefix to map to IPv6 address scheme 224 * @hash_key_len: Rx FST hash key size 225 * @hash_key: Rx FST Toeplitz hash key 226 */ 227 struct dp_htt_rx_flow_fst_setup { 228 uint8_t pdev_id; 229 uint32_t max_entries; 230 uint32_t max_search; 231 uint32_t base_addr_lo; 232 uint32_t base_addr_hi; 233 uint32_t ip_da_sa_prefix; 234 uint32_t hash_key_len; 235 uint8_t *hash_key; 236 }; 237 238 /** 239 * enum dp_htt_flow_fst_operation - FST related operations allowed 240 * @DP_HTT_FST_CACHE_OP_NONE: Cache no-op 241 * @DP_HTT_FST_CACHE_INVALIDATE_ENTRY: Invalidate single cache entry 242 * @DP_HTT_FST_CACHE_INVALIDATE_FULL: Invalidate entire cache 243 * @DP_HTT_FST_ENABLE: Bypass FST is enabled 244 * @DP_HTT_FST_DISABLE: Disable bypass FST 245 */ 246 enum dp_htt_flow_fst_operation { 247 DP_HTT_FST_CACHE_OP_NONE, 248 DP_HTT_FST_CACHE_INVALIDATE_ENTRY, 249 DP_HTT_FST_CACHE_INVALIDATE_FULL, 250 DP_HTT_FST_ENABLE, 251 DP_HTT_FST_DISABLE 252 }; 253 254 /** 255 * struct dp_htt_rx_flow_fst_setup - Rx FST setup message 256 * @pdev_id: DP Pdev identifier 257 * @op_code: FST operation to be performed by FW/HW 258 * @rx_flow: Rx Flow information on which operation is to be performed 259 */ 260 struct dp_htt_rx_flow_fst_operation { 261 uint8_t pdev_id; 262 enum dp_htt_flow_fst_operation op_code; 263 struct cdp_rx_flow_info *rx_flow; 264 }; 265 266 /* 267 * htt_soc_initialize() - SOC level HTT initialization 268 * @htt_soc: Opaque htt SOC handle 269 * @ctrl_psoc: Opaque ctrl SOC handle 270 * @htc_soc: SOC level HTC handle 271 * @hal_soc: Opaque HAL SOC handle 272 * @osdev: QDF device 273 * 274 * Return: HTT handle on success; NULL on failure 275 */ 276 void * 277 htt_soc_initialize(struct htt_soc *htt_soc, 278 struct cdp_ctrl_objmgr_psoc *ctrl_psoc, 279 HTC_HANDLE htc_soc, 280 hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev); 281 282 /* 283 * htt_soc_attach() - attach DP and HTT SOC 284 * @soc: DP SOC handle 285 * @htc_hdl: HTC handle 286 * 287 * Return: htt_soc handle on Success, NULL on Failure 288 */ 289 struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_hdl); 290 291 /* 292 * htt_set_htc_handle_() - set HTC handle 293 * @htt_hdl: HTT handle/SOC 294 * @htc_soc: HTC handle 295 * 296 * Return: None 297 */ 298 void htt_set_htc_handle(struct htt_soc *htt_hdl, HTC_HANDLE htc_soc); 299 300 /* 301 * htt_get_htc_handle_() - set HTC handle 302 * @htt_hdl: HTT handle/SOC 303 * 304 * Return: HTC_HANDLE 305 */ 306 HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_hdl); 307 308 /* 309 * htt_soc_htc_dealloc() - HTC memory de-alloc 310 * @htt_soc: SOC level HTT handle 311 * 312 * Return: None 313 */ 314 void htt_soc_htc_dealloc(struct htt_soc *htt_handle); 315 316 /* 317 * htt_soc_htc_prealloc() - HTC memory prealloc 318 * @htt_soc: SOC level HTT handle 319 * 320 * Return: QDF_STATUS_SUCCESS on success or 321 * QDF_STATUS_E_NO_MEM on allocation failure 322 */ 323 QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *htt_soc); 324 325 void htt_soc_detach(struct htt_soc *soc); 326 327 int htt_srng_setup(struct htt_soc *htt_soc, int pdev_id, 328 hal_ring_handle_t hal_ring_hdl, 329 int hal_ring_type); 330 331 int htt_soc_attach_target(struct htt_soc *htt_soc); 332 333 /* 334 * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter 335 * config message to target 336 * @htt_soc: HTT SOC handle 337 * @pdev_id: PDEV Id 338 * @hal_srng: Opaque HAL SRNG pointer 339 * @hal_ring_type: SRNG ring type 340 * @ring_buf_size: SRNG buffer size 341 * @htt_tlv_filter: Rx SRNG TLV and filter setting 342 * 343 * Return: 0 on success; error code on failure 344 */ 345 int htt_h2t_rx_ring_cfg(struct htt_soc *htt_soc, int pdev_id, 346 hal_ring_handle_t hal_ring_hdl, 347 int hal_ring_type, int ring_buf_size, 348 struct htt_rx_ring_tlv_filter *htt_tlv_filter); 349 350 /* 351 * htt_t2h_stats_handler() - target to host stats work handler 352 * @context: context (dp soc context) 353 * 354 * Return: void 355 */ 356 void htt_t2h_stats_handler(void *context); 357 358 /** 359 * struct htt_stats_context - htt stats information 360 * @soc: Size of each descriptor in the pool 361 * @msg: T2H Ext stats message queue 362 * @msg_len: T2H Ext stats message length 363 */ 364 struct htt_stats_context { 365 struct dp_soc *soc; 366 qdf_nbuf_queue_t msg; 367 uint32_t msg_len; 368 }; 369 370 int 371 dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(uint32_t bitmap); 372 373 /** 374 * dp_ppdu_desc_user_stats_update(): Function to update TX user stats 375 * @pdev: DP pdev handle 376 * @ppdu_info: per PPDU TLV descriptor 377 * 378 * return: void 379 */ 380 void 381 dp_ppdu_desc_user_stats_update(struct dp_pdev *pdev, 382 struct ppdu_info *ppdu_info); 383 384 /** 385 * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW 386 * @pdev: DP pdev handle 387 * @fse_setup_info: FST setup parameters 388 * 389 * Return: Success when HTT message is sent, error on failure 390 */ 391 QDF_STATUS 392 dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev, 393 struct dp_htt_rx_flow_fst_setup *setup_info); 394 395 /** 396 * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to 397 * add/del a flow in HW 398 * @pdev: DP pdev handle 399 * @fse_op_info: Flow entry parameters 400 * 401 * Return: Success when HTT message is sent, error on failure 402 */ 403 QDF_STATUS 404 dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev, 405 struct dp_htt_rx_flow_fst_operation *op_info); 406 #endif /* _DP_HTT_H_ */ 407