Here's another patch set with several cleanups throughout the driver.
Martin Kaiser (9):
staging: r8188eu: don't store addba request
staging: r8188eu: remove some obsolete comments
staging: r8188eu: reorder assignments, clarify the header format
staging: r8188eu: reformat a function header
staging: r8188eu: remove state checks in rtw_led_control
staging: r8188eu: clean up rtw_hal_init
staging: r8188eu: remove get_fwstate
staging: r8188eu: merge two rtw_free_network_nolock functions
staging: r8188eu: remove checks in dump_mgntframe
drivers/staging/r8188eu/core/rtw_led.c | 3 +-
drivers/staging/r8188eu/core/rtw_mlme.c | 23 ++++++---------
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 28 ++++++++-----------
drivers/staging/r8188eu/core/rtw_recv.c | 2 --
drivers/staging/r8188eu/hal/hal_intf.c | 19 +++++--------
.../staging/r8188eu/hal/rtl8188e_hal_init.c | 6 +---
drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c | 15 ++++------
drivers/staging/r8188eu/include/rtw_mlme.h | 7 -----
.../staging/r8188eu/include/rtw_mlme_ext.h | 4 +--
drivers/staging/r8188eu/include/wifi.h | 8 ------
10 files changed, 36 insertions(+), 79 deletions(-)
--
2.30.2
There's no need to store an incoming addba request in struct
mlme_ext_info. We only need the addba request to copy some of its fields
into our addba response.
It's simpler to pass the incoming request's management frame to
issue_action_BA as an additional parameter. issue_action_BA can then
extract the required fields. If issue_action_BA prepares a request rather
than a response, the caller sets the parameter for the incoming request to
NULL.
Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 25 ++++++++-----------
.../staging/r8188eu/include/rtw_mlme_ext.h | 4 +--
drivers/staging/r8188eu/include/wifi.h | 8 ------
3 files changed, 13 insertions(+), 24 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 6679d4037d6b..324757699716 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -1486,11 +1486,9 @@ static void OnAction_back(struct adapter *padapter, struct recv_frame *precv_fra
struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
struct sta_info *psta = NULL;
struct recv_reorder_ctrl *preorder_ctrl;
- unsigned char *frame_body;
unsigned short tid;
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
- u8 *pframe = precv_frame->rx_data;
struct sta_priv *pstapriv = &padapter->stapriv;
if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
@@ -1501,23 +1499,19 @@ static void OnAction_back(struct adapter *padapter, struct recv_frame *precv_fra
if (!psta)
return;
- frame_body = (unsigned char *)(pframe + sizeof(struct ieee80211_hdr_3addr));
-
if (!pmlmeinfo->HT_enable)
return;
/* All union members start with an action code, it's ok to use addba_req. */
switch (mgmt->u.action.u.addba_req.action_code) {
case WLAN_ACTION_ADDBA_REQ:
- memcpy(&pmlmeinfo->ADDBA_req, &frame_body[2], sizeof(struct ADDBA_request));
tid = u16_get_bits(le16_to_cpu(mgmt->u.action.u.addba_req.capab),
IEEE80211_ADDBA_PARAM_TID_MASK);
preorder_ctrl = &psta->recvreorder_ctrl[tid];
preorder_ctrl->indicate_seq = 0xffff;
preorder_ctrl->enable = pmlmeinfo->bAcceptAddbaReq;
-
issue_action_BA(padapter, mgmt->sa, WLAN_ACTION_ADDBA_RESP,
pmlmeinfo->bAcceptAddbaReq ?
- WLAN_STATUS_SUCCESS : WLAN_STATUS_REQUEST_DECLINED);
+ WLAN_STATUS_SUCCESS : WLAN_STATUS_REQUEST_DECLINED, mgmt);
break;
case WLAN_ACTION_ADDBA_RESP:
tid = u16_get_bits(le16_to_cpu(mgmt->u.action.u.addba_resp.capab),
@@ -5377,7 +5371,8 @@ 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, u8 action, u16 status)
+void issue_action_BA(struct adapter *padapter, unsigned char *raddr, u8 action,
+ u16 status, struct ieee80211_mgmt *mgmt_req)
{
u16 start_seq;
u16 BA_starting_seqctrl = 0;
@@ -5446,13 +5441,13 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, u8 action,
break;
case WLAN_ACTION_ADDBA_RESP:
mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP;
- mgmt->u.action.u.addba_resp.dialog_token = pmlmeinfo->ADDBA_req.dialog_token;
+ mgmt->u.action.u.addba_resp.dialog_token = mgmt_req->u.action.u.addba_req.dialog_token;
mgmt->u.action.u.addba_resp.status = cpu_to_le16(status);
- capab = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f;
+ capab = le16_to_cpu(mgmt_req->u.action.u.addba_req.capab) & 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);
- mgmt->u.action.u.addba_resp.timeout = pmlmeinfo->ADDBA_req.BA_timeout_value;
+ mgmt->u.action.u.addba_resp.timeout = mgmt_req->u.action.u.addba_req.timeout;
pattrib->pktlen = offsetofend(struct ieee80211_mgmt, u.action.u.addba_resp.timeout);
break;
case WLAN_ACTION_DELBA:
@@ -5620,7 +5615,8 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr)
if (initiator == 0) { /* recipient */
for (tid = 0; tid < MAXTID; tid++) {
if (psta->recvreorder_ctrl[tid].enable) {
- issue_action_BA(padapter, addr, WLAN_ACTION_DELBA, (((tid << 1) | initiator) & 0x1F));
+ issue_action_BA(padapter, addr, WLAN_ACTION_DELBA,
+ (((tid << 1) | initiator) & 0x1F), NULL);
psta->recvreorder_ctrl[tid].enable = false;
psta->recvreorder_ctrl[tid].indicate_seq = 0xffff;
}
@@ -5628,7 +5624,8 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr)
} else if (initiator == 1) { /* originator */
for (tid = 0; tid < MAXTID; tid++) {
if (psta->htpriv.agg_enable_bitmap & BIT(tid)) {
- issue_action_BA(padapter, addr, WLAN_ACTION_DELBA, (((tid << 1) | initiator) & 0x1F));
+ issue_action_BA(padapter, addr, WLAN_ACTION_DELBA,
+ (((tid << 1) | initiator) & 0x1F), NULL);
psta->htpriv.agg_enable_bitmap &= ~BIT(tid);
psta->htpriv.candidate_tid_bitmap &= ~BIT(tid);
}
@@ -7683,7 +7680,7 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf)
if (((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && (pmlmeinfo->HT_enable)) ||
((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) {
- issue_action_BA(padapter, pparm->addr, WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid);
+ issue_action_BA(padapter, pparm->addr, WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid, NULL);
_set_timer(&psta->addba_retry_timer, ADDBA_TO);
} else {
psta->htpriv.candidate_tid_bitmap &= ~BIT(pparm->tid);
diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
index e234a3b9af6f..a519a3dcdf61 100644
--- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h
+++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
@@ -285,7 +285,6 @@ struct mlme_ext_info {
u8 bwmode_updated;
u8 hidden_ssid_mode;
- struct ADDBA_request ADDBA_req;
struct WMM_para_element WMM_param;
struct HT_caps_element HT_caps;
struct HT_info_element HT_info;
@@ -523,7 +522,8 @@ 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, u8 action, u16 status);
+void issue_action_BA(struct adapter *padapter, unsigned char *raddr, u8 action,
+ u16 status, struct ieee80211_mgmt *mgmt_req);
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);
diff --git a/drivers/staging/r8188eu/include/wifi.h b/drivers/staging/r8188eu/include/wifi.h
index 92a584a8b6c0..2381c519ceaf 100644
--- a/drivers/staging/r8188eu/include/wifi.h
+++ b/drivers/staging/r8188eu/include/wifi.h
@@ -430,14 +430,6 @@ struct WMM_para_element {
struct AC_param ac_param[4];
} __packed;
-struct ADDBA_request {
- unsigned char action_code;
- unsigned char dialog_token;
- __le16 BA_para_set;
- __le16 BA_timeout_value;
- __le16 BA_starting_seqctrl;
-} __packed;
-
#define MAX_AMPDU_FACTOR_64K 3
/* Spatial Multiplexing Power Save Modes */
--
2.30.2
Remove obsolete comments in validate_recv_data_frame.
There is no prxcmd variable (any more?).
Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_recv.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
index 94f85cd7038d..cb0f35d7ab98 100644
--- a/drivers/staging/r8188eu/core/rtw_recv.c
+++ b/drivers/staging/r8188eu/core/rtw_recv.c
@@ -1065,8 +1065,6 @@ static int validate_recv_data_frame(struct adapter *adapter,
if (!psta)
return _FAIL;
- /* psta->rssi = prxcmd->rssi; */
- /* psta->signal_quality = prxcmd->sq; */
precv_frame->psta = psta;
pattrib->amsdu = 0;
--
2.30.2
The definition of Hal_EfuseParseIDCode88E can be a single line.
Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index cc29963f4b49..73855bca76fe 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -676,11 +676,7 @@ s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy)
return status;
}
-void
-Hal_EfuseParseIDCode88E(
- struct adapter *padapter,
- u8 *hwinfo
- )
+void Hal_EfuseParseIDCode88E(struct adapter *padapter, u8 *hwinfo)
{
struct eeprom_priv *pEEPROM = &padapter->eeprompriv;
struct net_device *netdev = padapter->pnetdev;
--
2.30.2
Reorder some of the assignments in update_recvframe_attrib_88e.
This should make it a bit easier to understand the format of the header
that is added by the chip's firmware.
Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c
index 9a61eef8550b..d1ac2960f1c4 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c
@@ -66,28 +66,25 @@ void update_recvframe_attrib_88e(struct recv_frame *precvframe, struct recv_stat
if (pattrib->pkt_rpt_type == NORMAL_RX) {
pattrib->pkt_len = le32_to_cpu(prxstat->rxdw0) & 0x00003fff;
+ pattrib->icv_err = (le32_to_cpu(prxstat->rxdw0) >> 15) & 0x1;
pattrib->drvinfo_sz = ((le32_to_cpu(prxstat->rxdw0) >> 16) & 0xf) * 8;
-
+ pattrib->encrypt = (u8)((le32_to_cpu(prxstat->rxdw0) >> 20) & 0x7);
+ pattrib->qos = (le32_to_cpu(prxstat->rxdw0) >> 23) & 0x1;
+ pattrib->shift_sz = (le32_to_cpu(prxstat->rxdw0) >> 24) & 0x3;
pattrib->physt = (le32_to_cpu(prxstat->rxdw0) >> 26) & 0x1;
-
pattrib->bdecrypted = (le32_to_cpu(prxstat->rxdw0) & BIT(27)) ? 0 : 1;
- pattrib->encrypt = (le32_to_cpu(prxstat->rxdw0) >> 20) & 0x7;
- pattrib->qos = (le32_to_cpu(prxstat->rxdw0) >> 23) & 0x1;
pattrib->priority = (le32_to_cpu(prxstat->rxdw1) >> 8) & 0xf;
-
pattrib->amsdu = (le32_to_cpu(prxstat->rxdw1) >> 13) & 0x1;
+ pattrib->mdata = (le32_to_cpu(prxstat->rxdw1) >> 26) & 0x1;
+ pattrib->mfrag = (le32_to_cpu(prxstat->rxdw1) >> 27) & 0x1;
pattrib->seq_num = le32_to_cpu(prxstat->rxdw2) & 0x00000fff;
pattrib->frag_num = (le32_to_cpu(prxstat->rxdw2) >> 12) & 0xf;
- pattrib->mfrag = (le32_to_cpu(prxstat->rxdw1) >> 27) & 0x1;
- pattrib->mdata = (le32_to_cpu(prxstat->rxdw1) >> 26) & 0x1;
pattrib->mcs_rate = le32_to_cpu(prxstat->rxdw3) & 0x3f;
pattrib->rxht = (le32_to_cpu(prxstat->rxdw3) >> 6) & 0x1;
- pattrib->icv_err = (le32_to_cpu(prxstat->rxdw0) >> 15) & 0x1;
- pattrib->shift_sz = (le32_to_cpu(prxstat->rxdw0) >> 24) & 0x3;
} else if (pattrib->pkt_rpt_type == TX_REPORT1) { /* CCX */
pattrib->pkt_len = TX_RPT1_PKT_LEN;
} else if (pattrib->pkt_rpt_type == TX_REPORT2) {
--
2.30.2
Clean up the rtw_hal_init function.
Remove the status variable. Exit immediately for errors.
Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/hal_intf.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/r8188eu/hal/hal_intf.c b/drivers/staging/r8188eu/hal/hal_intf.c
index 37935aef71ea..13790e32f11c 100644
--- a/drivers/staging/r8188eu/hal/hal_intf.c
+++ b/drivers/staging/r8188eu/hal/hal_intf.c
@@ -6,24 +6,19 @@
#include "../include/drv_types.h"
#include "../include/hal_intf.h"
-uint rtw_hal_init(struct adapter *adapt)
+uint rtw_hal_init(struct adapter *adapt)
{
- uint status = _SUCCESS;
-
adapt->hw_init_completed = false;
- status = rtl8188eu_hal_init(adapt);
+ if (rtl8188eu_hal_init(adapt) != _SUCCESS)
+ return _FAIL;
- if (status == _SUCCESS) {
- adapt->hw_init_completed = true;
+ adapt->hw_init_completed = true;
- if (adapt->registrypriv.notch_filter == 1)
- hal_notch_filter_8188e(adapt, 1);
- } else {
- adapt->hw_init_completed = false;
- }
+ if (adapt->registrypriv.notch_filter == 1)
+ hal_notch_filter_8188e(adapt, 1);
- return status;
+ return _SUCCESS;
}
uint rtw_hal_deinit(struct adapter *adapt)
--
2.30.2
There's no need to check for bSurpriseRemoved and bDriverStopped in
dump_mgmtframe.
The sequence of function calls is
dump_mgntframe
rtl8188eu_mgnt_xmit
rtw_dump_xframe
loop over all fragments
For each fragment, rtw_write_port is called. This function checks
bSurpriseRemoved and bDriverStopped.
Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 324757699716..17803aca83c8 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -3959,9 +3959,6 @@ void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattri
void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe)
{
- if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
- return;
-
rtl8188eu_mgnt_xmit(padapter, pmgntframe);
}
--
2.30.2
The get_fwstate function is not used. Remove it.
Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/include/rtw_mlme.h | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/staging/r8188eu/include/rtw_mlme.h b/drivers/staging/r8188eu/include/rtw_mlme.h
index ca539c652f26..268f898b151b 100644
--- a/drivers/staging/r8188eu/include/rtw_mlme.h
+++ b/drivers/staging/r8188eu/include/rtw_mlme.h
@@ -443,11 +443,6 @@ static inline bool check_fwstate(struct mlme_priv *pmlmepriv, int state)
return false;
}
-static inline int get_fwstate(struct mlme_priv *pmlmepriv)
-{
- return pmlmepriv->fw_state;
-}
-
/*
* No Limit on the calling context,
* therefore set it to be the critical section...
--
2.30.2
There's no need to check for bSurpriseRemoved or bDriverStopped in the
rtw_led_control function. This function schedules a delayed worker which
calls SwLedOn or SwLedOff (or the function calls SwLedOff directly).
SwLedOn and SwLedOff check bDriverStopped themselves or they initiate a
USB control transfer via usb_write, where bSurpriseRemoved is checked.
Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_led.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c
index ce8de2eb7845..48725ce9d369 100644
--- a/drivers/staging/r8188eu/core/rtw_led.c
+++ b/drivers/staging/r8188eu/core/rtw_led.c
@@ -140,8 +140,7 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)
struct registry_priv *registry_par;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
- if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped) ||
- (!padapter->hw_init_completed))
+ if (!padapter->hw_init_completed)
return;
if (!pLed->bRegUseLed)
--
2.30.2
On 11/6/22 13:48, Martin Kaiser wrote:
> Here's another patch set with several cleanups throughout the driver.
>
> Martin Kaiser (9):
> staging: r8188eu: don't store addba request
> staging: r8188eu: remove some obsolete comments
> staging: r8188eu: reorder assignments, clarify the header format
> staging: r8188eu: reformat a function header
> staging: r8188eu: remove state checks in rtw_led_control
> staging: r8188eu: clean up rtw_hal_init
> staging: r8188eu: remove get_fwstate
> staging: r8188eu: merge two rtw_free_network_nolock functions
> staging: r8188eu: remove checks in dump_mgntframe
>
> drivers/staging/r8188eu/core/rtw_led.c | 3 +-
> drivers/staging/r8188eu/core/rtw_mlme.c | 23 ++++++---------
> drivers/staging/r8188eu/core/rtw_mlme_ext.c | 28 ++++++++-----------
> drivers/staging/r8188eu/core/rtw_recv.c | 2 --
> drivers/staging/r8188eu/hal/hal_intf.c | 19 +++++--------
> .../staging/r8188eu/hal/rtl8188e_hal_init.c | 6 +---
> drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c | 15 ++++------
> drivers/staging/r8188eu/include/rtw_mlme.h | 7 -----
> .../staging/r8188eu/include/rtw_mlme_ext.h | 4 +--
> drivers/staging/r8188eu/include/wifi.h | 8 ------
> 10 files changed, 36 insertions(+), 79 deletions(-)
>
Tested-by: Philipp Hortmann <[email protected]> # Edimax N150