diff mbox series

[08/17] RDMA/core: Add signature attrs element for ib_mr structure

Message ID 1549560811-8655-9-git-send-email-maxg@mellanox.com (mailing list archive)
State Superseded
Headers show
Series Introduce new API for T10-PI offload | expand

Commit Message

Max Gurtovoy Feb. 7, 2019, 5:33 p.m. UTC
This element will describe the needed characteristics for the signature
operation per signature enabled memory region (type IB_MR_TYPE_PI).

Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
Signed-off-by: Israel Rukshin <israelr@mellanox.com>
---
 drivers/infiniband/core/uverbs_cmd.c |  1 +
 drivers/infiniband/core/verbs.c      | 13 ++++++++++++-
 include/rdma/ib_verbs.h              |  2 +-
 3 files changed, 14 insertions(+), 2 deletions(-)

Comments

Sagi Grimberg Feb. 7, 2019, 6:18 p.m. UTC | #1
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Christoph Hellwig Feb. 12, 2019, 4:03 p.m. UTC | #2
On Thu, Feb 07, 2019 at 07:33:22PM +0200, Max Gurtovoy wrote:
> This element will describe the needed characteristics for the signature
> operation per signature enabled memory region (type IB_MR_TYPE_PI).
> 
> Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
> Signed-off-by: Israel Rukshin <israelr@mellanox.com>
> ---
>  drivers/infiniband/core/uverbs_cmd.c |  1 +
>  drivers/infiniband/core/verbs.c      | 13 ++++++++++++-
>  include/rdma/ib_verbs.h              |  2 +-
>  3 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> index 72c5a8daf558..699fbcf68d06 100644
> --- a/drivers/infiniband/core/uverbs_cmd.c
> +++ b/drivers/infiniband/core/uverbs_cmd.c
> @@ -739,6 +739,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs)
>  	mr->pd      = pd;
>  	mr->type    = IB_MR_TYPE_MEM_REG;
>  	mr->dm	    = NULL;
> +	mr->sig_attrs = NULL;

Maybe this is an argument that the PI MR support should use a different
structure rathern than ib_mr?  That would also remove the need for all
the error checking if the "right" kind of MR is passed in.
Max Gurtovoy March 3, 2019, 1:08 p.m. UTC | #3
On 2/12/2019 6:03 PM, Christoph Hellwig wrote:
> On Thu, Feb 07, 2019 at 07:33:22PM +0200, Max Gurtovoy wrote:
>> This element will describe the needed characteristics for the signature
>> operation per signature enabled memory region (type IB_MR_TYPE_PI).
>>
>> Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
>> Signed-off-by: Israel Rukshin <israelr@mellanox.com>
>> ---
>>   drivers/infiniband/core/uverbs_cmd.c |  1 +
>>   drivers/infiniband/core/verbs.c      | 13 ++++++++++++-
>>   include/rdma/ib_verbs.h              |  2 +-
>>   3 files changed, 14 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
>> index 72c5a8daf558..699fbcf68d06 100644
>> --- a/drivers/infiniband/core/uverbs_cmd.c
>> +++ b/drivers/infiniband/core/uverbs_cmd.c
>> @@ -739,6 +739,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs)
>>   	mr->pd      = pd;
>>   	mr->type    = IB_MR_TYPE_MEM_REG;
>>   	mr->dm	    = NULL;
>> +	mr->sig_attrs = NULL;
> Maybe this is an argument that the PI MR support should use a different
> structure rathern than ib_mr?  That would also remove the need for all
> the error checking if the "right" kind of MR is passed in.

In general, this sounds reasonable. But if we do that, we should be 
doing that for all the MR types.

I guess you meant to embed ib_mr into 
ib_mr_integrity/ib_mr_aligned/ib_mr_gappy (or a much better naming...).

Well, we should consider that as an improvement to the rdma k-verbs API, 
regardless this patch set.

Jason/Leon/Doug,

thoughts ?

if needed, we can work on new APIs after merging this series. the series 
is already long enough...
diff mbox series

Patch

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 72c5a8daf558..699fbcf68d06 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -739,6 +739,7 @@  static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs)
 	mr->pd      = pd;
 	mr->type    = IB_MR_TYPE_MEM_REG;
 	mr->dm	    = NULL;
+	mr->sig_attrs = NULL;
 	mr->uobject = uobj;
 	atomic_inc(&pd->usecnt);
 	mr->res.type = RDMA_RESTRACK_MR;
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 8e36e451df05..1503e9dfc326 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -1947,6 +1947,7 @@  int ib_dereg_mr(struct ib_mr *mr)
 {
 	struct ib_pd *pd = mr->pd;
 	struct ib_dm *dm = mr->dm;
+	struct ib_sig_attrs *sig_attrs = mr->sig_attrs;
 	int ret;
 
 	rdma_restrack_del(&mr->res);
@@ -1955,6 +1956,7 @@  int ib_dereg_mr(struct ib_mr *mr)
 		atomic_dec(&pd->usecnt);
 		if (dm)
 			atomic_dec(&dm->usecnt);
+		kfree(sig_attrs);
 	}
 
 	return ret;
@@ -1996,6 +1998,7 @@  struct ib_mr *ib_alloc_mr(struct ib_pd *pd,
 		mr->res.type = RDMA_RESTRACK_MR;
 		rdma_restrack_kadd(&mr->res);
 		mr->type = mr_type;
+		mr->sig_attrs = NULL;
 	}
 
 	return mr;
@@ -2019,6 +2022,7 @@  struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd,
 				    u32 max_num_meta_sg)
 {
 	struct ib_mr *mr;
+	struct ib_sig_attrs *sig_attrs;
 
 	if (!pd->device->ops.alloc_mr_integrity ||
 	    !pd->device->ops.map_mr_sg_pi)
@@ -2027,10 +2031,16 @@  struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd,
 	if (!max_num_meta_sg)
 		return ERR_PTR(-EINVAL);
 
+	sig_attrs = kzalloc(sizeof(struct ib_sig_attrs), GFP_KERNEL);
+	if (!sig_attrs)
+		return ERR_PTR(-ENOMEM);
+
 	mr = pd->device->ops.alloc_mr_integrity(pd, max_num_data_sg,
 						max_num_meta_sg);
-	if (IS_ERR(mr))
+	if (IS_ERR(mr)) {
+		kfree(sig_attrs);
 		return mr;
+	}
 
 	mr->device = pd->device;
 	mr->pd = pd;
@@ -2041,6 +2051,7 @@  struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd,
 	mr->res.type = RDMA_RESTRACK_MR;
 	rdma_restrack_kadd(&mr->res);
 	mr->type = IB_MR_TYPE_PI;
+	mr->sig_attrs = sig_attrs;
 
 	return mr;
 }
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 134d13ab39e5..1ec36490bc6f 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1707,7 +1707,7 @@  struct ib_mr {
 	};
 
 	struct ib_dm      *dm;
-
+	struct ib_sig_attrs *sig_attrs; /* only for IB_MR_TYPE_PI MRs */
 	/*
 	 * Implementation details of the RDMA core, don't use in drivers:
 	 */