All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-rc] IB/cma: Fix false P_Key mismatch messages
@ 2021-05-05 12:54 Håkon Bugge
  2021-05-10 17:04 ` Jason Gunthorpe
  0 siblings, 1 reply; 11+ messages in thread
From: Håkon Bugge @ 2021-05-05 12:54 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe; +Cc: linux-rdma

There are three conditions that must be fulfilled in order to consider
a partition match. Those are:

      1. Both P_Keys must valid
      2. At least one must be a full member
      3. The partitions (lower 15 bits) must match

In system employing both limited and full membership ports, we see
these false warning messages:

RDMA CMA: got different BTH P_Key (0x2a00) and primary path P_Key (0xaa00)
RDMA CMA: in the future this may cause the request to be dropped

even though the partition is the same.

See IBTA 10.9.1.2 Special P_Keys and 10.9.3 Partition Key Matching for
a reference.

Fixes: 84424a7fc793 ("IB/cma: Print warning on different inner and header P_Keys")
Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
---
 drivers/infiniband/core/cma.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 2b9ffc2..f5bcf7d 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1368,6 +1368,24 @@ static int cma_save_net_info(struct sockaddr *src_addr,
 	return cma_save_ip_info(src_addr, dst_addr, ib_event, service_id);
 }
 
+/*
+ * If at least one of the pkeys is a full member, none of them are
+ * invalid, and the partitions (lower 15 bits) are equal, we have a
+ * match.
+ *
+ * See IBTA 10.9.1.2 Special P_Keys and 10.9.3 Partition Key Matching
+ */
+
+static bool partition_match(u16 pkey_a, u16 pkey_b)
+{
+	const u16 fmb = 0x8000; /* Full Member Bit */
+	const bool valid_pkeys = (pkey_a & ~fmb) && (pkey_b & ~fmb);
+	const bool one_full = (pkey_a | pkey_b) & fmb;
+	const bool same_partition = (pkey_a | fmb) == (pkey_b | fmb);
+
+	return valid_pkeys && one_full && same_partition;
+}
+
 static int cma_save_req_info(const struct ib_cm_event *ib_event,
 			     struct cma_req_info *req)
 {
@@ -1385,7 +1403,7 @@ static int cma_save_req_info(const struct ib_cm_event *ib_event,
 		req->has_gid	= true;
 		req->service_id = req_param->primary_path->service_id;
 		req->pkey	= be16_to_cpu(req_param->primary_path->pkey);
-		if (req->pkey != req_param->bth_pkey)
+		if (!partition_match(req->pkey, req_param->bth_pkey))
 			pr_warn_ratelimited("RDMA CMA: got different BTH P_Key (0x%x) and primary path P_Key (0x%x)\n"
 					    "RDMA CMA: in the future this may cause the request to be dropped\n",
 					    req_param->bth_pkey, req->pkey);
@@ -1396,7 +1414,7 @@ static int cma_save_req_info(const struct ib_cm_event *ib_event,
 		req->has_gid	= false;
 		req->service_id	= sidr_param->service_id;
 		req->pkey	= sidr_param->pkey;
-		if (req->pkey != sidr_param->bth_pkey)
+		if (!partition_match(req->pkey, sidr_param->bth_pkey))
 			pr_warn_ratelimited("RDMA CMA: got different BTH P_Key (0x%x) and SIDR request payload P_Key (0x%x)\n"
 					    "RDMA CMA: in the future this may cause the request to be dropped\n",
 					    sidr_param->bth_pkey, req->pkey);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-07-09 16:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05 12:54 [PATCH for-rc] IB/cma: Fix false P_Key mismatch messages Håkon Bugge
2021-05-10 17:04 ` Jason Gunthorpe
2021-05-10 18:52   ` Haakon Bugge
2021-05-10 19:12     ` Jason Gunthorpe
2021-06-29 13:45       ` Haakon Bugge
2021-07-05 16:26         ` Jason Gunthorpe
2021-07-05 16:59           ` Haakon Bugge
2021-07-08 15:59             ` Haakon Bugge
2021-07-08 18:52               ` Jason Gunthorpe
2021-07-09 16:45                 ` Haakon Bugge
2021-07-09 16:56                   ` Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.