[PATCH for-next v1 11/12] SIW debugging

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

 



Signed-off-by: Bernard Metzler <bmt@xxxxxxxxxxxxxx>
---
 drivers/infiniband/sw/siw/siw_debug.c | 102 ++++++++++++++++++++++++++
 drivers/infiniband/sw/siw/siw_debug.h |  35 +++++++++
 2 files changed, 137 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..b96cbe10700c
--- /dev/null
+++ b/drivers/infiniband/sw/siw/siw_debug.c
@@ -0,0 +1,102 @@
+// 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))
+
+char *siw_print_hdr(union iwarp_hdr *hdr, int qp_id, char *string)
+{
+	static char buf[128];
+	enum rdma_opcode op = __rdmap_get_opcode(&hdr->ctrl);
+	u16 mpa_len = be16_to_cpu(hdr->ctrl.mpa_len);
+	u16 ctrl = be16_to_cpu(hdr->ctrl.ddp_rdmap_ctrl);
+
+	switch (op) {
+	case RDMAP_RDMA_WRITE:
+		sprintf(buf,
+			"[QP %u]: %s(WRITE, DDP len %d, ctrl %02x): %08x %016llx",
+			qp_id, string, ddp_data_len(op, mpa_len), ctrl,
+			hdr->rwrite.sink_stag, hdr->rwrite.sink_to);
+		break;
+
+	case RDMAP_RDMA_READ_REQ:
+		sprintf(buf,
+			"[QP %u]: %s(RREQ, DDP len %d, ctrl %02x): %08x %08x %08x %08x %016llx %08x %08x %016llx",
+			qp_id, string, ddp_data_len(op, mpa_len), ctrl,
+			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:
+		sprintf(buf,
+			"[QP %u]: %s(RRESP, DDP len %d, ctrl %02x): %08x %016llx",
+			qp_id, string, ddp_data_len(op, mpa_len), ctrl,
+			be32_to_cpu(hdr->rresp.sink_stag),
+			be64_to_cpu(hdr->rresp.sink_to));
+		break;
+
+	case RDMAP_SEND:
+		sprintf(buf,
+			"[QP %u]: %s(SEND, DDP len %d, ctrl %02x): %08x %08x %08x",
+			qp_id, string, ddp_data_len(op, mpa_len), ctrl,
+			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:
+		sprintf(buf,
+			"[QP %u]: %s(S_INV, DDP len %d, ctrl %02x): %08x %08x %08x %08x",
+			qp_id, string, ddp_data_len(op, mpa_len), ctrl,
+			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:
+		sprintf(buf,
+			"[QP %u]: %s(S_SE, DDP len %d, ctrl %02x): %08x %08x %08x",
+			qp_id, string, ddp_data_len(op, mpa_len), ctrl,
+			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:
+		sprintf(buf,
+			"[QP %u]: %s(S_SE_INV, DDP len %d, ctrl %02x): %08x %08x %08x %08x",
+			qp_id, string, ddp_data_len(op, mpa_len), ctrl,
+			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:
+		sprintf(buf,
+			"[QP %u]: %s(TERM, DDP len %d, ctrl %02x):",
+			qp_id, string, ddp_data_len(op, mpa_len), ctrl);
+		break;
+
+	default:
+		sprintf(buf,
+			"[QP %u]: %s (undefined opcode %d)", qp_id, string,
+			op);
+		break;
+	}
+	return buf;
+}
diff --git a/drivers/infiniband/sw/siw/siw_debug.h b/drivers/infiniband/sw/siw/siw_debug.h
new file mode 100644
index 000000000000..2759028ba446
--- /dev/null
+++ b/drivers/infiniband/sw/siw/siw_debug.h
@@ -0,0 +1,35 @@
+/* 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
+
+extern char *siw_print_hdr(union iwarp_hdr *hdr, int qp_id, char *string);
+
+#define siw_dbg(ibdev, fmt, ...)                                               \
+	dev_dbg(&(ibdev)->dev, "cpu%2d %s: " fmt, smp_processor_id(),          \
+		__func__, ##__VA_ARGS__)
+
+#define siw_dbg_qp(qp, fmt, ...)                                               \
+	siw_dbg(&qp->sdev->base_dev,                                           \
+		  "[QP %u]: " fmt, qp_id(qp), ##__VA_ARGS__)
+
+#define siw_dbg_cq(cq, fmt, ...)                                               \
+	siw_dbg(cq->base_cq.device, "[CQ %u]: " fmt, cq->id, ##__VA_ARGS__)
+
+#define siw_dbg_pd(pd, fmt, ...)                                               \
+	siw_dbg(pd->device, "[PD %u]: " fmt, pd->res.id, ##__VA_ARGS__)
+
+#define siw_dbg_mem(mem, fmt, ...)                                             \
+	siw_dbg(&mem->sdev->base_dev,                                          \
+		"[MEM 0x%08x]: " fmt, mem->stag, ##__VA_ARGS__)
+
+#define siw_dbg_cep(cep, fmt, ...)                                             \
+	siw_dbg(&cep->sdev->base_dev, "[CEP 0x%p]: " fmt, cep, ##__VA_ARGS__)
+
+#define siw_dbg_pkt(hdr, qp, fmt)                                              \
+	siw_dbg(&qp->sdev->base_dev, "%s ", siw_print_hdr(hdr, qp_id(qp), fmt))
+
+#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