Commit e79c9c60 authored by Jason Gunthorpe's avatar Jason Gunthorpe

IB/mlx5: Remove references to uboject->context

These should all go through udata now. Add mlx5_udata_to_mdev to convert
a udata into the struct mlx5_ib_dev as these call sites require.
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 9e886b39
...@@ -373,8 +373,10 @@ static u64 devx_get_obj_id(const void *in) ...@@ -373,8 +373,10 @@ static u64 devx_get_obj_id(const void *in)
return obj_id; return obj_id;
} }
static bool devx_is_valid_obj_id(struct ib_uobject *uobj, const void *in) static bool devx_is_valid_obj_id(struct uverbs_attr_bundle *attrs,
struct ib_uobject *uobj, const void *in)
{ {
struct mlx5_ib_dev *dev = mlx5_udata_to_mdev(&attrs->driver_udata);
u64 obj_id = devx_get_obj_id(in); u64 obj_id = devx_get_obj_id(in);
if (!obj_id) if (!obj_id)
...@@ -389,7 +391,6 @@ static bool devx_is_valid_obj_id(struct ib_uobject *uobj, const void *in) ...@@ -389,7 +391,6 @@ static bool devx_is_valid_obj_id(struct ib_uobject *uobj, const void *in)
case UVERBS_OBJECT_SRQ: case UVERBS_OBJECT_SRQ:
{ {
struct mlx5_core_srq *srq = &(to_msrq(uobj->object)->msrq); struct mlx5_core_srq *srq = &(to_msrq(uobj->object)->msrq);
struct mlx5_ib_dev *dev = to_mdev(uobj->context->device);
u16 opcode; u16 opcode;
switch (srq->common.res) { switch (srq->common.res) {
...@@ -1136,7 +1137,8 @@ static int devx_obj_cleanup(struct ib_uobject *uobject, ...@@ -1136,7 +1137,8 @@ static int devx_obj_cleanup(struct ib_uobject *uobject,
return ret; return ret;
if (obj->flags & DEVX_OBJ_FLAGS_INDIRECT_MKEY) { if (obj->flags & DEVX_OBJ_FLAGS_INDIRECT_MKEY) {
struct mlx5_ib_dev *dev = to_mdev(uobject->context->device); struct mlx5_ib_dev *dev =
mlx5_udata_to_mdev(&attrs->driver_udata);
call_srcu(&dev->mr_srcu, &obj->devx_mr.rcu, call_srcu(&dev->mr_srcu, &obj->devx_mr.rcu,
devx_free_indirect_mkey); devx_free_indirect_mkey);
...@@ -1261,7 +1263,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_MODIFY)( ...@@ -1261,7 +1263,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_MODIFY)(
if (!devx_is_obj_modify_cmd(cmd_in)) if (!devx_is_obj_modify_cmd(cmd_in))
return -EINVAL; return -EINVAL;
if (!devx_is_valid_obj_id(uobj, cmd_in)) if (!devx_is_valid_obj_id(attrs, uobj, cmd_in))
return -EINVAL; return -EINVAL;
cmd_out = uverbs_zalloc(attrs, cmd_out_len); cmd_out = uverbs_zalloc(attrs, cmd_out_len);
...@@ -1303,7 +1305,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_QUERY)( ...@@ -1303,7 +1305,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_QUERY)(
if (!devx_is_obj_query_cmd(cmd_in)) if (!devx_is_obj_query_cmd(cmd_in))
return -EINVAL; return -EINVAL;
if (!devx_is_valid_obj_id(uobj, cmd_in)) if (!devx_is_valid_obj_id(attrs, uobj, cmd_in))
return -EINVAL; return -EINVAL;
cmd_out = uverbs_zalloc(attrs, cmd_out_len); cmd_out = uverbs_zalloc(attrs, cmd_out_len);
...@@ -1351,7 +1353,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_ASYNC_CMD_FD_ALLOC)( ...@@ -1351,7 +1353,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_ASYNC_CMD_FD_ALLOC)(
struct ib_uobject *uobj = uverbs_attr_get_uobject( struct ib_uobject *uobj = uverbs_attr_get_uobject(
attrs, MLX5_IB_ATTR_DEVX_ASYNC_CMD_FD_ALLOC_HANDLE); attrs, MLX5_IB_ATTR_DEVX_ASYNC_CMD_FD_ALLOC_HANDLE);
struct mlx5_ib_dev *mdev = to_mdev(uobj->context->device); struct mlx5_ib_dev *mdev = mlx5_udata_to_mdev(&attrs->driver_udata);
ev_file = container_of(uobj, struct devx_async_cmd_event_file, ev_file = container_of(uobj, struct devx_async_cmd_event_file,
uobj); uobj);
...@@ -1413,7 +1415,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_ASYNC_QUERY)( ...@@ -1413,7 +1415,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_ASYNC_QUERY)(
if (err) if (err)
return err; return err;
if (!devx_is_valid_obj_id(uobj, cmd_in)) if (!devx_is_valid_obj_id(attrs, uobj, cmd_in))
return -EINVAL; return -EINVAL;
fd_uobj = uverbs_attr_get_uobject(attrs, fd_uobj = uverbs_attr_get_uobject(attrs,
......
...@@ -75,7 +75,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)( ...@@ -75,7 +75,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
struct ib_qp *qp = NULL; struct ib_qp *qp = NULL;
struct ib_uobject *uobj = struct ib_uobject *uobj =
uverbs_attr_get_uobject(attrs, MLX5_IB_ATTR_CREATE_FLOW_HANDLE); uverbs_attr_get_uobject(attrs, MLX5_IB_ATTR_CREATE_FLOW_HANDLE);
struct mlx5_ib_dev *dev = to_mdev(uobj->context->device); struct mlx5_ib_dev *dev = mlx5_udata_to_mdev(&attrs->driver_udata);
int len, ret, i; int len, ret, i;
u32 counter_id = 0; u32 counter_id = 0;
...@@ -208,7 +208,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_MATCHER_CREATE)( ...@@ -208,7 +208,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_MATCHER_CREATE)(
{ {
struct ib_uobject *uobj = uverbs_attr_get_uobject( struct ib_uobject *uobj = uverbs_attr_get_uobject(
attrs, MLX5_IB_ATTR_FLOW_MATCHER_CREATE_HANDLE); attrs, MLX5_IB_ATTR_FLOW_MATCHER_CREATE_HANDLE);
struct mlx5_ib_dev *dev = to_mdev(uobj->context->device); struct mlx5_ib_dev *dev = mlx5_udata_to_mdev(&attrs->driver_udata);
struct mlx5_ib_flow_matcher *obj; struct mlx5_ib_flow_matcher *obj;
u32 flags; u32 flags;
int err; int err;
...@@ -327,7 +327,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER)( ...@@ -327,7 +327,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER)(
{ {
struct ib_uobject *uobj = uverbs_attr_get_uobject( struct ib_uobject *uobj = uverbs_attr_get_uobject(
attrs, MLX5_IB_ATTR_CREATE_MODIFY_HEADER_HANDLE); attrs, MLX5_IB_ATTR_CREATE_MODIFY_HEADER_HANDLE);
struct mlx5_ib_dev *mdev = to_mdev(uobj->context->device); struct mlx5_ib_dev *mdev = mlx5_udata_to_mdev(&attrs->driver_udata);
enum mlx5_ib_uapi_flow_table_type ft_type; enum mlx5_ib_uapi_flow_table_type ft_type;
struct ib_flow_action *action; struct ib_flow_action *action;
int num_actions; int num_actions;
...@@ -354,7 +354,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER)( ...@@ -354,7 +354,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER)(
if (IS_ERR(action)) if (IS_ERR(action))
return PTR_ERR(action); return PTR_ERR(action);
uverbs_flow_action_fill_action(action, uobj, uobj->context->device, uverbs_flow_action_fill_action(action, uobj, &mdev->ib_dev,
IB_FLOW_ACTION_UNSPECIFIED); IB_FLOW_ACTION_UNSPECIFIED);
return 0; return 0;
...@@ -446,7 +446,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT)( ...@@ -446,7 +446,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT)(
{ {
struct ib_uobject *uobj = uverbs_attr_get_uobject(attrs, struct ib_uobject *uobj = uverbs_attr_get_uobject(attrs,
MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_HANDLE); MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_HANDLE);
struct mlx5_ib_dev *mdev = to_mdev(uobj->context->device); struct mlx5_ib_dev *mdev = mlx5_udata_to_mdev(&attrs->driver_udata);
enum mlx5_ib_uapi_flow_action_packet_reformat_type dv_prt; enum mlx5_ib_uapi_flow_action_packet_reformat_type dv_prt;
enum mlx5_ib_uapi_flow_table_type ft_type; enum mlx5_ib_uapi_flow_table_type ft_type;
struct mlx5_ib_flow_action *maction; struct mlx5_ib_flow_action *maction;
...@@ -494,8 +494,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT)( ...@@ -494,8 +494,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT)(
goto free_maction; goto free_maction;
} }
uverbs_flow_action_fill_action(&maction->ib_action, uobj, uverbs_flow_action_fill_action(&maction->ib_action, uobj, &mdev->ib_dev,
uobj->context->device,
IB_FLOW_ACTION_UNSPECIFIED); IB_FLOW_ACTION_UNSPECIFIED);
return 0; return 0;
......
...@@ -968,6 +968,14 @@ static inline struct mlx5_ib_dev *to_mdev(struct ib_device *ibdev) ...@@ -968,6 +968,14 @@ static inline struct mlx5_ib_dev *to_mdev(struct ib_device *ibdev)
return container_of(ibdev, struct mlx5_ib_dev, ib_dev); return container_of(ibdev, struct mlx5_ib_dev, ib_dev);
} }
static inline struct mlx5_ib_dev *mlx5_udata_to_mdev(struct ib_udata *udata)
{
struct mlx5_ib_ucontext *context = rdma_udata_to_drv_context(
udata, struct mlx5_ib_ucontext, ibucontext);
return to_mdev(context->ibucontext.device);
}
static inline struct mlx5_ib_cq *to_mcq(struct ib_cq *ibcq) static inline struct mlx5_ib_cq *to_mcq(struct ib_cq *ibcq)
{ {
return container_of(ibcq, struct mlx5_ib_cq, ibcq); return container_of(ibcq, struct mlx5_ib_cq, ibcq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment