From: Rishik Yechuri <epicrishik@gmail.com>
To: Ping-Ke Shih <pkshih@realtek.com>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
Rishik Yechuri <rishik.yechuri.code@gmail.com>
Subject: [PATCH rtw-next 1/6] wifi: rtlwifi: use struct ieee80211_pspoll for the PS Poll reserved page
Date: Tue, 10 Nov 2026 12:44:04 -0600 [thread overview]
Message-ID: <20261110184409.42205-2-rishik.yechuri.code@gmail.com> (raw)
In-Reply-To: <20261110184409.42205-1-rishik.yechuri.code@gmail.com>
The reserved page builders fill in the PS Poll template with the
SET_80211_PS_POLL_* macros from base.h, which write at fixed byte
offsets into a u8 buffer. The AID macro stores a host order u16, so
the frame is only correct on a little endian machine.
Point at the template with struct ieee80211_pspoll from
<linux/ieee80211.h> instead. Its aid member is __le16, so the AID goes
through cpu_to_le16() and sparse can check it. The two addresses are
copied with ether_addr_copy() on the struct members. Remove the three
macros.
On little endian systems the bytes written are the same as before.
Signed-off-by: Rishik Yechuri <rishik.yechuri.code@gmail.com>
Assisted-by: Claude:claude-fable-5-1
---
drivers/net/wireless/realtek/rtlwifi/base.h | 7 -------
.../wireless/realtek/rtlwifi/rtl8188ee/fw.c | 10 +++++-----
.../realtek/rtlwifi/rtl8192c/fw_common.c | 10 +++++-----
.../wireless/realtek/rtlwifi/rtl8192de/fw.c | 10 +++++-----
.../wireless/realtek/rtlwifi/rtl8192ee/fw.c | 10 +++++-----
.../wireless/realtek/rtlwifi/rtl8723ae/fw.c | 10 +++++-----
.../wireless/realtek/rtlwifi/rtl8723be/fw.c | 10 +++++-----
.../wireless/realtek/rtlwifi/rtl8821ae/fw.c | 20 +++++++++----------
8 files changed, 40 insertions(+), 47 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtlwifi/base.h b/drivers/net/wireless/realtek/rtlwifi/base.h
index f3a6a43a42ec..870ca1dff3ee 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.h
+++ b/drivers/net/wireless/realtek/rtlwifi/base.h
@@ -46,13 +46,6 @@ enum ap_peer {
#define MAX_LISTEN_INTERVAL 10
#define MAX_RATE_TRIES 4
-#define SET_80211_PS_POLL_AID(_hdr, _val) \
- (*(u16 *)((u8 *)(_hdr) + 2) = _val)
-#define SET_80211_PS_POLL_BSSID(_hdr, _val) \
- ether_addr_copy(((u8 *)(_hdr)) + 4, (u8 *)(_val))
-#define SET_80211_PS_POLL_TA(_hdr, _val) \
- ether_addr_copy(((u8 *)(_hdr))+10, (u8 *)(_val))
-
#define SET_80211_HDR_ADDRESS1(_hdr, _val) \
CP_MACADDR((u8 *)(_hdr)+FRAME_OFFSET_ADDRESS1, (u8 *)(_val))
#define SET_80211_HDR_ADDRESS2(_hdr, _val) \
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c
index 9a9f9e14f472..cda9388388ab 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c
@@ -545,7 +545,7 @@ void rtl88e_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
u8 u1rsvdpageloc[5] = { 0 };
bool b_dlok = false;
u8 *beacon;
- u8 *p_pspoll;
+ struct ieee80211_pspoll *p_pspoll;
u8 *nullfunc;
u8 *p_probersp;
@@ -561,10 +561,10 @@ void rtl88e_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
* (2) ps-poll
*--------------------------------------------------------
*/
- p_pspoll = &reserved_page_packet[PSPOLL_PG * 128];
- SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000));
- SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid);
- SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr);
+ p_pspoll = (struct ieee80211_pspoll *)&reserved_page_packet[PSPOLL_PG * 128];
+ p_pspoll->aid = cpu_to_le16(mac->assoc_id | 0xc000);
+ ether_addr_copy(p_pspoll->bssid, mac->bssid);
+ ether_addr_copy(p_pspoll->ta, mac->mac_addr);
SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1rsvdpageloc, PSPOLL_PG);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c
index b618f07f29b0..3e8befbcf865 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c
@@ -573,7 +573,7 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
bool b_dlok = false;
u8 *beacon;
- u8 *p_pspoll;
+ struct ieee80211_pspoll *p_pspoll;
u8 *nullfunc;
u8 *p_probersp;
/*---------------------------------------------------------
@@ -586,10 +586,10 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
/*-------------------------------------------------------
(2) ps-poll
--------------------------------------------------------*/
- p_pspoll = &reserved_page_packet[PSPOLL_PG * 128];
- SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000));
- SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid);
- SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr);
+ p_pspoll = (struct ieee80211_pspoll *)&reserved_page_packet[PSPOLL_PG * 128];
+ p_pspoll->aid = cpu_to_le16(mac->assoc_id | 0xc000);
+ ether_addr_copy(p_pspoll->bssid, mac->bssid);
+ ether_addr_copy(p_pspoll->ta, mac->mac_addr);
SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1rsvdpageloc, PSPOLL_PG);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c
index c8444a72ff69..23c7b088e8cd 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c
@@ -260,7 +260,7 @@ void rtl92d_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished)
u8 u1rsvdpageloc[3] = { PROBERSP_PG, PSPOLL_PG, NULL_PG };
bool dlok = false;
u8 *beacon;
- u8 *p_pspoll;
+ struct ieee80211_pspoll *p_pspoll;
u8 *nullfunc;
u8 *p_probersp;
/*---------------------------------------------------------
@@ -272,10 +272,10 @@ void rtl92d_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished)
/*-------------------------------------------------------
(2) ps-poll
--------------------------------------------------------*/
- p_pspoll = &reserved_page_packet[PSPOLL_PG * 128];
- SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000));
- SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid);
- SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr);
+ p_pspoll = (struct ieee80211_pspoll *)&reserved_page_packet[PSPOLL_PG * 128];
+ p_pspoll->aid = cpu_to_le16(mac->assoc_id | 0xc000);
+ ether_addr_copy(p_pspoll->bssid, mac->bssid);
+ ether_addr_copy(p_pspoll->ta, mac->mac_addr);
/*--------------------------------------------------------
(3) null data
---------------------------------------------------------*/
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
index 3728e3ec2c25..e50db134682f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
@@ -663,7 +663,7 @@ void rtl92ee_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
bool b_dlok = false;
u8 *beacon;
- u8 *p_pspoll;
+ struct ieee80211_pspoll *p_pspoll;
u8 *nullfunc;
u8 *p_probersp;
u8 *qosnull;
@@ -680,10 +680,10 @@ void rtl92ee_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
* (2) ps-poll
*--------------------------------------------------------
*/
- p_pspoll = &reserved_page_packet[PSPOLL_PG * 128];
- SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000));
- SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid);
- SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr);
+ p_pspoll = (struct ieee80211_pspoll *)&reserved_page_packet[PSPOLL_PG * 128];
+ p_pspoll->aid = cpu_to_le16(mac->assoc_id | 0xc000);
+ ether_addr_copy(p_pspoll->bssid, mac->bssid);
+ ether_addr_copy(p_pspoll->ta, mac->mac_addr);
SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1rsvdpageloc, PSPOLL_PG);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/fw.c
index d1b50a80c191..63c55dae2aab 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/fw.c
@@ -393,7 +393,7 @@ void rtl8723e_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
u8 u1rsvdpageloc[3] = { 0 };
bool b_dlok = false;
u8 *beacon;
- u8 *p_pspoll;
+ struct ieee80211_pspoll *p_pspoll;
u8 *nullfunc;
u8 *p_probersp;
@@ -409,10 +409,10 @@ void rtl8723e_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
* (2) ps-poll
*--------------------------------------------------------
*/
- p_pspoll = &reserved_page_packet[PSPOLL_PG * 128];
- SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000));
- SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid);
- SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr);
+ p_pspoll = (struct ieee80211_pspoll *)&reserved_page_packet[PSPOLL_PG * 128];
+ p_pspoll->aid = cpu_to_le16(mac->assoc_id | 0xc000);
+ ether_addr_copy(p_pspoll->bssid, mac->bssid);
+ ether_addr_copy(p_pspoll->ta, mac->mac_addr);
SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1rsvdpageloc, PSPOLL_PG);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c
index b3e6c91e26c0..33c8fb0c49ed 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c
@@ -484,7 +484,7 @@ void rtl8723be_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
bool b_dlok = false;
u8 *beacon;
- u8 *p_pspoll;
+ struct ieee80211_pspoll *p_pspoll;
u8 *nullfunc;
u8 *p_probersp;
u8 *qosnull;
@@ -501,10 +501,10 @@ void rtl8723be_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
* (2) ps-poll
*-------------------------------------------------------
*/
- p_pspoll = &reserved_page_packet[PSPOLL_PG * 128];
- SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000));
- SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid);
- SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr);
+ p_pspoll = (struct ieee80211_pspoll *)&reserved_page_packet[PSPOLL_PG * 128];
+ p_pspoll->aid = cpu_to_le16(mac->assoc_id | 0xc000);
+ ether_addr_copy(p_pspoll->bssid, mac->bssid);
+ ether_addr_copy(p_pspoll->ta, mac->mac_addr);
SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1rsvdpageloc, PSPOLL_PG);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c
index 4facbc0bff4e..ddae3a14f79e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c
@@ -1525,7 +1525,7 @@ void rtl8812ae_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
u8 u1rsvdpageloc2[7] = { 0 };
bool b_dlok = false;
u8 *beacon;
- u8 *p_pspoll;
+ struct ieee80211_pspoll *p_pspoll;
u8 *nullfunc;
u8 *qosnull;
u8 *btqosnull;
@@ -1547,10 +1547,10 @@ void rtl8812ae_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
* (2) ps-poll
*--------------------------------------------------------
*/
- p_pspoll = &reserved_page_packet_8812[PSPOLL_PG * 512];
- SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000));
- SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid);
- SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr);
+ p_pspoll = (struct ieee80211_pspoll *)&reserved_page_packet_8812[PSPOLL_PG * 512];
+ p_pspoll->aid = cpu_to_le16(mac->assoc_id | 0xc000);
+ ether_addr_copy(p_pspoll->bssid, mac->bssid);
+ ether_addr_copy(p_pspoll->ta, mac->mac_addr);
SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1rsvdpageloc, PSPOLL_PG);
@@ -1662,7 +1662,7 @@ void rtl8821ae_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
u8 u1rsvdpageloc2[7] = { 0 };
bool b_dlok = false;
u8 *beacon;
- u8 *p_pspoll;
+ struct ieee80211_pspoll *p_pspoll;
u8 *nullfunc;
u8 *qosnull;
u8 *btqosnull;
@@ -1684,10 +1684,10 @@ void rtl8821ae_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
* (2) ps-poll
*--------------------------------------------------------
*/
- p_pspoll = &reserved_page_packet_8821[PSPOLL_PG * 256];
- SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000));
- SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid);
- SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr);
+ p_pspoll = (struct ieee80211_pspoll *)&reserved_page_packet_8821[PSPOLL_PG * 256];
+ p_pspoll->aid = cpu_to_le16(mac->assoc_id | 0xc000);
+ ether_addr_copy(p_pspoll->bssid, mac->bssid);
+ ether_addr_copy(p_pspoll->ta, mac->mac_addr);
SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1rsvdpageloc, PSPOLL_PG);
--
2.43.0
next prev parent reply other threads:[~2026-11-10 18:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 18:44 [PATCH rtw-next 0/6] wifi: rtlwifi: replace the 802.11 header helper macros with kernel ones Rishik Yechuri
2026-11-10 18:44 ` Rishik Yechuri [this message]
2026-11-10 18:44 ` [PATCH rtw-next 2/6] wifi: rtlwifi: use struct ieee80211_hdr for the reserved page headers Rishik Yechuri
2026-11-10 18:44 ` [PATCH rtw-next 3/6] wifi: rtlwifi: call msecs_to_jiffies() directly Rishik Yechuri
2026-11-10 18:44 ` [PATCH rtw-next 4/6] wifi: rtlwifi: rtl8192se: use ALIGN() for the H2C command length Rishik Yechuri
2026-11-10 18:44 ` [PATCH rtw-next 5/6] wifi: rtlwifi: use ieee80211_is_ctl() instead of WLAN_FC_GET_TYPE() Rishik Yechuri
2026-11-10 18:44 ` [PATCH rtw-next 6/6] wifi: rtlwifi: remove byte(), packet_get_type() and FILL_OCTET_STRING() Rishik Yechuri
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=20261110184409.42205-2-rishik.yechuri.code@gmail.com \
--to=epicrishik@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=pkshih@realtek.com \
--cc=rishik.yechuri.code@gmail.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.