From patchwork Fri Dec 30 18:06:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 37736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3008474wrt; Fri, 30 Dec 2022 10:08:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXvY/0jVKPZ9XYakKBa+ogT0BToe1rUm7zMVwP8fD85RzXzOsseHATYwadzRTx3L+5VIqp3T X-Received: by 2002:a17:90a:f614:b0:219:672a:42db with SMTP id bw20-20020a17090af61400b00219672a42dbmr40971128pjb.19.1672423706609; Fri, 30 Dec 2022 10:08:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672423706; cv=none; d=google.com; s=arc-20160816; b=nRep3Oql3vPFO46gQbJFM4LqxfoDaMZFSix+pO5wgLK2WrIYYQTtbiW+meb0ShNQQ1 nDZHrFM8SzrfmHRlDhTcF2P3u87GxTHLqG0PZMkTLfl0UZ1GYh30HnZ+3j1QWXd1v8RR ahsEAShEI+E5NQ2syT4ZiWf6HFQyk8tkPqUDhqdDHSLmCZSb4eTDDwN1Qj3ZEqwyDfID zh5Jr4Uceqt5k3t9thzX3/CrBvdp5zM65wqPweWlfs5DGotWcX5z1f2VKG/snu6fu30e D0Glhxo0bN5axY4WkxB+PAEOlu19EE9IHbYGlQWFfZ1HCVIOAx/VKk3UBWVYKVlvXEU4 D1mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=5BadzVsgoO/PFohDV9+kmnVIe5Rv18qTamlfEvg46DY=; b=gfXyb0cSMXQyKZQxIXJUQmqFOth2wVkuNfrthjPPkCMA2y7WiVEM9uePb1TEmWGlXk S2/fPzaNF6kkGrCj8iStAQcdsMrhigmwM4f6GDk3rL089NdWnwYHE+CdBMBPY8GhMHq8 fAvl9I+sQ3tN7tXRjU/jbGAIxmDK4yU2Ie4hOe6X6s4nlnKq/gCg9ZIew2Yt/pWfqe8S E3oYuq3v3Hxwlrq8h6bTV+7sYJxgUN/LpuimXIvN0k7JSiwuGkIBOeqClNXdzDwPH9V0 4l9CyP6zB/ovl/rKWDbS4Yb8UD5I/s2v4ytTYmkr9NUon5uP4mfoltXjI4THbZsfrdtx NwWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h22-20020a17090adb9600b001f06a6fdb2fsi24729152pjv.27.2022.12.30.10.08.14; Fri, 30 Dec 2022 10:08:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235503AbiL3SHm (ORCPT + 99 others); Fri, 30 Dec 2022 13:07:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235438AbiL3SHU (ORCPT ); Fri, 30 Dec 2022 13:07:20 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 723801C42C for ; Fri, 30 Dec 2022 10:07:18 -0800 (PST) Received: from dslb-188-097-208-179.188.097.pools.vodafone-ip.de ([188.97.208.179] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1pBJmj-0004rR-4g; Fri, 30 Dec 2022 19:07:13 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 09/20] staging: r8188eu: simplify frame type check Date: Fri, 30 Dec 2022 19:06:35 +0100 Message-Id: <20221230180646.91008-10-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221230180646.91008-1-martin@kaiser.cx> References: <20221230180646.91008-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753663360428713253?= X-GMAIL-MSGID: =?utf-8?q?1753663360428713253?= Reorder the code in rtw_make_wlanhdr to make the function simpler. There's a large if statement to check that we process only data frames. Revert the condition and exit for non-data frames. Signed-off-by: Martin Kaiser --- drivers/staging/r8188eu/core/rtw_xmit.c | 139 ++++++++++++------------ 1 file changed, 70 insertions(+), 69 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 2bccb9ca42e9..502f9a6f4250 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -809,90 +809,91 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr SetFrameSubType(fctrl, pattrib->subtype); - if (pattrib->subtype & IEEE80211_FTYPE_DATA) { - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - /* to_ds = 1, fr_ds = 0; */ - /* Data transfer to AP */ - SetToDs(fctrl); - memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv), ETH_ALEN); - memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); - memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN); - - if (pqospriv->qos_option) - qos_option = true; - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - /* to_ds = 0, fr_ds = 1; */ - SetFrDs(fctrl); - memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); - memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN); - memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN); - - if (psta->qos_option) - qos_option = true; - } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { - memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); - memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); - memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN); - - if (psta->qos_option) - qos_option = true; - } else { - res = _FAIL; - goto exit; - } + if (!(pattrib->subtype & IEEE80211_FTYPE_DATA)) + return _SUCCESS; + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + /* to_ds = 1, fr_ds = 0; */ + /* Data transfer to AP */ + SetToDs(fctrl); + memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv), ETH_ALEN); + memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); + memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN); + + if (pqospriv->qos_option) + qos_option = true; + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + /* to_ds = 0, fr_ds = 1; */ + SetFrDs(fctrl); + memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); + memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN); - if (pattrib->mdata) - SetMData(fctrl); + if (psta->qos_option) + qos_option = true; + } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { + memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); + memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); + memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN); - if (pattrib->encrypt) - SetPrivacy(fctrl); + if (psta->qos_option) + qos_option = true; + } else { + res = _FAIL; + goto exit; + } - if (qos_option) { - qc = (unsigned short *)(hdr + pattrib->hdrlen - 2); + if (pattrib->mdata) + SetMData(fctrl); - if (pattrib->priority) - SetPriority(qc, pattrib->priority); + if (pattrib->encrypt) + SetPrivacy(fctrl); - SetEOSP(qc, pattrib->eosp); + if (qos_option) { + qc = (unsigned short *)(hdr + pattrib->hdrlen - 2); - SetAckpolicy(qc, pattrib->ack_policy); - } + if (pattrib->priority) + SetPriority(qc, pattrib->priority); - /* TODO: fill HT Control Field */ + SetEOSP(qc, pattrib->eosp); - /* Update Seq Num will be handled by f/w */ - if (psta) { - psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; - psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF; + SetAckpolicy(qc, pattrib->ack_policy); + } - pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority]; + /* TODO: fill HT Control Field */ - SetSeqNum(hdr, pattrib->seqnum); + /* Update Seq Num will be handled by f/w */ + if (psta) { + psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; + psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF; - /* check if enable ampdu */ - if (pattrib->ht_en && psta->htpriv.ampdu_enable) { - if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority)) - pattrib->ampdu_en = true; - } + pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority]; - /* re-check if enable ampdu by BA_starting_seqctrl */ - if (pattrib->ampdu_en) { - u16 tx_seq; + SetSeqNum(hdr, pattrib->seqnum); - tx_seq = psta->BA_starting_seqctrl[pattrib->priority & 0x0f]; + /* check if enable ampdu */ + if (pattrib->ht_en && psta->htpriv.ampdu_enable) { + if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority)) + pattrib->ampdu_en = true; + } - /* check BA_starting_seqctrl */ - if (SN_LESS(pattrib->seqnum, tx_seq)) { - pattrib->ampdu_en = false;/* AGG BK */ - } else if (SN_EQUAL(pattrib->seqnum, tx_seq)) { - psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq + 1) & 0xfff; + /* re-check if enable ampdu by BA_starting_seqctrl */ + if (pattrib->ampdu_en) { + u16 tx_seq; - pattrib->ampdu_en = true;/* AGG EN */ - } else { - psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum + 1) & 0xfff; - pattrib->ampdu_en = true;/* AGG EN */ - } + tx_seq = psta->BA_starting_seqctrl[pattrib->priority & 0x0f]; + + /* check BA_starting_seqctrl */ + if (SN_LESS(pattrib->seqnum, tx_seq)) { + pattrib->ampdu_en = false;/* AGG BK */ + } else if (SN_EQUAL(pattrib->seqnum, tx_seq)) { + psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq + 1) & 0xfff; + + pattrib->ampdu_en = true;/* AGG EN */ + } else { + psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum + 1) & 0xfff; + pattrib->ampdu_en = true;/* AGG EN */ } } }