⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 device.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 2 页
字号:
int ib_register_client(struct ib_client *client){	struct ib_device *device;	down(&device_sem);	list_add_tail(&client->list, &client_list);	list_for_each_entry(device, &device_list, core_list)		if (client->add && !add_client_context(device, client))			client->add(device);	up(&device_sem);	return 0;}EXPORT_SYMBOL(ib_register_client);/** * ib_unregister_client - Unregister an IB client * @client:Client to unregister * * Upper level users use ib_unregister_client() to remove their client * registration.  When ib_unregister_client() is called, the client * will receive a remove callback for each IB device still registered. */void ib_unregister_client(struct ib_client *client){	struct ib_client_data *context, *tmp;	struct ib_device *device;	unsigned long flags;	down(&device_sem);	list_for_each_entry(device, &device_list, core_list) {		if (client->remove)			client->remove(device);		spin_lock_irqsave(&device->client_data_lock, flags);		list_for_each_entry_safe(context, tmp, &device->client_data_list, list)			if (context->client == client) {				list_del(&context->list);				kfree(context);			}		spin_unlock_irqrestore(&device->client_data_lock, flags);	}	list_del(&client->list);	up(&device_sem);}EXPORT_SYMBOL(ib_unregister_client);/** * ib_get_client_data - Get IB client context * @device:Device to get context for * @client:Client to get context for * * ib_get_client_data() returns client context set with * ib_set_client_data(). */void *ib_get_client_data(struct ib_device *device, struct ib_client *client){	struct ib_client_data *context;	void *ret = NULL;	unsigned long flags;	spin_lock_irqsave(&device->client_data_lock, flags);	list_for_each_entry(context, &device->client_data_list, list)		if (context->client == client) {			ret = context->data;			break;		}	spin_unlock_irqrestore(&device->client_data_lock, flags);	return ret;}EXPORT_SYMBOL(ib_get_client_data);/** * ib_set_client_data - Get IB client context * @device:Device to set context for * @client:Client to set context for * @data:Context to set * * ib_set_client_data() sets client context that can be retrieved with * ib_get_client_data(). */void ib_set_client_data(struct ib_device *device, struct ib_client *client,			void *data){	struct ib_client_data *context;	unsigned long flags;	spin_lock_irqsave(&device->client_data_lock, flags);	list_for_each_entry(context, &device->client_data_list, list)		if (context->client == client) {			context->data = data;			goto out;		}	printk(KERN_WARNING "No client context found for %s/%s\n",	       device->name, client->name);out:	spin_unlock_irqrestore(&device->client_data_lock, flags);}EXPORT_SYMBOL(ib_set_client_data);/** * ib_register_event_handler - Register an IB event handler * @event_handler:Handler to register * * ib_register_event_handler() registers an event handler that will be * called back when asynchronous IB events occur (as defined in * chapter 11 of the InfiniBand Architecture Specification).  This * callback may occur in interrupt context. */int ib_register_event_handler  (struct ib_event_handler *event_handler){	unsigned long flags;	spin_lock_irqsave(&event_handler->device->event_handler_lock, flags);	list_add_tail(&event_handler->list,		      &event_handler->device->event_handler_list);	spin_unlock_irqrestore(&event_handler->device->event_handler_lock, flags);	return 0;}EXPORT_SYMBOL(ib_register_event_handler);/** * ib_unregister_event_handler - Unregister an event handler * @event_handler:Handler to unregister * * Unregister an event handler registered with * ib_register_event_handler(). */int ib_unregister_event_handler(struct ib_event_handler *event_handler){	unsigned long flags;	spin_lock_irqsave(&event_handler->device->event_handler_lock, flags);	list_del(&event_handler->list);	spin_unlock_irqrestore(&event_handler->device->event_handler_lock, flags);	return 0;}EXPORT_SYMBOL(ib_unregister_event_handler);/** * ib_dispatch_event - Dispatch an asynchronous event * @event:Event to dispatch * * Low-level drivers must call ib_dispatch_event() to dispatch the * event to all registered event handlers when an asynchronous event * occurs. */void ib_dispatch_event(struct ib_event *event){	unsigned long flags;	struct ib_event_handler *handler;	spin_lock_irqsave(&event->device->event_handler_lock, flags);	list_for_each_entry(handler, &event->device->event_handler_list, list)		handler->handler(handler, event);	spin_unlock_irqrestore(&event->device->event_handler_lock, flags);}EXPORT_SYMBOL(ib_dispatch_event);/** * ib_query_device - Query IB device attributes * @device:Device to query * @device_attr:Device attributes * * ib_query_device() returns the attributes of a device through the * @device_attr pointer. */int ib_query_device(struct ib_device *device,		    struct ib_device_attr *device_attr){	return device->query_device(device, device_attr);}EXPORT_SYMBOL(ib_query_device);/** * ib_query_port - Query IB port attributes * @device:Device to query * @port_num:Port number to query * @port_attr:Port attributes * * ib_query_port() returns the attributes of a port through the * @port_attr pointer. */int ib_query_port(struct ib_device *device,		  u8 port_num,		  struct ib_port_attr *port_attr){	if (device->node_type == IB_NODE_SWITCH) {		if (port_num)			return -EINVAL;	} else if (port_num < 1 || port_num > device->phys_port_cnt)		return -EINVAL;	return device->query_port(device, port_num, port_attr);}EXPORT_SYMBOL(ib_query_port);/** * ib_query_gid - Get GID table entry * @device:Device to query * @port_num:Port number to query * @index:GID table index to query * @gid:Returned GID * * ib_query_gid() fetches the specified GID table entry. */int ib_query_gid(struct ib_device *device,		 u8 port_num, int index, union ib_gid *gid){	return device->query_gid(device, port_num, index, gid);}EXPORT_SYMBOL(ib_query_gid);/** * ib_query_pkey - Get P_Key table entry * @device:Device to query * @port_num:Port number to query * @index:P_Key table index to query * @pkey:Returned P_Key * * ib_query_pkey() fetches the specified P_Key table entry. */int ib_query_pkey(struct ib_device *device,		  u8 port_num, u16 index, u16 *pkey){	return device->query_pkey(device, port_num, index, pkey);}EXPORT_SYMBOL(ib_query_pkey);/** * ib_modify_device - Change IB device attributes * @device:Device to modify * @device_modify_mask:Mask of attributes to change * @device_modify:New attribute values * * ib_modify_device() changes a device's attributes as specified by * the @device_modify_mask and @device_modify structure. */int ib_modify_device(struct ib_device *device,		     int device_modify_mask,		     struct ib_device_modify *device_modify){	return device->modify_device(device, device_modify_mask,				     device_modify);}EXPORT_SYMBOL(ib_modify_device);/** * ib_modify_port - Modifies the attributes for the specified port. * @device: The device to modify. * @port_num: The number of the port to modify. * @port_modify_mask: Mask used to specify which attributes of the port *   to change. * @port_modify: New attribute values for the port. * * ib_modify_port() changes a port's attributes as specified by the * @port_modify_mask and @port_modify structure. */int ib_modify_port(struct ib_device *device,		   u8 port_num, int port_modify_mask,		   struct ib_port_modify *port_modify){	if (device->node_type == IB_NODE_SWITCH) {		if (port_num)			return -EINVAL;	} else if (port_num < 1 || port_num > device->phys_port_cnt)		return -EINVAL;	return device->modify_port(device, port_num, port_modify_mask,				   port_modify);}EXPORT_SYMBOL(ib_modify_port);static int __init ib_core_init(void){	int ret;	ret = ib_sysfs_setup();	if (ret)		printk(KERN_WARNING "Couldn't create InfiniBand device class\n");	ret = ib_cache_setup();	if (ret) {		printk(KERN_WARNING "Couldn't set up InfiniBand P_Key/GID cache\n");		ib_sysfs_cleanup();	}	return ret;}static void __exit ib_core_cleanup(void){	ib_cache_cleanup();	ib_sysfs_cleanup();}module_init(ib_core_init);module_exit(ib_core_cleanup);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -