diff options
author | Jack Morgenstein <jackm@mellanox.co.il> | 2006-06-17 23:37:34 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-06-17 23:37:34 -0400 |
commit | 6fb9cdbf2cdb2ea187e57ec2e16cc59df2adf86a (patch) | |
tree | 329eb272835bd3105696ddbc60cdaea971aa2a6e /drivers/infiniband | |
parent | 856c256f883f027a14b546164294b4a86fea81a4 (diff) |
IB: Add caching of ports' LMC
Add an LMC cache to struct ib_device, and add a function
ib_get_cached_lmc() to query the cache.
Signed-off-by: Jack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/cache.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index 50364c0b090c..e05ca2cdc73f 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c | |||
@@ -191,6 +191,24 @@ int ib_find_cached_pkey(struct ib_device *device, | |||
191 | } | 191 | } |
192 | EXPORT_SYMBOL(ib_find_cached_pkey); | 192 | EXPORT_SYMBOL(ib_find_cached_pkey); |
193 | 193 | ||
194 | int ib_get_cached_lmc(struct ib_device *device, | ||
195 | u8 port_num, | ||
196 | u8 *lmc) | ||
197 | { | ||
198 | unsigned long flags; | ||
199 | int ret = 0; | ||
200 | |||
201 | if (port_num < start_port(device) || port_num > end_port(device)) | ||
202 | return -EINVAL; | ||
203 | |||
204 | read_lock_irqsave(&device->cache.lock, flags); | ||
205 | *lmc = device->cache.lmc_cache[port_num - start_port(device)]; | ||
206 | read_unlock_irqrestore(&device->cache.lock, flags); | ||
207 | |||
208 | return ret; | ||
209 | } | ||
210 | EXPORT_SYMBOL(ib_get_cached_lmc); | ||
211 | |||
194 | static void ib_cache_update(struct ib_device *device, | 212 | static void ib_cache_update(struct ib_device *device, |
195 | u8 port) | 213 | u8 port) |
196 | { | 214 | { |
@@ -251,6 +269,8 @@ static void ib_cache_update(struct ib_device *device, | |||
251 | device->cache.pkey_cache[port - start_port(device)] = pkey_cache; | 269 | device->cache.pkey_cache[port - start_port(device)] = pkey_cache; |
252 | device->cache.gid_cache [port - start_port(device)] = gid_cache; | 270 | device->cache.gid_cache [port - start_port(device)] = gid_cache; |
253 | 271 | ||
272 | device->cache.lmc_cache[port - start_port(device)] = tprops->lmc; | ||
273 | |||
254 | write_unlock_irq(&device->cache.lock); | 274 | write_unlock_irq(&device->cache.lock); |
255 | 275 | ||
256 | kfree(old_pkey_cache); | 276 | kfree(old_pkey_cache); |
@@ -305,7 +325,13 @@ static void ib_cache_setup_one(struct ib_device *device) | |||
305 | kmalloc(sizeof *device->cache.gid_cache * | 325 | kmalloc(sizeof *device->cache.gid_cache * |
306 | (end_port(device) - start_port(device) + 1), GFP_KERNEL); | 326 | (end_port(device) - start_port(device) + 1), GFP_KERNEL); |
307 | 327 | ||
308 | if (!device->cache.pkey_cache || !device->cache.gid_cache) { | 328 | device->cache.lmc_cache = kmalloc(sizeof *device->cache.lmc_cache * |
329 | (end_port(device) - | ||
330 | start_port(device) + 1), | ||
331 | GFP_KERNEL); | ||
332 | |||
333 | if (!device->cache.pkey_cache || !device->cache.gid_cache || | ||
334 | !device->cache.lmc_cache) { | ||
309 | printk(KERN_WARNING "Couldn't allocate cache " | 335 | printk(KERN_WARNING "Couldn't allocate cache " |
310 | "for %s\n", device->name); | 336 | "for %s\n", device->name); |
311 | goto err; | 337 | goto err; |
@@ -333,6 +359,7 @@ err_cache: | |||
333 | err: | 359 | err: |
334 | kfree(device->cache.pkey_cache); | 360 | kfree(device->cache.pkey_cache); |
335 | kfree(device->cache.gid_cache); | 361 | kfree(device->cache.gid_cache); |
362 | kfree(device->cache.lmc_cache); | ||
336 | } | 363 | } |
337 | 364 | ||
338 | static void ib_cache_cleanup_one(struct ib_device *device) | 365 | static void ib_cache_cleanup_one(struct ib_device *device) |
@@ -349,6 +376,7 @@ static void ib_cache_cleanup_one(struct ib_device *device) | |||
349 | 376 | ||
350 | kfree(device->cache.pkey_cache); | 377 | kfree(device->cache.pkey_cache); |
351 | kfree(device->cache.gid_cache); | 378 | kfree(device->cache.gid_cache); |
379 | kfree(device->cache.lmc_cache); | ||
352 | } | 380 | } |
353 | 381 | ||
354 | static struct ib_client cache_client = { | 382 | static struct ib_client cache_client = { |