From 4c1571fcddda2ac4062d1a05377f80c792f978dd Mon Sep 17 00:00:00 2001 From: Alexander Gall Date: Mon, 17 Jan 2022 10:23:25 +0100 Subject: [PATCH] apps.mellanox: Add per-queue drop stats For each configured queue, add a stats counter rxdrop_ that reflects the hardware per-queue drop counter where is the queue id in the ConnectX configuration as defined by the user. # Conflicts: # src/apps/mellanox/connectx.lua --- src/apps/mellanox/connectx.lua | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/apps/mellanox/connectx.lua b/src/apps/mellanox/connectx.lua index 60542dbf9a..002b3da185 100644 --- a/src/apps/mellanox/connectx.lua +++ b/src/apps/mellanox/connectx.lua @@ -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 @@ -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, @@ -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 @@ -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 @@ -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