All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] staging: r8188eu: another round of cleanups
@ 2022-11-06 17:04 Martin Kaiser
  2022-11-06 17:04 ` [PATCH 1/3] staging: r8188eu: use a qos_hdr in validate_recv_data_frame Martin Kaiser
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Martin Kaiser @ 2022-11-06 17:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, 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

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

-- 
2.30.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] staging: r8188eu: use a qos_hdr in validate_recv_data_frame
  2022-11-06 17:04 [PATCH 0/3] staging: r8188eu: another round of cleanups Martin Kaiser
@ 2022-11-06 17:04 ` Martin Kaiser
  2022-11-07 12:54   ` Dan Carpenter
  2022-11-06 17:04 ` [PATCH 2/3] staging: r8188eu: drop another removal/stop check Martin Kaiser
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Martin Kaiser @ 2022-11-06 17:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, 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.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 drivers/staging/r8188eu/core/rtw_recv.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
index cb0f35d7ab98..245b931c483d 100644
--- a/drivers/staging/r8188eu/core/rtw_recv.c
+++ b/drivers/staging/r8188eu/core/rtw_recv.c
@@ -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;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] staging: r8188eu: drop another removal/stop check
  2022-11-06 17:04 [PATCH 0/3] staging: r8188eu: another round of cleanups Martin Kaiser
  2022-11-06 17:04 ` [PATCH 1/3] staging: r8188eu: use a qos_hdr in validate_recv_data_frame Martin Kaiser
@ 2022-11-06 17:04 ` Martin Kaiser
  2022-11-06 17:04 ` [PATCH 3/3] staging: r8188eu: drop removal/stop check in dump_mgntframe_and_wait_ack Martin Kaiser
  2022-11-07  6:23 ` [PATCH 0/3] staging: r8188eu: another round of cleanups Philipp Hortmann
  3 siblings, 0 replies; 7+ messages in thread
From: Martin Kaiser @ 2022-11-06 17:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, 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.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 17803aca83c8..bfd6afd7266e 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -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);
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] staging: r8188eu: drop removal/stop check in dump_mgntframe_and_wait_ack
  2022-11-06 17:04 [PATCH 0/3] staging: r8188eu: another round of cleanups Martin Kaiser
  2022-11-06 17:04 ` [PATCH 1/3] staging: r8188eu: use a qos_hdr in validate_recv_data_frame Martin Kaiser
  2022-11-06 17:04 ` [PATCH 2/3] staging: r8188eu: drop another removal/stop check Martin Kaiser
@ 2022-11-06 17:04 ` Martin Kaiser
  2022-11-07  6:23 ` [PATCH 0/3] staging: r8188eu: another round of cleanups Philipp Hortmann
  3 siblings, 0 replies; 7+ messages in thread
From: Martin Kaiser @ 2022-11-06 17:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, 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.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index bfd6afd7266e..be33489d3dfd 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -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;
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] staging: r8188eu: another round of cleanups
  2022-11-06 17:04 [PATCH 0/3] staging: r8188eu: another round of cleanups Martin Kaiser
                   ` (2 preceding siblings ...)
  2022-11-06 17:04 ` [PATCH 3/3] staging: r8188eu: drop removal/stop check in dump_mgntframe_and_wait_ack Martin Kaiser
@ 2022-11-07  6:23 ` Philipp Hortmann
  3 siblings, 0 replies; 7+ messages in thread
From: Philipp Hortmann @ 2022-11-07  6:23 UTC (permalink / raw)
  To: Martin Kaiser, Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel

On 11/6/22 18:04, Martin Kaiser wrote:
> 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(-)
> 

Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] staging: r8188eu: use a qos_hdr in validate_recv_data_frame
  2022-11-06 17:04 ` [PATCH 1/3] staging: r8188eu: use a qos_hdr in validate_recv_data_frame Martin Kaiser
@ 2022-11-07 12:54   ` Dan Carpenter
  2022-11-07 20:27     ` Martin Kaiser
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2022-11-07 12:54 UTC (permalink / raw)
  To: Martin Kaiser
  Cc: Greg Kroah-Hartman, Larry Finger, Phillip Potter, Michael Straube,
	Pavel Skripkin, linux-staging, linux-kernel

On Sun, Nov 06, 2022 at 06:04:53PM +0100, Martin Kaiser wrote:
> 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.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
>  drivers/staging/r8188eu/core/rtw_recv.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
> index cb0f35d7ab98..245b931c483d 100644
> --- a/drivers/staging/r8188eu/core/rtw_recv.c
> +++ b/drivers/staging/r8188eu/core/rtw_recv.c
> @@ -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);
                               ^^^^
Why did this change from "=" to "+="?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] staging: r8188eu: use a qos_hdr in validate_recv_data_frame
  2022-11-07 12:54   ` Dan Carpenter
@ 2022-11-07 20:27     ` Martin Kaiser
  0 siblings, 0 replies; 7+ messages in thread
From: Martin Kaiser @ 2022-11-07 20:27 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Greg Kroah-Hartman, Larry Finger, Phillip Potter, Michael Straube,
	Pavel Skripkin, linux-staging, linux-kernel

Thus wrote Dan Carpenter (error27@gmail.com):

> On Sun, Nov 06, 2022 at 06:04:53PM +0100, Martin Kaiser wrote:
> > 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.

> > Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> > ---
> >  drivers/staging/r8188eu/core/rtw_recv.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)

> > diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
> > index cb0f35d7ab98..245b931c483d 100644
> > --- a/drivers/staging/r8188eu/core/rtw_recv.c
> > +++ b/drivers/staging/r8188eu/core/rtw_recv.c
> > @@ -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);
>                                ^^^^
> 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-11-07 20:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-06 17:04 [PATCH 0/3] staging: r8188eu: another round of cleanups Martin Kaiser
2022-11-06 17:04 ` [PATCH 1/3] staging: r8188eu: use a qos_hdr in validate_recv_data_frame Martin Kaiser
2022-11-07 12:54   ` Dan Carpenter
2022-11-07 20:27     ` Martin Kaiser
2022-11-06 17:04 ` [PATCH 2/3] staging: r8188eu: drop another removal/stop check Martin Kaiser
2022-11-06 17:04 ` [PATCH 3/3] staging: r8188eu: drop removal/stop check in dump_mgntframe_and_wait_ack Martin Kaiser
2022-11-07  6:23 ` [PATCH 0/3] staging: r8188eu: another round of cleanups Philipp Hortmann

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.