1 /*
2  * Copyright (c) 2024 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 /** @file
8  *
9  * @addtogroup nrf_wifi_api_common FMAC API common
10  * @{
11  *
12  * @brief Header containing declarations for utility functions for
13  * FMAC IF Layer of the Wi-Fi driver.
14  */
15 
16 #ifndef __FMAC_STRUCTS_COMMON_H__
17 #define __FMAC_STRUCTS_COMMON_H__
18 
19 #include "osal_api.h"
20 #include "host_rpu_umac_if.h"
21 
22 #define NRF_WIFI_FW_CHUNK_ID_STR_LEN 16
23 
24 /** @brief Device operation modes. */
25 enum nrf_wifi_op_mode {
26 	/** System mode. */
27 	NRF_WIFI_OP_MODE_SYS = 0,
28 	/** Radio test mode */
29 	NRF_WIFI_OP_MODE_RT,
30 	/** Offloaded raw TX mode */
31 	NRF_WIFI_OP_MODE_OFF_RAW_TX,
32 
33 /** @cond INTERNAL_HIDDEN */
34 	__NRF_WIFI_OP_MODE_AFTER_LAST,
35 	NRF_WIFI_OP_MODE_MAX = __NRF_WIFI_OP_MODE_AFTER_LAST - 1,
36 	NRF_WIFI_OP_MODE_UNKNOWN
37 /** @endcond */
38 };
39 
40 /**
41  * @brief Structure to hold host specific statistics.
42  *
43  */
44 struct rpu_host_stats {
45 	/** Total number of TX frames transmitted. */
46 	unsigned long long total_tx_pkts;
47 	/** Total number of TX dones received. */
48 	unsigned long long total_tx_done_pkts;
49 	/** Total number of TX frames dropped. */
50 	unsigned long long total_tx_drop_pkts;
51 	/** Total number of RX frames received. */
52 	unsigned long long total_rx_pkts;
53 	/** Total number of RX frames dropped. */
54 	unsigned long long total_rx_drop_pkts;
55 };
56 
57 
58 /**
59  * @brief Structure to hold FW patch information.
60  *
61  */
62 struct nrf_wifi_fw_info {
63 	/** Pointer to the FW patch data. */
64 	const void *data;
65 	/** Size of the FW patch data. */
66 	unsigned int size;
67 };
68 
69 
70 /**
71  * @brief Structure to hold FW patch information for LMAC and UMAC.
72  *
73  */
74 struct nrf_wifi_fmac_fw_info {
75 	/** Primary LMAC FW patch information. */
76 	struct nrf_wifi_fw_info lmac_patch_pri;
77 	/** Secondary LMAC FW patch information. */
78 	struct nrf_wifi_fw_info lmac_patch_sec;
79 	/** Primary UMAC FW patch information. */
80 	struct nrf_wifi_fw_info umac_patch_pri;
81 	/** Secondary UMAC FW patch information. */
82 	struct nrf_wifi_fw_info umac_patch_sec;
83 };
84 
85 /**
86  * @brief Structure to hold FW patch chunk information.
87  *
88  */
89 struct nrf_wifi_fmac_fw_chunk_info {
90 	/** Pointer to the FW patch chunk ID string. */
91 	char id_str[NRF_WIFI_FW_CHUNK_ID_STR_LEN];
92 	/** Pointer to the FW patch chunk data. */
93 	const void *data;
94 	/** Size of the FW patch chunk data. */
95 	unsigned int size;
96 	/** Destination address of the FW patch chunk data. */
97 	unsigned int dest_addr;
98 };
99 
100 
101 /**
102  * @brief Structure to hold OTP region information.
103  *
104  */
105 struct nrf_wifi_fmac_otp_info {
106 	/** OTP region information. */
107 	struct host_rpu_umac_info info;
108 	/** Flags indicating which OTP regions are valid. */
109 	unsigned int flags;
110 };
111 
112 /* Maximum number of channels supported in a regulatory
113  * currently set to 42 as hardware supports 2.4GHz and 5GHz.
114  * In 2.4 GHz band maximum 14 channels and
115  * in 5 GHz band maximum 28 channels are supported.
116  * Maximum number of channels will change if more number
117  * of channels are enabled in different bands or
118  * different bands are supported in hardware.
119  */
120 #define MAX_NUM_REG_CHANELS 42
121 
122 /**
123  * @brief Structure to hold Regulatory parameter data.
124  *
125  */
126 struct nrf_wifi_fmac_reg_info {
127 	/** ISO IEC Country code. */
128 	unsigned char alpha2[NRF_WIFI_COUNTRY_CODE_LEN];
129 	 /** Forcefully set regulatory. */
130 	bool force;
131 	/** Regulatory channels count*/
132 	unsigned int reg_chan_count;
133 	/** Regulatory channel attributes */
134 	struct nrf_wifi_get_reg_chn_info reg_chan_info[MAX_NUM_REG_CHANELS];
135 };
136 
137 /**
138  * @brief Structure to hold common fmac priv parameter data.
139  *
140  */
141 struct nrf_wifi_fmac_priv {
142 	/** Handle to the HAL layer. */
143 	struct nrf_wifi_hal_priv *hpriv;
144 	/** Operation mode. \ref nrf_wifi_op_mode */
145 	int op_mode;
146 	/** Data pointer to mode specific parameters */
147 	char priv[];
148 };
149 
150 /**
151  * @brief Structure to hold common fmac dev context parameter data.
152  *
153  */
154 struct nrf_wifi_fmac_dev_ctx {
155 	/** Handle to the FMAC IF abstraction layer. */
156 	struct nrf_wifi_fmac_priv *fpriv;
157 	/** Handle to the OS abstraction layer. */
158 	void *os_dev_ctx;
159 	/** Handle to the HAL layer. */
160 	void *hal_dev_ctx;
161 	/** Operation mode. \ref nrf_wifi_op_mode */
162 	int op_mode;
163 	/** Firmware statistics. */
164 	void *fw_stats;
165 	/** Firmware statistics requested. */
166 	bool stats_req;
167 	/** Firmware boot done. */
168 	bool fw_boot_done;
169 	/** Firmware init done. */
170 	bool fw_init_done;
171 	/** Firmware deinit done. */
172 	bool fw_deinit_done;
173 	/** Alpha2 valid. */
174 	bool alpha2_valid;
175 	/** Alpha2 country code, last byte is reserved for null character. */
176 	unsigned char alpha2[3];
177 	/** Regulatory channels count*/
178 	unsigned int reg_chan_count;
179 	/** Regulatory channel attributes */
180 	struct nrf_wifi_get_reg_chn_info *reg_chan_info;
181 	/** To determine if event is solicited or not */
182 	bool waiting_for_reg_event;
183 	/** Regulatory set status */
184 	int reg_set_status;
185 	/** Regulatory change event */
186 	struct nrf_wifi_event_regulatory_change *reg_change;
187 	/** TX power ceiling parameters */
188 	struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params;
189 	/** Data pointer to mode specific parameters */
190 	char priv[];
191 };
192 /**
193  * @}
194  */
195 #endif /* __FMAC_STRUCTS_COMMON_H__ */
196