From af91488c6edc4cebaf8b072c8bb258122a055cdb Mon Sep 17 00:00:00 2001 From: Vivekananda Uppunda Date: Mon, 7 Oct 2024 09:08:50 +0530 Subject: [PATCH] nrf_wifi: Bring in Promiscuous mode filtering support in driver 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 --- .../fw_if/umac_if/inc/default/fmac_structs.h | 8 ++-- drivers/nrf_wifi/fw_if/umac_if/src/rx.c | 47 ++++++++++++++----- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/drivers/nrf_wifi/fw_if/umac_if/inc/default/fmac_structs.h b/drivers/nrf_wifi/fw_if/umac_if/inc/default/fmac_structs.h index c58d7b84..e1f565c5 100644 --- a/drivers/nrf_wifi/fw_if/umac_if/inc/default/fmac_structs.h +++ b/drivers/nrf_wifi/fw_if/umac_if/inc/default/fmac_structs.h @@ -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, diff --git a/drivers/nrf_wifi/fw_if/umac_if/src/rx.c b/drivers/nrf_wifi/fw_if/umac_if/src/rx.c index 15bdf894..03ffc880 100644 --- a/drivers/nrf_wifi/fw_if/umac_if/src/rx.c +++ b/drivers/nrf_wifi/fw_if/umac_if/src/rx.c @@ -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, @@ -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; @@ -282,6 +285,12 @@ 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) { @@ -289,11 +298,12 @@ 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, - 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 @@ -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 {