This series simplifies the issue_probereq_ex function and fixes other
minor things.
Martin Kaiser (5):
staging: r8188eu: drop return value from issue_probereq_ex
staging: r8188eu: remove wait_ms parameter
staging: r8188eu: fix the number of probereq retries
staging: r8188eu: simplify the checks for zero address
staging: r8188eu: use ieee80211 helper for protected bit
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 30 ++++++-------------
drivers/staging/r8188eu/core/rtw_recv.c | 5 ++--
.../staging/r8188eu/include/rtw_mlme_ext.h | 3 +-
drivers/staging/r8188eu/include/wifi.h | 3 --
4 files changed, 12 insertions(+), 29 deletions(-)
--
2.30.2
issue_probereq_ex sends a probe request and retries if this fails. There's
no point in making the number of retries configurable. Hard-code the value
that's used by issue_probereq_ex's only caller.
Simplify the code to check the loop condition only once.
Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 21 +++++++------------
.../staging/r8188eu/include/rtw_mlme_ext.h | 3 +--
2 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 990336244030..667f54e313ef 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -4482,21 +4482,16 @@ inline void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps
_issue_probereq(padapter, pssid, da, false);
}
-void issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da,
- int try_cnt)
+void issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da)
{
- int ret;
- int i = 0;
-
- do {
- ret = _issue_probereq(padapter, pssid, da, true);
-
- i++;
+ int i;
- if (i < try_cnt && ret == _FAIL)
+ for (i = 0; i < 3; i++) {
+ if (_issue_probereq(padapter, pssid, da, true) == _FAIL)
msleep(1);
-
- } while ((i < try_cnt) && (ret == _FAIL));
+ else
+ break;
+ }
}
/* if psta == NULL, indicate we are station (client) now... */
@@ -7046,7 +7041,7 @@ void linked_status_chk(struct adapter *padapter)
}
if (rx_chk != _SUCCESS)
- issue_probereq_ex(padapter, &pmlmeinfo->network.Ssid, psta->hwaddr, 3);
+ issue_probereq_ex(padapter, &pmlmeinfo->network.Ssid, psta->hwaddr);
if ((tx_chk != _SUCCESS && pmlmeinfo->link_count++ == 0xf) || rx_chk != _SUCCESS) {
tx_chk = issue_nulldata(padapter, psta->hwaddr, 0, 3, 1);
diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
index 04fd673d3a04..089bd5446773 100644
--- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h
+++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
@@ -512,8 +512,7 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta,
unsigned short status);
void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid,
u8 *da);
-void issue_probereq_ex(struct adapter *adapter, struct ndis_802_11_ssid *pssid,
- u8 *da, int try_cnt);
+void issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da);
int issue_nulldata(struct adapter *padapter, unsigned char *da,
unsigned int power_mode, int try_cnt, int wait_ms);
int issue_qos_nulldata(struct adapter *padapter, unsigned char *da,
--
2.30.2
Use ieee80211_has_protected to check if the "protected" bit is set. Remove
the r8188eu driver's internal macro for this check.
Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 2 +-
drivers/staging/r8188eu/include/wifi.h | 3 ---
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 667f54e313ef..93696892ec7d 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -809,7 +809,7 @@ static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fram
if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE))
return;
- offset = (GetPrivacy(pframe)) ? 4 : 0;
+ offset = ieee80211_has_protected(hdr->frame_control) ? 4 : 0;
seq = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + offset + 2));
status = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + offset + 4));
diff --git a/drivers/staging/r8188eu/include/wifi.h b/drivers/staging/r8188eu/include/wifi.h
index 2381c519ceaf..254a4bc1a141 100644
--- a/drivers/staging/r8188eu/include/wifi.h
+++ b/drivers/staging/r8188eu/include/wifi.h
@@ -170,9 +170,6 @@ enum WIFI_REG_DOMAIN {
#define SetPrivacy(pbuf) \
*(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_)
-#define GetPrivacy(pbuf) \
- (((*(__le16 *)(pbuf)) & cpu_to_le16(_PRIVACY_)) != 0)
-
#define GetFrameType(pbuf) \
(le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(3) | BIT(2)))
--
2.30.2
In function ap2sta_data_frame, we can use is_zero_ether_addr to check for
all-zero ethernet addresses. Both pattrib->bssid and mybssid are 16-bit
aligned.
Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_recv.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
index 5b0a66aebff1..631c500dda42 100644
--- a/drivers/staging/r8188eu/core/rtw_recv.c
+++ b/drivers/staging/r8188eu/core/rtw_recv.c
@@ -779,9 +779,8 @@ static int ap2sta_data_frame(
}
/* check BSSID */
- if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
- !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
- (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) {
+ if (is_zero_ether_addr(pattrib->bssid) || is_zero_ether_addr(mybssid) ||
+ (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) {
if (!bmcast)
issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
--
2.30.2
The only caller of issue_probereq_ex does not check the return value. We
can remove it and make issue_probereq_ex a void function.
Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 11 ++---------
drivers/staging/r8188eu/include/rtw_mlme_ext.h | 4 ++--
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 161cb67f7882..2f3f7da08d0c 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -4482,8 +4482,8 @@ inline void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps
_issue_probereq(padapter, pssid, da, false);
}
-int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da,
- int try_cnt, int wait_ms)
+void issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da,
+ int try_cnt, int wait_ms)
{
int ret;
int i = 0;
@@ -4497,13 +4497,6 @@ int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid,
msleep(wait_ms);
} while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0)));
-
- if (ret != _FAIL) {
- ret = _SUCCESS;
- goto exit;
- }
-exit:
- return ret;
}
/* if psta == NULL, indicate we are station (client) now... */
diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
index c46fc1a53085..720610bc8fef 100644
--- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h
+++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
@@ -512,8 +512,8 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta,
unsigned short status);
void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid,
u8 *da);
-s32 issue_probereq_ex(struct adapter *adapter, struct ndis_802_11_ssid *pssid,
- u8 *da, int try_cnt, int wait_ms);
+void issue_probereq_ex(struct adapter *adapter, struct ndis_802_11_ssid *pssid,
+ u8 *da, int try_cnt, int wait_ms);
int issue_nulldata(struct adapter *padapter, unsigned char *da,
unsigned int power_mode, int try_cnt, int wait_ms);
int issue_qos_nulldata(struct adapter *padapter, unsigned char *da,
--
2.30.2
On 11/26/22 16:42, Martin Kaiser wrote:
> This series simplifies the issue_probereq_ex function and fixes other
> minor things.
>
> Martin Kaiser (5):
> staging: r8188eu: drop return value from issue_probereq_ex
> staging: r8188eu: remove wait_ms parameter
> staging: r8188eu: fix the number of probereq retries
> staging: r8188eu: simplify the checks for zero address
> staging: r8188eu: use ieee80211 helper for protected bit
>
> drivers/staging/r8188eu/core/rtw_mlme_ext.c | 30 ++++++-------------
> drivers/staging/r8188eu/core/rtw_recv.c | 5 ++--
> .../staging/r8188eu/include/rtw_mlme_ext.h | 3 +-
> drivers/staging/r8188eu/include/wifi.h | 3 --
> 4 files changed, 12 insertions(+), 29 deletions(-)
>
Tested-by: Philipp Hortmann <[email protected]> # Edimax N150