Fix the bandwidth reporting for ath10k devices

This commit is contained in:
Tim Wilkinson 2023-02-13 14:04:48 -08:00 committed by Joe AE6XE
parent b4df8bd893
commit dd00c7b1c3
2 changed files with 26 additions and 2 deletions

View File

@ -242,6 +242,22 @@ function lqm()
-- Or any hidden nodes -- Or any hidden nodes
os.execute(IW .. " " .. phy .. " set rts off > /dev/null 2>&1") os.execute(IW .. " " .. phy .. " set rts off > /dev/null 2>&1")
-- If the channel bandwidth is less than 20, we need to adjust what we report as the values from 'iw' will not
-- be correct
local channel_bw_scale = 1
local chanbw = read_all("/sys/kernel/debug/ieee80211/" .. phy .. "/ath10k/chanbw")
if not chanbw then
chanbw = read_all("/sys/kernel/debug/ieee80211/" .. phy .. "/ath9k/chanbw")
end
if chanbw then
chanbw = tonumber(chanbw)
if chanbw == 10 then
channel_bw_scale = 0.5
elseif chanbw == 5 then
channel_bw_scale = 0.25
end
end
local noise = -95 local noise = -95
local tracker = {} local tracker = {}
local dtdlinks = {} local dtdlinks = {}
@ -322,6 +338,9 @@ function lqm()
local val = line:match(k .. "%s*([%d%-]+)") local val = line:match(k .. "%s*([%d%-]+)")
if val then if val then
station[v] = tonumber(val) station[v] = tonumber(val)
if v == "tx_bitrate" or v == "rx_bitrate" then
station[v] = station[v] * channel_bw_scale
end
end end
end end
end end

View File

@ -110,6 +110,9 @@ end
local chanbw = 1 local chanbw = 1
local cb = "/sys/kernel/debug/ieee80211/" .. phy .. "/ath9k/chanbw" local cb = "/sys/kernel/debug/ieee80211/" .. phy .. "/ath9k/chanbw"
if not nixio.fs.stat(cb) then
cb = "/sys/kernel/debug/ieee80211/" .. phy .. "/ath10k/chanbw"
end
if nixio.fs.stat(cb) then if nixio.fs.stat(cb) then
for line in io.lines(cb) for line in io.lines(cb)
do do
@ -214,7 +217,9 @@ end
-- load up arpcache -- load up arpcache
local arpcache = {} local arpcache = {}
arptable(function(a) arptable(function(a)
if a["Flags"] ~= "0x0" and a["HW address"] ~= "00:00:00:00:00:00" then
arpcache[a["IP address"]] = a arpcache[a["IP address"]] = a
end
end) end)
local iwrates local iwrates
@ -268,7 +273,7 @@ do
end end
local station = iwrates[mac["HW address"]] local station = iwrates[mac["HW address"]]
if station then if station then
links[node.remoteIP].mbps = string.format("%.1f", station.txbitrate) links[node.remoteIP].mbps = string.format("%.1f", tonumber(station.txbitrate) / chanbw)
end end
end end
end end