Changeset View
Changeset View
Standalone View
Standalone View
sys/ofed/drivers/infiniband/core/uverbs.h
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
#include <linux/kref.h> | #include <linux/kref.h> | ||||
#include <linux/idr.h> | #include <linux/idr.h> | ||||
#include <linux/mutex.h> | #include <linux/mutex.h> | ||||
#include <linux/completion.h> | #include <linux/completion.h> | ||||
#include <linux/cdev.h> | #include <linux/cdev.h> | ||||
#include <linux/srcu.h> | #include <linux/srcu.h> | ||||
#include <linux/rcupdate.h> | #include <linux/rcupdate.h> | ||||
#include <linux/rbtree.h> | #include <linux/rbtree.h> | ||||
#include <linux/wait.h> | |||||
#include <rdma/ib_verbs.h> | #include <rdma/ib_verbs.h> | ||||
#include <rdma/ib_umem.h> | #include <rdma/ib_umem.h> | ||||
#include <rdma/ib_user_verbs.h> | #include <rdma/ib_user_verbs.h> | ||||
#include <rdma/uverbs_std_types.h> | |||||
#define UVERBS_MODULE_NAME ib_uverbs | |||||
#include <rdma/uverbs_named_ioctl.h> | |||||
static inline void | static inline void | ||||
ib_uverbs_init_udata(struct ib_udata *udata, | ib_uverbs_init_udata(struct ib_udata *udata, | ||||
const void __user *ibuf, | const void __user *ibuf, | ||||
void __user *obuf, | void __user *obuf, | ||||
size_t ilen, size_t olen) | size_t ilen, size_t olen) | ||||
{ | { | ||||
udata->inbuf = ibuf; | udata->inbuf = ibuf; | ||||
udata->outbuf = obuf; | udata->outbuf = obuf; | ||||
Show All 20 Lines | |||||
* ib_uverbs_open() each time the character special file is opened, | * ib_uverbs_open() each time the character special file is opened, | ||||
* and released in ib_uverbs_release_file() when the file is released. | * and released in ib_uverbs_release_file() when the file is released. | ||||
* | * | ||||
* struct ib_uverbs_file: One reference is held by the VFS and | * struct ib_uverbs_file: One reference is held by the VFS and | ||||
* released when the file is closed. Another reference is taken when | * released when the file is closed. Another reference is taken when | ||||
* an asynchronous event queue file is created and released when the | * an asynchronous event queue file is created and released when the | ||||
* event file is closed. | * event file is closed. | ||||
* | * | ||||
* struct ib_uverbs_event_file: One reference is held by the VFS and | * struct ib_uverbs_event_queue: Base structure for | ||||
* released when the file is closed. For asynchronous event files, | * struct ib_uverbs_async_event_file and struct ib_uverbs_completion_event_file. | ||||
* another reference is held by the corresponding main context file | * One reference is held by the VFS and released when the file is closed. | ||||
* and released when that file is closed. For completion event files, | * For asynchronous event files, another reference is held by the corresponding | ||||
* a reference is taken when a CQ is created that uses the file, and | * main context file and released when that file is closed. For completion | ||||
* released when the CQ is destroyed. | * event files, a reference is taken when a CQ is created that uses the file, | ||||
* and released when the CQ is destroyed. | |||||
*/ | */ | ||||
struct ib_uverbs_device { | struct ib_uverbs_device { | ||||
atomic_t refcount; | atomic_t refcount; | ||||
int num_comp_vectors; | u32 num_comp_vectors; | ||||
struct completion comp; | struct completion comp; | ||||
struct device *dev; | struct device dev; | ||||
struct ib_device __rcu *ib_dev; | struct ib_device __rcu *ib_dev; | ||||
int devnum; | int devnum; | ||||
struct cdev cdev; | struct cdev cdev; | ||||
struct rb_root xrcd_tree; | struct rb_root xrcd_tree; | ||||
struct mutex xrcd_tree_mutex; | struct mutex xrcd_tree_mutex; | ||||
struct kobject kobj; | |||||
struct srcu_struct disassociate_srcu; | struct srcu_struct disassociate_srcu; | ||||
struct mutex lists_mutex; /* protect lists */ | struct mutex lists_mutex; /* protect lists */ | ||||
struct list_head uverbs_file_list; | struct list_head uverbs_file_list; | ||||
struct list_head uverbs_events_file_list; | struct uverbs_api *uapi; | ||||
}; | }; | ||||
struct ib_uverbs_event_file { | struct ib_uverbs_event_queue { | ||||
struct kref ref; | |||||
int is_async; | |||||
struct ib_uverbs_file *uverbs_file; | |||||
spinlock_t lock; | spinlock_t lock; | ||||
int is_closed; | int is_closed; | ||||
wait_queue_head_t poll_wait; | wait_queue_head_t poll_wait; | ||||
struct fasync_struct *async_queue; | struct fasync_struct *async_queue; | ||||
struct list_head event_list; | struct list_head event_list; | ||||
struct list_head list; | |||||
}; | }; | ||||
struct ib_uverbs_async_event_file { | |||||
struct ib_uobject uobj; | |||||
struct ib_uverbs_event_queue ev_queue; | |||||
struct ib_event_handler event_handler; | |||||
}; | |||||
struct ib_uverbs_completion_event_file { | |||||
struct ib_uobject uobj; | |||||
struct ib_uverbs_event_queue ev_queue; | |||||
}; | |||||
struct ib_uverbs_file { | struct ib_uverbs_file { | ||||
struct kref ref; | struct kref ref; | ||||
struct mutex mutex; | |||||
struct mutex cleanup_mutex; /* protect cleanup */ | |||||
struct ib_uverbs_device *device; | struct ib_uverbs_device *device; | ||||
struct mutex ucontext_lock; | |||||
/* | |||||
* ucontext must be accessed via ib_uverbs_get_ucontext() or with | |||||
* ucontext_lock held | |||||
*/ | |||||
struct ib_ucontext *ucontext; | struct ib_ucontext *ucontext; | ||||
struct ib_event_handler event_handler; | struct ib_uverbs_async_event_file *async_file; | ||||
struct ib_uverbs_event_file *async_file; | |||||
struct list_head list; | struct list_head list; | ||||
int is_closed; | |||||
/* | |||||
* To access the uobjects list hw_destroy_rwsem must be held for write | |||||
* OR hw_destroy_rwsem held for read AND uobjects_lock held. | |||||
* hw_destroy_rwsem should be called across any destruction of the HW | |||||
* object of an associated uobject. | |||||
*/ | |||||
struct rw_semaphore hw_destroy_rwsem; | |||||
spinlock_t uobjects_lock; | |||||
struct list_head uobjects; | |||||
struct mutex umap_lock; | |||||
struct list_head umaps; | |||||
struct xarray idr; | |||||
}; | }; | ||||
struct ib_uverbs_event { | struct ib_uverbs_event { | ||||
union { | union { | ||||
struct ib_uverbs_async_event_desc async; | struct ib_uverbs_async_event_desc async; | ||||
struct ib_uverbs_comp_event_desc comp; | struct ib_uverbs_comp_event_desc comp; | ||||
} desc; | } desc; | ||||
struct list_head list; | struct list_head list; | ||||
struct list_head obj_list; | struct list_head obj_list; | ||||
u32 *counter; | u32 *counter; | ||||
}; | }; | ||||
struct ib_uverbs_mcast_entry { | struct ib_uverbs_mcast_entry { | ||||
struct list_head list; | struct list_head list; | ||||
union ib_gid gid; | union ib_gid gid; | ||||
u16 lid; | u16 lid; | ||||
}; | }; | ||||
struct ib_uevent_object { | struct ib_uevent_object { | ||||
struct ib_uobject uobject; | struct ib_uobject uobject; | ||||
/* List member for ib_uverbs_async_event_file list */ | |||||
struct list_head event_list; | struct list_head event_list; | ||||
u32 events_reported; | u32 events_reported; | ||||
}; | }; | ||||
struct ib_uxrcd_object { | struct ib_uxrcd_object { | ||||
struct ib_uobject uobject; | struct ib_uobject uobject; | ||||
atomic_t refcnt; | atomic_t refcnt; | ||||
}; | }; | ||||
Show All 11 Lines | struct ib_uqp_object { | ||||
struct ib_uxrcd_object *uxrcd; | struct ib_uxrcd_object *uxrcd; | ||||
}; | }; | ||||
struct ib_uwq_object { | struct ib_uwq_object { | ||||
struct ib_uevent_object uevent; | struct ib_uevent_object uevent; | ||||
}; | }; | ||||
struct ib_ucq_object { | struct ib_ucq_object { | ||||
struct ib_uobject uobject; | struct ib_uevent_object uevent; | ||||
struct ib_uverbs_file *uverbs_file; | |||||
struct list_head comp_list; | struct list_head comp_list; | ||||
struct list_head async_list; | |||||
u32 comp_events_reported; | u32 comp_events_reported; | ||||
u32 async_events_reported; | |||||
}; | }; | ||||
extern spinlock_t ib_uverbs_idr_lock; | extern const struct file_operations uverbs_event_fops; | ||||
extern struct idr ib_uverbs_pd_idr; | extern const struct file_operations uverbs_async_event_fops; | ||||
extern struct idr ib_uverbs_mr_idr; | void ib_uverbs_init_event_queue(struct ib_uverbs_event_queue *ev_queue); | ||||
extern struct idr ib_uverbs_mw_idr; | void ib_uverbs_init_async_event_file(struct ib_uverbs_async_event_file *ev_file); | ||||
extern struct idr ib_uverbs_ah_idr; | void ib_uverbs_free_event_queue(struct ib_uverbs_event_queue *event_queue); | ||||
extern struct idr ib_uverbs_cq_idr; | void ib_uverbs_flow_resources_free(struct ib_uflow_resources *uflow_res); | ||||
extern struct idr ib_uverbs_qp_idr; | |||||
extern struct idr ib_uverbs_srq_idr; | |||||
extern struct idr ib_uverbs_xrcd_idr; | |||||
extern struct idr ib_uverbs_rule_idr; | |||||
extern struct idr ib_uverbs_wq_idr; | |||||
extern struct idr ib_uverbs_rwq_ind_tbl_idr; | |||||
void idr_remove_uobj(struct idr *idp, struct ib_uobject *uobj); | int ib_alloc_ucontext(struct uverbs_attr_bundle *attrs); | ||||
int ib_init_ucontext(struct uverbs_attr_bundle *attrs); | |||||
struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file, | void ib_uverbs_release_ucq(struct ib_uverbs_completion_event_file *ev_file, | ||||
struct ib_device *ib_dev, | |||||
int is_async); | |||||
void ib_uverbs_free_async_event_file(struct ib_uverbs_file *uverbs_file); | |||||
struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd); | |||||
void ib_uverbs_release_ucq(struct ib_uverbs_file *file, | |||||
struct ib_uverbs_event_file *ev_file, | |||||
struct ib_ucq_object *uobj); | struct ib_ucq_object *uobj); | ||||
void ib_uverbs_release_uevent(struct ib_uverbs_file *file, | void ib_uverbs_release_uevent(struct ib_uevent_object *uobj); | ||||
struct ib_uevent_object *uobj); | void ib_uverbs_release_file(struct kref *ref); | ||||
void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context); | void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context); | ||||
void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr); | void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr); | ||||
void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr); | void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr); | ||||
void ib_uverbs_wq_event_handler(struct ib_event *event, void *context_ptr); | void ib_uverbs_wq_event_handler(struct ib_event *event, void *context_ptr); | ||||
void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr); | void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr); | ||||
void ib_uverbs_event_handler(struct ib_event_handler *handler, | int ib_uverbs_dealloc_xrcd(struct ib_uobject *uobject, struct ib_xrcd *xrcd, | ||||
struct ib_event *event); | enum rdma_remove_reason why, | ||||
void ib_uverbs_dealloc_xrcd(struct ib_uverbs_device *dev, struct ib_xrcd *xrcd); | struct uverbs_attr_bundle *attrs); | ||||
int uverbs_dealloc_mw(struct ib_mw *mw); | int uverbs_dealloc_mw(struct ib_mw *mw); | ||||
void ib_uverbs_detach_umcast(struct ib_qp *qp, | |||||
struct ib_uqp_object *uobj); | |||||
long ib_uverbs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); | |||||
struct ib_uverbs_flow_spec { | struct ib_uverbs_flow_spec { | ||||
union { | union { | ||||
union { | union { | ||||
struct ib_uverbs_flow_spec_hdr hdr; | struct ib_uverbs_flow_spec_hdr hdr; | ||||
struct { | struct { | ||||
__u32 type; | __u32 type; | ||||
__u16 size; | __u16 size; | ||||
__u16 reserved; | __u16 reserved; | ||||
}; | }; | ||||
}; | }; | ||||
struct ib_uverbs_flow_spec_eth eth; | struct ib_uverbs_flow_spec_eth eth; | ||||
struct ib_uverbs_flow_spec_ipv4 ipv4; | struct ib_uverbs_flow_spec_ipv4 ipv4; | ||||
struct ib_uverbs_flow_spec_esp esp; | |||||
struct ib_uverbs_flow_spec_tcp_udp tcp_udp; | struct ib_uverbs_flow_spec_tcp_udp tcp_udp; | ||||
struct ib_uverbs_flow_spec_ipv6 ipv6; | struct ib_uverbs_flow_spec_ipv6 ipv6; | ||||
struct ib_uverbs_flow_spec_action_tag flow_tag; | |||||
struct ib_uverbs_flow_spec_action_drop drop; | |||||
struct ib_uverbs_flow_spec_action_handle action; | |||||
struct ib_uverbs_flow_spec_action_count flow_count; | |||||
}; | }; | ||||
}; | }; | ||||
#define IB_UVERBS_DECLARE_CMD(name) \ | int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type, | ||||
ssize_t ib_uverbs_##name(struct ib_uverbs_file *file, \ | const void *kern_spec_mask, | ||||
struct ib_device *ib_dev, \ | const void *kern_spec_val, | ||||
const char __user *buf, int in_len, \ | size_t kern_filter_sz, | ||||
int out_len) | union ib_flow_spec *ib_spec); | ||||
IB_UVERBS_DECLARE_CMD(get_context); | /* | ||||
IB_UVERBS_DECLARE_CMD(query_device); | * ib_uverbs_query_port_resp.port_cap_flags started out as just a copy of the | ||||
IB_UVERBS_DECLARE_CMD(query_port); | * PortInfo CapabilityMask, but was extended with unique bits. | ||||
IB_UVERBS_DECLARE_CMD(alloc_pd); | */ | ||||
IB_UVERBS_DECLARE_CMD(dealloc_pd); | static inline u32 make_port_cap_flags(const struct ib_port_attr *attr) | ||||
IB_UVERBS_DECLARE_CMD(reg_mr); | { | ||||
IB_UVERBS_DECLARE_CMD(rereg_mr); | u32 res; | ||||
IB_UVERBS_DECLARE_CMD(dereg_mr); | |||||
IB_UVERBS_DECLARE_CMD(alloc_mw); | |||||
IB_UVERBS_DECLARE_CMD(dealloc_mw); | |||||
IB_UVERBS_DECLARE_CMD(create_comp_channel); | |||||
IB_UVERBS_DECLARE_CMD(create_cq); | |||||
IB_UVERBS_DECLARE_CMD(resize_cq); | |||||
IB_UVERBS_DECLARE_CMD(poll_cq); | |||||
IB_UVERBS_DECLARE_CMD(req_notify_cq); | |||||
IB_UVERBS_DECLARE_CMD(destroy_cq); | |||||
IB_UVERBS_DECLARE_CMD(create_qp); | |||||
IB_UVERBS_DECLARE_CMD(open_qp); | |||||
IB_UVERBS_DECLARE_CMD(query_qp); | |||||
IB_UVERBS_DECLARE_CMD(modify_qp); | |||||
IB_UVERBS_DECLARE_CMD(destroy_qp); | |||||
IB_UVERBS_DECLARE_CMD(post_send); | |||||
IB_UVERBS_DECLARE_CMD(post_recv); | |||||
IB_UVERBS_DECLARE_CMD(post_srq_recv); | |||||
IB_UVERBS_DECLARE_CMD(create_ah); | |||||
IB_UVERBS_DECLARE_CMD(destroy_ah); | |||||
IB_UVERBS_DECLARE_CMD(attach_mcast); | |||||
IB_UVERBS_DECLARE_CMD(detach_mcast); | |||||
IB_UVERBS_DECLARE_CMD(create_srq); | |||||
IB_UVERBS_DECLARE_CMD(modify_srq); | |||||
IB_UVERBS_DECLARE_CMD(query_srq); | |||||
IB_UVERBS_DECLARE_CMD(destroy_srq); | |||||
IB_UVERBS_DECLARE_CMD(create_xsrq); | |||||
IB_UVERBS_DECLARE_CMD(open_xrcd); | |||||
IB_UVERBS_DECLARE_CMD(close_xrcd); | |||||
#define IB_UVERBS_DECLARE_EX_CMD(name) \ | /* All IBA CapabilityMask bits are passed through here, except bit 26, | ||||
int ib_uverbs_ex_##name(struct ib_uverbs_file *file, \ | * which is overridden with IP_BASED_GIDS. This is due to a historical | ||||
struct ib_device *ib_dev, \ | * mistake in the implementation of IP_BASED_GIDS. Otherwise all other | ||||
struct ib_udata *ucore, \ | * bits match the IBA definition across all kernel versions. | ||||
struct ib_udata *uhw) | */ | ||||
res = attr->port_cap_flags & ~(u32)IB_UVERBS_PCF_IP_BASED_GIDS; | |||||
IB_UVERBS_DECLARE_EX_CMD(create_flow); | if (attr->ip_gids) | ||||
IB_UVERBS_DECLARE_EX_CMD(destroy_flow); | res |= IB_UVERBS_PCF_IP_BASED_GIDS; | ||||
IB_UVERBS_DECLARE_EX_CMD(query_device); | |||||
IB_UVERBS_DECLARE_EX_CMD(create_cq); | |||||
IB_UVERBS_DECLARE_EX_CMD(create_qp); | |||||
IB_UVERBS_DECLARE_EX_CMD(create_wq); | |||||
IB_UVERBS_DECLARE_EX_CMD(modify_wq); | |||||
IB_UVERBS_DECLARE_EX_CMD(destroy_wq); | |||||
IB_UVERBS_DECLARE_EX_CMD(create_rwq_ind_table); | |||||
IB_UVERBS_DECLARE_EX_CMD(destroy_rwq_ind_table); | |||||
return res; | |||||
} | |||||
void copy_port_attr_to_resp(struct ib_port_attr *attr, | |||||
struct ib_uverbs_query_port_resp *resp, | |||||
struct ib_device *ib_dev, u8 port_num); | |||||
#endif /* UVERBS_H */ | #endif /* UVERBS_H */ |