mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Doug Ledford <doug.ledford@hpe.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
	Slingshot Open Source Team <slingshot-os-team@groups.ext.hpe.com>
Cc: <linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Doug Ledford <doug.ledford@hpe.com>
Subject: [PATCH 10/11] RDMA/cxi: read the NIC telemetry through counters
Date: Fri, 30 Oct 2026 21:35:38 -0700	[thread overview]
Message-ID: <20261030-cxi-for-next-v1-10-bc6e49e07037@hpe.com> (raw)
In-Reply-To: <20261030-cxi-for-next-v1-0-bc6e49e07037@hpe.com>

Implement read_counters_ex() so that user space can read the NIC
telemetry through the COUNTERS object.  An item number is the index of
the telemetry item in the core driver's table, so the caller names what
it wants without the driver describing thousands of entries in sysfs.
Items the device does not define read as zero with a zero timestamp.
The values come from the core driver's cxi_telem_read(), which reads
the device BAR directly.

Known limitation, deferred to V2: this patch carries SR-IOV
virtual-function code (VF-to-PF mailbox requests, mailbox opcodes or VF
resource handling) from an older, incomplete version of the Cassini
SR-IOV support. V2 of this series will include the updated SR-IOV
implementation, so issues in the VF paths should be ignored for now.

Signed-off-by: Doug Ledford <doug.ledford@hpe.com>
---
 drivers/infiniband/hw/cxi/cxiverbs_counters.c | 38 +++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/drivers/infiniband/hw/cxi/cxiverbs_counters.c b/drivers/infiniband/hw/cxi/cxiverbs_counters.c
new file mode 100644
index 000000000000..2ece6568ea7d
--- /dev/null
+++ b/drivers/infiniband/hw/cxi/cxiverbs_counters.c
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * CXI RDMA telemetry counters, read through the uverbs counters object.
+ * Counter numbers are Cassini telemetry item IDs; user space names them.
+ * Copyright 2026 Hewlett Packard Enterprise Development LP
+ */
+
+#include <rdma/ib_verbs.h>
+
+#include "cxiverbs.h"
+
+int cxiverbs_create_counters(struct ib_counters *counters,
+			     struct uverbs_attr_bundle *attrs)
+{
+	return 0;
+}
+
+int cxiverbs_destroy_counters(struct ib_counters *counters)
+{
+	return 0;
+}
+
+/*
+ * Counters are not attached to anything, so the core's attach check does
+ * not apply. With no items, counter N is telemetry item N.
+ */
+int cxiverbs_read_counters_ex(struct ib_counters *counters,
+			      struct ib_counters_read_attr *attr,
+			      struct uverbs_attr_bundle *attrs)
+{
+	struct cxiverbs_dev *dev = to_cxiverbs_dev(counters->device);
+
+	if (!dev->cdev->is_physfn)
+		return -EOPNOTSUPP;
+
+	return cxi_telem_read(dev->cdev, attr->items, attr->counters_buff,
+			      attr->timestamps, attr->ncounters);
+}

-- 
2.56.0


  parent reply	other threads:[~2026-10-31  4:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-31  4:35 [PATCH 00/11] Subject: [PATCH for-next 00/11] RDMA/cxi: add the HPE Cassini verbs driver Doug Ledford
2026-10-31  4:35 ` [PATCH 01/11] RDMA/core: read selected counters with timestamps Doug Ledford
2026-10-31  4:35 ` [PATCH 02/11] RDMA/core: allow jobs without an address table Doug Ledford
2026-10-31  4:35 ` [PATCH 03/11] RDMA/core: add Slingshot identifiers and driver-owned GIDs Doug Ledford
2026-10-31  4:35 ` [PATCH 04/11] RDMA/cxi: add the native ABI and resource definitions Doug Ledford
2026-11-05 13:54   ` Uwe Kleine-König
2026-10-31  4:35 ` [PATCH 05/11] RDMA/cxi: add the auxiliary device and driver ops Doug Ledford
2026-10-31  4:35 ` [PATCH 06/11] RDMA/cxi: add explicit context LNI and PID lifetimes Doug Ledford
2026-10-31  4:35 ` [PATCH 07/11] RDMA/cxi: add VNI-isolated queue pairs Doug Ledford
2026-10-31  4:35 ` [PATCH 08/11] RDMA/cxi: add native memory registration Doug Ledford
2026-10-31  4:35 ` [PATCH 09/11] RDMA/cxi: add services jobs profiles queues and counting triggers Doug Ledford
2026-10-31  4:35 ` Doug Ledford [this message]
2026-10-31  4:35 ` [PATCH 11/11] RDMA/cxi: wire the driver into the build Doug Ledford
2026-11-03 14:28 ` [PATCH 00/11] Subject: [PATCH for-next 00/11] RDMA/cxi: add the HPE Cassini verbs driver Leon Romanovsky
2026-11-03 14:30   ` Jason Gunthorpe
2026-11-04  9:54     ` Leon Romanovsky
2026-11-04 16:17       ` Doug Ledford
2026-11-04 16:14     ` Doug Ledford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261030-cxi-for-next-v1-10-bc6e49e07037@hpe.com \
    --to=doug.ledford@hpe.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=slingshot-os-team@groups.ext.hpe.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®