From: "Håkon Bugge" <Haakon.Bugge@oracle.com>
To: Doug Ledford <dledford@redhat.com>,
Don Hiatt <don.hiatt@intel.com>, Ira Weiny <ira.weiny@intel.com>,
Sean Hefty <sean.hefty@intel.com>
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
"Håkon Bugge" <haakon.bugge@oracle.com>
Subject: [PATCH IB/core 1/2] IB/core: A full pkey is required to match a limited one
Date: Wed, 9 May 2018 11:30:19 +0200 [thread overview]
Message-ID: <20180509093020.24503-2-Haakon.Bugge@oracle.com> (raw)
In-Reply-To: <20180509093020.24503-1-Haakon.Bugge@oracle.com>
In ib_find_cached_pkey(), the preference is to return the pkey-index
of the full pkey, if both a limited and the full exists in the cache.
However, if both pkeys are limited, the function return success.
To detect if two pkeys are eligible for communication,
ib_find_matched_cached_pkey() is introduced, which requires at least
one of the pkeys to be a full member, in order to return success.
Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
---
drivers/infiniband/core/cache.c | 32 +++++++++++++++++++++++++++-----
include/rdma/ib_cache.h | 18 ++++++++++++++++++
2 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index fb2d347f760f..cb7e9818a226 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -983,10 +983,11 @@ int ib_get_cached_subnet_prefix(struct ib_device *device,
}
EXPORT_SYMBOL(ib_get_cached_subnet_prefix);
-int ib_find_cached_pkey(struct ib_device *device,
- u8 port_num,
- u16 pkey,
- u16 *index)
+static int __ib_find_cached_pkey(struct ib_device *device,
+ u8 port_num,
+ u16 pkey,
+ u16 *index,
+ bool allow_lim_to_lim_match)
{
struct ib_pkey_cache *cache;
unsigned long flags;
@@ -1013,7 +1014,11 @@ int ib_find_cached_pkey(struct ib_device *device,
partial_ix = i;
}
- if (ret && partial_ix >= 0) {
+ /*
+ * If table content is limited, pkey must be full to match,
+ * unless allow_lim_to_lim_match is set
+ */
+ if (ret && partial_ix >= 0 && (pkey & 0x8000 || allow_lim_to_lim_match)) {
*index = partial_ix;
ret = 0;
}
@@ -1022,6 +1027,23 @@ int ib_find_cached_pkey(struct ib_device *device,
return ret;
}
+
+int ib_find_matched_cached_pkey(struct ib_device *device,
+ u8 port_num,
+ u16 pkey,
+ u16 *index)
+{
+ return __ib_find_cached_pkey(device, port_num, pkey, index, false);
+}
+EXPORT_SYMBOL(ib_find_matched_cached_pkey);
+
+int ib_find_cached_pkey(struct ib_device *device,
+ u8 port_num,
+ u16 pkey,
+ u16 *index)
+{
+ return __ib_find_cached_pkey(device, port_num, pkey, index, true);
+}
EXPORT_SYMBOL(ib_find_cached_pkey);
int ib_find_exact_cached_pkey(struct ib_device *device,
diff --git a/include/rdma/ib_cache.h b/include/rdma/ib_cache.h
index eb49cc8d1f95..748bd27559b6 100644
--- a/include/rdma/ib_cache.h
+++ b/include/rdma/ib_cache.h
@@ -92,6 +92,24 @@ int ib_get_cached_pkey(struct ib_device *device_handle,
u16 *pkey);
/**
+ * ib_find_matched_cached_pkey - Returns the PKey table index where a
+ * specified PKey value occurs. Success requires at least one of the
+ * PKeys to be a full-member.
+ * @device: The device to query.
+ * @port_num: The port number of the device to search for the PKey.
+ * @pkey: The PKey value to search for.
+ * @index: The index into the cached PKey table where the PKey was found.
+ *
+ * ib_find_matched_cached_pkey() searches the specified PKey table in
+ * the local software cache and return success unless both PKeys are
+ * limited.
+ */
+int ib_find_matched_cached_pkey(struct ib_device *device,
+ u8 port_num,
+ u16 pkey,
+ u16 *index);
+
+/**
* ib_find_cached_pkey - Returns the PKey table index where a specified
* PKey value occurs.
* @device: The device to query.
--
2.13.6
next prev parent reply other threads:[~2018-05-09 9:31 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-09 9:30 [PATCH IB/core 0/2] Do not form IB connections between limited partition members Håkon Bugge
2018-05-09 9:30 ` Håkon Bugge [this message]
2018-05-09 9:30 ` [PATCH IB/core 2/2] IB/cm: Send authentic pkey in REQ msg and check eligibility of the pkeys Håkon Bugge
2018-05-09 11:28 ` Hal Rosenstock
2018-05-10 9:16 ` Håkon Bugge
2018-05-10 14:01 ` Hal Rosenstock
2018-05-10 15:16 ` Håkon Bugge
2018-05-10 16:54 ` Hal Rosenstock
2018-05-11 10:55 ` Håkon Bugge
2018-05-11 12:51 ` Hal Rosenstock
2018-05-14 21:04 ` Jason Gunthorpe
2018-05-14 21:02 ` Jason Gunthorpe
2018-05-15 0:38 ` Hal Rosenstock
2018-05-15 18:11 ` Håkon Bugge
2018-05-15 19:04 ` Jason Gunthorpe
2018-05-16 6:47 ` Håkon Bugge
2018-05-16 15:12 ` Jason Gunthorpe
2018-05-16 16:42 ` Hal Rosenstock
2018-05-16 16:57 ` Jason Gunthorpe
[not found] ` <151B2A36-28F0-4A88-8633-31AE7E55F848@oracle.com>
2018-05-16 18:01 ` Jason Gunthorpe
2018-05-16 18:14 ` Håkon Bugge
2018-05-16 18:16 ` Jason Gunthorpe
[not found] ` <A087A721-E596-428E-8554-FAEB4BE9B306@oracle.com>
2018-05-16 19:30 ` Hal Rosenstock
2018-05-09 18:11 ` kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180509093020.24503-2-Haakon.Bugge@oracle.com \
--to=haakon.bugge@oracle.com \
--cc=dledford@redhat.com \
--cc=don.hiatt@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=sean.hefty@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®