Skip to content

Commit

Permalink
nrf_wifi: Bring in Promiscuous mode filtering support in driver
Browse files Browse the repository at this point in the history
This set of changes brings in promiscuous mode filtering support in
the driver. Since, firmware would be unable to filter packets in
the case of promiscuous mode as it would lead to connection issues,
filtering support is moved to the driver for promiscuous mode.

Signed-off-by: Vivekananda Uppunda <[email protected]>
  • Loading branch information
VivekUppunda authored and krish2718 committed Oct 17, 2024
1 parent 4cc2464 commit af91488
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
8 changes: 4 additions & 4 deletions drivers/nrf_wifi/fw_if/umac_if/inc/default/fmac_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ struct nrf_wifi_fmac_callbk_fns {
signed short signal);
#endif /* NRF70_STA_MODE */
#if defined(NRF70_RAW_DATA_RX) || defined(NRF70_PROMISC_DATA_RX)
void (*rx_sniffer_frm_callbk_fn)(void *os_vif_ctx,
void *frm,
struct raw_rx_pkt_header *,
bool pkt_free);
void (*sniffer_callbk_fn)(void *os_vif_ctx,
void *frm,
struct raw_rx_pkt_header *,
bool pkt_free);
#endif /* NRF70_RAW_DATA_RX || NRF70_PROMISC_DATA_RX */
void (*reg_change_callbk_fn)(void *os_vif_ctx,
struct nrf_wifi_event_regulatory_change *reg_change,
Expand Down
47 changes: 36 additions & 11 deletions drivers/nrf_wifi/fw_if/umac_if/src/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "hal_api.h"
#include "fmac_rx.h"
#include "fmac_util.h"

#include "fmac_promisc.h"

static enum nrf_wifi_status
nrf_wifi_fmac_map_desc_to_pool(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
Expand Down Expand Up @@ -211,6 +211,9 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_event_process(struct nrf_wifi_fmac_dev_ctx
struct nrf_wifi_fmac_rx_pool_map_info pool_info;
#if defined(NRF70_RAW_DATA_RX) || defined(NRF70_PROMISC_DATA_RX)
struct raw_rx_pkt_header raw_rx_hdr;
#if defined(NRF70_PROMISC_DATA_RX)
unsigned short frame_control;
#endif
#endif /* NRF70_RAW_DATA_RX || NRF70_PROMISC_DATA_RX */
void *nwb = NULL;
void *nwb_data = NULL;
Expand Down Expand Up @@ -282,18 +285,25 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_event_process(struct nrf_wifi_fmac_dev_ctx
rx_buf_info->nwb = 0;
rx_buf_info->mapped = false;

#ifdef NRF70_PROMISC_DATA_RX
nrf_wifi_osal_mem_cpy(&frame_control,
nwb_data,
sizeof(unsigned short));
#endif

if (config->rx_pkt_type == NRF_WIFI_RX_PKT_DATA) {
#ifdef NRF70_PROMISC_DATA_RX
if (vif_ctx->promisc_mode) {
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,
false);
if (nrf_wifi_util_check_filt_setting(vif_ctx, &frame_control)) {
def_priv->callbk_fns.sniffer_callbk_fn(vif_ctx->os_vif_ctx,
nwb,
&raw_rx_hdr,
false);
}
}
#endif
#ifdef NRF70_STA_MODE
Expand Down Expand Up @@ -359,11 +369,26 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_event_process(struct nrf_wifi_fmac_dev_ctx
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,
true);
#if defined(NRF70_PROMISC_DATA_RX)
if (nrf_wifi_util_check_filt_setting(vif_ctx, &frame_control))
#endif
{
def_priv->callbk_fns.sniffer_callbk_fn(vif_ctx->os_vif_ctx,
nwb,
&raw_rx_hdr,
true);
}
#if defined(NRF70_PROMISC_DATA_RX)
/**
* In the case of Monitor mode, the sniffer callback function
* will free the packet. For promiscuous mode, if the packet
* is not meant to be sent up the stack, the packet needs
* to be freed here.
*/
else {
nrf_wifi_osal_nbuf_free(nwb);
}
#endif
}
#endif /* NRF70_RAW_DATA_RX || NRF70_PROMISC_DATA_RX */
else {
Expand Down

0 comments on commit af91488

Please sign in to comment.