1 /* 2 * Copyright (c) 2024 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @brief Header containing FMAC interface specific declarations for the 9 * Zephyr OS layer of the Wi-Fi driver. 10 */ 11 12 #ifndef __ZEPHYR_FMAC_MAIN_H__ 13 #define __ZEPHYR_FMAC_MAIN_H__ 14 15 #include <stdio.h> 16 17 #include <version.h> 18 19 #include <zephyr/kernel.h> 20 #include <zephyr/net/net_if.h> 21 #ifndef CONFIG_NRF70_RADIO_TEST 22 #include <zephyr/net/wifi_mgmt.h> 23 #include <zephyr/net/ethernet.h> 24 #ifdef CONFIG_NETWORKING 25 #include <net_if.h> 26 #endif /* CONFIG_NETWORKING */ 27 #ifdef CONFIG_NRF70_STA_MODE 28 #include <drivers/driver_zephyr.h> 29 #endif /* CONFIG_NRF70_STA_MODE */ 30 #include <system/fmac_api.h> 31 #else 32 #include <radio_test/fmac_api.h> 33 #endif /* !CONFIG_NRF70_RADIO_TEST */ 34 35 #include <host_rpu_umac_if.h> 36 37 #define NRF70_DRIVER_VERSION "1."KERNEL_VERSION_STRING 38 39 #ifndef CONFIG_NRF70_OFFLOADED_RAW_TX 40 #ifndef CONFIG_NRF70_RADIO_TEST 41 struct nrf_wifi_vif_ctx_zep { 42 const struct device *zep_dev_ctx; 43 struct net_if *zep_net_if_ctx; 44 void *supp_drv_if_ctx; 45 void *rpu_ctx_zep; 46 unsigned char vif_idx; 47 struct k_mutex vif_lock; 48 49 scan_result_cb_t disp_scan_cb; 50 bool scan_in_progress; 51 int scan_type; 52 uint16_t max_bss_cnt; 53 unsigned int scan_res_cnt; 54 struct k_work_delayable scan_timeout_work; 55 56 struct net_eth_addr mac_addr; 57 int if_type; 58 char ifname[16]; 59 enum nrf_wifi_fmac_if_op_state if_op_state; 60 bool set_if_event_received; 61 int set_if_status; 62 #ifdef CONFIG_NET_STATISTICS_ETHERNET 63 struct net_stats_eth eth_stats; 64 #endif /* CONFIG_NET_STATISTICS_ETHERNET */ 65 #ifdef CONFIG_NRF70_STA_MODE 66 unsigned int assoc_freq; 67 enum nrf_wifi_fmac_if_carr_state if_carr_state; 68 struct wpa_signal_info *signal_info; 69 struct wpa_conn_info *conn_info; 70 struct zep_wpa_supp_dev_callbk_fns supp_callbk_fns; 71 unsigned char twt_flows_map; 72 unsigned char twt_flow_in_progress_map; 73 struct wifi_ps_config *ps_info; 74 bool ps_config_info_evnt; 75 bool authorized; 76 bool cookie_resp_received; 77 #ifdef CONFIG_NRF70_DATA_TX 78 struct k_work nrf_wifi_net_iface_work; 79 #endif /* CONFIG_NRF70_DATA_TX */ 80 unsigned long rssi_record_timestamp_us; 81 signed short rssi; 82 #endif /* CONFIG_NRF70_STA_MODE */ 83 #ifdef CONFIG_NRF70_AP_MODE 84 int inactive_time_sec; 85 #endif /* CONFIG_NRF70_AP_MODE */ 86 #ifdef CONFIG_NRF_WIFI_RPU_RECOVERY 87 struct k_work nrf_wifi_rpu_recovery_work; 88 #endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */ 89 int rts_threshold_value; 90 }; 91 92 struct nrf_wifi_vif_ctx_map { 93 const char *ifname; 94 struct nrf_wifi_vif_ctx_zep *vif_ctx; 95 }; 96 #endif /* !CONFIG_NRF70_RADIO_TEST */ 97 98 struct nrf_wifi_ctx_zep { 99 void *drv_priv_zep; 100 void *rpu_ctx; 101 #ifdef CONFIG_NRF70_RADIO_TEST 102 struct rpu_conf_params conf_params; 103 bool rf_test_run; 104 unsigned char rf_test; 105 #else /* CONFIG_NRF70_RADIO_TEST */ 106 struct nrf_wifi_vif_ctx_zep vif_ctx_zep[MAX_NUM_VIFS]; 107 #ifdef CONFIG_NRF70_UTIL 108 struct rpu_conf_params conf_params; 109 #endif /* CONFIG_NRF70_UTIL */ 110 #endif /* CONFIG_NRF70_RADIO_TEST */ 111 unsigned char *extended_capa, *extended_capa_mask; 112 unsigned int extended_capa_len; 113 struct k_mutex rpu_lock; 114 #ifdef CONFIG_NRF_WIFI_RPU_RECOVERY 115 bool rpu_recovery_in_progress; 116 unsigned long last_rpu_recovery_time_ms; 117 unsigned int rpu_recovery_retries; 118 int rpu_recovery_success; 119 int rpu_recovery_failure; 120 #endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */ 121 }; 122 123 struct nrf_wifi_drv_priv_zep { 124 struct nrf_wifi_fmac_priv *fmac_priv; 125 /* TODO: Replace with a linked list to handle unlimited RPUs */ 126 struct nrf_wifi_ctx_zep rpu_ctx_zep; 127 }; 128 129 extern struct nrf_wifi_drv_priv_zep rpu_drv_priv_zep; 130 131 void nrf_wifi_scan_timeout_work(struct k_work *work); 132 133 void configure_tx_pwr_settings(struct nrf_wifi_tx_pwr_ctrl_params *tx_pwr_ctrl_params, 134 struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params); 135 void configure_board_dep_params(struct nrf_wifi_board_params *board_params); 136 void set_tx_pwr_ceil_default(struct nrf_wifi_tx_pwr_ceil_params *pwr_ceil_params); 137 const char *nrf_wifi_get_drv_version(void); 138 enum nrf_wifi_status nrf_wifi_fmac_dev_add_zep(struct nrf_wifi_drv_priv_zep *drv_priv_zep); 139 enum nrf_wifi_status nrf_wifi_fmac_dev_rem_zep(struct nrf_wifi_drv_priv_zep *drv_priv_zep); 140 struct nrf_wifi_vif_ctx_zep *nrf_wifi_get_vif_ctx(struct net_if *iface); 141 #ifdef CONFIG_NRF_WIFI_RPU_RECOVERY 142 void nrf_wifi_rpu_recovery_cb(void *vif_ctx, 143 void *event_data, 144 unsigned int event_len); 145 #endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */ 146 #endif /* !CONFIG_NRF70_OFFLOADED_RAW_TX */ 147 #ifdef CONFIG_BUILD_ONLY_NO_BLOBS nrf_wifi_fw_load(void * rpu_ctx)148inline enum nrf_wifi_status nrf_wifi_fw_load(void *rpu_ctx) 149 { 150 (void)rpu_ctx; 151 152 return NRF_WIFI_STATUS_SUCCESS; 153 } 154 #else 155 enum nrf_wifi_status nrf_wifi_fw_load(void *rpu_ctx); 156 #endif /* CONFIG_BUILD_ONLY_NO_BLOBS */ 157 #endif /* __ZEPHYR_FMAC_MAIN_H__ */ 158