1 /* 2 * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 /** 16 * rwnx_utils.h 17 */ 18 #ifndef _RWNX_UTILS_H_ 19 #define _RWNX_UTILS_H_ 20 21 #include "wifi_ipc_shared.h" 22 #include "dbg.h" 23 24 #if PLF_WIFI_AUDIO 25 #define FRAMES_11MBPS_ENABLED (1) 26 #else 27 #define FRAMES_11MBPS_ENABLED (0) 28 #endif 29 30 typedef uint32_t (*patch_tbl_array_t)[2]; 31 32 extern patch_tbl_array_t patch_tbl; 33 extern patch_tbl_array_t patch_tbl_func; 34 extern uint32_t *patch_func; 35 extern uint32_t patch_tbl_size; 36 extern uint32_t patch_tbl_func_size; 37 extern uint32_t patch_func_size; 38 extern uint32_t aon_patch_start_addr; 39 extern uint32_t aon_patch_num; 40 extern uint32_t patch_store_addr; 41 extern uint32_t fw_patch_addr; 42 43 #define TRACE_NONE(fmt, ...) 44 45 #define RWNX_DBG TRACE_NONE 46 #define RWNX_FN_ENTRY_STR ">>> %s()\n", __func__ 47 48 enum rwnx_dev_flag { 49 RWNX_DEV_RESTARTING, 50 RWNX_DEV_STACK_RESTARTING, 51 RWNX_DEV_STARTED, 52 }; 53 54 extern struct co_list rx_buffer_free_list; 55 enum ipc_rx_buffer_status { 56 RX_BUFFER_PUSHED = 0, 57 RX_BUFFER_FREE = 0x5A5A5A5A, 58 RX_BUFFER_READY = RX_DMA_OVER_PATTERN, 59 RX_UF_VEC_VALID_PATTERN = 0x0000C0DE, 60 }; 61 62 struct rwnx_hw; 63 typedef uint32_t dma_addr_t; 64 65 /// 802.11 Status Code 66 #define MAC_ST_SUCCESSFUL 0 67 #define MAC_ST_FAILURE 1 68 #define MAC_ST_RESERVED 2 69 #define MAC_ST_CAPA_NOT_SUPPORTED 10 70 #define MAC_ST_REASSOC_NOT_ASSOC 11 71 #define MAC_ST_ASSOC_DENIED 12 72 #define MAC_ST_AUTH_ALGO_NOT_SUPPORTED 13 73 #define MAC_ST_AUTH_FRAME_WRONG_SEQ 14 74 #define MAC_ST_AUTH_CHALLENGE_FAILED 15 75 #define MAC_ST_AUTH_TIMEOUT 16 76 #define MAC_ST_ASSOC_TOO_MANY_STA 17 77 #define MAC_ST_ASSOC_RATES_NOT_SUPPORTED 18 78 #define MAC_ST_ASSOC_PREAMBLE_NOT_SUPPORTED 19 79 80 #define MAC_ST_ASSOC_SPECTRUM_REQUIRED 22 81 #define MAC_ST_ASSOC_POWER_CAPA 23 82 #define MAC_ST_ASSOC_SUPPORTED_CHANNEL 24 83 #define MAC_ST_ASSOC_SLOT_NOT_SUPPORTED 25 84 85 #define MAC_ST_REFUSED_TEMPORARILY 30 86 #define MAC_ST_INVALID_MFP_POLICY 31 87 88 #define MAC_ST_INVALID_IE 40 // draft 7.0 extention 89 #define MAC_ST_GROUP_CIPHER_INVALID 41 // draft 7.0 extention 90 #define MAC_ST_PAIRWISE_CIPHER_INVALID 42 // draft 7.0 extention 91 #define MAC_ST_AKMP_INVALID 43 // draft 7.0 extention 92 #define MAC_ST_UNSUPPORTED_RSNE_VERSION 44 // draft 7.0 extention 93 #define MAC_ST_INVALID_RSNE_CAPA 45 // draft 7.0 extention 94 #define MAC_ST_CIPHER_SUITE_REJECTED 46 // draft 7.0 extention 95 /** @} */ 96 97 /** 98 * struct rwnx_ipc_elem - Generic IPC buffer of fixed size 99 * 100 * @addr: Host address of the buffer. 101 * @dma_addr: DMA address of the buffer. 102 */ 103 struct rwnx_ipc_elem { 104 //void *addr; 105 dma_addr_t dma_addr; 106 }; 107 struct rwnx_ipc_host_elem { 108 struct co_list_hdr hdr; 109 uint32_t addr; 110 }; 111 /** 112 * struct rwnx_ipc_elem_pool - Generic pool of IPC buffers of fixed size 113 * 114 * @nb: Number of buffers currenlty allocated in the pool 115 * @buf: Array of buffers (size of array is @nb) 116 * @pool: DMA pool in which buffers have been allocated 117 */ 118 struct rwnx_ipc_elem_pool { 119 int nb; 120 //struct rwnx_ipc_elem *buf; 121 struct rwnx_ipc_elem buf[IPC_MSGE2A_BUF_CNT]; 122 //struct dma_pool *pool; 123 }; 124 125 /** 126 * struct rwnx_ipc_elem - Generic IPC buffer of variable size 127 * 128 * @addr: Host address of the buffer. 129 * @dma_addr: DMA address of the buffer. 130 * @size: Size, in bytes, of the buffer 131 */ 132 struct rwnx_ipc_elem_var { 133 void *addr; 134 dma_addr_t dma_addr; 135 size_t size; 136 }; 137 138 #if 1//def CONFIG_RWNX_FULLMAC 139 140 /** 141 * struct rwnx_skb_cb - Control Buffer structure for RX buffer 142 * 143 * @dma_addr: DMA address of the data buffer 144 * @pattern: Known pattern (used to check pointer on skb) 145 * @idx: Index in &struct rwnx_hw.rxbuff_table that contains address of this 146 * buffer 147 */ 148 struct rwnx_skb_cb { 149 dma_addr_t dma_addr; 150 uint32_t pattern; 151 uint32_t idx; 152 }; 153 #endif /* CONFIG_RWNX_FULLMAC */ 154 155 void *rwnx_ipc_fw_trace_desc_get(struct rwnx_hw *rwnx_hw); 156 157 void rwnx_ipc_deinit(struct rwnx_hw *rwnx_hw); 158 int rwnx_check_ipc_txbuf(void); 159 uint32_t rwnx_tx_post_list_cnt(void); 160 161 struct ipc_host_env_tag; 162 163 int rwnx_ipc_rxbuf_init(struct rwnx_hw *rwnx_hw); 164 165 void wifi_aon_launch(void); 166 167 #if PLF_RSSI_DATAPKT 168 int8_t data_pkt_rssi_get(void); 169 #endif /* PLF_RSSI_DATAPKT */ 170 171 #ifdef CFG_WIFI_ENGINEERING_MODE 172 void wifi_engineering_mode_channel_index_set(uint8_t index); 173 uint8_t wifi_engineering_mode_channel_index_get(void); 174 bool wifi_engineering_mode_status_get(void); 175 void wifi_engineering_mode_status_set(bool flag); 176 #endif /* CFG_WIFI_ENGINEERING_MODE */ 177 #endif /* _RWNX_UTILS_H_ */ 178