WCNCR00165815][rdk-b][common][bsp][Refactor and sync kernel/wifi from Openwrt]
[Description]
Refactor and sync kernel/wifi from Openwrt
[Release-log]
N/A
diff --git a/recipes-wifi/linux-mac80211/files/patches/subsys/912-mac80211-mtk-check-the-control-channel-before-downgr.patch b/recipes-wifi/linux-mac80211/files/patches/subsys/912-mac80211-mtk-check-the-control-channel-before-downgr.patch
new file mode 100644
index 0000000..1f115ef
--- /dev/null
+++ b/recipes-wifi/linux-mac80211/files/patches/subsys/912-mac80211-mtk-check-the-control-channel-before-downgr.patch
@@ -0,0 +1,55 @@
+From 8fe4d8388de19d99992da0dd6ba0ae90ed4141e9 Mon Sep 17 00:00:00 2001
+From: mtk31095 <michael-cy.lee@mediatek.com>
+Date: Fri, 16 Dec 2022 10:37:53 +0800
+Subject: [PATCH] mac80211: mtk: check the control channel before downgrading
+ the bandwidth
+
+Signed-off-by: mtk31095 <michael-cy.lee@mediatek.com>
+---
+ net/mac80211/mlme.c | 23 +++++++++++++++++++++++
+ 1 file changed, 23 insertions(+)
+
+diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
+index f97bf2b..8ee325a 100644
+--- a/net/mac80211/mlme.c
++++ b/net/mac80211/mlme.c
+@@ -5019,6 +5019,26 @@ ieee80211_verify_sta_he_mcs_support(struct ieee80211_sub_if_data *sdata,
+ return false;
+ }
+
++static bool ieee80211_check_same_ctrl_channel(struct ieee80211_sub_if_data *sdata,
++ const struct cfg80211_chan_def *chandef)
++{
++ struct ieee80211_local *local = sdata->local;
++ struct ieee80211_chanctx *ctx;
++
++ mutex_lock(&local->chanctx_mtx);
++ list_for_each_entry(ctx, &local->chanctx_list, list) {
++ if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED)
++ continue;
++ if (ctx->mode == IEEE80211_CHANCTX_EXCLUSIVE)
++ continue;
++ if (chandef->chan == ctx->conf.def.chan)
++ return true;
++ }
++
++ mutex_unlock(&local->chanctx_mtx);
++ return false;
++}
++
+ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
+ struct cfg80211_bss *cbss)
+ {
+@@ -5179,6 +5199,9 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
+ chandef.width == NL80211_CHAN_WIDTH_10)
+ goto out;
+
++ if (!ret || !ieee80211_check_same_ctrl_channel(sdata, &chandef))
++ goto out;
++
+ while (ret && chandef.width != NL80211_CHAN_WIDTH_20_NOHT) {
+ ifmgd->flags |= ieee80211_chandef_downgrade(&chandef);
+ ret = ieee80211_vif_use_channel(sdata, &chandef,
+--
+2.25.1
+
diff --git a/recipes-wifi/linux-mac80211/files/patches/subsys/912-mac80211-mtk-fix-tx-amsdu-aggregation.patch b/recipes-wifi/linux-mac80211/files/patches/subsys/912-mac80211-mtk-fix-tx-amsdu-aggregation.patch
new file mode 100644
index 0000000..15f19d3
--- /dev/null
+++ b/recipes-wifi/linux-mac80211/files/patches/subsys/912-mac80211-mtk-fix-tx-amsdu-aggregation.patch
@@ -0,0 +1,55 @@
+From 43a5e3f9890c25ec18756ba12b709c7a0e60404b Mon Sep 17 00:00:00 2001
+From: TomLiu <tomml.liu@mediatek.com>
+Date: Wed, 14 Dec 2022 00:26:50 -0800
+Subject: [PATCH]mac80211-mtk-fix-tx-amsdu-aggregation
+
+---
+ include/net/mac80211.h | 7 +++++++
+ net/mac80211/agg-tx.c | 6 ++++--
+ 2 files changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/include/net/mac80211.h b/include/net/mac80211.h
+index 9a38b9f..bf4469b 100755
+--- a/include/net/mac80211.h
++++ b/include/net/mac80211.h
+@@ -2675,6 +2675,13 @@ static inline void _ieee80211_hw_set(struct ieee80211_hw *hw,
+ }
+ #define ieee80211_hw_set(hw, flg) _ieee80211_hw_set(hw, IEEE80211_HW_##flg)
+
++static inline void _ieee80211_hw_clear(struct ieee80211_hw *hw,
++ enum ieee80211_hw_flags flg)
++{
++ return __clear_bit(flg, hw->flags);
++}
++#define ieee80211_hw_clear(hw, flg) _ieee80211_hw_clear(hw, IEEE80211_HW_##flg)
++
+ /**
+ * struct ieee80211_scan_request - hw scan request
+ *
+diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
+index c30f02d..f43f653 100755
+--- a/net/mac80211/agg-tx.c
++++ b/net/mac80211/agg-tx.c
+@@ -66,7 +66,8 @@ static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata,
+ struct ieee80211_local *local = sdata->local;
+ struct sk_buff *skb;
+ struct ieee80211_mgmt *mgmt;
+- u16 capab;
++ u16 capab = 0;
++ bool amsdu = ieee80211_hw_check(&local->hw, SUPPORTS_AMSDU_IN_AMPDU);
+
+ skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom);
+
+@@ -95,7 +96,8 @@ static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata,
+ mgmt->u.action.u.addba_req.action_code = WLAN_ACTION_ADDBA_REQ;
+
+ mgmt->u.action.u.addba_req.dialog_token = dialog_token;
+- capab = IEEE80211_ADDBA_PARAM_AMSDU_MASK;
++ if (amsdu)
++ capab = IEEE80211_ADDBA_PARAM_AMSDU_MASK;
+ capab |= IEEE80211_ADDBA_PARAM_POLICY_MASK;
+ capab |= u16_encode_bits(tid, IEEE80211_ADDBA_PARAM_TID_MASK);
+ capab |= u16_encode_bits(agg_size, IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK);
+--
+2.32.0
+
diff --git a/recipes-wifi/linux-mac80211/files/patches/subsys/subsys.inc b/recipes-wifi/linux-mac80211/files/patches/subsys/subsys.inc
index 355e6bd..35cdbc6 100644
--- a/recipes-wifi/linux-mac80211/files/patches/subsys/subsys.inc
+++ b/recipes-wifi/linux-mac80211/files/patches/subsys/subsys.inc
@@ -61,6 +61,8 @@
file://909-cfg80211-mtk-implement-DFS-status-show-cac-and-nop-s.patch \
file://910-mac80211-mtk-Set-TWT-Information-Frame-Disabled-bit-.patch \
file://911-mac80211-mtk-fix-the-issue-of-AP-and-STA-starting-on.patch \
+ file://912-mac80211-mtk-check-the-control-channel-before-downgr.patch \
+ file://912-mac80211-mtk-fix-tx-amsdu-aggregation.patch \
file://99900-mac80211-mtk-mask-kernel-version-limitation-and-fil.patch \
file://99901-mac80211-mtk-add-fill-receive-path-ops-to-get-wed-i.patch \
"