Merge tag 'mlx5-updates-2020-05-15' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / drivers / net / ethernet / mellanox / mlx5 / core / debugfs.c
index 04854e5..6409090 100644 (file)
@@ -101,15 +101,15 @@ void mlx5_unregister_debugfs(void)
 
 void mlx5_qp_debugfs_init(struct mlx5_core_dev *dev)
 {
-       atomic_set(&dev->num_qps, 0);
-
        dev->priv.qp_debugfs = debugfs_create_dir("QPs",  dev->priv.dbg_root);
 }
+EXPORT_SYMBOL(mlx5_qp_debugfs_init);
 
 void mlx5_qp_debugfs_cleanup(struct mlx5_core_dev *dev)
 {
        debugfs_remove_recursive(dev->priv.qp_debugfs);
 }
+EXPORT_SYMBOL(mlx5_qp_debugfs_cleanup);
 
 void mlx5_eq_debugfs_init(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,
                         int index, int *is_str)
 {
-       int outlen = MLX5_ST_SZ_BYTES(query_qp_out);
-       struct mlx5_qp_context *ctx;
+       u32 out[MLX5_ST_SZ_BYTES(query_qp_out)] = {};
+       u32 in[MLX5_ST_SZ_DW(query_qp_in)] = {};
        u64 param = 0;
-       u32 *out;
+       int state;
+       u32 *qpc;
        int err;
-       int no_sq;
 
-       out = kzalloc(outlen, GFP_KERNEL);
-       if (!out)
-               return param;
-
-       err = mlx5_core_qp_query(dev, qp, out, outlen);
-       if (err) {
-               mlx5_core_warn(dev, "failed to query qp err=%d\n", err);
-               goto out;
-       }
+       MLX5_SET(query_qp_in, in, opcode, MLX5_CMD_OP_QUERY_QP);
+       MLX5_SET(query_qp_in, in, qpn, qp->qpn);
+       err = mlx5_cmd_exec_inout(dev, query_qp, in, out);
+       if (err)
+               return 0;
 
        *is_str = 0;
 
-       /* FIXME: use MLX5_GET rather than mlx5_qp_context manual struct */
-       ctx = (struct mlx5_qp_context *)MLX5_ADDR_OF(query_qp_out, out, qpc);
-
+       qpc = MLX5_ADDR_OF(query_qp_out, out, qpc);
        switch (index) {
        case QP_PID:
                param = qp->pid;
                break;
        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;
                break;
        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;
                break;
        case QP_MTU:
-               switch (ctx->mtu_msgmax >> 5) {
+               switch (MLX5_GET(qpc, qpc, mtu)) {
                case IB_MTU_256:
                        param = 256;
                        break;
@@ -258,46 +253,31 @@ static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp,
                }
                break;
        case QP_N_RECV:
-               param = 1 << ((ctx->rq_size_stride >> 3) & 0xf);
+               param = 1 << MLX5_GET(qpc, qpc, log_rq_size);
                break;
        case QP_RECV_SZ:
-               param = 1 << ((ctx->rq_size_stride & 7) + 4);
+               param = 1 << (MLX5_GET(qpc, qpc, log_rq_stride) + 4);
                break;
        case QP_N_SEND:
-               no_sq = be16_to_cpu(ctx->sq_crq_size) >> 15;
-               if (!no_sq)
-                       param = 1 << (be16_to_cpu(ctx->sq_crq_size) >> 11);
-               else
-                       param = 0;
+               if (!MLX5_GET(qpc, qpc, no_sq))
+                       param = 1 << MLX5_GET(qpc, qpc, log_sq_size);
                break;
        case QP_LOG_PG_SZ:
-               param = (be32_to_cpu(ctx->log_pg_sz_remote_qpn) >> 24) & 0x1f;
-               param += 12;
+               param = MLX5_GET(qpc, qpc, log_page_size) + 12;
                break;
        case QP_RQPN:
-               param = be32_to_cpu(ctx->log_pg_sz_remote_qpn) & 0xffffff;
+               param = MLX5_GET(qpc, qpc, remote_qpn);
                break;
        }
 
-out:
-       kfree(out);
        return param;
 }
 
-static int mlx5_core_eq_query(struct mlx5_core_dev *dev, struct mlx5_eq *eq,
-                             u32 *out, int outlen)
-{
-       u32 in[MLX5_ST_SZ_DW(query_eq_in)] = {};
-
-       MLX5_SET(query_eq_in, in, opcode, MLX5_CMD_OP_QUERY_EQ);
-       MLX5_SET(query_eq_in, in, eq_number, eq->eqn);
-       return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen);
-}
-
 static u64 eq_read_field(struct mlx5_core_dev *dev, struct mlx5_eq *eq,
                         int index)
 {
        int outlen = MLX5_ST_SZ_BYTES(query_eq_out);
+       u32 in[MLX5_ST_SZ_DW(query_eq_in)] = {};
        u64 param = 0;
        void *ctx;
        u32 *out;
@@ -307,7 +287,9 @@ static u64 eq_read_field(struct mlx5_core_dev *dev, struct mlx5_eq *eq,
        if (!out)
                return param;
 
-       err = mlx5_core_eq_query(dev, eq, out, outlen);
+       MLX5_SET(query_eq_in, in, opcode, MLX5_CMD_OP_QUERY_EQ);
+       MLX5_SET(query_eq_in, in, eq_number, eq->eqn);
+       err = mlx5_cmd_exec_inout(dev, query_eq, in, out);
        if (err) {
                mlx5_core_warn(dev, "failed to query eq\n");
                goto out;
@@ -344,7 +326,7 @@ static u64 cq_read_field(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
        if (!out)
                return param;
 
-       err = mlx5_core_query_cq(dev, cq, out, outlen);
+       err = mlx5_core_query_cq(dev, cq, out);
        if (err) {
                mlx5_core_warn(dev, "failed to query cq\n");
                goto out;
@@ -461,6 +443,7 @@ int mlx5_debug_qp_add(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp)
 
        return err;
 }
+EXPORT_SYMBOL(mlx5_debug_qp_add);
 
 void mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp)
 {
@@ -470,6 +453,7 @@ void mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp)
        if (qp->dbg)
                rem_res_tree(qp->dbg);
 }
+EXPORT_SYMBOL(mlx5_debug_qp_remove);
 
 int mlx5_debug_eq_add(struct mlx5_core_dev *dev, struct mlx5_eq *eq)
 {