ibcore: Implement ib_uverbs_get_ucontext_file().
Expose ib_ucontext from a given ib_uverbs_file. Drivers that use the ioctl(9) API may have the ib_uverbs_file and need a way to get the related ib_ucontext from it, this is enabled by this patch. Downstream patches from this series will use it. Linux commit: 7dc08dcfc8c86cb4457e383734ff6844ddaff876 MFC after: 1 week Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
This commit is contained in:
parent
05f4691919
commit
79b817084c
@ -146,6 +146,30 @@ static int (*uverbs_ex_cmd_table[])(struct ib_uverbs_file *file,
|
||||
static void ib_uverbs_add_one(struct ib_device *device);
|
||||
static void ib_uverbs_remove_one(struct ib_device *device, void *client_data);
|
||||
|
||||
/*
|
||||
* Must be called with the ufile->device->disassociate_srcu held, and the lock
|
||||
* must be held until use of the ucontext is finished.
|
||||
*/
|
||||
struct ib_ucontext *ib_uverbs_get_ucontext_file(struct ib_uverbs_file *ufile)
|
||||
{
|
||||
/*
|
||||
* We do not hold the hw_destroy_rwsem lock for this flow, instead
|
||||
* srcu is used. It does not matter if someone races this with
|
||||
* get_context, we get NULL or valid ucontext.
|
||||
*/
|
||||
struct ib_ucontext *ucontext = READ_ONCE(ufile->ucontext);
|
||||
|
||||
if (!srcu_dereference(ufile->device->ib_dev,
|
||||
&ufile->device->disassociate_srcu))
|
||||
return ERR_PTR(-EIO);
|
||||
|
||||
if (!ucontext)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
return ucontext;
|
||||
}
|
||||
EXPORT_SYMBOL(ib_uverbs_get_ucontext_file);
|
||||
|
||||
int uverbs_dealloc_mw(struct ib_mw *mw)
|
||||
{
|
||||
struct ib_pd *pd = mw->pd;
|
||||
|
@ -67,6 +67,7 @@
|
||||
|
||||
struct ifla_vf_info;
|
||||
struct ifla_vf_stats;
|
||||
struct ib_uverbs_file;
|
||||
|
||||
extern struct workqueue_struct *ib_wq;
|
||||
extern struct workqueue_struct *ib_comp_wq;
|
||||
@ -3390,6 +3391,8 @@ void ib_drain_rq(struct ib_qp *qp);
|
||||
void ib_drain_sq(struct ib_qp *qp);
|
||||
void ib_drain_qp(struct ib_qp *qp);
|
||||
|
||||
struct ib_ucontext *ib_uverbs_get_ucontext_file(struct ib_uverbs_file *ufile);
|
||||
|
||||
int ib_resolve_eth_dmac(struct ib_device *device,
|
||||
struct ib_ah_attr *ah_attr);
|
||||
#endif /* IB_VERBS_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user