[PATCH v8 11/12] SIW debugging

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Bernard Metzler <bmt@xxxxxxxxxxxxxxxxxxx>

Signed-off-by: Bernard Metzler <bmt@xxxxxxxxxxxxxx>
---
 drivers/infiniband/sw/siw/siw_debug.c | 91 +++++++++++++++++++++++++++
 drivers/infiniband/sw/siw/siw_debug.h | 40 ++++++++++++
 2 files changed, 131 insertions(+)
 create mode 100644 drivers/infiniband/sw/siw/siw_debug.c
 create mode 100644 drivers/infiniband/sw/siw/siw_debug.h

diff --git a/drivers/infiniband/sw/siw/siw_debug.c b/drivers/infiniband/sw/siw/siw_debug.c
new file mode 100644
index 000000000000..86460d370333
--- /dev/null
+++ b/drivers/infiniband/sw/siw/siw_debug.c
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause
+
+/* Authors: Bernard Metzler <bmt@xxxxxxxxxxxxxx> */
+/* Copyright (c) 2008-2019, IBM Corporation */
+
+#include <linux/types.h>
+#include <linux/printk.h>
+
+#include "siw.h"
+
+#define ddp_data_len(op, mpa_len)                                              \
+	(mpa_len - (iwarp_pktinfo[op].hdr_len - MPA_HDR_SIZE))
+
+void siw_print_hdr(union iwarp_hdr *hdr, int qp_id, char *string)
+{
+	enum rdma_opcode op = __rdmap_get_opcode(&hdr->ctrl);
+	u16 mpa_len = be16_to_cpu(hdr->ctrl.mpa_len);
+
+	switch (op) {
+	case RDMAP_RDMA_WRITE:
+		pr_info("siw: [QP %u]: %s(WRITE, DDP len %d): %08x %016llx\n",
+			qp_id, string, ddp_data_len(op, mpa_len),
+			hdr->rwrite.sink_stag, hdr->rwrite.sink_to);
+		break;
+
+	case RDMAP_RDMA_READ_REQ:
+		pr_info("siw: [QP %u]: %s(RREQ, DDP len %d): %08x %08x %08x %08x %016llx %08x %08x %016llx\n",
+			qp_id, string, ddp_data_len(op, mpa_len),
+			be32_to_cpu(hdr->rreq.ddp_qn),
+			be32_to_cpu(hdr->rreq.ddp_msn),
+			be32_to_cpu(hdr->rreq.ddp_mo),
+			be32_to_cpu(hdr->rreq.sink_stag),
+			be64_to_cpu(hdr->rreq.sink_to),
+			be32_to_cpu(hdr->rreq.read_size),
+			be32_to_cpu(hdr->rreq.source_stag),
+			be64_to_cpu(hdr->rreq.source_to));
+
+		break;
+
+	case RDMAP_RDMA_READ_RESP:
+		pr_info("siw: [QP %u]: %s(RRESP, DDP len %d): %08x %016llx\n",
+			qp_id, string, ddp_data_len(op, mpa_len),
+			be32_to_cpu(hdr->rresp.sink_stag),
+			be64_to_cpu(hdr->rresp.sink_to));
+		break;
+
+	case RDMAP_SEND:
+		pr_info("siw: [QP %u]: %s(SEND, DDP len %d): %08x %08x %08x\n",
+			qp_id, string, ddp_data_len(op, mpa_len),
+			be32_to_cpu(hdr->send.ddp_qn),
+			be32_to_cpu(hdr->send.ddp_msn),
+			be32_to_cpu(hdr->send.ddp_mo));
+		break;
+
+	case RDMAP_SEND_INVAL:
+		pr_info("siw: [QP %u]: %s(S_INV, DDP len %d): %08x %08x %08x %08x\n",
+			qp_id, string, ddp_data_len(op, mpa_len),
+			be32_to_cpu(hdr->send_inv.inval_stag),
+			be32_to_cpu(hdr->send_inv.ddp_qn),
+			be32_to_cpu(hdr->send_inv.ddp_msn),
+			be32_to_cpu(hdr->send_inv.ddp_mo));
+		break;
+
+	case RDMAP_SEND_SE:
+		pr_info("siw: [QP %u]: %s(S_SE, DDP len %d): %08x %08x %08x\n",
+			qp_id, string, ddp_data_len(op, mpa_len),
+			be32_to_cpu(hdr->send.ddp_qn),
+			be32_to_cpu(hdr->send.ddp_msn),
+			be32_to_cpu(hdr->send.ddp_mo));
+		break;
+
+	case RDMAP_SEND_SE_INVAL:
+		pr_info("siw: [QP %u]: %s(S_SE_INV, DDP len %d): %08x %08x %08x %08x\n",
+			qp_id, string, ddp_data_len(op, mpa_len),
+			be32_to_cpu(hdr->send_inv.inval_stag),
+			be32_to_cpu(hdr->send_inv.ddp_qn),
+			be32_to_cpu(hdr->send_inv.ddp_msn),
+			be32_to_cpu(hdr->send_inv.ddp_mo));
+		break;
+
+	case RDMAP_TERMINATE:
+		pr_info("siw: [QP %u]: %s(TERM, DDP len %d):\n", qp_id, string,
+			ddp_data_len(op, mpa_len));
+		break;
+
+	default:
+		pr_info("siw: [QP %u]: %s (undefined opcode %d)", qp_id, string,
+			op);
+		break;
+	}
+}
diff --git a/drivers/infiniband/sw/siw/siw_debug.h b/drivers/infiniband/sw/siw/siw_debug.h
new file mode 100644
index 000000000000..2cfe7ce68428
--- /dev/null
+++ b/drivers/infiniband/sw/siw/siw_debug.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
+
+/* Authors: Bernard Metzler <bmt@xxxxxxxxxxxxxx> */
+/* Copyright (c) 2008-2019, IBM Corporation */
+
+#ifndef _SIW_DEBUG_H
+#define _SIW_DEBUG_H
+
+#define siw_dbg(ddev, fmt, ...)                                                \
+	dev_dbg(&(ddev)->base_dev.dev, "cpu%2d %s: " fmt, smp_processor_id(),  \
+		__func__, ##__VA_ARGS__)
+
+#define siw_dbg_qp(qp, fmt, ...)                                               \
+	siw_dbg(qp->sdev, "[QP %u]: " fmt, qp->id, ##__VA_ARGS__)
+
+#define siw_dbg_cq(cq, fmt, ...)                                               \
+	siw_dbg(cq->sdev, "[CQ %u]: " fmt, cq->id, ##__VA_ARGS__)
+
+#define siw_dbg_pd(pd, fmt, ...)                                               \
+	siw_dbg(pd->sdev, "[PD %u]: " fmt, pd->base_pd.res.id, ##__VA_ARGS__)
+
+#define siw_dbg_mem(mem, fmt, ...)                                             \
+	siw_dbg(mem->sdev, "[MEM 0x%08x]: " fmt, mem->stag, ##__VA_ARGS__)
+
+#define siw_dbg_cep(cep, fmt, ...)                                             \
+	siw_dbg(cep->sdev, "[CEP 0x%p]: " fmt, cep, ##__VA_ARGS__)
+
+#ifdef DEBUG_HDR
+
+#define siw_dprint_hdr(hdr, qpn, msg) siw_print_hdr(hdr, qpn, msg)
+
+#else
+
+#define siw_dprint_hdr(hdr, qpn, msg)                                          \
+	do {                                                                   \
+	} while (0)
+
+#endif
+
+#endif
-- 
2.17.2




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux