From: Martin Kaiser <martin@kaiser.cx>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
Phillip Potter <phil@philpotter.co.uk>,
Michael Straube <straube.linux@gmail.com>,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Martin Kaiser <martin@kaiser.cx>
Subject: [PATCH 3/7] staging: r8188eu: use standard mechanisms for control frames
Date: Wed, 23 Mar 2022 08:48:55 +0100 [thread overview]
Message-ID: <20220323074859.177425-4-martin@kaiser.cx> (raw)
In-Reply-To: <20220323074859.177425-1-martin@kaiser.cx>
Use defines and macros from ieee80211.h to check for control frames and
to define control frame subtypes.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
drivers/staging/r8188eu/core/rtw_recv.c | 3 ++-
drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c | 3 ++-
drivers/staging/r8188eu/include/wifi.h | 21 ++++++-------------
3 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
index fa0ae1c1187b..f1983f3ff9f3 100644
--- a/drivers/staging/r8188eu/core/rtw_recv.c
+++ b/drivers/staging/r8188eu/core/rtw_recv.c
@@ -801,9 +801,10 @@ static int validate_recv_ctrl_frame(struct adapter *padapter,
struct rx_pkt_attrib *pattrib = &precv_frame->attrib;
struct sta_priv *pstapriv = &padapter->stapriv;
u8 *pframe = precv_frame->rx_data;
+ __le16 fc = *(__le16 *)pframe;
/* uint len = precv_frame->len; */
- if (GetFrameType(pframe) != WIFI_CTRL_TYPE)
+ if (!ieee80211_is_ctl(fc))
return _FAIL;
/* receive the frames that ra(a1) is my address */
diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c
index 9bf7a9248026..7e50a42b6f75 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c
@@ -113,12 +113,13 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe, struct phy_stat
struct hal_data_8188e *pHalData = &padapter->haldata;
struct phy_info *pPHYInfo = &pattrib->phy_info;
u8 *wlanhdr = precvframe->rx_data;
+ __le16 fc = *(__le16 *)wlanhdr;
struct odm_per_pkt_info pkt_info;
u8 *sa = NULL;
struct sta_priv *pstapriv;
struct sta_info *psta;
- pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) &&
+ pkt_info.bPacketMatchBSSID = ((!ieee80211_is_ctl(fc)) &&
!pattrib->icv_err && !pattrib->crc_err &&
!memcmp(get_hdr_bssid(wlanhdr),
get_bssid(&padapter->mlmepriv), ETH_ALEN));
diff --git a/drivers/staging/r8188eu/include/wifi.h b/drivers/staging/r8188eu/include/wifi.h
index 299553351246..47b73fde2006 100644
--- a/drivers/staging/r8188eu/include/wifi.h
+++ b/drivers/staging/r8188eu/include/wifi.h
@@ -13,7 +13,6 @@
#define WLAN_SSID_MAXLEN 32
enum WIFI_FRAME_TYPE {
- WIFI_CTRL_TYPE = (BIT(2)),
WIFI_DATA_TYPE = (BIT(3)),
WIFI_QOS_DATA_TYPE = (BIT(7)|BIT(3)), /* QoS Data */
};
@@ -34,13 +33,12 @@ enum WIFI_FRAME_SUBTYPE {
WIFI_ACTION = (BIT(7) | BIT(6) | BIT(4) | IEEE80211_FTYPE_MGMT),
/* below is for control frame */
- WIFI_PSPOLL = (BIT(7) | BIT(5) | WIFI_CTRL_TYPE),
- WIFI_RTS = (BIT(7) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
- WIFI_CTS = (BIT(7) | BIT(6) | WIFI_CTRL_TYPE),
- WIFI_ACK = (BIT(7) | BIT(6) | BIT(4) | WIFI_CTRL_TYPE),
- WIFI_CFEND = (BIT(7) | BIT(6) | BIT(5) | WIFI_CTRL_TYPE),
- WIFI_CFEND_CFACK = (BIT(7) | BIT(6) | BIT(5) | BIT(4) |
- WIFI_CTRL_TYPE),
+ WIFI_PSPOLL = (BIT(7) | BIT(5) | IEEE80211_FTYPE_CTL),
+ WIFI_RTS = (BIT(7) | BIT(5) | BIT(4) | IEEE80211_FTYPE_CTL),
+ WIFI_CTS = (BIT(7) | BIT(6) | IEEE80211_FTYPE_CTL),
+ WIFI_ACK = (BIT(7) | BIT(6) | BIT(4) | IEEE80211_FTYPE_CTL),
+ WIFI_CFEND = (BIT(7) | BIT(6) | BIT(5) | IEEE80211_FTYPE_CTL),
+ WIFI_CFEND_CFACK = (BIT(7) | BIT(6) | BIT(5) | BIT(4) | IEEE80211_FTYPE_CTL),
/* below is for data frame */
WIFI_DATA = (0 | WIFI_DATA_TYPE),
@@ -340,13 +338,6 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
return sa;
}
-static inline bool IsFrameTypeCtrl(unsigned char *pframe)
-{
- if (WIFI_CTRL_TYPE == GetFrameType(pframe))
- return true;
- else
- return false;
-}
/*-----------------------------------------------------------------------------
Below is for the security related definition
------------------------------------------------------------------------------*/
--
2.30.2
next prev parent reply other threads:[~2022-03-23 7:49 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-23 7:48 [PATCH 0/7] staging: r8188eu: use ieee80211 helpers for parsing Martin Kaiser
2022-03-23 7:48 ` [PATCH 1/7] staging: r8188eu: use ieee80211 define for version check Martin Kaiser
2022-03-23 14:28 ` David Laight
2022-03-27 18:19 ` Martin Kaiser
2022-03-23 23:59 ` kernel test robot
2022-03-23 7:48 ` [PATCH 2/7] staging: r8188eu: use ieee80211 helper to read the pwr bit Martin Kaiser
2022-03-23 7:48 ` Martin Kaiser [this message]
2022-03-23 7:48 ` [PATCH 4/7] staging: r8188eu: use standard mechanisms for data frames Martin Kaiser
2022-03-23 7:48 ` [PATCH 5/7] staging: r8188eu: use standard mechanisms for qos " Martin Kaiser
2022-03-23 7:48 ` [PATCH 6/7] staging: r8188eu: remove unused data frame subtypes Martin Kaiser
2022-03-23 7:48 ` [PATCH 7/7] staging: r8188eu: remove unused control " Martin Kaiser
2022-03-27 18:09 ` [PATCH v2 0/9] staging: r8188eu: use ieee80211 helpers for parsing Martin Kaiser
2022-03-27 18:09 ` [PATCH v2 1/9] staging: r8188eu: use ieee80211 define for version check Martin Kaiser
2022-03-27 18:09 ` [PATCH v2 2/9] staging: r8188eu: use ieee80211 helper to read the pwr bit Martin Kaiser
2022-03-27 18:09 ` [PATCH v2 3/9] staging: r8188eu: use standard mechanisms for control frames Martin Kaiser
2022-03-27 18:09 ` [PATCH v2 4/9] staging: r8188eu: use standard mechanisms for data frames Martin Kaiser
2022-03-27 18:09 ` [PATCH v2 5/9] staging: r8188eu: use standard mechanisms for qos " Martin Kaiser
2022-03-27 18:09 ` [PATCH v2 6/9] staging: r8188eu: remove unused data frame subtypes Martin Kaiser
2022-03-27 18:09 ` [PATCH v2 7/9] staging: r8188eu: remove unused control " Martin Kaiser
2022-03-27 18:09 ` [PATCH v2 8/9] staging: r8188eu: use ieee80211 macro for sequence number Martin Kaiser
2022-03-27 18:09 ` [PATCH v2 9/9] staging: r8188eu: use ieee80211 define for fragment number Martin Kaiser
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=20220323074859.177425-4-martin@kaiser.cx \
--to=martin@kaiser.cx \
--cc=Larry.Finger@lwfinger.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=phil@philpotter.co.uk \
--cc=straube.linux@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