Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2233151iob; Thu, 5 May 2022 20:01:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbVWdWcSzVyloq66Y994f5jgnffHPzojrwPibo8nDuUGGp9hHBSPFO5DynsJFUsd0f7HRN X-Received: by 2002:a17:906:d296:b0:6f4:318d:7ee3 with SMTP id ay22-20020a170906d29600b006f4318d7ee3mr1070098ejb.575.1651806099611; Thu, 05 May 2022 20:01:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651806099; cv=none; d=google.com; s=arc-20160816; b=IBohBH3ek05yeOltBQ/r0iwQh6QhiEW+Hgjy8+kryJnvLpcR3bPYY7w7Bv10dRy3Vl X/56/PmtUvudiHvCloo/a3mSljTDldjoImCSkOa9V61iR7Lc7ybqpVV9MJLxsG38g8pI iwM1sD6u5yM1ypsdcBE6vHPjifTibQHQFM+oKN7q6lcPt0VXlivxFBD2RkxrC+WLZ4g9 DO5e8rR6ae/a2ktjFOrQiPkXZiyjs6FId2QLCYDUOBzTvtRTNkvlCKM7/VNbOKYbB02O aE1y7GTvVqrEfAY15epiLAv5OwZn/ZOmdqT1V6s3JUGxCnVk4YLn6u3gf6ApVRmPjFMN QsKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=jq9pHaLtRMnUEmE5kxRLNNxnfV6ePclZ8xcnCrX9Rp0=; b=NgQFmF4BAhAtk94d4PysM++R0v7ttLacWU7EssuOmbl6OD2Up6Z6VcoxDriitTMFBa wwNgXAm/hFU9aIHXgCF1xFoD/ydZQEHZOvcrbaT9qlM0uO134/Ej1BpvBdyhb8bwftBy ITHbcURt3Q4Y8i++EhxZCKVBY8XXToY8NfogslTTbvvOm82qtUSXhrL1ITCC3oPYnxhm Ao2GaWyoJ3N97OaHWa7x56kbV1LfEZWDFNdn96E+n5C4AZ0Fxf3pOtJF8w7SJrgDGafL PA0OzDPuXPkmw0bkOzrXgyU03BtUQsESYTrE9iFjLz2jWHwNkJ+ACQa7jRjDj9kNt1Fm DFeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id zc8-20020a170906988800b006f385c98ca8si3866736ejb.615.2022.05.05.20.01.18; Thu, 05 May 2022 20:01:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347215AbiEEI3w (ORCPT + 68 others); Thu, 5 May 2022 04:29:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235299AbiEEI3s (ORCPT ); Thu, 5 May 2022 04:29:48 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E5792D1CE for ; Thu, 5 May 2022 01:26:02 -0700 (PDT) X-UUID: d3921ea14115416193a409467bf9c0ea-20220505 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.4,REQID:557196c3-f3e2-4301-b59d-09a95ae17ecd,OB:10,L OB:10,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:100,FILE:0,RULE:Release_Ham, ACTION:release,TS:100 X-CID-INFO: VERSION:1.1.4,REQID:557196c3-f3e2-4301-b59d-09a95ae17ecd,OB:10,LOB :10,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:100,FILE:0,RULE:Spam_GS981B3D, ACTION:quarantine,TS:100 X-CID-META: VersionHash:faefae9,CLOUDID:b6ceaab2-56b5-4c9e-8d83-0070b288eb6a,C OID:a5cd4d0f3da0,Recheck:0,SF:28|16|19|48,TC:nil,Content:0,EDM:-3,File:nil ,QS:0,BEC:nil X-UUID: d3921ea14115416193a409467bf9c0ea-20220505 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 191554284; Thu, 05 May 2022 16:25:58 +0800 Received: from mtkmbs07n1.mediatek.inc (172.21.101.16) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Thu, 5 May 2022 16:25:57 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 5 May 2022 16:25:56 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 5 May 2022 16:25:56 +0800 From: Peter Chiu To: Felix Fietkau CC: Lorenzo Bianconi , Ryder Lee , Evelyn Tsai , Shayne Chen , , , Peter Chiu Subject: [PATCH 3/4] mt76: mt7915: reject duplicated twt flows Date: Thu, 5 May 2022 16:25:53 +0800 Message-ID: <20220505082554.16656-3-chui-hao.chiu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220505082554.16656-1-chui-hao.chiu@mediatek.com> References: <20220505082554.16656-1-chui-hao.chiu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,MAY_BE_FORGED, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR,UNPARSEABLE_RELAY autolearn=no 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-wireless@vger.kernel.org Reject twt flows with the same parameters to prevent some potential issues causing by duplicated establishment. Reviewed-by: Ryder Lee Reviewed-by: Shayne Chen Signed-off-by: Peter Chiu --- .../net/wireless/mediatek/mt76/mt7915/mac.c | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 94a1871fbf43..ff60a3d2d26d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -2601,6 +2601,34 @@ static int mt7915_mac_check_twt_req(struct ieee80211_twt_setup *twt) return 0; } +static inline bool +mt7915_mac_twt_param_equal(struct mt7915_sta *msta, + struct ieee80211_twt_params *twt_agrt) +{ + u16 type = le16_to_cpu(twt_agrt->req_type); + u8 exp; + int i; + + exp = FIELD_GET(IEEE80211_TWT_REQTYPE_WAKE_INT_EXP, type); + for (i = 0; i < MT7915_MAX_STA_TWT_AGRT; i++) { + struct mt7915_twt_flow *f; + + if (!(msta->twt.flowid_mask & BIT(i))) + continue; + + f = &msta->twt.flow[i]; + if (f->duration == twt_agrt->min_twt_dur && + f->mantissa == twt_agrt->mantissa && + f->exp == exp && + f->protection == !!(type & IEEE80211_TWT_REQTYPE_PROTECTION) && + f->flowtype == !!(type & IEEE80211_TWT_REQTYPE_FLOWTYPE) && + f->trigger == !!(type & IEEE80211_TWT_REQTYPE_TRIGGER)) + return true; + } + + return false; +} + void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw, struct ieee80211_sta *sta, struct ieee80211_twt_setup *twt) @@ -2634,6 +2662,9 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw, exp = FIELD_GET(IEEE80211_TWT_REQTYPE_WAKE_INT_EXP, req_type); sta_setup_cmd = FIELD_GET(IEEE80211_TWT_REQTYPE_SETUP_CMD, req_type); + if (mt7915_mac_twt_param_equal(msta, twt_agrt)) + goto unlock; + flow = &msta->twt.flow[flowid]; memset(flow, 0, sizeof(*flow)); INIT_LIST_HEAD(&flow->list); -- 2.18.0