All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA
@ 2022-05-21 15:38 Martin Kaiser
  2022-05-21 15:38 ` [PATCH 01/12] staging: r8188eu: remove unnecessary category check Martin Kaiser
                   ` (12 more replies)
  0 siblings, 13 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-21 15:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Start cleaning up the issue_action_BA function. Use helpers from
ieee80211.h to populate some of the fields of the outgoing frame.

(I'll send more patches for the remaining fields and messages.)

Martin Kaiser (12):
  staging: r8188eu: remove unnecessary category check
  staging: r8188eu: use defines for the block action codes
  staging: r8188eu: use ieee80211_mgmt in issue_action_BA
  staging: r8188eu: use mgmt to set the addresses
  staging: r8188eu: use mgmt to set the sequence number
  staging: r8188eu: use mgmt to set the category
  staging: r8188eu: use mgmt to set the action codes
  staging: r8188eu: use mgmt to set the dialog token
  staging: r8188eu: use mgmt to set the timeout
  staging: r8188eu: use ieee80211 to set addba capabilities
  staging: r8188eu: use mgmt to set start sequence number
  staging: r8188eu: calculate the addba request length

 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 124 ++++++++++----------
 1 file changed, 63 insertions(+), 61 deletions(-)

-- 
2.30.2


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

* [PATCH 01/12] staging: r8188eu: remove unnecessary category check
  2022-05-21 15:38 [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
@ 2022-05-21 15:38 ` Martin Kaiser
  2022-05-21 15:38 ` [PATCH 02/12] staging: r8188eu: use defines for the block action codes Martin Kaiser
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-21 15:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Remove the unnecessary category check in issue_action_BA. category is
initialised to 3 (WLAN_CATEGORY_BACK) and never updated.

The rtw_set_fixed_ie call gets a pointer to category but it doesn't update
the value.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index faf23fc950c5..f47cf3e7316c 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5415,60 +5415,58 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	pframe = rtw_set_fixed_ie(pframe, 1, &(category), &pattrib->pktlen);
 	pframe = rtw_set_fixed_ie(pframe, 1, &(action), &pattrib->pktlen);
 
-	if (category == 3) {
-		switch (action) {
-		case 0: /* ADDBA req */
-			do {
-				pmlmeinfo->dialogToken++;
-			} while (pmlmeinfo->dialogToken == 0);
-			pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->dialogToken, &pattrib->pktlen);
+	switch (action) {
+	case 0: /* ADDBA req */
+		do {
+			pmlmeinfo->dialogToken++;
+		} while (pmlmeinfo->dialogToken == 0);
+		pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->dialogToken, &pattrib->pktlen);
 
-			BA_para_set = (0x1002 | ((status & 0xf) << 2)); /* immediate ack & 64 buffer size */
-			le_tmp = cpu_to_le16(BA_para_set);
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		BA_para_set = (0x1002 | ((status & 0xf) << 2)); /* immediate ack & 64 buffer size */
+		le_tmp = cpu_to_le16(BA_para_set);
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
 
-			BA_timeout_value = 5000;/*  5ms */
-			le_tmp = cpu_to_le16(BA_timeout_value);
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		BA_timeout_value = 5000;/*  5ms */
+		le_tmp = cpu_to_le16(BA_timeout_value);
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
 
-			psta = rtw_get_stainfo(pstapriv, raddr);
-			if (psta) {
-				start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07] & 0xfff) + 1;
+		psta = rtw_get_stainfo(pstapriv, raddr);
+		if (psta) {
+			start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07] & 0xfff) + 1;
 
-				psta->BA_starting_seqctrl[status & 0x07] = start_seq;
+			psta->BA_starting_seqctrl[status & 0x07] = start_seq;
 
-				BA_starting_seqctrl = start_seq << 4;
-			}
-			le_tmp = cpu_to_le16(BA_starting_seqctrl);
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
-			break;
-		case 1: /* ADDBA rsp */
-			pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->ADDBA_req.dialog_token, &pattrib->pktlen);
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&status, &pattrib->pktlen);
-			BA_para_set = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f;
-			BA_para_set |= 0x1000; /* 64 buffer size */
-
-			if (pregpriv->ampdu_amsdu == 0)/* disabled */
-				BA_para_set = BA_para_set & ~BIT(0);
-			else if (pregpriv->ampdu_amsdu == 1)/* enabled */
-				BA_para_set = BA_para_set | BIT(0);
-			le_tmp = cpu_to_le16(BA_para_set);
-
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&pmlmeinfo->ADDBA_req.BA_timeout_value, &pattrib->pktlen);
-			break;
-		case 2:/* DELBA */
-			BA_para_set = (status & 0x1F) << 3;
-			le_tmp = cpu_to_le16(BA_para_set);
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
-
-			reason_code = 37;/* Requested from peer STA as it does not want to use the mechanism */
-			le_tmp = cpu_to_le16(reason_code);
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
-			break;
-		default:
-			break;
+			BA_starting_seqctrl = start_seq << 4;
 		}
+		le_tmp = cpu_to_le16(BA_starting_seqctrl);
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		break;
+	case 1: /* ADDBA rsp */
+		pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->ADDBA_req.dialog_token, &pattrib->pktlen);
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&status, &pattrib->pktlen);
+		BA_para_set = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f;
+		BA_para_set |= 0x1000; /* 64 buffer size */
+
+		if (pregpriv->ampdu_amsdu == 0)/* disabled */
+			BA_para_set = BA_para_set & ~BIT(0);
+		else if (pregpriv->ampdu_amsdu == 1)/* enabled */
+			BA_para_set = BA_para_set | BIT(0);
+		le_tmp = cpu_to_le16(BA_para_set);
+
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&pmlmeinfo->ADDBA_req.BA_timeout_value, &pattrib->pktlen);
+		break;
+	case 2:/* DELBA */
+		BA_para_set = (status & 0x1F) << 3;
+		le_tmp = cpu_to_le16(BA_para_set);
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+
+		reason_code = 37;/* Requested from peer STA as it does not want to use the mechanism */
+		le_tmp = cpu_to_le16(reason_code);
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		break;
+	default:
+		break;
 	}
 
 	pattrib->last_txcmdsz = pattrib->pktlen;
-- 
2.30.2


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

* [PATCH 02/12] staging: r8188eu: use defines for the block action codes
  2022-05-21 15:38 [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
  2022-05-21 15:38 ` [PATCH 01/12] staging: r8188eu: remove unnecessary category check Martin Kaiser
@ 2022-05-21 15:38 ` Martin Kaiser
  2022-05-21 15:38 ` [PATCH 03/12] staging: r8188eu: use ieee80211_mgmt in issue_action_BA Martin Kaiser
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-21 15:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Replace the numeric values for the block action codes in issue_action_BA
with the defines from ieee80211.h.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index f47cf3e7316c..0265784368e2 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5416,7 +5416,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	pframe = rtw_set_fixed_ie(pframe, 1, &(action), &pattrib->pktlen);
 
 	switch (action) {
-	case 0: /* ADDBA req */
+	case WLAN_ACTION_ADDBA_REQ:
 		do {
 			pmlmeinfo->dialogToken++;
 		} while (pmlmeinfo->dialogToken == 0);
@@ -5441,7 +5441,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		le_tmp = cpu_to_le16(BA_starting_seqctrl);
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
 		break;
-	case 1: /* ADDBA rsp */
+	case WLAN_ACTION_ADDBA_RESP:
 		pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->ADDBA_req.dialog_token, &pattrib->pktlen);
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&status, &pattrib->pktlen);
 		BA_para_set = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f;
@@ -5456,7 +5456,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&pmlmeinfo->ADDBA_req.BA_timeout_value, &pattrib->pktlen);
 		break;
-	case 2:/* DELBA */
+	case WLAN_ACTION_DELBA:
 		BA_para_set = (status & 0x1F) << 3;
 		le_tmp = cpu_to_le16(BA_para_set);
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
-- 
2.30.2


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

* [PATCH 03/12] staging: r8188eu: use ieee80211_mgmt in issue_action_BA
  2022-05-21 15:38 [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
  2022-05-21 15:38 ` [PATCH 01/12] staging: r8188eu: remove unnecessary category check Martin Kaiser
  2022-05-21 15:38 ` [PATCH 02/12] staging: r8188eu: use defines for the block action codes Martin Kaiser
@ 2022-05-21 15:38 ` Martin Kaiser
  2022-05-21 15:38 ` [PATCH 04/12] staging: r8188eu: use mgmt to set the addresses Martin Kaiser
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-21 15:38 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_mgmt variable in issue_action_BA, this will make
it much simpler to populate the fields of the outoing frame.

Use the new mgmt variable to set the type and subtype of the frame.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 0265784368e2..eec716fea41c 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5376,13 +5376,13 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	struct pkt_attrib *pattrib;
 	u8 *pframe;
 	struct ieee80211_hdr *pwlanhdr;
-	__le16 *fctrl;
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
 	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 	struct sta_info *psta;
 	struct sta_priv *pstapriv = &padapter->stapriv;
 	struct registry_priv *pregpriv = &padapter->registrypriv;
+	struct ieee80211_mgmt *mgmt;
 
 	pmgntframe = alloc_mgtxmitframe(pxmitpriv);
 	if (!pmgntframe)
@@ -5396,9 +5396,9 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 
 	pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
 	pwlanhdr = (struct ieee80211_hdr *)pframe;
+	mgmt = (struct ieee80211_mgmt *)pframe;
 
-	fctrl = &pwlanhdr->frame_control;
-	*(fctrl) = 0;
+	mgmt->frame_control = cpu_to_le16(IEEE80211_STYPE_ACTION | IEEE80211_FTYPE_MGMT);
 
 	/* memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); */
 	memcpy(pwlanhdr->addr1, raddr, ETH_ALEN);
@@ -5407,7 +5407,6 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 
 	SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
 	pmlmeext->mgnt_seq++;
-	SetFrameSubType(pframe, WIFI_ACTION);
 
 	pframe += sizeof(struct ieee80211_hdr_3addr);
 	pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-- 
2.30.2


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

* [PATCH 04/12] staging: r8188eu: use mgmt to set the addresses
  2022-05-21 15:38 [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                   ` (2 preceding siblings ...)
  2022-05-21 15:38 ` [PATCH 03/12] staging: r8188eu: use ieee80211_mgmt in issue_action_BA Martin Kaiser
@ 2022-05-21 15:38 ` Martin Kaiser
  2022-05-21 15:38 ` [PATCH 05/12] staging: r8188eu: use mgmt to set the sequence number Martin Kaiser
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-21 15:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure in issue_action_BA to set the three addresses of
the outgoing frame.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index eec716fea41c..f08521cb1ff7 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5400,10 +5400,9 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 
 	mgmt->frame_control = cpu_to_le16(IEEE80211_STYPE_ACTION | IEEE80211_FTYPE_MGMT);
 
-	/* memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); */
-	memcpy(pwlanhdr->addr1, raddr, ETH_ALEN);
-	memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-	memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
+	memcpy(mgmt->da, raddr, ETH_ALEN);
+	memcpy(mgmt->sa, myid(&padapter->eeprompriv), ETH_ALEN);
+	memcpy(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
 
 	SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
 	pmlmeext->mgnt_seq++;
-- 
2.30.2


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

* [PATCH 05/12] staging: r8188eu: use mgmt to set the sequence number
  2022-05-21 15:38 [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                   ` (3 preceding siblings ...)
  2022-05-21 15:38 ` [PATCH 04/12] staging: r8188eu: use mgmt to set the addresses Martin Kaiser
@ 2022-05-21 15:38 ` Martin Kaiser
  2022-05-21 20:44   ` kernel test robot
  2022-05-21 15:38 ` [PATCH 06/12] staging: r8188eu: use mgmt to set the category Martin Kaiser
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Martin Kaiser @ 2022-05-21 15:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure in issue_action_BA to set the sequence number of
the outgoing frame.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index f08521cb1ff7..9a26b67d49bd 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5404,7 +5404,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	memcpy(mgmt->sa, myid(&padapter->eeprompriv), ETH_ALEN);
 	memcpy(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
 
-	SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
+	mgmt->seq_ctrl = cpu_to_le16(pmlmeext->mgnt_seq);
 	pmlmeext->mgnt_seq++;
 
 	pframe += sizeof(struct ieee80211_hdr_3addr);
-- 
2.30.2


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

* [PATCH 06/12] staging: r8188eu: use mgmt to set the category
  2022-05-21 15:38 [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                   ` (4 preceding siblings ...)
  2022-05-21 15:38 ` [PATCH 05/12] staging: r8188eu: use mgmt to set the sequence number Martin Kaiser
@ 2022-05-21 15:38 ` Martin Kaiser
  2022-05-21 15:38 ` [PATCH 07/12] staging: r8188eu: use mgmt to set the action codes Martin Kaiser
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-21 15:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure in issue_action_BA to set the category of the
outgoing frame. Remove the rtw_set_fixed_ie call.

We can now use the define directly, the category variable can be removed.

rtw_set_fixed_ie increments pattrib->pktlen, we have to do this ourselves
now (until we use a proper way to calculate the packet length).

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 9a26b67d49bd..dd736416ddcf 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5365,7 +5365,6 @@ int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int
 
 void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short status)
 {
-	u8 category = WLAN_CATEGORY_BACK;
 	u16 start_seq;
 	u16 BA_para_set;
 	u16 reason_code;
@@ -5410,7 +5409,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	pframe += sizeof(struct ieee80211_hdr_3addr);
 	pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
 
-	pframe = rtw_set_fixed_ie(pframe, 1, &(category), &pattrib->pktlen);
+	mgmt->u.action.category = WLAN_CATEGORY_BACK;
+	pattrib->pktlen++;
 	pframe = rtw_set_fixed_ie(pframe, 1, &(action), &pattrib->pktlen);
 
 	switch (action) {
-- 
2.30.2


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

* [PATCH 07/12] staging: r8188eu: use mgmt to set the action codes
  2022-05-21 15:38 [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                   ` (5 preceding siblings ...)
  2022-05-21 15:38 ` [PATCH 06/12] staging: r8188eu: use mgmt to set the category Martin Kaiser
@ 2022-05-21 15:38 ` Martin Kaiser
  2022-05-21 15:38 ` [PATCH 08/12] staging: r8188eu: use mgmt to set the dialog token Martin Kaiser
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-21 15:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure in issue_action_BA to set the action codes.
We have to distinguish between the different message types.

We also have to increment the packet length manually as we're no longer
calling rtw_set_fixed_ie, which increments the length.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index dd736416ddcf..efffbbfd495e 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5411,10 +5411,11 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 
 	mgmt->u.action.category = WLAN_CATEGORY_BACK;
 	pattrib->pktlen++;
-	pframe = rtw_set_fixed_ie(pframe, 1, &(action), &pattrib->pktlen);
 
 	switch (action) {
 	case WLAN_ACTION_ADDBA_REQ:
+		mgmt->u.action.u.addba_req.action_code = WLAN_ACTION_ADDBA_REQ;
+		pattrib->pktlen++;
 		do {
 			pmlmeinfo->dialogToken++;
 		} while (pmlmeinfo->dialogToken == 0);
@@ -5440,6 +5441,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
 		break;
 	case WLAN_ACTION_ADDBA_RESP:
+		mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP;
+		pattrib->pktlen++;
 		pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->ADDBA_req.dialog_token, &pattrib->pktlen);
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&status, &pattrib->pktlen);
 		BA_para_set = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f;
@@ -5455,6 +5458,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&pmlmeinfo->ADDBA_req.BA_timeout_value, &pattrib->pktlen);
 		break;
 	case WLAN_ACTION_DELBA:
+		mgmt->u.action.u.delba.action_code = WLAN_ACTION_DELBA;
+		pattrib->pktlen++;
 		BA_para_set = (status & 0x1F) << 3;
 		le_tmp = cpu_to_le16(BA_para_set);
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
-- 
2.30.2


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

* [PATCH 08/12] staging: r8188eu: use mgmt to set the dialog token
  2022-05-21 15:38 [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                   ` (6 preceding siblings ...)
  2022-05-21 15:38 ` [PATCH 07/12] staging: r8188eu: use mgmt to set the action codes Martin Kaiser
@ 2022-05-21 15:38 ` Martin Kaiser
  2022-05-21 15:38 ` [PATCH 09/12] staging: r8188eu: use mgmt to set the timeout Martin Kaiser
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-21 15:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure in issue_action_BA to set the dialog token.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index efffbbfd495e..bd74a8460ab3 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5419,7 +5419,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		do {
 			pmlmeinfo->dialogToken++;
 		} while (pmlmeinfo->dialogToken == 0);
-		pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->dialogToken, &pattrib->pktlen);
+		mgmt->u.action.u.addba_req.dialog_token = pmlmeinfo->dialogToken;
+		pattrib->pktlen++;
 
 		BA_para_set = (0x1002 | ((status & 0xf) << 2)); /* immediate ack & 64 buffer size */
 		le_tmp = cpu_to_le16(BA_para_set);
-- 
2.30.2


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

* [PATCH 09/12] staging: r8188eu: use mgmt to set the timeout
  2022-05-21 15:38 [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                   ` (7 preceding siblings ...)
  2022-05-21 15:38 ` [PATCH 08/12] staging: r8188eu: use mgmt to set the dialog token Martin Kaiser
@ 2022-05-21 15:38 ` Martin Kaiser
  2022-05-21 15:38 ` [PATCH 10/12] staging: r8188eu: use ieee80211 to set addba capabilities Martin Kaiser
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-21 15:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure in issue_action_BA to set the timeout in the
outgoing frame.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index bd74a8460ab3..d4dff434b19c 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5368,7 +5368,6 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	u16 start_seq;
 	u16 BA_para_set;
 	u16 reason_code;
-	u16 BA_timeout_value;
 	__le16	le_tmp;
 	u16 BA_starting_seqctrl = 0;
 	struct xmit_frame *pmgntframe;
@@ -5426,9 +5425,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		le_tmp = cpu_to_le16(BA_para_set);
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
 
-		BA_timeout_value = 5000;/*  5ms */
-		le_tmp = cpu_to_le16(BA_timeout_value);
-		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		mgmt->u.action.u.addba_req.timeout = cpu_to_le16(5000); /* 5 ms */
+		pattrib->pktlen += 2;
 
 		psta = rtw_get_stainfo(pstapriv, raddr);
 		if (psta) {
-- 
2.30.2


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

* [PATCH 10/12] staging: r8188eu: use ieee80211 to set addba capabilities
  2022-05-21 15:38 [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                   ` (8 preceding siblings ...)
  2022-05-21 15:38 ` [PATCH 09/12] staging: r8188eu: use mgmt to set the timeout Martin Kaiser
@ 2022-05-21 15:38 ` Martin Kaiser
  2022-05-21 15:38 ` [PATCH 11/12] staging: r8188eu: use mgmt to set start sequence number Martin Kaiser
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-21 15:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure and defines from ieee80211.h to set the
capabilities field of an addba request.

If issue_action_BA is called with action == WLAN_ACTION_ADDBA_REQ, the
status parameter contains the tid.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index d4dff434b19c..089baa78a28a 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5381,6 +5381,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	struct sta_priv *pstapriv = &padapter->stapriv;
 	struct registry_priv *pregpriv = &padapter->registrypriv;
 	struct ieee80211_mgmt *mgmt;
+	u16 capab;
 
 	pmgntframe = alloc_mgtxmitframe(pxmitpriv);
 	if (!pmgntframe)
@@ -5421,9 +5422,12 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		mgmt->u.action.u.addba_req.dialog_token = pmlmeinfo->dialogToken;
 		pattrib->pktlen++;
 
-		BA_para_set = (0x1002 | ((status & 0xf) << 2)); /* immediate ack & 64 buffer size */
-		le_tmp = cpu_to_le16(BA_para_set);
-		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		/* immediate ack & 64 buffer size */
+		capab = u16_encode_bits(64, IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK);
+		capab |= u16_encode_bits(1, IEEE80211_ADDBA_PARAM_POLICY_MASK);
+		capab |= u16_encode_bits(status, IEEE80211_ADDBA_PARAM_TID_MASK);
+		mgmt->u.action.u.addba_req.capab = cpu_to_le16(capab);
+		pattrib->pktlen += 2;
 
 		mgmt->u.action.u.addba_req.timeout = cpu_to_le16(5000); /* 5 ms */
 		pattrib->pktlen += 2;
-- 
2.30.2


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

* [PATCH 11/12] staging: r8188eu: use mgmt to set start sequence number
  2022-05-21 15:38 [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                   ` (9 preceding siblings ...)
  2022-05-21 15:38 ` [PATCH 10/12] staging: r8188eu: use ieee80211 to set addba capabilities Martin Kaiser
@ 2022-05-21 15:38 ` Martin Kaiser
  2022-05-21 15:38 ` [PATCH 12/12] staging: r8188eu: calculate the addba request length Martin Kaiser
  2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
  12 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-21 15:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure in issue_action_BA to set the start sequence
number.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 089baa78a28a..3e293ec59b7f 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5440,8 +5440,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 
 			BA_starting_seqctrl = start_seq << 4;
 		}
-		le_tmp = cpu_to_le16(BA_starting_seqctrl);
-		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		mgmt->u.action.u.addba_req.start_seq_num = cpu_to_le16(BA_starting_seqctrl);
+		pattrib->pktlen += 2;
 		break;
 	case WLAN_ACTION_ADDBA_RESP:
 		mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP;
-- 
2.30.2


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

* [PATCH 12/12] staging: r8188eu: calculate the addba request length
  2022-05-21 15:38 [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                   ` (10 preceding siblings ...)
  2022-05-21 15:38 ` [PATCH 11/12] staging: r8188eu: use mgmt to set start sequence number Martin Kaiser
@ 2022-05-21 15:38 ` Martin Kaiser
  2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
  12 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-21 15:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

When issue_action_BA compiles an addba request, it does not add any
extensions. start_seq_num is the last field of the addba request.

The length of the request is the offset of the end of start_seq_num in the
struct ieee80211_mgmt that defines the message.

Use offsetofend to calculate this offset and drop the intermediate pktlen
increments as we add addba request components. (We have to keep the
increments for other message types until we use offsetofend for them as
well.)

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 3e293ec59b7f..e56135efa1f8 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5415,22 +5415,18 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	switch (action) {
 	case WLAN_ACTION_ADDBA_REQ:
 		mgmt->u.action.u.addba_req.action_code = WLAN_ACTION_ADDBA_REQ;
-		pattrib->pktlen++;
 		do {
 			pmlmeinfo->dialogToken++;
 		} while (pmlmeinfo->dialogToken == 0);
 		mgmt->u.action.u.addba_req.dialog_token = pmlmeinfo->dialogToken;
-		pattrib->pktlen++;
 
 		/* immediate ack & 64 buffer size */
 		capab = u16_encode_bits(64, IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK);
 		capab |= u16_encode_bits(1, IEEE80211_ADDBA_PARAM_POLICY_MASK);
 		capab |= u16_encode_bits(status, IEEE80211_ADDBA_PARAM_TID_MASK);
 		mgmt->u.action.u.addba_req.capab = cpu_to_le16(capab);
-		pattrib->pktlen += 2;
 
 		mgmt->u.action.u.addba_req.timeout = cpu_to_le16(5000); /* 5 ms */
-		pattrib->pktlen += 2;
 
 		psta = rtw_get_stainfo(pstapriv, raddr);
 		if (psta) {
@@ -5441,7 +5437,9 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 			BA_starting_seqctrl = start_seq << 4;
 		}
 		mgmt->u.action.u.addba_req.start_seq_num = cpu_to_le16(BA_starting_seqctrl);
-		pattrib->pktlen += 2;
+
+		pattrib->pktlen = offsetofend(struct ieee80211_mgmt,
+					      u.action.u.addba_req.start_seq_num);
 		break;
 	case WLAN_ACTION_ADDBA_RESP:
 		mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP;
-- 
2.30.2


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

* Re: [PATCH 05/12] staging: r8188eu: use mgmt to set the sequence number
  2022-05-21 15:38 ` [PATCH 05/12] staging: r8188eu: use mgmt to set the sequence number Martin Kaiser
@ 2022-05-21 20:44   ` kernel test robot
  0 siblings, 0 replies; 27+ messages in thread
From: kernel test robot @ 2022-05-21 20:44 UTC (permalink / raw)
  To: Martin Kaiser, Greg Kroah-Hartman
  Cc: kbuild-all, Larry Finger, Phillip Potter, Michael Straube,
	Pavel Skripkin, linux-staging, linux-kernel, Martin Kaiser

Hi Martin,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on staging/staging-testing]

url:    https://github.com/intel-lab-lkp/linux/commits/Martin-Kaiser/staging-r8188eu-start-cleaning-up-issue_action_BA/20220521-234202
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 6a31a95135da0bb2c5349e49e37d76e9909ab7ea
config: i386-randconfig-a005 (https://download.01.org/0day-ci/archive/20220522/202205220408.1gEq5pSp-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-1) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/d2cf0b366868a18d3237f29c55e8c2f3a95a433f
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Martin-Kaiser/staging-r8188eu-start-cleaning-up-issue_action_BA/20220521-234202
        git checkout d2cf0b366868a18d3237f29c55e8c2f3a95a433f
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/staging/r8188eu/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/staging/r8188eu/core/rtw_mlme_ext.c: In function 'issue_action_BA':
>> drivers/staging/r8188eu/core/rtw_mlme_ext.c:5378:31: warning: variable 'pwlanhdr' set but not used [-Wunused-but-set-variable]
    5378 |         struct ieee80211_hdr *pwlanhdr;
         |                               ^~~~~~~~


vim +/pwlanhdr +5378 drivers/staging/r8188eu/core/rtw_mlme_ext.c

15865124feed88 Phillip Potter  2021-07-28  5365  
15865124feed88 Phillip Potter  2021-07-28  5366  void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short status)
15865124feed88 Phillip Potter  2021-07-28  5367  {
64c62b697f7612 Martin Kaiser   2022-05-02  5368  	u8 category = WLAN_CATEGORY_BACK;
15865124feed88 Phillip Potter  2021-07-28  5369  	u16 start_seq;
15865124feed88 Phillip Potter  2021-07-28  5370  	u16 BA_para_set;
15865124feed88 Phillip Potter  2021-07-28  5371  	u16 reason_code;
15865124feed88 Phillip Potter  2021-07-28  5372  	u16 BA_timeout_value;
15865124feed88 Phillip Potter  2021-07-28  5373  	__le16	le_tmp;
15865124feed88 Phillip Potter  2021-07-28  5374  	u16 BA_starting_seqctrl = 0;
15865124feed88 Phillip Potter  2021-07-28  5375  	struct xmit_frame *pmgntframe;
15865124feed88 Phillip Potter  2021-07-28  5376  	struct pkt_attrib *pattrib;
15865124feed88 Phillip Potter  2021-07-28  5377  	u8 *pframe;
9dc9653c8501b9 Michael Straube 2022-04-18 @5378  	struct ieee80211_hdr *pwlanhdr;
3b522a11b50476 Michael Straube 2021-08-09  5379  	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
3b522a11b50476 Michael Straube 2021-08-09  5380  	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
3b522a11b50476 Michael Straube 2021-08-09  5381  	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
15865124feed88 Phillip Potter  2021-07-28  5382  	struct sta_info *psta;
15865124feed88 Phillip Potter  2021-07-28  5383  	struct sta_priv *pstapriv = &padapter->stapriv;
15865124feed88 Phillip Potter  2021-07-28  5384  	struct registry_priv *pregpriv = &padapter->registrypriv;
106e8dfa1c07a9 Martin Kaiser   2022-05-21  5385  	struct ieee80211_mgmt *mgmt;
15865124feed88 Phillip Potter  2021-07-28  5386  
15865124feed88 Phillip Potter  2021-07-28  5387  	pmgntframe = alloc_mgtxmitframe(pxmitpriv);
552838fdcaef2c Michael Straube 2021-08-01  5388  	if (!pmgntframe)
15865124feed88 Phillip Potter  2021-07-28  5389  		return;
15865124feed88 Phillip Potter  2021-07-28  5390  
15865124feed88 Phillip Potter  2021-07-28  5391  	/* update attribute */
15865124feed88 Phillip Potter  2021-07-28  5392  	pattrib = &pmgntframe->attrib;
15865124feed88 Phillip Potter  2021-07-28  5393  	update_mgntframe_attrib(padapter, pattrib);
15865124feed88 Phillip Potter  2021-07-28  5394  
15865124feed88 Phillip Potter  2021-07-28  5395  	memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
15865124feed88 Phillip Potter  2021-07-28  5396  
15865124feed88 Phillip Potter  2021-07-28  5397  	pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
9dc9653c8501b9 Michael Straube 2022-04-18  5398  	pwlanhdr = (struct ieee80211_hdr *)pframe;
106e8dfa1c07a9 Martin Kaiser   2022-05-21  5399  	mgmt = (struct ieee80211_mgmt *)pframe;
15865124feed88 Phillip Potter  2021-07-28  5400  
106e8dfa1c07a9 Martin Kaiser   2022-05-21  5401  	mgmt->frame_control = cpu_to_le16(IEEE80211_STYPE_ACTION | IEEE80211_FTYPE_MGMT);
15865124feed88 Phillip Potter  2021-07-28  5402  
35f6cf522c478c Martin Kaiser   2022-05-21  5403  	memcpy(mgmt->da, raddr, ETH_ALEN);
35f6cf522c478c Martin Kaiser   2022-05-21  5404  	memcpy(mgmt->sa, myid(&padapter->eeprompriv), ETH_ALEN);
35f6cf522c478c Martin Kaiser   2022-05-21  5405  	memcpy(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
15865124feed88 Phillip Potter  2021-07-28  5406  
d2cf0b366868a1 Martin Kaiser   2022-05-21  5407  	mgmt->seq_ctrl = cpu_to_le16(pmlmeext->mgnt_seq);
15865124feed88 Phillip Potter  2021-07-28  5408  	pmlmeext->mgnt_seq++;
15865124feed88 Phillip Potter  2021-07-28  5409  
9dc9653c8501b9 Michael Straube 2022-04-18  5410  	pframe += sizeof(struct ieee80211_hdr_3addr);
9dc9653c8501b9 Michael Straube 2022-04-18  5411  	pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
15865124feed88 Phillip Potter  2021-07-28  5412  
3b522a11b50476 Michael Straube 2021-08-09  5413  	pframe = rtw_set_fixed_ie(pframe, 1, &(category), &pattrib->pktlen);
3b522a11b50476 Michael Straube 2021-08-09  5414  	pframe = rtw_set_fixed_ie(pframe, 1, &(action), &pattrib->pktlen);
15865124feed88 Phillip Potter  2021-07-28  5415  
15865124feed88 Phillip Potter  2021-07-28  5416  	switch (action) {
84aee42a485b38 Martin Kaiser   2022-05-21  5417  	case WLAN_ACTION_ADDBA_REQ:
15865124feed88 Phillip Potter  2021-07-28  5418  		do {
15865124feed88 Phillip Potter  2021-07-28  5419  			pmlmeinfo->dialogToken++;
15865124feed88 Phillip Potter  2021-07-28  5420  		} while (pmlmeinfo->dialogToken == 0);
3b522a11b50476 Michael Straube 2021-08-09  5421  		pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->dialogToken, &pattrib->pktlen);
15865124feed88 Phillip Potter  2021-07-28  5422  
15865124feed88 Phillip Potter  2021-07-28  5423  		BA_para_set = (0x1002 | ((status & 0xf) << 2)); /* immediate ack & 64 buffer size */
15865124feed88 Phillip Potter  2021-07-28  5424  		le_tmp = cpu_to_le16(BA_para_set);
3b522a11b50476 Michael Straube 2021-08-09  5425  		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
15865124feed88 Phillip Potter  2021-07-28  5426  
15865124feed88 Phillip Potter  2021-07-28  5427  		BA_timeout_value = 5000;/*  5ms */
15865124feed88 Phillip Potter  2021-07-28  5428  		le_tmp = cpu_to_le16(BA_timeout_value);
3b522a11b50476 Michael Straube 2021-08-09  5429  		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
15865124feed88 Phillip Potter  2021-07-28  5430  
15865124feed88 Phillip Potter  2021-07-28  5431  		psta = rtw_get_stainfo(pstapriv, raddr);
552838fdcaef2c Michael Straube 2021-08-01  5432  		if (psta) {
15865124feed88 Phillip Potter  2021-07-28  5433  			start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07] & 0xfff) + 1;
15865124feed88 Phillip Potter  2021-07-28  5434  
15865124feed88 Phillip Potter  2021-07-28  5435  			psta->BA_starting_seqctrl[status & 0x07] = start_seq;
15865124feed88 Phillip Potter  2021-07-28  5436  
15865124feed88 Phillip Potter  2021-07-28  5437  			BA_starting_seqctrl = start_seq << 4;
15865124feed88 Phillip Potter  2021-07-28  5438  		}
15865124feed88 Phillip Potter  2021-07-28  5439  		le_tmp = cpu_to_le16(BA_starting_seqctrl);
3b522a11b50476 Michael Straube 2021-08-09  5440  		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
15865124feed88 Phillip Potter  2021-07-28  5441  		break;
84aee42a485b38 Martin Kaiser   2022-05-21  5442  	case WLAN_ACTION_ADDBA_RESP:
3b522a11b50476 Michael Straube 2021-08-09  5443  		pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->ADDBA_req.dialog_token, &pattrib->pktlen);
3b522a11b50476 Michael Straube 2021-08-09  5444  		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&status, &pattrib->pktlen);
15865124feed88 Phillip Potter  2021-07-28  5445  		BA_para_set = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f;
15865124feed88 Phillip Potter  2021-07-28  5446  		BA_para_set |= 0x1000; /* 64 buffer size */
15865124feed88 Phillip Potter  2021-07-28  5447  
15865124feed88 Phillip Potter  2021-07-28  5448  		if (pregpriv->ampdu_amsdu == 0)/* disabled */
15865124feed88 Phillip Potter  2021-07-28  5449  			BA_para_set = BA_para_set & ~BIT(0);
15865124feed88 Phillip Potter  2021-07-28  5450  		else if (pregpriv->ampdu_amsdu == 1)/* enabled */
15865124feed88 Phillip Potter  2021-07-28  5451  			BA_para_set = BA_para_set | BIT(0);
15865124feed88 Phillip Potter  2021-07-28  5452  		le_tmp = cpu_to_le16(BA_para_set);
15865124feed88 Phillip Potter  2021-07-28  5453  
3b522a11b50476 Michael Straube 2021-08-09  5454  		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
3b522a11b50476 Michael Straube 2021-08-09  5455  		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&pmlmeinfo->ADDBA_req.BA_timeout_value, &pattrib->pktlen);
15865124feed88 Phillip Potter  2021-07-28  5456  		break;
84aee42a485b38 Martin Kaiser   2022-05-21  5457  	case WLAN_ACTION_DELBA:
15865124feed88 Phillip Potter  2021-07-28  5458  		BA_para_set = (status & 0x1F) << 3;
15865124feed88 Phillip Potter  2021-07-28  5459  		le_tmp = cpu_to_le16(BA_para_set);
3b522a11b50476 Michael Straube 2021-08-09  5460  		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
15865124feed88 Phillip Potter  2021-07-28  5461  
15865124feed88 Phillip Potter  2021-07-28  5462  		reason_code = 37;/* Requested from peer STA as it does not want to use the mechanism */
15865124feed88 Phillip Potter  2021-07-28  5463  		le_tmp = cpu_to_le16(reason_code);
3b522a11b50476 Michael Straube 2021-08-09  5464  		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
15865124feed88 Phillip Potter  2021-07-28  5465  		break;
15865124feed88 Phillip Potter  2021-07-28  5466  	default:
15865124feed88 Phillip Potter  2021-07-28  5467  		break;
15865124feed88 Phillip Potter  2021-07-28  5468  	}
15865124feed88 Phillip Potter  2021-07-28  5469  
15865124feed88 Phillip Potter  2021-07-28  5470  	pattrib->last_txcmdsz = pattrib->pktlen;
15865124feed88 Phillip Potter  2021-07-28  5471  
15865124feed88 Phillip Potter  2021-07-28  5472  	dump_mgntframe(padapter, pmgntframe);
15865124feed88 Phillip Potter  2021-07-28  5473  }
15865124feed88 Phillip Potter  2021-07-28  5474  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA
  2022-05-21 15:38 [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                   ` (11 preceding siblings ...)
  2022-05-21 15:38 ` [PATCH 12/12] staging: r8188eu: calculate the addba request length Martin Kaiser
@ 2022-05-24  9:00 ` Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 01/12] staging: r8188eu: remove unnecessary category check Martin Kaiser
                     ` (11 more replies)
  12 siblings, 12 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-24  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Start cleaning up the issue_action_BA function. Use helpers from
ieee80211.h to populate some of the fields of the outgoing frame.

(I'll send more patches for the remaining fields and messages.)

v2
- patch 5: remove a variable that's no longer used

Martin Kaiser (12):
  staging: r8188eu: remove unnecessary category check
  staging: r8188eu: use defines for the block action codes
  staging: r8188eu: use ieee80211_mgmt in issue_action_BA
  staging: r8188eu: use mgmt to set the addresses
  staging: r8188eu: use mgmt to set the sequence number
  staging: r8188eu: use mgmt to set the category
  staging: r8188eu: use mgmt to set the action codes
  staging: r8188eu: use mgmt to set the dialog token
  staging: r8188eu: use mgmt to set the timeout
  staging: r8188eu: use ieee80211 to set addba capabilities
  staging: r8188eu: use mgmt to set start sequence number
  staging: r8188eu: calculate the addba request length

 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 126 ++++++++++----------
 1 file changed, 63 insertions(+), 63 deletions(-)

-- 
2.30.2


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

* [PATCH v2 01/12] staging: r8188eu: remove unnecessary category check
  2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
@ 2022-05-24  9:00   ` Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 02/12] staging: r8188eu: use defines for the block action codes Martin Kaiser
                     ` (10 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-24  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Remove the unnecessary category check in issue_action_BA. category is
initialised to 3 (WLAN_CATEGORY_BACK) and never updated.

The rtw_set_fixed_ie call gets a pointer to category but it doesn't update
the value.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index faf23fc950c5..f47cf3e7316c 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5415,60 +5415,58 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	pframe = rtw_set_fixed_ie(pframe, 1, &(category), &pattrib->pktlen);
 	pframe = rtw_set_fixed_ie(pframe, 1, &(action), &pattrib->pktlen);
 
-	if (category == 3) {
-		switch (action) {
-		case 0: /* ADDBA req */
-			do {
-				pmlmeinfo->dialogToken++;
-			} while (pmlmeinfo->dialogToken == 0);
-			pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->dialogToken, &pattrib->pktlen);
+	switch (action) {
+	case 0: /* ADDBA req */
+		do {
+			pmlmeinfo->dialogToken++;
+		} while (pmlmeinfo->dialogToken == 0);
+		pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->dialogToken, &pattrib->pktlen);
 
-			BA_para_set = (0x1002 | ((status & 0xf) << 2)); /* immediate ack & 64 buffer size */
-			le_tmp = cpu_to_le16(BA_para_set);
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		BA_para_set = (0x1002 | ((status & 0xf) << 2)); /* immediate ack & 64 buffer size */
+		le_tmp = cpu_to_le16(BA_para_set);
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
 
-			BA_timeout_value = 5000;/*  5ms */
-			le_tmp = cpu_to_le16(BA_timeout_value);
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		BA_timeout_value = 5000;/*  5ms */
+		le_tmp = cpu_to_le16(BA_timeout_value);
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
 
-			psta = rtw_get_stainfo(pstapriv, raddr);
-			if (psta) {
-				start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07] & 0xfff) + 1;
+		psta = rtw_get_stainfo(pstapriv, raddr);
+		if (psta) {
+			start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07] & 0xfff) + 1;
 
-				psta->BA_starting_seqctrl[status & 0x07] = start_seq;
+			psta->BA_starting_seqctrl[status & 0x07] = start_seq;
 
-				BA_starting_seqctrl = start_seq << 4;
-			}
-			le_tmp = cpu_to_le16(BA_starting_seqctrl);
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
-			break;
-		case 1: /* ADDBA rsp */
-			pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->ADDBA_req.dialog_token, &pattrib->pktlen);
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&status, &pattrib->pktlen);
-			BA_para_set = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f;
-			BA_para_set |= 0x1000; /* 64 buffer size */
-
-			if (pregpriv->ampdu_amsdu == 0)/* disabled */
-				BA_para_set = BA_para_set & ~BIT(0);
-			else if (pregpriv->ampdu_amsdu == 1)/* enabled */
-				BA_para_set = BA_para_set | BIT(0);
-			le_tmp = cpu_to_le16(BA_para_set);
-
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&pmlmeinfo->ADDBA_req.BA_timeout_value, &pattrib->pktlen);
-			break;
-		case 2:/* DELBA */
-			BA_para_set = (status & 0x1F) << 3;
-			le_tmp = cpu_to_le16(BA_para_set);
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
-
-			reason_code = 37;/* Requested from peer STA as it does not want to use the mechanism */
-			le_tmp = cpu_to_le16(reason_code);
-			pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
-			break;
-		default:
-			break;
+			BA_starting_seqctrl = start_seq << 4;
 		}
+		le_tmp = cpu_to_le16(BA_starting_seqctrl);
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		break;
+	case 1: /* ADDBA rsp */
+		pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->ADDBA_req.dialog_token, &pattrib->pktlen);
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&status, &pattrib->pktlen);
+		BA_para_set = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f;
+		BA_para_set |= 0x1000; /* 64 buffer size */
+
+		if (pregpriv->ampdu_amsdu == 0)/* disabled */
+			BA_para_set = BA_para_set & ~BIT(0);
+		else if (pregpriv->ampdu_amsdu == 1)/* enabled */
+			BA_para_set = BA_para_set | BIT(0);
+		le_tmp = cpu_to_le16(BA_para_set);
+
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&pmlmeinfo->ADDBA_req.BA_timeout_value, &pattrib->pktlen);
+		break;
+	case 2:/* DELBA */
+		BA_para_set = (status & 0x1F) << 3;
+		le_tmp = cpu_to_le16(BA_para_set);
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+
+		reason_code = 37;/* Requested from peer STA as it does not want to use the mechanism */
+		le_tmp = cpu_to_le16(reason_code);
+		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		break;
+	default:
+		break;
 	}
 
 	pattrib->last_txcmdsz = pattrib->pktlen;
-- 
2.30.2


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

* [PATCH v2 02/12] staging: r8188eu: use defines for the block action codes
  2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 01/12] staging: r8188eu: remove unnecessary category check Martin Kaiser
@ 2022-05-24  9:00   ` Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 03/12] staging: r8188eu: use ieee80211_mgmt in issue_action_BA Martin Kaiser
                     ` (9 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-24  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Replace the numeric values for the block action codes in issue_action_BA
with the defines from ieee80211.h.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index f47cf3e7316c..0265784368e2 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5416,7 +5416,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	pframe = rtw_set_fixed_ie(pframe, 1, &(action), &pattrib->pktlen);
 
 	switch (action) {
-	case 0: /* ADDBA req */
+	case WLAN_ACTION_ADDBA_REQ:
 		do {
 			pmlmeinfo->dialogToken++;
 		} while (pmlmeinfo->dialogToken == 0);
@@ -5441,7 +5441,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		le_tmp = cpu_to_le16(BA_starting_seqctrl);
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
 		break;
-	case 1: /* ADDBA rsp */
+	case WLAN_ACTION_ADDBA_RESP:
 		pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->ADDBA_req.dialog_token, &pattrib->pktlen);
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&status, &pattrib->pktlen);
 		BA_para_set = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f;
@@ -5456,7 +5456,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&pmlmeinfo->ADDBA_req.BA_timeout_value, &pattrib->pktlen);
 		break;
-	case 2:/* DELBA */
+	case WLAN_ACTION_DELBA:
 		BA_para_set = (status & 0x1F) << 3;
 		le_tmp = cpu_to_le16(BA_para_set);
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
-- 
2.30.2


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

* [PATCH v2 03/12] staging: r8188eu: use ieee80211_mgmt in issue_action_BA
  2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 01/12] staging: r8188eu: remove unnecessary category check Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 02/12] staging: r8188eu: use defines for the block action codes Martin Kaiser
@ 2022-05-24  9:00   ` Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 04/12] staging: r8188eu: use mgmt to set the addresses Martin Kaiser
                     ` (8 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-24  9:00 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_mgmt variable in issue_action_BA, this will make
it much simpler to populate the fields of the outoing frame.

Use the new mgmt variable to set the type and subtype of the frame.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 0265784368e2..eec716fea41c 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5376,13 +5376,13 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	struct pkt_attrib *pattrib;
 	u8 *pframe;
 	struct ieee80211_hdr *pwlanhdr;
-	__le16 *fctrl;
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
 	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 	struct sta_info *psta;
 	struct sta_priv *pstapriv = &padapter->stapriv;
 	struct registry_priv *pregpriv = &padapter->registrypriv;
+	struct ieee80211_mgmt *mgmt;
 
 	pmgntframe = alloc_mgtxmitframe(pxmitpriv);
 	if (!pmgntframe)
@@ -5396,9 +5396,9 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 
 	pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
 	pwlanhdr = (struct ieee80211_hdr *)pframe;
+	mgmt = (struct ieee80211_mgmt *)pframe;
 
-	fctrl = &pwlanhdr->frame_control;
-	*(fctrl) = 0;
+	mgmt->frame_control = cpu_to_le16(IEEE80211_STYPE_ACTION | IEEE80211_FTYPE_MGMT);
 
 	/* memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); */
 	memcpy(pwlanhdr->addr1, raddr, ETH_ALEN);
@@ -5407,7 +5407,6 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 
 	SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
 	pmlmeext->mgnt_seq++;
-	SetFrameSubType(pframe, WIFI_ACTION);
 
 	pframe += sizeof(struct ieee80211_hdr_3addr);
 	pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-- 
2.30.2


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

* [PATCH v2 04/12] staging: r8188eu: use mgmt to set the addresses
  2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                     ` (2 preceding siblings ...)
  2022-05-24  9:00   ` [PATCH v2 03/12] staging: r8188eu: use ieee80211_mgmt in issue_action_BA Martin Kaiser
@ 2022-05-24  9:00   ` Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 05/12] staging: r8188eu: use mgmt to set the sequence number Martin Kaiser
                     ` (7 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-24  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure in issue_action_BA to set the three addresses of
the outgoing frame.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index eec716fea41c..f08521cb1ff7 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5400,10 +5400,9 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 
 	mgmt->frame_control = cpu_to_le16(IEEE80211_STYPE_ACTION | IEEE80211_FTYPE_MGMT);
 
-	/* memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); */
-	memcpy(pwlanhdr->addr1, raddr, ETH_ALEN);
-	memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-	memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
+	memcpy(mgmt->da, raddr, ETH_ALEN);
+	memcpy(mgmt->sa, myid(&padapter->eeprompriv), ETH_ALEN);
+	memcpy(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
 
 	SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
 	pmlmeext->mgnt_seq++;
-- 
2.30.2


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

* [PATCH v2 05/12] staging: r8188eu: use mgmt to set the sequence number
  2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                     ` (3 preceding siblings ...)
  2022-05-24  9:00   ` [PATCH v2 04/12] staging: r8188eu: use mgmt to set the addresses Martin Kaiser
@ 2022-05-24  9:00   ` Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 06/12] staging: r8188eu: use mgmt to set the category Martin Kaiser
                     ` (6 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-24  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser, kernel test robot

Use the mgmt structure in issue_action_BA to set the sequence number of
the outgoing frame.

pwlanhdr is now unused, it can be removed.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
v2:
- remove pwlanhdr, it's not used any more

 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index f08521cb1ff7..e64f2a0ec626 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5375,7 +5375,6 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	struct xmit_frame *pmgntframe;
 	struct pkt_attrib *pattrib;
 	u8 *pframe;
-	struct ieee80211_hdr *pwlanhdr;
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
 	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
@@ -5395,7 +5394,6 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
 
 	pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-	pwlanhdr = (struct ieee80211_hdr *)pframe;
 	mgmt = (struct ieee80211_mgmt *)pframe;
 
 	mgmt->frame_control = cpu_to_le16(IEEE80211_STYPE_ACTION | IEEE80211_FTYPE_MGMT);
@@ -5404,7 +5402,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	memcpy(mgmt->sa, myid(&padapter->eeprompriv), ETH_ALEN);
 	memcpy(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
 
-	SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
+	mgmt->seq_ctrl = cpu_to_le16(pmlmeext->mgnt_seq);
 	pmlmeext->mgnt_seq++;
 
 	pframe += sizeof(struct ieee80211_hdr_3addr);
-- 
2.30.2


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

* [PATCH v2 06/12] staging: r8188eu: use mgmt to set the category
  2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                     ` (4 preceding siblings ...)
  2022-05-24  9:00   ` [PATCH v2 05/12] staging: r8188eu: use mgmt to set the sequence number Martin Kaiser
@ 2022-05-24  9:00   ` Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 07/12] staging: r8188eu: use mgmt to set the action codes Martin Kaiser
                     ` (5 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-24  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure in issue_action_BA to set the category of the
outgoing frame. Remove the rtw_set_fixed_ie call.

We can now use the define directly, the category variable can be removed.

rtw_set_fixed_ie increments pattrib->pktlen, we have to do this ourselves
now (until we use a proper way to calculate the packet length).

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index e64f2a0ec626..d693e0a1396b 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5365,7 +5365,6 @@ int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int
 
 void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short status)
 {
-	u8 category = WLAN_CATEGORY_BACK;
 	u16 start_seq;
 	u16 BA_para_set;
 	u16 reason_code;
@@ -5408,7 +5407,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	pframe += sizeof(struct ieee80211_hdr_3addr);
 	pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
 
-	pframe = rtw_set_fixed_ie(pframe, 1, &(category), &pattrib->pktlen);
+	mgmt->u.action.category = WLAN_CATEGORY_BACK;
+	pattrib->pktlen++;
 	pframe = rtw_set_fixed_ie(pframe, 1, &(action), &pattrib->pktlen);
 
 	switch (action) {
-- 
2.30.2


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

* [PATCH v2 07/12] staging: r8188eu: use mgmt to set the action codes
  2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                     ` (5 preceding siblings ...)
  2022-05-24  9:00   ` [PATCH v2 06/12] staging: r8188eu: use mgmt to set the category Martin Kaiser
@ 2022-05-24  9:00   ` Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 08/12] staging: r8188eu: use mgmt to set the dialog token Martin Kaiser
                     ` (4 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-24  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure in issue_action_BA to set the action codes.
We have to distinguish between the different message types.

We also have to increment the packet length manually as we're no longer
calling rtw_set_fixed_ie, which increments the length.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index d693e0a1396b..aa73afc6e36a 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5409,10 +5409,11 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 
 	mgmt->u.action.category = WLAN_CATEGORY_BACK;
 	pattrib->pktlen++;
-	pframe = rtw_set_fixed_ie(pframe, 1, &(action), &pattrib->pktlen);
 
 	switch (action) {
 	case WLAN_ACTION_ADDBA_REQ:
+		mgmt->u.action.u.addba_req.action_code = WLAN_ACTION_ADDBA_REQ;
+		pattrib->pktlen++;
 		do {
 			pmlmeinfo->dialogToken++;
 		} while (pmlmeinfo->dialogToken == 0);
@@ -5438,6 +5439,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
 		break;
 	case WLAN_ACTION_ADDBA_RESP:
+		mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP;
+		pattrib->pktlen++;
 		pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->ADDBA_req.dialog_token, &pattrib->pktlen);
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&status, &pattrib->pktlen);
 		BA_para_set = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f;
@@ -5453,6 +5456,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&pmlmeinfo->ADDBA_req.BA_timeout_value, &pattrib->pktlen);
 		break;
 	case WLAN_ACTION_DELBA:
+		mgmt->u.action.u.delba.action_code = WLAN_ACTION_DELBA;
+		pattrib->pktlen++;
 		BA_para_set = (status & 0x1F) << 3;
 		le_tmp = cpu_to_le16(BA_para_set);
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
-- 
2.30.2


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

* [PATCH v2 08/12] staging: r8188eu: use mgmt to set the dialog token
  2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                     ` (6 preceding siblings ...)
  2022-05-24  9:00   ` [PATCH v2 07/12] staging: r8188eu: use mgmt to set the action codes Martin Kaiser
@ 2022-05-24  9:00   ` Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 09/12] staging: r8188eu: use mgmt to set the timeout Martin Kaiser
                     ` (3 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-24  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure in issue_action_BA to set the dialog token.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index aa73afc6e36a..ce6327dbc534 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5417,7 +5417,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		do {
 			pmlmeinfo->dialogToken++;
 		} while (pmlmeinfo->dialogToken == 0);
-		pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->dialogToken, &pattrib->pktlen);
+		mgmt->u.action.u.addba_req.dialog_token = pmlmeinfo->dialogToken;
+		pattrib->pktlen++;
 
 		BA_para_set = (0x1002 | ((status & 0xf) << 2)); /* immediate ack & 64 buffer size */
 		le_tmp = cpu_to_le16(BA_para_set);
-- 
2.30.2


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

* [PATCH v2 09/12] staging: r8188eu: use mgmt to set the timeout
  2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                     ` (7 preceding siblings ...)
  2022-05-24  9:00   ` [PATCH v2 08/12] staging: r8188eu: use mgmt to set the dialog token Martin Kaiser
@ 2022-05-24  9:00   ` Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 10/12] staging: r8188eu: use ieee80211 to set addba capabilities Martin Kaiser
                     ` (2 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-24  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure in issue_action_BA to set the timeout in the
outgoing frame.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index ce6327dbc534..da0c0363eb4d 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5368,7 +5368,6 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	u16 start_seq;
 	u16 BA_para_set;
 	u16 reason_code;
-	u16 BA_timeout_value;
 	__le16	le_tmp;
 	u16 BA_starting_seqctrl = 0;
 	struct xmit_frame *pmgntframe;
@@ -5424,9 +5423,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		le_tmp = cpu_to_le16(BA_para_set);
 		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
 
-		BA_timeout_value = 5000;/*  5ms */
-		le_tmp = cpu_to_le16(BA_timeout_value);
-		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		mgmt->u.action.u.addba_req.timeout = cpu_to_le16(5000); /* 5 ms */
+		pattrib->pktlen += 2;
 
 		psta = rtw_get_stainfo(pstapriv, raddr);
 		if (psta) {
-- 
2.30.2


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

* [PATCH v2 10/12] staging: r8188eu: use ieee80211 to set addba capabilities
  2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                     ` (8 preceding siblings ...)
  2022-05-24  9:00   ` [PATCH v2 09/12] staging: r8188eu: use mgmt to set the timeout Martin Kaiser
@ 2022-05-24  9:00   ` Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 11/12] staging: r8188eu: use mgmt to set start sequence number Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 12/12] staging: r8188eu: calculate the addba request length Martin Kaiser
  11 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-24  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure and defines from ieee80211.h to set the
capabilities field of an addba request.

If issue_action_BA is called with action == WLAN_ACTION_ADDBA_REQ, the
status parameter contains the tid.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index da0c0363eb4d..823c54837364 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5380,6 +5380,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	struct sta_priv *pstapriv = &padapter->stapriv;
 	struct registry_priv *pregpriv = &padapter->registrypriv;
 	struct ieee80211_mgmt *mgmt;
+	u16 capab;
 
 	pmgntframe = alloc_mgtxmitframe(pxmitpriv);
 	if (!pmgntframe)
@@ -5419,9 +5420,12 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		mgmt->u.action.u.addba_req.dialog_token = pmlmeinfo->dialogToken;
 		pattrib->pktlen++;
 
-		BA_para_set = (0x1002 | ((status & 0xf) << 2)); /* immediate ack & 64 buffer size */
-		le_tmp = cpu_to_le16(BA_para_set);
-		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		/* immediate ack & 64 buffer size */
+		capab = u16_encode_bits(64, IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK);
+		capab |= u16_encode_bits(1, IEEE80211_ADDBA_PARAM_POLICY_MASK);
+		capab |= u16_encode_bits(status, IEEE80211_ADDBA_PARAM_TID_MASK);
+		mgmt->u.action.u.addba_req.capab = cpu_to_le16(capab);
+		pattrib->pktlen += 2;
 
 		mgmt->u.action.u.addba_req.timeout = cpu_to_le16(5000); /* 5 ms */
 		pattrib->pktlen += 2;
-- 
2.30.2


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

* [PATCH v2 11/12] staging: r8188eu: use mgmt to set start sequence number
  2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                     ` (9 preceding siblings ...)
  2022-05-24  9:00   ` [PATCH v2 10/12] staging: r8188eu: use ieee80211 to set addba capabilities Martin Kaiser
@ 2022-05-24  9:00   ` Martin Kaiser
  2022-05-24  9:00   ` [PATCH v2 12/12] staging: r8188eu: calculate the addba request length Martin Kaiser
  11 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-24  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use the mgmt structure in issue_action_BA to set the start sequence
number.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 823c54837364..408aa0a28382 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5438,8 +5438,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 
 			BA_starting_seqctrl = start_seq << 4;
 		}
-		le_tmp = cpu_to_le16(BA_starting_seqctrl);
-		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen);
+		mgmt->u.action.u.addba_req.start_seq_num = cpu_to_le16(BA_starting_seqctrl);
+		pattrib->pktlen += 2;
 		break;
 	case WLAN_ACTION_ADDBA_RESP:
 		mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP;
-- 
2.30.2


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

* [PATCH v2 12/12] staging: r8188eu: calculate the addba request length
  2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
                     ` (10 preceding siblings ...)
  2022-05-24  9:00   ` [PATCH v2 11/12] staging: r8188eu: use mgmt to set start sequence number Martin Kaiser
@ 2022-05-24  9:00   ` Martin Kaiser
  11 siblings, 0 replies; 27+ messages in thread
From: Martin Kaiser @ 2022-05-24  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

When issue_action_BA compiles an addba request, it does not add any
extensions. start_seq_num is the last field of the addba request.

The length of the request is the offset of the end of start_seq_num in the
struct ieee80211_mgmt that defines the message.

Use offsetofend to calculate this offset and drop the intermediate pktlen
increments as we add addba request components. (We have to keep the
increments for other message types until we use offsetofend for them as
well.)

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 408aa0a28382..5446e19d8d09 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5413,22 +5413,18 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	switch (action) {
 	case WLAN_ACTION_ADDBA_REQ:
 		mgmt->u.action.u.addba_req.action_code = WLAN_ACTION_ADDBA_REQ;
-		pattrib->pktlen++;
 		do {
 			pmlmeinfo->dialogToken++;
 		} while (pmlmeinfo->dialogToken == 0);
 		mgmt->u.action.u.addba_req.dialog_token = pmlmeinfo->dialogToken;
-		pattrib->pktlen++;
 
 		/* immediate ack & 64 buffer size */
 		capab = u16_encode_bits(64, IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK);
 		capab |= u16_encode_bits(1, IEEE80211_ADDBA_PARAM_POLICY_MASK);
 		capab |= u16_encode_bits(status, IEEE80211_ADDBA_PARAM_TID_MASK);
 		mgmt->u.action.u.addba_req.capab = cpu_to_le16(capab);
-		pattrib->pktlen += 2;
 
 		mgmt->u.action.u.addba_req.timeout = cpu_to_le16(5000); /* 5 ms */
-		pattrib->pktlen += 2;
 
 		psta = rtw_get_stainfo(pstapriv, raddr);
 		if (psta) {
@@ -5439,7 +5435,9 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 			BA_starting_seqctrl = start_seq << 4;
 		}
 		mgmt->u.action.u.addba_req.start_seq_num = cpu_to_le16(BA_starting_seqctrl);
-		pattrib->pktlen += 2;
+
+		pattrib->pktlen = offsetofend(struct ieee80211_mgmt,
+					      u.action.u.addba_req.start_seq_num);
 		break;
 	case WLAN_ACTION_ADDBA_RESP:
 		mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP;
-- 
2.30.2


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

end of thread, other threads:[~2022-05-24  9:01 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-21 15:38 [PATCH 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
2022-05-21 15:38 ` [PATCH 01/12] staging: r8188eu: remove unnecessary category check Martin Kaiser
2022-05-21 15:38 ` [PATCH 02/12] staging: r8188eu: use defines for the block action codes Martin Kaiser
2022-05-21 15:38 ` [PATCH 03/12] staging: r8188eu: use ieee80211_mgmt in issue_action_BA Martin Kaiser
2022-05-21 15:38 ` [PATCH 04/12] staging: r8188eu: use mgmt to set the addresses Martin Kaiser
2022-05-21 15:38 ` [PATCH 05/12] staging: r8188eu: use mgmt to set the sequence number Martin Kaiser
2022-05-21 20:44   ` kernel test robot
2022-05-21 15:38 ` [PATCH 06/12] staging: r8188eu: use mgmt to set the category Martin Kaiser
2022-05-21 15:38 ` [PATCH 07/12] staging: r8188eu: use mgmt to set the action codes Martin Kaiser
2022-05-21 15:38 ` [PATCH 08/12] staging: r8188eu: use mgmt to set the dialog token Martin Kaiser
2022-05-21 15:38 ` [PATCH 09/12] staging: r8188eu: use mgmt to set the timeout Martin Kaiser
2022-05-21 15:38 ` [PATCH 10/12] staging: r8188eu: use ieee80211 to set addba capabilities Martin Kaiser
2022-05-21 15:38 ` [PATCH 11/12] staging: r8188eu: use mgmt to set start sequence number Martin Kaiser
2022-05-21 15:38 ` [PATCH 12/12] staging: r8188eu: calculate the addba request length Martin Kaiser
2022-05-24  9:00 ` [PATCH v2 00/12] staging: r8188eu: start cleaning up issue_action_BA Martin Kaiser
2022-05-24  9:00   ` [PATCH v2 01/12] staging: r8188eu: remove unnecessary category check Martin Kaiser
2022-05-24  9:00   ` [PATCH v2 02/12] staging: r8188eu: use defines for the block action codes Martin Kaiser
2022-05-24  9:00   ` [PATCH v2 03/12] staging: r8188eu: use ieee80211_mgmt in issue_action_BA Martin Kaiser
2022-05-24  9:00   ` [PATCH v2 04/12] staging: r8188eu: use mgmt to set the addresses Martin Kaiser
2022-05-24  9:00   ` [PATCH v2 05/12] staging: r8188eu: use mgmt to set the sequence number Martin Kaiser
2022-05-24  9:00   ` [PATCH v2 06/12] staging: r8188eu: use mgmt to set the category Martin Kaiser
2022-05-24  9:00   ` [PATCH v2 07/12] staging: r8188eu: use mgmt to set the action codes Martin Kaiser
2022-05-24  9:00   ` [PATCH v2 08/12] staging: r8188eu: use mgmt to set the dialog token Martin Kaiser
2022-05-24  9:00   ` [PATCH v2 09/12] staging: r8188eu: use mgmt to set the timeout Martin Kaiser
2022-05-24  9:00   ` [PATCH v2 10/12] staging: r8188eu: use ieee80211 to set addba capabilities Martin Kaiser
2022-05-24  9:00   ` [PATCH v2 11/12] staging: r8188eu: use mgmt to set start sequence number Martin Kaiser
2022-05-24  9:00   ` [PATCH v2 12/12] staging: r8188eu: calculate the addba request length Martin Kaiser

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.