Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lua/driver/ixgbe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ function dev:clearRxStats()
return
end

-- clear TX counters. We want to clear the s/w statistics and also reg read to clear the h/w level
function dev:clearTxStats()
-- Read the hardware registers to clear them
dpdkc.read_reg32(self.id, GPTC)
dpdkc.read_reg32(self.id, GOTCL)
dpdkc.read_reg32(self.id, GOTCH)
-- Reset the software accumulation counters
self.txPkts = 0ULL
self.txBytes = 0ULL
return
end

-- necessary because of clear-on-read registers and the interaction with the normal rte_eth_stats_get() call
function dev:getTxStats()
self.txPkts = (self.txPkts or 0ULL) + dpdkc.read_reg32(self.id, GPTC)
Expand Down
17 changes: 11 additions & 6 deletions lua/stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,12 @@ function rxCounter:getStats(forceUpdate)
end

--- Device-based counter
function devRxCounter:getThroughput()
return self.dev:getRxStats()
end
function devRxCounter:getThroughput()
return self.dev:getRxStats()
end

function devRxCounter:clearThroughput()
return self.dev:clearRxStats()
function devRxCounter:clearThroughput()
return self.dev:clearRxStats()
end

--- Packet-based counter
Expand Down Expand Up @@ -453,10 +453,16 @@ function mod:newDevTxCounter(name, dev, format, file)
local obj = newCounter("dev", name, dev, format, file, "tx")
obj.sleep = 50
setmetatable(obj, devTxCounter)
obj:clearThroughput()
obj:getThroughput() -- reset stats on the NIC
return obj
end

-- Similiar to clearRxStats
function devTxCounter:clearThroughput()
return self.dev:clearTxStats()
end

--- Create a new tx counter that can be updated by passing packet buffers to it.
--- @param name the name of the counter, included in the output
--- @param format the output format, "CSV" and "plain" (default) are currently supported
Expand Down Expand Up @@ -629,4 +635,3 @@ end
__LIBMOON_STATS_TASK = statsTask

return mod