linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Bob Pearson <rpearsonhpe@gmail.com>
Cc: zyjzyj2000@gmail.com, linux-rdma@vger.kernel.org
Subject: Re: [PATCH v3 3/6] RDMA/rxe: Create AH index and return to user space
Date: Fri, 27 Aug 2021 09:51:09 -0300	[thread overview]
Message-ID: <20210827125109.GA1353574@nvidia.com> (raw)
In-Reply-To: <20210722212244.412157-4-rpearsonhpe@gmail.com>

On Thu, Jul 22, 2021 at 04:22:42PM -0500, Bob Pearson wrote:
> Make changes to rdma_user_rxe.h to allow indexing AH objects, passing
> the index in UD send WRs to the driver and returning the index to the rxe
> provider.
> 
> Modify rxe_create_ah() to add an index to AH when created and if
> called from a new user provider return it to user space. If called
> from an old provider mark the AH as not having a useful index.
> Modify rxe_destroy_ah to drop the index before deleting the object.
> 
> Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
>  drivers/infiniband/sw/rxe/rxe_verbs.c | 31 ++++++++++++++++++++++++++-
>  drivers/infiniband/sw/rxe/rxe_verbs.h |  2 ++
>  include/uapi/rdma/rdma_user_rxe.h     |  8 ++++++-
>  3 files changed, 39 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
> index 725015a2e84c..7181e21f0c55 100644
> +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
> @@ -161,9 +161,19 @@ static int rxe_create_ah(struct ib_ah *ibah,
>  			 struct ib_udata *udata)
>  
>  {
> -	int err;
>  	struct rxe_dev *rxe = to_rdev(ibah->device);
>  	struct rxe_ah *ah = to_rah(ibah);
> +	struct rxe_create_ah_resp __user *uresp = NULL;
> +	int err;
> +
> +	if (udata) {
> +		/* test if new user provider */
> +		if (udata->outlen >= sizeof(*uresp))
> +			uresp = udata->outbuf;
> +		ah->is_user = true;
> +	} else {
> +		ah->is_user = false;
> +	}
>  
>  	err = rxe_av_chk_attr(rxe, init_attr->ah_attr);
>  	if (err)
> @@ -173,6 +183,24 @@ static int rxe_create_ah(struct ib_ah *ibah,
>  	if (err)
>  		return err;
>  
> +	/* create index > 0 */
> +	rxe_add_index(ah);
> +	ah->ah_num = ah->pelem.index;
> +
> +	if (uresp) {
> +		/* only if new user provider */
> +		err = copy_to_user(&uresp->ah_num, &ah->ah_num,
> +					 sizeof(uresp->ah_num));

This should just a using a min_t(size_t udata->outlen, sizeof(*uresp))

And this needs to create the uresp on the stack and copy the whole
thing, not try to copy single values at a time

> diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h
> index 959a3260fcab..500c47d84500 100644
> +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h
> @@ -48,6 +48,8 @@ struct rxe_ah {
>  	struct rxe_pool_entry	pelem;
>  	struct rxe_pd		*pd;
>  	struct rxe_av		av;
> +	bool			is_user;
> +	int			ah_num;

unsigned int?

Jason

  reply	other threads:[~2021-08-27 12:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-22 21:22 [PATCH for-next v3 0/5] Replace AV by AH in UD sends Bob Pearson
2021-07-22 21:22 ` [PATCH v3 1/6] RDMA/rxe: Move AV from rxe_send_wqe to rxe_send_wr Bob Pearson
2021-07-22 21:22 ` [PATCH v3 2/6] RDMA/rxe: Change AH objects to indexed Bob Pearson
2021-07-22 21:22 ` [PATCH v3 3/6] RDMA/rxe: Create AH index and return to user space Bob Pearson
2021-08-27 12:51   ` Jason Gunthorpe [this message]
2021-07-22 21:22 ` [PATCH v3 4/6] RDMA/rxe: Replace ah->pd by ah->ibah.pd Bob Pearson
2021-07-22 21:22 ` [PATCH v3 5/6] RDMA/rxe: Lookup kernel AH from ah index in UD WQEs Bob Pearson
2021-08-27 12:53   ` Jason Gunthorpe
2021-07-22 21:22 ` [PATCH v3 6/6] RDMA/rxe: Convert kernel UD post send to use ah_num Bob Pearson

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=20210827125109.GA1353574@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=rpearsonhpe@gmail.com \
    --cc=zyjzyj2000@gmail.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;
as well as URLs for NNTP newsgroup(s).