Lines Matching refs:device
57 struct ib_device *device; member
61 static inline int start_port(struct ib_device *device) in start_port() argument
63 return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1; in start_port()
66 static inline int end_port(struct ib_device *device) in end_port() argument
68 return (device->node_type == RDMA_NODE_IB_SWITCH) ? in end_port()
69 0 : device->phys_port_cnt; in end_port()
72 int ib_get_cached_gid(struct ib_device *device, in ib_get_cached_gid() argument
81 if (port_num < start_port(device) || port_num > end_port(device)) in ib_get_cached_gid()
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()
93 read_unlock_irqrestore(&device->cache.lock, flags); in ib_get_cached_gid()
99 int ib_find_cached_gid(struct ib_device *device, in ib_find_cached_gid() argument
113 read_lock_irqsave(&device->cache.lock, flags); in ib_find_cached_gid()
115 for (p = 0; p <= end_port(device) - start_port(device); ++p) { in ib_find_cached_gid()
116 cache = device->cache.gid_cache[p]; in ib_find_cached_gid()
119 *port_num = p + start_port(device); in ib_find_cached_gid()
128 read_unlock_irqrestore(&device->cache.lock, flags); in ib_find_cached_gid()
134 int ib_get_cached_pkey(struct ib_device *device, in ib_get_cached_pkey() argument
143 if (port_num < start_port(device) || port_num > end_port(device)) in ib_get_cached_pkey()
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()
155 read_unlock_irqrestore(&device->cache.lock, flags); in ib_get_cached_pkey()
161 int ib_find_cached_pkey(struct ib_device *device, in ib_find_cached_pkey() argument
172 if (port_num < start_port(device) || port_num > end_port(device)) in ib_find_cached_pkey()
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()
196 read_unlock_irqrestore(&device->cache.lock, flags); in ib_find_cached_pkey()
202 int ib_find_exact_cached_pkey(struct ib_device *device, in ib_find_exact_cached_pkey() argument
212 if (port_num < start_port(device) || port_num > end_port(device)) in ib_find_exact_cached_pkey()
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()
228 read_unlock_irqrestore(&device->cache.lock, flags); in ib_find_exact_cached_pkey()
234 int ib_get_cached_lmc(struct ib_device *device, in ib_get_cached_lmc() argument
241 if (port_num < start_port(device) || port_num > end_port(device)) in ib_get_cached_lmc()
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()
252 static void ib_cache_update(struct ib_device *device, in ib_cache_update() argument
265 ret = ib_query_port(device, port, tprops); in ib_cache_update()
268 ret, device->name); in ib_cache_update()
287 ret = ib_query_pkey(device, port, i, pkey_cache->table + i); in ib_cache_update()
290 ret, device->name, i); in ib_cache_update()
296 ret = ib_query_gid(device, port, i, gid_cache->table + i); in ib_cache_update()
299 ret, device->name, i); in ib_cache_update()
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()
332 ib_cache_update(work->device, work->port_num); in ib_cache_task()
351 work->device = event->device; in ib_cache_event()
358 static void ib_cache_setup_one(struct ib_device *device) in ib_cache_setup_one() argument
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()
366 (end_port(device) - start_port(device) + 1), GFP_KERNEL); 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()
369 (end_port(device) - start_port(device) + 1), GFP_KERNEL); in ib_cache_setup_one()
371 device->cache.lmc_cache = kmalloc(sizeof *device->cache.lmc_cache * in ib_cache_setup_one()
372 (end_port(device) - in ib_cache_setup_one()
373 start_port(device) + 1), 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()
379 "for %s\n", device->name); in ib_cache_setup_one()
383 for (p = 0; p <= end_port(device) - start_port(device); ++p) { 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()
386 ib_cache_update(device, p + start_port(device)); in ib_cache_setup_one()
389 INIT_IB_EVENT_HANDLER(&device->cache.event_handler, in ib_cache_setup_one()
390 device, ib_cache_event); in ib_cache_setup_one()
391 if (ib_register_event_handler(&device->cache.event_handler)) in ib_cache_setup_one()
397 for (p = 0; p <= end_port(device) - start_port(device); ++p) { 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()
408 static void ib_cache_cleanup_one(struct ib_device *device) in ib_cache_cleanup_one() argument
412 ib_unregister_event_handler(&device->cache.event_handler); in ib_cache_cleanup_one()
415 for (p = 0; p <= end_port(device) - start_port(device); ++p) { 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()