@@ -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,
@@ -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.
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(-)