mtwifi-cfg: add support for 6GHz

This commit is contained in:
hanwckf 2024-09-20 02:21:20 +08:00
parent 1bfe4ec86b
commit bc757d25ba
9 changed files with 247 additions and 103 deletions

View File

@ -342,7 +342,7 @@ var CBIWifiFrequencyValue = form.Value.extend({
this.channels = {
'2g': [ 'auto', 'auto', true ],
'5g': [ 'auto', 'auto', true ],
'6g': [],
'6g': [ 'auto', 'auto', true ],
'60g': []
};
@ -415,7 +415,8 @@ var CBIWifiFrequencyValue = form.Value.extend({
],
'ax': [
'2g', '2.4 GHz', this.channels['2g'].length > 3,
'5g', '5 GHz', this.channels['5g'].length > 3
'5g', '5 GHz', this.channels['5g'].length > 3,
'6g', '6 GHz', this.channels['6g'].length > 3,
]
};
}, this));
@ -1582,13 +1583,15 @@ return view.extend({
crypto_modes.push(['wep-shared', _('WEP Shared Key'), 10]);
}
else if (hwtype == 'mtwifi') {
crypto_modes.push(['psk2', 'WPA2-PSK', 35]);
crypto_modes.push(['psk', 'WPA-PSK', 12]);
crypto_modes.push(['sae', 'WPA3-SAE', 31]);
crypto_modes.push(['sae', 'WPA3-SAE', 31]);
crypto_modes.push(['owe', 'OWE', 1]);
if (ifmode == 'ap') {
crypto_modes.push(['psk-mixed', 'WPA-PSK/WPA2-PSK Mixed Mode', 22]);
crypto_modes.push(['sae-mixed', 'WPA2-PSK/WPA3-SAE Mixed Mode', 36]);
if (band != '6g') {
crypto_modes.push(['psk2', 'WPA2-PSK', 35]);
crypto_modes.push(['psk', 'WPA-PSK', 12]);
if (ifmode == 'ap') {
crypto_modes.push(['psk-mixed', 'WPA-PSK/WPA2-PSK Mixed Mode', 22]);
crypto_modes.push(['sae-mixed', 'WPA2-PSK/WPA3-SAE Mixed Mode', 36]);
}
}
}

View File

@ -51,7 +51,7 @@ function show_devs()
end
function get_dev_prop(dev, prop)
if l1dat.devname_ridx[dev] then
if l1dat.devname_ridx[dev] and l1dat.devname_ridx[dev][prop] then
print(l1dat.devname_ridx[dev][prop])
end
end

View File

@ -149,6 +149,16 @@ function vif_is_apcli(vif, dev)
end
end
function is_ax_mode(cfg)
if not cfg.config.htmode then
return false
end
if string.sub(cfg.config.htmode,1,2) == "HE" then
return true
end
return false
end
function vif_count(cfg)
local vif_num = 0
local ap_num = 0
@ -382,21 +392,20 @@ function mtwifi_cfg_setup(argv)
end
local WirelessMode
local ax_feature = false
if cfg.config.band == "2g" then
if string.sub(cfg.config.htmode,1,2) == "HE" then
WirelessMode = 9 -- PHY_11BGN_MIXED
if is_ax_mode(cfg) then
WirelessMode = 16 -- PHY_11AX_24G
ax_feature = true
else
WirelessMode = 9 -- PHY_11BGN_MIXED
end
elseif cfg.config.band == "5g" then
if string.sub(cfg.config.htmode,1,2) == "HE" then
WirelessMode = 15 -- PHY_11VHT_N_MIXED
if is_ax_mode(cfg) then
WirelessMode = 17 -- PHY_11AX_5G
ax_feature = true
else
WirelessMode = 15 -- PHY_11VHT_N_MIXED
end
elseif cfg.config.band == "6g" then
if is_ax_mode(cfg) then
WirelessMode = 18 -- PHY_11AX_6G
end
end
@ -471,7 +480,7 @@ function mtwifi_cfg_setup(argv)
dats.CountryCode = cfg.config.country
if cfg.config.band == "2g" then
dats.CountryRegion = defs.countryRegions[cfg.config.country][1]
elseif cfg.config.band == "5g" then
elseif cfg.config.band == "5g" or cfg.config.band == "6g" then
dats.CountryRegionABand = defs.countryRegions[cfg.config.country][2]
end
end
@ -506,7 +515,7 @@ function mtwifi_cfg_setup(argv)
dats.ITxBfEn = 0
end
if ax_feature and cfg.config.twt then
if is_ax_mode(cfg) and cfg.config.twt then
dats.TWTSupport = cfg.config.twt
else
dats.TWTSupport = 0
@ -562,6 +571,12 @@ function mtwifi_cfg_setup(argv)
set_dat(dats, apidx, "DtimPeriod",v.config.dtim_period)
set_dat(dats, apidx, "WirelessMode", WirelessMode)
if is_ax_mode(cfg) then
set_dat(dats, apidx, "HT_BAWinSize", 256)
else
set_dat(dats, apidx, "HT_BAWinSize", 64)
end
if v.config.macfilter then
if v.config.macfilter == "allow" then
set_idx_dat(dats, apidx-1, "AccessPolicy", 1)

View File

@ -49,6 +49,7 @@ mtwifi_defs.vif_cfgs = {
["RTSThreshold"] = "2347",
["HT_AMSDU"] = "1",
["HT_AutoBA"] = "1",
["HT_BAWinSize"] = "256",
["HT_GI"] = "1",
["HT_LDPC"] = "1",
["HT_OpMode"] = "0",

View File

@ -7,34 +7,40 @@ append DRIVERS "mtwifi"
detect_mtwifi() {
local idx ifname
local band hwmode htmode htbsscoex ssid dbdc_main
local band htmode htbsscoex ssid dbdc_main
if [ -d "/sys/module/mt_wifi" ]; then
dev_list="$(l1util list)"
for dev in $dev_list; do
config_get type ${dev} type
[ "$type" = "mtwifi" ] || {
ifname="$(l1util get ${dev} main_ifname)"
idx="$(l1util get ${dev} subidx)"
if [ $idx -eq 1 ]; then
band="2g"
hwmode="11g"
[ $idx -eq 1 ] && dbdc_main="1" || dbdc_main="0"
band="$(l1util get ${dev} band)"
if [ -z "$band" ] || [ "$band" = "nil" ]; then
[ $idx -eq 1 ] && band="2g" || band="5g"
fi
if [ "$band" = "2g" ]; then
htmode="HE40"
htbsscoex="1"
ssid="ImmortalWrt-2.4G"
dbdc_main="1"
else
band="5g"
hwmode="11a"
elif [ "$band" = "5g" ]; then
htmode="HE160"
htbsscoex="0"
ssid="ImmortalWrt-5G"
dbdc_main="0"
elif [ "$band" = "6g" ]; then
htmode="HE160"
htbsscoex="0"
ssid="ImmortalWrt-6G"
fi
uci -q batch <<-EOF
set wireless.${dev}=wifi-device
set wireless.${dev}.type=mtwifi
set wireless.${dev}.phy=${ifname}
set wireless.${dev}.hwmode=${hwmode}
set wireless.${dev}.band=${band}
set wireless.${dev}.dbdc_main=${dbdc_main}
set wireless.${dev}.channel=auto

View File

@ -27,7 +27,7 @@
+
+ range.we_version_compiled = WIRELESS_EXT;
+
+ BandIdx = wlan_operate_get_ch_band(wdev);
+ BandIdx = HcGetBandByWdev(wdev);
+ pChCtrl = hc_get_channel_ctrl(pAdin->hdev_ctrl, BandIdx);
+
+ for (i = 0; i < pChCtrl->ChListNum && i < IW_MAX_FREQUENCIES; i++) {

View File

@ -0,0 +1,71 @@
--- a/mt_wifi/embedded/ap/ap_cfg.c
+++ b/mt_wifi/embedded/ap/ap_cfg.c
@@ -11880,6 +11880,39 @@ INT RTMPAPQueryInformation(
os_free_mem(chn_list);
break;
}
+ case OID_GET_CHANNEL_LIST:
+ {
+ int i = 0;
+ UCHAR BandIdx = 0;
+ CHANNEL_CTRL *pChCtrl = NULL;
+ struct wifi_dev *wdev = NULL;
+ struct channel_list_basic *chn_list;
+
+ wdev = get_wdev_by_ioctl_idx_and_iftype(pAd, pObj->ioctl_if, pObj->ioctl_if_type);
+
+ if (wdev == NULL)
+ break;
+
+ os_alloc_mem(pAd, (UCHAR **)&chn_list, sizeof(struct channel_list_basic));
+ if (chn_list == NULL)
+ break;
+ NdisZeroMemory(chn_list, sizeof(struct channel_list_basic));
+
+ BandIdx = HcGetBandByWdev(wdev);
+ pChCtrl = hc_get_channel_ctrl(pAd->hdev_ctrl, BandIdx);
+
+ for (i = 0; i < pChCtrl->ChListNum && i < MAX_NUM_OF_CHANNELS; i++) {
+ chn_list->ChList[i].channel_idx = i;
+ chn_list->ChList[i].channel = pChCtrl->ChList[i].Channel;
+ }
+ chn_list->ChListNum = pChCtrl->ChListNum;
+
+ wrq->u.data.length = sizeof(struct channel_list_basic);
+ Status = copy_to_user(wrq->u.data.pointer, chn_list, wrq->u.data.length);
+ os_free_mem(chn_list);
+
+ break;
+ }
#ifdef MAP_6E_SUPPORT
case OID_GET_OP_CLASS:
{
--- a/mt_wifi/embedded/include/oid.h
+++ b/mt_wifi/embedded/include/oid.h
@@ -1223,6 +1223,17 @@ typedef struct GNU_PACKED _channel_info
struct msg_channel_list {
CHANNEL_INFO CHANNELLIST[60];
};
+
+typedef struct _channel_info_basic {
+ UINT8 channel;
+ UINT8 channel_idx;
+} CHANNEL_INFO_BASIC, *PCHANNEL_INFO_BASIC;
+
+struct channel_list_basic {
+ CHANNEL_INFO_BASIC ChList[MAX_NUM_OF_CHANNELS];
+ UINT8 ChListNum;
+};
+
typedef struct GNU_PACKED offchannel_param {
UCHAR channel[MAX_AWAY_CHANNEL];
UCHAR scan_type[MAX_AWAY_CHANNEL];
@@ -2565,6 +2576,8 @@ enum vendor_ie_subcmd_oid {
#define OID_SET_AFC_CONFIG 0x09BE
#endif /* CONFIG_6G_AFC_SUPPORT */
+#define OID_GET_CHANNEL_LIST 0x09C0
+
#ifdef ACS_CTCC_SUPPORT
#define OID_802_11_GET_ACS_CHANNEL_SCORE 0x2014

View File

@ -73,6 +73,60 @@ static int mtk_is_ifup(const char *ifname)
return 0;
}
static int mtk_get_band(const char *dev)
{
struct iwreq wrq;
const char* ifname;
int chband;
/* get band base on ioctl */
ifname = mtk_dev2phy(dev);
if (!ifname)
return -1;
if (!mtk_is_ifup(ifname))
return -1;
wrq.u.data.length = sizeof(chband);
wrq.u.data.pointer = &chband;
wrq.u.data.flags = OID_GET_WIRELESS_BAND;
if (mtk_ioctl(ifname, RT_PRIV_IOCTL, &wrq) >= 0)
return chband;
return -1;
}
static int mtk_channel2freq(int channel, enum MTK_CH_BAND band)
{
if (channel < 1)
return 0;
if (band == MTK_CH_BAND_24G)
{
if (channel == 14)
return 2484;
else if (channel < 14)
return (channel * 5) + 2407;
}
else if (band == MTK_CH_BAND_5G)
{
if (channel >= 182 && channel <= 196)
return (channel * 5) + 4000;
else
return (channel * 5) + 5000;
}
else if (band == MTK_CH_BAND_6G)
{
if (channel == 2)
return 5935;
if (channel <= 233)
return (channel * 5) + 5950;
}
return 0;
}
static int mtk_get_mode(const char *dev, int *buf)
{
struct iwreq wrq;
@ -203,37 +257,20 @@ static int mtk_get_center_chan2(const char *dev, int *buf)
static int mtk_get_frequency(const char *dev, int *buf)
{
int channel;
struct iwreq wrq;
const char *ifname;
int channel, band, freq;
ifname = mtk_dev2phy(dev);
if (!ifname)
band = mtk_get_band(dev);
if (band < 0)
return -1;
if (mtk_ioctl(ifname, SIOCGIWFREQ, &wrq) >= 0)
{
channel = wrq.u.freq.m;
if (mtk_get_channel(dev, &channel) < 0)
return -1;
if (channel <= 0)
return -1;
freq = mtk_channel2freq(channel, band);
if (freq)
*buf = freq;
if (channel > 14) {
if (channel >= 182 && channel <= 196)
*buf = 4000 + channel * 5;
else
*buf = 5000 + channel * 5;
} else if (channel == 14) {
*buf = 2484;
} else {
*buf = 2407 + channel * 5;
}
return 0;
}
return -1;
return 0;
}
static int mtk_get_txpower(const char *dev, int *buf)
@ -611,10 +648,11 @@ static inline int wext_freq2mhz(const struct iw_freq *in)
static int mtk_get_freqlist(const char *dev, char *buf, int *len)
{
struct iwreq wrq;
struct iw_range range;
struct channel_list_basic ch_list;
struct iwinfo_freqlist_entry entry;
const char* ifname;
int i, bl;
int band;
ifname = mtk_dev2phy(dev);
if (!ifname)
@ -623,20 +661,25 @@ static int mtk_get_freqlist(const char *dev, char *buf, int *len)
if (!mtk_is_ifup(ifname))
return -1;
wrq.u.data.pointer = (caddr_t) &range;
wrq.u.data.length = sizeof(struct iw_range);
wrq.u.data.flags = 0;
band = mtk_get_band(dev);
if (band < 0)
return -1;
if (mtk_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0)
wrq.u.data.length = sizeof(struct channel_list_basic);
wrq.u.data.pointer = &ch_list;
wrq.u.data.flags = OID_GET_CHANNEL_LIST;
if (mtk_ioctl(ifname, RT_PRIV_IOCTL, &wrq) >= 0)
{
bl = 0;
for (i = 0; i < range.num_frequency; i++)
for (i = 0; i < ch_list.ChListNum; i++)
{
entry.mhz = wext_freq2mhz(&range.freq[i]);
entry.channel = range.freq[i].i;
entry.channel = ch_list.ChList[i].channel;
entry.mhz = mtk_channel2freq(ch_list.ChList[i].channel, band);
entry.restricted = 0;
//printf("channel=%d, mhz=%d\n", entry.channel, entry.mhz);
memcpy(&buf[bl], &entry, sizeof(struct iwinfo_freqlist_entry));
bl += sizeof(struct iwinfo_freqlist_entry);
}
@ -692,6 +735,8 @@ static int mtk_get_hwmodelist(const char *dev, int *buf)
struct iwinfo_freqlist_entry *e = NULL;
struct uci_section *s;
const char* band = NULL;
struct iwreq wrq;
int chband;
int len = 0;
*buf = 0;
@ -711,32 +756,23 @@ uciout:
*buf = (IWINFO_80211_N | IWINFO_80211_AX);
else if (!strcmp(band,"5g"))
*buf = (IWINFO_80211_AC | IWINFO_80211_AX);
else if (!strcmp(band,"6g"))
*buf = IWINFO_80211_AX;
return 0;
}
/* get hwmode base on iwrange */
ifname = mtk_dev2phy(dev);
if (!ifname)
chband = mtk_get_band(dev);
if (chband < 0)
return -1;
if (!mtk_get_freqlist(ifname, chans, &len))
switch (chband)
{
for (e = (struct iwinfo_freqlist_entry *)chans; e->channel; e++ )
{
if (e->channel <= 14 ) //2.4Ghz
{
*buf = (IWINFO_80211_N | IWINFO_80211_AX);
}
else //5Ghz
{
*buf = (IWINFO_80211_AC | IWINFO_80211_AX);
}
}
return 0;
case MTK_CH_BAND_24G: *buf = (IWINFO_80211_N | IWINFO_80211_AX); break;
case MTK_CH_BAND_5G: *buf = (IWINFO_80211_AC | IWINFO_80211_AX); break;
case MTK_CH_BAND_6G: *buf = IWINFO_80211_AX; break;
}
return -1;
return 0;
}
static int mtk_get_htmodelist(const char *dev, int *buf)
@ -746,6 +782,8 @@ static int mtk_get_htmodelist(const char *dev, int *buf)
struct iwinfo_freqlist_entry *e = NULL;
struct uci_section *s;
const char* band = NULL;
struct iwreq wrq;
int chband;
int len = 0;
*buf = 0;
@ -766,33 +804,31 @@ uciout:
else if (!strcmp(band,"5g"))
*buf = (IWINFO_HTMODE_VHT20 | IWINFO_HTMODE_VHT40 | IWINFO_HTMODE_VHT80 | IWINFO_HTMODE_VHT160
| IWINFO_HTMODE_HE20 | IWINFO_HTMODE_HE40 | IWINFO_HTMODE_HE80 | IWINFO_HTMODE_HE160);
else if (!strcmp(band,"6g"))
*buf = (IWINFO_HTMODE_HE20 | IWINFO_HTMODE_HE40 | IWINFO_HTMODE_HE80 | IWINFO_HTMODE_HE160);
return 0;
}
/* get htmode base on iwrange */
ifname = mtk_dev2phy(dev);
if (!ifname)
chband = mtk_get_band(dev);
if (chband < 0)
return -1;
if (!mtk_get_freqlist(ifname, chans, &len))
switch (chband)
{
for (e = (struct iwinfo_freqlist_entry *)chans; e->channel; e++ )
{
if (e->channel <= 14 ) //2.4Ghz
{
*buf = (IWINFO_HTMODE_HT20 | IWINFO_HTMODE_HT40 | IWINFO_HTMODE_HE20 | IWINFO_HTMODE_HE40);
}
else //5Ghz
{
*buf = (IWINFO_HTMODE_VHT20 | IWINFO_HTMODE_VHT40 | IWINFO_HTMODE_VHT80 | IWINFO_HTMODE_VHT160
| IWINFO_HTMODE_HE20 | IWINFO_HTMODE_HE40 | IWINFO_HTMODE_HE80 | IWINFO_HTMODE_HE160);
}
}
return 0;
case MTK_CH_BAND_24G:
*buf = (IWINFO_HTMODE_HT20 | IWINFO_HTMODE_HT40 | IWINFO_HTMODE_HE20 | IWINFO_HTMODE_HE40);
break;
case MTK_CH_BAND_5G:
*buf = (IWINFO_HTMODE_VHT20 | IWINFO_HTMODE_VHT40 | IWINFO_HTMODE_VHT80 | IWINFO_HTMODE_VHT160
| IWINFO_HTMODE_HE20 | IWINFO_HTMODE_HE40 | IWINFO_HTMODE_HE80 | IWINFO_HTMODE_HE160);
break;
case MTK_CH_BAND_6G:
*buf = (IWINFO_HTMODE_HE20 | IWINFO_HTMODE_HE40 | IWINFO_HTMODE_HE80 | IWINFO_HTMODE_HE160);
break;
}
return -1;
return 0;
}
static int mtk_get_htmode(const char *dev, int *buf)

View File

@ -46,12 +46,23 @@ typedef struct _RT_802_11_MAC_ENTRY_FIX {
} RT_802_11_MAC_ENTRY;
#define MAX_NUMBER_OF_MAC 544
#define MAX_NUM_OF_CHANNELS 59
typedef struct _RT_802_11_MAC_TABLE_FIX {
unsigned long Num;
RT_802_11_MAC_ENTRY Entry[MAX_NUMBER_OF_MAC];
} RT_802_11_MAC_TABLE;
typedef struct _channel_info_basic {
UINT8 channel;
UINT8 channel_idx;
} CHANNEL_INFO_BASIC, *PCHANNEL_INFO_BASIC;
struct channel_list_basic {
CHANNEL_INFO_BASIC ChList[MAX_NUM_OF_CHANNELS];
UINT8 ChListNum;
};
#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 0x01)
#define RTPRIV_IOCTL_SET (SIOCIWFIRSTPRIV + 0x02)
#define RTPRIV_IOCTL_E2P (SIOCIWFIRSTPRIV + 0x07)
@ -64,6 +75,7 @@ typedef struct _RT_802_11_MAC_TABLE_FIX {
#define OID_802_11_BW 0x1903
#define OID_GET_CHAN_LIST 0x0998
#define OID_GET_WIRELESS_BAND 0x09B4
#define OID_GET_CHANNEL_LIST 0x09C0
#define OID_802_11_SECURITY_TYPE 0x093e
#define RT_OID_802_11_PHY_MODE 0x050C
#define GET_MAC_TABLE_STRUCT_FLAG_RAW_SSID 0x1