Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp7556234rwl; Fri, 30 Dec 2022 10:09:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXsiJXeXY9n6ZW+QiTjss11vKUdU07xi5D6eTPEuQbTVUbsstDzlCr5vOTCFqhB38PcifIJO X-Received: by 2002:a17:90a:e54d:b0:219:681c:9f29 with SMTP id ei13-20020a17090ae54d00b00219681c9f29mr40030818pjb.1.1672423756833; Fri, 30 Dec 2022 10:09:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672423756; cv=none; d=google.com; s=arc-20160816; b=BTFgo6T8eHb9a680SpBZmuZ9NFbbHHSUP8wvbiHfh5e+1wHr5tzwt5En/KK1bRZO6q PnoCBPz+6yfB+vTK3H+af1Bfr8TW3aG/BvYX+pPFkbqXxOO59QpNvc08VTvaNXc8P93l ldevOovTkB4V1uAZa+Lz9rkqFDl3qbEuC0W70exgy8d/NKclv4lxGrB0qYPk/WadlRFY yHMmMcpzF/lZdcnv/UoyvtP/C8//Xm5Z1YUL/xifctEgqCrHLvIfFOuU3L8nvZvaPuJJ qNFLN/JeFuz+8sV9TPbCGG13N8/tweHcOCRLn9VyWt24mv3t9xM/mfn+F+wS7fzlsRND QLOQ== 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 Return-Path: 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.51; Fri, 30 Dec 2022 10:09:16 -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 + 63 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 Content-Transfer-Encoding: 8bit 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 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 */ } } } -- 2.30.2