1
0
mirror of https://github.com/aircrack-ng/rtl8812au.git synced 2024-11-26 07:04:12 +00:00

Merge pull request #823 from astsam2/v5.6.4.2

Add ability to get the current channel by iw utility
This commit is contained in:
Christian Bremvåg 2021-02-03 13:55:29 +01:00 committed by GitHub
commit b65dcf4105
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 172 additions and 24 deletions

View File

@ -51,6 +51,8 @@ u8 op_chs_of_cch_2g_40m[CENTER_CH_2G_40M_NUM][2] = {
};
u8 center_ch_5g_all[CENTER_CH_5G_ALL_NUM] = {
15, 16, 17, 18,
20, 24, 28, 32,
/* G00 */36, 38, 40,
42,
/* G01 */44, 46, 48,
@ -58,6 +60,8 @@ u8 center_ch_5g_all[CENTER_CH_5G_ALL_NUM] = {
/* G02 */52, 54, 56,
58,
/* G03 */60, 62, 64,
68, 72, 76, 80,
84, 88, 92, 96,
/* G04 */100, 102, 104,
106,
/* G05 */108, 110, 112,
@ -78,10 +82,14 @@ u8 center_ch_5g_all[CENTER_CH_5G_ALL_NUM] = {
};
u8 center_ch_5g_20m[CENTER_CH_5G_20M_NUM] = {
15, 16, 17, 18,
20, 24, 28, 32,
/* G00 */36, 40,
/* G01 */44, 48,
/* G02 */52, 56,
/* G03 */60, 64,
68, 72, 76, 80,
84, 88, 92, 96,
/* G04 */100, 104,
/* G05 */108, 112,
/* G06 */116, 120,
@ -111,6 +119,7 @@ u8 center_ch_5g_40m[CENTER_CH_5G_40M_NUM] = {
/* G13 */175
};
#if 0
u8 center_ch_5g_20m_40m[CENTER_CH_5G_20M_NUM + CENTER_CH_5G_40M_NUM] = {
/* G00 */36, 38, 40,
/* G01 */44, 46, 48,
@ -127,6 +136,7 @@ u8 center_ch_5g_20m_40m[CENTER_CH_5G_20M_NUM + CENTER_CH_5G_40M_NUM] = {
/* G12 */165, 167, 169,
/* G13 */173, 175, 177
};
#endif
u8 op_chs_of_cch_5g_40m[CENTER_CH_5G_40M_NUM][2] = {
{36, 40}, /* 38 */
@ -376,15 +386,15 @@ u8 rtw_get_ch_group(u8 ch, u8 *group, u8 *cck_group)
} else {
band = BAND_ON_5G;
if (36 <= ch && ch <= 42)
if (15 <= ch && ch <= 42)
gp = 0;
else if (44 <= ch && ch <= 48)
gp = 1;
else if (50 <= ch && ch <= 58)
gp = 2;
else if (60 <= ch && ch <= 64)
else if (60 <= ch && ch <= 80)
gp = 3;
else if (100 <= ch && ch <= 106)
else if (82 <= ch && ch <= 106)
gp = 4;
else if (108 <= ch && ch <= 114)
gp = 5;

View File

@ -595,7 +595,6 @@ void set_channel_bwmode(_adapter *padapter, unsigned char channel, unsigned char
RTW_INFO("[%s] ch = %d, offset = %d, bwmode = %d\n", __func__, channel, channel_offset, bwmode);
center_ch = rtw_get_center_ch(channel, bwmode, channel_offset);
if (bwmode == CHANNEL_WIDTH_80) {
if (center_ch > channel)
chnl_offset80 = HAL_PRIME_CHNL_OFFSET_LOWER;

View File

@ -4452,14 +4452,6 @@ s32 rtw_monitor_xmit_entry(struct sk_buff *skb, struct net_device *ndev)
// so we can directly apply overrides rather than cache all the values into
// variables and apply them later.
// In just a bit we will attempt to take a pointer to the wlan hdr. If the remaining bytes
// are less than a full header, we will technically be reading random bytes. So this is a
// guard check to ensure there is a full minimum frame to read before we alloc and proceed
// to read.
if (unlikely(len < sizeof(struct rtw_ieee80211_hdr))) {
goto fail;
}
// Process rest of frame
alloc_delay = 100;
for (alloc_tries=3; alloc_tries > 0; alloc_tries--) {

View File

@ -1071,7 +1071,6 @@ void phydm_phy_sts_n_parsing(struct dm_struct *dm,
#endif
#if ODM_IC_11AC_SERIES_SUPPORT
void phydm_rx_physts_bw_parsing(struct phydm_phyinfo_struct *phy_info,
struct phydm_perpkt_info_struct *
pktinfo,
@ -1189,6 +1188,16 @@ void phydm_rx_physts_1st_type(struct dm_struct *dm,
phy_info->rx_pwdb_all = rssi;
phy_info->rx_mimo_signal_strength[0] = rssi;
// fill per path rx power info
for (i = RF_PATH_A; i < dm->num_rf_path; i++) {
if (i < RF_PATH_C)
val = phy_sts->gain_trsw[i];
else
val = phy_sts->gain_trsw_cd[i - 2];
phy_info->rx_pwr[i] = (val & 0x7F) - 110;
}
} else {
/* @== [OFDM rate] ===================================================*/
for (i = RF_PATH_A; i < dm->num_rf_path; i++) {

View File

@ -1798,9 +1798,11 @@ phy_SwChnl8812(
/* fc_area */
if (36 <= channelToSW && channelToSW <= 48)
phy_set_bb_reg(pAdapter, rFc_area_Jaguar, 0x1ffe0000, 0x494);
else if (50 <= channelToSW && channelToSW <= 64)
else if (15 <= channelToSW && channelToSW <= 35)
phy_set_bb_reg(pAdapter, rFc_area_Jaguar, 0x1ffe0000, 0x494);
else if (50 <= channelToSW && channelToSW <= 80)
phy_set_bb_reg(pAdapter, rFc_area_Jaguar, 0x1ffe0000, 0x453);
else if (100 <= channelToSW && channelToSW <= 116)
else if (82 <= channelToSW && channelToSW <= 116)
phy_set_bb_reg(pAdapter, rFc_area_Jaguar, 0x1ffe0000, 0x452);
else if (118 <= channelToSW)
phy_set_bb_reg(pAdapter, rFc_area_Jaguar, 0x1ffe0000, 0x412);
@ -1809,9 +1811,11 @@ phy_SwChnl8812(
for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) {
/* RF_MOD_AG */
if (36 <= channelToSW && channelToSW <= 64)
if (36 <= channelToSW && channelToSW <= 80)
phy_set_rf_reg(pAdapter, eRFPath, RF_CHNLBW_Jaguar, BIT18 | BIT17 | BIT16 | BIT9 | BIT8, 0x101); /* 5'b00101); */
else if (100 <= channelToSW && channelToSW <= 140)
else if (15 <= channelToSW && channelToSW <= 35)
phy_set_rf_reg(pAdapter, eRFPath, RF_CHNLBW_Jaguar, BIT18 | BIT17 | BIT16 | BIT9 | BIT8, 0x101); /* 5'b00101); */
else if (82 <= channelToSW && channelToSW <= 140)
phy_set_rf_reg(pAdapter, eRFPath, RF_CHNLBW_Jaguar, BIT18 | BIT17 | BIT16 | BIT9 | BIT8, 0x301); /* 5'b01101); */
else if (140 < channelToSW)
phy_set_rf_reg(pAdapter, eRFPath, RF_CHNLBW_Jaguar, BIT18 | BIT17 | BIT16 | BIT9 | BIT8, 0x501); /* 5'b10101); */
@ -1826,25 +1830,25 @@ phy_SwChnl8812(
/* <20130104, Kordan> APK for MP chip is done on initialization from folder. */
if (IS_HARDWARE_TYPE_8821U(pAdapter) && (!IS_NORMAL_CHIP(pHalData->version_id)) && channelToSW > 14) {
/* <20121116, Kordan> For better result of APK. Asked by AlexWang. */
if (36 <= channelToSW && channelToSW <= 64)
if (15 <= channelToSW && channelToSW <= 80)
phy_set_rf_reg(pAdapter, eRFPath, RF_APK_Jaguar, bRFRegOffsetMask, 0x710E7);
else if (100 <= channelToSW && channelToSW <= 140)
else if (82 <= channelToSW && channelToSW <= 140)
phy_set_rf_reg(pAdapter, eRFPath, RF_APK_Jaguar, bRFRegOffsetMask, 0x716E9);
else
phy_set_rf_reg(pAdapter, eRFPath, RF_APK_Jaguar, bRFRegOffsetMask, 0x714E9);
} else if (IS_HARDWARE_TYPE_8821S(pAdapter) && channelToSW > 14) {
/* <20130111, Kordan> For better result of APK. Asked by Willson. */
if (36 <= channelToSW && channelToSW <= 64)
if (15 <= channelToSW && channelToSW <= 80)
phy_set_rf_reg(pAdapter, eRFPath, RF_APK_Jaguar, bRFRegOffsetMask, 0x714E9);
else if (100 <= channelToSW && channelToSW <= 140)
else if (82 <= channelToSW && channelToSW <= 140)
phy_set_rf_reg(pAdapter, eRFPath, RF_APK_Jaguar, bRFRegOffsetMask, 0x110E9);
else
phy_set_rf_reg(pAdapter, eRFPath, RF_APK_Jaguar, bRFRegOffsetMask, 0x714E9);
} else if (IS_HARDWARE_TYPE_8821E(pAdapter) && channelToSW > 14) {
/* <20130613, Kordan> For better result of APK. Asked by Willson. */
if (36 <= channelToSW && channelToSW <= 64)
if (15 <= channelToSW && channelToSW <= 80)
phy_set_rf_reg(pAdapter, eRFPath, RF_APK_Jaguar, bRFRegOffsetMask, 0x114E9);
else if (100 <= channelToSW && channelToSW <= 140)
else if (82 <= channelToSW && channelToSW <= 140)
phy_set_rf_reg(pAdapter, eRFPath, RF_APK_Jaguar, bRFRegOffsetMask, 0x110E9);
else
phy_set_rf_reg(pAdapter, eRFPath, RF_APK_Jaguar, bRFRegOffsetMask, 0x110E9);

View File

@ -25,7 +25,7 @@
#define CENTER_CH_2G_40M_NUM 9
#define CENTER_CH_2G_NUM 14
#define CENTER_CH_5G_20M_NUM 28 /* 20M center channels */
#define CENTER_CH_5G_20M_NUM (28+16) /* 20M center channels */
#define CENTER_CH_5G_40M_NUM 14 /* 40M center channels */
#define CENTER_CH_5G_80M_NUM 7 /* 80M center channels */
#define CENTER_CH_5G_160M_NUM 3 /* 160M center channels */
@ -43,7 +43,9 @@ u8 center_chs_2g(u8 bw, u8 id);
extern u8 center_ch_5g_20m[CENTER_CH_5G_20M_NUM];
extern u8 center_ch_5g_40m[CENTER_CH_5G_40M_NUM];
#if 0
extern u8 center_ch_5g_20m_40m[CENTER_CH_5G_20M_NUM + CENTER_CH_5G_40M_NUM];
#endif
extern u8 center_ch_5g_80m[CENTER_CH_5G_80M_NUM];
extern u8 center_ch_5g_all[CENTER_CH_5G_ALL_NUM];

View File

@ -201,9 +201,14 @@ static struct ieee80211_channel rtw_2ghz_channels[MAX_CHANNEL_NUM_2G] = {
/* from center_ch_5g_20m */
static struct ieee80211_channel rtw_5ghz_a_channels[MAX_CHANNEL_NUM_5G] = {
CHAN5G(15, 0), CHAN5G(16, 0), CHAN5G(17, 0), CHAN5G(18, 0),
CHAN5G(20, 0), CHAN5G(24, 0), CHAN5G(28, 0), CHAN5G(32, 0),
CHAN5G(36, 0), CHAN5G(40, 0), CHAN5G(44, 0), CHAN5G(48, 0),
CHAN5G(52, 0), CHAN5G(56, 0), CHAN5G(60, 0), CHAN5G(64, 0),
CHAN5G(68, 0), CHAN5G(72, 0), CHAN5G(76, 0), CHAN5G(80, 0),
CHAN5G(84, 0), CHAN5G(88, 0), CHAN5G(92, 0), CHAN5G(96, 0),
CHAN5G(100, 0), CHAN5G(104, 0), CHAN5G(108, 0), CHAN5G(112, 0),
CHAN5G(116, 0), CHAN5G(120, 0), CHAN5G(124, 0), CHAN5G(128, 0),
@ -6085,6 +6090,132 @@ static int cfg80211_rtw_set_channel(struct wiphy *wiphy
return 0;
}
static int cfg80211_rtw_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, struct cfg80211_chan_def *chandef){
_adapter *padapter= wiphy_to_adapter(wiphy);
int channel;
int control_freq;
int center_freq;
int center_freq2=0;
int width;
int band;
int bandWidth;
int offset;
struct dvobj_priv *dvobj;
struct net_device *ndev = wdev->netdev;
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
if (!ndev)
return -ENODEV;
offset = rtw_get_oper_choffset(padapter);
//channel = adapter_to_dvobj(padapter)->oper_channel;
channel = pHalData->current_channel;
if(channel >= 1){
if(channel <= 14)
band = NL80211_BAND_2GHZ;
else
band = NL80211_BAND_5GHZ;
#if 0
switch(pHalData->current_band_type){
case 0:
band = NL80211_BAND_2GHZ;
break;
case 1:
band = NL80211_BAND_5GHZ;
break;
default:
return -EINVAL;
}
#endif
control_freq = ieee80211_channel_to_frequency(channel, band);
dvobj = adapter_to_dvobj(padapter);
if(dvobj != NULL){
bandWidth = adapter_to_dvobj(padapter)->oper_bwmode;
RTW_INFO("%s bw %d\n", __func__, adapter_to_dvobj(padapter)->oper_bwmode);
}else{
bandWidth = pHalData->current_channel_bw;
RTW_INFO("%s dvobj null\n", __func__);
}
switch(pHalData->current_channel_bw){
case CHANNEL_WIDTH_5:
width = NL80211_CHAN_WIDTH_5;
center_freq = control_freq;
break;
case CHANNEL_WIDTH_10:
width = NL80211_CHAN_WIDTH_10;
center_freq = control_freq;
break;
case CHANNEL_WIDTH_20:
RTW_INFO("%s width 20\n", __func__);
width = NL80211_CHAN_WIDTH_20;
center_freq = control_freq;
break;
case CHANNEL_WIDTH_40:
RTW_INFO("%s width 40\n", __func__);
width = NL80211_CHAN_WIDTH_40;
if(offset == HAL_PRIME_CHNL_OFFSET_LOWER){
center_freq = control_freq +10;
}else{
center_freq = control_freq -10;
}
break;
case CHANNEL_WIDTH_80:
RTW_INFO("%s width 80\n", __func__);
width = NL80211_CHAN_WIDTH_80;
if(offset==HAL_PRIME_CHNL_OFFSET_LOWER){
center_freq = control_freq +30;
}else{
center_freq = control_freq -30;
}
break;
case CHANNEL_WIDTH_160:
RTW_INFO("%s width 160\n", __func__);
width = NL80211_CHAN_WIDTH_160;
if(offset == HAL_PRIME_CHNL_OFFSET_LOWER){
center_freq = control_freq +50;
}else{
center_freq = control_freq -50;
}
break;
case CHANNEL_WIDTH_80_80:
RTW_INFO("%s width 80x80\n", __func__);
width = NL80211_CHAN_WIDTH_80P80;
if(offset==HAL_PRIME_CHNL_OFFSET_LOWER){
center_freq = control_freq +30;
center_freq2=center_freq+80;
}else{
center_freq = control_freq -30;
center_freq2=center_freq-80;
}
break;
case CHANNEL_WIDTH_MAX:
RTW_INFO("%s width max\n", __func__);
width = NL80211_CHAN_WIDTH_160;
break;
}
chandef->chan = ieee80211_get_channel(wiphy, control_freq);
if(chandef->chan == NULL) {
chandef->chan = ieee80211_get_channel(wiphy, ieee80211_channel_to_frequency(channel, band));
RTW_INFO("%s chan null\n", __func__);
if(chandef->chan == NULL) {
RTW_INFO("%s chan null\n", __func__);
return -EINVAL;
}
}
chandef->width = width;
chandef->center_freq1 = center_freq;
chandef->center_freq2 = center_freq2;
RTW_INFO("%s : channel %d width %d freq1 %d freq2 %d center_freq %d offset %d\n", __func__,
channel, width, chandef->center_freq1, chandef->center_freq2, chandef->chan->center_freq,
rtw_get_oper_choffset(padapter)
);
}else{
return -EINVAL;
}
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
@ -10083,6 +10214,7 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
#if (KERNEL_VERSION(4, 17, 0) <= LINUX_VERSION_CODE)
.external_auth = cfg80211_rtw_external_auth,
#endif
.get_channel = cfg80211_rtw_get_channel,
};
struct wiphy *rtw_wiphy_alloc(_adapter *padapter, struct device *dev)