1 /* 2 * Copyright (c) 2024 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 /** @file 7 * 8 * @addtogroup nrf70_off_raw_tx_api nRF70 Offloaded raw TX API 9 * @{ 10 * 11 * @brief File containing API's for the Offloaded raw TX feature. 12 */ 13 14 #ifndef INCLUDE_ZEPHYR_DRIVERS_OFF_RAW_TX_API_H_ 15 #define INCLUDE_ZEPHYR_DRIVERS_OFF_RAW_TX_API_H_ 16 17 #include <stdbool.h> 18 #include <stdint.h> 19 #include "osal_api.h" 20 21 /* Minimum frame size for raw packet transmission */ 22 #define NRF_WIFI_OFF_RAW_TX_FRAME_SIZE_MIN 26 23 /* Maximum frame size for raw packet transmission */ 24 #define NRF_WIFI_OFF_RAW_TX_FRAME_SIZE_MAX 600 25 /* Maximum length of country code*/ 26 #define NRF_WIFI_COUNTRY_CODE_LEN 2 27 /** 28 * @brief- Transmission rates 29 * Rate to be used for transmitting a packet. 30 */ 31 enum nrf_wifi_off_raw_tx_rate { 32 /** 1 Mbps */ 33 RATE_1M, 34 /** 2 Mbps */ 35 RATE_2M, 36 /** 5.5 Mbps */ 37 RATE_5_5M, 38 /** 11 Mbps */ 39 RATE_11M, 40 /** 6 Mbps */ 41 RATE_6M, 42 /** 9 Mbps */ 43 RATE_9M, 44 /** 12 Mbps */ 45 RATE_12M, 46 /** 18 Mbps */ 47 RATE_18M, 48 /** 24 Mbps */ 49 RATE_24M, 50 /** 36 Mbps */ 51 RATE_36M, 52 /** 48 Mbps */ 53 RATE_48M, 54 /** 54 Mbps */ 55 RATE_54M, 56 /** MCS 0 */ 57 RATE_MCS0, 58 /** MCS 1 */ 59 RATE_MCS1, 60 /** MCS 2 */ 61 RATE_MCS2, 62 /** MCS 3 */ 63 RATE_MCS3, 64 /** MCS 4 */ 65 RATE_MCS4, 66 /** MCS 5 */ 67 RATE_MCS5, 68 /** MCS 6 */ 69 RATE_MCS6, 70 /** MCS 7 */ 71 RATE_MCS7, 72 /** Invalid rate */ 73 RATE_MAX 74 }; 75 76 77 /** 78 * @brief- HE guard interval value 79 * Value of the guard interval to be used between symbols when transmitting using HE. 80 */ 81 enum nrf_wifi_off_raw_tx_he_gi { 82 /** 800 ns */ 83 HE_GI_800NS, 84 /** 1600 ns */ 85 HE_GI_1600NS, 86 /** 3200 ns */ 87 HE_GI_3200NS, 88 /** Invalid value */ 89 HE_GI_MAX 90 }; 91 92 93 /** 94 * @brief- HE long training field duration 95 * Value of the long training field duration to be used when transmitting using HE. 96 */ 97 enum nrf_wifi_off_raw_tx_he_ltf { 98 /** 3.2us */ 99 HE_LTF_3200NS, 100 /** 6.4us */ 101 HE_LTF_6400NS, 102 /** 12.8us */ 103 HE_LTF_12800NS, 104 /** Invalid value */ 105 HE_LTF_MAX 106 }; 107 108 /** 109 * @brief- Throughput mode 110 * Throughput mode to be used for transmitting the packet. 111 */ 112 enum nrf_wifi_off_raw_tx_tput_mode { 113 /** Legacy mode */ 114 TPUT_MODE_LEGACY, 115 /** High Throughput mode (11n) */ 116 TPUT_MODE_HT, 117 /** Very high throughput mode (11ac) */ 118 TPUT_MODE_VHT, 119 /** HE SU mode */ 120 TPUT_MODE_HE_SU, 121 /** HE ER SU mode */ 122 TPUT_MODE_HE_ER_SU, 123 /** HE TB mode */ 124 TPUT_MODE_HE_TB, 125 /** Highest throughput mode currently defined */ 126 TPUT_MODE_MAX 127 }; 128 129 /** 130 * @brief This structure defines the Offloaded raw tx debug statistics. 131 * 132 */ 133 struct nrf_wifi_off_raw_tx_stats { 134 /** Number of packets sent */ 135 unsigned int off_raw_tx_pkt_sent; 136 }; 137 138 /** 139 * @brief- Configuration parameters for offloaded raw TX 140 * Parameters which can be used to configure the offloaded raw TX operation. 141 */ 142 struct nrf_wifi_off_raw_tx_conf { 143 /** Time interval (in microseconds) between transmissions */ 144 unsigned int period_us; 145 /** Transmit power in dBm (0 to 20) */ 146 unsigned int tx_pwr; 147 /** Channel number on which to transmit */ 148 unsigned int chan; 149 /** Set to TRUE to use short preamble for FALSE to disable short preamble */ 150 bool short_preamble; 151 /* Number of times a packet should be retried at each possible rate */ 152 unsigned int num_retries; 153 /** Throughput mode for packet transmittion. Refer &enum nrf_wifi_off_raw_tx_tput_mode */ 154 enum nrf_wifi_off_raw_tx_tput_mode tput_mode; 155 /* Rate at which packet needs to be transmitted. Refer &enum nrf_wifi_off_raw_tx_rate */ 156 enum nrf_wifi_off_raw_tx_rate rate; 157 /** HE GI. Refer &enum nrf_wifi_off_raw_tx_he_gi */ 158 enum nrf_wifi_off_raw_tx_he_gi he_gi; 159 /** HE GI. Refer &enum nrf_wifi_off_raw_tx_he_ltf */ 160 enum nrf_wifi_off_raw_tx_he_ltf he_ltf; 161 /* Pointer to packet to be transmitted */ 162 void *pkt; 163 /** Packet length of the frame to be transmitted, (min 26 bytes and max 600 bytes) */ 164 unsigned int pkt_len; 165 }; 166 167 168 /** 169 * @brief Initialize the nRF70 for operating in the offloaded raw TX mode. 170 * @param mac_addr MAC address to be used for the nRF70 device. 171 * @param country_code Country code to be set for regularity domain. 172 * 173 * This function is initializes the nRF70 device for offloaded raw TX mode by: 174 * - Powering it up, 175 * - Downloading a firmware patch (if any). 176 * - Initializing the firmware to accept further commands 177 * 178 * The mac_addr parameter is used to set the MAC address of the nRF70 device. 179 * This address can be used to override the MAC addresses programmed in the OTP and 180 * the value configured (if any) in CONFIG_WIFI_FIXED_MAC_ADDRESS. 181 * The priority order in which the MAC address values for the nRF70 device are used is: 182 * - If mac_addr is provided, the MAC address is set to the value provided. 183 * - If CONFIG_WIFI_FIXED_MAC_ADDRESS is enabled, the MAC address uses the Kconfig value. 184 * - If none of the above are provided, the MAC address is set to the value programmed in the OTP. 185 * 186 * @retval 0 If the operation was successful. 187 * @retval -1 If the operation failed. 188 */ 189 int nrf70_off_raw_tx_init(uint8_t *mac_addr, unsigned char *country_code); 190 191 /** 192 * @brief Initialize the nRF70 for operating in the offloaded raw TX mode. 193 * 194 * This function is deinitializes the nRF70 device. 195 * 196 */ 197 void nrf70_off_raw_tx_deinit(void); 198 199 /** 200 * @brief Update the configured offloaded raw TX parameters. 201 * @param conf Configuration parameters to be updated for the offloaded raw TX operation. 202 * 203 * This function is used to update configured parameters for offloaded raw TX operation. 204 * This function should be used to when the parameters need to be updated during an ongoing 205 * raw TX operation without having to stop it. 206 * 207 * @retval 0 If the operation was successful. 208 * @retval -1 If the operation failed. 209 */ 210 int nrf70_off_raw_tx_conf_update(struct nrf_wifi_off_raw_tx_conf *conf); 211 212 /** 213 * @brief Start the offloaded raw TX. 214 * @param conf Configuration parameters necessary for the offloaded raw TX operation. 215 * 216 * This function is used to start offloaded raw TX operation. When this function is invoked 217 * the nRF70 device will start transmitting frames as per the configuration specified by @p conf. 218 * 219 * @retval 0 If the operation was successful. 220 * @retval -1 If the operation failed. 221 */ 222 int nrf70_off_raw_tx_start(struct nrf_wifi_off_raw_tx_conf *conf); 223 224 /** 225 * @brief Stop the offloaded raw TX. 226 * 227 * This function is used to stop offloaded raw TX operation. When this function is invoked 228 * the nRF70 device will stop transmitting frames. 229 * 230 * @retval 0 If the operation was successful. 231 * @retval -1 If the operation failed. 232 */ 233 int nrf70_off_raw_tx_stop(void); 234 235 /** 236 * @brief Get the MAC address of the nRF70 device. 237 * @param mac_addr Buffer to store the MAC address. 238 * 239 * This function is used to get the MAC address of the nRF70 device. 240 * The MAC address is stored in the buffer pointed by mac_addr. 241 * The MAC address is expected to be a 6 byte value. 242 * 243 * @retval 0 If the operation was successful. 244 * @retval -1 If the operation failed. 245 */ 246 int nrf70_off_raw_tx_mac_addr_get(uint8_t *mac_addr); 247 248 /** 249 * @brief Get statistics of the offloaded raw TX. 250 * @param off_raw_tx_stats Statistics of the offloaded raw TX operation. 251 * 252 * This function is used to get statistics of offloaded raw TX operation. When this function 253 * is invoked the nRF70 device will show statistics. 254 * 255 * @retval 0 If the operation was successful. 256 * @retval -1 If the operation failed. 257 */ 258 int nrf70_off_raw_tx_stats(struct nrf_wifi_off_raw_tx_stats *off_raw_tx_stats); 259 /** 260 * @} 261 */ 262 #endif /* INCLUDE_ZEPHYR_DRIVERS_OFF_RAW_TX_API_H_ */ 263