Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp675100ybz; Wed, 29 Apr 2020 07:27:42 -0700 (PDT) X-Google-Smtp-Source: APiQypKQEzo/K/9XZw4b4UDwGpBd+U5pnyJL7+rp5bFDmmpRb/sibKj71vGenyZwLEiWVPOWkHmX X-Received: by 2002:a05:6402:22ea:: with SMTP id dn10mr2711255edb.70.1588170462162; Wed, 29 Apr 2020 07:27:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588170462; cv=none; d=google.com; s=arc-20160816; b=rDsAB8KRugZ+QA3c6egrNUb8v5HFqdKAHpfZ7XiLgEk9OIj8tHGzdvm70XFjIVu4qC piBVa/glMzseqXJ/gEdVbb0RWY+zJA25ikLlEKbM0Md7sgaJTIp2tpGrfnmkB2f4Paik O01gPlKqJrEwiRC1hmlE5xTfxpSe6uAixT8itirVMrimxSmq9fEvMnc4o6wW7f1yqX3x k6i935tKZVDWGkGx476C9FoZ+NPT+aaoaaUzXGM9yge4mgG27I624lDMkEZ7LJiIByNY lUf1brHW+n0BBFOgaqLyFhO0KDphP1TX5JMJ9MVKrzNZoJvIEAkZxHOK4p9IpcQU7nuP qrmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=ahvcHTbu6OU85lbffsjrYwMRhH2ids8giAuFLpLYvJ4=; b=MSIAkA+7ffN30IPW5c87/+Ft9WM6ftDXqM1P3Gvzn9zbdnombQW+qtBh++PBrLYzR/ zo42Wp3yfqEtVACMzpVmTD0azHD89bhqQhG/nSOoX5jZHsVaafHrvz3pSzV11CcQSfeb UKCvAe7Am499FeKhZcyAK/EKf65pbrSuohQqv3sIBTM7OVhi3JIq6/At9FgDUy/SV6NZ Zda1UEOw8EcDpvTgwOl/9vNRBMKC7Fqp13FRwfYa0MyQK0BYuY8aGMftibpXRmjgyCel FuaVc0DqOSorDNSLTSdMzxjqcv67axUfO4V/wCXUukSpMQe7p60jRlWkbqHJLMw/Lxtx iW5A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si4188966ejl.173.2020.04.29.07.27.17; Wed, 29 Apr 2020 07:27:42 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726511AbgD2O0v (ORCPT + 99 others); Wed, 29 Apr 2020 10:26:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726493AbgD2O0v (ORCPT ); Wed, 29 Apr 2020 10:26:51 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63BCBC03C1AD for ; Wed, 29 Apr 2020 07:26:51 -0700 (PDT) Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) (envelope-from ) id 1jTnfl-001wuG-Km; Wed, 29 Apr 2020 16:26:49 +0200 Message-ID: <73a4e63e16bffb69cd9b62fd904b926dd5278fbf.camel@sipsolutions.net> Subject: Re: [PATCH 02/10] cfg80211: validate 6 GHz chandef From: Johannes Berg To: Rajkumar Manoharan Cc: linux-wireless@vger.kernel.org Date: Wed, 29 Apr 2020 16:26:48 +0200 In-Reply-To: <1587768108-25248-3-git-send-email-rmanohar@codeaurora.org> References: <1587768108-25248-1-git-send-email-rmanohar@codeaurora.org> <1587768108-25248-3-git-send-email-rmanohar@codeaurora.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Fri, 2020-04-24 at 15:41 -0700, Rajkumar Manoharan wrote: > > +static inline bool > +cfg80211_chandef_is_6ghz(const struct cfg80211_chan_def *chandef) > +{ > + return (chandef->center_freq1 > 5940 && chandef->center_freq1 < 7105); > +} Seems like this > +++ b/net/wireless/chan.c > @@ -19,6 +19,29 @@ static bool cfg80211_valid_60g_freq(u32 freq) > return freq >= 58320 && freq <= 70200; > } > > +static bool cfg80211_is_6ghz_freq(u32 freq) > +{ > + return (freq > 5940 && freq < 7105); > +} should use this, by also exposing it, or something. > +static enum nl80211_chan_width cfg80211_chan_to_bw_6ghz(u8 idx) > +{ > + /* channels: 1, 5, 9, 13... */ > + if ((idx & 0x3) == 0x1) > + return NL80211_CHAN_WIDTH_20; > + /* channels 3, 11, 19... */ > + if ((idx & 0x7) == 0x3) > + return NL80211_CHAN_WIDTH_40; > + /* channels 7, 23, 39.. */ > + if ((idx & 0xf) == 0x7) > + return NL80211_CHAN_WIDTH_80; > + /* channels 15, 47, 79...*/ > + if ((idx & 0x1f) == 0xf) > + return NL80211_CHAN_WIDTH_160; > + > + return NL80211_CHAN_WIDTH_20; > +} We haven't really done that for anything else - is that really necessary? > +static bool cfg80211_6ghz_chandef_valid(const struct cfg80211_chan_def *chandef) > +{ > + enum nl80211_chan_width bw; > + int chan_idx; > + > + if (!cfg80211_is_6ghz_freq(chandef->center_freq1)) > + return false; this is kinda pointless, > @@ -213,6 +255,10 @@ bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef) > !cfg80211_edmg_chandef_valid(chandef)) > return false; > > + if (cfg80211_chandef_is_6ghz(chandef) && > + !cfg80211_6ghz_chandef_valid(chandef)) > + return false; You only get there if it was in range ... Not sure about this whole patch, it seems a bit pointless? johannes