Blame SOURCES/0001-ibacm-Do-not-open-non-InfiniBand-device.patch

3a6352
From 9ecb459f5bb442174189f25e9ce6c59d66b5b943 Mon Sep 17 00:00:00 2001
3a6352
From: Honggang Li <honli@redhat.com>
3a6352
Date: Tue, 4 Feb 2020 09:01:11 +0800
3a6352
Subject: [PATCH] ibacm: Do not open non InfiniBand device
3a6352
3a6352
For dual port HCA, which has an InfiniBand port and an Ethernet port,
3a6352
only open InfiniBand port will introduce segment fault issues.
3a6352
3a6352
Because the Ethernet port did not open yet, segment fault when active
3a6352
the Ethernet port. The second segment fault issue happens when there
3a6352
is asyn event on the Ethernet port.
3a6352
3a6352
We should skip pure iWARP or RoCE devices, but not device which has at
3a6352
least one InfiniBand port.
3a6352
3a6352
Signed-off-by: Honggang Li <honli@redhat.com>
3a6352
---
3a6352
 ibacm/src/acm.c | 22 ++++++++++++++++++++++
3a6352
 1 file changed, 22 insertions(+)
3a6352
3a6352
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
3a6352
index 1aa08f4b..77828d8c 100644
3a6352
--- a/ibacm/src/acm.c
3a6352
+++ b/ibacm/src/acm.c
3a6352
@@ -2600,9 +2600,11 @@ static void acm_open_dev(struct ibv_device *ibdev)
3a6352
 {
3a6352
 	struct acmc_device *dev;
3a6352
 	struct ibv_device_attr attr;
3a6352
+	struct ibv_port_attr port_attr;
3a6352
 	struct ibv_context *verbs;
3a6352
 	size_t size;
3a6352
 	int i, ret;
3a6352
+	bool has_ib_port = false;
3a6352
 
3a6352
 	acm_log(1, "%s\n", ibdev->name);
3a6352
 	verbs = ibv_open_device(ibdev);
3a6352
@@ -2617,6 +2619,26 @@ static void acm_open_dev(struct ibv_device *ibdev)
3a6352
 		goto err1;
3a6352
 	}
3a6352
 
3a6352
+	for (i = 0; i < attr.phys_port_cnt; i++) {
3a6352
+		ret = ibv_query_port(verbs, i + 1, &port_attr);
3a6352
+		if (ret) {
3a6352
+			acm_log(0, "ERROR - ibv_query_port (%s, %d) return (%d)\n",
3a6352
+				ibdev->name, i + 1, ret);
3a6352
+			continue;
3a6352
+		}
3a6352
+
3a6352
+		if (port_attr.link_layer == IBV_LINK_LAYER_INFINIBAND) {
3a6352
+			acm_log(1, "%s port %d is an InfiniBand port\n", ibdev->name, i);
3a6352
+			has_ib_port = true;
3a6352
+		} else
3a6352
+			acm_log(1, "%s port %d is not an InfiniBand port\n", ibdev->name, i);
3a6352
+	}
3a6352
+
3a6352
+	if (!has_ib_port) {
3a6352
+		acm_log(1, "%s does not support InfiniBand.\n", ibdev->name);
3a6352
+		goto err1;
3a6352
+	}
3a6352
+
3a6352
 	size = sizeof(*dev) + sizeof(struct acmc_port) * attr.phys_port_cnt;
3a6352
 	dev = (struct acmc_device *) calloc(1, size);
3a6352
 	if (!dev)
3a6352
-- 
3a6352
2.24.1
3a6352