diff options
| author | Eli Cohen <eli@dev.mellanox.co.il> | 2014-01-14 10:45:19 -0500 |
|---|---|---|
| committer | Roland Dreier <roland@purestorage.com> | 2014-01-23 02:23:50 -0500 |
| commit | db81a5c374b5bd650c5e6ae85d026709751db103 (patch) | |
| tree | 5567376f685a054973bc83b9b3a4d9309f8c41e2 | |
| parent | bde51583f49bd87e452e9504d489926638046b11 (diff) | |
mlx5_core: Improve debugfs readability
Use strings to display transport service or state of QPs. Use numeric
value for MTU of a QP.
Signed-off-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/debugfs.c | 39 | ||||
| -rw-r--r-- | include/linux/mlx5/qp.h | 45 |
2 files changed, 78 insertions, 6 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c index 80f6d127257a..10e1f1a18255 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c | |||
| @@ -275,7 +275,7 @@ void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev) | |||
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp, | 277 | static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp, |
| 278 | int index) | 278 | int index, int *is_str) |
| 279 | { | 279 | { |
| 280 | struct mlx5_query_qp_mbox_out *out; | 280 | struct mlx5_query_qp_mbox_out *out; |
| 281 | struct mlx5_qp_context *ctx; | 281 | struct mlx5_qp_context *ctx; |
| @@ -293,19 +293,40 @@ static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp, | |||
| 293 | goto out; | 293 | goto out; |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | *is_str = 0; | ||
| 296 | ctx = &out->ctx; | 297 | ctx = &out->ctx; |
| 297 | switch (index) { | 298 | switch (index) { |
| 298 | case QP_PID: | 299 | case QP_PID: |
| 299 | param = qp->pid; | 300 | param = qp->pid; |
| 300 | break; | 301 | break; |
| 301 | case QP_STATE: | 302 | case QP_STATE: |
| 302 | param = be32_to_cpu(ctx->flags) >> 28; | 303 | param = (u64)mlx5_qp_state_str(be32_to_cpu(ctx->flags) >> 28); |
| 304 | *is_str = 1; | ||
| 303 | break; | 305 | break; |
| 304 | case QP_XPORT: | 306 | case QP_XPORT: |
| 305 | param = (be32_to_cpu(ctx->flags) >> 16) & 0xff; | 307 | param = (u64)mlx5_qp_type_str((be32_to_cpu(ctx->flags) >> 16) & 0xff); |
| 308 | *is_str = 1; | ||
| 306 | break; | 309 | break; |
| 307 | case QP_MTU: | 310 | case QP_MTU: |
| 308 | param = ctx->mtu_msgmax >> 5; | 311 | switch (ctx->mtu_msgmax >> 5) { |
| 312 | case IB_MTU_256: | ||
| 313 | param = 256; | ||
| 314 | break; | ||
| 315 | case IB_MTU_512: | ||
| 316 | param = 512; | ||
| 317 | break; | ||
| 318 | case IB_MTU_1024: | ||
| 319 | param = 1024; | ||
| 320 | break; | ||
| 321 | case IB_MTU_2048: | ||
| 322 | param = 2048; | ||
| 323 | break; | ||
| 324 | case IB_MTU_4096: | ||
| 325 | param = 4096; | ||
| 326 | break; | ||
| 327 | default: | ||
| 328 | param = 0; | ||
| 329 | } | ||
| 309 | break; | 330 | break; |
| 310 | case QP_N_RECV: | 331 | case QP_N_RECV: |
| 311 | param = 1 << ((ctx->rq_size_stride >> 3) & 0xf); | 332 | param = 1 << ((ctx->rq_size_stride >> 3) & 0xf); |
| @@ -414,6 +435,7 @@ static ssize_t dbg_read(struct file *filp, char __user *buf, size_t count, | |||
| 414 | struct mlx5_field_desc *desc; | 435 | struct mlx5_field_desc *desc; |
| 415 | struct mlx5_rsc_debug *d; | 436 | struct mlx5_rsc_debug *d; |
| 416 | char tbuf[18]; | 437 | char tbuf[18]; |
| 438 | int is_str = 0; | ||
| 417 | u64 field; | 439 | u64 field; |
| 418 | int ret; | 440 | int ret; |
| 419 | 441 | ||
| @@ -424,7 +446,7 @@ static ssize_t dbg_read(struct file *filp, char __user *buf, size_t count, | |||
| 424 | d = (void *)(desc - desc->i) - sizeof(*d); | 446 | d = (void *)(desc - desc->i) - sizeof(*d); |
| 425 | switch (d->type) { | 447 | switch (d->type) { |
| 426 | case MLX5_DBG_RSC_QP: | 448 | case MLX5_DBG_RSC_QP: |
| 427 | field = qp_read_field(d->dev, d->object, desc->i); | 449 | field = qp_read_field(d->dev, d->object, desc->i, &is_str); |
| 428 | break; | 450 | break; |
| 429 | 451 | ||
| 430 | case MLX5_DBG_RSC_EQ: | 452 | case MLX5_DBG_RSC_EQ: |
| @@ -440,7 +462,12 @@ static ssize_t dbg_read(struct file *filp, char __user *buf, size_t count, | |||
| 440 | return -EINVAL; | 462 | return -EINVAL; |
| 441 | } | 463 | } |
| 442 | 464 | ||
| 443 | ret = snprintf(tbuf, sizeof(tbuf), "0x%llx\n", field); | 465 | |
| 466 | if (is_str) | ||
| 467 | ret = snprintf(tbuf, sizeof(tbuf), "%s\n", (const char *)field); | ||
| 468 | else | ||
| 469 | ret = snprintf(tbuf, sizeof(tbuf), "0x%llx\n", field); | ||
| 470 | |||
| 444 | if (ret > 0) { | 471 | if (ret > 0) { |
| 445 | if (copy_to_user(buf, tbuf, ret)) | 472 | if (copy_to_user(buf, tbuf, ret)) |
| 446 | return -EFAULT; | 473 | return -EFAULT; |
diff --git a/include/linux/mlx5/qp.h b/include/linux/mlx5/qp.h index d9e3eacb3a7f..d51eff713549 100644 --- a/include/linux/mlx5/qp.h +++ b/include/linux/mlx5/qp.h | |||
| @@ -464,4 +464,49 @@ void mlx5_cleanup_qp_table(struct mlx5_core_dev *dev); | |||
| 464 | int mlx5_debug_qp_add(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp); | 464 | int mlx5_debug_qp_add(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp); |
| 465 | void mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp); | 465 | void mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp); |
| 466 | 466 | ||
| 467 | static inline const char *mlx5_qp_type_str(int type) | ||
| 468 | { | ||
| 469 | switch (type) { | ||
| 470 | case MLX5_QP_ST_RC: return "RC"; | ||
| 471 | case MLX5_QP_ST_UC: return "C"; | ||
| 472 | case MLX5_QP_ST_UD: return "UD"; | ||
| 473 | case MLX5_QP_ST_XRC: return "XRC"; | ||
| 474 | case MLX5_QP_ST_MLX: return "MLX"; | ||
| 475 | case MLX5_QP_ST_QP0: return "QP0"; | ||
| 476 | case MLX5_QP_ST_QP1: return "QP1"; | ||
| 477 | case MLX5_QP_ST_RAW_ETHERTYPE: return "RAW_ETHERTYPE"; | ||
| 478 | case MLX5_QP_ST_RAW_IPV6: return "RAW_IPV6"; | ||
| 479 | case MLX5_QP_ST_SNIFFER: return "SNIFFER"; | ||
| 480 | case MLX5_QP_ST_SYNC_UMR: return "SYNC_UMR"; | ||
| 481 | case MLX5_QP_ST_PTP_1588: return "PTP_1588"; | ||
| 482 | case MLX5_QP_ST_REG_UMR: return "REG_UMR"; | ||
| 483 | default: return "Invalid transport type"; | ||
| 484 | } | ||
| 485 | } | ||
| 486 | |||
| 487 | static inline const char *mlx5_qp_state_str(int state) | ||
| 488 | { | ||
| 489 | switch (state) { | ||
| 490 | case MLX5_QP_STATE_RST: | ||
| 491 | return "RST"; | ||
| 492 | case MLX5_QP_STATE_INIT: | ||
| 493 | return "INIT"; | ||
| 494 | case MLX5_QP_STATE_RTR: | ||
| 495 | return "RTR"; | ||
| 496 | case MLX5_QP_STATE_RTS: | ||
| 497 | return "RTS"; | ||
| 498 | case MLX5_QP_STATE_SQER: | ||
| 499 | return "SQER"; | ||
| 500 | case MLX5_QP_STATE_SQD: | ||
| 501 | return "SQD"; | ||
| 502 | case MLX5_QP_STATE_ERR: | ||
| 503 | return "ERR"; | ||
| 504 | case MLX5_QP_STATE_SQ_DRAINING: | ||
| 505 | return "SQ_DRAINING"; | ||
| 506 | case MLX5_QP_STATE_SUSPENDED: | ||
| 507 | return "SUSPENDED"; | ||
| 508 | default: return "Invalid QP state"; | ||
| 509 | } | ||
| 510 | } | ||
| 511 | |||
| 467 | #endif /* MLX5_QP_H */ | 512 | #endif /* MLX5_QP_H */ |
