* [PATCH rdma-next 0/8] RDMA support for DMA handle
@ 2025-07-07 17:03 Leon Romanovsky
2025-07-07 17:03 ` [PATCH rdma-next 1/8] pci/tph: Expose pcie_tph_get_st_table_size() Leon Romanovsky
0 siblings, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2025-07-07 17:03 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Andrew Lunn, Bernard Metzler, Bjorn Helgaas, Bryan Tan,
Chengchang Tang, Cheng Xu, Christian Benvenuti,
Dennis Dalessandro, Edward Srouji, Eric Dumazet, Jakub Kicinski,
Junxian Huang, Kai Shen, Kalesh AP, Konstantin Taranov, linux-pci,
linux-rdma, Long Li, Michael Margolin, Michal Kalderon,
Moshe Shemesh, Mustafa Ismail, Nelson Escobar, netdev,
Paolo Abeni, Potnuri Bharat Teja, Saeed Mahameed, Selvin Xavier,
Tariq Toukan, Tatyana Nikolova, Vishnu Dasa, Yishai Hadas,
Zhu Yanjun
From Yishai,
This patch series introduces a new DMA Handle (DMAH) object, along with
corresponding APIs for its allocation and deallocation.
The DMAH object encapsulates attributes relevant for DMA transactions.
While initially intended to support TLP Processing Hints (TPH) [1], the
design is extensible to accommodate future features such as PCI
multipath for DMA, PCI UIO configurations, traffic class selection, and
more.
Additionally, we introduce a new ioctl method on the MR object:
UVERBS_METHOD_REG_MR.
This method consolidates multiple reg_mr variants under a single
user-space ioctl interface, supporting: ibv_reg_mr(), ibv_reg_mr_iova(),
ibv_reg_mr_iova2() and ibv_reg_dmabuf_mr(). It also enables passing a
DMA handle as part of the registration process.
Throughout the patch series, the following DMAH-related stuff can also
be observed in the IB layer:
- Association with a CPU ID and its memory type, for use with Steering
Tags [2].
- Inclusion of Processing Hints (PH) data for TPH functionality [3].
- Enforces security by ensuring that only tasks allowed to run on a
given CPU may request a DMA handle for it.
- Reference counting for DMAH life cycle management and safe usage
across memory regions.
mlx5 driver implementation:
--------------------------
The series includes implementation of the above functionality in the
mlx5 driver.
In mlx5_core:
- Enables TPH over PCIe when both firmware and OS support it.
- Manages Steering Tags and corresponding indices by writing tag values
to the PCI configuration space.
- Exposes APIs to upper layers (e.g., mlx5_ib) to enable the PCIe TPH
functionality.
In mlx5_ib:
- Adds full support for DMAH operations.
- Utilizes mlx5_core's Steering Tag APIs to derive tag indices from input.
- Stores the resulting index in a mlx5_dmah structure for use during
MKEY creation with a DMA handle.
- Adds support for allowing MKEYs to be created in conjunction with DMA
handles.
Additional details are provided in the commit messages.
[1] Background, from PCIe specification 6.2.
TLP Processing Hints (TPH)
--------------------------
TLP Processing Hints is an optional feature that provides hints in
Request TLP headers to facilitate optimized processing of Requests that
target Memory Space. These Processing Hints enable the system hardware
(e.g., the Root Complex and/ or Endpoints) to optimize platform
resources such as system and memory interconnect on a per TLP basis.
Steering Tags are system-specific values used to identify a processing
resource that a Requester explicitly targets. System software discovers
and identifies TPH capabilities to determine the Steering Tag allocation
for each Function that supports TPH
[2] Steering Tags
Functions that intend to target a TLP towards a specific processing
resource such as a host processor or system cache hierarchy require
topological information of the target cache (e.g., which host cache).
Steering Tags are system-specific values that provide information about
the host or cache structure in the system cache hierarchy. These values
are used to associate processing elements within the platform with the
processing of Requests.
[3] Processing Hints
The Requester provides hints to the Root Complex or other targets about
the intended use of data and data structures by the host and/or device.
The hints are provided by the Requester, which has knowledge of upcoming
Request patterns, and which the Completer would not be able to deduce
autonomously (with good accuracy)
Yishai
Yishai Hadas (8):
pci/tph: Expose pcie_tph_get_st_table_size()
net/mlx5: Expose IFC bits for TPH
net/mlx5: Add support for device steering tag
IB/core: Add UVERBS_METHOD_REG_MR on the MR object
RDMA/core: Introduce a DMAH object and its alloc/free APIs
RDMA/mlx5: Add DMAH object support
IB: Extend UVERBS_METHOD_REG_MR to get DMAH
RDMA/mlx5: Add DMAH support for reg_user_mr/reg_user_dmabuf_mr
drivers/infiniband/core/Makefile | 1 +
drivers/infiniband/core/device.c | 3 +
drivers/infiniband/core/rdma_core.h | 1 +
drivers/infiniband/core/restrack.c | 2 +
drivers/infiniband/core/uverbs_cmd.c | 2 +-
.../infiniband/core/uverbs_std_types_dmah.c | 151 ++++++++++++++++
drivers/infiniband/core/uverbs_std_types_mr.c | 170 +++++++++++++++++-
drivers/infiniband/core/uverbs_uapi.c | 1 +
drivers/infiniband/core/verbs.c | 5 +-
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 8 +
drivers/infiniband/hw/bnxt_re/ib_verbs.h | 2 +
drivers/infiniband/hw/cxgb4/iw_cxgb4.h | 1 +
drivers/infiniband/hw/cxgb4/mem.c | 6 +-
drivers/infiniband/hw/efa/efa.h | 2 +
drivers/infiniband/hw/efa/efa_verbs.c | 8 +
drivers/infiniband/hw/erdma/erdma_verbs.c | 6 +-
drivers/infiniband/hw/erdma/erdma_verbs.h | 3 +-
drivers/infiniband/hw/hns/hns_roce_device.h | 1 +
drivers/infiniband/hw/hns/hns_roce_mr.c | 4 +
drivers/infiniband/hw/irdma/verbs.c | 9 +
drivers/infiniband/hw/mana/mana_ib.h | 2 +
drivers/infiniband/hw/mana/mr.c | 8 +
drivers/infiniband/hw/mlx4/mlx4_ib.h | 1 +
drivers/infiniband/hw/mlx4/mr.c | 4 +
drivers/infiniband/hw/mlx5/Makefile | 1 +
drivers/infiniband/hw/mlx5/devx.c | 4 +
drivers/infiniband/hw/mlx5/dmah.c | 54 ++++++
drivers/infiniband/hw/mlx5/dmah.h | 23 +++
drivers/infiniband/hw/mlx5/main.c | 5 +
drivers/infiniband/hw/mlx5/mlx5_ib.h | 7 +
drivers/infiniband/hw/mlx5/mr.c | 103 +++++++++--
drivers/infiniband/hw/mlx5/odp.c | 1 +
drivers/infiniband/hw/mthca/mthca_provider.c | 6 +-
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 6 +-
drivers/infiniband/hw/ocrdma/ocrdma_verbs.h | 3 +-
drivers/infiniband/hw/qedr/verbs.c | 6 +-
drivers/infiniband/hw/qedr/verbs.h | 3 +-
drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 4 +
drivers/infiniband/hw/usnic/usnic_ib_verbs.h | 1 +
drivers/infiniband/hw/vmw_pvrdma/pvrdma_mr.c | 5 +
.../infiniband/hw/vmw_pvrdma/pvrdma_verbs.h | 1 +
drivers/infiniband/sw/rdmavt/mr.c | 5 +
drivers/infiniband/sw/rdmavt/mr.h | 1 +
drivers/infiniband/sw/rxe/rxe_verbs.c | 4 +
drivers/infiniband/sw/siw/siw_verbs.c | 7 +-
drivers/infiniband/sw/siw/siw_verbs.h | 3 +-
.../net/ethernet/mellanox/mlx5/core/Makefile | 5 +
.../net/ethernet/mellanox/mlx5/core/lib/st.c | 162 +++++++++++++++++
.../net/ethernet/mellanox/mlx5/core/main.c | 2 +
.../ethernet/mellanox/mlx5/core/mlx5_core.h | 9 +
drivers/pci/tph.c | 11 +-
include/linux/mlx5/driver.h | 20 +++
include/linux/mlx5/mlx5_ifc.h | 14 +-
include/linux/pci-tph.h | 1 +
include/rdma/ib_verbs.h | 31 ++++
include/rdma/restrack.h | 4 +
include/uapi/rdma/ib_user_ioctl_cmds.h | 32 ++++
57 files changed, 905 insertions(+), 40 deletions(-)
create mode 100644 drivers/infiniband/core/uverbs_std_types_dmah.c
create mode 100644 drivers/infiniband/hw/mlx5/dmah.c
create mode 100644 drivers/infiniband/hw/mlx5/dmah.h
create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/st.c
--
2.50.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH rdma-next 1/8] pci/tph: Expose pcie_tph_get_st_table_size()
2025-07-07 17:03 [PATCH rdma-next 0/8] RDMA support for DMA handle Leon Romanovsky
@ 2025-07-07 17:03 ` Leon Romanovsky
2025-07-07 19:40 ` Bjorn Helgaas
0 siblings, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2025-07-07 17:03 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: Yishai Hadas, Bjorn Helgaas, linux-pci
From: Yishai Hadas <yishaih@nvidia.com>
Expose pcie_tph_get_st_table_size() to be used by drivers as will be
done in the next patch from the series.
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/pci/tph.c | 11 ++++++-----
include/linux/pci-tph.h | 1 +
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
index 77fce5e1b830..cc64f93709a4 100644
--- a/drivers/pci/tph.c
+++ b/drivers/pci/tph.c
@@ -168,7 +168,7 @@ static u32 get_st_table_loc(struct pci_dev *pdev)
* Return the size of ST table. If ST table is not in TPH Requester Extended
* Capability space, return 0. Otherwise return the ST Table Size + 1.
*/
-static u16 get_st_table_size(struct pci_dev *pdev)
+u16 pcie_tph_get_st_table_size(struct pci_dev *pdev)
{
u32 reg;
u32 loc;
@@ -185,6 +185,7 @@ static u16 get_st_table_size(struct pci_dev *pdev)
return FIELD_GET(PCI_TPH_CAP_ST_MASK, reg) + 1;
}
+EXPORT_SYMBOL(pcie_tph_get_st_table_size);
/* Return device's Root Port completer capability */
static u8 get_rp_completer_type(struct pci_dev *pdev)
@@ -211,7 +212,7 @@ static int write_tag_to_st_table(struct pci_dev *pdev, int index, u16 tag)
int offset;
/* Check if index is out of bound */
- st_table_size = get_st_table_size(pdev);
+ st_table_size = pcie_tph_get_st_table_size(pdev);
if (index >= st_table_size)
return -ENXIO;
@@ -443,7 +444,7 @@ void pci_restore_tph_state(struct pci_dev *pdev)
pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, *cap++);
st_entry = (u16 *)cap;
offset = PCI_TPH_BASE_SIZEOF;
- num_entries = get_st_table_size(pdev);
+ num_entries = pcie_tph_get_st_table_size(pdev);
for (i = 0; i < num_entries; i++) {
pci_write_config_word(pdev, pdev->tph_cap + offset,
*st_entry++);
@@ -475,7 +476,7 @@ void pci_save_tph_state(struct pci_dev *pdev)
/* Save all ST entries in extended capability structure */
st_entry = (u16 *)cap;
offset = PCI_TPH_BASE_SIZEOF;
- num_entries = get_st_table_size(pdev);
+ num_entries = pcie_tph_get_st_table_size(pdev);
for (i = 0; i < num_entries; i++) {
pci_read_config_word(pdev, pdev->tph_cap + offset,
st_entry++);
@@ -499,7 +500,7 @@ void pci_tph_init(struct pci_dev *pdev)
if (!pdev->tph_cap)
return;
- num_entries = get_st_table_size(pdev);
+ num_entries = pcie_tph_get_st_table_size(pdev);
save_size = sizeof(u32) + num_entries * sizeof(u16);
pci_add_ext_cap_save_buffer(pdev, PCI_EXT_CAP_ID_TPH, save_size);
}
diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h
index c3e806c13d64..9e4e331b1603 100644
--- a/include/linux/pci-tph.h
+++ b/include/linux/pci-tph.h
@@ -28,6 +28,7 @@ int pcie_tph_get_cpu_st(struct pci_dev *dev,
unsigned int cpu_uid, u16 *tag);
void pcie_disable_tph(struct pci_dev *pdev);
int pcie_enable_tph(struct pci_dev *pdev, int mode);
+u16 pcie_tph_get_st_table_size(struct pci_dev *pdev);
#else
static inline int pcie_tph_set_st_entry(struct pci_dev *pdev,
unsigned int index, u16 tag)
--
2.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH rdma-next 1/8] pci/tph: Expose pcie_tph_get_st_table_size()
2025-07-07 17:03 ` [PATCH rdma-next 1/8] pci/tph: Expose pcie_tph_get_st_table_size() Leon Romanovsky
@ 2025-07-07 19:40 ` Bjorn Helgaas
2025-07-07 19:59 ` Leon Romanovsky
0 siblings, 1 reply; 5+ messages in thread
From: Bjorn Helgaas @ 2025-07-07 19:40 UTC (permalink / raw)
To: Leon Romanovsky; +Cc: Jason Gunthorpe, Yishai Hadas, Bjorn Helgaas, linux-pci
On Mon, Jul 07, 2025 at 08:03:01PM +0300, Leon Romanovsky wrote:
> From: Yishai Hadas <yishaih@nvidia.com>
>
> Expose pcie_tph_get_st_table_size() to be used by drivers as will be
> done in the next patch from the series.
This series doesn't actually use pcie_tph_get_st_table_size().
Subject line convention would be "PCI/TPH: Expose ..."
> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
> drivers/pci/tph.c | 11 ++++++-----
> include/linux/pci-tph.h | 1 +
> 2 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
> index 77fce5e1b830..cc64f93709a4 100644
> --- a/drivers/pci/tph.c
> +++ b/drivers/pci/tph.c
> @@ -168,7 +168,7 @@ static u32 get_st_table_loc(struct pci_dev *pdev)
> * Return the size of ST table. If ST table is not in TPH Requester Extended
> * Capability space, return 0. Otherwise return the ST Table Size + 1.
> */
> -static u16 get_st_table_size(struct pci_dev *pdev)
> +u16 pcie_tph_get_st_table_size(struct pci_dev *pdev)
> {
> u32 reg;
> u32 loc;
> @@ -185,6 +185,7 @@ static u16 get_st_table_size(struct pci_dev *pdev)
>
> return FIELD_GET(PCI_TPH_CAP_ST_MASK, reg) + 1;
> }
> +EXPORT_SYMBOL(pcie_tph_get_st_table_size);
>
> /* Return device's Root Port completer capability */
> static u8 get_rp_completer_type(struct pci_dev *pdev)
> @@ -211,7 +212,7 @@ static int write_tag_to_st_table(struct pci_dev *pdev, int index, u16 tag)
> int offset;
>
> /* Check if index is out of bound */
> - st_table_size = get_st_table_size(pdev);
> + st_table_size = pcie_tph_get_st_table_size(pdev);
> if (index >= st_table_size)
> return -ENXIO;
>
> @@ -443,7 +444,7 @@ void pci_restore_tph_state(struct pci_dev *pdev)
> pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, *cap++);
> st_entry = (u16 *)cap;
> offset = PCI_TPH_BASE_SIZEOF;
> - num_entries = get_st_table_size(pdev);
> + num_entries = pcie_tph_get_st_table_size(pdev);
> for (i = 0; i < num_entries; i++) {
> pci_write_config_word(pdev, pdev->tph_cap + offset,
> *st_entry++);
> @@ -475,7 +476,7 @@ void pci_save_tph_state(struct pci_dev *pdev)
> /* Save all ST entries in extended capability structure */
> st_entry = (u16 *)cap;
> offset = PCI_TPH_BASE_SIZEOF;
> - num_entries = get_st_table_size(pdev);
> + num_entries = pcie_tph_get_st_table_size(pdev);
> for (i = 0; i < num_entries; i++) {
> pci_read_config_word(pdev, pdev->tph_cap + offset,
> st_entry++);
> @@ -499,7 +500,7 @@ void pci_tph_init(struct pci_dev *pdev)
> if (!pdev->tph_cap)
> return;
>
> - num_entries = get_st_table_size(pdev);
> + num_entries = pcie_tph_get_st_table_size(pdev);
> save_size = sizeof(u32) + num_entries * sizeof(u16);
> pci_add_ext_cap_save_buffer(pdev, PCI_EXT_CAP_ID_TPH, save_size);
> }
> diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h
> index c3e806c13d64..9e4e331b1603 100644
> --- a/include/linux/pci-tph.h
> +++ b/include/linux/pci-tph.h
> @@ -28,6 +28,7 @@ int pcie_tph_get_cpu_st(struct pci_dev *dev,
> unsigned int cpu_uid, u16 *tag);
> void pcie_disable_tph(struct pci_dev *pdev);
> int pcie_enable_tph(struct pci_dev *pdev, int mode);
> +u16 pcie_tph_get_st_table_size(struct pci_dev *pdev);
> #else
> static inline int pcie_tph_set_st_entry(struct pci_dev *pdev,
> unsigned int index, u16 tag)
> --
> 2.50.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH rdma-next 1/8] pci/tph: Expose pcie_tph_get_st_table_size()
2025-07-07 19:40 ` Bjorn Helgaas
@ 2025-07-07 19:59 ` Leon Romanovsky
2025-07-07 22:46 ` Bjorn Helgaas
0 siblings, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2025-07-07 19:59 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: Jason Gunthorpe, Yishai Hadas, Bjorn Helgaas, linux-pci
On Mon, Jul 07, 2025 at 02:40:49PM -0500, Bjorn Helgaas wrote:
> On Mon, Jul 07, 2025 at 08:03:01PM +0300, Leon Romanovsky wrote:
> > From: Yishai Hadas <yishaih@nvidia.com>
> >
> > Expose pcie_tph_get_st_table_size() to be used by drivers as will be
> > done in the next patch from the series.
>
> This series doesn't actually use pcie_tph_get_st_table_size().
It is in use in patch [PATCH mlx5-next 3/8] net/mlx5: Add support for device steering tag
https://lore.kernel.org/all/dc4c7f6ba34e6beaf95a3c4f9c2e122925be97c9.1751907231.git.leon@kernel.org/
>
> Subject line convention would be "PCI/TPH: Expose ..."
Sure, I can fix when applying it.
Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH rdma-next 1/8] pci/tph: Expose pcie_tph_get_st_table_size()
2025-07-07 19:59 ` Leon Romanovsky
@ 2025-07-07 22:46 ` Bjorn Helgaas
0 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2025-07-07 22:46 UTC (permalink / raw)
To: Leon Romanovsky; +Cc: Jason Gunthorpe, Yishai Hadas, Bjorn Helgaas, linux-pci
On Mon, Jul 07, 2025 at 10:59:03PM +0300, Leon Romanovsky wrote:
> On Mon, Jul 07, 2025 at 02:40:49PM -0500, Bjorn Helgaas wrote:
> > On Mon, Jul 07, 2025 at 08:03:01PM +0300, Leon Romanovsky wrote:
> > > From: Yishai Hadas <yishaih@nvidia.com>
> > >
> > > Expose pcie_tph_get_st_table_size() to be used by drivers as will be
> > > done in the next patch from the series.
> >
> > This series doesn't actually use pcie_tph_get_st_table_size().
>
> It is in use in patch [PATCH mlx5-next 3/8] net/mlx5: Add support for device steering tag
> https://lore.kernel.org/all/dc4c7f6ba34e6beaf95a3c4f9c2e122925be97c9.1751907231.git.leon@kernel.org/
Oops, sorry, dunno how I missed that.
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-07 22:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-07 17:03 [PATCH rdma-next 0/8] RDMA support for DMA handle Leon Romanovsky
2025-07-07 17:03 ` [PATCH rdma-next 1/8] pci/tph: Expose pcie_tph_get_st_table_size() Leon Romanovsky
2025-07-07 19:40 ` Bjorn Helgaas
2025-07-07 19:59 ` Leon Romanovsky
2025-07-07 22:46 ` Bjorn Helgaas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox