2005-07-08 08:57:13 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2005 Topspin Communications. All rights reserved.
|
2006-01-31 06:29:21 +08:00
|
|
|
* Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
|
2005-08-11 14:03:10 +08:00
|
|
|
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
|
|
|
|
* Copyright (c) 2005 Voltaire, Inc. All rights reserved.
|
2005-10-15 06:26:04 +08:00
|
|
|
* Copyright (c) 2005 PathScale, Inc. All rights reserved.
|
2005-07-08 08:57:13 +08:00
|
|
|
*
|
|
|
|
* This software is available to you under a choice of one of two
|
|
|
|
* licenses. You may choose to be licensed under the terms of the GNU
|
|
|
|
* General Public License (GPL) Version 2, available from the file
|
|
|
|
* COPYING in the main directory of this source tree, or the
|
|
|
|
* OpenIB.org BSD license below:
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or
|
|
|
|
* without modification, are permitted provided that the following
|
|
|
|
* conditions are met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer.
|
|
|
|
*
|
|
|
|
* - Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials
|
|
|
|
* provided with the distribution.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*
|
|
|
|
* $Id: uverbs.h 2559 2005-06-06 19:43:16Z roland $
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef UVERBS_H
|
|
|
|
#define UVERBS_H
|
|
|
|
|
|
|
|
#include <linux/kref.h>
|
|
|
|
#include <linux/idr.h>
|
2006-01-14 06:51:39 +08:00
|
|
|
#include <linux/mutex.h>
|
2006-08-04 01:56:42 +08:00
|
|
|
#include <linux/completion.h>
|
2005-07-08 08:57:13 +08:00
|
|
|
|
2005-08-26 04:40:04 +08:00
|
|
|
#include <rdma/ib_verbs.h>
|
|
|
|
#include <rdma/ib_user_verbs.h>
|
2005-07-08 08:57:13 +08:00
|
|
|
|
2005-10-29 06:38:26 +08:00
|
|
|
/*
|
|
|
|
* Our lifetime rules for these structs are the following:
|
|
|
|
*
|
|
|
|
* struct ib_uverbs_device: One reference is held by the module and
|
|
|
|
* released in ib_uverbs_remove_one(). Another reference is taken by
|
|
|
|
* ib_uverbs_open() each time the character special file is opened,
|
|
|
|
* and released in ib_uverbs_release_file() when the file is released.
|
|
|
|
*
|
|
|
|
* struct ib_uverbs_file: One reference is held by the VFS and
|
|
|
|
* released when the file is closed. Another reference is taken when
|
|
|
|
* an asynchronous event queue file is created and released when the
|
|
|
|
* event file is closed.
|
|
|
|
*
|
|
|
|
* struct ib_uverbs_event_file: One reference is held by the VFS and
|
|
|
|
* released when the file is closed. For asynchronous event files,
|
|
|
|
* another reference is held by the corresponding main context file
|
|
|
|
* and released when that file is closed. For completion event files,
|
|
|
|
* a reference is taken when a CQ is created that uses the file, and
|
|
|
|
* released when the CQ is destroyed.
|
|
|
|
*/
|
|
|
|
|
2005-07-08 08:57:13 +08:00
|
|
|
struct ib_uverbs_device {
|
2005-10-29 06:38:26 +08:00
|
|
|
struct kref ref;
|
2006-08-04 01:56:42 +08:00
|
|
|
struct completion comp;
|
2005-07-08 08:57:13 +08:00
|
|
|
int devnum;
|
2005-10-29 06:38:26 +08:00
|
|
|
struct cdev *dev;
|
|
|
|
struct class_device *class_dev;
|
2005-07-08 08:57:13 +08:00
|
|
|
struct ib_device *ib_dev;
|
2005-09-27 04:53:25 +08:00
|
|
|
int num_comp_vectors;
|
2005-07-08 08:57:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ib_uverbs_event_file {
|
|
|
|
struct kref ref;
|
2005-09-27 04:53:25 +08:00
|
|
|
struct file *file;
|
2005-07-08 08:57:13 +08:00
|
|
|
struct ib_uverbs_file *uverbs_file;
|
|
|
|
spinlock_t lock;
|
|
|
|
int is_async;
|
|
|
|
wait_queue_head_t poll_wait;
|
2005-07-28 05:40:00 +08:00
|
|
|
struct fasync_struct *async_queue;
|
2005-07-08 08:57:13 +08:00
|
|
|
struct list_head event_list;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ib_uverbs_file {
|
|
|
|
struct kref ref;
|
2006-01-14 06:51:39 +08:00
|
|
|
struct mutex mutex;
|
2005-07-08 08:57:13 +08:00
|
|
|
struct ib_uverbs_device *device;
|
|
|
|
struct ib_ucontext *ucontext;
|
|
|
|
struct ib_event_handler event_handler;
|
2005-09-27 04:53:25 +08:00
|
|
|
struct ib_uverbs_event_file *async_file;
|
2005-07-08 08:57:13 +08:00
|
|
|
};
|
|
|
|
|
2005-09-10 06:55:08 +08:00
|
|
|
struct ib_uverbs_event {
|
|
|
|
union {
|
|
|
|
struct ib_uverbs_async_event_desc async;
|
|
|
|
struct ib_uverbs_comp_event_desc comp;
|
|
|
|
} desc;
|
2005-07-08 08:57:13 +08:00
|
|
|
struct list_head list;
|
2005-09-10 06:55:08 +08:00
|
|
|
struct list_head obj_list;
|
|
|
|
u32 *counter;
|
2005-07-08 08:57:13 +08:00
|
|
|
};
|
|
|
|
|
2005-11-30 08:57:01 +08:00
|
|
|
struct ib_uverbs_mcast_entry {
|
|
|
|
struct list_head list;
|
|
|
|
union ib_gid gid;
|
|
|
|
u16 lid;
|
|
|
|
};
|
|
|
|
|
2005-09-10 06:55:08 +08:00
|
|
|
struct ib_uevent_object {
|
|
|
|
struct ib_uobject uobject;
|
|
|
|
struct list_head event_list;
|
|
|
|
u32 events_reported;
|
2005-07-08 08:57:13 +08:00
|
|
|
};
|
|
|
|
|
2005-11-30 08:57:01 +08:00
|
|
|
struct ib_uqp_object {
|
|
|
|
struct ib_uevent_object uevent;
|
|
|
|
struct list_head mcast_list;
|
|
|
|
};
|
|
|
|
|
2005-09-10 06:55:08 +08:00
|
|
|
struct ib_ucq_object {
|
|
|
|
struct ib_uobject uobject;
|
2005-10-31 01:50:04 +08:00
|
|
|
struct ib_uverbs_file *uverbs_file;
|
2005-09-10 06:55:08 +08:00
|
|
|
struct list_head comp_list;
|
|
|
|
struct list_head async_list;
|
|
|
|
u32 comp_events_reported;
|
|
|
|
u32 async_events_reported;
|
2005-07-08 08:57:13 +08:00
|
|
|
};
|
|
|
|
|
IB/uverbs: Don't serialize with ib_uverbs_idr_mutex
Currently, all userspace verbs operations that call into the kernel
are serialized by ib_uverbs_idr_mutex. This can be a scalability
issue for some workloads, especially for devices driven by the ipath
driver, which needs to call into the kernel even for datapath
operations.
Fix this by adding reference counts to the userspace objects, and then
converting ib_uverbs_idr_mutex into a spinlock that only protects the
idrs long enough to take a reference on the object being looked up.
Because remove operations may fail, we have to do a slightly funky
two-step deletion, which is described in the comments at the top of
uverbs_cmd.c.
This also still leaves ib_uverbs_idr_lock as a single lock that is
possibly subject to contention. However, the lock hold time will only
be a single idr operation, so multiple threads should still be able to
make progress, even if ib_uverbs_idr_lock is being ping-ponged.
Surprisingly, these changes even shrink the object code:
add/remove: 23/5 grow/shrink: 4/21 up/down: 633/-693 (-60)
Signed-off-by: Roland Dreier <rolandd@cisco.com>
2006-06-18 11:44:49 +08:00
|
|
|
extern spinlock_t ib_uverbs_idr_lock;
|
2005-07-08 08:57:13 +08:00
|
|
|
extern struct idr ib_uverbs_pd_idr;
|
|
|
|
extern struct idr ib_uverbs_mr_idr;
|
|
|
|
extern struct idr ib_uverbs_mw_idr;
|
|
|
|
extern struct idr ib_uverbs_ah_idr;
|
|
|
|
extern struct idr ib_uverbs_cq_idr;
|
|
|
|
extern struct idr ib_uverbs_qp_idr;
|
2005-08-19 03:24:13 +08:00
|
|
|
extern struct idr ib_uverbs_srq_idr;
|
2005-07-08 08:57:13 +08:00
|
|
|
|
IB/uverbs: Don't serialize with ib_uverbs_idr_mutex
Currently, all userspace verbs operations that call into the kernel
are serialized by ib_uverbs_idr_mutex. This can be a scalability
issue for some workloads, especially for devices driven by the ipath
driver, which needs to call into the kernel even for datapath
operations.
Fix this by adding reference counts to the userspace objects, and then
converting ib_uverbs_idr_mutex into a spinlock that only protects the
idrs long enough to take a reference on the object being looked up.
Because remove operations may fail, we have to do a slightly funky
two-step deletion, which is described in the comments at the top of
uverbs_cmd.c.
This also still leaves ib_uverbs_idr_lock as a single lock that is
possibly subject to contention. However, the lock hold time will only
be a single idr operation, so multiple threads should still be able to
make progress, even if ib_uverbs_idr_lock is being ping-ponged.
Surprisingly, these changes even shrink the object code:
add/remove: 23/5 grow/shrink: 4/21 up/down: 633/-693 (-60)
Signed-off-by: Roland Dreier <rolandd@cisco.com>
2006-06-18 11:44:49 +08:00
|
|
|
void idr_remove_uobj(struct idr *idp, struct ib_uobject *uobj);
|
|
|
|
|
2005-09-27 04:53:25 +08:00
|
|
|
struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
|
|
|
|
int is_async, int *fd);
|
|
|
|
void ib_uverbs_release_event_file(struct kref *ref);
|
|
|
|
struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd);
|
|
|
|
|
2005-10-29 06:38:26 +08:00
|
|
|
void ib_uverbs_release_ucq(struct ib_uverbs_file *file,
|
|
|
|
struct ib_uverbs_event_file *ev_file,
|
|
|
|
struct ib_ucq_object *uobj);
|
|
|
|
void ib_uverbs_release_uevent(struct ib_uverbs_file *file,
|
|
|
|
struct ib_uevent_object *uobj);
|
|
|
|
|
2005-07-08 08:57:13 +08:00
|
|
|
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_qp_event_handler(struct ib_event *event, void *context_ptr);
|
2005-08-19 03:24:13 +08:00
|
|
|
void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr);
|
2005-09-27 04:53:25 +08:00
|
|
|
void ib_uverbs_event_handler(struct ib_event_handler *handler,
|
|
|
|
struct ib_event *event);
|
2005-07-08 08:57:13 +08:00
|
|
|
|
|
|
|
int ib_umem_get(struct ib_device *dev, struct ib_umem *mem,
|
|
|
|
void *addr, size_t size, int write);
|
|
|
|
void ib_umem_release(struct ib_device *dev, struct ib_umem *umem);
|
|
|
|
void ib_umem_release_on_close(struct ib_device *dev, struct ib_umem *umem);
|
|
|
|
|
|
|
|
#define IB_UVERBS_DECLARE_CMD(name) \
|
|
|
|
ssize_t ib_uverbs_##name(struct ib_uverbs_file *file, \
|
|
|
|
const char __user *buf, int in_len, \
|
|
|
|
int out_len)
|
|
|
|
|
|
|
|
IB_UVERBS_DECLARE_CMD(get_context);
|
|
|
|
IB_UVERBS_DECLARE_CMD(query_device);
|
|
|
|
IB_UVERBS_DECLARE_CMD(query_port);
|
|
|
|
IB_UVERBS_DECLARE_CMD(alloc_pd);
|
|
|
|
IB_UVERBS_DECLARE_CMD(dealloc_pd);
|
|
|
|
IB_UVERBS_DECLARE_CMD(reg_mr);
|
|
|
|
IB_UVERBS_DECLARE_CMD(dereg_mr);
|
2005-09-27 04:53:25 +08:00
|
|
|
IB_UVERBS_DECLARE_CMD(create_comp_channel);
|
2005-07-08 08:57:13 +08:00
|
|
|
IB_UVERBS_DECLARE_CMD(create_cq);
|
2006-01-31 06:29:21 +08:00
|
|
|
IB_UVERBS_DECLARE_CMD(resize_cq);
|
2005-10-15 06:26:04 +08:00
|
|
|
IB_UVERBS_DECLARE_CMD(poll_cq);
|
|
|
|
IB_UVERBS_DECLARE_CMD(req_notify_cq);
|
2005-07-08 08:57:13 +08:00
|
|
|
IB_UVERBS_DECLARE_CMD(destroy_cq);
|
|
|
|
IB_UVERBS_DECLARE_CMD(create_qp);
|
2006-02-14 08:31:25 +08:00
|
|
|
IB_UVERBS_DECLARE_CMD(query_qp);
|
2005-07-08 08:57:13 +08:00
|
|
|
IB_UVERBS_DECLARE_CMD(modify_qp);
|
|
|
|
IB_UVERBS_DECLARE_CMD(destroy_qp);
|
2005-10-15 06:26:04 +08:00
|
|
|
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);
|
2005-07-08 08:57:13 +08:00
|
|
|
IB_UVERBS_DECLARE_CMD(attach_mcast);
|
|
|
|
IB_UVERBS_DECLARE_CMD(detach_mcast);
|
2005-08-19 03:24:13 +08:00
|
|
|
IB_UVERBS_DECLARE_CMD(create_srq);
|
|
|
|
IB_UVERBS_DECLARE_CMD(modify_srq);
|
2006-02-14 08:31:57 +08:00
|
|
|
IB_UVERBS_DECLARE_CMD(query_srq);
|
2005-08-19 03:24:13 +08:00
|
|
|
IB_UVERBS_DECLARE_CMD(destroy_srq);
|
2005-07-08 08:57:13 +08:00
|
|
|
|
|
|
|
#endif /* UVERBS_H */
|