[PATCH 08/11] Functions to drop caches

DORMANTno replies

From: Goldwyn Rodrigues <hidden>
Date: 2011-11-07 08:50:28
Subsystem: infiniband subsystem, the rest · Maintainers: Jason Gunthorpe, Leon Romanovsky, Linus Torvalds

These functions are called in case of port changes or device resets etc.

Signed-off-by: Goldwyn Rodrigues <redacted>
---
 drivers/infiniband/core/cache.c |   26 ++++++++++++++++++++++++++
 include/rdma/ib_cache.h         |   15 +++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index 67252ad..532d442 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -397,6 +397,19 @@ static void ib_cache_pkey_free(struct ib_pkey_cache *cache)
 	kfree(cache);
 }
 
+int ib_cache_pkey_drop(struct ib_cache *cache, u8 port_num)
+{
+	struct ib_pkey_cache *pc;
+	unsigned long flags;
+
+	write_lock_irqsave(&cache->lock, flags);
+	pc = cache->pkey_cache[port_num - cache->start_port];
+	memset(pc->valid_bm, 0, BITS_TO_LONGS(pc->table_len));
+	write_unlock_irqrestore(&cache->lock, flags);
+	return 0;
+}
+EXPORT_SYMBOL(ib_cache_pkey_drop);
+
 static struct ib_gid_cache *ib_cache_gid_alloc(int size)
 {
 	struct ib_gid_cache *gc;
@@ -419,6 +432,19 @@ static void ib_cache_gid_free(struct ib_gid_cache *cache)
 	kfree(cache);
 }
 
+int ib_cache_gid_drop(struct ib_cache *cache, u8 port_num)
+{
+	struct ib_gid_cache *gc;
+	unsigned long flags;
+
+	write_lock_irqsave(&cache->lock, flags);
+	gc = cache->gid_cache[port_num - cache->start_port];
+	memset(gc->valid_bm, 0, BITS_TO_LONGS(gc->table_len));
+	write_unlock_irqrestore(&cache->lock, flags);
+	return 0;
+}
+EXPORT_SYMBOL(ib_cache_gid_drop);
+
 int ib_cache_init(struct ib_cache *cache,
 		  struct ib_device *device)
 {
diff --git a/include/rdma/ib_cache.h b/include/rdma/ib_cache.h
index a5d7c7d..8a23663 100644
--- a/include/rdma/ib_cache.h
+++ b/include/rdma/ib_cache.h
@@ -138,4 +138,19 @@ int ib_cache_init(struct ib_cache *cache,
  * @cache: The cache to free
  */
 void ib_cache_free(struct ib_cache *cache);
+
+/**
+ * ib_cache_pkey_drop - drop the pkey cache entry associated with port
+ * @cache: The cache to free
+ * @port_num: port number entry in the cache
+ */
+int ib_cache_pkey_drop(struct ib_cache *cache, u8 port_num);
+
+
+/**
+ * ib_cache_gid_drop - drop the gid cache entry associated with port
+ * @cache: The cache to free
+ * @port_num: port number entry in the cache
+ */
+int ib_cache_gid_drop(struct ib_cache *cache, u8 port_num);
 #endif /* _IB_CACHE_H */
-- 
1.7.6


-- 
Goldwyn
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help