Commit 7c717d3a authored by Max Gurtovoy's avatar Max Gurtovoy Committed by Jason Gunthorpe

RDMA/core: Add signature attrs element for ib_mr structure

This element will describe the needed characteristics for the signature
operation per signature enabled memory region (type IB_MR_TYPE_INTEGRITY).
Also add meta_length attribute to ib_sig_attrs structure for saving the
mapped metadata length (needed for the new API implementation).
Signed-off-by: default avatarMax Gurtovoy <maxg@mellanox.com>
Signed-off-by: default avatarIsrael Rukshin <israelr@mellanox.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 2cdfcdd8
...@@ -747,6 +747,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) ...@@ -747,6 +747,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs)
mr->pd = pd; mr->pd = pd;
mr->type = IB_MR_TYPE_USER; mr->type = IB_MR_TYPE_USER;
mr->dm = NULL; mr->dm = NULL;
mr->sig_attrs = NULL;
mr->uobject = uobj; mr->uobject = uobj;
atomic_inc(&pd->usecnt); atomic_inc(&pd->usecnt);
mr->res.type = RDMA_RESTRACK_MR; mr->res.type = RDMA_RESTRACK_MR;
......
...@@ -1976,6 +1976,7 @@ int ib_dereg_mr_user(struct ib_mr *mr, struct ib_udata *udata) ...@@ -1976,6 +1976,7 @@ int ib_dereg_mr_user(struct ib_mr *mr, struct ib_udata *udata)
{ {
struct ib_pd *pd = mr->pd; struct ib_pd *pd = mr->pd;
struct ib_dm *dm = mr->dm; struct ib_dm *dm = mr->dm;
struct ib_sig_attrs *sig_attrs = mr->sig_attrs;
int ret; int ret;
rdma_restrack_del(&mr->res); rdma_restrack_del(&mr->res);
...@@ -1984,6 +1985,7 @@ int ib_dereg_mr_user(struct ib_mr *mr, struct ib_udata *udata) ...@@ -1984,6 +1985,7 @@ int ib_dereg_mr_user(struct ib_mr *mr, struct ib_udata *udata)
atomic_dec(&pd->usecnt); atomic_dec(&pd->usecnt);
if (dm) if (dm)
atomic_dec(&dm->usecnt); atomic_dec(&dm->usecnt);
kfree(sig_attrs);
} }
return ret; return ret;
...@@ -2025,6 +2027,7 @@ struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type, ...@@ -2025,6 +2027,7 @@ struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type,
mr->res.type = RDMA_RESTRACK_MR; mr->res.type = RDMA_RESTRACK_MR;
rdma_restrack_kadd(&mr->res); rdma_restrack_kadd(&mr->res);
mr->type = mr_type; mr->type = mr_type;
mr->sig_attrs = NULL;
} }
return mr; return mr;
...@@ -2048,6 +2051,7 @@ struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd, ...@@ -2048,6 +2051,7 @@ struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd,
u32 max_num_meta_sg) u32 max_num_meta_sg)
{ {
struct ib_mr *mr; struct ib_mr *mr;
struct ib_sig_attrs *sig_attrs;
if (!pd->device->ops.alloc_mr_integrity || if (!pd->device->ops.alloc_mr_integrity ||
!pd->device->ops.map_mr_sg_pi) !pd->device->ops.map_mr_sg_pi)
...@@ -2056,10 +2060,16 @@ struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd, ...@@ -2056,10 +2060,16 @@ struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd,
if (!max_num_meta_sg) if (!max_num_meta_sg)
return ERR_PTR(-EINVAL); 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, mr = pd->device->ops.alloc_mr_integrity(pd, max_num_data_sg,
max_num_meta_sg); max_num_meta_sg);
if (IS_ERR(mr)) if (IS_ERR(mr)) {
kfree(sig_attrs);
return mr; return mr;
}
mr->device = pd->device; mr->device = pd->device;
mr->pd = pd; mr->pd = pd;
...@@ -2070,6 +2080,7 @@ struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd, ...@@ -2070,6 +2080,7 @@ struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd,
mr->res.type = RDMA_RESTRACK_MR; mr->res.type = RDMA_RESTRACK_MR;
rdma_restrack_kadd(&mr->res); rdma_restrack_kadd(&mr->res);
mr->type = IB_MR_TYPE_INTEGRITY; mr->type = IB_MR_TYPE_INTEGRITY;
mr->sig_attrs = sig_attrs;
return mr; return mr;
} }
......
...@@ -1739,7 +1739,7 @@ struct ib_mr { ...@@ -1739,7 +1739,7 @@ struct ib_mr {
}; };
struct ib_dm *dm; struct ib_dm *dm;
struct ib_sig_attrs *sig_attrs; /* only for IB_MR_TYPE_INTEGRITY MRs */
/* /*
* Implementation details of the RDMA core, don't use in drivers: * Implementation details of the RDMA core, don't use in drivers:
*/ */
......
...@@ -80,11 +80,13 @@ struct ib_sig_domain { ...@@ -80,11 +80,13 @@ struct ib_sig_domain {
* @check_mask: bitmask for signature byte check (8 bytes) * @check_mask: bitmask for signature byte check (8 bytes)
* @mem: memory domain layout descriptor. * @mem: memory domain layout descriptor.
* @wire: wire domain layout descriptor. * @wire: wire domain layout descriptor.
* @meta_length: metadata length
*/ */
struct ib_sig_attrs { struct ib_sig_attrs {
u8 check_mask; u8 check_mask;
struct ib_sig_domain mem; struct ib_sig_domain mem;
struct ib_sig_domain wire; struct ib_sig_domain wire;
int meta_length;
}; };
enum ib_sig_err_type { enum ib_sig_err_type {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment