• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /barrelfish-2018-10-04/lib/devif/backends/net/mlx4/drivers/infiniband/core/

Lines Matching defs:device

58  struct ib_device  *device;
62 static inline int start_port(struct ib_device *device) {
63 return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1;
66 static inline int end_port(struct ib_device *device) {
67 return (device->node_type == RDMA_NODE_IB_SWITCH) ?
68 0 : device->phys_port_cnt;
71 int ib_get_cached_gid(struct ib_device *device,
80 if (port_num < start_port(device) || port_num > end_port(device))
83 read_lock_irqsave(&device->cache.lock, flags);
85 cache = device->cache.gid_cache[port_num - start_port(device)];
92 read_unlock_irqrestore(&device->cache.lock, flags);
98 int ib_find_cached_gid(struct ib_device *device,
112 read_lock_irqsave(&device->cache.lock, flags);
114 for (p = 0; p <= end_port(device) - start_port(device); ++p) {
115 cache = device->cache.gid_cache[p];
118 *port_num = p + start_port(device);
127 read_unlock_irqrestore(&device->cache.lock, flags);
133 int ib_get_cached_pkey(struct ib_device *device,
142 if (port_num < start_port(device) || port_num > end_port(device))
145 read_lock_irqsave(&device->cache.lock, flags);
147 cache = device->cache.pkey_cache[port_num - start_port(device)];
154 read_unlock_irqrestore(&device->cache.lock, flags);
160 int ib_find_cached_pkey(struct ib_device *device,
170 if (port_num < start_port(device) || port_num > end_port(device))
173 read_lock_irqsave(&device->cache.lock, flags);
175 cache = device->cache.pkey_cache[port_num - start_port(device)];
186 read_unlock_irqrestore(&device->cache.lock, flags);
192 int ib_get_cached_lmc(struct ib_device *device,
199 if (port_num < start_port(device) || port_num > end_port(device))
202 read_lock_irqsave(&device->cache.lock, flags);
203 *lmc = device->cache.lmc_cache[port_num - start_port(device)];
204 read_unlock_irqrestore(&device->cache.lock, flags);
210 static void ib_cache_update(struct ib_device *device, u8 port) {
221 ret = ib_query_port(device, port, tprops);
223 printf("ib_query_port failed (%d) for %s\n", ret, device->name);
243 ret = ib_query_pkey(device, port, i, pkey_cache->table + i);
246 device->name, i);
252 ret = ib_query_gid(device, port, i, gid_cache->table + i);
255 device->name, i);
260 /*write_lock_irq(&device->cache.lock);*/
262 old_pkey_cache = device->cache.pkey_cache[port - start_port(device)];
263 old_gid_cache = device->cache.gid_cache[port - start_port(device)];
265 device->cache.pkey_cache[port - start_port(device)] = pkey_cache;
266 device->cache.gid_cache[port - start_port(device)] = gid_cache;
268 device->cache.lmc_cache[port - start_port(device)] = tprops->lmc;
270 /*write_unlock_irq(&device->cache.lock);*/
287 ib_cache_update(work->device, work->port_num);
306 work->device = event->device;
313 void ib_cache_setup_one(struct ib_device *device) {
316 /*rwlock_init(&device->cache.lock);*/
318 device->cache.pkey_cache = malloc(
319 sizeof *device->cache.pkey_cache
320 * (end_port(device) - start_port(device) + 1));
321 device->cache.gid_cache = malloc(
322 sizeof *device->cache.gid_cache
323 * (end_port(device) - start_port(device) + 1));
325 device->cache.lmc_cache = malloc(
326 sizeof *device->cache.lmc_cache
327 * (end_port(device) - start_port(device) + 1));
329 if (!device->cache.pkey_cache || !device->cache.gid_cache
330 || !device->cache.lmc_cache) {
332 "for %s\n", device->name);
336 printf("end_port(device): %d\n", end_port(device));
337 printf("start_port(device): %d\n", start_port(device));
339 for (p = 0; p <= end_port(device) - start_port(device); ++p) {
340 device->cache.pkey_cache[p] = NULL;
341 device->cache.gid_cache[p] = NULL;
342 ib_cache_update(device, p + start_port(device));
345 /*INIT_IB_EVENT_HANDLER(&device->cache.event_handler, device, ib_cache_event);
346 if (ib_register_event_handler(&device->cache.event_handler))
351 /*err_cache: for (p = 0; p <= end_port(device) - start_port(device); ++p) {
352 free(device->cache.pkey_cache[p]);
353 free(device->cache.gid_cache[p]);
356 err: free(device->cache.pkey_cache);
357 free(device->cache.gid_cache);
358 free(device->cache.lmc_cache);
361 static void ib_cache_cleanup_one(struct ib_device *device)
365 ib_unregister_event_handler(&device->cache.event_handler);
368 for (p = 0; p <= end_port(device) - start_port(device); ++p) {
369 kfree(device->cache.pkey_cache[p]);
370 kfree(device->cache.gid_cache[p]);
373 kfree(device->cache.pkey_cache);
374 kfree(device->cache.gid_cache);
375 kfree(device->cache.lmc_cache);