All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Jason Gunthorpe <jgg-uk2M96/98Pc@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	RDMA mailing list
	<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Mark Bloch <markb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Parav Pandit <parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Dasaratharaman Chandramouli
	<dasaratharaman.chandramouli-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Don Hiatt <don.hiatt-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH rdma-next 4/6] RDMA/{cma, ucma}: Refactor to have transport specific checks
Date: Thu, 11 Jan 2018 08:05:37 +0200	[thread overview]
Message-ID: <20180111060537.GO7368@mtr-leonro.local> (raw)
In-Reply-To: <20180110233748.GS4518-uk2M96/98Pc@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 3320 bytes --]

On Wed, Jan 10, 2018 at 04:37:48PM -0700, Jason Gunthorpe wrote:
> On Mon, Jan 08, 2018 at 05:04:46PM +0200, Leon Romanovsky wrote:
> > From: Parav Pandit <parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> >
> > Code is refactored to perform transport specific checks for OPA, IB,
> > RoCE to be done in core routine. Wherever possible, it is better to avoid
> > spreading transport specific code in multiple kernel modules.
> >
> > Signed-off-by: Parav Pandit <parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> > Reviewed-by: Mark Bloch <markb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> > Signed-off-by: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> >  drivers/infiniband/core/cma.c  | 11 ++++++++++-
> >  drivers/infiniband/core/ucma.c |  9 +--------
> >  2 files changed, 11 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> > index f1e425da926d..68223bd56b53 100644
> > +++ b/drivers/infiniband/core/cma.c
> > @@ -2522,14 +2522,23 @@ int rdma_set_ib_path(struct rdma_cm_id *id,
> >  		     struct sa_path_rec *path_rec)
> >  {
> >  	struct rdma_id_private *id_priv;
> > +	struct sa_path_rec *in_path_rec;
> > +	struct sa_path_rec opa;
> >  	int ret;
> >
> > +	if (rdma_cap_opa_ah(id->device, id->port_num)) {
> > +		sa_convert_path_ib_to_opa(&opa, path_rec);
> > +		in_path_rec = &opa;
> > +	} else {
> > +		in_path_rec = path_rec;
> > +	}
> > +
> >  	id_priv = container_of(id, struct rdma_id_private, id);
> >  	if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_RESOLVED,
> >  			   RDMA_CM_ROUTE_RESOLVED))
> >  		return -EINVAL;
> >
> > -	id->route.path_rec = kmemdup(path_rec, sizeof(*path_rec),
> > +	id->route.path_rec = kmemdup(in_path_rec, sizeof(*in_path_rec),
> >  				     GFP_KERNEL);
> >  	if (!id->route.path_rec) {
> >  		ret = -ENOMEM;
> > diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
> > index 6d32af27bac6..7b25226b608e 100644
> > +++ b/drivers/infiniband/core/ucma.c
> > @@ -1227,14 +1227,7 @@ static int ucma_set_ib_path(struct ucma_context *ctx,
> >  	sa_path.rec_type = SA_PATH_REC_TYPE_IB;
> >  	ib_sa_unpack_path(path_data->path_rec, &sa_path);
> >
> > -	if (rdma_cap_opa_ah(ctx->cm_id->device, ctx->cm_id->port_num)) {
> > -		struct sa_path_rec opa;
> > -
> > -		sa_convert_path_ib_to_opa(&opa, &sa_path);
> > -		ret = rdma_set_ib_path(ctx->cm_id, &opa);
> > -	} else {
> > -		ret = rdma_set_ib_path(ctx->cm_id, &sa_path);
> > -	}
> > +	ret = rdma_set_ib_path(ctx->cm_id, &sa_path);
>
>
> No, this is not right
>
> sa_convert_path_ib_to_opa is misnamed and the usage here is arguably
> misplaced.
>
> It is converting the internal OPA path record into a compability path
> record. The ONLY place a compatability path record should be used is
> at the uapi boundary when copying to userspace.
>
> It is certainly not the right direction to have the core APIs
> degrade the path record.
>
> If anything should be fixed here, it is to move the degradation closer
> to the actual copy_to_user.
>
> Why was it put here anyhow? I don't see a uapi boundary?

As Parav wrote, it was added in commit 57520751445b ("IB/SA: Add OPA
path record type") and it looks like this sa_convert_path_ib_to_opa()
can be deleted, because there is the same conversion in ucma_query_path().

Thanks

>
> Jason

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2018-01-11  6:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-08 15:04 [PATCH rdma-next 0/6] RoCE Path Record refactoring Leon Romanovsky
     [not found] ` <20180108150448.29069-1-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2018-01-08 15:04   ` [PATCH rdma-next 1/6] RDMA/cma: Use the net namespace of the rdma_cm_id Leon Romanovsky
     [not found]     ` <20180108150448.29069-2-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2018-01-19  8:38       ` Knut Omang
2018-01-08 15:04   ` [PATCH rdma-next 2/6] RDMA/cma: Provide function to set RoCE path record L2 parameters Leon Romanovsky
2018-01-08 15:04   ` [PATCH rdma-next 3/6] RDMA/{cma, ucma}: Simplify and rename rdma_set_ib_paths Leon Romanovsky
2018-01-08 15:04   ` [PATCH rdma-next 4/6] RDMA/{cma, ucma}: Refactor to have transport specific checks Leon Romanovsky
     [not found]     ` <20180108150448.29069-5-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2018-01-10 23:37       ` Jason Gunthorpe
     [not found]         ` <20180110233748.GS4518-uk2M96/98Pc@public.gmane.org>
2018-01-11  0:55           ` Parav Pandit
2018-01-11  6:05           ` Leon Romanovsky [this message]
     [not found]             ` <20180111060537.GO7368-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2018-01-11 16:56               ` Jason Gunthorpe
     [not found]                 ` <20180111165622.GB1309-uk2M96/98Pc@public.gmane.org>
2018-01-11 18:50                   ` Leon Romanovsky
     [not found]                     ` <20180111185004.GD15760-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2018-01-11 18:53                       ` Jason Gunthorpe
2018-01-08 15:04   ` [PATCH rdma-next 5/6] RDMA/cma: Fix setting RoCE specific path record fields Leon Romanovsky
     [not found]     ` <20180108150448.29069-6-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2018-01-11  5:04       ` Jason Gunthorpe
     [not found]         ` <20180111050453.GB16668-uk2M96/98Pc@public.gmane.org>
2018-01-11 13:57           ` Parav Pandit
2018-01-08 15:04   ` [PATCH rdma-next 6/6] RDMA/cma: Fix returning correct path record entry for RoCE Leon Romanovsky
2018-01-11  0:20   ` [PATCH rdma-next 0/6] RoCE Path Record refactoring Jason Gunthorpe

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=20180111060537.GO7368@mtr-leonro.local \
    --to=leon-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=dasaratharaman.chandramouli-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=don.hiatt-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=jgg-uk2M96/98Pc@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=markb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    /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.