Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Txinjection monitor changes #1192

Merged
merged 3 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions nrf_wifi/fw_if/umac_if/inc/default/fmac_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ enum nrf_wifi_fmac_if_carr_state {
NRF_WIFI_FMAC_IF_CARR_STATE_INVALID
};

#ifdef CONFIG_NRF700X_RAW_DATA_RX
/**
* @brief Structure to hold raw rx packet information.
*
* This structure holds the information to be sent to higher
* layers on receive of a raw frame.
*/
struct raw_rx_pkt_header {
/** Frequency on which this packet received. */
unsigned short frequency;
/** Signal strength of received packet. */
signed short signal;
/** Received packet type */
unsigned char rate_flags;
/** Data rate of the packet (MCS or Legacy). */
unsigned char rate;
};
#endif /* CONFIG_NRF700X_RAW_DATA_RX */

/**
* @brief Callback functions to be invoked by UMAC IF layer when a particular event occurs.
Expand Down Expand Up @@ -246,6 +264,11 @@ struct nrf_wifi_fmac_callbk_fns {
void (*process_rssi_from_rx)(void *os_vif_ctx,
signed short signal);
#endif /* CONFIG_NRF700X_STA_MODE */
#ifdef CONFIG_NRF700X_RAW_DATA_RX
void (*rx_sniffer_frm_callbk_fn)(void *os_vif_ctx,
void *frm,
struct raw_rx_pkt_header *);
#endif
};

#if defined(CONFIG_NRF700X_STA_MODE) || defined(__DOXYGEN__)
Expand Down Expand Up @@ -479,10 +502,16 @@ struct nrf_wifi_fmac_vif_ctx {
unsigned char bssid[NRF_WIFI_ETH_ADDR_LEN];
/** Mode setting for the current VIF */
unsigned char mode;
#ifdef CONFIG_NRF700X_RAW_DATA_TX
#if defined(CONFIG_NRF700X_RAW_DATA_TX) || defined(CONFIG_NRF700X_RAW_DATA_RX)
/** Channel setting for the current VIF */
unsigned char channel;
#endif /* CONFIG_NRF700X_RAW_DATA_TX */
/** TX injection mode setting */
bool txinjection_mode;
#endif /* CONFIG_NRF700X_RAW_DATA_TX || CONFIG_NRF700X_RAW_DATA_RX */
#ifdef CONFIG_NRF700X_RAW_DATA_RX
/** Filter setting for Monitor and Promiscuous modes */
unsigned char packet_filter;
#endif /* CONFIG_NRF700X_RAW_DATA_RX */
};

/**
Expand Down
23 changes: 21 additions & 2 deletions nrf_wifi/fw_if/umac_if/inc/fmac_api_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ enum nrf_wifi_status nrf_wifi_fmac_set_mode(void *dev_ctx,
unsigned char if_idx,
unsigned char mode);

#ifdef CONFIG_NRF700X_RAW_DATA_TX
#if defined(CONFIG_NRF700X_RAW_DATA_TX) || defined(CONFIG_NRF700X_RAW_DATA_RX)
/**
* @brief Set the current channel
* @param dev_ctx Pointer to the UMAC IF context for a RPU WLAN device.
Expand All @@ -342,7 +342,26 @@ enum nrf_wifi_status nrf_wifi_fmac_set_channel(void *dev_ctx,
unsigned char if_idx,
unsigned int channel);

#endif /* CONFIG_NRF700X_RAW_DATA_TX */
#endif /* CONFIG_NRF700X_RAW_DATA_TX || CONFIG_NRF700X_RAW_DATA_RX */

#ifdef CONFIG_NRF700X_RAW_DATA_RX
/**
* @brief Set 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.
*
* This function is used to send a command
* to RPU to set filter setting for sniffer operation
*
* @return Command execution status
*/
enum nrf_wifi_status nrf_wifi_fmac_set_packet_filter(void *dev_ctx, unsigned char filter,
unsigned char if_idx,
unsigned short buffer_size);
#endif

/**
* @}
*/
Expand Down
48 changes: 46 additions & 2 deletions nrf_wifi/fw_if/umac_if/src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx
/**
* Set the transmit queue for RAW packet transmission
*/
#ifdef CONFIG_NRF700X_RAW_DATA_TX
if (mode_event->op_mode == (NRF_WIFI_TX_INJECTION_MODE |
NRF_WIFI_STA_MODE)) {
def_dev_ctx->tx_config.peers[MAX_PEERS].peer_id =
Expand All @@ -935,17 +936,48 @@ static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx
mode_event->if_index;
def_dev_ctx->vif_ctx[mode_event->if_index]->if_type =
NRF_WIFI_STA_TX_INJECTOR;
} else if (mode_event->op_mode == NRF_WIFI_STA_MODE) {
def_dev_ctx->vif_ctx[mode_event->if_index]->txinjection_mode
= true;
} else
#endif /* CONFIG_NRF700X_RAW_DATA_TX */
if (mode_event->op_mode == NRF_WIFI_STA_MODE) {
def_dev_ctx->vif_ctx[mode_event->if_index]->if_type =
NRF_WIFI_IFTYPE_STATION;
#ifdef CONFIG_NRF700X_RAW_DATA_TX
def_dev_ctx->vif_ctx[mode_event->if_index]->txinjection_mode
= false;
#endif /* CONFIG_NRF700X_RAW_DATA_TX */
def_dev_ctx->tx_config.peers[MAX_PEERS].peer_id = -1;
}
#ifdef CONFIG_NRF700X_RAW_DATA_RX
else if (mode_event->op_mode == NRF_WIFI_MONITOR_MODE) {
def_dev_ctx->vif_ctx[mode_event->if_index]->if_type =
NRF_WIFI_IFTYPE_MONITOR;
def_dev_ctx->tx_config.peers[MAX_PEERS].peer_id = -1;
#ifdef CONFIG_NRF700X_RAW_DATA_TX
def_dev_ctx->vif_ctx[mode_event->if_index]->txinjection_mode
= false;
#endif /* CONFIG_NRF700X_RAW_DATA_TX */
} else if (mode_event->op_mode == (NRF_WIFI_MONITOR_MODE |
NRF_WIFI_TX_INJECTION_MODE)) {
def_dev_ctx->tx_config.peers[MAX_PEERS].peer_id
= MAX_PEERS;
def_dev_ctx->tx_config.peers[MAX_PEERS].if_idx =
mode_event->if_index;
def_dev_ctx->vif_ctx[mode_event->if_index]->if_type =
NRF_WIFI_MONITOR_TX_INJECTOR;
#ifdef CONFIG_NRF700X_RAW_DATA_TX
def_dev_ctx->vif_ctx[mode_event->if_index]->txinjection_mode
= true;
#endif /* CONFIG_NRF700X_RAW_DATA_TX */
}
#endif /* CONFIG_NRF700X_RAW_DATA_RX */
status = NRF_WIFI_STATUS_SUCCESS;
}
}
break;
#endif
#ifdef CONFIG_NRF700X_RAW_DATA_TX
#if defined(CONFIG_NRF700X_RAW_DATA_TX) || defined(CONFIG_NRF700X_RAW_DATA_RX)
case NRF_WIFI_EVENT_CHANNEL_SET_DONE:
struct nrf_wifi_event_set_channel *channel_event;

Expand All @@ -957,6 +989,18 @@ static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx
status = NRF_WIFI_STATUS_SUCCESS;
break;
#endif /* CONFIG_NRF700X_RAW_DATA_TX */
#ifdef CONFIG_NRF700X_RAW_DATA_RX
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_RAW_DATA_RX */
default:
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
"%s: Unknown event recd: %d",
Expand Down
48 changes: 46 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 @@ -1067,7 +1067,7 @@ enum nrf_wifi_status nrf_wifi_fmac_set_mode(void *dev_ctx,
return status;
}

#ifdef CONFIG_NRF700X_RAW_DATA_TX
#if defined(CONFIG_NRF700X_RAW_DATA_TX) || defined(CONFIG_NRF700X_RAW_DATA_RX)
enum nrf_wifi_status nrf_wifi_fmac_set_channel(void *dev_ctx,
unsigned char if_idx,
unsigned int channel)
Expand Down Expand Up @@ -1109,4 +1109,48 @@ enum nrf_wifi_status nrf_wifi_fmac_set_channel(void *dev_ctx,
out:
return status;
}
#endif /* CONFIG_NRF700X_RAW_DATA_TX */
#endif /* CONFIG_NRF700X_RAW_DATA_TX || CONFIG_NRF700X_RAW_DATA_RX */

#ifdef CONFIG_NRF700X_RAW_DATA_RX
enum nrf_wifi_status nrf_wifi_fmac_set_packet_filter(void *dev_ctx, unsigned char filter,
unsigned char if_idx,
unsigned short buffer_size)
{
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
struct nrf_wifi_cmd_raw_config_filter *umac_cmd_data = NULL;
struct host_rpu_msg *umac_cmd = NULL;
struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = dev_ctx;
int len = 0;

if (!fmac_dev_ctx) {
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
"%s: Invalid parameters\n",
__func__);
goto out;
}

len = sizeof(*umac_cmd_data);
umac_cmd = umac_cmd_alloc(fmac_dev_ctx,
NRF_WIFI_HOST_RPU_MSG_TYPE_SYSTEM,
len);
if (!umac_cmd) {
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
"%s: umac_cmd_alloc failed\n",
__func__);
goto out;
}

umac_cmd_data = (struct nrf_wifi_cmd_raw_config_filter *)(umac_cmd->msg);
umac_cmd_data->sys_head.cmd_event = NRF_WIFI_CMD_RAW_CONFIG_FILTER;
umac_cmd_data->sys_head.len = len;
umac_cmd_data->if_index = if_idx;
umac_cmd_data->filter = filter;
umac_cmd_data->capture_len = buffer_size;

status = nrf_wifi_hal_ctrl_cmd_send(fmac_dev_ctx->hal_dev_ctx,
umac_cmd,
(sizeof(*umac_cmd) + len));
out:
return status;
}
#endif /* CONFIG_NRF700X_RAW_DATA_RX */
6 changes: 3 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 @@ -353,8 +353,7 @@ enum nrf_wifi_status nrf_wifi_check_mode_validity(unsigned char mode)
*/
if ((mode ^ NRF_WIFI_STA_MODE) == 0) {
return NRF_WIFI_STATUS_SUCCESS;
} else if ((mode ^ (NRF_WIFI_STA_MODE |
NRF_WIFI_TX_INJECTION_MODE)) == 0) {
} else if ((mode ^ NRF_WIFI_MONITOR_MODE) == 0) {
return NRF_WIFI_STATUS_SUCCESS;
}
return NRF_WIFI_STATUS_FAIL;
Expand All @@ -363,7 +362,8 @@ enum nrf_wifi_status nrf_wifi_check_mode_validity(unsigned char mode)
#ifdef CONFIG_NRF700X_RAW_DATA_TX
bool nrf_wifi_util_is_rawpktmode_enabled(struct nrf_wifi_fmac_vif_ctx *vif)
{
if (vif->if_type == NRF_WIFI_STA_TX_INJECTOR) {
if ((vif->if_type == NRF_WIFI_STA_TX_INJECTOR) ||
(vif->if_type == NRF_WIFI_MONITOR_TX_INJECTOR)) {
return true;
}
return false;
Expand Down
20 changes: 18 additions & 2 deletions nrf_wifi/fw_if/umac_if/src/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_event_process(struct nrf_wifi_fmac_dev_ctx
struct nrf_wifi_fmac_vif_ctx *vif_ctx = NULL;
struct nrf_wifi_fmac_buf_map_info *rx_buf_info = NULL;
struct nrf_wifi_fmac_rx_pool_map_info pool_info;
#ifdef CONFIG_NRF700X_RAW_DATA_RX
struct raw_rx_pkt_header raw_rx_hdr;
#endif /* CONFIG_NRF700X_RAW_DATA_RX */
void *nwb = NULL;
void *nwb_data = NULL;
unsigned int num_pkts = 0;
Expand Down Expand Up @@ -359,9 +362,22 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_event_process(struct nrf_wifi_fmac_dev_ctx
#endif /* CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS */
nrf_wifi_osal_nbuf_free(fmac_dev_ctx->fpriv->opriv,
nwb);
} else {
}
#ifdef CONFIG_NRF700X_RAW_DATA_RX
else if (config->rx_pkt_type == NRF_WIFI_RAW_RX_PKT) {
raw_rx_hdr.frequency = config->frequency;
raw_rx_hdr.signal = config->signal;
raw_rx_hdr.rate_flags = config->rate_flags;
raw_rx_hdr.rate = config->rate;

def_priv->callbk_fns.rx_sniffer_frm_callbk_fn(vif_ctx->os_vif_ctx,
nwb,
&raw_rx_hdr);
}
#endif /* CONFIG_NRF700X_RAW_DATA_RX */
else {
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
"%s: Invalid frame type recd %d",
"%s: Invalid frame type received %d",
__func__,
config->rx_pkt_type);
status = NRF_WIFI_STATUS_FAIL;
Expand Down
Loading