Skip to contentSkip to conversation

Add cache update functions

PATCH In review Goldwyn Rodrigues 1 participant 1 message Nov 7, 2011 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 6/11 Add cache update functions

---
 drivers/infiniband/core/cache.c |   54 +++++++++++++++++++++++++++++++++++++++
 include/rdma/ib_cache.h         |   25 ++++++++++++++++++
 2 files changed, 79 insertions(+), 0 deletions(-)
drivers/infiniband/core/cache.c +54 -0
index f6d0830..8c99788 100644
@@ -206,6 +206,60 @@ int ib_find_cached_pkey(struct ib_cache *cache,
 }
 EXPORT_SYMBOL(ib_find_cached_pkey);
 
+int ib_update_cached_pkey(struct ib_cache *cache,
+	  		  u8 port_num,
+			  int index,
+			  u16 pkey)
+{
+	struct ib_pkey_cache *pc;
+	unsigned long flags;
+	int ret = 0;
+
+	if (port_num < cache->start_port || port_num > cache->end_port)
+		return -EINVAL;
+
+	write_lock_irqsave(&cache->lock, flags);
+
+	pc = cache->pkey_cache[port_num - cache->start_port];
+
+	if (index < 0 || index >= pc->table_len)
+		ret = -EINVAL;
+	else
+		pc->table[index] = pkey;
+
+	write_unlock_irqrestore(&cache->lock, flags);
+
+	return ret;
+}
+EXPORT_SYMBOL(ib_update_cached_pkey);
+
+int ib_update_cached_gid(struct ib_cache *cache,
+			 u8 port_num,
+			 int index,
+			 union ib_gid gid)
+{
+	struct ib_gid_cache *gc;
+	unsigned long flags;
+	int ret = 0;
+
+	if (port_num < cache->start_port || port_num > cache->end_port)
+		return -EINVAL;
+
+	write_lock_irqsave(&cache->lock, flags);
+
+	gc = cache->gid_cache[port_num - cache->start_port];
+
+	if (index < 0 || index >= gc->table_len)
+		ret = -EINVAL;
+	else
+		gc->table[index] = gid;
+
+	write_unlock_irqrestore(&cache->lock, flags);
+
+	return ret;
+}
+EXPORT_SYMBOL(ib_update_cached_gid);
+
 static void ib_cache_update(struct ib_device *device,
 			    u8                port)
 {
include/rdma/ib_cache.h +25 -0
index 8af9d07..4dd91dc 100644
@@ -100,4 +100,29 @@ int ib_find_cached_pkey(struct ib_cache     *cache,
 			u16                  pkey,
 			u16                 *index);
 
+
+/**
+ * ib_update_cached_pkey - updates the cache with the value specified
+ * @cache: The cache to query
+ * @port_num: The port number of the device
+ * @index: The index into the cached PKey table
+ * @pkey: The PKey value to be set
+ */
+int ib_update_cached_pkey(struct ib_cache *cache,
+	  		  u8 port_num,
+			  int index,
+			  u16 pkey);
+
+/**
+ * ib_update_cached_gid - updates the cache with the gid
+ * @cache: The cache to query
+ * @port_num: The port number of the device
+ * @index: The index into the cached PKey table
+ * @gid: The gid value to be set
+ */
+int ib_update_cached_gid(struct ib_cache *cach,
+			 u8 port_num,
+			 int index,
+			 union ib_gid gid);
+
 #endif /* _IB_CACHE_H */
Signature · 9 lines
1.7.6


-- 
Goldwyn
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html