diff mbox series

[RFC,v1,176/256] cl8k: add rx/rx_filter.c

Message ID 20210617160223.160998-177-viktor.barna@celeno.com
State New
Headers show
Series wireless: cl8k driver for Celeno IEEE 802.11ax devices | expand

Commit Message

Viktor Barna June 17, 2021, 4:01 p.m. UTC
From: Viktor Barna <viktor.barna@celeno.com>

(Part of the split. Please, take a look at the cover letter for more
details).

Signed-off-by: Viktor Barna <viktor.barna@celeno.com>
---
 .../net/wireless/celeno/cl8k/rx/rx_filter.c   | 88 +++++++++++++++++++
 1 file changed, 88 insertions(+)
 create mode 100644 drivers/net/wireless/celeno/cl8k/rx/rx_filter.c

--
2.30.0
diff mbox series

Patch

diff --git a/drivers/net/wireless/celeno/cl8k/rx/rx_filter.c b/drivers/net/wireless/celeno/cl8k/rx/rx_filter.c
new file mode 100644
index 000000000000..95415ec6aad0
--- /dev/null
+++ b/drivers/net/wireless/celeno/cl8k/rx/rx_filter.c
@@ -0,0 +1,88 @@ 
+// SPDX-License-Identifier: MIT
+/* Copyright(c) 2019-2021, Celeno Communications Ltd. */
+
+#include "rx/rx_filter.h"
+#include "fw/msg_tx.h"
+#include "ieee80211_i.h"
+
+u32 cl_rx_filter_update_flags(struct cl_hw *cl_hw, u32 filter)
+{
+       u32 rx_filter = 0;
+
+       if (filter & FIF_ALLMULTI)
+               rx_filter |= RX_CNTRL_ACCEPT_MULTICAST_BIT;
+
+       if (filter & (FIF_FCSFAIL | FIF_PLCPFAIL))
+               rx_filter |= RX_CNTRL_ACCEPT_ERROR_FRAMES_BIT;
+
+       if (filter & FIF_BCN_PRBRESP_PROMISC)
+               rx_filter |= RX_CNTRL_ACCEPT_OTHER_BSSID_BIT;
+
+       if (filter & FIF_CONTROL)
+               rx_filter |= RX_CNTRL_ACCEPT_OTHER_CNTRL_FRAMES_BIT |
+                            RX_CNTRL_ACCEPT_CF_END_BIT |
+                            RX_CNTRL_ACCEPT_ACK_BIT |
+                            RX_CNTRL_ACCEPT_CTS_BIT |
+                            RX_CNTRL_ACCEPT_RTS_BIT |
+                            RX_CNTRL_ACCEPT_BA_BIT | RX_CNTRL_ACCEPT_BAR_BIT;
+
+       if (filter & FIF_OTHER_BSS)
+               rx_filter |= RX_CNTRL_ACCEPT_OTHER_BSSID_BIT;
+
+       if (filter & FIF_PSPOLL)
+               rx_filter |= RX_CNTRL_ACCEPT_PS_POLL_BIT;
+
+       if (filter & FIF_PROBE_REQ)
+               rx_filter |= RX_CNTRL_ACCEPT_PROBE_REQ_BIT;
+
+       /* Add the filter flags that are set by default and cannot be changed here */
+       rx_filter |= CL_MAC80211_NOT_CHANGEABLE;
+
+       if (ieee80211_hw_check(cl_hw->hw, AMPDU_AGGREGATION))
+               rx_filter |= RX_CNTRL_ACCEPT_BA_BIT;
+
+       /*
+        * work around for HW bug (AD 14672)
+        * In order for the response frames to BAR and RTS be with correct
+        * power they should always be accepted and found in the KSR
+        */
+       rx_filter |= RX_CNTRL_ACCEPT_BAR_BIT | RX_CNTRL_ACCEPT_RTS_BIT;
+
+       return rx_filter;
+}
+
+static u32 cl_filter_get_flags(struct net_device *dev)
+{
+       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+       return sdata->local->filter_flags;
+}
+
+void cl_rx_filter_restore_flags(struct cl_hw *cl_hw)
+{
+       struct net_device *dev = cl_vif_get_first_net_device(cl_hw);
+       u32 filter = 0;
+
+       if (!dev)
+               return;
+
+       filter = cl_filter_get_flags(dev);
+       cl_dbg_verbose(cl_hw, "Restoring filter flags to 0x%x\n", filter);
+       cl_msg_tx_set_filter(cl_hw, filter, false);
+}
+
+void cl_rx_filter_set_promiscuous_off(unsigned long data)
+{
+       struct cl_hw *cl_hw = (struct cl_hw *)data;
+
+       cl_rx_filter_restore_flags(cl_hw);
+}
+
+void cl_rx_filter_set_promiscuous(struct cl_hw *cl_hw)
+{
+       u32 filter = ~(FIF_FCSFAIL | FIF_PLCPFAIL | (1 << 31));
+
+       cl_dbg_verbose(cl_hw, "set promiscuous mode 0x%x\n", filter);
+       cl_msg_tx_set_filter(cl_hw, filter, false);
+}
+