RDMA support for DMA handle
Subsystems (21)
cover RDMA support for DMA handle
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
Signature · 1 line
2.50.0
PATCH 1/8 pci/tph: Expose pcie_tph_get_st_table_size()
From: Yishai Hadas <[email protected]>
Expose pcie_tph_get_st_table_size() to be used by drivers as will be done in the next patch from the series.
--- drivers/pci/tph.c | 11 ++++++----- include/linux/pci-tph.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/pci/tph.c +6 -5
@@ -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); }
include/linux/pci-tph.h +1 -0
@@ -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)
Signature · 1 line
2.50.0
Re: [PATCH rdma-next 1/8] pci/tph: Expose pcie_tph_get_st_table_size()
Quoted 4 lines · Leon Romanovsky
From: Yishai Hadas <[email protected]>
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 ..."
Quoted 79 lines
Signed-off-by Yishai Hadas <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>--- drivers/pci/tph.c | 11 ++++++----- include/linux/pci-tph.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-)drivers/pci/tph.c +6
-5@@ -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); }include/linux/pci-tph.h +1
-0@@ -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)Signature · 1 line
2.50.0
Re: [PATCH rdma-next 1/8] pci/tph: Expose pcie_tph_get_st_table_size()
Quoted 7 lines · Bjorn Helgaas
Quoted 4 lines · Leon Romanovsky
From: Yishai Hadas <[email protected]>
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/
Quoted 2 lines
Subject line convention would be "PCI/TPH: Expose ..."
Sure, I can fix when applying it.
Thanks
Bjorn Helgaas
Acked-byRe: [PATCH rdma-next 1/8] pci/tph: Expose pcie_tph_get_st_table_size()
Quoted 11 lines · Leon Romanovsky
Quoted 7 lines · Bjorn Helgaas
Quoted 4 lines · Leon Romanovsky
From: Yishai Hadas <[email protected]>
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.
PATCH 2/8 net/mlx5: Expose IFC bits for TPH
In reply to Leon RomanovskyFrom: Yishai Hadas <[email protected]>
Expose IFC bits for the TPH functionality.
--- include/linux/mlx5/mlx5_ifc.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
include/linux/mlx5/mlx5_ifc.h +12 -2
@@ -1859,7 +1859,9 @@ struct mlx5_ifc_cmd_hca_cap_bits {u8 reserved_at_280[0x10 ];u8 max_wqe_sz_sq[0x10 ]; -u8 reserved_at_2a0[0xb ]; +u8 reserved_at_2a0[0x7 ]; +u8 mkey_pcie_tph[0x1 ]; +u8 reserved_at_2a8[0x3 ];u8 shampo[0x1 ];u8 reserved_at_2ac[0x4 ];u8 max_wqe_sz_rq[0x10 ];
@@ -4404,6 +4406,10 @@ enum { MLX5_MKC_ACCESS_MODE_CROSSING = 0x6, }; +enum { +MLX5_MKC_PCIE_TPH_NO_STEERING_TAG_INDEX =0 , +}; +struct mlx5_ifc_mkc_bits {u8 reserved_at_0[0x1 ];u8 free[0x1 ];
@@ -4455,7 +4461,11 @@ struct mlx5_ifc_mkc_bits {u8 relaxed_ordering_read[0x1 ];u8 log_page_size[0x6 ]; -u8 reserved_at_1e0[0x20 ]; +u8 reserved_at_1e0[0x5 ]; +u8 pcie_tph_en[0x1 ]; +u8 pcie_tph_ph[0x2 ]; +u8 pcie_tph_steering_tag_index[0x8 ]; +u8 reserved_at_1f0[0x10 ]; };struct mlx5_ifc_pkey_bits {
Signature · 1 line
2.50.0
PATCH 3/8 net/mlx5: Add support for device steering tag
In reply to Leon RomanovskyFrom: Yishai Hadas <[email protected]>
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.
This patch adds steering tag support for mlx5 based NICs by:
- Enabling the TPH functionality over PCI if both FW and OS support it.
- Managing steering tags and their matching steering indexes by writing a ST to an ST index over the PCI configuration space.
- Exposing APIs to upper layers (e.g.,mlx5_ib) to allow usage of the PCI TPH infrastructure.
Further details:
- Upon probing of a device, the feature will be enabled based on both capability detection and OS support.
- It will retrieve the appropriate ST for a given CPU ID and memory type using the pcie_tph_get_cpu_st() API.
- It will track available ST indices according to the configuration space table size (expected to be 63 entries), reserving index 0 to indicate non-TPH use.
- It will assign a free ST index with a ST using the pcie_tph_set_st_entry() API.
- It will reuse the same index for identical (CPU ID + memory type) combinations by maintaining a reference count per entry.
- It will expose APIs to upper layers (e.g., mlx5_ib) to allow usage of the PCI TPH infrastructure.
- SF will use its parent PF stuff.
--- .../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 + include/linux/mlx5/driver.h | 20 +++ 5 files changed, 198 insertions(+) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/st.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +5 -0
@@ -167,5 +167,10 @@ mlx5_core-$(CONFIG_MLX5_SF) += sf/vhca_event.o sf/dev/dev.o sf/dev/driver.o irq_ # mlx5_core-$(CONFIG_MLX5_SF_MANAGER) += sf/cmd.o sf/hw_table.o sf/devlink.o +# +# TPH support +# +mlx5_core-$(CONFIG_PCIE_TPH) += lib/st.o + obj-$(CONFIG_MLX5_DPLL) += mlx5_dpll.o mlx5_dpll-y := dpll.o
drivers/net/ethernet/mellanox/mlx5/core/lib/st.c new file +162 -0
162 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/main.c +2 -0
@@ -1102,6 +1102,7 @@ static int mlx5_init_once(struct mlx5_core_dev *dev) } dev->dm =mlx5_dm_create (dev); + dev->st =mlx5_st_create (dev); dev->tracer =mlx5_fw_tracer_create (dev); dev->hv_vhca =mlx5_hv_vhca_create (dev); dev->rsc_dump =mlx5_rsc_dump_create (dev);
@@ -1150,6 +1151,7 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev)mlx5_rsc_dump_destroy (dev);mlx5_hv_vhca_destroy (dev->hv_vhca);mlx5_fw_tracer_destroy (dev->tracer); +mlx5_st_destroy (dev);mlx5_dm_cleanup (dev);mlx5_fs_core_free (dev);mlx5_sf_table_cleanup (dev);
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +9 -0
@@ -300,6 +300,15 @@ int mlx5_set_mtppse(struct mlx5_core_dev *mdev, u8 pin, u8 arm, u8 mode);struct mlx5_dm *mlx5_dm_create (struct mlx5_core_dev *dev);void mlx5_dm_cleanup (struct mlx5_core_dev *dev); +#ifdef CONFIG_PCIE_TPH +struct mlx5_st *mlx5_st_create (struct mlx5_core_dev *dev); +void mlx5_st_destroy (struct mlx5_core_dev *dev); +#else +static inline struct mlx5_st * +mlx5_st_create (struct mlx5_core_dev *dev) {return NULL ; } +static inline void mlx5_st_destroy (struct mlx5_core_dev *dev) {return ; } +#endif +void mlx5_toggle_port_link (struct mlx5_core_dev *dev);int mlx5_set_port_admin_status (struct mlx5_core_dev *dev,enum mlx5_port_status status);
include/linux/mlx5/driver.h +20 -0
@@ -36,6 +36,7 @@#include <linux/kernel.h> #include <linux/completion.h> #include <linux/pci.h> +#include <linux/pci-tph.h> #include <linux/irq.h> #include <linux/spinlock_types.h> #include <linux/semaphore.h>
@@ -688,6 +689,7 @@ struct mlx5_fw_tracer;struct mlx5_vxlan ;struct mlx5_geneve ;struct mlx5_hv_vhca ; +struct mlx5_st ;#define MLX5_LOG_SW_ICM_BLOCK_SIZE (dev) (MLX5_CAP_DEV_MEM(dev, log_sw_icm_alloc_granularity))#define MLX5_SW_ICM_BLOCK_SIZE (dev) (1 << MLX5_LOG_SW_ICM_BLOCK_SIZE(dev))
@@ -757,6 +759,7 @@ struct mlx5_core_dev {u32 issi;struct mlx5e_resources mlx5e_res;struct mlx5_dm *dm; +struct mlx5_st *st;struct mlx5_vxlan *vxlan;struct mlx5_geneve *geneve;struct {
@@ -1160,6 +1163,23 @@ int mlx5_dm_sw_icm_alloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type type,int mlx5_dm_sw_icm_dealloc (struct mlx5_core_dev *dev,enum mlx5_sw_icm_type type,u64 length,u16 uid,phys_addr_t addr,u32 obj_id); +#ifdef CONFIG_PCIE_TPH +int mlx5_st_alloc_index (struct mlx5_core_dev *dev,enum tph_mem_type mem_type, +unsigned int cpu_uid,u16 *st_index); +int mlx5_st_dealloc_index (struct mlx5_core_dev *dev,u16 st_index); +#else +static inline int mlx5_st_alloc_index (struct mlx5_core_dev *dev, +enum tph_mem_type mem_type, +unsigned int cpu_uid,u16 *st_index) +{ +return -EOPNOTSUPP ; +} +static inline int mlx5_st_dealloc_index (struct mlx5_core_dev *dev,u16 st_index) +{ +return -EOPNOTSUPP ; +} +#endif +struct mlx5_core_dev *mlx5_vf_get_core_dev (struct pci_dev *pdev);void mlx5_vf_put_core_dev (struct mlx5_core_dev *mdev);
Signature · 1 line
2.50.0
Re: [PATCH mlx5-next 3/8] net/mlx5: Add support for device steering tag
Quoted 56 lines · Leon Romanovsky
From: Yishai Hadas <[email protected]>
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.This patch adds steering tag support for mlx5 based NICs by:
- Enabling the TPH functionality over PCI if both FW and OS support it.
- Managing steering tags and their matching steering indexes by writing a ST to an ST index over the PCI configuration space.
- Exposing APIs to upper layers (e.g.,mlx5_ib) to allow usage of the PCI TPH infrastructure.Further details:
- Upon probing of a device, the feature will be enabled based on both capability detection and OS support.- It will retrieve the appropriate ST for a given CPU ID and memory type using the
pcie_tph_get_cpu_st()API.- It will track available ST indices according to the configuration space table size (expected to be 63 entries), reserving index 0 to indicate non-TPH use.
- It will assign a free ST index with a ST using the
pcie_tph_set_st_entry()API.- It will reuse the same index for identical (CPU ID + memory type) combinations by maintaining a reference count per entry.
- It will expose APIs to upper layers (e.g.,
mlx5_ib) to allow usage of the PCI TPH infrastructure.- SF will use its parent PF stuff.
Signed-off-by Yishai Hadas <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>--- .../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 + include/linux/mlx5/driver.h | 20 +++ 5 files changed, 198 insertions(+) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/st.c
<...>
drivers/net/ethernet/mellanox/mlx5/core/lib/st.c line 34
Quoted 1 line
drivers/net/ethernet/mellanox/mlx5/core/lib/st.c new file +1
-0+if (mlx5_core_is_sf (dev))
Somehow this line was lost during rebase.
This should be if (IS_ENABLED(CONFIG_MLX5_SF) && mlx5_core_is_sf(dev))
Thanks
PATCH 4/8 IB/core: Add UVERBS_METHOD_REG_MR on the MR object
In reply to Leon RomanovskyFrom: Yishai Hadas <[email protected]>
This new method enables us to use a single ioctl from user space which supports the below variants of reg_mr [1].
The method will be extended in the next patches from the series with an extra attribute to let us pass DMA handle to be used as part of the registration.
[1] ibv_reg_mr(), ibv_reg_mr_iova(), ibv_reg_mr_iova2(), ibv_reg_dmabuf_mr().
--- drivers/infiniband/core/uverbs_std_types_mr.c | 153 +++++++++++++++++- include/uapi/rdma/ib_user_ioctl_cmds.h | 14 ++ 2 files changed, 166 insertions(+), 1 deletion(-)
drivers/infiniband/core/uverbs_std_types_mr.c +152 -1
@@ -266,6 +266,122 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_DMABUF_MR)(return ret; } +static int UVERBS_HANDLER (UVERBS_METHOD_REG_MR )( +struct uverbs_attr_bundle *attrs) +{ +struct ib_uobject *uobj = +uverbs_attr_get_uobject (attrs,UVERBS_ATTR_REG_MR_HANDLE ); +struct ib_pd *pd = +uverbs_attr_get_obj (attrs,UVERBS_ATTR_REG_MR_PD_HANDLE ); +u32 valid_access_flags =IB_ACCESS_SUPPORTED ; +u64 length, iova, fd_offset =0 , addr =0 ; +struct ib_device *ib_dev = pd->device; +bool has_fd_offset = false; +bool has_addr = false; +bool has_fd = false; +u32 access_flags; +struct ib_mr *mr; +int fd; +int ret; + + ret =uverbs_copy_from (&iova, attrs,UVERBS_ATTR_REG_MR_IOVA ); +if (ret) +return ret; + + ret =uverbs_copy_from (&length, attrs,UVERBS_ATTR_REG_MR_LENGTH ); +if (ret) +return ret; + +if (uverbs_attr_is_valid (attrs,UVERBS_ATTR_REG_MR_ADDR )) { + ret =uverbs_copy_from (&addr, attrs, +UVERBS_ATTR_REG_MR_ADDR ); +if (ret) +return ret; + has_addr = true; + } + +if (uverbs_attr_is_valid (attrs,UVERBS_ATTR_REG_MR_FD_OFFSET )) { + ret =uverbs_copy_from (&fd_offset, attrs, +UVERBS_ATTR_REG_MR_FD_OFFSET ); +if (ret) +return ret; + has_fd_offset = true; + } + +if (uverbs_attr_is_valid (attrs,UVERBS_ATTR_REG_MR_FD )) { + ret =uverbs_get_raw_fd (&fd, attrs, +UVERBS_ATTR_REG_MR_FD ); +if (ret) +return ret; + has_fd = true; + } + +if (has_fd) { +if (!ib_dev->ops.reg_user_mr_dmabuf) +return -EOPNOTSUPP ; + +/* FD requires offset and can't come with addr */ +if (!has_fd_offset || has_addr) +return -EINVAL ; + +if ((fd_offset & ~PAGE_MASK ) != (iova & ~PAGE_MASK )) +return -EINVAL ; + + valid_access_flags =IB_ACCESS_LOCAL_WRITE | +IB_ACCESS_REMOTE_READ | +IB_ACCESS_REMOTE_WRITE | +IB_ACCESS_REMOTE_ATOMIC | +IB_ACCESS_RELAXED_ORDERING ; + }else { +if (!has_addr || has_fd_offset) +return -EINVAL ; + +if ((addr & ~PAGE_MASK ) != (iova & ~PAGE_MASK )) +return -EINVAL ; + } + + ret =uverbs_get_flags32 (&access_flags, attrs, +UVERBS_ATTR_REG_MR_ACCESS_FLAGS , + valid_access_flags); +if (ret) +return ret; + + ret =ib_check_mr_access (ib_dev, access_flags); +if (ret) +return ret; + +if (has_fd) + mr = pd->device->ops.reg_user_mr_dmabuf (pd, fd_offset, length, iova, + fd, access_flags, attrs); +else + mr = pd->device->ops.reg_user_mr (pd, addr, length, + iova, access_flags,NULL ); + +if (IS_ERR (mr)) +return PTR_ERR (mr); + + mr->device = pd->device; + mr->pd = pd; + mr->type =IB_MR_TYPE_USER ; + mr->uobject = uobj; +atomic_inc (&pd->usecnt); +rdma_restrack_new (&mr->res,RDMA_RESTRACK_MR ); +rdma_restrack_set_name (&mr->res,NULL ); +rdma_restrack_add (&mr->res); + uobj->object = mr; + +uverbs_finalize_uobj_create (attrs,UVERBS_ATTR_REG_MR_HANDLE ); + + ret =uverbs_copy_to (attrs,UVERBS_ATTR_REG_MR_RESP_LKEY , + &mr->lkey,sizeof (mr->lkey)); +if (ret) +return ret; + + ret =uverbs_copy_to (attrs,UVERBS_ATTR_REG_MR_RESP_RKEY , + &mr->rkey,sizeof (mr->rkey)); +return ret; +} + DECLARE_UVERBS_NAMED_METHOD( UVERBS_METHOD_ADVISE_MR, UVERBS_ATTR_IDR(UVERBS_ATTR_ADVISE_MR_PD_HANDLE,
@@ -362,6 +478,40 @@ DECLARE_UVERBS_NAMED_METHOD(UVERBS_ATTR_TYPE (u32), UA_MANDATORY)); +DECLARE_UVERBS_NAMED_METHOD ( +UVERBS_METHOD_REG_MR , +UVERBS_ATTR_IDR (UVERBS_ATTR_REG_MR_HANDLE , +UVERBS_OBJECT_MR , +UVERBS_ACCESS_NEW , +UA_MANDATORY ), +UVERBS_ATTR_IDR (UVERBS_ATTR_REG_MR_PD_HANDLE , +UVERBS_OBJECT_PD , +UVERBS_ACCESS_READ , +UA_MANDATORY ), +UVERBS_ATTR_PTR_IN (UVERBS_ATTR_REG_MR_IOVA , +UVERBS_ATTR_TYPE (u64), +UA_MANDATORY ), +UVERBS_ATTR_PTR_IN (UVERBS_ATTR_REG_MR_LENGTH , +UVERBS_ATTR_TYPE (u64), +UA_MANDATORY ), +UVERBS_ATTR_FLAGS_IN (UVERBS_ATTR_REG_MR_ACCESS_FLAGS , + enum ib_access_flags, +UA_MANDATORY ), +UVERBS_ATTR_PTR_IN (UVERBS_ATTR_REG_MR_ADDR , +UVERBS_ATTR_TYPE (u64), +UA_OPTIONAL ), +UVERBS_ATTR_PTR_IN (UVERBS_ATTR_REG_MR_FD_OFFSET , +UVERBS_ATTR_TYPE (u64), +UA_OPTIONAL ), +UVERBS_ATTR_RAW_FD (UVERBS_ATTR_REG_MR_FD , +UA_OPTIONAL ), +UVERBS_ATTR_PTR_OUT (UVERBS_ATTR_REG_MR_RESP_LKEY , +UVERBS_ATTR_TYPE (u32), +UA_MANDATORY ), +UVERBS_ATTR_PTR_OUT (UVERBS_ATTR_REG_MR_RESP_RKEY , +UVERBS_ATTR_TYPE (u32), +UA_MANDATORY )); + DECLARE_UVERBS_NAMED_METHOD_DESTROY( UVERBS_METHOD_MR_DESTROY, UVERBS_ATTR_IDR(UVERBS_ATTR_DESTROY_MR_HANDLE,
@@ -376,7 +526,8 @@ DECLARE_UVERBS_NAMED_OBJECT( &UVERBS_METHOD(UVERBS_METHOD_DM_MR_REG), &UVERBS_METHOD(UVERBS_METHOD_MR_DESTROY), &UVERBS_METHOD(UVERBS_METHOD_QUERY_MR), - &UVERBS_METHOD(UVERBS_METHOD_REG_DMABUF_MR)); + &UVERBS_METHOD(UVERBS_METHOD_REG_DMABUF_MR), + &UVERBS_METHOD(UVERBS_METHOD_REG_MR));const struct uapi_definition uverbs_def_obj_mr[] = { UAPI_DEF_CHAIN_OBJ_TREE_NAMED(UVERBS_OBJECT_MR,
include/uapi/rdma/ib_user_ioctl_cmds.h +14 -0
@@ -253,6 +253,7 @@ enum uverbs_methods_mr {UVERBS_METHOD_ADVISE_MR ,UVERBS_METHOD_QUERY_MR ,UVERBS_METHOD_REG_DMABUF_MR , + UVERBS_METHOD_REG_MR, }; enum uverbs_attrs_mr_destroy_ids {
@@ -286,6 +287,19 @@ enum uverbs_attrs_reg_dmabuf_mr_cmd_attr_ids { UVERBS_ATTR_REG_DMABUF_MR_RESP_RKEY, }; +enum uverbs_attrs_reg_mr_cmd_attr_ids { +UVERBS_ATTR_REG_MR_HANDLE , +UVERBS_ATTR_REG_MR_PD_HANDLE , +UVERBS_ATTR_REG_MR_IOVA , +UVERBS_ATTR_REG_MR_ADDR , +UVERBS_ATTR_REG_MR_LENGTH , +UVERBS_ATTR_REG_MR_ACCESS_FLAGS , +UVERBS_ATTR_REG_MR_FD , +UVERBS_ATTR_REG_MR_FD_OFFSET , +UVERBS_ATTR_REG_MR_RESP_LKEY , +UVERBS_ATTR_REG_MR_RESP_RKEY , +}; +enum uverbs_attrs_create_counters_cmd_attr_ids {UVERBS_ATTR_CREATE_COUNTERS_HANDLE , };
Signature · 1 line
2.50.0
PATCH 5/8 RDMA/core: Introduce a DMAH object and its alloc/free APIs
In reply to Leon RomanovskyFrom: Yishai Hadas <[email protected]>
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 privileged 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.
--- drivers/infiniband/core/Makefile | 1 + drivers/infiniband/core/device.c | 3 + drivers/infiniband/core/rdma_core.h | 1 + drivers/infiniband/core/restrack.c | 2 + .../infiniband/core/uverbs_std_types_dmah.c | 151 ++++++++++++++++++ drivers/infiniband/core/uverbs_uapi.c | 1 + include/rdma/ib_verbs.h | 28 ++++ include/rdma/restrack.h | 4 + include/uapi/rdma/ib_user_ioctl_cmds.h | 17 ++ 9 files changed, 208 insertions(+) create mode 100644 drivers/infiniband/core/uverbs_std_types_dmah.c
drivers/infiniband/core/Makefile +1 -0
@@ -33,6 +33,7 @@ ib_umad-y := user_mad.o ib_uverbs-y := uverbs_main.o uverbs_cmd.o uverbs_marshall.o \ rdma_core.o uverbs_std_types.o uverbs_ioctl.o \ uverbs_std_types_cq.o \ + uverbs_std_types_dmah.o \ uverbs_std_types_flow_action.o uverbs_std_types_dm.o \ uverbs_std_types_mr.o uverbs_std_types_counters.o \ uverbs_uapi.o uverbs_std_types_device.o \
drivers/infiniband/core/device.c +3 -0
@@ -2708,6 +2708,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)SET_DEVICE_OP (dev_ops, add_sub_dev);SET_DEVICE_OP (dev_ops, advise_mr);SET_DEVICE_OP (dev_ops, alloc_dm); +SET_DEVICE_OP (dev_ops, alloc_dmah);SET_DEVICE_OP (dev_ops, alloc_hw_device_stats);SET_DEVICE_OP (dev_ops, alloc_hw_port_stats);SET_DEVICE_OP (dev_ops, alloc_mr);
@@ -2735,6 +2736,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)SET_DEVICE_OP (dev_ops, create_user_ah);SET_DEVICE_OP (dev_ops, create_wq);SET_DEVICE_OP (dev_ops, dealloc_dm); +SET_DEVICE_OP (dev_ops, dealloc_dmah);SET_DEVICE_OP (dev_ops, dealloc_driver);SET_DEVICE_OP (dev_ops, dealloc_mw);SET_DEVICE_OP (dev_ops, dealloc_pd);
@@ -2832,6 +2834,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)SET_OBJ_SIZE (dev_ops, ib_ah);SET_OBJ_SIZE (dev_ops, ib_counters);SET_OBJ_SIZE (dev_ops, ib_cq); +SET_OBJ_SIZE (dev_ops, ib_dmah);SET_OBJ_SIZE (dev_ops, ib_mw);SET_OBJ_SIZE (dev_ops, ib_pd);SET_OBJ_SIZE (dev_ops, ib_qp);
drivers/infiniband/core/rdma_core.h +1 -0
@@ -156,6 +156,7 @@ extern const struct uapi_definition uverbs_def_obj_counters[];extern const struct uapi_definition uverbs_def_obj_cq[];extern const struct uapi_definition uverbs_def_obj_device[];extern const struct uapi_definition uverbs_def_obj_dm[]; +extern const struct uapi_definition uverbs_def_obj_dmah[];extern const struct uapi_definition uverbs_def_obj_flow_action[];extern const struct uapi_definition uverbs_def_obj_intf[];extern const struct uapi_definition uverbs_def_obj_mr[];
drivers/infiniband/core/restrack.c +2 -0
@@ -100,6 +100,8 @@ static struct ib_device *res_to_dev(struct rdma_restrack_entry *res) return container_of(res, struct rdma_counter, res)->device;case RDMA_RESTRACK_SRQ : return container_of(res, struct ib_srq, res)->device; +case RDMA_RESTRACK_DMAH : + return container_of(res, struct ib_dmah, res)->device;default :WARN_ONCE (true,"Wrong resource tracking type %u\n" , res->type);return NULL ;
drivers/infiniband/core/uverbs_std_types_dmah.c new file +151 -0
151 lines not on this page · raw message
drivers/infiniband/core/uverbs_uapi.c +1 -0
@@ -631,6 +631,7 @@ static const struct uapi_definition uverbs_core_api[] = {UAPI_DEF_CHAIN (uverbs_def_obj_cq),UAPI_DEF_CHAIN (uverbs_def_obj_device),UAPI_DEF_CHAIN (uverbs_def_obj_dm), +UAPI_DEF_CHAIN (uverbs_def_obj_dmah),UAPI_DEF_CHAIN (uverbs_def_obj_flow_action),UAPI_DEF_CHAIN (uverbs_def_obj_intf), UAPI_DEF_CHAIN(uverbs_def_obj_mr),
include/rdma/ib_verbs.h +28 -0
@@ -42,6 +42,7 @@#include <rdma/signature.h> #include <uapi/rdma/rdma_user_ioctl.h> #include <uapi/rdma/ib_user_ioctl_verbs.h> +#include <linux/pci-tph.h> #define IB_FW_VERSION_NAME_MAX ETHTOOL_FWVERS_LEN
@@ -1846,6 +1847,29 @@ struct ib_dm {atomic_t usecnt; }; +/* bit values to mark existence of ib_dmah fields */ +enum { +IB_DMAH_CPU_ID_EXISTS , +IB_DMAH_MEM_TYPE_EXISTS , +IB_DMAH_PH_EXISTS , +}; + +struct ib_dmah { +struct ib_device *device; +u32 cpu_id; +enum tph_mem_type mem_type; +u8 ph; +struct ib_uobject *uobject; + +u8 valid_fields;/* use IB_DMAH_XXX_EXISTS */ +atomic_t usecnt; + +/* +* Implementation details of the RDMA core, don't use in drivers: +*/ +struct rdma_restrack_entry res; +}; +struct ib_mr {struct ib_device *device;struct ib_pd *pd;
@@ -2569,6 +2593,9 @@ struct ib_device_ops {struct ib_dm_alloc_attr *attr, struct uverbs_attr_bundle *attrs);int (*dealloc_dm)(struct ib_dm *dm,struct uverbs_attr_bundle *attrs); +int (*alloc_dmah)(struct ib_dmah *ibdmah, +struct uverbs_attr_bundle *attrs); +int (*dealloc_dmah)(struct ib_dmah *dmah,struct uverbs_attr_bundle *attrs);struct ib_mr *(*reg_dm_mr)(struct ib_pd *pd,struct ib_dm *dm,struct ib_dm_mr_attr *attr,struct uverbs_attr_bundle *attrs);
@@ -2726,6 +2753,7 @@ struct ib_device_ops {DECLARE_RDMA_OBJ_SIZE (ib_ah);DECLARE_RDMA_OBJ_SIZE (ib_counters);DECLARE_RDMA_OBJ_SIZE (ib_cq); +DECLARE_RDMA_OBJ_SIZE (ib_dmah);DECLARE_RDMA_OBJ_SIZE (ib_mw);DECLARE_RDMA_OBJ_SIZE (ib_pd);DECLARE_RDMA_OBJ_SIZE (ib_qp);
include/rdma/restrack.h +4 -0
@@ -56,6 +56,10 @@ enum rdma_restrack_type {* @RDMA_RESTRACK_SRQ: Shared receive queue (SRQ) */ RDMA_RESTRACK_SRQ , +/** +* @RDMA_RESTRACK_DMAH: DMA handle +*/ + RDMA_RESTRACK_DMAH,/** * @RDMA_RESTRACK_MAX: Last entry, used for array dclarations */
include/uapi/rdma/ib_user_ioctl_cmds.h +17 -0
@@ -55,6 +55,7 @@ enum uverbs_default_objects {UVERBS_OBJECT_DM ,UVERBS_OBJECT_COUNTERS ,UVERBS_OBJECT_ASYNC_EVENT , + UVERBS_OBJECT_DMAH, }; enum {
@@ -236,6 +237,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 ,
Signature · 1 line
2.50.0
PATCH 6/8 RDMA/mlx5: Add DMAH object support
In reply to Leon RomanovskyFrom: Yishai Hadas <[email protected]>
This patch introduces support for allocating and deallocating the DMAH object.
Further details:
----------------
The DMAH API is exposed to upper layers only if the underlying device supports TPH.
It uses the mlx5_core steering tag (ST) APIs to get a steering tag index based on the provided input.
The obtained index is stored in the device-specific mlx5_dmah structure for future use.
Upcoming patches in the series will integrate the allocated DMAH into the memory region (MR) registration process.
--- drivers/infiniband/hw/mlx5/Makefile | 1 + drivers/infiniband/hw/mlx5/dmah.c | 54 +++++++++++++++++++++++++++++ drivers/infiniband/hw/mlx5/dmah.h | 23 ++++++++++++ drivers/infiniband/hw/mlx5/main.c | 5 +++ 4 files changed, 83 insertions(+) create mode 100644 drivers/infiniband/hw/mlx5/dmah.c create mode 100644 drivers/infiniband/hw/mlx5/dmah.h
drivers/infiniband/hw/mlx5/Makefile +1 -0
@@ -8,6 +8,7 @@ mlx5_ib-y := ah.o \ cq.o \ data_direct.o \ dm.o \ + dmah.o \ doorbell.o \ fs.o \ gsi.o \
drivers/infiniband/hw/mlx5/dmah.c new file +54 -0
54 lines not on this page · raw message
drivers/infiniband/hw/mlx5/dmah.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* +* Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved +*/ + +#ifndef _MLX5_IB_DMAH_H +#define _MLX5_IB_DMAH_H + +#include "mlx5_ib.h" + +extern const struct ib_device_ops mlx5_ib_dev_dmah_ops; + +struct mlx5_ib_dmah { +struct ib_dmah ibdmah; +u16 st_index; +}; + +static inline struct mlx5_ib_dmah *to_mdmah (struct ib_dmah *ibdmah) +{ + return container_of(ibdmah, struct mlx5_ib_dmah, ibdmah); +} + +#endif /* _MLX5_IB_DMAH_H */
drivers/infiniband/hw/mlx5/main.c +5 -0
@@ -50,6 +50,7 @@#include <rdma/ib_ucaps.h> #include "macsec.h" #include "data_direct.h" +#include "dmah.h" #define UVERBS_MODULE_NAME mlx5_ib#include <rdma/uverbs_named_ioctl.h>
@@ -4181,6 +4182,7 @@ static const struct ib_device_ops mlx5_ib_dev_ops = {INIT_RDMA_OBJ_SIZE (ib_ah, mlx5_ib_ah, ibah),INIT_RDMA_OBJ_SIZE (ib_counters, mlx5_ib_mcounters, ibcntrs),INIT_RDMA_OBJ_SIZE (ib_cq, mlx5_ib_cq, ibcq), +INIT_RDMA_OBJ_SIZE (ib_dmah, mlx5_ib_dmah, ibdmah),INIT_RDMA_OBJ_SIZE (ib_pd, mlx5_ib_pd, ibpd),INIT_RDMA_OBJ_SIZE (ib_qp, mlx5_ib_qp, ibqp), INIT_RDMA_OBJ_SIZE(ib_srq, mlx5_ib_srq, ibsrq),
@@ -4308,6 +4310,9 @@ static int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev) MLX5_GENERAL_OBJ_TYPES_CAP_SW_ICM) ib_set_device_ops(&dev->ib_dev, &mlx5_ib_dev_dm_ops); +if (mdev->st) +ib_set_device_ops (&dev->ib_dev, &mlx5_ib_dev_dmah_ops); +ib_set_device_ops (&dev->ib_dev, &mlx5_ib_dev_ops);if (IS_ENABLED (CONFIG_INFINIBAND_USER_ACCESS ))
Signature · 1 line
2.50.0
PATCH 7/8 IB: Extend UVERBS_METHOD_REG_MR to get DMAH
In reply to Leon RomanovskyFrom: Yishai Hadas <[email protected]>
Extend UVERBS_METHOD_REG_MR to get DMAH and pass it to all drivers.
It will be used in mlx5 driver as part of the next patch from the series.
--- drivers/infiniband/core/uverbs_cmd.c | 2 +- drivers/infiniband/core/uverbs_std_types_mr.c | 21 ++++++++++++++++--- 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/mlx5_ib.h | 2 ++ drivers/infiniband/hw/mlx5/mr.c | 8 ++++--- 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 ++- include/rdma/ib_verbs.h | 3 +++ include/uapi/rdma/ib_user_ioctl_cmds.h | 1 + 36 files changed, 144 insertions(+), 18 deletions(-)
drivers/infiniband/core/uverbs_cmd.c +1 -1
@@ -741,7 +741,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) } mr = pd->device->ops.reg_user_mr (pd, cmd.start, cmd.length, cmd.hca_va, - cmd.access_flags, + cmd.access_flags,NULL , &attrs->driver_udata);if (IS_ERR (mr)) { ret =PTR_ERR (mr);
drivers/infiniband/core/uverbs_std_types_mr.c +18 -3
@@ -238,7 +238,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_DMABUF_MR)(return ret; mr = pd->device->ops.reg_user_mr_dmabuf (pd, offset, length, iova, fd, - access_flags, + access_flags,NULL , attrs);if (IS_ERR (mr))return PTR_ERR (mr);
@@ -276,6 +276,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_MR)(u32 valid_access_flags =IB_ACCESS_SUPPORTED ;u64 length, iova, fd_offset =0 , addr =0 ;struct ib_device *ib_dev = pd->device; +struct ib_dmah *dmah =NULL ;bool has_fd_offset = false;bool has_addr = false;bool has_fd = false;
@@ -340,6 +341,12 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_MR)(return -EINVAL ; } +if (uverbs_attr_is_valid (attrs,UVERBS_ATTR_REG_MR_DMA_HANDLE )) { + dmah =uverbs_attr_get_obj (attrs,UVERBS_ATTR_REG_MR_DMA_HANDLE ); +if (IS_ERR (dmah)) +return PTR_ERR (dmah); + } + ret =uverbs_get_flags32 (&access_flags, attrs,UVERBS_ATTR_REG_MR_ACCESS_FLAGS , valid_access_flags);
@@ -352,10 +359,10 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_MR)(if (has_fd) mr = pd->device->ops.reg_user_mr_dmabuf (pd, fd_offset, length, iova, - fd, access_flags, attrs); + fd, access_flags, dmah, attrs);else mr = pd->device->ops.reg_user_mr (pd, addr, length, - iova, access_flags,NULL ); + iova, access_flags, dmah,NULL );if (IS_ERR (mr))return PTR_ERR (mr);
@@ -365,6 +372,10 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_MR)( mr->type =IB_MR_TYPE_USER ; mr->uobject = uobj;atomic_inc (&pd->usecnt); +if (dmah) { + mr->dmah = dmah; +atomic_inc (&dmah->usecnt); + }rdma_restrack_new (&mr->res,RDMA_RESTRACK_MR );rdma_restrack_set_name (&mr->res,NULL );rdma_restrack_add (&mr->res);
@@ -488,6 +499,10 @@ DECLARE_UVERBS_NAMED_METHOD( UVERBS_OBJECT_PD,UVERBS_ACCESS_READ , UA_MANDATORY), +UVERBS_ATTR_IDR (UVERBS_ATTR_REG_MR_DMA_HANDLE , +UVERBS_OBJECT_DMAH , +UVERBS_ACCESS_READ , +UA_OPTIONAL ),UVERBS_ATTR_PTR_IN (UVERBS_ATTR_REG_MR_IOVA ,UVERBS_ATTR_TYPE (u64 ), UA_MANDATORY),
drivers/infiniband/core/verbs.c +4 -1
@@ -2223,7 +2223,7 @@ struct ib_mr *ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, } mr = pd->device->ops.reg_user_mr (pd, start, length, virt_addr, - access_flags,NULL ); + access_flags,NULL ,NULL );if (IS_ERR (mr))return mr;
@@ -2262,6 +2262,7 @@ int ib_dereg_mr_user(struct ib_mr *mr, struct ib_udata *udata) {struct ib_pd *pd = mr->pd;struct ib_dm *dm = mr->dm; +struct ib_dmah *dmah = mr->dmah;struct ib_sig_attrs *sig_attrs = mr->sig_attrs;int ret;
@@ -2272,6 +2273,8 @@ int ib_dereg_mr_user(struct ib_mr *mr, struct ib_udata *udata)atomic_dec (&pd->usecnt);if (dm)atomic_dec (&dm->usecnt); +if (dmah) +atomic_dec (&dmah->usecnt);kfree (sig_attrs); }
drivers/infiniband/hw/bnxt_re/ib_verbs.c +8 -0
@@ -4235,6 +4235,7 @@ static struct ib_mr *__bnxt_re_user_reg_mr(struct ib_pd *ib_pd, u64 length, u64struct ib_mr *bnxt_re_reg_user_mr (struct ib_pd *ib_pd,u64 start,u64 length,u64 virt_addr,int mr_access_flags, +struct ib_dmah *dmah,struct ib_udata *udata) { struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd);
@@ -4242,6 +4243,9 @@ struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *ib_pd, u64 start, u64 length,struct ib_umem *umem;struct ib_mr *ib_mr; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); + umem =ib_umem_get (&rdev->ibdev, start, length, mr_access_flags);if (IS_ERR (umem))return ERR_CAST (umem);
@@ -4255,6 +4259,7 @@ struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *ib_pd, u64 start, u64 length,struct ib_mr *bnxt_re_reg_user_mr_dmabuf (struct ib_pd *ib_pd,u64 start,u64 length,u64 virt_addr,int fd,int mr_access_flags, +struct ib_dmah *dmah,struct uverbs_attr_bundle *attrs) { struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd);
@@ -4263,6 +4268,9 @@ struct ib_mr *bnxt_re_reg_user_mr_dmabuf(struct ib_pd *ib_pd, u64 start,struct ib_umem *umem;struct ib_mr *ib_mr; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); + umem_dmabuf =ib_umem_dmabuf_get_pinned (&rdev->ibdev, start, length, fd, mr_access_flags);if (IS_ERR (umem_dmabuf))
drivers/infiniband/hw/bnxt_re/ib_verbs.h +2 -0
@@ -258,10 +258,12 @@ struct ib_mw *bnxt_re_alloc_mw(struct ib_pd *ib_pd, enum ib_mw_type type,int bnxt_re_dealloc_mw (struct ib_mw *mw);struct ib_mr *bnxt_re_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int mr_access_flags, +struct ib_dmah *dmah,struct ib_udata *udata);struct ib_mr *bnxt_re_reg_user_mr_dmabuf (struct ib_pd *ib_pd,u64 start,u64 length,u64 virt_addr,int fd,int mr_access_flags, +struct ib_dmah *dmah,struct uverbs_attr_bundle *attrs);int bnxt_re_alloc_ucontext (struct ib_ucontext *ctx,struct ib_udata *udata);void bnxt_re_dealloc_ucontext (struct ib_ucontext *context);
drivers/infiniband/hw/cxgb4/iw_cxgb4.h +1 -0
@@ -1006,6 +1006,7 @@ int c4iw_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,void c4iw_dealloc (struct uld_ctx *ctx);struct ib_mr *c4iw_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt,int acc, +struct ib_dmah *dmah,struct ib_udata *udata);struct ib_mr *c4iw_get_dma_mr (struct ib_pd *pd,int acc);int c4iw_dereg_mr (struct ib_mr *ib_mr,struct ib_udata *udata);
drivers/infiniband/hw/cxgb4/mem.c +5 -1
@@ -489,7 +489,8 @@ struct ib_mr *c4iw_get_dma_mr(struct ib_pd *pd, int acc) }struct ib_mr *c4iw_reg_user_mr (struct ib_pd *pd,u64 start,u64 length, -u64 virt,int acc,struct ib_udata *udata) +u64 virt,int acc,struct ib_dmah *dmah, +struct ib_udata *udata) {__be64 *pages;int shift, n, i;
@@ -501,6 +502,9 @@ struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,pr_debug ("ib_pd %p\n" , pd); +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); +if (length == ~0ULL )return ERR_PTR (-EINVAL );
drivers/infiniband/hw/efa/efa.h +2 -0
@@ -164,10 +164,12 @@ int efa_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, struct uverbs_attr_bundle *attrs);struct ib_mr *efa_reg_mr (struct ib_pd *ibpd,u64 start,u64 length,u64 virt_addr,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata);struct ib_mr *efa_reg_user_mr_dmabuf (struct ib_pd *ibpd,u64 start,u64 length,u64 virt_addr,int fd,int access_flags, +struct ib_dmah *dmah,struct uverbs_attr_bundle *attrs);int efa_dereg_mr (struct ib_mr *ibmr,struct ib_udata *udata); int efa_get_port_immutable(struct ib_device *ibdev, u32 port_num,
drivers/infiniband/hw/efa/efa_verbs.c +8 -0
@@ -1727,6 +1727,7 @@ static int efa_register_mr(struct ib_pd *ibpd, struct efa_mr *mr, u64 start,struct ib_mr *efa_reg_user_mr_dmabuf (struct ib_pd *ibpd,u64 start,u64 length,u64 virt_addr,int fd,int access_flags, +struct ib_dmah *dmah,struct uverbs_attr_bundle *attrs) {struct efa_dev *dev =to_edev (ibpd->device);
@@ -1734,6 +1735,9 @@ struct ib_mr *efa_reg_user_mr_dmabuf(struct ib_pd *ibpd, u64 start,struct efa_mr *mr;int err; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); + mr =efa_alloc_mr (ibpd, access_flags, &attrs->driver_udata);if (IS_ERR (mr)) { err =PTR_ERR (mr);
@@ -1766,12 +1770,16 @@ struct ib_mr *efa_reg_user_mr_dmabuf(struct ib_pd *ibpd, u64 start,struct ib_mr *efa_reg_mr (struct ib_pd *ibpd,u64 start,u64 length,u64 virt_addr,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata) {struct efa_dev *dev =to_edev (ibpd->device);struct efa_mr *mr;int err; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); + mr =efa_alloc_mr (ibpd, access_flags, udata);if (IS_ERR (mr)) { err =PTR_ERR (mr);
drivers/infiniband/hw/erdma/erdma_verbs.c +5 -1
@@ -1200,13 +1200,17 @@ int erdma_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents, }struct ib_mr *erdma_reg_user_mr (struct ib_pd *ibpd,u64 start,u64 len, -u64 virt,int access,struct ib_udata *udata) +u64 virt,int access,struct ib_dmah *dmah, +struct ib_udata *udata) {struct erdma_mr *mr =NULL ;struct erdma_dev *dev =to_edev (ibpd->device);u32 stag;int ret; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); +if (!len || len > dev->attrs.max_mr_size)return ERR_PTR (-EINVAL );
drivers/infiniband/hw/erdma/erdma_verbs.h +2 -1
@@ -452,7 +452,8 @@ int erdma_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata);void erdma_disassociate_ucontext (struct ib_ucontext *ibcontext);int erdma_req_notify_cq (struct ib_cq *ibcq,enum ib_cq_notify_flags flags);struct ib_mr *erdma_reg_user_mr (struct ib_pd *ibpd,u64 start,u64 len, -u64 virt,int access,struct ib_udata *udata); +u64 virt,int access,struct ib_dmah *dmah, +struct ib_udata *udata);struct ib_mr *erdma_get_dma_mr (struct ib_pd *ibpd,int rights);int erdma_dereg_mr (struct ib_mr *ibmr,struct ib_udata *data);int erdma_mmap (struct ib_ucontext *ctx,struct vm_area_struct *vma);
drivers/infiniband/hw/hns/hns_roce_device.h +1 -0
@@ -1219,6 +1219,7 @@ int hns_roce_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata);struct ib_mr *hns_roce_get_dma_mr (struct ib_pd *pd,int acc);struct ib_mr *hns_roce_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata); struct ib_mr *hns_roce_rereg_user_mr(struct ib_mr *mr, int flags, u64 start, u64 length, u64 virt_addr,
drivers/infiniband/hw/hns/hns_roce_mr.c +4 -0
@@ -231,12 +231,16 @@ struct ib_mr *hns_roce_get_dma_mr(struct ib_pd *pd, int acc)struct ib_mr *hns_roce_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata) {struct hns_roce_dev *hr_dev =to_hr_dev (pd->device);struct hns_roce_mr *mr;int ret; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); + mr =kzalloc (sizeof (*mr),GFP_KERNEL );if (!mr) { ret = -ENOMEM ;
drivers/infiniband/hw/irdma/verbs.c +9 -0
@@ -3013,10 +3013,12 @@ static int irdma_reg_user_mr_type_cq(struct irdma_mem_reg_req req,* @len: length of mr * @virt: virtual address * @access: access of mr +* @dmah: dma handle * @udata: user data */ static struct ib_mr *irdma_reg_user_mr (struct ib_pd *pd,u64 start,u64 len,u64 virt,int access, +struct ib_dmah *dmah,struct ib_udata *udata) {#define IRDMA_MEM_REG_MIN_REQ_LEN offsetofend(struct irdma_mem_reg_req, sq_pages)
@@ -3026,6 +3028,9 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,struct irdma_mr *iwmr =NULL ;int err; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); +if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)return ERR_PTR (-EINVAL );
@@ -3085,6 +3090,7 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,static struct ib_mr *irdma_reg_user_mr_dmabuf (struct ib_pd *pd,u64 start,u64 len,u64 virt,int fd,int access, +struct ib_dmah *dmah,struct uverbs_attr_bundle *attrs) {struct irdma_device *iwdev =to_iwdev (pd->device);
@@ -3092,6 +3098,9 @@ static struct ib_mr *irdma_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,struct irdma_mr *iwmr;int err; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); +if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)return ERR_PTR (-EINVAL );
drivers/infiniband/hw/mana/mana_ib.h +2 -0
@@ -624,6 +624,7 @@ struct ib_mr *mana_ib_get_dma_mr(struct ib_pd *ibpd, int access_flags);struct ib_mr *mana_ib_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 iova,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata);int mana_ib_dereg_mr (struct ib_mr *ibmr,struct ib_udata *udata);
@@ -713,5 +714,6 @@ int mana_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);struct ib_mr *mana_ib_reg_user_mr_dmabuf (struct ib_pd *ibpd,u64 start,u64 length,u64 iova,int fd,int mr_access_flags, +struct ib_dmah *dmah,struct uverbs_attr_bundle *attrs);#endif
drivers/infiniband/hw/mana/mr.c +8 -0
@@ -106,6 +106,7 @@ static int mana_ib_gd_destroy_mr(struct mana_ib_dev *dev, u64 mr_handle)struct ib_mr *mana_ib_reg_user_mr (struct ib_pd *ibpd,u64 start,u64 length,u64 iova,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata) { struct mana_ib_pd *pd = container_of(ibpd, struct mana_ib_pd, ibpd);
@@ -116,6 +117,9 @@ struct ib_mr *mana_ib_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 length,u64 dma_region_handle;int err; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); + dev = container_of(ibdev, struct mana_ib_dev, ib_dev); ibdev_dbg(ibdev,
@@ -188,6 +192,7 @@ struct ib_mr *mana_ib_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 length,struct ib_mr *mana_ib_reg_user_mr_dmabuf (struct ib_pd *ibpd,u64 start,u64 length,u64 iova,int fd,int access_flags, +struct ib_dmah *dmah,struct uverbs_attr_bundle *attrs) { struct mana_ib_pd *pd = container_of(ibpd, struct mana_ib_pd, ibpd);
@@ -199,6 +204,9 @@ struct ib_mr *mana_ib_reg_user_mr_dmabuf(struct ib_pd *ibpd, u64 start, u64 lengu64 dma_region_handle;int err; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); + dev = container_of(ibdev, struct mana_ib_dev, ib_dev); access_flags &= ~IB_ACCESS_OPTIONAL ;
drivers/infiniband/hw/mlx4/mlx4_ib.h +1 -0
@@ -759,6 +759,7 @@ int mlx4_ib_umem_write_mtt(struct mlx4_ib_dev *dev, struct mlx4_mtt *mtt, struct ib_umem *umem);struct ib_mr *mlx4_ib_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata);int mlx4_ib_dereg_mr (struct ib_mr *mr,struct ib_udata *udata);int mlx4_ib_alloc_mw (struct ib_mw *mw,struct ib_udata *udata);
drivers/infiniband/hw/mlx4/mr.c +4 -0
@@ -139,6 +139,7 @@ static struct ib_umem *mlx4_get_umem_mr(struct ib_device *device, u64 start,struct ib_mr *mlx4_ib_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata) {struct mlx4_ib_dev *dev =to_mdev (pd->device);
@@ -147,6 +148,9 @@ struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,int err;int n; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); + mr =kzalloc (sizeof (*mr),GFP_KERNEL );if (!mr)return ERR_PTR (-ENOMEM );
drivers/infiniband/hw/mlx5/mlx5_ib.h +2 -0
@@ -1380,10 +1380,12 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata);struct ib_mr *mlx5_ib_get_dma_mr (struct ib_pd *pd,int acc);struct ib_mr *mlx5_ib_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata);struct ib_mr *mlx5_ib_reg_user_mr_dmabuf (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int fd,int access_flags, +struct ib_dmah *dmah,struct uverbs_attr_bundle *attrs); int mlx5_ib_advise_mr(struct ib_pd *pd, enum ib_uverbs_advise_mr_advice advice,
drivers/infiniband/hw/mlx5/mr.c +5 -3
@@ -1564,13 +1564,14 @@ static struct ib_mr *create_user_odp_mr(struct ib_pd *pd, u64 start, u64 length,struct ib_mr *mlx5_ib_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 iova,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata) {struct mlx5_ib_dev *dev =to_mdev (pd->device);struct ib_umem *umem;int err; -if (!IS_ENABLED (CONFIG_INFINIBAND_USER_MEM )) +if (!IS_ENABLED (CONFIG_INFINIBAND_USER_MEM ) || dmah)return ERR_PTR (-EOPNOTSUPP ); mlx5_ib_dbg(dev, "start 0x%llx, iova 0x%llx, length 0x%llx, access_flags 0x%x\n",
@@ -1724,6 +1725,7 @@ reg_user_mr_dmabuf_by_data_direct(struct ib_pd *pd, u64 offset,struct ib_mr *mlx5_ib_reg_user_mr_dmabuf (struct ib_pd *pd,u64 offset,u64 length,u64 virt_addr,int fd,int access_flags, +struct ib_dmah *dmah,struct uverbs_attr_bundle *attrs) {struct mlx5_ib_dev *dev =to_mdev (pd->device);
@@ -1731,7 +1733,7 @@ struct ib_mr *mlx5_ib_reg_user_mr_dmabuf(struct ib_pd *pd, u64 offset,int err;if (!IS_ENABLED (CONFIG_INFINIBAND_USER_MEM ) || - !IS_ENABLED (CONFIG_INFINIBAND_ON_DEMAND_PAGING )) + !IS_ENABLED (CONFIG_INFINIBAND_ON_DEMAND_PAGING ) || dmah)return ERR_PTR (-EOPNOTSUPP );if (uverbs_attr_is_valid (attrs,MLX5_IB_ATTR_REG_DMABUF_MR_ACCESS_FLAGS )) {
@@ -1937,7 +1939,7 @@ struct ib_mr *mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,*/ recreate:return mlx5_ib_reg_user_mr (new_pd, start, length, iova, - new_access_flags, udata); + new_access_flags,NULL , udata); } static int
drivers/infiniband/hw/mthca/mthca_provider.c +5 -1
@@ -825,7 +825,8 @@ static struct ib_mr *mthca_get_dma_mr(struct ib_pd *pd, int acc) }static struct ib_mr *mthca_reg_user_mr (struct ib_pd *pd,u64 start,u64 length, -u64 virt,int acc,struct ib_udata *udata) +u64 virt,int acc,struct ib_dmah *dmah, +struct ib_udata *udata) {struct mthca_dev *dev =to_mdev (pd->device);struct ib_block_iter biter;
@@ -838,6 +839,9 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,int err =0 ;int write_mtt_size; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); +if (udata->inlen <sizeof ucmd) {if (!context->reg_mr_warned) { mthca_warn(dev, "Process '%s' did not pass in MR attrs.\n",
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +5 -1
@@ -847,13 +847,17 @@ static void build_user_pbes(struct ocrdma_dev *dev, struct ocrdma_mr *mr) }struct ib_mr *ocrdma_reg_user_mr (struct ib_pd *ibpd,u64 start,u64 len, -u64 usr_addr,int acc,struct ib_udata *udata) +u64 usr_addr,int acc,struct ib_dmah *dmah, +struct ib_udata *udata) {int status = -ENOMEM ;struct ocrdma_dev *dev =get_ocrdma_dev (ibpd->device);struct ocrdma_mr *mr;struct ocrdma_pd *pd; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); + pd =get_ocrdma_pd (ibpd);if (acc &IB_ACCESS_REMOTE_WRITE && !(acc &IB_ACCESS_LOCAL_WRITE ))
drivers/infiniband/hw/ocrdma/ocrdma_verbs.h +2 -1
@@ -98,7 +98,8 @@ int ocrdma_post_srq_recv(struct ib_srq *, const struct ib_recv_wr *,int ocrdma_dereg_mr (struct ib_mr *ib_mr,struct ib_udata *udata);struct ib_mr *ocrdma_get_dma_mr (struct ib_pd *,int acc);struct ib_mr *ocrdma_reg_user_mr (struct ib_pd *,u64 start,u64 length, -u64 virt,int acc,struct ib_udata *); +u64 virt,int acc,struct ib_dmah *dmah, +struct ib_udata *);struct ib_mr *ocrdma_alloc_mr (struct ib_pd *pd,enum ib_mr_type mr_type,u32 max_num_sg); int ocrdma_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
drivers/infiniband/hw/qedr/verbs.c +5 -1
@@ -2953,13 +2953,17 @@ static int init_mr_info(struct qedr_dev *dev, struct mr_info *info, }struct ib_mr *qedr_reg_user_mr (struct ib_pd *ibpd,u64 start,u64 len, -u64 usr_addr,int acc,struct ib_udata *udata) +u64 usr_addr,int acc,struct ib_dmah *dmah, +struct ib_udata *udata) {struct qedr_dev *dev =get_qedr_dev (ibpd->device);struct qedr_mr *mr;struct qedr_pd *pd;int rc = -ENOMEM ; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); + pd =get_qedr_pd (ibpd); DP_DEBUG(dev, QEDR_MSG_MR, "qedr_register user mr pd = %d start = %lld, len = %lld, usr_addr = %lld, acc = %d\n",
drivers/infiniband/hw/qedr/verbs.h +2 -1
@@ -79,7 +79,8 @@ int qedr_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata);struct ib_mr *qedr_get_dma_mr (struct ib_pd *,int acc);struct ib_mr *qedr_reg_user_mr (struct ib_pd *,u64 start,u64 length, -u64 virt,int acc,struct ib_udata *); +u64 virt,int acc,struct ib_dmah *dmah, +struct ib_udata *);int qedr_map_mr_sg (struct ib_mr *ibmr,struct scatterlist *sg,int sg_nents,unsigned int *sg_offset);
drivers/infiniband/hw/usnic/usnic_ib_verbs.c +4 -0
@@ -592,6 +592,7 @@ int usnic_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata)struct ib_mr *usnic_ib_reg_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata) {struct usnic_ib_mr *mr;
@@ -600,6 +601,9 @@ struct ib_mr *usnic_ib_reg_mr(struct ib_pd *pd, u64 start, u64 length,usnic_dbg ("start 0x%llx va 0x%llx length 0x%llx\n" , start, virt_addr, length); +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); + mr =kzalloc (sizeof (*mr),GFP_KERNEL );if (!mr)return ERR_PTR (-ENOMEM );
drivers/infiniband/hw/usnic/usnic_ib_verbs.h +1 -0
@@ -60,6 +60,7 @@ int usnic_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,int usnic_ib_destroy_cq (struct ib_cq *cq,struct ib_udata *udata);struct ib_mr *usnic_ib_reg_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata);int usnic_ib_dereg_mr (struct ib_mr *ibmr,struct ib_udata *udata);int usnic_ib_alloc_ucontext (struct ib_ucontext *uctx,struct ib_udata *udata);
drivers/infiniband/hw/vmw_pvrdma/pvrdma_mr.c +5 -0
@@ -104,12 +104,14 @@ struct ib_mr *pvrdma_get_dma_mr(struct ib_pd *pd, int acc)* @length: length of region * @virt_addr: I/O virtual address * @access_flags: access flags for memory region +* @dmah: dma handle * @udata: user data * * @return: ib_mr pointer on success, otherwise returns an errno. */ struct ib_mr *pvrdma_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata) {struct pvrdma_dev *dev =to_vdev (pd->device);
@@ -121,6 +123,9 @@ struct ib_mr *pvrdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,struct pvrdma_cmd_create_mr_resp *resp = &rsp.create_mr_resp;int ret, npages; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); +if (length ==0 || length > dev->dsr->caps.max_mr_size) {dev_warn (&dev->pdev->dev,"invalid mem region length\n" );return ERR_PTR (-EINVAL );
drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h +1 -0
@@ -366,6 +366,7 @@ int pvrdma_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata);struct ib_mr *pvrdma_get_dma_mr (struct ib_pd *pd,int acc);struct ib_mr *pvrdma_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata);int pvrdma_dereg_mr (struct ib_mr *mr,struct ib_udata *udata); struct ib_mr *pvrdma_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
drivers/infiniband/sw/rdmavt/mr.c +5 -0
@@ -329,12 +329,14 @@ struct ib_mr *rvt_get_dma_mr(struct ib_pd *pd, int acc)* @length: length of region to register * @virt_addr: associated virtual address * @mr_access_flags: access flags for this memory region +* @dmah: dma handle * @udata: unused by the driver * * Return: the memory region on success, otherwise returns an errno. */ struct ib_mr *rvt_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int mr_access_flags, +struct ib_dmah *dmah,struct ib_udata *udata) {struct rvt_mr *mr;
@@ -343,6 +345,9 @@ struct ib_mr *rvt_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,int n, m;struct ib_mr *ret; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); +if (length ==0 )return ERR_PTR (-EINVAL );
drivers/infiniband/sw/rdmavt/mr.h +1 -0
@@ -26,6 +26,7 @@ void rvt_mr_exit(struct rvt_dev_info *rdi);struct ib_mr *rvt_get_dma_mr (struct ib_pd *pd,int acc);struct ib_mr *rvt_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int mr_access_flags, +struct ib_dmah *dmah,struct ib_udata *udata);int rvt_dereg_mr (struct ib_mr *ibmr,struct ib_udata *udata); struct ib_mr *rvt_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
drivers/infiniband/sw/rxe/rxe_verbs.c +4 -0
@@ -1271,6 +1271,7 @@ static struct ib_mr *rxe_get_dma_mr(struct ib_pd *ibpd, int access)static struct ib_mr *rxe_reg_user_mr (struct ib_pd *ibpd,u64 start,u64 length,u64 iova,int access, +struct ib_dmah *dmah,struct ib_udata *udata) {struct rxe_dev *rxe =to_rdev (ibpd->device);
@@ -1278,6 +1279,9 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd, u64 start,struct rxe_mr *mr;int err, cleanup_err; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); +if (access & ~RXE_ACCESS_SUPPORTED_MR ) {rxe_err_pd (pd,"access = %#x not supported (%#x)\n" , access,RXE_ACCESS_SUPPORTED_MR );
drivers/infiniband/sw/siw/siw_verbs.c +6 -1
@@ -1321,10 +1321,12 @@ int siw_dereg_mr(struct ib_mr *base_mr, struct ib_udata *udata)* @len: len of MR * @rnic_va: not used by siw * @rights: MR access rights +* @dmah: dma handle * @udata: user buffer to communicate STag and Key. */ struct ib_mr *siw_reg_user_mr (struct ib_pd *pd,u64 start,u64 len, -u64 rnic_va,int rights,struct ib_udata *udata) +u64 rnic_va,int rights,struct ib_dmah *dmah, +struct ib_udata *udata) {struct siw_mr *mr =NULL ;struct siw_umem *umem =NULL ;
@@ -1332,6 +1334,9 @@ struct ib_mr *siw_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,struct siw_device *sdev =to_siw_dev (pd->device);int rv; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); +siw_dbg_pd (pd,"start: 0x%p, va: 0x%p, len: %llu\n" , (void *)(uintptr_t )start, (void *)(uintptr_t )rnic_va, (unsigned long long )len);
drivers/infiniband/sw/siw/siw_verbs.h +2 -1
@@ -65,7 +65,8 @@ int siw_destroy_cq(struct ib_cq *base_cq, struct ib_udata *udata);int siw_poll_cq (struct ib_cq *base_cq,int num_entries,struct ib_wc *wc);int siw_req_notify_cq (struct ib_cq *base_cq,enum ib_cq_notify_flags flags);struct ib_mr *siw_reg_user_mr (struct ib_pd *base_pd,u64 start,u64 len, -u64 rnic_va,int rights,struct ib_udata *udata); +u64 rnic_va,int rights,struct ib_dmah *dmah, +struct ib_udata *udata);struct ib_mr *siw_alloc_mr (struct ib_pd *base_pd,enum ib_mr_type mr_type,u32 max_sge);struct ib_mr *siw_get_dma_mr (struct ib_pd *base_pd,int rights);
include/rdma/ib_verbs.h +3 -0
@@ -1887,6 +1887,7 @@ struct ib_mr {struct ib_dm *dm;struct ib_sig_attrs *sig_attrs;/* only for IB_MR_TYPE_INTEGRITY MRs */ +struct ib_dmah *dmah;/* * Implementation details of the RDMA core, don't use in drivers: */
@@ -2525,10 +2526,12 @@ struct ib_device_ops {struct ib_mr *(*get_dma_mr)(struct ib_pd *pd,int mr_access_flags);struct ib_mr *(*reg_user_mr)(struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int mr_access_flags, +struct ib_dmah *dmah,struct ib_udata *udata);struct ib_mr *(*reg_user_mr_dmabuf)(struct ib_pd *pd,u64 offset,u64 length,u64 virt_addr,int fd,int mr_access_flags, +struct ib_dmah *dmah,struct uverbs_attr_bundle *attrs); struct ib_mr *(*rereg_user_mr)(struct ib_mr *mr, int flags, u64 start, u64 length, u64 virt_addr,
include/uapi/rdma/ib_user_ioctl_cmds.h +1 -0
@@ -307,6 +307,7 @@ enum uverbs_attrs_reg_dmabuf_mr_cmd_attr_ids {enum uverbs_attrs_reg_mr_cmd_attr_ids {UVERBS_ATTR_REG_MR_HANDLE ,UVERBS_ATTR_REG_MR_PD_HANDLE , +UVERBS_ATTR_REG_MR_DMA_HANDLE ,UVERBS_ATTR_REG_MR_IOVA ,UVERBS_ATTR_REG_MR_ADDR ,UVERBS_ATTR_REG_MR_LENGTH ,
Signature · 1 line
2.50.0
Junxian Huang
maintainerRe: [PATCH rdma-next 7/8] IB: Extend UVERBS_METHOD_REG_MR to get DMAH
Quoted 69 lines · Leon Romanovsky
From: Yishai Hadas <[email protected]>
Extend
UVERBS_METHOD_REG_MRto get DMAH and pass it to all drivers.It will be used in mlx5 driver as part of the next patch from the series.
Signed-off-by Yishai Hadas <[email protected]>Reviewed-by Edward Srouji <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>--- drivers/infiniband/core/uverbs_cmd.c | 2 +- drivers/infiniband/core/uverbs_std_types_mr.c | 21 ++++++++++++++++--- 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/mlx5_ib.h | 2 ++ drivers/infiniband/hw/mlx5/mr.c | 8 ++++--- 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 ++- include/rdma/ib_verbs.h | 3 +++ include/uapi/rdma/ib_user_ioctl_cmds.h | 1 + 36 files changed, 144 insertions(+), 18 deletions(-)drivers/infiniband/hw/hns/hns_roce_device.h +1
-0@@ -1219,6 +1219,7 @@ int hns_roce_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata);struct ib_mr *hns_roce_get_dma_mr (struct ib_pd *pd,int acc);struct ib_mr *hns_roce_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata); struct ib_mr *hns_roce_rereg_user_mr(struct ib_mr *mr, int flags, u64 start, u64 length, u64 virt_addr,drivers/infiniband/hw/hns/hns_roce_mr.c +0
-0@@ -231,12 +231,16 @@ struct ib_mr *hns_roce_get_dma_mr(struct ib_pd *pd, int acc) struct ib_mr *hns_roce_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, u64 virt_addr, int access_flags,
drivers/infiniband/hw/hns/hns_roce_mr.c struct ib_mr *hns_roce_get_dma_mr(struct ib_pd *pd, int acc) · line 243
Quoted 10 lines
drivers/infiniband/hw/hns/hns_roce_mr.c +4
-0+struct ib_dmah *dmah, struct ib_udata *udata) { struct hns_roce_dev *hr_dev = to_hr_dev(pd->device);struct hns_roce_mr *mr;int ret; +if (dmah) +return ERR_PTR (-EOPNOTSUPP ); +
Could you change hns part as below? We have an error counter in the err_out label.
Thanks
Junxian
drivers/infiniband/hw/hns/hns_roce_mr.c +5 -0
@@ -237,6 +237,11 @@ struct ib_mr *hns_roce_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,struct hns_roce_mr *mr;int ret; +if (dmah) { + ret = -EOPNOTSUPP ; + goto err_out; + } + mr =kzalloc (sizeof (*mr),GFP_KERNEL );if (!mr) { ret = -ENOMEM ;
Quoted 3 lines
drivers/infiniband/hw/hns/hns_roce_mr.c +0
-0mr =kzalloc (sizeof (*mr),GFP_KERNEL );if (!mr) { ret = -ENOMEM ;
Re: [PATCH rdma-next 7/8] IB: Extend UVERBS_METHOD_REG_MR to get DMAH
Quoted 79 lines · Junxian Huang
Quoted 76 lines · Leon Romanovsky
From: Yishai Hadas <[email protected]>
Extend
UVERBS_METHOD_REG_MRto get DMAH and pass it to all drivers.It will be used in mlx5 driver as part of the next patch from the series.
Signed-off-by Yishai Hadas <[email protected]>Reviewed-by Edward Srouji <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>--- drivers/infiniband/core/uverbs_cmd.c | 2 +- drivers/infiniband/core/uverbs_std_types_mr.c | 21 ++++++++++++++++--- 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/mlx5_ib.h | 2 ++ drivers/infiniband/hw/mlx5/mr.c | 8 ++++--- 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 ++- include/rdma/ib_verbs.h | 3 +++ include/uapi/rdma/ib_user_ioctl_cmds.h | 1 + 36 files changed, 144 insertions(+), 18 deletions(-)drivers/infiniband/hw/hns/hns_roce_device.h +1
-0@@ -1219,6 +1219,7 @@ int hns_roce_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata);struct ib_mr *hns_roce_get_dma_mr (struct ib_pd *pd,int acc);struct ib_mr *hns_roce_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata); struct ib_mr *hns_roce_rereg_user_mr(struct ib_mr *mr, int flags, u64 start, u64 length, u64 virt_addr,drivers/infiniband/hw/hns/hns_roce_mr.c +1
-0@@ -231,12 +231,16 @@ struct ib_mr *hns_roce_get_dma_mr(struct ib_pd *pd, int acc)struct ib_mr *hns_roce_reg_user_mr (struct ib_pd *pd,u64 start,u64 length,u64 virt_addr,int access_flags, +struct ib_dmah *dmah,struct ib_udata *udata) {struct hns_roce_dev *hr_dev =to_hr_dev (pd->device);struct hns_roce_mr *mr;int ret;
Quoted 5 lines
drivers/infiniband/hw/hns/hns_roce_mr.c struct ib_mr *hns_roce_get_dma_mr(struct ib_pd *pd, int acc) · line 243
Quoted 3 lines
drivers/infiniband/hw/hns/hns_roce_mr.c +3
-0+if (dmah) +return ERR_PTR (-EOPNOTSUPP ); +Could you change hns part as below? We have an error counter in the
err_outlabel.
Of course, I will do it.
Quoted 24 lines
Thanks
Junxiandrivers/infiniband/hw/hns/hns_roce_mr.c +5
-0@@ -237,6 +237,11 @@ struct ib_mr *hns_roce_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,struct hns_roce_mr *mr;int ret; +if (dmah) { + ret = -EOPNOTSUPP ; + goto err_out; + } + mr =kzalloc (sizeof (*mr),GFP_KERNEL );if (!mr) { ret = -ENOMEM ;Quoted 4 lines
drivers/infiniband/hw/hns/hns_roce_mr.c +0
-0mr =kzalloc (sizeof (*mr),GFP_KERNEL );if (!mr) { ret = -ENOMEM ;
Gal Pressman
reviewerRe: [PATCH rdma-next 7/8] IB: Extend UVERBS_METHOD_REG_MR to get DMAH
In reply to Junxian HuangQuoted 1 line · Junxian Huang
Could you change hns part as below? We have an error counter in the
err_outlabel.
Same for EFA.
Quoted 25 lines
Thanks
Junxiandrivers/infiniband/hw/hns/hns_roce_mr.c +5
-0@@ -237,6 +237,11 @@ struct ib_mr *hns_roce_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,struct hns_roce_mr *mr;int ret; +if (dmah) { + ret = -EOPNOTSUPP ; + goto err_out; + } + mr =kzalloc (sizeof (*mr),GFP_KERNEL );if (!mr) { ret = -ENOMEM ;Quoted 4 lines
drivers/infiniband/hw/hns/hns_roce_mr.c +0
-0mr =kzalloc (sizeof (*mr),GFP_KERNEL );if (!mr) { ret = -ENOMEM ;
Jason Gunthorpe
maintainerRe: [PATCH rdma-next 7/8] IB: Extend UVERBS_METHOD_REG_MR to get DMAH
Quoted 4 lines · Gal Pressman
Quoted 1 line · Junxian Huang
Could you change hns part as below? We have an error counter in the
err_outlabel.Same for EFA.
Yuk, why?
If we want to count system call failures it should not be done in drivers.
Jason
Gal Pressman
reviewerRe: [PATCH rdma-next 7/8] IB: Extend UVERBS_METHOD_REG_MR to get DMAH
Quoted 10 lines · Jason Gunthorpe
Quoted 4 lines · Gal Pressman
Quoted 1 line · Junxian Huang
Could you change hns part as below? We have an error counter in the
err_outlabel.Same for EFA.
Yuk, why?
If we want to count system call failures it should not be done in drivers.
Why is this check different than others?
EFA counts failures from incompatible udata/abi, or even ib_copy_from_data() errors, isn't it similar?
Jason Gunthorpe
maintainerRe: [PATCH rdma-next 7/8] IB: Extend UVERBS_METHOD_REG_MR to get DMAH
Quoted 9 lines · Gal Pressman
Quoted 8 lines · Jason Gunthorpe
Quoted 4 lines · Gal Pressman
Quoted 1 line · Junxian Huang
Could you change hns part as below? We have an error counter in the
err_outlabel.Same for EFA.
Yuk, why?
Quoted 7 lines
Quoted 2 lines
If we want to count system call failures it should not be done in drivers.
Why is this check different than others?
EFA counts failures from incompatible udata/abi, or even
ib_copy_from_data()errors, isn't it similar?
It is, and that is the Yuk. Drives shouldn't have counters for generic system call failures.
Jason
Margolin, Michael
maintainerRe: [PATCH rdma-next 7/8] IB: Extend UVERBS_METHOD_REG_MR to get DMAH
Quoted 14 lines · Jason Gunthorpe
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
Quoted 9 lines · Gal Pressman
Quoted 8 lines · Jason Gunthorpe
Quoted 3 lines · Gal Pressman
Quoted 1 line · Junxian Huang
Could you change hns part as below? We have an error counter in the
err_outlabel.Same for EFA.
Yuk, why?
If we want to count system call failures it should not be done in drivers.
Quoted 8 lines
Quoted 4 lines
Why is this check different than others?
EFA counts failures from incompatible udata/abi, or even
ib_copy_from_data()errors, isn't it similar?It is, and that is the Yuk. Drives shouldn't have counters for generic system call failures.
Jason
IMHO if control reaches driver code, it isn't a generic system call failure.
Maybe we should find a way to check this in common code rather than handling in each driver.
Michael
Re: [PATCH rdma-next 7/8] IB: Extend UVERBS_METHOD_REG_MR to get DMAH
Quoted 16 lines · Michael
Quoted 14 lines · Jason Gunthorpe
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
Quoted 9 lines · Gal Pressman
Quoted 8 lines · Jason Gunthorpe
Quoted 3 lines · Gal Pressman
Quoted 1 line · Junxian Huang
Could you change hns part as below? We have an error counter in the
err_outlabel.Same for EFA.
Yuk, why?
If we want to count system call failures it should not be done in drivers.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Why is this check different than others?
EFA counts failures from incompatible udata/abi, or even
ib_copy_from_data()errors, isn't it similar?It is, and that is the Yuk. Drives shouldn't have counters for generic system call failures.
IMHO if control reaches driver code, it isn't a generic system call failure.
I don't think so, lots of the driver code is generic boilerplate. This dmah check is generic boilerplate. If this series added a new op instead of a new parameter it would not be counted. Doesn't make any sense.
Quoted 2 lines
Maybe we should find a way to check this in common code rather than handling in each driver.
If you counted the number of FW calls that fail that would make sense.
But this is capturing too much to be considered just driver code, too many of the failure paths have nothing to do with the driver.
Jason
PATCH 8/8 RDMA/mlx5: Add DMAH support for reg_user_mr/reg_user_dmabuf_mr
In reply to Leon RomanovskyFrom: Yishai Hadas <[email protected]>
As part of this enhancement, allow the creation of an MKEY associated with a DMA handle.
Additional notes:
MKEYs with TPH (i.e. TLP Processing Hints) attributes are currently not UMR-capable unless explicitly enabled by firmware or hardware. Therefore, to maintain such MKEYs in the MR cache, the TPH fields have been added to the rb_key structure, with a dedicated hash bucket.
The ability to bypass the kernel verbs flow and create an MKEY with TPH attributes using DEVX has been restricted. TPH must follow the standard InfiniBand flow, where a DMAH is created with the appropriate security checks and management mechanisms in place.
DMA handles are currently not supported in conjunction with On-Demand Paging (ODP).
Re-registration of memory regions originally created with TPH attributes is currently not supported.
--- drivers/infiniband/hw/mlx5/devx.c | 4 ++ drivers/infiniband/hw/mlx5/mlx5_ib.h | 5 ++ drivers/infiniband/hw/mlx5/mr.c | 101 ++++++++++++++++++++++----- drivers/infiniband/hw/mlx5/odp.c | 1 + 4 files changed, 92 insertions(+), 19 deletions(-)
drivers/infiniband/hw/mlx5/devx.c +4 -0
@@ -1393,6 +1393,10 @@ static int devx_handle_mkey_create(struct mlx5_ib_dev *dev, }MLX5_SET (create_mkey_in, in, mkey_umem_valid,1 ); +/* TPH is not allowed to bypass the regular kernel's verbs flow */ +MLX5_SET (mkc, mkc, pcie_tph_en,0 ); +MLX5_SET (mkc, mkc, pcie_tph_steering_tag_index, +MLX5_MKC_PCIE_TPH_NO_STEERING_TAG_INDEX );return 0 ; }
drivers/infiniband/hw/mlx5/mlx5_ib.h +5 -0
@@ -650,8 +650,13 @@ enum mlx5_mkey_type { MLX5_MKEY_IMPLICIT_CHILD, }; +/* Used for non-existent ph value */ +#define MLX5_IB_NO_PH 0xff +struct mlx5r_cache_rb_key {u8 ats:1 ; +u8 ph; +u16 st_index;unsigned int access_mode;unsigned int access_flags;unsigned int ndescs;
drivers/infiniband/hw/mlx5/mr.c +82 -19
266 lines not on this page · raw message
drivers/infiniband/hw/mlx5/odp.c +1 -0
@@ -1866,6 +1866,7 @@ int mlx5_odp_init_mkey_cache(struct mlx5_ib_dev *dev)struct mlx5r_cache_rb_key rb_key = { .access_mode =MLX5_MKC_ACCESS_MODE_KSM , .ndescs = mlx5_imr_ksm_entries, + .ph =MLX5_IB_NO_PH , };struct mlx5_cache_ent *ent;
Signature · 1 line
2.50.0