• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/sys/ofed/drivers/infiniband/core/

Lines Matching refs:device

59 	/* The device or client is going down. Do not call client or device
76 * client_list. device_mutex protects writer access by device and client
89 static int ib_device_check_mandatory(struct ib_device *device)
120 if (!*(void **) ((char *) device + mandatory_table[i].offset)) {
122 device->name, mandatory_table[i].name);
132 struct ib_device *device;
134 list_for_each_entry(device, &device_list, core_list)
135 if (!strncmp(name, device->name, IB_DEVICE_NAME_MAX))
136 return device;
146 struct ib_device *device;
153 list_for_each_entry(device, &device_list, core_list) {
154 if (!sscanf(device->name, name, &i))
159 if (!strncmp(buf, device->name, IB_DEVICE_NAME_MAX))
174 static void ib_device_release(struct device *device)
176 struct ib_device *dev = container_of(device, struct ib_device, dev);
183 * device reaches UNREGISTERED state.
197 * ib_alloc_device - allocate an IB device struct
208 struct ib_device *device;
213 device = kzalloc(size, GFP_KERNEL);
214 if (!device)
217 device->dev.parent = &linux_root_device;
218 device->dev.class = &ib_class;
219 device_initialize(&device->dev);
221 dev_set_drvdata(&device->dev, device);
223 INIT_LIST_HEAD(&device->event_handler_list);
224 spin_lock_init(&device->event_handler_lock);
225 spin_lock_init(&device->client_data_lock);
226 INIT_LIST_HEAD(&device->client_data_list);
227 INIT_LIST_HEAD(&device->port_list);
229 return device;
234 * ib_dealloc_device - free an IB device struct
235 * @device:structure to free
239 void ib_dealloc_device(struct ib_device *device)
241 WARN_ON(device->reg_state != IB_DEV_UNREGISTERED &&
242 device->reg_state != IB_DEV_UNINITIALIZED);
243 kobject_put(&device->dev.kobj);
247 static int add_client_context(struct ib_device *device, struct ib_client *client)
255 device->name, client->name);
264 spin_lock_irqsave(&device->client_data_lock, flags);
265 list_add(&context->list, &device->client_data_list);
266 spin_unlock_irqrestore(&device->client_data_lock, flags);
278 static int read_port_immutable(struct ib_device *device)
281 u8 start_port = rdma_start_port(device);
282 u8 end_port = rdma_end_port(device);
286 * device->port_immutable is indexed directly by the port number to make
292 device->port_immutable = kzalloc(sizeof(*device->port_immutable)
295 if (!device->port_immutable)
299 ret = device->get_port_immutable(device, port,
300 &device->port_immutable[port]);
304 if (verify_immutable(device, port))
320 * ib_register_device - Register an IB device with IB core
321 * @device:Device to register
325 * callback for each device that is added. @device must be allocated
328 int ib_register_device(struct ib_device *device,
338 if (strchr(device->name, '%')) {
339 ret = alloc_name(device->name);
344 if (ib_device_check_mandatory(device)) {
349 ret = read_port_immutable(device);
352 device->name);
356 ret = ib_cache_setup_one(device);
362 memset(&device->attrs, 0, sizeof(device->attrs));
363 ret = device->query_device(device, &device->attrs, &uhw);
365 pr_warn("Couldn't query the device attributes\n");
369 ret = ib_device_register_sysfs(device, port_callback);
371 pr_warn("Couldn't register device %s with driver model\n",
372 device->name);
376 device->reg_state = IB_DEV_REGISTERED;
379 if (client->add && !add_client_context(device, client))
380 client->add(device);
383 list_add_tail(&device->core_list, &device_list);
389 ib_cache_cleanup_one(device);
390 ib_cache_release_one(device);
392 kfree(device->port_immutable);
400 * ib_unregister_device - Unregister an IB device
401 * @device:Device to unregister
403 * Unregister an IB device. All clients will receive a remove callback.
405 void ib_unregister_device(struct ib_device *device)
413 list_del(&device->core_list);
414 spin_lock_irqsave(&device->client_data_lock, flags);
415 list_for_each_entry_safe(context, tmp, &device->client_data_list, list)
417 spin_unlock_irqrestore(&device->client_data_lock, flags);
420 list_for_each_entry_safe(context, tmp, &device->client_data_list,
423 context->client->remove(device, context->data);
429 ib_device_unregister_sysfs(device);
430 ib_cache_cleanup_one(device);
433 spin_lock_irqsave(&device->client_data_lock, flags);
434 list_for_each_entry_safe(context, tmp, &device->client_data_list, list)
436 spin_unlock_irqrestore(&device->client_data_lock, flags);
439 device->reg_state = IB_DEV_UNREGISTERED;
448 * register callbacks for IB device addition and removal. When an IB
449 * device is added, each registered client's add method will be called
450 * (in the order the clients were registered), and when a device is
458 struct ib_device *device;
462 list_for_each_entry(device, &device_list, core_list)
463 if (client->add && !add_client_context(device, client))
464 client->add(device);
482 * will receive a remove callback for each IB device still registered.
487 struct ib_device *device;
496 list_for_each_entry(device, &device_list, core_list) {
500 spin_lock_irqsave(&device->client_data_lock, flags);
501 list_for_each_entry_safe(context, tmp, &device->client_data_list, list)
507 spin_unlock_irqrestore(&device->client_data_lock, flags);
511 client->remove(device, found_context ?
516 device->name, client->name);
521 spin_lock_irqsave(&device->client_data_lock, flags);
524 spin_unlock_irqrestore(&device->client_data_lock, flags);
534 * @device:Device to get context for
540 void *ib_get_client_data(struct ib_device *device, struct ib_client *client)
546 spin_lock_irqsave(&device->client_data_lock, flags);
547 list_for_each_entry(context, &device->client_data_list, list)
552 spin_unlock_irqrestore(&device->client_data_lock, flags);
560 * @device:Device to set context for
567 void ib_set_client_data(struct ib_device *device, struct ib_client *client,
573 spin_lock_irqsave(&device->client_data_lock, flags);
574 list_for_each_entry(context, &device->client_data_list, list)
581 device->name, client->name);
584 spin_unlock_irqrestore(&device->client_data_lock, flags);
601 spin_lock_irqsave(&event_handler->device->event_handler_lock, flags);
603 &event_handler->device->event_handler_list);
604 spin_unlock_irqrestore(&event_handler->device->event_handler_lock, flags);
621 spin_lock_irqsave(&event_handler->device->event_handler_lock, flags);
623 spin_unlock_irqrestore(&event_handler->device->event_handler_lock, flags);
642 spin_lock_irqsave(&event->device->event_handler_lock, flags);
644 list_for_each_entry(handler, &event->device->event_handler_list, list)
647 spin_unlock_irqrestore(&event->device->event_handler_lock, flags);
653 * @device:Device to query
660 int ib_query_port(struct ib_device *device,
667 if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
671 err = device->query_port(device, port_num, port_attr);
675 if (rdma_port_get_link_layer(device, port_num) != IB_LINK_LAYER_INFINIBAND)
678 err = ib_query_gid(device, port_num, 0, &gid, NULL);
689 * @device:Device to query
698 int ib_query_gid(struct ib_device *device,
702 if (rdma_cap_roce_gid_table(device, port_num))
703 return ib_get_cached_gid(device, port_num, index, gid, attr);
708 return device->query_gid(device, port_num, index, gid);
714 * @ib_dev : IB device we want to query
722 * device for which filter() function returns non zero.
761 * to netdevices and calls callback() on each device for which
802 * @device:Device to query
809 int ib_query_pkey(struct ib_device *device,
812 return device->query_pkey(device, port_num, index, pkey);
817 * ib_modify_device - Change IB device attributes
818 * @device:Device to modify
822 * ib_modify_device() changes a device's attributes as specified by
825 int ib_modify_device(struct ib_device *device,
829 if (!device->modify_device)
832 return device->modify_device(device, device_modify_mask,
839 * @device: The device to modify.
848 int ib_modify_port(struct ib_device *device,
852 if (!device->modify_port)
855 if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
858 return device->modify_port(device, port_num, port_modify_mask,
866 * @device: The device to query.
870 * @port_num: The port number of the device where the GID value was found.
874 int ib_find_gid(struct ib_device *device, union ib_gid *gid,
881 for (port = rdma_start_port(device); port <= rdma_end_port(device); ++port) {
882 if (rdma_cap_roce_gid_table(device, port)) {
883 if (!ib_find_cached_gid_by_port(device, gid, gid_type, port,
893 for (i = 0; i < device->port_immutable[port].gid_tbl_len; ++i) {
894 ret = ib_query_gid(device, port, i, &tmp_gid, NULL);
913 * @device: The device to query.
914 * @port_num: The port number of the device to search for the PKey.
918 int ib_find_pkey(struct ib_device *device,
925 for (i = 0; i < device->port_immutable[port_num].pkey_tbl_len; ++i) {
926 ret = ib_query_pkey(device, port_num, i, &tmp_pkey);
952 * @dev: An RDMA device on which the request has been received.
953 * @port: Port number on the RDMA device.
1012 pr_warn("Couldn't create InfiniBand device class\n");