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 /* 104 * Below offset are based on htt_ppdu_stats_common_tlv 105 * defined in htt_ppdu_stats.h 106 */ 107 #define HTT_PPDU_STATS_COMMON_TLV_TLV_HDR_OFFSET 0 108 #define HTT_PPDU_STATS_COMMON_TLV_PPDU_ID_OFFSET 1 109 #define HTT_PPDU_STATS_COMMON_TLV_RING_ID_SCH_CMD_ID_OFFSET 2 110 #define HTT_PPDU_STATS_COMMON_TLV_QTYPE_FRM_TYPE_OFFSET 3 111 #define HTT_PPDU_STATS_COMMON_TLV_CHAIN_MASK_OFFSET 4 112 #define HTT_PPDU_STATS_COMMON_TLV_FES_DUR_US_OFFSET 5 113 #define HTT_PPDU_STATS_COMMON_TLV_SCH_EVAL_START_TSTMP_L32_US_OFFSET 6 114 #define HTT_PPDU_STATS_COMMON_TLV_SCH_END_TSTMP_US_OFFSET 7 115 #define HTT_PPDU_STATS_COMMON_TLV_START_TSTMP_L32_US_OFFSET 8 116 #define HTT_PPDU_STATS_COMMON_TLV_CHAN_MHZ_PHY_MODE_OFFSET 9 117 #define HTT_PPDU_STATS_COMMON_TLV_CCA_DELTA_TIME_US_OFFSET 10 118 #define HTT_PPDU_STATS_COMMON_TLV_RXFRM_DELTA_TIME_US_OFFSET 11 119 #define HTT_PPDU_STATS_COMMON_TLV_TXFRM_DELTA_TIME_US_OFFSET 12 120 #define HTT_PPDU_STATS_COMMON_TLV_RESV_NUM_UL_BEAM_OFFSET 13 121 #define HTT_PPDU_STATS_COMMON_TLV_START_TSTMP_U32_US_OFFSET 14 122 123 /* get index for field in htt_ppdu_stats_common_tlv */ 124 #define HTT_GET_STATS_CMN_INDEX(index) \ 125 HTT_PPDU_STATS_COMMON_TLV_##index##_OFFSET 126 127 struct dp_htt_htc_pkt { 128 void *soc_ctxt; 129 qdf_dma_addr_t nbuf_paddr; 130 HTC_PACKET htc_pkt; 131 }; 132 133 struct dp_htt_htc_pkt_union { 134 union { 135 struct dp_htt_htc_pkt pkt; 136 struct dp_htt_htc_pkt_union *next; 137 } u; 138 }; 139 140 struct dp_htt_timestamp { 141 long *umac_ttt; 142 long *lmac_ttt; 143 }; 144 145 struct htt_soc { 146 struct cdp_ctrl_objmgr_psoc *ctrl_psoc; 147 struct dp_soc *dp_soc; 148 hal_soc_handle_t hal_soc; 149 struct dp_htt_timestamp pdevid_tt[MAX_PDEV_CNT]; 150 /* htt_logger handle */ 151 struct htt_logger *htt_logger_handle; 152 HTC_HANDLE htc_soc; 153 qdf_device_t osdev; 154 HTC_ENDPOINT_ID htc_endpoint; 155 struct dp_htt_htc_pkt_union *htt_htc_pkt_freelist; 156 struct dp_htt_htc_pkt_union *htt_htc_pkt_misclist; 157 struct { 158 u_int8_t major; 159 u_int8_t minor; 160 } tgt_ver; 161 struct { 162 u_int8_t major; 163 u_int8_t minor; 164 } wifi_ip_ver; 165 166 struct { 167 int htc_err_cnt; 168 int htc_pkt_free; 169 } stats; 170 171 HTT_TX_MUTEX_TYPE htt_tx_mutex; 172 }; 173 174 /** 175 * struct htt_rx_ring_tlv_filter - Rx ring TLV filter 176 * enable/disable. 177 * @mpdu_start: enable/disable MPDU start TLV 178 * @msdu_start: enable/disable MSDU start TLV 179 * @packet: enable/disable PACKET TLV 180 * @msdu_end: enable/disable MSDU end TLV 181 * @mpdu_end: enable/disable MPDU end TLV 182 * @packet_header: enable/disable PACKET header TLV 183 * @attention: enable/disable ATTENTION TLV 184 * @ppdu_start: enable/disable PPDU start TLV 185 * @ppdu_end: enable/disable PPDU end TLV 186 * @ppdu_end_user_stats: enable/disable PPDU user stats TLV 187 * @ppdu_end_user_stats_ext: enable/disable PPDU user stats ext TLV 188 * @ppdu_end_status_done: enable/disable PPDU end status done TLV 189 * @enable_fp: enable/disable FP packet 190 * @enable_md: enable/disable MD packet 191 * @enable_mo: enable/disable MO packet 192 * @enable_mgmt: enable/disable MGMT packet 193 * @enable_ctrl: enable/disable CTRL packet 194 * @enable_data: enable/disable DATA packet 195 * @offset_valid: Flag to indicate if below offsets are valid 196 * @rx_packet_offset: Offset of packet payload 197 * @rx_header_offset: Offset of rx_header tlv 198 * @rx_mpdu_end_offset: Offset of rx_mpdu_end tlv 199 * @rx_mpdu_start_offset: Offset of rx_mpdu_start tlv 200 * @rx_msdu_end_offset: Offset of rx_msdu_end tlv 201 * @rx_msdu_start_offset: Offset of rx_msdu_start tlv 202 * @rx_attn_offset: Offset of rx_attention tlv 203 */ 204 struct htt_rx_ring_tlv_filter { 205 u_int32_t mpdu_start:1, 206 msdu_start:1, 207 packet:1, 208 msdu_end:1, 209 mpdu_end:1, 210 packet_header:1, 211 attention:1, 212 ppdu_start:1, 213 ppdu_end:1, 214 ppdu_end_user_stats:1, 215 ppdu_end_user_stats_ext:1, 216 ppdu_end_status_done:1, 217 header_per_msdu:1, 218 enable_fp:1, 219 enable_md:1, 220 enable_mo:1; 221 u_int32_t fp_mgmt_filter:16, 222 mo_mgmt_filter:16; 223 u_int32_t fp_ctrl_filter:16, 224 mo_ctrl_filter:16; 225 u_int32_t fp_data_filter:16, 226 mo_data_filter:16; 227 u_int16_t md_data_filter; 228 u_int16_t md_mgmt_filter; 229 u_int16_t md_ctrl_filter; 230 bool offset_valid; 231 uint16_t rx_packet_offset; 232 uint16_t rx_header_offset; 233 uint16_t rx_mpdu_end_offset; 234 uint16_t rx_mpdu_start_offset; 235 uint16_t rx_msdu_end_offset; 236 uint16_t rx_msdu_start_offset; 237 uint16_t rx_attn_offset; 238 }; 239 240 /** 241 * struct dp_htt_rx_flow_fst_setup - Rx FST setup message 242 * @pdev_id: DP Pdev identifier 243 * @max_entries: Size of Rx FST in number of entries 244 * @max_search: Number of collisions allowed 245 * @base_addr_lo: lower 32-bit physical address 246 * @base_addr_hi: upper 32-bit physical address 247 * @ip_da_sa_prefix: IPv4 prefix to map to IPv6 address scheme 248 * @hash_key_len: Rx FST hash key size 249 * @hash_key: Rx FST Toeplitz hash key 250 */ 251 struct dp_htt_rx_flow_fst_setup { 252 uint8_t pdev_id; 253 uint32_t max_entries; 254 uint32_t max_search; 255 uint32_t base_addr_lo; 256 uint32_t base_addr_hi; 257 uint32_t ip_da_sa_prefix; 258 uint32_t hash_key_len; 259 uint8_t *hash_key; 260 }; 261 262 /** 263 * enum dp_htt_flow_fst_operation - FST related operations allowed 264 * @DP_HTT_FST_CACHE_OP_NONE: Cache no-op 265 * @DP_HTT_FST_CACHE_INVALIDATE_ENTRY: Invalidate single cache entry 266 * @DP_HTT_FST_CACHE_INVALIDATE_FULL: Invalidate entire cache 267 * @DP_HTT_FST_ENABLE: Bypass FST is enabled 268 * @DP_HTT_FST_DISABLE: Disable bypass FST 269 */ 270 enum dp_htt_flow_fst_operation { 271 DP_HTT_FST_CACHE_OP_NONE, 272 DP_HTT_FST_CACHE_INVALIDATE_ENTRY, 273 DP_HTT_FST_CACHE_INVALIDATE_FULL, 274 DP_HTT_FST_ENABLE, 275 DP_HTT_FST_DISABLE 276 }; 277 278 /** 279 * struct dp_htt_rx_flow_fst_setup - Rx FST setup message 280 * @pdev_id: DP Pdev identifier 281 * @op_code: FST operation to be performed by FW/HW 282 * @rx_flow: Rx Flow information on which operation is to be performed 283 */ 284 struct dp_htt_rx_flow_fst_operation { 285 uint8_t pdev_id; 286 enum dp_htt_flow_fst_operation op_code; 287 struct cdp_rx_flow_info *rx_flow; 288 }; 289 290 /* 291 * htt_soc_initialize() - SOC level HTT initialization 292 * @htt_soc: Opaque htt SOC handle 293 * @ctrl_psoc: Opaque ctrl SOC handle 294 * @htc_soc: SOC level HTC handle 295 * @hal_soc: Opaque HAL SOC handle 296 * @osdev: QDF device 297 * 298 * Return: HTT handle on success; NULL on failure 299 */ 300 void * 301 htt_soc_initialize(struct htt_soc *htt_soc, 302 struct cdp_ctrl_objmgr_psoc *ctrl_psoc, 303 HTC_HANDLE htc_soc, 304 hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev); 305 306 /* 307 * htt_soc_attach() - attach DP and HTT SOC 308 * @soc: DP SOC handle 309 * @htc_hdl: HTC handle 310 * 311 * Return: htt_soc handle on Success, NULL on Failure 312 */ 313 struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_hdl); 314 315 /* 316 * htt_set_htc_handle_() - set HTC handle 317 * @htt_hdl: HTT handle/SOC 318 * @htc_soc: HTC handle 319 * 320 * Return: None 321 */ 322 void htt_set_htc_handle(struct htt_soc *htt_hdl, HTC_HANDLE htc_soc); 323 324 /* 325 * htt_get_htc_handle_() - set HTC handle 326 * @htt_hdl: HTT handle/SOC 327 * 328 * Return: HTC_HANDLE 329 */ 330 HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_hdl); 331 332 /* 333 * htt_soc_htc_dealloc() - HTC memory de-alloc 334 * @htt_soc: SOC level HTT handle 335 * 336 * Return: None 337 */ 338 void htt_soc_htc_dealloc(struct htt_soc *htt_handle); 339 340 /* 341 * htt_soc_htc_prealloc() - HTC memory prealloc 342 * @htt_soc: SOC level HTT handle 343 * 344 * Return: QDF_STATUS_SUCCESS on success or 345 * QDF_STATUS_E_NO_MEM on allocation failure 346 */ 347 QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *htt_soc); 348 349 void htt_soc_detach(struct htt_soc *soc); 350 351 int htt_srng_setup(struct htt_soc *htt_soc, int pdev_id, 352 hal_ring_handle_t hal_ring_hdl, 353 int hal_ring_type); 354 355 int htt_soc_attach_target(struct htt_soc *htt_soc); 356 357 /* 358 * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter 359 * config message to target 360 * @htt_soc: HTT SOC handle 361 * @pdev_id: PDEV Id 362 * @hal_srng: Opaque HAL SRNG pointer 363 * @hal_ring_type: SRNG ring type 364 * @ring_buf_size: SRNG buffer size 365 * @htt_tlv_filter: Rx SRNG TLV and filter setting 366 * 367 * Return: 0 on success; error code on failure 368 */ 369 int htt_h2t_rx_ring_cfg(struct htt_soc *htt_soc, int pdev_id, 370 hal_ring_handle_t hal_ring_hdl, 371 int hal_ring_type, int ring_buf_size, 372 struct htt_rx_ring_tlv_filter *htt_tlv_filter); 373 374 /* 375 * htt_t2h_stats_handler() - target to host stats work handler 376 * @context: context (dp soc context) 377 * 378 * Return: void 379 */ 380 void htt_t2h_stats_handler(void *context); 381 382 /** 383 * struct htt_stats_context - htt stats information 384 * @soc: Size of each descriptor in the pool 385 * @msg: T2H Ext stats message queue 386 * @msg_len: T2H Ext stats message length 387 */ 388 struct htt_stats_context { 389 struct dp_soc *soc; 390 qdf_nbuf_queue_t msg; 391 uint32_t msg_len; 392 }; 393 394 int 395 dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(uint32_t bitmap); 396 397 /** 398 * dp_ppdu_desc_user_stats_update(): Function to update TX user stats 399 * @pdev: DP pdev handle 400 * @ppdu_info: per PPDU TLV descriptor 401 * 402 * return: void 403 */ 404 void 405 dp_ppdu_desc_user_stats_update(struct dp_pdev *pdev, 406 struct ppdu_info *ppdu_info); 407 408 /** 409 * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW 410 * @pdev: DP pdev handle 411 * @fse_setup_info: FST setup parameters 412 * 413 * Return: Success when HTT message is sent, error on failure 414 */ 415 QDF_STATUS 416 dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev, 417 struct dp_htt_rx_flow_fst_setup *setup_info); 418 419 /** 420 * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to 421 * add/del a flow in HW 422 * @pdev: DP pdev handle 423 * @fse_op_info: Flow entry parameters 424 * 425 * Return: Success when HTT message is sent, error on failure 426 */ 427 QDF_STATUS 428 dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev, 429 struct dp_htt_rx_flow_fst_operation *op_info); 430 #endif /* _DP_HTT_H_ */ 431