Skip to content

Commit

Permalink
Merge branch 'mlx5-devx' into wip/dl-for-next
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dledford committed Dec 4, 2018
2 parents ffd321e + 5aa3771 commit b2d8754
Show file tree
Hide file tree
Showing 47 changed files with 1,376 additions and 1,143 deletions.
27 changes: 17 additions & 10 deletions drivers/infiniband/core/rdma_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,16 +398,23 @@ struct ib_uobject *rdma_lookup_get_uobject(const struct uverbs_api_object *obj,
struct ib_uobject *uobj;
int ret;

if (!obj)
return ERR_PTR(-EINVAL);
if (IS_ERR(obj) && PTR_ERR(obj) == -ENOMSG) {
/* must be UVERBS_IDR_ANY_OBJECT, see uapi_get_object() */
uobj = lookup_get_idr_uobject(NULL, ufile, id, mode);
if (IS_ERR(uobj))
return uobj;
} else {
if (IS_ERR(obj))
return ERR_PTR(-EINVAL);

uobj = obj->type_class->lookup_get(obj, ufile, id, mode);
if (IS_ERR(uobj))
return uobj;
uobj = obj->type_class->lookup_get(obj, ufile, id, mode);
if (IS_ERR(uobj))
return uobj;

if (uobj->uapi_object != obj) {
ret = -EINVAL;
goto free;
if (uobj->uapi_object != obj) {
ret = -EINVAL;
goto free;
}
}

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

return uobj;
free:
obj->type_class->lookup_put(uobj, mode);
uobj->uapi_object->type_class->lookup_put(uobj, mode);
uverbs_uobject_put(uobj);
return ERR_PTR(ret);
}
Expand Down Expand Up @@ -491,7 +498,7 @@ struct ib_uobject *rdma_alloc_begin_uobject(const struct uverbs_api_object *obj,
{
struct ib_uobject *ret;

if (!obj)
if (IS_ERR(obj))
return ERR_PTR(-EINVAL);

/*
Expand Down
21 changes: 15 additions & 6 deletions drivers/infiniband/core/rdma_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ void release_ufile_idr_uobject(struct ib_uverbs_file *ufile);
* Depending on ID the slot pointer in the radix tree points at one of these
* structs.
*/
struct uverbs_api_object {
const struct uverbs_obj_type *type_attrs;
const struct uverbs_obj_type_class *type_class;
u8 disabled:1;
};

struct uverbs_api_ioctl_method {
int(__rcu *handler)(struct uverbs_attr_bundle *attrs);
Expand Down Expand Up @@ -162,10 +157,24 @@ struct uverbs_api {
const struct uverbs_api_write_method **write_ex_methods;
};

/*
* Get an uverbs_api_object that corresponds to the given object_id.
* Note:
* -ENOMSG means that any object is allowed to match during lookup.
*/
static inline const struct uverbs_api_object *
uapi_get_object(struct uverbs_api *uapi, u16 object_id)
{
return radix_tree_lookup(&uapi->radix, uapi_key_obj(object_id));
const struct uverbs_api_object *res;

if (object_id == UVERBS_IDR_ANY_OBJECT)
return ERR_PTR(-ENOMSG);

res = radix_tree_lookup(&uapi->radix, uapi_key_obj(object_id));
if (!res)
return ERR_PTR(-ENOENT);

return res;
}

char *uapi_key_format(char *S, unsigned int key);
Expand Down
10 changes: 8 additions & 2 deletions drivers/infiniband/core/uverbs_uapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ static int uapi_merge_obj_tree(struct uverbs_api *uapi,
if (WARN_ON(obj_elm->type_attrs))
return -EINVAL;

obj_elm->id = obj->id;
obj_elm->type_attrs = obj->type_attrs;
obj_elm->type_class = obj->type_attrs->type_class;
/*
Expand Down Expand Up @@ -580,8 +581,13 @@ static void uapi_finalize_disable(struct uverbs_api *uapi)
if (obj_key == UVERBS_API_KEY_ERR)
continue;
tmp_obj = uapi_get_object(uapi, obj_key);
if (tmp_obj && !tmp_obj->disabled)
continue;
if (IS_ERR(tmp_obj)) {
if (PTR_ERR(tmp_obj) == -ENOMSG)
continue;
} else {
if (!tmp_obj->disabled)
continue;
}

starting_key = iter.index;
uapi_remove_method(
Expand Down
4 changes: 3 additions & 1 deletion drivers/infiniband/hw/mlx5/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
obj-$(CONFIG_MLX5_INFINIBAND) += mlx5_ib.o

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
mlx5_ib-y := main.o cq.o doorbell.o qp.o mem.o srq_cmd.o \
srq.o mr.o ah.o mad.o gsi.o ib_virt.o cmd.o \
cong.o
mlx5_ib-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += odp.o
mlx5_ib-$(CONFIG_MLX5_ESWITCH) += ib_rep.o
mlx5_ib-$(CONFIG_INFINIBAND_USER_ACCESS) += devx.o
Expand Down
4 changes: 2 additions & 2 deletions drivers/infiniband/hw/mlx5/cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <rdma/ib_user_verbs.h>
#include <rdma/ib_cache.h>
#include "mlx5_ib.h"
#include "srq.h"

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

if (qp->ibqp.xrcd) {
msrq = mlx5_core_get_srq(dev->mdev,
be32_to_cpu(cqe->srqn));
msrq = mlx5_cmd_get_srq(dev, be32_to_cpu(cqe->srqn));
srq = to_mibsrq(msrq);
} else {
srq = to_msrq(qp->ibqp.srq);
Expand Down
Loading

0 comments on commit b2d8754

Please sign in to comment.