From: Doug Ledford <doug.ledford@hpe.com>
To: <linux-rdma@vger.kernel.org>, <slingshot-os-team@groups.ext.hpe.com>
Cc: <linux-kernel@vger.kernel.org>,
Doug Ledford <doug.ledford@hpe.com>,
Iraimani P <iraimani.pavadai@hpe.com>
Subject: [PATCH 06/12] cxiverbs: encode list entries and VNI-isolated remote keys
Date: Sat, 31 Oct 2026 12:25:59 -0700 [thread overview]
Message-ID: <20261031-cxi-for-next-v1-6-93ce01907ce2@hpe.com> (raw)
In-Reply-To: <20261031-cxi-for-next-v1-0-93ce01907ce2@hpe.com>
Add cxi_le.h, which encodes receive list entries and remote keys.
A logical remote key is at most 48 bits. The wire key is the logical
key shifted left by 16 with the job's VNI in the low 16 bits, and the
list entry clears the ignore bits covering the VNI so it is always
compared. A logical key that does not fit is rejected with EOPNOTSUPP
rather than truncated, and a zero key is rejected with EINVAL, because
zero match bits are reserved for receives that do not use a key.
The helpers return negative errno values like the rest of the
hardware interface; the verbs entry points negate them before
setting errno.
Co-developed-by: Iraimani P <iraimani.pavadai@hpe.com>
Signed-off-by: Iraimani P <iraimani.pavadai@hpe.com>
Signed-off-by: Doug Ledford <doug.ledford@hpe.com>
---
providers/cxi/cxi_le.h | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 97 insertions(+)
diff --git a/providers/cxi/cxi_le.h b/providers/cxi/cxi_le.h
new file mode 100644
index 000000000000..096b3933adee
--- /dev/null
+++ b/providers/cxi/cxi_le.h
@@ -0,0 +1,97 @@
+/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
+/*
+ * Copyright 2026 Hewlett Packard Enterprise Development LP
+ */
+
+/*
+ * List entries the provider appends to an RU QP's PTE. The PTE is a
+ * matching PTE, so an entry is selected by match_bits (under ignore_bits)
+ * and by the initiator's match_id; both must be right or nothing matches.
+ */
+
+#ifndef CXI_LE_H
+#define CXI_LE_H
+
+#include <stdint.h>
+#include <errno.h>
+#include <string.h>
+#include "cxi_prov_hw.h"
+#include <rdma/cxiverbs-abi.h>
+
+/* SEND carries no key, so a receive buffer matches exactly the zero no rkey is. */
+#define CXI_LE_RECV_MATCH_BITS 0ULL
+
+#define CXI_LE_VNI_MASK 0xffffULL
+#define CXI_LE_RKEY_MAX 0xffffffffffffULL
+
+static inline int cxi_le_wire_key(uint64_t rkey, uint64_t *wire_key)
+{
+ if (rkey > CXI_LE_RKEY_MAX)
+ return -EOPNOTSUPP;
+ *wire_key = rkey << 16;
+ return 0;
+}
+
+static inline int cxi_le_set_vni(union c_cmdu *cmd, uint64_t rkey, uint16_t vni)
+{
+ uint64_t wire_key;
+ int ret = cxi_le_wire_key(rkey, &wire_key);
+
+ if (ret)
+ return ret;
+ cmd->target.match_bits = wire_key | vni;
+ cmd->target.ignore_bits &= ~CXI_LE_VNI_MASK;
+ return 0;
+}
+
+static inline void cxi_le_recv(union c_cmdu *cmd, uint16_t ptlte_index, uint8_t lac, uint64_t iova,
+ uint64_t length)
+{
+ memset(cmd, 0, sizeof(*cmd));
+ cmd->command.opcode = C_CMD_TGT_APPEND;
+ cmd->target.ptlte_index = ptlte_index;
+ cmd->target.ptl_list = C_PTL_LIST_PRIORITY;
+ cmd->target.op_put = 1;
+ cmd->target.use_once = 1;
+ cmd->target.lac = lac;
+ cmd->target.start = iova;
+ cmd->target.length = length;
+ cmd->target.match_bits = CXI_LE_RECV_MATCH_BITS;
+ cmd->target.ignore_bits = 0;
+ cmd->target.match_id = CXI_MATCH_ID_ANY;
+}
+
+/*
+ * An attached region matches its rkey exactly: a region reachable by a
+ * narrow key is made that way at registration, so the key carries its own
+ * width. It persists until detached, and buffer_id names it for the unlink.
+ */
+static inline void cxi_le_region(union c_cmdu *cmd, uint16_t ptlte_index, uint64_t lkey64,
+ uint64_t rkey64, uint64_t iova, uint64_t length)
+{
+ memset(cmd, 0, sizeof(*cmd));
+ cmd->command.opcode = C_CMD_TGT_APPEND;
+ cmd->target.ptlte_index = ptlte_index;
+ cmd->target.ptl_list = C_PTL_LIST_PRIORITY;
+ cmd->target.op_put = 1;
+ cmd->target.op_get = 1;
+ cmd->target.lac = lkey64 & CXI_LKEY64_LAC_MASK;
+ cmd->target.start = iova;
+ cmd->target.length = length;
+ cmd->target.match_bits = rkey64;
+ cmd->target.ignore_bits = 0;
+ cmd->target.match_id = CXI_MATCH_ID_ANY;
+ cmd->target.use_once = 0;
+ cmd->target.buffer_id = (uint16_t)(rkey64 & 0xffff);
+}
+
+static inline void cxi_le_region_unlink(union c_cmdu *cmd, uint16_t ptlte_index, uint64_t rkey64)
+{
+ memset(cmd, 0, sizeof(*cmd));
+ cmd->command.opcode = C_CMD_TGT_UNLINK;
+ cmd->target.ptlte_index = ptlte_index;
+ cmd->target.ptl_list = C_PTL_LIST_PRIORITY;
+ cmd->target.buffer_id = (uint16_t)(rkey64 & 0xffff);
+}
+
+#endif /* CXI_LE_H */
--
2.56.0
next prev parent reply other threads:[~2026-10-31 19:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 19:25 [PATCH 00/12] cxiverbs: add the HPE Cassini verbs provider Doug Ledford
2026-10-31 19:25 ` [PATCH 01/12] libibverbs: add ibv_read_counters_ex() Doug Ledford
2026-10-31 19:25 ` [PATCH 02/12] libibverbs: permit jobs without an address table Doug Ledford
2026-10-31 19:25 ` [PATCH 03/12] libibverbs: support provider completion channels and Slingshot transport Doug Ledford
2026-10-31 19:25 ` [PATCH 04/12] cxiverbs: add the synchronized native hardware and verbs headers Doug Ledford
2026-10-31 19:25 ` [PATCH 05/12] cxiverbs: define the native direct-verbs resource interface Doug Ledford
2026-10-31 19:25 ` Doug Ledford [this message]
2026-10-31 19:26 ` [PATCH 07/12] cxiverbs: add the provider and device discovery Doug Ledford
2026-10-31 19:26 ` [PATCH 08/12] cxiverbs: implement UET verbs with explicit native ownership Doug Ledford
2026-10-31 19:26 ` [PATCH 09/12] cxiverbs: cover identity isolation and polling and event traffic Doug Ledford
2026-10-31 19:26 ` [PATCH 10/12] cxiverbs: launch Slurm-style exact VNI TC and resource grants Doug Ledford
2026-10-31 19:26 ` [PATCH 11/12] cxiverbs: wire and package the CXI verbs provider and tests Doug Ledford
2026-10-31 19:26 ` [PATCH 12/12] libibverbs: port RU examples to explicitly granted resources 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=20261031-cxi-for-next-v1-6-93ce01907ce2@hpe.com \
--to=doug.ledford@hpe.com \
--cc=iraimani.pavadai@hpe.com \
--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®