Skip to contentSkip to conversation

RDMA/efa: Add EFA query MR support

PATCH Superseded Michael Margolin 3 participants 9 messages Dec 11, 2023 – Jan 4, 2024

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Michael Margolin

author maintainer
#0 lore raw

PATCH v3 1/1 RDMA/efa: Add EFA query MR support

Add EFA driver uapi definitions and register a new query MR method that currently returns the physical PCI buses' IDs the device is using to reach the MR. Update admin definitions and efa-abi accordingly.

---
 drivers/infiniband/hw/efa/efa.h               | 12 +++-
 .../infiniband/hw/efa/efa_admin_cmds_defs.h   | 31 +++++++++
 drivers/infiniband/hw/efa/efa_com_cmd.c       |  9 +++
 drivers/infiniband/hw/efa/efa_com_cmd.h       | 10 +++
 drivers/infiniband/hw/efa/efa_main.c          |  5 ++
 drivers/infiniband/hw/efa/efa_verbs.c         | 69 +++++++++++++++++++
 include/uapi/rdma/efa-abi.h                   | 19 +++++
 7 files changed, 154 insertions(+), 1 deletion(-)
drivers/infiniband/hw/efa/efa.h +11 -1
index 7352a1f5d811..81f5aaf07091 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
 /*
- * Copyright 2018-2021 Amazon.com, Inc. or its affiliates. All rights reserved.
+ * Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All rights reserved.
  */
 
 #ifndef _EFA_H_
@@ -80,9 +80,19 @@ struct efa_pd {
 	u16 pdn;
 };
 
+struct efa_mr_pci_info {
+	u16 recv_pci_bus_id;
+	u16 rdma_read_pci_bus_id;
+	u16 rdma_recv_pci_bus_id;
+	u8 recv_pci_bus_id_valid : 1;
+	u8 rdma_read_pci_bus_id_valid : 1;
+	u8 rdma_recv_pci_bus_id_valid : 1;
+};
+
 struct efa_mr {
 	struct ib_mr ibmr;
 	struct ib_umem *umem;
+	struct efa_mr_pci_info pci_info;
 };
 
 struct efa_cq {
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h +31 -0
index 9c65bd27bae0..597f7ca6f31d 100644
@@ -415,6 +415,32 @@ struct efa_admin_reg_mr_resp {
 	 * memory region
 	 */
 	u32 r_key;
+
+	/*
+	 * Mask indicating which fields have valid values
+	 * 0 : recv_pci_bus_id
+	 * 1 : rdma_read_pci_bus_id
+	 * 2 : rdma_recv_pci_bus_id
+	 */
+	u8 validity;
+
+	/*
+	 * Physical PCIe bus used by the device to reach the MR for receive
+	 * operation
+	 */
+	u8 recv_pci_bus_id;
+
+	/*
+	 * Physical PCIe bus used by the device to reach the MR for RDMA read
+	 * operation
+	 */
+	u8 rdma_read_pci_bus_id;
+
+	/*
+	 * Physical PCIe bus used by the device to reach the MR for RDMA write
+	 * receive
+	 */
+	u8 rdma_recv_pci_bus_id;
 };
 
 struct efa_admin_dereg_mr_cmd {
@@ -999,6 +1025,11 @@ struct efa_admin_host_info {
 #define EFA_ADMIN_REG_MR_CMD_REMOTE_WRITE_ENABLE_MASK       BIT(1)
 #define EFA_ADMIN_REG_MR_CMD_REMOTE_READ_ENABLE_MASK        BIT(2)
 
+/* reg_mr_resp */
+#define EFA_ADMIN_REG_MR_RESP_RECV_PCI_BUS_ID_MASK          BIT(0)
+#define EFA_ADMIN_REG_MR_RESP_RDMA_READ_PCI_BUS_ID_MASK     BIT(1)
+#define EFA_ADMIN_REG_MR_RESP_RDMA_RECV_PCI_BUS_ID_MASK     BIT(2)
+
 /* create_cq_cmd */
 #define EFA_ADMIN_CREATE_CQ_CMD_INTERRUPT_MODE_ENABLED_MASK BIT(5)
 #define EFA_ADMIN_CREATE_CQ_CMD_VIRT_MASK                   BIT(6)
drivers/infiniband/hw/efa/efa_com_cmd.c +9 -0
index 576811885d59..4801640f9f4f 100644
@@ -270,6 +270,15 @@ int efa_com_register_mr(struct efa_com_dev *edev,
 
 	result->l_key = cmd_completion.l_key;
 	result->r_key = cmd_completion.r_key;
+	result->pci_info.recv_pci_bus_id = cmd_completion.recv_pci_bus_id;
+	result->pci_info.rdma_read_pci_bus_id = cmd_completion.rdma_read_pci_bus_id;
+	result->pci_info.rdma_recv_pci_bus_id = cmd_completion.rdma_recv_pci_bus_id;
+	result->pci_info.recv_pci_bus_id_valid = EFA_GET(&cmd_completion.validity,
+							 EFA_ADMIN_REG_MR_RESP_RECV_PCI_BUS_ID);
+	result->pci_info.rdma_read_pci_bus_id_valid = EFA_GET(&cmd_completion.validity,
+							      EFA_ADMIN_REG_MR_RESP_RDMA_READ_PCI_BUS_ID);
+	result->pci_info.rdma_recv_pci_bus_id_valid = EFA_GET(&cmd_completion.validity,
+							      EFA_ADMIN_REG_MR_RESP_RDMA_RECV_PCI_BUS_ID);
 
 	return 0;
 }
drivers/infiniband/hw/efa/efa_com_cmd.h +10 -0
index fc97f37bb39b..00635575c3b0 100644
@@ -199,6 +199,15 @@ struct efa_com_reg_mr_params {
 	u8 indirect;
 };
 
+struct efa_com_mr_pci_info {
+	u16 recv_pci_bus_id;
+	u16 rdma_read_pci_bus_id;
+	u16 rdma_recv_pci_bus_id;
+	u8 recv_pci_bus_id_valid : 1;
+	u8 rdma_read_pci_bus_id_valid : 1;
+	u8 rdma_recv_pci_bus_id_valid : 1;
+};
+
 struct efa_com_reg_mr_result {
 	/*
 	 * To be used in conjunction with local buffers references in SQ and
@@ -210,6 +219,7 @@ struct efa_com_reg_mr_result {
 	 * accessed memory region
 	 */
 	u32 r_key;
+	struct efa_com_mr_pci_info pci_info;
 };
 
 struct efa_com_dereg_mr_params {
drivers/infiniband/hw/efa/efa_main.c +5 -0
index 15ee92081118..da4f378c7c16 100644
@@ -9,6 +9,7 @@
 #include <linux/version.h>
 
 #include <rdma/ib_user_verbs.h>
+#include <rdma/uverbs_ioctl.h>
 
 #include "efa.h"
 
@@ -36,6 +37,8 @@ MODULE_DEVICE_TABLE(pci, efa_pci_tbl);
 	(BIT(EFA_ADMIN_FATAL_ERROR) | BIT(EFA_ADMIN_WARNING) | \
 	 BIT(EFA_ADMIN_NOTIFICATION) | BIT(EFA_ADMIN_KEEP_ALIVE))
 
+extern const struct uapi_definition efa_uapi_defs[];
+
 /* This handler will called for unknown event group or unimplemented handlers */
 static void unimplemented_aenq_handler(void *data,
 				       struct efa_admin_aenq_entry *aenq_e)
@@ -432,6 +435,8 @@ static int efa_ib_device_add(struct efa_dev *dev)
 
 	ib_set_device_ops(&dev->ibdev, &efa_dev_ops);
 
+	dev->ibdev.driver_def = efa_uapi_defs;
+
 	err = ib_register_device(&dev->ibdev, "efa_%d", &pdev->dev);
 	if (err)
 		goto err_destroy_eqs;
drivers/infiniband/hw/efa/efa_verbs.c +69 -0

90 lines not on this page · raw message

include/uapi/rdma/efa-abi.h +19 -0
index d94c32f28804..7ced04ca2ad9 100644
@@ -7,6 +7,7 @@
 #define EFA_ABI_USER_H
 
 #include <linux/types.h>
+#include <rdma/ib_user_ioctl_cmds.h>
 
 /*
  * Increment this value if any changes that break userspace ABI
@@ -134,4 +135,22 @@ struct efa_ibv_ex_query_device_resp {
 	__u32 device_caps;
 };
 
+enum {
+	EFA_QUERY_MR_VALIDITY_RECV_PCI_BUS_ID = 1 << 0,
+	EFA_QUERY_MR_VALIDITY_RDMA_READ_PCI_BUS_ID = 1 << 1,
+	EFA_QUERY_MR_VALIDITY_RDMA_RECV_PCI_BUS_ID = 1 << 2,
+};
+
+enum efa_query_mr_attrs {
+	EFA_IB_ATTR_QUERY_MR_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
+	EFA_IB_ATTR_QUERY_MR_RESP_PCI_BUS_ID_VALIDITY,
+	EFA_IB_ATTR_QUERY_MR_RESP_RECV_PCI_BUS_ID,
+	EFA_IB_ATTR_QUERY_MR_RESP_RDMA_READ_PCI_BUS_ID,
+	EFA_IB_ATTR_QUERY_MR_RESP_RDMA_RECV_PCI_BUS_ID,
+};
+
+enum efa_mr_methods {
+	EFA_IB_METHOD_MR_QUERY = (1U << UVERBS_ID_NS_SHIFT),
+};
+
 #endif /* EFA_ABI_USER_H */
Signature · 1 line
2.40.1
maintainer
#1 lore raw
Quoted 24 lines · Michael Margolin
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h +16 -0
index 9c65bd27bae0..597f7ca6f31d 100644
@@ -415,6 +415,32 @@ struct efa_admin_reg_mr_resp {
 	 * memory region
 	 */
 	u32 r_key;
+
+	/*
+	 * Mask indicating which fields have valid values
+	 * 0 : recv_pci_bus_id
+	 * 1 : rdma_read_pci_bus_id
+	 * 2 : rdma_recv_pci_bus_id
+	 */
+	u8 validity;
+
+	/*
+	 * Physical PCIe bus used by the device to reach the MR for receive
+	 * operation
+	 */
+	u8 recv_pci_bus_id;
+
+	/*

drivers/infiniband/hw/efa/efa_admin_cmds_defs.h struct efa_admin_reg_mr_resp { · line 443

Quoted 10 lines
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h +10 -0
+	 * Physical PCIe bus used by the device to reach the MR for RDMA read
+	 * operation
+	 */
+	u8 rdma_read_pci_bus_id;
+
+	/*
+	 * Physical PCIe bus used by the device to reach the MR for RDMA write
+	 * receive
+	 */
+	u8 rdma_recv_pci_bus_id;

What driver is bound to this other PCIe bus and how did the iommu get setup for it?

Jason

author maintainer
#2 lore raw
Quoted 42 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 24 lines · Michael Margolin
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h +16 -0
index 9c65bd27bae0..597f7ca6f31d 100644
@@ -415,6 +415,32 @@ struct efa_admin_reg_mr_resp {
       * memory region
       */
      u32 r_key;
+
+     /*
+      * Mask indicating which fields have valid values
+      * 0 : recv_pci_bus_id
+      * 1 : rdma_read_pci_bus_id
+      * 2 : rdma_recv_pci_bus_id
+      */
+     u8 validity;
+
+     /*
+      * Physical PCIe bus used by the device to reach the MR for receive
+      * operation
+      */
+     u8 recv_pci_bus_id;
+
+     /*

drivers/infiniband/hw/efa/efa_admin_cmds_defs.h struct efa_admin_reg_mr_resp { · line 443

Quoted 10 lines
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h +10 -0
+      * Physical PCIe bus used by the device to reach the MR for RDMA read
+      * operation
+      */
+     u8 rdma_read_pci_bus_id;
+
+     /*
+      * Physical PCIe bus used by the device to reach the MR for RDMA write
+      * receive
+      */
+     u8 rdma_recv_pci_bus_id;

What driver is bound to this other PCIe bus and how did the iommu get setup for it?

Quoted 1 line

Jason

It's internal bus that is not directly exposed to the host. Addresses mapping is acquired from accelerator's driver as for any MR residing in accelerator memory, and the translation is owned by devices on that bus.

Michael

author maintainer
#3 lore raw
Quoted 43 lines · Michael
Quoted 42 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 24 lines · Michael Margolin
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h +16 -0
index 9c65bd27bae0..597f7ca6f31d 100644
@@ -415,6 +415,32 @@ struct efa_admin_reg_mr_resp {
       * memory region
       */
      u32 r_key;
+
+     /*
+      * Mask indicating which fields have valid values
+      * 0 : recv_pci_bus_id
+      * 1 : rdma_read_pci_bus_id
+      * 2 : rdma_recv_pci_bus_id
+      */
+     u8 validity;
+
+     /*
+      * Physical PCIe bus used by the device to reach the MR for receive
+      * operation
+      */
+     u8 recv_pci_bus_id;
+
+     /*

drivers/infiniband/hw/efa/efa_admin_cmds_defs.h struct efa_admin_reg_mr_resp { · line 443

Quoted 10 lines
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h +10 -0
+      * Physical PCIe bus used by the device to reach the MR for RDMA read
+      * operation
+      */
+     u8 rdma_read_pci_bus_id;
+
+     /*
+      * Physical PCIe bus used by the device to reach the MR for RDMA write
+      * receive
+      */
+     u8 rdma_recv_pci_bus_id;

What driver is bound to this other PCIe bus and how did the iommu get setup for it?

Quoted 7 lines
Quoted 1 line

Jason

It's internal bus that is not directly exposed to the host. Addresses mapping is acquired from accelerator's driver as for any MR residing in accelerator memory, and the translation is owned by devices on that bus.

Michael

Hi,

Just want to make sure if there are any questions / comments regarding to this patch that haven't been addressed?

Michael

#4 lore raw
Quoted 51 lines · Michael
Quoted 49 lines · Michael
Quoted 42 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 24 lines · Michael Margolin
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h +16 -0
index 9c65bd27bae0..597f7ca6f31d 100644
@@ -415,6 +415,32 @@ struct efa_admin_reg_mr_resp {
       * memory region
       */
      u32 r_key;
+
+     /*
+      * Mask indicating which fields have valid values
+      * 0 : recv_pci_bus_id
+      * 1 : rdma_read_pci_bus_id
+      * 2 : rdma_recv_pci_bus_id
+      */
+     u8 validity;
+
+     /*
+      * Physical PCIe bus used by the device to reach the MR for receive
+      * operation
+      */
+     u8 recv_pci_bus_id;
+
+     /*

drivers/infiniband/hw/efa/efa_admin_cmds_defs.h struct efa_admin_reg_mr_resp { · line 443

Quoted 10 lines
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h +10 -0
+      * Physical PCIe bus used by the device to reach the MR for RDMA read
+      * operation
+      */
+     u8 rdma_read_pci_bus_id;
+
+     /*
+      * Physical PCIe bus used by the device to reach the MR for RDMA write
+      * receive
+      */
+     u8 rdma_recv_pci_bus_id;

What driver is bound to this other PCIe bus and how did the iommu get setup for it?

Quoted 1 line

Jason

It's internal bus that is not directly exposed to the host. Addresses mapping is acquired from accelerator's driver as for any MR residing in accelerator memory, and the translation is owned by devices on that bus.

Quoted 6 lines
Quoted 1 line

Michael

Hi,

Just want to make sure if there are any questions / comments regarding to this patch that haven't been addressed?

I'm waiting from Jason ack/nack on this patch as he was the one who asked the question.

Thanks

Quoted 4 lines

Michael

maintainer
#5 lore raw
In reply to Margolin, Michael
Quoted 38 lines · Michael
Quoted 29 lines · Michael Margolin
Quoted 28 lines
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h +20 -0
index 9c65bd27bae0..597f7ca6f31d 100644
@@ -415,6 +415,32 @@ struct efa_admin_reg_mr_resp {
       * memory region
       */
      u32 r_key;
+
+     /*
+      * Mask indicating which fields have valid values
+      * 0 : recv_pci_bus_id
+      * 1 : rdma_read_pci_bus_id
+      * 2 : rdma_recv_pci_bus_id
+      */
+     u8 validity;
+
+     /*
+      * Physical PCIe bus used by the device to reach the MR for receive
+      * operation
+      */
+     u8 recv_pci_bus_id;
+
+     /*
+      * Physical PCIe bus used by the device to reach the MR for RDMA read
+      * operation
+      */
+     u8 rdma_read_pci_bus_id;
Quoted 8 lines

drivers/infiniband/hw/efa/efa_admin_cmds_defs.h struct efa_admin_reg_mr_resp { · line 443

Quoted 6 lines
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h +6 -0
+
+     /*
+      * Physical PCIe bus used by the device to reach the MR for RDMA write
+      * receive
+      */
+     u8 rdma_recv_pci_bus_id;

What driver is bound to this other PCIe bus and how did the iommu get setup for it?

Quoted 3 lines

It's internal bus that is not directly exposed to the host. Addresses mapping is acquired from accelerator's driver as for any MR residing in accelerator memory, and the translation is owned by devices on that bus.

So if it isn't visible to the host, or connectable to anything Linux would call a PCI RID, why are you giving it such specific names? Just call it 'interconnect path id' or something and make it opaque?

Jason

author maintainer
#6 lore raw
Quoted 42 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 37 lines · Michael
Quoted 37 lines · Michael Margolin
Quoted 24 lines
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h +16 -0
index 9c65bd27bae0..597f7ca6f31d 100644
@@ -415,6 +415,32 @@ struct efa_admin_reg_mr_resp {
        * memory region
        */
       u32 r_key;
+
+     /*
+      * Mask indicating which fields have valid values
+      * 0 : recv_pci_bus_id
+      * 1 : rdma_read_pci_bus_id
+      * 2 : rdma_recv_pci_bus_id
+      */
+     u8 validity;
+
+     /*
+      * Physical PCIe bus used by the device to reach the MR for receive
+      * operation
+      */
+     u8 recv_pci_bus_id;
+
+     /*

drivers/infiniband/hw/efa/efa_admin_cmds_defs.h struct efa_admin_reg_mr_resp { · line 443

Quoted 10 lines
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h +10 -0
+      * Physical PCIe bus used by the device to reach the MR for RDMA read
+      * operation
+      */
+     u8 rdma_read_pci_bus_id;
+
+     /*
+      * Physical PCIe bus used by the device to reach the MR for RDMA write
+      * receive
+      */
+     u8 rdma_recv_pci_bus_id;

What driver is bound to this other PCIe bus and how did the iommu get setup for it?

Quoted 8 lines
Quoted 3 lines

It's internal bus that is not directly exposed to the host. Addresses mapping is acquired from accelerator's driver as for any MR residing in accelerator memory, and the translation is owned by devices on that bus.

So if it isn't visible to the host, or connectable to anything Linux would call a PCI RID, why are you giving it such specific names? Just call it 'interconnect path id' or something and make it opaque?

Jason

I would like it to be as opaque as possible but on the other hand to express that the mentioned 'interconnect path' relates specifically to PCI path.

I think that except of this, since 'bus_id' is quite general term that cannot be used without proper context, it isn't likely to cause any unintended use of those fields.

Michael

maintainer
#7 lore raw
Quoted 2 lines · Michael

I would like it to be as opaque as possible but on the other hand to express that the mentioned 'interconnect path' relates specifically to PCI path.

Who cares it is a "PCI path" if the the thing is totally invisible? It is some hidden implementation detail of your device that today happens to be PCI.

There are many ways to get interconnect multipath coming, including PCIe UIO.

Jason

author maintainer
#8 lore raw
Quoted 8 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 2 lines · Michael

I would like it to be as opaque as possible but on the other hand to express that the mentioned 'interconnect path' relates specifically to PCI path.

Quoted 8 lines

Who cares it is a "PCI path" if the the thing is totally invisible? It is some hidden implementation detail of your device that today happens to be PCI.

There are many ways to get interconnect multipath coming, including PCIe UIO.

Jason

Ok, changed according to your suggestion.

Michael