Skip to content

Commit

Permalink
nrf_wifi: Incorporating changes for raw packet transmission
Browse files Browse the repository at this point in the history
This set of changes brings in support for raw packet transmission

Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
  • Loading branch information
VivekUppunda committed Nov 15, 2023
1 parent 5ade38c commit 64ae0e6
Show file tree
Hide file tree
Showing 10 changed files with 571 additions and 56 deletions.
54 changes: 54 additions & 0 deletions nrf_wifi/fw_if/umac_if/inc/default/fmac_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,60 @@ enum nrf_wifi_status nrf_wifi_fmac_set_listen_interval(void *fmac_dev_ctx,
enum nrf_wifi_status nrf_wifi_fmac_set_ps_wakeup_mode(void *fmac_dev_ctx,
unsigned char if_idx,
bool ps_wakeup_mode);

#ifdef CONFIG_NRF700X_RAW_DATA_TX
/**
* @brief Transmit a raw unaltered frame to the RPU.
* @param dev_ctx Pointer to the UMAC IF context for a RPU WLAN device.
* @param if_idx Index of the interface on which the frame is to be
* transmitted.
* @param net_packet Pointer to the OS specific network buffer.
*
* This function takes care of transmitting a frame to the RPU firmware.
* It does the following:
*
* - Queues the frames to a transmit queue.
* - Based on token availability, sends one or more frames to the RPU using
* the command for transmission.
* - The firmware sends an event once the command has
* been processed to indicate whether the frame has been
* transmitted/aborted.
* - The driver cleans up the frame buffer(s) after receiving this event.
*
*@retval WIFI_NRF_STATUS_SUCCESS On success
*@retval WIFI_NRF_STATUS_FAIL On failure
*/
enum nrf_wifi_status nrf_wifi_fmac_start_rawpkt_xmit(void *dev_ctx,
unsigned char if_idx,
void *net_packet);

/**
* @brief Check if raw packet transmission mode is enabled or not.
* @param vif Pointer to the virtual interface context.
*
* This function checks if raw packet transmission mode is enabled or not. If
* raw packet transmission mode is enabled, the packet will be allowed to be
* transmitted. If the mode is disabled, the packet will be silently dropped.
*
*@retval WIFI_NRF_STATUS_SUCCESS On success
*@retval WIFI_NRF_STATUS_FAIL On failure
*/
bool nrf_wifi_util_is_rawpktmode_enabled(struct nrf_wifi_fmac_vif_ctx *vif);

/**
* @brief Check if a valid mode is being set.
* @param mode The mode value attempted to be configured.
*
* This function checks the mode value attempted to be configured
* is a valid mode as supported by the driver. If the mode is valid,
* the mode will be configured to the lower layers, else an error value
* will be flagged.
*
*@retval WIFI_NRF_STATUS_SUCCESS On success
*@retval WIFI_NRF_STATUS_FAIL On failure
*/
enum nrf_wifi_status nrf_wifi_check_mode_validity(unsigned char mode);
#endif /* CONFIG_NRF700X_RAW_DATA_TX */
/**
* @}
*/
Expand Down
59 changes: 53 additions & 6 deletions nrf_wifi/fw_if/umac_if/inc/default/fmac_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define MAX_PEERS 5
#define MAX_SW_PEERS (MAX_PEERS + 1)
#define NRF_WIFI_AC_TWT_PRIORITY_EMERGENCY 0xFF
#define NRF_WIFI_MAGIC_NUM_RAWTX 0x12345678


/**
Expand Down Expand Up @@ -356,6 +357,51 @@ struct nrf_wifi_fmac_priv_def {
#endif /* CONFIG_NRF700X_STA_MODE */
};

#ifdef CONFIG_NRF700X_RAW_DATA_TX

/**
* @brief Transmit modes for raw packets.
*
*/
enum nrf_wifi_fmac_mode {
/** Legacy mode. */
NRF_WIFI_FMAC_RAWTX_MODE_LEGACY,
/** HT mode. */
NRF_WIFI_FMAC_RAWTX_MODE_HT,
/** VHT mode. */
NRF_WIFI_FMAC_RAWTX_MODE_VHT,
/** HE SU mode. */
NRF_WIFI_FMAC_RAWTX_MODE_HE_SU,
/** HE ER SU mode. */
NRF_WIFI_FMAC_RAWTX_MODE_HE_ER_SU,
/** HE TB mode. */
NRF_WIFI_FMAC_RAWTX_MODE_HE_TB,
/** Throughput max. */
NRF_WIFI_FMAC_RAWTX_MODE_MAX
};

/**
* @brief Structure to hold raw tx packet information.
*
* This structure holds the information sent by higher
* layers to transmit a raw frame.
*/
struct raw_tx_pkt_header {
/** magic number to identify a raw packet. */
unsigned int magic_num;
/** Data rate at which packet is to be transmitted. */
unsigned char data_rate;
/** Packet length. */
unsigned short packet_length;
/** Mode describing if packet is VHT, HT, HE or Legacy @ref nrf_wifi_fmac_mode. */
unsigned char tx_mode;
/** Wi-Fi access category mapping for packet @ref nrf_wifi_fmac_ac. */
unsigned char queue;
/** Flag indicating raw packet transmission. */
unsigned char raw_tx_flag;
};
#endif /* CONFIG_NRF700X_RAW_DATA_TX */

/**
* @brief Structure to hold per device context information for the UMAC IF layer.
*
Expand Down Expand Up @@ -391,6 +437,9 @@ struct nrf_wifi_fmac_dev_ctx_def {
void *tx_done_tasklet;
#endif /* CONFIG_NRF700X_TX_DONE_WQ_ENABLED */
#endif /* CONFIG_NRF700X_STA_MODE */
#ifdef CONFIG_NRF700X_RAW_DATA_TX
struct raw_tx_pkt_header raw_tx_config;
#endif /* CONFIG_NRF700X_RAW_DATA_TX */
};

/**
Expand All @@ -414,14 +463,12 @@ struct nrf_wifi_fmac_vif_ctx {
int if_type;
/** BSSID of the AP to which this VIF is connected (applicable only in STA mode). */
unsigned char bssid[NRF_WIFI_ETH_ADDR_LEN];
#ifdef CONFIG_NRF700X_RAWDATA_TX
/** packet filter setting for the VIF */
unsigned char packet_filter;
/** mode setting for the current VIF */
#ifdef CONFIG_NRF700X_RAW_DATA_TX
/** Mode setting for the current VIF */
unsigned char mode;
/** channel setting for the current VIF */
/** Channel setting for the current VIF */
unsigned char channel;
#endif /* CONFIG_NRF700X_RAWDATA_TX */
#endif /* CONFIG_NRF700X_RAW_DATA_TX */
};

/**
Expand Down
31 changes: 17 additions & 14 deletions nrf_wifi/fw_if/umac_if/inc/fmac_api_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,53 +241,56 @@ enum nrf_wifi_status nrf_wifi_fmac_get_reg(struct nrf_wifi_fmac_dev_ctx *fmac_de
enum nrf_wifi_status nrf_wifi_fmac_get_power_save_info(void *fmac_dev_ctx,
unsigned char if_idx);

#ifdef CONFIG_NRF700X_RAWDATA_TX
#ifdef CONFIG_NRF700X_RAW_DATA_TX
/**
* @brief Get or set the current mode of operation
* @brief Set the current mode of operation
* @param dev_ctx Pointer to the UMAC IF context for a RPU WLAN device.
* @param if_idx Index of the interface on which mode is to be set.
* @param mode value to be set for the interface.
* @param mode Value to be set for the interface.
*
* This function is used to send a command
* to RPU to Set/Get mode of operation
* to RPU to set mode of operation
*
* @return Command execution status
* @retval WIFI_NRF_STATUS_SUCCESS On success
* @retval WIFI_NRF_STATUS_FAIL On failure
*/
enum nrf_wifi_status nrf_wifi_fmac_mode(void *dev_ctx,
unsigned char if_idx,
unsigned char mode);

/**
* @brief Get or set the current channel
* @brief Set the current channel
* @param dev_ctx Pointer to the UMAC IF context for a RPU WLAN device.
* @param if_idx Index of the interface on which mode is to be set.
* @param channel value to be set for the interface.
* @param channel Value to be set for the interface.
*
* This function is used to send a command
* to RPU to Set/Get current channel of operation
* to RPU to set current channel of operation
*
* @return Command execution status
* @retval WIFI_NRF_STATUS_SUCCESS On success
* @retval WIFI_NRF_STATUS_FAIL On failure
*/
enum nrf_wifi_status nrf_wifi_fmac_channel(void *dev_ctx,
unsigned char if_idx,
unsigned int channel);

/**
* @brief Get or set the current channel
* @brief Set the packet filter settings
* @param dev_ctx Pointer to the UMAC IF context for a RPU WLAN device.
* @param filter value to be set for the interface.
* @param if_idx Index of the interface on which mode is to be set.
* @param buffer_size size of packet capture length.
* @param buffer_size Size of packet capture length.
*
* This function is used to send a command
* to RPU to Set/Get current channel of operation
* to RPU to set current packet filter settings
*
* @return Command execution status
* @retval WIFI_NRF_STATUS_SUCCESS On success
* @retval WIFI_NRF_STATUS_FAIL On failure
*/
enum nrf_wifi_status nrf_wifi_fmac_packet_filter(void *dev_ctx, unsigned char filter,
unsigned char if_idx,
unsigned short buffer_size);
#endif
#endif /* CONFIG_NRF700X_RAW_DATA_TX */
/**
* @}
*/
Expand Down
14 changes: 14 additions & 0 deletions nrf_wifi/fw_if/umac_if/inc/fmac_tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ struct tx_pkt_info {
unsigned int peer_id;
};

#ifdef CONFIG_NRF700X_RAW_DATA_TX
struct tx_cmd_prep_raw_info {
struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx;
struct nrf_wifi_cmd_raw_tx *raw_config;
unsigned char num_tx_pkts;
};
#endif /* CONFIG_NRF700X_RAW_DATA_TX */

struct tx_cmd_prep_info {
struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx;
struct nrf_wifi_tx_buff *config;
Expand All @@ -56,6 +64,12 @@ void tx_deinit(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx);
enum nrf_wifi_status nrf_wifi_fmac_tx_done_event_process(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
struct nrf_wifi_tx_buff_done *config);

#ifdef CONFIG_NRF700X_RAW_DATA_TX
enum nrf_wifi_status
nrf_wifi_fmac_rawtx_done_event_process(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
struct nrf_wifi_event_raw_tx_done *config);
#endif /* CONFIG_NRF700X_RAW_DATA_TX */

unsigned int tx_desc_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
int queue);

Expand Down
4 changes: 2 additions & 2 deletions nrf_wifi/fw_if/umac_if/inc/fmac_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ bool nrf_wifi_util_is_arr_zero(unsigned char *arr,

#endif /* !CONFIG_NRF700X_RADIO_TEST */

#ifdef CONFIG_NRF700X_RAWDATA_TX
#ifdef CONFIG_NRF700X_RAW_DATA_TX
bool nrf_wifi_util_is_rawpktmode_enabled(struct nrf_wifi_fmac_vif_ctx *vif);

enum nrf_wifi_status nrf_wifi_check_mode_validity(unsigned char mode);
#endif
#endif /* CONFIG_NRF700X_RAW_DATA_TX */

void *wifi_fmac_priv(struct nrf_wifi_fmac_priv *def);
void *wifi_dev_priv(struct nrf_wifi_fmac_dev_ctx *def);
Expand Down
3 changes: 3 additions & 0 deletions nrf_wifi/fw_if/umac_if/src/default/fmac_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -2013,6 +2013,9 @@ unsigned char nrf_wifi_fmac_add_vif(void *dev_ctx,
vif_ctx->fmac_dev_ctx = fmac_dev_ctx;
vif_ctx->os_vif_ctx = os_vif_ctx;
vif_ctx->if_type = vif_info->iftype;
#ifdef CONFIG_NRF700X_RAW_DATA_TX
vif_ctx->mode = NRF_WIFI_STA_MODE;
#endif /* CONFIG_NRF700X_RAW_DATA_TX */

nrf_wifi_osal_mem_cpy(fmac_dev_ctx->fpriv->opriv,
vif_ctx->mac_addr,
Expand Down
21 changes: 13 additions & 8 deletions nrf_wifi/fw_if/umac_if/src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,12 +852,11 @@ static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx
{
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
unsigned char *sys_head = NULL;
struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx;
#ifdef CONFIG_NRF700X_RADIO_TEST
struct nrf_wifi_fmac_dev_ctx_rt *def_dev_ctx_rt;
struct nrf_wifi_umac_event_err_status *umac_status;

def_dev_ctx = wifi_dev_priv(fmac_dev_ctx);
#else
struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx;
#endif /* CONFIG_NRF700X_RADIO_TEST */

if (!fmac_dev_ctx || !rpu_msg) {
Expand All @@ -866,9 +865,9 @@ static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx

#ifdef CONFIG_NRF700X_RADIO_TEST
def_dev_ctx_rt = wifi_dev_priv(fmac_dev_ctx);
#endif
#else
def_dev_ctx = wifi_dev_priv(fmac_dev_ctx);

#endif
sys_head = (unsigned char *)rpu_msg->msg;

switch (((struct nrf_wifi_sys_head *)sys_head)->cmd_event) {
Expand Down Expand Up @@ -896,9 +895,14 @@ static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx
status = NRF_WIFI_STATUS_SUCCESS;
break;
#endif /* CONFIG_NRF700X_RADIO_TEST */
#ifdef CONFIG_NRF700X_RAWDATA_TX
#ifdef CONFIG_NRF700X_RAW_DATA_TX
case NRF_WIFI_EVENT_RAW_TX_DONE:
status = nrf_wifi_fmac_rawtx_done_event_process(fmac_dev_ctx,
(struct nrf_wifi_event_raw_tx_done *)sys_head);
break;
case NRF_WIFI_EVENT_MODE_SET_DONE:
struct nrf_wifi_event_raw_config_mode *mode_event;

mode_event = (struct nrf_wifi_event_raw_config_mode *)sys_head;
if (!mode_event->status) {
def_dev_ctx->vif_ctx[mode_event->if_index]->mode =
Expand All @@ -923,6 +927,7 @@ static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx
break;
case NRF_WIFI_EVENT_CHANNEL_SET_DONE:
struct nrf_wifi_event_set_channel *channel_event;

channel_event = (struct nrf_wifi_event_set_channel *)sys_head;
if (!channel_event->status) {
def_dev_ctx->vif_ctx[channel_event->if_index]->channel =
Expand All @@ -932,22 +937,22 @@ static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx
break;
case NRF_WIFI_EVENT_FILTER_SET_DONE:
struct nrf_wifi_event_raw_config_filter *filter_event;

filter_event = (struct nrf_wifi_event_raw_config_filter *)sys_head;
if (!filter_event->status) {
def_dev_ctx->vif_ctx[filter_event->if_index]->packet_filter =
filter_event->filter;
}
status = NRF_WIFI_STATUS_SUCCESS;
break;
#endif /* CONFIG_NRF700X_RAWDATA_TX */
#endif /* CONFIG_NRF700X_RAW_DATA_TX */
default:
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
"%s: Unknown event recd: %d\n",
__func__,
((struct nrf_wifi_sys_head *)sys_head)->cmd_event);
break;
}

return status;
}

Expand Down
4 changes: 2 additions & 2 deletions nrf_wifi/fw_if/umac_if/src/fmac_api_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ enum nrf_wifi_status nrf_wifi_fmac_get_host_rpu_ps_ctrl_state(void *dev_ctx,
#endif /* CONFIG_NRF_WIFI_LOW_POWER */
#endif /* CONFIG_NRF700X_UTIL */

#ifdef CONFIG_NRF700X_RAWDATA_TX
#ifdef CONFIG_NRF700X_RAW_DATA_TX
enum nrf_wifi_status nrf_wifi_fmac_mode(void *dev_ctx,
unsigned char if_idx,
unsigned char mode)
Expand Down Expand Up @@ -1059,4 +1059,4 @@ enum nrf_wifi_status nrf_wifi_fmac_packet_filter(void *dev_ctx, unsigned char fi
out:
return status;
}
#endif /* CONFIG_NRF700X_RAWDATA_TX */
#endif /* CONFIG_NRF700X_RAW_DATA_TX */
10 changes: 7 additions & 3 deletions nrf_wifi/fw_if/umac_if/src/fmac_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ unsigned char *nrf_wifi_util_get_dest(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx
unsigned char *nrf_wifi_util_get_ra(struct nrf_wifi_fmac_vif_ctx *vif,
void *nwb)
{
if (vif->if_type == NRF_WIFI_IFTYPE_STATION) {
if ((vif->if_type == NRF_WIFI_IFTYPE_STATION)
#ifdef CONFIG_NRF700X_RAW_DATA_TX
|| (vif->if_type == NRF_WIFI_STA_TX_INJECTOR)
#endif /* CONFIG_NRF700X_RAW_DATA_TX */
) {
return vif->bssid;
}

Expand All @@ -341,7 +345,7 @@ unsigned char *nrf_wifi_util_get_src(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,

#endif /* CONFIG_NRF700X_STA_MODE */

#ifdef CONFIG_NRF700X_RAWDATA_TX
#ifdef CONFIG_NRF700X_RAW_DATA_TX
enum nrf_wifi_status nrf_wifi_check_mode_validity(unsigned char mode)
{
/**
Expand All @@ -364,7 +368,7 @@ bool nrf_wifi_util_is_rawpktmode_enabled(struct nrf_wifi_fmac_vif_ctx *vif)
}
return false;
}
#endif /* CONFIG_NRF700X_RAWDATA_TX */
#endif /* CONFIG_NRF700X_RAW_DATA_TX */

bool nrf_wifi_util_is_arr_zero(unsigned char *arr,
unsigned int arr_sz)
Expand Down
Loading

0 comments on commit 64ae0e6

Please sign in to comment.