From ba30683611157c7c6a92d04202a3db0ef9b6605b Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Wed, 24 Apr 2019 14:06:46 +0800 Subject: [PATCH] mtk: add mt7615 driver and luci support --- .../mtk/applications/mtk-luci-plugin/Makefile | 75 + .../mtk-luci-plugin/luci-app-mtkwifi/Makefile | 19 + .../luasrc/controller/mtkwifi.lua | 845 ++++++++++ .../luasrc/view/admin_mtk/mtk_wifi_apcli.htm | 343 +++++ .../view/admin_mtk/mtk_wifi_dev_cfg.htm | 851 +++++++++++ .../view/admin_mtk/mtk_wifi_overview.htm | 171 +++ .../view/admin_mtk/mtk_wifi_vif_cfg.htm | 602 ++++++++ .../luci-app-mtkwifi/root/sbin/mtkwifi | 199 +++ .../root/usr/lib/lua/mtkwifi.lua | 953 ++++++++++++ .../luci-app-webconsole/Makefile | 19 + .../luasrc/controller/webconsole.lua | 23 + .../luasrc/view/mtk_web_console.htm | 51 + package/mtk/applications/mtk-nvram/Makefile | 94 ++ package/mtk/applications/mtk-nvram/config.in | 6 + .../mtk/applications/mtk-nvram/src/Makefile | 35 + .../mtk/applications/mtk-nvram/src/crc32.c | 88 ++ .../mtk/applications/mtk-nvram/src/crc32.h | 16 + .../mtk/applications/mtk-nvram/src/flash.c | 252 +++ .../mtk/applications/mtk-nvram/src/flash.h | 19 + .../mtk/applications/mtk-nvram/src/layout.h | 52 + .../applications/mtk-nvram/src/main_flash.c | 94 ++ .../applications/mtk-nvram/src/main_nvram.c | 109 ++ .../mtk/applications/mtk-nvram/src/nvram.c | 585 +++++++ .../mtk/applications/mtk-nvram/src/nvram.h | 58 + package/mtk/applications/uci2dat/Makefile | 48 + package/mtk/applications/uci2dat/src/Makefile | 7 + .../mtk/applications/uci2dat/src/uci2dat.c | 1356 +++++++++++++++++ package/mtk/applications/wificonf/Makefile | 56 + .../wificonf/files/usr/bin/nvram_get | 93 ++ .../mtk/applications/wificonf/src/Makefile | 7 + .../mtk/applications/wificonf/src/wificonf.c | 679 +++++++++ package/mtk/drivers/mt_wifi/Makefile | 231 +++ .../drivers/mt_wifi/auto_build_kernel_4_4.sh | 80 + package/mtk/drivers/mt_wifi/config.in | 868 +++++++++++ package/mtk/drivers/mt_wifi/files/firmware.sh | 16 + .../mtk/drivers/mt_wifi/files/mt7615.1.2G.dat | 375 +++++ .../mtk/drivers/mt_wifi/files/mt7615.1.5G.dat | 375 +++++ .../drivers/mt_wifi/files/mt7615e-sku-bf.dat | 65 + .../mtk/drivers/mt_wifi/files/mt7615e-sku.dat | 65 + .../mtk/drivers/mt_wifi/files/mt7615e.1.dat | 410 +++++ .../mtk/drivers/mt_wifi/files/mt7615e.2.dat | 412 +++++ .../drivers/mt_wifi/files/mt7615e.eeprom.bin | Bin 0 -> 1024 bytes package/mtk/drivers/mt_wifi/files/mt7615e.lua | 301 ++++ .../mtk/drivers/mt_wifi/files/mt7622.1.dat | 412 +++++ .../drivers/mt_wifi/files/wifi_services.lua | 98 ++ .../mt_wifi/patches/1110-mt-wifi-common.patch | 19 + .../1111-fix-eeprom-flash-read-write.patch | 167 ++ package/mtk/drivers/wifi-l1profile/Makefile | 53 + .../wifi-l1profile/l1profile.config.in | 208 +++ .../drivers/wifi-l1profile/make-l1profile.py | 111 ++ package/mtk/drivers/wifi_forward/Makefile | 84 + package/mtk/drivers/wifi_forward/config.in | 16 + 52 files changed, 12171 insertions(+) create mode 100644 package/mtk/applications/mtk-luci-plugin/Makefile create mode 100644 package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/Makefile create mode 100644 package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/controller/mtkwifi.lua create mode 100644 package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_apcli.htm create mode 100644 package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_dev_cfg.htm create mode 100644 package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_overview.htm create mode 100644 package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_vif_cfg.htm create mode 100644 package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/root/sbin/mtkwifi create mode 100644 package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/root/usr/lib/lua/mtkwifi.lua create mode 100644 package/mtk/applications/mtk-luci-plugin/luci-app-webconsole/Makefile create mode 100644 package/mtk/applications/mtk-luci-plugin/luci-app-webconsole/luasrc/controller/webconsole.lua create mode 100644 package/mtk/applications/mtk-luci-plugin/luci-app-webconsole/luasrc/view/mtk_web_console.htm create mode 100644 package/mtk/applications/mtk-nvram/Makefile create mode 100644 package/mtk/applications/mtk-nvram/config.in create mode 100644 package/mtk/applications/mtk-nvram/src/Makefile create mode 100644 package/mtk/applications/mtk-nvram/src/crc32.c create mode 100644 package/mtk/applications/mtk-nvram/src/crc32.h create mode 100644 package/mtk/applications/mtk-nvram/src/flash.c create mode 100644 package/mtk/applications/mtk-nvram/src/flash.h create mode 100644 package/mtk/applications/mtk-nvram/src/layout.h create mode 100644 package/mtk/applications/mtk-nvram/src/main_flash.c create mode 100644 package/mtk/applications/mtk-nvram/src/main_nvram.c create mode 100644 package/mtk/applications/mtk-nvram/src/nvram.c create mode 100644 package/mtk/applications/mtk-nvram/src/nvram.h create mode 100644 package/mtk/applications/uci2dat/Makefile create mode 100644 package/mtk/applications/uci2dat/src/Makefile create mode 100644 package/mtk/applications/uci2dat/src/uci2dat.c create mode 100644 package/mtk/applications/wificonf/Makefile create mode 100644 package/mtk/applications/wificonf/files/usr/bin/nvram_get create mode 100644 package/mtk/applications/wificonf/src/Makefile create mode 100644 package/mtk/applications/wificonf/src/wificonf.c create mode 100644 package/mtk/drivers/mt_wifi/Makefile create mode 100644 package/mtk/drivers/mt_wifi/auto_build_kernel_4_4.sh create mode 100644 package/mtk/drivers/mt_wifi/config.in create mode 100644 package/mtk/drivers/mt_wifi/files/firmware.sh create mode 100644 package/mtk/drivers/mt_wifi/files/mt7615.1.2G.dat create mode 100644 package/mtk/drivers/mt_wifi/files/mt7615.1.5G.dat create mode 100644 package/mtk/drivers/mt_wifi/files/mt7615e-sku-bf.dat create mode 100644 package/mtk/drivers/mt_wifi/files/mt7615e-sku.dat create mode 100644 package/mtk/drivers/mt_wifi/files/mt7615e.1.dat create mode 100644 package/mtk/drivers/mt_wifi/files/mt7615e.2.dat create mode 100644 package/mtk/drivers/mt_wifi/files/mt7615e.eeprom.bin create mode 100644 package/mtk/drivers/mt_wifi/files/mt7615e.lua create mode 100644 package/mtk/drivers/mt_wifi/files/mt7622.1.dat create mode 100644 package/mtk/drivers/mt_wifi/files/wifi_services.lua create mode 100644 package/mtk/drivers/mt_wifi/patches/1110-mt-wifi-common.patch create mode 100644 package/mtk/drivers/mt_wifi/patches/1111-fix-eeprom-flash-read-write.patch create mode 100644 package/mtk/drivers/wifi-l1profile/Makefile create mode 100644 package/mtk/drivers/wifi-l1profile/l1profile.config.in create mode 100644 package/mtk/drivers/wifi-l1profile/make-l1profile.py create mode 100644 package/mtk/drivers/wifi_forward/Makefile create mode 100644 package/mtk/drivers/wifi_forward/config.in diff --git a/package/mtk/applications/mtk-luci-plugin/Makefile b/package/mtk/applications/mtk-luci-plugin/Makefile new file mode 100644 index 000000000..44d4d0993 --- /dev/null +++ b/package/mtk/applications/mtk-luci-plugin/Makefile @@ -0,0 +1,75 @@ +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/version.mk + +PKG_NAME:=mtk-luci-plugin +PKG_RELEASE:=1 +PKG_BUILD_DEPENDS:=base-files +PKG_FILE_DEPENDS:= +PKG_LICENSE:=GPL-2.0 + +PKG_MAINTAINER:=Hua Shao + +include $(INCLUDE_DIR)/package.mk + +HTDOCS = /www +LUA_LIBRARYDIR = /usr/lib/lua +LUCI_LIBRARYDIR = $(LUA_LIBRARYDIR)/luci + + +define Package/mtk-luci-plugin + SECTION:=MTK Properties + CATEGORY:=MTK Properties + SUBMENU:=Misc + DEPENDS:=+lua + TITLE:=MTK's LuCI plugins. + VERSION:=$(PKG_RELEASE)-$(REVISION) +endef + + +define Package/mtk-luci-plugin/config + config LUCI_APP_MTKWIFI + bool "luci-app-mtkwifi" + depends on PACKAGE_mtk-luci-plugin + default y + help + "LuCI plugin to manipulate MTK WiFi drivers" + + config LUCI_APP_WEBCONSOLE + bool "luci-app-webconsole" + depends on PACKAGE_mtk-luci-plugin + default y + help + "LuCI plugin for access shell from web" +endef + +define Build/Compile + +endef + +define Package/common/install + if [ -d $(2)/luasrc ]; then \ + $(INSTALL_DIR) $(1)$(LUCI_LIBRARYDIR); \ + cp -pR ./$(2)/luasrc/* $(1)$(LUCI_LIBRARYDIR)/; \ + else true; fi + if [ -d $(2)/htdocs ]; then \ + $(INSTALL_DIR) $(1)$(HTDOCS); \ + cp -pR ./$(2)/htdocs/* $(1)$(HTDOCS)/; \ + else true; fi + if [ -d $(2)/root ]; then \ + $(INSTALL_DIR) $(1)/; \ + cp -pR ./$(2)/root/* $(1)/; \ + else true; fi + if [ -d $(2)/src ]; then \ + $(call Build/Install/Default) \ + $(CP) ./$(PKG_INSTALL_DIR)/* $(1)/; \ + else true; fi +endef + + +define Package/mtk-luci-plugin/install + $(call Package/common/install,$(1),luci-app-mtkwifi) + $(call Package/common/install,$(1),luci-app-webconsole) +endef + + +$(eval $(call BuildPackage,mtk-luci-plugin)) diff --git a/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/Makefile b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/Makefile new file mode 100644 index 000000000..2ba0b6fde --- /dev/null +++ b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/Makefile @@ -0,0 +1,19 @@ +include $(TOPDIR)/rules.mk + +PKG_LICENSE:=GPLv2 +PKG_MAINTAINER:=Hua Shao + +LUCI_TITLE:=Manipulate mtk's proprietary wifi driver. +LUCI_DEPENDS:= + +# earlier version of luci put "luci.mk" somewhere else... +LUCI_MK_OLDPATH:=$(shell test -e ../luci.mk && echo "old") +LUCI_MK_NEWPATH:=$(shell test -e ../../luci.mk && echo "new") +ifeq ($(LUCI_MK_OLDPATH),old) +include ../luci.mk +endif +ifeq ($(LUCI_MK_NEWPATH),new) +include ../../luci.mk +endif + +# call BuildPackage - OpenWrt buildroot signature diff --git a/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/controller/mtkwifi.lua b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/controller/mtkwifi.lua new file mode 100644 index 000000000..df2ff2f71 --- /dev/null +++ b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/controller/mtkwifi.lua @@ -0,0 +1,845 @@ +-- This module is a demo to configure MTK' proprietary WiFi driver. +-- Basic idea is to bypass uci and edit wireless profile (mt76xx.dat) directly. +-- LuCI's WiFi configuration is more logical and elegent, but it's quite tricky to +-- translate uci into MTK's WiFi profile (like we did in "uci2dat"). +-- And you will get your hands dirty. +-- +-- Hua Shao + +module("luci.controller.mtkwifi", package.seeall) +local http = require("luci.http") +local mtkwifi = require("mtkwifi") + +function __mtkwifi_reload(devname) + local profiles = mtkwifi.search_dev_and_profile() + + for dev,profile in pairs(profiles) do + if not devname or devname == dev then + local diff = mtkwifi.diff_profile(profile) + -- Adding or deleting a vif will need to reinstall the wifi ko, + -- so we call "mtkwifi restart" here. + if diff.BssidNum then + os.execute("/sbin/mtkwifi restart "..devname) + else + os.execute("/sbin/mtkwifi reload "..devname) + end + -- keep a backup for this commit + -- it will be used in mtkwifi.diff_profile() + os.execute("cp -f "..profile.." "..mtkwifi.__profile_bak_path(profile)) + end + end +end + + +function index() + local page + + page = node("admin", "mtk") + page.target = firstchild() + page.title = _("MTK") + page.order = 80 + page.index = true + + entry({"admin", "mtk", "wifi"}, template("admin_mtk/mtk_wifi_overview"), _("WiFi configuration"), 1) + entry({"admin", "mtk", "wifi", "dev_cfg_view"}, template("admin_mtk/mtk_wifi_dev_cfg")).leaf = true + entry({"admin", "mtk", "wifi", "dev_cfg"}, call("dev_cfg")).leaf = true + entry({"admin", "mtk", "wifi", "dev_cfg_reset"}, call("dev_cfg_reset")).leaf = true + entry({"admin", "mtk", "wifi", "dev_cfg_raw"}, call("dev_cfg_raw")).leaf = true + entry({"admin", "mtk", "wifi", "vif_cfg_view"}, template("admin_mtk/mtk_wifi_vif_cfg")).leaf = true + entry({"admin", "mtk", "wifi", "vif_cfg"}, call("vif_cfg")).leaf = true + entry({"admin", "mtk", "wifi", "vif_add_view"}, template("admin_mtk/mtk_wifi_vif_cfg")).leaf = true + entry({"admin", "mtk", "wifi", "vif_add"}, call("vif_cfg")).leaf = true + entry({"admin", "mtk", "wifi", "vif_del"}, call("vif_del")).leaf = true + entry({"admin", "mtk", "wifi", "vif_disable"}, call("vif_disable")).leaf = true + entry({"admin", "mtk", "wifi", "vif_enable"}, call("vif_enable")).leaf = true + entry({"admin", "mtk", "wifi", "get_station_list"}, call("get_station_list")) + entry({"admin", "mtk", "wifi", "get_country_region_list"}, call("get_country_region_list")).leaf = true + entry({"admin", "mtk", "wifi", "get_channel_list"}, call("get_channel_list")) + entry({"admin", "mtk", "wifi", "get_HT_ext_channel_list"}, call("get_HT_ext_channel_list")) + entry({"admin", "mtk", "wifi", "get_5G_2nd_80Mhz_channel_list"}, call("get_5G_2nd_80Mhz_channel_list")) + entry({"admin", "mtk", "wifi", "reset"}, call("reset_wifi")).leaf = true + entry({"admin", "mtk", "wifi", "reload"}, call("reload_wifi")).leaf = true + entry({"admin", "mtk", "wifi", "get_raw_profile"}, call("get_raw_profile")) + entry({"admin", "mtk", "wifi", "apcli_cfg_view"}, template("admin_mtk/mtk_wifi_apcli")).leaf = true + entry({"admin", "mtk", "wifi", "apcli_cfg"}, call("apcli_cfg")).leaf = true + entry({"admin", "mtk", "wifi", "apcli_disconnect"}, call("apcli_disconnect")).leaf = true + entry({"admin", "mtk", "wifi", "apcli_connect"}, call("apcli_connect")).leaf = true + entry({"admin", "mtk", "wifi", "apcli_scan"}, call("apcli_scan")).leaf = true; +end + +function dev_cfg(devname) + local profiles = mtkwifi.search_dev_and_profile() + assert(profiles[devname]) + local cfgs = mtkwifi.load_profile(profiles[devname]) + + for k,v in pairs(http.formvalue()) do + if type(v) ~= type("") and type(v) ~= type(0) then + nixio.syslog("err", "dev_cfg, invalid value type for "..k..","..type(v)) + elseif string.byte(k) == string.byte("_") then + nixio.syslog("err", "dev_cfg, special: "..k.."="..v) + else + cfgs[k] = v or "" + end + end + + if mtkwifi.band(cfgs.WirelessMode) == "5G" then + cfgs.CountryRegionABand = http.formvalue("__cr"); + else + cfgs.CountryRegion = http.formvalue("__cr"); + end + + if cfgs.Channel == "0" then -- Auto Channel Select + cfgs.AutoChannelSelect = "3" + else + cfgs.AutoChannelSelect = "0" + end + + if http.formvalue("__bw") == "20" then + cfgs.HT_BW = 0 + cfgs.VHT_BW = 0 + elseif http.formvalue("__bw") == "40" then + cfgs.HT_BW = 1 + cfgs.VHT_BW = 0 + cfgs.HT_BSSCoexistence = 0 + elseif http.formvalue("__bw") == "60" then + cfgs.HT_BW = 1 + cfgs.VHT_BW = 0 + cfgs.HT_BSSCoexistence = 1 + elseif http.formvalue("__bw") == "80" then + cfgs.HT_BW = 1 + cfgs.VHT_BW = 1 + elseif http.formvalue("__bw") == "160" then + cfgs.HT_BW = 1 + cfgs.VHT_BW = 2 + elseif http.formvalue("__bw") == "161" then + cfgs.HT_BW = 1 + cfgs.VHT_BW = 3 + cfgs.VHT_Sec80_Channel = http.formvalue("VHT_Sec80_Channel") or "" + end + + if cfgs.ApCliAuthMode == "WEP" then + cfgs.ApCliEncrypType = http.formvalue("__apcli_wep_enctype") + else + cfgs.ApCliEncrypType = http.formvalue("__apcli_wpa_enctype") + end + + local mimo = http.formvalue("__mimo") + if mimo == "0" then + cfgs.ETxBfEnCond=1 + cfgs.MUTxRxEnable=0 + cfgs.ITxBfEn=0 + elseif mimo == "1" then + cfgs.ETxBfEnCond=0 + cfgs.MUTxRxEnable=0 + cfgs.ITxBfEn=1 + elseif mimo == "2" then + cfgs.ETxBfEnCond=1 + cfgs.MUTxRxEnable=0 + cfgs.ITxBfEn=1 + elseif mimo == "3" then + cfgs.ETxBfEnCond=1 + if tonumber(cfgs.ApCliEnable) == 1 then + cfgs.MUTxRxEnable=3 + else + cfgs.MUTxRxEnable=1 + end + cfgs.ITxBfEn=0 + elseif mimo == "4" then + cfgs.ETxBfEnCond=1 + if tonumber(cfgs.ApCliEnable) == 1 then + cfgs.MUTxRxEnable=3 + else + cfgs.MUTxRxEnable=1 + end + cfgs.ITxBfEn=1 + else + cfgs.ETxBfEnCond=0 + cfgs.MUTxRxEnable=0 + cfgs.ITxBfEn=0 + end + +-- if cfgs.ApCliEnable == "1" then +-- cfgs.Channel = http.formvalue("__apcli_channel") +-- end + + -- VOW + -- ATC should actually be scattered into each SSID, but I'm just lazy. + if cfgs.VOW_Airtime_Fairness_En then + for i = 1,tonumber(cfgs.BssidNum) do + __atc_tp = http.formvalue("__atc_vif"..i.."_tp") or "0" + __atc_min_tp = http.formvalue("__atc_vif"..i.."_min_tp") or "0" + __atc_max_tp = http.formvalue("__atc_vif"..i.."_max_tp") or "0" + __atc_at = http.formvalue("__atc_vif"..i.."_at") or "0" + __atc_min_at = http.formvalue("__atc_vif"..i.."_min_at") or "0" + __atc_max_at = http.formvalue("__atc_vif"..i.."_max_at") or "0" + + nixio.syslog("info", "ATC.__atc_tp ="..i..__atc_tp ); + nixio.syslog("info", "ATC.__atc_min_tp ="..i..__atc_min_tp ); + nixio.syslog("info", "ATC.__atc_max_tp ="..i..__atc_max_tp ); + nixio.syslog("info", "ATC.__atc_at ="..i..__atc_at ); + nixio.syslog("info", "ATC.__atc_min_at ="..i..__atc_min_at ); + nixio.syslog("info", "ATC.__atc_max_at ="..i..__atc_max_at ); + + cfgs.VOW_Rate_Ctrl_En = mtkwifi.token_set(cfgs.VOW_Rate_Ctrl_En, i, __atc_tp) + cfgs.VOW_Group_Min_Rate = mtkwifi.token_set(cfgs.VOW_Group_Min_Rate, i, __atc_min_tp) + cfgs.VOW_Group_Max_Rate = mtkwifi.token_set(cfgs.VOW_Group_Max_Rate, i, __atc_max_tp) + + cfgs.VOW_Airtime_Ctrl_En = mtkwifi.token_set(cfgs.VOW_Airtime_Ctrl_En, i, __atc_at) + cfgs.VOW_Group_Min_Ratio = mtkwifi.token_set(cfgs.VOW_Group_Min_Ratio, i, __atc_min_at) + cfgs.VOW_Group_Max_Ratio = mtkwifi.token_set(cfgs.VOW_Group_Max_Ratio, i, __atc_max_at) + end + + cfgs.VOW_RX_En = http.formvalue("VOW_RX_En") or "0" + end + + -- http.write_json(http.formvalue()) + mtkwifi.save_profile(cfgs, profiles[devname]) + + if http.formvalue("__apply") then + __mtkwifi_reload(devname) + end + + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi", "dev_cfg_view",devname)) +end + +function dev_cfg_raw(devname) + -- http.write_json(http.formvalue()) + local profiles = mtkwifi.search_dev_and_profile() + assert(profiles[devname]) + + local raw = http.formvalue("raw") + raw = string.gsub(raw, "\r\n", "\n") + local cfgs = mtkwifi.load_profile(nil, raw) + mtkwifi.save_profile(cfgs, profiles[devname]) + + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi", "dev_cfg_view", devname)) +end + +function dev_cfg_reset(devname) + -- http.write_json(http.formvalue()) + local profiles = mtkwifi.search_dev_and_profile() + assert(profiles[devname]) + + local fd = io.open("/rom"..profiles[devname], "r") + if fd then + fd:close() -- just to test if file exists. + os.execute("cp -f /rom"..profiles[devname].." "..profiles[devname]) + else + mtkwifi.debug("unable to find /rom"..profiles[devname]) + end + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi", "dev_cfg_view", devname)) +end + +function vif_del(dev, vif) + mtkwifi.debug("vif_del("..dev..vif..")") + local devname,vifname = dev, vif + mtkwifi.debug("devname="..devname) + mtkwifi.debug("vifname="..vifname) + local devs = mtkwifi.get_all_devs() + local idx = devs[devname]["vifs"][vifname].vifidx -- or tonumber(string.match(vifname, "%d+")) + 1 + mtkwifi.debug("idx="..idx, devname, vifname) + local profile = devs[devname].profile + assert(profile) + if idx and tonumber(idx) >= 0 then + local cfgs = mtkwifi.load_profile(profile) + if cfgs then + mtkwifi.debug("ssid"..idx.."="..cfgs["SSID"..idx].."
") + cfgs["SSID"..idx] = "" + mtkwifi.debug("ssid"..idx.."="..cfgs["SSID"..idx].."
") + mtkwifi.debug("wpapsk"..idx.."="..cfgs["WPAPSK"..idx].."
") + cfgs["WPAPSK"..idx] = "" + local ssidlist = {} + local j = 1 + for i = 1,16 do + if cfgs["SSID"..i] ~= "" then + ssidlist[j] = cfgs["SSID"..i] + j = j + 1 + end + end + for i,v in ipairs(ssidlist) do + mtkwifi.debug("ssidlist"..i.."="..v) + end + mtkwifi.debug("cfgs.BssidNum="..cfgs.BssidNum.." #ssidlist="..#ssidlist) + assert(tonumber(cfgs.BssidNum) == #ssidlist + 1, "Please delete vif from larger idx.") + cfgs.BssidNum = #ssidlist + for i = 1,16 do + if i <= cfgs.BssidNum then + cfgs["SSID"..i] = ssidlist[i] + elseif cfgs["SSID"..i] then + cfgs["SSID"..i] = "" + end + end + + mtkwifi.save_profile(cfgs, profile) + else + mtkwifi.debug(profile.." cannot be found!") + end + end + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi")) +end + +function vif_disable(iface) + os.execute("ifconfig "..iface.." down") + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi")) +end + +function vif_enable(iface) + os.execute("ifconfig "..iface.." up") + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi")) +end + + +--[[ +-- security config in mtk wifi is quite complicated! +-- cfgs listed below are attached with vif and combined like "0;0;0;0". They need specicial treatment. + TxRate, WmmCapable, NoForwarding, + HideSSID, IEEE8021X, PreAuth, + AuthMode, EncrypType, RekeyMethod, + RekeyInterval, PMKCachePeriod, + DefaultKeyId, Key{n}Type, HT_EXTCHA, + RADIUS_Server, RADIUS_Port, +]] + +local function conf_wep_keys(cfgs,vifidx) + cfgs.DefaultKeyID = mtkwifi.token_set(cfgs.DefaultKeyID, vifidx, http.formvalue("__DefaultKeyID") or 1) + cfgs["Key1Str"..vifidx] = http.formvalue("Key1Str"..vifidx) + cfgs["Key2Str"..vifidx] = http.formvalue("Key2Str"..vifidx) + cfgs["Key3Str"..vifidx] = http.formvalue("Key3Str"..vifidx) + cfgs["Key4Str"..vifidx] = http.formvalue("Key4Str"..vifidx) + + cfgs["Key1Type"]=mtkwifi.token_set(cfgs["Key1Type"],vifidx, http.formvalue("WEP1Type"..vifidx)) + cfgs["Key2Type"]=mtkwifi.token_set(cfgs["Key2Type"],vifidx, http.formvalue("WEP2Type"..vifidx)) + cfgs["Key3Type"]=mtkwifi.token_set(cfgs["Key3Type"],vifidx, http.formvalue("WEP3Type"..vifidx)) + cfgs["Key4Type"]=mtkwifi.token_set(cfgs["Key4Type"],vifidx, http.formvalue("WEP4Type"..vifidx)) + + return cfgs +end + +local function __security_cfg(cfgs, vif_idx) + mtkwifi.debug("__security_cfg, before, HideSSID="..tostring(cfgs.HideSSID)) + mtkwifi.debug("__security_cfg, before, NoForwarding="..tostring(cfgs.NoForwarding)) + mtkwifi.debug("__security_cfg, before, WmmCapable="..tostring(cfgs.WmmCapable)) + mtkwifi.debug("__security_cfg, before, TxRate="..tostring(cfgs.TxRate)) + mtkwifi.debug("__security_cfg, before, RekeyInterval="..tostring(cfgs.RekeyInterval)) + mtkwifi.debug("__security_cfg, before, AuthMode="..tostring(cfgs.AuthMode)) + mtkwifi.debug("__security_cfg, before, EncrypType="..tostring(cfgs.EncrypType)) + mtkwifi.debug("__security_cfg, before, WscModeOption="..tostring(cfgs.WscModeOption)) + mtkwifi.debug("__security_cfg, before, RekeyMethod="..tostring(cfgs.RekeyMethod)) + mtkwifi.debug("__security_cfg, before, IEEE8021X="..tostring(cfgs.IEEE8021X)) + mtkwifi.debug("__security_cfg, before, DefaultKeyID="..tostring(cfgs.DefaultKeyID)) + mtkwifi.debug("__security_cfg, before, PMFMFPC="..tostring(cfgs.PMFMFPC)) + mtkwifi.debug("__security_cfg, before, PMFMFPR="..tostring(cfgs.PMFMFPR)) + mtkwifi.debug("__security_cfg, before, PMFSHA256="..tostring(cfgs.PMFSHA256)) + mtkwifi.debug("__security_cfg, before, RADIUS_Server="..tostring(cfgs.RADIUS_Server)) + mtkwifi.debug("__security_cfg, before, RADIUS_Port="..tostring(cfgs.RADIUS_Port)) + mtkwifi.debug("__security_cfg, before, session_timeout_interval="..tostring(cfgs.session_timeout_interval)) + mtkwifi.debug("__security_cfg, before, PMKCachePeriod="..tostring(cfgs.PMKCachePeriod)) + mtkwifi.debug("__security_cfg, before, PreAuth="..tostring(cfgs.PreAuth)) + mtkwifi.debug("__security_cfg, before, Wapiifname="..tostring(cfgs.Wapiifname)) + + cfgs.HideSSID = mtkwifi.token_set(cfgs.HideSSID, vif_idx, http.formvalue("__hidessid") or "0") + cfgs.NoForwarding = mtkwifi.token_set(cfgs.NoForwarding, vif_idx, http.formvalue("__noforwarding") or "0") + cfgs.WmmCapable = mtkwifi.token_set(cfgs.WmmCapable, vif_idx, http.formvalue("__wmmcapable") or "0") + cfgs.TxRate = mtkwifi.token_set(cfgs.TxRate, vif_idx, http.formvalue("__txrate") or "0"); + cfgs.RekeyInterval = mtkwifi.token_set(cfgs.RekeyInterval, vif_idx, http.formvalue("__rekeyinterval") or "0"); + + local __authmode = http.formvalue("__authmode") or "Disable" + cfgs.AuthMode = mtkwifi.token_set(cfgs.AuthMode, vif_idx, __authmode) + + --[[ need to handle disable case as it conflicts with OPENWEP + case = disable; authmode = OPEN, encryption = NONE + case = open/OPENWEP; authmode = OPEN, encryption = WEP + ]] + if __authmode == "Disable" then + cfgs.AuthMode = mtkwifi.token_set(cfgs.AuthMode, vif_idx, "OPEN") + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, "NONE") + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "DISABLE") + elseif __authmode == "OPEN" or __authmode == "SHARED" or __authmode == "WEPAUTO" then + --[[ the following required cfgs are already set in loop above + cfgs.Key{n}Str, ... + cfgs.Key{n}Type, ... + cfgs.DefaultKeyID + ]] + cfgs.WscModeOption = "0" + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, "WEP") + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "DISABLE") + cfgs = conf_wep_keys(cfgs,vif_idx) + cfgs.WscConfMode = mtkwifi.token_set(cfgs.WscConfMode, vif_idx, 0) + elseif __authmode == "WPAPSK" or __authmode == "WPAPSKWPA2PSK" then + --[[ the following required cfgs are already set in loop above + cfgs.WPAPSK{n}, ... + cfgs.RekeyInterval + ]] + + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "TIME") + cfgs.IEEE8021X = mtkwifi.token_set(cfgs.IEEE8021X, vif_idx, "0") + cfgs.DefaultKeyID = mtkwifi.token_set(cfgs.DefaultKeyID, vif_idx, "2") + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, http.formvalue("__wpa_encrypttype") or "NONE") + --cfgs["WPAPSK"..vif_idx] = http.formvalue("WPAPSK"..vif_idx) + elseif __authmode == "WPA2PSK" then + --[[ the following required cfgs are already set in loop above + cfgs.WPAPSK{n}, ... + cfgs.RekeyInterval + ]] + -- for DOT11W_PMF_SUPPORT + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, http.formvalue("__wpa_encrypttype") or "0") + if cfgs.PMFMFPC then + cfgs.PMFMFPC = mtkwifi.token_set(cfgs.PMFMFPC, vif_idx, http.formvalue("__pmfmfpc") or "0") + end + if cfgs.PMFMFPR then + cfgs.PMFMFPR = mtkwifi.token_set(cfgs.PMFMFPR, vif_idx, http.formvalue("__pmfmfpr") or "0") + end + if cfgs.PMFSHA256 then + cfgs.PMFSHA256 = mtkwifi.token_set(cfgs.PMFSHA256, vif_idx, http.formvalue("__pmfsha256") or "0") + end + + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "TIME") + cfgs.IEEE8021X = mtkwifi.token_set(cfgs.IEEE8021X, vif_idx, "0") + cfgs.DefaultKeyID = mtkwifi.token_set(cfgs.DefaultKeyID, vif_idx, "2") + elseif __authmode == "WPA" then + --[[ the following required cfgs are already set in loop above + cfgs.WPAPSK{n}, ... + cfgs.RekeyInterval + cfgs.RADIUS_Key + ]] + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, http.formvalue("__wpa_encrypttype") or "0") + cfgs.RADIUS_Server = mtkwifi.token_set(cfgs.RADIUS_Server, vif_idx, http.formvalue("__radius_server") or "0") + cfgs.RADIUS_Port = mtkwifi.token_set(cfgs.RADIUS_Port, vif_idx, http.formvalue("__radius_port") or "0") + cfgs.session_timeout_interval = mtkwifi.token_set(cfgs.session_timeout_interval, vif_idx, http.formvalue("__session_timeout_interval") or "0") + + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "TIME") + cfgs.IEEE8021X = mtkwifi.token_set(cfgs.IEEE8021X, vif_idx, "0") + cfgs.DefaultKeyID = mtkwifi.token_set(cfgs.DefaultKeyID, vif_idx, "2") + elseif __authmode == "WPA2" then + --[[ the following required cfgs are already set in loop above + cfgs.WPAPSK{n}, ... + cfgs.RekeyInterval + cfgs.RADIUS_Key + ]] + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, http.formvalue("__wpa_encrypttype") or "0") + cfgs.RADIUS_Server = mtkwifi.token_set(cfgs.RADIUS_Server, vif_idx, http.formvalue("__radius_server") or "0") + cfgs.RADIUS_Port = mtkwifi.token_set(cfgs.RADIUS_Port, vif_idx, http.formvalue("__radius_port") or "0") + cfgs.session_timeout_interval = mtkwifi.token_set(cfgs.session_timeout_interval, vif_idx, http.formvalue("__session_timeout_interval") or "0") + cfgs.PMKCachePeriod = mtkwifi.token_set(cfgs.PMKCachePeriod, vif_idx, http.formvalue("__pmkcacheperiod") or "0") + cfgs.PreAuth = mtkwifi.token_set(cfgs.PreAuth, vif_idx, http.formvalue("__preauth") or "0") + -- for DOT11W_PMF_SUPPORT + if cfgs.PMFMFPC then + cfgs.PMFMFPC = mtkwifi.token_set(cfgs.PMFMFPC, vif_idx, http.formvalue("__pmfmfpc") or "0") + end + if cfgs.PMFMFPR then + cfgs.PMFMFPR = mtkwifi.token_set(cfgs.PMFMFPR, vif_idx, http.formvalue("__pmfmfpr") or "0") + end + if cfgs.PMFSHA256 then + cfgs.PMFSHA256 = mtkwifi.token_set(cfgs.PMFSHA256, vif_idx, http.formvalue("__pmfsha256") or "0") + end + + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "TIME") + cfgs.IEEE8021X = mtkwifi.token_set(cfgs.IEEE8021X, vif_idx, "0") + cfgs.DefaultKeyID = mtkwifi.token_set(cfgs.DefaultKeyID, vif_idx, "2") + elseif __authmode == "WPA1WPA2" then + --[[ the following required cfgs are already set in loop above + cfgs.WPAPSK{n}, ... + cfgs.RekeyInterval + cfgs.RADIUS_Key + ]] + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, http.formvalue("__wpa_encrypttype") or "0") + cfgs.RADIUS_Server = mtkwifi.token_set(cfgs.RADIUS_Server, vif_idx, http.formvalue("__radius_server") or "0") + cfgs.RADIUS_Port = mtkwifi.token_set(cfgs.RADIUS_Port, vif_idx, http.formvalue("__radius_port") or "1812") + cfgs.session_timeout_interval = mtkwifi.token_set(cfgs.session_timeout_interval, vif_idx, http.formvalue("__session_timeout_interval") or "0") + cfgs.PMKCachePeriod = mtkwifi.token_set(cfgs.PMKCachePeriod, vif_idx, http.formvalue("__pmkcacheperiod") or "0") + cfgs.PreAuth = mtkwifi.token_set(cfgs.PreAuth, vif_idx, http.formvalue("__preauth") or "0") + + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "TIME") + cfgs.IEEE8021X = mtkwifi.token_set(cfgs.IEEE8021X, vif_idx, "0") + cfgs.DefaultKeyID = mtkwifi.token_set(cfgs.DefaultKeyID, vif_idx, "2") + elseif __authmode == "IEEE8021X" then + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "DISABLE") + cfgs.AuthMode = mtkwifi.token_set(cfgs.AuthMode, vif_idx, "OPEN") + cfgs.IEEE8021X = mtkwifi.token_set(cfgs.IEEE8021X, vif_idx, "1") + cfgs.RADIUS_Server = mtkwifi.token_set(cfgs.RADIUS_Server, vif_idx, http.formvalue("__radius_server") or "0") + cfgs.RADIUS_Port = mtkwifi.token_set(cfgs.RADIUS_Port, vif_idx, http.formvalue("__radius_port") or "0") + cfgs.session_timeout_interval = mtkwifi.token_set(cfgs.session_timeout_interval, vif_idx, http.formvalue("__session_timeout_interval") or "0") + if http.formvalue("__8021x_wep") then + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, "WEP") + else + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, "NONE") + end + elseif __authmode == "WAICERT" then + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, "SMS4") + cfgs.Wapiifname = mtkwifi.token_set(cfgs.Wapiifname, vif_idx, "br-lan") + -- cfgs.wapicert_asipaddr + -- cfgs.WapiAsPort + -- cfgs.wapicert_ascert + -- cfgs.wapicert_usercert + elseif __authmode == "WAIPSK" then + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, "SMS4") + -- cfgs.wapipsk_keytype + -- cfgs.wapipsk_prekey + end + + mtkwifi.debug("__security_cfg, after, HideSSID="..tostring(cfgs.HideSSID)) + mtkwifi.debug("__security_cfg, after, NoForwarding="..tostring(cfgs.NoForwarding)) + mtkwifi.debug("__security_cfg, after, WmmCapable="..tostring(cfgs.WmmCapable)) + mtkwifi.debug("__security_cfg, after, TxRate="..tostring(cfgs.TxRate)) + mtkwifi.debug("__security_cfg, after, RekeyInterval="..tostring(cfgs.RekeyInterval)) + mtkwifi.debug("__security_cfg, after, AuthMode="..tostring(cfgs.AuthMode)) + mtkwifi.debug("__security_cfg, after, EncrypType="..tostring(cfgs.EncrypType)) + mtkwifi.debug("__security_cfg, after, WscModeOption="..tostring(cfgs.WscModeOption)) + mtkwifi.debug("__security_cfg, after, RekeyMethod="..tostring(cfgs.RekeyMethod)) + mtkwifi.debug("__security_cfg, after, IEEE8021X="..tostring(cfgs.IEEE8021X)) + mtkwifi.debug("__security_cfg, after, DefaultKeyID="..tostring(cfgs.DefaultKeyID)) + mtkwifi.debug("__security_cfg, after, PMFMFPC="..tostring(cfgs.PMFMFPC)) + mtkwifi.debug("__security_cfg, after, PMFMFPR="..tostring(cfgs.PMFMFPR)) + mtkwifi.debug("__security_cfg, after, PMFSHA256="..tostring(cfgs.PMFSHA256)) + mtkwifi.debug("__security_cfg, after, RADIUS_Server="..tostring(cfgs.RADIUS_Server)) + mtkwifi.debug("__security_cfg, after, RADIUS_Port="..tostring(cfgs.RADIUS_Port)) + mtkwifi.debug("__security_cfg, after, session_timeout_interval="..tostring(cfgs.session_timeout_interval)) + mtkwifi.debug("__security_cfg, after, PMKCachePeriod="..tostring(cfgs.PMKCachePeriod)) + mtkwifi.debug("__security_cfg, after, PreAuth="..tostring(cfgs.PreAuth)) + mtkwifi.debug("__security_cfg, after, Wapiifname="..tostring(cfgs.Wapiifname)) +end + +function initialize_multiBssParameters(cfgs,vif_idx) + cfgs["WPAPSK"..vif_idx]="12345678" + cfgs["Key1Type"]=mtkwifi.token_set(cfgs["Key1Type"],vif_idx,"0") + cfgs["Key2Type"]=mtkwifi.token_set(cfgs["Key2Type"],vif_idx,"0") + cfgs["Key3Type"]=mtkwifi.token_set(cfgs["Key3Type"],vif_idx,"0") + cfgs["Key4Type"]=mtkwifi.token_set(cfgs["Key4Type"],vif_idx,"0") + cfgs["RADIUS_Server"]=mtkwifi.token_set(cfgs["RADIUS_Server"],vif_idx,"0") + cfgs["RADIUS_Key"..vif_idx]="ralink" + cfgs["DefaultKeyID"]=mtkwifi.token_set(cfgs["DefaultKeyID"],vif_idx,"1") + cfgs["IEEE8021X"]=mtkwifi.token_set(cfgs["IEEE8021X"],vif_idx,"0") + cfgs["WscConfMode"]=mtkwifi.token_set(cfgs["WscConfMode"],vif_idx,"0") + cfgs["PreAuth"]=mtkwifi.token_set(cfgs["PreAuth"],vif_idx,"0") + return cfgs +end + +function vif_cfg(dev, vif) + local devname, vifname = dev, vif + if not devname then devname = vif end + mtkwifi.debug("devname="..devname) + mtkwifi.debug("vifname="..(vifname or "")) + local devs = mtkwifi.get_all_devs() + local profile = devs[devname].profile + assert(profile) + + local cfgs = mtkwifi.load_profile(profile) + + for k,v in pairs(http.formvalue()) do + if type(v) == type("") or type(v) == type(0) then + nixio.syslog("debug", "post."..k.."="..tostring(v)) + else + nixio.syslog("debug", "post."..k.." invalid, type="..type(v)) + end + end + + -- sometimes vif_idx start from 0, like AccessPolicy0 + -- sometimes it starts from 1, like WPAPSK1. nice! + local vif_idx + local to_url + if http.formvalue("__action") == "vif_cfg_view" then + vif_idx = devs[devname]["vifs"][vifname].vifidx + mtkwifi.debug("vif_idx=", vif_idx, devname, vifname) + to_url = luci.dispatcher.build_url("admin", "mtk", "wifi", "vif_cfg_view", devname, vifname) + elseif http.formvalue("__action") == "vif_add_view" then + cfgs.BssidNum = tonumber(cfgs.BssidNum) + 1 + vif_idx = tonumber(cfgs.BssidNum) + to_url = luci.dispatcher.build_url("admin", "mtk", "wifi") + -- initializing ; separated parameters for the new interface + cfgs = initialize_multiBssParameters(cfgs, vif_idx) + + end + + -- "__" should not be in the name if user wants to copy formvalue data directly in the dat file variable + for k,v in pairs(http.formvalue()) do + if type(v) ~= type("") and type(v) ~= type(0) then + nixio.syslog("err", "vif_cfg, invalid value type for "..k..","..type(v)) + elseif string.byte(k) ~= string.byte("_") then + mtkwifi.debug("copying values for "..k) + cfgs[k] = v or "" + end + end + + cfgs["AccessPolicy"..vif_idx-1] = http.formvalue("__accesspolicy") + local t = mtkwifi.parse_mac(http.formvalue("__maclist")) + cfgs["AccessControlList"..vif_idx-1] = table.concat(t, ";") + + __security_cfg(cfgs, vif_idx) + + mtkwifi.debug(devname, profile) + mtkwifi.save_profile(cfgs, profile) + if http.formvalue("__apply") then + __mtkwifi_reload(devname) + end + return luci.http.redirect(to_url) +end + +function apcli_scan(ifname) + local aplist = mtkwifi.scan_ap(ifname) + http.write_json(aplist) +end + +function get_station_list() + http.write("get_station_list") +end + +function reset_wifi(devname) + if devname then + os.execute("cp -f /rom/etc/wireless/"..devname.."/ /etc/wireless/") + else + os.execute("cp -rf /rom/etc/wireless /etc/") + end + os.execute("rm -rf /tmp/mtk/wifi") + __mtkwifi_reload(devname) + return luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi")) +end + +function reload_wifi(devname) + __mtkwifi_reload(devname) + return luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi")) +end + +function get_raw_profile() + local sid = http.formvalue("sid") + http.write_json("get_raw_profile") +end + +function get_country_region_list() + local mode = http.formvalue("mode") + local cr_list; + + if mtkwifi.band(mode) == "5G" then + cr_list = mtkwifi.CountryRegionList_5G_All + else + cr_list = mtkwifi.CountryRegionList_2G_All + end + + http.write_json(cr_list) +end + +function remove_ch_by_region(ch_list, region) + for i = #ch_list,2,-1 do + if not ch_list[i].region[region] then + table.remove(ch_list, i) + end + end +end + +function get_channel_list() + local mode = http.formvalue("mode") + local region = tonumber(http.formvalue("country_region")) or 1 + local ch_list + + if mtkwifi.band(mode) == "5G" then + ch_list = mtkwifi.ChannelList_5G_All + else + ch_list = mtkwifi.ChannelList_2G_All + end + + remove_ch_by_region(ch_list, region) + http.write_json(ch_list) +end + +function get_HT_ext_channel_list() + local ch_cur = tonumber(http.formvalue("ch_cur")) + local region = tonumber(http.formvalue("country_region")) or 1 + local ext_ch_list = {} + + if ch_cur <= 14 then -- 2.4G Channel + local ch_list = mtkwifi.ChannelList_2G_All + local below_ch = ch_cur - 4 + local above_ch = ch_cur + 4 + local i = 1 + + if below_ch > 0 and ch_list[below_ch + 1].region[region] then + ext_ch_list[i] = {} + ext_ch_list[i].val = 0 + ext_ch_list[i].text = ch_list[below_ch + 1].text + i = i + 1 + end + + if above_ch <= 14 and ch_list[above_ch + 1].region[region] then + ext_ch_list[i] = {} + ext_ch_list[i].val = 1 + ext_ch_list[i].text = ch_list[above_ch + 1].text + end + else -- 5G Channel + local ch_list = mtkwifi.ChannelList_5G_All + local ext_ch_idx = -1 + local len = 0 + + for k, v in ipairs(ch_list) do + len = len + 1 + if v.channel == ch_cur then + ext_ch_idx = (k % 2 == 0) and k + 1 or k - 1 + end + end + + if ext_ch_idx > 0 and ext_ch_idx < len and ch_list[ext_ch_idx].region[region] then + ext_ch_list[1] = {} + ext_ch_list[1].val = ext_ch_idx % 2 + ext_ch_list[1].text = ch_list[ext_ch_idx].text + end + end + + http.write_json(ext_ch_list) +end + +function get_5G_2nd_80Mhz_channel_list() + local ch_cur = tonumber(http.formvalue("ch_cur")) + local region = tonumber(http.formvalue("country_region")) + local ch_list = mtkwifi.ChannelList_5G_2nd_80MHZ_ALL + local ch_list_5g = mtkwifi.ChannelList_5G_All + local i, j, test_ch, test_idx + local bw80_1st_idx = -1 + + -- remove adjacent freqencies starting from list tail. + for i = #ch_list,1,-1 do + for j = 0,3 do + if ch_list[i].channel == -1 then + break + end + + test_ch = ch_list[i].channel + j * 4 + test_idx = ch_list[i].chidx + j + + if test_ch == ch_cur then + if i + 1 <= #ch_list and ch_list[i + 1] then + table.remove(ch_list, i + 1) + end + table.remove(ch_list, i) + bw80_1st_idx = i + break + end + + if i == (bw80_1st_idx - 1) or (not ch_list_5g[test_idx].region[region]) then + table.remove(ch_list, i) + break + end + end + end + + -- remove unused channel. + for i = #ch_list,1,-1 do + if ch_list[i].channel == -1 then + table.remove(ch_list, i) + end + end + http.write_json(ch_list) +end + +function apcli_cfg(dev, vif) + local devname = dev + mtkwifi.debug(devname) + local profiles = mtkwifi.search_dev_and_profile() + mtkwifi.debug(profiles[devname]) + assert(profiles[devname]) + + local cfgs = mtkwifi.load_profile(profiles[devname]) + + for k,v in pairs(http.formvalue()) do + if type(v) ~= type("") and type(v) ~= type(0) then + nixio.syslog("err", "apcli_cfg, invalid value type for "..k..","..type(v)) + elseif string.byte(k) ~= string.byte("_") then + cfgs[k] = v or "" + end + end + + cfgs.ApCliSsid = ''..mtkwifi.__handleSpecialChars(http.formvalue("ApCliSsid")) + local __authmode = http.formvalue("ApCliAuthMode") + if __authmode == "Disable" then + cfgs.ApCliAuthMode = "OPEN" + cfgs.ApCliEncrypType = "NONE" + elseif __authmode == "OPEN" or __authmode == "SHARED" then + cfgs.ApCliAuthMode = __authmode + cfgs.ApCliEncrypType = http.formvalue("wep_ApCliEncrypType") + else + cfgs.ApCliAuthMode = __authmode + cfgs.ApCliEncrypType = http.formvalue("wpa_ApCliEncrypType") + end + + mtkwifi.save_profile(cfgs, profiles[devname]) + + if http.formvalue("__apply") then + __mtkwifi_reload(devname) + end + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi", "apcli_cfg_view", dev, vif)) +end + +function apcli_connect(dev, vif) + -- dev_vif can be + -- 1. mt7620.apcli0 # simple case + -- 2. mt7615e.1.apclix0 # multi-card + -- 3. mt7615e.1.2G.apclix0 # multi-card & multi-profile + local devname,vifname = dev, vif + mtkwifi.debug("devname=", dev, "vifname=", vif) + mtkwifi.debug(devname) + mtkwifi.debug(vifname) + local profiles = mtkwifi.search_dev_and_profile() + mtkwifi.debug(profiles[devname]) + assert(profiles[devname]) + + local cfgs = mtkwifi.load_profile(profiles[devname]) + cfgs.ApCliEnable = "1" + mtkwifi.save_profile(cfgs, profiles[devname]) + + os.execute("ifconfig "..vifname.." up") + local brvifs = mtkwifi.__trim(mtkwifi.read_pipe("uci get network.lan.ifname")) + if not string.match(brvifs, vifname) then + brvifs = brvifs.." "..vifname + nixio.syslog("debug", "add "..vifname.." into lan") + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + os.execute("ubus call network.interface.lan add_device \"{\\\"name\\\":\\\""..vifname.."\\\"}\"") + end + + os.execute("iwpriv "..vifname.." set MACRepeaterEn="..cfgs.MACRepeaterEn) + os.execute("iwpriv "..vifname.." set ApCliEnable=0") + os.execute("iwpriv "..vifname.." set Channel="..cfgs.Channel) + os.execute("iwpriv "..vifname.." set ApCliAuthMode="..cfgs.ApCliAuthMode) + os.execute("iwpriv "..vifname.." set ApCliEncrypType="..cfgs.ApCliEncrypType) + if cfgs.ApCliAuthMode == "WEP" then + os.execute("#iwpriv "..vifname.." set ApCliDefaultKeyID="..cfgs.ApCliDefaultKeyID) + os.execute("#iwpriv "..vifname.." set ApCliKey1="..cfgs.ApCliKey1Str) + elseif cfgs.ApCliAuthMode == "WPAPSK" + or cfgs.ApCliAuthMode == "WPA2PSK" + or cfgs.ApCliAuthMode == "WPA1PSKWPA2PSK" then + os.execute("iwpriv "..vifname.." set ApCliWPAPSK="..cfgs.ApCliWPAPSK) + end + os.execute("iwpriv "..vifname.." set ApCliSsid=\""..cfgs.ApCliSsid.."\"") + os.execute("iwpriv "..vifname.." set ApCliEnable=1") + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi")) +end + +function apcli_disconnect(dev, vif) + -- dev_vif can be + -- 1. mt7620.apcli0 # simple case + -- 2. mt7615e.1.apclix0 # multi-card + -- 3. mt7615e.1.2G.apclix0 # multi-card & multi-profile + local devname,vifname = dev, vif + mtkwifi.debug("devname=", dev, "vifname", vif) + mtkwifi.debug(devname) + mtkwifi.debug(vifname) + local profiles = mtkwifi.search_dev_and_profile() + mtkwifi.debug(profiles[devname]) + assert(profiles[devname]) + + local cfgs = mtkwifi.load_profile(profiles[devname]) + cfgs.ApCliEnable = "1" + mtkwifi.save_profile(cfgs, profiles[devname]) + + os.execute("iwpriv "..vifname.." set ApCliEnable=0") + + local brvifs = mtkwifi.__trim(mtkwifi.read_pipe("uci get network.lan.ifname")) + if string.match(brvifs, vifname) then + brvifs = mtkwifi.__trim(string.gsub(brvifs, vifname, "")) + nixio.syslog("debug", "add "..vifname.." into lan") + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + os.execute("ubus call network.interface.lan remove_device \"{\\\"name\\\":\\\""..vifname.."\\\"}\"") + end + os.execute("ifconfig "..vifname.." down") + + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi")) +end + diff --git a/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_apcli.htm b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_apcli.htm new file mode 100644 index 000000000..063a8215f --- /dev/null +++ b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_apcli.htm @@ -0,0 +1,343 @@ + +<%+header%> + +<% +local disp = require "luci.dispatcher" +-- local request = disp.context.path +local request = disp.context.request +local mtkwifi = require("mtkwifi") +--local devname = string.match(request[5], "(mt.+)%.") +local devname = request[5] +local devs = mtkwifi.get_all_devs() +local dev = {} +local vif = {} +local vifidx +for _,v in ipairs(devs) do + if v.devname == devname then + dev = v + end +end + +local vifname = request[6] or dev.apcli.vifname +assert(vifname) +vif = dev and dev.vifs[vifname] or nil +vifidx = vif and vif.vifidx or nil +--print(devs, dev, dev.apcli, devname, vifname) + +local cfgs = mtkwifi.load_profile(dev.profile) +local debug = 0 +%> + + + + + +
" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, 'Some fields are invalid, cannot save values!')" autocomplete="off"> + +
+ Wireless Repeater - <%=devname.."@"..vifname%> +
 Manually setup apcli0 connection:
+        iwpriv <%=vifname%> set ApCliEnable=0              // disable sta mode first
+        iwpriv <%=vifname%> set ApCliAuthMode=             // root ap authentication mode
+        iwpriv <%=vifname%> set ApCliEncrypType=           // root ap encryption type
+        iwpriv <%=vifname%> set ApCliWPAPSK=               // root ap password
+        iwpriv <%=vifname%> set ApCliWirelessMode=         // root ap wifi mode
+        iwpriv <%=vifname%> set ApCliSsid=                 // root ap ssid
+        iwpriv <%=vifname%> set ApCliEnable=1              // enable sta mode
+
+

+ +

+ +
+
+
+
+ Connection Configurations + + + + + + + + + + + + + + + + + + + + + + + + + style="display: none;"<% end %>> + + + + + + + + + + + + style="display: none;"<% end %>> + + + + + + + + + + + +
MAC Repeater Mode + checked="checked"<% end %> /> Enable + checked="checked"<% end %> /> Disable +
Root AP SSID + +
Root AP Channel + + This will overwrite ap channel.
Root AP Authentication Mode + +
Root AP Encryption + +
Root AP WPA Key + +
Root AP Encryption + +
Root AP WEP Key + + +
+
+ +
+ + + +
+
+ + + +<%+footer%> diff --git a/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_dev_cfg.htm b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_dev_cfg.htm new file mode 100644 index 000000000..83f9f5cc8 --- /dev/null +++ b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_dev_cfg.htm @@ -0,0 +1,851 @@ + +<%+header%> + + +<% +local disp = require "luci.dispatcher" +-- local request = disp.context.path +local request = disp.context.request +local mtkwifi = require("mtkwifi") +local devname = request[5] +local devs = mtkwifi.get_all_devs() +local dev = {} +for _,v in ipairs(devs) do + if v.devname == devname then + dev = v + end +end + +local cfgs = mtkwifi.load_profile(dev.profile) + +%> + + + + + + +
" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, 'Some fields are invalid, cannot save values!')" autocomplete="false"> +
+ Device Configurations - <%=devname%> +<% +local diff = mtkwifi.diff_profile(dev.profile) +if next(diff) ~= nil then +%> + ('">reload to apply changes) +<% + end +%> + + + + + + + + + + + + + + + + + + + + + + + + <% if cfgs.HT_OpMode then %> + + + + + + <% end %> + <% if cfgs.HT_GI then %> + + + + + + <% end %> + + + + + + <% if cfgs.VHT_BW then %> + + + + + + + + + + + <% end %> + <% if cfgs.HT_STBC then %> + + + + + + <% end %> + <% if cfgs.HT_AMSDU then %> + + + + + + <% end %> + <% if cfgs.HT_AutoBA then %> + + + + + + <% end %> + <% if cfgs.HT_BADecline then %> + + + + + + <% end %> + <% if cfgs.HT_DisallowTKIP then %> + + + + + + <% end %> + <% if cfgs.HT_LDPC then %> + + + + + + <% end %> + <% if cfgs.VHT_SGI then %> + + + + + + <% end %> + <% if cfgs.VHT_STBC then %> + + + + + + <% end %> + <% if cfgs.VHT_BW_SIGNAL then %> + + + + + + <% end %> + <% if cfgs.VHT_LDPC then %> + + + + + + <% end %> + <% if cfgs.BGProtection then %> + + + + + + <% end %> + <% if cfgs.VHT_BW then %> + + + + + + <% end %> + <% if cfgs.BeaconPeriod then %> + + + + + + <% end %> + <% if cfgs.DtimPeriod then %> + + + + + + <% end %> + <% if cfgs.FragThreshold then %> + + + + + + <% end %> + <% if cfgs.RTSThreshold then %> + + + + + + <% end %> + <% if cfgs.TxPower then %> + + + + + + <% end %> + <% if cfgs.TxPreamble then %> + + + + + + <% end %> + <% if cfgs.ShortSlot then %> + + + + + + <% end %> + <% if cfgs.TxBurst then %> + + + + + + <% end %> + <% if cfgs.PktAggregate then %> + + + + + + <% end %> + <% if cfgs.IEEE80211H then %> + + + + + + <% end %> +
Mode + +
Channel + + <% if cfgs.ApCliEnable == "1" then %> APClient/Repeater Mode. <% end %>
Country Code + +
Country Region + +
Operating Mode + +
HT Guard Interval + +
Channel BandWidth + +
2G 40Mhz Ext Channel + + <% if cfgs.ApCliEnable == "1" then %> APClient/Repeater Mode. <% end %>
5G 2nd 80Mhz Channel + + <% if cfgs.ApCliEnable == "1" then %> APClient/Repeater Mode. <% end %>
STBC + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
A-MSDU + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
Auto Block ACK + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
Decline BA Request + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
HT Disallow TKIP + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
HT LDPC + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
VHT Short GI + +
VHT STBC + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
VHT BW Signaling + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable + checked="checked"<% end %>/> Dynamic +
VHT LDPC + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
BG Protection Mode + +
HT Protection + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
Beacon Interval + ms(range 20-999, default 100) +
Data Beacon Rate (DTIM) + ms(range 1-255, default 1) +
Fragment Threshold + (range 256-2346, default 2346) +
RTS Threshold + (range 256-2347, default 2347) +
TX Power + dbm(range 1-100, default 100) +
Short Preamble + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
Short Slot + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
TX Burst + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
Packet Aggregate + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
802.11H + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
+ + +
+
+ + + + +
+
+ + +
" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, 'Some fields are invalid, cannot save values!')" autocomplete="off"> +
+ Raw Configurations ( Edit WiFi profile directly ) +

WARNING : DO NOT MESS WITH IT IF YOU DON'T UNDERSTAND IT!

+ +
+
+ '" type="button" /> + + '" /> +
+
+ + + + +<%+footer%> diff --git a/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_overview.htm b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_overview.htm new file mode 100644 index 000000000..94c08c941 --- /dev/null +++ b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_overview.htm @@ -0,0 +1,171 @@ +<%+header%> + +<% +local mtkwifi = require("mtkwifi") +local devs = mtkwifi.get_all_devs() +%> +

Wireless Overview

+ + + + <% if #devs == 0 then %> +
+ No wireless device found. +
+ <% end %> + + <% for _,dev in ipairs(devs) do %> +
+ + + + + + + + + + + <% for _,vif in ipairs(dev.vifs) do %> + + + + + + + <% end %> + + + <% if dev.apcli then %> + + + + + + + <% end %> + + +
+ + + <%=dev.devname%> + <% + local diff = mtkwifi.diff_profile(dev.profile) + if next(diff) ~= nil then + %> + * need reload to apply changes + <% + end + %> +
+ work mode: <% if dev.ApCliEnable == "1" then %> APCli <% else %> AP<% end %> +
+ + '" /> + '" /> +
+ <% if vif.state == "up" then %> + + <% else %> + + <% end %> + Interface: <%=vif.vifname%> | Type: AP | SSID: <%=vif.__ssid%> | Channel: <%=vif.__channel or dev.Channel%> +
+ <% if vif.state == "up" then %> + BSSID::<%=vif.__bssid%> | Mode: <%=dev.WirelessModeList[tonumber(vif.__wirelessmode or dev.WirelessMode)]%> + <% else %> + Wireless is disabled or not associated + <% end %> +
+ <% if not vif.state then %> + + <% elseif vif.state == "up" then %> + '" /> + <% else %> + '" /> + <% end %> + '" /> + '" /> +
+ <% if dev.apcli.state == "up" then %> + + <% else %> + + <% end %> + Interface: <%=dev.apcli.devname%> | Type: STA | Status: <%=dev.apcli.status%> +
+ <% if dev.apcli.status == "Connected" then %> + BSSID::<%=dev.apcli.bssid%> | + SSID::<%=dev.apcli.ssid%> + <% else %> + Wireless is disabled or not associated + <% end %> +
+ <% if dev.apcli.state == "up" then %> + '" /> + <% else %> + '" /> + <% end %> + + <% if dev.apcli.status == "Connected" then %> + + <% else %> + + <% end %> + + '" /> +
+
+ <% end %> + + + + + +<%+footer%> diff --git a/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_vif_cfg.htm b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_vif_cfg.htm new file mode 100644 index 000000000..357c40975 --- /dev/null +++ b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_vif_cfg.htm @@ -0,0 +1,602 @@ + +<%+header%> + +<% +function any_wsc_enabled(wsc_conf_mode) + if (wsc_conf_mode == "7") then + return 1; + end + if (wsc_conf_mode == "4") then + return 1; + end + if (wsc_conf_mode == "2") then + return 1; + end + if (wsc_conf_mode == "1") then + return 1; + end + return 0; +end + +local disp = require "luci.dispatcher" +local path = disp.context.path +local request = disp.context.request +local mtkwifi = require("mtkwifi") +local devname +local vifname, vifidx +local dev = {} +local vif = {} + +if request[4] == "vif_add_view" then + devname, vifname = request[5], request[6] + local devs = mtkwifi.get_all_devs() + dev = devs and devs[devname] + vifname = vifname..#dev.vifs + vifidx = #dev.vifs + 1 + +elseif request[4] == "vif_cfg_view" then + devname, vifname = request[5], request[6] + local devs = mtkwifi.get_all_devs() + dev = devs and devs[devname] or nil + vif = dev and dev.vifs[vifname] or nil + vifidx = vif and vif.vifidx or nil +end + +local cfgs = mtkwifi.load_profile(dev.profile) +local WscValue = mtkwifi.token_get(cfgs["WscConfMode"], vifidx, "0") or "0" +%> + + + + + +
" enctype="multipart/form-data" onsubmit="return validate_security(<%=vifidx%>,<%=cfgs["HT_DisallowTKIP"]%>)" autocomplete="off"> +<% if not dev or not vif then%> +
+ Interface Not Exist - <%=vifname and devname.."@"..vifname or devname%> + +
+<% else %> +
+ Interface Configurations - <%=vifname and devname.."@"..vifname or devname%> +<% +local diff = mtkwifi.diff_profile(dev.profile) +if next(diff) ~= nil then +%> +('">reload to apply changes) +<% +end +%> + + + + + + + + <% if dev.DBDC_MODE == "0" then %> + + + + + <% end %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SSID + " required="required" /> + +
Channel + +
Auth Mode + +
Hidden + + checked="checked" + <% end %> type="checkbox" /> +
AP Isolation + + checked="checked" + <% end %> type="checkbox" /> +
WMM Capable + + checked="checked" + <% end %> type="checkbox" /> +
TX Rate + +
+ +
+# 1. one MAC one line.
+# 2. empty lines will be ignored.
+# 3. lines start with "#" will be ignored.
+# 4. invalid MAC will be ignored.
+
+11:22:33:44:55:66
+AA:BB:CC:DD:EE:FF
+11:22:33:aa:bb:cc
+ + +
+ +
+ + + + +
+<% end %> +
+ +<%+footer%> diff --git a/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/root/sbin/mtkwifi b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/root/sbin/mtkwifi new file mode 100644 index 000000000..0ffe38f11 --- /dev/null +++ b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/root/sbin/mtkwifi @@ -0,0 +1,199 @@ +#!/usr/bin/env lua +-- Alternative for OpenWrt's /sbin/wifi. +-- Copyright Not Reserved. +-- Hua Shao + +package.path = '/lib/wifi/?.lua;'..package.path + +local mtkwifi = require("mtkwifi") +local nixio = require("nixio") + +function usage() + print("wifi [devname]") +end + + +function wifi_common_up(devname) + nixio.syslog("debug", "wifi_common_up "..tostring(devname)) + + -- need to find out the vif prefix for this device + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "ra%a-%d+") then + os.execute("ifconfig "..vif.." up") + end + end + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "apcli%a-%d+") then + os.execute("ifconfig "..vif.." up") + end + end +end + + +function wifi_common_down(devname) + nixio.syslog("debug", "wifi_common_down "..tostring(devname)) + + -- need to find out the vif prefix for this device + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "apcli%d+") + or string.match(vif, "apclii%d+") then + os.execute("ifconfig "..vif.." down") + end + end + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "ra%d+") + or string.match(vif, "rai%d+") + or string.match(vif, "rae%d+") + or string.match(vif, "rax%d+") then + os.execute("ifconfig "..vif.." down") + end + end +end + +function wifi_common_reload(devname) + nixio.syslog("debug", "wifi_common_reload "..tostring(devname)) + wifi_common_up() + wifi_common_down() +end + +function wifi_common_restart(devname) + nixio.syslog("debug", "wifi_common_restart "..tostring(devname)) + wifi_common_reload() +end + +function wifi_common_reset(devname) + nixio.syslog("debug", "wifi_common_reset called!") + local curpath = "/etc/wireless/" + if devname then + curpath = curpath..devname.."/" + end + local defpath = "/rom"..defpath + if mtkwifi.exists(defpath) then + os.execute("rm -rf "..curpath) + os.execute("cp -rf "..defpath.." "..curpath) + wifi_common_reload() + else + nixio.syslog("debug", defpath.." missing, unable to reset!") + end +end + +function wifi_common_status(devname) + nixio.syslog("debug", "wifi_common_status "..tostring(devname)) + print(mtkwifi.read_pipe("iwconfig")) + print(mtkwifi.read_pipe("ifconfig -a")) +end + +function wifi_common_detect(devname) + nixio.syslog("debug", "wifi_common_detect "..tostring(devname)) + local devs = mtkwifi.getdevs() + for _,dev in ipairs(devs) do + print("config wifi-device "..dev.devname.. + "\n\toption type "..dev.devname.. + "\n\toption vendor ralink".. + "\n\toption channel "..dev.Channel) + for _,vif in ipairs(dev.vifs) do + print("\nconfig wifi-iface".. + "\n\toption device"..dev.devname.. + "\n\toption ifname"..vif.vifname.. + "\n\toption network lan".. + "\n\toption mode ap") + end + end +end + +for _,f in ipairs(string.split(mtkwifi.read_pipe("find /lib/wifi/ -name \"*.lua\" 2>/dev/null"), "\n")) do + dofile(f) +end + +function wifi(cmd, devname) + local mtkwifi = require("mtkwifi") + local devs, l1parser = mtkwifi.__get_l1dat() + if not devs or not l1parser then + return wifi_orig(cmd, devname) + end + + if devname then + local dev = devs.devname_ridx[devname] + assert(mtkwifi.exists(dev.init_script)) + local compatname = dev.init_compatible + assert(compatname) + + if _G[compatname.."_"..cmd] then + nixio.syslog("info", "call "..compatname.."_"..cmd.."("..devname..")") + _G[compatname.."_"..cmd](devname) + end + return + end + + -- if devname not not specified + for devname, dev in pairs(devs.devname_ridx) do + local compatname = dev.init_compatible + nixio.syslog("info", "call "..compatname.."_"..cmd.."("..devname..")") + _G[compatname.."_"..cmd](devname) + end +end + +function wifi_orig(cmd,devname) + local relname = nil + if devname then + relname = string.split(devname,".")[1] + end + + if relname then + if _G[relname.."_"..cmd] then + nixio.syslog("info", "call "..relname.."_"..cmd.."("..devname..")") + _G[relname.."_"..cmd](devname) + end + else + local devinfo = mtkwifi.search_dev_and_profile() + local done = {} + for __devname in pairs(devinfo) do + local __relname = string.split(__devname,".")[1] + repeat + -- common case + if done[__relname] then break else done[__relname] = true end + if _G[__relname.."_"..cmd] then + nixio.syslog("info", "call "..__relname.."_"..cmd.."("..__devname..")") + _G[__relname.."_"..cmd](__devname) + break + end + -- try shell + local dev_shell = "/lib/wifi/"..__relname..".sh" + if mtkwifi.exists(dev_shell) then + local cmd = "source "..dev_shell.."; "..__relname.."_"..cmd.." > /dev/null" + nixio.syslog("info", cmd) + if os.execute(cmd) ~= 0 then + nixio.syslog("err", cmd) + end + break + end + -- fall back on common api + nixio.syslog("info", "no scripts for "..__relname.." found, fall back on common api!") + _G["wifi_common_"..cmd](__devname) + until true + end + end +end + +cmd = arg[1] +dev = arg[2] + +if cmd == "up" +or cmd == "down" +or cmd == "status" +or cmd == "detect" +or cmd == "reload" +or cmd == "restart" +or cmd == "reset" then + wifi(cmd, dev) +elseif cmd == "reload_legacy" then + nixio.syslog("info", "legacy command "..cmd) + wifi("up", dev) +else + usage() +end + diff --git a/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/root/usr/lib/lua/mtkwifi.lua b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/root/usr/lib/lua/mtkwifi.lua new file mode 100644 index 000000000..b5128f215 --- /dev/null +++ b/package/mtk/applications/mtk-luci-plugin/luci-app-mtkwifi/root/usr/lib/lua/mtkwifi.lua @@ -0,0 +1,953 @@ +#!/usr/bin/env lua + +--[[ + * A lua library to manipulate mtk's wifi driver. used in luci-app-mtk. + * + * Hua Shao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. +]] + +local mtkwifi = {} +local _, nixio = pcall(require, "nixio") + +function mtkwifi.debug(...) + local ff = io.open("/tmp/mtkwifi.dbg.log", "a") + local vars = {...} + for _, v in pairs(vars) do + ff:write(v.." ") + end + ff:write("\n") + ff:close() +end + +if not nixio then + nixio.syslog = mtkwifi.debug +end + +function string:split(sep) + local sep, fields = sep or ":", {} + local pattern = string.format("([^%s]+)", sep) + self:gsub(pattern, function(c) fields[#fields+1] = c end) + return fields +end + +function mtkwifi.__trim(s) + if s then return (s:gsub("^%s*(.-)%s*$", "%1")) end +end + +function mtkwifi.__handleSpecialChars(s) + s = s:gsub("\\", "\\\\") + s = s:gsub("\"", "\\\"") + s = mtkwifi.__trim(s) + return s +end + +-- if order function given, sort by it by passing the table and keys a, b, +-- otherwise just sort the keys +function mtkwifi.__spairs(t, order) + -- collect the keys + local keys = {} + for k in pairs(t) do keys[#keys+1] = k end + table.sort(keys, order) + -- return the iterator function + local i = 0 + return function() + i = i + 1 + if keys[i] then + return keys[i], t[keys[i]] + end + end +end + +function mtkwifi.__lines(str) + local t = {} + local function helper(line) table.insert(t, line) return "" end + helper((str:gsub("(.-)\r?\n", helper))) + return t +end + +function mtkwifi.__get_l1dat() + if not pcall(require, "l1dat_parser") then + return + end + + local parser = require("l1dat_parser") + local l1dat = parser.load_l1_profile(parser.L1_DAT_PATH) + + return l1dat, parser +end + +function mtkwifi.sleep(s) + local ntime = os.clock() + s + repeat until os.clock() > ntime +end + +function mtkwifi.deepcopy(orig) + local orig_type = type(orig) + local copy + if orig_type == 'table' then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[mtkwifi.deepcopy(orig_key)] = mtkwifi.deepcopy(orig_value) + end + setmetatable(copy, mtkwifi.deepcopy(getmetatable(orig))) + else -- number, string, boolean, etc + copy = orig + end + return copy +end + +function mtkwifi.read_pipe(pipe) + local fp = io.popen(pipe) + local txt = fp:read("*a") + fp:close() + return txt +end + +function mtkwifi.load_profile(path, raw) + local cfgs = {} + local content + + if path then + local fd = io.open(path, "r") + if not fd then return end + content = fd:read("*all") + fd:close() + elseif raw then + content = raw + else + return + end + + -- convert profile into lua table + for _,line in ipairs(mtkwifi.__lines(content)) do + line = mtkwifi.__trim(line) + if string.byte(line) ~= string.byte("#") then + local i = string.find(line, "=") + if i then + local k,v + k = string.sub(line, 1, i-1) + v = string.sub(line, i+1) + if cfgs[mtkwifi.__trim(k)] then + mtkwifi.debug("warning", "skip repeated key"..line) + end + cfgs[mtkwifi.__trim(k)] = mtkwifi.__trim(v) or "" + else + mtkwifi.debug("warning", "skip line without '=' "..line) + end + else + mtkwifi.debug("warning", "skip comment line "..line) + end + end + return cfgs +end + +function mtkwifi.__profile_bak_path(profile) + local bak = "/tmp/mtk/wifi/"..string.match(profile, "([^/]+\.dat)")..".last" + os.execute("mkdir -p /tmp/mtk/wifi") + return bak +end + +function mtkwifi.save_profile(cfgs, path) + + if not cfgs then + mtkwifi.debug("configuration was empty, nothing saved") + return + end + + local fd = io.open(path, "w") + table.sort(cfgs, function(a,b) return a/dev/null")) or 0 + vifs[j].state = flags%2 == 1 and "up" or "down" + end + vifs[j].__ssid = cfgs["SSID"..j] + vifs[j].__bssid = mtkwifi.read_pipe("cat /sys/class/net/"..prefix..(j-1).."/address 2>/dev/null") or "?" + if dbdc then + vifs[j].__channel = mtkwifi.token_get(cfgs.Channel, j, 0) + vifs[j].__wirelessmode = mtkwifi.token_get(cfgs.WirelessMode, j, 0) + end + + vifs[j].__authmode = mtkwifi.token_get(cfgs.AuthMode, j, "OPEN") + vifs[j].__encrypttype = mtkwifi.token_get(cfgs.EncrypType, j, "NONE") + vifs[j].__hidessid = mtkwifi.token_get(cfgs.HideSSID, j, 0) + vifs[j].__noforwarding = mtkwifi.token_get(cfgs.NoForwarding, j, 0) + vifs[j].__wmmcapable = mtkwifi.token_get(cfgs.WmmCapable, j, 0) + vifs[j].__txrate = mtkwifi.token_get(cfgs.TxRate, j, 0) + vifs[j].__ieee8021x = mtkwifi.token_get(cfgs.IEEE8021X, j, 0) + vifs[j].__preauth = mtkwifi.token_get(cfgs.PreAuth, j, 0) + vifs[j].__rekeymethod = mtkwifi.token_get(cfgs.RekeyMethod, j, 0) + vifs[j].__rekeyinterval = mtkwifi.token_get(cfgs.RekeyInterval, j, 0) + vifs[j].__pmkcacheperiod = mtkwifi.token_get(cfgs.PMKCachePeriod, j, 0) + vifs[j].__ht_extcha = mtkwifi.token_get(cfgs.HT_EXTCHA, j, 0) + vifs[j].__radius_server = mtkwifi.token_get(cfgs.RADIUS_Server, j, 0) + vifs[j].__radius_port = mtkwifi.token_get(cfgs.RADIUS_Port, j, 0) + vifs[j].__wepkey_id = mtkwifi.token_get(cfgs.DefaultKeyID, j, 0) + vifs[j].__wscconfmode = mtkwifi.token_get(cfgs.WscConfMode, j, 0) + vifs[j].__wepkeys = { + cfgs["Key"..j.."Str1"], + cfgs["Key"..j.."Str2"], + cfgs["Key"..j.."Str3"], + cfgs["Key"..j.."Str4"], + } + vifs[j].__wpapsk = cfgs["WPAPSK"..j] + + -- VoW + vifs[j].__atc_tp = mtkwifi.token_get(cfgs.VOW_Rate_Ctrl_En, j, 0) + vifs[j].__atc_min_tp = mtkwifi.token_get(cfgs.VOW_Group_Min_Rate, j, "") + vifs[j].__atc_max_tp = mtkwifi.token_get(cfgs.VOW_Group_Max_Rate, j, "") + vifs[j].__atc_at = mtkwifi.token_get(cfgs.VOW_Airtime_Ctrl_En, j, 0) + vifs[j].__atc_min_at = mtkwifi.token_get(cfgs.VOW_Group_Min_Ratio, j, "") + vifs[j].__atc_max_at = mtkwifi.token_get(cfgs.VOW_Group_Max_Ratio, j, "") + + -- TODO index by vifname + vifs[vifs[j].vifname] = vifs[j] + end + + return vifs +end + +function mtkwifi.__setup_apcli(cfgs, devname, mainidx, subidx) + local l1dat, l1 = mtkwifi.__get_l1dat() + local dridx = l1dat and l1.DEV_RINDEX + + local apcli = {} + local dev_idx = string.match(devname, "(%w+)") + local apcli_prefix = l1dat and l1dat[dridx][devname].apcli_ifname or + dbdc_apcli_prefix[mainidx][subidx] + + local apcli_name = apcli_prefix.."0" + + if mtkwifi.exists("/sys/class/net/"..apcli_name) then + apcli.vifname = apcli_name + apcli.vifidx = "1" + local iwapcli = mtkwifi.read_pipe("iwconfig "..apcli_name.." | grep ESSID 2>/dev/null") + + local _,_,ssid = string.find(iwapcli, "ESSID:\"(.*)\"") + local flags = tonumber(mtkwifi.read_pipe("cat /sys/class/net/"..apcli_name.."/flags 2>/dev/null")) or 0 + apcli.state = flags%2 == 1 and "up" or "down" + if not ssid or ssid == "" then + apcli.status = "Disconnected" + else + apcli.ssid = ssid + apcli.status = "Connected" + end + apcli.devname = apcli_name + apcli.bssid = mtkwifi.read_pipe("cat /sys/class/net/"..apcli_name.."/address 2>/dev/null") or "?" + local flags = tonumber(mtkwifi.read_pipe("cat /sys/class/net/"..apcli_name.."/flags 2>/dev/null")) or 0 + apcli.ifstatus = flags%2 == 1 and "up" or "" + return apcli + else + return + end +end + +function mtkwifi.get_all_devs() + local devs = {} + local i = 1 -- dev idx + local profiles = mtkwifi.search_dev_and_profile() + local wpa_support = 0 + local wapi_support = 0 + + for devname,profile in pairs(profiles) do + mtkwifi.debug("debug", "checking "..profile) + + local fd = io.open(profile,"r") + if not fd then + mtkwifi.debug("debug", "cannot find "..profile) + else + fd:close() + mtkwifi.debug("debug", "load "..profile) + mtkwifi.debug("loading profile"..profile) + local cfgs = mtkwifi.load_profile(profile) + if not cfgs then + mtkwifi.debug("error loading profile"..profile) + mtkwifi.debug("err", "error loading "..profile) + return + end + devs[i] = {} + devs[i].vifs = {} + devs[i].apcli = {} + devs[i].devname = devname + devs[i].profile = profile + local tmp = "" + tmp = string.split(devname, ".") + devs[i].maindev = tmp[1] + devs[i].mainidx = tonumber(tmp[2]) or 1 + devs[i].subdev = devname + devs[i].subidx = string.match(tmp[3] or "", "(%d+)")=="2" and 2 or 1 + devs[i].devband = tonumber(tmp[3]) + if devs[i].devband then + devs[i].multiprofile = true + devs[i].dbdc = true + end + devs[i].version = mtkwifi.read_pipe("cat /etc/wireless/"..devs[i].maindev.."/version 2>/dev/null") or "unknown" + devs[i].ApCliEnable = cfgs.ApCliEnable + devs[i].WirelessMode = cfgs.WirelessMode + devs[i].WirelessModeList = {} + for key, value in pairs(DevicePropertyMap) do + local found = string.find(string.upper(devname), string.upper(value.device)) + if found then + for k=1,#value.band do + devs[i].WirelessModeList[tonumber(value.band[k])] = WirelessModeList[tonumber(value.band[k])] + end + end + end + devs[i].WscConfMode = cfgs.WscConfMode + devs[i].AuthModeList = AuthModeList + devs[i].WpsEnableAuthModeList = WpsEnableAuthModeList + + if wpa_support == 1 then + table.insert(devs[i].AuthModeList,"WPAPSK") + table.insert(devs[i].AuthModeList,"WPA") + end + + if wapi_support == 1 then + table.insert(devs[i].AuthModeList,"WAIPSK") + table.insert(devs[i].AuthModeList,"WAICERT") + end + devs[i].ApCliAuthModeList = ApCliAuthModeList + devs[i].WPA_Enc_List = WPA_Enc_List + devs[i].WEP_Enc_List = WEP_Enc_List + devs[i].Channel = tonumber(cfgs.Channel) + devs[i].DBDC_MODE = tonumber(cfgs.DBDC_MODE) + devs[i].band = devs[i].devband or mtkwifi.band(cfgs.WirelessMode) + + if cfgs.MUTxRxEnable then + if tonumber(cfgs.ETxBfEnCond)==1 + and tonumber(cfgs.MUTxRxEnable)==0 + and tonumber(cfgs.ITxBfEn)==0 + then devs[i].__mimo = 0 + elseif tonumber(cfgs.ETxBfEnCond)==0 + and tonumber(cfgs.MUTxRxEnable)==0 + and tonumber(cfgs.ITxBfEn)==1 + then devs[i].__mimo = 1 + elseif tonumber(cfgs.ETxBfEnCond)==1 + and tonumber(cfgs.MUTxRxEnable)==0 + and tonumber(cfgs.ITxBfEn)==1 + then devs[i].__mimo = 2 + elseif tonumber(cfgs.ETxBfEnCond)==1 + and tonumber(cfgs.MUTxRxEnable)>0 + and tonumber(cfgs.ITxBfEn)==0 + then devs[i].__mimo = 3 + elseif tonumber(cfgs.ETxBfEnCond)==1 + and tonumber(cfgs.MUTxRxEnable)>0 + and tonumber(cfgs.ITxBfEn)==1 + then devs[i].__mimo = 4 + else devs[i].__mimo = 5 + end + end + + if cfgs.HT_BW == "0" or not cfgs.HT_BW then + devs[i].__bw = "20" + elseif cfgs.HT_BW == "1" and cfgs.VHT_BW == "0" or not cfgs.VHT_BW then + if cfgs.HT_BSSCoexistence == "0" or not cfgs.HT_BSSCoexistence then + devs[i].__bw = "40" + else + devs[i].__bw = "60" -- 20/40 coexist + end + elseif cfgs.HT_BW == "1" and cfgs.VHT_BW == "1" then + devs[i].__bw = "80" + elseif cfgs.HT_BW == "1" and cfgs.VHT_BW == "2" then + devs[i].__bw = "160" + elseif cfgs.HT_BW == "1" and cfgs.VHT_BW == "3" then + devs[i].__bw = "161" + end + + devs[i].vifs = mtkwifi.__setup_vifs(cfgs, devname, devs[i].mainidx, devs[i].subidx) + devs[i].apcli = mtkwifi.__setup_apcli(cfgs, devname, devs[i].mainidx, devs[i].subidx) + + -- Setup reverse indices by devname + devs[devname] = devs[i] + + if devs[i].apcli then + devs[i][devs[i].apcli.devname] = devs[i].apcli + end + + i = i + 1 + end + end + return devs +end + +function mtkwifi.exists(path) + local fp = io.open(path, "rb") + if fp then fp:close() end + return fp ~= nil +end + +function mtkwifi.parse_mac(str) + local macs = {} + local pat = "^[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]$" + + local function ismac(str) + if str:match(pat) then return str end + end + + if not str then return macs end + local t = str:split("\n") + for _,v in pairs(t) do + local mac = ismac(mtkwifi.__trim(v)) + if mac then + table.insert(macs, mac) + end + end + + return macs + -- body +end + + +function mtkwifi.scan_ap(vifname) + os.execute("iwpriv "..vifname.." set SiteSurvey=0") + os.execute("sleep 10") -- depends on your env + local scan_result = mtkwifi.read_pipe("iwpriv "..vifname.." get_site_survey 2>/dev/null") + + local aplist = {} + local xx = {} + for i, line in ipairs(mtkwifi.__lines(scan_result)) do + if #line>40 and string.match(line, " BSSID ") then + xx.Ch = {string.find(line, "Ch "),3} + xx.SSID = {string.find(line, "SSID "),32} + xx.BSSID = {string.find(line, "BSSID "),17} + xx.Security = {string.find(line, "Security "),22} + xx.Signal = {string.find(line, "Sig%a%al"),4} + xx.Mode = {string.find(line, "W-Mode"),5} + xx.ExtCh = {string.find(line, "ExtCH"),6} + xx.WPS = {string.find(line, "WPS"),3} + xx.NT = {string.find(line, "NT"),2} + end + + local tmp = {} + if #line>40 and not string.match(line, " BSSID ") then + tmp = {} + tmp.channel = mtkwifi.__trim(string.sub(line, xx.Ch[1], xx.Ch[1]+xx.Ch[2])) + tmp.ssid = mtkwifi.__trim(string.sub(line, xx.SSID[1], xx.SSID[1]+xx.SSID[2])) + tmp.bssid = string.upper(mtkwifi.__trim(string.sub(line, xx.BSSID[1], xx.BSSID[1]+xx.BSSID[2]))) + tmp.security = mtkwifi.__trim(string.sub(line, xx.Security[1], xx.Security[1]+xx.Security[2])) + tmp.authmode = mtkwifi.__trim(string.split(tmp.security, "/")[1]) + tmp.encrypttype = mtkwifi.__trim(string.split(tmp.security, "/")[2] or "NONE") + tmp.rssi = mtkwifi.__trim(string.sub(line, xx.Signal[1], xx.Signal[1]+xx.Signal[2])) + tmp.extch = mtkwifi.__trim(string.sub(line, xx.ExtCh[1], xx.ExtCh[1]+xx.ExtCh[2])) + tmp.mode = mtkwifi.__trim(string.sub(line, xx.Mode[1], xx.Mode[1]+xx.Mode[2])) + tmp.wps = mtkwifi.__trim(string.sub(line, xx.WPS[1], xx.WPS[1]+xx.WPS[2])) + tmp.nt = mtkwifi.__trim(string.sub(line, xx.NT[1], xx.NT[1]+xx.NT[2])) + table.insert(aplist, tmp) + end + end + + return aplist +end + +function mtkwifi.__any_wsc_enabled(wsc_conf_mode) + if (wsc_conf_mode == "") then + return 0; + end + if (wsc_conf_mode == "7") then + return 1; + end + if (wsc_conf_mode == "4") then + return 1; + end + if (wsc_conf_mode == "2") then + return 1; + end + if (wsc_conf_mode == "1") then + return 1; + end + return 0; +end + +function mtkwifi.__restart_if_wps(devname, ifname, cfgs) + local devs = mtkwifi.get_all_devs() + local ssid_index = devs[devname]["vifs"][ifname].vifidx + local wsc_conf_mode = "" + + wsc_conf_mode=mtkwifi.token_get(cfgs["WscConfMode"], ssid_index, "") + + os.execute("iwpriv "..ifname.." set WscConfMode=0") + mtkwifi.debug("iwpriv "..ifname.." set WscConfMode=0") + os.execute("route delete 239.255.255.250") + mtkwifi.debug("route delete 239.255.255.250") + if(mtkwifi.__any_wsc_enabled(wsc_conf_mode)) then + os.execute("iwpriv "..ifname.." set WscConfMode=7") + mtkwifi.debug("iwpriv "..ifname.." set WscConfMode=7") + os.execute("route add -host 239.255.255.250 dev br0") + mtkwifi.debug("route add -host 239.255.255.250 dev br0") + end + + -- execute wps_action.lua file to send signal for current interface + os.execute("lua wps_action.lua "..ifname) + mtkwifi.debug("lua wps_action.lua "..ifname) + return cfgs +end + +function mtkwifi.restart_8021x(devname, devices) + local l1dat, l1 = mtkwifi.__get_l1dat() + local dridx = l1dat and l1.DEV_RINDEX + + local devs = devices or mtkwifi.get_all_devs() + local dev = devs[devname] + local main_ifname = l1dat and l1dat[dridx][devname].main_ifname or dbdc_prefix[mainidx][subidx].."0" + local prefix = l1dat and l1dat[dridx][devname].ext_ifname or dbdc_prefix[mainidx][subidx] + + local ps_cmd = "ps | grep -v grep | grep rt2860apd | grep "..main_ifname.." | awk '{print $1}'" + local pid_cmd = "cat /var/run/rt2860apd_"..devs[devname].vifs[1].vifname..".pid" + local apd_pid = mtkwifi.read_pipe(pid_cmd) or mtkwifi.read_pipe(ps_cmd) + if tonumber(apd_pid) then + os.execute("kill "..apd_pid) + end + + local cfgs = mtkwifi.load_profile(devs[devname].profile) + local auth_mode = cfgs['AuthMode'] + local ieee8021x = cfgs['IEEE8021X'] + local pat_auth_mode = {"WPA$", "WPA;", "WPA2$", "WPA2;", "WPA1WPA2$", "WPA1WPA2;"} + local pat_ieee8021x = {"1$", "1;"} + local apd_en = false + + for _, pat in ipairs(pat_auth_mode) do + if string.find(auth_mode, pat) then + apd_en = true + end + end + + for _, pat in ipairs(pat_ieee8021x) do + if string.find(ieee8021x, pat) then + apd_en = true + end + end + + if not apd_en then + return + end + + os.execute("rt2860apd -i "..main_ifname.." -p "..prefix) +end + +return mtkwifi diff --git a/package/mtk/applications/mtk-luci-plugin/luci-app-webconsole/Makefile b/package/mtk/applications/mtk-luci-plugin/luci-app-webconsole/Makefile new file mode 100644 index 000000000..3594622d3 --- /dev/null +++ b/package/mtk/applications/mtk-luci-plugin/luci-app-webconsole/Makefile @@ -0,0 +1,19 @@ +include $(TOPDIR)/rules.mk + +PKG_LICENSE:=GPLv2 +PKG_MAINTAINER:=Hua Shao + +LUCI_TITLE:=A simple web console. +LUCI_DEPENDS:= + +# earlier version of luci put "luci.mk" somewhere else... +LUCI_MK_OLDPATH:=$(shell test -e ../luci.mk && echo "old") +LUCI_MK_NEWPATH:=$(shell test -e ../../luci.mk && echo "new") +ifeq ($(LUCI_MK_OLDPATH),old) +include ../luci.mk +endif +ifeq ($(LUCI_MK_NEWPATH),new) +include ../../luci.mk +endif + +# call BuildPackage - OpenWrt buildroot signature diff --git a/package/mtk/applications/mtk-luci-plugin/luci-app-webconsole/luasrc/controller/webconsole.lua b/package/mtk/applications/mtk-luci-plugin/luci-app-webconsole/luasrc/controller/webconsole.lua new file mode 100644 index 000000000..5ec0bd164 --- /dev/null +++ b/package/mtk/applications/mtk-luci-plugin/luci-app-webconsole/luasrc/controller/webconsole.lua @@ -0,0 +1,23 @@ +-- A simple web console in case you don't have access to the shell +-- +-- Hua Shao + +module("luci.controller.webconsole", package.seeall) +local http = require("luci.http") +function index() + entry({"admin", "mtk", "console"}, template("mtk_web_console"), _("Web Console"), 4) + entry({"admin", "mtk", "webcmd"}, call("webcmd")) +end + +function webcmd() + local cmd = http.formvalue("cmd") + if cmd then + local fp = io.popen(tostring(cmd).." 2>&1") + local result = fp:read("*a") + fp:close() + result = result:gsub("<", "<") + http.write(tostring(result)) + else + http.write_json(http.formvalue()) + end +end diff --git a/package/mtk/applications/mtk-luci-plugin/luci-app-webconsole/luasrc/view/mtk_web_console.htm b/package/mtk/applications/mtk-luci-plugin/luci-app-webconsole/luasrc/view/mtk_web_console.htm new file mode 100644 index 000000000..c3aa4213b --- /dev/null +++ b/package/mtk/applications/mtk-luci-plugin/luci-app-webconsole/luasrc/view/mtk_web_console.htm @@ -0,0 +1,51 @@ +<%+header%> + +

Web Console

+
+
+ Execute shell commands or scripts as root. Be Careful. +

Press Enter to execute. Press Shift+Enter to start a new line.

+

+

+ + + + + + + +


+    
+
+ + + +<%+footer%> + diff --git a/package/mtk/applications/mtk-nvram/Makefile b/package/mtk/applications/mtk-nvram/Makefile new file mode 100644 index 000000000..2109d8605 --- /dev/null +++ b/package/mtk/applications/mtk-nvram/Makefile @@ -0,0 +1,94 @@ +# +# hua.shao@mediatek.com +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=mtk-nvram +PKG_RELEASE:=1 +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) +PKG_KCONFIG:=NVRAM_MTD_NAME + +PKG_MAINTAINER:=Hua Shao + +include $(INCLUDE_DIR)/package.mk + +define Package/nvram + SECTION:=MTK Properties + CATEGORY:=MTK Properties + SUBMENU:=Applications + TITLE:=MTK APSoC nvram tool + DEPENDS:=+libnvram + MENU:=1 +endef + +define Package/nvram/config + source "$(SOURCE)/config.in" +endef + +define Package/flash + SECTION:=MTK Properties + CATEGORY:=MTK Properties + SUBMENU:=Applications + TITLE:=MTK APSoC flash R/W tool + DEPENDS:=+libnvram +endef + +define Package/libnvram + SECTION:=MTK Properties + CATEGORY:=MTK Properties + SUBMENU:=Libraries + TITLE:=MTK APSoC nvram library + DEPENDS:= +endef + +define Package/nvram/description + MTK nvram tool +endef + +define Package/flash/description + flash r/w tool +endef + +define Package/libnvram/description + MTK nvram library +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) + $(CP) ./src/* $(PKG_BUILD_DIR)/ + $(call Build/Prepare/Default) +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) ./src/nvram.h $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/lib*.so $(1)/usr/lib/ +endef + + +MAKE_FLAGS += \ + CONFIG_NVRAM_MTD_NAME=$(CONFIG_NVRAM_MTD_NAME) + + +define Package/nvram/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/nvram $(1)/usr/bin +endef + +define Package/flash/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/flash $(1)/usr/bin +endef + +define Package/libnvram/install + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_BIN) $(PKG_BUILD_DIR)/*.so $(1)/usr/lib +endef + + +$(eval $(call BuildPackage,libnvram)) +$(eval $(call BuildPackage,nvram)) +$(eval $(call BuildPackage,flash)) + diff --git a/package/mtk/applications/mtk-nvram/config.in b/package/mtk/applications/mtk-nvram/config.in new file mode 100644 index 000000000..633c88ba0 --- /dev/null +++ b/package/mtk/applications/mtk-nvram/config.in @@ -0,0 +1,6 @@ +menu "nvram Features" + depends on PACKAGE_nvram +config NVRAM_MTD_NAME + string "mtd name for nvram" + default "Config" +endmenu diff --git a/package/mtk/applications/mtk-nvram/src/Makefile b/package/mtk/applications/mtk-nvram/src/Makefile new file mode 100644 index 000000000..abe3b8ce7 --- /dev/null +++ b/package/mtk/applications/mtk-nvram/src/Makefile @@ -0,0 +1,35 @@ +exe1 := nvram +exe2 := flash +lib:= libnvram.so +libobjs := crc32.o flash.o nvram.o +exe1objs := main_nvram.o +exe2objs := main_flash.o + +CFLAGS += -Wall + +ifdef CONFIG_NVRAM_MTD_NAME +CFLAGS += -DNVRAM_MTD_NAME=\"$(CONFIG_NVRAM_MTD_NAME)\" +endif + +all: $(lib) $(exe1) $(exe2) + +$(lib) : $(libobjs) + $(CC) $(CFLAGS) -shared -o $@ $^ + +$(exe1) : $(exe1objs) $(lib) + $(CC) $(CFLAGS) -o $@ $^ + +$(exe2) : $(exe2objs) flash.o + $(CC) $(CFLAGS) -o $@ $^ + +$(exe1objs): %.o : %.c + $(CC) $(CFLAGS) -fPIC -c $< -o $@ + +$(exe2objs): %.o : %.c + $(CC) $(CFLAGS) -fPIC -c $< -o $@ + +$(libobjs): %.o : %.c + $(CC) $(CFLAGS) -fPIC -c $< -o $@ + +clean: + -rm *.o $(exe1) $(exe2) $(lib) diff --git a/package/mtk/applications/mtk-nvram/src/crc32.c b/package/mtk/applications/mtk-nvram/src/crc32.c new file mode 100644 index 000000000..f337dc304 --- /dev/null +++ b/package/mtk/applications/mtk-nvram/src/crc32.c @@ -0,0 +1,88 @@ +/****************************************************************** + * $File: crc32.c + * + * $Author: Hua Shao + * $Date: Oct, 2014 + * + ******************************************************************/ +#include + +static const uint32_t crc_table[256] = +{ + 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, + 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, + 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, + 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, + 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, + 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, + 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, + 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, + 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, + 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, + 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, + 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, + 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, + 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, + 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, + 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, + 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, + 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, + 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, + 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, + 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, + 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, + 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, + 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, + 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, + 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, + 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, + 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, + 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, + 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, + 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, + 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, + 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, + 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, + 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, + 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, + 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, + 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, + 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, + 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, + 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, + 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, + 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, + 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, + 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, + 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, + 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, + 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, + 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, + 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, + 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, + 0x2d02ef8dL +}; + + +#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); +#define DO2(buf) DO1(buf); DO1(buf); +#define DO4(buf) DO2(buf); DO2(buf); +#define DO8(buf) DO4(buf); DO4(buf); + +uint32_t crc32(uint32_t crc, const uint8_t *buf, uint32_t len) +{ + crc = crc ^ 0xffffffffL; + while (len >= 8) + { + DO8(buf); + len -= 8; + } + if (len) do + { + DO1(buf); + } + while (--len); + return crc ^ 0xffffffffL; +} + + diff --git a/package/mtk/applications/mtk-nvram/src/crc32.h b/package/mtk/applications/mtk-nvram/src/crc32.h new file mode 100644 index 000000000..81c7a981a --- /dev/null +++ b/package/mtk/applications/mtk-nvram/src/crc32.h @@ -0,0 +1,16 @@ +/****************************************************************** + * $File: crc32.h + * + * $Author: Hua Shao + * $Date: Oct, 2014 + * + ******************************************************************/ + +#ifndef CRC32_H +#define CRC32_H + +#include + +uint32_t crc32(uint32_t crc, const uint8_t *buf, uint32_t len); + +#endif /* CRC32_H */ diff --git a/package/mtk/applications/mtk-nvram/src/flash.c b/package/mtk/applications/mtk-nvram/src/flash.c new file mode 100644 index 000000000..d5469716b --- /dev/null +++ b/package/mtk/applications/mtk-nvram/src/flash.c @@ -0,0 +1,252 @@ +/****************************************************************** + * $File: flash.c + * + * $Author: Hua Shao + * $Date: Oct, 2014 + * + ******************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nvram.h" +#include "flash.h" + +struct mtd_info_user +{ + uint8_t type; + uint32_t flags; + uint32_t size; + uint32_t erasesize; + uint32_t oobblock; + uint32_t oobsize; + uint32_t ecctype; + uint32_t eccsize; +}; + +struct erase_info_user +{ + uint32_t start; + uint32_t length; +}; + +#define MEMGETINFO _IOR('M', 1, struct mtd_info_user) +#define MEMERASE _IOW('M', 2, struct erase_info_user) +#define min(x,y) ({ typeof(x) _x = (x); typeof(y) _y = (y); (void) (&_x == &_y); _x < _y ? _x : _y; }) + +int32_t mtd_open(const char *name, int32_t flags) +{ + FILE *fp; + char dev[80]; + int i, ret; + + if (strstr(name, "/dev/mtd")) + { + return open(name, flags); + } + + if ((fp = fopen("/proc/mtd", "r"))) + { + while (fgets(dev, sizeof(dev), fp)) + { + if (sscanf(dev, "mtd%d:", &i) && strstr(dev, name)) + { + snprintf(dev, sizeof(dev), "/dev/mtd%d", i); + if ((ret = open(dev, flags)) < 0) + { + snprintf(dev, sizeof(dev), "/dev/mtd/%d", i); + ret = open(dev, flags); + } + fclose(fp); + return ret; + } + } + fclose(fp); + } + fprintf(stderr, "Could not open mtd device, %s\n", strerror(errno)); + return -1; +} + +uint32_t mtd_size(const char *name) +{ + FILE *fp; + char buf[80]; + + if ((fp = fopen("/proc/mtd", "r"))) + { + while (fgets(buf, sizeof(buf), fp)) + { + if (strstr(buf, name)) + { + char * p = strchr(buf, ' '); + ASSERT(p); + p++; + fclose(fp); + return strtoul(p,0,16); + } + } + } + fclose(fp); + return 0; +} + + +int32_t flash_read(char *path, char *buf, off_t from, size_t len) +{ + int32_t fd, ret; + struct mtd_info_user info; + + fd = mtd_open(path, O_RDONLY); + if (fd < 0) + { + fprintf(stderr, "Could not open mtd device\n"); + return -1; + } + + if (ioctl(fd, MEMGETINFO, &info)) + { + fprintf(stderr, "Could not get mtd device info\n"); + close(fd); + return -1; + } + if (len > info.size) + { + fprintf(stderr, "Too many bytes - %zu > %u bytes\n", len, info.erasesize); + close(fd); + return -1; + } + + lseek(fd, from, SEEK_SET); + ret = read(fd, buf, len); + if (ret == -1) + { + fprintf(stderr, "Reading from mtd failed\n"); + close(fd); + return -1; + } + + close(fd); + return ret; +} + + +int32_t flash_write(char *path, char *buf, off_t to, size_t len) +{ + int32_t fd, ret = 0; + struct mtd_info_user info; + struct erase_info_user ei; + + fd = mtd_open(path, O_RDWR | O_SYNC); + if (fd < 0) + { + fprintf(stderr, "Could not open mtd device\n"); + return -1; + } + + if (ioctl(fd, MEMGETINFO, &info)) + { + fprintf(stderr, "Could not get mtd device info\n"); + close(fd); + return -1; + } + if (len > info.size) + { + fprintf(stderr, "Too many bytes - %zu > %u bytes\n", len, info.erasesize); + close(fd); + return -1; + } + + while (len > 0) + { + if ((len & (info.erasesize-1)) || (len < info.erasesize)) + { + int piece_size; + unsigned int piece, bakaddr; + char *bak = NULL; + + bak = (char *)malloc(info.erasesize); + if (bak == NULL) + { + fprintf(stderr, "Not enough memory\n"); + close(fd); + return -1; + } + + bakaddr = to & ~(info.erasesize - 1); + lseek(fd, bakaddr, SEEK_SET); + + ret = read(fd, bak, info.erasesize); + if (ret == -1) + { + fprintf(stderr, "Reading from mtd failed\n"); + close(fd); + free(bak); + return -1; + } + + piece = to & (info.erasesize - 1); + piece_size = min((uint32_t)len, info.erasesize - piece); + memcpy(bak + piece, buf, piece_size); + + ei.start = bakaddr; + ei.length = info.erasesize; + if (ioctl(fd, MEMERASE, &ei) < 0) + { + fprintf(stderr, "Erasing mtd failed\n"); + close(fd); + free(bak); + return -1; + } + + lseek(fd, bakaddr, SEEK_SET); + ret = write(fd, bak, info.erasesize); + if (ret == -1) + { + fprintf(stderr, "Writing to mtd failed\n"); + close(fd); + free(bak); + return -1; + } + + free(bak); + buf += piece_size; + to += piece_size; + len -= piece_size; + } + else + { + ei.start = to; + ei.length = info.erasesize; + if (ioctl(fd, MEMERASE, &ei) < 0) + { + fprintf(stderr, "Erasing mtd failed\n"); + close(fd); + return -1; + } + + ret = write(fd, buf, info.erasesize); + if (ret == -1) + { + fprintf(stderr, "Writing to mtd failed\n"); + close(fd); + return -1; + } + + buf += info.erasesize; + to += info.erasesize; + len -= info.erasesize; + } + } + + close(fd); + return ret; +} + + diff --git a/package/mtk/applications/mtk-nvram/src/flash.h b/package/mtk/applications/mtk-nvram/src/flash.h new file mode 100644 index 000000000..b9f000a31 --- /dev/null +++ b/package/mtk/applications/mtk-nvram/src/flash.h @@ -0,0 +1,19 @@ +/****************************************************************** + * $File: flash.h + * + * $Author: Hua Shao + * $Date: Oct, 2014 + * + ******************************************************************/ + +#ifndef FLASH_H +#define FLASH_H + +#include + +uint32_t mtd_size(const char *name); +int32_t flash_read(char *path, char *buf, off_t from, size_t len); +int32_t flash_write(char *path, char *buf, off_t to, size_t len); + +#endif /* FLASH_H */ + diff --git a/package/mtk/applications/mtk-nvram/src/layout.h b/package/mtk/applications/mtk-nvram/src/layout.h new file mode 100644 index 000000000..312cac15f --- /dev/null +++ b/package/mtk/applications/mtk-nvram/src/layout.h @@ -0,0 +1,52 @@ +/****************************************************************** + * $File: layout.h + * + * $Author: Hua Shao + * $Date: Oct, 2014 + * + ******************************************************************/ + +#ifndef LAYOUT_H +#define LAYOUT_H + +/* uncomment NVRAM_CUSTOM_LAYOUT to enable your layout. */ + +// #define NVRAM_CUSTOM_LAYOUT + +#ifdef NVRAM_CUSTOM_LAYOUT +static layout_t nvlayout[] = +{ + /* the first 4KB of "Config" is reserved for uboot. */ + { + .name = "uboot", + .offset = 0x0, + .size = 0x1000, + .flag = NV_RO, + }, + /* you can use the rest space, up to 60KB. */ + { + .name = "2860", + .offset = 0x2000, + .size = 0x4000, + }, + { + .name = "rtdev", + .offset = 0x6000, + .size = 0x2000, + }, + { + .name = "cert", + .offset = 0x8000, + .size = 0x2000, + }, + { + .name = "wapi", + .offset = 0xa000, + .size = 0x5000, + }, +}; +#endif /* NVRAM_CUSTOM_LAYOUT */ + +#endif /* LAYOUT_H */ + + diff --git a/package/mtk/applications/mtk-nvram/src/main_flash.c b/package/mtk/applications/mtk-nvram/src/main_flash.c new file mode 100644 index 000000000..7f04a9a95 --- /dev/null +++ b/package/mtk/applications/mtk-nvram/src/main_flash.c @@ -0,0 +1,94 @@ +/****************************************************************** + * $File: main.c + * + * $Author: Hua Shao + * $Date: Oct, 2014 + * + ******************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#include "flash.h" + + +int usage(void) +{ + printf("%s", "flash r \n"); + printf("%s", "flash w <0xNN> [<0xNN> ...]\n"); + return 0; +} + +int main(int argc, char ** argv) +{ + int off = 0; + int len = 0; + int ret = 0; + int i = 0; + char * buf = NULL; + + if (argc < 5) + return usage(); + + if (0 == strcmp(argv[1], "r")) + { + off = atoi(argv[3]); + len = atoi(argv[4]); + buf = (char *)malloc(len); + if (!buf) + { + fprintf(stderr, "failed to alloc buf[%d], %s\n", len, strerror(errno)); + return -1; + } + memset(buf, 0, len); + + ret = flash_read(argv[2], buf, off, len); + if (ret < 0) + { + fprintf(stderr, "failed to read buf[%d], %s\n", len, strerror(errno)); + if (buf) free(buf); + return -1; + } + + for(i=0; i +#include "nvram.h" + +int32_t usage(int32_t reason) +{ + if (reason != OK) + printf("Invalid usage! "); + fprintf(stderr, "Usage:\n" + "\tnvram get
\n" + "\t\t Get a value from the section by name. It operates in cache.\n" + "\tnvram set
\n" + "\t\t Set a value into the section by name. It operates in cache.\n" + "\tnvram del
\n" + "\t\t Delete an entry in the section by name. It operates in cache.\n" + "\tnvram commit\n" + "\t\t Flush cache into flash.\n" + "\tnvram layout\n" + "\t\t Display nvram sections layout.\n" + "\tnvram show [section]\n" + "\t\t Display all entries in nvram. Section name is optional.\n" + "\tnvram loadfile
\n" + "\t\t Load nvram entries from a file, and flush it into the section.\n" + "\tnvram clear
\n" + "\t\t DANGEROUS! Clear all nvram entries inside flash.\n" + ); + return OK; +} + + +int32_t main(int32_t argc, char ** argv) +{ +#if 0 + int32_t i = 0; + + for(i=0; i +#include +#include +#include +#include +#include +#include + +#include "nvram.h" +#include "crc32.h" +#include "flash.h" + + +#define MAX_ENTRY 500 + + +typedef struct +{ + char * name; + char * value; +} entry_t; + +typedef struct +{ + char * name; + uint32_t offset; + uint32_t size; + uint32_t flag; + uint32_t crc; + entry_t cache[MAX_ENTRY]; +} section_t; + + +#define NV_RO (1) /* read only */ + +typedef struct +{ + char * name; + uint32_t offset; + uint32_t size; + uint32_t flag; +} layout_t; + +#include "layout.h" + +#ifndef NVRAM_CUSTOM_LAYOUT + +/* this is a demo layout, + please make your own layout in layout.h +*/ + +static layout_t nvlayout[] = +{ + /* the first 4KB of "Config" is reserved for uboot. */ + { + .name = "uboot", + .offset = 0x0, + .size = 0x1000, + .flag = NV_RO, + }, + { + .name = "readonly", + .offset = 0x1000, + .size = 0x1000, + .flag = NV_RO, + }, + { + .name = "test1", + .offset = 0x2000, + .size = 0x4000, + .flag = 0, + }, + { + .name = "test2", + .offset = 0x6000, + .size = 0x2000, + .flag = 0, + }, + { + .name = "test3", + .offset = 0x8000, + .size = 0x8000, + }, +}; +#endif + + +static uint32_t nvram_mtd_size = 0; +static section_t * nvramcache = NULL; +static uint32_t sectionnum = sizeof(nvlayout)/sizeof(layout_t); + +static section_t * _nvram_section(char * name) +{ + int32_t i = 0; + for (i=0; iflag & NV_RO) + { + fprintf(stderr, "section \"%s\"is read-only!\n", section); + return NG; + } + + /* check if name exists */ + for (i=0; icache[i].name && + 0 == strcmp(key, sect->cache[i].name)) + break; + } + + if (i >= MAX_ENTRY) + { + fprintf(stderr, "no such entry!\n"); + return NG; + } + + sfree(sect->cache[i].name); + sfree(sect->cache[i].value); + + return OK; + +} + + +static int32_t _nvram_buf_set(char * section, char * key, char * value) +{ + int32_t i = 0; + section_t * sect = NULL; + + DEBUG("%s(%s,%s,%s)\n", __FUNCTION__, section, key, value); + + sect = _nvram_section(section); + if (!sect) + return NG; + + if (sect->flag & NV_RO) + { + fprintf(stderr, "section \"%s\"is read-only!\n", section); + return NG; + } + + /* check if name exists */ + for (i=0; icache[i].name && + 0 == strcmp(key, sect->cache[i].name)) + break; + } + if (i < MAX_ENTRY) + goto __set; + + /* else, find an empty room */ + for (i=0; icache[i].name) + break; + } + if (i >= MAX_ENTRY) + { + fprintf(stderr, "no empty room found! %s\n", __FUNCTION__); + return NG; + } + + ASSERT(!sect->cache[i].name); + ASSERT(!sect->cache[i].value); + +__set: + sect->cache[i].name = strdup(key); + sect->cache[i].value = strdup(value); + + return OK; +} + +static char * _nvram_buf_get(char * section, char * key) +{ + int32_t i = 0; + section_t * sect = NULL; + + DEBUG("%s(%s,%s)\n", __FUNCTION__, section, key); + + sect = _nvram_section(section); + if (!sect) + return NULL; + + for (i=0; icache[i].name && + 0 == strcmp(sect->cache[i].name, key)) + { + printf("%s\n", sect->cache[i].value); + return sect->cache[i].value; + } + } + + fprintf(stderr, "no such entry!\n"); + return NULL; +} + + + +int32_t nvram_parse(char * section, char * cachefile) +{ + int32_t rc = 0; + FILE * fp = NULL; + size_t len = 0; + char * data, * p = NULL, * q = NULL; + int32_t i = 0, j = 0; + + API(); + + fp = fopen(cachefile, "r+b"); + if (!fp) + { + fprintf(stderr, "failed to load %s, %s, %s\n", cachefile, strerror(errno), __FUNCTION__); + return NG; + } + + fseek(fp, 0, SEEK_END); + len = ftell(fp); + fseek(fp, 0, SEEK_SET); + + data = (char *)malloc(len); + if(!data) + { + fprintf(stderr, "failed to alloc buffer (%zu) for nvram! %s.\n", len, __FUNCTION__); + fclose(fp); + return NG; + } + memset(data, 0, len); + rc = fread(data, 1, len, fp); + DEBUG("rc %d, len %zu\n", rc, len); + ASSERT(rc == len); + + nvramcache = (section_t *)malloc(sizeof(section_t)*sectionnum); + memset(nvramcache, 0, sizeof(sizeof(section_t)*sectionnum)); + for (i = 0; i 128) break; + q = strchr(p, '='); + if (!q) + { + fprintf(stderr, "nvram format error, offset %d, in %s!\n", + (int32_t)(p-data), nvlayout[i].name); + break; + } + *q = 0; + q++; + DEBUG("\t<%s>=<%s>\n", p, q); + nvramcache[i].cache[j].name = strdup(p); + nvramcache[i].cache[j].value = strdup(q); + p = q + strlen(q) + 1; + j++; + } + } + + if (data) free(data); + fclose(fp); + return OK; +} + + +int32_t nvram_commit(char flash) +{ + int32_t rc = OK; + int32_t sect = 0, i = 0; + FILE * fp = NULL; + char * buffer = NULL, * p = NULL, * q = NULL; + + API(); + + fp = fopen(NVRAM_CACHE_FILE, "r+"); + if(!fp) + { + fprintf(stderr, "failed to open %s, %s.\n", NVRAM_CACHE_FILE, __FUNCTION__); + rc = NG; + goto __quit; + } + + buffer = (char *)malloc(nvram_mtd_size); + if(!buffer) + { + fprintf(stderr, "failed to alloc buffer (%d) for nvram! %s.\n", nvram_mtd_size, __FUNCTION__); + rc = NG; + goto __quit; + } + + for (sect=0; sect=q) + { + fprintf(stderr, "exceed nvram section size %u!\n", nvramcache[sect].size); + rc = NG; + goto __quit; + } + sprintf(p, "%s=%s", + nvramcache[sect].cache[i].name, + nvramcache[sect].cache[i].value); + p += l; + } + } + *p = '\0'; // just make sure + + nvramcache[sect].crc = + crc32(0, (uint8_t *)(buffer + nvramcache[sect].offset+4), nvramcache[sect].size-4); + *(uint32_t *)(buffer + nvramcache[sect].offset) = nvramcache[sect].crc; + DEBUG("cal crc32 = 0x%8x!\n", nvramcache[sect].crc); + + fseek(fp, nvramcache[sect].offset, SEEK_SET); + DEBUG("write nvram raw data, offset %u, size %u!\n", + nvramcache[sect].offset, nvramcache[sect].size); + i = fwrite(buffer + nvramcache[sect].offset, 1, nvramcache[sect].size, fp); + ASSERT(i == nvramcache[sect].size); + } + + if (flash) + { + i = flash_write(NVRAM_MTD_NAME, buffer, 0, nvram_mtd_size); + ASSERT(i>0); + } + + +__quit: + sfree(buffer); + fclose(fp); + return rc; +} + + +char * nvram_get(char * section, char * key) +{ + API(); + return _nvram_buf_get(section, key); +} + + +int32_t nvram_del(char * section, char * key) +{ + API(); + + if (OK == _nvram_buf_del(section, key)) + return nvram_commit(0); + return NG; +} + + +int32_t nvram_set(char * section, char * key, char * value) +{ + API(); + if (OK == _nvram_buf_set(section, key, value)) + return nvram_commit(0); + return NG; +} + +int32_t nvram_show(char * section) +{ + int32_t i = 0, j = 0; + API(); + for (i=0; iflag & NV_RO)) + { + fprintf(stderr, "invalid section!\n"); + return NG; + } + + fseek(fp, sec->offset, SEEK_SET); + + buffer = (char *)malloc(sec->size); + if(!buffer) + { + fprintf(stderr, "failed to alloc buffer (%d) for nvram! %s.\n", sec->size, __FUNCTION__); + fclose(fp); + return NG; + } + memset(buffer, 0, sec->size); + + sec->crc = + crc32(0, (uint8_t *)(buffer+4), sec->size-4); + *(uint32_t *)(buffer) = sec->crc; + + i = fwrite(buffer, sec->size, 1, fp); + ASSERT(i == 1); + + fclose(fp); + return OK; +} + +int32_t nvram_loadfile(char * section, char * defile) +{ + API(); + + if (OK == nvram_parse(section, defile)) + return nvram_commit(1); + + return NG; +} + + +int32_t nvram_filecache(char * defile) +{ + int32_t rc = OK; + FILE * fp = NULL; + struct stat statbuf; + char * buffer = NULL; + int32_t i; + + API(); + + nvram_mtd_size = mtd_size(NVRAM_MTD_NAME); + DEBUG("mtd_size(%s) = %u\n", NVRAM_MTD_NAME, nvram_mtd_size); + if (nvram_mtd_size <= 0) + return NG; + + + /* create a cache file */ + rc = stat(defile, &statbuf); + if (!rc) + { + DEBUG("cache file %s is ready.\n", defile); + return OK; + } + + + fp = fopen(defile, "w+b"); + if (!fp) + { + fprintf(stderr, "failed to create %s, %s, %s\n", + defile, strerror(errno), __FUNCTION__); + return NG; + } + DEBUG("cache file %s, created.\n", defile); + + buffer = (char *)malloc(nvram_mtd_size); + if(!buffer) + { + fprintf(stderr, "failed to alloc %d bytes for , %s, %s\n", + nvram_mtd_size, defile, __FUNCTION__); + fclose(fp); + return NG; + } + rc = fwrite(buffer, 1, nvram_mtd_size, fp); + ASSERT(rc == nvram_mtd_size); + + /* dump nvram partition into a cache file. */ + for (i=0; i +#include +#include + +#ifndef NVRAM_CACHE_FILE +#define NVRAM_CACHE_FILE "/tmp/.nvramcache" +#endif + +#ifndef NVRAM_MTD_NAME +#define NVRAM_MTD_NAME "Config" +#endif + + +#define OK (0) +#define NG (-1) + +#if 0 +#define DEBUG(...) do{ fprintf(stderr, " ");printf(__VA_ARGS__);} while(0) +#define API() fprintf(stderr, " api: %s.\n", __FUNCTION__) +#else +#define DEBUG(...) +#define API() +#endif +#define ASSERT(cond) \ + do { \ + if(!(cond)) \ + { \ + fprintf(stderr, " assert [%s] fail, %s L%d\n", #cond, __FUNCTION__, __LINE__); \ + exit(-1); \ + } \ + } while(0) + +#define sfree(p) do {if(p) { free(p); p = NULL;} } while(0) + +char * nvram_get(char * section, char * key); +int32_t nvram_set(char * section, char * key, char * value); +int32_t nvram_del(char * section, char * key); +int32_t nvram_show(char * section); +int32_t nvram_layout(void); +int32_t nvram_loadfile(char * section, char * defile); +int32_t nvram_filecache(char * defile); +int32_t nvram_clear(char * section); +int32_t nvram_parse(char * section, char * cachefile); +int32_t nvram_commit(char flash); + +#endif /* NVRAM_H */ + diff --git a/package/mtk/applications/uci2dat/Makefile b/package/mtk/applications/uci2dat/Makefile new file mode 100644 index 000000000..9fe62ca9a --- /dev/null +++ b/package/mtk/applications/uci2dat/Makefile @@ -0,0 +1,48 @@ +# +# hua.shao@mediatek.com +# +# MTK Property Software. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=uci2dat +PKG_RELEASE:=1 + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) +PKG_CONFIG_DEPENDS:= + +PKG_MAINTAINER:=Hua Shao + +include $(INCLUDE_DIR)/package.mk + +define Package/uci2dat + SECTION:=MTK Properties + CATEGORY:=MTK Properties + DEPENDS:=+libuci + TITLE:=Translate uci config into MTK/Ralink WiFi profile + SUBMENU:=Applications +endef + +define Package/uci2dat/description + Translate uci config into ralink wifi dat format +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) + $(CP) ./src/* $(PKG_BUILD_DIR)/ +endef + +TARGET_CFLAGS += -luci -Wall +TARGET_CFLAGS += -Wno-error=format-security + +define Build/Configure +endef + +define Package/uci2dat/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/uci2dat $(1)/usr/bin +endef + + +$(eval $(call BuildPackage,uci2dat)) diff --git a/package/mtk/applications/uci2dat/src/Makefile b/package/mtk/applications/uci2dat/src/Makefile new file mode 100644 index 000000000..9e732700f --- /dev/null +++ b/package/mtk/applications/uci2dat/src/Makefile @@ -0,0 +1,7 @@ + +uci2dat: + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ uci2dat.c + +clean: + -rm -f *.o *.elf *.gbd + diff --git a/package/mtk/applications/uci2dat/src/uci2dat.c b/package/mtk/applications/uci2dat/src/uci2dat.c new file mode 100644 index 000000000..f7847d50f --- /dev/null +++ b/package/mtk/applications/uci2dat/src/uci2dat.c @@ -0,0 +1,1356 @@ +/***************************************************************************** + * $File: uci2dat.c + * + * $Author: Hua Shao + * $Date: Feb, 2014 + * + * Boring, Boring, Boring, Boring, Boring........ + * + *****************************************************************************/ + + +#include +#include +#include +#include +#include +#include + +#include + + +#ifdef OK +#undef OK +#endif +#define OK (0) + +#ifdef NG +#undef NG +#endif +#define NG (-1) + +#ifdef SHDBG +#undef SHDBG +#endif +#define SHDBG(...) printf(__VA_ARGS__) +#define DEVNUM_MAX (4) +#define MBSSID_MAX (4) + + +#define VFPRINT(fp, e, ...) \ + do {\ + char buffer[128] = {0}; \ + snprintf(buffer, sizeof(buffer), __VA_ARGS__); \ + if (strlen(buffer) > 0) { \ + SHDBG("%s(),%s=", __FUNCTION__, e->dat_key); \ + fprintf(fp, "%s", buffer); \ + SHDBG("%s(),%s=%s, def=\"%s\"\n", __FUNCTION__, \ + e->dat_key, buffer, e->defvalue?e->defvalue:""); \ + } \ + }while(0) + +#define FPRINT(fp, e, v) \ + do {\ + if (v && strlen(v) > 0) { \ + SHDBG("%s(),%s=", __FUNCTION__, e->dat_key); \ + fprintf(fp, "%s", v); \ + SHDBG("%s", v); \ + SHDBG(", def=\"%s\"\n", e->defvalue?e->defvalue:""); \ + } \ + }while(0) + +#define WIFI_UCI_FILE "/etc/config/wireless" + +#define PARSE_UCI_OPTION(dst, src) \ + do { \ + src = NULL; \ + src = uci_lookup_option_string(uci_ctx, s, dst.uci_key); \ + if(src) { \ + dst.value = strdup(src); \ + SHDBG("%s(), %s=%s\n", __FUNCTION__, dst.uci_key, dst.value); \ + } \ + }while(0) + + +struct _param; + +typedef void (*ucihook)(FILE *,struct _param *, const char * devname); + +typedef struct _param +{ + const char * dat_key; + const char * uci_key; + char * value; + ucihook hook; + const char * defvalue; +} param; + + +typedef struct __extra_cfg +{ + param cfg; + struct __extra_cfg * next; +} extra_cfg; + +typedef struct _vif +{ + param ssid; + param authmode; /* wep, wpa, ... */ + param hidden; /* Hidden SSID */ + param cipher; /* ccmp(aes),tkip */ + param key; /* wpa psk */ + + param wepkey[4]; /* wep key, ugly, yep! */ + + param auth_server; + param auth_port; + param auth_secret; + param rekeyinteval; + param preauth; + param pmkcacheperiod; +} vif; + +typedef struct +{ + char devname[16]; + param * params; + int vifnum; + vif vifs[MBSSID_MAX]; +} wifi_params; + +void hooker(FILE * fp, param * p, const char * devname); + +/* these are separated from CFG_ELEMENTS because they + use a different represention structure. +*/ +vif VIF = +{ + .ssid = {NULL, "ssid", NULL, NULL, NULL}, + .authmode = {NULL, "encryption", NULL, NULL, NULL}, + .hidden = {NULL, "hidden", NULL, NULL, NULL}, + .cipher = {NULL, "cipher", NULL, NULL, NULL}, + + /* wpa key, or wep key index */ + .key = {NULL, "key", NULL, NULL, NULL}, + + /* wep key group */ + .wepkey = { + {NULL, "key1", NULL, NULL, NULL}, + {NULL, "key2", NULL, NULL, NULL}, + {NULL, "key3", NULL, NULL, NULL}, + {NULL, "key4", NULL, NULL, NULL} + }, + + /* wpa & 8021x */ + .auth_server = {NULL, "auth_server", "0", NULL, NULL}, + .auth_port = {NULL, "auth_port", "1812", NULL, NULL}, + .auth_secret = {NULL, "auth_secret", NULL, NULL, NULL}, + .pmkcacheperiod = {NULL, "pmkcacheperiod", NULL, NULL, NULL}, + .preauth = {NULL, "preauth", NULL, NULL, NULL}, + .rekeyinteval = {NULL, "rekeyinteval", NULL, NULL, NULL}, +}; + +param CFG_ELEMENTS[] = +{ + /* Default configurations described in : + MTK_Wi-Fi_SoftAP_Software_Programmming_Guide_v3.6.pdf + */ + {"CountryRegion", "region", NULL, hooker, "1"}, + {"CountryRegionABand", "aregion", NULL, hooker, "7"}, + {"CountryCode", "country", NULL, hooker, NULL}, + {"BssidNum", NULL, NULL, hooker, "1"}, + {"SSID1", NULL, NULL, hooker, "OpenWrt"}, + {"SSID2", NULL, NULL, hooker, NULL}, + {"SSID3", NULL, NULL, hooker, NULL}, + {"SSID4", NULL, NULL, hooker, NULL}, + {"WirelessMode", "wifimode", NULL, hooker, "9"}, + {"TxRate", "txrate", NULL, hooker, "0"}, + {"Channel", "channel", NULL, hooker, "0"}, + {"BasicRate", "basicrate", NULL, hooker, "15"}, + {"BeaconPeriod", "beacon", NULL, hooker, "100"}, + {"DtimPeriod", "dtim", NULL, hooker, "1"}, + {"TxPower", "txpower", NULL, hooker, "100"}, + {"DisableOLBC", "disolbc", NULL, hooker, "0"}, + {"BGProtection", "bgprotect", NULL, hooker, "0"}, + {"TxAntenna", "txantenna", NULL, hooker, NULL}, + {"RxAntenna", "rxantenna", NULL, hooker, NULL}, + {"TxPreamble", "txpreamble", NULL, hooker, "0"}, + {"RTSThreshold", "rtsthres", NULL, hooker, "2347"}, + {"FragThreshold", "fragthres", NULL, hooker, "2346"}, + {"TxBurst", "txburst", NULL, hooker, "1"}, + {"PktAggregate", "pktaggre", NULL, hooker, "0"}, + {"TurboRate", "turborate", NULL, hooker, "0"}, + {"WmmCapable", "wmm", NULL, hooker, "1"}, + {"APSDCapable", "apsd", NULL, hooker, "1"}, + {"DLSCapable", "dls", NULL, hooker, "0"}, + {"APAifsn", "apaifsn", NULL, hooker, "3;7;1;1"}, + {"APCwmin", "apcwmin", NULL, hooker, "4;4;3;2"}, + {"APCwmax", "apcwmax", NULL, hooker, "6;10;4;3"}, + {"APTxop", "aptxop", NULL, hooker, "0;0;94;47"}, + {"APACM", "apacm", NULL, hooker, "0;0;0;0"}, + {"BSSAifsn", "bssaifsn", NULL, hooker, "3;7;2;2"}, + {"BSSCwmin", "bsscwmin", NULL, hooker, "4;4;3;2"}, + {"BSSCwmax", "bsscwmax", NULL, hooker, "10;10;4;3"}, + {"BSSTxop", "bsstxop", NULL, hooker, "0;0;94;47"}, + {"BSSACM", "bssacm", NULL, hooker, "0;0;0;0"}, + {"AckPolicy", "ackpolicy", NULL, hooker, "0;0;0;0"}, + {"NoForwarding", "noforward", NULL, hooker, "0"}, + {"NoForwardingBTNBSSID", NULL, NULL, NULL, "0"}, + {"HideSSID", "hidden", NULL, hooker, "0"}, + {"StationKeepAlive", NULL, NULL, NULL, "0"}, + {"ShortSlot", "shortslot", NULL, hooker, "1"}, + {"AutoChannelSelect", "channel", NULL, hooker, "2"}, + {"IEEE8021X", "ieee8021x", NULL, hooker, "0"}, + {"IEEE80211H", "ieee80211h", NULL, hooker, "0"}, + {"CSPeriod", "csperiod", NULL, hooker, "10"}, + {"WirelessEvent", "wirelessevent", NULL, hooker, "0"}, + {"IdsEnable", "idsenable", NULL, hooker, "0"}, + {"AuthFloodThreshold", NULL, NULL, NULL, "32"}, + {"AssocReqFloodThreshold", NULL, NULL, NULL, "32"}, + {"ReassocReqFloodThreshold", NULL, NULL, NULL, "32"}, + {"ProbeReqFloodThreshold", NULL, NULL, NULL, "32"}, + {"DisassocFloodThreshold", NULL, NULL, NULL, "32"}, + {"DeauthFloodThreshold", NULL, NULL, NULL, "32"}, + {"EapReqFooldThreshold", NULL, NULL, NULL, "32"}, + {"PreAuth", "preauth", NULL, hooker, "0"}, + {"AuthMode", NULL, NULL, hooker, "OPEN"}, + {"EncrypType", NULL, NULL, hooker, "NONE"}, + {"RekeyInterval", "rekeyinteval", NULL, hooker, "0"}, + {"PMKCachePeriod", "pmkcacheperiod", NULL, hooker, "10"}, + {"WPAPSK1", NULL, NULL, hooker, NULL}, + {"WPAPSK2", NULL, NULL, hooker, NULL}, + {"WPAPSK3", NULL, NULL, hooker, NULL}, + {"WPAPSK4", NULL, NULL, hooker, NULL}, + {"DefaultKeyID", NULL, NULL, hooker, "1"}, + {"Key1Type", NULL, NULL, hooker, "1"}, + {"Key1Str1", NULL, NULL, hooker, NULL}, + {"Key1Str2", NULL, NULL, hooker, NULL}, + {"Key1Str3", NULL, NULL, hooker, NULL}, + {"Key1Str4", NULL, NULL, hooker, NULL}, + {"Key2Type", NULL, NULL, hooker, "1"}, + {"Key2Str1", NULL, NULL, hooker, NULL}, + {"Key2Str2", NULL, NULL, hooker, NULL}, + {"Key2Str3", NULL, NULL, hooker, NULL}, + {"Key2Str4", NULL, NULL, hooker, NULL}, + {"Key3Type", NULL, NULL, hooker, "1"}, + {"Key3Str1", NULL, NULL, hooker, NULL}, + {"Key3Str2", NULL, NULL, hooker, NULL}, + {"Key3Str3", NULL, NULL, hooker, NULL}, + {"Key3Str4", NULL, NULL, hooker, NULL}, + {"Key4Type", NULL, NULL, hooker, "1"}, + {"Key4Str1", NULL, NULL, hooker, NULL}, + {"Key4Str2", NULL, NULL, hooker, NULL}, + {"Key4Str3", NULL, NULL, hooker, NULL}, + {"Key4Str4", NULL, NULL, hooker, NULL}, + {"AccessPolicy0", NULL, NULL, NULL, "0"}, + {"AccessControlList0", NULL, NULL, NULL, NULL}, + {"AccessPolicy1", NULL, NULL, NULL, "0"}, + {"AccessControlList1", NULL, NULL, NULL, NULL}, + {"AccessPolicy2", NULL, NULL, NULL, "0"}, + {"AccessControlList2", NULL, NULL, NULL, NULL}, + {"AccessPolicy3", NULL, NULL, NULL, "0"}, + {"AccessControlList3", NULL, NULL, NULL, NULL}, + {"WdsEnable", "wds_enable", NULL, hooker, "0"}, + {"WdsEncrypType", "wds_enctype", NULL, hooker, "NONE"}, + {"WdsList", NULL, NULL, NULL, NULL}, + {"Wds0Key", NULL, NULL, NULL, NULL}, + {"Wds1Key", NULL, NULL, NULL, NULL}, + {"Wds2Key", NULL, NULL, NULL, NULL}, + {"Wds3Key", NULL, NULL, NULL, NULL}, + {"RADIUS_Server", "auth_server", NULL, hooker, NULL}, + {"RADIUS_Port", "auth_port", NULL, hooker, NULL}, + {"RADIUS_Key1", "radius_key1", NULL, hooker, NULL}, + {"RADIUS_Key2", "radius_key2", NULL, hooker, NULL}, + {"RADIUS_Key3", "radius_key2", NULL, hooker, NULL}, + {"RADIUS_Key4", "radius_key4", NULL, hooker, NULL}, + {"own_ip_addr", "own_ip_addr", NULL, hooker, "192.168.5.234"}, + {"EAPifname", "eapifname", NULL, hooker, NULL}, + {"PreAuthifname", "preauthifname", NULL, hooker, "br-lan"}, + {"HT_HTC", "ht_htc", NULL, hooker, "0"}, + {"HT_RDG", "ht_rdg", NULL, hooker, "0"}, + {"HT_EXTCHA", "ht_extcha", NULL, hooker, "0"}, + {"HT_LinkAdapt", "ht_linkadapt", NULL, hooker, "0"}, + {"HT_OpMode", "ht_opmode", NULL, hooker, "0"}, + {"HT_MpduDensity", NULL, NULL, hooker, "5"}, + {"HT_BW", "bw", NULL, hooker, "0"}, + {"VHT_BW", "bw", NULL, hooker, "0"}, + {"VHT_Sec80_Channel", "vht2ndchannel", NULL, hooker, NULL}, + {"VHT_SGI", "vht_sgi", NULL, hooker, "1"}, + {"VHT_STBC", "vht_stbc", NULL, hooker, "0"}, + {"VHT_BW_SIGNAL", "vht_bw_sig", NULL, hooker, "0"}, + {"VHT_DisallowNonVHT", "vht_disnonvht", NULL, hooker, NULL}, + {"VHT_LDPC", "vht_ldpc", NULL, hooker, "1"}, + {"HT_AutoBA", "ht_autoba", NULL, hooker, "1"}, + {"HT_AMSDU", "ht_amsdu", NULL, hooker, NULL}, + {"HT_BAWinSize", "ht_bawinsize", NULL, hooker, "64"}, + {"HT_GI", "ht_gi", NULL, hooker, "1"}, + {"HT_MCS", "ht_mcs", NULL, hooker, "33"}, + {"WscManufacturer", "wscmanufacturer", NULL, hooker, NULL}, + {"WscModelName", "wscmodelname", NULL, hooker, NULL}, + {"WscDeviceName", "wscdevicename", NULL, hooker, NULL}, + {"WscModelNumber", "wscmodelnumber", NULL, hooker, NULL}, + {"WscSerialNumber", "wscserialnumber", NULL, hooker, NULL}, + + /* Extra configurations found in 76x2e */ + {"FixedTxMode", "fixedtxmode", NULL, hooker, "0"}, + {"AutoProvisionEn", "autoprovision", NULL, hooker, "0"}, + {"FreqDelta", "freqdelta", NULL, hooker, "0"}, + {"CarrierDetect", "carrierdetect", NULL, hooker, "0"}, + {"ITxBfEn", NULL, NULL, hooker, "0"}, + {"PreAntSwitch", "preantswitch", NULL, hooker, "1"}, + {"PhyRateLimit", "phyratelimit", NULL, hooker, "0"}, + {"DebugFlags", "debugflags", NULL, hooker, "0"}, + {"ETxBfEnCond", NULL, NULL, hooker, "0"}, + {"ITxBfTimeout", NULL, NULL, NULL, "0"}, + {"ETxBfNoncompress", NULL, NULL, NULL, "0"}, + {"ETxBfIncapable", NULL, NULL, hooker, "1"}, + {"FineAGC", "fineagc", NULL, hooker, "0"}, + {"StreamMode", "streammode", NULL, hooker, "0"}, + {"StreamModeMac0", NULL, NULL, NULL, NULL}, + {"StreamModeMac1", NULL, NULL, NULL, NULL}, + {"StreamModeMac2", NULL, NULL, NULL, NULL}, + {"StreamModeMac3", NULL, NULL, NULL, NULL}, + {"RDRegion", NULL, NULL, NULL, NULL}, + {"DfsLowerLimit", "dfs_lowlimit", NULL, hooker, "0"}, + {"DfsUpperLimit", "dfs_uplimit", NULL, hooker, "0"}, + {"DfsOutdoor", "dfs_outdoor", NULL, hooker, "0"}, + {"SymRoundFromCfg", NULL, NULL, NULL, "0"}, + {"BusyIdleFromCfg", NULL, NULL, NULL, "0"}, + {"DfsRssiHighFromCfg", NULL, NULL, NULL, "0"}, + {"DfsRssiLowFromCfg", NULL, NULL, NULL, "0"}, + {"DFSParamFromConfig", NULL, NULL, NULL, "0"}, + {"FCCParamCh0", NULL, NULL, NULL, NULL}, + {"FCCParamCh1", NULL, NULL, NULL, NULL}, + {"FCCParamCh2", NULL, NULL, NULL, NULL}, + {"FCCParamCh3", NULL, NULL, NULL, NULL}, + {"CEParamCh0", NULL, NULL, NULL, NULL}, + {"CEParamCh1", NULL, NULL, NULL, NULL}, + {"CEParamCh2", NULL, NULL, NULL, NULL}, + {"CEParamCh3", NULL, NULL, NULL, NULL}, + {"JAPParamCh0", NULL, NULL, NULL, NULL}, + {"JAPParamCh1", NULL, NULL, NULL, NULL}, + {"JAPParamCh2", NULL, NULL, NULL, NULL}, + {"JAPParamCh3", NULL, NULL, NULL, NULL}, + {"JAPW53ParamCh0", NULL, NULL, NULL, NULL}, + {"JAPW53ParamCh1", NULL, NULL, NULL, NULL}, + {"JAPW53ParamCh2", NULL, NULL, NULL, NULL}, + {"JAPW53ParamCh3", NULL, NULL, NULL, NULL}, + {"FixDfsLimit", "fixdfslimit", NULL, hooker, "0"}, + {"LongPulseRadarTh", "lpsradarth", NULL, hooker, "0"}, + {"AvgRssiReq", "avgrssireq", NULL, hooker, "0"}, + {"DFS_R66", "dfs_r66", NULL, hooker, "0"}, + {"BlockCh", "blockch", NULL, hooker, NULL}, + {"GreenAP", "greenap", NULL, hooker, "0"}, + {"WapiPsk1", NULL, NULL, NULL, NULL}, + {"WapiPsk2", NULL, NULL, NULL, NULL}, + {"WapiPsk3", NULL, NULL, NULL, NULL}, + {"WapiPsk4", NULL, NULL, NULL, NULL}, + {"WapiPsk5", NULL, NULL, NULL, NULL}, + {"WapiPsk6", NULL, NULL, NULL, NULL}, + {"WapiPsk7", NULL, NULL, NULL, NULL}, + {"WapiPsk8", NULL, NULL, NULL, NULL}, + {"WapiPskType", NULL, NULL, NULL, NULL}, + {"Wapiifname", NULL, NULL, NULL, NULL}, + {"WapiAsCertPath", NULL, NULL, NULL, NULL}, + {"WapiUserCertPath", NULL, NULL, NULL, NULL}, + {"WapiAsIpAddr", NULL, NULL, NULL, NULL}, + {"WapiAsPort", NULL, NULL, NULL, NULL}, + {"RekeyMethod", "rekeymethod", NULL, hooker, "TIME"}, + {"MeshAutoLink", "mesh_autolink", NULL, hooker, "0"}, + {"MeshAuthMode", "mesh_authmode", NULL, hooker, NULL}, + {"MeshEncrypType", "mesh_enctype", NULL, hooker, NULL}, + {"MeshDefaultkey", "mesh_defkey", NULL, hooker, "0"}, + {"MeshWEPKEY", "mesh_wepkey", NULL, hooker, NULL}, + {"MeshWPAKEY", "mesh_wpakey", NULL, hooker, NULL}, + {"MeshId", "mesh_id", NULL, hooker, NULL}, + {"HSCounter", "hscount", NULL, hooker, "0"}, + {"HT_BADecline", "ht_badec", NULL, hooker, "0"}, + {"HT_STBC", "ht_stbc", NULL, hooker, "0"}, + {"HT_LDPC", "ht_ldpc", NULL, hooker, "1"}, + {"HT_TxStream", "ht_txstream", NULL, hooker, "1"}, + {"HT_RxStream", "ht_rxstream", NULL, hooker, "1"}, + {"HT_PROTECT", "ht_protect", NULL, hooker, "1"}, + {"HT_DisallowTKIP", "ht_distkip", NULL, hooker, "0"}, + {"HT_BSSCoexistence", "ht_bsscoexist", NULL, hooker, "0"}, + {"WscConfMode", "wsc_confmode", NULL, hooker, "0"}, + {"WscConfStatus", "wsc_confstatus", NULL, hooker, "2"}, + {"WCNTest", "wcntest", NULL, hooker, "0"}, + {"WdsPhyMode", "wds_phymode", NULL, hooker, NULL}, + {"RADIUS_Acct_Server", "radius_acctserver", NULL, hooker, NULL}, + {"RADIUS_Acct_Port", "radius_acctport", NULL, hooker, "1813"}, + {"RADIUS_Acct_Key", "radius_acctkey", NULL, hooker, NULL}, + {"Ethifname", "ethifname", NULL, hooker, NULL}, + {"session_timeout_interval", "session_intv", NULL, hooker, "0"}, + {"idle_timeout_interval", "idle_intv", NULL, hooker, "0"}, + {"WiFiTest", NULL, NULL, NULL, "0"}, + {"TGnWifiTest", "tgnwifitest", NULL, hooker, "0"}, + {"ApCliEnable", NULL, NULL, NULL, "0"}, + {"ApCliSsid", NULL, NULL, NULL, NULL}, + {"ApCliBssid", NULL, NULL, NULL, NULL}, + {"ApCliAuthMode", NULL, NULL, NULL, NULL}, + {"ApCliEncrypType", NULL, NULL, NULL, NULL}, + {"ApCliWPAPSK", NULL, NULL, NULL, NULL}, + {"ApCliDefaultKeyID", NULL, NULL, NULL, "0"}, + {"ApCliKey1Type", NULL, NULL, NULL, "0"}, + {"ApCliKey1Str", NULL, NULL, NULL, NULL}, + {"ApCliKey2Type", NULL, NULL, NULL, "0"}, + {"ApCliKey2Str", NULL, NULL, NULL, NULL}, + {"ApCliKey3Type", NULL, NULL, NULL, "0"}, + {"ApCliKey3Str", NULL, NULL, NULL, NULL}, + {"ApCliKey4Type", NULL, NULL, NULL, "0"}, + {"ApCliKey4Str", NULL, NULL, NULL, NULL}, + {"EfuseBufferMode", "efusebufmode", NULL, hooker, "0"}, + {"E2pAccessMode", "e2paccmode", NULL, hooker, "1"}, + {"RadioOn", "radio", NULL, hooker, "1"}, + {"BW_Enable", "bw_enable", NULL, hooker, "0"}, + {"BW_Root", "bw_root", NULL, hooker, "0"}, + {"BW_Priority", "bw_priority", NULL, hooker, NULL}, + {"BW_Guarantee_Rate", "bw_grtrate", NULL, hooker, NULL}, + {"BW_Maximum_Rate", "bw_maxrate", NULL, hooker, NULL}, + + /* add more configurations */ + {"AutoChannelSkipList", "autoch_skip", NULL, hooker, NULL}, + {"WscConfMethod", "wsc_confmethod", NULL, hooker, NULL}, + {"WscKeyASCII", "wsc_keyascii", NULL, hooker, NULL}, + {"WscSecurityMode", "wsc_security", NULL, hooker, NULL}, + {"Wsc4digitPinCode", "wsc_4digitpin", NULL, hooker, NULL}, + {"WscVendorPinCode", "wsc_vendorpin", NULL, hooker, NULL}, + {"WscV2Support", "wsc_v2", NULL, hooker, NULL}, + {"HT_MIMOPS", "mimops", NULL, hooker, "3"}, + {"G_BAND_256QAM", "g256qam", NULL, hooker, "1"}, + {"DBDC_MODE", "dbdc", NULL, hooker, "0"}, + {"IgmpSnEnable", "igmpsnoop", NULL, hooker, "1"}, + {"MUTxRxEnable", "mutxrxenable", NULL, hooker, "1"}, + {"ITxBfEnCond", "itxbfencond", NULL, hooker, "0"}, + {"BandSteering", "bandsteering", NULL, hooker, "0"}, + + {NULL, "txbf", NULL, hooker, "0"}, // all txbf params use this hook +}; + +extra_cfg * __extra_cfgs__ = NULL; + +static struct uci_context * uci_ctx; +static struct uci_package * uci_wireless; +static wifi_params wifi_cfg[DEVNUM_MAX]; + + +char * __get_value_by_datkey(char * datkey, wifi_params * wifi) +{ + int i; + for(i=0; iparams[i].dat_key && 0 == strcmp(datkey, wifi->params[i].dat_key)) + return wifi->params[i].value; + return NULL; +} + + +char * __get_value_by_ucikey(char * ucikey, wifi_params * wifi) +{ + int i; + for(i=0; iparams[i].uci_key && 0 == strcmp(ucikey, wifi->params[i].uci_key)) + return wifi->params[i].value; + return NULL; +} + + +int strmatch(const char * str, const char * pattern) +{ + int i = strlen(str); + int j = 0; + if (i != strlen(pattern)) + return -1; + + for(j=0; jdat_key, p->uci_key, + p->value?p->value:"(null)", p->hook?"Y":"-", p->defvalue); + } + } + return NULL; +} + + +void parse_dat(char * devname, char * datpath) +{ + FILE * fp = NULL; + char buffer[1024] = {0}; + char k[512] = {0}; + char v[512] = {0}; + int i = 0, n = 0; + char * p = NULL; + char * q = NULL; + wifi_params * cfg = NULL; + + for (i=0; iparams[n].value = strdup(v); + //printf("%s(), <%s>=<%s>", __FUNCTION__,CFG_ELEMENTS[n].dat_key,cfg->params[n].value); + break; + } + } + if (n >= sizeof(CFG_ELEMENTS)/sizeof(CFG_ELEMENTS[0])) + { + fprintf(stderr, "<%s> not supported by uci2dat yet, ignored.\n", k); + extra_cfg * c = (extra_cfg *)malloc(sizeof(extra_cfg)); + memset(c, 0, sizeof(extra_cfg)); + c->cfg.dat_key = strdup(k); + c->cfg.uci_key = strdup(k); + c->cfg.value = strdup(v); + c->cfg.defvalue = NULL; + c->cfg.hook = NULL; + c->next = __extra_cfgs__; + __extra_cfgs__ = c; + } + // else + // printf("<%s>=<%s>\n", k, v); + + } while(1); + +__error: + if(fp) fclose(fp); + + return; +} + + +void parse_uci(char * arg) +{ + struct uci_element *e = NULL; + const char * value = NULL; + int i = 0; + int cur_dev, cur_vif; + + if (!uci_wireless || !uci_ctx) + { + fprintf(stderr, "%s() uci context not ready!\n", __FUNCTION__); + return; + } + + /* scan wireless devices ! */ + uci_foreach_element(&uci_wireless->sections, e) + { + struct uci_section *s = uci_to_section(e); + + if(0 == strcmp(s->type, "wifi-device")) + { + printf("%s(), wifi-device: %s\n", __FUNCTION__, s->e.name); + for(cur_dev=0; cur_deve.name, wifi_cfg[cur_dev].devname)) + break; + } + + if(cur_dev>=DEVNUM_MAX) + { + printf("%s(), device (%s) not found!\n", __FUNCTION__, s->e.name); + break; + } + + for( i = 0; isections, e) + { + struct uci_section *s = uci_to_section(e); + if(0 == strcmp(s->type, "wifi-iface")) + { + value = NULL; + value = uci_lookup_option_string(uci_ctx, s, "device"); + for(cur_dev=0; cur_dev= DEVNUM_MAX) + { + fprintf(stderr, "%s(), device (%s) not found!\n", __FUNCTION__, value); + break; + } + value = NULL; + value = uci_lookup_option_string(uci_ctx, s, "ifname"); + printf("%s(), wifi-iface: %s\n", __FUNCTION__, value); + + cur_vif = wifi_cfg[cur_dev].vifnum; + + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].ssid, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].hidden, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].key, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].wepkey[0], value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].wepkey[1], value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].wepkey[2], value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].wepkey[3], value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].auth_server, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].auth_port, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].auth_secret, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].rekeyinteval, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].preauth, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].pmkcacheperiod, value); + + #define STRNCPPP(dst,src) \ + do {\ + dst.value = strdup(src);\ + printf("%s(), %s=%s\n", __FUNCTION__, dst.uci_key, src); \ + } while(0) + + /* cipher */ + value = uci_lookup_option_string(uci_ctx, s, "encryption"); + if(value) + { + const char * p = NULL; + if (0 == strncmp("8021x", value, strlen("8021x"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "8021x"); + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, "wep"); + } + + if (0 == strncmp("none", value, strlen("none"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "none"); + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, "NONE"); + } + else if (0 == strncmp("wep-open", value, strlen("wep-open"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "wep-open"); + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, "wep"); + } + else if (0 == strncmp("wep-shared", value, strlen("wep-shared"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "wep-shared"); + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, "wep"); + } + else if (0 == strncmp("mixed-psk", value, strlen("mixed-psk"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "psk-mixed"); + p = value+strlen("mixed-psk"); + if (*p == '+' && *(p+1) != 0) + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, p+1); + else + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, "tkip+ccmp"); + } + else if(0 == strncmp("psk", value, strlen("psk"))) + { + if (0 == strncmp("psk-mixed", value, strlen("psk-mixed"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "psk-mixed"); + p = value+strlen("psk-mixed"); + } + else if (0 == strncmp("psk+psk2", value, strlen("psk+psk2"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "psk-mixed"); + p = value+strlen("psk+psk2"); + } + else if (0 == strncmp("psk2", value, strlen("psk2"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "psk2"); + p = value+strlen("psk2"); + } + else if (0 == strncmp("psk", value, strlen("psk"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "psk"); + p = value+strlen("psk"); + } + + if (*p == '+' && *(p+1) != 0) + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, p+1); + else + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, "tkip+ccmp"); + } + else if(0 == strncmp("wpa", value, strlen("wpa"))) + { + if (0 == strncmp("wpa-mixed", value, strlen("wpa-mixed"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "wpa-mixed"); + p = value+strlen("wpa-mixed"); + } + else if (0 == strncmp("wpa+wpa2", value, strlen("wpa+wpa2"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "wpa-mixed"); + p = value+strlen("wpa+wpa2"); + } + else if (0 == strncmp("wpa2", value, strlen("wpa2"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "wpa2"); + p = value+strlen("wpa2"); + } + else if (0 == strncmp("wpa", value, strlen("wpa"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "wpa"); + p = value+strlen("wpa"); + } + + if (*p == '+' && *(p+1) != 0) + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, p+1); + else + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, "tkip+ccmp"); + } + + } + wifi_cfg[cur_dev].vifnum++; + } + } + return; +} + + +void hooker(FILE * fp, param * p, const char * devname) +{ + int N = 0; + int i = 0; + + if (!uci_wireless || !uci_ctx) + { + fprintf(stderr, "%s() uci context not ready!\n", __FUNCTION__); + return; + } + + for(N=0; N= MBSSID_MAX) + { + fprintf(stderr, "%s() device (%s) not found!\n", __FUNCTION__, devname); + return; + } + + if(0 == strmatch(p->dat_key, "SSID?")) + { + i = atoi(p->dat_key+4)-1; + if(i<0 || i >= MBSSID_MAX) + { + fprintf(stderr, "%s() array index error, L%d\n", __FUNCTION__, __LINE__); + return; + } + FPRINT(fp, p, wifi_cfg[N].vifs[i].ssid.value); + } + else if(0 == strcmp(p->dat_key, "BssidNum")) + { + VFPRINT(fp, p, "%d", wifi_cfg[N].vifnum); + } + else if(0 == strcmp(p->dat_key, "EncrypType")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + + if (!wifi_cfg[N].vifs[i].authmode.value) continue; + if (!wifi_cfg[N].vifs[i].cipher.value) continue; + + if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "none")) + FPRINT(fp, p, "NONE"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wep-open") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wep-shared") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "8021x")) + FPRINT(fp, p, "WEP"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].cipher.value, "ccmp")) + FPRINT(fp, p, "AES"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].cipher.value, "tkip")) + FPRINT(fp, p, "TKIP"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].cipher.value, "ccmp+tkip") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].cipher.value, "tkip+ccmp")) + FPRINT(fp, p, "TKIPAES"); + else + FPRINT(fp, p, "NONE"); + } + } + else if(0 == strcmp(p->dat_key, "AuthMode")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + if (!wifi_cfg[N].vifs[i].authmode.value) continue; + + if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "none")) + FPRINT(fp, p, "OPEN"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wep-open")) + FPRINT(fp, p, "OPEN"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "8021x")) + FPRINT(fp, p, "OPEN"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wep-shared")) + FPRINT(fp, p, "SHARED"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wep-auto")) + FPRINT(fp, p, "WEPAUTO"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk")) + FPRINT(fp, p, "WPAPSK"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk2")) + FPRINT(fp, p, "WPA2PSK"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk-mixed") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk+psk2")) + FPRINT(fp, p, "WPAPSKWPA2PSK"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wpa")) + FPRINT(fp, p, "WPA"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wpa2")) + FPRINT(fp, p, "WPA2"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wpa-mixed") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wpa+wpa2")) + FPRINT(fp, p, "WPA1WPA2"); + else + FPRINT(fp, p, "OPEN"); + } + + } + else if(0 == strcmp(p->dat_key, "HideSSID")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + if (!wifi_cfg[N].vifs[i].hidden.value) + FPRINT(fp, p, "0"); + else + FPRINT(fp, p, wifi_cfg[N].vifs[i].hidden.value); + } + } + else if(0 == strcmp(p->dat_key, "Channel")) + { + if(0 == strcmp(p->value, "auto")) + FPRINT(fp, p, "0"); + else + FPRINT(fp, p, p->value); + } + else if(0 == strcmp(p->dat_key, "AutoChannelSelect")) + { + if(0 == strcmp(p->value, "0")) + FPRINT(fp, p, "2"); + else + FPRINT(fp, p, "0"); + } + else if(0 == strcmp(p->dat_key, "HT_BW")) + { + if(0 == strcmp(p->value, "0")) + FPRINT(fp, p, "0"); + else + FPRINT(fp, p, "1"); + } + else if(0 == strcmp(p->dat_key, "VHT_BW")) + { + if(0 == strcmp(p->value, "2")) + FPRINT(fp, p, "1"); + else if (0 == strcmp(p->value, "3")) + FPRINT(fp, p, "2"); + else if (0 == strcmp(p->value, "4")) + FPRINT(fp, p, "3"); + else + FPRINT(fp, p, "0"); + } + else if(0 == strmatch(p->dat_key, "WPAPSK?"))//(0 == strncmp(p->dat_key, "WPAPSK", 6)) + { + i = atoi(p->dat_key+6)-1; + if(i<0 || i >= MBSSID_MAX) + { + fprintf(stderr, "%s() array index error, L%d\n", __FUNCTION__, __LINE__); + return; + } + if (!wifi_cfg[N].vifs[i].authmode.value) return; + if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk2") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk+psk2") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk-mixed")) + FPRINT(fp, p, wifi_cfg[N].vifs[i].key.value); + } + else if(0 == strcmp(p->dat_key, "RADIUS_Server")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + FPRINT(fp, p, wifi_cfg[N].vifs[i].auth_server.value); + } + } + else if(0 == strcmp(p->dat_key, "RADIUS_Port")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + FPRINT(fp, p, wifi_cfg[N].vifs[i].auth_port.value); + } + } + else if(0 == strmatch(p->dat_key, "RADIUS_Key?"))//(0 == strncmp(p->dat_key, "WPAPSK", 6)) + { + i = atoi(p->dat_key+10)-1; + if(i<0 || i >= MBSSID_MAX) + { + fprintf(stderr, "%s() array index error, L%d\n", __FUNCTION__, __LINE__); + return; + } + FPRINT(fp, p, wifi_cfg[N].vifs[i].auth_secret.value); + } + else if(0 == strcmp(p->dat_key, "PreAuth")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + FPRINT(fp, p, wifi_cfg[N].vifs[i].preauth.value); + } + } + else if(0 == strcmp(p->dat_key, "RekeyInterval")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + FPRINT(fp, p, wifi_cfg[N].vifs[i].rekeyinteval.value); + } + } + else if(0 == strcmp(p->dat_key, "PMKCachePeriod")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + FPRINT(fp, p, wifi_cfg[N].vifs[i].pmkcacheperiod.value); + } + } + + else if(0 == strcmp(p->dat_key, "IEEE8021X")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + if (!wifi_cfg[N].vifs[i].authmode.value) continue; + if(0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "8021x")) + FPRINT(fp, p, "1"); + } + } + else if(0 == strmatch(p->dat_key, "DefaultKeyID")) /* WEP */ + { + for(i=0; idat_key, "Key?Type")) /* WEP */ + { + int j; + i = atoi(p->dat_key+3)-1; + for(j=0; jdat_key, "Key?Str?")) /* WEP */ + { + int j; + i = atoi(p->dat_key+3)-1; + j = atoi(p->dat_key+7)-1; + if (!wifi_cfg[N].vifs[j].wepkey[i].value) return; + if(0 == strncmp("s:", wifi_cfg[N].vifs[j].wepkey[i].value, 2)) + FPRINT(fp, p, wifi_cfg[N].vifs[j].wepkey[i].value+2); + else + FPRINT(fp, p, wifi_cfg[N].vifs[j].wepkey[i].value); + } + else if (0 == strcmp(p->dat_key, "ETxBfIncapable")) + { + char * value = __get_value_by_ucikey("txbf", &wifi_cfg[N]); + if (!value) + FPRINT(fp, p, "0"); + else if (0 == strcmp(value, "3")) + FPRINT(fp, p, "0"); + else if (0 == strcmp(value, "2")) + FPRINT(fp, p, "0"); + else if (0 == strcmp(value, "1")) + FPRINT(fp, p, "1"); + else if (0 == strcmp(value, "0")) + FPRINT(fp, p, "1"); + else + FPRINT(fp, p, "0"); + } + else if (0 == strcmp(p->dat_key, "ITxBfEn")) + { + char * value = __get_value_by_ucikey("txbf", &wifi_cfg[N]); + if (!value) + FPRINT(fp, p, "1"); + else if (0 == strcmp(value, "3")) + FPRINT(fp, p, "1"); + else if (0 == strcmp(value, "2")) + FPRINT(fp, p, "0"); + else if (0 == strcmp(value, "1")) + FPRINT(fp, p, "1"); + else if (0 == strcmp(value, "0")) + FPRINT(fp, p, "0"); + else + FPRINT(fp, p, "1"); + } + else if (0 == strcmp(p->dat_key, "ETxBfEnCond")) + { + char * value = __get_value_by_ucikey("txbf", &wifi_cfg[N]); + if (!value) + FPRINT(fp, p, "1"); + else if (0 == strcmp(value, "3")) + FPRINT(fp, p, "1"); + else if (0 == strcmp(value, "2")) + FPRINT(fp, p, "1"); + else if (0 == strcmp(value, "1")) + FPRINT(fp, p, "0"); + else if (0 == strcmp(value, "0")) + FPRINT(fp, p, "0"); + else + FPRINT(fp, p, "1"); + } + /* the rest part is quite simple! */ + else + { + FPRINT(fp, p, p->value); + } + +} + + +void gen_dat(char * devname, char * datpath) +{ + FILE * fp = NULL; + char buffer[1024] = {0}; + int i = 0; + param * p = NULL; + wifi_params * cfg = NULL; + extra_cfg * e = __extra_cfgs__; + + for (i=0; idevname); + system(buffer); + + snprintf(buffer, sizeof(buffer), "/etc/wireless/%s/%s.dat", cfg->devname, cfg->devname); + fp = fopen(buffer, "wb"); + } + + if(!fp) + { + fprintf(stderr, "Failed to open %s, %s!\n", buffer, strerror(errno)); + return; + } + + fprintf(fp, "# Generated by uci2dat\n"); + fprintf(fp, "# The word of \"Default\" must not be removed\n"); + fprintf(fp, "Default\n"); + + + for(i=0; iparams[i]; + if (!p->dat_key) continue; + printf("%s(), %s\n", __FUNCTION__, p->dat_key); + /* either get value from dat or uci */ + if(p->value) + { + fprintf(fp, "%s=", p->dat_key); + if(p->hook) + p->hook(fp, p, cfg->devname); + else if(strlen(p->value) > 0) + fprintf(fp, p->value); + /* + else if(p->defvalue) + fprintf(fp, p->defvalue); + */ + fprintf(fp, "\n"); + } + } + + while (e) + { + fprintf(fp, "%s=", e->cfg.dat_key); + if(strlen(e->cfg.value) > 0) + fprintf(fp, e->cfg.value); + else if(e->cfg.defvalue) + fprintf(fp, e->cfg.defvalue); + fprintf(fp, "\n"); + e = e->next; + } + + fclose(fp); + + return; +} + +void init_wifi_cfg(void) +{ + struct uci_element *e = NULL; + int i,j; + + for(i=0; isections, e) + { + struct uci_section *s = uci_to_section(e); + if(0 == strcmp(s->type, "wifi-device")) + { + for(i=0; ie.name, sizeof(wifi_cfg[i].devname)); + break; + } + } + + if(i>=DEVNUM_MAX) + { + fprintf(stderr, "%s(), too many devices!\n", __FUNCTION__); + break; + } + } + } +} + +void usage(void) +{ + int i, j; + param * p = NULL; + + printf("uci2dat -- a tool to translate uci config (/etc/config/wireless)\n"); + printf(" into ralink driver dat.\n"); + printf("\nUsage:\n"); + printf(" uci2dat -d -f \n"); + + printf("\nArguments:\n"); + printf(" -d device name, mt7620, eg.\n"); + printf(" -f dat file path.\n"); + + printf("\nSupported keywords:\n"); + printf(" %-16s\t%-16s\t%s\n", "[uci-key]", "[dat-key]", "[default]"); + for(i=0, j=0; iuci_key) + { + printf("%3d. %-16s\t%-16s\t%s\n",j, p->uci_key, p->dat_key, p->defvalue); + j++; + } + } + + printf("%2d. %s\n", j++, VIF.ssid.uci_key); + printf("%2d. %s\n", j++, VIF.authmode.uci_key); + printf("%2d. %s\n", j++, VIF.hidden.uci_key); + printf("%2d. %s\n", j++, VIF.cipher.uci_key); + printf("%2d. %s\n", j++, VIF.key.uci_key); + +} + + +int main(int argc, char ** argv) +{ + int opt = 0; + char * dev = NULL; + char * dat = NULL; + int test = 0; + + while ((opt = getopt (argc, argv, "htf:d:")) != -1) + { + switch (opt) + { + case 'f': + dat = optarg; + break; + case 'd': + dev = optarg; + break; + case 't': + test = 1; + break; + case 'h': + usage(); + return OK; + default: + usage(); + return NG; + } + } + + if (!uci_ctx) + { + uci_ctx = uci_alloc_context(); + } + else + { + uci_wireless = uci_lookup_package(uci_ctx, "wireless"); + if (uci_wireless) + uci_unload(uci_ctx, uci_wireless); + } + + if (uci_load(uci_ctx, "wireless", &uci_wireless)) + { + return NG; + } + + init_wifi_cfg(); + + if(dev && dat) + { + parse_dat(dev, dat); + parse_uci(NULL); + } + + if(test) + { + FILE * fp = NULL; + char * p = NULL; + char device[32] = {0}; + char profile[128] = {0}; + fp = popen("cat /etc/config/wireless" + " | grep \"wifi-device\"" + " | sed -n \"s/config[ \t]*wifi-device[\t]*//gp\"", + "r"); + if(!fp) + { + fprintf(stderr, "%s(), error L%d\n", __FUNCTION__, __LINE__); + return NG; + } + while(fgets(device, sizeof(device), fp)) + { + if (strlen(device) > 0) + { + p = device+strlen(device)-1; + while(*p < ' ') + { + *p=0; // trim newline + p++; + } + snprintf(profile, sizeof(profile), "/etc/wireless/%s/%s.dat", device, device); + parse_dat(device, profile); + } + else + printf("%s(), error L%d\n", __FUNCTION__, __LINE__); + } + pclose(fp); + parse_uci(NULL); + __dump_all(); + + } + else if(dev && dat) + gen_dat(dev, dat); + else + usage(); + + uci_unload(uci_ctx, uci_wireless); + return OK; +} + + + + diff --git a/package/mtk/applications/wificonf/Makefile b/package/mtk/applications/wificonf/Makefile new file mode 100644 index 000000000..3d3741ee8 --- /dev/null +++ b/package/mtk/applications/wificonf/Makefile @@ -0,0 +1,56 @@ +# +# Hua Shao +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=wificonf +PKG_RELEASE:=1 + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) +PKG_CONFIG_DEPENDS:= + +PKG_MAINTAINER:=Hua Shao + +include $(INCLUDE_DIR)/package.mk + +define Package/wificonf + SECTION:=MTK Properties + CATEGORY:=MTK Properties + TITLE:=Read/Write MTK WiFi profiles + DEPENDS:= + SUBMENU:=Applications + MENU:=1 +endef + +define Package/wificonf/description + Read/Write MTK WiFi profiles +endef + +define Package/wificonf/config + if PACKAGE_wificonf + config SUPPORT_LSDK_NVRAM_CMD + bool "Provide compatible usage for LSDK nvram command" + default n + endif +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) + make -C src clean + $(CP) ./src/* $(PKG_BUILD_DIR)/ +endef + +TARGET_CFLAGS += -Wall +TARGET_CFLAGS += -Wno-error=format-security + +define Package/wificonf/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/wificonf $(1)/usr/bin + if [ "$$(CONFIG_SUPPORT_LSDK_NVRAM_CMD)" != "" ]; then \ + $(INSTALL_BIN) ./files/usr/bin/nvram_get $(1)/usr/bin/nvram_get; \ + $(LN) /usr/bin/nvram_get $(1)/usr/bin/nvram_set; \ + fi +endef + +$(eval $(call BuildPackage,wificonf)) diff --git a/package/mtk/applications/wificonf/files/usr/bin/nvram_get b/package/mtk/applications/wificonf/files/usr/bin/nvram_get new file mode 100644 index 000000000..40456d907 --- /dev/null +++ b/package/mtk/applications/wificonf/files/usr/bin/nvram_get @@ -0,0 +1,93 @@ +#!/bin/sh + +# usage: +# nvram_get [dev] +# nvram_set [dev] + + +usage() +{ + echo "Usage:" + echo " nvram_get [dev] " + echo " nvram_set [dev] " + echo "" + echo "This a wrapper script which provides compatible tools as LSDK \"nvram_set\" and \"nvram_get\"." + echo "It uses \"wificonf\" as a underlying tool, check \"wificonf -h\" for more usage." +} + +if [ "$0" == "nvram_set" -o "$0" == "/usr/bin/nvram_set" ]; then + CMD=set + if [ 2 == $# ]; then + KEY=$1 + VAL=$2 + elif [ 3 == $# ]; then + DEV=$1 + KEY=$2 + VAL=$3 + else + usage + exit 1 + fi +else + CMD=get + if [ 1 == $# ]; then + KEY=$1 + elif [ 2 == $# ]; then + DEV=$1 + KEY=$2 + else + usage + exit 1 + fi +fi + +# first, check if there're soft-links for wifi profiles +if [ "$DEV" != "" ]; then + PROFILE=`readlink /tmp/mtk/wifi/$1` +fi + +# else, try default mapping with l1profile: +# 2880 -> 1st card +# rtdev -> 2nd card +# wifi3 -> 3rd card + +if [ "$PROFILE" == "" ]; then + if [ -f /etc/wireless/l1profile.dat ]; then + # first line "Default" is illegal in shell + cat /etc/wireless/l1profile.dat | tail -n +2 > /tmp/l1profile.sh; + . /tmp/l1profile.sh; + case "$DEV" in + 2880) + PROFILE=$INDEX0_profile_path + ;; + rtdev) + PROFILE=$INDEX1_profile_path + ;; + wifi3) + PROFILE=$INDEX2_profile_path + ;; + *) + PROFILE=$INDEX0_profile_path + ;; + esac + fi +fi + +# Fatal error: still cannot find correct $PROFILE ! +if [ "$PROFILE" == "" ]; then + echo "Error: nvram_$CMD is not configured properly!" >&2 + echo "Either you don't have a valid \"/etc/wireless/l1profile.dat\" , or you forgot to do something like:" >&2 + echo " mkdir -p /tmp/mtk/wifi" >&2 + echo " ln -s /etc/wireless/mt76xx/mt76xx.dat /tmp/mtk/wifi/xxxx" >&2 + exit 1 +fi + +############ Final Wrapper ############ + +if [ -f /usr/bin/wificonf ]; then + /usr/bin/wificonf -f $PROFILE $CMD $KEY $VAL +else + echo "Error: unabled to locate wificonf!" >&2 + exit 1 +fi + diff --git a/package/mtk/applications/wificonf/src/Makefile b/package/mtk/applications/wificonf/src/Makefile new file mode 100644 index 000000000..033fe332c --- /dev/null +++ b/package/mtk/applications/wificonf/src/Makefile @@ -0,0 +1,7 @@ + +wificonf: wificonf.c + $(CC) -Wall -Werror $(CFLAGS) $(LDFLAGS) -o $@ wificonf.c + +clean: + -rm -f *.o *.elf *.gbd wificonf + diff --git a/package/mtk/applications/wificonf/src/wificonf.c b/package/mtk/applications/wificonf/src/wificonf.c new file mode 100644 index 000000000..13996b884 --- /dev/null +++ b/package/mtk/applications/wificonf/src/wificonf.c @@ -0,0 +1,679 @@ +/**************************************************************************** + * + * Copyright (c) Hua Shao + * + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#undef OK +#undef NG +#undef SHDBG +#undef IS_SPACE +#undef IS_NEWLINE +#undef ASSERT + +#define OK (0) + +#define NG (-1) + +#define SHDBG(...) if(!__quiet) fprintf(stderr, __VA_ARGS__) + +#define IS_SPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n') + +#define IS_NEWLINE(c) ((c) == '\r' || (c) == '\n') + +#define ASSERT(_cond_) \ + do { \ + if (!(_cond_)) {\ + SHDBG("assert failure: %s, %s, %s L%d.\n", #_cond_, errno != 0?strerror(errno):"", __FUNCTION__, __LINE__); \ + exit(-1); \ + } \ + } while(0); + +int __quiet = 0; +int __base64 = 0; +char * __profile = NULL; +char * EMPTY = ""; + + +int base64 = 0; +static const unsigned char base64_table[65] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +unsigned char * base64_encode(const unsigned char *src, size_t len, + size_t *out_len) +{ + unsigned char *out, *pos; + const unsigned char *end, *in; + size_t olen; + int line_len; + + olen = len * 4 / 3 + 4; /* 3-byte blocks to 4-byte */ + olen += olen / 72; /* line feeds */ + olen++; /* nul termination */ + if (olen < len) + return NULL; /* integer overflow */ + out = malloc(olen+1); /* null terminated */ + if (out == NULL) + return NULL; + out[olen] = 0; + + end = src + len; + in = src; + pos = out; + line_len = 0; + while (end - in >= 3) + { + *pos++ = base64_table[in[0] >> 2]; + *pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)]; + *pos++ = base64_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)]; + *pos++ = base64_table[in[2] & 0x3f]; + in += 3; + line_len += 4; + if (line_len >= 72) + { + *pos++ = '\n'; + line_len = 0; + } + } + + if (end - in) + { + *pos++ = base64_table[in[0] >> 2]; + if (end - in == 1) + { + *pos++ = base64_table[(in[0] & 0x03) << 4]; + *pos++ = '='; + } + else + { + *pos++ = base64_table[((in[0] & 0x03) << 4) | + (in[1] >> 4)]; + *pos++ = base64_table[(in[1] & 0x0f) << 2]; + } + *pos++ = '='; + line_len += 4; + } + + if (line_len) + *pos++ = '\n'; + + *pos = '\0'; + if (out_len) + *out_len = pos - out; + return out; +} + + +unsigned char * base64_decode(const unsigned char *src, size_t len, + size_t *out_len) +{ + unsigned char dtable[256], *out, *pos, block[4], tmp; + size_t i, count, olen; + int pad = 0; + + memset(dtable, 0x80, 256); + for (i = 0; i < sizeof(base64_table) - 1; i++) + dtable[base64_table[i]] = (unsigned char) i; + dtable['='] = 0; + + count = 0; + for (i = 0; i < len; i++) + { + if (dtable[src[i]] != 0x80) + count++; + } + + if (count == 0 || count % 4) + return NULL; + + olen = count / 4 * 3; + pos = out = malloc(olen+1); + if (out == NULL) + return NULL; + pos[olen] = 0; + + count = 0; + for (i = 0; i < len; i++) + { + tmp = dtable[src[i]]; + if (tmp == 0x80) + continue; + + if (src[i] == '=') + pad++; + block[count] = tmp; + count++; + if (count == 4) + { + *pos++ = (block[0] << 2) | (block[1] >> 4); + *pos++ = (block[1] << 4) | (block[2] >> 2); + *pos++ = (block[2] << 6) | block[3]; + count = 0; + if (pad) + { + if (pad == 1) + pos--; + else if (pad == 2) + pos -= 2; + else + { + /* Invalid padding */ + free(out); + return NULL; + } + break; + } + } + } + + if (out_len) + *out_len = pos - out; + return out; +} + + +char * __get_token(char * str, int idx) +{ + int i = 0; + char * p = NULL; + char * q = NULL; + char * tmp = strdup(str); + char * new = EMPTY; + + do + { + p = strchr(tmp, '='); + if (!p) break; + p++; + i = 0; + while(i\" first\n"); + exit(-1); + } + + profile = (char *)malloc(sb.st_size + 1); + ASSERT(profile); + + ret = readlink(link, profile, sb.st_size+1); + if (ret < 0) + { + SHDBG("use \"wificonf use \" first\n"); + return NULL; + } + ASSERT(ret <= sb.st_size+1); + profile[sb.st_size] = 0; + + + return profile; +} + + +int conf_get(char * key) +{ + int offset = 0; + FILE * fp = NULL; + char buffer[1024] = {0}; + char * p = NULL; + char * q = NULL; + char * profile = NULL; + + profile = __get_profile(NULL); + ASSERT(profile); + + fp = fopen(profile, "rb"); + ASSERT(fp); + + offset = __locate_key(fp, key); + ASSERT(offset >= 0); + + memset(buffer, 0, sizeof(buffer)); + fseek(fp, offset, SEEK_SET); + p = fgets(buffer, sizeof(buffer)-1, fp); + if(!p) return OK; + p = strstr(buffer, "="); + if(!p) return OK; + p++; + + while(IS_SPACE(*p)) p++; /* trim head spaces */ + q = p; + while(*q != 0) q++; + q--;/* q points to the last character */ + while(q > p && IS_SPACE(*q)) + { + *q = 0; + q--; + }; /* trim tail spaces */ + printf("%s\n", p); + + if(fp) fclose(fp); + return OK; +} + + +int conf_set(char * key, char * value) +{ + int ret = 0; + FILE * fp = NULL; + char * buffer = NULL; + int nbytes = 0; + char * profile = NULL; + char * p = NULL; + struct stat sb; + size_t len = strlen(value); + + if (__base64) + { + value = (char *)base64_decode((unsigned char *)value, strlen(value), &len); + ASSERT(value); + } + + profile = __get_profile(NULL); + ASSERT(profile); + + fp = fopen(profile, "rb"); + ASSERT(fp); + + nbytes = __locate_key(fp, key); + ASSERT(nbytes >= 0); + + ASSERT(stat(profile, &sb) == 0); + buffer = (char *)malloc(sb.st_size + 1); + ASSERT(buffer); + buffer[sb.st_size] = 0; + + fseek(fp, 0, SEEK_SET); + ret = fread(buffer, 1, sb.st_size, fp); + ASSERT(ret == sb.st_size); + fclose(fp); + + fp = fopen(profile, "wb"); + ASSERT(fp); + ret = fwrite(buffer, 1, nbytes, fp); + ASSERT(ret == nbytes); + + fprintf(fp, "%s=", key); + for (ret=0; ret= 0); + + profile = __get_profile(NULL); + ASSERT(profile); + + fp = fopen(profile, "rb"); + ASSERT(fp); + + offset = __locate_key(fp, key); + ASSERT(offset>=0); + + fseek(fp, offset, SEEK_SET); + memset(buffer, 0, sizeof(buffer)); + p = fgets(buffer, sizeof(buffer)-1, fp); + if(!p) return OK; + + printf("%s\n", __get_token(buffer, idx)); + + if(fp) fclose(fp); + return OK; +} + + +int conf_set_token(char * key, int idx, char * value) +{ + int ret = 0; + int nbytes = 0; + FILE * fp = NULL; + char * buffer = NULL; + char * p = NULL; + char * q = NULL; + char * profile = NULL; + struct stat sb; + size_t len = strlen(value); + + ASSERT(key); + ASSERT(idx >= 0 && idx < 32); + + if (__base64) + { + value = (char *)base64_decode((unsigned char *)value, strlen(value), &len); + ASSERT(value); + } + + profile = __get_profile(NULL); + ASSERT(profile); + + ASSERT(stat(profile, &sb) == 0); + buffer = (char *)malloc(sb.st_size + 1); + ASSERT(buffer); + buffer[sb.st_size] = 0; + + fp = fopen(profile, "rb"); + ASSERT(fp); + + ret = fread(buffer, 1, sb.st_size, fp); + ASSERT(ret == sb.st_size); + + nbytes = __locate_key(fp, key); + ASSERT(nbytes>=0); + + fclose(fp); + + /* write the first part. */ + fp = fopen(profile, "wb"); + ASSERT(fp); + ret = fwrite(buffer, 1, nbytes, fp); + ASSERT(ret == nbytes); + + /* write new key-value. */ + p = buffer+nbytes; + q = p; + while(*q != '\n' && q != 0) q++; + *q = 0; + q++; + p = __set_token(p, idx, value); + fprintf(fp, "%s\n", p); + + /* write rest data */ + nbytes = buffer + sb.st_size - q; /* remain data */ + ret = fwrite(q, 1, nbytes, fp); + ASSERT(ret == nbytes); + + if(fp) fclose(fp); + return OK; +} + + + +int usage(void) +{ + printf("Usage:\n" + " wificonf [option] use \n" + " wificonf [option] get \n" + " wificonf [option] get [idx]\n" + " wificonf [option] set \n" + " wificonf [option] set \n" + "\n" + "Options:\n" + " -e use base64 encoded .\n" + " -f specify the profile.\n" + " -q be quiet, no error will be reported.\n" + "\n\n" + "Examples:\n" + " 1. set the default profile you want to access\n" + " wificonf use /etc/wireless/mt7603.dat\n" + " wificonf get SSID1\n" + " 2. change the default profile you want to access\n" + " wificonf use /etc/wireless/mt7615.dat\n" + " wificonf set SSID1 MasterNet\n" + " wificonf set SSID2 GuestNet\n" + " wificonf set BssidNum 2\n" + " 3. also you can specify the profile with each command\n" + " wificonf -f /etc/wireless/mt7603.dat set SSID1 WiFi-7603\n" + " 4. access a key that has a list of values\n" + " wificonf set TestKey \"1;2;3;4\"\n" + " wificonf get TestKey --> 1;2;3;4\n" + " wificonf set TestKey 0 99\n" + " wificonf get TestKey --> 99;2;3;4\n" + ); + + return OK; +} + + + +int use_profile(char * profile, char * alias) +{ + char softlink[512]; + int ret; + + struct stat st; + + if (stat("/tmp/.wificonf", &st) < 0) + { + ret = mkdir("/tmp/.wificonf", 0700); + ASSERT(ret == 0); + } + + snprintf(softlink, sizeof(softlink), "/tmp/.wificonf/current"); + if (lstat(softlink, &st) == 0) + { + ret = unlink(softlink); + ASSERT(ret == 0); + } + + ret = symlink(profile, softlink); + ASSERT(ret == 0); + + if (!alias) return OK; + + snprintf(softlink, sizeof(softlink), "/tmp/.wificonf/%s", alias); + + if (lstat(softlink, &st) == 0) + { + SHDBG("you are overwritting %s to %s\n", softlink, profile); + ret = unlink(softlink); + ASSERT(ret == 0); + } + ret = symlink(profile, softlink); + ASSERT(ret == 0); + + return OK; +} + + +int main(int argn, char ** args) +{ + int argc = 1; + int c; + int i; + char * argv[8]; + + argv[0] = strdup(args[0]); + + while ((c = getopt (argn, args, "ef:qh")) != -1) + { + switch (c) + { + case 'f': + __profile = optarg; + break; + case 'q': + __quiet = 1; + break; + case 'e': + __base64 = 1; + break; + case 'h': + default: + return usage(); + } + } + + for (i = optind; i < argn; i++) + argv[argc++] = args[i]; + + if (argc < 2) + return usage(); + + if (0 == strcmp(argv[1], "use")) + { + if (argc == 3) + return use_profile(argv[2], NULL); + else if (argc == 4) + return use_profile(argv[2], argv[3]); + else + return usage(); + } + + if (0 == strcmp(argv[1], "get")) + { + /* case 1: wificonf get */ + /* case 2: wificonf get */ + if (argc == 3) + return conf_get(argv[2]); + else if (argc == 4) + return conf_get_token(argv[2], atoi(argv[3])); + else + return usage(); + } + + if (0 == strcmp(argv[1], "set")) + { + /* case 1: wificonf set */ + /* case 2: wificonf set */ + if (argc == 4) + return conf_set(argv[2], argv[3]); + else if (argc == 5) + return conf_set_token(argv[2], atoi(argv[3]), argv[4]); + else + return usage(); + } + + return OK; +} + + + + diff --git a/package/mtk/drivers/mt_wifi/Makefile b/package/mtk/drivers/mt_wifi/Makefile new file mode 100644 index 000000000..b203c2cef --- /dev/null +++ b/package/mtk/drivers/mt_wifi/Makefile @@ -0,0 +1,231 @@ +# All rights reserved. +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=mt_wifi +P4REV:= +PKG_VERSION:=5.0.2.0 +PKG_SOURCE:=MT7621_7615.tar.xz +#PKG_SOURCE:=MT7615_MT7622_LinuxAP.tar.bz2 +#PKG_SOURCE:=MT7615_MT7622_LinuxAP_$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:= +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME) +PKG_KCONFIG:= \ + AP_SUPPORT \ + RT_FIRST_CARD \ + RT_SECOND_CARD \ + RT_FIRST_IF_RF_OFFSET \ + RT_SECOND_IF_RF_OFFSET \ + MT_WIFI \ + WIFI_BASIC_FUNC \ + MT_WIFI_PATH \ + FIRST_IF_NONE \ + FIRST_IF_EEPROM_FLASH \ + FIRST_IF_EEPROM_EFUSE \ + RT_FIRST_CARD_EEPROM \ + SECOND_IF_NONE \ + SECOND_IF_EEPROM_FLASH \ + SECOND_IF_EEPROM_PROM \ + SECOND_IF_EEPROM_EFUSE \ + RT_SECOND_CARD_EEPROM \ + MULTI_INF_SUPPORT \ + WIFI_BASIC_FUNC \ + WIRELESS_EXT \ + WEXT_SPY \ + WEXT_PRIV \ + DOT11_N_SUPPORT \ + DOT11_VHT_AC \ + WIFI_DRIVER \ + G_BAND_256QAM_SUPPORT \ + BRCM_256QAM_SUPPORT \ + ICAP_SUPPORT \ + MT_AP_SUPPORT \ + BACKGROUND_SCAN_SUPPORT \ + SMART_CARRIER_SENSE_SUPPORT \ + MT_DFS_SUPPORT \ + HDR_TRANS_TX_SUPPORT \ + CHIP_MT7615E \ + HDR_TRANS_RX_SUPPORT \ + DBDC_MODE \ + MULTI_PROFILE_SUPPORT \ + DEFAULT_5G_PROFILE \ + SUPPORT_DYNAMIC_TXOP \ + WSC_INCLUDED \ + MT_STA_SUPPORT \ + WSC_V2_SUPPORT \ + DOT11W_PMF_SUPPORT \ + PASSPOINT_R2 \ + TXBF_SUPPORT \ + IGMP_SNOOP_SUPPORT \ + RATE_ADAPTION \ + RATE_ADAPT_AGBS_SUPPORT \ + RTMP_FLASH_SUPPORT \ + ATE_SUPPORT \ + UAPSD \ + RLT_MAC \ + RLT_BBP \ + RLT_RF \ + RTMP_MAC \ + RTMP_BBP \ + RTMP_RF \ + RTMP_PCI_SUPPORT \ + RTMP_USB_SUPPORT \ + RTMP_RBUS_SUPPORT \ + WIFI_MODE_AP \ + WIFI_MODE_STA \ + WIRELESS_EXT \ + WEXT_SPY \ + WEXT_PRIV \ + WDS_SUPPORT \ + MBSS_SUPPORT \ + APCLI_SUPPORT \ + APCLI_CERT_SUPPORT \ + MAC_REPEATER_SUPPORT \ + RALINK_RT6352 \ + RALINK_MT7620 \ + RALINK_MT7603E \ + CON_WPS_SUPPORT \ + VOW_SUPPORT \ + BAND_STEERING \ + TXOP_ARBITER \ + CFG_SUPPORT_DYNAMIC_TXOP \ + WIFI_MODE_BOTH \ + WIFI_RLT_MAC \ + RLT_MAC \ + WIFI_RTMP_MAC \ + RTMP_MAC \ + WIFI_MT_MAC \ + CHIP_MT7603E \ + CHIP_MT7615E \ + MT_MAC \ + RATE_ADAPTION \ + SUPPORT_OPENWRT \ + SDK_USER_LIGHTY \ + MUMIMO_SUPPORT \ + MU_RA_SUPPORT \ + LED_CONTROL_SUPPORT \ + RA_HW_NAT \ + RA_HW_NAT_WIFI_NEW_ARCH \ + CFG80211_SUPPORT \ + SER_SUPPORT \ + GREENAP_SUPPORT \ + RADIUS_ACCOUNTING_SUPPORT \ + TPC_SUPPORT \ + RLM_CAL_CACHE_SUPPORT \ + RF_LOCKDOWN_SUPPORT \ + PASSPOINT_R2 \ + RED_SUPPORT \ + FIRST_IF_EPAELNA \ + FIRST_IF_IPAILNA \ + FIRST_IF_IPAELNA \ + FIRST_IF_EPAILNA \ + SECOND_IF_EPAELNA \ + SECOND_IF_IPAILNA \ + SECOND_IF_IPAELNA \ + SECOND_IF_EPAILNA \ + THIRD_IF_EPAELNA \ + THIRD_IF_IPAILNA \ + THIRD_IF_IPAELNA \ + THIRD_IF_EPAILNA \ + WIFI_PKT_FWD \ + DOT11K_RRM_SUPPORT \ + DOT11R_FT_SUPPORT \ + MBO_SUPPORT \ + WIFI_PKT_FWD_V1 \ + FIRST_IF_MT7615E \ + FIRST_IF_MT7622 \ + FIRST_IF_MT7626 \ + SECOND_IF_MT7615E \ + THIRD_IF_NONE \ + THIRD_IF_MT7615E \ + RT_THIRD_CARD \ + RT_THIRD_IF_RF_OFFSET \ + THIRD_IF_EEPROM_FLASH \ + THIRD_IF_EEPROM_PROM \ + THIRD_IF_EEPROM_EFUSE \ + RT_THIRD_CARD_EEPROM \ + SPECTRUM_SUPPORT \ + MULTI_PROFILE_SUPPORT \ + PRE_CAL_TRX_SET1_SUPPORT \ + MWDS \ + MCAST_RATE_SPECIFIC \ + WLAN_HOOK \ + COEX_SUPPORT \ + EASY_SETUP_SUPPORT \ + EVENT_NOTIFIER_SUPPORT \ + AIR_MONITOR \ + WNM_SUPPORT \ + INTERWORKING \ + LINUX_NET_TXQ_SUPPORT \ + CHIP_MT7622 \ + CHIP_MT7626 \ + WHNAT_SUPPORT \ + FAST_NAT_SUPPORT \ + PRE_CAL_TRX_SET2_SUPPORT \ + LINK_TEST_SUPPORT \ + TCP_RACK_SUPPORT \ + FQ_SCH_SUPPORT \ + BRCM_256QAM_SUPPORT \ + VHT_TXBF_2G_EPIGRAM_IE_SUPPORT \ + DSCP_PRI_SUPPORT \ + PCIE_ASPM_DYM_CTRL_SUPPORT \ + +PKG_CONFIG_DEPENDS:=$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_MTK_$c),CONFIG_$(c))) + +include $(INCLUDE_DIR)/package.mk + +TAR_CMD=$(HOST_TAR) -C $(1)/ $(TAR_OPTIONS) + +define KernelPackage/mt_wifi + CATEGORY:=MTK Properties + TITLE:=MTK wifi AP driver + DEPENDS:=+wifi-l1profile +ifneq ($(CONFIG_MTK_WHNAT_SUPPORT), ) + FILES:=$(PKG_BUILD_DIR)/mt_wifi_ap/mt_wifi.ko \ + $(PKG_BUILD_DIR)/mt_wifi/embedded/tools/plug_in/whnat/mt_whnat.ko + AUTOLOAD:=$(call AutoProbe,mt_wifi mt_whnat) +else + FILES:=$(PKG_BUILD_DIR)/mt_wifi_ap/mt_wifi.ko + AUTOLOAD:=$(call AutoProbe,mt_wifi) +endif + SUBMENU:=Drivers + MENU:=1 +endef + +define KernelPackage/mt_wifi/config + source "$(SOURCE)/config.in" +endef + + +define Build/Compile + $(MAKE) -C "$(LINUX_DIR)" V=1 \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + ARCH="$(LINUX_KARCH)" \ + SUBDIRS="$(PKG_BUILD_DIR)/mt_wifi_ap" \ + $(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_MTK_$c),CONFIG_$(c)=$(CONFIG_MTK_$(c)))) \ + modules +endef + +define KernelPackage/mt_wifi/install + $(INSTALL_DIR) $(1)/etc/init.d/ + $(INSTALL_DIR) $(1)/lib/wifi/ + $(INSTALL_DIR) $(1)/etc/wireless/mediatek/ + $(INSTALL_DIR) $(1)/etc/Wireless/RT2860/ + $(INSTALL_DIR) $(1)/etc/wireless/mt7615/ + $(INSTALL_DIR) $(1)/etc/RT2860/ + $(INSTALL_BIN) ./files/mt7615.1.2G.dat $(1)/etc/wireless/mt7615/ + $(INSTALL_BIN) ./files/mt7615.1.5G.dat $(1)/etc/wireless/mt7615/ + $(INSTALL_BIN) ./files/mt7615e-sku.dat $(1)/etc/wireless/mediatek/ + $(INSTALL_BIN) ./files/mt7615e-sku-bf.dat $(1)/etc/wireless/mediatek/ + echo $(PKG_VERSION) > $(1)/etc/wireless/mediatek/version + $(INSTALL_BIN) ./files/mt7615e*.lua $(1)/lib/wifi/ + $(INSTALL_BIN) ./files/wifi_services.lua $(1)/lib/wifi/ + $(INSTALL_BIN) ./files/firmware.sh $(1)/etc/init.d/ + +endef + +$(eval $(call KernelPackage,mt_wifi)) diff --git a/package/mtk/drivers/mt_wifi/auto_build_kernel_4_4.sh b/package/mtk/drivers/mt_wifi/auto_build_kernel_4_4.sh new file mode 100644 index 000000000..67f19dec5 --- /dev/null +++ b/package/mtk/drivers/mt_wifi/auto_build_kernel_4_4.sh @@ -0,0 +1,80 @@ +if [ -d wifi_driver ]; then + mkdir -p mt_wifi_ap + mkdir -p mt_wifi_sta + cp -a wifi_driver/os/linux/Kconfig.mt_wifi_ap ./mt_wifi_ap/Kconfig + cp -a wifi_driver/os/linux/Makefile.mt_wifi_ap ./mt_wifi_ap/Makefile + cp -a wifi_driver/os/linux/Kconfig.mt_wifi_sta ./mt_wifi_sta/Kconfig + cp -a wifi_driver/os/linux/Makefile.mt_wifi_sta ./mt_wifi_sta/Makefile + cp -a wifi_driver/os/linux/Kconfig.mt_wifi wifi_driver/embedded/Kconfig + cp -rf wifi_driver mt_wifi + #if [ -d mt_wifi ]; then + # rm -rf mt_wifi + #fi + #mv wifi_driver mt_wifi + echo "7622 mt_wifi autobuild" + RT28xx_DIR=./mt_wifi + CHIPSET=mt7622 + RT28xx_MODE=AP + HAS_WOW_SUPPORT=n + HAS_FPGA_MODE=n + HAS_RX_CUT_THROUGH=n + RT28xx_BIN_DIR=. + export RT28xx_DIR CHIPSET RT28xx_MODE HAS_WOW_SUPPORT HAS_FPGA_MODE HAS_RX_CUT_THROUGH RT28xx_BIN_DIR + make -C mt_wifi/embedded build_tools + ./mt_wifi/embedded/tools/bin2h + make -C mt_wifi/embedded build_sku_tables + ./mt_wifi/txpwr/dat2h + echo "7615 mt_wifi autobuild" + RT28xx_DIR=./mt_wifi + CHIPSET=mt7615 + RT28xx_MODE=AP + HAS_WOW_SUPPORT=n + HAS_FPGA_MODE=n + HAS_RX_CUT_THROUGH=n + RT28xx_BIN_DIR=. + export RT28xx_DIR CHIPSET RT28xx_MODE HAS_WOW_SUPPORT HAS_FPGA_MODE HAS_RX_CUT_THROUGH RT28xx_BIN_DIR + make -C mt_wifi/embedded build_tools + ./mt_wifi/embedded/tools/bin2h + make -C mt_wifi/embedded build_sku_tables + ./mt_wifi/txpwr/dat2h + echo "7626 mt_wifi autobuild" + RT28xx_DIR=./mt_wifi + CHIPSET=mt7626 + RT28xx_MODE=AP + HAS_WOW_SUPPORT=n + HAS_FPGA_MODE=n + HAS_RX_CUT_THROUGH=n + RT28xx_BIN_DIR=. + export RT28xx_DIR CHIPSET RT28xx_MODE HAS_WOW_SUPPORT HAS_FPGA_MODE HAS_RX_CUT_THROUGH RT28xx_BIN_DIR + make -C mt_wifi/embedded build_tools + ./mt_wifi/embedded/tools/bin2h + make -C mt_wifi/embedded build_sku_tables + ./mt_wifi/txpwr/dat2h +elif [ -d rlt_wifi ]; then + mkdir -p mt_wifi_ap + mkdir -p mt_wifi_sta + cp -a rlt_wifi/os/linux/Kconfig.mt_wifi_ap ./mt_wifi_ap/Kconfig + cp -a rlt_wifi/os/linux/Makefile.mt_wifi_ap ./mt_wifi_ap/Makefile + cp -a rlt_wifi/os/linux/Kconfig.mt_wifi_sta ./mt_wifi_sta/Kconfig + cp -a rlt_wifi/os/linux/Makefile.mt_wifi_sta ./mt_wifi_sta/Makefile + cp -a rlt_wifi/os/linux/Kconfig.mt_wifi rlt_wifi/embedded/Kconfig + if [ -d mt_wifi ]; then + rm -rf mt_wifi + fi + mv rlt_wifi mt_wifi + echo "7615e rlt_wifi autobuild" + RT28xx_DIR=./mt_wifi + CHIPSET=mt7615 + RT28xx_MODE=AP + HAS_WOW_SUPPORT=n + HAS_FPGA_MODE=n + HAS_RX_CUT_THROUGH=n + RT28xx_BIN_DIR=. + export RT28xx_DIR CHIPSET RT28xx_MODE HAS_WOW_SUPPORT HAS_FPGA_MODE HAS_RX_CUT_THROUGH RT28xx_BIN_DIR + make -C mt_wifi/embedded build_tools + ./mt_wifi/embedded/tools/bin2h + make -C mt_wifi/embedded build_sku_tables + ./mt_wifi/txpwr/dat2h +else + exit 1 +fi diff --git a/package/mtk/drivers/mt_wifi/config.in b/package/mtk/drivers/mt_wifi/config.in new file mode 100644 index 000000000..51fa06359 --- /dev/null +++ b/package/mtk/drivers/mt_wifi/config.in @@ -0,0 +1,868 @@ +if PACKAGE_kmod-mt_wifi + +config MTK_SUPPORT_OPENWRT + bool + default y + depends on PACKAGE_kmod-mt_wifi + +config MTK_WIFI_DRIVER + bool + default y + depends on PACKAGE_kmod-mt_wifi + select MTK_WIFI_MT_MAC + select MTK_MT_MAC + #select MTK_FIRST_IF_MT7615E + #select MTK_CHIP_MT7622 + #select MTK_CHIP_MT7626 + #select MTK_SECOND_IF_MT7615E + #select MTK_THIRD_IF_MT7615E + #select MTK_CHIP_MT7615E + +if MTK_WIFI_DRIVER + +choice + prompt "Choose First WiFi Interface" + config MTK_FIRST_IF_NONE + bool "None" + + config MTK_FIRST_IF_MT7615E + bool "MT7615E" + select MTK_WIFI_MT_MAC + select MTK_MT_MAC + select MTK_CHIP_MT7615E + + config MTK_FIRST_IF_MT7622 + bool "MT7622" + select MTK_WIFI_MT_MAC + select MTK_MT_MAC + select MTK_CHIP_MT7622 + + config MTK_FIRST_IF_MT7626 + bool "MT7626" + select MTK_WIFI_MT_MAC + select MTK_MT_MAC + select MTK_CHIP_MT7626 +endchoice + +choice + prompt "Choose Second WiFi Interface" + config MTK_SECOND_IF_NONE + bool "None" + + config MTK_SECOND_IF_MT7615E + bool "MT7615E" + select MTK_WIFI_MT_MAC + select MTK_CHIP_MT7615E + select MTK_MULTI_INF_SUPPORT + +endchoice + +choice + prompt "Choose Third WiFi Interface" + config MTK_THIRD_IF_NONE + bool "None" + + config MTK_THIRD_IF_MT7615E + bool "MT7615E" + select MTK_WIFI_MT_MAC + select MTK_CHIP_MT7615E + select MTK_MULTI_INF_SUPPORT + +endchoice + +config MTK_RT_FIRST_CARD + int + depends on ! MTK_FIRST_IF_NONE + default 7615 if MTK_FIRST_IF_MT7615E + default 7622 if MTK_FIRST_IF_MT7622 + default 7626 if MTK_FIRST_IF_MT7626 + +config MTK_RT_SECOND_CARD + int + depends on ! MTK_SECOND_IF_NONE + default 7615 if MTK_SECOND_IF_MT7615E + +config MTK_RT_THIRD_CARD + int + depends on ! MTK_THIRD_IF_NONE + default 7615 if MTK_THIRD_IF_MT7615E + +config MTK_RT_FIRST_IF_RF_OFFSET + hex + depends on ! MTK_FIRST_IF_NONE + default 0xc0000 + +config MTK_RT_SECOND_IF_RF_OFFSET + hex + depends on ! MTK_SECOND_IF_NONE + default 0xc8000 + +config MTK_RT_THIRD_IF_RF_OFFSET + hex + depends on ! MTK_THIRD_IF_NONE + default 0xd0000 + +config MTK_MT_WIFI + tristate "MT WIFI Driver" + select MTK_WIFI_BASIC_FUNC if MTK_MT_WIFI + +config MTK_MT_WIFI_PATH + string + depends on MTK_MT_WIFI + default "mt_wifi" + +if MTK_MT_WIFI +menu "WiFi Generic Feature Options" +choice + prompt "EEPROM Type of 1st Card" + depends on ! MTK_FIRST_IF_NONE + + config MTK_FIRST_IF_EEPROM_FLASH + bool "FLASH" + + config MTK_FIRST_IF_EEPROM_PROM + bool "EEPROM" + + config MTK_FIRST_IF_EEPROM_EFUSE + bool "EFUSE" + +endchoice + +config MTK_RT_FIRST_CARD_EEPROM + string + depends on ! MTK_FIRST_IF_NONE + default "prom" if MTK_FIRST_IF_EEPROM_PROM + default "efuse" if MTK_FIRST_IF_EEPROM_EFUSE + default "flash" if MTK_FIRST_IF_EEPROM_FLASH + +choice + prompt "EEPROM Type of 2nd Card" + depends on ! MTK_SECOND_IF_NONE + + config MTK_SECOND_IF_EEPROM_FLASH + bool "FLASH" + + config MTK_SECOND_IF_EEPROM_PROM + bool "EEPROM" + + config MTK_SECOND_IF_EEPROM_EFUSE + bool "EFUSE" + +endchoice + +config MTK_RT_SECOND_CARD_EEPROM + string + depends on ! MTK_SECOND_IF_NONE + default "prom" if MTK_SECOND_IF_EEPROM_PROM + default "efuse" if MTK_SECOND_IF_EEPROM_EFUSE + default "flash" if MTK_SECOND_IF_EEPROM_FLASH + +choice + prompt "EEPROM Type of 3th Card" + depends on ! MTK_THIRD_IF_NONE + + config MTK_THIRD_IF_EEPROM_FLASH + bool "FLASH" + + config MTK_THIRD_IF_EEPROM_PROM + bool "EEPROM" + + config MTK_THIRD_IF_EEPROM_EFUSE + bool "EFUSE" + +endchoice + +config MTK_RT_THIRD_CARD_EEPROM + string + depends on ! MTK_THIRD_IF_NONE + default "prom" if MTK_THIRD_IF_EEPROM_PROM + default "efuse" if MTK_THIRD_IF_EEPROM_EFUSE + default "flash" if MTK_THIRD_IF_EEPROM_FLASH + +config MTK_MULTI_INF_SUPPORT + bool + default y if !MTK_FIRST_IF_NONE && !MTK_SECOND_IF_NONE + +config MTK_WIFI_BASIC_FUNC + bool "Basic Functions" + select MTK_WIRELESS_EXT + select MTK_WEXT_SPY + select MTK_WEXT_PRIV + +config MTK_DOT11_N_SUPPORT + bool "802.11n support" + default y + +config MTK_DOT11_VHT_AC + bool "802.11AC support" + depends on MTK_WIFI_DRIVER + depends on MTK_DOT11_N_SUPPORT + default y + +config MTK_G_BAND_256QAM_SUPPORT + bool "2.4G 256QAM support" + depends on MTK_WIFI_DRIVER + depends on MTK_DOT11_VHT_AC + default y + +config MTK_BRCM_256QAM_SUPPORT + bool "BRCM 2.4G 256QAM support" + depends on MTK_WIFI_DRIVER + depends on MTK_G_BAND_256QAM_SUPPORT + default n + +config MTK_VHT_TXBF_2G_EPIGRAM_IE_SUPPORT + bool "BRCM 2.4G VHT Sounding support" + depends on MTK_WIFI_DRIVER + default n + +config MTK_TPC_SUPPORT + bool "802.11h TPC Support" + depends on MTK_WIFI_DRIVER + default y + +config MTK_ICAP_SUPPORT + bool "ICAP Support" + depends on MTK_WIFI_DRIVER + depends on MTK_MT_AP_SUPPORT + default y + +config MTK_SPECTRUM_SUPPORT + bool "Wifi Spectrum Support" + depends on MTK_WIFI_DRIVER + depends on MTK_MT_AP_SUPPORT + default y + +config MTK_BACKGROUND_SCAN_SUPPORT + bool "Background Scan Support" + depends on MTK_WIFI_DRIVER + default y + +config MTK_SMART_CARRIER_SENSE_SUPPORT + bool "Smart Carrier Sense Support" + depends on MTK_WIFI_DRIVER + default y + +config MTK_MT_DFS_SUPPORT + bool "Dynamic Frequency Selection Support" + depends on MTK_WIFI_DRIVER + default y + +#config WFA_VHT_R2_PF +# bool "WFA VHT R2 Plugfest" +# depends on DOT11_VHT_AC +# default n + +config MTK_HDR_TRANS_TX_SUPPORT + bool "Tx Header Translation" + depends on MTK_CHIP_MT7615E || MTK_CHIP_MT7622 || MTK_CHIP_MT7626 + default y + +config MTK_HDR_TRANS_RX_SUPPORT + bool "Rx Header Translation" + depends on MTK_CHIP_MT7615E || MTK_CHIP_MT7622 || MTK_CHIP_MT7626 + default y + +config MTK_DBDC_MODE + bool "dbdc mode support" + depends on MTK_CHIP_MT7615E || MTK_CHIP_MT7626 + select MULTI_PROFILE_SUPPORT + select DEFAULT_5G_PROFILE + default y + +config MTK_MULTI_PROFILE_SUPPORT + bool "Multi Profile Support" + depends on MTK_DBDC_MODE + default y + +config MTK_DEFAULT_5G_PROFILE + bool "5G default profile for DBDC" + depends on MTK_DBDC_MODE +# depends on MTK_MULTI_PROFILE_SUPPORT + default y + +config MTK_WSC_INCLUDED + bool "WSC (WiFi Simple Config)" + depends on MTK_WIFI_DRIVER + depends on MTK_MT_AP_SUPPORT || MTK_MT_STA_SUPPORT + default y + +config MTK_WSC_V2_SUPPORT + bool "WSC V2(WiFi Simple Config Version 2.0)" + depends on MTK_WIFI_DRIVER + depends on MTK_MT_AP_SUPPORT || MTK_MT_STA_SUPPORT + default y + +config MTK_DOT11W_PMF_SUPPORT + bool "PMF" + depends on MTK_WIFI_DRIVER + depends on MTK_MT_AP_SUPPORT || MTK_MT_STA_SUPPORT + default y + +config MTK_TXBF_SUPPORT + bool "Tx Bean Forming Support" + depends on MTK_WIFI_DRIVER + default y + +config MTK_FAST_NAT_SUPPORT + bool "Fast-NAT support" +# depends on RA_HW_NAT_WIFI + default n + +config MTK_WHNAT_SUPPORT + tristate "Wifi Hardware NAT support" + depends on MTK_CHIP_MT7615E + depends on MTK_WLAN_HOOK + depends on MTK_FAST_NAT_SUPPORT + select PACKAGE_kmod-hw_nat + default n + +#config LLTD_SUPPORT +# bool "LLTD (Link Layer Topology Discovery Protocol)" +# depends on WIFI_DRIVER +# depends on MT_AP_SUPPORT +# default n + +#config QOS_DLS_SUPPORT +# bool "802.11e DLS ((Direct-Link Setup) Support" +# depends on WIFI_DRIVER +# depends on MT_AP_SUPPORT +# default n + +#config WAPI_SUPPORT +# bool "WAPI Support" +# depends on WIFI_DRIVER +# default n + +config MTK_FTM_SUPPORT + bool "FTM Support" + depends on MTK_WIFI_DRIVER + select MTK_PASSPOINT_R2 + default n + +#config CARRIER_DETECTION_SUPPORT +# bool "Carrier Detect" +# depends on WIFI_DRIVER +# default n + +config MTK_IGMP_SNOOP_SUPPORT + bool "IGMP snooping" + depends on MTK_WIFI_DRIVER + depends on MTK_MT_AP_SUPPORT + default y + +#config BLOCK_NET_IF +# bool "NETIF Block" +# depends on WIFI_DRIVER +# depends on MT_AP_SUPPORT +# default n +# help +# Support Net interface block while Tx-Sw queue full + +#config RATE_ADAPTION +# bool "New Rate Adaptation support" +# depends on WIFI_DRIVER +# default y + +#config NEW_RATE_ADAPT_SUPPORT +# bool "Intelligent Rate Adaption" +# depends on WIFI_DRIVER && RATE_ADAPTION +# default y + +#config AGS_SUPPORT +# bool "Adaptive Group Switching" +# depends on WIFI_DRIVER && RATE_ADAPTION +# depends on MT_AP_SUPPORT || MT_STA_SUPPORT +# default n + +#config RATE_ADAPT_AGBS_SUPPORT +# bool "Adaptive AGBS Mode" +# depends on WIFI_DRIVER && RATE_ADAPTION +# depends on MT_AP_SUPPORT || MT_STA_SUPPORT +# default y + +#config IDS_SUPPORT +# bool "IDS (Intrusion Detection System) Support" +# depends on WIFI_DRIVER +# depends on MT_AP_SUPPORT +# default n + +#config WIFI_WORK_QUEUE +# bool "Work Queue" +# depends on WIFI_DRIVER +# default n + +#config WIFI_SKB_RECYCLE +# bool "SKB Recycle(Linux)" +# depends on WIFI_DRIVER +# depends on MT_AP_SUPPORT +# default n + +config MTK_RTMP_FLASH_SUPPORT + bool "Flash Support" + depends on MTK_WIFI_DRIVER + default y + +config MTK_PRE_CAL_TRX_SET1_SUPPORT + bool "Calibration To Flash/BinFile Support" + depends on MTK_WIFI_DRIVER + default y + +config MTK_RLM_CAL_CACHE_SUPPORT + bool "RlmCalibrationCache Support" + depends on MTK_WIFI_DRIVER + default y + +config MTK_PRE_CAL_TRX_SET2_SUPPORT + bool "Pre-calibration to Flash Support" + depends on MTK_WIFI_DRIVER + default y + +config MTK_RF_LOCKDOWN_SUPPORT + bool "RF Lockdown Support" + depends on MTK_WIFI_DRIVER + default n + +config MTK_LINK_TEST_SUPPORT + bool "Link Test Support" + depends on MTK_WIFI_DRIVER + default n + +#config MTK_LED_CONTROL_SUPPORT +# bool "LED Support" +# depends on MTK_WIFI_DRIVER +# depends on MTK_MT_AP_SUPPORT +# default n + +config MTK_ATE_SUPPORT + bool "ATE/QA Support" + depends on MTK_WIFI_DRIVER + default y + +#config MTK_MEMORY_OPTIMIZATION +# bool "Memory Optimization" +# depends on MTK_WIFI_DRIVER +# default n + +config MTK_PASSPOINT_R2 + bool "Passpoint Release-2 Support" + depends on MTK_WIFI_DRIVER + select MTK_DOT11W_PMF_SUPPORT + depends on MTK_MT_AP_SUPPORT + default n + +config MTK_MBO_SUPPORT + bool "MBO Support" + depends on MTK_WIFI_DRIVER + select MTK_INTERWORKING + select MTK_WNM_SUPPORT + select MTK_DOT11K_RRM_SUPPORT + select MTK_DOT11R_FT_SUPPORT + select MTK_DOT11W_PMF_SUPPORT + default n + +#config TRACE_TCP_PKT +# bool "TCP DATA/ACK packets trace log" +# depends on WIFI_DRIVER +# default n + +config MTK_UAPSD + bool "UAPSD support" + depends on MTK_WIFI_DRIVER + depends on MTK_MT_AP_SUPPORT || MTK_MT_STA_SUPPORT + default y + +config MTK_TCP_RACK_SUPPORT + bool "TCP Reduced ACK support" + depends on MTK_WIFI_DRIVER + default n + +#### PA_LNA_Type choice + +config MTK_RED_SUPPORT + bool "RED(Random Early Drop) support" + depends on MTK_WIFI_DRIVER + depends on MTK_MT_AP_SUPPORT || MTK_MT_STA_SUPPORT + default y + +config MTK_FQ_SCH_SUPPORT + bool "Fair Queueing support" + depends on MTK_WIFI_DRIVER + depends on MTK_MT_AP_SUPPORT && MTK_VOW_SUPPORT + depends on MTK_CHIP_MT7622 + default y + +config MTK_FDB_SUPPORT + bool "FW Debug Port" + depends on MTK_WIFI_DRIVER + default n + +choice + prompt "PA LNA Type of 1st Card" + depends on ! MTK_FIRST_IF_NONE + + config MTK_FIRST_IF_EPAELNA + bool "ePAeLNA" + config MTK_FIRST_IF_IPAILNA + bool "iPAiLNA" + config MTK_FIRST_IF_IPAELNA + bool "iPAeLNA" +# config MTK_FIRST_IF_EPAILNA +# bool "ePAiLNA" +endchoice +choice + prompt "PA LNA Type of 2nd Card" + depends on ! MTK_SECOND_IF_NONE + + config MTK_SECOND_IF_EPAELNA + bool "ePAeLNA" + config MTK_SECOND_IF_IPAILNA + bool "iPAiLNA" + config MTK_SECOND_IF_IPAELNA + bool "iPAeLNA" +# config MTK_SECOND_IF_EPAILNA +# bool "ePAiLNA" +endchoice +choice + prompt "PA LNA Type of 3rd Card" + depends on ! MTK_THIRD_IF_NONE + + config MTK_THIRD_IF_EPAELNA + bool "ePAeLNA" + config MTK_THIRD_IF_IPAILNA + bool "iPAiLNA" + config MTK_THIRD_IF_IPAELNA + bool "iPAeLNA" +# config MTK_THIRD_IF_EPAILNA +# bool "ePAiLNA" +endchoice +#### PA_LNA_Type choice END + +# +# Section for chip architectures +# +# "RLT MAC Support" +config MTK_RLT_MAC + bool + depends on MTK_WIFI_DRIVER + default n + +config MTK_RLT_BBP + bool + +config MTK_RLT_RF + bool + +# "RTMP MAC Support" +config MTK_RTMP_MAC + bool + depends on MTK_WIFI_DRIVER + default n + +config MTK_RTMP_BBP + bool + +config MTK_RTMP_RF + bool + +# +# Section for interfaces +# +config MTK_RTMP_PCI_SUPPORT + bool + +config MTK_RTMP_USB_SUPPORT + bool + +config MTK_RTMP_RBUS_SUPPORT + bool + +endmenu + +menu "WiFi Operation Modes" +choice + prompt "Main Mode" + default MTK_WIFI_MODE_AP + + config MTK_WIFI_MODE_AP + tristate "AP" + select MTK_MT_AP_SUPPORT + + config MTK_WIFI_MODE_STA + tristate "STA" + select MTK_MT_STA_SUPPORT + + config MTK_WIFI_MODE_BOTH + tristate "APSTA" + select MTK_MT_AP_SUPPORT + select MTK_MT_STA_SUPPORT +endchoice + + +config MTK_MT_AP_SUPPORT + tristate "Ralink RT2860 802.11n AP support" +# depends on NET_RADIO + select MTK_WIRELESS_EXT + select MTK_WEXT_SPY + select MTK_WEXT_PRIV + +config MTK_WDS_SUPPORT + bool "WDS" + depends on MTK_MT_AP_SUPPORT + default y + +config MTK_MBSS_SUPPORT + bool "MBSSID" + depends on MTK_MT_AP_SUPPORT + default y + +#config NEW_MBSSID_MODE +# bool "New MBSSID MODE" +# depends on MT_AP_SUPPORT && MBSS_SUPPORT +# depends on RALINK_RT3883 || RALINK_RT3352 || RALINK_RT5350 || RALINK_RT6352 || RALINK_MT7620 +# default y + +#config ENHANCE_NEW_MBSSID_MODE +# bool "Enhanced MBSSID mode" +# depends on NEW_MBSSID_MODE +# default y + +config MTK_APCLI_SUPPORT + bool "AP-Client Support" + depends on MTK_MT_AP_SUPPORT + default y + +config MTK_APCLI_CERT_SUPPORT + bool "AP-Client TGn Cert Support" + depends on MTK_MT_AP_SUPPORT + depends on MTK_APCLI_SUPPORT + default n + +config MTK_MAC_REPEATER_SUPPORT + bool "MAC Repeater Support" + depends on MTK_MT_AP_SUPPORT + depends on MTK_APCLI_SUPPORT + depends on MTK_RALINK_RT6352 || MTK_RALINK_MT7620 || MTK_RALINK_MT7603E || MTK_MT_AP_SUPPORT + default y + +config MTK_MWDS + bool "Mixed WDS(MWDS)" + depends on MTK_MT_AP_SUPPORT + select MTK_APCLI_SUPPORT + default n + +config MTK_MUMIMO_SUPPORT + bool "MU-MIMO Support" + depends on MTK_WIFI_DRIVER + select MTK_MU_RA_SUPPORT + default y + +config MTK_MU_RA_SUPPORT + bool "MU-RGA Support" + depends on MTK_MUMIMO_SUPPORT + +config MTK_DOT11R_FT_SUPPORT + bool "802.11r Fast BSS Transition" + depends on MTK_MT_AP_SUPPORT + default n + +config MTK_DOT11K_RRM_SUPPORT + bool "802.11k Radio Resource Management" + depends on MTK_MT_AP_SUPPORT + default n + +#config SNIFFER_SUPPORT +# bool "SNIFFER" +# depends on MT_AP_SUPPORT +# default n + +config MTK_CFG80211_SUPPORT + bool "CFG80211" + depends on MTK_MT_AP_SUPPORT + default n + +config MTK_DSCP_PRI_SUPPORT + bool "Dscp Priority Mapping Support" + depends on MTK_MT_AP_SUPPORT + default n + +config MTK_CON_WPS_SUPPORT + bool "Concurrent WPS Support" + depends on MTK_MT_AP_SUPPORT + depends on MTK_APCLI_SUPPORT + depends on MTK_WSC_INCLUDED + depends on MTK_WSC_V2_SUPPORT +# depends on MTK_MULTI_INF_SUPPORT + default n + +#config LLTD_SUPPORT +# bool "LLTD (Link Layer Topology Discovery Protocol)" +# depends on MT_AP_SUPPORT + +#config COC_SUPPORT +# bool "CoC Support" +# depends on MT_AP_SUPPORT +# default n + +#config RT2860V2_SNMP +# bool "Net-SNMP Support" +# depends on MT_AP_SUPPORT + +config MTK_MCAST_RATE_SPECIFIC + bool "User specific tx rate of mcast pkt" + depends on MTK_MT_AP_SUPPORT + default y + +#config EXT_BUILD_CHANNEL_LIST +# bool "Extension Channel List" +# depends on MT_AP_SUPPORT + +#config AUTO_CH_SELECT_ENHANCE +# bool "Auto Channel Selection Enhancement" +# depends on MT_AP_SUPPORT + +config MTK_VOW_SUPPORT + bool "MediaAir(VOW) support" + depends on MTK_MT_AP_SUPPORT + default y + +#config AIRPLAY_SUPPORT +# bool "AIRPLAY Support" +# depends on MT_AP_SUPPORT +# default n + +config MTK_BAND_STEERING + bool "Band Steering" + depends on MTK_MT_AP_SUPPORT + default y + +config MTK_LED_CONTROL_SUPPORT + bool "LED Control Support" + default n + +config MTK_WLAN_HOOK + bool "WLAN hook Support" + depends on MTK_WIFI_DRIVER + default n + +config MTK_RADIUS_ACCOUNTING_SUPPORT + bool "Radius Accounting Support" + depends on MTK_MT_AP_SUPPORT + default n + +config MTK_GREENAP_SUPPORT + bool "GreenAP Support" + depends on MTK_MT_AP_SUPPORT + default y + +config MTK_PCIE_ASPM_DYM_CTRL_SUPPORT + bool "Pcie Aspm Dynamic Control Support" + depends on MTK_MT_AP_SUPPORT + default y + +config MTK_COEX_SUPPORT + bool "Coex Support" + depends on MTK_MT_AP_SUPPORT + default n + +config MTK_EASY_SETUP_SUPPORT + bool "Whole Home Coverage - Easy Setup" + depends on MTK_MT_AP_SUPPORT + default n + +config MTK_EVENT_NOTIFIER_SUPPORT + bool "Whole Home Coverage - Event Notifier" + depends on MTK_MT_AP_SUPPORT + default n + +config MTK_AIR_MONITOR + bool "Air Monitor" + depends on MTK_MT_AP_SUPPORT + default n + +config MTK_WNM_SUPPORT + bool "802.11v WNM Support" + depends on MTK_MT_AP_SUPPORT + default n + +config MTK_INTERWORKING + bool "802.11u Interworking" + depends on MTK_MT_AP_SUPPORT + default n + +#config ROAMING_ENHANCE_SUPPORT +# bool "Roaming Enhance Support" +# depends on MT_AP_SUPPORT +# depends on APCLI_SUPPORT +# default n + +config MTK_LINUX_NET_TXQ_SUPPORT + bool "NET TX Queue Support" + default n + +#config WIFI_FWD_SUPPORT +# bool "WiFi Forwarding Support" +# default n + +endmenu + +endif + +config MTK_WIFI_MT_MAC + bool + default y + depends on MTK_MT_WIFI + +if MTK_WIFI_RLT_MAC + config MTK_RLT_MAC + bool + default y +endif + +if MTK_WIFI_RTMP_MAC + config MTK_RTMP_MAC + bool + default y +endif + +if MTK_WIFI_MT_MAC + config MTK_MT_MAC + bool + default y + + config MTK_CHIP_MT7603E + bool + default n + + config MTK_CHIP_MT7615E + bool + default n + + config MTK_CHIP_MT7622 + bool + default n + + config MTK_CHIP_MT7663E + bool + default n + + config MTK_CHIP_MT7626 + bool + default n +endif + +if MTK_CHIP_MT7615E || MTK_CHIP_MT7622 || MTK_CHIP_MT7626 + config MTK_MT_MAC + bool + default y + select MTK_RATE_ADAPTION + select MTK_RATE_ADAPT_AGBS_SUPPORT + select MTK_DOT11_N_SUPPORT + select MTK_DOT11_VHT_AC + select MTK_HDR_TRANS_TX_SUPPORT + select MTK_HDR_TRANS_RX_SUPPORT +endif + +endif #MTK_WIFI_DRIVER# +endif #PACKAGE_kmod-mt_wifi# + diff --git a/package/mtk/drivers/mt_wifi/files/firmware.sh b/package/mtk/drivers/mt_wifi/files/firmware.sh new file mode 100644 index 000000000..b6da6c3e3 --- /dev/null +++ b/package/mtk/drivers/mt_wifi/files/firmware.sh @@ -0,0 +1,16 @@ +#!/bin/sh /etc/rc.common + +START=15 +STOP=15 + +USE_PROCD=1 + +start_service() { + [ -f /etc/hotplug.d/firmware/11-mtk-wifi-e2p ] && sh /etc/hotplug.d/firmware/11-mtk-wifi-e2p +} + +stop_service() { + echo 'do nothing' > /dev/null +} + + diff --git a/package/mtk/drivers/mt_wifi/files/mt7615.1.2G.dat b/package/mtk/drivers/mt_wifi/files/mt7615.1.2G.dat new file mode 100644 index 000000000..89a7b83c5 --- /dev/null +++ b/package/mtk/drivers/mt_wifi/files/mt7615.1.2G.dat @@ -0,0 +1,375 @@ +Default +AccessControlList0= +AccessControlList1= +AccessControlList10= +AccessControlList11= +AccessControlList12= +AccessControlList13= +AccessControlList14= +AccessControlList15= +AccessControlList2= +AccessControlList3= +AccessControlList4= +AccessControlList5= +AccessControlList6= +AccessControlList7= +AccessControlList8= +AccessControlList9= +AccessPolicy0=0 +AccessPolicy1=0 +AccessPolicy10=0 +AccessPolicy11=0 +AccessPolicy12=0 +AccessPolicy13=0 +AccessPolicy14=0 +AccessPolicy15=0 +AccessPolicy2=0 +AccessPolicy3=0 +AccessPolicy4=0 +AccessPolicy5=0 +AccessPolicy6=0 +AccessPolicy7=0 +AccessPolicy8=0 +AccessPolicy9=0 +AckPolicy=0;0;0;0 +APACM=0;0;0;0 +APAifsn=3;7;1;1 +ApCliAuthMode= +ApCliBssid= +ApCliDefaultKeyID= +ApCliEnable= +ApCliEncrypType= +ApCliKey1Str= +ApCliKey1Str1= +ApCliKey1Type= +ApCliKey2Str= +ApCliKey2Str1= +ApCliKey2Type= +ApCliKey3Str= +ApCliKey3Str1= +ApCliKey3Type= +ApCliKey4Str= +ApCliKey4Str1= +ApCliKey4Type= +ApCliSsid= +ApCliWirelessMode= +ApCliWPAPSK= +ApCliWPAPSK1= +APCwmax=6;10;4;3 +APCwmin=4;4;3;2 +APSDCapable=1 +APTxop=0;0;94;47 +AuthMode=OPEN +AutoChannelSelect=0 +AutoChannelSkipList= +AutoProvisionEn=0 +BandSteering=0 +BasicRate=15 +BeaconPeriod=100 +BFBACKOFFenable=0 +BgndScanSkipCh= +BGProtection=0 +BndStrgBssIdx= +BSSACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmax=10;10;4;3 +BSSCwmin=4;4;3;2 +BssidNum=1 +BSSTxop=0;0;94;47 +BW_Enable=0 +BW_Guarantee_Rate= +BW_Maximum_Rate= +BW_Priority= +BW_Root=0 +CalCacheApply=0 +CarrierDetect=0 +Channel=6 +ChannelGrp= +CountryCode=US +CountryRegion=5 +CountryRegionABand=7 +CP_SUPPORT=2 +CSPeriod=6 +DBDC_MODE=1 +DebugFlags=0 +DefaultKeyID=1 +DfsCalibration=0 +DfsEnable=0 +DfsFalseAlarmPrevent=1 +DfsZeroWait=0 +DfsZeroWaitCacTime=255 +DisableOLBC=0 +DtimPeriod=1 +E2pAccessMode=2 +EAPifname=br0 +EDCCAEnable=1 +EncrypType=NONE +EthConvertMode=dongle +EtherTrafficBand=0 +Ethifname= +ETxBfEnCond=1 +FineAGC=0 +FixedTxMode= +ForceRoamSupport= +FragThreshold=2346 +FreqDelta=0 +FtSupport=0 +GreenAP=1 +G_BAND_256QAM=1 +HideSSID=0 +HT_AMSDU=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_BAWinSize=64 +HT_BSSCoexistence=1 +HT_BW=1 +HT_DisallowTKIP=1 +HT_EXTCHA=1 +HT_GI=1 +HT_HTC=1 +HT_LDPC=1 +HT_LinkAdapt=0 +HT_MCS=33 +HT_MpduDensity=5 +HT_OpMode=0 +HT_PROTECT=1 +HT_RxStream=2 +HT_STBC=1 +HT_TxStream=2 +IcapMode=0 +idle_timeout_interval=0 +IEEE80211H=1 +IEEE8021X=0 +IgmpSnEnable=0 +ITxBfEn=1 +Key1Str= +Key1Str1= +Key1Str10= +Key1Str11= +Key1Str12= +Key1Str13= +Key1Str14= +Key1Str15= +Key1Str16= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key1Str9= +Key1Type=0 +Key2Str= +Key2Str1= +Key2Str10= +Key2Str11= +Key2Str12= +Key2Str13= +Key2Str14= +Key2Str15= +Key2Str16= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key2Str9= +Key2Type=0 +Key3Str= +Key3Str1= +Key3Str10= +Key3Str11= +Key3Str12= +Key3Str13= +Key3Str14= +Key3Str15= +Key3Str16= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key3Str9= +Key3Type=0 +Key4Str= +Key4Str1= +Key4Str10= +Key4Str11= +Key4Str12= +Key4Str13= +Key4Str14= +Key4Str15= +Key4Str16= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +Key4Str9= +Key4Type=0 +LinkTestSupport=0 +MACRepeaterEn= +MACRepeaterOuiMode=2 +MUTxRxEnable=0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +own_ip_addr=10.10.10.254 +PcieAspm=0 +PERCENTAGEenable=0 +PhyRateLimit=0 +PMFMFPC=1 +PMFMFPR=0 +PMFSHA256=0 +PMKCachePeriod=10 +PowerUpCckOfdm=0:0:0:0:0:0:0 +PowerUpHT20=0:0:0:0:0:0:0 +PowerUpHT40=0:0:0:0:0:0:0 +PowerUpVHT160=0:0:0:0:0:0:0 +PowerUpVHT20=0:0:0:0:0:0:0 +PowerUpVHT40=0:0:0:0:0:0:0 +PowerUpVHT80=0:0:0:0:0:0:0 +PreAntSwitch= +PreAuth=0 +PreAuthifname=br0 +RadioLinkSelection=0 +RadioOn=1 +RADIUS_Acct_Key= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Server= +RADIUS_Key1= +RADIUS_Key10= +RADIUS_Key11= +RADIUS_Key12= +RADIUS_Key13= +RADIUS_Key14= +RADIUS_Key15= +RADIUS_Key16= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Key9= +RADIUS_Port=1812 +RADIUS_Server=0 +RDRegion= +RED_Enable=1 +RekeyInterval=3600 +RekeyMethod=DISABLE +RRMEnable=0 +RTSThreshold=2347 +session_timeout_interval=0 +ShortSlot=1 +SKUenable=0 +SSID= +SSID1=K2P_2G +SSID10= +SSID11= +SSID12= +SSID13= +SSID14= +SSID15= +SSID16= +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +SSID9= +StationKeepAlive=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +TGnWifiTest=0 +ThermalRecal=0 +TxBurst=1 +TxPower=100 +TxPreamble=1 +VHT_BW=1 +VHT_BW_SIGNAL=0 +VHT_LDPC=1 +VHT_Sec80_Channel=0 +VHT_SGI=1 +VHT_STBC=1 +VLANID=0 +VLANPriority=0 +VLANTag=0 +VOW_Airtime_Ctrl_En= +VOW_Airtime_Fairness_En=1 +VOW_BW_Ctrl=0 +VOW_Group_Backlog= +VOW_Group_DWRR_Max_Wait_Time= +VOW_Group_DWRR_Quantum= +VOW_Group_Max_Airtime_Bucket_Size= +VOW_Group_Max_Rate= +VOW_Group_Max_Rate_Bucket_Size= +VOW_Group_Max_Ratio= +VOW_Group_Max_Wait_Time= +VOW_Group_Min_Airtime_Bucket_Size= +VOW_Group_Min_Rate= +VOW_Group_Min_Rate_Bucket_Size= +VOW_Group_Min_Ratio= +VOW_Rate_Ctrl_En= +VOW_Refill_Period= +VOW_RX_En=1 +VOW_Sta_BE_DWRR_Quantum= +VOW_Sta_BK_DWRR_Quantum= +VOW_Sta_DWRR_Max_Wait_Time= +VOW_Sta_VI_DWRR_Quantum= +VOW_Sta_VO_DWRR_Quantum= +VOW_WATF_Enable= +VOW_WATF_MAC_LV0= +VOW_WATF_MAC_LV1= +VOW_WATF_MAC_LV2= +VOW_WATF_MAC_LV3= +VOW_WATF_Q_LV0= +VOW_WATF_Q_LV1= +VOW_WATF_Q_LV2= +VOW_WATF_Q_LV3= +VOW_WMM_Search_Rule_Band0= +VOW_WMM_Search_Rule_Band1= +WCNTest=0 +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +WdsEnable=0 +WdsEncrypType=NONE +WdsList= +WdsPhyMode=0 +WHNAT=0 +WiFiTest=0 +WirelessMode=9 +WmmCapable=1 +WPAPSK= +WPAPSK1=12345678 +WPAPSK10= +WPAPSK11= +WPAPSK12= +WPAPSK13= +WPAPSK14= +WPAPSK15= +WPAPSK16= +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +WPAPSK9= +WscConfMode=0 +WscConfStatus=2 diff --git a/package/mtk/drivers/mt_wifi/files/mt7615.1.5G.dat b/package/mtk/drivers/mt_wifi/files/mt7615.1.5G.dat new file mode 100644 index 000000000..aa3febfa1 --- /dev/null +++ b/package/mtk/drivers/mt_wifi/files/mt7615.1.5G.dat @@ -0,0 +1,375 @@ +Default +AccessControlList0= +AccessControlList1= +AccessControlList10= +AccessControlList11= +AccessControlList12= +AccessControlList13= +AccessControlList14= +AccessControlList15= +AccessControlList2= +AccessControlList3= +AccessControlList4= +AccessControlList5= +AccessControlList6= +AccessControlList7= +AccessControlList8= +AccessControlList9= +AccessPolicy0=0 +AccessPolicy1=0 +AccessPolicy10=0 +AccessPolicy11=0 +AccessPolicy12=0 +AccessPolicy13=0 +AccessPolicy14=0 +AccessPolicy15=0 +AccessPolicy2=0 +AccessPolicy3=0 +AccessPolicy4=0 +AccessPolicy5=0 +AccessPolicy6=0 +AccessPolicy7=0 +AccessPolicy8=0 +AccessPolicy9=0 +AckPolicy=0;0;0;0 +APACM=0;0;0;0 +APAifsn=3;7;1;1 +ApCliAuthMode= +ApCliBssid= +ApCliDefaultKeyID= +ApCliEnable= +ApCliEncrypType= +ApCliKey1Str= +ApCliKey1Str1= +ApCliKey1Type= +ApCliKey2Str= +ApCliKey2Str1= +ApCliKey2Type= +ApCliKey3Str= +ApCliKey3Str1= +ApCliKey3Type= +ApCliKey4Str= +ApCliKey4Str1= +ApCliKey4Type= +ApCliSsid= +ApCliWirelessMode= +ApCliWPAPSK= +ApCliWPAPSK1= +APCwmax=6;10;4;3 +APCwmin=4;4;3;2 +APSDCapable=1 +APTxop=0;0;94;47 +AuthMode=OPEN +AutoChannelSelect=0 +AutoChannelSkipList= +AutoProvisionEn=0 +BandSteering=0 +BasicRate=15 +BeaconPeriod=100 +BFBACKOFFenable=0 +BgndScanSkipCh= +BGProtection=0 +BndStrgBssIdx= +BSSACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmax=10;10;4;3 +BSSCwmin=4;4;3;2 +BssidNum=1 +BSSTxop=0;0;94;47 +BW_Enable=0 +BW_Guarantee_Rate= +BW_Maximum_Rate= +BW_Priority= +BW_Root=0 +CalCacheApply=0 +CarrierDetect=0 +Channel=36 +ChannelGrp= +CountryCode=US +CountryRegion=5 +CountryRegionABand=7 +CP_SUPPORT=2 +CSPeriod=6 +DBDC_MODE=1 +DebugFlags=0 +DefaultKeyID=1 +DfsCalibration=0 +DfsEnable=1 +DfsFalseAlarmPrevent=1 +DfsZeroWait=0 +DfsZeroWaitCacTime=255 +DisableOLBC=0 +DtimPeriod=1 +E2pAccessMode=2 +EAPifname=br0 +EDCCAEnable=1 +EncrypType=NONE +EthConvertMode=dongle +EtherTrafficBand=0 +Ethifname= +ETxBfEnCond=1 +FineAGC=0 +FixedTxMode= +ForceRoamSupport= +FragThreshold=2346 +FreqDelta=0 +FtSupport=0 +GreenAP=1 +G_BAND_256QAM=1 +HideSSID=0 +HT_AMSDU=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_BAWinSize=64 +HT_BSSCoexistence=1 +HT_BW=1 +HT_DisallowTKIP=1 +HT_EXTCHA=1 +HT_GI=1 +HT_HTC=1 +HT_LDPC=1 +HT_LinkAdapt=0 +HT_MCS=33 +HT_MpduDensity=5 +HT_OpMode=0 +HT_PROTECT=1 +HT_RxStream=2 +HT_STBC=1 +HT_TxStream=2 +IcapMode=0 +idle_timeout_interval=0 +IEEE80211H=1 +IEEE8021X=0 +IgmpSnEnable=0 +ITxBfEn=1 +Key1Str= +Key1Str1= +Key1Str10= +Key1Str11= +Key1Str12= +Key1Str13= +Key1Str14= +Key1Str15= +Key1Str16= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key1Str9= +Key1Type=0 +Key2Str= +Key2Str1= +Key2Str10= +Key2Str11= +Key2Str12= +Key2Str13= +Key2Str14= +Key2Str15= +Key2Str16= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key2Str9= +Key2Type=0 +Key3Str= +Key3Str1= +Key3Str10= +Key3Str11= +Key3Str12= +Key3Str13= +Key3Str14= +Key3Str15= +Key3Str16= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key3Str9= +Key3Type=0 +Key4Str= +Key4Str1= +Key4Str10= +Key4Str11= +Key4Str12= +Key4Str13= +Key4Str14= +Key4Str15= +Key4Str16= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +Key4Str9= +Key4Type=0 +LinkTestSupport=0 +MACRepeaterEn= +MACRepeaterOuiMode=2 +MUTxRxEnable=1 +NoForwarding=0 +NoForwardingBTNBSSID=0 +own_ip_addr=10.10.10.254 +PcieAspm=0 +PERCENTAGEenable=0 +PhyRateLimit=0 +PMFMFPC=1 +PMFMFPR=0 +PMFSHA256=0 +PMKCachePeriod=10 +PowerUpCckOfdm=0:0:0:0:0:0:0 +PowerUpHT20=0:0:0:0:0:0:0 +PowerUpHT40=0:0:0:0:0:0:0 +PowerUpVHT160=0:0:0:0:0:0:0 +PowerUpVHT20=0:0:0:0:0:0:0 +PowerUpVHT40=0:0:0:0:0:0:0 +PowerUpVHT80=0:0:0:0:0:0:0 +PreAntSwitch= +PreAuth=0 +PreAuthifname=br0 +RadioLinkSelection=0 +RadioOn=1 +RADIUS_Acct_Key= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Server= +RADIUS_Key1= +RADIUS_Key10= +RADIUS_Key11= +RADIUS_Key12= +RADIUS_Key13= +RADIUS_Key14= +RADIUS_Key15= +RADIUS_Key16= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Key9= +RADIUS_Port=1812 +RADIUS_Server=0 +RDRegion= +RED_Enable=1 +RekeyInterval=3600 +RekeyMethod=DISABLE +RRMEnable=0 +RTSThreshold=2347 +session_timeout_interval=0 +ShortSlot=1 +SKUenable=0 +SSID= +SSID1=K2P_5G +SSID10= +SSID11= +SSID12= +SSID13= +SSID14= +SSID15= +SSID16= +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +SSID9= +StationKeepAlive=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +TGnWifiTest=0 +ThermalRecal=0 +TxBurst=1 +TxPower=100 +TxPreamble=1 +VHT_BW=1 +VHT_BW_SIGNAL=0 +VHT_LDPC=1 +VHT_Sec80_Channel=0 +VHT_SGI=1 +VHT_STBC=1 +VLANID=0 +VLANPriority=0 +VLANTag=0 +VOW_Airtime_Ctrl_En= +VOW_Airtime_Fairness_En=1 +VOW_BW_Ctrl=0 +VOW_Group_Backlog= +VOW_Group_DWRR_Max_Wait_Time= +VOW_Group_DWRR_Quantum= +VOW_Group_Max_Airtime_Bucket_Size= +VOW_Group_Max_Rate= +VOW_Group_Max_Rate_Bucket_Size= +VOW_Group_Max_Ratio= +VOW_Group_Max_Wait_Time= +VOW_Group_Min_Airtime_Bucket_Size= +VOW_Group_Min_Rate= +VOW_Group_Min_Rate_Bucket_Size= +VOW_Group_Min_Ratio= +VOW_Rate_Ctrl_En= +VOW_Refill_Period= +VOW_RX_En=1 +VOW_Sta_BE_DWRR_Quantum= +VOW_Sta_BK_DWRR_Quantum= +VOW_Sta_DWRR_Max_Wait_Time= +VOW_Sta_VI_DWRR_Quantum= +VOW_Sta_VO_DWRR_Quantum= +VOW_WATF_Enable= +VOW_WATF_MAC_LV0= +VOW_WATF_MAC_LV1= +VOW_WATF_MAC_LV2= +VOW_WATF_MAC_LV3= +VOW_WATF_Q_LV0= +VOW_WATF_Q_LV1= +VOW_WATF_Q_LV2= +VOW_WATF_Q_LV3= +VOW_WMM_Search_Rule_Band0= +VOW_WMM_Search_Rule_Band1= +WCNTest=0 +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +WdsEnable=0 +WdsEncrypType=NONE +WdsList= +WdsPhyMode=0 +WHNAT=0 +WiFiTest=0 +WirelessMode=14 +WmmCapable=1 +WPAPSK= +WPAPSK1=12345678 +WPAPSK10= +WPAPSK11= +WPAPSK12= +WPAPSK13= +WPAPSK14= +WPAPSK15= +WPAPSK16= +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +WPAPSK9= +WscConfMode=0 +WscConfStatus=2 diff --git a/package/mtk/drivers/mt_wifi/files/mt7615e-sku-bf.dat b/package/mtk/drivers/mt_wifi/files/mt7615e-sku-bf.dat new file mode 100644 index 000000000..be9c0d353 --- /dev/null +++ b/package/mtk/drivers/mt_wifi/files/mt7615e-sku-bf.dat @@ -0,0 +1,65 @@ +# Single SKU Max Power Table | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +# 2.4G Channel |CCK | | | |OFDM | | | | | | | |VHT20 | | | | | | | | | |VHT40 | | | | | | | | | |Txstream_Delta | | | | | | | | | | | | | | | | | | | | | +Band: 2.4G |CCK_1M |CCK_2M |CCK_5.5M |CCK_11M |OFDM_6M |OFDM_9M |OFDM_12M |OFDM_18M |OFDM_24M |OFDM_36M |OFDM_48M |OFDM_54M |VHT20_MCS0 |VHT20_MCS1 |VHT20_MCS2 |VHT20_MCS3 |VHT20_MCS4 |VHT20_MCS5 |VHT20_MCS6 |VHT20_MCS7 |VHT20_MCS8 |VHT20_MCS9 |VHT40_MCS0 |VHT40_MCS1 |VHT40_MCS2 |VHT40_MCS3 |VHT40_MCS4 |VHT40_MCS5 |VHT40_MCS6 |VHT40_MCS7 |VHT40_MCS8 |VHT40_MCS9 |Txstream_3T |Txstream_2T |Txstream_1T | | | | | | | | | | | | | | | | | | | +Ch1 |8 | |8 | |8 | |8 | |8 | |8 |8 |10 |8 | |8 | |8 | |20 |12 |18 |16 |8 | |8 | |8 | |9 |11 |12 |2 |1 |3 | | | | | | | | | | | | | | | | | | | +Ch2 |8 | |8 | |8 | |8 | |8 | |8 |8 |15 |8 | |8 | |8 | |19 |19 |10 |12 |8 | |8 | |8 | |9 |16 |12 |5 |4 |0 | | | | | | | | | | | | | | | | | | | +Ch3 |8 | |8 | |8 | |8 | |8 | |8 |8 |18 |8 | |8 | |8 | |17 |18 |16 |20 |8 | |8 | |8 | |12 |8 |20 |0 |2 |0 | | | | | | | | | | | | | | | | | | | +Ch4 |8 | |8 | |8 | |8 | |8 | |8 |8 |9 |8 | |8 | |8 | |14 |10 |14 |18 |8 | |8 | |8 | |14 |12 |10 |3 |4 |5 | | | | | | | | | | | | | | | | | | | +Ch5 |8 | |8 | |8 | |8 | |8 | |8 |8 |10 |8 | |8 | |8 | |10 |13 |11 |8 |8 | |8 | |8 | |12 |8 |9 |4 |5 |3 | | | | | | | | | | | | | | | | | | | +Ch6 |8 | |8 | |8 | |8 | |8 | |8 |8 |13 |8 | |8 | |8 | |11 |9 |12 |16 |8 | |8 | |8 | |9 |17 |11 |5 |2 |1 | | | | | | | | | | | | | | | | | | | +Ch7 |8 | |8 | |8 | |8 | |8 | |8 |8 |10 |8 | |8 | |8 | |14 |11 |13 |18 |8 | |8 | |8 | |16 |13 |10 |2 |5 |4 | | | | | | | | | | | | | | | | | | | +Ch8 |8 | |8 | |8 | |8 | |8 | |8 |8 |15 |8 | |8 | |8 | |14 |9 |11 |10 |8 | |8 | |8 | |11 |14 |8 |5 |5 |3 | | | | | | | | | | | | | | | | | | | +Ch9 |8 | |8 | |8 | |8 | |8 | |8 |8 |11 |8 | |8 | |8 | |12 |9 |15 |19 |8 | |8 | |8 | |14 |20 |12 |2 |5 |3 | | | | | | | | | | | | | | | | | | | +Ch10 |8 | |8 | |8 | |8 | |8 | |8 |8 |14 |8 | |8 | |8 | |17 |14 |17 |15 |8 | |8 | |8 | |9 |17 |8 |2 |4 |2 | | | | | | | | | | | | | | | | | | | +Ch11 |8 | |8 | |8 | |8 | |8 | |8 |8 |14 |8 | |8 | |8 | |20 |10 |20 |18 |8 | |8 | |8 | |12 |8 |20 |3 |1 |4 | | | | | | | | | | | | | | | | | | | +Ch12 |8 | |8 | |8 | |8 | |8 | |8 |8 |18 |8 | |8 | |8 | |20 |16 |17 |9 |8 | |8 | |8 | |11 |20 |9 |0 |0 |1 | | | | | | | | | | | | | | | | | | | +Ch13 |8 | |8 | |8 | |8 | |8 | |8 |8 |8 |8 | |8 | |8 | |11 |16 |19 |16 |8 | |8 | |8 | |15 |12 |12 |2 |0 |2 | | | | | | | | | | | | | | | | | | | +Ch14 |8 | |8 | |8 | |8 | |8 | |8 |8 |10 |8 | |8 | |8 | |15 |17 |16 |14 |8 | |8 | |8 | |12 |14 |20 |4 |1 |5 | | | | | | | | | | | | | | | | | | | + | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +# 5G Channel |OFDM | | | | | | | |VHT20 | | | | | | | | | |VHT40 | | | | | | | | | |VHT80 | | | | | | | | | |VHT160 | | | | | | | | | |Txstream_Delta | | | | | +Band: 5G |OFDM_6M |OFDM_9M |OFDM_12M |OFDM_18M |OFDM_24M |OFDM_36M |OFDM_48M |OFDM_54M |VHT20_MCS0 |VHT20_MCS1 |VHT20_MCS2 |VHT20_MCS3 |VHT20_MCS4 |VHT20_MCS5 |VHT20_MCS6 |VHT20_MCS7 |VHT20_MCS8 |VHT20_MCS9 |VHT40_MCS0 |VHT40_MCS1 |VHT40_MCS2 |VHT40_MCS3 |VHT40_MCS4 |VHT40_MCS5 |VHT40_MCS6 |VHT40_MCS7 |VHT40_MCS8 |VHT40_MCS9 |VHT80_MCS0 |VHT80_MCS1 |VHT80_MCS2 |VHT80_MCS3 |VHT80_MCS4 |VHT80_MCS5 |VHT80_MCS6 |VHT80_MCS7 |VHT80_MCS8 |VHT80_MCS9 |VHT160_MCS0 |VHT160_MCS1 |VHT160_MCS2 |VHT160_MCS3 |VHT160_MCS4 |VHT160_MCS5 |VHT160_MCS6 |VHT160_MCS7 |VHT160_MCS8 |VHT160_MCS9 |Txstream_3T |Txstream_2T |Txstream_1T | | | +Ch184 |18 | |18 | |18 | |18 |18 |15 |18 | |12 | |13 | |11 |14 |16 |16 |12 | |12 | |13 | |20 |17 |16 |17 |18 | |9 | |16 | |17 |20 |18 |16 |19 | |15 | |9 | |17 |8 |17 |0 |4 |4 | | | +Ch188 |18 | |18 | |18 | |18 |18 |16 |20 | |9 | |9 | |11 |8 |12 |18 |15 | |11 | |11 | |14 |8 |17 |16 |16 | |16 | |12 | |8 |13 |19 |18 |11 | |9 | |12 | |14 |8 |13 |5 |2 |0 | | | +Ch192 |18 | |18 | |18 | |18 |18 |15 |9 | |11 | |9 | |15 |14 |11 |19 |15 | |8 | |18 | |20 |20 |8 |9 |9 | |9 | |11 | |18 |13 |14 |20 |18 | |10 | |14 | |12 |13 |16 |0 |2 |0 | | | +Ch196 |18 | |18 | |18 | |18 |18 |10 |11 | |19 | |13 | |12 |11 |10 |13 |11 | |19 | |10 | |16 |20 |15 |15 |8 | |14 | |8 | |18 |20 |15 |17 |17 | |14 | |12 | |12 |8 |16 |4 |3 |2 | | | +Ch8 |18 | |18 | |18 | |18 |18 |18 |13 | |19 | |20 | |18 |10 |9 |8 |8 | |17 | |15 | |17 |9 |18 |19 |11 | |12 | |15 | |20 |12 |12 |13 |9 | |9 | |15 | |10 |11 |17 |4 |3 |3 | | | +Ch12 |18 | |18 | |18 | |18 |18 |17 |20 | |14 | |10 | |10 |16 |15 |13 |11 | |15 | |16 | |17 |11 |15 |9 |18 | |8 | |20 | |19 |11 |9 |20 |8 | |18 | |8 | |8 |18 |18 |1 |3 |4 | | | +Ch16 |18 | |18 | |18 | |18 |18 |10 |18 | |18 | |8 | |19 |8 |12 |19 |16 | |19 | |18 | |16 |19 |12 |18 |18 | |9 | |10 | |18 |20 |20 |20 |9 | |11 | |20 | |17 |14 |16 |2 |2 |2 | | | +Ch36 |18 | |18 | |18 | |18 |18 |18 |19 | |8 | |11 | |16 |10 |9 |19 |11 | |19 | |9 | |8 |19 |8 |11 |17 | |20 | |14 | |9 |19 |19 |20 |13 | |12 | |19 | |13 |17 |9 |5 |1 |2 | | | +Ch40 |18 | |18 | |18 | |18 |18 |13 |20 | |13 | |19 | |16 |11 |14 |17 |17 | |14 | |8 | |13 |8 |10 |20 |10 | |9 | |14 | |11 |14 |17 |9 |20 | |15 | |19 | |9 |8 |11 |3 |1 |1 | | | +Ch44 |18 | |18 | |18 | |18 |18 |10 |14 | |19 | |20 | |17 |16 |12 |18 |8 | |17 | |18 | |15 |19 |14 |11 |13 | |14 | |12 | |16 |16 |19 |13 |14 | |19 | |14 | |20 |20 |11 |5 |1 |0 | | | +Ch48 |18 | |18 | |18 | |18 |18 |8 |12 | |12 | |19 | |11 |8 |11 |20 |12 | |12 | |11 | |15 |16 |10 |12 |16 | |11 | |15 | |18 |19 |17 |16 |17 | |11 | |8 | |10 |16 |16 |5 |5 |0 | | | +Ch52 |18 | |18 | |18 | |18 |18 |15 |12 | |15 | |20 | |9 |10 |10 |14 |8 | |20 | |10 | |16 |17 |18 |11 |16 | |17 | |10 | |17 |12 |13 |17 |17 | |13 | |18 | |18 |20 |13 |4 |3 |4 | | | +Ch56 |18 | |18 | |18 | |18 |18 |13 |16 | |15 | |13 | |15 |20 |13 |14 |11 | |10 | |20 | |10 |8 |16 |12 |10 | |16 | |11 | |9 |11 |14 |17 |12 | |17 | |13 | |18 |10 |19 |0 |3 |3 | | | +Ch60 |18 | |18 | |18 | |18 |18 |14 |11 | |8 | |20 | |13 |16 |13 |11 |20 | |9 | |17 | |16 |11 |8 |12 |17 | |15 | |8 | |16 |10 |20 |19 |15 | |13 | |9 | |17 |18 |11 |4 |1 |2 | | | +Ch64 |18 | |18 | |18 | |18 |18 |13 |14 | |8 | |12 | |17 |8 |12 |18 |17 | |17 | |14 | |18 |8 |8 |20 |17 | |16 | |20 | |9 |15 |11 |10 |11 | |18 | |10 | |10 |15 |19 |2 |1 |4 | | | +Ch68 |18 | |18 | |18 | |18 |18 |14 |19 | |17 | |9 | |18 |19 |20 |12 |14 | |8 | |14 | |20 |20 |18 |9 |18 | |11 | |19 | |19 |10 |11 |8 |18 | |9 | |8 | |16 |11 |8 |3 |3 |1 | | | +Ch72 |18 | |18 | |18 | |18 |18 |19 |13 | |20 | |11 | |16 |9 |19 |20 |19 | |14 | |8 | |9 |17 |13 |19 |15 | |8 | |9 | |19 |14 |19 |15 |18 | |16 | |12 | |13 |15 |10 |4 |3 |1 | | | +Ch76 |18 | |18 | |18 | |18 |18 |17 |13 | |16 | |20 | |16 |8 |9 |20 |11 | |17 | |11 | |8 |18 |9 |20 |9 | |17 | |16 | |11 |11 |11 |18 |10 | |13 | |W | |20 |17 |8 |1 |3 |3 | | | +Ch80 |18 | |18 | |18 | |18 |18 |14 |20 | |13 | |13 | |17 |8 |10 |16 |8 | |9 | |19 | |16 |17 |17 |19 |15 | |9 | |13 | |16 |13 |14 |12 |9 | |20 | |20 | |14 |18 |18 |0 |4 |2 | | | +Ch84 |18 | |18 | |18 | |18 |18 |11 |18 | |20 | |9 | |13 |14 |11 |16 |15 | |12 | |11 | |9 |19 |13 |11 |11 | |9 | |15 | |16 |18 |13 |12 |8 | |8 | |8 | |10 |12 |15 |3 |2 |5 | | | +Ch88 |18 | |18 | |18 | |18 |18 |18 |19 | |9 | |17 | |15 |8 |19 |11 |11 | |14 | |9 | |14 |20 |20 |11 |11 | |15 | |12 | |14 |11 |8 |18 |15 | |19 | |18 | |12 |20 |16 |5 |5 |1 | | | +Ch92 |18 | |18 | |18 | |18 |18 |11 |8 | |15 | |13 | |13 |13 |13 |16 |14 | |14 | |9 | |9 |15 |20 |11 |17 | |10 | |14 | |13 |17 |11 |8 |18 | |20 | |8 | |10 |19 |18 |1 |4 |4 | | | +Ch96 |18 | |18 | |18 | |18 |18 |8 |12 | |16 | |9 | |13 |12 |9 |8 |11 | |8 | |8 | |19 |11 |15 |16 |8 | |11 | |16 | |18 |16 |9 |19 |9 | |10 | |15 | |19 |19 |15 |4 |2 |4 | | | +Ch100 |18 | |18 | |18 | |18 |18 |18 |13 | |20 | |20 | |12 |9 |19 |10 |9 | |14 | |8 | |19 |10 |17 |9 |10 | |10 | |8 | |13 |12 |11 |20 |11 | |16 | |18 | |14 |16 |19 |1 |1 |2 | | | +Ch104 |18 | |18 | |18 | |18 |18 |19 |12 | |20 | |14 | |16 |15 |9 |19 |11 | |15 | |11 | |12 |18 |15 |11 |15 | |19 | |10 | |14 |15 |19 |9 |13 | |19 | |13 | |11 |11 |17 |2 |2 |0 | | | +Ch108 |18 | |18 | |18 | |18 |18 |18 |15 | |13 | |16 | |11 |19 |19 |18 |19 | |12 | |17 | |8 |9 |10 |8 |8 | |18 | |8 | |10 |11 |17 |15 |10 | |19 | |13 | |16 |10 |15 |0 |2 |3 | | | +Ch112 |18 | |18 | |18 | |18 |18 |8 |13 | |9 | |17 | |9 |15 |17 |10 |19 | |9 | |19 | |11 |16 |14 |16 |8 | |18 | |13 | |16 |13 |17 |19 |11 | |8 | |8 | |18 |14 |17 |5 |2 |5 | | | +Ch116 |18 | |18 | |18 | |18 |18 |8 |20 | |11 | |15 | |8 |11 |8 |18 |15 | |13 | |17 | |14 |13 |9 |8 |14 | |14 | |11 | |9 |19 |17 |11 |11 | |8 | |20 | |8 |10 |20 |5 |2 |1 | | | +Ch120 |18 | |18 | |18 | |18 |18 |14 |20 | |8 | |20 | |14 |10 |10 |17 |12 | |16 | |20 | |10 |20 |17 |18 |9 | |15 | |14 | |17 |13 |14 |16 |8 | |18 | |10 | |15 |12 |12 |1 |5 |3 | | | +Ch124 |18 | |18 | |18 | |18 |18 |20 |9 | |17 | |12 | |12 |8 |14 |8 |8 | |20 | |17 | |16 |20 |13 |14 |16 | |10 | |14 | |20 |15 |17 |8 |10 | |13 | |13 | |11 |13 |9 |5 |0 |5 | | | +Ch128 |18 | |18 | |18 | |18 |18 |9 |19 | |9 | |14 | |8 |14 |11 |9 |14 | |16 | |15 | |14 |10 |15 |14 |14 | |20 | |10 | |16 |15 |11 |12 |13 | |13 | |13 | |12 |15 |20 |1 |4 |3 | | | +Ch132 |18 | |18 | |18 | |18 |18 |20 |16 | |13 | |8 | |18 |11 |20 |12 |11 | |11 | |14 | |12 |13 |8 |12 |13 | |10 | |20 | |19 |12 |13 |14 |12 | |11 | |19 | |19 |20 |8 |3 |1 |4 | | | +Ch136 |18 | |18 | |18 | |18 |18 |12 |12 | |19 | |10 | |20 |10 |8 |17 |8 | |12 | |10 | |10 |13 |13 |12 |8 | |11 | |18 | |14 |12 |17 |8 |14 | |14 | |9 | |11 |18 |14 |1 |2 |2 | | | +Ch140 |18 | |18 | |18 | |18 |18 |12 |10 | |13 | |9 | |16 |8 |20 |10 |17 | |8 | |15 | |13 |20 |15 |10 |18 | |13 | |12 | |12 |16 |18 |12 |17 | |10 | |16 | |11 |15 |14 |3 |2 |5 | | | +Ch144 |18 | |18 | |18 | |18 |18 |19 |9 | |15 | |8 | |13 |18 |17 |9 |19 | |16 | |11 | |20 |12 |15 |19 |10 | |17 | |15 | |17 |14 |9 |9 |13 | |17 | |16 | |10 |9 |10 |1 |5 |2 | | | +Ch149 |18 | |18 | |18 | |18 |18 |15 |20 | |12 | |19 | |19 |19 |10 |10 |13 | |15 | |19 | |12 |19 |10 |14 |15 | |10 | |15 | |9 |8 |11 |15 |13 | |10 | |16 | |15 |18 |12 |5 |5 |2 | | | +Ch153 |18 | |18 | |18 | |18 |18 |20 |17 | |8 | |19 | |16 |20 |13 |16 |18 | |14 | |11 | |10 |16 |16 |19 |15 | |13 | |17 | |19 |18 |19 |20 |8 | |18 | |9 | |17 |11 |11 |1 |2 |1 | | | +Ch157 |18 | |18 | |18 | |18 |18 |13 |17 | |12 | |19 | |16 |8 |17 |11 |12 | |15 | |14 | |18 |11 |12 |9 |18 | |20 | |13 | |16 |13 |20 |17 |19 | |10 | |12 | |20 |18 |16 |5 |2 |3 | | | +Ch161 |18 | |18 | |18 | |18 |18 |12 |12 | |16 | |12 | |15 |11 |18 |11 |13 | |17 | |19 | |11 |13 |13 |9 |15 | |10 | |10 | |19 |13 |20 |13 |9 | |8 | |8 | |20 |14 |12 |0 |4 |1 | | | +Ch165 |18 | |18 | |18 | |18 |18 |13 |16 | |15 | |13 | |15 |8 |19 |15 |10 | |17 | |13 | |13 |19 |20 |8 |18 | |15 | |20 | |16 |9 |14 |11 |20 | |11 | |19 | |15 |16 |8 |1 |2 |0 | | | +Ch169 |18 | |18 | |18 | |18 |18 |8 |17 | |17 | |13 | |16 |8 |14 |18 |11 | |8 | |18 | |20 |14 |8 |17 |8 | |13 | |18 | |19 |20 |19 |20 |17 | |13 | |20 | |9 |15 |18 |0 |3 |4 | | | +Ch173 |18 | |18 | |18 | |18 |18 |14 |9 | |13 | |12 | |15 |14 |15 |10 |10 | |18 | |16 | |16 |8 |13 |16 |11 | |11 | |13 | |13 |15 |12 |20 |15 | |14 | |13 | |16 |11 |14 |3 |3 |4 | | | +Ch177 |18 | |18 | |18 | |18 |18 |19 |18 | |16 | |10 | |20 |13 |11 |16 |12 | |16 | |18 | |18 |11 |18 |8 |13 | |14 | |11 | |18 |14 |16 |16 |19 | |16 | |13 | |15 |8 |13 |5 |0 |0 | | | +Ch181 |18 | |18 | |18 | |18 |18 |20 |11 | |10 | |9 | |8 |9 |15 |15 |8 | |8 | |12 | |11 |9 |18 |20 |11 | |17 | |11 | |8 |15 |8 |18 |12 | |18 | |16 | |19 |9 |14 |4 |1 |4 | | | + | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | diff --git a/package/mtk/drivers/mt_wifi/files/mt7615e-sku.dat b/package/mtk/drivers/mt_wifi/files/mt7615e-sku.dat new file mode 100644 index 000000000..be9c0d353 --- /dev/null +++ b/package/mtk/drivers/mt_wifi/files/mt7615e-sku.dat @@ -0,0 +1,65 @@ +# Single SKU Max Power Table | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +# 2.4G Channel |CCK | | | |OFDM | | | | | | | |VHT20 | | | | | | | | | |VHT40 | | | | | | | | | |Txstream_Delta | | | | | | | | | | | | | | | | | | | | | +Band: 2.4G |CCK_1M |CCK_2M |CCK_5.5M |CCK_11M |OFDM_6M |OFDM_9M |OFDM_12M |OFDM_18M |OFDM_24M |OFDM_36M |OFDM_48M |OFDM_54M |VHT20_MCS0 |VHT20_MCS1 |VHT20_MCS2 |VHT20_MCS3 |VHT20_MCS4 |VHT20_MCS5 |VHT20_MCS6 |VHT20_MCS7 |VHT20_MCS8 |VHT20_MCS9 |VHT40_MCS0 |VHT40_MCS1 |VHT40_MCS2 |VHT40_MCS3 |VHT40_MCS4 |VHT40_MCS5 |VHT40_MCS6 |VHT40_MCS7 |VHT40_MCS8 |VHT40_MCS9 |Txstream_3T |Txstream_2T |Txstream_1T | | | | | | | | | | | | | | | | | | | +Ch1 |8 | |8 | |8 | |8 | |8 | |8 |8 |10 |8 | |8 | |8 | |20 |12 |18 |16 |8 | |8 | |8 | |9 |11 |12 |2 |1 |3 | | | | | | | | | | | | | | | | | | | +Ch2 |8 | |8 | |8 | |8 | |8 | |8 |8 |15 |8 | |8 | |8 | |19 |19 |10 |12 |8 | |8 | |8 | |9 |16 |12 |5 |4 |0 | | | | | | | | | | | | | | | | | | | +Ch3 |8 | |8 | |8 | |8 | |8 | |8 |8 |18 |8 | |8 | |8 | |17 |18 |16 |20 |8 | |8 | |8 | |12 |8 |20 |0 |2 |0 | | | | | | | | | | | | | | | | | | | +Ch4 |8 | |8 | |8 | |8 | |8 | |8 |8 |9 |8 | |8 | |8 | |14 |10 |14 |18 |8 | |8 | |8 | |14 |12 |10 |3 |4 |5 | | | | | | | | | | | | | | | | | | | +Ch5 |8 | |8 | |8 | |8 | |8 | |8 |8 |10 |8 | |8 | |8 | |10 |13 |11 |8 |8 | |8 | |8 | |12 |8 |9 |4 |5 |3 | | | | | | | | | | | | | | | | | | | +Ch6 |8 | |8 | |8 | |8 | |8 | |8 |8 |13 |8 | |8 | |8 | |11 |9 |12 |16 |8 | |8 | |8 | |9 |17 |11 |5 |2 |1 | | | | | | | | | | | | | | | | | | | +Ch7 |8 | |8 | |8 | |8 | |8 | |8 |8 |10 |8 | |8 | |8 | |14 |11 |13 |18 |8 | |8 | |8 | |16 |13 |10 |2 |5 |4 | | | | | | | | | | | | | | | | | | | +Ch8 |8 | |8 | |8 | |8 | |8 | |8 |8 |15 |8 | |8 | |8 | |14 |9 |11 |10 |8 | |8 | |8 | |11 |14 |8 |5 |5 |3 | | | | | | | | | | | | | | | | | | | +Ch9 |8 | |8 | |8 | |8 | |8 | |8 |8 |11 |8 | |8 | |8 | |12 |9 |15 |19 |8 | |8 | |8 | |14 |20 |12 |2 |5 |3 | | | | | | | | | | | | | | | | | | | +Ch10 |8 | |8 | |8 | |8 | |8 | |8 |8 |14 |8 | |8 | |8 | |17 |14 |17 |15 |8 | |8 | |8 | |9 |17 |8 |2 |4 |2 | | | | | | | | | | | | | | | | | | | +Ch11 |8 | |8 | |8 | |8 | |8 | |8 |8 |14 |8 | |8 | |8 | |20 |10 |20 |18 |8 | |8 | |8 | |12 |8 |20 |3 |1 |4 | | | | | | | | | | | | | | | | | | | +Ch12 |8 | |8 | |8 | |8 | |8 | |8 |8 |18 |8 | |8 | |8 | |20 |16 |17 |9 |8 | |8 | |8 | |11 |20 |9 |0 |0 |1 | | | | | | | | | | | | | | | | | | | +Ch13 |8 | |8 | |8 | |8 | |8 | |8 |8 |8 |8 | |8 | |8 | |11 |16 |19 |16 |8 | |8 | |8 | |15 |12 |12 |2 |0 |2 | | | | | | | | | | | | | | | | | | | +Ch14 |8 | |8 | |8 | |8 | |8 | |8 |8 |10 |8 | |8 | |8 | |15 |17 |16 |14 |8 | |8 | |8 | |12 |14 |20 |4 |1 |5 | | | | | | | | | | | | | | | | | | | + | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +# 5G Channel |OFDM | | | | | | | |VHT20 | | | | | | | | | |VHT40 | | | | | | | | | |VHT80 | | | | | | | | | |VHT160 | | | | | | | | | |Txstream_Delta | | | | | +Band: 5G |OFDM_6M |OFDM_9M |OFDM_12M |OFDM_18M |OFDM_24M |OFDM_36M |OFDM_48M |OFDM_54M |VHT20_MCS0 |VHT20_MCS1 |VHT20_MCS2 |VHT20_MCS3 |VHT20_MCS4 |VHT20_MCS5 |VHT20_MCS6 |VHT20_MCS7 |VHT20_MCS8 |VHT20_MCS9 |VHT40_MCS0 |VHT40_MCS1 |VHT40_MCS2 |VHT40_MCS3 |VHT40_MCS4 |VHT40_MCS5 |VHT40_MCS6 |VHT40_MCS7 |VHT40_MCS8 |VHT40_MCS9 |VHT80_MCS0 |VHT80_MCS1 |VHT80_MCS2 |VHT80_MCS3 |VHT80_MCS4 |VHT80_MCS5 |VHT80_MCS6 |VHT80_MCS7 |VHT80_MCS8 |VHT80_MCS9 |VHT160_MCS0 |VHT160_MCS1 |VHT160_MCS2 |VHT160_MCS3 |VHT160_MCS4 |VHT160_MCS5 |VHT160_MCS6 |VHT160_MCS7 |VHT160_MCS8 |VHT160_MCS9 |Txstream_3T |Txstream_2T |Txstream_1T | | | +Ch184 |18 | |18 | |18 | |18 |18 |15 |18 | |12 | |13 | |11 |14 |16 |16 |12 | |12 | |13 | |20 |17 |16 |17 |18 | |9 | |16 | |17 |20 |18 |16 |19 | |15 | |9 | |17 |8 |17 |0 |4 |4 | | | +Ch188 |18 | |18 | |18 | |18 |18 |16 |20 | |9 | |9 | |11 |8 |12 |18 |15 | |11 | |11 | |14 |8 |17 |16 |16 | |16 | |12 | |8 |13 |19 |18 |11 | |9 | |12 | |14 |8 |13 |5 |2 |0 | | | +Ch192 |18 | |18 | |18 | |18 |18 |15 |9 | |11 | |9 | |15 |14 |11 |19 |15 | |8 | |18 | |20 |20 |8 |9 |9 | |9 | |11 | |18 |13 |14 |20 |18 | |10 | |14 | |12 |13 |16 |0 |2 |0 | | | +Ch196 |18 | |18 | |18 | |18 |18 |10 |11 | |19 | |13 | |12 |11 |10 |13 |11 | |19 | |10 | |16 |20 |15 |15 |8 | |14 | |8 | |18 |20 |15 |17 |17 | |14 | |12 | |12 |8 |16 |4 |3 |2 | | | +Ch8 |18 | |18 | |18 | |18 |18 |18 |13 | |19 | |20 | |18 |10 |9 |8 |8 | |17 | |15 | |17 |9 |18 |19 |11 | |12 | |15 | |20 |12 |12 |13 |9 | |9 | |15 | |10 |11 |17 |4 |3 |3 | | | +Ch12 |18 | |18 | |18 | |18 |18 |17 |20 | |14 | |10 | |10 |16 |15 |13 |11 | |15 | |16 | |17 |11 |15 |9 |18 | |8 | |20 | |19 |11 |9 |20 |8 | |18 | |8 | |8 |18 |18 |1 |3 |4 | | | +Ch16 |18 | |18 | |18 | |18 |18 |10 |18 | |18 | |8 | |19 |8 |12 |19 |16 | |19 | |18 | |16 |19 |12 |18 |18 | |9 | |10 | |18 |20 |20 |20 |9 | |11 | |20 | |17 |14 |16 |2 |2 |2 | | | +Ch36 |18 | |18 | |18 | |18 |18 |18 |19 | |8 | |11 | |16 |10 |9 |19 |11 | |19 | |9 | |8 |19 |8 |11 |17 | |20 | |14 | |9 |19 |19 |20 |13 | |12 | |19 | |13 |17 |9 |5 |1 |2 | | | +Ch40 |18 | |18 | |18 | |18 |18 |13 |20 | |13 | |19 | |16 |11 |14 |17 |17 | |14 | |8 | |13 |8 |10 |20 |10 | |9 | |14 | |11 |14 |17 |9 |20 | |15 | |19 | |9 |8 |11 |3 |1 |1 | | | +Ch44 |18 | |18 | |18 | |18 |18 |10 |14 | |19 | |20 | |17 |16 |12 |18 |8 | |17 | |18 | |15 |19 |14 |11 |13 | |14 | |12 | |16 |16 |19 |13 |14 | |19 | |14 | |20 |20 |11 |5 |1 |0 | | | +Ch48 |18 | |18 | |18 | |18 |18 |8 |12 | |12 | |19 | |11 |8 |11 |20 |12 | |12 | |11 | |15 |16 |10 |12 |16 | |11 | |15 | |18 |19 |17 |16 |17 | |11 | |8 | |10 |16 |16 |5 |5 |0 | | | +Ch52 |18 | |18 | |18 | |18 |18 |15 |12 | |15 | |20 | |9 |10 |10 |14 |8 | |20 | |10 | |16 |17 |18 |11 |16 | |17 | |10 | |17 |12 |13 |17 |17 | |13 | |18 | |18 |20 |13 |4 |3 |4 | | | +Ch56 |18 | |18 | |18 | |18 |18 |13 |16 | |15 | |13 | |15 |20 |13 |14 |11 | |10 | |20 | |10 |8 |16 |12 |10 | |16 | |11 | |9 |11 |14 |17 |12 | |17 | |13 | |18 |10 |19 |0 |3 |3 | | | +Ch60 |18 | |18 | |18 | |18 |18 |14 |11 | |8 | |20 | |13 |16 |13 |11 |20 | |9 | |17 | |16 |11 |8 |12 |17 | |15 | |8 | |16 |10 |20 |19 |15 | |13 | |9 | |17 |18 |11 |4 |1 |2 | | | +Ch64 |18 | |18 | |18 | |18 |18 |13 |14 | |8 | |12 | |17 |8 |12 |18 |17 | |17 | |14 | |18 |8 |8 |20 |17 | |16 | |20 | |9 |15 |11 |10 |11 | |18 | |10 | |10 |15 |19 |2 |1 |4 | | | +Ch68 |18 | |18 | |18 | |18 |18 |14 |19 | |17 | |9 | |18 |19 |20 |12 |14 | |8 | |14 | |20 |20 |18 |9 |18 | |11 | |19 | |19 |10 |11 |8 |18 | |9 | |8 | |16 |11 |8 |3 |3 |1 | | | +Ch72 |18 | |18 | |18 | |18 |18 |19 |13 | |20 | |11 | |16 |9 |19 |20 |19 | |14 | |8 | |9 |17 |13 |19 |15 | |8 | |9 | |19 |14 |19 |15 |18 | |16 | |12 | |13 |15 |10 |4 |3 |1 | | | +Ch76 |18 | |18 | |18 | |18 |18 |17 |13 | |16 | |20 | |16 |8 |9 |20 |11 | |17 | |11 | |8 |18 |9 |20 |9 | |17 | |16 | |11 |11 |11 |18 |10 | |13 | |W | |20 |17 |8 |1 |3 |3 | | | +Ch80 |18 | |18 | |18 | |18 |18 |14 |20 | |13 | |13 | |17 |8 |10 |16 |8 | |9 | |19 | |16 |17 |17 |19 |15 | |9 | |13 | |16 |13 |14 |12 |9 | |20 | |20 | |14 |18 |18 |0 |4 |2 | | | +Ch84 |18 | |18 | |18 | |18 |18 |11 |18 | |20 | |9 | |13 |14 |11 |16 |15 | |12 | |11 | |9 |19 |13 |11 |11 | |9 | |15 | |16 |18 |13 |12 |8 | |8 | |8 | |10 |12 |15 |3 |2 |5 | | | +Ch88 |18 | |18 | |18 | |18 |18 |18 |19 | |9 | |17 | |15 |8 |19 |11 |11 | |14 | |9 | |14 |20 |20 |11 |11 | |15 | |12 | |14 |11 |8 |18 |15 | |19 | |18 | |12 |20 |16 |5 |5 |1 | | | +Ch92 |18 | |18 | |18 | |18 |18 |11 |8 | |15 | |13 | |13 |13 |13 |16 |14 | |14 | |9 | |9 |15 |20 |11 |17 | |10 | |14 | |13 |17 |11 |8 |18 | |20 | |8 | |10 |19 |18 |1 |4 |4 | | | +Ch96 |18 | |18 | |18 | |18 |18 |8 |12 | |16 | |9 | |13 |12 |9 |8 |11 | |8 | |8 | |19 |11 |15 |16 |8 | |11 | |16 | |18 |16 |9 |19 |9 | |10 | |15 | |19 |19 |15 |4 |2 |4 | | | +Ch100 |18 | |18 | |18 | |18 |18 |18 |13 | |20 | |20 | |12 |9 |19 |10 |9 | |14 | |8 | |19 |10 |17 |9 |10 | |10 | |8 | |13 |12 |11 |20 |11 | |16 | |18 | |14 |16 |19 |1 |1 |2 | | | +Ch104 |18 | |18 | |18 | |18 |18 |19 |12 | |20 | |14 | |16 |15 |9 |19 |11 | |15 | |11 | |12 |18 |15 |11 |15 | |19 | |10 | |14 |15 |19 |9 |13 | |19 | |13 | |11 |11 |17 |2 |2 |0 | | | +Ch108 |18 | |18 | |18 | |18 |18 |18 |15 | |13 | |16 | |11 |19 |19 |18 |19 | |12 | |17 | |8 |9 |10 |8 |8 | |18 | |8 | |10 |11 |17 |15 |10 | |19 | |13 | |16 |10 |15 |0 |2 |3 | | | +Ch112 |18 | |18 | |18 | |18 |18 |8 |13 | |9 | |17 | |9 |15 |17 |10 |19 | |9 | |19 | |11 |16 |14 |16 |8 | |18 | |13 | |16 |13 |17 |19 |11 | |8 | |8 | |18 |14 |17 |5 |2 |5 | | | +Ch116 |18 | |18 | |18 | |18 |18 |8 |20 | |11 | |15 | |8 |11 |8 |18 |15 | |13 | |17 | |14 |13 |9 |8 |14 | |14 | |11 | |9 |19 |17 |11 |11 | |8 | |20 | |8 |10 |20 |5 |2 |1 | | | +Ch120 |18 | |18 | |18 | |18 |18 |14 |20 | |8 | |20 | |14 |10 |10 |17 |12 | |16 | |20 | |10 |20 |17 |18 |9 | |15 | |14 | |17 |13 |14 |16 |8 | |18 | |10 | |15 |12 |12 |1 |5 |3 | | | +Ch124 |18 | |18 | |18 | |18 |18 |20 |9 | |17 | |12 | |12 |8 |14 |8 |8 | |20 | |17 | |16 |20 |13 |14 |16 | |10 | |14 | |20 |15 |17 |8 |10 | |13 | |13 | |11 |13 |9 |5 |0 |5 | | | +Ch128 |18 | |18 | |18 | |18 |18 |9 |19 | |9 | |14 | |8 |14 |11 |9 |14 | |16 | |15 | |14 |10 |15 |14 |14 | |20 | |10 | |16 |15 |11 |12 |13 | |13 | |13 | |12 |15 |20 |1 |4 |3 | | | +Ch132 |18 | |18 | |18 | |18 |18 |20 |16 | |13 | |8 | |18 |11 |20 |12 |11 | |11 | |14 | |12 |13 |8 |12 |13 | |10 | |20 | |19 |12 |13 |14 |12 | |11 | |19 | |19 |20 |8 |3 |1 |4 | | | +Ch136 |18 | |18 | |18 | |18 |18 |12 |12 | |19 | |10 | |20 |10 |8 |17 |8 | |12 | |10 | |10 |13 |13 |12 |8 | |11 | |18 | |14 |12 |17 |8 |14 | |14 | |9 | |11 |18 |14 |1 |2 |2 | | | +Ch140 |18 | |18 | |18 | |18 |18 |12 |10 | |13 | |9 | |16 |8 |20 |10 |17 | |8 | |15 | |13 |20 |15 |10 |18 | |13 | |12 | |12 |16 |18 |12 |17 | |10 | |16 | |11 |15 |14 |3 |2 |5 | | | +Ch144 |18 | |18 | |18 | |18 |18 |19 |9 | |15 | |8 | |13 |18 |17 |9 |19 | |16 | |11 | |20 |12 |15 |19 |10 | |17 | |15 | |17 |14 |9 |9 |13 | |17 | |16 | |10 |9 |10 |1 |5 |2 | | | +Ch149 |18 | |18 | |18 | |18 |18 |15 |20 | |12 | |19 | |19 |19 |10 |10 |13 | |15 | |19 | |12 |19 |10 |14 |15 | |10 | |15 | |9 |8 |11 |15 |13 | |10 | |16 | |15 |18 |12 |5 |5 |2 | | | +Ch153 |18 | |18 | |18 | |18 |18 |20 |17 | |8 | |19 | |16 |20 |13 |16 |18 | |14 | |11 | |10 |16 |16 |19 |15 | |13 | |17 | |19 |18 |19 |20 |8 | |18 | |9 | |17 |11 |11 |1 |2 |1 | | | +Ch157 |18 | |18 | |18 | |18 |18 |13 |17 | |12 | |19 | |16 |8 |17 |11 |12 | |15 | |14 | |18 |11 |12 |9 |18 | |20 | |13 | |16 |13 |20 |17 |19 | |10 | |12 | |20 |18 |16 |5 |2 |3 | | | +Ch161 |18 | |18 | |18 | |18 |18 |12 |12 | |16 | |12 | |15 |11 |18 |11 |13 | |17 | |19 | |11 |13 |13 |9 |15 | |10 | |10 | |19 |13 |20 |13 |9 | |8 | |8 | |20 |14 |12 |0 |4 |1 | | | +Ch165 |18 | |18 | |18 | |18 |18 |13 |16 | |15 | |13 | |15 |8 |19 |15 |10 | |17 | |13 | |13 |19 |20 |8 |18 | |15 | |20 | |16 |9 |14 |11 |20 | |11 | |19 | |15 |16 |8 |1 |2 |0 | | | +Ch169 |18 | |18 | |18 | |18 |18 |8 |17 | |17 | |13 | |16 |8 |14 |18 |11 | |8 | |18 | |20 |14 |8 |17 |8 | |13 | |18 | |19 |20 |19 |20 |17 | |13 | |20 | |9 |15 |18 |0 |3 |4 | | | +Ch173 |18 | |18 | |18 | |18 |18 |14 |9 | |13 | |12 | |15 |14 |15 |10 |10 | |18 | |16 | |16 |8 |13 |16 |11 | |11 | |13 | |13 |15 |12 |20 |15 | |14 | |13 | |16 |11 |14 |3 |3 |4 | | | +Ch177 |18 | |18 | |18 | |18 |18 |19 |18 | |16 | |10 | |20 |13 |11 |16 |12 | |16 | |18 | |18 |11 |18 |8 |13 | |14 | |11 | |18 |14 |16 |16 |19 | |16 | |13 | |15 |8 |13 |5 |0 |0 | | | +Ch181 |18 | |18 | |18 | |18 |18 |20 |11 | |10 | |9 | |8 |9 |15 |15 |8 | |8 | |12 | |11 |9 |18 |20 |11 | |17 | |11 | |8 |15 |8 |18 |12 | |18 | |16 | |19 |9 |14 |4 |1 |4 | | | + | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | diff --git a/package/mtk/drivers/mt_wifi/files/mt7615e.1.dat b/package/mtk/drivers/mt_wifi/files/mt7615e.1.dat new file mode 100644 index 000000000..f58d6ba52 --- /dev/null +++ b/package/mtk/drivers/mt_wifi/files/mt7615e.1.dat @@ -0,0 +1,410 @@ +#The word of "Default" must not be removed +Default +AccessControlList0= +AccessControlList1= +AccessControlList10= +AccessControlList11= +AccessControlList12= +AccessControlList13= +AccessControlList14= +AccessControlList15= +AccessControlList2= +AccessControlList3= +AccessControlList4= +AccessControlList5= +AccessControlList6= +AccessControlList7= +AccessControlList8= +AccessControlList9= +AccessPolicy0=0 +AccessPolicy1=0 +AccessPolicy10=0 +AccessPolicy11=0 +AccessPolicy12=0 +AccessPolicy13=0 +AccessPolicy14=0 +AccessPolicy15=0 +AccessPolicy2=0 +AccessPolicy3=0 +AccessPolicy4=0 +AccessPolicy5=0 +AccessPolicy6=0 +AccessPolicy7=0 +AccessPolicy8=0 +AccessPolicy9=0 +AckPolicy=0;0;0;0 +APACM=0;0;0;0 +APAifsn=3;7;1;1 +ApCliAuthMode= +ApCliBssid= +ApCliDefaultKeyID= +ApCliEnable= +ApCliKey1Str= +ApCliKey1Str1= +ApCliKey1Type= +ApCliKey2Str= +ApCliKey2Str1= +ApCliKey2Type= +ApCliKey3Str= +ApCliKey3Str1= +ApCliKey3Type= +ApCliKey4Str= +ApCliKey4Str1= +ApCliKey4Type= +ApCliSsid= +ApCliWirelessMode= +ApCliWPAPSK= +ApCliWPAPSK1= +APCwmax=6;10;4;3 +APCwmin=4;4;3;2 +APSDCapable=1 +APTxop=0;0;94;47 +AuthMode=OPEN +AutoChannelSelect=3 +AutoChannelSkipList= +AutoProvisionEn=0 +BandSteering=0 +BasicRate=15 +BeaconPeriod=100 +BFBACKOFFenable=0 +BgndScanSkipCh= +BGProtection=0 +BndStrgBssIdx= +BSSACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmax=10;10;4;3 +BSSCwmin=4;4;3;2 +BssidNum=1 +BSSTxop=0;0;94;47 +BW_Enable=0 +BW_Guarantee_Rate= +BW_Maximum_Rate= +BW_Priority= +BW_Root=0 +CalCacheApply=0 +CarrierDetect=0 +Channel=0 +ChannelGrp= +CountryCode=US +CountryRegion=5 +CountryRegionABand=7 +CP_SUPPORT=2 +CSPeriod=6 +DBDC_MODE=0 +DebugFlags=0 +DefaultKeyID=1 +DfsCalibration=0 +DfsEnable=0 +DfsFalseAlarmPrevent=1 +DfsZeroWait=0 +DfsZeroWaitCacTime=255 +DisableOLBC=0 +DtimPeriod=1 +E2pAccessMode=2 +EAPifname=br-lan +EDCCAEnable=1 +EncrypType=NONE +EthConvertMode=dongle +EtherTrafficBand=0 +Ethifname= +ETxBfEnCond=1 +FineAGC=0 +FixedTxMode= +ForceRoamSupport= +FragThreshold=2346 +FreqDelta=0 +FtSupport=0 +GreenAP=1 +G_BAND_256QAM=1 +HideSSID=0 +HT_AMSDU=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_BAWinSize=64 +HT_BSSCoexistence=1 +HT_BW=1 +HT_DisallowTKIP=1 +HT_EXTCHA=1 +HT_GI=1 +HT_HTC=1 +HT_LDPC=1 +HT_LinkAdapt=0 +HT_MCS=33 +HT_MpduDensity=5 +HT_OpMode=0 +HT_PROTECT=1 +HT_RDG=0 +HT_RxStream=4 +HT_STBC=1 +HT_TxStream=4 +IcapMode=0 +idle_timeout_interval=0 +IEEE80211H=1 +IEEE8021X=0 +IgmpSnEnable=0 +ITxBfEn=1 +Key1Str= +Key1Str1= +Key1Str10= +Key1Str11= +Key1Str12= +Key1Str13= +Key1Str14= +Key1Str15= +Key1Str16= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key1Str9= +Key1Type=0 +Key2Str= +Key2Str1= +Key2Str10= +Key2Str11= +Key2Str12= +Key2Str13= +Key2Str14= +Key2Str15= +Key2Str16= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key2Str9= +Key2Type=0 +Key3Str= +Key3Str1= +Key3Str10= +Key3Str11= +Key3Str12= +Key3Str13= +Key3Str14= +Key3Str15= +Key3Str16= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key3Str9= +Key3Type=0 +Key4Str= +Key4Str1= +Key4Str10= +Key4Str11= +Key4Str12= +Key4Str13= +Key4Str14= +Key4Str15= +Key4Str16= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +Key4Str9= +Key4Type=0 +LinkTestSupport=0 +MACRepeaterEn= +MACRepeaterOuiMode=2 +MeshAuthMode= +MeshAutoLink=0 +MeshDefaultkey=0 +MeshEncrypType= +MeshId= +MeshWEPKEY= +MeshWPAKEY= +MUTxRxEnable=0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +own_ip_addr=192.168.1.1 +PcieAspm=0 +PERCENTAGEenable=0 +PhyRateLimit=0 +PMFMFPC=1 +PMFMFPR=0 +PMFSHA256=0 +PMKCachePeriod=10 +PowerUpCckOfdm=0:0:0:0:0:0:0 +PowerUpHT20=0:0:0:0:0:0:0 +PowerUpHT40=0:0:0:0:0:0:0 +PowerUpVHT160=0:0:0:0:0:0:0 +PowerUpVHT20=0:0:0:0:0:0:0 +PowerUpVHT40=0:0:0:0:0:0:0 +PowerUpVHT80=0:0:0:0:0:0:0 +PreAntSwitch= +PreAuth=0 +PreAuthifname=br-lan +RadioLinkSelection=0 +RadioOn=1 +RADIUS_Acct_Key= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Server= +RADIUS_Key1= +RADIUS_Key10= +RADIUS_Key11= +RADIUS_Key12= +RADIUS_Key13= +RADIUS_Key14= +RADIUS_Key15= +RADIUS_Key16= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Key9= +RADIUS_Port=1812 +RADIUS_Server=0 +RDRegion= +RED_Enable=1 +RekeyInterval=3600 +RekeyMethod=DISABLE +RRMEnable=0 +RTSThreshold=2347 +session_timeout_interval=0 +ShortSlot=1 +SKUenable=0 +SSID= +SSID1=WITHUSP-5.0 +SSID10= +SSID11= +SSID12= +SSID13= +SSID14= +SSID15= +SSID16= +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +SSID9= +StationKeepAlive=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +TGnWifiTest=0 +ThermalRecal=0 +TxBurst=1 +TxPower=100 +TxPreamble=1 +VHT_BW=1 +VHT_BW_SIGNAL=0 +VHT_LDPC=1 +VHT_Sec80_Channel=0 +VHT_SGI=1 +VHT_STBC=1 +VLANID=0 +VLANPriority=0 +VLANTag=0 +VOW_Airtime_Ctrl_En=0 +VOW_Airtime_Fairness_En=1 +VOW_BW_Ctrl=0 +VOW_Group_Backlog= +VOW_Group_DWRR_Max_Wait_Time= +VOW_Group_DWRR_Quantum= +VOW_Group_Max_Airtime_Bucket_Size= +VOW_Group_Max_Rate= +VOW_Group_Max_Rate_Bucket_Size= +VOW_Group_Max_Ratio= +VOW_Group_Max_Wait_Time= +VOW_Group_Min_Airtime_Bucket_Size= +VOW_Group_Min_Rate= +VOW_Group_Min_Rate_Bucket_Size= +VOW_Group_Min_Ratio= +VOW_Rate_Ctrl_En=0 +VOW_Refill_Period= +VOW_RX_En=1 +VOW_Sta_BE_DWRR_Quantum= +VOW_Sta_BK_DWRR_Quantum= +VOW_Sta_DWRR_Max_Wait_Time= +VOW_Sta_VI_DWRR_Quantum= +VOW_Sta_VO_DWRR_Quantum= +VOW_WATF_Enable= +VOW_WATF_MAC_LV0= +VOW_WATF_MAC_LV1= +VOW_WATF_MAC_LV2= +VOW_WATF_MAC_LV3= +VOW_WATF_Q_LV0= +VOW_WATF_Q_LV1= +VOW_WATF_Q_LV2= +VOW_WATF_Q_LV3= +VOW_WMM_Search_Rule_Band0= +VOW_WMM_Search_Rule_Band1= +WapiAsCertPath= +WapiAsIpAddr= +WapiAsPort= +Wapiifname= +WapiPsk1= +WapiPsk10= +WapiPsk11= +WapiPsk12= +WapiPsk13= +WapiPsk14= +WapiPsk15= +WapiPsk16= +WapiPsk2= +WapiPsk3= +WapiPsk4= +WapiPsk5= +WapiPsk6= +WapiPsk7= +WapiPsk8= +WapiPsk9= +WapiPskType= +WapiUserCertPath= +WCNTest=0 +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +WdsEnable=0 +WdsEncrypType=NONE +WdsList= +WdsPhyMode=0 +WHNAT=1 +WiFiTest=0 +WirelessMode=14 +WmmCapable=1 +WPAPSK= +WPAPSK1=12345678 +WPAPSK10= +WPAPSK11= +WPAPSK12= +WPAPSK13= +WPAPSK14= +WPAPSK15= +WPAPSK16= +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +WPAPSK9= +WscConfMode=0 +WscConfStatus=2 +WEP1Type1=0 +WEP2Type1=0 +WEP3Type1=0 +WEP4Type1=0 +WPSRadio=0 diff --git a/package/mtk/drivers/mt_wifi/files/mt7615e.2.dat b/package/mtk/drivers/mt_wifi/files/mt7615e.2.dat new file mode 100644 index 000000000..56f39e1e9 --- /dev/null +++ b/package/mtk/drivers/mt_wifi/files/mt7615e.2.dat @@ -0,0 +1,412 @@ +#The word of "Default" must not be removed +Default +AccessControlList0= +AccessControlList1= +AccessControlList10= +AccessControlList11= +AccessControlList12= +AccessControlList13= +AccessControlList14= +AccessControlList15= +AccessControlList2= +AccessControlList3= +AccessControlList4= +AccessControlList5= +AccessControlList6= +AccessControlList7= +AccessControlList8= +AccessControlList9= +AccessPolicy0=0 +AccessPolicy1=0 +AccessPolicy10=0 +AccessPolicy11=0 +AccessPolicy12=0 +AccessPolicy13=0 +AccessPolicy14=0 +AccessPolicy15=0 +AccessPolicy2=0 +AccessPolicy3=0 +AccessPolicy4=0 +AccessPolicy5=0 +AccessPolicy6=0 +AccessPolicy7=0 +AccessPolicy8=0 +AccessPolicy9=0 +AckPolicy=0;0;0;0 +APACM=0;0;0;0 +APAifsn=3;7;1;1 +ApCliAuthMode= +ApCliBssid= +ApCliDefaultKeyID= +ApCliEnable= +ApCliEncrypType= +ApCliKey1Str= +ApCliKey1Str1= +ApCliKey1Type= +ApCliKey2Str= +ApCliKey2Str1= +ApCliKey2Type= +ApCliKey3Str= +ApCliKey3Str1= +ApCliKey3Type= +ApCliKey4Str= +ApCliKey4Str1= +ApCliKey4Type= +ApCliSsid= +ApCliWirelessMode= +ApCliWPAPSK= +ApCliWPAPSK1= +APCwmax=6;10;4;3 +APCwmin=4;4;3;2 +APSDCapable=1 +APTxop=0;0;94;47 +AuthMode=OPEN +AutoChannelSelect=3 +AutoChannelSkipList= +AutoProvisionEn=0 +BandSteering=0 +BasicRate=15 +BeaconPeriod=100 +BFBACKOFFenable=0 +BgndScanSkipCh= +BGProtection=0 +BndStrgBssIdx= +BSSACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmax=10;10;4;3 +BSSCwmin=4;4;3;2 +BssidNum=1 +BSSTxop=0;0;94;47 +BW_Enable=0 +BW_Guarantee_Rate= +BW_Maximum_Rate= +BW_Priority= +BW_Root=0 +CalCacheApply=0 +CarrierDetect=0 +Channel=0 +ChannelGrp= +CountryCode=US +CountryRegion=5 +CountryRegionABand=7 +CP_SUPPORT=2 +CSPeriod=6 +DBDC_MODE=0 +DebugFlags=0 +DefaultKeyID=1 +DfsCalibration=0 +DfsEnable=0 +DfsFalseAlarmPrevent=1 +DfsZeroWait=0 +DfsZeroWaitCacTime=255 +DisableOLBC=0 +DtimPeriod=1 +E2pAccessMode=1 +EAPifname=br-lan +EDCCAEnable=1 +EncrypType=NONE +EthConvertMode=dongle +EtherTrafficBand=0 +Ethifname= +ETxBfEnCond=1 +FineAGC=0 +FixedTxMode= +ForceRoamSupport= +FragThreshold=2346 +FreqDelta=0 +FtSupport=0 +GreenAP=1 +G_BAND_256QAM=1 +HideSSID=0 +HT_AMSDU=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_BAWinSize=64 +HT_BSSCoexistence=1 +HT_BW=1 +HT_DisallowTKIP=1 +HT_EXTCHA=1 +HT_GI=1 +HT_HTC=1 +HT_LDPC=1 +HT_LinkAdapt=0 +HT_MCS=33 +HT_MpduDensity=5 +HT_OpMode=0 +HT_PROTECT=1 +HT_RDG=0 +HT_RxStream=4 +HT_STBC=1 +HT_TxStream=4 +IcapMode=0 +idle_timeout_interval=0 +IEEE80211H=1 +IEEE8021X=0 +IgmpSnEnable=0 +ITxBfEn=1 +Key1Str= +Key1Str1= +Key1Str10= +Key1Str11= +Key1Str12= +Key1Str13= +Key1Str14= +Key1Str15= +Key1Str16= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key1Str9= +Key1Type=0 +Key2Str= +Key2Str1= +Key2Str10= +Key2Str11= +Key2Str12= +Key2Str13= +Key2Str14= +Key2Str15= +Key2Str16= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key2Str9= +Key2Type=0 +Key3Str= +Key3Str1= +Key3Str10= +Key3Str11= +Key3Str12= +Key3Str13= +Key3Str14= +Key3Str15= +Key3Str16= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key3Str9= +Key3Type=0 +Key4Str= +Key4Str1= +Key4Str10= +Key4Str11= +Key4Str12= +Key4Str13= +Key4Str14= +Key4Str15= +Key4Str16= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +Key4Str9= +Key4Type=0 +LinkTestSupport=0 +MACRepeaterEn= +MACRepeaterOuiMode=2 +MeshAuthMode= +MeshAutoLink=0 +MeshDefaultkey=0 +MeshEncrypType= +MeshId= +MeshWEPKEY= +MeshWPAKEY= +MUTxRxEnable=0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +own_ip_addr=192.168.1.1 + +PcieAspm=0 +PERCENTAGEenable=0 +PhyRateLimit=0 +PMFMFPC=1 +PMFMFPR=0 +PMFSHA256=0 +PMKCachePeriod=10 +PowerUpCckOfdm=0:0:0:0:0:0:0 +PowerUpHT20=0:0:0:0:0:0:0 +PowerUpHT40=0:0:0:0:0:0:0 +PowerUpVHT160=0:0:0:0:0:0:0 +PowerUpVHT20=0:0:0:0:0:0:0 +PowerUpVHT40=0:0:0:0:0:0:0 +PowerUpVHT80=0:0:0:0:0:0:0 +PreAntSwitch= +PreAuth=0 +PreAuthifname=br-lan +RadioLinkSelection=0 +RadioOn=1 +RADIUS_Acct_Key= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Server= +RADIUS_Key1= +RADIUS_Key10= +RADIUS_Key11= +RADIUS_Key12= +RADIUS_Key13= +RADIUS_Key14= +RADIUS_Key15= +RADIUS_Key16= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Key9= +RADIUS_Port=1812 +RADIUS_Server=0 +RDRegion= +RED_Enable=1 +RekeyInterval=3600 +RekeyMethod=DISABLE +RRMEnable=0 +RTSThreshold=2347 +session_timeout_interval=0 +ShortSlot=1 +SKUenable=0 +SSID= +SSID1=MTK_AP3 +SSID10= +SSID11= +SSID12= +SSID13= +SSID14= +SSID15= +SSID16= +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +SSID9= +StationKeepAlive=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +TGnWifiTest=0 +ThermalRecal=0 +TxBurst=1 +TxPower=100 +TxPreamble=1 +VHT_BW=1 +VHT_BW_SIGNAL=0 +VHT_LDPC=1 +VHT_Sec80_Channel=0 +VHT_SGI=1 +VHT_STBC=1 +VLANID=0 +VLANPriority=0 +VLANTag=0 +VOW_Airtime_Ctrl_En= +VOW_Airtime_Fairness_En=1 +VOW_BW_Ctrl=0 +VOW_Group_Backlog= +VOW_Group_DWRR_Max_Wait_Time= +VOW_Group_DWRR_Quantum= +VOW_Group_Max_Airtime_Bucket_Size= +VOW_Group_Max_Rate= +VOW_Group_Max_Rate_Bucket_Size= +VOW_Group_Max_Ratio= +VOW_Group_Max_Wait_Time= +VOW_Group_Min_Airtime_Bucket_Size= +VOW_Group_Min_Rate= +VOW_Group_Min_Rate_Bucket_Size= +VOW_Group_Min_Ratio= +VOW_Rate_Ctrl_En= +VOW_Refill_Period= +VOW_RX_En=1 +VOW_Sta_BE_DWRR_Quantum= +VOW_Sta_BK_DWRR_Quantum= +VOW_Sta_DWRR_Max_Wait_Time= +VOW_Sta_VI_DWRR_Quantum= +VOW_Sta_VO_DWRR_Quantum= +VOW_WATF_Enable= +VOW_WATF_MAC_LV0= +VOW_WATF_MAC_LV1= +VOW_WATF_MAC_LV2= +VOW_WATF_MAC_LV3= +VOW_WATF_Q_LV0= +VOW_WATF_Q_LV1= +VOW_WATF_Q_LV2= +VOW_WATF_Q_LV3= +VOW_WMM_Search_Rule_Band0= +VOW_WMM_Search_Rule_Band1= +WapiAsCertPath= +WapiAsIpAddr= +WapiAsPort= +Wapiifname= +WapiPsk1= +WapiPsk10= +WapiPsk11= +WapiPsk12= +WapiPsk13= +WapiPsk14= +WapiPsk15= +WapiPsk16= +WapiPsk2= +WapiPsk3= +WapiPsk4= +WapiPsk5= +WapiPsk6= +WapiPsk7= +WapiPsk8= +WapiPsk9= +WapiPskType= +WapiUserCertPath= +WCNTest=0 +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +WdsEnable=0 +WdsEncrypType=NONE +WdsList= +WdsPhyMode=0 +WHNAT=1 +WiFiTest=0 +WirelessMode=14 +WmmCapable=1 +WPAPSK= +WPAPSK1=12345678 +WPAPSK10= +WPAPSK11= +WPAPSK12= +WPAPSK13= +WPAPSK14= +WPAPSK15= +WPAPSK16= +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +WPAPSK9= +WscConfMode=0 +WscConfStatus=2 +WEP1Type1=0 +WEP2Type1=0 +WEP3Type1=0 +WEP4Type1=0 +WPSRadio=0 diff --git a/package/mtk/drivers/mt_wifi/files/mt7615e.eeprom.bin b/package/mtk/drivers/mt_wifi/files/mt7615e.eeprom.bin new file mode 100644 index 0000000000000000000000000000000000000000..32556855cee12e791cf339891a40717dc6516617 GIT binary patch literal 1024 zcmeHDI}Ut&ba9Nq+HXTwJmOFOoBJMX>8 z2Pmd&jNmnAsKzxrP>P`I+O`EWbR(s#wMJD{64qM4z!+kuv*90P zQJR`^-+>F2?hU_ZGyG}HdR*zVjH#GT`8cEpw>huRmzdV)-6r@NztH6Zf4#sPcn4O( literal 0 HcmV?d00001 diff --git a/package/mtk/drivers/mt_wifi/files/mt7615e.lua b/package/mtk/drivers/mt_wifi/files/mt7615e.lua new file mode 100644 index 000000000..e8786ed34 --- /dev/null +++ b/package/mtk/drivers/mt_wifi/files/mt7615e.lua @@ -0,0 +1,301 @@ +#!/usr/bin/lua +-- Alternative for OpenWrt's /sbin/wifi. +-- Copyright Not Reserved. +-- Hua Shao + +package.path = '/lib/wifi/?.lua;'..package.path + +local vif_prefix = {"ra", "rai", "rae", "rax", "ray", "raz", + "apcli", "apclix", "apclii", "apcliy", "apclie", "apcliz", } + +local function esc(x) + return (x:gsub('%%', '%%%%') + :gsub('^%^', '%%^') + :gsub('%$$', '%%$') + :gsub('%(', '%%(') + :gsub('%)', '%%)') + :gsub('%.', '%%.') + :gsub('%[', '%%[') + :gsub('%]', '%%]') + :gsub('%*', '%%*') + :gsub('%+', '%%+') + :gsub('%-', '%%-') + :gsub('%?', '%%?')) +end + +function add_vif_into_lan(vif) + local mtkwifi = require("mtkwifi") + local brvifs = mtkwifi.__trim( mtkwifi.read_pipe("uci get network.lan.ifname")) + if not string.match(brvifs, esc(vif)) then + nixio.syslog("debug", "add "..vif.." into lan") + -- brvifs = brvifs.." "..vif + -- os.execute("uci set network.lan.ifname=\""..brvifs.."\"") --netifd will down vif form /etc/config/network + -- os.execute("uci commit") + -- os.execute("ubus call network.interface.lan add_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + os.execute("brctl addif br-lan "..vif) -- double insurance for rare failure + end +end + +function del_vif_from_lan(vif) + local mtkwifi = require("mtkwifi") + local brvifs = mtkwifi.__trim(mtkwifi.read_pipe("uci get network.lan.ifname")) + if string.match(brvifs, esc(vif)) then + -- brvifs = mtkwifi.__trim(string.gsub(brvifs, esc(vif), "")) + nixio.syslog("debug", "del "..vif.." from lan") + -- os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + -- os.execute("uci commit") + -- os.execute("ubus call network.interface.lan remove_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + os.execute("brctl delif br-lan "..vif) + end +end + +function mt7615e_up(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + local wifi_services_exist = false + if mtkwifi.exists("/lib/wifi/wifi_services.lua") then + wifi_services_exist = require("wifi_services") + end + + nixio.syslog("debug", "mt7615e_up called!") + + local devs, l1parser = mtkwifi.__get_l1dat() + -- l1 profile present, good! + if l1parser and devs then + dev = devs.devname_ridx[devname] + if not dev then + nixio.syslog("err", "mt7615e_up: dev "..devname.." not found!") + return + end + -- we have to bring up main_ifname first, main_ifname will create all other vifs. + if mtkwifi.exists("/sys/class/net/"..dev.main_ifname) then + nixio.syslog("debug", "mt7615e_up: ifconfig "..dev.main_ifname.." up") + os.execute("ifconfig "..dev.main_ifname.." up") + add_vif_into_lan(dev.main_ifname) + if wifi_services_exist then + miniupnpd_chk(devname,dev.main_ifname,true) + end + else + nixio.syslog("err", "mt7615e_up: main_ifname "..dev.main_ifname.." missing, quit!") + return + end + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if vif ~= dev.main_ifname and + ( string.match(vif, esc(dev.ext_ifname).."[0-9]+") + or string.match(vif, esc(dev.apcli_ifname).."[0-9]+") + or string.match(vif, esc(dev.wds_ifname).."[0-9]+") + or string.match(vif, esc(dev.mesh_ifname).."[0-9]+")) + then + nixio.syslog("debug", "mt7615e_up: ifconfig "..vif.."0 up") + os.execute("ifconfig "..vif.." up") + add_vif_into_lan(vif) + if wifi_services_exist and string.match(vif, esc(dev.ext_ifname).."[0-9]+") then + miniupnpd_chk(devname,vif, true) + end + -- else nixio.syslog("debug", "mt7615e_up: skip "..vif..", prefix not match "..pre) + end + end + os.execute("iwpriv "..dev.main_ifname.." set hw_nat_register=1") + if wifi_services_exist then + d8021xd_chk(devname,dev.ext_ifname,dev.main_ifname,true) + end + elseif mtkwifi.exists("/etc/wireless/mt7615e/"..devname..".dat") then + for _, pre in ipairs(vif_prefix) do + -- we have to bring up root vif first, root vif will create all other vifs. + if mtkwifi.exists("/sys/class/net/"..pre.."0") then + nixio.syslog("debug", "mt7615e_up: ifconfig "..pre.."0 up") + os.execute("ifconfig "..pre.."0 up") + add_vif_into_lan(pre.."0") + end + + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + -- nixio.syslog("debug", "mt7615e_up: navigate "..pre) + if string.match(vif, pre.."[1-9]+") then + nixio.syslog("debug", "mt7615e_up: ifconfig "..vif.." up") + os.execute("ifconfig "..vif.." up") + add_vif_into_lan(vif) + if wifi_services_exist then + miniupnpd_chk(devname, vif, true) + end + -- else nixio.syslog("debug", "mt7615e_up: skip "..vif..", prefix not match "..pre) + end + end + if wifi_services_exist then + d8021xd_chk(devname,pre,pre.."0",true) + end + end + else nixio.syslog("debug", "mt7615e_up: skip "..devname..", config not exist") + end + + -- M.A.N service + if mtkwifi.exists("/etc/init.d/man") then + os.execute("/etc/init.d/man stop") + os.execute("/etc/init.d/man start") + end + + os.execute(" rm -rf /tmp/mtk/wifi/mt7615e*.need_reload") +end + +function mt7615e_down(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + local wifi_services_exist = false + if mtkwifi.exists("/lib/wifi/wifi_services.lua") then + wifi_services_exist = require("wifi_services") + end + + nixio.syslog("debug", "mt7615e_down called!") + + -- M.A.N service + if mtkwifi.exists("/etc/init.d/man") then + os.execute("/etc/init.d/man stop") + end + + local devs, l1parser = mtkwifi.__get_l1dat() + -- l1 profile present, good! + if l1parser and devs then + dev = devs.devname_ridx[devname] + if not dev then + nixio.syslog("err", "mt7615e_down: dev "..devname.." not found!") + return + end + os.execute("iwpriv "..dev.main_ifname.." set hw_nat_register=0") + if wifi_services_exist then + d8021xd_chk(devname,dev.ext_ifname,dev.main_ifname) + end + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if vif == dev.main_ifname + or string.match(vif, esc(dev.ext_ifname).."[0-9]+") + or string.match(vif, esc(dev.apcli_ifname).."[0-9]+") + or string.match(vif, esc(dev.wds_ifname).."[0-9]+") + or string.match(vif, esc(dev.mesh_ifname).."[0-9]+") + then + if wifi_services_exist then + if vif == dev.main_ifname + or string.match(vif, esc(dev.ext_ifname).."[0-9]+") then + miniupnpd_chk(devname,vif) + end + end + nixio.syslog("debug", "mt7615e_down: ifconfig "..vif.." down") + os.execute("ifconfig "..vif.." down") + del_vif_from_lan(vif) + -- else nixio.syslog("debug", "mt7615e_down: skip "..vif..", prefix not match "..pre) + end + end + elseif mtkwifi.exists("/etc/wireless/mt7615e/"..devname..".dat") then + for _, pre in ipairs(vif_prefix) do + if wifi_services_exist then + d8021xd_chk(devname,pre,pre.."0") + end + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, pre.."[0-9]+") then + nixio.syslog("debug", "mt7615e_down: ifconfig "..vif.."down") + os.execute("ifconfig "..vif.." down") + del_vif_from_lan(vif) + if wifi_services_exist then + miniupnpd_chk(devname,vif) + end + -- else nixio.syslog("debug", "mt7615e_down: skip "..vif..", prefix not match "..pre) + end + end + end + else nixio.syslog("debug", "mt7615e_down: skip "..devname..", config not exist") + end + + os.execute(" rm -rf /tmp/mtk/wifi/mt7615e*.need_reload") +end + +function mt7615e_reload(devname) + local nixio = require("nixio") + nixio.syslog("debug", "mt7615e_reload called!") + mt7615e_down(devname) + mt7615e_up(devname) +end + +function mt7615e_restart(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + local devs, l1parser = mtkwifi.__get_l1dat() + nixio.syslog("debug", "mt7615e_restart called!") + if devname then + local dev = devs.devname_ridx[devname] + assert(mtkwifi.exists(dev.init_script)) + local compatname = dev.init_compatible + for devname, dev in pairs(devs.devname_ridx) do + if dev.init_compatible == compatname then + mt7615e_down(devname) + end + end + else + for devname, dev in pairs(devs.devname_ridx) do + mt7615e_down(devname) + end + end + os.execute("rmmod wifi_forward") + os.execute("rmmod mt_whnat") + os.execute("rmmod mt_wifi") + os.execute("rmmod hw_nat") + os.execute("insmod /lib/modules/ralink/hw_nat.ko") + os.execute("modprobe mt_wifi") + os.execute("modprobe mt_whnat") + os.execute("modprobe wifi_forward") + if devname then + local dev = devs.devname_ridx[devname] + assert(mtkwifi.exists(dev.init_script)) + local compatname = dev.init_compatible + for devname, dev in pairs(devs.devname_ridx) do + if dev.init_compatible == compatname then + mt7615e_up(devname) + end + end + else + for devname, dev in pairs(devs.devname_ridx) do + mt7615e_up(devname) + end + end +end + +function mt7615e_reset(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7615e_reset called!") + if mtkwifi.exists("/rom/etc/wireless/mt7615e/") then + os.execute("rm -rf /etc/wireless/mt7615e/") + os.execute("cp -rf /rom/etc/wireless/mt7615e/ /etc/wireless/") + mt7615e_reload(devname) + else + nixio.syslog("debug", "mt7615e_reset: /rom"..profile.." missing, unable to reset!") + end +end + +function mt7615e_status(devname) + return wifi_common_status() +end + +function mt7615e_detect(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7615e_detect called!") + + for _,dev in ipairs(mtkwifi.get_all_devs()) do + local relname = string.format("%s%d%d",dev.maindev,dev.mainidx,dev.subidx) + print([[ +config wifi-device ]]..relname.."\n"..[[ + option type mt7615e + option vendor ralink +]]) + for _,vif in ipairs(dev.vifs) do + print([[ +config wifi-iface + option device ]]..relname.."\n"..[[ + option ifname ]]..vif.vifname.."\n"..[[ + option network lan + option mode ap + option ssid ]]..vif.__ssid.."\n") + end + end +end diff --git a/package/mtk/drivers/mt_wifi/files/mt7622.1.dat b/package/mtk/drivers/mt_wifi/files/mt7622.1.dat new file mode 100644 index 000000000..49cac22a8 --- /dev/null +++ b/package/mtk/drivers/mt_wifi/files/mt7622.1.dat @@ -0,0 +1,412 @@ +#The word of "Default" must not be removed +Default +AccessControlList0= +AccessControlList1= +AccessControlList10= +AccessControlList11= +AccessControlList12= +AccessControlList13= +AccessControlList14= +AccessControlList15= +AccessControlList2= +AccessControlList3= +AccessControlList4= +AccessControlList5= +AccessControlList6= +AccessControlList7= +AccessControlList8= +AccessControlList9= +AccessPolicy0=0 +AccessPolicy1=0 +AccessPolicy10=0 +AccessPolicy11=0 +AccessPolicy12=0 +AccessPolicy13=0 +AccessPolicy14=0 +AccessPolicy15=0 +AccessPolicy2=0 +AccessPolicy3=0 +AccessPolicy4=0 +AccessPolicy5=0 +AccessPolicy6=0 +AccessPolicy7=0 +AccessPolicy8=0 +AccessPolicy9=0 +AckPolicy=0;0;0;0 +APACM=0;0;0;0 +APAifsn=3;7;1;1 +ApCliAuthMode= +ApCliBssid= +ApCliDefaultKeyID= +ApCliEnable= +ApCliEncrypType= +ApCliKey1Str= +ApCliKey1Str1= +ApCliKey1Type= +ApCliKey2Str= +ApCliKey2Str1= +ApCliKey2Type= +ApCliKey3Str= +ApCliKey3Str1= +ApCliKey3Type= +ApCliKey4Str= +ApCliKey4Str1= +ApCliKey4Type= +ApCliSsid= +ApCliWirelessMode= +ApCliWPAPSK= +ApCliWPAPSK1= +APCwmax=6;10;4;3 +APCwmin=4;4;3;2 +APSDCapable=1 +APTxop=0;0;94;47 +AuthMode=OPEN +AutoChannelSelect=3 +AutoChannelSkipList= +AutoProvisionEn=0 +BandSteering=0 +BasicRate=15 +BeaconPeriod=100 +BFBACKOFFenable=0 +BgndScanSkipCh= +BGProtection=0 +BndStrgBssIdx= +BSSACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmax=10;10;4;3 +BSSCwmin=4;4;3;2 +BssidNum=1 +BSSTxop=0;0;94;47 +BW_Enable=0 +BW_Guarantee_Rate= +BW_Maximum_Rate= +BW_Priority= +BW_Root=0 +CalCacheApply=0 +CarrierDetect=0 +Channel=0 +ChannelGrp= +CountryCode=US +CountryRegion=5 +CountryRegionABand=7 +CP_SUPPORT=2 +CSPeriod=6 +DBDC_MODE=0 +DebugFlags=0 +DefaultKeyID=1 +DfsCalibration=0 +DfsEnable=0 +DfsFalseAlarmPrevent=1 +DfsZeroWait=0 +DfsZeroWaitCacTime=255 +DisableOLBC=0 +DtimPeriod=1 +E2pAccessMode=2 +EAPifname=br-lan +EDCCAEnable=1 +EncrypType=NONE +EthConvertMode=dongle +EtherTrafficBand=0 +Ethifname= +ETxBfEnCond=1 +FineAGC=0 +FixedTxMode= +ForceRoamSupport= +FragThreshold=2346 +FreqDelta=0 +FtSupport=0 +GreenAP=1 +G_BAND_256QAM=1 +HideSSID=0 +HT_AMSDU=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_BAWinSize=64 +HT_BSSCoexistence=1 +HT_BW=1 +HT_DisallowTKIP=1 +HT_EXTCHA=1 +HT_GI=1 +HT_HTC=1 +HT_LDPC=1 +HT_LinkAdapt=0 +HT_MCS=33 +HT_MpduDensity=5 +HT_OpMode=0 +HT_PROTECT=1 +HT_RDG=0 +HT_RxStream=4 +HT_STBC=1 +HT_TxStream=4 +IcapMode=0 +idle_timeout_interval=0 +IEEE80211H=1 +IEEE8021X=0 +IgmpSnEnable=0 +ITxBfEn=1 +Key1Str= +Key1Str1= +Key1Str10= +Key1Str11= +Key1Str12= +Key1Str13= +Key1Str14= +Key1Str15= +Key1Str16= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key1Str9= +Key1Type=0 +Key2Str= +Key2Str1= +Key2Str10= +Key2Str11= +Key2Str12= +Key2Str13= +Key2Str14= +Key2Str15= +Key2Str16= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key2Str9= +Key2Type=0 +Key3Str= +Key3Str1= +Key3Str10= +Key3Str11= +Key3Str12= +Key3Str13= +Key3Str14= +Key3Str15= +Key3Str16= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key3Str9= +Key3Type=0 +Key4Str= +Key4Str1= +Key4Str10= +Key4Str11= +Key4Str12= +Key4Str13= +Key4Str14= +Key4Str15= +Key4Str16= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +Key4Str9= +Key4Type=0 +LinkTestSupport=0 +MACRepeaterEn= +MACRepeaterOuiMode=2 +MeshAuthMode= +MeshAutoLink=0 +MeshDefaultkey=0 +MeshEncrypType= +MeshId= +MeshWEPKEY= +MeshWPAKEY= +MUTxRxEnable=0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +own_ip_addr=192.168.1.1 +PcieAspm=0 +PERCENTAGEenable=0 +PhyRateLimit=0 +PMFMFPC=1 +PMFMFPR=0 +PMFSHA256=0 +PMKCachePeriod=10 +PowerUpCckOfdm=0:0:0:0:0:0:0 +PowerUpHT20=0:0:0:0:0:0:0 +PowerUpHT40=0:0:0:0:0:0:0 +PowerUpVHT160=0:0:0:0:0:0:0 +PowerUpVHT20=0:0:0:0:0:0:0 +PowerUpVHT40=0:0:0:0:0:0:0 +PowerUpVHT80=0:0:0:0:0:0:0 +PreAntSwitch= +PreAuth=0 +PreAuthifname=br-lan +RadioLinkSelection=0 +RadioOn=1 +RADIUS_Acct_Key= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Server= +RADIUS_Key1= +RADIUS_Key10= +RADIUS_Key11= +RADIUS_Key12= +RADIUS_Key13= +RADIUS_Key14= +RADIUS_Key15= +RADIUS_Key16= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Key9= +RADIUS_Port=1812 +RADIUS_Server=0 +RDRegion= +RED_Enable=1 +RekeyInterval=3600 +RekeyMethod=DISABLE +RRMEnable=0 +RTSThreshold=2347 +session_timeout_interval=0 +ShortSlot=1 +SKUenable=0 +SSID= +SSID1=WITHUSP-2.4 +SSID10= +SSID11= +SSID12= +SSID13= +SSID14= +SSID15= +SSID16= +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +SSID9= +StationKeepAlive=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +TGnWifiTest=0 +ThermalRecal=0 +CCKTxStream=4 +TxBurst=1 +TxPower=100 +TxPreamble=1 +VHT_BW=0 +VHT_BW_SIGNAL=0 +VHT_LDPC=1 +VHT_Sec80_Channel=0 +VHT_SGI=1 +VHT_STBC=1 +VLANID=0 +VLANPriority=0 +VLANTag=0 +VOW_Airtime_Ctrl_En=0 +VOW_Airtime_Fairness_En=1 +VOW_BW_Ctrl=0 +VOW_Group_Backlog= +VOW_Group_DWRR_Max_Wait_Time= +VOW_Group_DWRR_Quantum= +VOW_Group_Max_Airtime_Bucket_Size= +VOW_Group_Max_Rate= +VOW_Group_Max_Rate_Bucket_Size= +VOW_Group_Max_Ratio= +VOW_Group_Max_Wait_Time= +VOW_Group_Min_Airtime_Bucket_Size= +VOW_Group_Min_Rate= +VOW_Group_Min_Rate_Bucket_Size= +VOW_Group_Min_Ratio= +VOW_Rate_Ctrl_En=0 +VOW_Refill_Period= +VOW_RX_En=1 +VOW_Sta_BE_DWRR_Quantum= +VOW_Sta_BK_DWRR_Quantum= +VOW_Sta_DWRR_Max_Wait_Time= +VOW_Sta_VI_DWRR_Quantum= +VOW_Sta_VO_DWRR_Quantum= +VOW_WATF_Enable= +VOW_WATF_MAC_LV0= +VOW_WATF_MAC_LV1= +VOW_WATF_MAC_LV2= +VOW_WATF_MAC_LV3= +VOW_WATF_Q_LV0= +VOW_WATF_Q_LV1= +VOW_WATF_Q_LV2= +VOW_WATF_Q_LV3= +VOW_WMM_Search_Rule_Band0= +VOW_WMM_Search_Rule_Band1= +WapiAsCertPath= +WapiAsIpAddr= +WapiAsPort= +Wapiifname= +WapiPsk1= +WapiPsk10= +WapiPsk11= +WapiPsk12= +WapiPsk13= +WapiPsk14= +WapiPsk15= +WapiPsk16= +WapiPsk2= +WapiPsk3= +WapiPsk4= +WapiPsk5= +WapiPsk6= +WapiPsk7= +WapiPsk8= +WapiPsk9= +WapiPskType= +WapiUserCertPath= +WCNTest=0 +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +WdsEnable=0 +WdsEncrypType=NONE +WdsList= +WdsPhyMode=0 +WHNAT=0 +WiFiTest=0 +WirelessMode=9 +WmmCapable=1 +WPAPSK= +WPAPSK1=12345678 +WPAPSK10= +WPAPSK11= +WPAPSK12= +WPAPSK13= +WPAPSK14= +WPAPSK15= +WPAPSK16= +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +WPAPSK9= +WscConfMode=0 +WscConfStatus=2 +WEP1Type1=0 +WEP2Type1=0 +WEP3Type1=0 +WEP4Type1=0 +WPSRadio=0 diff --git a/package/mtk/drivers/mt_wifi/files/wifi_services.lua b/package/mtk/drivers/mt_wifi/files/wifi_services.lua new file mode 100644 index 000000000..77579d39e --- /dev/null +++ b/package/mtk/drivers/mt_wifi/files/wifi_services.lua @@ -0,0 +1,98 @@ +--This file is created for check some deamons like miniupnpd,8021xd... + + local mtkwifi = require("mtkwifi") + local devs = mtkwifi.get_all_devs() + local nixio = require("nixio") + +function miniupnpd_chk(devname,vif,enable) + local WAN_IF=mtkwifi.__trim(mtkwifi.read_pipe("uci -q get network.wan.ifname")) + + os.execute("rm -rf /etc/miniupnpd.conf") + os.execute("iptables -t nat -F MINIUPNPD 1>/dev/null 2>&1") + --rmeoving the rule to MINIUPNPD + os.execute("iptables-t nat -D PREROUTING -i "..WAN_IF.." -j MINIUPNPD 1>/dev/null 2>&1") + os.execute("iptables-t nat -X MINIUPNPD 1>/dev/null 2>&1") + + --removing the MINIUPNPD chain for filter + os.execute("iptables -t filter -F MINIUPNPD 1>/dev/null 2>&1") + --adding the rule to MINIUPNPD + + os.execute("iptables -t filter -D FORWARD -i "..WAN_IF.." ! -o "..WAN_IF.." -j MINIUPNPD 1>/dev/null 2>&1") + os.execute("iptables -t filter -X MINIUPNPD 1>/dev/null 2>&1") + + os.execute("iptables -t nat -N MINIUPNPD") + os.execute("iptables -t nat -A PREROUTING -i "..WAN_IF.." -j MINIUPNPD") + os.execute("iptables -t filter -N MINIUPNPD") + os.execute("iptables -t filter -A FORWARD -i "..WAN_IF.." ! -o "..WAN_IF.." -j MINIUPNPD") + + if mtkwifi.exists("/tmp/run/miniupnpd."..vif) then + os.execute("cat /tmp/run/miniupnpd."..vif.." | xargs kill -9") + end + + if enable then + local profile = mtkwifi.search_dev_and_profile()[devname] + local cfgs = mtkwifi.load_profile(profile) + local ssid_index = devs[devname]["vifs"][vif].vifidx + local wsc_conf_mode = "" + local PORT_NUM = 7777+(string.byte(vif, -1)+string.byte(vif, -2)) + local LAN_IPADDR = mtkwifi.__trim(mtkwifi.read_pipe("uci -q get network.lan.ipaddr")) + local LAN_MASK = mtkwifi.__trim(mtkwifi.read_pipe("uci -q get network.lan.netmask")) + local port = 6352 + (string.byte(vif, -1)+string.byte(vif, -2)) + LAN_IPADDR = LAN_IPADDR.."/"..LAN_MASK + wsc_conf_mode = mtkwifi.token_get(cfgs["WscConfMode"], ssid_index, "") + + local file = io.open("/etc/miniupnpd.conf", "w") + if nil == file then + nixio.syslog("debug","open file /etc/miniupnpd.conf fail") + end + + file:write("ext_ifname=",WAN_IF,'\n','\n', + "listening_ip=",LAN_IPADDR,'\n','\n', + "port=",port,'\n','\n', + "bitrate_up=800000000",'\n', + "bitrate_down=800000000",'\n','\n', + "secure_mode=no",'\n','\n', + "system_uptime=yes",'\n','\n', + "notify_interval=30",'\n','\n', + "uuid=68555350-3352-3883-2883-335030522880",'\n','\n', + "serial=12345678",'\n','\n', + "model_number=1",'\n','\n', + "enable_upnp=no",'\n','\n') + file:close() + + if wsc_conf_mode ~= "" and wsc_conf_mode ~= "0" then + os.execute("miniupnpd -m 1 -I "..vif.." -P /var/run/miniupnpd."..vif.." -G -i "..WAN_IF.." -a "..LAN_IPADDR.." -n "..PORT_NUM) + end + end +end + +function d8021xd_chk(devname,prefix,main_ifname,enable) + local profile = mtkwifi.search_dev_and_profile()[devname] + local cfgs = mtkwifi.load_profile(profile) + local auth_mode = cfgs.AuthMode + local ieee8021x = cfgs.IEEE8021X + local pat_auth_mode = {"WPA$", "WPA;", "WPA2$", "WPA2;", "WPA1WPA2$", "WPA1WPA2;"} + local pat_ieee8021x = {"1$", "1;"} + local apd_en = false + if mtkwifi.exists("/tmp/run/8021xd_"..main_ifname..".pid") then + os.execute("cat /tmp/run/8021xd_"..main_ifname..".pid | xargs kill -9") + os.execute("rm /tmp/run/8021xd_"..main_ifname..".pid") + end + if enable then + for _, pat in ipairs(pat_auth_mode) do + if string.find(auth_mode, pat) then + apd_en = true + end + end + + for _, pat in ipairs(pat_ieee8021x) do + if string.find(ieee8021x, pat) then + apd_en = true + end + end + + if apd_en then + os.execute("8021xd -p "..prefix.. " -i "..main_ifname) + end + end +end diff --git a/package/mtk/drivers/mt_wifi/patches/1110-mt-wifi-common.patch b/package/mtk/drivers/mt_wifi/patches/1110-mt-wifi-common.patch new file mode 100644 index 000000000..683adb31a --- /dev/null +++ b/package/mtk/drivers/mt_wifi/patches/1110-mt-wifi-common.patch @@ -0,0 +1,19 @@ +diff -urN a/mt_wifi/mt_wifi/embedded/common/cmm_info.c b/mt_wifi/mt_wifi/embedded/common/cmm_info.c +--- a/mt_wifi/embedded/common/cmm_info.c 2018-11-01 10:03:25.663408611 +0000 ++++ b/mt_wifi/embedded/common/cmm_info.c 2018-11-01 10:09:14.991395503 +0000 +@@ -3200,6 +3200,15 @@ + else + need_send = FALSE; + } ++#if 1 ++ /* [2018.11.01 hepark] To fill 5G information */ ++ else if (!strcmp(wrq->ifr_ifrn.ifrn_name, "rai0")) { ++ if (!memcmp(pEntry->wdev->if_dev->name, "rax", 3)) ++ need_send = FALSE; ++ else ++ need_send = TRUE; ++ } ++#endif + } + if (IS_ENTRY_CLIENT(pEntry) && (pEntry->Sst == SST_ASSOC) && (need_send == TRUE)) { + pDst = &pMacTab->Entry[pMacTab->Num]; diff --git a/package/mtk/drivers/mt_wifi/patches/1111-fix-eeprom-flash-read-write.patch b/package/mtk/drivers/mt_wifi/patches/1111-fix-eeprom-flash-read-write.patch new file mode 100644 index 000000000..daebbd760 --- /dev/null +++ b/package/mtk/drivers/mt_wifi/patches/1111-fix-eeprom-flash-read-write.patch @@ -0,0 +1,167 @@ +diff -urN a/mt_wifi/embedded/common/ee_flash.c b/mt_wifi/embedded/common/ee_flash.c +--- a/mt_wifi/embedded/common/ee_flash.c 2018-04-30 15:57:54.000000000 +0800 ++++ b/mt_wifi/embedded/common/ee_flash.c 2019-01-14 21:28:38.163721571 +0800 +@@ -111,8 +111,8 @@ + int mt_mtd_write_nm_wifi(char *name, loff_t to, size_t len, const u_char *buf); + int mt_mtd_read_nm_wifi(char *name, loff_t from, size_t len, u_char *buf); + +-#define flash_read(_ctrl, _ptr, _offset, _len) mt_mtd_read_nm_wifi("Factory", _offset, (size_t)_len, _ptr) +-#define flash_write(_ctrl, _ptr, _offset, _len) mt_mtd_write_nm_wifi("Factory", _offset, (size_t)_len, _ptr) ++#define flash_read(_ctrl, _ptr, _offset, _len) mt_mtd_read_nm_wifi("factory", _offset&0xFFFF, (size_t)_len, _ptr) ++#define flash_write(_ctrl, _ptr, _offset, _len) mt_mtd_write_nm_wifi("factory", _offset&0xFFFF, (size_t)_len, _ptr) + + #else + /* +@@ -122,8 +122,8 @@ + extern int ra_mtd_write_nm(char *name, loff_t to, size_t len, const u_char *buf); + extern int ra_mtd_read_nm(char *name, loff_t from, size_t len, u_char *buf); + +-#define flash_read(_ctrl, _ptr, _offset, _len) ra_mtd_read_nm("Factory", _offset, (size_t)_len, _ptr) +-#define flash_write(_ctrl, _ptr, _offset, _len) ra_mtd_write_nm("Factory", _offset, (size_t)_len, _ptr) ++#define flash_read(_ctrl, _ptr, _offset, _len) ra_mtd_read_nm("factory", _offset&0xFFFF, (size_t)_len, _ptr) ++#define flash_write(_ctrl, _ptr, _offset, _len) ra_mtd_write_nm("factory", _offset&0xFFFF, (size_t)_len, _ptr) + + #endif /*CONFIG_WIFI_MTD*/ + #endif /*RA_MTD_RW_BY_NUM*/ +diff -urN a/mt_wifi/embedded/common/eeprom.c b/mt_wifi/embedded/common/eeprom.c +--- a/mt_wifi/embedded/common/eeprom.c 2018-04-30 15:57:54.000000000 +0800 ++++ b/mt_wifi/embedded/common/eeprom.c 2019-04-19 17:05:48.336239756 +0800 +@@ -646,7 +646,7 @@ + efuse_probe(pAd); + #endif /* RTMP_EFUSE_SUPPORT */ + +- /* rtmp_eeprom_of_platform(pAd); //for MT7615, only use E2pAccessMode parameter to get eeprom type */ ++ rtmp_eeprom_of_platform(pAd); //for MT7615, only use E2pAccessMode parameter to get eeprom type */ + + if (forceMode != E2P_NONE && forceMode < NUM_OF_E2P_MODE) { + e2p_type = forceMode; +diff -urN a/mt_wifi/os/linux/mt_wifi_mtd.c b/mt_wifi/os/linux/mt_wifi_mtd.c +--- a/mt_wifi/os/linux/mt_wifi_mtd.c 1970-01-01 08:00:00.000000000 +0800 ++++ b/mt_wifi/os/linux/mt_wifi_mtd.c 2019-01-06 17:17:32.771446000 +0800 +@@ -0,0 +1,113 @@ ++/* ++ *************************************************************************** ++ * MediaTek Inc. ++ * ++ * All rights reserved. source code is an unpublished work and the ++ * use of a copyright notice does not imply otherwise. This source code ++ * contains confidential trade secret material of MediaTek. Any attemp ++ * or participation in deciphering, decoding, reverse engineering or in any ++ * way altering the source code is stricitly prohibited, unless the prior ++ * written consent of MediaTek, Inc. is obtained. ++ *************************************************************************** ++ Module Name: ++ mt_wifi_mtd.c ++ ++*/ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#if defined (CONFIG_MIPS) ++#include ++#endif ++ ++int mt_mtd_write_nm_wifi(char *name, loff_t to, size_t len, const u_char *buf) ++{ ++ int ret = -1; ++ size_t rdlen, wrlen; ++ struct mtd_info *mtd; ++ struct erase_info ei; ++ u_char *bak = NULL; ++ ++ mtd = get_mtd_device_nm(name); ++ if (IS_ERR(mtd)) ++ return -1; ++ ++ if (len > mtd->erasesize) { ++ put_mtd_device(mtd); ++ return -E2BIG; ++ } ++ ++ bak = kmalloc(mtd->erasesize, GFP_KERNEL); ++ if (bak == NULL) { ++ put_mtd_device(mtd); ++ return -ENOMEM; ++ } ++ ++ ret = mtd_read(mtd, 0, mtd->erasesize, &rdlen, bak); ++ ++ if (ret != 0) { ++ put_mtd_device(mtd); ++ kfree(bak); ++ return ret; ++ } ++ ++ if (rdlen != mtd->erasesize) ++ printk("warning: ra_mtd_write: rdlen is not equal to erasesize\n"); ++ ++ memcpy(bak + to, buf, len); ++ ++ ei.mtd = mtd; ++ ei.callback = NULL; ++ ei.addr = 0; ++ ei.len = mtd->erasesize; ++ ei.priv = 0; ++ ++ ret = mtd_erase(mtd, &ei); ++ ++ if (ret != 0) { ++ put_mtd_device(mtd); ++ kfree(bak); ++ return ret; ++ } ++ ++ ret = mtd_write(mtd, 0, mtd->erasesize, &wrlen, bak); ++ ++ ++ ++ put_mtd_device(mtd); ++ kfree(bak); ++ return ret; ++} ++EXPORT_SYMBOL(mt_mtd_write_nm_wifi); ++ ++ ++int mt_mtd_read_nm_wifi(char *name, loff_t from, size_t len, u_char *buf) ++{ ++ int ret; ++ size_t rdlen; ++ struct mtd_info *mtd; ++ ++ mtd = get_mtd_device_nm(name); ++ if (IS_ERR(mtd)) ++ return -1; ++ ++ ret = mtd_read(mtd, from, len, &rdlen, buf); ++ ++ if (rdlen != len) ++ printk("warning: ra_mtd_read_nm: rdlen is not equal to len\n"); ++ ++ put_mtd_device(mtd); ++ ++ return ret; ++} ++EXPORT_SYMBOL(mt_mtd_read_nm_wifi); +diff -urN a/mt_wifi_ap/Makefile b/mt_wifi_ap/Makefile +--- a/mt_wifi_ap/Makefile 2018-04-30 15:57:57.000000000 +0800 ++++ b/mt_wifi_ap/Makefile 2019-04-20 21:16:22.510780934 +0800 +@@ -678,7 +678,8 @@ + os_objs := $(SRC_DIR)/os/linux/rt_proc.o\ + $(SRC_DIR)/os/linux/rt_linux.o\ + $(SRC_DIR)/os/linux/rt_profile.o\ +- $(SRC_DIR)/os/linux/rt_main_dev.o ++ $(SRC_DIR)/os/linux/rt_main_dev.o\ ++ $(SRC_DIR)/os/linux/mt_wifi_mtd.o + + ifeq ($(CONFIG_WLAN_HOOK),y) + EXTRA_CFLAGS +=-DRTMP_WLAN_HOOK_SUPPORT diff --git a/package/mtk/drivers/wifi-l1profile/Makefile b/package/mtk/drivers/wifi-l1profile/Makefile new file mode 100644 index 000000000..cedc23297 --- /dev/null +++ b/package/mtk/drivers/wifi-l1profile/Makefile @@ -0,0 +1,53 @@ +# +# Copyright (C) 2016 MediaTek +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/version.mk + +PKG_NAME:=wifi-l1profile +PKG_RELEASE:=1 +PKG_BUILD_DEPENDS:= +PKG_FILE_DEPENDS:= +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/wifi-l1profile + SECTION:=MTK Properties + CATEGORY:=MTK Properties + SUBMENU:=Drivers + DEPENDS:= + TITLE:=Build WiFi l1profile.data on demand. + VERSION:=$(PKG_RELEASE)-$(REVISION) + MENU:=1 +endef + +define Package/wifi-l1profile/description + This package helps to build l1profile on demand. +endef + +define Package/wifi-l1profile/config + if PACKAGE_wifi-l1profile + source "$(SOURCE)/l1profile.config.in" + endif +endef + +define Build/Prepare +endef + +define Build/Compile + rm -rf $(PKG_BUILD_DIR) + mkdir -p $(PKG_BUILD_DIR) + python ./make-l1profile.py $(TOPDIR)/.config /dev/null +endef + +define Package/wifi-l1profile/install + $(INSTALL_DIR) $(1)/etc/wireless/ + python ./make-l1profile.py $(TOPDIR)/.config $(1)/etc/wireless/l1profile.dat > /dev/null +endef + +$(eval $(call BuildPackage,wifi-l1profile)) diff --git a/package/mtk/drivers/wifi-l1profile/l1profile.config.in b/package/mtk/drivers/wifi-l1profile/l1profile.config.in new file mode 100644 index 000000000..b4a000c76 --- /dev/null +++ b/package/mtk/drivers/wifi-l1profile/l1profile.config.in @@ -0,0 +1,208 @@ +# l1profile configurations + +menuconfig first_card + bool "1st card" + default y + +if first_card + +config first_card_name + string "1st card name" + default "MT7622" + +config first_card_profile_path + string "profile path" + default "/etc/wireless/mediatek/mt7622.1.dat" + +config first_card_init_script + string "init scripts" + default "/lib/wifi/mt7615e.lua" + +config first_card_init_compatible + string "this chip uses a compatible driver" + default "mt7615e" + +config first_card_EEPROM_offset + string "eeprom data offset (in flash mode)" + default "0x0" + +config first_card_EEPROM_size + string "eeprom data size (in flash mode)" + default "0x5000" + +config first_card_EEPROM_name + string "eeprom file name (request_firmware)" + default "e2p" + +config first_card_main_ifname + string "primary interface name" + default "ra0" + +config first_card_ext_ifname + string "interface prefix for multi-bssid" + default "ra" + +config first_card_wds_ifname + string "WDS interface prefix" + default "wds" + +config first_card_apcli_ifname + string "APCLI interface prefix" + default "apcli" + +config first_card_mesh_ifname + string "MESH interface prefix" + default "mesh" + +config first_card_nvram_zone + string "nvram zone" + default "dev1" + +config first_card_single_sku_path + string "single SKU data path" + default "/etc/wireless/mediatek/mt7615e-sku.dat" + +config first_card_bf_sku_path + string "Beam forming SKU data path" + default "/etc/wireless/mediatek/mt7615e-sku-bf.dat" + +endif + + + +menuconfig second_card + bool "2nd card" + default y + +if second_card + +config second_card_name + string "2nd card name" + default "MT7615" + +config second_card_profile_path + string "profile path" + default "/etc/wireless/mediatek/mt7615e.1.dat" + +config second_card_init_script + string "init scripts" + default "/lib/wifi/mt7615e.lua" + +config second_card_init_compatible + string "this chip uses a compatible driver" + default "mt7615e" + +config second_card_EEPROM_offset + string "eeprom data offset (in flash mode)" + default "0x5000" + +config second_card_EEPROM_size + string "eeprom data size (in flash mode)" + default "0xB000" + +config second_card_EEPROM_name + string "eeprom file name (request_firmware)" + default "e2p" + +config second_card_main_ifname + string "primary interface name" + default "rai0" + +config second_card_ext_ifname + string "interface prefix for multi-bssid" + default "rai" + +config second_card_wds_ifname + string "WDS interface prefix" + default "wdsi" + +config second_card_apcli_ifname + string "APCLI interface prefix" + default "apclii" + +config second_card_mesh_ifname + string "MESH interface prefix" + default "meshi" + +config second_card_nvram_zone + string "nvram zone" + default "dev2" + +config second_card_single_sku_path + string "single SKU data path" + default "/etc/wireless/mediatek/mt7615e-sku.dat" + +config second_card_bf_sku_path + string "Beam forming SKU data path" + default "/etc/wireless/mediatek/mt7615e-sku-bf.dat" + +endif + + +menuconfig third_card + bool "3rd card" + default y + +if third_card + +config third_card_name + string "3rd card name" + default "MT7615" + +config third_card_profile_path + string "profile path" + default "/etc/wireless/mediatek/mt7615e.2.dat" + +config third_card_init_script + string "init scripts" + default "/lib/wifi/mt7615e.lua" + +config third_card_init_compatible + string "this chip uses a compatible driver" + default "mt7615e" + +config third_card_EEPROM_offset + string "eeprom data offset (in flash mode)" + default "0x10000" + +config third_card_EEPROM_size + string "eeprom data size (in flash mode)" + default "0xB000" + +config third_card_EEPROM_name + string "eeprom file name (request_firmware)" + default "e2p" + +config third_card_main_ifname + string "primary interface name" + default "wlan0" + +config third_card_ext_ifname + string "interface prefix for multi-bssid" + default "wlan" + +config third_card_wds_ifname + string "WDS interface prefix" + default "wlan-wds" + +config third_card_apcli_ifname + string "APCLI interface prefix" + default "wlan-apcli" + +config third_card_mesh_ifname + string "MESH interface prefix" + default "wlan-mesh" + +config third_card_nvram_zone + string "nvram zone" + default "dev3" + +config third_card_single_sku_path + string "single SKU data path" + default "/etc/wireless/mediatek/mt7615e-sku.dat" + +config third_card_bf_sku_path + string "Beam forming SKU data path" + default "/etc/wireless/mediatek/mt7615e-sku-bf.dat" + +endif diff --git a/package/mtk/drivers/wifi-l1profile/make-l1profile.py b/package/mtk/drivers/wifi-l1profile/make-l1profile.py new file mode 100644 index 000000000..0a52cd6d6 --- /dev/null +++ b/package/mtk/drivers/wifi-l1profile/make-l1profile.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python + +# Hua Shao + +import sys +import re +import random + +l1conf = [] + +def parseconfig(conf): + global l1conf + + l1conf.extend([[],[],[]]) + with open(conf, "r") as fp: + for line in fp: + if line.startswith("CONFIG_first_card_"): + kv = line.split("=") + l1conf[0].append((kv[0][len("CONFIG_first_card_"):], kv[1].strip("\"\'\r\n\t"))) + elif line.startswith("CONFIG_second_card_"): + kv = line.split("=") + l1conf[1].append((kv[0][len("CONFIG_second_card_"):], kv[1].strip("\"\'\r\n\t"))) + elif line.startswith("CONFIG_third_card_"): + kv = line.split("=") + l1conf[2].append((kv[0][len("CONFIG_third_card_"):], kv[1].strip("\"\'\r\n\t"))) + else: + continue + +def validate(): + global l1conf + + d1 = dict(l1conf[0]) if len(l1conf) > 0 else {} + d2 = dict(l1conf[1]) if len(l1conf) > 1 else {} + d3 = dict(l1conf[2]) if len(l1conf) > 2 else {} + + # make sure no empty value + for dx in [d1,d2,d3]: + for k,v in dx.items(): + assert v + + # make sure these configs are unique + for name in ["main_ifname", "ext_ifname", "wds_ifname", + "apcli_name", "mesh_ifname", "nvram_zone", + "profile_path"]: + if1 = d1.get(name, random.random()) + if2 = d2.get(name, random.random()) + if3 = d3.get(name, random.random()) + assert len(set([if1, if2, if3])) == 3, "duplication found in "+name + + # main_ifname should end with "0" + if1 = [ x.strip() for x in d1.get("main_ifname","").split(";") if x] + if2 = [ x.strip() for x in d2.get("main_ifname","").split(";") if x] + if3 = [ x.strip() for x in d3.get("main_ifname","").split(";") if x] + for each in if1: + assert not each or each.endswith("0"), "1st main_ifname {0} does not ends with 0".format(each) + for each in if2: + assert not each or each.endswith("0"), "2nd main_ifname {0} does not ends with 0".format(each) + for each in if3: + assert not each or each.endswith("0"), "3rd main_ifname {0} does not ends with 0".format(each) + + # main_ifname should start with ext_ifname + if1ext = [ x.strip() for x in d1.get("ext_ifname","").split(";") if x] + if2ext = [ x.strip() for x in d2.get("ext_ifname","").split(";") if x] + if3ext = [ x.strip() for x in d3.get("ext_ifname","").split(";") if x] + + assert len(if1) == len(if1ext), "number of 1st main_ifname does not equal to 1st ext_ifname" + assert len(if2) == len(if2ext), "number of 2nd main_ifname does not equal to 2nd ext_ifname" + assert len(if3) == len(if3ext), "number of 3rd main_ifname does not equal to 3rd ext_ifname" + + for i,each in enumerate(if1ext): + assert if1[i].startswith(each), "1st main_ifname {0} does not start with its ext_ifname {1}".format(if1[i], each) + for i,each in enumerate(if2ext): + assert if2[i].startswith(each), "2nd main_ifname {0} does not start with its ext_ifname {1}".format(if2[i], each) + for i,each in enumerate(if3ext): + assert if3[i].startswith(each), "3rd main_ifname {0} does not start with its ext_ifname {1}".format(if3[i], each) + + # assertion failure or returning any python non-true value will terminate the build procedure. + # if you need more validations, feel free to add you code below. + + return True + +def genfile(dest): + global l1conf + + with open(dest, "w") as fp: + print("Default") + fp.write("Default\n") + for i,lst in enumerate(l1conf): + for (k,v) in lst: + if k == "name": + line = "INDEX{0}={1}".format(i, v) + else: + line = "INDEX{0}_{1}={2}".format(i, k, v) + print(line) + fp.write(line+"\n") + fp.write("\n") # extra line-end to make drivers happy + +if __name__ == "__main__": + if len(sys.argv) < 3: + print("arguments missing!") + print("usage: make-l1profile.py <.config> !") + sys.exit(-1) + conf = sys.argv[1] + dest = sys.argv[2] + parseconfig(conf) + if validate(): + genfile(dest) + else: + print("something is wrong with your l1profile configurations!") + sys.exit(-1) + diff --git a/package/mtk/drivers/wifi_forward/Makefile b/package/mtk/drivers/wifi_forward/Makefile new file mode 100644 index 000000000..c2d51c769 --- /dev/null +++ b/package/mtk/drivers/wifi_forward/Makefile @@ -0,0 +1,84 @@ +# All rights reserved. +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=wifi_forward +PKG_REVISION:=01fc537c +PKG_SOURCE:=$(PKG_NAME)-$(PKG_REVISION).tar.bz2 +P4REV:= +PKG_VERSION:= +PKG_SOURCE_URL:= +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME) +PKG_KCONFIG:= \ + MT_WIFI_PKT_FWD \ + MT_WIFI_PKT_FWD_V1 + +PKG_CONFIG_DEPENDS:=$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),CONFIG_$(c))) + +include $(INCLUDE_DIR)/package.mk + +TAR_CMD=$(HOST_TAR) -C $(1)/.. $(TAR_OPTIONS) + +define KernelPackage/wifi_forward + CATEGORY:=MTK Properties + TITLE:=MTK wifi forward driver +ifeq ($(CONFIG_MT_WIFI_PKT_FWD_V1),y) + FILES:=$(PKG_BUILD_DIR)/wifi_fwd_v1/wifi_forward.ko +else + FILES:=$(PKG_BUILD_DIR)/wifi_fwd/wifi_forward.ko +endif + AUTOLOAD:=$(call AutoProbe,wifi_forward) + SUBMENU:=Drivers + MENU:=1 +endef + +define KernelPackage/wifi_forward/config + source "$(SOURCE)/config.in" +endef + + +ifeq ($(CONFIG_MT_WIFI_PKT_FWD_V1),y) +define Build/Compile + $(MAKE) -C "$(LINUX_DIR)" V=1 \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + ARCH="$(LINUX_KARCH)" \ + SUBDIRS="$(PKG_BUILD_DIR)/wifi_fwd_v1" \ + $(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),CONFIG_$(c)=$(CONFIG_$(c)))) \ + modules +endef +else +define Build/Compile + $(MAKE) -C "$(LINUX_DIR)" V=1 \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + ARCH="$(LINUX_KARCH)" \ + SUBDIRS="$(PKG_BUILD_DIR)/wifi_fwd" \ + $(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),CONFIG_$(c)=$(CONFIG_$(c)))) \ + modules +endef +endif + +TARGET_CFLAGS += \ + $(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),-DCONFIG_$(c)=$(CONFIG_$c))) + +MAKE_FLAGS += \ + $(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),CONFIG_$(c)=$(CONFIG_$c))) + +TARGET_CFLAGS += -DCONFIG_SUPPORT_OPENWRT +MAKE_FLAGS += CONFIG_SUPPORT_OPENWRT=y + +define KernelPackage/wifi_forward/install + # $(INSTALL_DIR) $(1)/lib/modules/ralink/ + # if [ "$$(CONFIG_MT_WIFI_PKT_FWD_V1)" = "y" ]; then \ + # $(INSTALL_BIN) $(PKG_BUILD_DIR)/wifi_fwd_v1/wifi_forward.ko $(1)/lib/modules/ralink/; \ + # else \ + # $(INSTALL_BIN) $(PKG_BUILD_DIR)/wifi_fwd/wifi_forward.ko $(1)/lib/modules/ralink/; \ + # fi +endef + +$(eval $(call KernelPackage,wifi_forward)) + + diff --git a/package/mtk/drivers/wifi_forward/config.in b/package/mtk/drivers/wifi_forward/config.in new file mode 100644 index 000000000..3f0702cb7 --- /dev/null +++ b/package/mtk/drivers/wifi_forward/config.in @@ -0,0 +1,16 @@ +if PACKAGE_kmod-wifi_forward + +menu "WiFi Operation Modes" +config MT_WIFI_PKT_FWD + bool "WiFi package forward" + default y + +config MT_WIFI_PKT_FWD_V1 + depends on MT_WIFI_PKT_FWD + bool "WiFi package forward V1" + default n + +endmenu + +endif +