Commit a1eb1802 authored by Leon Romanovsky's avatar Leon Romanovsky

RDMA/mlx5: Unfold create RMP function

There is no need to perform create_rmp in two separate function, while
one of them uses stack as a placeholder for data while other allocates
it dynamically. Combine those two functions to one instead of two.
Reviewed-by: default avatarMark Bloch <markb@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
parent f3da6577
...@@ -298,20 +298,6 @@ static int query_xrc_srq_cmd(struct mlx5_ib_dev *dev, ...@@ -298,20 +298,6 @@ static int query_xrc_srq_cmd(struct mlx5_ib_dev *dev,
return err; return err;
} }
static int mlx5_core_create_rmp(struct mlx5_ib_dev *dev, u32 *in, int inlen,
u32 *rmpn)
{
u32 out[MLX5_ST_SZ_DW(create_rmp_out)] = { 0 };
int err;
MLX5_SET(create_rmp_in, in, opcode, MLX5_CMD_OP_CREATE_RMP);
err = mlx5_cmd_exec(dev->mdev, in, inlen, out, sizeof(out));
if (!err)
*rmpn = MLX5_GET(create_rmp_out, out, rmpn);
return err;
}
static int mlx5_core_modify_rmp(struct mlx5_ib_dev *dev, u32 *in, int inlen) static int mlx5_core_modify_rmp(struct mlx5_ib_dev *dev, u32 *in, int inlen)
{ {
u32 out[MLX5_ST_SZ_DW(modify_rmp_out)] = {0}; u32 out[MLX5_ST_SZ_DW(modify_rmp_out)] = {0};
...@@ -333,18 +319,24 @@ static int mlx5_core_query_rmp(struct mlx5_ib_dev *dev, u32 rmpn, u32 *out) ...@@ -333,18 +319,24 @@ static int mlx5_core_query_rmp(struct mlx5_ib_dev *dev, u32 rmpn, u32 *out)
static int create_rmp_cmd(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq, static int create_rmp_cmd(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
struct mlx5_srq_attr *in) struct mlx5_srq_attr *in)
{ {
void *create_in; void *create_out = NULL;
void *create_in = NULL;
void *rmpc; void *rmpc;
void *wq; void *wq;
int pas_size; int pas_size;
int outlen;
int inlen; int inlen;
int err; int err;
pas_size = get_pas_size(in); pas_size = get_pas_size(in);
inlen = MLX5_ST_SZ_BYTES(create_rmp_in) + pas_size; inlen = MLX5_ST_SZ_BYTES(create_rmp_in) + pas_size;
outlen = MLX5_ST_SZ_BYTES(create_rmp_out);
create_in = kvzalloc(inlen, GFP_KERNEL); create_in = kvzalloc(inlen, GFP_KERNEL);
if (!create_in) create_out = kvzalloc(outlen, GFP_KERNEL);
return -ENOMEM; if (!create_in || !create_out) {
err = -ENOMEM;
goto out;
}
rmpc = MLX5_ADDR_OF(create_rmp_in, create_in, ctx); rmpc = MLX5_ADDR_OF(create_rmp_in, create_in, ctx);
wq = MLX5_ADDR_OF(rmpc, rmpc, wq); wq = MLX5_ADDR_OF(rmpc, rmpc, wq);
...@@ -354,11 +346,16 @@ static int create_rmp_cmd(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq, ...@@ -354,11 +346,16 @@ static int create_rmp_cmd(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
set_wq(wq, in); set_wq(wq, in);
memcpy(MLX5_ADDR_OF(rmpc, rmpc, wq.pas), in->pas, pas_size); memcpy(MLX5_ADDR_OF(rmpc, rmpc, wq.pas), in->pas, pas_size);
err = mlx5_core_create_rmp(dev, create_in, inlen, &srq->srqn); MLX5_SET(create_rmp_in, create_in, opcode, MLX5_CMD_OP_CREATE_RMP);
if (!err) err = mlx5_cmd_exec(dev->mdev, create_in, inlen, create_out, outlen);
if (!err) {
srq->srqn = MLX5_GET(create_rmp_out, create_out, rmpn);
srq->uid = in->uid; srq->uid = in->uid;
}
out:
kvfree(create_in); kvfree(create_in);
kvfree(create_out);
return err; return err;
} }
......
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