Skip to contentSkip to conversation

staging: rtl8723bs: clean up xmit classifier and propagate errno

PATCH Superseded Hungyu Lin 1 participant 6 messages May 14 Staging

lore
Share & tools
lore

Hungyu Lin

author
#0 lore raw

v2 cover staging: rtl8723bs: clean up xmit classifier and propagate errno

v2:
- Clarify commit message for hal xmit path as suggested by Dan Carpenter
- None of the callers of rtw_hal_xmitframe_enqueue() check the return value, so they do not need to be updated

This series cleans up the xmit classifier path in rtl8723bs and converts the enqueue path to use standard errno-style return values.

The changes are split into small steps:
- simplify control flow
- make the helper static
- convert the helper to return errno
- propagate errno through the enqueue path
- propagate errno through the HAL layer

Hungyu Lin (5):
staging: rtl8723bs: simplify rtw_xmit_classifier control flow
staging: rtl8723bs: make rtw_xmit_classifier static
staging: rtl8723bs: convert rtw_xmit_classifier to return errno
staging: rtl8723bs: propagate errno through xmit enqueue path
staging: rtl8723bs: propagate errno through hal xmit path

 drivers/staging/rtl8723bs/core/rtw_xmit.c     | 84 +++++++++----------
 drivers/staging/rtl8723bs/hal/hal_intf.c      |  7 +-
 .../staging/rtl8723bs/hal/rtl8723bs_xmit.c    |  8 +-
 drivers/staging/rtl8723bs/include/hal_intf.h  |  2 +-
 drivers/staging/rtl8723bs/include/rtw_xmit.h  |  3 +-
 5 files changed, 52 insertions(+), 52 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 1/5 staging: rtl8723bs: simplify rtw_xmit_classifier control flow

Simplify rtw_xmit_classifier() by removing the exit label and using direct returns for error handling.

No functional change.

---
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/staging/rtl8723bs/core/rtw_xmit.c +3 -8
index 458e471535ad..72e5dddfee5d 100644
@@ -1874,16 +1874,13 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe)
 	struct tx_servq	*ptxservq;
 	struct pkt_attrib	*pattrib = &pxmitframe->attrib;
 	struct hw_xmit	*phwxmits =  padapter->xmitpriv.hwxmits;
-	signed int res = _SUCCESS;
 
 	psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
 	if (pattrib->psta != psta)
 		return _FAIL;
 
-	if (!psta) {
-		res = _FAIL;
-		goto exit;
-	}
+	if (!psta)
+		return _FAIL;
 
 	if (!(psta->state & _FW_LINKED))
 		return _FAIL;
@@ -1897,9 +1894,7 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe)
 	ptxservq->qcnt++;
 	phwxmits[ac_index].accnt++;
 
-exit:
-
-	return res;
+	return _SUCCESS;
 }
 
 void rtw_free_hwxmits(struct adapter *padapter)
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v2 2/5 staging: rtl8723bs: make rtw_xmit_classifier static

In reply to Hungyu Lin

The rtw_xmit_classifier() function is only used within rtw_xmit.c. Move it above its caller and make it static to limit its scope.

---
 drivers/staging/rtl8723bs/core/rtw_xmit.c    | 68 ++++++++++----------
 drivers/staging/rtl8723bs/include/rtw_xmit.h |  1 -
 2 files changed, 34 insertions(+), 35 deletions(-)
drivers/staging/rtl8723bs/core/rtw_xmit.c +34 -34
index 72e5dddfee5d..b3953bdedb04 100644
@@ -1821,6 +1821,40 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram
 	spin_unlock_bh(&pframequeue->lock);
 }
 
+/*
+ * Will enqueue pxmitframe to the proper queue,
+ * and indicate it to xx_pending list.....
+ */
+static s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe)
+{
+	u8 ac_index;
+	struct sta_info *psta;
+	struct tx_servq	*ptxservq;
+	struct pkt_attrib	*pattrib = &pxmitframe->attrib;
+	struct hw_xmit	*phwxmits =  padapter->xmitpriv.hwxmits;
+
+	psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
+	if (pattrib->psta != psta)
+		return _FAIL;
+
+	if (!psta)
+		return _FAIL;
+
+	if (!(psta->state & _FW_LINKED))
+		return _FAIL;
+
+	ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index));
+
+	if (list_empty(&ptxservq->tx_pending))
+		list_add_tail(&ptxservq->tx_pending, get_list_head(phwxmits[ac_index].sta_queue));
+
+	list_add_tail(&pxmitframe->list, get_list_head(&ptxservq->sta_pending));
+	ptxservq->qcnt++;
+	phwxmits[ac_index].accnt++;
+
+	return _SUCCESS;
+}
+
 s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe)
 {
 	if (rtw_xmit_classifier(padapter, pxmitframe) == _FAIL)
@@ -1863,40 +1897,6 @@ struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *
 	return ptxservq;
 }
 
-/*
- * Will enqueue pxmitframe to the proper queue,
- * and indicate it to xx_pending list.....
- */
-s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe)
-{
-	u8 ac_index;
-	struct sta_info *psta;
-	struct tx_servq	*ptxservq;
-	struct pkt_attrib	*pattrib = &pxmitframe->attrib;
-	struct hw_xmit	*phwxmits =  padapter->xmitpriv.hwxmits;
-
-	psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
-	if (pattrib->psta != psta)
-		return _FAIL;
-
-	if (!psta)
-		return _FAIL;
-
-	if (!(psta->state & _FW_LINKED))
-		return _FAIL;
-
-	ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index));
-
-	if (list_empty(&ptxservq->tx_pending))
-		list_add_tail(&ptxservq->tx_pending, get_list_head(phwxmits[ac_index].sta_queue));
-
-	list_add_tail(&pxmitframe->list, get_list_head(&ptxservq->sta_pending));
-	ptxservq->qcnt++;
-	phwxmits[ac_index].accnt++;
-
-	return _SUCCESS;
-}
-
 void rtw_free_hwxmits(struct adapter *padapter)
 {
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
drivers/staging/rtl8723bs/include/rtw_xmit.h +0 -1
index b0189a703d28..a2ff62182b97 100644
@@ -440,7 +440,6 @@ extern void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue
 struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, signed int up, u8 *ac);
 extern s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe);
 
-extern s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe);
 extern u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib);
 #define rtw_wlan_pkt_size(f) rtw_calculate_wlan_pkt_size_by_attribue(&f->attrib)
 extern s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe);
Signature · 1 line
2.34.1
author
#3 lore raw

PATCH v2 3/5 staging: rtl8723bs: convert rtw_xmit_classifier to return errno

In reply to Hungyu Lin

Convert rtw_xmit_classifier() to return 0 on success and negative error codes on failure.

Update the caller to check for non-zero return values and preserve the existing _FAIL/_SUCCESS semantics.

---
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/staging/rtl8723bs/core/rtw_xmit.c +9 -6
index b3953bdedb04..80f3dfaf793d 100644
@@ -1825,7 +1825,7 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram
  * Will enqueue pxmitframe to the proper queue,
  * and indicate it to xx_pending list.....
  */
-static s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe)
+static int rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe)
 {
 	u8 ac_index;
 	struct sta_info *psta;
@@ -1835,13 +1835,13 @@ static s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmi
 
 	psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
 	if (pattrib->psta != psta)
-		return _FAIL;
+		return -ENODEV;
 
 	if (!psta)
-		return _FAIL;
+		return -EINVAL;
 
 	if (!(psta->state & _FW_LINKED))
-		return _FAIL;
+		return -ENETDOWN;
 
 	ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index));
 
@@ -1852,12 +1852,15 @@ static s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmi
 	ptxservq->qcnt++;
 	phwxmits[ac_index].accnt++;
 
-	return _SUCCESS;
+	return 0;
 }
 
 s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe)
 {
-	if (rtw_xmit_classifier(padapter, pxmitframe) == _FAIL)
+	int res;
+
+	res = rtw_xmit_classifier(padapter, pxmitframe);
+	if (res)
 		return _FAIL;
 
 	return _SUCCESS;
Signature · 1 line
2.34.1
author
#4 lore raw

PATCH v2 4/5 staging: rtl8723bs: propagate errno through xmit enqueue path

In reply to Hungyu Lin

Propagate errno values from rtw_xmit_classifier() through rtw_xmitframe_enqueue(), and update the local enqueue caller to check for non-zero return values.

---
 drivers/staging/rtl8723bs/core/rtw_xmit.c      |  6 +++---
 drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 10 +++++-----
 drivers/staging/rtl8723bs/include/rtw_xmit.h   |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/staging/rtl8723bs/core/rtw_xmit.c +3 -3
index 80f3dfaf793d..054cb4c9d1de 100644
@@ -1855,15 +1855,15 @@ static int rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmi
 	return 0;
 }
 
-s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe)
+int rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe)
 {
 	int res;
 
 	res = rtw_xmit_classifier(padapter, pxmitframe);
 	if (res)
-		return _FAIL;
+		return res;
 
-	return _SUCCESS;
+	return 0;
 }
 
 struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, signed int up, u8 *ac)
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +5 -5
index a7f23335cdd9..ff82b6efefc7 100644
@@ -464,8 +464,8 @@ s32 rtl8723bs_mgnt_xmit(
  *Handle xmitframe(packet) come from rtw_xmit()
  *
  * Return:
- *true	dump packet directly ok
- *false	enqueue, temporary can't transmit packets to hardware
+ * true      dump packet directly ok
+ * false     enqueue, temporary can't transmit packets to hardware
  */
 s32 rtl8723bs_hal_xmit(
 	struct adapter *padapter, struct xmit_frame *pxmitframe
@@ -491,7 +491,7 @@ s32 rtl8723bs_hal_xmit(
 	spin_lock_bh(&pxmitpriv->lock);
 	err = rtw_xmitframe_enqueue(padapter, pxmitframe);
 	spin_unlock_bh(&pxmitpriv->lock);
-	if (err != _SUCCESS) {
+	if (err) {
 		rtw_free_xmitframe(pxmitpriv, pxmitframe);
 
 		pxmitpriv->tx_drop++;
@@ -511,7 +511,7 @@ s32	rtl8723bs_hal_xmitframe_enqueue(
 	s32 err;
 
 	err = rtw_xmitframe_enqueue(padapter, pxmitframe);
-	if (err != _SUCCESS) {
+	if (err) {
 		rtw_free_xmitframe(pxmitpriv, pxmitframe);
 
 		pxmitpriv->tx_drop++;
@@ -519,7 +519,7 @@ s32	rtl8723bs_hal_xmitframe_enqueue(
 		complete(&pxmitpriv->SdioXmitStart);
 	}
 
-	return err;
+	return err ? _FAIL : _SUCCESS;
 
 }
 
drivers/staging/rtl8723bs/include/rtw_xmit.h +1 -1
index a2ff62182b97..b13f16716e98 100644
@@ -438,7 +438,7 @@ struct xmit_frame *rtw_alloc_xmitframe_once(struct xmit_priv *pxmitpriv);
 extern s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitframe);
 extern void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pframequeue);
 struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, signed int up, u8 *ac);
-extern s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe);
+int rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe);
 
 extern u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib);
 #define rtw_wlan_pkt_size(f) rtw_calculate_wlan_pkt_size_by_attribue(&f->attrib)
Signature · 1 line
2.34.1
author
#5 lore raw

PATCH v2 5/5 staging: rtl8723bs: propagate errno through hal xmit path

In reply to Hungyu Lin

Propagate errno values from rtl8723bs_hal_xmitframe_enqueue() through rtw_hal_xmitframe_enqueue() by returning the error code directly.

Update rtw_hal_xmit() to explicitly map the boolean return value of rtl8723bs_hal_xmit() to _SUCCESS/_FAIL, clarifying the return semantics at the HAL boundary.

None of the callers of rtw_hal_xmitframe_enqueue() check the return value, so they do not need to be updated. This change does not affect runtime behavior.

---
v2:
- Clarify commit message per Dan Carpenter's review

 drivers/staging/rtl8723bs/hal/hal_intf.c       | 7 +++++--
 drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 2 +-
 drivers/staging/rtl8723bs/include/hal_intf.h   | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/hal/hal_intf.c +5 -2
index 03f23b75d532..77fa6e67530a 100644
@@ -99,14 +99,17 @@ u8 rtw_hal_check_ips_status(struct adapter *padapter)
 	return CheckIPSStatus(padapter);
 }
 
-s32	rtw_hal_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe)
+int rtw_hal_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe)
 {
 	return rtl8723bs_hal_xmitframe_enqueue(padapter, pxmitframe);
 }
 
 s32	rtw_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe)
 {
-	return rtl8723bs_hal_xmit(padapter, pxmitframe);
+	if (rtl8723bs_hal_xmit(padapter, pxmitframe))
+		return _FAIL;
+
+	return _SUCCESS;
 }
 
 /*
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +1 -1
index ff82b6efefc7..ea7c9f4ac0f4 100644
@@ -519,7 +519,7 @@ s32	rtl8723bs_hal_xmitframe_enqueue(
 		complete(&pxmitpriv->SdioXmitStart);
 	}
 
-	return err ? _FAIL : _SUCCESS;
+	return err;
 
 }
 
drivers/staging/rtl8723bs/include/hal_intf.h +1 -1
index 9b000681ff80..ee8ad26325b5 100644
@@ -195,7 +195,7 @@ void rtw_hal_set_odm_var(struct adapter *padapter, enum hal_odm_variable eVariab
 
 u8 rtw_hal_check_ips_status(struct adapter *padapter);
 
-s32	rtw_hal_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe);
+int rtw_hal_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe);
 s32	rtw_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe);
 s32	rtw_hal_mgnt_xmit(struct adapter *padapter, struct xmit_frame *pmgntframe);
 
Signature · 1 line
2.34.1