mtwifi-cfg: add support for tri-band models

This commit is contained in:
hanwckf 2024-09-14 21:54:48 +08:00
parent 7b6369185e
commit 1bfe4ec86b
4 changed files with 40 additions and 19 deletions

View File

@ -148,7 +148,7 @@ function l1dat_parser.load_l1_profile(path)
end end
end end
}) })
local nixio = require("nixio") --local nixio = require("nixio")
local chipset_num = {} local chipset_num = {}
local dir = io.popen("ls /etc/wireless/") local dir = io.popen("ls /etc/wireless/")
if not dir then return end if not dir then return end
@ -167,9 +167,9 @@ function l1dat_parser.load_l1_profile(path)
k1, k2 = string.match(k, "INDEX(%d+)_(.+)") k1, k2 = string.match(k, "INDEX(%d+)_(.+)")
if k1 then if k1 then
k1 = tonumber(k1) + 1 k1 = tonumber(k1) + 1
if devs[k1][k2] then --if devs[k1][k2] then
nixio.syslog("warning", "skip repeated key"..line) -- nixio.syslog("warning", "skip repeated key"..line)
end --end
devs[k1][k2] = v or "" devs[k1][k2] = v or ""
else else
k1 = string.match(k, "INDEX(%d+)") k1 = string.match(k, "INDEX(%d+)")

View File

@ -26,14 +26,27 @@ function show_usage()
end end
function show_devs() function show_devs()
local devs = {}
local ret = "" local ret = ""
for k, _ in pairs(l1dat.devname_ridx) do
if #ret > 0 then for k, v in pairs(l1dat.devname_ridx) do
ret = ret .. " " .. k -- skip MT7986-2.4G for ax7800 project
else if not(string.find(v.profile_path, "ax7800") and
ret = k v.INDEX == "MT7986" and v.subidx == 1) then
table.insert(devs, k)
end end
end end
table.sort(devs)
for _,v in ipairs(devs) do
if #ret > 0 then
ret = ret .. " " .. v
else
ret = v
end
end
print(ret) print(ret)
end end

View File

@ -92,12 +92,14 @@ end
function ifup(ifname) function ifup(ifname)
if ifname and #ifname > 0 then if ifname and #ifname > 0 then
os.execute("ifconfig "..ifname.." up") os.execute("ifconfig "..ifname.." up")
nixio.syslog("info", "mtwifi-cfg: ifconfig up "..ifname)
end end
end end
function ifdown(ifname) function ifdown(ifname)
if ifname and #ifname > 0 then if ifname and #ifname > 0 then
os.execute("ifconfig "..ifname.." down") os.execute("ifconfig "..ifname.." down")
nixio.syslog("info", "mtwifi-cfg: ifconfig down "..ifname)
end end
end end
@ -184,11 +186,12 @@ end
function mtwifi_up(devname, cfg, restore_vifs, is_dbdc) function mtwifi_up(devname, cfg, restore_vifs, is_dbdc)
nixio.syslog("info", "mtwifi-cfg: start "..devname) nixio.syslog("info", "mtwifi-cfg: start "..devname)
local dev = l1dat.devname_ridx[devname] local dev = l1dat.devname_ridx[devname]
local dbdc_main_ifname = defs.dbdc_init_ifname
if not dev then return end if not dev then return end
if is_dbdc then if is_dbdc then
local dbdc_main_dev = dev.INDEX .. "_1_1"
local dbdc_main_ifname = l1dat.devname_ridx[dbdc_main_dev].main_ifname
if not is_dbdc_inited(dbdc_main_ifname) then if not is_dbdc_inited(dbdc_main_ifname) then
nixio.syslog("info", "mtwifi-cfg: dbdc card init...") nixio.syslog("info", "mtwifi-cfg: dbdc card init...")
ifup(dbdc_main_ifname) ifup(dbdc_main_ifname)
@ -318,7 +321,9 @@ function set_chip_cfg(cfg, dats)
-- setup other dev cfg -- setup other dev cfg
for k,v in pairs(l1dat.devname_ridx) do for k,v in pairs(l1dat.devname_ridx) do
if k ~= cfg.device then if k ~= cfg.device and
v.INDEX == l1dat.devname_ridx[cfg.device].INDEX and
v.mainidx == l1dat.devname_ridx[cfg.device].mainidx then
dev_dats = load_profile(v.profile_path) dev_dats = load_profile(v.profile_path)
if dev_dats then if dev_dats then
for _,j in pairs(defs.chip_cfgs) do for _,j in pairs(defs.chip_cfgs) do
@ -641,18 +646,22 @@ function mtwifi_cfg_setup(argv)
end end
if restart_other_dbdc_dev then if restart_other_dbdc_dev then
for k, _ in pairs(l1dat.devname_ridx) do for k, j in pairs(l1dat.devname_ridx) do
local ret = mtwifi_down(k, cfg) if j.INDEX == dev.INDEX and j.mainidx == dev.mainidx then
for _, v in ipairs(ret) do local ret = mtwifi_down(k, cfg)
table.insert(restore_vifs, v) for _, v in ipairs(ret) do
table.insert(restore_vifs, v)
end
end end
end end
if #restore_vifs > 0 then if #restore_vifs > 0 then
nixio.syslog("info", "mtwifi-cfg: dbdc restore_vifs: "..inspect.inspect(restore_vifs)) nixio.syslog("info", "mtwifi-cfg: dbdc restore_vifs: "..inspect.inspect(restore_vifs))
end end
for k, _ in pairs(l1dat.devname_ridx) do for k, j in pairs(l1dat.devname_ridx) do
mtwifi_up(k, cfg, restore_vifs, true) if j.INDEX == dev.INDEX and j.mainidx == dev.mainidx then
mtwifi_up(k, cfg, restore_vifs, true)
end
end end
else else
mtwifi_down(devname) mtwifi_down(devname)

View File

@ -16,7 +16,6 @@
local mtwifi_defs = {} local mtwifi_defs = {}
mtwifi_defs.dbdc_init_ifname = "ra0"
mtwifi_defs.max_mbssid = 16 mtwifi_defs.max_mbssid = 16
mtwifi_defs.max_acl_entry = 129 mtwifi_defs.max_acl_entry = 129