-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RDMA/hns: Support rq record doorbell for the user space
This patch adds interfaces and definitions to support the rq record doorbell for the user space. Signed-off-by: Yixian Liu <liuyixian@huawei.com> Signed-off-by: Lijun Ou <oulijun@huawei.com> Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com> Signed-off-by: Shaobo Xu <xushaobo2@huawei.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
- Loading branch information
Yixian Liu
authored and
Doug Ledford
committed
Mar 13, 2018
1 parent
036ef0a
commit e088a68
Showing
7 changed files
with
200 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) */ | ||
/* | ||
* Copyright (c) 2017 Hisilicon Limited. | ||
* Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. | ||
*/ | ||
|
||
#include <linux/platform_device.h> | ||
#include <rdma/ib_umem.h> | ||
#include "hns_roce_device.h" | ||
|
||
int hns_roce_db_map_user(struct hns_roce_ucontext *context, unsigned long virt, | ||
struct hns_roce_db *db) | ||
{ | ||
struct hns_roce_user_db_page *page; | ||
int ret = 0; | ||
|
||
mutex_lock(&context->page_mutex); | ||
|
||
list_for_each_entry(page, &context->page_list, list) | ||
if (page->user_virt == (virt & PAGE_MASK)) | ||
goto found; | ||
|
||
page = kmalloc(sizeof(*page), GFP_KERNEL); | ||
if (!page) { | ||
ret = -ENOMEM; | ||
goto out; | ||
} | ||
|
||
refcount_set(&page->refcount, 1); | ||
page->user_virt = (virt & PAGE_MASK); | ||
page->umem = ib_umem_get(&context->ibucontext, virt & PAGE_MASK, | ||
PAGE_SIZE, 0, 0); | ||
if (IS_ERR(page->umem)) { | ||
ret = PTR_ERR(page->umem); | ||
kfree(page); | ||
goto out; | ||
} | ||
|
||
list_add(&page->list, &context->page_list); | ||
|
||
found: | ||
db->dma = sg_dma_address(page->umem->sg_head.sgl) + | ||
(virt & ~PAGE_MASK); | ||
db->u.user_page = page; | ||
refcount_inc(&page->refcount); | ||
|
||
out: | ||
mutex_unlock(&context->page_mutex); | ||
|
||
return ret; | ||
} | ||
EXPORT_SYMBOL(hns_roce_db_map_user); | ||
|
||
void hns_roce_db_unmap_user(struct hns_roce_ucontext *context, | ||
struct hns_roce_db *db) | ||
{ | ||
mutex_lock(&context->page_mutex); | ||
|
||
refcount_dec(&db->u.user_page->refcount); | ||
if (refcount_dec_if_one(&db->u.user_page->refcount)) { | ||
list_del(&db->u.user_page->list); | ||
ib_umem_release(db->u.user_page->umem); | ||
kfree(db->u.user_page); | ||
} | ||
|
||
mutex_unlock(&context->page_mutex); | ||
} | ||
EXPORT_SYMBOL(hns_roce_db_unmap_user); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters