1
0
mirror of https://github.com/aircrack-ng/rtl8812au.git synced 2024-11-10 08:07:05 +00:00

Trying another channel switching code

This commit is contained in:
kimocoder 2019-04-07 18:46:13 +02:00
parent 54710f5403
commit aaef1baf31

View File

@ -3939,12 +3939,12 @@ int value;
value = dbm;
#endif
if (value < 0)
if (value < 0) {
value = 0;
if (value > 40)
}
if (value > 40) {
value = 40;
}
if (type == NL80211_TX_POWER_FIXED) {
pHalData->CurrentTxPwrIdx = value;
rtw_hal_set_tx_power_level(padapter, pHalData->current_channel);
@ -5710,104 +5710,48 @@ static int cfg80211_rtw_set_channel(struct wiphy *wiphy
return 0;
}
static int cfg80211_rtw_set_monitor_channel(struct wiphy *wiphy
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
, struct cfg80211_chan_def *chandef
#else
, struct ieee80211_channel *chan
, enum nl80211_channel_type channel_type
#endif
)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
/* TODO: 160 MHz bandwidth */
static int cfg80211_rtw_set_monitor_channel(struct wiphy *wiphy, struct cfg80211_chan_def *chandef)
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
struct ieee80211_channel *chan = chandef->chan;
#endif
int chan_target = (u8) ieee80211_frequency_to_channel(chandef->chan->center_freq);
int chan_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
int chan_width = CHANNEL_WIDTH_20;
_adapter *padapter = wiphy_to_adapter(wiphy);
int target_channal = chan->hw_value;
int target_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
int target_width = CHANNEL_WIDTH_20;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
#ifdef CONFIG_DEBUG_CFG80211
RTW_INFO("center_freq %u Mhz ch %u width %u freq1 %u freq2 %u\n"
, chan->center_freq
, chan->hw_value
, chandef->width
, chandef->center_freq1
, chandef->center_freq2);
#endif /* CONFIG_DEBUG_CFG80211 */
switch (chandef->width) {
case NL80211_CHAN_WIDTH_20_NOHT:
case NL80211_CHAN_WIDTH_20:
target_width = CHANNEL_WIDTH_20;
target_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
chan_width = CHANNEL_WIDTH_20;
chan_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
break;
case NL80211_CHAN_WIDTH_40:
target_width = CHANNEL_WIDTH_40;
if (chandef->center_freq1 > chan->center_freq)
target_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
chan_width = CHANNEL_WIDTH_40;
if (chandef->center_freq1 > chandef->chan->center_freq)
chan_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
else
target_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
chan_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
break;
case NL80211_CHAN_WIDTH_80:
target_width = CHANNEL_WIDTH_80;
target_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
break;
case NL80211_CHAN_WIDTH_80P80:
target_width = CHANNEL_WIDTH_80_80;
target_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
break;
case NL80211_CHAN_WIDTH_160:
target_width = CHANNEL_WIDTH_160;
target_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
break;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
case NL80211_CHAN_WIDTH_5:
case NL80211_CHAN_WIDTH_10:
#endif
default:
target_width = CHANNEL_WIDTH_20;
target_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
break;
}
#else
#ifdef CONFIG_DEBUG_CFG80211
RTW_INFO("center_freq %u Mhz ch %u channel_type %u\n"
, chan->center_freq
, chan->hw_value
, channel_type);
#endif /* CONFIG_DEBUG_CFG80211 */
switch (channel_type) {
case NL80211_CHAN_NO_HT:
case NL80211_CHAN_HT20:
target_width = CHANNEL_WIDTH_20;
target_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
break;
case NL80211_CHAN_HT40MINUS:
target_width = CHANNEL_WIDTH_40;
target_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
break;
case NL80211_CHAN_HT40PLUS:
target_width = CHANNEL_WIDTH_40;
target_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
chan_width = CHANNEL_WIDTH_80;
if (chandef->center_freq1 > chandef->chan->center_freq)
chan_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
else
chan_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
break;
default:
target_width = CHANNEL_WIDTH_20;
target_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
chan_width = CHANNEL_WIDTH_20;
chan_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
break;
}
#endif
RTW_INFO(FUNC_ADPT_FMT" ch:%d bw:%d, offset:%d\n"
, FUNC_ADPT_ARG(padapter), target_channal, target_width, target_offset);
rtw_set_chbw_cmd(padapter, target_channal, target_width, target_offset, RTW_CMDF_WAIT_ACK);
set_channel_bwmode(padapter, chan_target, chan_offset, chan_width);
RTW_INFO("%s : %d %d %d\n", __func__, chan_target, chan_offset, chan_width);
return 0;
}
#endif
static int cfg80211_rtw_auth(struct wiphy *wiphy, struct net_device *ndev,
struct cfg80211_auth_request *req)
@ -9514,6 +9458,9 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
.set_pmksa = cfg80211_rtw_set_pmksa,
.del_pmksa = cfg80211_rtw_del_pmksa,
.flush_pmksa = cfg80211_rtw_flush_pmksa,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
.set_monitor_channel = cfg80211_rtw_set_monitor_channel,
#endif
#ifdef CONFIG_AP_MODE
.add_virtual_intf = cfg80211_rtw_add_virtual_intf,