Skip to content

Commit b2d8754

Browse files
committed
Merge branch 'mlx5-devx' into wip/dl-for-next
From Yishai, ----------------------------------- This series enriches DEVX support in few aspects: it enables interoperability between DEVX and verbs and improves mechanism for controlling privileged DEVX commands. The first patch updates mlx5 ifc file. Next 3 patches enable modifying and querying verbs objects via the DEVX interface. To achieve that the core layer introduced the 'UVERBS_IDR_ANY_OBJECT' type to match any IDR object. Once it's used by some driver's method, the infrastructure skips checking for the IDR type and it becomes the driver handler responsibility. The DEVX methods of modify and query were changed to get any object type via the 'UVERBS_IDR_ANY_OBJECT' mechanism. The type checking is done per object as part of the driver code. The next 3 patches introduce more robust mechanism for controlling privileged DEVX commands. The responsibility to block/allow per command was moved to be done in the firmware based on the UID credentials that the driver reports upon user context creation. This enables more granularity per command based on the device security model and the user credentials. In addition, by introducing a valid range for 'general commands' we prevent the need to touch the driver's code any time that a new future command will be added. The last patch fixes the XRC verbs flow once a DEVX context is used. This is needed as XRCD is some shared kernel resource and as such a kernel UID (=0) should be used in its related resources. Thanks Yishai Hadas ----------------------------------- The top 6 patches are the mlx5-devx series, the remainder are from the mlx5-next tree as the mlx5-devx series depended on the mlx5-next mlx5_ifc file update. * mlx5-devx: (42 commits) IB/mlx5: Allow XRC usage via verbs in DEVX context IB/mlx5: Update the supported DEVX commands IB/mlx5: Enforce DEVX privilege by firmware IB/mlx5: Enable modify and query verbs objects via DEVX IB/core: Enable getting an object type from a given uobject IB/core: Introduce UVERBS_IDR_ANY_OBJECT net/mlx5: Update mlx5_ifc with DEVX UCTX capabilities bits RDMA/mlx5: Unfold modify RMP function RDMA/mlx5: Unfold create RMP function RDMA/mlx5: Initialize SRQ tables on mlx5_ib RDMA/mlx5: Update SRQ functions signatures to mlx5_ib format RDMA/mlx5: Use stages for callback to setup and release DEVX RDMA/mlx5: Remove SRQ signature global flag net/mlx5: Move SRQ functions to RDMA part net/mlx5: Remove references to local mlx5_core functions net/mlx5: Remove not-used lib/eq.h header file net/mlx5: Remove dead transobj code net/mlx5: Align SRQ licenses and copyright information net/mlx5: Debug print for forwarded async events net/mlx5: Forward SRQ resource events ... Signed-off-by: Doug Ledford <dledford@redhat.com>
2 parents ffd321e + 5aa3771 commit b2d8754

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1376
-1143
lines changed

drivers/infiniband/core/rdma_core.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -398,16 +398,23 @@ struct ib_uobject *rdma_lookup_get_uobject(const struct uverbs_api_object *obj,
398398
struct ib_uobject *uobj;
399399
int ret;
400400

401-
if (!obj)
402-
return ERR_PTR(-EINVAL);
401+
if (IS_ERR(obj) && PTR_ERR(obj) == -ENOMSG) {
402+
/* must be UVERBS_IDR_ANY_OBJECT, see uapi_get_object() */
403+
uobj = lookup_get_idr_uobject(NULL, ufile, id, mode);
404+
if (IS_ERR(uobj))
405+
return uobj;
406+
} else {
407+
if (IS_ERR(obj))
408+
return ERR_PTR(-EINVAL);
403409

404-
uobj = obj->type_class->lookup_get(obj, ufile, id, mode);
405-
if (IS_ERR(uobj))
406-
return uobj;
410+
uobj = obj->type_class->lookup_get(obj, ufile, id, mode);
411+
if (IS_ERR(uobj))
412+
return uobj;
407413

408-
if (uobj->uapi_object != obj) {
409-
ret = -EINVAL;
410-
goto free;
414+
if (uobj->uapi_object != obj) {
415+
ret = -EINVAL;
416+
goto free;
417+
}
411418
}
412419

413420
/*
@@ -427,7 +434,7 @@ struct ib_uobject *rdma_lookup_get_uobject(const struct uverbs_api_object *obj,
427434

428435
return uobj;
429436
free:
430-
obj->type_class->lookup_put(uobj, mode);
437+
uobj->uapi_object->type_class->lookup_put(uobj, mode);
431438
uverbs_uobject_put(uobj);
432439
return ERR_PTR(ret);
433440
}
@@ -491,7 +498,7 @@ struct ib_uobject *rdma_alloc_begin_uobject(const struct uverbs_api_object *obj,
491498
{
492499
struct ib_uobject *ret;
493500

494-
if (!obj)
501+
if (IS_ERR(obj))
495502
return ERR_PTR(-EINVAL);
496503

497504
/*

drivers/infiniband/core/rdma_core.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ void release_ufile_idr_uobject(struct ib_uverbs_file *ufile);
118118
* Depending on ID the slot pointer in the radix tree points at one of these
119119
* structs.
120120
*/
121-
struct uverbs_api_object {
122-
const struct uverbs_obj_type *type_attrs;
123-
const struct uverbs_obj_type_class *type_class;
124-
u8 disabled:1;
125-
};
126121

127122
struct uverbs_api_ioctl_method {
128123
int(__rcu *handler)(struct uverbs_attr_bundle *attrs);
@@ -162,10 +157,24 @@ struct uverbs_api {
162157
const struct uverbs_api_write_method **write_ex_methods;
163158
};
164159

160+
/*
161+
* Get an uverbs_api_object that corresponds to the given object_id.
162+
* Note:
163+
* -ENOMSG means that any object is allowed to match during lookup.
164+
*/
165165
static inline const struct uverbs_api_object *
166166
uapi_get_object(struct uverbs_api *uapi, u16 object_id)
167167
{
168-
return radix_tree_lookup(&uapi->radix, uapi_key_obj(object_id));
168+
const struct uverbs_api_object *res;
169+
170+
if (object_id == UVERBS_IDR_ANY_OBJECT)
171+
return ERR_PTR(-ENOMSG);
172+
173+
res = radix_tree_lookup(&uapi->radix, uapi_key_obj(object_id));
174+
if (!res)
175+
return ERR_PTR(-ENOENT);
176+
177+
return res;
169178
}
170179

171180
char *uapi_key_format(char *S, unsigned int key);

drivers/infiniband/core/uverbs_uapi.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ static int uapi_merge_obj_tree(struct uverbs_api *uapi,
184184
if (WARN_ON(obj_elm->type_attrs))
185185
return -EINVAL;
186186

187+
obj_elm->id = obj->id;
187188
obj_elm->type_attrs = obj->type_attrs;
188189
obj_elm->type_class = obj->type_attrs->type_class;
189190
/*
@@ -580,8 +581,13 @@ static void uapi_finalize_disable(struct uverbs_api *uapi)
580581
if (obj_key == UVERBS_API_KEY_ERR)
581582
continue;
582583
tmp_obj = uapi_get_object(uapi, obj_key);
583-
if (tmp_obj && !tmp_obj->disabled)
584-
continue;
584+
if (IS_ERR(tmp_obj)) {
585+
if (PTR_ERR(tmp_obj) == -ENOMSG)
586+
continue;
587+
} else {
588+
if (!tmp_obj->disabled)
589+
continue;
590+
}
585591

586592
starting_key = iter.index;
587593
uapi_remove_method(

drivers/infiniband/hw/mlx5/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
obj-$(CONFIG_MLX5_INFINIBAND) += mlx5_ib.o
22

3-
mlx5_ib-y := main.o cq.o doorbell.o qp.o mem.o srq.o mr.o ah.o mad.o gsi.o ib_virt.o cmd.o cong.o
3+
mlx5_ib-y := main.o cq.o doorbell.o qp.o mem.o srq_cmd.o \
4+
srq.o mr.o ah.o mad.o gsi.o ib_virt.o cmd.o \
5+
cong.o
46
mlx5_ib-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += odp.o
57
mlx5_ib-$(CONFIG_MLX5_ESWITCH) += ib_rep.o
68
mlx5_ib-$(CONFIG_INFINIBAND_USER_ACCESS) += devx.o

drivers/infiniband/hw/mlx5/cq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <rdma/ib_user_verbs.h>
3636
#include <rdma/ib_cache.h>
3737
#include "mlx5_ib.h"
38+
#include "srq.h"
3839

3940
static void mlx5_ib_cq_comp(struct mlx5_core_cq *cq)
4041
{
@@ -177,8 +178,7 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
177178
struct mlx5_core_srq *msrq = NULL;
178179

179180
if (qp->ibqp.xrcd) {
180-
msrq = mlx5_core_get_srq(dev->mdev,
181-
be32_to_cpu(cqe->srqn));
181+
msrq = mlx5_cmd_get_srq(dev, be32_to_cpu(cqe->srqn));
182182
srq = to_mibsrq(msrq);
183183
} else {
184184
srq = to_msrq(qp->ibqp.srq);

0 commit comments

Comments
 (0)