From: Rishik Yechuri <epicrishik@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Rishik Yechuri <rishik.yechuri.code@gmail.com>
Subject: [PATCH 09/10] staging: rtl8723bs: use IEEE80211_QOS_CTL_* masks for QoS control
Date: Tue, 13 Oct 2026 15:15:37 -0500 [thread overview]
Message-ID: <20261013201538.43156-10-rishik.yechuri.code@gmail.com> (raw)
In-Reply-To: <20261013201538.43156-1-rishik.yechuri.code@gmail.com>
The driver reads and writes the QoS Control field with the
SetPriority(), GetPriority(), SetEOSP(), SetAckpolicy(),
GetAckpolicy() and GetAMsdu() macros, which shift and mask the field
by hand. <linux/ieee80211.h> defines IEEE80211_QOS_CTL_* masks for the
TID, EOSP, Ack Policy and A-MSDU Present subfields.
On transmit, set the subfields with le16_encode_bits() and the
corresponding masks, and declare the QoS Control pointers as __le16
to match the byte order of the field. le16_encode_bits() masks the
value to the width of the subfield, as the macros did.
On receive, locate the field with ieee80211_get_qos_ctl() instead of
a fixed offset of 24 bytes, and extract the subfields with
u8_get_bits(). Frames with four addresses are rejected by
validate_recv_data_frame() before the QoS Control field is parsed, so
the helper always returns the same offset as before.
Remove the macro definitions, which no longer have any users.
No functional change intended.
Signed-off-by: Rishik Yechuri <rishik.yechuri.code@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 10 +++++-----
drivers/staging/rtl8723bs/core/rtw_recv.c | 8 +++++---
drivers/staging/rtl8723bs/core/rtw_xmit.c | 12 +++++++-----
drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 8 ++++----
drivers/staging/rtl8723bs/include/wifi.h | 15 ---------------
5 files changed, 21 insertions(+), 32 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index ec0046d3a..4d8073d48 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -3039,7 +3039,7 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da,
unsigned char *pframe;
struct ieee80211_hdr *pwlanhdr;
__le16 *fctrl;
- u16 *qc;
+ __le16 *qc;
struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
@@ -3071,13 +3071,13 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da,
else if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE)
*fctrl |= cpu_to_le16(IEEE80211_FCTL_TODS);
- qc = (unsigned short *)(pframe + pattrib->hdrlen - 2);
+ qc = (__le16 *)(pframe + pattrib->hdrlen - 2);
- SetPriority(qc, tid);
+ *qc |= le16_encode_bits(tid, IEEE80211_QOS_CTL_TID_MASK);
- SetEOSP(qc, pattrib->eosp);
+ *qc |= le16_encode_bits(pattrib->eosp, IEEE80211_QOS_CTL_EOSP);
- SetAckpolicy(qc, pattrib->ack_policy);
+ *qc |= le16_encode_bits(pattrib->ack_policy, IEEE80211_QOS_CTL_ACK_POLICY_MASK);
memcpy(pwlanhdr->addr1, da, ETH_ALEN);
memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN);
diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index b09ea6f76..a7462444e 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -1309,9 +1309,11 @@ static signed int validate_recv_data_frame(struct adapter *adapter, union recv_f
pattrib->ack_policy = 0;
/* parsing QC field */
if (pattrib->qos == 1) {
- pattrib->priority = GetPriority((ptr + 24));
- pattrib->ack_policy = GetAckpolicy((ptr + 24));
- pattrib->amsdu = GetAMsdu((ptr + 24));
+ u8 *qc = ieee80211_get_qos_ctl(hdr);
+
+ pattrib->priority = u8_get_bits(*qc, IEEE80211_QOS_CTL_TID_MASK);
+ pattrib->ack_policy = u8_get_bits(*qc, IEEE80211_QOS_CTL_ACK_POLICY_MASK);
+ pattrib->amsdu = u8_get_bits(*qc, IEEE80211_QOS_CTL_A_MSDU_PRESENT);
pattrib->hdrlen = pattrib->to_fr_ds == 3 ? 32 : 26;
if (pattrib->priority != 0 && pattrib->priority != 3)
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 1624bf6de..290e7e589 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -904,7 +904,7 @@ static void xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxm
int rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib)
{
- u16 *qc;
+ __le16 *qc;
struct ieee80211_hdr *pwlanhdr = (struct ieee80211_hdr *)hdr;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -956,14 +956,16 @@ int rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
*fctrl |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
if (qos_option) {
- qc = (unsigned short *)(hdr + pattrib->hdrlen - 2);
+ qc = (__le16 *)(hdr + pattrib->hdrlen - 2);
if (pattrib->priority)
- SetPriority(qc, pattrib->priority);
+ *qc |= le16_encode_bits(pattrib->priority,
+ IEEE80211_QOS_CTL_TID_MASK);
- SetEOSP(qc, pattrib->eosp);
+ *qc |= le16_encode_bits(pattrib->eosp, IEEE80211_QOS_CTL_EOSP);
- SetAckpolicy(qc, pattrib->ack_policy);
+ *qc |= le16_encode_bits(pattrib->ack_policy,
+ IEEE80211_QOS_CTL_ACK_POLICY_MASK);
}
/* TODO: fill HT Control Field */
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
index 756d6dc84..24cf2b6eb 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
@@ -260,8 +260,8 @@ static void ConstructNullFunctionData(struct adapter *padapter,
*fctrl |= cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC);
pwlanqoshdr = (struct ieee80211_qos_hdr *)pframe;
- SetPriority(&pwlanqoshdr->qos_ctrl, AC);
- SetEOSP(&pwlanqoshdr->qos_ctrl, bEosp);
+ pwlanqoshdr->qos_ctrl |= le16_encode_bits(AC, IEEE80211_QOS_CTL_TID_MASK);
+ pwlanqoshdr->qos_ctrl |= le16_encode_bits(bEosp, IEEE80211_QOS_CTL_EOSP);
pktlen = sizeof(struct ieee80211_qos_hdr);
} else {
@@ -748,8 +748,8 @@ static void ConstructBtNullFunctionData(struct adapter *padapter,
*fctrl |= cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC);
pwlanqoshdr = (struct ieee80211_qos_hdr *)pframe;
- SetPriority(&pwlanqoshdr->qos_ctrl, AC);
- SetEOSP(&pwlanqoshdr->qos_ctrl, bEosp);
+ pwlanqoshdr->qos_ctrl |= le16_encode_bits(AC, IEEE80211_QOS_CTL_TID_MASK);
+ pwlanqoshdr->qos_ctrl |= le16_encode_bits(bEosp, IEEE80211_QOS_CTL_EOSP);
pktlen = sizeof(struct ieee80211_qos_hdr);
} else {
diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h
index 85348979a..d1bb9076d 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -18,21 +18,6 @@
/* This test verifies the WLAN NIC can update the NAV through sending the CTS with large duration. */
#define WiFiNavUpperUs 30000 /* 30 ms */
-#define SetPriority(pbuf, tid) \
- (*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf))
-
-#define GetPriority(pbuf) ((le16_to_cpu(*(__le16 *)(pbuf))) & 0xf)
-
-#define SetEOSP(pbuf, eosp) \
- (*(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4))
-
-#define SetAckpolicy(pbuf, ack) \
- (*(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5))
-
-#define GetAckpolicy(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 5) & 0x3)
-
-#define GetAMsdu(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1)
-
static inline unsigned char *rtl8723bs_get_ra(unsigned char *pframe)
{
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
--
2.43.0
next prev parent reply other threads:[~2026-10-13 20:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 20:15 [PATCH 00/10] staging: rtl8723bs: replace private 802.11 header macros with generic helpers Rishik Yechuri
2026-10-13 20:15 ` [PATCH 01/10] staging: rtl8723bs: use struct ieee80211_hdr for header addresses Rishik Yechuri
2026-10-13 20:15 ` [PATCH 02/10] staging: rtl8723bs: use ieee80211_has_*() to test frame control flags Rishik Yechuri
2026-10-13 20:15 ` [PATCH 03/10] staging: rtl8723bs: set frame control flags with IEEE80211_FCTL_* masks Rishik Yechuri
2026-10-13 20:15 ` [PATCH 04/10] staging: rtl8723bs: use ieee80211_is_*() for frame type tests Rishik Yechuri
2026-10-13 20:15 ` [PATCH 05/10] staging: rtl8723bs: use IEEE80211_FCTL_* masks for frame type dispatch Rishik Yechuri
2026-10-13 20:15 ` [PATCH 06/10] staging: rtl8723bs: remove unused num member from struct mlme_handler Rishik Yechuri
2026-10-13 20:15 ` [PATCH 07/10] staging: rtl8723bs: use IEEE80211_FTYPE_* and IEEE80211_STYPE_* values Rishik Yechuri
2026-10-13 20:15 ` [PATCH 08/10] staging: rtl8723bs: use struct ieee80211_hdr for seq_ctrl and duration_id Rishik Yechuri
2026-10-13 20:15 ` Rishik Yechuri [this message]
2026-10-13 20:15 ` [PATCH 10/10] staging: rtl8723bs: use ieee80211_get_DA() and ieee80211_get_SA() 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=20261013201538.43156-10-rishik.yechuri.code@gmail.com \
--to=epicrishik@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox