qcacmn: Make band related changes in the regulatory component

Make band related changes given below:

1. Add the API wlan_reg_chan_band_to_freq, that takes IEEE Channel Number
   and bands as input and returns the Channel center frequency.
2. Add the API wlan_reg_freq_to_band, that takes frequency as input and
   returns the corresponding band.

Change-Id: I8554f6a9c24e7508e8a551c5f318b643741f13c8
CRs-Fixed: 2523257
Tento commit je obsažen v:
Hariharan Basuthkar
2019-07-23 18:45:48 +05:30
odevzdal nshrivas
rodič 6698513b8d
revize 06cb75e445
5 změnil soubory, kde provedl 122 přidání a 9 odebrání

Zobrazit soubor

@@ -2441,6 +2441,57 @@ reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev,
return num_channels;
}
uint16_t reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev,
uint8_t chan_num,
uint8_t band_mask)
{
enum channel_enum min_chan, max_chan;
struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
uint16_t freq;
pdev_priv_obj = reg_get_pdev_obj(pdev);
if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) {
reg_err("reg pdev priv obj is NULL");
return 0;
}
if (BAND_6G_PRESENT(band_mask)) {
if (BAND_2G_PRESENT(band_mask) ||
BAND_5G_PRESENT(band_mask)) {
reg_err("Incorrect band_mask %x", band_mask);
return 0;
}
min_chan = MIN_6GHZ_CHANNEL;
max_chan = MAX_6GHZ_CHANNEL;
return reg_compute_chan_to_freq(pdev, chan_num,
min_chan,
max_chan);
} else {
if (BAND_2G_PRESENT(band_mask)) {
min_chan = MIN_24GHZ_CHANNEL;
max_chan = MAX_24GHZ_CHANNEL;
freq = reg_compute_chan_to_freq(pdev, chan_num,
min_chan,
max_chan);
if (freq != 0)
return freq;
}
if (BAND_5G_PRESENT(band_mask)) {
min_chan = MIN_49GHZ_CHANNEL;
max_chan = MAX_5GHZ_CHANNEL;
return reg_compute_chan_to_freq(pdev, chan_num,
min_chan,
max_chan);
}
reg_err("Incorrect band_mask %x", band_mask);
return 0;
}
}
bool reg_is_49ghz_freq(uint32_t freq)
{
return REG_IS_49GHZ_FREQ(freq);
@@ -3301,7 +3352,6 @@ bool reg_is_frequency_valid_5g_sbs(uint16_t curfreq, uint16_t newfreq)
return REG_IS_FREQUENCY_VALID_5G_SBS(curfreq, newfreq);
}
#ifdef CONFIG_BAND_6GHZ
bool reg_is_same_band_freqs(uint16_t freq1, uint16_t freq2)
{
return (freq1 && freq2 && ((REG_IS_6GHZ_FREQ(freq1) &&
@@ -3311,13 +3361,15 @@ bool reg_is_same_band_freqs(uint16_t freq1, uint16_t freq2)
(REG_IS_24GHZ_CH_FREQ(freq1) &&
REG_IS_24GHZ_CH_FREQ(freq2))));
}
#else
bool reg_is_same_band_freqs(uint16_t freq1, uint16_t freq2)
enum reg_wifi_band reg_freq_to_band(uint16_t freq)
{
return (freq1 && freq2 && ((REG_IS_5GHZ_FREQ(freq1) &&
REG_IS_5GHZ_FREQ(freq2)) ||
(REG_IS_24GHZ_CH_FREQ(freq1) &&
REG_IS_24GHZ_CH_FREQ(freq2))));
if (REG_IS_24GHZ_CH_FREQ(freq))
return REG_BAND_2G;
else if (REG_IS_5GHZ_FREQ(freq) || REG_IS_49GHZ_FREQ(freq))
return REG_BAND_5G;
else if (REG_IS_6GHZ_FREQ(freq))
return REG_BAND_6G;
return REG_BAND_UNKNOWN;
}
#endif /* CONFIG_BAND_6GHZ */
#endif /* CONFIG_CHAN_FREQ_API */

Zobrazit soubor

@@ -583,6 +583,22 @@ uint16_t reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev,
uint8_t band_mask,
struct regulatory_channel *channel_list);
/**
* reg_chan_band_to_freq - Return channel frequency based on the channel number
* and band.
* @pdev: pdev ptr
* @chan: Channel Number
* @band_mask: Bitmap for bands
*
* Return: Return channel frequency or return 0, if the channel is disabled or
* if the input channel number or band_mask is invalid. Composite bands are
* supported only for 2.4Ghz and 5Ghz bands. For other bands the following
* priority is given: 1) 6Ghz 2) 5Ghz 3) 2.4Ghz.
*/
uint16_t reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev,
uint8_t chan,
uint8_t band_mask);
/**
* reg_is_49ghz_freq() - Check if the given channel frequency is 4.9GHz
* @freq: Channel frequency
@@ -865,5 +881,13 @@ bool reg_is_same_band_freqs(uint16_t freq1, uint16_t freq2);
* Return: true if the given center frequency is a valid 5G SBS
*/
bool reg_is_frequency_valid_5g_sbs(uint16_t curfreq, uint16_t newfreq);
/**
* reg_freq_to_band() - Get band from channel frequency
* @chan_num: channel frequency
*
* Return: wifi band
*/
enum reg_wifi_band reg_freq_to_band(uint16_t freq);
#endif /* CONFIG_CHAN_FREQ_API */
#endif

Zobrazit soubor

@@ -794,7 +794,7 @@ struct reg_rule_info {
};
/**
* enum reg_wifi_band
* enum reg_reg_wifi_band
* @REG_BAND_2G: 2G band
* @REG_BAND_5G: 5G band
* @REG_BAND_6G: 6G band

Zobrazit soubor

@@ -169,6 +169,7 @@ uint16_t wlan_reg_min_6ghz_chan_freq(void);
*/
#define WLAN_REG_MAX_6GHZ_CHAN_FREQ wlan_reg_max_6ghz_chan_freq()
uint16_t wlan_reg_max_6ghz_chan_freq(void);
#else
#define WLAN_REG_IS_6GHZ_CHAN_FREQ(freq) (false)
@@ -212,6 +213,22 @@ wlan_reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev,
uint8_t band_mask,
struct regulatory_channel *channel_list);
/**
* wlan_reg_chan_band_to_freq - Return channel frequency based on the channel
* number and band.
* @pdev: pdev ptr
* @chan: Channel Number
* @band_mask: Bitmap for bands
*
* Return: Return channel frequency or return 0, if the channel is disabled or
* if the input channel number or band_mask is invalid. Composite bands are
* supported only for 2.4Ghz and 5Ghz bands. For other bands the following
* priority is given: 1) 6Ghz 2) 5Ghz 3) 2.4Ghz.
*/
uint16_t wlan_reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev,
uint8_t chan,
uint8_t band_mask);
/**
* wlan_reg_is_49ghz_freq() - Check if the given channel frequency is 4.9GHz
* @freq: Channel frequency
@@ -1062,5 +1079,13 @@ bool wlan_reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev,
* Return: true or false
*/
bool wlan_reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq);
/**
* wlan_reg_chan_to_band() - Get band from channel number
* @chan_num: channel number
*
* Return: wifi band
*/
enum reg_wifi_band wlan_reg_freq_to_band(uint16_t freq);
#endif /*CONFIG_CHAN_FREQ_API */
#endif

Zobrazit soubor

@@ -754,6 +754,7 @@ bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq)
{
return reg_is_6ghz_psc_chan_freq(freq);
}
#endif /* CONFIG_BAND_6GHZ */
uint16_t
@@ -769,6 +770,12 @@ wlan_reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev,
return reg_get_band_channel_list(pdev, band_mask, channel_list);
}
uint16_t wlan_reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev,
uint8_t chan, uint8_t band_mask)
{
return reg_chan_band_to_freq(pdev, chan, band_mask);
}
bool wlan_reg_is_49ghz_freq(uint32_t freq)
{
return reg_is_49ghz_freq(freq);
@@ -947,4 +954,9 @@ uint32_t wlan_reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev,
{
return reg_get_channel_reg_power_for_freq(pdev, freq);
}
enum reg_wifi_band wlan_reg_freq_to_band(uint16_t freq)
{
return reg_freq_to_band(freq);
}
#endif /* CONFIG CHAN FREQ API */