Skip to content

Commit

Permalink
apps.mellanox: Add per-queue drop stats
Browse files Browse the repository at this point in the history
For each configured queue, add a stats counter rxdrop_<queue_id> that
reflects the hardware per-queue drop counter where <queue_id> is the
queue id in the ConnectX configuration as defined by the user.

# Conflicts:
#	src/apps/mellanox/connectx.lua
  • Loading branch information
alexandergall authored and eugeneia committed Mar 9, 2022
1 parent 64a62f2 commit 4c1571f
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/apps/mellanox/connectx.lua
Expand Up @@ -283,8 +283,9 @@ function ConnectX:new (conf)
local rqlist = {}
local rqs = {}

-- List of queue counter IDs (ConnectX5 and up)
local counter_set_ids = {}
-- List of queue counter IDs and their corresponding queue IDs from
-- the configuration (ConnectX5 and up)
local q_counters = {}

-- Enable MAC/VLAN switching?
local usemac = false
Expand Down Expand Up @@ -333,7 +334,8 @@ function ConnectX:new (conf)
local counter_set_id
if self.mlx > 4 then
counter_set_id = hca:alloc_q_counter()
table.insert(counter_set_ids, counter_set_id)
table.insert(q_counters, { counter_id = counter_set_id,
queue_id = queue.id })
end
-- XXX order check
cxq.sqn = hca:create_sq(scqn, pd, sq_stride, sendq_size,
Expand Down Expand Up @@ -516,6 +518,11 @@ function ConnectX:new (conf)
txdrop = {counter},
txerrors = {counter},
}
-- Create per-queue drop counters named by the queue identifiers in
-- the configuration.
for _, queue in ipairs(conf.queues) do
frame["rxdrop_"..queue.id] = {counter}
end
self.stats = shm.create_frame("pci/"..pciaddress, frame)

-- Create separate HCAs to retreive port statistics. Those
Expand Down Expand Up @@ -561,16 +568,18 @@ function ConnectX:new (conf)
}

-- Empty for ConnectX4
for _, id in ipairs(counter_set_ids) do
for _, q_counter in ipairs(q_counters) do
local per_q_rxdrop = self.stats["rxdrop_"..q_counter.queue_id]
table.insert(self.stats_reqs,
{
start_fn = HCA.query_q_counter_start,
finish_fn = HCA.query_q_counter_finish,
args = { set_id = id },
args = q_counter.counter_id,
process_fn = function(r, stats)
-- Incremental update relies on query_q_counter to
-- clear the counter after read.
counter.add(stats.rxdrop, r.out_of_buffer)
counter.add(per_q_rxdrop, r.out_of_buffer)
end
})
end
Expand Down Expand Up @@ -1955,13 +1964,13 @@ end
local q_stats = {
out_of_buffer = 0ULL
}
function HCA:query_q_counter_start (args)
function HCA:query_q_counter_start (id)
self:command("QUERY_Q_COUNTER", 0x20, 0x10C)
:input("opcode", 0x00, 31, 16, 0x773)
-- Clear the counter after reading. This allows us to
-- update the rxdrop stat incrementally.
:input("clear", 0x18, 31, 31, 1)
:input("counter_set_id",0x1c, 7, 0, args.set_id)
:input("counter_set_id",0x1c, 7, 0, id)
:execute_async()
end

Expand Down

0 comments on commit 4c1571f

Please sign in to comment.