Use cache structure instead of device (gid)
PATCH 4/11 Use cache structure instead of device (gid)
Changes all ib_xxx_cached_gid funcitons to use device structure instead of cache structure.
Signed-off-by Goldwyn Rodrigues <[email protected]>
--- drivers/infiniband/core/cache.c | 41 +++++++++++++++++++++----------------- include/rdma/ib_cache.h | 4 +- include/rdma/ib_verbs.h | 2 + 3 files changed, 27 insertions(+), 20 deletions(-)
drivers/infiniband/core/cache.c +23 -18
@@ -71,44 +71,44 @@ static inline int end_port(struct ib_device *device) 0 : device->phys_port_cnt; } -int ib_get_cached_gid (struct ib_device *device, +int ib_get_cached_gid (struct ib_cache *cache,u8 port_num,int index,union ib_gid *gid) { -struct ib_gid_cache *cache; +struct ib_gid_cache *gc;unsigned long flags;int ret =0 ; -if (port_num <start_port (device) || port_num >end_port (device)) +if (port_num < cache->start_port || port_num > cache->end_port)return -EINVAL ; -read_lock_irqsave (&device->cache.lock, flags); +read_lock_irqsave (&cache->lock, flags); - cache = device->cache.gid_cache[port_num -start_port (device)]; + gc = cache->gid_cache[port_num - cache->start_port]; -if (!test_bit (index, cache->valid_bm)) { +if (!test_bit (index, gc->valid_bm)) { ret = -ENOENT ; goto out; } -if (index <0 || index >= cache->table_len) +if (index <0 || index >= gc->table_len) ret = -EINVAL ;else - *gid = cache->table[index]; + *gid = gc->table[index]; out: -read_unlock_irqrestore (&device->cache.lock, flags); +read_unlock_irqrestore (&cache->lock, flags);return ret; }EXPORT_SYMBOL (ib_get_cached_gid); -int ib_find_cached_gid (struct ib_device *device, +int ib_find_cached_gid (struct ib_cache *cache,union ib_gid *gid,u8 *port_num,u16 *index) { -struct ib_gid_cache *cache; +struct ib_gid_cache *gc;unsigned long flags;int p, i;int ret = -ENOENT ;
@@ -117,13 +117,15 @@ int ib_find_cached_gid(struct ib_device *device,if (index) *index =-1 ; -read_lock_irqsave (&device->cache.lock, flags); +read_lock_irqsave (&cache->lock, flags); -for (p =0 ; p <=end_port (device) -start_port (device); ++p) { - cache = device->cache.gid_cache[p]; -for (i =0 ; i < cache->table_len; ++i) { -if (!memcmp (gid, &cache->table[i],sizeof *gid)) { - *port_num = p +start_port (device); +for (p =0 ; p <= cache->end_port - cache->start_port; ++p) { + gc = cache->gid_cache[p]; +for (i =0 ; i < gc->table_len; ++i) { +if (!test_bit (i, gc->valid_bm)) +continue ; +if (!memcmp (gid, &gc->table[i],sizeof *gid)) { + *port_num = p + cache->start_port;if (index) *index = i; ret =0 ;
@@ -132,7 +134,7 @@ int ib_find_cached_gid(struct ib_device *device, } } found: -read_unlock_irqrestore (&device->cache.lock, flags); +read_unlock_irqrestore (&cache->lock, flags);return ret; }
@@ -320,6 +322,9 @@ static void ib_cache_setup_one(struct ib_device *device) {int p; + device->cache.start_port =start_port (device); + device->cache.end_port =end_port (device); +rwlock_init (&device->cache.lock); device->cache.pkey_cache =
include/rdma/ib_cache.h +2 -2
@@ -47,7 +47,7 @@* ib_get_cached_gid() fetches the specified GID table entry stored in * the local software cache. */ -int ib_get_cached_gid (struct ib_device *device, +int ib_get_cached_gid (struct ib_cache *cache,u8 port_num,int index,union ib_gid *gid);
@@ -64,7 +64,7 @@ int ib_get_cached_gid(struct ib_device *device,* ib_find_cached_gid() searches for the specified GID value in * the local software cache. */ -int ib_find_cached_gid (struct ib_device *device, +int ib_find_cached_gid (struct ib_cache *cache,union ib_gid *gid,u8 *port_num,u16 *index);
include/rdma/ib_verbs.h +2 -0
@@ -1010,6 +1010,8 @@ enum ib_mad_result {struct ib_cache {rwlock_t lock;struct ib_event_handler event_handler; +u8 start_port; +u8 end_port;struct ib_pkey_cache **pkey_cache;struct ib_gid_cache **gid_cache; };
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