Restrict Kernel Version Check to Below 6.1.39
modifies the kernel version check in the source code to ensure compatibility with kernel versions below 6.1.39. The change was necessary due to the removal of the REGULATORY_IGNORE_STALE_KICKOFF flag in recent kernel versions, which caused compilation issues. The modified check now correctly excludes kernel versions 6.1.39 and above, preventing these issues. Reference: morrownr/88x2bu-20210702#165 (comment) Signed-off-by: thienandangthanh <thienandangthanh@gmail.com>
This commit is contained in:
parent
163badb456
commit
c2a6210883
|
@ -1,414 +1,414 @@
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* Copyright(c) 2009-2010 - 2017 Realtek Corporation.
|
* Copyright(c) 2009-2010 - 2017 Realtek Corporation.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of version 2 of the GNU General Public License as
|
* under the terms of version 2 of the GNU General Public License as
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
* more details.
|
* more details.
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <drv_types.h>
|
#include <drv_types.h>
|
||||||
|
|
||||||
#ifdef CONFIG_IOCTL_CFG80211
|
#ifdef CONFIG_IOCTL_CFG80211
|
||||||
static void rtw_regd_overide_flags(struct wiphy *wiphy, struct rf_ctl_t *rfctl)
|
static void rtw_regd_overide_flags(struct wiphy *wiphy, struct rf_ctl_t *rfctl)
|
||||||
{
|
{
|
||||||
RT_CHANNEL_INFO *channel_set = rfctl->channel_set;
|
RT_CHANNEL_INFO *channel_set = rfctl->channel_set;
|
||||||
u8 max_chan_nums = rfctl->max_chan_nums;
|
u8 max_chan_nums = rfctl->max_chan_nums;
|
||||||
struct ieee80211_supported_band *sband;
|
struct ieee80211_supported_band *sband;
|
||||||
struct ieee80211_channel *ch;
|
struct ieee80211_channel *ch;
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
u16 channel;
|
u16 channel;
|
||||||
u32 freq;
|
u32 freq;
|
||||||
|
|
||||||
/* all channels disable */
|
/* all channels disable */
|
||||||
for (i = 0; i < NUM_NL80211_BANDS; i++) {
|
for (i = 0; i < NUM_NL80211_BANDS; i++) {
|
||||||
sband = wiphy->bands[i];
|
sband = wiphy->bands[i];
|
||||||
if (!sband)
|
if (!sband)
|
||||||
continue;
|
continue;
|
||||||
for (j = 0; j < sband->n_channels; j++) {
|
for (j = 0; j < sband->n_channels; j++) {
|
||||||
ch = &sband->channels[j];
|
ch = &sband->channels[j];
|
||||||
if (!ch)
|
if (!ch)
|
||||||
continue;
|
continue;
|
||||||
ch->flags = IEEE80211_CHAN_DISABLED;
|
ch->flags = IEEE80211_CHAN_DISABLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* channels apply by channel plans. */
|
/* channels apply by channel plans. */
|
||||||
for (i = 0; i < max_chan_nums; i++) {
|
for (i = 0; i < max_chan_nums; i++) {
|
||||||
channel = channel_set[i].ChannelNum;
|
channel = channel_set[i].ChannelNum;
|
||||||
freq = rtw_ch2freq(channel);
|
freq = rtw_ch2freq(channel);
|
||||||
ch = ieee80211_get_channel(wiphy, freq);
|
ch = ieee80211_get_channel(wiphy, freq);
|
||||||
if (!ch) {
|
if (!ch) {
|
||||||
rtw_warn_on(1);
|
rtw_warn_on(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enable */
|
/* enable */
|
||||||
ch->flags = 0;
|
ch->flags = 0;
|
||||||
|
|
||||||
if (channel_set[i].flags & RTW_CHF_DFS) {
|
if (channel_set[i].flags & RTW_CHF_DFS) {
|
||||||
/*
|
/*
|
||||||
* before integrating with nl80211 flow
|
* before integrating with nl80211 flow
|
||||||
* bypass IEEE80211_CHAN_RADAR when configured with radar detection
|
* bypass IEEE80211_CHAN_RADAR when configured with radar detection
|
||||||
* to prevent from hostapd blocking DFS channels
|
* to prevent from hostapd blocking DFS channels
|
||||||
*/
|
*/
|
||||||
if (rtw_rfctl_dfs_domain_unknown(rfctl))
|
if (rtw_rfctl_dfs_domain_unknown(rfctl))
|
||||||
ch->flags |= IEEE80211_CHAN_RADAR;
|
ch->flags |= IEEE80211_CHAN_RADAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel_set[i].flags & RTW_CHF_NO_IR) {
|
if (channel_set[i].flags & RTW_CHF_NO_IR) {
|
||||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
|
||||||
ch->flags |= IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_PASSIVE_SCAN;
|
ch->flags |= IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_PASSIVE_SCAN;
|
||||||
#else
|
#else
|
||||||
ch->flags |= IEEE80211_CHAN_NO_IR;
|
ch->flags |= IEEE80211_CHAN_NO_IR;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_REGD_SRC_FROM_OS
|
#ifdef CONFIG_REGD_SRC_FROM_OS
|
||||||
static void rtw_regd_apply_dfs_flags(struct rf_ctl_t *rfctl)
|
static void rtw_regd_apply_dfs_flags(struct rf_ctl_t *rfctl)
|
||||||
{
|
{
|
||||||
RT_CHANNEL_INFO *channel_set = rfctl->channel_set;
|
RT_CHANNEL_INFO *channel_set = rfctl->channel_set;
|
||||||
u8 max_chan_nums = rfctl->max_chan_nums;
|
u8 max_chan_nums = rfctl->max_chan_nums;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct ieee80211_channel *chan;
|
struct ieee80211_channel *chan;
|
||||||
|
|
||||||
/* channels apply by channel plans. */
|
/* channels apply by channel plans. */
|
||||||
for (i = 0; i < max_chan_nums; i++) {
|
for (i = 0; i < max_chan_nums; i++) {
|
||||||
chan = channel_set[i].os_chan;
|
chan = channel_set[i].os_chan;
|
||||||
if (channel_set[i].flags & RTW_CHF_DFS) {
|
if (channel_set[i].flags & RTW_CHF_DFS) {
|
||||||
/*
|
/*
|
||||||
* before integrating with nl80211 flow
|
* before integrating with nl80211 flow
|
||||||
* clear IEEE80211_CHAN_RADAR when configured with radar detection
|
* clear IEEE80211_CHAN_RADAR when configured with radar detection
|
||||||
* to prevent from hostapd blocking DFS channels
|
* to prevent from hostapd blocking DFS channels
|
||||||
*/
|
*/
|
||||||
if (!rtw_rfctl_dfs_domain_unknown(rfctl))
|
if (!rtw_rfctl_dfs_domain_unknown(rfctl))
|
||||||
chan->flags &= ~IEEE80211_CHAN_RADAR;
|
chan->flags &= ~IEEE80211_CHAN_RADAR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void rtw_regd_apply_flags(struct wiphy *wiphy)
|
void rtw_regd_apply_flags(struct wiphy *wiphy)
|
||||||
{
|
{
|
||||||
struct dvobj_priv *dvobj = wiphy_to_dvobj(wiphy);
|
struct dvobj_priv *dvobj = wiphy_to_dvobj(wiphy);
|
||||||
struct rf_ctl_t *rfctl = dvobj_to_rfctl(dvobj);
|
struct rf_ctl_t *rfctl = dvobj_to_rfctl(dvobj);
|
||||||
|
|
||||||
if (rfctl->regd_src == REGD_SRC_RTK_PRIV)
|
if (rfctl->regd_src == REGD_SRC_RTK_PRIV)
|
||||||
rtw_regd_overide_flags(wiphy, rfctl);
|
rtw_regd_overide_flags(wiphy, rfctl);
|
||||||
#ifdef CONFIG_REGD_SRC_FROM_OS
|
#ifdef CONFIG_REGD_SRC_FROM_OS
|
||||||
else if (rfctl->regd_src == REGD_SRC_OS)
|
else if (rfctl->regd_src == REGD_SRC_OS)
|
||||||
rtw_regd_apply_dfs_flags(rfctl);
|
rtw_regd_apply_dfs_flags(rfctl);
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
rtw_warn_on(1);
|
rtw_warn_on(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_REGD_SRC_FROM_OS
|
#ifdef CONFIG_REGD_SRC_FROM_OS
|
||||||
/* init_channel_set_from_wiphy */
|
/* init_channel_set_from_wiphy */
|
||||||
u8 rtw_os_init_channel_set(_adapter *padapter, RT_CHANNEL_INFO *channel_set)
|
u8 rtw_os_init_channel_set(_adapter *padapter, RT_CHANNEL_INFO *channel_set)
|
||||||
{
|
{
|
||||||
struct wiphy *wiphy = adapter_to_wiphy(padapter);
|
struct wiphy *wiphy = adapter_to_wiphy(padapter);
|
||||||
struct rf_ctl_t *rfctl = adapter_to_rfctl(padapter);
|
struct rf_ctl_t *rfctl = adapter_to_rfctl(padapter);
|
||||||
struct registry_priv *regsty = adapter_to_regsty(padapter);
|
struct registry_priv *regsty = adapter_to_regsty(padapter);
|
||||||
struct ieee80211_channel *chan;
|
struct ieee80211_channel *chan;
|
||||||
u8 chanset_size = 0;
|
u8 chanset_size = 0;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
_rtw_memset(channel_set, 0, sizeof(RT_CHANNEL_INFO) * MAX_CHANNEL_NUM);
|
_rtw_memset(channel_set, 0, sizeof(RT_CHANNEL_INFO) * MAX_CHANNEL_NUM);
|
||||||
|
|
||||||
for (i = NL80211_BAND_2GHZ; i <= NL80211_BAND_5GHZ; i++) {
|
for (i = NL80211_BAND_2GHZ; i <= NL80211_BAND_5GHZ; i++) {
|
||||||
if (!wiphy->bands[i])
|
if (!wiphy->bands[i])
|
||||||
continue;
|
continue;
|
||||||
for (j = 0; j < wiphy->bands[i]->n_channels; j++) {
|
for (j = 0; j < wiphy->bands[i]->n_channels; j++) {
|
||||||
chan = &wiphy->bands[i]->channels[j];
|
chan = &wiphy->bands[i]->channels[j];
|
||||||
if (chan->flags & IEEE80211_CHAN_DISABLED)
|
if (chan->flags & IEEE80211_CHAN_DISABLED)
|
||||||
continue;
|
continue;
|
||||||
if (rtw_regsty_is_excl_chs(regsty, chan->hw_value))
|
if (rtw_regsty_is_excl_chs(regsty, chan->hw_value))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (chanset_size >= MAX_CHANNEL_NUM) {
|
if (chanset_size >= MAX_CHANNEL_NUM) {
|
||||||
RTW_WARN("chset size can't exceed MAX_CHANNEL_NUM(%u)\n", MAX_CHANNEL_NUM);
|
RTW_WARN("chset size can't exceed MAX_CHANNEL_NUM(%u)\n", MAX_CHANNEL_NUM);
|
||||||
i = NL80211_BAND_5GHZ + 1;
|
i = NL80211_BAND_5GHZ + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel_set[chanset_size].ChannelNum = chan->hw_value;
|
channel_set[chanset_size].ChannelNum = chan->hw_value;
|
||||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
|
||||||
if (chan->flags & (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_PASSIVE_SCAN))
|
if (chan->flags & (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_PASSIVE_SCAN))
|
||||||
#else
|
#else
|
||||||
if (chan->flags & IEEE80211_CHAN_NO_IR)
|
if (chan->flags & IEEE80211_CHAN_NO_IR)
|
||||||
#endif
|
#endif
|
||||||
channel_set[chanset_size].flags |= RTW_CHF_NO_IR;
|
channel_set[chanset_size].flags |= RTW_CHF_NO_IR;
|
||||||
if (chan->flags & IEEE80211_CHAN_RADAR)
|
if (chan->flags & IEEE80211_CHAN_RADAR)
|
||||||
channel_set[chanset_size].flags |= RTW_CHF_DFS;
|
channel_set[chanset_size].flags |= RTW_CHF_DFS;
|
||||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
|
||||||
if (chan->flags & IEEE80211_CHAN_NO_HT40PLUS)
|
if (chan->flags & IEEE80211_CHAN_NO_HT40PLUS)
|
||||||
channel_set[chanset_size].flags |= RTW_CHF_NO_HT40U;
|
channel_set[chanset_size].flags |= RTW_CHF_NO_HT40U;
|
||||||
if (chan->flags & IEEE80211_CHAN_NO_HT40MINUS)
|
if (chan->flags & IEEE80211_CHAN_NO_HT40MINUS)
|
||||||
channel_set[chanset_size].flags |= RTW_CHF_NO_HT40L;
|
channel_set[chanset_size].flags |= RTW_CHF_NO_HT40L;
|
||||||
#endif
|
#endif
|
||||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
|
||||||
if (chan->flags & IEEE80211_CHAN_NO_80MHZ)
|
if (chan->flags & IEEE80211_CHAN_NO_80MHZ)
|
||||||
channel_set[chanset_size].flags |= RTW_CHF_NO_80MHZ;
|
channel_set[chanset_size].flags |= RTW_CHF_NO_80MHZ;
|
||||||
if (chan->flags & IEEE80211_CHAN_NO_160MHZ)
|
if (chan->flags & IEEE80211_CHAN_NO_160MHZ)
|
||||||
channel_set[chanset_size].flags |= RTW_CHF_NO_160MHZ;
|
channel_set[chanset_size].flags |= RTW_CHF_NO_160MHZ;
|
||||||
#endif
|
#endif
|
||||||
channel_set[chanset_size].os_chan = chan;
|
channel_set[chanset_size].os_chan = chan;
|
||||||
chanset_size++;
|
chanset_size++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_IEEE80211_BAND_5GHZ
|
#if CONFIG_IEEE80211_BAND_5GHZ
|
||||||
#ifdef CONFIG_DFS_MASTER
|
#ifdef CONFIG_DFS_MASTER
|
||||||
for (i = 0; i < chanset_size; i++)
|
for (i = 0; i < chanset_size; i++)
|
||||||
channel_set[i].non_ocp_end_time = rtw_get_current_time();
|
channel_set[i].non_ocp_end_time = rtw_get_current_time();
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_IEEE80211_BAND_5GHZ */
|
#endif /* CONFIG_IEEE80211_BAND_5GHZ */
|
||||||
|
|
||||||
if (chanset_size)
|
if (chanset_size)
|
||||||
RTW_INFO(FUNC_ADPT_FMT" ch num:%d\n"
|
RTW_INFO(FUNC_ADPT_FMT" ch num:%d\n"
|
||||||
, FUNC_ADPT_ARG(padapter), chanset_size);
|
, FUNC_ADPT_ARG(padapter), chanset_size);
|
||||||
else
|
else
|
||||||
RTW_WARN(FUNC_ADPT_FMT" final chset has no channel\n"
|
RTW_WARN(FUNC_ADPT_FMT" final chset has no channel\n"
|
||||||
, FUNC_ADPT_ARG(padapter));
|
, FUNC_ADPT_ARG(padapter));
|
||||||
|
|
||||||
return chanset_size;
|
return chanset_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
s16 rtw_os_get_total_txpwr_regd_lmt_mbm(_adapter *adapter, u8 cch, enum channel_width bw)
|
s16 rtw_os_get_total_txpwr_regd_lmt_mbm(_adapter *adapter, u8 cch, enum channel_width bw)
|
||||||
{
|
{
|
||||||
struct wiphy *wiphy = adapter_to_wiphy(adapter);
|
struct wiphy *wiphy = adapter_to_wiphy(adapter);
|
||||||
s16 mbm = UNSPECIFIED_MBM;
|
s16 mbm = UNSPECIFIED_MBM;
|
||||||
u8 *op_chs;
|
u8 *op_chs;
|
||||||
u8 op_ch_num;
|
u8 op_ch_num;
|
||||||
u8 i;
|
u8 i;
|
||||||
u32 freq;
|
u32 freq;
|
||||||
struct ieee80211_channel *ch;
|
struct ieee80211_channel *ch;
|
||||||
|
|
||||||
if (!rtw_get_op_chs_by_cch_bw(cch, bw, &op_chs, &op_ch_num))
|
if (!rtw_get_op_chs_by_cch_bw(cch, bw, &op_chs, &op_ch_num))
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
for (i = 0; i < op_ch_num; i++) {
|
for (i = 0; i < op_ch_num; i++) {
|
||||||
freq = rtw_ch2freq(op_chs[i]);
|
freq = rtw_ch2freq(op_chs[i]);
|
||||||
ch = ieee80211_get_channel(wiphy, freq);
|
ch = ieee80211_get_channel(wiphy, freq);
|
||||||
if (!ch) {
|
if (!ch) {
|
||||||
rtw_warn_on(1);
|
rtw_warn_on(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0))
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0))
|
||||||
mbm = rtw_min(mbm, ch->max_reg_power * MBM_PDBM);
|
mbm = rtw_min(mbm, ch->max_reg_power * MBM_PDBM);
|
||||||
#else
|
#else
|
||||||
/* require max_power == 0 (therefore orig_mpwr set to 0) when wiphy registration */
|
/* require max_power == 0 (therefore orig_mpwr set to 0) when wiphy registration */
|
||||||
mbm = rtw_min(mbm, ch->max_power * MBM_PDBM);
|
mbm = rtw_min(mbm, ch->max_power * MBM_PDBM);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return mbm;
|
return mbm;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0))
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0))
|
||||||
static enum rtw_dfs_regd nl80211_dfs_regions_to_rtw_dfs_region(enum nl80211_dfs_regions region)
|
static enum rtw_dfs_regd nl80211_dfs_regions_to_rtw_dfs_region(enum nl80211_dfs_regions region)
|
||||||
{
|
{
|
||||||
switch (region) {
|
switch (region) {
|
||||||
case NL80211_DFS_FCC:
|
case NL80211_DFS_FCC:
|
||||||
return RTW_DFS_REGD_FCC;
|
return RTW_DFS_REGD_FCC;
|
||||||
case NL80211_DFS_ETSI:
|
case NL80211_DFS_ETSI:
|
||||||
return RTW_DFS_REGD_ETSI;
|
return RTW_DFS_REGD_ETSI;
|
||||||
case NL80211_DFS_JP:
|
case NL80211_DFS_JP:
|
||||||
return RTW_DFS_REGD_MKK;
|
return RTW_DFS_REGD_MKK;
|
||||||
case NL80211_DFS_UNSET:
|
case NL80211_DFS_UNSET:
|
||||||
default:
|
default:
|
||||||
return RTW_DFS_REGD_NONE;
|
return RTW_DFS_REGD_NONE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)) */
|
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)) */
|
||||||
#endif /* CONFIG_REGD_SRC_FROM_OS */
|
#endif /* CONFIG_REGD_SRC_FROM_OS */
|
||||||
|
|
||||||
#ifdef CONFIG_RTW_DEBUG
|
#ifdef CONFIG_RTW_DEBUG
|
||||||
static const char *nl80211_reg_initiator_str(enum nl80211_reg_initiator initiator)
|
static const char *nl80211_reg_initiator_str(enum nl80211_reg_initiator initiator)
|
||||||
{
|
{
|
||||||
switch (initiator) {
|
switch (initiator) {
|
||||||
case NL80211_REGDOM_SET_BY_DRIVER:
|
case NL80211_REGDOM_SET_BY_DRIVER:
|
||||||
return "DRIVER";
|
return "DRIVER";
|
||||||
case NL80211_REGDOM_SET_BY_CORE:
|
case NL80211_REGDOM_SET_BY_CORE:
|
||||||
return "CORE";
|
return "CORE";
|
||||||
case NL80211_REGDOM_SET_BY_USER:
|
case NL80211_REGDOM_SET_BY_USER:
|
||||||
return "USER";
|
return "USER";
|
||||||
case NL80211_REGDOM_SET_BY_COUNTRY_IE:
|
case NL80211_REGDOM_SET_BY_COUNTRY_IE:
|
||||||
return "COUNTRY_IE";
|
return "COUNTRY_IE";
|
||||||
}
|
}
|
||||||
rtw_warn_on(1);
|
rtw_warn_on(1);
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
|
||||||
static const char *nl80211_user_reg_hint_type_str(enum nl80211_user_reg_hint_type type)
|
static const char *nl80211_user_reg_hint_type_str(enum nl80211_user_reg_hint_type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NL80211_USER_REG_HINT_USER:
|
case NL80211_USER_REG_HINT_USER:
|
||||||
return "USER";
|
return "USER";
|
||||||
case NL80211_USER_REG_HINT_CELL_BASE:
|
case NL80211_USER_REG_HINT_CELL_BASE:
|
||||||
return "CELL_BASE";
|
return "CELL_BASE";
|
||||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
|
||||||
case NL80211_USER_REG_HINT_INDOOR:
|
case NL80211_USER_REG_HINT_INDOOR:
|
||||||
return "INDOOR";
|
return "INDOOR";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
rtw_warn_on(1);
|
rtw_warn_on(1);
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0))
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0))
|
||||||
static const char *nl80211_dfs_regions_str(enum nl80211_dfs_regions region)
|
static const char *nl80211_dfs_regions_str(enum nl80211_dfs_regions region)
|
||||||
{
|
{
|
||||||
switch (region) {
|
switch (region) {
|
||||||
case NL80211_DFS_UNSET:
|
case NL80211_DFS_UNSET:
|
||||||
return "UNSET";
|
return "UNSET";
|
||||||
case NL80211_DFS_FCC:
|
case NL80211_DFS_FCC:
|
||||||
return "FCC";
|
return "FCC";
|
||||||
case NL80211_DFS_ETSI:
|
case NL80211_DFS_ETSI:
|
||||||
return "ETSI";
|
return "ETSI";
|
||||||
case NL80211_DFS_JP:
|
case NL80211_DFS_JP:
|
||||||
return "JP";
|
return "JP";
|
||||||
}
|
}
|
||||||
rtw_warn_on(1);
|
rtw_warn_on(1);
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
};
|
};
|
||||||
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)) */
|
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)) */
|
||||||
|
|
||||||
static const char *environment_cap_str(enum environment_cap cap)
|
static const char *environment_cap_str(enum environment_cap cap)
|
||||||
{
|
{
|
||||||
switch (cap) {
|
switch (cap) {
|
||||||
case ENVIRON_ANY:
|
case ENVIRON_ANY:
|
||||||
return "ANY";
|
return "ANY";
|
||||||
case ENVIRON_INDOOR:
|
case ENVIRON_INDOOR:
|
||||||
return "INDOOR";
|
return "INDOOR";
|
||||||
case ENVIRON_OUTDOOR:
|
case ENVIRON_OUTDOOR:
|
||||||
return "OUTDOOR";
|
return "OUTDOOR";
|
||||||
}
|
}
|
||||||
rtw_warn_on(1);
|
rtw_warn_on(1);
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dump_requlatory_request(void *sel, struct regulatory_request *request)
|
static void dump_requlatory_request(void *sel, struct regulatory_request *request)
|
||||||
{
|
{
|
||||||
u8 alpha2_len;
|
u8 alpha2_len;
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0))
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0))
|
||||||
alpha2_len = 3;
|
alpha2_len = 3;
|
||||||
#else
|
#else
|
||||||
alpha2_len = 2;
|
alpha2_len = 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
|
||||||
RTW_PRINT_SEL(sel, "initiator:%s, wiphy_idx:%d, type:%s\n"
|
RTW_PRINT_SEL(sel, "initiator:%s, wiphy_idx:%d, type:%s\n"
|
||||||
, nl80211_reg_initiator_str(request->initiator)
|
, nl80211_reg_initiator_str(request->initiator)
|
||||||
, request->wiphy_idx
|
, request->wiphy_idx
|
||||||
, nl80211_user_reg_hint_type_str(request->user_reg_hint_type));
|
, nl80211_user_reg_hint_type_str(request->user_reg_hint_type));
|
||||||
#else
|
#else
|
||||||
RTW_PRINT_SEL(sel, "initiator:%s, wiphy_idx:%d\n"
|
RTW_PRINT_SEL(sel, "initiator:%s, wiphy_idx:%d\n"
|
||||||
, nl80211_reg_initiator_str(request->initiator)
|
, nl80211_reg_initiator_str(request->initiator)
|
||||||
, request->wiphy_idx);
|
, request->wiphy_idx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RTW_PRINT_SEL(sel, "alpha2:%.*s\n", alpha2_len, request->alpha2);
|
RTW_PRINT_SEL(sel, "alpha2:%.*s\n", alpha2_len, request->alpha2);
|
||||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0))
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0))
|
||||||
RTW_PRINT_SEL(sel, "dfs_region:%s\n", nl80211_dfs_regions_str(request->dfs_region));
|
RTW_PRINT_SEL(sel, "dfs_region:%s\n", nl80211_dfs_regions_str(request->dfs_region));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RTW_PRINT_SEL(sel, "intersect:%d\n", request->intersect);
|
RTW_PRINT_SEL(sel, "intersect:%d\n", request->intersect);
|
||||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38))
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38))
|
||||||
RTW_PRINT_SEL(sel, "processed:%d\n", request->processed);
|
RTW_PRINT_SEL(sel, "processed:%d\n", request->processed);
|
||||||
#endif
|
#endif
|
||||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36))
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36))
|
||||||
RTW_PRINT_SEL(sel, "country_ie_checksum:0x%08x\n", request->country_ie_checksum);
|
RTW_PRINT_SEL(sel, "country_ie_checksum:0x%08x\n", request->country_ie_checksum);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RTW_PRINT_SEL(sel, "country_ie_env:%s\n", environment_cap_str(request->country_ie_env));
|
RTW_PRINT_SEL(sel, "country_ie_env:%s\n", environment_cap_str(request->country_ie_env));
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_RTW_DEBUG */
|
#endif /* CONFIG_RTW_DEBUG */
|
||||||
|
|
||||||
static void rtw_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
|
static void rtw_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
|
||||||
{
|
{
|
||||||
struct dvobj_priv *dvobj = wiphy_to_dvobj(wiphy);
|
struct dvobj_priv *dvobj = wiphy_to_dvobj(wiphy);
|
||||||
struct rf_ctl_t *rfctl = dvobj_to_rfctl(dvobj);
|
struct rf_ctl_t *rfctl = dvobj_to_rfctl(dvobj);
|
||||||
struct registry_priv *regsty = dvobj_to_regsty(dvobj);
|
struct registry_priv *regsty = dvobj_to_regsty(dvobj);
|
||||||
|
|
||||||
#ifdef CONFIG_RTW_DEBUG
|
#ifdef CONFIG_RTW_DEBUG
|
||||||
if (rtw_drv_log_level >= _DRV_INFO_) {
|
if (rtw_drv_log_level >= _DRV_INFO_) {
|
||||||
RTW_INFO(FUNC_WIPHY_FMT"\n", FUNC_WIPHY_ARG(wiphy));
|
RTW_INFO(FUNC_WIPHY_FMT"\n", FUNC_WIPHY_ARG(wiphy));
|
||||||
dump_requlatory_request(RTW_DBGDUMP, request);
|
dump_requlatory_request(RTW_DBGDUMP, request);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_REGD_SRC_FROM_OS
|
#ifdef CONFIG_REGD_SRC_FROM_OS
|
||||||
if (REGSTY_REGD_SRC_FROM_OS(regsty)) {
|
if (REGSTY_REGD_SRC_FROM_OS(regsty)) {
|
||||||
enum rtw_dfs_regd dfs_region = RTW_DFS_REGD_NONE;
|
enum rtw_dfs_regd dfs_region = RTW_DFS_REGD_NONE;
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0))
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0))
|
||||||
dfs_region = nl80211_dfs_regions_to_rtw_dfs_region(request->dfs_region);
|
dfs_region = nl80211_dfs_regions_to_rtw_dfs_region(request->dfs_region);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* trigger command to sync regulatory form OS */
|
/* trigger command to sync regulatory form OS */
|
||||||
rtw_sync_os_regd_cmd(wiphy_to_adapter(wiphy), RTW_CMDF_WAIT_ACK, request->alpha2, dfs_region);
|
rtw_sync_os_regd_cmd(wiphy_to_adapter(wiphy), RTW_CMDF_WAIT_ACK, request->alpha2, dfs_region);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* use alpha2 as input to select the corresponding channel plan settings defined by Realtek */
|
/* use alpha2 as input to select the corresponding channel plan settings defined by Realtek */
|
||||||
switch (request->initiator) {
|
switch (request->initiator) {
|
||||||
case NL80211_REGDOM_SET_BY_DRIVER:
|
case NL80211_REGDOM_SET_BY_DRIVER:
|
||||||
break;
|
break;
|
||||||
case NL80211_REGDOM_SET_BY_CORE:
|
case NL80211_REGDOM_SET_BY_CORE:
|
||||||
break;
|
break;
|
||||||
case NL80211_REGDOM_SET_BY_USER:
|
case NL80211_REGDOM_SET_BY_USER:
|
||||||
rtw_set_country(wiphy_to_adapter(wiphy), request->alpha2);
|
rtw_set_country(wiphy_to_adapter(wiphy), request->alpha2);
|
||||||
break;
|
break;
|
||||||
case NL80211_REGDOM_SET_BY_COUNTRY_IE:
|
case NL80211_REGDOM_SET_BY_COUNTRY_IE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rtw_regd_apply_flags(wiphy);
|
rtw_regd_apply_flags(wiphy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
|
||||||
static int rtw_reg_notifier_return(struct wiphy *wiphy, struct regulatory_request *request)
|
static int rtw_reg_notifier_return(struct wiphy *wiphy, struct regulatory_request *request)
|
||||||
{
|
{
|
||||||
rtw_reg_notifier(wiphy, request);
|
rtw_reg_notifier(wiphy, request);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int rtw_regd_init(struct wiphy *wiphy)
|
int rtw_regd_init(struct wiphy *wiphy)
|
||||||
{
|
{
|
||||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
|
||||||
wiphy->reg_notifier = rtw_reg_notifier_return;
|
wiphy->reg_notifier = rtw_reg_notifier_return;
|
||||||
#else
|
#else
|
||||||
wiphy->reg_notifier = rtw_reg_notifier;
|
wiphy->reg_notifier = rtw_reg_notifier;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
|
||||||
wiphy->flags &= ~WIPHY_FLAG_STRICT_REGULATORY;
|
wiphy->flags &= ~WIPHY_FLAG_STRICT_REGULATORY;
|
||||||
wiphy->flags &= ~WIPHY_FLAG_DISABLE_BEACON_HINTS;
|
wiphy->flags &= ~WIPHY_FLAG_DISABLE_BEACON_HINTS;
|
||||||
#else
|
#else
|
||||||
wiphy->regulatory_flags &= ~REGULATORY_STRICT_REG;
|
wiphy->regulatory_flags &= ~REGULATORY_STRICT_REG;
|
||||||
wiphy->regulatory_flags &= ~REGULATORY_DISABLE_BEACON_HINTS;
|
wiphy->regulatory_flags &= ~REGULATORY_DISABLE_BEACON_HINTS;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0))
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 39))
|
||||||
wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
|
wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_IOCTL_CFG80211 */
|
#endif /* CONFIG_IOCTL_CFG80211 */
|
||||||
|
|
Loading…
Reference in New Issue