RDMA/core: Introduce IB_MR_TYPE_INTEGRITY and ib_alloc_mr_integrity API
This is a preparation for signature verbs API re-design. In the new design a single MR with IB_MR_TYPE_INTEGRITY type will be used to perform the needed mapping for data integrity operations. Signed-off-by: Israel Rukshin <israelr@mellanox.com> Signed-off-by: Max Gurtovoy <maxg@mellanox.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:

committed by
Jason Gunthorpe

parent
a0bc099abf
commit
26bc7eaee9
@@ -2437,6 +2437,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
|
||||
SET_DEVICE_OP(dev_ops, alloc_fmr);
|
||||
SET_DEVICE_OP(dev_ops, alloc_hw_stats);
|
||||
SET_DEVICE_OP(dev_ops, alloc_mr);
|
||||
SET_DEVICE_OP(dev_ops, alloc_mr_integrity);
|
||||
SET_DEVICE_OP(dev_ops, alloc_mw);
|
||||
SET_DEVICE_OP(dev_ops, alloc_pd);
|
||||
SET_DEVICE_OP(dev_ops, alloc_rdma_netdev);
|
||||
|
@@ -2011,6 +2011,9 @@ struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type,
|
||||
if (!pd->device->ops.alloc_mr)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
if (WARN_ON_ONCE(mr_type == IB_MR_TYPE_INTEGRITY))
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
mr = pd->device->ops.alloc_mr(pd, mr_type, max_num_sg, udata);
|
||||
if (!IS_ERR(mr)) {
|
||||
mr->device = pd->device;
|
||||
@@ -2028,6 +2031,49 @@ struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type,
|
||||
}
|
||||
EXPORT_SYMBOL(ib_alloc_mr_user);
|
||||
|
||||
/**
|
||||
* ib_alloc_mr_integrity() - Allocates an integrity memory region
|
||||
* @pd: protection domain associated with the region
|
||||
* @max_num_data_sg: maximum data sg entries available for registration
|
||||
* @max_num_meta_sg: maximum metadata sg entries available for
|
||||
* registration
|
||||
*
|
||||
* Notes:
|
||||
* Memory registration page/sg lists must not exceed max_num_sg,
|
||||
* also the integrity page/sg lists must not exceed max_num_meta_sg.
|
||||
*
|
||||
*/
|
||||
struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd,
|
||||
u32 max_num_data_sg,
|
||||
u32 max_num_meta_sg)
|
||||
{
|
||||
struct ib_mr *mr;
|
||||
|
||||
if (!pd->device->ops.alloc_mr_integrity)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
if (!max_num_meta_sg)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
mr = pd->device->ops.alloc_mr_integrity(pd, max_num_data_sg,
|
||||
max_num_meta_sg);
|
||||
if (IS_ERR(mr))
|
||||
return mr;
|
||||
|
||||
mr->device = pd->device;
|
||||
mr->pd = pd;
|
||||
mr->dm = NULL;
|
||||
mr->uobject = NULL;
|
||||
atomic_inc(&pd->usecnt);
|
||||
mr->need_inval = false;
|
||||
mr->res.type = RDMA_RESTRACK_MR;
|
||||
rdma_restrack_kadd(&mr->res);
|
||||
mr->type = IB_MR_TYPE_INTEGRITY;
|
||||
|
||||
return mr;
|
||||
}
|
||||
EXPORT_SYMBOL(ib_alloc_mr_integrity);
|
||||
|
||||
/* "Fast" memory regions */
|
||||
|
||||
struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd,
|
||||
|
Reference in New Issue
Block a user