All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Weihang Li <liweihang@huawei.com>
Cc: dledford@redhat.com, leon@kernel.org, linux-rdma@vger.kernel.org,
	linuxarm@huawei.com, Xi Wang <wangxi11@huawei.com>
Subject: Re: [PATCH v2 for-next 1/2] RDMA/hns: Refactor hns uar mmap flow
Date: Thu, 3 Jun 2021 16:12:05 -0300	[thread overview]
Message-ID: <20210603191205.GA318515@nvidia.com> (raw)
In-Reply-To: <1622705834-19353-2-git-send-email-liweihang@huawei.com>

On Thu, Jun 03, 2021 at 03:37:13PM +0800, Weihang Li wrote:
> From: Xi Wang <wangxi11@huawei.com>
> 
> Classify the uar address by wrapping the uar type and start page as offset
> for hns rdma io mmap.
> 
> Signed-off-by: Xi Wang <wangxi11@huawei.com>
> Signed-off-by: Weihang Li <liweihang@huawei.com>
>  drivers/infiniband/hw/hns/hns_roce_main.c | 27 ++++++++++++++++++++++++---
>  include/uapi/rdma/hns-abi.h               |  4 ++++
>  2 files changed, 28 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c
> index 6c6e82b..9610bfd 100644
> +++ b/drivers/infiniband/hw/hns/hns_roce_main.c
> @@ -338,12 +338,23 @@ static void hns_roce_dealloc_ucontext(struct ib_ucontext *ibcontext)
>  	hns_roce_uar_free(to_hr_dev(ibcontext->device), &context->uar);
>  }
>  
> -static int hns_roce_mmap(struct ib_ucontext *context,
> -			 struct vm_area_struct *vma)
> +/* command value is offset[15:8] */
> +static int hns_roce_mmap_get_command(unsigned long offset)
> +{
> +	return (offset >> 8) & 0xff;
> +}
> +
> +/* index value is offset[63:16] | offset[7:0] */
> +static unsigned long hns_roce_mmap_get_index(unsigned long offset)
> +{
> +	return ((offset >> 16) << 8) | (offset & 0xff);
> +}

Please try to avoid using this command stuff copied from mlx drivers,
especially do not encode the qpn in this.

The proper way is to request and return a mmap cookie through the
verb that causes the page to be allocated. For instance specifying a
new input parameter to the create QP udata and an output parameter
with the mmap cookie.

You can look at what the mlx UAR stuff does for some idea how to
convert the old command style to a the preferred cookie style.

Jason

  reply	other threads:[~2021-06-03 19:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03  7:37 [PATCH v2 for-next 0/2] RDMA/hns: Add support for userspace Direct WQE Weihang Li
2021-06-03  7:37 ` [PATCH v2 for-next 1/2] RDMA/hns: Refactor hns uar mmap flow Weihang Li
2021-06-03 19:12   ` Jason Gunthorpe [this message]
2021-06-10 12:07     ` liweihang
2021-06-03  7:37 ` [PATCH v2 for-next 2/2] RDMA/hns: Support direct WQE of userspace Weihang Li
2021-06-03 19:12   ` Jason Gunthorpe
2021-06-11  9:03     ` liweihang

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=20210603191205.GA318515@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=dledford@redhat.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=liweihang@huawei.com \
    --cc=wangxi11@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.