From: Leon Romanovsky <leon@kernel.org>
To: Selvin Xavier <selvin.xavier@broadcom.com>
Cc: jgg@ziepe.ca, linux-rdma@vger.kernel.org
Subject: Re: [PATCH for-next 1/2] RDMA/bnxt_re: Add UAPI to share a page with user space
Date: Wed, 13 Dec 2023 10:09:58 +0200 [thread overview]
Message-ID: <20231213080958.GM4870@unreal> (raw)
In-Reply-To: <1702438411-23530-2-git-send-email-selvin.xavier@broadcom.com>
On Tue, Dec 12, 2023 at 07:33:30PM -0800, Selvin Xavier wrote:
> Gen P7 adapters require to share a toggle value for CQ
> and SRQ. This is received by the driver as part of
> interrupt notifications and needs to be shared with the
> user space. Add a new UAPI infrastructure to get the
> shared page for CQ and SRQ.
>
> Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
> ---
> drivers/infiniband/hw/bnxt_re/ib_verbs.c | 106 +++++++++++++++++++++++++++++++
> drivers/infiniband/hw/bnxt_re/ib_verbs.h | 1 +
> include/uapi/rdma/bnxt_re-abi.h | 26 ++++++++
> 3 files changed, 133 insertions(+)
>
> diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> index e7ef099..76cea30 100644
> --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> @@ -567,6 +567,7 @@ bnxt_re_mmap_entry_insert(struct bnxt_re_ucontext *uctx, u64 mem_offset,
> case BNXT_RE_MMAP_WC_DB:
> case BNXT_RE_MMAP_DBR_BAR:
> case BNXT_RE_MMAP_DBR_PAGE:
> + case BNXT_RE_MMAP_TOGGLE_PAGE:
> ret = rdma_user_mmap_entry_insert(&uctx->ib_uctx,
> &entry->rdma_entry, PAGE_SIZE);
> break;
> @@ -4254,6 +4255,7 @@ int bnxt_re_mmap(struct ib_ucontext *ib_uctx, struct vm_area_struct *vma)
> rdma_entry);
> break;
> case BNXT_RE_MMAP_DBR_PAGE:
> + case BNXT_RE_MMAP_TOGGLE_PAGE:
> /* Driver doesn't expect write access for user space */
> if (vma->vm_flags & VM_WRITE)
> return -EFAULT;
> @@ -4430,8 +4432,112 @@ DECLARE_UVERBS_NAMED_METHOD(BNXT_RE_METHOD_NOTIFY_DRV);
> DECLARE_UVERBS_GLOBAL_METHODS(BNXT_RE_OBJECT_NOTIFY_DRV,
> &UVERBS_METHOD(BNXT_RE_METHOD_NOTIFY_DRV));
>
> +/* Toggle MEM */
> +static int UVERBS_HANDLER(BNXT_RE_METHOD_GET_TOGGLE_MEM)(struct uverbs_attr_bundle *attrs)
> +{
> + struct ib_uobject *uobj = uverbs_attr_get_uobject(attrs, BNXT_RE_TOGGLE_MEM_HANDLE);
> + enum bnxt_re_get_toggle_mem_type res_type;
> + struct bnxt_re_user_mmap_entry *entry;
> + enum bnxt_re_mmap_flag mmap_flag;
> + struct bnxt_qplib_chip_ctx *cctx;
> + struct bnxt_re_ucontext *uctx;
> + struct bnxt_re_dev *rdev;
> + u64 mem_offset;
> + u32 length;
> + u32 offset;
> + u64 addr;
> + int err;
> +
> + uctx = container_of(ib_uverbs_get_ucontext(attrs), struct bnxt_re_ucontext, ib_uctx);
> + if (IS_ERR(uctx))
How is it possible? You should check return value from ib_uverbs_get_ucontext() and not container_of.
> + return PTR_ERR(uctx);
> +
> + err = uverbs_get_const(&res_type, attrs, BNXT_RE_TOGGLE_MEM_TYPE);
> + if (err)
> + return err;
> +
> + rdev = uctx->rdev;
> + cctx = rdev->chip_ctx;
> +
> + switch (res_type) {
> + case BNXT_RE_CQ_TOGGLE_MEM:
> + break;
No need in this break here.
> + case BNXT_RE_SRQ_TOGGLE_MEM:
> + break;
> +
> + default:
> + return -EOPNOTSUPP;
> + }
Thanks
next prev parent reply other threads:[~2023-12-13 8:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-13 3:33 [PATCH for-next 0/2] RDMA/bnxt_re: Share the CQ pages for GenP7 adapters Selvin Xavier
2023-12-13 3:33 ` [PATCH for-next 1/2] RDMA/bnxt_re: Add UAPI to share a page with user space Selvin Xavier
2023-12-13 8:09 ` Leon Romanovsky [this message]
2023-12-13 8:17 ` Selvin Xavier
2023-12-13 15:59 ` kernel test robot
2023-12-13 3:33 ` [PATCH for-next 2/2] RDMA/bnxt_re: Share a page to expose per CQ info with userspace Selvin Xavier
2023-12-13 8:20 ` Leon Romanovsky
2023-12-13 8:38 ` Selvin Xavier
2023-12-13 16:21 ` kernel test robot
2023-12-13 19:48 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231213080958.GM4870@unreal \
--to=leon@kernel.org \
--cc=jgg@ziepe.ca \
--cc=linux-rdma@vger.kernel.org \
--cc=selvin.xavier@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox