* [PATCH rdma-next 0/6] Introduce UCAP API and usage in mlx5
@ 2025-02-26 14:17 Leon Romanovsky
2025-02-26 14:17 ` [PATCH rdma-next 6/6] docs: infiniband: document the UCAP API Leon Romanovsky
0 siblings, 1 reply; 2+ messages in thread
From: Leon Romanovsky @ 2025-02-26 14:17 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Chiara Meiohas, Jonathan Corbet, linux-doc, linux-rdma,
Mark Bloch, Patrisious Haddad, Yishai Hadas
This series introduces the User CAPability (UCAP) API that allows
creating user contexts with various firmware privileges.
The UCAP API provides fine-grained control over specific firmware
features by representing each capability as a character device with root
read-write access. Root processes can grant users special privileges by
allowing access to these character devices. User contexts created using
a file descriptor of a UCAP will have specific UCAP privileges.
Two UCAP character devices are created for mlx5, and user contexts
opened with at least one of these UCAPs are considered privileged. To
ensure that privileged commands can always proceed, non-privileged
commands are limited when a privileged user is present on the device.
Thanks
Chiara Meiohas (5):
RDMA/uverbs: Introduce UCAP (User CAPabilities) API
RDMA/mlx5: Create UCAP char devices for supported device capabilities
RDMA/uverbs: Add support for UCAPs in context creation
RDMA/mlx5: Check enabled UCAPs when creating ucontext
docs: infiniband: document the UCAP API
Patrisious Haddad (1):
RDMA/mlx5: Expose RDMA TRANSPORT flow table types to userspace
Documentation/infiniband/index.rst | 1 +
Documentation/infiniband/ucaps.rst | 71 +++++
drivers/infiniband/core/Makefile | 3 +-
drivers/infiniband/core/ucaps.c | 255 ++++++++++++++++++
drivers/infiniband/core/uverbs_cmd.c | 19 ++
drivers/infiniband/core/uverbs_main.c | 2 +
.../infiniband/core/uverbs_std_types_device.c | 4 +
drivers/infiniband/hw/mlx5/devx.c | 31 ++-
drivers/infiniband/hw/mlx5/devx.h | 5 +-
drivers/infiniband/hw/mlx5/fs.c | 154 ++++++++++-
drivers/infiniband/hw/mlx5/fs.h | 2 +
drivers/infiniband/hw/mlx5/main.c | 77 +++++-
drivers/infiniband/hw/mlx5/mlx5_ib.h | 3 +
include/rdma/ib_ucaps.h | 25 ++
include/rdma/ib_verbs.h | 1 +
include/uapi/rdma/ib_user_ioctl_cmds.h | 1 +
include/uapi/rdma/mlx5_user_ioctl_cmds.h | 1 +
include/uapi/rdma/mlx5_user_ioctl_verbs.h | 2 +
18 files changed, 635 insertions(+), 22 deletions(-)
create mode 100644 Documentation/infiniband/ucaps.rst
create mode 100644 drivers/infiniband/core/ucaps.c
create mode 100644 include/rdma/ib_ucaps.h
--
2.48.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH rdma-next 6/6] docs: infiniband: document the UCAP API
2025-02-26 14:17 [PATCH rdma-next 0/6] Introduce UCAP API and usage in mlx5 Leon Romanovsky
@ 2025-02-26 14:17 ` Leon Romanovsky
0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2025-02-26 14:17 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Chiara Meiohas, Jonathan Corbet, linux-doc, linux-rdma,
Yishai Hadas
From: Chiara Meiohas <cmeiohas@nvidia.com>
Add an explanation on the newly added UCAP API.
Signed-off-by: Chiara Meiohas <cmeiohas@nvidia.com>
Reviewed-by: Yishai Hadas <yishaih@nvidia.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
---
Documentation/infiniband/index.rst | 1 +
Documentation/infiniband/ucaps.rst | 71 ++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+)
create mode 100644 Documentation/infiniband/ucaps.rst
diff --git a/Documentation/infiniband/index.rst b/Documentation/infiniband/index.rst
index 9cd7615438b9..5b4c24125f66 100644
--- a/Documentation/infiniband/index.rst
+++ b/Documentation/infiniband/index.rst
@@ -12,6 +12,7 @@ InfiniBand
opa_vnic
sysfs
tag_matching
+ ucaps
user_mad
user_verbs
diff --git a/Documentation/infiniband/ucaps.rst b/Documentation/infiniband/ucaps.rst
new file mode 100644
index 000000000000..b8b6927742f4
--- /dev/null
+++ b/Documentation/infiniband/ucaps.rst
@@ -0,0 +1,71 @@
+=================================
+Infiniband Userspace Capabilities
+=================================
+
+ User CAPabilities (UCAPs) provide fine-grained control over specific
+ firmware features in Infiniband (IB) devices. This approach offers
+ more granular capabilities than the existing Linux capabilities,
+ which may be too generic for certain FW features.
+
+ Each user capability is represented as a character device with root
+ read-write access. Root processes can grant users special privileges
+ by allowing access to these character devices (e.g., using chown).
+
+Usage
+=====
+
+ UCAPs allow control over specific features of an IB device using file
+ descriptors of UCAP character devices. Here is how a user enables
+ specific features of an IB device:
+
+ * A root process grants the user access to the UCAP files that
+ represents the capabilities (e.g., using chown).
+ * The user opens the UCAP files, obtaining file descriptors.
+ * When opening an IB device, include an array of the UCAP file
+ descriptors as an attribute.
+ * The ib_uverbs driver recognizes the UCAP file descriptors and enables
+ the corresponding capabilities for the IB device.
+
+Creating UCAPs
+==============
+
+ To create a new UCAP, drivers must first define a type in the
+ rdma_user_cap enum in rdma/ib_ucaps.h. The name of the UCAP character
+ device should be added to the ucap_names array in
+ drivers/infiniband/core/ucaps.c. Then, the driver can create the UCAP
+ character device by calling the ib_create_ucap API with the UCAP
+ type.
+
+ A reference count is stored for each UCAP to track creations and
+ removals of the UCAP device. If multiple creation calls are made with
+ the same type (e.g., for two IB devices), the UCAP character device
+ is created during the first call and subsequent calls increment the
+ reference count.
+
+ The UCAP character device is created under /dev/infiniband, and its
+ permissions are set to allow root read and write access only.
+
+Removing UCAPs
+==============
+
+ Each removal decrements the reference count of the UCAP. The UCAP
+ character device is removed from the filesystem only when the
+ reference count is decreased to 0.
+
+/dev and /sys/class files
+=========================
+
+ The class::
+
+ /sys/class/infiniband_ucaps
+
+ is created when the first UCAP character device is created.
+
+ The UCAP character device is created under /dev/infiniband.
+
+ For example, if mlx5_ib adds the rdma_user_cap
+ RDMA_UCAP_MLX5_CTRL_LOCAL with name "mlx5_perm_ctrl_local", this will
+ create the device node::
+
+ /dev/infiniband/mlx5_perm_ctrl_local
+
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-26 14:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-26 14:17 [PATCH rdma-next 0/6] Introduce UCAP API and usage in mlx5 Leon Romanovsky
2025-02-26 14:17 ` [PATCH rdma-next 6/6] docs: infiniband: document the UCAP API Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).