All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: <linux-wireless@vger.kernel.org>
Cc: <gary.chang@realtek.com>, <timlee@realtek.com>
Subject: [PATCH 03/12] wifi: rtw89: wow: parsing Auth Key Management from associate request
Date: Thu, 25 Apr 2024 19:28:07 +0800	[thread overview]
Message-ID: <20240425112816.26431-4-pkshih@realtek.com> (raw)
In-Reply-To: <20240425112816.26431-1-pkshih@realtek.com>

From: Chih-Kang Chang <gary.chang@realtek.com>

Need Auth Key Management(AKM) to let firmware to generate appropriate
EAPoL packet for GTK rekey. The AKM is present in the association request
RSN IE to indicate which cipher that station selected.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtw89/core.c |  3 +++
 drivers/net/wireless/realtek/rtw89/core.h |  1 +
 drivers/net/wireless/realtek/rtw89/wow.c  | 15 +++++++++++++++
 drivers/net/wireless/realtek/rtw89/wow.h  | 17 +++++++++++++++++
 4 files changed, 36 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index dda69e8d114d..ce5126ed876e 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -18,6 +18,7 @@
 #include "ser.h"
 #include "txrx.h"
 #include "util.h"
+#include "wow.h"
 
 static bool rtw89_disable_ps_mode;
 module_param_named(disable_ps_mode, rtw89_disable_ps_mode, bool, 0644);
@@ -254,6 +255,8 @@ static void rtw89_traffic_stats_accu(struct rtw89_dev *rtwdev,
 				     struct sk_buff *skb, bool tx)
 {
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+	if (tx && ieee80211_is_assoc_req(hdr->frame_control))
+		rtw89_wow_parse_akm(rtwdev, skb);
 
 	if (!ieee80211_is_data(hdr->frame_control))
 		return;
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 9da8be9927d3..834e19c533ae 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -5161,6 +5161,7 @@ struct rtw89_wow_param {
 	DECLARE_BITMAP(flags, RTW89_WOW_FLAG_NUM);
 	struct rtw89_wow_cam_info patterns[RTW89_MAX_PATTERN_NUM];
 	u8 pattern_cnt;
+	u8 akm;
 };
 
 struct rtw89_mcc_limit {
diff --git a/drivers/net/wireless/realtek/rtw89/wow.c b/drivers/net/wireless/realtek/rtw89/wow.c
index ea555f29442d..dcae75128c71 100644
--- a/drivers/net/wireless/realtek/rtw89/wow.c
+++ b/drivers/net/wireless/realtek/rtw89/wow.c
@@ -12,6 +12,21 @@
 #include "util.h"
 #include "wow.h"
 
+void rtw89_wow_parse_akm(struct rtw89_dev *rtwdev, struct sk_buff *skb)
+{
+	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;
+	struct rtw89_wow_param *rtw_wow = &rtwdev->wow;
+	const u8 *rsn, *ies = mgmt->u.assoc_req.variable;
+	struct rtw89_rsn_ie *rsn_ie;
+
+	rsn = cfg80211_find_ie(WLAN_EID_RSN, ies, skb->len);
+	if (!rsn)
+		return;
+
+	rsn_ie = (struct rtw89_rsn_ie *)rsn;
+	rtw_wow->akm = rsn_ie->akm_cipher_suite.type;
+}
+
 static void rtw89_wow_leave_deep_ps(struct rtw89_dev *rtwdev)
 {
 	__rtw89_leave_ps_mode(rtwdev);
diff --git a/drivers/net/wireless/realtek/rtw89/wow.h b/drivers/net/wireless/realtek/rtw89/wow.h
index a2f7b2e3cdb4..1fbb112c4c1a 100644
--- a/drivers/net/wireless/realtek/rtw89/wow.h
+++ b/drivers/net/wireless/realtek/rtw89/wow.h
@@ -15,7 +15,24 @@ enum rtw89_wake_reason {
 	RTW89_WOW_RSN_RX_NLO = 0x55,
 };
 
+struct rtw89_cipher_suite {
+	u8 oui[3];
+	u8 type;
+} __packed;
+
+struct rtw89_rsn_ie {
+	u8 tag_number;
+	u8 tag_length;
+	__le16 rsn_version;
+	struct rtw89_cipher_suite group_cipher_suite;
+	__le16 pairwise_cipher_suite_cnt;
+	struct rtw89_cipher_suite pairwise_cipher_suite;
+	__le16 akm_cipher_suite_cnt;
+	struct rtw89_cipher_suite akm_cipher_suite;
+} __packed;
+
 int rtw89_wow_suspend(struct rtw89_dev *rtwdev, struct cfg80211_wowlan *wowlan);
 int rtw89_wow_resume(struct rtw89_dev *rtwdev);
+void rtw89_wow_parse_akm(struct rtw89_dev *rtwdev, struct sk_buff *skb);
 
 #endif
-- 
2.25.1


  parent reply	other threads:[~2024-04-25 11:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-25 11:28 [PATCH 00/12] wifi: rtw89: wow: support more exchange in WoWLAN mode Ping-Ke Shih
2024-04-25 11:28 ` [PATCH 01/12] wifi: rtw89: wow: send RFK pre-nofity H2C command " Ping-Ke Shih
2024-04-25 11:28 ` [PATCH 02/12] wifi: rtw89: wow: refine WoWLAN flows of HCI interrupts and low power mode Ping-Ke Shih
2024-04-25 11:28 ` Ping-Ke Shih [this message]
2024-05-01 14:37   ` [PATCH 03/12] wifi: rtw89: wow: parsing Auth Key Management from associate request kernel test robot
2024-05-02  1:16     ` Ping-Ke Shih
2024-04-25 11:28 ` [PATCH 04/12] wifi: rtw89: wow: prepare PTK GTK info from mac80211 Ping-Ke Shih
2024-04-25 11:28 ` [PATCH 05/12] wifi: rtw89: use struct to access firmware command h2c_dctl_sec_cam_v1 Ping-Ke Shih
2024-04-25 11:28 ` [PATCH 06/12] wifi: rtw89: use struct to fill H2C of WoWLAN global configuration Ping-Ke Shih
2024-04-25 11:28 ` [PATCH 07/12] wifi: rtw89: wow: construct EAPoL packet for GTK rekey offload Ping-Ke Shih
2024-04-25 11:28 ` [PATCH 08/12] wifi: rtw89: wow: add GTK rekey feature related H2C commands Ping-Ke Shih
2024-04-25 11:28 ` [PATCH 09/12] wifi: rtw89: wow: update latest PTK GTK info to mac80211 after resume Ping-Ke Shih
2024-04-25 11:28 ` [PATCH 10/12] wifi: rtw89: wow: support 802.11w PMF IGTK rekey Ping-Ke Shih
2024-04-25 11:28 ` [PATCH 11/12] wifi: rtw89: wow: support WEP cipher on WoWLAN Ping-Ke Shih
2024-04-25 11:28 ` [PATCH 12/12] wifi: rtw89: wow: add ARP offload feature Ping-Ke Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240425112816.26431-4-pkshih@realtek.com \
    --to=pkshih@realtek.com \
    --cc=gary.chang@realtek.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=timlee@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.