Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3039877pxb; Sun, 29 Aug 2021 11:18:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTB5LFdX5xXCK+/0iI0Fy2N0CBbLvG7vSYHYwyRo9ucn1ZxoZYoEToPTo70u/gHe/6Gg56 X-Received: by 2002:a5d:9653:: with SMTP id d19mr15395015ios.74.1630261108990; Sun, 29 Aug 2021 11:18:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630261108; cv=none; d=google.com; s=arc-20160816; b=CPyXgHjUT8u0wo2c8fReMfmKRZYOb2vj9S70ffs58+/ks8Xqb2heKXhCjhwwG4SFqN bmGBkKJDm9vgfm3i5/vpHLuPqupHCnxoL7csoupIKLabaY5HNqTmMyzL7xJozgg0ZTbx V5R5gIRhhObX9rHmAa14xta5PsDjqYhO+d81Z76uVHIRi3bgCzkJhOdrCWWlBnMZFkQ0 lOC8QX45nwWArY8T56qb22wNorH2fuL7ZMQDSwEcMFQC7b4WLeNXQPnSey8qOAM46aCZ ROqrrk9tWLRosSlUeJt0M7TEhecyjVlYgwTUl2vpPW8QIC+XfWnMTHKjzA5h6MairnB5 tcog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=6qpYKHPZ3o/6p8b4HBCXmyZQFDSVexANicwSr1f3zk8=; b=LfkS4ExZq3BhjuW+hMymR8Oyp+D1nVI/rORXgzuMvSomfVtpldXb4MNIEvTg6mWFT8 LKpNvN+kZnBWzI25rlMhqFv0lwe6RLcuM0YGuHlf1JiAldFdZNxVov8si5RAH30cHBzY zPNLIFvs4e+SEvLfDw3NEyjguDgbOStB1CJuOHQ49DmrjqYhRSpXKXeINNPjUSaf2ZVo GdYJZ2yDYyzig07T7HyujUIHR5dXnxrizPdHjVWNcSVovYeJBfmNtiw/nuuN3Wf2wQy9 wXfP5cwiQaAQg3qItbhLgUPJPze1KPJXMF2fFYjhTh8P1abJYgg3J3mJgbPRS2nx/U3V vwOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RlAWJQuC; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p4si12310921ilq.160.2021.08.29.11.18.13; Sun, 29 Aug 2021 11:18:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RlAWJQuC; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232422AbhH2STB (ORCPT + 99 others); Sun, 29 Aug 2021 14:19:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230010AbhH2STB (ORCPT ); Sun, 29 Aug 2021 14:19:01 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CA46C061575 for ; Sun, 29 Aug 2021 11:18:08 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id m18so12300927lfl.10 for ; Sun, 29 Aug 2021 11:18:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=6qpYKHPZ3o/6p8b4HBCXmyZQFDSVexANicwSr1f3zk8=; b=RlAWJQuCVBr9KMnjgUj1FsKOb96EzNnNe2t9pCuakhoG0MdwkX3EAKB3YLTm9B7FqN tItSf69UF731foIENk9yrnavs5JQ6u1T+uEGeN2372v64vfO+CSeoqiFZBVJ3d6Caerk qSCxf4HwXwmVpOeTMf4MVxjBQn+NXyktB+FeIGrRD4m3LBjHv0xK4DsR/EzxoBGcppqa avZCdNep2R74Q9alizkMgPOUo2IjxaiFPck2qgMr4nMIiqNwBX3oFTzO/5wRCj4XwCZF bBEU4+CyhLtS3m+sGE/OXGZOf1IJXoqPuZZFnmmBwUT5fU2XDs6LrqPqvYgv3lmkMHru bHzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=6qpYKHPZ3o/6p8b4HBCXmyZQFDSVexANicwSr1f3zk8=; b=O4QdzWC7OBgXjW1Ll7NR8FVnziXQ+NaFmQvEfSArJgCbwmWRp4yuH/Wz4GMOifUHy8 aNCRyhUSYpemjUaggJEX9I616b8tRhJmGffs2K1cD7f5f+omLAiG2/0u5dxzcsX6zrvv c1f3cbg8wkpGW5fvsObXz/AHbTaf5SdujhlBgWIUSYQ2cTY+1EL45/3dydaTbE2C/wwL qEB6FK3VtrJ7cYMmTkf3VGZ8AHu5WXrTUZKnZak2WiMjLQMffboJnNVkXy1DOT7+GlPI 8o405d2fF7qCqrv0oZuTRZYeD4n+0fCM3nby3NNVfGrPeX1T7a/akhQXEAtbNRW20HNR CMEA== X-Gm-Message-State: AOAM530bwZ7NyX3C3fwF4NAiJaZLahCtqVyFaEkvvEesFWOzFcVdkES3 m+ziDoqs9RoaBrKMYO7ORvfV2X2Ql0V7eyUJv7Kl6piD+14= X-Received: by 2002:a05:6512:3b9b:: with SMTP id g27mr462557lfv.556.1630261086691; Sun, 29 Aug 2021 11:18:06 -0700 (PDT) MIME-Version: 1.0 References: <20210820203531.20706-1-greearb@candelatech.com> In-Reply-To: <20210820203531.20706-1-greearb@candelatech.com> From: Janusz Dziedzic Date: Sun, 29 Aug 2021 20:17:55 +0200 Message-ID: Subject: Re: [PATCH v3 1/2] mt76: mt7915: fix STA mode connection on DFS channels To: Ben Greear Cc: linux-wireless , Rubio Lu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org pt., 20 sie 2021 o 22:37 napisa=C5=82(a): > > From: Ben Greear > > Only AP, adhoc and mesh mode needs to check CAC. > Stations, in particular, do not need this check. > > Signed-off-by: Rubio Lu > Signed-off-by: Ben Greear > --- > v3: Fix typo in SOB in 1/2, fix rebase typo in 2/2, > split long line in 2/2 > .../net/wireless/mediatek/mt76/mt7915/mac.c | 38 +++++++++++++++++-- > 1 file changed, 35 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/ne= t/wireless/mediatek/mt76/mt7915/mac.c > index 8747e452e114..a6e142d27b60 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c > +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c > @@ -2455,6 +2455,32 @@ static int mt7915_dfs_start_radar_detector(struct = mt7915_phy *phy) > return 0; > } > > +struct mt7915_vif_counts { > + u32 mesh; > + u32 adhoc; > + u32 ap; > +}; > + > +static void > +mt7915_vif_counts(void *priv, u8 *mac, struct ieee80211_vif *vif) > +{ > + struct mt7915_vif_counts *counts =3D priv; > + > + switch (vif->type) { > + case NL80211_IFTYPE_ADHOC: > + counts->adhoc++; > + break; > + case NL80211_IFTYPE_MESH_POINT: > + counts->mesh++; > + break; > + case NL80211_IFTYPE_AP: > + counts->ap++; > + break; > + default: > + break; > + } > +} > + > static int > mt7915_dfs_init_radar_specs(struct mt7915_phy *phy) > { > @@ -2495,6 +2521,7 @@ int mt7915_dfs_init_radar_detector(struct mt7915_ph= y *phy) > struct mt7915_dev *dev =3D phy->dev; > bool ext_phy =3D phy !=3D &dev->phy; > int err; > + struct mt7915_vif_counts counts =3D {0}; > > if (dev->mt76.region =3D=3D NL80211_DFS_UNSET) { > phy->dfs_state =3D -1; > @@ -2519,9 +2546,14 @@ int mt7915_dfs_init_radar_detector(struct mt7915_p= hy *phy) > phy->dfs_state =3D chandef->chan->dfs_state; > > if (chandef->chan->flags & IEEE80211_CHAN_RADAR) { > - if (chandef->chan->dfs_state !=3D NL80211_DFS_AVAILABLE) > - return mt7915_dfs_start_radar_detector(phy); > - > + if (chandef->chan->dfs_state !=3D NL80211_DFS_AVAILABLE) = { > + ieee80211_iterate_active_interfaces(phy->mt76->hw= , > + IEEE80211_IFACE_ITER_RESUME_ALL, > + mt7915_vif_counts, &counts); > + if (counts.ap + counts.adhoc + counts.mesh) > + mt7915_dfs_start_radar_detector(phy); > + return 0; > + } > return mt7915_mcu_rdd_cmd(dev, RDD_CAC_END, ext_phy, > MT_RX_SEL0, 0); > } > -- > 2.20.1 > This depends on spec interpretation - when we have multiple ifaces on the same radio/channel (STA + APs). Maybe this is good time to start discussion about it - how we handle DFS and if we should improve. Some vendors "derive" CAC from STA. So, while STA don't need to run CAC and first VIF sta will be connected on DFS channel, assume don't need to run CAC for second, third ... AP VIF. Still required ISM (In service monitoring, radar detection if AP ifaces) but simple skip CAC. This simplify implementation a lot for multi-vif (STA+APs) case. So, maybe we should/could add kconfig for that - CONFIG_DFS_DERIVE_STA_CAC. When set, we could simple set NL80211_DFS_AVAILABLE when STA will connect on DFS channel - then any other APs we will add on the same channel will not require CAC, radar detection still required. Regarding STA connection on DFS channel, I agree - today MT76x have a bug for that (eg. single VIF station). I have much older code and fix it simplest way I could. --- a/mt7615/mac.c +++ b/mt7615/mac.c @@ -2034,6 +2034,11 @@ static int mt7615_dfs_start_radar_detect phy->rdd_state |=3D BIT(1); } + /* end CAC - upper layer will care about it, lock tx, beacon setup */ + err =3D mt7615_mcu_rdd_cmd(dev, RDD_CAC_END, ext_phy, MT_RX_SEL0, 0); + if (err < 0) + return err; + return 0; } @@ -2104,11 +2109,7 @@ int mt7615_dfs_init_radar_detector(struc phy->dfs_state =3D chandef->chan->dfs_state; if (chandef->chan->flags & IEEE80211_CHAN_RADAR) { - if (chandef->chan->dfs_state !=3D NL80211_DFS_AVAILABLE) - return mt7615_dfs_start_radar_detector(phy); - - return mt7615_mcu_rdd_cmd(dev, RDD_CAC_END, ext_phy, - MT_RX_SEL0, 0); + return mt7615_dfs_start_radar_detector(phy); } stop: BR Janusz