Skip to contentSkip to conversation

staging: r8188eu: some more cleanups

PATCH In review Martin Kaiser 2 participants 7 messages Apr 13, 2022 – Apr 17, 2022 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: r8188eu: some more cleanups

Here's another set of simple cleanups in the code that handles incoming frames.

Martin Kaiser (4):
staging: r8188eu: use ieee80211 helper to read the qos tid
staging: r8188eu: merge _mgt_dispatcher into mgt_dispatcher
staging: r8188eu: use ieee80211 helpers in mgt_dispatcher
staging: r8188eu: pkt_newalloc is not used

 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 35 +++++++++------------
 drivers/staging/r8188eu/core/rtw_recv.c     |  3 +-
 drivers/staging/r8188eu/include/rtw_recv.h  |  1 -
 drivers/staging/r8188eu/include/wifi.h      |  2 --
 4 files changed, 16 insertions(+), 25 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/4 staging: r8188eu: use ieee80211 helper to read the qos tid

Replace the driver-specific GetPriority macro with ieee80211_get_tid, which does exactly the same thing.

---
 drivers/staging/r8188eu/core/rtw_recv.c | 2 +-
 drivers/staging/r8188eu/include/wifi.h  | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_recv.c +1 -1
index 91a6e0f035f4..16224476d18a 100644
@@ -978,7 +978,7 @@ static int validate_recv_data_frame(struct adapter *adapter,
 	pattrib->ack_policy = 0;
 	/* parsing QC field */
 	if (pattrib->qos) {
-		pattrib->priority = GetPriority((ptr + 24));
+		pattrib->priority = ieee80211_get_tid(hdr);
 		pattrib->ack_policy = GetAckpolicy((ptr + 24));
 		pattrib->amsdu = GetAMsdu((ptr + 24));
 		pattrib->hdrlen = 26;
drivers/staging/r8188eu/include/wifi.h +0 -2
index b26770e91fc0..0254310bdf44 100644
@@ -211,8 +211,6 @@ enum WIFI_REG_DOMAIN {
 #define SetPriority(pbuf, tid)	\
 	*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf)
 
-#define GetPriority(pbuf)	((le16_to_cpu(*(__le16 *)(pbuf))) & 0xf)
-
 #define SetEOSP(pbuf, eosp)	\
 		*(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4)
 
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/4 staging: r8188eu: merge _mgt_dispatcher into mgt_dispatcher

In reply to Martin Kaiser

All that the _mgt_dispatcher function does is to call a function from a function pointer. It's not worth having a separate function for this.

Merge _mgt_dispatcher into mgt_dispatcher.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 22 ++++++++-------------
 1 file changed, 8 insertions(+), 14 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +8 -14
index 66dd06371991..ba071de4c05c 100644
@@ -390,19 +390,6 @@ void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext)
 	}
 }
 
-static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptable, struct recv_frame *precv_frame)
-{
-	u8 *pframe = precv_frame->rx_data;
-
-	if (ptable->func) {
-	/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
-		if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) &&
-		    !is_broadcast_ether_addr(GetAddr1Ptr(pframe)))
-			return;
-		ptable->func(padapter, precv_frame);
-	}
-}
-
 void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)
 {
 	int index;
@@ -442,7 +429,14 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)
 		else
 			ptable->func = &OnAuthClient;
 	}
-	_mgt_dispatcher(padapter, ptable, precv_frame);
+
+	if (ptable->func) {
+	/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
+		if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) &&
+		    !is_broadcast_ether_addr(GetAddr1Ptr(pframe)))
+			return;
+		ptable->func(padapter, precv_frame);
+	}
 }
 
 static u32 p2p_listen_state_process(struct adapter *padapter, unsigned char *da)
Signature · 1 line
2.30.2
#3 lore raw

Re: [PATCH 2/4] staging: r8188eu: merge _mgt_dispatcher into mgt_dispatcher

Hi Martin,

Quoted 7 lines · Martin Kaiser

All that the _mgt_dispatcher function does is to call a function from a function pointer. It's not worth having a separate function for this.

Merge _mgt_dispatcher into mgt_dispatcher.

---

[code snip]

drivers/staging/r8188eu/core/rtw_mlme_ext.c void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) · line 440

Quoted 9 lines
drivers/staging/r8188eu/core/rtw_mlme_ext.c +8 -0
+
+	if (ptable->func) {
+	/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
+		if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) &&
+		    !is_broadcast_ether_addr(GetAddr1Ptr(pframe)))
+			return;
+		ptable->func(padapter, precv_frame);
+	}
  }

Looks like each mlme_sta_tbl element has func member initialized. I think, we can remove this check.

With regards,
Pavel Skripkin

#4 lore raw

Re: [PATCH 2/4] staging: r8188eu: merge _mgt_dispatcher into mgt_dispatcher

Hi Pavel,

Thus wrote Pavel Skripkin ([email protected]):

Quoted 11 lines · Martin Kaiser
Quoted 7 lines

All that the _mgt_dispatcher function does is to call a function from a function pointer. It's not worth having a separate function for this.

Merge _mgt_dispatcher into mgt_dispatcher.

---

[code snip]

Quoted 12 lines

drivers/staging/r8188eu/core/rtw_mlme_ext.c void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) · line 440

Quoted 9 lines
drivers/staging/r8188eu/core/rtw_mlme_ext.c +8 -0
+
+	if (ptable->func) {
+	/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
+		if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) &&
+		    !is_broadcast_ether_addr(GetAddr1Ptr(pframe)))
+			return;
+		ptable->func(padapter, precv_frame);
+	}
  }

Looks like each mlme_sta_tbl element has func member initialized. I think, we can remove this check.

I've just sent a series to refactor mgt_dispatcher.

All mlme_sta_tbl entries have a function pointer, but some of the point to a dummy function DoReserved. I guess we should use NULL and keep the check instead of calling a function that does nothing.

Best regards,
Martin

#5 lore raw

PATCH 3/4 staging: r8188eu: use ieee80211 helpers in mgt_dispatcher

In reply to Martin Kaiser

Use structs and functions from ieee80211.h in mgt_dispatcher to parse the incoming frame.

---
 drivers/staging/r8188eu/core/rtw_mlme_ext.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +9 -8
index ba071de4c05c..b6ee6a24930a 100644
@@ -396,14 +396,15 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)
 	struct mlme_handler *ptable;
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 	u8 *pframe = precv_frame->rx_data;
-	struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(pframe));
+	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
+	struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, hdr->addr2);
 
-	if (GetFrameType(pframe) != IEEE80211_FTYPE_MGMT)
+	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(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) &&
-	    !is_broadcast_ether_addr(GetAddr1Ptr(pframe)))
+	if (memcmp(hdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN) &&
+	    !is_broadcast_ether_addr(hdr->addr1))
 		return;
 
 	ptable = mlme_sta_tbl;
@@ -415,7 +416,7 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)
 	ptable += index;
 
 	if (psta) {
-		if (GetRetry(pframe)) {
+		if (ieee80211_has_retry(hdr->frame_control)) {
 			if (precv_frame->attrib.seq_num == psta->RxMgmtFrameSeqNum)
 				/* drop the duplicate management frame */
 				return;
@@ -423,7 +424,7 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)
 		psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num;
 	}
 
-	if (GetFrameSubType(pframe) == WIFI_AUTH) {
+	if (ieee80211_is_auth(hdr->frame_control)) {
 		if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
 			ptable->func = &OnAuth;
 		else
@@ -432,8 +433,8 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)
 
 	if (ptable->func) {
 	/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
-		if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) &&
-		    !is_broadcast_ether_addr(GetAddr1Ptr(pframe)))
+		if (memcmp(hdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN) &&
+		    !is_broadcast_ether_addr(hdr->addr1))
 			return;
 		ptable->func(padapter, precv_frame);
 	}
Signature · 1 line
2.30.2
#6 lore raw

PATCH 4/4 staging: r8188eu: pkt_newalloc is not used

In reply to Martin Kaiser

pkg_newalloc in struct recv_buf is not used. Remove it.

---
 drivers/staging/r8188eu/core/rtw_recv.c    | 1 -
 drivers/staging/r8188eu/include/rtw_recv.h | 1 -
 2 files changed, 2 deletions(-)
drivers/staging/r8188eu/core/rtw_recv.c +0 -1
index 16224476d18a..c1005ddaa249 100644
@@ -71,7 +71,6 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
 
 		list_add_tail(&precvframe->list, &precvpriv->free_recv_queue.queue);
 
-		precvframe->pkt_newalloc = NULL;
 		precvframe->pkt = NULL;
 
 		precvframe->len = 0;
drivers/staging/r8188eu/include/rtw_recv.h +0 -1
index 59b4773bc3c9..e57e48a51f17 100644
@@ -229,7 +229,6 @@ struct recv_buf {
 struct recv_frame {
 	struct list_head list;
 	struct sk_buff	 *pkt;
-	struct sk_buff	 *pkt_newalloc;
 	struct adapter  *adapter;
 	u8 fragcnt;
 	int frame_tag;
Signature · 1 line
2.30.2