1 /* 2 * 3 *Copyright (c) 2024 Nordic Semiconductor ASA 4 * 5 *SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 /** 9 * @file 10 * @addtogroup nrf_wifi_fw_if Wi-Fi driver and firmware interface 11 * @{ 12 * 13 * @brief Data interface between host and RPU 14 */ 15 16 #ifndef __HOST_RPU_DATA_IF_H__ 17 #define __HOST_RPU_DATA_IF_H__ 18 19 #include "host_rpu_common_if.h" 20 #include "host_rpu_sys_if.h" 21 22 #include "common/pack_def.h" 23 24 #define TX_BUF_HEADROOM 52 25 26 /** 27 * @brief UMAC data interface commands and events. 28 * 29 */ 30 enum nrf_wifi_umac_data_commands { 31 /** Unused. */ 32 NRF_WIFI_CMD_MGMT_BUFF_CONFIG, 33 /** Transmit data packet @ref nrf_wifi_tx_buff */ 34 NRF_WIFI_CMD_TX_BUFF, 35 /** TX done event @ref nrf_wifi_tx_buff_done */ 36 NRF_WIFI_CMD_TX_BUFF_DONE, 37 /** RX packet event @ref nrf_wifi_rx_buff*/ 38 NRF_WIFI_CMD_RX_BUFF, 39 /** Event to indicate interface is operational 40 * @ref nrf_wifi_data_carrier_state 41 */ 42 NRF_WIFI_CMD_CARRIER_ON, 43 /** Event to indicate interface is non-operational 44 * @ref nrf_wifi_data_carrier_state 45 */ 46 NRF_WIFI_CMD_CARRIER_OFF, 47 /** Event to indicate softap client's power save mode 48 * If client is in power save mode, host should start buffering 49 * packets until it receives NRF_WIFI_CMD_PS_GET_FRAMES event. 50 */ 51 NRF_WIFI_CMD_PM_MODE, 52 /** Event to indicate to start sending buffered packets for 53 * softap client @ref nrf_wifi_sap_ps_get_frames. 54 */ 55 NRF_WIFI_CMD_PS_GET_FRAMES, 56 }; 57 58 /** 59 * @brief Data interface Command and Event header. 60 * 61 */ 62 struct nrf_wifi_umac_head { 63 /** Command or Event id see &enum nrf_wifi_umac_data_commands */ 64 unsigned int cmd; 65 /** length */ 66 unsigned int len; 67 68 } __NRF_WIFI_PKD; 69 70 #define NRF_WIFI_TX_FLAGS_DSCP_TOS_MASK 0xFFFF 71 #define NRF_WIFI_TX_FLAGS_DSCP_TOS_SHIFT 0 72 #define NRF_WIFI_TX_FLAGS_DSCP_TOS(x) (((x) << NRF_WIFI_TX_FLAGS_DSCP_TOS_SHIFT) & NRF_WIFI_TX_FLAGS_DSCP_TOS_MASK) 73 74 enum nrf_wifi_tx_flags { 75 NRF_WIFI_TX_FLAG_TWT_EMERGENCY_TX = (1 << 31), 76 NRF_WIFI_TX_FLAG_CHKSUM_AVAILABLE = (1 << 30), 77 }; 78 79 /** 80 * @brief Tx mac80211 header information. 81 * 82 */ 83 struct tx_mac_hdr_info { 84 /** Unused */ 85 signed int umac_fill_flags; 86 /** frame control */ 87 unsigned short fc; 88 /** source Mac header */ 89 unsigned char dest[6]; 90 /** destination Mac address */ 91 unsigned char src[6]; 92 /** Ethernet type */ 93 unsigned short etype; 94 /** TX flags */ 95 unsigned int tx_flags; 96 /** more frames queued */ 97 unsigned char more_data; 98 /** End Of Service Period flag(applicable in U-APSD) */ 99 unsigned char eosp; 100 } __NRF_WIFI_PKD; 101 102 /** 103 * @brief This structure provides the information of each packet in the tx command. 104 * 105 */ 106 107 struct nrf_wifi_tx_buff_info { 108 /** Tx packet length */ 109 unsigned short pkt_length; 110 /** Tx packet address */ 111 unsigned int ddr_ptr; 112 } __NRF_WIFI_PKD; 113 114 /** 115 * @brief This structure provides the parameters for the tx command. 116 * 117 */ 118 struct nrf_wifi_tx_buff { 119 /** Command header @ref nrf_wifi_umac_head */ 120 struct nrf_wifi_umac_head umac_head; 121 /** Interface id */ 122 unsigned char wdev_id; 123 /** Descriptor id */ 124 unsigned char tx_desc_num; 125 /** Common mac header for all packets in this command 126 * @ref tx_mac_hdr_info 127 */ 128 struct tx_mac_hdr_info mac_hdr_info; 129 /** Pending buffer size at host to encode queue size 130 * in qos control field of mac header in TWT enable case 131 */ 132 unsigned int pending_buf_size; 133 /** Number of packets sending in this command */ 134 unsigned char num_tx_pkts; 135 /** Each packets information @ref nrf_wifi_tx_buff_info */ 136 struct nrf_wifi_tx_buff_info tx_buff_info[0]; 137 } __NRF_WIFI_PKD; 138 139 #define NRF_WIFI_TX_STATUS_SUCCESS 0 140 #define NRF_WIFI_TX_STATUS_FAILED 1 141 142 /** 143 * @brief This structure represents the Tx done event(NRF_WIFI_CMD_TX_BUFF_DONE). 144 * 145 */ 146 struct nrf_wifi_tx_buff_done { 147 /** Header @ref nrf_wifi_umac_head */ 148 struct nrf_wifi_umac_head umac_head; 149 /** Descriptor id */ 150 unsigned char tx_desc_num; 151 /** Number of packets in this Tx done event */ 152 unsigned char num_tx_status_code; 153 /** Frame sent time at Phy */ 154 unsigned char timestamp_t1[6]; 155 /** Frame ack received time at Phy */ 156 unsigned char timestamp_t4[6]; 157 /** Status of Tx packet. Maximum of MAX_TX_AGG_SIZE */ 158 unsigned char tx_status_code[0]; 159 } __NRF_WIFI_PKD; 160 161 /** 162 * @brief This structure defines the type of received packet. 163 * 164 */ 165 enum nrf_wifi_rx_pkt_type { 166 /** The Rx packet is of type data */ 167 NRF_WIFI_RX_PKT_DATA, 168 /** RX packet is beacon or probe response */ 169 NRF_WIFI_RX_PKT_BCN_PRB_RSP, 170 /** Raw Rx packet */ 171 NRF_WIFI_RAW_RX_PKT 172 }; 173 174 /** 175 * @brief This structure provides information about the parameters in the RX data event. 176 * 177 */ 178 struct nrf_wifi_rx_buff_info { 179 /** Descriptor id */ 180 unsigned short descriptor_id; 181 /** Rx packet length */ 182 unsigned short rx_pkt_len; 183 /** type PKT_TYPE_MPDU/PKT_TYPE_MSDU_WITH_MAC/PKT_TYPE_MSDU */ 184 unsigned char pkt_type; 185 /** Frame received time at Phy */ 186 unsigned char timestamp_t2[6]; 187 /** Ack sent time at Phy */ 188 unsigned char timestamp_t3[6]; 189 } __NRF_WIFI_PKD; 190 191 /** 192 * @brief This structure represents RX data event(NRF_WIFI_CMD_RX_BUFF). 193 * 194 */ 195 struct nrf_wifi_rx_buff { 196 /** Header @ref nrf_wifi_umac_head */ 197 struct nrf_wifi_umac_head umac_head; 198 /** Rx packet type. see &enum nrf_wifi_rx_pkt_type */ 199 signed short rx_pkt_type; 200 /** Refer rpu_tput_mode */ 201 unsigned char rate_flags; 202 /** Rate: Legacy : 1, 2, 55, 6, 9, 11, 12, 18, 24, 36, 48, 54 203 * 11N VHT HE : MCS index 0 to 7. 204 */ 205 unsigned char rate; 206 /** Interface id */ 207 unsigned char wdev_id; 208 /** Number of packets in this event */ 209 unsigned char rx_pkt_cnt; 210 /** Depricated */ 211 unsigned char reserved; 212 /** MAC header length. Same for all packets in this event */ 213 unsigned char mac_header_len; 214 /** Frequency on which this packet received */ 215 unsigned short frequency; 216 /** signal strength */ 217 signed short signal; 218 /** Information of each packet. @ref nrf_wifi_rx_buff_info */ 219 struct nrf_wifi_rx_buff_info rx_buff_info[0]; 220 } __NRF_WIFI_PKD; 221 222 /** 223 * @brief This structure provides information about the carrier (interface) state. 224 * 225 */ 226 struct nrf_wifi_data_carrier_state { 227 /** Header @ref nrf_wifi_umac_head */ 228 struct nrf_wifi_umac_head umac_head; 229 /** Interface id */ 230 unsigned int wdev_id; 231 232 } __NRF_WIFI_PKD; 233 234 /** SoftAP client is in active mode */ 235 #define NRF_WIFI_CLIENT_ACTIVE 0 236 /** SoftAP client is in power save mode */ 237 #define NRF_WIFI_CLIENT_PS_MODE 1 238 239 /** 240 * @brief This structure describes an event related to the power save state of the softap's client. 241 * When the client is in PS mode (NRF_WIFI_CLIENT_PS_MODE), the host should queue Tx packets. 242 * When the client is in wakeup mode (NRF_WIFI_CLIENT_ACTIVE), the host should send all 243 * buffered and upcoming Tx packets. 244 * 245 */ 246 struct nrf_wifi_sap_client_pwrsave { 247 /** Header @ref nrf_wifi_umac_head */ 248 struct nrf_wifi_umac_head umac_head; 249 /** Interface id */ 250 unsigned int wdev_id; 251 /** state NRF_WIFI_CLIENT_ACTIVE or NRF_WIFI_CLIENT_PS_MODE */ 252 unsigned char sta_ps_state; 253 /** STA MAC Address */ 254 unsigned char mac_addr[NRF_WIFI_ETH_ADDR_LEN]; 255 256 } __NRF_WIFI_PKD; 257 258 /** 259 * @brief This structure represents an event that instructs the host to transmit a specific 260 * number of frames that host queued when softap's client is in power save mode. 261 * This event is primarily used when Softap's client operates in legacy power save mode. 262 * In this scenario, the access point (AP) is required to send a single packet for every PS POLL 263 * frame it receives from the client. Additionally, this mechanism will also be utilized in 264 * UAPSD power save. 265 * 266 */ 267 struct nrf_wifi_sap_ps_get_frames { 268 /** Header @ref nrf_wifi_umac_head */ 269 struct nrf_wifi_umac_head umac_head; 270 /** Interface id */ 271 unsigned int wdev_id; 272 /** STA MAC Address */ 273 unsigned char mac_addr[NRF_WIFI_ETH_ADDR_LEN]; 274 /** Number of frames to be transmitted in this service period */ 275 signed char num_frames; 276 277 } __NRF_WIFI_PKD; 278 279 /** 280 * @} 281 */ 282 #endif /* __HOST_RPU_DATA_IF_H__ */ 283