diff mbox series

[v5,12/13] SIW debugging

Message ID 20190219100903.15408-13-bmt@zurich.ibm.com (mailing list archive)
State Superseded
Delegated to: Jason Gunthorpe
Headers show
Series SIW: Request for Comments | expand

Commit Message

Bernard Metzler Feb. 19, 2019, 10:09 a.m. UTC
Signed-off-by: Bernard Metzler <bmt@zurich.ibm.com>
---
 drivers/infiniband/sw/siw/siw_debug.c | 124 ++++++++++++++++++++++++++
 drivers/infiniband/sw/siw/siw_debug.h |  69 ++++++++++++++
 2 files changed, 193 insertions(+)
 create mode 100644 drivers/infiniband/sw/siw/siw_debug.c
 create mode 100644 drivers/infiniband/sw/siw/siw_debug.h

Comments

Gal Pressman Feb. 28, 2019, 11:57 a.m. UTC | #1
On 19-Feb-19 12:09, Bernard Metzler wrote:
> Signed-off-by: Bernard Metzler <bmt@zurich.ibm.com>
> ---
>  drivers/infiniband/sw/siw/siw_debug.c | 124 ++++++++++++++++++++++++++
>  drivers/infiniband/sw/siw/siw_debug.h |  69 ++++++++++++++
>  2 files changed, 193 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..a0c0c67378c9
> --- /dev/null
> +++ b/drivers/infiniband/sw/siw/siw_debug.c
> @@ -0,0 +1,124 @@
> +// SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause
> +/*
> + * Software iWARP device driver
> + *
> + * Authors: Bernard Metzler <bmt@zurich.ibm.com>
> + *
> + * Copyright (c) 2008-2018, IBM Corporation
> + *
> + * This software is available to you under a choice of one of two
> + * licenses. You may choose to be licensed under the terms of the GNU
> + * General Public License (GPL) Version 2, available from the file
> + * COPYING in the main directory of this source tree, or the
> + * BSD license below:
> + *
> + *   Redistribution and use in source and binary forms, with or
> + *   without modification, are permitted provided that the following
> + *   conditions are met:
> + *
> + *   - Redistributions of source code must retain the above copyright notice,
> + *     this list of conditions and the following disclaimer.
> + *
> + *   - Redistributions in binary form must reproduce the above copyright
> + *     notice, this list of conditions and the following disclaimer in the
> + *     documentation and/or other materials provided with the distribution.
> + *
> + *   - Neither the name of IBM nor the names of its contributors may be
> + *     used to endorse or promote products derived from this software without
> + *     specific prior written permission.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
> + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
> + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
> + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> + * SOFTWARE.
> + */
> +
> +#include <linux/types.h>
> +#include <linux/printk.h>
> +
> +#include "siw.h"
> +
> +void siw_print_hdr(union iwarp_hdr *hdr, int qp_id, char *string)
> +{
> +	enum rdma_opcode op = __rdmap_opcode(&hdr->ctrl);
> +	u16 mpa_len = be16_to_cpu(hdr->ctrl.mpa_len);
> +
> +	switch (op) {
> +

No need for blank lines between cases.

> +	case RDMAP_RDMA_WRITE:
> +		pr_info("siw: [QP %d]: %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 %d]: %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 %d]: %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 %d]: %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 %d]: %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 %d]: %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 %d]: %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 %d]: %s(TERM, DDP len %d):\n", qp_id, string,
> +			ddp_data_len(op, mpa_len));
> +		break;
> +
> +	default:
> +		pr_info("siw: [QP %d]: %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..662dfb275b75
> --- /dev/null
> +++ b/drivers/infiniband/sw/siw/siw_debug.h
> @@ -0,0 +1,69 @@
> +// SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause
> +/*
> + * Software iWARP device driver
> + *
> + * Authors: Bernard Metzler <bmt@zurich.ibm.com>
> + *
> + *
> + * Copyright (c) 2008-2018, IBM Corporation
> + *
> + * This software is available to you under a choice of one of two
> + * licenses. You may choose to be licensed under the terms of the GNU
> + * General Public License (GPL) Version 2, available from the file
> + * COPYING in the main directory of this source tree, or the
> + * BSD license below:
> + *
> + *   Redistribution and use in source and binary forms, with or
> + *   without modification, are permitted provided that the following
> + *   conditions are met:
> + *
> + *   - Redistributions of source code must retain the above copyright notice,
> + *     this list of conditions and the following disclaimer.
> + *
> + *   - Redistributions in binary form must reproduce the above copyright
> + *     notice, this list of conditions and the following disclaimer in the
> + *     documentation and/or other materials provided with the distribution.
> + *
> + *   - Neither the name of IBM nor the names of its contributors may be
> + *     used to endorse or promote products derived from this software without
> + *     specific prior written permission.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
> + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
> + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
> + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> + * SOFTWARE.
> + */
> +
> +#ifndef _SIW_DEBUG_H
> +#define _SIW_DEBUG_H
> +
> +extern void siw_print_hdr(union iwarp_hdr *hdr, int id, char *msg);

Is extern really needed here?

> +
> +#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->hdr.sdev, "[QP %d]: " fmt, QP_ID(qp), ##__VA_ARGS__)
> +
> +#define siw_dbg_cep(cep, fmt, ...) \
> +	siw_dbg(cep->sdev, "[CEP 0x%p]: " fmt, cep, ##__VA_ARGS__)
> +
> +#define siw_dbg_obj(obj, fmt, ...) \
> +	siw_dbg(obj->hdr.sdev, "[OBJ ID %d]: " fmt, obj->hdr.id, ##__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
> 

Reviewed-by: Gal Pressman <galpress@amazon.com>
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..a0c0c67378c9
--- /dev/null
+++ b/drivers/infiniband/sw/siw/siw_debug.c
@@ -0,0 +1,124 @@ 
+// SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause
+/*
+ * Software iWARP device driver
+ *
+ * Authors: Bernard Metzler <bmt@zurich.ibm.com>
+ *
+ * Copyright (c) 2008-2018, IBM Corporation
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * BSD license below:
+ *
+ *   Redistribution and use in source and binary forms, with or
+ *   without modification, are permitted provided that the following
+ *   conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of IBM nor the names of its contributors may be
+ *     used to endorse or promote products derived from this software without
+ *     specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/types.h>
+#include <linux/printk.h>
+
+#include "siw.h"
+
+void siw_print_hdr(union iwarp_hdr *hdr, int qp_id, char *string)
+{
+	enum rdma_opcode op = __rdmap_opcode(&hdr->ctrl);
+	u16 mpa_len = be16_to_cpu(hdr->ctrl.mpa_len);
+
+	switch (op) {
+
+	case RDMAP_RDMA_WRITE:
+		pr_info("siw: [QP %d]: %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 %d]: %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 %d]: %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 %d]: %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 %d]: %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 %d]: %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 %d]: %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 %d]: %s(TERM, DDP len %d):\n", qp_id, string,
+			ddp_data_len(op, mpa_len));
+		break;
+
+	default:
+		pr_info("siw: [QP %d]: %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..662dfb275b75
--- /dev/null
+++ b/drivers/infiniband/sw/siw/siw_debug.h
@@ -0,0 +1,69 @@ 
+// SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause
+/*
+ * Software iWARP device driver
+ *
+ * Authors: Bernard Metzler <bmt@zurich.ibm.com>
+ *
+ *
+ * Copyright (c) 2008-2018, IBM Corporation
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * BSD license below:
+ *
+ *   Redistribution and use in source and binary forms, with or
+ *   without modification, are permitted provided that the following
+ *   conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of IBM nor the names of its contributors may be
+ *     used to endorse or promote products derived from this software without
+ *     specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _SIW_DEBUG_H
+#define _SIW_DEBUG_H
+
+extern void siw_print_hdr(union iwarp_hdr *hdr, int id, char *msg);
+
+#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->hdr.sdev, "[QP %d]: " fmt, QP_ID(qp), ##__VA_ARGS__)
+
+#define siw_dbg_cep(cep, fmt, ...) \
+	siw_dbg(cep->sdev, "[CEP 0x%p]: " fmt, cep, ##__VA_ARGS__)
+
+#define siw_dbg_obj(obj, fmt, ...) \
+	siw_dbg(obj->hdr.sdev, "[OBJ ID %d]: " fmt, obj->hdr.id, ##__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