* [PATCH mlx5-next 1/7] net/mlx5: Update mlx5_ifc with DEVX UCTX capabilities bits
2018-11-26 6:28 [PATCH rdma-next 0/7] Enrich DEVX support Leon Romanovsky
@ 2018-11-26 6:28 ` Leon Romanovsky
2018-12-03 18:32 ` Doug Ledford
2018-11-26 6:28 ` [PATCH rdma-next 2/7] IB/core: Introduce UVERBS_IDR_ANY_OBJECT Leon Romanovsky
` (6 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: Leon Romanovsky @ 2018-11-26 6:28 UTC (permalink / raw)
To: Doug Ledford, Jason Gunthorpe
Cc: Leon Romanovsky, RDMA mailing list, Artemy Kovalyov, Yishai Hadas,
Saeed Mahameed, linux-netdev
From: Yishai Hadas <yishaih@mellanox.com>
Expose device capabilities for DEVX user context, it includes which caps
the device is supported and a matching bit to set as part of user
context creation.
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Reviewed-by: Artemy Kovalyov <artemyko@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
include/linux/mlx5/mlx5_ifc.h | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 6f64e814cc10..ece1b606c909 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -883,6 +883,10 @@ enum {
MLX5_CAP_UMR_FENCE_NONE = 0x2,
};
+enum {
+ MLX5_UCTX_CAP_RAW_TX = 1UL << 0,
+};
+
struct mlx5_ifc_cmd_hca_cap_bits {
u8 reserved_at_0[0x30];
u8 vhca_id[0x10];
@@ -1193,7 +1197,13 @@ struct mlx5_ifc_cmd_hca_cap_bits {
u8 num_vhca_ports[0x8];
u8 reserved_at_618[0x6];
u8 sw_owner_id[0x1];
- u8 reserved_at_61f[0x1e1];
+ u8 reserved_at_61f[0x1];
+
+ u8 reserved_at_620[0x80];
+
+ u8 uctx_cap[0x20];
+
+ u8 reserved_at_6c0[0x140];
};
enum mlx5_flow_destination_type {
@@ -9276,7 +9286,9 @@ struct mlx5_ifc_umem_bits {
struct mlx5_ifc_uctx_bits {
u8 modify_field_select[0x40];
- u8 reserved_at_40[0x1c0];
+ u8 cap[0x20];
+
+ u8 reserved_at_60[0x1a0];
};
struct mlx5_ifc_create_umem_in_bits {
--
2.19.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH mlx5-next 1/7] net/mlx5: Update mlx5_ifc with DEVX UCTX capabilities bits
2018-11-26 6:28 ` [PATCH mlx5-next 1/7] net/mlx5: Update mlx5_ifc with DEVX UCTX capabilities bits Leon Romanovsky
@ 2018-12-03 18:32 ` Doug Ledford
2018-12-04 7:56 ` Leon Romanovsky
0 siblings, 1 reply; 14+ messages in thread
From: Doug Ledford @ 2018-12-03 18:32 UTC (permalink / raw)
To: Leon Romanovsky, Jason Gunthorpe
Cc: Leon Romanovsky, RDMA mailing list, Artemy Kovalyov, Yishai Hadas,
Saeed Mahameed, linux-netdev
[-- Attachment #1: Type: text/plain, Size: 1910 bytes --]
On Mon, 2018-11-26 at 08:28 +0200, Leon Romanovsky wrote:
> From: Yishai Hadas <yishaih@mellanox.com>
>
> Expose device capabilities for DEVX user context, it includes which caps
> the device is supported and a matching bit to set as part of user
> context creation.
>
> Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
> Reviewed-by: Artemy Kovalyov <artemyko@mellanox.com>
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
This looks fine to me. Is it in mlx5-next yet?
> ---
> include/linux/mlx5/mlx5_ifc.h | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
> index 6f64e814cc10..ece1b606c909 100644
> --- a/include/linux/mlx5/mlx5_ifc.h
> +++ b/include/linux/mlx5/mlx5_ifc.h
> @@ -883,6 +883,10 @@ enum {
> MLX5_CAP_UMR_FENCE_NONE = 0x2,
> };
>
> +enum {
> + MLX5_UCTX_CAP_RAW_TX = 1UL << 0,
> +};
> +
> struct mlx5_ifc_cmd_hca_cap_bits {
> u8 reserved_at_0[0x30];
> u8 vhca_id[0x10];
> @@ -1193,7 +1197,13 @@ struct mlx5_ifc_cmd_hca_cap_bits {
> u8 num_vhca_ports[0x8];
> u8 reserved_at_618[0x6];
> u8 sw_owner_id[0x1];
> - u8 reserved_at_61f[0x1e1];
> + u8 reserved_at_61f[0x1];
> +
> + u8 reserved_at_620[0x80];
> +
> + u8 uctx_cap[0x20];
> +
> + u8 reserved_at_6c0[0x140];
> };
>
> enum mlx5_flow_destination_type {
> @@ -9276,7 +9286,9 @@ struct mlx5_ifc_umem_bits {
> struct mlx5_ifc_uctx_bits {
> u8 modify_field_select[0x40];
>
> - u8 reserved_at_40[0x1c0];
> + u8 cap[0x20];
> +
> + u8 reserved_at_60[0x1a0];
> };
>
> struct mlx5_ifc_create_umem_in_bits {
--
Doug Ledford <dledford@redhat.com>
GPG KeyID: B826A3330E572FDD
Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH mlx5-next 1/7] net/mlx5: Update mlx5_ifc with DEVX UCTX capabilities bits
2018-12-03 18:32 ` Doug Ledford
@ 2018-12-04 7:56 ` Leon Romanovsky
0 siblings, 0 replies; 14+ messages in thread
From: Leon Romanovsky @ 2018-12-04 7:56 UTC (permalink / raw)
To: Doug Ledford
Cc: Jason Gunthorpe, RDMA mailing list, Artemy Kovalyov, Yishai Hadas,
Saeed Mahameed, linux-netdev
[-- Attachment #1: Type: text/plain, Size: 649 bytes --]
On Mon, Dec 03, 2018 at 01:32:45PM -0500, Doug Ledford wrote:
> On Mon, 2018-11-26 at 08:28 +0200, Leon Romanovsky wrote:
> > From: Yishai Hadas <yishaih@mellanox.com>
> >
> > Expose device capabilities for DEVX user context, it includes which caps
> > the device is supported and a matching bit to set as part of user
> > context creation.
> >
> > Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
> > Reviewed-by: Artemy Kovalyov <artemyko@mellanox.com>
> > Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
>
> This looks fine to me. Is it in mlx5-next yet?
>
9d43faac02e3 net/mlx5: Update mlx5_ifc with DEVX UCTX capabilities bits
Thanks
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH rdma-next 2/7] IB/core: Introduce UVERBS_IDR_ANY_OBJECT
2018-11-26 6:28 [PATCH rdma-next 0/7] Enrich DEVX support Leon Romanovsky
2018-11-26 6:28 ` [PATCH mlx5-next 1/7] net/mlx5: Update mlx5_ifc with DEVX UCTX capabilities bits Leon Romanovsky
@ 2018-11-26 6:28 ` Leon Romanovsky
2018-11-26 6:28 ` [PATCH rdma-next 3/7] IB/core: Enable getting an object type from a given uobject Leon Romanovsky
` (5 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Leon Romanovsky @ 2018-11-26 6:28 UTC (permalink / raw)
To: Doug Ledford, Jason Gunthorpe
Cc: Leon Romanovsky, RDMA mailing list, Artemy Kovalyov, Yishai Hadas,
Saeed Mahameed, linux-netdev
From: Yishai Hadas <yishaih@mellanox.com>
Introduce the UVERBS_IDR_ANY_OBJECT type to match any IDR object.
Once used, the infrastructure skips checking for the IDR type, it
becomes the driver handler responsibility.
This enables drivers to get in a given method an object from various of
types.
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
drivers/infiniband/core/rdma_core.c | 27 +++++++++++++++++----------
drivers/infiniband/core/rdma_core.h | 16 +++++++++++++++-
drivers/infiniband/core/uverbs_uapi.c | 9 +++++++--
include/rdma/uverbs_ioctl.h | 6 ++++++
4 files changed, 45 insertions(+), 13 deletions(-)
diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c
index efa292489271..d160ed23065e 100644
--- a/drivers/infiniband/core/rdma_core.c
+++ b/drivers/infiniband/core/rdma_core.c
@@ -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;
+ }
}
/*
@@ -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);
}
@@ -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);
/*
diff --git a/drivers/infiniband/core/rdma_core.h b/drivers/infiniband/core/rdma_core.h
index bac484d6753a..8aec28037c48 100644
--- a/drivers/infiniband/core/rdma_core.h
+++ b/drivers/infiniband/core/rdma_core.h
@@ -162,10 +162,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);
diff --git a/drivers/infiniband/core/uverbs_uapi.c b/drivers/infiniband/core/uverbs_uapi.c
index 19ae4b19b2ef..faac225184a6 100644
--- a/drivers/infiniband/core/uverbs_uapi.c
+++ b/drivers/infiniband/core/uverbs_uapi.c
@@ -580,8 +580,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(
diff --git a/include/rdma/uverbs_ioctl.h b/include/rdma/uverbs_ioctl.h
index 7f4ace93e502..2f56844fb7da 100644
--- a/include/rdma/uverbs_ioctl.h
+++ b/include/rdma/uverbs_ioctl.h
@@ -524,6 +524,12 @@ struct uapi_definition {
.u2.objs_arr.max_len = _max_len, \
__VA_ARGS__ } })
+/*
+ * Only for use with UVERBS_ATTR_IDR, allows any uobject type to be accepted,
+ * the user must validate the type of the uobject instead.
+ */
+#define UVERBS_IDR_ANY_OBJECT 0xFFFF
+
#define UVERBS_ATTR_IDR(_attr_id, _idr_type, _access, ...) \
(&(const struct uverbs_attr_def){ \
.id = _attr_id, \
--
2.19.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH rdma-next 3/7] IB/core: Enable getting an object type from a given uobject
2018-11-26 6:28 [PATCH rdma-next 0/7] Enrich DEVX support Leon Romanovsky
2018-11-26 6:28 ` [PATCH mlx5-next 1/7] net/mlx5: Update mlx5_ifc with DEVX UCTX capabilities bits Leon Romanovsky
2018-11-26 6:28 ` [PATCH rdma-next 2/7] IB/core: Introduce UVERBS_IDR_ANY_OBJECT Leon Romanovsky
@ 2018-11-26 6:28 ` Leon Romanovsky
2018-11-26 6:28 ` [PATCH rdma-next 4/7] IB/mlx5: Enable modify and query verbs objects via DEVX Leon Romanovsky
` (4 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Leon Romanovsky @ 2018-11-26 6:28 UTC (permalink / raw)
To: Doug Ledford, Jason Gunthorpe
Cc: Leon Romanovsky, RDMA mailing list, Artemy Kovalyov, Yishai Hadas,
Saeed Mahameed, linux-netdev
From: Yishai Hadas <yishaih@mellanox.com>
Enable getting an object type from a given uobject, the type is saved
upon tree merging and is returned as part of some helper function.
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
drivers/infiniband/core/rdma_core.h | 5 -----
drivers/infiniband/core/uverbs_uapi.c | 1 +
include/rdma/uverbs_std_types.h | 12 ++++++++++++
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/infiniband/core/rdma_core.h b/drivers/infiniband/core/rdma_core.h
index 8aec28037c48..b3ca7457ac42 100644
--- a/drivers/infiniband/core/rdma_core.h
+++ b/drivers/infiniband/core/rdma_core.h
@@ -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);
diff --git a/drivers/infiniband/core/uverbs_uapi.c b/drivers/infiniband/core/uverbs_uapi.c
index faac225184a6..0136c1d78a0f 100644
--- a/drivers/infiniband/core/uverbs_uapi.c
+++ b/drivers/infiniband/core/uverbs_uapi.c
@@ -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;
/*
diff --git a/include/rdma/uverbs_std_types.h b/include/rdma/uverbs_std_types.h
index df878ce02c94..883abcf6d36e 100644
--- a/include/rdma/uverbs_std_types.h
+++ b/include/rdma/uverbs_std_types.h
@@ -182,5 +182,17 @@ static inline void ib_set_flow(struct ib_uobject *uobj, struct ib_flow *ibflow,
uflow->resources = uflow_res;
}
+struct uverbs_api_object {
+ const struct uverbs_obj_type *type_attrs;
+ const struct uverbs_obj_type_class *type_class;
+ u8 disabled:1;
+ u32 id;
+};
+
+static inline u32 uobj_get_object_id(struct ib_uobject *uobj)
+{
+ return uobj->uapi_object->id;
+}
+
#endif
--
2.19.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH rdma-next 4/7] IB/mlx5: Enable modify and query verbs objects via DEVX
2018-11-26 6:28 [PATCH rdma-next 0/7] Enrich DEVX support Leon Romanovsky
` (2 preceding siblings ...)
2018-11-26 6:28 ` [PATCH rdma-next 3/7] IB/core: Enable getting an object type from a given uobject Leon Romanovsky
@ 2018-11-26 6:28 ` Leon Romanovsky
2018-11-26 6:28 ` [PATCH rdma-next 5/7] IB/mlx5: Enforce DEVX privilege by firmware Leon Romanovsky
` (3 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Leon Romanovsky @ 2018-11-26 6:28 UTC (permalink / raw)
To: Doug Ledford, Jason Gunthorpe
Cc: Leon Romanovsky, RDMA mailing list, Artemy Kovalyov, Yishai Hadas,
Saeed Mahameed, linux-netdev
From: Yishai Hadas <yishaih@mellanox.com>
Enables modify and query verbs objects via the DEVX interface.
To support this the above DEVX handlers were changed to get any
object type via the UVERBS_IDR_ANY_OBJECT mechanism.
The type checking and handling is done per object as part of the
driver code.
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
drivers/infiniband/hw/mlx5/devx.c | 108 ++++++++++++++++++++++++++----
1 file changed, 96 insertions(+), 12 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c
index 0aa2ee732eaa..f80b78aab4da 100644
--- a/drivers/infiniband/hw/mlx5/devx.c
+++ b/drivers/infiniband/hw/mlx5/devx.c
@@ -9,6 +9,7 @@
#include <rdma/uverbs_ioctl.h>
#include <rdma/mlx5_user_ioctl_cmds.h>
#include <rdma/ib_umem.h>
+#include <rdma/uverbs_std_types.h>
#include <linux/mlx5/driver.h>
#include <linux/mlx5/fs.h>
#include "mlx5_ib.h"
@@ -132,7 +133,7 @@ static u64 get_enc_obj_id(u16 opcode, u32 obj_id)
return ((u64)opcode << 32) | obj_id;
}
-static int devx_is_valid_obj_id(struct devx_obj *obj, const void *in)
+static u64 devx_get_obj_id(const void *in)
{
u16 opcode = MLX5_GET(general_obj_in_cmd_hdr, in, opcode);
u64 obj_id;
@@ -336,13 +337,96 @@ static int devx_is_valid_obj_id(struct devx_obj *obj, const void *in)
MLX5_GET(arm_xrq_in, in, xrqn));
break;
default:
+ obj_id = 0;
+ }
+
+ return obj_id;
+}
+
+static bool devx_is_valid_obj_id(struct ib_uobject *uobj, const void *in)
+{
+ u64 obj_id = devx_get_obj_id(in);
+
+ if (!obj_id)
return false;
+
+ switch (uobj_get_object_id(uobj)) {
+ case UVERBS_OBJECT_CQ:
+ return get_enc_obj_id(MLX5_CMD_OP_CREATE_CQ,
+ to_mcq(uobj->object)->mcq.cqn) ==
+ obj_id;
+
+ case UVERBS_OBJECT_SRQ:
+ {
+ struct mlx5_core_srq *srq = &(to_msrq(uobj->object)->msrq);
+ struct mlx5_ib_dev *dev = to_mdev(uobj->context->device);
+ u16 opcode;
+
+ switch (srq->common.res) {
+ case MLX5_RES_XSRQ:
+ opcode = MLX5_CMD_OP_CREATE_XRC_SRQ;
+ break;
+ case MLX5_RES_XRQ:
+ opcode = MLX5_CMD_OP_CREATE_XRQ;
+ break;
+ default:
+ if (!dev->mdev->issi)
+ opcode = MLX5_CMD_OP_CREATE_SRQ;
+ else
+ opcode = MLX5_CMD_OP_CREATE_RMP;
+ }
+
+ return get_enc_obj_id(opcode,
+ to_msrq(uobj->object)->msrq.srqn) ==
+ obj_id;
}
- if (obj_id == obj->obj_id)
- return true;
+ case UVERBS_OBJECT_QP:
+ {
+ struct mlx5_ib_qp *qp = to_mqp(uobj->object);
+ enum ib_qp_type qp_type = qp->ibqp.qp_type;
+
+ if (qp_type == IB_QPT_RAW_PACKET ||
+ (qp->flags & MLX5_IB_QP_UNDERLAY)) {
+ struct mlx5_ib_raw_packet_qp *raw_packet_qp =
+ &qp->raw_packet_qp;
+ struct mlx5_ib_rq *rq = &raw_packet_qp->rq;
+ struct mlx5_ib_sq *sq = &raw_packet_qp->sq;
+
+ return (get_enc_obj_id(MLX5_CMD_OP_CREATE_RQ,
+ rq->base.mqp.qpn) == obj_id ||
+ get_enc_obj_id(MLX5_CMD_OP_CREATE_SQ,
+ sq->base.mqp.qpn) == obj_id ||
+ get_enc_obj_id(MLX5_CMD_OP_CREATE_TIR,
+ rq->tirn) == obj_id ||
+ get_enc_obj_id(MLX5_CMD_OP_CREATE_TIS,
+ sq->tisn) == obj_id);
+ }
+
+ if (qp_type == MLX5_IB_QPT_DCT)
+ return get_enc_obj_id(MLX5_CMD_OP_CREATE_DCT,
+ qp->dct.mdct.mqp.qpn) == obj_id;
+
+ return get_enc_obj_id(MLX5_CMD_OP_CREATE_QP,
+ qp->ibqp.qp_num) == obj_id;
+ }
- return false;
+ case UVERBS_OBJECT_WQ:
+ return get_enc_obj_id(MLX5_CMD_OP_CREATE_RQ,
+ to_mrwq(uobj->object)->core_qp.qpn) ==
+ obj_id;
+
+ case UVERBS_OBJECT_RWQ_IND_TBL:
+ return get_enc_obj_id(MLX5_CMD_OP_CREATE_RQT,
+ to_mrwq_ind_table(uobj->object)->rqtn) ==
+ obj_id;
+
+ case MLX5_IB_OBJECT_DEVX_OBJ:
+ return ((struct devx_obj *)uobj->object)->obj_id == obj_id;
+
+ default:
+ return false;
+ }
}
static void devx_set_umem_valid(const void *in)
@@ -994,7 +1078,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_MODIFY)(
struct ib_uobject *uobj = uverbs_attr_get_uobject(attrs,
MLX5_IB_ATTR_DEVX_OBJ_MODIFY_HANDLE);
struct mlx5_ib_ucontext *c = to_mucontext(uobj->context);
- struct devx_obj *obj = uobj->object;
+ struct mlx5_ib_dev *mdev = to_mdev(uobj->context->device);
void *cmd_out;
int err;
int uid;
@@ -1006,7 +1090,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_MODIFY)(
if (!devx_is_obj_modify_cmd(cmd_in))
return -EINVAL;
- if (!devx_is_valid_obj_id(obj, cmd_in))
+ if (!devx_is_valid_obj_id(uobj, cmd_in))
return -EINVAL;
cmd_out = uverbs_zalloc(attrs, cmd_out_len);
@@ -1016,7 +1100,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_MODIFY)(
MLX5_SET(general_obj_in_cmd_hdr, cmd_in, uid, uid);
devx_set_umem_valid(cmd_in);
- err = mlx5_cmd_exec(obj->mdev, cmd_in,
+ err = mlx5_cmd_exec(mdev->mdev, cmd_in,
uverbs_attr_get_len(attrs, MLX5_IB_ATTR_DEVX_OBJ_MODIFY_CMD_IN),
cmd_out, cmd_out_len);
if (err)
@@ -1035,10 +1119,10 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_QUERY)(
struct ib_uobject *uobj = uverbs_attr_get_uobject(attrs,
MLX5_IB_ATTR_DEVX_OBJ_QUERY_HANDLE);
struct mlx5_ib_ucontext *c = to_mucontext(uobj->context);
- struct devx_obj *obj = uobj->object;
void *cmd_out;
int err;
int uid;
+ struct mlx5_ib_dev *mdev = to_mdev(uobj->context->device);
uid = devx_get_uid(c, cmd_in);
if (uid < 0)
@@ -1047,7 +1131,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_QUERY)(
if (!devx_is_obj_query_cmd(cmd_in))
return -EINVAL;
- if (!devx_is_valid_obj_id(obj, cmd_in))
+ if (!devx_is_valid_obj_id(uobj, cmd_in))
return -EINVAL;
cmd_out = uverbs_zalloc(attrs, cmd_out_len);
@@ -1055,7 +1139,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_QUERY)(
return PTR_ERR(cmd_out);
MLX5_SET(general_obj_in_cmd_hdr, cmd_in, uid, uid);
- err = mlx5_cmd_exec(obj->mdev, cmd_in,
+ err = mlx5_cmd_exec(mdev->mdev, cmd_in,
uverbs_attr_get_len(attrs, MLX5_IB_ATTR_DEVX_OBJ_QUERY_CMD_IN),
cmd_out, cmd_out_len);
if (err)
@@ -1293,7 +1377,7 @@ DECLARE_UVERBS_NAMED_METHOD_DESTROY(
DECLARE_UVERBS_NAMED_METHOD(
MLX5_IB_METHOD_DEVX_OBJ_MODIFY,
UVERBS_ATTR_IDR(MLX5_IB_ATTR_DEVX_OBJ_MODIFY_HANDLE,
- MLX5_IB_OBJECT_DEVX_OBJ,
+ UVERBS_IDR_ANY_OBJECT,
UVERBS_ACCESS_WRITE,
UA_MANDATORY),
UVERBS_ATTR_PTR_IN(
@@ -1309,7 +1393,7 @@ DECLARE_UVERBS_NAMED_METHOD(
DECLARE_UVERBS_NAMED_METHOD(
MLX5_IB_METHOD_DEVX_OBJ_QUERY,
UVERBS_ATTR_IDR(MLX5_IB_ATTR_DEVX_OBJ_QUERY_HANDLE,
- MLX5_IB_OBJECT_DEVX_OBJ,
+ UVERBS_IDR_ANY_OBJECT,
UVERBS_ACCESS_READ,
UA_MANDATORY),
UVERBS_ATTR_PTR_IN(
--
2.19.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH rdma-next 5/7] IB/mlx5: Enforce DEVX privilege by firmware
2018-11-26 6:28 [PATCH rdma-next 0/7] Enrich DEVX support Leon Romanovsky
` (3 preceding siblings ...)
2018-11-26 6:28 ` [PATCH rdma-next 4/7] IB/mlx5: Enable modify and query verbs objects via DEVX Leon Romanovsky
@ 2018-11-26 6:28 ` Leon Romanovsky
2018-11-26 6:28 ` [PATCH rdma-next 6/7] IB/mlx5: Update the supported DEVX commands Leon Romanovsky
` (2 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Leon Romanovsky @ 2018-11-26 6:28 UTC (permalink / raw)
To: Doug Ledford, Jason Gunthorpe
Cc: Leon Romanovsky, RDMA mailing list, Artemy Kovalyov, Yishai Hadas,
Saeed Mahameed, linux-netdev
From: Yishai Hadas <yishaih@mellanox.com>
Enforce DEVX privilege by firmware, this enables future device
functionality without the need to make driver changes unless a new
privilege type will be introduced.
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Reviewed-by: Artemy Kovalyov <artemyko@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
drivers/infiniband/hw/mlx5/devx.c | 17 +++++++++--------
drivers/infiniband/hw/mlx5/main.c | 4 ++--
drivers/infiniband/hw/mlx5/mlx5_ib.h | 5 +++--
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c
index f80b78aab4da..80053324dd31 100644
--- a/drivers/infiniband/hw/mlx5/devx.c
+++ b/drivers/infiniband/hw/mlx5/devx.c
@@ -47,24 +47,31 @@ devx_ufile2uctx(const struct uverbs_attr_bundle *attrs)
return to_mucontext(ib_uverbs_get_ucontext(attrs));
}
-int mlx5_ib_devx_create(struct mlx5_ib_dev *dev)
+int mlx5_ib_devx_create(struct mlx5_ib_dev *dev, bool is_user)
{
u32 in[MLX5_ST_SZ_DW(create_uctx_in)] = {0};
u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {0};
u64 general_obj_types;
- void *hdr;
+ void *hdr, *uctx;
int err;
u16 uid;
+ u32 cap = 0;
hdr = MLX5_ADDR_OF(create_uctx_in, in, hdr);
+ uctx = MLX5_ADDR_OF(create_uctx_in, in, uctx);
general_obj_types = MLX5_CAP_GEN_64(dev->mdev, general_obj_types);
if (!(general_obj_types & MLX5_GENERAL_OBJ_TYPES_CAP_UCTX) ||
!(general_obj_types & MLX5_GENERAL_OBJ_TYPES_CAP_UMEM))
return -EINVAL;
+ if (is_user && capable(CAP_NET_RAW) &&
+ (MLX5_CAP_GEN(dev->mdev, uctx_cap) & MLX5_UCTX_CAP_RAW_TX))
+ cap |= MLX5_UCTX_CAP_RAW_TX;
+
MLX5_SET(general_obj_in_cmd_hdr, hdr, opcode, MLX5_CMD_OP_CREATE_GENERAL_OBJECT);
MLX5_SET(general_obj_in_cmd_hdr, hdr, obj_type, MLX5_OBJ_TYPE_UCTX);
+ MLX5_SET(uctx, uctx, cap, cap);
err = mlx5_cmd_exec(dev->mdev, in, sizeof(in), out, sizeof(out));
if (err)
@@ -672,9 +679,6 @@ static int devx_get_uid(struct mlx5_ib_ucontext *c, void *cmd_in)
if (!c->devx_uid)
return -EINVAL;
- if (!capable(CAP_NET_RAW))
- return -EPERM;
-
return c->devx_uid;
}
static bool devx_is_general_cmd(void *in)
@@ -1239,9 +1243,6 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_UMEM_REG)(
if (!c->devx_uid)
return -EINVAL;
- if (!capable(CAP_NET_RAW))
- return -EPERM;
-
obj = kzalloc(sizeof(struct devx_umem), GFP_KERNEL);
if (!obj)
return -ENOMEM;
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index b3986bc961ca..2b09e6896e5a 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -1763,7 +1763,7 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
#endif
if (req.flags & MLX5_IB_ALLOC_UCTX_DEVX) {
- err = mlx5_ib_devx_create(dev);
+ err = mlx5_ib_devx_create(dev, true);
if (err < 0)
goto out_uars;
context->devx_uid = err;
@@ -6234,7 +6234,7 @@ static int mlx5_ib_stage_devx_init(struct mlx5_ib_dev *dev)
{
int uid;
- uid = mlx5_ib_devx_create(dev);
+ uid = mlx5_ib_devx_create(dev, false);
if (uid > 0)
dev->devx_whitelist_uid = uid;
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index 59e1664a107f..4d33965369cc 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -1268,7 +1268,7 @@ void mlx5_ib_put_native_port_mdev(struct mlx5_ib_dev *dev,
u8 port_num);
#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
-int mlx5_ib_devx_create(struct mlx5_ib_dev *dev);
+int mlx5_ib_devx_create(struct mlx5_ib_dev *dev, bool is_user);
void mlx5_ib_devx_destroy(struct mlx5_ib_dev *dev, u16 uid);
const struct uverbs_object_tree_def *mlx5_ib_get_devx_tree(void);
extern const struct uapi_definition mlx5_ib_devx_defs[];
@@ -1283,7 +1283,8 @@ int mlx5_ib_get_flow_trees(const struct uverbs_object_tree_def **root);
void mlx5_ib_destroy_flow_action_raw(struct mlx5_ib_flow_action *maction);
#else
static inline int
-mlx5_ib_devx_create(struct mlx5_ib_dev *dev) { return -EOPNOTSUPP; };
+mlx5_ib_devx_create(struct mlx5_ib_dev *dev,
+ bool is_user) { return -EOPNOTSUPP; }
static inline void mlx5_ib_devx_destroy(struct mlx5_ib_dev *dev, u16 uid) {}
static inline bool mlx5_ib_devx_is_flow_dest(void *obj, int *dest_id,
int *dest_type)
--
2.19.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH rdma-next 6/7] IB/mlx5: Update the supported DEVX commands
2018-11-26 6:28 [PATCH rdma-next 0/7] Enrich DEVX support Leon Romanovsky
` (4 preceding siblings ...)
2018-11-26 6:28 ` [PATCH rdma-next 5/7] IB/mlx5: Enforce DEVX privilege by firmware Leon Romanovsky
@ 2018-11-26 6:28 ` Leon Romanovsky
2018-11-26 6:28 ` [PATCH rdma-next 7/7] IB/mlx5: Allow XRC usage via verbs in DEVX context Leon Romanovsky
2018-12-04 19:02 ` [PATCH rdma-next 0/7] Enrich DEVX support Doug Ledford
7 siblings, 0 replies; 14+ messages in thread
From: Leon Romanovsky @ 2018-11-26 6:28 UTC (permalink / raw)
To: Doug Ledford, Jason Gunthorpe
Cc: Leon Romanovsky, RDMA mailing list, Artemy Kovalyov, Yishai Hadas,
Saeed Mahameed, linux-netdev
From: Yishai Hadas <yishaih@mellanox.com>
Update the supported DEVX commands, it includes adding to the
query/modify command's list and to the encoding handling.
In addition, a valid range for general commands was added to be used for
future commands.
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Reviewed-by: Artemy Kovalyov <artemyko@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
drivers/infiniband/hw/mlx5/devx.c | 17 +++++++++++++++++
include/linux/mlx5/mlx5_ifc.h | 10 ++++++++++
2 files changed, 27 insertions(+)
diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c
index 80053324dd31..5271469aad10 100644
--- a/drivers/infiniband/hw/mlx5/devx.c
+++ b/drivers/infiniband/hw/mlx5/devx.c
@@ -314,6 +314,8 @@ static u64 devx_get_obj_id(const void *in)
MLX5_GET(query_dct_in, in, dctn));
break;
case MLX5_CMD_OP_QUERY_XRQ:
+ case MLX5_CMD_OP_QUERY_XRQ_DC_PARAMS_ENTRY:
+ case MLX5_CMD_OP_QUERY_XRQ_ERROR_PARAMS:
obj_id = get_enc_obj_id(MLX5_CMD_OP_CREATE_XRQ,
MLX5_GET(query_xrq_in, in, xrqn));
break;
@@ -340,9 +342,16 @@ static u64 devx_get_obj_id(const void *in)
MLX5_GET(drain_dct_in, in, dctn));
break;
case MLX5_CMD_OP_ARM_XRQ:
+ case MLX5_CMD_OP_SET_XRQ_DC_PARAMS_ENTRY:
obj_id = get_enc_obj_id(MLX5_CMD_OP_CREATE_XRQ,
MLX5_GET(arm_xrq_in, in, xrqn));
break;
+ case MLX5_CMD_OP_QUERY_PACKET_REFORMAT_CONTEXT:
+ obj_id = get_enc_obj_id
+ (MLX5_CMD_OP_ALLOC_PACKET_REFORMAT_CONTEXT,
+ MLX5_GET(query_packet_reformat_context_in,
+ in, packet_reformat_id));
+ break;
default:
obj_id = 0;
}
@@ -601,6 +610,7 @@ static bool devx_is_obj_modify_cmd(const void *in)
case MLX5_CMD_OP_DRAIN_DCT:
case MLX5_CMD_OP_ARM_DCT_FOR_KEY_VIOLATION:
case MLX5_CMD_OP_ARM_XRQ:
+ case MLX5_CMD_OP_SET_XRQ_DC_PARAMS_ENTRY:
return true;
case MLX5_CMD_OP_SET_FLOW_TABLE_ENTRY:
{
@@ -642,6 +652,9 @@ static bool devx_is_obj_query_cmd(const void *in)
case MLX5_CMD_OP_QUERY_XRC_SRQ:
case MLX5_CMD_OP_QUERY_DCT:
case MLX5_CMD_OP_QUERY_XRQ:
+ case MLX5_CMD_OP_QUERY_XRQ_DC_PARAMS_ENTRY:
+ case MLX5_CMD_OP_QUERY_XRQ_ERROR_PARAMS:
+ case MLX5_CMD_OP_QUERY_PACKET_REFORMAT_CONTEXT:
return true;
default:
return false;
@@ -685,6 +698,10 @@ static bool devx_is_general_cmd(void *in)
{
u16 opcode = MLX5_GET(general_obj_in_cmd_hdr, in, opcode);
+ if (opcode >= MLX5_CMD_OP_GENERAL_START &&
+ opcode < MLX5_CMD_OP_GENERAL_END)
+ return true;
+
switch (opcode) {
case MLX5_CMD_OP_QUERY_HCA_CAP:
case MLX5_CMD_OP_QUERY_HCA_VPORT_CONTEXT:
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index ece1b606c909..171d68663640 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -144,6 +144,9 @@ enum {
MLX5_CMD_OP_DESTROY_XRQ = 0x718,
MLX5_CMD_OP_QUERY_XRQ = 0x719,
MLX5_CMD_OP_ARM_XRQ = 0x71a,
+ MLX5_CMD_OP_QUERY_XRQ_DC_PARAMS_ENTRY = 0x725,
+ MLX5_CMD_OP_SET_XRQ_DC_PARAMS_ENTRY = 0x726,
+ MLX5_CMD_OP_QUERY_XRQ_ERROR_PARAMS = 0x727,
MLX5_CMD_OP_QUERY_VPORT_STATE = 0x750,
MLX5_CMD_OP_MODIFY_VPORT_STATE = 0x751,
MLX5_CMD_OP_QUERY_ESW_VPORT_CONTEXT = 0x752,
@@ -245,6 +248,7 @@ enum {
MLX5_CMD_OP_MODIFY_FLOW_TABLE = 0x93c,
MLX5_CMD_OP_ALLOC_PACKET_REFORMAT_CONTEXT = 0x93d,
MLX5_CMD_OP_DEALLOC_PACKET_REFORMAT_CONTEXT = 0x93e,
+ MLX5_CMD_OP_QUERY_PACKET_REFORMAT_CONTEXT = 0x93f,
MLX5_CMD_OP_ALLOC_MODIFY_HEADER_CONTEXT = 0x940,
MLX5_CMD_OP_DEALLOC_MODIFY_HEADER_CONTEXT = 0x941,
MLX5_CMD_OP_QUERY_MODIFY_HEADER_CONTEXT = 0x942,
@@ -260,6 +264,12 @@ enum {
MLX5_CMD_OP_MAX
};
+/* Valid range for general commands that don't work over an object */
+enum {
+ MLX5_CMD_OP_GENERAL_START = 0xb00,
+ MLX5_CMD_OP_GENERAL_END = 0xd00,
+};
+
struct mlx5_ifc_flow_table_fields_supported_bits {
u8 outer_dmac[0x1];
u8 outer_smac[0x1];
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH rdma-next 7/7] IB/mlx5: Allow XRC usage via verbs in DEVX context
2018-11-26 6:28 [PATCH rdma-next 0/7] Enrich DEVX support Leon Romanovsky
` (5 preceding siblings ...)
2018-11-26 6:28 ` [PATCH rdma-next 6/7] IB/mlx5: Update the supported DEVX commands Leon Romanovsky
@ 2018-11-26 6:28 ` Leon Romanovsky
2018-12-04 19:02 ` [PATCH rdma-next 0/7] Enrich DEVX support Doug Ledford
7 siblings, 0 replies; 14+ messages in thread
From: Leon Romanovsky @ 2018-11-26 6:28 UTC (permalink / raw)
To: Doug Ledford, Jason Gunthorpe
Cc: Leon Romanovsky, RDMA mailing list, Artemy Kovalyov, Yishai Hadas,
Saeed Mahameed, linux-netdev
From: Yishai Hadas <yishaih@mellanox.com>
Allows XRC usage from the verbs flow in a DEVX context.
As XRCD is some shared kernel resource between processes it should be
created with UID=0 to point on that.
As a result once XRC QP/SRQ are created they must be used as well with
UID=0 so that firmware will allow the XRCD usage.
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Reviewed-by: Artemy Kovalyov <artemyko@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 -
drivers/infiniband/hw/mlx5/qp.c | 12 +++++-------
drivers/infiniband/hw/mlx5/srq.c | 2 +-
3 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index 4d33965369cc..24cb2f793210 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -543,7 +543,6 @@ struct mlx5_ib_srq {
struct mlx5_ib_xrcd {
struct ib_xrcd ibxrcd;
u32 xrcdn;
- u16 uid;
};
enum mlx5_ib_mtt_access_flags {
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 52ffc6af3c20..369db954edbe 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -775,6 +775,7 @@ static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
__be64 *pas;
void *qpc;
int err;
+ u16 uid;
err = ib_copy_from_udata(&ucmd, udata, sizeof(ucmd));
if (err) {
@@ -836,7 +837,8 @@ static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
goto err_umem;
}
- MLX5_SET(create_qp_in, *in, uid, to_mpd(pd)->uid);
+ uid = (attr->qp_type != IB_QPT_XRC_TGT) ? to_mpd(pd)->uid : 0;
+ MLX5_SET(create_qp_in, *in, uid, uid);
pas = (__be64 *)MLX5_ADDR_OF(create_qp_in, *in, pas);
if (ubuffer->umem)
mlx5_ib_populate_pas(dev, ubuffer->umem, page_shift, pas, 0);
@@ -5513,7 +5515,6 @@ struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev,
struct mlx5_ib_dev *dev = to_mdev(ibdev);
struct mlx5_ib_xrcd *xrcd;
int err;
- u16 uid;
if (!MLX5_CAP_GEN(dev->mdev, xrc))
return ERR_PTR(-ENOSYS);
@@ -5522,14 +5523,12 @@ struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev,
if (!xrcd)
return ERR_PTR(-ENOMEM);
- uid = context ? to_mucontext(context)->devx_uid : 0;
- err = mlx5_cmd_xrcd_alloc(dev->mdev, &xrcd->xrcdn, uid);
+ err = mlx5_cmd_xrcd_alloc(dev->mdev, &xrcd->xrcdn, 0);
if (err) {
kfree(xrcd);
return ERR_PTR(-ENOMEM);
}
- xrcd->uid = uid;
return &xrcd->ibxrcd;
}
@@ -5537,10 +5536,9 @@ int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd)
{
struct mlx5_ib_dev *dev = to_mdev(xrcd->device);
u32 xrcdn = to_mxrcd(xrcd)->xrcdn;
- u16 uid = to_mxrcd(xrcd)->uid;
int err;
- err = mlx5_cmd_xrcd_dealloc(dev->mdev, xrcdn, uid);
+ err = mlx5_cmd_xrcd_dealloc(dev->mdev, xrcdn, 0);
if (err)
mlx5_ib_warn(dev, "failed to dealloc xrcdn 0x%x\n", xrcdn);
diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
index b3aef0eb39cb..0413b10dea71 100644
--- a/drivers/infiniband/hw/mlx5/srq.c
+++ b/drivers/infiniband/hw/mlx5/srq.c
@@ -113,7 +113,7 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
in->log_page_size = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
in->page_offset = offset;
- in->uid = to_mpd(pd)->uid;
+ in->uid = (in->type != IB_SRQT_XRC) ? to_mpd(pd)->uid : 0;
if (MLX5_CAP_GEN(dev->mdev, cqe_version) == MLX5_CQE_VERSION_V1 &&
in->type != IB_SRQT_BASIC)
in->user_index = uidx;
--
2.19.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH rdma-next 0/7] Enrich DEVX support
2018-11-26 6:28 [PATCH rdma-next 0/7] Enrich DEVX support Leon Romanovsky
` (6 preceding siblings ...)
2018-11-26 6:28 ` [PATCH rdma-next 7/7] IB/mlx5: Allow XRC usage via verbs in DEVX context Leon Romanovsky
@ 2018-12-04 19:02 ` Doug Ledford
2018-12-04 19:15 ` Jason Gunthorpe
7 siblings, 1 reply; 14+ messages in thread
From: Doug Ledford @ 2018-12-04 19:02 UTC (permalink / raw)
To: Leon Romanovsky, Jason Gunthorpe
Cc: Leon Romanovsky, RDMA mailing list, Artemy Kovalyov, Yishai Hadas,
Saeed Mahameed, linux-netdev
[-- Attachment #1: Type: text/plain, Size: 3367 bytes --]
On Mon, 2018-11-26 at 08:28 +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@mellanox.com>
>
> 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 (7):
> net/mlx5: Update mlx5_ifc with DEVX UCTX capabilities bits
> IB/core: Introduce UVERBS_IDR_ANY_OBJECT
> IB/core: Enable getting an object type from a given uobject
> IB/mlx5: Enable modify and query verbs objects via DEVX
> IB/mlx5: Enforce DEVX privilege by firmware
> IB/mlx5: Update the supported DEVX commands
> IB/mlx5: Allow XRC usage via verbs in DEVX context
>
> drivers/infiniband/core/rdma_core.c | 27 +++--
> drivers/infiniband/core/rdma_core.h | 21 ++--
> drivers/infiniband/core/uverbs_uapi.c | 10 +-
> drivers/infiniband/hw/mlx5/devx.c | 142 ++++++++++++++++++++++----
> drivers/infiniband/hw/mlx5/main.c | 4 +-
> drivers/infiniband/hw/mlx5/mlx5_ib.h | 6 +-
> drivers/infiniband/hw/mlx5/qp.c | 12 +--
> drivers/infiniband/hw/mlx5/srq.c | 2 +-
> include/linux/mlx5/mlx5_ifc.h | 26 ++++-
> include/rdma/uverbs_ioctl.h | 6 ++
> include/rdma/uverbs_std_types.h | 12 +++
> 11 files changed, 215 insertions(+), 53 deletions(-)
>
> --
> 2.19.1
>
Hi Leon,
I've put this into my wip/dl-for-next branch. Because it pulled in the
mlx5-next tree (which was significant because the patch we wanted was at
the tip and a whole slew of other patches were before it), the changeset
for this patch looks much bigger. And it had the merge conflict you
mentioned. You might want to double check my work before it gets moved
over to the official for-next branch.
--
Doug Ledford <dledford@redhat.com>
GPG KeyID: B826A3330E572FDD
Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH rdma-next 0/7] Enrich DEVX support
2018-12-04 19:02 ` [PATCH rdma-next 0/7] Enrich DEVX support Doug Ledford
@ 2018-12-04 19:15 ` Jason Gunthorpe
2018-12-04 19:45 ` Doug Ledford
0 siblings, 1 reply; 14+ messages in thread
From: Jason Gunthorpe @ 2018-12-04 19:15 UTC (permalink / raw)
To: Doug Ledford
Cc: Leon Romanovsky, Jason Gunthorpe, Leon Romanovsky, linux-rdma,
Artemy Kovalyov, Yishai Hadas, Saeed Mahameed, netdev
On Tue, Dec 4, 2018 at 12:02 PM Doug Ledford <dledford@redhat.com> wrote:
>
> On Mon, 2018-11-26 at 08:28 +0200, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@mellanox.com>
> >
> > 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 (7):
> > net/mlx5: Update mlx5_ifc with DEVX UCTX capabilities bits
> > IB/core: Introduce UVERBS_IDR_ANY_OBJECT
> > IB/core: Enable getting an object type from a given uobject
> > IB/mlx5: Enable modify and query verbs objects via DEVX
> > IB/mlx5: Enforce DEVX privilege by firmware
> > IB/mlx5: Update the supported DEVX commands
> > IB/mlx5: Allow XRC usage via verbs in DEVX context
> >
> > drivers/infiniband/core/rdma_core.c | 27 +++--
> > drivers/infiniband/core/rdma_core.h | 21 ++--
> > drivers/infiniband/core/uverbs_uapi.c | 10 +-
> > drivers/infiniband/hw/mlx5/devx.c | 142 ++++++++++++++++++++++----
> > drivers/infiniband/hw/mlx5/main.c | 4 +-
> > drivers/infiniband/hw/mlx5/mlx5_ib.h | 6 +-
> > drivers/infiniband/hw/mlx5/qp.c | 12 +--
> > drivers/infiniband/hw/mlx5/srq.c | 2 +-
> > include/linux/mlx5/mlx5_ifc.h | 26 ++++-
> > include/rdma/uverbs_ioctl.h | 6 ++
> > include/rdma/uverbs_std_types.h | 12 +++
> > 11 files changed, 215 insertions(+), 53 deletions(-)
> >
> > --
> > 2.19.1
> >
>
> Hi Leon,
>
> I've put this into my wip/dl-for-next branch. Because it pulled in the
> mlx5-next tree (which was significant because the patch we wanted was at
> the tip and a whole slew of other patches were before it),
Yes, this is how the shared branch works, DaveM merges it, we don't
have to unless we have a dependency, so it can accumulate a bit.
> the changeset
> for this patch looks much bigger. And it had the merge conflict you
> mentioned. You might want to double check my work before it gets moved
> over to the official for-next branch.
It is a bit easier to follow the git log if merges are done with the
--log option to summarize what was pulled in.
Jason
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH rdma-next 0/7] Enrich DEVX support
2018-12-04 19:15 ` Jason Gunthorpe
@ 2018-12-04 19:45 ` Doug Ledford
2018-12-04 20:34 ` Leon Romanovsky
0 siblings, 1 reply; 14+ messages in thread
From: Doug Ledford @ 2018-12-04 19:45 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Leon Romanovsky, Jason Gunthorpe, Leon Romanovsky, linux-rdma,
Artemy Kovalyov, Yishai Hadas, Saeed Mahameed, netdev
[-- Attachment #1: Type: text/plain, Size: 4287 bytes --]
On Tue, 2018-12-04 at 12:15 -0700, Jason Gunthorpe wrote:
> On Tue, Dec 4, 2018 at 12:02 PM Doug Ledford <dledford@redhat.com> wrote:
> > On Mon, 2018-11-26 at 08:28 +0200, Leon Romanovsky wrote:
> > > From: Leon Romanovsky <leonro@mellanox.com>
> > >
> > > 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 (7):
> > > net/mlx5: Update mlx5_ifc with DEVX UCTX capabilities bits
> > > IB/core: Introduce UVERBS_IDR_ANY_OBJECT
> > > IB/core: Enable getting an object type from a given uobject
> > > IB/mlx5: Enable modify and query verbs objects via DEVX
> > > IB/mlx5: Enforce DEVX privilege by firmware
> > > IB/mlx5: Update the supported DEVX commands
> > > IB/mlx5: Allow XRC usage via verbs in DEVX context
> > >
> > > drivers/infiniband/core/rdma_core.c | 27 +++--
> > > drivers/infiniband/core/rdma_core.h | 21 ++--
> > > drivers/infiniband/core/uverbs_uapi.c | 10 +-
> > > drivers/infiniband/hw/mlx5/devx.c | 142 ++++++++++++++++++++++----
> > > drivers/infiniband/hw/mlx5/main.c | 4 +-
> > > drivers/infiniband/hw/mlx5/mlx5_ib.h | 6 +-
> > > drivers/infiniband/hw/mlx5/qp.c | 12 +--
> > > drivers/infiniband/hw/mlx5/srq.c | 2 +-
> > > include/linux/mlx5/mlx5_ifc.h | 26 ++++-
> > > include/rdma/uverbs_ioctl.h | 6 ++
> > > include/rdma/uverbs_std_types.h | 12 +++
> > > 11 files changed, 215 insertions(+), 53 deletions(-)
> > >
> > > --
> > > 2.19.1
> > >
> >
> > Hi Leon,
> >
> > I've put this into my wip/dl-for-next branch. Because it pulled in the
> > mlx5-next tree (which was significant because the patch we wanted was at
> > the tip and a whole slew of other patches were before it),
>
> Yes, this is how the shared branch works, DaveM merges it, we don't
> have to unless we have a dependency, so it can accumulate a bit.
I get how it works :-P. I was just commenting that it had in fact built
up an accumulation.
> > the changeset
> > for this patch looks much bigger. And it had the merge conflict you
> > mentioned. You might want to double check my work before it gets moved
> > over to the official for-next branch.
>
> It is a bit easier to follow the git log if merges are done with the
> --log option to summarize what was pulled in.
I'll modify my merge alias to add it. As it stands, I'll repush this to
my wip branch with the --log option added.
--
Doug Ledford <dledford@redhat.com>
GPG KeyID: B826A3330E572FDD
Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH rdma-next 0/7] Enrich DEVX support
2018-12-04 19:45 ` Doug Ledford
@ 2018-12-04 20:34 ` Leon Romanovsky
0 siblings, 0 replies; 14+ messages in thread
From: Leon Romanovsky @ 2018-12-04 20:34 UTC (permalink / raw)
To: Doug Ledford
Cc: Jason Gunthorpe, Jason Gunthorpe, linux-rdma, Artemy Kovalyov,
Yishai Hadas, Saeed Mahameed, netdev
[-- Attachment #1: Type: text/plain, Size: 4558 bytes --]
On Tue, Dec 04, 2018 at 02:45:56PM -0500, Doug Ledford wrote:
> On Tue, 2018-12-04 at 12:15 -0700, Jason Gunthorpe wrote:
> > On Tue, Dec 4, 2018 at 12:02 PM Doug Ledford <dledford@redhat.com> wrote:
> > > On Mon, 2018-11-26 at 08:28 +0200, Leon Romanovsky wrote:
> > > > From: Leon Romanovsky <leonro@mellanox.com>
> > > >
> > > > 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 (7):
> > > > net/mlx5: Update mlx5_ifc with DEVX UCTX capabilities bits
> > > > IB/core: Introduce UVERBS_IDR_ANY_OBJECT
> > > > IB/core: Enable getting an object type from a given uobject
> > > > IB/mlx5: Enable modify and query verbs objects via DEVX
> > > > IB/mlx5: Enforce DEVX privilege by firmware
> > > > IB/mlx5: Update the supported DEVX commands
> > > > IB/mlx5: Allow XRC usage via verbs in DEVX context
> > > >
> > > > drivers/infiniband/core/rdma_core.c | 27 +++--
> > > > drivers/infiniband/core/rdma_core.h | 21 ++--
> > > > drivers/infiniband/core/uverbs_uapi.c | 10 +-
> > > > drivers/infiniband/hw/mlx5/devx.c | 142 ++++++++++++++++++++++----
> > > > drivers/infiniband/hw/mlx5/main.c | 4 +-
> > > > drivers/infiniband/hw/mlx5/mlx5_ib.h | 6 +-
> > > > drivers/infiniband/hw/mlx5/qp.c | 12 +--
> > > > drivers/infiniband/hw/mlx5/srq.c | 2 +-
> > > > include/linux/mlx5/mlx5_ifc.h | 26 ++++-
> > > > include/rdma/uverbs_ioctl.h | 6 ++
> > > > include/rdma/uverbs_std_types.h | 12 +++
> > > > 11 files changed, 215 insertions(+), 53 deletions(-)
> > > >
> > > > --
> > > > 2.19.1
> > > >
> > >
> > > Hi Leon,
> > >
> > > I've put this into my wip/dl-for-next branch. Because it pulled in the
> > > mlx5-next tree (which was significant because the patch we wanted was at
> > > the tip and a whole slew of other patches were before it),
> >
> > Yes, this is how the shared branch works, DaveM merges it, we don't
> > have to unless we have a dependency, so it can accumulate a bit.
>
> I get how it works :-P. I was just commenting that it had in fact built
> up an accumulation.
>
> > > the changeset
> > > for this patch looks much bigger. And it had the merge conflict you
> > > mentioned. You might want to double check my work before it gets moved
> > > over to the official for-next branch.
> >
> > It is a bit easier to follow the git log if merges are done with the
> > --log option to summarize what was pulled in.
>
> I'll modify my merge alias to add it. As it stands, I'll repush this to
> my wip branch with the --log option added.
Thanks, I looked on the merge commit 33cb7e760de ("Merge 'mlx5-next'
into mlx5-devx") and it looks exactly as I have.
Thanks again.
>
> --
> Doug Ledford <dledford@redhat.com>
> GPG KeyID: B826A3330E572FDD
> Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread