Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1705605pxm; Thu, 24 Feb 2022 07:59:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAVmCoqsalOE/CU5vz+xujxyZCGtC015Gzr9XbX50BDlvjRX2nVvmesEVWUjY0p1UmmgUE X-Received: by 2002:a17:90b:30cb:b0:1bb:fa5e:68a with SMTP id hi11-20020a17090b30cb00b001bbfa5e068amr3423882pjb.5.1645718369225; Thu, 24 Feb 2022 07:59:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645718369; cv=none; d=google.com; s=arc-20160816; b=QNFIUYbGWz0CB1S6oOBKX6uAFyw9gsoma7LirlnvLS18CLmTLhyWdIVzIGaUztvO8C DBfwLL2R3pDlFRR/oW5zcFMtoVUwE4Q+ryXA9SKOEG0DxhXn8XrVmbWmOT7LGf2rkfc1 VTnGX6acdtlIJZ+P2oHT/oBfhvPfwXvGh19DEuHAGgPCnmyrdSHWajpqBmQJIXlnIiTi AHfrpfU1LZ+3LUYdEzH02nHs/imQ0tWhc1wdvL5M/bI5d8MGX18dJDwD5DnPDGAZRTyw kwSBlePZuPfn7s2d9ci5EfkloidY8kd0Q8EKyN2YrAzgTVFuVFGSl3z+2Pzu1IpScaSc 0lJg== 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 :message-id:date:subject:to:from:dkim-signature; bh=VMyIEEoc90IkE826BBN4FO4r3y31Hr4F0V0mhxWbplk=; b=A0s5uxxZrFin8AOGg14c1Xj0sQhfjwNpIHfAavxw6FnBo7QwDWq4GicDqhA2CkVt1F NJiGT21fnsjiL+XfgT+o7LAa35N0NnF9FnQP2X9uYcvnmwgGVknWtK8sq8V1RXBTfO1P fKTMsS3IirsdQnYZ0dYEqWJDDlk9XPq4k0qhtbIYZy3eW9B9cuFpNHG+bntQqhnOtXfE aTcxo9TI9yK6vPchChrRHY9kRkB0AY1lCXWLYvPKnzePqZ72oYvxeaszhFf9cJAkfzPj RmllrjX7IyAXL5LN9NUG+QYYGDFa+IJGzjQygOKb1ylHUR10qCRrQPUBGBQ0nn175Y3Q NgeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=Tyg3KRN8; spf=softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id lk15-20020a17090b33cf00b001bc503ab020si5684574pjb.21.2022.02.24.07.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 07:59:29 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=Tyg3KRN8; spf=softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5BF28175830; Thu, 24 Feb 2022 07:58:33 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235131AbiBXNjj (ORCPT + 73 others); Thu, 24 Feb 2022 08:39:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235129AbiBXNji (ORCPT ); Thu, 24 Feb 2022 08:39:38 -0500 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDD5E25F36C for ; Thu, 24 Feb 2022 05:39:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject :To:From:Sender:Reply-To:Cc:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=VMyIEEoc90IkE826BBN4FO4r3y31Hr4F0V0mhxWbplk=; b=Tyg3KRN8nTTmsS9uW7dksxGukl rRVRO5gWTngYsgdNGDlis4G0AWSUhyBt/0hD1lZqUpdEqDJBKUtFBuhACygv2+CzsTDei01ZhdzzE s7u3QP+iY4vZCznICD13D3d9ZdY/vl5raPhG3ZGmKU/tGWgGkw7netbdxpl162WFp+Ho=; Received: from p200300daa7204f00019652c85c04bce2.dip0.t-ipconnect.de ([2003:da:a720:4f00:196:52c8:5c04:bce2] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1nNEKo-00036C-UR for linux-wireless@vger.kernel.org; Thu, 24 Feb 2022 14:39:07 +0100 From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH] mt76: fix dfs state issue with 160 MHz channels Date: Thu, 24 Feb 2022 14:39:05 +0100 Message-Id: <20220224133905.49774-1-nbd@nbd.name> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 When operating on a mix of DFS and non-DFS channels, the driver only checks the CAC status of the control channel. This causes beacons/tx to fail if the control channel is on a non-DFS channel. Fix this by calling cfg80211_reg_can_beacon to determine the DFS status of all affected channels Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mac80211.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 8 +++++--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 8 +++++--- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 8 +++++--- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index 9796419c99e1..372b94a665ec 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c @@ -1658,7 +1658,7 @@ enum mt76_dfs_state mt76_phy_dfs_state(struct mt76_phy *phy) return MT_DFS_STATE_DISABLED; } - if (phy->chandef.chan->dfs_state != NL80211_DFS_AVAILABLE) + if (!cfg80211_reg_can_beacon(hw->wiphy, &phy->chandef, NL80211_IFTYPE_AP)) return MT_DFS_STATE_CAC; return MT_DFS_STATE_ACTIVE; diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c index 120760ea1c89..e98c6076a633 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -2151,10 +2151,12 @@ int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd) .center_chan2 = ieee80211_frequency_to_channel(freq2), }; - if (phy->mt76->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) + if (cmd == MCU_EXT_CMD(SET_RX_PATH)) + req.switch_reason = CH_SWITCH_NORMAL; + else if (phy->mt76->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) req.switch_reason = CH_SWITCH_SCAN_BYPASS_DPD; - else if ((chandef->chan->flags & IEEE80211_CHAN_RADAR) && - chandef->chan->dfs_state != NL80211_DFS_AVAILABLE) + else if (!cfg80211_reg_can_beacon(phy->mt76->hw->wiphy, chandef, + NL80211_IFTYPE_AP)) req.switch_reason = CH_SWITCH_DFS; else req.switch_reason = CH_SWITCH_NORMAL; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index 8c014299daa1..119f9358162f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -2811,10 +2811,12 @@ int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd) } #endif - if (phy->mt76->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) + if (cmd == MCU_EXT_CMD(SET_RX_PATH)) + req.switch_reason = CH_SWITCH_NORMAL; + else if (phy->mt76->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) req.switch_reason = CH_SWITCH_SCAN_BYPASS_DPD; - else if (phy->mt76->hw->conf.radar_enabled && - chandef->chan->dfs_state != NL80211_DFS_AVAILABLE) + else if (!cfg80211_reg_can_beacon(phy->mt76->hw->wiphy, chandef, + NL80211_IFTYPE_AP)) req.switch_reason = CH_SWITCH_DFS; else req.switch_reason = CH_SWITCH_NORMAL; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c index 33a836825cca..e7adcba7a8bf 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -863,10 +863,12 @@ int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd) else req.channel_band = chandef->chan->band; - if (dev->mt76.hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) + if (cmd == MCU_EXT_CMD(SET_RX_PATH)) + req.switch_reason = CH_SWITCH_NORMAL; + else if (dev->mt76.hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) req.switch_reason = CH_SWITCH_SCAN_BYPASS_DPD; - else if ((chandef->chan->flags & IEEE80211_CHAN_RADAR) && - chandef->chan->dfs_state != NL80211_DFS_AVAILABLE) + else if (!cfg80211_reg_can_beacon(dev->mt76.hw->wiphy, chandef, + NL80211_IFTYPE_AP)) req.switch_reason = CH_SWITCH_DFS; else req.switch_reason = CH_SWITCH_NORMAL; -- 2.32.0 (Apple Git-132)