1 /* 2 * Copyright (c) 2024 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /** 8 * @file 9 * @addtogroup nrf_wifi_fw_if Wi-Fi driver and firmware interface 10 * @{ 11 * @brief Common structures and definitions. 12 */ 13 14 #ifndef __LMAC_IF_COMMON__ 15 #define __LMAC_IF_COMMON__ 16 17 #include "common/rpu_if.h" 18 #include "common/phy_rf_params_common.h" 19 #include "common/pack_def.h" 20 21 #define RPU_MEM_LMAC_BOOT_SIG 0xB7000D50 22 #define RPU_MEM_LMAC_VER 0xB7000D54 23 24 #define RPU_MEM_LMAC_PATCH_BIN 0x80043A80 25 #define RPU_MEM_LMAC_PATCH_BIMG 0x8004BC00 26 27 #define NRF_WIFI_LMAC_VER(ver) ((ver & 0xFF000000) >> 24) 28 #define NRF_WIFI_LMAC_VER_MAJ(ver) ((ver & 0x00FF0000) >> 16) 29 #define NRF_WIFI_LMAC_VER_MIN(ver) ((ver & 0x0000FF00) >> 8) 30 #define NRF_WIFI_LMAC_VER_EXTRA(ver) (ver & 0x000000FF) 31 32 #define NRF_WIFI_LMAC_BOOT_SIG 0x5A5A5A5A 33 #define NRF_WIFI_LMAC_ROM_PATCH_OFFSET (RPU_MEM_LMAC_PATCH_BIMG - RPU_ADDR_LMAC_CORE_RET_START) 34 #define NRF_WIFI_LMAC_BOOT_EXCP_VECT_0 0x3c1a8000 35 #define NRF_WIFI_LMAC_BOOT_EXCP_VECT_1 0x275a0000 36 #define NRF_WIFI_LMAC_BOOT_EXCP_VECT_2 0x03400008 37 #define NRF_WIFI_LMAC_BOOT_EXCP_VECT_3 0x00000000 38 39 #define NRF_WIFI_LMAC_MAX_RX_BUFS 256 40 41 #define HW_SLEEP_ENABLE 2 42 #define SW_SLEEP_ENABLE 1 43 #define SLEEP_DISABLE 0 44 #define HW_DELAY 7300 45 #define SW_DELAY 5000 46 #define BCN_TIMEOUT 20000 47 #define CALIB_SLEEP_CLOCK_ENABLE 1 48 49 #define ACTIVE_SCAN_DURATION 50 50 #define PASSIVE_SCAN_DURATION 130 51 #define WORKING_CH_SCAN_DURATION 50 52 #define CHNL_PROBE_CNT 2 53 54 #define PKT_TYPE_MPDU 0 55 #define PKT_TYPE_MSDU_WITH_MAC 1 56 #define PKT_TYPE_MSDU 2 57 58 #define NRF_WIFI_RPU_PWR_STATUS_SUCCESS 0 59 #define NRF_WIFI_RPU_PWR_STATUS_FAIL -1 60 61 /** 62 * struct lmac_prod_stats : used to get the production mode stats 63 **/ 64 65 /* Events */ 66 #define MAX_RSSI_SAMPLES 10 67 struct lmac_prod_stats { 68 /*Structure that holds all the debug information in LMAC*/ 69 unsigned int reset_cmd_cnt; 70 unsigned int reset_complete_event_cnt; 71 unsigned int unable_gen_event; 72 unsigned int ch_prog_cmd_cnt; 73 unsigned int channel_prog_done; 74 unsigned int tx_pkt_cnt; 75 unsigned int tx_pkt_done_cnt; 76 unsigned int scan_pkt_cnt; 77 unsigned int internal_pkt_cnt; 78 unsigned int internal_pkt_done_cnt; 79 unsigned int ack_resp_cnt; 80 unsigned int tx_timeout; 81 unsigned int deagg_isr; 82 unsigned int deagg_inptr_desc_empty; 83 unsigned int deagg_circular_buffer_full; 84 unsigned int lmac_rxisr_cnt; 85 unsigned int rx_decryptcnt; 86 unsigned int process_decrypt_fail; 87 unsigned int prepa_rx_event_fail; 88 unsigned int rx_core_pool_full_cnt; 89 unsigned int rx_mpdu_crc_success_cnt; 90 unsigned int rx_mpdu_crc_fail_cnt; 91 unsigned int rx_ofdm_crc_success_cnt; 92 unsigned int rx_ofdm_crc_fail_cnt; 93 unsigned int rxDSSSCrcSuccessCnt; 94 unsigned int rxDSSSCrcFailCnt; 95 unsigned int rx_crypto_start_cnt; 96 unsigned int rx_crypto_done_cnt; 97 unsigned int rx_event_buf_full; 98 unsigned int rx_extram_buf_full; 99 unsigned int scan_req; 100 unsigned int scan_complete; 101 unsigned int scan_abort_req; 102 unsigned int scan_abort_complete; 103 unsigned int internal_buf_pool_null; 104 }; 105 106 /** 107 * struct phy_prod_stats : used to get the production mode stats 108 **/ 109 struct phy_prod_stats { 110 unsigned int ofdm_crc32_pass_cnt; 111 unsigned int ofdm_crc32_fail_cnt; 112 unsigned int dsss_crc32_pass_cnt; 113 unsigned int dsss_crc32_fail_cnt; 114 char averageRSSI; 115 }; 116 117 union rpu_stats { 118 struct lmac_prod_stats lmac_stats; 119 struct phy_prod_stats phy_stats; 120 }; 121 122 struct hpqm_queue { 123 unsigned int pop_addr; 124 unsigned int push_addr; 125 unsigned int id_num; 126 unsigned int status_addr; 127 unsigned int status_mask; 128 } __NRF_WIFI_PKD; 129 130 struct INT_HPQ { 131 unsigned int id; 132 /* The head and tail values are relative 133 * to the start of the 134 * HWQM register block. 135 */ 136 unsigned int head; 137 unsigned int tail; 138 } __NRF_WIFI_PKD; 139 140 /** 141 * @brief LMAC firmware config params 142 * 143 */ 144 struct lmac_fw_config_params { 145 /** lmac firmware boot status. LMAC will set to 0x5a5a5a5a after completing boot process */ 146 unsigned int boot_status; 147 /** LMAC version */ 148 unsigned int version; 149 /** Address to resubmit Rx buffers */ 150 unsigned int lmac_rx_buffer_addr; 151 /** Maximum Rx descriptors */ 152 unsigned int lmac_rx_max_desc_cnt; 153 /** size of each descriptor size */ 154 unsigned int lmac_rx_desc_size; 155 /** rpu config name. this is a string */ 156 unsigned char rpu_config_name[16]; 157 /** rpu config number */ 158 unsigned char rpu_config_number[8]; 159 /** numRX */ 160 unsigned int numRX; 161 /** numTX */ 162 unsigned int numTX; 163 #define FREQ_2_4_GHZ 1 164 #define FREQ_5_GHZ 2 165 /** supported bands */ 166 unsigned int bands; 167 /** system frequency */ 168 unsigned int sys_frequency_in_mhz; 169 /** queue which contains Free GRAM pointers for commands */ 170 struct hpqm_queue FreeCmdPtrQ; 171 /** Command pointer queue. Host should pick pointer from FreeCmdPtrQ, populate 172 * command into that address and submit back to this queue for RPU 173 */ 174 struct hpqm_queue cmdPtrQ; 175 /** queue which contains Free GRAM pointers for events */ 176 struct hpqm_queue eventPtrQ; 177 /** Event pointer queue. Host should pick pointer from FreeCmdPtrQ, populate 178 * command into that address and submit back to this queue for RPU 179 */ 180 struct hpqm_queue freeEventPtrQ; 181 /** Rx buffer queue */ 182 struct hpqm_queue SKBGramPtrQ_1; 183 /** Rx buffer queue */ 184 struct hpqm_queue SKBGramPtrQ_2; 185 /** Rx buffer queue */ 186 struct hpqm_queue SKBGramPtrQ_3; 187 /** lmac register address to enable ISR to Host */ 188 unsigned int HP_lmac_to_host_isr_en; 189 /** Address to Clear host ISR */ 190 unsigned int HP_lmac_to_host_isr_clear; 191 /** Address to set ISR to lmac Clear host ISR */ 192 unsigned int HP_set_lmac_isr; 193 194 #define NUM_32_QUEUES 4 195 /** Hardware queues */ 196 struct INT_HPQ hpq32[NUM_32_QUEUES]; 197 198 } __NRF_WIFI_PKD; 199 200 #define MAX_NUM_OF_RX_QUEUES 3 201 202 struct rx_buf_pool_params { 203 /** buffer size */ 204 unsigned short buf_sz; 205 /** number of buffers */ 206 unsigned short num_bufs; 207 } __NRF_WIFI_PKD; 208 209 struct temp_vbat_config { 210 unsigned int temp_based_calib_en; 211 unsigned int temp_calib_bitmap; 212 unsigned int vbat_calibp_bitmap; 213 unsigned int temp_vbat_mon_period; 214 int vth_very_low; 215 int vth_low; 216 int vth_hi; 217 int temp_threshold; 218 int vbat_threshold; 219 } __NRF_WIFI_PKD; 220 /** 221 * @} 222 */ 223 #endif 224