* [PATCH 1/5] staging: r8188eu: make validate_recv_ctrl_frame return void
2022-04-03 16:45 [PATCH 0/5] staging: r8188eu: clean up validate_recv_ctrl_frame Martin Kaiser
@ 2022-04-03 16:45 ` Martin Kaiser
2022-04-03 16:45 ` [PATCH 2/5] staging: r8188eu: use ieee80211 helper to check for pspoll Martin Kaiser
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Martin Kaiser @ 2022-04-03 16:45 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Larry Finger, Phillip Potter, Michael Straube, linux-staging,
linux-kernel, Martin Kaiser
Make validate_recv_ctrl_frame return void.
At the moment, the function always returns _FAIL, the caller does not
check the return value.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
drivers/staging/r8188eu/core/rtw_recv.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
index 1a79c3f46bbf..931bd81b0886 100644
--- a/drivers/staging/r8188eu/core/rtw_recv.c
+++ b/drivers/staging/r8188eu/core/rtw_recv.c
@@ -795,8 +795,8 @@ static int sta2ap_data_frame(struct adapter *adapter,
return ret;
}
-static int validate_recv_ctrl_frame(struct adapter *padapter,
- struct recv_frame *precv_frame)
+static void validate_recv_ctrl_frame(struct adapter *padapter,
+ struct recv_frame *precv_frame)
{
struct rx_pkt_attrib *pattrib = &precv_frame->attrib;
struct sta_priv *pstapriv = &padapter->stapriv;
@@ -805,11 +805,11 @@ static int validate_recv_ctrl_frame(struct adapter *padapter,
/* uint len = precv_frame->len; */
if (!ieee80211_is_ctl(fc))
- return _FAIL;
+ return;
/* receive the frames that ra(a1) is my address */
if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN))
- return _FAIL;
+ return;
/* only handle ps-poll */
if (GetFrameSubType(pframe) == WIFI_PSPOLL) {
@@ -821,7 +821,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter,
psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
if (!psta || psta->aid != aid)
- return _FAIL;
+ return;
/* for rx pkt statistics */
psta->sta_stats.rx_ctrl_pkts++;
@@ -847,7 +847,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter,
}
if (wmmps_ac)
- return _FAIL;
+ return;
if (psta->state & WIFI_STA_ALIVE_CHK_STATE) {
psta->expire_to = pstapriv->expire_to;
@@ -905,8 +905,6 @@ static int validate_recv_ctrl_frame(struct adapter *padapter,
spin_unlock_bh(&pxmitpriv->lock);
}
}
-
- return _FAIL;
}
struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, struct recv_frame *precv_frame);
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 2/5] staging: r8188eu: use ieee80211 helper to check for pspoll
2022-04-03 16:45 [PATCH 0/5] staging: r8188eu: clean up validate_recv_ctrl_frame Martin Kaiser
2022-04-03 16:45 ` [PATCH 1/5] staging: r8188eu: make validate_recv_ctrl_frame return void Martin Kaiser
@ 2022-04-03 16:45 ` Martin Kaiser
2022-04-03 16:45 ` [PATCH 3/5] staging: r8188eu: exit straight away if we have no pspoll frame Martin Kaiser
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Martin Kaiser @ 2022-04-03 16:45 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Larry Finger, Phillip Potter, Michael Straube, linux-staging,
linux-kernel, Martin Kaiser
Use the ieee80211 helper to check if our incoming ctrl frame is a
pspoll frame.
We can drop the initial ctrl frame check as ieee80211_is_pspoll
checks for a control frame with subtype pspoll.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
drivers/staging/r8188eu/core/rtw_recv.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
index 931bd81b0886..74fe2d7011fc 100644
--- a/drivers/staging/r8188eu/core/rtw_recv.c
+++ b/drivers/staging/r8188eu/core/rtw_recv.c
@@ -804,15 +804,12 @@ static void validate_recv_ctrl_frame(struct adapter *padapter,
__le16 fc = *(__le16 *)pframe;
/* uint len = precv_frame->len; */
- if (!ieee80211_is_ctl(fc))
- return;
-
/* receive the frames that ra(a1) is my address */
if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN))
return;
/* only handle ps-poll */
- if (GetFrameSubType(pframe) == WIFI_PSPOLL) {
+ if (ieee80211_is_pspoll(fc)) {
u16 aid;
u8 wmmps_ac = 0;
struct sta_info *psta = NULL;
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 3/5] staging: r8188eu: exit straight away if we have no pspoll frame
2022-04-03 16:45 [PATCH 0/5] staging: r8188eu: clean up validate_recv_ctrl_frame Martin Kaiser
2022-04-03 16:45 ` [PATCH 1/5] staging: r8188eu: make validate_recv_ctrl_frame return void Martin Kaiser
2022-04-03 16:45 ` [PATCH 2/5] staging: r8188eu: use ieee80211 helper to check for pspoll Martin Kaiser
@ 2022-04-03 16:45 ` Martin Kaiser
2022-04-03 16:45 ` [PATCH 4/5] staging: r8188eu: use ieee80211 structs for addresses Martin Kaiser
2022-04-03 16:45 ` [PATCH 5/5] staging: r8188eu: use ieee80211 struct for aid Martin Kaiser
4 siblings, 0 replies; 6+ messages in thread
From: Martin Kaiser @ 2022-04-03 16:45 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Larry Finger, Phillip Potter, Michael Straube, linux-staging,
linux-kernel, Martin Kaiser
validate_recv_ctrl_frame wraps nearly all of its code into a large
if (pspoll) { ... } clause.
Revert this condition and exit if the incoming frame is not a pspoll
frame.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
drivers/staging/r8188eu/core/rtw_recv.c | 146 ++++++++++++------------
1 file changed, 73 insertions(+), 73 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
index 74fe2d7011fc..39834771519f 100644
--- a/drivers/staging/r8188eu/core/rtw_recv.c
+++ b/drivers/staging/r8188eu/core/rtw_recv.c
@@ -803,104 +803,104 @@ static void validate_recv_ctrl_frame(struct adapter *padapter,
u8 *pframe = precv_frame->rx_data;
__le16 fc = *(__le16 *)pframe;
/* uint len = precv_frame->len; */
+ u16 aid;
+ u8 wmmps_ac;
+ struct sta_info *psta;
/* receive the frames that ra(a1) is my address */
if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN))
return;
/* only handle ps-poll */
- if (ieee80211_is_pspoll(fc)) {
- u16 aid;
- u8 wmmps_ac = 0;
- struct sta_info *psta = NULL;
+ if (!ieee80211_is_pspoll(fc))
+ return;
- aid = GetAid(pframe);
- psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
+ aid = GetAid(pframe);
+ psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
- if (!psta || psta->aid != aid)
- return;
+ if (!psta || psta->aid != aid)
+ return;
- /* for rx pkt statistics */
- psta->sta_stats.rx_ctrl_pkts++;
+ /* for rx pkt statistics */
+ psta->sta_stats.rx_ctrl_pkts++;
- switch (pattrib->priority) {
- case 1:
- case 2:
- wmmps_ac = psta->uapsd_bk & BIT(0);
- break;
- case 4:
- case 5:
- wmmps_ac = psta->uapsd_vi & BIT(0);
- break;
- case 6:
- case 7:
- wmmps_ac = psta->uapsd_vo & BIT(0);
- break;
- case 0:
- case 3:
- default:
- wmmps_ac = psta->uapsd_be & BIT(0);
- break;
- }
+ switch (pattrib->priority) {
+ case 1:
+ case 2:
+ wmmps_ac = psta->uapsd_bk & BIT(0);
+ break;
+ case 4:
+ case 5:
+ wmmps_ac = psta->uapsd_vi & BIT(0);
+ break;
+ case 6:
+ case 7:
+ wmmps_ac = psta->uapsd_vo & BIT(0);
+ break;
+ case 0:
+ case 3:
+ default:
+ wmmps_ac = psta->uapsd_be & BIT(0);
+ break;
+ }
- if (wmmps_ac)
- return;
+ if (wmmps_ac)
+ return;
- if (psta->state & WIFI_STA_ALIVE_CHK_STATE) {
- psta->expire_to = pstapriv->expire_to;
- psta->state ^= WIFI_STA_ALIVE_CHK_STATE;
- }
+ if (psta->state & WIFI_STA_ALIVE_CHK_STATE) {
+ psta->expire_to = pstapriv->expire_to;
+ psta->state ^= WIFI_STA_ALIVE_CHK_STATE;
+ }
- if ((psta->state & WIFI_SLEEP_STATE) && (pstapriv->sta_dz_bitmap & BIT(psta->aid))) {
- struct list_head *xmitframe_plist, *xmitframe_phead;
- struct xmit_frame *pxmitframe = NULL;
- struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+ if ((psta->state & WIFI_SLEEP_STATE) && (pstapriv->sta_dz_bitmap & BIT(psta->aid))) {
+ struct list_head *xmitframe_plist, *xmitframe_phead;
+ struct xmit_frame *pxmitframe = NULL;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
- spin_lock_bh(&pxmitpriv->lock);
+ spin_lock_bh(&pxmitpriv->lock);
- xmitframe_phead = get_list_head(&psta->sleep_q);
- xmitframe_plist = xmitframe_phead->next;
+ xmitframe_phead = get_list_head(&psta->sleep_q);
+ xmitframe_plist = xmitframe_phead->next;
- if (xmitframe_phead != xmitframe_plist) {
- pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
+ if (xmitframe_phead != xmitframe_plist) {
+ pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
- xmitframe_plist = xmitframe_plist->next;
+ xmitframe_plist = xmitframe_plist->next;
- list_del_init(&pxmitframe->list);
+ list_del_init(&pxmitframe->list);
- psta->sleepq_len--;
+ psta->sleepq_len--;
- if (psta->sleepq_len > 0)
- pxmitframe->attrib.mdata = 1;
- else
- pxmitframe->attrib.mdata = 0;
+ if (psta->sleepq_len > 0)
+ pxmitframe->attrib.mdata = 1;
+ else
+ pxmitframe->attrib.mdata = 0;
- pxmitframe->attrib.triggered = 1;
+ pxmitframe->attrib.triggered = 1;
- if (psta->sleepq_len == 0) {
- pstapriv->tim_bitmap &= ~BIT(psta->aid);
+ if (psta->sleepq_len == 0) {
+ pstapriv->tim_bitmap &= ~BIT(psta->aid);
- /* upate BCN for TIM IE */
- /* update_BCNTIM(padapter); */
- update_beacon(padapter, _TIM_IE_, NULL, false);
- }
- } else {
- if (pstapriv->tim_bitmap & BIT(psta->aid)) {
- if (psta->sleepq_len == 0)
- /* issue nulldata with More data bit = 0 to indicate we have no buffered packets */
- issue_nulldata(padapter, psta->hwaddr, 0, 0, 0);
- else
- psta->sleepq_len = 0;
-
- pstapriv->tim_bitmap &= ~BIT(psta->aid);
-
- /* upate BCN for TIM IE */
- /* update_BCNTIM(padapter); */
- update_beacon(padapter, _TIM_IE_, NULL, false);
- }
+ /* upate BCN for TIM IE */
+ /* update_BCNTIM(padapter); */
+ update_beacon(padapter, _TIM_IE_, NULL, false);
+ }
+ } else {
+ if (pstapriv->tim_bitmap & BIT(psta->aid)) {
+ if (psta->sleepq_len == 0)
+ /* issue nulldata with More data bit = 0 to indicate we have no buffered packets */
+ issue_nulldata(padapter, psta->hwaddr, 0, 0, 0);
+ else
+ psta->sleepq_len = 0;
+
+ pstapriv->tim_bitmap &= ~BIT(psta->aid);
+
+ /* upate BCN for TIM IE */
+ /* update_BCNTIM(padapter); */
+ update_beacon(padapter, _TIM_IE_, NULL, false);
}
- spin_unlock_bh(&pxmitpriv->lock);
}
+ spin_unlock_bh(&pxmitpriv->lock);
}
}
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 4/5] staging: r8188eu: use ieee80211 structs for addresses
2022-04-03 16:45 [PATCH 0/5] staging: r8188eu: clean up validate_recv_ctrl_frame Martin Kaiser
` (2 preceding siblings ...)
2022-04-03 16:45 ` [PATCH 3/5] staging: r8188eu: exit straight away if we have no pspoll frame Martin Kaiser
@ 2022-04-03 16:45 ` Martin Kaiser
2022-04-03 16:45 ` [PATCH 5/5] staging: r8188eu: use ieee80211 struct for aid Martin Kaiser
4 siblings, 0 replies; 6+ messages in thread
From: Martin Kaiser @ 2022-04-03 16:45 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Larry Finger, Phillip Potter, Michael Straube, linux-staging,
linux-kernel, Martin Kaiser
Map the incoming frame data to a struct ieee80211_hdr and extract
the addresses.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
drivers/staging/r8188eu/core/rtw_recv.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
index 39834771519f..a8ab1be33cfb 100644
--- a/drivers/staging/r8188eu/core/rtw_recv.c
+++ b/drivers/staging/r8188eu/core/rtw_recv.c
@@ -801,22 +801,21 @@ static void 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; */
u16 aid;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
u8 wmmps_ac;
struct sta_info *psta;
/* receive the frames that ra(a1) is my address */
- if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN))
+ if (memcmp(hdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN))
return;
/* only handle ps-poll */
- if (!ieee80211_is_pspoll(fc))
+ if (!ieee80211_is_pspoll(hdr->frame_control))
return;
aid = GetAid(pframe);
- psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
+ psta = rtw_get_stainfo(pstapriv, hdr->addr2);
if (!psta || psta->aid != aid)
return;
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 5/5] staging: r8188eu: use ieee80211 struct for aid
2022-04-03 16:45 [PATCH 0/5] staging: r8188eu: clean up validate_recv_ctrl_frame Martin Kaiser
` (3 preceding siblings ...)
2022-04-03 16:45 ` [PATCH 4/5] staging: r8188eu: use ieee80211 structs for addresses Martin Kaiser
@ 2022-04-03 16:45 ` Martin Kaiser
4 siblings, 0 replies; 6+ messages in thread
From: Martin Kaiser @ 2022-04-03 16:45 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Larry Finger, Phillip Potter, Michael Straube, linux-staging,
linux-kernel, Martin Kaiser
Remove the GetAid macro and map the frame data to a struct
ieee80211_pspoll instead. We can then read the aid component.
psta->aid is in host endianness and has a 0x3FFF mask applied. We have to
convert our read value as well and apply the mask before we compare it to
psta->aid.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
drivers/staging/r8188eu/core/rtw_recv.c | 7 ++-----
drivers/staging/r8188eu/include/wifi.h | 2 --
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
index a8ab1be33cfb..9f0bb29c9c56 100644
--- a/drivers/staging/r8188eu/core/rtw_recv.c
+++ b/drivers/staging/r8188eu/core/rtw_recv.c
@@ -800,9 +800,8 @@ static void 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;
- u16 aid;
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
+ struct ieee80211_pspoll *pspoll = (struct ieee80211_pspoll *)hdr;
u8 wmmps_ac;
struct sta_info *psta;
@@ -814,10 +813,8 @@ static void validate_recv_ctrl_frame(struct adapter *padapter,
if (!ieee80211_is_pspoll(hdr->frame_control))
return;
- aid = GetAid(pframe);
psta = rtw_get_stainfo(pstapriv, hdr->addr2);
-
- if (!psta || psta->aid != aid)
+ if (!psta || psta->aid != (le16_to_cpu(pspoll->aid) & 0x3FFF))
return;
/* for rx pkt statistics */
diff --git a/drivers/staging/r8188eu/include/wifi.h b/drivers/staging/r8188eu/include/wifi.h
index e10cf17d6aa0..eb3cb1fb285f 100644
--- a/drivers/staging/r8188eu/include/wifi.h
+++ b/drivers/staging/r8188eu/include/wifi.h
@@ -228,8 +228,6 @@ enum WIFI_REG_DOMAIN {
#define SetAMsdu(pbuf, amsdu) \
*(__le16 *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7)
-#define GetAid(pbuf) (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 2)) & 0x3fff)
-
#define GetTid(pbuf) (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + \
(((GetToDs(pbuf)<<1) | GetFrDs(pbuf)) == 3 ? \
30 : 24))) & 0x000f)
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread