Skip to contentSkip to conversation

staging: r8188eu: clean up mlme handlers

PATCH In review Martin Kaiser 2 participants 19 messages Oct 24, 2022 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: r8188eu: clean up mlme handlers

This series cleans up the mlme handlers that process incoming management frames.

We can reorder the handler functions and remove forward declarations. We can also remove unused return values and simplify the error handling.

This series should be applied after the "some more small cleanups" series.

As usual, this series was tested with EdimaxV2 on an arm32 system.

Martin Kaiser (17):
staging: r8188eu: restructure mlme subfunction handling
staging: r8188eu: make OnAssocReq static
staging: r8188eu: make OnAssocRsp static
staging: r8188eu: make OnProbeReq static
staging: r8188eu: make OnProbeRsp static
staging: r8188eu: make OnBeacon static
staging: r8188eu: make OnDisassoc static
staging: r8188eu: make OnAuthClient static
staging: r8188eu: make OnDeAuth static
staging: r8188eu: make OnAction static
staging: r8188eu: make OnAuth static
staging: r8188eu: change mlme handlers to void
staging: r8188eu: remove unnecessary label
staging: r8188eu: remove unnecessary else branch
staging: r8188eu: remove unnecessary return
staging: r8188eu: remove an else branch
staging: r8188eu: go2asoc is not needed

 drivers/staging/r8188eu/core/rtw_mlme_ext.c   | 226 ++++++++----------
 .../staging/r8188eu/include/rtw_mlme_ext.h    |  23 +-
 2 files changed, 100 insertions(+), 149 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/17 staging: r8188eu: restructure mlme subfunction handling

Move some code around in rtw_mlme_ext.c to make it simpler.

mlme_sta_tbl is used only by mgt_dispatcher. Move the table inside the function. Move mgt_dispatcher behind the handler functions. We can then make the handler functions static.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 116 ++++++++++----------
 1 file changed, 57 insertions(+), 59 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +57 -59
index d44e455f09ca..15b7148fa898 100644
@@ -12,24 +12,6 @@
 #include "../include/rtl8188e_xmit.h"
 #include "../include/rtl8188e_dm.h"
 
-/* response function for each management frame subtype, do not reorder */
-static mlme_handler mlme_sta_tbl[] = {
-	OnAssocReq,
-	OnAssocRsp,
-	OnAssocReq,
-	OnAssocRsp,
-	OnProbeReq,
-	OnProbeRsp,
-	NULL,
-	NULL,
-	OnBeacon,
-	NULL,
-	OnDisassoc,
-	OnAuthClient,
-	OnDeAuth,
-	OnAction,
-};
-
 static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0};
 
 /**************************************************
@@ -393,47 +375,6 @@ void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext)
 	}
 }
 
-void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-	int index;
-	mlme_handler fct;
-	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
-	struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, hdr->addr2);
-
-	if (!ieee80211_is_mgmt(hdr->frame_control))
-		return;
-
-	/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
-	if (memcmp(hdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN) &&
-	    !is_broadcast_ether_addr(hdr->addr1))
-		return;
-
-	index = (le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE) >> 4;
-	if (index >= ARRAY_SIZE(mlme_sta_tbl))
-		return;
-	fct = mlme_sta_tbl[index];
-
-	if (psta) {
-		if (ieee80211_has_retry(hdr->frame_control)) {
-			if (precv_frame->attrib.seq_num == psta->RxMgmtFrameSeqNum)
-				/* drop the duplicate management frame */
-				return;
-		}
-		psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num;
-	}
-
-	if (ieee80211_is_auth(hdr->frame_control)) {
-		if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
-			fct = OnAuth;
-		else
-			fct = OnAuthClient;
-	}
-
-	if (fct)
-		fct(padapter, precv_frame);
-}
-
 static u32 p2p_listen_state_process(struct adapter *padapter, unsigned char *da)
 {
 	bool response = true;
@@ -4004,6 +3945,63 @@ struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv)
 	return pmgntframe;
 }
 
+void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)
+{
+	mlme_handler mlme_sta_tbl[] = {
+		OnAssocReq,
+		OnAssocRsp,
+		OnAssocReq,
+		OnAssocRsp,
+		OnProbeReq,
+		OnProbeRsp,
+		NULL,
+		NULL,
+		OnBeacon,
+		NULL,
+		OnDisassoc,
+		OnAuthClient,
+		OnDeAuth,
+		OnAction,
+	};
+	int index;
+	mlme_handler fct;
+	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
+	struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, hdr->addr2);
+
+	if (!ieee80211_is_mgmt(hdr->frame_control))
+		return;
+
+	/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
+	if (memcmp(hdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN) &&
+	    !is_broadcast_ether_addr(hdr->addr1))
+		return;
+
+	index = (le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE) >> 4;
+	if (index >= ARRAY_SIZE(mlme_sta_tbl))
+		return;
+	fct = mlme_sta_tbl[index];
+
+	if (psta) {
+		if (ieee80211_has_retry(hdr->frame_control)) {
+			if (precv_frame->attrib.seq_num == psta->RxMgmtFrameSeqNum)
+				/* drop the duplicate management frame */
+				return;
+		}
+		psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num;
+	}
+
+	if (ieee80211_is_auth(hdr->frame_control)) {
+		if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
+			fct = OnAuth;
+		else
+			fct = OnAuthClient;
+	}
+
+	if (fct)
+		fct(padapter, precv_frame);
+}
+
 /****************************************************************************
 
 Following are some TX functions for WiFi MLME
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/17 staging: r8188eu: make OnAssocReq static

In reply to Martin Kaiser

OnAssocReq is used only in rtw_mlme_ext.c. Make this function static.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c    | 2 +-
 drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +1 -1
index 15b7148fa898..4e7d9a273fe4 100644
@@ -911,7 +911,7 @@ static void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen)
 	}
 }
 
-unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	u16 capab_info;
 	struct rtw_ieee802_11_elems elems;
drivers/staging/r8188eu/include/rtw_mlme_ext.h +0 -2
index 66aa8b497aa1..41e31cec9abe 100644
@@ -536,8 +536,6 @@ void start_clnt_auth(struct adapter *padapter);
 void start_clnt_join(struct adapter *padapter);
 void start_create_ibss(struct adapter *padapter);
 
-unsigned int OnAssocReq(struct adapter *padapter,
-			struct recv_frame *precv_frame);
 unsigned int OnAssocRsp(struct adapter *padapter,
 			struct recv_frame *precv_frame);
 unsigned int OnProbeReq(struct adapter *padapter,
Signature · 1 line
2.30.2
#3 lore raw

PATCH 3/17 staging: r8188eu: make OnAssocRsp static

In reply to Martin Kaiser

OnAssocRsp is used only in rtw_mlme_ext.c. Make this function static.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c    | 2 +-
 drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +1 -1
index 4e7d9a273fe4..0b46da9de47c 100644
@@ -1319,7 +1319,7 @@ static unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *prec
 	return _FAIL;
 }
 
-unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
 	uint i;
drivers/staging/r8188eu/include/rtw_mlme_ext.h +0 -2
index 41e31cec9abe..c2b1aa2f378b 100644
@@ -536,8 +536,6 @@ void start_clnt_auth(struct adapter *padapter);
 void start_clnt_join(struct adapter *padapter);
 void start_create_ibss(struct adapter *padapter);
 
-unsigned int OnAssocRsp(struct adapter *padapter,
-			struct recv_frame *precv_frame);
 unsigned int OnProbeReq(struct adapter *padapter,
 			struct recv_frame *precv_frame);
 unsigned int OnProbeRsp(struct adapter *padapter,
Signature · 1 line
2.30.2
#4 lore raw

PATCH 4/17 staging: r8188eu: make OnProbeReq static

In reply to Martin Kaiser

OnProbeReq is used only in rtw_mlme_ext.c. Make this function static.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c    | 2 +-
 drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +1 -1
index 0b46da9de47c..4a0bea5f5052 100644
@@ -447,7 +447,7 @@ Following are the callback functions for each subtype of the management frames
 
 *****************************************************************************/
 
-unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	unsigned int	ielen;
 	unsigned char	*p;
drivers/staging/r8188eu/include/rtw_mlme_ext.h +0 -2
index c2b1aa2f378b..b24aae8108b6 100644
@@ -536,8 +536,6 @@ void start_clnt_auth(struct adapter *padapter);
 void start_clnt_join(struct adapter *padapter);
 void start_create_ibss(struct adapter *padapter);
 
-unsigned int OnProbeReq(struct adapter *padapter,
-			struct recv_frame *precv_frame);
 unsigned int OnProbeRsp(struct adapter *padapter,
 			struct recv_frame *precv_frame);
 unsigned int OnBeacon(struct adapter *padapter,
Signature · 1 line
2.30.2
#5 lore raw

PATCH 5/17 staging: r8188eu: make OnProbeRsp static

In reply to Martin Kaiser

OnProbeRsp is used only in rtw_mlme_ext.c. Make this function static.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c    | 2 +-
 drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +1 -1
index 4a0bea5f5052..797c843de616 100644
@@ -515,7 +515,7 @@ static unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *prec
 	return _SUCCESS;
 }
 
-unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	struct mlme_ext_priv	*pmlmeext = &padapter->mlmeextpriv;
 	struct wifidirect_info	*pwdinfo = &padapter->wdinfo;
drivers/staging/r8188eu/include/rtw_mlme_ext.h +0 -2
index b24aae8108b6..52991ec7b3e8 100644
@@ -536,8 +536,6 @@ void start_clnt_auth(struct adapter *padapter);
 void start_clnt_join(struct adapter *padapter);
 void start_create_ibss(struct adapter *padapter);
 
-unsigned int OnProbeRsp(struct adapter *padapter,
-			struct recv_frame *precv_frame);
 unsigned int OnBeacon(struct adapter *padapter,
 		      struct recv_frame *precv_frame);
 unsigned int OnDisassoc(struct adapter *padapter,
Signature · 1 line
2.30.2
#6 lore raw

PATCH 6/17 staging: r8188eu: make OnBeacon static

In reply to Martin Kaiser

OnBeacon is used only in rtw_mlme_ext.c. Make this function static.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c    | 2 +-
 drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +1 -1
index 797c843de616..07ed3d704c2d 100644
@@ -561,7 +561,7 @@ static unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *prec
 	return _SUCCESS;
 }
 
-unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	int cam_idx;
 	struct sta_info	*psta;
drivers/staging/r8188eu/include/rtw_mlme_ext.h +0 -2
index 52991ec7b3e8..b4868598eba8 100644
@@ -536,8 +536,6 @@ void start_clnt_auth(struct adapter *padapter);
 void start_clnt_join(struct adapter *padapter);
 void start_create_ibss(struct adapter *padapter);
 
-unsigned int OnBeacon(struct adapter *padapter,
-		      struct recv_frame *precv_frame);
 unsigned int OnDisassoc(struct adapter *padapter,
 			struct recv_frame *precv_frame);
 unsigned int OnAuth(struct adapter *padapter,
Signature · 1 line
2.30.2
#7 lore raw

PATCH 7/17 staging: r8188eu: make OnDisassoc static

In reply to Martin Kaiser

OnDisassoc is used only in rtw_mlme_ext.c. Make this function static.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c    | 2 +-
 drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +1 -1
index 07ed3d704c2d..dc836e5878d1 100644
@@ -1458,7 +1458,7 @@ unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame)
 	return _SUCCESS;
 }
 
-unsigned int OnDisassoc(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnDisassoc(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	u16 reason;
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
drivers/staging/r8188eu/include/rtw_mlme_ext.h +0 -2
index b4868598eba8..c1bc554202a0 100644
@@ -536,8 +536,6 @@ void start_clnt_auth(struct adapter *padapter);
 void start_clnt_join(struct adapter *padapter);
 void start_create_ibss(struct adapter *padapter);
 
-unsigned int OnDisassoc(struct adapter *padapter,
-			struct recv_frame *precv_frame);
 unsigned int OnAuth(struct adapter *padapter,
 		    struct recv_frame *precv_frame);
 unsigned int OnAuthClient(struct adapter *padapter,
Signature · 1 line
2.30.2
#8 lore raw

PATCH 8/17 staging: r8188eu: make OnAuthClient static

In reply to Martin Kaiser

OnAuthClient is used only in rtw_mlme_ext.c. Make this function static.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c    | 2 +-
 drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +1 -1
index dc836e5878d1..7c9ca0c71b65 100644
@@ -800,7 +800,7 @@ unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame)
 	return _FAIL;
 }
 
-unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	unsigned int	seq, len, status, offset;
 	unsigned char	*p;
drivers/staging/r8188eu/include/rtw_mlme_ext.h +0 -2
index c1bc554202a0..866d358f5f10 100644
@@ -538,8 +538,6 @@ void start_create_ibss(struct adapter *padapter);
 
 unsigned int OnAuth(struct adapter *padapter,
 		    struct recv_frame *precv_frame);
-unsigned int OnAuthClient(struct adapter *padapter,
-			  struct recv_frame *precv_frame);
 unsigned int OnDeAuth(struct adapter *padapter,
 		      struct recv_frame *precv_frame);
 unsigned int OnAction(struct adapter *padapter,
Signature · 1 line
2.30.2
#9 lore raw

PATCH 9/17 staging: r8188eu: make OnDeAuth static

In reply to Martin Kaiser

OnDeAuth is used only in rtw_mlme_ext.c. Make this function static.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c    | 2 +-
 drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +1 -1
index 7c9ca0c71b65..6c97df6f88fe 100644
@@ -1396,7 +1396,7 @@ static unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *prec
 	return _SUCCESS;
 }
 
-unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
 	unsigned short	reason;
drivers/staging/r8188eu/include/rtw_mlme_ext.h +0 -2
index 866d358f5f10..14df83574478 100644
@@ -538,8 +538,6 @@ void start_create_ibss(struct adapter *padapter);
 
 unsigned int OnAuth(struct adapter *padapter,
 		    struct recv_frame *precv_frame);
-unsigned int OnDeAuth(struct adapter *padapter,
-		      struct recv_frame *precv_frame);
 unsigned int OnAction(struct adapter *padapter,
 		      struct recv_frame *precv_frame);
 
Signature · 1 line
2.30.2
#10 lore raw

PATCH 10/17 staging: r8188eu: make OnAction static

In reply to Martin Kaiser

OnAction is used only in rtw_mlme_ext.c. Make this function static.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c    | 2 +-
 drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +1 -1
index 6c97df6f88fe..08f193781776 100644
@@ -3906,7 +3906,7 @@ unsigned int OnAction_p2p(struct adapter *padapter, struct recv_frame *precv_fra
 	return _SUCCESS;
 }
 
-unsigned int OnAction(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnAction(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
 
drivers/staging/r8188eu/include/rtw_mlme_ext.h +0 -2
index 14df83574478..f192733a5c53 100644
@@ -538,8 +538,6 @@ void start_create_ibss(struct adapter *padapter);
 
 unsigned int OnAuth(struct adapter *padapter,
 		    struct recv_frame *precv_frame);
-unsigned int OnAction(struct adapter *padapter,
-		      struct recv_frame *precv_frame);
 
 unsigned int OnAction_back(struct adapter *padapter,
 			   struct recv_frame *precv_frame);
Signature · 1 line
2.30.2
#11 lore raw

PATCH 11/17 staging: r8188eu: make OnAuth static

In reply to Martin Kaiser

OnAuth is used only in rtw_mlme_ext.c. Make this function static.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c    | 2 +-
 drivers/staging/r8188eu/include/rtw_mlme_ext.h | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +1 -1
index 08f193781776..34b41931fb66 100644
@@ -651,7 +651,7 @@ static unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_
 	return _SUCCESS;
 }
 
-unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	unsigned int	auth_mode, ie_len;
 	u16 seq;
drivers/staging/r8188eu/include/rtw_mlme_ext.h +0 -3
index f192733a5c53..f77e6dc81831 100644
@@ -536,9 +536,6 @@ void start_clnt_auth(struct adapter *padapter);
 void start_clnt_join(struct adapter *padapter);
 void start_create_ibss(struct adapter *padapter);
 
-unsigned int OnAuth(struct adapter *padapter,
-		    struct recv_frame *precv_frame);
-
 unsigned int OnAction_back(struct adapter *padapter,
 			   struct recv_frame *precv_frame);
 unsigned int on_action_public(struct adapter *padapter,
Signature · 1 line
2.30.2
#12 lore raw

PATCH 12/17 staging: r8188eu: change mlme handlers to void

In reply to Martin Kaiser

The mlme handlers that are called from mgt_dispatcher return an error code. mgt_dispatcher doesn't check this error code, we can remove it and change the handler functions to void.

For now, make only the minimum changes to the handlers for removing the error codes. If handlers can be simplified, that'll be done it separate patches.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c   | 93 ++++++++-----------
 .../staging/r8188eu/include/rtw_mlme_ext.h    |  2 +-
 2 files changed, 41 insertions(+), 54 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +40 -53
index 34b41931fb66..074c95f76e27 100644
@@ -447,7 +447,7 @@ Following are the callback functions for each subtype of the management frames
 
 *****************************************************************************/
 
-static unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame)
+static void OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	unsigned int	ielen;
 	unsigned char	*p;
@@ -481,17 +481,17 @@ static unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *prec
 				report_survey_event(padapter, precv_frame);
 				p2p_listen_state_process(padapter,  get_sa(pframe));
 
-				return _SUCCESS;
+				return;
 			}
 		}
 	}
 
 	if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
-		return _SUCCESS;
+		return;
 
 	if (!check_fwstate(pmlmepriv, _FW_LINKED) &&
 	    !check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE))
-		return _SUCCESS;
+		return;
 
 	p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ielen,
 			len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_);
@@ -503,7 +503,7 @@ static unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *prec
 
 		if ((ielen != 0 && memcmp((void *)(p + 2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) ||
 		    (ielen == 0 && pmlmeinfo->hidden_ssid_mode))
-			return _SUCCESS;
+			return;
 
 _issue_probersp:
 
@@ -512,10 +512,9 @@ static unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *prec
 		    check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)))
 			issue_probersp(padapter, get_sa(pframe), is_valid_p2p_probereq);
 	}
-	return _SUCCESS;
 }
 
-static unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame)
+static void OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	struct mlme_ext_priv	*pmlmeext = &padapter->mlmeextpriv;
 	struct wifidirect_info	*pwdinfo = &padapter->wdinfo;
@@ -537,7 +536,7 @@ static unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *prec
 				}
 			}
 		}
-		return _SUCCESS;
+		return;
 	} else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) {
 		if (pwdinfo->nego_req_info.benable) {
 			if (!memcmp(pwdinfo->nego_req_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN)) {
@@ -555,13 +554,11 @@ static unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *prec
 	}
 	if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
 		report_survey_event(padapter, precv_frame);
-		return _SUCCESS;
+		return;
 	}
-
-	return _SUCCESS;
 }
 
-static unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame)
+static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	int cam_idx;
 	struct sta_info	*psta;
@@ -576,7 +573,7 @@ static unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_
 
 	if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
 		report_survey_event(padapter, precv_frame);
-		return _SUCCESS;
+		return;
 	}
 
 	if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) {
@@ -600,7 +597,7 @@ static unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_
 			/* start auth */
 			start_clnt_auth(padapter);
 
-			return _SUCCESS;
+			return;
 		}
 
 		if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) {
@@ -610,7 +607,7 @@ static unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_
 				if (!ret) {
 					receive_disconnect(padapter,
 							   pmlmeinfo->network.MacAddress, 0);
-					return _SUCCESS;
+					return;
 				}
 				/* update WMM, ERP in the beacon */
 				/* todo: the timer is used instead of the number of the beacon received */
@@ -629,12 +626,12 @@ static unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_
 				/* allocate a new CAM entry for IBSS station */
 				cam_idx = allocate_fw_sta_entry(padapter);
 				if (cam_idx == NUM_STA)
-					goto _END_ONBEACON_;
+					return;
 
 				/* get supported rate */
 				if (update_sta_support_rate(padapter, (pframe + WLAN_HDR_A3_LEN + _BEACON_IE_OFFSET_), (len - WLAN_HDR_A3_LEN - _BEACON_IE_OFFSET_), cam_idx) == _FAIL) {
 					pmlmeinfo->FW_sta_info[cam_idx].status = 0;
-					goto _END_ONBEACON_;
+					return;
 				}
 
 				/* update TSF Value */
@@ -645,13 +642,9 @@ static unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_
 			}
 		}
 	}
-
-_END_ONBEACON_:
-
-	return _SUCCESS;
 }
 
-static unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame)
+static void OnAuth(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	unsigned int	auth_mode, ie_len;
 	u16 seq;
@@ -668,7 +661,7 @@ static unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_fr
 	uint len = precv_frame->len;
 
 	if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
-		return _FAIL;
+		return;
 
 	sa = GetAddr2Ptr(pframe);
 
@@ -784,7 +777,7 @@ static unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_fr
 	if (pstat->state & WIFI_FW_AUTH_SUCCESS)
 		pstat->auth_seq = 0;
 
-	return _SUCCESS;
+	return;
 
 auth_fail:
 
@@ -797,10 +790,9 @@ static unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_fr
 	memcpy(pstat->hwaddr, sa, 6);
 
 	issue_auth(padapter, pstat, (unsigned short)status);
-	return _FAIL;
 }
 
-static unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *precv_frame)
+static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	unsigned int	seq, len, status, offset;
 	unsigned char	*p;
@@ -812,10 +804,10 @@ static unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *pr
 
 	/* check A1 matches or not */
 	if (memcmp(myid(&padapter->eeprompriv), get_da(pframe), ETH_ALEN))
-		return _SUCCESS;
+		return;
 
 	if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE))
-		return _SUCCESS;
+		return;
 
 	offset = (GetPrivacy(pframe)) ? 4 : 0;
 
@@ -848,7 +840,7 @@ static unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *pr
 			issue_auth(padapter, NULL, 0);
 			set_link_timer(pmlmeext, REAUTH_TO);
 
-			return _SUCCESS;
+			return;
 		} else {
 			/*  open system */
 			go2asoc = 1;
@@ -865,10 +857,10 @@ static unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *pr
 
 	if (go2asoc) {
 		start_clnt_assoc(padapter);
-		return _SUCCESS;
+		return;
 	}
 authclnt_fail:
-	return _FAIL;
+	return;
 }
 
 static void UpdateBrateTbl(u8 *mbrate)
@@ -911,7 +903,7 @@ static void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen)
 	}
 }
 
-static unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame)
+static void OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	u16 capab_info;
 	struct rtw_ieee802_11_elems elems;
@@ -937,7 +929,7 @@ static unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *prec
 	u32 p2pielen = 0;
 
 	if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
-		return _FAIL;
+		return;
 
 	frame_type = GetFrameSubType(pframe);
 	if (frame_type == WIFI_ASSOCREQ)
@@ -946,7 +938,7 @@ static unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *prec
 		ie_offset = _REASOCREQ_IE_OFFSET_;
 
 	if (pkt_len < IEEE80211_3ADDR_LEN + ie_offset)
-		return _FAIL;
+		return;
 
 	pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
 	if (pstat == (struct sta_info *)NULL) {
@@ -1300,13 +1292,13 @@ static unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *prec
 		report_add_sta_event(padapter, pstat->hwaddr, pstat->aid);
 	}
 
-	return _SUCCESS;
+	return;
 
 asoc_class2_error:
 
 	issue_deauth(padapter, (void *)GetAddr2Ptr(pframe), status);
 
-	return _FAIL;
+	return;
 
 OnAssocReqFail:
 
@@ -1316,10 +1308,10 @@ static unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *prec
 	else
 		issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP);
 
-	return _FAIL;
+	return;
 }
 
-static unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame)
+static void OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
 	uint i;
@@ -1333,13 +1325,13 @@ static unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *prec
 
 	/* check A1 matches or not */
 	if (memcmp(myid(&padapter->eeprompriv), mgmt->da, ETH_ALEN))
-		return _SUCCESS;
+		return;
 
 	if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE)))
-		return _SUCCESS;
+		return;
 
 	if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)
-		return _SUCCESS;
+		return;
 
 	_cancel_timer_ex(&pmlmeext->link_timer);
 
@@ -1392,11 +1384,9 @@ static unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *prec
 
 report_assoc_result:
 	report_join_res(padapter, res);
-
-	return _SUCCESS;
 }
 
-static unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame)
+static void OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
 	unsigned short	reason;
@@ -1406,7 +1396,7 @@ static unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_
 	struct wifidirect_info *pwdinfo = &padapter->wdinfo;
 
 	if (memcmp(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN))
-		return _SUCCESS;
+		return;
 
 	if (pwdinfo->rx_invitereq_info.scan_op_ch_only) {
 		_cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey);
@@ -1422,7 +1412,7 @@ static unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_
 
 		psta = rtw_get_stainfo(pstapriv, mgmt->sa);
 		if (!psta)
-			return _SUCCESS;
+			return;
 
 		spin_lock_bh(&pstapriv->asoc_list_lock);
 		if (!list_empty(&psta->asoc_list)) {
@@ -1455,10 +1445,9 @@ static unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_
 
 		pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
 	}
-	return _SUCCESS;
 }
 
-static unsigned int OnDisassoc(struct adapter *padapter, struct recv_frame *precv_frame)
+static void OnDisassoc(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	u16 reason;
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -1469,7 +1458,7 @@ static unsigned int OnDisassoc(struct adapter *padapter, struct recv_frame *prec
 
 	/* check A3 */
 	if (!(!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)))
-		return _SUCCESS;
+		return;
 
 	if (pwdinfo->rx_invitereq_info.scan_op_ch_only) {
 		_cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey);
@@ -1497,12 +1486,11 @@ static unsigned int OnDisassoc(struct adapter *padapter, struct recv_frame *prec
 			associated_clients_update(padapter, updated);
 		}
 
-		return _SUCCESS;
+		return;
 	} else {
 		receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
 	}
 	pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
-	return _SUCCESS;
 }
 
 unsigned int OnAction_back(struct adapter *padapter, struct recv_frame *precv_frame)
@@ -3906,7 +3894,7 @@ unsigned int OnAction_p2p(struct adapter *padapter, struct recv_frame *precv_fra
 	return _SUCCESS;
 }
 
-static unsigned int OnAction(struct adapter *padapter, struct recv_frame *precv_frame)
+static void OnAction(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
 
@@ -3921,7 +3909,6 @@ static unsigned int OnAction(struct adapter *padapter, struct recv_frame *precv_
 		OnAction_p2p(padapter, precv_frame);
 		break;
 	}
-	return _SUCCESS;
 }
 
 struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv)
drivers/staging/r8188eu/include/rtw_mlme_ext.h +1 -1
index f77e6dc81831..c8beaa927cba 100644
@@ -184,7 +184,7 @@ enum SCAN_STATE {
 	SCAN_STATE_MAX,
 };
 
-typedef unsigned int (*mlme_handler)(struct adapter *adapt, struct recv_frame *frame);
+typedef void (*mlme_handler)(struct adapter *adapt, struct recv_frame *frame);
 
 struct	ss_res {
 	int	state;
Signature · 1 line
2.30.2
#13 lore raw

PATCH 13/17 staging: r8188eu: remove unnecessary label

In reply to Martin Kaiser

Remove a label on OnAuthClient that just calls return. We can return directly instead of jumping to this label.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +4 -6
index 074c95f76e27..01fe5019b333 100644
@@ -823,7 +823,7 @@ static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fram
 		}
 
 		set_link_timer(pmlmeext, 1);
-		goto authclnt_fail;
+		return;
 	}
 
 	if (seq == 2) {
@@ -833,7 +833,7 @@ static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fram
 				pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_);
 
 			if (!p)
-				goto authclnt_fail;
+				return;
 
 			memcpy((void *)(pmlmeinfo->chg_txt), (void *)(p + 2), len);
 			pmlmeinfo->auth_seq = 3;
@@ -849,18 +849,16 @@ static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fram
 		if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
 			go2asoc = 1;
 		else
-			goto authclnt_fail;
+			return;
 	} else {
 		/*  this is also illegal */
-		goto authclnt_fail;
+		return;
 	}
 
 	if (go2asoc) {
 		start_clnt_assoc(padapter);
 		return;
 	}
-authclnt_fail:
-	return;
 }
 
 static void UpdateBrateTbl(u8 *mbrate)
Signature · 1 line
2.30.2
#14 lore raw

PATCH 14/17 staging: r8188eu: remove unnecessary else branch

In reply to Martin Kaiser

Remove an else branch in OnAuthClient that is not needed.

If we go into the else branch, go2asoc is 0. We can simply continue and the last if condition will be false.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +0 -3
index 01fe5019b333..3c6ea9912d7f 100644
@@ -850,9 +850,6 @@ static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fram
 			go2asoc = 1;
 		else
 			return;
-	} else {
-		/*  this is also illegal */
-		return;
 	}
 
 	if (go2asoc) {
Signature · 1 line
2.30.2
#15 lore raw

PATCH 15/17 staging: r8188eu: remove unnecessary return

In reply to Martin Kaiser

Remove a return statement at the end of a function.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +1 -3
index 3c6ea9912d7f..7120e015d1bd 100644
@@ -852,10 +852,8 @@ static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fram
 			return;
 	}
 
-	if (go2asoc) {
+	if (go2asoc)
 		start_clnt_assoc(padapter);
-		return;
-	}
 }
 
 static void UpdateBrateTbl(u8 *mbrate)
Signature · 1 line
2.30.2
#16 lore raw

PATCH 16/17 staging: r8188eu: remove an else branch

In reply to Martin Kaiser

If we go into this else branch, go2asoc is 0. We can continue to the end of the function. The final if condition will be false.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +0 -2
index 7120e015d1bd..77402e55f640 100644
@@ -848,8 +848,6 @@ static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fram
 	} else if (seq == 4) {
 		if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
 			go2asoc = 1;
-		else
-			return;
 	}
 
 	if (go2asoc)
Signature · 1 line
2.30.2
#17 lore raw

PATCH 17/17 staging: r8188eu: go2asoc is not needed

In reply to Martin Kaiser

Remove the go2asoc variable in OnAuthClient and call start_clnt_assoc directly. This makes the code a tiny bit shorter.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +2 -6
index 77402e55f640..ffb708f242e6 100644
@@ -796,7 +796,6 @@ static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fram
 {
 	unsigned int	seq, len, status, offset;
 	unsigned char	*p;
-	unsigned int	go2asoc = 0;
 	struct mlme_ext_priv	*pmlmeext = &padapter->mlmeextpriv;
 	struct mlme_ext_info	*pmlmeinfo = &pmlmeext->mlmext_info;
 	u8 *pframe = precv_frame->rx_data;
@@ -843,15 +842,12 @@ static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fram
 			return;
 		} else {
 			/*  open system */
-			go2asoc = 1;
+			start_clnt_assoc(padapter);
 		}
 	} else if (seq == 4) {
 		if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
-			go2asoc = 1;
+			start_clnt_assoc(padapter);
 	}
-
-	if (go2asoc)
-		start_clnt_assoc(padapter);
 }
 
 static void UpdateBrateTbl(u8 *mbrate)
Signature · 1 line
2.30.2
Tested-by on the v1 series
#18 lore raw
In reply to Martin Kaiser
Quoted 29 lines · Martin Kaiser

This series cleans up the mlme handlers that process incoming management frames.

We can reorder the handler functions and remove forward declarations. We can also remove unused return values and simplify the error handling.

This series should be applied after the "some more small cleanups" series.

As usual, this series was tested with EdimaxV2 on an arm32 system.

Martin Kaiser (17):
staging: r8188eu: restructure mlme subfunction handling
staging: r8188eu: make OnAssocReq static
staging: r8188eu: make OnAssocRsp static
staging: r8188eu: make OnProbeReq static
staging: r8188eu: make OnProbeRsp static
staging: r8188eu: make OnBeacon static
staging: r8188eu: make OnDisassoc static
staging: r8188eu: make OnAuthClient static
staging: r8188eu: make OnDeAuth static
staging: r8188eu: make OnAction static
staging: r8188eu: make OnAuth static
staging: r8188eu: change mlme handlers to void
staging: r8188eu: remove unnecessary label
staging: r8188eu: remove unnecessary else branch
staging: r8188eu: remove unnecessary return
staging: r8188eu: remove an else branch
staging: r8188eu: go2asoc is not needed

Quoted 4 lines
  drivers/staging/r8188eu/core/rtw_mlme_ext.c   | 226 ++++++++----------
  .../staging/r8188eu/include/rtw_mlme_ext.h    |  23 +-
  2 files changed, 100 insertions(+), 149 deletions(-)