aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/infiniband/core/cache.c32
-rw-r--r--include/rdma/ib_cache.h16
2 files changed, 48 insertions, 0 deletions
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index 4da381b74f54..80f6cf2449fb 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -199,6 +199,38 @@ int ib_find_cached_pkey(struct ib_device *device,
199} 199}
200EXPORT_SYMBOL(ib_find_cached_pkey); 200EXPORT_SYMBOL(ib_find_cached_pkey);
201 201
202int ib_find_exact_cached_pkey(struct ib_device *device,
203 u8 port_num,
204 u16 pkey,
205 u16 *index)
206{
207 struct ib_pkey_cache *cache;
208 unsigned long flags;
209 int i;
210 int ret = -ENOENT;
211
212 if (port_num < start_port(device) || port_num > end_port(device))
213 return -EINVAL;
214
215 read_lock_irqsave(&device->cache.lock, flags);
216
217 cache = device->cache.pkey_cache[port_num - start_port(device)];
218
219 *index = -1;
220
221 for (i = 0; i < cache->table_len; ++i)
222 if (cache->table[i] == pkey) {
223 *index = i;
224 ret = 0;
225 break;
226 }
227
228 read_unlock_irqrestore(&device->cache.lock, flags);
229
230 return ret;
231}
232EXPORT_SYMBOL(ib_find_exact_cached_pkey);
233
202int ib_get_cached_lmc(struct ib_device *device, 234int ib_get_cached_lmc(struct ib_device *device,
203 u8 port_num, 235 u8 port_num,
204 u8 *lmc) 236 u8 *lmc)
diff --git a/include/rdma/ib_cache.h b/include/rdma/ib_cache.h
index 00a2b8ec327f..ad9a3c280944 100644
--- a/include/rdma/ib_cache.h
+++ b/include/rdma/ib_cache.h
@@ -101,6 +101,22 @@ int ib_find_cached_pkey(struct ib_device *device,
101 u16 *index); 101 u16 *index);
102 102
103/** 103/**
104 * ib_find_exact_cached_pkey - Returns the PKey table index where a specified
105 * PKey value occurs. Comparison uses the FULL 16 bits (incl membership bit)
106 * @device: The device to query.
107 * @port_num: The port number of the device to search for the PKey.
108 * @pkey: The PKey value to search for.
109 * @index: The index into the cached PKey table where the PKey was found.
110 *
111 * ib_find_exact_cached_pkey() searches the specified PKey table in
112 * the local software cache.
113 */
114int ib_find_exact_cached_pkey(struct ib_device *device,
115 u8 port_num,
116 u16 pkey,
117 u16 *index);
118
119/**
104 * ib_get_cached_lmc - Returns a cached lmc table entry 120 * ib_get_cached_lmc - Returns a cached lmc table entry
105 * @device: The device to query. 121 * @device: The device to query.
106 * @port_num: The port number of the device to query. 122 * @port_num: The port number of the device to query.