Skip to content

Instantly share code, notes, and snippets.

@codedwrench
Last active July 28, 2020 18:58
Show Gist options
  • Save codedwrench/d07927b4118d0265a692a06c49ea9031 to your computer and use it in GitHub Desktop.
Save codedwrench/d07927b4118d0265a692a06c49ea9031 to your computer and use it in GitHub Desktop.
Added promiscuous mode back into ath9k and some regulatory patches
diff --git a/drivers/net/wireless/ath/Kconfig b/drivers/net/wireless/ath/Kconfig
index b10972b6c..3493f00e4 100644
--- a/drivers/net/wireless/ath/Kconfig
+++ b/drivers/net/wireless/ath/Kconfig
@@ -23,6 +23,9 @@ config WLAN_VENDOR_ATH
if WLAN_VENDOR_ATH
+config ATH_USER_REGD
+ bool "Do not enforce EEPROM regulatory restrictions"
+
config ATH_DEBUG
bool "Atheros wireless debugging"
---help---
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index 791f66336..5cfb7bffc 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -1245,7 +1245,8 @@ static int ath9k_htc_config(struct ieee80211_hw *hw, u32 changed)
}
#define SUPPORTED_FILTERS \
- (FIF_ALLMULTI | \
+ (FIF_PROMISC_IN_BSS | \
+ FIF_ALLMULTI | \
FIF_CONTROL | \
FIF_PSPOLL | \
FIF_OTHER_BSS | \
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
index 118e5550b..6f5599b91 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
@@ -872,7 +872,14 @@ u32 ath9k_htc_calcrxfilter(struct ath9k_htc_priv *priv)
if (priv->rxfilter & FIF_PROBE_REQ)
rfilt |= ATH9K_RX_FILTER_PROBEREQ;
- if (ah->is_monitoring)
+ /*
+ * Set promiscuous mode when FIF_PROMISC_IN_BSS is enabled for station
+ * mode interface or when in monitor mode. AP mode does not need this
+ * since it receives all in-BSS frames anyway.
+ */
+ if (((ah->opmode != NL80211_IFTYPE_AP) &&
+ (priv->rxfilter & FIF_PROMISC_IN_BSS)) ||
+ ah->is_monitoring)
rfilt |= ATH9K_RX_FILTER_PROM;
if (priv->rxfilter & FIF_CONTROL)
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 17c318902..af0509721 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -831,6 +831,7 @@ static const struct ieee80211_iface_limit if_limits[] = {
BIT(NL80211_IFTYPE_AP) },
{ .max = 1, .types = BIT(NL80211_IFTYPE_P2P_CLIENT) |
BIT(NL80211_IFTYPE_P2P_GO) },
+ { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) },
};
#ifdef CONFIG_WIRELESS_WDS
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 457e9b0d2..bd0e1df4f 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1469,12 +1469,13 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
return 0;
}
-#define SUPPORTED_FILTERS \
- (FIF_ALLMULTI | \
+#define SUPPORTED_FILTERS \
+ (FIF_PROMISC_IN_BSS | \
+ FIF_ALLMULTI | \
FIF_CONTROL | \
FIF_PSPOLL | \
FIF_OTHER_BSS | \
- FIF_BCN_PRBRESP_PROMISC | \
+ FIF_BCN_PRBRESP_PROMISC | \
FIF_PROBE_REQ | \
FIF_FCSFAIL)
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 06e660858..da6b44b96 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -392,7 +392,14 @@ u32 ath_calcrxfilter(struct ath_softc *sc)
if (sc->cur_chan->rxfilter & FIF_PROBE_REQ)
rfilt |= ATH9K_RX_FILTER_PROBEREQ;
- if (sc->sc_ah->is_monitoring)
+ /*
+ * Set promiscuous mode when FIF_PROMISC_IN_BSS is enabled for station
+ * mode interface or when in monitor mode. AP mode does not need this
+ * since it receives all in-BSS frames anyway.
+ */
+ if (((sc->sc_ah->opmode != NL80211_IFTYPE_AP) &&
+ (sc->cur_chan->rxfilter & FIF_PROMISC_IN_BSS)) ||
+ (sc->sc_ah->is_monitoring))
rfilt |= ATH9K_RX_FILTER_PROM;
if ((sc->cur_chan->rxfilter & FIF_CONTROL) ||
diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
index bee9110b9..d22b0668a 100644
--- a/drivers/net/wireless/ath/regd.c
+++ b/drivers/net/wireless/ath/regd.c
@@ -24,6 +24,7 @@
#include "regd_common.h"
static int __ath_regd_init(struct ath_regulatory *reg);
+static struct reg_dmn_pair_mapping *ath_get_regpair(int regdmn);
/*
* This is a set of common rules used by our world regulatory domains.
@@ -188,6 +189,9 @@ static bool dynamic_country_user_possible(struct ath_regulatory *reg)
static bool ath_reg_dyn_country_user_allow(struct ath_regulatory *reg)
{
+#ifdef CONFIG_ATH_USER_REGD
+ return true;
+#endif
if (!IS_ENABLED(CONFIG_ATH_REG_DYNAMIC_USER_REG_HINTS))
return false;
if (!dynamic_country_user_possible(reg))
@@ -345,6 +349,10 @@ ath_reg_apply_beaconing_flags(struct wiphy *wiphy,
struct ieee80211_channel *ch;
unsigned int i;
+#ifdef CONFIG_ATH_USER_REGD
+ return;
+#endif
+
for (band = 0; band < NUM_NL80211_BANDS; band++) {
if (!wiphy->bands[band])
continue;
@@ -378,6 +386,10 @@ ath_reg_apply_ir_flags(struct wiphy *wiphy,
{
struct ieee80211_supported_band *sband;
+#ifdef CONFIG_ATH_USER_REGD
+ return;
+#endif
+
sband = wiphy->bands[NL80211_BAND_2GHZ];
if (!sband)
return;
@@ -407,6 +419,10 @@ static void ath_reg_apply_radar_flags(struct wiphy *wiphy,
struct ieee80211_channel *ch;
unsigned int i;
+#ifdef CONFIG_ATH_USER_REGD
+ return;
+#endif
+
if (!wiphy->bands[NL80211_BAND_5GHZ])
return;
@@ -639,6 +655,11 @@ ath_regd_init_wiphy(struct ath_regulatory *reg,
const struct ieee80211_regdomain *regd;
wiphy->reg_notifier = reg_notifier;
+
+#ifdef CONFIG_ATH_USER_REGD
+ return 0;
+#endif
+
wiphy->regulatory_flags |= REGULATORY_STRICT_REG |
REGULATORY_CUSTOM_REG;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment