Skip to contentSkip to conversation

staging: r8188eu: another round of cleanups

PATCH Superseded Martin Kaiser 3 participants 7 messages Nov 6, 2022 – Nov 7, 2022 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover staging: r8188eu: another round of cleanups

Here's some more cleanups, mostly related to bSurpriseRemoved and bDriverStopped.

Please apply them after the first patchset I sent earlier today.

Martin Kaiser (3):
staging: r8188eu: use a qos_hdr in validate_recv_data_frame
staging: r8188eu: drop another removal/stop check
staging: r8188eu: drop removal/stop check in
dump_mgntframe_and_wait_ack

 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 6 ------
 drivers/staging/r8188eu/core/rtw_recv.c     | 9 +++++----
 2 files changed, 5 insertions(+), 10 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/3 staging: r8188eu: use a qos_hdr in validate_recv_data_frame

Define a struct ieee80211_qos_hdr in the validate_recv_data_frame function. Use this struct to replace some numeric offsets and make the code easier to understand.

---
 drivers/staging/r8188eu/core/rtw_recv.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/staging/r8188eu/core/rtw_recv.c +5 -4
index cb0f35d7ab98..245b931c483d 100644
@@ -1032,7 +1032,6 @@ static int validate_recv_data_frame(struct adapter *adapter,
 				    struct recv_frame *precv_frame)
 {
 	struct sta_info *psta = NULL;
-	u8 *ptr = precv_frame->rx_data;
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
 	struct rx_pkt_attrib	*pattrib = &precv_frame->attrib;
 	struct security_priv	*psecuritypriv = &adapter->securitypriv;
@@ -1071,10 +1070,12 @@ static int validate_recv_data_frame(struct adapter *adapter,
 	pattrib->ack_policy = 0;
 	/* parsing QC field */
 	if (pattrib->qos) {
+		struct ieee80211_qos_hdr *qos_hdr = (struct ieee80211_qos_hdr *)hdr;
+
 		pattrib->priority = ieee80211_get_tid(hdr);
-		pattrib->ack_policy = GetAckpolicy((ptr + 24));
-		pattrib->amsdu = GetAMsdu((ptr + 24));
-		pattrib->hdrlen = 26;
+		pattrib->ack_policy = GetAckpolicy(&qos_hdr->qos_ctrl);
+		pattrib->amsdu = GetAMsdu(&qos_hdr->qos_ctrl);
+		pattrib->hdrlen += sizeof(*qos_hdr);
 
 		if (pattrib->priority != 0 && pattrib->priority != 3)
 			adapter->recvpriv.bIsAnyNonBEPkts = true;
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH 1/3] staging: r8188eu: use a qos_hdr in validate_recv_data_frame

Quoted 22 lines · Martin Kaiser

Define a struct ieee80211_qos_hdr in the validate_recv_data_frame function. Use this struct to replace some numeric offsets and make the code easier to understand.

---
 drivers/staging/r8188eu/core/rtw_recv.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/staging/r8188eu/core/rtw_recv.c +0 -1
index cb0f35d7ab98..245b931c483d 100644
@@ -1032,7 +1032,6 @@ static int validate_recv_data_frame(struct adapter *adapter,
 				    struct recv_frame *precv_frame)
 {
 	struct sta_info *psta = NULL;
-	u8 *ptr = precv_frame->rx_data;
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
 	struct rx_pkt_attrib	*pattrib = &precv_frame->attrib;
 	struct security_priv	*psecuritypriv = &adapter->securitypriv;

drivers/staging/r8188eu/core/rtw_recv.c static int validate_recv_data_frame(struct adapter *adapter, · line 1077

Quoted 9 lines
drivers/staging/r8188eu/core/rtw_recv.c +2 -3
@@ -1071,10 +1070,12 @@ static int validate_recv_data_frame(struct adapter *adapter,
 	pattrib->ack_policy = 0;
 	/* parsing QC field */
 	if (pattrib->qos) {
+		struct ieee80211_qos_hdr *qos_hdr = (struct ieee80211_qos_hdr *)hdr;
+
 		pattrib->priority = ieee80211_get_tid(hdr);
-		pattrib->ack_policy = GetAckpolicy((ptr + 24));
-		pattrib->amsdu = GetAMsdu((ptr + 24));
-		pattrib->hdrlen = 26;
                               ^^^

drivers/staging/r8188eu/core/rtw_recv.c static int validate_recv_data_frame(struct adapter *adapter, · line 1078

Quoted 3 lines
drivers/staging/r8188eu/core/rtw_recv.c +3 -0
+		pattrib->ack_policy = GetAckpolicy(&qos_hdr->qos_ctrl);
+		pattrib->amsdu = GetAMsdu(&qos_hdr->qos_ctrl);
+		pattrib->hdrlen += sizeof(*qos_hdr);
                               ^^^^

Why did this change from "=" to "+="?

regards,
dan carpenter

#3 lore raw

Re: [PATCH 1/3] staging: r8188eu: use a qos_hdr in validate_recv_data_frame

Thus wrote Dan Carpenter ([email protected]):

Quoted 34 lines · Martin Kaiser
Quoted 22 lines

Define a struct ieee80211_qos_hdr in the validate_recv_data_frame function. Use this struct to replace some numeric offsets and make the code easier to understand.

---
 drivers/staging/r8188eu/core/rtw_recv.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/staging/r8188eu/core/rtw_recv.c +0 -1
index cb0f35d7ab98..245b931c483d 100644
@@ -1032,7 +1032,6 @@ static int validate_recv_data_frame(struct adapter *adapter,
 				    struct recv_frame *precv_frame)
 {
 	struct sta_info *psta = NULL;
-	u8 *ptr = precv_frame->rx_data;
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
 	struct rx_pkt_attrib	*pattrib = &precv_frame->attrib;
 	struct security_priv	*psecuritypriv = &adapter->securitypriv;

drivers/staging/r8188eu/core/rtw_recv.c static int validate_recv_data_frame(struct adapter *adapter, · line 1077

Quoted 9 lines
drivers/staging/r8188eu/core/rtw_recv.c +2 -3
@@ -1071,10 +1070,12 @@ static int validate_recv_data_frame(struct adapter *adapter,
 	pattrib->ack_policy = 0;
 	/* parsing QC field */
 	if (pattrib->qos) {
+		struct ieee80211_qos_hdr *qos_hdr = (struct ieee80211_qos_hdr *)hdr;
+
 		pattrib->priority = ieee80211_get_tid(hdr);
-		pattrib->ack_policy = GetAckpolicy((ptr + 24));
-		pattrib->amsdu = GetAMsdu((ptr + 24));
-		pattrib->hdrlen = 26;
                               ^^^
Quoted 5 lines

drivers/staging/r8188eu/core/rtw_recv.c static int validate_recv_data_frame(struct adapter *adapter, · line 1078

Quoted 3 lines
drivers/staging/r8188eu/core/rtw_recv.c +3 -0
+		pattrib->ack_policy = GetAckpolicy(&qos_hdr->qos_ctrl);
+		pattrib->amsdu = GetAMsdu(&qos_hdr->qos_ctrl);
+		pattrib->hdrlen += sizeof(*qos_hdr);
                               ^^^^

Why did this change from "=" to "+="?

Thanks a lot for spotting this, Dan!

I tried a couple of versions, some of which used +=. For the one I submitted, this is wrong, of course.

All of pattrib is initialised to 0 in update_recvframe_attrib_88e and pattrib->hdrlen is not updated until the assignment above. That's why the += still works and testing didn't show the problem.

v2 is on the way...

Thanks again,

Martin

#4 lore raw

PATCH 2/3 staging: r8188eu: drop another removal/stop check

In reply to Martin Kaiser

There's no need to check bDriverStopped and bSurpriseRemoved in issue_probereq_ex.

The code path looks like

issue_probereq_ex
_issue_probereq
dump_mgntframe
or
dump_mgntframe_and_wait_ack

All paths from dump_mgntframe check the two variables. dump_mgntframe_and_wait_ack contains a check as well.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +0 -3
index 17803aca83c8..bfd6afd7266e 100644
@@ -4496,9 +4496,6 @@ int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid,
 
 		i++;
 
-		if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
-			break;
-
 		if (i < try_cnt && wait_ms > 0 && ret == _FAIL)
 			msleep(wait_ms);
 
Signature · 1 line
2.30.2
#5 lore raw

PATCH 3/3 staging: r8188eu: drop removal/stop check in dump_mgntframe_and_wait_ack

In reply to Martin Kaiser

We can remove the checks for bDriverStopped and bSurpriseRemoved in dump_mgntframe_and_wait_ack.

The code path from this function looks like

dump_mgntframe_and_wait_ack
rtl8188eu_mgnt_xmit
rtw_dump_xframe
loop over all fragments

rtw_write_port is called for each fragment. bSurpriseRemoved and bDriverStopped are checked in rtw_write_port.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +0 -3
index bfd6afd7266e..be33489d3dfd 100644
@@ -3988,9 +3988,6 @@ s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmg
 	u32 timeout_ms = 500;/*   500ms */
 	struct xmit_priv	*pxmitpriv = &padapter->xmitpriv;
 
-	if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
-		return -1;
-
 	mutex_lock(&pxmitpriv->ack_tx_mutex);
 	pxmitpriv->ack_tx = true;
 
Signature · 1 line
2.30.2
Tested-by on the v1 series
#6 lore raw
In reply to Martin Kaiser
Quoted 11 lines · Martin Kaiser

Here's some more cleanups, mostly related to bSurpriseRemoved and bDriverStopped.

Please apply them after the first patchset I sent earlier today.

Martin Kaiser (3):
staging: r8188eu: use a qos_hdr in validate_recv_data_frame
staging: r8188eu: drop another removal/stop check
staging: r8188eu: drop removal/stop check in
dump_mgntframe_and_wait_ack

Quoted 4 lines
  drivers/staging/r8188eu/core/rtw_mlme_ext.c | 6 ------
  drivers/staging/r8188eu/core/rtw_recv.c     | 9 +++++----
  2 files changed, 5 insertions(+), 10 deletions(-)