Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 27619
b: refs/heads/master
c: 6fb9cdb
h: refs/heads/master
i:
  27617: c2adeef
  27615: 575de8d
v: v3
  • Loading branch information
Jack Morgenstein authored and Roland Dreier committed Jun 18, 2006
1 parent d17fb8b commit 1281df6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 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: 856c256f883f027a14b546164294b4a86fea81a4
refs/heads/master: 6fb9cdbf2cdb2ea187e57ec2e16cc59df2adf86a
30 changes: 29 additions & 1 deletion trunk/drivers/infiniband/core/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,24 @@ int ib_find_cached_pkey(struct ib_device *device,
}
EXPORT_SYMBOL(ib_find_cached_pkey);

int ib_get_cached_lmc(struct ib_device *device,
u8 port_num,
u8 *lmc)
{
unsigned long flags;
int ret = 0;

if (port_num < start_port(device) || port_num > end_port(device))
return -EINVAL;

read_lock_irqsave(&device->cache.lock, flags);
*lmc = device->cache.lmc_cache[port_num - start_port(device)];
read_unlock_irqrestore(&device->cache.lock, flags);

return ret;
}
EXPORT_SYMBOL(ib_get_cached_lmc);

static void ib_cache_update(struct ib_device *device,
u8 port)
{
Expand Down Expand Up @@ -251,6 +269,8 @@ static void ib_cache_update(struct ib_device *device,
device->cache.pkey_cache[port - start_port(device)] = pkey_cache;
device->cache.gid_cache [port - start_port(device)] = gid_cache;

device->cache.lmc_cache[port - start_port(device)] = tprops->lmc;

write_unlock_irq(&device->cache.lock);

kfree(old_pkey_cache);
Expand Down Expand Up @@ -305,7 +325,13 @@ static void ib_cache_setup_one(struct ib_device *device)
kmalloc(sizeof *device->cache.gid_cache *
(end_port(device) - start_port(device) + 1), GFP_KERNEL);

if (!device->cache.pkey_cache || !device->cache.gid_cache) {
device->cache.lmc_cache = kmalloc(sizeof *device->cache.lmc_cache *
(end_port(device) -
start_port(device) + 1),
GFP_KERNEL);

if (!device->cache.pkey_cache || !device->cache.gid_cache ||
!device->cache.lmc_cache) {
printk(KERN_WARNING "Couldn't allocate cache "
"for %s\n", device->name);
goto err;
Expand Down Expand Up @@ -333,6 +359,7 @@ static void ib_cache_setup_one(struct ib_device *device)
err:
kfree(device->cache.pkey_cache);
kfree(device->cache.gid_cache);
kfree(device->cache.lmc_cache);
}

static void ib_cache_cleanup_one(struct ib_device *device)
Expand All @@ -349,6 +376,7 @@ static void ib_cache_cleanup_one(struct ib_device *device)

kfree(device->cache.pkey_cache);
kfree(device->cache.gid_cache);
kfree(device->cache.lmc_cache);
}

static struct ib_client cache_client = {
Expand Down
13 changes: 13 additions & 0 deletions trunk/include/rdma/ib_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,17 @@ int ib_find_cached_pkey(struct ib_device *device,
u16 pkey,
u16 *index);

/**
* ib_get_cached_lmc - Returns a cached lmc table entry
* @device: The device to query.
* @port_num: The port number of the device to query.
* @lmc: The lmc value for the specified port for that device.
*
* ib_get_cached_lmc() fetches the specified lmc table entry stored in
* the local software cache.
*/
int ib_get_cached_lmc(struct ib_device *device,
u8 port_num,
u8 *lmc);

#endif /* _IB_CACHE_H */
1 change: 1 addition & 0 deletions trunk/include/rdma/ib_verbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ struct ib_cache {
struct ib_event_handler event_handler;
struct ib_pkey_cache **pkey_cache;
struct ib_gid_cache **gid_cache;
u8 *lmc_cache;
};

struct ib_device {
Expand Down

0 comments on commit 1281df6

Please sign in to comment.