Lines Matching refs:cache
77 struct ib_gid_cache *cache; in ib_get_cached_gid() local
84 read_lock_irqsave(&device->cache.lock, flags); in ib_get_cached_gid()
86 cache = device->cache.gid_cache[port_num - start_port(device)]; in ib_get_cached_gid()
88 if (index < 0 || index >= cache->table_len) in ib_get_cached_gid()
91 *gid = cache->table[index]; in ib_get_cached_gid()
93 read_unlock_irqrestore(&device->cache.lock, flags); in ib_get_cached_gid()
104 struct ib_gid_cache *cache; in ib_find_cached_gid() local
113 read_lock_irqsave(&device->cache.lock, flags); in ib_find_cached_gid()
116 cache = device->cache.gid_cache[p]; in ib_find_cached_gid()
117 for (i = 0; i < cache->table_len; ++i) { in ib_find_cached_gid()
118 if (!memcmp(gid, &cache->table[i], sizeof *gid)) { in ib_find_cached_gid()
128 read_unlock_irqrestore(&device->cache.lock, flags); in ib_find_cached_gid()
139 struct ib_pkey_cache *cache; in ib_get_cached_pkey() local
146 read_lock_irqsave(&device->cache.lock, flags); in ib_get_cached_pkey()
148 cache = device->cache.pkey_cache[port_num - start_port(device)]; in ib_get_cached_pkey()
150 if (index < 0 || index >= cache->table_len) in ib_get_cached_pkey()
153 *pkey = cache->table[index]; in ib_get_cached_pkey()
155 read_unlock_irqrestore(&device->cache.lock, flags); in ib_get_cached_pkey()
166 struct ib_pkey_cache *cache; in ib_find_cached_pkey() local
175 read_lock_irqsave(&device->cache.lock, flags); in ib_find_cached_pkey()
177 cache = device->cache.pkey_cache[port_num - start_port(device)]; in ib_find_cached_pkey()
181 for (i = 0; i < cache->table_len; ++i) in ib_find_cached_pkey()
182 if ((cache->table[i] & 0x7fff) == (pkey & 0x7fff)) { in ib_find_cached_pkey()
183 if (cache->table[i] & 0x8000) { in ib_find_cached_pkey()
196 read_unlock_irqrestore(&device->cache.lock, flags); in ib_find_cached_pkey()
207 struct ib_pkey_cache *cache; in ib_find_exact_cached_pkey() local
215 read_lock_irqsave(&device->cache.lock, flags); in ib_find_exact_cached_pkey()
217 cache = device->cache.pkey_cache[port_num - start_port(device)]; in ib_find_exact_cached_pkey()
221 for (i = 0; i < cache->table_len; ++i) in ib_find_exact_cached_pkey()
222 if (cache->table[i] == pkey) { in ib_find_exact_cached_pkey()
228 read_unlock_irqrestore(&device->cache.lock, flags); in ib_find_exact_cached_pkey()
244 read_lock_irqsave(&device->cache.lock, flags); in ib_get_cached_lmc()
245 *lmc = device->cache.lmc_cache[port_num - start_port(device)]; in ib_get_cached_lmc()
246 read_unlock_irqrestore(&device->cache.lock, flags); in ib_get_cached_lmc()
304 write_lock_irq(&device->cache.lock); in ib_cache_update()
306 old_pkey_cache = device->cache.pkey_cache[port - start_port(device)]; in ib_cache_update()
307 old_gid_cache = device->cache.gid_cache [port - start_port(device)]; in ib_cache_update()
309 device->cache.pkey_cache[port - start_port(device)] = pkey_cache; in ib_cache_update()
310 device->cache.gid_cache [port - start_port(device)] = gid_cache; in ib_cache_update()
312 device->cache.lmc_cache[port - start_port(device)] = tprops->lmc; in ib_cache_update()
314 write_unlock_irq(&device->cache.lock); in ib_cache_update()
362 rwlock_init(&device->cache.lock); in ib_cache_setup_one()
364 device->cache.pkey_cache = in ib_cache_setup_one()
365 kmalloc(sizeof *device->cache.pkey_cache * in ib_cache_setup_one()
367 device->cache.gid_cache = in ib_cache_setup_one()
368 kmalloc(sizeof *device->cache.gid_cache * in ib_cache_setup_one()
371 device->cache.lmc_cache = kmalloc(sizeof *device->cache.lmc_cache * in ib_cache_setup_one()
376 if (!device->cache.pkey_cache || !device->cache.gid_cache || in ib_cache_setup_one()
377 !device->cache.lmc_cache) { in ib_cache_setup_one()
384 device->cache.pkey_cache[p] = NULL; in ib_cache_setup_one()
385 device->cache.gid_cache [p] = NULL; in ib_cache_setup_one()
389 INIT_IB_EVENT_HANDLER(&device->cache.event_handler, in ib_cache_setup_one()
391 if (ib_register_event_handler(&device->cache.event_handler)) in ib_cache_setup_one()
398 kfree(device->cache.pkey_cache[p]); in ib_cache_setup_one()
399 kfree(device->cache.gid_cache[p]); in ib_cache_setup_one()
403 kfree(device->cache.pkey_cache); in ib_cache_setup_one()
404 kfree(device->cache.gid_cache); in ib_cache_setup_one()
405 kfree(device->cache.lmc_cache); in ib_cache_setup_one()
412 ib_unregister_event_handler(&device->cache.event_handler); in ib_cache_cleanup_one()
416 kfree(device->cache.pkey_cache[p]); in ib_cache_cleanup_one()
417 kfree(device->cache.gid_cache[p]); in ib_cache_cleanup_one()
420 kfree(device->cache.pkey_cache); in ib_cache_cleanup_one()
421 kfree(device->cache.gid_cache); in ib_cache_cleanup_one()
422 kfree(device->cache.lmc_cache); in ib_cache_cleanup_one()