RDMA/core: Save the MR type in the ib_mr structure
authorMax Gurtovoy <maxg@mellanox.com>
Tue, 11 Jun 2019 15:52:38 +0000 (18:52 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Mon, 24 Jun 2019 14:49:26 +0000 (11:49 -0300)
This is a preparation for the signature verbs API change. This change is
needed since the MR type will define, in the upcoming patches, the need
for allocating internal resources in LLD for signature handover related
operations. It will also help to make sure that signature related
functions are called with an appropriate MR type and fail otherwise.
Also introduce new mr types IB_MR_TYPE_USER, IB_MR_TYPE_DMA and
IB_MR_TYPE_DM for correctness.

Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
Signed-off-by: Israel Rukshin <israelr@mellanox.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/core/uverbs_std_types_mr.c
drivers/infiniband/core/verbs.c
include/rdma/ib_verbs.h

index d13b87d27ce570558682a4332bd6efe628e0e453..689275c2894ffe22c15b1cb2d9a65ebd1ca62269 100644 (file)
@@ -745,6 +745,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs)
 
        mr->device  = pd->device;
        mr->pd      = pd;
+       mr->type    = IB_MR_TYPE_USER;
        mr->dm      = NULL;
        mr->uobject = uobj;
        atomic_inc(&pd->usecnt);
index 610d3b9f7654d81b891d2f87f867588b48a8b9b4..7ca79bfa348785afc560b56f836ff010539f2611 100644 (file)
@@ -128,6 +128,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_DM_MR_REG)(
 
        mr->device  = pd->device;
        mr->pd      = pd;
+       mr->type    = IB_MR_TYPE_DM;
        mr->dm      = dm;
        mr->uobject = uobj;
        atomic_inc(&pd->usecnt);
index 16ef8a9bda4c2f6daddd3e67d8006117184edb89..10ff85b79d257e88fc60b04e2769cb1799e5b015 100644 (file)
@@ -299,6 +299,7 @@ struct ib_pd *__ib_alloc_pd(struct ib_device *device, unsigned int flags,
 
                mr->device      = pd->device;
                mr->pd          = pd;
+               mr->type        = IB_MR_TYPE_DMA;
                mr->uobject     = NULL;
                mr->need_inval  = false;
 
@@ -2020,6 +2021,7 @@ struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type,
                mr->need_inval = false;
                mr->res.type = RDMA_RESTRACK_MR;
                rdma_restrack_kadd(&mr->res);
+               mr->type = mr_type;
        }
 
        return mr;
index dc59fa12669aba9570351994e65f15ec32d4f3bb..b6ec71ee4d3ede0fa9765ad4a2405d10f43abf67 100644 (file)
@@ -782,11 +782,20 @@ __attribute_const__ int ib_rate_to_mbps(enum ib_rate rate);
  *                            register any arbitrary sg lists (without
  *                            the normal mr constraints - see
  *                            ib_map_mr_sg)
+ * @IB_MR_TYPE_DM:            memory region that is used for device
+ *                            memory registration
+ * @IB_MR_TYPE_USER:          memory region that is used for the user-space
+ *                            application
+ * @IB_MR_TYPE_DMA:           memory region that is used for DMA operations
+ *                            without address translations (VA=PA)
  */
 enum ib_mr_type {
        IB_MR_TYPE_MEM_REG,
        IB_MR_TYPE_SIGNATURE,
        IB_MR_TYPE_SG_GAPS,
+       IB_MR_TYPE_DM,
+       IB_MR_TYPE_USER,
+       IB_MR_TYPE_DMA,
 };
 
 enum ib_mr_status_check {
@@ -1719,6 +1728,7 @@ struct ib_mr {
        u64                iova;
        u64                length;
        unsigned int       page_size;
+       enum ib_mr_type    type;
        bool               need_inval;
        union {
                struct ib_uobject       *uobject;       /* user */