Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 328540
b: refs/heads/master
c: ff7166c
h: refs/heads/master
v: v3
  • Loading branch information
Jack Morgenstein authored and Roland Dreier committed Oct 1, 2012
1 parent f28718c commit 0dfe7a6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d2b57063e4aba51d3c49ec957607d2e4c9d5f29a
refs/heads/master: ff7166c447df23a61e4f51bf748319dc6728dc74
15 changes: 12 additions & 3 deletions trunk/drivers/infiniband/core/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ int ib_find_cached_pkey(struct ib_device *device,
unsigned long flags;
int i;
int ret = -ENOENT;
int partial_ix = -1;

if (port_num < start_port(device) || port_num > end_port(device))
return -EINVAL;
Expand All @@ -179,11 +180,19 @@ int ib_find_cached_pkey(struct ib_device *device,

for (i = 0; i < cache->table_len; ++i)
if ((cache->table[i] & 0x7fff) == (pkey & 0x7fff)) {
*index = i;
ret = 0;
break;
if (cache->table[i] & 0x8000) {
*index = i;
ret = 0;
break;
} else
partial_ix = i;
}

if (ret && partial_ix >= 0) {
*index = partial_ix;
ret = 0;
}

read_unlock_irqrestore(&device->cache.lock, flags);

return ret;
Expand Down
16 changes: 13 additions & 3 deletions trunk/drivers/infiniband/core/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,18 +707,28 @@ int ib_find_pkey(struct ib_device *device,
{
int ret, i;
u16 tmp_pkey;
int partial_ix = -1;

for (i = 0; i < device->pkey_tbl_len[port_num - start_port(device)]; ++i) {
ret = ib_query_pkey(device, port_num, i, &tmp_pkey);
if (ret)
return ret;

if ((pkey & 0x7fff) == (tmp_pkey & 0x7fff)) {
*index = i;
return 0;
/* if there is full-member pkey take it.*/
if (tmp_pkey & 0x8000) {
*index = i;
return 0;
}
if (partial_ix < 0)
partial_ix = i;
}
}

/*no full-member, if exists take the limited*/
if (partial_ix >= 0) {
*index = partial_ix;
return 0;
}
return -ENOENT;
}
EXPORT_SYMBOL(ib_find_pkey);
Expand Down

0 comments on commit 0dfe7a6

Please sign in to comment.