Skip to contentSkip to conversation

RDMA/vmw_pvrdma: Add RoCEv2 support

PATCH In review Adit Ranadive 2 participants 9 messages Aug 18, 2017 – Aug 21, 2017 6 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover RDMA/vmw_pvrdma: Add RoCEv2 support

Hi Doug,

These are a set of patches to add RoCEv2 support for the VMware PVRDMA driver as well as exposing some device caps. Please add these to your 4.14 queue.

Thanks,
Adit
---
Adit Ranadive (2):
RDMA/vmw_pvrdma: Update device query parameters
RDMA/vmw_pvrdma: Add new port_cap flag

Bryan Tan (1):
RDMA/vmw_pvrdma: Add RoCEv2 support

 drivers/infiniband/hw/vmw_pvrdma/pvrdma.h         |  3 +++
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h | 12 +++++++--
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c    | 30 +++++++++++++----------
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_misc.c    | 14 +++++++++++
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c   | 10 ++++++++
 5 files changed, 54 insertions(+), 15 deletions(-)
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): cover.1503073950.git.aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org

#2 lore raw

PATCH 1/3 RDMA/vmw_pvrdma: Add RoCEv2 support

From: Bryan Tan <[email protected]>

The driver version is bumped for compatibility purposes. Also, send correct GID type during register to device.

---
 drivers/infiniband/hw/vmw_pvrdma/pvrdma.h         |  2 ++
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h |  9 +++++++-
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c    | 25 ++++++++++++++---------
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_misc.c    | 14 +++++++++++++
 4 files changed, 39 insertions(+), 11 deletions(-)
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +2 -0
index 8e2f0a1..513a182 100644
@@ -444,6 +444,8 @@ void pvrdma_ah_attr_to_rdma(struct rdma_ah_attr *dst,
 			    const struct pvrdma_ah_attr *src);
 void rdma_ah_attr_to_pvrdma(struct pvrdma_ah_attr *dst,
 			    const struct rdma_ah_attr *src);
+enum ib_gid_type pvrdma_gid_type_to_ib(u8 gid_type);
+u8 ib_gid_type_to_pvrdma(enum ib_gid_type gid_type);
 
 int pvrdma_uar_table_init(struct pvrdma_dev *dev);
 void pvrdma_uar_table_cleanup(struct pvrdma_dev *dev);
drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h +8 -1
index 09078cc..71df5d1 100644
@@ -50,7 +50,7 @@
 
 #include "pvrdma_verbs.h"
 
-#define PVRDMA_VERSION			17
+#define PVRDMA_VERSION			18
 #define PVRDMA_BOARD_ID			1
 #define PVRDMA_REV_ID			1
 
@@ -123,6 +123,13 @@
 #define PVRDMA_GID_TYPE_FLAG_ROCE_V1	BIT(0)
 #define PVRDMA_GID_TYPE_FLAG_ROCE_V2	BIT(1)
 
+/*
+ * PVRDMA version macros. Some new features require updates to PVRDMA_VERSION.
+ * These macros allow us to check for different features if necessary.
+ */
+
+#define PVRDMA_VERSION_ROCEV2_SUPPORT	18
+
 enum pvrdma_pci_resource {
 	PVRDMA_PCI_RESOURCE_MSIX,	/* BAR0: MSI-X, MMIO. */
 	PVRDMA_PCI_RESOURCE_REG,	/* BAR1: Registers, MMIO. */
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +15 -10
index 7f29e4d..6fd5828 100644
@@ -128,10 +128,14 @@ static int pvrdma_init_device(struct pvrdma_dev *dev)
 static int pvrdma_port_immutable(struct ib_device *ibdev, u8 port_num,
 				 struct ib_port_immutable *immutable)
 {
+	struct pvrdma_dev *dev = to_vdev(ibdev);
 	struct ib_port_attr attr;
 	int err;
 
-	immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE;
+	if (dev->dsr->caps.gid_types == PVRDMA_GID_TYPE_FLAG_ROCE_V1)
+		immutable->core_cap_flags |= RDMA_CORE_PORT_IBA_ROCE;
+	else if (dev->dsr->caps.gid_types == PVRDMA_GID_TYPE_FLAG_ROCE_V2)
+		immutable->core_cap_flags |= RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP;
 
 	err = ib_query_port(ibdev, port_num, &attr);
 	if (err)
@@ -569,6 +573,7 @@ static void pvrdma_free_slots(struct pvrdma_dev *dev)
 
 static int pvrdma_add_gid_at_index(struct pvrdma_dev *dev,
 				   const union ib_gid *gid,
+				   u8 gid_type,
 				   int index)
 {
 	int ret;
@@ -586,7 +591,7 @@ static int pvrdma_add_gid_at_index(struct pvrdma_dev *dev,
 	cmd_bind->mtu = ib_mtu_enum_to_int(IB_MTU_1024);
 	cmd_bind->vlan = 0xfff;
 	cmd_bind->index = index;
-	cmd_bind->gid_type = PVRDMA_GID_TYPE_FLAG_ROCE_V1;
+	cmd_bind->gid_type = gid_type;
 
 	ret = pvrdma_cmd_post(dev, &req, NULL, 0);
 	if (ret < 0) {
@@ -607,7 +612,9 @@ static int pvrdma_add_gid(struct ib_device *ibdev,
 {
 	struct pvrdma_dev *dev = to_vdev(ibdev);
 
-	return pvrdma_add_gid_at_index(dev, gid, index);
+	return pvrdma_add_gid_at_index(dev, gid,
+				       ib_gid_type_to_pvrdma(attr->gid_type),
+				       index);
 }
 
 static int pvrdma_del_gid_at_index(struct pvrdma_dev *dev, int index)
@@ -822,10 +829,6 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
 	version = pvrdma_read_reg(dev, PVRDMA_REG_VERSION);
 	dev_info(&pdev->dev, "device version %d, driver version %d\n",
 		 version, PVRDMA_VERSION);
-	if (version < PVRDMA_VERSION) {
-		dev_err(&pdev->dev, "incompatible device version\n");
-		goto err_uar_unmap;
-	}
 
 	dev->dsr = dma_alloc_coherent(&pdev->dev, sizeof(*dev->dsr),
 				      &dev->dsrbase, GFP_KERNEL);
@@ -904,9 +907,11 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
 		goto err_free_cq_ring;
 	}
 
-	/* Currently, the driver only supports RoCE V1. */
-	if (!(dev->dsr->caps.gid_types & PVRDMA_GID_TYPE_FLAG_ROCE_V1)) {
-		dev_err(&pdev->dev, "driver needs RoCE v1 support\n");
+	/* PVRDMA supports RoCE V1 or V2. */
+	if (version >= PVRDMA_VERSION_ROCEV2_SUPPORT &&
+	    !((dev->dsr->caps.gid_types & PVRDMA_GID_TYPE_FLAG_ROCE_V1) ||
+	      (dev->dsr->caps.gid_types & PVRDMA_GID_TYPE_FLAG_ROCE_V2))) {
+		dev_err(&pdev->dev, "driver needs RoCE v1 or v2 support\n");
 		ret = -EFAULT;
 		goto err_free_cq_ring;
 	}
drivers/infiniband/hw/vmw_pvrdma/pvrdma_misc.c +14 -0
index ec6a4ca..0861e28 100644
@@ -303,3 +303,17 @@ void rdma_ah_attr_to_pvrdma(struct pvrdma_ah_attr *dst,
 	dst->port_num = rdma_ah_get_port_num(src);
 	memcpy(&dst->dmac, src->roce.dmac, sizeof(dst->dmac));
 }
+
+enum ib_gid_type pvrdma_gid_type_to_ib(u8 gid_type)
+{
+	return (gid_type == PVRDMA_GID_TYPE_FLAG_ROCE_V2) ?
+		IB_GID_TYPE_ROCE_UDP_ENCAP :
+		IB_GID_TYPE_ROCE;
+}
+
+u8 ib_gid_type_to_pvrdma(enum ib_gid_type gid_type)
+{
+	return (gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP) ?
+		PVRDMA_GID_TYPE_FLAG_ROCE_V2 :
+		PVRDMA_GID_TYPE_FLAG_ROCE_V1;
+}
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

PATCH 2/3 RDMA/vmw_pvrdma: Update device query parameters

In reply to a message not in the archive

Added support for two device caps - max_sge_rd, max_fast_reg_page_list_len. Simplified some of the RoCEv2 versioning code and added 2 more device cap flags.

---
 drivers/infiniband/hw/vmw_pvrdma/pvrdma.h         |  1 +
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h | 19 ++++++++++---------
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c    |  7 +++----
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c   |  9 +++++++++
 4 files changed, 23 insertions(+), 13 deletions(-)
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +1 -0
index 513a182..ea10155 100644
@@ -194,6 +194,7 @@ struct pvrdma_dev {
 	void *resp_slot;
 	unsigned long flags;
 	struct list_head device_link;
+	unsigned int dsr_version;
 
 	/* Locking and interrupt information. */
 	spinlock_t cmd_lock; /* Command lock. */
drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h +10 -9
index 71df5d1..d947557 100644
@@ -50,7 +50,15 @@
 
 #include "pvrdma_verbs.h"
 
-#define PVRDMA_VERSION			18
+/*
+ * PVRDMA version macros. Some new features require updates to PVRDMA_VERSION.
+ * These macros allow us to check for different features if necessary.
+ */
+
+#define PVRDMA_ROCEV1_VERSION		17
+#define PVRDMA_ROCEV2_VERSION		18
+#define PVRDMA_VERSION			PVRDMA_ROCEV2_VERSION
+
 #define PVRDMA_BOARD_ID			1
 #define PVRDMA_REV_ID			1
 
@@ -123,13 +131,6 @@
 #define PVRDMA_GID_TYPE_FLAG_ROCE_V1	BIT(0)
 #define PVRDMA_GID_TYPE_FLAG_ROCE_V2	BIT(1)
 
-/*
- * PVRDMA version macros. Some new features require updates to PVRDMA_VERSION.
- * These macros allow us to check for different features if necessary.
- */
-
-#define PVRDMA_VERSION_ROCEV2_SUPPORT	18
-
 enum pvrdma_pci_resource {
 	PVRDMA_PCI_RESOURCE_MSIX,	/* BAR0: MSI-X, MMIO. */
 	PVRDMA_PCI_RESOURCE_REG,	/* BAR1: Registers, MMIO. */
@@ -232,7 +233,7 @@ struct pvrdma_device_caps {
 	u8  atomic_ops;				/* PVRDMA_ATOMIC_OP_* bits */
 	u8  bmme_flags;				/* FRWR Mem Mgmt Extensions */
 	u8  gid_types;				/* PVRDMA_GID_TYPE_FLAG_ */
-	u8  reserved[4];
+	u32 max_fast_reg_page_list_len;
 };
 
 struct pvrdma_ring_page_info {
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +3 -4
index 6fd5828..ae536a4 100644
@@ -729,7 +729,6 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
 	int ret;
 	unsigned long start;
 	unsigned long len;
-	unsigned int version;
 	dma_addr_t slot_dma = 0;
 
 	dev_dbg(&pdev->dev, "initializing driver %s\n", pci_name(pdev));
@@ -826,9 +825,9 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
 		goto err_unmap_regs;
 	}
 
-	version = pvrdma_read_reg(dev, PVRDMA_REG_VERSION);
+	dev->dsr_version = pvrdma_read_reg(dev, PVRDMA_REG_VERSION);
 	dev_info(&pdev->dev, "device version %d, driver version %d\n",
-		 version, PVRDMA_VERSION);
+		 dev->dsr_version, PVRDMA_VERSION);
 
 	dev->dsr = dma_alloc_coherent(&pdev->dev, sizeof(*dev->dsr),
 				      &dev->dsrbase, GFP_KERNEL);
@@ -908,7 +907,7 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
 	}
 
 	/* PVRDMA supports RoCE V1 or V2. */
-	if (version >= PVRDMA_VERSION_ROCEV2_SUPPORT &&
+	if (dev->dsr_version >= PVRDMA_ROCEV2_VERSION &&
 	    !((dev->dsr->caps.gid_types & PVRDMA_GID_TYPE_FLAG_ROCE_V1) ||
 	      (dev->dsr->caps.gid_types & PVRDMA_GID_TYPE_FLAG_ROCE_V2))) {
 		dev_err(&pdev->dev, "driver needs RoCE v1 or v2 support\n");
drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c +9 -0
index 2851704..0b19d1a 100644
@@ -83,6 +83,8 @@ int pvrdma_query_device(struct ib_device *ibdev,
 	props->max_qp_wr = dev->dsr->caps.max_qp_wr;
 	props->device_cap_flags = dev->dsr->caps.device_cap_flags;
 	props->max_sge = dev->dsr->caps.max_sge;
+	props->max_sge_rd = (dev->dsr_version >= PVRDMA_ROCEV2_VERSION) ?
+			     dev->dsr->caps.max_sge_rd : dev->dsr->caps.max_sge;
 	props->max_cq = dev->dsr->caps.max_cq;
 	props->max_cqe = dev->dsr->caps.max_cqe;
 	props->max_mr = dev->dsr->caps.max_mr;
@@ -100,9 +102,16 @@ int pvrdma_query_device(struct ib_device *ibdev,
 	if ((dev->dsr->caps.bmme_flags & PVRDMA_BMME_FLAG_LOCAL_INV) &&
 	    (dev->dsr->caps.bmme_flags & PVRDMA_BMME_FLAG_REMOTE_INV) &&
 	    (dev->dsr->caps.bmme_flags & PVRDMA_BMME_FLAG_FAST_REG_WR)) {
+		props->max_fast_reg_page_list_len =
+		(dev->dsr_version >= PVRDMA_ROCEV2_VERSION) ?
+		 dev->dsr->caps.max_fast_reg_page_list_len :
+		 PVRDMA_MAX_FAST_REG_PAGES;
 		props->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS;
 	}
 
+	props->device_cap_flags |= IB_DEVICE_PORT_ACTIVE_EVENT |
+				   IB_DEVICE_RC_RNR_NAK_GEN;
+
 	return 0;
 }
 
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 6eb31ebec69c1d28b83cb44e84cdb01ebdec3827.1503073950.git.aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org

#5 lore raw

Re: [PATCH for-next 2/3] RDMA/vmw_pvrdma: Update device query parameters

Quoted 48 lines · Adit Ranadive

Added support for two device caps - max_sge_rd, max_fast_reg_page_list_len. Simplified some of the RoCEv2 versioning code and added 2 more device cap flags.

---
 drivers/infiniband/hw/vmw_pvrdma/pvrdma.h         |  1 +
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h | 19 ++++++++++---------
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c    |  7 +++----
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c   |  9 +++++++++
 4 files changed, 23 insertions(+), 13 deletions(-)
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +1 -0
index 513a182..ea10155 100644
@@ -194,6 +194,7 @@ struct pvrdma_dev {
 	void *resp_slot;
 	unsigned long flags;
 	struct list_head device_link;
+	unsigned int dsr_version;
 
 	/* Locking and interrupt information. */
 	spinlock_t cmd_lock; /* Command lock. */
drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h +9 -1
index 71df5d1..d947557 100644
@@ -50,7 +50,15 @@
 
 #include "pvrdma_verbs.h"
 
-#define PVRDMA_VERSION			18
+/*
+ * PVRDMA version macros. Some new features require updates to PVRDMA_VERSION.
+ * These macros allow us to check for different features if necessary.
+ */
+
+#define PVRDMA_ROCEV1_VERSION		17
+#define PVRDMA_ROCEV2_VERSION		18
+#define PVRDMA_VERSION			PVRDMA_ROCEV2_VERSION
+
 #define PVRDMA_BOARD_ID			1
 #define PVRDMA_REV_ID			1
 

drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h line 132

Quoted 10 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h +0 -7
@@ -123,13 +131,6 @@
 #define PVRDMA_GID_TYPE_FLAG_ROCE_V1	BIT(0)
 #define PVRDMA_GID_TYPE_FLAG_ROCE_V2	BIT(1)
 
-/*
- * PVRDMA version macros. Some new features require updates to PVRDMA_VERSION.
- * These macros allow us to check for different features if necessary.
- */
-
-#define PVRDMA_VERSION_ROCEV2_SUPPORT	18
-

You added it in previous patch of the same series. Please don't send patches with code which is going to be removed/rewritten immediately.

Quoted 37 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h +1 -1
 enum pvrdma_pci_resource {
 	PVRDMA_PCI_RESOURCE_MSIX,	/* BAR0: MSI-X, MMIO. */
 	PVRDMA_PCI_RESOURCE_REG,	/* BAR1: Registers, MMIO. */
@@ -232,7 +233,7 @@ struct pvrdma_device_caps {
 	u8  atomic_ops;				/* PVRDMA_ATOMIC_OP_* bits */
 	u8  bmme_flags;				/* FRWR Mem Mgmt Extensions */
 	u8  gid_types;				/* PVRDMA_GID_TYPE_FLAG_ */
-	u8  reserved[4];
+	u32 max_fast_reg_page_list_len;
 };
 
 struct pvrdma_ring_page_info {
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +2 -3
index 6fd5828..ae536a4 100644
@@ -729,7 +729,6 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
 	int ret;
 	unsigned long start;
 	unsigned long len;
-	unsigned int version;
 	dma_addr_t slot_dma = 0;
 
 	dev_dbg(&pdev->dev, "initializing driver %s\n", pci_name(pdev));
@@ -826,9 +825,9 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
 		goto err_unmap_regs;
 	}
 
-	version = pvrdma_read_reg(dev, PVRDMA_REG_VERSION);
+	dev->dsr_version = pvrdma_read_reg(dev, PVRDMA_REG_VERSION);
 	dev_info(&pdev->dev, "device version %d, driver version %d\n",
-		 version, PVRDMA_VERSION);
+		 dev->dsr_version, PVRDMA_VERSION);
 
 	dev->dsr = dma_alloc_coherent(&pdev->dev, sizeof(*dev->dsr),
 				      &dev->dsrbase, GFP_KERNEL);

drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c static int pvrdma_pci_probe(struct pci_dev *pdev, · line 910

Quoted 5 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +1 -1
@@ -908,7 +907,7 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
 	}
 
 	/* PVRDMA supports RoCE V1 or V2. */
-	if (version >= PVRDMA_VERSION_ROCEV2_SUPPORT &&
+	if (dev->dsr_version >= PVRDMA_ROCEV2_VERSION &&

Your whole idea of version is shaky. You need to move to capability bits per feature model and not rely on global version. In the near future, your code will be full of checks like this.

There is a reason why you don't see many device driver here relies on FW version, which is similar to your versioning scheme.

Thanks

Quoted 40 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +0 -0
 	    !((dev->dsr->caps.gid_types & PVRDMA_GID_TYPE_FLAG_ROCE_V1) ||
 	      (dev->dsr->caps.gid_types & PVRDMA_GID_TYPE_FLAG_ROCE_V2))) {
 		dev_err(&pdev->dev, "driver needs RoCE v1 or v2 support\n");
drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c +9 -1
index 2851704..0b19d1a 100644
@@ -83,6 +83,8 @@ int pvrdma_query_device(struct ib_device *ibdev,
 	props->max_qp_wr = dev->dsr->caps.max_qp_wr;
 	props->device_cap_flags = dev->dsr->caps.device_cap_flags;
 	props->max_sge = dev->dsr->caps.max_sge;
+	props->max_sge_rd = (dev->dsr_version >= PVRDMA_ROCEV2_VERSION) ?
+			     dev->dsr->caps.max_sge_rd : dev->dsr->caps.max_sge;
 	props->max_cq = dev->dsr->caps.max_cq;
 	props->max_cqe = dev->dsr->caps.max_cqe;
 	props->max_mr = dev->dsr->caps.max_mr;
@@ -100,9 +102,16 @@ int pvrdma_query_device(struct ib_device *ibdev,
 	if ((dev->dsr->caps.bmme_flags & PVRDMA_BMME_FLAG_LOCAL_INV) &&
 	    (dev->dsr->caps.bmme_flags & PVRDMA_BMME_FLAG_REMOTE_INV) &&
 	    (dev->dsr->caps.bmme_flags & PVRDMA_BMME_FLAG_FAST_REG_WR)) {
+		props->max_fast_reg_page_list_len =
+		(dev->dsr_version >= PVRDMA_ROCEV2_VERSION) ?
+		 dev->dsr->caps.max_fast_reg_page_list_len :
+		 PVRDMA_MAX_FAST_REG_PAGES;
 		props->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS;
 	}
 
+	props->device_cap_flags |= IB_DEVICE_PORT_ACTIVE_EVENT |
+				   IB_DEVICE_RC_RNR_NAK_GEN;
+
 	return 0;
 }
 
--

2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170820061122.GD18138-U/[email protected]

#7 lore raw

Re: [PATCH for-next 2/3] RDMA/vmw_pvrdma: Update device query parameters

Quoted 52 lines · Leon Romanovsky
Quoted 51 lines · Adit Ranadive

Added support for two device caps - max_sge_rd, max_fast_reg_page_list_len. Simplified some of the RoCEv2 versioning code and added 2 more device cap flags.

---
 drivers/infiniband/hw/vmw_pvrdma/pvrdma.h         |  1 +
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h | 19 ++++++++++---------
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c    |  7 +++----
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c   |  9 +++++++++
 4 files changed, 23 insertions(+), 13 deletions(-)
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +1 -0
index 513a182..ea10155 100644
@@ -194,6 +194,7 @@ struct pvrdma_dev {
 	void *resp_slot;
 	unsigned long flags;
 	struct list_head device_link;
+	unsigned int dsr_version;
 
 	/* Locking and interrupt information. */
 	spinlock_t cmd_lock; /* Command lock. */
drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h +9 -1
index 71df5d1..d947557 100644
@@ -50,7 +50,15 @@
 
 #include "pvrdma_verbs.h"
 
-#define PVRDMA_VERSION			18
+/*
+ * PVRDMA version macros. Some new features require updates to PVRDMA_VERSION.
+ * These macros allow us to check for different features if necessary.
+ */
+
+#define PVRDMA_ROCEV1_VERSION		17
+#define PVRDMA_ROCEV2_VERSION		18
+#define PVRDMA_VERSION			PVRDMA_ROCEV2_VERSION
+
 #define PVRDMA_BOARD_ID			1
 #define PVRDMA_REV_ID			1
 
@@ -123,13 +131,6 @@
 #define PVRDMA_GID_TYPE_FLAG_ROCE_V1	BIT(0)
 #define PVRDMA_GID_TYPE_FLAG_ROCE_V2	BIT(1)
 
Quoted 10 lines

drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h line 132

Quoted 7 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h +0 -7
-/*
- * PVRDMA version macros. Some new features require updates to PVRDMA_VERSION.
- * These macros allow us to check for different features if necessary.
- */
-
-#define PVRDMA_VERSION_ROCEV2_SUPPORT	18
-

You added it in previous patch of the same series. Please don't send patches with code which is going to be removed/rewritten immediately.

The previous patch was posted a while back internally. I had to do some cleanup (second patch) before sending it out. I'll send out a v1 with this merged into the first patch.

Quoted 40 lines
Quoted 40 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h +1 -1
 enum pvrdma_pci_resource {
 	PVRDMA_PCI_RESOURCE_MSIX,	/* BAR0: MSI-X, MMIO. */
 	PVRDMA_PCI_RESOURCE_REG,	/* BAR1: Registers, MMIO. */
@@ -232,7 +233,7 @@ struct pvrdma_device_caps {
 	u8  atomic_ops;				/* PVRDMA_ATOMIC_OP_* bits */
 	u8  bmme_flags;				/* FRWR Mem Mgmt Extensions */
 	u8  gid_types;				/* PVRDMA_GID_TYPE_FLAG_ */
-	u8  reserved[4];
+	u32 max_fast_reg_page_list_len;
 };
 
 struct pvrdma_ring_page_info {
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +2 -3
index 6fd5828..ae536a4 100644
@@ -729,7 +729,6 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
 	int ret;
 	unsigned long start;
 	unsigned long len;
-	unsigned int version;
 	dma_addr_t slot_dma = 0;
 
 	dev_dbg(&pdev->dev, "initializing driver %s\n", pci_name(pdev));
@@ -826,9 +825,9 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
 		goto err_unmap_regs;
 	}
 
-	version = pvrdma_read_reg(dev, PVRDMA_REG_VERSION);
+	dev->dsr_version = pvrdma_read_reg(dev, PVRDMA_REG_VERSION);
 	dev_info(&pdev->dev, "device version %d, driver version %d\n",
-		 version, PVRDMA_VERSION);
+		 dev->dsr_version, PVRDMA_VERSION);
 
 	dev->dsr = dma_alloc_coherent(&pdev->dev, sizeof(*dev->dsr),
 				      &dev->dsrbase, GFP_KERNEL);
@@ -908,7 +907,7 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
 	}
 
Quoted 7 lines

drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c static int pvrdma_pci_probe(struct pci_dev *pdev, · line 910

Quoted 3 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +1 -1
 	/* PVRDMA supports RoCE V1 or V2. */
-	if (version >= PVRDMA_VERSION_ROCEV2_SUPPORT &&
+	if (dev->dsr_version >= PVRDMA_ROCEV2_VERSION &&

Your whole idea of version is shaky. You need to move to capability bits per feature model and not rely on global version. In the near future, your code will be full of checks like this.

Why does the type of check matter? We would have to do a check anyway if there were capability bits exposed. In our case the global version is essentially the feature model for the device given that it isn't as feature rich as some of the other RDMA providers so doing a blanket check on the version seems the simplest way to go. I think the check here for the version is redundant anyways and can remove that in v1.

Quoted 2 lines

There is a reason why you don't see many device driver here relies on FW version, which is similar to your versioning scheme.

I agree but in our case we can't update the FW version without exposing any new capabilities (due to compatibility reasons) so is essentially tied to the feature caps. As a compromise I can add a macro that checks the caps so the various version checks are a bit less obnoxious.

Thanks,
Adit
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 32182246-e301-4529-c63a-20e616bb6f2a-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org

#9 lore raw

Re: [PATCH for-next 2/3] RDMA/vmw_pvrdma: Update device query parameters

Quoted 116 lines · Adit Ranadive
Quoted 52 lines · Leon Romanovsky
Quoted 51 lines · Adit Ranadive

Added support for two device caps - max_sge_rd, max_fast_reg_page_list_len. Simplified some of the RoCEv2 versioning code and added 2 more device cap flags.

---
 drivers/infiniband/hw/vmw_pvrdma/pvrdma.h         |  1 +
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h | 19 ++++++++++---------
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c    |  7 +++----
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c   |  9 +++++++++
 4 files changed, 23 insertions(+), 13 deletions(-)
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +1 -0
index 513a182..ea10155 100644
@@ -194,6 +194,7 @@ struct pvrdma_dev {
 	void *resp_slot;
 	unsigned long flags;
 	struct list_head device_link;
+	unsigned int dsr_version;
 
 	/* Locking and interrupt information. */
 	spinlock_t cmd_lock; /* Command lock. */
drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h +9 -1
index 71df5d1..d947557 100644
@@ -50,7 +50,15 @@
 
 #include "pvrdma_verbs.h"
 
-#define PVRDMA_VERSION			18
+/*
+ * PVRDMA version macros. Some new features require updates to PVRDMA_VERSION.
+ * These macros allow us to check for different features if necessary.
+ */
+
+#define PVRDMA_ROCEV1_VERSION		17
+#define PVRDMA_ROCEV2_VERSION		18
+#define PVRDMA_VERSION			PVRDMA_ROCEV2_VERSION
+
 #define PVRDMA_BOARD_ID			1
 #define PVRDMA_REV_ID			1
 
@@ -123,13 +131,6 @@
 #define PVRDMA_GID_TYPE_FLAG_ROCE_V1	BIT(0)
 #define PVRDMA_GID_TYPE_FLAG_ROCE_V2	BIT(1)
 
Quoted 10 lines

drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h line 132

Quoted 7 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h +0 -7
-/*
- * PVRDMA version macros. Some new features require updates to PVRDMA_VERSION.
- * These macros allow us to check for different features if necessary.
- */
-
-#define PVRDMA_VERSION_ROCEV2_SUPPORT	18
-

You added it in previous patch of the same series. Please don't send patches with code which is going to be removed/rewritten immediately.

The previous patch was posted a while back internally. I had to do some cleanup (second patch) before sending it out. I'll send out a v1 with this merged into the first patch.

Quoted 40 lines
Quoted 40 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h +1 -1
 enum pvrdma_pci_resource {
 	PVRDMA_PCI_RESOURCE_MSIX,	/* BAR0: MSI-X, MMIO. */
 	PVRDMA_PCI_RESOURCE_REG,	/* BAR1: Registers, MMIO. */
@@ -232,7 +233,7 @@ struct pvrdma_device_caps {
 	u8  atomic_ops;				/* PVRDMA_ATOMIC_OP_* bits */
 	u8  bmme_flags;				/* FRWR Mem Mgmt Extensions */
 	u8  gid_types;				/* PVRDMA_GID_TYPE_FLAG_ */
-	u8  reserved[4];
+	u32 max_fast_reg_page_list_len;
 };
 
 struct pvrdma_ring_page_info {
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +2 -3
index 6fd5828..ae536a4 100644
@@ -729,7 +729,6 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
 	int ret;
 	unsigned long start;
 	unsigned long len;
-	unsigned int version;
 	dma_addr_t slot_dma = 0;
 
 	dev_dbg(&pdev->dev, "initializing driver %s\n", pci_name(pdev));
@@ -826,9 +825,9 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
 		goto err_unmap_regs;
 	}
 
-	version = pvrdma_read_reg(dev, PVRDMA_REG_VERSION);
+	dev->dsr_version = pvrdma_read_reg(dev, PVRDMA_REG_VERSION);
 	dev_info(&pdev->dev, "device version %d, driver version %d\n",
-		 version, PVRDMA_VERSION);
+		 dev->dsr_version, PVRDMA_VERSION);
 
 	dev->dsr = dma_alloc_coherent(&pdev->dev, sizeof(*dev->dsr),
 				      &dev->dsrbase, GFP_KERNEL);
@@ -908,7 +907,7 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
 	}
 
Quoted 7 lines

drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c static int pvrdma_pci_probe(struct pci_dev *pdev, · line 910

Quoted 3 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +1 -1
 	/* PVRDMA supports RoCE V1 or V2. */
-	if (version >= PVRDMA_VERSION_ROCEV2_SUPPORT &&
+	if (dev->dsr_version >= PVRDMA_ROCEV2_VERSION &&

Your whole idea of version is shaky. You need to move to capability bits per feature model and not rely on global version. In the near future, your code will be full of checks like this.

Quoted 6 lines

Why does the type of check matter? We would have to do a check anyway if there were capability bits exposed. In our case the global version is essentially the feature model for the device given that it isn't as feature rich as some of the other RDMA providers so doing a blanket check on the version seems the simplest way to go. I think the check here for the version is redundant anyways and can remove that in v1.

It is always good thing to remove unneeded checks.

Quoted 8 lines
Quoted 3 lines

There is a reason why you don't see many device driver here relies on FW version, which is similar to your versioning scheme.

I agree but in our case we can't update the FW version without exposing any new capabilities (due to compatibility reasons) so is essentially tied to the feature caps. As a compromise I can add a macro that checks the caps so the various version checks are a bit less obnoxious.

Thanks,
It will allow you to put all your checks of versions in one place and implement global_version-to-capability_bits translation table.

Quoted 7 lines

Thanks,
Adit
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw

PATCH 3/3 RDMA/vmw_pvrdma: Add new port_cap flag

In reply to a message not in the archive

Set the IP_BASED_GIDS port cap flag for vmw_pvrdma.

---
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c +1 -0
index 0b19d1a..1a367b7 100644
@@ -152,6 +152,7 @@ int pvrdma_query_port(struct ib_device *ibdev, u8 port,
 	props->gid_tbl_len = resp->attrs.gid_tbl_len;
 	props->port_cap_flags =
 		pvrdma_port_cap_flags_to_ib(resp->attrs.port_cap_flags);
+	props->port_cap_flags |= IB_PORT_CM_SUP | IB_PORT_IP_BASED_GIDS;
 	props->max_msg_sz = resp->attrs.max_msg_sz;
 	props->bad_pkey_cntr = resp->attrs.bad_pkey_cntr;
 	props->qkey_viol_cntr = resp->attrs.qkey_viol_cntr;
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): a7af1415fad6c6de00486002cdb6b95efec4e891.1503073950.git.aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org

#12 lore raw

Re: [PATCH for-next 3/3] RDMA/vmw_pvrdma: Add new port_cap flag

Quoted 5 lines · Adit Ranadive

Set the IP_BASED_GIDS port cap flag for vmw_pvrdma.

---

Adit,

Please reread the Documentation/process/5.Posting.rst and the Documentation/process/submitting-patches.rst for the meaning of the tags ("12) When to use Acked-by: and Cc:").

I think that you wanted to write Reviewed-by instead.

Thanks,

A message that is not in the archive (sent off-list or not yet received): 20170820055617.GC18138-U/[email protected]

#14 lore raw

Re: [PATCH for-next 3/3] RDMA/vmw_pvrdma: Add new port_cap flag

Quoted 8 lines · Leon Romanovsky
Quoted 5 lines · Adit Ranadive

Set the IP_BASED_GIDS port cap flag for vmw_pvrdma.

---

Quoted 7 lines

Adit,

Please reread the Documentation/process/5.Posting.rst and the Documentation/process/submitting-patches.rst for the meaning of the tags ("12) When to use Acked-by: and Cc:").

I think that you wanted to write Reviewed-by instead.

Sure, thanks for the pointers.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html