[openib-general] [PATCH 1 of 2] add lmc cache
Michael S. Tsirkin
mst at mellanox.co.il
Sat Apr 29 18:28:34 PDT 2006
Add LMC cache.
Signed-off-by: Jack Morgenstein <jackm at mellanox.co.il>
Index: src/drivers/infiniband/include/rdma/ib_verbs.h
===================================================================
--- src/drivers/infiniband/include/rdma/ib_verbs.h (revision 6066)
+++ src/drivers/infiniband/include/rdma/ib_verbs.h (working copy)
@@ -822,6 +822,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 {
Index: src/drivers/infiniband/include/rdma/ib_cache.h
===================================================================
--- src/drivers/infiniband/include/rdma/ib_cache.h (revision 6066)
+++ src/drivers/infiniband/include/rdma/ib_cache.h (working copy)
@@ -102,4 +102,17 @@ int ib_find_cached_pkey(struct ib_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 */
Index: src/drivers/infiniband/core/cache.c
===================================================================
--- src/drivers/infiniband/core/cache.c (revision 6066)
+++ src/drivers/infiniband/core/cache.c (working copy)
@@ -191,6 +195,24 @@ int ib_find_cached_pkey(struct ib_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)
{
@@ -251,6 +273,8 @@ static void ib_cache_update(struct ib_de
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);
@@ -305,7 +329,13 @@ static void ib_cache_setup_one(struct ib
kmalloc(sizeof *device->cache.pkey_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;
@@ -333,6 +363,7 @@ err_cache:
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)
@@ -349,6 +380,7 @@ static void ib_cache_cleanup_one(struct
kfree(device->cache.pkey_cache);
kfree(device->cache.gid_cache);
+ kfree(device->cache.lmc_cache);
}
static struct ib_client cache_client = {
--
MST
More information about the general
mailing list