aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/core/cache.c15
-rw-r--r--drivers/infiniband/core/device.c16
2 files changed, 25 insertions, 6 deletions
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index 9353992f9eea..4da381b74f54 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -167,6 +167,7 @@ int ib_find_cached_pkey(struct ib_device *device,
167 unsigned long flags; 167 unsigned long flags;
168 int i; 168 int i;
169 int ret = -ENOENT; 169 int ret = -ENOENT;
170 int partial_ix = -1;
170 171
171 if (port_num < start_port(device) || port_num > end_port(device)) 172 if (port_num < start_port(device) || port_num > end_port(device))
172 return -EINVAL; 173 return -EINVAL;
@@ -179,11 +180,19 @@ int ib_find_cached_pkey(struct ib_device *device,
179 180
180 for (i = 0; i < cache->table_len; ++i) 181 for (i = 0; i < cache->table_len; ++i)
181 if ((cache->table[i] & 0x7fff) == (pkey & 0x7fff)) { 182 if ((cache->table[i] & 0x7fff) == (pkey & 0x7fff)) {
182 *index = i; 183 if (cache->table[i] & 0x8000) {
183 ret = 0; 184 *index = i;
184 break; 185 ret = 0;
186 break;
187 } else
188 partial_ix = i;
185 } 189 }
186 190
191 if (ret && partial_ix >= 0) {
192 *index = partial_ix;
193 ret = 0;
194 }
195
187 read_unlock_irqrestore(&device->cache.lock, flags); 196 read_unlock_irqrestore(&device->cache.lock, flags);
188 197
189 return ret; 198 return ret;
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index e711de400a01..18c1ece765f2 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -707,18 +707,28 @@ int ib_find_pkey(struct ib_device *device,
707{ 707{
708 int ret, i; 708 int ret, i;
709 u16 tmp_pkey; 709 u16 tmp_pkey;
710 int partial_ix = -1;
710 711
711 for (i = 0; i < device->pkey_tbl_len[port_num - start_port(device)]; ++i) { 712 for (i = 0; i < device->pkey_tbl_len[port_num - start_port(device)]; ++i) {
712 ret = ib_query_pkey(device, port_num, i, &tmp_pkey); 713 ret = ib_query_pkey(device, port_num, i, &tmp_pkey);
713 if (ret) 714 if (ret)
714 return ret; 715 return ret;
715
716 if ((pkey & 0x7fff) == (tmp_pkey & 0x7fff)) { 716 if ((pkey & 0x7fff) == (tmp_pkey & 0x7fff)) {
717 *index = i; 717 /* if there is full-member pkey take it.*/
718 return 0; 718 if (tmp_pkey & 0x8000) {
719 *index = i;
720 return 0;
721 }
722 if (partial_ix < 0)
723 partial_ix = i;
719 } 724 }
720 } 725 }
721 726
727 /*no full-member, if exists take the limited*/
728 if (partial_ix >= 0) {
729 *index = partial_ix;
730 return 0;
731 }
722 return -ENOENT; 732 return -ENOENT;
723} 733}
724EXPORT_SYMBOL(ib_find_pkey); 734EXPORT_SYMBOL(ib_find_pkey);