All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA
@ 2022-06-02 19:37 Martin Kaiser
  2022-06-02 19:37 ` [PATCH 01/11] staging: r8188eu: use mgmt to set resp dialog token Martin Kaiser
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Martin Kaiser @ 2022-06-02 19:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Simplify the code to send the addba response and the delba message. Use
ieee80211 helpers if possible.

This series should be applied after the "start cleaning up
issue_action_BA" series.

Martin Kaiser (11):
  staging: r8188eu: use mgmt to set resp dialog token
  staging: r8188eu: use mgmt to set the addba resp status
  staging: r8188eu: use mgmt to set the addba resp timeout
  staging: r8188eu: use ieee80211 to set addba resp capabilities
  staging: r8188eu: calculate the addba response length
  staging: r8188eu: use mgmt to set the delba reason code
  staging: r8188eu: use mgmt to set delba params
  staging: r8188eu: clarify the contents of the delba params
  staging: r8188eu: calculate the delba length
  staging: r8188eu: remove the pframe variable
  staging: r8188eu: use u8, u16 in issue_action_BA prototype

 drivers/staging/r8188eu/core/rtw_mlme_ext.c   | 51 +++++++------------
 .../staging/r8188eu/include/rtw_mlme_ext.h    |  3 +-
 2 files changed, 18 insertions(+), 36 deletions(-)

-- 
2.30.2


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

* [PATCH 01/11] staging: r8188eu: use mgmt to set resp dialog token
  2022-06-02 19:37 [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Martin Kaiser
@ 2022-06-02 19:37 ` Martin Kaiser
  2022-06-02 19:37 ` [PATCH 02/11] staging: r8188eu: use mgmt to set the addba resp status Martin Kaiser
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Martin Kaiser @ 2022-06-02 19:37 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 to set the dialog token of an addba response.

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 5446e19d8d09..ad3dc6d1ca6f 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5442,7 +5442,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	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);
+		mgmt->u.action.u.addba_resp.dialog_token = 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 */
-- 
2.30.2


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

* [PATCH 02/11] staging: r8188eu: use mgmt to set the addba resp status
  2022-06-02 19:37 [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Martin Kaiser
  2022-06-02 19:37 ` [PATCH 01/11] staging: r8188eu: use mgmt to set resp dialog token Martin Kaiser
@ 2022-06-02 19:37 ` Martin Kaiser
  2022-06-02 19:37 ` [PATCH 03/11] staging: r8188eu: use mgmt to set the addba resp timeout Martin Kaiser
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Martin Kaiser @ 2022-06-02 19:37 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 struct to set the addba response status.

The caller passes the status code in host endianness, we have to convert
it to little endian.

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 ad3dc6d1ca6f..f97a22395ce4 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5444,7 +5444,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		pattrib->pktlen++;
 		mgmt->u.action.u.addba_resp.dialog_token = pmlmeinfo->ADDBA_req.dialog_token;
 		pattrib->pktlen++;
-		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&status, &pattrib->pktlen);
+		mgmt->u.action.u.addba_resp.status = cpu_to_le16(status);
+		pattrib->pktlen += 2;
 		BA_para_set = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f;
 		BA_para_set |= 0x1000; /* 64 buffer size */
 
-- 
2.30.2


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

* [PATCH 03/11] staging: r8188eu: use mgmt to set the addba resp timeout
  2022-06-02 19:37 [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Martin Kaiser
  2022-06-02 19:37 ` [PATCH 01/11] staging: r8188eu: use mgmt to set resp dialog token Martin Kaiser
  2022-06-02 19:37 ` [PATCH 02/11] staging: r8188eu: use mgmt to set the addba resp status Martin Kaiser
@ 2022-06-02 19:37 ` Martin Kaiser
  2022-06-02 19:37 ` [PATCH 04/11] staging: r8188eu: use ieee80211 to set addba resp capabilities Martin Kaiser
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Martin Kaiser @ 2022-06-02 19:37 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 struct to set the addba response timeout. Copy the timeout
from the saved addba request. The timeout field is already le16, we don't
have to convert the endianness.

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 f97a22395ce4..de2a1e8b1a65 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5456,7 +5456,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);
-		pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&pmlmeinfo->ADDBA_req.BA_timeout_value, &pattrib->pktlen);
+		mgmt->u.action.u.addba_resp.timeout = pmlmeinfo->ADDBA_req.BA_timeout_value;
+		pattrib->pktlen += 2;
 		break;
 	case WLAN_ACTION_DELBA:
 		mgmt->u.action.u.delba.action_code = WLAN_ACTION_DELBA;
-- 
2.30.2


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

* [PATCH 04/11] staging: r8188eu: use ieee80211 to set addba resp capabilities
  2022-06-02 19:37 [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Martin Kaiser
                   ` (2 preceding siblings ...)
  2022-06-02 19:37 ` [PATCH 03/11] staging: r8188eu: use mgmt to set the addba resp timeout Martin Kaiser
@ 2022-06-02 19:37 ` Martin Kaiser
  2022-06-02 19:37 ` [PATCH 05/11] staging: r8188eu: calculate the addba response length Martin Kaiser
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Martin Kaiser @ 2022-06-02 19:37 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 response.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index de2a1e8b1a65..b391273969af 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5446,16 +5446,11 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		pattrib->pktlen++;
 		mgmt->u.action.u.addba_resp.status = cpu_to_le16(status);
 		pattrib->pktlen += 2;
-		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);
+		capab = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f;
+		capab |= u16_encode_bits(64, IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK);
+		capab |= u16_encode_bits(pregpriv->ampdu_amsdu, IEEE80211_ADDBA_PARAM_AMSDU_MASK);
+		mgmt->u.action.u.addba_req.capab = cpu_to_le16(capab);
+		pattrib->pktlen += 2;
 		mgmt->u.action.u.addba_resp.timeout = pmlmeinfo->ADDBA_req.BA_timeout_value;
 		pattrib->pktlen += 2;
 		break;
-- 
2.30.2


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

* [PATCH 05/11] staging: r8188eu: calculate the addba response length
  2022-06-02 19:37 [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Martin Kaiser
                   ` (3 preceding siblings ...)
  2022-06-02 19:37 ` [PATCH 04/11] staging: r8188eu: use ieee80211 to set addba resp capabilities Martin Kaiser
@ 2022-06-02 19:37 ` Martin Kaiser
  2022-06-02 19:37 ` [PATCH 06/11] staging: r8188eu: use mgmt to set the delba reason code Martin Kaiser
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Martin Kaiser @ 2022-06-02 19:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

An addba response always ends with the timeout field. The length of the
addba response is the offset of the end of the timeout field 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 response components.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index b391273969af..2a13546e585c 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5441,18 +5441,14 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		break;
 	case WLAN_ACTION_ADDBA_RESP:
 		mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP;
-		pattrib->pktlen++;
 		mgmt->u.action.u.addba_resp.dialog_token = pmlmeinfo->ADDBA_req.dialog_token;
-		pattrib->pktlen++;
 		mgmt->u.action.u.addba_resp.status = cpu_to_le16(status);
-		pattrib->pktlen += 2;
 		capab = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f;
 		capab |= u16_encode_bits(64, IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK);
 		capab |= u16_encode_bits(pregpriv->ampdu_amsdu, IEEE80211_ADDBA_PARAM_AMSDU_MASK);
 		mgmt->u.action.u.addba_req.capab = cpu_to_le16(capab);
-		pattrib->pktlen += 2;
 		mgmt->u.action.u.addba_resp.timeout = pmlmeinfo->ADDBA_req.BA_timeout_value;
-		pattrib->pktlen += 2;
+		pattrib->pktlen = offsetofend(struct ieee80211_mgmt, u.action.u.addba_resp.timeout);
 		break;
 	case WLAN_ACTION_DELBA:
 		mgmt->u.action.u.delba.action_code = WLAN_ACTION_DELBA;
-- 
2.30.2


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

* [PATCH 06/11] staging: r8188eu: use mgmt to set the delba reason code
  2022-06-02 19:37 [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Martin Kaiser
                   ` (4 preceding siblings ...)
  2022-06-02 19:37 ` [PATCH 05/11] staging: r8188eu: calculate the addba response length Martin Kaiser
@ 2022-06-02 19:37 ` Martin Kaiser
  2022-06-02 19:37 ` [PATCH 07/11] staging: r8188eu: use mgmt to set delba params Martin Kaiser
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Martin Kaiser @ 2022-06-02 19:37 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 struct to set the delba reason code.

Replace the numeric value with a define and remove the temporary variable.

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 2a13546e585c..97bc5a968a84 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5367,7 +5367,6 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 {
 	u16 start_seq;
 	u16 BA_para_set;
-	u16 reason_code;
 	__le16	le_tmp;
 	u16 BA_starting_seqctrl = 0;
 	struct xmit_frame *pmgntframe;
@@ -5457,9 +5456,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);
 
-		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);
+		mgmt->u.action.u.delba.reason_code = cpu_to_le16(WLAN_STATUS_REQUEST_DECLINED);
+		pattrib->pktlen += 2;
 		break;
 	default:
 		break;
-- 
2.30.2


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

* [PATCH 07/11] staging: r8188eu: use mgmt to set delba params
  2022-06-02 19:37 [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Martin Kaiser
                   ` (5 preceding siblings ...)
  2022-06-02 19:37 ` [PATCH 06/11] staging: r8188eu: use mgmt to set the delba reason code Martin Kaiser
@ 2022-06-02 19:37 ` Martin Kaiser
  2022-06-02 19:37 ` [PATCH 08/11] staging: r8188eu: clarify the contents of the " Martin Kaiser
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Martin Kaiser @ 2022-06-02 19:37 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 struct to set the delba parameters. Use the exact same value
for the parameters as the current code.

Remove a dead increment of pframe, we don't use pframe for the delba
message any more.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 97bc5a968a84..b4d22dae212a 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5366,8 +5366,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)
 {
 	u16 start_seq;
-	u16 BA_para_set;
-	__le16	le_tmp;
 	u16 BA_starting_seqctrl = 0;
 	struct xmit_frame *pmgntframe;
 	struct pkt_attrib *pattrib;
@@ -5403,7 +5401,6 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	mgmt->seq_ctrl = cpu_to_le16(pmlmeext->mgnt_seq);
 	pmlmeext->mgnt_seq++;
 
-	pframe += sizeof(struct ieee80211_hdr_3addr);
 	pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
 
 	mgmt->u.action.category = WLAN_CATEGORY_BACK;
@@ -5452,10 +5449,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	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);
-
+		mgmt->u.action.u.delba.params = cpu_to_le16((status & 0x1F) << 3);
+		pattrib->pktlen += 2;
 		mgmt->u.action.u.delba.reason_code = cpu_to_le16(WLAN_STATUS_REQUEST_DECLINED);
 		pattrib->pktlen += 2;
 		break;
-- 
2.30.2


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

* [PATCH 08/11] staging: r8188eu: clarify the contents of the delba params
  2022-06-02 19:37 [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Martin Kaiser
                   ` (6 preceding siblings ...)
  2022-06-02 19:37 ` [PATCH 07/11] staging: r8188eu: use mgmt to set delba params Martin Kaiser
@ 2022-06-02 19:37 ` Martin Kaiser
  2022-06-02 19:37 ` [PATCH 09/11] staging: r8188eu: calculate the delba length Martin Kaiser
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Martin Kaiser @ 2022-06-02 19:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

The delba parameters field contains an initiator/receiver flag and the
tid. The caller of issue_action_BA passes these components in the status
parameter.

Extract the two components from status and use u16_encode_bits to copy
them into the parameters field. This should clarify what's going on and
should make it easier to replace the status parameter in the future.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index b4d22dae212a..7968674a0705 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5377,7 +5377,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;
+	u16 capab, params;
 
 	pmgntframe = alloc_mgtxmitframe(pxmitpriv);
 	if (!pmgntframe)
@@ -5450,6 +5450,9 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		mgmt->u.action.u.delba.action_code = WLAN_ACTION_DELBA;
 		pattrib->pktlen++;
 		mgmt->u.action.u.delba.params = cpu_to_le16((status & 0x1F) << 3);
+		params = u16_encode_bits((status & 0x1), IEEE80211_DELBA_PARAM_INITIATOR_MASK);
+		params |= u16_encode_bits((status >> 1) & 0xF, IEEE80211_DELBA_PARAM_TID_MASK);
+		mgmt->u.action.u.delba.params = cpu_to_le16(params);
 		pattrib->pktlen += 2;
 		mgmt->u.action.u.delba.reason_code = cpu_to_le16(WLAN_STATUS_REQUEST_DECLINED);
 		pattrib->pktlen += 2;
-- 
2.30.2


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

* [PATCH 09/11] staging: r8188eu: calculate the delba length
  2022-06-02 19:37 [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Martin Kaiser
                   ` (7 preceding siblings ...)
  2022-06-02 19:37 ` [PATCH 08/11] staging: r8188eu: clarify the contents of the " Martin Kaiser
@ 2022-06-02 19:37 ` Martin Kaiser
  2022-06-02 19:37 ` [PATCH 10/11] staging: r8188eu: remove the pframe variable Martin Kaiser
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Martin Kaiser @ 2022-06-02 19:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use offsetofend to calculate the length of the delba message.

We are now calculating all message lengths based on the offset of their
last field. All intermediate updates of pattrib->pktlen can be removed.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 7968674a0705..565e447bb75e 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5401,10 +5401,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	mgmt->seq_ctrl = cpu_to_le16(pmlmeext->mgnt_seq);
 	pmlmeext->mgnt_seq++;
 
-	pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
 	mgmt->u.action.category = WLAN_CATEGORY_BACK;
-	pattrib->pktlen++;
 
 	switch (action) {
 	case WLAN_ACTION_ADDBA_REQ:
@@ -5448,14 +5445,12 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 		break;
 	case WLAN_ACTION_DELBA:
 		mgmt->u.action.u.delba.action_code = WLAN_ACTION_DELBA;
-		pattrib->pktlen++;
 		mgmt->u.action.u.delba.params = cpu_to_le16((status & 0x1F) << 3);
 		params = u16_encode_bits((status & 0x1), IEEE80211_DELBA_PARAM_INITIATOR_MASK);
 		params |= u16_encode_bits((status >> 1) & 0xF, IEEE80211_DELBA_PARAM_TID_MASK);
 		mgmt->u.action.u.delba.params = cpu_to_le16(params);
-		pattrib->pktlen += 2;
 		mgmt->u.action.u.delba.reason_code = cpu_to_le16(WLAN_STATUS_REQUEST_DECLINED);
-		pattrib->pktlen += 2;
+		pattrib->pktlen = offsetofend(struct ieee80211_mgmt, u.action.u.delba.reason_code);
 		break;
 	default:
 		break;
-- 
2.30.2


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

* [PATCH 10/11] staging: r8188eu: remove the pframe variable
  2022-06-02 19:37 [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Martin Kaiser
                   ` (8 preceding siblings ...)
  2022-06-02 19:37 ` [PATCH 09/11] staging: r8188eu: calculate the delba length Martin Kaiser
@ 2022-06-02 19:37 ` Martin Kaiser
  2022-06-02 19:37 ` [PATCH 11/11] staging: r8188eu: use u8, u16 in issue_action_BA prototype Martin Kaiser
  2022-06-05 16:03 ` [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Pavel Skripkin
  11 siblings, 0 replies; 13+ messages in thread
From: Martin Kaiser @ 2022-06-02 19:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Remove the pframe variable, it is no longer used for populating fields of
the outgoing frame.

pmgntframe->buf_addr is already a u8 *, we can drop the (u8 *) cast.

Increment the u8 *pmgntframe->buf_addr by TXDESC_OFFSET before we cast
it to struct ieee80211_mgmt *.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 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 565e447bb75e..c025f95defab 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5369,7 +5369,6 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 	u16 BA_starting_seqctrl = 0;
 	struct xmit_frame *pmgntframe;
 	struct pkt_attrib *pattrib;
-	u8 *pframe;
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
 	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
@@ -5389,8 +5388,7 @@ 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;
-	mgmt = (struct ieee80211_mgmt *)pframe;
+	mgmt = (struct ieee80211_mgmt *)(pmgntframe->buf_addr + TXDESC_OFFSET);
 
 	mgmt->frame_control = cpu_to_le16(IEEE80211_STYPE_ACTION | IEEE80211_FTYPE_MGMT);
 
-- 
2.30.2


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

* [PATCH 11/11] staging: r8188eu: use u8, u16 in issue_action_BA prototype
  2022-06-02 19:37 [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Martin Kaiser
                   ` (9 preceding siblings ...)
  2022-06-02 19:37 ` [PATCH 10/11] staging: r8188eu: remove the pframe variable Martin Kaiser
@ 2022-06-02 19:37 ` Martin Kaiser
  2022-06-05 16:03 ` [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Pavel Skripkin
  11 siblings, 0 replies; 13+ messages in thread
From: Martin Kaiser @ 2022-06-02 19:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser

Use u8 and u16 in the issue_action_BA prototype. The code expects these
parameters to be exactly 8 and 16 bits wide.

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

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index c025f95defab..1c1598c71b78 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -5363,7 +5363,7 @@ int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int
 	return ret;
 }
 
-void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short status)
+void issue_action_BA(struct adapter *padapter, unsigned char *raddr, u8 action, u16 status)
 {
 	u16 start_seq;
 	u16 BA_starting_seqctrl = 0;
diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
index 573d65b175cc..71864733b1c0 100644
--- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h
+++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
@@ -524,8 +524,7 @@ int issue_deauth(struct adapter *padapter, unsigned char *da,
 		 unsigned short reason);
 int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason,
 		    int try_cnt, int wait_ms);
-void issue_action_BA(struct adapter *padapter, unsigned char *raddr,
-		     unsigned char action, unsigned short status);
+void issue_action_BA(struct adapter *padapter, unsigned char *raddr, u8 action, u16 status);
 unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr);
 unsigned int send_beacon(struct adapter *padapter);
 bool get_beacon_valid_bit(struct adapter *adapter);
-- 
2.30.2


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

* Re: [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA
  2022-06-02 19:37 [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Martin Kaiser
                   ` (10 preceding siblings ...)
  2022-06-02 19:37 ` [PATCH 11/11] staging: r8188eu: use u8, u16 in issue_action_BA prototype Martin Kaiser
@ 2022-06-05 16:03 ` Pavel Skripkin
  11 siblings, 0 replies; 13+ messages in thread
From: Pavel Skripkin @ 2022-06-05 16:03 UTC (permalink / raw)
  To: Martin Kaiser, Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, linux-staging,
	linux-kernel

Hi Martin,

On 6/2/22 22:37, Martin Kaiser wrote:
> Simplify the code to send the addba response and the delba message. Use
> ieee80211 helpers if possible.
> 
> This series should be applied after the "start cleaning up
> issue_action_BA" series.
> 
> Martin Kaiser (11):
>    staging: r8188eu: use mgmt to set resp dialog token
>    staging: r8188eu: use mgmt to set the addba resp status
>    staging: r8188eu: use mgmt to set the addba resp timeout
>    staging: r8188eu: use ieee80211 to set addba resp capabilities
>    staging: r8188eu: calculate the addba response length
>    staging: r8188eu: use mgmt to set the delba reason code
>    staging: r8188eu: use mgmt to set delba params
>    staging: r8188eu: clarify the contents of the delba params
>    staging: r8188eu: calculate the delba length
>    staging: r8188eu: remove the pframe variable
>    staging: r8188eu: use u8, u16 in issue_action_BA prototype
> 
>   drivers/staging/r8188eu/core/rtw_mlme_ext.c   | 51 +++++++------------
>   .../staging/r8188eu/include/rtw_mlme_ext.h    |  3 +-
>   2 files changed, 18 insertions(+), 36 deletions(-)
> 

Looks fine, thanks!

Tested-by: Pavel Skripkin <paskripkin@gmail.com>




With regards,
Pavel Skripkin

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

end of thread, other threads:[~2022-06-05 16:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02 19:37 [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Martin Kaiser
2022-06-02 19:37 ` [PATCH 01/11] staging: r8188eu: use mgmt to set resp dialog token Martin Kaiser
2022-06-02 19:37 ` [PATCH 02/11] staging: r8188eu: use mgmt to set the addba resp status Martin Kaiser
2022-06-02 19:37 ` [PATCH 03/11] staging: r8188eu: use mgmt to set the addba resp timeout Martin Kaiser
2022-06-02 19:37 ` [PATCH 04/11] staging: r8188eu: use ieee80211 to set addba resp capabilities Martin Kaiser
2022-06-02 19:37 ` [PATCH 05/11] staging: r8188eu: calculate the addba response length Martin Kaiser
2022-06-02 19:37 ` [PATCH 06/11] staging: r8188eu: use mgmt to set the delba reason code Martin Kaiser
2022-06-02 19:37 ` [PATCH 07/11] staging: r8188eu: use mgmt to set delba params Martin Kaiser
2022-06-02 19:37 ` [PATCH 08/11] staging: r8188eu: clarify the contents of the " Martin Kaiser
2022-06-02 19:37 ` [PATCH 09/11] staging: r8188eu: calculate the delba length Martin Kaiser
2022-06-02 19:37 ` [PATCH 10/11] staging: r8188eu: remove the pframe variable Martin Kaiser
2022-06-02 19:37 ` [PATCH 11/11] staging: r8188eu: use u8, u16 in issue_action_BA prototype Martin Kaiser
2022-06-05 16:03 ` [PATCH 00/11] staging: r8188eu: continue the cleanup of issue_action_BA Pavel Skripkin

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.