Commit 57a6c5e9 authored by Leon Romanovsky's avatar Leon Romanovsky

net/mlx5: Replace hand written QP context struct with automatic getters

By changing debugfs to not use any QP related API, convert the debugfs
code to use MLX5_GET() directly to access QP context instead of hand
written struct.
Reviewed-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
parent f93f4f4f
...@@ -202,42 +202,37 @@ void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev) ...@@ -202,42 +202,37 @@ void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev)
static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp, static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp,
int index, int *is_str) int index, int *is_str)
{ {
int outlen = MLX5_ST_SZ_BYTES(query_qp_out); u32 out[MLX5_ST_SZ_BYTES(query_qp_out)] = {};
struct mlx5_qp_context *ctx; u32 in[MLX5_ST_SZ_DW(query_qp_in)] = {};
u64 param = 0; u64 param = 0;
u32 *out; int state;
u32 *qpc;
int err; int err;
int no_sq;
out = kzalloc(outlen, GFP_KERNEL);
if (!out)
return param;
err = mlx5_core_qp_query(dev, qp, out, outlen); MLX5_SET(query_qp_in, in, opcode, MLX5_CMD_OP_QUERY_QP);
if (err) { MLX5_SET(query_qp_in, in, qpn, qp->qpn);
mlx5_core_warn(dev, "failed to query qp err=%d\n", err); err = mlx5_cmd_exec_inout(dev, query_qp, in, out);
goto out; if (err)
} return 0;
*is_str = 0; *is_str = 0;
/* FIXME: use MLX5_GET rather than mlx5_qp_context manual struct */ qpc = MLX5_ADDR_OF(query_qp_out, out, qpc);
ctx = (struct mlx5_qp_context *)MLX5_ADDR_OF(query_qp_out, out, qpc);
switch (index) { switch (index) {
case QP_PID: case QP_PID:
param = qp->pid; param = qp->pid;
break; break;
case QP_STATE: case QP_STATE:
param = (unsigned long)mlx5_qp_state_str(be32_to_cpu(ctx->flags) >> 28); state = MLX5_GET(qpc, qpc, state);
param = (unsigned long)mlx5_qp_state_str(state);
*is_str = 1; *is_str = 1;
break; break;
case QP_XPORT: case QP_XPORT:
param = (unsigned long)mlx5_qp_type_str((be32_to_cpu(ctx->flags) >> 16) & 0xff); param = (unsigned long)mlx5_qp_type_str(MLX5_GET(qpc, qpc, st));
*is_str = 1; *is_str = 1;
break; break;
case QP_MTU: case QP_MTU:
switch (ctx->mtu_msgmax >> 5) { switch (MLX5_GET(qpc, qpc, mtu)) {
case IB_MTU_256: case IB_MTU_256:
param = 256; param = 256;
break; break;
...@@ -258,29 +253,23 @@ static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp, ...@@ -258,29 +253,23 @@ static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp,
} }
break; break;
case QP_N_RECV: case QP_N_RECV:
param = 1 << ((ctx->rq_size_stride >> 3) & 0xf); param = 1 << MLX5_GET(qpc, qpc, log_rq_size);
break; break;
case QP_RECV_SZ: case QP_RECV_SZ:
param = 1 << ((ctx->rq_size_stride & 7) + 4); param = 1 << (MLX5_GET(qpc, qpc, log_rq_stride) + 4);
break; break;
case QP_N_SEND: case QP_N_SEND:
no_sq = be16_to_cpu(ctx->sq_crq_size) >> 15; if (!MLX5_GET(qpc, qpc, no_sq))
if (!no_sq) param = 1 << MLX5_GET(qpc, qpc, log_sq_size);
param = 1 << (be16_to_cpu(ctx->sq_crq_size) >> 11);
else
param = 0;
break; break;
case QP_LOG_PG_SZ: case QP_LOG_PG_SZ:
param = (be32_to_cpu(ctx->log_pg_sz_remote_qpn) >> 24) & 0x1f; param = MLX5_GET(qpc, qpc, log_page_size) + 12;
param += 12;
break; break;
case QP_RQPN: case QP_RQPN:
param = be32_to_cpu(ctx->log_pg_sz_remote_qpn) & 0xffffff; param = MLX5_GET(qpc, qpc, remote_qpn);
break; break;
} }
out:
kfree(out);
return param; return param;
} }
......
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