diff mbox series

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

Message ID 20190526114156.6827-12-bmt@zurich.ibm.com (mailing list archive)
State Superseded
Headers show
Series SIW: Software iWarp RDMA (siw) driver | expand

Commit Message

Bernard Metzler May 26, 2019, 11:41 a.m. UTC
Signed-off-by: Bernard Metzler <bmt@zurich.ibm.com>
---
 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

Comments

Leon Romanovsky June 10, 2019, 7:34 a.m. UTC | #1
On Sun, May 26, 2019 at 01:41:55PM +0200, Bernard Metzler wrote:
> Signed-off-by: Bernard Metzler <bmt@zurich.ibm.com>
> ---
>  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

1. Use Gal's ibdev_* prints.
2. Remove all your custom siw_print_hdr() thing. It belongs to custom
debug kernel which you can use in-house, but not for upstream and
globally distributed code. Our assumption that code works.

Thanks
Bernard Metzler June 11, 2019, 3:23 p.m. UTC | #2
-----"Leon Romanovsky" <leon@kernel.org> wrote: -----

>To: "Bernard Metzler" <bmt@zurich.ibm.com>
>From: "Leon Romanovsky" <leon@kernel.org>
>Date: 06/10/2019 09:35AM
>Cc: linux-rdma@vger.kernel.org
>Subject: [EXTERNAL] Re: [PATCH for-next v1 11/12] SIW debugging
>
>On Sun, May 26, 2019 at 01:41:55PM +0200, Bernard Metzler wrote:
>> Signed-off-by: Bernard Metzler <bmt@zurich.ibm.com>
>> ---
>>  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
>
>1. Use Gal's ibdev_* prints.

I'll have a look now. 

>2. Remove all your custom siw_print_hdr() thing. It belongs to custom
>debug kernel which you can use in-house, but not for upstream and
>globally distributed code. Our assumption that code works.

OK will remove. Have to say siw initially targeted RDMA application
debugging, that's why it had that many debug statements. slowly cleaning up ;)

>
>Thanks
>
>
diff mbox series

Patch

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@zurich.ibm.com> */
+/* 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@zurich.ibm.com> */
+/* 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