// SPDX-License-Identifier: GPL-2.0/* * This file contains helper code to handle channel * settings and keeping track of what is possible at * any point in time. * * Copyright 2009 Johannes Berg <johannes@sipsolutions.net> * Copyright 2013-2014 Intel Mobile Communications GmbH * Copyright 2018-2020 Intel Corporation */#include<linux/export.h>#include<net/cfg80211.h>#include"core.h"#include"rdev-ops.h"staticboolcfg80211_valid_60g_freq(u32freq){returnfreq>=58320&&freq<=70200;}voidcfg80211_chandef_create(structcfg80211_chan_def*chandef,structieee80211_channel*chan,enumnl80211_channel_typechan_type){if(WARN_ON(!chan))return;chandef->chan=chan;chandef->freq1_offset=chan->freq_offset;chandef->center_freq2=0;chandef->edmg.bw_config=0;chandef->edmg.channels=0;switch(chan_type){caseNL80211_CHAN_NO_HT:chandef->width=NL80211_CHAN_WIDTH_20_NOHT;chandef->center_freq1=chan->center_freq;break;caseNL80211_CHAN_HT20:chandef->width=NL80211_CHAN_WIDTH_20;chandef->center_freq1=chan->center_freq;break;caseNL80211_CHAN_HT40PLUS:chandef->width=NL80211_CHAN_WIDTH_40;chandef->center_freq1=chan->center_freq+10;break;caseNL80211_CHAN_HT40MINUS:chandef->width=NL80211_CHAN_WIDTH_40;chandef->center_freq1=chan->center_freq-10;break;default:WARN_ON(1);}}EXPORT_SYMBOL(cfg80211_chandef_create);staticboolcfg80211_edmg_chandef_valid(conststructcfg80211_chan_def*chandef){intmax_contiguous=0;intnum_of_enabled=0;intcontiguous=0;inti;if(!chandef->edmg.channels||!chandef->edmg.bw_config)returnfalse;if(!cfg80211_valid_60g_freq(chandef->chan->center_freq))returnfalse;for(i=0;i<6;i++){if(chandef->edmg.channels&BIT(i)){contiguous++;num_of_enabled++;}else{contiguous=0;}max_contiguous=max(contiguous,max_contiguous);}/* basic verification of edmg configuration according to * IEEE P802.11ay/D4.0 section 9.4.2.251 *//* check bw_config against contiguous edmg channels */switch(chandef->edmg.bw_config){caseIEEE80211_EDMG_BW_CONFIG_4