RDMA/core: Introduce a DMAH object and its alloc/free APIs

Introduce a new DMA handle (DMAH) object along with its corresponding
allocation and deallocation APIs.

This DMAH object encapsulates attributes intended for use in DMA
transactions.

While its initial purpose is to support TPH functionality, it is
designed to be extensible for future features such as DMA PCI multipath,
PCI UIO configurations, PCI traffic class selection, and more.

Further details:
----------------
We ensure that a caller requesting a DMA handle for a specific CPU ID is
permitted to be scheduled on it. This prevent a potential security issue
where a non privilege user may trigger DMA operations toward a CPU that
it's not allowed to run on.

We manage reference counting for the DMAH object and its consumers
(e.g., memory regions) as will be detailed in subsequent patches in the
series.

Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
Reviewed-by: Edward Srouji <edwards@nvidia.com>
Link: https://patch.msgid.link/2cad097e849597e49d6b61e6865dba878257f371.1752752567.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
Yishai Hadas
2025-07-23 01:42:10 -04:00
committed by Leon Romanovsky
parent 5b2e45049d
commit d83edab562
9 changed files with 200 additions and 0 deletions
+17
View File
@@ -55,6 +55,7 @@ enum uverbs_default_objects {
UVERBS_OBJECT_DM,
UVERBS_OBJECT_COUNTERS,
UVERBS_OBJECT_ASYNC_EVENT,
UVERBS_OBJECT_DMAH,
};
enum {
@@ -240,6 +241,22 @@ enum uverbs_methods_dm {
UVERBS_METHOD_DM_FREE,
};
enum uverbs_attrs_alloc_dmah_cmd_attr_ids {
UVERBS_ATTR_ALLOC_DMAH_HANDLE,
UVERBS_ATTR_ALLOC_DMAH_CPU_ID,
UVERBS_ATTR_ALLOC_DMAH_TPH_MEM_TYPE,
UVERBS_ATTR_ALLOC_DMAH_PH,
};
enum uverbs_attrs_free_dmah_cmd_attr_ids {
UVERBS_ATTR_FREE_DMA_HANDLE,
};
enum uverbs_methods_dmah {
UVERBS_METHOD_DMAH_ALLOC,
UVERBS_METHOD_DMAH_FREE,
};
enum uverbs_attrs_reg_dm_mr_cmd_attr_ids {
UVERBS_ATTR_REG_DM_MR_HANDLE,
UVERBS_ATTR_REG_DM_MR_OFFSET,