Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp543484ybl; Fri, 30 Aug 2019 03:40:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/d6dhY91jYG8dpuyPcO7rWZZRP2bxw22R7GGa2hq7/6+/0mxQGCTuOQ/Yby5avAOxUYhf X-Received: by 2002:a17:90a:30e6:: with SMTP id h93mr14484497pjb.37.1567161658527; Fri, 30 Aug 2019 03:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567161658; cv=none; d=google.com; s=arc-20160816; b=SJbuY1cTPOo24TyJBM8XXg3bYvuLti6mbIP0D0hIx1kW1u9ghYCak903/u6BRME0ck Gr10vNF+DSIP7Jx4N2Ou0+BDh9FUPZuWViRhg0zU2/HEnqOHIZkzhlabM92r0ocT4bun 7CHo6nVXm04+AmgDkgfCATGmQyOtbI+skVG7BLr/SV3RGrcno96s1f7X+7XOFGqJ1TPA SF+boUzw1KIY6Sn+tlnSVFwZBS7qpeDubPLDtTA2VCXSJ2fDZWPqs5/qO8/oraSP/Z0w KHxgsMtmZNWxe3+bG8XK7Xznp7D0Uz/HgcLmEgTeBjAY+QNizFcEHn4rFtcQDK3Mb5c7 dx7Q== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=JjCGk953Wcxs0Gns8eITBhEGK4wipyV/zJbSLGtTENw=; b=TMk2TcaXZtTFlvGPsLquQx1PFaaodufSZehntcN344gA0jl/QjIUm5HuqUcok15fpQ 4L3o1UexEWv65zkf0PZsOyaWrxXrlnl1SnbTzhCbFMmsznzqumvTbSHLAidFoO6Jmywy X52JyjtWRWl58reP5z1GHCG9Sbpzj/rUPXIiYRPX0Cp7AWLYCBUgXv+ohR5sMX9bRLVc RmmRWwBJbc0qRF+9ib8DzOz0ULb7fzp8VvJx6Qh4S75aSOBHinDkyIaw+svPNB2vBvQ9 3FBbsgPAWvLm6WYJNJoOp/Uw8HrA4erIzyWIVmHftyYsCQvP/p8iQS7qhBKJlfwTYcIW SVyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="BbrWwki/"; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si5580453pfi.76.2019.08.30.03.40.44; Fri, 30 Aug 2019 03:40:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="BbrWwki/"; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728086AbfH3KkY (ORCPT + 99 others); Fri, 30 Aug 2019 06:40:24 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:50870 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725780AbfH3KkX (ORCPT ); Fri, 30 Aug 2019 06:40:23 -0400 Received: by mail-wm1-f65.google.com with SMTP id v15so6798918wml.0 for ; Fri, 30 Aug 2019 03:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=JjCGk953Wcxs0Gns8eITBhEGK4wipyV/zJbSLGtTENw=; b=BbrWwki/Fpi650/waZ8y2mrYZweWZJ6dZBFUqCrvE0H8xzYfNUsZ3gGJo4V++UiYBN sP1U3DvpfcLt1I2ehDFznhbplv8xCtqnfaeC+Dv5uhdr1Jw4SIXSSSZqarrVo6QbosE6 La2IBTrg+GJlKRebcEPWd9gta0L6ftelr1mvY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=JjCGk953Wcxs0Gns8eITBhEGK4wipyV/zJbSLGtTENw=; b=BRw8fFD8SHvTnLqT3a99ydyXIU03crTh+mFLRJn/oveM3nZvW69XJXC0T5MMSRjThS OkwKzuwPTHpRZ/70aFYVG5+7PW+dVovHMbcpTaKGm+ExfPDYe/BZ10DvlBmCN2xhO+K9 70SdqQMxogxyZcnjaEDFQd2wDL+GX19S+V+K8pAGsoip1N6bLuFe7XgWJ98Qr05hnLHo Pd3DK7MdXyT5Tnj7YTv6x1JHAu4P6d2AMyP5j6wdKloFCaN3Y3iz0zqmjp1pdtxMMDsO 0+iP9/FVwn7R+g3lNZuWP8AeDX/gVNn9d4ccdRUtgSB0H1KO0Hz1GvYh08cumvvi2hyR +f8w== X-Gm-Message-State: APjAAAWLLOS4q5LQLwtYOF5xJKAnNUyhkva5BoOx7/PZAd/MYKwwRMSY erHn+ghHqUQQzQhVThHo1UP6SQ== X-Received: by 2002:a1c:ed1a:: with SMTP id l26mr18258664wmh.34.1567161621645; Fri, 30 Aug 2019 03:40:21 -0700 (PDT) Received: from [10.176.68.244] ([192.19.248.250]) by smtp.gmail.com with ESMTPSA id u6sm5254220wmm.26.2019.08.30.03.40.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Aug 2019 03:40:21 -0700 (PDT) Subject: Re: [PATCH] cfg80211: Add new helper function for channels To: Amar Singhal , jouni@codeaurora.org Cc: johannes@sipsolutions.net, linux-wireless@vger.kernel.org, jjohnson@codeaurora.org, rmanohar@codeaurora.org References: <1567115381-7831-1-git-send-email-asinghal@codeaurora.org> From: Arend Van Spriel Message-ID: <01082dca-8d71-c674-1f61-ab5d7e07c007@broadcom.com> Date: Fri, 30 Aug 2019 12:40:19 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1567115381-7831-1-git-send-email-asinghal@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 8/29/2019 11:49 PM, Amar Singhal wrote: > Add new helper function to convert (chan_number, oper_class) pair to > frequency. Call this function ieee80211_channel_op_class_to_frequency. > This function would be very useful in the context of 6 GHz channels, > where channel number is not unique. That 'unique' statement does not apply to 6GHz by itself. The addition of 6GHz channels makes channel numbers across bands not unique. The funcion > Signed-off-by: Amar Singhal > --- > include/net/cfg80211.h | 10 ++++++++++ > net/wireless/util.c | 23 +++++++++++++++++++++++ > 2 files changed, 33 insertions(+) > > diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h > index 6467b60..decafba 100644 > --- a/include/net/cfg80211.h > +++ b/include/net/cfg80211.h > @@ -4914,1 +4914,1 @@ static inline void *wdev_priv(struct wireless_dev *wdev) > int ieee80211_channel_to_frequency(int chan, enum nl80211_band band); > > /** > + * ieee80211_channel_op_class_to_frequency - convert > + * (channel, operating class) to frequency > + * @chan_num: channel number > + * @global_op_class: global operating class > + * > + * Return: The corresponding frequency, or 0 if the conversion failed. > + */ > +int ieee80211_channel_op_class_to_frequency(u8 chan_num, u8 global_op_class); > + > +/** > * ieee80211_frequency_to_channel - convert frequency to channel number > * @freq: center frequency > * Return: The corresponding channel, or 0 if the conversion failed. > diff --git a/net/wireless/util.c b/net/wireless/util.c > index 9aba8d54..7f64b4a 100644 > --- a/net/wireless/util.c > +++ b/net/wireless/util.c > @@ -144,6 +144,29 @@ struct ieee80211_channel *ieee80211_get_channel(struct wiphy *wiphy, int freq) > } > EXPORT_SYMBOL(ieee80211_get_channel); > > +int ieee80211_channel_op_class_to_frequency(u8 chan_num, u8 global_op_class) > +{ > + if (global_op_class >= 131 && global_op_class <= 135) > + return (5940 + 5 * chan_num); > + else if (global_op_class >= 115 && global_op_class <= 130) > + return (5000 + 5 * chan_num); > + else if (global_op_class >= 112 && global_op_class <= 113) > + return (5000 + 5 * chan_num); > + else if (global_op_class >= 109 && global_op_class <= 110) > + return (4000 + 5 * chan_num); > + else if (global_op_class >= 83 && global_op_class <= 84) > + return (2407 + 5 * chan_num); > + else if (global_op_class == 81) > + return (2407 + 5 * chan_num); > + else if (global_op_class == 82) > + return (2414 + 5 * chan_num); > + else if (global_op_class == 180) > + return (56160 + 5 * chan_num); > + else > + return 0; > +} > +EXPORT_SYMBOL(ieee80211_channel_op_class_to_frequency); The function ieee80211_operating_class_to_band() uses ranges within switch statement, eg.: case 128 ... 130: *band = NL80211_BAND_5GHZ; return true; For consistency it might be good to do the same here. Regards, Arend