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

Lines Matching defs:device

76  static int ib_device_check_mandatory(struct ib_device *device)
106 if (!*(void **) ((u_char *) device + mandatory_table[i].offset)) {
108 device->name, mandatory_table[i].name);
118 struct ib_device *device;
120 list_for_each_entry(device, &device_list, core_list)
121 if (!strncmp(name, device->name, IB_DEVICE_NAME_MAX))
122 return device;
132 struct ib_device *device;
139 list_for_each_entry(device, &device_list, core_list) {
140 if (!sscanf(device->name, name, &i))
145 if (!strncmp(buf, device->name, IB_DEVICE_NAME_MAX))
160 static int start_port(struct ib_device *device) {
161 return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1;
164 static int end_port(struct ib_device *device) {
165 return (device->node_type == RDMA_NODE_IB_SWITCH) ?
166 0 : device->phys_port_cnt;
170 * ib_alloc_device - allocate an IB device struct
190 * ib_dealloc_device - free an IB device struct
191 * @device:structure to free
195 void ib_dealloc_device(struct ib_device *device)
197 if (device->reg_state == IB_DEV_UNINITIALIZED) {
198 kfree(device);
202 BUG_ON(device->reg_state != IB_DEV_UNREGISTERED);
204 kobject_put(&device->dev.kobj);
208 static int add_client_context(struct ib_device *device, struct ib_client *client)
216 device->name, client->name);
223 spin_lock_irqsave(&device->client_data_lock, flags);
224 list_add(&context->list, &device->client_data_list);
225 spin_unlock_irqrestore(&device->client_data_lock, flags);
230 static int read_port_table_lengths(struct ib_device *device)
240 num_ports = end_port(device) - start_port(device) + 1;
242 device->pkey_tbl_len = kmalloc(sizeof *device->pkey_tbl_len * num_ports,
244 device->gid_tbl_len = kmalloc(sizeof *device->gid_tbl_len * num_ports,
246 if (!device->pkey_tbl_len || !device->gid_tbl_len)
250 ret = ib_query_port(device, port_index + start_port(device),
254 device->pkey_tbl_len[port_index] = tprops->pkey_tbl_len;
255 device->gid_tbl_len[port_index] = tprops->gid_tbl_len;
262 kfree(device->gid_tbl_len);
263 kfree(device->pkey_tbl_len);
270 * ib_register_device - Register an IB device with IB core
271 * @device:Device to register
275 * callback for each device that is added. @device must be allocated
278 int ib_register_device(struct ib_device *device,
286 if (strchr(device->name, '%')) {
287 ret = alloc_name(device->name);
292 if (ib_device_check_mandatory(device)) {
297 INIT_LIST_HEAD(&device->event_handler_list);
298 INIT_LIST_HEAD(&device->client_data_list);
299 spin_lock_init(&device->event_handler_lock);
300 spin_lock_init(&device->client_data_lock);
301 device->ib_uverbs_xrcd_table = RB_ROOT;
302 mutex_init(&device->xrcd_table_mutex);
304 ret = read_port_table_lengths(device);
306 printk(KERN_WARNING "Couldn't create table lengths cache for device %s\n",
307 device->name);
311 ret = ib_device_register_sysfs(device, port_callback);
313 printk(KERN_WARNING "Couldn't register device %s with driver model\n",
314 device->name);
315 kfree(device->gid_tbl_len);
316 kfree(device->pkey_tbl_len);
320 list_add_tail(&device->core_list, &device_list);
322 device->reg_state = IB_DEV_REGISTERED;
328 if (client->add && !add_client_context(device, client))
329 client->add(device);
339 * ib_unregister_device - Unregister an IB device
340 * @device:Device to unregister
342 * Unregister an IB device. All clients will receive a remove callback.
344 void ib_unregister_device(struct ib_device *device)
354 client->remove(device);
356 list_del(&device->core_list);
358 kfree(device->gid_tbl_len);
359 kfree(device->pkey_tbl_len);
363 ib_device_unregister_sysfs(device);
365 spin_lock_irqsave(&device->client_data_lock, flags);
366 list_for_each_entry_safe(context, tmp, &device->client_data_list, list)
368 spin_unlock_irqrestore(&device->client_data_lock, flags);
370 device->reg_state = IB_DEV_UNREGISTERED;
379 * register callbacks for IB device addition and removal. When an IB
380 * device is added, each registered client's add method will be called
381 * (in the order the clients were registered), and when a device is
389 struct ib_device *device;
394 list_for_each_entry(device, &device_list, core_list)
395 if (client->add && !add_client_context(device, client))
396 client->add(device);
410 * will receive a remove callback for each IB device still registered.
415 struct ib_device *device;
420 list_for_each_entry(device, &device_list, core_list) {
422 client->remove(device);
424 spin_lock_irqsave(&device->client_data_lock, flags);
425 list_for_each_entry_safe(context, tmp, &device->client_data_list, list)
430 spin_unlock_irqrestore(&device->client_data_lock, flags);
440 * @device:Device to get context for
446 void *ib_get_client_data(struct ib_device *device, struct ib_client *client)
452 spin_lock_irqsave(&device->client_data_lock, flags);
453 list_for_each_entry(context, &device->client_data_list, list)
458 spin_unlock_irqrestore(&device->client_data_lock, flags);
466 * @device:Device to set context for
473 void ib_set_client_data(struct ib_device *device, struct ib_client *client,
479 spin_lock_irqsave(&device->client_data_lock, flags);
480 list_for_each_entry(context, &device->client_data_list, list)
487 device->name, client->name);
490 spin_unlock_irqrestore(&device->client_data_lock, flags);
507 spin_lock_irqsave(&event_handler->device->event_handler_lock, flags);
509 &event_handler->device->event_handler_list);
510 spin_unlock_irqrestore(&event_handler->device->event_handler_lock, flags);
527 spin_lock_irqsave(&event_handler->device->event_handler_lock, flags);
529 spin_unlock_irqrestore(&event_handler->device->event_handler_lock, flags);
548 spin_lock_irqsave(&event->device->event_handler_lock, flags);
550 list_for_each_entry(handler, &event->device->event_handler_list, list)
553 spin_unlock_irqrestore(&event->device->event_handler_lock, flags);
558 * ib_query_device - Query IB device attributes
559 * @device:Device to query
562 * ib_query_device() returns the attributes of a device through the
565 int ib_query_device(struct ib_device *device,
568 return device->query_device(device, device_attr);
574 * @device:Device to query
581 int ib_query_port(struct ib_device *device, u8 port_num,
583 if (port_num < start_port(device) || port_num > end_port(device))
586 return device->query_port(device, port_num, port_attr);
593 * @device:Device to query
600 int ib_query_gid(struct ib_device *device, u8 port_num, int index,
602 return device->query_gid(device, port_num, index, gid);
609 * @device:Device to query
616 int ib_query_pkey(struct ib_device *device, u8 port_num, u16 index, u16 *pkey) {
617 return device->query_pkey(device, port_num, index, pkey);
623 * ib_modify_device - Change IB device attributes
624 * @device:Device to modify
628 * ib_modify_device() changes a device's attributes as specified by
631 int ib_modify_device(struct ib_device *device,
635 return device->modify_device(device, device_modify_mask,
642 * @device: The device to modify.
651 int ib_modify_port(struct ib_device *device,
655 if (port_num < start_port(device) || port_num > end_port(device))
658 return device->modify_port(device, port_num, port_modify_mask,
666 * @device: The device to query.
668 * @port_num: The port number of the device where the GID value was found.
672 int ib_find_gid(struct ib_device *device, union ib_gid *gid,
678 for (port = start_port(device); port <= end_port(device); ++port) {
679 for (i = 0; i < device->gid_tbl_len[port - start_port(device)]; ++i) {
680 ret = ib_query_gid(device, port, i, &tmp_gid);
699 * @device: The device to query.
700 * @port_num: The port number of the device to search for the PKey.
704 int ib_find_pkey(struct ib_device *device,
710 for (i = 0; i < device->pkey_tbl_len[port_num - start_port(device)]; ++i) {
711 ret = ib_query_pkey(device, port_num, i, &tmp_pkey);
736 printk(KERN_WARNING "Couldn't create InfiniBand device class\n");